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 204 Lines • ▼ Show 20 Line(s) | |||||
430 | } | 432 | } | ||
431 | 433 | | |||
432 | QList<Plasma::Types::Location> Corona::freeEdges(int screen) const | 434 | QList<Plasma::Types::Location> Corona::freeEdges(int screen) const | ||
433 | { | 435 | { | ||
434 | QList<Plasma::Types::Location> freeEdges; | 436 | QList<Plasma::Types::Location> freeEdges; | ||
435 | freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge | 437 | freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge | ||
436 | << Plasma::Types::LeftEdge << Plasma::Types::RightEdge; | 438 | << Plasma::Types::LeftEdge << Plasma::Types::RightEdge; | ||
437 | 439 | | |||
438 | foreach (Containment *containment, containments()) { | 440 | const auto containments = this->containments(); | ||
441 | for (Containment *containment : containments) { | ||||
439 | if (containment->screen() == screen && | 442 | if (containment->screen() == screen && | ||
440 | freeEdges.contains(containment->location())) { | 443 | freeEdges.contains(containment->location())) { | ||
441 | freeEdges.removeAll(containment->location()); | 444 | freeEdges.removeAll(containment->location()); | ||
442 | } | 445 | } | ||
443 | } | 446 | } | ||
444 | 447 | | |||
445 | return freeEdges; | 448 | return freeEdges; | ||
446 | } | 449 | } | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 514 | { | |||
514 | } else { | 517 | } else { | ||
515 | q->setImmutability(Types::Mutable); | 518 | q->setImmutability(Types::Mutable); | ||
516 | } | 519 | } | ||
517 | } | 520 | } | ||
518 | 521 | | |||
519 | void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const | 522 | void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const | ||
520 | { | 523 | { | ||
521 | KConfigGroup containmentsGroup(cg, "Containments"); | 524 | KConfigGroup containmentsGroup(cg, "Containments"); | ||
522 | foreach (const Containment *containment, containments) { | 525 | for (const Containment *containment : containments) { | ||
dfaure: (already const, this method is const) | |||||
523 | QString cid = QString::number(containment->id()); | 526 | QString cid = QString::number(containment->id()); | ||
524 | KConfigGroup containmentConfig(&containmentsGroup, cid); | 527 | KConfigGroup containmentConfig(&containmentsGroup, cid); | ||
525 | containment->save(containmentConfig); | 528 | containment->save(containmentConfig); | ||
526 | } | 529 | } | ||
527 | } | 530 | } | ||
528 | 531 | | |||
529 | void CoronaPrivate::updateContainmentImmutability() | 532 | void CoronaPrivate::updateContainmentImmutability() | ||
530 | { | 533 | { | ||
531 | foreach (Containment *c, containments) { | 534 | for (Containment *c : qAsConst(containments)) { | ||
532 | // we need to tell each containment that immutability has been altered | 535 | // we need to tell each containment that immutability has been altered | ||
533 | c->updateConstraints(Types::ImmutableConstraint); | 536 | c->updateConstraints(Types::ImmutableConstraint); | ||
534 | } | 537 | } | ||
535 | } | 538 | } | ||
536 | 539 | | |||
537 | void CoronaPrivate::containmentDestroyed(QObject *obj) | 540 | void CoronaPrivate::containmentDestroyed(QObject *obj) | ||
538 | { | 541 | { | ||
539 | // we do a static_cast here since it really isn't an Containment by this | 542 | // 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) | |||||
646 | { | 649 | { | ||
647 | if (!conf.isValid()) { | 650 | if (!conf.isValid()) { | ||
648 | return QList<Containment *>(); | 651 | return QList<Containment *>(); | ||
649 | } | 652 | } | ||
650 | 653 | | |||
651 | QList<Plasma::Containment *> newContainments; | 654 | QList<Plasma::Containment *> newContainments; | ||
652 | QSet<uint> containmentsIds; | 655 | QSet<uint> containmentsIds; | ||
653 | 656 | | |||
654 | foreach (Containment *containment, containments) { | 657 | for (Containment *containment : qAsConst(containments)) { | ||
655 | containmentsIds.insert(containment->id()); | 658 | containmentsIds.insert(containment->id()); | ||
656 | } | 659 | } | ||
657 | 660 | | |||
658 | KConfigGroup containmentsGroup(&conf, "Containments"); | 661 | KConfigGroup containmentsGroup(&conf, "Containments"); | ||
659 | QStringList groups = containmentsGroup.groupList(); | 662 | QStringList groups = containmentsGroup.groupList(); | ||
660 | std::sort(groups.begin(), groups.end()); | 663 | std::sort(groups.begin(), groups.end()); | ||
661 | 664 | | |||
662 | foreach (const QString &group, groups) { | 665 | for (const QString &group : qAsConst(groups)) { | ||
663 | KConfigGroup containmentConfig(&containmentsGroup, group); | 666 | KConfigGroup containmentConfig(&containmentsGroup, group); | ||
664 | 667 | | |||
665 | if (containmentConfig.entryMap().isEmpty()) { | 668 | if (containmentConfig.entryMap().isEmpty()) { | ||
666 | continue; | 669 | continue; | ||
667 | } | 670 | } | ||
668 | 671 | | |||
669 | uint cid = group.toUInt(); | 672 | uint cid = group.toUInt(); | ||
670 | if (containmentsIds.contains(cid)) { | 673 | if (containmentsIds.contains(cid)) { | ||
Show All 32 Lines | 701 | #endif | |||
703 | } | 706 | } | ||
704 | 707 | | |||
705 | return newContainments; | 708 | return newContainments; | ||
706 | } | 709 | } | ||
707 | 710 | | |||
708 | void CoronaPrivate::notifyContainmentsReady() | 711 | void CoronaPrivate::notifyContainmentsReady() | ||
709 | { | 712 | { | ||
710 | containmentsStarting = 0; | 713 | containmentsStarting = 0; | ||
711 | foreach (Containment *containment, containments) { | 714 | for (Containment *containment : qAsConst(containments)) { | ||
712 | if (!containment->isUiReady() && containment->screen() >= 0) { | 715 | if (!containment->isUiReady() && containment->screen() >= 0) { | ||
713 | ++containmentsStarting; | 716 | ++containmentsStarting; | ||
714 | QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { containmentReady(ready); } ); | 717 | QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { containmentReady(ready); } ); | ||
715 | } | 718 | } | ||
716 | } | 719 | } | ||
717 | 720 | | |||
718 | if (containmentsStarting <= 0) { | 721 | if (containmentsStarting <= 0) { | ||
719 | emit q->startupCompleted(); | 722 | emit q->startupCompleted(); | ||
Show All 17 Lines |
applets?