From 681fec4cacb0120d5a0b3722c2cd61752ee0b66c Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 5 Feb 2015 04:26:19 +0300 Subject: [PATCH 1/3] start work on desktop panel --- sources/CMakeLists.txt | 1 + .../package/contents/config/main.xml | 6 +- .../package/contents/ui/advanced.qml | 6 +- .../package/contents/ui/appearance.qml | 1 - .../package/contents/ui/dataengine.qml | 7 +- .../package/contents/ui/main.qml | 8 +- .../package/contents/ui/tooltip.qml | 39 +- .../package/contents/ui/widget.qml | 7 +- .../awesome-widget-kf5/plugin/awtooltip.cpp | 11 +- sources/desktop-panel-kf5/CMakeLists.txt | 16 + .../package/contents/config/config.qml | 47 ++ .../package/contents/config/main.xml | 84 ++++ .../package/contents/ui/about.qml | 99 +++++ .../package/contents/ui/advanced.qml | 275 ++++++++++++ .../package/contents/ui/appearance.qml | 402 ++++++++++++++++++ .../package/contents/ui/general.qml | 36 ++ .../package/contents/ui/main.qml | 85 ++++ .../package/contents/ui/qmldir | 1 + .../package/contents/ui/widget.qml | 234 ++++++++++ .../package/metadata.desktop | 28 ++ .../desktop-panel-kf5/plugin/CMakeLists.txt | 33 ++ .../desktop-panel-kf5/plugin/desktoppanel.cpp | 39 ++ .../desktop-panel-kf5/plugin/desktoppanel.h | 37 ++ sources/desktop-panel-kf5/plugin/dpadds.cpp | 255 +++++++++++ sources/desktop-panel-kf5/plugin/dpadds.h | 67 +++ ...plet-org.kde.plasma.desktop-panel.notifyrc | 24 ++ sources/desktop-panel-kf5/plugin/qmldir | 3 + 27 files changed, 1805 insertions(+), 46 deletions(-) create mode 100644 sources/desktop-panel-kf5/CMakeLists.txt create mode 100644 sources/desktop-panel-kf5/package/contents/config/config.qml create mode 100644 sources/desktop-panel-kf5/package/contents/config/main.xml create mode 100644 sources/desktop-panel-kf5/package/contents/ui/about.qml create mode 100644 sources/desktop-panel-kf5/package/contents/ui/advanced.qml create mode 100644 sources/desktop-panel-kf5/package/contents/ui/appearance.qml create mode 100644 sources/desktop-panel-kf5/package/contents/ui/general.qml create mode 100644 sources/desktop-panel-kf5/package/contents/ui/main.qml create mode 100644 sources/desktop-panel-kf5/package/contents/ui/qmldir create mode 100644 sources/desktop-panel-kf5/package/contents/ui/widget.qml create mode 100644 sources/desktop-panel-kf5/package/metadata.desktop create mode 100644 sources/desktop-panel-kf5/plugin/CMakeLists.txt create mode 100644 sources/desktop-panel-kf5/plugin/desktoppanel.cpp create mode 100644 sources/desktop-panel-kf5/plugin/desktoppanel.h create mode 100644 sources/desktop-panel-kf5/plugin/dpadds.cpp create mode 100644 sources/desktop-panel-kf5/plugin/dpadds.h create mode 100644 sources/desktop-panel-kf5/plugin/plasma-applet-org.kde.plasma.desktop-panel.notifyrc create mode 100644 sources/desktop-panel-kf5/plugin/qmldir diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index eeda57a..9ffb346 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -43,6 +43,7 @@ if (BUILD_KDE4) add_subdirectory (desktop-panel-kde4) else () add_subdirectory (awesome-widget-kf5) + add_subdirectory (desktop-panel-kf5) endif () # translations diff --git a/sources/awesome-widget-kf5/package/contents/config/main.xml b/sources/awesome-widget-kf5/package/contents/config/main.xml index 0045137..e49a2bd 100644 --- a/sources/awesome-widget-kf5/package/contents/config/main.xml +++ b/sources/awesome-widget-kf5/package/contents/config/main.xml @@ -80,13 +80,13 @@ #ff00ff - + true - + #008800 - + #880000 diff --git a/sources/awesome-widget-kf5/package/contents/ui/advanced.qml b/sources/awesome-widget-kf5/package/contents/ui/advanced.qml index 2ee6c94..1c1890a 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/advanced.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/advanced.qml @@ -47,15 +47,15 @@ Item { "swapTooltip": plasmoid.configuration.swapTooltip, "downTooltip": plasmoid.configuration.downTooltip, "upTooltip": plasmoid.configuration.downTooltip, - "batteryTooltip": plasmoid.configuration.batteryTooltip, + "batTooltip": plasmoid.configuration.batTooltip, "cpuTooltipColor": plasmoid.configuration.cpuTooltipColor, "cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor, "memTooltipColor": plasmoid.configuration.memTooltipColor, "swapTooltipColor": plasmoid.configuration.swapTooltipColor, "downTooltipColor": plasmoid.configuration.downTooltipColor, "upTooltipColor": plasmoid.configuration.upTooltipColor, - "batteryTooltipColor": plasmoid.configuration.batteryTooltipColor, - "batteryInTooltipColor": plasmoid.configuration.batteryInTooltipColor + "batTooltipColor": plasmoid.configuration.batTooltipColor, + "batInTooltipColor": plasmoid.configuration.batInTooltipColor } property alias cfg_background: background.checked diff --git a/sources/awesome-widget-kf5/package/contents/ui/appearance.qml b/sources/awesome-widget-kf5/package/contents/ui/appearance.qml index d7be19b..0ca5464 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/appearance.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/appearance.qml @@ -21,7 +21,6 @@ import QtQuick.Controls.Styles 1.3 as QtStyles import QtQuick.Dialogs 1.1 as QtDialogs import org.kde.plasma.private.awesomewidget 1.0 -import "." Item { diff --git a/sources/awesome-widget-kf5/package/contents/ui/dataengine.qml b/sources/awesome-widget-kf5/package/contents/ui/dataengine.qml index 5fec953..4e18e59 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/dataengine.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/dataengine.qml @@ -22,7 +22,6 @@ import QtQuick.Layouts 1.0 as QtLayouts import QtQuick.Controls.Styles 1.3 as QtStyles import org.kde.plasma.private.awesomewidget 1.0 -import "." Item { @@ -43,15 +42,15 @@ Item { "swapTooltip": plasmoid.configuration.swapTooltip, "downTooltip": plasmoid.configuration.downTooltip, "upTooltip": plasmoid.configuration.downTooltip, - "batteryTooltip": plasmoid.configuration.batteryTooltip, + "batTooltip": plasmoid.configuration.batTooltip, "cpuTooltipColor": plasmoid.configuration.cpuTooltipColor, "cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor, "memTooltipColor": plasmoid.configuration.memTooltipColor, "swapTooltipColor": plasmoid.configuration.swapTooltipColor, "downTooltipColor": plasmoid.configuration.downTooltipColor, "upTooltipColor": plasmoid.configuration.upTooltipColor, - "batteryTooltipColor": plasmoid.configuration.batteryTooltipColor, - "batteryInTooltipColor": plasmoid.configuration.batteryInTooltipColor + "batTooltipColor": plasmoid.configuration.batTooltipColor, + "batInTooltipColor": plasmoid.configuration.batInTooltipColor } property variant cfg_dataengine: AWActions.readDataEngineConfiguration() diff --git a/sources/awesome-widget-kf5/package/contents/ui/main.qml b/sources/awesome-widget-kf5/package/contents/ui/main.qml index fa1c910..b672611 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/main.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/main.qml @@ -47,15 +47,15 @@ Item { "swapTooltip": plasmoid.configuration.swapTooltip, "downTooltip": plasmoid.configuration.downTooltip, "upTooltip": plasmoid.configuration.downTooltip, - "batteryTooltip": plasmoid.configuration.batteryTooltip, + "batTooltip": plasmoid.configuration.batTooltip, "cpuTooltipColor": plasmoid.configuration.cpuTooltipColor, "cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor, "memTooltipColor": plasmoid.configuration.memTooltipColor, "swapTooltipColor": plasmoid.configuration.swapTooltipColor, "downTooltipColor": plasmoid.configuration.downTooltipColor, "upTooltipColor": plasmoid.configuration.upTooltipColor, - "batteryTooltipColor": plasmoid.configuration.batteryTooltipColor, - "batteryInTooltipColor": plasmoid.configuration.batteryInTooltipColor + "batTooltipColor": plasmoid.configuration.batTooltipColor, + "batInTooltipColor": plasmoid.configuration.batInTooltipColor } signal needUpdate @@ -111,7 +111,7 @@ Item { id: timeDE engine: "time" connectedSources: ["Local"] - interval: plasmoid.configuration.interval + interval: 1000 onNewData: { if (debug) console.log("[main::onNewData] : Update source " + sourceName) diff --git a/sources/awesome-widget-kf5/package/contents/ui/tooltip.qml b/sources/awesome-widget-kf5/package/contents/ui/tooltip.qml index 879e88c..b4bc184 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/tooltip.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/tooltip.qml @@ -21,7 +21,6 @@ import QtQuick.Controls.Styles 1.3 as QtStyles import QtQuick.Dialogs 1.1 as QtDialogs import org.kde.plasma.private.awesomewidget 1.0 -import "." Item { @@ -47,9 +46,9 @@ Item { property alias cfg_downTooltip: downTooltip.checked property alias cfg_downTooltipColor: downTooltipColor.text property alias cfg_upTooltipColor: upTooltipColor.text - property alias cfg_batteryTooltip: batteryTooltip.checked - property alias cfg_batteryTooltipColor: batteryTooltipColor.text - property alias cfg_batteryInTooltipColor: batteryInTooltipColor.text + property alias cfg_batTooltip: batTooltip.checked + property alias cfg_batTooltipColor: batTooltipColor.text + property alias cfg_batInTooltipColor: batInTooltipColor.text Column { @@ -430,13 +429,13 @@ Item { width: parent.width QtControls.Label { height: parent.height - width: parent.width * 2 / 5 - batteryTooltip.width + width: parent.width * 2 / 5 - batTooltip.width horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter text: i18n("Battery active color") } QtControls.CheckBox { - id: batteryTooltip + id: batTooltip height: parent.height width: implicitWidth style: QtStyles.CheckBoxStyle { @@ -458,22 +457,22 @@ Item { } } QtControls.Button { - id: batteryTooltipColor + id: batTooltipColor width: parent.width * 3 / 5 style: QtStyles.ButtonStyle { background: Rectangle { - color: plasmoid.configuration.batteryTooltipColor + color: plasmoid.configuration.batTooltipColor } } - text: plasmoid.configuration.batteryTooltipColor - onClicked: batteryTooltipColorDialog.visible = true + text: plasmoid.configuration.batTooltipColor + onClicked: batTooltipColorDialog.visible = true } QtDialogs.ColorDialog { - id: batteryTooltipColorDialog + id: batTooltipColorDialog title: i18n("Select a color") - color: batteryTooltipColor.text - onAccepted: batteryTooltipColor.text = batteryTooltipColorDialog.color + color: batTooltipColor.text + onAccepted: batTooltipColor.text = batTooltipColorDialog.color } } @@ -488,22 +487,22 @@ Item { text: i18n("Battery inactive color") } QtControls.Button { - id: batteryInTooltipColor + id: batInTooltipColor width: parent.width * 3 / 5 style: QtStyles.ButtonStyle { background: Rectangle { - color: plasmoid.configuration.batteryInTooltipColor + color: plasmoid.configuration.batInTooltipColor } } - text: plasmoid.configuration.batteryInTooltipColor - onClicked: batteryInTooltipColorDialog.visible = true + text: plasmoid.configuration.batInTooltipColor + onClicked: batInTooltipColorDialog.visible = true } QtDialogs.ColorDialog { - id: batteryInTooltipColorDialog + id: batInTooltipColorDialog title: i18n("Select a color") - color: batteryInTooltipColor.text - onAccepted: batteryInTooltipColor.text = batteryInTooltipColorDialog.color + color: batInTooltipColor.text + onAccepted: batInTooltipColor.text = batInTooltipColorDialog.color } } } diff --git a/sources/awesome-widget-kf5/package/contents/ui/widget.qml b/sources/awesome-widget-kf5/package/contents/ui/widget.qml index b0810c7..a996815 100644 --- a/sources/awesome-widget-kf5/package/contents/ui/widget.qml +++ b/sources/awesome-widget-kf5/package/contents/ui/widget.qml @@ -20,7 +20,6 @@ import QtQuick.Controls 1.3 as QtControls import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.private.awesomewidget 1.0 -import "." Item { @@ -48,15 +47,15 @@ Item { "swapTooltip": plasmoid.configuration.swapTooltip, "downTooltip": plasmoid.configuration.downTooltip, "upTooltip": plasmoid.configuration.downTooltip, - "batteryTooltip": plasmoid.configuration.batteryTooltip, + "batTooltip": plasmoid.configuration.batTooltip, "cpuTooltipColor": plasmoid.configuration.cpuTooltipColor, "cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor, "memTooltipColor": plasmoid.configuration.memTooltipColor, "swapTooltipColor": plasmoid.configuration.swapTooltipColor, "downTooltipColor": plasmoid.configuration.downTooltipColor, "upTooltipColor": plasmoid.configuration.upTooltipColor, - "batteryTooltipColor": plasmoid.configuration.batteryTooltipColor, - "batteryInTooltipColor": plasmoid.configuration.batteryInTooltipColor + "batTooltipColor": plasmoid.configuration.batTooltipColor, + "batInTooltipColor": plasmoid.configuration.batInTooltipColor } property alias cfg_text: textPattern.text diff --git a/sources/awesome-widget-kf5/plugin/awtooltip.cpp b/sources/awesome-widget-kf5/plugin/awtooltip.cpp index af97ee3..0540902 100644 --- a/sources/awesome-widget-kf5/plugin/awtooltip.cpp +++ b/sources/awesome-widget-kf5/plugin/awtooltip.cpp @@ -51,7 +51,7 @@ AWToolTip::AWToolTip(QObject *parent, counts += configuration[QString("memTooltip")].toInt(); counts += configuration[QString("swapTooltip")].toInt(); counts += configuration[QString("downTooltip")].toInt(); - counts += configuration[QString("batteryTooltip")].toInt(); + counts += configuration[QString("batTooltip")].toInt(); boundaries[QString("cpuTooltip")] = 100.0; boundaries[QString("cpuclTooltip")] = 4000.0; @@ -108,10 +108,7 @@ QPixmap AWToolTip::image() for (int i=0; i(data[requiredKeys[i]].count()); float normY = 100.0 / (1.5 * boundaries[requiredKeys[i]]); - if (requiredKeys[i] == QString("batTooltip")) - isBattery = true; - else - isBattery = false; + isBattery = (requiredKeys[i] == QString("batTooltip")); if (!isBattery) pen.setColor(QColor(configuration[requiredKeys[i] + QString("Color")].toString())); float shift = i * 100.0; if (down) shift -= 100.0; @@ -122,9 +119,9 @@ QPixmap AWToolTip::image() float y2 = - fabs(data[requiredKeys[i]][j+1]) * normY + 5.0; if (isBattery) { if (data[requiredKeys[i]][j+1] > 0) - pen.setColor(QColor(configuration[QString("batteryColor")].toString())); + pen.setColor(QColor(configuration[QString("batTooltipColor")].toString())); else - pen.setColor(QColor(configuration[QString("batteryInColor")].toString())); + pen.setColor(QColor(configuration[QString("batInTooltipColor")].toString())); } toolTipScene->addLine(x1, y1, x2, y2, pen); } diff --git a/sources/desktop-panel-kf5/CMakeLists.txt b/sources/desktop-panel-kf5/CMakeLists.txt new file mode 100644 index 0000000..4173e9c --- /dev/null +++ b/sources/desktop-panel-kf5/CMakeLists.txt @@ -0,0 +1,16 @@ +# set project name +set (SUBPROJECT plasma_applet_desktop-panel) +message (STATUS "Subproject ${SUBPROJECT}") + +find_package (ECM 0.0.12 REQUIRED NO_MODULE) +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) + +find_package (Qt5 REQUIRED COMPONENTS Core Qml) +find_package (KF5 REQUIRED COMPONENTS I18n Notifications Plasma Service WindowSystem) + +include (KDEInstallDirs) +include (KDECMakeSettings) +include (KDECompilerSettings) + +add_subdirectory (plugin) +plasma_install_package (package org.kde.plasma.desktoppanel) diff --git a/sources/desktop-panel-kf5/package/contents/config/config.qml b/sources/desktop-panel-kf5/package/contents/config/config.qml new file mode 100644 index 0000000..5f62ce6 --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/config/config.qml @@ -0,0 +1,47 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 + +import org.kde.plasma.configuration 2.0 + + +ConfigModel { + ConfigCategory { + name: i18n("Widget") + icon: "utilities-system-monitor" + source: "widget.qml" + } + + ConfigCategory { + name: i18n("Advanced") + icon: "system-run" + source: "advanced.qml" + } + + ConfigCategory { + name: i18n("Appearance") + icon: "preferences-desktop-theme" + source: "appearance.qml" + } + + ConfigCategory { + name: i18n("About") + icon: "help-about" + source: "about.qml" + } +} diff --git a/sources/desktop-panel-kf5/package/contents/config/main.xml b/sources/desktop-panel-kf5/package/contents/config/main.xml new file mode 100644 index 0000000..3440e43 --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/config/main.xml @@ -0,0 +1,84 @@ + + + + + + + + [$fullmark$number/$total: $name] + + + + + + + true + + + windows + + + 200 + + + #ffffff + + + true + + + false + + + ¤ + + + -1 + + + + + + + center + + + Terminus + + + 12 + + + #000000 + + + normal + + + normal + + + + center + + + Terminus + + + 12 + + + #ff0000 + + + normal + + + normal + + + + diff --git a/sources/desktop-panel-kf5/package/contents/ui/about.qml b/sources/desktop-panel-kf5/package/contents/ui/about.qml new file mode 100644 index 0000000..746ed6f --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/ui/about.qml @@ -0,0 +1,99 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.3 as QtControls +import QtQuick.Layouts 1.0 as QtLayouts + +import org.kde.plasma.private.desktoppanel 1.0 + + +Item { + id: aboutPage + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property bool debug: DPAdds.isDebugEnabled() + + + Column { + id: pageColumn + width: units.gridUnit * 25 + QtControls.TabView { + height: parent.height + width: parent.width + QtControls.Tab { + title: i18n("About") + + QtLayouts.ColumnLayout { + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + text: DPAdds.getAboutText("header") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignJustify + text: DPAdds.getAboutText("description") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignLeft + textFormat: Text.RichText + text: DPAdds.getAboutText("links") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + font.capitalization: Font.SmallCaps + horizontalAlignment: Text.AlignHCenter + textFormat: Text.RichText + text: DPAdds.getAboutText("copy") + } + } + } + + QtControls.Tab { + title: i18n("Acknowledgment") + + QtLayouts.ColumnLayout { + QtControls.Label { + QtLayouts.Layout.fillWidth: true + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignJustify + text: DPAdds.getAboutText("translators") + } + + QtControls.Label { + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignJustify + textFormat: Text.RichText + text: DPAdds.getAboutText("3rdparty") + } + } + } + } + } + + Component.onCompleted: { + if (debug) console.log("[about::onCompleted]") + } +} diff --git a/sources/desktop-panel-kf5/package/contents/ui/advanced.qml b/sources/desktop-panel-kf5/package/contents/ui/advanced.qml new file mode 100644 index 0000000..1c1890a --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/ui/advanced.qml @@ -0,0 +1,275 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.3 as QtControls +import org.kde.plasma.core 2.0 as PlasmaCore + +import org.kde.plasma.private.awesomewidget 1.0 + + +Item { + id: advancedPage + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property bool debug: AWKeys.isDebugEnabled() + property variant settings: { + "customTime": plasmoid.configuration.customTime, + "customUptime": plasmoid.configuration.customUptime, + "tempUnits": plasmoid.configuration.tempUnits, + "acOnline": plasmoid.configuration.acOnline, + "acOffline": plasmoid.configuration.acOffline + } + property variant tooltipSettings: { + "tooltipNumber": plasmoid.configuration.tooltipNumber, + "useTooltipBackground": plasmoid.configuration.useTooltipBackground, + "tooltipBackgroung": plasmoid.configuration.tooltipBackgroung, + "cpuTooltip": plasmoid.configuration.cpuTooltip, + "cpuclTooltip": plasmoid.configuration.cpuclTooltip, + "memTooltip": plasmoid.configuration.memTooltip, + "swapTooltip": plasmoid.configuration.swapTooltip, + "downTooltip": plasmoid.configuration.downTooltip, + "upTooltip": plasmoid.configuration.downTooltip, + "batTooltip": plasmoid.configuration.batTooltip, + "cpuTooltipColor": plasmoid.configuration.cpuTooltipColor, + "cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor, + "memTooltipColor": plasmoid.configuration.memTooltipColor, + "swapTooltipColor": plasmoid.configuration.swapTooltipColor, + "downTooltipColor": plasmoid.configuration.downTooltipColor, + "upTooltipColor": plasmoid.configuration.upTooltipColor, + "batTooltipColor": plasmoid.configuration.batTooltipColor, + "batInTooltipColor": plasmoid.configuration.batInTooltipColor + } + + property alias cfg_background: background.checked + property alias cfg_customTime: customTime.text + property alias cfg_customUptime: customUptime.text + property string cfg_tempUnits: tempUnits.currentText + property alias cfg_acOnline: acOnline.text + property alias cfg_acOffline: acOffline.text + + + Column { + id: pageColumn + width: units.gridUnit * 25 + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.heigth + width: parent.width * 2 / 5 + } + QtControls.CheckBox { + id: background + width: parent.width * 3 / 5 + text: i18n("Enable background") + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Custom time format") + } + QtControls.TextField { + id: customTime + width: parent.width * 3 / 5 + text: plasmoid.configuration.customTime + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Custom uptime format") + } + QtControls.TextField { + id: customUptime + width: parent.width * 3 / 5 + text: plasmoid.configuration.customUptime + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Temperature units") + } + QtControls.ComboBox { + id: tempUnits + width: parent.width * 3 / 5 + textRole: "label" + model: [ + { + 'label': i18n("Celsius"), + 'name': "Celsius" + }, + { + 'label': i18n("Fahrenheit"), + 'name': "Fahrenheit" + }, + { + 'label': i18n("Kelvin"), + 'name': "Kelvin" + }, + { + 'label': i18n("Reaumur"), + 'name': "Reaumur" + }, + { + 'label': i18n("cm^-1"), + 'name': "cm^-1" + }, + { + 'label': i18n("kJ/mol"), + 'name': "kJ/mol" + }, + { + 'label': i18n("kcal/mol"), + 'name': "kcal/mol" + } + ] + onCurrentIndexChanged: cfg_tempUnits = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.tempUnits) { + tempUnits.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("AC online tag") + } + QtControls.TextField { + id: acOnline + width: parent.width * 3 / 5 + text: plasmoid.configuration.acOnline + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("AC offline tag") + } + QtControls.TextField { + id: acOffline + width: parent.width * 3 / 5 + text: plasmoid.configuration.acOffline + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Bars") + } + QtControls.Button { + width: parent.width * 3 / 5 + text: i18n("Edit bars") + onClicked: AWKeys.editItem("graphicalitem") + } + } + } + + // we need to initializate DataEngines here too + // because we need to get keys and values + PlasmaCore.DataSource { + id: systemmonitorDE + engine: "systemmonitor" + connectedSources: systemmonitorDE.sources + interval: 5000 + + onNewData: { + if (debug) console.log("[advanced::onNewData] : Update source " + sourceName) + + AWKeys.setDataBySource(sourceName, data, settings) + } + } + + PlasmaCore.DataSource { + id: extsysmonDE + engine: "extsysmon" + connectedSources: ["battery", "custom", "desktop", "netdev", "gpu", + "gputemp", "hddtemp", "pkg", "player", "ps", "update"] + interval: 5000 + + onNewData: { + if (debug) console.log("[advanced::onNewData] : Update source " + sourceName) + + AWKeys.setDataBySource(sourceName, data, settings) + } + } + + PlasmaCore.DataSource { + id: timeDE + engine: "time" + connectedSources: ["Local"] + interval: 5000 + + onNewData: { + if (debug) console.log("[advanced::onNewData] : Update source " + sourceName) + + AWKeys.setDataBySource(sourceName, data, settings) + } + } + + Component.onCompleted: { + if (debug) console.log("[advanced::onCompleted]") + + // init submodule + AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings) + } +} diff --git a/sources/desktop-panel-kf5/package/contents/ui/appearance.qml b/sources/desktop-panel-kf5/package/contents/ui/appearance.qml new file mode 100644 index 0000000..45b62e5 --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/ui/appearance.qml @@ -0,0 +1,402 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.3 as QtControls +import QtQuick.Layouts 1.0 as QtLayouts +import QtQuick.Controls.Styles 1.3 as QtStyles +import QtQuick.Dialogs 1.1 as QtDialogs + +import org.kde.plasma.private.desktoppanel 1.0 + + +Item { + id: appearancePage + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property bool debug: DPAdds.isDebugEnabled() + property variant weight: { + 25: 0, + 50: 1, + 63: 3, + 75: 4, + 87: 5 + } + + property alias cfg_fontFamily: selectFont.text + property alias cfg_fontSize: fontSize.value + property string cfg_fontWeight: fontWeight.currentText + property string cfg_fontStyle: fontStyle.currentText + property alias cfg_fontColor: selectColor.text + property alias cfg_currentFontFamily: currentSelectFont.text + property alias cfg_currentFontSize: currentFontSize.value + property string cfg_currentFontWeight: currentFontWeight.currentText + property string cfg_currentFontStyle: currentFontStyle.currentText + property alias cfg_currentFontColor: currentSelectColor.text + + + Column { + id: pageColumn + width: units.gridUnit * 25 + QtControls.TabView { + height: parent.height + width: parent.width + QtControls.Tab { + title: i18n("Active desktop") + + QtLayouts.ColumnLayout { + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font") + } + QtControls.Button { + id: currentSelectFont + width: parent.width * 2 / 3 + text: plasmoid.configuration.currentFontFamily + onClicked: currentFontDialog.visible = true + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font size") + } + QtControls.SpinBox { + id: currentFontSize + width: parent.width * 2 / 3 + minimumValue: 8 + maximumValue: 32 + stepSize: 1 + value: plasmoid.configuration.currentFontSize + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font weight") + } + QtControls.ComboBox { + id: currentFontWeight + width: parent.width * 2 / 3 + textRole: "label" + model: [ + { + 'label': i18n("light"), + 'name': "light" + }, + { + 'label': i18n("normal"), + 'name': "normal" + }, + { + 'label': i18n("demi bold"), + 'name': "demibold" + }, + { + 'label': i18n("bold"), + 'name': "bold" + }, + { + 'label': i18n("black"), + 'name': "black" + } + ] + onCurrentIndexChanged: cfg_currentFontWeight = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.currentFontWeight) { + currentFontWeight.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font style") + } + QtControls.ComboBox { + id: currentFontStyle + width: parent.width * 2 / 3 + textRole: "label" + model: [ + { + 'label': i18n("normal"), + 'name': "normal" + }, + { + 'label': i18n("italic"), + 'name': "italic" + } + ] + onCurrentIndexChanged: cfg_currentFontStyle = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.currentFontStyle) { + currentFontStyle.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font color") + } + QtControls.Button { + id: currentSelectColor + width: parent.width * 2 / 3 + style: QtStyles.ButtonStyle { + background: Rectangle { + color: plasmoid.configuration.currentFontColor + } + } + text: plasmoid.configuration.currentFontColor + onClicked: currentColorDialog.visible = true + } + } + } + + QtDialogs.ColorDialog { + id: currentColorDialog + title: i18n("Select a color") + color: currentSelectColor.text + onAccepted: currentSelectColor.text = currentColorDialog.color + } + + QtDialogs.FontDialog { + id: currentFontDialog + title: i18n("Select a font") + font: Qt.font({ family: currentSelectFont.text, pointSize: currentFontSize.value, weight: Font.Normal }) + onAccepted: { + currentSelectFont.text = currentFontDialog.font.family + currentFontSize.value = currentFontDialog.font.pointSize + currentFontStyle.currentIndex = currentFontDialog.font.italic ? 1 : 0 + currentFontWeight.currentIndex = weight[currentFontDialog.font.weight] + } + } + } + + QtControls.Tab { + title: i18n("Inactive desktop") + + QtLayouts.ColumnLayout { + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font") + } + QtControls.Button { + id: selectFont + width: parent.width * 2 / 3 + text: plasmoid.configuration.fontFamily + onClicked: fontDialog.visible = true + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font size") + } + QtControls.SpinBox { + id: fontSize + width: parent.width * 2 / 3 + minimumValue: 8 + maximumValue: 32 + stepSize: 1 + value: plasmoid.configuration.fontSize + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font weight") + } + QtControls.ComboBox { + id: fontWeight + width: parent.width * 2 / 3 + textRole: "label" + model: [ + { + 'label': i18n("light"), + 'name': "light" + }, + { + 'label': i18n("normal"), + 'name': "normal" + }, + { + 'label': i18n("demi bold"), + 'name': "demibold" + }, + { + 'label': i18n("bold"), + 'name': "bold" + }, + { + 'label': i18n("black"), + 'name': "black" + } + ] + onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.fontWeight) { + fontWeight.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font style") + } + QtControls.ComboBox { + id: fontStyle + width: parent.width * 2 / 3 + textRole: "label" + model: [ + { + 'label': i18n("normal"), + 'name': "normal" + }, + { + 'label': i18n("italic"), + 'name': "italic" + } + ] + onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"] + Component.onCompleted: { + for (var i = 0; i < model.length; i++) { + if (model[i]["name"] == plasmoid.configuration.fontStyle) { + fontStyle.currentIndex = i; + } + } + } + } + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width / 3 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Font color") + } + QtControls.Button { + id: selectColor + width: parent.width * 2 / 3 + style: QtStyles.ButtonStyle { + background: Rectangle { + color: plasmoid.configuration.fontColor + } + } + text: plasmoid.configuration.fontColor + onClicked: colorDialog.visible = true + } + } + } + + QtDialogs.ColorDialog { + id: colorDialog + title: i18n("Select a color") + color: selectColor.text + onAccepted: selectColor.text = colorDialog.color + } + + QtDialogs.FontDialog { + id: fontDialog + title: i18n("Select a font") + font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal }) + onAccepted: { + selectFont.text = fontDialog.font.family + fontSize.value = fontDialog.font.pointSize + fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0 + fontWeight.currentIndex = weight[fontDialog.font.weight] + } + } + } + } + } + + Component.onCompleted: { + if (debug) console.log("[appearance::onCompleted]") + } +} diff --git a/sources/desktop-panel-kf5/package/contents/ui/general.qml b/sources/desktop-panel-kf5/package/contents/ui/general.qml new file mode 100644 index 0000000..dc26a78 --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/ui/general.qml @@ -0,0 +1,36 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +pragma Singleton +import QtQuick 2.0 + + +QtObject { + property variant fontWeight: { + "light": Font.Light, + "normal": Font.Normal, + "demibold": Font.DemiBold, + "bold": Font.Bold, + "black": Font.Black + } + property variant align: { + "left": Text.AlignLeft, + "center": Text.AlignHCenter, + "right": Text.AlignRight, + "justify": Text.AlignJustify + } +} diff --git a/sources/desktop-panel-kf5/package/contents/ui/main.qml b/sources/desktop-panel-kf5/package/contents/ui/main.qml new file mode 100644 index 0000000..a9e9b11 --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/ui/main.qml @@ -0,0 +1,85 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.4 +import QtQuick.Controls 1.3 as QtControls +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.plasma.private.desktoppanel 1.0 +import "." + + +Item { + id: main + + property bool debug: DPAdds.isDebugEnabled() + property variant settings: { + } + + + // init + Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation + Plasmoid.compactRepresentation: Plasmoid.fullRepresentation + + Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar + Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar + Layout.minimumHeight: text.height + Layout.minimumWidth: text.width + + Plasmoid.icon: "utilities-system-monitor" + Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground" + + + // ui + Grid { + columns: 1 + + Text { + id: text + height: contentHeight + width: contentWidth + textFormat: Text.RichText + wrapMode: Text.NoWrap + + horizontalAlignment: general.align[plasmoid.configuration.textAlign] + verticalAlignment: Text.AlignVCenter + + color: plasmoid.configuration.fontColor + font.family: plasmoid.configuration.fontFamily + font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false + font.pointSize: plasmoid.configuration.fontSize + font.weight: general.fontWeight[plasmoid.configuration.fontWeight] + + text: plasmoid.configuration.text + + PlasmaCore.ToolTipArea { + id: rootTooltip + mainItem: Text { + id: tooltip + textFormat: Text.RichText + } + } + } + } + + Component.onCompleted: { + if (debug) console.log("[main::onCompleted]") + } +} diff --git a/sources/desktop-panel-kf5/package/contents/ui/qmldir b/sources/desktop-panel-kf5/package/contents/ui/qmldir new file mode 100644 index 0000000..dda3998 --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/ui/qmldir @@ -0,0 +1 @@ +singleton general general.qml diff --git a/sources/desktop-panel-kf5/package/contents/ui/widget.qml b/sources/desktop-panel-kf5/package/contents/ui/widget.qml new file mode 100644 index 0000000..a9a4ad6 --- /dev/null +++ b/sources/desktop-panel-kf5/package/contents/ui/widget.qml @@ -0,0 +1,234 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.3 as QtControls + +import org.kde.plasma.private.desktoppanel 1.0 + + +Item { + id: widgetPage + width: childrenRect.width + height: childrenRect.height + implicitWidth: pageColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property bool debug: DPAdds.isDebugEnabled() + + property alias cfg_text: textPattern.text + + + Column { + id: pageColumn + width: units.gridUnit * 25 + QtControls.Label { + width: parent.width + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.WordWrap + text: i18n("Detailed information may be found on project homepage") + } + + Row { + height: implicitHeight + width: parent.width + QtControls.Button { + text: i18n("Font") + iconName: "font" + + onClicked: { + if (debug) console.log("[widget::onClicked] : Font button") + + var defaultFont = { + "color": plasmoid.configuration.fontColor, + "family": plasmoid.configuration.fontFamily, + "size": plasmoid.configuration.fontSize + } + var font = DPAdds.getFont(defaultFont) + var pos = textPattern.cursorPosition + var selected = textPattern.selectedText + textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) + textPattern.insert(pos, "" + + selected + "") + } + } + QtControls.Button { + iconName: "format-indent-more" + + onClicked: { + if (debug) console.log("[widget::onClicked] : Indent button") + + var pos = textPattern.cursorPosition + var selected = textPattern.selectedText + textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) + textPattern.insert(pos, selected + "
\n") + } + } + + QtControls.Button { + iconName: "format-text-bold" + + onClicked: { + if (debug) console.log("[widget::onClicked] : Bold button") + + var pos = textPattern.cursorPosition + var selected = textPattern.selectedText + textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) + textPattern.insert(pos, "" + selected + "") + } + } + QtControls.Button { + iconName: "format-text-italic" + + onClicked: { + if (debug) console.log("[widget::onClicked] : Italic button") + + var pos = textPattern.cursorPosition + var selected = textPattern.selectedText + textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) + textPattern.insert(pos, "" + selected + "") + } + } + QtControls.Button { + iconName: "format-text-underline" + + onClicked: { + if (debug) console.log("[widget::onClicked] : Underline button") + + var pos = textPattern.cursorPosition + var selected = textPattern.selectedText + textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) + textPattern.insert(pos, "" + selected + "") + } + } + QtControls.Button { + iconName: "format-text-strikethrough" + + onClicked: { + if (debug) console.log("[widget::onClicked] : Strike button") + + var pos = textPattern.cursorPosition + var selected = textPattern.selectedText + textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) + textPattern.insert(pos, "" + selected + "") + } + } + + QtControls.Button { + iconName: "format-justify-left" + + onClicked: { + if (debug) console.log("[widget::onClicked] : Left button") + + var pos = textPattern.cursorPosition + var selected = textPattern.selectedText + textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) + textPattern.insert(pos, "

" + selected + "" + selected + "" + selected + "" + selected + " + +#include "dpadds.h" + + +static QObject *dpadds_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + + return new DPAdds(); +} + + +void DPPlugin::registerTypes(const char *uri) +{ + Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.desktoppanel")); + + qmlRegisterSingletonType(uri, 1, 0, "DPAdds", dpadds_singletontype_provider); +} diff --git a/sources/desktop-panel-kf5/plugin/desktoppanel.h b/sources/desktop-panel-kf5/plugin/desktoppanel.h new file mode 100644 index 0000000..0887bcb --- /dev/null +++ b/sources/desktop-panel-kf5/plugin/desktoppanel.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef DPPLUGIN_H +#define DPPLUGIN_H + +#include + + +class QQmlEngine; + +class DPPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri); +}; + + +#endif /* DPPLUGIN_H */ diff --git a/sources/desktop-panel-kf5/plugin/dpadds.cpp b/sources/desktop-panel-kf5/plugin/dpadds.cpp new file mode 100644 index 0000000..f2ea9ff --- /dev/null +++ b/sources/desktop-panel-kf5/plugin/dpadds.cpp @@ -0,0 +1,255 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + +#include "dpadds.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "version.h" + + +DPAdds::DPAdds(QObject *parent) + : QObject(parent) +{ + // debug + QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); + QString debugEnv = environment.value(QString("DEBUG"), QString("no")); + debug = (debugEnv == QString("yes")); + + connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SLOT(changeDesktop(int))); +} + + +DPAdds::~DPAdds() +{ + if (debug) qDebug() << PDEBUG; +} + + +bool DPAdds::isDebugEnabled() +{ + if (debug) qDebug() << PDEBUG; + + return debug; +} + + +QStringList DPAdds::dictKeys() +{ + if (debug) qDebug() << PDEBUG; + + QStringList allKeys; + allKeys.append(QString("fullmark")); + allKeys.append(QString("mark")); + allKeys.append(QString("name")); + allKeys.append(QString("number")); + allKeys.append(QString("total")); + + return allKeys; +} + + +QString DPAdds::parsePattern(const QString pattern, const int desktop) +{ + if (debug) qDebug() << PDEBUG; + + QString parsed = pattern; + QStringList keys = dictKeys(); + parsed.replace(QString(" "), QString(" ")); + parsed.replace(QString("$$"), QString("$\\$\\")); + for (int i=0; i") + + QString("%2
").arg(QString(HOMEPAGE)).arg(i18n("Homepage")) + + QString("%2
").arg(QString(REPOSITORY)).arg(i18n("Repository")) + + QString("%2
").arg(QString(BUGTRACKER)).arg(i18n("Bugtracker")) + + QString("%2
").arg(QString(TRANSLATION)).arg(i18n("Translation issue")) + + QString("%2
").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages")) + + QString("%2").arg(QString(OPENSUSE_PACKAGES)).arg(i18n("openSUSE packages")); + else if (type == QString("copy")) + text = QString("© %1 %3
").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) + + i18n("This software is licensed under %1", QString(LICENSE)) + QString("
"); + else if (type == QString("translators")) + text = i18n("Translators: %1", QString(TRANSLATORS)); + else if (type == QString("3rdparty")) { + QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts); + for (int i=0; i%1 (%2 license)") + .arg(trdPartyList[i].split(QChar(','))[0]) + .arg(trdPartyList[i].split(QChar(','))[1]) + .arg(trdPartyList[i].split(QChar(','))[2]); + text = i18n("This software uses: %1", trdPartyList.join(QString(", "))); + } + + return text; +} + + +QMap DPAdds::getFont(const QMap defaultFont) +{ + if (debug) qDebug() << PDEBUG; + + QMap fontMap; + CFont defaultCFont = CFont(defaultFont[QString("family")].toString(), + defaultFont[QString("size")].toInt(), + 400, false, defaultFont[QString("color")].toString()); + CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, + false, false); + fontMap[QString("color")] = font.color().name(); + fontMap[QString("family")] = font.family(); + fontMap[QString("size")] = font.pointSize(); + + return fontMap; +} + + +void DPAdds::changePanelsState() +{ + if (debug) qDebug() << PDEBUG; + if (panelsToControl == QString("-1")) return; + +// QList panels = getPanels(); +// for (int i=0; iview()->isVisible(); +// int winId = panels[i]->view()->winId(); +// if (wasVisible) { +// if (debug) qDebug() << PDEBUG << ":" << "Hide panel"; +// KWindowInfo oldInfo = KWindowSystem::windowInfo(winId, NET::WMState); +// oldState = oldInfo.state(); +// panels[i]->view()->setVisible(false); +// } else { +// if (debug) qDebug() << PDEBUG << ":" << "Show panel"; +// panels[i]->view()->setVisible(true); +// KWindowSystem::clearState(winId, NET::KeepAbove); +// KWindowSystem::setState(winId, oldState | NET::StaysOnTop); +// KWindowSystem::setOnAllDesktops(winId, true); +// } +// } +} + + +void DPAdds::sendNotification(const QString eventId, const QString message) +{ + KNotification *notification = KNotification::event(eventId, QString("Desktop Panel ::: ") + eventId, message); + notification->setComponentName(QString("plasma-applet-org.kde.plasma.desktop-panel")); +} + + +void DPAdds::setCurrentDesktop(const int desktop) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop; + + KWindowSystem::setCurrentDesktop(desktop); +} + + +void DPAdds::changeDesktop(const int desktop) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop; + + emit(desktopChanged()); +} + + +QList DPAdds::getPanels() +{ + if (debug) qDebug() << PDEBUG; + + Plasma::Containment *containment = new Plasma::Containment(this, QVariantList()); + QList panels; + for (int i=0; icorona()->containments().count(); i++) + if (containment->corona()->containments()[i]->containmentType() == + Plasma::Types::ContainmentType::PanelContainment) + panels.append(containment->corona()->containments()[i]); + + return panels; +} + + +QString DPAdds::panelLocationToStr(Plasma::Types::Location location) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Location" << location; + + switch(location) { + case Plasma::Types::Location::TopEdge: + return i18n("Top Edge"); + case Plasma::Types::Location::BottomEdge: + return i18n("Bottom Edge"); + case Plasma::Types::Location::LeftEdge: + return i18n("Left Edge"); + case Plasma::Types::Location::RightEdge: + return i18n("Right Edge"); + default: + return i18n("Unknown location (%1)", location); + } +} diff --git a/sources/desktop-panel-kf5/plugin/dpadds.h b/sources/desktop-panel-kf5/plugin/dpadds.h new file mode 100644 index 0000000..1d729b5 --- /dev/null +++ b/sources/desktop-panel-kf5/plugin/dpadds.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * This file is part of awesome-widgets * + * * + * awesome-widgets 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 3 of the * + * License, or (at your option) any later version. * + * * + * awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ * + ***************************************************************************/ + + +#ifndef DPADDS_H +#define DPADDS_H + +#include + +#include +#include +#include + + +class DPAdds : public QObject +{ + Q_OBJECT + +public: + DPAdds(QObject *parent = 0); + ~DPAdds(); + + Q_INVOKABLE bool isDebugEnabled(); + Q_INVOKABLE QStringList dictKeys(); + Q_INVOKABLE QString parsePattern(const QString pattern, const int desktop); + // values + Q_INVOKABLE QString valueByKey(const QString key, const int desktop); + // configuration slots + Q_INVOKABLE QString getAboutText(const QString type = "header"); + Q_INVOKABLE QMap getFont(const QMap defaultFont); + +signals: + void desktopChanged(); + +public slots: + Q_INVOKABLE void changePanelsState(); + Q_INVOKABLE static void sendNotification(const QString eventId, const QString message); + Q_INVOKABLE void setCurrentDesktop(const int desktop); + +private slots: + void changeDesktop(const int desktop); + +private: + QList getPanels(); + QString panelLocationToStr(Plasma::Types::Location location); + // variables + bool debug = false; + int oldState; + QString mark, panelsToControl; +}; + + +#endif /* DPADDS_H */ diff --git a/sources/desktop-panel-kf5/plugin/plasma-applet-org.kde.plasma.desktop-panel.notifyrc b/sources/desktop-panel-kf5/plugin/plasma-applet-org.kde.plasma.desktop-panel.notifyrc new file mode 100644 index 0000000..30b8a0e --- /dev/null +++ b/sources/desktop-panel-kf5/plugin/plasma-applet-org.kde.plasma.desktop-panel.notifyrc @@ -0,0 +1,24 @@ +[Global] +IconName=system +Name=Desktop Panel +Comment=Desktop panel notifications + +[info] +Name=Information +Comment=Information +Action=Popup + +[Event/event] +Name=Event +Comment=Some event occurs +Action=Popup + +[Event/system] +Name=System information +Comment=System information +Action=Popup + +[Event/tag] +Name=Tag information +Comment=Tag information +Action=Popup diff --git a/sources/desktop-panel-kf5/plugin/qmldir b/sources/desktop-panel-kf5/plugin/qmldir new file mode 100644 index 0000000..b49440a --- /dev/null +++ b/sources/desktop-panel-kf5/plugin/qmldir @@ -0,0 +1,3 @@ +module org.kde.plasma.private.desktoppanel + +plugin dpplugin From 35a5aa6a6c61188043941b828d98556239ded3e0 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 5 Feb 2015 05:32:38 +0300 Subject: [PATCH 2/3] fix memory leak --- sources/desktop-panel-kf5/plugin/dpadds.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sources/desktop-panel-kf5/plugin/dpadds.cpp b/sources/desktop-panel-kf5/plugin/dpadds.cpp index f2ea9ff..73f6864 100644 --- a/sources/desktop-panel-kf5/plugin/dpadds.cpp +++ b/sources/desktop-panel-kf5/plugin/dpadds.cpp @@ -174,7 +174,7 @@ void DPAdds::changePanelsState() if (debug) qDebug() << PDEBUG; if (panelsToControl == QString("-1")) return; -// QList panels = getPanels(); + QList panels = getPanels(); // for (int i=0; iview()->isVisible(); @@ -192,6 +192,7 @@ void DPAdds::changePanelsState() // KWindowSystem::setOnAllDesktops(winId, true); // } // } + panels.clear(); } @@ -230,6 +231,7 @@ QList DPAdds::getPanels() if (containment->corona()->containments()[i]->containmentType() == Plasma::Types::ContainmentType::PanelContainment) panels.append(containment->corona()->containments()[i]); + delete containment; return panels; } From 685c0390b48c75d113024c3b5e19450ec251a0a4 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 5 Feb 2015 12:31:34 +0300 Subject: [PATCH 3/3] end porting core part todo: panels control, windows preview --- .../awesome-widget-kde4/awesome-widget.cpp | 2 +- sources/awesome-widget-kde4/graphicalitem.cpp | 4 +- .../plugin/graphicalitem.cpp | 4 +- sources/desktop-panel-kde4/desktop-panel.cpp | 2 +- .../package/contents/config/main.xml | 3 - sources/desktop-panel-kf5/plugin/dpadds.cpp | 182 +++++++++++++++++- sources/desktop-panel-kf5/plugin/dpadds.h | 18 +- 7 files changed, 197 insertions(+), 18 deletions(-) diff --git a/sources/awesome-widget-kde4/awesome-widget.cpp b/sources/awesome-widget-kde4/awesome-widget.cpp index 18d58cb..78f2612 100644 --- a/sources/awesome-widget-kde4/awesome-widget.cpp +++ b/sources/awesome-widget-kde4/awesome-widget.cpp @@ -492,7 +492,7 @@ void AwesomeWidget::showUpdates(QString version) text += i18n("New version : %1", version) + QString("\n\n"); text += i18n("Click \"Ok\" to download"); int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel); - switch(select) { + switch (select) { case QMessageBox::Ok: QDesktopServices::openUrl(QString(RELEASES) + version); break; diff --git a/sources/awesome-widget-kde4/graphicalitem.cpp b/sources/awesome-widget-kde4/graphicalitem.cpp index 0437ced..04b0bad 100644 --- a/sources/awesome-widget-kde4/graphicalitem.cpp +++ b/sources/awesome-widget-kde4/graphicalitem.cpp @@ -75,7 +75,7 @@ QString GraphicalItem::getImage(const float value) view->resize(_width + 5.0, _height + 5.0); // paint - switch(_type) { + switch (_type) { case Vertical: pen.setWidth(_width); // inactive @@ -190,7 +190,7 @@ QString GraphicalItem::getStrType() if (debug) qDebug() << PDEBUG; QString value; - switch(_type) { + switch (_type) { case Vertical: value = QString("Vertical"); break; diff --git a/sources/awesome-widget-kf5/plugin/graphicalitem.cpp b/sources/awesome-widget-kf5/plugin/graphicalitem.cpp index 1085239..e44be2a 100644 --- a/sources/awesome-widget-kf5/plugin/graphicalitem.cpp +++ b/sources/awesome-widget-kf5/plugin/graphicalitem.cpp @@ -79,7 +79,7 @@ QString GraphicalItem::image(const float value) view->resize(m_width + 5.0, m_height + 5.0); // paint - switch(m_type) { + switch (m_type) { case Vertical: pen.setWidth(m_width); // inactive @@ -206,7 +206,7 @@ QString GraphicalItem::strType() if (debug) qDebug() << PDEBUG; QString value; - switch(m_type) { + switch (m_type) { case Vertical: value = QString("Vertical"); break; diff --git a/sources/desktop-panel-kde4/desktop-panel.cpp b/sources/desktop-panel-kde4/desktop-panel.cpp index bd2bd2c..178a866 100644 --- a/sources/desktop-panel-kde4/desktop-panel.cpp +++ b/sources/desktop-panel-kde4/desktop-panel.cpp @@ -188,7 +188,7 @@ QString DesktopPanel::panelLocationToStr(Plasma::Location loc) if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "Location" << loc; - switch(loc) { + switch (loc) { case Plasma::TopEdge: return i18n("Top Edge"); case Plasma::BottomEdge: diff --git a/sources/desktop-panel-kf5/package/contents/config/main.xml b/sources/desktop-panel-kf5/package/contents/config/main.xml index 3440e43..d779b52 100644 --- a/sources/desktop-panel-kf5/package/contents/config/main.xml +++ b/sources/desktop-panel-kf5/package/contents/config/main.xml @@ -14,9 +14,6 @@ - - true - windows diff --git a/sources/desktop-panel-kf5/plugin/dpadds.cpp b/sources/desktop-panel-kf5/plugin/dpadds.cpp index 73f6864..862156d 100644 --- a/sources/desktop-panel-kf5/plugin/dpadds.cpp +++ b/sources/desktop-panel-kf5/plugin/dpadds.cpp @@ -22,8 +22,14 @@ #include #include +#include #include +#include +#include +#include +#include #include +#include #include #include @@ -63,7 +69,6 @@ QStringList DPAdds::dictKeys() if (debug) qDebug() << PDEBUG; QStringList allKeys; - allKeys.append(QString("fullmark")); allKeys.append(QString("mark")); allKeys.append(QString("name")); allKeys.append(QString("number")); @@ -73,6 +78,57 @@ QStringList DPAdds::dictKeys() } +QString DPAdds::toolTipImage(const int desktop) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop; + + // prepare + // clear + QGraphicsScene *toolTipScene = new QGraphicsScene(); + QGraphicsView *toolTipView = new QGraphicsView(toolTipScene); + DesktopWindowsInfo info = getInfoByDesktop(desktop); + float margin = 5.0 * info.desktop.width() / 400.0; + toolTipView->resize(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin); + toolTipScene->clear(); + toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush)); + // borders + toolTipScene->addLine(0, 0, 0, info.desktop.height() + 2.0 * margin); + toolTipScene->addLine(0, info.desktop.height() + 2.0 * margin, + info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin); + toolTipScene->addLine(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin, + info.desktop.width() + 2.0 * margin, 0); + toolTipScene->addLine(info.desktop.width() + 2.0 * margin, 0, 0, 0); + + if (tooltipType == QString("contours")) { + QPen pen = QPen(); + pen.setWidthF(2.0 * info.desktop.width() / 400.0); + pen.setColor(QColor(tooltipColor)); + for (int i=0; iaddLine(info.windows[i].left() + margin, info.windows[i].bottom() + margin, + info.windows[i].left() + margin, info.windows[i].top() + margin, pen); + toolTipScene->addLine(info.windows[i].left() + margin, info.windows[i].top() + margin, + info.windows[i].right() + margin, info.windows[i].top() + margin, pen); + toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].top() + margin, + info.windows[i].right() + margin, info.windows[i].bottom() + margin, pen); + toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].bottom() + margin, + info.windows[i].left() + margin, info.windows[i].bottom() + margin, pen); + } + } else if (tooltipType == QString("clean")) { +// toolTip.setWindowsToPreview(info.desktopId); + } else if (tooltipType == QString("windows")) { +// toolTip.setWindowsToPreview(info.winId); + } + + QPixmap image = toolTipView->grab().scaledToWidth(tooltipWidth); + QByteArray byteArray; + QBuffer buffer(&byteArray); + image.save(&buffer, "PNG"); + + return QString("").arg(QString(byteArray.toBase64())); +} + + QString DPAdds::parsePattern(const QString pattern, const int desktop) { if (debug) qDebug() << PDEBUG; @@ -89,6 +145,42 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop) } +void DPAdds::setMark(const QString newMark) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Mark" << newMark; + + mark = newMark; +} + + +void DPAdds::setPanelsToControl(const QString newPanels) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Panels" << newPanels; + + panelsToControl.clear(); + if (newPanels == QString("-1")) { + int count = getPanels().count(); + for (int i=0; i tooltipData) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Data" << tooltipData; + + tooltipColor = tooltipData[QString("tooltipColor")].toString(); + tooltipType = tooltipData[QString("tooltipType")].toString(); + tooltipWidth = tooltipData[QString("tooltipWidth")].toInt(); +} + + QString DPAdds::valueByKey(const QString key, const int desktop) { if (debug) qDebug() << PDEBUG; @@ -99,10 +191,8 @@ QString DPAdds::valueByKey(const QString key, const int desktop) currentMark = mark; else currentMark = QString(""); - if (key == QString("fullmark")) + if (key == QString("mark")) return QString("%1").arg(currentMark, currentMark.count(), QLatin1Char(' ')); - else if (key == QString("mark")) - return currentMark; else if (key == QString("name")) return KWindowSystem::desktopName(desktop); else if (key == QString("number")) @@ -114,6 +204,56 @@ QString DPAdds::valueByKey(const QString key, const int desktop) } +QString DPAdds::editPanelsToContol(const QString current) +{ + if (debug) qDebug() << PDEBUG; + + // paint + QDialog *dialog = new QDialog(0); + QListWidget *widget = new QListWidget(dialog); + QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close, + Qt::Vertical, dialog); + QHBoxLayout *layout = new QHBoxLayout(dialog); + layout->addWidget(widget); + layout->addWidget(buttons); + dialog->setLayout(layout); + connect(buttons, SIGNAL(rejected()), dialog, SLOT(reject())); + connect(buttons, SIGNAL(accepted()), dialog, SLOT(accept())); + + // fill + QList panels = getPanels(); + for (int i=0; ilocation()), widget); + if ((current.split(QChar(',')).contains(QString::number(i))) || + (current == QString("-1"))) + item->setCheckState(Qt::Checked); + else + item->setCheckState(Qt::Unchecked); + } + + // exec + QString value; + QStringList indexes; + int ret = dialog->exec(); + switch (ret) { + case QDialog::Accepted: + for (int i=0; icount(); i++) + if (widget->item(i)->checkState() == Qt::Checked) + indexes.append(QString::number(i)); + if (indexes.count() == widget->count()) + value = QString("-1"); + else + value = indexes.join(QChar(',')); + break; + default: + value = current; + break; + } + + return value; +} + + QString DPAdds::getAboutText(const QString type) { if (debug) qDebug() << PDEBUG; @@ -172,11 +312,11 @@ QMap DPAdds::getFont(const QMap defaultFon void DPAdds::changePanelsState() { if (debug) qDebug() << PDEBUG; - if (panelsToControl == QString("-1")) return; + if (panelsToControl.isEmpty()) return; QList panels = getPanels(); // for (int i=0; iview()->isVisible(); // int winId = panels[i]->view()->winId(); // if (wasVisible) { @@ -221,6 +361,34 @@ void DPAdds::changeDesktop(const int desktop) } +DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int desktop) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop; + + + DesktopWindowsInfo info; + info.desktop = KWindowSystem::workArea(desktop); + + QList windows = KWindowSystem::windows(); + for (int i=0; i DPAdds::getPanels() { if (debug) qDebug() << PDEBUG; @@ -242,7 +410,7 @@ QString DPAdds::panelLocationToStr(Plasma::Types::Location location) if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "Location" << location; - switch(location) { + switch (location) { case Plasma::Types::Location::TopEdge: return i18n("Top Edge"); case Plasma::Types::Location::BottomEdge: diff --git a/sources/desktop-panel-kf5/plugin/dpadds.h b/sources/desktop-panel-kf5/plugin/dpadds.h index 1d729b5..9fd8633 100644 --- a/sources/desktop-panel-kf5/plugin/dpadds.h +++ b/sources/desktop-panel-kf5/plugin/dpadds.h @@ -30,16 +30,28 @@ class DPAdds : public QObject { Q_OBJECT + typedef struct { + QRect desktop; + QList desktopId; + QList windows; + QList winId; + } DesktopWindowsInfo; + public: DPAdds(QObject *parent = 0); ~DPAdds(); Q_INVOKABLE bool isDebugEnabled(); Q_INVOKABLE QStringList dictKeys(); + Q_INVOKABLE QString toolTipImage(const int desktop); Q_INVOKABLE QString parsePattern(const QString pattern, const int desktop); // values + Q_INVOKABLE void setMark(const QString newMark); + Q_INVOKABLE void setPanelsToControl(const QString newPanels); + Q_INVOKABLE void setToolTipData(const QMap tooltipData); Q_INVOKABLE QString valueByKey(const QString key, const int desktop); // configuration slots + Q_INVOKABLE QString editPanelsToContol(const QString current); Q_INVOKABLE QString getAboutText(const QString type = "header"); Q_INVOKABLE QMap getFont(const QMap defaultFont); @@ -55,12 +67,14 @@ private slots: void changeDesktop(const int desktop); private: + DesktopWindowsInfo getInfoByDesktop(const int desktop); QList getPanels(); QString panelLocationToStr(Plasma::Types::Location location); // variables bool debug = false; - int oldState; - QString mark, panelsToControl; + int oldState, tooltipWidth; + QString mark, tooltipColor, tooltipType; + QList panelsToControl; };