Use KConfigXT in Zoom Effect
REVIEW: 106402
This commit is contained in:
parent
f581e22e38
commit
f1df9ee2f0
7 changed files with 71 additions and 64 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
zoom/zoom.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources zoom/zoomconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
zoom/zoom.desktop
|
||||
|
@ -19,6 +21,7 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
zoom/zoom_config.cpp
|
||||
zoom/zoom_config.ui
|
||||
)
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources zoom/zoomconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
|
|
|
@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "zoom.h"
|
||||
// KConfigSkeleton
|
||||
#include "zoomconfig.h"
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
|
@ -202,15 +204,15 @@ void ZoomEffect::recreateTexture()
|
|||
|
||||
void ZoomEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Zoom");
|
||||
ZoomConfig::self()->readConfig();
|
||||
// On zoom-in and zoom-out change the zoom by the defined zoom-factor.
|
||||
zoomFactor = qMax(0.1, conf.readEntry("ZoomFactor", zoomFactor));
|
||||
zoomFactor = qMax(0.1, ZoomConfig::zoomFactor()/100.0);
|
||||
// Visibility of the mouse-pointer.
|
||||
mousePointer = MousePointerType(conf.readEntry("MousePointer", int(mousePointer)));
|
||||
mousePointer = MousePointerType(ZoomConfig::mousePointer());
|
||||
// Track moving of the mouse.
|
||||
mouseTracking = MouseTrackingType(conf.readEntry("MouseTracking", int(mouseTracking)));
|
||||
mouseTracking = MouseTrackingType(ZoomConfig::mouseTracking());
|
||||
// Enable tracking of the focused location.
|
||||
bool _enableFocusTracking = conf.readEntry("EnableFocusTracking", enableFocusTracking);
|
||||
bool _enableFocusTracking = ZoomConfig::enableFocusTracking();
|
||||
if (enableFocusTracking != _enableFocusTracking) {
|
||||
enableFocusTracking = _enableFocusTracking;
|
||||
if (QDBusConnection::sessionBus().isConnected()) {
|
||||
|
@ -221,13 +223,13 @@ void ZoomEffect::reconfigure(ReconfigureFlags)
|
|||
}
|
||||
}
|
||||
// When the focus changes, move the zoom area to the focused location.
|
||||
followFocus = conf.readEntry("EnableFollowFocus", followFocus);
|
||||
followFocus = ZoomConfig::enableFollowFocus();
|
||||
// The time in milliseconds to wait before a focus-event takes away a mouse-move.
|
||||
focusDelay = qMax(0, conf.readEntry("FocusDelay", focusDelay));
|
||||
focusDelay = qMax(uint(0), ZoomConfig::focusDelay());
|
||||
// The factor the zoom-area will be moved on touching an edge on push-mode or using the navigation KAction's.
|
||||
moveFactor = qMax(0.1, conf.readEntry("MoveFactor", moveFactor));
|
||||
moveFactor = qMax(0.1, ZoomConfig::moveFactor());
|
||||
// Load the saved zoom value.
|
||||
target_zoom = conf.readEntry("InitialZoom", target_zoom);
|
||||
target_zoom = ZoomConfig::initialZoom();
|
||||
if (target_zoom > 1.0)
|
||||
zoomIn(target_zoom);
|
||||
}
|
||||
|
|
33
effects/zoom/zoom.kcfg
Normal file
33
effects/zoom/zoom.kcfg
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?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-Zoom">
|
||||
<entry name="ZoomFactor" type="Double">
|
||||
<default>1.2</default>
|
||||
</entry>
|
||||
<entry name="MousePointer" type="UInt">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="MouseTracking" type="UInt">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="EnableFocusTracking" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="EnableFollowFocus" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="FocusDelay" type="UInt">
|
||||
<default>350</default>
|
||||
</entry>
|
||||
<entry name="MoveFactor" type="Double">
|
||||
<default>20.0</default>
|
||||
</entry>
|
||||
<entry name="InitialZoom" type="Double">
|
||||
<default>1.0</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "zoom_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "zoomconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
@ -49,12 +51,7 @@ ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) :
|
|||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_ui);
|
||||
|
||||
connect(m_ui->zoomStepsSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changed()));
|
||||
connect(m_ui->mousePointerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->mouseTrackingComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->focusTrackingCheckBox, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->followFocusCheckBox, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
|
||||
addConfig(ZoomConfig::self(), m_ui);
|
||||
|
||||
// Shortcut config. The shortcut belongs to the component "kwin"!
|
||||
KActionCollection *actionCollection = new KActionCollection(this, KComponentData("kwin"));
|
||||
|
@ -120,44 +117,13 @@ ZoomEffectConfig::~ZoomEffectConfig()
|
|||
m_ui->editor->undoChanges();
|
||||
}
|
||||
|
||||
void ZoomEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Zoom");
|
||||
m_ui->zoomStepsSpinBox->setValue(conf.readEntry("ZoomFactor", 1.2));
|
||||
m_ui->mousePointerComboBox->setCurrentIndex(conf.readEntry("MousePointer", 0));
|
||||
m_ui->mouseTrackingComboBox->setCurrentIndex(conf.readEntry("MouseTracking", 0));
|
||||
m_ui->focusTrackingCheckBox->setChecked(conf.readEntry("EnableFocusTracking", false));
|
||||
m_ui->followFocusCheckBox->setChecked(conf.readEntry("EnableFollowFocus", true));
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void ZoomEffectConfig::save()
|
||||
{
|
||||
//KCModule::save();
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Zoom");
|
||||
conf.writeEntry("ZoomFactor", m_ui->zoomStepsSpinBox->value());
|
||||
conf.writeEntry("MousePointer", m_ui->mousePointerComboBox->currentIndex());
|
||||
conf.writeEntry("MouseTracking", m_ui->mouseTrackingComboBox->currentIndex());
|
||||
conf.writeEntry("EnableFocusTracking", m_ui->focusTrackingCheckBox->isChecked());
|
||||
conf.writeEntry("EnableFollowFocus", m_ui->followFocusCheckBox->isChecked());
|
||||
m_ui->editor->save(); // undo() will restore to this state from now on
|
||||
conf.sync();
|
||||
emit changed(false);
|
||||
KCModule::save();
|
||||
EffectsHandler::sendReloadMessage("zoom");
|
||||
}
|
||||
|
||||
void ZoomEffectConfig::defaults()
|
||||
{
|
||||
m_ui->zoomStepsSpinBox->setValue(1.25);
|
||||
m_ui->mousePointerComboBox->setCurrentIndex(0);
|
||||
m_ui->mouseTrackingComboBox->setCurrentIndex(0);
|
||||
m_ui->focusTrackingCheckBox->setChecked(false);
|
||||
m_ui->followFocusCheckBox->setChecked(true);
|
||||
m_ui->editor->allDefault();
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "zoom_config.moc"
|
||||
|
|
|
@ -46,8 +46,6 @@ public:
|
|||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
ZoomEffectConfigForm* m_ui;
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>zoomStepsSpinBox</cstring>
|
||||
<cstring>kcfg_ZoomFactor</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="zoomStepsSpinBox">
|
||||
<widget class="QDoubleSpinBox" name="kcfg_ZoomFactor">
|
||||
<property name="whatsThis">
|
||||
<string>On zoom-in and zoom-out change the zoom by the defined zoom-factor.</string>
|
||||
</property>
|
||||
|
@ -58,7 +58,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="focusTrackingCheckBox">
|
||||
<widget class="QCheckBox" name="kcfg_EnableFocusTracking">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -71,7 +71,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="followFocusCheckBox">
|
||||
<widget class="QCheckBox" name="kcfg_EnableFollowFocus">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
@ -92,12 +92,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>mousePointerComboBox</cstring>
|
||||
<cstring>kcfg_MousePointer</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="mousePointerComboBox">
|
||||
<widget class="QComboBox" name="kcfg_MousePointer">
|
||||
<property name="whatsThis">
|
||||
<string>Visibility of the mouse-pointer.</string>
|
||||
</property>
|
||||
|
@ -119,7 +119,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="mouseTrackingComboBox">
|
||||
<widget class="QComboBox" name="kcfg_MouseTracking">
|
||||
<property name="whatsThis">
|
||||
<string>Track moving of the mouse.</string>
|
||||
</property>
|
||||
|
@ -154,7 +154,7 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>mouseTrackingComboBox</cstring>
|
||||
<cstring>kcfg_MouseTracking</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -184,18 +184,18 @@
|
|||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>zoomStepsSpinBox</tabstop>
|
||||
<tabstop>mousePointerComboBox</tabstop>
|
||||
<tabstop>mouseTrackingComboBox</tabstop>
|
||||
<tabstop>focusTrackingCheckBox</tabstop>
|
||||
<tabstop>followFocusCheckBox</tabstop>
|
||||
<tabstop>kcfg_ZoomFactor</tabstop>
|
||||
<tabstop>kcfg_MousePointer</tabstop>
|
||||
<tabstop>kcfg_MouseTracking</tabstop>
|
||||
<tabstop>kcfg_EnableFocusTracking</tabstop>
|
||||
<tabstop>kcfg_EnableFollowFocus</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>focusTrackingCheckBox</sender>
|
||||
<sender>kcfg_EnableFocusTracking</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>followFocusCheckBox</receiver>
|
||||
<receiver>kcfg_EnableFollowFocus</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
|
5
effects/zoom/zoomconfig.kcfgc
Normal file
5
effects/zoom/zoomconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=zoom.kcfg
|
||||
ClassName=ZoomConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue