From f882756fad00281be0c8c726a81b72d4ca5ee8da Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Mon, 10 Oct 2016 20:43:07 +0300 Subject: [PATCH] update desktoppanel qml part --- .../package/contents/ui/about.qml | 1 + .../package/contents/ui/about.qml | 1 + .../package/contents/ui/activeapp.qml | 299 +++-------------- .../package/contents/ui/advanced.qml | 2 - .../package/contents/ui/inactiveapp.qml | 303 +++--------------- 5 files changed, 90 insertions(+), 516 deletions(-) diff --git a/sources/awesome-widget/package/contents/ui/about.qml b/sources/awesome-widget/package/contents/ui/about.qml index 1a1ce68..7f39ffe 100644 --- a/sources/awesome-widget/package/contents/ui/about.qml +++ b/sources/awesome-widget/package/contents/ui/about.qml @@ -22,6 +22,7 @@ import org.kde.plasma.private.awesomewidget 1.0 Item { id: aboutPage + // backend AWActions { id: awActions } diff --git a/sources/desktop-panel/package/contents/ui/about.qml b/sources/desktop-panel/package/contents/ui/about.qml index 874455a..352cf42 100644 --- a/sources/desktop-panel/package/contents/ui/about.qml +++ b/sources/desktop-panel/package/contents/ui/about.qml @@ -22,6 +22,7 @@ import org.kde.plasma.private.desktoppanel 1.0 Item { id: aboutPage + // backend DPAdds { id: dpAdds } diff --git a/sources/desktop-panel/package/contents/ui/activeapp.qml b/sources/desktop-panel/package/contents/ui/activeapp.qml index 58ed75a..da070a8 100644 --- a/sources/desktop-panel/package/contents/ui/activeapp.qml +++ b/sources/desktop-panel/package/contents/ui/activeapp.qml @@ -16,11 +16,9 @@ ***************************************************************************/ import QtQuick 2.0 -import QtQuick.Controls 1.3 as QtControls -import QtQuick.Controls.Styles 1.3 as QtStyles -import QtQuick.Dialogs 1.1 as QtDialogs import org.kde.plasma.private.desktoppanel 1.0 +import "." Item { @@ -36,280 +34,69 @@ Item { implicitHeight: pageColumn.implicitHeight property bool debug: dpAdds.isDebugEnabled() - property variant weight: { - 25: 0, - 50: 1, - 63: 3, - 75: 4, - 87: 5 - } - property alias cfg_currentFontFamily: selectFont.text + property alias cfg_currentFontFamily: font.value property alias cfg_currentFontSize: fontSize.value - property string cfg_currentFontWeight: fontWeight.currentText - property string cfg_currentFontStyle: fontStyle.currentText + property string cfg_currentFontWeight: fontWeight.value + property string cfg_currentFontStyle: fontStyle.value property alias cfg_currentFontColor: selectColor.text property alias cfg_currentTextStyleColor: selectStyleColor.text - property string cfg_currentTextStyle: textStyle.currentText + property string cfg_currentTextStyle: textStyle.value Column { id: pageColumn anchors.fill: parent - 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.currentFontFamily - onClicked: { - if (debug) console.debug() - fontDialog.setFont() - fontDialog.visible = true - } - } + + FontSelector { + id: font + text: i18n("Font") + value: plasmoid.configuration.currentFontFamily } - 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.currentFontSize - } + IntegerSelector { + id: fontSize + maximumValue: 32 + minimumValue: 8 + stepSize: 1 + text: i18n("Font size") + 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: 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_currentFontWeight = model[currentIndex]["name"] - Component.onCompleted: { - if (debug) console.debug() - for (var i = 0; i < model.length; i++) { - if (model[i]["name"] == plasmoid.configuration.currentFontWeight) { - if (debug) console.info("Found", model[i]["name"], "on", i) - fontWeight.currentIndex = i - } - } - } - } + ComboBoxSelector { + id: fontWeight + model: general.fontWeightModel + text: i18n("Font weight") + value: plasmoid.configuration.currentFontWeight + onValueEdited: cfg_currentFontWeight = newValue } - 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_currentFontStyle = model[currentIndex]["name"] - Component.onCompleted: { - if (debug) console.debug() - for (var i = 0; i < model.length; i++) { - if (model[i]["name"] == plasmoid.configuration.currentFontStyle) { - if (debug) console.info("Found", model[i]["name"], "on", i) - fontStyle.currentIndex = i - } - } - } - } + ComboBoxSelector { + id: fontStyle + model: general.fontStyleModel + text: i18n("Font style") + value: plasmoid.configuration.currentFontStyle + onValueEdited: cfg_currentFontStyle = newValue } - 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.currentFontColor - } - } - text: plasmoid.configuration.currentFontColor - onClicked: colorDialog.visible = true - } + ColorSelector { + id: selectColor + text: i18n("Font color") + value: plasmoid.configuration.currentFontColor } - Row { - height: implicitHeight - width: parent.width - QtControls.Label { - height: parent.height - width: parent.width / 3 - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: i18n("Style") - } - QtControls.ComboBox { - id: textStyle - width: parent.width * 2 / 3 - textRole: "label" - model: [ - { - 'label': i18n("normal"), - 'name': "normal" - }, - { - 'label': i18n("outline"), - 'name': "outline" - }, - { - 'label': i18n("raised"), - 'name': "raised" - }, - { - 'label': i18n("sunken"), - 'name': "sunken" - } - ] - onCurrentIndexChanged: cfg_currentTextStyle = model[currentIndex]["name"] - Component.onCompleted: { - if (debug) console.debug() - for (var i = 0; i < model.length; i++) { - if (model[i]["name"] == plasmoid.configuration.currentTextStyle) { - if (debug) console.info("Found", model[i]["name"], "on", i) - textStyle.currentIndex = i - } - } - } - } + ComboBoxSelector { + id: textStyle + model: general.textStyleModel + text: i18n("Style") + value: plasmoid.configuration.currentTextStyle + onValueEdited: cfg_currentTextStyle = newValue } - Row { - height: implicitHeight - width: parent.width - QtControls.Label { - height: parent.height - width: parent.width / 3 - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: i18n("Style color") - } - QtControls.Button { - id: selectStyleColor - width: parent.width * 2 / 3 - style: QtStyles.ButtonStyle { - background: Rectangle { - color: plasmoid.configuration.currentTextStyleColor - } - } - text: plasmoid.configuration.currentTextStyleColor - onClicked: textStyleColorDialog.visible = true - } - } - } - - QtDialogs.ColorDialog { - id: colorDialog - title: i18n("Select a color") - color: selectColor.text - onAccepted: selectColor.text = colorDialog.color - } - - QtDialogs.ColorDialog { - id: textStyleColorDialog - title: i18n("Select a color") - color: selectStyleColor.text - onAccepted: selectStyleColor.text = textStyleColorDialog.color - } - - QtDialogs.FontDialog { - id: fontDialog - title: i18n("Select a font") - signal setFont - - onAccepted: { - if (debug) console.debug() - selectFont.text = fontDialog.font.family - fontSize.value = fontDialog.font.pointSize - fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0 - fontWeight.currentIndex = weight[fontDialog.font.weight] - } - onSetFont: { - if (debug) console.debug() - fontDialog.font = Qt.font({ - family: selectFont.text, - pointSize: fontSize.value > 0 ? fontSize.value : 12, - italic: fontStyle.currentIndex == 1, - weight: Font.Normal, - }) + ColorSelector { + id: selectStyleColor + text: i18n("Style color") + value: plasmoid.configuration.currentTextStyleColor } } diff --git a/sources/desktop-panel/package/contents/ui/advanced.qml b/sources/desktop-panel/package/contents/ui/advanced.qml index ade2153..84a5dd3 100644 --- a/sources/desktop-panel/package/contents/ui/advanced.qml +++ b/sources/desktop-panel/package/contents/ui/advanced.qml @@ -17,8 +17,6 @@ import QtQuick 2.0 import QtQuick.Controls 1.3 as QtControls -import QtQuick.Controls.Styles 1.3 as QtStyles -import QtQuick.Dialogs 1.1 as QtDialogs import org.kde.plasma.private.desktoppanel 1.0 diff --git a/sources/desktop-panel/package/contents/ui/inactiveapp.qml b/sources/desktop-panel/package/contents/ui/inactiveapp.qml index cc8b171..7174d9a 100644 --- a/sources/desktop-panel/package/contents/ui/inactiveapp.qml +++ b/sources/desktop-panel/package/contents/ui/inactiveapp.qml @@ -16,11 +16,9 @@ ***************************************************************************/ import QtQuick 2.0 -import QtQuick.Controls 1.3 as QtControls -import QtQuick.Controls.Styles 1.3 as QtStyles -import QtQuick.Dialogs 1.1 as QtDialogs import org.kde.plasma.private.desktoppanel 1.0 +import "." Item { @@ -36,280 +34,69 @@ Item { 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_fontFamily: font.value 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_textStyleColor: selectStyleColor.text - property string cfg_textStyle: textStyle.currentText + property string cfg_fontWeight: fontWeight.value + property string cfg_fontStyle: fontStyle.value + property alias cfg_fontColor: selectColor.value + property alias cfg_textStyleColor: selectStyleColor.value + property string cfg_textStyle: textStyle.value Column { id: pageColumn anchors.fill: parent - 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: { - if (debug) console.debug() - fontDialog.setFont() - fontDialog.visible = true - } - } + + FontSelector { + id: font + text: i18n("Font") + value: plasmoid.configuration.fontFamily } - 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 - } + IntegerSelector { + id: fontSize + maximumValue: 32 + minimumValue: 8 + stepSize: 1 + text: i18n("Font size") + 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: { - if (debug) console.debug() - for (var i = 0; i < model.length; i++) { - if (model[i]["name"] == plasmoid.configuration.fontWeight) { - if (debug) console.info("Found", model[i]["name"], "on", i) - fontWeight.currentIndex = i - } - } - } - } + ComboBoxSelector { + id: fontWeight + model: general.fontWeightModel + text: i18n("Font weight") + value: plasmoid.configuration.fontWeight + onValueEdited: cfg_fontWeight = newValue } - 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: { - if (debug) console.debug() - for (var i = 0; i < model.length; i++) { - if (model[i]["name"] == plasmoid.configuration.fontStyle) { - if (debug) console.info("Found", model[i]["name"], "on", i) - fontStyle.currentIndex = i - } - } - } - } + ComboBoxSelector { + id: fontStyle + model: general.fontStyleModel + text: i18n("Font style") + value: plasmoid.configuration.fontStyle + onValueEdited: cfg_fontStyle = newValue } - 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 - } + ColorSelector { + id: selectColor + text: i18n("Font color") + value: plasmoid.configuration.fontColor } - Row { - height: implicitHeight - width: parent.width - QtControls.Label { - height: parent.height - width: parent.width / 3 - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: i18n("Style") - } - QtControls.ComboBox { - id: textStyle - width: parent.width * 2 / 3 - textRole: "label" - model: [ - { - 'label': i18n("normal"), - 'name': "normal" - }, - { - 'label': i18n("outline"), - 'name': "outline" - }, - { - 'label': i18n("raised"), - 'name': "raised" - }, - { - 'label': i18n("sunken"), - 'name': "sunken" - } - ] - onCurrentIndexChanged: cfg_textStyle = model[currentIndex]["name"] - Component.onCompleted: { - if (debug) console.debug() - for (var i = 0; i < model.length; i++) { - if (model[i]["name"] == plasmoid.configuration.textStyle) { - if (debug) console.info("Found", model[i]["name"], "on", i) - textStyle.currentIndex = i - } - } - } - } + ComboBoxSelector { + id: textStyle + model: general.textStyleModel + text: i18n("Style") + value: plasmoid.configuration.textStyle + onValueEdited: cfg_textStyle = newValue } - Row { - height: implicitHeight - width: parent.width - QtControls.Label { - height: parent.height - width: parent.width / 3 - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: i18n("Style color") - } - QtControls.Button { - id: selectStyleColor - width: parent.width * 2 / 3 - style: QtStyles.ButtonStyle { - background: Rectangle { - color: plasmoid.configuration.textStyleColor - } - } - text: plasmoid.configuration.textStyleColor - onClicked: textStyleColorDialog.visible = true - } - } - } - - QtDialogs.ColorDialog { - id: colorDialog - title: i18n("Select a color") - color: selectColor.text - onAccepted: selectColor.text = colorDialog.color - } - - QtDialogs.ColorDialog { - id: textStyleColorDialog - title: i18n("Select a color") - color: selectStyleColor.text - onAccepted: selectStyleColor.text = textStyleColorDialog.color - } - - QtDialogs.FontDialog { - id: fontDialog - title: i18n("Select a font") - signal setFont - - onAccepted: { - if (debug) console.debug() - selectFont.text = fontDialog.font.family - fontSize.value = fontDialog.font.pointSize - fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0 - fontWeight.currentIndex = weight[fontDialog.font.weight] - } - onSetFont: { - if (debug) console.debug() - fontDialog.font = Qt.font({ - family: selectFont.text, - pointSize: fontSize.value > 0 ? fontSize.value : 12, - italic: fontStyle.currentIndex == 1, - weight: Font.Normal, - }) + ColorSelector { + id: selectStyleColor + text: i18n("Style color") + value: plasmoid.configuration.textStyleColor } }