]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/selectionmanager.cpp
* Use the height of the icon as factor for the toggle size. This prevents that the...
[dolphin.git] / src / selectionmanager.cpp
index 1722bc3c5d20f7ba39a0f0899187686a29dce7fd..7dd07e63efa42337db2fb2759a0fee978bfdfbd0 100644 (file)
@@ -27,6 +27,7 @@
 #include <QAbstractButton>
 #include <QAbstractItemView>
 #include <QAbstractProxyModel>
+#include <QApplication>
 #include <QModelIndex>
 #include <QPainter>
 #include <QPaintEvent>
@@ -62,7 +63,10 @@ void SelectionManager::reset()
 void SelectionManager::slotEntered(const QModelIndex& index)
 {
     m_toggle->hide();
-    if (index.isValid() && (index.column() == DolphinModel::Name)) {
+    const bool showToggle = index.isValid() &&
+                            (index.column() == DolphinModel::Name) &&
+                            (QApplication::mouseButtons() == Qt::NoButton);
+    if (showToggle) {
         m_toggle->setUrl(urlForIndex(index));
 
         if (!m_connected) {
@@ -77,11 +81,22 @@ 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
+        const int height = m_view->iconSize().height();
+        if (height >= KIconLoader::SizeEnormous) {
+            m_toggle->resize(KIconLoader::SizeMedium, KIconLoader::SizeMedium);
+        } else if (height >= KIconLoader::SizeLarge) {
+            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();