mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
* remove panel hidding functions (comment in)
* remove ps calls from DE. Now processes are reading from /proc * remove qdbus calls from DE. Now mpris information is reading using native DBus functions * update graphicalitem in KDE4 TODO: * widgets resizing * tests and optimizations * update DE configuration for KDE4 package
This commit is contained in:
parent
d74c7cb030
commit
8055647f34
@ -77,11 +77,7 @@ QString GraphicalItem::image(const float value)
|
|||||||
view->resize(m_width + 5.0, m_height + 5.0);
|
view->resize(m_width + 5.0, m_height + 5.0);
|
||||||
|
|
||||||
// paint
|
// paint
|
||||||
<<<<<<< HEAD
|
|
||||||
switch(m_type) {
|
switch(m_type) {
|
||||||
=======
|
|
||||||
switch (_type) {
|
|
||||||
>>>>>>> 685c0390b48c75d113024c3b5e19450ec251a0a4
|
|
||||||
case Vertical:
|
case Vertical:
|
||||||
pen.setWidth(m_width);
|
pen.setWidth(m_width);
|
||||||
// inactive
|
// inactive
|
||||||
@ -208,11 +204,7 @@ QString GraphicalItem::strType()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
<<<<<<< HEAD
|
|
||||||
switch(m_type) {
|
switch(m_type) {
|
||||||
=======
|
|
||||||
switch (_type) {
|
|
||||||
>>>>>>> 685c0390b48c75d113024c3b5e19450ec251a0a4
|
|
||||||
case Vertical:
|
case Vertical:
|
||||||
value = QString("Vertical");
|
value = QString("Vertical");
|
||||||
break;
|
break;
|
||||||
|
@ -182,22 +182,22 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
// Row {
|
||||||
height: implicitHeight
|
// height: implicitHeight
|
||||||
width: parent.width
|
// width: parent.width
|
||||||
QtControls.Label {
|
// QtControls.Label {
|
||||||
height: parent.height
|
// height: parent.height
|
||||||
width: parent.width * 2 / 5
|
// width: parent.width * 2 / 5
|
||||||
horizontalAlignment: Text.AlignRight
|
// horizontalAlignment: Text.AlignRight
|
||||||
verticalAlignment: Text.AlignVCenter
|
// verticalAlignment: Text.AlignVCenter
|
||||||
text: i18n("Panels to be hidden")
|
// text: i18n("Panels to be hidden")
|
||||||
}
|
// }
|
||||||
QtControls.Button {
|
// QtControls.Button {
|
||||||
width: parent.width * 3 / 5
|
// width: parent.width * 3 / 5
|
||||||
text: i18n("Edit panels")
|
// text: i18n("Edit panels")
|
||||||
onClicked: cfg_panels = DPAdds.editPanelsToContol(plasmoid.configuration.panels)
|
// onClicked: cfg_panels = DPAdds.editPanelsToContol(plasmoid.configuration.panels)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
QtDialogs.ColorDialog {
|
QtDialogs.ColorDialog {
|
||||||
|
@ -147,7 +147,7 @@ Item {
|
|||||||
Plasmoid.onActivated: {
|
Plasmoid.onActivated: {
|
||||||
if (debug) console.log("[main::onActivated]")
|
if (debug) console.log("[main::onActivated]")
|
||||||
|
|
||||||
DPAdds.changePanelsState()
|
// DPAdds.changePanelsState()
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasmoid.onUserConfiguringChanged: {
|
Plasmoid.onUserConfiguringChanged: {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
#include <KNotifications/KNotification>
|
#include <KNotifications/KNotification>
|
||||||
#include <KWindowSystem/KWindowSystem>
|
#include <KWindowSystem/KWindowSystem>
|
||||||
#include <Plasma/Corona>
|
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -459,13 +458,11 @@ QList<Plasma::Containment *> DPAdds::getPanels()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
ScriptEngine *env = new ScriptEngine(this);
|
|
||||||
Plasma::Corona *corona = env->corona();
|
|
||||||
// Plasma::Corona *corona = new Plasma::Corona(this);
|
// Plasma::Corona *corona = new Plasma::Corona(this);
|
||||||
QList<Plasma::Containment *> panels;
|
QList<Plasma::Containment *> panels;
|
||||||
for (int i=0; i<corona->containments().count(); i++)
|
// for (int i=0; i<corona->containments().count(); i++)
|
||||||
if (corona->containments()[i]->containmentType() == Plasma::Types::ContainmentType::PanelContainment)
|
// if (corona->containments()[i]->containmentType() == Plasma::Types::ContainmentType::PanelContainment)
|
||||||
panels.append(corona->containments()[i]);
|
// panels.append(corona->containments()[i]);
|
||||||
// delete corona;
|
// delete corona;
|
||||||
|
|
||||||
return panels;
|
return panels;
|
||||||
|
@ -11,7 +11,7 @@ if (BUILD_KDE4)
|
|||||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||||
set (KDE_INCLUDE ${KDE4_INCLUDES})
|
set (KDE_INCLUDE ${KDE4_INCLUDES})
|
||||||
else ()
|
else ()
|
||||||
find_package (Qt5 REQUIRED COMPONENTS Network Widgets)
|
find_package (Qt5 REQUIRED COMPONENTS DBus Network Widgets)
|
||||||
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
|
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
|
||||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||||
find_package (KF5 REQUIRED COMPONENTS Plasma Service WindowSystem)
|
find_package (KF5 REQUIRED COMPONENTS Plasma Service WindowSystem)
|
||||||
@ -20,8 +20,10 @@ else ()
|
|||||||
include (KDECMakeSettings)
|
include (KDECMakeSettings)
|
||||||
include (KDECompilerSettings)
|
include (KDECompilerSettings)
|
||||||
|
|
||||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
|
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS}
|
||||||
|
${Qt5Network_DEFINITIONS} ${Qt5Widgets_DEFINITIONS})
|
||||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||||
|
${Qt5DBus_INCLUDE_DIRS}
|
||||||
${Qt5Network_INCLUDE_DIRS}
|
${Qt5Network_INCLUDE_DIRS}
|
||||||
${Qt5Widgets_INCLUDE_DIRS})
|
${Qt5Widgets_INCLUDE_DIRS})
|
||||||
set (KDE_INCLUDE ${Plasma_INCLUDE_DIR})
|
set (KDE_INCLUDE ${Plasma_INCLUDE_DIR})
|
||||||
@ -57,7 +59,8 @@ else ()
|
|||||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||||
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER} ${TASK_MOC_SOURCE})
|
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER} ${TASK_MOC_SOURCE})
|
||||||
target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} KF5::WindowSystem ${Qt5Network_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} KF5::WindowSystem
|
||||||
|
${Qt5DBus_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||||
kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
#include <Plasma/DataContainer>
|
#include <Plasma/DataContainer>
|
||||||
|
|
||||||
|
#include <QDBusArgument>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusConnectionInterface>
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -100,20 +104,17 @@ QString ExtendedSysMon::getAutoMpris()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString mpris;
|
QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, QString("ListNames"));
|
||||||
QString cmd = QString("bash -c \"qdbus 'org.mpris.MediaPlayer2.*'\"");
|
QList<QVariant> arguments = listServices.arguments();
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
|
||||||
TaskResult process = runTask(cmd);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
|
||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
for (int i=0; i<arguments.count(); i++) {
|
||||||
if (qoutput.split(QChar('\n'))[0].split(QChar('.')).count() > 3)
|
if (!arguments[i].toString().startsWith(QString("org.mpris.MediaPlayer2."))) continue;
|
||||||
mpris = qoutput.split(QChar('\n'))[0].split(QChar('.'))[3];
|
QString service = arguments[i].toString();
|
||||||
|
service.remove(QString("org.mpris.MediaPlayer2."));
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Player found" << mpris;
|
return QString();
|
||||||
return mpris;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -506,20 +507,37 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
info[QString("duration")] = QString("0");
|
info[QString("duration")] = QString("0");
|
||||||
info[QString("progress")] = QString("0");
|
info[QString("progress")] = QString("0");
|
||||||
info[QString("title")] = QString("unknown");
|
info[QString("title")] = QString("unknown");
|
||||||
QString cmd;
|
|
||||||
if (playerName == QString("mpd"))
|
if (playerName == QString("mpd"))
|
||||||
// mpd
|
// mpd
|
||||||
cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%1:%2\"")
|
return getPlayerMpdInfo(mpdAddress, mpdPort);
|
||||||
.arg(mpdAddress)
|
|
||||||
.arg(mpdPort);
|
|
||||||
else if (playerName == QString("mpris")) {
|
else if (playerName == QString("mpris")) {
|
||||||
// players which supports mpris
|
// players which supports mpris
|
||||||
if (mpris == QString("auto"))
|
if (mpris == QString("auto")) mpris = getAutoMpris();
|
||||||
mpris = getAutoMpris();
|
|
||||||
if (mpris.isEmpty()) return info;
|
if (mpris.isEmpty()) return info;
|
||||||
cmd = QString("bash -c \"qdbus org.mpris.%1 /Player GetMetadata && qdbus org.mpris.%1 /Player PositionGet\"")
|
return getPlayerMprisInfo(mpris);
|
||||||
.arg(mpris);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress,
|
||||||
|
const QString mpdPort)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
|
||||||
|
|
||||||
|
QMap<QString, QVariant> info;
|
||||||
|
info[QString("album")] = QString("unknown");
|
||||||
|
info[QString("artist")] = QString("unknown");
|
||||||
|
info[QString("duration")] = QString("0");
|
||||||
|
info[QString("progress")] = QString("0");
|
||||||
|
info[QString("title")] = QString("unknown");
|
||||||
|
|
||||||
|
QString cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%1:%2\"")
|
||||||
|
.arg(mpdAddress)
|
||||||
|
.arg(mpdPort);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
@ -528,38 +546,70 @@ QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
|
|
||||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
QString qstr = QString("");
|
QString qstr = QString("");
|
||||||
if (playerName == QString("mpd"))
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Album"))
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Album"))
|
info[QString("album")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
info[QString("album")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Artist"))
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Artist"))
|
info[QString("artist")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
info[QString("artist")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time")) {
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time")) {
|
info[QString("duration")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[0];
|
||||||
info[QString("duration")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[0];
|
info[QString("progress")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[1];
|
||||||
info[QString("progress")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[1];
|
} else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Title"))
|
||||||
} else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Title"))
|
info[QString("title")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
info[QString("title")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (playerName == QString("mpris"))
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("album"))
|
|
||||||
info[QString("album")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("artist"))
|
|
||||||
info[QString("artist")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time"))
|
|
||||||
info[QString("duration")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
|
||||||
info[QString("title")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
|
||||||
} else {
|
|
||||||
int time = qstr.toInt() / 1000;
|
|
||||||
info[QString("progress")] = QString::number(time);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QMap<QString, QVariant> ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << "MPRIS" << mpris;
|
||||||
|
|
||||||
|
QMap<QString, QVariant> info;
|
||||||
|
info[QString("album")] = QString("unknown");
|
||||||
|
info[QString("artist")] = QString("unknown");
|
||||||
|
info[QString("duration")] = 0;
|
||||||
|
info[QString("progress")] = 0;
|
||||||
|
info[QString("title")] = QString("unknown");
|
||||||
|
|
||||||
|
// init
|
||||||
|
QDBusArgument arg;
|
||||||
|
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||||
|
QDBusMessage response, request;
|
||||||
|
QVariantMap map;
|
||||||
|
|
||||||
|
// general information
|
||||||
|
request = QDBusMessage::createMethodCall(QString("org.mpris.MediaPlayer2.%1").arg(mpris),
|
||||||
|
QString("/Player"),
|
||||||
|
QString(""),
|
||||||
|
QString("GetMetadata"));
|
||||||
|
response = bus.call(request, QDBus::BlockWithGui);
|
||||||
|
if (response.arguments().size() == 0) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||||
|
} else {
|
||||||
|
arg = response.arguments()[0].value<QDBusArgument>();
|
||||||
|
arg >> map;
|
||||||
|
info[QString("album")] = map[QString("album")];
|
||||||
|
info[QString("artist")] = map[QString("artist")];
|
||||||
|
info[QString("duration")] = map[QString("time")];
|
||||||
|
info[QString("title")] = map[QString("title")];
|
||||||
|
}
|
||||||
|
|
||||||
|
// position
|
||||||
|
request = QDBusMessage::createMethodCall(QString("org.mpris.MediaPlayer2.%1").arg(mpris),
|
||||||
|
QString("/Player"),
|
||||||
|
QString(""),
|
||||||
|
QString("PositionGet"));
|
||||||
|
response = bus.call(request, QDBus::BlockWithGui);
|
||||||
|
if (response.arguments().size() == 0) {
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||||
|
} else
|
||||||
|
info[QString("progress")] = response.arguments()[0].toInt() / 1000;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -569,32 +619,24 @@ QMap<QString, QVariant> ExtendedSysMon::getPsStats()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
QStringList allDirectories = QDir(QString("/proc")).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||||
|
QStringList directories = allDirectories.filter(QRegExp(QString("(\\d+)")));
|
||||||
|
QStringList running;
|
||||||
|
|
||||||
|
for (int i=0; i<directories.count(); i++) {
|
||||||
|
QFile statusFile(directories[i] + QString("/status"));
|
||||||
|
if (!statusFile.open(QIODevice::ReadOnly)) continue;
|
||||||
|
QFile cmdFile(directories[i] + QString("/cmdline"));
|
||||||
|
if (!cmdFile.open(QIODevice::ReadOnly)) continue;
|
||||||
|
|
||||||
|
QString output = statusFile.readAll();
|
||||||
|
if (output.contains(QString("running"))) running.append(cmdFile.readAll());
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> psStats;
|
QMap<QString, QVariant> psStats;
|
||||||
QString cmd, qoutput;
|
psStats[QString("pscount")] = running.count();
|
||||||
cmd = QString("ps --no-headers -o command");
|
psStats[QString("ps")] = running.join(QString(","));
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
psStats[QString("pstotal")] = directories.count();
|
||||||
TaskResult process = runTask(cmd);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
|
||||||
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
|
||||||
QStringList psList;
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++)
|
|
||||||
if (!qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("ps ")))
|
|
||||||
psList.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
|
||||||
psStats[QString("pscount")] = psList.count();
|
|
||||||
psStats[QString("ps")] = psList.join(QString(","));
|
|
||||||
|
|
||||||
cmd = QString("ps -e --no-headers -o command");
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
|
||||||
process = runTask(cmd);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
|
||||||
if (process.exitCode != 0)
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
|
||||||
|
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
|
||||||
psStats[QString("pstotal")] = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count();
|
|
||||||
|
|
||||||
return psStats;
|
return psStats;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,10 @@ public:
|
|||||||
QMap<QString, QVariant> getPlayerInfo(const QString playerName,
|
QMap<QString, QVariant> getPlayerInfo(const QString playerName,
|
||||||
const QString mpdAddress = 0,
|
const QString mpdAddress = 0,
|
||||||
const QString mpdPort = 0,
|
const QString mpdPort = 0,
|
||||||
QString mpris = 0);
|
const QString mpris = 0);
|
||||||
|
QMap<QString, QVariant> getPlayerMpdInfo(const QString mpdAddress = 0,
|
||||||
|
const QString mpdPort = 0);
|
||||||
|
QMap<QString, QVariant> getPlayerMprisInfo(const QString mpris = 0);
|
||||||
QMap<QString, QVariant> getPsStats();
|
QMap<QString, QVariant> getPsStats();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user