Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwincompositing/main.cpp
Show All 23 Lines | |||||
24 | #include "ui_compositing.h" | 24 | #include "ui_compositing.h" | ||
25 | #include <QAction> | 25 | #include <QAction> | ||
26 | #include <QApplication> | 26 | #include <QApplication> | ||
27 | #include <QLayout> | 27 | #include <QLayout> | ||
28 | 28 | | |||
29 | #include <kcmodule.h> | 29 | #include <kcmodule.h> | ||
30 | #include <kservice.h> | 30 | #include <kservice.h> | ||
31 | 31 | | |||
32 | #include <algorithm> | ||||
zzag: Where is it used? | |||||
33 | #include <functional> | ||||
34 | | ||||
zzag: Keep them sorted alphabetically please. | |||||
32 | class KWinCompositingSettings : public KCModule | 35 | class KWinCompositingSettings : public KCModule | ||
33 | { | 36 | { | ||
34 | Q_OBJECT | 37 | Q_OBJECT | ||
35 | public: | 38 | public: | ||
36 | explicit KWinCompositingSettings(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); | 39 | explicit KWinCompositingSettings(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); | ||
37 | 40 | | |||
38 | public Q_SLOTS: | 41 | public Q_SLOTS: | ||
39 | void load() override; | 42 | void load() override; | ||
40 | void save() override; | 43 | void save() override; | ||
41 | void defaults() override; | 44 | void defaults() override; | ||
42 | 45 | | |||
43 | private: | 46 | private: | ||
44 | void init(); | 47 | void init(); | ||
45 | KWin::Compositing::Compositing *m_compositing; | 48 | KWin::Compositing::Compositing *m_compositing; | ||
46 | Ui_CompositingForm m_form; | 49 | Ui_CompositingForm m_form; | ||
47 | }; | 50 | }; | ||
48 | 51 | | |||
52 | static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0}; | ||||
53 | | ||||
49 | KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariantList &args) | 54 | KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariantList &args) | ||
50 | : KCModule(parent, args) | 55 | : KCModule(parent, args) | ||
51 | , m_compositing(new KWin::Compositing::Compositing(this)) | 56 | , m_compositing(new KWin::Compositing::Compositing(this)) | ||
52 | { | 57 | { | ||
53 | m_form.setupUi(this); | 58 | m_form.setupUi(this); | ||
54 | m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | 59 | m_form.glCrashedWarning->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); | ||
55 | QAction *reenableGLAction = new QAction(i18n("Re-enable OpenGL detection"), this); | 60 | QAction *reenableGLAction = new QAction(i18n("Re-enable OpenGL detection"), this); | ||
56 | connect(reenableGLAction, &QAction::triggered, m_compositing, &KWin::Compositing::Compositing::reenableOpenGLDetection); | 61 | connect(reenableGLAction, &QAction::triggered, m_compositing, &KWin::Compositing::Compositing::reenableOpenGLDetection); | ||
Show All 17 Lines | 75 | { | |||
74 | connect(m_compositing, &Compositing::changed, this, static_cast<void(KCModule::*)()>(&KWinCompositingSettings::changed)); | 79 | connect(m_compositing, &Compositing::changed, this, static_cast<void(KCModule::*)()>(&KWinCompositingSettings::changed)); | ||
75 | 80 | | |||
76 | // enabled check box | 81 | // enabled check box | ||
77 | m_form.compositingEnabled->setChecked(m_compositing->compositingEnabled()); | 82 | m_form.compositingEnabled->setChecked(m_compositing->compositingEnabled()); | ||
78 | connect(m_compositing, &Compositing::compositingEnabledChanged, m_form.compositingEnabled, &QCheckBox::setChecked); | 83 | connect(m_compositing, &Compositing::compositingEnabledChanged, m_form.compositingEnabled, &QCheckBox::setChecked); | ||
79 | connect(m_form.compositingEnabled, &QCheckBox::toggled, m_compositing, &Compositing::setCompositingEnabled); | 84 | connect(m_form.compositingEnabled, &QCheckBox::toggled, m_compositing, &Compositing::setCompositingEnabled); | ||
80 | 85 | | |||
81 | // animation speed | 86 | // animation speed | ||
82 | m_form.animationSpeed->setValue(m_compositing->animationSpeed()); | 87 | m_form.animationSpeed->setMaximum(s_animationMultipliers.size() - 1); | ||
83 | connect(m_compositing, &Compositing::animationSpeedChanged, m_form.animationSpeed, &QSlider::setValue); | 88 | auto setSpeed = [this](const qreal multiplier) { | ||
zzag: Delete qDebug. | |||||
84 | connect(m_form.animationSpeed, &QSlider::valueChanged, m_compositing, &Compositing::setAnimationSpeed); | 89 | auto const it = std::lower_bound(s_animationMultipliers.begin(), s_animationMultipliers.end(), multiplier, std::greater<qreal>()); | ||
90 | const int index = std::distance(s_animationMultipliers.begin(), it); | ||||
91 | m_form.animationSpeed->setValue(index); | ||||
92 | }; | ||||
93 | setSpeed(m_compositing->animationSpeed()); | ||||
94 | connect(m_compositing, &Compositing::animationSpeedChanged, m_form.animationSpeed, setSpeed); | ||||
95 | connect(m_form.animationSpeed, &QSlider::valueChanged, m_compositing, [this](int index) { | ||||
96 | m_compositing->setAnimationSpeed(s_animationMultipliers[index]); | ||||
97 | }); | ||||
98 | | ||||
99 | if (Compositing::isRunningPlasma()) { | ||||
100 | m_form.animationSpeedLabel->hide(); | ||||
101 | m_form.animationSpeedControls->hide(); | ||||
102 | } | ||||
85 | 103 | | |||
86 | // gl scale filter | 104 | // gl scale filter | ||
87 | m_form.glScaleFilter->setCurrentIndex(m_compositing->glScaleFilter()); | 105 | m_form.glScaleFilter->setCurrentIndex(m_compositing->glScaleFilter()); | ||
88 | connect(m_compositing, &Compositing::glScaleFilterChanged, m_form.glScaleFilter, &QComboBox::setCurrentIndex); | 106 | connect(m_compositing, &Compositing::glScaleFilterChanged, m_form.glScaleFilter, &QComboBox::setCurrentIndex); | ||
89 | connect(m_form.glScaleFilter, currentIndexChangedSignal, m_compositing, &Compositing::setGlScaleFilter); | 107 | connect(m_form.glScaleFilter, currentIndexChangedSignal, m_compositing, &Compositing::setGlScaleFilter); | ||
90 | connect(m_form.glScaleFilter, currentIndexChangedSignal, | 108 | connect(m_form.glScaleFilter, currentIndexChangedSignal, | ||
91 | [this](int index) { | 109 | [this](int index) { | ||
92 | if (index == 2) { | 110 | if (index == 2) { | ||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |
Where is it used?