From 085eec7a3d294f5f7816c6ef6dfe2327198d31ce Mon Sep 17 00:00:00 2001 From: Evgeniy Alekseev Date: Wed, 6 Jul 2016 14:23:01 +0300 Subject: [PATCH] some fixes inside extensions * do not use private variables if there are special methods * change macro call from `aw_*` to `aw_macro_*` * add forgotten configuration reading/writting for list formatter --- .../plugin/awpatternfunctions.cpp | 4 +- sources/awesomewidgets/abstractextitem.cpp | 39 +++--- .../awesomewidgets/awabstractformatter.cpp | 2 +- .../awesomewidgets/awdatetimeformatter.cpp | 6 +- sources/awesomewidgets/awfloatformatter.cpp | 40 +++--- sources/awesomewidgets/awlistformatter.cpp | 36 +++++ sources/awesomewidgets/awlistformatter.h | 2 + sources/awesomewidgets/awscriptformatter.cpp | 26 ++-- sources/awesomewidgets/extquotes.cpp | 10 +- sources/awesomewidgets/extscript.cpp | 40 +++--- sources/awesomewidgets/extupgrade.cpp | 28 ++-- sources/awesomewidgets/extweather.cpp | 30 ++--- sources/awesomewidgets/graphicalitem.cpp | 124 +++++++++--------- 13 files changed, 213 insertions(+), 174 deletions(-) diff --git a/sources/awesome-widget/plugin/awpatternfunctions.cpp b/sources/awesome-widget/plugin/awpatternfunctions.cpp index 154a258..70bd96c 100644 --- a/sources/awesome-widget/plugin/awpatternfunctions.cpp +++ b/sources/awesome-widget/plugin/awpatternfunctions.cpp @@ -230,8 +230,8 @@ QString AWPatternFunctions::insertMacros(QString code) QString name = macro.args.takeFirst(); // find macro usage QList macroUsage - = AWPatternFunctions::findFunctionCalls(QString("aw_%1").arg(name), - code); + = AWPatternFunctions::findFunctionCalls( + QString("aw_macro_%1").arg(name), code); for (auto function : macroUsage) { if (function.args.count() != macro.args.count()) { qCWarning(LOG_AW) << "Invalid args count found for call" diff --git a/sources/awesomewidgets/abstractextitem.cpp b/sources/awesomewidgets/abstractextitem.cpp index cfed6cb..69a3445 100644 --- a/sources/awesomewidgets/abstractextitem.cpp +++ b/sources/awesomewidgets/abstractextitem.cpp @@ -60,11 +60,11 @@ void AbstractExtItem::bumpApi(const int _newVer) void AbstractExtItem::copyDefaults(AbstractExtItem *_other) const { - _other->setActive(m_active); - _other->setApiVersion(m_apiVersion); - _other->setComment(m_comment); - _other->setInterval(m_interval); - _other->setName(m_name); + _other->setActive(isActive()); + _other->setApiVersion(apiVersion()); + _other->setComment(comment()); + _other->setInterval(interval()); + _other->setName(name()); } @@ -129,7 +129,7 @@ QString AbstractExtItem::tag(const QString _type) const { qCDebug(LOG_LIB) << "Tag type" << _type; - return QString("%1%2").arg(_type).arg(m_number); + return QString("%1%2").arg(_type).arg(number()); } @@ -182,7 +182,8 @@ void AbstractExtItem::setNumber(int _number) if (generateNumber) { _number = []() { qCWarning(LOG_LIB) << "Number is empty, generate new one"; - qsrand(QTime::currentTime().msec()); + // we suppose that currentTIme().msec() is always valid time + qsrand(static_cast(QTime::currentTime().msec())); int n = qrand() % 1000; qCInfo(LOG_LIB) << "Generated number is" << n; return n; @@ -200,15 +201,15 @@ void AbstractExtItem::readConfiguration() QSettings settings(m_fileName, QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setName(settings.value(QString("Name"), m_name).toString()); - setComment(settings.value(QString("Comment"), m_comment).toString()); + setName(settings.value(QString("Name"), name()).toString()); + setComment(settings.value(QString("Comment"), comment()).toString()); setApiVersion( - settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt()); + settings.value(QString("X-AW-ApiVersion"), apiVersion()).toInt()); setActive( - settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() + settings.value(QString("X-AW-Active"), QVariant(isActive())).toString() == QString("true")); - setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt()); - setNumber(settings.value(QString("X-AW-Number"), m_number).toInt()); + setInterval(settings.value(QString("X-AW-Interval"), interval()).toInt()); + setNumber(settings.value(QString("X-AW-Number"), number()).toInt()); settings.endGroup(); } @@ -229,12 +230,12 @@ void AbstractExtItem::writeConfiguration() const settings.beginGroup(QString("Desktop Entry")); settings.setValue(QString("Encoding"), QString("UTF-8")); - settings.setValue(QString("Name"), m_name); - settings.setValue(QString("Comment"), m_comment); - settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion); - settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString()); - settings.setValue(QString("X-AW-Interval"), m_interval); - settings.setValue(QString("X-AW-Number"), m_number); + settings.setValue(QString("Name"), name()); + settings.setValue(QString("Comment"), comment()); + settings.setValue(QString("X-AW-ApiVersion"), apiVersion()); + settings.setValue(QString("X-AW-Active"), QVariant(isActive()).toString()); + settings.setValue(QString("X-AW-Interval"), interval()); + settings.setValue(QString("X-AW-Number"), number()); settings.endGroup(); settings.sync(); diff --git a/sources/awesomewidgets/awabstractformatter.cpp b/sources/awesomewidgets/awabstractformatter.cpp index 4d3c58f..013a3f7 100644 --- a/sources/awesomewidgets/awabstractformatter.cpp +++ b/sources/awesomewidgets/awabstractformatter.cpp @@ -40,7 +40,7 @@ void AWAbstractFormatter::copyDefaults(AbstractExtItem *_other) const { AbstractExtItem::copyDefaults(_other); - static_cast(_other)->setType(m_type); + static_cast(_other)->setType(type()); } diff --git a/sources/awesomewidgets/awdatetimeformatter.cpp b/sources/awesomewidgets/awdatetimeformatter.cpp index dfaa437..65fcffc 100644 --- a/sources/awesomewidgets/awdatetimeformatter.cpp +++ b/sources/awesomewidgets/awdatetimeformatter.cpp @@ -94,7 +94,7 @@ void AWDateTimeFormatter::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setFormat(settings.value(QString("X-AW-Format"), m_format).toString()); + setFormat(settings.value(QString("X-AW-Format"), format()).toString()); settings.endGroup(); bumpApi(AWEFAPI); @@ -108,7 +108,7 @@ int AWDateTimeFormatter::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText(QString("DateTime")); - ui->lineEdit_format->setText(m_format); + ui->lineEdit_format->setText(format()); int ret = exec(); if (ret != 1) @@ -131,7 +131,7 @@ void AWDateTimeFormatter::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Format"), m_format); + settings.setValue(QString("X-AW-Format"), format()); settings.endGroup(); settings.sync(); diff --git a/sources/awesomewidgets/awfloatformatter.cpp b/sources/awesomewidgets/awfloatformatter.cpp index 53a0f5a..c936e86 100644 --- a/sources/awesomewidgets/awfloatformatter.cpp +++ b/sources/awesomewidgets/awfloatformatter.cpp @@ -52,8 +52,8 @@ QString AWFloatFormatter::convert(const QVariant &_value) const { qCDebug(LOG_LIB) << "Convert value" << _value; - return QString("%1").arg(_value.toDouble() * m_multiplier + m_summand, - m_count, m_format, m_precision, m_fillChar); + return QString("%1").arg(_value.toDouble() * multiplier() + summand(), + count(), format(), precision(), fillChar()); } @@ -174,18 +174,18 @@ void AWFloatFormatter::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setCount(settings.value(QString("X-AW-Width"), m_count).toInt()); + setCount(settings.value(QString("X-AW-Width"), count()).toInt()); setFillChar( - settings.value(QString("X-AW-FillChar"), m_fillChar).toString().at(0)); - setFormat(settings.value(QString("X-AW-Format"), QString(m_format)) + settings.value(QString("X-AW-FillChar"), fillChar()).toString().at(0)); + setFormat(settings.value(QString("X-AW-Format"), QString(format())) .toString() .at(0) .toLatin1()); setMultiplier( - settings.value(QString("X-AW-Multiplier"), m_multiplier).toDouble()); + settings.value(QString("X-AW-Multiplier"), multiplier()).toDouble()); setPrecision( - settings.value(QString("X-AW-Precision"), m_precision).toInt()); - setSummand(settings.value(QString("X-AW-Summand"), m_summand).toDouble()); + settings.value(QString("X-AW-Precision"), precision()).toInt()); + setSummand(settings.value(QString("X-AW-Summand"), summand()).toDouble()); settings.endGroup(); bumpApi(AWEFAPI); @@ -200,12 +200,12 @@ int AWFloatFormatter::showConfiguration(const QVariant args) ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText(QString("Float")); ui->comboBox_format->setCurrentIndex( - ui->comboBox_format->findText(QString(m_format))); - ui->spinBox_precision->setValue(m_precision); - ui->spinBox_width->setValue(m_count); - ui->lineEdit_fill->setText(QString(m_fillChar)); - ui->doubleSpinBox_multiplier->setValue(m_multiplier); - ui->doubleSpinBox_summand->setValue(m_summand); + ui->comboBox_format->findText(QString(format()))); + ui->spinBox_precision->setValue(precision()); + ui->spinBox_width->setValue(count()); + ui->lineEdit_fill->setText(QString(fillChar())); + ui->doubleSpinBox_multiplier->setValue(multiplier()); + ui->doubleSpinBox_summand->setValue(summand()); int ret = exec(); if (ret != 1) @@ -233,12 +233,12 @@ void AWFloatFormatter::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Width"), m_count); - settings.setValue(QString("X-AW-FillChar"), m_fillChar); - settings.setValue(QString("X-AW-Format"), m_format); - settings.setValue(QString("X-AW-Multiplier"), m_multiplier); - settings.setValue(QString("X-AW-Precision"), m_precision); - settings.setValue(QString("X-AW-Summand"), m_summand); + settings.setValue(QString("X-AW-Width"), count()); + settings.setValue(QString("X-AW-FillChar"), fillChar()); + settings.setValue(QString("X-AW-Format"), format()); + settings.setValue(QString("X-AW-Multiplier"), multiplier()); + settings.setValue(QString("X-AW-Precision"), precision()); + settings.setValue(QString("X-AW-Summand"), summand()); settings.endGroup(); settings.sync(); diff --git a/sources/awesomewidgets/awlistformatter.cpp b/sources/awesomewidgets/awlistformatter.cpp index c513598..40e2239 100644 --- a/sources/awesomewidgets/awlistformatter.cpp +++ b/sources/awesomewidgets/awlistformatter.cpp @@ -21,6 +21,8 @@ #include +#include + #include "awdebug.h" @@ -117,6 +119,23 @@ void AWListFormatter::setSorted(const bool _sorted) } +void AWListFormatter::readConfiguration() +{ + AWAbstractFormatter::readConfiguration(); + + QSettings settings(fileName(), QSettings::IniFormat); + + settings.beginGroup(QString("Desktop Entry")); + setFilter(settings.value(QString("X-AW-Filter"), filter()).toString()); + setSeparator( + settings.value(QString("X-AW-Separator"), separator()).toString()); + setSorted(settings.value(QString("X-AW-Sort"), isSorted()).toBool()); + settings.endGroup(); + + bumpApi(AWEFAPI); +} + + int AWListFormatter::showConfiguration(const QVariant args) { Q_UNUSED(args) @@ -144,6 +163,23 @@ int AWListFormatter::showConfiguration(const QVariant args) } +void AWListFormatter::writeConfiguration() const +{ + AWAbstractFormatter::writeConfiguration(); + + QSettings settings(writtableConfig(), QSettings::IniFormat); + qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); + + settings.beginGroup(QString("Desktop Entry")); + settings.setValue(QString("X-AW-Filter"), filter()); + settings.setValue(QString("X-AW-Separator"), separator()); + settings.setValue(QString("X-AW-Sort"), isSorted()); + settings.endGroup(); + + settings.sync(); +} + + void AWListFormatter::translate() { ui->label_name->setText(i18n("Name")); diff --git a/sources/awesomewidgets/awlistformatter.h b/sources/awesomewidgets/awlistformatter.h index ebc384d..36438a6 100644 --- a/sources/awesomewidgets/awlistformatter.h +++ b/sources/awesomewidgets/awlistformatter.h @@ -48,7 +48,9 @@ public: void setSorted(const bool _sorted); public slots: + void readConfiguration(); int showConfiguration(const QVariant args = QVariant()); + void writeConfiguration() const; private: Ui::AWListFormatter *ui = nullptr; diff --git a/sources/awesomewidgets/awscriptformatter.cpp b/sources/awesomewidgets/awscriptformatter.cpp index e06ef23..380b9ee 100644 --- a/sources/awesomewidgets/awscriptformatter.cpp +++ b/sources/awesomewidgets/awscriptformatter.cpp @@ -146,10 +146,10 @@ void AWScriptFormatter::readConfiguration() settings.beginGroup(QString("Desktop Entry")); setAppendCode( - settings.value(QString("X-AW-AppendCode"), m_appendCode).toBool()); - setCode(settings.value(QString("X-AW-Code"), m_code).toString()); + settings.value(QString("X-AW-AppendCode"), appendCode()).toBool()); + setCode(settings.value(QString("X-AW-Code"), code()).toString()); setHasReturn( - settings.value(QString("X-AW-HasReturn"), m_hasReturn).toBool()); + settings.value(QString("X-AW-HasReturn"), hasReturn()).toBool()); settings.endGroup(); bumpApi(AWEFAPI); @@ -163,11 +163,11 @@ int AWScriptFormatter::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_typeValue->setText(QString("Script")); - ui->checkBox_appendCode->setCheckState(m_appendCode ? Qt::Checked + ui->checkBox_appendCode->setCheckState(appendCode() ? Qt::Checked : Qt::Unchecked); - ui->checkBox_hasReturn->setCheckState(m_hasReturn ? Qt::Checked + ui->checkBox_hasReturn->setCheckState(hasReturn() ? Qt::Checked : Qt::Unchecked); - ui->textEdit_code->setPlainText(m_code); + ui->textEdit_code->setPlainText(code()); int ret = exec(); if (ret != 1) @@ -193,9 +193,9 @@ void AWScriptFormatter::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-AppendCode"), m_appendCode); - settings.setValue(QString("X-AW-Code"), m_code); - settings.setValue(QString("X-AW-HasReturn"), m_hasReturn); + settings.setValue(QString("X-AW-AppendCode"), appendCode()); + settings.setValue(QString("X-AW-Code"), code()); + settings.setValue(QString("X-AW-HasReturn"), hasReturn()); settings.endGroup(); settings.sync(); @@ -205,13 +205,13 @@ void AWScriptFormatter::writeConfiguration() const void AWScriptFormatter::initProgram() { // init JS code - if (m_appendCode) + if (appendCode()) m_program = QString("(function(value) { %1%2 })") - .arg(m_code) - .arg(m_hasReturn ? QString("") : QString("; return output;")); + .arg(code()) + .arg(hasReturn() ? QString("") : QString("; return output;")); else - m_program = m_code; + m_program = code(); qCInfo(LOG_LIB) << "Create JS engine with code" << m_program; } diff --git a/sources/awesomewidgets/extquotes.cpp b/sources/awesomewidgets/extquotes.cpp index 525d45c..830636b 100644 --- a/sources/awesomewidgets/extquotes.cpp +++ b/sources/awesomewidgets/extquotes.cpp @@ -96,7 +96,7 @@ QString ExtQuotes::ticker() const QString ExtQuotes::uniq() const { - return m_ticker; + return ticker(); } @@ -116,7 +116,7 @@ void ExtQuotes::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString()); + setTicker(settings.value(QString("X-AW-Ticker"), ticker()).toString()); settings.endGroup(); // update for current API @@ -159,7 +159,7 @@ int ExtQuotes::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->lineEdit_ticker->setText(m_ticker); + ui->lineEdit_ticker->setText(ticker()); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->spinBox_interval->setValue(interval()); @@ -188,7 +188,7 @@ void ExtQuotes::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Ticker"), m_ticker); + settings.setValue(QString("X-AW-Ticker"), ticker()); settings.endGroup(); settings.sync(); @@ -260,7 +260,7 @@ void ExtQuotes::initUrl() params.addQueryItem(QString("env"), QString("store://datatables.org/alltableswithkeys")); params.addQueryItem(QString("q"), - QString(YAHOO_QUOTES_QUERY).arg(m_ticker)); + QString(YAHOO_QUOTES_QUERY).arg(ticker())); m_url.setQuery(params); } diff --git a/sources/awesomewidgets/extscript.cpp b/sources/awesomewidgets/extscript.cpp index fd5179a..b090721 100644 --- a/sources/awesomewidgets/extscript.cpp +++ b/sources/awesomewidgets/extscript.cpp @@ -104,14 +104,14 @@ ExtScript::Redirect ExtScript::redirect() const QString ExtScript::uniq() const { - return m_executable; + return executable(); } QString ExtScript::strRedirect() const { QString value; - switch (m_redirect) { + switch (redirect()) { case Redirect::stdout2stderr: value = QString("stdout2stderr"); break; @@ -182,7 +182,7 @@ QString ExtScript::applyFilters(QString _value) const { qCDebug(LOG_LIB) << "Value" << _value; - for (auto filt : m_filters) { + for (auto filt : filters()) { qCInfo(LOG_LIB) << "Found filter" << filt; QVariantMap filter = jsonFilters[filt].toMap(); if (filter.isEmpty()) { @@ -203,7 +203,7 @@ void ExtScript::updateFilter(const QString _filter, const bool _add) qCDebug(LOG_LIB) << "Should be added filters" << _add << "from" << _filter; if (_add) { - if (m_filters.contains(_filter)) + if (filters().contains(_filter)) return; m_filters.append(_filter); } else { @@ -219,12 +219,12 @@ void ExtScript::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setExecutable(settings.value(QString("Exec"), m_executable).toString()); - setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString()); + setExecutable(settings.value(QString("Exec"), executable()).toString()); + setPrefix(settings.value(QString("X-AW-Prefix"), prefix()).toString()); setStrRedirect( settings.value(QString("X-AW-Redirect"), strRedirect()).toString()); // api == 3 - setFilters(settings.value(QString("X-AW-Filters"), m_filters) + setFilters(settings.value(QString("X-AW-Filters"), filters()) .toString() .split(QChar(','), QString::SkipEmptyParts)); settings.endGroup(); @@ -270,9 +270,9 @@ QVariantHash ExtScript::run() if ((times == 1) && (process->state() == QProcess::NotRunning)) { QStringList cmdList; - if (!m_prefix.isEmpty()) - cmdList.append(m_prefix); - cmdList.append(m_executable); + if (!prefix().isEmpty()) + cmdList.append(prefix()); + cmdList.append(executable()); qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' ')); process->start(cmdList.join(QChar(' '))); } @@ -293,19 +293,19 @@ int ExtScript::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->lineEdit_command->setText(m_executable); - ui->lineEdit_prefix->setText(m_prefix); + ui->lineEdit_command->setText(executable()); + ui->lineEdit_prefix->setText(prefix()); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); - ui->comboBox_redirect->setCurrentIndex(static_cast(m_redirect)); + ui->comboBox_redirect->setCurrentIndex(static_cast(redirect())); ui->spinBox_interval->setValue(interval()); // filters ui->checkBox_colorFilter->setCheckState( - m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked); + filters().contains(QString("color")) ? Qt::Checked : Qt::Unchecked); ui->checkBox_linesFilter->setCheckState( - m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked); + filters().contains(QString("newline")) ? Qt::Checked : Qt::Unchecked); ui->checkBox_spaceFilter->setCheckState( - m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked); + filters().contains(QString("space")) ? Qt::Checked : Qt::Unchecked); int ret = exec(); if (ret != 1) @@ -340,10 +340,10 @@ void ExtScript::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("Exec"), m_executable); - settings.setValue(QString("X-AW-Prefix"), m_prefix); + settings.setValue(QString("Exec"), executable()); + settings.setValue(QString("X-AW-Prefix"), prefix()); settings.setValue(QString("X-AW-Redirect"), strRedirect()); - settings.setValue(QString("X-AW-Filters"), m_filters.join(QChar(','))); + settings.setValue(QString("X-AW-Filters"), filters().join(QChar(','))); settings.endGroup(); settings.sync(); @@ -363,7 +363,7 @@ void ExtScript::updateValue() qCInfo(LOG_LIB) << "Output" << qoutput; QString strValue; - switch (m_redirect) { + switch (redirect()) { case Redirect::stdout2stderr: break; case Redirect::stderr2stdout: diff --git a/sources/awesomewidgets/extupgrade.cpp b/sources/awesomewidgets/extupgrade.cpp index 951d4d1..f3f8381 100644 --- a/sources/awesomewidgets/extupgrade.cpp +++ b/sources/awesomewidgets/extupgrade.cpp @@ -93,7 +93,7 @@ int ExtUpgrade::null() const QString ExtUpgrade::uniq() const { - return m_executable; + return executable(); } @@ -130,10 +130,10 @@ void ExtUpgrade::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setExecutable(settings.value(QString("Exec"), m_executable).toString()); - setNull(settings.value(QString("X-AW-Null"), m_null).toInt()); + setExecutable(settings.value(QString("Exec"), executable()).toString()); + setNull(settings.value(QString("X-AW-Null"), null()).toInt()); // api == 3 - setFilter(settings.value(QString("X-AW-Filter"), m_filter).toString()); + setFilter(settings.value(QString("X-AW-Filter"), filter()).toString()); settings.endGroup(); bumpApi(AWEUAPI); @@ -146,7 +146,7 @@ QVariantHash ExtUpgrade::run() return value; if ((times == 1) && (process->state() == QProcess::NotRunning)) { - QString cmd = QString("sh -c \"%1\"").arg(m_executable); + QString cmd = QString("sh -c \"%1\"").arg(executable()); qCInfo(LOG_LIB) << "Run cmd" << cmd; process->start(cmd); } @@ -167,11 +167,11 @@ int ExtUpgrade::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->lineEdit_command->setText(m_executable); - ui->lineEdit_filter->setText(m_filter); + ui->lineEdit_command->setText(executable()); + ui->lineEdit_filter->setText(filter()); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); - ui->spinBox_null->setValue(m_null); + ui->spinBox_null->setValue(null()); ui->spinBox_interval->setValue(interval()); int ret = exec(); @@ -200,9 +200,9 @@ void ExtUpgrade::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("Exec"), m_executable); - settings.setValue(QString("X-AW-Filter"), m_filter); - settings.setValue(QString("X-AW-Null"), m_null); + settings.setValue(QString("Exec"), executable()); + settings.setValue(QString("X-AW-Filter"), filter()); + settings.setValue(QString("X-AW-Null"), null()); settings.endGroup(); settings.sync(); @@ -218,11 +218,11 @@ void ExtUpgrade::updateValue() ->toUnicode(process->readAllStandardOutput()) .trimmed(); value[tag(QString("pkgcount"))] = [this](QString output) { - return m_filter.isEmpty() + return filter().isEmpty() ? output.split(QChar('\n'), QString::SkipEmptyParts).count() - - m_null + - null() : output.split(QChar('\n'), QString::SkipEmptyParts) - .filter(QRegExp(m_filter)) + .filter(QRegExp(filter())) .count(); }(qoutput); diff --git a/sources/awesomewidgets/extweather.cpp b/sources/awesomewidgets/extweather.cpp index 456d893..d09f3a6 100644 --- a/sources/awesomewidgets/extweather.cpp +++ b/sources/awesomewidgets/extweather.cpp @@ -150,7 +150,7 @@ int ExtWeather::ts() const QString ExtWeather::uniq() const { - return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts); + return QString("%1 (%2) at %3").arg(city()).arg(country()).arg(ts()); } @@ -216,11 +216,11 @@ void ExtWeather::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setCity(settings.value(QString("X-AW-City"), m_city).toString()); - setCountry(settings.value(QString("X-AW-Country"), m_country).toString()); - setTs(settings.value(QString("X-AW-TS"), m_ts).toInt()); + setCity(settings.value(QString("X-AW-City"), city()).toString()); + setCountry(settings.value(QString("X-AW-Country"), country()).toString()); + setTs(settings.value(QString("X-AW-TS"), ts()).toInt()); // api == 2 - setImage(settings.value(QString("X-AW-Image"), QVariant(m_image)).toString() + setImage(settings.value(QString("X-AW-Image"), QVariant(image())).toString() == QString("true")); // api == 3 setStrProvider( @@ -286,11 +286,11 @@ int ExtWeather::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->comboBox_provider->setCurrentIndex(static_cast(m_provider)); - ui->lineEdit_city->setText(m_city); - ui->lineEdit_country->setText(m_country); - ui->spinBox_timestamp->setValue(m_ts); - ui->checkBox_image->setCheckState(m_image ? Qt::Checked : Qt::Unchecked); + ui->comboBox_provider->setCurrentIndex(static_cast(provider())); + ui->lineEdit_city->setText(city()); + ui->lineEdit_country->setText(country()); + ui->spinBox_timestamp->setValue(ts()); + ui->checkBox_image->setCheckState(image() ? Qt::Checked : Qt::Unchecked); ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked); ui->spinBox_interval->setValue(interval()); @@ -323,11 +323,11 @@ void ExtWeather::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-City"), m_city); - settings.setValue(QString("X-AW-Country"), m_country); - settings.setValue(QString("X-AW-Image"), m_image); + settings.setValue(QString("X-AW-City"), city()); + settings.setValue(QString("X-AW-Country"), country()); + settings.setValue(QString("X-AW-Image"), image()); settings.setValue(QString("X-AW-Provider"), strProvider()); - settings.setValue(QString("X-AW-TS"), m_ts); + settings.setValue(QString("X-AW-TS"), ts()); settings.endGroup(); settings.sync(); @@ -373,7 +373,7 @@ void ExtWeather::initProvider() break; } - return m_providerObject->initUrl(m_city, m_country, m_ts); + return m_providerObject->initUrl(city(), country(), ts()); } diff --git a/sources/awesomewidgets/graphicalitem.cpp b/sources/awesomewidgets/graphicalitem.cpp index d236cdc..8a9c32c 100644 --- a/sources/awesomewidgets/graphicalitem.cpp +++ b/sources/awesomewidgets/graphicalitem.cpp @@ -71,18 +71,18 @@ GraphicalItem *GraphicalItem::copy(const QString _fileName, const int _number) GraphicalItem *item = new GraphicalItem(static_cast(parent()), _fileName); copyDefaults(item); - item->setActiveColor(m_activeColor); - item->setBar(m_bar); - item->setCount(m_count); - item->setCustom(m_custom); - item->setDirection(m_direction); - item->setItemHeight(m_height); - item->setInactiveColor(m_inactiveColor); - item->setMaxValue(m_maxValue); - item->setMinValue(m_minValue); + item->setActiveColor(activeColor()); + item->setBar(bar()); + item->setCount(count()); + item->setCustom(isCustom()); + item->setDirection(direction()); + item->setItemHeight(itemHeight()); + item->setInactiveColor(inactiveColor()); + item->setMaxValue(maxValue()); + item->setMinValue(minValue()); item->setNumber(_number); - item->setType(m_type); - item->setItemWidth(m_width); + item->setType(type()); + item->setItemWidth(itemWidth()); return item; } @@ -95,34 +95,34 @@ QString GraphicalItem::image(const QVariant &value) m_scene->clear(); int scale[2] = {1, 1}; float converted - = m_helper->getPercents(value.toFloat(), m_minValue, m_maxValue); + = m_helper->getPercents(value.toFloat(), minValue(), maxValue()); // paint switch (m_type) { case Type::Vertical: m_helper->paintVertical(converted); // scale - scale[1] = -2 * static_cast(m_direction) + 1; + scale[1] = -2 * static_cast(direction()) + 1; break; case Type::Circle: m_helper->paintCircle(converted); // scale - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; break; case Type::Graph: m_helper->paintGraph(converted); - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; scale[1] = -1; break; case Type::Bars: m_helper->paintBars(converted); - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; scale[1] = -1; break; case Type::Horizontal: m_helper->paintHorizontal(converted); // scale - scale[0] = -2 * static_cast(m_direction) + 1; + scale[0] = -2 * static_cast(direction()) + 1; break; } @@ -159,8 +159,8 @@ void GraphicalItem::initScene() // init helper m_helper = new GraphicalItemHelper(this, m_scene); - m_helper->setParameters(m_activeColor, m_inactiveColor, m_width, m_height, - m_count); + m_helper->setParameters(activeColor(), inactiveColor(), itemWidth(), + itemHeight(), count()); } @@ -227,7 +227,7 @@ GraphicalItem::Type GraphicalItem::type() const QString GraphicalItem::strType() const { QString value; - switch (m_type) { + switch (type()) { case Type::Vertical: value = QString("Vertical"); break; @@ -258,7 +258,7 @@ GraphicalItem::Direction GraphicalItem::direction() const QString GraphicalItem::strDirection() const { QString value; - switch (m_direction) { + switch (direction()) { case Direction::RightToLeft: value = QString("RightToLeft"); break; @@ -279,7 +279,7 @@ QStringList GraphicalItem::usedKeys() const QString GraphicalItem::uniq() const { - return m_bar; + return bar(); } @@ -411,11 +411,11 @@ void GraphicalItem::setUsedKeys(const QStringList _usedKeys) // remove dubs // HACK converting to set may break order - m_usedKeys.clear(); + usedKeys().clear(); for (auto key : _usedKeys) { - if (m_usedKeys.contains(key)) + if (usedKeys().contains(key)) continue; - m_usedKeys.append(key); + usedKeys().append(key); } } @@ -427,31 +427,31 @@ void GraphicalItem::readConfiguration() QSettings settings(fileName(), QSettings::IniFormat); settings.beginGroup(QString("Desktop Entry")); - setCount(settings.value(QString("X-AW-Count"), m_count).toInt()); - setCustom(settings.value(QString("X-AW-Custom"), m_custom).toBool()); - setBar(settings.value(QString("X-AW-Value"), m_bar).toString()); - setMaxValue(settings.value(QString("X-AW-Max"), m_maxValue).toFloat()); - setMinValue(settings.value(QString("X-AW-Min"), m_minValue).toFloat()); + setCount(settings.value(QString("X-AW-Count"), count()).toInt()); + setCustom(settings.value(QString("X-AW-Custom"), isCustom()).toBool()); + setBar(settings.value(QString("X-AW-Value"), bar()).toString()); + setMaxValue(settings.value(QString("X-AW-Max"), maxValue()).toFloat()); + setMinValue(settings.value(QString("X-AW-Min"), minValue()).toFloat()); setActiveColor( - settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString()); + settings.value(QString("X-AW-ActiveColor"), activeColor()).toString()); setInactiveColor( - settings.value(QString("X-AW-InactiveColor"), m_inactiveColor) + settings.value(QString("X-AW-InactiveColor"), inactiveColor()) .toString()); setStrType(settings.value(QString("X-AW-Type"), strType()).toString()); setStrDirection( settings.value(QString("X-AW-Direction"), strDirection()).toString()); - setItemHeight(settings.value(QString("X-AW-Height"), m_height).toInt()); - setItemWidth(settings.value(QString("X-AW-Width"), m_width).toInt()); + setItemHeight(settings.value(QString("X-AW-Height"), itemHeight()).toInt()); + setItemWidth(settings.value(QString("X-AW-Width"), itemWidth()).toInt()); // api == 5 if (apiVersion() < 5) { QString prefix; - prefix = m_activeColor.startsWith(QString("/")) ? QString("file://%1") + prefix = activeColor().startsWith(QString("/")) ? QString("file://%1") : QString("color://%1"); - m_activeColor = prefix.arg(m_activeColor); - prefix = m_inactiveColor.startsWith(QString("/")) + m_activeColor = prefix.arg(activeColor()); + prefix = inactiveColor().startsWith(QString("/")) ? QString("file://%1") : QString("color://%1"); - m_inactiveColor = prefix.arg(m_inactiveColor); + m_inactiveColor = prefix.arg(inactiveColor()); } settings.endGroup(); @@ -468,31 +468,31 @@ int GraphicalItem::showConfiguration(const QVariant args) ui->lineEdit_name->setText(name()); ui->lineEdit_comment->setText(comment()); ui->label_numberValue->setText(QString("%1").arg(number())); - ui->checkBox_custom->setChecked(m_custom); + ui->checkBox_custom->setChecked(isCustom()); ui->comboBox_value->addItems(tags); - if (m_custom) { - ui->lineEdit_customValue->setText(m_bar); + if (isCustom()) { + ui->lineEdit_customValue->setText(bar()); } else { - ui->comboBox_value->addItem(m_bar); + ui->comboBox_value->addItem(bar()); ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1); } - ui->doubleSpinBox_max->setValue(m_maxValue); - ui->doubleSpinBox_min->setValue(m_minValue); - ui->spinBox_count->setValue(m_count); - if (m_helper->isColor(m_activeColor)) + ui->doubleSpinBox_max->setValue(maxValue()); + ui->doubleSpinBox_min->setValue(minValue()); + ui->spinBox_count->setValue(count()); + if (m_helper->isColor(activeColor())) ui->comboBox_activeImageType->setCurrentIndex(0); else ui->comboBox_activeImageType->setCurrentIndex(1); - ui->lineEdit_activeColor->setText(m_activeColor); - if (m_helper->isColor(m_inactiveColor)) + ui->lineEdit_activeColor->setText(activeColor()); + if (m_helper->isColor(inactiveColor())) ui->comboBox_inactiveImageType->setCurrentIndex(0); else ui->comboBox_inactiveImageType->setCurrentIndex(1); - ui->lineEdit_inactiveColor->setText(m_inactiveColor); - ui->comboBox_type->setCurrentIndex(static_cast(m_type)); - ui->comboBox_direction->setCurrentIndex(static_cast(m_direction)); - ui->spinBox_height->setValue(m_height); - ui->spinBox_width->setValue(m_width); + ui->lineEdit_inactiveColor->setText(inactiveColor()); + ui->comboBox_type->setCurrentIndex(static_cast(type())); + ui->comboBox_direction->setCurrentIndex(static_cast(direction())); + ui->spinBox_height->setValue(itemHeight()); + ui->spinBox_width->setValue(itemWidth()); // update UI emit(ui->comboBox_type->currentIndexChanged( @@ -532,17 +532,17 @@ void GraphicalItem::writeConfiguration() const qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); settings.beginGroup(QString("Desktop Entry")); - settings.setValue(QString("X-AW-Value"), m_bar); - settings.setValue(QString("X-AW-Count"), m_count); - settings.setValue(QString("X-AW-Custom"), m_custom); - settings.setValue(QString("X-AW-Max"), m_maxValue); - settings.setValue(QString("X-AW-Min"), m_minValue); - settings.setValue(QString("X-AW-ActiveColor"), m_activeColor); - settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor); + settings.setValue(QString("X-AW-Value"), bar()); + settings.setValue(QString("X-AW-Count"), count()); + settings.setValue(QString("X-AW-Custom"), isCustom()); + settings.setValue(QString("X-AW-Max"), maxValue()); + settings.setValue(QString("X-AW-Min"), minValue()); + settings.setValue(QString("X-AW-ActiveColor"), activeColor()); + settings.setValue(QString("X-AW-InactiveColor"), inactiveColor()); settings.setValue(QString("X-AW-Type"), strType()); settings.setValue(QString("X-AW-Direction"), strDirection()); - settings.setValue(QString("X-AW-Height"), m_height); - settings.setValue(QString("X-AW-Width"), m_width); + settings.setValue(QString("X-AW-Height"), itemHeight()); + settings.setValue(QString("X-AW-Width"), itemWidth()); settings.endGroup(); settings.sync();