Use KConfigXT in Translucency Effect
Port the KCM to use KConfigXT which means that the complete custom code for loading, saving and setting to defaults can be dropped. Also in the effect in brings some advantages as we basically get compile time checks whether the accessed config is named correctly. The saved values for translucency are now UInts in [0,100] instead of doubles in [0.0,1.0], so an update script is needed. REVIEW: 106310
This commit is contained in:
parent
7ad25b663e
commit
509daa60a1
7 changed files with 94 additions and 104 deletions
|
@ -6,6 +6,8 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
|||
translucency/translucency.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_sources translucency/translucencyconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
translucency/translucency.desktop
|
||||
|
@ -19,6 +21,7 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
|
|||
translucency/translucency_config.cpp
|
||||
translucency/translucency_config.ui
|
||||
)
|
||||
kde4_add_kcfg_files(kwin4_effect_builtins_config_sources translucency/translucencyconfig.kcfgc)
|
||||
|
||||
# .desktop files
|
||||
install( FILES
|
||||
|
|
|
@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "translucency.h"
|
||||
// KConfigSkeleton
|
||||
#include "translucencyconfig.h"
|
||||
|
||||
#include <kconfiggroup.h>
|
||||
|
||||
|
@ -47,18 +49,18 @@ TranslucencyEffect::TranslucencyEffect()
|
|||
|
||||
void TranslucencyEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
KConfigGroup conf = effects->effectConfig("Translucency");
|
||||
decoration = conf.readEntry("Decoration", 1.0);
|
||||
moveresize = conf.readEntry("MoveResize", 0.8);
|
||||
dialogs = conf.readEntry("Dialogs", 1.0);
|
||||
inactive = conf.readEntry("Inactive", 1.0);
|
||||
comboboxpopups = conf.readEntry("ComboboxPopups", 1.0);
|
||||
menus = conf.readEntry("Menus", 1.0);
|
||||
individualmenuconfig = conf.readEntry("IndividualMenuConfig", false);
|
||||
TranslucencyConfig::self()->readConfig();
|
||||
decoration = TranslucencyConfig::decoration()/100.0;
|
||||
moveresize = TranslucencyConfig::moveResize()/100.0;
|
||||
dialogs = TranslucencyConfig::dialogs()/100.0;
|
||||
inactive = TranslucencyConfig::inactive()/100.0;
|
||||
comboboxpopups = TranslucencyConfig::comboboxPopups()/100.0;
|
||||
menus = TranslucencyConfig::menus()/100.0;
|
||||
individualmenuconfig = TranslucencyConfig::individualMenuConfig();
|
||||
if (individualmenuconfig) {
|
||||
dropdownmenus = conf.readEntry("DropdownMenus", 1.0);
|
||||
popupmenus = conf.readEntry("PopupMenus", 1.0);
|
||||
tornoffmenus = conf.readEntry("TornOffMenus", 1.0);
|
||||
dropdownmenus = TranslucencyConfig::dropdownMenus()/100.0;
|
||||
popupmenus = TranslucencyConfig::popupMenus()/100.0;
|
||||
tornoffmenus = TranslucencyConfig::tornOffMenus()/100.0;
|
||||
} else {
|
||||
dropdownmenus = menus;
|
||||
popupmenus = menus;
|
||||
|
|
39
effects/translucency/translucency.kcfg
Normal file
39
effects/translucency/translucency.kcfg
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?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-Translucency">
|
||||
<entry name="Decoration" type="Int">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="MoveResize" type="Int">
|
||||
<default>80</default>
|
||||
</entry>
|
||||
<entry name="Dialogs" type="UInt">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="Inactive" type="UInt">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="ComboboxPopups" type="UInt">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="Menus" type="UInt">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="IndividualMenuConfig" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry name="DropdownMenus" type="UInt">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="PopupMenus" type="UInt">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="TornOffMenus" type="UInt">
|
||||
<default>100</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
|
@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "translucency_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "translucencyconfig.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
|
||||
|
@ -46,76 +48,17 @@ TranslucencyEffectConfig::TranslucencyEffectConfig(QWidget* parent, const QVaria
|
|||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(m_ui);
|
||||
|
||||
connect(m_ui->decorations, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->inactive, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->moveresize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->dialogs, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->comboboxpopup, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->menus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->individualmenuconfig, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->dropdownmenus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->popupmenus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->tornoffmenus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
addConfig(TranslucencyConfig::self(), m_ui);
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
void TranslucencyEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Translucency");
|
||||
m_ui->decorations->setValue((int)(conf.readEntry("Decoration", 1.0) * 100));
|
||||
m_ui->moveresize->setValue((int)(conf.readEntry("MoveResize", 0.8) * 100));
|
||||
m_ui->dialogs->setValue((int)(conf.readEntry("Dialogs", 1.0) * 100));
|
||||
m_ui->inactive->setValue((int)(conf.readEntry("Inactive", 1.0) * 100));
|
||||
m_ui->comboboxpopup->setValue((int)(conf.readEntry("ComboboxPopups", 1.0) * 100));
|
||||
m_ui->menus->setValue((int)(conf.readEntry("Menus", 1.0) * 100));
|
||||
m_ui->individualmenuconfig->setChecked((conf.readEntry("IndividualMenuConfig", false)));
|
||||
m_ui->dropdownmenus->setValue((int)(conf.readEntry("DropdownMenus", 1.0) * 100));
|
||||
m_ui->popupmenus->setValue((int)(conf.readEntry("PopupMenus", 1.0) * 100));
|
||||
m_ui->tornoffmenus->setValue((int)(conf.readEntry("TornOffMenus", 1.0) * 100));
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void TranslucencyEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig("Translucency");
|
||||
conf.writeEntry("Decoration", m_ui->decorations->value() / 100.0);
|
||||
conf.writeEntry("MoveResize", m_ui->moveresize->value() / 100.0);
|
||||
conf.writeEntry("Dialogs", m_ui->dialogs->value() / 100.0);
|
||||
conf.writeEntry("Inactive", m_ui->inactive->value() / 100.0);
|
||||
conf.writeEntry("ComboboxPopups", m_ui->comboboxpopup->value() / 100.0);
|
||||
conf.writeEntry("Menus", m_ui->menus->value() / 100.0);
|
||||
conf.writeEntry("IndividualMenuConfig", m_ui->individualmenuconfig->isChecked());
|
||||
conf.writeEntry("DropdownMenus", m_ui->dropdownmenus->value() / 100.0);
|
||||
conf.writeEntry("PopupMenus", m_ui->popupmenus->value() / 100.0);
|
||||
conf.writeEntry("TornOffMenus", m_ui->tornoffmenus->value() / 100.0);
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage("translucency");
|
||||
}
|
||||
|
||||
void TranslucencyEffectConfig::defaults()
|
||||
{
|
||||
m_ui->decorations->setValue(100);
|
||||
m_ui->moveresize->setValue(80);
|
||||
m_ui->dialogs->setValue(100);
|
||||
m_ui->inactive->setValue(100);
|
||||
m_ui->comboboxpopup->setValue(100);
|
||||
m_ui->menus->setValue(100);
|
||||
m_ui->individualmenuconfig->setChecked(false);
|
||||
m_ui->dropdownmenus->setValue(100);
|
||||
m_ui->popupmenus->setValue(100);
|
||||
m_ui->tornoffmenus->setValue(100);
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "translucency_config.moc"
|
||||
|
|
|
@ -42,8 +42,6 @@ public:
|
|||
explicit TranslucencyEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private:
|
||||
TranslucencyEffectConfigForm* m_ui;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QSlider" name="dialogs">
|
||||
<widget class="QSlider" name="kcfg_Dialogs">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>dialogs</cstring>
|
||||
<cstring>kcfg_Dialogs</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -73,12 +73,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>decorations</cstring>
|
||||
<cstring>kcfg_Decoration</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QSlider" name="comboboxpopup">
|
||||
<widget class="QSlider" name="kcfg_ComboboxPopups">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -97,7 +97,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="2">
|
||||
<widget class="QSlider" name="menus">
|
||||
<widget class="QSlider" name="kcfg_Menus">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -130,7 +130,7 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>inactive</cstring>
|
||||
<cstring>kcfg_Inactive</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -149,7 +149,7 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>moveresize</cstring>
|
||||
<cstring>kcfg_MoveResize</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -168,12 +168,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboboxpopup</cstring>
|
||||
<cstring>kcfg_ComboboxPopups</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QSlider" name="moveresize">
|
||||
<widget class="QSlider" name="kcfg_MoveResize">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -205,7 +205,7 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QSlider" name="decorations">
|
||||
<widget class="QSlider" name="kcfg_Decoration">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
|
@ -230,7 +230,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QSlider" name="inactive">
|
||||
<widget class="QSlider" name="kcfg_Inactive">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -292,7 +292,7 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>menus</cstring>
|
||||
<cstring>kcfg_Menus</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -300,7 +300,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="individualmenuconfig">
|
||||
<widget class="QGroupBox" name="kcfg_IndividualMenuConfig">
|
||||
<property name="title">
|
||||
<string>Set menu translucency independently</string>
|
||||
</property>
|
||||
|
@ -326,12 +326,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>dropdownmenus</cstring>
|
||||
<cstring>kcfg_DropdownMenus</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QSlider" name="dropdownmenus">
|
||||
<widget class="QSlider" name="kcfg_DropdownMenus">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
|
@ -370,12 +370,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>popupmenus</cstring>
|
||||
<cstring>kcfg_PopupMenus</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QSlider" name="popupmenus">
|
||||
<widget class="QSlider" name="kcfg_PopupMenus">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -408,12 +408,12 @@
|
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>tornoffmenus</cstring>
|
||||
<cstring>kcfg_TornOffMenus</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QSlider" name="tornoffmenus">
|
||||
<widget class="QSlider" name="kcfg_TornOffMenus">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
</property>
|
||||
|
@ -479,23 +479,23 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>decorations</tabstop>
|
||||
<tabstop>inactive</tabstop>
|
||||
<tabstop>moveresize</tabstop>
|
||||
<tabstop>dialogs</tabstop>
|
||||
<tabstop>comboboxpopup</tabstop>
|
||||
<tabstop>menus</tabstop>
|
||||
<tabstop>individualmenuconfig</tabstop>
|
||||
<tabstop>dropdownmenus</tabstop>
|
||||
<tabstop>popupmenus</tabstop>
|
||||
<tabstop>tornoffmenus</tabstop>
|
||||
<tabstop>kcfg_Decoration</tabstop>
|
||||
<tabstop>kcfg_Inactive</tabstop>
|
||||
<tabstop>kcfg_MoveResize</tabstop>
|
||||
<tabstop>kcfg_Dialogs</tabstop>
|
||||
<tabstop>kcfg_ComboboxPopups</tabstop>
|
||||
<tabstop>kcfg_Menus</tabstop>
|
||||
<tabstop>kcfg_IndividualMenuConfig</tabstop>
|
||||
<tabstop>kcfg_DropdownMenus</tabstop>
|
||||
<tabstop>kcfg_PopupMenus</tabstop>
|
||||
<tabstop>kcfg_TornOffMenus</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>individualmenuconfig</sender>
|
||||
<sender>kcfg_IndividualMenuConfig</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>menus</receiver>
|
||||
<receiver>kcfg_Menus</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
|
5
effects/translucency/translucencyconfig.kcfgc
Normal file
5
effects/translucency/translucencyconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=translucency.kcfg
|
||||
ClassName=TranslucencyConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue