mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-05-04 04:13:49 +00:00
port widget to dbus
This commit is contained in:
parent
0fcfb7d7e4
commit
cee37c6a4a
75
sources/3rdparty/fontdialog/fontdialog.cpp
vendored
75
sources/3rdparty/fontdialog/fontdialog.cpp
vendored
@ -39,81 +39,6 @@ void CFont::setCurrentColor(const QColor color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CFont::html2QFont(const int htmlWeight)
|
|
||||||
{
|
|
||||||
int weight = 16;
|
|
||||||
switch(htmlWeight) {
|
|
||||||
case 100:
|
|
||||||
weight = 16;
|
|
||||||
break;
|
|
||||||
case 200:
|
|
||||||
case 300:
|
|
||||||
weight = 25;
|
|
||||||
break;
|
|
||||||
case 400:
|
|
||||||
weight = 50;
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
case 600:
|
|
||||||
weight = 63;
|
|
||||||
break;
|
|
||||||
case 700:
|
|
||||||
case 800:
|
|
||||||
weight = 75;
|
|
||||||
break;
|
|
||||||
case 900:
|
|
||||||
weight = 87;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CFont::qFont2html(const int weight)
|
|
||||||
{
|
|
||||||
int htmlWeight = 400;
|
|
||||||
switch(weight) {
|
|
||||||
case 16:
|
|
||||||
htmlWeight = 100;
|
|
||||||
break;
|
|
||||||
case 25:
|
|
||||||
htmlWeight = 300;
|
|
||||||
break;
|
|
||||||
case 50:
|
|
||||||
htmlWeight = 400;
|
|
||||||
break;
|
|
||||||
case 63:
|
|
||||||
htmlWeight = 600;
|
|
||||||
break;
|
|
||||||
case 75:
|
|
||||||
htmlWeight = 800;
|
|
||||||
break;
|
|
||||||
case 87:
|
|
||||||
htmlWeight = 900;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return htmlWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CFont::htmlWeight()
|
|
||||||
{
|
|
||||||
return CFont::qFont2html(weight());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CFont::setHtmlWeight(const int htmlWeight)
|
|
||||||
{
|
|
||||||
setWeight(CFont::html2QFont(htmlWeight));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CFont CFont::fromQFont(const QFont font, const QColor color)
|
CFont CFont::fromQFont(const QFont font, const QColor color)
|
||||||
{
|
{
|
||||||
return CFont(font.family(), font.pointSize(), font.weight(), font.italic(), color);
|
return CFont(font.family(), font.pointSize(), font.weight(), font.italic(), color);
|
||||||
|
5
sources/3rdparty/fontdialog/fontdialog.h
vendored
5
sources/3rdparty/fontdialog/fontdialog.h
vendored
@ -34,11 +34,6 @@ public:
|
|||||||
// color properties
|
// color properties
|
||||||
QColor color();
|
QColor color();
|
||||||
void setCurrentColor(const QColor color);
|
void setCurrentColor(const QColor color);
|
||||||
// html weight properties
|
|
||||||
static int html2QFont(const int htmlWeight);
|
|
||||||
static int qFont2html(const int weight);
|
|
||||||
int htmlWeight();
|
|
||||||
void setHtmlWeight(const int htmlWeight);
|
|
||||||
// conversion to QFont
|
// conversion to QFont
|
||||||
static CFont fromQFont(const QFont font,
|
static CFont fromQFont(const QFont font,
|
||||||
const QColor color = QColor(QString("#000000")));
|
const QColor color = QColor(QString("#000000")));
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <QQmlPropertyMap>
|
#include <QQmlPropertyMap>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextCodec>
|
|
||||||
|
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
@ -285,7 +284,6 @@ void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key, const
|
|||||||
QFile file(_fileName);
|
QFile file(_fileName);
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
out.setCodec("UTF-8");
|
|
||||||
out << _settings.value(_key).toString().toUtf8();
|
out << _settings.value(_key).toString().toUtf8();
|
||||||
out.flush();
|
out.flush();
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
#include "awdataengineaggregator.h"
|
#include "awdataengineaggregator.h"
|
||||||
|
|
||||||
#include <Plasma/DataContainer>
|
#include <QDBusConnection>
|
||||||
|
#include <ksysguard/systemstats/DBusInterface.h>
|
||||||
|
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
@ -27,20 +28,19 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *_parent)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
m_consumer = new Plasma::DataEngineConsumer();
|
qDBusRegisterMetaType<KSysGuard::SensorData>();
|
||||||
m_dataEngines["systemmonitor"] = m_consumer->dataEngine("systemmonitor");
|
qDBusRegisterMetaType<KSysGuard::SensorInfo>();
|
||||||
m_dataEngines["extsysmon"] = m_consumer->dataEngine("extsysmon");
|
qDBusRegisterMetaType<KSysGuard::SensorDataList>();
|
||||||
m_dataEngines["time"] = m_consumer->dataEngine("time");
|
qDBusRegisterMetaType<QHash<QString, KSysGuard::SensorInfo>>();
|
||||||
|
|
||||||
// additional method required by systemmonitor structure
|
m_interface = new KSysGuard::SystemStats::DBusInterface(
|
||||||
m_newSourceConnection
|
KSysGuard::SystemStats::ServiceName, KSysGuard::SystemStats::ObjectPath, QDBusConnection::sessionBus(), this);
|
||||||
= connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, [this](const QString &source) {
|
connect(m_interface, SIGNAL(newSensorData(KSysGuard::SensorDataList)), this,
|
||||||
emit(deviceAdded(source));
|
SLOT(updateData(KSysGuard::SensorDataList)));
|
||||||
m_dataEngines["systemmonitor"]->connectSource(source, parent(), 1000);
|
connect(m_interface, SIGNAL(sensorAdded(const QString &)), this, SLOT(sensorAdded(const QString &)));
|
||||||
});
|
connect(m_interface, SIGNAL(sensorMetaDataChanged(const QHash<QString, KSysGuard::SensorInfo> &)), this,
|
||||||
|
SLOT(updateSensor(const QHash<QString, KSysGuard::SensorInfo> &)));
|
||||||
// required to define Qt::QueuedConnection for signal-slot connection
|
connect(m_interface, SIGNAL(sensorRemoved(const QString &)), this, SLOT(sensorRemoved(const QString &)));
|
||||||
qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,62 +54,5 @@ AWDataEngineAggregator::~AWDataEngineAggregator()
|
|||||||
|
|
||||||
void AWDataEngineAggregator::disconnectSources()
|
void AWDataEngineAggregator::disconnectSources()
|
||||||
{
|
{
|
||||||
for (auto dataEngine : m_dataEngines.values())
|
m_interface->unsubscribe(m_sensors.values());
|
||||||
for (auto &source : dataEngine->sources())
|
|
||||||
dataEngine->disconnectSource(source, parent());
|
|
||||||
disconnect(m_newSourceConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::reconnectSources(const int _interval)
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW) << "Reconnect sources with interval" << _interval;
|
|
||||||
|
|
||||||
disconnectSources();
|
|
||||||
|
|
||||||
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(), (uint)_interval);
|
|
||||||
});
|
|
||||||
|
|
||||||
#ifdef BUILD_FUTURE
|
|
||||||
createQueuedConnection();
|
|
||||||
#endif /* BUILD_FUTURE */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::dropSource(const QString &_source)
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW) << "Source" << _source;
|
|
||||||
|
|
||||||
// HACK there is no possibility to check to which dataengine source
|
|
||||||
// connected we will try to disconnect it from all engines
|
|
||||||
for (auto dataEngine : m_dataEngines.values())
|
|
||||||
dataEngine->disconnectSource(_source, parent());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWDataEngineAggregator::createQueuedConnection()
|
|
||||||
{
|
|
||||||
// HACK additional method which forces QueuedConnection instead of Auto one
|
|
||||||
// for more details refer to plasma-framework source code
|
|
||||||
for (auto &dataEngine : m_dataEngines.keys()) {
|
|
||||||
// different source set for different engines
|
|
||||||
QStringList sources = dataEngine == "time" ? QStringList() << "Local" : m_dataEngines[dataEngine]->sources();
|
|
||||||
// reconnect sources
|
|
||||||
for (auto &source : sources) {
|
|
||||||
Plasma::DataContainer *container = m_dataEngines[dataEngine]->containerForSource(source);
|
|
||||||
// disconnect old connections first
|
|
||||||
disconnect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(),
|
|
||||||
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)));
|
|
||||||
// and now reconnect with Qt::QueuedConnection type
|
|
||||||
connect(container, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), parent(),
|
|
||||||
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)), Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,16 @@
|
|||||||
#ifndef AWDATAENGINEAGGREGATOR_H
|
#ifndef AWDATAENGINEAGGREGATOR_H
|
||||||
#define AWDATAENGINEAGGREGATOR_H
|
#define AWDATAENGINEAGGREGATOR_H
|
||||||
|
|
||||||
#include <Plasma/DataEngine>
|
#include <ksysguard/systemstats/SensorInfo.h>
|
||||||
#include <Plasma/DataEngineConsumer>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
|
|
||||||
|
namespace KSysGuard::SystemStats
|
||||||
|
{
|
||||||
|
class DBusInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AWDataEngineAggregator : public QObject
|
class AWDataEngineAggregator : public QObject
|
||||||
@ -33,19 +39,20 @@ public:
|
|||||||
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
explicit AWDataEngineAggregator(QObject *_parent = nullptr);
|
||||||
~AWDataEngineAggregator() override;
|
~AWDataEngineAggregator() override;
|
||||||
void disconnectSources();
|
void disconnectSources();
|
||||||
void reconnectSources(int _interval);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceAdded(const QString &_source);
|
void deviceAdded(const QString &_source);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void dropSource(const QString &_source);
|
void sensorAdded(const QString &_sensor);
|
||||||
|
void sensorRemoved(const QString &_sensor);
|
||||||
|
void updateData(KSysGuard::SensorDataList _data);
|
||||||
|
void updateSensor(const QHash<QString, KSysGuard::SensorInfo> &_sensor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createQueuedConnection();
|
void createQueuedConnection();
|
||||||
Plasma::DataEngineConsumer *m_consumer = nullptr;
|
KSysGuard::SystemStats::DBusInterface *m_interface = nullptr;
|
||||||
QHash<QString, Plasma::DataEngine *> m_dataEngines;
|
QSet<QString> m_sensors;
|
||||||
QMetaObject::Connection m_newSourceConnection;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,10 +199,11 @@ void AWKeys::editItem(const QString &_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data)
|
void AWKeys::dataUpdated(const KSysGuard::SensorDataList &_data)
|
||||||
{
|
{
|
||||||
// run concurrent data update
|
// TODO use QtConcurrent::map or something like that
|
||||||
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, _sourceName, _data);
|
for (auto &sensor : _data)
|
||||||
|
QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, sensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -351,9 +352,9 @@ QString AWKeys::parsePattern(QString _pattern) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWKeys::setDataBySource(const QString &_sourceName, const QVariantMap &_data)
|
void AWKeys::setDataBySource(const QString &_sourceName, const KSysGuard::SensorData &_data)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Source" << _sourceName << "with data" << _data;
|
qCDebug(LOG_AW) << "Source" << _sourceName << "with data" << _data.payload;
|
||||||
|
|
||||||
// first list init
|
// first list init
|
||||||
QStringList tags = m_aggregator->keysFromSource(_sourceName);
|
QStringList tags = m_aggregator->keysFromSource(_sourceName);
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
#ifndef AWKEYS_H
|
#ifndef AWKEYS_H
|
||||||
#define AWKEYS_H
|
#define AWKEYS_H
|
||||||
|
|
||||||
#include <Plasma/DataEngine>
|
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
#include <ksysguard/systemstats/SensorInfo.h>
|
||||||
|
|
||||||
|
|
||||||
class AWDataAggregator;
|
class AWDataAggregator;
|
||||||
class AWDataEngineAggregator;
|
class AWDataEngineAggregator;
|
||||||
@ -56,9 +56,7 @@ public:
|
|||||||
Q_INVOKABLE void editItem(const QString &_type);
|
Q_INVOKABLE void editItem(const QString &_type);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data);
|
void dataUpdated(const KSysGuard::SensorDataList &_data);
|
||||||
// dummy method required by DataEngine connections
|
|
||||||
static void modelChanged(const QString &, QAbstractItemModel *){};
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dropSourceFromDataengine(const QString &_source);
|
void dropSourceFromDataengine(const QString &_source);
|
||||||
@ -74,7 +72,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 &_sourceName, const QVariantMap &_data);
|
void setDataBySource(const KSysGuard::SensorData &_data);
|
||||||
// objects
|
// objects
|
||||||
AWDataAggregator *m_dataAggregator = nullptr;
|
AWDataAggregator *m_dataAggregator = nullptr;
|
||||||
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
|
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
|
||||||
|
@ -22,8 +22,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_D
|
|||||||
find_package(KF6 REQUIRED COMPONENTS I18n Notifications Service WindowSystem)
|
find_package(KF6 REQUIRED COMPONENTS I18n Notifications Service WindowSystem)
|
||||||
find_package(LibTaskManager REQUIRED)
|
find_package(LibTaskManager REQUIRED)
|
||||||
find_package(Plasma REQUIRED)
|
find_package(Plasma REQUIRED)
|
||||||
|
find_package(KSysGuard REQUIRED)
|
||||||
include(KDEInstallDirs)
|
include(KDEInstallDirs)
|
||||||
include(KDECMakeSettings)
|
include(KDECMakeSettings)
|
||||||
include(KDECompilerSettings)
|
include(KDECompilerSettings)
|
||||||
set(Kf6_INCLUDE ${KDE_INSTALL_FULL_INCLUDEDIR_KF})
|
set(Kf6_INCLUDE ${KDE_INSTALL_FULL_INCLUDEDIR_KF})
|
||||||
set(Kf6_LIBRARIES KF6::I18n KF6::Notifications KF6::WindowSystem PW::LibTaskManager)
|
set(Kf6_LIBRARIES KF6::I18n KF6::Notifications KF6::WindowSystem KSysGuard::Sensors KSysGuard::SensorFaces PW::LibTaskManager)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user