diff --git a/containments/homescreen/CMakeLists.txt b/containments/homescreen/CMakeLists.txt index e3640903..11eafabd 100644 --- a/containments/homescreen/CMakeLists.txt +++ b/containments/homescreen/CMakeLists.txt @@ -16,6 +16,7 @@ target_link_libraries(plasma_containment_phone_homescreen KF5::KIOGui KF5::Notifications KF5::WaylandClient + KF5::WindowSystem ) diff --git a/containments/homescreen/homescreen.cpp b/containments/homescreen/homescreen.cpp index f4d68994..983f77be 100644 --- a/containments/homescreen/homescreen.cpp +++ b/containments/homescreen/homescreen.cpp @@ -5,6 +5,7 @@ #include "homescreen.h" +#include #include #include #include @@ -12,8 +13,8 @@ HomeScreen::HomeScreen(QObject *parent, const QVariantList &args) : Plasma::Containment(parent, args) { - setHasConfigurationInterface(true); + connect(KWindowSystem::self(), &KWindowSystem::showingDesktopChanged, this, &HomeScreen::showingDesktopChanged); } HomeScreen::~HomeScreen() = default; @@ -42,6 +43,16 @@ void HomeScreen::stackAfter(QQuickItem *item1, QQuickItem *item2) item1->stackAfter(item2); } +bool HomeScreen::showingDesktop() const +{ + return KWindowSystem::showingDesktop(); +} + +void HomeScreen::setShowingDesktop(bool showingDesktop) +{ + KWindowSystem::setShowingDesktop(showingDesktop); +} + K_PLUGIN_CLASS_WITH_JSON(HomeScreen, "metadata.json") #include "homescreen.moc" diff --git a/containments/homescreen/homescreen.h b/containments/homescreen/homescreen.h index d378b68d..daefa497 100644 --- a/containments/homescreen/homescreen.h +++ b/containments/homescreen/homescreen.h @@ -16,6 +16,7 @@ class FavoritesModel; class HomeScreen : public Plasma::Containment { Q_OBJECT + Q_PROPERTY(bool showingDesktop READ showingDesktop WRITE setShowingDesktop NOTIFY showingDesktopChanged) public: HomeScreen(QObject *parent, const QVariantList &args); @@ -23,10 +24,15 @@ public: void configChanged() override; + bool showingDesktop() const; + void setShowingDesktop(bool showingDesktop); Q_INVOKABLE void stackBefore(QQuickItem *item1, QQuickItem *item2); Q_INVOKABLE void stackAfter(QQuickItem *item1, QQuickItem *item2); +Q_SIGNALS: + void showingDesktopChanged(bool showingDesktop); + protected: // void configChanged() override; diff --git a/containments/homescreen/package/contents/ui/main.qml b/containments/homescreen/package/contents/ui/main.qml index 6b64cb7f..75564a42 100644 --- a/containments/homescreen/package/contents/ui/main.qml +++ b/containments/homescreen/package/contents/ui/main.qml @@ -113,6 +113,23 @@ FocusScope { } } + Plasmoid.onActivated: { + console.log("Triggered!", plasmoid.nativeInterface.showingDesktop) + + // there's a couple of steps: + // - minimize windows + // - open app drawer + // - restore windows + if (!plasmoid.nativeInterface.showingDesktop) { + plasmoid.nativeInterface.showingDesktop = true + } else if (appDrawer.status !== HomeScreenComponents.AppDrawer.Status.Open) { + mainFlickable.currentIndex = 0 + appDrawer.open() + } else { + plasmoid.nativeInterface.showingDesktop = false + appDrawer.close() + } + } HomeScreenComponents.AppDrawer { id: appDrawer anchors.fill: parent diff --git a/containments/homescreen/package/metadata.desktop b/containments/homescreen/package/metadata.desktop index ab1576e4..a5acb85f 100644 --- a/containments/homescreen/package/metadata.desktop +++ b/containments/homescreen/package/metadata.desktop @@ -49,3 +49,4 @@ X-KDE-PluginInfo-Name=org.kde.phone.homescreen X-KDE-PluginInfo-Version= X-KDE-PluginInfo-Website= X-Plasma-MainScript=ui/main.qml +X-Plasma-Provides=org.kde.plasma.launchermenu diff --git a/shell/contents/layout.js b/shell/contents/layout.js index 57452667..75b77663 100644 --- a/shell/contents/layout.js +++ b/shell/contents/layout.js @@ -3,6 +3,8 @@ for (var j = 0; j < desktopsArray.length; j++) { desktopsArray[j].wallpaperPlugin = "org.kde.image"; } desktopsArray[0].addWidget("org.kde.phone.krunner", 0, 0, screenGeometry(0).width, 20) +desktopsArray[0].currentConfigGroup = ["Shortcuts"] +desktopsArray[0].writeConfig("global", "Meta+F1") // keep this list in sync with shell/contents/updates/panelsfix.js var panel = new Panel("org.kde.phone.panel");