mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-22 18:19:56 +00:00
system source, some code improvements
This commit is contained in:
@ -21,17 +21,17 @@
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <utility>
|
||||
|
||||
#include "awabstractselector.h"
|
||||
#include "awdebug.h"
|
||||
|
||||
|
||||
AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, const bool _hasEdit,
|
||||
const QStringList &_keys)
|
||||
AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, const bool _hasEdit, QStringList _keys)
|
||||
: QDialog(_parent)
|
||||
, ui(new Ui::AWAbstractPairConfig)
|
||||
, m_hasEdit(_hasEdit)
|
||||
, m_keys(_keys)
|
||||
, m_keys(std::move(_keys))
|
||||
{
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
@ -84,8 +84,8 @@ void AWAbstractPairConfig::edit()
|
||||
|
||||
void AWAbstractPairConfig::updateUi()
|
||||
{
|
||||
QPair<QString, QString> current = static_cast<AWAbstractSelector *>(sender())->current();
|
||||
int index = m_selectors.indexOf(static_cast<AWAbstractSelector *>(sender()));
|
||||
QPair<QString, QString> current = dynamic_cast<AWAbstractSelector *>(sender())->current();
|
||||
int index = m_selectors.indexOf(dynamic_cast<AWAbstractSelector *>(sender()));
|
||||
|
||||
if ((current.first.isEmpty()) && (current.second.isEmpty())) {
|
||||
// remove current selector if it is empty and does not last
|
||||
@ -110,7 +110,7 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringLi
|
||||
qCDebug(LOG_AW) << "Add selector with keys" << _keys << "values" << _values
|
||||
<< "and current ones" << _current;
|
||||
|
||||
AWAbstractSelector *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable);
|
||||
auto *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable);
|
||||
selector->init(_keys, _values, _current);
|
||||
ui->verticalLayout->insertWidget(ui->verticalLayout->count() - 1, selector);
|
||||
connect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi()));
|
||||
|
@ -36,12 +36,12 @@ class AWAbstractPairConfig : public QDialog
|
||||
|
||||
public:
|
||||
explicit AWAbstractPairConfig(QWidget *_parent = nullptr, const bool _hasEdit = false,
|
||||
const QStringList &_keys = QStringList());
|
||||
virtual ~AWAbstractPairConfig();
|
||||
QStringList _keys = QStringList());
|
||||
~AWAbstractPairConfig() override;
|
||||
template <class T> void initHelper()
|
||||
{
|
||||
if (m_helper)
|
||||
delete m_helper;
|
||||
|
||||
delete m_helper;
|
||||
m_helper = new T(this);
|
||||
}
|
||||
void showDialog();
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <utility>
|
||||
|
||||
#include "awdebug.h"
|
||||
|
||||
|
||||
AWAbstractPairHelper::AWAbstractPairHelper(const QString &_filePath, const QString &_section)
|
||||
: m_filePath(_filePath)
|
||||
, m_section(_section)
|
||||
AWAbstractPairHelper::AWAbstractPairHelper(QString _filePath, QString _section)
|
||||
: m_filePath(std::move(_filePath))
|
||||
, m_section(std::move(_section))
|
||||
{
|
||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
class AWAbstractPairHelper
|
||||
{
|
||||
public:
|
||||
explicit AWAbstractPairHelper(const QString &_filePath = "", const QString &_section = "");
|
||||
explicit AWAbstractPairHelper(QString _filePath = "", QString _section = "");
|
||||
virtual ~AWAbstractPairHelper();
|
||||
QStringList keys() const;
|
||||
QHash<QString, QString> pairs() const;
|
||||
|
@ -34,7 +34,7 @@ class AWAbstractSelector : public QWidget
|
||||
public:
|
||||
explicit AWAbstractSelector(QWidget *_parent = nullptr,
|
||||
const QPair<bool, bool> &_editable = {false, false});
|
||||
virtual ~AWAbstractSelector();
|
||||
~AWAbstractSelector() override;
|
||||
QPair<QString, QString> current() const;
|
||||
void init(const QStringList &_keys, const QStringList &_values,
|
||||
const QPair<QString, QString> &_current);
|
||||
|
@ -55,7 +55,7 @@ void AWActions::checkUpdates(const bool _showAnyway)
|
||||
}
|
||||
|
||||
|
||||
QString AWActions::getFileContent(const QString &_path) const
|
||||
QString AWActions::getFileContent(const QString &_path)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Get content from file" << _path;
|
||||
|
||||
@ -72,13 +72,13 @@ QString AWActions::getFileContent(const QString &_path) const
|
||||
|
||||
|
||||
// HACK: since QML could not use QLoggingCategory I need this hack
|
||||
bool AWActions::isDebugEnabled() const
|
||||
bool AWActions::isDebugEnabled()
|
||||
{
|
||||
return LOG_AW().isDebugEnabled();
|
||||
}
|
||||
|
||||
|
||||
bool AWActions::runCmd(const QString &_cmd) const
|
||||
bool AWActions::runCmd(const QString &_cmd)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Cmd" << _cmd;
|
||||
|
||||
@ -89,15 +89,15 @@ bool AWActions::runCmd(const QString &_cmd) const
|
||||
|
||||
|
||||
// HACK: this method uses variable from version.h
|
||||
void AWActions::showReadme() const
|
||||
void AWActions::showReadme()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(HOMEPAGE));
|
||||
}
|
||||
|
||||
|
||||
void AWActions::showLegacyInfo() const
|
||||
void AWActions::showLegacyInfo()
|
||||
{
|
||||
QMessageBox *msgBox = new QMessageBox(nullptr);
|
||||
auto *msgBox = new QMessageBox(nullptr);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->setModal(false);
|
||||
msgBox->setWindowTitle(i18n("Not supported"));
|
||||
@ -110,7 +110,7 @@ void AWActions::showLegacyInfo() const
|
||||
|
||||
|
||||
// HACK: this method uses variables from version.h
|
||||
QString AWActions::getAboutText(const QString &_type) const
|
||||
QString AWActions::getAboutText(const QString &_type)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Type" << _type;
|
||||
|
||||
@ -118,7 +118,7 @@ QString AWActions::getAboutText(const QString &_type) const
|
||||
}
|
||||
|
||||
|
||||
QVariantMap AWActions::getFont(const QVariantMap &_defaultFont) const
|
||||
QVariantMap AWActions::getFont(const QVariantMap &_defaultFont)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Default font is" << _defaultFont;
|
||||
|
||||
|
@ -31,16 +31,16 @@ class AWActions : public QObject
|
||||
|
||||
public:
|
||||
explicit AWActions(QObject *_parent = nullptr);
|
||||
virtual ~AWActions();
|
||||
~AWActions() override;
|
||||
Q_INVOKABLE void checkUpdates(const bool _showAnyway = false);
|
||||
Q_INVOKABLE QString getFileContent(const QString &_path) const;
|
||||
Q_INVOKABLE bool isDebugEnabled() const;
|
||||
Q_INVOKABLE bool runCmd(const QString &_cmd) const;
|
||||
Q_INVOKABLE void showLegacyInfo() const;
|
||||
Q_INVOKABLE void showReadme() const;
|
||||
Q_INVOKABLE static QString getFileContent(const QString &_path);
|
||||
Q_INVOKABLE static bool isDebugEnabled();
|
||||
Q_INVOKABLE static bool runCmd(const QString &_cmd);
|
||||
Q_INVOKABLE static void showLegacyInfo();
|
||||
Q_INVOKABLE static void showReadme();
|
||||
// configuration slots
|
||||
Q_INVOKABLE QString getAboutText(const QString &_type) const;
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap &_defaultFont) const;
|
||||
Q_INVOKABLE static QString getAboutText(const QString &_type);
|
||||
Q_INVOKABLE static QVariantMap getFont(const QVariantMap &_defaultFont);
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE static void sendNotification(const QString &_eventId, const QString &_message);
|
||||
|
@ -50,7 +50,7 @@ void AWBugReporter::doConnect()
|
||||
|
||||
|
||||
QString AWBugReporter::generateText(const QString &_description, const QString &_reproduce,
|
||||
const QString &_expected, const QString &_logs) const
|
||||
const QString &_expected, const QString &_logs)
|
||||
{
|
||||
// do not log _logs here, it may have quite large size
|
||||
qCDebug(LOG_AW) << "Generate text with description" << _description << "steps" << _reproduce
|
||||
@ -72,7 +72,7 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Send bug report with title" << _title << "and body" << _body;
|
||||
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr);
|
||||
auto *manager = new QNetworkAccessManager(nullptr);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
SLOT(issueReplyRecieved(QNetworkReply *)));
|
||||
|
||||
@ -100,7 +100,7 @@ void AWBugReporter::issueReplyRecieved(QNetworkReply *_reply)
|
||||
return emit(replyReceived(0, ""));
|
||||
}
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonParseError error{};
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(LOG_AW) << "Parse error" << error.errorString();
|
||||
@ -124,7 +124,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
|
||||
// cache url first
|
||||
m_lastBugUrl = _url;
|
||||
|
||||
QMessageBox *msgBox = new QMessageBox(nullptr);
|
||||
auto *msgBox = new QMessageBox(nullptr);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->setModal(false);
|
||||
msgBox->setWindowTitle(i18n("Issue created"));
|
||||
@ -138,7 +138,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
|
||||
|
||||
void AWBugReporter::userReplyOnBugReport(QAbstractButton *_button)
|
||||
{
|
||||
QMessageBox::ButtonRole ret = static_cast<QMessageBox *>(sender())->buttonRole(_button);
|
||||
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
|
||||
qCInfo(LOG_AW) << "User select" << ret;
|
||||
|
||||
switch (ret) {
|
||||
|
@ -31,10 +31,10 @@ class AWBugReporter : public QObject
|
||||
|
||||
public:
|
||||
explicit AWBugReporter(QObject *_parent = nullptr);
|
||||
virtual ~AWBugReporter();
|
||||
~AWBugReporter() override;
|
||||
Q_INVOKABLE void doConnect();
|
||||
Q_INVOKABLE QString generateText(const QString &_description, const QString &_reproduce,
|
||||
const QString &_expected, const QString &_logs) const;
|
||||
Q_INVOKABLE static QString generateText(const QString &_description, const QString &_reproduce,
|
||||
const QString &_expected, const QString &_logs);
|
||||
Q_INVOKABLE void sendBugReport(const QString &_title, const QString &_body);
|
||||
|
||||
signals:
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
#include "awconfighelper.h"
|
||||
|
||||
#include <KI18n/KLocalizedString>
|
||||
|
||||
#include <QDir>
|
||||
#include <QQmlPropertyMap>
|
||||
#include <QSettings>
|
||||
@ -62,7 +60,7 @@ QString AWConfigHelper::configurationDirectory() const
|
||||
}
|
||||
|
||||
|
||||
bool AWConfigHelper::dropCache() const
|
||||
bool AWConfigHelper::dropCache()
|
||||
{
|
||||
QString fileName
|
||||
= QString("%1/awesomewidgets.ndx")
|
||||
@ -78,7 +76,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
|
||||
|
||||
QSettings settings(_fileName, QSettings::IniFormat);
|
||||
// plasmoid configuration
|
||||
const QQmlPropertyMap *configuration = static_cast<const QQmlPropertyMap *>(_nativeConfig);
|
||||
const auto *configuration = dynamic_cast<const QQmlPropertyMap *>(_nativeConfig);
|
||||
settings.beginGroup("plasmoid");
|
||||
for (auto &key : configuration->keys()) {
|
||||
QVariant value = configuration->value(key);
|
||||
@ -173,7 +171,7 @@ QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName,
|
||||
}
|
||||
|
||||
|
||||
QVariantMap AWConfigHelper::readDataEngineConfiguration() const
|
||||
QVariantMap AWConfigHelper::readDataEngineConfiguration()
|
||||
{
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation,
|
||||
"plasma-dataengine-extsysmon.conf");
|
||||
@ -199,7 +197,7 @@ QVariantMap AWConfigHelper::readDataEngineConfiguration() const
|
||||
}
|
||||
|
||||
|
||||
bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configuration) const
|
||||
bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configuration)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Configuration" << _configuration;
|
||||
|
||||
@ -226,7 +224,7 @@ bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configurat
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::copyConfigs(const QString &_localDir) const
|
||||
void AWConfigHelper::copyConfigs(const QString &_localDir)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Local directory" << _localDir;
|
||||
|
||||
@ -268,15 +266,14 @@ void AWConfigHelper::copyExtensions(const QString &_item, const QString &_type,
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::copySettings(QSettings &_from, QSettings &_to) const
|
||||
void AWConfigHelper::copySettings(QSettings &_from, QSettings &_to)
|
||||
{
|
||||
for (auto &key : _from.childKeys())
|
||||
_to.setValue(key, _from.value(key));
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::readFile(QSettings &_settings, const QString &_key,
|
||||
const QString &_fileName) const
|
||||
void AWConfigHelper::readFile(QSettings &_settings, const QString &_key, const QString &_fileName)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << _key << "from file" << _fileName;
|
||||
|
||||
@ -291,8 +288,7 @@ void AWConfigHelper::readFile(QSettings &_settings, const QString &_key,
|
||||
}
|
||||
|
||||
|
||||
void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key,
|
||||
const QString &_fileName) const
|
||||
void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key, const QString &_fileName)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Key" << _key << "to file" << _fileName;
|
||||
|
||||
|
@ -31,26 +31,26 @@ class AWConfigHelper : public QObject
|
||||
|
||||
public:
|
||||
explicit AWConfigHelper(QObject *_parent = nullptr);
|
||||
virtual ~AWConfigHelper();
|
||||
~AWConfigHelper() override;
|
||||
Q_INVOKABLE QString configurationDirectory() const;
|
||||
Q_INVOKABLE bool dropCache() const;
|
||||
Q_INVOKABLE static bool dropCache();
|
||||
Q_INVOKABLE bool exportConfiguration(QObject *_nativeConfig, const QString &_fileName) const;
|
||||
Q_INVOKABLE QVariantMap importConfiguration(const QString &_fileName,
|
||||
const bool _importPlasmoid,
|
||||
const bool _importExtensions,
|
||||
const bool _importAdds) const;
|
||||
// dataengine
|
||||
Q_INVOKABLE QVariantMap readDataEngineConfiguration() const;
|
||||
Q_INVOKABLE bool writeDataEngineConfiguration(const QVariantMap &_configuration) const;
|
||||
Q_INVOKABLE static QVariantMap readDataEngineConfiguration();
|
||||
Q_INVOKABLE static bool writeDataEngineConfiguration(const QVariantMap &_configuration);
|
||||
|
||||
private:
|
||||
// methods
|
||||
void copyConfigs(const QString &_localDir) const;
|
||||
static void copyConfigs(const QString &_localDir);
|
||||
void copyExtensions(const QString &_item, const QString &_type, QSettings &_settings,
|
||||
const bool _inverse) const;
|
||||
void copySettings(QSettings &_from, QSettings &_to) const;
|
||||
void readFile(QSettings &_settings, const QString &_key, const QString &_fileName) const;
|
||||
void writeFile(QSettings &_settings, const QString &_key, const QString &_fileName) const;
|
||||
static void copySettings(QSettings &_from, QSettings &_to);
|
||||
static void readFile(QSettings &_settings, const QString &_key, const QString &_fileName);
|
||||
static void writeFile(QSettings &_settings, const QString &_key, const QString &_fileName);
|
||||
// properties
|
||||
QString m_baseDir;
|
||||
QStringList m_dirs = {"desktops", "quotes", "scripts", "upgrade", "weather", "formatters"};
|
||||
|
@ -29,7 +29,7 @@ class AWCustomKeysConfig : public AWAbstractPairConfig
|
||||
public:
|
||||
explicit AWCustomKeysConfig(QWidget *_parent = nullptr,
|
||||
const QStringList &_keys = QStringList());
|
||||
virtual ~AWCustomKeysConfig();
|
||||
~AWCustomKeysConfig() override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -30,15 +30,15 @@ class AWCustomKeysHelper : public QObject, public AWAbstractPairHelper
|
||||
|
||||
public:
|
||||
explicit AWCustomKeysHelper(QObject *_parent = nullptr);
|
||||
virtual ~AWCustomKeysHelper();
|
||||
~AWCustomKeysHelper() override;
|
||||
// get
|
||||
QString source(const QString &_key) const;
|
||||
QStringList sources() const;
|
||||
QStringList refinedSources() const;
|
||||
// configuration related
|
||||
virtual void editPairs(){};
|
||||
virtual QStringList leftKeys();
|
||||
virtual QStringList rightKeys();
|
||||
void editPairs() override{};
|
||||
QStringList leftKeys() override;
|
||||
QStringList rightKeys() override;
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -54,7 +54,7 @@ AWDataAggregator::~AWDataAggregator()
|
||||
}
|
||||
|
||||
|
||||
QString AWDataAggregator::htmlImage(const QPixmap &_source) const
|
||||
QString AWDataAggregator::htmlImage(const QPixmap &_source)
|
||||
{
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
@ -195,7 +195,7 @@ void AWDataAggregator::initScene()
|
||||
}
|
||||
|
||||
|
||||
QString AWDataAggregator::notificationText(const QString &_source, const float _value) const
|
||||
QString AWDataAggregator::notificationText(const QString &_source, const float _value)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value;
|
||||
|
||||
@ -215,7 +215,7 @@ QString AWDataAggregator::notificationText(const QString &_source, const float _
|
||||
}
|
||||
|
||||
|
||||
QString AWDataAggregator::notificationText(const QString &_source, const QString &_value) const
|
||||
QString AWDataAggregator::notificationText(const QString &_source, const QString &_value)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Notification source" << _source << "with value" << _value;
|
||||
|
||||
@ -246,10 +246,7 @@ void AWDataAggregator::setData(const QVariantHash &_values)
|
||||
m_currentNetworkDevice = value;
|
||||
}(_values["netdev"].toString());
|
||||
// additional check for GPU load
|
||||
[this](const float value) {
|
||||
checkValue("gpu", value, 90.0);
|
||||
m_currentGPULoad = value;
|
||||
}(_values["gpu"].toFloat());
|
||||
[this](const float value) { checkValue("gpu", value, 90.0); }(_values["gpu"].toFloat());
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,8 +34,8 @@ class AWDataAggregator : public QObject
|
||||
|
||||
public:
|
||||
explicit AWDataAggregator(QObject *_parent = nullptr);
|
||||
virtual ~AWDataAggregator();
|
||||
QString htmlImage(const QPixmap &_source) const;
|
||||
~AWDataAggregator() override;
|
||||
static QString htmlImage(const QPixmap &_source);
|
||||
void setParameters(const QVariantMap &_settings);
|
||||
QPixmap tooltipImage();
|
||||
|
||||
@ -53,8 +53,8 @@ private:
|
||||
void checkValue(const QString &_source, const QString &_current,
|
||||
const QString &_received) const;
|
||||
void initScene();
|
||||
QString notificationText(const QString &_source, const float _value) const;
|
||||
QString notificationText(const QString &_source, const QString &_value) const;
|
||||
static QString notificationText(const QString &_source, const float _value);
|
||||
static QString notificationText(const QString &_source, const QString &_value);
|
||||
// main method
|
||||
void setData(const QVariantHash &_values);
|
||||
void setData(const QString &_source, float _value, const float _extremum = -1.0f);
|
||||
@ -63,7 +63,6 @@ private:
|
||||
// variables
|
||||
int m_counts = 0;
|
||||
QVariantHash m_configuration;
|
||||
float m_currentGPULoad = 0.0f;
|
||||
QString m_currentNetworkDevice = "lo";
|
||||
QHash<QString, float> m_boundaries;
|
||||
QHash<QString, QList<float>> m_values;
|
||||
|
@ -69,16 +69,16 @@ void AWDataEngineAggregator::reconnectSources(const int _interval)
|
||||
|
||||
disconnectSources();
|
||||
|
||||
m_dataEngines["systemmonitor"]->connectAllSources(parent(), _interval);
|
||||
m_dataEngines["extsysmon"]->connectAllSources(parent(), _interval);
|
||||
m_dataEngines["systemmonitor"]->connectAllSources(parent(), (uint)_interval);
|
||||
m_dataEngines["extsysmon"]->connectAllSources(parent(), (uint)_interval);
|
||||
m_dataEngines["time"]->connectSource("Local", parent(), 1000);
|
||||
|
||||
m_newSourceConnection
|
||||
= connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded,
|
||||
[this, _interval](const QString source) {
|
||||
emit(deviceAdded(source));
|
||||
m_dataEngines["systemmonitor"]->connectSource(source, parent(), _interval);
|
||||
});
|
||||
m_newSourceConnection = connect(
|
||||
m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded,
|
||||
[this, _interval](const QString source) {
|
||||
emit(deviceAdded(source));
|
||||
m_dataEngines["systemmonitor"]->connectSource(source, parent(), (uint)_interval);
|
||||
});
|
||||
|
||||
#ifdef BUILD_FUTURE
|
||||
createQueuedConnection();
|
||||
|
@ -31,7 +31,7 @@ class AWDataEngineAggregator : public QObject
|
||||
|
||||
public:
|
||||
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
||||
virtual ~AWDataEngineAggregator();
|
||||
~AWDataEngineAggregator() override;
|
||||
void disconnectSources();
|
||||
void reconnectSources(const int _interval);
|
||||
|
||||
|
@ -33,7 +33,7 @@ class AWDataEngineMapper : public QObject
|
||||
|
||||
public:
|
||||
explicit AWDataEngineMapper(QObject *_parent = nullptr, AWFormatterHelper *_custom = nullptr);
|
||||
virtual ~AWDataEngineMapper();
|
||||
~AWDataEngineMapper() override;
|
||||
// get methods
|
||||
AWKeysAggregator::FormatterType formatter(const QString &_key) const;
|
||||
QStringList keysFromSource(const QString &_source) const;
|
||||
|
@ -33,7 +33,7 @@ class AWDBusAdaptor : public QDBusAbstractAdaptor
|
||||
|
||||
public:
|
||||
explicit AWDBusAdaptor(AWKeys *_parent = nullptr);
|
||||
virtual ~AWDBusAdaptor();
|
||||
~AWDBusAdaptor() override;
|
||||
|
||||
public slots:
|
||||
// get methods
|
||||
|
@ -28,7 +28,7 @@ class AWPlugin : public QQmlExtensionPlugin
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||
|
||||
public:
|
||||
void registerTypes(const char *uri);
|
||||
void registerTypes(const char *uri) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ class AWFormatterConfig : public AWAbstractPairConfig
|
||||
public:
|
||||
explicit AWFormatterConfig(QWidget *_parent = nullptr,
|
||||
const QStringList &_keys = QStringList());
|
||||
virtual ~AWFormatterConfig();
|
||||
~AWFormatterConfig() override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -122,7 +122,7 @@ void AWFormatterHelper::editItems()
|
||||
|
||||
|
||||
AWAbstractFormatter::FormatterClass
|
||||
AWFormatterHelper::defineFormatterClass(const QString &_stringType) const
|
||||
AWFormatterHelper::defineFormatterClass(const QString &_stringType)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Define formatter class for" << _stringType;
|
||||
|
||||
|
@ -30,29 +30,29 @@ class AWFormatterHelper : public AbstractExtItemAggregator, public AWAbstractPai
|
||||
|
||||
public:
|
||||
explicit AWFormatterHelper(QWidget *_parent = nullptr);
|
||||
virtual ~AWFormatterHelper();
|
||||
~AWFormatterHelper() override;
|
||||
// read-write methods
|
||||
void initItems();
|
||||
void initItems() override;
|
||||
// methods
|
||||
QString convert(const QVariant &_value, const QString &_name) const;
|
||||
QStringList definedFormatters() const;
|
||||
QList<AbstractExtItem *> items() const;
|
||||
QList<AbstractExtItem *> items() const override;
|
||||
// configuration related
|
||||
virtual void editPairs();
|
||||
virtual QStringList leftKeys();
|
||||
virtual QStringList rightKeys();
|
||||
void editPairs() override;
|
||||
QStringList leftKeys() override;
|
||||
QStringList rightKeys() override;
|
||||
|
||||
public slots:
|
||||
void editItems();
|
||||
|
||||
private:
|
||||
// methods
|
||||
AWAbstractFormatter::FormatterClass defineFormatterClass(const QString &_stringType) const;
|
||||
static AWAbstractFormatter::FormatterClass defineFormatterClass(const QString &_stringType);
|
||||
void initFormatters();
|
||||
QPair<QString, AWAbstractFormatter::FormatterClass>
|
||||
readMetadata(const QString &_filePath) const;
|
||||
// parent methods
|
||||
void doCreateItem();
|
||||
void doCreateItem() override;
|
||||
// properties
|
||||
QHash<QString, AWAbstractFormatter *> m_formatters;
|
||||
QHash<QString, AWAbstractFormatter *> m_formattersClasses;
|
||||
|
@ -15,6 +15,7 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "awkeycache.h"
|
||||
|
||||
#include <QDir>
|
||||
|
@ -31,7 +31,7 @@ QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars,
|
||||
const QVariantMap &_tooltip, const QStringList &_userKeys,
|
||||
const QStringList &_allKeys);
|
||||
QHash<QString, QStringList> loadKeysFromCache();
|
||||
};
|
||||
} // namespace AWKeyCache
|
||||
|
||||
|
||||
#endif /* AWKEYCACHE_H */
|
||||
|
@ -39,7 +39,7 @@ class AWKeyOperations : public QObject
|
||||
|
||||
public:
|
||||
explicit AWKeyOperations(QObject *_parent = nullptr);
|
||||
virtual ~AWKeyOperations();
|
||||
~AWKeyOperations() override;
|
||||
QStringList devices(const QString &_type) const;
|
||||
QHash<QString, QStringList> devices() const;
|
||||
void updateCache();
|
||||
|
@ -345,10 +345,9 @@ QString AWKeys::parsePattern(QString _pattern) const
|
||||
// bars
|
||||
for (auto &bar : m_foundBars) {
|
||||
GraphicalItem *item = m_keyOperator->giByKey(bar);
|
||||
QString image = item->isCustom()
|
||||
? item->image(AWPatternFunctions::expandLambdas(
|
||||
item->bar(), m_aggregator, m_values, item->usedKeys()))
|
||||
: item->image(m_values[item->bar()]);
|
||||
QString image = item->isCustom() ? item->image(AWPatternFunctions::expandLambdas(
|
||||
item->bar(), m_aggregator, m_values, item->usedKeys()))
|
||||
: item->image(m_values[item->bar()]);
|
||||
_pattern.replace(QString("$%1").arg(bar), image);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class AWKeys : public QObject
|
||||
|
||||
public:
|
||||
explicit AWKeys(QObject *_parent = nullptr);
|
||||
virtual ~AWKeys();
|
||||
~AWKeys() override;
|
||||
Q_INVOKABLE void initDataAggregator(const QVariantMap &_tooltipParams);
|
||||
Q_INVOKABLE void initKeys(const QString &_currentPattern, const int _interval, const int _limit,
|
||||
const bool _optimize);
|
||||
@ -59,7 +59,7 @@ public:
|
||||
public slots:
|
||||
void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data);
|
||||
// dummy method required by DataEngine connections
|
||||
void modelChanged(QString, QAbstractItemModel *){};
|
||||
static void modelChanged(QString, QAbstractItemModel *){};
|
||||
|
||||
signals:
|
||||
void dropSourceFromDataengine(const QString &_source);
|
||||
|
@ -117,7 +117,7 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key)
|
||||
break;
|
||||
case FormatterType::TimeCustom:
|
||||
output = m_customTime;
|
||||
[&output, loc, this](const QDateTime dt) {
|
||||
[&output, loc, this](const QDateTime &dt) {
|
||||
for (auto &key : m_timeKeys)
|
||||
output.replace(QString("$%1").arg(key), loc.toString(dt, key));
|
||||
}(_data.toDateTime());
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
};
|
||||
|
||||
explicit AWKeysAggregator(QObject *_parent = nullptr);
|
||||
virtual ~AWKeysAggregator();
|
||||
~AWKeysAggregator() override;
|
||||
void initFormatters();
|
||||
// get methods
|
||||
QString formatter(const QVariant &_data, const QString &_key) const;
|
||||
|
@ -37,7 +37,7 @@ AWPairConfigFactory::~AWPairConfigFactory()
|
||||
|
||||
void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys)
|
||||
{
|
||||
AWFormatterConfig *config = new AWFormatterConfig(nullptr, _keys);
|
||||
auto *config = new AWFormatterConfig(nullptr, _keys);
|
||||
config->showDialog();
|
||||
config->deleteLater();
|
||||
}
|
||||
@ -45,7 +45,7 @@ void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys)
|
||||
|
||||
void AWPairConfigFactory::showKeysDialog(const QStringList &_keys)
|
||||
{
|
||||
AWCustomKeysConfig *config = new AWCustomKeysConfig(nullptr, _keys);
|
||||
auto *config = new AWCustomKeysConfig(nullptr, _keys);
|
||||
config->showDialog();
|
||||
config->deleteLater();
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ class AWPairConfigFactory : public QObject
|
||||
|
||||
public:
|
||||
explicit AWPairConfigFactory(QObject *_parent = nullptr);
|
||||
virtual ~AWPairConfigFactory();
|
||||
Q_INVOKABLE void showFormatterDialog(const QStringList &_keys);
|
||||
Q_INVOKABLE void showKeysDialog(const QStringList &_keys);
|
||||
~AWPairConfigFactory() override;
|
||||
Q_INVOKABLE static void showFormatterDialog(const QStringList &_keys);
|
||||
Q_INVOKABLE static void showKeysDialog(const QStringList &_keys);
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -54,7 +54,7 @@ QString AWPatternFunctions::expandTemplates(QString _code)
|
||||
qCDebug(LOG_AW) << "Expand templates in" << _code;
|
||||
|
||||
// match the following construction $template{{some code here}}
|
||||
QRegularExpression templatesRegexp("\\$template\\{\\{(?<body>.*?)\\}\\}");
|
||||
QRegularExpression templatesRegexp(R"(\$template\{\{(?<body>.*?)\}\})");
|
||||
templatesRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
QRegularExpressionMatchIterator it = templatesRegexp.globalMatch(_code);
|
||||
@ -92,8 +92,7 @@ AWPatternFunctions::findFunctionCalls(const QString &_function, const QString &_
|
||||
// in this field if they are not screened by $, i.e. '$,'
|
||||
// * body depends on the function name, double brackets should be screened
|
||||
// by using $, e.g. ${
|
||||
QRegularExpression regex(
|
||||
QString("\\$%1\\<(?<args>.*?)\\>\\{\\{(?<body>.*?)\\}\\}").arg(_function));
|
||||
QRegularExpression regex(QString(R"(\$%1\<(?<args>.*?)\>\{\{(?<body>.*?)\}\})").arg(_function));
|
||||
regex.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
QList<AWPatternFunctions::AWFunction> foundFunctions;
|
||||
@ -266,7 +265,7 @@ QStringList AWPatternFunctions::findLambdas(const QString &_code)
|
||||
|
||||
QStringList selectedKeys;
|
||||
// match the following construction ${{some code here}}
|
||||
QRegularExpression lambdaRegexp("\\$\\{\\{(?<body>.*?)\\}\\}");
|
||||
QRegularExpression lambdaRegexp(R"(\$\{\{(?<body>.*?)\}\})");
|
||||
lambdaRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
QRegularExpressionMatchIterator it = lambdaRegexp.globalMatch(_code);
|
||||
|
@ -46,7 +46,7 @@ QString insertMacros(QString _code);
|
||||
// find methods
|
||||
QStringList findKeys(const QString &_code, const QStringList &_keys, const bool _isBars);
|
||||
QStringList findLambdas(const QString &_code);
|
||||
};
|
||||
} // namespace AWPatternFunctions
|
||||
|
||||
|
||||
#endif /* AWPATTERNFUNCTIONS_H */
|
||||
|
@ -126,7 +126,7 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_
|
||||
return;
|
||||
}
|
||||
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr);
|
||||
auto *manager = new QNetworkAccessManager(nullptr);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
||||
SLOT(telemetryReplyRecieved(QNetworkReply *)));
|
||||
|
||||
@ -156,7 +156,7 @@ void AWTelemetryHandler::telemetryReplyRecieved(QNetworkReply *_reply)
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonParseError error{};
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(LOG_AW) << "Parse error" << error.errorString();
|
||||
@ -173,7 +173,7 @@ void AWTelemetryHandler::telemetryReplyRecieved(QNetworkReply *_reply)
|
||||
}
|
||||
|
||||
|
||||
QString AWTelemetryHandler::getKey(const int _count) const
|
||||
QString AWTelemetryHandler::getKey(const int _count)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Get key for keys count" << _count;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
const char *REMOTE_TELEMETRY_URL = "https://arcanis.me/telemetry";
|
||||
|
||||
explicit AWTelemetryHandler(QObject *_parent = nullptr, const QString &_clientId = "");
|
||||
virtual ~AWTelemetryHandler();
|
||||
~AWTelemetryHandler() override;
|
||||
Q_INVOKABLE QStringList get(const QString &_group) const;
|
||||
Q_INVOKABLE QString getLast(const QString &_group) const;
|
||||
Q_INVOKABLE void init(const int _count, const bool _enableRemote, const QString &_clientId);
|
||||
@ -46,7 +46,7 @@ private slots:
|
||||
void telemetryReplyRecieved(QNetworkReply *_reply);
|
||||
|
||||
private:
|
||||
QString getKey(const int _count) const;
|
||||
static QString getKey(const int _count);
|
||||
QString m_clientId;
|
||||
QString m_localFile;
|
||||
int m_storeCount = 0;
|
||||
|
@ -52,7 +52,7 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway)
|
||||
|
||||
// showAnyway options requires to show message if no updates found on direct
|
||||
// request. In case of automatic check no message will be shown
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(nullptr);
|
||||
auto *manager = new QNetworkAccessManager(nullptr);
|
||||
connect(manager, &QNetworkAccessManager::finished, [_showAnyway, this](QNetworkReply *reply) {
|
||||
return versionReplyRecieved(reply, _showAnyway);
|
||||
});
|
||||
@ -72,7 +72,7 @@ bool AWUpdateHelper::checkVersion()
|
||||
qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion;
|
||||
|
||||
if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) {
|
||||
genMessageBox(i18n("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'),
|
||||
genMessageBox(i18nc("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'),
|
||||
QMessageBox::Ok)
|
||||
->open();
|
||||
return true;
|
||||
@ -103,7 +103,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
|
||||
qCDebug(LOG_AW) << "Version" << _version;
|
||||
|
||||
QString text;
|
||||
text += i18n("Current version : %1", VERSION);
|
||||
text += i18nc("Current version : %1", VERSION);
|
||||
text += QString(COMMIT_SHA).isEmpty() ? "\n" : QString(" (%1)\n").arg(QString(COMMIT_SHA));
|
||||
text += i18n("New version : %1", _version.toString()) + "\n\n";
|
||||
text += i18n("Click \"Ok\" to download");
|
||||
@ -115,7 +115,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
|
||||
|
||||
void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
|
||||
{
|
||||
QMessageBox::ButtonRole ret = static_cast<QMessageBox *>(sender())->buttonRole(_button);
|
||||
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
|
||||
qCInfo(LOG_AW) << "User select" << ret;
|
||||
|
||||
switch (ret) {
|
||||
@ -138,7 +138,7 @@ void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, const bool _sho
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonParseError error = QJsonParseError();
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(LOG_AW) << "Parse error" << error.errorString();
|
||||
@ -167,7 +167,7 @@ QMessageBox *AWUpdateHelper::genMessageBox(const QString &_title, const QString
|
||||
{
|
||||
qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body;
|
||||
|
||||
QMessageBox *msgBox = new QMessageBox(nullptr);
|
||||
auto *msgBox = new QMessageBox(nullptr);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->setModal(false);
|
||||
msgBox->setWindowTitle(_title);
|
||||
|
@ -32,19 +32,19 @@ class AWUpdateHelper : public QObject
|
||||
|
||||
public:
|
||||
explicit AWUpdateHelper(QObject *_parent = nullptr);
|
||||
virtual ~AWUpdateHelper();
|
||||
~AWUpdateHelper() override;
|
||||
void checkUpdates(const bool _showAnyway = false);
|
||||
bool checkVersion();
|
||||
|
||||
private slots:
|
||||
void showInfo(const QVersionNumber &_version);
|
||||
static void showInfo(const QVersionNumber &_version);
|
||||
void showUpdates(const QVersionNumber &_version);
|
||||
void userReplyOnUpdates(QAbstractButton *_button);
|
||||
void versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway);
|
||||
|
||||
private:
|
||||
QMessageBox *genMessageBox(const QString &_title, const QString &_body,
|
||||
const QMessageBox::StandardButtons _buttons);
|
||||
static QMessageBox *genMessageBox(const QString &_title, const QString &_body,
|
||||
const QMessageBox::StandardButtons _buttons);
|
||||
QVersionNumber m_foundVersion;
|
||||
QString m_genericConfig;
|
||||
};
|
||||
|
Reference in New Issue
Block a user