From 120e201c5bbbae715cd8115bf184ac4e10c5a998 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 19 Sep 2015 10:25:26 +0300 Subject: [PATCH] * move update interval to another tab * some changes inside concurrent run * update COPYING to vanila format --- COPYING | 8 ++-- sources/CMakeLists.txt | 2 +- .../package/contents/ui/advanced.qml | 21 ++++++++++ .../package/contents/ui/appearance.qml | 21 ---------- sources/awesome-widget/plugin/awkeys.cpp | 41 +++++++++++-------- sources/awesome-widget/plugin/awkeys.h | 10 ++--- sources/awesomewidgets/abstractextitem.h | 1 - .../abstractextitemaggregator.h | 1 - 8 files changed, 53 insertions(+), 52 deletions(-) diff --git a/COPYING b/COPYING index cf0c57b..9cecc1d 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - awesome-widgets - Copyright (C) 2013-2014 Evgeniy Alekseev + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - awesome-widgets Copyright (C) 2013 Evgeniy Alekseev + {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 0d3527c..334c86f 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -25,7 +25,7 @@ message(STATUS "Project: ${PROJECT_NAME}") message(STATUS "Version: ${PROJECT_VERSION}") message(STATUS "Build date: ${CURRENT_DATE}") -option(BUILD_FUTURE "Build with the features which will be marked as stable later" ON) +option(BUILD_FUTURE "Build with the features which will be marked as stable later" OFF) option(BUILD_PLASMOIDS "Build plasmoids" ON) option(BUILD_DEB_PACKAGE "Build deb package" OFF) option(BUILD_RPM_PACKAGE "Build rpm package" OFF) diff --git a/sources/awesome-widget/package/contents/ui/advanced.qml b/sources/awesome-widget/package/contents/ui/advanced.qml index a3096d0..5f73c72 100644 --- a/sources/awesome-widget/package/contents/ui/advanced.qml +++ b/sources/awesome-widget/package/contents/ui/advanced.qml @@ -35,6 +35,7 @@ Item { property bool debug: awActions.isDebugEnabled() + property alias cfg_interval: update.value property alias cfg_height: widgetHeight.value property alias cfg_width: widgetWidth.value property alias cfg_notify: notify.checked @@ -53,6 +54,26 @@ Item { Column { id: pageColumn anchors.fill: parent + Row { + height: implicitHeight + width: parent.width + QtControls.Label { + height: parent.height + width: parent.width * 2 / 5 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: i18n("Time interval") + } + QtControls.SpinBox { + id: update + width: parent.width * 3 / 5 + minimumValue: 1000 + maximumValue: 10000 + stepSize: 500 + value: plasmoid.configuration.interval + } + } + Row { height: implicitHeight width: parent.width diff --git a/sources/awesome-widget/package/contents/ui/appearance.qml b/sources/awesome-widget/package/contents/ui/appearance.qml index 2d102a6..6559cb9 100644 --- a/sources/awesome-widget/package/contents/ui/appearance.qml +++ b/sources/awesome-widget/package/contents/ui/appearance.qml @@ -44,7 +44,6 @@ Item { 87: 5 } - property alias cfg_interval: update.value property alias cfg_fontFamily: selectFont.text property alias cfg_fontSize: fontSize.value property string cfg_fontWeight: fontWeight.currentText @@ -55,26 +54,6 @@ Item { Column { id: pageColumn anchors.fill: parent - Row { - height: implicitHeight - width: parent.width - QtControls.Label { - height: parent.height - width: parent.width / 3 - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: i18n("Time interval") - } - QtControls.SpinBox { - id: update - width: parent.width * 2 / 3 - minimumValue: 1000 - maximumValue: 10000 - stepSize: 500 - value: plasmoid.configuration.interval - } - } - Row { height: implicitHeight width: parent.width diff --git a/sources/awesome-widget/plugin/awkeys.cpp b/sources/awesome-widget/plugin/awkeys.cpp index 80d6872..86524f6 100644 --- a/sources/awesome-widget/plugin/awkeys.cpp +++ b/sources/awesome-widget/plugin/awkeys.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "awdebug.h" #include "awkeysaggregator.h" @@ -34,6 +36,7 @@ #include "extupgrade.h" #include "extweather.h" #include "graphicalitem.h" +#include "version.h" AWKeys::AWKeys(QObject *parent) @@ -50,6 +53,15 @@ AWKeys::AWKeys(QObject *parent) // transfer signal from AWDataAggregator object to QML ui connect(dataAggregator, SIGNAL(toolTipPainted(const QString)), this, SIGNAL(needToolTipToBeUpdated(const QString))); +#ifdef BUILD_FUTURE + // queue limit. It may be configured by using QUEUE_LIMIT cmake limit flag. + // In other hand since I'm using global thread pool, it makes sense to limit + // queue by QThread::idealThreadCount() value + queueLimit = QUEUE_LIMIT == 0 ? QThread::idealThreadCount() : QUEUE_LIMIT; + // thread pool + threadPool = new QThreadPool(this); + threadPool->setMaxThreadCount(queueLimit); +#endif /* BUILD_FUTURE */ } @@ -63,6 +75,7 @@ AWKeys::~AWKeys() if (extUpgrade != nullptr) delete extUpgrade; if (extWeather != nullptr) delete extWeather; + delete threadPool; delete aggregator; delete dataAggregator; } @@ -308,7 +321,7 @@ void AWKeys::dataUpdateReceived(const QString sourceName, const QVariantMap data // run concurrent data update #ifdef BUILD_FUTURE - QtConcurrent::run([this, sourceName, data]() { + QtConcurrent::run(threadPool, [this, sourceName, data]() { return setDataBySource(sourceName, data); }); #else /* BUILD_FUTURE */ @@ -643,26 +656,20 @@ QString AWKeys::parsePattern(QString pattern) const void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data) { -#ifdef BUILD_FUTURE - // check if data stream is locked -// if ((lock = ((lock) && (queue > 0)))) return; -#endif /* BUILD_FUTURE */ - qCDebug(LOG_AW); qCDebug(LOG_AW) << "Source" << sourceName; qCDebug(LOG_AW) << "Data" << data; - // update - if (sourceName == QString("update")) return emit(needToBeUpdated()); - +#ifdef BUILD_FUTURE + // check if data stream is locked + if ((lock = ((lock) && (queue > 0)))) return; // drop if limits are reached -// qDebug() << ++queue; -// if (queue > queueLimit) { if (++queue > queueLimit) { qCWarning(LOG_AW) << "Messages queue" << queue-- << "more than limits" << queueLimit; -// lock = true; + lock = true; return; } +#endif /* BUILD_FUTURE */ // first list init QStringList tags = aggregator->keysFromSource(sourceName); @@ -670,7 +677,9 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data) tags = aggregator->registerSource(sourceName, data[QString("units")].toString()); // update data or drop source if there are no matches - if (tags.isEmpty()) { + if (sourceName == QString("update")) { + emit(needToBeUpdated()); + } else if (tags.isEmpty()) { qCDebug(LOG_AW) << "Source" << sourceName << "not found"; emit(dropSourceFromDataengine(sourceName)); } else { @@ -681,9 +690,7 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data) }); } -// volatile float n = 1.0; -// for (volatile float i=1.0; i<100000.0; i++) -// n *= i; -// qDebug() << queue-- << queueLimit; +#ifdef BUILD_FUTURE queue--; +#endif /* BUILD_FUTURE */ } diff --git a/sources/awesome-widget/plugin/awkeys.h b/sources/awesome-widget/plugin/awkeys.h index cead73e..7127631 100644 --- a/sources/awesome-widget/plugin/awkeys.h +++ b/sources/awesome-widget/plugin/awkeys.h @@ -20,10 +20,8 @@ #define AWKEYS_H #include -#include #include "extitemaggregator.h" -#include "version.h" class AWDataAggregator; @@ -33,6 +31,7 @@ class ExtScript; class ExtUpgrade; class ExtWeather; class GraphicalItem; +class QThreadPool; class AWKeys : public QObject { @@ -91,11 +90,8 @@ private: bool m_wrapNewLines = false; // queue and stream lock properties bool lock = false; - int queue = 0; - // queue limit. It may be configured by using QUEUE_LIMIT cmake limit flag. - // In other hand since I'm using global thread pool, it makes sense to limit - // queue by QThread::idealThreadCount() value - const int queueLimit = QUEUE_LIMIT == 0 ? QThread::idealThreadCount() : QUEUE_LIMIT; + QThreadPool *threadPool = nullptr; + int queueLimit, queue = 0; }; diff --git a/sources/awesomewidgets/abstractextitem.h b/sources/awesomewidgets/abstractextitem.h index ac9d145..94077a7 100644 --- a/sources/awesomewidgets/abstractextitem.h +++ b/sources/awesomewidgets/abstractextitem.h @@ -19,7 +19,6 @@ #define ABSTRACTEXTITEM_H #include -#include #include diff --git a/sources/awesomewidgets/abstractextitemaggregator.h b/sources/awesomewidgets/abstractextitemaggregator.h index 7a23e5d..94ad6b4 100644 --- a/sources/awesomewidgets/abstractextitemaggregator.h +++ b/sources/awesomewidgets/abstractextitemaggregator.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include