Use KConfigXT in DesktopGrid effect
REVIEW: 106398
This commit is contained in:
parent
99fcab5c36
commit
66f568342a
7 changed files with 90 additions and 109 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
desktopgrid/desktopgrid.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources desktopgrid/desktopgridconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
desktopgrid/desktopgrid.desktop
|
||||
|
@ -20,6 +22,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
desktopgrid/desktopgrid_config.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources desktopgrid/desktopgridconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
desktopgrid/desktopgrid_config.desktop
|
||||
|
|
|
@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "desktopgrid.h"
|
||||
// KConfigSkeleton
|
||||
#include "desktopgridconfig.h"
|
||||
|
||||
#include "../presentwindows/presentwindows_proxy.h"
|
||||
|
||||
|
@ -30,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <kactioncollection.h>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <netwm_def.h>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
|
@ -100,29 +101,26 @@ DesktopGridEffect::~DesktopGridEffect()
|
|||
|
||||
void DesktopGridEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = effects->effectConfig("DesktopGrid");
|
||||
DesktopGridConfig::self()->readConfig();
|
||||
|
||||
foreach (ElectricBorder border, borderActivate) {
|
||||
effects->unreserveElectricBorder(border);
|
||||
}
|
||||
borderActivate.clear();
|
||||
QList<int> borderList = QList<int>();
|
||||
borderList.append(int(ElectricNone));
|
||||
borderList = conf.readEntry("BorderActivate", borderList);
|
||||
foreach (int i, borderList) {
|
||||
foreach (int i, DesktopGridConfig::borderActivate()) {
|
||||
borderActivate.append(ElectricBorder(i));
|
||||
effects->reserveElectricBorder(ElectricBorder(i));
|
||||
}
|
||||
|
||||
zoomDuration = animationTime(conf, "ZoomDuration", 300);
|
||||
zoomDuration = animationTime(DesktopGridConfig::zoomDuration() != 0 ? DesktopGridConfig::zoomDuration() : 300);
|
||||
timeline.setCurveShape(QTimeLine::EaseInOutCurve);
|
||||
timeline.setDuration(zoomDuration);
|
||||
|
||||
border = conf.readEntry("BorderWidth", 10);
|
||||
desktopNameAlignment = Qt::Alignment(conf.readEntry("DesktopNameAlignment", 0));
|
||||
layoutMode = conf.readEntry("LayoutMode", int(LayoutPager));
|
||||
customLayoutRows = conf.readEntry("CustomLayoutRows", 2);
|
||||
m_usePresentWindows = conf.readEntry("PresentWindows", true);
|
||||
border = DesktopGridConfig::borderWidth();
|
||||
desktopNameAlignment = Qt::Alignment(DesktopGridConfig::desktopNameAlignment());
|
||||
layoutMode = DesktopGridConfig::layoutMode();
|
||||
customLayoutRows = DesktopGridConfig::customLayoutRows();
|
||||
m_usePresentWindows = DesktopGridConfig::presentWindows();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
28
effects/desktopgrid/desktopgrid.kcfg
Normal file
28
effects/desktopgrid/desktopgrid.kcfg
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?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-DesktopGrid">
|
||||
<entry name="BorderActivate" type="IntList" />
|
||||
<entry name="ZoomDuration" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="BorderWidth" type="Int">
|
||||
<default>10</default>
|
||||
</entry>
|
||||
<entry name="DesktopNameAlignment" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="LayoutMode" type="Int">
|
||||
<default code="true">0</default>
|
||||
</entry>
|
||||
<entry name="CustomLayoutRows" type="Int">
|
||||
<default>2</default>
|
||||
</entry>
|
||||
<entry name="PresentWindows" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -20,6 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "desktopgrid_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "desktopgridconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <kconfiggroup.h>
|
||||
|
@ -60,37 +63,23 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariant
|
|||
|
||||
m_ui->shortcutEditor->addCollection(m_actionCollection);
|
||||
|
||||
m_alignmentItems.append(Qt::Alignment(0));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18nc("Desktop name alignment:", "Disabled"));
|
||||
m_alignmentItems.append(Qt::AlignHCenter | Qt::AlignTop);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top"));
|
||||
m_alignmentItems.append(Qt::AlignRight | Qt::AlignTop);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Right"));
|
||||
m_alignmentItems.append(Qt::AlignRight | Qt::AlignVCenter);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Right"));
|
||||
m_alignmentItems.append(Qt::AlignRight | Qt::AlignBottom);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Right"));
|
||||
m_alignmentItems.append(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom"));
|
||||
m_alignmentItems.append(Qt::AlignLeft | Qt::AlignBottom);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Left"));
|
||||
m_alignmentItems.append(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Left"));
|
||||
m_alignmentItems.append(Qt::AlignLeft | Qt::AlignTop);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Left"));
|
||||
m_alignmentItems.append(Qt::AlignCenter);
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Center"));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18nc("Desktop name alignment:", "Disabled"), QVariant(Qt::Alignment(0)));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top"), QVariant(Qt::AlignHCenter | Qt::AlignTop));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Right"), QVariant(Qt::AlignRight | Qt::AlignTop));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Right"), QVariant(Qt::AlignRight | Qt::AlignVCenter));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Right"), QVariant(Qt::AlignRight | Qt::AlignBottom));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom"), QVariant(Qt::AlignHCenter | Qt::AlignBottom));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Bottom-Left"), QVariant(Qt::AlignLeft | Qt::AlignBottom));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Left"), QVariant(Qt::AlignLeft | Qt::AlignVCenter));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Left"), QVariant(Qt::AlignLeft | Qt::AlignTop));
|
||||
m_ui->desktopNameAlignmentCombo->addItem(i18n("Center"), QVariant(Qt::AlignCenter));
|
||||
|
||||
connect(m_ui->zoomDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->borderWidthSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
addConfig(DesktopGridConfig::self(), m_ui);
|
||||
connect(m_ui->kcfg_LayoutMode, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutSelectionChanged()));
|
||||
connect(m_ui->desktopNameAlignmentCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->layoutCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->layoutCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(layoutSelectionChanged()));
|
||||
connect(m_ui->layoutRowsSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->shortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
|
||||
connect(m_ui->presentWindowsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
||||
|
||||
load();
|
||||
layoutSelectionChanged();
|
||||
}
|
||||
|
||||
DesktopGridEffectConfig::~DesktopGridEffectConfig()
|
||||
|
@ -99,83 +88,41 @@ DesktopGridEffectConfig::~DesktopGridEffectConfig()
|
|||
m_ui->shortcutEditor->undoChanges();
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
|
||||
|
||||
m_ui->zoomDurationSpin->setValue(conf.readEntry("ZoomDuration", 0));
|
||||
m_ui->zoomDurationSpin->setSuffix(ki18np(" millisecond", " milliseconds"));
|
||||
m_ui->borderWidthSpin->setValue(conf.readEntry("BorderWidth", 10));
|
||||
m_ui->borderWidthSpin->setSuffix(ki18np(" pixel", " pixels"));
|
||||
|
||||
Qt::Alignment alignment = Qt::Alignment(conf.readEntry("DesktopNameAlignment", 0));
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex(m_alignmentItems.indexOf(alignment));
|
||||
|
||||
int layoutMode = conf.readEntry("LayoutMode", int(DesktopGridEffect::LayoutPager));
|
||||
m_ui->layoutCombo->setCurrentIndex(layoutMode);
|
||||
layoutSelectionChanged();
|
||||
|
||||
m_ui->layoutRowsSpin->setValue(conf.readEntry("CustomLayoutRows", 2));
|
||||
m_ui->layoutRowsSpin->setSuffix(ki18np(" row", " rows"));
|
||||
|
||||
m_ui->presentWindowsCheckBox->setChecked(conf.readEntry("PresentWindows", true));
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::save()
|
||||
{
|
||||
DesktopGridConfig::setDesktopNameAlignment(m_ui->desktopNameAlignmentCombo->itemData(m_ui->desktopNameAlignmentCombo->currentIndex()).toInt());
|
||||
KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
|
||||
|
||||
conf.writeEntry("ZoomDuration", m_ui->zoomDurationSpin->value());
|
||||
conf.writeEntry("BorderWidth", m_ui->borderWidthSpin->value());
|
||||
|
||||
int alignment = m_ui->desktopNameAlignmentCombo->currentIndex();
|
||||
alignment = int(m_alignmentItems[alignment]);
|
||||
conf.writeEntry("DesktopNameAlignment", alignment);
|
||||
|
||||
int layoutMode = m_ui->layoutCombo->currentIndex();
|
||||
conf.writeEntry("LayoutMode", layoutMode);
|
||||
|
||||
conf.writeEntry("CustomLayoutRows", m_ui->layoutRowsSpin->value());
|
||||
|
||||
conf.writeEntry("PresentWindows", m_ui->presentWindowsCheckBox->isChecked());
|
||||
|
||||
m_ui->shortcutEditor->save();
|
||||
|
||||
conf.writeEntry("DesktopNameAlignment", DesktopGridConfig::desktopNameAlignment());
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("desktopgrid");
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::defaults()
|
||||
void DesktopGridEffectConfig::load()
|
||||
{
|
||||
m_ui->zoomDurationSpin->setValue(0);
|
||||
m_ui->borderWidthSpin->setValue(10);
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex(0);
|
||||
m_ui->layoutCombo->setCurrentIndex(int(DesktopGridEffect::LayoutPager));
|
||||
m_ui->layoutRowsSpin->setValue(2);
|
||||
m_ui->shortcutEditor->allDefault();
|
||||
m_ui->presentWindowsCheckBox->setChecked(true);
|
||||
emit changed(true);
|
||||
KCModule::load();
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex(m_ui->desktopNameAlignmentCombo->findData(QVariant(DesktopGridConfig::desktopNameAlignment())));
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::layoutSelectionChanged()
|
||||
{
|
||||
if (m_ui->layoutCombo->currentIndex() == DesktopGridEffect::LayoutCustom) {
|
||||
if (m_ui->kcfg_LayoutMode->currentIndex() == DesktopGridEffect::LayoutCustom) {
|
||||
m_ui->layoutRowsLabel->setEnabled(true);
|
||||
m_ui->layoutRowsSpin->setEnabled(true);
|
||||
m_ui->kcfg_CustomLayoutRows->setEnabled(true);
|
||||
} else {
|
||||
m_ui->layoutRowsLabel->setEnabled(false);
|
||||
m_ui->layoutRowsSpin->setEnabled(false);
|
||||
m_ui->kcfg_CustomLayoutRows->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopGridEffectConfig::defaults()
|
||||
{
|
||||
KCModule::defaults();
|
||||
m_ui->desktopNameAlignmentCombo->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "desktopgrid_config.moc"
|
||||
|
|
|
@ -55,7 +55,6 @@ private slots:
|
|||
private:
|
||||
DesktopGridEffectConfigForm* m_ui;
|
||||
KActionCollection* m_actionCollection;
|
||||
QList<Qt::Alignment> m_alignmentItems;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>zoomDurationSpin</cstring>
|
||||
<cstring>kcfg_ZoomDuration</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="KIntSpinBox" name="zoomDurationSpin">
|
||||
<widget class="KIntSpinBox" name="kcfg_ZoomDuration">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -58,12 +58,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>borderWidthSpin</cstring>
|
||||
<cstring>kcfg_BorderWidth</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="KIntSpinBox" name="borderWidthSpin">
|
||||
<widget class="KIntSpinBox" name="kcfg_BorderWidth">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -110,12 +110,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>layoutCombo</cstring>
|
||||
<cstring>kcfg_LayoutMode</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="KComboBox" name="layoutCombo">
|
||||
<widget class="KComboBox" name="kcfg_LayoutMode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -148,12 +148,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>layoutRowsSpin</cstring>
|
||||
<cstring>kcfg_CustomLayoutRows</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="KIntSpinBox" name="layoutRowsSpin">
|
||||
<widget class="KIntSpinBox" name="kcfg_CustomLayoutRows">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -185,7 +185,7 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="presentWindowsCheckBox">
|
||||
<widget class="QCheckBox" name="kcfg_PresentWindows">
|
||||
<property name="text">
|
||||
<string>Use Present Windows effect to layout the windows</string>
|
||||
</property>
|
||||
|
@ -234,11 +234,11 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>zoomDurationSpin</tabstop>
|
||||
<tabstop>borderWidthSpin</tabstop>
|
||||
<tabstop>kcfg_ZoomDuration</tabstop>
|
||||
<tabstop>kcfg_BorderWidth</tabstop>
|
||||
<tabstop>desktopNameAlignmentCombo</tabstop>
|
||||
<tabstop>layoutCombo</tabstop>
|
||||
<tabstop>layoutRowsSpin</tabstop>
|
||||
<tabstop>kcfg_LayoutMode</tabstop>
|
||||
<tabstop>kcfg_CustomLayoutRows</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
5
effects/desktopgrid/desktopgridconfig.kcfgc
Normal file
5
effects/desktopgrid/desktopgridconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=desktopgrid.kcfg
|
||||
ClassName=DesktopGridConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue