Commit 519c4df5 authored by Méven Car's avatar Méven Car Committed by Méven Car

KCM/Compositing: Use KConfig XT to store values

Summary:
 * Clean a little the code
 * Improve a little the UI

Test Plan:
Before:
{F8167763}
After:
{F8167764}

Reviewers: #kwin, ervin, bport, crossi, hchain, zzag

Reviewed By: #kwin, ervin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27955
parent 4cfdb330
......@@ -8,18 +8,20 @@ remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_STRICT_ITERATORS -DQT_NO_CAST_FR
################# configure checks and create the configured files #################
set(kwincomposing_SRC
set(kwincompositing_SRC
main.cpp
compositing.cpp
)
qt5_add_dbus_interface(kwincomposing_SRC
kconfig_add_kcfg_files(kwincompositing_SRC kwincompositing_setting.kcfgc GENERATE_MOC)
qt5_add_dbus_interface(kwincompositing_SRC
${KWin_SOURCE_DIR}/org.kde.kwin.Compositing.xml kwin_compositing_interface
)
ki18n_wrap_ui(kwincomposing_SRC compositing.ui)
ki18n_wrap_ui(kwincompositing_SRC compositing.ui)
add_library(kwincompositing MODULE ${kwincomposing_SRC})
add_library(kwincompositing MODULE ${kwincompositing_SRC})
target_link_libraries(kwincompositing
Qt5::DBus
......
This diff is collapsed.
......@@ -28,6 +28,8 @@
class OrgKdeKwinCompositingInterface;
class KWinCompositingSetting;
namespace KWin {
namespace Compositing {
......@@ -82,11 +84,12 @@ public:
static bool isRunningPlasma();
public Q_SLOTS:
void reset();
void load();
void defaults();
Q_SIGNALS:
void changed();
void changed(bool changed);
void defaulted(bool defaulted);
void animationSpeedChanged(qreal);
void windowThumbnailChanged(int);
void glScaleFilterChanged(int);
......@@ -97,7 +100,12 @@ Q_SIGNALS:
void openGLPlatformInterfaceChanged(int);
void windowsBlockCompositingChanged(bool);
private Q_SLOTS:
void updateSettings();
private:
void applyValues();
qreal m_animationSpeed;
int m_windowThumbnail;
int m_glScaleFilter;
......@@ -105,13 +113,13 @@ private:
int m_glSwapStrategy;
int m_compositingType;
bool m_compositingEnabled;
bool m_changed;
OpenGLPlatformInterfaceModel *m_openGLPlatformInterfaceModel;
int m_openGLPlatformInterface;
bool m_windowsBlockCompositing;
bool m_windowsBlockingCompositing;
OrgKdeKwinCompositingInterface *m_compositingInterface;
KSharedConfigPtr m_config;
KWinCompositingSetting *m_settings;
};
......
......@@ -14,6 +14,9 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
......@@ -71,13 +74,6 @@ Alternatively, you might want to use the XRender backend instead.</string>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="compositingEnabled">
<property name="text">
<string>Enable compositor on startup</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="animationSpeedLabel">
<property name="text">
......@@ -292,6 +288,13 @@ Alternatively, you might want to use the XRender backend instead.</string>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="compositingEnabled">
<property name="text">
<string>Enable compositor on startup</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
<?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="KDE">
<entry name="AnimationDurationFactor" type="Double">
<default>1.0</default>
</entry>
</group>
<group name="Compositing">
<entry name="HiddenPreviews" type="Int">
<default>5</default>
</entry>
<entry name="glTextureFilter" key="GLTextureFilter" type="Int">
<default>2</default>
</entry>
<entry name="XRenderSmoothScale" type="Bool">
<default>false</default>
</entry>
<entry name="Enabled" type="Bool">
<default>true</default>
</entry>
<entry name="OpenGLIsUnsafe" type="Bool">
<default>true</default>
</entry>
<entry name="glPreferBufferSwap" key="GLPreferBufferSwap" type="Enum">
<default>a</default>
<choices>
<choice name="n" />
<choice name="a" />
<choice name="e" />
<choice name="p" />
<choice name="c" />
</choices>
</entry>
<entry name="Backend" type="Enum">
<default>OpenGL</default>
<choices>
<choice name="OpenGL" />
<choice name="XRender" />
</choices>
</entry>
<entry name="glCore" key="GLCore" type="Bool">
<default>false</default>
</entry>
<entry name="WindowsBlockCompositing" type="Bool">
<default>true</default>
</entry>
<entry name="glPlatformInterface" key="GLPlatformInterface" type="String">
<default>glx</default>
<choices>
<choice name="glx" />
<choice name="egl" />
</choices>
</entry>
</group>
</kcfg>
File=kwincompositing_setting.kcfg
ClassName=KWinCompositingSetting
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true
......@@ -32,11 +32,11 @@
#include <algorithm>
#include <functional>
class KWinCompositingSettings : public KCModule
class KWinCompositingKCM : public KCModule
{
Q_OBJECT
public:
explicit KWinCompositingSettings(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
explicit KWinCompositingKCM(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
public Q_SLOTS:
void load() override;
......@@ -51,7 +51,7 @@ private:
static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0};
KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariantList &args)
KWinCompositingKCM::KWinCompositingKCM(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
, m_compositing(new KWin::Compositing::Compositing(this))
{
......@@ -71,12 +71,13 @@ KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariant
init();
}
void KWinCompositingSettings::init()
void KWinCompositingKCM::init()
{
using namespace KWin::Compositing;
auto currentIndexChangedSignal = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged);
connect(m_compositing, &Compositing::changed, this, &KWinCompositingSettings::markAsChanged);
connect(m_compositing, &Compositing::changed, this, qOverload<bool>(&KCModule::changed));
connect(m_compositing, &Compositing::defaulted, this, qOverload<bool>(&KCModule::defaulted));
// enabled check box
m_form.compositingEnabled->setChecked(m_compositing->compositingEnabled());
......@@ -202,26 +203,26 @@ void KWinCompositingSettings::init()
}
}
void KWinCompositingSettings::load()
void KWinCompositingKCM::load()
{
KCModule::load();
m_compositing->reset();
m_compositing->load();
}
void KWinCompositingSettings::defaults()
void KWinCompositingKCM::defaults()
{
KCModule::defaults();
m_compositing->defaults();
}
void KWinCompositingSettings::save()
void KWinCompositingKCM::save()
{
KCModule::save();
m_compositing->save();
}
K_PLUGIN_FACTORY(KWinCompositingConfigFactory,
registerPlugin<KWinCompositingSettings>("compositing");
registerPlugin<KWinCompositingKCM>("compositing");
)
#include "main.moc"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment