summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Kügler <sebas@kde.org>2015-03-05 01:04:47 (GMT)
committerSebastian Kügler <sebas@kde.org>2015-03-05 13:14:15 (GMT)
commitbdb4702179898f07d4301799b29d104506d6e534 (patch)
tree9fff3b44ff34bc742e8e4094010208e82ad43dd0
parent05f20129e65e883d33a910763450e8947eeb97c9 (diff)
Hide pager when there's only one virtual desktop
As discussed during the recent papercut session, hide the pager in the panel when there's only one virtual desktop configured. This reinstates a Plasma 4 feature. REVIEW:122822
-rw-r--r--applets/pager/package/contents/ui/main.qml2
-rw-r--r--applets/pager/plugin/pager.cpp15
-rw-r--r--applets/pager/plugin/pager.h4
3 files changed, 18 insertions, 3 deletions
diff --git a/applets/pager/package/contents/ui/main.qml b/applets/pager/package/contents/ui/main.qml
index e69ab35..51b61b5 100644
--- a/applets/pager/package/contents/ui/main.qml
+++ b/applets/pager/package/contents/ui/main.qml
@@ -46,7 +46,7 @@ Item {
property int dragSwitchDesktopId: -1
anchors.fill: parent
- //visible: repeater.count > 1 // FIXME: re-enable and fix collapsing
+ visible: pager.desktopCount > 1
property color windowActiveOnActiveDesktopColor: theme.textColor
property color windowInactiveOnActiveDesktopColor: theme.textColor
diff --git a/applets/pager/plugin/pager.cpp b/applets/pager/plugin/pager.cpp
index 997db2d..22c6ca2 100644
--- a/applets/pager/plugin/pager.cpp
+++ b/applets/pager/plugin/pager.cpp
@@ -114,6 +114,10 @@ Pager::~Pager()
{
}
+int Pager::desktopCount() const
+{
+ return m_desktopCount;
+}
void Pager::setCurrentDesktop(int desktop)
@@ -327,7 +331,11 @@ void Pager::updateSizes()
ph = m_size.height();
}
- m_preferredSize = QSize(pw, ph);
+ if (m_desktopCount > 1) {
+ m_preferredSize = QSize(pw, ph);
+ } else {
+ m_preferredSize = QSize(1, 1); // 0, 0 doesn't collapse completely, leaves uncanny spacing
+ }
emit preferredSizeChanged();
QRectF itemRect(QPointF(leftMargin, topMargin) , QSizeF(itemWidth, itemHeight));
@@ -437,7 +445,10 @@ void Pager::numberOfDesktopsChanged(int num)
NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout);
m_rows = info.desktopLayoutColumnsRows().height();
- m_desktopCount = num;
+ if (num != m_desktopCount) {
+ m_desktopCount = num;
+ emit desktopCountChanged();
+ }
m_pagerModel->clearDesktopRects();
recalculateGridSizes(m_rows);
diff --git a/applets/pager/plugin/pager.h b/applets/pager/plugin/pager.h
index 0e471c8..78d461d 100644
--- a/applets/pager/plugin/pager.h
+++ b/applets/pager/plugin/pager.h
@@ -45,6 +45,7 @@ class Pager : public QObject
Q_OBJECT
Q_PROPERTY(QObject* model READ model CONSTANT)
Q_PROPERTY(int currentDesktop READ currentDesktop NOTIFY currentDesktopChanged)
+ Q_PROPERTY(int desktopCount READ desktopCount NOTIFY desktopCountChanged)
Q_PROPERTY(bool showWindowIcons READ showWindowIcons WRITE setShowWindowIcons NOTIFY showWindowIconsChanged)
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
Q_PROPERTY(QSizeF size READ size WRITE setSize NOTIFY sizeChanged)
@@ -75,6 +76,8 @@ class Pager : public QObject
int currentDesktop() const { return m_currentDesktop; }
void setCurrentDesktop(int desktop);
+ int desktopCount() const;
+
bool showWindowIcons() const { return m_showWindowIcons; }
void setShowWindowIcons(bool show);
@@ -97,6 +100,7 @@ class Pager : public QObject
Q_SIGNALS:
void currentDesktopChanged();
+ void desktopCountChanged();
void showWindowIconsChanged();
void orientationChanged();
void sizeChanged();