mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
add work with key cache
fix bug with invalid dataengine settings in UI
This commit is contained in:
parent
9a6b883905
commit
104bb52557
@ -34,7 +34,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
QtControls.TabView {
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
|
@ -69,7 +69,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
|
@ -49,7 +49,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
|
@ -57,7 +57,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
@ -105,11 +105,11 @@ Item {
|
||||
id: gpuDev
|
||||
width: parent.width * 3 / 5
|
||||
model: ["auto", "disable", "ati", "nvidia"]
|
||||
onCurrentIndexChanged: cfg_dataengine["GPUDEV"] = model[currentIndex]
|
||||
Component.onCompleted: {
|
||||
for (var i=0; i<model.length; i++) {
|
||||
console.log(cfg_dataengine["GPUDEV"])
|
||||
if (model[i] == cfg_dataengine["GPUDEV"]) {
|
||||
gpuDev.currentIndex = i;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,6 @@ Item {
|
||||
id: hdd
|
||||
width: parent.width * 3 / 5
|
||||
model: AWKeys.getHddDevices(true)
|
||||
onCurrentIndexChanged: cfg_dataengine["HDDDEV"] = model[currentIndex]
|
||||
Component.onCompleted: {
|
||||
for (var i=0; i<model.length; i++) {
|
||||
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
||||
@ -226,7 +225,6 @@ Item {
|
||||
id: player
|
||||
width: parent.width * 3 / 5
|
||||
model: ["mpris", "mpd"]
|
||||
onCurrentIndexChanged: cfg_dataengine["PLAYER"] = model[currentIndex]
|
||||
Component.onCompleted: {
|
||||
for (var i=0; i<model.length; i++) {
|
||||
if (model[i] == cfg_dataengine["PLAYER"]) {
|
||||
@ -282,6 +280,9 @@ Item {
|
||||
Component.onDestruction: {
|
||||
if (debug) console.log("[dataengine::onDestruction]")
|
||||
|
||||
cfg_dataengine["GPUDEV"] = gpuDev.currentText
|
||||
cfg_dataengine["HDDDEV"] = hdd.currentText
|
||||
cfg_dataengine["PLAYER"] = player.currentText
|
||||
cfg_dataengine["MPRIS"] = mpris.currentText
|
||||
AWActions.writeDataEngineConfiguration(cfg_dataengine)
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ Item {
|
||||
PlasmaCore.DataSource {
|
||||
id: extsysmonDE
|
||||
engine: "extsysmon"
|
||||
connectedSources: ["battery", "custom", "desktop", "netdev", "gpu",
|
||||
"gputemp", "hddtemp", "pkg", "player", "ps", "update"]
|
||||
connectedSources: ["battery", "custom", "desktop", "netdev", "gpu", "gputemp",
|
||||
"hddtemp", "quotes", "pkg", "player", "ps", "update"]
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onNewData: {
|
||||
@ -171,7 +171,7 @@ Item {
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
|
||||
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
||||
text.text = AWKeys.parsePattern()
|
||||
tooltip.text = AWKeys.toolTipImage()
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
QtControls.Label {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
@ -63,7 +63,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
QtControls.Label {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
28
sources/awesome-widget-kf5/package/metadata.desktop
Normal file
28
sources/awesome-widget-kf5/package/metadata.desktop
Normal file
@ -0,0 +1,28 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Awesome Widget
|
||||
Comment=A minimalistic Plasmoid
|
||||
Comment[en]=A minimalistic Plasmoid
|
||||
Comment[es]=Un plasmoide minimalista
|
||||
Comment[es]=Un script Plasmoïde minimaliste
|
||||
Comment[pt_BR]=Um script Plasmoid
|
||||
Comment[ru]=Минималистичный плазмоид
|
||||
Comment[uk]=Мінімалістичний плазмоїд
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-Plasma-API=declarativeappletscript
|
||||
X-Plasma-MainScript=ui/main.qml
|
||||
X-Plasma-RemoteLocation=
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
|
||||
X-KDE-PluginInfo-Version=2.2.2
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
@ -28,6 +28,7 @@
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegExp>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QThread>
|
||||
|
||||
@ -39,7 +40,6 @@
|
||||
#include "extscript.h"
|
||||
#include "extupgrade.h"
|
||||
#include "graphicalitem.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
AWKeys::AWKeys(QObject *parent)
|
||||
@ -50,9 +50,6 @@ AWKeys::AWKeys(QObject *parent)
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
// signals
|
||||
connect(this, SIGNAL(sourceAdded(QString)), this, SLOT(addSource(QString)));
|
||||
|
||||
// init dialog
|
||||
dialog = new QDialog(nullptr);
|
||||
widgetDialog = new QListWidget(dialog);
|
||||
@ -88,7 +85,7 @@ AWKeys::~AWKeys()
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString pattern,
|
||||
void AWKeys::initKeys(const QString currentPattern,
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup)
|
||||
{
|
||||
@ -105,16 +102,18 @@ void AWKeys::initKeys(const QString pattern,
|
||||
if (toolTip != nullptr) delete toolTip;
|
||||
|
||||
// init
|
||||
pattern = currentPattern;
|
||||
extQuotes = getExtQuotes();
|
||||
extScripts = getExtScripts();
|
||||
extUpgrade = getExtUpgrade();
|
||||
graphicalItems = getGraphicalItems();
|
||||
keys = dictKeys();
|
||||
foundBars = findGraphicalItems(pattern);
|
||||
foundKeys = findKeys(pattern);
|
||||
// update network and hdd list
|
||||
addKeyToCache(QString("Hdd"));
|
||||
addKeyToCache(QString("Network"));
|
||||
loadKeysFromCache();
|
||||
reinitKeys();
|
||||
toolTip = new AWToolTip(this, tooltipParams);
|
||||
|
||||
ready = true;
|
||||
enablePopup = popup;
|
||||
}
|
||||
|
||||
@ -127,10 +126,10 @@ bool AWKeys::isDebugEnabled()
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::parsePattern(const QString pattern)
|
||||
QString AWKeys::parsePattern()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!ready) return pattern;
|
||||
if (keys.isEmpty()) return pattern;
|
||||
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
@ -149,7 +148,7 @@ QString AWKeys::toolTipImage()
|
||||
{
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!ready) return QString();
|
||||
if (keys.isEmpty()) return QString();
|
||||
|
||||
QPixmap tooltip = toolTip->image();
|
||||
QByteArray byteArray;
|
||||
@ -168,7 +167,7 @@ QSize AWKeys::toolTipSize()
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::addDevice(const QString source)
|
||||
void AWKeys::addDevice(const QString source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
@ -181,49 +180,15 @@ bool AWKeys::addDevice(const QString source)
|
||||
if (diskRegexp.indexIn(source) > -1) {
|
||||
QString device = source;
|
||||
device.remove(QString("/Rate/rblk"));
|
||||
diskDevices.append(device);
|
||||
} else if (fanRegexp.indexIn(source) > -1)
|
||||
fanDevices.append(source);
|
||||
else if (mountRegexp.indexIn(source) > -1) {
|
||||
addKeyToCache(QString("Disk"), device);
|
||||
} else if (fanRegexp.indexIn(source) > -1) {
|
||||
addKeyToCache(QString("Fan"), source);
|
||||
} else if (mountRegexp.indexIn(source) > -1) {
|
||||
QString device = source;
|
||||
device.remove(QString("partitions")).remove(QString("/filllevel"));
|
||||
mountDevices.append(device);
|
||||
} else if (tempRegexp.indexIn(source) > -1)
|
||||
tempDevices.append(source);
|
||||
|
||||
// check sources to be connected
|
||||
if ((source.endsWith(QString("/TotalLoad"))) ||
|
||||
(source.endsWith(QString("/clock"))) ||
|
||||
(source.endsWith(QString("/AverageClock"))) ||
|
||||
(source.endsWith(QString("/Rate/rblk"))) ||
|
||||
(source.endsWith(QString("/Rate/wblk"))) ||
|
||||
(source.endsWith(QString("/filllevel"))) ||
|
||||
(source.endsWith(QString("/freespace"))) ||
|
||||
(source.endsWith(QString("/usedspace"))) ||
|
||||
(source.endsWith(QString("/receiver/data"))) ||
|
||||
(source.endsWith(QString("/receiver/data"))) ||
|
||||
(source.endsWith(QString("/transmitter/data"))) ||
|
||||
(source.startsWith(QString("lmsensors/"))) ||
|
||||
(source.startsWith(QString("mem/physical/"))) ||
|
||||
(source.startsWith(QString("mem/swap/"))) ||
|
||||
(source == QString("system/uptime")) ||
|
||||
(source == QString("Local")) ||
|
||||
(source == QString("battery")) ||
|
||||
(source == QString("custom")) ||
|
||||
(source == QString("desktop")) ||
|
||||
(source == QString("netdev")) ||
|
||||
(source == QString("gpu")) ||
|
||||
(source == QString("gputemp")) ||
|
||||
(source == QString("hddtemp")) ||
|
||||
(source == QString("pkg")) ||
|
||||
(source == QString("player")) ||
|
||||
(source == QString("ps")) ||
|
||||
(source == QString("update"))) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source << "not found";
|
||||
return false;
|
||||
addKeyToCache(QString("Mount"), device);
|
||||
} else if (tempRegexp.indexIn(source) > -1) {
|
||||
addKeyToCache(QString("Temp"), source);
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,12 +258,12 @@ QStringList AWKeys::dictKeys()
|
||||
allKeys.append(QString("hddw%1").arg(i));
|
||||
}
|
||||
// hdd temp
|
||||
for (int i=getHddDevices().count()-1; i>=0; i--) {
|
||||
for (int i=hddDevices.count()-1; i>=0; i--) {
|
||||
allKeys.append(QString("hddtemp%1").arg(i));
|
||||
allKeys.append(QString("hddtemp%1").arg(i));
|
||||
}
|
||||
// network
|
||||
for (int i=getNetworkDevices().count()-1; i>=0; i--) {
|
||||
for (int i=networkDevices.count()-1; i>=0; i--) {
|
||||
allKeys.append(QString("down%1").arg(i));
|
||||
allKeys.append(QString("up%1").arg(i));
|
||||
}
|
||||
@ -351,79 +316,19 @@ QStringList AWKeys::dictKeys()
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getDiskDevices()
|
||||
QStringList AWKeys::getHddDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
diskDevices.sort();
|
||||
|
||||
return diskDevices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getFanDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
fanDevices.sort();
|
||||
|
||||
return fanDevices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getHddDevices(const bool needAbstract)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
|
||||
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
||||
for (int i=0; i<devices.count(); i++)
|
||||
devices[i] = QString("/dev/") + devices[i];
|
||||
devices.sort();
|
||||
|
||||
if (needAbstract) {
|
||||
devices.insert(0, QString("disable"));
|
||||
devices.insert(0, QString("auto"));
|
||||
}
|
||||
QStringList devices = hddDevices;
|
||||
// required by ui interface
|
||||
devices.insert(0, QString("disable"));
|
||||
devices.insert(0, QString("auto"));
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getMountDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
mountDevices.sort();
|
||||
|
||||
return mountDevices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getNetworkDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList interfaceList;
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++)
|
||||
interfaceList.append(rawInterfaceList[i].name());
|
||||
interfaceList.sort();
|
||||
|
||||
return interfaceList;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getTempDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
tempDevices.sort();
|
||||
|
||||
return tempDevices;
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params)
|
||||
@ -435,7 +340,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
|
||||
// checking
|
||||
if (!checkKeys(data)) return false;
|
||||
if (!ready) return false;
|
||||
if (keys.isEmpty()) return false;
|
||||
|
||||
// regular expressions
|
||||
QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad"));
|
||||
@ -523,7 +428,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
} else if (sourceName == QString("gpu")) {
|
||||
// gpu load
|
||||
// notification
|
||||
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("gpu")].toFloat() < 90.0))
|
||||
if ((data[QString("value")].toFloat() >= 75.0) && (values[QString("gpu")].toFloat() < 75.0))
|
||||
AWActions::sendNotification(QString("event"), i18n("High GPU load"), enablePopup);
|
||||
// value
|
||||
values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
@ -575,7 +480,6 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
}
|
||||
} else if (sourceName == QString("hddtemp")) {
|
||||
// hdd temperature
|
||||
QStringList hddDevices = getHddDevices();
|
||||
for (int i=0; i<data.keys().count(); i++)
|
||||
for (int j=0; j<hddDevices.count(); j++)
|
||||
if (hddDevices[j] == data.keys()[i]) {
|
||||
@ -621,7 +525,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
// download speed
|
||||
QString device = sourceName;
|
||||
device.remove(QString("network/interfaces/")).remove(QString("/receiver/data"));
|
||||
QStringList allNetworkDevices = getNetworkDevices();
|
||||
QStringList allNetworkDevices = networkDevices;
|
||||
for (int i=0; i<allNetworkDevices.count(); i++)
|
||||
if (allNetworkDevices[i] == device) {
|
||||
values[QString("down%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
@ -635,7 +539,7 @@ bool AWKeys::setDataBySource(const QString sourceName,
|
||||
// upload speed
|
||||
QString device = sourceName;
|
||||
device.remove(QString("network/interfaces/")).remove(QString("/transmitter/data"));
|
||||
QStringList allNetworkDevices = getNetworkDevices();
|
||||
QStringList allNetworkDevices = networkDevices;
|
||||
for (int i=0; i<allNetworkDevices.count(); i++)
|
||||
if (allNetworkDevices[i] == device) {
|
||||
values[QString("up%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
@ -769,9 +673,9 @@ QString AWKeys::infoByKey(QString key)
|
||||
else if (key.contains(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))))
|
||||
return QString("%1").arg(mountDevices[key.remove(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))).toInt()]);
|
||||
else if (key.startsWith(QString("hddtemp")))
|
||||
return QString("%1").arg(getHddDevices()[key.remove(QString("hddtemp")).toInt()]);
|
||||
return QString("%1").arg(hddDevices[key.remove(QString("hddtemp")).toInt()]);
|
||||
else if (key.contains(QRegExp(QString("^(down|up)[0-9]"))))
|
||||
return QString("%1").arg(getNetworkDevices()[key.remove(QRegExp(QString("^(down|up)"))).toInt()]);
|
||||
return QString("%1").arg(networkDevices[key.remove(QRegExp(QString("^(down|up)"))).toInt()]);
|
||||
else if (key.startsWith(QString("pkgcount")))
|
||||
return QString("%1").arg(extUpgrade[key.remove(QString("pkgcount")).toInt()]->executable());
|
||||
else if ((key.startsWith(QString("ask"))) ||
|
||||
@ -852,11 +756,66 @@ void AWKeys::editItem(const QString type)
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::addSource()
|
||||
void AWKeys::loadKeysFromCache()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cache file" << fileName;
|
||||
QSettings cache(fileName, QSettings::IniFormat);
|
||||
QStringList cachedKeys;
|
||||
|
||||
cache.beginGroup(QString("Disk"));
|
||||
diskDevices.clear();
|
||||
cachedKeys = cache.allKeys();
|
||||
for (int i=0; i<cachedKeys.count(); i++)
|
||||
diskDevices.append(cache.value(cachedKeys[i]).toString());
|
||||
cache.endGroup();
|
||||
|
||||
cache.beginGroup(QString("Fan"));
|
||||
fanDevices.clear();
|
||||
cachedKeys = cache.allKeys();
|
||||
for (int i=0; i<cachedKeys.count(); i++)
|
||||
fanDevices.append(cache.value(cachedKeys[i]).toString());
|
||||
cache.endGroup();
|
||||
|
||||
cache.beginGroup(QString("Hdd"));
|
||||
hddDevices.clear();
|
||||
cachedKeys = cache.allKeys();
|
||||
for (int i=0; i<cachedKeys.count(); i++)
|
||||
hddDevices.append(cache.value(cachedKeys[i]).toString());
|
||||
cache.endGroup();
|
||||
|
||||
cache.beginGroup(QString("Mount"));
|
||||
mountDevices.clear();
|
||||
cachedKeys = cache.allKeys();
|
||||
for (int i=0; i<cachedKeys.count(); i++)
|
||||
mountDevices.append(cache.value(cachedKeys[i]).toString());
|
||||
cache.endGroup();
|
||||
|
||||
cache.beginGroup(QString("Network"));
|
||||
networkDevices.clear();
|
||||
cachedKeys = cache.allKeys();
|
||||
for (int i=0; i<cachedKeys.count(); i++)
|
||||
networkDevices.append(cache.value(cachedKeys[i]).toString());
|
||||
cache.endGroup();
|
||||
|
||||
cache.beginGroup(QString("Temp"));
|
||||
tempDevices.clear();
|
||||
cachedKeys = cache.allKeys();
|
||||
for (int i=0; i<cachedKeys.count(); i++)
|
||||
tempDevices.append(cache.value(cachedKeys[i]).toString());
|
||||
cache.endGroup();
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::reinitKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
keys = dictKeys();
|
||||
foundBars = findGraphicalItems();
|
||||
foundKeys = findKeys();
|
||||
}
|
||||
|
||||
|
||||
@ -1209,6 +1168,51 @@ void AWKeys::copyUpgrade(const QString original)
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::addKeyToCache(const QString type, const QString key)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Key type" << type;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cache file" << fileName;
|
||||
QSettings cache(fileName, QSettings::IniFormat);
|
||||
|
||||
cache.beginGroup(type);
|
||||
QStringList cachedValues;
|
||||
for (int i=0; i<cache.allKeys().count(); i++)
|
||||
cachedValues.append(cache.value(cache.allKeys()[i]).toString());
|
||||
|
||||
if (type == QString("Hdd")) {
|
||||
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
|
||||
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
||||
for (int i=0; i<devices.count(); i++) {
|
||||
QString device = QString("/dev/%1").arg(devices[i]);
|
||||
if (cachedValues.contains(devices[i])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
|
||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||
}
|
||||
} else if (type == QString("Network")) {
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++) {
|
||||
QString device = rawInterfaceList[i].name();
|
||||
if (cachedValues.contains(device)) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
|
||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||
}
|
||||
} else {
|
||||
if (cachedValues.contains(key)) return;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << key << "for type" << type;
|
||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
|
||||
}
|
||||
cache.endGroup();
|
||||
|
||||
cache.sync();
|
||||
loadKeysFromCache();
|
||||
return reinitKeys();
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::checkKeys(const QMap<QString, QVariant> data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -1269,7 +1273,7 @@ float AWKeys::temperature(const float temp, const QString units)
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::findGraphicalItems(const QString pattern)
|
||||
QStringList AWKeys::findGraphicalItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -1289,7 +1293,7 @@ QStringList AWKeys::findGraphicalItems(const QString pattern)
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::findKeys(const QString pattern)
|
||||
QStringList AWKeys::findKeys()
|
||||
{
|
||||
QStringList selectedKeys;
|
||||
for (int i=0; i<keys.count(); i++) {
|
||||
|
@ -51,22 +51,17 @@ public:
|
||||
AWKeys(QObject *parent = 0);
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE void initKeys(const QString pattern,
|
||||
Q_INVOKABLE void initKeys(const QString currentPattern,
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup = false);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||
Q_INVOKABLE QString parsePattern();
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
Q_INVOKABLE QSize toolTipSize();
|
||||
// keys
|
||||
Q_INVOKABLE bool addDevice(const QString source);
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList getDiskDevices();
|
||||
Q_INVOKABLE QStringList getFanDevices();
|
||||
Q_INVOKABLE QStringList getHddDevices(const bool needAbstract = false);
|
||||
Q_INVOKABLE QStringList getMountDevices();
|
||||
Q_INVOKABLE QStringList getNetworkDevices();
|
||||
Q_INVOKABLE QStringList getTempDevices();
|
||||
Q_INVOKABLE QStringList getHddDevices();
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params);
|
||||
@ -77,11 +72,9 @@ public:
|
||||
// configuration
|
||||
Q_INVOKABLE void editItem(const QString type);
|
||||
|
||||
signals:
|
||||
void sourceAdded(const QString source);
|
||||
|
||||
private slots:
|
||||
void addSource(const QString source);
|
||||
void loadKeysFromCache();
|
||||
void reinitKeys();
|
||||
// editor
|
||||
void editItemButtonPressed(QAbstractButton *button);
|
||||
void copyBar(const QString original);
|
||||
@ -91,13 +84,14 @@ private slots:
|
||||
|
||||
private:
|
||||
// methods
|
||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||
bool checkKeys(const QMap<QString, QVariant> data);
|
||||
QString networkDevice();
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units = QString("Celsius"));
|
||||
float temperature(const float temp, const QString units);
|
||||
// find methods
|
||||
QStringList findGraphicalItems(const QString pattern);
|
||||
QStringList findKeys(const QString pattern);
|
||||
QStringList findGraphicalItems();
|
||||
QStringList findKeys();
|
||||
// get methods
|
||||
QList<ExtQuotes *> getExtQuotes();
|
||||
QList<ExtScript *> getExtScripts();
|
||||
@ -117,14 +111,14 @@ private:
|
||||
// variables
|
||||
bool debug = false;
|
||||
bool enablePopup = false;
|
||||
bool ready = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtQuotes *> extQuotes;
|
||||
QList<ExtScript *> extScripts;
|
||||
QList<ExtUpgrade *> extUpgrade;
|
||||
QStringList foundBars, foundKeys, keys;
|
||||
QString pattern;
|
||||
QMap<QString, QString> values;
|
||||
QStringList diskDevices, fanDevices, mountDevices, tempDevices;
|
||||
QStringList diskDevices, fanDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,126 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 AWKEYS_H
|
||||
#define AWKEYS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QListWidget>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QPushButton>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class ExtQuotes;
|
||||
class ExtScript;
|
||||
class ExtUpgrade;
|
||||
class GraphicalItem;
|
||||
|
||||
class AWKeysOperations : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum RequestedItem {
|
||||
Nothing,
|
||||
RequestedGraphicalItem,
|
||||
RequestedExtQuotes,
|
||||
RequestedExtScript,
|
||||
RequestedExtUpgrade
|
||||
};
|
||||
typedef struct {
|
||||
QString key = QString();
|
||||
QString value = QString();
|
||||
} AWStruct;
|
||||
|
||||
public:
|
||||
AWKeysOperations(QObject *parent = 0);
|
||||
~AWKeysOperations();
|
||||
|
||||
// keys
|
||||
AWStruct addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList getDiskDevices();
|
||||
Q_INVOKABLE QStringList getFanDevices();
|
||||
Q_INVOKABLE QStringList getHddDevices(const bool needAbstract = false);
|
||||
Q_INVOKABLE QStringList getMountDevices();
|
||||
Q_INVOKABLE QStringList getNetworkDevices();
|
||||
Q_INVOKABLE QStringList getTempDevices();
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params);
|
||||
// values
|
||||
Q_INVOKABLE void graphicalValueByKey();
|
||||
Q_INVOKABLE QString infoByKey(QString key);
|
||||
Q_INVOKABLE QString valueByKey(QString key);
|
||||
// configuration
|
||||
Q_INVOKABLE void editItem(const QString type);
|
||||
|
||||
signals:
|
||||
void sourceAdded(const QString source);
|
||||
|
||||
private slots:
|
||||
void addSource(const QString source);
|
||||
// editor
|
||||
void editItemButtonPressed(QAbstractButton *button);
|
||||
void copyBar(const QString original);
|
||||
void copyQuotes(const QString original);
|
||||
void copyScript(const QString original);
|
||||
void copyUpgrade(const QString original);
|
||||
|
||||
private:
|
||||
// methods
|
||||
bool checkKeys(const QMap<QString, QVariant> data);
|
||||
QString networkDevice();
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units = QString("Celsius"));
|
||||
// find methods
|
||||
QStringList findGraphicalItems(const QString pattern);
|
||||
QStringList findKeys(const QString pattern);
|
||||
// get methods
|
||||
QList<ExtQuotes *> getExtQuotes();
|
||||
QList<ExtScript *> getExtScripts();
|
||||
QList<ExtUpgrade *> getExtUpgrade();
|
||||
QList<GraphicalItem *> getGraphicalItems();
|
||||
GraphicalItem *getItemByTag(const QString tag);
|
||||
QStringList getTimeKeys();
|
||||
// graphical elements
|
||||
QDialog *dialog = nullptr;
|
||||
QListWidget *widgetDialog = nullptr;
|
||||
QDialogButtonBox *dialogButtons = nullptr;
|
||||
QPushButton *copyButton = nullptr;
|
||||
QPushButton *createButton = nullptr;
|
||||
QPushButton *deleteButton = nullptr;
|
||||
RequestedItem requestedItem = Nothing;
|
||||
// variables
|
||||
bool debug = false;
|
||||
bool enablePopup = false;
|
||||
bool ready = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtQuotes *> extQuotes;
|
||||
QList<ExtScript *> extScripts;
|
||||
QList<ExtUpgrade *> extUpgrade;
|
||||
QStringList foundBars, foundKeys, keys;
|
||||
QMap<QString, QString> values;
|
||||
QStringList diskDevices, fanDevices, mountDevices, tempDevices;
|
||||
};
|
||||
|
||||
|
||||
#endif /* AWKEYS_H */
|
28
sources/desktop-panel-kf5/package/metadata.desktop
Normal file
28
sources/desktop-panel-kf5/package/metadata.desktop
Normal file
@ -0,0 +1,28 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Desktop Panel
|
||||
Comment=A minimalistic Plasmoid
|
||||
Comment[en]=A minimalistic Plasmoid
|
||||
Comment[es]=Un plasmoide minimalista
|
||||
Comment[es]=Un script Plasmoïde minimaliste
|
||||
Comment[pt_BR]=Um script Plasmoid
|
||||
Comment[ru]=Минималистичный плазмоид
|
||||
Comment[uk]=Мінімалістичний плазмоїд
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
Type=Service
|
||||
Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-Plasma-API=declarativeappletscript
|
||||
X-Plasma-MainScript=ui/main.qml
|
||||
X-Plasma-RemoteLocation=
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=org.kde.plasma.desktoppanel
|
||||
X-KDE-PluginInfo-Version=2.2.2
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=AAPL.NASDAQ
|
||||
Comment=Apple Inc
|
||||
X-AW-Ticker=AAPL
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=EUR/RUB
|
||||
Comment=EUR/RUB
|
||||
X-AW-Ticker=EURRUB=X
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=EUR/USD
|
||||
Comment=EUR/USD
|
||||
X-AW-Ticker=EURUSD=X
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=GOOG.NASDAQ
|
||||
Comment=Google Inc
|
||||
X-AW-Ticker=GOOG
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=MSFT.NASDAQ
|
||||
Comment=Microsoft Corp
|
||||
X-AW-Ticker=MSFT
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=RTS
|
||||
Comment=RTS Index
|
||||
X-AW-Ticker=RTS.RS
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=S&P
|
||||
Comment=S&P 500 Index
|
||||
X-AW-Ticker=^GSPC
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=USD/RUB
|
||||
Comment=USD/RUB
|
||||
X-AW-Ticker=USDRUB=X
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
@ -3,6 +3,6 @@ Encoding=UTF-8
|
||||
Name=VIX
|
||||
Comment=Volatility S&P 500
|
||||
X-AW-Ticker=^VIX
|
||||
X-AW-Active=true
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-Interval=60
|
||||
|
Loading…
Reference in New Issue
Block a user