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