Changeset View
Changeset View
Standalone View
Standalone View
src/plasma/corona.cpp
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 104 | } else { | |||
---|---|---|---|---|---|
105 | c = KSharedConfig::openConfig(configName, KConfig::SimpleConfig); | 105 | c = KSharedConfig::openConfig(configName, KConfig::SimpleConfig); | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | d->saveLayout(c); | 108 | d->saveLayout(c); | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | void Corona::exportLayout(KConfigGroup &config, QList<Containment *> containments) | 111 | void Corona::exportLayout(KConfigGroup &config, QList<Containment *> containments) | ||
112 | { | 112 | { | ||
113 | foreach (const QString &group, config.groupList()) { | 113 | const auto groupList = config.groupList(); | ||
114 | for (const QString &group : groupList) { | ||||
114 | KConfigGroup cg(&config, group); | 115 | KConfigGroup cg(&config, group); | ||
115 | cg.deleteGroup(); | 116 | cg.deleteGroup(); | ||
116 | } | 117 | } | ||
117 | 118 | | |||
118 | //temporarily unlock so that removal works | 119 | //temporarily unlock so that removal works | ||
119 | Types::ImmutabilityType oldImm = immutability(); | 120 | Types::ImmutabilityType oldImm = immutability(); | ||
120 | d->immutability = Types::Mutable; | 121 | d->immutability = Types::Mutable; | ||
121 | 122 | | |||
122 | KConfigGroup dest(&config, "Containments"); | 123 | KConfigGroup dest(&config, "Containments"); | ||
123 | KConfigGroup dummy; | 124 | KConfigGroup dummy; | ||
124 | foreach (Plasma::Containment *c, containments) { | 125 | for (Plasma::Containment *c : qAsConst(containments)) { | ||
125 | c->save(dummy); | 126 | c->save(dummy); | ||
126 | c->config().reparent(&dest); | 127 | c->config().reparent(&dest); | ||
127 | 128 | | |||
128 | //ensure the containment is unlocked | 129 | //ensure the containment is unlocked | ||
129 | //this is done directly because we have to bypass any Types::SystemImmutable checks | 130 | //this is done directly because we have to bypass any Types::SystemImmutable checks | ||
130 | c->Applet::d->immutability = Types::Mutable; | 131 | c->Applet::d->immutability = Types::Mutable; | ||
131 | foreach (Applet *a, c->applets()) { | 132 | const auto lstApplet = c->applets(); | ||
133 | for (Applet *a : lstApplet) { | ||||
apol: applets? | |||||
132 | a->d->immutability = Types::Mutable; | 134 | a->d->immutability = Types::Mutable; | ||
133 | } | 135 | } | ||
134 | 136 | | |||
135 | c->destroy(); | 137 | c->destroy(); | ||
136 | } | 138 | } | ||
137 | 139 | | |||
138 | //restore immutability | 140 | //restore immutability | ||
139 | d->immutability = oldImm; | 141 | d->immutability = oldImm; | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
186 | 188 | | |||
187 | QList<Plasma::Containment *> Corona::importLayout(const KConfigGroup &conf) | 189 | QList<Plasma::Containment *> Corona::importLayout(const KConfigGroup &conf) | ||
188 | { | 190 | { | ||
189 | return d->importLayout(conf, true); | 191 | return d->importLayout(conf, true); | ||
190 | } | 192 | } | ||
191 | 193 | | |||
192 | Containment *Corona::containmentForScreen(int screen) const | 194 | Containment *Corona::containmentForScreen(int screen) const | ||
193 | { | 195 | { | ||
194 | foreach (Containment *containment, d->containments) { | 196 | for (Containment *containment : qAsConst(d->containments)) { | ||
195 | if (containment->screen() == screen && | 197 | if (containment->screen() == screen && | ||
196 | (containment->containmentType() == Plasma::Types::DesktopContainment || | 198 | (containment->containmentType() == Plasma::Types::DesktopContainment || | ||
197 | containment->containmentType() == Plasma::Types::CustomContainment)) { | 199 | containment->containmentType() == Plasma::Types::CustomContainment)) { | ||
198 | return containment; | 200 | return containment; | ||
199 | } | 201 | } | ||
200 | } | 202 | } | ||
201 | 203 | | |||
202 | return nullptr; | 204 | return nullptr; | ||
203 | } | 205 | } | ||
204 | 206 | | |||
205 | Containment *Corona::containmentForScreen(int screen, | 207 | Containment *Corona::containmentForScreen(int screen, | ||
206 | const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) | 208 | const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) | ||
207 | { | 209 | { | ||
208 | return containmentForScreen(screen, QString(), defaultPluginIfNonExistent, defaultArgs); | 210 | return containmentForScreen(screen, QString(), defaultPluginIfNonExistent, defaultArgs); | ||
209 | } | 211 | } | ||
210 | 212 | | |||
211 | Containment *Corona::containmentForScreen(int screen, | 213 | Containment *Corona::containmentForScreen(int screen, | ||
212 | const QString &activity, | 214 | const QString &activity, | ||
213 | const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) | 215 | const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) | ||
214 | { | 216 | { | ||
215 | Containment *containment = nullptr; | 217 | Containment *containment = nullptr; | ||
216 | 218 | | |||
217 | foreach (Containment *cont, d->containments) { | 219 | for (Containment *cont : qAsConst(d->containments)) { | ||
218 | if (cont->lastScreen() == screen && | 220 | if (cont->lastScreen() == screen && | ||
219 | (cont->activity().isEmpty() || cont->activity() == activity) && | 221 | (cont->activity().isEmpty() || cont->activity() == activity) && | ||
220 | (cont->containmentType() == Plasma::Types::DesktopContainment || | 222 | (cont->containmentType() == Plasma::Types::DesktopContainment || | ||
221 | cont->containmentType() == Plasma::Types::CustomContainment)) { | 223 | cont->containmentType() == Plasma::Types::CustomContainment)) { | ||
222 | containment = cont; | 224 | containment = cont; | ||
223 | } | 225 | } | ||
224 | } | 226 | } | ||
225 | 227 | | |||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | |||||
383 | } | 385 | } | ||
384 | 386 | | |||
385 | QList<Plasma::Types::Location> Corona::freeEdges(int screen) const | 387 | QList<Plasma::Types::Location> Corona::freeEdges(int screen) const | ||
386 | { | 388 | { | ||
387 | QList<Plasma::Types::Location> freeEdges; | 389 | QList<Plasma::Types::Location> freeEdges; | ||
388 | freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge | 390 | freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge | ||
389 | << Plasma::Types::LeftEdge << Plasma::Types::RightEdge; | 391 | << Plasma::Types::LeftEdge << Plasma::Types::RightEdge; | ||
390 | 392 | | |||
391 | foreach (Containment *containment, containments()) { | 393 | const auto containments = this->containments(); | ||
394 | for (Containment *containment : containments) { | ||||
392 | if (containment->screen() == screen && | 395 | if (containment->screen() == screen && | ||
393 | freeEdges.contains(containment->location())) { | 396 | freeEdges.contains(containment->location())) { | ||
394 | freeEdges.removeAll(containment->location()); | 397 | freeEdges.removeAll(containment->location()); | ||
395 | } | 398 | } | ||
396 | } | 399 | } | ||
397 | 400 | | |||
398 | return freeEdges; | 401 | return freeEdges; | ||
399 | } | 402 | } | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 456 | { | |||
456 | } else { | 459 | } else { | ||
457 | q->setImmutability(Types::Mutable); | 460 | q->setImmutability(Types::Mutable); | ||
458 | } | 461 | } | ||
459 | } | 462 | } | ||
460 | 463 | | |||
461 | void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const | 464 | void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const | ||
462 | { | 465 | { | ||
463 | KConfigGroup containmentsGroup(cg, "Containments"); | 466 | KConfigGroup containmentsGroup(cg, "Containments"); | ||
464 | foreach (const Containment *containment, containments) { | 467 | for (const Containment *containment : qAsConst(containments)) { | ||
dfaure: (already const, this method is const) | |||||
465 | QString cid = QString::number(containment->id()); | 468 | QString cid = QString::number(containment->id()); | ||
466 | KConfigGroup containmentConfig(&containmentsGroup, cid); | 469 | KConfigGroup containmentConfig(&containmentsGroup, cid); | ||
467 | containment->save(containmentConfig); | 470 | containment->save(containmentConfig); | ||
468 | } | 471 | } | ||
469 | } | 472 | } | ||
470 | 473 | | |||
471 | void CoronaPrivate::updateContainmentImmutability() | 474 | void CoronaPrivate::updateContainmentImmutability() | ||
472 | { | 475 | { | ||
473 | foreach (Containment *c, containments) { | 476 | for (Containment *c : qAsConst(containments)) { | ||
474 | // we need to tell each containment that immutability has been altered | 477 | // we need to tell each containment that immutability has been altered | ||
475 | c->updateConstraints(Types::ImmutableConstraint); | 478 | c->updateConstraints(Types::ImmutableConstraint); | ||
476 | } | 479 | } | ||
477 | } | 480 | } | ||
478 | 481 | | |||
479 | void CoronaPrivate::containmentDestroyed(QObject *obj) | 482 | void CoronaPrivate::containmentDestroyed(QObject *obj) | ||
480 | { | 483 | { | ||
481 | // we do a static_cast here since it really isn't an Containment by this | 484 | // we do a static_cast here since it really isn't an Containment by this | ||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | |||||
588 | { | 591 | { | ||
589 | if (!conf.isValid()) { | 592 | if (!conf.isValid()) { | ||
590 | return QList<Containment *>(); | 593 | return QList<Containment *>(); | ||
591 | } | 594 | } | ||
592 | 595 | | |||
593 | QList<Plasma::Containment *> newContainments; | 596 | QList<Plasma::Containment *> newContainments; | ||
594 | QSet<uint> containmentsIds; | 597 | QSet<uint> containmentsIds; | ||
595 | 598 | | |||
596 | foreach (Containment *containment, containments) { | 599 | for (Containment *containment : qAsConst(containments)) { | ||
597 | containmentsIds.insert(containment->id()); | 600 | containmentsIds.insert(containment->id()); | ||
598 | } | 601 | } | ||
599 | 602 | | |||
600 | KConfigGroup containmentsGroup(&conf, "Containments"); | 603 | KConfigGroup containmentsGroup(&conf, "Containments"); | ||
601 | QStringList groups = containmentsGroup.groupList(); | 604 | QStringList groups = containmentsGroup.groupList(); | ||
602 | std::sort(groups.begin(), groups.end()); | 605 | std::sort(groups.begin(), groups.end()); | ||
603 | 606 | | |||
604 | foreach (const QString &group, groups) { | 607 | for (const QString &group : qAsConst(groups)) { | ||
605 | KConfigGroup containmentConfig(&containmentsGroup, group); | 608 | KConfigGroup containmentConfig(&containmentsGroup, group); | ||
606 | 609 | | |||
607 | if (containmentConfig.entryMap().isEmpty()) { | 610 | if (containmentConfig.entryMap().isEmpty()) { | ||
608 | continue; | 611 | continue; | ||
609 | } | 612 | } | ||
610 | 613 | | |||
611 | uint cid = group.toUInt(); | 614 | uint cid = group.toUInt(); | ||
612 | if (containmentsIds.contains(cid)) { | 615 | if (containmentsIds.contains(cid)) { | ||
Show All 32 Lines | 643 | #endif | |||
645 | } | 648 | } | ||
646 | 649 | | |||
647 | return newContainments; | 650 | return newContainments; | ||
648 | } | 651 | } | ||
649 | 652 | | |||
650 | void CoronaPrivate::notifyContainmentsReady() | 653 | void CoronaPrivate::notifyContainmentsReady() | ||
651 | { | 654 | { | ||
652 | containmentsStarting = 0; | 655 | containmentsStarting = 0; | ||
653 | foreach (Containment *containment, containments) { | 656 | for (Containment *containment : qAsConst(containments)) { | ||
654 | if (!containment->isUiReady() && containment->screen() >= 0) { | 657 | if (!containment->isUiReady() && containment->screen() >= 0) { | ||
655 | ++containmentsStarting; | 658 | ++containmentsStarting; | ||
656 | QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { containmentReady(ready); } ); | 659 | QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { containmentReady(ready); } ); | ||
657 | } | 660 | } | ||
658 | } | 661 | } | ||
659 | 662 | | |||
660 | if (containmentsStarting <= 0) { | 663 | if (containmentsStarting <= 0) { | ||
661 | emit q->startupCompleted(); | 664 | emit q->startupCompleted(); | ||
Show All 17 Lines |
applets?