mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 06:45:48 +00:00
add raw support to hide panels
This commit is contained in:
@ -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]";
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user