mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
realize keys methods
This commit is contained in:
parent
213595b3c1
commit
3a0cbee39f
23
sources/.kdev4/sources.kdev4
Normal file
23
sources/.kdev4/sources.kdev4
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[Buildset]
|
||||||
|
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00a\x00w\x00e\x00s\x00o\x00m\x00e\x00-\x00w\x00i\x00d\x00g\x00e\x00t\x00s)
|
||||||
|
|
||||||
|
[CMake]
|
||||||
|
Build Directory Count=1
|
||||||
|
Current Build Directory Index=0
|
||||||
|
ProjectRootRelative=./
|
||||||
|
|
||||||
|
[CMake][CMake Build Directory 0]
|
||||||
|
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
|
||||||
|
Build Type=Debug
|
||||||
|
CMake Binary=file:///usr/bin/cmake
|
||||||
|
Environment Profile=
|
||||||
|
Extra Arguments=
|
||||||
|
Install Directory=
|
||||||
|
|
||||||
|
[Defines And Includes][Compiler]
|
||||||
|
Name=GCC
|
||||||
|
Path=gcc
|
||||||
|
Type=GCC
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
VersionControlSupport=kdevgit
|
@ -0,0 +1,29 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
import org.kde.plasma.configuration 2.0
|
||||||
|
|
||||||
|
|
||||||
|
ConfigModel {
|
||||||
|
// ConfigCategory {
|
||||||
|
// name: i18n("Widget")
|
||||||
|
// icon: "utilities-system-monitor"
|
||||||
|
// source: "widget.qml"
|
||||||
|
// }
|
||||||
|
}
|
143
sources/awesome-widget-kf5/package/contents/config/main.xml
Normal file
143
sources/awesome-widget-kf5/package/contents/config/main.xml
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||||
|
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||||
|
<kcfgfile name=""/>
|
||||||
|
|
||||||
|
<group name="Widget">
|
||||||
|
<!-- widget -->
|
||||||
|
<entry name="text" type="string">
|
||||||
|
<default>[cpu: $cpu%] [mem: $mem%] [swap: $swap%] [$netdev: $down/$upKB/s]</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group name="Advanced">
|
||||||
|
<!-- advanced -->
|
||||||
|
<entry name="background" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="popup" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="customTime" type="string">
|
||||||
|
<default>$hh:$mm</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="customUptime" type="string">
|
||||||
|
<default>$dd,$hh,$mm</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="tempUnits" type="string">
|
||||||
|
<default>Celsius</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="tempDevice" type="string">
|
||||||
|
<default></default>
|
||||||
|
</entry>
|
||||||
|
<entry name="fanDevice" type="string">
|
||||||
|
<default></default>
|
||||||
|
</entry>
|
||||||
|
<entry name="mount" type="string">
|
||||||
|
<default>/</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="hdd" type="string">
|
||||||
|
<default>/dev/sda</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="disk" type="string">
|
||||||
|
<default>disk/sda_(8:0)</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="customNetdev" type="string">
|
||||||
|
<default></default>
|
||||||
|
</entry>
|
||||||
|
<entry name="acOnline" type="string">
|
||||||
|
<default>(*)</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="acOffline" type="string">
|
||||||
|
<default>( )</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="checkUpdates" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group name="Tooltip">
|
||||||
|
<entry name="tooltipNumber" type="int">
|
||||||
|
<default>100</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="useTooltipBackground" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="tooltipBackgroung" type="string">
|
||||||
|
<default>#ffffff</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="cpuTooltip" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="cpuTooltipColor" type="string">
|
||||||
|
<default>#ff0000</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="cpuclTooltip" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="cpuclTooltipColor" type="string">
|
||||||
|
<default>#00ff00</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="memTooltip" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="memTooltipColor" type="string">
|
||||||
|
<default>#0000ff</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="swapTooltip" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="swapTooltipColor" type="string">
|
||||||
|
<default>#ffff00</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="downTooltip" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="downTooltipColor" type="string">
|
||||||
|
<default>#00ffff</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="upTooltip" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="upTooltipColor" type="string">
|
||||||
|
<default>#ff00ff</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="batteryTooltip" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="batteryTooltipColor" type="string">
|
||||||
|
<default>#008800</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="batteryInTooltipColor" type="string">
|
||||||
|
<default>#880000</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<group name="Appearance">
|
||||||
|
<!-- appearance -->
|
||||||
|
<entry name="interval" type="int">
|
||||||
|
<default>1000</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="textAlign" type="string">
|
||||||
|
<default>center</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="fontFamily" type="string">
|
||||||
|
<default>Terminus</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="fontSize" type="int">
|
||||||
|
<default>12</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="fontColor" type="string">
|
||||||
|
<default>#000000</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="fontWeight" type="string">
|
||||||
|
<default>normal</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="fontStyle" type="string">
|
||||||
|
<default>normal</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
</kcfg>
|
140
sources/awesome-widget-kf5/package/contents/ui/main.qml
Normal file
140
sources/awesome-widget-kf5/package/contents/ui/main.qml
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
import QtQuick 2.4
|
||||||
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
|
import org.kde.plasma.plasmoid 2.0
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
|
import org.kde.plasma.private.awesome-widget 1.0
|
||||||
|
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: main
|
||||||
|
|
||||||
|
// variables
|
||||||
|
// internal
|
||||||
|
property bool debug: AWKeys.isDebugEnabled()
|
||||||
|
property variant fontWeight: {
|
||||||
|
"light": Font.Light,
|
||||||
|
"normal": Font.Normal,
|
||||||
|
"demibold": Font.DemiBold,
|
||||||
|
"bold": Font.Bold,
|
||||||
|
"black": Font.Black
|
||||||
|
}
|
||||||
|
property variant align: {
|
||||||
|
"left": Text.AlignLeft,
|
||||||
|
"center": Text.AlignHCenter,
|
||||||
|
"right": Text.AlignRight,
|
||||||
|
"justify": Text.AlignJustify
|
||||||
|
}
|
||||||
|
// external
|
||||||
|
property variant info: {
|
||||||
|
}
|
||||||
|
property string pattern: plasmoid.configuration.text
|
||||||
|
// signals
|
||||||
|
signal needUpdate
|
||||||
|
|
||||||
|
// init
|
||||||
|
Plasmoid.icon: "utilities-system-monitor"
|
||||||
|
Plasmoid.backgroundHints: "DefaultBackground"
|
||||||
|
Plasmoid.toolTipMainText: "Awesome Widget"
|
||||||
|
Plasmoid.associatedApplication: "ksysguard"
|
||||||
|
|
||||||
|
PlasmaCore.DataSource {
|
||||||
|
id: systemmonitorDE
|
||||||
|
engine: "systemmonitor"
|
||||||
|
connectedSources: ["active", "current", "extip4", "extip6", "interfaces", "intip4", "intip6", "profiles", "status"]
|
||||||
|
interval: plasmoid.configuration.interval
|
||||||
|
|
||||||
|
onNewData: {
|
||||||
|
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||||
|
|
||||||
|
if ((data.value == "N\\A") || (data.value == "")) return
|
||||||
|
// update
|
||||||
|
info[sourceName] = data.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlasmaCore.DataSource {
|
||||||
|
id: extsysmonDE
|
||||||
|
engine: "ext-sysmon"
|
||||||
|
connectedSources: ["update"]
|
||||||
|
interval: plasmoid.configuration.interval
|
||||||
|
|
||||||
|
onNewData: {
|
||||||
|
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||||
|
|
||||||
|
if (sourceName == "update") needUpdate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ui
|
||||||
|
Grid {
|
||||||
|
id: mainGrid
|
||||||
|
columns: 1
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: text
|
||||||
|
color: plasmoid.configuration.fontColor
|
||||||
|
font.family: plasmoid.configuration.fontFamily
|
||||||
|
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
|
||||||
|
font.pointSize: plasmoid.configuration.fontSize
|
||||||
|
font.weight: fontWeight[plasmoid.configuration.fontWeight]
|
||||||
|
horizontalAlignment: align[plasmoid.configuration.textAlign]
|
||||||
|
textFormat: Text.RichText
|
||||||
|
text: plasmoid.configuration.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (debug) console.log("[main::onCompleted]")
|
||||||
|
|
||||||
|
// actions
|
||||||
|
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
|
||||||
|
plasmoid.setAction("updateText", i18n("Update text"), "stock-refresh")
|
||||||
|
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
|
||||||
|
}
|
||||||
|
|
||||||
|
onNeedUpdate: {
|
||||||
|
if (debug) console.log("[main::onNeedUpdate]")
|
||||||
|
|
||||||
|
text.text = AWKeys.parsePattern(pattern, info)
|
||||||
|
// update geometry
|
||||||
|
text.update()
|
||||||
|
height = text.contentHeight
|
||||||
|
width = text.contentWidth
|
||||||
|
update()
|
||||||
|
}
|
||||||
|
|
||||||
|
function action_checkUpdates() {
|
||||||
|
if (debug) console.log("[main::action_checkUpdates]")
|
||||||
|
|
||||||
|
AWActions.checkUpdates()
|
||||||
|
}
|
||||||
|
|
||||||
|
function action_showReadme() {
|
||||||
|
if (debug) console.log("[main::action_showReadme]")
|
||||||
|
|
||||||
|
AWActions.showReadme()
|
||||||
|
}
|
||||||
|
|
||||||
|
function action_updateText() {
|
||||||
|
if (debug) console.log("[main::action_updateText]")
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
[Dolphin]
|
|
||||||
Timestamp=2015,1,19,23,14,34
|
|
||||||
Version=3
|
|
@ -173,7 +173,7 @@ void AWActions::showUpdates(QString version)
|
|||||||
text += i18n("Click \"Ok\" to download");
|
text += i18n("Click \"Ok\" to download");
|
||||||
|
|
||||||
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
switch(select) {
|
switch (select) {
|
||||||
case QMessageBox::Ok:
|
case QMessageBox::Ok:
|
||||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||||
break;
|
break;
|
||||||
|
203
sources/awesome-widget-kf5/plugin/awdesources.cpp
Normal file
203
sources/awesome-widget-kf5/plugin/awdesources.cpp
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "awdesources.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QProcessEnvironment>
|
||||||
|
#include <QRegExp>
|
||||||
|
|
||||||
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
|
|
||||||
|
AWDESources::AWDESources(QObject *parent, const QString pattern,
|
||||||
|
const QStringList foundKeys,
|
||||||
|
const QStringList foundBars,
|
||||||
|
const QMap<QString, QVariant> counts,
|
||||||
|
const QMap<QString, QVariant> paths,
|
||||||
|
const QMap<QString, QVariant> tooltipBools)
|
||||||
|
: QObject(parent),
|
||||||
|
m_pattern(pattern),
|
||||||
|
m_foundKeys(foundKeys),
|
||||||
|
m_foundBars(foundBars),
|
||||||
|
m_counts(counts),
|
||||||
|
m_paths(paths),
|
||||||
|
m_tooltipBools(tooltipBools)
|
||||||
|
{
|
||||||
|
// debug
|
||||||
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||||
|
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||||
|
debug = (debugEnv == QString("yes"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AWDESources::~AWDESources()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWDESources::getSourcesForExtSystemMonitor()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
QRegExp regExp;
|
||||||
|
|
||||||
|
// battery
|
||||||
|
regExp = QRegExp(QString("(^|bar[0-9].*)(ac|bat.*)"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_foundBars.indexOf(regExp) > -1) ||
|
||||||
|
(m_tooltipBools[QString("batteryTooltip")].toBool()))
|
||||||
|
sources.append(QString("battery"));
|
||||||
|
// custom command
|
||||||
|
regExp = QRegExp(QString("custom.*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("custom"));
|
||||||
|
// desktop
|
||||||
|
regExp = QRegExp(QString(".*desktop.*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("desktop"));
|
||||||
|
// gpu
|
||||||
|
regExp = QRegExp(QString("(^|bar[0-9].*)gpu"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_foundBars.indexOf(regExp) > -1))
|
||||||
|
sources.append(QString("gpu"));
|
||||||
|
// gpu temp
|
||||||
|
regExp = QRegExp(QString("gputemp"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("gputemp"));
|
||||||
|
// hdd temp
|
||||||
|
regExp = QRegExp(QString("hddtemp.*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("hddtemp"));
|
||||||
|
// package manager
|
||||||
|
regExp = QRegExp(QString("pkgcount.*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("pkg"));
|
||||||
|
// player
|
||||||
|
regExp = QRegExp(QString("(album|artist|duration|progress|title)"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("player"));
|
||||||
|
// ps
|
||||||
|
regExp = QRegExp(QString("ps.*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("ps"));
|
||||||
|
// update == always true
|
||||||
|
sources.append(QString("update"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWDESources::getSourcesForSystemMonitor()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
QRegExp regExp;
|
||||||
|
|
||||||
|
// cpu
|
||||||
|
regExp = QRegExp(QString("(^|bar[0-9].*)cpu(?!cl).*"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_foundBars.indexOf(regExp) > -1) ||
|
||||||
|
(m_tooltipBools[QString("cpuTooltip")].toBool())) {
|
||||||
|
sources.append(QString("cpu/system/TotalLoad"));
|
||||||
|
for (int i=0; i<m_counts[QString("cpu")].toInt(); i++)
|
||||||
|
sources.append(QString("cpu/cpu") + QString::number(i) + QString("/TotalLoad"));
|
||||||
|
}
|
||||||
|
// cpuclock
|
||||||
|
regExp = QRegExp(QString("cpucl.*"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_foundBars.indexOf(regExp) > -1) ||
|
||||||
|
(m_tooltipBools[QString("cpuclTooltip")].toBool())) {
|
||||||
|
sources.append(QString("cpu/system/AverageClock"));
|
||||||
|
for (int i=0; i<m_counts[QString("cpu")].toInt(); i++)
|
||||||
|
sources.append(QString("cpu/cpu") + QString::number(i) + QString("/clock"));
|
||||||
|
}
|
||||||
|
// disk speed
|
||||||
|
regExp = QRegExp(QString("hdd[rw].*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
for (int i=0; i<m_paths[QString("disk")].toString().split(QString("@@")).count(); i++) {
|
||||||
|
sources.append(m_paths[QString("disk")].toString().split(QString("@@"))[i] + QString("/Rate/rblk"));
|
||||||
|
sources.append(m_paths[QString("disk")].toString().split(QString("@@"))[i] + QString("/Rate/wblk"));
|
||||||
|
}
|
||||||
|
// fan
|
||||||
|
regExp = QRegExp(QString("fan.*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(m_paths[QString("fanDevice")].toString().split(QString("@@")));
|
||||||
|
// mount
|
||||||
|
regExp = QRegExp(QString("(^|bar[0-9].*)hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb).*"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_foundBars.indexOf(regExp) > -1))
|
||||||
|
for (int i=0; i<m_paths[QString("mount")].toString().split(QString("@@")).count(); i++) {
|
||||||
|
sources.append(QString("partitions") + m_paths[QString("mount")].toString().split(QString("@@"))[i] + QString("/filllevel"));
|
||||||
|
sources.append(QString("partitions") + m_paths[QString("mount")].toString().split(QString("@@"))[i] + QString("/freespace"));
|
||||||
|
sources.append(QString("partitions") + m_paths[QString("mount")].toString().split(QString("@@"))[i] + QString("/usedspace"));
|
||||||
|
}
|
||||||
|
// memory
|
||||||
|
regExp = QRegExp(QString("(^|bar[0-9].*)mem.*"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_foundBars.indexOf(regExp) > -1) ||
|
||||||
|
(m_tooltipBools[QString("memTooltip")].toBool())) {
|
||||||
|
sources.append(QString("mem/physical/free"));
|
||||||
|
sources.append(QString("mem/physical/used"));
|
||||||
|
sources.append(QString("mem/physical/application"));
|
||||||
|
}
|
||||||
|
// network
|
||||||
|
regExp = QRegExp(QString("(down|up|netdev)"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_tooltipBools[QString("downTooltip")].toBool())) {
|
||||||
|
sources.append(QString("network/interfaces/") + m_paths[QString("netdev")].toString() + QString("/transmitter/data"));
|
||||||
|
sources.append(QString("network/interfaces/") + m_paths[QString("netdev")].toString() + QString("/receiver/data"));
|
||||||
|
}
|
||||||
|
// swap
|
||||||
|
regExp = QRegExp(QString("(^|bar[0-9].*)swap.*"));
|
||||||
|
if ((m_foundKeys.indexOf(regExp) > -1) ||
|
||||||
|
(m_foundBars.indexOf(regExp) > -1) ||
|
||||||
|
(m_paths[QString("swapTooltip")].toBool())) {
|
||||||
|
sources.append(QString("mem/swap/free"));
|
||||||
|
sources.append(QString("mem/swap/used"));
|
||||||
|
}
|
||||||
|
// temp
|
||||||
|
regExp = QRegExp(QString("temp.*"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(m_paths[QString("tempDevice")].toString().split(QString("@@")));
|
||||||
|
// uptime
|
||||||
|
regExp = QRegExp(QString("(^|c)uptime"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("system/uptime"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWDESources::getSourcesForTimeMonitor()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
QRegExp regExp;
|
||||||
|
|
||||||
|
// time
|
||||||
|
regExp = QRegExp(QString("(^|iso|short|long|c)time"));
|
||||||
|
if (m_foundKeys.indexOf(regExp) > -1)
|
||||||
|
sources.append(QString("Local"));
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
54
sources/awesome-widget-kf5/plugin/awdesources.h
Normal file
54
sources/awesome-widget-kf5/plugin/awdesources.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef AWDESOURCES_H
|
||||||
|
#define AWDESOURCES_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
|
class AWDESources : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AWDESources(QObject *parent = 0,
|
||||||
|
const QString pattern = QString(""),
|
||||||
|
const QStringList foundKeys = QStringList(),
|
||||||
|
const QStringList foundBars = QStringList(),
|
||||||
|
const QMap<QString, QVariant> counts = QMap<QString, QVariant>(),
|
||||||
|
const QMap<QString, QVariant> paths = QMap<QString, QVariant>(),
|
||||||
|
const QMap<QString, QVariant> tooltipBools = QMap<QString, QVariant>());
|
||||||
|
~AWDESources();
|
||||||
|
|
||||||
|
QStringList getSourcesForExtSystemMonitor();
|
||||||
|
QStringList getSourcesForSystemMonitor();
|
||||||
|
QStringList getSourcesForTimeMonitor();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// variables
|
||||||
|
bool debug = false;
|
||||||
|
QString m_pattern;
|
||||||
|
QStringList m_foundKeys, m_foundBars;
|
||||||
|
QMap<QString, QVariant> m_counts, m_paths, m_tooltipBools;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* AWDESOURCES_H */
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
|
#include "awdesources.h"
|
||||||
#include "extscript.h"
|
#include "extscript.h"
|
||||||
#include "graphicalitem.h"
|
#include "graphicalitem.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -133,13 +134,27 @@ QString AWKeys::parsePattern(const QString pattern, const QMap<QString, QVariant
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWKeys::sourcesForDataEngine(const QString pattern, const QString dataEngine)
|
QStringList AWKeys::sourcesForDataEngine(const QString pattern,
|
||||||
|
const QMap<QString, QVariant> paths,
|
||||||
|
const QMap<QString, QVariant> tooltipBools,
|
||||||
|
const QString dataEngine)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Pattern" << pattern;
|
if (debug) qDebug() << PDEBUG << ":" << "Pattern" << pattern;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "DataEngine" << dataEngine;
|
if (debug) qDebug() << PDEBUG << ":" << "DataEngine" << dataEngine;
|
||||||
|
|
||||||
|
AWDESources *deSources = new AWDESources(this, pattern, foundKeys, foundBars,
|
||||||
|
counts(), paths, tooltipBools);
|
||||||
|
|
||||||
QStringList sources;
|
QStringList sources;
|
||||||
|
if (dataEngine == QString("ext-sysmon"))
|
||||||
|
sources = deSources->getSourcesForExtSystemMonitor();
|
||||||
|
else if (dataEngine == QString("systemmonitor"))
|
||||||
|
sources = deSources->getSourcesForSystemMonitor();
|
||||||
|
else if (dataEngine == QString("time"))
|
||||||
|
sources = deSources->getSourcesForTimeMonitor();
|
||||||
|
delete deSources;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Sources" << sources;
|
||||||
|
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
Q_INVOKABLE int numberCpus();
|
Q_INVOKABLE int numberCpus();
|
||||||
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> values);
|
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> values);
|
||||||
Q_INVOKABLE QStringList sourcesForDataEngine(const QString pattern,
|
Q_INVOKABLE QStringList sourcesForDataEngine(const QString pattern,
|
||||||
|
const QMap<QString, QVariant> paths,
|
||||||
|
const QMap<QString, QVariant> tooltipBools,
|
||||||
const QString dataEngine = QString("systemmonitor"));
|
const QString dataEngine = QString("systemmonitor"));
|
||||||
Q_INVOKABLE float temperature(const float temp, const QString units = QString("Celsius"));
|
Q_INVOKABLE float temperature(const float temp, const QString units = QString("Celsius"));
|
||||||
// keys
|
// keys
|
||||||
|
3
sources/sources.kdev4
Normal file
3
sources/sources.kdev4
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[Project]
|
||||||
|
Manager=KDevCMakeManager
|
||||||
|
Name=awesome-widgets
|
Loading…
Reference in New Issue
Block a user