]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fixes, fixes, fixes:
authorRafael Fernández López <ereslibre@kde.org>
Tue, 25 Dec 2007 17:37:41 +0000 (17:37 +0000)
committerRafael Fernández López <ereslibre@kde.org>
Tue, 25 Dec 2007 17:37:41 +0000 (17:37 +0000)
* Better item appearance (selected and hover) on systemsettings.
* Keyboard navigation improved in dolphin, and now is possible to navigate with keyboard in systemsettings (it was not possible before).
* No rubberband or multiple selection on systemsettings.
* Single or double click for item activation depends on the system state on systemsettings.
* On KCategoryDrawer now titles are drawn with more margin, as happens on DolphinCategoryDrawer. This gives more consistency to its look.

CCMAIL: wstephenson@kde.org

svn path=/trunk/KDE/kdebase/apps/; revision=752784

src/kcategorizedview.cpp
src/kcategorydrawer.cpp

index 6fa7632f2731445b33f96e8223642589ec473c2a..8a0b3c8c570eca766407409f1e657c17ca7acbd7 100644 (file)
@@ -365,19 +365,21 @@ void KCategorizedView::Private::drawNewCategory(const QModelIndex &index,
 
     optionCopy.state &= ~QStyle::State_Selected;
 
-    if ((category == hoveredCategory) && !mouseButtonPressed)
-    {
-        optionCopy.state |= QStyle::State_MouseOver;
-    }
-    else if ((category == hoveredCategory) && mouseButtonPressed)
-    {
-        QPoint initialPressPosition = listView->viewport()->mapFromGlobal(QCursor::pos());
-        initialPressPosition.setY(initialPressPosition.y() + listView->verticalOffset());
-        initialPressPosition.setX(initialPressPosition.x() + listView->horizontalOffset());
-
-        if (initialPressPosition == this->initialPressPosition)
+    if ((listView->selectionMode() != SingleSelection) && (listView->selectionMode() != NoSelection)) {
+        if ((category == hoveredCategory) && !mouseButtonPressed)
         {
-            optionCopy.state |= QStyle::State_Selected;
+            optionCopy.state |= QStyle::State_MouseOver;
+        }
+        else if ((category == hoveredCategory) && mouseButtonPressed)
+        {
+            QPoint initialPressPosition = listView->viewport()->mapFromGlobal(QCursor::pos());
+            initialPressPosition.setY(initialPressPosition.y() + listView->verticalOffset());
+            initialPressPosition.setX(initialPressPosition.x() + listView->horizontalOffset());
+
+            if (initialPressPosition == this->initialPressPosition)
+            {
+                optionCopy.state |= QStyle::State_Selected;
+            }
         }
     }
 
@@ -774,39 +776,42 @@ void KCategorizedView::paintEvent(QPaintEvent *event)
         else if (intersectedInThePast)
         {
             break; // the visible area has been finished, we don't need to keep asking, the rest won't intersect
-                   // this is doable because we know that categories are correctly ordered on the list
+                // this is doable because we know that categories are correctly ordered on the list
         }
     }
 
-    if (d->mouseButtonPressed && !d->isDragging)
+    if ((selectionMode() != SingleSelection) && (selectionMode() != NoSelection))
     {
-        QPoint start, end, initialPressPosition;
+        if (d->mouseButtonPressed && !d->isDragging)
+        {
+            QPoint start, end, initialPressPosition;
 
-        initialPressPosition = d->initialPressPosition;
+            initialPressPosition = d->initialPressPosition;
 
-        initialPressPosition.setY(initialPressPosition.y() - verticalOffset());
-        initialPressPosition.setX(initialPressPosition.x() - horizontalOffset());
+            initialPressPosition.setY(initialPressPosition.y() - verticalOffset());
+            initialPressPosition.setX(initialPressPosition.x() - horizontalOffset());
 
-        if (d->initialPressPosition.x() > d->mousePosition.x() ||
-            d->initialPressPosition.y() > d->mousePosition.y())
-        {
-            start = d->mousePosition;
-            end = initialPressPosition;
-        }
-        else
-        {
-            start = initialPressPosition;
-            end = d->mousePosition;
-        }
+            if (d->initialPressPosition.x() > d->mousePosition.x() ||
+                d->initialPressPosition.y() > d->mousePosition.y())
+            {
+                start = d->mousePosition;
+                end = initialPressPosition;
+            }
+            else
+            {
+                start = initialPressPosition;
+                end = d->mousePosition;
+            }
 
-        QStyleOptionRubberBand yetAnotherOption;
-        yetAnotherOption.initFrom(this);
-        yetAnotherOption.shape = QRubberBand::Rectangle;
-        yetAnotherOption.opaque = false;
-        yetAnotherOption.rect = QRect(start, end).intersected(viewport()->rect().adjusted(-16, -16, 16, 16));
-        painter.save();
-        style()->drawControl(QStyle::CE_RubberBand, &yetAnotherOption, &painter);
-        painter.restore();
+            QStyleOptionRubberBand yetAnotherOption;
+            yetAnotherOption.initFrom(this);
+            yetAnotherOption.shape = QRubberBand::Rectangle;
+            yetAnotherOption.opaque = false;
+            yetAnotherOption.rect = QRect(start, end).intersected(viewport()->rect().adjusted(-16, -16, 16, 16));
+            painter.save();
+            style()->drawControl(QStyle::CE_RubberBand, &yetAnotherOption, &painter);
+            painter.restore();
+        }
     }
 
     if (d->isDragging && !d->dragLeftViewport)
@@ -1090,7 +1095,8 @@ void KCategorizedView::mouseReleaseEvent(QMouseEvent *event)
     initialPressPosition.setY(initialPressPosition.y() + verticalOffset());
     initialPressPosition.setX(initialPressPosition.x() + horizontalOffset());
 
-    if (initialPressPosition == d->initialPressPosition)
+    if ((selectionMode() != SingleSelection) && (selectionMode() != NoSelection) &&
+        (initialPressPosition == d->initialPressPosition))
     {
         foreach(const QString &category, d->categories)
         {
@@ -1570,7 +1576,8 @@ void KCategorizedView::currentChanged(const QModelIndex &current,
     if (!elementsPerRow)
         elementsPerRow++;
 
-    d->forcedSelectionPosition = d->elementsInfo[current.row()].relativeOffsetToCategory % elementsPerRow;
+    if (d->mouseButtonPressed || d->rightMouseButtonPressed)
+        d->forcedSelectionPosition = d->elementsInfo[current.row()].relativeOffsetToCategory % elementsPerRow;
 
     QListView::currentChanged(current, previous);
 }
index d0c671915459f12a38e166c92d35f4b565943383..53cf059f1f12e522e2899c678e25b99cd03d162f 100644 (file)
@@ -23,6 +23,7 @@
 #include <QPainter>
 #include <QStyleOption>
 
+#include <kiconloader.h>
 #include <kcategorizedsortfilterproxymodel.h>
 
 KCategoryDrawer::KCategoryDrawer()
@@ -61,6 +62,17 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
     opt.direction = option.direction;
     opt.text = category;
 
+    int iconSize = KIconLoader::global()->currentSize(KIconLoader::Small);
+
+    if (option.direction == Qt::LeftToRight)
+    {
+        opt.rect.setLeft(opt.rect.left() + (iconSize / 4));
+    }
+    else
+    {
+        opt.rect.setRight(opt.rect.width() - (iconSize / 4));
+    }
+
     if (option.state & QStyle::State_Selected)
     {
         QColor selected = option.palette.color(QPalette::Highlight);
@@ -113,7 +125,7 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
 
     painter->setPen(color);
 
-    painter->drawText(option.rect, Qt::AlignVCenter | Qt::AlignLeft,
+    painter->drawText(opt.rect, Qt::AlignVCenter | Qt::AlignLeft,
     metrics.elidedText(category, Qt::ElideRight, option.rect.width()));
 
     painter->restore();