From: Peter Penz Date: Thu, 7 May 2009 16:54:08 +0000 (+0000) Subject: increase the size of the selection toggle corresponding to the item size X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/b8fa103e8a7e9942f472f6e5c931a0db31263568 increase the size of the selection toggle corresponding to the item size BUG: 191629 svn path=/trunk/KDE/kdebase/apps/; revision=964924 --- diff --git a/src/selectionmanager.cpp b/src/selectionmanager.cpp index 7a7034d22..129e7e2ca 100644 --- a/src/selectionmanager.cpp +++ b/src/selectionmanager.cpp @@ -81,11 +81,21 @@ void SelectionManager::slotEntered(const QModelIndex& index) const QRect rect = m_view->visualRect(index); + // align the toggle on the bottom left of the item const int gap = 2; const int x = rect.left() + gap; const int y = rect.top() + gap; m_toggle->move(QPoint(x, y)); + // increase the size of the toggle for large items + if (rect.height() >= KIconLoader::SizeEnormous) { + m_toggle->resize(KIconLoader::SizeMedium, KIconLoader::SizeMedium); + } else if (rect.height() >= KIconLoader::SizeHuge) { + m_toggle->resize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium); + } else { + m_toggle->resize(KIconLoader::SizeSmall, KIconLoader::SizeSmall); + } + QItemSelectionModel* selModel = m_view->selectionModel(); m_toggle->setChecked(selModel->isSelected(index)); m_toggle->show(); diff --git a/src/selectiontoggle.cpp b/src/selectiontoggle.cpp index 5c573811e..8a77da0d3 100644 --- a/src/selectiontoggle.cpp +++ b/src/selectiontoggle.cpp @@ -149,6 +149,12 @@ void SelectionToggle::mouseReleaseEvent(QMouseEvent* event) m_leftMouseButtonPressed = (event->buttons() & Qt::LeftButton); } +void SelectionToggle::resizeEvent(QResizeEvent* event) +{ + QAbstractButton::resizeEvent(event); + setIconOverlay(isChecked()); +} + void SelectionToggle::paintEvent(QPaintEvent* event) { QPainter painter(this); @@ -206,7 +212,7 @@ void SelectionToggle::setIconOverlay(bool checked) const char* icon = checked ? "list-remove" : "list-add"; m_icon = KIconLoader::global()->loadIcon(icon, KIconLoader::NoGroup, - KIconLoader::SizeSmall); + qMin(width(), height())); update(); } diff --git a/src/selectiontoggle.h b/src/selectiontoggle.h index 705f9a6e6..5519272b3 100644 --- a/src/selectiontoggle.h +++ b/src/selectiontoggle.h @@ -62,6 +62,7 @@ protected: virtual void leaveEvent(QEvent* event); virtual void mousePressEvent(QMouseEvent* event); virtual void mouseReleaseEvent(QMouseEvent* event); + virtual void resizeEvent(QResizeEvent* event); virtual void paintEvent(QPaintEvent* event); private slots: