Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindesktop/animationsmodel.cpp
Show All 24 Lines | |||||
25 | 25 | | |||
26 | AnimationsModel::AnimationsModel(QObject *parent) | 26 | AnimationsModel::AnimationsModel(QObject *parent) | ||
27 | : EffectsModel(parent) | 27 | : EffectsModel(parent) | ||
28 | { | 28 | { | ||
29 | connect(this, &EffectsModel::loaded, this, | 29 | connect(this, &EffectsModel::loaded, this, | ||
30 | [this] { | 30 | [this] { | ||
31 | setEnabled(modelCurrentEnabled()); | 31 | setEnabled(modelCurrentEnabled()); | ||
32 | setCurrentIndex(modelCurrentIndex()); | 32 | setCurrentIndex(modelCurrentIndex()); | ||
33 | loadImmutability(); | ||||
33 | } | 34 | } | ||
34 | ); | 35 | ); | ||
35 | connect(this, &AnimationsModel::currentIndexChanged, this, | 36 | connect(this, &AnimationsModel::currentIndexChanged, this, | ||
36 | [this] { | 37 | [this] { | ||
37 | const QModelIndex index_ = index(m_currentIndex, 0); | 38 | const QModelIndex index_ = index(m_currentIndex, 0); | ||
38 | if (!index_.isValid()) { | 39 | if (!index_.isValid()) { | ||
39 | return; | 40 | return; | ||
40 | } | 41 | } | ||
Show All 32 Lines | 70 | { | |||
73 | } | 74 | } | ||
74 | } | 75 | } | ||
75 | 76 | | |||
76 | bool AnimationsModel::currentConfigurable() const | 77 | bool AnimationsModel::currentConfigurable() const | ||
77 | { | 78 | { | ||
78 | return m_currentConfigurable; | 79 | return m_currentConfigurable; | ||
79 | } | 80 | } | ||
80 | 81 | | |||
82 | bool AnimationsModel::isImmutable() const | ||||
83 | { | ||||
84 | return m_isImmutable; | ||||
85 | } | ||||
86 | | ||||
87 | void AnimationsModel::setIsImmutable(bool isImmutable) | ||||
88 | { | ||||
89 | if (m_isImmutable == isImmutable) { | ||||
90 | return; | ||||
91 | } | ||||
92 | | ||||
93 | m_isImmutable = isImmutable; | ||||
94 | emit isImmutableChanged(m_isImmutable); | ||||
95 | } | ||||
96 | | ||||
81 | bool AnimationsModel::shouldStore(const EffectData &data) const | 97 | bool AnimationsModel::shouldStore(const EffectData &data) const | ||
82 | { | 98 | { | ||
83 | return data.untranslatedCategory.contains( | 99 | return data.untranslatedCategory.contains( | ||
84 | QStringLiteral("Virtual Desktop Switching Animation"), Qt::CaseInsensitive); | 100 | QStringLiteral("Virtual Desktop Switching Animation"), Qt::CaseInsensitive); | ||
85 | } | 101 | } | ||
86 | 102 | | |||
87 | EffectsModel::Status AnimationsModel::status(int row) const | 103 | EffectsModel::Status AnimationsModel::status(int row) const | ||
88 | { | 104 | { | ||
Show All 17 Lines | 121 | for (int i = 0; i < rowCount(); ++i) { | |||
106 | if (status(i) != Status::Disabled) { | 122 | if (status(i) != Status::Disabled) { | ||
107 | return i; | 123 | return i; | ||
108 | } | 124 | } | ||
109 | } | 125 | } | ||
110 | 126 | | |||
111 | return 0; | 127 | return 0; | ||
112 | } | 128 | } | ||
113 | 129 | | |||
130 | void AnimationsModel::loadImmutability() | ||||
131 | { | ||||
132 | // Since there are many entries, consider one is enough to set immutability of | ||||
133 | // switching animation option | ||||
134 | KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins"); | ||||
135 | for (int i = 0; i < rowCount(); ++i) { | ||||
136 | const QModelIndex index_ = index(i, 0); | ||||
137 | const QString entryName = index_.data(ServiceNameRole).toString() + QLatin1String("Enabled"); | ||||
138 | if (kwinConfig.isEntryImmutable(entryName)) { | ||||
139 | setIsImmutable(true); | ||||
140 | break; | ||||
141 | } | ||||
142 | } | ||||
143 | } | ||||
144 | | ||||
114 | void AnimationsModel::load() | 145 | void AnimationsModel::load() | ||
115 | { | 146 | { | ||
116 | EffectsModel::load(); | 147 | EffectsModel::load(); | ||
117 | } | 148 | } | ||
118 | 149 | | |||
119 | void AnimationsModel::save() | 150 | void AnimationsModel::save() | ||
120 | { | 151 | { | ||
121 | for (int i = 0; i < rowCount(); ++i) { | 152 | for (int i = 0; i < rowCount(); ++i) { | ||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |