diff --git a/applets/activitypager/CMakeLists.txt b/applets/activitypager/CMakeLists.txt --- a/applets/activitypager/CMakeLists.txt +++ b/applets/activitypager/CMakeLists.txt @@ -1,28 +1,2 @@ -add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.activitypager\") -plasma_install_package(package org.kde.plasma.activitypager) - -set(pager_SRCS - plugin/model.cpp - plugin/activitypager.cpp - plugin/activitypagerplugin.cpp) - -add_library(activitypagerplugin SHARED ${pager_SRCS}) - -target_link_libraries(activitypagerplugin - KF5::KIOCore - KF5::WindowSystem - KF5::Plasma - KF5::Activities - KF5::KDELibs4Support - Qt5::Core - Qt5::Qml - Qt5::Quick - Qt5::DBus -) - -if (X11_FOUND) - target_link_libraries(activitypagerplugin Qt5::X11Extras PW::LibTaskManager) -endif() - -install(TARGETS activitypagerplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/activitypager) -install(FILES plugin/qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/activitypager) +install(FILES metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME plasma-applet-org.kde.plasma.activitypager.desktop) +install(FILES metadata.desktop DESTINATION ${PLASMA_DATA_INSTALL_DIR}/plasmoids/org.kde.plasma.activitypager ) diff --git a/applets/activitypager/Messages.sh b/applets/activitypager/Messages.sh deleted file mode 100644 --- a/applets/activitypager/Messages.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /usr/bin/env bash -$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.activitypager.pot -rm -f rc.cpp \ No newline at end of file diff --git a/applets/activitypager/package/contents/code/utils.js b/applets/activitypager/package/contents/code/utils.js deleted file mode 100644 --- a/applets/activitypager/package/contents/code/utils.js +++ /dev/null @@ -1,6 +0,0 @@ -.pragma library - -function contains(item, point) { - return point.x >= item.x && point.x <= item.x + item.width - && point.y >= item.y && point.y <= item.y + item.height; -} diff --git a/applets/activitypager/package/contents/config/config.qml b/applets/activitypager/package/contents/config/config.qml deleted file mode 100644 --- a/applets/activitypager/package/contents/config/config.qml +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. - */ - -import QtQuick 2.0 - -import org.kde.plasma.configuration 2.0 - -ConfigModel { - ConfigCategory { - name: i18n("General") - icon: "user-desktop" - source: "configGeneral.qml" - } -} diff --git a/applets/activitypager/package/contents/config/main.xml b/applets/activitypager/package/contents/config/main.xml deleted file mode 100644 --- a/applets/activitypager/package/contents/config/main.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - 2 - - - false - - - - - - - 0 - - - - - - - diff --git a/applets/activitypager/package/contents/ui/configGeneral.qml b/applets/activitypager/package/contents/ui/configGeneral.qml deleted file mode 100644 --- a/applets/activitypager/package/contents/ui/configGeneral.qml +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2013 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 2.010-1301, USA. - */ - -import QtQuick 2.0 -import QtQuick.Controls 1.0 as QtControls -import QtQuick.Layouts 1.0 as Layouts - - -//FIXME this causes a crash in Oxygen style -//QtControls.GroupBox { -Item { - - width: childrenRect.width - height: childrenRect.height - -//FIXME enable when we're back to being a group box -// flat: true -// title: i18n("Appearance") - - property int cfg_displayedText - property alias cfg_showWindowIcons: showRecentlyInstalledCheckbox.checked - property int cfg_currentDesktopSelected - - onCfg_displayedTextChanged: { - switch (cfg_displayedText) { - case 0: - displayedTextGroup.current = desktopNumberRadio; - break; - case 1: - displayedTextGroup.current = desktopNameRadio; - break; - default: - case 2: - displayedTextGroup.current = noTextRadio; - break; - } - } - - onCfg_currentDesktopSelectedChanged: { - switch (cfg_currentDesktopSelected) { - case 0: - currentDesktopSelectedGroup.current = doesNothingRadio; - break; - default: - case 1: - currentDesktopSelectedGroup.current = showsDesktopRadio; - break; - } - } - - Component.onCompleted: cfg_currentDesktopSelectedChanged() - - QtControls.ExclusiveGroup { - id: displayedTextGroup - } - QtControls.ExclusiveGroup { - id: currentDesktopSelectedGroup - } - - Layouts.GridLayout { - columns: 2 - QtControls.Label { - text: i18n("Display Text:") - Layouts.Layout.alignment: Qt.AlignVCenter|Qt.AlignRight - } - QtControls.RadioButton { - id: desktopNumberRadio - exclusiveGroup: displayedTextGroup - text: i18n("Activity number") - onCheckedChanged: if (checked) cfg_displayedText = 0; - } - Item { - width: 2 - height: 2 - Layouts.Layout.rowSpan: 2 - } - QtControls.RadioButton { - id: desktopNameRadio - exclusiveGroup: displayedTextGroup - text: i18n("Activity name") - onCheckedChanged: if (checked) cfg_displayedText = 1; - } - QtControls.RadioButton { - id: noTextRadio - exclusiveGroup: displayedTextGroup - text: i18n("No text") - onCheckedChanged: if (checked) cfg_displayedText = 2; - } - - QtControls.Label { - text: i18n("Display icons:") - Layouts.Layout.alignment: Qt.AlignVCenter|Qt.AlignRight - } - QtControls.CheckBox { - id: showRecentlyInstalledCheckbox - } - - QtControls.Label { - text: i18n("Selecting current activity:") - Layouts.Layout.alignment: Qt.AlignVCenter|Qt.AlignRight - } - QtControls.RadioButton { - id: doesNothingRadio - exclusiveGroup: currentDesktopSelectedGroup - text: i18n("Does nothing") - onCheckedChanged: if (checked) cfg_currentDesktopSelected = 0; - } - Item { - width: 2 - height: 2 - Layouts.Layout.rowSpan: 2 - } - QtControls.RadioButton { - id: showsDesktopRadio - exclusiveGroup: currentDesktopSelectedGroup - text: i18n("Shows desktop") - onCheckedChanged: if (checked) cfg_currentDesktopSelected = 1; - } - } - -} diff --git a/applets/activitypager/package/contents/ui/main.qml b/applets/activitypager/package/contents/ui/main.qml deleted file mode 100644 --- a/applets/activitypager/package/contents/ui/main.qml +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright 2012 Luís Gabriel Lima - * - * 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.Layouts 1.1 -import org.kde.plasma.plasmoid 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 KQuickControlsAddonsComponents -import org.kde.draganddrop 2.0 -import org.kde.plasma.private.activitypager 2.0 -import "utils.js" as Utils - -Item { - id: root - - property bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical) - - Layout.minimumWidth: Layout.maximumWidth - Layout.minimumHeight: Layout.maximumHeight - - Layout.maximumWidth: !root.vertical ? pager.preferredSize.width : Infinity - Layout.maximumHeight: root.vertical ? pager.preferredSize.height : Infinity - - Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation - Layout.fillWidth: root.vertical - Layout.fillHeight: !root.vertical - - property bool dragging: false - property int dragId - - property int dragSwitchDesktopId: -1 - - anchors.fill: parent - //visible: repeater.count > 1 // FIXME: re-enable and fix collapsing - - property color windowActiveOnActiveDesktopColor: theme.textColor - property color windowInactiveOnActiveDesktopColor: theme.textColor - property color windowActiveColor: theme.textColor - property color windowActiveBorderColor: theme.textColor - property color windowInactiveColor: theme.textColor - property color windowInactiveBorderColor: theme.textColor - - function action_showActivityManager() { - var service = dataSource.serviceForSource("Status") - var operation = service.operationDescription("toggleActivityManager") - service.startOperationCall(operation) - } - - PlasmaCore.DataSource { - id: dataSource - engine: "org.kde.activities" - connectedSources: ["Status"] - } - - Connections { - target: theme - onThemeChanged: { - windowActiveOnActiveDesktopColor = theme.textColor - windowActiveOnActiveDesktopColor.a = 0.6 - windowActiveColor = theme.textColor - windowActiveColor.a = 0.5; - windowActiveBorderColor = theme.textColor - //windowActiveBorderColor = 1 - - windowInactiveOnActiveDesktopColor = theme.textColor - windowInactiveOnActiveDesktopColor.a = 0.35; - windowInactiveColor = theme.textColor - windowInactiveColor.a = 0.17; - windowInactiveBorderColor = theme.textColor - windowInactiveBorderColor.a = 0.5 - } - } - Component.onCompleted: { - plasmoid.setAction("showActivityManager", i18n("Show Activity Manager..."), "preferences-activities"); - - windowActiveOnActiveDesktopColor = theme.textColor - windowActiveOnActiveDesktopColor.a = 0.6 - windowActiveColor = theme.textColor - windowActiveColor.a = 0.5; - windowActiveBorderColor = theme.textColor - //windowActiveBorderColor = 1 - - windowInactiveOnActiveDesktopColor = theme.textColor - windowInactiveOnActiveDesktopColor.a = 0.35; - windowInactiveColor = theme.textColor - windowInactiveColor.a = 0.17; - windowInactiveBorderColor = theme.textColor - windowInactiveBorderColor.a = 0.5 - } - - Binding { - //target is set on component.onCompleted above once we've actually created the action - //doing it before hand breaks - id: actionEnablerBinding - property: "enabled" - value: repeater.count > 1 - } - - ActivityPager { - id: pager - orientation: plasmoid.formFactor == PlasmaCore.Types.Vertical ? Qt.Vertical : Qt.Horizontal - size: Qt.size(root.width, root.height) - showWindowIcons: plasmoid.configuration.showWindowIcons - currentDesktopSelected: plasmoid.configuration.currentDesktopSelected - displayedText: plasmoid.configuration.displayedText - } - - Timer { - id: dragTimer - interval: 1000 - onTriggered: { - if (dragSwitchDesktopId != -1 && dragSwitchDesktopId !== pager.currentDesktop-1) { - pager.changeDesktop(dragSwitchDesktopId); - } - } - } - - Repeater { - id: repeater - model: pager.model - - PlasmaCore.ToolTipArea { - id: desktop - - property int desktopId: index - property string desktopName: model.desktopName ? model.desktopName : "" - property bool active: (desktopId === pager.currentDesktop-1) - - mainText: desktopName - - x: model.x - y: model.y - width: model.width - height: model.height - - PlasmaCore.FrameSvgItem { - anchors.fill: parent - z: 1 // to make sure that the FrameSvg will be placed on top of the windows - imagePath: "widgets/pager" - prefix: (desktopMouseArea.enabled && desktopMouseArea.containsMouse) || (root.dragging && root.dragId == desktopId) ? - "hover" : (desktop.active ? "active" : "normal") - } - - DropArea { - id: droparea - anchors.fill: parent - preventStealing: true - - onDragEnter: { - root.dragSwitchDesktopId = desktop.desktopId; - dragTimer.start(); - } - onDragLeave: { - root.dragSwitchDesktopId = -1; - dragTimer.stop(); - } - onDrop: { - pager.dropMimeData(event.mimeData, desktop.desktopId); - root.dragSwitchDesktopId = -1; - dragTimer.stop(); - } - } - - MouseArea { - id: desktopMouseArea - anchors.fill: parent - onClicked: pager.changeDesktop(desktopId); - onWheel: { - if (wheel.angleDelta.y > 0 || wheel.angleDelta.x > 0) { - pager.changeDesktop((repeater.count + pager.currentDesktop - 2) % repeater.count) - } else { - pager.changeDesktop(pager.currentDesktop % repeater.count) - } - } - } - - Item { - id: clipRect - x: 1 - y: 1 - width: desktop.width - 2 - height: desktop.height - 2 - clip: true - - PlasmaComponents.Label { - id: desktopText - anchors.centerIn: parent - text: pager.displayedText == ActivityPager.Name ? desktop.desktopName - : (pager.displayedText == ActivityPager.Number ? desktop.desktopId+1 : "") - - } - - Repeater { - model: windows - - //update the tooltip whenever we add or remove a window - onCountChanged: { - var tooltipText = i18np("%1 window", "%1 windows", count) - - if (count) { - var i; - tooltipText += "
    "; - for (i=0; i < Math.min(count,4); i++) { - if (itemAt(i)) { - tooltipText += "
  • "+ itemAt(i).visibleName +"
  • "; - } - } - tooltipText += "
"; - if (i < count) { - tooltipText += "
" - tooltipText += i18np("and %1 other window", "and %1 other windows", count-i) - } - } - - desktop.subText = tooltipText - } - - Rectangle { - id: windowRect - - property int windowId: model.windowId - property string visibleName: model.visibleName - - /* since we move clipRect with 1, move it back */ - x: model.x - 1 - y: model.y - 1 - width: model.width - height: model.height - color: { - if (desktop.active) { - if (model.active) - return windowActiveOnActiveDesktopColor; - else - return windowInactiveOnActiveDesktopColor; - } else { - if (model.active) - return windowActiveColor; - else - return windowInactiveColor; - } - } - - border.width: 1 - border.color: model.active ? windowActiveBorderColor - : windowInactiveBorderColor - - KQuickControlsAddonsComponents.QPixmapItem { - id: icon - anchors.centerIn: parent - pixmap: model.icon - height: nativeHeight - width: nativeWidth - visible: pager.showWindowIcons && (windowRect.width >= icon.width) && (windowRect.height >= icon.height) - } - - MouseArea { - id: windowMouseArea - anchors.fill: parent - drag.target: windowRect - drag.axis: Drag.XandYAxis - drag.minimumX: -windowRect.width/2 - drag.maximumX: root.width - windowRect.width/2 - drag.minimumY: -windowRect.height/2 - drag.maximumY: root.height - windowRect.height/2 - - // used to save the state of some properties before the dragging - QtObject { - id: saveState - property int x: -1 - property int y: -1 - property variant parent - property int desktop: -1 - property int mouseX: -1 - property int mouseY: -1 - } - - drag.onActiveChanged: { - root.dragging = drag.active; - desktopMouseArea.enabled = !drag.active; - } - - // reparent windowRect to enable the dragging for other desktops - onPressed: { - if (windowRect.parent == root) - return; - - saveState.x = windowRect.x; - saveState.y = windowRect.y - saveState.parent = windowRect.parent; - saveState.desktop = desktop.desktopId; - saveState.mouseX = mouseX; - saveState.mouseY = mouseY; - - var value = root.mapFromItem(clipRect, windowRect.x, windowRect.y); - windowRect.x = value.x; - windowRect.y = value.y - windowRect.parent = root; - } - - onReleased: { - if (root.dragging) { - pager.moveWindow(windowRect.windowId, windowRect.x, windowRect.y, - root.dragId, saveState.desktop); - } else { - // when there is no dragging (just a click), the event is passed - // to the desktop mousearea - desktopMouseArea.clicked(mouse); - } - - windowRect.x = saveState.x; - windowRect.y = saveState.y; - windowRect.parent = saveState.parent; - } - } - - function checkDesktopHover() { - if (!windowMouseArea.drag.active) - return; - - var mouse = root.mapFromItem(windowRect, saveState.mouseX, saveState.mouseY); - for (var i = 0; i < root.children.length; i++) { - var item = root.children[i]; - if (item.desktopId != undefined && Utils.contains(item, mouse)) { - root.dragId = item.desktopId; - return; - } - } - } - - onXChanged: checkDesktopHover(); - onYChanged: checkDesktopHover(); - } - } - } - } - } -} diff --git a/applets/activitypager/package/metadata.desktop b/applets/activitypager/package/metadata.desktop deleted file mode 100644 --- a/applets/activitypager/package/metadata.desktop +++ /dev/null @@ -1,82 +0,0 @@ -[Desktop Entry] -Name=Activity Pager -Name[ast]=Paxinador d'actividaes -Name[ca]=Paginador d'activitats -Name[ca@valencia]=Paginador d'activitats -Name[cs]=Prohlížeč aktivit -Name[da]=Aktivitetsvælger -Name[de]=Aktivitätenübersicht -Name[el]=Βομβητής δραστηριοτήτων -Name[en_GB]=Activity Pager -Name[es]=Paginador de actividades -Name[et]=Tegevuste lülitaja -Name[fi]=Aktiviteettisivutin -Name[fr]=Gestionnaire d'activité -Name[gl]=Paxinador de actividades -Name[it]=Paginatore attività -Name[ko]=활동 호출기 -Name[lt]=Veiklų perjungimas -Name[nl]=Pager van activiteiten -Name[nn]=Aktivitetsbytar -Name[pl]=Przełącznik aktywności -Name[pt]=Paginador de Actividades -Name[pt_BR]=Paginador de atividades -Name[ru]=Переключение комнат -Name[sk]=Stránkovač aktivít -Name[sl]=Pozivnik za dejavnosti -Name[sr]=Листач активности -Name[sr@ijekavian]=Листач активности -Name[sr@ijekavianlatin]=Listač aktivnosti -Name[sr@latin]=Listač aktivnosti -Name[sv]=Aktivitetsbytare -Name[uk]=Пейджер просторів дій -Name[x-test]=xxActivity Pagerxx -Name[zh_CN]=活动分页器 -Comment=Switch between activities -Comment[ca]=Commuta entre activitats -Comment[ca@valencia]=Commuta entre activitats -Comment[cs]=Přepnout mezi aktivitami -Comment[da]=Skift mellem aktiviteter -Comment[de]=Zwischen Aktivitäten wechseln -Comment[el]=Εναλλαγή μεταξύ των δραστηριοτήτων -Comment[en_GB]=Switch between activities -Comment[es]=Cambiar entre actividades -Comment[et]=Lülitumine tegevuste vahel -Comment[fi]=Vaihda aktiviteettien välillä -Comment[fr]=Basculer entre les activités -Comment[gl]=Cambia de actividade. -Comment[it]=Passa da un'attività all'altra -Comment[ko]=활동간 전환 -Comment[lt]=Persijungimas tarp veiklų -Comment[nl]=Tussen activiteiten schakelen -Comment[nn]=Byt mellom aktiviteter -Comment[pl]=Przełącza między aktywnościami -Comment[pt]=Mudar de actividades -Comment[pt_BR]=Alterna entre as atividades -Comment[ru]=Переключение между комнатами -Comment[sk]=Prepnúť medzi aktivitami -Comment[sl]=Preklopite med dejavnostmi -Comment[sr]=Пребацивање између активности -Comment[sr@ijekavian]=Пребацивање између активности -Comment[sr@ijekavianlatin]=Prebacivanje između aktivnosti -Comment[sr@latin]=Prebacivanje između aktivnosti -Comment[sv]=Byt mellan aktiviteter -Comment[uk]=Перемикання між просторами дій -Comment[x-test]=xxSwitch between activitiesxx -Comment[zh_CN]=在活动间切换 - -Icon=org.kde.plasma.pager -Type=Service -X-Plasma-API=declarativeappletscript -X-KDE-ServiceTypes=Plasma/Applet -X-Plasma-MainScript=ui/main.qml -X-Plasma-Provides=org.kde.plasma.virtualdesktops -X-KDE-PluginInfo-Author=The Plasma Team -X-KDE-PluginInfo-Email=plasma-devel@kde.org -X-KDE-PluginInfo-Name=org.kde.plasma.activitypager -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Website=http://userbase.kde.org -X-KDE-PluginInfo-Category=Windows and Tasks -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true diff --git a/applets/activitypager/plugin/activitypager.h b/applets/activitypager/plugin/activitypager.h deleted file mode 100644 --- a/applets/activitypager/plugin/activitypager.h +++ /dev/null @@ -1,167 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Daniel Laidig * - * Copyright (C) 2012 by Luís Gabriel Lima * - * * - * 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 ACTIVITYPAGER_H -#define ACTIVITYPAGER_H - -#include - -#include - -#include "model.h" -#include - -class QDesktopWidget; - -class KColorScheme; -class KWindowInfo; -class KCModuleProxy; - -namespace Plasma -{ - class FrameSvg; -} - -namespace KActivities -{ - class Consumer; - class Controller; -} - -class ActivityPager : public QObject -{ - Q_OBJECT - Q_PROPERTY(QObject* model READ model CONSTANT) - Q_PROPERTY(int currentDesktop READ currentDesktop NOTIFY currentDesktopChanged) - 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) - Q_PROPERTY(QSize preferredSize READ preferredSize NOTIFY preferredSizeChanged) - Q_PROPERTY(ActivityPager::CurrentDesktopSelected currentDesktopSelected READ currentDesktopSelected WRITE setCurrentDesktopSelected NOTIFY currentDesktopSelectedChanged) - Q_PROPERTY(ActivityPager::DisplayedText displayedText READ displayedText WRITE setDisplayedText NOTIFY displayedTextChanged) - - public: - enum CurrentDesktopSelected { - DoNothing = 0, - ShowDesktop, - ShowDashboard - }; - Q_ENUMS(CurrentDesktopSelected) - - enum DisplayedText { - Number = 0, - Name, - None - }; - Q_ENUMS(DisplayedText) - - ActivityPager(QObject *parent = 0); - ~ActivityPager(); - - QObject *model() const { return m_pagerModel; } - - int currentDesktop() const { return m_currentDesktop; } - void setCurrentDesktop(int desktop); - - bool showWindowIcons() const { return m_showWindowIcons; } - void setShowWindowIcons(bool show); - - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - - QSizeF size() const; - void setSize(const QSizeF &size); - - QSize preferredSize() const; - - CurrentDesktopSelected currentDesktopSelected() const; - void setCurrentDesktopSelected(CurrentDesktopSelected cur); - - DisplayedText displayedText() const; - void setDisplayedText(DisplayedText disp); - - Q_INVOKABLE void moveWindow(int, double, double, int, int); - Q_INVOKABLE void changeDesktop(int desktopId); - Q_INVOKABLE void dropMimeData(QMimeData *mimeData, int desktopId); - - Q_SIGNALS: - void currentDesktopChanged(); - void showWindowIconsChanged(); - void orientationChanged(); - void sizeChanged(); - void preferredSizeChanged(); - void currentDesktopSelectedChanged(); - void displayedTextChanged(); - - public Q_SLOTS: - void recalculateGridSizes(int rows); - void updateSizes(); - void recalculateWindowRects(); - void openVirtualDesktopsKCM(); - - protected Q_SLOTS: - void currentActivityChanged(const QString &activity); - void desktopsSizeChanged(); - void numberOfDesktopsChanged(); - void desktopNamesChanged(); - void windowChanged(WId id, const unsigned long *dirty); - void startTimer(); - void startTimerFast(); -#if HAVE_X11 - void slotAddDesktop(); - void slotRemoveDesktop(); -#endif - - protected: - void createMenu(); - QRect fixViewportPosition( const QRect& r ); - - private: - - PagerModel *m_pagerModel; - - QTimer* m_timer; - - - DisplayedText m_displayedText; - CurrentDesktopSelected m_currentDesktopSelected; - int m_rows; - int m_columns; - int m_desktopCount; - int m_currentDesktop; - QString m_currentActivity; - qreal m_widthScaleFactor; - qreal m_heightScaleFactor; - QSizeF m_size; - QSize m_preferredSize; - Qt::Orientation m_orientation; - KActivities::Controller *m_controller; - - bool m_showWindowIcons : 1; - bool m_desktopDown : 1; - bool m_validSizes : 1; - - QDesktopWidget *m_desktopWidget; -#if HAVE_X11 - bool m_isX11; -#endif - }; - -#endif diff --git a/applets/activitypager/plugin/activitypager.cpp b/applets/activitypager/plugin/activitypager.cpp deleted file mode 100644 --- a/applets/activitypager/plugin/activitypager.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Daniel Laidig * - * Copyright (C) 2012 by Luís Gabriel Lima * - * * - * 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 "activitypager.h" - -#include - -#include -#include -#include -#include -#if HAVE_X11 -#include -#endif -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#if HAVE_X11 -#include -#include -#endif - -#include -#include - -#include -#include - -const int FAST_UPDATE_DELAY = 100; -const int UPDATE_DELAY = 500; -const int MAXDESKTOPS = 20; -// random(), find a less magic one if you can. -sreich -const qreal MAX_TEXT_WIDTH = 800; - -ActivityPager::ActivityPager(QObject *parent) - : QObject(parent), - m_displayedText(None), - m_currentDesktopSelected(DoNothing), - m_columns(0), - m_currentDesktop(0), - m_orientation(Qt::Horizontal), - m_showWindowIcons(false), - m_desktopDown(false), - m_validSizes(false), - m_desktopWidget(QApplication::desktop()) -#if HAVE_X11 - , m_isX11(QX11Info::isPlatformX11()) -#endif -{ - m_controller = new KActivities::Controller(this); - connect(m_controller, SIGNAL(currentActivityChanged(QString)), this, SLOT(currentActivityChanged(QString))); - m_currentActivity = m_controller->currentActivity(); - - NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout); - m_rows = info.desktopLayoutColumnsRows().height(); - - // initialize with a decent default - m_desktopCount = qMax(1, m_controller->activities(KActivities::Info::Running).length()); - - m_pagerModel = new PagerModel(this); - - m_timer = new QTimer(this); - m_timer->setSingleShot(true); - connect(m_timer, SIGNAL(timeout()), this, SLOT(recalculateWindowRects())); - - connect(m_controller, SIGNAL(currentActivityChanged(QString)), this, SLOT(currentActivityChanged(QString))); - - connect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), this, SLOT(startTimerFast())); - connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)), this, SLOT(startTimerFast())); - connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(startTimerFast())); - connect(m_controller, SIGNAL(activitiesChanged(QStringList)), this, SLOT(numberOfDesktopsChanged())); - /**/connect(KWindowSystem::self(), SIGNAL(desktopNamesChanged()), this, SLOT(desktopNamesChanged())); - connect(KWindowSystem::self(), SIGNAL(stackingOrderChanged()), this, SLOT(startTimerFast())); - connect(KWindowSystem::self(), SIGNAL(windowChanged(WId,const ulong*)), this, SLOT(windowChanged(WId,const ulong*))); - connect(KWindowSystem::self(), SIGNAL(showingDesktopChanged(bool)), this, SLOT(startTimer())); - connect(m_desktopWidget, SIGNAL(screenCountChanged(int)), SLOT(desktopsSizeChanged())); - connect(m_desktopWidget, SIGNAL(resized(int)), SLOT(desktopsSizeChanged())); - - // connect to KWin's reloadConfig signal to get updates on the desktop layout - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig", - this, SLOT(configChanged())); - - recalculateGridSizes(m_rows); - - setCurrentDesktop(m_controller->activities(KActivities::Info::Running).indexOf(m_currentActivity) + 1); -} - -ActivityPager::~ActivityPager() -{ -} - - - -void ActivityPager::setCurrentDesktop(int desktop) -{ - if (m_currentDesktop != desktop) { - m_currentDesktop = desktop; - emit currentDesktopChanged(); - } -} - -void ActivityPager::setShowWindowIcons(bool show) -{ - if (m_showWindowIcons != show) { - m_showWindowIcons = show; - emit showWindowIconsChanged(); - } -} - -Qt::Orientation ActivityPager::orientation() const -{ - return m_orientation; -} - -void ActivityPager::setOrientation(Qt::Orientation orientation) -{ - if (m_orientation == orientation) { - return; - } - - m_orientation = orientation; - emit orientationChanged(); - - // whenever we switch to/from vertical form factor, swap the rows and columns around - if (m_columns != m_rows) { - // pass in columns as the new rows - recalculateGridSizes(m_columns); - recalculateWindowRects(); - } -} - -QSizeF ActivityPager::size() const -{ - return m_size; -} - -QSize ActivityPager::preferredSize() const -{ - return m_preferredSize; -} - -void ActivityPager::setSize(const QSizeF &size) -{ - if (m_size == size) { - return; - } - - m_size = size; - emit sizeChanged(); - - m_validSizes = false; - - startTimer(); -} - -ActivityPager::CurrentDesktopSelected ActivityPager::currentDesktopSelected() const -{ - return m_currentDesktopSelected; -} - -void ActivityPager::setCurrentDesktopSelected(CurrentDesktopSelected cur) -{ - if (m_currentDesktopSelected == cur) { - return; - } - - m_currentDesktopSelected = cur; - emit currentDesktopSelectedChanged(); -} - -ActivityPager::DisplayedText ActivityPager::displayedText() const -{ - return m_displayedText; -} - -void ActivityPager::setDisplayedText(ActivityPager::DisplayedText disp) -{ - if (m_displayedText == disp) { - return; - } - - m_displayedText = disp; - emit displayedTextChanged(); -} - -#if HAVE_X11 -void ActivityPager::slotAddDesktop() -{ - if (!m_isX11) { - return; - } - NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops); - info.setNumberOfDesktops(info.numberOfDesktops() + 1); -} - -void ActivityPager::slotRemoveDesktop() -{ - if (!m_isX11) { - return; - } - NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops); - int desktops = info.numberOfDesktops(); - if (desktops > 1) { - info.setNumberOfDesktops(info.numberOfDesktops() - 1); - } -} -#endif - -void ActivityPager::recalculateGridSizes(int rows) -{ - // recalculate the number of rows and columns in the grid - rows = qBound(1, rows, m_desktopCount); - // avoid weird cases like having 3 rows for 4 desktops, where the last row is unused - int columns = m_desktopCount / rows; - if (m_desktopCount % rows > 0) { - columns++; - } - - rows = m_desktopCount / columns; - if (m_desktopCount % columns > 0) { - rows++; - } - - // update the grid size - m_rows = rows; - m_columns = columns; - - updateSizes(); -} - -void ActivityPager::updateSizes() -{ - const int padding = 2; // Space between miniatures of desktops - const int textMargin = 3; // Space between name of desktop and border - - const qreal leftMargin = 0; - const qreal topMargin = 0; - const qreal rightMargin = 0; - const qreal bottomMargin = 0; - - QRect totalRect; - for (int x = 0; x < m_desktopWidget->screenCount(); x++) { - totalRect |= m_desktopWidget->screenGeometry(x); - } - - const qreal ratio = (qreal) totalRect.width() / - (qreal) totalRect.height(); - - - qreal itemHeight; - qreal itemWidth; - qreal preferredItemHeight; - qreal preferredItemWidth; - - if (orientation() == Qt::Vertical) { - - itemWidth = (m_size.width() - leftMargin - rightMargin - - padding * (m_columns - 1)) / m_columns; - - itemHeight = itemWidth / ratio; - - } else { - // work out the preferred size based on the height of the geometry - preferredItemHeight = (m_size.height() - topMargin - bottomMargin - - padding * (m_rows - 1)) / m_rows; - preferredItemWidth = preferredItemHeight * ratio; - - if (m_displayedText == Name) { - // When containment is in this position we are not limited by low width and we can - // afford increasing width of applet to be able to display every name of desktops - for (int i = 0; i < m_desktopCount; i++) { - QFontMetricsF metrics(KGlobalSettings::taskbarFont()); - QSizeF textSize = metrics.size(Qt::TextSingleLine, KActivities::Info(m_controller->activities(KActivities::Info::Running)[i]).name()); - if (textSize.width() + textMargin * 2 > preferredItemWidth) { - preferredItemWidth = textSize.width() + textMargin * 2; - } - } - } - - itemWidth = (m_size.width() - leftMargin - rightMargin - - padding * (m_columns - 1)) / m_columns; - if (itemWidth > preferredItemWidth) { - itemWidth = preferredItemWidth; - } - itemHeight = preferredItemHeight; - if (itemWidth < itemHeight * ratio) { - itemWidth = itemHeight * ratio; - } - } - - m_widthScaleFactor = itemWidth / totalRect.width(); - m_heightScaleFactor = itemHeight / totalRect.height(); - - m_pagerModel->clearDesktopRects(); - - int pw = (int)(leftMargin + (itemWidth + padding) * m_columns + rightMargin); - int ph = (int)(topMargin + (itemHeight + padding) * m_rows + bottomMargin); - - if (orientation() == Qt::Vertical) { - pw = m_size.width(); - } else { - ph = m_size.height(); - } - - m_preferredSize = QSize(pw, ph); - emit preferredSizeChanged(); - - QRectF itemRect(QPointF(leftMargin, topMargin) , QSizeF(itemWidth, itemHeight)); - for (int i = 0; i < m_desktopCount; i++) { - itemRect.moveLeft(leftMargin + (i % m_columns) * (itemWidth + padding)); - itemRect.moveTop(topMargin + (i / m_columns) * (itemHeight + padding)); - - QString name = KActivities::Info(m_controller->activities(KActivities::Info::Running)[i]).name(); - m_pagerModel->appendDesktopRect(itemRect, name); - } - - m_validSizes = true; -} - -void ActivityPager::recalculateWindowRects() -{ - NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout); - m_rows = info.desktopLayoutColumnsRows().height(); - - if (!m_validSizes) { - recalculateGridSizes(m_rows); - updateSizes(); - } - - QList windows = KWindowSystem::stackingOrder(); - m_pagerModel->clearWindowRects(); - - //FIXME: this has to be done here since we don't know the slot order - //probably m_desktopCount should be removed alsogether - int newCount = m_controller->activities(KActivities::Info::Running).length(); - - if (m_desktopCount != newCount) { - m_desktopCount = newCount; - m_pagerModel->clearDesktopRects(); - recalculateGridSizes(m_rows); - } - - -#if HAVE_X11 - foreach (WId window, windows) { - KWindowInfo info = KWindowSystem::windowInfo(window, NET::WMGeometry | NET::WMFrameExtents | - NET::WMWindowType | NET::WMDesktop | - NET::WMState | NET::XAWMState | NET::WMVisibleName); - NET::WindowType type = info.windowType(NET::NormalMask | NET::DialogMask | NET::OverrideMask | - NET::UtilityMask | NET::DesktopMask | NET::DockMask | - NET::TopMenuMask | NET::SplashMask | NET::ToolbarMask | - NET::MenuMask); - - // the reason we don't check for -1 or Net::Unknown here is that legitimate windows, such - // as some java application windows, may not have a type set for them. - // apparently sane defaults on properties is beyond the wisdom of x11. - if (type == NET::Desktop || type == NET::Dock || type == NET::TopMenu || - type == NET::Splash || type == NET::Menu || type == NET::Toolbar || - info.hasState(NET::SkipPager) || info.isMinimized()) { - continue; - } - - - for (int i = 0; i < m_desktopCount; i++) { - - //check activity - NETWinInfo netInfo(QX11Info::connection(), window, QX11Info::appRootWindow(), 0, NET::WM2Activities); - QString result(netInfo.activities()); - if (!result.isEmpty() && result != "00000000-0000-0000-0000-000000000000") { - QStringList activities = result.split(','); - if (!activities.contains(m_controller->activities(KActivities::Info::Running)[i])) { - continue; - } - } - - QRectF windowRect = info.frameGeometry(); - - if (KWindowSystem::mapViewport()) { - windowRect = fixViewportPosition(windowRect.toRect()); - } - - windowRect = QRectF(windowRect.x() * m_widthScaleFactor, - windowRect.y() * m_heightScaleFactor, - windowRect.width() * m_widthScaleFactor, - windowRect.height() * m_heightScaleFactor).toRect(); - - bool active = (window == KWindowSystem::activeWindow()); - int windowIconSize = KIconLoader::global()->currentSize(KIconLoader::Small); - int windowRectSize = qMin(windowRect.width(), windowRect.height()); - windowIconSize = qMax(windowIconSize, windowRectSize / 2); - QPixmap icon = KWindowSystem::icon(info.win(), windowIconSize, windowIconSize, true); - m_pagerModel->appendWindowRect(i, window, windowRect, active, icon, info.visibleName()); - } - } -#endif -} - -void ActivityPager::currentActivityChanged(const QString &activity) -{ - m_currentActivity = activity; - setCurrentDesktop(m_controller->activities(KActivities::Info::Running).indexOf(activity) + 1); - m_desktopDown = false; - startTimerFast(); -} - -void ActivityPager::numberOfDesktopsChanged() -{ - - NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout); - m_rows = info.desktopLayoutColumnsRows().height(); - - m_desktopCount = m_controller->activities(KActivities::Info::Running).length(); - - m_pagerModel->clearDesktopRects(); - recalculateGridSizes(m_rows); - recalculateWindowRects(); -} - -void ActivityPager::desktopNamesChanged() -{ - m_pagerModel->clearDesktopRects(); - m_validSizes = false; - startTimer(); -} - -void ActivityPager::windowChanged(WId id, const unsigned long* dirty) -{ - Q_UNUSED(id) - - if (dirty[NETWinInfo::PROTOCOLS] & (NET::WMGeometry | NET::WMDesktop) || - dirty[NETWinInfo::PROTOCOLS2] & NET::WM2Activities) { - startTimer(); - } -} - -void ActivityPager::desktopsSizeChanged() -{ - m_pagerModel->clearDesktopRects(); - m_validSizes = false; - startTimer(); -} - -void ActivityPager::startTimer() -{ - if (!m_timer->isActive()) { - m_timer->start(UPDATE_DELAY); - } -} - -void ActivityPager::startTimerFast() -{ - if (!m_timer->isActive()) { - m_timer->start(FAST_UPDATE_DELAY); - } -} - -void ActivityPager::moveWindow(int window, double x, double y, int targetDesktop, int sourceDesktop) -{ -#if HAVE_X11 - if (!m_isX11) { - return; - } - WId windowId = (WId) window; - - QPointF dest = QPointF(x, y) - m_pagerModel->desktopRectAt(targetDesktop).topLeft(); - - dest = QPointF(dest.x()/m_widthScaleFactor, dest.y()/m_heightScaleFactor); - - // don't move windows to negative positions - dest = QPointF(qMax(dest.x(), qreal(0.0)), qMax(dest.y(), qreal(0.0))); - - // use _NET_MOVERESIZE_WINDOW rather than plain move, so that the WM knows this is a ActivityPager request - NETRootInfo info(QX11Info::connection(), 0); - int flags = (0x20 << 12) | (0x03 << 8) | 1; // from tool, x/y, northwest gravity - - if (!KWindowSystem::mapViewport()) { - KWindowInfo windowInfo = KWindowSystem::windowInfo(windowId, NET::WMDesktop | NET::WMState); - - if (targetDesktop < m_controller->activities(KActivities::Info::Running).length()) { - NETWinInfo netInfo(QX11Info::connection(), window, QX11Info::appRootWindow(), 0, NET::WM2Activities); - - QString newActivity = m_controller->activities(KActivities::Info::Running)[targetDesktop]; - - netInfo.setActivities(QString(newActivity).toLatin1()); - } - - // only move the window if it is not full screen and if it is kept within the same desktop - // moving when dropping between desktop is too annoying due to the small drop area. - if (!(windowInfo.state() & NET::FullScreen) && - (targetDesktop == sourceDesktop || windowInfo.onAllDesktops())) { - QPoint d = dest.toPoint(); - info.moveResizeWindowRequest(windowId, flags, d.x(), d.y(), 0, 0); - } - } else { - // setOnDesktop() with viewports is also moving a window, and since it takes a moment - // for the WM to do the move, there's a race condition with figuring out how much to move, - // so do it only as one move - dest += KWindowSystem::desktopToViewport(targetDesktop+1, false); - QPoint d = KWindowSystem::constrainViewportRelativePosition(dest.toPoint()); - info.moveResizeWindowRequest(windowId, flags, d.x(), d.y(), 0, 0); - } - m_timer->start(); -#else - Q_UNUSED(window) - Q_UNUSED(x) - Q_UNUSED(y) - Q_UNUSED(targetDesktop) - Q_UNUSED(sourceDesktop) -#endif -} - -void ActivityPager::changeDesktop(int newDesktop) -{ -#if HAVE_X11 - if (!m_isX11) { - return; - } - if (m_currentDesktop == newDesktop + 1) { - // toogle the desktop or the dashboard - if (m_currentDesktopSelected == ShowDesktop) { - NETRootInfo info(QX11Info::connection(), 0); - m_desktopDown = !m_desktopDown; - info.setShowingDesktop(m_desktopDown); - } - } else if (newDesktop < m_controller->activities(KActivities::Info::Running).length()) { - m_controller->setCurrentActivity(m_controller->activities(KActivities::Info::Running)[newDesktop]); - setCurrentDesktop(newDesktop + 1); - } -#else - Q_UNUSED(newDesktop) -#endif -} - -// KWindowSystem does not translate position when mapping viewports -// to virtual desktops (it'd probably break more things than fix), -// so the offscreen coordinates need to be fixed -QRect ActivityPager::fixViewportPosition( const QRect& r ) -{ - QRect desktopGeom = m_desktopWidget->geometry(); - int x = r.center().x() % desktopGeom.width(); - int y = r.center().y() % desktopGeom.height(); - if( x < 0 ) { - x = x + desktopGeom.width(); - } - if( y < 0 ) { - y = y + desktopGeom.height(); - } - return QRect( x - r.width() / 2, y - r.height() / 2, r.width(), r.height()); -} - -void ActivityPager::openVirtualDesktopsKCM() -{ - KProcess::execute("kcmshell5", QStringList() << "desktop"); -} - -void ActivityPager::dropMimeData(QMimeData *mimeData, int desktopId) -{ - if (!mimeData) { - return; - } - - QString newActivity; - - if (desktopId < m_controller->activities(KActivities::Info::Running).length()) { - newActivity = m_controller->activities(KActivities::Info::Running).value(desktopId); - } - - if (newActivity.isEmpty()) { - return; - } - -#if HAVE_X11 - if (m_isX11) { - bool ok; - const QList &ids = TaskManager::XWindowTasksModel::winIdsFromMimeData(mimeData, &ok); - if (ok) { - foreach (const WId &id, ids) { - KWindowSystem::setOnActivities(id, {newActivity}); - } - } - } -#endif -} - - -#include "moc_activitypager.cpp" diff --git a/applets/activitypager/plugin/activitypagerplugin.h b/applets/activitypager/plugin/activitypagerplugin.h deleted file mode 100644 --- a/applets/activitypager/plugin/activitypagerplugin.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (C) 2011 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - - -#ifndef ACTIVITYPAGERPLUGIN_H -#define ACTIVITYPAGERPLUGIN_H - -#include -#include - - -class ActivityPagerPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") -public: - virtual void registerTypes(const char *uri); -}; - -#endif // ACTIVITYPAGERPLUGIN_H diff --git a/applets/activitypager/plugin/activitypagerplugin.cpp b/applets/activitypager/plugin/activitypagerplugin.cpp deleted file mode 100644 --- a/applets/activitypager/plugin/activitypagerplugin.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2011 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - - -#include "activitypagerplugin.h" -#include "activitypager.h" - -#include - -void ActivityPagerPlugin::registerTypes (const char *uri) -{ - Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.activitypager")); - qmlRegisterType(uri, 2, 0, "ActivityPager"); -} diff --git a/applets/activitypager/plugin/model.h b/applets/activitypager/plugin/model.h deleted file mode 100644 --- a/applets/activitypager/plugin/model.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2012 Luís Gabriel Lima - * - * 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 MODEL_H -#define MODEL_H - -#include -#include -#include // For WId -#include - -class RectangleModel : public QAbstractListModel -{ - Q_OBJECT -public: - enum RectangleRoles { - WidthRole = Qt::UserRole + 1, - HeightRole, - XRole, - YRole - }; - - RectangleModel(QObject *parent = 0); - - virtual QHash roles() const; - virtual void clear(); - void append(const QRectF &rect); - QRectF &rectAt(int index); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -private: - QList m_rects; -}; - - -class WindowModel : public RectangleModel -{ - Q_OBJECT -public: - enum WindowRole { - IdRole = RectangleModel::YRole + 1, - ActiveRole, - IconRole, - VisibleNameRole - }; - - WindowModel(QObject *parent = 0); - - QHash roles() const; - void clear(); - void append(WId, const QRectF &, bool active, const QPixmap &icon, const QString &name); - WId idAt(int index) const; - QString visibleNameAt(int index) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -private: - QList m_ids; - QList m_active; - QList m_icons; - QStringList m_visibleNames; -}; - - -class PagerModel : public QAbstractListModel -{ - Q_OBJECT -public: - enum PagerRoles { - WindowsRole = RectangleModel::YRole + 1, - DesktopNameRole - }; - - PagerModel(QObject *parent = 0); - - QHash roles() const; - - void clearDesktopRects(); - void appendDesktopRect(const QRectF &rect, const QString &name); - QRectF &desktopRectAt(int index); - - void clearWindowRects(); - void appendWindowRect(int desktopId, WId, const QRectF &, bool active, - const QPixmap &icon, const QString &name); - WindowModel *windowsAt(int index) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - -private: - RectangleModel m_desktops; - QList m_windows; - QStringList m_names; -}; - -#endif // MODEL_H diff --git a/applets/activitypager/plugin/model.cpp b/applets/activitypager/plugin/model.cpp deleted file mode 100644 --- a/applets/activitypager/plugin/model.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright 2012 Luís Gabriel Lima - * - * 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 "model.h" - -RectangleModel::RectangleModel(QObject *parent) - : QAbstractListModel(parent) -{ - setRoleNames(roles()); -} - -QHash RectangleModel::roles() const -{ - QHash rectRoles; - rectRoles[WidthRole] = "width"; - rectRoles[HeightRole] = "height"; - rectRoles[XRole] = "x"; - rectRoles[YRole] = "y"; - return rectRoles; -} - -void RectangleModel::clear() -{ - m_rects.clear(); -} - -void RectangleModel::append(const QRectF &rect) -{ - m_rects.append(rect); -} - -QRectF &RectangleModel::rectAt(int index) -{ - return m_rects[index]; -} - -int RectangleModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return m_rects.count(); -} - -QVariant RectangleModel::data(const QModelIndex &index, int role) const -{ - if (index.row() < 0 || index.row() > m_rects.count()) - return QVariant(); - - const QRectF &rect = m_rects[index.row()]; - switch(role) { - case WidthRole: - return rect.width(); - case HeightRole: - return rect.height(); - case XRole: - return rect.x(); - case YRole: - return rect.y(); - default: - return QVariant(); - } -} - - -WindowModel::WindowModel(QObject *parent) - : RectangleModel(parent) -{ - setRoleNames(roles()); -} - -QHash WindowModel::roles() const -{ - QHash rectRoles = RectangleModel::roles(); - rectRoles[IdRole] = "windowId"; - rectRoles[ActiveRole] = "active"; - rectRoles[IconRole] = "icon"; - rectRoles[VisibleNameRole] = "visibleName"; - return rectRoles; -} - -void WindowModel::clear() -{ - beginResetModel(); - RectangleModel::clear(); - m_ids.clear(); - m_active.clear(); - m_icons.clear(); - m_visibleNames.clear(); - endResetModel(); -} - -void WindowModel::append(WId windowId, const QRectF &rect, bool active, - const QPixmap &icon, const QString &name) -{ - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_ids.append(windowId); - RectangleModel::append(rect); - m_active.append(active); - m_icons.append(icon); - m_visibleNames.append(name); - endInsertRows(); -} - -WId WindowModel::idAt(int index) const -{ - return m_ids[index]; -} - -QString WindowModel::visibleNameAt(int index) const -{ - return m_visibleNames[index]; -} - -QVariant WindowModel::data(const QModelIndex &index, int role) const -{ - if (index.row() < 0 || index.row() >= rowCount()) - return QVariant(); - - if (role >= RectangleModel::WidthRole && role < IdRole) - return RectangleModel::data(index, role); - - switch (role) { - case IdRole: - return int(m_ids[index.row()]); - case ActiveRole: - return m_active[index.row()]; - case IconRole: - return m_icons[index.row()]; - case VisibleNameRole: - return m_visibleNames[index.row()]; - default: - return QVariant(); - } -} - - -PagerModel::PagerModel(QObject *parent) - : QAbstractListModel(parent) -{ - setRoleNames(roles()); -} - -WindowModel *PagerModel::windowsAt(int index) const -{ - if (index < 0 || index >= m_windows.count()) - return 0; - - return qobject_cast(m_windows[index]); -} - -QHash PagerModel::roles() const -{ - QHash rectRoles = m_desktops.roles(); - rectRoles[WindowsRole] = "windows"; - rectRoles[DesktopNameRole] = "desktopName"; - return rectRoles; -} - -void PagerModel::clearDesktopRects() -{ - beginResetModel(); - m_desktops.clear(); - m_names.clear(); - endResetModel(); -} - -void PagerModel::appendDesktopRect(const QRectF &rect, const QString &name) -{ - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_desktops.append(rect); - m_names.append(name); - endInsertRows(); -} - -QRectF& PagerModel::desktopRectAt(int index) -{ - return m_desktops.rectAt(index); -} - -void PagerModel::clearWindowRects() -{ - int removeIndex = -1; - for (int i = 0; i < m_windows.count(); i++) { - windowsAt(i)->clear(); - - if (i >= rowCount()) - removeIndex = (removeIndex == -1) ? i : -1; - } - - if (removeIndex != -1) { - // remove the windows model if the number of desktop has decreased - for (int i = m_windows.count()-1; i >= removeIndex; i--) { - windowsAt(i)->deleteLater(); - m_windows.removeAt(i); - } - } - - // append more windows model if the number of desktop has increased - for (int i = m_windows.count(); i < rowCount(); i++) - m_windows.append(new WindowModel(this)); -} - -void PagerModel::appendWindowRect(int desktopId, WId windowId, const QRectF &rect, - bool active, const QPixmap &icon, const QString &name) -{ - WindowModel *windows = windowsAt(desktopId); - if (!windows) - return; - - windows->append(windowId, rect, active, icon, name); - - QModelIndex i = index(desktopId); - emit dataChanged(i, i); -} - -QVariant PagerModel::data(const QModelIndex &index, int role) const -{ - if (role >= RectangleModel::WidthRole && role < WindowsRole) - return m_desktops.data(index, role); - - if (index.row() < 0 || index.row() >= m_windows.count()) - return QVariant(); - - switch (role) { - case WindowsRole: - return QVariant::fromValue(m_windows[index.row()]); - case DesktopNameRole: - return m_names[index.row()]; - default: - return QVariant(); - } -} - -int PagerModel::rowCount(const QModelIndex &index) const -{ - return m_desktops.rowCount(index); -} diff --git a/applets/activitypager/plugin/qmldir b/applets/activitypager/plugin/qmldir deleted file mode 100644 --- a/applets/activitypager/plugin/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module org.kde.plasma.private.activitypager - -plugin activitypagerplugin