mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
more correct logging, use qt logging for qml as well
This commit is contained in:
parent
aacb50c946
commit
4c27382467
@ -19,6 +19,7 @@
|
|||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget")
|
Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", QtMsgType::QtWarningMsg)
|
||||||
Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel")
|
Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel", QtMsgType::QtWarningMsg)
|
||||||
Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon")
|
Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon", QtMsgType::QtWarningMsg)
|
||||||
|
Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets", QtMsgType::QtWarningMsg)
|
||||||
|
@ -26,16 +26,17 @@
|
|||||||
#endif /* LOG_FORMAT */
|
#endif /* LOG_FORMAT */
|
||||||
|
|
||||||
// define info log level
|
// define info log level
|
||||||
#define isInfoEnabled isDebugEnabled
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#ifndef qCInfo
|
#ifndef qCInfo
|
||||||
#define qCInfo qCDebug
|
#define qCInfo qCDebug
|
||||||
#endif /* qCInfo */
|
#endif /* qCInfo */
|
||||||
#endif /* QT_VERSION */
|
#endif /* QT_VERSION */
|
||||||
|
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(LOG_AW)
|
Q_DECLARE_LOGGING_CATEGORY(LOG_AW)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(LOG_DP)
|
Q_DECLARE_LOGGING_CATEGORY(LOG_DP)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(LOG_ESM)
|
Q_DECLARE_LOGGING_CATEGORY(LOG_ESM)
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(LOG_LIB)
|
||||||
|
|
||||||
|
|
||||||
#endif /* AWDEBUG_H */
|
#endif /* AWDEBUG_H */
|
||||||
|
@ -110,6 +110,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,8 +214,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_tempUnits = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_tempUnits = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.tempUnits) {
|
if (model[i]["name"] == plasmoid.configuration.tempUnits) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
tempUnits.currentIndex = i;
|
tempUnits.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,6 +304,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,7 @@ Item {
|
|||||||
width: parent.width * 2 / 3
|
width: parent.width * 2 / 3
|
||||||
text: plasmoid.configuration.fontFamily
|
text: plasmoid.configuration.fontFamily
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (debug) console.debug()
|
||||||
fontDialog.setFont()
|
fontDialog.setFont()
|
||||||
fontDialog.visible = true
|
fontDialog.visible = true
|
||||||
}
|
}
|
||||||
@ -154,8 +155,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontWeight.currentIndex = i;
|
fontWeight.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,8 +192,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontStyle.currentIndex = i;
|
fontStyle.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,12 +240,14 @@ Item {
|
|||||||
signal setFont
|
signal setFont
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
if (debug) console.debug()
|
||||||
selectFont.text = fontDialog.font.family
|
selectFont.text = fontDialog.font.family
|
||||||
fontSize.value = fontDialog.font.pointSize
|
fontSize.value = fontDialog.font.pointSize
|
||||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
onSetFont: {
|
onSetFont: {
|
||||||
|
if (debug) console.debug()
|
||||||
fontDialog.font = Qt.font({
|
fontDialog.font = Qt.font({
|
||||||
family: selectFont.text,
|
family: selectFont.text,
|
||||||
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||||
@ -251,6 +258,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,10 @@ Item {
|
|||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
model: ["auto", "disable", "ati", "nvidia"]
|
model: ["auto", "disable", "ati", "nvidia"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i=0; i<model.length; i++) {
|
for (var i=0; i<model.length; i++) {
|
||||||
if (model[i] == cfg_dataengine["GPUDEV"]) {
|
if (model[i] == cfg_dataengine["GPUDEV"]) {
|
||||||
|
if (debug) console.info("Found", model[i], "on", i)
|
||||||
currentIndex = i;
|
currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,8 +140,10 @@ Item {
|
|||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
model: awKeys.getHddDevices(true)
|
model: awKeys.getHddDevices(true)
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i=0; i<model.length; i++) {
|
for (var i=0; i<model.length; i++) {
|
||||||
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
||||||
|
if (debug) console.info("Found", model[i], "on", i)
|
||||||
hdd.currentIndex = i;
|
hdd.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,8 +237,10 @@ Item {
|
|||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
model: ["disable", "mpris", "mpd"]
|
model: ["disable", "mpris", "mpd"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i=0; i<model.length; i++) {
|
for (var i=0; i<model.length; i++) {
|
||||||
if (model[i] == cfg_dataengine["PLAYER"]) {
|
if (model[i] == cfg_dataengine["PLAYER"]) {
|
||||||
|
if (debug) console.info("Found", model[i], "on", i)
|
||||||
player.currentIndex = i;
|
player.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,14 +301,14 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
awKeys.initKeys(plasmoid.configuration.text)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
cfg_dataengine["GPUDEV"] = gpuDev.currentText
|
cfg_dataengine["GPUDEV"] = gpuDev.currentText
|
||||||
cfg_dataengine["HDDDEV"] = hdd.currentText
|
cfg_dataengine["HDDDEV"] = hdd.currentText
|
||||||
|
@ -92,14 +92,14 @@ Item {
|
|||||||
interval: plasmoid.configuration.interval
|
interval: plasmoid.configuration.interval
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
systemmonitorDE.interval = plasmoid.configuration.interval
|
systemmonitorDE.interval = plasmoid.configuration.interval
|
||||||
|
|
||||||
awKeys.setDataBySource(sourceName, data, settings)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
onSourceAdded: {
|
onSourceAdded: {
|
||||||
if (debug) console.log("Source " + source)
|
if (debug) console.debug("Source", source)
|
||||||
|
|
||||||
awKeys.addDevice(source)
|
awKeys.addDevice(source)
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ Item {
|
|||||||
interval: plasmoid.configuration.interval
|
interval: plasmoid.configuration.interval
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
extsysmonDE.interval = plasmoid.configuration.interval
|
extsysmonDE.interval = plasmoid.configuration.interval
|
||||||
|
|
||||||
awKeys.setDataBySource(sourceName, data, settings)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
@ -126,7 +126,7 @@ Item {
|
|||||||
interval: 1000
|
interval: 1000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
|
||||||
awKeys.setDataBySource(sourceName, data, settings)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
||||||
@ -183,26 +183,27 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDropSource: {
|
onDropSource: {
|
||||||
if (debug) console.log("Source " + sourceName)
|
if (debug) console.debug()
|
||||||
|
if (debug) console.debug("Source", sourceName)
|
||||||
|
|
||||||
systemmonitorDE.disconnectSource(sourceName)
|
systemmonitorDE.disconnectSource(sourceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
onNeedTextUpdate: {
|
onNeedTextUpdate: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
text.text = newText
|
text.text = newText
|
||||||
sizeUpdate()
|
sizeUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
onNeedToolTipUpdate: {
|
onNeedToolTipUpdate: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
tooltip.text = newText
|
tooltip.text = newText
|
||||||
}
|
}
|
||||||
|
|
||||||
onSizeUpdate: {
|
onSizeUpdate: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
if (plasmoid.configuration.height == 0) {
|
if (plasmoid.configuration.height == 0) {
|
||||||
Layout.minimumHeight = text.contentHeight
|
Layout.minimumHeight = text.contentHeight
|
||||||
@ -222,7 +223,7 @@ Item {
|
|||||||
|
|
||||||
Plasmoid.onUserConfiguringChanged: {
|
Plasmoid.onUserConfiguringChanged: {
|
||||||
if (plasmoid.userConfiguring) return
|
if (plasmoid.userConfiguring) return
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
awKeys.initKeys(plasmoid.configuration.text)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
@ -235,25 +236,25 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function action_checkUpdates() {
|
function action_checkUpdates() {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
return awActions.checkUpdates()
|
return awActions.checkUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_showReadme() {
|
function action_showReadme() {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
return awActions.showReadme()
|
return awActions.showReadme()
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_report() {
|
function action_report() {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
return awActions.sendEmail()
|
return awActions.sendEmail()
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_requestKey() {
|
function action_requestKey() {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
return awKeys.graphicalValueByKey()
|
return awKeys.graphicalValueByKey()
|
||||||
}
|
}
|
||||||
|
@ -513,6 +513,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,7 @@ Item {
|
|||||||
iconName: "font"
|
iconName: "font"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Font button")
|
if (debug) console.debug("Font button")
|
||||||
|
|
||||||
var defaultFont = {
|
var defaultFont = {
|
||||||
"color": plasmoid.configuration.fontColor,
|
"color": plasmoid.configuration.fontColor,
|
||||||
"family": plasmoid.configuration.fontFamily,
|
"family": plasmoid.configuration.fontFamily,
|
||||||
@ -112,8 +111,7 @@ Item {
|
|||||||
iconName: "format-indent-more"
|
iconName: "format-indent-more"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Indent button")
|
if (debug) console.debug("Indent button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -126,8 +124,7 @@ Item {
|
|||||||
iconName: "format-text-bold"
|
iconName: "format-text-bold"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Bold button")
|
if (debug) console.debug("Bold button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -139,8 +136,7 @@ Item {
|
|||||||
iconName: "format-text-italic"
|
iconName: "format-text-italic"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Italic button")
|
if (debug) console.debug("Italic button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -152,8 +148,7 @@ Item {
|
|||||||
iconName: "format-text-underline"
|
iconName: "format-text-underline"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Underline button")
|
if (debug) console.debug("Underline button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -165,8 +160,7 @@ Item {
|
|||||||
iconName: "format-text-strikethrough"
|
iconName: "format-text-strikethrough"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Strike button")
|
if (debug) console.debug("Strike button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -179,8 +173,7 @@ Item {
|
|||||||
iconName: "format-justify-left"
|
iconName: "format-justify-left"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Left button")
|
if (debug) console.debug("Left button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -192,8 +185,7 @@ Item {
|
|||||||
iconName: "format-justify-center"
|
iconName: "format-justify-center"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Center button")
|
if (debug) console.debug("Center button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -205,8 +197,7 @@ Item {
|
|||||||
iconName: "format-justify-right"
|
iconName: "format-justify-right"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Right button")
|
if (debug) console.debug("Right button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -218,8 +209,7 @@ Item {
|
|||||||
iconName: "format-justify-fill"
|
iconName: "format-justify-fill"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Justify button")
|
if (debug) console.debug("Justify button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -289,7 +279,9 @@ Item {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
|
if (debug) console.debug()
|
||||||
tags.model = awKeys.dictKeys(true, model[currentIndex]["regexp"])
|
tags.model = awKeys.dictKeys(true, model[currentIndex]["regexp"])
|
||||||
|
if (debug) console.info("Init model", tags.model, "for", model[currentIndex]["label"])
|
||||||
tags.currentIndex = -1
|
tags.currentIndex = -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,8 +295,7 @@ Item {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!tags.currentText) return
|
if (!tags.currentText) return
|
||||||
if (debug) console.log("Add tag button")
|
if (debug) console.debug("Add tag button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -317,8 +308,7 @@ Item {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!tags.currentText) return
|
if (!tags.currentText) return
|
||||||
if (debug) console.log("Show tag button")
|
if (debug) console.debug("Show tag button")
|
||||||
|
|
||||||
var message = i18n("Tag: %1", tags.currentText)
|
var message = i18n("Tag: %1", tags.currentText)
|
||||||
message += "<br>"
|
message += "<br>"
|
||||||
message += i18n("Value: %1", awKeys.valueByKey(tags.currentText))
|
message += i18n("Value: %1", awKeys.valueByKey(tags.currentText))
|
||||||
@ -332,8 +322,7 @@ Item {
|
|||||||
text: i18n("Add lambda")
|
text: i18n("Add lambda")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Lambda button")
|
if (debug) console.debug("Lambda button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -370,8 +359,7 @@ Item {
|
|||||||
interval: 5000
|
interval: 5000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
|
||||||
awKeys.setDataBySource(sourceName, data, settings)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,8 +371,7 @@ Item {
|
|||||||
interval: 5000
|
interval: 5000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
|
||||||
awKeys.setDataBySource(sourceName, data, settings)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -396,14 +383,13 @@ Item {
|
|||||||
interval: 5000
|
interval: 5000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
|
||||||
awKeys.setDataBySource(sourceName, data, settings)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
awKeys.initKeys(plasmoid.configuration.text)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
|
@ -42,15 +42,7 @@
|
|||||||
AWActions::AWActions(QObject *parent)
|
AWActions::AWActions(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
// debug
|
qCDebug(LOG_AW);
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
|
||||||
bool debug = (debugEnv == QString("yes"));
|
|
||||||
|
|
||||||
// logging
|
|
||||||
const_cast<QLoggingCategory &>(LOG_AW()).setEnabled(QtMsgType::QtDebugMsg, debug);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
qCInfo(LOG_AW) << "simple test" << QT_VERSION_CHECK(5, 5, 0) << QT_VERSION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,6 +150,7 @@ QString AWActions::getAboutText(const QString type) const
|
|||||||
QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
|
QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Default font is" << defaultFont;
|
||||||
|
|
||||||
QVariantMap fontMap;
|
QVariantMap fontMap;
|
||||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||||
@ -178,7 +171,7 @@ QVariantMap AWActions::readDataEngineConfiguration() const
|
|||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
||||||
qCDebug(LOG_AW) << "Configuration file" << fileName;
|
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
QVariantMap configuration;
|
QVariantMap configuration;
|
||||||
|
|
||||||
@ -203,7 +196,7 @@ void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) co
|
|||||||
|
|
||||||
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
|
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
qCDebug(LOG_AW) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Configuration"));
|
settings.beginGroup(QString("Configuration"));
|
||||||
settings.setValue(QString("ACPIPATH"), configuration[QString("ACPIPATH")]);
|
settings.setValue(QString("ACPIPATH"), configuration[QString("ACPIPATH")]);
|
||||||
@ -271,6 +264,7 @@ void AWActions::versionReplyRecieved(QNetworkReply *reply) const
|
|||||||
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
|
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
|
||||||
QString version = firstRelease[QString("tag_name")].toString();
|
QString version = firstRelease[QString("tag_name")].toString();
|
||||||
version.remove(QString("V."));
|
version.remove(QString("V."));
|
||||||
|
qCInfo(LOG_AW) << "Found version" << version;
|
||||||
|
|
||||||
int old_major = QString(VERSION).split(QChar('.')).at(0).toInt();
|
int old_major = QString(VERSION).split(QChar('.')).at(0).toInt();
|
||||||
int old_minor = QString(VERSION).split(QChar('.')).at(1).toInt();
|
int old_minor = QString(VERSION).split(QChar('.')).at(1).toInt();
|
||||||
|
@ -30,8 +30,8 @@ class AWActions : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWActions(QObject *parent = nullptr);
|
explicit AWActions(QObject *parent = nullptr);
|
||||||
~AWActions();
|
virtual ~AWActions();
|
||||||
|
|
||||||
Q_INVOKABLE void checkUpdates();
|
Q_INVOKABLE void checkUpdates();
|
||||||
Q_INVOKABLE bool dropCache() const;
|
Q_INVOKABLE bool dropCache() const;
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <QProcessEnvironment>
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -44,21 +43,21 @@
|
|||||||
AWKeys::AWKeys(QObject *parent)
|
AWKeys::AWKeys(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
// debug
|
qCDebug(LOG_AW);
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
|
||||||
bool debug = (debugEnv == QString("yes"));
|
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
const_cast<QLoggingCategory &>(LOG_AW()).setEnabled(QtMsgType::QtDebugMsg, debug);
|
// disable info because QtMsgType has invalid enum order
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
const_cast<QLoggingCategory &>(LOG_AW()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||||
|
#endif /* QT_VERSION */
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
qSetMessagePattern(LOG_FORMAT);
|
||||||
|
|
||||||
// backend
|
// backend
|
||||||
graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, QString("desktops"), debug);
|
graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, QString("desktops"));
|
||||||
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"), debug);
|
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"));
|
||||||
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"), debug);
|
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"));
|
||||||
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"), debug);
|
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"));
|
||||||
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"), debug);
|
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"));
|
||||||
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(dataUpdate()));
|
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(dataUpdate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +79,7 @@ AWKeys::~AWKeys()
|
|||||||
void AWKeys::initKeys(const QString currentPattern)
|
void AWKeys::initKeys(const QString currentPattern)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Pattern" << currentPattern;
|
||||||
|
|
||||||
// init
|
// init
|
||||||
pattern = currentPattern;
|
pattern = currentPattern;
|
||||||
@ -94,6 +94,7 @@ void AWKeys::initKeys(const QString currentPattern)
|
|||||||
void AWKeys::initTooltip(const QVariantMap tooltipParams)
|
void AWKeys::initTooltip(const QVariantMap tooltipParams)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Tooltip parameters" << tooltipParams;
|
||||||
|
|
||||||
if (toolTip != nullptr) {
|
if (toolTip != nullptr) {
|
||||||
disconnect(toolTip, SIGNAL(toolTipPainted(QString)), this, SIGNAL(needToolTipToBeUpdated(QString)));
|
disconnect(toolTip, SIGNAL(toolTipPainted(QString)), this, SIGNAL(needToolTipToBeUpdated(QString)));
|
||||||
@ -109,6 +110,7 @@ void AWKeys::initTooltip(const QVariantMap tooltipParams)
|
|||||||
void AWKeys::setPopupEnabled(const bool popup)
|
void AWKeys::setPopupEnabled(const bool popup)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Is popup enabled" << popup;
|
||||||
|
|
||||||
enablePopup = popup;
|
enablePopup = popup;
|
||||||
}
|
}
|
||||||
@ -117,6 +119,7 @@ void AWKeys::setPopupEnabled(const bool popup)
|
|||||||
void AWKeys::setTranslateStrings(const bool translate)
|
void AWKeys::setTranslateStrings(const bool translate)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Is translation enabled" << translate;
|
||||||
|
|
||||||
translateStrings = translate;
|
translateStrings = translate;
|
||||||
}
|
}
|
||||||
@ -125,6 +128,7 @@ void AWKeys::setTranslateStrings(const bool translate)
|
|||||||
void AWKeys::setWrapNewLines(const bool wrap)
|
void AWKeys::setWrapNewLines(const bool wrap)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Is wrapping enabled" << wrap;
|
||||||
|
|
||||||
wrapNewLines = wrap;
|
wrapNewLines = wrap;
|
||||||
}
|
}
|
||||||
@ -698,15 +702,14 @@ QString AWKeys::valueByKey(QString key) const
|
|||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
qCDebug(LOG_AW) << "Requested key" << key;
|
qCDebug(LOG_AW) << "Requested key" << key;
|
||||||
|
|
||||||
key.remove(QRegExp(QString("^bar[0-9]{1,}")));
|
return values[key.remove(QRegExp(QString("^bar[0-9]{1,}")))];
|
||||||
|
|
||||||
return values[key];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::editItem(const QString type)
|
void AWKeys::editItem(const QString type)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Item type" << type;
|
||||||
|
|
||||||
if (type == QString("graphicalitem")) {
|
if (type == QString("graphicalitem")) {
|
||||||
graphicalItems->setConfigArgs(dictKeys(true, QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")));
|
graphicalItems->setConfigArgs(dictKeys(true, QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")));
|
||||||
@ -738,7 +741,7 @@ void AWKeys::loadKeysFromCache()
|
|||||||
|
|
||||||
QString fileName = QString("%1/awesomewidgets.ndx")
|
QString fileName = QString("%1/awesomewidgets.ndx")
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||||
qCDebug(LOG_AW) << "Cache file" << fileName;
|
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||||
QSettings cache(fileName, QSettings::IniFormat);
|
QSettings cache(fileName, QSettings::IniFormat);
|
||||||
|
|
||||||
cache.beginGroup(QString("Disk"));
|
cache.beginGroup(QString("Disk"));
|
||||||
@ -777,9 +780,57 @@ void AWKeys::reinitKeys()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
foundBars = findGraphicalItems();
|
// init
|
||||||
foundKeys = findKeys();
|
QStringList allKeys = dictKeys();
|
||||||
foundLambdas = findLambdas();
|
|
||||||
|
// append lists
|
||||||
|
// bars
|
||||||
|
foundBars = [allKeys](QString pattern) {
|
||||||
|
QStringList selectedKeys;
|
||||||
|
foreach(QString key, allKeys)
|
||||||
|
if ((key.startsWith(QString("bar"))) &&
|
||||||
|
(pattern.contains(QString("$%1").arg(key)))) {
|
||||||
|
qCInfo(LOG_AW) << "Found bar" << key;
|
||||||
|
selectedKeys.append(key);
|
||||||
|
}
|
||||||
|
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No bars found";
|
||||||
|
return selectedKeys;
|
||||||
|
}(pattern);
|
||||||
|
|
||||||
|
// main key list
|
||||||
|
foundKeys = [allKeys](QString pattern) {
|
||||||
|
QStringList selectedKeys;
|
||||||
|
foreach(QString key, allKeys)
|
||||||
|
if ((!key.startsWith(QString("bar"))) &&
|
||||||
|
(pattern.contains(QString("$%1").arg(key)))) {
|
||||||
|
qCInfo(LOG_AW) << "Found key" << key;
|
||||||
|
selectedKeys.append(key);
|
||||||
|
}
|
||||||
|
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No keys found";
|
||||||
|
return selectedKeys;
|
||||||
|
}(pattern);
|
||||||
|
|
||||||
|
// lambdas
|
||||||
|
foundLambdas = [](QString pattern) {
|
||||||
|
QStringList selectedKeys;
|
||||||
|
// substring inside ${{ }} (with brackets) which should not contain ${{
|
||||||
|
QRegularExpression lambdaRegexp(QString("\\$\\{\\{((?!\\$\\{\\{).)*?\\}\\}"));
|
||||||
|
lambdaRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
||||||
|
|
||||||
|
QRegularExpressionMatchIterator it = lambdaRegexp.globalMatch(pattern);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
QRegularExpressionMatch match = it.next();
|
||||||
|
QString lambda = match.captured();
|
||||||
|
// drop brakets
|
||||||
|
lambda.remove(QRegExp(QString("^\\$\\{\\{")));
|
||||||
|
lambda.remove(QRegExp(QString("\\}\\}$")));
|
||||||
|
// append
|
||||||
|
qCInfo(LOG_AW) << "Found lambda" << lambda;
|
||||||
|
selectedKeys.append(lambda);
|
||||||
|
}
|
||||||
|
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No lambdas found";
|
||||||
|
return selectedKeys;
|
||||||
|
}(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -790,7 +841,7 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
|||||||
qCDebug(LOG_AW) << "Key" << key;
|
qCDebug(LOG_AW) << "Key" << key;
|
||||||
|
|
||||||
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||||
qCDebug(LOG_AW) << "Cache file" << fileName;
|
qCInfo(LOG_AW) << "Cache file" << fileName;
|
||||||
QSettings cache(fileName, QSettings::IniFormat);
|
QSettings cache(fileName, QSettings::IniFormat);
|
||||||
|
|
||||||
cache.beginGroup(type);
|
cache.beginGroup(type);
|
||||||
@ -804,7 +855,7 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
|||||||
foreach(QString dev, devices) {
|
foreach(QString dev, devices) {
|
||||||
QString device = QString("/dev/%1").arg(dev);
|
QString device = QString("/dev/%1").arg(dev);
|
||||||
if (cachedValues.contains(device)) continue;
|
if (cachedValues.contains(device)) continue;
|
||||||
qCDebug(LOG_AW) << "Found new key" << device << "for type" << type;
|
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
|
||||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||||
}
|
}
|
||||||
} else if (type == QString("Network")) {
|
} else if (type == QString("Network")) {
|
||||||
@ -812,12 +863,12 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
|||||||
foreach(QNetworkInterface interface, rawInterfaceList) {
|
foreach(QNetworkInterface interface, rawInterfaceList) {
|
||||||
QString device = interface.name();
|
QString device = interface.name();
|
||||||
if (cachedValues.contains(device)) continue;
|
if (cachedValues.contains(device)) continue;
|
||||||
qCDebug(LOG_AW) << "Found new key" << device << "for type" << type;
|
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
|
||||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cachedValues.contains(key)) return;
|
if (cachedValues.contains(key)) return;
|
||||||
qCDebug(LOG_AW) << "Found new key" << key << "for type" << type;
|
qCInfo(LOG_AW) << "Found new key" << key << "for type" << type;
|
||||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
|
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
|
||||||
}
|
}
|
||||||
cache.endGroup();
|
cache.endGroup();
|
||||||
@ -834,12 +885,14 @@ QString AWKeys::parsePattern() const
|
|||||||
|
|
||||||
QString parsed = pattern;
|
QString parsed = pattern;
|
||||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
|
|
||||||
|
// lambdas
|
||||||
foreach(QString key, foundLambdas)
|
foreach(QString key, foundLambdas)
|
||||||
parsed.replace(QString("${{%1}}").arg(key), [this](QString key) {
|
parsed.replace(QString("${{%1}}").arg(key), [this](QString key) {
|
||||||
QScriptEngine engine;
|
QScriptEngine engine;
|
||||||
foreach(QString lambdaKey, foundKeys)
|
foreach(QString lambdaKey, foundKeys)
|
||||||
key.replace(QString("$%1").arg(lambdaKey), values[lambdaKey]);
|
key.replace(QString("$%1").arg(lambdaKey), values[lambdaKey]);
|
||||||
qCDebug(LOG_AW) << "Expression" << key;
|
qCInfo(LOG_AW) << "Expression" << key;
|
||||||
QScriptValue result = engine.evaluate(key);
|
QScriptValue result = engine.evaluate(key);
|
||||||
if (engine.hasUncaughtException()) {
|
if (engine.hasUncaughtException()) {
|
||||||
int line = engine.uncaughtExceptionLineNumber();
|
int line = engine.uncaughtExceptionLineNumber();
|
||||||
@ -848,17 +901,22 @@ QString AWKeys::parsePattern() const
|
|||||||
} else
|
} else
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}(key));
|
}(key));
|
||||||
|
|
||||||
|
// main keys
|
||||||
foreach(QString key, foundKeys)
|
foreach(QString key, foundKeys)
|
||||||
parsed.replace(QString("$%1").arg(key), [](QString key, QString value) {
|
parsed.replace(QString("$%1").arg(key), [](QString key, QString value) {
|
||||||
if (!key.startsWith(QString("custom")))
|
if (!key.startsWith(QString("custom")))
|
||||||
value.replace(QString(" "), QString(" "));
|
value.replace(QString(" "), QString(" "));
|
||||||
return value;
|
return value;
|
||||||
}(key, values[key]));
|
}(key, values[key]));
|
||||||
|
|
||||||
|
// bars
|
||||||
foreach(QString bar, foundBars)
|
foreach(QString bar, foundBars)
|
||||||
parsed.replace(QString("$%1").arg(bar),
|
parsed.replace(QString("$%1").arg(bar),
|
||||||
graphicalItems->itemByTag(bar)->image(valueByKey(bar).toFloat()));
|
graphicalItems->itemByTag(bar)->image(valueByKey(bar).toFloat()));
|
||||||
|
|
||||||
|
// prepare strings
|
||||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||||
// wrap new lines if required
|
|
||||||
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
@ -868,6 +926,8 @@ QString AWKeys::parsePattern() const
|
|||||||
float AWKeys::temperature(const float temp, const QString units) const
|
float AWKeys::temperature(const float temp, const QString units) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Temperature value" << temp;
|
||||||
|
qCDebug(LOG_AW) << "Temperature units" << units;
|
||||||
|
|
||||||
float converted = temp;
|
float converted = temp;
|
||||||
if (units == QString("Celsius"))
|
if (units == QString("Celsius"))
|
||||||
@ -887,65 +947,3 @@ float AWKeys::temperature(const float temp, const QString units) const
|
|||||||
|
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWKeys::findGraphicalItems() const
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW);
|
|
||||||
|
|
||||||
QStringList orderedKeys;
|
|
||||||
foreach(GraphicalItem *item, graphicalItems->items())
|
|
||||||
orderedKeys.append(item->tag());
|
|
||||||
orderedKeys.sort();
|
|
||||||
|
|
||||||
QStringList selectedKeys;
|
|
||||||
for (int i=orderedKeys.count()-1; i>=0; i--)
|
|
||||||
if (pattern.contains(QString("$%1").arg(orderedKeys.at(i)))) {
|
|
||||||
qCDebug(LOG_AW) << "Found bar" << orderedKeys.at(i);
|
|
||||||
selectedKeys.append(orderedKeys.at(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return selectedKeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStringList AWKeys::findKeys() const
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW);
|
|
||||||
|
|
||||||
QStringList selectedKeys;
|
|
||||||
foreach(QString key, dictKeys()) {
|
|
||||||
if (key.startsWith(QString("bar"))) continue;
|
|
||||||
if (pattern.contains(QString("$%1").arg(key))) {
|
|
||||||
qCDebug(LOG_AW) << "Found key" << key;
|
|
||||||
selectedKeys.append(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return selectedKeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStringList AWKeys::findLambdas() const
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW);
|
|
||||||
|
|
||||||
QStringList selectedKeys;
|
|
||||||
// substring inside ${{ }} (with brackets) which should not contain ${{
|
|
||||||
QRegularExpression lambdaRegexp(QString("\\$\\{\\{((?!\\$\\{\\{).)*?\\}\\}"));
|
|
||||||
lambdaRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
|
||||||
|
|
||||||
QRegularExpressionMatchIterator it = lambdaRegexp.globalMatch(pattern);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
QRegularExpressionMatch match = it.next();
|
|
||||||
QString lambda = match.captured();
|
|
||||||
// drop brakets
|
|
||||||
lambda.remove(QRegExp(QString("^\\$\\{\\{")));
|
|
||||||
lambda.remove(QRegExp(QString("\\}\\}$")));
|
|
||||||
// append
|
|
||||||
qCDebug(LOG_AW) << "Found lambda" << lambda;
|
|
||||||
selectedKeys.append(lambda);
|
|
||||||
}
|
|
||||||
|
|
||||||
return selectedKeys;
|
|
||||||
}
|
|
||||||
|
@ -40,8 +40,8 @@ class AWKeys : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWKeys(QObject *parent = nullptr);
|
explicit AWKeys(QObject *parent = nullptr);
|
||||||
~AWKeys();
|
virtual ~AWKeys();
|
||||||
|
|
||||||
Q_INVOKABLE void initKeys(const QString currentPattern);
|
Q_INVOKABLE void initKeys(const QString currentPattern);
|
||||||
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
|
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
|
||||||
@ -79,10 +79,6 @@ private:
|
|||||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||||
QString parsePattern() const;
|
QString parsePattern() const;
|
||||||
float temperature(const float temp, const QString units) const;
|
float temperature(const float temp, const QString units) const;
|
||||||
// find methods
|
|
||||||
QStringList findGraphicalItems() const;
|
|
||||||
QStringList findKeys() const;
|
|
||||||
QStringList findLambdas() const;
|
|
||||||
// get methods
|
// get methods
|
||||||
AWToolTip *toolTip = nullptr;
|
AWToolTip *toolTip = nullptr;
|
||||||
bool enablePopup = false;
|
bool enablePopup = false;
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "awtooltip.h"
|
#include "awtooltip.h"
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QProcessEnvironment>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
@ -28,14 +27,7 @@ AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
|
|||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
configuration(qvariant_cast<QVariantHash>(settings))
|
configuration(qvariant_cast<QVariantHash>(settings))
|
||||||
{
|
{
|
||||||
// debug
|
qCDebug(LOG_AW);
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
|
||||||
bool debug = (debugEnv == QString("yes"));
|
|
||||||
|
|
||||||
// logging
|
|
||||||
const_cast<QLoggingCategory &>(LOG_AW()).setEnabled(QtMsgType::QtDebugMsg, debug);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
|
|
||||||
toolTipScene = new QGraphicsScene(nullptr);
|
toolTipScene = new QGraphicsScene(nullptr);
|
||||||
toolTipView = new QGraphicsView(toolTipScene);
|
toolTipView = new QGraphicsView(toolTipScene);
|
||||||
@ -145,6 +137,7 @@ QPixmap AWToolTip::image()
|
|||||||
float shift = i * 100.0;
|
float shift = i * 100.0;
|
||||||
if (down) shift -= 100.0;
|
if (down) shift -= 100.0;
|
||||||
for (int j=0; j<data[requiredKeys.at(i)].count()-1; j++) {
|
for (int j=0; j<data[requiredKeys.at(i)].count()-1; j++) {
|
||||||
|
// some magic here
|
||||||
float x1 = j * normX + shift;
|
float x1 = j * normX + shift;
|
||||||
float y1 = - fabs(data[requiredKeys.at(i)].at(j)) * normY + 5.0;
|
float y1 = - fabs(data[requiredKeys.at(i)].at(j)) * normY + 5.0;
|
||||||
float x2 = (j + 1) * normX + shift;
|
float x2 = (j + 1) * normX + shift;
|
||||||
@ -164,9 +157,12 @@ QPixmap AWToolTip::image()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWToolTip::setData(const QString source, float value, const bool ac)
|
void AWToolTip::setData(const QString source, float value, const bool dontInvert)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Source" << source;
|
||||||
|
qCDebug(LOG_AW) << "Value" << value;
|
||||||
|
qCDebug(LOG_AW) << "Do not invert value" << dontInvert;
|
||||||
|
|
||||||
if (data[source].count() == 0)
|
if (data[source].count() == 0)
|
||||||
data[source].append(0.0);
|
data[source].append(0.0);
|
||||||
@ -174,19 +170,12 @@ void AWToolTip::setData(const QString source, float value, const bool ac)
|
|||||||
data[source].takeFirst();
|
data[source].takeFirst();
|
||||||
if (isnan(value)) value = 0.0;
|
if (isnan(value)) value = 0.0;
|
||||||
|
|
||||||
if (ac)
|
// invert values for different battery colours
|
||||||
data[source].append(value);
|
data[source].append(dontInvert ? value : -value);
|
||||||
else
|
|
||||||
data[source].append(-value);
|
|
||||||
|
|
||||||
if ((source == QString("downTooltip")) || (source == QString("upTooltip"))) {
|
if (source == QString("downTooltip")) {
|
||||||
foreach(float val, data[QString("downTooltip")])
|
QList<float> netValues = data[QString("downTooltip")] + data[QString("upTooltip")];
|
||||||
if (boundaries[QString("downTooltip")] < val)
|
boundaries[QString("downTooltip")] = 1.2 * *std::max_element(netValues.cbegin(), netValues.cend());
|
||||||
boundaries[QString("downTooltip")] = val;
|
|
||||||
foreach(float val, data[QString("upTooltip")])
|
|
||||||
if (boundaries[QString("downTooltip")] < val)
|
|
||||||
boundaries[QString("downTooltip")] = val;
|
|
||||||
boundaries[QString("downTooltip")] *= 1.2;
|
|
||||||
boundaries[QString("upTooltip")] = boundaries[QString("downTooltip")];
|
boundaries[QString("upTooltip")] = boundaries[QString("downTooltip")];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ class AWToolTip : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWToolTip(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
|
explicit AWToolTip(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
|
||||||
~AWToolTip();
|
virtual ~AWToolTip();
|
||||||
QSize getSize() const;
|
QSize getSize() const;
|
||||||
QString htmlImage();
|
QString htmlImage();
|
||||||
QPixmap image();
|
QPixmap image();
|
||||||
@ -50,7 +50,7 @@ private:
|
|||||||
QGraphicsScene *toolTipScene = nullptr;
|
QGraphicsScene *toolTipScene = nullptr;
|
||||||
QGraphicsView *toolTipView = nullptr;
|
QGraphicsView *toolTipView = nullptr;
|
||||||
void setData(const QString source, float value,
|
void setData(const QString source, float value,
|
||||||
const bool ac = true);
|
const bool dontInvert = true);
|
||||||
// variables
|
// variables
|
||||||
int counts = 0;
|
int counts = 0;
|
||||||
QVariantHash configuration;
|
QVariantHash configuration;
|
||||||
|
@ -27,14 +27,14 @@
|
|||||||
|
|
||||||
|
|
||||||
AbstractExtItem::AbstractExtItem(QWidget *parent, const QString desktopName,
|
AbstractExtItem::AbstractExtItem(QWidget *parent, const QString desktopName,
|
||||||
const QStringList directories, const bool debugCmd)
|
const QStringList directories)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
m_fileName(desktopName),
|
m_fileName(desktopName),
|
||||||
m_dirs(directories)
|
m_dirs(directories)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
qCDebug(LOG_LIB) << "Desktop name" << desktopName;
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
qCDebug(LOG_LIB) << "Directories" << directories;
|
||||||
|
|
||||||
m_name = m_fileName;
|
m_name = m_fileName;
|
||||||
}
|
}
|
||||||
@ -42,16 +42,16 @@ AbstractExtItem::AbstractExtItem(QWidget *parent, const QString desktopName,
|
|||||||
|
|
||||||
AbstractExtItem::~AbstractExtItem()
|
AbstractExtItem::~AbstractExtItem()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T *AbstractExtItem::copy(const QString fileName, const int number)
|
T *AbstractExtItem::copy(const QString _fileName, const int _number)
|
||||||
{
|
{
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(_fileName)
|
||||||
Q_UNUSED(number)
|
Q_UNUSED(_number)
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
// an analog of pure virtual method
|
// an analog of pure virtual method
|
||||||
return new T();
|
return new T();
|
||||||
@ -61,7 +61,7 @@ T *AbstractExtItem::copy(const QString fileName, const int number)
|
|||||||
|
|
||||||
int AbstractExtItem::apiVersion() const
|
int AbstractExtItem::apiVersion() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_apiVersion;
|
return m_apiVersion;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ int AbstractExtItem::apiVersion() const
|
|||||||
|
|
||||||
QString AbstractExtItem::comment() const
|
QString AbstractExtItem::comment() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_comment;
|
return m_comment;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ QString AbstractExtItem::comment() const
|
|||||||
|
|
||||||
QStringList AbstractExtItem::directories() const
|
QStringList AbstractExtItem::directories() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_dirs;
|
return m_dirs;
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ QStringList AbstractExtItem::directories() const
|
|||||||
|
|
||||||
QString AbstractExtItem::fileName() const
|
QString AbstractExtItem::fileName() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ QString AbstractExtItem::fileName() const
|
|||||||
|
|
||||||
int AbstractExtItem::interval() const
|
int AbstractExtItem::interval() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_interval;
|
return m_interval;
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ int AbstractExtItem::interval() const
|
|||||||
|
|
||||||
bool AbstractExtItem::isActive() const
|
bool AbstractExtItem::isActive() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_active;
|
return m_active;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ bool AbstractExtItem::isActive() const
|
|||||||
|
|
||||||
QString AbstractExtItem::name() const
|
QString AbstractExtItem::name() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ QString AbstractExtItem::name() const
|
|||||||
|
|
||||||
int AbstractExtItem::number() const
|
int AbstractExtItem::number() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_number;
|
return m_number;
|
||||||
}
|
}
|
||||||
@ -125,8 +125,8 @@ int AbstractExtItem::number() const
|
|||||||
|
|
||||||
QString AbstractExtItem::tag(const QString _type) const
|
QString AbstractExtItem::tag(const QString _type) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Tag type" << _type;
|
qCDebug(LOG_LIB) << "Tag type" << _type;
|
||||||
|
|
||||||
return QString("%1%2").arg(_type).arg(m_number);
|
return QString("%1%2").arg(_type).arg(m_number);
|
||||||
}
|
}
|
||||||
@ -134,8 +134,8 @@ QString AbstractExtItem::tag(const QString _type) const
|
|||||||
|
|
||||||
void AbstractExtItem::setApiVersion(const int _apiVersion)
|
void AbstractExtItem::setApiVersion(const int _apiVersion)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Version" << _apiVersion;
|
qCDebug(LOG_LIB) << "Version" << _apiVersion;
|
||||||
|
|
||||||
m_apiVersion = _apiVersion;
|
m_apiVersion = _apiVersion;
|
||||||
}
|
}
|
||||||
@ -143,8 +143,8 @@ void AbstractExtItem::setApiVersion(const int _apiVersion)
|
|||||||
|
|
||||||
void AbstractExtItem::setActive(const bool _state)
|
void AbstractExtItem::setActive(const bool _state)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "State" << _state;
|
qCDebug(LOG_LIB) << "State" << _state;
|
||||||
|
|
||||||
m_active = _state;
|
m_active = _state;
|
||||||
}
|
}
|
||||||
@ -152,8 +152,8 @@ void AbstractExtItem::setActive(const bool _state)
|
|||||||
|
|
||||||
void AbstractExtItem::setComment(const QString _comment)
|
void AbstractExtItem::setComment(const QString _comment)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Comment" << _comment;
|
qCDebug(LOG_LIB) << "Comment" << _comment;
|
||||||
|
|
||||||
m_comment = _comment;
|
m_comment = _comment;
|
||||||
}
|
}
|
||||||
@ -161,8 +161,8 @@ void AbstractExtItem::setComment(const QString _comment)
|
|||||||
|
|
||||||
void AbstractExtItem::setInterval(const int _interval)
|
void AbstractExtItem::setInterval(const int _interval)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Interval" << _interval;
|
qCDebug(LOG_LIB) << "Interval" << _interval;
|
||||||
if (_interval <= 0) return;
|
if (_interval <= 0) return;
|
||||||
|
|
||||||
m_interval = _interval;
|
m_interval = _interval;
|
||||||
@ -171,8 +171,8 @@ void AbstractExtItem::setInterval(const int _interval)
|
|||||||
|
|
||||||
void AbstractExtItem::setName(const QString _name)
|
void AbstractExtItem::setName(const QString _name)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Name" << _name;
|
qCDebug(LOG_LIB) << "Name" << _name;
|
||||||
|
|
||||||
m_name = _name;
|
m_name = _name;
|
||||||
}
|
}
|
||||||
@ -180,14 +180,14 @@ void AbstractExtItem::setName(const QString _name)
|
|||||||
|
|
||||||
void AbstractExtItem::setNumber(int _number)
|
void AbstractExtItem::setNumber(int _number)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Number" << _number;
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
if (_number == -1)
|
if (_number == -1)
|
||||||
_number = []() {
|
_number = []() {
|
||||||
qCWarning(LOG_ESM) << "Number is empty, generate new one";
|
qCWarning(LOG_LIB) << "Number is empty, generate new one";
|
||||||
qsrand(QTime::currentTime().msec());
|
qsrand(QTime::currentTime().msec());
|
||||||
int n = qrand() % 1000;
|
int n = qrand() % 1000;
|
||||||
qCDebug(LOG_ESM) << "Generated number is" << n;
|
qCInfo(LOG_LIB) << "Generated number is" << n;
|
||||||
return n;
|
return n;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ void AbstractExtItem::setNumber(int _number)
|
|||||||
|
|
||||||
void AbstractExtItem::readConfiguration()
|
void AbstractExtItem::readConfiguration()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||||
if (!QDir(m_dirs.at(i)).entryList(QDir::Files).contains(m_fileName)) continue;
|
if (!QDir(m_dirs.at(i)).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||||
@ -217,11 +217,11 @@ void AbstractExtItem::readConfiguration()
|
|||||||
|
|
||||||
bool AbstractExtItem::tryDelete() const
|
bool AbstractExtItem::tryDelete() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
foreach(QString dir, m_dirs) {
|
foreach(QString dir, m_dirs) {
|
||||||
bool status = QFile::remove(QString("%1/%2").arg(dir).arg(m_fileName));
|
bool status = QFile::remove(QString("%1/%2").arg(dir).arg(m_fileName));
|
||||||
qCDebug(LOG_ESM) << "Remove file" << QString("%1/%2").arg(dir).arg(m_fileName) << status;
|
qCInfo(LOG_LIB) << "Remove file" << QString("%1/%2").arg(dir).arg(m_fileName) << status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if exists
|
// check if exists
|
||||||
@ -233,10 +233,10 @@ bool AbstractExtItem::tryDelete() const
|
|||||||
|
|
||||||
void AbstractExtItem::writeConfiguration() const
|
void AbstractExtItem::writeConfiguration() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(m_dirs.first()).arg(m_fileName), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(m_dirs.first()).arg(m_fileName), QSettings::IniFormat);
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||||
|
@ -38,10 +38,9 @@ class AbstractExtItem : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AbstractExtItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
explicit AbstractExtItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList());
|
||||||
const bool debugCmd = false);
|
|
||||||
virtual ~AbstractExtItem();
|
virtual ~AbstractExtItem();
|
||||||
template <class T> T *copy(const QString fileName, const int number);
|
template <class T> T *copy(const QString _fileName, const int _number);
|
||||||
// get methods
|
// get methods
|
||||||
int apiVersion() const;
|
int apiVersion() const;
|
||||||
QString comment() const;
|
QString comment() const;
|
||||||
|
@ -26,12 +26,10 @@
|
|||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent, const bool debugCmd)
|
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
|
|
||||||
dialog = new QDialog(this);
|
dialog = new QDialog(this);
|
||||||
widgetDialog = new QListWidget(dialog);
|
widgetDialog = new QListWidget(dialog);
|
||||||
@ -55,7 +53,7 @@ AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent, const bool
|
|||||||
|
|
||||||
AbstractExtItemAggregator::~AbstractExtItemAggregator()
|
AbstractExtItemAggregator::~AbstractExtItemAggregator()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
@ -63,7 +61,7 @@ AbstractExtItemAggregator::~AbstractExtItemAggregator()
|
|||||||
|
|
||||||
QString AbstractExtItemAggregator::getName()
|
QString AbstractExtItemAggregator::getName()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
QString name = QInputDialog::getText(this, i18n("Enter file name"),
|
QString name = QInputDialog::getText(this, i18n("Enter file name"),
|
||||||
@ -78,7 +76,7 @@ QString AbstractExtItemAggregator::getName()
|
|||||||
|
|
||||||
QVariant AbstractExtItemAggregator::configArgs() const
|
QVariant AbstractExtItemAggregator::configArgs() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_configArgs;
|
return m_configArgs;
|
||||||
}
|
}
|
||||||
@ -86,8 +84,8 @@ QVariant AbstractExtItemAggregator::configArgs() const
|
|||||||
|
|
||||||
void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
|
void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Configuration arguments" << _configArgs;
|
qCDebug(LOG_LIB) << "Configuration arguments" << _configArgs;
|
||||||
|
|
||||||
m_configArgs = _configArgs;
|
m_configArgs = _configArgs;
|
||||||
}
|
}
|
||||||
@ -96,7 +94,7 @@ void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
|
|||||||
void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
|
void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
Q_UNUSED(item)
|
Q_UNUSED(item)
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return editItem();
|
return editItem();
|
||||||
}
|
}
|
||||||
@ -104,7 +102,7 @@ void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
|
|||||||
|
|
||||||
void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
|
void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
if (static_cast<QPushButton *>(button) == copyButton)
|
if (static_cast<QPushButton *>(button) == copyButton)
|
||||||
return copyItem();
|
return copyItem();
|
||||||
|
@ -33,7 +33,7 @@ class AbstractExtItemAggregator : public QWidget
|
|||||||
Q_PROPERTY(QVariant configArgs READ configArgs WRITE setConfigArgs)
|
Q_PROPERTY(QVariant configArgs READ configArgs WRITE setConfigArgs)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AbstractExtItemAggregator(QWidget *parent = nullptr, const bool debugCmd = false);
|
explicit AbstractExtItemAggregator(QWidget *parent = nullptr);
|
||||||
virtual ~AbstractExtItemAggregator();
|
virtual ~AbstractExtItemAggregator();
|
||||||
QString getName();
|
QString getName();
|
||||||
// ui
|
// ui
|
||||||
|
@ -33,13 +33,17 @@ template <class T>
|
|||||||
class ExtItemAggregator : public AbstractExtItemAggregator
|
class ExtItemAggregator : public AbstractExtItemAggregator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ExtItemAggregator(QWidget *parent, const QString type,
|
explicit ExtItemAggregator(QWidget *parent, const QString type)
|
||||||
const bool debugCmd = false)
|
: AbstractExtItemAggregator(parent),
|
||||||
: AbstractExtItemAggregator(parent, debugCmd),
|
|
||||||
m_type(type)
|
m_type(type)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
qCDebug(LOG_LIB) << "Type" << type;
|
||||||
|
|
||||||
|
// disable info because QtMsgType has invalid enum order
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
const_cast<QLoggingCategory &>(LOG_LIB()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||||
|
#endif /* QT_VERSION */
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
qSetMessagePattern(LOG_FORMAT);
|
||||||
|
|
||||||
initItems();
|
initItems();
|
||||||
@ -47,23 +51,23 @@ public:
|
|||||||
|
|
||||||
virtual ~ExtItemAggregator()
|
virtual ~ExtItemAggregator()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
m_items.clear();
|
m_items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void editItems()
|
void editItems()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
int ret = dialog->exec();
|
int ret = dialog->exec();
|
||||||
qCDebug(LOG_ESM) << "Dialog returns" << ret;
|
qCInfo(LOG_LIB) << "Dialog returns" << ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
void initItems()
|
void initItems()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
m_items.clear();
|
m_items.clear();
|
||||||
m_items = getItems();
|
m_items = getItems();
|
||||||
@ -71,7 +75,8 @@ public:
|
|||||||
|
|
||||||
T *itemByTag(const QString _tag) const
|
T *itemByTag(const QString _tag) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Tag" << _tag;
|
||||||
|
|
||||||
T *found = nullptr;
|
T *found = nullptr;
|
||||||
foreach(T *item, m_items) {
|
foreach(T *item, m_items) {
|
||||||
@ -79,13 +84,16 @@ public:
|
|||||||
found = item;
|
found = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (found == nullptr)
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by tag" << _tag;
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *itemByTagNumber(const int _number) const
|
T *itemByTagNumber(const int _number) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
T *found = nullptr;
|
T *found = nullptr;
|
||||||
foreach(T *item, m_items) {
|
foreach(T *item, m_items) {
|
||||||
@ -93,13 +101,15 @@ public:
|
|||||||
found = item;
|
found = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (found == nullptr)
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by number" << _number;
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *itemFromWidget() const
|
T *itemFromWidget() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QListWidgetItem *widgetItem = widgetDialog->currentItem();
|
QListWidgetItem *widgetItem = widgetDialog->currentItem();
|
||||||
if (widgetItem == nullptr) return nullptr;
|
if (widgetItem == nullptr) return nullptr;
|
||||||
@ -110,20 +120,22 @@ public:
|
|||||||
found = item;
|
found = item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (found == nullptr)
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by name" << widgetItem->text();
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<T *> items() const
|
QList<T *> items() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_items;
|
return m_items;
|
||||||
};
|
};
|
||||||
|
|
||||||
int uniqNumber() const
|
int uniqNumber() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QList<int> tagList;
|
QList<int> tagList;
|
||||||
foreach(T *item, m_items) tagList.append(item->number());
|
foreach(T *item, m_items) tagList.append(item->number());
|
||||||
@ -140,7 +152,7 @@ private:
|
|||||||
// init method
|
// init method
|
||||||
QList<T *> getItems()
|
QList<T *> getItems()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
// create directory at $HOME
|
// create directory at $HOME
|
||||||
QString localDir = QString("%1/awesomewidgets/%2")
|
QString localDir = QString("%1/awesomewidgets/%2")
|
||||||
@ -148,7 +160,7 @@ private:
|
|||||||
.arg(m_type);
|
.arg(m_type);
|
||||||
QDir localDirectory;
|
QDir localDirectory;
|
||||||
if (localDirectory.mkpath(localDir))
|
if (localDirectory.mkpath(localDir))
|
||||||
qCDebug(LOG_ESM) << "Created directory" << localDir;
|
qCInfo(LOG_LIB) << "Created directory" << localDir;
|
||||||
|
|
||||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||||
QString("awesomewidgets/%1").arg(m_type),
|
QString("awesomewidgets/%1").arg(m_type),
|
||||||
@ -160,9 +172,9 @@ private:
|
|||||||
foreach(QString file, files) {
|
foreach(QString file, files) {
|
||||||
if (!file.endsWith(QString(".desktop"))) continue;
|
if (!file.endsWith(QString(".desktop"))) continue;
|
||||||
if (names.contains(file)) continue;
|
if (names.contains(file)) continue;
|
||||||
qCDebug(LOG_ESM) << "Found file" << file << "in" << dir;
|
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
|
||||||
names.append(file);
|
names.append(file);
|
||||||
items.append(new T(this, file, dirs, LOG_ESM().isDebugEnabled()));
|
items.append(new T(this, file, dirs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +183,8 @@ private:
|
|||||||
|
|
||||||
void repaint()
|
void repaint()
|
||||||
{
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
widgetDialog->clear();
|
widgetDialog->clear();
|
||||||
foreach(T *_item, m_items) {
|
foreach(T *_item, m_items) {
|
||||||
QListWidgetItem *item = new QListWidgetItem(_item->fileName(), widgetDialog);
|
QListWidgetItem *item = new QListWidgetItem(_item->fileName(), widgetDialog);
|
||||||
@ -186,12 +200,15 @@ private:
|
|||||||
// methods
|
// methods
|
||||||
void copyItem()
|
void copyItem()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
T *source = itemFromWidget();
|
T *source = itemFromWidget();
|
||||||
QString fileName = getName();
|
QString fileName = getName();
|
||||||
int number = uniqNumber();
|
int number = uniqNumber();
|
||||||
if ((source == nullptr) || (fileName.isEmpty())) return;
|
if ((source == nullptr) || (fileName.isEmpty())) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to copy";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
T *newItem = source->copy(fileName, number);
|
T *newItem = source->copy(fileName, number);
|
||||||
if (newItem->showConfiguration(configArgs()) == 1) {
|
if (newItem->showConfiguration(configArgs()) == 1) {
|
||||||
@ -202,16 +219,19 @@ private:
|
|||||||
|
|
||||||
void createItem()
|
void createItem()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString fileName = getName();
|
QString fileName = getName();
|
||||||
int number = uniqNumber();
|
int number = uniqNumber();
|
||||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||||
QString("awesomewidgets/%1").arg(m_type),
|
QString("awesomewidgets/%1").arg(m_type),
|
||||||
QStandardPaths::LocateDirectory);
|
QStandardPaths::LocateDirectory);
|
||||||
if (fileName.isEmpty()) return;
|
if (fileName.isEmpty()) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to create";
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
T *newItem = new T(this, fileName, dirs, LOG_ESM().isDebugEnabled());
|
T *newItem = new T(this, fileName, dirs);
|
||||||
newItem->setNumber(number);
|
newItem->setNumber(number);
|
||||||
if (newItem->showConfiguration(configArgs()) == 1) {
|
if (newItem->showConfiguration(configArgs()) == 1) {
|
||||||
initItems();
|
initItems();
|
||||||
@ -221,10 +241,13 @@ private:
|
|||||||
|
|
||||||
void deleteItem()
|
void deleteItem()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
T *source = itemFromWidget();
|
T *source = itemFromWidget();
|
||||||
if (source == nullptr) return;
|
if (source == nullptr) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to delete";
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
if (source->tryDelete()) {
|
if (source->tryDelete()) {
|
||||||
initItems();
|
initItems();
|
||||||
@ -234,10 +257,13 @@ private:
|
|||||||
|
|
||||||
void editItem()
|
void editItem()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
T *source = itemFromWidget();
|
T *source = itemFromWidget();
|
||||||
if (source == nullptr) return;
|
if (source == nullptr) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to edit";
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
if (source->showConfiguration(configArgs()) == 1) {
|
if (source->showConfiguration(configArgs()) == 1) {
|
||||||
initItems();
|
initItems();
|
||||||
|
@ -34,13 +34,11 @@
|
|||||||
|
|
||||||
|
|
||||||
ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
|
ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
|
||||||
const QStringList directories, const bool debugCmd)
|
const QStringList directories)
|
||||||
: AbstractExtItem(parent, quotesName, directories, debugCmd),
|
: AbstractExtItem(parent, quotesName, directories),
|
||||||
ui(new Ui::ExtQuotes)
|
ui(new Ui::ExtQuotes)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
|
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -64,7 +62,7 @@ ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
|
|||||||
|
|
||||||
ExtQuotes::~ExtQuotes()
|
ExtQuotes::~ExtQuotes()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||||
|
|
||||||
@ -73,18 +71,19 @@ ExtQuotes::~ExtQuotes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtQuotes *ExtQuotes::copy(const QString fileName, const int number)
|
ExtQuotes *ExtQuotes::copy(const QString _fileName, const int _number)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), fileName,
|
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
directories(), LOG_ESM().isDebugEnabled());
|
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setComment(comment());
|
item->setComment(comment());
|
||||||
item->setInterval(interval());
|
item->setInterval(interval());
|
||||||
item->setName(name());
|
item->setName(name());
|
||||||
item->setNumber(number);
|
item->setNumber(_number);
|
||||||
item->setTicker(ticker());
|
item->setTicker(ticker());
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@ -93,7 +92,7 @@ ExtQuotes *ExtQuotes::copy(const QString fileName, const int number)
|
|||||||
|
|
||||||
QString ExtQuotes::ticker() const
|
QString ExtQuotes::ticker() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_ticker;
|
return m_ticker;
|
||||||
}
|
}
|
||||||
@ -101,7 +100,7 @@ QString ExtQuotes::ticker() const
|
|||||||
|
|
||||||
QString ExtQuotes::uniq() const
|
QString ExtQuotes::uniq() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_ticker;
|
return m_ticker;
|
||||||
}
|
}
|
||||||
@ -109,8 +108,8 @@ QString ExtQuotes::uniq() const
|
|||||||
|
|
||||||
void ExtQuotes::setTicker(const QString _ticker)
|
void ExtQuotes::setTicker(const QString _ticker)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Ticker" << _ticker;
|
qCDebug(LOG_LIB) << "Ticker" << _ticker;
|
||||||
|
|
||||||
m_ticker = _ticker;
|
m_ticker = _ticker;
|
||||||
}
|
}
|
||||||
@ -118,7 +117,7 @@ void ExtQuotes::setTicker(const QString _ticker)
|
|||||||
|
|
||||||
void ExtQuotes::readConfiguration()
|
void ExtQuotes::readConfiguration()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
@ -132,6 +131,7 @@ void ExtQuotes::readConfiguration()
|
|||||||
|
|
||||||
// update for current API
|
// update for current API
|
||||||
if ((apiVersion() > 0) && (apiVersion() < AWEQAPI)) {
|
if ((apiVersion() > 0) && (apiVersion() < AWEQAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEQAPI;
|
||||||
setApiVersion(AWEQAPI);
|
setApiVersion(AWEQAPI);
|
||||||
writeConfiguration();
|
writeConfiguration();
|
||||||
}
|
}
|
||||||
@ -140,11 +140,11 @@ void ExtQuotes::readConfiguration()
|
|||||||
|
|
||||||
QVariantHash ExtQuotes::run()
|
QVariantHash ExtQuotes::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
if ((!isActive()) || (isRunning)) return values;
|
if ((!isActive()) || (isRunning)) return values;
|
||||||
|
|
||||||
if (times == 1) {
|
if (times == 1) {
|
||||||
qCDebug(LOG_ESM) << "Send request";
|
qCInfo(LOG_LIB) << "Send request";
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
|
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
|
||||||
new QReplyTimeout(reply, 1000);
|
new QReplyTimeout(reply, 1000);
|
||||||
@ -161,7 +161,7 @@ QVariantHash ExtQuotes::run()
|
|||||||
int ExtQuotes::showConfiguration(const QVariant args)
|
int ExtQuotes::showConfiguration(const QVariant args)
|
||||||
{
|
{
|
||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->lineEdit_name->setText(name());
|
ui->lineEdit_name->setText(name());
|
||||||
ui->lineEdit_comment->setText(comment());
|
ui->lineEdit_comment->setText(comment());
|
||||||
@ -187,11 +187,11 @@ int ExtQuotes::showConfiguration(const QVariant args)
|
|||||||
|
|
||||||
void ExtQuotes::writeConfiguration() const
|
void ExtQuotes::writeConfiguration() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
settings.setValue(QString("X-AW-Ticker"), m_ticker);
|
settings.setValue(QString("X-AW-Ticker"), m_ticker);
|
||||||
@ -202,9 +202,9 @@ void ExtQuotes::writeConfiguration() const
|
|||||||
|
|
||||||
void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Return code" << reply->error();
|
qCDebug(LOG_LIB) << "Return code" << reply->error();
|
||||||
qCDebug(LOG_ESM) << "Reply error message" << reply->errorString();
|
qCDebug(LOG_LIB) << "Reply error message" << reply->errorString();
|
||||||
|
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
@ -212,7 +212,7 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
if ((reply->error() != QNetworkReply::NoError) ||
|
if ((reply->error() != QNetworkReply::NoError) ||
|
||||||
(error.error != QJsonParseError::NoError)) {
|
(error.error != QJsonParseError::NoError)) {
|
||||||
qCWarning(LOG_ESM) << "Parse error" << error.errorString();
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()[QString("query")].toMap();
|
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()[QString("query")].toMap();
|
||||||
@ -244,7 +244,7 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
|||||||
|
|
||||||
void ExtQuotes::translate()
|
void ExtQuotes::translate()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->label_name->setText(i18n("Name"));
|
ui->label_name->setText(i18n("Name"));
|
||||||
ui->label_comment->setText(i18n("Comment"));
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
@ -258,11 +258,11 @@ void ExtQuotes::translate()
|
|||||||
|
|
||||||
QString ExtQuotes::url() const
|
QString ExtQuotes::url() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString apiUrl = QString(YAHOO_URL);
|
QString apiUrl = QString(YAHOO_URL);
|
||||||
apiUrl.replace(QString("$TICKER"), m_ticker);
|
apiUrl.replace(QString("$TICKER"), m_ticker);
|
||||||
qCDebug(LOG_ESM) << "API url" << apiUrl;
|
qCInfo(LOG_LIB) << "API url" << apiUrl;
|
||||||
|
|
||||||
return apiUrl;
|
return apiUrl;
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,9 @@ class ExtQuotes : public AbstractExtItem
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExtQuotes(QWidget *parent = nullptr, const QString quotesName = QString(),
|
explicit ExtQuotes(QWidget *parent = nullptr, const QString quotesName = QString(),
|
||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList());
|
||||||
const bool debugCmd = false);
|
|
||||||
virtual ~ExtQuotes();
|
virtual ~ExtQuotes();
|
||||||
ExtQuotes *copy(const QString fileName, const int number);
|
ExtQuotes *copy(const QString _fileName, const int _number);
|
||||||
// get methods
|
// get methods
|
||||||
QString ticker() const;
|
QString ticker() const;
|
||||||
QString uniq() const;
|
QString uniq() const;
|
||||||
|
@ -32,13 +32,11 @@
|
|||||||
|
|
||||||
|
|
||||||
ExtScript::ExtScript(QWidget *parent, const QString scriptName,
|
ExtScript::ExtScript(QWidget *parent, const QString scriptName,
|
||||||
const QStringList directories, const bool debugCmd)
|
const QStringList directories)
|
||||||
: AbstractExtItem(parent, scriptName, directories, debugCmd),
|
: AbstractExtItem(parent, scriptName, directories),
|
||||||
ui(new Ui::ExtScript)
|
ui(new Ui::ExtScript)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
|
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
readJsonFilters();
|
readJsonFilters();
|
||||||
@ -55,7 +53,7 @@ ExtScript::ExtScript(QWidget *parent, const QString scriptName,
|
|||||||
|
|
||||||
ExtScript::~ExtScript()
|
ExtScript::~ExtScript()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
process->kill();
|
process->kill();
|
||||||
delete process;
|
delete process;
|
||||||
@ -63,12 +61,13 @@ ExtScript::~ExtScript()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtScript *ExtScript::copy(const QString fileName, const int number)
|
ExtScript *ExtScript::copy(const QString _fileName, const int _number)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), fileName,
|
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
directories(), LOG_ESM().isDebugEnabled());
|
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setComment(comment());
|
item->setComment(comment());
|
||||||
@ -76,7 +75,7 @@ ExtScript *ExtScript::copy(const QString fileName, const int number)
|
|||||||
item->setHasOutput(hasOutput());
|
item->setHasOutput(hasOutput());
|
||||||
item->setInterval(interval());
|
item->setInterval(interval());
|
||||||
item->setName(name());
|
item->setName(name());
|
||||||
item->setNumber(number);
|
item->setNumber(_number);
|
||||||
item->setPrefix(prefix());
|
item->setPrefix(prefix());
|
||||||
item->setRedirect(redirect());
|
item->setRedirect(redirect());
|
||||||
|
|
||||||
@ -86,7 +85,7 @@ ExtScript *ExtScript::copy(const QString fileName, const int number)
|
|||||||
|
|
||||||
QString ExtScript::executable() const
|
QString ExtScript::executable() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_executable;
|
return m_executable;
|
||||||
}
|
}
|
||||||
@ -94,7 +93,7 @@ QString ExtScript::executable() const
|
|||||||
|
|
||||||
QStringList ExtScript::filters() const
|
QStringList ExtScript::filters() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_filters;
|
return m_filters;
|
||||||
}
|
}
|
||||||
@ -102,7 +101,7 @@ QStringList ExtScript::filters() const
|
|||||||
|
|
||||||
bool ExtScript::hasOutput() const
|
bool ExtScript::hasOutput() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_output;
|
return m_output;
|
||||||
}
|
}
|
||||||
@ -110,7 +109,7 @@ bool ExtScript::hasOutput() const
|
|||||||
|
|
||||||
QString ExtScript::prefix() const
|
QString ExtScript::prefix() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_prefix;
|
return m_prefix;
|
||||||
}
|
}
|
||||||
@ -118,7 +117,7 @@ QString ExtScript::prefix() const
|
|||||||
|
|
||||||
ExtScript::Redirect ExtScript::redirect() const
|
ExtScript::Redirect ExtScript::redirect() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_redirect;
|
return m_redirect;
|
||||||
}
|
}
|
||||||
@ -126,7 +125,7 @@ ExtScript::Redirect ExtScript::redirect() const
|
|||||||
|
|
||||||
QString ExtScript::uniq() const
|
QString ExtScript::uniq() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_executable;
|
return m_executable;
|
||||||
}
|
}
|
||||||
@ -134,7 +133,7 @@ QString ExtScript::uniq() const
|
|||||||
|
|
||||||
QString ExtScript::strRedirect() const
|
QString ExtScript::strRedirect() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
switch (m_redirect) {
|
switch (m_redirect) {
|
||||||
@ -156,8 +155,8 @@ QString ExtScript::strRedirect() const
|
|||||||
|
|
||||||
void ExtScript::setExecutable(const QString _executable)
|
void ExtScript::setExecutable(const QString _executable)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Executable" << _executable;
|
qCDebug(LOG_LIB) << "Executable" << _executable;
|
||||||
|
|
||||||
m_executable = _executable;
|
m_executable = _executable;
|
||||||
}
|
}
|
||||||
@ -165,18 +164,20 @@ void ExtScript::setExecutable(const QString _executable)
|
|||||||
|
|
||||||
void ExtScript::setFilters(const QStringList _filters)
|
void ExtScript::setFilters(const QStringList _filters)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Filters" << _filters;
|
qCDebug(LOG_LIB) << "Filters" << _filters;
|
||||||
|
|
||||||
foreach(QString filter, _filters)
|
std::for_each(_filters.cbegin(), _filters.cend(),
|
||||||
updateFilter(filter);
|
[this](QString filter) { return updateFilter(filter); });
|
||||||
|
// foreach(QString filter, _filters)
|
||||||
|
// updateFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtScript::setHasOutput(const bool _state)
|
void ExtScript::setHasOutput(const bool _state)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "State" << _state;
|
qCDebug(LOG_LIB) << "State" << _state;
|
||||||
|
|
||||||
m_output = _state;
|
m_output = _state;
|
||||||
}
|
}
|
||||||
@ -184,8 +185,8 @@ void ExtScript::setHasOutput(const bool _state)
|
|||||||
|
|
||||||
void ExtScript::setPrefix(const QString _prefix)
|
void ExtScript::setPrefix(const QString _prefix)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Prefix" << _prefix;
|
qCDebug(LOG_LIB) << "Prefix" << _prefix;
|
||||||
|
|
||||||
m_prefix = _prefix;
|
m_prefix = _prefix;
|
||||||
}
|
}
|
||||||
@ -193,8 +194,8 @@ void ExtScript::setPrefix(const QString _prefix)
|
|||||||
|
|
||||||
void ExtScript::setRedirect(const Redirect _redirect)
|
void ExtScript::setRedirect(const Redirect _redirect)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Redirect" << _redirect;
|
qCDebug(LOG_LIB) << "Redirect" << _redirect;
|
||||||
|
|
||||||
m_redirect = _redirect;
|
m_redirect = _redirect;
|
||||||
}
|
}
|
||||||
@ -202,8 +203,8 @@ void ExtScript::setRedirect(const Redirect _redirect)
|
|||||||
|
|
||||||
void ExtScript::setStrRedirect(const QString _redirect)
|
void ExtScript::setStrRedirect(const QString _redirect)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Redirect" << _redirect;
|
qCDebug(LOG_LIB) << "Redirect" << _redirect;
|
||||||
|
|
||||||
if (_redirect == QString("stdout2sdterr"))
|
if (_redirect == QString("stdout2sdterr"))
|
||||||
m_redirect = stdout2stderr;
|
m_redirect = stdout2stderr;
|
||||||
@ -216,14 +217,14 @@ void ExtScript::setStrRedirect(const QString _redirect)
|
|||||||
|
|
||||||
QString ExtScript::applyFilters(QString _value) const
|
QString ExtScript::applyFilters(QString _value) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Value" << _value;
|
qCDebug(LOG_LIB) << "Value" << _value;
|
||||||
|
|
||||||
foreach(QString filt, m_filters) {
|
foreach(QString filt, m_filters) {
|
||||||
qCDebug(LOG_ESM) << "Found filter" << filt;
|
qCInfo(LOG_LIB) << "Found filter" << filt;
|
||||||
QVariantMap filter = jsonFilters[filt].toMap();
|
QVariantMap filter = jsonFilters[filt].toMap();
|
||||||
if (filter.isEmpty()) {
|
if (filter.isEmpty()) {
|
||||||
qCWarning(LOG_ESM) << "Could not find filter in the json";
|
qCWarning(LOG_LIB) << "Could not find filter" << _value << "in the json";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach(QString f, filter.keys())
|
foreach(QString f, filter.keys())
|
||||||
@ -236,9 +237,9 @@ QString ExtScript::applyFilters(QString _value) const
|
|||||||
|
|
||||||
void ExtScript::updateFilter(const QString _filter, const bool _add)
|
void ExtScript::updateFilter(const QString _filter, const bool _add)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Filter" << _filter;
|
qCDebug(LOG_LIB) << "Filter" << _filter;
|
||||||
qCDebug(LOG_ESM) << "Should be added" << _add;
|
qCDebug(LOG_LIB) << "Should be added" << _add;
|
||||||
|
|
||||||
if (_add) {
|
if (_add) {
|
||||||
if (m_filters.contains(_filter)) return;
|
if (m_filters.contains(_filter)) return;
|
||||||
@ -251,7 +252,7 @@ void ExtScript::updateFilter(const QString _filter, const bool _add)
|
|||||||
|
|
||||||
void ExtScript::readConfiguration()
|
void ExtScript::readConfiguration()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
@ -274,6 +275,7 @@ void ExtScript::readConfiguration()
|
|||||||
|
|
||||||
// update for current API
|
// update for current API
|
||||||
if ((apiVersion() > 0) && (apiVersion() < AWESAPI)) {
|
if ((apiVersion() > 0) && (apiVersion() < AWESAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWESAPI;
|
||||||
setApiVersion(AWESAPI);
|
setApiVersion(AWESAPI);
|
||||||
writeConfiguration();
|
writeConfiguration();
|
||||||
}
|
}
|
||||||
@ -282,39 +284,41 @@ void ExtScript::readConfiguration()
|
|||||||
|
|
||||||
void ExtScript::readJsonFilters()
|
void ExtScript::readJsonFilters()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||||
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
|
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << fileName;
|
qCInfo(LOG_LIB) << "Configuration file" << fileName;
|
||||||
QFile jsonFile(fileName);
|
QFile jsonFile(fileName);
|
||||||
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
qCWarning(LOG_LIB) << "Could not open" << fileName;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
QString jsonText = jsonFile.readAll();
|
QString jsonText = jsonFile.readAll();
|
||||||
jsonFile.close();
|
jsonFile.close();
|
||||||
|
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qCWarning(LOG_ESM) << "Json parse error" << error.errorString();
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jsonFilters = jsonDoc.toVariant().toMap();
|
jsonFilters = jsonDoc.toVariant().toMap();
|
||||||
|
|
||||||
qCDebug(LOG_ESM) << "Filters" << jsonFilters;
|
qCDebug(LOG_LIB) << "Filters" << jsonFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantHash ExtScript::run()
|
QVariantHash ExtScript::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
if (!isActive()) return value;
|
if (!isActive()) return value;
|
||||||
|
|
||||||
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
||||||
QStringList cmdList;
|
QStringList cmdList;
|
||||||
if (!m_prefix.isEmpty()) cmdList.append(m_prefix);
|
if (!m_prefix.isEmpty()) cmdList.append(m_prefix);
|
||||||
cmdList.append(m_executable);
|
cmdList.append(m_executable);
|
||||||
qCDebug(LOG_ESM) << "cmd" << cmdList.join(QChar(' '));
|
qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' '));
|
||||||
process->start(cmdList.join(QChar(' ')));
|
process->start(cmdList.join(QChar(' ')));
|
||||||
} else if (times >= interval())
|
} else if (times >= interval())
|
||||||
times = 0;
|
times = 0;
|
||||||
@ -327,7 +331,7 @@ QVariantHash ExtScript::run()
|
|||||||
int ExtScript::showConfiguration(const QVariant args)
|
int ExtScript::showConfiguration(const QVariant args)
|
||||||
{
|
{
|
||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->lineEdit_name->setText(name());
|
ui->lineEdit_name->setText(name());
|
||||||
ui->lineEdit_comment->setText(comment());
|
ui->lineEdit_comment->setText(comment());
|
||||||
@ -367,11 +371,11 @@ int ExtScript::showConfiguration(const QVariant args)
|
|||||||
|
|
||||||
void ExtScript::writeConfiguration() const
|
void ExtScript::writeConfiguration() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
settings.setValue(QString("Exec"), m_executable);
|
settings.setValue(QString("Exec"), m_executable);
|
||||||
@ -387,13 +391,13 @@ void ExtScript::writeConfiguration() const
|
|||||||
|
|
||||||
void ExtScript::updateValue()
|
void ExtScript::updateValue()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
qCDebug(LOG_ESM) << "Cmd returns" << process->exitCode();
|
qCInfo(LOG_LIB) << "Cmd returns" << process->exitCode();
|
||||||
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardError()).trimmed();
|
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardError()).trimmed();
|
||||||
qCDebug(LOG_ESM) << "Error" << qdebug;
|
qCInfo(LOG_LIB) << "Error" << qdebug;
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||||
qCDebug(LOG_ESM) << "Error" << qoutput;
|
qCInfo(LOG_LIB) << "Error" << qoutput;
|
||||||
QString strValue;
|
QString strValue;
|
||||||
|
|
||||||
switch (m_redirect) {
|
switch (m_redirect) {
|
||||||
@ -415,7 +419,7 @@ void ExtScript::updateValue()
|
|||||||
|
|
||||||
void ExtScript::translate()
|
void ExtScript::translate()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->label_name->setText(i18n("Name"));
|
ui->label_name->setText(i18n("Name"));
|
||||||
ui->label_comment->setText(i18n("Comment"));
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
@ -45,10 +45,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(),
|
explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(),
|
||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList());
|
||||||
const bool debugCmd = false);
|
virtual ~ExtScript();
|
||||||
~ExtScript();
|
ExtScript *copy(const QString _fileName, const int _number);
|
||||||
ExtScript *copy(const QString fileName, const int number);
|
|
||||||
// get methods
|
// get methods
|
||||||
QString executable() const;
|
QString executable() const;
|
||||||
QStringList filters() const;
|
QStringList filters() const;
|
||||||
|
@ -30,13 +30,11 @@
|
|||||||
|
|
||||||
|
|
||||||
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
|
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
|
||||||
const QStringList directories, const bool debugCmd)
|
const QStringList directories)
|
||||||
: AbstractExtItem(parent, upgradeName, directories, debugCmd),
|
: AbstractExtItem(parent, upgradeName, directories),
|
||||||
ui(new Ui::ExtUpgrade)
|
ui(new Ui::ExtUpgrade)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
|
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -52,7 +50,7 @@ ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
|
|||||||
|
|
||||||
ExtUpgrade::~ExtUpgrade()
|
ExtUpgrade::~ExtUpgrade()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
process->kill();
|
process->kill();
|
||||||
delete process;
|
delete process;
|
||||||
@ -60,12 +58,13 @@ ExtUpgrade::~ExtUpgrade()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtUpgrade *ExtUpgrade::copy(const QString fileName, const int number)
|
ExtUpgrade *ExtUpgrade::copy(const QString _fileName, const int _number)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), fileName,
|
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
directories(), LOG_ESM().isDebugEnabled());
|
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setComment(comment());
|
item->setComment(comment());
|
||||||
@ -73,7 +72,7 @@ ExtUpgrade *ExtUpgrade::copy(const QString fileName, const int number)
|
|||||||
item->setFilter(filter());
|
item->setFilter(filter());
|
||||||
item->setInterval(interval());
|
item->setInterval(interval());
|
||||||
item->setName(name());
|
item->setName(name());
|
||||||
item->setNumber(number);
|
item->setNumber(_number);
|
||||||
item->setNull(null());
|
item->setNull(null());
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@ -82,7 +81,7 @@ ExtUpgrade *ExtUpgrade::copy(const QString fileName, const int number)
|
|||||||
|
|
||||||
QString ExtUpgrade::executable() const
|
QString ExtUpgrade::executable() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_executable;
|
return m_executable;
|
||||||
}
|
}
|
||||||
@ -90,7 +89,7 @@ QString ExtUpgrade::executable() const
|
|||||||
|
|
||||||
QString ExtUpgrade::filter() const
|
QString ExtUpgrade::filter() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_filter;
|
return m_filter;
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ QString ExtUpgrade::filter() const
|
|||||||
|
|
||||||
int ExtUpgrade::null() const
|
int ExtUpgrade::null() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_null;
|
return m_null;
|
||||||
}
|
}
|
||||||
@ -106,7 +105,7 @@ int ExtUpgrade::null() const
|
|||||||
|
|
||||||
QString ExtUpgrade::uniq() const
|
QString ExtUpgrade::uniq() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_executable;
|
return m_executable;
|
||||||
}
|
}
|
||||||
@ -114,8 +113,8 @@ QString ExtUpgrade::uniq() const
|
|||||||
|
|
||||||
void ExtUpgrade::setExecutable(const QString _executable)
|
void ExtUpgrade::setExecutable(const QString _executable)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Executable" << _executable;
|
qCDebug(LOG_LIB) << "Executable" << _executable;
|
||||||
|
|
||||||
m_executable = _executable;
|
m_executable = _executable;
|
||||||
}
|
}
|
||||||
@ -123,8 +122,8 @@ void ExtUpgrade::setExecutable(const QString _executable)
|
|||||||
|
|
||||||
void ExtUpgrade::setFilter(const QString _filter)
|
void ExtUpgrade::setFilter(const QString _filter)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Filter" << _filter;
|
qCDebug(LOG_LIB) << "Filter" << _filter;
|
||||||
|
|
||||||
m_filter = _filter;
|
m_filter = _filter;
|
||||||
}
|
}
|
||||||
@ -132,8 +131,8 @@ void ExtUpgrade::setFilter(const QString _filter)
|
|||||||
|
|
||||||
void ExtUpgrade::setNull(const int _null)
|
void ExtUpgrade::setNull(const int _null)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Null lines" << _null;
|
qCDebug(LOG_LIB) << "Null lines" << _null;
|
||||||
if (_null < 0) return;
|
if (_null < 0) return;
|
||||||
|
|
||||||
m_null = _null;
|
m_null = _null;
|
||||||
@ -142,7 +141,7 @@ void ExtUpgrade::setNull(const int _null)
|
|||||||
|
|
||||||
void ExtUpgrade::readConfiguration()
|
void ExtUpgrade::readConfiguration()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
@ -159,6 +158,7 @@ void ExtUpgrade::readConfiguration()
|
|||||||
|
|
||||||
// update for current API
|
// update for current API
|
||||||
if ((apiVersion() > 0) && (apiVersion() < AWEUAPI)) {
|
if ((apiVersion() > 0) && (apiVersion() < AWEUAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEUAPI;
|
||||||
setApiVersion(AWEUAPI);
|
setApiVersion(AWEUAPI);
|
||||||
writeConfiguration();
|
writeConfiguration();
|
||||||
}
|
}
|
||||||
@ -167,12 +167,14 @@ void ExtUpgrade::readConfiguration()
|
|||||||
|
|
||||||
QVariantHash ExtUpgrade::run()
|
QVariantHash ExtUpgrade::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
if (!isActive()) return value;
|
if (!isActive()) return value;
|
||||||
|
|
||||||
if ((times == 1) && (process->state() == QProcess::NotRunning))
|
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
||||||
process->start(QString("sh -c \"%1\"").arg(m_executable));
|
QString cmd = QString("sh -c \"%1\"").arg(m_executable);
|
||||||
else if (times >= interval())
|
qCInfo(LOG_LIB) << "Run cmd" << cmd;
|
||||||
|
process->start(cmd);
|
||||||
|
} else if (times >= interval())
|
||||||
times = 0;
|
times = 0;
|
||||||
times++;
|
times++;
|
||||||
|
|
||||||
@ -183,7 +185,7 @@ QVariantHash ExtUpgrade::run()
|
|||||||
int ExtUpgrade::showConfiguration(const QVariant args)
|
int ExtUpgrade::showConfiguration(const QVariant args)
|
||||||
{
|
{
|
||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->lineEdit_name->setText(name());
|
ui->lineEdit_name->setText(name());
|
||||||
ui->lineEdit_comment->setText(comment());
|
ui->lineEdit_comment->setText(comment());
|
||||||
@ -213,11 +215,11 @@ int ExtUpgrade::showConfiguration(const QVariant args)
|
|||||||
|
|
||||||
void ExtUpgrade::writeConfiguration() const
|
void ExtUpgrade::writeConfiguration() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
settings.setValue(QString("Exec"), m_executable);
|
settings.setValue(QString("Exec"), m_executable);
|
||||||
@ -231,10 +233,10 @@ void ExtUpgrade::writeConfiguration() const
|
|||||||
|
|
||||||
void ExtUpgrade::updateValue()
|
void ExtUpgrade::updateValue()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
qCDebug(LOG_ESM) << "Cmd returns" << process->exitCode();
|
qCInfo(LOG_LIB) << "Cmd returns" << process->exitCode();
|
||||||
qCDebug(LOG_ESM) << "Error" << process->readAllStandardError();
|
qCInfo(LOG_LIB) << "Error" << process->readAllStandardError();
|
||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||||
value[tag(QString("pkgcount"))] = [this](QString output) {
|
value[tag(QString("pkgcount"))] = [this](QString output) {
|
||||||
@ -247,7 +249,7 @@ void ExtUpgrade::updateValue()
|
|||||||
|
|
||||||
void ExtUpgrade::translate()
|
void ExtUpgrade::translate()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->label_name->setText(i18n("Name"));
|
ui->label_name->setText(i18n("Name"));
|
||||||
ui->label_comment->setText(i18n("Comment"));
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
@ -36,10 +36,9 @@ class ExtUpgrade : public AbstractExtItem
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExtUpgrade(QWidget *parent = nullptr, const QString upgradeName = QString(),
|
explicit ExtUpgrade(QWidget *parent = nullptr, const QString upgradeName = QString(),
|
||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList());
|
||||||
const bool debugCmd = false);
|
virtual ~ExtUpgrade();
|
||||||
~ExtUpgrade();
|
ExtUpgrade *copy(const QString _fileName, const int _number);
|
||||||
ExtUpgrade *copy(const QString fileName, const int number);
|
|
||||||
// get methods
|
// get methods
|
||||||
QString executable() const;
|
QString executable() const;
|
||||||
QString filter() const;
|
QString filter() const;
|
||||||
|
@ -34,13 +34,11 @@
|
|||||||
|
|
||||||
|
|
||||||
ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
|
ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
|
||||||
const QStringList directories, const bool debugCmd)
|
const QStringList directories)
|
||||||
: AbstractExtItem(parent, weatherName, directories, debugCmd),
|
: AbstractExtItem(parent, weatherName, directories),
|
||||||
ui(new Ui::ExtWeather)
|
ui(new Ui::ExtWeather)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
|
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -60,7 +58,7 @@ ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
|
|||||||
|
|
||||||
ExtWeather::~ExtWeather()
|
ExtWeather::~ExtWeather()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)),
|
disconnect(manager, SIGNAL(finished(QNetworkReply *)),
|
||||||
this, SLOT(weatherReplyReceived(QNetworkReply *)));
|
this, SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||||
@ -70,12 +68,13 @@ ExtWeather::~ExtWeather()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtWeather *ExtWeather::copy(const QString fileName, const int number)
|
ExtWeather *ExtWeather::copy(const QString _fileName, const int _number)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), fileName,
|
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
directories(), LOG_ESM().isDebugEnabled());
|
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
item->setCity(city());
|
item->setCity(city());
|
||||||
@ -83,7 +82,7 @@ ExtWeather *ExtWeather::copy(const QString fileName, const int number)
|
|||||||
item->setCountry(country());
|
item->setCountry(country());
|
||||||
item->setInterval(interval());
|
item->setInterval(interval());
|
||||||
item->setName(name());
|
item->setName(name());
|
||||||
item->setNumber(number);
|
item->setNumber(_number);
|
||||||
item->setTs(ts());
|
item->setTs(ts());
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@ -92,8 +91,8 @@ ExtWeather *ExtWeather::copy(const QString fileName, const int number)
|
|||||||
|
|
||||||
QString ExtWeather::weatherFromInt(const int _id) const
|
QString ExtWeather::weatherFromInt(const int _id) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "ID" << _id;
|
qCDebug(LOG_LIB) << "ID" << _id;
|
||||||
// refer to http://openweathermap.org/weather-conditions
|
// refer to http://openweathermap.org/weather-conditions
|
||||||
|
|
||||||
QString weather;
|
QString weather;
|
||||||
@ -192,7 +191,7 @@ QString ExtWeather::weatherFromInt(const int _id) const
|
|||||||
|
|
||||||
QString ExtWeather::city() const
|
QString ExtWeather::city() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_city;
|
return m_city;
|
||||||
}
|
}
|
||||||
@ -200,7 +199,7 @@ QString ExtWeather::city() const
|
|||||||
|
|
||||||
QString ExtWeather::country() const
|
QString ExtWeather::country() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_country;
|
return m_country;
|
||||||
}
|
}
|
||||||
@ -208,7 +207,7 @@ QString ExtWeather::country() const
|
|||||||
|
|
||||||
int ExtWeather::ts() const
|
int ExtWeather::ts() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_ts;
|
return m_ts;
|
||||||
}
|
}
|
||||||
@ -216,7 +215,7 @@ int ExtWeather::ts() const
|
|||||||
|
|
||||||
QString ExtWeather::uniq() const
|
QString ExtWeather::uniq() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts);
|
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts);
|
||||||
}
|
}
|
||||||
@ -224,8 +223,8 @@ QString ExtWeather::uniq() const
|
|||||||
|
|
||||||
void ExtWeather::setCity(const QString _city)
|
void ExtWeather::setCity(const QString _city)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "City" << _city;
|
qCDebug(LOG_LIB) << "City" << _city;
|
||||||
|
|
||||||
m_city = _city;
|
m_city = _city;
|
||||||
}
|
}
|
||||||
@ -233,8 +232,8 @@ void ExtWeather::setCity(const QString _city)
|
|||||||
|
|
||||||
void ExtWeather::setCountry(const QString _country)
|
void ExtWeather::setCountry(const QString _country)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Country" << _country;
|
qCDebug(LOG_LIB) << "Country" << _country;
|
||||||
|
|
||||||
m_country = _country;
|
m_country = _country;
|
||||||
}
|
}
|
||||||
@ -242,8 +241,8 @@ void ExtWeather::setCountry(const QString _country)
|
|||||||
|
|
||||||
void ExtWeather::setTs(const int _ts)
|
void ExtWeather::setTs(const int _ts)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Timestamp" << _ts;
|
qCDebug(LOG_LIB) << "Timestamp" << _ts;
|
||||||
|
|
||||||
m_ts = _ts;
|
m_ts = _ts;
|
||||||
}
|
}
|
||||||
@ -251,7 +250,7 @@ void ExtWeather::setTs(const int _ts)
|
|||||||
|
|
||||||
void ExtWeather::readConfiguration()
|
void ExtWeather::readConfiguration()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
@ -267,6 +266,7 @@ void ExtWeather::readConfiguration()
|
|||||||
|
|
||||||
// update for current API
|
// update for current API
|
||||||
if ((apiVersion() > 0) && (apiVersion() < AWEWAPI)) {
|
if ((apiVersion() > 0) && (apiVersion() < AWEWAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEWAPI;
|
||||||
setApiVersion(AWEWAPI);
|
setApiVersion(AWEWAPI);
|
||||||
writeConfiguration();
|
writeConfiguration();
|
||||||
}
|
}
|
||||||
@ -275,11 +275,11 @@ void ExtWeather::readConfiguration()
|
|||||||
|
|
||||||
QVariantHash ExtWeather::run()
|
QVariantHash ExtWeather::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
if ((!isActive()) || (isRunning)) return values;
|
if ((!isActive()) || (isRunning)) return values;
|
||||||
|
|
||||||
if (times == 1) {
|
if (times == 1) {
|
||||||
qCDebug(LOG_ESM) << "Send request";
|
qCInfo(LOG_LIB) << "Send request";
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url(m_ts != 0))));
|
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url(m_ts != 0))));
|
||||||
new QReplyTimeout(reply, 1000);
|
new QReplyTimeout(reply, 1000);
|
||||||
@ -296,7 +296,7 @@ QVariantHash ExtWeather::run()
|
|||||||
int ExtWeather::showConfiguration(const QVariant args)
|
int ExtWeather::showConfiguration(const QVariant args)
|
||||||
{
|
{
|
||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->lineEdit_name->setText(name());
|
ui->lineEdit_name->setText(name());
|
||||||
ui->lineEdit_comment->setText(comment());
|
ui->lineEdit_comment->setText(comment());
|
||||||
@ -326,11 +326,11 @@ int ExtWeather::showConfiguration(const QVariant args)
|
|||||||
|
|
||||||
void ExtWeather::writeConfiguration() const
|
void ExtWeather::writeConfiguration() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
settings.setValue(QString("X-AW-City"), m_city);
|
settings.setValue(QString("X-AW-City"), m_city);
|
||||||
@ -344,9 +344,9 @@ void ExtWeather::writeConfiguration() const
|
|||||||
|
|
||||||
void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Return code" << reply->error();
|
qCDebug(LOG_LIB) << "Return code" << reply->error();
|
||||||
qCDebug(LOG_ESM) << "Reply error message" << reply->errorString();
|
qCDebug(LOG_LIB) << "Reply error message" << reply->errorString();
|
||||||
|
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
@ -354,14 +354,14 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
|||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
if ((reply->error() != QNetworkReply::NoError) ||
|
if ((reply->error() != QNetworkReply::NoError) ||
|
||||||
(error.error != QJsonParseError::NoError)) {
|
(error.error != QJsonParseError::NoError)) {
|
||||||
qCWarning(LOG_ESM) << "Parse error" << error.errorString();
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to map
|
// convert to map
|
||||||
QVariantMap json = jsonDoc.toVariant().toMap();
|
QVariantMap json = jsonDoc.toVariant().toMap();
|
||||||
if (json[QString("cod")].toInt() != 200) {
|
if (json[QString("cod")].toInt() != 200) {
|
||||||
qCWarning(LOG_ESM) << "Invalid return code";
|
qCWarning(LOG_LIB) << "Invalid return code";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,8 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
|||||||
|
|
||||||
QVariantHash ExtWeather::parseSingleJson(const QVariantMap json) const
|
QVariantHash ExtWeather::parseSingleJson(const QVariantMap json) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Single json data" << json;
|
||||||
|
|
||||||
QVariantHash output;
|
QVariantHash output;
|
||||||
|
|
||||||
@ -404,7 +405,7 @@ QVariantHash ExtWeather::parseSingleJson(const QVariantMap json) const
|
|||||||
|
|
||||||
void ExtWeather::translate()
|
void ExtWeather::translate()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->label_name->setText(i18n("Name"));
|
ui->label_name->setText(i18n("Name"));
|
||||||
ui->label_comment->setText(i18n("Comment"));
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
@ -419,13 +420,13 @@ void ExtWeather::translate()
|
|||||||
|
|
||||||
QString ExtWeather::url(const bool isForecast) const
|
QString ExtWeather::url(const bool isForecast) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Is forecast" << isForecast;
|
qCDebug(LOG_LIB) << "Is forecast" << isForecast;
|
||||||
|
|
||||||
QString apiUrl = isForecast ? QString(OWM_FORECAST_URL) : QString(OWM_URL);
|
QString apiUrl = isForecast ? QString(OWM_FORECAST_URL) : QString(OWM_URL);
|
||||||
apiUrl.replace(QString("$CITY"), m_city);
|
apiUrl.replace(QString("$CITY"), m_city);
|
||||||
apiUrl.replace(QString("$COUNTRY"), m_country);
|
apiUrl.replace(QString("$COUNTRY"), m_country);
|
||||||
qCDebug(LOG_ESM) << "API url" << apiUrl;
|
qCInfo(LOG_LIB) << "API url" << apiUrl;
|
||||||
|
|
||||||
return apiUrl;
|
return apiUrl;
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,9 @@ class ExtWeather : public AbstractExtItem
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExtWeather(QWidget *parent = nullptr, const QString weatherName = QString(),
|
explicit ExtWeather(QWidget *parent = nullptr, const QString weatherName = QString(),
|
||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList());
|
||||||
const bool debugCmd = false);
|
virtual ~ExtWeather();
|
||||||
~ExtWeather();
|
ExtWeather *copy(const QString _fileName, const int _number);
|
||||||
ExtWeather *copy(const QString fileName, const int number);
|
|
||||||
QString weatherFromInt(const int _id) const;
|
QString weatherFromInt(const int _id) const;
|
||||||
// get methods
|
// get methods
|
||||||
QString city() const;
|
QString city() const;
|
||||||
|
@ -33,13 +33,11 @@
|
|||||||
|
|
||||||
|
|
||||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
|
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
|
||||||
const QStringList directories, const bool debugCmd)
|
const QStringList directories)
|
||||||
: AbstractExtItem(parent, desktopName, directories, debugCmd),
|
: AbstractExtItem(parent, desktopName, directories),
|
||||||
ui(new Ui::GraphicalItem)
|
ui(new Ui::GraphicalItem)
|
||||||
{
|
{
|
||||||
// logging
|
qCDebug(LOG_LIB);
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
|
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
|
||||||
|
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -52,18 +50,19 @@ GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
|
|||||||
|
|
||||||
GraphicalItem::~GraphicalItem()
|
GraphicalItem::~GraphicalItem()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GraphicalItem *GraphicalItem::copy(const QString fileName, const int number)
|
GraphicalItem *GraphicalItem::copy(const QString _fileName, const int _number)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()),
|
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
fileName, directories(), LOG_ESM().isDebugEnabled());
|
|
||||||
item->setActive(isActive());
|
item->setActive(isActive());
|
||||||
item->setActiveColor(activeColor());
|
item->setActiveColor(activeColor());
|
||||||
item->setApiVersion(apiVersion());
|
item->setApiVersion(apiVersion());
|
||||||
@ -73,8 +72,8 @@ GraphicalItem *GraphicalItem::copy(const QString fileName, const int number)
|
|||||||
item->setHeight(height());
|
item->setHeight(height());
|
||||||
item->setInactiveColor(inactiveColor());
|
item->setInactiveColor(inactiveColor());
|
||||||
item->setInterval(interval());
|
item->setInterval(interval());
|
||||||
item->setName(QString("bar%1").arg(number));
|
item->setName(QString("bar%1").arg(_number));
|
||||||
item->setNumber(number);
|
item->setNumber(_number);
|
||||||
item->setType(type());
|
item->setType(type());
|
||||||
item->setWidth(width());
|
item->setWidth(width());
|
||||||
|
|
||||||
@ -84,8 +83,8 @@ GraphicalItem *GraphicalItem::copy(const QString fileName, const int number)
|
|||||||
|
|
||||||
QString GraphicalItem::image(const float value) const
|
QString GraphicalItem::image(const float value) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Value" << value;
|
qCDebug(LOG_LIB) << "Value" << value;
|
||||||
if (m_bar == QString("none")) return QString("");
|
if (m_bar == QString("none")) return QString("");
|
||||||
|
|
||||||
QColor active = stringToColor(m_activeColor);
|
QColor active = stringToColor(m_activeColor);
|
||||||
@ -164,7 +163,7 @@ QString GraphicalItem::image(const float value) const
|
|||||||
|
|
||||||
QString GraphicalItem::bar() const
|
QString GraphicalItem::bar() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_bar;
|
return m_bar;
|
||||||
}
|
}
|
||||||
@ -172,7 +171,7 @@ QString GraphicalItem::bar() const
|
|||||||
|
|
||||||
QString GraphicalItem::activeColor() const
|
QString GraphicalItem::activeColor() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_activeColor;
|
return m_activeColor;
|
||||||
}
|
}
|
||||||
@ -180,7 +179,7 @@ QString GraphicalItem::activeColor() const
|
|||||||
|
|
||||||
QString GraphicalItem::inactiveColor() const
|
QString GraphicalItem::inactiveColor() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_inactiveColor;
|
return m_inactiveColor;
|
||||||
}
|
}
|
||||||
@ -188,7 +187,7 @@ QString GraphicalItem::inactiveColor() const
|
|||||||
|
|
||||||
QString GraphicalItem::tag() const
|
QString GraphicalItem::tag() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return name() + m_bar;
|
return name() + m_bar;
|
||||||
}
|
}
|
||||||
@ -196,7 +195,7 @@ QString GraphicalItem::tag() const
|
|||||||
|
|
||||||
GraphicalItem::Type GraphicalItem::type() const
|
GraphicalItem::Type GraphicalItem::type() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
@ -204,7 +203,7 @@ GraphicalItem::Type GraphicalItem::type() const
|
|||||||
|
|
||||||
QString GraphicalItem::strType() const
|
QString GraphicalItem::strType() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
@ -225,7 +224,7 @@ QString GraphicalItem::strType() const
|
|||||||
|
|
||||||
GraphicalItem::Direction GraphicalItem::direction() const
|
GraphicalItem::Direction GraphicalItem::direction() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_direction;
|
return m_direction;
|
||||||
}
|
}
|
||||||
@ -233,7 +232,7 @@ GraphicalItem::Direction GraphicalItem::direction() const
|
|||||||
|
|
||||||
QString GraphicalItem::strDirection() const
|
QString GraphicalItem::strDirection() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
switch (m_direction) {
|
switch (m_direction) {
|
||||||
@ -251,7 +250,7 @@ QString GraphicalItem::strDirection() const
|
|||||||
|
|
||||||
int GraphicalItem::height() const
|
int GraphicalItem::height() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_height;
|
return m_height;
|
||||||
}
|
}
|
||||||
@ -259,7 +258,7 @@ int GraphicalItem::height() const
|
|||||||
|
|
||||||
int GraphicalItem::width() const
|
int GraphicalItem::width() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_width;
|
return m_width;
|
||||||
}
|
}
|
||||||
@ -267,7 +266,7 @@ int GraphicalItem::width() const
|
|||||||
|
|
||||||
QString GraphicalItem::uniq() const
|
QString GraphicalItem::uniq() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_bar;
|
return m_bar;
|
||||||
}
|
}
|
||||||
@ -275,25 +274,21 @@ QString GraphicalItem::uniq() const
|
|||||||
|
|
||||||
void GraphicalItem::setBar(const QString _bar)
|
void GraphicalItem::setBar(const QString _bar)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Bar" << _bar;
|
qCDebug(LOG_LIB) << "Bar" << _bar;
|
||||||
|
|
||||||
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
|
if (!_bar.contains(QRegExp(QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")))) {
|
||||||
(!_bar.contains(QRegExp(QString("gpu")))) &&
|
qCWarning(LOG_LIB) << "Unsupported bar type" << _bar;
|
||||||
(!_bar.contains(QRegExp(QString("mem")))) &&
|
|
||||||
(!_bar.contains(QRegExp(QString("swap")))) &&
|
|
||||||
(!_bar.contains(QRegExp(QString("hdd[0-9].*")))) &&
|
|
||||||
(!_bar.contains(QRegExp(QString("bat.*")))))
|
|
||||||
m_bar = QString("none");
|
m_bar = QString("none");
|
||||||
else
|
} else
|
||||||
m_bar = _bar;
|
m_bar = _bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItem::setActiveColor(const QString _color)
|
void GraphicalItem::setActiveColor(const QString _color)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Color" << _color;
|
qCDebug(LOG_LIB) << "Color" << _color;
|
||||||
|
|
||||||
m_activeColor = _color;
|
m_activeColor = _color;
|
||||||
}
|
}
|
||||||
@ -301,8 +296,8 @@ void GraphicalItem::setActiveColor(const QString _color)
|
|||||||
|
|
||||||
void GraphicalItem::setInactiveColor(const QString _color)
|
void GraphicalItem::setInactiveColor(const QString _color)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Color" << _color;
|
qCDebug(LOG_LIB) << "Color" << _color;
|
||||||
|
|
||||||
m_inactiveColor = _color;
|
m_inactiveColor = _color;
|
||||||
}
|
}
|
||||||
@ -310,8 +305,8 @@ void GraphicalItem::setInactiveColor(const QString _color)
|
|||||||
|
|
||||||
void GraphicalItem::setType(const Type _type)
|
void GraphicalItem::setType(const Type _type)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Type" << _type;
|
qCDebug(LOG_LIB) << "Type" << _type;
|
||||||
|
|
||||||
m_type = _type;
|
m_type = _type;
|
||||||
}
|
}
|
||||||
@ -319,8 +314,8 @@ void GraphicalItem::setType(const Type _type)
|
|||||||
|
|
||||||
void GraphicalItem::setStrType(const QString _type)
|
void GraphicalItem::setStrType(const QString _type)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Type" << _type;
|
qCDebug(LOG_LIB) << "Type" << _type;
|
||||||
|
|
||||||
if (_type == QString("Vertical"))
|
if (_type == QString("Vertical"))
|
||||||
setType(Vertical);
|
setType(Vertical);
|
||||||
@ -333,8 +328,8 @@ void GraphicalItem::setStrType(const QString _type)
|
|||||||
|
|
||||||
void GraphicalItem::setDirection(const Direction _direction)
|
void GraphicalItem::setDirection(const Direction _direction)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Direction" << _direction;
|
qCDebug(LOG_LIB) << "Direction" << _direction;
|
||||||
|
|
||||||
m_direction = _direction;
|
m_direction = _direction;
|
||||||
}
|
}
|
||||||
@ -342,8 +337,8 @@ void GraphicalItem::setDirection(const Direction _direction)
|
|||||||
|
|
||||||
void GraphicalItem::setStrDirection(const QString _direction)
|
void GraphicalItem::setStrDirection(const QString _direction)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Direction" << _direction;
|
qCDebug(LOG_LIB) << "Direction" << _direction;
|
||||||
|
|
||||||
if (_direction == QString("RightToLeft"))
|
if (_direction == QString("RightToLeft"))
|
||||||
setDirection(RightToLeft);
|
setDirection(RightToLeft);
|
||||||
@ -354,8 +349,8 @@ void GraphicalItem::setStrDirection(const QString _direction)
|
|||||||
|
|
||||||
void GraphicalItem::setHeight(const int _height)
|
void GraphicalItem::setHeight(const int _height)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Height" << _height;
|
qCDebug(LOG_LIB) << "Height" << _height;
|
||||||
if (_height <= 0) return;
|
if (_height <= 0) return;
|
||||||
|
|
||||||
m_height = _height;
|
m_height = _height;
|
||||||
@ -364,8 +359,8 @@ void GraphicalItem::setHeight(const int _height)
|
|||||||
|
|
||||||
void GraphicalItem::setWidth(const int _width)
|
void GraphicalItem::setWidth(const int _width)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Width" << _width;
|
qCDebug(LOG_LIB) << "Width" << _width;
|
||||||
if (_width <= 0) return;
|
if (_width <= 0) return;
|
||||||
|
|
||||||
m_width = _width;
|
m_width = _width;
|
||||||
@ -374,7 +369,7 @@ void GraphicalItem::setWidth(const int _width)
|
|||||||
|
|
||||||
void GraphicalItem::readConfiguration()
|
void GraphicalItem::readConfiguration()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=directories().count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
@ -396,6 +391,7 @@ void GraphicalItem::readConfiguration()
|
|||||||
|
|
||||||
// update for current API
|
// update for current API
|
||||||
if ((apiVersion() > 0) && (apiVersion() < AWGIAPI)) {
|
if ((apiVersion() > 0) && (apiVersion() < AWGIAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWGIAPI;
|
||||||
setApiVersion(AWGIAPI);
|
setApiVersion(AWGIAPI);
|
||||||
writeConfiguration();
|
writeConfiguration();
|
||||||
}
|
}
|
||||||
@ -404,7 +400,7 @@ void GraphicalItem::readConfiguration()
|
|||||||
|
|
||||||
QVariantHash GraphicalItem::run()
|
QVariantHash GraphicalItem::run()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
// required by abstract class
|
// required by abstract class
|
||||||
return QVariantHash();
|
return QVariantHash();
|
||||||
@ -413,7 +409,8 @@ QVariantHash GraphicalItem::run()
|
|||||||
|
|
||||||
int GraphicalItem::showConfiguration(const QVariant args)
|
int GraphicalItem::showConfiguration(const QVariant args)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Combobox arguments" << args;
|
||||||
QStringList tags = args.toStringList();
|
QStringList tags = args.toStringList();
|
||||||
|
|
||||||
ui->label_nameValue->setText(name());
|
ui->label_nameValue->setText(name());
|
||||||
@ -449,11 +446,11 @@ int GraphicalItem::showConfiguration(const QVariant args)
|
|||||||
|
|
||||||
void GraphicalItem::writeConfiguration() const
|
void GraphicalItem::writeConfiguration() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
settings.setValue(QString("X-AW-Value"), m_bar);
|
settings.setValue(QString("X-AW-Value"), m_bar);
|
||||||
@ -471,12 +468,13 @@ void GraphicalItem::writeConfiguration() const
|
|||||||
|
|
||||||
void GraphicalItem::changeColor()
|
void GraphicalItem::changeColor()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
|
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
|
||||||
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
|
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
|
||||||
QColorDialog::ShowAlphaChannel);
|
QColorDialog::ShowAlphaChannel);
|
||||||
if (!newColor.isValid()) return;
|
if (!newColor.isValid()) return;
|
||||||
|
qCInfo(LOG_LIB) << "Selected color" << newColor;
|
||||||
|
|
||||||
QStringList colorText;
|
QStringList colorText;
|
||||||
colorText.append(QString("%1").arg(newColor.red()));
|
colorText.append(QString("%1").arg(newColor.red()));
|
||||||
@ -490,8 +488,8 @@ void GraphicalItem::changeColor()
|
|||||||
|
|
||||||
QColor GraphicalItem::stringToColor(const QString _color) const
|
QColor GraphicalItem::stringToColor(const QString _color) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
qCDebug(LOG_ESM) << "Color" << _color;
|
qCDebug(LOG_LIB) << "Color" << _color;
|
||||||
|
|
||||||
QColor qcolor;
|
QColor qcolor;
|
||||||
QStringList listColor = _color.split(QChar(','));
|
QStringList listColor = _color.split(QChar(','));
|
||||||
@ -508,7 +506,7 @@ QColor GraphicalItem::stringToColor(const QString _color) const
|
|||||||
|
|
||||||
void GraphicalItem::translate()
|
void GraphicalItem::translate()
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->label_name->setText(i18n("Name"));
|
ui->label_name->setText(i18n("Name"));
|
||||||
ui->label_comment->setText(i18n("Comment"));
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
@ -50,10 +50,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||||
const QStringList directories = QStringList(),
|
const QStringList directories = QStringList());
|
||||||
const bool debugCmd = false);
|
virtual ~GraphicalItem();
|
||||||
~GraphicalItem();
|
GraphicalItem *copy(const QString _fileName, const int _number);
|
||||||
GraphicalItem *copy(const QString fileName, const int number);
|
|
||||||
QString image(const float value) const;
|
QString image(const float value) const;
|
||||||
// get methods
|
// get methods
|
||||||
QString bar() const;
|
QString bar() const;
|
||||||
|
@ -111,6 +111,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ Item {
|
|||||||
width: parent.width * 2 / 3
|
width: parent.width * 2 / 3
|
||||||
text: plasmoid.configuration.currentFontFamily
|
text: plasmoid.configuration.currentFontFamily
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (debug) console.debug()
|
||||||
fontDialog.setFont()
|
fontDialog.setFont()
|
||||||
fontDialog.visible = true
|
fontDialog.visible = true
|
||||||
}
|
}
|
||||||
@ -133,8 +134,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_currentFontWeight = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_currentFontWeight = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.currentFontWeight) {
|
if (model[i]["name"] == plasmoid.configuration.currentFontWeight) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontWeight.currentIndex = i;
|
fontWeight.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,8 +171,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_currentFontStyle = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_currentFontStyle = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.currentFontStyle) {
|
if (model[i]["name"] == plasmoid.configuration.currentFontStyle) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontStyle.currentIndex = i;
|
fontStyle.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,12 +219,14 @@ Item {
|
|||||||
signal setFont
|
signal setFont
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
if (debug) console.debug()
|
||||||
selectFont.text = fontDialog.font.family
|
selectFont.text = fontDialog.font.family
|
||||||
fontSize.value = fontDialog.font.pointSize
|
fontSize.value = fontDialog.font.pointSize
|
||||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
onSetFont: {
|
onSetFont: {
|
||||||
|
if (debug) console.debug()
|
||||||
fontDialog.font = Qt.font({
|
fontDialog.font = Qt.font({
|
||||||
family: selectFont.text,
|
family: selectFont.text,
|
||||||
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||||
@ -230,6 +237,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_tooltipType = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_tooltipType = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.tooltipType) {
|
if (model[i]["name"] == plasmoid.configuration.tooltipType) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
tooltipType.currentIndex = i;
|
tooltipType.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,6 +257,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ Item {
|
|||||||
width: parent.width * 2 / 3
|
width: parent.width * 2 / 3
|
||||||
text: plasmoid.configuration.fontFamily
|
text: plasmoid.configuration.fontFamily
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (debug) console.debug()
|
||||||
fontDialog.setFont()
|
fontDialog.setFont()
|
||||||
fontDialog.visible = true
|
fontDialog.visible = true
|
||||||
}
|
}
|
||||||
@ -133,8 +134,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontWeight.currentIndex = i;
|
fontWeight.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,8 +171,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontStyle.currentIndex = i;
|
fontStyle.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,12 +219,14 @@ Item {
|
|||||||
signal setFont
|
signal setFont
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
if (debug) console.debug()
|
||||||
selectFont.text = fontDialog.font.family
|
selectFont.text = fontDialog.font.family
|
||||||
fontSize.value = fontDialog.font.pointSize
|
fontSize.value = fontDialog.font.pointSize
|
||||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
onSetFont: {
|
onSetFont: {
|
||||||
|
if (debug) console.debug()
|
||||||
fontDialog.font = Qt.font({
|
fontDialog.font = Qt.font({
|
||||||
family: selectFont.text,
|
family: selectFont.text,
|
||||||
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||||
@ -230,6 +237,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,11 +108,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNeedUpdate: {
|
onNeedUpdate: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
for (var i=0; i<repeater.count; i++) {
|
for (var i=0; i<repeater.count; i++) {
|
||||||
if (!repeater.itemAt(i)) {
|
if (!repeater.itemAt(i)) {
|
||||||
if (debug) console.log("Nothing to do here " + i)
|
if (debug) console.info("Nothing to do here", i)
|
||||||
timer.start()
|
timer.start()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNeedTooltipUpdate: {
|
onNeedTooltipUpdate: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
for (var i=0; i<repeater.count; i++) {
|
for (var i=0; i<repeater.count; i++) {
|
||||||
repeater.itemAt(i).tooltip.text = dpAdds.toolTipImage(i + 1)
|
repeater.itemAt(i).tooltip.text = dpAdds.toolTipImage(i + 1)
|
||||||
@ -146,7 +146,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSizeUpdate: {
|
onSizeUpdate: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
if (plasmoid.configuration.height == 0) {
|
if (plasmoid.configuration.height == 0) {
|
||||||
var newHeight = 0
|
var newHeight = 0
|
||||||
@ -171,14 +171,14 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Plasmoid.onActivated: {
|
Plasmoid.onActivated: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// dpAdds.changePanelsState()
|
// dpAdds.changePanelsState()
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasmoid.onUserConfiguringChanged: {
|
Plasmoid.onUserConfiguringChanged: {
|
||||||
if (plasmoid.userConfiguring) return
|
if (plasmoid.userConfiguring) return
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
dpAdds.setMark(plasmoid.configuration.mark)
|
dpAdds.setMark(plasmoid.configuration.mark)
|
||||||
dpAdds.setPanelsToControl(plasmoid.configuration.panels)
|
dpAdds.setPanelsToControl(plasmoid.configuration.panels)
|
||||||
@ -188,7 +188,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
Plasmoid.userConfiguringChanged(false)
|
Plasmoid.userConfiguringChanged(false)
|
||||||
|
@ -59,8 +59,7 @@ Item {
|
|||||||
iconName: "font"
|
iconName: "font"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Font button")
|
if (debug) console.debug("Font button")
|
||||||
|
|
||||||
var defaultFont = {
|
var defaultFont = {
|
||||||
"color": plasmoid.configuration.fontColor,
|
"color": plasmoid.configuration.fontColor,
|
||||||
"family": plasmoid.configuration.fontFamily,
|
"family": plasmoid.configuration.fontFamily,
|
||||||
@ -81,8 +80,7 @@ Item {
|
|||||||
iconName: "format-indent-more"
|
iconName: "format-indent-more"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Indent button")
|
if (debug) console.debug("Indent button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -95,8 +93,7 @@ Item {
|
|||||||
iconName: "format-text-bold"
|
iconName: "format-text-bold"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Bold button")
|
if (debug) console.debug("Bold button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -108,8 +105,7 @@ Item {
|
|||||||
iconName: "format-text-italic"
|
iconName: "format-text-italic"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Italic button")
|
if (debug) console.debug("Italic button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -121,8 +117,7 @@ Item {
|
|||||||
iconName: "format-text-underline"
|
iconName: "format-text-underline"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Underline button")
|
if (debug) console.debug("Underline button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -134,8 +129,7 @@ Item {
|
|||||||
iconName: "format-text-strikethrough"
|
iconName: "format-text-strikethrough"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Strike button")
|
if (debug) console.debug("Strike button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -148,8 +142,7 @@ Item {
|
|||||||
iconName: "format-justify-left"
|
iconName: "format-justify-left"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Left button")
|
if (debug) console.debug("Left button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -161,8 +154,7 @@ Item {
|
|||||||
iconName: "format-justify-center"
|
iconName: "format-justify-center"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Center button")
|
if (debug) console.debug("Center button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -174,8 +166,7 @@ Item {
|
|||||||
iconName: "format-justify-right"
|
iconName: "format-justify-right"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Right button")
|
if (debug) console.debug("Right button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -187,8 +178,7 @@ Item {
|
|||||||
iconName: "format-justify-fill"
|
iconName: "format-justify-fill"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Justify button")
|
if (debug) console.debug("Justify button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -210,8 +200,7 @@ Item {
|
|||||||
text: i18n("Add")
|
text: i18n("Add")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Add tag button")
|
if (debug) console.debug("Add tag button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -223,8 +212,7 @@ Item {
|
|||||||
text: i18n("Show value")
|
text: i18n("Show value")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("Show tag button")
|
if (debug) console.debug("Show tag button")
|
||||||
|
|
||||||
var message = i18n("Tag: %1", tags.currentText)
|
var message = i18n("Tag: %1", tags.currentText)
|
||||||
message += "<br>"
|
message += "<br>"
|
||||||
message += i18n("Value: %1", dpAdds.valueByKey(tags.currentText))
|
message += i18n("Value: %1", dpAdds.valueByKey(tags.currentText))
|
||||||
@ -244,6 +232,6 @@ Item {
|
|||||||
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QProcessEnvironment>
|
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
|
||||||
#include <fontdialog/fontdialog.h>
|
#include <fontdialog/fontdialog.h>
|
||||||
@ -41,13 +40,12 @@
|
|||||||
DPAdds::DPAdds(QObject *parent)
|
DPAdds::DPAdds(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
// debug
|
qCDebug(LOG_DP);
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
|
||||||
bool debug = (debugEnv == QString("yes"));
|
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
const_cast<QLoggingCategory &>(LOG_DP()).setEnabled(QtMsgType::QtDebugMsg, debug);
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
const_cast<QLoggingCategory &>(LOG_DP()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||||
|
#endif /* QT_VERSION */
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
qSetMessagePattern(LOG_FORMAT);
|
||||||
|
|
||||||
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SIGNAL(desktopChanged()));
|
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SIGNAL(desktopChanged()));
|
||||||
@ -110,7 +108,8 @@ QString DPAdds::toolTipImage(const int desktop) const
|
|||||||
DesktopWindowsInfo info = getInfoByDesktop(desktop);
|
DesktopWindowsInfo info = getInfoByDesktop(desktop);
|
||||||
if (tooltipType == QString("names")) {
|
if (tooltipType == QString("names")) {
|
||||||
QStringList windowList;
|
QStringList windowList;
|
||||||
foreach(WindowData data, info.windowsData) windowList.append(data.name);
|
std::for_each(info.windowsData.cbegin(), info.windowsData.cend(),
|
||||||
|
[&windowList](WindowData data) { windowList.append(data.name); });
|
||||||
return QString("<ul><li>%1</li></ul>").arg(windowList.join(QString("</li><li>")));
|
return QString("<ul><li>%1</li></ul>").arg(windowList.join(QString("</li><li>")));
|
||||||
}
|
}
|
||||||
// init
|
// init
|
||||||
@ -151,20 +150,23 @@ QString DPAdds::toolTipImage(const int desktop) const
|
|||||||
}
|
}
|
||||||
} else if (tooltipType == QString("clean")) {
|
} else if (tooltipType == QString("clean")) {
|
||||||
QScreen *screen = QGuiApplication::primaryScreen();
|
QScreen *screen = QGuiApplication::primaryScreen();
|
||||||
foreach(WindowData data, info.desktopsData) {
|
std::for_each(info.desktopsData.cbegin(), info.desktopsData.cend(),
|
||||||
|
[&toolTipScene, &screen](WindowData data) {
|
||||||
QPixmap desktop = screen->grabWindow(data.id);
|
QPixmap desktop = screen->grabWindow(data.id);
|
||||||
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
||||||
}
|
});
|
||||||
} else if (tooltipType == QString("windows")) {
|
} else if (tooltipType == QString("windows")) {
|
||||||
QScreen *screen = QGuiApplication::primaryScreen();
|
QScreen *screen = QGuiApplication::primaryScreen();
|
||||||
foreach(WindowData data, info.desktopsData) {
|
std::for_each(info.desktopsData.cbegin(), info.desktopsData.cend(),
|
||||||
|
[&toolTipScene, &screen](WindowData data) {
|
||||||
QPixmap desktop = screen->grabWindow(data.id);
|
QPixmap desktop = screen->grabWindow(data.id);
|
||||||
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
toolTipScene->addPixmap(desktop)->setOffset(data.rect.left(), data.rect.top());
|
||||||
}
|
});
|
||||||
foreach(WindowData data, info.windowsData) {
|
std::for_each(info.windowsData.cbegin(), info.windowsData.cend(),
|
||||||
|
[&toolTipScene, &screen](WindowData data) {
|
||||||
QPixmap window = screen->grabWindow(data.id);
|
QPixmap window = screen->grabWindow(data.id);
|
||||||
toolTipScene->addPixmap(window)->setOffset(data.rect.left(), data.rect.top());
|
toolTipScene->addPixmap(window)->setOffset(data.rect.left(), data.rect.top());
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap image = toolTipView->grab().scaledToWidth(tooltipWidth);
|
QPixmap image = toolTipView->grab().scaledToWidth(tooltipWidth);
|
||||||
@ -182,6 +184,8 @@ QString DPAdds::toolTipImage(const int desktop) const
|
|||||||
QString DPAdds::parsePattern(const QString pattern, const int desktop) const
|
QString DPAdds::parsePattern(const QString pattern, const int desktop) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_DP);
|
qCDebug(LOG_DP);
|
||||||
|
qCDebug(LOG_DP) << "Pattern" << pattern;
|
||||||
|
qCDebug(LOG_DP) << "Desktop number" << desktop;
|
||||||
|
|
||||||
QString parsed = pattern;
|
QString parsed = pattern;
|
||||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
@ -233,6 +237,7 @@ QString DPAdds::valueByKey(const QString key, int desktop) const
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_DP);
|
qCDebug(LOG_DP);
|
||||||
qCDebug(LOG_DP) << "Requested key" << key;
|
qCDebug(LOG_DP) << "Requested key" << key;
|
||||||
|
qCDebug(LOG_DP) << "Desktop number" << desktop;
|
||||||
if (desktop == -1) desktop = currentDesktop();
|
if (desktop == -1) desktop = currentDesktop();
|
||||||
|
|
||||||
QString currentMark = currentDesktop() == desktop ? mark : QString("");
|
QString currentMark = currentDesktop() == desktop ? mark : QString("");
|
||||||
@ -253,6 +258,7 @@ QString DPAdds::valueByKey(const QString key, int desktop) const
|
|||||||
QString DPAdds::editPanelsToContol(const QString current)
|
QString DPAdds::editPanelsToContol(const QString current)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_DP);
|
qCDebug(LOG_DP);
|
||||||
|
qCDebug(LOG_DP) << "Current panels" << current;
|
||||||
|
|
||||||
// paint
|
// paint
|
||||||
QDialog *dialog = new QDialog(nullptr);
|
QDialog *dialog = new QDialog(nullptr);
|
||||||
@ -342,6 +348,7 @@ QString DPAdds::getAboutText(const QString type) const
|
|||||||
QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
|
QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_DP);
|
qCDebug(LOG_DP);
|
||||||
|
qCDebug(LOG_DP) << "Default font is" << defaultFont;
|
||||||
|
|
||||||
QVariantMap fontMap;
|
QVariantMap fontMap;
|
||||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||||
@ -466,6 +473,7 @@ QString DPAdds::panelLocationToStr(Plasma::Types::Location location) const
|
|||||||
case Plasma::Types::Location::RightEdge:
|
case Plasma::Types::Location::RightEdge:
|
||||||
return i18n("Right Edge");
|
return i18n("Right Edge");
|
||||||
default:
|
default:
|
||||||
|
qCWarning(LOG_DP) << "Unknown location" << location;
|
||||||
return i18n("Unknown location (%1)", location);
|
return i18n("Unknown location (%1)", location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@ class DPAdds : public QObject
|
|||||||
} DesktopWindowsInfo;
|
} DesktopWindowsInfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DPAdds(QObject *parent = nullptr);
|
explicit DPAdds(QObject *parent = nullptr);
|
||||||
~DPAdds();
|
virtual ~DPAdds();
|
||||||
|
|
||||||
Q_INVOKABLE bool isDebugEnabled() const;
|
Q_INVOKABLE bool isDebugEnabled() const;
|
||||||
Q_INVOKABLE int currentDesktop() const;
|
Q_INVOKABLE int currentDesktop() const;
|
||||||
|
@ -19,6 +19,7 @@ file(RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_I
|
|||||||
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
||||||
set(TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
set(TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||||
file(GLOB SUBPROJECT_CONF *.conf)
|
file(GLOB SUBPROJECT_CONF *.conf)
|
||||||
|
file(GLOB SUBPROJECT_INI *.ini)
|
||||||
|
|
||||||
# prepare
|
# prepare
|
||||||
configure_file(${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
configure_file(${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||||
@ -34,3 +35,4 @@ kcoreaddons_desktop_to_json(${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJ
|
|||||||
install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/dataengine)
|
install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/dataengine)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||||
install(FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
install(FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
||||||
|
install(FILES ${SUBPROJECT_INI} DESTINATION ${CONFIG_INSTALL_DIR})
|
||||||
|
17
sources/extsysmon/awesome-widgets-logging.ini
Normal file
17
sources/extsysmon/awesome-widgets-logging.ini
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[Rules]
|
||||||
|
org.kde.plasma.awesomewidget.debug=true
|
||||||
|
org.kde.plasma.awesomewidget.info=true
|
||||||
|
org.kde.plasma.awesomewidget.warning=true
|
||||||
|
org.kde.plasma.awesomewidget.critical=true
|
||||||
|
org.kde.plasma.desktoppanel.debug=true
|
||||||
|
org.kde.plasma.desktoppanel.info=true
|
||||||
|
org.kde.plasma.desktoppanel.warning=true
|
||||||
|
org.kde.plasma.desktoppanel.critical=true
|
||||||
|
org.kde.plasma.extsysmon.debug=true
|
||||||
|
org.kde.plasma.extsysmon.info=true
|
||||||
|
org.kde.plasma.extsysmon.warning=true
|
||||||
|
org.kde.plasma.extsysmon.critical=true
|
||||||
|
org.kde.plasma.awesomewidgets.debug=true
|
||||||
|
org.kde.plasma.awesomewidgets.info=true
|
||||||
|
org.kde.plasma.awesomewidgets.warning=true
|
||||||
|
org.kde.plasma.awesomewidgets.critical=true
|
@ -27,7 +27,6 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <QProcessEnvironment>
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -47,23 +46,21 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
|
|||||||
: Plasma::DataEngine(parent, args)
|
: Plasma::DataEngine(parent, args)
|
||||||
{
|
{
|
||||||
Q_UNUSED(args)
|
Q_UNUSED(args)
|
||||||
|
qCDebug(LOG_ESM);
|
||||||
// debug
|
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
|
||||||
bool debug = (debugEnv == QString("yes"));
|
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debug);
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||||
|
#endif /* QT_VERSION */
|
||||||
qSetMessagePattern(LOG_FORMAT);
|
qSetMessagePattern(LOG_FORMAT);
|
||||||
|
|
||||||
setMinimumPollingInterval(333);
|
setMinimumPollingInterval(333);
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
|
|
||||||
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"), debug);
|
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"));
|
||||||
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"), debug);
|
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"));
|
||||||
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"), debug);
|
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"));
|
||||||
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"), debug);
|
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +84,7 @@ QStringList ExtendedSysMon::getAllHdd() const
|
|||||||
for (int i=0; i<devices.count(); i++)
|
for (int i=0; i<devices.count(); i++)
|
||||||
devices[i] = QString("/dev/%1").arg(devices.at(i));
|
devices[i] = QString("/dev/%1").arg(devices.at(i));
|
||||||
|
|
||||||
qCDebug(LOG_ESM) << "Device list" << devices;
|
qCInfo(LOG_ESM) << "Device list" << devices;
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +103,7 @@ QString ExtendedSysMon::getAutoGpu() const
|
|||||||
else if (output.contains(QString("nvidia")))
|
else if (output.contains(QString("nvidia")))
|
||||||
gpu = QString("nvidia");
|
gpu = QString("nvidia");
|
||||||
|
|
||||||
qCDebug(LOG_ESM) << "Device" << gpu;
|
qCInfo(LOG_ESM) << "Device" << gpu;
|
||||||
return gpu;
|
return gpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +117,7 @@ QString ExtendedSysMon::getAutoMpris() const
|
|||||||
QStringList arguments = listServices.arguments().first().toStringList();
|
QStringList arguments = listServices.arguments().first().toStringList();
|
||||||
|
|
||||||
foreach(QString arg, arguments) {
|
foreach(QString arg, arguments) {
|
||||||
qCDebug(LOG_ESM) << "Service found" << arg;
|
qCInfo(LOG_ESM) << "Service found" << arg;
|
||||||
if (!arg.startsWith(QString("org.mpris.MediaPlayer2."))) continue;
|
if (!arg.startsWith(QString("org.mpris.MediaPlayer2."))) continue;
|
||||||
QString service = arg;
|
QString service = arg;
|
||||||
service.remove(QString("org.mpris.MediaPlayer2."));
|
service.remove(QString("org.mpris.MediaPlayer2."));
|
||||||
@ -150,7 +147,7 @@ QStringList ExtendedSysMon::sources() const
|
|||||||
source.append(QString("update"));
|
source.append(QString("update"));
|
||||||
source.append(QString("weather"));
|
source.append(QString("weather"));
|
||||||
|
|
||||||
qCDebug(LOG_ESM) << "Sources" << source;
|
qCInfo(LOG_ESM) << "Sources" << source;
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +158,7 @@ void ExtendedSysMon::readConfiguration()
|
|||||||
|
|
||||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation,
|
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation,
|
||||||
QString("plasma-dataengine-extsysmon.conf"));
|
QString("plasma-dataengine-extsysmon.conf"));
|
||||||
qCDebug(LOG_ESM) << "Configuration file" << fileName;
|
qCInfo(LOG_ESM) << "Configuration file" << fileName;
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
QHash<QString, QString> rawConfig;
|
QHash<QString, QString> rawConfig;
|
||||||
|
|
||||||
@ -183,6 +180,7 @@ void ExtendedSysMon::readConfiguration()
|
|||||||
QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QString> rawConfig) const
|
QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QString> rawConfig) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_ESM);
|
qCDebug(LOG_ESM);
|
||||||
|
qCDebug(LOG_ESM) << "Raw configuration" << rawConfig;
|
||||||
|
|
||||||
// gpudev
|
// gpudev
|
||||||
if (rawConfig[QString("GPUDEV")] == QString("disable"))
|
if (rawConfig[QString("GPUDEV")] == QString("disable"))
|
||||||
@ -203,7 +201,7 @@ QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QStri
|
|||||||
QStringList devices;
|
QStringList devices;
|
||||||
QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$");
|
QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$");
|
||||||
foreach(QString device, deviceList)
|
foreach(QString device, deviceList)
|
||||||
if ((QFile::exists(device)) && (diskRegexp.indexIn(device) > -1))
|
if ((QFile::exists(device)) && (device.contains(diskRegexp)))
|
||||||
devices.append(device);
|
devices.append(device);
|
||||||
if (devices.isEmpty())
|
if (devices.isEmpty())
|
||||||
rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
|
rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
|
||||||
@ -217,7 +215,7 @@ QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QStri
|
|||||||
rawConfig[QString("PLAYER")] = QString("mpris");
|
rawConfig[QString("PLAYER")] = QString("mpris");
|
||||||
|
|
||||||
foreach(QString key, rawConfig.keys())
|
foreach(QString key, rawConfig.keys())
|
||||||
qCDebug(LOG_ESM) << key << "=" << rawConfig[key];
|
qCInfo(LOG_ESM) << key << "=" << rawConfig[key];
|
||||||
return rawConfig;
|
return rawConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,10 +294,10 @@ float ExtendedSysMon::getGpu(const QString device) const
|
|||||||
cmd = QString("nvidia-smi -q -x");
|
cmd = QString("nvidia-smi -q -x");
|
||||||
else if (device == QString("ati"))
|
else if (device == QString("ati"))
|
||||||
cmd = QString("aticonfig --od-getclocks");
|
cmd = QString("aticonfig --od-getclocks");
|
||||||
qCDebug(LOG_ESM) << "cmd" << cmd;
|
qCInfo(LOG_ESM) << "cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
qCDebug(LOG_ESM) << "Error" << process.error;
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
||||||
@ -336,10 +334,10 @@ float ExtendedSysMon::getGpuTemp(const QString device) const
|
|||||||
cmd = QString("nvidia-smi -q -x");
|
cmd = QString("nvidia-smi -q -x");
|
||||||
else if (device == QString("ati"))
|
else if (device == QString("ati"))
|
||||||
cmd = QString("aticonfig --od-gettemperature");
|
cmd = QString("aticonfig --od-gettemperature");
|
||||||
qCDebug(LOG_ESM) << "cmd" << cmd;
|
qCInfo(LOG_ESM) << "cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
qCDebug(LOG_ESM) << "Error" << process.error;
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||||
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
if (configuration[QString("GPUDEV")] == QString("nvidia"))
|
||||||
@ -369,11 +367,11 @@ float ExtendedSysMon::getHddTemp(const QString cmd, const QString device) const
|
|||||||
|
|
||||||
float value = 0.0;
|
float value = 0.0;
|
||||||
TaskResult process = runTask(QString("%1 %2").arg(cmd).arg(device));
|
TaskResult process = runTask(QString("%1 %2").arg(cmd).arg(device));
|
||||||
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
qCDebug(LOG_ESM) << "Error" << process.error;
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
|
||||||
bool smartctl = cmd.contains(QString("smartctl"));
|
bool smartctl = cmd.contains(QString("smartctl"));
|
||||||
qCDebug(LOG_ESM) << "Define smartctl" << smartctl;
|
qCInfo(LOG_ESM) << "Parse as smartctl" << smartctl;
|
||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
if (smartctl) {
|
if (smartctl) {
|
||||||
@ -401,6 +399,7 @@ QString ExtendedSysMon::getNetworkDevice() const
|
|||||||
|
|
||||||
QString device = QString("lo");
|
QString device = QString("lo");
|
||||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||||
|
qCInfo(LOG_ESM) << "Devices" << rawInterfaceList;
|
||||||
foreach(QNetworkInterface interface, rawInterfaceList)
|
foreach(QNetworkInterface interface, rawInterfaceList)
|
||||||
if ((interface.flags().testFlag(QNetworkInterface::IsUp)) &&
|
if ((interface.flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||||
(!interface.flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
(!interface.flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||||
@ -457,10 +456,10 @@ QVariantHash ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress, const QS
|
|||||||
QString cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%1:%2\"")
|
QString cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%1:%2\"")
|
||||||
.arg(mpdAddress)
|
.arg(mpdAddress)
|
||||||
.arg(mpdPort);
|
.arg(mpdPort);
|
||||||
qCDebug(LOG_ESM) << "cmd" << cmd;
|
qCInfo(LOG_ESM) << "cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
|
qCInfo(LOG_ESM) << "Cmd returns" << process.exitCode;
|
||||||
qCDebug(LOG_ESM) << "Error" << process.error;
|
qCInfo(LOG_ESM) << "Error" << process.error;
|
||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
|
||||||
@ -506,7 +505,7 @@ QVariantHash ExtendedSysMon::getPlayerMprisInfo(const QString mpris) const
|
|||||||
request.setArguments(args);
|
request.setArguments(args);
|
||||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||||
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
|
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
|
||||||
qCDebug(LOG_ESM) << "Error message" << response.errorMessage();
|
qCWarning(LOG_ESM) << "Error message" << response.errorMessage();
|
||||||
} else {
|
} else {
|
||||||
// another portion of dirty magic
|
// another portion of dirty magic
|
||||||
QVariantHash map = qdbus_cast<QVariantHash>(response.arguments().first()
|
QVariantHash map = qdbus_cast<QVariantHash>(response.arguments().first()
|
||||||
@ -524,7 +523,7 @@ QVariantHash ExtendedSysMon::getPlayerMprisInfo(const QString mpris) const
|
|||||||
request.setArguments(args);
|
request.setArguments(args);
|
||||||
response = bus.call(request, QDBus::BlockWithGui);
|
response = bus.call(request, QDBus::BlockWithGui);
|
||||||
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
|
if ((response.type() != QDBusMessage::ReplyMessage) || (response.arguments().isEmpty())) {
|
||||||
qCDebug(LOG_ESM) << "Error message" << response.errorMessage();
|
qCWarning(LOG_ESM) << "Error message" << response.errorMessage();
|
||||||
} else
|
} else
|
||||||
// this cast is simpler than the previous one ;)
|
// this cast is simpler than the previous one ;)
|
||||||
info[QString("progress")] = response.arguments().first().value<QDBusVariant>()
|
info[QString("progress")] = response.arguments().first().value<QDBusVariant>()
|
||||||
@ -555,7 +554,7 @@ QVariantHash ExtendedSysMon::getPsStats() const
|
|||||||
|
|
||||||
QVariantHash psStats;
|
QVariantHash psStats;
|
||||||
psStats[QString("pscount")] = running.count();
|
psStats[QString("pscount")] = running.count();
|
||||||
psStats[QString("ps")] = running.join(QString(","));
|
psStats[QString("ps")] = running.join(QChar(','));
|
||||||
psStats[QString("pstotal")] = directories.count();
|
psStats[QString("pstotal")] = directories.count();
|
||||||
|
|
||||||
return psStats;
|
return psStats;
|
||||||
@ -625,6 +624,9 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
|||||||
QVariantHash data = weather->run();
|
QVariantHash data = weather->run();
|
||||||
foreach(QString key, data.keys()) setData(source, key, data[key]);
|
foreach(QString key, data.keys()) setData(source, key, data[key]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCWarning(LOG_ESM) << "Unknown source" << source;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -34,7 +34,7 @@ class ExtendedSysMon : public Plasma::DataEngine
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExtendedSysMon(QObject *parent, const QVariantList &args);
|
explicit ExtendedSysMon(QObject *parent, const QVariantList &args);
|
||||||
~ExtendedSysMon();
|
virtual ~ExtendedSysMon();
|
||||||
// update functions
|
// update functions
|
||||||
QVariantHash getBattery(const QString acpiPath) const;
|
QVariantHash getBattery(const QString acpiPath) const;
|
||||||
QVariantHash getCurrentDesktop() const;
|
QVariantHash getCurrentDesktop() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user