add raw support to hide panels

This commit is contained in:
arcan1s 2014-08-28 03:06:48 +04:00
parent 123cfcb475
commit d28d7156ce
5 changed files with 60 additions and 48 deletions

View File

@ -21,7 +21,7 @@ optdepends=("amarok: for music player monitor"
makedepends=('automoc4' 'cmake')
source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
install=${pkgname}.install
md5sums=('b5f8383c198e7059f463678f84a16273')
md5sums=('23b3f2f2d0a8bd87354d721cbf43ee22')
backup=('usr/share/config/extsysmon.conf')
changelog=CHANGELOG

View File

@ -22,17 +22,24 @@
#include <KDE/KConfigDialog>
#include <KDE/KGlobal>
#include <KDE/KStandardDirs>
#include <plasma/theme.h>
#include <KDE/Plasma/Containment>
#include <KDE/Plasma/Corona>
#include <KDE/Plasma/Theme>
#include <KDE/KWindowInfo>
#include <KDE/KWindowSystem>
#include <QDebug>
#include <QFile>
#include <QGraphicsLinearLayout>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <QProcessEnvironment>
#include <QTextCodec>
CustomPlasmaLabel::CustomPlasmaLabel(DesktopPanel *wid, const int num)
: Plasma::Label(wid)
: Plasma::Label(wid),
number(num),
widget(wid)
{
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
@ -42,10 +49,7 @@ CustomPlasmaLabel::CustomPlasmaLabel(DesktopPanel *wid, const int num)
else
debug = false;
if (debug) qDebug() << "[PTM-DP]" << "Init label" << num;
number = num;
widget = wid;
if (debug) qDebug() << "[PTM-DP]" << "Init label" << number;
}
@ -115,6 +119,7 @@ void DesktopPanel::init()
// read variables
configChanged();
connect(this, SIGNAL(activate()), this, SLOT(changePanelsState()));
}
@ -155,6 +160,21 @@ QStringList DesktopPanel::getDesktopNames()
}
QList<Plasma::Containment *> DesktopPanel::getPanels()
{
if (debug) qDebug() << "[PTM-DP]" << "[getPanels]";
QList<Plasma::Containment *> panels;
for (int i=0; i<containment()->corona()->containments().count(); i++) {
qDebug() << containment()->corona()->containments()[i]->containmentType();
if (containment()->corona()->containments()[i]->containmentType() == Plasma::Containment::PanelContainment)
panels.append(containment()->corona()->containments()[i]);
}
return panels;
}
QString DesktopPanel::parsePattern(const QString rawLine, const int num)
{
if (debug) qDebug() << "[PTM-DP]" << "[parsePattern]";
@ -231,6 +251,30 @@ void DesktopPanel::reinit()
}
void DesktopPanel::changePanelsState()
{
if (debug) qDebug() << "[PTM-DP]" << "[changePanelsState]";
QList<Plasma::Containment *> panels = getPanels();
for (int i=0; i<panels.count(); i++) {
bool wasVisible = panels[i]->view()->isVisible();
int winId = panels[i]->view()->winId();
if (wasVisible) {
if (debug) qDebug() << "[PTM-DP]" << "[changePanelsState]" << ":" << "Hide panel";
KWindowInfo oldInfo = KWindowSystem::windowInfo(winId, NET::WMState);
oldState = oldInfo.state();
panels[i]->view()->setVisible(false);
} else {
if (debug) qDebug() << "[PTM-DP]" << "[changePanelsState]" << ":" << "Show panel";
panels[i]->view()->setVisible(true);
KWindowSystem::clearState(winId, NET::KeepAbove);
KWindowSystem::setState(winId, oldState | NET::StaysOnTop);
KWindowSystem::setOnAllDesktops(winId, true);
}
}
}
int DesktopPanel::setCurrentDesktop(const int number)
{
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]";

View File

@ -68,7 +68,8 @@ public slots:
// configuration interface
void configAccepted();
void configChanged();
// event
// events
void changePanelsState();
int setCurrentDesktop(const int number);
private slots:
@ -80,6 +81,7 @@ protected:
private:
// functions
QStringList getDesktopNames();
QList<Plasma::Containment *> getPanels();
void updateText();
// ui
QGraphicsLinearLayout *layout;
@ -88,6 +90,7 @@ private:
bool debug;
// data engine
int currentDesktop;
int oldState;
Plasma::DataEngine *extsysmonEngine;
// configuration interface
Ui::AppearanceWidget uiAppConfig;

View File

@ -46,7 +46,6 @@ ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
setMinimumPollingInterval(333);
readConfiguration();
setKeys();
}
@ -164,43 +163,6 @@ QStringList ExtendedSysMon::sources() const
}
void ExtendedSysMon::setKeys()
{
if (debug) qDebug() << "[DE]" << "[setKeys]";
// custom
for (int i=0; i<configuration[QString("CUSTOM")].split(QString("@@"), QString::SkipEmptyParts).count(); i++)
setData(QString("custom"), QString("custom") + QString::number(i), QString(""));
// desktop
setData(QString("desktop"), QString("list"), QString(""));
setData(QString("desktop"), QString("number"), int(0));
setData(QString("desktop"), QString("currentName"), QString(""));
setData(QString("desktop"), QString("currentNumber"), int(0));
// gpu
setData(QString("gpu"), QString("GPU"), float(0.0));
// gputemp
setData(QString("gputemp"), QString("GPUTemp"), float(0.0));
// hddtemp
for (int i=0; i<configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts).count(); i++) {
QString key = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts)[i];
setData(QString("hddtemp"), key, float(0.0));
}
// pkg
for (int i=0; i<configuration[QString("PKGCMD")].split(QString(","), QString::SkipEmptyParts).count(); i++)
setData(QString("pkg"), QString("pkgCount") + QString::number(i), 0);
// player
setData(QString("player"), QString("album"), QString("unknown"));
setData(QString("player"), QString("artist"), QString("unknown"));
setData(QString("player"), QString("duration"), QString("0"));
setData(QString("player"), QString("progress"), QString("0"));
setData(QString("player"), QString("title"), QString("unknown"));
// ps
setData(QString("ps"), QString("psCount"), QString("0"));
setData(QString("ps"), QString("ps"), QString(""));
setData(QString("ps"), QString("psTotal"), QString("0"));
}
void ExtendedSysMon::readConfiguration()
{
if (debug) qDebug() << "[DE]" << "[readConfiguration]";
@ -559,8 +521,12 @@ int ExtendedSysMon::getUpgradeInfo(const QString cmd)
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Cmd returns" << process.exitCode;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
int count = 0;
for (int i=0; i<qoutput.split(QChar('\n')).count(); i++)
if (!qoutput.isEmpty())
count++;
return qoutput.split(QChar('\n')).count();
return count;
}

View File

@ -54,7 +54,6 @@ private:
QString getAutoGpu();
QString getAutoMpris();
QStringList getDesktopNames();
void setKeys();
void readConfiguration();
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
};