start moving to qt5 style logging

This commit is contained in:
arcan1s 2015-08-29 00:58:39 +03:00
parent 466faf53fa
commit aacb50c946
44 changed files with 598 additions and 516 deletions

24
sources/awdebug.cpp Normal file
View File

@ -0,0 +1,24 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#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")

41
sources/awdebug.h Normal file
View File

@ -0,0 +1,41 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWDEBUG_H
#define AWDEBUG_H
#include <QLoggingCategory>
#ifndef LOG_FORMAT
#define LOG_FORMAT "[%{time yyyy-MM-ddTHH:mm:ss.zzzZ}][%{if-debug}DD%{endif}%{if-info}II%{endif}%{if-warning}WW%{endif}%{if-critical}CC%{endif}%{if-fatal}FF%{endif}][%{category}][%{function}] %{message}"
#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)
#endif /* AWDEBUG_H */

View File

@ -110,6 +110,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[about::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -302,6 +302,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[advanced::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -251,6 +251,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[appearance::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -295,14 +295,14 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[dataengine::onCompleted]")
if (debug) console.log("")
// init submodule
awKeys.initKeys(plasmoid.configuration.text)
}
Component.onDestruction: {
if (debug) console.log("[dataengine::onDestruction]")
if (debug) console.log("")
cfg_dataengine["GPUDEV"] = gpuDev.currentText
cfg_dataengine["HDDDEV"] = hdd.currentText

View File

@ -92,14 +92,14 @@ Item {
interval: plasmoid.configuration.interval
onNewData: {
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
if (debug) console.log("Update source " + sourceName)
systemmonitorDE.interval = plasmoid.configuration.interval
awKeys.setDataBySource(sourceName, data, settings)
}
onSourceAdded: {
if (debug) console.log("[main::onSourceAdded] : Source " + source)
if (debug) console.log("Source " + source)
awKeys.addDevice(source)
}
@ -112,7 +112,7 @@ Item {
interval: plasmoid.configuration.interval
onNewData: {
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
if (debug) console.log("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("[main::onNewData] : Update source " + sourceName)
if (debug) console.log("Update source " + sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
@ -165,7 +165,7 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[main::onCompleted]")
if (debug) console.log("")
// actions
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
@ -183,27 +183,26 @@ Item {
}
onDropSource: {
if (debug) console.log("[main::onDropSource]")
if (debug) console.log("[main::onDropSource] : Source " + sourceName)
if (debug) console.log("Source " + sourceName)
systemmonitorDE.disconnectSource(sourceName)
}
onNeedTextUpdate: {
if (debug) console.log("[main::onNeedTextUpdate]")
if (debug) console.log("")
text.text = newText
sizeUpdate()
}
onNeedToolTipUpdate: {
if (debug) console.log("[main::onNeedToolTipUpdate]")
if (debug) console.log("")
tooltip.text = newText
}
onSizeUpdate: {
if (debug) console.log("[main::onSizeUpdate]")
if (debug) console.log("")
if (plasmoid.configuration.height == 0) {
Layout.minimumHeight = text.contentHeight
@ -223,7 +222,7 @@ Item {
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.log("[main::onUserConfiguringChanged]")
if (debug) console.log("")
// init submodule
awKeys.initKeys(plasmoid.configuration.text)
@ -236,25 +235,25 @@ Item {
}
function action_checkUpdates() {
if (debug) console.log("[main::action_checkUpdates]")
if (debug) console.log("")
return awActions.checkUpdates()
}
function action_showReadme() {
if (debug) console.log("[main::action_showReadme]")
if (debug) console.log("")
return awActions.showReadme()
}
function action_report() {
if (debug) console.log("[main::action_report]")
if (debug) console.log("")
return awActions.sendEmail()
}
function action_requestKey() {
if (debug) console.log("[main::action_requestKey]")
if (debug) console.log("")
return awKeys.graphicalValueByKey()
}

View File

@ -513,6 +513,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[tooltip::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -90,7 +90,7 @@ Item {
iconName: "font"
onClicked: {
if (debug) console.log("[widget::onClicked] : Font button")
if (debug) console.log("Font button")
var defaultFont = {
"color": plasmoid.configuration.fontColor,
@ -112,7 +112,7 @@ Item {
iconName: "format-indent-more"
onClicked: {
if (debug) console.log("[widget::onClicked] : Indent button")
if (debug) console.log("Indent button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -126,7 +126,7 @@ Item {
iconName: "format-text-bold"
onClicked: {
if (debug) console.log("[widget::onClicked] : Bold button")
if (debug) console.log("Bold button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -139,7 +139,7 @@ Item {
iconName: "format-text-italic"
onClicked: {
if (debug) console.log("[widget::onClicked] : Italic button")
if (debug) console.log("Italic button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -152,7 +152,7 @@ Item {
iconName: "format-text-underline"
onClicked: {
if (debug) console.log("[widget::onClicked] : Underline button")
if (debug) console.log("Underline button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -165,7 +165,7 @@ Item {
iconName: "format-text-strikethrough"
onClicked: {
if (debug) console.log("[widget::onClicked] : Strike button")
if (debug) console.log("Strike button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -179,7 +179,7 @@ Item {
iconName: "format-justify-left"
onClicked: {
if (debug) console.log("[widget::onClicked] : Left button")
if (debug) console.log("Left button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -192,7 +192,7 @@ Item {
iconName: "format-justify-center"
onClicked: {
if (debug) console.log("[widget::onClicked] : Center button")
if (debug) console.log("Center button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -205,7 +205,7 @@ Item {
iconName: "format-justify-right"
onClicked: {
if (debug) console.log("[widget::onClicked] : Right button")
if (debug) console.log("Right button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -218,7 +218,7 @@ Item {
iconName: "format-justify-fill"
onClicked: {
if (debug) console.log("[widget::onClicked] : Justify button")
if (debug) console.log("Justify button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -303,7 +303,7 @@ Item {
onClicked: {
if (!tags.currentText) return
if (debug) console.log("[widget::onClicked] : Add tag button")
if (debug) console.log("Add tag button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -317,7 +317,7 @@ Item {
onClicked: {
if (!tags.currentText) return
if (debug) console.log("[widget::onClicked] : Show tag button")
if (debug) console.log("Show tag button")
var message = i18n("Tag: %1", tags.currentText)
message += "<br>"
@ -332,7 +332,7 @@ Item {
text: i18n("Add lambda")
onClicked: {
if (debug) console.log("[widget::onClicked] : Lambda button")
if (debug) console.log("Lambda button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -370,7 +370,7 @@ Item {
interval: 5000
onNewData: {
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
if (debug) console.log("Update source " + sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
@ -383,7 +383,7 @@ Item {
interval: 5000
onNewData: {
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
if (debug) console.log("Update source " + sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
@ -396,14 +396,14 @@ Item {
interval: 5000
onNewData: {
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
if (debug) console.log("Update source " + sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
}
Component.onCompleted: {
if (debug) console.log("[widget::onCompleted]")
if (debug) console.log("")
// init submodule
awKeys.initKeys(plasmoid.configuration.text)

View File

@ -12,7 +12,7 @@ include_directories(
${Kf5_INCLUDE}
)
file(GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp)
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
file(GLOB SUBPROJECT_UI *.ui)
file(GLOB SUBPROJECT_NOTIFY *.notifyrc)

View File

@ -20,7 +20,6 @@
#include <KI18n/KLocalizedString>
#include <KNotifications/KNotification>
#include <QDebug>
#include <QDesktopServices>
#include <QDir>
#include <QJsonDocument>
@ -35,10 +34,8 @@
#include <QStandardPaths>
#include <fontdialog/fontdialog.h>
#include <pdebug/pdebug.h>
#include "extscript.h"
#include "graphicalitem.h"
#include "awdebug.h"
#include "version.h"
@ -48,19 +45,24 @@ AWActions::AWActions(QObject *parent)
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
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;
}
AWActions::~AWActions()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
}
void AWActions::checkUpdates()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
@ -71,7 +73,7 @@ void AWActions::checkUpdates()
bool AWActions::dropCache() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QString fileName = QString("%1/awesomewidgets.ndx")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
@ -82,16 +84,16 @@ bool AWActions::dropCache() const
bool AWActions::isDebugEnabled() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
return debug;
return LOG_AW().isDebugEnabled();
}
void AWActions::runCmd(const QString cmd) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Cmd" << cmd;
QProcess command;
sendNotification(QString("Info"), i18n("Run %1", cmd));
@ -102,13 +104,13 @@ void AWActions::runCmd(const QString cmd) const
void AWActions::sendEmail() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
}
void AWActions::showReadme() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QDesktopServices::openUrl(QString(HOMEPAGE));
}
@ -116,8 +118,8 @@ void AWActions::showReadme() const
QString AWActions::getAboutText(const QString type) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Type" << type;
QString text;
if (type == QString("header"))
@ -155,7 +157,7 @@ QString AWActions::getAboutText(const QString type) const
QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QVariantMap fontMap;
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
@ -173,10 +175,10 @@ QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
QVariantMap AWActions::readDataEngineConfiguration() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
qCDebug(LOG_AW) << "Configuration file" << fileName;
QSettings settings(fileName, QSettings::IniFormat);
QVariantMap configuration;
@ -197,11 +199,11 @@ QVariantMap AWActions::readDataEngineConfiguration() const
void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
QSettings settings(fileName, QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
qCDebug(LOG_AW) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Configuration"));
settings.setValue(QString("ACPIPATH"), configuration[QString("ACPIPATH")]);
@ -221,6 +223,9 @@ void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) co
void AWActions::sendNotification(const QString eventId, const QString message,
const bool enablePopup)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Event" << eventId;
qCDebug(LOG_AW) << "Message" << message;
if ((eventId == QString("event")) && (!enablePopup)) return;
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: %1").arg(eventId), message);
@ -230,7 +235,7 @@ void AWActions::sendNotification(const QString eventId, const QString message,
void AWActions::showUpdates(QString version) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QString text;
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
@ -249,14 +254,16 @@ void AWActions::showUpdates(QString version) const
void AWActions::versionReplyRecieved(QNetworkReply *reply) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Return code" << reply->error();
qCDebug(LOG_AW) << "Reply error message" << reply->errorString();
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
if ((reply->error() != QNetworkReply::NoError) ||
(error.error != QJsonParseError::NoError)) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return;
}

View File

@ -55,8 +55,6 @@ private slots:
void versionReplyRecieved(QNetworkReply *reply) const;
private:
// variables
bool debug = false;
};

View File

@ -20,7 +20,6 @@
#include <KI18n/KLocalizedString>
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QInputDialog>
#include <QLocale>
@ -32,9 +31,8 @@
#include <QStandardPaths>
#include <QThread>
#include <pdebug/pdebug.h>
#include "awactions.h"
#include "awdebug.h"
#include "awtooltip.h"
#include "extquotes.h"
#include "extscript.h"
@ -49,7 +47,11 @@ AWKeys::AWKeys(QObject *parent)
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
bool debug = (debugEnv == QString("yes"));
// logging
const_cast<QLoggingCategory &>(LOG_AW()).setEnabled(QtMsgType::QtDebugMsg, debug);
qSetMessagePattern(LOG_FORMAT);
// backend
graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, QString("desktops"), debug);
@ -63,7 +65,7 @@ AWKeys::AWKeys(QObject *parent)
AWKeys::~AWKeys()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
if (toolTip != nullptr) delete toolTip;
@ -77,7 +79,7 @@ AWKeys::~AWKeys()
void AWKeys::initKeys(const QString currentPattern)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
// init
pattern = currentPattern;
@ -91,7 +93,7 @@ void AWKeys::initKeys(const QString currentPattern)
void AWKeys::initTooltip(const QVariantMap tooltipParams)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
if (toolTip != nullptr) {
disconnect(toolTip, SIGNAL(toolTipPainted(QString)), this, SIGNAL(needToolTipToBeUpdated(QString)));
@ -106,7 +108,7 @@ void AWKeys::initTooltip(const QVariantMap tooltipParams)
void AWKeys::setPopupEnabled(const bool popup)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
enablePopup = popup;
}
@ -114,7 +116,7 @@ void AWKeys::setPopupEnabled(const bool popup)
void AWKeys::setTranslateStrings(const bool translate)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
translateStrings = translate;
}
@ -122,7 +124,7 @@ void AWKeys::setTranslateStrings(const bool translate)
void AWKeys::setWrapNewLines(const bool wrap)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
wrapNewLines = wrap;
}
@ -130,7 +132,7 @@ void AWKeys::setWrapNewLines(const bool wrap)
QSize AWKeys::toolTipSize() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
if (toolTip == nullptr) return QSize();
return toolTip->getSize();
@ -139,8 +141,8 @@ QSize AWKeys::toolTipSize() const
void AWKeys::addDevice(const QString source)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Source" << source;
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
QRegExp mountRegexp = QRegExp(QString("partitions/.*/filllevel"));
@ -161,9 +163,9 @@ void AWKeys::addDevice(const QString source)
QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Should be sorted" << sorted;
if (debug) qDebug() << PDEBUG << ":" << "Filter" << regexp;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Should be sorted" << sorted;
qCDebug(LOG_AW) << "Filter" << regexp;
QStringList allKeys;
// time
@ -318,7 +320,7 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
QStringList AWKeys::getHddDevices() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QStringList devices = hddDevices;
// required by ui interface
@ -332,9 +334,9 @@ QStringList AWKeys::getHddDevices() const
void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
const QVariantMap params)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
if (debug) qDebug() << PDEBUG << ":" << "Data" << data;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Source" << sourceName;
qCDebug(LOG_AW) << "Data" << data;
if (sourceName == QString("update")) return emit(needToBeUpdated());
@ -632,7 +634,7 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
temperature(data[key].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
}
} else {
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName << "not found";
qCDebug(LOG_AW) << "Source" << sourceName << "not found";
emit(dropSourceFromDataengine(sourceName));
}
}
@ -640,11 +642,11 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
void AWKeys::graphicalValueByKey() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
bool ok;
QString tag = QInputDialog::getItem(nullptr, i18n("Select tag"), i18n("Tag"),
dictKeys(true), 0, false, &ok);
dictKeys(true), 0, true, &ok);
if ((!ok) || (tag.isEmpty())) return;
QString message = i18n("Tag: %1", tag);
@ -657,8 +659,8 @@ void AWKeys::graphicalValueByKey() const
QString AWKeys::infoByKey(QString key) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Requested key" << key;
key.remove(QRegExp(QString("^bar[0-9]{1,}")));
if (key.startsWith(QString("custom")))
@ -693,8 +695,8 @@ QString AWKeys::infoByKey(QString key) const
QString AWKeys::valueByKey(QString key) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Requested key" << key;
key.remove(QRegExp(QString("^bar[0-9]{1,}")));
@ -704,7 +706,7 @@ QString AWKeys::valueByKey(QString key) const
void AWKeys::editItem(const QString type)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
if (type == QString("graphicalitem")) {
graphicalItems->setConfigArgs(dictKeys(true, QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")));
@ -723,7 +725,7 @@ void AWKeys::editItem(const QString type)
void AWKeys::dataUpdate() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
emit(needTextToBeUpdated(parsePattern()));
if (toolTip != nullptr) emit(toolTip->updateData(values));
@ -732,11 +734,11 @@ void AWKeys::dataUpdate() const
void AWKeys::loadKeysFromCache()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QString fileName = QString("%1/awesomewidgets.ndx")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
if (debug) qDebug() << PDEBUG << ":" << "Cache file" << fileName;
qCDebug(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
cache.beginGroup(QString("Disk"));
@ -773,7 +775,7 @@ void AWKeys::loadKeysFromCache()
void AWKeys::reinitKeys()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
foundBars = findGraphicalItems();
foundKeys = findKeys();
@ -783,12 +785,12 @@ void AWKeys::reinitKeys()
void AWKeys::addKeyToCache(const QString type, const QString key)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Key type" << type;
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Key type" << type;
qCDebug(LOG_AW) << "Key" << key;
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
if (debug) qDebug() << PDEBUG << ":" << "Cache file" << fileName;
qCDebug(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
cache.beginGroup(type);
@ -802,7 +804,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;
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
qCDebug(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")) {
@ -810,12 +812,12 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
foreach(QNetworkInterface interface, rawInterfaceList) {
QString device = interface.name();
if (cachedValues.contains(device)) continue;
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
qCDebug(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;
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << key << "for type" << type;
qCDebug(LOG_AW) << "Found new key" << key << "for type" << type;
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
}
cache.endGroup();
@ -828,7 +830,7 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
QString AWKeys::parsePattern() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QString parsed = pattern;
parsed.replace(QString("$$"), QString("$\\$\\"));
@ -837,12 +839,11 @@ QString AWKeys::parsePattern() const
QScriptEngine engine;
foreach(QString lambdaKey, foundKeys)
key.replace(QString("$%1").arg(lambdaKey), values[lambdaKey]);
if (debug) qDebug() << PDEBUG << ":" << "Expression" << key;
qCDebug(LOG_AW) << "Expression" << key;
QScriptValue result = engine.evaluate(key);
if (engine.hasUncaughtException()) {
int line = engine.uncaughtExceptionLineNumber();
if (debug) qDebug() << PDEBUG << ":" << "Uncaught exception at line"
<< line << ":" << result.toString();
qCWarning(LOG_AW) << "Uncaught exception at line" << line << ":" << result.toString();
return QString();
} else
return result.toString();
@ -866,7 +867,7 @@ QString AWKeys::parsePattern() const
float AWKeys::temperature(const float temp, const QString units) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
float converted = temp;
if (units == QString("Celsius"))
@ -890,7 +891,7 @@ float AWKeys::temperature(const float temp, const QString units) const
QStringList AWKeys::findGraphicalItems() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QStringList orderedKeys;
foreach(GraphicalItem *item, graphicalItems->items())
@ -900,7 +901,7 @@ QStringList AWKeys::findGraphicalItems() const
QStringList selectedKeys;
for (int i=orderedKeys.count()-1; i>=0; i--)
if (pattern.contains(QString("$%1").arg(orderedKeys.at(i)))) {
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys.at(i);
qCDebug(LOG_AW) << "Found bar" << orderedKeys.at(i);
selectedKeys.append(orderedKeys.at(i));
}
@ -910,13 +911,13 @@ QStringList AWKeys::findGraphicalItems() const
QStringList AWKeys::findKeys() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QStringList selectedKeys;
foreach(QString key, dictKeys()) {
if (key.startsWith(QString("bar"))) continue;
if (pattern.contains(QString("$%1").arg(key))) {
if (debug) qDebug() << PDEBUG << ":" << "Found key" << key;
qCDebug(LOG_AW) << "Found key" << key;
selectedKeys.append(key);
}
}
@ -927,7 +928,7 @@ QStringList AWKeys::findKeys() const
QStringList AWKeys::findLambdas() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QStringList selectedKeys;
// substring inside ${{ }} (with brackets) which should not contain ${{
@ -942,7 +943,7 @@ QStringList AWKeys::findLambdas() const
lambda.remove(QRegExp(QString("^\\$\\{\\{")));
lambda.remove(QRegExp(QString("\\}\\}$")));
// append
if (debug) qDebug() << PDEBUG << ":" << "Found lambda" << lambda;
qCDebug(LOG_AW) << "Found lambda" << lambda;
selectedKeys.append(lambda);
}

View File

@ -85,7 +85,6 @@ private:
QStringList findLambdas() const;
// get methods
AWToolTip *toolTip = nullptr;
bool debug = false;
bool enablePopup = false;
bool translateStrings = false;
bool wrapNewLines = false;

View File

@ -18,11 +18,10 @@
#include "awtooltip.h"
#include <QBuffer>
#include <QDebug>
#include <QProcessEnvironment>
#include <math.h>
#include <pdebug/pdebug.h>
#include "awdebug.h"
AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
@ -32,7 +31,11 @@ AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
bool debug = (debugEnv == QString("yes"));
// logging
const_cast<QLoggingCategory &>(LOG_AW()).setEnabled(QtMsgType::QtDebugMsg, debug);
qSetMessagePattern(LOG_FORMAT);
toolTipScene = new QGraphicsScene(nullptr);
toolTipView = new QGraphicsView(toolTipScene);
@ -74,7 +77,7 @@ AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
AWToolTip::~AWToolTip()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
delete toolTipScene;
}
@ -82,7 +85,7 @@ AWToolTip::~AWToolTip()
void AWToolTip::dataUpdate(QHash<QString, QString> values)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
// battery update requires info is AC online or not
setData(QString("batTooltip"), values[QString("bat")].toFloat(),
@ -101,7 +104,7 @@ void AWToolTip::dataUpdate(QHash<QString, QString> values)
QSize AWToolTip::getSize() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
return size;
}
@ -109,7 +112,7 @@ QSize AWToolTip::getSize() const
QString AWToolTip::htmlImage()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
QPixmap rawImage = image();
QByteArray byteArray;
@ -123,7 +126,7 @@ QString AWToolTip::htmlImage()
QPixmap AWToolTip::image()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
toolTipView->resize(size);
// create image
@ -163,7 +166,7 @@ QPixmap AWToolTip::image()
void AWToolTip::setData(const QString source, float value, const bool ac)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_AW);
if (data[source].count() == 0)
data[source].append(0.0);

View File

@ -52,7 +52,6 @@ private:
void setData(const QString source, float value,
const bool ac = true);
// variables
bool debug = false;
int counts = 0;
QVariantHash configuration;
QHash<QString, float> boundaries;

View File

@ -12,7 +12,7 @@ include_directories(
${Kf5_INCLUDE}
)
file(GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.cpp)
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
file(GLOB SUBPROJECT_HEADER *.h ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.h)
file(GLOB SUBPROJECT_UI *.ui)
set(SUBPROJECT_GRAPHITEMS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)

View File

@ -17,14 +17,12 @@
#include "abstractextitem.h"
#include <QDebug>
#include <QDir>
#include <QSettings>
#include <QStandardPaths>
#include <QTime>
#include <pdebug/pdebug.h>
#include "awdebug.h"
#include "version.h"
@ -32,16 +30,19 @@ AbstractExtItem::AbstractExtItem(QWidget *parent, const QString desktopName,
const QStringList directories, const bool debugCmd)
: QDialog(parent),
m_fileName(desktopName),
m_dirs(directories),
debug(debugCmd)
m_dirs(directories)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
m_name = m_fileName;
}
AbstractExtItem::~AbstractExtItem()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
}
@ -50,6 +51,7 @@ T *AbstractExtItem::copy(const QString fileName, const int number)
{
Q_UNUSED(fileName)
Q_UNUSED(number)
qCDebug(LOG_ESM);
// an analog of pure virtual method
return new T();
@ -59,7 +61,7 @@ T *AbstractExtItem::copy(const QString fileName, const int number)
int AbstractExtItem::apiVersion() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_apiVersion;
}
@ -67,7 +69,7 @@ int AbstractExtItem::apiVersion() const
QString AbstractExtItem::comment() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_comment;
}
@ -75,7 +77,7 @@ QString AbstractExtItem::comment() const
QStringList AbstractExtItem::directories() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_dirs;
}
@ -83,7 +85,7 @@ QStringList AbstractExtItem::directories() const
QString AbstractExtItem::fileName() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_fileName;
}
@ -91,7 +93,7 @@ QString AbstractExtItem::fileName() const
int AbstractExtItem::interval() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_interval;
}
@ -99,7 +101,7 @@ int AbstractExtItem::interval() const
bool AbstractExtItem::isActive() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_active;
}
@ -107,7 +109,7 @@ bool AbstractExtItem::isActive() const
QString AbstractExtItem::name() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_name;
}
@ -115,7 +117,7 @@ QString AbstractExtItem::name() const
int AbstractExtItem::number() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_number;
}
@ -123,8 +125,8 @@ int AbstractExtItem::number() const
QString AbstractExtItem::tag(const QString _type) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Tag type" << _type;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Tag type" << _type;
return QString("%1%2").arg(_type).arg(m_number);
}
@ -132,8 +134,8 @@ QString AbstractExtItem::tag(const QString _type) const
void AbstractExtItem::setApiVersion(const int _apiVersion)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Version" << _apiVersion;
m_apiVersion = _apiVersion;
}
@ -141,8 +143,8 @@ void AbstractExtItem::setApiVersion(const int _apiVersion)
void AbstractExtItem::setActive(const bool _state)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "State" << _state;
m_active = _state;
}
@ -150,8 +152,8 @@ void AbstractExtItem::setActive(const bool _state)
void AbstractExtItem::setComment(const QString _comment)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Comment" << _comment;
m_comment = _comment;
}
@ -159,8 +161,8 @@ void AbstractExtItem::setComment(const QString _comment)
void AbstractExtItem::setInterval(const int _interval)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Interval" << _interval;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Interval" << _interval;
if (_interval <= 0) return;
m_interval = _interval;
@ -169,8 +171,8 @@ void AbstractExtItem::setInterval(const int _interval)
void AbstractExtItem::setName(const QString _name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Name" << _name;
m_name = _name;
}
@ -178,14 +180,16 @@ void AbstractExtItem::setName(const QString _name)
void AbstractExtItem::setNumber(int _number)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Number" << _number;
if (_number == -1) {
if (debug) qDebug() << PDEBUG << ":" << "Number is empty, generate new one";
qsrand(QTime::currentTime().msec());
_number = qrand() % 1000;
if (debug) qDebug() << PDEBUG << ":" << "Generated number is" << _number;
}
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Number" << _number;
if (_number == -1)
_number = []() {
qCWarning(LOG_ESM) << "Number is empty, generate new one";
qsrand(QTime::currentTime().msec());
int n = qrand() % 1000;
qCDebug(LOG_ESM) << "Generated number is" << n;
return n;
}();
m_number = _number;
}
@ -193,7 +197,7 @@ void AbstractExtItem::setNumber(int _number)
void AbstractExtItem::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
for (int i=m_dirs.count()-1; i>=0; i--) {
if (!QDir(m_dirs.at(i)).entryList(QDir::Files).contains(m_fileName)) continue;
@ -213,11 +217,11 @@ void AbstractExtItem::readConfiguration()
bool AbstractExtItem::tryDelete() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
foreach(QString dir, m_dirs) {
bool status = QFile::remove(QString("%1/%2").arg(dir).arg(m_fileName));
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << QString("%1/%2").arg(dir).arg(m_fileName) << status;
qCDebug(LOG_ESM) << "Remove file" << QString("%1/%2").arg(dir).arg(m_fileName) << status;
}
// check if exists
@ -229,10 +233,10 @@ bool AbstractExtItem::tryDelete() const
void AbstractExtItem::writeConfiguration() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QSettings settings(QString("%1/%2").arg(m_dirs.first()).arg(m_fileName), QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Encoding"), QString("UTF-8"));

View File

@ -71,7 +71,6 @@ public slots:
private:
QString m_fileName;
QStringList m_dirs;
bool debug;
virtual void translate() = 0;
// properties
int m_apiVersion = 0;

View File

@ -19,18 +19,20 @@
#include <KI18n/KLocalizedString>
#include <QDebug>
#include <QHBoxLayout>
#include <QInputDialog>
#include <QLineEdit>
#include <pdebug/pdebug.h>
#include "awdebug.h"
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent, const bool debugCmd)
: QWidget(parent),
debug(debugCmd)
: QWidget(parent)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
dialog = new QDialog(this);
widgetDialog = new QListWidget(dialog);
dialogButtons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close,
@ -53,7 +55,7 @@ AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent, const bool
AbstractExtItemAggregator::~AbstractExtItemAggregator()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
delete dialog;
}
@ -61,7 +63,7 @@ AbstractExtItemAggregator::~AbstractExtItemAggregator()
QString AbstractExtItemAggregator::getName()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
bool ok;
QString name = QInputDialog::getText(this, i18n("Enter file name"),
@ -76,7 +78,7 @@ QString AbstractExtItemAggregator::getName()
QVariant AbstractExtItemAggregator::configArgs() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_configArgs;
}
@ -84,8 +86,8 @@ QVariant AbstractExtItemAggregator::configArgs() const
void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Configuration arguments" << _configArgs;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Configuration arguments" << _configArgs;
m_configArgs = _configArgs;
}
@ -94,7 +96,7 @@ void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
{
Q_UNUSED(item)
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return editItem();
}
@ -102,7 +104,7 @@ void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
if (static_cast<QPushButton *>(button) == copyButton)
return copyItem();

View File

@ -53,7 +53,6 @@ private slots:
void editItemButtonPressed(QAbstractButton *button);
private:
bool debug;
QVariant m_configArgs;
// methods
virtual void copyItem() = 0;

View File

@ -20,12 +20,11 @@
#include <KI18n/KLocalizedString>
#include <QDebug>
#include <QDir>
#include <QSettings>
#include <QStandardPaths>
#include <pdebug/pdebug.h>
#include "awdebug.h"
#include "abstractextitemaggregator.h"
@ -37,31 +36,34 @@ public:
explicit ExtItemAggregator(QWidget *parent, const QString type,
const bool debugCmd = false)
: AbstractExtItemAggregator(parent, debugCmd),
debug(debugCmd),
m_type(type)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
initItems();
};
~ExtItemAggregator()
virtual ~ExtItemAggregator()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
m_items.clear();
}
void editItems()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
repaint();
int ret = dialog->exec();
if (debug) qDebug() << PDEBUG << ":" << "Dialog returns" << ret;
qCDebug(LOG_ESM) << "Dialog returns" << ret;
};
void initItems()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
m_items.clear();
m_items = getItems();
@ -69,7 +71,7 @@ public:
T *itemByTag(const QString _tag) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
T *found = nullptr;
foreach(T *item, m_items) {
@ -83,7 +85,7 @@ public:
T *itemByTagNumber(const int _number) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
T *found = nullptr;
foreach(T *item, m_items) {
@ -97,7 +99,7 @@ public:
T *itemFromWidget() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QListWidgetItem *widgetItem = widgetDialog->currentItem();
if (widgetItem == nullptr) return nullptr;
@ -114,14 +116,14 @@ public:
QList<T *> items() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_items;
};
int uniqNumber() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QList<int> tagList;
foreach(T *item, m_items) tagList.append(item->number());
@ -132,14 +134,13 @@ public:
};
private:
bool debug;
QList<T *> m_items;
QString m_type;
// init method
QList<T *> getItems()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
// create directory at $HOME
QString localDir = QString("%1/awesomewidgets/%2")
@ -147,7 +148,7 @@ private:
.arg(m_type);
QDir localDirectory;
if (localDirectory.mkpath(localDir))
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
qCDebug(LOG_ESM) << "Created directory" << localDir;
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
QString("awesomewidgets/%1").arg(m_type),
@ -159,9 +160,9 @@ private:
foreach(QString file, files) {
if (!file.endsWith(QString(".desktop"))) continue;
if (names.contains(file)) continue;
if (debug) qDebug() << PDEBUG << ":" << "Found file" << file << "in" << dir;
qCDebug(LOG_ESM) << "Found file" << file << "in" << dir;
names.append(file);
items.append(new T(this, file, dirs, debug));
items.append(new T(this, file, dirs, LOG_ESM().isDebugEnabled()));
}
}
@ -185,7 +186,7 @@ private:
// methods
void copyItem()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
T *source = itemFromWidget();
QString fileName = getName();
@ -201,7 +202,7 @@ private:
void createItem()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString fileName = getName();
int number = uniqNumber();
@ -210,7 +211,7 @@ private:
QStandardPaths::LocateDirectory);
if (fileName.isEmpty()) return;
T *newItem = new T(this, fileName, dirs, debug);
T *newItem = new T(this, fileName, dirs, LOG_ESM().isDebugEnabled());
newItem->setNumber(number);
if (newItem->showConfiguration(configArgs()) == 1) {
initItems();
@ -220,7 +221,7 @@ private:
void deleteItem()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
T *source = itemFromWidget();
if (source == nullptr) return;
@ -233,7 +234,7 @@ private:
void editItem()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
T *source = itemFromWidget();
if (source == nullptr) return;

View File

@ -20,7 +20,6 @@
#include <KI18n/KLocalizedString>
#include <QDebug>
#include <QDir>
#include <QJsonDocument>
#include <QJsonParseError>
@ -28,18 +27,21 @@
#include <QNetworkRequest>
#include <QSettings>
#include <pdebug/pdebug.h>
#include <qreplytimeout/qreplytimeout.h>
#include "awdebug.h"
#include "version.h"
ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
const QStringList directories, const bool debugCmd)
: AbstractExtItem(parent, quotesName, directories, debugCmd),
debug(debugCmd),
ui(new Ui::ExtQuotes)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
readConfiguration();
ui->setupUi(this);
translate();
@ -62,7 +64,7 @@ ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
ExtQuotes::~ExtQuotes()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
@ -73,10 +75,10 @@ ExtQuotes::~ExtQuotes()
ExtQuotes *ExtQuotes::copy(const QString fileName, const int number)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), fileName,
directories(), debug);
directories(), LOG_ESM().isDebugEnabled());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setComment(comment());
@ -91,7 +93,7 @@ ExtQuotes *ExtQuotes::copy(const QString fileName, const int number)
QString ExtQuotes::ticker() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_ticker;
}
@ -99,7 +101,7 @@ QString ExtQuotes::ticker() const
QString ExtQuotes::uniq() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_ticker;
}
@ -107,8 +109,8 @@ QString ExtQuotes::uniq() const
void ExtQuotes::setTicker(const QString _ticker)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Ticker" << _ticker;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Ticker" << _ticker;
m_ticker = _ticker;
}
@ -116,7 +118,7 @@ void ExtQuotes::setTicker(const QString _ticker)
void ExtQuotes::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
@ -138,11 +140,11 @@ void ExtQuotes::readConfiguration()
QVariantHash ExtQuotes::run()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
if ((!isActive()) || (isRunning)) return values;
if (times == 1) {
if (debug) qDebug() << PDEBUG << ":" << "Send request";
qCDebug(LOG_ESM) << "Send request";
isRunning = true;
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
new QReplyTimeout(reply, 1000);
@ -159,7 +161,7 @@ QVariantHash ExtQuotes::run()
int ExtQuotes::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
@ -185,11 +187,11 @@ int ExtQuotes::showConfiguration(const QVariant args)
void ExtQuotes::writeConfiguration() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Ticker"), m_ticker);
@ -200,17 +202,17 @@ void ExtQuotes::writeConfiguration() const
void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Return code" << reply->error();
if (debug) qDebug() << PDEBUG << ":" << "Reply error message" << reply->errorString();
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Return code" << reply->error();
qCDebug(LOG_ESM) << "Reply error message" << reply->errorString();
isRunning = false;
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
if ((reply->error() != QNetworkReply::NoError) ||
(error.error != QJsonParseError::NoError)) {
qCWarning(LOG_ESM) << "Parse error" << error.errorString();
return;
}
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()[QString("query")].toMap();
@ -242,7 +244,7 @@ void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
void ExtQuotes::translate()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
@ -256,11 +258,11 @@ void ExtQuotes::translate()
QString ExtQuotes::url() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString apiUrl = QString(YAHOO_URL);
apiUrl.replace(QString("$TICKER"), m_ticker);
if (debug) qDebug() << PDEBUG << ":" << "API url" << apiUrl;
qCDebug(LOG_ESM) << "API url" << apiUrl;
return apiUrl;
}

View File

@ -39,7 +39,7 @@ public:
explicit ExtQuotes(QWidget *parent = nullptr, const QString quotesName = QString(),
const QStringList directories = QStringList(),
const bool debugCmd = false);
~ExtQuotes();
virtual ~ExtQuotes();
ExtQuotes *copy(const QString fileName, const int number);
// get methods
QString ticker() const;
@ -57,7 +57,6 @@ private slots:
void quotesReplyReceived(QNetworkReply *reply);
private:
bool debug;
QNetworkAccessManager *manager;
bool isRunning = false;
Ui::ExtQuotes *ui;

View File

@ -20,7 +20,6 @@
#include <KI18n/KLocalizedString>
#include <QDebug>
#include <QDir>
#include <QJsonDocument>
#include <QJsonParseError>
@ -28,17 +27,19 @@
#include <QStandardPaths>
#include <QTextCodec>
#include <pdebug/pdebug.h>
#include "awdebug.h"
#include "version.h"
ExtScript::ExtScript(QWidget *parent, const QString scriptName,
const QStringList directories, const bool debugCmd)
: AbstractExtItem(parent, scriptName, directories, debugCmd),
debug(debugCmd),
ui(new Ui::ExtScript)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
readConfiguration();
readJsonFilters();
ui->setupUi(this);
@ -54,7 +55,7 @@ ExtScript::ExtScript(QWidget *parent, const QString scriptName,
ExtScript::~ExtScript()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
process->kill();
delete process;
@ -64,10 +65,10 @@ ExtScript::~ExtScript()
ExtScript *ExtScript::copy(const QString fileName, const int number)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), fileName,
directories(), debug);
directories(), LOG_ESM().isDebugEnabled());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setComment(comment());
@ -85,7 +86,7 @@ ExtScript *ExtScript::copy(const QString fileName, const int number)
QString ExtScript::executable() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_executable;
}
@ -93,7 +94,7 @@ QString ExtScript::executable() const
QStringList ExtScript::filters() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_filters;
}
@ -101,7 +102,7 @@ QStringList ExtScript::filters() const
bool ExtScript::hasOutput() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_output;
}
@ -109,7 +110,7 @@ bool ExtScript::hasOutput() const
QString ExtScript::prefix() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_prefix;
}
@ -117,7 +118,7 @@ QString ExtScript::prefix() const
ExtScript::Redirect ExtScript::redirect() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_redirect;
}
@ -125,7 +126,7 @@ ExtScript::Redirect ExtScript::redirect() const
QString ExtScript::uniq() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_executable;
}
@ -133,7 +134,7 @@ QString ExtScript::uniq() const
QString ExtScript::strRedirect() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString value;
switch (m_redirect) {
@ -155,8 +156,8 @@ QString ExtScript::strRedirect() const
void ExtScript::setExecutable(const QString _executable)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Executable" << _executable;
m_executable = _executable;
}
@ -164,8 +165,8 @@ void ExtScript::setExecutable(const QString _executable)
void ExtScript::setFilters(const QStringList _filters)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Filters" << _filters;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Filters" << _filters;
foreach(QString filter, _filters)
updateFilter(filter);
@ -174,8 +175,8 @@ void ExtScript::setFilters(const QStringList _filters)
void ExtScript::setHasOutput(const bool _state)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "State" << _state;
m_output = _state;
}
@ -183,8 +184,8 @@ void ExtScript::setHasOutput(const bool _state)
void ExtScript::setPrefix(const QString _prefix)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Prefix" << _prefix;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Prefix" << _prefix;
m_prefix = _prefix;
}
@ -192,8 +193,8 @@ void ExtScript::setPrefix(const QString _prefix)
void ExtScript::setRedirect(const Redirect _redirect)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Redirect" << _redirect;
m_redirect = _redirect;
}
@ -201,8 +202,8 @@ void ExtScript::setRedirect(const Redirect _redirect)
void ExtScript::setStrRedirect(const QString _redirect)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Redirect" << _redirect;
if (_redirect == QString("stdout2sdterr"))
m_redirect = stdout2stderr;
@ -215,14 +216,14 @@ void ExtScript::setStrRedirect(const QString _redirect)
QString ExtScript::applyFilters(QString _value) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Value" << _value;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Value" << _value;
foreach(QString filt, m_filters) {
if (debug) qDebug() << PDEBUG << ":" << "Found filter" << filt;
qCDebug(LOG_ESM) << "Found filter" << filt;
QVariantMap filter = jsonFilters[filt].toMap();
if (filter.isEmpty()) {
if (debug) qDebug() << PDEBUG << ":" << "Could not find filter in the json";
qCWarning(LOG_ESM) << "Could not find filter in the json";
continue;
}
foreach(QString f, filter.keys())
@ -235,9 +236,9 @@ QString ExtScript::applyFilters(QString _value) const
void ExtScript::updateFilter(const QString _filter, const bool _add)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Filter" << _filter;
if (debug) qDebug() << PDEBUG << ":" << "Should be added" << _add;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Filter" << _filter;
qCDebug(LOG_ESM) << "Should be added" << _add;
if (_add) {
if (m_filters.contains(_filter)) return;
@ -250,7 +251,7 @@ void ExtScript::updateFilter(const QString _filter, const bool _add)
void ExtScript::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
@ -281,11 +282,11 @@ void ExtScript::readConfiguration()
void ExtScript::readJsonFilters()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
qCDebug(LOG_ESM) << "Configuration file" << fileName;
QFile jsonFile(fileName);
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
return;
@ -294,24 +295,26 @@ void ExtScript::readJsonFilters()
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
if (error.error != QJsonParseError::NoError) return;
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_ESM) << "Json parse error" << error.errorString();
return;
}
jsonFilters = jsonDoc.toVariant().toMap();
if (debug) qDebug() << PDEBUG << ":" << "Filters" << jsonFilters;
qCDebug(LOG_ESM) << "Filters" << jsonFilters;
}
QVariantHash ExtScript::run()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
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);
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
qCDebug(LOG_ESM) << "cmd" << cmdList.join(QChar(' '));
process->start(cmdList.join(QChar(' ')));
} else if (times >= interval())
times = 0;
@ -324,7 +327,7 @@ QVariantHash ExtScript::run()
int ExtScript::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
@ -364,11 +367,11 @@ int ExtScript::showConfiguration(const QVariant args)
void ExtScript::writeConfiguration() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Exec"), m_executable);
@ -384,25 +387,23 @@ void ExtScript::writeConfiguration() const
void ExtScript::updateValue()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process->exitCode();
qCDebug(LOG_ESM) << "Cmd returns" << process->exitCode();
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardError()).trimmed();
if (debug) qDebug() << PDEBUG << ":" << "Error" << qdebug;
qCDebug(LOG_ESM) << "Error" << qdebug;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
qCDebug(LOG_ESM) << "Error" << qoutput;
QString strValue;
switch (m_redirect) {
case stdout2stderr:
if (debug) qDebug() << PDEBUG << ":" << "Debug" << qdebug;
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
break;
case stderr2stdout:
strValue = QString("%1\n%2").arg(qdebug).arg(qoutput);
break;
case nothing:
default:
if (debug) qDebug() << PDEBUG << ":" << "Debug" << qdebug;
strValue = qoutput;
break;
}
@ -414,7 +415,7 @@ void ExtScript::updateValue()
void ExtScript::translate()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));

View File

@ -80,7 +80,6 @@ private slots:
void updateValue();
private:
bool debug;
QProcess *process = nullptr;
Ui::ExtScript *ui;
void translate();

View File

@ -20,23 +20,24 @@
#include <KI18n/KLocalizedString>
#include <QDebug>
#include <QDir>
#include <QRegExp>
#include <QSettings>
#include <QTextCodec>
#include <pdebug/pdebug.h>
#include "awdebug.h"
#include "version.h"
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
const QStringList directories, const bool debugCmd)
: AbstractExtItem(parent, upgradeName, directories, debugCmd),
debug(debugCmd),
ui(new Ui::ExtUpgrade)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
readConfiguration();
ui->setupUi(this);
translate();
@ -51,7 +52,7 @@ ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
ExtUpgrade::~ExtUpgrade()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
process->kill();
delete process;
@ -61,10 +62,10 @@ ExtUpgrade::~ExtUpgrade()
ExtUpgrade *ExtUpgrade::copy(const QString fileName, const int number)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), fileName,
directories(), debug);
directories(), LOG_ESM().isDebugEnabled());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setComment(comment());
@ -81,7 +82,7 @@ ExtUpgrade *ExtUpgrade::copy(const QString fileName, const int number)
QString ExtUpgrade::executable() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_executable;
}
@ -89,7 +90,7 @@ QString ExtUpgrade::executable() const
QString ExtUpgrade::filter() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_filter;
}
@ -97,7 +98,7 @@ QString ExtUpgrade::filter() const
int ExtUpgrade::null() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_null;
}
@ -105,7 +106,7 @@ int ExtUpgrade::null() const
QString ExtUpgrade::uniq() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_executable;
}
@ -113,8 +114,8 @@ QString ExtUpgrade::uniq() const
void ExtUpgrade::setExecutable(const QString _executable)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Executable" << _executable;
m_executable = _executable;
}
@ -122,8 +123,8 @@ void ExtUpgrade::setExecutable(const QString _executable)
void ExtUpgrade::setFilter(const QString _filter)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Filter" << _filter;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Filter" << _filter;
m_filter = _filter;
}
@ -131,8 +132,8 @@ void ExtUpgrade::setFilter(const QString _filter)
void ExtUpgrade::setNull(const int _null)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Null lines" << _null;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Null lines" << _null;
if (_null < 0) return;
m_null = _null;
@ -141,7 +142,7 @@ void ExtUpgrade::setNull(const int _null)
void ExtUpgrade::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
@ -166,7 +167,7 @@ void ExtUpgrade::readConfiguration()
QVariantHash ExtUpgrade::run()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
if (!isActive()) return value;
if ((times == 1) && (process->state() == QProcess::NotRunning))
@ -182,7 +183,7 @@ QVariantHash ExtUpgrade::run()
int ExtUpgrade::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
@ -212,11 +213,11 @@ int ExtUpgrade::showConfiguration(const QVariant args)
void ExtUpgrade::writeConfiguration() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Exec"), m_executable);
@ -230,21 +231,23 @@ void ExtUpgrade::writeConfiguration() const
void ExtUpgrade::updateValue()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process->exitCode();
if (debug) qDebug() << PDEBUG << ":" << "Error" << process->readAllStandardError();
qCDebug(LOG_ESM) << "Cmd returns" << process->exitCode();
qCDebug(LOG_ESM) << "Error" << process->readAllStandardError();
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
value[tag(QString("pkgcount"))] = m_filter.isEmpty() ?
qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null :
qoutput.split(QChar('\n'), QString::SkipEmptyParts).filter(QRegExp(m_filter)).count();
value[tag(QString("pkgcount"))] = [this](QString output) {
return m_filter.isEmpty() ?
output.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null :
output.split(QChar('\n'), QString::SkipEmptyParts).filter(QRegExp(m_filter)).count();
}(qoutput);
}
void ExtUpgrade::translate()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));

View File

@ -60,7 +60,6 @@ private slots:
void updateValue();
private:
bool debug;
QProcess *process = nullptr;
Ui::ExtUpgrade *ui;
void translate();

View File

@ -20,7 +20,6 @@
#include <KI18n/KLocalizedString>
#include <QDebug>
#include <QDir>
#include <QJsonDocument>
#include <QJsonParseError>
@ -28,18 +27,21 @@
#include <QNetworkRequest>
#include <QSettings>
#include <pdebug/pdebug.h>
#include <qreplytimeout/qreplytimeout.h>
#include "awdebug.h"
#include "version.h"
ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
const QStringList directories, const bool debugCmd)
: AbstractExtItem(parent, weatherName, directories, debugCmd),
debug(debugCmd),
ui(new Ui::ExtWeather)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
readConfiguration();
ui->setupUi(this);
translate();
@ -58,7 +60,7 @@ ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
ExtWeather::~ExtWeather()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
disconnect(manager, SIGNAL(finished(QNetworkReply *)),
this, SLOT(weatherReplyReceived(QNetworkReply *)));
@ -70,10 +72,10 @@ ExtWeather::~ExtWeather()
ExtWeather *ExtWeather::copy(const QString fileName, const int number)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), fileName,
directories(), debug);
directories(), LOG_ESM().isDebugEnabled());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setCity(city());
@ -90,8 +92,8 @@ ExtWeather *ExtWeather::copy(const QString fileName, const int number)
QString ExtWeather::weatherFromInt(const int _id) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "ID" << _id;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "ID" << _id;
// refer to http://openweathermap.org/weather-conditions
QString weather;
@ -190,7 +192,7 @@ QString ExtWeather::weatherFromInt(const int _id) const
QString ExtWeather::city() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_city;
}
@ -198,7 +200,7 @@ QString ExtWeather::city() const
QString ExtWeather::country() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_country;
}
@ -206,7 +208,7 @@ QString ExtWeather::country() const
int ExtWeather::ts() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_ts;
}
@ -214,7 +216,7 @@ int ExtWeather::ts() const
QString ExtWeather::uniq() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts);
}
@ -222,8 +224,8 @@ QString ExtWeather::uniq() const
void ExtWeather::setCity(const QString _city)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "City" << _city;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "City" << _city;
m_city = _city;
}
@ -231,8 +233,8 @@ void ExtWeather::setCity(const QString _city)
void ExtWeather::setCountry(const QString _country)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Country" << _country;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Country" << _country;
m_country = _country;
}
@ -240,8 +242,8 @@ void ExtWeather::setCountry(const QString _country)
void ExtWeather::setTs(const int _ts)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Timestamp" << _ts;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Timestamp" << _ts;
m_ts = _ts;
}
@ -249,7 +251,7 @@ void ExtWeather::setTs(const int _ts)
void ExtWeather::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
@ -273,11 +275,11 @@ void ExtWeather::readConfiguration()
QVariantHash ExtWeather::run()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
if ((!isActive()) || (isRunning)) return values;
if (times == 1) {
if (debug) qDebug() << PDEBUG << ":" << "Send request";
qCDebug(LOG_ESM) << "Send request";
isRunning = true;
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url(m_ts != 0))));
new QReplyTimeout(reply, 1000);
@ -294,7 +296,7 @@ QVariantHash ExtWeather::run()
int ExtWeather::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
@ -324,11 +326,11 @@ int ExtWeather::showConfiguration(const QVariant args)
void ExtWeather::writeConfiguration() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-City"), m_city);
@ -342,24 +344,24 @@ void ExtWeather::writeConfiguration() const
void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Return code" << reply->error();
if (debug) qDebug() << PDEBUG << ":" << "Reply error message" << reply->errorString();
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Return code" << reply->error();
qCDebug(LOG_ESM) << "Reply error message" << reply->errorString();
isRunning = false;
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
if ((reply->error() != QNetworkReply::NoError) ||
(error.error != QJsonParseError::NoError)) {
qCWarning(LOG_ESM) << "Parse error" << error.errorString();
return;
}
// convert to map
QVariantMap json = jsonDoc.toVariant().toMap();
if (json[QString("cod")].toInt() != 200) {
if (debug) qDebug() << PDEBUG << ":" << "Invalid return code";
qCWarning(LOG_ESM) << "Invalid return code";
return;
}
@ -376,7 +378,7 @@ void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
QVariantHash ExtWeather::parseSingleJson(const QVariantMap json) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QVariantHash output;
@ -402,7 +404,7 @@ QVariantHash ExtWeather::parseSingleJson(const QVariantMap json) const
void ExtWeather::translate()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
@ -417,13 +419,13 @@ void ExtWeather::translate()
QString ExtWeather::url(const bool isForecast) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << "Is forecast" << isForecast;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "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);
if (debug) qDebug() << PDEBUG << ":" << "API url" << apiUrl;
qCDebug(LOG_ESM) << "API url" << apiUrl;
return apiUrl;
}

View File

@ -65,7 +65,6 @@ private slots:
void weatherReplyReceived(QNetworkReply *reply);
private:
bool debug;
QNetworkAccessManager *manager;
bool isRunning = false;
Ui::ExtWeather *ui;

View File

@ -22,24 +22,25 @@
#include <QBuffer>
#include <QColorDialog>
#include <QDebug>
#include <QDir>
#include <QGraphicsEllipseItem>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QSettings>
#include <pdebug/pdebug.h>
#include "awdebug.h"
#include "version.h"
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
const QStringList directories, const bool debugCmd)
: AbstractExtItem(parent, desktopName, directories, debugCmd),
debug(debugCmd),
ui(new Ui::GraphicalItem)
{
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debugCmd);
qSetMessagePattern(LOG_FORMAT);
readConfiguration();
ui->setupUi(this);
translate();
@ -51,7 +52,7 @@ GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
GraphicalItem::~GraphicalItem()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
delete ui;
}
@ -59,10 +60,10 @@ GraphicalItem::~GraphicalItem()
GraphicalItem *GraphicalItem::copy(const QString fileName, const int number)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()),
fileName, directories(), debug);
fileName, directories(), LOG_ESM().isDebugEnabled());
item->setActive(isActive());
item->setActiveColor(activeColor());
item->setApiVersion(apiVersion());
@ -83,8 +84,8 @@ GraphicalItem *GraphicalItem::copy(const QString fileName, const int number)
QString GraphicalItem::image(const float value) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Value" << value;
if (m_bar == QString("none")) return QString("");
QColor active = stringToColor(m_activeColor);
@ -163,7 +164,7 @@ QString GraphicalItem::image(const float value) const
QString GraphicalItem::bar() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_bar;
}
@ -171,7 +172,7 @@ QString GraphicalItem::bar() const
QString GraphicalItem::activeColor() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_activeColor;
}
@ -179,7 +180,7 @@ QString GraphicalItem::activeColor() const
QString GraphicalItem::inactiveColor() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_inactiveColor;
}
@ -187,7 +188,7 @@ QString GraphicalItem::inactiveColor() const
QString GraphicalItem::tag() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return name() + m_bar;
}
@ -195,7 +196,7 @@ QString GraphicalItem::tag() const
GraphicalItem::Type GraphicalItem::type() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_type;
}
@ -203,7 +204,7 @@ GraphicalItem::Type GraphicalItem::type() const
QString GraphicalItem::strType() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString value;
switch (m_type) {
@ -224,7 +225,7 @@ QString GraphicalItem::strType() const
GraphicalItem::Direction GraphicalItem::direction() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_direction;
}
@ -232,7 +233,7 @@ GraphicalItem::Direction GraphicalItem::direction() const
QString GraphicalItem::strDirection() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString value;
switch (m_direction) {
@ -250,7 +251,7 @@ QString GraphicalItem::strDirection() const
int GraphicalItem::height() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_height;
}
@ -258,7 +259,7 @@ int GraphicalItem::height() const
int GraphicalItem::width() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_width;
}
@ -266,7 +267,7 @@ int GraphicalItem::width() const
QString GraphicalItem::uniq() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
return m_bar;
}
@ -274,8 +275,8 @@ QString GraphicalItem::uniq() const
void GraphicalItem::setBar(const QString _bar)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Bar" << _bar;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Bar" << _bar;
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
(!_bar.contains(QRegExp(QString("gpu")))) &&
@ -291,8 +292,8 @@ void GraphicalItem::setBar(const QString _bar)
void GraphicalItem::setActiveColor(const QString _color)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Color" << _color;
m_activeColor = _color;
}
@ -300,8 +301,8 @@ void GraphicalItem::setActiveColor(const QString _color)
void GraphicalItem::setInactiveColor(const QString _color)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Color" << _color;
m_inactiveColor = _color;
}
@ -309,8 +310,8 @@ void GraphicalItem::setInactiveColor(const QString _color)
void GraphicalItem::setType(const Type _type)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Type" << _type;
m_type = _type;
}
@ -318,8 +319,8 @@ void GraphicalItem::setType(const Type _type)
void GraphicalItem::setStrType(const QString _type)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Type" << _type;
if (_type == QString("Vertical"))
setType(Vertical);
@ -332,8 +333,8 @@ void GraphicalItem::setStrType(const QString _type)
void GraphicalItem::setDirection(const Direction _direction)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Direction" << _direction;
m_direction = _direction;
}
@ -341,8 +342,8 @@ void GraphicalItem::setDirection(const Direction _direction)
void GraphicalItem::setStrDirection(const QString _direction)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Direction" << _direction;
if (_direction == QString("RightToLeft"))
setDirection(RightToLeft);
@ -353,8 +354,8 @@ void GraphicalItem::setStrDirection(const QString _direction)
void GraphicalItem::setHeight(const int _height)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Height" << _height;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Height" << _height;
if (_height <= 0) return;
m_height = _height;
@ -363,8 +364,8 @@ void GraphicalItem::setHeight(const int _height)
void GraphicalItem::setWidth(const int _width)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Width" << _width;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Width" << _width;
if (_width <= 0) return;
m_width = _width;
@ -373,7 +374,7 @@ void GraphicalItem::setWidth(const int _width)
void GraphicalItem::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
@ -403,7 +404,7 @@ void GraphicalItem::readConfiguration()
QVariantHash GraphicalItem::run()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
// required by abstract class
return QVariantHash();
@ -412,7 +413,7 @@ QVariantHash GraphicalItem::run()
int GraphicalItem::showConfiguration(const QVariant args)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QStringList tags = args.toStringList();
ui->label_nameValue->setText(name());
@ -448,11 +449,11 @@ int GraphicalItem::showConfiguration(const QVariant args)
void GraphicalItem::writeConfiguration() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
qCDebug(LOG_ESM) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Value"), m_bar);
@ -470,7 +471,7 @@ void GraphicalItem::writeConfiguration() const
void GraphicalItem::changeColor()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
@ -482,14 +483,15 @@ void GraphicalItem::changeColor()
colorText.append(QString("%1").arg(newColor.green()));
colorText.append(QString("%1").arg(newColor.blue()));
colorText.append(QString("%1").arg(newColor.alpha()));
static_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
return static_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
}
QColor GraphicalItem::stringToColor(const QString _color) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Color" << _color;
QColor qcolor;
QStringList listColor = _color.split(QChar(','));
@ -506,7 +508,7 @@ QColor GraphicalItem::stringToColor(const QString _color) const
void GraphicalItem::translate()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));

View File

@ -90,7 +90,6 @@ private slots:
private:
QString m_fileName;
QStringList m_dirs;
bool debug;
Ui::GraphicalItem *ui;
QColor stringToColor(const QString _color) const;
void translate();

View File

@ -111,6 +111,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[about::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -230,6 +230,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[activeapp::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -255,6 +255,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[advanced::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -230,6 +230,6 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[inactiveapp::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -108,11 +108,11 @@ Item {
}
onNeedUpdate: {
if (debug) console.log("[main::onNeedUpdate]")
if (debug) console.log("")
for (var i=0; i<repeater.count; i++) {
if (!repeater.itemAt(i)) {
if (debug) console.log("[main::onNeedUpdate] : Nothing to do here " + i)
if (debug) console.log("Nothing to do here " + i)
timer.start()
return
}
@ -138,7 +138,7 @@ Item {
}
onNeedTooltipUpdate: {
if (debug) console.log("[main::onNeedTooltipUpdate]")
if (debug) console.log("")
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("[main::onSizeUpdate]")
if (debug) console.log("")
if (plasmoid.configuration.height == 0) {
var newHeight = 0
@ -171,14 +171,14 @@ Item {
}
Plasmoid.onActivated: {
if (debug) console.log("[main::onActivated]")
if (debug) console.log("")
// dpAdds.changePanelsState()
}
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.log("[main::onUserConfiguringChanged]")
if (debug) console.log("")
dpAdds.setMark(plasmoid.configuration.mark)
dpAdds.setPanelsToControl(plasmoid.configuration.panels)
@ -188,7 +188,7 @@ Item {
}
Component.onCompleted: {
if (debug) console.log("[main::onCompleted]")
if (debug) console.log("")
// init submodule
Plasmoid.userConfiguringChanged(false)

View File

@ -59,7 +59,7 @@ Item {
iconName: "font"
onClicked: {
if (debug) console.log("[widget::onClicked] : Font button")
if (debug) console.log("Font button")
var defaultFont = {
"color": plasmoid.configuration.fontColor,
@ -81,7 +81,7 @@ Item {
iconName: "format-indent-more"
onClicked: {
if (debug) console.log("[widget::onClicked] : Indent button")
if (debug) console.log("Indent button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -95,7 +95,7 @@ Item {
iconName: "format-text-bold"
onClicked: {
if (debug) console.log("[widget::onClicked] : Bold button")
if (debug) console.log("Bold button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -108,7 +108,7 @@ Item {
iconName: "format-text-italic"
onClicked: {
if (debug) console.log("[widget::onClicked] : Italic button")
if (debug) console.log("Italic button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -121,7 +121,7 @@ Item {
iconName: "format-text-underline"
onClicked: {
if (debug) console.log("[widget::onClicked] : Underline button")
if (debug) console.log("Underline button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -134,7 +134,7 @@ Item {
iconName: "format-text-strikethrough"
onClicked: {
if (debug) console.log("[widget::onClicked] : Strike button")
if (debug) console.log("Strike button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -148,7 +148,7 @@ Item {
iconName: "format-justify-left"
onClicked: {
if (debug) console.log("[widget::onClicked] : Left button")
if (debug) console.log("Left button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -161,7 +161,7 @@ Item {
iconName: "format-justify-center"
onClicked: {
if (debug) console.log("[widget::onClicked] : Center button")
if (debug) console.log("Center button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -174,7 +174,7 @@ Item {
iconName: "format-justify-right"
onClicked: {
if (debug) console.log("[widget::onClicked] : Right button")
if (debug) console.log("Right button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -187,7 +187,7 @@ Item {
iconName: "format-justify-fill"
onClicked: {
if (debug) console.log("[widget::onClicked] : Justify button")
if (debug) console.log("Justify button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -210,7 +210,7 @@ Item {
text: i18n("Add")
onClicked: {
if (debug) console.log("[widget::onClicked] : Add tag button")
if (debug) console.log("Add tag button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
@ -223,7 +223,7 @@ Item {
text: i18n("Show value")
onClicked: {
if (debug) console.log("[widget::onClicked] : Show tag button")
if (debug) console.log("Show tag button")
var message = i18n("Tag: %1", tags.currentText)
message += "<br>"
@ -244,6 +244,6 @@ Item {
Component.onCompleted: {
if (debug) console.log("[widget::onCompleted]")
if (debug) console.log("")
}
}

View File

@ -11,8 +11,7 @@ include_directories(
${Kf5_INCLUDE}
)
file(GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
file(GLOB SUBPROJECT_NOTIFY *.notifyrc)
add_library(${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})

View File

@ -22,7 +22,6 @@
#include <KWindowSystem/KWindowSystem>
#include <QBuffer>
#include <QDebug>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QGraphicsView>
@ -34,21 +33,22 @@
#include <QScreen>
#include <fontdialog/fontdialog.h>
#include <pdebug/pdebug.h>
#include <pdebug/pdebug-time.h>
#include "awdebug.h"
#include "version.h"
DPAdds::DPAdds(QObject *parent)
: QObject(parent)
{
qInstallMessageHandler(debugString);
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
bool debug = (debugEnv == QString("yes"));
// logging
const_cast<QLoggingCategory &>(LOG_DP()).setEnabled(QtMsgType::QtDebugMsg, debug);
qSetMessagePattern(LOG_FORMAT);
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SIGNAL(desktopChanged()));
connect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), this, SIGNAL(windowListChanged()));
@ -58,21 +58,21 @@ DPAdds::DPAdds(QObject *parent)
DPAdds::~DPAdds()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
}
bool DPAdds::isDebugEnabled() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
return debug;
return LOG_DP().isDebugEnabled();
}
int DPAdds::currentDesktop() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
return KWindowSystem::currentDesktop();
}
@ -80,7 +80,7 @@ int DPAdds::currentDesktop() const
QStringList DPAdds::dictKeys() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
QStringList allKeys;
allKeys.append(QString("mark"));
@ -94,7 +94,7 @@ QStringList DPAdds::dictKeys() const
int DPAdds::numberOfDesktops() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
return KWindowSystem::numberOfDesktops();
}
@ -102,8 +102,8 @@ int DPAdds::numberOfDesktops() const
QString DPAdds::toolTipImage(const int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Desktop" << desktop;
if (tooltipType == QString("none")) return QString();
// prepare
@ -181,7 +181,7 @@ QString DPAdds::toolTipImage(const int desktop) const
QString DPAdds::parsePattern(const QString pattern, const int desktop) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
QString parsed = pattern;
parsed.replace(QString("$$"), QString("$\\$\\"));
@ -195,8 +195,8 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop) const
void DPAdds::setMark(const QString newMark)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Mark" << newMark;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Mark" << newMark;
mark = newMark;
}
@ -204,8 +204,8 @@ void DPAdds::setMark(const QString newMark)
void DPAdds::setPanelsToControl(const QString newPanels)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Panels" << newPanels;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Panels" << newPanels;
panelsToControl.clear();
if (newPanels == QString("-1")) {
@ -220,8 +220,8 @@ void DPAdds::setPanelsToControl(const QString newPanels)
void DPAdds::setToolTipData(const QVariantMap tooltipData)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Data" << tooltipData;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Data" << tooltipData;
tooltipColor = tooltipData[QString("tooltipColor")].toString();
tooltipType = tooltipData[QString("tooltipType")].toString();
@ -231,8 +231,8 @@ void DPAdds::setToolTipData(const QVariantMap tooltipData)
QString DPAdds::valueByKey(const QString key, int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Requested key" << key;
if (desktop == -1) desktop = currentDesktop();
QString currentMark = currentDesktop() == desktop ? mark : QString("");
@ -252,7 +252,7 @@ QString DPAdds::valueByKey(const QString key, int desktop) const
QString DPAdds::editPanelsToContol(const QString current)
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
// paint
QDialog *dialog = new QDialog(nullptr);
@ -302,8 +302,8 @@ QString DPAdds::editPanelsToContol(const QString current)
QString DPAdds::getAboutText(const QString type) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Type" << type;
QString text;
if (type == QString("header"))
@ -341,7 +341,7 @@ QString DPAdds::getAboutText(const QString type) const
QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
QVariantMap fontMap;
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
@ -359,7 +359,7 @@ QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
void DPAdds::changePanelsState() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
if (panelsToControl.isEmpty()) return;
// QList<Plasma::Containment *> panels = getPanels();
@ -368,12 +368,12 @@ void DPAdds::changePanelsState() const
// bool wasVisible = panels.at(i)->view()->isVisible();
// int winId = panels.at(i)->view()->winId();
// if (wasVisible) {
// if (debug) qDebug() << PDEBUG << ":" << "Hide panel";
// qCDebug(LOG_DP) << "Hide panel";
// KWindowInfo oldInfo = KWindowSystem::windowInfo(winId, NET::WMState);
// oldState = oldInfo.state();
// panels.at(i)->view()->setVisible(false);
// } else {
// if (debug) qDebug() << PDEBUG << ":" << "Show panel";
// qCDebug(LOG_DP) << "Show panel";
// panels.at(i)->view()->setVisible(true);
// KWindowSystem::clearState(winId, NET::KeepAbove);
// KWindowSystem::setState(winId, oldState | NET::StaysOnTop);
@ -386,6 +386,10 @@ void DPAdds::changePanelsState() const
void DPAdds::sendNotification(const QString eventId, const QString message)
{
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Event" << eventId;
qCDebug(LOG_DP) << "Message" << message;
KNotification *notification = KNotification::event(eventId, QString("Desktop Panel ::: %1").arg(eventId), message);
notification->setComponentName(QString("plasma-applet-org.kde.plasma.desktop-panel"));
}
@ -393,8 +397,8 @@ void DPAdds::sendNotification(const QString eventId, const QString message)
void DPAdds::setCurrentDesktop(const int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Desktop" << desktop;
KWindowSystem::setCurrentDesktop(desktop);
}
@ -402,8 +406,8 @@ void DPAdds::setCurrentDesktop(const int desktop) const
DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int desktop) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Desktop" << desktop;
DesktopWindowsInfo info;
@ -433,7 +437,7 @@ DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int desktop) const
QList<Plasma::Containment *> DPAdds::getPanels() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_DP);
// Plasma::Corona *corona = new Plasma::Corona(this);
QList<Plasma::Containment *> panels;
@ -449,8 +453,8 @@ QList<Plasma::Containment *> DPAdds::getPanels() const
QString DPAdds::panelLocationToStr(Plasma::Types::Location location) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Location" << location;
qCDebug(LOG_DP);
qCDebug(LOG_DP) << "Location" << location;
switch (location) {
case Plasma::Types::Location::TopEdge:

View File

@ -76,7 +76,6 @@ private:
QList<Plasma::Containment *> getPanels() const;
QString panelLocationToStr(Plasma::Types::Location location) const;
// variables
bool debug = false;
int oldState, tooltipWidth = 200;
QString mark = QString("*");
QString tooltipColor = QString("#000000");

View File

@ -16,8 +16,7 @@ include_directories(
file(GLOB SUBPROJECT_DESKTOP_IN *.desktop)
file(RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
file(GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
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)

View File

@ -24,7 +24,6 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusMessage>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QNetworkInterface>
@ -34,10 +33,9 @@
#include <QSettings>
#include <QStandardPaths>
#include <pdebug/pdebug.h>
#include <pdebug/pdebug-time.h>
#include <task/taskadds.h>
#include "awdebug.h"
#include "extquotes.h"
#include "extscript.h"
#include "extupgrade.h"
@ -49,12 +47,15 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
: Plasma::DataEngine(parent, args)
{
Q_UNUSED(args)
qInstallMessageHandler(debugString);
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
bool debug = (debugEnv == QString("yes"));
// logging
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtDebugMsg, debug);
qSetMessagePattern(LOG_FORMAT);
setMinimumPollingInterval(333);
readConfiguration();
@ -68,7 +69,7 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
ExtendedSysMon::~ExtendedSysMon()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
delete extQuotes;
delete extScripts;
@ -79,21 +80,21 @@ ExtendedSysMon::~ExtendedSysMon()
QStringList ExtendedSysMon::getAllHdd() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
for (int i=0; i<devices.count(); i++)
devices[i] = QString("/dev/%1").arg(devices.at(i));
if (debug) qDebug() << PDEBUG << ":" << "Device list" << devices;
qCDebug(LOG_ESM) << "Device list" << devices;
return devices;
}
QString ExtendedSysMon::getAutoGpu() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString gpu = QString("disable");
QFile moduleFile(QString("/proc/modules"));
@ -105,21 +106,21 @@ QString ExtendedSysMon::getAutoGpu() const
else if (output.contains(QString("nvidia")))
gpu = QString("nvidia");
if (debug) qDebug() << PDEBUG << ":" << "Device" << gpu;
qCDebug(LOG_ESM) << "Device" << gpu;
return gpu;
}
QString ExtendedSysMon::getAutoMpris() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, QString("ListNames"));
if (listServices.arguments().isEmpty()) return QString();
QStringList arguments = listServices.arguments().first().toStringList();
foreach(QString arg, arguments) {
if (debug) qDebug() << PDEBUG << ":" << "Service found" << arg;
qCDebug(LOG_ESM) << "Service found" << arg;
if (!arg.startsWith(QString("org.mpris.MediaPlayer2."))) continue;
QString service = arg;
service.remove(QString("org.mpris.MediaPlayer2."));
@ -132,7 +133,7 @@ QString ExtendedSysMon::getAutoMpris() const
QStringList ExtendedSysMon::sources() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QStringList source;
source.append(QString("battery"));
@ -149,18 +150,18 @@ QStringList ExtendedSysMon::sources() const
source.append(QString("update"));
source.append(QString("weather"));
if (debug) qDebug() << PDEBUG << ":" << "Sources" << source;
qCDebug(LOG_ESM) << "Sources" << source;
return source;
}
void ExtendedSysMon::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation,
QString("plasma-dataengine-extsysmon.conf"));
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
qCDebug(LOG_ESM) << "Configuration file" << fileName;
QSettings settings(fileName, QSettings::IniFormat);
QHash<QString, QString> rawConfig;
@ -181,7 +182,7 @@ void ExtendedSysMon::readConfiguration()
QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QString> rawConfig) const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
// gpudev
if (rawConfig[QString("GPUDEV")] == QString("disable"))
@ -216,15 +217,15 @@ QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QStri
rawConfig[QString("PLAYER")] = QString("mpris");
foreach(QString key, rawConfig.keys())
if (debug) qDebug() << PDEBUG << ":" << key << "=" << rawConfig[key];
qCDebug(LOG_ESM) << key << "=" << rawConfig[key];
return rawConfig;
}
QVariantHash ExtendedSysMon::getBattery(const QString acpiPath) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "ACPI path" << acpiPath;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "ACPI path" << acpiPath;
QVariantHash battery;
battery[QString("ac")] = false;
@ -266,7 +267,7 @@ QVariantHash ExtendedSysMon::getBattery(const QString acpiPath) const
QVariantHash ExtendedSysMon::getCurrentDesktop() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
int number = KWindowSystem::currentDesktop();
int total = KWindowSystem::numberOfDesktops();
@ -284,8 +285,8 @@ QVariantHash ExtendedSysMon::getCurrentDesktop() const
float ExtendedSysMon::getGpu(const QString device) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Device" << device;
float value = 0.0;
if ((device != QString("nvidia")) && (device != QString("ati")))
@ -295,10 +296,10 @@ float ExtendedSysMon::getGpu(const QString device) const
cmd = QString("nvidia-smi -q -x");
else if (device == QString("ati"))
cmd = QString("aticonfig --od-getclocks");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
qCDebug(LOG_ESM) << "cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
qCDebug(LOG_ESM) << "Error" << process.error;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
if (configuration[QString("GPUDEV")] == QString("nvidia"))
@ -324,8 +325,8 @@ float ExtendedSysMon::getGpu(const QString device) const
float ExtendedSysMon::getGpuTemp(const QString device) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Device" << device;
float value = 0.0;
if ((device != QString("nvidia")) && (device != QString("ati")))
@ -335,10 +336,10 @@ float ExtendedSysMon::getGpuTemp(const QString device) const
cmd = QString("nvidia-smi -q -x");
else if (device == QString("ati"))
cmd = QString("aticonfig --od-gettemperature");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
qCDebug(LOG_ESM) << "cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
qCDebug(LOG_ESM) << "Error" << process.error;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
if (configuration[QString("GPUDEV")] == QString("nvidia"))
@ -362,17 +363,17 @@ float ExtendedSysMon::getGpuTemp(const QString device) const
float ExtendedSysMon::getHddTemp(const QString cmd, const QString device) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "cmd" << cmd;
qCDebug(LOG_ESM) << "Device" << device;
float value = 0.0;
TaskResult process = runTask(QString("%1 %2").arg(cmd).arg(device));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
qCDebug(LOG_ESM) << "Error" << process.error;
bool smartctl = cmd.contains(QString("smartctl"));
if (debug) qDebug() << PDEBUG << ":" << "Define smartctl" << smartctl;
qCDebug(LOG_ESM) << "Define smartctl" << smartctl;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
if (smartctl) {
@ -396,7 +397,7 @@ float ExtendedSysMon::getHddTemp(const QString cmd, const QString device) const
QString ExtendedSysMon::getNetworkDevice() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QString device = QString("lo");
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
@ -415,10 +416,10 @@ QString ExtendedSysMon::getNetworkDevice() const
QVariantHash ExtendedSysMon::getPlayerInfo(const QString playerName, const QString mpdAddress,
const QString mpdPort, QString mpris) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "player" << playerName;
if (debug) qDebug() << PDEBUG << ":" << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
if (debug) qDebug() << PDEBUG << ":" << "MPRIS" << mpris;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "player" << playerName;
qCDebug(LOG_ESM) << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
qCDebug(LOG_ESM) << "MPRIS" << mpris;
QVariantHash info;
info[QString("album")] = QString("unknown");
@ -443,8 +444,8 @@ QVariantHash ExtendedSysMon::getPlayerInfo(const QString playerName, const QStri
QVariantHash ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress, const QString mpdPort) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "MPD" << QString("%1:%2").arg(mpdAddress).arg(mpdPort);
QVariantHash info;
info[QString("album")] = QString("unknown");
@ -456,10 +457,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);
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
qCDebug(LOG_ESM) << "cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
qCDebug(LOG_ESM) << "Cmd returns" << process.exitCode;
qCDebug(LOG_ESM) << "Error" << process.error;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
foreach(QString str, qoutput.split(QChar('\n'), QString::SkipEmptyParts)) {
@ -482,8 +483,8 @@ QVariantHash ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress, const QS
QVariantHash ExtendedSysMon::getPlayerMprisInfo(const QString mpris) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << "MPRIS" << mpris;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "MPRIS" << mpris;
QVariantHash info;
info[QString("album")] = QString("unknown");
@ -505,7 +506,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())) {
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
qCDebug(LOG_ESM) << "Error message" << response.errorMessage();
} else {
// another portion of dirty magic
QVariantHash map = qdbus_cast<QVariantHash>(response.arguments().first()
@ -523,7 +524,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())) {
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
qCDebug(LOG_ESM) << "Error message" << response.errorMessage();
} else
// this cast is simpler than the previous one ;)
info[QString("progress")] = response.arguments().first().value<QDBusVariant>()
@ -535,7 +536,7 @@ QVariantHash ExtendedSysMon::getPlayerMprisInfo(const QString mpris) const
QVariantHash ExtendedSysMon::getPsStats() const
{
if (debug) qDebug() << PDEBUG;
qCDebug(LOG_ESM);
QStringList allDirectories = QDir(QString("/proc")).entryList(QDir::Dirs | QDir::NoDotAndDotDot,
QDir::Name);
@ -563,8 +564,8 @@ QVariantHash ExtendedSysMon::getPsStats() const
bool ExtendedSysMon::sourceRequestEvent(const QString &source)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Source" << source;
return updateSourceEvent(source);
}
@ -572,8 +573,8 @@ bool ExtendedSysMon::sourceRequestEvent(const QString &source)
bool ExtendedSysMon::updateSourceEvent(const QString &source)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
qCDebug(LOG_ESM);
qCDebug(LOG_ESM) << "Source" << source;
if (source == QString("battery")) {
QVariantHash battery = getBattery(configuration[QString("ACPIPATH")]);

View File

@ -63,7 +63,6 @@ private:
ExtItemAggregator<ExtScript> *extScripts;
ExtItemAggregator<ExtUpgrade> *extUpgrade;
ExtItemAggregator<ExtWeather> *extWeather;
bool debug;
// reread configuration
QStringList getAllHdd() const;
QString getAutoGpu() const;