2008-11-04 00:08:39 +01:00
|
|
|
/*
|
2020-08-13 21:08:54 +02:00
|
|
|
SPDX-FileCopyrightText: 2007 Matt Broadstone <mbroadst@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2007-2011 Aaron Seigo <aseigo@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2007 Riccardo Iaconelli <riccardo@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2009 Chani Armitage <chani@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
*/
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
#include "corona.h"
|
2012-09-24 18:10:25 +02:00
|
|
|
#include "private/corona_p.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2014-06-04 18:55:05 +02:00
|
|
|
#include <QGuiApplication>
|
2008-11-04 00:08:39 +01:00
|
|
|
#include <QMimeData>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QTimer>
|
2014-06-04 18:55:05 +02:00
|
|
|
#include <QScreen>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2008-12-12 15:41:15 +01:00
|
|
|
#include <cmath>
|
|
|
|
|
2013-07-29 19:05:59 +02:00
|
|
|
#include <QDebug>
|
2020-07-08 07:44:43 +02:00
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <KWindowSystem>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
#include "containment.h"
|
2011-07-19 22:04:22 +02:00
|
|
|
#include "pluginloader.h"
|
2014-11-11 16:44:48 +01:00
|
|
|
#include "packagestructure.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
#include "private/applet_p.h"
|
2009-05-03 22:22:14 +02:00
|
|
|
#include "private/containment_p.h"
|
2014-11-11 16:44:48 +01:00
|
|
|
#include "private/package_p.h"
|
2014-07-14 13:23:20 +02:00
|
|
|
#include "private/timetracker.h"
|
2015-12-15 22:56:40 +01:00
|
|
|
#include "debug_p.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
using namespace Plasma;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
Corona::Corona(QObject *parent)
|
2012-09-24 18:10:25 +02:00
|
|
|
: QObject(parent),
|
2008-11-04 00:08:39 +01:00
|
|
|
d(new CoronaPrivate(this))
|
|
|
|
{
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Corona ctor start";
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
d->init();
|
2014-07-14 13:23:20 +02:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2015-12-27 20:37:30 +01:00
|
|
|
if (qEnvironmentVariableIsSet("PLASMA_TRACK_STARTUP")) {
|
|
|
|
new TimeTracker(this);
|
|
|
|
}
|
2014-07-14 13:23:20 +02:00
|
|
|
#endif
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Corona::~Corona()
|
|
|
|
{
|
2012-03-24 19:33:54 +01:00
|
|
|
KConfigGroup trans(KSharedConfig::openConfig(), "PlasmaTransientsConfig");
|
2009-01-22 01:00:16 +01:00
|
|
|
trans.deleteGroup();
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2013-02-12 14:26:34 +01:00
|
|
|
Plasma::Package Corona::package() const
|
|
|
|
{
|
2018-11-19 22:41:38 +01:00
|
|
|
return Package(d->package);
|
2013-02-12 14:26:34 +01:00
|
|
|
}
|
|
|
|
|
2013-09-02 18:04:22 +02:00
|
|
|
void Corona::setPackage(const Plasma::Package &package)
|
2013-08-31 17:33:09 +02:00
|
|
|
{
|
2014-11-11 16:44:48 +01:00
|
|
|
setKPackage(*package.d->internalPackage);
|
2013-09-02 21:06:35 +02:00
|
|
|
emit packageChanged(package);
|
2013-08-31 17:33:09 +02:00
|
|
|
}
|
|
|
|
|
2014-11-11 16:44:48 +01:00
|
|
|
KPackage::Package Corona::kPackage() const
|
|
|
|
{
|
|
|
|
return d->package;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Corona::setKPackage(const KPackage::Package &package)
|
|
|
|
{
|
|
|
|
d->package = package;
|
|
|
|
emit kPackageChanged(package);
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void Corona::saveLayout(const QString &configName) const
|
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
KSharedConfigPtr c;
|
|
|
|
|
|
|
|
if (configName.isEmpty() || configName == d->configName) {
|
|
|
|
c = config();
|
|
|
|
} else {
|
|
|
|
c = KSharedConfig::openConfig(configName, KConfig::SimpleConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
d->saveLayout(c);
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2014-04-26 01:45:47 +02:00
|
|
|
void Corona::exportLayout(KConfigGroup &config, QList<Containment *> containments)
|
2010-09-27 20:16:43 +02:00
|
|
|
{
|
2019-03-20 07:12:03 +01:00
|
|
|
const auto groupList = config.groupList();
|
|
|
|
for (const QString &group : groupList) {
|
2012-09-24 18:10:25 +02:00
|
|
|
KConfigGroup cg(&config, group);
|
|
|
|
cg.deleteGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
//temporarily unlock so that removal works
|
2013-05-14 20:27:32 +02:00
|
|
|
Types::ImmutabilityType oldImm = immutability();
|
2013-05-10 19:29:13 +02:00
|
|
|
d->immutability = Types::Mutable;
|
2012-09-24 18:10:25 +02:00
|
|
|
|
|
|
|
KConfigGroup dest(&config, "Containments");
|
|
|
|
KConfigGroup dummy;
|
2019-03-20 07:12:03 +01:00
|
|
|
for (Plasma::Containment *c : qAsConst(containments)) {
|
2012-09-24 18:10:25 +02:00
|
|
|
c->save(dummy);
|
|
|
|
c->config().reparent(&dest);
|
|
|
|
|
|
|
|
//ensure the containment is unlocked
|
2013-05-10 19:29:13 +02:00
|
|
|
//this is done directly because we have to bypass any Types::SystemImmutable checks
|
|
|
|
c->Applet::d->immutability = Types::Mutable;
|
2019-03-20 07:12:03 +01:00
|
|
|
const auto lstApplet = c->applets();
|
|
|
|
for (Applet *a : lstApplet) {
|
2013-05-10 19:29:13 +02:00
|
|
|
a->d->immutability = Types::Mutable;
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
|
|
|
|
2013-02-18 18:59:47 +01:00
|
|
|
c->destroy();
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//restore immutability
|
|
|
|
d->immutability = oldImm;
|
|
|
|
|
|
|
|
config.sync();
|
2010-09-27 20:16:43 +02:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void Corona::requestConfigSync()
|
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
// constant controlling how long between requesting a configuration sync
|
|
|
|
// and one happening should occur. currently 10 seconds
|
|
|
|
static const int CONFIG_SYNC_TIMEOUT = 10000;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
// TODO: should we check into our immutability before doing this?
|
2008-12-18 23:12:49 +01:00
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
//NOTE: this is a pretty simplistic model: we simply save no more than CONFIG_SYNC_TIMEOUT
|
|
|
|
// after the first time this is called. not much of a heuristic for save points, but
|
|
|
|
// it should at least compress these activities a bit and provide a way for applet
|
|
|
|
// authors to ween themselves from the sync() disease. A more interesting/dynamic
|
|
|
|
// algorithm for determining when to actually sync() to disk might be better, though.
|
2012-12-20 10:47:51 +01:00
|
|
|
if (!d->configSyncTimer->isActive()) {
|
|
|
|
d->configSyncTimer->start(CONFIG_SYNC_TIMEOUT);
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
void Corona::requireConfigSync()
|
2010-02-24 15:24:52 +01:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
d->syncConfig();
|
2010-02-24 15:24:52 +01:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
void Corona::loadLayout(const QString &configName)
|
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
if (!configName.isEmpty() && configName != d->configName) {
|
|
|
|
// if we have a new config name passed in, then use that as the config file for this Corona
|
2018-04-13 13:58:44 +02:00
|
|
|
d->config = nullptr;
|
2012-09-24 18:10:25 +02:00
|
|
|
d->configName = configName;
|
|
|
|
}
|
|
|
|
|
|
|
|
KConfigGroup conf(config(), QString());
|
2016-03-16 12:33:10 +01:00
|
|
|
if (!config()->groupList().isEmpty()) {
|
|
|
|
d->importLayout(conf, false);
|
2016-06-07 15:23:13 +02:00
|
|
|
} else {
|
|
|
|
loadDefaultLayout();
|
|
|
|
d->notifyContainmentsReady();
|
2016-03-16 12:33:10 +01:00
|
|
|
}
|
2014-04-30 19:30:23 +02:00
|
|
|
|
|
|
|
KConfigGroup cg(config(), "General");
|
|
|
|
setImmutability((Plasma::Types::ImmutabilityType)cg.readEntry("immutability", (int)Plasma::Types::Mutable));
|
2010-05-14 19:00:54 +02:00
|
|
|
}
|
2009-10-11 19:06:26 +02:00
|
|
|
|
2010-09-27 20:16:43 +02:00
|
|
|
QList<Plasma::Containment *> Corona::importLayout(const KConfigGroup &conf)
|
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
return d->importLayout(conf, true);
|
2010-09-27 20:16:43 +02:00
|
|
|
}
|
|
|
|
|
2013-02-18 18:05:45 +01:00
|
|
|
Containment *Corona::containmentForScreen(int screen) const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2019-03-20 07:12:03 +01:00
|
|
|
for (Containment *containment : qAsConst(d->containments)) {
|
2012-09-24 18:10:25 +02:00
|
|
|
if (containment->screen() == screen &&
|
2018-03-30 13:06:15 +02:00
|
|
|
(containment->containmentType() == Plasma::Types::DesktopContainment ||
|
|
|
|
containment->containmentType() == Plasma::Types::CustomContainment)) {
|
2012-09-24 18:10:25 +02:00
|
|
|
return containment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 13:58:44 +02:00
|
|
|
return nullptr;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2014-07-28 13:41:58 +02:00
|
|
|
Containment *Corona::containmentForScreen(int screen,
|
|
|
|
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
|
|
|
|
{
|
2018-03-30 13:06:15 +02:00
|
|
|
return containmentForScreen(screen, QString(), defaultPluginIfNonExistent, defaultArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
Containment *Corona::containmentForScreen(int screen,
|
|
|
|
const QString &activity,
|
|
|
|
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
|
|
|
|
{
|
|
|
|
Containment *containment = nullptr;
|
|
|
|
|
2019-03-20 07:12:03 +01:00
|
|
|
for (Containment *cont : qAsConst(d->containments)) {
|
2018-03-30 13:06:15 +02:00
|
|
|
if (cont->lastScreen() == screen &&
|
|
|
|
(cont->activity().isEmpty() || cont->activity() == activity) &&
|
|
|
|
(cont->containmentType() == Plasma::Types::DesktopContainment ||
|
|
|
|
cont->containmentType() == Plasma::Types::CustomContainment)) {
|
|
|
|
containment = cont;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-28 13:41:58 +02:00
|
|
|
if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
|
|
|
|
// screen requests are allowed to bypass immutability
|
2016-07-18 14:43:03 +02:00
|
|
|
if (screen >= 0) {
|
2014-07-28 13:41:58 +02:00
|
|
|
Plasma::Types::ImmutabilityType imm = d->immutability;
|
|
|
|
d->immutability = Types::Mutable;
|
2018-03-30 13:06:15 +02:00
|
|
|
containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0, screen, false);
|
2018-04-16 13:36:07 +02:00
|
|
|
|
2014-07-28 13:41:58 +02:00
|
|
|
d->immutability = imm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-16 13:36:07 +02:00
|
|
|
if (containment) {
|
|
|
|
containment->setActivity(activity);
|
|
|
|
}
|
2014-07-28 13:41:58 +02:00
|
|
|
return containment;
|
|
|
|
}
|
|
|
|
|
2018-03-30 13:06:15 +02:00
|
|
|
QList<Containment *> Corona::containmentsForActivity(const QString &activity)
|
|
|
|
{
|
|
|
|
QList<Containment *> conts;
|
|
|
|
|
|
|
|
if (activity.isEmpty()) {
|
|
|
|
return conts;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::copy_if(d->containments.begin(),
|
|
|
|
d->containments.end(),
|
|
|
|
std::back_inserter(conts),
|
|
|
|
[activity](Containment *cont) { return cont->activity() == activity &&
|
|
|
|
(cont->containmentType() == Plasma::Types::DesktopContainment ||
|
|
|
|
cont->containmentType() == Plasma::Types::CustomContainment);} );
|
|
|
|
|
|
|
|
return conts;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<Containment *> Corona::containmentsForScreen(int screen)
|
|
|
|
{
|
|
|
|
QList<Containment *> conts;
|
|
|
|
|
|
|
|
if (screen < 0) {
|
|
|
|
return conts;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::copy_if(d->containments.begin(),
|
|
|
|
d->containments.end(),
|
|
|
|
std::back_inserter(conts),
|
|
|
|
[screen](Containment *cont) { return cont->lastScreen() == screen &&
|
|
|
|
(cont->containmentType() == Plasma::Types::DesktopContainment ||
|
|
|
|
cont->containmentType() == Plasma::Types::CustomContainment);} );
|
|
|
|
|
|
|
|
return conts;
|
|
|
|
}
|
|
|
|
|
2014-04-26 01:45:47 +02:00
|
|
|
QList<Containment *> Corona::containments() const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
return d->containments;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2014-04-22 14:57:17 +02:00
|
|
|
bool Corona::isStartupCompleted() const
|
|
|
|
{
|
|
|
|
return d->containmentsStarting <= 0;
|
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
KSharedConfigPtr Corona::config() const
|
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
if (!d->config) {
|
|
|
|
d->config = KSharedConfig::openConfig(d->configName, KConfig::SimpleConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
return d->config;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2013-03-04 16:15:04 +01:00
|
|
|
Containment *Corona::createContainment(const QString &name, const QVariantList &args)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2017-12-02 15:12:40 +01:00
|
|
|
if (d->immutability == Types::Mutable || args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) {
|
2018-04-18 12:31:12 +02:00
|
|
|
return d->addContainment(name, args, 0, -1, false);
|
2009-11-05 02:12:22 +01:00
|
|
|
}
|
2008-12-10 01:57:42 +01:00
|
|
|
|
2018-04-13 13:58:44 +02:00
|
|
|
return nullptr;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2014-04-09 22:15:02 +02:00
|
|
|
Containment *Corona::createContainmentDelayed(const QString &name, const QVariantList &args)
|
|
|
|
{
|
|
|
|
if (d->immutability == Types::Mutable) {
|
2018-03-30 13:06:15 +02:00
|
|
|
return d->addContainment(name, args, 0, -1, true);
|
2014-04-09 22:15:02 +02:00
|
|
|
}
|
|
|
|
|
2018-04-13 13:58:44 +02:00
|
|
|
return nullptr;
|
2014-04-09 22:15:02 +02:00
|
|
|
}
|
|
|
|
|
2014-07-09 12:02:31 +02:00
|
|
|
int Corona::screenForContainment(const Containment *) const
|
2013-12-17 15:46:57 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
int Corona::numScreens() const
|
2008-11-06 19:21:10 +01:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
return 1;
|
2008-11-06 19:21:10 +01:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
QRegion Corona::availableScreenRegion(int id) const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
return QRegion(screenGeometry(id));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2014-03-11 15:29:25 +01:00
|
|
|
QRect Corona::availableScreenRect(int id) const
|
|
|
|
{
|
|
|
|
return screenGeometry(id);
|
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
void Corona::loadDefaultLayout()
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2013-03-13 11:12:18 +01:00
|
|
|
//Default implementation does nothing
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2013-05-14 20:27:32 +02:00
|
|
|
Types::ImmutabilityType Corona::immutability() const
|
2009-09-28 19:28:17 +02:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
return d->immutability;
|
|
|
|
}
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2013-05-14 20:27:32 +02:00
|
|
|
void Corona::setImmutability(const Types::ImmutabilityType immutable)
|
2012-09-24 18:10:25 +02:00
|
|
|
{
|
2013-05-10 19:29:13 +02:00
|
|
|
if (d->immutability == immutable || d->immutability == Types::SystemImmutable) {
|
2012-09-24 18:10:25 +02:00
|
|
|
return;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2011-07-29 15:46:52 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "setting immutability to" << immutable;
|
2011-07-29 15:46:52 +02:00
|
|
|
#endif
|
2012-09-24 18:10:25 +02:00
|
|
|
d->immutability = immutable;
|
|
|
|
d->updateContainmentImmutability();
|
|
|
|
//tell non-containments that might care (like plasmaapp or a custom corona)
|
|
|
|
emit immutabilityChanged(immutable);
|
|
|
|
|
|
|
|
//update our actions
|
2016-02-29 00:08:05 +01:00
|
|
|
QAction *action = d->actions.action(QStringLiteral("lock widgets"));
|
2012-09-24 18:10:25 +02:00
|
|
|
if (action) {
|
2013-05-10 19:29:13 +02:00
|
|
|
if (d->immutability == Types::SystemImmutable) {
|
2012-09-24 18:10:25 +02:00
|
|
|
action->setEnabled(false);
|
|
|
|
action->setVisible(false);
|
2009-09-28 19:28:17 +02:00
|
|
|
} else {
|
2013-05-10 19:29:13 +02:00
|
|
|
bool unlocked = d->immutability == Types::Mutable;
|
2012-09-24 18:10:25 +02:00
|
|
|
action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"));
|
2016-02-29 00:08:05 +01:00
|
|
|
action->setIcon(QIcon::fromTheme(unlocked ? QStringLiteral("object-locked") : QStringLiteral("object-unlocked")));
|
2012-09-24 18:10:25 +02:00
|
|
|
action->setEnabled(true);
|
|
|
|
action->setVisible(true);
|
2009-09-28 19:28:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
edit mode action
Summary: needed for the context menu entry
Test Plan: with the p-w- portion the action shows in the context menu
Reviewers: #plasma, #vdg, GB_2, ngraham, davidedmundson
Reviewed By: #plasma, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, broulik, GB_2, ngraham, kde-frameworks-devel
Tags: #frameworks
Maniphest Tasks: T10190, T11094, T10402
Differential Revision: https://phabricator.kde.org/D24263
2019-10-18 12:56:21 +02:00
|
|
|
action = d->actions.action(QStringLiteral("edit mode"));
|
|
|
|
if (action) {
|
|
|
|
switch (d->immutability) {
|
|
|
|
case Types::UserImmutable:
|
|
|
|
action->setEnabled(false);
|
|
|
|
action->setVisible(true);
|
|
|
|
break;
|
|
|
|
case Types::SystemImmutable:
|
|
|
|
action->setEnabled(false);
|
|
|
|
action->setVisible(false);
|
|
|
|
break;
|
|
|
|
case Types::Mutable:
|
|
|
|
default:
|
|
|
|
action->setEnabled(true);
|
|
|
|
action->setVisible(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-10 19:29:13 +02:00
|
|
|
if (d->immutability != Types::SystemImmutable) {
|
2012-09-24 18:10:25 +02:00
|
|
|
KConfigGroup cg(config(), "General");
|
2008-12-12 15:41:15 +01:00
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
// we call the dptr member directly for locked since isImmutable()
|
|
|
|
// also checks kiosk and parent containers
|
|
|
|
cg.writeEntry("immutability", (int)d->immutability);
|
|
|
|
requestConfigSync();
|
2008-12-12 15:41:15 +01:00
|
|
|
}
|
2019-09-26 18:20:31 +02:00
|
|
|
|
|
|
|
if (d->immutability != Types::Mutable) {
|
edit mode action
Summary: needed for the context menu entry
Test Plan: with the p-w- portion the action shows in the context menu
Reviewers: #plasma, #vdg, GB_2, ngraham, davidedmundson
Reviewed By: #plasma, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, broulik, GB_2, ngraham, kde-frameworks-devel
Tags: #frameworks
Maniphest Tasks: T10190, T11094, T10402
Differential Revision: https://phabricator.kde.org/D24263
2019-10-18 12:56:21 +02:00
|
|
|
setEditMode(false);
|
2019-09-26 18:20:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Corona::setEditMode(bool edit)
|
|
|
|
{
|
edit mode action
Summary: needed for the context menu entry
Test Plan: with the p-w- portion the action shows in the context menu
Reviewers: #plasma, #vdg, GB_2, ngraham, davidedmundson
Reviewed By: #plasma, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, broulik, GB_2, ngraham, kde-frameworks-devel
Tags: #frameworks
Maniphest Tasks: T10190, T11094, T10402
Differential Revision: https://phabricator.kde.org/D24263
2019-10-18 12:56:21 +02:00
|
|
|
if (edit == d->editMode || (edit && d->immutability != Plasma::Types::Mutable)) {
|
2019-09-26 18:20:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
edit mode action
Summary: needed for the context menu entry
Test Plan: with the p-w- portion the action shows in the context menu
Reviewers: #plasma, #vdg, GB_2, ngraham, davidedmundson
Reviewed By: #plasma, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, broulik, GB_2, ngraham, kde-frameworks-devel
Tags: #frameworks
Maniphest Tasks: T10190, T11094, T10402
Differential Revision: https://phabricator.kde.org/D24263
2019-10-18 12:56:21 +02:00
|
|
|
QAction *editAction = d->actions.action(QStringLiteral("edit mode"));
|
|
|
|
if (editAction) {
|
|
|
|
if (edit) {
|
|
|
|
editAction->setText(i18n("Finish Customizing Layout"));
|
|
|
|
} else {
|
|
|
|
editAction->setText(i18n("Customize Layout..."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-26 18:20:31 +02:00
|
|
|
d->editMode = edit;
|
edit mode action
Summary: needed for the context menu entry
Test Plan: with the p-w- portion the action shows in the context menu
Reviewers: #plasma, #vdg, GB_2, ngraham, davidedmundson
Reviewed By: #plasma, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, broulik, GB_2, ngraham, kde-frameworks-devel
Tags: #frameworks
Maniphest Tasks: T10190, T11094, T10402
Differential Revision: https://phabricator.kde.org/D24263
2019-10-18 12:56:21 +02:00
|
|
|
emit editModeChanged(edit);
|
2019-09-26 18:20:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Corona::isEditMode() const
|
|
|
|
{
|
|
|
|
return d->editMode;
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
2008-12-12 15:41:15 +01:00
|
|
|
|
2013-05-14 18:27:27 +02:00
|
|
|
QList<Plasma::Types::Location> Corona::freeEdges(int screen) const
|
2012-09-24 18:10:25 +02:00
|
|
|
{
|
2013-05-14 18:27:27 +02:00
|
|
|
QList<Plasma::Types::Location> freeEdges;
|
2013-05-10 19:29:13 +02:00
|
|
|
freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge
|
|
|
|
<< Plasma::Types::LeftEdge << Plasma::Types::RightEdge;
|
2011-07-28 18:53:21 +02:00
|
|
|
|
2019-03-20 07:12:03 +01:00
|
|
|
const auto containments = this->containments();
|
|
|
|
for (Containment *containment : containments) {
|
2012-09-24 18:10:25 +02:00
|
|
|
if (containment->screen() == screen &&
|
2014-04-26 01:45:47 +02:00
|
|
|
freeEdges.contains(containment->location())) {
|
2012-09-24 18:10:25 +02:00
|
|
|
freeEdges.removeAll(containment->location());
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
return freeEdges;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2013-02-25 16:36:27 +01:00
|
|
|
KActionCollection *Corona::actions() const
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2013-02-25 16:36:27 +01:00
|
|
|
return &d->actions;
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
CoronaPrivate::CoronaPrivate(Corona *corona)
|
|
|
|
: q(corona),
|
2013-05-10 19:29:13 +02:00
|
|
|
immutability(Types::Mutable),
|
2018-04-13 13:58:44 +02:00
|
|
|
config(nullptr),
|
2012-12-20 10:47:51 +01:00
|
|
|
configSyncTimer(new QTimer(corona)),
|
2014-04-22 14:57:17 +02:00
|
|
|
actions(corona),
|
|
|
|
containmentsStarting(0)
|
2012-09-24 18:10:25 +02:00
|
|
|
{
|
2013-02-12 14:26:34 +01:00
|
|
|
//TODO: make Package path configurable
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
if (QCoreApplication::instance()) {
|
2017-12-02 15:12:40 +01:00
|
|
|
configName = QCoreApplication::instance()->applicationName() + QStringLiteral("-appletsrc");
|
2012-09-24 18:10:25 +02:00
|
|
|
} else {
|
2016-02-29 00:08:05 +01:00
|
|
|
configName = QStringLiteral("plasma-appletsrc");
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
2009-05-03 22:22:14 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
CoronaPrivate::~CoronaPrivate()
|
2009-05-03 22:22:14 +02:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
qDeleteAll(containments);
|
2009-05-03 22:22:14 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
void CoronaPrivate::init()
|
2009-10-05 22:50:57 +02:00
|
|
|
{
|
2013-03-13 11:07:24 +01:00
|
|
|
desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package.filePath("defaults")), "Desktop");
|
|
|
|
|
2012-12-20 10:47:51 +01:00
|
|
|
configSyncTimer->setSingleShot(true);
|
|
|
|
QObject::connect(configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
|
2012-09-24 18:10:25 +02:00
|
|
|
|
|
|
|
//some common actions
|
2016-02-29 00:08:05 +01:00
|
|
|
actions.setConfigGroup(QStringLiteral("Shortcuts"));
|
2012-09-24 18:10:25 +02:00
|
|
|
|
2016-02-29 00:08:05 +01:00
|
|
|
QAction *lockAction = actions.add<QAction>(QStringLiteral("lock widgets"));
|
2012-09-24 18:10:25 +02:00
|
|
|
QObject::connect(lockAction, SIGNAL(triggered(bool)), q, SLOT(toggleImmutability()));
|
|
|
|
lockAction->setText(i18n("Lock Widgets"));
|
|
|
|
lockAction->setAutoRepeat(true);
|
2016-02-29 00:08:05 +01:00
|
|
|
lockAction->setIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
|
2013-05-10 19:29:13 +02:00
|
|
|
lockAction->setData(Plasma::Types::ControlAction);
|
2016-02-29 00:08:05 +01:00
|
|
|
lockAction->setShortcut(QKeySequence(QStringLiteral("alt+d, l")));
|
2012-09-24 18:10:25 +02:00
|
|
|
lockAction->setShortcutContext(Qt::ApplicationShortcut);
|
|
|
|
|
|
|
|
//fake containment/applet actions
|
|
|
|
KActionCollection *containmentActions = AppletPrivate::defaultActions(q); //containment has to start with applet stuff
|
|
|
|
ContainmentPrivate::addDefaultActions(containmentActions); //now it's really containment
|
edit mode action
Summary: needed for the context menu entry
Test Plan: with the p-w- portion the action shows in the context menu
Reviewers: #plasma, #vdg, GB_2, ngraham, davidedmundson
Reviewed By: #plasma, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, broulik, GB_2, ngraham, kde-frameworks-devel
Tags: #frameworks
Maniphest Tasks: T10190, T11094, T10402
Differential Revision: https://phabricator.kde.org/D24263
2019-10-18 12:56:21 +02:00
|
|
|
|
|
|
|
QAction *editAction = actions.add<QAction>(QStringLiteral("edit mode"));
|
|
|
|
QObject::connect(editAction, &QAction::triggered, q, [this] () {
|
|
|
|
q->setEditMode(!q->isEditMode());
|
|
|
|
});
|
|
|
|
editAction->setText(i18n("Customize Layout..."));
|
|
|
|
editAction->setAutoRepeat(true);
|
|
|
|
editAction->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
|
|
|
|
editAction->setData(Plasma::Types::ControlAction);
|
|
|
|
editAction->setShortcut(QKeySequence(QStringLiteral("alt+d, e")));
|
|
|
|
editAction->setShortcutContext(Qt::ApplicationShortcut);
|
2009-10-05 22:50:57 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
void CoronaPrivate::toggleImmutability()
|
2009-10-05 22:50:57 +02:00
|
|
|
{
|
2013-05-10 19:29:13 +02:00
|
|
|
if (immutability == Types::Mutable) {
|
|
|
|
q->setImmutability(Types::UserImmutable);
|
2012-09-24 18:10:25 +02:00
|
|
|
} else {
|
2013-05-10 19:29:13 +02:00
|
|
|
q->setImmutability(Types::Mutable);
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
2009-10-05 22:50:57 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const
|
2010-04-03 21:10:32 +02:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
KConfigGroup containmentsGroup(cg, "Containments");
|
2019-03-20 07:12:03 +01:00
|
|
|
for (const Containment *containment : containments) {
|
2012-09-24 18:10:25 +02:00
|
|
|
QString cid = QString::number(containment->id());
|
|
|
|
KConfigGroup containmentConfig(&containmentsGroup, cid);
|
|
|
|
containment->save(containmentConfig);
|
|
|
|
}
|
2010-04-03 21:10:32 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
void CoronaPrivate::updateContainmentImmutability()
|
2010-04-03 21:10:32 +02:00
|
|
|
{
|
2019-03-20 07:12:03 +01:00
|
|
|
for (Containment *c : qAsConst(containments)) {
|
2012-09-24 18:10:25 +02:00
|
|
|
// we need to tell each containment that immutability has been altered
|
2013-05-10 19:29:13 +02:00
|
|
|
c->updateConstraints(Types::ImmutableConstraint);
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
2010-04-03 21:10:32 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
void CoronaPrivate::containmentDestroyed(QObject *obj)
|
2011-01-11 21:45:24 +01:00
|
|
|
{
|
2014-04-26 01:45:47 +02:00
|
|
|
// we do a static_cast here since it really isn't an Containment by this
|
|
|
|
// point anymore since we are in the qobject dtor. we don't actually
|
|
|
|
// try and do anything with it, we just need the value of the pointer
|
|
|
|
// so this unsafe looking code is actually just fine.
|
|
|
|
Containment *containment = static_cast<Plasma::Containment *>(obj);
|
|
|
|
int index = containments.indexOf(containment);
|
2011-01-11 21:45:24 +01:00
|
|
|
|
2014-04-26 01:45:47 +02:00
|
|
|
if (index > -1) {
|
|
|
|
containments.removeAt(index);
|
|
|
|
q->requestConfigSync();
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
2014-04-26 01:45:47 +02:00
|
|
|
}
|
2012-09-24 18:10:25 +02:00
|
|
|
|
|
|
|
void CoronaPrivate::syncConfig()
|
2011-01-11 21:45:24 +01:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
q->config()->sync();
|
|
|
|
emit q->configSynced();
|
2011-01-11 21:45:24 +01:00
|
|
|
}
|
|
|
|
|
2018-03-30 13:06:15 +02:00
|
|
|
Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, int lastScreen, bool delayedInit)
|
2011-01-11 21:45:24 +01:00
|
|
|
{
|
2012-09-24 18:10:25 +02:00
|
|
|
QString pluginName = name;
|
2018-04-13 13:58:44 +02:00
|
|
|
Containment *containment = nullptr;
|
|
|
|
Applet *applet = nullptr;
|
2012-09-24 18:10:25 +02:00
|
|
|
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "Loading" << name << args << id;
|
2012-09-24 18:10:25 +02:00
|
|
|
|
2016-02-29 00:08:05 +01:00
|
|
|
if (pluginName.isEmpty() || pluginName == QLatin1String("default")) {
|
2012-09-24 18:10:25 +02:00
|
|
|
// default to the desktop containment
|
2013-10-23 15:24:33 +02:00
|
|
|
pluginName = desktopDefaultsConfig.readEntry("Containment", "org.kde.desktopcontainment");
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
|
|
|
|
2016-02-29 00:08:05 +01:00
|
|
|
bool loadingNull = pluginName == QLatin1String("null");
|
2012-09-24 18:10:25 +02:00
|
|
|
if (!loadingNull) {
|
|
|
|
applet = PluginLoader::self()->loadApplet(pluginName, id, args);
|
2014-04-26 01:45:47 +02:00
|
|
|
containment = dynamic_cast<Containment *>(applet);
|
2012-12-07 17:02:27 +01:00
|
|
|
if (containment) {
|
|
|
|
containment->setParent(q);
|
|
|
|
}
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!containment) {
|
|
|
|
if (!loadingNull) {
|
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "loading of containment" << name << "failed.";
|
2012-09-24 18:10:25 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// in case we got a non-Containment from Applet::loadApplet or
|
|
|
|
// a null containment was requested
|
|
|
|
if (applet) {
|
|
|
|
// the applet probably doesn't know what's hit it, so let's pretend it can be
|
|
|
|
// initialized to make assumptions in the applet's dtor safer
|
|
|
|
applet->init();
|
|
|
|
delete applet;
|
|
|
|
}
|
2017-12-02 15:12:40 +01:00
|
|
|
applet = containment = new Containment(q, {}, id);
|
2018-03-30 13:06:15 +02:00
|
|
|
if (lastScreen >= 0) {
|
|
|
|
containment->d->lastScreen = lastScreen;
|
|
|
|
}
|
2014-07-14 14:22:36 +02:00
|
|
|
//if it's a dummy containment, just say its ui is ready, not blocking the corona
|
|
|
|
applet->updateConstraints(Plasma::Types::UiReadyConstraint);
|
2012-09-24 18:10:25 +02:00
|
|
|
|
|
|
|
// we want to provide something and don't care about the failure to launch
|
2013-05-10 19:29:13 +02:00
|
|
|
containment->setFormFactor(Plasma::Types::Planar);
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// if this is a new containment, we need to ensure that there are no stale
|
|
|
|
// configuration data around
|
|
|
|
if (id == 0) {
|
|
|
|
KConfigGroup conf(q->config(), "Containments");
|
|
|
|
conf = KConfigGroup(&conf, QString::number(containment->id()));
|
|
|
|
conf.deleteGroup();
|
|
|
|
}
|
|
|
|
|
2014-09-15 15:40:15 +02:00
|
|
|
//make sure the containments are sorted by id
|
|
|
|
auto position = std::lower_bound(containments.begin(), containments.end(), containment, [](Plasma::Containment *c1, Plasma::Containment *c2) {
|
|
|
|
return c1->id() < c2->id();
|
|
|
|
});
|
|
|
|
containments.insert(position, containment);
|
2012-09-24 18:10:25 +02:00
|
|
|
|
|
|
|
QObject::connect(containment, SIGNAL(destroyed(QObject*)),
|
2014-04-26 01:45:47 +02:00
|
|
|
q, SLOT(containmentDestroyed(QObject*)));
|
2019-08-30 17:26:54 +02:00
|
|
|
QObject::connect(containment, &Applet::configNeedsSaving,
|
|
|
|
q, &Corona::requestConfigSync);
|
|
|
|
QObject::connect(containment, &Containment::screenChanged,
|
|
|
|
q, &Corona::screenOwnerChanged);
|
2012-09-24 18:10:25 +02:00
|
|
|
|
2014-04-09 22:15:02 +02:00
|
|
|
if (!delayedInit) {
|
|
|
|
containment->init();
|
|
|
|
KConfigGroup cg = containment->config();
|
|
|
|
containment->restore(cg);
|
|
|
|
containment->updateConstraints(Plasma::Types::StartupCompletedConstraint);
|
|
|
|
containment->save(cg);
|
|
|
|
q->requestConfigSync();
|
|
|
|
containment->flushPendingConstraintsEvents();
|
|
|
|
emit q->containmentAdded(containment);
|
2015-10-13 14:24:29 +02:00
|
|
|
//if id = 0 a new containment has been created, not restored
|
|
|
|
if (id == 0) {
|
|
|
|
emit q->containmentCreated(containment);
|
|
|
|
}
|
2014-04-09 22:15:02 +02:00
|
|
|
}
|
2012-12-20 10:47:51 +01:00
|
|
|
|
2013-02-05 14:55:40 +01:00
|
|
|
return containment;
|
2011-01-11 21:45:24 +01:00
|
|
|
}
|
|
|
|
|
2012-09-24 18:10:25 +02:00
|
|
|
QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig)
|
|
|
|
{
|
|
|
|
if (!conf.isValid()) {
|
|
|
|
return QList<Containment *>();
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<Plasma::Containment *> newContainments;
|
|
|
|
QSet<uint> containmentsIds;
|
|
|
|
|
2019-03-20 07:12:03 +01:00
|
|
|
for (Containment *containment : qAsConst(containments)) {
|
2012-09-24 18:10:25 +02:00
|
|
|
containmentsIds.insert(containment->id());
|
|
|
|
}
|
|
|
|
|
|
|
|
KConfigGroup containmentsGroup(&conf, "Containments");
|
2014-09-15 15:40:15 +02:00
|
|
|
QStringList groups = containmentsGroup.groupList();
|
2019-02-28 13:55:40 +01:00
|
|
|
std::sort(groups.begin(), groups.end());
|
2012-09-24 18:10:25 +02:00
|
|
|
|
2019-03-20 07:12:03 +01:00
|
|
|
for (const QString &group : qAsConst(groups)) {
|
2012-09-24 18:10:25 +02:00
|
|
|
KConfigGroup containmentConfig(&containmentsGroup, group);
|
|
|
|
|
|
|
|
if (containmentConfig.entryMap().isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint cid = group.toUInt();
|
|
|
|
if (containmentsIds.contains(cid)) {
|
|
|
|
cid = ++AppletPrivate::s_maxAppletId;
|
|
|
|
} else if (cid > AppletPrivate::s_maxAppletId) {
|
|
|
|
AppletPrivate::s_maxAppletId = cid;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mergeConfig) {
|
|
|
|
KConfigGroup realConf(q->config(), "Containments");
|
|
|
|
realConf = KConfigGroup(&realConf, QString::number(cid));
|
|
|
|
// in case something was there before us
|
|
|
|
realConf.deleteGroup();
|
|
|
|
containmentConfig.copyTo(&realConf);
|
|
|
|
}
|
|
|
|
|
2015-12-15 22:56:40 +01:00
|
|
|
//qCDebug(LOG_PLASMA) << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
|
2012-09-24 18:10:25 +02:00
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin", QString());
|
2012-09-24 18:10:25 +02:00
|
|
|
#endif
|
2018-03-30 13:06:15 +02:00
|
|
|
Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, -1);
|
2012-09-24 18:10:25 +02:00
|
|
|
if (!c) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
newContainments.append(c);
|
|
|
|
containmentsIds.insert(c->id());
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2015-12-15 22:56:40 +01:00
|
|
|
// qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Restored Containment" << c->pluginName();
|
2012-09-24 18:10:25 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-04-22 14:57:17 +02:00
|
|
|
if (!mergeConfig) {
|
2016-06-07 15:23:13 +02:00
|
|
|
notifyContainmentsReady();
|
|
|
|
}
|
2014-07-14 13:23:20 +02:00
|
|
|
|
2016-06-07 15:23:13 +02:00
|
|
|
return newContainments;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoronaPrivate::notifyContainmentsReady()
|
|
|
|
{
|
|
|
|
containmentsStarting = 0;
|
2019-03-20 07:12:03 +01:00
|
|
|
for (Containment *containment : qAsConst(containments)) {
|
2016-07-18 14:43:03 +02:00
|
|
|
if (!containment->isUiReady() && containment->screen() >= 0) {
|
2016-06-07 15:23:13 +02:00
|
|
|
++containmentsStarting;
|
|
|
|
QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { containmentReady(ready); } );
|
2014-07-14 13:23:20 +02:00
|
|
|
}
|
2014-04-22 14:57:17 +02:00
|
|
|
}
|
|
|
|
|
2016-06-07 15:23:13 +02:00
|
|
|
if (containmentsStarting <= 0) {
|
|
|
|
emit q->startupCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CoronaPrivate::containmentReady(bool ready)
|
|
|
|
{
|
|
|
|
if (!ready) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
--containmentsStarting;
|
|
|
|
if (containmentsStarting <= 0) {
|
|
|
|
emit q->startupCompleted();
|
|
|
|
}
|
2012-09-24 18:10:25 +02:00
|
|
|
}
|
2011-01-11 21:45:24 +01:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
} // namespace Plasma
|
|
|
|
|
2012-02-08 23:33:03 +01:00
|
|
|
#include "moc_corona.cpp"
|