[kcmkwin/compositing] Use a classic ui file for the Compositor settings

For a classic user interface like the advanced compositor settings the
good old widgets are still better suited than the new QuickControls.

REVIEW: 118273
This commit is contained in:
Martin Gräßlin 2014-05-23 10:11:02 +02:00
parent b259dda336
commit c16472e535
3 changed files with 387 additions and 4 deletions

View file

@ -26,6 +26,8 @@ qt5_add_dbus_interface( kwincomposing_SRC
qt5_add_dbus_interface( kwincomposing_SRC
${KWIN_SOURCE_DIR}/org.kde.kwin.Effects.xml kwin_effects_interface)
ki18n_wrap_ui(kwincomposing_SRC compositing.ui)
add_library(kwincompositing MODULE ${kwincomposing_SRC})
target_link_libraries(kwincompositing

View file

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CompositingForm</class>
<widget class="QWidget" name="CompositingForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="compositingEnabled">
<property name="text">
<string>Enable compositor on startup</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Animation speed:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSlider" name="animationSpeed">
<property name="maximum">
<number>6</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Instant</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Very slow</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="glScaleFilterLabel">
<property name="text">
<string>Scale method:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="glScaleFilter">
<item>
<property name="text">
<string>Crisp</string>
</property>
</item>
<item>
<property name="text">
<string>Smooth</string>
</property>
</item>
<item>
<property name="text">
<string>Accurate</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="xrScaleFilterLabel">
<property name="text">
<string>Scale method:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="xrScaleFilter">
<item>
<property name="text">
<string>Crisp</string>
</property>
</item>
<item>
<property name="text">
<string>Smooth (slower)</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Rendering backend:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="type"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="openGLPlatformInterfaceLabel">
<property name="text">
<string>OpenGL interface:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="openGLPlatformInterface"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Tearing prevention (&quot;vsync&quot;):</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="tearingPrevention">
<item>
<property name="text">
<string>Never</string>
</property>
</item>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>Only when cheap</string>
</property>
</item>
<item>
<property name="text">
<string>Full screen repaints</string>
</property>
</item>
<item>
<property name="text">
<string>Re-use screen content</string>
</property>
</item>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Keep window thumbnails:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QComboBox" name="windowThumbnail">
<item>
<property name="text">
<string>Always (Breaks Animations)</string>
</property>
</item>
<item>
<property name="text">
<string>Only for Shown Windows</string>
</property>
</item>
<item>
<property name="text">
<string>Never</string>
</property>
</item>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Expert:</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QCheckBox" name="unredirectFullscreen">
<property name="text">
<string>Suspend compositor for full screen windows</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Experimental:</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QCheckBox" name="colorCorrection">
<property name="text">
<string>Enable color correction</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -20,8 +20,9 @@
**************************************************************************/
#include "compositing.h"
#include "model.h"
#include "ui_compositing.h"
#include <QApplication>
#include <QLayout>
@ -55,14 +56,134 @@ public:
: KWinCompositingKCM(parent, args, KWin::Compositing::EffectView::DesktopEffectsView) {}
};
class KWinCompositingSettings : public KWinCompositingKCM
class KWinCompositingSettings : public KCModule
{
Q_OBJECT
public:
explicit KWinCompositingSettings(QWidget* parent = 0, const QVariantList& args = QVariantList())
: KWinCompositingKCM(parent, args, KWin::Compositing::EffectView::CompositingSettingsView) {}
explicit KWinCompositingSettings(QWidget *parent = 0, const QVariantList &args = QVariantList());
public Q_SLOTS:
void load() override;
void save() override;
void defaults() override;
private:
void init();
KWin::Compositing::Compositing *m_compositing;
Ui_CompositingForm m_form;
};
KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
, m_compositing(new KWin::Compositing::Compositing(this))
{
m_form.setupUi(this);
init();
}
void KWinCompositingSettings::init()
{
using namespace KWin::Compositing;
auto currentIndexChangedSignal = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged);
connect(m_compositing, &Compositing::changed, this, static_cast<void(KCModule::*)()>(&KWinCompositingSettings::changed));
// enabled check box
m_form.compositingEnabled->setChecked(m_compositing->compositingEnabled());
connect(m_compositing, &Compositing::compositingEnabledChanged, m_form.compositingEnabled, &QCheckBox::setChecked);
connect(m_form.compositingEnabled, &QCheckBox::toggled, m_compositing, &Compositing::setCompositingEnabled);
// animation speed
m_form.animationSpeed->setValue(m_compositing->animationSpeed());
connect(m_compositing, &Compositing::animationSpeedChanged, m_form.animationSpeed, &QSlider::setValue);
connect(m_form.animationSpeed, &QSlider::valueChanged, m_compositing, &Compositing::setAnimationSpeed);
// gl scale filter
m_form.glScaleFilter->setCurrentIndex(m_compositing->glScaleFilter());
connect(m_compositing, &Compositing::glScaleFilterChanged, m_form.glScaleFilter, &QComboBox::setCurrentIndex);
connect(m_form.glScaleFilter, currentIndexChangedSignal, m_compositing, &Compositing::setGlScaleFilter);
// xrender scale filter
m_form.xrScaleFilter->setCurrentIndex(m_compositing->xrScaleFilter());
connect(m_compositing, &Compositing::xrScaleFilterChanged, m_form.xrScaleFilter, &QComboBox::setCurrentIndex);
connect(m_form.xrScaleFilter, currentIndexChangedSignal, m_compositing, &Compositing::setXrScaleFilter);
// tearing prevention
m_form.tearingPrevention->setCurrentIndex(m_compositing->glSwapStrategy());
connect(m_compositing, &Compositing::glSwapStrategyChanged, m_form.tearingPrevention, &QComboBox::setCurrentIndex);
connect(m_form.tearingPrevention, currentIndexChangedSignal, m_compositing, &Compositing::setGlSwapStrategy);
// windowThumbnail
m_form.windowThumbnail->setCurrentIndex(m_compositing->windowThumbnail());
connect(m_compositing, &Compositing::windowThumbnailChanged, m_form.windowThumbnail, &QComboBox::setCurrentIndex);
connect(m_form.windowThumbnail, currentIndexChangedSignal, m_compositing, &Compositing::setWindowThumbnail);
// openglPlatformInterface
m_form.openGLPlatformInterface->setModel(m_compositing->openGLPlatformInterfaceModel());
m_form.openGLPlatformInterface->setCurrentIndex(m_compositing->openGLPlatformInterface());
connect(m_compositing, &Compositing::openGLPlatformInterfaceChanged, m_form.openGLPlatformInterface, &QComboBox::setCurrentIndex);
connect(m_form.openGLPlatformInterface, currentIndexChangedSignal, m_compositing, &Compositing::setOpenGLPlatformInterface);
// unredirect fullscreen
m_form.unredirectFullscreen->setChecked(m_compositing->unredirectFullscreen());
connect(m_compositing, &Compositing::unredirectFullscreenChanged, m_form.unredirectFullscreen, &QCheckBox::setChecked);
connect(m_form.unredirectFullscreen, &QCheckBox::toggled, m_compositing, &Compositing::setUnredirectFullscreen);
// color correction
m_form.colorCorrection->setChecked(m_compositing->glColorCorrection());
connect(m_compositing, &Compositing::glColorCorrectionChanged, m_form.colorCorrection, &QCheckBox::setChecked);
connect(m_form.colorCorrection, &QCheckBox::toggled, m_compositing, &Compositing::setGlColorCorrection);
// compositing type
CompositingType *type = new CompositingType(this);
m_form.type->setModel(type);
auto updateCompositingType = [this, type]() {
m_form.type->setCurrentIndex(type->indexForCompositingType(m_compositing->compositingType()));
};
updateCompositingType();
connect(m_compositing, &Compositing::compositingTypeChanged,
[updateCompositingType]() {
updateCompositingType();
}
);
auto showHideBasedOnType = [this, type]() {
const int currentType = type->compositingTypeForIndex(m_form.type->currentIndex());
m_form.glScaleFilter->setVisible(currentType != CompositingType::XRENDER_INDEX);
m_form.glScaleFilterLabel->setVisible(currentType != CompositingType::XRENDER_INDEX);
m_form.xrScaleFilter->setVisible(currentType == CompositingType::XRENDER_INDEX);
m_form.xrScaleFilterLabel->setVisible(currentType == CompositingType::XRENDER_INDEX);
m_form.openGLPlatformInterface->setVisible(currentType != CompositingType::XRENDER_INDEX);
m_form.openGLPlatformInterfaceLabel->setVisible(currentType != CompositingType::XRENDER_INDEX);
m_form.colorCorrection->setEnabled(currentType == CompositingType::OPENGL31_INDEX || currentType == CompositingType::OPENGL20_INDEX);
};
showHideBasedOnType();
connect(m_form.type, currentIndexChangedSignal,
[this, type, showHideBasedOnType]() {
m_compositing->setCompositingType(type->compositingTypeForIndex(m_form.type->currentIndex()));
showHideBasedOnType();
}
);
}
void KWinCompositingSettings::load()
{
KCModule::load();
m_compositing->reset();
}
void KWinCompositingSettings::defaults()
{
KCModule::defaults();
m_compositing->defaults();
}
void KWinCompositingSettings::save()
{
KCModule::save();
m_compositing->save();
}
KWinCompositingKCM::KWinCompositingKCM(QWidget* parent, const QVariantList& args, KWin::Compositing::EffectView::ViewType viewType)
: KCModule(parent, args)
, m_view(new KWin::Compositing::EffectView(viewType))