Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindesktop/animationsmodel.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | 20 | | |||
21 | #include "animationsmodel.h" | 21 | #include "animationsmodel.h" | ||
22 | 22 | | |||
23 | namespace KWin | 23 | namespace KWin | ||
24 | { | 24 | { | ||
25 | 25 | | |||
26 | AnimationsModel::AnimationsModel(QObject *parent) | 26 | AnimationsModel::AnimationsModel(QObject *parent) | ||
27 | : EffectModel(parent) | 27 | : EffectsModel(parent) | ||
28 | { | 28 | { | ||
29 | connect(this, &AnimationsModel::currentIndexChanged, this, | 29 | connect(this, &AnimationsModel::currentIndexChanged, this, | ||
30 | [this] { | 30 | [this] { | ||
31 | const QModelIndex index_ = index(m_currentIndex, 0); | 31 | const QModelIndex index_ = index(m_currentIndex, 0); | ||
32 | if (!index_.isValid()) { | 32 | if (!index_.isValid()) { | ||
33 | return; | 33 | return; | ||
34 | } | 34 | } | ||
35 | const bool configurable = index_.data(ConfigurableRole).toBool(); | 35 | const bool configurable = index_.data(ConfigurableRole).toBool(); | ||
Show All 37 Lines | |||||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | bool AnimationsModel::shouldStore(const EffectData &data) const | 75 | bool AnimationsModel::shouldStore(const EffectData &data) const | ||
76 | { | 76 | { | ||
77 | return data.untranslatedCategory.contains( | 77 | return data.untranslatedCategory.contains( | ||
78 | QStringLiteral("Virtual Desktop Switching Animation"), Qt::CaseInsensitive); | 78 | QStringLiteral("Virtual Desktop Switching Animation"), Qt::CaseInsensitive); | ||
79 | } | 79 | } | ||
80 | 80 | | |||
81 | EffectModel::Status AnimationsModel::status(int row) const | 81 | EffectsModel::Status AnimationsModel::status(int row) const | ||
82 | { | 82 | { | ||
83 | return Status(data(index(row, 0), static_cast<int>(EffectStatusRole)).toInt()); | 83 | return Status(data(index(row, 0), static_cast<int>(EffectStatusRole)).toInt()); | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | bool AnimationsModel::modelCurrentEnabled() const | 86 | bool AnimationsModel::modelCurrentEnabled() const | ||
87 | { | 87 | { | ||
88 | for (int i = 0; i < rowCount(); ++i) { | 88 | for (int i = 0; i < rowCount(); ++i) { | ||
89 | if (status(i) != Status::Disabled) { | 89 | if (status(i) != Status::Disabled) { | ||
Show All 12 Lines | 99 | for (int i = 0; i < rowCount(); ++i) { | |||
102 | } | 102 | } | ||
103 | } | 103 | } | ||
104 | 104 | | |||
105 | return 0; | 105 | return 0; | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | void AnimationsModel::load() | 108 | void AnimationsModel::load() | ||
109 | { | 109 | { | ||
110 | EffectModel::load(); | 110 | EffectsModel::load(); | ||
111 | setEnabled(modelCurrentEnabled()); | 111 | setEnabled(modelCurrentEnabled()); | ||
112 | setCurrentIndex(modelCurrentIndex()); | 112 | setCurrentIndex(modelCurrentIndex()); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | void AnimationsModel::save() | 115 | void AnimationsModel::save() | ||
116 | { | 116 | { | ||
117 | for (int i = 0; i < rowCount(); ++i) { | 117 | for (int i = 0; i < rowCount(); ++i) { | ||
118 | const auto status = (m_enabled && i == m_currentIndex) | 118 | const auto status = (m_enabled && i == m_currentIndex) | ||
119 | ? EffectModel::Status::Enabled | 119 | ? EffectsModel::Status::Enabled | ||
120 | : EffectModel::Status::Disabled; | 120 | : EffectsModel::Status::Disabled; | ||
121 | updateEffectStatus(index(i, 0), status); | 121 | updateEffectStatus(index(i, 0), status); | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | EffectModel::save(); | 124 | EffectsModel::save(); | ||
125 | } | 125 | } | ||
126 | 126 | | |||
127 | void AnimationsModel::defaults() | 127 | void AnimationsModel::defaults() | ||
128 | { | 128 | { | ||
129 | EffectModel::defaults(); | 129 | EffectsModel::defaults(); | ||
130 | setEnabled(modelCurrentEnabled()); | 130 | setEnabled(modelCurrentEnabled()); | ||
131 | setCurrentIndex(modelCurrentIndex()); | 131 | setCurrentIndex(modelCurrentIndex()); | ||
132 | } | 132 | } | ||
133 | 133 | | |||
134 | bool AnimationsModel::needsSave() const | 134 | bool AnimationsModel::needsSave() const | ||
135 | { | 135 | { | ||
136 | KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); | 136 | KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); | ||
137 | 137 | | |||
Show All 17 Lines |