mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
* better extensions update
* prepare dataaggregator to graph data * add ability to wrap text * move tag selection dialog to ui
This commit is contained in:
parent
f08600db61
commit
dddc3962a5
@ -50,6 +50,9 @@
|
|||||||
<entry name="translateStrings" type="bool">
|
<entry name="translateStrings" type="bool">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="wrapText" type="bool">
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group name="Tooltip">
|
<group name="Tooltip">
|
||||||
|
@ -47,6 +47,7 @@ Item {
|
|||||||
property alias cfg_acOffline: acOffline.text
|
property alias cfg_acOffline: acOffline.text
|
||||||
property alias cfg_checkUpdates: updates.checked
|
property alias cfg_checkUpdates: updates.checked
|
||||||
property alias cfg_translateStrings: translate.checked
|
property alias cfg_translateStrings: translate.checked
|
||||||
|
property alias cfg_wrapText: wordWrap.checked
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@ -120,6 +121,20 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
height: parent.heigth
|
||||||
|
width: parent.width * 2 / 5
|
||||||
|
}
|
||||||
|
QtControls.CheckBox {
|
||||||
|
id: wordWrap
|
||||||
|
width: parent.width * 3 / 5
|
||||||
|
text: i18n("Enable word wrap")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import QtQuick 2.4
|
import QtQuick 2.4
|
||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
|
import QtQuick.Dialogs 1.2 as QtDialogs
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import org.kde.plasma.plasmoid 2.0
|
import org.kde.plasma.plasmoid 2.0
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
@ -37,13 +38,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
property bool debug: awActions.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
property variant settings: {
|
|
||||||
"customTime": plasmoid.configuration.customTime,
|
|
||||||
"customUptime": plasmoid.configuration.customUptime,
|
|
||||||
"tempUnits": plasmoid.configuration.tempUnits,
|
|
||||||
"acOnline": plasmoid.configuration.acOnline,
|
|
||||||
"acOffline": plasmoid.configuration.acOffline
|
|
||||||
}
|
|
||||||
property variant tooltipSettings: {
|
property variant tooltipSettings: {
|
||||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
||||||
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
||||||
@ -63,8 +57,10 @@ Item {
|
|||||||
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
||||||
"batTooltipColor": plasmoid.configuration.batTooltipColor,
|
"batTooltipColor": plasmoid.configuration.batTooltipColor,
|
||||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor,
|
"batInTooltipColor": plasmoid.configuration.batInTooltipColor,
|
||||||
// additinal field to parse AC status
|
// additional field to parse AC status
|
||||||
"acOnline": plasmoid.configuration.acOnline
|
"acOnline": plasmoid.configuration.acOnline,
|
||||||
|
// additional field to send notifications
|
||||||
|
"notify": plasmoid.configuration.notify
|
||||||
}
|
}
|
||||||
|
|
||||||
signal dropSource(string sourceName)
|
signal dropSource(string sourceName)
|
||||||
@ -93,7 +89,7 @@ Item {
|
|||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.debug("Update source", sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
awKeys.dataUpdateReceived(sourceName, data, settings)
|
awKeys.dataUpdateReceived(sourceName, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
onSourceAdded: {
|
onSourceAdded: {
|
||||||
@ -110,8 +106,7 @@ Item {
|
|||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.debug("Update source", sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
// extsysmonDE.interval = plasmoid.configuration.interval
|
awKeys.dataUpdateReceived(sourceName, data)
|
||||||
awKeys.dataUpdateReceived(sourceName, data, settings)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +118,7 @@ Item {
|
|||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.debug("Update source", sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
awKeys.dataUpdateReceived(sourceName, data, settings)
|
awKeys.dataUpdateReceived(sourceName, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +129,7 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: plasmoid.configuration.wrapText ? Text.WordWrap : Text.NoWrap
|
||||||
|
|
||||||
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
@ -157,6 +152,27 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtDialogs.Dialog {
|
||||||
|
id: tagSelector
|
||||||
|
title: i18n("Select tag")
|
||||||
|
|
||||||
|
QtControls.ComboBox {
|
||||||
|
id: tagSelectorBox
|
||||||
|
width: parent.width
|
||||||
|
editable: true
|
||||||
|
}
|
||||||
|
|
||||||
|
onAccepted: {
|
||||||
|
var tag = tagSelectorBox.editText
|
||||||
|
var message = i18n("Tag: %1", tag)
|
||||||
|
message += "<br>"
|
||||||
|
message += i18n("Value: %1", awKeys.valueByKey(tag))
|
||||||
|
message += "<br>"
|
||||||
|
message += i18n("Info: %1", awKeys.infoByKey(tag))
|
||||||
|
awActions.sendNotification("tag", message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.debug()
|
if (debug) console.debug()
|
||||||
|
|
||||||
@ -221,10 +237,15 @@ Item {
|
|||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
awKeys.initKeys(plasmoid.configuration.text)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
awKeys.initTooltip(tooltipSettings)
|
awKeys.initDataAggregator(tooltipSettings)
|
||||||
awKeys.setPopupEnabled(plasmoid.configuration.notify)
|
|
||||||
awKeys.setTranslateStrings(plasmoid.configuration.translateStrings)
|
|
||||||
awKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
awKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||||
|
// configure aggregator
|
||||||
|
awKeys.setAggregatorProperty("acOffline", plasmoid.configuration.acOffline)
|
||||||
|
awKeys.setAggregatorProperty("acOnline", plasmoid.configuration.acOnline)
|
||||||
|
awKeys.setAggregatorProperty("customTime", plasmoid.configuration.customTime)
|
||||||
|
awKeys.setAggregatorProperty("customUptime", plasmoid.configuration.customUptime)
|
||||||
|
awKeys.setAggregatorProperty("tempUnits", plasmoid.configuration.tempUnits)
|
||||||
|
awKeys.setAggregatorProperty("translate", plasmoid.configuration.translateStrings)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_checkUpdates() {
|
function action_checkUpdates() {
|
||||||
@ -242,6 +263,7 @@ Item {
|
|||||||
function action_requestKey() {
|
function action_requestKey() {
|
||||||
if (debug) console.debug()
|
if (debug) console.debug()
|
||||||
|
|
||||||
return awKeys.graphicalValueByKey()
|
tagSelectorBox.model = awKeys.dictKeys(true)
|
||||||
|
return tagSelector.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,33 +38,6 @@ Item {
|
|||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: awActions.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
property variant settings: {
|
|
||||||
"customTime": plasmoid.configuration.customTime,
|
|
||||||
"customUptime": plasmoid.configuration.customUptime,
|
|
||||||
"tempUnits": plasmoid.configuration.tempUnits,
|
|
||||||
"acOnline": plasmoid.configuration.acOnline,
|
|
||||||
"acOffline": plasmoid.configuration.acOffline
|
|
||||||
}
|
|
||||||
property variant tooltipSettings: {
|
|
||||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
|
||||||
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
|
||||||
"tooltipBackgroung": plasmoid.configuration.tooltipBackgroung,
|
|
||||||
"cpuTooltip": plasmoid.configuration.cpuTooltip,
|
|
||||||
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
|
|
||||||
"memTooltip": plasmoid.configuration.memTooltip,
|
|
||||||
"swapTooltip": plasmoid.configuration.swapTooltip,
|
|
||||||
"downTooltip": plasmoid.configuration.downTooltip,
|
|
||||||
"upTooltip": plasmoid.configuration.downTooltip,
|
|
||||||
"batTooltip": plasmoid.configuration.batTooltip,
|
|
||||||
"cpuTooltipColor": plasmoid.configuration.cpuTooltipColor,
|
|
||||||
"cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor,
|
|
||||||
"memTooltipColor": plasmoid.configuration.memTooltipColor,
|
|
||||||
"swapTooltipColor": plasmoid.configuration.swapTooltipColor,
|
|
||||||
"downTooltipColor": plasmoid.configuration.downTooltipColor,
|
|
||||||
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
|
||||||
"batTooltipColor": plasmoid.configuration.batTooltipColor,
|
|
||||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor
|
|
||||||
}
|
|
||||||
|
|
||||||
property alias cfg_text: textPattern.text
|
property alias cfg_text: textPattern.text
|
||||||
|
|
||||||
@ -362,7 +335,7 @@ Item {
|
|||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.debug("Update source", sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
awKeys.dataUpdateReceived(sourceName, data, settings)
|
awKeys.dataUpdateReceived(sourceName, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +347,7 @@ Item {
|
|||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.debug("Update source", sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
awKeys.dataUpdateReceived(sourceName, data, settings)
|
awKeys.dataUpdateReceived(sourceName, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,16 +359,24 @@ Item {
|
|||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.debug("Update source", sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
awKeys.dataUpdateReceived(sourceName, data, settings)
|
awKeys.dataUpdateReceived(sourceName, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.debug()
|
if (debug) console.debug()
|
||||||
|
|
||||||
|
// drop "update" source which does not required by this page
|
||||||
|
extsysmonDE.disconnectSource("update")
|
||||||
awKeys.dropSourceFromDataengine.connect(dropSource)
|
awKeys.dropSourceFromDataengine.connect(dropSource)
|
||||||
// init submodule
|
// init submodule
|
||||||
awKeys.initKeys(plasmoid.configuration.text)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
|
awKeys.setAggregatorProperty("acOffline", plasmoid.configuration.acOffline)
|
||||||
|
awKeys.setAggregatorProperty("acOnline", plasmoid.configuration.acOnline)
|
||||||
|
awKeys.setAggregatorProperty("customTime", plasmoid.configuration.customTime)
|
||||||
|
awKeys.setAggregatorProperty("customUptime", plasmoid.configuration.customUptime)
|
||||||
|
awKeys.setAggregatorProperty("tempUnits", plasmoid.configuration.tempUnits)
|
||||||
|
awKeys.setAggregatorProperty("translate", plasmoid.configuration.translateStrings)
|
||||||
}
|
}
|
||||||
|
|
||||||
onDropSource: {
|
onDropSource: {
|
||||||
|
@ -20,25 +20,69 @@
|
|||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "awactions.h"
|
#include "awactions.h"
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
AWDataAggregator::AWDataAggregator(QObject *parent, QVariantMap settings)
|
AWDataAggregator::AWDataAggregator(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent)
|
||||||
configuration(qvariant_cast<QVariantHash>(settings))
|
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
toolTipScene = new QGraphicsScene(nullptr);
|
initScene();
|
||||||
toolTipView = new QGraphicsView(toolTipScene);
|
|
||||||
toolTipView->setStyleSheet(QString("background: transparent"));
|
connect(this, SIGNAL(updateData(QHash<QString, QString>)),
|
||||||
toolTipView->setContentsMargins(0, 0, 0, 0);
|
this, SLOT(dataUpdate(QHash<QString, QString>)));
|
||||||
toolTipView->setFrameShape(QFrame::NoFrame);
|
}
|
||||||
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
|
AWDataAggregator::~AWDataAggregator()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
delete toolTipScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<float> AWDataAggregator::getData(const QString key) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Key" << key;
|
||||||
|
|
||||||
|
return data[QString("%1Tooltip").arg(key)];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QSize AWDataAggregator::getTooltipSize() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWDataAggregator::htmlImage(const QPixmap source) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
QByteArray byteArray;
|
||||||
|
QBuffer buffer(&byteArray);
|
||||||
|
source.save(&buffer, "PNG");
|
||||||
|
|
||||||
|
return byteArray.isEmpty() ? QString() :
|
||||||
|
QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWDataAggregator::setParameters(QVariantMap settings)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Settings" << settings;
|
||||||
|
|
||||||
|
configuration = qvariant_cast<QVariantHash>(settings);
|
||||||
|
|
||||||
enablePopup = configuration[QString("notify")].toBool();
|
enablePopup = configuration[QString("notify")].toBool();
|
||||||
|
|
||||||
@ -67,66 +111,10 @@ AWDataAggregator::AWDataAggregator(QObject *parent, QVariantMap settings)
|
|||||||
if (configuration[QString("upTooltip")].toBool()) requiredKeys.append(QString("upTooltip"));
|
if (configuration[QString("upTooltip")].toBool()) requiredKeys.append(QString("upTooltip"));
|
||||||
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("batTooltip"));
|
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("batTooltip"));
|
||||||
|
|
||||||
connect(this, SIGNAL(updateData(QHash<QString, QString>)),
|
// background
|
||||||
this, SLOT(dataUpdate(QHash<QString, QString>)));
|
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool() ?
|
||||||
}
|
QBrush(QColor(configuration[QString("tooltipBackground")].toString())) :
|
||||||
|
QBrush(Qt::NoBrush));
|
||||||
|
|
||||||
AWDataAggregator::~AWDataAggregator()
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW);
|
|
||||||
|
|
||||||
delete toolTipScene;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWDataAggregator::dataUpdate(QHash<QString, QString> values)
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW);
|
|
||||||
|
|
||||||
// battery update requires info is AC online or not
|
|
||||||
setData(values[QString("ac")] == configuration[QString("acOnline")],
|
|
||||||
QString("batTooltip"), values[QString("bat")].toFloat());
|
|
||||||
// usual case
|
|
||||||
setData(QString("cpuTooltip"), values[QString("cpu")].toFloat(), 90.0);
|
|
||||||
setData(QString("cpuclTooltip"), values[QString("cpucl")].toFloat());
|
|
||||||
setData(QString("memTooltip"), values[QString("mem")].toFloat(), 90.0);
|
|
||||||
setData(QString("swapTooltip"), values[QString("swap")].toFloat(), 0.0);
|
|
||||||
setData(QString("downTooltip"), values[QString("downkb")].toFloat());
|
|
||||||
setData(QString("upTooltip"), values[QString("upkb")].toFloat());
|
|
||||||
// additional check for network device
|
|
||||||
[this](const QString value) {
|
|
||||||
checkValue(QString("netdev"), currentNetworkDevice, value);
|
|
||||||
currentNetworkDevice = value;
|
|
||||||
}(values[QString("netdev")]);
|
|
||||||
// additional check for GPU load
|
|
||||||
[this](const float value) {
|
|
||||||
checkValue(QString("gpu"), value, 90.0);
|
|
||||||
currentGPULoad = value;
|
|
||||||
}(values[QString("gpu")].toFloat());
|
|
||||||
|
|
||||||
emit(toolTipPainted(htmlImage(tooltipImage())));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QSize AWDataAggregator::getTooltipSize() const
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW);
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString AWDataAggregator::htmlImage(const QPixmap source)
|
|
||||||
{
|
|
||||||
qCDebug(LOG_AW);
|
|
||||||
|
|
||||||
QByteArray byteArray;
|
|
||||||
QBuffer buffer(&byteArray);
|
|
||||||
source.save(&buffer, "PNG");
|
|
||||||
|
|
||||||
return byteArray.isEmpty() ? QString() :
|
|
||||||
QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,10 +126,6 @@ QPixmap AWDataAggregator::tooltipImage()
|
|||||||
// create image
|
// create image
|
||||||
toolTipScene->clear();
|
toolTipScene->clear();
|
||||||
QPen pen = QPen();
|
QPen pen = QPen();
|
||||||
// background
|
|
||||||
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool() ?
|
|
||||||
QBrush(QColor(configuration[QString("tooltipBackground")].toString())) :
|
|
||||||
QBrush(Qt::NoBrush));
|
|
||||||
bool down = false;
|
bool down = false;
|
||||||
foreach(QString key, requiredKeys) {
|
foreach(QString key, requiredKeys) {
|
||||||
// create frame
|
// create frame
|
||||||
@ -174,6 +158,35 @@ QPixmap AWDataAggregator::tooltipImage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWDataAggregator::dataUpdate(QHash<QString, QString> values)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
// battery update requires info is AC online or not
|
||||||
|
setData(values[QString("ac")] == configuration[QString("acOnline")],
|
||||||
|
QString("batTooltip"), values[QString("bat")].toFloat());
|
||||||
|
// usual case
|
||||||
|
setData(QString("cpuTooltip"), values[QString("cpu")].toFloat(), 90.0);
|
||||||
|
setData(QString("cpuclTooltip"), values[QString("cpucl")].toFloat());
|
||||||
|
setData(QString("memTooltip"), values[QString("mem")].toFloat(), 90.0);
|
||||||
|
setData(QString("swapTooltip"), values[QString("swap")].toFloat(), 0.0);
|
||||||
|
setData(QString("downTooltip"), values[QString("downkb")].toFloat());
|
||||||
|
setData(QString("upTooltip"), values[QString("upkb")].toFloat());
|
||||||
|
// additional check for network device
|
||||||
|
[this](const QString value) {
|
||||||
|
checkValue(QString("netdev"), currentNetworkDevice, value);
|
||||||
|
currentNetworkDevice = value;
|
||||||
|
}(values[QString("netdev")]);
|
||||||
|
// additional check for GPU load
|
||||||
|
[this](const float value) {
|
||||||
|
checkValue(QString("gpu"), value, 90.0);
|
||||||
|
currentGPULoad = value;
|
||||||
|
}(values[QString("gpu")].toFloat());
|
||||||
|
|
||||||
|
emit(toolTipPainted(htmlImage(tooltipImage())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWDataAggregator::checkValue(const QString source, const float value, const float extremum) const
|
void AWDataAggregator::checkValue(const QString source, const float value, const float extremum) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
@ -181,8 +194,13 @@ void AWDataAggregator::checkValue(const QString source, const float value, const
|
|||||||
qCDebug(LOG_AW) << "Value" << value;
|
qCDebug(LOG_AW) << "Value" << value;
|
||||||
qCDebug(LOG_AW) << "Called with extremum" << extremum;
|
qCDebug(LOG_AW) << "Called with extremum" << extremum;
|
||||||
|
|
||||||
|
if (value >= 0.0) {
|
||||||
if ((enablePopup) && (value > extremum) && (data[source].last() < extremum))
|
if ((enablePopup) && (value > extremum) && (data[source].last() < extremum))
|
||||||
return AWActions::sendNotification(QString("event"), notificationText(source, value));
|
return AWActions::sendNotification(QString("event"), notificationText(source, value));
|
||||||
|
} else {
|
||||||
|
if ((enablePopup) && (value < extremum) && (data[source].last() > extremum))
|
||||||
|
return AWActions::sendNotification(QString("event"), notificationText(source, value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -198,6 +216,20 @@ void AWDataAggregator::checkValue(const QString source, const QString current, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWDataAggregator::initScene()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
toolTipScene = new QGraphicsScene(nullptr);
|
||||||
|
toolTipView = new QGraphicsView(toolTipScene);
|
||||||
|
toolTipView->setStyleSheet(QString("background: transparent"));
|
||||||
|
toolTipView->setContentsMargins(0, 0, 0, 0);
|
||||||
|
toolTipView->setFrameShape(QFrame::NoFrame);
|
||||||
|
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWDataAggregator::notificationText(const QString source, const float value) const
|
QString AWDataAggregator::notificationText(const QString source, const float value) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
@ -32,10 +32,12 @@ class AWDataAggregator : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AWDataAggregator(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
|
explicit AWDataAggregator(QObject *parent = nullptr);
|
||||||
virtual ~AWDataAggregator();
|
virtual ~AWDataAggregator();
|
||||||
|
QList<float> getData(const QString key) const;
|
||||||
QSize getTooltipSize() const;
|
QSize getTooltipSize() const;
|
||||||
QString htmlImage(const QPixmap source);
|
QString htmlImage(const QPixmap source) const;
|
||||||
|
void setParameters(QVariantMap settings);
|
||||||
QPixmap tooltipImage();
|
QPixmap tooltipImage();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -51,6 +53,7 @@ private:
|
|||||||
QGraphicsView *toolTipView = nullptr;
|
QGraphicsView *toolTipView = nullptr;
|
||||||
void checkValue(const QString source, const float value, const float extremum) const;
|
void checkValue(const QString source, const float value, const float extremum) const;
|
||||||
void checkValue(const QString source, const QString current, const QString received) const;
|
void checkValue(const QString source, const QString current, const QString received) const;
|
||||||
|
void initScene();
|
||||||
QString notificationText(const QString source, const float value) const;
|
QString notificationText(const QString source, const float value) const;
|
||||||
QString notificationText(const QString source, const QString value) const;
|
QString notificationText(const QString source, const QString value) const;
|
||||||
void setData(const QString source, float value, const float extremum = -1.0);
|
void setData(const QString source, float value, const float extremum = -1.0);
|
||||||
@ -60,7 +63,7 @@ private:
|
|||||||
int counts = 0;
|
int counts = 0;
|
||||||
QVariantHash configuration;
|
QVariantHash configuration;
|
||||||
float currentGPULoad = 0.0;
|
float currentGPULoad = 0.0;
|
||||||
QString currentNetworkDevice;
|
QString currentNetworkDevice = QString("lo");
|
||||||
QHash<QString, float> boundaries;
|
QHash<QString, float> boundaries;
|
||||||
QHash<QString, QList<float>> data;
|
QHash<QString, QList<float>> data;
|
||||||
bool enablePopup = false;
|
bool enablePopup = false;
|
||||||
|
@ -46,14 +46,11 @@ AWKeys::AWKeys(QObject *parent)
|
|||||||
qSetMessagePattern(LOG_FORMAT);
|
qSetMessagePattern(LOG_FORMAT);
|
||||||
|
|
||||||
aggregator = new AWKeysAggregator(this);
|
aggregator = new AWKeysAggregator(this);
|
||||||
|
dataAggregator = new AWDataAggregator(this);
|
||||||
// backend
|
|
||||||
graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, QString("desktops"));
|
|
||||||
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"));
|
|
||||||
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"));
|
|
||||||
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"));
|
|
||||||
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"));
|
|
||||||
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(dataUpdate()));
|
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(dataUpdate()));
|
||||||
|
// transfer signal from AWDataAggregator object to QML ui
|
||||||
|
connect(dataAggregator, SIGNAL(toolTipPainted(QString)),
|
||||||
|
this, SIGNAL(needToolTipToBeUpdated(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,14 +58,14 @@ AWKeys::~AWKeys()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
if (dataAggregator != nullptr) delete dataAggregator;
|
if (graphicalItems != nullptr) delete graphicalItems;
|
||||||
|
if (extQuotes != nullptr) delete extQuotes;
|
||||||
|
if (extScripts != nullptr) delete extScripts;
|
||||||
|
if (extUpgrade != nullptr) delete extUpgrade;
|
||||||
|
if (extWeather != nullptr) delete extWeather;
|
||||||
|
|
||||||
delete aggregator;
|
delete aggregator;
|
||||||
delete graphicalItems;
|
delete dataAggregator;
|
||||||
delete extQuotes;
|
|
||||||
delete extScripts;
|
|
||||||
delete extUpgrade;
|
|
||||||
delete extWeather;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,16 +74,7 @@ void AWKeys::initDataAggregator(const QVariantMap tooltipParams)
|
|||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
qCDebug(LOG_AW) << "Tooltip parameters" << tooltipParams;
|
qCDebug(LOG_AW) << "Tooltip parameters" << tooltipParams;
|
||||||
|
|
||||||
if (dataAggregator != nullptr) {
|
dataAggregator->setParameters(tooltipParams);
|
||||||
disconnect(dataAggregator, SIGNAL(toolTipPainted(QString)),
|
|
||||||
this, SIGNAL(needToolTipToBeUpdated(QString)));
|
|
||||||
delete dataAggregator;
|
|
||||||
}
|
|
||||||
|
|
||||||
dataAggregator = new AWDataAggregator(this, tooltipParams);
|
|
||||||
// transfer signal from AWDataAggregator object to QML ui
|
|
||||||
connect(dataAggregator, SIGNAL(toolTipPainted(QString)),
|
|
||||||
this, SIGNAL(needToolTipToBeUpdated(QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +122,6 @@ void AWKeys::setWrapNewLines(const bool wrap)
|
|||||||
QSize AWKeys::toolTipSize() const
|
QSize AWKeys::toolTipSize() const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
if (dataAggregator == nullptr) return QSize();
|
|
||||||
|
|
||||||
return dataAggregator->getTooltipSize();
|
return dataAggregator->getTooltipSize();
|
||||||
}
|
}
|
||||||
@ -418,7 +405,7 @@ void AWKeys::dataUpdate()
|
|||||||
calculateValues();
|
calculateValues();
|
||||||
calculateLambdas();
|
calculateLambdas();
|
||||||
emit(needTextToBeUpdated(parsePattern()));
|
emit(needTextToBeUpdated(parsePattern()));
|
||||||
if (dataAggregator != nullptr) emit(dataAggregator->updateData(values));
|
emit(dataAggregator->updateData(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -469,6 +456,20 @@ void AWKeys::reinitKeys()
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW);
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
// renew extensions
|
||||||
|
// delete them if any
|
||||||
|
if (graphicalItems != nullptr) delete graphicalItems;
|
||||||
|
if (extQuotes != nullptr) delete extQuotes;
|
||||||
|
if (extScripts != nullptr) delete extScripts;
|
||||||
|
if (extUpgrade != nullptr) delete extUpgrade;
|
||||||
|
if (extWeather != nullptr) delete extWeather;
|
||||||
|
// create
|
||||||
|
graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, QString("desktops"));
|
||||||
|
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"));
|
||||||
|
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"));
|
||||||
|
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"));
|
||||||
|
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"));
|
||||||
|
|
||||||
// init
|
// init
|
||||||
QStringList allKeys = dictKeys();
|
QStringList allKeys = dictKeys();
|
||||||
|
|
||||||
@ -678,9 +679,18 @@ QString AWKeys::parsePattern() const
|
|||||||
}(key, values[key]));
|
}(key, values[key]));
|
||||||
|
|
||||||
// bars
|
// bars
|
||||||
foreach(QString bar, foundBars)
|
foreach(QString bar, foundBars) {
|
||||||
parsed.replace(QString("$%1").arg(bar),
|
GraphicalItem *item = graphicalItems->itemByTag(bar);
|
||||||
graphicalItems->itemByTag(bar)->image(valueByKey(bar).toFloat()));
|
QString key = bar;
|
||||||
|
key.remove(QRegExp(QString("^bar[0-9]{1,}")));
|
||||||
|
if (item->type() == GraphicalItem::Graph)
|
||||||
|
parsed.replace(QString("$%1").arg(bar), item->image([](const QList<float> data) {
|
||||||
|
return QVariant::fromValue<QList<float>>(data);
|
||||||
|
}(dataAggregator->getData(key))));
|
||||||
|
else
|
||||||
|
parsed.replace(QString("$%1").arg(bar), item->image(values[key]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// prepare strings
|
// prepare strings
|
||||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||||
|
@ -82,11 +82,11 @@ private:
|
|||||||
AWDataAggregator *dataAggregator = nullptr;
|
AWDataAggregator *dataAggregator = nullptr;
|
||||||
bool enablePopup = false;
|
bool enablePopup = false;
|
||||||
bool wrapNewLines = false;
|
bool wrapNewLines = false;
|
||||||
ExtItemAggregator<GraphicalItem> *graphicalItems;
|
ExtItemAggregator<GraphicalItem> *graphicalItems = nullptr;
|
||||||
ExtItemAggregator<ExtQuotes> *extQuotes;
|
ExtItemAggregator<ExtQuotes> *extQuotes = nullptr;
|
||||||
ExtItemAggregator<ExtScript> *extScripts;
|
ExtItemAggregator<ExtScript> *extScripts = nullptr;
|
||||||
ExtItemAggregator<ExtUpgrade> *extUpgrade;
|
ExtItemAggregator<ExtUpgrade> *extUpgrade = nullptr;
|
||||||
ExtItemAggregator<ExtWeather> *extWeather;
|
ExtItemAggregator<ExtWeather> *extWeather = nullptr;
|
||||||
bool lock = false;
|
bool lock = false;
|
||||||
int queue = 0;
|
int queue = 0;
|
||||||
QString pattern;
|
QString pattern;
|
||||||
|
Loading…
Reference in New Issue
Block a user