mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
add toggle panel configuration
This commit is contained in:
parent
d28d7156ce
commit
2c35031549
@ -165,16 +165,34 @@ QList<Plasma::Containment *> DesktopPanel::getPanels()
|
|||||||
if (debug) qDebug() << "[PTM-DP]" << "[getPanels]";
|
if (debug) qDebug() << "[PTM-DP]" << "[getPanels]";
|
||||||
|
|
||||||
QList<Plasma::Containment *> panels;
|
QList<Plasma::Containment *> panels;
|
||||||
for (int i=0; i<containment()->corona()->containments().count(); i++) {
|
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)
|
if (containment()->corona()->containments()[i]->containmentType() == Plasma::Containment::PanelContainment)
|
||||||
panels.append(containment()->corona()->containments()[i]);
|
panels.append(containment()->corona()->containments()[i]);
|
||||||
}
|
|
||||||
|
|
||||||
return panels;
|
return panels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString DesktopPanel::panelLocationToStr(Plasma::Location loc)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[PTM-DP]" << "[panelLocationToStr]";
|
||||||
|
if (debug) qDebug() << "[PTM-DP]" << "[panelLocationToStr]" << ":" << "Location" << loc;
|
||||||
|
|
||||||
|
switch(loc) {
|
||||||
|
case Plasma::TopEdge:
|
||||||
|
return i18n("Top Edge");
|
||||||
|
case Plasma::BottomEdge:
|
||||||
|
return i18n("Bottom Edge");
|
||||||
|
case Plasma::LeftEdge:
|
||||||
|
return i18n("Left Edge");
|
||||||
|
case Plasma::RightEdge:
|
||||||
|
return i18n("Right Edge");
|
||||||
|
default:
|
||||||
|
return i18n("Unknown Position (%1)", loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString DesktopPanel::parsePattern(const QString rawLine, const int num)
|
QString DesktopPanel::parsePattern(const QString rawLine, const int num)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[PTM-DP]" << "[parsePattern]";
|
if (debug) qDebug() << "[PTM-DP]" << "[parsePattern]";
|
||||||
@ -257,6 +275,10 @@ void DesktopPanel::changePanelsState()
|
|||||||
|
|
||||||
QList<Plasma::Containment *> panels = getPanels();
|
QList<Plasma::Containment *> panels = getPanels();
|
||||||
for (int i=0; i<panels.count(); i++) {
|
for (int i=0; i<panels.count(); i++) {
|
||||||
|
if ((configuration[QString("panels")].split(QChar(','))
|
||||||
|
.contains(QString::number(i))) ||
|
||||||
|
(configuration[QString("panels")] == QString("-1")))
|
||||||
|
continue;
|
||||||
bool wasVisible = panels[i]->view()->isVisible();
|
bool wasVisible = panels[i]->view()->isVisible();
|
||||||
int winId = panels[i]->view()->winId();
|
int winId = panels[i]->view()->winId();
|
||||||
if (wasVisible) {
|
if (wasVisible) {
|
||||||
@ -275,7 +297,7 @@ void DesktopPanel::changePanelsState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DesktopPanel::setCurrentDesktop(const int number)
|
void DesktopPanel::setCurrentDesktop(const int number)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]";
|
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]";
|
||||||
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]" << "Set desktop" << number + 1;
|
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]" << "Set desktop" << number + 1;
|
||||||
@ -284,12 +306,7 @@ int DesktopPanel::setCurrentDesktop(const int number)
|
|||||||
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]" << "Run cmd " << cmd;
|
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]" << "Run cmd " << cmd;
|
||||||
|
|
||||||
QProcess command;
|
QProcess command;
|
||||||
command.start(cmd);
|
command.startDetached(cmd);
|
||||||
command.waitForFinished(-1);
|
|
||||||
int status = command.exitCode();
|
|
||||||
if (debug) qDebug() << "[PTM-DP]" << "[setCurrentDesktop]" << "Cmd returns " << status;
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -335,6 +352,8 @@ void DesktopPanel::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
uiAppConfig.setupUi(appWidget);
|
uiAppConfig.setupUi(appWidget);
|
||||||
QWidget *configWidget = new QWidget;
|
QWidget *configWidget = new QWidget;
|
||||||
uiWidConfig.setupUi(configWidget);
|
uiWidConfig.setupUi(configWidget);
|
||||||
|
QWidget *toggleWidget = new QWidget;
|
||||||
|
uiToggleConfig.setupUi(toggleWidget);
|
||||||
|
|
||||||
if (configuration[QString("background")].toInt() == 0)
|
if (configuration[QString("background")].toInt() == 0)
|
||||||
uiWidConfig.checkBox_background->setCheckState(Qt::Unchecked);
|
uiWidConfig.checkBox_background->setCheckState(Qt::Unchecked);
|
||||||
@ -389,8 +408,22 @@ void DesktopPanel::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
else if (fontStyle == "italic")
|
else if (fontStyle == "italic")
|
||||||
uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(1);
|
uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(1);
|
||||||
|
|
||||||
|
uiToggleConfig.listWidget_list->clear();
|
||||||
|
QList<Plasma::Containment *> panels = getPanels();
|
||||||
|
for (int i=0; i<panels.count(); i++) {
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(panelLocationToStr(panels[i]->location()), uiToggleConfig.listWidget_list);
|
||||||
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||||
|
if ((configuration[QString("panels")].split(QChar(','))
|
||||||
|
.contains(QString::number(i))) ||
|
||||||
|
(configuration[QString("panels")] == QString("-1")))
|
||||||
|
item->setCheckState(Qt::Checked);
|
||||||
|
else
|
||||||
|
item->setCheckState(Qt::Unchecked);
|
||||||
|
}
|
||||||
|
|
||||||
parent->addPage(configWidget, i18n("Widget"), Applet::icon());
|
parent->addPage(configWidget, i18n("Widget"), Applet::icon());
|
||||||
parent->addPage(appWidget, i18n("Appearance"), QString("preferences-desktop-theme"));
|
parent->addPage(appWidget, i18n("Appearance"), QString("preferences-desktop-theme"));
|
||||||
|
parent->addPage(toggleWidget, i18n("Toggle panels"), QString("plasma"));
|
||||||
|
|
||||||
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
||||||
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
|
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
|
||||||
@ -424,6 +457,15 @@ void DesktopPanel::configAccepted()
|
|||||||
cg.writeEntry("fontColor", uiAppConfig.kcolorcombo_fontColorInactive->color().name());
|
cg.writeEntry("fontColor", uiAppConfig.kcolorcombo_fontColorInactive->color().name());
|
||||||
cg.writeEntry("fontWeight", uiAppConfig.spinBox_fontWeightInactive->value());
|
cg.writeEntry("fontWeight", uiAppConfig.spinBox_fontWeightInactive->value());
|
||||||
cg.writeEntry("fontStyle", uiAppConfig.comboBox_fontStyleInactive->currentText());
|
cg.writeEntry("fontStyle", uiAppConfig.comboBox_fontStyleInactive->currentText());
|
||||||
|
|
||||||
|
QStringList indexes;
|
||||||
|
for (int i=0; i<uiToggleConfig.listWidget_list->count(); i++)
|
||||||
|
if (uiToggleConfig.listWidget_list->item(i)->checkState() == Qt::Checked)
|
||||||
|
indexes.append(QString::number(i));
|
||||||
|
if (indexes.count() == uiToggleConfig.listWidget_list->count())
|
||||||
|
cg.writeEntry("panels", QString("-1"));
|
||||||
|
else
|
||||||
|
cg.writeEntry("panels", indexes.join(QChar(',')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -439,6 +481,7 @@ void DesktopPanel::configChanged()
|
|||||||
configuration[QString("layout")] = cg.readEntry("layout", "0");
|
configuration[QString("layout")] = cg.readEntry("layout", "0");
|
||||||
configuration[QString("leftStretch")] = cg.readEntry("leftStretch", "2");
|
configuration[QString("leftStretch")] = cg.readEntry("leftStretch", "2");
|
||||||
configuration[QString("mark")] = cg.readEntry("mark", "¤");
|
configuration[QString("mark")] = cg.readEntry("mark", "¤");
|
||||||
|
configuration[QString("panels")] = cg.readEntry("panels", "-1");
|
||||||
configuration[QString("pattern")] = cg.readEntry("pattern", "[$mark$number/$total: $name]");
|
configuration[QString("pattern")] = cg.readEntry("pattern", "[$mark$number/$total: $name]");
|
||||||
configuration[QString("rightStretch")] = cg.readEntry("rightStretch", "2");
|
configuration[QString("rightStretch")] = cg.readEntry("rightStretch", "2");
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <Plasma/Label>
|
#include <Plasma/Label>
|
||||||
|
|
||||||
#include <ui_appearance.h>
|
#include <ui_appearance.h>
|
||||||
|
#include <ui_toggle.h>
|
||||||
#include <ui_widget.h>
|
#include <ui_widget.h>
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public slots:
|
|||||||
void configChanged();
|
void configChanged();
|
||||||
// events
|
// events
|
||||||
void changePanelsState();
|
void changePanelsState();
|
||||||
int setCurrentDesktop(const int number);
|
void setCurrentDesktop(const int number);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void reinit();
|
void reinit();
|
||||||
@ -82,6 +83,7 @@ private:
|
|||||||
// functions
|
// functions
|
||||||
QStringList getDesktopNames();
|
QStringList getDesktopNames();
|
||||||
QList<Plasma::Containment *> getPanels();
|
QList<Plasma::Containment *> getPanels();
|
||||||
|
QString panelLocationToStr(Plasma::Location loc);
|
||||||
void updateText();
|
void updateText();
|
||||||
// ui
|
// ui
|
||||||
QGraphicsLinearLayout *layout;
|
QGraphicsLinearLayout *layout;
|
||||||
@ -95,6 +97,7 @@ private:
|
|||||||
// configuration interface
|
// configuration interface
|
||||||
Ui::AppearanceWidget uiAppConfig;
|
Ui::AppearanceWidget uiAppConfig;
|
||||||
Ui::ConfigWindow uiWidConfig;
|
Ui::ConfigWindow uiWidConfig;
|
||||||
|
Ui::ToggleWindow uiToggleConfig;
|
||||||
// configuration
|
// configuration
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
QStringList desktopNames;
|
QStringList desktopNames;
|
||||||
|
69
sources/desktop-panel/toggle.ui
Normal file
69
sources/desktop-panel/toggle.ui
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ToggleWindow</class>
|
||||||
|
<widget class="QWidget" name="ToggleWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>480</width>
|
||||||
|
<height>343</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>480</width>
|
||||||
|
<height>320</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string notr="true">Toggle Window</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>464</width>
|
||||||
|
<height>327</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_info">
|
||||||
|
<property name="text">
|
||||||
|
<string>To control panels please set widget shortcut.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="listWidget_list"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_widget">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>152</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue
Block a user