mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-16 07:09:58 +00:00
move back desktop files
add widget configuration append plugin slots rewrite KF5 and DE to use ExtUpgrade class some fixes
This commit is contained in:
@ -21,9 +21,9 @@ import org.kde.plasma.configuration 2.0
|
||||
|
||||
|
||||
ConfigModel {
|
||||
// ConfigCategory {
|
||||
// name: i18n("Widget")
|
||||
// icon: "utilities-system-monitor"
|
||||
// source: "widget.qml"
|
||||
// }
|
||||
ConfigCategory {
|
||||
name: i18n("Widget")
|
||||
icon: "utilities-system-monitor"
|
||||
source: "widget.qml"
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,12 @@ Item {
|
||||
if ((data.value == "N\\A") || (data.value == "")) return
|
||||
if (AWKeys.isReady()) AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
|
||||
onSourceAdded: {
|
||||
if (debug) console.log("[main::onSourceAdded] : Source " + source)
|
||||
|
||||
AWActions.addDevice(source)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
|
223
sources/awesome-widget-kf5/package/contents/ui/widget.qml
Normal file
223
sources/awesome-widget-kf5/package/contents/ui/widget.qml
Normal file
@ -0,0 +1,223 @@
|
||||
/***************************************************************************
|
||||
* 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 QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
import QtQuick.Layouts 1.0 as QtLayouts
|
||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
|
||||
|
||||
Item {
|
||||
id: widgetPage
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
implicitWidth: pageColumn.implicitWidth
|
||||
implicitHeight: pageColumn.implicitHeight
|
||||
|
||||
property bool debug: AWKeys.isDebugEnabled()
|
||||
|
||||
property alias cfg_text: textPattern.text
|
||||
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 50
|
||||
QtControls.Label {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: i18n("Detailed information may be found on <a href=\"http://arcanis.name/projects/awesome-widgets/\">project homepage</a>")
|
||||
}
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.Button {
|
||||
text: i18n("Font")
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Font button")
|
||||
|
||||
var defaultFont = {
|
||||
"color": plasmoid.configuration.fontColor,
|
||||
"family": plasmoid.configuration.fontFamily,
|
||||
"size": plasmoid.configuration.fontSize
|
||||
}
|
||||
var font = AWActions.getFont(defaultFont)
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<span style=\"color:" + font.color +
|
||||
"; font-family:'" + font.family +
|
||||
"'; font-size:" + font.size + "pt;\">" +
|
||||
selected + "</span>")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
iconName: "format-indent-more"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Indent button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, selected + "<br>\n")
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
iconName: "format-text-bold"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Bold button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<b>" + selected + "</b>")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
iconName: "format-text-italic"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Italic button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<i>" + selected + "</i>")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
iconName: "format-text-underline"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Underline button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<u>" + selected + "</u>")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
iconName: "format-text-strikethrough"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Strike button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<s>" + selected + "</s>")
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
iconName: "format-justify-left"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Left button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"left\">" + selected + "</p")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
iconName: "format-justify-center"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Center button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"center\">" + selected + "</p")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
iconName: "format-justify-right"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Right button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"right\">" + selected + "</p")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
iconName: "format-justify-fill"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Justify button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p")
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.ComboBox {
|
||||
id: tags
|
||||
model: AWKeys.dictKeys()
|
||||
}
|
||||
QtControls.Button {
|
||||
text: i18n("Add")
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Add tag button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, selected + "$" + tags.currentText)
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
text: i18n("Show value")
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Show tag button")
|
||||
|
||||
var message = i18n("Tag: %1<br>Value: %2", tags.currentText, AWKeys.valueByKey(tags.currentText))
|
||||
AWActions.sendNotification("tag", message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtControls.TextArea {
|
||||
id: textPattern
|
||||
width: parent.width
|
||||
textFormat: TextEdit.PlainText
|
||||
text: plasmoid.configuration.text
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("[widget::onCompleted]")
|
||||
}
|
||||
}
|
@ -27,8 +27,11 @@ file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
file (GLOB SUBPROJECT_UI *.ui)
|
||||
# task source is required by extscripts
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
../../extsysmon/extscript.cpp)
|
||||
${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
||||
../../extsysmon/extscript.cpp
|
||||
../../extsysmon/extupgrade.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
set (SUBPROJECT_DESKTOPS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
||||
|
||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||
@ -38,3 +41,4 @@ target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
||||
install (DIRECTORY ${SUBPROJECT_DESKTOPS} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
||||
|
@ -22,16 +22,18 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QProcess>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegExp>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QThread>
|
||||
|
||||
#include <fontdialog/fontdialog.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "extscript.h"
|
||||
@ -97,6 +99,94 @@ void AWActions::showReadme()
|
||||
}
|
||||
|
||||
|
||||
void AWActions::addDevice(const QString source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
|
||||
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
|
||||
QRegExp fanRegexp = QRegExp(QString("lmsensors/.*/fan.*"));
|
||||
QRegExp mountRegexp = QRegExp(QString("partitions/.*/filllevel"));
|
||||
QRegExp tempRegexp = QRegExp(QString("lmsensors/.*temp.*/.*"));
|
||||
|
||||
if (diskRegexp.indexIn(source) > -1) {
|
||||
QStringList splitSource = source.split(QChar('/'));
|
||||
QString device = splitSource[0] + QString("/") + splitSource[1];
|
||||
diskDevices.append(device);
|
||||
} else if (fanRegexp.indexIn(source) > -1)
|
||||
fanDevices.append(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);
|
||||
}
|
||||
|
||||
|
||||
QStringList AWActions::getDiskDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return diskDevices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWActions::getFanDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return fanDevices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWActions::getHddDevices()
|
||||
{
|
||||
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];
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWActions::getMountDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return mountDevices;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWActions::getTempDevices()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return tempDevices;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> defaultFont)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> fontMap;
|
||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||
defaultFont[QString("size")].toInt(),
|
||||
400, false, defaultFont[QString("color")].toString());
|
||||
CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont,
|
||||
false, false);
|
||||
fontMap[QString("color")] = font.color().name();
|
||||
fontMap[QString("family")] = font.family();
|
||||
fontMap[QString("size")] = font.pointSize();
|
||||
|
||||
return fontMap;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -38,6 +38,14 @@ public:
|
||||
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true"));
|
||||
Q_INVOKABLE void sendNotification(const QString eventId, const QString message);
|
||||
Q_INVOKABLE void showReadme();
|
||||
// configuration slots
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList getDiskDevices();
|
||||
Q_INVOKABLE QStringList getFanDevices();
|
||||
Q_INVOKABLE QStringList getHddDevices();
|
||||
Q_INVOKABLE QStringList getMountDevices();
|
||||
Q_INVOKABLE QStringList getTempDevices();
|
||||
Q_INVOKABLE QMap<QString, QVariant> getFont(const QMap<QString, QVariant> defaultFont);
|
||||
// dataengine
|
||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||
@ -50,6 +58,7 @@ private:
|
||||
QMap<QString, QVariant> updateDataEngineConfiguration(QMap<QString, QVariant> rawConfig);
|
||||
// variables
|
||||
bool debug = false;
|
||||
QStringList diskDevices, fanDevices, mountDevices, tempDevices;
|
||||
};
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "awtooltip.h"
|
||||
#include "extscript.h"
|
||||
#include "extupgrade.h"
|
||||
#include "graphicalitem.h"
|
||||
#include "version.h"
|
||||
|
||||
@ -58,6 +59,7 @@ void AWKeys::initKeys(const QString pattern,
|
||||
|
||||
// clear
|
||||
extScripts.clear();
|
||||
extUpgrade.clear();
|
||||
graphicalItems.clear();
|
||||
counts.clear();
|
||||
keys.clear();
|
||||
@ -67,6 +69,7 @@ void AWKeys::initKeys(const QString pattern,
|
||||
|
||||
// init
|
||||
extScripts = getExtScripts();
|
||||
extUpgrade = getExtUpgrade();
|
||||
graphicalItems = getGraphicalItems();
|
||||
counts = getCounts(params);
|
||||
keys = dictKeys();
|
||||
@ -94,36 +97,6 @@ bool AWKeys::isReady()
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::networkDevice(const QString custom)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom device" << custom;
|
||||
|
||||
QString device = QString("lo");
|
||||
if (custom.isEmpty()) {
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++)
|
||||
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint))) {
|
||||
device = rawInterfaceList[i].name();
|
||||
break;
|
||||
}
|
||||
} else
|
||||
device = custom;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
int AWKeys::numberCpus()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QThread::idealThreadCount();
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::parsePattern(const QString pattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -131,39 +104,20 @@ QString AWKeys::parsePattern(const QString pattern)
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<foundKeys.count(); i++)
|
||||
parsed.replace(QString("$") + foundKeys[i], values[foundKeys[i]]);
|
||||
for (int i=0; i<foundBars.count(); i++) {
|
||||
QString key = foundBars[i];
|
||||
key.remove(QRegExp(QString("bar[0-9]{1,}")));
|
||||
parsed.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->image(values[key].toFloat()));
|
||||
}
|
||||
parsed.replace(QString("$") + foundKeys[i], valueByKey(foundKeys[i]));
|
||||
for (int i=0; i<foundBars.count(); i++)
|
||||
parsed.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->image(valueByKey(foundBars[i]).toFloat()));
|
||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
||||
float AWKeys::temperature(const float temp, const QString units)
|
||||
QPixmap AWKeys::toolTipImage()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if(debug) qDebug() << PDEBUG;
|
||||
|
||||
float converted = temp;
|
||||
if (units == QString("Celsius"))
|
||||
;
|
||||
else if (units == QString("Fahrenheit"))
|
||||
converted = temp * 9.0 / 5.0 + 32.0;
|
||||
else if (units == QString("Kelvin"))
|
||||
converted = temp + 273.15;
|
||||
else if (units == QString("Reaumur"))
|
||||
converted = temp * 0.8;
|
||||
else if (units == QString("cm^-1"))
|
||||
converted = (temp + 273.15) * 0.695;
|
||||
else if (units == QString("kJ/mol"))
|
||||
converted = (temp + 273.15) * 8.31;
|
||||
else if (units == QString("kcal/mol"))
|
||||
converted = (temp + 273.15) * 1.98;
|
||||
|
||||
return converted;
|
||||
return toolTip->image();
|
||||
}
|
||||
|
||||
|
||||
@ -280,6 +234,24 @@ QStringList AWKeys::extScriptsInfo()
|
||||
info.append(extScripts[i]->name());
|
||||
info.append(extScripts[i]->comment());
|
||||
info.append(extScripts[i]->executable());
|
||||
info.append(QVariant(extScripts[i]->isActive()).toString());
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::extUpgradeInfo()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList info;
|
||||
for (int i=0; i<extUpgrade.count(); i++) {
|
||||
info.append(extUpgrade[i]->fileName());
|
||||
info.append(extUpgrade[i]->name());
|
||||
info.append(extUpgrade[i]->comment());
|
||||
info.append(extUpgrade[i]->executable());
|
||||
info.append(QVariant(extUpgrade[i]->isActive()).toString());
|
||||
}
|
||||
|
||||
return info;
|
||||
@ -381,11 +353,11 @@ void AWKeys::setDataBySource(const QString sourceName,
|
||||
}
|
||||
} else if (sourceName == QString("gpu")) {
|
||||
// gpu load
|
||||
values[QString("gpu")] = QString("%1").arg(data[QString("GPU")].toFloat(), 5, 'f', 1);
|
||||
values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
} else if (sourceName == QString("gputemp")) {
|
||||
// gpu temperature
|
||||
values[QString("gputemp")] = QString("%1").arg(
|
||||
temperature(data[QString("GPUTemp")].toFloat(),params[QString("tempUnits")].toString()), 4, 'f', 1);
|
||||
temperature(data[QString("value")].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
|
||||
} else if (sourceName.contains(mountFillRegExp)) {
|
||||
// fill level
|
||||
QString mount = sourceName;
|
||||
@ -554,6 +526,71 @@ void AWKeys::setDataBySource(const QString sourceName,
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::valueByKey(QString key)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
|
||||
|
||||
key.remove(QRegExp(QString("^bar[0-9]{1,}")));
|
||||
|
||||
return values[key];
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::networkDevice(const QString custom)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom device" << custom;
|
||||
|
||||
QString device = QString("lo");
|
||||
if (custom.isEmpty()) {
|
||||
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
|
||||
for (int i=0; i<rawInterfaceList.count(); i++)
|
||||
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
|
||||
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint))) {
|
||||
device = rawInterfaceList[i].name();
|
||||
break;
|
||||
}
|
||||
} else
|
||||
device = custom;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
||||
int AWKeys::numberCpus()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QThread::idealThreadCount();
|
||||
}
|
||||
|
||||
|
||||
float AWKeys::temperature(const float temp, const QString units)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
float converted = temp;
|
||||
if (units == QString("Celsius"))
|
||||
;
|
||||
else if (units == QString("Fahrenheit"))
|
||||
converted = temp * 9.0 / 5.0 + 32.0;
|
||||
else if (units == QString("Kelvin"))
|
||||
converted = temp + 273.15;
|
||||
else if (units == QString("Reaumur"))
|
||||
converted = temp * 0.8;
|
||||
else if (units == QString("cm^-1"))
|
||||
converted = (temp + 273.15) * 0.695;
|
||||
else if (units == QString("kJ/mol"))
|
||||
converted = (temp + 273.15) * 8.31;
|
||||
else if (units == QString("kcal/mol"))
|
||||
converted = (temp + 273.15) * 1.98;
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::findGraphicalItems(const QString pattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -598,9 +635,7 @@ QMap<QString, QVariant> AWKeys::getCounts(const QMap<QString, QVariant> params)
|
||||
awCounts[QString("fan")] = params[QString("fanDevice")].toString().split(QString("@@")).count();
|
||||
awCounts[QString("hddtemp")] = params[QString("hdd")].toString().split(QString("@@")).count();
|
||||
awCounts[QString("mount")] = params[QString("mount")].toString().split(QString("@@")).count();
|
||||
// TODO update pkg parsing
|
||||
// awCounts[QString("pkg")] = deSettings[QString("PKGCMD")].split(QChar(',')).count();
|
||||
awCounts[QString("pkg")] = 1;
|
||||
awCounts[QString("pkg")] = extUpgrade.count();
|
||||
awCounts[QString("temp")] = params[QString("tempDevice")].toString().split(QString("@@")).count();
|
||||
|
||||
return awCounts;
|
||||
@ -614,13 +649,13 @@ QList<ExtScript *> AWKeys::getExtScripts()
|
||||
QList<ExtScript *> externalScripts;
|
||||
// create directory at $HOME
|
||||
QString localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||
QString("/plasma_engine_extsysmon/scripts");
|
||||
QString("/plasma_dataengine_extsysmon/scripts");
|
||||
QDir localDirectory;
|
||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||
QString("plasma_engine_extsysmon/scripts"),
|
||||
QString("plasma_dataengine_extsysmon/scripts"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
QStringList names;
|
||||
for (int i=0; i<dirs.count(); i++) {
|
||||
@ -638,6 +673,37 @@ QList<ExtScript *> AWKeys::getExtScripts()
|
||||
}
|
||||
|
||||
|
||||
QList<ExtUpgrade *> AWKeys::getExtUpgrade()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<ExtUpgrade *> externalUpgrade;
|
||||
// create directory at $HOME
|
||||
QString localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||
QString("/plasma_dataengine_extsysmon/upgrade");
|
||||
QDir localDirectory;
|
||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||
QString("plasma_dataengine_extsysmon/upgrade"),
|
||||
QStandardPaths::LocateDirectory);
|
||||
QStringList names;
|
||||
for (int i=0; i<dirs.count(); i++) {
|
||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||
for (int j=0; j<files.count(); j++) {
|
||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||
if (names.contains(files[j])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||
names.append(files[j]);
|
||||
externalUpgrade.append(new ExtUpgrade(0, files[j], dirs, debug));
|
||||
}
|
||||
}
|
||||
|
||||
return externalUpgrade;
|
||||
}
|
||||
|
||||
|
||||
QList<GraphicalItem *> AWKeys::getGraphicalItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
@ -22,11 +22,13 @@
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QPixmap>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class AWToolTip;
|
||||
class ExtScript;
|
||||
class ExtUpgrade;
|
||||
class GraphicalItem;
|
||||
|
||||
class AWKeys : public QObject
|
||||
@ -42,23 +44,31 @@ public:
|
||||
const QMap<QString, QVariant> tooltipParams);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE bool isReady();
|
||||
Q_INVOKABLE QString networkDevice(const QString custom = QString(""));
|
||||
Q_INVOKABLE int numberCpus();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||
Q_INVOKABLE float temperature(const float temp, const QString units = QString("Celsius"));
|
||||
Q_INVOKABLE QPixmap toolTipImage();
|
||||
// keys
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList extScriptsInfo();
|
||||
Q_INVOKABLE QStringList extUpgradeInfo();
|
||||
Q_INVOKABLE QStringList graphicalItemsInfo();
|
||||
Q_INVOKABLE void setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params);
|
||||
Q_INVOKABLE QStringList findGraphicalItems(const QString pattern);
|
||||
Q_INVOKABLE QStringList findKeys(const QString pattern);
|
||||
// values
|
||||
Q_INVOKABLE QString valueByKey(QString key);
|
||||
|
||||
private:
|
||||
// methods
|
||||
QString networkDevice(const QString custom = QString(""));
|
||||
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
|
||||
QMap<QString, QVariant> getCounts(const QMap<QString, QVariant> params);
|
||||
QList<ExtScript *> getExtScripts();
|
||||
QList<ExtUpgrade *> getExtUpgrade();
|
||||
QList<GraphicalItem *> getGraphicalItems();
|
||||
GraphicalItem *getItemByTag(const QString tag);
|
||||
QStringList getTimeKeys();
|
||||
@ -68,6 +78,7 @@ private:
|
||||
bool ready = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtScript *> extScripts;
|
||||
QList<ExtUpgrade *> extUpgrade;
|
||||
QStringList foundBars, foundKeys, keys;
|
||||
QMap<QString, QVariant> counts;
|
||||
QMap<QString, QString> values;
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
QMap<QString, QVariant> m_settings = QMap<QString, QVariant>());
|
||||
~AWToolTip();
|
||||
|
||||
Q_INVOKABLE QPixmap image();
|
||||
QPixmap image();
|
||||
void setData(const QString source, const float value,
|
||||
const bool ac = true);
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar3
|
||||
Comment=Simple bat bar
|
||||
X-AW-Value=bat
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar0
|
||||
Comment=Simple cpu bar
|
||||
X-AW-Value=cpu
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar1
|
||||
Comment=Simple mem bar
|
||||
X-AW-Value=mem
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar2
|
||||
Comment=Simple swap bar
|
||||
X-AW-Value=swap
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -0,0 +1,25 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
# name should be barN and uniq
|
||||
Name=bar100500
|
||||
Comment=Template for the AW bars
|
||||
# value to show. Supported types are
|
||||
# cpu, cpu[0-9], mem, swap, bat
|
||||
X-AW-Value=cpu
|
||||
# active color, RGBA
|
||||
# you should use double quotes
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
# inactive color, RGBA
|
||||
# you should use double quotes
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
# bar type. Supported types are
|
||||
# Horizontal, Vertical, Circle
|
||||
X-AW-Type=Horizontal
|
||||
# direction. LeftToRight or RightToLeft
|
||||
X-AW-Direction=LeftToRight
|
||||
# height in pixels
|
||||
X-AW-Height=25
|
||||
# width in pixels
|
||||
X-AW-Width=100
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
Reference in New Issue
Block a user