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
|
magnifier/magnifier.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
kde4_add_kcfg_files(kwin4_effect_builtins_sources magnifier/magnifierconfig.kcfgc)
|
||||||
|
|
||||||
# .desktop files
|
# .desktop files
|
||||||
install( FILES
|
install( FILES
|
||||||
magnifier/magnifier.desktop
|
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.cpp
|
||||||
magnifier/magnifier_config.ui
|
magnifier/magnifier_config.ui
|
||||||
)
|
)
|
||||||
|
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources magnifier/magnifierconfig.kcfgc)
|
||||||
|
|
||||||
# .desktop files
|
# .desktop files
|
||||||
install( FILES
|
install( FILES
|
||||||
|
|
|
@ -21,12 +21,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#include "magnifier.h"
|
#include "magnifier.h"
|
||||||
|
// KConfigSkeleton
|
||||||
|
#include "magnifierconfig.h"
|
||||||
|
|
||||||
#include <kwinconfig.h>
|
#include <kwinconfig.h>
|
||||||
|
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
#include <kconfiggroup.h>
|
|
||||||
#include <kstandardaction.h>
|
#include <kstandardaction.h>
|
||||||
|
|
||||||
#include <kwinglutils.h>
|
#include <kwinglutils.h>
|
||||||
|
@ -82,13 +83,13 @@ bool MagnifierEffect::supported()
|
||||||
|
|
||||||
void MagnifierEffect::reconfigure(ReconfigureFlags)
|
void MagnifierEffect::reconfigure(ReconfigureFlags)
|
||||||
{
|
{
|
||||||
KConfigGroup conf = EffectsHandler::effectConfig("Magnifier");
|
MagnifierConfig::self()->readConfig();
|
||||||
int width, height;
|
int width, height;
|
||||||
width = conf.readEntry("Width", 200);
|
width = MagnifierConfig::width();
|
||||||
height = conf.readEntry("Height", 200);
|
height = MagnifierConfig::height();
|
||||||
magnifier_size = QSize(width, height);
|
magnifier_size = QSize(width, height);
|
||||||
// Load the saved zoom value.
|
// Load the saved zoom value.
|
||||||
target_zoom = conf.readEntry("InitialZoom", target_zoom);
|
target_zoom = MagnifierConfig::initialZoom();
|
||||||
if (target_zoom != zoom)
|
if (target_zoom != zoom)
|
||||||
toggle();
|
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"
|
#include "magnifier_config.h"
|
||||||
|
// KConfigSkeleton
|
||||||
|
#include "magnifierconfig.h"
|
||||||
|
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
|
|
||||||
|
@ -51,9 +53,9 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList
|
||||||
|
|
||||||
layout->addWidget(m_ui);
|
layout->addWidget(m_ui);
|
||||||
|
|
||||||
|
addConfig(MagnifierConfig::self(), m_ui);
|
||||||
|
|
||||||
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
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"!
|
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||||
m_actionCollection = new KActionCollection(this, KComponentData("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));
|
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
|
||||||
|
|
||||||
m_ui->editor->addCollection(m_actionCollection);
|
m_ui->editor->addCollection(m_actionCollection);
|
||||||
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
MagnifierEffectConfig::~MagnifierEffectConfig()
|
MagnifierEffectConfig::~MagnifierEffectConfig()
|
||||||
|
@ -83,48 +86,21 @@ MagnifierEffectConfig::~MagnifierEffectConfig()
|
||||||
m_ui->editor->undoChanges();
|
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()
|
void MagnifierEffectConfig::save()
|
||||||
{
|
{
|
||||||
kDebug(1212) << "Saving config of Magnifier" ;
|
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
|
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||||
|
KCModule::save();
|
||||||
conf.sync();
|
|
||||||
|
|
||||||
emit changed(false);
|
|
||||||
EffectsHandler::sendReloadMessage("magnifier");
|
EffectsHandler::sendReloadMessage("magnifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifierEffectConfig::defaults()
|
void MagnifierEffectConfig::defaults()
|
||||||
{
|
{
|
||||||
m_ui->spinWidth->setValue(200);
|
|
||||||
m_ui->spinHeight->setValue(200);
|
|
||||||
m_ui->editor->allDefault();
|
m_ui->editor->allDefault();
|
||||||
emit changed(true);
|
KCModule::defaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#include "magnifier_config.moc"
|
#include "magnifier_config.moc"
|
||||||
|
|
|
@ -45,7 +45,6 @@ public:
|
||||||
virtual ~MagnifierEffectConfig();
|
virtual ~MagnifierEffectConfig();
|
||||||
|
|
||||||
virtual void save();
|
virtual void save();
|
||||||
virtual void load();
|
|
||||||
virtual void defaults();
|
virtual void defaults();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<ui version="4.0" >
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
<class>KWin::MagnifierEffectConfigForm</class>
|
<class>KWin::MagnifierEffectConfigForm</class>
|
||||||
<widget class="QWidget" name="KWin::MagnifierEffectConfigForm" >
|
<widget class="QWidget" name="KWin::MagnifierEffectConfigForm">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
|
@ -9,73 +10,73 @@
|
||||||
<height>181</height>
|
<height>181</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupSize" >
|
<widget class="QGroupBox" name="groupSize">
|
||||||
<property name="title" >
|
<property name="title">
|
||||||
<string>Size</string>
|
<string>Size</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_Width</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_Width">
|
||||||
<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="suffix" >
|
<property name="suffix">
|
||||||
<string> px</string>
|
<string> px</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum" >
|
<property name="maximum">
|
||||||
<number>9999</number>
|
<number>9999</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep" >
|
<property name="singleStep">
|
||||||
<number>10</number>
|
<number>10</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>&Height:</string>
|
<string>&Height:</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>spinHeight</cstring>
|
<cstring>kcfg_Height</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" >
|
<item row="1" column="1">
|
||||||
<widget class="KIntSpinBox" name="spinHeight" >
|
<widget class="KIntSpinBox" name="kcfg_Height">
|
||||||
<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="suffix" >
|
<property name="suffix">
|
||||||
<string> px</string>
|
<string> px</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum" >
|
<property name="maximum">
|
||||||
<number>9999</number>
|
<number>9999</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep" >
|
<property name="singleStep">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -84,7 +85,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="KWin::GlobalShortcutsEditor" native="1" name="editor" />
|
<widget class="KWin::GlobalShortcutsEditor" name="editor" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -97,7 +98,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/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