Use KConfigXT in MouseMark Effect
REVIEW: 106414
This commit is contained in:
parent
65bb42a801
commit
ab305a1aba
7 changed files with 81 additions and 79 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
||||||
mousemark/mousemark.cpp
|
mousemark/mousemark.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
kde4_add_kcfg_files(kwin4_effect_builtins_sources mousemark/mousemarkconfig.kcfgc)
|
||||||
|
|
||||||
# .desktop files
|
# .desktop files
|
||||||
install( FILES
|
install( FILES
|
||||||
mousemark/mousemark.desktop
|
mousemark/mousemark.desktop
|
||||||
|
@ -20,6 +22,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
||||||
mousemark/mousemark_config.ui
|
mousemark/mousemark_config.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources mousemark/mousemarkconfig.kcfgc)
|
||||||
|
|
||||||
# .desktop files
|
# .desktop files
|
||||||
install( FILES
|
install( FILES
|
||||||
mousemark/mousemark_config.desktop
|
mousemark/mousemark_config.desktop
|
||||||
|
|
|
@ -21,15 +21,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "mousemark.h"
|
#include "mousemark.h"
|
||||||
|
|
||||||
|
// KConfigSkeleton
|
||||||
|
#include "mousemarkconfig.h"
|
||||||
|
|
||||||
#include <kwinconfig.h>
|
#include <kwinconfig.h>
|
||||||
#include <kwinglutils.h>
|
#include <kwinglutils.h>
|
||||||
|
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
#include <kglobal.h>
|
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kstandarddirs.h>
|
|
||||||
#include <kconfiggroup.h>
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -68,10 +68,10 @@ MouseMarkEffect::~MouseMarkEffect()
|
||||||
static int width_2 = 1;
|
static int width_2 = 1;
|
||||||
void MouseMarkEffect::reconfigure(ReconfigureFlags)
|
void MouseMarkEffect::reconfigure(ReconfigureFlags)
|
||||||
{
|
{
|
||||||
KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
|
MouseMarkConfig::self()->readConfig();
|
||||||
width = conf.readEntry("LineWidth", 3);
|
width = MouseMarkConfig::lineWidth();
|
||||||
width_2 = width / 2;
|
width_2 = width / 2;
|
||||||
color = conf.readEntry("Color", QColor(Qt::red));
|
color = MouseMarkConfig::color();
|
||||||
color.setAlphaF(1.0);
|
color.setAlphaF(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
effects/mousemark/mousemark.kcfg
Normal file
15
effects/mousemark/mousemark.kcfg
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?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-MouseMark">
|
||||||
|
<entry name="LineWidth" type="UInt">
|
||||||
|
<default>3</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="Color" type="Color">
|
||||||
|
<default>255,0,0</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
</kcfg>
|
|
@ -20,11 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "mousemark_config.h"
|
#include "mousemark_config.h"
|
||||||
|
|
||||||
|
// KConfigSkeleton
|
||||||
|
#include "mousemarkconfig.h"
|
||||||
|
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
|
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <kconfiggroup.h>
|
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <KShortcutsEditor>
|
#include <KShortcutsEditor>
|
||||||
|
@ -46,13 +48,13 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList
|
||||||
{
|
{
|
||||||
m_ui = new MouseMarkEffectConfigForm(this);
|
m_ui = new MouseMarkEffectConfigForm(this);
|
||||||
|
|
||||||
|
m_ui->kcfg_LineWidth->setSuffix(ki18np(" pixel", " pixels"));
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
layout->addWidget(m_ui);
|
layout->addWidget(m_ui);
|
||||||
|
|
||||||
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
addConfig(MouseMarkConfig::self(), m_ui);
|
||||||
connect(m_ui->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
|
||||||
connect(m_ui->comboColors, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
|
||||||
|
|
||||||
// Shortcut config. The shortcut belongs to the component "kwin"!
|
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||||
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
||||||
|
@ -78,48 +80,17 @@ MouseMarkEffectConfig::~MouseMarkEffectConfig()
|
||||||
m_ui->editor->undoChanges();
|
m_ui->editor->undoChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseMarkEffectConfig::load()
|
|
||||||
{
|
|
||||||
KCModule::load();
|
|
||||||
|
|
||||||
KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
|
|
||||||
|
|
||||||
int width = conf.readEntry("LineWidth", 3);
|
|
||||||
QColor color = conf.readEntry("Color", QColor(Qt::red));
|
|
||||||
m_ui->spinWidth->setValue(width);
|
|
||||||
m_ui->spinWidth->setSuffix(ki18np(" pixel", " pixels"));
|
|
||||||
m_ui->comboColors->setColor(color);
|
|
||||||
|
|
||||||
emit changed(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MouseMarkEffectConfig::save()
|
void MouseMarkEffectConfig::save()
|
||||||
{
|
{
|
||||||
kDebug(1212) << "Saving config of MouseMark" ;
|
kDebug(1212) << "Saving config of MouseMark" ;
|
||||||
//KCModule::save();
|
KCModule::save();
|
||||||
|
|
||||||
KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
|
|
||||||
|
|
||||||
conf.writeEntry("LineWidth", m_ui->spinWidth->value());
|
|
||||||
conf.writeEntry("Color", m_ui->comboColors->color());
|
|
||||||
|
|
||||||
m_actionCollection->writeSettings();
|
m_actionCollection->writeSettings();
|
||||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||||
|
|
||||||
conf.sync();
|
|
||||||
|
|
||||||
emit changed(false);
|
|
||||||
EffectsHandler::sendReloadMessage("mousemark");
|
EffectsHandler::sendReloadMessage("mousemark");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseMarkEffectConfig::defaults()
|
|
||||||
{
|
|
||||||
m_ui->spinWidth->setValue(3);
|
|
||||||
m_ui->comboColors->setColor(Qt::red);
|
|
||||||
emit changed(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#include "mousemark_config.moc"
|
#include "mousemark_config.moc"
|
||||||
|
|
|
@ -45,8 +45,6 @@ public:
|
||||||
virtual ~MouseMarkEffectConfig();
|
virtual ~MouseMarkEffectConfig();
|
||||||
|
|
||||||
virtual void save();
|
virtual void save();
|
||||||
virtual void load();
|
|
||||||
virtual void defaults();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MouseMarkEffectConfigForm* m_ui;
|
MouseMarkEffectConfigForm* m_ui;
|
||||||
|
|
|
@ -1,62 +1,71 @@
|
||||||
<ui version="4.0" >
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
<class>KWin::MouseMarkEffectConfigForm</class>
|
<class>KWin::MouseMarkEffectConfigForm</class>
|
||||||
<widget class="QWidget" name="KWin::MouseMarkEffectConfigForm" >
|
<widget class="QWidget" name="KWin::MouseMarkEffectConfigForm">
|
||||||
<layout class="QVBoxLayout" >
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>279</width>
|
||||||
|
<height>178</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox" >
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title" >
|
<property name="title">
|
||||||
<string>Appearance</string>
|
<string>Appearance</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" >
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" >
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>&Width:</string>
|
<string>&Width:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment" >
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>spinWidth</cstring>
|
<cstring>kcfg_LineWidth</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" >
|
<item row="0" column="1">
|
||||||
<widget class="KIntSpinBox" name="spinWidth" >
|
<widget class="KIntSpinBox" name="kcfg_LineWidth">
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum" >
|
<property name="minimum">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum" >
|
<property name="maximum">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="value" >
|
<property name="value">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" >
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2" >
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>&Color:</string>
|
<string>&Color:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment" >
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>comboColors</cstring>
|
<cstring>kcfg_Color</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1">
|
||||||
<widget class="KColorCombo" name="comboColors" >
|
<widget class="KColorCombo" name="kcfg_Color">
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy">
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -67,17 +76,17 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="KWin::GlobalShortcutsEditor" native="1" name="editor" />
|
<widget class="KWin::GlobalShortcutsEditor" name="editor" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>Draw with the mouse by holding Shift+Meta keys and moving the mouse.</string>
|
<string>Draw with the mouse by holding Shift+Meta keys and moving the mouse.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment" >
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap" >
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -98,7 +107,7 @@
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>KWin::GlobalShortcutsEditor</class>
|
<class>KWin::GlobalShortcutsEditor</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header location="global" >kwineffects.h</header>
|
<header location="global">kwineffects.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
|
5
effects/mousemark/mousemarkconfig.kcfgc
Normal file
5
effects/mousemark/mousemarkconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
File=mousemark.kcfg
|
||||||
|
ClassName=MouseMarkConfig
|
||||||
|
NameSpace=KWin
|
||||||
|
Singleton=true
|
||||||
|
Mutators=true
|
Loading…
Reference in a new issue