┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2007-12-25 17:37:41 +0000
committerRafael Fernández López <[email protected]>2007-12-25 17:37:41 +0000
commite4170c1910ad91fd31bc64edfab17ddc814411d5 (patch)
tree03a3c74328dcf47536622c32e81f9802d1909d54 /src
parent8ded05f86d425ede250aa2ee3ed6b5fbc87e37f9 (diff)
Fixes, fixes, fixes:
* 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: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=752784
Diffstat (limited to 'src')
-rw-r--r--src/kcategorizedview.cpp85
-rw-r--r--src/kcategorydrawer.cpp14
2 files changed, 59 insertions, 40 deletions
diff --git a/src/kcategorizedview.cpp b/src/kcategorizedview.cpp
index 6fa7632f2..8a0b3c8c5 100644
--- a/src/kcategorizedview.cpp
+++ b/src/kcategorizedview.cpp
@@ -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);
}
diff --git a/src/kcategorydrawer.cpp b/src/kcategorydrawer.cpp
index d0c671915..53cf059f1 100644
--- a/src/kcategorydrawer.cpp
+++ b/src/kcategorydrawer.cpp
@@ -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();