Compare commits

..

8 Commits

Author SHA1 Message Date
ce93664f5b feat: restore multithreaded processing 2024-04-08 11:55:28 +03:00
ac52888b0d refactor: use default qml library paths
previous implementation stores data in share instead of lib (I guess, I
had issues with using default paths?). Let's use normal paths instead
2024-03-31 15:17:50 +03:00
a35b57e5d2 refactor: simplify sources processing
Also fix desktop source
2024-03-30 22:34:31 +02:00
0bcceefd47 refactor: remove innclude guards, use pragma instead 2024-03-28 03:05:26 +02:00
f27050afbc refactor: use new-style qt connections 2024-03-28 02:40:17 +02:00
d71f85eaad fix: remove deprecations from test cases 2024-03-28 01:57:18 +02:00
b0df3535a5 fix: handle memory units as bytes 2024-03-28 01:56:57 +02:00
4d01b87088 initial plasma6 support 2024-03-28 01:26:46 +02:00
222 changed files with 1276 additions and 3774 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 ksysguard
run: pacman -S --noconfirm plasma-workspace
- name: configure cmake
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
run: cmake -B build -S sources -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_FUTURE=ON -DBUILD_TESTING=ON
- name: build
working-directory: /repo/build

View File

@ -2,17 +2,14 @@
pkgname=plasma6-applet-awesome-widgets
_pkgname=awesome-widgets
pkgver=4.0.0alpha1
pkgver=4.0.0alpha2
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=("hddtemp: for HDD temperature monitor"
"smartmontools: for HDD temperature monitor"
"mpd: for music player monitor"
"nvidia-utils: for GPU monitor")
optdepends=("mpd: for music player 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
View File

@ -1,284 +0,0 @@
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, SIGNAL(currentIndexChanged(QString)), this, SLOT(updateColor(QString)));
connect(colorBox, &QComboBox::currentTextChanged, this, &CFontDialog::updateColor);
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, SIGNAL(accepted()), this, SLOT(accept()));
QObject::connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
QObject::connect(buttons, &QDialogButtonBox::accepted, this, &CFontDialog::accept);
QObject::connect(buttons, &QDialogButtonBox::rejected, this, &CFontDialog::reject);
mainGrid->addWidget(buttons, 1, 0, 1, 5);
italicBox->setHidden(!needItalic);

View File

@ -15,8 +15,7 @@
* License along with this library. *
***************************************************************************/
#ifndef FONTDIALOG_H
#define FONTDIALOG_H
#pragma once
#include <QComboBox>
#include <QDialog>
@ -72,6 +71,3 @@ 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,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWDEBUG_H
#define AWDEBUG_H
#pragma once
#include <QLoggingCategory>
@ -42,6 +40,3 @@ 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,27 +16,21 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
Item {
KCM.SimpleKCM {
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,24 +17,20 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
Item {
KCM.SimpleKCM {
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
@ -55,7 +51,6 @@ Item {
property alias cfg_telemetryRemote: telemetryRemote.checked
property alias cfg_telemetryId: telemetryId.value
Column {
id: pageColumn
anchors.fill: parent
@ -135,32 +130,32 @@ Item {
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")
@ -194,14 +189,18 @@ Item {
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
@ -210,11 +209,12 @@ Item {
value: i18n("Export configuration")
onButtonActivated: saveConfigAs.open()
}
ButtonSelector {
ImportDialog {
id: loadConfigFrom
onConfigurationReceived: {
for (var key in configuration)
for (const key in configuration)
plasmoid.configuration[key] = configuration[key]
}
}
@ -225,15 +225,19 @@ Item {
}
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
@ -242,6 +246,7 @@ Item {
text: i18n("History count")
value: plasmoid.configuration.telemetryCount
}
LineSelector {
id: telemetryId
text: i18n("Telemetry ID")
@ -250,9 +255,4 @@ Item {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,30 +16,21 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import "."
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
Item {
KCM.SimpleKCM {
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
@ -50,7 +41,6 @@ Item {
property alias cfg_textStyleColor: selectStyleColor.value
property string cfg_textStyle: textStyle.value
Column {
id: pageColumn
anchors.fill: parent
@ -106,9 +96,4 @@ Item {
value: plasmoid.configuration.textStyleColor
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -17,36 +17,29 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
Item {
KCM.SimpleKCM {
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
@ -58,61 +51,11 @@ Item {
}
}
GroupBox {
height: implicitHeight
width: parent.width
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
@ -128,16 +71,16 @@ Item {
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")
@ -150,40 +93,40 @@ Item {
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")
@ -211,9 +154,11 @@ Item {
height: implicitHeight
width: parent.width
title: i18n("Extensions")
Column {
height: implicitHeight
width: parent.width
ButtonSelector {
value: i18n("Custom scripts")
onButtonActivated: awKeys.editItem("extscript")
@ -244,19 +189,11 @@ Item {
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,12 +22,13 @@ import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.private.awesomewidget 1.0
import "."
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
PlasmoidItem {
id: main
// backend
AWKeys {
id: awKeys
@ -42,7 +43,6 @@ PlasmoidItem {
id: bugReport
}
property bool debug: awActions.isDebugEnabled()
property variant tooltipSettings: {
"tooltipNumber": plasmoid.configuration.tooltipNumber,
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
@ -72,15 +72,13 @@ 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
@ -94,7 +92,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]
@ -124,8 +122,8 @@ PlasmoidItem {
}
onAccepted: {
var tag = tagSelectorBox.editText
var message = i18n("Tag: %1", tag)
const tag = tagSelectorBox.editText
let message = i18n("Tag: %1", tag)
message += "<br>"
message += i18n("Value: %1", awKeys.valueByKey(tag))
message += "<br>"
@ -138,25 +136,33 @@ 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
@ -167,31 +173,25 @@ 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,7 +202,6 @@ PlasmoidItem {
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.debug()
// init submodule
awKeys.initDataAggregator(tooltipSettings)
@ -217,7 +216,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,
@ -227,37 +226,10 @@ 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) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
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 v.toString(16);
});
}

View File

@ -1,27 +0,0 @@
# 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,23 +17,14 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
Item {
KCM.SimpleKCM {
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
@ -53,7 +44,6 @@ Item {
property alias cfg_batTooltipColor: batTooltipColor.value
property alias cfg_batInTooltipColor: batInTooltipColor.value
Column {
id: pageColumn
anchors.fill: parent
@ -178,11 +168,13 @@ Item {
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")
@ -204,11 +196,13 @@ Item {
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")
@ -217,9 +211,4 @@ Item {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,13 +16,16 @@
***************************************************************************/
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.awesomewidget 1.0
import "."
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.awesomewidget
Item {
KCM.SimpleKCM {
id: widgetPage
// backend
AWKeys {
id: awKeys
@ -31,19 +34,11 @@ Item {
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
@ -74,10 +69,7 @@ Item {
}
}
Component.onCompleted: {
if (debug) console.debug()
awKeys.needTextToBeUpdated.connect(needTextUpdate)
// init submodule
awKeys.initKeys(plasmoid.configuration.text, plasmoid.configuration.interval,
@ -92,7 +84,6 @@ Item {
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": "3.5.1",
"Version": "4.0.0",
"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, SIGNAL(accepted()), this, SLOT(accept()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AWAbstractPairConfig::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &AWAbstractPairConfig::reject);
// edit feature
if (m_hasEdit) {
m_editButton = ui->buttonBox->addButton(i18n("Edit"), QDialogButtonBox::ActionRole);
connect(m_editButton, SIGNAL(clicked(bool)), this, SLOT(edit()));
connect(m_editButton, &QPushButton::clicked, [this]() { return edit(); });
}
}
@ -84,14 +84,14 @@ void AWAbstractPairConfig::edit()
void AWAbstractPairConfig::updateUi()
{
QPair<QString, QString> current = dynamic_cast<AWAbstractSelector *>(sender())->current();
int index = m_selectors.indexOf(dynamic_cast<AWAbstractSelector *>(sender()));
auto current = dynamic_cast<AWAbstractSelector *>(sender())->current();
auto 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;
AWAbstractSelector *selector = m_selectors.takeAt(index);
auto 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, SIGNAL(selectionChanged()), this, SLOT(updateUi()));
connect(selector, &AWAbstractSelector::selectionChanged, this, &AWAbstractPairConfig::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, SIGNAL(selectionChanged()), this, SLOT(updateUi()));
disconnect(selector, &AWAbstractSelector::selectionChanged, this, &AWAbstractPairConfig::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 QPair<QStringList, QStringList>(left, right);
return {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, m_helper->pairs()[key]));
addSelector(keys.first, keys.second, QPair<QString, QString>(key, pairs[key]));
// empty one
addSelector(keys.first, keys.second, QPair<QString, QString>());
}

View File

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

View File

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

View File

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

View File

@ -71,13 +71,6 @@ 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;
@ -97,7 +90,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,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWACTIONS_H
#define AWACTIONS_H
#pragma once
#include <QMap>
#include <QObject>
@ -34,7 +32,6 @@ 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();
@ -48,6 +45,3 @@ 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, SIGNAL(replyReceived(const int, const QString &)), this, SLOT(showInformation(int, const QString &)));
connect(this, &AWBugReporter::replyReceived, this, &AWBugReporter::showInformation);
}
@ -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, SIGNAL(finished(QNetworkReply *)), this, SLOT(issueReplyRecieved(QNetworkReply *)));
auto manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished, this, &AWBugReporter::issueReplyReceived);
QNetworkRequest request = QNetworkRequest(QUrl(BUGTRACKER_API));
auto 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
QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
auto 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::issueReplyRecieved(QNetworkReply *_reply)
void AWBugReporter::issueReplyReceived(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::issueReplyRecieved(QNetworkReply *_reply)
}
QJsonParseError error{};
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
auto 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::issueReplyRecieved(QNetworkReply *_reply)
_reply->deleteLater();
// convert to map
QVariantMap response = jsonDoc.toVariant().toMap();
QString url = response["html_url"].toString();
int number = response["number"].toInt();
auto response = jsonDoc.toVariant().toMap();
auto url = response["html_url"].toString();
auto 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)
{
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
qCInfo(LOG_AW) << "User select" << ret;
switch (ret) {

View File

@ -15,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWBUGREPORTER_H
#define AWBUGREPORTER_H
#pragma once
#include <QObject>
@ -41,13 +39,10 @@ signals:
void replyReceived(int _number, const QString &_url);
private slots:
void issueReplyRecieved(QNetworkReply *_reply);
void issueReplyReceived(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
const auto *configuration = dynamic_cast<const QQmlPropertyMap *>(_nativeConfig);
auto configuration = dynamic_cast<const QQmlPropertyMap *>(_nativeConfig);
settings.beginGroup("plasmoid");
for (auto &key : configuration->keys()) {
QVariant value = configuration->value(key);
@ -170,9 +170,6 @@ 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");
@ -197,9 +194,6 @@ 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,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWCONFIGHELPER_H
#define AWCONFIGHELPER_H
#pragma once
#include <QObject>
#include <QVariant>
@ -52,6 +50,3 @@ private:
QString m_baseDir;
QStringList m_dirs = {"desktops", "quotes", "scripts", "upgrade", "weather", "formatters"};
};
#endif /* AWCONFIGHELPER_H */

View File

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

View File

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

View File

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

View File

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

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(KSysGuard::SensorDataList _data);
void updateData(const KSysGuard::SensorDataList &_data);
void updateSensors(const QHash<QString, KSysGuard::SensorInfo> &_sensors);
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWFORMATTERHELPER_H
#define AWFORMATTERHELPER_H
#pragma once
#include "abstractextitemaggregator.h"
#include "awabstractformatter.h"
@ -56,6 +54,3 @@ 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;
QString fileName
auto fileName
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
qCInfo(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
@ -41,19 +41,8 @@ bool AWKeyCache::addKeyToCache(const QString &_type, const QString &_key)
for (auto &number : cache.allKeys())
cachedValues.append(cache.value(number).toString());
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();
if (_type == "net") {
auto rawInterfaceList = QNetworkInterface::allInterfaces();
for (auto &interface : rawInterfaceList) {
QString device = interface.name();
if (cachedValues.contains(device))
@ -98,7 +87,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
if (!used.contains(key))
continue;
key.remove("hddtotmb");
int index = key.toInt();
auto index = key.toInt();
used << QString("hddfreemb%1").arg(index) << QString("hddmb%1").arg(index);
}
// hddtotgb*
@ -106,7 +95,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
if (!used.contains(key))
continue;
key.remove("hddtotgb");
int index = key.toInt();
auto index = key.toInt();
used << QString("hddfreegb%1").arg(index) << QString("hddgb%1").arg(index);
}
// mem
@ -139,7 +128,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
for (auto &key : netKeys) {
if (!used.contains(key))
continue;
QStringList filt = _allKeys.filter(QRegularExpression(QString("^%1[0-9]{1,}").arg(key)));
auto filt = _allKeys.filter(QRegularExpression(QString("^%1[0-9]{1,}").arg(key)));
for (auto &filtered : filt)
used << filtered;
}
@ -158,7 +147,7 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys, const QStringL
QHash<QString, QStringList> AWKeyCache::loadKeysFromCache()
{
QString fileName
auto fileName
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
qCInfo(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);

View File

@ -15,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWKEYCACHE_H
#define AWKEYCACHE_H
#pragma once
#include <QHash>
#include <QString>
@ -31,6 +29,3 @@ 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,7 +72,6 @@ QHash<QString, QStringList> AWKeyOperations::devices() const
void AWKeyOperations::updateCache()
{
// update network and hdd list
addKeyToCache("hdd");
addKeyToCache("net");
}
@ -90,15 +89,20 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(item->tag("timestamp"));
}
// cpuclock & cpu
for (int i = 0; i < QThread::idealThreadCount(); i++) {
for (auto i = 0; i < QThread::idealThreadCount(); i++) {
allKeys.append(QString("cpucl%1").arg(i));
allKeys.append(QString("cpu%1").arg(i));
}
// temperature
for (int i = 0; i < m_devices["temp"].count(); i++)
for (auto 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 (int i = 0; i < m_devices["mount"].count(); i++) {
for (auto 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));
@ -108,15 +112,12 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(QString("hdd%1").arg(i));
}
// hdd speed
for (int i = 0; i < m_devices["disk"].count(); i++) {
for (auto 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 (int i = 0; i < m_devices["net"].count(); i++) {
for (auto 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));
@ -129,9 +130,8 @@ QStringList AWKeyOperations::dictKeys() const
allKeys.append(QString("up%1").arg(i));
}
// battery
QStringList allBatteryDevices
= QDir("/sys/class/power_supply")
.entryList(QStringList({"BAT*"}), QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
auto 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,52 +205,48 @@ QString AWKeyOperations::infoByKey(const QString &_key) const
{
qCDebug(LOG_AW) << "Requested key" << _key;
QString stripped = _key;
auto stripped = _key;
stripped.remove(QRegularExpression("\\d+"));
QString output;
if (_key.startsWith("bar")) {
AbstractExtItem *item = m_graphicalItems->itemByTag(_key, stripped);
auto item = m_graphicalItems->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.startsWith("custom")) {
AbstractExtItem *item = m_extScripts->itemByTag(_key, stripped);
auto item = m_extScripts->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("^hdd[rw]"))) {
QString index = _key;
auto 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)"))) {
QString index = _key;
auto 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]"))) {
QString index = _key;
auto index = _key;
index.remove(QRegularExpression("^(down|up)"));
output = m_devices["net"][index.toInt()];
} else if (_key.startsWith("pkgcount")) {
AbstractExtItem *item = m_extUpgrade->itemByTag(_key, stripped);
auto item = m_extUpgrade->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("(^|perc)(ask|bid|price)(chg|)"))) {
AbstractExtItem *item = m_extQuotes->itemByTag(_key, stripped);
auto item = m_extQuotes->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.contains(QRegularExpression("(weather|weatherId|humidity|pressure|temperature)"))) {
AbstractExtItem *item = m_extWeather->itemByTag(_key, stripped);
auto item = m_extWeather->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else if (_key.startsWith("temp")) {
QString index = _key;
auto index = _key;
index.remove("temp");
output = m_devices["temp"][index.toInt()];
} else if (_key.startsWith("response")) {
AbstractExtItem *item = m_extNetRequest->itemByTag(_key, stripped);
auto item = m_extNetRequest->itemByTag(_key, stripped);
if (item)
output = item->uniq();
} else {
@ -302,9 +298,10 @@ 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;
@ -317,6 +314,10 @@ 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,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWKEYOPERATIONS_H
#define AWKEYOPERATIONS_H
#pragma once
#include <QObject>
@ -78,6 +76,3 @@ private:
QHash<QString, QStringList> m_devices;
QString m_pattern;
};
#endif /* AWKEYOPERATIONS_H */

View File

@ -103,6 +103,7 @@ 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);
@ -152,26 +153,6 @@ 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;
@ -201,12 +182,14 @@ void AWKeys::editItem(const QString &_type)
void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors, const KSysGuard::SensorDataList &_data)
{
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);
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);
}
}
@ -271,7 +254,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.0f * m_values["memmb"].toDouble() / m_values["memtotmb"].toDouble();
m_values["mem"] = 100.0 * 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());
@ -290,7 +273,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.0f * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
m_values["swap"] = 100.0 * m_values["swapmb"].toDouble() / m_values["swaptotmb"].toDouble();
// user defined keys
for (auto &key : m_keyOperator->userKeys())
@ -356,10 +339,9 @@ QString AWKeys::parsePattern(QString _pattern) const
}
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
const KSysGuard::SensorData &_data)
void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value)
{
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _data.payload;
qCDebug(LOG_AW) << "Source" << _source << _sensor.name << "with data" << _value;
// first list init
auto tags = m_aggregator->keysFromSource(_source);
@ -373,6 +355,6 @@ void AWKeys::setDataBySource(const QString &_source, const KSysGuard::SensorInfo
}
m_mutex.lock();
std::for_each(tags.cbegin(), tags.cend(), [this, &_data](const QString &tag) { m_values[tag] = _data.payload; });
std::for_each(tags.cbegin(), tags.cend(), [this, _value](const QString &tag) { m_values[tag] = _value; });
m_mutex.unlock();
}

View File

@ -15,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWKEYS_H
#define AWKEYS_H
#pragma once
#include <QMutex>
#include <QObject>
@ -48,22 +46,19 @@ 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();
@ -72,8 +67,7 @@ private:
void calculateValues();
void createDBusInterface();
[[nodiscard]] QString parsePattern(QString _pattern) const;
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor,
const KSysGuard::SensorData &_data);
void setDataBySource(const QString &_source, const KSysGuard::SensorInfo &_sensor, const QVariant &_value);
// objects
AWDataAggregator *m_dataAggregator = nullptr;
AWDataEngineAggregator *m_dataEngineAggregator = nullptr;
@ -90,6 +84,3 @@ private:
QThreadPool *m_threadPool = nullptr;
QMutex m_mutex;
};
#endif /* AWKEYS_H */

View File

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

View File

@ -15,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWKEYSAGGREGATOR_H
#define AWKEYSAGGREGATOR_H
#pragma once
#include <ksysguard/formatter/Unit.h>
@ -53,6 +51,7 @@ public:
ACFormat,
MemGBFormat,
MemMBFormat,
MemKBFormat,
NetSmartFormat,
NetSmartUnits,
Quotes,
@ -67,6 +66,10 @@ 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();
@ -83,10 +86,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]] float temperature(float temp) const;
[[nodiscard]] double temperature(double temp) const;
AWFormatterHelper *m_customFormatters = nullptr;
AWDataEngineMapper *m_mapper = nullptr;
QStringList m_timeKeys;
@ -98,6 +101,3 @@ 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,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWPAIRCONFIGFACTORY_H
#define AWPAIRCONFIGFACTORY_H
#pragma once
#include <QObject>
@ -34,6 +32,3 @@ public:
private:
};
#endif /* AWPAIRCONFIGFACTORY_H */

View File

@ -15,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWPATTERNFUNCTIONS_H
#define AWPATTERNFUNCTIONS_H
#pragma once
#include <QString>
#include <QVariant>
@ -47,6 +45,3 @@ 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, SIGNAL(finished(QNetworkReply *)), this, SLOT(telemetryReplyRecieved(QNetworkReply *)));
auto manager = new QNetworkAccessManager(nullptr);
connect(manager, &QNetworkAccessManager::finished, this, &AWTelemetryHandler::telemetryReplyReceived);
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
QByteArray data = QJsonDocument::fromVariant(payload).toJson(QJsonDocument::Compact);
auto 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::telemetryReplyRecieved(QNetworkReply *_reply)
void AWTelemetryHandler::telemetryReplyReceived(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::telemetryReplyRecieved(QNetworkReply *_reply)
}
QJsonParseError error{};
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
auto 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::telemetryReplyRecieved(QNetworkReply *_reply)
_reply->deleteLater();
// convert to map
QVariantMap response = jsonDoc.toVariant().toMap();
QString message = response["message"].toString();
auto response = jsonDoc.toVariant().toMap();
auto message = response["message"].toString();
qCInfo(LOG_AW) << "Server reply on telemetry" << message;
return emit(replyReceived(message));

View File

@ -15,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWTELEMETRYHANDLER_H
#define AWTELEMETRYHANDLER_H
#pragma once
#include <QObject>
@ -43,7 +41,7 @@ signals:
void replyReceived(const QString &_message);
private slots:
void telemetryReplyRecieved(QNetworkReply *_reply);
void telemetryReplyReceived(QNetworkReply *_reply);
private:
static QString getKey(int _count);
@ -52,6 +50,3 @@ 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 versionReplyRecieved(reply, _showAnyway); });
[_showAnyway, this](QNetworkReply *reply) { return versionReplyReceived(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);
QVersionNumber version = QVersionNumber::fromString(settings.value("Version", QString(VERSION)).toString());
auto 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;
QString text = i18n("You are using the actual version %1", _version.toString());
auto 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)
{
QMessageBox::ButtonRole ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
auto 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::versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway)
void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _showAnyway)
{
qCDebug(LOG_AW) << "Show message anyway" << _showAnyway;
if (_reply->error() != QNetworkReply::NoError) {
@ -134,8 +134,8 @@ void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply, const bool _sho
return;
}
QJsonParseError error = QJsonParseError();
QJsonDocument jsonDoc = QJsonDocument::fromJson(_reply->readAll(), &error);
auto error = QJsonParseError();
auto 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::versionReplyRecieved(QNetworkReply *_reply, const bool _sho
_reply->deleteLater();
// convert to map
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
QString version = firstRelease["tag_name"].toString();
auto firstRelease = jsonDoc.toVariant().toList().first().toMap();
auto version = firstRelease["tag_name"].toString();
version.remove("V.");
m_foundVersion = QVersionNumber::fromString(version);
qCInfo(LOG_AW) << "Update found version to" << m_foundVersion;
QVersionNumber oldVersion = QVersionNumber::fromString(VERSION);
auto 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,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWUPDATEHELPER_H
#define AWUPDATEHELPER_H
#pragma once
#include <QMessageBox>
#include <QObject>
@ -40,7 +38,7 @@ private slots:
static void showInfo(const QVersionNumber &_version);
void showUpdates(const QVersionNumber &_version);
void userReplyOnUpdates(QAbstractButton *_button);
void versionReplyRecieved(QNetworkReply *_reply, bool _showAnyway);
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
private:
static QMessageBox *genMessageBox(const QString &_title, const QString &_body,
@ -48,6 +46,3 @@ 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, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
disconnect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::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, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
connect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate);
}
@ -234,7 +234,7 @@ void AbstractExtItem::setName(const QString &_name)
void AbstractExtItem::setNumber(int _number)
{
qCDebug(LOG_LIB) << "Number" << _number;
bool generateNumber = (_number == -1);
auto 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, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
disconnect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
delete m_socket;
}
@ -278,9 +278,9 @@ void AbstractExtItem::initSocket()
deinitSocket();
m_socket = new QLocalServer(this);
bool listening = m_socket->listen(socket());
auto listening = m_socket->listen(socket());
qCInfo(LOG_LIB) << "Server listening on" << socket() << listening;
connect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
}
@ -303,7 +303,7 @@ void AbstractExtItem::readConfiguration()
bool AbstractExtItem::tryDelete() const
{
bool status = QFile::remove(m_fileName);
auto status = QFile::remove(m_fileName);
qCInfo(LOG_LIB) << "Remove file" << m_fileName << status;
return status;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,8 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef EXTITEMAGGREGATOR_H
#define EXTITEMAGGREGATOR_H
#pragma once
#include <KI18n/KLocalizedString>
@ -66,7 +65,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));
@ -78,7 +77,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();
}
@ -87,7 +86,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);
@ -104,7 +103,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);
@ -130,7 +129,7 @@ private:
auto dirs = directories();
for (auto &dir : dirs) {
QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
auto files = QDir(dir).entryList(QDir::Files, QDir::Name);
for (auto &file : files) {
// check filename
if (!file.endsWith(".desktop"))
@ -146,10 +145,7 @@ 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,9 +40,8 @@ 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, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
connect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
}
@ -50,8 +49,8 @@ ExtNetworkRequest::~ExtNetworkRequest()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
disconnect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
m_manager->deleteLater();
}

View File

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

View File

@ -46,9 +46,8 @@ 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, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtQuotes::quotesReplyReceived);
connect(this, &ExtQuotes::requestDataUpdate, this, &ExtQuotes::sendRequest);
}
@ -56,8 +55,8 @@ ExtQuotes::~ExtQuotes()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtQuotes::quotesReplyReceived);
disconnect(this, &ExtQuotes::requestDataUpdate, this, &ExtQuotes::sendRequest);
m_manager->deleteLater();
}

View File

@ -15,8 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef EXTQUOTES_H
#define EXTQUOTES_H
#pragma once
#include <QNetworkReply>
@ -61,6 +60,3 @@ 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, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
m_process->waitForFinished(0);
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
connect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
}
@ -51,10 +51,9 @@ 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, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
disconnect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
}
@ -227,11 +226,11 @@ void ExtScript::readJsonFilters()
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
QString jsonText = jsonFile.readAll();
auto jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;

View File

@ -15,8 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef EXTSCRIPT_H
#define EXTSCRIPT_H
#pragma once
#include <QProcess>
@ -76,6 +75,3 @@ 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, SIGNAL(finished(int)), this, SLOT(updateValue()));
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
m_process->waitForFinished(0);
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
connect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
}
@ -49,7 +49,7 @@ ExtUpgrade::~ExtUpgrade()
m_process->kill();
m_process->deleteLater();
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
disconnect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
}

View File

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

View File

@ -49,9 +49,8 @@ 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, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
connect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
}
@ -59,8 +58,8 @@ ExtWeather::~ExtWeather()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
disconnect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
m_manager->deleteLater();
}
@ -150,7 +149,7 @@ int ExtWeather::ts() const
QString ExtWeather::uniq() const
{
return QString("%1 (%2) at %3").arg(city()).arg(country()).arg(ts());
return QString("%1 (%2) at %3").arg(city(), country()).arg(ts());
}
@ -237,11 +236,11 @@ void ExtWeather::readJsonMap()
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
QString jsonText = jsonFile.readAll();
auto jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error{};
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;

View File

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

View File

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

View File

@ -15,8 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef GRAPHICALITEMHELPER_H
#define GRAPHICALITEMHELPER_H
#pragma once
#include <QColor>
#include <QObject>
@ -56,6 +55,3 @@ 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,8 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef OWMWEATHERPROVIDER_H
#define OWMWEATHERPROVIDER_H
#pragma once
#include "abstractweatherprovider.h"
@ -42,6 +41,3 @@ 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, SIGNAL(timeout()), this, SLOT(expired()));
connect(m_timer, &QTimer::timeout, this, &QCronScheduler::expired);
m_timer->start();
}

View File

@ -15,8 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef QCRONSCHEDULER_H
#define QCRONSCHEDULER_H
#pragma once
#include "QObject"
@ -58,6 +57,3 @@ 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.NASDAQ
Name=AAPL
Comment=Apple Inc
X-AW-Ticker="AAPL"
X-AW-Ticker="AAPL.US"
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.NASDAQ
Name=GOOG
Comment=Google Inc
X-AW-Ticker="GOOG"
X-AW-Ticker="GOOG.US"
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.NASDAQ
Name=MSFT
Comment=Microsoft Corp
X-AW-Ticker="MSFT"
X-AW-Ticker="MSFT.US"
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;
QStringList sourceValues = QString::fromUtf8(_source).trimmed().split(',');
auto 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() / price;
values[tag("percpricechg")] = 100.0 * values[tag("pricechg")].toDouble() / oldPrice;
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() / volume;
values[tag("percvolumechg")] = 100.0 * values[tag("volumechg")].toDouble() / oldVolume;
values[tag("volume")] = volume;
return values;

View File

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

View File

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

View File

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

View File

@ -16,27 +16,21 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.desktoppanel 1.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
Item {
KCM.SimpleKCM {
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,24 +16,14 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.desktoppanel 1.0
import "."
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
Item {
KCM.SimpleKCM {
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
@ -43,7 +33,6 @@ Item {
property alias cfg_currentTextStyleColor: selectStyleColor.value
property string cfg_currentTextStyle: textStyle.value
Column {
id: pageColumn
anchors.fill: parent
@ -99,9 +88,4 @@ Item {
value: plasmoid.configuration.currentTextStyleColor
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -17,23 +17,14 @@
import QtQuick 2.15
import QtQuick.Controls
import org.kde.kcmutils as KCM
import org.kde.plasma.private.desktoppanel 1.0
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
Item {
KCM.SimpleKCM {
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
@ -44,7 +35,6 @@ Item {
property alias cfg_tooltipWidth: tooltipWidth.value
property alias cfg_tooltipColor: tooltipColor.value
Column {
id: pageColumn
anchors.fill: parent
@ -82,48 +72,48 @@ Item {
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")
@ -144,16 +134,16 @@ Item {
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")
@ -178,8 +168,4 @@ Item {
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -16,24 +16,14 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.desktoppanel 1.0
import "."
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
Item {
KCM.SimpleKCM {
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
@ -43,7 +33,6 @@ Item {
property alias cfg_textStyleColor: selectStyleColor.value
property string cfg_textStyle: textStyle.value
Column {
id: pageColumn
anchors.fill: parent
@ -99,9 +88,4 @@ Item {
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.private.desktoppanel 1.0
import "."
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
PlasmoidItem {
@ -32,7 +32,6 @@ PlasmoidItem {
id: dpAdds
}
property bool debug: dpAdds.isDebugEnabled()
property variant tooltipSettings: {
"tooltipColor": plasmoid.configuration.tooltipColor,
"tooltipType": plasmoid.configuration.tooltipType,
@ -43,14 +42,12 @@ 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
@ -97,7 +94,6 @@ PlasmoidItem {
}
}
Timer {
id: timer
interval: 1000
@ -105,19 +101,16 @@ PlasmoidItem {
}
onNeedUpdate: {
if (debug) console.debug()
for (var i=0; i<repeater.count; i++) {
for (let 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]
@ -125,7 +118,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]
@ -139,13 +132,11 @@ PlasmoidItem {
}
onNeedTooltipUpdate: {
if (debug) console.debug()
for (var i=0; i<repeater.count; i++) {
for (let 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
}
@ -153,11 +144,9 @@ PlasmoidItem {
}
onSizeUpdate: {
if (debug) console.debug()
if (plasmoid.configuration.height == 0) {
var newHeight = 0
for (var i=0; i<repeater.count; i++)
if (plasmoid.configuration.height === 0) {
let newHeight = 0
for (let i = 0; i < repeater.count; i++)
newHeight += repeater.itemAt(i).contentHeight
Layout.minimumHeight = newHeight
Layout.maximumHeight = -1
@ -165,9 +154,9 @@ PlasmoidItem {
Layout.minimumHeight = plasmoid.configuration.height
Layout.maximumHeight = plasmoid.configuration.height
}
if (plasmoid.configuration.width == 0) {
var newWidth = 0
for (var i=0; i<repeater.count; i++)
if (plasmoid.configuration.width === 0) {
let newWidth = 0
for (let i = 0; i < repeater.count; i++)
newWidth += repeater.itemAt(i).contentWidth
Layout.minimumWidth = newWidth
Layout.maximumWidth = -1
@ -179,7 +168,6 @@ PlasmoidItem {
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.debug()
dpAdds.setMark(plasmoid.configuration.mark)
dpAdds.setToolTipData(tooltipSettings)
@ -188,8 +176,6 @@ PlasmoidItem {
}
Component.onCompleted: {
if (debug) console.debug()
// init submodule
Plasmoid.userConfiguringChanged(false)
dpAdds.desktopChanged.connect(needUpdate)

View File

@ -1,27 +0,0 @@
# 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,28 +16,21 @@
***************************************************************************/
import QtQuick 2.15
import org.kde.kcmutils as KCM
import org.kde.plasma.private.desktoppanel 1.0
import "."
import org.kde.plasma.awesomewidgets
import org.kde.plasma.private.desktoppanel
Item {
KCM.SimpleKCM {
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
@ -60,9 +53,4 @@ Item {
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": "3.5.1",
"Version": "4.0.0",
"Website": "https://arcanis.me/projects/awesome-widgets/"
},
"X-Plasma-API-Minimum-Version": "6.0"

View File

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

View File

@ -49,9 +49,7 @@ DPAdds::DPAdds(QObject *_parent)
m_vdi = new TaskManager::VirtualDesktopInfo(this);
m_taskModel = new TaskManager::WindowTasksModel(this);
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()));
connect(m_vdi, &TaskManager::VirtualDesktopInfo::currentDesktopChanged, this, &DPAdds::desktopChanged);
}
@ -64,13 +62,6 @@ 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();
@ -120,8 +111,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,9 +15,7 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef DPADDS_H
#define DPADDS_H
#pragma once
// ui library required by WId definition
#include <QGuiApplication>
@ -46,7 +44,6 @@ 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;
@ -79,6 +76,3 @@ private:
QString m_tooltipColor = "#000000";
QString m_tooltipType = "none";
};
#endif /* DPADDS_H */

View File

@ -27,8 +27,6 @@
#include "awdebug.h"
#include "extsysmonaggregator.h"
#include "gpuloadsource.h"
#include "hddtempsource.h"
ExtendedSysMon::ExtendedSysMon(QObject *_parent, const QVariantList &_args)
@ -53,9 +51,6 @@ 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();
@ -71,31 +66,6 @@ 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