Hi,
I have been playing a bit with the Add Widget UI on the plane back from
Akademy and replaced the scroll buttons with a scrollbar. Attached patch
is a first step at it, largely unfinished as I would like to know if you
are interested in getting this integrated before I finish it.
Screenshots:
- Horizontal: http://imagebin.ca/view/NkxkAG.html
- Vertical: http://imagebin.ca/view/XnBxX8vt.html
What do you think?
Aurélien
diff --git a/workspace/libs/plasmagenericshell/abstracticonlist.cpp b/workspace/libs/plasmagenericshell/abstracticonlist.cpp
index 78a1fd1..3141516 100644
--- a/workspace/libs/plasmagenericshell/abstracticonlist.cpp
+++ b/workspace/libs/plasmagenericshell/abstracticonlist.cpp
@@ -37,6 +37,7 @@
#include <Plasma/Containment>
#include <Plasma/Corona>
#include <Plasma/ItemBackground>
+#include <Plasma/ScrollBar>
#include <Plasma/Theme>
#include <Plasma/ToolButton>
@@ -102,6 +103,11 @@ void AbstractIconList::init()
m_downRightArrow->setPreferredSize(IconSize(KIconLoader::Panel), IconSize(KIconLoader::Panel));
m_downRightArrow->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
+ m_scrollBar = new Plasma::ScrollBar(this);
+ m_scrollBar->setOrientation(m_orientation);
+ m_scrollBar->setSingleStep(128);
+ connect(m_scrollBar, SIGNAL(valueChanged(int)), SLOT(scrollListWidget(int)));
+ /*
if (m_orientation == Qt::Horizontal) {
m_upLeftArrow->setIcon(KIcon(m_arrowsSvg->pixmap("left-arrow")));
m_downRightArrow->setIcon(KIcon(m_arrowsSvg->pixmap("right-arrow")));
@@ -113,6 +119,7 @@ void AbstractIconList::init()
m_upLeftArrow->setMaximumSize(-1, IconSize(KIconLoader::Panel));
m_downRightArrow->setMaximumSize(-1, IconSize(KIconLoader::Panel));
}
+ */
connect(m_downRightArrow, SIGNAL(pressed()), this, SLOT(scrollDownRight()));
connect(m_upLeftArrow, SIGNAL(pressed()), this, SLOT(scrollUpLeft()));
@@ -136,6 +143,7 @@ void AbstractIconList::init()
m_appletListWindowWidget->installEventFilter(this);
//layouts
+ /*
m_arrowsLayout = new QGraphicsLinearLayout(m_orientation);
m_arrowsLayout->addItem(m_appletListWindowWidget);
@@ -145,7 +153,14 @@ void AbstractIconList::init()
m_arrowsLayout->setAlignment(m_downRightArrow, Qt::AlignVCenter | Qt::AlignHCenter);
m_arrowsLayout->setAlignment(m_upLeftArrow, Qt::AlignVCenter | Qt::AlignHCenter);
m_arrowsLayout->setAlignment(m_appletListWindowWidget, Qt::AlignVCenter | Qt::AlignHCenter);
-
+ */
+ if (m_orientation == Qt::Horizontal) {
+ m_arrowsLayout = new QGraphicsLinearLayout(Qt::Vertical);
+ } else {
+ m_arrowsLayout = new QGraphicsLinearLayout(Qt::Horizontal);
+ }
+ m_arrowsLayout->addItem(m_appletListWindowWidget);
+ m_arrowsLayout->addItem(m_scrollBar);
//m_hoverIndicator = new Plasma::ItemBackground(m_appletListWindowWidget);
m_hoverIndicator = new Plasma::ItemBackground(m_appletListWidget);
setLayout(m_arrowsLayout);
@@ -344,6 +359,7 @@ void AbstractIconList::updateList()
updateGeometry();
m_hoverIndicator->hide();
resetScroll();
+ updateScrollBar();
}
void AbstractIconList::wheelEvent(QGraphicsSceneWheelEvent *event)
@@ -462,11 +478,30 @@ void AbstractIconList::resetScroll()
manageArrows();
}
+void AbstractIconList::scrollListWidget(int value)
+{
+ qreal pos = -value;
+ if (m_orientation == Qt::Horizontal) {
+ m_appletListWidget->setPos(pos, 0);
+ } else {
+ m_appletListWidget->setPos(0, pos);
+ }
+}
+
+void AbstractIconList::updateScrollBar()
+{
+ int ws = windowSize();
+ m_scrollBar->setPageStep(ws);
+ m_scrollBar->setRange(0, listSize() - ws);
+}
+
void AbstractIconList::manageArrows()
{
qreal list_size = listSize();
qreal window_size = windowSize();
+ updateScrollBar();
+
if (list_size <= window_size || m_currentAppearingAppletsOnList.isEmpty()) {
m_upLeftArrow->setEnabled(false);
m_downRightArrow->setEnabled(false);
diff --git a/workspace/libs/plasmagenericshell/abstracticonlist.h b/workspace/libs/plasmagenericshell/abstracticonlist.h
index cd14cd5..d7dbaf5 100644
--- a/workspace/libs/plasmagenericshell/abstracticonlist.h
+++ b/workspace/libs/plasmagenericshell/abstracticonlist.h
@@ -38,6 +38,7 @@ namespace Plasma
{
class Animation;
class ItemBackground;
+ class ScrollBar;
class ToolButton;
class PLASMAGENERICSHELL_EXPORT AbstractIconList : public QGraphicsWidget
@@ -110,6 +111,8 @@ private:
void wheelEvent(QGraphicsSceneWheelEvent *event);
+ void updateScrollBar();
+
public Q_SLOTS:
void searchTermChanged(const QString &text);
void updateList();
@@ -137,6 +140,7 @@ private Q_SLOTS:
void iconHoverEnter(Plasma::AbstractIcon *icon);
void setSearch();
+ void scrollListWidget(int);
private:
//list containing the applet icons of the filter proxy model
@@ -147,6 +151,7 @@ private:
QGraphicsWidget *m_appletListWindowWidget;
QGraphicsLinearLayout *m_arrowsLayout;
+ Plasma::ScrollBar *m_scrollBar;
Plasma::ToolButton *m_downRightArrow;
Plasma::ToolButton *m_upLeftArrow;
Plasma::Svg *m_arrowsSvg;
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel