Use KConfigXT in Magnifier Effect
REVIEW: 106442
This commit is contained in:
parent
85510b91aa
commit
696ea9f4d3
7 changed files with 75 additions and 72 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
magnifier/magnifier.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources magnifier/magnifierconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
magnifier/magnifier.desktop
|
||||
|
@ -19,6 +21,7 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
magnifier/magnifier_config.cpp
|
||||
magnifier/magnifier_config.ui
|
||||
)
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources magnifier/magnifierconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
|
|
|
@ -21,12 +21,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "magnifier.h"
|
||||
// KConfigSkeleton
|
||||
#include "magnifierconfig.h"
|
||||
|
||||
#include <kwinconfig.h>
|
||||
|
||||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <kstandardaction.h>
|
||||
|
||||
#include <kwinglutils.h>
|
||||
|
@ -82,13 +83,13 @@ bool MagnifierEffect::supported()
|
|||
|
||||
void MagnifierEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Magnifier");
|
||||
MagnifierConfig::self()->readConfig();
|
||||
int width, height;
|
||||
width = conf.readEntry("Width", 200);
|
||||
height = conf.readEntry("Height", 200);
|
||||
width = MagnifierConfig::width();
|
||||
height = MagnifierConfig::height();
|
||||
magnifier_size = QSize(width, height);
|
||||
// Load the saved zoom value.
|
||||
target_zoom = conf.readEntry("InitialZoom", target_zoom);
|
||||
target_zoom = MagnifierConfig::initialZoom();
|
||||
if (target_zoom != zoom)
|
||||
toggle();
|
||||
}
|
||||
|
|
18
effects/magnifier/magnifier.kcfg
Normal file
18
effects/magnifier/magnifier.kcfg
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?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-Magnifier">
|
||||
<entry name="Width" type="UInt">
|
||||
<default>200</default>
|
||||
</entry>
|
||||
<entry name="Height" type="UInt">
|
||||
<default>200</default>
|
||||
</entry>
|
||||
<entry name="InitialZoom" type="Double">
|
||||
<default>1.0</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "magnifier_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "magnifierconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
@ -51,9 +53,9 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList
|
|||
|
||||
layout->addWidget(m_ui);
|
||||
|
||||
addConfig(MagnifierConfig::self(), m_ui);
|
||||
|
||||
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
||||
connect(m_ui->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->spinHeight, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
|
||||
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
||||
|
@ -75,6 +77,7 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList
|
|||
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
|
||||
|
||||
m_ui->editor->addCollection(m_actionCollection);
|
||||
load();
|
||||
}
|
||||
|
||||
MagnifierEffectConfig::~MagnifierEffectConfig()
|
||||
|
@ -83,48 +86,21 @@ MagnifierEffectConfig::~MagnifierEffectConfig()
|
|||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void MagnifierEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Magnifier");
|
||||
|
||||
int width = conf.readEntry("Width", 200);
|
||||
int height = conf.readEntry("Height", 200);
|
||||
m_ui->spinWidth->setValue(width);
|
||||
m_ui->spinHeight->setValue(height);
|
||||
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void MagnifierEffectConfig::save()
|
||||
{
|
||||
kDebug(1212) << "Saving config of Magnifier" ;
|
||||
//KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Magnifier");
|
||||
|
||||
conf.writeEntry("Width", m_ui->spinWidth->value());
|
||||
conf.writeEntry("Height", m_ui->spinHeight->value());
|
||||
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
KCModule::save();
|
||||
EffectsHandler::sendReloadMessage("magnifier");
|
||||
}
|
||||
|
||||
void MagnifierEffectConfig::defaults()
|
||||
{
|
||||
m_ui->spinWidth->setValue(200);
|
||||
m_ui->spinHeight->setValue(200);
|
||||
m_ui->editor->allDefault();
|
||||
emit changed(true);
|
||||
KCModule::defaults();
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "magnifier_config.moc"
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
virtual ~MagnifierEffectConfig();
|
||||
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>KWin::MagnifierEffectConfigForm</class>
|
||||
<widget class="QWidget" name="KWin::MagnifierEffectConfigForm" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="KWin::MagnifierEffectConfigForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
|
@ -9,73 +10,73 @@
|
|||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupSize" >
|
||||
<property name="title" >
|
||||
<widget class="QGroupBox" name="groupSize">
|
||||
<property name="title">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>&Width:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>spinWidth</cstring>
|
||||
<property name="buddy">
|
||||
<cstring>kcfg_Width</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="KIntSpinBox" name="spinWidth" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<item row="0" column="1">
|
||||
<widget class="KIntSpinBox" name="kcfg_Width">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix" >
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>&Height:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>spinHeight</cstring>
|
||||
<property name="buddy">
|
||||
<cstring>kcfg_Height</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="KIntSpinBox" name="spinHeight" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<item row="1" column="1">
|
||||
<widget class="KIntSpinBox" name="kcfg_Height">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix" >
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -84,7 +85,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KWin::GlobalShortcutsEditor" native="1" name="editor" />
|
||||
<widget class="KWin::GlobalShortcutsEditor" name="editor" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -97,7 +98,7 @@
|
|||
<customwidget>
|
||||
<class>KWin::GlobalShortcutsEditor</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global" >kwineffects.h</header>
|
||||
<header location="global">kwineffects.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
|
5
effects/magnifier/magnifierconfig.kcfgc
Normal file
5
effects/magnifier/magnifierconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=magnifier.kcfg
|
||||
ClassName=MagnifierConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue