Use KConfigXT in TrackMouse Effect
REVIEW: 106416
This commit is contained in:
parent
b8630d19ec
commit
6ac2014533
7 changed files with 63 additions and 40 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
trackmouse/trackmouse.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources trackmouse/trackmouseconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
trackmouse/trackmouse.desktop
|
||||
|
@ -26,6 +28,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
trackmouse/trackmouse_config.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources trackmouse/trackmouseconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
trackmouse/trackmouse_config.desktop
|
||||
|
|
|
@ -21,6 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "trackmouse.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "trackmouseconfig.h"
|
||||
|
||||
#include <QTime>
|
||||
#include <QMatrix4x4>
|
||||
|
||||
|
@ -32,7 +35,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <KDE/KConfigGroup>
|
||||
#include <KDE/KLocale>
|
||||
|
||||
#include <math.h>
|
||||
|
@ -84,14 +86,14 @@ TrackMouseEffect::~TrackMouseEffect()
|
|||
void TrackMouseEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
m_modifiers = 0;
|
||||
KConfigGroup conf = effects->effectConfig("TrackMouse");
|
||||
if (conf.readEntry("Shift", false))
|
||||
TrackMouseConfig::self()->readConfig();
|
||||
if (TrackMouseConfig::shift())
|
||||
m_modifiers |= Qt::ShiftModifier;
|
||||
if (conf.readEntry("Alt", false))
|
||||
if (TrackMouseConfig::alt())
|
||||
m_modifiers |= Qt::AltModifier;
|
||||
if (conf.readEntry("Control", true))
|
||||
if (TrackMouseConfig::control())
|
||||
m_modifiers |= Qt::ControlModifier;
|
||||
if (conf.readEntry("Meta", true))
|
||||
if (TrackMouseConfig::meta())
|
||||
m_modifiers |= Qt::MetaModifier;
|
||||
|
||||
if (m_modifiers) {
|
||||
|
|
21
effects/trackmouse/trackmouse.kcfg
Normal file
21
effects/trackmouse/trackmouse.kcfg
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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-TrackMouse">
|
||||
<entry name="Meta" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="Control" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="Alt" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="Shift" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -32,6 +32,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include "trackmouse_config.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "trackmouseconfig.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -49,12 +52,8 @@ TrackMouseEffectConfig::TrackMouseEffectConfig(QWidget* parent, const QVariantLi
|
|||
m_ui = new TrackMouseEffectConfigForm(this);
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_ui);
|
||||
connect(m_ui->alt, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||
connect(m_ui->control, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||
connect(m_ui->meta, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||
connect(m_ui->shift, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||
connect(m_ui->modifierRadio, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||
connect(m_ui->shortcutRadio, SIGNAL(clicked(bool)), SLOT(changed()));
|
||||
|
||||
addConfig(TrackMouseConfig::self(), m_ui);
|
||||
|
||||
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
||||
m_actionCollection->setConfigGroup("TrackMouse");
|
||||
|
@ -74,44 +73,36 @@ TrackMouseEffectConfig::~TrackMouseEffectConfig()
|
|||
{
|
||||
}
|
||||
|
||||
void TrackMouseEffectConfig::checkModifiers()
|
||||
{
|
||||
const bool modifiers = m_ui->kcfg_Shift->isChecked() || m_ui->kcfg_Alt->isChecked() ||
|
||||
m_ui->kcfg_Control->isChecked() || m_ui->kcfg_Meta->isChecked();
|
||||
m_ui->modifierRadio->setChecked(modifiers);
|
||||
m_ui->shortcutRadio->setChecked(!modifiers);
|
||||
}
|
||||
|
||||
void TrackMouseEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
if (KAction *a = qobject_cast<KAction*>(m_actionCollection->action("TrackMouse")))
|
||||
m_ui->shortcut->setKeySequence(a->globalShortcut().primary());
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("TrackMouse");
|
||||
m_ui->meta->setChecked(conf.readEntry("Meta", true));
|
||||
m_ui->control->setChecked(conf.readEntry("Control", true));
|
||||
m_ui->alt->setChecked(conf.readEntry("Alt", false));
|
||||
m_ui->shift->setChecked(conf.readEntry("Shift", false));
|
||||
const bool modifiers = m_ui->shift->isChecked() || m_ui->alt->isChecked() ||
|
||||
m_ui->control->isChecked() || m_ui->meta->isChecked();
|
||||
m_ui->modifierRadio->setChecked(modifiers);
|
||||
m_ui->shortcutRadio->setChecked(!modifiers);
|
||||
|
||||
checkModifiers();
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void TrackMouseEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("TrackMouse");
|
||||
conf.writeEntry("Shift", m_ui->modifierRadio->isChecked() && m_ui->shift->isChecked());
|
||||
conf.writeEntry("Alt", m_ui->modifierRadio->isChecked() && m_ui->alt->isChecked());
|
||||
conf.writeEntry("Control", m_ui->modifierRadio->isChecked() && m_ui->control->isChecked());
|
||||
conf.writeEntry("Meta", m_ui->modifierRadio->isChecked() && m_ui->meta->isChecked());
|
||||
KCModule::save();
|
||||
m_actionCollection->writeSettings();
|
||||
conf.sync();
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("trackmouse");
|
||||
}
|
||||
|
||||
void TrackMouseEffectConfig::defaults()
|
||||
{
|
||||
KCModule::defaults();
|
||||
m_ui->shortcut->clearKeySequence();
|
||||
m_ui->meta->setChecked(true);
|
||||
m_ui->control->setChecked(true);
|
||||
m_ui->alt->setChecked(false);
|
||||
m_ui->shift->setChecked(false);
|
||||
emit changed(true);
|
||||
checkModifiers();
|
||||
}
|
||||
|
||||
void TrackMouseEffectConfig::shortcutChanged(const QKeySequence &seq)
|
||||
|
@ -122,7 +113,6 @@ void TrackMouseEffectConfig::shortcutChanged(const QKeySequence &seq)
|
|||
emit changed(true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "trackmouse_config.moc"
|
||||
|
|
|
@ -53,6 +53,7 @@ public slots:
|
|||
private slots:
|
||||
void shortcutChanged(const QKeySequence &seq);
|
||||
private:
|
||||
void checkModifiers();
|
||||
TrackMouseEffectConfigForm* m_ui;
|
||||
KActionCollection* m_actionCollection;
|
||||
};
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>311</width>
|
||||
<height>101</height>
|
||||
<width>327</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
|
@ -38,28 +38,28 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="alt">
|
||||
<widget class="QCheckBox" name="kcfg_Alt">
|
||||
<property name="text">
|
||||
<string>Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="control">
|
||||
<widget class="QCheckBox" name="kcfg_Control">
|
||||
<property name="text">
|
||||
<string>Ctrl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="shift">
|
||||
<widget class="QCheckBox" name="kcfg_Shift">
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="meta">
|
||||
<widget class="QCheckBox" name="kcfg_Meta">
|
||||
<property name="text">
|
||||
<string>Meta</string>
|
||||
</property>
|
||||
|
|
5
effects/trackmouse/trackmouseconfig.kcfgc
Normal file
5
effects/trackmouse/trackmouseconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=trackmouse.kcfg
|
||||
ClassName=TrackMouseConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue