Changeset View
Changeset View
Standalone View
Standalone View
kded/config.cpp
Show All 33 Lines | |||||
34 | QString Config::s_fixedConfigFileName = QStringLiteral("fixed-config"); | 34 | QString Config::s_fixedConfigFileName = QStringLiteral("fixed-config"); | ||
35 | QString Config::s_configsDirName = QStringLiteral("" /*"configs/"*/); // TODO: KDE6 - move these files into the subfolder | 35 | QString Config::s_configsDirName = QStringLiteral("" /*"configs/"*/); // TODO: KDE6 - move these files into the subfolder | ||
36 | 36 | | |||
37 | QString Config::configsDirPath() | 37 | QString Config::configsDirPath() | ||
38 | { | 38 | { | ||
39 | return Globals::dirPath() % s_configsDirName; | 39 | return Globals::dirPath() % s_configsDirName; | ||
40 | } | 40 | } | ||
41 | 41 | | |||
42 | Config::Config(KScreen::ConfigPtr config) | 42 | Config::Config(KScreen::ConfigPtr config, QObject *parent) | ||
43 | : m_data(config) | 43 | : QObject(parent) | ||
44 | , m_data(config) | ||||
45 | , m_control(new ControlConfig(config, this)) | ||||
romangg: Caching it means we don't read in new retention value when it changed. So this patch without a… | |||||
44 | { | 46 | { | ||
45 | } | 47 | } | ||
46 | 48 | | |||
47 | QString Config::filePath() | 49 | QString Config::filePath() | ||
48 | { | 50 | { | ||
49 | if (!QDir().mkpath(configsDirPath())) { | 51 | if (!QDir().mkpath(configsDirPath())) { | ||
50 | return QString(); | 52 | return QString(); | ||
51 | } | 53 | } | ||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | |||||
164 | 166 | | |||
165 | bool Config::writeFile(const QString &filePath) | 167 | bool Config::writeFile(const QString &filePath) | ||
166 | { | 168 | { | ||
167 | if (id().isEmpty()) { | 169 | if (id().isEmpty()) { | ||
168 | return false; | 170 | return false; | ||
169 | } | 171 | } | ||
170 | const KScreen::OutputList outputs = m_data->outputs(); | 172 | const KScreen::OutputList outputs = m_data->outputs(); | ||
171 | 173 | | |||
172 | const auto control = ControlConfig(m_data); | 174 | // TODO: until we have the file watcher this is necessary to reload control files. | ||
175 | delete m_control; | ||||
176 | m_control = new ControlConfig(m_data, this); | ||||
173 | 177 | | |||
174 | const auto oldConfig = readFile(); | 178 | const auto oldConfig = readFile(); | ||
175 | KScreen::OutputList oldOutputs; | 179 | KScreen::OutputList oldOutputs; | ||
176 | if (oldConfig) { | 180 | if (oldConfig) { | ||
177 | oldOutputs = oldConfig->data()->outputs(); | 181 | oldOutputs = oldConfig->data()->outputs(); | ||
178 | } | 182 | } | ||
179 | 183 | | |||
180 | QVariantList outputList; | 184 | QVariantList outputList; | ||
Show All 29 Lines | 204 | auto setOutputConfigInfo = [this, &info](const KScreen::OutputPtr &out) { | |||
210 | QVariantMap pos; | 214 | QVariantMap pos; | ||
211 | pos[QStringLiteral("x")] = out->pos().x(); | 215 | pos[QStringLiteral("x")] = out->pos().x(); | ||
212 | pos[QStringLiteral("y")] = out->pos().y(); | 216 | pos[QStringLiteral("y")] = out->pos().y(); | ||
213 | info[QStringLiteral("pos")] = pos; | 217 | info[QStringLiteral("pos")] = pos; | ||
214 | }; | 218 | }; | ||
215 | setOutputConfigInfo(output->isEnabled() ? output : oldOutput); | 219 | setOutputConfigInfo(output->isEnabled() ? output : oldOutput); | ||
216 | 220 | | |||
217 | if (output->isEnabled() && | 221 | if (output->isEnabled() && | ||
218 | control.getOutputRetention(output->hash(), output->name()) != | 222 | m_control->getOutputRetention(output->hash(), output->name()) != | ||
219 | Control::OutputRetention::Individual) { | 223 | Control::OutputRetention::Individual) { | ||
220 | // try to update global output data | 224 | // try to update global output data | ||
221 | Output::writeGlobal(output); | 225 | Output::writeGlobal(output); | ||
222 | } | 226 | } | ||
223 | 227 | | |||
224 | outputList.append(info); | 228 | outputList.append(info); | ||
225 | } | 229 | } | ||
226 | 230 | | |||
Show All 23 Lines |
Caching it means we don't read in new retention value when it changed. So this patch without a file watcher yet or other system to communicate changes breaks the runtime. Solution without it: do not cache but in writeFile always create new object for now.