diff --git a/applets/CMakeLists.txt b/applets/CMakeLists.txt --- a/applets/CMakeLists.txt +++ b/applets/CMakeLists.txt @@ -11,4 +11,6 @@ add_subdirectory(showActivityManager) endif() +add_subdirectory(minimizeall) +add_subdirectory(showdesktop) add_subdirectory(kimpanel) diff --git a/applets/minimizeall/CMakeLists.txt b/applets/minimizeall/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/applets/minimizeall/CMakeLists.txt @@ -0,0 +1,2 @@ + +plasma_install_package(package org.kde.plasma.minimizeall) diff --git a/applets/minimizeall/Messages.sh b/applets/minimizeall/Messages.sh new file mode 100644 --- /dev/null +++ b/applets/minimizeall/Messages.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT `find . -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.minimizeall.pot diff --git a/applets/minimizeall/package/contents/config/main.xml b/applets/minimizeall/package/contents/config/main.xml new file mode 100644 --- /dev/null +++ b/applets/minimizeall/package/contents/config/main.xml @@ -0,0 +1,13 @@ + + + + + + + user-desktop + + + diff --git a/applets/minimizeall/package/contents/ui/main.qml b/applets/minimizeall/package/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/applets/minimizeall/package/contents/ui/main.qml @@ -0,0 +1,172 @@ +/* + * Copyright 2015 Sebastian Kügler + * Copyright 2016 Anthony Fieroni + * Copyright 2018 David Edmundson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +import QtQuick 2.7 +import QtQuick.Layouts 1.1 + +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +import org.kde.taskmanager 0.1 as TaskManager + +Item { + id: root + + readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge + || plasmoid.location === PlasmaCore.Types.RightEdge + || plasmoid.location === PlasmaCore.Types.BottomEdge + || plasmoid.location === PlasmaCore.Types.LeftEdge) + + Layout.minimumWidth: units.gridUnit + Layout.minimumHeight: units.gridUnit + + Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 + Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 + + Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation + + Plasmoid.onActivated: toggleActive() + + property bool active: false + property var minimizedClients: [] //list of persistentmodelindexes from task manager model of clients minimised by us + + function activate() { + var clients = [] + for (var i = 0 ; i < tasksModel.count; i++) { + var idx = tasksModel.makeModelIndex(i); + if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsMinimized)) { + tasksModel.requestToggleMinimized(idx); + clients.push(tasksModel.makePersistentModelIndex(i)); + } + } + root.minimizedClients = clients; + root.active = true; + } + + function deactivate() { + root.active = false; + for (var i = 0 ; i < root.minimizedClients.length; i++) { + var idx = root.minimizedClients[i] + //client deleted, do nothing + if (!idx.valid) { + continue; + } + //if the user has restored it already, do nothing + if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsMinimized)) { + continue; + } + tasksModel.requestToggleMinimized(idx); + } + root.minimizedClients = []; + } + + function toggleActive() { + if (root.active) { + deactivate(); + } else { + activate(); + } + } + + TaskManager.TasksModel { + id: tasksModel + sortMode: TaskManager.TasksModel.SortDisabled + groupMode: TaskManager.TasksModel.GroupDisabled + } + + Connections { + target: tasksModel + enabled: root.active + + onActiveTaskChanged: { + if (tasksModel.activeTask.valid) { //to suppress changing focus to non windows, such as the desktop + root.active = false; + root.minimizedClients = []; + } + } + onVirtualDesktopChanged: deactivate() + onActivityChanged: deactivate() + } + + PlasmaCore.FrameSvgItem { + id: expandedItem + anchors.fill: parent + imagePath: "widgets/tabbar" + prefix: { + var prefix; + switch (plasmoid.location) { + case PlasmaCore.Types.LeftEdge: + prefix = "west-active-tab"; + break; + case PlasmaCore.Types.TopEdge: + prefix = "north-active-tab"; + break; + case PlasmaCore.Types.RightEdge: + prefix = "east-active-tab"; + break; + default: + prefix = "south-active-tab"; + } + if (!hasElementPrefix(prefix)) { + prefix = "active-tab"; + } + return prefix; + } + opacity: root.active ? 1 : 0 + Behavior on opacity { + NumberAnimation { + duration: units.shortDuration + easing.type: Easing.InOutQuad + } + } + } + + PlasmaCore.IconItem { + id:icon + source: plasmoid.configuration.icon + active: tooltip.containsMouse + anchors.fill: parent + } + + PlasmaCore.ToolTipArea { + id: tooltip + anchors.fill: parent + mainText : i18n("Minimize Windows") + subText : i18n("Show the desktop by minimizing all windows") + icon : plasmoid.configuration.icon + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: root.toggleActive() + } + //also activate when dragging an item over the plasmoid so a user can easily drag data to the desktop + DropArea { + anchors.fill: parent + onEntered: activateTimer.start() + onExited: activateTimer.stop() + Timer { + id: activateTimer + interval: 250 //to match TaskManager + onTriggered: toggleActive() + } + } + } +} diff --git a/applets/minimizeall/package/metadata.desktop b/applets/minimizeall/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/applets/minimizeall/package/metadata.desktop @@ -0,0 +1,93 @@ +[Desktop Entry] +Name=Minimize all Windows +Name[ca]=Minimitza totes les finestres +Name[ca@valencia]=Minimitza totes les finestres +Name[cs]=Minimalizovat všechna okna +Name[da]=Minimér alle vinduer +Name[de]=Alle Fenster minimieren +Name[el]=Ελαχιστοποίηση όλων των παραθύρων +Name[en_GB]=Minimise all Windows +Name[es]=Minimizar todas las ventanas +Name[et]=Kõigi akende minimeerimine +Name[eu]=Leiho guztiak minimizatu +Name[fi]=Pienennä kaikki ikkunat +Name[fr]=Minimiser toutes les fenêtres +Name[gl]=Minimizar todas as xanelas +Name[he]=מזער את כל החלונות +Name[hu]=Minimalizáló +Name[ia]=Minimisa omne fenestras +Name[id]=Minimize all Windows +Name[it]=Minimizza tutte le finestre +Name[ko]=모든 창 최소화 +Name[lt]=Visų langų sumažinimas +Name[nl]=Alle vensters minimaliseren +Name[nn]=Minimer alle vindauge +Name[pl]=Minimalizacja wszystkich okien +Name[pt]=Minimizar Todas as Janelas +Name[pt_BR]=Minimizar todas as janelas +Name[ru]=Сворачивание всех окон +Name[sk]=Minimalizovať všetky okná +Name[sl]=Skrči vsa okna +Name[sr]=минимизовање свих прозора +Name[sr@ijekavian]=минимизовање свих прозора +Name[sr@ijekavianlatin]=minimizovanje svih prozora +Name[sr@latin]=minimizovanje svih prozora +Name[sv]=Minimera alla fönster +Name[tr]=Tüm Pencereleri Küçült +Name[uk]=Згорнути усі вікна +Name[x-test]=xxMinimize all Windowsxx +Name[zh_CN]=最小化所有窗口 +Name[zh_TW]=最小化所有視窗 +Comment=Shows the desktop by minimizing all windows +Comment[ca]=Mostra l'escriptori minimitzant totes les finestres +Comment[ca@valencia]=Mostra l'escriptori minimitzant totes les finestres +Comment[cs]=Zobrazit plochu minimalizací všech oken +Comment[da]=Viser skrivebordet ved at minimere alle vinduer +Comment[de]=Zeigt die Arbeitsfläche an, indem alle Fenster minimiert werden +Comment[el]=Εμφάνιση της επιφάνειας εργασίας μέσω ελαχιστοποίησης όλων των παραθύρων +Comment[en_GB]=Shows the desktop by minimising all windows +Comment[es]=Muestra el escritorio minimizando todas las ventanas +Comment[et]=Töölaua näitamine kõiki aknaid minimeerides +Comment[eu]=Mahaigaina erakusten du leiho guztian minimizatuz +Comment[fi]=Näyttää työpöydän pienentämällä kaikki ikkunat +Comment[fr]=Afficher le bureau en minimisant toutes les fenêtres +Comment[gl]=Minimiza todas as xanelas para mostrar o escritorio. +Comment[he]=הראה את שולחן העבודה על ידי מיזעור כל החלונות +Comment[hu]=Megjeleníti az asztalt az összes ablak minimalizálásával +Comment[id]=Menampilkan desktop dengan meminimalkan semua window +Comment[it]=Mostra il desktop minimizzando tutte le finestre +Comment[ko]=모든 창을 최소화해서 데스크톱 보이기 +Comment[lt]=Sumažina visus langus ir parodo darbalaukį +Comment[nl]=Toont het bureaublad door alle vensters te minimaliseren +Comment[nn]=Vis skrivebordet ved å minimera alle vindauga +Comment[pl]=Ukazuje pulpit minimalizując wszystkie okna +Comment[pt]=Mostra o ecrã ao minimizar todas as janelas +Comment[pt_BR]=Mostra a área de trabalho ao minimizar todas as janelas +Comment[ru]=Сворачивание всех окон, чтобы увидеть рабочий стол +Comment[sk]=Zobrazí plochu minimalizovaním všetkých okien +Comment[sl]=Pokaže namizje s skrčenjem vseh oken +Comment[sr]=Приказује површ минимизовањем свих прозора +Comment[sr@ijekavian]=Приказује површ минимизовањем свих прозора +Comment[sr@ijekavianlatin]=Prikazuje površ minimizovanjem svih prozora +Comment[sr@latin]=Prikazuje površ minimizovanjem svih prozora +Comment[sv]=Visar skrivbordet genom att minimera alla fönster +Comment[tr]=Tüm pencereleri küçülterek masaüstünü gösterir +Comment[uk]=Показує стільницю, згорнувши усі вікна +Comment[x-test]=xxShows the desktop by minimizing all windowsxx +Comment[zh_CN]=最小化所有窗口以显示桌面 +Comment[zh_TW]=透過最小化所有視窗來顯示桌面 +Icon=user-desktop + +Type=Service +X-KDE-ServiceTypes=Plasma/Applet +X-KDE-PluginInfo-Author=Sebastian Kügler +X-KDE-PluginInfo-Email=sebas@kde.org +X-KDE-PluginInfo-Name=org.kde.plasma.minimizeall +X-KDE-PluginInfo-Version=1.0 +X-KDE-PluginInfo-Website=http://plasma.kde.org/ +X-KDE-PluginInfo-Category=Windows and Tasks +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL-2.0+ +X-KDE-PluginInfo-EnabledByDefault=true +X-Plasma-MainScript=ui/main.qml +X-Plasma-API=declarativeappletscript diff --git a/applets/showdesktop/CMakeLists.txt b/applets/showdesktop/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/applets/showdesktop/CMakeLists.txt @@ -0,0 +1,20 @@ +plasma_install_package(package org.kde.plasma.showdesktop) + +add_definitions(-DTRANSLATION_DOMAIN="plasma_applet_org.kde.plasma.showdesktop") + +set(showdesktop_SRCS + plugin/showdesktop.cpp + plugin/showdesktopplugin.cpp +) + +add_library(showdesktopplugin SHARED ${showdesktop_SRCS}) + +target_link_libraries(showdesktopplugin + Qt5::Core + Qt5::Qml + Qt5::Quick + KF5::WindowSystem + ) + +install(TARGETS showdesktopplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/showdesktop) +install(FILES plugin/qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/showdesktop) diff --git a/applets/showdesktop/Messages.sh b/applets/showdesktop/Messages.sh new file mode 100755 --- /dev/null +++ b/applets/showdesktop/Messages.sh @@ -0,0 +1,2 @@ +#! /usr/bin/env bash +$XGETTEXT `find . -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.showdesktop.pot diff --git a/applets/showdesktop/package/contents/config/main.xml b/applets/showdesktop/package/contents/config/main.xml new file mode 100644 --- /dev/null +++ b/applets/showdesktop/package/contents/config/main.xml @@ -0,0 +1,13 @@ + + + + + + + user-desktop + + + diff --git a/applets/showdesktop/package/contents/ui/main.qml b/applets/showdesktop/package/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/applets/showdesktop/package/contents/ui/main.qml @@ -0,0 +1,91 @@ +/* + Copyright (C) 2014 Ashish Madeti + Copyright (C) 2016 Kai Uwe Broulik + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +import QtQuick 2.1 +import QtQuick.Layouts 1.1 + +import org.kde.plasma.core 2.0 as PlasmaCore + +import org.kde.plasma.plasmoid 2.0 + +import org.kde.plasma.private.showdesktop 0.1 + +QtObject { + id: root + + // you can't have an applet with just a compact representation :( + Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation + Plasmoid.onActivated: showdesktop.showingDesktop = !showdesktop.showingDesktop + Plasmoid.icon: plasmoid.configuration.icon + Plasmoid.title: i18n("Show Desktop") + Plasmoid.toolTipSubText: i18n("Show the Plasma desktop") + + // QtObject has no default property + property QtObject showdesktop: ShowDesktop { } + + Component.onCompleted: { + plasmoid.setAction("minimizeall", i18nc("@action", "Minimize All Windows")) + } + + function action_minimizeall() { + showdesktop.minimizeAll() + } + + Plasmoid.fullRepresentation: PlasmaCore.ToolTipArea { + readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge + || plasmoid.location === PlasmaCore.Types.RightEdge + || plasmoid.location === PlasmaCore.Types.BottomEdge + || plasmoid.location === PlasmaCore.Types.LeftEdge) + + Layout.minimumWidth: units.iconSizes.small + Layout.minimumHeight: Layout.minimumWidth + + Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1 + Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1 + + icon: plasmoid.icon + mainText: plasmoid.title + subText: plasmoid.toolTipSubText + + MouseArea { + anchors.fill: parent + onClicked: showdesktop.showingDesktop = !showdesktop.showingDesktop + } + + PlasmaCore.IconItem { + anchors.fill: parent + source: plasmoid.icon + active: parent.containsMouse || showdesktop.showingDesktop + } + + // also activate when dragging an item over the plasmoid so a user can easily drag data to the desktop + DropArea { + anchors.fill: parent + onEntered: activateTimer.start() + onExited: activateTimer.stop() + + Timer { + id: activateTimer + interval: 250 //to match TaskManager + onTriggered: plasmoid.activated() + } + } + } + +} diff --git a/applets/showdesktop/package/metadata.desktop b/applets/showdesktop/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/applets/showdesktop/package/metadata.desktop @@ -0,0 +1,133 @@ +[Desktop Entry] +Name=Show Desktop +Name[ar]=أظهر سطح المكتب +Name[bs]=Prikaži radnu površinu +Name[ca]=Mostra l'escriptori +Name[ca@valencia]=Mostra l'escriptori +Name[cs]=Zobrazit plochu +Name[da]=Vis skrivebord +Name[de]=Arbeitsfläche anzeigen +Name[el]=Εμφάνιση επιφάνειας εργασίας +Name[en_GB]=Show Desktop +Name[es]=Mostrar el escritorio +Name[et]=Töölaua näitamine +Name[eu]=Erakutsi mahaigaina +Name[fi]=Näytä työpöytä +Name[fr]=Afficher un bureau +Name[ga]=Taispeáin an Deasc +Name[gl]=Mostrar o escritorio +Name[he]=הצג שולחן עבודה +Name[hr]=Prkaži radnu površinu +Name[hu]=A munkaasztal megjelenítése +Name[ia]=Monstra Scriptorio +Name[id]=Show Desktop +Name[is]=Sýna skjáborðið +Name[it]=Mostra desktop +Name[ja]=デスクトップを表示 +Name[kk]=Үстел бетін көрсету +Name[km]=បង្ហាញ​ផ្ទៃតុ +Name[ko]=데스크톱 보이기 +Name[ku]=Sermasê Nîşan Bide +Name[lt]=Rodyti darbalaukį +Name[lv]=Parādīt darbvirsmu +Name[mr]=डेस्कटॉप दर्शवा +Name[nb]=Vis skrivebord +Name[nds]=Schriefdisch wiesen +Name[nl]=Bureaublad tonen +Name[nn]=Vis skrivebord +Name[pa]=ਡੈਸਕਟਾਪ ਵੇਖੋ +Name[pl]=Pokaż pulpit +Name[pt]=Mostrar o Ecrã +Name[pt_BR]=Exibir a área de trabalho +Name[ro]=Arată biroul +Name[ru]=Показать рабочий стол +Name[sk]=Zobraziť plochu +Name[sl]=Pokaži namizje +Name[sq]=Shfaq Hapësirën e Punës +Name[sr]=приказ површи +Name[sr@ijekavian]=приказ површи +Name[sr@ijekavianlatin]=prikaz površi +Name[sr@latin]=prikaz površi +Name[sv]=Visa skrivbord +Name[th]=แสดงพื้นที่ทำงาน +Name[tr]=Masaüstünü Göster +Name[ug]=ئۈستەلئۈستىنى كۆرسەت +Name[uk]=Показати стільницю +Name[wa]=Mostrer scribanne +Name[x-test]=xxShow Desktopxx +Name[zh_CN]=显示桌面 +Name[zh_TW]=顯示桌面 +Comment=Show the Plasma desktop +Comment[ar]=أظهر سطح مكتب بلازما +Comment[bs]=Prikazi plazma površ +Comment[ca]=Mostra l'escriptori Plasma +Comment[ca@valencia]=Mostra l'escriptori Plasma +Comment[cs]=Zobrazení plochy Plasmy +Comment[da]=Viser Plasmas skrivebord. +Comment[de]=Die Plasma-Arbeitsfläche anzeigen +Comment[el]=Εμφάνιση της επιφάνειας εργασίας plasma +Comment[en_GB]=Show the Plasma desktop +Comment[es]=Mostrar el escritorio de Plasma +Comment[et]=Plasma töölaua näitamine +Comment[eu]=Erakutsi Plasma mahaigaina +Comment[fi]=Näyttää työpöydän +Comment[fr]=Afficher le bureau Plasma +Comment[ga]=Taispeáin an deasc Plasma +Comment[gl]=Mostra o escritorio Plasma +Comment[he]=מציג את שולחן העבודה Plasma +Comment[hr]=Prikaži radnu površinu Plasme +Comment[hu]=A Plazma munkaasztal megjelenítése +Comment[ia]=Monstra le scriptorio de Plasma +Comment[id]=Menampilkan desktop Plasma +Comment[is]=Sýna Plasmaskjáborðið +Comment[it]=Mostra il desktop di Plasma +Comment[ja]=Plasma デスクトップを表示します +Comment[kk]=Plasma үстелінің бетін көрсету +Comment[km]=បង្ហាញ​ផ្ទៃតុ​ប្លាស្មា +Comment[ko]=Plasma 데스크톱 보이기 +Comment[ku]=Sermase ya Plasma nîşan bide +Comment[lt]=Rodo Plasma darbalaukį +Comment[lv]=Parāda Plasma darbvirsmu +Comment[mr]=प्लाज्मा डेस्कटॉप दर्शवा +Comment[nb]=Vis Plasma-skrivebordet +Comment[nds]=Den Plasma-Schriefdisch wiesen +Comment[nl]=Toont het Plasma-bureaublad +Comment[nn]=Vis Plasma-skrivebordet +Comment[pa]=ਪਲਾਜ਼ਮਾ ਡੈਸਕਟਾਪ ਵੇਖੋ +Comment[pl]=Pokazuje pulpit Plazmy +Comment[pt]=Mostrar o ecrã do Plasma +Comment[pt_BR]=Mostra a área de trabalho do Plasma +Comment[ro]=Arată biroul Plasma +Comment[ru]=Показать рабочий стол Plasma +Comment[sk]=Zobrazenie plochy Plasmy +Comment[sl]=Pokaži namizje Plasma +Comment[sr]=Баците поглед на плазма површ +Comment[sr@ijekavian]=Баците поглед на плазма површ +Comment[sr@ijekavianlatin]=Bacite pogled na plasma površ +Comment[sr@latin]=Bacite pogled na plasma površ +Comment[sv]=Visa Plasmas skrivbord +Comment[th]=แสดงพื้นที่ทำงานของพลาสมา +Comment[tr]=Plasma masaüstünü göster +Comment[uk]=Показує стільницю Плазми +Comment[wa]=Mostrer l' sicribanne Plasma +Comment[x-test]=xxShow the Plasma desktopxx +Comment[zh_CN]=显示 Plasma 桌面 +Comment[zh_TW]=顯示 Plasma 桌面 +Icon=user-desktop + +Type=Service +X-KDE-ServiceTypes=Plasma/Applet + +X-KDE-PluginInfo-Author=Petri Damstén +X-KDE-PluginInfo-Email=damu@iki.fi +X-KDE-PluginInfo-Name=org.kde.plasma.showdesktop +X-KDE-PluginInfo-Version=1.0 +X-KDE-PluginInfo-Website=http://plasma.kde.org/ +X-KDE-PluginInfo-Category=Windows and Tasks +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL-2.0+ +X-KDE-PluginInfo-EnabledByDefault=true +X-Plasma-MainScript=ui/main.qml +X-Plasma-API=declarativeappletscript + +X-KDE-FormFactors=desktop diff --git a/applets/showdesktop/plugin/qmldir b/applets/showdesktop/plugin/qmldir new file mode 100644 --- /dev/null +++ b/applets/showdesktop/plugin/qmldir @@ -0,0 +1,2 @@ +module org.kde.plasma.private.showdesktop +plugin showdesktopplugin diff --git a/applets/showdesktop/plugin/showdesktop.h b/applets/showdesktop/plugin/showdesktop.h new file mode 100644 --- /dev/null +++ b/applets/showdesktop/plugin/showdesktop.h @@ -0,0 +1,43 @@ +/* + * Copyright 2008 Petri Damsten + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SHOWDESKTOP_HEADER +#define SHOWDESKTOP_HEADER + +#include + +class ShowDesktop : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool showingDesktop READ showingDesktop WRITE setShowingDesktop NOTIFY showingDesktopChanged) + +public: + explicit ShowDesktop(QObject *parent = nullptr); + ~ShowDesktop() override; + + bool showingDesktop() const; + void setShowingDesktop(bool showingDesktop); + + Q_INVOKABLE void minimizeAll(); + +Q_SIGNALS: + void showingDesktopChanged(bool showingDesktop); + +}; + +#endif //SHOWDESKTOP_HEADER diff --git a/applets/showdesktop/plugin/showdesktop.cpp b/applets/showdesktop/plugin/showdesktop.cpp new file mode 100644 --- /dev/null +++ b/applets/showdesktop/plugin/showdesktop.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2008 Petri Damsten + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "showdesktop.h" + +#include + +ShowDesktop::ShowDesktop(QObject *parent) : QObject(parent) +{ + connect(KWindowSystem::self(), &KWindowSystem::showingDesktopChanged, + this, &ShowDesktop::showingDesktopChanged); +} + +ShowDesktop::~ShowDesktop() = default; + +bool ShowDesktop::showingDesktop() const +{ + return KWindowSystem::showingDesktop(); +} + +void ShowDesktop::setShowingDesktop(bool showingDesktop) +{ + KWindowSystem::setShowingDesktop(showingDesktop); +} + +void ShowDesktop::minimizeAll() +{ + const auto &windows = KWindowSystem::windows(); + for (WId wid : windows) { + KWindowSystem::minimizeWindow(wid); + } +} diff --git a/applets/showdesktop/plugin/showdesktopplugin.h b/applets/showdesktop/plugin/showdesktopplugin.h new file mode 100644 --- /dev/null +++ b/applets/showdesktop/plugin/showdesktopplugin.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2014 Ashish Madeti + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef SHOWDESKTOPPLUGIN_H +#define SHOWDESKTOPPLUGIN_H + +#include +#include +#include + +class ShowDesktopPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) override; +}; + +#endif // SHOWDESKTOPPLUGIN_H diff --git a/applets/showdesktop/plugin/showdesktopplugin.cpp b/applets/showdesktop/plugin/showdesktopplugin.cpp new file mode 100644 --- /dev/null +++ b/applets/showdesktop/plugin/showdesktopplugin.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2014 Ashish Madeti + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "showdesktopplugin.h" +#include "showdesktop.h" + +// Qt +#include + +void ShowDesktopPlugin::registerTypes(const char *uri) +{ + Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.showdesktop")); + qmlRegisterType(uri, 0, 1, "ShowDesktop"); +}