Use KConfigXT in MouseClick Effect
This commit is contained in:
parent
378a4f8fe4
commit
a6ab97172e
7 changed files with 86 additions and 116 deletions
|
@ -6,6 +6,7 @@
|
|||
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
||||
mouseclick/mouseclick.cpp
|
||||
)
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources mouseclick/mouseclickconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
|
@ -22,6 +23,8 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
mouseclick/mouseclick_config.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources mouseclick/mouseclickconfig.kcfgc)
|
||||
|
||||
install( FILES
|
||||
mouseclick/mouseclick_config.desktop
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
|
||||
|
|
|
@ -19,8 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "mouseclick.h"
|
||||
// KConfigSkeleton
|
||||
#include "mouseclickconfig.h"
|
||||
|
||||
#include <kwinconfig.h>
|
||||
#include <kwinglutils.h>
|
||||
|
||||
#include <KDE/KAction>
|
||||
|
@ -72,16 +73,16 @@ bool MouseClickEffect::supported()
|
|||
|
||||
void MouseClickEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("MouseClick");
|
||||
m_colors[0] = conf.readEntry("Color1", QColor(Qt::red));
|
||||
m_colors[1] = conf.readEntry("Color2", QColor(Qt::green));
|
||||
m_colors[2] = conf.readEntry("Color3", QColor(Qt::blue));
|
||||
m_lineWidth = conf.readEntry("LineWidth", 1.f);
|
||||
m_ringLife = conf.readEntry("RingLife", 300);
|
||||
m_ringMaxSize = conf.readEntry("RingSize", 20);
|
||||
m_ringCount = conf.readEntry("RingCount", 2);
|
||||
m_showText = conf.readEntry("ShowText", true);
|
||||
m_font = conf.readEntry("Font", QFont());
|
||||
MouseClickConfig::self()->readConfig();
|
||||
m_colors[0] = MouseClickConfig::color1();
|
||||
m_colors[1] = MouseClickConfig::color2();
|
||||
m_colors[2] = MouseClickConfig::color3();
|
||||
m_lineWidth = MouseClickConfig::lineWidth();
|
||||
m_ringLife = MouseClickConfig::ringLife();
|
||||
m_ringMaxSize = MouseClickConfig::ringSize();
|
||||
m_ringCount = MouseClickConfig::ringCount();
|
||||
m_showText = MouseClickConfig::showText();
|
||||
m_font = MouseClickConfig::font();
|
||||
}
|
||||
|
||||
void MouseClickEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
|
|
34
effects/mouseclick/mouseclick.kcfg
Normal file
34
effects/mouseclick/mouseclick.kcfg
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?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-MouseClick">
|
||||
<entry name="Color1" type="Color">
|
||||
<default code="true">QColor(Qt::red)</default>
|
||||
</entry>
|
||||
<entry name="Color2" type="Color">
|
||||
<default code="true">QColor(Qt::green)</default>
|
||||
</entry>
|
||||
<entry name="Color3" type="Color">
|
||||
<default code="true">QColor(Qt::blue)</default>
|
||||
</entry>
|
||||
<entry name="LineWidth" type="Double">
|
||||
<default>1.0</default>
|
||||
</entry>
|
||||
<entry name="RingLife" type="UInt">
|
||||
<default>300</default>
|
||||
</entry>
|
||||
<entry name="RingSize" type="UInt">
|
||||
<default>20</default>
|
||||
</entry>
|
||||
<entry name="RingCount" type="UInt">
|
||||
<default>2</default>
|
||||
</entry>
|
||||
<entry name="ShowText" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="Font" type="Font"/>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -19,12 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "mouseclick_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "mouseclickconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <KDE/KActionCollection>
|
||||
#include <KDE/KAction>
|
||||
#include <KDE/KConfigGroup>
|
||||
#include <KDE/KShortcutsEditor>
|
||||
|
||||
#include <QWidget>
|
||||
|
@ -48,15 +49,6 @@ MouseClickEffectConfig::MouseClickEffectConfig(QWidget* parent, const QVariantLi
|
|||
layout->addWidget(m_ui);
|
||||
|
||||
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
||||
connect(m_ui->button1_color_input, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->button2_color_input, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->button3_color_input, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->ring_line_width_input, SIGNAL(valueChanged(double)), this, SLOT(changed()));
|
||||
connect(m_ui->ring_duration_input, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->ring_radius_input, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->ring_count_input, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->showtext_input, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->font_input, SIGNAL(fontSelected(QFont)), this, SLOT(changed()));
|
||||
|
||||
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
||||
|
@ -67,6 +59,8 @@ MouseClickEffectConfig::MouseClickEffectConfig(QWidget* parent, const QVariantLi
|
|||
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Asterisk));
|
||||
|
||||
m_ui->editor->addCollection(m_actionCollection);
|
||||
|
||||
addConfig(MouseClickConfig::self(), m_ui);
|
||||
load();
|
||||
}
|
||||
|
||||
|
@ -76,87 +70,13 @@ MouseClickEffectConfig::~MouseClickEffectConfig()
|
|||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void MouseClickEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("MouseClick");
|
||||
|
||||
QColor color1 = conf.readEntry("Color1", QColor(Qt::red));
|
||||
QColor color2 = conf.readEntry("Color2", QColor(Qt::green));
|
||||
QColor color3 = conf.readEntry("Color3", QColor(Qt::blue));
|
||||
|
||||
float lineWidth = conf.readEntry("LineWidth", 1.f);
|
||||
float ringLife = conf.readEntry("RingLife", 300);
|
||||
float ringSize = conf.readEntry("RingSize", 20);
|
||||
|
||||
bool showText = conf.readEntry("ShowText", true);
|
||||
int ringCount = conf.readEntry("RingCount", 2);
|
||||
QFont font = conf.readEntry("Font", QFont());
|
||||
|
||||
m_ui->button1_color_input->setColor(color1);
|
||||
m_ui->button2_color_input->setColor(color2);
|
||||
m_ui->button3_color_input->setColor(color3);
|
||||
m_ui->ring_line_width_input->setValue(lineWidth);
|
||||
m_ui->ring_duration_input->setValue(ringLife);
|
||||
m_ui->ring_radius_input->setValue(ringSize);
|
||||
m_ui->ring_count_input->setValue(ringCount);
|
||||
|
||||
m_ui->showtext_input->setChecked(showText);
|
||||
m_ui->font_input->setFont(font);
|
||||
|
||||
m_ui->ring_line_width_input->setSuffix(i18n(" pixels"));
|
||||
m_ui->ring_duration_input->setSuffix(ki18np(" millisecond", " milliseconds"));
|
||||
m_ui->ring_radius_input->setSuffix(ki18np(" pixel", " pixels"));
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void MouseClickEffectConfig::save()
|
||||
{
|
||||
//KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("MouseClick");
|
||||
|
||||
conf.writeEntry("Color1", m_ui->button1_color_input->color());
|
||||
conf.writeEntry("Color2", m_ui->button2_color_input->color());
|
||||
conf.writeEntry("Color3", m_ui->button3_color_input->color());
|
||||
|
||||
conf.writeEntry("LineWidth", m_ui->ring_line_width_input->value());
|
||||
conf.writeEntry("RingLife", m_ui->ring_duration_input->value());
|
||||
conf.writeEntry("RingSize", m_ui->ring_radius_input->value());
|
||||
conf.writeEntry("RingCount", m_ui->ring_count_input->value());
|
||||
|
||||
conf.writeEntry("ShowText", m_ui->showtext_input->isChecked());
|
||||
conf.writeEntry("Font", m_ui->font_input->font());
|
||||
|
||||
m_actionCollection->writeSettings();
|
||||
KCModule::save();
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("mouseclick");
|
||||
}
|
||||
|
||||
void MouseClickEffectConfig::defaults()
|
||||
{
|
||||
m_ui->button1_color_input->setColor(Qt::red);
|
||||
m_ui->button2_color_input->setColor(Qt::green);
|
||||
m_ui->button3_color_input->setColor(Qt::blue);
|
||||
|
||||
m_ui->ring_line_width_input->setValue(1.f);
|
||||
m_ui->ring_duration_input->setValue(300);
|
||||
m_ui->ring_radius_input->setValue(20);
|
||||
m_ui->ring_count_input->setValue(2);
|
||||
|
||||
m_ui->showtext_input->setChecked(true);
|
||||
m_ui->font_input->setFont(QFont());
|
||||
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "mouseclick_config.moc"
|
||||
|
|
|
@ -45,8 +45,6 @@ public:
|
|||
virtual ~MouseClickEffectConfig();
|
||||
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
MouseClickEffectConfigForm* m_ui;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>292</width>
|
||||
<width>335</width>
|
||||
<height>378</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -22,7 +22,7 @@
|
|||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="1" column="1">
|
||||
<widget class="KColorCombo" name="button1_color_input">
|
||||
<widget class="KColorCombo" name="kcfg_Color1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -40,7 +40,7 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>button1_color_input</cstring>
|
||||
<cstring>kcfg_Color1</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -50,12 +50,12 @@
|
|||
<string>Middle Mouse Button Color:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>button2_color_input</cstring>
|
||||
<cstring>kcfg_Color2</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="KColorCombo" name="button2_color_input">
|
||||
<widget class="KColorCombo" name="kcfg_Color2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -70,12 +70,12 @@
|
|||
<string>Right Mouse Button Color:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>button3_color_input</cstring>
|
||||
<cstring>kcfg_Color3</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="KColorCombo" name="button3_color_input">
|
||||
<widget class="KColorCombo" name="kcfg_Color3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -103,28 +103,34 @@
|
|||
<string>Line Width:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>ring_line_width_input</cstring>
|
||||
<cstring>kcfg_LineWidth</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="KDoubleNumInput" name="ring_line_width_input">
|
||||
<widget class="KDoubleNumInput" name="kcfg_LineWidth">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> pixel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="KIntSpinBox" name="ring_duration_input">
|
||||
<widget class="KIntSpinBox" name="kcfg_RingLife">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> msec</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
|
@ -139,7 +145,7 @@
|
|||
<string>Ring Duration:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>ring_duration_input</cstring>
|
||||
<cstring>kcfg_RingLife</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -149,18 +155,21 @@
|
|||
<string>Ring Radius:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>ring_radius_input</cstring>
|
||||
<cstring>kcfg_RingSize</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="KIntSpinBox" name="ring_radius_input">
|
||||
<widget class="KIntSpinBox" name="kcfg_RingSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> pixel</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
|
@ -175,12 +184,12 @@
|
|||
<string>Ring Count:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>ring_count_input</cstring>
|
||||
<cstring>kcfg_RingCount</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="KIntNumInput" name="ring_count_input">
|
||||
<widget class="KIntNumInput" name="kcfg_RingCount">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -209,10 +218,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="KFontRequester" name="font_input"/>
|
||||
<widget class="KFontRequester" name="kcfg_Font"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="showtext_input">
|
||||
<widget class="QCheckBox" name="kcfg_ShowText">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -224,7 +233,7 @@
|
|||
<string>Show Text:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>showtext_input</cstring>
|
||||
<cstring>kcfg_ShowText</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
5
effects/mouseclick/mouseclickconfig.kcfgc
Normal file
5
effects/mouseclick/mouseclickconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=mouseclick.kcfg
|
||||
ClassName=MouseClickConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue