mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-03 00:45:56 +00:00
start moving to qt5 style logging
This commit is contained in:
@ -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)
|
||||
|
@ -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"));
|
||||
|
@ -71,7 +71,6 @@ public slots:
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
virtual void translate() = 0;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
|
@ -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();
|
||||
|
@ -53,7 +53,6 @@ private slots:
|
||||
void editItemButtonPressed(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QVariant m_configArgs;
|
||||
// methods
|
||||
virtual void copyItem() = 0;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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"));
|
||||
|
@ -80,7 +80,6 @@ private slots:
|
||||
void updateValue();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QProcess *process = nullptr;
|
||||
Ui::ExtScript *ui;
|
||||
void translate();
|
||||
|
@ -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"));
|
||||
|
@ -60,7 +60,6 @@ private slots:
|
||||
void updateValue();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QProcess *process = nullptr;
|
||||
Ui::ExtUpgrade *ui;
|
||||
void translate();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ private slots:
|
||||
void weatherReplyReceived(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QNetworkAccessManager *manager;
|
||||
bool isRunning = false;
|
||||
Ui::ExtWeather *ui;
|
||||
|
@ -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"));
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user