mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2026-02-01 13:59:47 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59e3b21071 | |||
| 7e13e1eef7 | |||
| da53052a6f |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
pkgname=plasma6-applet-awesome-widgets
|
pkgname=plasma6-applet-awesome-widgets
|
||||||
_pkgname=awesome-widgets
|
_pkgname=awesome-widgets
|
||||||
pkgver=4.0.4
|
pkgver=4.0.5
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
|
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
|
||||||
arch=('x86_64')
|
arch=('x86_64')
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ set(PROJECT_CONTACT "esalexeev@gmail.com")
|
|||||||
set(PROJECT_LICENSE "GPL3")
|
set(PROJECT_LICENSE "GPL3")
|
||||||
set(PROJECT_VERSION_MAJOR "4")
|
set(PROJECT_VERSION_MAJOR "4")
|
||||||
set(PROJECT_VERSION_MINOR "0")
|
set(PROJECT_VERSION_MINOR "0")
|
||||||
set(PROJECT_VERSION_PATCH "4")
|
set(PROJECT_VERSION_PATCH "5")
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
# append git version if any
|
# append git version if any
|
||||||
set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "")
|
set(PROJECT_COMMIT_SHA "Commit hash" CACHE INTERNAL "")
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
"Id": "org.kde.plasma.awesomewidget",
|
"Id": "org.kde.plasma.awesomewidget",
|
||||||
"License": "GPLv3",
|
"License": "GPLv3",
|
||||||
"Name": "Awesome Widget",
|
"Name": "Awesome Widget",
|
||||||
"Version": "4.0.4",
|
"Version": "4.0.5",
|
||||||
"Website": "https://arcanis.me/projects/awesome-widgets/"
|
"Website": "https://arcanis.me/projects/awesome-widgets/"
|
||||||
},
|
},
|
||||||
"X-Plasma-API-Minimum-Version": "6.0"
|
"X-Plasma-API-Minimum-Version": "6.0"
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
[[nodiscard]] QStringList sources() const;
|
[[nodiscard]] QStringList sources() const;
|
||||||
[[nodiscard]] QStringList refinedSources() const;
|
[[nodiscard]] QStringList refinedSources() const;
|
||||||
// configuration related
|
// configuration related
|
||||||
void editPairs() override{};
|
void editPairs() override {};
|
||||||
QStringList leftKeys() override;
|
QStringList leftKeys() override;
|
||||||
QStringList rightKeys() override;
|
QStringList rightKeys() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -95,14 +95,55 @@ void AWDataEngineAggregator::loadSources()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWDataEngineAggregator::registerClient(QObject *_client)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW) << "Register client" << _client;
|
||||||
|
|
||||||
|
// register new client
|
||||||
|
m_clients.insert(_client);
|
||||||
|
// (re)connect sources for new client
|
||||||
|
connectSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWDataEngineAggregator::unregisterClient(QObject *_client)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW) << "Unregister client" << _client;
|
||||||
|
|
||||||
|
m_clients.remove(_client);
|
||||||
|
for (auto [source, clients] : m_droppedBy.asKeyValueRange()) {
|
||||||
|
if (clients.remove(_client)) {
|
||||||
|
if (isSubscriptionUnused(source))
|
||||||
|
dropSource(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::dropSource(const QString &_source)
|
void AWDataEngineAggregator::dropSource(const QString &_source)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Disconnect sensor" << _source;
|
qCDebug(LOG_AW) << "Disconnect sensor" << _source;
|
||||||
|
|
||||||
if (m_subscribed.contains(_source)) {
|
if (m_subscribed.remove(_source))
|
||||||
m_interface->unsubscribe({_source}).waitForFinished();
|
m_interface->unsubscribe({_source}).waitForFinished();
|
||||||
m_subscribed.remove(_source);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
void AWDataEngineAggregator::dropSourceForClient(QObject *_client, const QString &_source)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW) << "Client" << _client << "dropping source" << _source;
|
||||||
|
|
||||||
|
m_droppedBy[_source].insert(_client);
|
||||||
|
|
||||||
|
// only unsubscribe if ALL clients have dropped this source
|
||||||
|
if (isSubscriptionUnused(_source))
|
||||||
|
dropSource(_source);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWDataEngineAggregator::isSubscriptionUnused(const QString &_source) const
|
||||||
|
{
|
||||||
|
return m_droppedBy.value(_source).size() >= m_clients.size() && !m_clients.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace KSysGuard::SystemStats
|
namespace KSysGuard::SystemStats
|
||||||
{
|
{
|
||||||
@@ -34,12 +35,26 @@ class AWDataEngineAggregator : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
|
||||||
~AWDataEngineAggregator() override;
|
~AWDataEngineAggregator() override;
|
||||||
|
|
||||||
|
AWDataEngineAggregator(AWDataEngineAggregator &) = delete;
|
||||||
|
void operator=(const AWDataEngineAggregator &) = delete;
|
||||||
|
|
||||||
|
[[nodiscard]] static AWDataEngineAggregator *instance(QObject *_client)
|
||||||
|
{
|
||||||
|
static auto instance = loadInstance();
|
||||||
|
instance->registerClient(_client);
|
||||||
|
return instance.get();
|
||||||
|
};
|
||||||
|
|
||||||
void connectSources();
|
void connectSources();
|
||||||
void disconnectSources();
|
void disconnectSources();
|
||||||
|
void dropSourceForClient(QObject *_client, const QString &_source);
|
||||||
|
[[nodiscard]] inline bool isSubscriptionUnused(const QString &_source) const;
|
||||||
[[nodiscard]] static bool isValidSensor(const KSysGuard::SensorInfo &_sensor);
|
[[nodiscard]] static bool isValidSensor(const KSysGuard::SensorInfo &_sensor);
|
||||||
void loadSources();
|
void loadSources();
|
||||||
|
void registerClient(QObject *_client);
|
||||||
|
void unregisterClient(QObject *_client);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
|
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
|
||||||
@@ -52,7 +67,18 @@ public slots:
|
|||||||
void updateData(const 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);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
||||||
|
|
||||||
|
[[nodiscard]] static std::unique_ptr<AWDataEngineAggregator> loadInstance()
|
||||||
|
{
|
||||||
|
auto instance = new AWDataEngineAggregator();
|
||||||
|
return std::unique_ptr<AWDataEngineAggregator>(instance);
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QSet<QObject *> m_clients;
|
||||||
|
QHash<QString, QSet<QObject *>> m_droppedBy;
|
||||||
KSysGuard::SystemStats::DBusInterface *m_interface = nullptr;
|
KSysGuard::SystemStats::DBusInterface *m_interface = nullptr;
|
||||||
QHash<QString, KSysGuard::SensorInfo> m_sensors;
|
QHash<QString, KSysGuard::SensorInfo> m_sensors;
|
||||||
QSet<QString> m_subscribed;
|
QSet<QString> m_subscribed;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ AWKeys::AWKeys(QObject *_parent)
|
|||||||
|
|
||||||
m_aggregator = new AWKeysAggregator(this);
|
m_aggregator = new AWKeysAggregator(this);
|
||||||
m_dataAggregator = new AWDataAggregator(this);
|
m_dataAggregator = new AWDataAggregator(this);
|
||||||
m_dataEngineAggregator = new AWDataEngineAggregator(this);
|
m_dataEngineAggregator = AWDataEngineAggregator::instance(this);
|
||||||
m_keyOperator = new AWKeyOperations(this);
|
m_keyOperator = new AWKeyOperations(this);
|
||||||
|
|
||||||
m_timer = new QTimer(this);
|
m_timer = new QTimer(this);
|
||||||
@@ -59,7 +59,8 @@ AWKeys::AWKeys(QObject *_parent)
|
|||||||
connect(m_dataAggregator, &AWDataAggregator::toolTipPainted,
|
connect(m_dataAggregator, &AWDataAggregator::toolTipPainted,
|
||||||
[this](const QString &_tooltip) { emit(needToolTipToBeUpdated(_tooltip)); });
|
[this](const QString &_tooltip) { emit(needToolTipToBeUpdated(_tooltip)); });
|
||||||
|
|
||||||
connect(this, &AWKeys::dropSourceFromDataengine, m_dataEngineAggregator, &AWDataEngineAggregator::dropSource);
|
connect(this, &AWKeys::dropSourceFromDataengine, this,
|
||||||
|
[this](const QString &_source) { m_dataEngineAggregator->dropSourceForClient(this, _source); });
|
||||||
connect(m_dataEngineAggregator, &AWDataEngineAggregator::dataUpdated, this, &AWKeys::dataUpdated);
|
connect(m_dataEngineAggregator, &AWDataEngineAggregator::dataUpdated, this, &AWKeys::dataUpdated);
|
||||||
// transfer signal from dataengine to update source list
|
// transfer signal from dataengine to update source list
|
||||||
connect(m_dataEngineAggregator, &AWDataEngineAggregator::deviceAdded, m_keyOperator, &AWKeyOperations::addDevice);
|
connect(m_dataEngineAggregator, &AWDataEngineAggregator::deviceAdded, m_keyOperator, &AWKeyOperations::addDevice);
|
||||||
@@ -70,6 +71,8 @@ AWKeys::~AWKeys()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
|
m_dataEngineAggregator->unregisterClient(this);
|
||||||
|
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
// delete dbus session
|
// delete dbus session
|
||||||
auto id = reinterpret_cast<qlonglong>(this);
|
auto id = reinterpret_cast<qlonglong>(this);
|
||||||
@@ -294,8 +297,8 @@ QString AWKeys::parsePattern(QString _pattern) const
|
|||||||
// bars
|
// bars
|
||||||
for (auto &bar : m_foundBars) {
|
for (auto &bar : m_foundBars) {
|
||||||
auto item = m_keyOperator->giByKey(bar);
|
auto item = m_keyOperator->giByKey(bar);
|
||||||
auto image = item->isCustom() ? item->image(
|
auto image = item->isCustom() ? item->image(AWPatternFunctions::expandLambdas(item->bar(), m_aggregator,
|
||||||
AWPatternFunctions::expandLambdas(item->bar(), m_aggregator, m_values, item->usedKeys()))
|
m_values, item->usedKeys()))
|
||||||
: item->image(m_values[item->bar()]);
|
: item->image(m_values[item->bar()]);
|
||||||
_pattern.replace(QString("$%1").arg(bar), image);
|
_pattern.replace(QString("$%1").arg(bar), image);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
[[nodiscard]] virtual QString format(const QVariant &_value, const QString &_key,
|
[[nodiscard]] virtual QString format(const QVariant &_value, const QString &_key,
|
||||||
const AWPluginFormatSettings &_settings) const
|
const AWPluginFormatSettings &_settings) const
|
||||||
= 0;
|
= 0;
|
||||||
virtual void load(){};
|
virtual void load() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,4 +22,3 @@
|
|||||||
#ifndef ui_i18n
|
#ifndef ui_i18n
|
||||||
#define ui_i18n(text, parent) i18n(text)
|
#define ui_i18n(text, parent) i18n(text)
|
||||||
#endif /* ui_i18n */
|
#endif /* ui_i18n */
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
"Id": "org.kde.plasma.desktoppanel",
|
"Id": "org.kde.plasma.desktoppanel",
|
||||||
"License": "GPLv3",
|
"License": "GPLv3",
|
||||||
"Name": "Desktop Panel",
|
"Name": "Desktop Panel",
|
||||||
"Version": "4.0.4",
|
"Version": "4.0.5",
|
||||||
"Website": "https://arcanis.me/projects/awesome-widgets/"
|
"Website": "https://arcanis.me/projects/awesome-widgets/"
|
||||||
},
|
},
|
||||||
"X-Plasma-API-Minimum-Version": "6.0"
|
"X-Plasma-API-Minimum-Version": "6.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user