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