mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
split plugin to classes
rewrite extscripts fix building implement several methods
This commit is contained in:
parent
f5fbb80d91
commit
213595b3c1
3
sources/awesome-widget-kf5/plugin/.directory
Normal file
3
sources/awesome-widget-kf5/plugin/.directory
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[Dolphin]
|
||||||
|
Timestamp=2015,1,19,23,14,34
|
||||||
|
Version=3
|
@ -17,13 +17,17 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
${PROJECT_TRDPARTY_DIR}
|
${PROJECT_TRDPARTY_DIR}
|
||||||
|
../../ext-sysmon
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../../ext-sysmon
|
||||||
${Qt_INCLUDE}
|
${Qt_INCLUDE}
|
||||||
${Kf5_INCLUDE})
|
${Kf5_INCLUDE})
|
||||||
|
|
||||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||||
file (GLOB SUBPROJECT_UI *.ui)
|
file (GLOB SUBPROJECT_UI *.ui)
|
||||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
# task source is required by extscripts
|
||||||
|
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||||
|
../../ext-sysmon/extscript.cpp)
|
||||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||||
|
|
||||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||||
|
210
sources/awesome-widget-kf5/plugin/awactions.cpp
Normal file
210
sources/awesome-widget-kf5/plugin/awactions.cpp
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "awactions.h"
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QProcessEnvironment>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
|
#include "extscript.h"
|
||||||
|
#include "graphicalitem.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
AWActions::AWActions(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
// debug
|
||||||
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||||
|
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||||
|
debug = (debugEnv == QString("yes"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AWActions::~AWActions()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::checkUpdates()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||||
|
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
|
||||||
|
|
||||||
|
manager->get(QNetworkRequest(QUrl(VERSION_API)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::runCmd(const QString cmd)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
|
|
||||||
|
QProcess command;
|
||||||
|
sendNotification(QString("Info"), i18n("Run %1", cmd));
|
||||||
|
|
||||||
|
command.startDetached(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::sendNotification(const QString eventId, const QString message)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
||||||
|
|
||||||
|
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: ") + eventId, message);
|
||||||
|
notification->setComponentName(QString("plasma-applet-org.kde.plasma.awesome-widget"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::showReadme()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QDesktopServices::openUrl(QString(HOMEPAGE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||||
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
|
QMap<QString, QVariant> rawConfig;
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Configuration"));
|
||||||
|
rawConfig[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/"));
|
||||||
|
rawConfig[QString("GPUDEV")] = settings.value(QString("GPUDEV"), QString("auto"));
|
||||||
|
rawConfig[QString("HDDDEV")] = settings.value(QString("HDDDEV"), QString("all"));
|
||||||
|
rawConfig[QString("HDDTEMPCMD")] = settings.value(QString("HDDTEMPCMD"), QString("sudo hddtemp"));
|
||||||
|
rawConfig[QString("MPDADDRESS")] = settings.value(QString("MPDADDRESS"), QString("localhost"));
|
||||||
|
rawConfig[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600"));
|
||||||
|
rawConfig[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto"));
|
||||||
|
rawConfig[QString("PKGCMD")] = settings.value(QString("PKGCMD"), QString("pacman -Qu"));
|
||||||
|
rawConfig[QString("PKGNULL")] = settings.value(QString("PKGNULL"), QString("0"));
|
||||||
|
rawConfig[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris"));
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
return updateDataEngineConfiguration(rawConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<QString, QVariant> AWActions::updateDataEngineConfiguration(QMap<QString, QVariant> rawConfig)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
for (int i=rawConfig[QString("PKGNULL")].toString().split(QString(","), QString::SkipEmptyParts).count();
|
||||||
|
i<rawConfig[QString("PKGCMD")].toString().split(QString(","), QString::SkipEmptyParts).count()+1;
|
||||||
|
i++)
|
||||||
|
rawConfig[QString("PKGNULL")].toString() += QString(",0");
|
||||||
|
|
||||||
|
for (int i=0; i<rawConfig.keys().count(); i++)
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" <<
|
||||||
|
rawConfig.keys()[i] << QString("=") << rawConfig[rawConfig.keys()[i]];
|
||||||
|
return rawConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
|
||||||
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Configuration"));
|
||||||
|
settings.setValue(QString("GPUDEV"), configuration[QString("GPUDEV")]);
|
||||||
|
settings.setValue(QString("HDDDEV"), configuration[QString("HDDDEV")]);
|
||||||
|
settings.setValue(QString("HDDTEMPCMD"), configuration[QString("HDDTEMPCMD")]);
|
||||||
|
settings.setValue(QString("MPDADDRESS"), configuration[QString("MPDADDRESS")]);
|
||||||
|
settings.setValue(QString("MPDPORT"), configuration[QString("MPDPORT")]);
|
||||||
|
settings.setValue(QString("MPRIS"), configuration[QString("MPRIS")]);
|
||||||
|
settings.setValue(QString("PKGCMD"), configuration[QString("PKGCMD")]);
|
||||||
|
settings.setValue(QString("PKGNULL"), configuration[QString("PKGNULL")]);
|
||||||
|
settings.setValue(QString("PLAYER"), configuration[QString("PLAYER")]);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::showUpdates(QString version)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
|
||||||
|
text += i18n("New version : %1", version) + QString("\n\n");
|
||||||
|
text += i18n("Click \"Ok\" to download");
|
||||||
|
|
||||||
|
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
|
switch(select) {
|
||||||
|
case QMessageBox::Ok:
|
||||||
|
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::versionReplyRecieved(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QString answer = reply->readAll();
|
||||||
|
if (!answer.contains(QString("tag_name"))) return;
|
||||||
|
QString version = QString(VERSION);
|
||||||
|
if (debug) qDebug() << PDEBUG << answer;
|
||||||
|
for (int i=0; i<answer.split(QString("tag_name")).count(); i++) {
|
||||||
|
version = answer.split(QString("tag_name"))[1].split(QChar(','))[0];
|
||||||
|
version.remove(QChar('"'));
|
||||||
|
version.remove(QChar(':'));
|
||||||
|
version.remove(QString("V."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int old_major = QString(VERSION).split(QChar('.'))[0].toInt();
|
||||||
|
int old_minor = QString(VERSION).split(QChar('.'))[1].toInt();
|
||||||
|
int old_patch = QString(VERSION).split(QChar('.'))[2].toInt();
|
||||||
|
int new_major = QString(version).split(QChar('.'))[0].toInt();
|
||||||
|
int new_minor = QString(version).split(QChar('.'))[1].toInt();
|
||||||
|
int new_patch = QString(version).split(QChar('.'))[2].toInt();
|
||||||
|
if ((old_major < new_major) ||
|
||||||
|
((old_major == new_major) && (old_minor < new_minor)) ||
|
||||||
|
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||||
|
showUpdates(version);
|
||||||
|
}
|
56
sources/awesome-widget-kf5/plugin/awactions.h
Normal file
56
sources/awesome-widget-kf5/plugin/awactions.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 AWACTIONS_H
|
||||||
|
#define AWACTIONS_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
|
||||||
|
class AWActions : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AWActions(QObject *parent = 0);
|
||||||
|
~AWActions();
|
||||||
|
|
||||||
|
Q_INVOKABLE void checkUpdates();
|
||||||
|
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();
|
||||||
|
// dataengine
|
||||||
|
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||||
|
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void showUpdates(QString version);
|
||||||
|
void versionReplyRecieved(QNetworkReply *reply);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap<QString, QVariant> updateDataEngineConfiguration(QMap<QString, QVariant> rawConfig);
|
||||||
|
// variables
|
||||||
|
bool debug = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* AWACTIONS_H */
|
@ -19,15 +19,25 @@
|
|||||||
|
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
|
||||||
#include "awadds.h"
|
#include "awactions.h"
|
||||||
|
#include "awkeys.h"
|
||||||
|
|
||||||
|
|
||||||
static QObject *aw_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
static QObject *awactions_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||||
{
|
{
|
||||||
Q_UNUSED(engine);
|
Q_UNUSED(engine);
|
||||||
Q_UNUSED(scriptEngine);
|
Q_UNUSED(scriptEngine);
|
||||||
|
|
||||||
return new AWAdds();
|
return new AWActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static QObject *awkeys_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||||
|
{
|
||||||
|
Q_UNUSED(engine);
|
||||||
|
Q_UNUSED(scriptEngine);
|
||||||
|
|
||||||
|
return new AWKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -35,5 +45,6 @@ void AWPlugin::registerTypes(const char *uri)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.awesome-widget"));
|
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.awesome-widget"));
|
||||||
|
|
||||||
qmlRegisterSingletonType<AWAdds>(uri, 1, 0, "AWAdds", aw_singletontype_provider);
|
qmlRegisterSingletonType<AWActions>(uri, 1, 0, "AWActions", awactions_singletontype_provider);
|
||||||
|
qmlRegisterSingletonType<AWKeys>(uri, 1, 0, "AWKeys", awkeys_singletontype_provider);
|
||||||
}
|
}
|
||||||
|
@ -15,34 +15,23 @@
|
|||||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "awadds.h"
|
#include "awkeys.h"
|
||||||
|
|
||||||
#include <KI18n/KLocalizedString>
|
|
||||||
#include <KNotifications/KNotification>
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDir>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <QNetworkRequest>
|
|
||||||
#include <QNetworkReply>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QSettings>
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTextCodec>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
//#include <task/taskadds.h>
|
|
||||||
|
|
||||||
#include "extscript.h"
|
#include "extscript.h"
|
||||||
#include "graphicalitem.h"
|
#include "graphicalitem.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
AWAdds::AWAdds(QObject *parent)
|
AWKeys::AWKeys(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
// debug
|
// debug
|
||||||
@ -54,24 +43,27 @@ AWAdds::AWAdds(QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AWAdds::~AWAdds()
|
AWKeys::~AWKeys()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::checkUpdates()
|
void AWKeys::initKeys(const QString pattern)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
// clear
|
||||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
|
foundBars.clear();
|
||||||
|
foundKeys.clear();
|
||||||
|
|
||||||
manager->get(QNetworkRequest(QUrl(VERSION_API)));
|
// init
|
||||||
|
foundBars = findGraphicalItems(pattern);
|
||||||
|
foundKeys = findKeys(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::initValues()
|
void AWKeys::initValues()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -87,7 +79,7 @@ void AWAdds::initValues()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool AWAdds::isDebugEnabled()
|
bool AWKeys::isDebugEnabled()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -95,7 +87,7 @@ bool AWAdds::isDebugEnabled()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWAdds::networkDevice(const QString custom)
|
QString AWKeys::networkDevice(const QString custom)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Custom device" << custom;
|
if (debug) qDebug() << PDEBUG << ":" << "Custom device" << custom;
|
||||||
@ -117,7 +109,7 @@ QString AWAdds::networkDevice(const QString custom)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int AWAdds::numberCpus()
|
int AWKeys::numberCpus()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -125,26 +117,35 @@ int AWAdds::numberCpus()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWAdds::parsePattern(const QString pattern, const QMap<QString, QVariant> dict,
|
QString AWKeys::parsePattern(const QString pattern, const QMap<QString, QVariant> values)
|
||||||
const QMap<QString, QVariant> values,
|
|
||||||
const QStringList foundKeys, const QStringList foundBars)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Dictionary" << dict;
|
|
||||||
|
|
||||||
QString parsed = pattern;
|
QString parsed = pattern;
|
||||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||||
for (int i=0; i<foundKeys.count(); i++)
|
for (int i=0; i<foundKeys.count(); i++)
|
||||||
parsed.replace(QString("$") + foundKeys[i], values[foundKeys[i]]);
|
parsed.replace(QString("$") + foundKeys[i], values[foundKeys[i]].toString());
|
||||||
for (int i=0; i<foundBars.count(); i++)
|
for (int i=0; i<foundBars.count(); i++)
|
||||||
parsed.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->getImage(values[foundBars[i]].toFloat()));
|
parsed.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->image(values[foundBars[i]].toFloat()));
|
||||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float AWAdds::tempepature(const float temp, const QString units)
|
QStringList AWKeys::sourcesForDataEngine(const QString pattern, const QString dataEngine)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Pattern" << pattern;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "DataEngine" << dataEngine;
|
||||||
|
|
||||||
|
QStringList sources;
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float AWKeys::temperature(const float temp, const QString units)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -168,7 +169,7 @@ float AWAdds::tempepature(const float temp, const QString units)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVariant> AWAdds::counts()
|
QMap<QString, QVariant> AWKeys::counts()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -194,7 +195,7 @@ QMap<QString, QVariant> AWAdds::counts()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWAdds::dictKeys()
|
QStringList AWKeys::dictKeys()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -298,7 +299,38 @@ QStringList AWAdds::dictKeys()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWAdds::timeKeys()
|
QStringList AWKeys::extScriptsInfo()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList info;
|
||||||
|
for (int i=0; i<extScripts.count(); i++) {
|
||||||
|
info.append(extScripts[i]->fileName());
|
||||||
|
info.append(extScripts[i]->name());
|
||||||
|
info.append(extScripts[i]->comment());
|
||||||
|
info.append(extScripts[i]->executable());
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWKeys::graphicalItemsInfo()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList info;
|
||||||
|
for (int i=0; i<graphicalItems.count(); i++) {
|
||||||
|
info.append(graphicalItems[i]->fileName());
|
||||||
|
info.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||||
|
info.append(graphicalItems[i]->comment());
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AWKeys::timeKeys()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -324,13 +356,13 @@ QStringList AWAdds::timeKeys()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList AWAdds::findGraphicalItems(const QString pattern)
|
QStringList AWKeys::findGraphicalItems(const QString pattern)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QStringList orderedKeys;
|
QStringList orderedKeys;
|
||||||
for (int i=0; i<graphicalItems.count(); i++)
|
for (int i=0; i<graphicalItems.count(); i++)
|
||||||
orderedKeys.append(graphicalItems[i]->getName() + graphicalItems[i]->getBar());
|
orderedKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||||
orderedKeys.sort();
|
orderedKeys.sort();
|
||||||
|
|
||||||
QStringList selectedKeys;
|
QStringList selectedKeys;
|
||||||
@ -344,7 +376,7 @@ QStringList AWAdds::findGraphicalItems(const QString pattern)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWAdds::findKeys(const QString pattern)
|
QStringList AWKeys::findKeys(const QString pattern)
|
||||||
{
|
{
|
||||||
QStringList selectedKeys;
|
QStringList selectedKeys;
|
||||||
for (int i=0; i<keys.count(); i++)
|
for (int i=0; i<keys.count(); i++)
|
||||||
@ -357,151 +389,7 @@ QString AWAdds::findKeys(const QString pattern)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::runCmd(const QString cmd)
|
QList<ExtScript *> AWKeys::getExtScripts()
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
|
||||||
|
|
||||||
QProcess command;
|
|
||||||
sendNotification(QString("Info"), i18n("Run %1", cmd));
|
|
||||||
|
|
||||||
command.startDetached(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::sendNotification(const QString eventId, const QString message)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
|
||||||
|
|
||||||
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: ") + eventId, message);
|
|
||||||
notification->setComponentName(QString("plasma-applet-org.kde.plasma.awesome-widget"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::showReadme()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QDesktopServices::openUrl(QString(HOMEPAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVariant> AWAdds::readDataEngineConfiguration()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
|
||||||
QMap<QString, QVariant> rawConfig;
|
|
||||||
|
|
||||||
settings.beginGroup(QString("Configuration"));
|
|
||||||
rawConfig[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/"));
|
|
||||||
rawConfig[QString("GPUDEV")] = settings.value(QString("GPUDEV"), QString("auto"));
|
|
||||||
rawConfig[QString("HDDDEV")] = settings.value(QString("HDDDEV"), QString("all"));
|
|
||||||
rawConfig[QString("HDDTEMPCMD")] = settings.value(QString("HDDTEMPCMD"), QString("sudo hddtemp"));
|
|
||||||
rawConfig[QString("MPDADDRESS")] = settings.value(QString("MPDADDRESS"), QString("localhost"));
|
|
||||||
rawConfig[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600"));
|
|
||||||
rawConfig[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto"));
|
|
||||||
rawConfig[QString("PKGCMD")] = settings.value(QString("PKGCMD"), QString("pacman -Qu"));
|
|
||||||
rawConfig[QString("PKGNULL")] = settings.value(QString("PKGNULL"), QString("0"));
|
|
||||||
rawConfig[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris"));
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
return updateDataEngineConfiguration(rawConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVariant> AWAdds::updateDataEngineConfiguration(QMap<QString, QVariant> rawConfig)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
for (int i=rawConfig[QString("PKGNULL")].toString().split(QString(","), QString::SkipEmptyParts).count();
|
|
||||||
i<rawConfig[QString("PKGCMD")].toString().split(QString(","), QString::SkipEmptyParts).count()+1;
|
|
||||||
i++)
|
|
||||||
rawConfig[QString("PKGNULL")].toString() += QString(",0");
|
|
||||||
|
|
||||||
for (int i=0; i<rawConfig.keys().count(); i++)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" <<
|
|
||||||
rawConfig.keys()[i] << QString("=") << rawConfig[rawConfig.keys()[i]];
|
|
||||||
return rawConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
|
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
|
||||||
|
|
||||||
settings.beginGroup(QString("Configuration"));
|
|
||||||
settings.setValue(QString("GPUDEV"), configuration[QString("GPUDEV")]);
|
|
||||||
settings.setValue(QString("HDDDEV"), configuration[QString("HDDDEV")]);
|
|
||||||
settings.setValue(QString("HDDTEMPCMD"), configuration[QString("HDDTEMPCMD")]);
|
|
||||||
settings.setValue(QString("MPDADDRESS"), configuration[QString("MPDADDRESS")]);
|
|
||||||
settings.setValue(QString("MPDPORT"), configuration[QString("MPDPORT")]);
|
|
||||||
settings.setValue(QString("MPRIS"), configuration[QString("MPRIS")]);
|
|
||||||
settings.setValue(QString("PKGCMD"), configuration[QString("PKGCMD")]);
|
|
||||||
settings.setValue(QString("PKGNULL"), configuration[QString("PKGNULL")]);
|
|
||||||
settings.setValue(QString("PLAYER"), configuration[QString("PLAYER")]);
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
settings.sync();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::showUpdates(QString version)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QString text;
|
|
||||||
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
|
|
||||||
text += i18n("New version : %1", version) + QString("\n\n");
|
|
||||||
text += i18n("Click \"Ok\" to download");
|
|
||||||
|
|
||||||
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
|
||||||
switch(select) {
|
|
||||||
case QMessageBox::Ok:
|
|
||||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWAdds::versionReplyRecieved(QNetworkReply *reply)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QString answer = reply->readAll();
|
|
||||||
if (!answer.contains(QString("tag_name"))) return;
|
|
||||||
QString version = QString(VERSION);
|
|
||||||
if (debug) qDebug() << PDEBUG << answer;
|
|
||||||
for (int i=0; i<answer.split(QString("tag_name")).count(); i++) {
|
|
||||||
version = answer.split(QString("tag_name"))[1].split(QChar(','))[0];
|
|
||||||
version.remove(QChar('"'));
|
|
||||||
version.remove(QChar(':'));
|
|
||||||
version.remove(QString("V."));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int old_major = QString(VERSION).split(QChar('.'))[0].toInt();
|
|
||||||
int old_minor = QString(VERSION).split(QChar('.'))[1].toInt();
|
|
||||||
int old_patch = QString(VERSION).split(QChar('.'))[2].toInt();
|
|
||||||
int new_major = QString(version).split(QChar('.'))[0].toInt();
|
|
||||||
int new_minor = QString(version).split(QChar('.'))[1].toInt();
|
|
||||||
int new_patch = QString(version).split(QChar('.'))[2].toInt();
|
|
||||||
if ((old_major < new_major) ||
|
|
||||||
((old_major == new_major) && (old_minor < new_minor)) ||
|
|
||||||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
|
||||||
showUpdates(version);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<ExtScript *> AWAdds::getExtScripts()
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -532,7 +420,7 @@ QList<ExtScript *> AWAdds::getExtScripts()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<GraphicalItem *> AWAdds::getGraphicalItems()
|
QList<GraphicalItem *> AWKeys::getGraphicalItems()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
@ -563,13 +451,13 @@ QList<GraphicalItem *> AWAdds::getGraphicalItems()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GraphicalItem *AWAdds::getItemByTag(const QString tag)
|
GraphicalItem *AWKeys::getItemByTag(const QString tag)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
GraphicalItem *item = nullptr;
|
GraphicalItem *item = nullptr;
|
||||||
for (int i=0; i< graphicalItems.count(); i++) {
|
for (int i=0; i< graphicalItems.count(); i++) {
|
||||||
if ((graphicalItems[i]->getName() + graphicalItems[i]->getBar()) != tag) continue;
|
if ((graphicalItems[i]->name() + graphicalItems[i]->bar()) != tag) continue;
|
||||||
item = graphicalItems[i];
|
item = graphicalItems[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
@ -16,8 +16,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef AWADDS_H
|
#ifndef AWKEYS_H
|
||||||
#define AWADDS_H
|
#define AWKEYS_H
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@ -27,55 +27,43 @@
|
|||||||
|
|
||||||
class ExtScript;
|
class ExtScript;
|
||||||
class GraphicalItem;
|
class GraphicalItem;
|
||||||
class QNetworkReply;
|
|
||||||
|
|
||||||
class AWAdds : public QObject
|
class AWKeys : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWAdds(QObject *parent = 0);
|
AWKeys(QObject *parent = 0);
|
||||||
~AWAdds();
|
~AWKeys();
|
||||||
|
|
||||||
Q_INVOKABLE void checkUpdates();
|
Q_INVOKABLE void initKeys(const QString pattern);
|
||||||
Q_INVOKABLE void initValues();
|
Q_INVOKABLE void initValues();
|
||||||
Q_INVOKABLE bool isDebugEnabled();
|
Q_INVOKABLE bool isDebugEnabled();
|
||||||
Q_INVOKABLE QString networkDevice(const QString custom = QString(""));
|
Q_INVOKABLE QString networkDevice(const QString custom = QString(""));
|
||||||
Q_INVOKABLE int numberCpus();
|
Q_INVOKABLE int numberCpus();
|
||||||
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> dict,
|
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> values);
|
||||||
const QMap<QString, QVariant> values,
|
Q_INVOKABLE QStringList sourcesForDataEngine(const QString pattern,
|
||||||
const QStringList foundKeys, const QStringList foundBars);
|
const QString dataEngine = QString("systemmonitor"));
|
||||||
Q_INVOKABLE float tempepature(const float temp, const QString units = QString("Celsius"));
|
Q_INVOKABLE float temperature(const float temp, const QString units = QString("Celsius"));
|
||||||
// keys
|
// keys
|
||||||
Q_INVOKABLE QMap<QString, QVariant> counts();
|
Q_INVOKABLE QMap<QString, QVariant> counts();
|
||||||
Q_INVOKABLE QStringList dictKeys();
|
Q_INVOKABLE QStringList dictKeys();
|
||||||
// Q_INVOKABLE QStringList graphicalItemsNames();
|
Q_INVOKABLE QStringList extScriptsInfo();
|
||||||
|
Q_INVOKABLE QStringList graphicalItemsInfo();
|
||||||
Q_INVOKABLE QStringList timeKeys();
|
Q_INVOKABLE QStringList timeKeys();
|
||||||
Q_INVOKABLE QStringList findGraphicalItems(const QString pattern);
|
Q_INVOKABLE QStringList findGraphicalItems(const QString pattern);
|
||||||
Q_INVOKABLE QStringList findKeys(const QString pattern);
|
Q_INVOKABLE QStringList findKeys(const QString pattern);
|
||||||
// actions
|
|
||||||
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();
|
|
||||||
// dataengine
|
|
||||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
|
||||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void showUpdates(QString version);
|
|
||||||
void versionReplyRecieved(QNetworkReply *reply);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<ExtScript *> getExtScripts();
|
QList<ExtScript *> getExtScripts();
|
||||||
QList<GraphicalItem *> getGraphicalItems();
|
QList<GraphicalItem *> getGraphicalItems();
|
||||||
GraphicalItem *getItemByTag(const QString tag);
|
GraphicalItem *getItemByTag(const QString tag);
|
||||||
QMap<QString, QVariant> updateDataEngineConfiguration(QMap<QString, QVariant> rawConfig);
|
|
||||||
// variables
|
// variables
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
QList<GraphicalItem *> graphicalItems;
|
QList<GraphicalItem *> graphicalItems;
|
||||||
QList<ExtScript *> extScripts;
|
QList<ExtScript *> extScripts;
|
||||||
QStringList keys;
|
QStringList foundBars, foundKeys, keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* AWADDS_H */
|
#endif /* AWKEYS_H */
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
|
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
@ -143,6 +145,14 @@ QString GraphicalItem::fileName()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GraphicalItem::apiVersion()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return m_apiVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::name()
|
QString GraphicalItem::name()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -254,6 +264,15 @@ int GraphicalItem::width()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GraphicalItem::setApiVersion(const int _apiVersion)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||||
|
|
||||||
|
m_apiVersion = _apiVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItem::setName(const QString _name)
|
void GraphicalItem::setName(const QString _name)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -382,6 +401,7 @@ void GraphicalItem::readConfiguration()
|
|||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
setName(settings.value(QString("Name"), m_name).toString());
|
setName(settings.value(QString("Name"), m_name).toString());
|
||||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||||
|
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWGIAPI).toInt());
|
||||||
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
||||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
||||||
@ -415,6 +435,7 @@ void GraphicalItem::showConfiguration(const QStringList tags)
|
|||||||
|
|
||||||
setName(ui->label_nameValue->text());
|
setName(ui->label_nameValue->text());
|
||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
|
setApiVersion(AWGIAPI);
|
||||||
setBar(ui->comboBox_value->currentText());
|
setBar(ui->comboBox_value->currentText());
|
||||||
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
|
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
|
||||||
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
|
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
|
||||||
@ -448,6 +469,7 @@ void GraphicalItem::writeConfiguration()
|
|||||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||||
settings.setValue(QString("Name"), m_name);
|
settings.setValue(QString("Name"), m_name);
|
||||||
settings.setValue(QString("Comment"), m_comment);
|
settings.setValue(QString("Comment"), m_comment);
|
||||||
|
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||||
settings.setValue(QString("X-AW-Value"), m_bar);
|
settings.setValue(QString("X-AW-Value"), m_bar);
|
||||||
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
||||||
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
||||||
|
@ -29,8 +29,9 @@ class GraphicalItem;
|
|||||||
class GraphicalItem : public QDialog
|
class GraphicalItem : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(QString comment READ comment WRITE setName)
|
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||||
Q_PROPERTY(QString bar READ bar WRITE setBar)
|
Q_PROPERTY(QString bar READ bar WRITE setBar)
|
||||||
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
||||||
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
||||||
@ -56,6 +57,7 @@ public:
|
|||||||
QString fileName();
|
QString fileName();
|
||||||
QString image(const float value);
|
QString image(const float value);
|
||||||
// get methods
|
// get methods
|
||||||
|
int apiVersion();
|
||||||
QString name();
|
QString name();
|
||||||
QString comment();
|
QString comment();
|
||||||
QString bar();
|
QString bar();
|
||||||
@ -68,6 +70,7 @@ public:
|
|||||||
int height();
|
int height();
|
||||||
int width();
|
int width();
|
||||||
// set methods
|
// set methods
|
||||||
|
void setApiVersion(const int _apiVersion = 0);
|
||||||
void setName(const QString _name = QString("none"));
|
void setName(const QString _name = QString("none"));
|
||||||
void setComment(const QString _comment = QString("empty"));
|
void setComment(const QString _comment = QString("empty"));
|
||||||
void setBar(const QString _bar = QString("cpu"));
|
void setBar(const QString _bar = QString("cpu"));
|
||||||
@ -96,6 +99,7 @@ private:
|
|||||||
bool debug;
|
bool debug;
|
||||||
Ui::GraphicalItem *ui;
|
Ui::GraphicalItem *ui;
|
||||||
// properties
|
// properties
|
||||||
|
int m_apiVersion = 0;
|
||||||
QString m_name = QString("none");
|
QString m_name = QString("none");
|
||||||
QString m_comment = QString("empty");
|
QString m_comment = QString("empty");
|
||||||
QString m_bar = QString("cpu");
|
QString m_bar = QString("cpu");
|
||||||
|
@ -26,15 +26,17 @@
|
|||||||
#include <pdebug/pdebug.h>
|
#include <pdebug/pdebug.h>
|
||||||
#include <task/taskadds.h>
|
#include <task/taskadds.h>
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringList directories, const bool debugCmd) :
|
ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringList directories, const bool debugCmd) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
fileName(scriptName),
|
m_fileName(scriptName),
|
||||||
dirs(directories),
|
m_dirs(directories),
|
||||||
debug(debugCmd),
|
debug(debugCmd),
|
||||||
ui(new Ui::ExtScript)
|
ui(new Ui::ExtScript)
|
||||||
{
|
{
|
||||||
_name = fileName;
|
m_name = m_fileName;
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
@ -48,68 +50,76 @@ ExtScript::~ExtScript()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::getComment()
|
int ExtScript::apiVersion()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _comment;
|
return m_apiVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::getExec()
|
QString ExtScript::comment()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _exec;
|
return m_comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::getFileName()
|
QString ExtScript::executable()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return fileName;
|
return m_executable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ExtScript::getInterval()
|
QString ExtScript::fileName()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _interval;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::getName()
|
int ExtScript::interval()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _name;
|
return m_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::getPrefix()
|
QString ExtScript::name()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _prefix;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtScript::Redirect ExtScript::getRedirect()
|
QString ExtScript::prefix()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _redirect;
|
return m_prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtScript::getStrRedirect()
|
ExtScript::Redirect ExtScript::redirect()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
return m_redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtScript::strRedirect()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
switch (_redirect) {
|
switch (m_redirect) {
|
||||||
case stdout2stderr:
|
case stdout2stderr:
|
||||||
value = QString("stdout2stderr");
|
value = QString("stdout2stderr");
|
||||||
break;
|
break;
|
||||||
@ -129,7 +139,7 @@ bool ExtScript::hasOutput()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _output;
|
return m_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +147,16 @@ bool ExtScript::isActive()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
return _active;
|
return m_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::setApiVersion(const int _apiVersion)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||||
|
|
||||||
|
m_apiVersion = _apiVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -146,25 +165,25 @@ void ExtScript::setActive(const bool state)
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||||
|
|
||||||
_active = state;
|
m_active = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtScript::setComment(const QString comment)
|
void ExtScript::setComment(const QString _comment)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << comment;
|
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||||
|
|
||||||
_comment = comment;
|
m_comment = _comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtScript::setExec(const QString exec)
|
void ExtScript::setExecutable(const QString _executable)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Executable" << exec;
|
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
|
||||||
|
|
||||||
_exec = exec;
|
m_executable = _executable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -173,49 +192,58 @@ void ExtScript::setHasOutput(const bool state)
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||||
|
|
||||||
_output = state;
|
m_output = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtScript::setInterval(const int interval)
|
void ExtScript::setInterval(const int _interval)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Interval" << interval;
|
if (debug) qDebug() << PDEBUG << ":" << "Interval" << _interval;
|
||||||
if (interval <= 0) return;
|
if (_interval <= 0) return;
|
||||||
|
|
||||||
_interval = interval;
|
m_interval = _interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtScript::setName(const QString name)
|
void ExtScript::setName(const QString _name)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << name;
|
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||||
|
|
||||||
_name = name;
|
m_name = _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtScript::setPrefix(const QString prefix)
|
void ExtScript::setPrefix(const QString _prefix)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Prefix" << prefix;
|
if (debug) qDebug() << PDEBUG << ":" << "Prefix" << _prefix;
|
||||||
|
|
||||||
_prefix = prefix;
|
m_prefix = _prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtScript::setRedirect(const QString redirect)
|
void ExtScript::setRedirect(const Redirect _redirect)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << redirect;
|
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
|
||||||
|
|
||||||
if (redirect == QString("stdout2sdterr"))
|
m_redirect = _redirect;
|
||||||
_redirect = stdout2stderr;
|
}
|
||||||
else if (redirect == QString("stderr2sdtout"))
|
|
||||||
_redirect = stderr2stdout;
|
|
||||||
|
void ExtScript::setStrRedirect(const QString _redirect)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
|
||||||
|
|
||||||
|
if (_redirect == QString("stdout2sdterr"))
|
||||||
|
m_redirect = stdout2stderr;
|
||||||
|
else if (_redirect == QString("stderr2sdtout"))
|
||||||
|
m_redirect = stderr2stdout;
|
||||||
else
|
else
|
||||||
_redirect = nothing;
|
m_redirect = nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -223,23 +251,25 @@ void ExtScript::readConfiguration()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
for (int i=dirs.count()-1; i>=0; i--) {
|
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||||
if (!QDir(dirs[i]).entryList(QDir::Files).contains(fileName)) continue;
|
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||||
QSettings settings(dirs[i] + QDir::separator() + fileName, QSettings::IniFormat);
|
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
setName(settings.value(QString("Name"), _name).toString());
|
setName(settings.value(QString("Name"), m_name).toString());
|
||||||
setComment(settings.value(QString("Comment"), _comment).toString());
|
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||||
setExec(settings.value(QString("Exec"), _exec).toString());
|
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWESAPI).toInt());
|
||||||
setPrefix(settings.value(QString("X-AW-Prefix"), _prefix).toString());
|
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||||
setActive(settings.value(QString("X-AW-Active"), QVariant(_active).toString()).toString() == QString("true"));
|
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
|
||||||
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(_output).toString()).toString() == QString("true"));
|
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||||
setRedirect(settings.value(QString("X-AW-Redirect"), getStrRedirect()).toString());
|
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(m_output)).toString() == QString("true"));
|
||||||
setInterval(settings.value(QString("X-AW-Interval"), _interval).toInt());
|
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
|
||||||
|
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_output)
|
if (!m_output)
|
||||||
setRedirect(QString("stdout2stderr"));
|
setRedirect(stdout2stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -248,17 +278,17 @@ ExtScript::ScriptData ExtScript::run(const int time)
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
ScriptData response;
|
ScriptData response;
|
||||||
response.active = _active;
|
response.active = m_active;
|
||||||
response.name = _name;
|
response.name = m_name;
|
||||||
response.refresh = false;
|
response.refresh = false;
|
||||||
if (!_active) return response;
|
if (!m_active) return response;
|
||||||
if (time != _interval) return response;
|
if (time != m_interval) return response;
|
||||||
response.refresh = true;
|
response.refresh = true;
|
||||||
|
|
||||||
QStringList cmdList;
|
QStringList cmdList;
|
||||||
if (!_prefix.isEmpty())
|
if (!m_prefix.isEmpty())
|
||||||
cmdList.append(_prefix);
|
cmdList.append(m_prefix);
|
||||||
cmdList.append(_exec);
|
cmdList.append(m_executable);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
|
||||||
TaskResult process = runTask(cmdList.join(QChar(' ')));
|
TaskResult process = runTask(cmdList.join(QChar(' ')));
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
@ -266,7 +296,7 @@ ExtScript::ScriptData ExtScript::run(const int time)
|
|||||||
QString info = QString::number(process.exitCode) + QString(":") +
|
QString info = QString::number(process.exitCode) + QString(":") +
|
||||||
QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed();
|
QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed();
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
switch(_redirect) {
|
switch (m_redirect) {
|
||||||
case stdout2stderr:
|
case stdout2stderr:
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
|
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
|
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
|
||||||
@ -288,30 +318,31 @@ void ExtScript::showConfiguration()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
ui->lineEdit_name->setText(_name);
|
ui->lineEdit_name->setText(m_name);
|
||||||
ui->lineEdit_comment->setText(_comment);
|
ui->lineEdit_comment->setText(m_comment);
|
||||||
ui->lineEdit_command->setText(_exec);
|
ui->lineEdit_command->setText(m_executable);
|
||||||
ui->lineEdit_prefix->setText(_prefix);
|
ui->lineEdit_prefix->setText(m_prefix);
|
||||||
if (_active)
|
if (m_active)
|
||||||
ui->checkBox_active->setCheckState(Qt::Checked);
|
ui->checkBox_active->setCheckState(Qt::Checked);
|
||||||
else
|
else
|
||||||
ui->checkBox_active->setCheckState(Qt::Unchecked);
|
ui->checkBox_active->setCheckState(Qt::Unchecked);
|
||||||
if (_output)
|
if (m_output)
|
||||||
ui->checkBox_output->setCheckState(Qt::Checked);
|
ui->checkBox_output->setCheckState(Qt::Checked);
|
||||||
else
|
else
|
||||||
ui->checkBox_output->setCheckState(Qt::Unchecked);
|
ui->checkBox_output->setCheckState(Qt::Unchecked);
|
||||||
ui->comboBox_redirect->setCurrentIndex((int)_redirect);
|
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
|
||||||
ui->spinBox_interval->setValue(_interval);
|
ui->spinBox_interval->setValue(m_interval);
|
||||||
|
|
||||||
int ret = exec();
|
int ret = exec();
|
||||||
if (ret != 1) return;
|
if (ret != 1) return;
|
||||||
setName(ui->lineEdit_name->text());
|
setName(ui->lineEdit_name->text());
|
||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
setExec(ui->lineEdit_command->text());
|
setApiVersion(AWESAPI);
|
||||||
|
setExecutable(ui->lineEdit_command->text());
|
||||||
setPrefix(ui->lineEdit_prefix->text());
|
setPrefix(ui->lineEdit_prefix->text());
|
||||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||||
setHasOutput(ui->checkBox_output->checkState() == Qt::Checked);
|
setHasOutput(ui->checkBox_output->checkState() == Qt::Checked);
|
||||||
setRedirect(ui->comboBox_redirect->currentText());
|
setStrRedirect(ui->comboBox_redirect->currentText());
|
||||||
setInterval(ui->spinBox_interval->value());
|
setInterval(ui->spinBox_interval->value());
|
||||||
|
|
||||||
writeConfiguration();
|
writeConfiguration();
|
||||||
@ -322,9 +353,9 @@ void ExtScript::tryDelete()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
for (int i=0; i<dirs.count(); i++)
|
for (int i=0; i<m_dirs.count(); i++)
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << dirs[i] + QDir::separator() + fileName <<
|
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||||
QFile::remove(dirs[i] + QDir::separator() + fileName);
|
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -332,20 +363,21 @@ void ExtScript::writeConfiguration()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QSettings settings(dirs[0] + QDir::separator() + fileName, QSettings::IniFormat);
|
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
|
||||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||||
settings.setValue(QString("Name"), _name);
|
settings.setValue(QString("Name"), m_name);
|
||||||
settings.setValue(QString("Comment"), _comment);
|
settings.setValue(QString("Comment"), m_comment);
|
||||||
settings.setValue(QString("Exec"), _exec);
|
settings.setValue(QString("Exec"), m_executable);
|
||||||
settings.setValue(QString("X-AW-Prefix"), _prefix);
|
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||||
settings.setValue(QString("X-AW-Active"), QVariant(_active).toString());
|
settings.setValue(QString("X-AW-Prefix"), m_prefix);
|
||||||
settings.setValue(QString("X-AW-Output"), QVariant(_active).toString());
|
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||||
settings.setValue(QString("X-AW-Redirect"), getStrRedirect());
|
settings.setValue(QString("X-AW-Output"), QVariant(m_active).toString());
|
||||||
settings.setValue(QString("X-AW-Interval"), _interval);
|
settings.setValue(QString("X-AW-Redirect"), strRedirect());
|
||||||
|
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,15 @@ class ExtScript;
|
|||||||
class ExtScript : public QDialog
|
class ExtScript : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||||
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
|
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||||
|
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||||
|
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
||||||
|
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||||
|
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
|
||||||
|
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||||
|
Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Redirect {
|
enum Redirect {
|
||||||
@ -46,25 +55,28 @@ public:
|
|||||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||||
~ExtScript();
|
~ExtScript();
|
||||||
// get methods
|
// get methods
|
||||||
QString getComment();
|
int apiVersion();
|
||||||
QString getExec();
|
QString comment();
|
||||||
QString getFileName();
|
QString executable();
|
||||||
int getInterval();
|
QString fileName();
|
||||||
QString getName();
|
int interval();
|
||||||
QString getPrefix();
|
QString name();
|
||||||
Redirect getRedirect();
|
QString prefix();
|
||||||
QString getStrRedirect();
|
Redirect redirect();
|
||||||
|
QString strRedirect();
|
||||||
bool hasOutput();
|
bool hasOutput();
|
||||||
bool isActive();
|
bool isActive();
|
||||||
// set methods
|
// set methods
|
||||||
void setActive(const bool state = true);
|
void setApiVersion(const int _apiVersion = 0);
|
||||||
void setComment(const QString comment = QString("empty"));
|
void setActive(const bool _state = true);
|
||||||
void setExec(const QString exec = QString("/usr/bin/true"));
|
void setComment(const QString _comment = QString("empty"));
|
||||||
void setHasOutput(const bool state = true);
|
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||||
void setInterval(const int interval = 1);
|
void setHasOutput(const bool _state = true);
|
||||||
void setName(const QString name = QString("none"));
|
void setInterval(const int _interval = 1);
|
||||||
void setPrefix(const QString prefix = QString(""));
|
void setName(const QString _name = QString("none"));
|
||||||
void setRedirect(const QString redirect = QString("nothing"));
|
void setPrefix(const QString _prefix = QString(""));
|
||||||
|
void setRedirect(const Redirect _redirect = nothing);
|
||||||
|
void setStrRedirect(const QString _redirect = QString("nothing"));
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
@ -73,21 +85,21 @@ public slots:
|
|||||||
void tryDelete();
|
void tryDelete();
|
||||||
void writeConfiguration();
|
void writeConfiguration();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString fileName;
|
QString m_fileName;
|
||||||
QStringList dirs;
|
QStringList m_dirs;
|
||||||
bool debug;
|
bool debug;
|
||||||
Ui::ExtScript *ui;
|
Ui::ExtScript *ui;
|
||||||
// properties
|
// properties
|
||||||
bool _active = true;
|
int m_apiVersion = 0;
|
||||||
QString _comment = QString("empty");
|
bool m_active = true;
|
||||||
QString _exec = QString("/usr/bin/true");
|
QString m_comment = QString("empty");
|
||||||
int _interval = 1;
|
QString m_executable = QString("/usr/bin/true");
|
||||||
QString _name = QString("none");
|
int m_interval = 1;
|
||||||
bool _output = true;
|
QString m_name = QString("none");
|
||||||
QString _prefix = QString("");
|
bool m_output = true;
|
||||||
Redirect _redirect = nothing;
|
QString m_prefix = QString("");
|
||||||
|
Redirect m_redirect = nothing;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,6 +174,7 @@ QStringList ExtendedSysMon::sources() const
|
|||||||
source.append(QString("pkg"));
|
source.append(QString("pkg"));
|
||||||
source.append(QString("player"));
|
source.append(QString("player"));
|
||||||
source.append(QString("ps"));
|
source.append(QString("ps"));
|
||||||
|
source.append(QString("update"));
|
||||||
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Sources" << source;
|
if (debug) qDebug() << PDEBUG << ":" << "Sources" << source;
|
||||||
return source;
|
return source;
|
||||||
@ -601,6 +602,8 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
|||||||
QMap<QString, QVariant> ps = getPsStats();
|
QMap<QString, QVariant> ps = getPsStats();
|
||||||
for (int i=0; i<ps.keys().count(); i++)
|
for (int i=0; i<ps.keys().count(); i++)
|
||||||
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
|
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
|
||||||
|
} else if (source == QString("update")) {
|
||||||
|
setData(source, QString("value"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#define EMAIL "@PROJECT_CONTACT@"
|
#define EMAIL "@PROJECT_CONTACT@"
|
||||||
#define LICENSE "@PROJECT_LICENSE@"
|
#define LICENSE "@PROJECT_LICENSE@"
|
||||||
#define TRDPARTY_LICENSE "tasks,BSD,https://github.com/mhogomchungu/tasks"
|
#define TRDPARTY_LICENSE "tasks,BSD,https://github.com/mhogomchungu/tasks"
|
||||||
|
#define AWGIAPI 1
|
||||||
|
#define AWESAPI 1
|
||||||
|
|
||||||
// links
|
// links
|
||||||
#define HOMEPAGE "http://arcanis.name/projects/awesome-widgets/"
|
#define HOMEPAGE "http://arcanis.name/projects/awesome-widgets/"
|
||||||
|
Loading…
Reference in New Issue
Block a user