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