mirror of
				https://github.com/arcan1s/awesome-widgets.git
				synced 2025-10-31 13:13:41 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			4.0.0alpha
			...
			cee37c6a4a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 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) | ||||
| { | ||||
|     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 | ||||
|     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 | ||||
|     static CFont fromQFont(const QFont font, | ||||
|                            const QColor color = QColor(QString("#000000"))); | ||||
|  | ||||
| @ -21,7 +21,6 @@ | ||||
| #include <QQmlPropertyMap> | ||||
| #include <QSettings> | ||||
| #include <QStandardPaths> | ||||
| #include <QTextCodec> | ||||
|  | ||||
| #include "awdebug.h" | ||||
|  | ||||
| @ -285,7 +284,6 @@ void AWConfigHelper::writeFile(QSettings &_settings, const QString &_key, const | ||||
|     QFile file(_fileName); | ||||
|     if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { | ||||
|         QTextStream out(&file); | ||||
|         out.setCodec("UTF-8"); | ||||
|         out << _settings.value(_key).toString().toUtf8(); | ||||
|         out.flush(); | ||||
|         file.close(); | ||||
|  | ||||
| @ -17,7 +17,8 @@ | ||||
|  | ||||
| #include "awdataengineaggregator.h" | ||||
|  | ||||
| #include <Plasma/DataContainer> | ||||
| #include <QDBusConnection> | ||||
| #include <ksysguard/systemstats/DBusInterface.h> | ||||
|  | ||||
| #include "awdebug.h" | ||||
|  | ||||
| @ -27,20 +28,19 @@ AWDataEngineAggregator::AWDataEngineAggregator(QObject *_parent) | ||||
| { | ||||
|     qCDebug(LOG_AW) << __PRETTY_FUNCTION__; | ||||
|  | ||||
|     m_consumer = new Plasma::DataEngineConsumer(); | ||||
|     m_dataEngines["systemmonitor"] = m_consumer->dataEngine("systemmonitor"); | ||||
|     m_dataEngines["extsysmon"] = m_consumer->dataEngine("extsysmon"); | ||||
|     m_dataEngines["time"] = m_consumer->dataEngine("time"); | ||||
|     qDBusRegisterMetaType<KSysGuard::SensorData>(); | ||||
|     qDBusRegisterMetaType<KSysGuard::SensorInfo>(); | ||||
|     qDBusRegisterMetaType<KSysGuard::SensorDataList>(); | ||||
|     qDBusRegisterMetaType<QHash<QString, KSysGuard::SensorInfo>>(); | ||||
|  | ||||
|     // additional method required by systemmonitor structure | ||||
|     m_newSourceConnection | ||||
|         = connect(m_dataEngines["systemmonitor"], &Plasma::DataEngine::sourceAdded, [this](const QString &source) { | ||||
|               emit(deviceAdded(source)); | ||||
|               m_dataEngines["systemmonitor"]->connectSource(source, parent(), 1000); | ||||
|           }); | ||||
|  | ||||
|     // required to define Qt::QueuedConnection for signal-slot connection | ||||
|     qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data"); | ||||
|     m_interface = new KSysGuard::SystemStats::DBusInterface( | ||||
|             KSysGuard::SystemStats::ServiceName, KSysGuard::SystemStats::ObjectPath, QDBusConnection::sessionBus(), this); | ||||
|     connect(m_interface, SIGNAL(newSensorData(KSysGuard::SensorDataList)), this, | ||||
|             SLOT(updateData(KSysGuard::SensorDataList))); | ||||
|     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> &))); | ||||
|     connect(m_interface, SIGNAL(sensorRemoved(const QString &)), this, SLOT(sensorRemoved(const QString &))); | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -54,62 +54,5 @@ AWDataEngineAggregator::~AWDataEngineAggregator() | ||||
|  | ||||
| void AWDataEngineAggregator::disconnectSources() | ||||
| { | ||||
|     for (auto dataEngine : m_dataEngines.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); | ||||
|         } | ||||
|     } | ||||
|     m_interface->unsubscribe(m_sensors.values()); | ||||
| } | ||||
|  | ||||
| @ -19,10 +19,16 @@ | ||||
| #ifndef AWDATAENGINEAGGREGATOR_H | ||||
| #define AWDATAENGINEAGGREGATOR_H | ||||
|  | ||||
| #include <Plasma/DataEngine> | ||||
| #include <Plasma/DataEngineConsumer> | ||||
| #include <ksysguard/systemstats/SensorInfo.h> | ||||
|  | ||||
| #include <QObject> | ||||
| #include <QSet> | ||||
|  | ||||
|  | ||||
| namespace KSysGuard::SystemStats | ||||
| { | ||||
|     class DBusInterface; | ||||
| } | ||||
|  | ||||
|  | ||||
| class AWDataEngineAggregator : public QObject | ||||
| @ -33,19 +39,20 @@ public: | ||||
|     explicit AWDataEngineAggregator(QObject *_parent = nullptr); | ||||
|     ~AWDataEngineAggregator() override; | ||||
|     void disconnectSources(); | ||||
|     void reconnectSources(int _interval); | ||||
|  | ||||
| signals: | ||||
|     void deviceAdded(const QString &_source); | ||||
|  | ||||
| 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: | ||||
|     void createQueuedConnection(); | ||||
|     Plasma::DataEngineConsumer *m_consumer = nullptr; | ||||
|     QHash<QString, Plasma::DataEngine *> m_dataEngines; | ||||
|     QMetaObject::Connection m_newSourceConnection; | ||||
|     KSysGuard::SystemStats::DBusInterface *m_interface = nullptr; | ||||
|     QSet<QString> m_sensors; | ||||
| }; | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -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 | ||||
|     QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, _sourceName, _data); | ||||
|     // TODO use QtConcurrent::map or something like that | ||||
|     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 | ||||
|     QStringList tags = m_aggregator->keysFromSource(_sourceName); | ||||
|  | ||||
| @ -19,11 +19,11 @@ | ||||
| #ifndef AWKEYS_H | ||||
| #define AWKEYS_H | ||||
|  | ||||
| #include <Plasma/DataEngine> | ||||
|  | ||||
| #include <QMutex> | ||||
| #include <QObject> | ||||
|  | ||||
| #include <ksysguard/systemstats/SensorInfo.h> | ||||
|  | ||||
|  | ||||
| class AWDataAggregator; | ||||
| class AWDataEngineAggregator; | ||||
| @ -56,9 +56,7 @@ public: | ||||
|     Q_INVOKABLE void editItem(const QString &_type); | ||||
|  | ||||
| public slots: | ||||
|     void dataUpdated(const QString &_sourceName, const Plasma::DataEngine::Data &_data); | ||||
|     // dummy method required by DataEngine connections | ||||
|     static void modelChanged(const QString &, QAbstractItemModel *){}; | ||||
|     void dataUpdated(const KSysGuard::SensorDataList &_data); | ||||
|  | ||||
| signals: | ||||
|     void dropSourceFromDataengine(const QString &_source); | ||||
| @ -74,7 +72,7 @@ private: | ||||
|     void calculateValues(); | ||||
|     void createDBusInterface(); | ||||
|     [[nodiscard]] QString parsePattern(QString _pattern) const; | ||||
|     void setDataBySource(const QString &_sourceName, const QVariantMap &_data); | ||||
|     void setDataBySource(const KSysGuard::SensorData &_data); | ||||
|     // objects | ||||
|     AWDataAggregator *m_dataAggregator = 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(LibTaskManager REQUIRED) | ||||
| find_package(Plasma REQUIRED) | ||||
| find_package(KSysGuard REQUIRED) | ||||
| include(KDEInstallDirs) | ||||
| include(KDECMakeSettings) | ||||
| include(KDECompilerSettings) | ||||
| 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) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user