Use KConfigXT in PresentWindows Effect

REVIEW: 106407
This commit is contained in:
Dirk Sarpe 2012-09-13 08:49:13 +02:00 committed by Martin Gräßlin
parent ab305a1aba
commit 31fa04d653
7 changed files with 123 additions and 171 deletions

View file

@ -7,6 +7,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
presentwindows/presentwindows_proxy.cpp
)
kde4_add_kcfg_files(kwin4_effect_builtins_sources presentwindows/presentwindowsconfig.kcfgc)
# .desktop files
install( FILES
presentwindows/presentwindows.desktop
@ -21,6 +23,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
presentwindows/presentwindows_config.ui
)
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources presentwindows/presentwindowsconfig.kcfgc)
# .desktop files
install( FILES
presentwindows/presentwindows_config.desktop

View file

@ -20,12 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "presentwindows.h"
//KConfigSkeleton
#include "presentwindowsconfig.h"
#include <kactioncollection.h>
#include <kaction.h>
#include <klocale.h>
#include <kcolorscheme.h>
#include <kconfiggroup.h>
#include <kdebug.h>
#include <kglobalsettings.h>
@ -122,7 +121,7 @@ PresentWindowsEffect::~PresentWindowsEffect()
void PresentWindowsEffect::reconfigure(ReconfigureFlags)
{
KConfigGroup conf = effects->effectConfig("PresentWindows");
PresentWindowsConfig::self()->readConfig();
foreach (ElectricBorder border, m_borderActivate) {
effects->unreserveElectricBorder(border);
}
@ -131,43 +130,34 @@ void PresentWindowsEffect::reconfigure(ReconfigureFlags)
}
m_borderActivate.clear();
m_borderActivateAll.clear();
QList<int> borderList = QList<int>();
borderList.append(int(ElectricNone));
borderList = conf.readEntry("BorderActivate", borderList);
foreach (int i, borderList) {
foreach (int i, PresentWindowsConfig::borderActivate()) {
m_borderActivate.append(ElectricBorder(i));
effects->reserveElectricBorder(ElectricBorder(i));
}
borderList.clear();
borderList.append(int(ElectricTopLeft));
borderList = conf.readEntry("BorderActivateAll", borderList);
foreach (int i, borderList) {
foreach (int i, PresentWindowsConfig::borderActivateAll()) {
m_borderActivateAll.append(ElectricBorder(i));
effects->reserveElectricBorder(ElectricBorder(i));
}
borderList.clear();
borderList.append(int(ElectricNone));
borderList = conf.readEntry("BorderActivateClass", borderList);
foreach (int i, borderList) {
foreach (int i, PresentWindowsConfig::borderActivateClass()) {
m_borderActivateClass.append(ElectricBorder(i));
effects->reserveElectricBorder(ElectricBorder(i));
}
m_layoutMode = conf.readEntry("LayoutMode", int(LayoutNatural));
m_showCaptions = conf.readEntry("DrawWindowCaptions", true);
m_showIcons = conf.readEntry("DrawWindowIcons", true);
m_doNotCloseWindows = !conf.readEntry("AllowClosingWindows", true);
m_ignoreMinimized = conf.readEntry("IgnoreMinimized", false);
m_accuracy = conf.readEntry("Accuracy", 1) * 20;
m_fillGaps = conf.readEntry("FillGaps", true);
m_layoutMode = PresentWindowsConfig::layoutMode();
m_showCaptions = PresentWindowsConfig::drawWindowCaptions();
m_showIcons = PresentWindowsConfig::drawWindowIcons();
m_doNotCloseWindows = !PresentWindowsConfig::allowClosingWindows();
m_ignoreMinimized = PresentWindowsConfig::ignoreMinimized();
m_accuracy = PresentWindowsConfig::accuracy() * 20;
m_fillGaps = PresentWindowsConfig::fillGaps();
m_fadeDuration = double(animationTime(150));
m_showPanel = conf.readEntry("ShowPanel", false);
m_leftButtonWindow = (WindowMouseAction)conf.readEntry("LeftButtonWindow", (int)WindowActivateAction);
m_middleButtonWindow = (WindowMouseAction)conf.readEntry("MiddleButtonWindow", (int)WindowNoAction);
m_rightButtonWindow = (WindowMouseAction)conf.readEntry("RightButtonWindow", (int)WindowExitAction);
m_leftButtonDesktop = (DesktopMouseAction)conf.readEntry("LeftButtonDesktop", (int)DesktopExitAction);
m_middleButtonDesktop = (DesktopMouseAction)conf.readEntry("MiddleButtonDesktop", (int)DesktopNoAction);
m_rightButtonDesktop = (DesktopMouseAction)conf.readEntry("RightButtonDesktop", (int)DesktopNoAction);
m_dragToClose = conf.readEntry("DragToClose", false);
m_showPanel = PresentWindowsConfig::showPanel();
m_leftButtonWindow = (WindowMouseAction)PresentWindowsConfig::leftButtonWindow();
m_middleButtonWindow = (WindowMouseAction)PresentWindowsConfig::middleButtonWindow();
m_rightButtonWindow = (WindowMouseAction)PresentWindowsConfig::rightButtonWindow();
m_leftButtonDesktop = (DesktopMouseAction)PresentWindowsConfig::leftButtonDesktop();
m_middleButtonDesktop = (DesktopMouseAction)PresentWindowsConfig::middleButtonDesktop();
m_rightButtonDesktop = (DesktopMouseAction)PresentWindowsConfig::rightButtonDesktop();
m_dragToClose = PresentWindowsConfig::dragToClose();
}
void* PresentWindowsEffect::proxy()

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc"/>
<group name="Effect-PresentWindows">
<entry name="LayoutMode" type="Int">
<default>0</default>
</entry>
<entry name="DrawWindowCaptions" type="Bool">
<default>true</default>
</entry>
<entry name="DrawWindowIcons" type="Bool">
<default>true</default>
</entry>
<entry name="AllowClosingWindows" type="Bool">
<default>true</default>
</entry>
<entry name="IgnoreMinimized" type="Bool">
<default>false</default>
</entry>
<entry name="ShowPanel" type="Bool">
<default>false</default>
</entry>
<entry name="Accuracy" type="Int">
<default>1</default>
</entry>
<entry name="FillGaps" type="Bool">
<default>true</default>
</entry>
<entry name="LeftButtonWindow" type="Int">
<default>1</default>
</entry>
<entry name="MiddleButtonWindow" type="Int">
<default>0</default>
</entry>
<entry name="RightButtonWindow" type="Int">
<default>2</default>
</entry>
<entry name="LeftButtonDesktop" type="Int">
<default>2</default>
</entry>
<entry name="MiddleButtonDesktop" type="Int">
<default>0</default>
</entry>
<entry name="RightButtonDesktop" type="Int">
<default>0</default>
</entry>
<entry name="DragToClose" type="Bool">
<default>false</default>
</entry>
<entry name="BorderActivate" type="IntList" />
<entry name="BorderActivateAll" type="IntList">
<default code="true">QList&lt;int&gt;() &lt;&lt; int(ElectricTopLeft)</default>
</entry>
<entry name="BorderActivateClass" type="IntList" />
</group>
</kcfg>

View file

@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "presentwindows_config.h"
// KConfigSkeleton
#include "presentwindowsconfig.h"
#include <kwineffects.h>
#include <kconfiggroup.h>
@ -70,21 +72,9 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV
m_ui->shortcutEditor->addCollection(m_actionCollection);
connect(m_ui->layoutCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(m_ui->displayTitleBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->displayIconBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->allowClosing, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->ignoreMinimizedBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->showPanelBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->accuracySlider, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->fillGapsBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
connect(m_ui->leftButtonWindowCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(m_ui->middleButtonWindowCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(m_ui->rightButtonWindowCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(m_ui->leftButtonDesktopCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(m_ui->middleButtonDesktopCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(m_ui->rightButtonDesktopCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
addConfig(PresentWindowsConfig::self(), m_ui);
load();
}
@ -95,113 +85,17 @@ PresentWindowsEffectConfig::~PresentWindowsEffectConfig()
m_ui->shortcutEditor->undoChanges();
}
void PresentWindowsEffectConfig::load()
{
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("PresentWindows");
int layoutMode = conf.readEntry("LayoutMode", int(PresentWindowsEffect::LayoutNatural));
m_ui->layoutCombo->setCurrentIndex(layoutMode);
bool displayTitle = conf.readEntry("DrawWindowCaptions", true);
m_ui->displayTitleBox->setChecked(displayTitle);
bool displayIcon = conf.readEntry("DrawWindowIcons", true);
m_ui->displayIconBox->setChecked(displayIcon);
bool allowClosing = conf.readEntry("AllowClosingWindows", true);
m_ui->allowClosing->setChecked(allowClosing);
bool ignoreMinimized = conf.readEntry("IgnoreMinimized", false);
m_ui->ignoreMinimizedBox->setChecked(ignoreMinimized);
bool showPanel = conf.readEntry("ShowPanel", false);
m_ui->showPanelBox->setChecked(showPanel);
int accuracy = conf.readEntry("Accuracy", 1);
m_ui->accuracySlider->setSliderPosition(accuracy);
bool fillGaps = conf.readEntry("FillGaps", true);
m_ui->fillGapsBox->setChecked(fillGaps);
int leftButtonWindow = conf.readEntry("LeftButtonWindow", int(PresentWindowsEffect::WindowActivateAction));
m_ui->leftButtonWindowCombo->setCurrentIndex(leftButtonWindow);
int middleButtonWindow = conf.readEntry("MiddleButtonWindow", int(PresentWindowsEffect::WindowNoAction));
m_ui->middleButtonWindowCombo->setCurrentIndex(middleButtonWindow);
int rightButtonWindow = conf.readEntry("RightButtonWindow", int(PresentWindowsEffect::WindowExitAction));
m_ui->rightButtonWindowCombo->setCurrentIndex(rightButtonWindow);
int leftButtonDesktop = conf.readEntry("LeftButtonDesktop", int(PresentWindowsEffect::DesktopExitAction));
m_ui->leftButtonDesktopCombo->setCurrentIndex(leftButtonDesktop);
int middleButtonDesktop = conf.readEntry("MiddleButtonDesktop", int(PresentWindowsEffect::DesktopNoAction));
m_ui->middleButtonDesktopCombo->setCurrentIndex(middleButtonDesktop);
int rightButtonDesktop = conf.readEntry("RightButtonDesktop", int(PresentWindowsEffect::DesktopNoAction));
m_ui->rightButtonDesktopCombo->setCurrentIndex(rightButtonDesktop);
emit changed(false);
}
void PresentWindowsEffectConfig::save()
{
KCModule::save();
KConfigGroup conf = EffectsHandler::effectConfig("PresentWindows");
int layoutMode = m_ui->layoutCombo->currentIndex();
conf.writeEntry("LayoutMode", layoutMode);
conf.writeEntry("DrawWindowCaptions", m_ui->displayTitleBox->isChecked());
conf.writeEntry("DrawWindowIcons", m_ui->displayIconBox->isChecked());
conf.writeEntry("AllowClosingWindows", m_ui->allowClosing->isChecked());
conf.writeEntry("IgnoreMinimized", m_ui->ignoreMinimizedBox->isChecked());
conf.writeEntry("ShowPanel", m_ui->showPanelBox->isChecked());
int accuracy = m_ui->accuracySlider->value();
conf.writeEntry("Accuracy", accuracy);
conf.writeEntry("FillGaps", m_ui->fillGapsBox->isChecked());
int leftButtonWindow = m_ui->leftButtonWindowCombo->currentIndex();
conf.writeEntry("LeftButtonWindow", leftButtonWindow);
int middleButtonWindow = m_ui->middleButtonWindowCombo->currentIndex();
conf.writeEntry("MiddleButtonWindow", middleButtonWindow);
int rightButtonWindow = m_ui->rightButtonWindowCombo->currentIndex();
conf.writeEntry("RightButtonWindow", rightButtonWindow);
int leftButtonDesktop = m_ui->leftButtonDesktopCombo->currentIndex();
conf.writeEntry("LeftButtonDesktop", leftButtonDesktop);
int middleButtonDesktop = m_ui->middleButtonDesktopCombo->currentIndex();
conf.writeEntry("MiddleButtonDesktop", middleButtonDesktop);
int rightButtonDesktop = m_ui->rightButtonDesktopCombo->currentIndex();
conf.writeEntry("RightButtonDesktop", rightButtonDesktop);
m_ui->shortcutEditor->save();
conf.sync();
emit changed(false);
EffectsHandler::sendReloadMessage("presentwindows");
}
void PresentWindowsEffectConfig::defaults()
{
m_ui->layoutCombo->setCurrentIndex(int(PresentWindowsEffect::LayoutNatural));
m_ui->displayTitleBox->setChecked(true);
m_ui->displayIconBox->setChecked(true);
m_ui->allowClosing->setChecked(true);
m_ui->ignoreMinimizedBox->setChecked(false);
m_ui->showPanelBox->setChecked(false);
m_ui->accuracySlider->setSliderPosition(1);
m_ui->fillGapsBox->setChecked(true);
m_ui->shortcutEditor->allDefault();
m_ui->leftButtonWindowCombo->setCurrentIndex(int(PresentWindowsEffect::WindowActivateAction));
m_ui->middleButtonWindowCombo->setCurrentIndex(int(PresentWindowsEffect::WindowNoAction));
m_ui->rightButtonWindowCombo->setCurrentIndex(int(PresentWindowsEffect::WindowExitAction));
m_ui->leftButtonDesktopCombo->setCurrentIndex(int(PresentWindowsEffect::DesktopExitAction));
m_ui->middleButtonDesktopCombo->setCurrentIndex(int(PresentWindowsEffect::DesktopNoAction));
m_ui->rightButtonDesktopCombo->setCurrentIndex(int(PresentWindowsEffect::DesktopNoAction));
emit changed(true);
KCModule::defaults();
}
} // namespace

View file

@ -46,7 +46,6 @@ public:
public slots:
virtual void save();
virtual void load();
virtual void defaults();
private:

View file

@ -37,7 +37,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="fillGapsBox">
<widget class="QCheckBox" name="kcfg_FillGaps">
<property name="text">
<string>Fill &amp;gaps</string>
</property>
@ -64,7 +64,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="accuracySlider">
<widget class="QSlider" name="kcfg_Accuracy">
<property name="minimumSize">
<size>
<width>130</width>
@ -125,12 +125,12 @@
<string>Left button:</string>
</property>
<property name="buddy">
<cstring>leftButtonWindowCombo</cstring>
<cstring>kcfg_LeftButtonWindow</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="leftButtonWindowCombo">
<widget class="KComboBox" name="kcfg_LeftButtonWindow">
<item>
<property name="text">
<string>No action</string>
@ -174,12 +174,12 @@
<string>Middle button:</string>
</property>
<property name="buddy">
<cstring>middleButtonWindowCombo</cstring>
<cstring>kcfg_MiddleButtonWindow</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="middleButtonWindowCombo">
<widget class="KComboBox" name="kcfg_MiddleButtonWindow">
<item>
<property name="text">
<string>No action</string>
@ -223,12 +223,12 @@
<string>Right button:</string>
</property>
<property name="buddy">
<cstring>rightButtonWindowCombo</cstring>
<cstring>kcfg_RightButtonWindow</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KComboBox" name="rightButtonWindowCombo">
<widget class="KComboBox" name="kcfg_RightButtonWindow">
<item>
<property name="text">
<string>No action</string>
@ -284,12 +284,12 @@
<string>Left button:</string>
</property>
<property name="buddy">
<cstring>leftButtonDesktopCombo</cstring>
<cstring>kcfg_LeftButtonDesktop</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="leftButtonDesktopCombo">
<widget class="KComboBox" name="kcfg_LeftButtonDesktop">
<item>
<property name="text">
<string>No action</string>
@ -318,12 +318,12 @@
<string>Middle button:</string>
</property>
<property name="buddy">
<cstring>middleButtonDesktopCombo</cstring>
<cstring>kcfg_MiddleButtonDesktop</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="middleButtonDesktopCombo">
<widget class="KComboBox" name="kcfg_MiddleButtonDesktop">
<item>
<property name="text">
<string>No action</string>
@ -352,12 +352,12 @@
<string>Right button:</string>
</property>
<property name="buddy">
<cstring>rightButtonDesktopCombo</cstring>
<cstring>kcfg_RightButtonDesktop</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KComboBox" name="rightButtonDesktopCombo">
<widget class="KComboBox" name="kcfg_RightButtonDesktop">
<item>
<property name="text">
<string>No action</string>
@ -398,40 +398,40 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>layoutCombo</cstring>
<cstring>kcfg_LayoutMode</cstring>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="displayTitleBox">
<widget class="QCheckBox" name="kcfg_DrawWindowCaptions">
<property name="text">
<string>Display window &amp;titles</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="displayIconBox">
<widget class="QCheckBox" name="kcfg_DrawWindowIcons">
<property name="text">
<string>Display window &amp;icons</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="ignoreMinimizedBox">
<widget class="QCheckBox" name="kcfg_IgnoreMinimized">
<property name="text">
<string>Ignore &amp;minimized windows</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="showPanelBox">
<widget class="QCheckBox" name="kcfg_ShowPanel">
<property name="text">
<string>Show &amp;panels</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="layoutCombo">
<widget class="KComboBox" name="kcfg_LayoutMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -456,7 +456,7 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="allowClosing">
<widget class="QCheckBox" name="kcfg_AllowClosingWindows">
<property name="text">
<string>Provide buttons to close the windows</string>
</property>
@ -481,13 +481,13 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>layoutCombo</tabstop>
<tabstop>displayTitleBox</tabstop>
<tabstop>displayIconBox</tabstop>
<tabstop>allowClosing</tabstop>
<tabstop>ignoreMinimizedBox</tabstop>
<tabstop>accuracySlider</tabstop>
<tabstop>fillGapsBox</tabstop>
<tabstop>kcfg_LayoutMode</tabstop>
<tabstop>kcfg_DrawWindowCaptions</tabstop>
<tabstop>kcfg_DrawWindowIcons</tabstop>
<tabstop>kcfg_AllowClosingWindows</tabstop>
<tabstop>kcfg_IgnoreMinimized</tabstop>
<tabstop>kcfg_Accuracy</tabstop>
<tabstop>kcfg_FillGaps</tabstop>
</tabstops>
<resources/>
<connections/>

View file

@ -0,0 +1,6 @@
File=presentwindows.kcfg
ClassName=PresentWindowsConfig
NameSpace=KWin
Singleton=true
Mutators=true
IncludeFiles=kwinglobals.h