From 5c25b8675ab8caa80de7d952b9a16c1dd7957e8b Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 16 Sep 2013 19:30:34 +0200 Subject: [PATCH] a very primitive dashboard right now we have a single view, that gets brought to front and the wallpaper made translucent. probably it will eventually need splitting the walppaper and the widgets in two separate views, but needs a more complex logic --- src/shell/desktopview.cpp | 27 +++++++++++++++++++ src/shell/desktopview.h | 2 ++ .../desktop/contents/views/Desktop.qml | 2 +- src/shell/shellcorona.cpp | 14 ++++++++-- src/shell/shellcorona.h | 2 +- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/shell/desktopview.cpp b/src/shell/desktopview.cpp index 792243d01..8b921d406 100644 --- a/src/shell/desktopview.cpp +++ b/src/shell/desktopview.cpp @@ -81,6 +81,33 @@ void DesktopView::setFillScreen(bool fillScreen) emit fillScreenChanged(); } +void DesktopView::setDashboardShown(bool shown) +{ + if (shown) { + if (m_stayBehind) { + KWindowSystem::setType(winId(), NET::Normal); + } + raise(); + KWindowSystem::raiseWindow(winId()); + + QObject *wpGraphicObject = containment()->property("wallpaperGraphicsObject").value(); + if (wpGraphicObject) { + wpGraphicObject->setProperty("opacity", 0.3); + } + } else { + if (m_stayBehind) { + KWindowSystem::setType(winId(), NET::Desktop); + } + lower(); + KWindowSystem::lowerWindow(winId()); + + QObject *wpGraphicObject = containment()->property("wallpaperGraphicsObject").value(); + if (wpGraphicObject) { + wpGraphicObject->setProperty("opacity", 1); + } + } +} + /* void DesktopView::showConfigurationInterface(Plasma::Applet *applet) { diff --git a/src/shell/desktopview.h b/src/shell/desktopview.h index f7cc6044e..58315a345 100644 --- a/src/shell/desktopview.h +++ b/src/shell/desktopview.h @@ -42,6 +42,8 @@ public: bool fillScreen() const; void setFillScreen(bool fillScreen); + void setDashboardShown(bool shown); + protected Q_SLOTS: /** * It will be called when the configuration is requested diff --git a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml index 71c033de3..cf15d67d9 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml @@ -24,7 +24,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore Rectangle { id: root - color: "black" + color: Qt.rgba(0, 0, 0, 0.2) width: 1024 height: 768 diff --git a/src/shell/shellcorona.cpp b/src/shell/shellcorona.cpp index 172d408ba..79c269de3 100644 --- a/src/shell/shellcorona.cpp +++ b/src/shell/shellcorona.cpp @@ -98,9 +98,10 @@ ShellCorona::ShellCorona(QObject *parent) QAction *dashboardAction = actions()->add("show dashboard"); QObject::connect(dashboardAction, &QAction::triggered, - this, &ShellCorona::toggleDashboard); + this, &ShellCorona::setDashboardShown); dashboardAction->setText(i18n("Show Dashboard")); dashboardAction->setAutoRepeat(true); + dashboardAction->setCheckable(true); dashboardAction->setIcon(QIcon::fromTheme("dashboard-show")); dashboardAction->setData(Plasma::Types::ControlAction); dashboardAction->setShortcut(QKeySequence("ctrl+f12")); @@ -428,9 +429,18 @@ void ShellCorona::syncAppConfig() applicationConfig()->sync(); } -void ShellCorona::toggleDashboard() +void ShellCorona::setDashboardShown(bool show) { qDebug() << "TODO: Toggling dashboard view"; + + QAction *dashboardAction = actions()->action("show dashboard"); + + if (dashboardAction) { + dashboardAction->setText(show ? i18n("Hide Dashboard") : i18n("Show Dashboard")); + } + foreach (DesktopView *view, d->views) { + view->setDashboardShown(show); + } } void ShellCorona::printScriptError(const QString &error) diff --git a/src/shell/shellcorona.h b/src/shell/shellcorona.h index 0e3f3ce9a..17c00848a 100644 --- a/src/shell/shellcorona.h +++ b/src/shell/shellcorona.h @@ -120,7 +120,7 @@ private Q_SLOTS: void handleContainmentAdded(Plasma::Containment *c); void showWidgetExplorer(); void syncAppConfig(); - void toggleDashboard(); + void setDashboardShown(bool show); private: class Private;