Compare commits

..

11 Commits

Author SHA1 Message Date
161ff64293 Release 4.0.0 2024-03-25 14:04:30 +02:00
115bef3dbe correct subscription processing 2024-03-24 00:42:03 +02:00
b6ade7310a extend temperature sensors 2024-03-23 15:30:35 +02:00
0555185044 add time source 2024-03-23 15:11:49 +02:00
23e197789f make it build together 2024-03-23 13:57:28 +02:00
67640cccdc do not derive from qwidget in aggregates 2024-03-22 16:57:47 +02:00
33a41bb6c0 do not derive from qwidget 2024-03-21 16:51:29 +02:00
42c11a6b60 port dataengin 2024-03-20 18:45:17 +02:00
423597dbd9 port widget to dbus 2024-03-15 15:51:23 +02:00
0fcfb7d7e4 port library 2024-03-08 16:22:00 +02:00
5fd3a4a21a update to plasma 6 support 2024-03-07 12:09:46 +02:00
222 changed files with 3783 additions and 1285 deletions

View File

@ -27,10 +27,10 @@ jobs:
run: pacman -Sy --noconfirm base-devel cmake extra-cmake-modules python util-linux-libs xorg-server-xvfb
- name: install dependencies
run: pacman -S --noconfirm plasma-workspace
run: pacman -S --noconfirm plasma-workspace ksysguard
- name: configure cmake
run: cmake -B build -S sources -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FUTURE=ON -DBUILD_TESTING=ON
run: cmake -B build -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FUTURE=ON -DBUILD_TESTING=ON sources
- name: build
working-directory: /repo/build

View File

@ -2,14 +2,17 @@
pkgname=plasma6-applet-awesome-widgets
_pkgname=awesome-widgets
pkgver=4.0.0alpha2
pkgver=4.0.0alpha1
pkgrel=1
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
arch=('x86_64')
url="https://arcanis.me/projects/awesome-widgets"
license=('GPL3')
depends=('plasma-workspace')
optdepends=("mpd: for music player monitor")
optdepends=("hddtemp: for HDD temperature monitor"
"smartmontools: for HDD temperature monitor"
"mpd: for music player monitor"
"nvidia-utils: for GPU monitor")
makedepends=('cmake' 'extra-cmake-modules' 'python')
source=(https://github.com/arcan1s/awesome-widgets/releases/download/${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
install="$pkgname.install"

284
sensors Normal file
View File

@ -0,0 +1,284 @@
cpu
cpu/all
cpu/all/averageFrequency
cpu/all/averageTemperature
cpu/all/coreCount
cpu/all/cpuCount
cpu/all/maximumFrequency
cpu/all/maximumTemperature
cpu/all/minimumFrequency
cpu/all/minimumTemperature
cpu/all/name
cpu/all/system
cpu/all/usage
cpu/all/user
cpu/all/wait
cpu/cpu0
cpu/cpu0/frequency
cpu/cpu0/name
cpu/cpu0/system
cpu/cpu0/temperature
cpu/cpu0/usage
cpu/cpu0/user
cpu/cpu0/wait
cpu/cpu1
cpu/cpu1/frequency
cpu/cpu1/name
cpu/cpu1/system
cpu/cpu1/temperature
cpu/cpu1/usage
cpu/cpu1/user
cpu/cpu1/wait
cpu/cpu10
cpu/cpu10/frequency
cpu/cpu10/name
cpu/cpu10/system
cpu/cpu10/temperature
cpu/cpu10/usage
cpu/cpu10/user
cpu/cpu10/wait
cpu/cpu11
cpu/cpu11/frequency
cpu/cpu11/name
cpu/cpu11/system
cpu/cpu11/temperature
cpu/cpu11/usage
cpu/cpu11/user
cpu/cpu11/wait
cpu/cpu12
cpu/cpu12/frequency
cpu/cpu12/name
cpu/cpu12/system
cpu/cpu12/temperature
cpu/cpu12/usage
cpu/cpu12/user
cpu/cpu12/wait
cpu/cpu13
cpu/cpu13/frequency
cpu/cpu13/name
cpu/cpu13/system
cpu/cpu13/temperature
cpu/cpu13/usage
cpu/cpu13/user
cpu/cpu13/wait
cpu/cpu14
cpu/cpu14/frequency
cpu/cpu14/name
cpu/cpu14/system
cpu/cpu14/temperature
cpu/cpu14/usage
cpu/cpu14/user
cpu/cpu14/wait
cpu/cpu15
cpu/cpu15/frequency
cpu/cpu15/name
cpu/cpu15/system
cpu/cpu15/temperature
cpu/cpu15/usage
cpu/cpu15/user
cpu/cpu15/wait
cpu/cpu16
cpu/cpu16/frequency
cpu/cpu16/name
cpu/cpu16/system
cpu/cpu16/temperature
cpu/cpu16/usage
cpu/cpu16/user
cpu/cpu16/wait
cpu/cpu17
cpu/cpu17/frequency
cpu/cpu17/name
cpu/cpu17/system
cpu/cpu17/temperature
cpu/cpu17/usage
cpu/cpu17/user
cpu/cpu17/wait
cpu/cpu18
cpu/cpu18/frequency
cpu/cpu18/name
cpu/cpu18/system
cpu/cpu18/temperature
cpu/cpu18/usage
cpu/cpu18/user
cpu/cpu18/wait
cpu/cpu19
cpu/cpu19/frequency
cpu/cpu19/name
cpu/cpu19/system
cpu/cpu19/temperature
cpu/cpu19/usage
cpu/cpu19/user
cpu/cpu19/wait
cpu/cpu2
cpu/cpu2/frequency
cpu/cpu2/name
cpu/cpu2/system
cpu/cpu2/temperature
cpu/cpu2/usage
cpu/cpu2/user
cpu/cpu2/wait
cpu/cpu3
cpu/cpu3/frequency
cpu/cpu3/name
cpu/cpu3/system
cpu/cpu3/temperature
cpu/cpu3/usage
cpu/cpu3/user
cpu/cpu3/wait
cpu/cpu4
cpu/cpu4/frequency
cpu/cpu4/name
cpu/cpu4/system
cpu/cpu4/temperature
cpu/cpu4/usage
cpu/cpu4/user
cpu/cpu4/wait
cpu/cpu5
cpu/cpu5/frequency
cpu/cpu5/name
cpu/cpu5/system
cpu/cpu5/temperature
cpu/cpu5/usage
cpu/cpu5/user
cpu/cpu5/wait
cpu/cpu6
cpu/cpu6/frequency
cpu/cpu6/name
cpu/cpu6/system
cpu/cpu6/temperature
cpu/cpu6/usage
cpu/cpu6/user
cpu/cpu6/wait
cpu/cpu7
cpu/cpu7/frequency
cpu/cpu7/name
cpu/cpu7/system
cpu/cpu7/temperature
cpu/cpu7/usage
cpu/cpu7/user
cpu/cpu7/wait
cpu/cpu8
cpu/cpu8/frequency
cpu/cpu8/name
cpu/cpu8/system
cpu/cpu8/temperature
cpu/cpu8/usage
cpu/cpu8/user
cpu/cpu8/wait
cpu/cpu9
cpu/cpu9/frequency
cpu/cpu9/name
cpu/cpu9/system
cpu/cpu9/temperature
cpu/cpu9/usage
cpu/cpu9/user
cpu/cpu9/wait
cpu/loadaverages
cpu/loadaverages/loadaverage1
cpu/loadaverages/loadaverage15
cpu/loadaverages/loadaverage5
disk
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/free
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/freePercent
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/name
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/read
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/total
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/used
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/usedPercent
disk/52e29d18-ad4d-47ad-98c4-a09ab0914a85/write
disk/all
disk/all/free
disk/all/freePercent
disk/all/read
disk/all/total
disk/all/used
disk/all/usedPercent
disk/all/write
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/free
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/freePercent
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/name
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/read
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/total
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/used
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/usedPercent
disk/d10dd7bf-e382-4e44-83d7-9af6c6df7258/write
disk/nvme0n1
disk/nvme0n1/name
disk/nvme0n1/read
disk/nvme0n1/total
disk/nvme0n1/write
gpu
lmsensors
lmsensors/BAT0-acpi-0
lmsensors/BAT0-acpi-0/in0
lmsensors/acpitz-acpi-0
lmsensors/acpitz-acpi-0/temp1
lmsensors/iwlwifi_1-virtual-0
lmsensors/iwlwifi_1-virtual-0/temp1
lmsensors/nvme-pci-0400
lmsensors/nvme-pci-0400/temp1
lmsensors/thinkpad-isa-0000
lmsensors/thinkpad-isa-0000/fan1
lmsensors/thinkpad-isa-0000/fan2
lmsensors/thinkpad-isa-0000/temp1
lmsensors/thinkpad-isa-0000/temp2
lmsensors/thinkpad-isa-0000/temp3
lmsensors/thinkpad-isa-0000/temp4
lmsensors/thinkpad-isa-0000/temp5
lmsensors/thinkpad-isa-0000/temp6
lmsensors/thinkpad-isa-0000/temp7
lmsensors/thinkpad-isa-0000/temp8
lmsensors/ucsi_source_psy_USBC000:001-isa-0000
lmsensors/ucsi_source_psy_USBC000:001-isa-0000/curr1
lmsensors/ucsi_source_psy_USBC000:001-isa-0000/in0
lmsensors/ucsi_source_psy_USBC000:002-isa-0000
lmsensors/ucsi_source_psy_USBC000:002-isa-0000/curr1
lmsensors/ucsi_source_psy_USBC000:002-isa-0000/in0
memory
memory/physical
memory/physical/application
memory/physical/applicationPercent
memory/physical/buffer
memory/physical/bufferPercent
memory/physical/cache
memory/physical/cachePercent
memory/physical/free
memory/physical/freePercent
memory/physical/total
memory/physical/used
memory/physical/usedPercent
memory/swap
memory/swap/free
memory/swap/freePercent
memory/swap/total
memory/swap/used
memory/swap/usedPercent
os
os/kernel
os/kernel/name
os/kernel/prettyName
os/kernel/version
os/plasma
os/plasma/kfVersion
os/plasma/plasmaVersion
os/plasma/qtVersion
os/plasma/windowsystem
os/system
os/system/hostname
os/system/logo
os/system/name
os/system/prettyName
os/system/uptime
os/system/url
os/system/version
power
power/4870
power/4870/capacity
power/4870/charge
power/4870/chargePercentage
power/4870/chargeRate
power/4870/design
power/4870/health
power/4870/name

View File

@ -58,7 +58,7 @@ CFontDialog::CFontDialog(QWidget *parent, bool needWeight, bool needItalic)
setLayout(mainGrid);
colorBox = new QComboBox(this);
connect(colorBox, &QComboBox::currentTextChanged, this, &CFontDialog::updateColor);
connect(colorBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateColor(QString)));
QStringList colorNames = QColor::colorNames();
int index = 0;
for (int i=0; i<colorNames.count(); i++) {
@ -81,8 +81,8 @@ CFontDialog::CFontDialog(QWidget *parent, bool needWeight, bool needItalic)
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this);
QObject::connect(buttons, &QDialogButtonBox::accepted, this, &CFontDialog::accept);
QObject::connect(buttons, &QDialogButtonBox::rejected, this, &CFontDialog::reject);
QObject::connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
QObject::connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
mainGrid->addWidget(buttons, 1, 0, 1, 5);
italicBox->setHidden(!needItalic);

View File

@ -15,7 +15,8 @@
* License along with this library. *
***************************************************************************/
#pragma once
#ifndef FONTDIALOG_H
#define FONTDIALOG_H
#include <QComboBox>
#include <QDialog>
@ -71,3 +72,6 @@ private:
QSpinBox *sizeBox;
QSpinBox *weightBox;
};
#endif /* FONTDIALOG_H */

View File

@ -12,7 +12,7 @@ QReplyTimeout::QReplyTimeout(QNetworkReply *reply, const int timeout)
void QReplyTimeout::timeout()
{
auto reply = dynamic_cast<QNetworkReply *>(parent());
auto *reply = dynamic_cast<QNetworkReply *>(parent());
if (reply->isRunning())
reply->close();
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDEBUG_H
#define AWDEBUG_H
#include <QLoggingCategory>
@ -40,3 +42,6 @@ Q_DECLARE_LOGGING_CATEGORY(LOG_DP)
Q_DECLARE_LOGGING_CATEGORY(LOG_ESM)
Q_DECLARE_LOGGING_CATEGORY(LOG_ESS)
Q_DECLARE_LOGGING_CATEGORY(LOG_LIB)
#endif /* AWDEBUG_H */

View File

@ -16,21 +16,27 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: aboutPage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
property bool debug: awActions.isDebugEnabled()
AboutTab {
textProvider: awActions
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -17,20 +17,24 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: advancedPage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_background: background.checked
property alias cfg_translateStrings: translate.checked
property alias cfg_wrapNewLines: wrapNewLines.checked
@ -51,6 +55,7 @@ KCM.SimpleKCM {
property alias cfg_telemetryRemote: telemetryRemote.checked
property alias cfg_telemetryId: telemetryId.value
Column {
id: pageColumn
anchors.fill: parent
@ -130,32 +135,32 @@ KCM.SimpleKCM {
id: tempUnits
model: [
{
"label": i18n("Celsius"),
"name": "Celsius"
'label': i18n("Celsius"),
'name': "Celsius"
},
{
"label": i18n("Fahrenheit"),
"name": "Fahrenheit"
'label': i18n("Fahrenheit"),
'name': "Fahrenheit"
},
{
"label": i18n("Kelvin"),
"name": "Kelvin"
'label': i18n("Kelvin"),
'name': "Kelvin"
},
{
"label": i18n("Reaumur"),
"name": "Reaumur"
'label': i18n("Reaumur"),
'name': "Reaumur"
},
{
"label": i18n("cm^-1"),
"name": "cm^-1"
'label': i18n("cm^-1"),
'name': "cm^-1"
},
{
"label": i18n("kJ/mol"),
"name": "kJ/mol"
'label': i18n("kJ/mol"),
'name': "kJ/mol"
},
{
"label": i18n("kcal/mol"),
"name": "kcal/mol"
'label': i18n("kcal/mol"),
'name': "kcal/mol"
}
]
text: i18n("Temperature units")
@ -189,18 +194,14 @@ KCM.SimpleKCM {
GroupBox {
width: parent.width
height: implicitHeight
title: i18n("Actions")
Column {
height: implicitHeight
width: parent.width
ButtonSelector {
value: i18n("Drop key cache")
onButtonActivated: awActions.dropCache()
}
ButtonSelector {
ExportDialog {
id: saveConfigAs
@ -209,12 +210,11 @@ KCM.SimpleKCM {
value: i18n("Export configuration")
onButtonActivated: saveConfigAs.open()
}
ButtonSelector {
ImportDialog {
id: loadConfigFrom
onConfigurationReceived: {
for (const key in configuration)
for (var key in configuration)
plasmoid.configuration[key] = configuration[key]
}
}
@ -225,19 +225,15 @@ KCM.SimpleKCM {
}
GroupBox {
height: implicitHeight
width: parent.width
title: i18n("Telemetry")
Column {
height: implicitHeight
width: parent.width
CheckBoxSelector {
id: telemetryRemote
text: i18n("Enable remote telemetry")
}
IntegerSelector {
id: telemetryCount
maximumValue: 10000
@ -246,7 +242,6 @@ KCM.SimpleKCM {
text: i18n("History count")
value: plasmoid.configuration.telemetryCount
}
LineSelector {
id: telemetryId
text: i18n("Telemetry ID")
@ -255,4 +250,9 @@ KCM.SimpleKCM {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,21 +16,30 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
import "."
KCM.SimpleKCM {
Item {
id: appearancePage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property variant weight: {
25: 0,
50: 1,
63: 3,
75: 4,
87: 5,
87: 5
}
property alias cfg_fontFamily: font.value
@ -41,6 +50,7 @@ KCM.SimpleKCM {
property alias cfg_textStyleColor: selectStyleColor.value
property string cfg_textStyle: textStyle.value
Column {
id: pageColumn
anchors.fill: parent
@ -96,4 +106,9 @@ KCM.SimpleKCM {
value: plasmoid.configuration.textStyleColor
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -17,29 +17,36 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: dataenginePage
// backend
AWKeys {
id: awKeys
}
AWActions {
id: awActions
}
AWConfigHelper {
id: awConfig
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property variant cfg_dataengine: awConfig.readDataEngineConfiguration()
Column {
id: pageColumn
anchors.fill: parent
GroupBox {
height: implicitHeight
width: parent.width
@ -54,8 +61,58 @@ KCM.SimpleKCM {
GroupBox {
height: implicitHeight
width: parent.width
title: i18n("Player")
title: i18n("GPU")
ComboBoxSelector {
model: [
{
'label': "auto",
'name': "auto"
},
{
'label': "disable",
'name': "disable"
},
{
'label': "ati",
'name': "ati"
},
{
'label': "nvidia",
'name': "nvidia"
}
]
text: i18n("GPU device")
value: cfg_dataengine["GPUDEV"]
onValueEdited: newValue => cfg_dataengine["GPUDEV"] = newValue
}
}
GroupBox {
height: implicitHeight
width: parent.width
title: i18n("HDD temperature")
Column {
height: implicitHeight
width: parent.width
ComboBoxSelector {
id: hdd
text: i18n("HDD")
value: cfg_dataengine["HDDDEV"]
onValueEdited: newValue => cfg_dataengine["HDDDEV"] = newValue
}
LineSelector {
text: i18n("hddtemp cmd")
value: cfg_dataengine["HDDTEMPCMD"]
onValueEdited: newValue => cfg_dataengine["HDDTEMPCMD"] = newValue
}
}
}
GroupBox {
height: implicitHeight
width: parent.width
title: i18n("Player")
Column {
height: implicitHeight
width: parent.width
@ -71,16 +128,16 @@ KCM.SimpleKCM {
ComboBoxSelector {
model: [
{
"label": "disable",
"name": "disable"
'label': "disable",
'name': "disable"
},
{
"label": "mpris",
"name": "mpris"
'label': "mpris",
'name': "mpris"
},
{
"label": "mpd",
"name": "mpd"
'label': "mpd",
'name': "mpd"
}
]
text: i18n("Music player")
@ -93,40 +150,40 @@ KCM.SimpleKCM {
editable: true
model: [
{
"label": "auto",
"name": "auto"
'label': 'auto',
'name': 'auto'
},
{
"label": "amarok",
"name": "amarok"
'label': 'amarok',
'name': 'amarok'
},
{
"label": "audacious",
"name": "audacious"
'label': 'audacious',
'name': 'audacious'
},
{
"label": "clementine",
"name": "clementine"
'label': 'clementine',
'name': 'clementine'
},
{
"label": "DeaDBeeF",
"name": "DeaDBeeF"
'label': 'DeaDBeeF',
'name': 'DeaDBeeF'
},
{
"label": "vlc",
"name": "vlc"
'label': 'vlc',
'name': 'vlc'
},
{
"label": "qmmp",
"name": "qmmp"
'label': 'qmmp',
'name': 'qmmp'
},
{
"label": "xmms2",
"name": "xmms2"
'label': 'xmms2',
'name': 'xmms2'
},
{
"label": cfg_dataengine["MPRIS"],
"name": cfg_dataengine["MPRIS"]
'label': cfg_dataengine["MPRIS"],
'name': cfg_dataengine["MPRIS"]
}
]
text: i18n("MPRIS player name")
@ -154,11 +211,9 @@ KCM.SimpleKCM {
height: implicitHeight
width: parent.width
title: i18n("Extensions")
Column {
height: implicitHeight
width: parent.width
ButtonSelector {
value: i18n("Custom scripts")
onButtonActivated: awKeys.editItem("extscript")
@ -189,11 +244,19 @@ KCM.SimpleKCM {
Component.onCompleted: {
if (debug) console.debug()
// init submodule
awKeys.updateCache()
// update hdd model
hdd.model = awKeys.getHddDevices()
hdd.onCompleted
}
Component.onDestruction: {
if (debug) console.debug()
cfg_dataengine["MPRIS"] = mpris.editText
awConfig.writeDataEngineConfiguration(cfg_dataengine)
}

View File

@ -22,13 +22,12 @@ import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
import "."
PlasmoidItem {
id: main
// backend
AWKeys {
id: awKeys
@ -43,6 +42,7 @@ PlasmoidItem {
id: bugReport
}
property bool debug: awActions.isDebugEnabled()
property variant tooltipSettings: {
"tooltipNumber": plasmoid.configuration.tooltipNumber,
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
@ -72,13 +72,15 @@ PlasmoidItem {
signal needToolTipUpdate(string newText)
signal sizeUpdate
Layout.fillWidth: PlasmoidItem.formFactor !== PlasmaCore.Planar
Layout.fillHeight: PlasmoidItem.formFactor !== PlasmaCore.Planar
Layout.fillWidth: PlasmoidItem.formFactor != PlasmaCore.Planar
Layout.fillHeight: PlasmoidItem.formFactor != PlasmaCore.Planar
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Plasmoid.icon: "utilities-system-monitor"
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
// ui
Text {
id: text
@ -92,7 +94,7 @@ PlasmoidItem {
color: plasmoid.configuration.fontColor
font.family: plasmoid.configuration.fontFamily
font.italic: plasmoid.configuration.fontStyle === "italic" ? true : false
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
font.pointSize: plasmoid.configuration.fontSize
font.weight: General.fontWeight[plasmoid.configuration.fontWeight]
@ -122,8 +124,8 @@ PlasmoidItem {
}
onAccepted: {
const tag = tagSelectorBox.editText
let message = i18n("Tag: %1", tag)
var tag = tagSelectorBox.editText
var message = i18n("Tag: %1", tag)
message += "<br>"
message += i18n("Value: %1", awKeys.valueByKey(tag))
message += "<br>"
@ -136,33 +138,25 @@ PlasmoidItem {
PlasmaCore.Action {
text: i18n("Request key")
icon.name: "utilities-system-monitor"
onTriggered: {
tagSelectorBox.model = awKeys.dictKeys(true)
tagSelector.open()
}
},
PlasmaCore.Action {
text: i18n("Show README")
icon.name: "text-x-readme"
onTriggered: awActions.showReadme()
},
PlasmaCore.Action {
text: i18n("Check updates")
icon.name: "system-software-update"
onTriggered: awActions.checkUpdates(true)
},
PlasmaCore.Action {
text: i18n("Report bug")
icon.name: "tools-report-bug"
onTriggered: {
bugReport.reset()
bugReport.open()
}
}
]
Component.onCompleted: {
if (debug) console.debug()
// init submodule
Plasmoid.userConfiguringChanged(false)
// connect data
@ -173,25 +167,31 @@ PlasmoidItem {
}
onNeedTextUpdate: newText => {
if (debug) console.debug()
text.text = newText
sizeUpdate()
}
onNeedToolTipUpdate: newText => {
if (debug) console.debug()
tooltip.text = newText
}
onSizeUpdate: {
if (debug) console.debug()
// 16 is a magic number
// in other case plasmoid will increase own size on each update
if (plasmoid.configuration.height === 0) {
if (plasmoid.configuration.height == 0) {
Layout.minimumHeight = text.contentHeight - 16
Layout.maximumHeight = -1
} else {
Layout.minimumHeight = plasmoid.configuration.height
Layout.maximumHeight = plasmoid.configuration.height
}
if (plasmoid.configuration.width === 0) {
if (plasmoid.configuration.width == 0) {
Layout.minimumWidth = text.contentWidth - 16
Layout.maximumWidth = -1
} else {
@ -202,6 +202,7 @@ PlasmoidItem {
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.debug()
// init submodule
awKeys.initDataAggregator(tooltipSettings)
@ -216,7 +217,7 @@ PlasmoidItem {
awKeys.setAggregatorProperty("tempUnits", plasmoid.configuration.tempUnits)
awKeys.setAggregatorProperty("translate", plasmoid.configuration.translateStrings)
// update telemetry ID
if (plasmoid.configuration.telemetryId.length === 0)
if (plasmoid.configuration.telemetryId.length == 0)
plasmoid.configuration.telemetryId = generateUuid()
// save telemetry
awTelemetryHandler.init(plasmoid.configuration.telemetryCount,
@ -226,10 +227,37 @@ PlasmoidItem {
awTelemetryHandler.uploadTelemetry("awwidgetconfig", plasmoid.configuration.text)
}
function action_checkUpdates() {
if (debug) console.debug()
return awActions.checkUpdates(true)
}
function action_showReadme() {
if (debug) console.debug()
return awActions.showReadme()
}
function action_reportBug() {
if (debug) console.debug()
bugReport.reset()
bugReport.open()
}
function action_requestKey() {
if (debug) console.debug()
tagSelectorBox.model = awKeys.dictKeys(true)
return tagSelector.open()
}
// code from http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
function generateUuid() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
let r = Math.random() * 16 | 0, v = c === "x" ? r : (r & 0x3 | 0x8);
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}

View File

@ -0,0 +1,27 @@
# Do not edit qmldir directly it will be overrided during compilation,
# edit qml/qmldir.in file instead.
# common QML constants
singleton General 1.0 file:///usr/share/awesomewidgets/qml/General.qml
# custom QML UI classes
AboutTab file:///usr/share/awesomewidgets/qml/AboutTab.qml
AWExtensions file:///usr/share/awesomewidgets/qml/AWExtensions.qml
AWInfoLabel file:///usr/share/awesomewidgets/qml/AWInfoLabel.qml
AWTagSelector file:///usr/share/awesomewidgets/qml/AWTagSelector.qml
AWTextEditor file:///usr/share/awesomewidgets/qml/AWTextEditor.qml
BugReport file:///usr/share/awesomewidgets/qml/BugReport.qml
ButtonSelector file:///usr/share/awesomewidgets/qml/ButtonSelector.qml
CheckBoxSelector file:///usr/share/awesomewidgets/qml/CheckBoxSelector.qml
ColorSelector file:///usr/share/awesomewidgets/qml/ColorSelector.qml
ComboBoxSelector file:///usr/share/awesomewidgets/qml/ComboBoxSelector.qml
ExportDialog file:///usr/share/awesomewidgets/qml/ExportDialog.qml
FontSelector file:///usr/share/awesomewidgets/qml/FontSelector.qml
HtmlDefaultFunctionsBar file:///usr/share/awesomewidgets/qml/HtmlDefaultFunctionsBar.qml
HtmlEditorButton file:///usr/share/awesomewidgets/qml/HtmlEditorButton.qml
HtmlEditorColor file:///usr/share/awesomewidgets/qml/HtmlEditorColor.qml
HtmlEditorFont file:///usr/share/awesomewidgets/qml/HtmlEditorFont.qml
ImportDialog file:///usr/share/awesomewidgets/qml/ImportDialog.qml
IntegerSelector file:///usr/share/awesomewidgets/qml/IntegerSelector.qml
LineSelector file:///usr/share/awesomewidgets/qml/LineSelector.qml

View File

@ -17,14 +17,23 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
KCM.SimpleKCM {
Item {
id: tooltipPage
// backend
AWActions {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_tooltipNumber: tooltipNumber.value
property alias cfg_useTooltipBackground: useTooltipBackground.checked
@ -44,6 +53,7 @@ KCM.SimpleKCM {
property alias cfg_batTooltipColor: batTooltipColor.value
property alias cfg_batInTooltipColor: batInTooltipColor.value
Column {
id: pageColumn
anchors.fill: parent
@ -168,13 +178,11 @@ KCM.SimpleKCM {
Column {
width: parent.width
enabled: networkTooltipLabel.checked
ColorSelector {
id: downkbTooltipColor
text: i18n("Download speed color")
value: plasmoid.configuration.downkbTooltipColor
}
ColorSelector {
id: upkbTooltipColor
text: i18n("Upload speed color")
@ -196,13 +204,11 @@ KCM.SimpleKCM {
Column {
width: parent.width
enabled: batteryTooltipLabel.checked
ColorSelector {
id: batTooltipColor
text: i18n("Battery active color")
value: plasmoid.configuration.batTooltipColor
}
ColorSelector {
id: batInTooltipColor
text: i18n("Battery inactive color")
@ -211,4 +217,9 @@ KCM.SimpleKCM {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,16 +16,13 @@
***************************************************************************/
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
import org.kde.plasma.private.awesomewidget 1.0
import "."
KCM.SimpleKCM {
Item {
id: widgetPage
// backend
AWKeys {
id: awKeys
@ -34,11 +31,19 @@ KCM.SimpleKCM {
id: awActions
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_text: textPattern.text
property bool lock: true
signal needTextUpdate(string newText)
Column {
id: pageColumn
anchors.fill: parent
@ -69,7 +74,10 @@ KCM.SimpleKCM {
}
}
Component.onCompleted: {
if (debug) console.debug()
awKeys.needTextToBeUpdated.connect(needTextUpdate)
// init submodule
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.interval,
@ -84,6 +92,7 @@ KCM.SimpleKCM {
onNeedTextUpdate: newText => {
if (lock) return
if (debug) console.debug()
extensions.showMessage(newText)
lock = true

View File

@ -19,7 +19,7 @@
"Id": "org.kde.plasma.awesomewidget",
"License": "GPLv3",
"Name": "Awesome Widget",
"Version": "4.0.0",
"Version": "3.5.1",
"Website": "https://arcanis.me/projects/awesome-widgets/"
},
"X-Plasma-API-Minimum-Version": "6.0"

View File

@ -37,13 +37,13 @@ AWAbstractPairConfig::AWAbstractPairConfig(QWidget *_parent, const bool _hasEdit
ui->setupUi(this);
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AWAbstractPairConfig::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &AWAbstractPairConfig::reject);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
// edit feature
if (m_hasEdit) {
m_editButton = ui->buttonBox->addButton(i18n("Edit"), QDialogButtonBox::ActionRole);
connect(m_editButton, &QPushButton::clicked, [this]() { return edit(); });
connect(m_editButton, SIGNAL(clicked(bool)), this, SLOT(edit()));
}
}
@ -84,14 +84,14 @@ void AWAbstractPairConfig::edit()
void AWAbstractPairConfig::updateUi()
{
auto current = dynamic_cast<AWAbstractSelector *>(sender())->current();
auto index = m_selectors.indexOf(dynamic_cast<AWAbstractSelector *>(sender()));
QPair<QString, QString> current = dynamic_cast<AWAbstractSelector *>(sender())->current();
int index = m_selectors.indexOf(dynamic_cast<AWAbstractSelector *>(sender()));
if ((current.first.isEmpty()) && (current.second.isEmpty())) {
// remove current selector if it is empty and does not last
if (sender() == m_selectors.last())
return;
auto selector = m_selectors.takeAt(index);
AWAbstractSelector *selector = m_selectors.takeAt(index);
ui->verticalLayout->removeWidget(selector);
selector->deleteLater();
} else {
@ -109,10 +109,10 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringLi
{
qCDebug(LOG_AW) << "Add selector with keys" << _keys << "values" << _values << "and current ones" << _current;
auto selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable);
auto *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable);
selector->init(_keys, _values, _current);
ui->verticalLayout->insertWidget(ui->verticalLayout->count() - 1, selector);
connect(selector, &AWAbstractSelector::selectionChanged, this, &AWAbstractPairConfig::updateUi);
connect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi()));
m_selectors.append(selector);
}
@ -120,7 +120,7 @@ void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringLi
void AWAbstractPairConfig::clearSelectors()
{
for (auto &selector : m_selectors) {
disconnect(selector, &AWAbstractSelector::selectionChanged, this, &AWAbstractPairConfig::updateUi);
disconnect(selector, SIGNAL(selectionChanged()), this, SLOT(updateUi()));
ui->verticalLayout->removeWidget(selector);
selector->deleteLater();
}
@ -164,7 +164,7 @@ QPair<QStringList, QStringList> AWAbstractPairConfig::initKeys() const
right.append(m_helper->rightKeys().isEmpty() ? m_keys : m_helper->rightKeys());
right.sort();
return {left, right};
return QPair<QStringList, QStringList>(left, right);
}
@ -175,7 +175,7 @@ void AWAbstractPairConfig::updateDialog()
auto keys = initKeys();
for (auto &key : m_helper->keys())
addSelector(keys.first, keys.second, QPair<QString, QString>(key, pairs[key]));
addSelector(keys.first, keys.second, QPair<QString, QString>(key, m_helper->pairs()[key]));
// empty one
addSelector(keys.first, keys.second, QPair<QString, QString>());
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTPAIRCONFIG_H
#define AWABSTRACTPAIRCONFIG_H
#include <QDialog>
@ -65,3 +67,6 @@ private:
[[nodiscard]] QPair<QStringList, QStringList> initKeys() const;
void updateDialog();
};
#endif /* AWABSTRACTPAIRCONFIG_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTPAIRHELPER_H
#define AWABSTRACTPAIRHELPER_H
#include <QHash>
@ -44,3 +46,6 @@ private:
QString m_filePath;
QString m_section;
};
#endif /* AWABSTRACTPAIRHELPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTSELECTOR_H
#define AWABSTRACTSELECTOR_H
#include <QWidget>
@ -41,3 +43,6 @@ signals:
private:
Ui::AWAbstractSelector *ui = nullptr;
};
#endif /* AWABSTRACTSELECTOR_H */

View File

@ -71,6 +71,13 @@ QString AWActions::getFileContent(const QString &_path)
}
// HACK: since QML could not use QLoggingCategory I need this hack
bool AWActions::isDebugEnabled()
{
return LOG_AW().isDebugEnabled();
}
bool AWActions::runCmd(const QString &_cmd, const QStringList &_args)
{
qCDebug(LOG_AW) << "Cmd" << _cmd << "args" << _args;
@ -90,7 +97,7 @@ void AWActions::showReadme()
void AWActions::showLegacyInfo()
{
auto msgBox = new QMessageBox(nullptr);
auto *msgBox = new QMessageBox(nullptr);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setModal(false);
msgBox->setWindowTitle(i18n("Not supported"));

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWACTIONS_H
#define AWACTIONS_H
#include <QMap>
#include <QObject>
@ -32,6 +34,7 @@ public:
~AWActions() override;
Q_INVOKABLE void checkUpdates(bool _showAnyway = false);
Q_INVOKABLE static QString getFileContent(const QString &_path);
Q_INVOKABLE static bool isDebugEnabled();
Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args);
Q_INVOKABLE static void showLegacyInfo();
Q_INVOKABLE static void showReadme();
@ -45,3 +48,6 @@ public slots:
private:
AWUpdateHelper *m_updateHelper = nullptr;
};
#endif /* AWACTIONS_H */

View File

@ -44,7 +44,7 @@ AWBugReporter::~AWBugReporter()
void AWBugReporter::doConnect()
{
// additional method for testing needs
connect(this, &AWBugReporter::replyReceived, this, &AWBugReporter::showInformation);
connect(this, SIGNAL(replyReceived(const int, const QString &)), this, SLOT(showInformation(int, const QString &)));
}
@ -71,26 +71,26 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body)
{
qCDebug(LOG_AW) << "Send bug report with title" << _title << "and body" << _body;
auto manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished, this, &AWBugReporter::issueReplyReceived);
auto *manager = new QNetworkAccessManager(nullptr);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(issueReplyRecieved(QNetworkReply *)));
auto request = QNetworkRequest(QUrl(BUGTRACKER_API));
QNetworkRequest request = QNetworkRequest(QUrl(BUGTRACKER_API));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
// generate payload
QVariantMap payload;
payload["title"] = _title;
payload["body"] = _body;
payload["labels"] = QStringList({"from application"});
payload["labels"] = QStringList() << "from application";
// convert to QByteArray to send request
auto data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
qCInfo(LOG_AW) << "Send request with _body" << data.data() << "and size" << data.size();
manager->post(request, data);
}
void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
void AWBugReporter::issueReplyRecieved(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
@ -98,7 +98,7 @@ void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
}
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return emit(replyReceived(0, ""));
@ -106,9 +106,9 @@ void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
_reply->deleteLater();
// convert to map
auto response = jsonDoc.toVariant().toMap();
auto url = response["html_url"].toString();
auto number = response["number"].toInt();
QVariantMap response = jsonDoc.toVariant().toMap();
QString url = response["html_url"].toString();
int number = response["number"].toInt();
return emit(replyReceived(number, url));
}
@ -121,7 +121,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
// cache url first
m_lastBugUrl = _url;
auto msgBox = new QMessageBox(nullptr);
auto *msgBox = new QMessageBox(nullptr);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setModal(false);
msgBox->setWindowTitle(i18n("Issue created"));
@ -135,7 +135,7 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
void AWBugReporter::userReplyOnBugReport(QAbstractButton *_button)
{
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
qCInfo(LOG_AW) << "User select" << ret;
switch (ret) {

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWBUGREPORTER_H
#define AWBUGREPORTER_H
#include <QObject>
@ -39,10 +41,13 @@ signals:
void replyReceived(int _number, const QString &_url);
private slots:
void issueReplyReceived(QNetworkReply *_reply);
void issueReplyRecieved(QNetworkReply *_reply);
void showInformation(int _number, const QString &_url);
void userReplyOnBugReport(QAbstractButton *_button);
private:
QString m_lastBugUrl;
};
#endif /* AWBUGREPORTER_H */

View File

@ -72,7 +72,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
QSettings settings(_fileName, QSettings::IniFormat);
// plasmoid configuration
auto configuration = dynamic_cast<const QQmlPropertyMap *>(_nativeConfig);
const auto *configuration = dynamic_cast<const QQmlPropertyMap *>(_nativeConfig);
settings.beginGroup("plasmoid");
for (auto &key : configuration->keys()) {
QVariant value = configuration->value(key);
@ -170,6 +170,9 @@ QVariantMap AWConfigHelper::readDataEngineConfiguration()
settings.beginGroup("Configuration");
configuration["ACPIPATH"] = settings.value("ACPIPATH", "/sys/class/power_supply/");
configuration["GPUDEV"] = settings.value("GPUDEV", "auto");
configuration["HDDDEV"] = settings.value("HDDDEV", "all");
configuration["HDDTEMPCMD"] = settings.value("HDDTEMPCMD", "sudo smartctl -a");
configuration["MPDADDRESS"] = settings.value("MPDADDRESS", "localhost");
configuration["MPDPORT"] = settings.value("MPDPORT", "6600");
configuration["MPRIS"] = settings.value("MPRIS", "auto");
@ -194,6 +197,9 @@ bool AWConfigHelper::writeDataEngineConfiguration(const QVariantMap &_configurat
settings.beginGroup("Configuration");
settings.setValue("ACPIPATH", _configuration["ACPIPATH"]);
settings.setValue("GPUDEV", _configuration["GPUDEV"]);
settings.setValue("HDDDEV", _configuration["HDDDEV"]);
settings.setValue("HDDTEMPCMD", _configuration["HDDTEMPCMD"]);
settings.setValue("MPDADDRESS", _configuration["MPDADDRESS"]);
settings.setValue("MPDPORT", _configuration["MPDPORT"]);
settings.setValue("MPRIS", _configuration["MPRIS"]);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWCONFIGHELPER_H
#define AWCONFIGHELPER_H
#include <QObject>
#include <QVariant>
@ -50,3 +52,6 @@ private:
QString m_baseDir;
QStringList m_dirs = {"desktops", "quotes", "scripts", "upgrade", "weather", "formatters"};
};
#endif /* AWCONFIGHELPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWCUSTOMKEYSCONFIG_H
#define AWCUSTOMKEYSCONFIG_H
#include "awabstractpairconfig.h"
@ -28,3 +30,6 @@ public:
explicit AWCustomKeysConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList());
~AWCustomKeysConfig() override;
};
#endif /* AWCUSTOMKEYSCONFIG_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWCUSTOMKEYSHELPER_H
#define AWCUSTOMKEYSHELPER_H
#include <QObject>
@ -40,3 +42,6 @@ public:
private:
};
#endif /* AWCUSTOMKEYSHELPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWTOOLTIP_H
#define AWTOOLTIP_H
#include <QObject>
#include <QVariant>
@ -66,3 +68,6 @@ private:
bool m_enablePopup = false;
QStringList requiredKeys;
};
#endif /* AWTOOLTIP_H */

View File

@ -89,9 +89,6 @@ void AWDataEngineAggregator::loadSources()
auto sensors = response.value();
updateSensors(sensors);
connectSources();
for (auto &sensor : m_sensors.keys())
emit(deviceAdded(sensor));
}
@ -124,9 +121,6 @@ void AWDataEngineAggregator::sensorAdded(const QString &_sensor)
m_interface->subscribe({_sensor}).waitForFinished();
m_subscribed.insert(_sensor);
}
// notify about new device
emit(deviceAdded(_sensor));
}
@ -139,7 +133,7 @@ void AWDataEngineAggregator::sensorRemoved(const QString &_sensor)
}
void AWDataEngineAggregator::updateData(const KSysGuard::SensorDataList &_data)
void AWDataEngineAggregator::updateData(KSysGuard::SensorDataList _data)
{
emit(dataUpdated(m_sensors, _data));
}
@ -147,9 +141,9 @@ void AWDataEngineAggregator::updateData(const KSysGuard::SensorDataList &_data)
void AWDataEngineAggregator::updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors)
{
for (auto [source, sensor] : _sensors.asKeyValueRange()) {
if (!isValidSensor(sensor))
for (auto sensor = _sensors.cbegin(); sensor != _sensors.cend(); ++sensor) {
if (!isValidSensor(sensor.value()))
continue;
m_sensors.insert(source, sensor);
m_sensors.insert(sensor.key(), sensor.value());
}
}

View File

@ -49,7 +49,7 @@ public slots:
void dropSource(const QString &_source);
void sensorAdded(const QString &_sensor);
void sensorRemoved(const QString &_sensor);
void updateData(const KSysGuard::SensorDataList &_data);
void updateData(KSysGuard::SensorDataList _data);
void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors);
private:

View File

@ -85,8 +85,6 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
auto cpuRegExp = QRegularExpression("^cpu/cpu.*/usage$");
auto cpuclRegExp = QRegularExpression("^cpu/cpu.*/frequency$");
auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
auto gpuTempRegExp = QRegularExpression("^gpu/gpu.*/temperature$");
auto hddrRegExp = QRegularExpression("^disk/.*/read$");
auto hddwRegExp = QRegularExpression("^disk/.*/write$");
auto mountFillRegExp = QRegularExpression("^disk/.*/usedPercent$");
@ -101,7 +99,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_formatter["ac"] = AWKeysAggregator::FormatterType::ACFormat;
} else if (_source.startsWith("extsysmon/battery/")) {
// battery stats
auto key = _source;
QString key = _source;
key.remove("extsysmon/battery/");
m_map.insert(_source, key);
m_formatter[key] = _source.contains("rate") ? AWKeysAggregator::FormatterType::Float
@ -112,7 +110,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_formatter["cpu"] = AWKeysAggregator::FormatterType::Float;
} else if (_source.contains(cpuRegExp)) {
// cpus
auto key = _source;
QString key = _source;
key.remove("cpu/").remove("/usage");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
@ -122,14 +120,14 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_formatter["cpucl"] = AWKeysAggregator::FormatterType::Integer;
} else if (_source.contains(cpuclRegExp)) {
// cpucls
auto key = _source;
QString key = _source;
key.remove("cpu/cpu").remove("/frequency");
key = QString("cpucl%1").arg(key);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
} else if (_source.startsWith("extsysmon/custom")) {
// custom
auto key = _source;
QString key = _source;
key.remove("extsysmon/custom/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
@ -147,55 +145,39 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_formatter["tdesktops"] = AWKeysAggregator::FormatterType::NoFormat;
} else if (_source.contains(hddrRegExp)) {
// read speed
auto device = _source;
QString device = _source;
device.remove("disk/").remove("/read");
auto index = m_devices["disk"].indexOf(device);
int index = m_devices["disk"].indexOf(device);
if (index > -1) {
QString key = QString("hddr%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
}
} else if (_source.contains(hddwRegExp)) {
// write speed
auto device = _source;
QString device = _source;
device.remove("disk/").remove("/write");
auto index = m_devices["disk"].indexOf(device);
int index = m_devices["disk"].indexOf(device);
if (index > -1) {
QString key = QString("hddw%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
}
} else if (_source == "gpu/all/usage") {
} else if (_source == "extsysmon/gpuload/load") {
// gpu load
m_map.insert(_source, "gpu");
m_formatter["gpu"] = AWKeysAggregator::FormatterType::Float;
} else if (_source.contains(gpuRegExp)) {
// gpus
auto device = _source;
device.remove("gpu/").remove("/usage");
auto index = m_devices["gpu"].indexOf(device);
if (index > -1) {
auto key = QString("gpu%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
}
} else if (_source.contains(gpuTempRegExp)) {
// gpus temps
auto device = _source;
device.remove("gpu/").remove("/temperature");
auto index = m_devices["gpu"].indexOf(device);
if (index > -1) {
auto key = QString("gputemp%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
}
} else if (_source == "extsysmon/gputemp/temperature") {
// gpu temperature
m_map.insert(_source, "gputemp");
m_formatter["gputemp"] = AWKeysAggregator::FormatterType::Temperature;
} else if (_source.contains(mountFillRegExp)) {
// fill level
auto device = _source;
QString device = _source;
device.remove("disk/").remove("/usedPercent");
auto index = m_devices["mount"].indexOf(device);
int index = m_devices["mount"].indexOf(device);
if (index > -1) {
auto key = QString("hdd%1").arg(index);
QString key = QString("hdd%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Float;
// additional keys
@ -204,9 +186,9 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
}
} else if (_source.contains(mountFreeRegExp)) {
// free space
auto device = _source;
QString device = _source;
device.remove("disk/").remove("/free");
auto index = m_devices["mount"].indexOf(device);
int index = m_devices["mount"].indexOf(device);
if (index > -1) {
// mb
QString key = QString("hddfreemb%1").arg(index);
@ -219,9 +201,9 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
}
} else if (_source.contains(mountUsedRegExp)) {
// used
auto device = _source;
QString device = _source;
device.remove("disk/").remove("/used");
auto index = m_devices["mount"].indexOf(device);
int index = m_devices["mount"].indexOf(device);
if (index > -1) {
// mb
QString key = QString("hddmb%1").arg(index);
@ -232,11 +214,21 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemGBFormat;
}
} else if (_source.startsWith("extsysmon/hdd/temperature")) {
// hdd temperature
QString device = _source;
device.remove("extsysmon/hdd/temperature");
int index = m_devices["hdd"].indexOf(device);
if (index > -1) {
QString key = QString("hddtemp%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
}
} else if (_source.startsWith("cpu/loadaverages/loadaverage")) {
// load average
auto time = _source;
QString time = _source;
time.remove("cpu/loadaverages/loadaverage");
auto key = QString("la%1").arg(time);
QString key = QString("la%1").arg(time);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::FloatTwoSymbols;
} else if (_source == "memory/physical/application") {
@ -273,19 +265,19 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_formatter["ssid"] = AWKeysAggregator::FormatterType::NoFormat;
} else if (_source.startsWith("extsysmon/requests/response")) {
// network response
auto key = _source;
QString key = _source;
key.remove("extsysmon/requests/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
} else if (_source.contains(netRegExp)) {
// network speed
auto type = _source.endsWith("download") ? "down" : "up";
auto index = m_devices["net"].indexOf(_source.split('/')[1]);
QString type = _source.contains("download") ? "down" : "up";
int index = m_devices["net"].indexOf(_source.split('/')[2]);
if (index > -1) {
// kb
auto key = QString("%1kb%2").arg(type).arg(index);
QString key = QString("%1kb%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
// smart
key = QString("%1%2").arg(type).arg(index);
m_map.insert(_source, key);
@ -297,13 +289,13 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
}
} else if (_source.contains(netTotalRegExp)) {
// network data total
auto type = _source.endsWith("Download") ? "down" : "up";
auto index = m_devices["net"].indexOf(_source.split('/')[1]);
QString type = _source.contains("download") ? "down" : "up";
int index = m_devices["net"].indexOf(_source.split('/')[2]);
if (index > -1) {
// kb
auto key = QString("%1totkb%2").arg(type).arg(index);
QString key = QString("%1totkb%2").arg(type).arg(index);
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::MemKBFormat;
m_formatter[key] = AWKeysAggregator::FormatterType::Integer;
// mb
key = QString("%1tot%2").arg(type).arg(index);
m_map.insert(_source, key);
@ -311,13 +303,13 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
}
} else if (_source.startsWith("extsysmon/upgrade")) {
// package manager
auto key = _source;
QString key = _source;
key.remove("extsysmon/upgrade/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::IntegerThree;
} else if (_source.startsWith("extsysmon/player")) {
// player
auto key = _source;
QString key = _source;
key.remove("extsysmon/player/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
@ -335,7 +327,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_formatter["pstot"] = AWKeysAggregator::FormatterType::NoFormat;
} else if (_source.startsWith("extsysmon/quotes")) {
// quotes
auto key = _source;
QString key = _source;
key.remove("extsysmon/quotes/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Quotes;
@ -363,7 +355,7 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
if (_units == KSysGuard::UnitInvalid)
return QStringList({QString("temp%1").arg(index)});
if (index > -1) {
auto key = QString("temp%1").arg(index);
QString key = QString("temp%1").arg(index);
m_map.insert(_source, key);
m_formatter[key] = _units == KSysGuard::UnitCelsius ? AWKeysAggregator::FormatterType::Temperature
: AWKeysAggregator::FormatterType::Integer;
@ -402,19 +394,19 @@ QStringList AWDataEngineMapper::registerSource(const QString &_source, const KSy
m_formatter["cuptime"] = AWKeysAggregator::FormatterType::UptimeCustom;
} else if (_source.startsWith("extsysmon/weather/temperature")) {
// temperature
auto key = _source;
QString key = _source;
key.remove("extsysmon/weather/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;
} else if (_source.startsWith("extsysmon/weather/")) {
// other weather
auto key = _source;
QString key = _source;
key.remove("extsysmon/weather/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::NoFormat;
} else if (_source.startsWith("extsysmon/load/load")) {
// load source
auto key = _source;
QString key = _source;
key.remove("extsysmon/load/");
m_map.insert(_source, key);
m_formatter[key] = AWKeysAggregator::FormatterType::Temperature;

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDATAENGINEMAPPER_H
#define AWDATAENGINEMAPPER_H
#include <ksysguard/formatter/Unit.h>
@ -48,3 +50,6 @@ private:
QHash<QString, AWKeysAggregator::FormatterType> m_formatter;
QMultiHash<QString, QString> m_map;
};
#endif /* AWDATAENGINEMAPPER_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDBUSADAPTOR_H
#define AWDBUSADAPTOR_H
#include <QDBusAbstractAdaptor>
@ -48,3 +50,6 @@ private:
AWKeys *m_plugin = nullptr;
QStringList m_logLevels = {"debug", "info", "warning", "critical"};
};
#endif /* AWDBUSADAPTOR_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWPLUGIN_H
#define AWPLUGIN_H
#include <QQmlExtensionPlugin>
@ -28,3 +30,6 @@ class AWPlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri) override;
};
#endif /* AWPLUGIN_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWFORMATTERCONFIG_H
#define AWFORMATTERCONFIG_H
#include "awabstractpairconfig.h"
@ -28,3 +30,6 @@ public:
explicit AWFormatterConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList());
~AWFormatterConfig() override;
};
#endif /* AWFORMATTERCONFIG_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWFORMATTERHELPER_H
#define AWFORMATTERHELPER_H
#include "abstractextitemaggregator.h"
#include "awabstractformatter.h"
@ -54,3 +56,6 @@ private:
QHash<QString, AWAbstractFormatter *> m_formatters;
QHash<QString, AWAbstractFormatter *> m_formattersClasses;
};
#endif /* AWFORMATTERHELPER_H */

View File

@ -31,7 +31,7 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
{
qCDebug(LOG_AW) << "Key" << _key << "with type" << _type;
auto fileName
QString fileName
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
qCInfo(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
@ -41,8 +41,19 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
for (auto &number : cache.allKeys())
cachedValues.append(cache.value(number).toString());
if (_type == "net") {
auto rawInterfaceList = QNetworkInterface::allInterfaces();
if (_type == "hdd") {
QStringList allDevices = QDir("/dev").entryList(QDir::System, QDir::Name);
QStringList devices = allDevices.filter(QRegularExpression("^[hms]d[a-z]$"));
for (auto &dev : devices) {
QString device = QString("/dev/%1").arg(dev);
if (cachedValues.contains(device))
continue;
qCInfo(LOG_AW) << "Found new key" << device << "for type" << _type;
cachedValues.append(device);
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
}
} else if (_type == "net") {
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
for (auto &interface : rawInterfaceList) {
QString device = interface.name();
if (cachedValues.contains(device))
@ -87,7 +98,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
if (!used.contains(key))
continue;
key.remove("hddtotmb");
auto index = key.toInt();
int index = key.toInt();
used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index);
}
// hddtotgb*
@ -95,7 +106,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
if (!used.contains(key))
continue;
key.remove("hddtotgb");
auto index = key.toInt();
int index = key.toInt();
used << QString("hddfreegb%1").arg(index) << QString("hddgb%1").arg(index);
}
// mem
@ -128,7 +139,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
for (auto &key : netKeys) {
if (!used.contains(key))
continue;
auto filt = _allKeys.filter(QRegularExpression(QString("^%1[0-9]{1,}").arg(key)));
QStringList filt = _allKeys.filter(QRegularExpression(QString("^%1[0-9]{1,}").arg(key)));
for (auto &filtered : filt)
used << filtered;
}
@ -147,7 +158,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
QHash<QString, QStringList> AWKeyCache::loadKeysFromCache()
{
auto fileName
QString fileName
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
qCInfo(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYCACHE_H
#define AWKEYCACHE_H
#include <QHash>
#include <QString>
@ -29,3 +31,6 @@ QStringList getRequiredKeys(const QStringList &_keys, const QStringList &_bars,
const QStringList &_userKeys, const QStringList &_allKeys);
QHash<QString, QStringList> loadKeysFromCache();
} // namespace AWKeyCache
#endif /* AWKEYCACHE_H */

View File

@ -72,6 +72,7 @@ QHash<QString, QStringList> AWKeyOperations::devices() const
void AWKeyOperations::updateCache()
{
// update network and hdd list
addKeyToCache("hdd");
addKeyToCache("net");
}
@ -89,20 +90,15 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(item->tag("timestamp"));
}
// cpuclock & cpu
for (auto i = 0; i < QThread::idealThreadCount(); i++) {
for (int i = 0; i < QThread::idealThreadCount(); i++) {
allKeys.append(QString("cpucl%1").arg(i));
allKeys.append(QString("cpu%1").arg(i));
}
// temperature
for (auto i = 0; i < m_devices["temp"].count(); i++)
for (int i = 0; i < m_devices["temp"].count(); i++)
allKeys.append(QString("temp%1").arg(i));
// gpu
for (auto i = 0; i < m_devices["gpu"].count(); i++) {
allKeys.append(QString("gpu%1").arg(i));
allKeys.append(QString("gputemp%1").arg(i));
}
// hdd
for (auto i = 0; i < m_devices["mount"].count(); i++) {
for (int i = 0; i < m_devices["mount"].count(); i++) {
allKeys.append(QString("hddmb%1").arg(i));
allKeys.append(QString("hddgb%1").arg(i));
allKeys.append(QString("hddfreemb%1").arg(i));
@ -112,12 +108,15 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(QString("hdd%1").arg(i));
}
// hdd speed
for (auto i = 0; i < m_devices["disk"].count(); i++) {
for (int i = 0; i < m_devices["disk"].count(); i++) {
allKeys.append(QString("hddr%1").arg(i));
allKeys.append(QString("hddw%1").arg(i));
}
// hdd temp
for (int i = 0; i < m_devices["hdd"].count(); i++)
allKeys.append(QString("hddtemp%1").arg(i));
// network
for (auto i = 0; i < m_devices["net"].count(); i++) {
for (int i = 0; i < m_devices["net"].count(); i++) {
allKeys.append(QString("downunits%1").arg(i));
allKeys.append(QString("upunits%1").arg(i));
allKeys.append(QString("downtotkb%1").arg(i));
@ -130,8 +129,9 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(QString("up%1").arg(i));
}
// battery
auto allBatteryDevices = QDir("/sys/class/power_supply")
.entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
QStringList allBatteryDevices
= QDir("/sys/class/power_supply")
.entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
for (int i = 0; i < allBatteryDevices.count(); i++) {
allKeys.append(QString("bat%1").arg(i));
allKeys.append(QString("batleft%1").arg(i));
@ -205,48 +205,52 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
{
qCDebug(LOG_AW) << "Requested key" << _key;
auto stripped = _key;
QString stripped = _key;
stripped.remove(QRegularExpression("\\d+"));
QString output;
if (_key.startsWith("bar")) {
auto item = m_graphicalItems->itemByTag(_key, stripped);
AbstractExtItem *item = m_graphicalItems->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.startsWith("custom")) {
auto item = m_extScripts->itemByTag(_key, stripped);
AbstractExtItem *item = m_extScripts->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("^hdd[rw]"))) {
auto index = _key;
QString index = _key;
index.remove(QRegularExpression("hdd[rw]"));
output = m_devices["disk"][index.toInt()];
} else if (_key.contains(QRegularExpression("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))) {
auto index = _key;
QString index = _key;
index.remove(QRegularExpression("^hdd(|mb|gb|freemb|freegb|totmb|totgb)"));
output = m_devices["mount"][index.toInt()];
} else if (_key.startsWith("hddtemp")) {
QString index = _key;
index.remove("hddtemp");
output = m_devices["hdd"][index.toInt()];
} else if (_key.contains(QRegularExpression("^(down|up)[0-9]"))) {
auto index = _key;
QString index = _key;
index.remove(QRegularExpression("^(down|up)"));
output = m_devices["net"][index.toInt()];
} else if (_key.startsWith("pkgcount")) {
auto item = m_extUpgrade->itemByTag(_key, stripped);
AbstractExtItem *item = m_extUpgrade->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("(^|perc)(ask|bid|price)(chg|)"))) {
auto item = m_extQuotes->itemByTag(_key, stripped);
AbstractExtItem *item = m_extQuotes->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("(weather|weatherId|humidity|pressure|temperature)"))) {
auto item = m_extWeather->itemByTag(_key, stripped);
AbstractExtItem *item = m_extWeather->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.startsWith("temp")) {
auto index = _key;
QString index = _key;
index.remove("temp");
output = m_devices["temp"][index.toInt()];
} else if (_key.startsWith("response")) {
auto item = m_extNetRequest->itemByTag(_key, stripped);
AbstractExtItem *item = m_extNetRequest->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else {
@ -298,10 +302,9 @@ void AWKeyOperations::addDevice(const QString &_source)
{
qCDebug(LOG_AW) << "Source" << _source;
auto diskRegexp = QRegularExpression("^disk/.*/read$");
auto mountRegexp = QRegularExpression("^disk/.*/usedPercent$");
auto diskRegexp = QRegularExpression("disk/.*/read");
auto mountRegexp = QRegularExpression("disk/.*/usedPercent");
auto cpuTempRegExp = QRegularExpression("^cpu/cpu.*/temperature$");
auto gpuRegExp = QRegularExpression("^gpu/gpu.*/usage$");
if (_source.contains(diskRegexp)) {
auto device = _source;
@ -314,10 +317,6 @@ void AWKeyOperations::addDevice(const QString &_source)
} else if (_source.startsWith("lmsensors") || _source.contains(cpuTempRegExp)
|| _source == "cpu/all/averageTemperature") {
addKeyToCache("temp", _source);
} else if (_source.contains(gpuRegExp)) {
auto device = _source;
device.remove("gpu/").remove("/usage");
addKeyToCache("gpu", device);
}
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYOPERATIONS_H
#define AWKEYOPERATIONS_H
#include <QObject>
@ -76,3 +78,6 @@ private:
QHash<QString, QStringList> m_devices;
QString m_pattern;
};
#endif /* AWKEYOPERATIONS_H */

View File

@ -103,7 +103,6 @@ void AWKeys::initKeys(const QString &_currentPattern, const int _interval, const
m_aggregator->initFormatters();
m_keyOperator->setPattern(_currentPattern);
m_keyOperator->updateCache();
m_dataEngineAggregator->loadSources();
// timer
m_timer->setInterval(_interval);
@ -153,6 +152,26 @@ QStringList AWKeys::dictKeys(const bool _sorted, const QString &_regexp) const
}
QVariantList AWKeys::getHddDevices() const
{
QStringList hddDevices = m_keyOperator->devices("hdd");
// required by selector in the UI
hddDevices.insert(0, "disable");
hddDevices.insert(0, "auto");
// build model
QVariantList devices;
for (auto &device : hddDevices) {
QVariantMap model;
model["label"] = device;
model["name"] = device;
devices.append(model);
}
return devices;
}
QString AWKeys::infoByKey(const QString &_key) const
{
qCDebug(LOG_AW) << "Requested info for key" << _key;
@ -182,14 +201,12 @@ void AWKeys::editItem(const QString &_type)
void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data)
{
qCDebug(LOG_AW) << "Update data for" << _data.count() << "items";
// though it is better to use QtConcurrent::map here, but it might cause stack corruption
for (auto &data : _data) {
if (!_sensors.contains(data.sensorProperty))
continue;
auto sensor = _sensors[data.sensorProperty];
std::ignore = QtConcurrent::run(m_threadPool, &AWKeys::setDataBySource, this, data.sensorProperty, sensor, data.payload);
for (auto &single : _data) {
if (_sensors.contains(single.sensorProperty)) {
setDataBySource(single.sensorProperty, _sensors.value(single.sensorProperty), single);
}
// TODO use QtConcurrent::map or something like that
// QtConcurrent::run(m_threadPool, this, &AWKeys::setDataBySource, "ss", sensor);
}
}
@ -254,7 +271,7 @@ void AWKeys::calculateValues()
m_values["memtotmb"] = m_values["memusedmb"].toLongLong() + m_values["memfreemb"].toLongLong();
m_values["memtotgb"] = m_values["memusedgb"].toDouble() + m_values["memfreegb"].toDouble();
// mem
m_values["mem"] = 100.0 * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
m_values["mem"] = 100.0f * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
// up, down, upkb, downkb, upunits, downunits
int netIndex = m_keyOperator->devices("net").indexOf(m_values["netdev"].toString());
@ -273,7 +290,7 @@ void AWKeys::calculateValues()
m_values["swaptotmb"] = m_values["swapmb"].toLongLong() + m_values["swapfreemb"].toLongLong();
m_values["swaptotgb"] = m_values["swapgb"].toDouble() + m_values["swapfreegb"].toDouble();
// swap
m_values["swap"] = 100.0 * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
m_values["swap"] = 100.0f * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
// user defined keys
for (auto &key : m_keyOperator->userKeys())
@ -339,9 +356,10 @@ QString AWKeys::parsePattern(QString _pattern) const
}
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value)
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
const KSysGuard::SensorData &_data)
{
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _value;
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _data.payload;
// first list init
auto tags = m_aggregator->keysFromSource(_source);
@ -355,6 +373,6 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo
}
m_mutex.lock();
std::for_each(tags.cbegin(), tags.cend(), [this, _value](const QString &tag) { m_values[tag] = _value; });
std::for_each(tags.cbegin(), tags.cend(), [this, &_data](const QString &tag) { m_values[tag] = _data.payload; });
m_mutex.unlock();
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYS_H
#define AWKEYS_H
#include <QMutex>
#include <QObject>
@ -46,19 +48,22 @@ public:
Q_INVOKABLE void updateCache();
// keys
Q_INVOKABLE [[nodiscard]] QStringList dictKeys(bool _sorted = false, const QString &_regexp = "") const;
Q_INVOKABLE [[nodiscard]] QVariantList getHddDevices() const;
// values
Q_INVOKABLE [[nodiscard]] QString infoByKey(const QString &_key) const;
Q_INVOKABLE [[nodiscard]] QString valueByKey(const QString &_key) const;
// configuration
Q_INVOKABLE void editItem(const QString &_type);
public slots:
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
signals:
void dropSourceFromDataengine(const QString &_source);
void needTextToBeUpdated(const QString &_newText) const;
void needToolTipToBeUpdated(const QString &_newText) const;
private slots:
void dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data);
void reinitKeys(const QStringList &_currentKeys);
void updateTextData();
@ -67,7 +72,8 @@ private:
void calculateValues();
void createDBusInterface();
[[nodiscard]] QString parsePattern(QString _pattern) const;
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value);
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
const KSysGuard::SensorData &_data);
// objects
AWDataAggregator *m_dataAggregator = nullptr;
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
@ -84,3 +90,6 @@ private:
QThreadPool *m_threadPool = nullptr;
QMutex m_mutex;
};
#endif /* AWKEYS_H */

View File

@ -85,24 +85,21 @@ QString AWKeysAggregator::formatter(const QVariant &_data, const QString &_key,
output = _data.toBool() ? m_acOnline : m_acOffline;
break;
case FormatterType::MemGBFormat:
output = QString("%1").arg(_data.toDouble() / GBinBytes, 5, 'f', 1);
output = QString("%1").arg(_data.toDouble() / (1024.0 * 1024.0), 5, 'f', 1);
break;
case FormatterType::MemMBFormat:
output = QString("%1").arg(_data.toDouble() / MBinBytes, 5, 'f', 0);
break;
case FormatterType::MemKBFormat:
output = QString("%1").arg(_data.toDouble() / KBinBytes, 5, 'f', 0);
output = QString("%1").arg(_data.toDouble() / 1024.0, 5, 'f', 0);
break;
case FormatterType::NetSmartFormat:
output = [](const double value) {
if (value > MBinBytes)
return QString("%1").arg(value / MBinBytes, 4, 'f', 1);
output = [](const float value) {
if (value > 1024.0)
return QString("%1").arg(value / 1024.0, 4, 'f', 1);
else
return QString("%1").arg(value / KBinBytes, 4, 'f', 0);
return QString("%1").arg(value, 4, 'f', 0);
}(_data.toDouble());
break;
case FormatterType::NetSmartUnits:
if (_data.toDouble() > MBinBytes)
if (_data.toDouble() > 1024.0)
output = m_translate ? i18n("MB/s") : "MB/s";
else
output = m_translate ? i18n("KB/s") : "KB/s";
@ -237,7 +234,7 @@ void AWKeysAggregator::setTranslate(const bool _translate)
}
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit _units,
QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysGuard::Unit &_units,
const QStringList &_keys)
{
qCDebug(LOG_AW) << "Source" << _source << "with units" << _units;
@ -246,24 +243,24 @@ QStringList AWKeysAggregator::registerSource(const QString &_source, const KSysG
}
double AWKeysAggregator::temperature(const double temp) const
float AWKeysAggregator::temperature(const float temp) const
{
qCDebug(LOG_AW) << "Temperature value" << temp;
auto converted = temp;
float converted = temp;
if (m_tempUnits == "Celsius") {
} else if (m_tempUnits == "Fahrenheit") {
converted = temp * 9.0f / 5.0 + 32.0;
converted = temp * 9.0f / 5.0f + 32.0f;
} else if (m_tempUnits == "Kelvin") {
converted = temp + 273.15;
converted = temp + 273.15f;
} else if (m_tempUnits == "Reaumur") {
converted = temp * 0.8;
converted = temp * 0.8f;
} else if (m_tempUnits == "cm^-1") {
converted = (temp + 273.15) * 0.695;
converted = (temp + 273.15f) * 0.695f;
} else if (m_tempUnits == "kJ/mol") {
converted = (temp + 273.15) * 8.31;
converted = (temp + 273.15f) * 8.31f;
} else if (m_tempUnits == "kcal/mol") {
converted = (temp + 273.15) * 1.98;
converted = (temp + 273.15f) * 1.98f;
} else {
qCWarning(LOG_AW) << "Invalid units" << m_tempUnits;
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWKEYSAGGREGATOR_H
#define AWKEYSAGGREGATOR_H
#include <ksysguard/formatter/Unit.h>
@ -51,7 +53,6 @@ public:
ACFormat,
MemGBFormat,
MemMBFormat,
MemKBFormat,
NetSmartFormat,
NetSmartUnits,
Quotes,
@ -66,10 +67,6 @@ public:
UptimeCustom
};
static constexpr double KBinBytes = 1024.0;
static constexpr double MBinBytes = 1024.0 * KBinBytes;
static constexpr double GBinBytes = 1024.0 * MBinBytes;
explicit AWKeysAggregator(QObject *_parent = nullptr);
~AWKeysAggregator() override;
void initFormatters();
@ -86,10 +83,10 @@ public:
void setTranslate(bool _translate);
public slots:
QStringList registerSource(const QString &_source, const KSysGuard::Unit _units, const QStringList &_keys);
QStringList registerSource(const QString &_source, const KSysGuard::Unit &_units, const QStringList &_keys);
private:
[[nodiscard]] double temperature(double temp) const;
[[nodiscard]] float temperature(float temp) const;
AWFormatterHelper *m_customFormatters = nullptr;
AWDataEngineMapper *m_mapper = nullptr;
QStringList m_timeKeys;
@ -101,3 +98,6 @@ private:
QString m_tempUnits;
bool m_translate = false;
};
#endif /* AWKEYSAGGREGATOR_H */

View File

@ -37,7 +37,7 @@ AWPairConfigFactory::~AWPairConfigFactory()
void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys)
{
auto config = new AWFormatterConfig(nullptr, _keys);
auto *config = new AWFormatterConfig(nullptr, _keys);
config->showDialog();
config->deleteLater();
}
@ -45,7 +45,7 @@ void AWPairConfigFactory::showFormatterDialog(const QStringList &_keys)
void AWPairConfigFactory::showKeysDialog(const QStringList &_keys)
{
auto config = new AWCustomKeysConfig(nullptr, _keys);
auto *config = new AWCustomKeysConfig(nullptr, _keys);
config->showDialog();
config->deleteLater();
}

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWPAIRCONFIGFACTORY_H
#define AWPAIRCONFIGFACTORY_H
#include <QObject>
@ -32,3 +34,6 @@ public:
private:
};
#endif /* AWPAIRCONFIGFACTORY_H */

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWPATTERNFUNCTIONS_H
#define AWPATTERNFUNCTIONS_H
#include <QString>
#include <QVariant>
@ -45,3 +47,6 @@ QString insertMacros(QString _code);
QStringList findKeys(const QString &_code, const QStringList &_keys, bool _isBars);
QStringList findLambdas(const QString &_code);
} // namespace AWPatternFunctions
#endif /* AWPATTERNFUNCTIONS_H */

View File

@ -126,8 +126,8 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_
return;
}
auto manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished, this, &AWTelemetryHandler::telemetryReplyReceived);
auto *manager = new QNetworkAccessManager(nullptr);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(telemetryReplyRecieved(QNetworkReply *)));
QUrl url(REMOTE_TELEMETRY_URL);
QNetworkRequest request(url);
@ -140,14 +140,14 @@ void AWTelemetryHandler::uploadTelemetry(const QString &_group, const QString &_
payload["metadata"] = _value;
payload["type"] = _group;
// convert to QByteArray to send request
auto data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
qCInfo(LOG_AW) << "Send request with body" << data.data() << "and size" << data.size();
manager->post(request, data);
}
void AWTelemetryHandler::telemetryReplyReceived(QNetworkReply *_reply)
void AWTelemetryHandler::telemetryReplyRecieved(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
@ -155,7 +155,7 @@ void AWTelemetryHandler::telemetryReplyReceived(QNetworkReply *_reply)
}
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return;
@ -163,8 +163,8 @@ void AWTelemetryHandler::telemetryReplyReceived(QNetworkReply *_reply)
_reply->deleteLater();
// convert to map
auto response = jsonDoc.toVariant().toMap();
auto message = response["message"].toString();
QVariantMap response = jsonDoc.toVariant().toMap();
QString message = response["message"].toString();
qCInfo(LOG_AW) << "Server reply on telemetry" << message;
return emit(replyReceived(message));

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWTELEMETRYHANDLER_H
#define AWTELEMETRYHANDLER_H
#include <QObject>
@ -41,7 +43,7 @@ signals:
void replyReceived(const QString &_message);
private slots:
void telemetryReplyReceived(QNetworkReply *_reply);
void telemetryReplyRecieved(QNetworkReply *_reply);
private:
static QString getKey(int _count);
@ -50,3 +52,6 @@ private:
int m_storeCount = 0;
bool m_uploadEnabled = false;
};
#endif /* AWTELEMETRYHANDLER_H */

View File

@ -52,9 +52,9 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway)
// showAnyway options requires to show message if no updates found on direct
// request. In case of automatic check no message will be shown
auto manager = new QNetworkAccessManager(nullptr);
auto *manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished,
[_showAnyway, this](QNetworkReply *reply) { return versionReplyReceived(reply, _showAnyway); });
[_showAnyway, this](QNetworkReply *reply) { return versionReplyRecieved(reply, _showAnyway); });
manager->get(QNetworkRequest(QUrl(VERSION_API)));
}
@ -63,7 +63,7 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway)
bool AWUpdateHelper::checkVersion()
{
QSettings settings(m_genericConfig, QSettings::IniFormat);
auto version = QVersionNumber::fromString(settings.value("Version", QString(VERSION)).toString());
QVersionNumber version = QVersionNumber::fromString(settings.value("Version", QString(VERSION)).toString());
// update version
settings.setValue("Version", QString(VERSION));
settings.sync();
@ -88,7 +88,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version)
{
qCDebug(LOG_AW) << "Version" << _version;
auto text = i18n("You are using the actual version %1", _version.toString());
QString text = i18n("You are using the actual version %1", _version.toString());
if (!QString(COMMIT_SHA).isEmpty())
text += QString(" (%1)").arg(QString(COMMIT_SHA));
return genMessageBox(i18n("No new version found"), text, QMessageBox::Ok)->open();
@ -112,7 +112,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
{
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
qCInfo(LOG_AW) << "User select" << ret;
switch (ret) {
@ -126,7 +126,7 @@ void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
}
void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _showAnyway)
void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway)
{
qCDebug(LOG_AW) << "Show message anyway" << _showAnyway;
if (_reply->error() != QNetworkReply::NoError) {
@ -134,8 +134,8 @@ void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _sho
return;
}
auto error = QJsonParseError();
auto jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
QJsonParseError error = QJsonParseError();
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return;
@ -143,13 +143,13 @@ void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _sho
_reply->deleteLater();
// convert to map
auto firstRelease = jsonDoc.toVariant().toList().first().toMap();
auto version = firstRelease["tag_name"].toString();
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
QString version = firstRelease["tag_name"].toString();
version.remove("V.");
m_foundVersion = QVersionNumber::fromString(version);
qCInfo(LOG_AW) << "Update found version to" << m_foundVersion;
auto oldVersion = QVersionNumber::fromString(VERSION);
QVersionNumber oldVersion = QVersionNumber::fromString(VERSION);
if (oldVersion < m_foundVersion)
return showUpdates(m_foundVersion);
else if (_showAnyway)
@ -163,7 +163,7 @@ QMessageBox *AWUpdateHelper::genMessageBox(const QString &_title, const QString
{
qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body;
auto msgBox = new QMessageBox(nullptr);
auto *msgBox = new QMessageBox(nullptr);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->setModal(false);
msgBox->setWindowTitle(_title);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWUPDATEHELPER_H
#define AWUPDATEHELPER_H
#include <QMessageBox>
#include <QObject>
@ -38,7 +40,7 @@ private slots:
static void showInfo(const QVersionNumber &_version);
void showUpdates(const QVersionNumber &_version);
void userReplyOnUpdates(QAbstractButton *_button);
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
void versionReplyRecieved(QNetworkReply *_reply, bool _showAnyway);
private:
static QMessageBox *genMessageBox(const QString &_title, const QString &_body,
@ -46,3 +48,6 @@ private:
QVersionNumber m_foundVersion;
QString m_genericConfig;
};
#endif /* AWUPDATEHELPER_H */

View File

@ -198,7 +198,7 @@ void AbstractExtItem::setCron(const QString &_cron)
qCDebug(LOG_LIB) << "Cron string" << _cron;
// deinit module first
if (m_scheduler) {
disconnect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate);
disconnect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
delete m_scheduler;
}
@ -209,7 +209,7 @@ void AbstractExtItem::setCron(const QString &_cron)
// init scheduler
m_scheduler = new QCronScheduler(this);
m_scheduler->parse(cron());
connect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate);
connect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
}
@ -234,7 +234,7 @@ void AbstractExtItem::setName(const QString &_name)
void AbstractExtItem::setNumber(int _number)
{
qCDebug(LOG_LIB) << "Number" << _number;
auto generateNumber = (_number == -1);
bool generateNumber = (_number == -1);
if (generateNumber) {
_number = []() {
qCWarning(LOG_LIB) << "Number is empty, generate new one";
@ -267,7 +267,7 @@ void AbstractExtItem::deinitSocket()
m_socket->close();
QLocalServer::removeServer(socket());
disconnect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
disconnect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
delete m_socket;
}
@ -278,9 +278,9 @@ void AbstractExtItem::initSocket()
deinitSocket();
m_socket = new QLocalServer(this);
auto listening = m_socket->listen(socket());
bool listening = m_socket->listen(socket());
qCInfo(LOG_LIB) << "Server listening on" << socket() << listening;
connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
connect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
}
@ -303,7 +303,7 @@ void AbstractExtItem::readConfiguration()
bool AbstractExtItem::tryDelete() const
{
auto status = QFile::remove(m_fileName);
bool status = QFile::remove(m_fileName);
qCInfo(LOG_LIB) << "Remove file" << m_fileName << status;
return status;

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTEXTITEM_H
#define ABSTRACTEXTITEM_H
#include <QVariant>
@ -101,3 +102,6 @@ private:
QLocalServer *m_socket = nullptr;
QString m_socketFile = "";
};
#endif /* ABSTRACTEXTITEM_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTEXTITEMAGGREGATOR_H
#define ABSTRACTEXTITEMAGGREGATOR_H
#include <QStandardPaths>
@ -79,3 +80,6 @@ private:
// ui methods
virtual void doCreateItem(QListWidget *_widget) = 0;
};
#endif /* ABSTRACTEXTITEMAGGREGATOR_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTQUOTESPROVIDER_H
#define ABSTRACTQUOTESPROVIDER_H
#include <QObject>
#include <QUrl>
@ -39,3 +40,6 @@ public:
};
[[nodiscard]] virtual QUrl url() const = 0;
};
#endif /* ABSTRACTQUOTESPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef ABSTRACTWEATHERPROVIDER_H
#define ABSTRACTWEATHERPROVIDER_H
#include <QObject>
#include <QUrl>
@ -39,3 +40,6 @@ public:
};
[[nodiscard]] virtual QUrl url() const = 0;
};
#endif /* ABSTRACTWEATHERPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWABSTRACTFORMATTER_H
#define AWABSTRACTFORMATTER_H
#include <QRegularExpression>
@ -51,3 +52,6 @@ private:
// properties
FormatterClass m_type = FormatterClass::NoFormat;
};
#endif /* AWABSTRACTFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWDATETIMEFORMATTER_H
#define AWDATETIMEFORMATTER_H
#include <QLocale>
@ -51,3 +52,6 @@ private:
QString m_format = "";
bool m_translate = true;
};
#endif /* AWDATETIMEFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWFLOATFORMATTER_H
#define AWFLOATFORMATTER_H
#include "awabstractformatter.h"
@ -67,3 +68,6 @@ private:
int m_precision = -1;
double m_summand = 0.0;
};
#endif /* AWFLOATFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWJSONFORMATTER_H
#define AWJSONFORMATTER_H
#include "awabstractformatter.h"
@ -48,3 +49,6 @@ private:
QString m_path;
QVariantList m_splittedPath;
};
#endif /* AWJSONFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWLISTFORMATTER_H
#define AWLISTFORMATTER_H
#include "awabstractformatter.h"
@ -52,3 +53,6 @@ private:
bool m_sorted = false;
QRegularExpression m_regex;
};
#endif /* AWLISTFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWNOFORMATTER_H
#define AWNOFORMATTER_H
#include "awabstractformatter.h"
@ -36,3 +37,6 @@ private:
void translate(void *_ui) override;
// properties
};
#endif /* AWNOFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWSCRIPTFORMATTER_H
#define AWSCRIPTFORMATTER_H
#include "awabstractformatter.h"
@ -55,3 +56,6 @@ private:
bool m_hasReturn = false;
QString m_program;
};
#endif /* AWSCRIPTFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef AWSTRINGFORMATTER_H
#define AWSTRINGFORMATTER_H
#include "awabstractformatter.h"
@ -51,3 +52,6 @@ private:
QChar m_fillChar = QChar();
bool m_forceWidth = false;
};
#endif /* AWSTRINGFORMATTER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTITEMAGGREGATOR_H
#define EXTITEMAGGREGATOR_H
#include <KI18n/KLocalizedString>
@ -65,7 +66,7 @@ public:
m_activeItems.clear();
m_items = getItems();
for (auto item : m_items) {
for (auto &item : m_items) {
if (!item->isActive())
continue;
m_activeItems.append(static_cast<T *>(item));
@ -77,7 +78,7 @@ public:
// HACK as soon as per one widget instance we have two objects each of
// them will try to control socket, whereas actually only one of them
// should be owner of the socket
for (auto item : m_items)
for (auto &item : m_items)
item->initSocket();
}
@ -86,7 +87,7 @@ public:
qCDebug(LOG_LIB) << "Tag" << _tag << "with used type" << _type;
T *found = nullptr;
for (auto item : m_items) {
for (auto &item : m_items) {
if (item->tag(_type) != _tag)
continue;
found = static_cast<T *>(item);
@ -103,7 +104,7 @@ public:
qCDebug(LOG_LIB) << "Number" << _number;
T *found = nullptr;
for (auto item : m_items) {
for (auto &item : m_items) {
if (item->number() != _number)
continue;
found = static_cast<T *>(item);
@ -129,7 +130,7 @@ private:
auto dirs = directories();
for (auto &dir : dirs) {
auto files = QDir(dir).entryList(QDir::Files, QDir::Name);
QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
for (auto &file : files) {
// check filename
if (!file.endsWith(".desktop"))
@ -145,7 +146,10 @@ private:
}
// sort items
std::sort(items.begin(), items.end(), [](auto lhs, auto rhs) { return lhs->number() < rhs->number(); });
std::sort(items.begin(), items.end(), [](auto *lhs, auto *rhs) { return lhs->number() < rhs->number(); });
return items;
};
};
#endif /* EXTITEMAGGREGATOR_H */

View File

@ -40,8 +40,9 @@ ExtNetworkRequest::ExtNetworkRequest(QObject *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
connect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -49,8 +50,8 @@ ExtNetworkRequest::~ExtNetworkRequest()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
disconnect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTNETWORKREQUEST_H
#define EXTNETWORKREQUEST_H
#include <QNetworkReply>
@ -58,3 +59,6 @@ private:
// values
QVariantHash m_values;
};
#endif /* EXTNETWORKREQUEST_H */

View File

@ -46,8 +46,9 @@ ExtQuotes::ExtQuotes(QObject *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtQuotes::quotesReplyReceived);
connect(this, &ExtQuotes::requestDataUpdate, this, &ExtQuotes::sendRequest);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -55,8 +56,8 @@ ExtQuotes::~ExtQuotes()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtQuotes::quotesReplyReceived);
disconnect(this, &ExtQuotes::requestDataUpdate, this, &ExtQuotes::sendRequest);
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTQUOTES_H
#define EXTQUOTES_H
#include <QNetworkReply>
@ -60,3 +61,6 @@ private:
// values
QVariantHash m_values;
};
#endif /* EXTQUOTES_H */

View File

@ -40,10 +40,10 @@ ExtScript::ExtScript(QObject *_parent, const QString &_filePath)
m_values[tag("custom")] = "";
m_process = new QProcess(nullptr);
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
m_process->waitForFinished(0);
connect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}
@ -51,9 +51,10 @@ ExtScript::~ExtScript()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
m_process->kill();
m_process->deleteLater();
disconnect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}
@ -226,11 +227,11 @@ void ExtScript::readJsonFilters()
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
auto jsonText = jsonFile.readAll();
QString jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTSCRIPT_H
#define EXTSCRIPT_H
#include <QProcess>
@ -75,3 +76,6 @@ private:
QVariantMap m_jsonFilters;
QVariantHash m_values;
};
#endif /* EXTSCRIPT_H */

View File

@ -36,10 +36,10 @@ ExtUpgrade::ExtUpgrade(QObject *_parent, const QString &_filePath)
m_values[tag("pkgcount")] = 0;
m_process = new QProcess(nullptr);
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
connect(m_process, SIGNAL(finished(int)), this, SLOT(updateValue()));
m_process->waitForFinished(0);
connect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}
@ -49,7 +49,7 @@ ExtUpgrade::~ExtUpgrade()
m_process->kill();
m_process->deleteLater();
disconnect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTUPGRADE_H
#define EXTUPGRADE_H
#include <QProcess>
@ -63,3 +64,6 @@ private:
// internal properties
QVariantHash m_values;
};
#endif /* EXTUPGRADE_H */

View File

@ -49,8 +49,9 @@ ExtWeather::ExtWeather(QObject *_parent, const QString &_filePath)
// HACK declare as child of nullptr to avoid crash with plasmawindowed
// in the destructor
m_manager = new QNetworkAccessManager(nullptr);
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
connect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
}
@ -58,8 +59,8 @@ ExtWeather::~ExtWeather()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
disconnect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
m_manager->deleteLater();
}
@ -149,7 +150,7 @@ int ExtWeather::ts() const
QString ExtWeather::uniq() const
{
return QString("%1 (%2) at %3").arg(city(), country()).arg(ts());
return QString("%1 (%2) at %3").arg(city()).arg(country()).arg(ts());
}
@ -236,11 +237,11 @@ void ExtWeather::readJsonMap()
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
auto jsonText = jsonFile.readAll();
QString jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef EXTWEATHER_H
#define EXTWEATHER_H
#include <QNetworkReply>
@ -89,3 +90,6 @@ private:
// values
QVariantHash m_values;
};
#endif /* EXTWEATHER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef GRAPHICALITEM_H
#define GRAPHICALITEM_H
#include <QColor>
@ -117,3 +118,6 @@ private:
QStringList m_usedKeys;
int m_width = 100;
};
#endif /* GRAPHICALITEM_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef GRAPHICALITEMHELPER_H
#define GRAPHICALITEMHELPER_H
#include <QColor>
#include <QObject>
@ -55,3 +56,6 @@ private:
// list of values which will be used to store data for graph type only
QList<float> m_values;
};
#endif /* GRAPHICALITEMHELPER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef OWMWEATHERPROVIDER_H
#define OWMWEATHERPROVIDER_H
#include "abstractweatherprovider.h"
@ -41,3 +42,6 @@ private:
int m_ts = 0;
QUrl m_url;
};
#endif /* OWMWEATHERPROVIDER_H */

View File

@ -33,7 +33,7 @@ QCronScheduler::QCronScheduler(QObject *_parent)
m_timer->setSingleShot(false);
m_timer->setInterval(60 * 1000);
connect(m_timer, &QTimer::timeout, this, &QCronScheduler::expired);
connect(m_timer, SIGNAL(timeout()), this, SLOT(expired()));
m_timer->start();
}

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef QCRONSCHEDULER_H
#define QCRONSCHEDULER_H
#include "QObject"
@ -57,3 +58,6 @@ private:
QTimer *m_timer = nullptr;
static QList<int> parseField(const QString &_value, int _min, int _max);
};
#endif /* QCRONSCHEDULER_H */

View File

@ -1,8 +1,8 @@
[Desktop Entry]
Encoding=UTF-8
Name=AAPL
Name=AAPL.NASDAQ
Comment=Apple Inc
X-AW-Ticker="AAPL.US"
X-AW-Ticker="AAPL"
X-AW-Active=false
X-AW-ApiVersion=5
X-AW-Interval=60

View File

@ -1,8 +1,8 @@
[Desktop Entry]
Encoding=UTF-8
Name=GOOG
Name=GOOG.NASDAQ
Comment=Google Inc
X-AW-Ticker="GOOG.US"
X-AW-Ticker="GOOG"
X-AW-Active=false
X-AW-ApiVersion=5
X-AW-Interval=60

View File

@ -1,8 +1,8 @@
[Desktop Entry]
Encoding=UTF-8
Name=MSFT
Name=MSFT.NASDAQ
Comment=Microsoft Corp
X-AW-Ticker="MSFT.US"
X-AW-Ticker="MSFT"
X-AW-Active=false
X-AW-ApiVersion=5
X-AW-Interval=60

View File

@ -54,7 +54,7 @@ QVariantHash StooqQuotesProvider::parse(const QByteArray &_source, const QVarian
QVariantHash values;
auto sourceValues = QString::fromUtf8(_source).trimmed().split(',');
QStringList sourceValues = QString::fromUtf8(_source).trimmed().split(',');
if (sourceValues.count() != 2) {
qCWarning(LOG_LIB) << "Parse error" << sourceValues;
return values;
@ -67,12 +67,12 @@ QVariantHash StooqQuotesProvider::parse(const QByteArray &_source, const QVarian
// last trade
auto price = sourceValues.at(0).toDouble();
values[tag("pricechg")] = oldPrice == 0.0 ? 0.0 : price - oldPrice;
values[tag("percpricechg")] = 100.0 * values[tag("pricechg")].toDouble() / oldPrice;
values[tag("percpricechg")] = 100.0 * values[tag("pricechg")].toDouble() / price;
values[tag("price")] = price;
// volume
auto volume = sourceValues.at(1).toInt();
values[tag("volumechg")] = oldVolume == 0 ? 0 : volume - oldVolume;
values[tag("percvolumechg")] = 100.0 * values[tag("volumechg")].toDouble() / oldVolume;
values[tag("percvolumechg")] = 100.0 * values[tag("volumechg")].toDouble() / volume;
values[tag("volume")] = volume;
return values;

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef STOOQQUOTESPROVIDER_H
#define STOOQQUOTESPROVIDER_H
#include "abstractquotesprovider.h"
@ -36,3 +37,6 @@ public:
private:
QUrl m_url;
};
#endif /* STOOQQUOTESPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef YAHOOQUOTESPROVIDER_H
#define YAHOOQUOTESPROVIDER_H
#include "abstractquotesprovider.h"
@ -37,3 +38,6 @@ public:
private:
QUrl m_url;
};
#endif /* YAHOOQUOTESPROVIDER_H */

View File

@ -15,7 +15,8 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef YAHOOWEATHERPROVIDER_H
#define YAHOOWEATHERPROVIDER_H
#include "abstractweatherprovider.h"
@ -42,3 +43,6 @@ private:
int m_ts = 0;
QUrl m_url;
};
#endif /* YAHOOWEATHERPROVIDER_H */

View File

@ -16,21 +16,27 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
KCM.SimpleKCM {
Item {
id: aboutPage
// backend
DPAdds {
id: dpAdds
}
width: childrenRect.width
height: childrenRect.height
property bool debug: awActions.isDebugEnabled()
AboutTab {
textProvider: dpAdds
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,14 +16,24 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
KCM.SimpleKCM {
Item {
id: activeAppearancePage
// backend
DPAdds {
id: dpAdds
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: dpAdds.isDebugEnabled()
property alias cfg_currentFontFamily: font.value
property alias cfg_currentFontSize: fontSize.value
@ -33,6 +43,7 @@ KCM.SimpleKCM {
property alias cfg_currentTextStyleColor: selectStyleColor.value
property string cfg_currentTextStyle: textStyle.value
Column {
id: pageColumn
anchors.fill: parent
@ -88,4 +99,9 @@ KCM.SimpleKCM {
value: plasmoid.configuration.currentTextStyleColor
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -17,14 +17,23 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
KCM.SimpleKCM {
Item {
id: advancedPage
// backend
DPAdds {
id: dpAdds
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: dpAdds.isDebugEnabled()
property alias cfg_background: background.checked
property alias cfg_verticalLayout: verticalLayout.checked
@ -35,6 +44,7 @@ KCM.SimpleKCM {
property alias cfg_tooltipWidth: tooltipWidth.value
property alias cfg_tooltipColor: tooltipColor.value
Column {
id: pageColumn
anchors.fill: parent
@ -72,48 +82,48 @@ KCM.SimpleKCM {
editable: true
model: [
{
"label": "#",
"name": "#"
'label': '#',
'name': '#'
},
{
"label": "$",
"name": "$"
'label': '$',
'name': '$'
},
{
"label": "%",
"name": "%"
'label': '%',
'name': '%'
},
{
"label": "&",
"name": "&"
'label': '&',
'name': '&'
},
{
"label": "*",
"name": "*"
'label': '*',
'name': '*'
},
{
"label": "@",
"name": "@"
'label': '@',
'name': '@'
},
{
"label": "¤",
"name": "¤"
'label': '¤',
'name': '¤'
},
{
"label": "¶",
"name": "¶"
'label': '¶',
'name': '¶'
},
{
"label": "·",
"name": "·"
'label': '·',
'name': '·'
},
{
"label": "º",
"name": "º"
'label': 'º',
'name': 'º'
},
{
"label": plasmoid.configuration.mark,
"name": plasmoid.configuration.mark
'label': plasmoid.configuration.mark,
'name': plasmoid.configuration.mark
}
]
text: i18n("Mark")
@ -134,16 +144,16 @@ KCM.SimpleKCM {
id: tooltipType
model: [
{
"label": i18n("contours"),
"name": "contours"
'label': i18n("contours"),
'name': "contours"
},
{
"label": i18n("names"),
"name": "names"
'label': i18n("names"),
'name': "names"
},
{
"label": i18n("none"),
"name": "none"
'label': i18n("none"),
'name': "none"
}
]
text: i18n("Tooltip type")
@ -168,4 +178,8 @@ KCM.SimpleKCM {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,14 +16,24 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
KCM.SimpleKCM {
Item {
id: inactiveAppearancePage
// backend
DPAdds {
id: dpAdds
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: dpAdds.isDebugEnabled()
property alias cfg_fontFamily: font.value
property alias cfg_fontSize: fontSize.value
@ -33,6 +43,7 @@ KCM.SimpleKCM {
property alias cfg_textStyleColor: selectStyleColor.value
property string cfg_textStyle: textStyle.value
Column {
id: pageColumn
anchors.fill: parent
@ -88,4 +99,9 @@ KCM.SimpleKCM {
value: plasmoid.configuration.textStyleColor
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -21,8 +21,8 @@ import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
PlasmoidItem {
@ -32,6 +32,7 @@ PlasmoidItem {
id: dpAdds
}
property bool debug: dpAdds.isDebugEnabled()
property variant tooltipSettings: {
"tooltipColor": plasmoid.configuration.tooltipColor,
"tooltipType": plasmoid.configuration.tooltipType,
@ -42,12 +43,14 @@ PlasmoidItem {
signal needTooltipUpdate
signal sizeUpdate
// init
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Plasmoid.icon: "utilities-system-monitor"
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
// ui
GridLayout {
anchors.fill: parent
@ -94,6 +97,7 @@ PlasmoidItem {
}
}
Timer {
id: timer
interval: 1000
@ -101,16 +105,19 @@ PlasmoidItem {
}
onNeedUpdate: {
for (let i = 0; i < repeater.count; i++) {
if (debug) console.debug()
for (var i=0; i<repeater.count; i++) {
if (!repeater.itemAt(i)) {
if (debug) console.info("Nothing to do here yet", i)
timer.start()
return
}
repeater.itemAt(i).text = dpAdds.parsePattern(plasmoid.configuration.text, i)
if (dpAdds.currentDesktop() === i) {
if (dpAdds.currentDesktop() == i) {
repeater.itemAt(i).color = plasmoid.configuration.currentFontColor
repeater.itemAt(i).font.family = plasmoid.configuration.currentFontFamily
repeater.itemAt(i).font.italic = plasmoid.configuration.currentFontStyle === "italic"
repeater.itemAt(i).font.italic = plasmoid.configuration.currentFontStyle == "italic"
repeater.itemAt(i).font.pointSize = plasmoid.configuration.currentFontSize
repeater.itemAt(i).font.weight = General.fontWeight[plasmoid.configuration.currentFontWeight]
repeater.itemAt(i).style = General.textStyle[plasmoid.configuration.currentTextStyle]
@ -118,7 +125,7 @@ PlasmoidItem {
} else {
repeater.itemAt(i).color = plasmoid.configuration.fontColor
repeater.itemAt(i).font.family = plasmoid.configuration.fontFamily
repeater.itemAt(i).font.italic = plasmoid.configuration.fontStyle === "italic"
repeater.itemAt(i).font.italic = plasmoid.configuration.fontStyle == "italic"
repeater.itemAt(i).font.pointSize = plasmoid.configuration.fontSize
repeater.itemAt(i).font.weight = General.fontWeight[plasmoid.configuration.fontWeight]
repeater.itemAt(i).style = General.textStyle[plasmoid.configuration.textStyle]
@ -132,11 +139,13 @@ PlasmoidItem {
}
onNeedTooltipUpdate: {
for (let i = 0; i < repeater.count; i++) {
if (debug) console.debug()
for (var i=0; i<repeater.count; i++) {
repeater.itemAt(i).tooltip.text = dpAdds.toolTipImage(i)
// resize text tooltip to content size
// this hack does not work for images-based tooltips
if (tooltipSettings.tooltipType === "names") {
if (tooltipSettings.tooltipType == "names") {
repeater.itemAt(i).tooltip.height = repeater.itemAt(i).tooltip.implicitHeight
repeater.itemAt(i).tooltip.width = repeater.itemAt(i).tooltip.implicitWidth
}
@ -144,9 +153,11 @@ PlasmoidItem {
}
onSizeUpdate: {
if (plasmoid.configuration.height === 0) {
let newHeight = 0
for (let i = 0; i < repeater.count; i++)
if (debug) console.debug()
if (plasmoid.configuration.height == 0) {
var newHeight = 0
for (var i=0; i<repeater.count; i++)
newHeight += repeater.itemAt(i).contentHeight
Layout.minimumHeight = newHeight
Layout.maximumHeight = -1
@ -154,9 +165,9 @@ PlasmoidItem {
Layout.minimumHeight = plasmoid.configuration.height
Layout.maximumHeight = plasmoid.configuration.height
}
if (plasmoid.configuration.width === 0) {
let newWidth = 0
for (let i = 0; i < repeater.count; i++)
if (plasmoid.configuration.width == 0) {
var newWidth = 0
for (var i=0; i<repeater.count; i++)
newWidth += repeater.itemAt(i).contentWidth
Layout.minimumWidth = newWidth
Layout.maximumWidth = -1
@ -168,6 +179,7 @@ PlasmoidItem {
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.debug()
dpAdds.setMark(plasmoid.configuration.mark)
dpAdds.setToolTipData(tooltipSettings)
@ -176,6 +188,8 @@ PlasmoidItem {
}
Component.onCompleted: {
if (debug) console.debug()
// init submodule
Plasmoid.userConfiguringChanged(false)
dpAdds.desktopChanged.connect(needUpdate)

View File

@ -0,0 +1,27 @@
# Do not edit qmldir directly it will be overrided during compilation,
# edit qml/qmldir.in file instead.
# common QML constants
singleton General 1.0 file:///usr/share/awesomewidgets/qml/General.qml
# custom QML UI classes
AboutTab file:///usr/share/awesomewidgets/qml/AboutTab.qml
AWExtensions file:///usr/share/awesomewidgets/qml/AWExtensions.qml
AWInfoLabel file:///usr/share/awesomewidgets/qml/AWInfoLabel.qml
AWTagSelector file:///usr/share/awesomewidgets/qml/AWTagSelector.qml
AWTextEditor file:///usr/share/awesomewidgets/qml/AWTextEditor.qml
BugReport file:///usr/share/awesomewidgets/qml/BugReport.qml
ButtonSelector file:///usr/share/awesomewidgets/qml/ButtonSelector.qml
CheckBoxSelector file:///usr/share/awesomewidgets/qml/CheckBoxSelector.qml
ColorSelector file:///usr/share/awesomewidgets/qml/ColorSelector.qml
ComboBoxSelector file:///usr/share/awesomewidgets/qml/ComboBoxSelector.qml
ExportDialog file:///usr/share/awesomewidgets/qml/ExportDialog.qml
FontSelector file:///usr/share/awesomewidgets/qml/FontSelector.qml
HtmlDefaultFunctionsBar file:///usr/share/awesomewidgets/qml/HtmlDefaultFunctionsBar.qml
HtmlEditorButton file:///usr/share/awesomewidgets/qml/HtmlEditorButton.qml
HtmlEditorColor file:///usr/share/awesomewidgets/qml/HtmlEditorColor.qml
HtmlEditorFont file:///usr/share/awesomewidgets/qml/HtmlEditorFont.qml
ImportDialog file:///usr/share/awesomewidgets/qml/ImportDialog.qml
IntegerSelector file:///usr/share/awesomewidgets/qml/IntegerSelector.qml
LineSelector file:///usr/share/awesomewidgets/qml/LineSelector.qml

View File

@ -16,21 +16,28 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
import org.kde.plasma.private.desktoppanel 1.0
import "."
KCM.SimpleKCM {
Item {
id: widgetPage
// backend
DPAdds {
id: dpAdds
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: dpAdds.isDebugEnabled()
property alias cfg_text: textPattern.text
Column {
id: pageColumn
anchors.fill: parent
@ -53,4 +60,9 @@ KCM.SimpleKCM {
backend: dpAdds
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -19,7 +19,7 @@
"Id": "org.kde.plasma.desktoppanel",
"License": "GPLv3",
"Name": "Desktop Panel",
"Version": "4.0.0",
"Version": "3.5.1",
"Website": "https://arcanis.me/projects/awesome-widgets/"
},
"X-Plasma-API-Minimum-Version": "6.0"

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef DPPLUGIN_H
#define DPPLUGIN_H
#include <QQmlExtensionPlugin>
@ -28,3 +30,6 @@ class DPPlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri) override;
};
#endif /* DPPLUGIN_H */

View File

@ -49,7 +49,9 @@ DPAdds::DPAdds(QObject *_parent)
m_vdi = new TaskManager::VirtualDesktopInfo(this);
m_taskModel = new TaskManager::WindowTasksModel(this);
connect(m_vdi, &TaskManager::VirtualDesktopInfo::currentDesktopChanged, this, &DPAdds::desktopChanged);
connect(m_vdi, SIGNAL(currentDesktopChanged()), this, SIGNAL(desktopChanged()));
connect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), this, SIGNAL(windowListChanged()));
connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)), this, SIGNAL(windowListChanged()));
}
@ -62,6 +64,13 @@ DPAdds::~DPAdds()
}
// HACK: since QML could not use QLoggingCategory I need this hack
bool DPAdds::isDebugEnabled()
{
return LOG_DP().isDebugEnabled();
}
int DPAdds::currentDesktop() const
{
auto current = m_vdi->currentDesktop();
@ -111,8 +120,8 @@ QString DPAdds::toolTipImage(const int _desktop) const
}
// init
auto toolTipScene = new QGraphicsScene();
auto toolTipView = new QGraphicsView(toolTipScene);
auto *toolTipScene = new QGraphicsScene();
auto *toolTipView = new QGraphicsView(toolTipScene);
toolTipView->setStyleSheet("background: transparent");
toolTipView->setContentsMargins(0, 0, 0, 0);
toolTipView->setFrameShape(QFrame::NoFrame);

View File

@ -15,7 +15,9 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#pragma once
#ifndef DPADDS_H
#define DPADDS_H
// ui library required by WId definition
#include <QGuiApplication>
@ -44,6 +46,7 @@ class DPAdds : public QObject
public:
explicit DPAdds(QObject *_parent = nullptr);
~DPAdds() override;
Q_INVOKABLE static bool isDebugEnabled();
Q_INVOKABLE [[nodiscard]] int currentDesktop() const;
Q_INVOKABLE static QStringList dictKeys(bool _sorted = true, const QString &_regexp = "");
Q_INVOKABLE [[nodiscard]] int numberOfDesktops() const;
@ -76,3 +79,6 @@ private:
QString m_tooltipColor = "#000000";
QString m_tooltipType = "none";
};
#endif /* DPADDS_H */

View File

@ -27,6 +27,8 @@
#include "awdebug.h"
#include "extsysmonaggregator.h"
#include "gpuloadsource.h"
#include "hddtempsource.h"
ExtendedSysMon::ExtendedSysMon(QObject *_parent, const QVariantList &_args)
@ -51,6 +53,9 @@ void ExtendedSysMon::readConfiguration()
settings.beginGroup("Configuration");
rawConfig["ACPIPATH"] = settings.value("ACPIPATH", "/sys/class/power_supply/").toString();
rawConfig["GPUDEV"] = settings.value("GPUDEV", "auto").toString();
rawConfig["HDDDEV"] = settings.value("HDDDEV", "all").toString();
rawConfig["HDDTEMPCMD"] = settings.value("HDDTEMPCMD", "sudo smartctl -a").toString();
rawConfig["MPDADDRESS"] = settings.value("MPDADDRESS", "localhost").toString();
rawConfig["MPDPORT"] = settings.value("MPDPORT", "6600").toString();
rawConfig["MPRIS"] = settings.value("MPRIS", "auto").toString();
@ -66,6 +71,31 @@ QHash<QString, QString> ExtendedSysMon::updateConfiguration(QHash<QString, QStri
{
qCDebug(LOG_ESM) << "Raw configuration" << _rawConfig;
// gpudev
if (_rawConfig["GPUDEV"] == "disable")
;
else if (_rawConfig["GPUDEV"] == "auto")
_rawConfig["GPUDEV"] = GPULoadSource::autoGpu();
else if ((_rawConfig["GPUDEV"] != "ati") && (_rawConfig["GPUDEV"] != "nvidia"))
_rawConfig["GPUDEV"] = GPULoadSource::autoGpu();
// hdddev
auto allHddDevices = HDDTemperatureSource::allHdd();
if (_rawConfig["HDDDEV"] == "all") {
_rawConfig["HDDDEV"] = allHddDevices.join(',');
} else if (_rawConfig["HDDDEV"] == "disable") {
_rawConfig["HDDDEV"] = "";
} else {
auto deviceList = _rawConfig["HDDDEV"].split(',', Qt::SkipEmptyParts);
QStringList devices;
auto diskRegexp = QRegularExpression("^/dev/[hms]d[a-z]$");
for (auto &device : deviceList)
if ((QFile::exists(device)) && (device.contains(diskRegexp)))
devices.append(device);
if (devices.isEmpty())
_rawConfig["HDDDEV"] = allHddDevices.join(',');
else
_rawConfig["HDDDEV"] = devices.join(',');
}
// player
if ((_rawConfig["PLAYER"] != "mpd") && (_rawConfig["PLAYER"] != "mpris") && (_rawConfig["PLAYER"] != "disable"))
_rawConfig["PLAYER"] = "mpris";

Some files were not shown because too many files have changed in this diff Show More