Create dialogs for button and color button

This commit is contained in:
Evgenii Alekseev 2016-09-29 10:24:03 +03:00
parent 80c994bce0
commit 31c129163b
6 changed files with 156 additions and 332 deletions

View File

@ -0,0 +1,41 @@
/***************************************************************************
* 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
Row {
height: implicitHeight
width: parent.width
property alias text: label.text
property alias value: button.text
signal buttonActivated
QtControls.Label {
id: label
height: parent.height
width: parent.width * 2 / 5
}
QtControls.Button {
id: button
width: parent.width * 3 / 5
onClicked: buttonActivated()
}
}

View File

@ -0,0 +1,55 @@
/***************************************************************************
* 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.Controls.Styles 1.3 as QtStyles
import QtQuick.Dialogs 1.1 as QtDialogs
Row {
height: implicitHeight
width: parent.width
property alias text: label.text
property alias value: colorButton.text
QtControls.Label {
id: label
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
QtControls.Button {
id: colorButton
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: value
}
}
onClicked: colorDialog.visible = true
}
QtDialogs.ColorDialog {
id: colorDialog
title: i18n("Select a color")
color: value
onAccepted: value = colorDialog.color
}
}

View File

@ -193,18 +193,9 @@ Item {
value: plasmoid.configuration.acOffline value: plasmoid.configuration.acOffline
} }
Row { ButtonSelector {
height: implicitHeight value: i18n("Drop key cache")
width: parent.width onButtonActivated: awActions.dropCache()
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
}
QtControls.Button {
width: parent.width * 3 / 5
text: i18n("Drop key cache")
onClicked: awActions.dropCache()
}
} }
Row { Row {

View File

@ -17,7 +17,6 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls import QtQuick.Controls 1.3 as QtControls
import QtQuick.Controls.Styles 1.3 as QtStyles
import QtQuick.Dialogs 1.1 as QtDialogs import QtQuick.Dialogs 1.1 as QtDialogs
import org.kde.plasma.private.awesomewidget 1.0 import org.kde.plasma.private.awesomewidget 1.0
@ -48,8 +47,8 @@ Item {
property alias cfg_fontSize: fontSize.value property alias cfg_fontSize: fontSize.value
property string cfg_fontWeight: fontWeight.value property string cfg_fontWeight: fontWeight.value
property string cfg_fontStyle: fontStyle.value property string cfg_fontStyle: fontStyle.value
property alias cfg_fontColor: selectColor.text property alias cfg_fontColor: selectColor.value
property alias cfg_textStyleColor: selectStyleColor.text property alias cfg_textStyleColor: selectStyleColor.value
property string cfg_textStyle: textStyle.value property string cfg_textStyle: textStyle.value
@ -133,27 +132,10 @@ Item {
onValueEdited: cfg_fontStyle = newValue onValueEdited: cfg_fontStyle = newValue
} }
Row { ColorSelector {
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 id: selectColor
width: parent.width * 2 / 3 text: i18n("Font color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.fontColor
background: Rectangle {
color: plasmoid.configuration.fontColor
}
}
text: plasmoid.configuration.fontColor
onClicked: colorDialog.visible = true
}
} }
ComboBoxSelector { ComboBoxSelector {
@ -181,43 +163,12 @@ Item {
onValueEdited: cfg_textStyle = newValue onValueEdited: cfg_textStyle = newValue
} }
Row { ColorSelector {
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 id: selectStyleColor
width: parent.width * 2 / 3 text: i18n("Style color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.textStyleColor
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 { QtDialogs.FontDialog {
id: fontDialog id: fontDialog

View File

@ -1,6 +1,8 @@
singleton general 1.0 general.qml singleton general 1.0 general.qml
BugReport ./BugReport.qml BugReport ./BugReport.qml
ButtonSelector ./ButtonSelector.qml
CheckBoxSelector ./CheckBoxSelector.qml CheckBoxSelector ./CheckBoxSelector.qml
ColorSelector ./ColorSelector.qml
ComboBoxSelector ./ComboBoxSelector.qml ComboBoxSelector ./ComboBoxSelector.qml
IntegerSelector ./IntegerSelector.qml IntegerSelector ./IntegerSelector.qml
LineSelector ./LineSelector.qml LineSelector ./LineSelector.qml

View File

@ -39,21 +39,21 @@ Item {
property alias cfg_tooltipNumber: tooltipNumber.value property alias cfg_tooltipNumber: tooltipNumber.value
property alias cfg_useTooltipBackground: useTooltipBackground.checked property alias cfg_useTooltipBackground: useTooltipBackground.checked
property alias cfg_tooltipBackground: tooltipBackground.text property alias cfg_tooltipBackground: tooltipBackground.value
property alias cfg_cpuTooltip: cpuTooltip.checked property alias cfg_cpuTooltip: cpuTooltip.checked
property alias cfg_cpuTooltipColor: cpuTooltipColor.text property alias cfg_cpuTooltipColor: cpuTooltipColor.value
property alias cfg_cpuclTooltip: cpuclTooltip.checked property alias cfg_cpuclTooltip: cpuclTooltip.checked
property alias cfg_cpuclTooltipColor: cpuclTooltipColor.text property alias cfg_cpuclTooltipColor: cpuclTooltipColor.value
property alias cfg_memTooltip: memTooltip.checked property alias cfg_memTooltip: memTooltip.checked
property alias cfg_memTooltipColor: memTooltipColor.text property alias cfg_memTooltipColor: memTooltipColor.value
property alias cfg_swapTooltip: swapTooltip.checked property alias cfg_swapTooltip: swapTooltip.checked
property alias cfg_swapTooltipColor: swapTooltipColor.text property alias cfg_swapTooltipColor: swapTooltipColor.value
property alias cfg_downkbTooltip: downkbTooltip.checked property alias cfg_downkbTooltip: downkbTooltip.checked
property alias cfg_downkbTooltipColor: downkbTooltipColor.text property alias cfg_downkbTooltipColor: downkbTooltipColor.value
property alias cfg_upkbTooltipColor: upkbTooltipColor.text property alias cfg_upkbTooltipColor: upkbTooltipColor.value
property alias cfg_batTooltip: batTooltip.checked property alias cfg_batTooltip: batTooltip.checked
property alias cfg_batTooltipColor: batTooltipColor.text property alias cfg_batTooltipColor: batTooltipColor.value
property alias cfg_batInTooltipColor: batInTooltipColor.text property alias cfg_batInTooltipColor: batInTooltipColor.value
Column { Column {
@ -82,34 +82,10 @@ Item {
width: parent.width width: parent.width
checkable: true checkable: true
title: i18n("Background") title: i18n("Background")
Row { ColorSelector {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Background color")
}
QtControls.Button {
id: tooltipBackground id: tooltipBackground
width: parent.width * 3 / 5 text: i18n("Background color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.tooltipBackground
background: Rectangle {
color: plasmoid.configuration.tooltipBackground
}
}
text: plasmoid.configuration.tooltipBackground
onClicked: tooltipBackgroundDialog.visible = true
}
QtDialogs.ColorDialog {
id: tooltipBackgroundDialog
title: i18n("Select a color")
color: tooltipBackground.text
onAccepted: tooltipBackground.text = tooltipBackgroundDialog.color
}
} }
} }
@ -119,34 +95,10 @@ Item {
width: parent.width width: parent.width
checkable: true checkable: true
title: i18n("CPU") title: i18n("CPU")
Row { ColorSelector {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("CPU color")
}
QtControls.Button {
id: cpuTooltipColor id: cpuTooltipColor
width: parent.width * 3 / 5 text: i18n("CPU color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.cpuTooltipColor
background: Rectangle {
color: plasmoid.configuration.cpuTooltipColor
}
}
text: plasmoid.configuration.cpuTooltipColor
onClicked: cpuTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: cpuTooltipColorDialog
title: i18n("Select a color")
color: cpuTooltipColor.text
onAccepted: cpuTooltipColor.text = cpuTooltipColorDialog.color
}
} }
} }
@ -156,34 +108,10 @@ Item {
width: parent.width width: parent.width
checkable: true checkable: true
title: i18n("CPU clock") title: i18n("CPU clock")
Row { ColorSelector {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("CPU clock color")
}
QtControls.Button {
id: cpuclTooltipColor id: cpuclTooltipColor
width: parent.width * 3 / 5 text: i18n("CPU clock color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.cpuclTooltipColor
background: Rectangle {
color: plasmoid.configuration.cpuclTooltipColor
}
}
text: plasmoid.configuration.cpuclTooltipColor
onClicked: cpuclTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: cpuclTooltipColorDialog
title: i18n("Select a color")
color: cpuclTooltipColor.text
onAccepted: cpuclTooltipColor.text = cpuclTooltipColorDialog.color
}
} }
} }
@ -193,34 +121,10 @@ Item {
width: parent.width width: parent.width
checkable: true checkable: true
title: i18n("Memory") title: i18n("Memory")
Row { ColorSelector {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Memory color")
}
QtControls.Button {
id: memTooltipColor id: memTooltipColor
width: parent.width * 3 / 5 text: i18n("Memory color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.memTooltipColor
background: Rectangle {
color: plasmoid.configuration.memTooltipColor
}
}
text: plasmoid.configuration.memTooltipColor
onClicked: memTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: memTooltipColorDialog
title: i18n("Select a color")
color: memTooltipColor.text
onAccepted: memTooltipColor.text = memTooltipColorDialog.color
}
} }
} }
@ -230,34 +134,10 @@ Item {
width: parent.width width: parent.width
checkable: true checkable: true
title: i18n("Swap") title: i18n("Swap")
Row { ColorSelector {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Swap color")
}
QtControls.Button {
id: swapTooltipColor id: swapTooltipColor
width: parent.width * 3 / 5 text: i18n("Swap color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.swapTooltipColor
background: Rectangle {
color: plasmoid.configuration.swapTooltipColor
}
}
text: plasmoid.configuration.swapTooltipColor
onClicked: swapTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: swapTooltipColorDialog
title: i18n("Select a color")
color: swapTooltipColor.text
onAccepted: swapTooltipColor.text = swapTooltipColorDialog.color
}
} }
} }
@ -270,63 +150,15 @@ Item {
Column { Column {
height: implicitHeight height: implicitHeight
width: parent.width width: parent.width
Row { ColorSelector {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Download speed color")
}
QtControls.Button {
id: downkbTooltipColor id: downkbTooltipColor
width: parent.width * 3 / 5 text: i18n("Download speed color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.downkbTooltipColor
background: Rectangle {
color: plasmoid.configuration.downkbTooltipColor
} }
} ColorSelector {
text: plasmoid.configuration.downkbTooltipColor
onClicked: downkbTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: downkbTooltipColorDialog
title: i18n("Select a color")
color: downkbTooltipColor.text
onAccepted: downkbTooltipColor.text = downkbTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Upload speed color")
}
QtControls.Button {
id: upkbTooltipColor id: upkbTooltipColor
width: parent.width * 3 / 5 text: i18n("Upload speed color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.upkbTooltipColor
background: Rectangle {
color: plasmoid.configuration.upkbTooltipColor
}
}
text: plasmoid.configuration.upkbTooltipColor
onClicked: upkbTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: upkbTooltipColorDialog
title: i18n("Select a color")
color: upkbTooltipColor.text
onAccepted: upkbTooltipColor.text = upkbTooltipColorDialog.color
}
} }
} }
} }
@ -340,63 +172,15 @@ Item {
Column { Column {
height: implicitHeight height: implicitHeight
width: parent.width width: parent.width
Row { ColorSelector {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Battery active color")
}
QtControls.Button {
id: batTooltipColor id: batTooltipColor
width: parent.width * 3 / 5 text: i18n("Battery active color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.batTooltipColor
background: Rectangle {
color: plasmoid.configuration.batTooltipColor
} }
} ColorSelector {
text: plasmoid.configuration.batTooltipColor
onClicked: batTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: batTooltipColorDialog
title: i18n("Select a color")
color: batTooltipColor.text
onAccepted: batTooltipColor.text = batTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Battery inactive color")
}
QtControls.Button {
id: batInTooltipColor id: batInTooltipColor
width: parent.width * 3 / 5 text: i18n("Battery inactive color")
style: QtStyles.ButtonStyle { value: plasmoid.configuration.batInTooltipColor
background: Rectangle {
color: plasmoid.configuration.batInTooltipColor
}
}
text: plasmoid.configuration.batInTooltipColor
onClicked: batInTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: batInTooltipColorDialog
title: i18n("Select a color")
color: batInTooltipColor.text
onAccepted: batInTooltipColor.text = batInTooltipColorDialog.color
}
} }
} }
} }