From bdb48213767255d66b2ddec149ae00c9433d290e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 4 Jun 2015 13:13:53 -0700 Subject: [PATCH] simple kwin script for a fullscreen switcher --- CMakeLists.txt | 3 + kwinmultitasking/contents/ui/main.qml | 39 +++++++++++ kwinmultitasking/contents/ui/switcher.qml | 79 +++++++++++++++++++++++ kwinmultitasking/metadata.desktop | 19 ++++++ 4 files changed, 140 insertions(+) create mode 100644 kwinmultitasking/contents/ui/main.qml create mode 100644 kwinmultitasking/contents/ui/switcher.qml create mode 100644 kwinmultitasking/metadata.desktop diff --git a/CMakeLists.txt b/CMakeLists.txt index e4bd215d..5f3fd935 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,9 @@ install(DIRECTORY compositor/ kpackage_install_package(phonebook org.kde.phone.phonebook genericqml) install(FILES phonebook/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.phonebook.desktop) +install( DIRECTORY kwinmultitasking/ DESTINATION ${DATA_INSTALL_DIR}/kwin/scripts/org.kde.phone.multitasking ) +install( FILES kwinmultitasking/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-org.kde.phone.multitasking.desktop ) + add_subdirectory(bin) #add_subdirectory(services) add_subdirectory(settingsmodules) diff --git a/kwinmultitasking/contents/ui/main.qml b/kwinmultitasking/contents/ui/main.qml new file mode 100644 index 00000000..dffc2ac5 --- /dev/null +++ b/kwinmultitasking/contents/ui/main.qml @@ -0,0 +1,39 @@ +/******************************************************************** + This file is part of the KDE project. + +Copyright (C) 2015 Marco MArtin + +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 . +*********************************************************************/ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: mainItemLoader + } + + Connections { + target: workspace + onCurrentDesktopChanged: { + if (!mainItemLoader.item) { + mainItemLoader.source = "switcher.qml"; + } + mainItemLoader.item.visible = true; + } + } +} + + diff --git a/kwinmultitasking/contents/ui/switcher.qml b/kwinmultitasking/contents/ui/switcher.qml new file mode 100644 index 00000000..10382c64 --- /dev/null +++ b/kwinmultitasking/contents/ui/switcher.qml @@ -0,0 +1,79 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2012, 2013 Martin Gräßlin + +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 . +*********************************************************************/ +import QtQuick 2.0; +import QtQuick.Window 2.0; +import org.kde.plasma.core 2.0 as PlasmaCore; +import org.kde.plasma.components 2.0 as PlasmaComponents; +import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons; +import org.kde.kwin 2.0 as KWin; + +PlasmaCore.Dialog { + id: dialog + location: PlasmaCore.Types.Floating + visible: false + flags: Qt.X11BypassWindowManagerHint + backgroundHints: PlasmaCore.Dialog.NoBackground + + mainItem: Item { + width: workspace.virtualScreenSize.width + height: workspace.virtualScreenSize.height + + PlasmaComponents.Button { + z: 99 + text: "close" + onClicked: dialog.visible = false; + } + GridView { + id: view + anchors.fill: parent + cellWidth: units.gridUnit * 20 + cellHeight: units.gridUnit * 20 // (view.width / view.height) + model: KWin.ClientModel { + id: clientModel + exclusions: KWin.ClientModel.NotAcceptingFocusExclusion + } + delegate: MouseArea { + width: view.cellWidth + height: view.cellHeight + PlasmaComponents.ToolButton { + anchors.right: parent.right + iconSource: "window-close" + flat: false + onClicked: model.client.closeWindow() + visible: model.client.closeable + } + KWin.ThumbnailItem { + anchors.fill: parent + //parentWindow: dialog.windowId + client: model.client + brightness: (index == view.currentIndex) ? 1.0 : 0.4 + } + onClicked: { + workspace.activeClient = model.client + dialog.visible = false + } + } + } + } + + Component.onCompleted: { + KWin.registerWindow(dialog); + } +} diff --git a/kwinmultitasking/metadata.desktop b/kwinmultitasking/metadata.desktop new file mode 100644 index 00000000..274c348e --- /dev/null +++ b/kwinmultitasking/metadata.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Name=Phone multitask +Comment=Multitasking user interface fpr Phone devices + +Icon=preferences-system-windows-script-test + +X-Plasma-API=declarativescript +X-Plasma-MainScript=ui/main.qml +X-KWin-Exclude-Listing=false + +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-Name=org.kde.phone.multitasking +X-KDE-PluginInfo-Version=1.0 + +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-ServiceTypes=KWin/Script +Type=Service