Compare commits

..

1 Commits

8 changed files with 156 additions and 62 deletions

View File

@ -16,15 +16,27 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: aboutPage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
property bool debug: awActions.isDebugEnabled()
AboutTab {
textProvider: awActions
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -17,19 +17,24 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: advancedPage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_background: background.checked
property alias cfg_translateStrings: translate.checked
property alias cfg_wrapNewLines: wrapNewLines.checked
@ -50,6 +55,7 @@ KCM.SimpleKCM {
property alias cfg_telemetryRemote: telemetryRemote.checked
property alias cfg_telemetryId: telemetryId.value
Column {
id: pageColumn
anchors.fill: parent
@ -188,18 +194,14 @@ KCM.SimpleKCM {
GroupBox {
width: parent.width
height: implicitHeight
title: i18n("Actions")
Column {
height: implicitHeight
width: parent.width
ButtonSelector {
value: i18n("Drop key cache")
onButtonActivated: awActions.dropCache()
}
ButtonSelector {
ExportDialog {
id: saveConfigAs
@ -208,12 +210,11 @@ KCM.SimpleKCM {
value: i18n("Export configuration")
onButtonActivated: saveConfigAs.open()
}
ButtonSelector {
ImportDialog {
id: loadConfigFrom
onConfigurationReceived: {
for (const key in configuration)
for (var key in configuration)
plasmoid.configuration[key] = configuration[key]
}
}
@ -224,19 +225,15 @@ KCM.SimpleKCM {
}
GroupBox {
height: implicitHeight
width: parent.width
title: i18n("Telemetry")
Column {
height: implicitHeight
width: parent.width
CheckBoxSelector {
id: telemetryRemote
text: i18n("Enable remote telemetry")
}
IntegerSelector {
id: telemetryCount
maximumValue: 10000
@ -245,7 +242,6 @@ KCM.SimpleKCM {
text: i18n("History count")
value: plasmoid.configuration.telemetryCount
}
LineSelector {
id: telemetryId
text: i18n("Telemetry ID")
@ -254,4 +250,9 @@ KCM.SimpleKCM {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,21 +16,30 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import "."
KCM.SimpleKCM {
Item {
id: appearancePage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property variant weight: {
25: 0,
50: 1,
63: 3,
75: 4,
87: 5,
87: 5
}
property alias cfg_fontFamily: font.value
@ -97,4 +106,9 @@ KCM.SimpleKCM {
value: plasmoid.configuration.textStyleColor
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -17,28 +17,36 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: dataenginePage
// backend
AWKeys {
id: awKeys
}
AWActions {
id: awActions
}
AWConfigHelper {
id: awConfig
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property variant cfg_dataengine: awConfig.readDataEngineConfiguration()
Column {
id: pageColumn
anchors.fill: parent
const
GroupBox {
height: implicitHeight
width: parent.width
@ -54,7 +62,6 @@ const
height: implicitHeight
width: parent.width
title: i18n("Player")
Column {
height: implicitHeight
width: parent.width
@ -153,11 +160,9 @@ const
height: implicitHeight
width: parent.width
title: i18n("Extensions")
Column {
height: implicitHeight
width: parent.width
ButtonSelector {
value: i18n("Custom scripts")
onButtonActivated: awKeys.editItem("extscript")
@ -188,6 +193,8 @@ const
Component.onCompleted: {
if (debug) console.debug()
// init submodule
awKeys.updateCache()
@ -197,6 +204,8 @@ const
}
Component.onDestruction: {
if (debug) console.debug()
cfg_dataengine["MPRIS"] = mpris.editText
awConfig.writeDataEngineConfiguration(cfg_dataengine)
}

View File

@ -28,7 +28,6 @@ import "."
PlasmoidItem {
id: main
// backend
AWKeys {
id: awKeys
@ -43,6 +42,7 @@ PlasmoidItem {
id: bugReport
}
property bool debug: awActions.isDebugEnabled()
property variant tooltipSettings: {
"tooltipNumber": plasmoid.configuration.tooltipNumber,
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
@ -72,13 +72,15 @@ PlasmoidItem {
signal needToolTipUpdate(string newText)
signal sizeUpdate
Layout.fillWidth: PlasmoidItem.formFactor !== PlasmaCore.Planar
Layout.fillHeight: PlasmoidItem.formFactor !== PlasmaCore.Planar
Layout.fillWidth: PlasmoidItem.formFactor != PlasmaCore.Planar
Layout.fillHeight: PlasmoidItem.formFactor != PlasmaCore.Planar
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Plasmoid.icon: "utilities-system-monitor"
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
// ui
Text {
id: text
@ -92,7 +94,7 @@ PlasmoidItem {
color: plasmoid.configuration.fontColor
font.family: plasmoid.configuration.fontFamily
font.italic: plasmoid.configuration.fontStyle === "italic" ? true : false
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
font.pointSize: plasmoid.configuration.fontSize
font.weight: General.fontWeight[plasmoid.configuration.fontWeight]
@ -122,8 +124,8 @@ PlasmoidItem {
}
onAccepted: {
const tag = tagSelectorBox.editText
let message = i18n("Tag: %1", tag)
var tag = tagSelectorBox.editText
var message = i18n("Tag: %1", tag)
message += "<br>"
message += i18n("Value: %1", awKeys.valueByKey(tag))
message += "<br>"
@ -136,33 +138,25 @@ PlasmoidItem {
PlasmaCore.Action {
text: i18n("Request key")
icon.name: "utilities-system-monitor"
onTriggered: {
tagSelectorBox.model = awKeys.dictKeys(true)
tagSelector.open()
}
},
PlasmaCore.Action {
text: i18n("Show README")
icon.name: "text-x-readme"
onTriggered: awActions.showReadme()
},
PlasmaCore.Action {
text: i18n("Check updates")
icon.name: "system-software-update"
onTriggered: awActions.checkUpdates(true)
},
PlasmaCore.Action {
text: i18n("Report bug")
icon.name: "tools-report-bug"
onTriggered: {
bugReport.reset()
bugReport.open()
}
}
]
Component.onCompleted: {
if (debug) console.debug()
// init submodule
Plasmoid.userConfiguringChanged(false)
// connect data
@ -173,25 +167,31 @@ PlasmoidItem {
}
onNeedTextUpdate: newText => {
if (debug) console.debug()
text.text = newText
sizeUpdate()
}
onNeedToolTipUpdate: newText => {
if (debug) console.debug()
tooltip.text = newText
}
onSizeUpdate: {
if (debug) console.debug()
// 16 is a magic number
// in other case plasmoid will increase own size on each update
if (plasmoid.configuration.height === 0) {
if (plasmoid.configuration.height == 0) {
Layout.minimumHeight = text.contentHeight - 16
Layout.maximumHeight = -1
} else {
Layout.minimumHeight = plasmoid.configuration.height
Layout.maximumHeight = plasmoid.configuration.height
}
if (plasmoid.configuration.width === 0) {
if (plasmoid.configuration.width == 0) {
Layout.minimumWidth = text.contentWidth - 16
Layout.maximumWidth = -1
} else {
@ -202,6 +202,7 @@ PlasmoidItem {
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.debug()
// init submodule
awKeys.initDataAggregator(tooltipSettings)
@ -216,7 +217,7 @@ PlasmoidItem {
awKeys.setAggregatorProperty("tempUnits", plasmoid.configuration.tempUnits)
awKeys.setAggregatorProperty("translate", plasmoid.configuration.translateStrings)
// update telemetry ID
if (plasmoid.configuration.telemetryId.length === 0)
if (plasmoid.configuration.telemetryId.length == 0)
plasmoid.configuration.telemetryId = generateUuid()
// save telemetry
awTelemetryHandler.init(plasmoid.configuration.telemetryCount,
@ -226,10 +227,37 @@ PlasmoidItem {
awTelemetryHandler.uploadTelemetry("awwidgetconfig", plasmoid.configuration.text)
}
function action_checkUpdates() {
if (debug) console.debug()
return awActions.checkUpdates(true)
}
function action_showReadme() {
if (debug) console.debug()
return awActions.showReadme()
}
function action_reportBug() {
if (debug) console.debug()
bugReport.reset()
bugReport.open()
}
function action_requestKey() {
if (debug) console.debug()
tagSelectorBox.model = awKeys.dictKeys(true)
return tagSelector.open()
}
// code from http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
function generateUuid() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
let r = Math.random() * 16 | 0, v = c === "x" ? r : (r & 0x3 | 0x8);
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}

View File

@ -17,13 +17,23 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: tooltipPage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_tooltipNumber: tooltipNumber.value
property alias cfg_useTooltipBackground: useTooltipBackground.checked
@ -43,6 +53,7 @@ KCM.SimpleKCM {
property alias cfg_batTooltipColor: batTooltipColor.value
property alias cfg_batInTooltipColor: batInTooltipColor.value
Column {
id: pageColumn
anchors.fill: parent
@ -167,13 +178,11 @@ KCM.SimpleKCM {
Column {
width: parent.width
enabled: networkTooltipLabel.checked
ColorSelector {
id: downkbTooltipColor
text: i18n("Download speed color")
value: plasmoid.configuration.downkbTooltipColor
}
ColorSelector {
id: upkbTooltipColor
text: i18n("Upload speed color")
@ -195,13 +204,11 @@ KCM.SimpleKCM {
Column {
width: parent.width
enabled: batteryTooltipLabel.checked
ColorSelector {
id: batTooltipColor
text: i18n("Battery active color")
value: plasmoid.configuration.batTooltipColor
}
ColorSelector {
id: batInTooltipColor
text: i18n("Battery inactive color")
@ -210,4 +217,9 @@ KCM.SimpleKCM {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,16 +16,13 @@
***************************************************************************/
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import "."
KCM.SimpleKCM {
Item {
id: widgetPage
// backend
AWKeys {
id: awKeys
@ -34,11 +31,19 @@ KCM.SimpleKCM {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_text: textPattern.text
property bool lock: true
signal needTextUpdate(string newText)
Column {
id: pageColumn
anchors.fill: parent
@ -69,7 +74,10 @@ KCM.SimpleKCM {
}
}
Component.onCompleted: {
if (debug) console.debug()
awKeys.needTextToBeUpdated.connect(needTextUpdate)
// init submodule
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.interval,
@ -84,6 +92,7 @@ KCM.SimpleKCM {
onNeedTextUpdate: newText => {
if (lock) return
if (debug) console.debug()
extensions.showMessage(newText)
lock = true

View File

@ -19,7 +19,7 @@ import QtQuick 2.15
import QtQuick.Controls
ScrollView {
Item {
width: parent.width
height: parent.height * 4 / 5
@ -28,6 +28,7 @@ ScrollView {
TextArea {
id: textArea
anchors.fill: parent
textFormat: TextEdit.PlainText
Column {
@ -49,9 +50,9 @@ ScrollView {
}
onTextChanged: {
let currentTag = getLastTag()
var currentTag = getLastTag()
// exit if there are spaces or empty
if ((currentTag.indexOf(" ") !== -1) || (currentTag.length === 0)) {
if ((currentTag.indexOf(" ") != -1) || (currentTag.length == 0)) {
tooltip.visible = false
return
}
@ -62,7 +63,7 @@ ScrollView {
// show tooltip if found more than 1 or current text does not match
// tag found
tooltip.visible = ((tags.count > 1)
|| ((tags.count === 1) && (tags.model[0] !== tooltip.substring)))
|| ((tags.count == 1) && (tags.model[0] != tooltip.substring)))
}
}
@ -80,7 +81,7 @@ ScrollView {
var substring = textArea.getText(0, textArea.cursorPosition)
// find last position of index in the given substring
var signIndex = substring.lastIndexOf('$') + 1
if ((signIndex === 0) || (signIndex === textArea.cursorPosition))
if ((signIndex == 0) || (signIndex == textArea.cursorPosition))
return ""
// get current tag text
return substring.substr(signIndex)
@ -89,6 +90,14 @@ ScrollView {
function insert(text) {
textArea.insert(textArea.cursorPosition, text)
}
function removeSelection() {
textArea.remove(textArea.selectionStart, textArea.selectionEnd)
}
function selectedText() {
return textArea.selectedText
}
}