mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
end work on core part. Now widget works normally
(except for configuration and appearance)
This commit is contained in:
parent
cce37d66e5
commit
c5a0ba3796
@ -37,7 +37,7 @@ endif ()
|
||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||
|
||||
add_subdirectory (ext-sysmon)
|
||||
add_subdirectory (extsysmon)
|
||||
if (BUILD_KDE4)
|
||||
add_subdirectory (awesome-widget-kde4)
|
||||
add_subdirectory (desktop-panel-kde4)
|
||||
|
@ -14,15 +14,15 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
../ext-sysmon
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../ext-sysmon)
|
||||
../extsysmon
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../extsysmon)
|
||||
|
||||
# set sources
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
||||
../ext-sysmon/extscript.cpp)
|
||||
../extsysmon/extscript.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
|
@ -197,7 +197,7 @@ void AwesomeWidget::init()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// dataengines
|
||||
extsysmonEngine = dataEngine(QString("ext-sysmon"));
|
||||
extsysmonEngine = dataEngine(QString("extsysmon"));
|
||||
sysmonEngine = dataEngine(QString("systemmonitor"));
|
||||
connect(sysmonEngine, SIGNAL(sourceAdded(QString)), this, SLOT(addDiskDevice(QString)));
|
||||
timeEngine = dataEngine(QString("time"));
|
||||
@ -258,7 +258,7 @@ void AwesomeWidget::replyRecieved(QNetworkReply *reply)
|
||||
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();
|
||||
|
@ -98,9 +98,6 @@
|
||||
<entry name="downTooltipColor" type="string">
|
||||
<default>#00ffff</default>
|
||||
</entry>
|
||||
<entry name="upTooltip" type="bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="upTooltipColor" type="string">
|
||||
<default>#ff00ff</default>
|
||||
</entry>
|
||||
|
@ -44,7 +44,38 @@ Item {
|
||||
"justify": Text.AlignJustify
|
||||
}
|
||||
// external
|
||||
property variant info: {
|
||||
property variant settings: {
|
||||
"customTime": plasmoid.configuration.customTime,
|
||||
"customUptime": plasmoid.configuration.customUptime,
|
||||
"tempUnits": plasmoid.configuration.tempUnits,
|
||||
"tempDevice": plasmoid.configuration.tempDevice,
|
||||
"fanDevice": plasmoid.configuration.fanDevice,
|
||||
"mount": plasmoid.configuration.mount,
|
||||
"hdd": plasmoid.configuration.hdd,
|
||||
"disk": plasmoid.configuration.disk,
|
||||
"customNetdev": plasmoid.configuration.customNetdev,
|
||||
"acOnline": plasmoid.configuration.acOnline,
|
||||
"acOffline": plasmoid.configuration.acOffline
|
||||
}
|
||||
property variant tooltipSettings: {
|
||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
||||
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
||||
"tooltipBackgroung": plasmoid.configuration.tooltipBackgroung,
|
||||
"cpuTooltip": plasmoid.configuration.cpuTooltip,
|
||||
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
|
||||
"memTooltip": plasmoid.configuration.memTooltip,
|
||||
"swapTooltip": plasmoid.configuration.swapTooltip,
|
||||
"downTooltip": plasmoid.configuration.downTooltip,
|
||||
"upTooltip": plasmoid.configuration.downTooltip,
|
||||
"batteryTooltip": plasmoid.configuration.batteryTooltip,
|
||||
"cpuTooltipColor": plasmoid.configuration.cpuTooltipColor,
|
||||
"cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor,
|
||||
"memTooltipColor": plasmoid.configuration.memTooltipColor,
|
||||
"swapTooltipColor": plasmoid.configuration.swapTooltipColor,
|
||||
"downTooltipColor": plasmoid.configuration.downTooltipColor,
|
||||
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
||||
"batteryTooltipColor": plasmoid.configuration.batteryTooltipColor,
|
||||
"batteryInTooltipColor": plasmoid.configuration.batteryInTooltipColor
|
||||
}
|
||||
property string pattern: plasmoid.configuration.text
|
||||
// signals
|
||||
@ -60,26 +91,29 @@ Item {
|
||||
id: systemmonitorDE
|
||||
engine: "systemmonitor"
|
||||
connectedSources: systemmonitorDE.sources
|
||||
interval: plasmoid.configuration.autoUpdateInterval
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
|
||||
if ((data.value == "N\\A") || (data.value == "")) return
|
||||
// update
|
||||
if (AWKeys.isReady()) AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: extsysmonDE
|
||||
engine: "ext-sysmon"
|
||||
engine: "extsysmon"
|
||||
connectedSources: extsysmonDE.sources
|
||||
interval: plasmoid.configuration.autoUpdateInterval
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
|
||||
// if (sourceName == "update") needUpdate()
|
||||
if ((data.value == "N\\A") || (data.value == "")) return
|
||||
if (AWKeys.isReady()) AWKeys.setDataBySource(sourceName, data, settings)
|
||||
// update
|
||||
if (sourceName == "update") needUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,10 +121,13 @@ Item {
|
||||
id: timeDE
|
||||
engine: "time"
|
||||
connectedSources: ["Local"]
|
||||
interval: plasmoid.configuration.autoUpdateInterval
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
|
||||
if ((data.value == "N\\A") || (data.value == "")) return
|
||||
if (AWKeys.isReady()) AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,6 +152,8 @@ Item {
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("[main::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(pattern, settings, tooltipSettings)
|
||||
// actions
|
||||
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
|
||||
plasmoid.setAction("updateText", i18n("Update text"), "stock-refresh")
|
||||
@ -124,7 +163,7 @@ Item {
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
|
||||
text.text = AWKeys.parsePattern(pattern, info)
|
||||
text.text = AWKeys.parsePattern(pattern)
|
||||
// update geometry
|
||||
text.update()
|
||||
height = text.contentHeight
|
||||
|
@ -17,8 +17,8 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
../../ext-sysmon
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../ext-sysmon
|
||||
../../extsysmon
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../extsysmon
|
||||
${Qt_INCLUDE}
|
||||
${Kf5_INCLUDE})
|
||||
|
||||
@ -27,7 +27,7 @@ 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
|
||||
../../ext-sysmon/extscript.cpp)
|
||||
../../extsysmon/extscript.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
|
||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
|
@ -41,8 +41,6 @@ AWKeys::AWKeys(QObject *parent)
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
initValues();
|
||||
}
|
||||
|
||||
|
||||
@ -52,11 +50,15 @@ AWKeys::~AWKeys()
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString pattern, const int maxTooltip)
|
||||
void AWKeys::initKeys(const QString pattern,
|
||||
const QMap<QString, QVariant> params,
|
||||
const QMap<QString, QVariant> tooltipParams)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// clear
|
||||
extScripts.clear();
|
||||
graphicalItems.clear();
|
||||
counts.clear();
|
||||
keys.clear();
|
||||
foundBars.clear();
|
||||
@ -64,25 +66,15 @@ void AWKeys::initKeys(const QString pattern, const int maxTooltip)
|
||||
toolTip = nullptr;
|
||||
|
||||
// init
|
||||
counts = getCounts();
|
||||
extScripts = getExtScripts();
|
||||
graphicalItems = getGraphicalItems();
|
||||
counts = getCounts(params);
|
||||
keys = dictKeys();
|
||||
foundBars = findGraphicalItems(pattern);
|
||||
foundKeys = findKeys(pattern);
|
||||
toolTip = new AWToolTip(this, maxTooltip);
|
||||
}
|
||||
toolTip = new AWToolTip(this, tooltipParams);
|
||||
|
||||
|
||||
void AWKeys::initValues()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// clear
|
||||
extScripts.clear();
|
||||
graphicalItems.clear();
|
||||
|
||||
// init
|
||||
extScripts = getExtScripts();
|
||||
graphicalItems = getGraphicalItems();
|
||||
ready = true;
|
||||
}
|
||||
|
||||
|
||||
@ -94,6 +86,14 @@ bool AWKeys::isDebugEnabled()
|
||||
}
|
||||
|
||||
|
||||
bool AWKeys::isReady()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return ready;
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::networkDevice(const QString custom)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -301,32 +301,6 @@ QStringList AWKeys::graphicalItemsInfo()
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::timeKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList keys;
|
||||
keys.append(QString("dddd"));
|
||||
keys.append(QString("ddd"));
|
||||
keys.append(QString("dd"));
|
||||
keys.append(QString("d"));
|
||||
keys.append(QString("MMMM"));
|
||||
keys.append(QString("MMM"));
|
||||
keys.append(QString("MM"));
|
||||
keys.append(QString("M"));
|
||||
keys.append(QString("yyyy"));
|
||||
keys.append(QString("yy"));
|
||||
keys.append(QString("hh"));
|
||||
keys.append(QString("h"));
|
||||
keys.append(QString("mm"));
|
||||
keys.append(QString("m"));
|
||||
keys.append(QString("ss"));
|
||||
keys.append(QString("s"));
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params)
|
||||
@ -351,10 +325,10 @@ void AWKeys::setDataBySource(const QString sourceName,
|
||||
for (int i=0; i<data.keys().count(); i++) {
|
||||
if (data.keys()[i] == QString("ac")) {
|
||||
values[QString("ac")] = data.keys()[i];
|
||||
// if (data[QString("ac")].toBool())
|
||||
// values[QString("ac")] = configuration[QString("acOnline")];
|
||||
// else
|
||||
// values[QString("ac")] = configuration[QString("acOffline")];
|
||||
if (data[QString("ac")].toBool())
|
||||
values[QString("ac")] = params[QString("acOnline")].toString();
|
||||
else
|
||||
values[QString("ac")] = params[QString("acOffline")].toString();
|
||||
} else {
|
||||
values[data.keys()[i]] = QString("%1").arg(data[data.keys()[i]].toFloat(), 3, 'f', 0);
|
||||
toolTip->setData(QString("bat"), data[data.keys()[i]].toFloat(), data[QString("ac")].toBool());
|
||||
@ -556,7 +530,7 @@ void AWKeys::setDataBySource(const QString sourceName,
|
||||
values[QString("isotime")] = data[QString("DateTime")].toDateTime().toString(Qt::ISODate);
|
||||
values[QString("shorttime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleShortDate);
|
||||
values[QString("longtime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleLongDate);
|
||||
QStringList _timeKeys = timeKeys();
|
||||
QStringList _timeKeys = getTimeKeys();
|
||||
values[QString("ctime")] = params[QString("customTime")].toString();
|
||||
for (int i=0; i<_timeKeys.count(); i++)
|
||||
values[QString("ctime")].replace(QString("$") + _timeKeys[i],
|
||||
@ -580,32 +554,6 @@ void AWKeys::setDataBySource(const QString sourceName,
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWKeys::getCounts()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> awCounts;
|
||||
awCounts[QString("cpu")] = numberCpus();
|
||||
awCounts[QString("custom")] = getExtScripts().count();
|
||||
// awCounts[QString("disk")] = configuration[QString("disk")].split(QString("@@")).count();
|
||||
// awCounts[QString("fan")] = configuration[QString("fanDevice")].split(QString("@@")).count();
|
||||
// awCounts[QString("hddtemp")] = configuration[QString("hdd")].split(QString("@@")).count();
|
||||
// awCounts[QString("mount")] = configuration[QString("mount")].split(QString("@@")).count();
|
||||
// awCounts[QString("pkg")] = deSettings[QString("PKGCMD")].split(QChar(',')).count();
|
||||
// awCounts[QString("temp")] = configuration[QString("tempDevice")].split(QString("@@")).count();
|
||||
// awCounts[QString("tooltip")] = 0;
|
||||
// awCounts[QString("tooltip")] += configuration[QString("cpuTooltip")].toInt();
|
||||
// awCounts[QString("tooltip")] += configuration[QString("cpuclTooltip")].toInt();
|
||||
// awCounts[QString("tooltip")] += configuration[QString("memTooltip")].toInt();
|
||||
// awCounts[QString("tooltip")] += configuration[QString("swapTooltip")].toInt();
|
||||
// awCounts[QString("tooltip")] += configuration[QString("downTooltip")].toInt();
|
||||
// awCounts[QString("tooltip")] += configuration[QString("batteryTooltip")].toInt();
|
||||
// awCounts[QString("tooltip")] = counts[QString("tooltip")] / 2;
|
||||
|
||||
return awCounts;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::findGraphicalItems(const QString pattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -639,6 +587,26 @@ QStringList AWKeys::findKeys(const QString pattern)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWKeys::getCounts(const QMap<QString, QVariant> params)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> awCounts;
|
||||
awCounts[QString("cpu")] = numberCpus();
|
||||
awCounts[QString("custom")] = extScripts.count();
|
||||
awCounts[QString("disk")] = params[QString("disk")].toString().split(QString("@@")).count();
|
||||
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("temp")] = params[QString("tempDevice")].toString().split(QString("@@")).count();
|
||||
|
||||
return awCounts;
|
||||
}
|
||||
|
||||
|
||||
QList<ExtScript *> AWKeys::getExtScripts()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -648,7 +616,7 @@ QList<ExtScript *> AWKeys::getExtScripts()
|
||||
QString localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||
QString("/plasma_engine_extsysmon/scripts");
|
||||
QDir localDirectory;
|
||||
if (localDirectory.mkpath(localDir))
|
||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||
@ -714,3 +682,29 @@ GraphicalItem *AWKeys::getItemByTag(const QString tag)
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getTimeKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList keys;
|
||||
keys.append(QString("dddd"));
|
||||
keys.append(QString("ddd"));
|
||||
keys.append(QString("dd"));
|
||||
keys.append(QString("d"));
|
||||
keys.append(QString("MMMM"));
|
||||
keys.append(QString("MMM"));
|
||||
keys.append(QString("MM"));
|
||||
keys.append(QString("M"));
|
||||
keys.append(QString("yyyy"));
|
||||
keys.append(QString("yy"));
|
||||
keys.append(QString("hh"));
|
||||
keys.append(QString("h"));
|
||||
keys.append(QString("mm"));
|
||||
keys.append(QString("m"));
|
||||
keys.append(QString("ss"));
|
||||
keys.append(QString("s"));
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
@ -37,9 +37,11 @@ public:
|
||||
AWKeys(QObject *parent = 0);
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE void initKeys(const QString pattern, const int maxTooltip);
|
||||
Q_INVOKABLE void initValues();
|
||||
Q_INVOKABLE void initKeys(const QString pattern,
|
||||
const QMap<QString, QVariant> params,
|
||||
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);
|
||||
@ -48,21 +50,22 @@ public:
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList extScriptsInfo();
|
||||
Q_INVOKABLE QStringList graphicalItemsInfo();
|
||||
Q_INVOKABLE QStringList timeKeys();
|
||||
Q_INVOKABLE void setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params);
|
||||
Q_INVOKABLE QMap<QString, QVariant> getCounts();
|
||||
Q_INVOKABLE QStringList findGraphicalItems(const QString pattern);
|
||||
Q_INVOKABLE QStringList findKeys(const QString pattern);
|
||||
|
||||
private:
|
||||
QMap<QString, QVariant> getCounts(const QMap<QString, QVariant> params);
|
||||
QList<ExtScript *> getExtScripts();
|
||||
QList<GraphicalItem *> getGraphicalItems();
|
||||
GraphicalItem *getItemByTag(const QString tag);
|
||||
QStringList getTimeKeys();
|
||||
AWToolTip *toolTip = nullptr;
|
||||
// variables
|
||||
bool debug = false;
|
||||
bool ready = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtScript *> extScripts;
|
||||
QStringList foundBars, foundKeys, keys;
|
||||
|
@ -24,9 +24,9 @@
|
||||
|
||||
|
||||
AWToolTip::AWToolTip(QObject *parent,
|
||||
const int maxCount)
|
||||
QMap<QString, QVariant> settings)
|
||||
: QObject(parent),
|
||||
m_maxCount(maxCount)
|
||||
m_settings(settings)
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
@ -41,13 +41,21 @@ AWToolTip::~AWToolTip()
|
||||
}
|
||||
|
||||
|
||||
QPixmap AWToolTip::image()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
|
||||
void AWToolTip::setData (const QString source, const float value, const bool ac)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (data[source].count() == 0)
|
||||
data[source].append(0.0);
|
||||
else if (data[source].count() > m_maxCount)
|
||||
else if (data[source].count() > m_settings[QString("tooltipNumber")].toInt())
|
||||
data[source].takeFirst();
|
||||
|
||||
if (ac)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class AWToolTip : public QObject
|
||||
@ -30,17 +31,17 @@ class AWToolTip : public QObject
|
||||
|
||||
public:
|
||||
AWToolTip(QObject *parent = 0,
|
||||
int maxCount = 0);
|
||||
QMap<QString, QVariant> m_settings = QMap<QString, QVariant>());
|
||||
~AWToolTip();
|
||||
|
||||
// Q_INVOKABLE QPixmap image();
|
||||
Q_INVOKABLE QPixmap image();
|
||||
void setData(const QString source, const float value,
|
||||
const bool ac = true);
|
||||
|
||||
private:
|
||||
// variables
|
||||
bool debug = false;
|
||||
int m_maxCount = 0;
|
||||
QMap<QString, QVariant> m_settings;
|
||||
QMap<QString, QList<float>> data;
|
||||
};
|
||||
|
||||
|
@ -44,10 +44,10 @@
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
|
||||
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
||||
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
|
||||
: Plasma::DataEngine(parent, args)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(args)
|
||||
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
@ -79,16 +79,14 @@ QString ExtendedSysMon::getAutoGpu()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString gpu = QString("disable");
|
||||
QString cmd = QString("lspci");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
QFile moduleFile(QString("/proc/modules"));
|
||||
if (!moduleFile.open(QIODevice::ReadOnly)) return gpu;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
if (qoutput.toLower().contains("nvidia"))
|
||||
gpu = QString("nvidia");
|
||||
else if (qoutput.toLower().contains("radeon"))
|
||||
QString output = moduleFile.readAll();
|
||||
if (output.contains(QString("fglrx")))
|
||||
gpu = QString("ati");
|
||||
else if (output.contains(QString("nvidia")))
|
||||
gpu = QString("nvidia");
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Device" << gpu;
|
||||
return gpu;
|
||||
@ -130,7 +128,7 @@ void ExtendedSysMon::initScripts()
|
||||
localDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
|
||||
QString("/plasma_engine_extsysmon/scripts");
|
||||
QDir localDirectory;
|
||||
if (localDirectory.mkpath(localDir))
|
||||
if ((!localDirectory.exists(localDir)) && (localDirectory.mkpath(localDir)))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation,
|
||||
@ -226,7 +224,7 @@ QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString
|
||||
else {
|
||||
QStringList deviceList = rawConfig[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
|
||||
QStringList devices;
|
||||
QRegExp diskRegexp = QRegExp("/dev/[hms]d[a-z]$");
|
||||
QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$");
|
||||
for (int i=0; i<deviceList.count(); i++)
|
||||
if ((QFile::exists(deviceList[i])) &&
|
||||
(diskRegexp.indexIn(deviceList[i]) > -1))
|
||||
@ -458,8 +456,9 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
||||
.arg(mpdPort);
|
||||
else if (playerName == QString("mpris")) {
|
||||
// players which supports mpris
|
||||
if (mpris == "auto")
|
||||
if (mpris == QString("auto"))
|
||||
mpris = getAutoMpris();
|
||||
if (mpris.isEmpty()) return info;
|
||||
cmd = QString("bash -c \"qdbus org.mpris.%1 /Player GetMetadata && qdbus org.mpris.%1 /Player PositionGet\"")
|
||||
.arg(mpris);
|
||||
}
|
||||
@ -598,9 +597,13 @@ bool ExtendedSysMon::updateSourceEvent(const QString &source)
|
||||
} else if (source == QString("netdev")) {
|
||||
setData(source, QString("value"), getNetworkDevice());
|
||||
} else if (source == QString("pkg")) {
|
||||
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++)
|
||||
setData(source, QString("pkgcount") + QString::number(i),
|
||||
getUpgradeInfo(configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts)[i]));
|
||||
if (pkgTimeUpdate > MSEC_IN_HOUR) {
|
||||
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++)
|
||||
setData(source, QString("pkgcount") + QString::number(i),
|
||||
getUpgradeInfo(configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts)[i]));
|
||||
pkgTimeUpdate = 0;
|
||||
}
|
||||
pkgTimeUpdate++;
|
||||
} else if (source == QString("player")) {
|
||||
QMap<QString, QVariant> player = getPlayerInfo(configuration[QString("PLAYER")],
|
||||
configuration[QString("MPDADDRESS")],
|
@ -18,6 +18,10 @@
|
||||
#ifndef EXTSYSMON_H
|
||||
#define EXTSYSMON_H
|
||||
|
||||
#ifndef MSEC_IN_HOUR
|
||||
#define MSEC_IN_HOUR 60*60*1000
|
||||
#endif /* MSEC_IN_HOUR */
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QProcess>
|
||||
|
||||
@ -55,6 +59,8 @@ private:
|
||||
QList<ExtScript *> externalScripts;
|
||||
QList<int> times;
|
||||
bool debug;
|
||||
// FIXME dirty hack to avoid update package information every second
|
||||
int pkgTimeUpdate = MSEC_IN_HOUR;
|
||||
// reread configuration
|
||||
QString getAllHdd();
|
||||
QString getAutoGpu();
|
@ -8,11 +8,11 @@ Icon=utilities-system-monitor
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_extsysmon
|
||||
X-Plasma-EngineName=ext-sysmon
|
||||
X-Plasma-EngineName=extsysmon
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=ext-sysmon
|
||||
X-KDE-PluginInfo-Name=extsysmon
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Category=System Information
|
||||
X-KDE-PluginInfo-Depends=
|
Loading…
Reference in New Issue
Block a user