mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-05-04 12:23:49 +00:00
Compare commits
2 Commits
ce93664f5b
...
f1a01fbb32
Author | SHA1 | Date | |
---|---|---|---|
f1a01fbb32 | |||
960640f5bc |
@ -9,6 +9,9 @@ endif ()
|
|||||||
if (POLICY CMP0071)
|
if (POLICY CMP0071)
|
||||||
cmake_policy(SET CMP0071 NEW)
|
cmake_policy(SET CMP0071 NEW)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (POLICY CMP0160)
|
||||||
|
cmake_policy(SET CMP0160 OLD)
|
||||||
|
endif ()
|
||||||
|
|
||||||
project(awesomewidgets)
|
project(awesomewidgets)
|
||||||
set(PROJECT_AUTHOR "Evgeniy Alekseev")
|
set(PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||||
|
@ -191,10 +191,6 @@ KCM.SimpleKCM {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
// init submodule
|
// init submodule
|
||||||
awKeys.updateCache()
|
awKeys.updateCache()
|
||||||
|
|
||||||
// update hdd model
|
|
||||||
hdd.model = awKeys.getHddDevices()
|
|
||||||
hdd.onCompleted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
|
@ -88,20 +88,6 @@ void AWActions::showReadme()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::showLegacyInfo()
|
|
||||||
{
|
|
||||||
auto msgBox = new QMessageBox(nullptr);
|
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
msgBox->setModal(false);
|
|
||||||
msgBox->setWindowTitle(i18n("Not supported"));
|
|
||||||
msgBox->setText(i18n("You are using mammoth's Qt version, try to update it first"));
|
|
||||||
msgBox->setStandardButtons(QMessageBox::Ok);
|
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
|
||||||
|
|
||||||
msgBox->open();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// HACK: this method uses variables from version.h
|
// HACK: this method uses variables from version.h
|
||||||
QString AWActions::getAboutText(const QString &_type)
|
QString AWActions::getAboutText(const QString &_type)
|
||||||
{
|
{
|
||||||
@ -135,7 +121,6 @@ void AWActions::sendNotification(const QString &_eventId, const QString &_messag
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Event" << _eventId << "with message" << _message;
|
qCDebug(LOG_AW) << "Event" << _eventId << "with message" << _message;
|
||||||
|
|
||||||
KNotification *notification
|
auto *event = KNotification::event(_eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message);
|
||||||
= KNotification::event(_eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message);
|
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
||||||
notification->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ public:
|
|||||||
Q_INVOKABLE void checkUpdates(bool _showAnyway = false);
|
Q_INVOKABLE void checkUpdates(bool _showAnyway = false);
|
||||||
Q_INVOKABLE static QString getFileContent(const QString &_path);
|
Q_INVOKABLE static QString getFileContent(const QString &_path);
|
||||||
Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args);
|
Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args);
|
||||||
Q_INVOKABLE static void showLegacyInfo();
|
|
||||||
Q_INVOKABLE static void showReadme();
|
Q_INVOKABLE static void showReadme();
|
||||||
// configuration slots
|
// configuration slots
|
||||||
Q_INVOKABLE static QString getAboutText(const QString &_type);
|
Q_INVOKABLE static QString getAboutText(const QString &_type);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "awbugreporter.h"
|
#include "awbugreporter.h"
|
||||||
|
|
||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -114,6 +115,12 @@ void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWBugReporter::openBugReport()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(m_lastBugUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWBugReporter::showInformation(const int _number, const QString &_url)
|
void AWBugReporter::showInformation(const int _number, const QString &_url)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Created issue with number" << _number << "and url" << _url;
|
qCDebug(LOG_AW) << "Created issue with number" << _number << "and url" << _url;
|
||||||
@ -121,29 +128,9 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
|
|||||||
// cache url first
|
// cache url first
|
||||||
m_lastBugUrl = _url;
|
m_lastBugUrl = _url;
|
||||||
|
|
||||||
auto msgBox = new QMessageBox(nullptr);
|
auto event = KNotification::event("system", i18n("Issue created"), i18n("Issue %1 has been created", _number));
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
||||||
msgBox->setModal(false);
|
|
||||||
msgBox->setWindowTitle(i18n("Issue created"));
|
|
||||||
msgBox->setText(i18n("Issue %1 has been created", _number));
|
|
||||||
msgBox->setStandardButtons(QMessageBox::Open | QMessageBox::Close);
|
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
|
||||||
|
|
||||||
msgBox->open(this, SLOT(userReplyOnBugReport(QAbstractButton *)));
|
auto action = event->addAction(i18n("Details"));
|
||||||
}
|
connect(action, &KNotificationAction::activated, this, &AWBugReporter::openBugReport);
|
||||||
|
|
||||||
|
|
||||||
void AWBugReporter::userReplyOnBugReport(QAbstractButton *_button)
|
|
||||||
{
|
|
||||||
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
|
|
||||||
qCInfo(LOG_AW) << "User select" << ret;
|
|
||||||
|
|
||||||
switch (ret) {
|
|
||||||
case QMessageBox::AcceptRole:
|
|
||||||
QDesktopServices::openUrl(m_lastBugUrl);
|
|
||||||
break;
|
|
||||||
case QMessageBox::RejectRole:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void issueReplyReceived(QNetworkReply *_reply);
|
void issueReplyReceived(QNetworkReply *_reply);
|
||||||
|
void openBugReport();
|
||||||
void showInformation(int _number, const QString &_url);
|
void showInformation(int _number, const QString &_url);
|
||||||
void userReplyOnBugReport(QAbstractButton *_button);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_lastBugUrl;
|
QString m_lastBugUrl;
|
||||||
|
@ -139,7 +139,7 @@ void AWDataEngineAggregator::sensorRemoved(const QString &_sensor)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::updateData(KSysGuard::SensorDataList _data)
|
void AWDataEngineAggregator::updateData(const KSysGuard::SensorDataList &_data)
|
||||||
{
|
{
|
||||||
emit(dataUpdated(m_sensors, _data));
|
emit(dataUpdated(m_sensors, _data));
|
||||||
}
|
}
|
||||||
@ -147,9 +147,9 @@ void AWDataEngineAggregator::updateData(KSysGuard::SensorDataList _data)
|
|||||||
|
|
||||||
void AWDataEngineAggregator::updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors)
|
void AWDataEngineAggregator::updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors)
|
||||||
{
|
{
|
||||||
for (auto sensor = _sensors.cbegin(); sensor != _sensors.cend(); ++sensor) {
|
for (auto [source, sensor] : _sensors.asKeyValueRange()) {
|
||||||
if (!isValidSensor(sensor.value()))
|
if (!isValidSensor(sensor))
|
||||||
continue;
|
continue;
|
||||||
m_sensors.insert(sensor.key(), sensor.value());
|
m_sensors.insert(source, sensor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public slots:
|
|||||||
void dropSource(const QString &_source);
|
void dropSource(const QString &_source);
|
||||||
void sensorAdded(const QString &_sensor);
|
void sensorAdded(const QString &_sensor);
|
||||||
void sensorRemoved(const QString &_sensor);
|
void sensorRemoved(const QString &_sensor);
|
||||||
void updateData(KSysGuard::SensorDataList _data);
|
void updateData(const KSysGuard::SensorDataList &_data);
|
||||||
void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors);
|
void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <QDBusError>
|
#include <QDBusError>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#include "awdataaggregator.h"
|
#include "awdataaggregator.h"
|
||||||
#include "awdataengineaggregator.h"
|
#include "awdataengineaggregator.h"
|
||||||
@ -153,26 +153,6 @@ QStringList AWKeys::dictKeys(const bool _sorted, const QString &_regexp) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantList AWKeys::getHddDevices() const
|
|
||||||
{
|
|
||||||
QStringList hddDevices = m_keyOperator->devices("hdd");
|
|
||||||
// required by selector in the UI
|
|
||||||
hddDevices.insert(0, "disable");
|
|
||||||
hddDevices.insert(0, "auto");
|
|
||||||
|
|
||||||
// build model
|
|
||||||
QVariantList devices;
|
|
||||||
for (auto &device : hddDevices) {
|
|
||||||
QVariantMap model;
|
|
||||||
model["label"] = device;
|
|
||||||
model["name"] = device;
|
|
||||||
devices.append(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return devices;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString AWKeys::infoByKey(const QString &_key) const
|
QString AWKeys::infoByKey(const QString &_key) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Requested info for key" << _key;
|
qCDebug(LOG_AW) << "Requested info for key" << _key;
|
||||||
@ -202,12 +182,15 @@ void AWKeys::editItem(const QString &_type)
|
|||||||
|
|
||||||
void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data)
|
void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data)
|
||||||
{
|
{
|
||||||
for (auto &single : _data) {
|
qCDebug(LOG_AW) << "Update data for" << _data.count() << "items";
|
||||||
if (_sensors.contains(single.sensorProperty)) {
|
|
||||||
setDataBySource(single.sensorProperty, _sensors.value(single.sensorProperty), single);
|
// though it is better to use QtConcurrent::map here, but it might cause stack corruption
|
||||||
}
|
for (auto &data : _data) {
|
||||||
// TODO use QtConcurrent::map or something like that
|
if (!_sensors.contains(data.sensorProperty))
|
||||||
// QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, "ss", sensor);
|
continue;
|
||||||
|
auto sensor = _sensors[data.sensorProperty];
|
||||||
|
std::ignore = QtConcurrent::run(m_threadPool, &AWKeys::setDataBySource, this, data.sensorProperty, sensor,
|
||||||
|
data.payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +255,7 @@ void AWKeys::calculateValues()
|
|||||||
m_values["memtotmb"] = m_values["memusedmb"].toLongLong() + m_values["memfreemb"].toLongLong();
|
m_values["memtotmb"] = m_values["memusedmb"].toLongLong() + m_values["memfreemb"].toLongLong();
|
||||||
m_values["memtotgb"] = m_values["memusedgb"].toDouble() + m_values["memfreegb"].toDouble();
|
m_values["memtotgb"] = m_values["memusedgb"].toDouble() + m_values["memfreegb"].toDouble();
|
||||||
// mem
|
// mem
|
||||||
m_values["mem"] = 100.0f * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
|
m_values["mem"] = 100.0 * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
|
||||||
|
|
||||||
// up, down, upkb, downkb, upunits, downunits
|
// up, down, upkb, downkb, upunits, downunits
|
||||||
int netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString());
|
int netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString());
|
||||||
@ -291,7 +274,7 @@ void AWKeys::calculateValues()
|
|||||||
m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong();
|
m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong();
|
||||||
m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble();
|
m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble();
|
||||||
// swap
|
// swap
|
||||||
m_values["swap"] = 100.0f * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
|
m_values["swap"] = 100.0 * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
|
||||||
|
|
||||||
// user defined keys
|
// user defined keys
|
||||||
for (auto &key : m_keyOperator->userKeys())
|
for (auto &key : m_keyOperator->userKeys())
|
||||||
@ -357,10 +340,9 @@ QString AWKeys::parsePattern(QString _pattern) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
|
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value)
|
||||||
const KSysGuard::SensorData &_data)
|
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _data.payload;
|
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _value;
|
||||||
|
|
||||||
// first list init
|
// first list init
|
||||||
auto tags = m_aggregator->keysFromSource(_source);
|
auto tags = m_aggregator->keysFromSource(_source);
|
||||||
@ -374,6 +356,6 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
std::for_each(tags.cbegin(), tags.cend(), [this, &_data](const QString &tag) { m_values[tag] = _data.payload; });
|
std::for_each(tags.cbegin(), tags.cend(), [this, _value](const QString &tag) { m_values[tag] = _value; });
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
@ -46,22 +46,19 @@ public:
|
|||||||
Q_INVOKABLE void updateCache();
|
Q_INVOKABLE void updateCache();
|
||||||
// keys
|
// keys
|
||||||
Q_INVOKABLE [[nodiscard]] QStringList dictKeys(bool _sorted = false, const QString &_regexp = "") const;
|
Q_INVOKABLE [[nodiscard]] QStringList dictKeys(bool _sorted = false, const QString &_regexp = "") const;
|
||||||
Q_INVOKABLE [[nodiscard]] QVariantList getHddDevices() const;
|
|
||||||
// values
|
// values
|
||||||
Q_INVOKABLE [[nodiscard]] QString infoByKey(const QString &_key) const;
|
Q_INVOKABLE [[nodiscard]] QString infoByKey(const QString &_key) const;
|
||||||
Q_INVOKABLE [[nodiscard]] QString valueByKey(const QString &_key) const;
|
Q_INVOKABLE [[nodiscard]] QString valueByKey(const QString &_key) const;
|
||||||
// configuration
|
// configuration
|
||||||
Q_INVOKABLE void editItem(const QString &_type);
|
Q_INVOKABLE void editItem(const QString &_type);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dropSourceFromDataengine(const QString &_source);
|
void dropSourceFromDataengine(const QString &_source);
|
||||||
void needTextToBeUpdated(const QString &_newText) const;
|
void needTextToBeUpdated(const QString &_newText) const;
|
||||||
void needToolTipToBeUpdated(const QString &_newText) const;
|
void needToolTipToBeUpdated(const QString &_newText) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
|
||||||
void reinitKeys(const QStringList &_currentKeys);
|
void reinitKeys(const QStringList &_currentKeys);
|
||||||
void updateTextData();
|
void updateTextData();
|
||||||
|
|
||||||
@ -70,8 +67,7 @@ private:
|
|||||||
void calculateValues();
|
void calculateValues();
|
||||||
void createDBusInterface();
|
void createDBusInterface();
|
||||||
[[nodiscard]] QString parsePattern(QString _pattern) const;
|
[[nodiscard]] QString parsePattern(QString _pattern) const;
|
||||||
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
|
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value);
|
||||||
const KSysGuard::SensorData &_data);
|
|
||||||
// objects
|
// objects
|
||||||
AWDataAggregator *m_dataAggregator = nullptr;
|
AWDataAggregator *m_dataAggregator = nullptr;
|
||||||
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
|
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "awupdatehelper.h"
|
#include "awupdatehelper.h"
|
||||||
|
|
||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -70,8 +71,7 @@ bool AWUpdateHelper::checkVersion()
|
|||||||
qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion;
|
qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion;
|
||||||
|
|
||||||
if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) {
|
if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) {
|
||||||
genMessageBox(i18nc("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'), QMessageBox::Ok)
|
sendNotification(i18nc("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'));
|
||||||
->open();
|
|
||||||
return true;
|
return true;
|
||||||
} else if (version != m_foundVersion) {
|
} else if (version != m_foundVersion) {
|
||||||
qCWarning(LOG_AW) << "No changelog information provided";
|
qCWarning(LOG_AW) << "No changelog information provided";
|
||||||
@ -84,6 +84,12 @@ bool AWUpdateHelper::checkVersion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWUpdateHelper::openReleasesPage()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(QString(RELEASES) + m_foundVersion.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Version" << _version;
|
qCDebug(LOG_AW) << "Version" << _version;
|
||||||
@ -91,7 +97,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
|||||||
auto text = i18n("You are using the actual version %1", _version.toString());
|
auto text = i18n("You are using the actual version %1", _version.toString());
|
||||||
if (!QString(COMMIT_SHA).isEmpty())
|
if (!QString(COMMIT_SHA).isEmpty())
|
||||||
text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
||||||
return genMessageBox(i18n("No new version found"), text, QMessageBox::Ok)->open();
|
sendNotification(i18n("No new version found"), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,24 +111,9 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
|
|||||||
text += i18n("New version : %1", _version.toString()) + "\n\n";
|
text += i18n("New version : %1", _version.toString()) + "\n\n";
|
||||||
text += i18n("Click \"Ok\" to download");
|
text += i18n("Click \"Ok\" to download");
|
||||||
|
|
||||||
genMessageBox(i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel)
|
auto event = sendNotification(i18n("There are updates"), text);
|
||||||
->open(this, SLOT(userReplyOnUpdates(QAbstractButton *)));
|
auto action = event->addAction(i18n("Details"));
|
||||||
}
|
connect(action, &KNotificationAction::activated, this, &AWUpdateHelper::openReleasesPage);
|
||||||
|
|
||||||
|
|
||||||
void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
|
|
||||||
{
|
|
||||||
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
|
|
||||||
qCInfo(LOG_AW) << "User select" << ret;
|
|
||||||
|
|
||||||
switch (ret) {
|
|
||||||
case QMessageBox::AcceptRole:
|
|
||||||
QDesktopServices::openUrl(QString(RELEASES) + m_foundVersion.toString());
|
|
||||||
break;
|
|
||||||
case QMessageBox::RejectRole:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,18 +149,12 @@ void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _sho
|
|||||||
|
|
||||||
|
|
||||||
// additional method which is used to show message box which does not block UI
|
// additional method which is used to show message box which does not block UI
|
||||||
QMessageBox *AWUpdateHelper::genMessageBox(const QString &_title, const QString &_body,
|
KNotification *AWUpdateHelper::sendNotification(const QString &_title, const QString &_body)
|
||||||
const QMessageBox::StandardButtons _buttons)
|
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body;
|
qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body;
|
||||||
|
|
||||||
auto msgBox = new QMessageBox(nullptr);
|
auto event = KNotification::event("system", _title, _body);
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
||||||
msgBox->setModal(false);
|
|
||||||
msgBox->setWindowTitle(_title);
|
|
||||||
msgBox->setText(_body);
|
|
||||||
msgBox->setStandardButtons(_buttons);
|
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
|
||||||
|
|
||||||
return msgBox;
|
return event;
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
|
||||||
|
|
||||||
|
class KNotification;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
class AWUpdateHelper : public QObject
|
class AWUpdateHelper : public QObject
|
||||||
@ -35,14 +35,13 @@ public:
|
|||||||
bool checkVersion();
|
bool checkVersion();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void openReleasesPage();
|
||||||
static void showInfo(const QVersionNumber &_version);
|
static void showInfo(const QVersionNumber &_version);
|
||||||
void showUpdates(const QVersionNumber &_version);
|
void showUpdates(const QVersionNumber &_version);
|
||||||
void userReplyOnUpdates(QAbstractButton *_button);
|
|
||||||
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
|
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QMessageBox *genMessageBox(const QString &_title, const QString &_body,
|
static KNotification *sendNotification(const QString &_title, const QString &_body);
|
||||||
QMessageBox::StandardButtons _buttons);
|
|
||||||
QVersionNumber m_foundVersion;
|
QVersionNumber m_foundVersion;
|
||||||
QString m_genericConfig;
|
QString m_genericConfig;
|
||||||
};
|
};
|
||||||
|
@ -73,10 +73,7 @@ void ExtSysMonSensor::update()
|
|||||||
|
|
||||||
void ExtSysMonSensor::loadProperties()
|
void ExtSysMonSensor::loadProperties()
|
||||||
{
|
{
|
||||||
auto sensors = m_source->sources();
|
for (auto [source, info] : m_source->sources().asKeyValueRange()) {
|
||||||
for (auto sensor = sensors.cbegin(); sensor != sensors.cend(); ++sensor) {
|
|
||||||
auto source = sensor.key();
|
|
||||||
auto info = sensor.value();
|
|
||||||
auto property = new KSysGuard::SensorProperty(source, info->name, this);
|
auto property = new KSysGuard::SensorProperty(source, info->name, this);
|
||||||
|
|
||||||
property->setUnit(info->unit);
|
property->setUnit(info->unit);
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
find_package(Gettext REQUIRED)
|
find_package(Gettext REQUIRED)
|
||||||
|
|
||||||
# main qt libraries
|
# main qt libraries
|
||||||
find_package(Qt6 6.6.0 REQUIRED COMPONENTS Core DBus Network Qml Test Widgets)
|
find_package(Qt6 6.6.0 REQUIRED COMPONENTS Core Concurrent DBus Network Qml Test Widgets)
|
||||||
add_definitions(
|
add_definitions(
|
||||||
${Qt6Core_DEFINITIONS} ${Qt6DBus_DEFINITIONS} ${Qt6Network_DEFINITIONS}
|
${Qt6Core_DEFINITIONS} ${Qt6DBus_DEFINITIONS} ${Qt6Network_DEFINITIONS}
|
||||||
${Qt6Qml_DEFINITIONS} ${Qt6Widgets_DEFINITIONS}
|
${Qt6Qml_DEFINITIONS} ${Qt6Widgets_DEFINITIONS}
|
||||||
)
|
)
|
||||||
set(Qt_INCLUDE
|
set(Qt_INCLUDE
|
||||||
${Qt6Core_INCLUDE_DIRS} ${Qt6DBus_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS}
|
${Qt6Core_INCLUDE_DIRS} ${Qt6Concurrent_INCLUDE_DIRS} ${Qt6DBus_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS}
|
||||||
${Qt6Qml_INCLUDE_DIRS} ${Qt6Widgets_INCLUDE_DIRS}
|
${Qt6Qml_INCLUDE_DIRS} ${Qt6Widgets_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
set(Qt_LIBRARIES
|
set(Qt_LIBRARIES
|
||||||
${Qt6Core_LIBRARIES} ${Qt6DBus_LIBRARIES} ${Qt6Network_LIBRARIES}
|
${Qt6Core_LIBRARIES} ${Qt6Concurrent_LIBRARIES} ${Qt6DBus_LIBRARIES} ${Qt6Network_LIBRARIES}
|
||||||
${Qt6Qml_LIBRARIES} ${Qt6Widgets_LIBRARIES}
|
${Qt6Qml_LIBRARIES} ${Qt6Widgets_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,12 +73,6 @@ void TestAWKeys::cleanupTestCase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TestAWKeys::test_hddDevices()
|
|
||||||
{
|
|
||||||
QVERIFY(plugin->getHddDevices().count() >= 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TestAWKeys::test_dictKeys()
|
void TestAWKeys::test_dictKeys()
|
||||||
{
|
{
|
||||||
auto keys = plugin->dictKeys();
|
auto keys = plugin->dictKeys();
|
||||||
|
@ -31,7 +31,6 @@ private slots:
|
|||||||
void initTestCase();
|
void initTestCase();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
// test
|
// test
|
||||||
void test_hddDevices();
|
|
||||||
void test_dictKeys();
|
void test_dictKeys();
|
||||||
void test_pattern();
|
void test_pattern();
|
||||||
void test_tooltip();
|
void test_tooltip();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user