diff --git a/autotests/configmodeltest.cpp b/autotests/configmodeltest.cpp index 41e9ee803..cb3ea135e 100644 --- a/autotests/configmodeltest.cpp +++ b/autotests/configmodeltest.cpp @@ -13,8 +13,8 @@ #include -#include #include +#include void ConfigModelTest::configSchemeFromPackage() { @@ -37,7 +37,7 @@ void ConfigModelTest::configSchemeFromPackage() QCOMPARE(configModel->get(0).toMap().value(QStringLiteral("icon")).toString(), QStringLiteral("plasma")); QCOMPARE(configModel->get(0).toMap().value(QStringLiteral("source")).toString(), QStringLiteral("ConfigGeneral.qml")); QCOMPARE(configModel->get(0).toMap().value(QStringLiteral("pluginName")).toString(), QString()); - QVERIFY(!configModel->get(0).toMap().value(QStringLiteral("kcm")).value()); + QVERIFY(!configModel->get(0).toMap().value(QStringLiteral("kcm")).value()); delete component; delete applet; @@ -108,4 +108,3 @@ void ConfigModelTest::notEmptySourceWithApplet() } QTEST_MAIN(ConfigModelTest) - diff --git a/autotests/configmodeltest.h b/autotests/configmodeltest.h index 97c19f64d..aa8b721b0 100644 --- a/autotests/configmodeltest.h +++ b/autotests/configmodeltest.h @@ -21,6 +21,4 @@ private Q_SLOTS: void configSchemeFromPackage(); void emptySourceWithApplet(); void notEmptySourceWithApplet(); - }; - diff --git a/autotests/coronatest.cpp b/autotests/coronatest.cpp index b397951f9..4d05871e7 100644 --- a/autotests/coronatest.cpp +++ b/autotests/coronatest.cpp @@ -5,16 +5,15 @@ */ #include "coronatest.h" -#include #include -#include +#include #include #include -#include -#include #include -Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint appletId, - const QVariantList &args) +#include +#include +#include +Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args) { Q_UNUSED(args) if (name == QLatin1String("simpleapplet")) { @@ -35,13 +34,13 @@ SimpleCorona::SimpleCorona(QObject *parent) } SimpleCorona::~SimpleCorona() -{} - +{ +} QRect SimpleCorona::screenGeometry(int screen) const { - //completely arbitrary, still not tested - return QRect(100*screen, 100, 100, 100); + // completely arbitrary, still not tested + return QRect(100 * screen, 100, 100, 100); } int SimpleCorona::screenForContainment(const Plasma::Containment *c) const @@ -52,10 +51,10 @@ int SimpleCorona::screenForContainment(const Plasma::Containment *c) const return 0; } -SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId) +SimpleApplet::SimpleApplet(QObject *parent, const QString &serviceId, uint appletId) : Plasma::Applet(parent, serviceId, appletId) { - //updateConstraints(Plasma::Types::UiReadyConstraint); + // updateConstraints(Plasma::Types::UiReadyConstraint); m_timer.setSingleShot(true); m_timer.setInterval(QRandomGenerator::global()->bounded((500 + 1) - 100) + 100); m_timer.start(); @@ -64,11 +63,10 @@ SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appl }); } - -SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, uint appletId) +SimpleContainment::SimpleContainment(QObject *parent, const QString &serviceId, uint appletId) : Plasma::Containment(parent, serviceId, appletId) { - //updateConstraints(Plasma::Types::UiReadyConstraint); + // updateConstraints(Plasma::Types::UiReadyConstraint); m_timer.setSingleShot(true); m_timer.setInterval(QRandomGenerator::global()->bounded((500 + 1) - 100) + 100); m_timer.start(); @@ -77,10 +75,10 @@ SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, }); } -SimpleNoScreenContainment::SimpleNoScreenContainment(QObject *parent , const QString &serviceId, uint appletId) +SimpleNoScreenContainment::SimpleNoScreenContainment(QObject *parent, const QString &serviceId, uint appletId) : Plasma::Containment(parent, serviceId, appletId) { - //This containment will *never* be isUiReady() + // This containment will *never* be isUiReady() } static void runKBuildSycoca() @@ -100,7 +98,6 @@ static void runKBuildSycoca() QCOMPARE(proc.exitStatus(), QProcess::NormalExit); } - void CoronaTest::initTestCase() { if (!KSycoca::isAvailable()) { @@ -140,21 +137,18 @@ void CoronaTest::restore() break; } } - - } - void CoronaTest::checkOrder() { QCOMPARE(m_corona->containments().count(), 3); - //check containments order + // check containments order QCOMPARE(m_corona->containments().at(0)->id(), (uint)1); QCOMPARE(m_corona->containments().at(1)->id(), (uint)4); QCOMPARE(m_corona->containments().at(2)->id(), (uint)5); - //check applets order + // check applets order QCOMPARE(m_corona->containments().at(0)->applets().count(), 2); QCOMPARE(m_corona->containments().at(0)->applets().at(0)->id(), (uint)2); QCOMPARE(m_corona->containments().at(0)->applets().at(1)->id(), (uint)3); @@ -177,9 +171,9 @@ void CoronaTest::addRemoveApplets() m_corona->containments().at(0)->createApplet(QStringLiteral("invalid")); QCOMPARE(m_corona->containments().at(0)->applets().count(), 3); - //remove action present + // remove action present QVERIFY(m_corona->containments().at(0)->applets().at(0)->actions()->action(QStringLiteral("remove"))); - //kill an applet + // kill an applet m_corona->containments().at(0)->applets().at(0)->destroy(); QSignalSpy spy(m_corona->containments().at(0)->applets().at(0), SIGNAL(destroyed())); @@ -187,11 +181,11 @@ void CoronaTest::addRemoveApplets() QCOMPARE(m_corona->containments().at(0)->applets().count(), 2); } -//this test has to be the last, since systemimmutability -//can't be programmatically unlocked +// this test has to be the last, since systemimmutability +// can't be programmatically unlocked void CoronaTest::immutability() { - //immutability + // immutability QCOMPARE(m_corona->immutability(), Plasma::Types::Mutable); m_corona->setImmutability(Plasma::Types::UserImmutable); QCOMPARE(m_corona->immutability(), Plasma::Types::UserImmutable); @@ -229,7 +223,7 @@ void CoronaTest::immutability() } } - //can't unlock systemimmutable + // can't unlock systemimmutable m_corona->setImmutability(Plasma::Types::Mutable); QCOMPARE(m_corona->immutability(), Plasma::Types::SystemImmutable); @@ -244,4 +238,3 @@ void CoronaTest::immutability() } QTEST_MAIN(CoronaTest) - diff --git a/autotests/coronatest.h b/autotests/coronatest.h index 7a7095370..aaa1cb746 100644 --- a/autotests/coronatest.h +++ b/autotests/coronatest.h @@ -16,17 +16,15 @@ class SimpleLoader : public Plasma::PluginLoader { protected: - virtual Plasma::Applet *internalLoadApplet(const QString &name, uint appletId = 0, - const QVariantList &args = QVariantList()) override; + virtual Plasma::Applet *internalLoadApplet(const QString &name, uint appletId = 0, const QVariantList &args = QVariantList()) override; }; - class SimpleCorona : public Plasma::Corona { Q_OBJECT public: - explicit SimpleCorona(QObject * parent = nullptr); + explicit SimpleCorona(QObject *parent = nullptr); ~SimpleCorona(); QRect screenGeometry(int) const override; @@ -39,6 +37,7 @@ class SimpleApplet : public Plasma::Applet public: explicit SimpleApplet(QObject *parent = nullptr, const QString &serviceId = QString(), uint appletId = 0); + private: QTimer m_timer; }; @@ -49,6 +48,7 @@ class SimpleContainment : public Plasma::Containment public: explicit SimpleContainment(QObject *parent = nullptr, const QString &serviceId = QString(), uint appletId = 0); + private: QTimer m_timer; }; @@ -82,4 +82,3 @@ private: }; #endif - diff --git a/autotests/dialognativetest.cpp b/autotests/dialognativetest.cpp index db2878851..111d6b976 100644 --- a/autotests/dialognativetest.cpp +++ b/autotests/dialognativetest.cpp @@ -23,15 +23,15 @@ void DialogNativeTest::initTestCase() m_panel = new QQuickView; m_panel->setGeometry(0, 0, 50, 50); - m_panel->setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus); + m_panel->setFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); m_panel2 = new QQuickView; m_panel2->setGeometry(100, 0, 50, 50); - m_panel2->setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus); + m_panel2->setFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); m_panel3 = new QQuickView; m_panel3->setGeometry(200, 0, 50, 50); - m_panel3->setFlags(Qt::FramelessWindowHint|Qt::WindowDoesNotAcceptFocus); + m_panel3->setFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); m_content = new QQuickItem; m_content->setWidth(100); diff --git a/autotests/dialognativetest.h b/autotests/dialognativetest.h index e9c98171a..38478000a 100644 --- a/autotests/dialognativetest.h +++ b/autotests/dialognativetest.h @@ -6,14 +6,12 @@ #ifndef DIALOGNATIVETEST_H #define DIALOGNATIVETEST_H -#include -#include #include +#include +#include #include "plasmaquick/dialog.h" - - class DialogNativeTest : public QObject { Q_OBJECT @@ -37,4 +35,3 @@ private: }; #endif - diff --git a/autotests/dialogqmltest.cpp b/autotests/dialogqmltest.cpp index b40d97533..c247dd9b3 100644 --- a/autotests/dialogqmltest.cpp +++ b/autotests/dialogqmltest.cpp @@ -8,39 +8,37 @@ #include -#include #include +#include #include - -//this test checks that we don't set visible to true until after we set the window flags +// this test checks that we don't set visible to true until after we set the window flags void DialogQmlTest::loadAndShow() { QQmlEngine engine; QByteArray dialogQml = -"import QtQuick 2.0\n" -"import org.kde.plasma.core 2.0 as PlasmaCore\n" -"\n" -"PlasmaCore.Dialog {\n" -" id: root\n" -"\n" -" location: true && PlasmaCore.Types.TopEdge\n" -" visible: true && true\n" -" type: true && PlasmaCore.Dialog.Notification\n" -"\n" -" mainItem: Rectangle {\n" -" width: 200\n" -" height: 200\n" -" }\n" -"}\n"; - - //we use true && Value to force it to be a complex binding, which won't be evaluated in - //component.beginCreate - //the bug still appears without this, but we need to delay it in this test - //so we can connect to the visibleChanged signal + "import QtQuick 2.0\n" + "import org.kde.plasma.core 2.0 as PlasmaCore\n" + "\n" + "PlasmaCore.Dialog {\n" + " id: root\n" + "\n" + " location: true && PlasmaCore.Types.TopEdge\n" + " visible: true && true\n" + " type: true && PlasmaCore.Dialog.Notification\n" + "\n" + " mainItem: Rectangle {\n" + " width: 200\n" + " height: 200\n" + " }\n" + "}\n"; + // we use true && Value to force it to be a complex binding, which won't be evaluated in + // component.beginCreate + // the bug still appears without this, but we need to delay it in this test + // so we can connect to the visibleChanged signal QQmlComponent component(&engine); @@ -48,13 +46,13 @@ void DialogQmlTest::loadAndShow() component.setData(dialogQml, QUrl(QStringLiteral("test://dialogTest"))); spy.wait(); - PlasmaQuick::Dialog *dialog = qobject_cast< PlasmaQuick::Dialog* >(component.beginCreate(engine.rootContext())); + PlasmaQuick::Dialog *dialog = qobject_cast(component.beginCreate(engine.rootContext())); qDebug() << component.errorString(); Q_ASSERT(dialog); m_dialogShown = false; - //this will be called during component.completeCreate + // this will be called during component.completeCreate auto c = connect(dialog, &QWindow::visibleChanged, [=]() { m_dialogShown = true; QCOMPARE(dialog->type(), PlasmaQuick::Dialog::Notification); @@ -64,12 +62,10 @@ void DialogQmlTest::loadAndShow() component.completeCreate(); QCOMPARE(m_dialogShown, true); - //disconnect on visible changed before we delete the dialog + // disconnect on visible changed before we delete the dialog disconnect(c); delete dialog; } - - QTEST_MAIN(DialogQmlTest) diff --git a/autotests/dialogqmltest.h b/autotests/dialogqmltest.h index a93d319ce..31bbb8cba 100644 --- a/autotests/dialogqmltest.h +++ b/autotests/dialogqmltest.h @@ -10,18 +10,15 @@ #include "plasmaquick/dialog.h" - - class DialogQmlTest : public QObject { Q_OBJECT private Q_SLOTS: void loadAndShow(); + private: bool m_dialogShown; - }; #endif - diff --git a/autotests/dialogstatetest.cpp b/autotests/dialogstatetest.cpp index f012b78b4..dcb7e799e 100644 --- a/autotests/dialogstatetest.cpp +++ b/autotests/dialogstatetest.cpp @@ -5,8 +5,8 @@ */ #include "dialogstatetest.h" -#include #include +#include void DialogStateTest::initTestCase() { diff --git a/autotests/dialogstatetest.h b/autotests/dialogstatetest.h index 76371d521..08e2fe38c 100644 --- a/autotests/dialogstatetest.h +++ b/autotests/dialogstatetest.h @@ -28,4 +28,3 @@ private: }; #endif - diff --git a/autotests/dynamictreemodel.cpp b/autotests/dynamictreemodel.cpp index be1c8acb6..3f59a33c6 100644 --- a/autotests/dynamictreemodel.cpp +++ b/autotests/dynamictreemodel.cpp @@ -12,25 +12,25 @@ #include DynamicTreeModel::DynamicTreeModel(QObject *parent) - : QAbstractItemModel(parent), - nextId(1) + : QAbstractItemModel(parent) + , nextId(1) { } QModelIndex DynamicTreeModel::index(int row, int column, const QModelIndex &parent) const { -// if (column != 0) -// return QModelIndex(); + // if (column != 0) + // return QModelIndex(); if (column < 0 || row < 0) { return QModelIndex(); } - QList > childIdColumns = m_childItems.value(parent.internalId()); + QList> childIdColumns = m_childItems.value(parent.internalId()); const qint64 grandParent = findParentId(parent.internalId()); if (grandParent >= 0) { - QList > parentTable = m_childItems.value(grandParent); + QList> parentTable = m_childItems.value(grandParent); Q_ASSERT(parent.column() < parentTable.size()); QList parentSiblings = parentTable.at(parent.column()); Q_ASSERT(parent.row() < parentSiblings.size()); @@ -53,7 +53,6 @@ QModelIndex DynamicTreeModel::index(int row, int column, const QModelIndex &pare qint64 id = rowIds.at(row); return createIndex(row, column, reinterpret_cast(id)); - } qint64 DynamicTreeModel::findParentId(qint64 searchId) const @@ -62,10 +61,10 @@ qint64 DynamicTreeModel::findParentId(qint64 searchId) const return -1; } - QHashIterator > > i(m_childItems); + QHashIterator>> i(m_childItems); while (i.hasNext()) { i.next(); - QListIterator > j(i.value()); + QListIterator> j(i.value()); while (j.hasNext()) { QList l = j.next(); if (l.contains(searchId)) { @@ -100,12 +99,11 @@ QModelIndex DynamicTreeModel::parent(const QModelIndex &index) const int row = childList.indexOf(parentId); return createIndex(row, column, reinterpret_cast(parentId)); - } int DynamicTreeModel::rowCount(const QModelIndex &index) const { - QList > cols = m_childItems.value(index.internalId()); + QList> cols = m_childItems.value(index.internalId()); if (cols.size() == 0) { return 0; @@ -120,7 +118,7 @@ int DynamicTreeModel::rowCount(const QModelIndex &index) const int DynamicTreeModel::columnCount(const QModelIndex &index) const { -// Q_UNUSED(index); + // Q_UNUSED(index); return m_childItems.value(index.internalId()).size(); } @@ -146,9 +144,12 @@ void DynamicTreeModel::clear() } ModelChangeCommand::ModelChangeCommand(DynamicTreeModel *model, QObject *parent) - : QObject(parent), m_model(model), m_numCols(1), m_startRow(-1), m_endRow(-1) + : QObject(parent) + , m_model(model) + , m_numCols(1) + , m_startRow(-1) + , m_endRow(-1) { - } QModelIndex ModelChangeCommand::findIndex(QList rows) @@ -166,7 +167,6 @@ QModelIndex ModelChangeCommand::findIndex(QList rows) ModelInsertCommand::ModelInsertCommand(DynamicTreeModel *model, QObject *parent) : ModelChangeCommand(model, parent) { - } void ModelInsertCommand::doCommand() @@ -179,13 +179,12 @@ void ModelInsertCommand::doCommand() if (m_model->m_childItems[parentId].size() <= col) { m_model->m_childItems[parentId].append(QList()); } -// QString name = QUuid::createUuid().toString(); + // QString name = QUuid::createUuid().toString(); qint64 id = m_model->newId(); QString name = QString::number(id); m_model->m_items.insert(id, name); m_model->m_childItems[parentId][col].insert(row, id); - } } m_model->endInsertRows(); @@ -194,7 +193,6 @@ void ModelInsertCommand::doCommand() ModelMoveCommand::ModelMoveCommand(DynamicTreeModel *model, QObject *parent) : ModelChangeCommand(model, parent) { - } bool ModelMoveCommand::emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow) { @@ -243,12 +241,10 @@ void ModelMoveCommand::emitPostSignal() ModelResetCommand::ModelResetCommand(DynamicTreeModel *model, QObject *parent) : ModelMoveCommand(model, parent) { - } ModelResetCommand::~ModelResetCommand() { - } bool ModelResetCommand::emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow) @@ -270,12 +266,10 @@ void ModelResetCommand::emitPostSignal() ModelResetCommandFixed::ModelResetCommandFixed(DynamicTreeModel *model, QObject *parent) : ModelMoveCommand(model, parent) { - } ModelResetCommandFixed::~ModelResetCommandFixed() { - } bool ModelResetCommandFixed::emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow) @@ -294,4 +288,3 @@ void ModelResetCommandFixed::emitPostSignal() { m_model->endResetModel(); } - diff --git a/autotests/dynamictreemodel.h b/autotests/dynamictreemodel.h index 9290d7e5b..f765c6290 100644 --- a/autotests/dynamictreemodel.h +++ b/autotests/dynamictreemodel.h @@ -42,7 +42,7 @@ protected Q_SLOTS: private: QHash m_items; - QHash > > m_childItems; + QHash>> m_childItems; qint64 nextId; qint64 newId() { @@ -59,17 +59,17 @@ private: friend class ModelMoveCommand; friend class ModelResetCommand; friend class ModelResetCommandFixed; - }; class ModelChangeCommand : public QObject { Q_OBJECT public: - explicit ModelChangeCommand(DynamicTreeModel *model, QObject *parent = nullptr); - virtual ~ModelChangeCommand() {} + virtual ~ModelChangeCommand() + { + } void setAncestorRowNumbers(QList rowNumbers) { @@ -101,7 +101,6 @@ protected: int m_numCols; int m_startRow; int m_endRow; - }; typedef QList ModelChangeCommandList; @@ -111,9 +110,10 @@ class ModelInsertCommand : public ModelChangeCommand Q_OBJECT public: - explicit ModelInsertCommand(DynamicTreeModel *model, QObject *parent = nullptr); - virtual ~ModelInsertCommand() {} + virtual ~ModelInsertCommand() + { + } virtual void doCommand(); }; @@ -124,7 +124,9 @@ class ModelMoveCommand : public ModelChangeCommand public: ModelMoveCommand(DynamicTreeModel *model, QObject *parent); - virtual ~ModelMoveCommand() {} + virtual ~ModelMoveCommand() + { + } virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); @@ -160,7 +162,6 @@ public: virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); virtual void emitPostSignal(); - }; /** @@ -176,7 +177,6 @@ public: virtual bool emitPreSignal(const QModelIndex &srcParent, int srcStart, int srcEnd, const QModelIndex &destParent, int destRow); virtual void emitPostSignal(); - }; #endif diff --git a/autotests/framesvgtest.cpp b/autotests/framesvgtest.cpp index 0377f47fb..9f133d335 100644 --- a/autotests/framesvgtest.cpp +++ b/autotests/framesvgtest.cpp @@ -7,8 +7,6 @@ #include "framesvgtest.h" #include - - void FrameSvgTest::initTestCase() { QStandardPaths::setTestModeEnabled(true); @@ -37,25 +35,25 @@ void FrameSvgTest::margins() void FrameSvgTest::contentsRect() { - m_frameSvg->resizeFrame(QSize(100,100)); + m_frameSvg->resizeFrame(QSize(100, 100)); QCOMPARE(m_frameSvg->contentsRect(), QRectF(26, 26, 48, 48)); } void FrameSvgTest::repaintBlocked() { - //check the properties to be correct even if set during a repaint blocked transaction + // check the properties to be correct even if set during a repaint blocked transaction m_frameSvg->setRepaintBlocked(true); QVERIFY(m_frameSvg->isRepaintBlocked()); m_frameSvg->setElementPrefix("prefix"); - m_frameSvg->setEnabledBorders(Plasma::FrameSvg::TopBorder|Plasma::FrameSvg::LeftBorder); - m_frameSvg->resizeFrame(QSizeF(100,100)); - + m_frameSvg->setEnabledBorders(Plasma::FrameSvg::TopBorder | Plasma::FrameSvg::LeftBorder); + m_frameSvg->resizeFrame(QSizeF(100, 100)); + m_frameSvg->setRepaintBlocked(false); QCOMPARE(m_frameSvg->prefix(), QString("prefix")); - QCOMPARE(m_frameSvg->enabledBorders(), Plasma::FrameSvg::TopBorder|Plasma::FrameSvg::LeftBorder); - QCOMPARE(m_frameSvg->frameSize(), QSizeF(100,100)); + QCOMPARE(m_frameSvg->enabledBorders(), Plasma::FrameSvg::TopBorder | Plasma::FrameSvg::LeftBorder); + QCOMPARE(m_frameSvg->frameSize(), QSizeF(100, 100)); } void FrameSvgTest::setTheme() diff --git a/autotests/framesvgtest.h b/autotests/framesvgtest.h index ecf3ffa4a..6d1b79167 100644 --- a/autotests/framesvgtest.h +++ b/autotests/framesvgtest.h @@ -8,11 +8,8 @@ #include - #include "plasma/framesvg.h" - - class FrameSvgTest : public QObject { Q_OBJECT @@ -33,4 +30,3 @@ private: }; #endif - diff --git a/autotests/iconitemtest.cpp b/autotests/iconitemtest.cpp index 8b6d3379c..b4a1c71a0 100644 --- a/autotests/iconitemtest.cpp +++ b/autotests/iconitemtest.cpp @@ -7,18 +7,18 @@ #include "iconitemtest.h" #include -#include -#include #include +#include +#include #include #include -#include #include +#include #include -#include "plasma/theme.h" #include "plasma/svg.h" +#include "plasma/theme.h" #include "utils.h" @@ -40,11 +40,11 @@ void IconItemTest::initTestCase() Plasma::TestUtils::installPlasmaTheme("breeze-light"); Plasma::TestUtils::installPlasmaTheme("breeze-dark"); - qputenv("XDG_DATA_DIRS", qgetenv("XDG_DATA_DIRS") + ":" + QFINDTESTDATA("data").toLocal8Bit()); + qputenv("XDG_DATA_DIRS", qgetenv("XDG_DATA_DIRS") + ":" + QFINDTESTDATA("data").toLocal8Bit()); QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); - if(!QDir(configPath).mkpath(QStringLiteral("."))) { + if (!QDir(configPath).mkpath(QStringLiteral("."))) { qFatal("Failed to create test configuration directory."); } @@ -99,7 +99,7 @@ QQuickItem *IconItemTest::createIconItem() spy.wait(); } - QQuickItem *item = qobject_cast(component.create(m_view->engine()->rootContext())); + QQuickItem *item = qobject_cast(component.create(m_view->engine()->rootContext())); Q_ASSERT(item && qstrcmp(item->metaObject()->className(), "IconItem") == 0); item->setParentItem(m_view->rootObject()); return item; @@ -143,7 +143,7 @@ void IconItemTest::loadPixmap() QCOMPARE(sourcePixmap, item->property("source").value()); } -//tests setting icon from a QImage +// tests setting icon from a QImage void IconItemTest::loadImage() { QScopedPointer item(createIconItem()); @@ -308,7 +308,7 @@ void IconItemTest::themeChange() QQuickItem *item1 = createIconItem(); item1->setProperty("animated", false); item1->setProperty("source", "zoom-fit-height"); - Plasma::Svg *svg1 = item1->findChild(); + Plasma::Svg *svg1 = item1->findChild(); changeTheme(svg1->theme(), "breeze-light"); QImage img1 = grabImage(item1); changeTheme(svg1->theme(), "breeze-dark"); @@ -321,7 +321,7 @@ void IconItemTest::themeChange() item2->setProperty("width", 22); item2->setProperty("height", 22); item2->setProperty("source", "tst-plasma-framework-test-icon"); - Plasma::Svg *svg2 = item2->findChild(); + Plasma::Svg *svg2 = item2->findChild(); changeTheme(svg2->theme(), "breeze-light"); img1 = grabImage(item2); changeTheme(svg2->theme(), "breeze-dark"); @@ -335,7 +335,7 @@ void IconItemTest::qiconFromTheme() QQuickItem *item1 = createIconItem(); QIcon icon1 = QIcon::fromTheme("konversation"); item1->setProperty("source", icon1); - QVERIFY(item1->findChild()); + QVERIFY(item1->findChild()); QVERIFY(!imageIsEmpty(grabImage(item1))); QCOMPARE(icon1, item1->property("source").value()); @@ -343,7 +343,7 @@ void IconItemTest::qiconFromTheme() QQuickItem *item2 = createIconItem(); QIcon icon2 = QIcon::fromTheme("tst-plasma-framework-test-icon"); item2->setProperty("source", icon2); - QVERIFY(item2->findChild()); + QVERIFY(item2->findChild()); QVERIFY(!imageIsEmpty(grabImage(item2))); QCOMPARE(icon2, item2->property("source").value()); } @@ -354,7 +354,7 @@ void IconItemTest::changeColorGroup() QQuickItem *item = createIconItem(); item->setProperty("animated", false); item->setProperty("source", "zoom-fit-height"); - Plasma::Svg *svg = item->findChild(); + Plasma::Svg *svg = item->findChild(); // not using "breeze" theme as that one follows system color scheme // and that one might not have a complementary group or a broken one changeTheme(svg->theme(), "breeze-light"); @@ -533,4 +533,3 @@ void IconItemTest::roundToIconSize() } QTEST_MAIN(IconItemTest) - diff --git a/autotests/iconitemtest.h b/autotests/iconitemtest.h index 1aa143dc6..34f5b809b 100644 --- a/autotests/iconitemtest.h +++ b/autotests/iconitemtest.h @@ -54,4 +54,3 @@ private: QQuickView *m_view; }; - diff --git a/autotests/plasmoidpackagetest.cpp b/autotests/plasmoidpackagetest.cpp index 7ce079434..8fcb686e4 100644 --- a/autotests/plasmoidpackagetest.cpp +++ b/autotests/plasmoidpackagetest.cpp @@ -7,11 +7,11 @@ #include "plasmoidpackagetest.h" #include "../config-plasma.h" +#include #include #include -#include -#include #include +#include #include @@ -246,7 +246,7 @@ void PlasmoidPackageTest::createAndInstallPackage() KZip package(packagePath); QVERIFY(package.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = package.directory(); - QVERIFY(dir);// + QVERIFY(dir); // QVERIFY(dir->entry("metadata.desktop")); const KArchiveEntry *contentsEntry = dir->entry("contents"); QVERIFY(contentsEntry); @@ -258,12 +258,12 @@ void PlasmoidPackageTest::createAndInstallPackage() m_defaultPackageStructure = new Plasma::PackageStructure(this); Plasma::Package *p = new Plasma::Package(m_defaultPackageStructure); qDebug() << "Installing " << archivePath; - //const QString packageRoot = "plasma/plasmoids/"; - //const QString servicePrefix = "plasma-applet-"; + // const QString packageRoot = "plasma/plasmoids/"; + // const QString servicePrefix = "plasma-applet-"; KJob *job = p->install(archivePath, m_packageRoot); - connect(job, SIGNAL(finished(KJob*)), SLOT(packageInstalled(KJob*))); + connect(job, SIGNAL(finished(KJob *)), SLOT(packageInstalled(KJob *))); - //QVERIFY(p->isValid()); + // QVERIFY(p->isValid()); delete p; } @@ -271,12 +271,12 @@ void PlasmoidPackageTest::packageInstalled(KJob *j) { qDebug() << "!!!!!!!!!!!!!!!!!!!! package installed" << (j->error() == KJob::NoError); QVERIFY(j->error() == KJob::NoError); - //QVERIFY(p->path()); + // QVERIFY(p->path()); Plasma::Package *p = new Plasma::Package(m_defaultPackageStructure); KJob *jj = p->uninstall("org.kde.microblog-qml", m_packageRoot); - //QObject::disconnect(j, SIGNAL(finished(KJob*)), this, SLOT(packageInstalled(KJob*))); - connect(jj, SIGNAL(finished(KJob*)), SLOT(packageInstalled(KJob*))); + // QObject::disconnect(j, SIGNAL(finished(KJob*)), this, SLOT(packageInstalled(KJob*))); + connect(jj, SIGNAL(finished(KJob *)), SLOT(packageInstalled(KJob *))); } void PlasmoidPackageTest::packageUninstalled(KJob *j) diff --git a/autotests/plasmoidpackagetest.h b/autotests/plasmoidpackagetest.h index b66f94bdf..4e0c79731 100644 --- a/autotests/plasmoidpackagetest.h +++ b/autotests/plasmoidpackagetest.h @@ -40,4 +40,3 @@ private: }; #endif - diff --git a/autotests/pluginloadertest.cpp b/autotests/pluginloadertest.cpp index 3123c0931..449dbba37 100644 --- a/autotests/pluginloadertest.cpp +++ b/autotests/pluginloadertest.cpp @@ -6,15 +6,15 @@ #include "pluginloadertest.h" -#include #include #include +#include #include #include -#include #include +#include QTEST_MAIN(PluginTest) @@ -26,9 +26,9 @@ PluginTest::PluginTest() void PluginTest::listEngines() { QVector plugins = Plasma::PluginLoader::self()->listDataEngineMetaData(); -// foreach (const KPluginInfo& info, plugins) { - //qDebug() << " Found DataEngine: " << info.pluginName() << info.name(); -// } + // foreach (const KPluginInfo& info, plugins) { + // qDebug() << " Found DataEngine: " << info.pluginName() << info.name(); + // } qDebug() << " Found " << plugins.count() << " DataEngines"; // Switch to true in order to let tests pass, this test usually will only // work with plugins installed, but there aren't any in plasma-framework @@ -47,7 +47,7 @@ void PluginTest::listContainmentActions() { const QVector plugins = Plasma::PluginLoader::self()->listContainmentActionsMetaData(QStringLiteral("plasma-shell")); qDebug() << "Categories: " << plugins.count(); - //QVERIFY(plugins.count() > 0 || m_buildonly); + // QVERIFY(plugins.count() > 0 || m_buildonly); } void PluginTest::listContainmentsOfType() @@ -55,12 +55,12 @@ void PluginTest::listContainmentsOfType() const KPluginInfo::List plugins = Plasma::PluginLoader::listContainmentsOfType(QStringLiteral("Desktop")); qDebug() << "Desktop Containments: " << plugins.count(); QVERIFY(plugins.count() > 0 || m_buildonly); - } static const auto source = QStringLiteral("Europe/Sofia"); -void EngineTest::dataUpdated(const QString &s, const Plasma::DataEngine::Data &data) { +void EngineTest::dataUpdated(const QString &s, const Plasma::DataEngine::Data &data) +{ QVERIFY(source == s); QVERIFY(data["Timezone"] == source); } @@ -92,4 +92,3 @@ void PluginTest::loadDataEngine() } #include "moc_pluginloadertest.cpp" - diff --git a/autotests/pluginloadertest.h b/autotests/pluginloadertest.h index 5abe947a2..9d45bb0a7 100644 --- a/autotests/pluginloadertest.h +++ b/autotests/pluginloadertest.h @@ -32,7 +32,9 @@ class EngineTest : public QObject { Q_OBJECT public: - EngineTest() {} + EngineTest() + { + } public Q_SLOTS: void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data); diff --git a/autotests/sortfiltermodeltest.cpp b/autotests/sortfiltermodeltest.cpp index 70ceb1b59..048afa068 100644 --- a/autotests/sortfiltermodeltest.cpp +++ b/autotests/sortfiltermodeltest.cpp @@ -10,9 +10,9 @@ // KDE // Qt +#include #include #include -#include #include using namespace Plasma; @@ -25,7 +25,7 @@ void SortFilterModelTest::setModel() QStandardItemModel model; SortFilterModel filterModel; - QSignalSpy spy(&filterModel, SIGNAL(sourceModelChanged(QObject*))); + QSignalSpy spy(&filterModel, SIGNAL(sourceModelChanged(QObject *))); filterModel.setModel(&model); QCOMPARE(spy.count(), 1); @@ -102,4 +102,3 @@ void SortFilterModelTest::mapRowFromSource() QCOMPARE(filterModel.mapRowFromSource(2), 1); QCOMPARE(filterModel.mapRowFromSource(-1), -1); } - diff --git a/autotests/themetest.cpp b/autotests/themetest.cpp index aa6085a55..e23d5d0ab 100644 --- a/autotests/themetest.cpp +++ b/autotests/themetest.cpp @@ -6,9 +6,9 @@ #include "themetest.h" #include "../src/plasma/private/svg_p.h" -#include #include #include +#include #include #include @@ -23,26 +23,23 @@ QString cacheIdHash(const Plasma::SvgPrivate::CacheId &id) { static const uint seed = 0x9e3779b9; - std::array parts = { - ::qHash(id.width), - ::qHash(id.height), - ::qHash(id.elementName), - ::qHash(id.filePath), - ::qHash(id.status), - ::qHash(id.devicePixelRatio), - ::qHash(id.scaleFactor), - ::qHash(id.colorGroup), - ::qHash(id.extraFlags), - ::qHash(id.lastModified) - }; + std::array parts = {::qHash(id.width), + ::qHash(id.height), + ::qHash(id.elementName), + ::qHash(id.filePath), + ::qHash(id.status), + ::qHash(id.devicePixelRatio), + ::qHash(id.scaleFactor), + ::qHash(id.colorGroup), + ::qHash(id.extraFlags), + ::qHash(id.lastModified)}; return QString::number(qHashRange(parts.begin(), parts.end(), seed)); } void ThemeTest::initTestCase() { // make our theme in search path - qputenv("XDG_DATA_DIRS", - qgetenv("XDG_DATA_DIRS") + ":" + QFINDTESTDATA("data").toLocal8Bit()); + qputenv("XDG_DATA_DIRS", qgetenv("XDG_DATA_DIRS") + ":" + QFINDTESTDATA("data").toLocal8Bit()); // set default icon theme to test-theme QStandardPaths::setTestModeEnabled(true); @@ -50,13 +47,13 @@ void ThemeTest::initTestCase() m_theme = new Plasma::Theme("testtheme", this); QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); - if(!QDir(configPath).mkpath(QStringLiteral("."))) { + if (!QDir(configPath).mkpath(QStringLiteral("."))) { qFatal("Failed to create test configuration directory."); } QFile::remove(configPath); - QIcon::setThemeSearchPaths(QStringList()<setImagePath(iconPath); QVERIFY(m_svg->isValid()); - m_svg->pixmap(); //trigger the SVG being loaded + m_svg->pixmap(); // trigger the SVG being loaded QFileInfo info(iconPath); - QString cacheId = cacheIdHash(Plasma::SvgPrivate::CacheId{48, 48, iconPath, QString(), m_svg->status(), m_svg->devicePixelRatio(), m_svg->scaleFactor(), m_svg->colorGroup(), 0, static_cast(info.lastModified().toSecsSinceEpoch())}); + QString cacheId = cacheIdHash(Plasma::SvgPrivate::CacheId{48, + 48, + iconPath, + QString(), + m_svg->status(), + m_svg->devicePixelRatio(), + m_svg->scaleFactor(), + m_svg->colorGroup(), + 0, + static_cast(info.lastModified().toSecsSinceEpoch())}); QPixmap result; QVERIFY(m_svg->theme()->findInCache(cacheId, result, info.lastModified().toSecsSinceEpoch())); @@ -102,12 +108,12 @@ void ThemeTest::loadSvgIcon() KIconTheme::forceThemeForTests("test-theme-two"); // KIconloader needs changesto be emitted manually, ouch. - for (int i=0; i < KIconLoader::LastGroup; i++) { + for (int i = 0; i < KIconLoader::LastGroup; i++) { KIconLoader::emitChange(KIconLoader::Group(i)); } spy.wait(); - //Svg emitting repaintNeeded when something changes in KIconLoader means the svg loaded an icon + // Svg emitting repaintNeeded when something changes in KIconLoader means the svg loaded an icon QVERIFY(spy.count() == 1); QVERIFY(!m_svg->theme()->findInCache(cacheId, result)); @@ -115,97 +121,53 @@ void ThemeTest::loadSvgIcon() void ThemeTest::testColors() { - QCOMPARE(m_theme->color(Plasma::Theme::TextColor, - Plasma::Theme::NormalColorGroup), QColor(49,54,59)); - QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, - Plasma::Theme::NormalColorGroup), QColor(239,240,241)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, - Plasma::Theme::NormalColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, - Plasma::Theme::NormalColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, - Plasma::Theme::NormalColorGroup), QColor(30,146,255)); - QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, - Plasma::Theme::NormalColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, - Plasma::Theme::NormalColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, - Plasma::Theme::NormalColorGroup), QColor(252,252,252)); - QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, - Plasma::Theme::NormalColorGroup), QColor(17,209,22)); - QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, - Plasma::Theme::NormalColorGroup), QColor(201,206,59)); - QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, - Plasma::Theme::NormalColorGroup), QColor(237,21,21)); + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, Plasma::Theme::NormalColorGroup), QColor(49, 54, 59)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, Plasma::Theme::NormalColorGroup), QColor(239, 240, 241)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, Plasma::Theme::NormalColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, Plasma::Theme::NormalColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, Plasma::Theme::NormalColorGroup), QColor(30, 146, 255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, Plasma::Theme::NormalColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, Plasma::Theme::NormalColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, Plasma::Theme::NormalColorGroup), QColor(252, 252, 252)); + QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, Plasma::Theme::NormalColorGroup), QColor(17, 209, 22)); + QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, Plasma::Theme::NormalColorGroup), QColor(201, 206, 59)); + QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, Plasma::Theme::NormalColorGroup), QColor(237, 21, 21)); - QCOMPARE(m_theme->color(Plasma::Theme::TextColor, - Plasma::Theme::ButtonColorGroup), QColor(49,54,59)); - QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, - Plasma::Theme::ButtonColorGroup), QColor(239,240,241)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, - Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, - Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, - Plasma::Theme::ButtonColorGroup), QColor(30,146,255)); - QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, - Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, - Plasma::Theme::ButtonColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, - Plasma::Theme::ButtonColorGroup), QColor(252,252,252)); - QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, - Plasma::Theme::ButtonColorGroup), QColor(17,209,23)); - QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, - Plasma::Theme::ButtonColorGroup), QColor(201,206,60)); - QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, - Plasma::Theme::ButtonColorGroup), QColor(237,21,22)); + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, Plasma::Theme::ButtonColorGroup), QColor(49, 54, 59)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, Plasma::Theme::ButtonColorGroup), QColor(239, 240, 241)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, Plasma::Theme::ButtonColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, Plasma::Theme::ButtonColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, Plasma::Theme::ButtonColorGroup), QColor(30, 146, 255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, Plasma::Theme::ButtonColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, Plasma::Theme::ButtonColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, Plasma::Theme::ButtonColorGroup), QColor(252, 252, 252)); + QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, Plasma::Theme::ButtonColorGroup), QColor(17, 209, 23)); + QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, Plasma::Theme::ButtonColorGroup), QColor(201, 206, 60)); + QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, Plasma::Theme::ButtonColorGroup), QColor(237, 21, 22)); - QCOMPARE(m_theme->color(Plasma::Theme::TextColor, - Plasma::Theme::ViewColorGroup), QColor(49,54,59)); - QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, - Plasma::Theme::ViewColorGroup), QColor(252,252,252)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, - Plasma::Theme::ViewColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, - Plasma::Theme::ViewColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, - Plasma::Theme::ViewColorGroup), QColor(30,146,255)); - QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, - Plasma::Theme::ViewColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, - Plasma::Theme::ViewColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, - Plasma::Theme::ViewColorGroup), QColor(252,252,252)); - QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, - Plasma::Theme::ViewColorGroup), QColor(17,209,24)); - QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, - Plasma::Theme::ViewColorGroup), QColor(201,206,61)); - QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, - Plasma::Theme::ViewColorGroup), QColor(237,21,23)); + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, Plasma::Theme::ViewColorGroup), QColor(49, 54, 59)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, Plasma::Theme::ViewColorGroup), QColor(252, 252, 252)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, Plasma::Theme::ViewColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, Plasma::Theme::ViewColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, Plasma::Theme::ViewColorGroup), QColor(30, 146, 255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, Plasma::Theme::ViewColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, Plasma::Theme::ViewColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, Plasma::Theme::ViewColorGroup), QColor(252, 252, 252)); + QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, Plasma::Theme::ViewColorGroup), QColor(17, 209, 24)); + QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, Plasma::Theme::ViewColorGroup), QColor(201, 206, 61)); + QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, Plasma::Theme::ViewColorGroup), QColor(237, 21, 23)); - QCOMPARE(m_theme->color(Plasma::Theme::TextColor, - Plasma::Theme::ComplementaryColorGroup), QColor(239,240,241)); - QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, - Plasma::Theme::ComplementaryColorGroup), QColor(49,54,59)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, - Plasma::Theme::ComplementaryColorGroup), QColor(61,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, - Plasma::Theme::ComplementaryColorGroup), QColor(71,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, - Plasma::Theme::ComplementaryColorGroup), QColor(40,146,255)); - QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, - Plasma::Theme::ComplementaryColorGroup), QColor(71,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, - Plasma::Theme::ComplementaryColorGroup), QColor(71,174,230)); - QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, - Plasma::Theme::ComplementaryColorGroup), QColor(252,252,252)); - QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, - Plasma::Theme::ComplementaryColorGroup), QColor(17,209,25)); - QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, - Plasma::Theme::ComplementaryColorGroup), QColor(201,206,62)); - QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, - Plasma::Theme::ComplementaryColorGroup), QColor(237,21,24)); + QCOMPARE(m_theme->color(Plasma::Theme::TextColor, Plasma::Theme::ComplementaryColorGroup), QColor(239, 240, 241)); + QCOMPARE(m_theme->color(Plasma::Theme::BackgroundColor, Plasma::Theme::ComplementaryColorGroup), QColor(49, 54, 59)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightColor, Plasma::Theme::ComplementaryColorGroup), QColor(61, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HoverColor, Plasma::Theme::ComplementaryColorGroup), QColor(71, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::FocusColor, Plasma::Theme::ComplementaryColorGroup), QColor(40, 146, 255)); + QCOMPARE(m_theme->color(Plasma::Theme::LinkColor, Plasma::Theme::ComplementaryColorGroup), QColor(71, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::VisitedLinkColor, Plasma::Theme::ComplementaryColorGroup), QColor(71, 174, 230)); + QCOMPARE(m_theme->color(Plasma::Theme::HighlightedTextColor, Plasma::Theme::ComplementaryColorGroup), QColor(252, 252, 252)); + QCOMPARE(m_theme->color(Plasma::Theme::PositiveTextColor, Plasma::Theme::ComplementaryColorGroup), QColor(17, 209, 25)); + QCOMPARE(m_theme->color(Plasma::Theme::NeutralTextColor, Plasma::Theme::ComplementaryColorGroup), QColor(201, 206, 62)); + QCOMPARE(m_theme->color(Plasma::Theme::NegativeTextColor, Plasma::Theme::ComplementaryColorGroup), QColor(237, 21, 24)); } void ThemeTest::testCompositingChange() @@ -250,4 +212,3 @@ void ThemeTest::testCompositingChange() } QTEST_MAIN(ThemeTest) - diff --git a/autotests/themetest.h b/autotests/themetest.h index 41e74c631..3b105f956 100644 --- a/autotests/themetest.h +++ b/autotests/themetest.h @@ -8,8 +8,8 @@ #include -#include "plasma/theme.h" #include "plasma/svg.h" +#include "plasma/theme.h" class ThemeTest : public QObject { @@ -30,4 +30,3 @@ private: }; #endif - diff --git a/autotests/utils.h b/autotests/utils.h index 5ccbaf0f7..e713e503f 100644 --- a/autotests/utils.h +++ b/autotests/utils.h @@ -6,20 +6,21 @@ #ifndef UTILS_H #define UTILS_H -#include #include #include +#include #include -namespace Plasma { -namespace TestUtils { - +namespace Plasma +{ +namespace TestUtils +{ static void copyPath(const QString &src, const QString &dst) { QDir dir(src); const auto dirList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - for (const auto &d : dirList ) { + for (const auto &d : dirList) { QString dst_path = dst + QLatin1Char('/') + d; dir.mkpath(dst_path); copyPath(src + QLatin1Char('/') + d, dst_path); @@ -49,12 +50,11 @@ static void installPlasmaTheme(const QString &theme = QStringLiteral("breeze")) const QString colorsFile = QFINDTESTDATA("../src/desktoptheme/" + theme + "/colors"); if (!colorsFile.isEmpty()) { - QFile::copy(colorsFile, themePath.filePath("colors")); + QFile::copy(colorsFile, themePath.filePath("colors")); } - } -} //TestUtils -} //Plasma +} // TestUtils +} // Plasma #endif diff --git a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp index 3346c34fd..3d4786e8f 100644 --- a/examples/dataengines/customDataContainers/customDataContainersEngine.cpp +++ b/examples/dataengines/customDataContainers/customDataContainersEngine.cpp @@ -4,8 +4,8 @@ SPDX-License-Identifier: BSD-2-Clause */ -#include #include +#include #include "customDataContainersEngine.h" @@ -68,4 +68,3 @@ K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.kde.examples.customDataContainers, Data // include the moc file so the build system makes it for us #include "customDataContainersEngine.moc" - diff --git a/examples/dataengines/customDataContainers/httpContainer.cpp b/examples/dataengines/customDataContainers/httpContainer.cpp index 408779ac6..ef9a2de77 100644 --- a/examples/dataengines/customDataContainers/httpContainer.cpp +++ b/examples/dataengines/customDataContainers/httpContainer.cpp @@ -9,8 +9,8 @@ #include HttpContainer::HttpContainer(const QUrl &url, QObject *parent) - : Plasma::DataContainer(parent), - m_url(url) + : Plasma::DataContainer(parent) + , m_url(url) { // Since we are grabbing data over the network, we request a // backing store. This way, if the network is down or on first start @@ -29,9 +29,8 @@ void HttpContainer::fetchUrl(bool reload) m_data.clear(); KIO::TransferJob *job = KIO::get(m_url, reload ? KIO::Reload : KIO::NoReload, KIO::HideProgressInfo); - connect(job, SIGNAL(data(KIO::Job*,QByteArray)), - this, SLOT(data(KIO::Job*,QByteArray))); - connect(job, SIGNAL(finished(KJob*)), this, SLOT(fetchFinished(KJob*))); + connect(job, SIGNAL(data(KIO::Job *, QByteArray)), this, SLOT(data(KIO::Job *, QByteArray))); + connect(job, SIGNAL(finished(KJob *)), this, SLOT(fetchFinished(KJob *))); if (m_job) { m_job.data()->kill(); @@ -76,5 +75,3 @@ void HttpContainer::fetchFinished(KJob *job) m_data.clear(); } } - - diff --git a/examples/dataengines/dataEngineTracker/dataenginetracker.cpp b/examples/dataengines/dataEngineTracker/dataenginetracker.cpp index a5ea1c23d..907b94541 100644 --- a/examples/dataengines/dataEngineTracker/dataenginetracker.cpp +++ b/examples/dataengines/dataEngineTracker/dataenginetracker.cpp @@ -6,12 +6,12 @@ #include "dataenginetracker.h" -#include #include +#include DataEngineTracker::DataEngineTracker(Plasma::DataEngine *engine, QObject *parent) - : QObject(parent), - m_engine(engine) + : QObject(parent) + , m_engine(engine) { connect(engine, SIGNAL(sourceAdded(QString)), this, SLOT(sourceAdded(QString))); connect(engine, SIGNAL(sourceRemoved(QString)), this, SLOT(sourceRemoved(QString))); @@ -40,4 +40,3 @@ void DataEngineTracker::sourceRemoved(const QString &source) } #include - diff --git a/examples/dataengines/dataEngineTracker/dataenginetracker.h b/examples/dataengines/dataEngineTracker/dataenginetracker.h index b846a856e..133c3e958 100644 --- a/examples/dataengines/dataEngineTracker/dataenginetracker.h +++ b/examples/dataengines/dataEngineTracker/dataenginetracker.h @@ -28,4 +28,3 @@ private: }; #endif - diff --git a/examples/dataengines/simpleEngine/simpleEngine.cpp b/examples/dataengines/simpleEngine/simpleEngine.cpp index e540e85bc..6c539fbd4 100644 --- a/examples/dataengines/simpleEngine/simpleEngine.cpp +++ b/examples/dataengines/simpleEngine/simpleEngine.cpp @@ -28,7 +28,6 @@ SimpleEngine::SimpleEngine(QObject *parent, const QVariantList &args) void SimpleEngine::init() { - // So now we will set up some sources. // Each DataEngine will, generally, be loaded once. Each DataEngine // can provide multiple sets of data keyed by a string, called "Sources". @@ -59,4 +58,3 @@ K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.kde.examples.simpleEngine, SimpleEngine // include the moc file so the build system makes it for us #include "simpleEngine.moc" - diff --git a/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp b/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp index 53ff51a66..dc4f7f53a 100644 --- a/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp +++ b/examples/dataengines/sourcesOnRequest/sourcesOnRequest.cpp @@ -94,4 +94,3 @@ K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(org.kde.examples.sourcesOnRequest, SourcesO // include the moc file so the build system makes it for us #include "sourcesOnRequest.moc" - diff --git a/examples/shell/customcorona.cpp b/examples/shell/customcorona.cpp index 23911e14c..3e7c05cd4 100644 --- a/examples/shell/customcorona.cpp +++ b/examples/shell/customcorona.cpp @@ -5,9 +5,9 @@ */ #include "customcorona.h" -#include -#include #include +#include +#include #include #include @@ -17,23 +17,27 @@ CustomCorona::CustomCorona(QObject *parent) : Plasma::Corona(parent) { KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Shell")); - //applications that want to load a plasma scene would have to load their own shell.. TODO: have a simple shell in plasma-framework for this purpose? + // applications that want to load a plasma scene would have to load their own shell.. TODO: have a simple shell in plasma-framework for this purpose? package.setPath(QStringLiteral("org.kde.plasma.desktop")); setKPackage(package); - qmlRegisterUncreatableType("org.kde.plasma.shell", 2, 0, "Desktop", QStringLiteral("It is not possible to create objects of type Desktop")); + qmlRegisterUncreatableType("org.kde.plasma.shell", + 2, + 0, + "Desktop", + QStringLiteral("It is not possible to create objects of type Desktop")); m_view = new PlasmaQuick::ContainmentView(this); m_view->setSource(package.fileUrl("views", QStringLiteral("Desktop.qml"))); m_view->show(); - + load(); } QRect CustomCorona::screenGeometry(int id) const { Q_UNUSED(id); - //TODO? + // TODO? return QRect(); } @@ -56,10 +60,10 @@ void CustomCorona::load() saveLayout(QStringLiteral("exampleplasmashell-appletsrc")); } - //don't let containments to be removed + // don't let containments to be removed for (auto c : containments()) { if (c->containmentType() == Plasma::Types::DesktopContainment) { - //example of a shell without a wallpaper + // example of a shell without a wallpaper c->setWallpaper(QStringLiteral("null")); m_view->setContainment(c); if (QAction *removeAction = c->actions()->action(QStringLiteral("remove"))) { diff --git a/examples/shell/main.cpp b/examples/shell/main.cpp index e4c4a9323..44cf7f5fb 100644 --- a/examples/shell/main.cpp +++ b/examples/shell/main.cpp @@ -5,8 +5,8 @@ */ #include -#include #include +#include #include #include diff --git a/examples/testcontainmentactionsplugin/test.cpp b/examples/testcontainmentactionsplugin/test.cpp index 21264902a..e09c84297 100644 --- a/examples/testcontainmentactionsplugin/test.cpp +++ b/examples/testcontainmentactionsplugin/test.cpp @@ -6,9 +6,8 @@ #include "test.h" - -#include #include +#include #include @@ -44,14 +43,14 @@ void ContextTest::init(const KConfigGroup &config) QWidget *ContextTest::createConfigurationInterface(QWidget *parent) { - //m_currentText = m_text; + // m_currentText = m_text; QWidget *widget = new QWidget(parent); m_ui.setupUi(widget); m_ui.text->setText(m_text); - //FIXME this way or just get it on close? - //connect(m_ui.text, SIGNAL(changed(QColor)), this, SLOT(setColor(QColor))); - //connect(this, SIGNAL(settingsChanged(bool)), parent, SLOT(settingsChanged(bool))); + // FIXME this way or just get it on close? + // connect(m_ui.text, SIGNAL(changed(QColor)), this, SLOT(setColor(QColor))); + // connect(this, SIGNAL(settingsChanged(bool)), parent, SLOT(settingsChanged(bool))); return widget; } diff --git a/examples/testcontainmentactionsplugin/test.h b/examples/testcontainmentactionsplugin/test.h index 28c9abd67..1076f0a8d 100644 --- a/examples/testcontainmentactionsplugin/test.h +++ b/examples/testcontainmentactionsplugin/test.h @@ -8,8 +8,8 @@ #define CONTEXTTEST_HEADER #include "ui_config.h" -#include #include +#include class ContextTest : public Plasma::ContainmentActions { diff --git a/src/declarativeimports/calendar/calendar.cpp b/src/declarativeimports/calendar/calendar.cpp index c4722c730..4cc54cd5a 100644 --- a/src/declarativeimports/calendar/calendar.cpp +++ b/src/declarativeimports/calendar/calendar.cpp @@ -23,7 +23,7 @@ Calendar::Calendar(QObject *parent) m_daysModel->setSourceData(&m_dayList); // m_dayHelper = new CalendarDayHelper(this); -// connect(m_dayHelper, SIGNAL(calendarChanged()), this, SLOT(updateData())); + // connect(m_dayHelper, SIGNAL(calendarChanged()), this, SLOT(updateData())); } QDateTime Calendar::displayedDate() const @@ -100,8 +100,8 @@ void Calendar::setTypes(int types) return; } -// m_types = static_cast(types); -// updateTypes(); + // m_types = static_cast(types); + // updateTypes(); Q_EMIT typesChanged(); } @@ -239,7 +239,7 @@ void Calendar::updateData() if (daysBeforeCurrentMonth > 0) { QDate previousMonth = m_displayedDate.addMonths(-1); - //QDate previousMonth(m_displayedDate.year(), m_displayedDate.month() - 1, 1); + // QDate previousMonth(m_displayedDate.year(), m_displayedDate.month() - 1, 1); for (int i = 0; i < daysBeforeCurrentMonth; i++) { DayData day; day.isCurrent = false; @@ -259,7 +259,6 @@ void Calendar::updateData() day.monthNumber = m_displayedDate.month(); day.yearNumber = m_displayedDate.year(); m_dayList << day; - } if (daysAfterCurrentMonth > 0) { @@ -295,16 +294,16 @@ void Calendar::updateData() Q_EMIT weeksModelChanged(); m_daysModel->update(); -// qDebug() << "---------------------------------------------------------------"; -// qDebug() << "Date obj: " << m_displayedDate; -// qDebug() << "Month: " << m_displayedDate.month(); -// qDebug() << "m_days: " << m_days; -// qDebug() << "m_weeks: " << m_weeks; -// qDebug() << "Days before this month: " << daysBeforeCurrentMonth; -// qDebug() << "Days after this month: " << daysAfterCurrentMonth; -// qDebug() << "Days in current month: " << m_displayedDate.daysInMonth(); -// qDebug() << "m_dayList size: " << m_dayList.count(); -// qDebug() << "---------------------------------------------------------------"; + // qDebug() << "---------------------------------------------------------------"; + // qDebug() << "Date obj: " << m_displayedDate; + // qDebug() << "Month: " << m_displayedDate.month(); + // qDebug() << "m_days: " << m_days; + // qDebug() << "m_weeks: " << m_weeks; + // qDebug() << "Days before this month: " << daysBeforeCurrentMonth; + // qDebug() << "Days after this month: " << daysAfterCurrentMonth; + // qDebug() << "Days in current month: " << m_displayedDate.daysInMonth(); + // qDebug() << "m_dayList size: " << m_dayList.count(); + // qDebug() << "---------------------------------------------------------------"; } void Calendar::nextDecade() diff --git a/src/declarativeimports/calendar/calendar.h b/src/declarativeimports/calendar/calendar.h index b6d488baa..d22507200 100644 --- a/src/declarativeimports/calendar/calendar.h +++ b/src/declarativeimports/calendar/calendar.h @@ -8,10 +8,10 @@ #ifndef CALENDAR_H #define CALENDAR_H -#include -#include #include +#include #include +#include #include "daydata.h" #include "daysmodel.h" @@ -112,7 +112,6 @@ class Calendar : public QObject */ Q_PROPERTY(QAbstractListModel *daysModel READ daysModel CONSTANT) - public: enum Type { Holiday = 1, diff --git a/src/declarativeimports/calendar/calendardata.cpp b/src/declarativeimports/calendar/calendardata.cpp index 2bd477d8a..51d0b8014 100644 --- a/src/declarativeimports/calendar/calendardata.cpp +++ b/src/declarativeimports/calendar/calendardata.cpp @@ -10,8 +10,8 @@ CalendarData::CalendarData(QObject *parent) : QObject(parent) , m_types(Holiday | Event | Todo | Journal) { -// m_etmCalendar = new ETMCalendar(); -// m_etmCalendar->setParent(this); //TODO: hit sergio + // m_etmCalendar = new ETMCalendar(); + // m_etmCalendar->setParent(this); //TODO: hit sergio // EntityTreeModel *model = m_etmCalendar->entityTreeModel(); // model->setCollectionFetchStrategy(EntityTreeModel::InvisibleCollectionFetch); @@ -25,7 +25,7 @@ CalendarData::CalendarData(QObject *parent) // m_filteredList = new DateTimeRangeFilterModel(this); // m_filteredList->setSourceModel(roleModel); -// updateTypes(); + // updateTypes(); } QDate CalendarData::startDate() const @@ -40,7 +40,7 @@ void CalendarData::setStartDate(const QDate &dateTime) } m_startDate = dateTime; -// m_filteredList->setStartDate(m_startDate); + // m_filteredList->setStartDate(m_startDate); Q_EMIT startDateChanged(); } @@ -74,4 +74,3 @@ bool CalendarData::loading() const { return false; } - diff --git a/src/declarativeimports/calendar/calendardata.h b/src/declarativeimports/calendar/calendardata.h index 5f7ec75f4..756c7e6e3 100644 --- a/src/declarativeimports/calendar/calendardata.h +++ b/src/declarativeimports/calendar/calendardata.h @@ -7,9 +7,9 @@ #ifndef CALENDARDATA_H #define CALENDARDATA_H -#include -#include #include +#include +#include class QAbstractItemModel; diff --git a/src/declarativeimports/calendar/calendarplugin.cpp b/src/declarativeimports/calendar/calendarplugin.cpp index 7c5865d56..657b2698e 100644 --- a/src/declarativeimports/calendar/calendarplugin.cpp +++ b/src/declarativeimports/calendar/calendarplugin.cpp @@ -5,14 +5,14 @@ */ #include "calendarplugin.h" -#include "calendardata.h" #include "calendar.h" +#include "calendardata.h" #include "eventdatadecorator.h" #include "eventpluginsmanager.h" -#include -#include #include +#include +#include static QObject *event_plugins_manager_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { @@ -30,6 +30,5 @@ void CalendarPlugin::registerTypes(const char *uri) qmlRegisterAnonymousType(uri, 1); qmlRegisterAnonymousType(uri, 1); qmlRegisterSingletonType(uri, 2, 0, "EventPluginsManager", event_plugins_manager_provider); - qmlRegisterUncreatableType(uri, 2, 0, "EventDataDecorator", - QStringLiteral("Unabel to create EventDataDecorator from QML")); + qmlRegisterUncreatableType(uri, 2, 0, "EventDataDecorator", QStringLiteral("Unabel to create EventDataDecorator from QML")); } diff --git a/src/declarativeimports/calendar/daydata.h b/src/declarativeimports/calendar/daydata.h index df63f1774..c71d763b5 100644 --- a/src/declarativeimports/calendar/daydata.h +++ b/src/declarativeimports/calendar/daydata.h @@ -9,10 +9,10 @@ class DayData { public: bool isCurrent; -// bool containsHolidayItems; -// bool containsEventItems; -// bool containsTodoItems; -// bool containsJournalItems; + // bool containsHolidayItems; + // bool containsEventItems; + // bool containsTodoItems; + // bool containsJournalItems; int dayNumber; int monthNumber; int yearNumber; diff --git a/src/declarativeimports/calendar/daysmodel.cpp b/src/declarativeimports/calendar/daysmodel.cpp index baf17bd7b..279790701 100644 --- a/src/declarativeimports/calendar/daysmodel.cpp +++ b/src/declarativeimports/calendar/daysmodel.cpp @@ -9,18 +9,17 @@ #include "eventdatadecorator.h" #include "eventpluginsmanager.h" -#include #include +#include #include #include -DaysModel::DaysModel(QObject *parent) : - QAbstractListModel(parent), - m_pluginsManager(nullptr), - m_lastRequestedEventsStartDate(QDate()), - m_agendaNeedsUpdate(false) +DaysModel::DaysModel(QObject *parent) + : QAbstractListModel(parent) + , m_pluginsManager(nullptr) + , m_lastRequestedEventsStartDate(QDate()) + , m_agendaNeedsUpdate(false) { - } DaysModel::~DaysModel() @@ -50,7 +49,6 @@ int DaysModel::rowCount(const QModelIndex &parent) const QVariant DaysModel::data(const QModelIndex &index, int role) const { if (index.isValid()) { - const DayData ¤tData = m_data->at(index.row()); const QDate currentDate(currentData.yearNumber, currentData.monthNumber, currentData.dayNumber); @@ -105,8 +103,7 @@ void DaysModel::onDataReady(const QMultiHash & } // only the containsEventItems roles may have changed - Q_EMIT dataChanged(index(0, 0), index(m_data->count() - 1, 0), - {containsEventItems, containsMajorEventItems, containsMinorEventItems}); + Q_EMIT dataChanged(index(0, 0), index(m_data->count() - 1, 0), {containsEventItems, containsMajorEventItems, containsMinorEventItems}); Q_EMIT agendaUpdated(QDate::currentDate()); } @@ -131,8 +128,7 @@ void DaysModel::onEventModified(const CalendarEvents::EventData &data) for (const QDate date : qAsConst(updatesList)) { const QModelIndex changedIndex = indexForDate(date); if (changedIndex.isValid()) { - Q_EMIT dataChanged(changedIndex, changedIndex, - {containsEventItems, containsMajorEventItems, containsMinorEventItems}); + Q_EMIT dataChanged(changedIndex, changedIndex, {containsEventItems, containsMajorEventItems, containsMinorEventItems}); } Q_EMIT agendaUpdated(date); } @@ -158,14 +154,13 @@ void DaysModel::onEventRemoved(const QString &uid) for (const QDate date : qAsConst(updatesList)) { const QModelIndex changedIndex = indexForDate(date); if (changedIndex.isValid()) { - Q_EMIT dataChanged(changedIndex, changedIndex, - {containsEventItems, containsMajorEventItems, containsMinorEventItems}); + Q_EMIT dataChanged(changedIndex, changedIndex, {containsEventItems, containsMajorEventItems, containsMinorEventItems}); } Q_EMIT agendaUpdated(date); } } -QList DaysModel::eventsForDate(const QDate &date) +QList DaysModel::eventsForDate(const QDate &date) { if (m_lastRequestedAgendaDate == date && !m_agendaNeedsUpdate) { return m_qmlData; @@ -231,7 +226,7 @@ bool DaysModel::hasMinorEventAtDate(const QDate &date) const void DaysModel::setPluginsManager(QObject *manager) { - EventPluginsManager *m = qobject_cast(manager); + EventPluginsManager *m = qobject_cast(manager); if (!m) { return; @@ -244,27 +239,21 @@ void DaysModel::setPluginsManager(QObject *manager) m_pluginsManager = m; - connect(m_pluginsManager, &EventPluginsManager::dataReady, - this, &DaysModel::onDataReady); - connect(m_pluginsManager, &EventPluginsManager::eventModified, - this, &DaysModel::onEventModified); - connect(m_pluginsManager, &EventPluginsManager::eventRemoved, - this, &DaysModel::onEventRemoved); - connect(m_pluginsManager, &EventPluginsManager::pluginsChanged, - this, &DaysModel::update); + connect(m_pluginsManager, &EventPluginsManager::dataReady, this, &DaysModel::onDataReady); + connect(m_pluginsManager, &EventPluginsManager::eventModified, this, &DaysModel::onEventModified); + connect(m_pluginsManager, &EventPluginsManager::eventRemoved, this, &DaysModel::onEventRemoved); + connect(m_pluginsManager, &EventPluginsManager::pluginsChanged, this, &DaysModel::update); QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); } QHash DaysModel::roleNames() const { - return { - {isCurrent, "isCurrent"}, - {containsEventItems, "containsEventItems"}, - {containsMajorEventItems, "containsMajorEventItems"}, - {containsMinorEventItems, "containsMinorEventItems"}, - {dayNumber, "dayNumber"}, - {monthNumber, "monthNumber"}, - {yearNumber, "yearNumber"} - }; + return {{isCurrent, "isCurrent"}, + {containsEventItems, "containsEventItems"}, + {containsMajorEventItems, "containsMajorEventItems"}, + {containsMinorEventItems, "containsMinorEventItems"}, + {dayNumber, "dayNumber"}, + {monthNumber, "monthNumber"}, + {yearNumber, "yearNumber"}}; } diff --git a/src/declarativeimports/calendar/daysmodel.h b/src/declarativeimports/calendar/daysmodel.h index 8b9646688..4c0d45ed8 100644 --- a/src/declarativeimports/calendar/daysmodel.h +++ b/src/declarativeimports/calendar/daysmodel.h @@ -22,12 +22,12 @@ class DaysModel : public QAbstractListModel public: enum Roles { isCurrent = Qt::UserRole + 1, - //containsHolidayItems, + // containsHolidayItems, containsEventItems, containsMajorEventItems, containsMinorEventItems, - //containsTodoItems, - //containsJournalItems, + // containsTodoItems, + // containsJournalItems, dayNumber, monthNumber, yearNumber, @@ -41,7 +41,7 @@ public: Q_INVOKABLE void setPluginsManager(QObject *manager); - Q_INVOKABLE QList eventsForDate(const QDate &date); + Q_INVOKABLE QList eventsForDate(const QDate &date); QHash roleNames() const override; @@ -63,9 +63,9 @@ private: EventPluginsManager *m_pluginsManager = nullptr; QList *m_data = nullptr; - QList m_qmlData; + QList m_qmlData; QDate m_lastRequestedAgendaDate; - QList m_eventPlugins; + QList m_eventPlugins; QMultiHash m_eventsData; QDate m_lastRequestedEventsStartDate; // this is always this+42 days bool m_agendaNeedsUpdate; diff --git a/src/declarativeimports/calendar/eventdatadecorator.cpp b/src/declarativeimports/calendar/eventdatadecorator.cpp index ae6a0e42b..9159e43b8 100644 --- a/src/declarativeimports/calendar/eventdatadecorator.cpp +++ b/src/declarativeimports/calendar/eventdatadecorator.cpp @@ -9,8 +9,8 @@ #include EventDataDecorator::EventDataDecorator(const CalendarEvents::EventData &data, QObject *parent) - : QObject(parent), - m_data(data) + : QObject(parent) + , m_data(data) { } @@ -47,12 +47,12 @@ QString EventDataDecorator::description() const QString EventDataDecorator::eventType() const { switch (m_data.type()) { - case CalendarEvents::EventData::Holiday: - return i18nc("Agenda listview section title", "Holidays"); - case CalendarEvents::EventData::Event: - return i18nc("Agenda listview section title", "Events"); - case CalendarEvents::EventData::Todo: - return i18nc("Agenda listview section title", "Todo"); + case CalendarEvents::EventData::Holiday: + return i18nc("Agenda listview section title", "Holidays"); + case CalendarEvents::EventData::Event: + return i18nc("Agenda listview section title", "Events"); + case CalendarEvents::EventData::Todo: + return i18nc("Agenda listview section title", "Todo"); } return i18nc("Means 'Other calendar items'", "Other"); } diff --git a/src/declarativeimports/calendar/eventdatadecorator.h b/src/declarativeimports/calendar/eventdatadecorator.h index d4ee272c6..465b0c435 100644 --- a/src/declarativeimports/calendar/eventdatadecorator.h +++ b/src/declarativeimports/calendar/eventdatadecorator.h @@ -7,8 +7,8 @@ #ifndef EVENTDATADECORATOR_H #define EVENTDATADECORATOR_H -#include #include +#include #include #include diff --git a/src/declarativeimports/calendar/eventpluginsmanager.cpp b/src/declarativeimports/calendar/eventpluginsmanager.cpp index 7a8247fcf..2b0b132a1 100644 --- a/src/declarativeimports/calendar/eventpluginsmanager.cpp +++ b/src/declarativeimports/calendar/eventpluginsmanager.cpp @@ -8,12 +8,12 @@ #include -#include #include +#include +#include +#include #include #include -#include -#include #include #include @@ -22,7 +22,8 @@ class EventPluginsModel : public QAbstractListModel { Q_OBJECT public: - EventPluginsModel(EventPluginsManager *manager) : QAbstractListModel(manager) + EventPluginsModel(EventPluginsManager *manager) + : QAbstractListModel(manager) { m_manager = manager; m_roles = QAbstractListModel::roleNames(); @@ -64,28 +65,26 @@ public: const EventPluginsManager::PluginData metadata = it.value(); switch (role) { - case Qt::DisplayRole: - return metadata.name; - case Qt::ToolTipRole: - return metadata.desc; - case Qt::DecorationRole: - return metadata.icon; - case Qt::UserRole: - { - // The currentPlugin path contains the full path including - // the plugin filename, so it needs to be cut off from the last '/' - const QStringRef pathRef = currentPlugin.leftRef(currentPlugin.lastIndexOf(QLatin1Char('/'))); - const QString qmlFilePath = metadata.configUi; - return QString(pathRef % QLatin1Char('/') % qmlFilePath); - } - case Qt::UserRole + 1: - return currentPlugin; - case Qt::EditRole: - return m_manager->m_enabledPlugins.contains(currentPlugin); + case Qt::DisplayRole: + return metadata.name; + case Qt::ToolTipRole: + return metadata.desc; + case Qt::DecorationRole: + return metadata.icon; + case Qt::UserRole: { + // The currentPlugin path contains the full path including + // the plugin filename, so it needs to be cut off from the last '/' + const QStringRef pathRef = currentPlugin.leftRef(currentPlugin.lastIndexOf(QLatin1Char('/'))); + const QString qmlFilePath = metadata.configUi; + return QString(pathRef % QLatin1Char('/') % qmlFilePath); + } + case Qt::UserRole + 1: + return currentPlugin; + case Qt::EditRole: + return m_manager->m_enabledPlugins.contains(currentPlugin); } return QVariant(); - } bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override @@ -123,18 +122,12 @@ private: EventPluginsManager::EventPluginsManager(QObject *parent) : QObject(parent) { - auto plugins = KPluginLoader::findPlugins( - QStringLiteral("plasmacalendarplugins"), - [](const KPluginMetaData &md) { - return md.serviceTypes().contains(QLatin1String("PlasmaCalendar/Plugin")); - }); + auto plugins = KPluginLoader::findPlugins(QStringLiteral("plasmacalendarplugins"), [](const KPluginMetaData &md) { + return md.serviceTypes().contains(QLatin1String("PlasmaCalendar/Plugin")); + }); for (const KPluginMetaData &plugin : qAsConst(plugins)) { m_availablePlugins.insert(plugin.fileName(), - { plugin.name(), - plugin.description(), - plugin.iconName(), - plugin.value(QStringLiteral("X-KDE-PlasmaCalendar-ConfigUi")) - }); + {plugin.name(), plugin.description(), plugin.iconName(), plugin.value(QStringLiteral("X-KDE-PlasmaCalendar-ConfigUi"))}); } // Fallback for legacy pre-KPlugin plugins so we can still load them @@ -160,11 +153,10 @@ EventPluginsManager::EventPluginsManager(QObject *parent) if (loader.metaData().value(QStringLiteral("IID")) == QLatin1String("org.kde.CalendarEventsPlugin")) { const auto md = loader.metaData().value(QStringLiteral("MetaData")).toObject(); m_availablePlugins.insert(absolutePath, - { md.value(QStringLiteral("Name")).toString(), - md.value(QStringLiteral("Description")).toString(), - md.value(QStringLiteral("Icon")).toString(), - md.value(QStringLiteral("ConfigUi")).toString() - }); + {md.value(QStringLiteral("Name")).toString(), + md.value(QStringLiteral("Description")).toString(), + md.value(QStringLiteral("Icon")).toString(), + md.value(QStringLiteral("ConfigUi")).toString()}); } } } @@ -229,19 +221,16 @@ void EventPluginsManager::loadPlugin(const QString &absolutePath) QObject *obj = loader.instance(); if (obj) { - CalendarEvents::CalendarEventsPlugin *eventsPlugin = qobject_cast(obj); + CalendarEvents::CalendarEventsPlugin *eventsPlugin = qobject_cast(obj); if (eventsPlugin) { qDebug() << "Loading Calendar plugin" << eventsPlugin; eventsPlugin->setProperty("pluginPath", absolutePath); m_plugins << eventsPlugin; // Connect the relay signals - connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::dataReady, - this, &EventPluginsManager::dataReady); - connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::eventModified, - this, &EventPluginsManager::eventModified); - connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::eventRemoved, - this, &EventPluginsManager::eventRemoved); + connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::dataReady, this, &EventPluginsManager::dataReady); + connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::eventModified, this, &EventPluginsManager::eventModified); + connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::eventRemoved, this, &EventPluginsManager::eventRemoved); } else { // not our/valid plugin, so unload it loader.unload(); @@ -251,12 +240,12 @@ void EventPluginsManager::loadPlugin(const QString &absolutePath) } } -QList EventPluginsManager::plugins() const +QList EventPluginsManager::plugins() const { return m_plugins; } -QAbstractListModel* EventPluginsManager::pluginsModel() const +QAbstractListModel *EventPluginsManager::pluginsModel() const { return m_model; } diff --git a/src/declarativeimports/calendar/eventpluginsmanager.h b/src/declarativeimports/calendar/eventpluginsmanager.h index fc209acf7..ad4f2736f 100644 --- a/src/declarativeimports/calendar/eventpluginsmanager.h +++ b/src/declarativeimports/calendar/eventpluginsmanager.h @@ -7,11 +7,12 @@ #ifndef EVENTPLUGINSMANAGER_H #define EVENTPLUGINSMANAGER_H -#include #include +#include #include -namespace CalendarEvents { +namespace CalendarEvents +{ class CalendarEventsPlugin; class EventData; } @@ -28,8 +29,8 @@ public: explicit EventPluginsManager(QObject *parent = nullptr); ~EventPluginsManager(); - QList plugins() const; - QAbstractListModel* pluginsModel() const; + QList plugins() const; + QAbstractListModel *pluginsModel() const; // This is a helper function to set which plugins // are enabled without needing to go through setEnabledPlugins @@ -55,7 +56,7 @@ private: friend class EventPluginsModel; EventPluginsModel *m_model = nullptr; - QList m_plugins; + QList m_plugins; struct PluginData { QString name; QString desc; @@ -67,4 +68,3 @@ private: }; #endif - diff --git a/src/declarativeimports/core/colorscope.cpp b/src/declarativeimports/core/colorscope.cpp index 4ab6b5537..9fed90567 100644 --- a/src/declarativeimports/core/colorscope.cpp +++ b/src/declarativeimports/core/colorscope.cpp @@ -8,9 +8,9 @@ #include "colorscope.h" +#include #include #include -#include #include #include @@ -20,11 +20,11 @@ QHash ColorScope::s_attachedScopes = QHash ColorScope::s_theme; ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject) - : QQuickItem(parent), - m_inherit(false), - m_group(Plasma::Theme::NormalColorGroup), - m_parent(parentObject), - m_actualGroup(Plasma::Theme::NormalColorGroup) + : QQuickItem(parent) + , m_inherit(false) + , m_group(Plasma::Theme::NormalColorGroup) + , m_parent(parentObject) + , m_actualGroup(Plasma::Theme::NormalColorGroup) { m_theme = s_theme.toStrongRef(); if (!m_theme) { @@ -38,20 +38,17 @@ ColorScope::ColorScope(QQuickItem *parent, QObject *parentObject) connect(this, &ColorScope::colorGroupChanged, this, &ColorScope::colorsChanged); if (parentObject && qobject_cast(parentObject)) { - connect(static_cast(parentObject), &QQuickItem::windowChanged, - this, [this]() { - findParentScope(); - checkColorGroupChanged(); - }); + connect(static_cast(parentObject), &QQuickItem::windowChanged, this, [this]() { + findParentScope(); + checkColorGroupChanged(); + }); - connect(static_cast(parentObject), &QQuickItem::parentChanged, - this, [this]() { - findParentScope(); - checkColorGroupChanged(); - }); + connect(static_cast(parentObject), &QQuickItem::parentChanged, this, [this]() { + findParentScope(); + checkColorGroupChanged(); + }); } else if (parent) { - connect(parent, &QQuickItem::parentChanged, - this, &ColorScope::checkColorGroupChanged); + connect(parent, &QQuickItem::parentChanged, this, &ColorScope::checkColorGroupChanged); } } @@ -77,21 +74,19 @@ ColorScope *ColorScope::qmlAttachedProperties(QObject *object) return s; } -void ColorScope::setParentScope(ColorScope* parentScope) +void ColorScope::setParentScope(ColorScope *parentScope) { if (parentScope == m_parentScope) return; if (m_parentScope) { - disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged, - this, &ColorScope::checkColorGroupChanged); + disconnect(m_parentScope.data(), &ColorScope::colorGroupChanged, this, &ColorScope::checkColorGroupChanged); } m_parentScope = parentScope; if (parentScope) { - connect(parentScope, &ColorScope::colorGroupChanged, - this, &ColorScope::checkColorGroupChanged); + connect(parentScope, &ColorScope::colorGroupChanged, this, &ColorScope::checkColorGroupChanged); } } @@ -198,7 +193,7 @@ void ColorScope::setInherit(bool inherit) void ColorScope::itemChange(ItemChange change, const ItemChangeData &value) { if (change == QQuickItem::ItemSceneChange) { - //we have a window: create the representations if needed + // we have a window: create the representations if needed if (value.window) { findParentScope(); checkColorGroupChanged(); diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h index edb35cb3a..4b147762e 100644 --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -7,12 +7,12 @@ #ifndef COLORSCOPE_H #define COLORSCOPE_H -#include -#include -#include -#include #include #include +#include +#include +#include +#include class QQuickItem; @@ -61,7 +61,7 @@ class ColorScope : public QQuickItem * Color of foreground objects with a "neutral message" connotation (usually yellow) */ Q_PROPERTY(QColor neutralTextColor READ neutralTextColor NOTIFY colorsChanged) - + /** * Color of foreground objects with a "negative message" connotation (usually red) */ @@ -79,7 +79,7 @@ class ColorScope : public QQuickItem Q_PROPERTY(bool inherit READ inherit WRITE setInherit NOTIFY inheritChanged) public: -/// @cond INTERNAL_DOCS + /// @cond INTERNAL_DOCS explicit ColorScope(QQuickItem *parent = nullptr, QObject *parentObject = nullptr); ~ColorScope() override; @@ -101,7 +101,7 @@ public: ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES static ColorScope *qmlAttachedProperties(QObject *object); -/// @endcond + /// @endcond ColorScope *findParentScope(); void itemChange(ItemChange change, const ItemChangeData &value) override; @@ -113,7 +113,7 @@ Q_SIGNALS: private: void checkColorGroupChanged(); - void setParentScope(ColorScope * parentScope); + void setParentScope(ColorScope *parentScope); bool m_inherit; Plasma::Theme::ColorGroup m_group; @@ -126,7 +126,6 @@ private: static QWeakPointer s_theme; QSharedPointer m_theme; - }; QML_DECLARE_TYPEINFO(ColorScope, QML_HAS_ATTACHED_PROPERTIES) diff --git a/src/declarativeimports/core/corebindingsplugin.cpp b/src/declarativeimports/core/corebindingsplugin.cpp index 78c24fdc9..2a6e19318 100644 --- a/src/declarativeimports/core/corebindingsplugin.cpp +++ b/src/declarativeimports/core/corebindingsplugin.cpp @@ -18,16 +18,16 @@ #include #include -#include "datasource.h" +#include "colorscope.h" #include "datamodel.h" +#include "datasource.h" +#include "dialog.h" #include "framesvgitem.h" +#include "iconitem.h" +#include "quicktheme.h" +#include "serviceoperationstatus.h" #include "svgitem.h" #include "theme.h" -#include "dialog.h" -#include "iconitem.h" -#include "serviceoperationstatus.h" -#include "colorscope.h" -#include "quicktheme.h" #include "tooltip.h" #include "units.h" @@ -63,7 +63,7 @@ void CoreBindingsPlugin::registerTypes(const char *uri) Q_ASSERT(uri == QByteArray("org.kde.plasma.core")); qmlRegisterUncreatableType(uri, 2, 0, "Types", {}); - qmlRegisterSingletonType(uri, 2, 0, "Units", [](QQmlEngine *engine, QJSEngine*) -> QObject* { + qmlRegisterSingletonType(uri, 2, 0, "Units", [](QQmlEngine *engine, QJSEngine *) -> QObject * { engine->setObjectOwnership(&Units::instance(), QQmlEngine::CppOwnership); return &Units::instance(); }); @@ -73,8 +73,10 @@ void CoreBindingsPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 0, "SvgItem"); qmlRegisterType(uri, 2, 0, "FrameSvgItem"); - //qmlRegisterType(uri, 2, 0, "Theme"); - qmlRegisterSingletonType(uri, 2, 0, "Theme", [](QQmlEngine* engine, QJSEngine*) -> QObject* { return new Plasma::QuickTheme(engine); }); + // qmlRegisterType(uri, 2, 0, "Theme"); + qmlRegisterSingletonType(uri, 2, 0, "Theme", [](QQmlEngine *engine, QJSEngine *) -> QObject * { + return new Plasma::QuickTheme(engine); + }); qmlRegisterType(uri, 2, 0, "ColorScope"); qmlRegisterType(uri, 2, 0, "DataSource"); @@ -98,16 +100,16 @@ void CoreBindingsPlugin::registerTypes(const char *uri) // qRegisterMetaType(); // For that also change all usages with those methods to use the fully namespaced type name // in the method signature. -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") + QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") // Do not to port these two for KF5 to // qmlRegisterInterface(uri, 1); // as this will incompatibly register with the fully namespaced name "Plasma::T", // not just the now explicitly passed alias name "T" qmlRegisterInterface("Service"); qmlRegisterInterface("ServiceJob"); -QT_WARNING_POP + QT_WARNING_POP qmlRegisterType(uri, 2, 0, "ServiceOperationStatus"); qmlRegisterAnonymousType(uri, 1); @@ -117,5 +119,3 @@ QT_WARNING_POP qmlRegisterType(uri, 2, 0, "WindowThumbnail"); } - - diff --git a/src/declarativeimports/core/datamodel.cpp b/src/declarativeimports/core/datamodel.cpp index 521a2ae5e..f818e70f6 100644 --- a/src/declarativeimports/core/datamodel.cpp +++ b/src/declarativeimports/core/datamodel.cpp @@ -13,19 +13,15 @@ namespace Plasma { - SortFilterModel::SortFilterModel(QObject *parent) : QSortFilterProxyModel(parent) { setObjectName(QStringLiteral("SortFilterModel")); setDynamicSortFilter(true); - connect(this, &QAbstractItemModel::rowsInserted, - this, &SortFilterModel::countChanged); - connect(this, &QAbstractItemModel::rowsRemoved, - this, &SortFilterModel::countChanged); - connect(this, &QAbstractItemModel::modelReset, - this, &SortFilterModel::countChanged); - connect(this, &SortFilterModel::countChanged, this, &SortFilterModel::syncRoleNames); + connect(this, &QAbstractItemModel::rowsInserted, this, &SortFilterModel::countChanged); + connect(this, &QAbstractItemModel::rowsRemoved, this, &SortFilterModel::countChanged); + connect(this, &QAbstractItemModel::modelReset, this, &SortFilterModel::countChanged); + connect(this, &SortFilterModel::countChanged, this, &SortFilterModel::syncRoleNames); } SortFilterModel::~SortFilterModel() @@ -49,10 +45,10 @@ void SortFilterModel::syncRoleNames() setSortRole(m_sortRole); } -QHash SortFilterModel::roleNames() const +QHash SortFilterModel::roleNames() const { if (sourceModel()) { - return sourceModel()->roleNames(); + return sourceModel()->roleNames(); } return {}; } @@ -82,7 +78,7 @@ void SortFilterModel::setModel(QAbstractItemModel *model) Q_EMIT sourceModelChanged(model); } -bool SortFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const +bool SortFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if (m_filterCallback.isCallable()) { QJSValueList args; @@ -132,7 +128,7 @@ QJSValue SortFilterModel::filterCallback() const return m_filterCallback; } -void SortFilterModel::setFilterCallback(const QJSValue& callback) +void SortFilterModel::setFilterCallback(const QJSValue &callback) { if (m_filterCallback.strictlyEquals(callback)) { return; @@ -222,22 +218,19 @@ int SortFilterModel::mapRowFromSource(int row) const } DataModel::DataModel(QObject *parent) - : QAbstractItemModel(parent), - m_dataSource(nullptr), - m_maxRoleId(Qt::UserRole + 1) + : QAbstractItemModel(parent) + , m_dataSource(nullptr) + , m_maxRoleId(Qt::UserRole + 1) { - //There is one reserved role name: DataEngineSource + // There is one reserved role name: DataEngineSource m_roleNames[m_maxRoleId] = QByteArrayLiteral("DataEngineSource"); m_roleIds[QStringLiteral("DataEngineSource")] = m_maxRoleId; ++m_maxRoleId; setObjectName(QStringLiteral("DataModel")); - connect(this, &QAbstractItemModel::rowsInserted, - this, &DataModel::countChanged); - connect(this, &QAbstractItemModel::rowsRemoved, - this, &DataModel::countChanged); - connect(this, &QAbstractItemModel::modelReset, - this, &DataModel::countChanged); + connect(this, &QAbstractItemModel::rowsInserted, this, &DataModel::countChanged); + connect(this, &QAbstractItemModel::rowsRemoved, this, &DataModel::countChanged); + connect(this, &QAbstractItemModel::modelReset, this, &DataModel::countChanged); } DataModel::~DataModel() @@ -251,7 +244,7 @@ void DataModel::dataUpdated(const QString &sourceName, const QVariantMap &data) } if (m_keyRoleFilter.isEmpty()) { - //an item is represented by a source: keys are roles m_roleLevel == FirstLevel + // an item is represented by a source: keys are roles m_roleLevel == FirstLevel QVariantList list; if (!m_dataSource->data()->isEmpty()) { @@ -270,12 +263,11 @@ void DataModel::dataUpdated(const QString &sourceName, const QVariantMap &data) } setItems(QString(), list); } else { - //a key that matches the one we want exists and is a list of DataEngine::Data - if (data.contains(m_keyRoleFilter) && - data.value(m_keyRoleFilter).canConvert()) { + // a key that matches the one we want exists and is a list of DataEngine::Data + if (data.contains(m_keyRoleFilter) && data.value(m_keyRoleFilter).canConvert()) { setItems(sourceName, data.value(m_keyRoleFilter).value()); } else if (m_keyRoleFilterRE.isValid()) { - //try to match the key we want with a regular expression if set + // try to match the key we want with a regular expression if set QVariantList list; QVariantMap::const_iterator i; for (i = data.constBegin(); i != data.constEnd(); ++i) { @@ -310,12 +302,9 @@ void DataModel::setDataSource(QObject *object) dataUpdated(key, m_dataSource->data()->value(key).value()); } - connect(m_dataSource, &DataSource::newData, - this, &DataModel::dataUpdated); - connect(m_dataSource, &DataSource::sourceRemoved, - this, &DataModel::removeSource); - connect(m_dataSource, &DataSource::sourceDisconnected, - this, &DataModel::removeSource); + connect(m_dataSource, &DataSource::newData, this, &DataModel::dataUpdated); + connect(m_dataSource, &DataSource::sourceRemoved, this, &DataModel::removeSource); + connect(m_dataSource, &DataSource::sourceDisconnected, this, &DataModel::removeSource); } QObject *DataModel::dataSource() const @@ -373,18 +362,18 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list) const int delta = list.length() - oldLength; const bool firstRun = m_items.isEmpty(); - //At what row number the first item associated to this source starts + // At what row number the first item associated to this source starts int sourceIndex = 0; - QMap >::const_iterator i; + QMap>::const_iterator i; for (i = m_items.constBegin(); i != m_items.constEnd(); ++i) { if (i.key() == sourceName) { break; } sourceIndex += i.value().count(); } - //signal as inserted the rows at the end, all the other rows will signal a dataupdated. - //better than a model reset because doesn't cause deletion and re-creation of every list item on a qml ListView, repeaters etc. - //the first run it gets reset because otherwise setRoleNames gets broken + // signal as inserted the rows at the end, all the other rows will signal a dataupdated. + // better than a model reset because doesn't cause deletion and re-creation of every list item on a qml ListView, repeaters etc. + // the first run it gets reset because otherwise setRoleNames gets broken if (firstRun) { beginResetModel(); } else if (delta > 0) { @@ -392,7 +381,7 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list) } else if (delta < 0) { beginRemoveRows(QModelIndex(), sourceIndex + list.length(), sourceIndex + oldLength - 1); } - //convert to vector, so data() will be O(1) + // convert to vector, so data() will be O(1) m_items[sourceName] = list.toVector(); if (!list.isEmpty()) { @@ -434,8 +423,7 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list) } else if (delta < 0) { endRemoveRows(); } - Q_EMIT dataChanged(createIndex(sourceIndex, 0), - createIndex(sourceIndex + qMin(list.length(), oldLength), 0)); + Q_EMIT dataChanged(createIndex(sourceIndex, 0), createIndex(sourceIndex + qMin(list.length(), oldLength), 0)); } QHash DataModel::roleNames() const @@ -445,10 +433,10 @@ QHash DataModel::roleNames() const void DataModel::removeSource(const QString &sourceName) { - //FIXME: find a way to remove only the proper things also in the case where sources are items + // FIXME: find a way to remove only the proper things also in the case where sources are items if (m_keyRoleFilter.isEmpty()) { - //source name in the map, linear scan + // source name in the map, linear scan for (int i = 0; i < m_items.value(QString()).count(); ++i) { if (m_items.value(QString())[i].value().value(QStringLiteral("DataEngineSource")) == sourceName) { beginRemoveRows(QModelIndex(), i, i); @@ -459,7 +447,7 @@ void DataModel::removeSource(const QString &sourceName) } } else { if (m_items.contains(sourceName)) { - //At what row number the first item associated to this source starts + // At what row number the first item associated to this source starts int sourceIndex = 0; for (auto i = m_items.constBegin(); i != m_items.constEnd(); ++i) { if (i.key() == sourceName) { @@ -468,7 +456,7 @@ void DataModel::removeSource(const QString &sourceName) sourceIndex += i.value().count(); } - //source name as key of the map + // source name as key of the map int count = m_items.value(sourceName).count(); if (count > 0) { @@ -484,15 +472,14 @@ void DataModel::removeSource(const QString &sourceName) QVariant DataModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.column() > 0 || - index.row() < 0 || index.row() >= countItems()) { + if (!index.isValid() || index.column() > 0 || index.row() < 0 || index.row() >= countItems()) { return QVariant(); } int count = 0; int actualRow = 0; QString source; - QMap >::const_iterator i; + QMap>::const_iterator i; for (i = m_items.constBegin(); i != m_items.constEnd(); ++i) { const int oldCount = count; count += i.value().count(); @@ -504,8 +491,8 @@ QVariant DataModel::data(const QModelIndex &index, int role) const } } - //is it the reserved role: DataEngineSource ? - //also, if each source is an item DataEngineSource is a role between all the others, otherwise we know it from the role variable + // is it the reserved role: DataEngineSource ? + // also, if each source is an item DataEngineSource is a role between all the others, otherwise we know it from the role variable if (!m_keyRoleFilter.isEmpty() && m_roleNames.value(role) == "DataEngineSource") { return source; } else { @@ -540,8 +527,8 @@ QModelIndex DataModel::parent(const QModelIndex &child) const int DataModel::rowCount(const QModelIndex &parent) const { - //this is not a tree - //TODO: make it possible some day? + // this is not a tree + // TODO: make it possible some day? if (parent.isValid()) { return 0; } @@ -572,4 +559,3 @@ QVariantMap DataModel::get(int row) const } } - diff --git a/src/declarativeimports/core/datamodel.h b/src/declarativeimports/core/datamodel.h index b12d4ae02..f9d0f7371 100644 --- a/src/declarativeimports/core/datamodel.h +++ b/src/declarativeimports/core/datamodel.h @@ -18,7 +18,6 @@ class QTimer; namespace Plasma { - class DataSource; class DataModel; @@ -134,7 +133,7 @@ Q_SIGNALS: protected: int roleNameToId(const QString &name) const; - bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; QHash roleNames() const override; protected Q_SLOTS: @@ -167,8 +166,8 @@ class DataModel : public QAbstractItemModel Q_PROPERTY(QString keyRoleFilter READ keyRoleFilter WRITE setKeyRoleFilter) /** - * it's a regular expression. If the DataSource is connected to more than one source, only inserts data from sources matching this filter expression in the model. - * If we want to have a source watch all sources beginning with say "name:", the required regexp would be sourceFilter: "name:.*" + * it's a regular expression. If the DataSource is connected to more than one source, only inserts data from sources matching this filter expression in the + * model. If we want to have a source watch all sources beginning with say "name:", the required regexp would be sourceFilter: "name:.*" */ Q_PROPERTY(QString sourceFilter READ sourceFilter WRITE setSourceFilter) @@ -196,12 +195,10 @@ public: void setSourceFilter(const QString &key); QString sourceFilter() const; - //Reimplemented + // Reimplemented QVariant data(const QModelIndex &index, int role) const override; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const override; - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &child) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; @@ -239,7 +236,7 @@ private: QRegExp m_keyRoleFilterRE; QString m_sourceFilter; QRegExp m_sourceFilterRE; - QMap > m_items; + QMap> m_items; QHash m_roleNames; QHash m_roleIds; int m_maxRoleId; diff --git a/src/declarativeimports/core/datasource.cpp b/src/declarativeimports/core/datasource.cpp index f6a9c3363..50c7a0a87 100644 --- a/src/declarativeimports/core/datasource.cpp +++ b/src/declarativeimports/core/datasource.cpp @@ -12,10 +12,10 @@ namespace Plasma { DataSource::DataSource(QObject *parent) - : QObject(parent), - m_ready(false), - m_interval(0), - m_intervalAlignment(Plasma::Types::NoAlignment) + : QObject(parent) + , m_ready(false) + , m_interval(0) + , m_intervalAlignment(Plasma::Types::NoAlignment) { m_models = new QQmlPropertyMap(this); m_data = new QQmlPropertyMap(this); @@ -24,7 +24,6 @@ DataSource::DataSource(QObject *parent) void DataSource::classBegin() { - } void DataSource::componentComplete() @@ -143,8 +142,8 @@ void DataSource::setupData() return; } -// qDebug() << " loading engine " << m_engine; - //FIXME: should all services be deleted just because we're changing the interval, etc? + // qDebug() << " loading engine " << m_engine; + // FIXME: should all services be deleted just because we're changing the interval, etc? qDeleteAll(m_services); m_services.clear(); @@ -156,7 +155,7 @@ void DataSource::setupData() void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data) { - //it can arrive also data we don't explicitly connected a source + // it can arrive also data we don't explicitly connected a source if (m_connectedSources.contains(sourceName)) { m_data->insert(sourceName, data); Q_EMIT dataChanged(); @@ -174,8 +173,8 @@ void DataSource::modelChanged(const QString &sourceName, QAbstractItemModel *mod } m_models->insert(sourceName, QVariant::fromValue(model)); - //FIXME: this will break in the case a second model is set - connect(model, &QObject::destroyed, m_models, [ = ]() { + // FIXME: this will break in the case a second model is set + connect(model, &QObject::destroyed, m_models, [=]() { m_models->clear(sourceName); }); } @@ -185,7 +184,7 @@ void DataSource::removeSource(const QString &source) m_data->clear(source); m_models->clear(source); - //TODO: emit those signals as last thing + // TODO: emit those signals as last thing if (m_connectedSources.contains(source)) { m_connectedSources.removeAll(source); Q_EMIT sourceDisconnected(source); diff --git a/src/declarativeimports/core/datasource.h b/src/declarativeimports/core/datasource.h index e40f4ccbd..5103ab0fe 100644 --- a/src/declarativeimports/core/datasource.h +++ b/src/declarativeimports/core/datasource.h @@ -11,13 +11,13 @@ #define DATASOURCE_H #include +#include +#include #include #include -#include -#include -#include #include +#include class QQmlPropertyMap; @@ -124,7 +124,7 @@ public: * The user has to be connected to its source, so the source name has to be present in the connectedSources property. */ Q_PROPERTY(QQmlPropertyMap *models READ models CONSTANT) - QQmlPropertyMap *models() const + QQmlPropertyMap *models() const { return m_models; } diff --git a/src/declarativeimports/core/fadingnode.cpp b/src/declarativeimports/core/fadingnode.cpp index 774972654..b8dea898f 100644 --- a/src/declarativeimports/core/fadingnode.cpp +++ b/src/declarativeimports/core/fadingnode.cpp @@ -6,15 +6,14 @@ #include "fadingnode_p.h" -#include #include #include +#include -struct FadingMaterialState -{ - QSGTexture *source = nullptr; - QSGTexture *target = nullptr; - qreal progress; +struct FadingMaterialState { + QSGTexture *source = nullptr; + QSGTexture *target = nullptr; + qreal progress; }; class FadingMaterialShader : public QSGSimpleMaterialShader @@ -23,18 +22,18 @@ class FadingMaterialShader : public QSGSimpleMaterialShader public: FadingMaterialShader(); using QSGSimpleMaterialShader::updateState; - void updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState) override; + void updateState(const FadingMaterialState *newState, const FadingMaterialState *oldState) override; QList attributes() const override; void initialize() override; + private: - QOpenGLFunctions *glFuncs = nullptr; + QOpenGLFunctions *glFuncs = nullptr; int m_progressId = 0; int m_sourceRectId = 0; int m_targetRectId = 0; }; - FadingMaterialShader::FadingMaterialShader() { setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/plasma-framework/shaders/fadingmaterial.frag")); @@ -46,7 +45,7 @@ QList FadingMaterialShader::attributes() const return {QByteArrayLiteral("qt_Vertex"), QByteArrayLiteral("qt_MultiTexCoord0")}; } -void FadingMaterialShader::updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState) +void FadingMaterialShader::updateState(const FadingMaterialState *newState, const FadingMaterialState *oldState) { if (!oldState || oldState->source != newState->source) { glFuncs->glActiveTexture(GL_TEXTURE0); @@ -65,7 +64,7 @@ void FadingMaterialShader::updateState(const FadingMaterialState* newState, cons } if (!oldState || oldState->progress != newState->progress) { - program()->setUniformValue(m_progressId, (GLfloat) newState->progress); + program()->setUniformValue(m_progressId, (GLfloat)newState->progress); } } @@ -75,7 +74,7 @@ void FadingMaterialShader::initialize() // shader not linked, exit otherwise we crash, BUG: 336272 return; } - QSGSimpleMaterialShader< FadingMaterialState >::initialize(); + QSGSimpleMaterialShader::initialize(); glFuncs = QOpenGLContext::currentContext()->functions(); program()->bind(); program()->setUniformValue("u_src", 0); @@ -86,10 +85,9 @@ void FadingMaterialShader::initialize() m_targetRectId = program()->uniformLocation("u_target_rect"); } - -FadingNode::FadingNode(QSGTexture *source, QSGTexture *target): - m_source(source), - m_target(target) +FadingNode::FadingNode(QSGTexture *source, QSGTexture *target) + : m_source(source) + , m_target(target) { QSGSimpleMaterial *m = FadingMaterialShader::createMaterial(); m->setFlag(QSGMaterial::Blending); @@ -115,7 +113,7 @@ void FadingNode::setRect(const QRectF &bounds) void FadingNode::setProgress(qreal progress) { - QSGSimpleMaterial *m = static_cast*>(material()); + QSGSimpleMaterial *m = static_cast *>(material()); m->state()->source = m_source.data(); m->state()->target = m_target.data(); m->state()->progress = progress; diff --git a/src/declarativeimports/core/fadingnode_p.h b/src/declarativeimports/core/fadingnode_p.h index fed26cad1..09bed077e 100644 --- a/src/declarativeimports/core/fadingnode_p.h +++ b/src/declarativeimports/core/fadingnode_p.h @@ -7,9 +7,9 @@ #ifndef FADINGNODE_H #define FADINGNODE_H +#include #include #include -#include /** * This node fades between two textures using a shader @@ -29,6 +29,7 @@ public: */ void setProgress(qreal progress); void setRect(const QRectF &bounds); + private: QScopedPointer m_source; QScopedPointer m_target; diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index e68658d35..22f1df6ab 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -8,29 +8,28 @@ #include "framesvgitem.h" #include -#include #include +#include #include #include -#include #include +#include -#include #include +#include #include //floor() namespace Plasma { - Q_GLOBAL_STATIC(ImageTexturesCache, s_cache) class FrameNode : public QSGNode { public: - FrameNode(const QString& prefix, FrameSvg* svg) + FrameNode(const QString &prefix, FrameSvg *svg) : QSGNode() , leftWidth(0) , rightWidth(0) @@ -47,9 +46,9 @@ public: bottomHeight = svg->elementSize(prefix % QLatin1String("bottom")).height(); } - QRect contentsRect(const QSize& size) const + QRect contentsRect(const QSize &size) const { - const QSize contentSize(size.width() - leftWidth - rightWidth, size.height() - topHeight - bottomHeight); + const QSize contentSize(size.width() - leftWidth - rightWidth, size.height() - topHeight - bottomHeight); return QRect(QPoint(leftWidth, topHeight), contentSize); } @@ -65,14 +64,14 @@ class FrameItemNode : public ManagedTextureNode { public: enum FitMode { - //render SVG at native resolution then stretch it in openGL + // render SVG at native resolution then stretch it in openGL FastStretch, - //on resize re-render the part of the frame from the SVG + // on resize re-render the part of the frame from the SVG Stretch, Tile, }; - FrameItemNode(FrameSvgItem* frameSvg, FrameSvg::EnabledBorders borders, FitMode fitMode, QSGNode* parent) + FrameItemNode(FrameSvgItem *frameSvg, FrameSvg::EnabledBorders borders, FitMode fitMode, QSGNode *parent) : ManagedTextureNode() , m_frameSvg(frameSvg) , m_border(borders) @@ -83,12 +82,12 @@ public: if (m_fitMode == Tile) { if (m_border == FrameSvg::TopBorder || m_border == FrameSvg::BottomBorder || m_border == FrameSvg::NoBorder) { - static_cast(material())->setHorizontalWrapMode(QSGTexture::Repeat); - static_cast(opaqueMaterial())->setHorizontalWrapMode(QSGTexture::Repeat); + static_cast(material())->setHorizontalWrapMode(QSGTexture::Repeat); + static_cast(opaqueMaterial())->setHorizontalWrapMode(QSGTexture::Repeat); } if (m_border == FrameSvg::LeftBorder || m_border == FrameSvg::RightBorder || m_border == FrameSvg::NoBorder) { - static_cast(material())->setVerticalWrapMode(QSGTexture::Repeat); - static_cast(opaqueMaterial())->setVerticalWrapMode(QSGTexture::Repeat); + static_cast(material())->setVerticalWrapMode(QSGTexture::Repeat); + static_cast(opaqueMaterial())->setVerticalWrapMode(QSGTexture::Repeat); } } @@ -97,8 +96,8 @@ public: m_elementNativeSize = m_frameSvg->frameSvg()->elementSize(elementId); if (m_elementNativeSize.isEmpty()) { - //if the default element is empty, we can avoid the slower tiling path - //this also avoids a divide by 0 error + // if the default element is empty, we can avoid the slower tiling path + // this also avoids a divide by 0 error m_fitMode = FastStretch; } @@ -115,37 +114,37 @@ public: setTexture(s_cache->loadTexture(m_frameSvg->window(), m_frameSvg->frameSvg()->image(size, elementId), options)); } - void reposition(const QRect& frameGeometry, QSize& fullSize) + void reposition(const QRect &frameGeometry, QSize &fullSize) { QRect nodeRect = FrameSvgHelpers::sectionRect(m_border, frameGeometry, fullSize); - //ensure we're not passing a weird rectangle to updateTexturedRectGeometry - if(!nodeRect.isValid() || nodeRect.isEmpty()) + // ensure we're not passing a weird rectangle to updateTexturedRectGeometry + if (!nodeRect.isValid() || nodeRect.isEmpty()) nodeRect = QRect(); - //the position of the relevant texture within this texture ID. - //for atlas' this will only be a small part of the texture + // the position of the relevant texture within this texture ID. + // for atlas' this will only be a small part of the texture QRectF textureRect; if (m_fitMode == Tile) { - textureRect = QRectF(0,0,1,1); //we can never be in an atlas for tiled images. + textureRect = QRectF(0, 0, 1, 1); // we can never be in an atlas for tiled images. - //if tiling horizontally + // if tiling horizontally if (m_border == FrameSvg::TopBorder || m_border == FrameSvg::BottomBorder || m_border == FrameSvg::NoBorder) { // cmp. CSS3's border-image-repeat: "repeat", though with first tile not centered, but aligned to left - textureRect.setWidth((qreal) nodeRect.width() / m_elementNativeSize.width()); + textureRect.setWidth((qreal)nodeRect.width() / m_elementNativeSize.width()); } - //if tiling vertically + // if tiling vertically if (m_border == FrameSvg::LeftBorder || m_border == FrameSvg::RightBorder || m_border == FrameSvg::NoBorder) { // cmp. CSS3's border-image-repeat: "repeat", though with first tile not centered, but aligned to top - textureRect.setHeight((qreal) nodeRect.height() / m_elementNativeSize.height()); + textureRect.setHeight((qreal)nodeRect.height() / m_elementNativeSize.height()); } } else if (m_fitMode == Stretch) { QString prefix = m_frameSvg->frameSvg()->actualPrefix(); QString elementId = prefix + FrameSvgHelpers::borderToElementId(m_border); - //re-render the SVG at new size + // re-render the SVG at new size updateTexture(nodeRect.size(), elementId); textureRect = texture()->normalizedTextureSubRect(); } else if (texture()) { // for fast stretch. @@ -157,7 +156,7 @@ public: } private: - FrameSvgItem* m_frameSvg; + FrameSvgItem *m_frameSvg; FrameSvg::EnabledBorders m_border; QSGNode *m_lastParent; QSize m_elementNativeSize; @@ -165,19 +164,19 @@ private: }; FrameSvgItemMargins::FrameSvgItemMargins(Plasma::FrameSvg *frameSvg, QObject *parent) - : QObject(parent), - m_frameSvg(frameSvg), - m_fixed(false), - m_inset(false) + : QObject(parent) + , m_frameSvg(frameSvg) + , m_fixed(false) + , m_inset(false) { - //qDebug() << "margins at: " << left() << top() << right() << bottom(); + // qDebug() << "margins at: " << left() << top() << right() << bottom(); } qreal FrameSvgItemMargins::left() const { if (m_fixed) { return m_frameSvg->fixedMarginSize(Types::LeftMargin); - } else if(m_inset){ + } else if (m_inset) { return m_frameSvg->insetSize(Types::LeftMargin); } else { return m_frameSvg->marginSize(Types::LeftMargin); @@ -188,7 +187,7 @@ qreal FrameSvgItemMargins::top() const { if (m_fixed) { return m_frameSvg->fixedMarginSize(Types::TopMargin); - } else if(m_inset){ + } else if (m_inset) { return m_frameSvg->insetSize(Types::TopMargin); } else { return m_frameSvg->marginSize(Types::TopMargin); @@ -199,7 +198,7 @@ qreal FrameSvgItemMargins::right() const { if (m_fixed) { return m_frameSvg->fixedMarginSize(Types::RightMargin); - } else if(m_inset){ + } else if (m_inset) { return m_frameSvg->insetSize(Types::RightMargin); } else { return m_frameSvg->marginSize(Types::RightMargin); @@ -210,7 +209,7 @@ qreal FrameSvgItemMargins::bottom() const { if (m_fixed) { return m_frameSvg->fixedMarginSize(Types::BottomMargin); - } else if(m_inset){ + } else if (m_inset) { return m_frameSvg->insetSize(Types::BottomMargin); } else { return m_frameSvg->marginSize(Types::BottomMargin); @@ -270,13 +269,13 @@ bool FrameSvgItemMargins::isInset() const } FrameSvgItem::FrameSvgItem(QQuickItem *parent) - : QQuickItem(parent), - m_margins(nullptr), - m_fixedMargins(nullptr), - m_insetMargins(nullptr), - m_textureChanged(false), - m_sizeChanged(false), - m_fastPath(true) + : QQuickItem(parent) + , m_margins(nullptr) + , m_fixedMargins(nullptr) + , m_insetMargins(nullptr) + , m_textureChanged(false) + , m_sizeChanged(false) + , m_fastPath(true) { m_frameSvg = new Plasma::FrameSvg(this); setFlag(ItemHasContents, true); @@ -293,9 +292,11 @@ FrameSvgItem::~FrameSvgItem() class CheckMarginsChange { public: - CheckMarginsChange(QVector& oldMargins, FrameSvgItemMargins *marginsObject) - : m_oldMargins(oldMargins), m_marginsObject(marginsObject) - {} + CheckMarginsChange(QVector &oldMargins, FrameSvgItemMargins *marginsObject) + : m_oldMargins(oldMargins) + , m_marginsObject(marginsObject) + { + } ~CheckMarginsChange() { @@ -308,7 +309,7 @@ public: } private: - QVector& m_oldMargins; + QVector &m_oldMargins; FrameSvgItemMargins *const m_marginsObject; }; @@ -352,7 +353,7 @@ QString FrameSvgItem::imagePath() const void FrameSvgItem::setPrefix(const QVariant &prefixes) { QStringList prefixList; - //is this a simple string? + // is this a simple string? if (prefixes.canConvert()) { prefixList << prefixes.toString(); } else if (prefixes.canConvert()) { @@ -478,14 +479,12 @@ bool FrameSvgItem::hasElementPrefix(const QString &prefix) const return m_frameSvg->hasElementPrefix(prefix); } - QRegion FrameSvgItem::mask() const { return m_frameSvg->mask(); } -void FrameSvgItem::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) +void FrameSvgItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { const bool isComponentComplete = this->isComponentComplete(); if (isComponentComplete) { @@ -512,7 +511,7 @@ void FrameSvgItem::doUpdate() CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); CheckMarginsChange checkInsetMargins(m_oldInsetMargins, m_insetMargins); - //if the theme changed, the available prefix may have changed as well + // if the theme changed, the available prefix may have changed as well applyPrefixes(); if (implicitWidth() <= 0) { @@ -525,12 +524,12 @@ void FrameSvgItem::doUpdate() QString prefix = m_frameSvg->actualPrefix(); bool hasOverlay = !prefix.startsWith(QLatin1String("mask-")) && m_frameSvg->hasElement(prefix % QLatin1String("overlay")); - bool hasComposeOverBorder = m_frameSvg->hasElement(prefix % QLatin1String("hint-compose-over-border")) && - m_frameSvg->hasElement(QLatin1String("mask-") % prefix % QLatin1String("center")); + bool hasComposeOverBorder = m_frameSvg->hasElement(prefix % QLatin1String("hint-compose-over-border")) + && m_frameSvg->hasElement(QLatin1String("mask-") % prefix % QLatin1String("center")); m_fastPath = !hasOverlay && !hasComposeOverBorder; - //software rendering (at time of writing Qt5.10) doesn't seem to like our tiling/stretching in the 9-tiles. - //also when using QPainter it's arguably faster to create and cache pixmaps of the whole frame, which is what the slow path does + // software rendering (at time of writing Qt5.10) doesn't seem to like our tiling/stretching in the 9-tiles. + // also when using QPainter it's arguably faster to create and cache pixmaps of the whole frame, which is what the slow path does if (QQuickWindow::sceneGraphBackend() == QLatin1String("software")) { m_fastPath = false; } @@ -549,8 +548,7 @@ Plasma::FrameSvg *FrameSvgItem::frameSvg() const QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) { - if (!window() || !m_frameSvg || - (!m_frameSvg->hasElementPrefix(m_frameSvg->actualPrefix()) && !m_frameSvg->hasElementPrefix(m_frameSvg->prefix()))) { + if (!window() || !m_frameSvg || (!m_frameSvg->hasElementPrefix(m_frameSvg->actualPrefix()) && !m_frameSvg->hasElementPrefix(m_frameSvg->prefix()))) { delete oldNode; return nullptr; } @@ -567,12 +565,12 @@ QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaint QString prefix = m_frameSvg->actualPrefix(); oldNode = new FrameNode(prefix, m_frameSvg); - bool tileCenter = (m_frameSvg->hasElement(QStringLiteral("hint-tile-center")) - || m_frameSvg->hasElement(prefix % QLatin1String("hint-tile-center"))); - bool stretchBorders = (m_frameSvg->hasElement(QStringLiteral("hint-stretch-borders")) - || m_frameSvg->hasElement(prefix % QLatin1String("hint-stretch-borders"))); + bool tileCenter = + (m_frameSvg->hasElement(QStringLiteral("hint-tile-center")) || m_frameSvg->hasElement(prefix % QLatin1String("hint-tile-center"))); + bool stretchBorders = + (m_frameSvg->hasElement(QStringLiteral("hint-stretch-borders")) || m_frameSvg->hasElement(prefix % QLatin1String("hint-stretch-borders"))); FrameItemNode::FitMode borderFitMode = stretchBorders ? FrameItemNode::Stretch : FrameItemNode::Tile; - FrameItemNode::FitMode centerFitMode = tileCenter ? FrameItemNode::Tile: FrameItemNode::Stretch; + FrameItemNode::FitMode centerFitMode = tileCenter ? FrameItemNode::Tile : FrameItemNode::Stretch; new FrameItemNode(this, FrameSvg::NoBorder, centerFitMode, oldNode); if (enabledBorders() & (FrameSvg::TopBorder | FrameSvg::LeftBorder)) { @@ -594,7 +592,7 @@ QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaint new FrameItemNode(this, FrameSvg::BottomBorder | FrameSvg::RightBorder, FrameItemNode::FastStretch, oldNode); } if (enabledBorders() & FrameSvg::LeftBorder) { - new FrameItemNode(this, FrameSvg::LeftBorder, borderFitMode, oldNode); + new FrameItemNode(this, FrameSvg::LeftBorder, borderFitMode, oldNode); } if (enabledBorders() & FrameSvg::RightBorder) { new FrameItemNode(this, FrameSvg::RightBorder, borderFitMode, oldNode); @@ -611,7 +609,7 @@ QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaint } if (m_sizeChanged) { - FrameNode* frameNode = static_cast(oldNode); + FrameNode *frameNode = static_cast(oldNode); QSize frameSize(width(), height()); QRect geometry = frameNode->contentsRect(frameSize); QSGNode *node = oldNode->firstChild(); @@ -627,7 +625,7 @@ QSGNode *FrameSvgItem::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaint if (!textureNode) { delete oldNode; textureNode = new ManagedTextureNode; - m_textureChanged = true; //force updating the texture on our newly created node + m_textureChanged = true; // force updating the texture on our newly created node oldNode = textureNode; } textureNode->setFiltering(filtering); @@ -667,7 +665,7 @@ void FrameSvgItem::updateDevicePixelRatio() { m_frameSvg->setScaleFactor(qMax(1.0, floor(Units::instance().devicePixelRatio()))); - //devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. + // devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned) const auto newDevicePixelRation = qMax(1.0, floor(window() ? window()->devicePixelRatio() : qApp->devicePixelRatio())); @@ -679,7 +677,6 @@ void FrameSvgItem::updateDevicePixelRatio() void FrameSvgItem::applyPrefixes() { - if (m_frameSvg->imagePath().isEmpty()) { return; } @@ -703,7 +700,7 @@ void FrameSvgItem::applyPrefixes() } } if (!found) { - //this setElementPrefix is done to keep the same behavior as before, when it was a simple string + // this setElementPrefix is done to keep the same behavior as before, when it was a simple string m_frameSvg->setElementPrefix(m_prefixes.constLast()); } if (oldPrefix != m_frameSvg->prefix()) { @@ -711,7 +708,7 @@ void FrameSvgItem::applyPrefixes() } } -void FrameSvgItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData & value) +void FrameSvgItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) { if (change == ItemSceneChange && value.window) { updateDevicePixelRatio(); @@ -721,4 +718,3 @@ void FrameSvgItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::I } } // Plasma namespace - diff --git a/src/declarativeimports/core/framesvgitem.h b/src/declarativeimports/core/framesvgitem.h index 2c2f1b67f..f4c2bb527 100644 --- a/src/declarativeimports/core/framesvgitem.h +++ b/src/declarativeimports/core/framesvgitem.h @@ -7,8 +7,8 @@ #ifndef FRAMESVGITEM_P #define FRAMESVGITEM_P -#include #include +#include #include @@ -16,7 +16,6 @@ namespace Plasma { - class FrameSvg; /** @@ -58,7 +57,6 @@ class FrameSvgItemMargins : public QObject */ Q_PROPERTY(qreal vertical READ vertical NOTIFY marginsChanged) - public: FrameSvgItemMargins(Plasma::FrameSvg *frameSvg, QObject *parent = nullptr); @@ -90,7 +88,6 @@ private: bool m_inset; }; - /** * @class FrameSvgItem * @@ -222,8 +219,7 @@ public: void setStatus(Plasma::Svg::Status status); Plasma::Svg::Status status() const; - void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; QRegion mask() const; @@ -234,13 +230,13 @@ public: QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; - void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData & data) override; + void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override; protected: void classBegin() override; void componentComplete() override; -/// @endcond + /// @endcond Q_SIGNALS: void imagePathChanged(); diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index abfa53706..13693991b 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -11,23 +11,28 @@ #include #include #include -#include #include +#include -#include #include +#include #include #include "fadingnode_p.h" -#include #include "theme.h" #include "units.h" +#include class IconItemSource { public: - explicit IconItemSource(IconItem *iconItem) : m_iconItem(iconItem) {} - virtual ~IconItemSource() {} + explicit IconItemSource(IconItem *iconItem) + : m_iconItem(iconItem) + { + } + virtual ~IconItemSource() + { + } virtual bool isValid() const = 0; virtual const QSize size() const = 0; @@ -45,7 +50,10 @@ protected: class NullSource : public IconItemSource { public: - explicit NullSource(IconItem *iconItem) : IconItemSource(iconItem) {} + explicit NullSource(IconItem *iconItem) + : IconItemSource(iconItem) + { + } bool isValid() const override { @@ -67,7 +75,8 @@ public: class QIconSource : public IconItemSource { public: - explicit QIconSource(const QIcon &icon, IconItem *iconItem) : IconItemSource(iconItem) + explicit QIconSource(const QIcon &icon, IconItem *iconItem) + : IconItemSource(iconItem) { m_icon = icon; } @@ -97,7 +106,8 @@ private: class QImageSource : public IconItemSource { public: - explicit QImageSource(const QImage &imageIcon, IconItem *iconItem) : IconItemSource(iconItem) + explicit QImageSource(const QImage &imageIcon, IconItem *iconItem) + : IconItemSource(iconItem) { m_imageIcon = imageIcon; } @@ -130,7 +140,8 @@ private: class SvgSource : public IconItemSource { public: - explicit SvgSource(const QString &sourceString, IconItem* iconItem) : IconItemSource(iconItem) + explicit SvgSource(const QString &sourceString, IconItem *iconItem) + : IconItemSource(iconItem) { m_svgIcon = new Plasma::Svg(iconItem); m_svgIcon->setColorGroup(iconItem->colorGroup()); @@ -149,17 +160,17 @@ public: }); if (iconItem->usesPlasmaTheme()) { - //try as a svg icon from plasma theme + // try as a svg icon from plasma theme m_svgIcon->setImagePath(QLatin1String("icons/") + sourceString.section(QLatin1Char('-'), 0, 0)); m_svgIcon->setContainsMultipleImages(true); } - //success? + // success? if (iconItem->usesPlasmaTheme() && m_svgIcon->isValid() && m_svgIcon->hasElement(sourceString)) { m_svgIconName = sourceString; - //ok, svg not available from the plasma theme + // ok, svg not available from the plasma theme } else { - //try to load from iconloader an svg with Plasma::Svg + // try to load from iconloader an svg with Plasma::Svg const auto *iconTheme = KIconLoader::global()->theme(); QString iconPath; if (iconTheme) { @@ -175,13 +186,14 @@ public: m_svgIcon->setImagePath(iconPath); m_svgIconName = sourceString; } else { - //fail, cleanup + // fail, cleanup delete m_svgIcon; } } } - ~SvgSource() { + ~SvgSource() + { if (m_svgIcon) { QObject::disconnect(m_iconItem, nullptr, m_svgIcon, nullptr); } @@ -196,13 +208,13 @@ public: { QSize s; if (m_svgIcon) { // FIXME: Check Svg::isValid()? Considered expensive by apidox. - //resize() resets the icon to its implicit size, specified + // resize() resets the icon to its implicit size, specified m_svgIcon->resize(); - //plasma theme icon, where one file contains multiple images + // plasma theme icon, where one file contains multiple images if (m_svgIcon->hasElement(m_svgIconName)) { s = m_svgIcon->elementSize(m_svgIconName); - //normal icon: one image per file, page size is icon size + // normal icon: one image per file, page size is icon size } else { s = m_svgIcon->size(); } @@ -248,35 +260,32 @@ private: }; IconItem::IconItem(QQuickItem *parent) - : QQuickItem(parent), - m_iconItemSource(new NullSource(this)), - m_status(Plasma::Svg::Normal), - m_active(false), - m_animated(true), - m_usesPlasmaTheme(true), - m_roundToIconSize(true), - m_textureChanged(false), - m_sizeChanged(false), - m_allowNextAnimation(false), - m_blockNextAnimation(false), - m_implicitHeightSetByUser(false), - m_implicitWidthSetByUser(false), - m_colorGroup(Plasma::Theme::NormalColorGroup), - m_animValue(0) + : QQuickItem(parent) + , m_iconItemSource(new NullSource(this)) + , m_status(Plasma::Svg::Normal) + , m_active(false) + , m_animated(true) + , m_usesPlasmaTheme(true) + , m_roundToIconSize(true) + , m_textureChanged(false) + , m_sizeChanged(false) + , m_allowNextAnimation(false) + , m_blockNextAnimation(false) + , m_implicitHeightSetByUser(false) + , m_implicitWidthSetByUser(false) + , m_colorGroup(Plasma::Theme::NormalColorGroup) + , m_animValue(0) { m_animation = new QPropertyAnimation(this); - connect(m_animation, &QPropertyAnimation::valueChanged, - this, &IconItem::valueChanged); - connect(m_animation, &QPropertyAnimation::finished, - this, &IconItem::animationFinished); + connect(m_animation, &QPropertyAnimation::valueChanged, this, &IconItem::valueChanged); + connect(m_animation, &QPropertyAnimation::finished, this, &IconItem::animationFinished); m_animation->setTargetObject(this); m_animation->setEasingCurve(QEasingCurve::InOutQuad); - m_animation->setDuration(250); //FIXME from theme + m_animation->setDuration(250); // FIXME from theme setFlag(ItemHasContents, true); - connect(KIconLoader::global(), &KIconLoader::iconLoaderSettingsChanged, - this, &IconItem::updateImplicitSize); + connect(KIconLoader::global(), &KIconLoader::iconLoaderSettingsChanged, this, &IconItem::updateImplicitSize); connect(this, &IconItem::implicitWidthChanged, this, &IconItem::implicitWidthChanged2); connect(this, &IconItem::implicitHeightChanged, this, &IconItem::implicitHeightChanged2); @@ -346,9 +355,7 @@ void IconItem::setSource(const QVariant &source) } if (!localFile.isEmpty()) { - if (sourceString.endsWith(QLatin1String(".svg")) || - sourceString.endsWith(QLatin1String(".svgz")) || - sourceString.endsWith(QLatin1String(".ico"))) { + if (sourceString.endsWith(QLatin1String(".svg")) || sourceString.endsWith(QLatin1String(".svgz")) || sourceString.endsWith(QLatin1String(".ico"))) { QIcon icon = QIcon(localFile); m_iconItemSource.reset(new QIconSource(icon, this)); } else { @@ -359,14 +366,14 @@ void IconItem::setSource(const QVariant &source) m_iconItemSource.reset(new SvgSource(sourceString, this)); if (!m_iconItemSource->isValid()) { - //if we started with a QIcon use that. + // if we started with a QIcon use that. QIcon icon = source.value(); if (icon.isNull()) { icon = QIcon::fromTheme(sourceString); } m_iconItemSource.reset(new QIconSource(icon, this)); - //since QIcon is rendered by KIconLoader, watch for when its configuration changes now and reload as needed. + // since QIcon is rendered by KIconLoader, watch for when its configuration changes now and reload as needed. connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &IconItem::iconLoaderIconChanged); } } @@ -412,7 +419,6 @@ Plasma::Theme::ColorGroup IconItem::colorGroup() const return m_colorGroup; } - void IconItem::setOverlays(const QStringList &overlays) { if (overlays == m_overlays) { @@ -428,7 +434,6 @@ QStringList IconItem::overlays() const return m_overlays; } - bool IconItem::isActive() const { return m_active; @@ -588,7 +593,7 @@ void IconItem::updatePolish() loadPixmap(); } -QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) +QSGNode *IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) { Q_UNUSED(updatePaintNodeData) @@ -598,7 +603,7 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update } if (m_animation->state() == QAbstractAnimation::Running) { - FadingNode *animatingNode = dynamic_cast(oldNode); + FadingNode *animatingNode = dynamic_cast(oldNode); if (!animatingNode || m_textureChanged) { delete oldNode; @@ -623,7 +628,7 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update return animatingNode; } else { - ManagedTextureNode *textureNode = dynamic_cast(oldNode); + ManagedTextureNode *textureNode = dynamic_cast(oldNode); if (!textureNode || m_textureChanged) { delete oldNode; @@ -692,7 +697,7 @@ void IconItem::loadPixmap() size = Units::roundToIconSize(size); } - //final pixmap to paint + // final pixmap to paint QPixmap result; if (size <= 0) { m_iconPixmap = QPixmap(); @@ -739,7 +744,7 @@ void IconItem::loadPixmap() Q_EMIT paintedSizeChanged(); } - //don't animate initial setting + // don't animate initial setting bool animated = (m_animated || m_allowNextAnimation) && !m_oldIconPixmap.isNull() && !m_sizeChanged && !m_blockNextAnimation; if (QQuickWindow::sceneGraphBackend() == QLatin1String("software")) { @@ -775,14 +780,12 @@ void IconItem::itemChange(ItemChange change, const ItemChangeData &value) connect(m_window.data(), &QWindow::visibleChanged, this, &IconItem::windowVisibleChanged); } schedulePixmapUpdate(); - } QQuickItem::itemChange(change, value); } -void IconItem::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) +void IconItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { if (newGeometry.size() != oldGeometry.size()) { m_sizeChanged = true; diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index 500274a97..853cbd042 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -9,11 +9,11 @@ #define ICONITEM_H #include -#include #include #include -#include +#include #include +#include #include @@ -51,8 +51,8 @@ class IconItem : public QQuickItem Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) /** - * Specifies the overlay(s) for this icon - */ + * Specifies the overlay(s) for this icon + */ Q_PROPERTY(QStringList overlays READ overlays WRITE setOverlays NOTIFY overlaysChanged) /** @@ -145,11 +145,10 @@ public: void setImplicitWidth2(int height); void updatePolish() override; - QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) override; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; void itemChange(ItemChange change, const ItemChangeData &value) override; - void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void componentComplete() override; @@ -180,9 +179,9 @@ private: QSize paintedSize(const QSizeF &containerSize = QSizeF()) const; void updateImplicitSize(); - //all the ways we can set an source. Only one of them will be valid + // all the ways we can set an source. Only one of them will be valid QScopedPointer m_iconItemSource; - //this contains the raw variant it was passed + // this contains the raw variant it was passed QVariant m_source; Plasma::Svg::Status m_status; @@ -205,7 +204,7 @@ private: Plasma::Theme::ColorGroup m_colorGroup; - //animation on pixmap change + // animation on pixmap change QPropertyAnimation *m_animation; qreal m_animValue; diff --git a/src/declarativeimports/core/quicktheme.cpp b/src/declarativeimports/core/quicktheme.cpp index e0ee6b029..4c71c6654 100644 --- a/src/declarativeimports/core/quicktheme.cpp +++ b/src/declarativeimports/core/quicktheme.cpp @@ -6,11 +6,8 @@ #include "quicktheme.h" - - namespace Plasma { - QuickTheme::QuickTheme(QObject *parent) : Theme(parent) { @@ -191,7 +188,6 @@ QColor QuickTheme::complementaryNegativeTextColor() const return Plasma::Theme::color(Plasma::Theme::TextColor, Plasma::Theme::ComplementaryColorGroup); } - QColor QuickTheme::headerTextColor() const { return Plasma::Theme::color(Plasma::Theme::TextColor, Plasma::Theme::HeaderColorGroup); diff --git a/src/declarativeimports/core/quicktheme.h b/src/declarativeimports/core/quicktheme.h index b62eb2481..9f0a93656 100644 --- a/src/declarativeimports/core/quicktheme.h +++ b/src/declarativeimports/core/quicktheme.h @@ -14,7 +14,6 @@ namespace Plasma { - /** * @class QuickTheme plasma/theme.h * @@ -85,8 +84,6 @@ public: explicit QuickTheme(QObject *parent = nullptr); ~QuickTheme(); - - /** * @return The theme's colorscheme's text color * @since 5.0 @@ -291,7 +288,6 @@ public: */ QColor complementaryNegativeTextColor() const; - /** * @return The theme's colorscheme's text color of "header" areas * @since 5.0 @@ -347,4 +343,3 @@ Q_SIGNALS: } // Plasma namespace #endif // multiple inclusion guard - diff --git a/src/declarativeimports/core/serviceoperationstatus.cpp b/src/declarativeimports/core/serviceoperationstatus.cpp index 6271f7782..efc9d9107 100644 --- a/src/declarativeimports/core/serviceoperationstatus.cpp +++ b/src/declarativeimports/core/serviceoperationstatus.cpp @@ -7,8 +7,8 @@ #include "serviceoperationstatus.h" ServiceOperationStatus::ServiceOperationStatus(QObject *parent) - : QObject(parent), - m_enabled(false) + : QObject(parent) + , m_enabled(false) { } @@ -26,8 +26,7 @@ void ServiceOperationStatus::setService(Plasma::Service *service) disconnect(m_service.data(), nullptr, this, nullptr); } if (service) { - connect(service, &Plasma::Service::operationEnabledChanged, - this, &ServiceOperationStatus::updateStatus); + connect(service, &Plasma::Service::operationEnabledChanged, this, &ServiceOperationStatus::updateStatus); } m_service = service; @@ -84,4 +83,3 @@ void ServiceOperationStatus::updateStatus() Q_EMIT enabledChanged(); } } - diff --git a/src/declarativeimports/core/svgitem.cpp b/src/declarativeimports/core/svgitem.cpp index c45b3ef8e..bc2e43b16 100644 --- a/src/declarativeimports/core/svgitem.cpp +++ b/src/declarativeimports/core/svgitem.cpp @@ -7,10 +7,10 @@ #include "svgitem.h" -#include -#include -#include #include +#include +#include +#include #include "plasma/svg.h" @@ -20,10 +20,9 @@ namespace Plasma { - SvgItem::SvgItem(QQuickItem *parent) - : QQuickItem(parent), - m_textureChanged(false) + : QQuickItem(parent) + , m_textureChanged(false) { setFlag(QQuickItem::ItemHasContents, true); connect(&Units::instance(), &Units::devicePixelRatioChanged, this, &SvgItem::updateDevicePixelRatio); @@ -109,7 +108,7 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP return nullptr; } - //this is more than just an optimization, uploading a null image to QSGAtlasTexture causes a crash + // this is more than just an optimization, uploading a null image to QSGAtlasTexture causes a crash if (width() == 0.0 || height() == 0.0) { delete oldNode; return nullptr; @@ -121,14 +120,14 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP m_textureChanged = true; } - //TODO use a heuristic to work out when to redraw - //if !m_smooth and size is approximate simply change the textureNode.rect without - //updating the material + // TODO use a heuristic to work out when to redraw + // if !m_smooth and size is approximate simply change the textureNode.rect without + // updating the material if (m_textureChanged || textureNode->texture()->textureSize() != QSize(width(), height())) { - //despite having a valid size sometimes we still get a null QImage from Plasma::Svg - //loading a null texture to an atlas fatals - //Dave E fixed this in Qt in 5.3.something onwards but we need this for now + // despite having a valid size sometimes we still get a null QImage from Plasma::Svg + // loading a null texture to an atlas fatals + // Dave E fixed this in Qt in 5.3.something onwards but we need this for now if (m_image.isNull()) { delete textureNode; return nullptr; @@ -160,7 +159,7 @@ void SvgItem::updateNeeded() void SvgItem::updateDevicePixelRatio() { if (m_svg) { - //devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. + // devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned) if (window()) { m_svg.data()->setDevicePixelRatio(qMax(1.0, floor(window()->devicePixelRatio()))); @@ -182,7 +181,7 @@ void SvgItem::updatePolish() QQuickItem::updatePolish(); if (m_svg) { - //setContainsMultipleImages has to be done there since m_frameSvg can be shared with somebody else + // setContainsMultipleImages has to be done there since m_frameSvg can be shared with somebody else m_textureChanged = true; m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty()); m_image = m_svg.data()->image(QSize(width(), height()), m_elementID); @@ -199,4 +198,3 @@ void SvgItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeomet } } // Plasma namespace - diff --git a/src/declarativeimports/core/svgitem.h b/src/declarativeimports/core/svgitem.h index d94a197a8..4ce181fab 100644 --- a/src/declarativeimports/core/svgitem.h +++ b/src/declarativeimports/core/svgitem.h @@ -7,14 +7,13 @@ #ifndef SVGITEM_P #define SVGITEM_P -#include #include +#include #include "units.h" namespace Plasma { - class Svg; /** @@ -48,7 +47,7 @@ class SvgItem : public QQuickItem Q_PROPERTY(QSizeF naturalSize READ naturalSize NOTIFY naturalSizeChanged) public: -/// @cond INTERNAL_DOCS + /// @cond INTERNAL_DOCS explicit SvgItem(QQuickItem *parent = nullptr); ~SvgItem() override; @@ -62,7 +61,7 @@ public: QSizeF naturalSize() const; QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; -/// @endcond + /// @endcond Q_SIGNALS: void elementIdChanged(); @@ -70,10 +69,10 @@ Q_SIGNALS: void naturalSizeChanged(); protected Q_SLOTS: -/// @cond INTERNAL_DOCS + /// @cond INTERNAL_DOCS void updateNeeded(); void updateDevicePixelRatio(); -/// @endcond + /// @endcond private: void scheduleImageUpdate(); diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp index 0c79b1f7c..0b0a38573 100644 --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -9,26 +9,26 @@ #include "tooltip.h" #include "tooltipdialog.h" -#include #include +#include #include "framesvgitem.h" -#include #include +#include ToolTipDialog *ToolTip::s_dialog = nullptr; -int ToolTip::s_dialogUsers = 0; +int ToolTip::s_dialogUsers = 0; ToolTip::ToolTip(QQuickItem *parent) - : QQuickItem(parent), - m_tooltipsEnabledGlobally(false), - m_containsMouse(false), - m_location(Plasma::Types::Floating), - m_textFormat(Qt::AutoText), - m_active(true), - m_interactive(false), - m_timeout(4000), - m_usingDialog(false) + : QQuickItem(parent) + , m_tooltipsEnabledGlobally(false) + , m_containsMouse(false) + , m_location(Plasma::Types::Floating) + , m_textFormat(Qt::AutoText) + , m_active(true) + , m_interactive(false) + , m_timeout(4000) + , m_usingDialog(false) { setAcceptHoverEvents(true); setFiltersChildMouseEvents(true); @@ -331,7 +331,7 @@ void ToolTip::hoverEnterEvent(QHoverEvent *event) // It need to be considered only when other items can deal with tooltip area if (m_active) { tooltipDialogInstance()->keepalive(); - //FIXME: showToolTip needs to be renamed in sync or something like that + // FIXME: showToolTip needs to be renamed in sync or something like that showToolTip(); } } else { diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h index 792322b60..711bf94ee 100644 --- a/src/declarativeimports/core/tooltip.h +++ b/src/declarativeimports/core/tooltip.h @@ -9,10 +9,10 @@ #ifndef TOOLTIPOBJECT_H #define TOOLTIPOBJECT_H -#include -#include -#include #include +#include +#include +#include class QQuickItem; class ToolTipDialog; @@ -107,7 +107,8 @@ class ToolTip : public QQuickItem /** * if interactive is false (default), the tooltip will automatically hide - * itself as soon as the mouse leaves the tooltiparea, if is true, if the mouse leaves tooltiparea and goes over the tooltip itself, the tooltip won't hide, so it will be possible to interact with tooltip contents + * itself as soon as the mouse leaves the tooltiparea, if is true, if the mouse leaves tooltiparea and goes over the tooltip itself, the tooltip won't hide, + * so it will be possible to interact with tooltip contents */ Q_PROPERTY(bool interactive MEMBER m_interactive WRITE setInteractive NOTIFY interactiveChanged) @@ -118,7 +119,7 @@ class ToolTip : public QQuickItem Q_PROPERTY(int timeout MEMBER m_timeout WRITE setTimeout) public: -/// @cond INTERNAL_DOCS + /// @cond INTERNAL_DOCS explicit ToolTip(QQuickItem *parent = nullptr); ~ToolTip() override; @@ -151,7 +152,7 @@ public: void setInteractive(bool interactive); void setTimeout(int timeout); -/// @endcond + /// @endcond public Q_SLOTS: @@ -167,13 +168,13 @@ public Q_SLOTS: void hideToolTip(); protected: -/// @cond INTERNAL_DOCS + /// @cond INTERNAL_DOCS bool childMouseEventFilter(QQuickItem *item, QEvent *event) override; void hoverEnterEvent(QHoverEvent *event) override; void hoverLeaveEvent(QHoverEvent *event) override; ToolTipDialog *tooltipDialogInstance(); -/// @endcond + /// @endcond Q_SIGNALS: void mainItemChanged(); @@ -215,9 +216,9 @@ private: int m_interval; int m_timeout; - //ToolTipDialog is not a Q_GLOBAL_STATIC because QQuickwindows as global static - //are deleted too later after some stuff in the qml runtime has already been deleted, - //causing a crash on exit + // ToolTipDialog is not a Q_GLOBAL_STATIC because QQuickwindows as global static + // are deleted too later after some stuff in the qml runtime has already been deleted, + // causing a crash on exit bool m_usingDialog : 1; static ToolTipDialog *s_dialog; static int s_dialogUsers; diff --git a/src/declarativeimports/core/tooltipdialog.cpp b/src/declarativeimports/core/tooltipdialog.cpp index 23cd10d93..f29a22524 100644 --- a/src/declarativeimports/core/tooltipdialog.cpp +++ b/src/declarativeimports/core/tooltipdialog.cpp @@ -6,20 +6,20 @@ #include "tooltipdialog.h" -#include -#include #include #include +#include +#include -#include #include +#include -ToolTipDialog::ToolTipDialog(QQuickItem *parent) - : Dialog(parent), - m_qmlObject(nullptr), - m_hideTimeout(4000), - m_interactive(false), - m_owner(nullptr) +ToolTipDialog::ToolTipDialog(QQuickItem *parent) + : Dialog(parent) + , m_qmlObject(nullptr) + , m_hideTimeout(4000) + , m_interactive(false) + , m_owner(nullptr) { setLocation(Plasma::Types::Floating); setType(Dialog::WindowType::Tooltip); @@ -42,7 +42,7 @@ QQuickItem *ToolTipDialog::loadDefaultItem() } if (!m_qmlObject->rootObject()) { - //HACK: search our own import + // HACK: search our own import const auto paths = m_qmlObject->engine()->importPathList(); for (const QString &path : paths) { if (QFile::exists(path + QStringLiteral("/org/kde/plasma/core"))) { diff --git a/src/declarativeimports/core/tooltipdialog.h b/src/declarativeimports/core/tooltipdialog.h index a792c9912..06eb0e622 100644 --- a/src/declarativeimports/core/tooltipdialog.h +++ b/src/declarativeimports/core/tooltipdialog.h @@ -9,8 +9,8 @@ #include "dialog.h" -#include #include +#include #include class QQuickItem; diff --git a/src/declarativeimports/core/units.cpp b/src/declarativeimports/core/units.cpp index 0873dbe4b..821ae07d3 100644 --- a/src/declarativeimports/core/units.cpp +++ b/src/declarativeimports/core/units.cpp @@ -8,20 +8,19 @@ #include "units.h" -#include #include -#include +#include +#include #include #include #include -#include +#include #include #include const int defaultLongDuration = 200; - SharedAppFilter::SharedAppFilter(QObject *parent) : QObject(parent) { @@ -29,7 +28,8 @@ SharedAppFilter::SharedAppFilter(QObject *parent) } SharedAppFilter::~SharedAppFilter() -{} +{ +} bool SharedAppFilter::eventFilter(QObject *watched, QEvent *event) { @@ -44,12 +44,12 @@ bool SharedAppFilter::eventFilter(QObject *watched, QEvent *event) SharedAppFilter *Units::s_sharedAppFilter = nullptr; Units::Units(QObject *parent) - : QObject(parent), - m_gridUnit(-1), - m_devicePixelRatio(-1), - m_smallSpacing(-1), - m_largeSpacing(-1), - m_longDuration(defaultLongDuration) // default base value for animations + : QObject(parent) + , m_gridUnit(-1) + , m_devicePixelRatio(-1) + , m_smallSpacing(-1) + , m_largeSpacing(-1) + , m_longDuration(defaultLongDuration) // default base value for animations { if (!s_sharedAppFilter) { s_sharedAppFilter = new SharedAppFilter(); @@ -64,18 +64,16 @@ Units::Units(QObject *parent) QObject::connect(s_sharedAppFilter, &SharedAppFilter::fontChanged, this, &Units::updateSpacing); m_animationSpeedWatcher = KConfigWatcher::create(KSharedConfig::openConfig()); - connect(m_animationSpeedWatcher.data(), &KConfigWatcher::configChanged, this, - [this](const KConfigGroup &group, const QByteArrayList &names) { - if (group.name() == QLatin1String("KDE") && names.contains(QByteArrayLiteral("AnimationDurationFactor"))) { - updateAnimationSpeed(); - } + connect(m_animationSpeedWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) { + if (group.name() == QLatin1String("KDE") && names.contains(QByteArrayLiteral("AnimationDurationFactor"))) { + updateAnimationSpeed(); + } }); updateAnimationSpeed(); } Units::~Units() { - } Units &Units::instance() @@ -105,7 +103,6 @@ void Units::updateAnimationSpeed() } } - void Units::iconLoaderSettingsChanged() { m_iconSizes->insert(QStringLiteral("desktop"), devicePixelIconSize(KIconLoader::global()->currentSize(KIconLoader::Desktop))); @@ -141,7 +138,7 @@ int Units::roundToIconSize(int size) if (size <= 0) { return 0; } else if (size < KIconLoader::SizeSmall) { - return KIconLoader::SizeSmall/2; + return KIconLoader::SizeSmall / 2; } else if (size < KIconLoader::SizeSmallMedium) { return KIconLoader::SizeSmall; @@ -263,7 +260,7 @@ int Units::shortDuration() const int Units::veryShortDuration() const { - return qRound(m_longDuration * 0.25); + return qRound(m_longDuration * 0.25); } int Units::veryLongDuration() const @@ -272,4 +269,3 @@ int Units::veryLongDuration() const } #include "moc_units.cpp" - diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h index 8d657079c..b5022a748 100644 --- a/src/declarativeimports/core/units.h +++ b/src/declarativeimports/core/units.h @@ -19,7 +19,7 @@ class QQuickItem; class SharedAppFilter : public QObject { - Q_OBJECT + Q_OBJECT public: explicit SharedAppFilter(QObject *parent = nullptr); ~SharedAppFilter() override; @@ -62,8 +62,8 @@ class Units : public QObject * * desktop (DEPRECATED: use iconSizeHints instead) * */ - //note the iconSizeChanged signal indicates that one (or more) of these icons have changed - //but the property map itself remains constant + // note the iconSizeChanged signal indicates that one (or more) of these icons have changed + // but the property map itself remains constant Q_PROPERTY(QQmlPropertyMap *iconSizes READ iconSizes CONSTANT) /** @@ -77,8 +77,8 @@ class Units : public QObject * * panel * * desktop */ - //note the iconSizeHintsChanged signal indicates that one (or more) of these icons have changed - //but the property map itself remains constant + // note the iconSizeHintsChanged signal indicates that one (or more) of these icons have changed + // but the property map itself remains constant Q_PROPERTY(QQmlPropertyMap *iconSizeHints READ iconSizeHints CONSTANT) // layout hints @@ -132,7 +132,7 @@ class Units : public QObject Q_PROPERTY(int veryLongDuration READ veryLongDuration NOTIFY durationChanged) public: -/// @cond INTERNAL_DOCS + /// @cond INTERNAL_DOCS ~Units(); @@ -198,7 +198,7 @@ public: * @since 5.78 */ int veryShortDuration() const; -/// @endcond + /// @endcond /** * @return a size rounded tothe nearest inferior standard icon size. @@ -222,10 +222,10 @@ private Q_SLOTS: private: Units(QObject *parent = nullptr); - Units(Units const&) = delete; // Copy construct - Units(Units&&) = delete; // Move construct - Units& operator=(Units const&) = delete; // Copy assign - Units& operator=(Units &&) = delete; // Move assign + Units(Units const &) = delete; // Copy construct + Units(Units &&) = delete; // Move construct + Units &operator=(Units const &) = delete; // Copy assign + Units &operator=(Units &&) = delete; // Move assign void updateDevicePixelRatio(); void updateAnimationSpeed(); @@ -248,5 +248,4 @@ private: int m_longDuration; }; -#endif //UNITS_H - +#endif // UNITS_H diff --git a/src/declarativeimports/core/windowthumbnail.cpp b/src/declarativeimports/core/windowthumbnail.cpp index 862b08aa9..d6c66ac34 100644 --- a/src/declarativeimports/core/windowthumbnail.cpp +++ b/src/declarativeimports/core/windowthumbnail.cpp @@ -19,14 +19,13 @@ #include #if HAVE_GLX #include -typedef void (*glXBindTexImageEXT_func)(Display *dpy, GLXDrawable drawable, - int buffer, const int *attrib_list); +typedef void (*glXBindTexImageEXT_func)(Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); typedef void (*glXReleaseTexImageEXT_func)(Display *dpy, GLXDrawable drawable, int buffer); #endif #if HAVE_EGL -typedef EGLImageKHR(*eglCreateImageKHR_func)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *); -typedef EGLBoolean(*eglDestroyImageKHR_func)(EGLDisplay, EGLImageKHR); -typedef GLvoid(*glEGLImageTargetTexture2DOES_func)(GLenum, GLeglImageOES); +typedef EGLImageKHR (*eglCreateImageKHR_func)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *); +typedef EGLBoolean (*eglDestroyImageKHR_func)(EGLDisplay, EGLImageKHR); +typedef GLvoid (*glEGLImageTargetTexture2DOES_func)(GLenum, GLeglImageOES); #endif // HAVE_EGL #endif @@ -34,17 +33,14 @@ typedef GLvoid(*glEGLImageTargetTexture2DOES_func)(GLenum, GLeglImageOES); namespace Plasma { - #if HAVE_XCB_COMPOSITE #if HAVE_GLX -class DiscardGlxPixmapRunnable : public QRunnable { +class DiscardGlxPixmapRunnable : public QRunnable +{ public: - DiscardGlxPixmapRunnable( - uint, - QFunctionPointer, - xcb_pixmap_t - ); + DiscardGlxPixmapRunnable(uint, QFunctionPointer, xcb_pixmap_t); void run() override; + private: uint m_texture; QFunctionPointer m_releaseTexImage; @@ -52,11 +48,12 @@ private: }; DiscardGlxPixmapRunnable::DiscardGlxPixmapRunnable(uint texture, QFunctionPointer deleteFunction, xcb_pixmap_t pixmap) - : QRunnable(), - m_texture(texture), - m_releaseTexImage(deleteFunction), - m_glxPixmap(pixmap) -{} + : QRunnable() + , m_texture(texture) + , m_releaseTexImage(deleteFunction) + , m_glxPixmap(pixmap) +{ +} void DiscardGlxPixmapRunnable::run() { @@ -67,17 +64,15 @@ void DiscardGlxPixmapRunnable::run() glDeleteTextures(1, &m_texture); } } -#endif //HAVE_GLX +#endif // HAVE_GLX #if HAVE_EGL -class DiscardEglPixmapRunnable : public QRunnable { +class DiscardEglPixmapRunnable : public QRunnable +{ public: - DiscardEglPixmapRunnable( - uint, - QFunctionPointer, - EGLImageKHR - ); + DiscardEglPixmapRunnable(uint, QFunctionPointer, EGLImageKHR); void run() override; + private: uint m_texture; QFunctionPointer m_eglDestroyImageKHR; @@ -85,11 +80,12 @@ private: }; DiscardEglPixmapRunnable::DiscardEglPixmapRunnable(uint texture, QFunctionPointer deleteFunction, EGLImageKHR image) - : QRunnable(), - m_texture(texture), - m_eglDestroyImageKHR(deleteFunction), - m_image(image) -{} + : QRunnable() + , m_texture(texture) + , m_eglDestroyImageKHR(deleteFunction) + , m_image(image) +{ +} void DiscardEglPixmapRunnable::run() { @@ -98,8 +94,8 @@ void DiscardEglPixmapRunnable::run() glDeleteTextures(1, &m_texture); } } -#endif//HAVE_EGL -#endif //HAVE_XCB_COMPOSITE +#endif // HAVE_EGL +#endif // HAVE_XCB_COMPOSITE WindowTextureNode::WindowTextureNode() : QSGSimpleTextureNode() @@ -219,22 +215,19 @@ void WindowThumbnail::releaseResources() #if HAVE_XCB_COMPOSITE #if HAVE_GLX && HAVE_EGL - //only one (or none) should be set, but never both + // only one (or none) should be set, but never both Q_ASSERT(m_glxPixmap == XCB_PIXMAP_NONE || m_image == EGL_NO_IMAGE_KHR); #endif #if HAVE_GLX || HAVE_EGL QQuickWindow::RenderStage m_renderStage = QQuickWindow::NoStage; #endif - //data is deleted in the render thread (with relevant GLX calls) - //note runnable may be called *after* this is deleted - //but the pointer is held by the WindowThumbnail which is in the main thread + // data is deleted in the render thread (with relevant GLX calls) + // note runnable may be called *after* this is deleted + // but the pointer is held by the WindowThumbnail which is in the main thread #if HAVE_GLX if (m_glxPixmap != XCB_PIXMAP_NONE) { - window()->scheduleRenderJob(new DiscardGlxPixmapRunnable(m_texture, - m_releaseTexImage, - m_glxPixmap), - m_renderStage); + window()->scheduleRenderJob(new DiscardGlxPixmapRunnable(m_texture, m_releaseTexImage, m_glxPixmap), m_renderStage); m_glxPixmap = XCB_PIXMAP_NONE; m_texture = 0; @@ -242,10 +235,7 @@ void WindowThumbnail::releaseResources() #endif #if HAVE_EGL if (m_image != EGL_NO_IMAGE_KHR) { - window()->scheduleRenderJob(new DiscardEglPixmapRunnable(m_texture, - m_eglDestroyImageKHR, - m_image), - m_renderStage); + window()->scheduleRenderJob(new DiscardEglPixmapRunnable(m_texture, m_eglDestroyImageKHR, m_image), m_renderStage); m_image = EGL_NO_IMAGE_KHR; m_texture = 0; @@ -254,8 +244,6 @@ void WindowThumbnail::releaseResources() #endif } - - uint32_t WindowThumbnail::winId() const { return m_winId; @@ -434,13 +422,9 @@ bool WindowThumbnail::xcbWindowToTextureEGL(WindowTextureNode *textureNode) xcb_connection_t *c = QX11Info::connection(); auto geometryCookie = xcb_get_geometry_unchecked(c, m_pixmap); - const EGLint attribs[] = { - EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, - EGL_NONE - }; - m_image = ((eglCreateImageKHR_func)(m_eglCreateImageKHR))(eglGetCurrentDisplay(), EGL_NO_CONTEXT, - EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)m_pixmap, attribs); + const EGLint attribs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; + m_image = ((eglCreateImageKHR_func)( + m_eglCreateImageKHR))(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)m_pixmap, attribs); if (m_image == EGL_NO_IMAGE_KHR) { qDebug() << "failed to create egl image"; @@ -471,9 +455,8 @@ void WindowThumbnail::resolveEGLFunctions() } auto *context = window()->openglContext(); QList extensions = QByteArray(eglQueryString(display, EGL_EXTENSIONS)).split(' '); - if (extensions.contains(QByteArrayLiteral("EGL_KHR_image")) || - (extensions.contains(QByteArrayLiteral("EGL_KHR_image_base")) && - extensions.contains(QByteArrayLiteral("EGL_KHR_image_pixmap")))) { + if (extensions.contains(QByteArrayLiteral("EGL_KHR_image")) + || (extensions.contains(QByteArrayLiteral("EGL_KHR_image_base")) && extensions.contains(QByteArrayLiteral("EGL_KHR_image_pixmap")))) { if (context->hasExtension(QByteArrayLiteral("GL_OES_EGL_image"))) { qDebug() << "Have EGL texture from pixmap"; m_eglCreateImageKHR = context->getProcAddress(QByteArrayLiteral("eglCreateImageKHR")); @@ -572,20 +555,18 @@ void WindowThumbnail::bindGLXTexture() resetDamaged(); } -struct FbConfigInfo -{ +struct FbConfigInfo { GLXFBConfig fbConfig; int textureFormat; }; -struct GlxGlobalData -{ - GlxGlobalData() { - xcb_connection_t * const conn = QX11Info::connection(); +struct GlxGlobalData { + GlxGlobalData() + { + xcb_connection_t *const conn = QX11Info::connection(); // Fetch the render pict formats - reply = xcb_render_query_pict_formats_reply(conn, - xcb_render_query_pict_formats_unchecked(conn), nullptr); + reply = xcb_render_query_pict_formats_reply(conn, xcb_render_query_pict_formats_unchecked(conn), nullptr); // Init the visual ID -> format ID hash table for (auto screens = xcb_render_query_pict_formats_screens_iterator(reply); screens.rem; xcb_render_pictscreen_next(&screens)) { @@ -621,7 +602,8 @@ struct GlxGlobalData } } - ~GlxGlobalData() { + ~GlxGlobalData() + { qDeleteAll(visualFbConfigHash); std::free(reply); } @@ -663,31 +645,42 @@ FbConfigInfo *getConfig(xcb_visualid_t visual) return nullptr; } - const int red_bits = qPopulationCount(direct->red_mask); + const int red_bits = qPopulationCount(direct->red_mask); const int green_bits = qPopulationCount(direct->green_mask); - const int blue_bits = qPopulationCount(direct->blue_mask); + const int blue_bits = qPopulationCount(direct->blue_mask); const int alpha_bits = qPopulationCount(direct->alpha_mask); const int depth = visualDepth(visual); const auto rgb_sizes = std::tie(red_bits, green_bits, blue_bits); - const int attribs[] = { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT, - GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, - GLX_X_RENDERABLE, True, - GLX_CONFIG_CAVEAT, int(GLX_DONT_CARE), // The ARGB32 visual is marked non-conformant in Catalyst - GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, int(GLX_DONT_CARE), - GLX_BUFFER_SIZE, red_bits + green_bits + blue_bits + alpha_bits, - GLX_RED_SIZE, red_bits, - GLX_GREEN_SIZE, green_bits, - GLX_BLUE_SIZE, blue_bits, - GLX_ALPHA_SIZE, alpha_bits, - GLX_STENCIL_SIZE, 0, - GLX_DEPTH_SIZE, 0, - 0 - }; + const int attribs[] = {GLX_RENDER_TYPE, + GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, + GLX_WINDOW_BIT | GLX_PIXMAP_BIT, + GLX_X_VISUAL_TYPE, + GLX_TRUE_COLOR, + GLX_X_RENDERABLE, + True, + GLX_CONFIG_CAVEAT, + int(GLX_DONT_CARE), // The ARGB32 visual is marked non-conformant in Catalyst + GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, + int(GLX_DONT_CARE), + GLX_BUFFER_SIZE, + red_bits + green_bits + blue_bits + alpha_bits, + GLX_RED_SIZE, + red_bits, + GLX_GREEN_SIZE, + green_bits, + GLX_BLUE_SIZE, + blue_bits, + GLX_ALPHA_SIZE, + alpha_bits, + GLX_STENCIL_SIZE, + 0, + GLX_DEPTH_SIZE, + 0, + 0}; if (QByteArray((char *)glGetString(GL_RENDERER)).contains("llvmpipe")) { return nullptr; @@ -710,22 +703,22 @@ FbConfigInfo *getConfig(xcb_visualid_t visual) for (int i = 0; i < count; i++) { int red, green, blue; - glXGetFBConfigAttrib(dpy, configs[i], GLX_RED_SIZE, &red); + glXGetFBConfigAttrib(dpy, configs[i], GLX_RED_SIZE, &red); glXGetFBConfigAttrib(dpy, configs[i], GLX_GREEN_SIZE, &green); - glXGetFBConfigAttrib(dpy, configs[i], GLX_BLUE_SIZE, &blue); + glXGetFBConfigAttrib(dpy, configs[i], GLX_BLUE_SIZE, &blue); if (std::tie(red, green, blue) != rgb_sizes) continue; xcb_visualid_t visual; - glXGetFBConfigAttrib(dpy, configs[i], GLX_VISUAL_ID, (int *) &visual); + glXGetFBConfigAttrib(dpy, configs[i], GLX_VISUAL_ID, (int *)&visual); if (visualDepth(visual) != depth) continue; int bind_rgb, bind_rgba; glXGetFBConfigAttrib(dpy, configs[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, &bind_rgba); - glXGetFBConfigAttrib(dpy, configs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &bind_rgb); + glXGetFBConfigAttrib(dpy, configs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &bind_rgb); if (!bind_rgb && !bind_rgba) continue; @@ -737,7 +730,7 @@ FbConfigInfo *getConfig(xcb_visualid_t visual) continue; int depth, stencil; - glXGetFBConfigAttrib(dpy, configs[i], GLX_DEPTH_SIZE, &depth); + glXGetFBConfigAttrib(dpy, configs[i], GLX_DEPTH_SIZE, &depth); glXGetFBConfigAttrib(dpy, configs[i], GLX_STENCIL_SIZE, &stencil); int texture_format; @@ -768,11 +761,10 @@ FbConfigInfo *getConfig(xcb_visualid_t visual) const FBConfig &candidate = candidates.front(); info = new FbConfigInfo; - info->fbConfig = candidate.config; + info->fbConfig = candidate.config; info->textureFormat = candidate.format; } - return info; } @@ -801,12 +793,7 @@ bool WindowThumbnail::loadGLXTexture() glGenTextures(1, &m_texture); - const int attrs[] = { - GLX_TEXTURE_FORMAT_EXT, info->textureFormat, - GLX_MIPMAP_TEXTURE_EXT, false, - GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, - XCB_NONE - }; + const int attrs[] = {GLX_TEXTURE_FORMAT_EXT, info->textureFormat, GLX_MIPMAP_TEXTURE_EXT, false, GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, XCB_NONE}; m_glxPixmap = glXCreatePixmap(QX11Info::display(), info->fbConfig, m_pixmap, attrs); @@ -891,8 +878,6 @@ bool WindowThumbnail::startRedirecting() #endif } - - void WindowThumbnail::setThumbnailAvailable(bool thumbnailAvailable) { if (m_thumbnailAvailable != thumbnailAvailable) { diff --git a/src/declarativeimports/core/windowthumbnail.h b/src/declarativeimports/core/windowthumbnail.h index 54b30fdc5..d08c150cd 100644 --- a/src/declarativeimports/core/windowthumbnail.h +++ b/src/declarativeimports/core/windowthumbnail.h @@ -12,9 +12,9 @@ // Qt #include -#include -#include #include +#include +#include #include // xcb #if HAVE_XCB_COMPOSITE @@ -32,7 +32,6 @@ class KWindowInfo; namespace Plasma { - class WindowTextureNode; /** @@ -117,7 +116,7 @@ private: xcb_damage_damage_t m_damage; xcb_pixmap_t m_pixmap; -/*The following must *only* be used from the render thread*/ + /*The following must *only* be used from the render thread*/ uint m_texture; #if HAVE_GLX bool windowToTextureGLX(WindowTextureNode *textureNode); @@ -152,6 +151,7 @@ public: WindowTextureNode(); virtual ~WindowTextureNode(); void reset(QSGTexture *texture); + private: QScopedPointer m_texture; }; diff --git a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp index db7980d7f..4f2b8488e 100644 --- a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp +++ b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp @@ -6,8 +6,8 @@ #include "plasmacomponentsplugin.h" -#include #include +#include #include #include "qrangemodel.h" @@ -39,7 +39,7 @@ EngineBookKeeping *EngineBookKeeping::self() QQmlEngine *EngineBookKeeping::engine() const { - //for components creation, any engine will do, as long is valid + // for components creation, any engine will do, as long is valid if (m_engines.isEmpty()) { qWarning() << "No engines found, this should never happen"; return nullptr; @@ -50,8 +50,7 @@ QQmlEngine *EngineBookKeeping::engine() const void EngineBookKeeping::insertEngine(QQmlEngine *engine) { - connect(engine, &QObject::destroyed, - this, &EngineBookKeeping::engineDestroyed); + connect(engine, &QObject::destroyed, this, &EngineBookKeeping::engineDestroyed); m_engines.insert(engine); } @@ -81,4 +80,3 @@ void PlasmaComponentsPlugin::registerTypes(const char *uri) } #include "moc_plasmacomponentsplugin.cpp" - diff --git a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h index 0e91ddb6d..128dced1c 100644 --- a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h +++ b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h @@ -29,7 +29,7 @@ private Q_SLOTS: void engineDestroyed(QObject *deleted); private: - QSet m_engines; + QSet m_engines; }; class PlasmaComponentsPlugin : public QQmlExtensionPlugin diff --git a/src/declarativeimports/plasmacomponents/qmenu.cpp b/src/declarativeimports/plasmacomponents/qmenu.cpp index 87b9e8aa7..ade245b83 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.cpp +++ b/src/declarativeimports/plasmacomponents/qmenu.cpp @@ -8,8 +8,8 @@ #include #include -#include #include +#include #include #include #include @@ -18,10 +18,10 @@ #include "plasmacomponentsplugin.h" QMenuProxy::QMenuProxy(QObject *parent) - : QObject(parent), - m_menu(nullptr), - m_status(DialogStatus::Closed), - m_placement(Plasma::Types::LeftPosedTopAlignedPopup) + : QObject(parent) + , m_menu(nullptr) + , m_status(DialogStatus::Closed) + , m_placement(Plasma::Types::LeftPosedTopAlignedPopup) { if (qobject_cast(QCoreApplication::instance())) { m_menu = new QMenu(nullptr); @@ -32,9 +32,9 @@ QMenuProxy::QMenuProxy(QObject *parent) KAcceleratorManager::manage(m_menu); connect(m_menu, &QMenu::triggered, this, &QMenuProxy::itemTriggered); - connect(m_menu, &QMenu::aboutToHide, this, [ = ]() { - m_status = DialogStatus::Closed; - Q_EMIT statusChanged(); + connect(m_menu, &QMenu::aboutToHide, this, [=]() { + m_status = DialogStatus::Closed; + Q_EMIT statusChanged(); }); } } @@ -79,13 +79,13 @@ void QMenuProxy::setVisualParent(QObject *parent) return; } - //if the old parent was a QAction, disconnect the menu from it + // if the old parent was a QAction, disconnect the menu from it QAction *action = qobject_cast(m_visualParent.data()); if (action) { action->setMenu(nullptr); m_menu->clear(); } - //if parent is a QAction, become a submenu + // if parent is a QAction, become a submenu action = qobject_cast(parent); if (action) { action->setMenu(m_menu); @@ -179,7 +179,7 @@ bool QMenuProxy::event(QEvent *event) case QEvent::ChildAdded: { QChildEvent *ce = static_cast(event); QMenuItem *mi = qobject_cast(ce->child()); - //FIXME: linear complexity here + // FIXME: linear complexity here if (mi && !m_items.contains(mi)) { if (mi->separator()) { m_menu->addSection(mi->text()); @@ -195,7 +195,7 @@ bool QMenuProxy::event(QEvent *event) QChildEvent *ce = static_cast(event); QMenuItem *mi = qobject_cast(ce->child()); - //FIXME: linear complexity here + // FIXME: linear complexity here if (mi) { m_menu->removeAction(mi->action()); m_items.removeAll(mi); @@ -275,7 +275,6 @@ void QMenuProxy::itemTriggered(QAction *action) Q_EMIT triggeredIndex(i); break; } - } } @@ -293,7 +292,7 @@ void QMenuProxy::rebuildMenu() } else { m_menu->addAction(item->action()); if (item->action()->menu()) { - //This ensures existence of the QWindow + // This ensures existence of the QWindow m_menu->winId(); item->action()->menu()->winId(); item->action()->menu()->windowHandle()->setTransientParent(m_menu->windowHandle()); @@ -377,48 +376,48 @@ void QMenuProxy::openRelative() } }; - switch(m_placement) { - case Types::TopPosedLeftAlignedPopup: { - pos = parentItem->mapToScene(QPointF(0, -m_menu->height())); - boundaryCorrection(-m_menu->width() + parentItem->width(), m_menu->height() + parentItem->height()); - break; - } - case Types::LeftPosedTopAlignedPopup: { - pos = parentItem->mapToScene(QPointF(-m_menu->width(), 0)); - boundaryCorrection(m_menu->width() + parentItem->width(), -m_menu->height() + parentItem->height()); - break; - } - case Types::TopPosedRightAlignedPopup: - pos = parentItem->mapToScene(QPointF(parentItem->width() - m_menu->width(), -m_menu->height())); - boundaryCorrection(m_menu->width() - parentItem->width(), m_menu->height() + parentItem->height()); - break; - case Types::RightPosedTopAlignedPopup: { - pos = parentItem->mapToScene(QPointF(parentItem->width(), 0)); - boundaryCorrection(-m_menu->width() - parentItem->width(), -m_menu->height() + parentItem->height()); - break; - } - case Types::LeftPosedBottomAlignedPopup: - pos = parentItem->mapToScene(QPointF(-m_menu->width(), -m_menu->height() + parentItem->height())); - boundaryCorrection(m_menu->width() + parentItem->width(), m_menu->height() - parentItem->height()); - break; - case Types::BottomPosedLeftAlignedPopup: { - pos = parentItem->mapToScene(QPointF(0, parentItem->height())); - boundaryCorrection(-m_menu->width() + parentItem->width(), -m_menu->height() - parentItem->height()); - break; - } - case Types::BottomPosedRightAlignedPopup: { - pos = parentItem->mapToScene(QPointF(parentItem->width() - m_menu->width(), parentItem->height())); - boundaryCorrection(m_menu->width() - parentItem->width(), -m_menu->height() - parentItem->height()); - break; - } - case Types::RightPosedBottomAlignedPopup: { - pos = parentItem->mapToScene(QPointF(parentItem->width(), -m_menu->height() + parentItem->height())); - boundaryCorrection(-m_menu->width() - parentItem->width(), m_menu->height() - parentItem->height()); - break; - } - default: - open(); - return; + switch (m_placement) { + case Types::TopPosedLeftAlignedPopup: { + pos = parentItem->mapToScene(QPointF(0, -m_menu->height())); + boundaryCorrection(-m_menu->width() + parentItem->width(), m_menu->height() + parentItem->height()); + break; + } + case Types::LeftPosedTopAlignedPopup: { + pos = parentItem->mapToScene(QPointF(-m_menu->width(), 0)); + boundaryCorrection(m_menu->width() + parentItem->width(), -m_menu->height() + parentItem->height()); + break; + } + case Types::TopPosedRightAlignedPopup: + pos = parentItem->mapToScene(QPointF(parentItem->width() - m_menu->width(), -m_menu->height())); + boundaryCorrection(m_menu->width() - parentItem->width(), m_menu->height() + parentItem->height()); + break; + case Types::RightPosedTopAlignedPopup: { + pos = parentItem->mapToScene(QPointF(parentItem->width(), 0)); + boundaryCorrection(-m_menu->width() - parentItem->width(), -m_menu->height() + parentItem->height()); + break; + } + case Types::LeftPosedBottomAlignedPopup: + pos = parentItem->mapToScene(QPointF(-m_menu->width(), -m_menu->height() + parentItem->height())); + boundaryCorrection(m_menu->width() + parentItem->width(), m_menu->height() - parentItem->height()); + break; + case Types::BottomPosedLeftAlignedPopup: { + pos = parentItem->mapToScene(QPointF(0, parentItem->height())); + boundaryCorrection(-m_menu->width() + parentItem->width(), -m_menu->height() - parentItem->height()); + break; + } + case Types::BottomPosedRightAlignedPopup: { + pos = parentItem->mapToScene(QPointF(parentItem->width() - m_menu->width(), parentItem->height())); + boundaryCorrection(m_menu->width() - parentItem->width(), -m_menu->height() - parentItem->height()); + break; + } + case Types::RightPosedBottomAlignedPopup: { + pos = parentItem->mapToScene(QPointF(parentItem->width(), -m_menu->height() + parentItem->height())); + boundaryCorrection(-m_menu->width() - parentItem->width(), m_menu->height() - parentItem->height()); + break; + } + default: + open(); + return; } openInternal(pos.toPoint()); @@ -429,7 +428,7 @@ void QMenuProxy::openInternal(QPoint pos) QQuickItem *parentItem = this->parentItem(); if (parentItem && parentItem->window()) { - //create the QWindow + // create the QWindow m_menu->winId(); m_menu->windowHandle()->setTransientParent(parentItem->window()); @@ -441,14 +440,14 @@ void QMenuProxy::openInternal(QPoint pos) } }; - //pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)" - //post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse() + // pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)" + // post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse() if (QVersionNumber::fromString(QString::fromLatin1(qVersion())) > QVersionNumber(5, 8, 0)) { QTimer::singleShot(0, this, ungrabMouseHack); } else { ungrabMouseHack(); } - //end workaround + // end workaround } m_menu->popup(pos); @@ -469,5 +468,3 @@ void QMenuProxy::close() { m_menu->hide(); } - - diff --git a/src/declarativeimports/plasmacomponents/qmenu.h b/src/declarativeimports/plasmacomponents/qmenu.h index 74cca7114..05810cb09 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.h +++ b/src/declarativeimports/plasmacomponents/qmenu.h @@ -7,13 +7,13 @@ #ifndef QMENU_PROXY_H #define QMENU_PROXY_H -#include -#include -#include -#include -#include "qmenuitem.h" #include "enums.h" #include "plasma.h" +#include "qmenuitem.h" +#include +#include +#include +#include class QDeclarativeItem; @@ -66,7 +66,8 @@ class QMenuProxy : public QObject Q_PROPERTY(QWindow *transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged) /** - * the visualParent is used to position the menu. it can be an item on the scene, like a button (that will open the menu on clicked) or another menuitem (in this case this will be a submenu) + * the visualParent is used to position the menu. it can be an item on the scene, like a button (that will open the menu on clicked) or another menuitem (in + * this case this will be a submenu) */ Q_PROPERTY(QObject *visualParent READ visualParent WRITE setVisualParent NOTIFY visualParentChanged()) Q_PROPERTY(DialogStatus::Status status READ status NOTIFY statusChanged) @@ -181,5 +182,4 @@ private: Plasma::Types::PopupPlacement m_placement; }; -#endif //QMENU_PROXY_H - +#endif // QMENU_PROXY_H diff --git a/src/declarativeimports/plasmacomponents/qmenuitem.cpp b/src/declarativeimports/plasmacomponents/qmenuitem.cpp index 63c2d8852..a5b3cdf77 100644 --- a/src/declarativeimports/plasmacomponents/qmenuitem.cpp +++ b/src/declarativeimports/plasmacomponents/qmenuitem.cpp @@ -8,9 +8,9 @@ #include "qmenuitem.h" QMenuItem::QMenuItem(QQuickItem *parent) - : QQuickItem(parent), - m_action(nullptr), - m_section(false) + : QQuickItem(parent) + , m_action(nullptr) + , m_section(false) { setAction(new QAction(this)); } @@ -141,6 +141,3 @@ void QMenuItem::updateAction() m_action->setVisible(isVisible()); m_action->setEnabled(isEnabled()); } - - - diff --git a/src/declarativeimports/plasmacomponents/qmenuitem.h b/src/declarativeimports/plasmacomponents/qmenuitem.h index e5ab0cfae..a6c1d57cf 100644 --- a/src/declarativeimports/plasmacomponents/qmenuitem.h +++ b/src/declarativeimports/plasmacomponents/qmenuitem.h @@ -73,4 +73,3 @@ private: }; #endif // QMENUITEM_H - diff --git a/src/declarativeimports/plasmacomponents/qrangemodel.cpp b/src/declarativeimports/plasmacomponents/qrangemodel.cpp index 903c2cc7b..759960721 100644 --- a/src/declarativeimports/plasmacomponents/qrangemodel.cpp +++ b/src/declarativeimports/plasmacomponents/qrangemodel.cpp @@ -33,7 +33,6 @@ namespace Plasma { - QRangeModelPrivate::QRangeModelPrivate(QRangeModel *qq) : q_ptr(qq) { @@ -157,7 +156,8 @@ void QRangeModelPrivate::emitValueAndPositionIfChanged(const qreal oldValue, con */ QRangeModel::QRangeModel(QObject *parent) - : QObject(parent), d_ptr(new QRangeModelPrivate(this)) + : QObject(parent) + , d_ptr(new QRangeModelPrivate(this)) { Q_D(QRangeModel); d->init(); @@ -169,7 +169,8 @@ QRangeModel::QRangeModel(QObject *parent) */ QRangeModel::QRangeModel(QRangeModelPrivate &dd, QObject *parent) - : QObject(parent), d_ptr(&dd) + : QObject(parent) + , d_ptr(&dd) { Q_D(QRangeModel); d->init(); @@ -518,4 +519,3 @@ void QRangeModel::toMaximum() } } // Plasma namespace - diff --git a/src/declarativeimports/plasmacomponents/qrangemodel.h b/src/declarativeimports/plasmacomponents/qrangemodel.h index df5191093..d92549065 100644 --- a/src/declarativeimports/plasmacomponents/qrangemodel.h +++ b/src/declarativeimports/plasmacomponents/qrangemodel.h @@ -13,7 +13,6 @@ namespace Plasma { - class QRangeModelPrivate; class QRangeModel : public QObject @@ -86,7 +85,6 @@ protected: private: Q_DISABLE_COPY(QRangeModel) Q_DECLARE_PRIVATE(QRangeModel) - }; } // Plasma namespace diff --git a/src/declarativeimports/plasmacomponents/qrangemodel_p.h b/src/declarativeimports/plasmacomponents/qrangemodel_p.h index bbe04affe..732edf22b 100644 --- a/src/declarativeimports/plasmacomponents/qrangemodel_p.h +++ b/src/declarativeimports/plasmacomponents/qrangemodel_p.h @@ -25,7 +25,6 @@ namespace Plasma { - class QRangeModelPrivate { Q_DECLARE_PUBLIC(QRangeModel) diff --git a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp index 54d852d6f..897b24508 100644 --- a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp +++ b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp @@ -30,4 +30,3 @@ QImage AppBackgroundProvider::requestImage(const QString &id, QSize *size, const Q_UNUSED(requestedSize) return QImage(m_theme->backgroundPath(id % QStringLiteral(".png"))); } - diff --git a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h index 155552d63..806ddd285 100644 --- a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h +++ b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h @@ -14,18 +14,18 @@ namespace Plasma class Theme; } -//TODO: should be possible to remove without significant breakages as is just an image provider +// TODO: should be possible to remove without significant breakages as is just an image provider /** * image provider for textures used for applications * @deprecated don't use it */ class AppBackgroundProvider : public QQuickImageProvider { - public: AppBackgroundProvider(); ~AppBackgroundProvider() override; QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override; + private: Plasma::Theme *m_theme; }; diff --git a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp index 9a3c86176..820385337 100644 --- a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp +++ b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp @@ -61,7 +61,6 @@ QString FallbackComponent::filePath(const QString &key) if (tmpPath.isAbsolute()) { resolved = m_basePath + path + key; } else { - resolved = QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_basePath + QLatin1Char('/') + path + key); } @@ -73,4 +72,3 @@ QString FallbackComponent::filePath(const QString &key) return resolved; } - diff --git a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h index 3267eeca2..20edb0bba 100644 --- a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h +++ b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h @@ -7,8 +7,8 @@ #ifndef FALLBACKCOMPONENT_H #define FALLBACKCOMPONENT_H -#include #include +#include #include /** @@ -38,13 +38,13 @@ public: explicit FallbackComponent(QObject *parent = nullptr); /** - * This method must be called after the basePath and the candidates property - * This method resolves a file path based on the base path and the candidates. - * it searches for a file named key under basepath/candidate/key, and returns - * the path constructed with the first candidate that matches, if any. - * - * @param key the name of the file to search for - **/ + * This method must be called after the basePath and the candidates property + * This method resolves a file path based on the base path and the candidates. + * it searches for a file named key under basepath/candidate/key, and returns + * the path constructed with the first candidate that matches, if any. + * + * @param key the name of the file to search for + **/ Q_INVOKABLE QString filePath(const QString &key = QString()); QString basePath() const; diff --git a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp index 4fc31a29f..859aac5f1 100644 --- a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp +++ b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp @@ -9,8 +9,8 @@ #include "appbackgroundprovider_p.h" #include "fallbackcomponent.h" -#include #include +#include // #include // #include @@ -26,5 +26,3 @@ void PlasmaExtraComponentsPlugin::registerTypes(const char *uri) Q_ASSERT(uri == QByteArray("org.kde.plasma.extras")); qmlRegisterType(uri, 2, 0, "FallbackComponent"); } - - diff --git a/src/declarativeimports/platformcomponents/application.cpp b/src/declarativeimports/platformcomponents/application.cpp index 4a97459de..baf4d0699 100644 --- a/src/declarativeimports/platformcomponents/application.cpp +++ b/src/declarativeimports/platformcomponents/application.cpp @@ -9,29 +9,23 @@ #include "utils/d_ptr_implementation.h" -#include #include +#include Application::Private::Private(Application *parent) : running(false) , q(parent) { - connect( - &process, &QProcess::stateChanged, - this, &Private::stateChanged - ); - connect( - &process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(errorFound(QProcess::ProcessError)) - ); + connect(&process, &QProcess::stateChanged, this, &Private::stateChanged); + connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(errorFound(QProcess::ProcessError))); process.setProcessChannelMode(QProcess::MergedChannels); } void Application::Private::stateChanged(QProcess::ProcessState newState) { Q_UNUSED(newState) - //running = (newState != QProcess::NotRunning); - //q->runningChanged(running); + // running = (newState != QProcess::NotRunning); + // q->runningChanged(running); } void Application::Private::errorFound(QProcess::ProcessError err) @@ -41,7 +35,8 @@ void Application::Private::errorFound(QProcess::ProcessError err) } Application::Application(QObject *parent) - : QObject(parent), d(this) + : QObject(parent) + , d(this) { } @@ -107,4 +102,3 @@ void Application::terminate() { d->process.terminate(); } - diff --git a/src/declarativeimports/platformcomponents/application.h b/src/declarativeimports/platformcomponents/application.h index 1d0712fd2..8b11dfedd 100644 --- a/src/declarativeimports/platformcomponents/application.h +++ b/src/declarativeimports/platformcomponents/application.h @@ -23,7 +23,7 @@ * } * @endcode */ -class Application: public QObject +class Application : public QObject { Q_OBJECT @@ -62,4 +62,3 @@ private: }; #endif /* APPLICATION_H */ - diff --git a/src/declarativeimports/platformcomponents/application_p.h b/src/declarativeimports/platformcomponents/application_p.h index 4f6d6494e..37342ce6e 100644 --- a/src/declarativeimports/platformcomponents/application_p.h +++ b/src/declarativeimports/platformcomponents/application_p.h @@ -11,7 +11,7 @@ #include -class Application::Private: public QObject +class Application::Private : public QObject { Q_OBJECT public: @@ -30,4 +30,3 @@ private: }; #endif /* APPLICATION_P_H */ - diff --git a/src/declarativeimports/platformcomponents/icondialog.cpp b/src/declarativeimports/platformcomponents/icondialog.cpp index 361faf432..351bc6156 100644 --- a/src/declarativeimports/platformcomponents/icondialog.cpp +++ b/src/declarativeimports/platformcomponents/icondialog.cpp @@ -21,7 +21,6 @@ class IconDialog::Private { public: - utils::SharedSingleton dialog; }; @@ -56,4 +55,3 @@ void IconDialog::closeDialog() IconDialog::~IconDialog() { } - diff --git a/src/declarativeimports/platformcomponents/icondialog.h b/src/declarativeimports/platformcomponents/icondialog.h index a84d03e05..430c2a024 100644 --- a/src/declarativeimports/platformcomponents/icondialog.h +++ b/src/declarativeimports/platformcomponents/icondialog.h @@ -28,7 +28,7 @@ * icon = iconDialog.openDialog() * @endcode */ -class IconDialog: public QObject +class IconDialog : public QObject { Q_OBJECT @@ -44,4 +44,3 @@ private: }; #endif /* ICONDIALOG_H */ - diff --git a/src/declarativeimports/platformcomponents/platformextensionplugin.cpp b/src/declarativeimports/platformcomponents/platformextensionplugin.cpp index 4349f6041..896acff91 100644 --- a/src/declarativeimports/platformcomponents/platformextensionplugin.cpp +++ b/src/declarativeimports/platformcomponents/platformextensionplugin.cpp @@ -4,14 +4,14 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include -#include #include +#include +#include #include "application.h" #include "icondialog.h" -class PlatformComponentsPlugin: public QQmlExtensionPlugin +class PlatformComponentsPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") @@ -22,14 +22,13 @@ public: { } - void registerTypes(const char *uri) override { + void registerTypes(const char *uri) override + { Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.platformcomponents")); - qmlRegisterType (uri, 2, 0, "Application"); - qmlRegisterType (uri, 2, 0, "IconDialog"); + qmlRegisterType(uri, 2, 0, "Application"); + qmlRegisterType(uri, 2, 0, "IconDialog"); } - }; #include "platformextensionplugin.moc" - diff --git a/src/declarativeimports/platformcomponents/utils/d_ptr.h b/src/declarativeimports/platformcomponents/utils/d_ptr.h index 5553c584c..e2008adce 100644 --- a/src/declarativeimports/platformcomponents/utils/d_ptr.h +++ b/src/declarativeimports/platformcomponents/utils/d_ptr.h @@ -11,8 +11,7 @@ namespace utils { - -template +template class d_ptr { private: @@ -21,19 +20,19 @@ private: public: d_ptr(); - template - d_ptr(Args &&...); + template + d_ptr(Args &&...); ~d_ptr(); T *operator->() const; }; -#define D_PTR \ - class Private; \ - friend class Private; \ - const ::utils::d_ptr d \ - +#define D_PTR \ + class Private; \ + friend class Private; \ + const ::utils::d_ptr d + } // namespace utils #endif diff --git a/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h b/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h index 3fa6978c4..0279040b6 100644 --- a/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h +++ b/src/declarativeimports/platformcomponents/utils/d_ptr_implementation.h @@ -11,20 +11,20 @@ namespace utils { - -template -d_ptr::d_ptr() : d(new T()) +template +d_ptr::d_ptr() + : d(new T()) { } -template -template -d_ptr::d_ptr(Args &&... args) +template +template +d_ptr::d_ptr(Args &&...args) : d(new T(std::forward(args)...)) { } -template +template d_ptr::~d_ptr() { } @@ -38,4 +38,3 @@ T *d_ptr::operator->() const } // namespace utils #endif - diff --git a/src/declarativeimports/platformcomponents/utils/sharedsingleton.h b/src/declarativeimports/platformcomponents/utils/sharedsingleton.h index f5b5b6a90..30738bacb 100644 --- a/src/declarativeimports/platformcomponents/utils/sharedsingleton.h +++ b/src/declarativeimports/platformcomponents/utils/sharedsingleton.h @@ -11,8 +11,7 @@ namespace utils { - -template +template class SharedSingleton { public: @@ -39,10 +38,9 @@ private: static std::weak_ptr s_instance; }; -template +template std::weak_ptr SharedSingleton::s_instance; } // namespace utils #endif /* SHARED_SINGLETON_P_H */ - diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index cfb266177..a930d93d4 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -15,48 +15,47 @@ #include #include +#include #include #include -#include #include #include #include #include #include +#include #include -#include #include #include #include -#include #include +#include #include "containment.h" #include "corona.h" #include "package.h" #include "plasma.h" -#include "scripting/appletscript.h" #include "pluginloader.h" +#include "scripting/appletscript.h" +#include "debug_p.h" #include "private/associatedapplicationmanager_p.h" #include "private/containment_p.h" #include "private/package_p.h" -#include "debug_p.h" namespace Plasma { - static KPluginMetaData appletMetadataForDirectory(const QString &path) { return QFile::exists(path + QLatin1String("/metadata.json")) - ? KPluginMetaData(path + QLatin1String("/metadata.json")) - : KPluginMetaData::fromDesktopFile(path + QLatin1String("/metadata.desktop"), { QStringLiteral("plasma-applet.desktop") }); + ? KPluginMetaData(path + QLatin1String("/metadata.json")) + : KPluginMetaData::fromDesktopFile(path + QLatin1String("/metadata.desktop"), {QStringLiteral("plasma-applet.desktop")}); } Applet::Applet(const KPluginMetaData &info, QObject *parent, uint appletId) - : QObject(parent), - d(new AppletPrivate(info, appletId, this)) + : QObject(parent) + , d(new AppletPrivate(info, appletId, this)) { qCDebug(LOG_PLASMA) << " From KPluginMetaData, valid? " << info.isValid(); // WARNING: do not access config() OR globalConfig() in this method! @@ -66,13 +65,13 @@ Applet::Applet(const KPluginMetaData &info, QObject *parent, uint appletId) } Applet::Applet(const KPluginInfo &info, QObject *parent, uint appletId) - : Applet(info.toMetaData(), parent, appletId) + : Applet(info.toMetaData(), parent, appletId) { } Applet::Applet(QObject *parent, const QString &serviceID, uint appletId) - : QObject(parent), - d(new AppletPrivate(KPluginMetaData(serviceID), appletId, this)) + : QObject(parent) + , d(new AppletPrivate(KPluginMetaData(serviceID), appletId, this)) { // WARNING: do not access config() OR globalConfig() in this method! // that requires a scene, which is not available at this point @@ -81,8 +80,8 @@ Applet::Applet(QObject *parent, const QString &serviceID, uint appletId) } Applet::Applet(QObject *parentObject, const QVariantList &args) - : QObject(nullptr), - d(new AppletPrivate(KPluginMetaData(), args.count() > 2 ? args[2].toInt() : 0, this)) + : QObject(nullptr) + , d(new AppletPrivate(KPluginMetaData(), args.count() > 2 ? args[2].toInt() : 0, this)) { setParent(parentObject); if (!args.isEmpty()) { @@ -113,8 +112,8 @@ Applet::Applet(QObject *parentObject, const QVariantList &args) } Applet::Applet(const QString &packagePath, uint appletId) - : QObject(nullptr), - d(new AppletPrivate(appletMetadataForDirectory(packagePath), appletId, this)) + : QObject(nullptr) + , d(new AppletPrivate(appletMetadataForDirectory(packagePath), appletId, this)) { d->init(packagePath); d->setupPackage(); @@ -125,7 +124,7 @@ Applet::~Applet() if (d->transient) { d->resetConfigurationObject(); } - //let people know that i will die + // let people know that i will die Q_EMIT appletDeleted(this); // ConfigLoader is deleted when AppletPrivate closes not Applet @@ -137,7 +136,7 @@ Applet::~Applet() void Applet::init() { - //Don't implement anything here, it will be overridden by subclasses + // Don't implement anything here, it will be overridden by subclasses } uint Applet::id() const @@ -156,7 +155,7 @@ void Applet::save(KConfigGroup &g) const group = *d->mainConfigGroup(); } - //qCDebug(LOG_PLASMA) << "saving" << pluginName() << "to" << group.name(); + // qCDebug(LOG_PLASMA) << "saving" << pluginName() << "to" << group.name(); // we call the dptr member directly for locked since isImmutable() // also checks kiosk and parent containers group.writeEntry("immutability", (int)d->immutability); @@ -180,7 +179,6 @@ void Applet::save(KConfigGroup &g) const void Applet::restore(KConfigGroup &group) { - setImmutability((Types::ImmutabilityType)group.readEntry("immutability", (int)Types::Mutable)); KConfigGroup shortcutConfig(&group, "Shortcuts"); @@ -199,12 +197,11 @@ void Applet::restore(KConfigGroup &group) } // local shortcut, if any - //TODO: implement; the shortcut will need to be registered with the containment + // TODO: implement; the shortcut will need to be registered with the containment /* #include "accessmanager.h" + #include "authorizationmanager.h" #include "private/plasmoidservice_p.h" - #include "authorizationmanager.h" - #include "authorizationmanager.h" shortcutText = shortcutConfig.readEntryUntranslated("local", QString()); if (!shortcutText.isEmpty()) { //TODO: implement; the shortcut @@ -287,11 +284,11 @@ KConfigGroup Applet::globalConfig() const void Applet::destroy() { if (immutability() != Types::Mutable || d->transient || !d->started) { - return; //don't double delete + return; // don't double delete } d->setDestroyed(true); - //FIXME: an animation on leave if !isContainment() would be good again .. which should be handled by the containment class + // FIXME: an animation on leave if !isContainment() would be good again .. which should be handled by the containment class d->cleanUpAndDelete(); } @@ -336,12 +333,12 @@ void Applet::updateConstraints(Plasma::Types::Constraints constraints) void Applet::constraintsEvent(Plasma::Types::Constraints constraints) { - //NOTE: do NOT put any code in here that reacts to constraints updates + // NOTE: do NOT put any code in here that reacts to constraints updates // as it will not get called for any applet that reimplements constraintsEvent // without calling the Applet:: version as well, which it shouldn't need to. // INSTEAD put such code into flushPendingConstraintsEvents Q_UNUSED(constraints) - //qCDebug(LOG_PLASMA) << constraints << "constraints are FormFactor: " << formFactor() + // qCDebug(LOG_PLASMA) << constraints << "constraints are FormFactor: " << formFactor() // << ", Location: " << location(); if (d->script) { d->script->constraintsEvent(constraints); @@ -424,8 +421,7 @@ void Applet::setBackgroundHints(Plasma::Types::BackgroundHints hint) Plasma::Types::BackgroundHints Applet::effectiveBackgroundHints() const { - if (d->userBackgroundHintsInitialized - && (d->backgroundHints & Plasma::Types::ConfigurableBackground)) { + if (d->userBackgroundHintsInitialized && (d->backgroundHints & Plasma::Types::ConfigurableBackground)) { return d->userBackgroundHints; } else { return d->backgroundHints; @@ -458,7 +454,6 @@ void Applet::setUserBackgroundHints(Plasma::Types::BackgroundHints hint) } } - KPluginInfo Applet::pluginInfo() const { return KPluginInfo(d->appletDescription); @@ -478,7 +473,7 @@ Types::ImmutabilityType Applet::immutability() const return Types::SystemImmutable; } - //Returning the more strict immutability between the applet immutability, Containment and Corona + // Returning the more strict immutability between the applet immutability, Containment and Corona Types::ImmutabilityType upperImmutability = Types::Mutable; if (isContainment()) { @@ -591,7 +586,7 @@ void Applet::flushPendingConstraintsEvents() d->constraintsTimer.stop(); } - //qCDebug(LOG_PLASMA) << "flushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!"; + // qCDebug(LOG_PLASMA) << "flushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!"; Plasma::Types::Constraints c = d->pendingConstraints; d->pendingConstraints = Types::NoConstraint; @@ -600,7 +595,7 @@ void Applet::flushPendingConstraintsEvents() } if (c & Plasma::Types::StartupCompletedConstraint) { - //common actions + // common actions bool unlocked = immutability() == Types::Mutable; QAction *closeApplet = d->actions->action(QStringLiteral("remove")); if (closeApplet) { @@ -611,7 +606,6 @@ void Applet::flushPendingConstraintsEvents() QAction *configAction = d->actions->action(QStringLiteral("configure")); if (configAction) { - if (d->hasConfigurationInterface) { bool canConfig = unlocked || KAuthorized::authorize(QStringLiteral("plasma/allow_configure_when_locked")); configAction->setVisible(canConfig); @@ -642,8 +636,8 @@ void Applet::flushPendingConstraintsEvents() action->setEnabled(canConfig); } - //an immutable constraint will always happen at startup - //make sure don't emit a change signal for nothing + // an immutable constraint will always happen at startup + // make sure don't emit a change signal for nothing if (d->oldImmutability != immutability()) { Q_EMIT immutabilityChanged(immutability()); } @@ -681,7 +675,7 @@ void Applet::flushPendingConstraintsEvents() QList Applet::contextualActions() { - //qCDebug(LOG_PLASMA) << "empty context actions"; + // qCDebug(LOG_PLASMA) << "empty context actions"; return d->script ? d->script->contextualActions() : QList(); } @@ -695,7 +689,7 @@ Types::FormFactor Applet::formFactor() const Containment *c = containment(); QObject *pw = qobject_cast(parent()); Plasma::Applet *parentApplet = qobject_cast(pw); - //assumption: this loop is usually is -really- short or doesn't run at all + // assumption: this loop is usually is -really- short or doesn't run at all while (!parentApplet && pw && pw->parent()) { pw = pw->parent(); parentApplet = qobject_cast(pw); @@ -742,8 +736,7 @@ void Applet::setGlobalShortcut(const QKeySequence &shortcut) d->activationAction->setText(i18n("Activate %1 Widget", title())); d->activationAction->setObjectName(QStringLiteral("activate widget %1").arg(id())); // NO I18N connect(d->activationAction, &QAction::triggered, this, &Applet::activated); - connect(d->activationAction, SIGNAL(changed()), - this, SLOT(globalShortcutChanged())); + connect(d->activationAction, SIGNAL(changed()), this, SLOT(globalShortcutChanged())); } else if (d->activationAction->shortcut() == shortcut) { return; } @@ -898,13 +891,13 @@ void Applet::timerEvent(QTimerEvent *event) bool Applet::isContainment() const { - //HACK: this is a special case for the systray - //containment in an applet that is not a containment + // HACK: this is a special case for the systray + // containment in an applet that is not a containment Applet *pa = qobject_cast(parent()); if (pa && !pa->isContainment()) { return true; } - //normal "acting as a containment" condition + // normal "acting as a containment" condition return qobject_cast(this) && qobject_cast(parent()); } diff --git a/src/plasma/applet.h b/src/plasma/applet.h index 0218a73ec..64d1415de 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -9,16 +9,16 @@ #ifndef PLASMA_APPLET_H #define PLASMA_APPLET_H -#include #include +#include #include #include #include +#include #include #include -#include #include @@ -27,7 +27,6 @@ class KConfigLoader; namespace Plasma { - class AppletPrivate; class Containment; class DataEngine; @@ -79,7 +78,7 @@ class PLASMA_EXPORT Applet : public QObject Q_PROPERTY(Plasma::Types::BackgroundHints effectiveBackgroundHints READ effectiveBackgroundHints NOTIFY effectiveBackgroundHintsChanged FINAL) public: -//CONSTRUCTORS + // CONSTRUCTORS /** * @param parent the QObject this applet is parented to * @param serviceId the name of the .desktop file containing the @@ -114,7 +113,7 @@ public: ~Applet() override; -//BOOKKEEPING + // BOOKKEEPING /** * @return the id of this applet */ @@ -182,14 +181,14 @@ public: */ Types::ContainmentDisplayHints containmentDisplayHints() const; -//CONFIGURATION + // CONFIGURATION /** - * Returns the KConfigGroup to access the applets configuration. - * - * This config object will write to an instance - * specific config file named \\rc - * in the Plasma appdata directory. - **/ + * Returns the KConfigGroup to access the applets configuration. + * + * This config object will write to an instance + * specific config file named \\rc + * in the Plasma appdata directory. + **/ KConfigGroup config() const; /** @@ -259,7 +258,7 @@ public: */ void setUserConfiguring(bool configuring); -//UTILS +// UTILS #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) /** * Accessor for the associated Package object if any. @@ -290,7 +289,7 @@ public: */ void updateConstraints(Plasma::Types::Constraints constraints = Plasma::Types::AllConstraints); -//METADATA +// METADATA #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) /** * @return metadata information about this plugin @@ -406,12 +405,13 @@ public: void setUserBackgroundHints(Plasma::Types::BackgroundHints hint); /** - * The effective background hints the applet will have: it will follow userBackgroundHints only if backgroundHints has the Plasma::Types::ConfigurableBackground flag set + * The effective background hints the applet will have: it will follow userBackgroundHints only if backgroundHints has the + * Plasma::Types::ConfigurableBackground flag set * @since 5.65 */ Plasma::Types::BackgroundHints effectiveBackgroundHints() const; -//ACTIONS + // ACTIONS /** * Returns a list of context-related QAction instances. * @@ -439,7 +439,7 @@ public: */ QKeySequence globalShortcut() const; -// ASSOCIATED APPLICATION + // ASSOCIATED APPLICATION /** * Sets an application associated to this applet, that will be * regarded as a full view of what is represented in the applet @@ -480,14 +480,14 @@ public: */ bool hasValidAssociatedApplication() const; -//Completely UI-specific, remove or move to scriptengine + // Completely UI-specific, remove or move to scriptengine /** * @return true if this plasmoid provides a GUI configuration **/ bool hasConfigurationInterface() const; Q_SIGNALS: -//BOOKEEPING + // BOOKEEPING /** * Emitted when the immutability changes * @since 4.4 @@ -543,7 +543,7 @@ Q_SIGNALS: */ void effectiveBackgroundHintsChanged(); -//CONFIGURATION + // CONFIGURATION /** * Emitted when an applet has changed values in its configuration * and wishes for them to be saved at the next save point. As this implies @@ -559,7 +559,7 @@ Q_SIGNALS: */ void userConfiguringChanged(bool configuring); -//ACTIONS + // ACTIONS /** * Emitted just before the contextual actions are about to show * For instance just before the context menu containing the actions @@ -573,7 +573,7 @@ Q_SIGNALS: */ void activated(); -//TODO: fix usage in containment, port to QObject::destroyed + // TODO: fix usage in containment, port to QObject::destroyed /** * Emitted when the applet is deleted */ @@ -599,7 +599,7 @@ Q_SIGNALS: void configurationRequiredChanged(bool needsConfig, const QString &reason); public Q_SLOTS: -//BOOKKEEPING + // BOOKKEEPING /** * Call this method when the applet fails to launch properly. An * optional reason can be provided. @@ -635,14 +635,14 @@ public Q_SLOTS: */ void setStatus(const Types::ItemStatus stat); -//CONFIGURATION + // CONFIGURATION /** * Called when applet configuration values have changed. */ - //TODO KF6: make it not a slot anymore and protected + // TODO KF6: make it not a slot anymore and protected virtual void configChanged(); -//UTILS + // UTILS /** * Sends all pending constraints updates to the applet. Will usually * be called automatically, but can also be called manually if needed. @@ -661,19 +661,19 @@ public Q_SLOTS: **/ virtual void init(); -//ASSOCIATED APPLICATION + // ASSOCIATED APPLICATION /** - * Open the application associated to this applet, if it's not set - * but some urls are, open those urls with the proper application - * for their mimetype - * @see setAssociatedApplication() - * @see setAssociatedApplicationUrls() - * @since 4.4 - */ + * Open the application associated to this applet, if it's not set + * but some urls are, open those urls with the proper application + * for their mimetype + * @see setAssociatedApplication() + * @see setAssociatedApplicationUrls() + * @since 4.4 + */ void runAssociatedApplication(); protected: -//CONSTRUCTORS + // CONSTRUCTORS /** * This constructor is to be used with the plugin loading systems * found in KPluginInfo and KService. The argument list is expected @@ -686,7 +686,7 @@ protected: */ Applet(QObject *parent, const QVariantList &args); -//CONFIGURATION + // CONFIGURATION /** * When called, the Applet should write any information needed as part * of the Applet's running state to the configuration object in config() @@ -722,7 +722,7 @@ protected: */ void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); -//UTILS + // UTILS /** * Called when any of the constraints for the applet have been updated. These constraints * range from notifying when the applet has officially "started up" to when geometry changes @@ -743,7 +743,7 @@ protected: */ virtual void constraintsEvent(Plasma::Types::Constraints constraints); -//TODO: timerEvent should go into AppletPrivate + // TODO: timerEvent should go into AppletPrivate /** * Reimplemented from QObject */ @@ -769,7 +769,7 @@ private: AppletPrivate *const d; - //Corona needs to access setLaunchErrorMessage and init + // Corona needs to access setLaunchErrorMessage and init friend class Corona; friend class CoronaPrivate; friend class Containment; @@ -787,12 +787,12 @@ private: /** * Register an applet when it is contained in a loadable module */ -#define K_EXPORT_PLASMA_APPLET(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) \ +#define K_EXPORT_PLASMA_APPLET(libname, classname) \ + K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -#define K_EXPORT_PLASMA_APPLET_WITH_JSON(libname, classname, jsonFile) \ - K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ +#define K_EXPORT_PLASMA_APPLET_WITH_JSON(libname, classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // multiple inclusion guard diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 37549f15b..a940f248a 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -13,23 +13,23 @@ #include "config-plasma.h" #include +#include #include #include -#include #include +#include #include #include -#include #include -#include -#include #include +#include +#include #include "containmentactions.h" #include "corona.h" -#include "pluginloader.h" #include "debug_p.h" +#include "pluginloader.h" #include "private/applet_p.h" @@ -37,12 +37,9 @@ namespace Plasma { - -Containment::Containment(QObject *parent, - const QString &serviceId, - uint containmentId) - : Applet(parent, serviceId, containmentId), - d(new ContainmentPrivate(this)) +Containment::Containment(QObject *parent, const QString &serviceId, uint containmentId) + : Applet(parent, serviceId, containmentId) + , d(new ContainmentPrivate(this)) { // WARNING: do not access config() OR globalConfig() in this method! // that requires a scene, which is not available at this point @@ -51,8 +48,8 @@ Containment::Containment(QObject *parent, } Containment::Containment(QObject *parent, const QVariantList &args) - : Applet(parent, args), - d(new ContainmentPrivate(this)) + : Applet(parent, args) + , d(new ContainmentPrivate(this)) { // WARNING: do not access config() OR globalConfig() in this method! // that requires a scene, which is not available at this point @@ -60,8 +57,8 @@ Containment::Containment(QObject *parent, const QVariantList &args) } Containment::Containment(const KPluginMetaData &md, uint appletId) - : Applet(md, nullptr, appletId), - d(new ContainmentPrivate(this)) + : Applet(md, nullptr, appletId) + , d(new ContainmentPrivate(this)) { // WARNING: do not access config() OR globalConfig() in this method! // that requires a scene, which is not available at this point @@ -80,8 +77,8 @@ void Containment::init() static_cast(this)->d->setupScripting(); if (d->type == Types::NoContainmentType) { - //setContainmentType(Plasma::Types::DesktopContainment); - //Try to determine the containment type. It must be done as soon as possible + // setContainmentType(Plasma::Types::DesktopContainment); + // Try to determine the containment type. It must be done as soon as possible QString type = pluginMetaData().value(QStringLiteral("X-Plasma-ContainmentType")); if (type == QLatin1String("Panel")) { @@ -90,18 +87,18 @@ void Containment::init() setContainmentType(Plasma::Types::CustomContainment); } else if (type == QLatin1String("CustomPanel")) { setContainmentType(Plasma::Types::CustomPanelContainment); - //default to desktop + // default to desktop } else { setContainmentType(Plasma::Types::DesktopContainment); } } - //connect actions + // connect actions ContainmentPrivate::addDefaultActions(actions(), this); bool unlocked = immutability() == Types::Mutable; - //fix the text of the actions that need title() - //btw, do we really want to use title() when it's a desktopcontainment? + // fix the text of the actions that need title() + // btw, do we really want to use title() when it's a desktopcontainment? QAction *closeApplet = actions()->action(QStringLiteral("remove")); if (closeApplet) { closeApplet->setText(i18nc("%1 is the name of the applet", "Remove %1", title())); @@ -126,14 +123,14 @@ void Containment::init() if (immutability() != Types::SystemImmutable && corona()) { QAction *lockDesktopAction = corona()->actions()->action(QStringLiteral("lock widgets")); - //keep a pointer so nobody notices it moved to corona + // keep a pointer so nobody notices it moved to corona if (lockDesktopAction) { actions()->addAction(QStringLiteral("lock widgets"), lockDesktopAction); } } - //HACK: this is valid only in the systray case - connect(this, &Containment::configureRequested, this, [=] (Plasma::Applet *a) { + // HACK: this is valid only in the systray case + connect(this, &Containment::configureRequested, this, [=](Plasma::Applet *a) { if (Plasma::Applet *p = qobject_cast(parent())) { Q_EMIT p->containment()->configureRequested(a); } @@ -176,28 +173,28 @@ void Containment::restore(KConfigGroup &group) KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins"); cfg = KConfigGroup(&cfg, QString::number(containmentType())); - //qCDebug(LOG_PLASMA) << cfg.keyList(); + // qCDebug(LOG_PLASMA) << cfg.keyList(); if (cfg.exists()) { - const auto keyList = cfg.keyList(); + const auto keyList = cfg.keyList(); for (const QString &key : keyList) { - //qCDebug(LOG_PLASMA) << "loading" << key; + // qCDebug(LOG_PLASMA) << "loading" << key; setContainmentActions(key, cfg.readEntry(key, QString())); } - } else { //shell defaults + } else { // shell defaults KConfigGroup defaultActionsCfg; switch (d->type) { - case Plasma::Types::PanelContainment: - /* fall through*/ - case Plasma::Types::CustomPanelContainment: - defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), "Panel"); - break; - case Plasma::Types::DesktopContainment: - defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), "Desktop"); - break; - default: - //for any other type of containment, there are no defaults - break; + case Plasma::Types::PanelContainment: + /* fall through*/ + case Plasma::Types::CustomPanelContainment: + defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), "Panel"); + break; + case Plasma::Types::DesktopContainment: + defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->kPackage().filePath("defaults")), "Desktop"); + break; + default: + // for any other type of containment, there are no defaults + break; } if (defaultActionsCfg.isValid()) { defaultActionsCfg = KConfigGroup(&defaultActionsCfg, "ContainmentActions"); @@ -233,7 +230,7 @@ void Containment::save(KConfigGroup &g) const // locking is saved in Applet::save Applet::save(group); -// group.writeEntry("screen", d->screen); + // group.writeEntry("screen", d->screen); group.writeEntry("lastScreen", d->lastScreen); group.writeEntry("formfactor", (int)d->formFactor); group.writeEntry("location", (int)d->location); @@ -257,7 +254,7 @@ void Containment::restoreContents(KConfigGroup &group) { KConfigGroup applets(&group, "Applets"); - //restore the applets ordered by id + // restore the applets ordered by id QStringList groups = applets.groupList(); std::sort(groups.begin(), groups.end()); @@ -265,7 +262,7 @@ void Containment::restoreContents(KConfigGroup &group) // are added from left to right or top to bottom for a panel containment QList appletConfigs; for (const QString &appletGroup : qAsConst(groups)) { - //qCDebug(LOG_PLASMA) << "reading from applet group" << appletGroup; + // qCDebug(LOG_PLASMA) << "reading from applet group" << appletGroup; KConfigGroup appletConfig(&applets, appletGroup); appletConfigs.append(appletConfig); } @@ -284,7 +281,7 @@ void Containment::restoreContents(KConfigGroup &group) d->createApplet(plugin, QVariantList(), appId); } - //if there are no applets, none of them is "loading" + // if there are no applets, none of them is "loading" if (Containment::applets().isEmpty()) { d->appletsUiReady = true; } @@ -313,9 +310,9 @@ void Containment::setContainmentType(Plasma::Types::ContainmentType type) Corona *Containment::corona() const { - if(Plasma::Corona* corona = qobject_cast(parent())) { + if (Plasma::Corona *corona = qobject_cast(parent())) { return corona; - //case in which this containment is child of an applet, hello systray :) + // case in which this containment is child of an applet, hello systray :) } else { Plasma::Applet *parentApplet = qobject_cast(parent()); if (parentApplet && parentApplet->containment()) { @@ -332,7 +329,7 @@ void Containment::setFormFactor(Types::FormFactor formFactor) return; } - //qCDebug(LOG_PLASMA) << "switching FF to " << formFactor; + // qCDebug(LOG_PLASMA) << "switching FF to " << formFactor; d->formFactor = formFactor; updateConstraints(Plasma::Types::FormFactorConstraint); @@ -413,14 +410,14 @@ void Containment::addApplet(Applet *applet) applet->setParent(this); // now move the old config to the new location - //FIXME: this doesn't seem to get the actual main config group containing plugin=, etc + // FIXME: this doesn't seem to get the actual main config group containing plugin=, etc KConfigGroup c = config().group("Applets").group(QString::number(applet->id())); oldConfig.reparent(&c); applet->d->resetConfigurationObject(); disconnect(applet, &Applet::activated, currentContainment, &Applet::activated); - //change the group to its configloader, if any - //FIXME: this is very, very brutal + // change the group to its configloader, if any + // FIXME: this is very, very brutal if (applet->configScheme()) { const QString oldGroupPrefix = QStringLiteral("Containments") + QString::number(currentContainment->id()) + QStringLiteral("Applets"); const QString newGroupPrefix = QStringLiteral("Containments") + QString::number(id()) + QStringLiteral("Applets"); @@ -436,8 +433,8 @@ void Containment::addApplet(Applet *applet) applet->setParent(this); } - //make sure the applets are sorted by id - auto position = std::lower_bound(d->applets.begin(), d->applets.end(), applet, [](Plasma::Applet *a1, Plasma::Applet *a2) { + // make sure the applets are sorted by id + auto position = std::lower_bound(d->applets.begin(), d->applets.end(), applet, [](Plasma::Applet *a1, Plasma::Applet *a2) { return a1->id() < a2->id(); }); d->applets.insert(position, applet); @@ -447,7 +444,7 @@ void Containment::addApplet(Applet *applet) } connect(applet, &Applet::configNeedsSaving, this, &Applet::configNeedsSaving); - connect(applet, SIGNAL(appletDeleted(Plasma::Applet*)), this, SLOT(appletDeleted(Plasma::Applet*))); + connect(applet, SIGNAL(appletDeleted(Plasma::Applet *)), this, SLOT(appletDeleted(Plasma::Applet *))); connect(applet, SIGNAL(statusChanged(Plasma::Types::ItemStatus)), this, SLOT(checkStatus(Plasma::Types::ItemStatus))); connect(applet, &Applet::activated, this, &Applet::activated); connect(this, &Containment::containmentDisplayHintsChanged, applet, &Applet::containmentDisplayHintsChanged); @@ -466,7 +463,7 @@ void Containment::addApplet(Applet *applet) applet->save(*applet->d->mainConfigGroup()); Q_EMIT configNeedsSaving(); } - //FIXME: an on-appear animation would be nice to have again + // FIXME: an on-appear animation would be nice to have again } applet->updateConstraints(Plasma::Types::AllConstraints); @@ -490,7 +487,7 @@ QList Containment::applets() const int Containment::screen() const { Q_ASSERT(corona()); - if (Corona* c = corona()) { + if (Corona *c = corona()) { return c->screenForContainment(this); } else { return -1; @@ -534,9 +531,9 @@ void Containment::setContainmentActions(const QString &trigger, const QString &p if (pluginName.isEmpty()) { cfg.deleteEntry(trigger); } else if (plugin) { - //it already existed, just reload config - plugin->setContainment(this); //to be safe - //FIXME make a truly unique config group + // it already existed, just reload config + plugin->setContainment(this); // to be safe + // FIXME make a truly unique config group KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger); plugin->restore(pluginConfig); @@ -550,7 +547,7 @@ void Containment::setContainmentActions(const QString &trigger, const QString &p KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger); plugin->restore(pluginConfig); } else { - //bad plugin... gets removed. is this a feature or a bug? + // bad plugin... gets removed. is this a feature or a bug? cfg.deleteEntry(trigger); } } diff --git a/src/plasma/containment.h b/src/plasma/containment.h index 8ee3925f6..cb40f8483 100644 --- a/src/plasma/containment.h +++ b/src/plasma/containment.h @@ -14,7 +14,6 @@ namespace Plasma { - class DataEngine; class Package; class Corona; @@ -56,9 +55,7 @@ public: * @param containmentId a unique id used to differentiate between multiple * instances of the same Applet type */ - explicit Containment(QObject *parent = nullptr, - const QString &serviceId = QString(), - uint containmentId = 0); + explicit Containment(QObject *parent = nullptr, const QString &serviceId = QString(), uint containmentId = 0); /** * This constructor is to be used with the plugin loading systems diff --git a/src/plasma/containmentactions.cpp b/src/plasma/containmentactions.cpp index bc3ff95cd..35154d2d5 100644 --- a/src/plasma/containmentactions.cpp +++ b/src/plasma/containmentactions.cpp @@ -7,22 +7,21 @@ #include "containmentactions.h" #include "containment.h" -#include "private/containmentactions_p.h" #include "private/containment_p.h" +#include "private/containmentactions_p.h" +#include #include #include #include -#include -#include #include +#include #include "version.h" namespace Plasma { - ContainmentActions::ContainmentActions(QObject *parentObject) : d(new ContainmentActionsPrivate({}, this)) { @@ -84,17 +83,17 @@ QWidget *ContainmentActions::createConfigurationInterface(QWidget *parent) void ContainmentActions::configurationAccepted() { - //do nothing by default + // do nothing by default } void ContainmentActions::performNextAction() { - //do nothing by default, implement in subclasses + // do nothing by default, implement in subclasses } void ContainmentActions::performPreviousAction() { - //do nothing by default, implement in subclasses + // do nothing by default, implement in subclasses } QList ContainmentActions::contextualActions() diff --git a/src/plasma/containmentactions.h b/src/plasma/containmentactions.h index c86f7905c..693e658fe 100644 --- a/src/plasma/containmentactions.h +++ b/src/plasma/containmentactions.h @@ -19,7 +19,6 @@ class KPluginMetaData; namespace Plasma { - class DataEngine; class Containment; class ContainmentActionsPrivate; @@ -155,8 +154,8 @@ private: * Register a containmentactions when it is contained in a loadable module */ -#define K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(libname, classname, jsonFile) \ - K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ +#define K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(libname, classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // PLASMA_CONTAINMENTACTIONS_H diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp index 8ba30b1e3..0c3f5afe7 100644 --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -13,32 +13,31 @@ #include #include #include -#include #include +#include #include -#include #include #include +#include #include "containment.h" -#include "pluginloader.h" +#include "debug_p.h" #include "packagestructure.h" +#include "pluginloader.h" #include "private/applet_p.h" #include "private/containment_p.h" #include "private/package_p.h" #include "private/timetracker.h" -#include "debug_p.h" using namespace Plasma; namespace Plasma { - Corona::Corona(QObject *parent) - : QObject(parent), - d(new CoronaPrivate(this)) + : QObject(parent) + , d(new CoronaPrivate(this)) { #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Corona ctor start"; @@ -103,7 +102,7 @@ void Corona::exportLayout(KConfigGroup &config, QList containment cg.deleteGroup(); } - //temporarily unlock so that removal works + // temporarily unlock so that removal works Types::ImmutabilityType oldImm = immutability(); d->immutability = Types::Mutable; @@ -113,8 +112,8 @@ void Corona::exportLayout(KConfigGroup &config, QList containment c->save(dummy); c->config().reparent(&dest); - //ensure the containment is unlocked - //this is done directly because we have to bypass any Types::SystemImmutable checks + // ensure the containment is unlocked + // this is done directly because we have to bypass any Types::SystemImmutable checks c->Applet::d->immutability = Types::Mutable; const auto lstApplet = c->applets(); for (Applet *a : lstApplet) { @@ -124,7 +123,7 @@ void Corona::exportLayout(KConfigGroup &config, QList containment c->destroy(); } - //restore immutability + // restore immutability d->immutability = oldImm; config.sync(); @@ -138,7 +137,7 @@ void Corona::requestConfigSync() // TODO: should we check into our immutability before doing this? - //NOTE: this is a pretty simplistic model: we simply save no more than CONFIG_SYNC_TIMEOUT + // 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 @@ -181,9 +180,8 @@ QList Corona::importLayout(const KConfigGroup &conf) Containment *Corona::containmentForScreen(int screen) const { for (Containment *containment : qAsConst(d->containments)) { - if (containment->screen() == screen && - (containment->containmentType() == Plasma::Types::DesktopContainment || - containment->containmentType() == Plasma::Types::CustomContainment)) { + if (containment->screen() == screen + && (containment->containmentType() == Plasma::Types::DesktopContainment || containment->containmentType() == Plasma::Types::CustomContainment)) { return containment; } } @@ -191,23 +189,18 @@ Containment *Corona::containmentForScreen(int screen) const return nullptr; } -Containment *Corona::containmentForScreen(int screen, - const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) +Containment *Corona::containmentForScreen(int screen, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) { return containmentForScreen(screen, QString(), defaultPluginIfNonExistent, defaultArgs); } -Containment *Corona::containmentForScreen(int screen, - const QString &activity, - const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) +Containment *Corona::containmentForScreen(int screen, const QString &activity, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs) { Containment *containment = nullptr; for (Containment *cont : qAsConst(d->containments)) { - if (cont->lastScreen() == screen && - (cont->activity().isEmpty() || cont->activity() == activity) && - (cont->containmentType() == Plasma::Types::DesktopContainment || - cont->containmentType() == Plasma::Types::CustomContainment)) { + if (cont->lastScreen() == screen && (cont->activity().isEmpty() || cont->activity() == activity) + && (cont->containmentType() == Plasma::Types::DesktopContainment || cont->containmentType() == Plasma::Types::CustomContainment)) { containment = cont; } } @@ -237,12 +230,10 @@ QList Corona::containmentsForActivity(const QString &activity) 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);} ); + 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; } @@ -255,12 +246,10 @@ QList Corona::containmentsForScreen(int screen) 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);} ); + 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; } @@ -324,7 +313,7 @@ QRect Corona::availableScreenRect(int id) const void Corona::loadDefaultLayout() { - //Default implementation does nothing + // Default implementation does nothing } Types::ImmutabilityType Corona::immutability() const @@ -343,10 +332,10 @@ void Corona::setImmutability(const Types::ImmutabilityType immutable) #endif d->immutability = immutable; d->updateContainmentImmutability(); - //tell non-containments that might care (like plasmaapp or a custom corona) + // tell non-containments that might care (like plasmaapp or a custom corona) Q_EMIT immutabilityChanged(immutable); - //update our actions + // update our actions QAction *action = d->actions.action(QStringLiteral("lock widgets")); if (action) { if (d->immutability == Types::SystemImmutable) { @@ -421,13 +410,11 @@ bool Corona::isEditMode() const QList Corona::freeEdges(int screen) const { QList freeEdges; - freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge - << Plasma::Types::LeftEdge << Plasma::Types::RightEdge; + freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge << Plasma::Types::LeftEdge << Plasma::Types::RightEdge; const auto containments = this->containments(); for (Containment *containment : containments) { - if (containment->screen() == screen && - freeEdges.contains(containment->location())) { + if (containment->screen() == screen && freeEdges.contains(containment->location())) { freeEdges.removeAll(containment->location()); } } @@ -441,14 +428,14 @@ KActionCollection *Corona::actions() const } CoronaPrivate::CoronaPrivate(Corona *corona) - : q(corona), - immutability(Types::Mutable), - config(nullptr), - configSyncTimer(new QTimer(corona)), - actions(corona), - containmentsStarting(0) + : q(corona) + , immutability(Types::Mutable) + , config(nullptr) + , configSyncTimer(new QTimer(corona)) + , actions(corona) + , containmentsStarting(0) { - //TODO: make Package path configurable + // TODO: make Package path configurable if (QCoreApplication::instance()) { configName = QCoreApplication::instance()->applicationName() + QStringLiteral("-appletsrc"); @@ -469,7 +456,7 @@ void CoronaPrivate::init() configSyncTimer->setSingleShot(true); QObject::connect(configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig())); - //some common actions + // some common actions actions.setConfigGroup(QStringLiteral("Shortcuts")); QAction *lockAction = actions.add(QStringLiteral("lock widgets")); @@ -481,12 +468,12 @@ void CoronaPrivate::init() lockAction->setShortcut(QKeySequence(QStringLiteral("alt+d, l"))); 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 + // fake containment/applet actions + KActionCollection *containmentActions = AppletPrivate::defaultActions(q); // containment has to start with applet stuff + ContainmentPrivate::addDefaultActions(containmentActions); // now it's really containment QAction *editAction = actions.add(QStringLiteral("edit mode")); - QObject::connect(editAction, &QAction::triggered, q, [this] () { + QObject::connect(editAction, &QAction::triggered, q, [this]() { q->setEditMode(!q->isEditMode()); }); editAction->setText(i18n("Enter Edit Mode")); @@ -586,7 +573,7 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi if (lastScreen >= 0) { containment->d->lastScreen = lastScreen; } - //if it's a dummy containment, just say its ui is ready, not blocking the corona + // if it's a dummy containment, just say its ui is ready, not blocking the corona applet->updateConstraints(Plasma::Types::UiReadyConstraint); // we want to provide something and don't care about the failure to launch @@ -601,18 +588,15 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi conf.deleteGroup(); } - //make sure the containments are sorted by id - auto position = std::lower_bound(containments.begin(), containments.end(), containment, [](Plasma::Containment *c1, Plasma::Containment *c2) { + // 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); - QObject::connect(containment, SIGNAL(destroyed(QObject*)), - q, SLOT(containmentDestroyed(QObject*))); - QObject::connect(containment, &Applet::configNeedsSaving, - q, &Corona::requestConfigSync); - QObject::connect(containment, &Containment::screenChanged, - q, &Corona::screenOwnerChanged); + QObject::connect(containment, SIGNAL(destroyed(QObject *)), q, SLOT(containmentDestroyed(QObject *))); + QObject::connect(containment, &Applet::configNeedsSaving, q, &Corona::requestConfigSync); + QObject::connect(containment, &Containment::screenChanged, q, &Corona::screenOwnerChanged); if (!delayedInit) { containment->init(); @@ -623,7 +607,7 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi q->requestConfigSync(); containment->flushPendingConstraintsEvents(); Q_EMIT q->containmentAdded(containment); - //if id = 0 a new containment has been created, not restored + // if id = 0 a new containment has been created, not restored if (id == 0) { Q_EMIT q->containmentCreated(containment); } @@ -671,9 +655,10 @@ QList CoronaPrivate::importLayout(const KConfigGroup &con containmentConfig.copyTo(&realConf); } - //qCDebug(LOG_PLASMA) << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group; + // qCDebug(LOG_PLASMA) << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group; #ifndef NDEBUG - // qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin", QString()); + // qCDebug(LOG_PLASMA) << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin", + // QString()); #endif Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, -1); if (!c) { @@ -701,7 +686,9 @@ void CoronaPrivate::notifyContainmentsReady() for (Containment *containment : qAsConst(containments)) { if (!containment->isUiReady() && containment->screen() >= 0) { ++containmentsStarting; - QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { containmentReady(ready); } ); + QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { + containmentReady(ready); + }); } } diff --git a/src/plasma/corona.h b/src/plasma/corona.h index 553fdd2a6..7b4328b3d 100644 --- a/src/plasma/corona.h +++ b/src/plasma/corona.h @@ -17,7 +17,6 @@ class QAction; namespace Plasma { - class CoronaPrivate; /** @@ -125,12 +124,10 @@ public: * @param defaultArgs optional arguments to pass in when creating a Containment if needed * @since 5.45 */ - Containment *containmentForScreen(int screen, - const QString &activity, - const QString &defaultPluginIfNonExistent, - const QVariantList &defaultArgs = QVariantList()); + Containment * + containmentForScreen(int screen, const QString &activity, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs = QVariantList()); - //TODO KF6: add activity here, can't be done now as the overload would get confused + // TODO KF6: add activity here, can't be done now as the overload would get confused #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 46) /** * Returns the Containment, if any, for a given physical screen @@ -154,9 +151,7 @@ public: * @deprecated Since 5.46, use containmentForScreen(int, const QString &, const QString &, const QVariantList &) */ PLASMA_DEPRECATED_VERSION(5, 46, "Use Corona::containmentForScreen(int, const QString &, const QString &, const QVariantList &)") - Containment *containmentForScreen(int screen, - const QString &defaultPluginIfNonExistent, - const QVariantList &defaultArgs = QVariantList()); + Containment *containmentForScreen(int screen, const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs = QVariantList()); #endif /** @@ -258,7 +253,7 @@ public: Types::ImmutabilityType immutability() const; /** - * Set the Corona globally into "edit mode" + * Set the Corona globally into "edit mode" * Only when the corona is of mutable type can be set of edit mode. * This indicates the UI to make easy for the user to manipulate applets. * @param edit @@ -429,8 +424,8 @@ protected: * or successfully loaded. * @see addContainment **/ - Containment *createContainmentDelayed(const QString &name, - const QVariantList &args = QVariantList()); + Containment *createContainmentDelayed(const QString &name, const QVariantList &args = QVariantList()); + private: CoronaPrivate *const d; @@ -446,4 +441,3 @@ private: } // namespace Plasma #endif - diff --git a/src/plasma/datacontainer.cpp b/src/plasma/datacontainer.cpp index 3c2618e80..e3f482037 100644 --- a/src/plasma/datacontainer.cpp +++ b/src/plasma/datacontainer.cpp @@ -7,20 +7,18 @@ #include "private/datacontainer_p.h" #include "private/storage_p.h" -#include #include +#include #include -#include "plasma.h" #include "debug_p.h" - +#include "plasma.h" namespace Plasma { - DataContainer::DataContainer(QObject *parent) - : QObject(parent), - d(new DataContainerPrivate(this)) + : QObject(parent) + , d(new DataContainerPrivate(this)) { } @@ -45,10 +43,10 @@ void DataContainer::setData(const QString &key, const QVariant &value) d->dirty = true; d->updateTimer.start(); - //check if storage is enabled and if storage is needed. - //If it is not set to be stored,then this is the first - //setData() since the last time it was stored. This - //gives us only one singleShot timer. + // check if storage is enabled and if storage is needed. + // If it is not set to be stored,then this is the first + // setData() since the last time it was stored. This + // gives us only one singleShot timer. if (isStorageEnabled() || !needsToBeStored()) { d->storageTimer.start(180000, this); } @@ -93,10 +91,9 @@ bool DataContainer::visualizationIsConnected(QObject *visualization) const return d->relayObjects.contains(visualization); } -void DataContainer::connectVisualization(QObject *visualization, uint pollingInterval, - Plasma::Types::IntervalAlignment alignment) +void DataContainer::connectVisualization(QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment alignment) { - //qCDebug(LOG_PLASMA) << "connecting visualization" <::iterator objIt = d->relayObjects.find(visualization); bool connected = objIt != d->relayObjects.end(); @@ -106,77 +103,70 @@ void DataContainer::connectVisualization(QObject *visualization, uint pollingInt SignalRelay *relay = objIt.value(); if (relay) { // connected to a relay - //qCDebug(LOG_PLASMA) << " already connected, but to a relay"; + // qCDebug(LOG_PLASMA) << " already connected, but to a relay"; if (relay->m_interval == pollingInterval && relay->m_align == alignment) { - //qCDebug(LOG_PLASMA) << " already connected to a relay of the same interval of" + // qCDebug(LOG_PLASMA) << " already connected to a relay of the same interval of" // << pollingInterval << ", nothing to do"; return; } if (relay->receiverCount() == 1) { - //qCDebug(LOG_PLASMA) << " removing relay, as it is now unused"; + // qCDebug(LOG_PLASMA) << " removing relay, as it is now unused"; d->relays.remove(relay->m_interval); delete relay; } else { if (visualization->metaObject()->indexOfSlot("dataUpdated(QString,Plasma::DataEngine::Data)") >= 0) { - disconnect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), - visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); + disconnect(relay, + SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), + visualization, + SLOT(dataUpdated(QString, Plasma::DataEngine::Data))); } - //modelChanged is always emitted by the dataSource since there is no polling there + // modelChanged is always emitted by the dataSource since there is no polling there if (visualization->metaObject()->indexOfSlot("modelChanged(QString,QAbstractItemModel*)") >= 0) { - disconnect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), - visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); + disconnect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); } - //relay->isUnused(); + // relay->isUnused(); } } else if (pollingInterval < 1) { // the visualization was connected already, but not to a relay // and it still doesn't want to connect to a relay, so we have // nothing to do! - //qCDebug(LOG_PLASMA) << " already connected, nothing to do"; + // qCDebug(LOG_PLASMA) << " already connected, nothing to do"; return; } else { if (visualization->metaObject()->indexOfSlot("dataUpdated(QString,Plasma::DataEngine::Data)") >= 0) { - disconnect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), - visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); + disconnect(this, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString, Plasma::DataEngine::Data))); } if (visualization->metaObject()->indexOfSlot("modelChanged(QString,QAbstractItemModel*)") >= 0) { - disconnect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), - visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); + disconnect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); } } } else { - connect(visualization, &QObject::destroyed, - this, &DataContainer::disconnectVisualization); //, Qt::QueuedConnection); + connect(visualization, &QObject::destroyed, this, &DataContainer::disconnectVisualization); //, Qt::QueuedConnection); } if (pollingInterval < 1) { - //qCDebug(LOG_PLASMA) << " connecting directly"; + // qCDebug(LOG_PLASMA) << " connecting directly"; d->relayObjects[visualization] = nullptr; if (visualization->metaObject()->indexOfSlot("dataUpdated(QString,Plasma::DataEngine::Data)") >= 0) { - connect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), - visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); + connect(this, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString, Plasma::DataEngine::Data))); } if (visualization->metaObject()->indexOfSlot("modelChanged(QString,QAbstractItemModel*)") >= 0) { - connect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), - visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); + connect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); } } else { - //qCDebug(LOG_PLASMA) << " connecting to a relay"; + // qCDebug(LOG_PLASMA) << " connecting to a relay"; // we only want to do an immediate update if this is not the first object to connect to us // if it is the first visualization, then the source will already have been populated // engine's sourceRequested method bool immediateUpdate = connected || d->relayObjects.count() > 1; - SignalRelay *relay = d->signalRelay(this, visualization, pollingInterval, - alignment, immediateUpdate); + SignalRelay *relay = d->signalRelay(this, visualization, pollingInterval, alignment, immediateUpdate); if (visualization->metaObject()->indexOfSlot("dataUpdated(QString,Plasma::DataEngine::Data)") >= 0) { - connect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), - visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); + connect(relay, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString, Plasma::DataEngine::Data))); } - //modelChanged is always emitted by the dataSource since there is no polling there + // modelChanged is always emitted by the dataSource since there is no polling there if (visualization->metaObject()->indexOfSlot("modelChanged(QString,QAbstractItemModel*)") >= 0) { - connect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), - visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); + connect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); } } } @@ -240,7 +230,7 @@ void DataContainerPrivate::store() StorageJob *job = static_cast(storage->startOperationCall(op)); job->setData(data); storageCount++; - QObject::connect(job, SIGNAL(finished(KJob*)), q, SLOT(storeJobFinished(KJob*))); + QObject::connect(job, SIGNAL(finished(KJob *)), q, SLOT(storeJobFinished(KJob *))); } void DataContainerPrivate::storeJobFinished(KJob *) @@ -266,8 +256,7 @@ void DataContainerPrivate::retrieve() QVariantMap retrieveGroup = storage->operationDescription(QStringLiteral("retrieve")); retrieveGroup[QStringLiteral("group")] = q->objectName(); ServiceJob *retrieveJob = storage->startOperationCall(retrieveGroup); - QObject::connect(retrieveJob, SIGNAL(result(KJob*)), q, - SLOT(populateFromStoredData(KJob*))); + QObject::connect(retrieveJob, SIGNAL(result(KJob *)), q, SLOT(populateFromStoredData(KJob *))); } void DataContainerPrivate::populateFromStoredData(KJob *job) @@ -290,7 +279,7 @@ void DataContainerPrivate::populateFromStoredData(KJob *job) } QVariantMap expireGroup = storage->operationDescription(QStringLiteral("expire")); - //expire things older than 4 days + // expire things older than 4 days expireGroup[QStringLiteral("age")] = 345600; storage->startOperationCall(expireGroup); } @@ -298,18 +287,15 @@ void DataContainerPrivate::populateFromStoredData(KJob *job) void DataContainer::disconnectVisualization(QObject *visualization) { QMap::iterator objIt = d->relayObjects.find(visualization); - disconnect(visualization, &QObject::destroyed, - this, &DataContainer::disconnectVisualization); //, Qt::QueuedConnection); + disconnect(visualization, &QObject::destroyed, this, &DataContainer::disconnectVisualization); //, Qt::QueuedConnection); if (objIt == d->relayObjects.end() || !objIt.value()) { // it is connected directly to the DataContainer itself if (visualization->metaObject()->indexOfSlot("dataUpdated(QString,Plasma::DataEngine::Data)") >= 0) { - disconnect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), - visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); + disconnect(this, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString, Plasma::DataEngine::Data))); } if (visualization->metaObject()->indexOfSlot("modelChanged(QString,QAbstractItemModel*)") >= 0) { - disconnect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), - visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); + disconnect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); } } else { SignalRelay *relay = objIt.value(); @@ -319,13 +305,11 @@ void DataContainer::disconnectVisualization(QObject *visualization) delete relay; } else { if (visualization->metaObject()->indexOfSlot("dataUpdated(QString,Plasma::DataEngine::Data)") >= 0) { - disconnect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)), - visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data))); + disconnect(relay, SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)), visualization, SLOT(dataUpdated(QString, Plasma::DataEngine::Data))); } - //modelChanged is always emitted by the dataSource since there is no polling there + // modelChanged is always emitted by the dataSource since there is no polling there if (visualization->metaObject()->indexOfSlot("modelChanged(QString,QAbstractItemModel*)") >= 0) { - disconnect(this, SIGNAL(modelChanged(QString,QAbstractItemModel*)), - visualization, SLOT(modelChanged(QString,QAbstractItemModel*))); + disconnect(this, SIGNAL(modelChanged(QString, QAbstractItemModel *)), visualization, SLOT(modelChanged(QString, QAbstractItemModel *))); } } } @@ -336,11 +320,11 @@ void DataContainer::disconnectVisualization(QObject *visualization) void DataContainer::checkForUpdate() { - //qCDebug(LOG_PLASMA) << objectName() << d->dirty; + // qCDebug(LOG_PLASMA) << objectName() << d->dirty; if (d->dirty) { Q_EMIT dataUpdated(objectName(), d->data); - //copy as checkQueueing can result in deletion of the relay + // copy as checkQueueing can result in deletion of the relay const auto relays = d->relays; for (SignalRelay *relay : relays) { relay->checkQueueing(); @@ -374,8 +358,7 @@ void DataContainer::setNeedsUpdate(bool update) bool DataContainer::isUsed() const { - return !d->relays.isEmpty() || - receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) > 0; + return !d->relays.isEmpty() || receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))) > 0; } void DataContainerPrivate::checkUsage() @@ -390,9 +373,9 @@ void DataContainer::timerEvent(QTimerEvent *event) if (event->timerId() == d->checkUsageTimer.timerId()) { if (!isUsed()) { // DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED! - //qCDebug(LOG_PLASMA) << objectName() << "is unused"; + // qCDebug(LOG_PLASMA) << objectName() << "is unused"; - //NOTE: Notifying visualization of the model destruction before actual deletion avoids crashes in some edge cases + // NOTE: Notifying visualization of the model destruction before actual deletion avoids crashes in some edge cases if (d->model) { d->model.clear(); Q_EMIT modelChanged(objectName(), nullptr); diff --git a/src/plasma/datacontainer.h b/src/plasma/datacontainer.h index f852ab582..d920edded 100644 --- a/src/plasma/datacontainer.h +++ b/src/plasma/datacontainer.h @@ -12,14 +12,13 @@ #include #include -#include #include +#include class QAbstractItemModel; namespace Plasma { - class DataContainerPrivate; /** @@ -130,8 +129,7 @@ public: * @param pollingInterval the time in milliseconds between updates * @param alignment the clock position to align updates to **/ - void connectVisualization(QObject *visualization, uint pollingInterval, - Plasma::Types::IntervalAlignment alignment); + void connectVisualization(QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment alignment); /** * sets this data container to be automatically stored. diff --git a/src/plasma/dataengine.cpp b/src/plasma/dataengine.cpp index 2fec69968..c3093f7ac 100644 --- a/src/plasma/dataengine.cpp +++ b/src/plasma/dataengine.cpp @@ -5,13 +5,13 @@ */ #include "dataengine.h" -#include "private/dataengine_p.h" #include "private/datacontainer_p.h" +#include "private/dataengine_p.h" #include #include -#include #include +#include #include #include @@ -23,23 +23,23 @@ #include "datacontainer.h" #include "package.h" #include "pluginloader.h" -#include "service.h" #include "scripting/dataenginescript.h" +#include "service.h" +#include "config-plasma.h" #include "private/service_p.h" #include "private/storage_p.h" -#include "config-plasma.h" namespace Plasma { - DataEngine::DataEngine(const KPluginInfo &plugin, QObject *parent) : DataEngine(plugin.toMetaData(), parent) -{} +{ +} DataEngine::DataEngine(const KPluginMetaData &plugin, QObject *parent) - : QObject(parent), - d(new DataEnginePrivate(this, plugin)) + : QObject(parent) + , d(new DataEnginePrivate(this, plugin)) { if (d->script) { d->setupScriptSupport(); @@ -51,8 +51,8 @@ DataEngine::DataEngine(const KPluginMetaData &plugin, QObject *parent) } DataEngine::DataEngine(QObject *parent, const QVariantList &args) - : QObject(parent), - d(new DataEnginePrivate(this, KPluginInfo(args).toMetaData(), args)) + : QObject(parent) + , d(new DataEnginePrivate(this, KPluginInfo(args).toMetaData(), args)) { if (d->script) { d->setupScriptSupport(); @@ -62,7 +62,7 @@ DataEngine::DataEngine(QObject *parent, const QVariantList &args) DataEngine::~DataEngine() { - //qCDebug(LOG_PLASMA) << objectName() << ": bye bye birdy! "; + // qCDebug(LOG_PLASMA) << objectName() << ": bye bye birdy! "; delete d; } @@ -97,11 +97,9 @@ KPluginMetaData DataEngine::metadata() const return d->dataEngineDescription; } -void DataEngine::connectSource(const QString &source, QObject *visualization, - uint pollingInterval, - Plasma::Types::IntervalAlignment intervalAlignment) const +void DataEngine::connectSource(const QString &source, QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment intervalAlignment) const { - //qCDebug(LOG_PLASMA) << "connectSource" << source; + // qCDebug(LOG_PLASMA) << "connectSource" << source; bool newSource; DataContainer *s = d->requestSource(source, &newSource); @@ -113,14 +111,12 @@ void DataEngine::connectSource(const QString &source, QObject *visualization, if (newSource && !s->data().isEmpty()) { newSource = false; } - d->connectSource(s, visualization, pollingInterval, intervalAlignment, - !newSource || pollingInterval > 0); - //qCDebug(LOG_PLASMA) << " ==> source connected"; + d->connectSource(s, visualization, pollingInterval, intervalAlignment, !newSource || pollingInterval > 0); + // qCDebug(LOG_PLASMA) << " ==> source connected"; } } -void DataEngine::connectAllSources(QObject *visualization, uint pollingInterval, - Plasma::Types::IntervalAlignment intervalAlignment) const +void DataEngine::connectAllSources(QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment intervalAlignment) const { for (DataContainer *s : qAsConst(d->sources)) { d->connectSource(s, visualization, pollingInterval, intervalAlignment); @@ -155,8 +151,8 @@ bool DataEngine::updateSourceEvent(const QString &source) if (d->script) { return d->script->updateSourceEvent(source); } else { - //qCDebug(LOG_PLASMA) << source; - return false; //TODO: should this be true to trigger, even needless, updates on every tick? + // qCDebug(LOG_PLASMA) << source; + return false; // TODO: should this be true to trigger, even needless, updates on every tick? } } @@ -258,9 +254,8 @@ void DataEngine::addSource(DataContainer *source) return; } - QObject::connect(source, SIGNAL(updateRequested(DataContainer*)), - this, SLOT(internalUpdateSource(DataContainer*))); - QObject::connect(source, SIGNAL(destroyed(QObject*)), this, SLOT(sourceDestroyed(QObject*))); + QObject::connect(source, SIGNAL(updateRequested(DataContainer *)), this, SLOT(internalUpdateSource(DataContainer *))); + QObject::connect(source, SIGNAL(destroyed(QObject *)), this, SLOT(sourceDestroyed(QObject *))); d->sources.insert(source->objectName(), source); Q_EMIT sourceAdded(source->objectName()); d->scheduleSourcesUpdated(); @@ -335,17 +330,17 @@ QHash DataEngine::containerDict() const void DataEngine::timerEvent(QTimerEvent *event) { - //qCDebug(LOG_PLASMA); + // qCDebug(LOG_PLASMA); if (event->timerId() == d->updateTimerId) { // if the freq update is less than 0, don't bother if (d->minPollingInterval < 0) { - //qCDebug(LOG_PLASMA) << "uh oh.. no polling allowed!"; + // qCDebug(LOG_PLASMA) << "uh oh.. no polling allowed!"; return; } // minPollingInterval if (d->updateTimer.elapsed() < d->minPollingInterval) { - //qCDebug(LOG_PLASMA) << "hey now.. slow down!"; + // qCDebug(LOG_PLASMA) << "hey now.. slow down!"; return; } @@ -370,7 +365,7 @@ void DataEngine::updateAllSources() QHashIterator it(d->sources); while (it.hasNext()) { it.next(); - //qCDebug(LOG_PLASMA) << "updating" << it.key(); + // qCDebug(LOG_PLASMA) << "updating" << it.key(); if (it.value()->isUsed()) { updateSourceEvent(it.key()); } @@ -403,15 +398,16 @@ void DataEngine::setStorageEnabled(const QString &source, bool store) // Private class implementations DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginMetaData &md, const QVariantList &args) - : q(e), - dataEngineDescription(md), - refCount(-1), // first ref - checkSourcesTimerId(0), - updateTimerId(0), - minPollingInterval(-1), - valid(false), - script(nullptr), - package(nullptr) + : q(e) + , dataEngineDescription(md) + , refCount(-1) + , // first ref + checkSourcesTimerId(0) + , updateTimerId(0) + , minPollingInterval(-1) + , valid(false) + , script(nullptr) + , package(nullptr) { updateTimer.start(); @@ -424,10 +420,9 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginMetaData &md, c QString api = dataEngineDescription.value(QStringLiteral("X-Plasma-API")); if (!api.isEmpty()) { - const QString path = - QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/dataengines/") + dataEngineDescription.pluginId(), - QStandardPaths::LocateDirectory); + const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/dataengines/") + dataEngineDescription.pluginId(), + QStandardPaths::LocateDirectory); package = new Package(PluginLoader::self()->loadPackage(QStringLiteral("Plasma/DataEngine"), api)); package->setPath(path); @@ -457,25 +452,24 @@ DataEnginePrivate::~DataEnginePrivate() void DataEnginePrivate::internalUpdateSource(DataContainer *source) { - if (minPollingInterval > 0 && - source->timeSinceLastUpdate() < (uint)minPollingInterval) { + if (minPollingInterval > 0 && source->timeSinceLastUpdate() < (uint)minPollingInterval) { // skip updating this source; it's been too soon - //qCDebug(LOG_PLASMA) << "internal update source is delaying" << source->timeSinceLastUpdate() << minPollingInterval; - //but fake an update so that the signalrelay that triggered this gets the data from the - //recent update. this way we don't have to worry about queuing - the relay will send a - //signal immediately and everyone else is undisturbed. + // qCDebug(LOG_PLASMA) << "internal update source is delaying" << source->timeSinceLastUpdate() << minPollingInterval; + // but fake an update so that the signalrelay that triggered this gets the data from the + // recent update. this way we don't have to worry about queuing - the relay will send a + // signal immediately and everyone else is undisturbed. source->setNeedsUpdate(); return; } if (q->updateSourceEvent(source->objectName())) { - //qCDebug(LOG_PLASMA) << "queuing an update"; + // qCDebug(LOG_PLASMA) << "queuing an update"; scheduleSourcesUpdated(); - }/* else { -#ifndef NDEBUG - // qCDebug(LOG_PLASMA) << "no update"; -#endif - }*/ + } /* else { + #ifndef NDEBUG + // qCDebug(LOG_PLASMA) << "no update"; + #endif + }*/ } void DataEnginePrivate::ref() @@ -505,23 +499,23 @@ DataContainer *DataEnginePrivate::source(const QString &sourceName, bool createW return nullptr; } - //qCDebug(LOG_PLASMA) << "DataEngine " << q->objectName() << ": could not find DataContainer " << sourceName << ", creating"; + // qCDebug(LOG_PLASMA) << "DataEngine " << q->objectName() << ": could not find DataContainer " << sourceName << ", creating"; DataContainer *s = new DataContainer(q); s->setObjectName(sourceName); sources.insert(sourceName, s); - QObject::connect(s, SIGNAL(destroyed(QObject*)), q, SLOT(sourceDestroyed(QObject*))); - QObject::connect(s, SIGNAL(updateRequested(DataContainer*)), - q, SLOT(internalUpdateSource(DataContainer*))); + QObject::connect(s, SIGNAL(destroyed(QObject *)), q, SLOT(sourceDestroyed(QObject *))); + QObject::connect(s, SIGNAL(updateRequested(DataContainer *)), q, SLOT(internalUpdateSource(DataContainer *))); return s; } -void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization, +void DataEnginePrivate::connectSource(DataContainer *s, + QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment align, bool immediateCall) { - //qCDebug(LOG_PLASMA) << "connect source called" << s->objectName() << "with interval" << pollingInterval; + // qCDebug(LOG_PLASMA) << "connect source called" << s->objectName() << "with interval" << pollingInterval; if (pollingInterval > 0) { // never more frequently than allowed, never more than 20 times per second @@ -535,21 +529,16 @@ void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization, if (immediateCall) { // we don't want to do an immediate call if we are simply // reconnecting - //qCDebug(LOG_PLASMA) << "immediate call requested, we have:" << s->visualizationIsConnected(visualization); - immediateCall = !s->data().isEmpty() && - !s->visualizationIsConnected(visualization); + // qCDebug(LOG_PLASMA) << "immediate call requested, we have:" << s->visualizationIsConnected(visualization); + immediateCall = !s->data().isEmpty() && !s->visualizationIsConnected(visualization); } s->connectVisualization(visualization, pollingInterval, align); if (immediateCall) { - QMetaObject::invokeMethod(visualization, "dataUpdated", - Q_ARG(QString, s->objectName()), - Q_ARG(Plasma::DataEngine::Data, s->data())); + QMetaObject::invokeMethod(visualization, "dataUpdated", Q_ARG(QString, s->objectName()), Q_ARG(Plasma::DataEngine::Data, s->data())); if (s->d->model) { - QMetaObject::invokeMethod(visualization, "modelChanged", - Q_ARG(QString, s->objectName()), - Q_ARG(QAbstractItemModel*, s->d->model.data())); + QMetaObject::invokeMethod(visualization, "modelChanged", Q_ARG(QString, s->objectName()), Q_ARG(QAbstractItemModel *, s->d->model.data())); } s->d->dirty = false; } @@ -574,7 +563,7 @@ DataContainer *DataEnginePrivate::requestSource(const QString &sourceName, bool *newSource = false; } - //qCDebug(LOG_PLASMA) << "requesting source " << sourceName; + // qCDebug(LOG_PLASMA) << "requesting source " << sourceName; DataContainer *s = source(sourceName, false); if (!s) { diff --git a/src/plasma/dataengine.h b/src/plasma/dataengine.h index 28ff50242..7d5bd024f 100644 --- a/src/plasma/dataengine.h +++ b/src/plasma/dataengine.h @@ -14,15 +14,14 @@ #include #include -#include #include #include +#include class QAbstractItemModel; namespace Plasma { - class DataContainer; class DataEngineScript; class Package; @@ -136,10 +135,10 @@ public: * If the data has not changed, no update will be sent. * @param intervalAlignment the number of ms to align the interval to **/ - Q_INVOKABLE void connectSource( - const QString &source, QObject *visualization, - uint pollingInterval = 0, - Plasma::Types::IntervalAlignment intervalAlignment = Types::NoAlignment) const; + Q_INVOKABLE void connectSource(const QString &source, + QObject *visualization, + uint pollingInterval = 0, + Plasma::Types::IntervalAlignment intervalAlignment = Types::NoAlignment) const; /** * Connects all currently existing sources to an object for data updates. @@ -169,9 +168,8 @@ public: * If the data has not changed, no update will be sent. * @param intervalAlignment the number of ms to align the interval to **/ - Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0, - Plasma::Types::IntervalAlignment intervalAlignment = - Types::NoAlignment) const; + Q_INVOKABLE void + connectAllSources(QObject *visualization, uint pollingInterval = 0, Plasma::Types::IntervalAlignment intervalAlignment = Types::NoAlignment) const; /** * Disconnects a source from an object that was receiving data updates. @@ -455,12 +453,12 @@ private: /** * Register a data engine when it is contained in a loadable module */ -#define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) \ +#define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \ + K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -#define K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(libname, classname, jsonFile) \ - K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ +#define K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(libname, classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // multiple inclusion guard diff --git a/src/plasma/dataengineconsumer.cpp b/src/plasma/dataengineconsumer.cpp index 043ff0ed6..e0535ffd0 100644 --- a/src/plasma/dataengineconsumer.cpp +++ b/src/plasma/dataengineconsumer.cpp @@ -13,13 +13,12 @@ #include +#include "debug_p.h" #include "private/dataenginemanager_p.h" #include "servicejob.h" -#include "debug_p.h" namespace Plasma { - void DataEngineConsumerPrivate::slotJobFinished(Plasma::ServiceJob *job) { #ifndef NDEBUG @@ -55,8 +54,7 @@ void DataEngineConsumerPrivate::slotServiceReady(Plasma::Service *plasmoidServic QVariantMap op = plasmoidService->operationDescription(QStringLiteral("DataEngine")); op[QStringLiteral("EngineName")] = engineNameForService.value(plasmoidService); plasmoidService->startOperationCall(op); - connect(plasmoidService, SIGNAL(finished(Plasma::ServiceJob*)), - this, SLOT(slotJobFinished(Plasma::ServiceJob*))); + connect(plasmoidService, SIGNAL(finished(Plasma::ServiceJob *)), this, SLOT(slotJobFinished(Plasma::ServiceJob *))); } DataEngineConsumer::DataEngineConsumer() @@ -90,4 +88,3 @@ DataEngine *DataEngineConsumer::dataEngine(const QString &name) } // namespace Plasma #include "private/moc_dataengineconsumer_p.cpp" - diff --git a/src/plasma/dataengineconsumer.h b/src/plasma/dataengineconsumer.h index c85afdb32..51fb3d837 100644 --- a/src/plasma/dataengineconsumer.h +++ b/src/plasma/dataengineconsumer.h @@ -13,7 +13,6 @@ namespace Plasma { - class DataEngine; class DataEngineConsumerPrivate; @@ -61,4 +60,3 @@ private: } // namespace Plasma #endif - diff --git a/src/plasma/framesvg.cpp b/src/plasma/framesvg.cpp index 5bc0244c4..8389f9d19 100644 --- a/src/plasma/framesvg.cpp +++ b/src/plasma/framesvg.cpp @@ -19,15 +19,14 @@ #include -#include "theme.h" -#include "private/svg_p.h" -#include "private/framesvg_helpers.h" #include "debug_p.h" +#include "private/framesvg_helpers.h" +#include "private/svg_p.h" +#include "theme.h" namespace Plasma { - -QHash> > FrameSvgPrivate::s_sharedFrames; +QHash>> FrameSvgPrivate::s_sharedFrames; // Any attempt to generate a frame whose width or height is larger than this // will be rejected @@ -39,8 +38,8 @@ FrameData::~FrameData() } FrameSvg::FrameSvg(QObject *parent) - : Svg(parent), - d(new FrameSvgPrivate(this)) + : Svg(parent) + , d(new FrameSvgPrivate(this)) { connect(this, &FrameSvg::repaintNeeded, this, std::bind(&FrameSvgPrivate::updateNeeded, d)); } @@ -127,8 +126,8 @@ void FrameSvg::setElementPrefix(const QString &prefix) bool FrameSvg::hasElementPrefix(const QString &prefix) const { - //for now it simply checks if a center element exists, - //because it could make sense for certain themes to not have all the elements + // for now it simply checks if a center element exists, + // because it could make sense for certain themes to not have all the elements if (prefix.isEmpty()) { return hasElement(QStringLiteral("center")); } @@ -212,7 +211,7 @@ qreal FrameSvg::marginSize(const Plasma::Types::MarginEdge edge) const case Plasma::Types::RightMargin: return d->frame->rightMargin; - //Plasma::BottomMargin + // Plasma::BottomMargin default: return d->frame->bottomMargin; } @@ -238,7 +237,7 @@ qreal FrameSvg::insetSize(const Plasma::Types::MarginEdge edge) const case Plasma::Types::RightMargin: return d->frame->insetRightMargin; - //Plasma::BottomMargin + // Plasma::BottomMargin default: return d->frame->insetBottomMargin; } @@ -264,7 +263,7 @@ qreal FrameSvg::fixedMarginSize(const Plasma::Types::MarginEdge edge) const case Plasma::Types::RightMargin: return d->frame->fixedRightMargin; - //Plasma::BottomMargin + // Plasma::BottomMargin default: return d->frame->fixedBottomMargin; } @@ -312,7 +311,7 @@ void FrameSvg::getInset(qreal &left, qreal &top, qreal &right, qreal &bottom) co QRectF FrameSvg::contentsRect() const { if (d->frame) { - QRectF rect(QPoint(0,0), d->frame->frameSize); + QRectF rect(QPoint(0, 0), d->frame->frameSize); return rect.adjusted(d->frame->leftMargin, d->frame->topMargin, -d->frame->rightMargin, -d->frame->bottomMargin); } else { return QRectF(); @@ -321,7 +320,7 @@ QRectF FrameSvg::contentsRect() const QPixmap FrameSvg::alphaMask() const { - //FIXME: the distinction between overlay and + // FIXME: the distinction between overlay and return d->alphaMask(); } @@ -334,14 +333,13 @@ QRegion FrameSvg::mask() const uint id = qHash(d->cacheId(d->frame.data(), QString()), SvgRectsCache::s_seed); - QRegion* obj = d->frame->cachedMasks.object(id); + QRegion *obj = d->frame->cachedMasks.object(id); if (!obj) { obj = new QRegion(QBitmap(d->alphaMask().mask())); result = *obj; d->frame->cachedMasks.insert(id, obj); - } - else { + } else { result = *obj; } return result; @@ -439,9 +437,8 @@ QPixmap FrameSvgPrivate::alphaMask() return maskFrame->cachedBackground; } - const bool shouldUpdate = maskFrame->enabledBorders != frame->enabledBorders - || maskFrame->frameSize != frameSize(frame.data()) - || maskFrame->imagePath != frame->imagePath; + const bool shouldUpdate = + maskFrame->enabledBorders != frame->enabledBorders || maskFrame->frameSize != frameSize(frame.data()) || maskFrame->imagePath != frame->imagePath; if (shouldUpdate) { maskFrame = lookupOrCreateMaskFrame(frame, maskPrefix, maskRequestedPrefix); if (!maskFrame->cachedBackground.isNull()) { @@ -457,7 +454,8 @@ QPixmap FrameSvgPrivate::alphaMask() return maskFrame->cachedBackground; } -QSharedPointer FrameSvgPrivate::lookupOrCreateMaskFrame(const QSharedPointer &frame, const QString &maskPrefix, const QString &maskRequestedPrefix) +QSharedPointer +FrameSvgPrivate::lookupOrCreateMaskFrame(const QSharedPointer &frame, const QString &maskPrefix, const QString &maskRequestedPrefix) { const uint key = qHash(cacheId(frame.data(), maskPrefix)); QSharedPointer mask = s_sharedFrames[q->theme()->d].value(key); @@ -492,7 +490,7 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer &frame) bool frameCached = !frame->cachedBackground.isNull(); bool overlayCached = false; - //TODO KF6: Kill Overlays + // TODO KF6: Kill Overlays const bool overlayAvailable = !frame->prefix.startsWith(QLatin1String("mask-")) && q->hasElement(frame->prefix % QLatin1String("overlay")); QPixmap overlay; if (q->isUsingRenderingCache()) { @@ -508,7 +506,7 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer &frame) generateFrameBackground(frame); } - //Overlays + // Overlays QSize overlaySize; QPoint actualOverlayPos = QPoint(0, 0); if (overlayAvailable && !overlayCached) { @@ -518,7 +516,7 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer &frame) actualOverlayPos.setX(frame->frameSize.width() - overlaySize.width()); } else if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-pos-bottom"))) { actualOverlayPos.setY(frame->frameSize.height() - overlaySize.height()); - //Stretched or Tiled? + // Stretched or Tiled? } else if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-stretch"))) { overlaySize = frameSize(frame).toSize(); } else { @@ -533,10 +531,9 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer &frame) overlay = alphaMask(); QPainter overlayPainter(&overlay); overlayPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); - //Tiling? - if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-horizontal")) || - q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-vertical"))) { - + // Tiling? + if (q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-horizontal")) + || q->hasElement(frame->prefix % QLatin1String("hint-overlay-tile-vertical"))) { QSize s = q->size(); q->resize(q->elementSize(frame->prefix % QLatin1String("overlay"))); @@ -562,7 +559,7 @@ void FrameSvgPrivate::generateBackground(const QSharedPointer &frame) void FrameSvgPrivate::generateFrameBackground(const QSharedPointer &frame) { - //qCDebug(LOG_PLASMA) << "generating background"; + // qCDebug(LOG_PLASMA) << "generating background"; const QSize size = frameSize(frame).toSize() * q->devicePixelRatio(); if (!size.isValid()) { @@ -585,10 +582,10 @@ void FrameSvgPrivate::generateFrameBackground(const QSharedPointer &f QRect contentRect = contentGeometry(frame, size); paintCenter(p, frame, contentRect, size); - paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::TopBorder, contentRect); - paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::TopBorder, contentRect); - paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::BottomBorder, contentRect); - paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::BottomBorder, contentRect); + paintCorner(p, frame, FrameSvg::LeftBorder | FrameSvg::TopBorder, contentRect); + paintCorner(p, frame, FrameSvg::RightBorder | FrameSvg::TopBorder, contentRect); + paintCorner(p, frame, FrameSvg::LeftBorder | FrameSvg::BottomBorder, contentRect); + paintCorner(p, frame, FrameSvg::RightBorder | FrameSvg::BottomBorder, contentRect); // Sides const int leftHeight = q->elementSize(frame->prefix % QLatin1String("left")).height(); @@ -605,11 +602,11 @@ void FrameSvgPrivate::generateFrameBackground(const QSharedPointer &f frame->cachedBackground.setDevicePixelRatio(q->devicePixelRatio()); } -QRect FrameSvgPrivate::contentGeometry(const QSharedPointer &frame, const QSize& size) const +QRect FrameSvgPrivate::contentGeometry(const QSharedPointer &frame, const QSize &size) const { const QSize contentSize(size.width() - frame->leftWidth * q->devicePixelRatio() - frame->rightWidth * q->devicePixelRatio(), size.height() - frame->topHeight * q->devicePixelRatio() - frame->bottomHeight * q->devicePixelRatio()); - QRect contentRect(QPoint(0,0), contentSize); + QRect contentRect(QPoint(0, 0), contentSize); if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(frame->prefix % QLatin1String("left"))) { contentRect.translate(frame->leftWidth * q->devicePixelRatio(), 0); } @@ -639,20 +636,20 @@ void FrameSvgPrivate::updateFrameData(uint lastModified, UpdateType updateType) newKey = qHash(cacheId(fd.data(), prefix)); - //reset frame to old values + // reset frame to old values fd->enabledBorders = oldBorders; fd->frameSize = currentSize; fd->imagePath = oldPath; - //FIXME: something more efficient than string comparison? + // FIXME: something more efficient than string comparison? if (oldKey == newKey) { return; } - //qCDebug(LOG_PLASMA) << "looking for" << newKey; + // qCDebug(LOG_PLASMA) << "looking for" << newKey; auto newFd = FrameSvgPrivate::s_sharedFrames[q->theme()->d].value(newKey); if (newFd) { - //qCDebug(LOG_PLASMA) << "FOUND IT!" << newFd->refcount; + // qCDebug(LOG_PLASMA) << "FOUND IT!" << newFd->refcount; // we've found a match, use that one Q_ASSERT(newKey == newFd.lock()->cacheId); frame = newFd; @@ -667,12 +664,12 @@ void FrameSvgPrivate::updateFrameData(uint lastModified, UpdateType updateType) frame = fd; fd->prefix = prefix; fd->requestedPrefix = requestedPrefix; - //updateSizes(); + // updateSizes(); fd->enabledBorders = enabledBorders; fd->frameSize = pendingFrameSize; fd->imagePath = q->imagePath(); fd->lastModified = lastModified; - //was fd just created empty now? + // was fd just created empty now? if (newKey == 0) { newKey = qHash(cacheId(fd.data(), prefix)); } @@ -688,7 +685,7 @@ void FrameSvgPrivate::updateFrameData(uint lastModified, UpdateType updateType) } } -void FrameSvgPrivate::paintCenter(QPainter& p, const QSharedPointer &frame, const QRect& contentRect, const QSize& fullSize) +void FrameSvgPrivate::paintCenter(QPainter &p, const QSharedPointer &frame, const QRect &contentRect, const QSize &fullSize) { if (!contentRect.isEmpty()) { const QString centerElementId = frame->prefix % QLatin1String("center"); @@ -699,7 +696,7 @@ void FrameSvgPrivate::paintCenter(QPainter& p, const QSharedPointer & QPainter centerPainter(¢er); centerPainter.setCompositionMode(QPainter::CompositionMode_Source); - q->paint(¢erPainter, QRect(QPoint(0, 0), centerTileSize),centerElementId); + q->paint(¢erPainter, QRect(QPoint(0, 0), centerTileSize), centerElementId); if (frame->composeOverBorder) { p.drawTiledPixmap(QRect(QPoint(0, 0), fullSize), center); @@ -708,8 +705,7 @@ void FrameSvgPrivate::paintCenter(QPainter& p, const QSharedPointer & } } else { if (frame->composeOverBorder) { - q->paint(&p, QRect(QPoint(0, 0), fullSize), - centerElementId); + q->paint(&p, QRect(QPoint(0, 0), fullSize), centerElementId); } else { q->paint(&p, FrameSvgHelpers::sectionRect(FrameSvg::NoBorder, contentRect, fullSize * q->devicePixelRatio()), centerElementId); } @@ -723,7 +719,11 @@ void FrameSvgPrivate::paintCenter(QPainter& p, const QSharedPointer & } } -void FrameSvgPrivate::paintBorder(QPainter& p, const QSharedPointer &frame, const FrameSvg::EnabledBorders borders, const QSize& size, const QRect& contentRect) const +void FrameSvgPrivate::paintBorder(QPainter &p, + const QSharedPointer &frame, + const FrameSvg::EnabledBorders borders, + const QSize &size, + const QRect &contentRect) const { QString side = frame->prefix % FrameSvgHelpers::borderToElementId(borders); if (frame->enabledBorders & borders && q->hasElement(side) && !size.isEmpty()) { @@ -742,7 +742,7 @@ void FrameSvgPrivate::paintBorder(QPainter& p, const QSharedPointer & } } -void FrameSvgPrivate::paintCorner(QPainter& p, const QSharedPointer &frame, Plasma::FrameSvg::EnabledBorders border, const QRect& contentRect) const +void FrameSvgPrivate::paintCorner(QPainter &p, const QSharedPointer &frame, Plasma::FrameSvg::EnabledBorders border, const QRect &contentRect) const { // Draw the corner only if both borders in both directions are enabled. if ((frame->enabledBorders & border) != border) { @@ -757,7 +757,16 @@ void FrameSvgPrivate::paintCorner(QPainter& p, const QSharedPointer & SvgPrivate::CacheId FrameSvgPrivate::cacheId(FrameData *frame, const QString &prefixToSave) const { const QSize size = frameSize(frame).toSize(); - return SvgPrivate::CacheId{double(size.width()), double(size.height()), frame->imagePath, prefixToSave, q->status(), q->devicePixelRatio(), q->scaleFactor(), q->colorGroup(), (uint)frame->enabledBorders, q->Svg::d->lastModified}; + return SvgPrivate::CacheId{double(size.width()), + double(size.height()), + frame->imagePath, + prefixToSave, + q->status(), + q->devicePixelRatio(), + q->scaleFactor(), + q->colorGroup(), + (uint)frame->enabledBorders, + q->Svg::d->lastModified}; } void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QPixmap &background, const QPixmap &overlay) @@ -766,19 +775,19 @@ void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QPixmap &bac return; } - //insert background + // insert background if (!frame) { return; } const uint id = qHash(cacheId(frame.data(), prefixToSave)); - //qCDebug(LOG_PLASMA)<<"Saving to cache frame"<theme()->insertIntoCache(QString::number(id), background, QString::number((qint64)q, 16) % prefixToSave); if (!overlay.isNull()) { - //insert overlay + // insert overlay const uint overlayId = qHash(cacheId(frame.data(), frame->prefix % QLatin1String("overlay"))); q->theme()->insertIntoCache(QString::number(overlayId), overlay, QString::number((qint64)q, 16) % prefixToSave % QLatin1String("overlay")); } @@ -786,7 +795,7 @@ void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QPixmap &bac void FrameSvgPrivate::updateSizes(FrameData *frame) const { - //qCDebug(LOG_PLASMA) << "!!!!!!!!!!!!!!!!!!!!!! updating sizes" << prefix; + // qCDebug(LOG_PLASMA) << "!!!!!!!!!!!!!!!!!!!!!! updating sizes" << prefix; Q_ASSERT(frame); QSize s = q->size(); @@ -795,7 +804,7 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const frame->cachedBackground = QPixmap(); } - //This has the same size regardless the border is enabled or not + // This has the same size regardless the border is enabled or not frame->fixedTopHeight = q->elementSize(frame->prefix % QLatin1String("top")).height(); if (q->hasElement(frame->prefix % QLatin1String("hint-top-margin"))) { @@ -804,7 +813,7 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const frame->fixedTopMargin = frame->fixedTopHeight; } - //The same, but its size depends from the margin being enabled + // The same, but its size depends from the margin being enabled if (frame->enabledBorders & FrameSvg::TopBorder) { frame->topMargin = frame->fixedTopMargin; frame->topHeight = frame->fixedTopHeight; @@ -881,13 +890,14 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const frame->insetBottomMargin = -1; } - frame->composeOverBorder = (q->hasElement(frame->prefix % QLatin1String("hint-compose-over-border")) && - q->hasElement(QLatin1String("mask-") % frame->prefix % QLatin1String("center"))); + frame->composeOverBorder = (q->hasElement(frame->prefix % QLatin1String("hint-compose-over-border")) + && q->hasElement(QLatin1String("mask-") % frame->prefix % QLatin1String("center"))); - //since it's rectangular, topWidth and bottomWidth must be the same - //the ones that don't have a frame->prefix is for retrocompatibility + // since it's rectangular, topWidth and bottomWidth must be the same + // the ones that don't have a frame->prefix is for retrocompatibility frame->tileCenter = (q->hasElement(QStringLiteral("hint-tile-center")) || q->hasElement(frame->prefix % QLatin1String("hint-tile-center"))); - frame->noBorderPadding = (q->hasElement(QStringLiteral("hint-no-border-padding")) || q->hasElement(frame->prefix % QLatin1String("hint-no-border-padding"))); + frame->noBorderPadding = + (q->hasElement(QStringLiteral("hint-no-border-padding")) || q->hasElement(frame->prefix % QLatin1String("hint-no-border-padding"))); frame->stretchBorders = (q->hasElement(QStringLiteral("hint-stretch-borders")) || q->hasElement(frame->prefix % QLatin1String("hint-stretch-borders"))); q->resize(s); } @@ -895,7 +905,7 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const void FrameSvgPrivate::updateNeeded() { q->setElementPrefix(requestedPrefix); - //frame not created yet? + // frame not created yet? if (!frame) { return; } @@ -905,7 +915,7 @@ void FrameSvgPrivate::updateNeeded() void FrameSvgPrivate::updateAndSignalSizes() { - //frame not created yet? + // frame not created yet? if (!frame) { return; } diff --git a/src/plasma/framesvg.h b/src/plasma/framesvg.h index b5e24c5cd..ea4e74b44 100644 --- a/src/plasma/framesvg.h +++ b/src/plasma/framesvg.h @@ -27,7 +27,6 @@ class QMatrix; namespace Plasma { - class FrameSvgPrivate; /** @@ -269,12 +268,12 @@ public: Q_INVOKABLE void clearCache(); /** - * Returns a pixmap of the SVG represented by this object. - * - * @param elelementId the ID string of the element to render, or an empty - * string for the whole SVG (the default) - * @return a QPixmap of the rendered SVG - */ + * Returns a pixmap of the SVG represented by this object. + * + * @param elelementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + * @return a QPixmap of the rendered SVG + */ Q_INVOKABLE QPixmap framePixmap(); /** @@ -283,8 +282,7 @@ public: * @param target the target rectangle on the paint device * @param source the portion rectangle of the source image */ - Q_INVOKABLE void paintFrame(QPainter *painter, const QRectF &target, - const QRectF &source = QRectF()); + Q_INVOKABLE void paintFrame(QPainter *painter, const QRectF &target, const QRectF &source = QRectF()); /** * Paints the loaded SVG with the elements that represents the border @@ -321,7 +319,7 @@ private: FrameSvgPrivate *const d; friend class FrameData; - //Q_PRIVATE_SLOT(d, void updateSizes()) + // Q_PRIVATE_SLOT(d, void updateSizes()) }; Q_DECLARE_OPERATORS_FOR_FLAGS(FrameSvg::EnabledBorders) diff --git a/src/plasma/package.cpp b/src/plasma/package.cpp index 2b2be16d7..950ce13c7 100644 --- a/src/plasma/package.cpp +++ b/src/plasma/package.cpp @@ -12,16 +12,16 @@ #include #include -#include #include -#include -#include #include +#include +#include +#include #include "config-plasma.h" -#include #include +#include #include "packagestructure.h" #include "pluginloader.h" @@ -30,12 +30,10 @@ namespace Plasma { - - PackagePrivate::PackagePrivate() - : internalPackage(nullptr), - fallbackPackage(nullptr), - structure(nullptr) + : internalPackage(nullptr) + , fallbackPackage(nullptr) + , structure(nullptr) { } @@ -43,7 +41,6 @@ PackagePrivate::~PackagePrivate() { } - Package::Package(PackageStructure *structure) : d(new Plasma::PackagePrivate()) { @@ -292,8 +289,8 @@ KJob *Package::install(const QString &sourcePackage, const QString &packageRoot) { const QString src = sourcePackage; const QString dest = packageRoot.isEmpty() ? defaultPackageRoot() : packageRoot; - //qCDebug(LOG_PLASMA) << "Source: " << src; - //qCDebug(LOG_PLASMA) << "PackageRoot: " << dest; + // qCDebug(LOG_PLASMA) << "Source: " << src; + // qCDebug(LOG_PLASMA) << "PackageRoot: " << dest; KJob *j = d->structure->install(this, src, dest); return j; } diff --git a/src/plasma/package.h b/src/plasma/package.h index 581d63a95..8cf32b2d7 100644 --- a/src/plasma/package.h +++ b/src/plasma/package.h @@ -19,13 +19,13 @@ class KJob; // not 5.6, as last Plasma API using this class only got removed later #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) -namespace KPackage { - class Package; +namespace KPackage +{ +class Package; } namespace Plasma { - /** * @class Package plasma/package.h * @@ -66,7 +66,7 @@ namespace Plasma * * @deprecated Since 5.6, use KPackage::Package instead **/ -//TODO: write documentation on USING a package +// TODO: write documentation on USING a package class PackagePrivate; class PackageStructure; @@ -193,8 +193,8 @@ public: bool allowExternalPaths() const; /** - * @return the package metadata object. - */ + * @return the package metadata object. + */ KPluginInfo metadata() const; /** @@ -366,6 +366,4 @@ Q_DECLARE_METATYPE(Plasma::Package) #endif // PLASMA_ENABLE_DEPRECATED_SINCE(5, 28) - #endif - diff --git a/src/plasma/packagestructure.cpp b/src/plasma/packagestructure.cpp index 2a0df8725..9ee9e3f33 100644 --- a/src/plasma/packagestructure.cpp +++ b/src/plasma/packagestructure.cpp @@ -5,31 +5,30 @@ */ #include "packagestructure.h" -#include +#include "debug_p.h" #include "private/package_p.h" #include "private/packagestructure_p.h" -#include "debug_p.h" +#include #include #include #include -#include #include -#include -#include +#include #include #include +#include +#include namespace Plasma { - QHash PackageStructureWrapper::s_packagesMap; PackageStructureWrapper::PackageStructureWrapper(Plasma::PackageStructure *structure, QObject *parent, const QVariantList &args) - : KPackage::PackageStructure(parent, args), - m_struct(structure) + : KPackage::PackageStructure(parent, args) + , m_struct(structure) { } @@ -39,7 +38,6 @@ PackageStructureWrapper::~PackageStructureWrapper() void PackageStructureWrapper::initPackage(KPackage::Package *package) { - if (!m_struct || !s_packagesMap.contains(package)) { return; } @@ -74,8 +72,6 @@ KJob *PackageStructureWrapper::uninstall(KPackage::Package *package, const QStri return m_struct->uninstall(s_packagesMap.value(package), packageRoot); } - - void PackageStructurePrivate::installPathChanged(const QString &path) { KJob *job = qobject_cast(q->sender()); @@ -86,7 +82,7 @@ void PackageStructurePrivate::installPathChanged(const QString &path) const QString servicePrefix = job->property("servicePrefix").toString(); const QString serviceName = job->property("serviceName").toString(); - //uninstall + // uninstall if (path.isEmpty()) { if (serviceName.isEmpty()) { return; @@ -99,7 +95,7 @@ void PackageStructurePrivate::installPathChanged(const QString &path) qCWarning(LOG_PLASMA) << "Unable to remove " << service; } - //install + // install } else { if (!servicePrefix.isEmpty()) { // and now we register it as a service =) @@ -117,7 +113,7 @@ void PackageStructurePrivate::installPathChanged(const QString &path) // used by the installing app in any case, and the // package is properly installed - aseigo - //TODO: remove installation of the desktop file in kservices5 when possible + // TODO: remove installation of the desktop file in kservices5 when possible const QString serviceName = servicePrefix + pluginName + QStringLiteral(".desktop"); @@ -147,16 +143,16 @@ void PackageStructurePrivate::installPathChanged(const QString &path) } } } - const auto call = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kded5"), QStringLiteral("/kbuildsycoca"), - QStringLiteral("org.kde.kbuildsycoca"), QStringLiteral("recreate")); + const auto call = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kded5"), + QStringLiteral("/kbuildsycoca"), + QStringLiteral("org.kde.kbuildsycoca"), + QStringLiteral("recreate")); QDBusConnection::sessionBus().asyncCall(call); } - - PackageStructure::PackageStructure(QObject *parent, const QVariantList &args) - : QObject(parent), - d(new PackageStructurePrivate(this)) + : QObject(parent) + , d(new PackageStructurePrivate(this)) { if (!args.isEmpty() && args.first().canConvert()) { d->internalStructure = KPackage::PackageLoader::self()->loadPackageStructure(args.first().toString()); @@ -179,8 +175,8 @@ void PackageStructure::initPackage(Package *package) void PackageStructure::pathChanged(Package *package) { - if (d->internalStructure && !qobject_cast(d->internalStructure)) { - d->internalStructure->pathChanged(package->d->internalPackage); + if (d->internalStructure && !qobject_cast(d->internalStructure)) { + d->internalStructure->pathChanged(package->d->internalPackage); } } diff --git a/src/plasma/packagestructure.h b/src/plasma/packagestructure.h index a5d0ddd28..168f8023f 100644 --- a/src/plasma/packagestructure.h +++ b/src/plasma/packagestructure.h @@ -11,16 +11,15 @@ #include +#include #include #include -#include #include #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) namespace Plasma { - class PackageStructurePrivate; class PLASMA_EXPORT PackageStructure : public QObject @@ -28,7 +27,6 @@ class PLASMA_EXPORT PackageStructure : public QObject Q_OBJECT public: - PLASMA_DEPRECATED_VERSION(5, 6, "Use KPackage API") explicit PackageStructure(QObject *parent = nullptr, const QVariantList &args = QVariantList()); @@ -91,12 +89,12 @@ private: /** * Register a Package class when it is contained in a loadable module */ -#define K_EXPORT_PLASMA_PACKAGE(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) \ +#define K_EXPORT_PLASMA_PACKAGE(libname, classname) \ + K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -#define K_EXPORT_PLASMA_PACKAGE_WITH_JSON(classname, jsonFile) \ - K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ +#define K_EXPORT_PLASMA_PACKAGE_WITH_JSON(classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // PLASMA_ENABLE_DEPRECATED_SINCE(5, 6) diff --git a/src/plasma/packagestructure/containmentactionspackage.cpp b/src/plasma/packagestructure/containmentactionspackage.cpp index 18d8d90cd..8fde43524 100644 --- a/src/plasma/packagestructure/containmentactionspackage.cpp +++ b/src/plasma/packagestructure/containmentactionspackage.cpp @@ -6,16 +6,19 @@ #include "plasma.h" +#include "config-plasma.h" +#include "packages_p.h" #include #include -#include "packages_p.h" -#include "config-plasma.h" class ContainmentActionsPackage : public Plasma::ChangeableMainScriptPackage { Q_OBJECT public: - ContainmentActionsPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {} + ContainmentActionsPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) + : ChangeableMainScriptPackage(parent, args) + { + } void initPackage(KPackage::Package *package) override { @@ -24,7 +27,6 @@ public: } }; - K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(ContainmentActionsPackage, "containmentactions-packagestructure.json") #include "containmentactionspackage.moc" diff --git a/src/plasma/packagestructure/dataenginepackage.cpp b/src/plasma/packagestructure/dataenginepackage.cpp index 6c19cd0cd..08189362b 100644 --- a/src/plasma/packagestructure/dataenginepackage.cpp +++ b/src/plasma/packagestructure/dataenginepackage.cpp @@ -6,17 +6,20 @@ #include "plasma.h" +#include "config-plasma.h" +#include "packages_p.h" #include #include #include -#include "packages_p.h" -#include "config-plasma.h" class DataEnginePackage : public Plasma::ChangeableMainScriptPackage { Q_OBJECT public: - DataEnginePackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {} + DataEnginePackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) + : ChangeableMainScriptPackage(parent, args) + { + } void initPackage(KPackage::Package *package) override { @@ -37,7 +40,6 @@ public: } }; - K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(DataEnginePackage, "dataengine-packagestructure.json") #include "dataenginepackage.moc" diff --git a/src/plasma/packagestructure/packages.cpp b/src/plasma/packagestructure/packages.cpp index c8ce325ef..6d51d7b7f 100644 --- a/src/plasma/packagestructure/packages.cpp +++ b/src/plasma/packagestructure/packages.cpp @@ -4,26 +4,25 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include #include // FLT_MAX +#include #include -#include #include +#include #include #include #include -#include -#include "packages_p.h" #include "config-plasma.h" +#include "packages_p.h" +#include #include namespace Plasma { - void ChangeableMainScriptPackage::initPackage(KPackage::Package *package) { package->addFileDefinition("mainscript", QStringLiteral("ui/main.qml"), i18n("Main Script File")); @@ -94,4 +93,3 @@ void GenericPackage::initPackage(KPackage::Package *package) } } // namespace Plasma - diff --git a/src/plasma/packagestructure/packages_p.h b/src/plasma/packagestructure/packages_p.h index e3e10e8ad..7778c67c7 100644 --- a/src/plasma/packagestructure/packages_p.h +++ b/src/plasma/packagestructure/packages_p.h @@ -14,12 +14,14 @@ namespace Plasma { - class ChangeableMainScriptPackage : public KPackage::PackageStructure { Q_OBJECT public: - ChangeableMainScriptPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : KPackage::PackageStructure(parent, args) {} + ChangeableMainScriptPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) + : KPackage::PackageStructure(parent, args) + { + } void initPackage(KPackage::Package *package) override; void pathChanged(KPackage::Package *package) override; @@ -32,7 +34,10 @@ class GenericPackage : public ChangeableMainScriptPackage { Q_OBJECT public: - GenericPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {} + GenericPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) + : ChangeableMainScriptPackage(parent, args) + { + } void initPackage(KPackage::Package *package) override; }; diff --git a/src/plasma/packagestructure/plasmagenericpackage.cpp b/src/plasma/packagestructure/plasmagenericpackage.cpp index b554072da..eef1cf636 100644 --- a/src/plasma/packagestructure/plasmagenericpackage.cpp +++ b/src/plasma/packagestructure/plasmagenericpackage.cpp @@ -6,10 +6,10 @@ #include "plasma.h" +#include "packages_p.h" #include #include #include -#include "packages_p.h" K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(Plasma::GenericPackage, "plasmageneric-packagestructure.json") diff --git a/src/plasma/packagestructure/plasmathemepackage.cpp b/src/plasma/packagestructure/plasmathemepackage.cpp index d57f90175..dc569b234 100644 --- a/src/plasma/packagestructure/plasmathemepackage.cpp +++ b/src/plasma/packagestructure/plasmathemepackage.cpp @@ -6,16 +6,19 @@ #include "plasma.h" +#include "config-plasma.h" #include #include #include -#include "config-plasma.h" class ThemePackage : public KPackage::PackageStructure { Q_OBJECT public: - ThemePackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : KPackage::PackageStructure(parent, args) {} + ThemePackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) + : KPackage::PackageStructure(parent, args) + { + } void initPackage(KPackage::Package *package) override { @@ -25,58 +28,44 @@ public: package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/")); package->addDirectoryDefinition("dialogs", QStringLiteral("dialogs/"), i18n("Images for dialogs")); - package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svg"), - i18n("Generic dialog background")); - package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svgz"), - i18n("Generic dialog background")); - package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svg"), - i18n("Theme for the logout dialog")); - package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svgz"), - i18n("Theme for the logout dialog")); + package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svg"), i18n("Generic dialog background")); + package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svgz"), i18n("Generic dialog background")); + package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svg"), i18n("Theme for the logout dialog")); + package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svgz"), i18n("Theme for the logout dialog")); package->addDirectoryDefinition("wallpapers", QStringLiteral("wallpapers/"), i18n("Wallpaper packages")); package->addDirectoryDefinition("widgets", QStringLiteral("widgets/"), i18n("Images for widgets")); - package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svg"), - i18n("Background image for widgets")); - package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svgz"), - i18n("Background image for widgets")); - package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svg"), - i18n("Analog clock face")); - package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svgz"), - i18n("Analog clock face")); - package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svg"), - i18n("Background image for panels")); - package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svgz"), - i18n("Background image for panels")); - package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svg"), - i18n("Background for graphing widgets")); - package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svgz"), - i18n("Background for graphing widgets")); - package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svg"), - i18n("Background image for tooltips")); - package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svgz"), - i18n("Background image for tooltips")); + package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svg"), i18n("Background image for widgets")); + package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svgz"), i18n("Background image for widgets")); + package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svg"), i18n("Analog clock face")); + package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svgz"), i18n("Analog clock face")); + package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svg"), i18n("Background image for panels")); + package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svgz"), i18n("Background image for panels")); + package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svg"), i18n("Background for graphing widgets")); + package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svgz"), i18n("Background for graphing widgets")); + package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svg"), i18n("Background image for tooltips")); + package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svgz"), i18n("Background image for tooltips")); package->addDirectoryDefinition("opaque/dialogs", QStringLiteral("opaque/dialogs/"), i18n("Opaque images for dialogs")); - package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svg"), - i18n("Opaque generic dialog background")); - package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svgz"), - i18n("Opaque generic dialog background")); - package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svg"), - i18n("Opaque theme for the logout dialog")); - package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svgz"), - i18n("Opaque theme for the logout dialog")); + package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svg"), i18n("Opaque generic dialog background")); + package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svgz"), i18n("Opaque generic dialog background")); + package->addFileDefinition("opaque/dialogs/shutdowndialog", + QStringLiteral("opaque/dialogs/shutdowndialog.svg"), + i18n("Opaque theme for the logout dialog")); + package->addFileDefinition("opaque/dialogs/shutdowndialog", + QStringLiteral("opaque/dialogs/shutdowndialog.svgz"), + i18n("Opaque theme for the logout dialog")); package->addDirectoryDefinition("opaque/widgets", QStringLiteral("opaque/widgets/"), i18n("Opaque images for widgets")); - package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svg"), - i18n("Opaque background image for panels")); - package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svgz"), - i18n("Opaque background image for panels")); - package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svg"), - i18n("Opaque background image for tooltips")); - package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svgz"), - i18n("Opaque background image for tooltips")); + package->addFileDefinition("opaque/widgets/panel-background", + QStringLiteral("opaque/widgets/panel-background.svg"), + i18n("Opaque background image for panels")); + package->addFileDefinition("opaque/widgets/panel-background", + QStringLiteral("opaque/widgets/panel-background.svgz"), + i18n("Opaque background image for panels")); + package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svg"), i18n("Opaque background image for tooltips")); + package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svgz"), i18n("Opaque background image for tooltips")); package->addFileDefinition("colors", QStringLiteral("colors"), i18n("KColorScheme configuration file")); @@ -89,4 +78,3 @@ public: K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(ThemePackage, "plasmatheme-packagestructure.json") #include "plasmathemepackage.moc" - diff --git a/src/plasma/packagestructure/plasmoidpackage.cpp b/src/plasma/packagestructure/plasmoidpackage.cpp index b99e3e9fa..af70f6c2f 100644 --- a/src/plasma/packagestructure/plasmoidpackage.cpp +++ b/src/plasma/packagestructure/plasmoidpackage.cpp @@ -6,17 +6,20 @@ #include "plasma.h" +#include "config-plasma.h" +#include "packages_p.h" +#include #include #include -#include -#include "packages_p.h" -#include "config-plasma.h" class PlasmoidPackage : public Plasma::GenericPackage { Q_OBJECT public: - PlasmoidPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : GenericPackage(parent, args) {} + PlasmoidPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) + : GenericPackage(parent, args) + { + } void initPackage(KPackage::Package *package) override { diff --git a/src/plasma/plasma.cpp b/src/plasma/plasma.cpp index 498131520..f1e9cfc6e 100644 --- a/src/plasma/plasma.cpp +++ b/src/plasma/plasma.cpp @@ -13,7 +13,6 @@ namespace Plasma { - Types::Types(QObject *parent) : QObject(parent) { @@ -30,7 +29,7 @@ Types::Direction locationToDirection(Types::Location location) case Types::Desktop: case Types::TopEdge: case Types::FullScreen: - //TODO: should we be smarter for floating and planer? + // TODO: should we be smarter for floating and planer? // perhaps we should take a QRect and/or QPos as well? return Types::Down; case Types::BottomEdge: @@ -51,7 +50,7 @@ Types::Direction locationToInverseDirection(Types::Location location) case Types::Desktop: case Types::TopEdge: case Types::FullScreen: - //TODO: should we be smarter for floating and planer? + // TODO: should we be smarter for floating and planer? // perhaps we should take a QRect and/or QPos as well? return Types::Up; case Types::BottomEdge: diff --git a/src/plasma/plasma.h b/src/plasma/plasma.h index 662e492de..647d650bf 100644 --- a/src/plasma/plasma.h +++ b/src/plasma/plasma.h @@ -44,21 +44,22 @@ public: ImmutableConstraint = 8, /**< the immutability (locked) nature of the applet changed */ StartupCompletedConstraint = 16, /**< application startup has completed */ ContextConstraint = 32, /**< the context (e.g. activity) has changed */ - UiReadyConstraint = 64, /**< The ui has been completely loaded */ // (FIXME: merged with StartupCompletedConstraint?) - AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint | - ImmutableConstraint, + UiReadyConstraint = 64, + /**< The ui has been completely loaded */ // (FIXME: merged with StartupCompletedConstraint?) + AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint | ImmutableConstraint, }; Q_ENUM(Constraint) Q_DECLARE_FLAGS(Constraints, Constraint) /** - * This enumeration lists the various hints that an applet can pass to its - * constraint regarding the way that it is represented + * This enumeration lists the various hints that an applet can pass to its + * constraint regarding the way that it is represented */ - enum ConstraintHints { //TODO KF6 ConstraintHints -> ConstraintHint - NoHint = 0, - CanFillArea = 1, /**< The CompactRepresentation can fill the area and ignore constraint margins*/ // (TODO: KF6 CanFillArea -> CompactRepresentationFillArea) - MarginAreasSeparator = CanFillArea | 2, /**< The applet acts as a separator between the standard and slim panel margin areas*/ + enum ConstraintHints { // TODO KF6 ConstraintHints -> ConstraintHint + NoHint = 0, + CanFillArea = 1, + /**< The CompactRepresentation can fill the area and ignore constraint margins*/ // (TODO: KF6 CanFillArea -> CompactRepresentationFillArea) + MarginAreasSeparator = CanFillArea | 2, /**< The applet acts as a separator between the standard and slim panel margin areas*/ }; Q_DECLARE_FLAGS(ConstraintFlags, ConstraintHints) Q_FLAG(ConstraintFlags) @@ -69,20 +70,20 @@ public: * (e.g. in Plasma, a Corona on the desktop or on a panel). **/ enum FormFactor { - Planar = 0, /**< The applet lives in a plane and has two - degrees of freedom to grow. Optimize for - desktop, laptop or tablet usage: a high - resolution screen 1-3 feet distant from the - viewer. */ + Planar = 0, /**< The applet lives in a plane and has two + degrees of freedom to grow. Optimize for + desktop, laptop or tablet usage: a high + resolution screen 1-3 feet distant from the + viewer. */ MediaCenter, /**< As with Planar, the applet lives in a plane but the interface should be optimized for medium-to-high resolution screens that are 5-15 feet distant from the viewer. Sometimes referred to as a "ten foot interface".*/ - Horizontal, /**< The applet is constrained vertically, but - can expand horizontally. */ - Vertical, /**< The applet is constrained horizontally, but - can expand vertically. */ + Horizontal, /**< The applet is constrained vertically, but + can expand horizontally. */ + Vertical, /**< The applet is constrained horizontally, but + can expand vertically. */ Application, /**< The Applet lives in a plane and should be optimized to look as a full application, for the desktop or the particular device. */ }; @@ -94,9 +95,12 @@ public: */ enum ContainmentDisplayHint { NoContainmentDisplayHint = 0, - ContainmentDrawsPlasmoidHeading = 1, /**< The containment will draw an titlebar-looking header for the applets, so the applets shouldn't attempt to paint a similar thing **/ - ContainmentForcesSquarePlasmoids = 2, /**< The containment will force every plasmoid to be constrained in a square icon (An example is the System Tray)**/ - DesktopFullyCovered = 4, /**< The desktop area for the contaiment's screen is not visible at all, for instance a window has been maximized on top of it */ + ContainmentDrawsPlasmoidHeading = + 1, /**< The containment will draw an titlebar-looking header for the applets, so the applets shouldn't attempt to paint a similar thing **/ + ContainmentForcesSquarePlasmoids = + 2, /**< The containment will force every plasmoid to be constrained in a square icon (An example is the System Tray)**/ + DesktopFullyCovered = + 4, /**< The desktop area for the contaiment's screen is not visible at all, for instance a window has been maximized on top of it */ }; Q_ENUM(ContainmentDisplayHint) Q_DECLARE_FLAGS(ContainmentDisplayHints, ContainmentDisplayHint) @@ -108,9 +112,9 @@ public: * while PanelContainments are accessories which can be present multiple per screen. */ enum ContainmentType { - NoContainmentType = -1, /**< @internal */ - DesktopContainment = 0, /**< A desktop containment */ - PanelContainment, /**< A desktop panel */ + NoContainmentType = -1, /**< @internal */ + DesktopContainment = 0, /**< A desktop containment */ + PanelContainment, /**< A desktop panel */ CustomContainment = 127, /**< A containment that is neither a desktop nor a panel but something application specific */ @@ -123,11 +127,12 @@ public: * A descriptive type for QActions, to help categorizing them when presented to the user */ enum ActionType { - AddAction = 0, /**< The action will cause something new being created*/ - ConfigureAction = 100, /**< The Action will make some kind of configuration ui to appear */ - ControlAction = 200, /**< Generic control, similar to ConfigureAction TODO: better doc */ - MiscAction = 300, /**< A type of action that doesn't fit in the other categories */ - DestructiveAction = 400, /**< A dangerous action, such as deletion of objects, plasmoids and files. They are intended to be shown separated from other actions */ + AddAction = 0, /**< The action will cause something new being created*/ + ConfigureAction = 100, /**< The Action will make some kind of configuration ui to appear */ + ControlAction = 200, /**< Generic control, similar to ConfigureAction TODO: better doc */ + MiscAction = 300, /**< A type of action that doesn't fit in the other categories */ + DestructiveAction = + 400, /**< A dangerous action, such as deletion of objects, plasmoids and files. They are intended to be shown separated from other actions */ UserAction = DestructiveAction + 1000, /**< If new types are needed in a C++ implementation, define them as ids more than UserAction*/ }; Q_ENUM(ActionType) @@ -140,9 +145,9 @@ public: **/ enum Direction { Down = 0, /**< Display downards */ - Up, /**< Display upwards */ - Left, /**< Display to the left */ - Right, /**< Display to the right */ + Up, /**< Display upwards */ + Left, /**< Display to the left */ + Right, /**< Display to the right */ }; Q_ENUM(Direction) @@ -153,13 +158,13 @@ public: enum Location { Floating = 0, /**< Free floating. Neither geometry or z-ordering is described precisely by this value. */ - Desktop, /**< On the planar desktop layer, extending across - the full screen from edge to edge */ - FullScreen, /**< Full screen */ - TopEdge, /**< Along the top of the screen*/ - BottomEdge, /**< Along the bottom of the screen*/ - LeftEdge, /**< Along the left side of the screen */ - RightEdge, /**< Along the right side of the screen */ + Desktop, /**< On the planar desktop layer, extending across + the full screen from edge to edge */ + FullScreen, /**< Full screen */ + TopEdge, /**< Along the top of the screen*/ + BottomEdge, /**< Along the bottom of the screen*/ + LeftEdge, /**< Along the left side of the screen */ + RightEdge, /**< Along the right side of the screen */ }; Q_ENUM(Location) @@ -168,11 +173,11 @@ public: * **/ enum Position { - LeftPositioned, /**< Positioned left */ - RightPositioned, /**< Positioned right */ - TopPositioned, /**< Positioned top */ - BottomPositioned, /**< Positioned bottom */ - CenterPositioned, /**< Positioned in the center */ + LeftPositioned, /**< Positioned left */ + RightPositioned, /**< Positioned right */ + TopPositioned, /**< Positioned top */ + BottomPositioned, /**< Positioned bottom */ + CenterPositioned, /**< Positioned in the center */ }; Q_ENUM(Position) @@ -181,23 +186,23 @@ public: * **/ enum PopupPlacement { - FloatingPopup = 0, /**< Free floating, non attached popup */ - TopPosedLeftAlignedPopup, /**< Popup positioned on the top, aligned - to the left of the widget */ - TopPosedRightAlignedPopup, /**< Popup positioned on the top, aligned - to the right of the widget */ - LeftPosedTopAlignedPopup, /**< Popup positioned on the left, aligned - to the top of the widget */ - LeftPosedBottomAlignedPopup, /**< Popup positioned on the left, aligned - to the bottom of the widget */ - BottomPosedLeftAlignedPopup, /**< Popup positioned on the bottom, aligned - to the left of the widget */ + FloatingPopup = 0, /**< Free floating, non attached popup */ + TopPosedLeftAlignedPopup, /**< Popup positioned on the top, aligned + to the left of the widget */ + TopPosedRightAlignedPopup, /**< Popup positioned on the top, aligned + to the right of the widget */ + LeftPosedTopAlignedPopup, /**< Popup positioned on the left, aligned + to the top of the widget */ + LeftPosedBottomAlignedPopup, /**< Popup positioned on the left, aligned + to the bottom of the widget */ + BottomPosedLeftAlignedPopup, /**< Popup positioned on the bottom, aligned + to the left of the widget */ BottomPosedRightAlignedPopup, /**< Popup positioned on the bottom, aligned to the right of the widget */ - RightPosedTopAlignedPopup, /**< Popup positioned on the right, aligned - to the top of the widget */ - RightPosedBottomAlignedPopup, /**< Popup positioned on the right, aligned - to the bottom of the widget */ + RightPosedTopAlignedPopup, /**< Popup positioned on the right, aligned + to the top of the widget */ + RightPosedBottomAlignedPopup, /**< Popup positioned on the right, aligned + to the bottom of the widget */ }; Q_ENUM(PopupPlacement) @@ -205,9 +210,9 @@ public: * Flip enumeration */ enum FlipDirection { - NoFlip = 0, /**< Do not flip */ - HorizontalFlip = 1, /**< Flip horizontally */ - VerticalFlip = 2, /**< Flip vertically */ + NoFlip = 0, /**< Do not flip */ + HorizontalFlip = 1, /**< Flip horizontally */ + VerticalFlip = 2, /**< Flip vertically */ }; Q_ENUM(FlipDirection) Q_DECLARE_FLAGS(Flip, FlipDirection) @@ -228,9 +233,9 @@ public: * system (e.g. kiosk setups). */ enum ImmutabilityType { - Mutable = 1, /**< The item can be modified in any way **/ - UserImmutable = 2, /**< The user has requested a lock down, and can undo - the lock down at any time **/ + Mutable = 1, /**< The item can be modified in any way **/ + UserImmutable = 2, /**< The user has requested a lock down, and can undo + the lock down at any time **/ SystemImmutable = 4, /**< the item is locked down by the system, the user can't unlock it **/ }; @@ -241,11 +246,11 @@ public: * or plugins, supported by plasma. */ enum ComponentType { - AppletComponent = 1, /**< Plasma::Applet based plugins **/ - DataEngineComponent = 2, /**< Plasma::DataEngine based plugins **/ - ContainmentComponent = 4,/**< Plasma::Containment based plugins **/ - WallpaperComponent = 8, /**< Plasma::Wallpaper based plugins **/ - GenericComponent = 16, /** Generic repositories of files, usually they keep QML files and their assets **/ + AppletComponent = 1, /**< Plasma::Applet based plugins **/ + DataEngineComponent = 2, /**< Plasma::DataEngine based plugins **/ + ContainmentComponent = 4, /**< Plasma::Containment based plugins **/ + WallpaperComponent = 8, /**< Plasma::Wallpaper based plugins **/ + GenericComponent = 16, /** Generic repositories of files, usually they keep QML files and their assets **/ }; Q_ENUM(ComponentType) Q_DECLARE_FLAGS(ComponentTypes, ComponentType) @@ -269,21 +274,21 @@ public: NeedsAttentionStatus = 3, /**< The Item needs attention **/ RequiresAttentionStatus = 4, /**< The Item needs persistent attention **/ AcceptingInputStatus = 5, /**< The Item is accepting input **/ - //FIXME KF6: this should be the smallest status - HiddenStatus = 6, /**< The Item will be hidden totally **/ + // FIXME KF6: this should be the smallest status + HiddenStatus = 6, /**< The Item will be hidden totally **/ }; Q_ENUM(ItemStatus) enum TrustLevel { - UnverifiableTrust = 0, /**< The trust of the object can not be verified, usually because no - trust information (e.g. a cryptographic signature) was provided */ - CompletelyUntrusted, /**< The signature is broken/expired/false */ - UnknownTrusted, /**< The signature is valid, but the key is unknown */ - UserTrusted, /**< The signature is valid and made with a key signed by one of the - user's own keys*/ - SelfTrusted, /**< The signature is valid and made with one of the user's own keys*/ - FullyTrusted, /**< The signature is valid and made with a key signed by the vendor's key*/ - UltimatelyTrusted, /**< The signature is valid and made with the vendor's key*/ + UnverifiableTrust = 0, /**< The trust of the object can not be verified, usually because no + trust information (e.g. a cryptographic signature) was provided */ + CompletelyUntrusted, /**< The signature is broken/expired/false */ + UnknownTrusted, /**< The signature is valid, but the key is unknown */ + UserTrusted, /**< The signature is valid and made with a key signed by one of the + user's own keys*/ + SelfTrusted, /**< The signature is valid and made with one of the user's own keys*/ + FullyTrusted, /**< The signature is valid and made with a key signed by the vendor's key*/ + UltimatelyTrusted, /**< The signature is valid and made with the vendor's key*/ }; Q_ENUM(TrustLevel) @@ -291,15 +296,15 @@ public: * Description on how draw a background for the applet */ enum BackgroundHints { - NoBackground = 0, /**< Not drawing a background under the applet, the applet has its own implementation */ - StandardBackground = 1, /**< The standard background from the theme is drawn */ + NoBackground = 0, /**< Not drawing a background under the applet, the applet has its own implementation */ + StandardBackground = 1, /**< The standard background from the theme is drawn */ TranslucentBackground = 2, /**< An alternate version of the background is drawn, usually more translucent */ ShadowBackground = 4, /**< The applet won't have a svg background but a drop shadow of its content done via a shader */ ConfigurableBackground = 8, /** If the hint has this flag, the user is able to configure this background */ DefaultBackground = StandardBackground, /**< Default settings: both standard background */ }; Q_ENUM(BackgroundHints) - //TODO KF6: BackgroundHint and BackgroundHints + // TODO KF6: BackgroundHint and BackgroundHints Q_DECLARE_FLAGS(BackgroundFlags, BackgroundHints) private: diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 5cfee0de2..9ee5b8a9e 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -9,13 +9,13 @@ #include #include -#include +#include +#include #include #include -#include -#include -#include +#include #include +#include #include "config-plasma.h" @@ -23,18 +23,17 @@ #include "containment.h" #include "containmentactions.h" #include "dataengine.h" +#include "debug_p.h" #include "package.h" #include "private/applet_p.h" -#include "private/service_p.h" // for NullService -#include "private/storage_p.h" #include "private/package_p.h" #include "private/packagestructure_p.h" +#include "private/service_p.h" // for NullService +#include "private/storage_p.h" #include -#include "debug_p.h" namespace Plasma { - static PluginLoader *s_pluginLoader = nullptr; class PluginLoaderPrivate @@ -48,7 +47,7 @@ public: static QSet knownCategories(); static QSet s_customCategories; - QHash > structures; + QHash> structures; bool isDefaultLoader; static QString s_dataEnginePluginDir; @@ -57,7 +56,8 @@ public: static QString s_servicesPluginDir; static QString s_containmentActionsPluginDir; - class Cache { + class Cache + { // We only use this cache during start of the process to speed up many consecutive calls // After that, we're too afraid to produce race conditions and it's not that time-critical anyway // the 20 seconds here means that the cache is only used within 20sec during startup, after that, @@ -69,7 +69,7 @@ public: QHash> plugins; public: - QVector findPluginsById(const QString& name, const QStringList &dirs); + QVector findPluginsById(const QString &name, const QStringList &dirs); }; Cache plasmoidCache; Cache dataengineCache; @@ -89,28 +89,17 @@ QSet PluginLoaderPrivate::knownCategories() // this is to trick the translation tools into making the correct // strings for translation QSet categories = s_customCategories; - categories << QStringLiteral(I18N_NOOP("Accessibility")).toLower() - << QStringLiteral(I18N_NOOP("Application Launchers")).toLower() - << QStringLiteral(I18N_NOOP("Astronomy")).toLower() - << QStringLiteral(I18N_NOOP("Date and Time")).toLower() - << QStringLiteral(I18N_NOOP("Development Tools")).toLower() - << QStringLiteral(I18N_NOOP("Education")).toLower() - << QStringLiteral(I18N_NOOP("Environment and Weather")).toLower() - << QStringLiteral(I18N_NOOP("Examples")).toLower() - << QStringLiteral(I18N_NOOP("File System")).toLower() - << QStringLiteral(I18N_NOOP("Fun and Games")).toLower() - << QStringLiteral(I18N_NOOP("Graphics")).toLower() - << QStringLiteral(I18N_NOOP("Language")).toLower() - << QStringLiteral(I18N_NOOP("Mapping")).toLower() - << QStringLiteral(I18N_NOOP("Miscellaneous")).toLower() - << QStringLiteral(I18N_NOOP("Multimedia")).toLower() - << QStringLiteral(I18N_NOOP("Online Services")).toLower() - << QStringLiteral(I18N_NOOP("Productivity")).toLower() - << QStringLiteral(I18N_NOOP("System Information")).toLower() - << QStringLiteral(I18N_NOOP("Utilities")).toLower() - << QStringLiteral(I18N_NOOP("Windows and Tasks")).toLower() - << QStringLiteral(I18N_NOOP("Clipboard")).toLower() - << QStringLiteral(I18N_NOOP("Tasks")).toLower(); + categories << QStringLiteral(I18N_NOOP("Accessibility")).toLower() << QStringLiteral(I18N_NOOP("Application Launchers")).toLower() + << QStringLiteral(I18N_NOOP("Astronomy")).toLower() << QStringLiteral(I18N_NOOP("Date and Time")).toLower() + << QStringLiteral(I18N_NOOP("Development Tools")).toLower() << QStringLiteral(I18N_NOOP("Education")).toLower() + << QStringLiteral(I18N_NOOP("Environment and Weather")).toLower() << QStringLiteral(I18N_NOOP("Examples")).toLower() + << QStringLiteral(I18N_NOOP("File System")).toLower() << QStringLiteral(I18N_NOOP("Fun and Games")).toLower() + << QStringLiteral(I18N_NOOP("Graphics")).toLower() << QStringLiteral(I18N_NOOP("Language")).toLower() + << QStringLiteral(I18N_NOOP("Mapping")).toLower() << QStringLiteral(I18N_NOOP("Miscellaneous")).toLower() + << QStringLiteral(I18N_NOOP("Multimedia")).toLower() << QStringLiteral(I18N_NOOP("Online Services")).toLower() + << QStringLiteral(I18N_NOOP("Productivity")).toLower() << QStringLiteral(I18N_NOOP("System Information")).toLower() + << QStringLiteral(I18N_NOOP("Utilities")).toLower() << QStringLiteral(I18N_NOOP("Windows and Tasks")).toLower() + << QStringLiteral(I18N_NOOP("Clipboard")).toLower() << QStringLiteral(I18N_NOOP("Tasks")).toLower(); return categories; } @@ -167,7 +156,7 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari } // Need to pass the empty directory because it's where plasmoids used to be - auto plugins = d->plasmoidCache.findPluginsById(name, { PluginLoaderPrivate::s_plasmoidsPluginDir, {} }); + auto plugins = d->plasmoidCache.findPluginsById(name, {PluginLoaderPrivate::s_plasmoidsPluginDir, {}}); const KPackage::Package p = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/Applet"), name); @@ -175,7 +164,7 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari if (plugins.isEmpty()) { const QString parentPlugin = p.metadata().value(QStringLiteral("X-Plasma-RootPath")); if (!parentPlugin.isEmpty()) { - plugins = d->plasmoidCache.findPluginsById(parentPlugin, { PluginLoaderPrivate::s_plasmoidsPluginDir, {} }); + plugins = d->plasmoidCache.findPluginsById(parentPlugin, {PluginLoaderPrivate::s_plasmoidsPluginDir, {}}); } } @@ -196,7 +185,7 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari } if (!applet) { - //qCDebug(LOG_PLASMA) << name << "not a C++ applet: Falling back to an empty one"; + // qCDebug(LOG_PLASMA) << name << "not a C++ applet: Falling back to an empty one"; QVariantList allArgs; allArgs << QVariant::fromValue(p) << p.metadata().fileName() << appletId << args; @@ -206,10 +195,9 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari } else { applet = new Applet(nullptr, allArgs); } - } - const QString localePath = p.filePath("translations"); + const QString localePath = p.filePath("translations"); if (!localePath.isEmpty()) { KLocalizedString::addDomainLocaleDir(QByteArray("plasma_applet_") + name.toLatin1(), localePath); } @@ -247,8 +235,7 @@ QStringList PluginLoader::listAllEngines(const QString &parentApp) { QStringList engines; // Look for C++ plugins first - auto filter = [&parentApp](const KPluginMetaData &md) -> bool - { + auto filter = [&parentApp](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp; }; QVector plugins; @@ -258,7 +245,7 @@ QStringList PluginLoader::listAllEngines(const QString &parentApp) plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir, filter); } - for (auto& plugin : qAsConst(plugins)) { + for (auto &plugin : qAsConst(plugins)) { engines << plugin.pluginId(); } @@ -282,14 +269,11 @@ KPluginInfo::List PluginLoader::listEngineInfoByCategory(const QString &category KPluginInfo::List list; // Look for C++ plugins first - auto filterNormal = [&category](const KPluginMetaData &md) -> bool - { + auto filterNormal = [&category](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-PluginInfo-Category")) == category; }; - auto filterParentApp = [&category, &parentApp](const KPluginMetaData &md) -> bool - { - return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp - && md.value(QStringLiteral("X-KDE-PluginInfo-Category")) == category; + auto filterParentApp = [&category, &parentApp](const KPluginMetaData &md) -> bool { + return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp && md.value(QStringLiteral("X-KDE-PluginInfo-Category")) == category; }; QVector plugins; if (parentApp.isEmpty()) { @@ -300,8 +284,7 @@ KPluginInfo::List PluginLoader::listEngineInfoByCategory(const QString &category list = KPluginInfo::fromMetaData(plugins); - - //TODO FIXME: PackageLoader needs to have a function to inject packageStructures + // TODO FIXME: PackageLoader needs to have a function to inject packageStructures const QList packagePlugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/DataEngine")); list << KPluginInfo::fromMetaData(packagePlugins.toVector()); @@ -315,17 +298,15 @@ Service *PluginLoader::loadService(const QString &name, const QVariantList &args return service; } - //TODO: scripting API support + // TODO: scripting API support if (name.isEmpty()) { return new NullService(QString(), parent); } else if (name == QLatin1String("org.kde.servicestorage")) { return new Storage(parent); } - // Look for C++ plugins first - auto filter = [&name](const KPluginMetaData &md) -> bool - { + auto filter = [&name](const KPluginMetaData &md) -> bool { return md.pluginId() == name; }; QVector plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_servicesPluginDir, filter); @@ -375,8 +356,8 @@ ContainmentActions *PluginLoader::loadContainmentActions(Containment *parent, co return actions; } - //FIXME: this is only for backwards compatibility, but probably will have to stay - //for the time being + // FIXME: this is only for backwards compatibility, but probably will have to stay + // for the time being QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(name); KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint); @@ -433,11 +414,9 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s if (internalStructure) { structure = new PackageStructure(); structure->d->internalStructure = internalStructure; - //fallback to old structures + // fallback to old structures } else { - - auto filter = [packageFormat](const KPluginMetaData &md) -> bool - { + auto filter = [packageFormat](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-PluginInfo-Name")) == packageFormat; }; @@ -445,7 +424,7 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s if (!plugins.isEmpty()) { KPluginLoader loader(plugins.first().fileName()); - KPluginFactory* factory = loader.factory(); + KPluginFactory *factory = loader.factory(); if (!factory) { qWarning() << "Error loading plugin:" << loader.errorString(); } else { @@ -464,7 +443,7 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s } #ifndef NDEBUG - // qCDebug(LOG_PLASMA) << "Couldn't load Package for" << packageFormat << "! reason given: " << error; + // qCDebug(LOG_PLASMA) << "Couldn't load Package for" << packageFormat << "! reason given: " << error; #endif return Package(); @@ -478,14 +457,13 @@ QList PluginLoader::listAppletMetaData(const QString &category, platforms.clear(); } - //FIXME: this assumes we are always use packages.. no pure c++ - std::function filter; - if (category.isEmpty()) { //use all but the excluded categories + // FIXME: this assumes we are always use packages.. no pure c++ + std::function filter; + if (category.isEmpty()) { // use all but the excluded categories KConfigGroup group(KSharedConfig::openConfig(), "General"); QStringList excluded = group.readEntry("ExcludeCategories", QStringList()); - filter = [excluded, parentApp, platforms](const KPluginMetaData &md) -> bool - { + filter = [excluded, parentApp, platforms](const KPluginMetaData &md) -> bool { if (!platforms.isEmpty() && !md.formFactors().isEmpty()) { bool found = false; for (const auto &plat : platforms) { @@ -503,10 +481,9 @@ QList PluginLoader::listAppletMetaData(const QString &category, const QString pa = md.value(QStringLiteral("X-KDE-ParentApp")); return (parentApp.isEmpty() || pa == parentApp) && !excluded.contains(md.category()); }; - } else { //specific category (this could be an excluded one - is that bad?) + } else { // specific category (this could be an excluded one - is that bad?) - filter = [category, parentApp, platforms](const KPluginMetaData &md) -> bool - { + filter = [category, parentApp, platforms](const KPluginMetaData &md) -> bool { if (!platforms.isEmpty() && !md.formFactors().isEmpty()) { bool found = false; for (const auto &plat : platforms) { @@ -544,14 +521,14 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS #if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) KPluginInfo::List list; - //NOTE: it still produces kplugininfos from KServices because some user code expects - //info.service() to be valid and would crash otherwise + // NOTE: it still produces kplugininfos from KServices because some user code expects + // info.service() to be valid and would crash otherwise for (const auto &md : plugins) { -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") + QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") auto pi = md.metaDataFileName().endsWith(QLatin1String(".json")) ? KPluginInfo(md) : KPluginInfo(KService::serviceByStorageId(md.metaDataFileName())); -QT_WARNING_POP + QT_WARNING_POP if (!pi.isValid()) { qCWarning(LOG_PLASMA) << "Could not load plugin info for plugin :" << md.pluginId() << "skipping plugin"; continue; @@ -566,8 +543,7 @@ QT_WARNING_POP QList PluginLoader::listAppletMetaDataForMimeType(const QString &mimeType) { - auto filter = [&mimeType](const KPluginMetaData &md) -> bool - { + auto filter = [&mimeType](const KPluginMetaData &md) -> bool { return KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropMimeTypes")).contains(mimeType); }; return KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); @@ -586,8 +562,7 @@ QList PluginLoader::listAppletMetaDataForUrl(const QUrl &url) parentApp = app->applicationName(); } - auto filter = [&parentApp](const KPluginMetaData &md) -> bool - { + auto filter = [&parentApp](const KPluginMetaData &md) -> bool { const QString pa = md.value(QStringLiteral("X-KDE-ParentApp")); return (parentApp.isEmpty() || pa == parentApp) && !KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns")).isEmpty(); }; @@ -620,16 +595,13 @@ QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool vi { KConfigGroup group(KSharedConfig::openConfig(), "General"); const QStringList excluded = group.readEntry("ExcludeCategories", QStringList()); - auto filter = [&parentApp, &excluded, visibleOnly](const KPluginMetaData &md) -> bool - { + auto filter = [&parentApp, &excluded, visibleOnly](const KPluginMetaData &md) -> bool { const QString pa = md.value(QStringLiteral("X-KDE-ParentApp")); - return (parentApp.isEmpty() || pa == parentApp) - && (excluded.isEmpty() || excluded.contains(md.value(QStringLiteral("X-KDE-PluginInfo-Category")))) + return (parentApp.isEmpty() || pa == parentApp) && (excluded.isEmpty() || excluded.contains(md.value(QStringLiteral("X-KDE-PluginInfo-Category")))) && (!visibleOnly || !md.isHidden()); }; const QList allApplets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter); - QStringList categories; for (auto &plugin : allApplets) { if (plugin.category().isEmpty()) { @@ -668,19 +640,15 @@ QString PluginLoader::appletCategory(const QString &appletName) return p.metadata().category(); } -KPluginInfo::List PluginLoader::listContainments(const QString &category, - const QString &parentApp) +KPluginInfo::List PluginLoader::listContainments(const QString &category, const QString &parentApp) { return listContainmentsOfType(QString(), category, parentApp); } -KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type, - const QString &category, - const QString &parentApp) +KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type, const QString &category, const QString &parentApp) { KConfigGroup group(KSharedConfig::openConfig(), "General"); - auto filter = [&type, &category, &parentApp](const KPluginMetaData &md) -> bool - { + auto filter = [&type, &category, &parentApp](const KPluginMetaData &md) -> bool { if (!md.serviceTypes().contains(QLatin1String("Plasma/Containment"))) { return false; } @@ -704,8 +672,7 @@ KPluginInfo::List PluginLoader::listContainmentsOfType(const QString &type, KPluginInfo::List PluginLoader::listContainmentsForMimeType(const QString &mimeType) { - auto filter = [&mimeType](const KPluginMetaData &md) -> bool - { + auto filter = [&mimeType](const KPluginMetaData &md) -> bool { return md.serviceTypes().contains(QLatin1String("Plasma/Containment")) && KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropMimeTypes")).contains(mimeType); }; @@ -737,8 +704,7 @@ KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp) QVector PluginLoader::listDataEngineMetaData(const QString &parentApp) { - auto filter = [&parentApp](const KPluginMetaData &md) -> bool - { + auto filter = [&parentApp](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp; }; @@ -761,8 +727,7 @@ KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parent QVector PluginLoader::listContainmentActionsMetaData(const QString &parentApp) { - auto filter = [&parentApp](const KPluginMetaData &md) -> bool - { + auto filter = [&parentApp](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-KDE-ParentApp")) == parentApp; }; @@ -774,8 +739,8 @@ QVector PluginLoader::listContainmentActionsMetaData(const QStr } #if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) - //FIXME: this is only for backwards compatibility, but probably will have to stay - //for the time being + // FIXME: this is only for backwards compatibility, but probably will have to stay + // for the time being QSet knownPlugins; for (const KPluginMetaData &p : qAsConst(plugins)) { knownPlugins.insert(p.pluginId()); @@ -787,11 +752,11 @@ QVector PluginLoader::listContainmentActionsMetaData(const QStr const KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint); for (KService::Ptr s : offers) { if (!knownPlugins.contains(s->pluginKeyword())) { -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") + QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") plugins.append(KPluginInfo(s).toMetaData()); -QT_WARNING_POP + QT_WARNING_POP } } #endif @@ -829,7 +794,6 @@ Service *PluginLoader::internalLoadService(const QString &name, const QVariantLi return nullptr; } - Package PluginLoader::internalLoadPackage(const QString &name, const QString &specialization) { Q_UNUSED(name); @@ -861,8 +825,8 @@ KPluginInfo::List PluginLoader::internalContainmentActionsInfo() const static KPluginInfo::List standardInternalInfo(const QString &type, const QString &category = QString()) { QStringList files = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, - QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/internal/") + type + QLatin1String("/*.desktop"), - QStandardPaths::LocateFile); + QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/internal/") + type + QLatin1String("/*.desktop"), + QStandardPaths::LocateFile); const KPluginInfo::List allInfo = KPluginInfo::fromFiles(files); @@ -910,15 +874,15 @@ bool PluginLoader::isPluginVersionCompatible(KPluginLoader &loader) if (version < minVersion || version > maxVersion) { qCWarning(LOG_PLASMA) << loader.fileName() << ": this plugin is compiled against incompatible Plasma version" << version - << "This build is compatible with" << PLASMA_VERSION_MAJOR << ".0.0 (" << minVersion - << ") to" << PLASMA_VERSION_STRING << "(" << maxVersion << ")"; + << "This build is compatible with" << PLASMA_VERSION_MAJOR << ".0.0 (" << minVersion << ") to" << PLASMA_VERSION_STRING << "(" + << maxVersion << ")"; return false; } return true; } -QVector PluginLoaderPrivate::Cache::findPluginsById(const QString& name, const QStringList &dirs) +QVector PluginLoaderPrivate::Cache::findPluginsById(const QString &name, const QStringList &dirs) { const qint64 now = qRound64(QDateTime::currentMSecsSinceEpoch() / 1000.0); bool useRuntimeCache = true; @@ -945,7 +909,7 @@ QVector PluginLoaderPrivate::Cache::findPluginsById(const QStri plugins.clear(); } - //if name wasn't a path, pluginName == name + // if name wasn't a path, pluginName == name const QString pluginName = name.section(QLatin1Char('/'), -1); QVector ret; @@ -957,8 +921,7 @@ QVector PluginLoaderPrivate::Cache::findPluginsById(const QStri } qCDebug(LOG_PLASMA) << "loading applet by name" << name << useRuntimeCache << ret.size(); } else { - - for (const auto& dir : dirs) { + for (const auto &dir : dirs) { ret = KPluginLoader::findPluginsById(dir, pluginName); if (!ret.isEmpty()) break; diff --git a/src/plasma/pluginloader.h b/src/plasma/pluginloader.h index bbcd9e694..809528a92 100644 --- a/src/plasma/pluginloader.h +++ b/src/plasma/pluginloader.h @@ -7,13 +7,12 @@ #ifndef PLUGIN_LOADER_H #define PLUGIN_LOADER_H +#include #include #include -#include namespace Plasma { - class Applet; class Containment; class ContainmentActions; @@ -22,7 +21,7 @@ class Service; class PluginLoaderPrivate; -//TODO: +// TODO: // * add loadWallpaper // * add KPluginInfo listing support for Containments (already loaded via the applet loading code) @@ -52,8 +51,7 @@ public: * @param args to send the applet extra arguments * @return a pointer to the loaded applet, or 0 on load failure **/ - Applet *loadApplet(const QString &name, uint appletId = 0, - const QVariantList &args = QVariantList()); + Applet *loadApplet(const QString &name, uint appletId = 0, const QVariantList &args = QVariantList()); /** * Load a dataengine plugin. @@ -128,8 +126,7 @@ public: * @param args to send the containmentactions extra arguments * @return a ContainmentActions object **/ - ContainmentActions *loadContainmentActions(Containment *parent, const QString &containmentActionsName, - const QVariantList &args = QVariantList()); + ContainmentActions *loadContainmentActions(Containment *parent, const QString &containmentActionsName, const QVariantList &args = QVariantList()); #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 30) /** @@ -239,8 +236,7 @@ public: * @return list of categories * @param visibleOnly true if it should only return applets that are marked as visible */ - QStringList listAppletCategories(const QString &parentApp = QString(), - bool visibleOnly = true); + QStringList listAppletCategories(const QString &parentApp = QString(), bool visibleOnly = true); /** * Sets the list of custom categories that are used in addition to the default @@ -278,8 +274,7 @@ public: * list of all containments. * @return list of containments **/ - static KPluginInfo::List listContainments(const QString &category = QString(), - const QString &parentApp = QString()); + static KPluginInfo::List listContainments(const QString &category = QString(), const QString &parentApp = QString()); /** * Returns a list of all known containments that match the parameters. @@ -299,9 +294,7 @@ public: * list of all containments, matching categories/type. * @return list of containments **/ - static KPluginInfo::List listContainmentsOfType(const QString &type, - const QString &category = QString(), - const QString &parentApp = QString()); + static KPluginInfo::List listContainmentsOfType(const QString &type, const QString &category = QString(), const QString &parentApp = QString()); /** * @return a list of all known types of containments on this system @@ -396,8 +389,7 @@ protected: * @param args to send the applet extra arguments * @return a pointer to the loaded applet, or 0 on load failure **/ - virtual Applet *internalLoadApplet(const QString &name, uint appletId = 0, - const QVariantList &args = QVariantList()); + virtual Applet *internalLoadApplet(const QString &name, uint appletId = 0, const QVariantList &args = QVariantList()); /** * A re-implementable method that allows subclasses to override diff --git a/src/plasma/private/actionwidgetinterface_p.h b/src/plasma/private/actionwidgetinterface_p.h index 294132bd1..89abc2446 100644 --- a/src/plasma/private/actionwidgetinterface_p.h +++ b/src/plasma/private/actionwidgetinterface_p.h @@ -13,14 +13,13 @@ namespace Plasma { - -template +template class ActionWidgetInterface : public ThemedWidgetInterface { public: ActionWidgetInterface(T *parent) - : ThemedWidgetInterface(parent), - action(nullptr) + : ThemedWidgetInterface(parent) + , action(nullptr) { } @@ -48,8 +47,8 @@ public: this->q->setEnabled(false); return; } - //we don't get told *what* changed, just that something changed - //so we update everything we care about + // we don't get told *what* changed, just that something changed + // so we update everything we care about this->q->setIcon(action->icon()); this->q->setText(action->iconText()); this->q->setEnabled(action->isEnabled()); @@ -84,4 +83,3 @@ public: } // namespace Plasma #endif - diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index 8446600e4..6a2721f00 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -12,67 +12,65 @@ #include +#include +#include #include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include #include #include "containment.h" #include "corona.h" +#include "debug_p.h" #include "pluginloader.h" -#include "scripting/scriptengine.h" -#include "scripting/appletscript.h" #include "private/containment_p.h" #include "private/package_p.h" +#include "scripting/appletscript.h" +#include "scripting/scriptengine.h" #include "timetracker.h" -#include "debug_p.h" namespace Plasma { - AppletPrivate::AppletPrivate(const KPluginMetaData &info, int uniqueID, Applet *applet) - : appletId(uniqueID), - q(applet), - immutability(Types::Mutable), - oldImmutability(Types::Mutable), - appletDescription(info), - icon(appletDescription.iconName()), - mainConfig(nullptr), - pendingConstraints(Types::NoConstraint), - script(nullptr), - package(nullptr), - configLoader(nullptr), - actions(AppletPrivate::defaultActions(applet)), - activationAction(nullptr), - itemStatus(Types::UnknownStatus), - modificationsTimer(nullptr), - deleteNotificationTimer(nullptr), - hasConfigurationInterface(false), - failed(false), - transient(false), - needsConfig(false), - started(false), - globalShortcutEnabled(false), - userConfiguring(false), - busy(false) + : appletId(uniqueID) + , q(applet) + , immutability(Types::Mutable) + , oldImmutability(Types::Mutable) + , appletDescription(info) + , icon(appletDescription.iconName()) + , mainConfig(nullptr) + , pendingConstraints(Types::NoConstraint) + , script(nullptr) + , package(nullptr) + , configLoader(nullptr) + , actions(AppletPrivate::defaultActions(applet)) + , activationAction(nullptr) + , itemStatus(Types::UnknownStatus) + , modificationsTimer(nullptr) + , deleteNotificationTimer(nullptr) + , hasConfigurationInterface(false) + , failed(false) + , transient(false) + , needsConfig(false) + , started(false) + , globalShortcutEnabled(false) + , userConfiguring(false) + , busy(false) { if (appletId == 0) { appletId = ++s_maxAppletId; } else if (appletId > s_maxAppletId) { s_maxAppletId = appletId; } - QObject::connect(actions->action(QStringLiteral("configure")), SIGNAL(triggered()), - q, SLOT(requestConfiguration())); + QObject::connect(actions->action(QStringLiteral("configure")), SIGNAL(triggered()), q, SLOT(requestConfiguration())); #ifndef NDEBUG if (qEnvironmentVariableIsSet("PLASMA_TRACK_STARTUP")) { new TimeTracker(q); @@ -82,7 +80,6 @@ AppletPrivate::AppletPrivate(const KPluginMetaData &info, int uniqueID, Applet * AppletPrivate::~AppletPrivate() { - if (deleteNotification) { deleteNotification->close(); } @@ -128,9 +125,11 @@ void AppletPrivate::init(const QString &_packagePath, const QVariantList &args) return; } - //A constructor may have set a valid package already + // A constructor may have set a valid package already if (!package.isValid()) { - const QString packagePath = _packagePath.isEmpty() && !appletDescription.metaDataFileName().isEmpty() ? QFileInfo(appletDescription.metaDataFileName()).dir().path() : _packagePath; + const QString packagePath = _packagePath.isEmpty() && !appletDescription.metaDataFileName().isEmpty() + ? QFileInfo(appletDescription.metaDataFileName()).dir().path() + : _packagePath; QString path = appletDescription.rawData().value(QStringLiteral("X-Plasma-RootPath")).toString(); if (path.isEmpty()) { path = packagePath.isEmpty() ? appletDescription.pluginId() : packagePath; @@ -141,8 +140,9 @@ void AppletPrivate::init(const QString &_packagePath, const QVariantList &args) if (!package.isValid()) { q->setLaunchErrorMessage(i18nc("Package file, name of the widget", - "Could not open the %1 package required for the %2 widget.", - appletDescription.pluginId(), appletDescription.name())); + "Could not open the %1 package required for the %2 widget.", + appletDescription.pluginId(), + appletDescription.name())); return; } } @@ -152,18 +152,18 @@ void AppletPrivate::init(const QString &_packagePath, const QVariantList &args) // deleted when the applet does script = Plasma::loadScriptEngine(api, q, args); - //It's valid, let's try to load the icon from within the package + // It's valid, let's try to load the icon from within the package if (script) { - //use the absolute path of the in-package icon as icon name + // use the absolute path of the in-package icon as icon name if (appletDescription.iconName().startsWith(QLatin1Char('/'))) { icon = package.filePath({}, appletDescription.iconName()); } - //package not valid, get rid of it + // package not valid, get rid of it } else { - q->setLaunchErrorMessage( - i18nc("API or programming language the widget was written in, name of the widget", - "Could not create a %1 ScriptEngine for the %2 widget.", - api, appletDescription.name())); + q->setLaunchErrorMessage(i18nc("API or programming language the widget was written in, name of the widget", + "Could not create a %1 ScriptEngine for the %2 widget.", + api, + appletDescription.name())); } if (!q->isContainment()) { @@ -181,8 +181,7 @@ void AppletPrivate::init(const QString &_packagePath, const QVariantList &args) const QStringList provides = KPluginMetaData::readStringList(q->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides")); if (!provides.isEmpty() && q->immutability() == Types::Mutable) { - auto filter = [&provides](const KPluginMetaData &md) -> bool - { + auto filter = [&provides](const KPluginMetaData &md) -> bool { const QStringList provided = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-Provides")); for (const QString &p : provides) { if (provided.contains(p)) { @@ -212,7 +211,7 @@ void AppletPrivate::cleanUpAndDelete() resetConfigurationObject(); if (activationAction && globalShortcutEnabled) { - //qCDebug(LOG_PLASMA) << "resetting global action for" << q->title() << activationAction->objectName(); + // qCDebug(LOG_PLASMA) << "resetting global action for" << q->title() << activationAction->objectName(); KGlobalAccel::self()->removeAllShortcuts(activationAction); } @@ -229,31 +228,31 @@ void AppletPrivate::setDestroyed(bool destroyed) { transient = destroyed; Q_EMIT q->destroyedChanged(destroyed); - //when an applet gets transient, it's "systemimmutable" + // when an applet gets transient, it's "systemimmutable" Q_EMIT q->immutabilityChanged(q->immutability()); Plasma::Containment *asContainment = qobject_cast(q); if (asContainment) { const auto lstApplets = asContainment->applets(); for (Applet *a : lstApplets) - a->d->setDestroyed(destroyed); + a->d->setDestroyed(destroyed); } } void AppletPrivate::askDestroy() { if (q->immutability() != Types::Mutable || !started) { - return; //don't double delete + return; // don't double delete } if (transient) { cleanUpAndDelete(); } else { - //There is no confirmation anymore for panels removal: - //this needs users feedback + // There is no confirmation anymore for panels removal: + // this needs users feedback setDestroyed(true); - //no parent, but it won't leak, since it will be closed both in case of timeout - //or direct action + // no parent, but it won't leak, since it will be closed both in case of timeout + // or direct action deleteNotification = new KNotification(QStringLiteral("plasmoidDeleted")); deleteNotification->setFlags(KNotification::Persistent | KNotification::SkipGrouping); @@ -265,10 +264,11 @@ void AppletPrivate::askDestroy() if (!q->isContainment()) { deleteNotification->setTitle(i18n("Widget Removed")); deleteNotification->setText(i18n("The widget \"%1\" has been removed.", q->title().toHtmlEscaped())); - } else if (asContainment && (asContainment->containmentType() == Types::PanelContainment || asContainment->containmentType() == Types::CustomPanelContainment)) { + } else if (asContainment + && (asContainment->containmentType() == Types::PanelContainment || asContainment->containmentType() == Types::CustomPanelContainment)) { deleteNotification->setTitle(i18n("Panel Removed")); deleteNotification->setText(i18n("A panel has been removed.")); - //This will never happen with our current shell, but could with a custom one + // This will never happen with our current shell, but could with a custom one } else { deleteNotification->setTitle(i18n("Desktop Removed")); deleteNotification->setText(i18n("A desktop has been removed.")); @@ -276,63 +276,61 @@ void AppletPrivate::askDestroy() actions.append(i18n("Undo")); deleteNotification->setActions(actions); - QObject::connect(deleteNotification.data(), &KNotification::action1Activated, q, - [=]() { - setDestroyed(false); - if (!q->isContainment() && q->containment()) { - Plasma::Applet *containmentApplet = static_cast(q->containment()); - if (containmentApplet && containmentApplet->d->deleteNotificationTimer) { - Q_EMIT containmentApplet->destroyedChanged(false); - //when an applet gets transient, it's "systemimmutable" - Q_EMIT q->immutabilityChanged(q->immutability()); - delete containmentApplet->d->deleteNotificationTimer; - containmentApplet->d->deleteNotificationTimer = nullptr; - } + QObject::connect(deleteNotification.data(), &KNotification::action1Activated, q, [=]() { + setDestroyed(false); + if (!q->isContainment() && q->containment()) { + Plasma::Applet *containmentApplet = static_cast(q->containment()); + if (containmentApplet && containmentApplet->d->deleteNotificationTimer) { + Q_EMIT containmentApplet->destroyedChanged(false); + // when an applet gets transient, it's "systemimmutable" + Q_EMIT q->immutabilityChanged(q->immutability()); + delete containmentApplet->d->deleteNotificationTimer; + containmentApplet->d->deleteNotificationTimer = nullptr; + } - //make sure the applets are sorted by id - auto position = std::lower_bound(q->containment()->d->applets.begin(), q->containment()->d->applets.end(), q, [](Plasma::Applet *a1, Plasma::Applet *a2) { - return a1->id() < a2->id(); - }); - q->containment()->d->applets.insert(position, q); - Q_EMIT q->containment()->appletAdded(q); - } - if (deleteNotification) { - deleteNotification->close(); - } else if (deleteNotificationTimer) { - deleteNotificationTimer->stop(); - deleteNotificationTimer->deleteLater(); - deleteNotificationTimer = nullptr; - } - }); - QObject::connect(deleteNotification.data(), &KNotification::closed, q, - [=]() { - //If the timer still exists, it means the undo action was NOT triggered - if (transient) { - cleanUpAndDelete(); - } - if (deleteNotificationTimer) { - deleteNotificationTimer->stop(); - deleteNotificationTimer->deleteLater(); - deleteNotificationTimer = nullptr; - } - }); + // make sure the applets are sorted by id + auto position = + std::lower_bound(q->containment()->d->applets.begin(), q->containment()->d->applets.end(), q, [](Plasma::Applet *a1, Plasma::Applet *a2) { + return a1->id() < a2->id(); + }); + q->containment()->d->applets.insert(position, q); + Q_EMIT q->containment()->appletAdded(q); + } + if (deleteNotification) { + deleteNotification->close(); + } else if (deleteNotificationTimer) { + deleteNotificationTimer->stop(); + deleteNotificationTimer->deleteLater(); + deleteNotificationTimer = nullptr; + } + }); + QObject::connect(deleteNotification.data(), &KNotification::closed, q, [=]() { + // If the timer still exists, it means the undo action was NOT triggered + if (transient) { + cleanUpAndDelete(); + } + if (deleteNotificationTimer) { + deleteNotificationTimer->stop(); + deleteNotificationTimer->deleteLater(); + deleteNotificationTimer = nullptr; + } + }); deleteNotification->sendEvent(); if (!deleteNotificationTimer) { deleteNotificationTimer = new QTimer(q); - //really delete after a minute + // really delete after a minute deleteNotificationTimer->setInterval(60 * 1000); deleteNotificationTimer->setSingleShot(true); - QObject::connect(deleteNotificationTimer, &QTimer::timeout, q, - [=]() { - transient = true; - if (deleteNotification) { - deleteNotification->close(); - } else { - Q_EMIT q->destroyedChanged(true); - cleanUpAndDelete(); - } - }); + QObject::connect(deleteNotificationTimer, &QTimer::timeout, q, [=]() { + transient = true; + if (deleteNotification) { + deleteNotification->close(); + } else { + Q_EMIT q->destroyedChanged(true); + cleanUpAndDelete(); + } + }); deleteNotificationTimer->start(); } if (!q->isContainment() && q->containment()) { @@ -354,7 +352,7 @@ void AppletPrivate::globalShortcutChanged() shortcutConfig.writeEntry("global", newShortCut); scheduleModificationNotification(); } - //qCDebug(LOG_PLASMA) << "after" << shortcut.primary() << d->activationAction->globalShortcut().primary(); + // qCDebug(LOG_PLASMA) << "after" << shortcut.primary() << d->activationAction->globalShortcut().primary(); } KActionCollection *AppletPrivate::defaultActions(QObject *parent) @@ -398,13 +396,13 @@ void AppletPrivate::requestConfiguration() void AppletPrivate::updateShortcuts() { if (q->isContainment()) { - //a horrible hack to avoid clobbering corona settings - //we pull them out, then read, then put them back + // a horrible hack to avoid clobbering corona settings + // we pull them out, then read, then put them back QList qactions; - const QList names = { QStringLiteral("add sibling containment"), QStringLiteral("configure shortcuts"), QStringLiteral("lock widgets")}; + const QList names = {QStringLiteral("add sibling containment"), QStringLiteral("configure shortcuts"), QStringLiteral("lock widgets")}; for (const QString &name : names) { QAction *a = actions->action(name); - actions->takeAction(a); //FIXME this is stupid, KActionCollection needs a takeAction(QString) method + actions->takeAction(a); // FIXME this is stupid, KActionCollection needs a takeAction(QString) method qactions << a; } @@ -432,11 +430,11 @@ void AppletPrivate::propagateConfigChanged() void AppletPrivate::setUiReady() { - //am i the containment? + // am i the containment? Containment *c = qobject_cast(q); if (c && c->isContainment()) { c->d->setUiReady(); - } else if (Containment* cc = q->containment()) { + } else if (Containment *cc = q->containment()) { cc->d->appletLoaded(q); } } @@ -494,7 +492,7 @@ void AppletPrivate::scheduleConstraintsUpdate(Plasma::Types::Constraints c) if (c & Plasma::Types::StartupCompletedConstraint) { started = true; if (q->isContainment()) { - qobject_cast(q)->d->setStarted(); + qobject_cast(q)->d->setStarted(); } } @@ -525,7 +523,7 @@ KConfigGroup *AppletPrivate::mainConfigGroup() if (q->isContainment()) { Corona *corona = static_cast(q)->corona(); KConfigGroup containmentConfig; - //qCDebug(LOG_PLASMA) << "got a corona, baby?" << (QObject*)corona << (QObject*)q; + // qCDebug(LOG_PLASMA) << "got a corona, baby?" << (QObject*)corona << (QObject*)q; if (parentApplet) { containmentConfig = parentApplet->config(); @@ -533,7 +531,7 @@ KConfigGroup *AppletPrivate::mainConfigGroup() } else if (corona) { containmentConfig = KConfigGroup(corona->config(), "Containments"); } else { - containmentConfig = KConfigGroup(KSharedConfig::openConfig(), "Containments"); + containmentConfig = KConfigGroup(KSharedConfig::openConfig(), "Containments"); } mainConfig = new KConfigGroup(&containmentConfig, QString::number(appletId)); @@ -568,7 +566,7 @@ void AppletPrivate::resetConfigurationObject() mainConfig->deleteEntry("formfactor"); mainConfig->deleteEntry("immutability"); mainConfig->deleteEntry("location"); - //if it's not a containment, deleting the non existing activityId entry does nothing + // if it's not a containment, deleting the non existing activityId entry does nothing mainConfig->deleteEntry("activityId"); mainConfig->deleteGroup(); delete mainConfig; @@ -591,4 +589,4 @@ void AppletPrivate::resetConfigurationObject() uint AppletPrivate::s_maxAppletId = 0; -} //namespace Plasma +} // namespace Plasma diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index 8bdbc6da0..5b9803b8f 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -24,7 +24,6 @@ class KKeySequenceWidget; namespace Plasma { - class AppletScript; class Service; @@ -93,7 +92,7 @@ public: QBasicTimer constraintsTimer; QBasicTimer *modificationsTimer; - QPointer deleteNotification; + QPointer deleteNotification; QTimer *deleteNotificationTimer; QString configurationRequiredReason; diff --git a/src/plasma/private/associatedapplicationmanager.cpp b/src/plasma/private/associatedapplicationmanager.cpp index 387d4a7b3..1b00eba83 100644 --- a/src/plasma/private/associatedapplicationmanager.cpp +++ b/src/plasma/private/associatedapplicationmanager.cpp @@ -9,27 +9,26 @@ #include "config-plasma.h" #include "debug_p.h" -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include -#include -#include #include #include #include -#include #include +#include +#include #include +#include #include "plasma/applet.h" namespace Plasma { - class AssociatedApplicationManagerPrivate { public: @@ -52,7 +51,7 @@ public: { QMimeDatabase mimeDb; - QHash >::iterator i; + QHash>::iterator i; for (i = urlLists.begin(); i != urlLists.end(); ++i) { QAction *a = i.key()->actions()->action(QStringLiteral("run associated application")); if (a) { @@ -70,7 +69,7 @@ public: } QHash applicationNames; - QHash > urlLists; + QHash> urlLists; }; class AssociatedApplicationManagerSingleton @@ -82,8 +81,8 @@ public: Q_GLOBAL_STATIC(AssociatedApplicationManagerSingleton, privateAssociatedApplicationManagerSelf) AssociatedApplicationManager::AssociatedApplicationManager(QObject *parent) - : QObject(parent), - d(new AssociatedApplicationManagerPrivate()) + : QObject(parent) + , d(new AssociatedApplicationManagerPrivate()) { connect(KSycoca::self(), SIGNAL(databaseChanged()), this, SLOT(updateActionNames())); } @@ -108,7 +107,7 @@ void AssociatedApplicationManager::setApplication(Plasma::Applet *applet, const if (hasAppBefore) { d->applicationNames.remove(applet); if (!hasUrls) { - disconnect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(cleanupApplet(QObject*))); + disconnect(applet, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupApplet(QObject *))); } } return; @@ -125,7 +124,7 @@ void AssociatedApplicationManager::setApplication(Plasma::Applet *applet, const a->setText(i18n("Run the Associated Application")); } } else if (!hasAppBefore) { - connect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(cleanupApplet(QObject*))); + connect(applet, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupApplet(QObject *))); } } } @@ -145,7 +144,7 @@ void AssociatedApplicationManager::setUrls(Plasma::Applet *applet, const QListurlLists.remove(applet); if (!hasApp) { - disconnect(applet, SIGNAL(destroyed(QObject*)), this, SLOT(cleanupApplet(QObject*))); + disconnect(applet, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupApplet(QObject *))); } } return; @@ -168,11 +167,11 @@ void AssociatedApplicationManager::setUrls(Plasma::Applet *applet, const QList AssociatedApplicationManager::urls(const Plasma::Applet *applet) const { return d->urlLists.value(applet); @@ -208,4 +207,3 @@ bool AssociatedApplicationManager::appletHasValidAssociatedApplication(const Pla } // namespace Plasma #include - diff --git a/src/plasma/private/associatedapplicationmanager_p.h b/src/plasma/private/associatedapplicationmanager_p.h index 8d93a5c22..06b7258d1 100644 --- a/src/plasma/private/associatedapplicationmanager_p.h +++ b/src/plasma/private/associatedapplicationmanager_p.h @@ -23,19 +23,19 @@ class AssociatedApplicationManager : public QObject public: static AssociatedApplicationManager *self(); - //set an application name for an applet + // set an application name for an applet void setApplication(Plasma::Applet *applet, const QString &application); - //returns the application name associated to an applet + // returns the application name associated to an applet QString application(const Plasma::Applet *applet) const; - //sets the urls associated to an applet + // sets the urls associated to an applet void setUrls(Plasma::Applet *applet, const QList &urls); - //returns the urls associated to an applet + // returns the urls associated to an applet QList urls(const Plasma::Applet *applet) const; - //run the associated application or the urls if no app is associated + // run the associated application or the urls if no app is associated void run(Plasma::Applet *applet); - //returns true if the applet has a valid associated application or urls + // returns true if the applet has a valid associated application or urls bool appletHasValidAssociatedApplication(const Plasma::Applet *applet) const; private: diff --git a/src/plasma/private/authorizationmanager_p.h b/src/plasma/private/authorizationmanager_p.h index 574bf7f3d..6709b1485 100644 --- a/src/plasma/private/authorizationmanager_p.h +++ b/src/plasma/private/authorizationmanager_p.h @@ -31,7 +31,6 @@ class Server; namespace Plasma { - class AuthorizationInterface; class AuthorizationRule; class Credentials; @@ -51,20 +50,19 @@ public: void addCredentials(const Credentials &identity); void saveRules(); - AuthorizationManager *q; - Jolie::Server *server; - AuthorizationManager::AuthorizationPolicy - authorizationPolicy; - AuthorizationInterface *authorizationInterface; - AuthorizationInterface *customAuthorizationInterface; - KWallet::Wallet *wallet; + AuthorizationManager *q; + Jolie::Server *server; + AuthorizationManager::AuthorizationPolicy authorizationPolicy; + AuthorizationInterface *authorizationInterface; + AuthorizationInterface *customAuthorizationInterface; + KWallet::Wallet *wallet; - Credentials myCredentials; - QMap identities; - QList rules; - KConfigGroup identitiesConfig; - KConfigGroup rulesConfig; - bool locked; + Credentials myCredentials; + QMap identities; + QList rules; + KConfigGroup identitiesConfig; + KConfigGroup rulesConfig; + bool locked; }; } diff --git a/src/plasma/private/containment_p.cpp b/src/plasma/private/containment_p.cpp index cb92f3e93..2009aab25 100644 --- a/src/plasma/private/containment_p.cpp +++ b/src/plasma/private/containment_p.cpp @@ -9,34 +9,34 @@ #include "private/containment_p.h" -#include #include #include +#include #include "config-plasma.h" #include "pluginloader.h" +#include "debug_p.h" #include "private/applet_p.h" #include "timetracker.h" -#include "debug_p.h" namespace Plasma { - const char ContainmentPrivate::defaultWallpaper[] = "org.kde.image"; -ContainmentPrivate::ContainmentPrivate(Containment *c): - q(c), - formFactor(Types::Planar), - location(Types::Floating), - lastScreen(-1), // never had a screen - type(Plasma::Types::NoContainmentType), - uiReady(false), - appletsUiReady(false) +ContainmentPrivate::ContainmentPrivate(Containment *c) + : q(c) + , formFactor(Types::Planar) + , location(Types::Floating) + , lastScreen(-1) + , // never had a screen + type(Plasma::Types::NoContainmentType) + , uiReady(false) + , appletsUiReady(false) { - //if the parent is an applet (i.e we are the systray) - //we want to follow screen changed signals from the parent's containment + // if the parent is an applet (i.e we are the systray) + // we want to follow screen changed signals from the parent's containment auto appletParent = qobject_cast(c->parent()); if (appletParent) { QObject::connect(appletParent->containment(), &Containment::screenChanged, c, &Containment::screenChanged); @@ -48,14 +48,13 @@ Plasma::ContainmentPrivate::~ContainmentPrivate() applets.clear(); } - void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containment *c) { actions->setConfigGroup(QStringLiteral("Shortcuts-Containment")); - //adjust applet actions + // adjust applet actions QAction *appAction = qobject_cast(actions->action(QStringLiteral("remove"))); - appAction->setShortcut(QKeySequence(Qt::ALT+Qt::Key_D, Qt::ALT+Qt::Key_R)); + appAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_D, Qt::ALT + Qt::Key_R)); if (c && c->d->isPanelContainment()) { appAction->setText(i18n("Remove this Panel")); } else { @@ -64,16 +63,16 @@ void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containme appAction = qobject_cast(actions->action(QStringLiteral("configure"))); if (appAction) { - appAction->setShortcut(QKeySequence(Qt::ALT+Qt::Key_D, Qt::ALT+Qt::Key_S)); + appAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_D, Qt::ALT + Qt::Key_S)); appAction->setText(i18n("Activity Settings")); } - //add our own actions + // add our own actions QAction *appletBrowserAction = actions->add(QStringLiteral("add widgets")); appletBrowserAction->setAutoRepeat(false); appletBrowserAction->setText(i18n("Add Widgets...")); appletBrowserAction->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); - appletBrowserAction->setShortcut(QKeySequence(Qt::ALT+Qt::Key_D, Qt::Key_A)); + appletBrowserAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_D, Qt::Key_A)); appletBrowserAction->setData(Plasma::Types::AddAction); } @@ -91,7 +90,7 @@ void ContainmentPrivate::configChanged() void ContainmentPrivate::checkStatus(Plasma::Types::ItemStatus appletStatus) { - //qCDebug(LOG_PLASMA) << "================== "<< appletStatus << q->status(); + // qCDebug(LOG_PLASMA) << "================== "<< appletStatus << q->status(); if (appletStatus == q->status()) { return; } @@ -122,9 +121,9 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Types::Constraints return; } - //qCDebug(LOG_PLASMA) << "got containmentConstraintsEvent" << constraints; + // qCDebug(LOG_PLASMA) << "got containmentConstraintsEvent" << constraints; if (constraints & Plasma::Types::ImmutableConstraint) { - //update actions + // update actions const bool unlocked = q->immutability() == Types::Mutable; QAction *action = q->actions()->action(QStringLiteral("remove")); @@ -191,7 +190,7 @@ Applet *ContainmentPrivate::createApplet(const QString &name, const QVariantList } q->addApplet(applet); - //mirror behavior of resorecontents: if an applet is not valid, set it immediately to uiReady + // mirror behavior of resorecontents: if an applet is not valid, set it immediately to uiReady if (!applet->pluginMetaData().isValid()) { applet->updateConstraints(Plasma::Types::UiReadyConstraint); } @@ -224,7 +223,7 @@ void ContainmentPrivate::setStarted() void ContainmentPrivate::setUiReady() { - //if we are the containment and there is still some uncomplete applet, we're still incomplete + // if we are the containment and there is still some uncomplete applet, we're still incomplete if (!uiReady) { uiReady = true; if (q->Applet::d->started && (appletsUiReady || applets.isEmpty()) && loadingApplets.isEmpty()) { @@ -233,7 +232,7 @@ void ContainmentPrivate::setUiReady() } } -void ContainmentPrivate::appletLoaded(Applet* applet) +void ContainmentPrivate::appletLoaded(Applet *applet) { loadingApplets.remove(applet); diff --git a/src/plasma/private/containment_p.h b/src/plasma/private/containment_p.h index 55b44067e..69d856057 100644 --- a/src/plasma/private/containment_p.h +++ b/src/plasma/private/containment_p.h @@ -11,10 +11,10 @@ #include #include -#include "plasma.h" #include "applet.h" -#include "corona.h" #include "containmentactions.h" +#include "corona.h" +#include "plasma.h" class KJob; @@ -25,7 +25,6 @@ class Job; namespace Plasma { - class Containment; class ContainmentPrivate @@ -64,7 +63,7 @@ public: void setUiReady(); void setStarted(); - void appletLoaded(Applet* applet); + void appletLoaded(Applet *applet); Containment *q; Types::FormFactor formFactor; @@ -72,8 +71,8 @@ public: Types::ContainmentDisplayHints containmentDisplayHints = Types::NoContainmentDisplayHint; QList applets; - //Applets still considered not ready - QSet loadingApplets; + // Applets still considered not ready + QSet loadingApplets; QString wallpaper; QHash localActionPlugins; int lastScreen; diff --git a/src/plasma/private/containmentactions_p.h b/src/plasma/private/containmentactions_p.h index 3193fdc44..d59fee056 100644 --- a/src/plasma/private/containmentactions_p.h +++ b/src/plasma/private/containmentactions_p.h @@ -11,26 +11,25 @@ namespace Plasma { - #if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) -static KPluginMetaData pluginMetaDatafromArg(const QVariant& arg) +static KPluginMetaData pluginMetaDatafromArg(const QVariant &arg) { if (arg.canConvert()) { return arg.value(); } -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") + QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") return KPluginInfo(KService::serviceByStorageId(arg.toString())).toMetaData(); -QT_WARNING_POP + QT_WARNING_POP } #endif class ContainmentActionsPrivate { public: - ContainmentActionsPrivate(const QVariant& arg, ContainmentActions */*containmentActions*/) + ContainmentActionsPrivate(const QVariant &arg, ContainmentActions * /*containmentActions*/) #if KSERVICE_BUILD_DEPRECATED_SINCE(5, 0) : containmentActionsDescription(pluginMetaDatafromArg(arg)) #else @@ -44,5 +43,4 @@ public: }; } // namespace Plasma -#endif //PLASMA_CONTAINMENTACTIONSPRIVATE_H - +#endif // PLASMA_CONTAINMENTACTIONSPRIVATE_H diff --git a/src/plasma/private/corona_p.h b/src/plasma/private/corona_p.h index d14ddb5f4..2f0e26725 100644 --- a/src/plasma/private/corona_p.h +++ b/src/plasma/private/corona_p.h @@ -17,7 +17,6 @@ class KShortcutsDialog; namespace Plasma { - class Containment; class CoronaPrivate diff --git a/src/plasma/private/datacontainer_p.cpp b/src/plasma/private/datacontainer_p.cpp index 5fb48c2b9..2d919704c 100644 --- a/src/plasma/private/datacontainer_p.cpp +++ b/src/plasma/private/datacontainer_p.cpp @@ -4,24 +4,23 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include "datacontainer.h" //krazy:exclude=includes #include "datacontainer_p.h" //krazy:exclude=includes +#include "datacontainer.h" //krazy:exclude=includes namespace Plasma { - -SignalRelay *DataContainerPrivate::signalRelay(const DataContainer *dc, QObject *visualization, - uint pollingInterval, - Plasma::Types::IntervalAlignment align, - bool immediateUpdate) +SignalRelay *DataContainerPrivate::signalRelay(const DataContainer *dc, + QObject *visualization, + uint pollingInterval, + Plasma::Types::IntervalAlignment align, + bool immediateUpdate) { QMap::const_iterator relayIt = relays.constFind(pollingInterval); SignalRelay *relay = nullptr; - //FIXME what if we have two applets with the same interval and different alignment? + // FIXME what if we have two applets with the same interval and different alignment? if (relayIt == relays.constEnd()) { - relay = new SignalRelay(const_cast(dc), this, - pollingInterval, align, immediateUpdate); + relay = new SignalRelay(const_cast(dc), this, pollingInterval, align, immediateUpdate); relays[pollingInterval] = relay; } else { relay = relayIt.value(); @@ -42,17 +41,16 @@ bool DataContainerPrivate::hasUpdates() return dirty; } -SignalRelay::SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint ival, - Plasma::Types::IntervalAlignment align, bool immediateUpdate) - : QObject(parent), - dc(parent), - d(data), - m_interval(ival), - m_align(align), - m_resetTimer(true), - m_queued(true) +SignalRelay::SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint ival, Plasma::Types::IntervalAlignment align, bool immediateUpdate) + : QObject(parent) + , dc(parent) + , d(data) + , m_interval(ival) + , m_align(align) + , m_resetTimer(true) + , m_queued(true) { - //qCDebug(LOG_PLASMA) << "signal relay with time of" << m_timerId << "being set up"; + // qCDebug(LOG_PLASMA) << "signal relay with time of" << m_timerId << "being set up"; m_timerId = startTimer(immediateUpdate ? 0 : m_interval); if (m_align != Plasma::Types::NoAlignment) { checkAlignment(); @@ -61,12 +59,12 @@ SignalRelay::SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint int SignalRelay::receiverCount() const { - return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))); + return receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))); } bool SignalRelay::isUnused() const { - return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) < 1; + return receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))) < 1; } void SignalRelay::checkAlignment() @@ -81,8 +79,7 @@ void SignalRelay::checkAlignment() int minutes = t.minute(); int seconds = t.second(); if (minutes > 1 || seconds > 10) { - newTime = ((60 - minutes) * 1000 * 60) + - ((60 - seconds) * 1000) + 500; + newTime = ((60 - minutes) * 1000 * 60) + ((60 - seconds) * 1000) + 500; } } @@ -95,11 +92,11 @@ void SignalRelay::checkAlignment() void SignalRelay::checkQueueing() { - //qCDebug(LOG_PLASMA) << m_queued; + // qCDebug(LOG_PLASMA) << m_queued; if (m_queued) { Q_EMIT dataUpdated(dc->objectName(), d->data); m_queued = false; - //TODO: should we re-align our timer at this point, to avoid + // TODO: should we re-align our timer at this point, to avoid // constant queueing due to more-or-less constant time // async update time? this might make sense for // staggered accesses to the same source by multiple @@ -138,13 +135,13 @@ void SignalRelay::timerEvent(QTimerEvent *event) Q_EMIT dc->updateRequested(dc); if (d->hasUpdates()) { - //qCDebug(LOG_PLASMA) << "emitting data updated directly" << d->data; + // qCDebug(LOG_PLASMA) << "emitting data updated directly" << d->data; Q_EMIT dataUpdated(dc->objectName(), d->data); m_queued = false; } else { // the source wasn't actually updated; so let's put ourselves in the queue // so we get a dataUpdated() call when the data does arrive - //qCDebug(LOG_PLASMA) << "queued"; + // qCDebug(LOG_PLASMA) << "queued"; m_queued = true; } } diff --git a/src/plasma/private/datacontainer_p.h b/src/plasma/private/datacontainer_p.h index 5e9777c78..b553b20da 100644 --- a/src/plasma/private/datacontainer_p.h +++ b/src/plasma/private/datacontainer_p.h @@ -10,9 +10,9 @@ #include "servicejob.h" #include "storage_p.h" -#include -#include #include +#include +#include #include @@ -27,13 +27,13 @@ class DataContainerPrivate { public: DataContainerPrivate(DataContainer *container) - : q(container), - storage(nullptr), - storageCount(0), - dirty(false), - cached(false), - enableStorage(false), - isStored(true) + : q(container) + , storage(nullptr) + , storageCount(0) + , dirty(false) + , cached(false) + , enableStorage(false) + , isStored(true) { } @@ -47,9 +47,8 @@ public: **/ void checkUsage(); - SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization, - uint pollingInterval, Plasma::Types::IntervalAlignment align, - bool immediateUpdate); + SignalRelay * + signalRelay(const DataContainer *dc, QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment align, bool immediateUpdate); bool hasUpdates(); @@ -77,7 +76,7 @@ public: QBasicTimer storageTimer; QBasicTimer checkUsageTimer; QPointer model; - int storageCount; + int storageCount; bool dirty : 1; bool cached : 1; bool enableStorage : 1; @@ -89,8 +88,7 @@ class SignalRelay : public QObject Q_OBJECT public: - SignalRelay(DataContainer *parent, DataContainerPrivate *data, - uint ival, Plasma::Types::IntervalAlignment align, bool immediateUpdate); + SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint ival, Plasma::Types::IntervalAlignment align, bool immediateUpdate); int receiverCount() const; bool isUnused() const; @@ -117,4 +115,3 @@ protected: } // Plasma namespace #endif // multiple inclusion guard - diff --git a/src/plasma/private/dataengine_p.h b/src/plasma/private/dataengine_p.h index 57ed9310e..51de9ecb4 100644 --- a/src/plasma/private/dataengine_p.h +++ b/src/plasma/private/dataengine_p.h @@ -13,7 +13,6 @@ namespace Plasma { - class Service; class DataEnginePrivate @@ -22,8 +21,7 @@ public: DataEnginePrivate(DataEngine *e, const KPluginMetaData &info, const QVariantList &args = QVariantList()); ~DataEnginePrivate(); DataContainer *source(const QString &sourceName, bool createWhenMissing = true); - void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval, - Plasma::Types::IntervalAlignment align, bool immediateCall = true); + void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment align, bool immediateCall = true); DataContainer *requestSource(const QString &sourceName, bool *newSource = nullptr); void internalUpdateSource(DataContainer *); void setupScriptSupport(); diff --git a/src/plasma/private/dataengineconsumer_p.h b/src/plasma/private/dataengineconsumer_p.h index ed51c9640..bb4fe2763 100644 --- a/src/plasma/private/dataengineconsumer_p.h +++ b/src/plasma/private/dataengineconsumer_p.h @@ -10,13 +10,12 @@ #define PLASMA_DATAENGINECONSUMER_P_H #include +#include #include #include -#include namespace Plasma { - class DataEngineConsumer; class Service; class ServiceMonitor; @@ -38,4 +37,3 @@ public Q_SLOTS: } // namespace Plasma #endif - diff --git a/src/plasma/private/dataenginemanager.cpp b/src/plasma/private/dataenginemanager.cpp index f99d1bc07..78a72686a 100644 --- a/src/plasma/private/dataenginemanager.cpp +++ b/src/plasma/private/dataenginemanager.cpp @@ -14,15 +14,14 @@ #include #include "datacontainer.h" -#include "pluginloader.h" -#include "private/dataengine_p.h" -#include "private/datacontainer_p.h" -#include "scripting/scriptengine.h" #include "debug_p.h" +#include "pluginloader.h" +#include "private/datacontainer_p.h" +#include "private/dataengine_p.h" +#include "scripting/scriptengine.h" namespace Plasma { - class NullEngine : public DataEngine { public: @@ -41,7 +40,8 @@ class DataEngineManagerPrivate public: DataEngineManagerPrivate() : nullEng(nullptr) - {} + { + } ~DataEngineManagerPrivate() { @@ -81,7 +81,7 @@ DataEngineManager *DataEngineManager::self() DataEngineManager::DataEngineManager() : d(new DataEngineManagerPrivate) { - //startTimer(30000); + // startTimer(30000); } DataEngineManager::~DataEngineManager() @@ -169,7 +169,7 @@ void DataEngineManager::timerEvent(QTimerEvent *) out << " * " << dc->objectName() << '\n'; out << " Data count: " << dc->d->data.count() << '\n'; out << " Stored: " << dc->isStorageEnabled() << " \n"; - const int directs = dc->receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))); + const int directs = dc->receivers(SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data))); if (directs > 0) { out << " Direction Connections: " << directs << " \n"; } @@ -189,7 +189,7 @@ void DataEngineManager::timerEvent(QTimerEvent *) } out << "\n\n"; #endif -// killTimer(event->timerId()); + // killTimer(event->timerId()); } } // namespace Plasma diff --git a/src/plasma/private/dataenginemanager_p.h b/src/plasma/private/dataenginemanager_p.h index 9dff2adaa..f14391f12 100644 --- a/src/plasma/private/dataenginemanager_p.h +++ b/src/plasma/private/dataenginemanager_p.h @@ -11,7 +11,6 @@ namespace Plasma { - class DataEngineManagerPrivate; /** @@ -22,7 +21,7 @@ class DataEngineManagerPrivate; * Plasma::DataEngineManager provides facilities for listing, loading and * according to reference count unloading of DataEngines. **/ -class DataEngineManager: public QObject +class DataEngineManager : public QObject { Q_OBJECT public: diff --git a/src/plasma/private/effectwatcher.cpp b/src/plasma/private/effectwatcher.cpp index cc9c3aaee..74a157037 100644 --- a/src/plasma/private/effectwatcher.cpp +++ b/src/plasma/private/effectwatcher.cpp @@ -12,11 +12,10 @@ namespace Plasma { - EffectWatcher::EffectWatcher(const QString &property, QObject *parent) - : QObject(parent), - m_property(XCB_ATOM_NONE), - m_isX11(QX11Info::isPlatformX11()) + : QObject(parent) + , m_property(XCB_ATOM_NONE) + , m_isX11(QX11Info::isPlatformX11()) { init(property); } diff --git a/src/plasma/private/effectwatcher_p.h b/src/plasma/private/effectwatcher_p.h index dba7e5402..01453d28b 100644 --- a/src/plasma/private/effectwatcher_p.h +++ b/src/plasma/private/effectwatcher_p.h @@ -15,8 +15,7 @@ namespace Plasma { - -class EffectWatcher: public QObject, public QAbstractNativeEventFilter +class EffectWatcher : public QObject, public QAbstractNativeEventFilter { Q_OBJECT diff --git a/src/plasma/private/framesvg_helpers.h b/src/plasma/private/framesvg_helpers.h index 2954ec479..ed9242f7e 100644 --- a/src/plasma/private/framesvg_helpers.h +++ b/src/plasma/private/framesvg_helpers.h @@ -11,10 +11,8 @@ namespace Plasma { - namespace FrameSvgHelpers { - /** * @returns the element id name for said @p borders */ @@ -47,30 +45,31 @@ QString borderToElementId(FrameSvg::EnabledBorders borders) /** * @returns the suggested geometry for the @p borders given a @p fullSize frame size and a @p contentRect */ -QRect sectionRect(Plasma::FrameSvg::EnabledBorders borders, const QRect& contentRect, const QSize& fullSize) +QRect sectionRect(Plasma::FrameSvg::EnabledBorders borders, const QRect &contentRect, const QSize &fullSize) { - //don't use QRect corner methods here, they have semantics that might come as unexpected. - //prefer constructing the points explicitly. e.g. from QRect::topRight docs: - //Note that for historical reasons this function returns QPoint(left() + width() -1, top()). + // don't use QRect corner methods here, they have semantics that might come as unexpected. + // prefer constructing the points explicitly. e.g. from QRect::topRight docs: + // Note that for historical reasons this function returns QPoint(left() + width() -1, top()). if (borders == FrameSvg::NoBorder) { return contentRect; } else if (borders == FrameSvg::TopBorder) { return QRect(QPoint(contentRect.left(), 0), QSize(contentRect.width(), contentRect.top())); } else if (borders == FrameSvg::BottomBorder) { - return QRect(QPoint(contentRect.left(), contentRect.bottom()+1), QSize(contentRect.width(), fullSize.height()-contentRect.bottom()-1)); + return QRect(QPoint(contentRect.left(), contentRect.bottom() + 1), QSize(contentRect.width(), fullSize.height() - contentRect.bottom() - 1)); } else if (borders == FrameSvg::LeftBorder) { return QRect(QPoint(0, contentRect.top()), QSize(contentRect.left(), contentRect.height())); } else if (borders == FrameSvg::RightBorder) { - return QRect(QPoint(contentRect.right()+1, contentRect.top()), QSize(fullSize.width()-contentRect.right()-1, contentRect.height())); + return QRect(QPoint(contentRect.right() + 1, contentRect.top()), QSize(fullSize.width() - contentRect.right() - 1, contentRect.height())); } else if (borders == (FrameSvg::TopBorder | FrameSvg::LeftBorder)) { return QRect(QPoint(0, 0), QSize(contentRect.left(), contentRect.top())); } else if (borders == (FrameSvg::TopBorder | FrameSvg::RightBorder)) { - return QRect(QPoint(contentRect.right()+1, 0), QSize(fullSize.width()-contentRect.right()-1, contentRect.top())); + return QRect(QPoint(contentRect.right() + 1, 0), QSize(fullSize.width() - contentRect.right() - 1, contentRect.top())); } else if (borders == (FrameSvg::BottomBorder | FrameSvg::LeftBorder)) { - return QRect(QPoint(0, contentRect.bottom()+1), QSize(contentRect.left(), fullSize.height()-contentRect.bottom()-1)); + return QRect(QPoint(0, contentRect.bottom() + 1), QSize(contentRect.left(), fullSize.height() - contentRect.bottom() - 1)); } else if (borders == (FrameSvg::BottomBorder | FrameSvg::RightBorder)) { - return QRect(QPoint(contentRect.right()+1, contentRect.bottom()+1), QSize(fullSize.width()-contentRect.right()-1, fullSize.height()-contentRect.bottom()-1)); + return QRect(QPoint(contentRect.right() + 1, contentRect.bottom() + 1), + QSize(fullSize.width() - contentRect.right() - 1, fullSize.height() - contentRect.bottom() - 1)); } else { qWarning() << "unrecognized border" << borders; } diff --git a/src/plasma/private/framesvg_p.h b/src/plasma/private/framesvg_p.h index dc0e509d3..9187d050a 100644 --- a/src/plasma/private/framesvg_p.h +++ b/src/plasma/private/framesvg_p.h @@ -8,8 +8,8 @@ #ifndef PLASMA_FRAMESVG_P_H #define PLASMA_FRAMESVG_P_H -#include #include +#include #include #include @@ -20,51 +20,50 @@ namespace Plasma { - class FrameData { public: FrameData(FrameSvg *svg, const QString &p) - : imagePath(svg->imagePath()), - prefix(p), - enabledBorders(FrameSvg::AllBorders), - frameSize(-1, -1), - topHeight(0), - leftWidth(0), - rightWidth(0), - bottomHeight(0), - topMargin(0), - leftMargin(0), - rightMargin(0), - bottomMargin(0), - noBorderPadding(false), - stretchBorders(false), - tileCenter(false), - composeOverBorder(false), - theme(nullptr) + : imagePath(svg->imagePath()) + , prefix(p) + , enabledBorders(FrameSvg::AllBorders) + , frameSize(-1, -1) + , topHeight(0) + , leftWidth(0) + , rightWidth(0) + , bottomHeight(0) + , topMargin(0) + , leftMargin(0) + , rightMargin(0) + , bottomMargin(0) + , noBorderPadding(false) + , stretchBorders(false) + , tileCenter(false) + , composeOverBorder(false) + , theme(nullptr) { } FrameData(const FrameData &other, FrameSvg *svg) - : imagePath(other.imagePath), - prefix(other.prefix), - enabledBorders(other.enabledBorders), - cachedMasks(MAX_CACHED_MASKS), - frameSize(other.frameSize), - topHeight(0), - leftWidth(0), - rightWidth(0), - bottomHeight(0), - topMargin(0), - leftMargin(0), - rightMargin(0), - bottomMargin(0), - devicePixelRatio(svg->devicePixelRatio()), - noBorderPadding(false), - stretchBorders(false), - tileCenter(false), - composeOverBorder(false), - theme(nullptr) + : imagePath(other.imagePath) + , prefix(other.prefix) + , enabledBorders(other.enabledBorders) + , cachedMasks(MAX_CACHED_MASKS) + , frameSize(other.frameSize) + , topHeight(0) + , leftWidth(0) + , rightWidth(0) + , bottomHeight(0) + , topMargin(0) + , leftMargin(0) + , rightMargin(0) + , bottomMargin(0) + , devicePixelRatio(svg->devicePixelRatio()) + , noBorderPadding(false) + , stretchBorders(false) + , tileCenter(false) + , composeOverBorder(false) + , theme(nullptr) { } @@ -82,31 +81,31 @@ public: QSize frameSize; uint cacheId; - //measures + // measures int topHeight; int leftWidth; int rightWidth; int bottomHeight; - //margins, are equal to the measures by default + // margins, are equal to the measures by default int topMargin; int leftMargin; int rightMargin; int bottomMargin; - //measures + // measures int fixedTopHeight; int fixedLeftWidth; int fixedRightWidth; int fixedBottomHeight; - //margins, are equal to the measures by default + // margins, are equal to the measures by default int fixedTopMargin; int fixedLeftMargin; int fixedRightMargin; int fixedBottomMargin; - //margins, we only have the hint for insets + // margins, we only have the hint for insets int insetTopMargin; int insetLeftMargin; int insetRightMargin; @@ -114,8 +113,8 @@ public: qreal devicePixelRatio; - //size of the svg where the size of the "center" - //element is contentWidth x contentHeight + // size of the svg where the size of the "center" + // element is contentWidth x contentHeight bool noBorderPadding : 1; bool stretchBorders : 1; bool tileCenter : 1; @@ -128,11 +127,11 @@ class FrameSvgPrivate { public: FrameSvgPrivate(FrameSvg *psvg) - : q(psvg), - overlayPos(0, 0), - enabledBorders(FrameSvg::AllBorders), - cacheAll(false), - repaintBlocked(false) + : q(psvg) + , overlayPos(0, 0) + , enabledBorders(FrameSvg::AllBorders) + , cacheAll(false) + , repaintBlocked(false) { } @@ -149,38 +148,48 @@ public: void generateFrameBackground(const QSharedPointer &); SvgPrivate::CacheId cacheId(FrameData *frame, const QString &prefixToUse) const; void cacheFrame(const QString &prefixToSave, const QPixmap &background, const QPixmap &overlay); - void updateSizes(FrameData* frame) const; - void updateSizes(const QSharedPointer &frame) const { return updateSizes(frame.data()); } + void updateSizes(FrameData *frame) const; + void updateSizes(const QSharedPointer &frame) const + { + return updateSizes(frame.data()); + } void updateNeeded(); void updateAndSignalSizes(); - QSizeF frameSize(const QSharedPointer &frame) const { return frameSize(frame.data()); } - QSizeF frameSize(FrameData* frame) const; - void paintBorder(QPainter& p, const QSharedPointer &frame, Plasma::FrameSvg::EnabledBorders border, const QSize& originalSize, const QRect& output) const; - void paintCorner(QPainter& p, const QSharedPointer &frame, Plasma::FrameSvg::EnabledBorders border, const QRect& output) const; - void paintCenter(QPainter& p, const QSharedPointer &frame, const QRect& contentRect, const QSize& fullSize); - QRect contentGeometry(const QSharedPointer &frame, const QSize& size) const; + QSizeF frameSize(const QSharedPointer &frame) const + { + return frameSize(frame.data()); + } + QSizeF frameSize(FrameData *frame) const; + void paintBorder(QPainter &p, + const QSharedPointer &frame, + Plasma::FrameSvg::EnabledBorders border, + const QSize &originalSize, + const QRect &output) const; + void paintCorner(QPainter &p, const QSharedPointer &frame, Plasma::FrameSvg::EnabledBorders border, const QRect &output) const; + void paintCenter(QPainter &p, const QSharedPointer &frame, const QRect &contentRect, const QSize &fullSize); + QRect contentGeometry(const QSharedPointer &frame, const QSize &size) const; void updateFrameData(uint lastModified, UpdateType updateType = UpdateFrameAndMargins); QSharedPointer lookupOrCreateMaskFrame(const QSharedPointer &frame, const QString &maskPrefix, const QString &maskRequestedPrefix); Types::Location location = Types::Floating; QString prefix; - //sometimes the prefix we requested is not available, so prefix will be emoty - //keep track of the requested one anyways, we'll try again when the theme changes + // sometimes the prefix we requested is not available, so prefix will be emoty + // keep track of the requested one anyways, we'll try again when the theme changes QString requestedPrefix; - FrameSvg * const q; + FrameSvg *const q; QPoint overlayPos; QSharedPointer frame; QSharedPointer maskFrame; - //those can differ from frame->enabledBorders if we are in a transition + // those can differ from frame->enabledBorders if we are in a transition FrameSvg::EnabledBorders enabledBorders; - //this can differ from frame->frameSize if we are in a transition + // this can differ from frame->frameSize if we are in a transition QSize pendingFrameSize; - static QHash> > s_sharedFrames; + static QHash>> s_sharedFrames; bool cacheAll : 1; bool repaintBlocked : 1; diff --git a/src/plasma/private/package_p.h b/src/plasma/private/package_p.h index 4687d455d..4cfcfefaf 100644 --- a/src/plasma/private/package_p.h +++ b/src/plasma/private/package_p.h @@ -16,7 +16,6 @@ namespace Plasma { - class PackagePrivate : public QSharedData { public: diff --git a/src/plasma/private/packagestructure_p.h b/src/plasma/private/packagestructure_p.h index 3c792510a..544d958af 100644 --- a/src/plasma/private/packagestructure_p.h +++ b/src/plasma/private/packagestructure_p.h @@ -10,14 +10,14 @@ #include "../packagestructure.h" +#include #include #include -#include namespace Plasma { - -class PackageStructureWrapper : public KPackage::PackageStructure { +class PackageStructureWrapper : public KPackage::PackageStructure +{ Q_OBJECT public: @@ -42,11 +42,13 @@ class PackageStructurePrivate { public: PackageStructurePrivate(PackageStructure *str) - : q(str), - internalStructure(nullptr) - {} + : q(str) + , internalStructure(nullptr) + { + } ~PackageStructurePrivate() - {} + { + } void installPathChanged(const QString &path); diff --git a/src/plasma/private/service_p.h b/src/plasma/private/service_p.h index f794f7148..8a2df4069 100644 --- a/src/plasma/private/service_p.h +++ b/src/plasma/private/service_p.h @@ -7,20 +7,19 @@ #ifndef SERVICE_P_H #define SERVICE_P_H -#include "servicejob.h" #include "service.h" +#include "servicejob.h" #include #include -#include #include +#include -#include #include +#include namespace Plasma { - class NullServiceJob : public ServiceJob { public: @@ -79,4 +78,3 @@ public: } // namespace Plasma #endif - diff --git a/src/plasma/private/servicejob_p.h b/src/plasma/private/servicejob_p.h index d775dd4e6..204b62f37 100644 --- a/src/plasma/private/servicejob_p.h +++ b/src/plasma/private/servicejob_p.h @@ -9,20 +9,16 @@ #include "../servicejob.h" +#include #include #include -#include namespace Plasma { - class ServiceJobPrivate { public: - ServiceJobPrivate(ServiceJob *owner, - const QString &dest, - const QString &op, - const QVariantMap ¶ms); + ServiceJobPrivate(ServiceJob *owner, const QString &dest, const QString &op, const QVariantMap ¶ms); void preventAutoStart(); void autoStart(); diff --git a/src/plasma/private/sharedtimer_p.h b/src/plasma/private/sharedtimer_p.h index 8f40640b5..8907ef818 100644 --- a/src/plasma/private/sharedtimer_p.h +++ b/src/plasma/private/sharedtimer_p.h @@ -11,7 +11,6 @@ namespace Plasma { - class Timer; class TimerDrive : public QObject @@ -37,4 +36,3 @@ private: } // namespace Plasma #endif - diff --git a/src/plasma/private/storage.cpp b/src/plasma/private/storage.cpp index 5f3d7a92f..8645c0650 100644 --- a/src/plasma/private/storage.cpp +++ b/src/plasma/private/storage.cpp @@ -8,7 +8,7 @@ #include "private/storage_p.h" -//Qt +// Qt #include #include #include @@ -16,25 +16,22 @@ #include #include -//KDE +// KDE #include -//Plasma +// Plasma #include "applet.h" #include "dataengine.h" #include "storagethread_p.h" -StorageJob::StorageJob(const QString &destination, - const QString &operation, - const QVariantMap ¶meters, - QObject *parent) - : ServiceJob(destination, operation, parameters, parent), - m_clientName(destination) +StorageJob::StorageJob(const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent) + : ServiceJob(destination, operation, parameters, parent) + , m_clientName(destination) { Plasma::StorageThread::self()->start(); connect(Plasma::StorageThread::self(), &Plasma::StorageThread::newResult, this, &StorageJob::resultSlot); qRegisterMetaType(); - qRegisterMetaType >(); + qRegisterMetaType>(); } StorageJob::~StorageJob() @@ -58,7 +55,7 @@ QString StorageJob::clientName() const void StorageJob::start() { - //FIXME: QHASH + // FIXME: QHASH QVariantMap params = parameters(); QString valueGroup = params[QStringLiteral("group")].toString(); @@ -72,7 +69,11 @@ void StorageJob::start() } else if (operationName() == QLatin1String("retrieve")) { QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QPointer, me), Q_ARG(QVariantMap, params)); } else if (operationName() == QLatin1String("delete")) { - QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QPointer, me), Q_ARG(QVariantMap, params)); + QMetaObject::invokeMethod(Plasma::StorageThread::self(), + "deleteEntry", + Qt::QueuedConnection, + Q_ARG(QPointer, me), + Q_ARG(QVariantMap, params)); } else if (operationName() == QLatin1String("expire")) { QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QPointer, me), Q_ARG(QVariantMap, params)); } else { @@ -100,12 +101,12 @@ Plasma::ServiceJob *Storage::createJob(const QString &operation, QVariantMap &pa return new StorageJob(m_clientName, operation, parameters, this); } -//Storage implementation +// Storage implementation Storage::Storage(QObject *parent) - : Plasma::Service(parent), - m_clientName(QStringLiteral("data")) + : Plasma::Service(parent) + , m_clientName(QStringLiteral("data")) { - //search among parents for an applet or dataengine: if found call the table as its plugin name + // search among parents for an applet or dataengine: if found call the table as its plugin name QObject *parentObject = this; while ((parentObject = parentObject->parent())) { diff --git a/src/plasma/private/storage_p.h b/src/plasma/private/storage_p.h index e75a37d5f..85b7efbd0 100644 --- a/src/plasma/private/storage_p.h +++ b/src/plasma/private/storage_p.h @@ -14,17 +14,14 @@ #include #include -//Begin StorageJob +// Begin StorageJob class StorageJob : public Plasma::ServiceJob { Q_OBJECT Q_PROPERTY(QVariantMap data READ data WRITE setData) public: - StorageJob(const QString &destination, - const QString &operation, - const QVariantMap ¶meters, - QObject *parent = nullptr); + StorageJob(const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent = nullptr); ~StorageJob() override; void setData(const QVariantMap &data); QVariantMap data() const; @@ -38,7 +35,7 @@ private: QString m_clientName; QVariantMap m_data; }; -//End StorageJob +// End StorageJob class Storage : public Plasma::Service { @@ -55,4 +52,4 @@ private: QString m_clientName; }; -#endif //PLASMA_STORAGE_P_H +#endif // PLASMA_STORAGE_P_H diff --git a/src/plasma/private/storagethread.cpp b/src/plasma/private/storagethread.cpp index 065ded9eb..8cc5f1278 100644 --- a/src/plasma/private/storagethread.cpp +++ b/src/plasma/private/storagethread.cpp @@ -7,21 +7,20 @@ #include "storagethread_p.h" #include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include "debug_p.h" #include #include -#include "debug_p.h" namespace Plasma { - class StorageThreadSingleton { public: @@ -75,7 +74,9 @@ void StorageThread::initializeDb(StorageJob *caller) qCWarning(LOG_PLASMA) << "Unable to open the plasma storage cache database: " << m_db.lastError(); } else if (!m_db.tables().contains(caller->clientName())) { QSqlQuery query(m_db); - query.prepare(QStringLiteral("create table ") + caller->clientName() + QStringLiteral(" (valueGroup varchar(256), id varchar(256), txt TEXT, int INTEGER, float REAL, binary BLOB, creationTime datetime, accessTime datetime, primary key (valueGroup, id))")); + query.prepare(QStringLiteral("create table ") + caller->clientName() + + QStringLiteral(" (valueGroup varchar(256), id varchar(256), txt TEXT, int INTEGER, float REAL, binary BLOB, creationTime datetime, " + "accessTime datetime, primary key (valueGroup, id))")); if (!query.exec()) { qCWarning(LOG_PLASMA) << "Unable to create table for" << caller->clientName(); m_db.close(); @@ -117,7 +118,8 @@ void StorageThread::save(QPointer wcaller, const QVariantMap ¶ms ids.append(m_db.driver()->formatValue(field)); } - query.prepare(QStringLiteral("delete from ") + caller->clientName() + QStringLiteral(" where valueGroup = :valueGroup and id in (") + ids + QStringLiteral(");")); + query.prepare(QStringLiteral("delete from ") + caller->clientName() + QStringLiteral(" where valueGroup = :valueGroup and id in (") + ids + + QStringLiteral(");")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); if (!query.exec()) { @@ -126,7 +128,8 @@ void StorageThread::save(QPointer wcaller, const QVariantMap ¶ms return; } - query.prepare(QStringLiteral("insert into ") + caller->clientName() + QStringLiteral(" values(:valueGroup, :id, :txt, :int, :float, :binary, date('now'), date('now'))")); + query.prepare(QStringLiteral("insert into ") + caller->clientName() + + QStringLiteral(" values(:valueGroup, :id, :txt, :int, :float, :binary, date('now'), date('now'))")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.bindValue(QStringLiteral(":txt"), QVariant()); query.bindValue(QStringLiteral(":int"), QVariant()); @@ -143,7 +146,7 @@ void StorageThread::save(QPointer wcaller, const QVariantMap ¶ms it.toFront(); while (it.hasNext()) { it.next(); - //qCDebug(LOG_PLASMA) << "going to insert" << valueGroup << it.key(); + // qCDebug(LOG_PLASMA) << "going to insert" << valueGroup << it.key(); query.bindValue(QStringLiteral(":id"), it.key()); QString field; @@ -176,7 +179,7 @@ void StorageThread::save(QPointer wcaller, const QVariantMap ¶ms } if (!query.exec()) { - //qCDebug(LOG_PLASMA) << "query failed:" << query.lastQuery() << query.lastError().text(); + // qCDebug(LOG_PLASMA) << "query failed:" << query.lastQuery() << query.lastError().text(); m_db.commit(); Q_EMIT newResult(caller, false); return; @@ -205,9 +208,9 @@ void StorageThread::retrieve(QPointer wcaller, const QVariantMap &pa QSqlQuery query(m_db); - //a bit redundant but should be the faster way with less string concatenation as possible + // a bit redundant but should be the faster way with less string concatenation as possible if (params[QStringLiteral("key")].toString().isEmpty()) { - //update modification time + // update modification time query.prepare(QStringLiteral("update ") + clientName + QStringLiteral(" set accessTime=date('now') where valueGroup=:valueGroup")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.exec(); @@ -215,7 +218,7 @@ void StorageThread::retrieve(QPointer wcaller, const QVariantMap &pa query.prepare(QStringLiteral("select * from ") + clientName + QStringLiteral(" where valueGroup=:valueGroup")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); } else { - //update modification time + // update modification time query.prepare(QStringLiteral("update ") + clientName + QStringLiteral(" set accessTime=date('now') where valueGroup=:valueGroup and id=:key")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.bindValue(QStringLiteral(":key"), params[QStringLiteral("key")].toString()); diff --git a/src/plasma/private/storagethread_p.h b/src/plasma/private/storagethread_p.h index 92f11c3b3..8bb000a3c 100644 --- a/src/plasma/private/storagethread_p.h +++ b/src/plasma/private/storagethread_p.h @@ -7,15 +7,14 @@ #ifndef STORAGETHREAD_H #define STORAGETHREAD_H -#include -#include #include +#include +#include #include "storage_p.h" namespace Plasma { - class StorageThread : public QThread { Q_OBJECT diff --git a/src/plasma/private/svg_p.h b/src/plasma/private/svg_p.h index e9acae781..100fabfa9 100644 --- a/src/plasma/private/svg_p.h +++ b/src/plasma/private/svg_p.h @@ -7,16 +7,15 @@ #ifndef PLASMA_SVG_P_H #define PLASMA_SVG_P_H +#include #include +#include #include #include #include -#include -#include namespace Plasma { - class Svg; class SharedSvgRenderer : public QSvgRenderer, public QSharedData @@ -26,23 +25,12 @@ public: typedef QExplicitlySharedDataPointer Ptr; explicit SharedSvgRenderer(QObject *parent = nullptr); - SharedSvgRenderer( - const QString &filename, - const QString &styleSheet, - QHash &interestingElements, - QObject *parent = nullptr); + SharedSvgRenderer(const QString &filename, const QString &styleSheet, QHash &interestingElements, QObject *parent = nullptr); - SharedSvgRenderer( - const QByteArray &contents, - const QString &styleSheet, - QHash &interestingElements, - QObject *parent = nullptr); + SharedSvgRenderer(const QByteArray &contents, const QString &styleSheet, QHash &interestingElements, QObject *parent = nullptr); private: - bool load( - const QByteArray &contents, - const QString &styleSheet, - QHash &interestingElements); + bool load(const QByteArray &contents, const QString &styleSheet, QHash &interestingElements); }; class SvgPrivate @@ -57,17 +45,17 @@ public: double devicePixelRatio; double scaleFactor; int colorGroup; - uint extraFlags; //Not used here, used for enabledborders in FrameSvg + uint extraFlags; // Not used here, used for enabledborders in FrameSvg uint lastModified; }; SvgPrivate(Svg *svg); ~SvgPrivate(); - //This function is meant for the rects cache + // This function is meant for the rects cache CacheId cacheId(const QString &elementId) const; - //This function is meant for the pixmap cache + // This function is meant for the pixmap cache QString cachePath(const QString &path, const QSize &size) const; bool setImagePath(const QString &imagePath); @@ -85,13 +73,13 @@ public: void checkColorHints(); - //Following two are utility functions to snap rendered elements to the pixel grid - //to and from are always 0 <= val <= 1 + // Following two are utility functions to snap rendered elements to the pixel grid + // to and from are always 0 <= val <= 1 qreal closestDistance(qreal to, qreal from); QRectF makeUniform(const QRectF &orig, const QRectF &dst); - //Slots + // Slots void themeChanged(); void colorsChanged(); @@ -122,8 +110,8 @@ public: bool themeFailed : 1; }; - -class SvgRectsCache : public QObject { +class SvgRectsCache : public QObject +{ Q_OBJECT public: SvgRectsCache(QObject *parent = nullptr); @@ -159,7 +147,7 @@ private: QTimer *m_configSyncTimer = nullptr; QString m_iconThemePath; KSharedConfigPtr m_svgElementsCache; - /* + /* * We are indexing in the hash cache ids by their "digested" uint out of qHash(CacheId) * because we need to serialize it and unserialize it to a config file, * which is more efficient to do that with the uint directly rather than a CacheId struct serialization @@ -168,10 +156,8 @@ private: QHash> m_invalidElements; QHash> m_sizeHintsForId; }; - } uint qHash(const Plasma::SvgPrivate::CacheId &id, uint seed = 0); #endif - diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp index a9734a32e..f924a76b1 100644 --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -6,25 +6,24 @@ */ #include "theme_p.h" +#include "debug_p.h" #include "framesvg.h" #include "framesvg_p.h" #include "svg_p.h" -#include "debug_p.h" -#include +#include #include #include #include -#include +#include #include -#include #include #include +#include namespace Plasma { - const char ThemePrivate::defaultTheme[] = "default"; const char ThemePrivate::themeRcFile[] = "plasmarc"; // the system colors theme is used to cache unthemed svgs with colorization needs @@ -38,36 +37,36 @@ ThemePrivate *ThemePrivate::globalTheme = nullptr; QHash ThemePrivate::themes = QHash(); ThemePrivate::ThemePrivate(QObject *parent) - : QObject(parent), - colorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(nullptr)), - selectionColorScheme(QPalette::Active, KColorScheme::Selection, KSharedConfigPtr(nullptr)), - buttonColorScheme(QPalette::Active, KColorScheme::Button, KSharedConfigPtr(nullptr)), - viewColorScheme(QPalette::Active, KColorScheme::View, KSharedConfigPtr(nullptr)), - complementaryColorScheme(QPalette::Active, KColorScheme::Complementary, KSharedConfigPtr(nullptr)), - headerColorScheme(QPalette::Active, KColorScheme::Header, KSharedConfigPtr(nullptr)), - tooltipColorScheme(QPalette::Active, KColorScheme::Tooltip, KSharedConfigPtr(nullptr)), - defaultWallpaperTheme(QStringLiteral(DEFAULT_WALLPAPER_THEME)), - defaultWallpaperSuffix(QStringLiteral(DEFAULT_WALLPAPER_SUFFIX)), - defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH), - defaultWallpaperHeight(DEFAULT_WALLPAPER_HEIGHT), - pixmapCache(nullptr), - cacheSize(0), - cachesToDiscard(NoCache), - compositingActive(KWindowSystem::self()->compositingActive()), - backgroundContrastActive(KWindowEffects::isEffectAvailable(KWindowEffects::BackgroundContrast)), - isDefault(true), - useGlobal(true), - hasWallpapers(false), - fixedName(false), - backgroundContrast(qQNaN()), - backgroundIntensity(qQNaN()), - backgroundSaturation(qQNaN()), - backgroundContrastEnabled(true), - adaptiveTransparencyEnabled(false), - blurBehindEnabled(true), - apiMajor(1), - apiMinor(0), - apiRevision(0) + : QObject(parent) + , colorScheme(QPalette::Active, KColorScheme::Window, KSharedConfigPtr(nullptr)) + , selectionColorScheme(QPalette::Active, KColorScheme::Selection, KSharedConfigPtr(nullptr)) + , buttonColorScheme(QPalette::Active, KColorScheme::Button, KSharedConfigPtr(nullptr)) + , viewColorScheme(QPalette::Active, KColorScheme::View, KSharedConfigPtr(nullptr)) + , complementaryColorScheme(QPalette::Active, KColorScheme::Complementary, KSharedConfigPtr(nullptr)) + , headerColorScheme(QPalette::Active, KColorScheme::Header, KSharedConfigPtr(nullptr)) + , tooltipColorScheme(QPalette::Active, KColorScheme::Tooltip, KSharedConfigPtr(nullptr)) + , defaultWallpaperTheme(QStringLiteral(DEFAULT_WALLPAPER_THEME)) + , defaultWallpaperSuffix(QStringLiteral(DEFAULT_WALLPAPER_SUFFIX)) + , defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH) + , defaultWallpaperHeight(DEFAULT_WALLPAPER_HEIGHT) + , pixmapCache(nullptr) + , cacheSize(0) + , cachesToDiscard(NoCache) + , compositingActive(KWindowSystem::self()->compositingActive()) + , backgroundContrastActive(KWindowEffects::isEffectAvailable(KWindowEffects::BackgroundContrast)) + , isDefault(true) + , useGlobal(true) + , hasWallpapers(false) + , fixedName(false) + , backgroundContrast(qQNaN()) + , backgroundIntensity(qQNaN()) + , backgroundSaturation(qQNaN()) + , backgroundContrastEnabled(true) + , adaptiveTransparencyEnabled(false) + , blurBehindEnabled(true) + , apiMajor(1) + , apiMinor(0) + , apiRevision(0) { ThemeConfig config; cacheTheme = config.cacheTheme(); @@ -84,7 +83,7 @@ ThemePrivate::ThemePrivate(QObject *parent) if (QPixmap::defaultDepth() > 8) { #if HAVE_X11 - //watch for background contrast effect property changes as well + // watch for background contrast effect property changes as well if (!s_backgroundContrastEffectWatcher) { s_backgroundContrastEffectWatcher = new EffectWatcher(QStringLiteral("_KDE_NET_WM_BACKGROUND_CONTRAST_REGION")); } @@ -107,10 +106,9 @@ ThemePrivate::ThemePrivate(QObject *parent) // ... but also remove/recreate cycles, like KConfig does it connect(KDirWatch::self(), &KDirWatch::created, this, &ThemePrivate::settingsFileChanged); - QObject::connect(KIconLoader::global(), &KIconLoader::iconChanged, - this, [this]() { - scheduleThemeChangeNotification(PixmapCache|SvgElementsCache); - }); + QObject::connect(KIconLoader::global(), &KIconLoader::iconChanged, this, [this]() { + scheduleThemeChangeNotification(PixmapCache | SvgElementsCache); + }); connect(KWindowSystem::self(), &KWindowSystem::compositingChanged, this, &ThemePrivate::compositingChanged); } @@ -161,7 +159,9 @@ bool ThemePrivate::useCache() KDirWatch::self()->removeFile(themeMetadataPath); } if (isRegularTheme) { - themeMetadataPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % themeName % QStringLiteral("/metadata.desktop")); + themeMetadataPath = + QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % themeName % QStringLiteral("/metadata.desktop")); const auto *iconTheme = KIconLoader::global()->theme(); if (iconTheme) { iconThemeMetadataPath = iconTheme->dir() + QStringLiteral("index.theme"); @@ -184,31 +184,24 @@ bool ThemePrivate::useCache() // watch the metadata file for changes at runtime KDirWatch::self()->addFile(themeMetadataPath); - QObject::connect(KDirWatch::self(), &KDirWatch::created, - this, &ThemePrivate::settingsFileChanged, - Qt::UniqueConnection); - QObject::connect(KDirWatch::self(), &KDirWatch::dirty, - this, &ThemePrivate::settingsFileChanged, - Qt::UniqueConnection); + QObject::connect(KDirWatch::self(), &KDirWatch::created, this, &ThemePrivate::settingsFileChanged, Qt::UniqueConnection); + QObject::connect(KDirWatch::self(), &KDirWatch::dirty, this, &ThemePrivate::settingsFileChanged, Qt::UniqueConnection); if (!iconThemeMetadataPath.isEmpty()) { KDirWatch::self()->addFile(iconThemeMetadataPath); } } - // now we check for, and remove if necessary, old caches QDir cacheDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)); cacheDir.setNameFilters(QStringList({cacheFileBase})); const auto files = cacheDir.entryInfoList(); for (const QFileInfo &file : files) { - if (currentCacheFileName.isEmpty() || - !file.absoluteFilePath().endsWith(currentCacheFileName)) { + if (currentCacheFileName.isEmpty() || !file.absoluteFilePath().endsWith(currentCacheFileName)) { QFile::remove(file.absoluteFilePath()); } } - } // now we do a sanity check: if the metadata.desktop file is newer than the cache, drop the cache @@ -221,14 +214,15 @@ bool ThemePrivate::useCache() // the cache should be dropped; we need a way to detect system color change when the // application is not running. // check for expired cache - const QString cacheFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + cacheFile + QLatin1String(".kcache"); + const QString cacheFilePath = + QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + cacheFile + QLatin1String(".kcache"); if (!cacheFilePath.isEmpty()) { const QFileInfo cacheFileInfo(cacheFilePath); const QFileInfo metadataFileInfo(themeMetadataPath); const QFileInfo iconThemeMetadataFileInfo(iconThemeMetadataPath); - cachesTooOld = (cacheFileInfo.lastModified().toSecsSinceEpoch() < metadataFileInfo.lastModified().toSecsSinceEpoch()) || - (cacheFileInfo.lastModified().toSecsSinceEpoch() < iconThemeMetadataFileInfo.lastModified().toSecsSinceEpoch()); + cachesTooOld = (cacheFileInfo.lastModified().toSecsSinceEpoch() < metadataFileInfo.lastModified().toSecsSinceEpoch()) + || (cacheFileInfo.lastModified().toSecsSinceEpoch() < iconThemeMetadataFileInfo.lastModified().toSecsSinceEpoch()); } } @@ -266,7 +260,7 @@ void ThemePrivate::onAppExitCleanup() cacheTheme = false; } -QString ThemePrivate::imagePath(const QString& theme, const QString& type, const QString& image) +QString ThemePrivate::imagePath(const QString &theme, const QString &type, const QString &image) { QString subdir = QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % type % image; return QStandardPaths::locate(QStandardPaths::GenericDataLocation, subdir); @@ -290,7 +284,7 @@ QString ThemePrivate::findInTheme(const QString &image, const QString &theme, bo QString search = imagePath(theme, type, image); - //not found or compositing enabled + // not found or compositing enabled if (search.isEmpty()) { search = imagePath(theme, QStringLiteral("/"), image); } @@ -307,7 +301,7 @@ void ThemePrivate::compositingChanged(bool active) #if HAVE_X11 if (compositingActive != active) { compositingActive = active; - //qCDebug(LOG_PLASMA) << QTime::currentTime(); + // qCDebug(LOG_PLASMA) << QTime::currentTime(); scheduleThemeChangeNotification(PixmapCache | SvgElementsCache); } #endif @@ -378,7 +372,7 @@ void ThemePrivate::scheduleThemeChangeNotification(CacheTypes caches) void ThemePrivate::notifyOfChanged() { - //qCDebug(LOG_PLASMA) << cachesToDiscard; + // qCDebug(LOG_PLASMA) << cachesToDiscard; discardCache(cachesToDiscard); cachesToDiscard = NoCache; Q_EMIT themeChanged(); @@ -390,7 +384,8 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S if (css.isEmpty()) { stylesheet = cachedDefaultStyleSheet; if (stylesheet.isEmpty()) { - stylesheet = QStringLiteral("\n\ + stylesheet = QStringLiteral( + "\n\ body {\n\ color: %textcolor;\n\ generalfont-size: %fontsize;\n\ @@ -412,8 +407,10 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S QHash elements; // If you add elements here, make sure their names are sufficiently unique to not cause // clashes between element keys - elements[QStringLiteral("%textcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::NormalColorGroup).name(); - elements[QStringLiteral("%backgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::NormalColorGroup).name(); + elements[QStringLiteral("%textcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::NormalColorGroup).name(); + elements[QStringLiteral("%backgroundcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%highlightcolor")] = color(Theme::HighlightColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%highlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%visitedlink")] = color(Theme::VisitedLinkColor, Theme::NormalColorGroup).name(); @@ -424,8 +421,10 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S elements[QStringLiteral("%neutraltextcolor")] = color(Theme::NeutralTextColor, Theme::NormalColorGroup).name(); elements[QStringLiteral("%negativetextcolor")] = color(Theme::NegativeTextColor, Theme::NormalColorGroup).name(); - elements[QStringLiteral("%buttontextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ButtonColorGroup).name(); - elements[QStringLiteral("%buttonbackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ButtonColorGroup).name(); + elements[QStringLiteral("%buttontextcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ButtonColorGroup).name(); + elements[QStringLiteral("%buttonbackgroundcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonhovercolor")] = color(Theme::HoverColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonfocuscolor")] = color(Theme::FocusColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ButtonColorGroup).name(); @@ -433,17 +432,21 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S elements[QStringLiteral("%buttonneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ButtonColorGroup).name(); elements[QStringLiteral("%buttonnegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ButtonColorGroup).name(); - elements[QStringLiteral("%viewtextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ViewColorGroup).name(); - elements[QStringLiteral("%viewbackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ViewColorGroup).name(); + elements[QStringLiteral("%viewtextcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ViewColorGroup).name(); + elements[QStringLiteral("%viewbackgroundcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewhovercolor")] = color(Theme::HoverColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewfocuscolor")] = color(Theme::FocusColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewpositivetextcolor")] = color(Theme::PositiveTextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ViewColorGroup).name(); elements[QStringLiteral("%viewnegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ViewColorGroup).name(); - - elements[QStringLiteral("%tooltiptextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ToolTipColorGroup).name(); - elements[QStringLiteral("%tooltipbackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ToolTipColorGroup).name(); + + elements[QStringLiteral("%tooltiptextcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ToolTipColorGroup).name(); + elements[QStringLiteral("%tooltipbackgroundcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ToolTipColorGroup).name(); elements[QStringLiteral("%tooltiphovercolor")] = color(Theme::HoverColor, Theme::ToolTipColorGroup).name(); elements[QStringLiteral("%tooltipfocuscolor")] = color(Theme::FocusColor, Theme::ToolTipColorGroup).name(); elements[QStringLiteral("%tooltiphighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ToolTipColorGroup).name(); @@ -451,8 +454,10 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S elements[QStringLiteral("%tooltipneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ToolTipColorGroup).name(); elements[QStringLiteral("%tooltipnegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ToolTipColorGroup).name(); - elements[QStringLiteral("%complementarytextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ComplementaryColorGroup).name(); - elements[QStringLiteral("%complementarybackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ComplementaryColorGroup).name(); + elements[QStringLiteral("%complementarytextcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::ComplementaryColorGroup).name(); + elements[QStringLiteral("%complementarybackgroundcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryhovercolor")] = color(Theme::HoverColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryfocuscolor")] = color(Theme::FocusColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementaryhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::ComplementaryColorGroup).name(); @@ -460,8 +465,10 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S elements[QStringLiteral("%complementaryneutraltextcolor")] = color(Theme::NeutralTextColor, Theme::ComplementaryColorGroup).name(); elements[QStringLiteral("%complementarynegativetextcolor")] = color(Theme::NegativeTextColor, Theme::ComplementaryColorGroup).name(); - elements[QStringLiteral("%headertextcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::HeaderColorGroup).name(); - elements[QStringLiteral("%headerbackgroundcolor")] = color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::HeaderColorGroup).name(); + elements[QStringLiteral("%headertextcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightedTextColor : Theme::TextColor, Theme::HeaderColorGroup).name(); + elements[QStringLiteral("%headerbackgroundcolor")] = + color(status == Svg::Status::Selected ? Theme::HighlightColor : Theme::BackgroundColor, Theme::HeaderColorGroup).name(); elements[QStringLiteral("%headerhovercolor")] = color(Theme::HoverColor, Theme::HeaderColorGroup).name(); elements[QStringLiteral("%headerfocuscolor")] = color(Theme::FocusColor, Theme::HeaderColorGroup).name(); elements[QStringLiteral("%headerhighlightedtextcolor")] = color(Theme::HighlightedTextColor, Theme::HeaderColorGroup).name(); @@ -585,7 +592,7 @@ const QString ThemePrivate::svgStyleSheet(Plasma::Theme::ColorGroup group, Plasm stylesheet += skel.arg(QStringLiteral("HeaderPositiveText"), QStringLiteral("%headerpositivetextcolor")); stylesheet += skel.arg(QStringLiteral("HeaderNeutralText"), QStringLiteral("%headerneutraltextcolor")); stylesheet += skel.arg(QStringLiteral("HeaderNegativeText"), QStringLiteral("%headernegativetextcolor")); - + stylesheet += skel.arg(QStringLiteral("TootipText"), QStringLiteral("%tooltiptextcolor")); stylesheet += skel.arg(QStringLiteral("TootipBackground"), QStringLiteral("%tooltipbackgroundcolor")); stylesheet += skel.arg(QStringLiteral("TootipHover"), QStringLiteral("%tooltiphovercolor")); @@ -625,7 +632,7 @@ void ThemePrivate::settingsChanged(bool emitChanges) if (fixedName) { return; } - //qCDebug(LOG_PLASMA) << "Settings Changed!"; + // qCDebug(LOG_PLASMA) << "Settings Changed!"; KConfigGroup cg = config(); setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false, emitChanges); } @@ -634,9 +641,9 @@ QColor ThemePrivate::color(Theme::ColorRole role, Theme::ColorGroup group) const { const KColorScheme *scheme = nullptr; - //Before 5.0 Plasma theme really only used Normal and Button - //many old themes are built on this assumption and will break - //otherwise + // Before 5.0 Plasma theme really only used Normal and Button + // many old themes are built on this assumption and will break + // otherwise if (apiMajor < 5 && group != Theme::NormalColorGroup) { group = Theme::ButtonColorGroup; } @@ -652,7 +659,7 @@ QColor ThemePrivate::color(Theme::ColorRole role, Theme::ColorGroup group) const break; } - //this doesn't have a real kcolorscheme + // this doesn't have a real kcolorscheme case Theme::ComplementaryColorGroup: { scheme = &complementaryColorScheme; break; @@ -662,7 +669,7 @@ QColor ThemePrivate::color(Theme::ColorRole role, Theme::ColorGroup group) const scheme = &headerColorScheme; break; } - + case Theme::ToolTipColorGroup: { scheme = &tooltipColorScheme; break; @@ -675,10 +682,7 @@ QColor ThemePrivate::color(Theme::ColorRole role, Theme::ColorGroup group) const } } - - switch (role) { - case Theme::TextColor: return scheme->foreground(KColorScheme::NormalText).color(); @@ -754,7 +758,6 @@ void ThemePrivate::processContrastSettings(KConfigBase *metadata) } } - void ThemePrivate::processAdaptiveTransparencySettings(KConfigBase *metadata) { KConfigGroup cg; @@ -793,11 +796,15 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings // the system colors. bool realTheme = theme != QLatin1String(systemColorsTheme); if (realTheme) { - QString themePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/metadata.desktop")); + QString themePath = + QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/metadata.desktop")); if (themePath.isEmpty() && themeName.isEmpty()) { // note: can't use QStringLiteral("foo" "bar") on Windows - themePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/default"), QStandardPaths::LocateDirectory); + themePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/default"), + QStandardPaths::LocateDirectory); if (themePath.isEmpty()) { return; @@ -815,10 +822,12 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings themeName = theme; // load the color scheme config - const QString colorsFile = realTheme ? QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/colors")) - : QString(); + const QString colorsFile = realTheme + ? QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/colors")) + : QString(); - //qCDebug(LOG_PLASMA) << "we're going for..." << colorsFile << "*******************"; + // qCDebug(LOG_PLASMA) << "we're going for..." << colorsFile << "*******************"; if (colorsFile.isEmpty()) { colors = nullptr; @@ -839,7 +848,9 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings // load the wallpaper settings, if any if (realTheme) { - const QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/metadata.desktop"))); + const QString metadataPath( + QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/metadata.desktop"))); KConfig metadata(metadataPath, KConfig::SimpleConfig); pluginMetaData = KPluginMetaData(metadataPath); @@ -856,7 +867,9 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings while (!fallback.isEmpty() && !fallbackThemes.contains(fallback)) { fallbackThemes.append(fallback); - QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % fallback % QStringLiteral("/metadata.desktop"))); + QString metadataPath( + QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % fallback % QStringLiteral("/metadata.desktop"))); KConfig metadata(metadataPath, KConfig::SimpleConfig); KConfigGroup cg(&metadata, "Settings"); fallback = cg.readEntry("FallbackTheme", QString()); @@ -867,13 +880,15 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings } for (const QString &theme : qAsConst(fallbackThemes)) { - QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QStringLiteral("/metadata.desktop"))); + QString metadataPath( + QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QStringLiteral("/metadata.desktop"))); KConfig metadata(metadataPath, KConfig::SimpleConfig); processWallpaperSettings(&metadata); } - //Check for what Plasma version the theme has been done - //There are some behavioral differences between KDE4 Plasma and Plasma 5 + // Check for what Plasma version the theme has been done + // There are some behavioral differences between KDE4 Plasma and Plasma 5 cg = KConfigGroup(&metadata, "Desktop Entry"); const QString apiVersion = cg.readEntry("X-Plasma-API", QString()); apiMajor = 1; @@ -900,7 +915,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings cg.sync(); } - if(emitChanged) { + if (emitChanged) { scheduleThemeChangeNotification(PixmapCache | SvgElementsCache); } } diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h index 3cf46fde6..422d0f292 100644 --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -8,16 +8,16 @@ #ifndef PLASMA_THEME_P_H #define PLASMA_THEME_P_H -#include "theme.h" #include "svg.h" +#include "theme.h" #include -#include #include #include +#include #include #include -#include +#include #include #include @@ -29,10 +29,9 @@ namespace Plasma { - class Theme; -//NOTE: Default wallpaper can be set from the theme configuration +// NOTE: Default wallpaper can be set from the theme configuration #define DEFAULT_WALLPAPER_THEME "default" #define DEFAULT_WALLPAPER_SUFFIX ".png" static const int DEFAULT_WALLPAPER_WIDTH = 1920; @@ -93,7 +92,7 @@ public: #if HAVE_X11 static EffectWatcher *s_backgroundContrastEffectWatcher; #endif -//Ref counting of ThemePrivate instances + // Ref counting of ThemePrivate instances static ThemePrivate *globalTheme; static QHash themes; @@ -146,7 +145,7 @@ public: bool adaptiveTransparencyEnabled; bool blurBehindEnabled; - //Version number of Plasma the Theme has been designed for + // Version number of Plasma the Theme has been designed for int apiMajor; int apiMinor; int apiRevision; diff --git a/src/plasma/private/timetracker.cpp b/src/plasma/private/timetracker.cpp index 5dd219bba..463e30526 100644 --- a/src/plasma/private/timetracker.cpp +++ b/src/plasma/private/timetracker.cpp @@ -5,14 +5,14 @@ */ #include "timetracker.h" -#include -#include -#include #include -#include +#include #include -#include +#include +#include #include +#include +#include using namespace Plasma; @@ -21,18 +21,21 @@ Q_GLOBAL_STATIC_WITH_ARGS(const qint64, s_beginning, (QDateTime::currentDateTime struct TimeTrackerWriter : QObject { Q_OBJECT public: - TimeTrackerWriter() { - QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, static_cast(&TimeTrackerWriter::print)); + TimeTrackerWriter() + { + QObject::connect(QCoreApplication::instance(), + &QCoreApplication::aboutToQuit, + this, + static_cast(&TimeTrackerWriter::print)); } - void print() { + void print() + { QJsonArray array; for (const ObjectHistory &history : qAsConst(m_data)) { - array.append(QJsonObject { - { QStringLiteral("events"), serializeEvents(history.events) }, - { QStringLiteral("initial"), QJsonValue::fromVariant(history.initial) } - }); + array.append(QJsonObject{{QStringLiteral("events"), serializeEvents(history.events)}, + {QStringLiteral("initial"), QJsonValue::fromVariant(history.initial)}}); } Q_ASSERT(array.count() == m_data.count()); QJsonDocument doc; @@ -44,22 +47,20 @@ public: f.write(doc.toJson()); } - void feed(QObject* obj, const ObjectHistory& tracker) + void feed(QObject *obj, const ObjectHistory &tracker) { m_data[obj] = tracker; } - QHash m_data; + QHash m_data; private: - QJsonArray serializeEvents(const QVector& events) const { + QJsonArray serializeEvents(const QVector &events) const + { QJsonArray ret; Q_ASSERT(!events.isEmpty()); for (const TimeEvent &ev : events) { - ret.append(QJsonObject { - { QStringLiteral("comment"), ev.comment }, - { QStringLiteral("time"), ev.moment.toMSecsSinceEpoch() - *s_beginning } - }); + ret.append(QJsonObject{{QStringLiteral("comment"), ev.comment}, {QStringLiteral("time"), ev.moment.toMSecsSinceEpoch() - *s_beginning}}); } Q_ASSERT(ret.count() == events.count()); return ret; @@ -67,12 +68,12 @@ private: }; Q_GLOBAL_STATIC(TimeTrackerWriter, s_writer) -TimeTracker::TimeTracker(QObject* o) +TimeTracker::TimeTracker(QObject *o) : QObject(o) { *s_beginning * 1; // ensure it's initialized - QTimer* t = new QTimer(this); + QTimer *t = new QTimer(this); t->setInterval(2000); t->setSingleShot(false); connect(t, &QTimer::timeout, this, &TimeTracker::sync); @@ -83,13 +84,14 @@ TimeTracker::TimeTracker(QObject* o) void TimeTracker::init() { - m_history.events.append(TimeEvent { QDateTime::currentDateTime(), QStringLiteral("constructed %1 %2").arg(QString::fromUtf8(parent()->metaObject()->className()), parent()->objectName()) }); + m_history.events.append(TimeEvent{QDateTime::currentDateTime(), + QStringLiteral("constructed %1 %2").arg(QString::fromUtf8(parent()->metaObject()->className()), parent()->objectName())}); QMetaMethod propChange = metaObject()->method(metaObject()->indexOfSlot("propertyChanged()")); - Q_ASSERT(propChange.isValid() && metaObject()->indexOfSlot("propertyChanged()")>=0); + Q_ASSERT(propChange.isValid() && metaObject()->indexOfSlot("propertyChanged()") >= 0); - QObject* o = parent(); - for (int i = 0, pc = o->metaObject()->propertyCount(); imetaObject()->propertyCount(); i < pc; ++i) { QMetaProperty prop = o->metaObject()->property(i); m_history.initial[QString::fromUtf8(prop.name())] = prop.read(o); @@ -112,15 +114,16 @@ void TimeTracker::propertyChanged() { Q_ASSERT(sender() == parent()); - const QMetaObject* mo = parent()->metaObject(); + const QMetaObject *mo = parent()->metaObject(); - for (int i = 0, pc = mo->propertyCount(); ipropertyCount(); i < pc; ++i) { const QMetaProperty prop = mo->property(i); if (prop.notifySignalIndex() == senderSignalIndex()) { QString val; QDebug d(&val); d << prop.read(parent()); - m_history.events.append(TimeEvent { QDateTime::currentDateTime(), QStringLiteral("property %1 changed to %2").arg(QString::fromUtf8(prop.name()), val.trimmed())}); + m_history.events.append( + TimeEvent{QDateTime::currentDateTime(), QStringLiteral("property %1 changed to %2").arg(QString::fromUtf8(prop.name()), val.trimmed())}); } } } diff --git a/src/plasma/private/timetracker.h b/src/plasma/private/timetracker.h index 553be0969..0676634bf 100644 --- a/src/plasma/private/timetracker.h +++ b/src/plasma/private/timetracker.h @@ -7,9 +7,9 @@ #ifndef TIMETRACKER_H #define TIMETRACKER_H +#include #include #include -#include #include #include "plasma/plasma_export.h" @@ -19,14 +19,12 @@ namespace Plasma class Containment; class Applet; -struct TimeEvent -{ +struct TimeEvent { QDateTime moment; QString comment; }; -struct ObjectHistory -{ +struct ObjectHistory { QVariantMap initial; QVector events; }; @@ -45,9 +43,9 @@ struct ObjectHistory class PLASMA_EXPORT TimeTracker : public QObject { -Q_OBJECT + Q_OBJECT public: - explicit TimeTracker(QObject* applet); + explicit TimeTracker(QObject *applet); virtual ~TimeTracker(); private Q_SLOTS: diff --git a/src/plasma/scripting/appletscript.cpp b/src/plasma/scripting/appletscript.cpp index 1a9a34505..ba49792b6 100644 --- a/src/plasma/scripting/appletscript.cpp +++ b/src/plasma/scripting/appletscript.cpp @@ -14,7 +14,6 @@ namespace Plasma { - class AppletScriptPrivate { public: @@ -22,8 +21,8 @@ public: }; AppletScript::AppletScript(QObject *parent) - : ScriptEngine(parent), - d(new AppletScriptPrivate) + : ScriptEngine(parent) + , d(new AppletScriptPrivate) { d->applet = nullptr; } diff --git a/src/plasma/scripting/appletscript.h b/src/plasma/scripting/appletscript.h index 1332ebe92..c78d40b1f 100644 --- a/src/plasma/scripting/appletscript.h +++ b/src/plasma/scripting/appletscript.h @@ -22,7 +22,6 @@ class QPainter; namespace Plasma { - class AppletScriptPrivate; class Extender; @@ -154,12 +153,11 @@ private: AppletScriptPrivate *const d; }; -#define K_EXPORT_PLASMA_APPLETSCRIPTENGINE(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) +#define K_EXPORT_PLASMA_APPLETSCRIPTENGINE(libname, classname) K_PLUGIN_FACTORY(factory, registerPlugin();) -#define K_EXPORT_PLASMA_APPLETSCRIPTENGINE_WITH_JSON(libname, classname, jsonFile) \ - K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ +#define K_EXPORT_PLASMA_APPLETSCRIPTENGINE_WITH_JSON(libname, classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -} //Plasma namespace +} // Plasma namespace #endif diff --git a/src/plasma/scripting/dataenginescript.cpp b/src/plasma/scripting/dataenginescript.cpp index 67d4956ed..638cf6430 100644 --- a/src/plasma/scripting/dataenginescript.cpp +++ b/src/plasma/scripting/dataenginescript.cpp @@ -12,7 +12,6 @@ namespace Plasma { - class DataEngineScriptPrivate { public: @@ -20,8 +19,8 @@ public: }; DataEngineScript::DataEngineScript(QObject *parent) - : ScriptEngine(parent), - d(new DataEngineScriptPrivate) + : ScriptEngine(parent) + , d(new DataEngineScriptPrivate) { } @@ -86,8 +85,7 @@ KPluginMetaData DataEngineScript::metadata() const return d->dataEngine->metadata(); } -void DataEngineScript::setData(const QString &source, const QString &key, - const QVariant &value) +void DataEngineScript::setData(const QString &source, const QString &key, const QVariant &value) { if (d->dataEngine) { d->dataEngine->setData(source, key, value); diff --git a/src/plasma/scripting/dataenginescript.h b/src/plasma/scripting/dataenginescript.h index a5b12e73a..f0c62de73 100644 --- a/src/plasma/scripting/dataenginescript.h +++ b/src/plasma/scripting/dataenginescript.h @@ -9,13 +9,12 @@ #include -#include #include +#include #include namespace Plasma { - class DataEngineScriptPrivate; class Service; @@ -114,8 +113,7 @@ protected: */ KPluginMetaData metadata() const; - void setData(const QString &source, const QString &key, - const QVariant &value); + void setData(const QString &source, const QString &key, const QVariant &value); void setData(const QString &source, const QVariant &value); /** @@ -129,7 +127,7 @@ protected: void removeAllData(const QString &source); void removeData(const QString &source, const QString &key); void setMinimumPollingInterval(int minimumMs); - int minimumPollingInterval() const; + int minimumPollingInterval() const; void setPollingInterval(uint frequency); void removeAllSources(); void addSource(DataContainer *source); @@ -142,12 +140,11 @@ private: DataEngineScriptPrivate *const d; }; -#define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) +#define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(libname, classname) K_PLUGIN_FACTORY(factory, registerPlugin();) -#define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE_WITH_JSON(libname, classname, jsonFile) \ - K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ +#define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE_WITH_JSON(libname, classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -} //Plasma namespace +} // Plasma namespace #endif diff --git a/src/plasma/scripting/scriptengine.cpp b/src/plasma/scripting/scriptengine.cpp index 0badb49cc..49dc09542 100644 --- a/src/plasma/scripting/scriptengine.cpp +++ b/src/plasma/scripting/scriptengine.cpp @@ -11,14 +11,13 @@ #include "applet.h" #include "dataengine.h" +#include "debug_p.h" #include "package.h" #include "scripting/appletscript.h" #include "scripting/dataenginescript.h" -#include "debug_p.h" namespace Plasma { - static QVector listEngines(Types::ComponentTypes types, std::function filter) { QVector ret; @@ -28,8 +27,8 @@ static QVector listEngines(Types::ComponentTypes types, std::fu if (!filter(plugin)) continue; const QStringList componentTypes = KPluginMetaData::readStringList(plugins.first().rawData(), QStringLiteral("X-Plasma-ComponentTypes")); - if (((types & Types::AppletComponent) && componentTypes.contains(QLatin1String("Applet"))) - ||((types & Types::DataEngineComponent) && componentTypes.contains(QLatin1String("DataEngine")))) { + if (((types & Types::AppletComponent) && componentTypes.contains(QLatin1String("Applet"))) + || ((types & Types::DataEngineComponent) && componentTypes.contains(QLatin1String("DataEngine")))) { ret << plugin; } } @@ -37,14 +36,14 @@ static QVector listEngines(Types::ComponentTypes types, std::fu } ScriptEngine::ScriptEngine(QObject *parent) - : QObject(parent), - d(nullptr) + : QObject(parent) + , d(nullptr) { } ScriptEngine::~ScriptEngine() { -// delete d; + // delete d; } bool ScriptEngine::init() @@ -65,7 +64,9 @@ QString ScriptEngine::mainScript() const QStringList knownLanguages(Types::ComponentTypes types) { QStringList languages; - const QVector plugins = listEngines(types, [] (const KPluginMetaData &) -> bool { return true;}); + const QVector plugins = listEngines(types, [](const KPluginMetaData &) -> bool { + return true; + }); for (const auto &plugin : plugins) languages << plugin.value(QStringLiteral("X-Plasma-API")); @@ -76,8 +77,7 @@ QStringList knownLanguages(Types::ComponentTypes types) typedef QHash> EngineCache; Q_GLOBAL_STATIC(EngineCache, engines) -ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QObject *parent, - const QVariantList &args = QVariantList()) +ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QObject *parent, const QVariantList &args = QVariantList()) { Q_UNUSED(parent); @@ -89,8 +89,7 @@ ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QOb } ScriptEngine *engine = nullptr; - auto filter = [&language](const KPluginMetaData &md) -> bool - { + auto filter = [&language](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-Plasma-API")) == language; }; @@ -111,8 +110,7 @@ ScriptEngine *loadEngine(const QString &language, Types::ComponentType type, QOb AppletScript *loadScriptEngine(const QString &language, Applet *applet, const QVariantList &args) { - AppletScript *engine = - static_cast(loadEngine(language, Types::AppletComponent, applet, args)); + AppletScript *engine = static_cast(loadEngine(language, Types::AppletComponent, applet, args)); if (engine) { engine->setApplet(applet); @@ -123,8 +121,7 @@ AppletScript *loadScriptEngine(const QString &language, Applet *applet, const QV DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine, const QVariantList &args) { - DataEngineScript *engine = - static_cast(loadEngine(language, Types::DataEngineComponent, dataEngine, args)); + DataEngineScript *engine = static_cast(loadEngine(language, Types::DataEngineComponent, dataEngine, args)); if (engine) { engine->setDataEngine(dataEngine); diff --git a/src/plasma/scripting/scriptengine.h b/src/plasma/scripting/scriptengine.h index 5a8a0a989..839875a26 100644 --- a/src/plasma/scripting/scriptengine.h +++ b/src/plasma/scripting/scriptengine.h @@ -8,8 +8,8 @@ #define PLASMA_SCRIPTENGINE_H #include -#include #include +#include #include #include @@ -19,7 +19,6 @@ class QPainter; namespace Plasma { - class Applet; class AppletScript; class DataEngine; @@ -94,4 +93,3 @@ PLASMA_EXPORT DataEngineScript *loadScriptEngine(const QString &language, DataEn } // namespace Plasma #endif - diff --git a/src/plasma/service.cpp b/src/plasma/service.cpp index fbf554c2e..ebabde628 100644 --- a/src/plasma/service.cpp +++ b/src/plasma/service.cpp @@ -12,30 +12,29 @@ #include #include -#include -#include -#include #include #include +#include +#include +#include #include -#include "version.h" -#include "pluginloader.h" #include "debug_p.h" +#include "pluginloader.h" +#include "version.h" namespace Plasma { - Service::Service(QObject *parent) - : QObject(parent), - d(new ServicePrivate(this)) + : QObject(parent) + , d(new ServicePrivate(this)) { } Service::Service(QObject *parent, const QVariantList &args) - : QObject(parent), - d(new ServicePrivate(this)) + : QObject(parent) + , d(new ServicePrivate(this)) { Q_UNUSED(args) } @@ -76,7 +75,7 @@ QVariantMap Service::operationDescription(const QString &operationName) return QVariantMap(); } - //qCDebug(LOG_PLASMA) << "operation" << operationName + // qCDebug(LOG_PLASMA) << "operation" << operationName // << "requested, has keys" << d->operationsMap.keys(); return d->operationsMap.value(operationName); } @@ -187,7 +186,8 @@ void Service::registerOperationsScheme() return; } - const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/services/") + d->name + QStringLiteral(".operations")); + const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/services/") + d->name + QStringLiteral(".operations")); if (path.isEmpty()) { #ifndef NDEBUG diff --git a/src/plasma/service.h b/src/plasma/service.h index 30fcc0c25..293015993 100644 --- a/src/plasma/service.h +++ b/src/plasma/service.h @@ -13,8 +13,8 @@ #include -#include #include +#include class QIODevice; class QWidget; @@ -23,7 +23,6 @@ class QQuickItem; namespace Plasma { - class ServiceJob; class ServicePrivate; @@ -168,8 +167,7 @@ protected: * @param parameters the parameters set by the user for the operation * @return a ServiceJob that can be started and monitored by the consumer */ - virtual ServiceJob *createJob(const QString &operation, - QVariantMap ¶meters) = 0; + virtual ServiceJob *createJob(const QString &operation, QVariantMap ¶meters) = 0; /** * By default this is based on the file in plasma/services/name.operations, but can be @@ -213,13 +211,12 @@ private: /** * Register a service when it is contained in a loadable module */ -#define K_EXPORT_PLASMA_SERVICE(libname, classname) \ - K_PLUGIN_FACTORY(factory, registerPlugin();) \ +#define K_EXPORT_PLASMA_SERVICE(libname, classname) \ + K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) -#define K_EXPORT_PLASMA_SERVICE_WITH_JSON(libname, classname, jsonFile) \ - K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ +#define K_EXPORT_PLASMA_SERVICE_WITH_JSON(libname, classname, jsonFile) \ + K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // multiple inclusion guard - diff --git a/src/plasma/servicejob.cpp b/src/plasma/servicejob.cpp index 8727a601e..452f598e4 100644 --- a/src/plasma/servicejob.cpp +++ b/src/plasma/servicejob.cpp @@ -12,14 +12,12 @@ namespace Plasma { - -ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest, - const QString &op, const QVariantMap ¶ms) - : q(owner), - destination(dest), - operation(op), - parameters(params), - m_allowAutoStart(true) +ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest, const QString &op, const QVariantMap ¶ms) + : q(owner) + , destination(dest) + , operation(op) + , parameters(params) + , m_allowAutoStart(true) { } @@ -42,12 +40,11 @@ void ServiceJobPrivate::autoStart() } } -ServiceJob::ServiceJob(const QString &destination, const QString &operation, - const QVariantMap ¶meters, QObject *parent) - : KJob(parent), - d(new ServiceJobPrivate(this, destination, operation, parameters)) +ServiceJob::ServiceJob(const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent) + : KJob(parent) + , d(new ServiceJobPrivate(this, destination, operation, parameters)) { - connect(this, SIGNAL(finished(KJob*)), this, SLOT(preventAutoStart())); + connect(this, SIGNAL(finished(KJob *)), this, SLOT(preventAutoStart())); } ServiceJob::~ServiceJob() diff --git a/src/plasma/servicejob.h b/src/plasma/servicejob.h index a9b26b9a5..bb79779a1 100644 --- a/src/plasma/servicejob.h +++ b/src/plasma/servicejob.h @@ -15,7 +15,6 @@ namespace Plasma { - class ServiceJobPrivate; /** @@ -52,8 +51,7 @@ public: * @param parameters the parameters of the @p action * @param parent the parent object for this service */ - ServiceJob(const QString &destination, const QString &operation, - const QVariantMap ¶meters, QObject *parent = nullptr); + ServiceJob(const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent = nullptr); /** * Destructor @@ -110,4 +108,3 @@ private: } // namespace Plasma #endif // multiple inclusion guard - diff --git a/src/plasma/svg.cpp b/src/plasma/svg.cpp index 79d6e5cf6..be744b8af 100644 --- a/src/plasma/svg.cpp +++ b/src/plasma/svg.cpp @@ -9,53 +9,49 @@ #include "private/svg_p.h" #include "private/theme_p.h" -#include #include +#include +#include #include #include #include #include +#include #include #include #include -#include -#include #include #include -#include #include #include #include #include +#include #include "applet.h" +#include "debug_p.h" #include "package.h" #include "theme.h" -#include "debug_p.h" uint qHash(const Plasma::SvgPrivate::CacheId &id, uint seed) { - std::array parts = { - ::qHash(id.width), - ::qHash(id.height), - ::qHash(id.elementName), - ::qHash(id.filePath), - ::qHash(id.status), - ::qHash(id.devicePixelRatio), - ::qHash(id.scaleFactor), - ::qHash(id.colorGroup), - ::qHash(id.extraFlags), - ::qHash(id.lastModified) - }; + std::array parts = {::qHash(id.width), + ::qHash(id.height), + ::qHash(id.elementName), + ::qHash(id.filePath), + ::qHash(id.status), + ::qHash(id.devicePixelRatio), + ::qHash(id.scaleFactor), + ::qHash(id.colorGroup), + ::qHash(id.extraFlags), + ::qHash(id.lastModified)}; return qHashRange(parts.begin(), parts.end(), seed); } - namespace Plasma { - class SvgRectsCacheSingleton { public: @@ -71,11 +67,7 @@ SharedSvgRenderer::SharedSvgRenderer(QObject *parent) { } -SharedSvgRenderer::SharedSvgRenderer( - const QString &filename, - const QString &styleSheet, - QHash &interestingElements, - QObject *parent) +SharedSvgRenderer::SharedSvgRenderer(const QString &filename, const QString &styleSheet, QHash &interestingElements, QObject *parent) : QSvgRenderer(parent) { KCompressionDevice file(filename, KCompressionDevice::GZip); @@ -85,20 +77,13 @@ SharedSvgRenderer::SharedSvgRenderer( load(file.readAll(), styleSheet, interestingElements); } -SharedSvgRenderer::SharedSvgRenderer( - const QByteArray &contents, - const QString &styleSheet, - QHash &interestingElements, - QObject *parent) +SharedSvgRenderer::SharedSvgRenderer(const QByteArray &contents, const QString &styleSheet, QHash &interestingElements, QObject *parent) : QSvgRenderer(parent) { load(contents, styleSheet, interestingElements); } -bool SharedSvgRenderer::load( - const QByteArray &contents, - const QString &styleSheet, - QHash &interestingElements) +bool SharedSvgRenderer::load(const QByteArray &contents, const QString &styleSheet, QHash &interestingElements) { // Apply the style sheet. if (!styleSheet.isEmpty() && contents.contains("current-color-scheme")) { @@ -110,9 +95,8 @@ bool SharedSvgRenderer::load( buffer.open(QIODevice::WriteOnly); QXmlStreamWriter writer(&buffer); while (!reader.atEnd()) { - if (reader.readNext() == QXmlStreamReader::StartElement && - reader.qualifiedName() == QLatin1String("style") && - reader.attributes().value(QLatin1String("id")) == QLatin1String("current-color-scheme")) { + if (reader.readNext() == QXmlStreamReader::StartElement && reader.qualifiedName() == QLatin1String("style") + && reader.attributes().value(QLatin1String("id")) == QLatin1String("current-color-scheme")) { writer.writeStartElement(QLatin1String("style")); writer.writeAttributes(reader.attributes()); writer.writeCharacters(styleSheet); @@ -154,16 +138,16 @@ bool SharedSvgRenderer::load( SvgRectsCache::SvgRectsCache(QObject *parent) : QObject(parent) { - const QString svgElementsFile = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + QStringLiteral("plasma-svgelements"); + const QString svgElementsFile = + QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + QStringLiteral("plasma-svgelements"); m_svgElementsCache = KSharedConfig::openConfig(svgElementsFile, KConfig::SimpleConfig); m_configSyncTimer = new QTimer(this); m_configSyncTimer->setSingleShot(true); m_configSyncTimer->setInterval(5000); - connect(m_configSyncTimer, &QTimer::timeout, - this, [this]() { - m_svgElementsCache->sync(); - }); + connect(m_configSyncTimer, &QTimer::timeout, this, [this]() { + m_svgElementsCache->sync(); + }); } SvgRectsCache *SvgRectsCache::instance() @@ -279,8 +263,8 @@ QList SvgRectsCache::sizeHintsForId(const QString &path, const QString &i void SvgRectsCache::insertSizeHintForId(const QString &path, const QString &id, const QSize &size) { - //TODO: need to make this more efficient - auto sizeListToString = [] (const QList &list) { + // TODO: need to make this more efficient + auto sizeListToString = [](const QList &list) { QString ret; for (const auto &s : list) { ret += QString::number(s.width()) % QLatin1Char('x') % QString::number(s.height()) % QLatin1Char(','); @@ -352,7 +336,11 @@ QStringList SvgRectsCache::cachedKeysForPath(const QString &path) const QStringList list = imageGroup.keyList(); QStringList filtered; - std::copy_if (list.begin(), list.end(), std::back_inserter(filtered), [](const QString element){bool ok; element.toLong(&ok); return ok;} ); + std::copy_if(list.begin(), list.end(), std::back_inserter(filtered), [](const QString element) { + bool ok; + element.toLong(&ok); + return ok; + }); return filtered; } @@ -364,22 +352,22 @@ void SvgRectsCache::updateLastModified(const QString &filePath, unsigned int las } SvgPrivate::SvgPrivate(Svg *svg) - : q(svg), - renderer(nullptr), - styleCrc(0), - colorGroup(Plasma::Theme::NormalColorGroup), - lastModified(0), - devicePixelRatio(1.0), - scaleFactor(s_lastScaleFactor), - status(Svg::Status::Normal), - multipleImages(false), - themed(false), - useSystemColors(false), - fromCurrentTheme(false), - applyColors(false), - usesColors(false), - cacheRendering(true), - themeFailed(false) + : q(svg) + , renderer(nullptr) + , styleCrc(0) + , colorGroup(Plasma::Theme::NormalColorGroup) + , lastModified(0) + , devicePixelRatio(1.0) + , scaleFactor(s_lastScaleFactor) + , status(Svg::Status::Normal) + , multipleImages(false) + , themed(false) + , useSystemColors(false) + , fromCurrentTheme(false) + , applyColors(false) + , usesColors(false) + , cacheRendering(true) + , themeFailed(false) { } @@ -388,14 +376,14 @@ SvgPrivate::~SvgPrivate() eraseRenderer(); } -//This function is meant for the rects cache +// This function is meant for the rects cache SvgPrivate::CacheId SvgPrivate::cacheId(const QString &elementId) const { auto idSize = size.isValid() && size != naturalSize ? size : QSizeF{-1.0, -1.0}; return CacheId{idSize.width(), idSize.height(), path, elementId, status, devicePixelRatio, scaleFactor, -1, 0, lastModified}; } -//This function is meant for the pixmap cache +// This function is meant for the pixmap cache QString SvgPrivate::cachePath(const QString &id, const QSize &size) const { auto cacheId = CacheId{double(size.width()), double(size.height()), path, id, status, devicePixelRatio, scaleFactor, colorGroup, 0, lastModified}; @@ -406,22 +394,20 @@ bool SvgPrivate::setImagePath(const QString &imagePath) { QString actualPath = imagePath; if (imagePath.startsWith(QLatin1String("file://"))) { - //length of file:// + // length of file:// actualPath.remove(0, 7); } bool isThemed = !actualPath.isEmpty() && !QDir::isAbsolutePath(actualPath); bool inIconTheme = false; - //an absolute path.. let's try if this actually an *icon* theme + // an absolute path.. let's try if this actually an *icon* theme if (!isThemed && !actualPath.isEmpty()) { const auto *iconTheme = KIconLoader::global()->theme(); isThemed = inIconTheme = iconTheme && actualPath.startsWith(iconTheme->dir()); } // lets check to see if we're already set to this file - if (isThemed == themed && - ((themed && themePath == actualPath) || - (!themed && path == actualPath))) { + if (isThemed == themed && ((themed && themePath == actualPath) || (!themed && path == actualPath))) { return false; } @@ -429,7 +415,7 @@ bool SvgPrivate::setImagePath(const QString &imagePath) // if we don't have any path right now and are going to set one, // then lets not schedule a repaint because we are just initializing! - bool updateNeeded = true; //!path.isEmpty() || !themePath.isEmpty(); + bool updateNeeded = true; //! path.isEmpty() || !themePath.isEmpty(); QObject::disconnect(actualTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged())); if (isThemed && !themed && s_systemColorsCache) { @@ -511,7 +497,7 @@ Theme *SvgPrivate::cacheAndColorsTheme() } else { // use a separate cache source for unthemed svg's if (!s_systemColorsCache) { - //FIXME: reference count this, so that it is deleted when no longer in use + // FIXME: reference count this, so that it is deleted when no longer in use s_systemColorsCache = new Plasma::Theme(QStringLiteral("internal-system-colors")); } @@ -533,17 +519,14 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi QSizeF bestFit(-1, -1); for (const auto &hint : elementSizeHints) { - - if (hint.width() >= s.width() * ratio && hint.height() >= s.height() * ratio && - (!bestFit.isValid() || - (bestFit.width() * bestFit.height()) > (hint.width() * hint.height()))) { + if (hint.width() >= s.width() * ratio && hint.height() >= s.height() * ratio + && (!bestFit.isValid() || (bestFit.width() * bestFit.height()) > (hint.width() * hint.height()))) { bestFit = hint; } } if (bestFit.isValid()) { - actualElementId = QString::number(bestFit.width()) % QLatin1Char('-') % - QString::number(bestFit.height()) % QLatin1Char('-') % elementId; + actualElementId = QString::number(bestFit.width()) % QLatin1Char('-') % QString::number(bestFit.height()) % QLatin1Char('-') % elementId; } } } @@ -567,7 +550,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi QPixmap p; if (cacheRendering && cacheAndColorsTheme()->findInCache(id, p, lastModified)) { p.setDevicePixelRatio(ratio); - //qCDebug(LOG_PLASMA) << "found cached version of " << id << p.size(); + // qCDebug(LOG_PLASMA) << "found cached version of " << id << p.size(); return p; } @@ -575,8 +558,8 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi QRectF finalRect = makeUniform(renderer->boundsOnElement(actualElementId), QRect(QPoint(0, 0), size)); - //don't alter the pixmap size or it won't match up properly to, e.g., FrameSvg elements - //makeUniform should never change the size so much that it gains or loses a whole pixel + // don't alter the pixmap size or it won't match up properly to, e.g., FrameSvg elements + // makeUniform should never change the size so much that it gains or loses a whole pixel p = QPixmap(size); p.fill(Qt::transparent); @@ -615,9 +598,9 @@ void SvgPrivate::createRenderer() if (themed && path.isEmpty() && !themeFailed) { Applet *applet = qobject_cast(q->parent()); - //FIXME: this maybe could be more efficient if we knew if the package was empty, e.g. for - //C++; however, I'm not sure this has any real world runtime impact. something to measure - //for. + // FIXME: this maybe could be more efficient if we knew if the package was empty, e.g. for + // C++; however, I'm not sure this has any real world runtime impact. something to measure + // for. if (applet && applet->kPackage().isValid()) { const KPackage::Package package = applet->kPackage(); path = package.filePath("images", themePath + QLatin1String(".svg")); @@ -679,8 +662,7 @@ void SvgPrivate::createRenderer() void SvgPrivate::eraseRenderer() { - if (renderer && - renderer->ref.loadRelaxed() == 2) { + if (renderer && renderer->ref.loadRelaxed() == 2) { // this and the cache reference it s_renderers.erase(s_renderers.find(styleCrc + path)); } @@ -711,7 +693,7 @@ QRectF SvgPrivate::elementRect(const QString &elementId) QRectF rect; const CacheId cacheId = SvgPrivate::cacheId(elementId); bool found = SvgRectsCache::instance()->findElementRect(cacheId, rect); - //This is a corner case where we are *sure* the element is not valid + // This is a corner case where we are *sure* the element is not valid if (!found) { rect = findAndCacheElementRect(elementId); } @@ -721,26 +703,27 @@ QRectF SvgPrivate::elementRect(const QString &elementId) QRectF SvgPrivate::findAndCacheElementRect(const QString &elementId) { - //we need to check the id before createRenderer(), otherwise it may generate a different id compared to the previous cacheId)( call + // we need to check the id before createRenderer(), otherwise it may generate a different id compared to the previous cacheId)( call const CacheId cacheId = SvgPrivate::cacheId(elementId); createRenderer(); - //This code will usually never be run because createRenderer already caches all the boundingRect in the elements in the svg + // This code will usually never be run because createRenderer already caches all the boundingRect in the elements in the svg QRectF elementRect = renderer->elementExists(elementId) ? #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - renderer->transformForElement(elementId).map(renderer->boundsOnElement(elementId)).boundingRect() : + renderer->transformForElement(elementId).map(renderer->boundsOnElement(elementId)).boundingRect() + : #else - renderer->matrixForElement(elementId).map(renderer->boundsOnElement(elementId)).boundingRect() : + renderer->matrixForElement(elementId).map(renderer->boundsOnElement(elementId)).boundingRect() + : #endif - QRectF(); + QRectF(); naturalSize = renderer->defaultSize() * scaleFactor; qreal dx = size.width() / renderer->defaultSize().width(); qreal dy = size.height() / renderer->defaultSize().height(); - elementRect = QRectF(elementRect.x() * dx, elementRect.y() * dy, - elementRect.width() * dx, elementRect.height() * dy); + elementRect = QRectF(elementRect.x() * dx, elementRect.y() * dy, elementRect.width() * dx, elementRect.height() * dy); SvgRectsCache::instance()->insert(cacheId, elementRect, lastModified); return elementRect; @@ -775,8 +758,8 @@ bool Svg::eventFilter(QObject *watched, QEvent *event) return QObject::eventFilter(watched, event); } -//Following two are utility functions to snap rendered elements to the pixel grid -//to and from are always 0 <= val <= 1 +// Following two are utility functions to snap rendered elements to the pixel grid +// to and from are always 0 <= val <= 1 qreal SvgPrivate::closestDistance(qreal to, qreal from) { qreal a = to - from; @@ -784,7 +767,7 @@ qreal SvgPrivate::closestDistance(qreal to, qreal from) return 0; } else if (to > from) { qreal b = to - from - 1; - return (qAbs(a) > qAbs(b)) ? b : a; + return (qAbs(a) > qAbs(b)) ? b : a; } else { qreal b = 1 + to - from; return (qAbs(a) > qAbs(b)) ? b : a; @@ -804,7 +787,7 @@ QRectF SvgPrivate::makeUniform(const QRectF &orig, const QRectF &dst) qreal div_x = dst.x() / orig.x(); qreal div_y = dst.y() / orig.y(); - //horizontal snap + // horizontal snap if (!qFuzzyIsNull(div_x) && !qFuzzyCompare(div_w, div_x)) { qreal rem_orig = orig.x() - (floor(orig.x())); qreal rem_dst = dst.x() - (floor(dst.x())); @@ -812,7 +795,7 @@ QRectF SvgPrivate::makeUniform(const QRectF &orig, const QRectF &dst) res.translate(offset + offset * div_w, 0); res.setWidth(res.width() + offset); } - //vertical snap + // vertical snap if (!qFuzzyIsNull(div_y) && !qFuzzyCompare(div_h, div_y)) { qreal rem_orig = orig.y() - (floor(orig.y())); qreal rem_dst = dst.y() - (floor(dst.y())); @@ -841,7 +824,7 @@ void SvgPrivate::themeChanged() setImagePath(currentPath); q->resize(); - //qCDebug(LOG_PLASMA) << themePath << ">>>>>>>>>>>>>>>>>> theme changed"; + // qCDebug(LOG_PLASMA) << themePath << ">>>>>>>>>>>>>>>>>> theme changed"; Q_EMIT q->repaintNeeded(); } @@ -862,8 +845,8 @@ QPointer SvgPrivate::s_systemColorsCache; qreal SvgPrivate::s_lastScaleFactor = 1.0; Svg::Svg(QObject *parent) - : QObject(parent), - d(new SvgPrivate(this)) + : QObject(parent) + , d(new SvgPrivate(this)) { } @@ -874,8 +857,8 @@ Svg::~Svg() void Svg::setDevicePixelRatio(qreal ratio) { - //be completely integer for now - //devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. + // be completely integer for now + // devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned) if (floor(d->devicePixelRatio) == floor(ratio)) { return; @@ -895,11 +878,10 @@ qreal Svg::devicePixelRatio() return d->devicePixelRatio; } - void Svg::setScaleFactor(qreal ratio) { - //be completely integer for now - //devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. + // be completely integer for now + // devicepixelratio is always set integer in the svg, so needs at least 192dpi to double up. //(it needs to be integer to have lines contained inside a svg piece to keep being pixel aligned) if (floor(d->scaleFactor) == floor(ratio)) { return; @@ -907,7 +889,7 @@ void Svg::setScaleFactor(qreal ratio) d->scaleFactor = floor(ratio); d->s_lastScaleFactor = d->scaleFactor; - //not resize() because we want to do it unconditionally + // not resize() because we want to do it unconditionally QRectF rect; d->naturalSize = SvgRectsCache::instance()->naturalSize(d->path, d->scaleFactor); @@ -963,8 +945,7 @@ void Svg::paint(QPainter *painter, const QPointF &point, const QString &elementI { Q_ASSERT(painter->device()); const int ratio = painter->device()->devicePixelRatio(); - QPixmap pix((elementID.isNull() || d->multipleImages) ? d->findInCache(elementID, ratio, size()) : - d->findInCache(elementID, ratio)); + QPixmap pix((elementID.isNull() || d->multipleImages) ? d->findInCache(elementID, ratio, size()) : d->findInCache(elementID, ratio)); if (pix.isNull()) { return; @@ -1011,8 +992,7 @@ void Svg::resize(qreal width, qreal height) void Svg::resize(const QSizeF &size) { - if (qFuzzyCompare(size.width(), d->size.width()) && - qFuzzyCompare(size.height(), d->size.height())) { + if (qFuzzyCompare(size.width(), d->size.width()) && qFuzzyCompare(size.height(), d->size.height())) { return; } @@ -1022,8 +1002,7 @@ void Svg::resize(const QSizeF &size) void Svg::resize() { - if (qFuzzyCompare(d->naturalSize.width(), d->size.width()) && - qFuzzyCompare(d->naturalSize.height(), d->size.height())) { + if (qFuzzyCompare(d->naturalSize.width(), d->size.width()) && qFuzzyCompare(d->naturalSize.height(), d->size.height())) { return; } @@ -1056,7 +1035,7 @@ bool Svg::isValid() const return false; } - //try very hard to avoid creation of a parser + // try very hard to avoid creation of a parser QRectF rect; QSizeF naturalSize = SvgRectsCache::instance()->naturalSize(d->path, d->scaleFactor); if (!naturalSize.isEmpty()) { @@ -1161,5 +1140,5 @@ Svg::Status Svg::status() const } // Plasma namespace -#include "private/moc_svg_p.cpp" #include "moc_svg.cpp" +#include "private/moc_svg_p.cpp" diff --git a/src/plasma/svg.h b/src/plasma/svg.h index 5e63febb2..24f88793f 100644 --- a/src/plasma/svg.h +++ b/src/plasma/svg.h @@ -24,7 +24,6 @@ class QMatrix; namespace Plasma { - class FrameSvgPrivate; class SvgPrivate; @@ -161,8 +160,7 @@ public: * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ - Q_INVOKABLE void paint(QPainter *painter, const QPointF &point, - const QString &elementID = QString()); + Q_INVOKABLE void paint(QPainter *painter, const QPointF &point, const QString &elementID = QString()); /** * Paints all or part of the SVG represented by this object @@ -178,8 +176,7 @@ public: * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ - Q_INVOKABLE void paint(QPainter *painter, int x, int y, - const QString &elementID = QString()); + Q_INVOKABLE void paint(QPainter *painter, int x, int y, const QString &elementID = QString()); /** * Paints all or part of the SVG represented by this object @@ -190,8 +187,7 @@ public: * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ - Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect, - const QString &elementID = QString()); + Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect, const QString &elementID = QString()); /** * Paints all or part of the SVG represented by this object @@ -204,8 +200,7 @@ public: * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ - Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width, - int height, const QString &elementID = QString()); + Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width, int height, const QString &elementID = QString()); /** * The size of the SVG. @@ -501,4 +496,3 @@ private: } // Plasma namespace #endif // multiple inclusion guard - diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp index e5450e08d..d0e805f7e 100644 --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -5,35 +5,34 @@ */ #include "theme.h" -#include "private/theme_p.h" #include "private/svg_p.h" +#include "private/theme_p.h" #include -#include #include +#include +#include #include #include #include -#include #include -#include +#include #include "config-plasma.h" #include #include -#include #include #include #include #include +#include #include #include "debug_p.h" namespace Plasma { - Theme::Theme(QObject *parent) : QObject(parent) { @@ -45,8 +44,7 @@ Theme::Theme(QObject *parent) d = ThemePrivate::globalTheme; if (QCoreApplication::instance()) { - connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, - d, &ThemePrivate::onAppExitCleanup); + connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, d, &ThemePrivate::onAppExitCleanup); } connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged); connect(d, &ThemePrivate::defaultFontChanged, this, &Theme::defaultFontChanged); @@ -56,7 +54,7 @@ Theme::Theme(QObject *parent) Theme::Theme(const QString &themeName, QObject *parent) : QObject(parent) { - auto& priv = ThemePrivate::themes[themeName]; + auto &priv = ThemePrivate::themes[themeName]; if (!priv) { priv = new ThemePrivate; } @@ -71,8 +69,7 @@ Theme::Theme(const QString &themeName, QObject *parent) d->cacheTheme = useCache; d->fixedName = true; if (QCoreApplication::instance()) { - connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, - d, &ThemePrivate::onAppExitCleanup); + connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, d, &ThemePrivate::onAppExitCleanup); } connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged); } @@ -105,15 +102,14 @@ void Theme::setThemeName(const QString &themeName) delete ThemePrivate::themes.take(d->themeName); } - auto& priv = ThemePrivate::themes[themeName]; + auto &priv = ThemePrivate::themes[themeName]; if (!priv) { priv = new ThemePrivate; } priv->ref.ref(); d = priv; if (QCoreApplication::instance()) { - connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, - d, &ThemePrivate::onAppExitCleanup); + connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, d, &ThemePrivate::onAppExitCleanup); } connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged); } @@ -131,7 +127,7 @@ QString Theme::imagePath(const QString &name) const // look for a compressed svg file in the theme if (name.contains(QLatin1String("../")) || name.isEmpty()) { // we don't support relative paths - //qCDebug(LOG_PLASMA) << "Theme says: bad image path " << name; + // qCDebug(LOG_PLASMA) << "Theme says: bad image path " << name; return QString(); } @@ -170,7 +166,7 @@ QString Theme::imagePath(const QString &name) const return path; } -QString Theme::backgroundPath(const QString& image) const +QString Theme::backgroundPath(const QString &image) const { return d->imagePath(themeName(), QStringLiteral("/appbackgrounds/"), image); } @@ -180,7 +176,6 @@ QString Theme::styleSheet(const QString &css) const return d->processStyleSheet(css, Svg::Status::Normal); } - QPalette Theme::palette() const { return d->palette; @@ -194,7 +189,7 @@ QString Theme::wallpaperPath(const QSize &size) const if (size.isValid()) { // try to customize the paper to the size requested - //TODO: this should do better than just fallback to the default size. + // TODO: this should do better than just fallback to the default size. // a "best fit" matching would be far better, so we don't end // up returning a 1920x1200 wallpaper for a 640x480 request ;) image = image.arg(size.width()).arg(size.height()); @@ -202,7 +197,7 @@ QString Theme::wallpaperPath(const QSize &size) const image = defaultImage; } - //TODO: the theme's wallpaper overrides regularly installed wallpapers. + // TODO: the theme's wallpaper overrides regularly installed wallpapers. // should it be possible for user installed (e.g. locateLocal) wallpapers // to override the theme? if (d->hasWallpapers) { @@ -216,14 +211,14 @@ QString Theme::wallpaperPath(const QSize &size) const if (fullPath.isEmpty()) { // we failed to find it in the theme, so look in the standard directories - //qCDebug(LOG_PLASMA) << "looking for" << image; + // qCDebug(LOG_PLASMA) << "looking for" << image; fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("wallpapers/") + image); } if (fullPath.isEmpty()) { // we still failed to find it in the theme, so look for the default in // the standard directories - //qCDebug(LOG_PLASMA) << "looking for" << defaultImage; + // qCDebug(LOG_PLASMA) << "looking for" << defaultImage; fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("wallpapers/") + defaultImage); if (fullPath.isEmpty()) { @@ -248,8 +243,8 @@ bool Theme::currentThemeHasImage(const QString &name) const return false; } - return !(d->findInTheme(name % QLatin1String(".svgz"), d->themeName, false).isEmpty()) || - !(d->findInTheme(name % QLatin1String(".svg"), d->themeName, false).isEmpty()); + return !(d->findInTheme(name % QLatin1String(".svgz"), d->themeName, false).isEmpty()) + || !(d->findInTheme(name % QLatin1String(".svg"), d->themeName, false).isEmpty()); } KSharedConfigPtr Theme::colorScheme() const @@ -281,7 +276,7 @@ bool Theme::useGlobalSettings() const bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified) { - //TODO KF6: Make lastModified non-optional. + // TODO KF6: Make lastModified non-optional. if (lastModified == 0) { qCWarning(LOG_PLASMA) << "findInCache with a lastModified timestamp of 0 is deprecated"; return false; @@ -325,7 +320,7 @@ void Theme::insertIntoCache(const QString &key, const QPixmap &pix, const QStrin d->keysToCache[key] = id; d->idsToCache[id] = key; - //always start timer in d->pixmapSaveTimer's thread + // always start timer in d->pixmapSaveTimer's thread QMetaObject::invokeMethod(d->pixmapSaveTimer, "start", Qt::QueuedConnection); } } @@ -372,7 +367,6 @@ void Theme::insertIntoRectsCache(const QString &image, const QString &element, c void Theme::invalidateRectsCache(const QString &image) { - SvgRectsCache::instance()->dropImageFromCache(image); } @@ -426,7 +420,7 @@ qreal Theme::backgroundContrast() const // If we're using a dark background color, darken the background if (qGray(color(Plasma::Theme::BackgroundColor).rgb()) < 127) { return 0.45; - // for a light theme lighten up the background + // for a light theme lighten up the background } else { return 0.3; } diff --git a/src/plasma/theme.h b/src/plasma/theme.h index 0dc5d51fa..61f21d987 100644 --- a/src/plasma/theme.h +++ b/src/plasma/theme.h @@ -8,8 +8,8 @@ #ifndef PLASMA_THEME_H #define PLASMA_THEME_H -#include #include +#include #include #include @@ -21,7 +21,6 @@ class KPluginMetaData; namespace Plasma { - class ThemePrivate; class SvgPrivate; @@ -47,7 +46,7 @@ class PLASMA_EXPORT Theme : public QObject Q_PROPERTY(bool useGlobalSettings READ useGlobalSettings NOTIFY themeChanged) Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged) - //fonts + // fonts Q_PROPERTY(QFont defaultFont READ defaultFont NOTIFY defaultFontChanged) Q_PROPERTY(QFont smallestFont READ smallestFont NOTIFY smallestFontChanged) @@ -66,7 +65,7 @@ public: FocusColor = 4, /**< color for focus effect on view */ LinkColor = 5, /**< color for clickable links */ VisitedLinkColor = 6, /**< color visited clickable links */ - HighlightedTextColor = 7,/**< color contrasting with HighlightColor, to be used for instance with */ + HighlightedTextColor = 7, /**< color contrasting with HighlightColor, to be used for instance with */ PositiveTextColor = 8, /**< color of foreground objects with a "positive message" connotation (usually green) */ NeutralTextColor = 9, /**< color of foreground objects with a "neutral message" connotation (usually yellow) */ NegativeTextColor = 10, /**< color of foreground objects with a "negative message" connotation (usually red) */ @@ -476,4 +475,3 @@ private: } // Plasma namespace #endif // multiple inclusion guard - diff --git a/src/plasma/version.cpp b/src/plasma/version.cpp index e6ee75547..f6100e74d 100644 --- a/src/plasma/version.cpp +++ b/src/plasma/version.cpp @@ -4,13 +4,12 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include -#include #include "debug_p.h" +#include +#include namespace Plasma { - unsigned int version() { return PLASMA_VERSION; @@ -61,4 +60,3 @@ bool isPluginVersionCompatible(unsigned int version) } } // Plasma namespace - diff --git a/src/plasma/version.h b/src/plasma/version.h index 43c5e6e0e..c40790bf4 100644 --- a/src/plasma/version.h +++ b/src/plasma/version.h @@ -12,20 +12,19 @@ #include #include -#define PLASMA_MAKE_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c)) +#define PLASMA_MAKE_VERSION(a, b, c) (((a) << 16) | ((b) << 8) | (c)) /** * Compile-time macro for checking the plasma version. Not useful for * detecting the version of libplasma at runtime. */ -#define PLASMA_IS_VERSION(a,b,c) (PLASMA_VERSION >= PLASMA_MAKE_VERSION(a,b,c)) +#define PLASMA_IS_VERSION(a, b, c) (PLASMA_VERSION >= PLASMA_MAKE_VERSION(a, b, c)) /** * Namespace for everything in libplasma */ namespace Plasma { - /** * The runtime version of libplasma */ diff --git a/src/plasmapkg/main.cpp b/src/plasmapkg/main.cpp index 540894992..fe04418be 100644 --- a/src/plasmapkg/main.cpp +++ b/src/plasmapkg/main.cpp @@ -51,19 +51,19 @@ int main(int argc, char **argv) QStringList params = app.arguments().mid(1); - //plasmapkg2 had some hardcoded types, kpackagetool5 requires the servicetype passed as the type parameter - //convert between the two - //user passed -t typeName + // plasmapkg2 had some hardcoded types, kpackagetool5 requires the servicetype passed as the type parameter + // convert between the two + // user passed -t typeName int typeIndex = params.indexOf(QLatin1String("-t")); if (typeIndex > -1 && params.length() > typeIndex + 1) { params[typeIndex + 1] = typeFromLegacy(params.value(typeIndex + 1)); } else { - //user passed --type typeName + // user passed --type typeName typeIndex = params.indexOf(QLatin1String("--type")); if (typeIndex > -1 && params.length() > typeIndex + 1) { params[typeIndex + 1] = typeFromLegacy(params.value(typeIndex + 1)); } else { - //user passed --type=typeName + // user passed --type=typeName typeIndex = params.indexOf(QRegularExpression(QStringLiteral("--type=.*"))); if (typeIndex > -1) { params[typeIndex] = QStringLiteral("--type=") + typeFromLegacy(params.value(typeIndex).replace(QStringLiteral("--type="), QString())); @@ -78,4 +78,3 @@ int main(int argc, char **argv) return p.exitCode(); } - diff --git a/src/plasmaquick/appletquickitem.cpp b/src/plasmaquick/appletquickitem.cpp index 836d465b6..35f6ea7fa 100644 --- a/src/plasmaquick/appletquickitem.cpp +++ b/src/plasmaquick/appletquickitem.cpp @@ -5,13 +5,13 @@ */ #include "appletquickitem.h" -#include "private/appletquickitem_p.h" #include "debug_p.h" +#include "private/appletquickitem_p.h" #include +#include #include #include -#include #include #include @@ -30,22 +30,21 @@ namespace PlasmaQuick { - QHash AppletQuickItemPrivate::s_rootObjects = QHash(); AppletQuickItemPrivate::PreloadPolicy AppletQuickItemPrivate::s_preloadPolicy = AppletQuickItemPrivate::Uninitialized; AppletQuickItemPrivate::AppletQuickItemPrivate(Plasma::Applet *a, AppletQuickItem *item) - : q(item), - switchWidth(-1), - switchHeight(-1), - applet(a), - expanded(false), - activationTogglesExpanded(true), - initComplete(false) + : q(item) + , switchWidth(-1) + , switchHeight(-1) + , applet(a) + , expanded(false) + , activationTogglesExpanded(true) + , initComplete(false) { if (s_preloadPolicy == Uninitialized) { - //default as Adaptive + // default as Adaptive s_preloadPolicy = Adaptive; if (qEnvironmentVariableIsSet("PLASMA_PRELOAD_POLICY")) { @@ -82,43 +81,44 @@ int AppletQuickItemPrivate::preloadWeight() const int defaultWeight; const QStringList provides(KPluginMetaData::readStringList(applet->pluginMetaData().rawData(), QStringLiteral("X-Plasma-Provides"))); - //some applet types we want a bigger weight + // some applet types we want a bigger weight if (provides.contains(QLatin1String("org.kde.plasma.launchermenu"))) { defaultWeight = DefaultLauncherPreloadWeight; } else { defaultWeight = DefaultPreloadWeight; } - //default widgets to be barely preloaded - return qBound(0, applet->config().readEntry(QStringLiteral("PreloadWeight"), qMax(defaultWeight, applet->pluginMetaData().rawData().value(QStringLiteral("X-Plasma-PreloadWeight")).toInt())), 100); + // default widgets to be barely preloaded + return qBound(0, + applet->config().readEntry(QStringLiteral("PreloadWeight"), + qMax(defaultWeight, applet->pluginMetaData().rawData().value(QStringLiteral("X-Plasma-PreloadWeight")).toInt())), + 100); } void AppletQuickItemPrivate::connectLayoutAttached(QObject *item) { QObject *layout = nullptr; - //Extract the representation's Layout, if any - //No Item? + // Extract the representation's Layout, if any + // No Item? if (!item) { return; } - //Search a child that has the needed Layout properties - //HACK: here we are not type safe, but is the only way to access to a pointer of Layout + // Search a child that has the needed Layout properties + // HACK: here we are not type safe, but is the only way to access to a pointer of Layout const auto lstChildren = item->children(); for (QObject *child : lstChildren) { - //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight - if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { + // find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight + if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && child->property("preferredWidth").isValid() + && child->property("preferredHeight").isValid() && child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() + && child->property("fillWidth").isValid() && child->property("fillHeight").isValid()) { layout = child; break; } } - //if the compact repr doesn't export a Layout.* attached property, - //reset our own with default values + // if the compact repr doesn't export a Layout.* attached property, + // reset our own with default values if (!layout) { if (ownLayout) { ownLayout->setProperty("minimumWidth", 0); @@ -133,7 +133,7 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item) return; } - //propagate all the size hints + // propagate all the size hints propagateSizeHint("minimumWidth"); propagateSizeHint("minimumHeight"); propagateSizeHint("preferredWidth"); @@ -143,28 +143,25 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item) propagateSizeHint("fillWidth"); propagateSizeHint("fillHeight"); - QObject *ownLayout = nullptr; const auto children = q->children(); for (QObject *child : children) { - //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight - if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { + // find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight + if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && child->property("preferredWidth").isValid() + && child->property("preferredHeight").isValid() && child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() + && child->property("fillWidth").isValid() && child->property("fillHeight").isValid()) { ownLayout = child; break; } } - //this should never happen, since we ask to create it if doesn't exists + // this should never happen, since we ask to create it if doesn't exists if (!ownLayout) { return; } - //if the representation didn't change, don't do anything + // if the representation didn't change, don't do anything if (representationLayout == layout) { return; } @@ -173,26 +170,18 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item) QObject::disconnect(representationLayout, nullptr, q, nullptr); } - //Here we can't use the new connect syntax because we can't link against QtQuick layouts - QObject::connect(layout, SIGNAL(minimumWidthChanged()), - q, SLOT(minimumWidthChanged())); - QObject::connect(layout, SIGNAL(minimumHeightChanged()), - q, SLOT(minimumHeightChanged())); + // Here we can't use the new connect syntax because we can't link against QtQuick layouts + QObject::connect(layout, SIGNAL(minimumWidthChanged()), q, SLOT(minimumWidthChanged())); + QObject::connect(layout, SIGNAL(minimumHeightChanged()), q, SLOT(minimumHeightChanged())); - QObject::connect(layout, SIGNAL(preferredWidthChanged()), - q, SLOT(preferredWidthChanged())); - QObject::connect(layout, SIGNAL(preferredHeightChanged()), - q, SLOT(preferredHeightChanged())); + QObject::connect(layout, SIGNAL(preferredWidthChanged()), q, SLOT(preferredWidthChanged())); + QObject::connect(layout, SIGNAL(preferredHeightChanged()), q, SLOT(preferredHeightChanged())); - QObject::connect(layout, SIGNAL(maximumWidthChanged()), - q, SLOT(maximumWidthChanged())); - QObject::connect(layout, SIGNAL(maximumHeightChanged()), - q, SLOT(maximumHeightChanged())); + QObject::connect(layout, SIGNAL(maximumWidthChanged()), q, SLOT(maximumWidthChanged())); + QObject::connect(layout, SIGNAL(maximumHeightChanged()), q, SLOT(maximumHeightChanged())); - QObject::connect(layout, SIGNAL(fillWidthChanged()), - q, SLOT(fillWidthChanged())); - QObject::connect(layout, SIGNAL(fillHeightChanged()), - q, SLOT(fillHeightChanged())); + QObject::connect(layout, SIGNAL(fillWidthChanged()), q, SLOT(fillWidthChanged())); + QObject::connect(layout, SIGNAL(fillHeightChanged()), q, SLOT(fillHeightChanged())); representationLayout = layout; AppletQuickItemPrivate::ownLayout = ownLayout; @@ -227,7 +216,8 @@ QQuickItem *AppletQuickItemPrivate::createCompactRepresentationItem() QVariantHash initialProperties; initialProperties[QStringLiteral("parent")] = QVariant::fromValue(q); - compactRepresentationItem = qobject_cast(qmlObject->createObjectFromComponent(compactRepresentation, QtQml::qmlContext(qmlObject->rootObject()), initialProperties)); + compactRepresentationItem = + qobject_cast(qmlObject->createObjectFromComponent(compactRepresentation, QtQml::qmlContext(qmlObject->rootObject()), initialProperties)); Q_EMIT q->compactRepresentationItemChanged(compactRepresentationItem); @@ -243,10 +233,11 @@ QQuickItem *AppletQuickItemPrivate::createFullRepresentationItem() if (fullRepresentation && fullRepresentation != qmlObject->mainComponent()) { QVariantHash initialProperties; initialProperties[QStringLiteral("parent")] = QVariant(); - fullRepresentationItem = qobject_cast(qmlObject->createObjectFromComponent(fullRepresentation, QtQml::qmlContext(qmlObject->rootObject()), initialProperties)); + fullRepresentationItem = + qobject_cast(qmlObject->createObjectFromComponent(fullRepresentation, QtQml::qmlContext(qmlObject->rootObject()), initialProperties)); } else { fullRepresentation = qmlObject->mainComponent(); - fullRepresentationItem = qobject_cast(qmlObject->rootObject()); + fullRepresentationItem = qobject_cast(qmlObject->rootObject()); Q_EMIT q->fullRepresentationChanged(fullRepresentation); } @@ -269,13 +260,14 @@ QQuickItem *AppletQuickItemPrivate::createCompactRepresentationExpanderItem() return compactRepresentationExpanderItem; } - compactRepresentationExpanderItem = qobject_cast(qmlObject->createObjectFromComponent(compactRepresentationExpander, QtQml::qmlContext(qmlObject->rootObject()))); + compactRepresentationExpanderItem = + qobject_cast(qmlObject->createObjectFromComponent(compactRepresentationExpander, QtQml::qmlContext(qmlObject->rootObject()))); if (!compactRepresentationExpanderItem) { return nullptr; } - compactRepresentationExpanderItem->setProperty("compactRepresentation", QVariant::fromValue(createCompactRepresentationItem())); + compactRepresentationExpanderItem->setProperty("compactRepresentation", QVariant::fromValue(createCompactRepresentationItem())); return compactRepresentationExpanderItem; } @@ -289,12 +281,12 @@ bool AppletQuickItemPrivate::appletShouldBeExpanded() const if (switchWidth > 0 && switchHeight > 0) { return q->width() > switchWidth && q->height() > switchHeight; - //if a size to switch wasn't set, determine what representation to always chose + // if a size to switch wasn't set, determine what representation to always chose } else { - //preferred representation set? + // preferred representation set? if (preferredRepresentation) { return preferredRepresentation == fullRepresentation; - //Otherwise, base on FormFactor + // Otherwise, base on FormFactor } else { return (applet->formFactor() != Plasma::Types::Horizontal && applet->formFactor() != Plasma::Types::Vertical); } @@ -311,24 +303,22 @@ void AppletQuickItemPrivate::preloadForExpansion() createFullRepresentationItem(); // When not already expanded, also preload the expander - if (!expanded && !applet->isContainment() && - (!preferredRepresentation || - preferredRepresentation != fullRepresentation)) { + if (!expanded && !applet->isContainment() && (!preferredRepresentation || preferredRepresentation != fullRepresentation)) { createCompactRepresentationExpanderItem(); } if (!appletShouldBeExpanded() && compactRepresentationExpanderItem) { - compactRepresentationExpanderItem->setProperty("fullRepresentation", QVariant::fromValue(createFullRepresentationItem())); + compactRepresentationExpanderItem->setProperty("fullRepresentation", QVariant::fromValue(createFullRepresentationItem())); } else if (fullRepresentationItem) { - fullRepresentationItem->setProperty("parent", QVariant::fromValue(q)); + fullRepresentationItem->setProperty("parent", QVariant::fromValue(q)); } - //preallocate nodes + // preallocate nodes if (fullRepresentationItem && fullRepresentationItem->window()) { fullRepresentationItem->window()->create(); } - qCDebug(LOG_PLASMAQUICK) << "Applet" << applet->title() << "loaded after" << ( QDateTime::currentMSecsSinceEpoch() - time) << "msec"; + qCDebug(LOG_PLASMAQUICK) << "Applet" << applet->title() << "loaded after" << (QDateTime::currentMSecsSinceEpoch() - time) << "msec"; } void AppletQuickItemPrivate::compactRepresentationCheck() @@ -341,26 +331,24 @@ void AppletQuickItemPrivate::compactRepresentationCheck() return; } - //ignore 0 sizes; + // ignore 0 sizes; if (q->width() <= 0 || q->height() <= 0) { return; } bool full = appletShouldBeExpanded(); - if ((full && fullRepresentationItem && fullRepresentationItem == currentRepresentationItem) || - (!full && compactRepresentationItem && compactRepresentationItem == currentRepresentationItem) - ) { + if ((full && fullRepresentationItem && fullRepresentationItem == currentRepresentationItem) + || (!full && compactRepresentationItem && compactRepresentationItem == currentRepresentationItem)) { return; } - - //Expanded + // Expanded if (full) { QQuickItem *item = createFullRepresentationItem(); if (item) { - //unwire with the expander + // unwire with the expander if (compactRepresentationExpanderItem) { compactRepresentationExpanderItem->setProperty("fullRepresentation", QVariant()); compactRepresentationExpanderItem->setProperty("compactRepresentation", QVariant()); @@ -369,7 +357,7 @@ void AppletQuickItemPrivate::compactRepresentationCheck() item->setParentItem(q); { - //set anchors + // set anchors QQmlExpression expr(QtQml::qmlContext(qmlObject->rootObject()), item, QStringLiteral("parent")); QQmlProperty prop(item, QStringLiteral("anchors.fill")); prop.write(expr.evaluate()); @@ -385,18 +373,18 @@ void AppletQuickItemPrivate::compactRepresentationCheck() Q_EMIT q->expandedChanged(true); } - //Icon + // Icon } else { QQuickItem *compactItem = createCompactRepresentationItem(); QQuickItem *compactExpanderItem = createCompactRepresentationExpanderItem(); if (compactItem && compactExpanderItem) { - //set the root item as the main visible item + // set the root item as the main visible item compactItem->setVisible(true); compactExpanderItem->setParentItem(q); compactExpanderItem->setVisible(true); { - //set anchors + // set anchors QQmlExpression expr(QtQml::qmlContext(qmlObject->rootObject()), compactExpanderItem, QStringLiteral("parent")); QQmlProperty prop(compactExpanderItem, QStringLiteral("anchors.fill")); prop.write(expr.evaluate()); @@ -406,8 +394,8 @@ void AppletQuickItemPrivate::compactRepresentationCheck() fullRepresentationItem->setProperty("parent", QVariant()); } - compactExpanderItem->setProperty("compactRepresentation", QVariant::fromValue(compactItem)); - //The actual full representation will be connected when created + compactExpanderItem->setProperty("compactRepresentation", QVariant::fromValue(compactItem)); + // The actual full representation will be connected when created compactExpanderItem->setProperty("fullRepresentation", QVariant()); currentRepresentationItem = compactItem; @@ -459,12 +447,9 @@ void AppletQuickItemPrivate::fillHeightChanged() propagateSizeHint("fillHeight"); } - - - AppletQuickItem::AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent) - : QQuickItem(parent), - d(new AppletQuickItemPrivate(applet, this)) + : QQuickItem(parent) + , d(new AppletQuickItemPrivate(applet, this)) { d->init(); @@ -499,12 +484,12 @@ AppletQuickItem::AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent) AppletQuickItem::~AppletQuickItem() { - //decrease weight + // decrease weight if (d->s_preloadPolicy >= AppletQuickItemPrivate::Adaptive) { d->applet->config().writeEntry(QStringLiteral("PreloadWeight"), qMax(0, d->preloadWeight() - AppletQuickItemPrivate::PreloadWeightDecrement)); } - //Here the order is important + // Here the order is important delete d->compactRepresentationItem; delete d->fullRepresentationItem; delete d->compactRepresentationExpanderItem; @@ -517,24 +502,24 @@ AppletQuickItem::~AppletQuickItem() AppletQuickItem *AppletQuickItem::qmlAttachedProperties(QObject *object) { QQmlContext *context; - //is it using shared engine mode? + // is it using shared engine mode? if (!QtQml::qmlEngine(object)->parent()) { context = QtQml::qmlContext(object); - //search the root context of the applet in which the object is in + // search the root context of the applet in which the object is in while (context) { - //the rootcontext of an applet is a child of the engine root context + // the rootcontext of an applet is a child of the engine root context if (context->parentContext() == QtQml::qmlEngine(object)->rootContext()) { break; } context = context->parentContext(); } - //otherwise index by root context + // otherwise index by root context } else { context = QtQml::qmlEngine(object)->rootContext(); } - //at the moment of the attached object creation, the root item is the only one that hasn't a parent - //only way to avoid creation of this attached for everybody but the root item + // at the moment of the attached object creation, the root item is the only one that hasn't a parent + // only way to avoid creation of this attached for everybody but the root item if (!object->parent() && AppletQuickItemPrivate::s_rootObjects.contains(context)) { return AppletQuickItemPrivate::s_rootObjects.value(context); } else { @@ -549,7 +534,7 @@ Plasma::Applet *AppletQuickItem::applet() const void AppletQuickItem::init() { - //FIXME: Plasmoid attached property should be fixed since can't be indexed by engine anymore + // FIXME: Plasmoid attached property should be fixed since can't be indexed by engine anymore if (AppletQuickItemPrivate::s_rootObjects.contains(d->qmlObject->rootContext())) { return; } @@ -558,21 +543,21 @@ void AppletQuickItem::init() Q_ASSERT(d->applet); - //Initialize the main QML file + // Initialize the main QML file QQmlEngine *engine = d->qmlObject->engine(); - //if the engine of the qmlObject is different from the static one, then we - //are using an old version of the api in which every applet had one engine - //so initialize a private url interceptor + // if the engine of the qmlObject is different from the static one, then we + // are using an old version of the api in which every applet had one engine + // so initialize a private url interceptor if (d->applet->kPackage().isValid() && !qobject_cast(d->qmlObject)) { PackageUrlInterceptor *interceptor = new PackageUrlInterceptor(engine, d->applet->kPackage()); interceptor->addAllowedPath(d->coronaPackage.path()); engine->setUrlInterceptor(interceptor); } - //Force QtQuickControls to use the "Plasma" style for this engine. - //this way is possible to mix QtQuickControls and plasma components in applets - //while still having the desktop style in configuration dialogs + // Force QtQuickControls to use the "Plasma" style for this engine. + // this way is possible to mix QtQuickControls and plasma components in applets + // while still having the desktop style in configuration dialogs if (!engine->property("_plasma_qqc_style_set").toBool()) { QQmlComponent c(engine); c.setData(QByteArrayLiteral("import QtQuick 2.1\n\ @@ -582,7 +567,8 @@ void AppletQuickItem::init() Component.onCompleted: {\ Settings.styleName = \"Plasma\";\ }\ - }"), QUrl()); + }"), + QUrl()); QObject *o = c.create(); o->deleteLater(); engine->setProperty(("_plasma_qqc_style_set"), true); @@ -590,7 +576,8 @@ void AppletQuickItem::init() d->qmlObject->setSource(d->applet->kPackage().fileUrl("mainscript")); - if (!engine || !engine->rootContext() || !engine->rootContext()->isValid() || !d->qmlObject->mainComponent() || d->qmlObject->mainComponent()->isError() || d->applet->failedToLaunch()) { + if (!engine || !engine->rootContext() || !engine->rootContext()->isValid() || !d->qmlObject->mainComponent() || d->qmlObject->mainComponent()->isError() + || d->applet->failedToLaunch()) { QString reason; QJsonObject errorData; errorData[QStringLiteral("appletName")] = i18n("Unknown Applet"); @@ -620,7 +607,7 @@ void AppletQuickItem::init() d->qmlObject->setSource(d->coronaPackage.fileUrl("appleterror")); d->qmlObject->completeInitialization(); - //even the error message QML may fail + // even the error message QML may fail if (d->qmlObject->mainComponent()->isError()) { return; } else { @@ -634,9 +621,9 @@ void AppletQuickItem::init() d->qmlObject->rootContext()->setContextProperty(QStringLiteral("plasmoid"), this); - //initialize size, so an useless resize less + // initialize size, so an useless resize less QVariantHash initialProperties; - //initialize with our size only if valid + // initialize with our size only if valid if (width() > 0 && height() > 0) { const qreal w = parentItem() ? std::min(parentItem()->width(), width()) : width(); const qreal h = parentItem() ? std::min(parentItem()->height(), height()) : height(); @@ -646,29 +633,29 @@ void AppletQuickItem::init() d->qmlObject->setInitializationDelayed(false); d->qmlObject->completeInitialization(initialProperties); - //otherwise, initialize our size to root object's size + // otherwise, initialize our size to root object's size if (d->qmlObject->rootObject() && (width() <= 0 || height() <= 0)) { const qreal w = d->qmlObject->rootObject()->property("width").value(); const qreal h = d->qmlObject->rootObject()->property("height").value(); setSize(parentItem() ? QSizeF(std::min(parentItem()->width(), w), std::min(parentItem()->height(), h)) : QSizeF(w, h)); } - //default fullrepresentation is our root main component, if none specified + // default fullrepresentation is our root main component, if none specified if (!d->fullRepresentation) { d->fullRepresentation = d->qmlObject->mainComponent(); - d->fullRepresentationItem = qobject_cast(d->qmlObject->rootObject()); + d->fullRepresentationItem = qobject_cast(d->qmlObject->rootObject()); Q_EMIT fullRepresentationChanged(d->fullRepresentation); } - //default compactRepresentation is a simple icon provided by the shell package + // default compactRepresentation is a simple icon provided by the shell package if (!d->compactRepresentation) { d->compactRepresentation = new QQmlComponent(engine, this); d->compactRepresentation->loadUrl(d->coronaPackage.fileUrl("defaultcompactrepresentation")); Q_EMIT compactRepresentationChanged(d->compactRepresentation); } - //default compactRepresentationExpander is the popup in which fullRepresentation goes + // default compactRepresentationExpander is the popup in which fullRepresentation goes if (!d->compactRepresentationExpander) { d->compactRepresentationExpander = new QQmlComponent(engine, this); QUrl compactExpanderUrl = d->containmentPackage.fileUrl("compactapplet"); @@ -685,40 +672,37 @@ void AppletQuickItem::init() qmlObject()->engine()->rootContext()->setBaseUrl(qmlObject()->source()); qmlObject()->engine()->setContextForObject(this, qmlObject()->engine()->rootContext()); - //if we're expanded we don't care about preloading because it will already be the case - //as well as for containments - if (d->applet->isContainment() || - d->expanded || d->preferredRepresentation == d->fullRepresentation) { + // if we're expanded we don't care about preloading because it will already be the case + // as well as for containments + if (d->applet->isContainment() || d->expanded || d->preferredRepresentation == d->fullRepresentation) { return; } if (!d->applet->isContainment() && d->applet->containment()) { - connect(d->applet->containment(), &Plasma::Containment::uiReadyChanged, - this, [this](bool uiReady) { - if (uiReady && d->s_preloadPolicy >= AppletQuickItemPrivate::Adaptive) { - const int preloadWeight = d->preloadWeight(); - qCDebug(LOG_PLASMAQUICK) << "New Applet " << d->applet->title() << "with a weight of" << preloadWeight; + connect(d->applet->containment(), &Plasma::Containment::uiReadyChanged, this, [this](bool uiReady) { + if (uiReady && d->s_preloadPolicy >= AppletQuickItemPrivate::Adaptive) { + const int preloadWeight = d->preloadWeight(); + qCDebug(LOG_PLASMAQUICK) << "New Applet " << d->applet->title() << "with a weight of" << preloadWeight; - //don't preload applets less then a certain weight - if (d->s_preloadPolicy >= AppletQuickItemPrivate::Aggressive || preloadWeight >= AppletQuickItemPrivate::DelayedPreloadWeight) { - //spread the creation over a random delay to make it look - //plasma started already, and load the popup in the background - //without big noticeable freezes, the bigger the weight the smaller is likely - //to be the delay, smaller minimum walue, smaller spread - const int min = (100 - preloadWeight) * 20; - const int max = (100 - preloadWeight) * 100; - const int delay = QRandomGenerator::global()->bounded((max + 1) - min) + min; - QTimer::singleShot(delay, this, [this, delay]() { - qCDebug(LOG_PLASMAQUICK) << "Delayed preload of " << d->applet->title() << "after" << (qreal)delay/1000 << "seconds"; - d->preloadForExpansion(); - }); - } + // don't preload applets less then a certain weight + if (d->s_preloadPolicy >= AppletQuickItemPrivate::Aggressive || preloadWeight >= AppletQuickItemPrivate::DelayedPreloadWeight) { + // spread the creation over a random delay to make it look + // plasma started already, and load the popup in the background + // without big noticeable freezes, the bigger the weight the smaller is likely + // to be the delay, smaller minimum walue, smaller spread + const int min = (100 - preloadWeight) * 20; + const int max = (100 - preloadWeight) * 100; + const int delay = QRandomGenerator::global()->bounded((max + 1) - min) + min; + QTimer::singleShot(delay, this, [this, delay]() { + qCDebug(LOG_PLASMAQUICK) << "Delayed preload of " << d->applet->title() << "after" << (qreal)delay / 1000 << "seconds"; + d->preloadForExpansion(); + }); } - }); + } + }); } } - Plasma::Package AppletQuickItem::appletPackage() const { return Plasma::Package(d->appletPackage); @@ -801,7 +785,7 @@ QObject *AppletQuickItem::testItem() d->testItem = d->qmlObject->createObjectFromSource(url, QtQml::qmlContext(rootItem())); if (d->testItem) { - d->testItem->setProperty("plasmoidItem", QVariant::fromValue(this)); + d->testItem->setProperty("plasmoidItem", QVariant::fromValue(this)); } } @@ -847,7 +831,7 @@ void AppletQuickItem::setExpanded(bool expanded) if (expanded) { d->preloadForExpansion(); - //increase on open, ignore containments + // increase on open, ignore containments if (d->s_preloadPolicy >= AppletQuickItemPrivate::Adaptive && !d->applet->isContainment()) { const int newWeight = qMin(d->preloadWeight() + AppletQuickItemPrivate::PreloadWeightIncrement, 100); d->applet->config().writeEntry(QStringLiteral("PreloadWeight"), newWeight); @@ -921,7 +905,7 @@ void AppletQuickItem::geometryChanged(const QRectF &newGeometry, const QRectF &o void AppletQuickItem::itemChange(ItemChange change, const ItemChangeData &value) { if (change == QQuickItem::ItemSceneChange) { - //we have a window: create the representations if needed + // we have a window: create the representations if needed if (value.window) { init(); } @@ -933,4 +917,3 @@ void AppletQuickItem::itemChange(ItemChange change, const ItemChangeData &value) } #include "moc_appletquickitem.cpp" - diff --git a/src/plasmaquick/appletquickitem.h b/src/plasmaquick/appletquickitem.h index 2a7a7e196..592f59286 100644 --- a/src/plasmaquick/appletquickitem.h +++ b/src/plasmaquick/appletquickitem.h @@ -7,9 +7,9 @@ #ifndef APPLETQUICKITEM_H #define APPLETQUICKITEM_H -#include #include #include +#include #include #include @@ -39,7 +39,6 @@ class QmlObject; namespace PlasmaQuick { - class AppletQuickItemPrivate; class PLASMAQUICK_EXPORT AppletQuickItem : public QQuickItem @@ -82,10 +81,10 @@ public: AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent = nullptr); ~AppletQuickItem() override; -////API NOT SUPPOSED TO BE USED BY QML + ////API NOT SUPPOSED TO BE USED BY QML Plasma::Applet *applet() const; - //Make the constructor lighter and delay the actual instantiation of the qml in the applet + // Make the constructor lighter and delay the actual instantiation of the qml in the applet virtual void init(); #if PLASMAQUICK_ENABLE_DEPRECATED_SINCE(5, 36) @@ -105,7 +104,7 @@ public: QObject *rootItem(); QObject *testItem(); -////PROPERTY ACCESSORS + ////PROPERTY ACCESSORS int switchWidth() const; void setSwitchWidth(int width); @@ -127,11 +126,11 @@ public: bool isActivationTogglesExpanded() const; void setActivationTogglesExpanded(bool activationTogglesExpanded); -////NEEDED BY QML TO CREATE ATTACHED PROPERTIES + ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES static AppletQuickItem *qmlAttachedProperties(QObject *object); Q_SIGNALS: -//Property signals + // Property signals void switchWidthChanged(int width); void switchHeightChanged(int height); @@ -148,7 +147,7 @@ Q_SIGNALS: protected: KDeclarative::QmlObject *qmlObject(); - //Reimplementation + // Reimplementation void childEvent(QChildEvent *event) override; void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void itemChange(ItemChange change, const ItemChangeData &value) override; diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index 686f98b00..c9528e1a9 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -5,31 +5,30 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include "private/configcategory_p.h" -#include "configview.h" #include "configmodel.h" #include "Plasma/Applet" #include "Plasma/Containment" +#include "configview.h" +#include "private/configcategory_p.h" //#include "plasmoid/wallpaperinterface.h" #include "kdeclarative/configpropertymap.h" #include #include #include -#include #include +#include #include #include -#include #include +#include #include #include namespace PlasmaQuick { - //////////////////////////////ConfigModel class ConfigModelPrivate @@ -69,7 +68,7 @@ ConfigCategory *ConfigModelPrivate::categories_at(QQmlListProperty(prop->object); if (!model || index >= model->d->categories.count() || index < 0) { return nullptr; - } else { + } else { return model->d->categories.at(index); } } @@ -190,10 +189,9 @@ QVariant ConfigModelPrivate::get(int row) const } ConfigModel::ConfigModel(QObject *parent) - : QAbstractListModel(parent), - d(new ConfigModelPrivate(this)) + : QAbstractListModel(parent) + , d(new ConfigModelPrivate(this)) { - } ConfigModel::~ConfigModel() @@ -219,12 +217,11 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const return d->categories.at(index.row())->name(); case IconRole: return d->categories.at(index.row())->icon(); - case SourceRole: - { + case SourceRole: { const QString source = d->categories.at(index.row())->source(); // Quick check if source is an absolute path or not if (d->appletInterface && !source.isEmpty() && !(source.startsWith(QLatin1Char('/')) && source.endsWith(QLatin1String("qml")))) { - if(!d->appletInterface.data()->kPackage().isValid()) + if (!d->appletInterface.data()->kPackage().isValid()) qWarning() << "wrong applet" << d->appletInterface.data()->pluginMetaData().name(); return d->appletInterface.data()->kPackage().fileUrl("ui", source); } else { @@ -238,7 +235,7 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const case KCMRole: { const QString pluginName = d->categories.at(index.row())->pluginName(); const QString pluginPath = KPluginLoader::findPlugin(pluginName); - //no kcm is registered for this row, it's a normal qml-only entry + // no kcm is registered for this row, it's a normal qml-only entry if (pluginName.isEmpty() || pluginPath.isEmpty()) { return QVariant(); } @@ -248,11 +245,11 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const } KPluginLoader loader(pluginPath); - KPluginFactory* factory = loader.factory(); + KPluginFactory *factory = loader.factory(); if (!factory) { qWarning() << "Error loading KCM:" << loader.errorString(); } else { - KQuickAddons::ConfigModule *cm = factory->create(const_cast(this)); + KQuickAddons::ConfigModule *cm = factory->create(const_cast(this)); if (!cm) { qWarning() << "Error creating KCM object from plugin" << loader.fileName(); } @@ -289,8 +286,7 @@ QVariant ConfigModel::get(int row) const return d->get(row); } -void ConfigModel::appendCategory(const QString &iconName, const QString &name, - const QString &path, const QString &pluginName) +void ConfigModel::appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName) { ConfigCategory *cat = new ConfigCategory(this); cat->setIcon(iconName); @@ -300,8 +296,7 @@ void ConfigModel::appendCategory(const QString &iconName, const QString &name, d->appendCategory(cat); } -void ConfigModel::appendCategory(const QString &iconName, const QString &name, - const QString &path, const QString &pluginName, bool visible) +void ConfigModel::appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName, bool visible) { ConfigCategory *cat = new ConfigCategory(this); cat->setIcon(iconName); @@ -344,11 +339,12 @@ Plasma::Applet *ConfigModel::applet() const QQmlListProperty ConfigModel::categories() { - return QQmlListProperty(this, nullptr, ConfigModelPrivate::categories_append, + return QQmlListProperty(this, + nullptr, + ConfigModelPrivate::categories_append, ConfigModelPrivate::categories_count, ConfigModelPrivate::categories_at, ConfigModelPrivate::categories_clear); - } } diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index 29602d116..261ecb79f 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -8,8 +8,8 @@ #ifndef CONFIGMODEL_H #define CONFIGMODEL_H -#include #include +#include #include @@ -31,7 +31,6 @@ class Applet; namespace PlasmaQuick { - class ConfigPropertyMap; class ConfigCategoryPrivate; @@ -67,11 +66,9 @@ public: * add a new category in the model * @param ConfigCategory the new category **/ - void appendCategory(const QString &iconName, const QString &name, - const QString &path, const QString &pluginName); + void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName); - Q_INVOKABLE void appendCategory(const QString &iconName, const QString &name, - const QString &path, const QString &pluginName, bool visible); + Q_INVOKABLE void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName, bool visible); // QML Engine isn't particularly smart resolving namespaces, hence fully qualified signature Q_INVOKABLE void appendCategory(PlasmaQuick::ConfigCategory *category); diff --git a/src/plasmaquick/configview.cpp b/src/plasmaquick/configview.cpp index 00bfd7d35..34ec13829 100644 --- a/src/plasmaquick/configview.cpp +++ b/src/plasmaquick/configview.cpp @@ -4,37 +4,36 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include "private/configcategory_p.h" #include "configview.h" -#include "configmodel.h" #include "Plasma/Applet" #include "Plasma/Containment" +#include "configmodel.h" +#include "private/configcategory_p.h" //#include "plasmoid/wallpaperinterface.h" #include "kdeclarative/configpropertymap.h" #include #include #include -#include #include +#include #include #include -#include #include +#include +#include #include #include -#include #include #include -//Unfortunately QWINDOWSIZE_MAX is not exported -#define DIALOGSIZE_MAX ((1<<24)-1) +// Unfortunately QWINDOWSIZE_MAX is not exported +#define DIALOGSIZE_MAX ((1 << 24) - 1) namespace PlasmaQuick { - //////////////////////////////ConfigView class ConfigViewPrivate @@ -52,19 +51,19 @@ public: void mainItemLoaded(); ConfigView *q; - QPointer applet; + QPointer applet; ConfigModel *configModel; ConfigModel *kcmConfigModel; Plasma::Corona *corona; - //Attached Layout property of mainItem, if any - QPointer mainItemLayout; + // Attached Layout property of mainItem, if any + QPointer mainItemLayout; }; ConfigViewPrivate::ConfigViewPrivate(Plasma::Applet *appl, ConfigView *view) - : q(view), - applet(appl), - corona(nullptr) + : q(view) + , applet(appl) + , corona(nullptr) { } @@ -92,11 +91,11 @@ void ConfigViewPrivate::init() KDeclarative::KDeclarative::setupEngine(q->engine()); // ### how to make sure to do this only once per engine? - //FIXME: problem on nvidia, all windows should be transparent or won't show + // FIXME: problem on nvidia, all windows should be transparent or won't show q->setColor(Qt::transparent); q->setTitle(i18n("%1 Settings", applet.data()->title())); - //systray case + // systray case if (!applet.data()->containment()->corona()) { Plasma::Applet *a = qobject_cast(applet.data()->containment()->parent()); if (a) { @@ -124,9 +123,9 @@ void ConfigViewPrivate::init() auto plasmoid = applet.data()->property("_plasma_graphicObject").value(); q->engine()->rootContext()->setContextProperties({QQmlContext::PropertyPair{QStringLiteral("plasmoid"), QVariant::fromValue(plasmoid)}, - QQmlContext::PropertyPair{QStringLiteral("configDialog"), QVariant::fromValue(q)}}); + QQmlContext::PropertyPair{QStringLiteral("configDialog"), QVariant::fromValue(q)}}); - //config model local of the applet + // config model local of the applet QQmlComponent *component = new QQmlComponent(q->engine(), applet.data()->kPackage().fileUrl("configmodel"), q); QObject *object = component->create(q->engine()->rootContext()); configModel = qobject_cast(object); @@ -142,9 +141,12 @@ void ConfigViewPrivate::init() // filter out non-authorized KCMs // KAuthorized expects KCMs with .desktop suffix, so we can't just pass everything // to KAuthorized::authorizeControlModules verbatim - kcms.erase(std::remove_if(kcms.begin(), kcms.end(), [](const QString &kcm) { - return !KAuthorized::authorizeControlModule(kcm + QLatin1String(".desktop")); - }), kcms.end()); + kcms.erase(std::remove_if(kcms.begin(), + kcms.end(), + [](const QString &kcm) { + return !KAuthorized::authorizeControlModule(kcm + QLatin1String(".desktop")); + }), + kcms.end()); if (!kcms.isEmpty()) { if (!configModel) { @@ -158,7 +160,8 @@ void ConfigViewPrivate::init() KPluginMetaData md(loader.fileName()); if (!md.isValid()) { - qWarning() << "Could not find" << kcm << "requested by X-Plasma-ConfigPlugins. Ensure that it exists, is a QML KCM, and lives in the 'kcms/' subdirectory."; + qWarning() << "Could not find" << kcm + << "requested by X-Plasma-ConfigPlugins. Ensure that it exists, is a QML KCM, and lives in the 'kcms/' subdirectory."; continue; } @@ -173,7 +176,7 @@ void ConfigViewPrivate::updateMinimumWidth() { if (mainItemLayout) { q->setMinimumWidth(mainItemLayout.data()->property("minimumWidth").toInt()); - //Sometimes setMinimumWidth doesn't actually resize: Qt bug? + // Sometimes setMinimumWidth doesn't actually resize: Qt bug? q->setWidth(qMax(q->width(), q->minimumWidth())); } else { @@ -185,7 +188,7 @@ void ConfigViewPrivate::updateMinimumHeight() { if (mainItemLayout) { q->setMinimumHeight(mainItemLayout.data()->property("minimumHeight").toInt()); - //Sometimes setMinimumHeight doesn't actually resize: Qt bug? + // Sometimes setMinimumHeight doesn't actually resize: Qt bug? q->setHeight(qMax(q->height(), q->minimumHeight())); } else { @@ -231,19 +234,17 @@ void ConfigViewPrivate::mainItemLoaded() q->resize(cg.readEntry("DialogWidth", q->width()), cg.readEntry("DialogHeight", q->height())); } - //Extract the representation's Layout, if any + // Extract the representation's Layout, if any QObject *layout = nullptr; - //Search a child that has the needed Layout properties - //HACK: here we are not type safe, but is the only way to access to a pointer of Layout + // Search a child that has the needed Layout properties + // HACK: here we are not type safe, but is the only way to access to a pointer of Layout const auto children = q->rootObject()->children(); for (QObject *child : children) { - //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight - if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { + // find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight + if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && child->property("preferredWidth").isValid() + && child->property("preferredHeight").isValid() && child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() + && child->property("fillWidth").isValid() && child->property("fillHeight").isValid()) { layout = child; break; } @@ -263,10 +264,9 @@ void ConfigViewPrivate::mainItemLoaded() } } - ConfigView::ConfigView(Plasma::Applet *applet, QWindow *parent) - : QQuickView(parent), - d(new ConfigViewPrivate(applet, this)) + : QQuickView(parent) + , d(new ConfigViewPrivate(applet, this)) { setIcon(QIcon::fromTheme(QStringLiteral("configure"))); qmlRegisterType("org.kde.plasma.configuration", 2, 0, "ConfigModel"); @@ -324,7 +324,7 @@ void ConfigView::setAppletGlobalShortcut(const QString &shortcut) Q_EMIT appletGlobalShortcutChanged(); } -//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have +// To emulate Qt::WA_DeleteOnClose that QWindow doesn't have void ConfigView::hideEvent(QHideEvent *ev) { QQuickWindow::hideEvent(ev); diff --git a/src/plasmaquick/configview.h b/src/plasmaquick/configview.h index c43841244..104c2733c 100644 --- a/src/plasmaquick/configview.h +++ b/src/plasmaquick/configview.h @@ -30,7 +30,6 @@ class Applet; namespace PlasmaQuick { - class ConfigViewPrivate; class ConfigModel; diff --git a/src/plasmaquick/containmentview.cpp b/src/plasmaquick/containmentview.cpp index 41516c812..68abdbf2c 100644 --- a/src/plasmaquick/containmentview.cpp +++ b/src/plasmaquick/containmentview.cpp @@ -8,23 +8,21 @@ #include "configview.h" #include -#include #include -#include -#include #include +#include +#include +#include #include "plasma/pluginloader.h" -#include #include +#include namespace PlasmaQuick { - class ContainmentViewPrivate { public: - ContainmentViewPrivate(Plasma::Corona *corona, ContainmentView *view); ~ContainmentViewPrivate(); @@ -42,8 +40,8 @@ public: }; ContainmentViewPrivate::ContainmentViewPrivate(Plasma::Corona *cor, ContainmentView *view) - : q(view), - corona(cor) + : q(view) + , corona(cor) { } @@ -63,7 +61,7 @@ void ContainmentViewPrivate::setContainment(Plasma::Containment *cont) if (containment) { QObject::disconnect(containment, nullptr, q, nullptr); QObject *oldGraphicObject = containment->property("_plasma_graphicObject").value(); - if (auto item = qobject_cast(oldGraphicObject)) { + if (auto item = qobject_cast(oldGraphicObject)) { item->setVisible(false); } containment->reactToScreenChange(); @@ -80,34 +78,32 @@ void ContainmentViewPrivate::setContainment(Plasma::Containment *cont) Q_EMIT q->containmentChanged(); - //we are QuickViewSharedEngine::SizeRootObjectToView, but that's not enough, as - //the root object isn't immediately resized (done at the resizeEvent handler). - //by resizing it just before restoring the containment, it removes a chain of resizes at startup + // we are QuickViewSharedEngine::SizeRootObjectToView, but that's not enough, as + // the root object isn't immediately resized (done at the resizeEvent handler). + // by resizing it just before restoring the containment, it removes a chain of resizes at startup if (q->rootObject()) { q->rootObject()->setSize(q->size()); } if (cont) { cont->reactToScreenChange(); - QObject::connect(cont, &Plasma::Containment::locationChanged, - q, &ContainmentView::locationChanged); - QObject::connect(cont, &Plasma::Containment::formFactorChanged, - q, &ContainmentView::formFactorChanged); - QObject::connect(cont, &Plasma::Containment::configureRequested, - q, &ContainmentView::showConfigurationInterface); - QObject::connect(cont, SIGNAL(destroyedChanged(bool)), - q, SLOT(updateDestroyed(bool))); + QObject::connect(cont, &Plasma::Containment::locationChanged, q, &ContainmentView::locationChanged); + QObject::connect(cont, &Plasma::Containment::formFactorChanged, q, &ContainmentView::formFactorChanged); + QObject::connect(cont, &Plasma::Containment::configureRequested, q, &ContainmentView::showConfigurationInterface); + QObject::connect(cont, SIGNAL(destroyedChanged(bool)), q, SLOT(updateDestroyed(bool))); // Panels are created invisible and the code below ensures they are only // shown once their contents have settled to avoid visual glitches on startup - if (cont->containmentType() == Plasma::Types::PanelContainment || - cont->containmentType() == Plasma::Types::CustomPanelContainment) { - - QObject::connect(cont, &Plasma::Containment::uiReadyChanged, - q, [this, cont](bool ready) { - if (ready && !cont->destroyed()) { - q->setVisible(true); - } - }, Qt::QueuedConnection); + if (cont->containmentType() == Plasma::Types::PanelContainment || cont->containmentType() == Plasma::Types::CustomPanelContainment) { + QObject::connect( + cont, + &Plasma::Containment::uiReadyChanged, + q, + [this, cont](bool ready) { + if (ready && !cont->destroyed()) { + q->setVisible(true); + } + }, + Qt::QueuedConnection); q->setVisible(!cont->destroyed() && cont->isUiReady()); } @@ -118,10 +114,10 @@ void ContainmentViewPrivate::setContainment(Plasma::Containment *cont) QQuickItem *graphicObject = qobject_cast(containment->property("_plasma_graphicObject").value()); if (graphicObject) { -// qDebug() << "using as graphic containment" << graphicObject << containment.data(); + // qDebug() << "using as graphic containment" << graphicObject << containment.data(); graphicObject->setFocus(true); - //by resizing before adding, it will avoid some resizes in most cases + // by resizing before adding, it will avoid some resizes in most cases graphicObject->setSize(q->size()); graphicObject->setParentItem(q->rootObject()); if (q->rootObject()) { @@ -183,13 +179,12 @@ void ContainmentViewPrivate::updateDestroyed(bool destroyed) } ContainmentView::ContainmentView(Plasma::Corona *corona, QWindow *parent) - : KQuickAddons::QuickViewSharedEngine(parent), - d(new ContainmentViewPrivate(corona, this)) + : KQuickAddons::QuickViewSharedEngine(parent) + , d(new ContainmentViewPrivate(corona, this)) { setColor(Qt::transparent); - QObject::connect(screen(), &QScreen::geometryChanged, - this, &ContainmentView::screenGeometryChanged); + QObject::connect(screen(), &QScreen::geometryChanged, this, &ContainmentView::screenGeometryChanged); if (corona->kPackage().isValid()) { const auto info = corona->kPackage().metadata(); @@ -202,18 +197,20 @@ ContainmentView::ContainmentView(Plasma::Corona *corona, QWindow *parent) qWarning() << "Invalid home screen package"; } - //Force QtQuickControls to use the "Plasma" style for this engine. - //this way is possible to mix QtQuickControls and plasma components in applets - //while still having the desktop style in configuration dialogs + // Force QtQuickControls to use the "Plasma" style for this engine. + // this way is possible to mix QtQuickControls and plasma components in applets + // while still having the desktop style in configuration dialogs QQmlComponent c(engine()); - c.setData("import QtQuick 2.1\n\ + c.setData( + "import QtQuick 2.1\n\ import QtQuick.Controls 1.0\n\ import QtQuick.Controls.Private 1.0\n \ Item {\ Component.onCompleted: {\ Settings.styleName = \"Plasma\";\ }\ - }", QUrl()); + }", + QUrl()); QObject *o = c.create(); o->deleteLater(); diff --git a/src/plasmaquick/containmentview.h b/src/plasmaquick/containmentview.h index 130196225..a151d82a6 100644 --- a/src/plasmaquick/containmentview.h +++ b/src/plasmaquick/containmentview.h @@ -9,9 +9,9 @@ #include -#include -#include "plasma/corona.h" #include "plasma/containment.h" +#include "plasma/corona.h" +#include // // W A R N I N G @@ -26,7 +26,6 @@ namespace PlasmaQuick { - class ContainmentViewPrivate; class PLASMAQUICK_EXPORT ContainmentView : public KQuickAddons::QuickViewSharedEngine diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index e6955a075..27b269790 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -8,23 +8,23 @@ */ #include "dialog.h" -#include "config-plasma.h" #include "../declarativeimports/core/framesvgitem.h" +#include "config-plasma.h" +#include "configview.h" #include "dialogshadows_p.h" #include "view.h" -#include "configview.h" -#include -#include #include -#include #include #include +#include +#include +#include #include -#include #include +#include #include @@ -48,26 +48,25 @@ #include #endif -//Unfortunately QWINDOWSIZE_MAX is not exported -#define DIALOGSIZE_MAX ((1<<24)-1) +// Unfortunately QWINDOWSIZE_MAX is not exported +#define DIALOGSIZE_MAX ((1 << 24) - 1) namespace PlasmaQuick { - class DialogPrivate { public: DialogPrivate(Dialog *dialog) - : q(dialog), - location(Plasma::Types::BottomEdge), - frameSvgItem(nullptr), - hasMask(false), - type(Dialog::Normal), - hideOnWindowDeactivate(false), - outputOnly(false), - visible(false), - componentComplete(dialog->parent() == nullptr), - backgroundHints(Dialog::StandardBackground) + : q(dialog) + , location(Plasma::Types::BottomEdge) + , frameSvgItem(nullptr) + , hasMask(false) + , type(Dialog::Normal) + , hideOnWindowDeactivate(false) + , outputOnly(false) + , visible(false) + , componentComplete(dialog->parent() == nullptr) + , backgroundHints(Dialog::StandardBackground) { hintsCommitTimer.setSingleShot(true); hintsCommitTimer.setInterval(0); @@ -76,7 +75,7 @@ public: void updateInputShape(); - //SLOTS + // SLOTS /** * Sync Borders updates the enabled borders of the frameSvgItem depending * on the geometry of the window. @@ -84,7 +83,7 @@ public: * \param windowGeometry The window geometry which should be taken into * consideration when activating/deactivating certain borders */ - void syncBorders(const QRect& windowGeometry); + void syncBorders(const QRect &windowGeometry); /** * This function sets the blurBehind, background contrast and shadows. It @@ -112,7 +111,7 @@ public: */ void updateLayoutParameters(); - QRect availableScreenGeometryForPosition(const QPoint& pos) const; + QRect availableScreenGeometryForPosition(const QPoint &pos) const; /** * This function checks the current position of the dialog and repositions @@ -152,11 +151,11 @@ public: bool componentComplete; Dialog::BackgroundHints backgroundHints; - //Attached Layout property of mainItem, if any - QPointer mainItemLayout; + // Attached Layout property of mainItem, if any + QPointer mainItemLayout; }; -QRect DialogPrivate::availableScreenGeometryForPosition(const QPoint& pos) const +QRect DialogPrivate::availableScreenGeometryForPosition(const QPoint &pos) const { // FIXME: QWindow::screen() never ever changes if the window is moved across // virtual screens (normal two screens with X), this seems to be intentional @@ -167,9 +166,9 @@ QRect DialogPrivate::availableScreenGeometryForPosition(const QPoint& pos) const QRect avail; const auto screens = QGuiApplication::screens(); for (QScreen *screen : screens) { - //we check geometry() but then take availableGeometry() - //to reliably check in which screen a position is, we need the full - //geometry, including areas for panels + // we check geometry() but then take availableGeometry() + // to reliably check in which screen a position is, we need the full + // geometry, including areas for panels if (screen->geometry().contains(pos)) { avail = screen->availableGeometry(); break; @@ -192,12 +191,12 @@ QRect DialogPrivate::availableScreenGeometryForPosition(const QPoint& pos) const return avail; } -void DialogPrivate::syncBorders(const QRect& geom) +void DialogPrivate::syncBorders(const QRect &geom) { QRect avail = availableScreenGeometryForPosition(geom.topLeft()); int borders = Plasma::FrameSvg::AllBorders; - //Tooltips always have all the borders + // Tooltips always have all the borders // floating windows have all borders if (!q->flags().testFlag(Qt::ToolTip) && location != Plasma::Types::Floating) { if (geom.x() <= avail.x() || location == Plasma::Types::LeftEdge) { @@ -240,11 +239,12 @@ void DialogPrivate::updateTheme() KWindowEffects::enableBlurBehind(q->winId(), theme.blurBehindEnabled(), frameSvgItem->mask()); - KWindowEffects::enableBackgroundContrast(q->winId(), theme.backgroundContrastEnabled(), - theme.backgroundContrast(), - theme.backgroundIntensity(), - theme.backgroundSaturation(), - frameSvgItem->mask()); + KWindowEffects::enableBackgroundContrast(q->winId(), + theme.backgroundContrastEnabled(), + theme.backgroundContrast(), + theme.backgroundIntensity(), + theme.backgroundSaturation(), + frameSvgItem->mask()); if (KWindowSystem::compositingActive()) { if (hasMask) { @@ -296,8 +296,8 @@ void DialogPrivate::updateVisibility(bool visible) } #if HAVE_KWAYLAND - //if is a wayland window that was hidden, we need - //to set its position again as there won't be any move event to sync QWindow::position and shellsurface::position + // if is a wayland window that was hidden, we need + // to set its position again as there won't be any move event to sync QWindow::position and shellsurface::position if (shellSurface && type != Dialog::OnScreenDisplay) { shellSurface->setPosition(q->position()); } @@ -321,7 +321,7 @@ void DialogPrivate::updateVisibility(bool visible) case Plasma::Types::BottomEdge: slideLocation = KWindowEffects::BottomEdge; break; - //no edge, no slide + // no edge, no slide default: break; } @@ -347,10 +347,10 @@ void DialogPrivate::updateMinimumWidth() q->setMinimumWidth(0); - //this is to try to get the internal item resized a tad before, but - //the flicker almost always happen anyways, so is *probably* useless - //this other kind of flicker is the view not being always focused exactly - //on the scene + // this is to try to get the internal item resized a tad before, but + // the flicker almost always happen anyways, so is *probably* useless + // this other kind of flicker is the view not being always focused exactly + // on the scene auto margin = frameSvgItem->fixedMargins(); int minimumWidth = mainItemLayout->property("minimumWidth").toInt() + margin->left() + margin->right(); if (q->screen()) { @@ -373,10 +373,10 @@ void DialogPrivate::updateMinimumHeight() q->setMinimumHeight(0); - //this is to try to get the internal item resized a tad before, but - //the flicker almost always happen anyways, so is *probably* useless - //this other kind of flicker is the view not being always focused exactly - //on the scene + // this is to try to get the internal item resized a tad before, but + // the flicker almost always happen anyways, so is *probably* useless + // this other kind of flicker is the view not being always focused exactly + // on the scene auto margin = frameSvgItem->fixedMargins(); int minimumHeight = mainItemLayout->property("minimumHeight").toInt() + margin->top() + margin->bottom(); if (q->screen()) { @@ -479,31 +479,27 @@ void DialogPrivate::updateLayoutParameters() QSize max(DIALOGSIZE_MAX, DIALOGSIZE_MAX); getSizeHints(min, max); - const QSize finalSize(qBound(min.width(), q->width(), max.width()), - qBound(min.height(), q->height(), max.height())); + const QSize finalSize(qBound(min.width(), q->width(), max.width()), qBound(min.height(), q->height(), max.height())); if (visualParent) { - //it's important here that we're using re->size() as size, we don't want to do recursive resizeEvents + // it's important here that we're using re->size() as size, we don't want to do recursive resizeEvents const QRect geom(q->popupPosition(visualParent, finalSize), finalSize); q->adjustGeometry(geom); } else { q->resize(finalSize); } - mainItem->setPosition(QPointF(margin->left(), - margin->top())); - mainItem->setSize(QSizeF(q->width() - margin->left() - margin->right(), - q->height() - margin->top() - margin->bottom())); + mainItem->setPosition(QPointF(margin->left(), margin->top())); + mainItem->setSize(QSizeF(q->width() - margin->left() - margin->right(), q->height() - margin->top() - margin->bottom())); - frameSvgItem->setSize(QSizeF(q->width(), - q->height())); + frameSvgItem->setSize(QSizeF(q->width(), q->height())); repositionIfOffScreen(); updateTheme(); - //FIXME: this seems to interfere with the geometry change that - //sometimes is still going on, causing flicker (this one is two repositions happening in quick succession). - //it may have to be delayed further + // FIXME: this seems to interfere with the geometry change that + // sometimes is still going on, causing flicker (this one is two repositions happening in quick succession). + // it may have to be delayed further q->setMinimumSize(min); q->setMaximumSize(max); @@ -566,12 +562,10 @@ void DialogPrivate::updateInputShape() } if (outputOnly) { // set input shape, so that it doesn't accept any input events - xcb_shape_rectangles(c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, - XCB_CLIP_ORDERING_UNSORTED, q->winId(), 0, 0, 0, nullptr); + xcb_shape_rectangles(c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, q->winId(), 0, 0, 0, nullptr); } else { // delete the shape - xcb_shape_mask(c, XCB_SHAPE_SO_INTERSECT, XCB_SHAPE_SK_INPUT, - q->winId(), 0, 0, XCB_PIXMAP_NONE); + xcb_shape_mask(c, XCB_SHAPE_SO_INTERSECT, XCB_SHAPE_SK_INPUT, q->winId(), 0, 0, XCB_PIXMAP_NONE); } } #endif @@ -593,9 +587,7 @@ void DialogPrivate::syncToMainItemSize() // fixedMargins will get all the borders, no matter if they are enabled auto margins = frameSvgItem->fixedMargins(); - const QSize fullSize = QSize(mainItem->width(), mainItem->height()) + - QSize(margins->left() + margins->right(), - margins->top() + margins->bottom()); + const QSize fullSize = QSize(mainItem->width(), mainItem->height()) + QSize(margins->left() + margins->right(), margins->top() + margins->bottom()); // We get the popup position with the fullsize as we need the popup // position in order to determine our actual size, as the position @@ -606,20 +598,18 @@ void DialogPrivate::syncToMainItemSize() // the borders. This way when syncBorders is called, it has a geometry // to work with. syncBorders(geom); - } - else { + } else { syncBorders(q->geometry()); } - QSize s = QSize(mainItem->width(), mainItem->height()) + - QSize(frameSvgItem->fixedMargins()->left() + frameSvgItem->fixedMargins()->right(), - frameSvgItem->fixedMargins()->top() + frameSvgItem->fixedMargins()->bottom()); + QSize s = QSize(mainItem->width(), mainItem->height()) + + QSize(frameSvgItem->fixedMargins()->left() + frameSvgItem->fixedMargins()->right(), + frameSvgItem->fixedMargins()->top() + frameSvgItem->fixedMargins()->bottom()); QSize min; QSize max(DIALOGSIZE_MAX, DIALOGSIZE_MAX); getSizeHints(min, max); - s = QSize(qBound(min.width(), s.width(), max.width()), - qBound(min.height(), s.height(), max.height())); + s = QSize(qBound(min.width(), s.width(), max.width()), qBound(min.height(), s.height(), max.height())); q->contentItem()->setSize(s); @@ -641,8 +631,7 @@ void DialogPrivate::syncToMainItemSize() q->resize(s); } - mainItem->setPosition(QPointF(frameSvgItem->fixedMargins()->left(), - frameSvgItem->fixedMargins()->top())); + mainItem->setPosition(QPointF(frameSvgItem->fixedMargins()->left(), frameSvgItem->fixedMargins()->top())); updateTheme(); } @@ -661,8 +650,7 @@ void DialogPrivate::slotWindowPositionChanged() if (mainItem) { auto margin = frameSvgItem->fixedMargins(); mainItem->setPosition(QPoint(margin->left(), margin->top())); - mainItem->setSize(QSize(q->width() - margin->left() - margin->right(), - q->height() - margin->top() - margin->bottom())); + mainItem->setSize(QSize(q->width() - margin->left() - margin->right(), q->height() - margin->top() - margin->bottom())); } } @@ -672,7 +660,7 @@ bool DialogPrivate::mainItemContainsPosition(const QPointF &point) const return false; } - return QRectF(mainItem->mapToScene(QPoint(0,0)), QSizeF(mainItem->width(), mainItem->height())).contains(point); + return QRectF(mainItem->mapToScene(QPoint(0, 0)), QSizeF(mainItem->width(), mainItem->height())).contains(point); } QPointF DialogPrivate::positionAdjustedForMainItem(const QPointF &point) const @@ -681,10 +669,9 @@ QPointF DialogPrivate::positionAdjustedForMainItem(const QPointF &point) const return point; } - QRectF itemRect(mainItem->mapToScene(QPoint(0,0)), QSizeF(mainItem->width(), mainItem->height())); + QRectF itemRect(mainItem->mapToScene(QPoint(0, 0)), QSizeF(mainItem->width(), mainItem->height())); - return QPointF(qBound(itemRect.left(), point.x(), itemRect.right()), - qBound(itemRect.top(), point.y(), itemRect.bottom())); + return QPointF(qBound(itemRect.left(), point.x(), itemRect.right()), qBound(itemRect.top(), point.y(), itemRect.bottom())); } void DialogPrivate::setupWaylandIntegration() @@ -716,28 +703,28 @@ void DialogPrivate::applyType() #if HAVE_X11 if (KWindowSystem::isPlatformX11()) { switch (type) { - case Dialog::Normal: - Q_UNREACHABLE(); - break; - case Dialog::Dock: - wmType = QXcbWindowFunctions::WmWindowType::Dock; - break; - case Dialog::DialogWindow: - wmType = QXcbWindowFunctions::WmWindowType::Dialog; - break; - case Dialog::PopupMenu: - wmType = QXcbWindowFunctions::WmWindowType::PopupMenu; - break; - case Dialog::Tooltip: - wmType = QXcbWindowFunctions::WmWindowType::Tooltip; - break; - case Dialog::Notification: - wmType = QXcbWindowFunctions::WmWindowType::Notification; - break; - case Dialog::OnScreenDisplay: - case Dialog::CriticalNotification: - // Not supported by Qt - break; + case Dialog::Normal: + Q_UNREACHABLE(); + break; + case Dialog::Dock: + wmType = QXcbWindowFunctions::WmWindowType::Dock; + break; + case Dialog::DialogWindow: + wmType = QXcbWindowFunctions::WmWindowType::Dialog; + break; + case Dialog::PopupMenu: + wmType = QXcbWindowFunctions::WmWindowType::PopupMenu; + break; + case Dialog::Tooltip: + wmType = QXcbWindowFunctions::WmWindowType::Tooltip; + break; + case Dialog::Notification: + wmType = QXcbWindowFunctions::WmWindowType::Notification; + break; + case Dialog::OnScreenDisplay: + case Dialog::CriticalNotification: + // Not supported by Qt + break; } if (wmType) { @@ -753,8 +740,8 @@ void DialogPrivate::applyType() q->setFlags(Qt::FramelessWindowHint | q->flags()); } - //an OSD can't be a Dialog, as qt xcb would attempt to set a transient parent for it - //see bug 370433 + // an OSD can't be a Dialog, as qt xcb would attempt to set a transient parent for it + // see bug 370433 if (type == Dialog::OnScreenDisplay) { q->setFlags((q->flags() & ~Qt::Dialog) | Qt::Window); } @@ -786,17 +773,20 @@ void DialogPrivate::applyType() #endif } - Dialog::Dialog(QQuickItem *parent) - : QQuickWindow(parent ? parent->window() : nullptr), - d(new DialogPrivate(this)) + : QQuickWindow(parent ? parent->window() : nullptr) + , d(new DialogPrivate(this)) { setClearBeforeRendering(true); setColor(QColor(Qt::transparent)); setFlags(Qt::FramelessWindowHint | Qt::Dialog); - connect(this, &QWindow::xChanged, [=]() { d->slotWindowPositionChanged(); }); - connect(this, &QWindow::yChanged, [=]() { d->slotWindowPositionChanged(); }); + connect(this, &QWindow::xChanged, [=]() { + d->slotWindowPositionChanged(); + }); + connect(this, &QWindow::yChanged, [=]() { + d->slotWindowPositionChanged(); + }); // Given dialogs are skip task bar and don't have a decoration // minimizing them using e.g. "minimize all" should just close them @@ -806,23 +796,18 @@ Dialog::Dialog(QQuickItem *parent) } }); - connect(this, &QWindow::visibleChanged, - this, &Dialog::visibleChangedProxy); - connect(this, SIGNAL(visibleChanged(bool)), - this, SLOT(updateInputShape())); - connect(this, SIGNAL(outputOnlyChanged()), - this, SLOT(updateInputShape())); + connect(this, &QWindow::visibleChanged, this, &Dialog::visibleChangedProxy); + connect(this, SIGNAL(visibleChanged(bool)), this, SLOT(updateInputShape())); + connect(this, SIGNAL(outputOnlyChanged()), this, SLOT(updateInputShape())); - //HACK: this property is invoked due to the initialization that gets done to contentItem() in the getter + // HACK: this property is invoked due to the initialization that gets done to contentItem() in the getter property("data"); - //Create the FrameSvg background. + // Create the FrameSvg background. d->frameSvgItem = new Plasma::FrameSvgItem(contentItem()); - //This is needed as a transition thing for KWayland + // This is needed as a transition thing for KWayland setProperty("__plasma_frameSvg", QVariant::fromValue(d->frameSvgItem->frameSvg())); - connect(&d->theme, SIGNAL(themeChanged()), - this, SLOT(updateTheme())); - + connect(&d->theme, SIGNAL(themeChanged()), this, SLOT(updateTheme())); } Dialog::~Dialog() @@ -863,21 +848,19 @@ void Dialog::setMainItem(QQuickItem *mainItem) connect(mainItem, SIGNAL(heightChanged()), this, SLOT(slotMainItemSizeChanged())); d->slotMainItemSizeChanged(); - //Extract the representation's Layout, if any + // Extract the representation's Layout, if any QObject *layout = nullptr; setMinimumSize(QSize(0, 0)); setMaximumSize(QSize(DIALOGSIZE_MAX, DIALOGSIZE_MAX)); - //Search a child that has the needed Layout properties - //HACK: here we are not type safe, but is the only way to access to a pointer of Layout + // Search a child that has the needed Layout properties + // HACK: here we are not type safe, but is the only way to access to a pointer of Layout const auto lstChild = mainItem->children(); for (QObject *child : lstChild) { - //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight - if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { + // find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight + if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && child->property("preferredWidth").isValid() + && child->property("preferredHeight").isValid() && child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() + && child->property("fillWidth").isValid() && child->property("fillHeight").isValid()) { layout = child; break; } @@ -886,9 +869,9 @@ void Dialog::setMainItem(QQuickItem *mainItem) d->mainItemLayout = layout; if (layout) { - //Why queued connections? - //we need to be sure that the properties are - //already *all* updated when we call the management code + // Why queued connections? + // we need to be sure that the properties are + // already *all* updated when we call the management code connect(layout, SIGNAL(minimumWidthChanged()), this, SLOT(updateMinimumWidth())); connect(layout, SIGNAL(minimumHeightChanged()), this, SLOT(updateMinimumHeight())); connect(layout, SIGNAL(maximumWidthChanged()), this, SLOT(updateMaximumWidth())); @@ -896,10 +879,9 @@ void Dialog::setMainItem(QQuickItem *mainItem) d->updateLayoutParameters(); } - } - //if this is called in Component.onCompleted we have to wait a loop the item is added to a scene + // if this is called in Component.onCompleted we have to wait a loop the item is added to a scene Q_EMIT mainItemChanged(); } } @@ -935,7 +917,7 @@ void Dialog::setVisualParent(QQuickItem *visualParent) QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) { if (!item) { - //If no item was specified try to align at the center of the parent view + // If no item was specified try to align at the center of the parent view QQuickItem *parentItem = qobject_cast(parent()); if (parentItem) { QScreen *screen = parentItem->window()->screen(); @@ -949,7 +931,7 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) return QPoint(screen->availableGeometry().right() - size.width(), screen->availableGeometry().center().y() - size.height() / 2); case Plasma::Types::BottomEdge: return QPoint(screen->availableGeometry().center().x() - size.width() / 2, screen->availableGeometry().bottom() - size.height()); - //Default center in the screen + // Default center in the screen default: return screen->geometry().center() - QPoint(size.width() / 2, size.height() / 2); } @@ -966,10 +948,10 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) return QPoint(); } - //if the item is in a dock or in a window that ignores WM we want to position the popups outside of the dock + // if the item is in a dock or in a window that ignores WM we want to position the popups outside of the dock const KWindowInfo winInfo(item->window()->winId(), NET::WMWindowType); - const bool outsideParentWindow = ((winInfo.windowType(NET::AllTypesMask) == NET::Dock) || (item->window()->flags() & Qt::X11BypassWindowManagerHint)) - && item->window()->mask().isNull(); + const bool outsideParentWindow = + ((winInfo.windowType(NET::AllTypesMask) == NET::Dock) || (item->window()->flags() & Qt::X11BypassWindowManagerHint)) && item->window()->mask().isNull(); QRect parentGeometryBounds; if (outsideParentWindow) { @@ -982,16 +964,12 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) } } - const QPoint topPoint(pos.x() + (item->mapRectToScene(item->boundingRect()).width() - size.width()) / 2, - parentGeometryBounds.top() - size.height()); - const QPoint bottomPoint(pos.x() + (item->mapRectToScene(item->boundingRect()).width() - size.width()) / 2, - parentGeometryBounds.bottom()); + const QPoint topPoint(pos.x() + (item->mapRectToScene(item->boundingRect()).width() - size.width()) / 2, parentGeometryBounds.top() - size.height()); + const QPoint bottomPoint(pos.x() + (item->mapRectToScene(item->boundingRect()).width() - size.width()) / 2, parentGeometryBounds.bottom()); - const QPoint leftPoint(parentGeometryBounds.left() - size.width(), - pos.y() + (item->mapRectToScene(item->boundingRect()).height() - size.height()) / 2); + const QPoint leftPoint(parentGeometryBounds.left() - size.width(), pos.y() + (item->mapRectToScene(item->boundingRect()).height() - size.height()) / 2); - const QPoint rightPoint(parentGeometryBounds.right(), - pos.y() + (item->mapRectToScene(item->boundingRect()).height() - size.height()) / 2); + const QPoint rightPoint(parentGeometryBounds.right(), pos.y() + (item->mapRectToScene(item->boundingRect()).height() - size.height()) / 2); QPoint dialogPos; if (d->location == Plasma::Types::TopEdge) { @@ -1004,14 +982,14 @@ QPoint Dialog::popupPosition(QQuickItem *item, const QSize &size) dialogPos = topPoint; } - //find the correct screen for the item - //we do not rely on item->window()->screen() because - //QWindow::screen() is always only the screen where the window gets first created - //not actually the current window. See QWindow::screen() documentation + // find the correct screen for the item + // we do not rely on item->window()->screen() because + // QWindow::screen() is always only the screen where the window gets first created + // not actually the current window. See QWindow::screen() documentation QRect avail = item->window()->screen()->availableGeometry(); if (outsideParentWindow && d->frameSvgItem->enabledBorders() != Plasma::FrameSvg::AllBorders) { - //make the panel look it's inside the panel, in order to not make it look cut + // make the panel look it's inside the panel, in order to not make it look cut switch (d->location) { case Plasma::Types::LeftEdge: case Plasma::Types::RightEdge: @@ -1106,35 +1084,32 @@ void Dialog::adjustGeometry(const QRect &geom) setGeometry(geom); } -void Dialog::resizeEvent(QResizeEvent* re) +void Dialog::resizeEvent(QResizeEvent *re) { QQuickWindow::resizeEvent(re); - //it's a spontaneous event generated in qguiapplication.cpp QGuiApplicationPrivate::processWindowScreenChangedEvent - //QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window), QRect()); - //This happens before the first show event when there is more than one screen, - //right after the window has been created, the window is still 0x0, - //but the resize event gets delivered with 0x0 again and executed with all the bad side effects - //this seems to happen for every window when there are multiple screens, so something we have probably to watch out for in the future + // it's a spontaneous event generated in qguiapplication.cpp QGuiApplicationPrivate::processWindowScreenChangedEvent + // QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window), QRect()); + // This happens before the first show event when there is more than one screen, + // right after the window has been created, the window is still 0x0, + // but the resize event gets delivered with 0x0 again and executed with all the bad side effects + // this seems to happen for every window when there are multiple screens, so something we have probably to watch out for in the future if (re->size().isEmpty() || re->size() == re->oldSize()) { return; } - //A dialog can be resized even if no mainItem has ever been set + // A dialog can be resized even if no mainItem has ever been set if (!d->mainItem) { return; } d->mainItem->disconnect(this); - d->frameSvgItem->setSize(QSizeF(re->size().width(), - re->size().height())); + d->frameSvgItem->setSize(QSizeF(re->size().width(), re->size().height())); auto margin = d->frameSvgItem->fixedMargins(); - d->mainItem->setPosition(QPointF(margin->left(), - margin->top())); + d->mainItem->setPosition(QPointF(margin->left(), margin->top())); - d->mainItem->setSize(QSize(re->size().width() - margin->left() - margin->right(), - re->size().height() - margin->top() - margin->bottom())); + d->mainItem->setSize(QSize(re->size().width() - margin->left() - margin->right(), re->size().height() - margin->top() - margin->bottom())); QObject::connect(d->mainItem, SIGNAL(widthChanged()), this, SLOT(slotMainItemSizeChanged())); QObject::connect(d->mainItem, SIGNAL(heightChanged()), this, SLOT(slotMainItemSizeChanged())); @@ -1169,9 +1144,8 @@ void Dialog::focusOutEvent(QFocusEvent *ev) QWindow *parentWindow = transientParent(); while (parentWindow) { - if (parentWindow->isActive() && - !(parentWindow->flags() & Qt::WindowDoesNotAcceptFocus)) { - parentHasFocus = true; + if (parentWindow->isActive() && !(parentWindow->flags() & Qt::WindowDoesNotAcceptFocus)) { + parentHasFocus = true; break; } @@ -1182,7 +1156,8 @@ void Dialog::focusOutEvent(QFocusEvent *ev) const QWindow *focusWindow = QGuiApplication::focusWindow(); bool childHasFocus = focusWindow && ((focusWindow->isActive() && isAncestorOf(focusWindow)) || (focusWindow->type() & Qt::Popup) == Qt::Popup); - const bool viewClicked = qobject_cast(focusWindow) || qobject_cast(focusWindow) || qobject_cast(focusWindow); + const bool viewClicked = qobject_cast(focusWindow) || qobject_cast(focusWindow) + || qobject_cast(focusWindow); if (viewClicked || (!parentHasFocus && !childHasFocus)) { setVisible(false); @@ -1207,7 +1182,7 @@ void Dialog::showEvent(QShowEvent *event) bool Dialog::event(QEvent *event) { if (event->type() == QEvent::Expose) { - auto ee = static_cast(event); + auto ee = static_cast(event); if (!KWindowSystem::isPlatformWayland() || ee->region().isNull()) { return QQuickWindow::event(event); @@ -1223,8 +1198,8 @@ bool Dialog::event(QEvent *event) * see https://phabricator.kde.org/T6064 */ #if HAVE_KWAYLAND - //sometimes non null regions arrive even for non visible windows - //for which surface creation would fail + // sometimes non null regions arrive even for non visible windows + // for which surface creation would fail if (!d->shellSurface && isVisible()) { KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager | NET::SkipSwitcher); d->setupWaylandIntegration(); @@ -1261,27 +1236,29 @@ bool Dialog::event(QEvent *event) */ if (d->mainItem && !d->mainItem->size().isEmpty()) { switch (event->type()) { - case QEvent::MouseMove: - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: { - QMouseEvent *me = static_cast(event); + case QEvent::MouseMove: + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: { + QMouseEvent *me = static_cast(event); - //don't mess with position if the cursor is actually outside the view: - //somebody is doing a click and drag that must not break when the cursor i outside - if (geometry().contains(me->screenPos().toPoint()) && !d->mainItemContainsPosition(me->windowPos())) { - QMouseEvent me2(me->type(), - d->positionAdjustedForMainItem(me->windowPos()), - d->positionAdjustedForMainItem(me->windowPos()), - d->positionAdjustedForMainItem(me->windowPos()) + position(), - me->button(), me->buttons(), me->modifiers()); + // don't mess with position if the cursor is actually outside the view: + // somebody is doing a click and drag that must not break when the cursor i outside + if (geometry().contains(me->screenPos().toPoint()) && !d->mainItemContainsPosition(me->windowPos())) { + QMouseEvent me2(me->type(), + d->positionAdjustedForMainItem(me->windowPos()), + d->positionAdjustedForMainItem(me->windowPos()), + d->positionAdjustedForMainItem(me->windowPos()) + position(), + me->button(), + me->buttons(), + me->modifiers()); - if (isVisible()) { - QCoreApplication::sendEvent(this, &me2); - } - return true; + if (isVisible()) { + QCoreApplication::sendEvent(this, &me2); } - break; + return true; } + break; + } case QEvent::Wheel: { QWheelEvent *we = static_cast(event); @@ -1291,8 +1268,12 @@ bool Dialog::event(QEvent *event) if (!d->mainItemContainsPosition(pos)) { QWheelEvent we2(d->positionAdjustedForMainItem(pos), d->positionAdjustedForMainItem(pos) + position(), - we->pixelDelta(), we->angleDelta(), - we->buttons(), we->modifiers(), we->phase(), false /*inverted*/); + we->pixelDelta(), + we->angleDelta(), + we->buttons(), + we->modifiers(), + we->phase(), + false /*inverted*/); if (isVisible()) { QCoreApplication::sendEvent(this, &we2); @@ -1302,51 +1283,60 @@ bool Dialog::event(QEvent *event) break; } - case QEvent::DragEnter: { - QDragEnterEvent *de = static_cast(event); - if (!d->mainItemContainsPosition(de->pos())) { - QDragEnterEvent de2(d->positionAdjustedForMainItem(de->pos()).toPoint(), - de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers()); + case QEvent::DragEnter: { + QDragEnterEvent *de = static_cast(event); + if (!d->mainItemContainsPosition(de->pos())) { + QDragEnterEvent de2(d->positionAdjustedForMainItem(de->pos()).toPoint(), + de->possibleActions(), + de->mimeData(), + de->mouseButtons(), + de->keyboardModifiers()); - if (isVisible()) { - QCoreApplication::sendEvent(this, &de2); - } - return true; + if (isVisible()) { + QCoreApplication::sendEvent(this, &de2); } - break; + return true; } - //DragLeave just works - case QEvent::DragLeave: - break; - case QEvent::DragMove: { - QDragMoveEvent *de = static_cast(event); - if (!d->mainItemContainsPosition(de->pos())) { - QDragMoveEvent de2(d->positionAdjustedForMainItem(de->pos()).toPoint(), - de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers()); + break; + } + // DragLeave just works + case QEvent::DragLeave: + break; + case QEvent::DragMove: { + QDragMoveEvent *de = static_cast(event); + if (!d->mainItemContainsPosition(de->pos())) { + QDragMoveEvent de2(d->positionAdjustedForMainItem(de->pos()).toPoint(), + de->possibleActions(), + de->mimeData(), + de->mouseButtons(), + de->keyboardModifiers()); - if (isVisible()) { - QCoreApplication::sendEvent(this, &de2); - } - return true; + if (isVisible()) { + QCoreApplication::sendEvent(this, &de2); } - break; + return true; } - case QEvent::Drop: { - QDropEvent *de = static_cast(event); - if (!d->mainItemContainsPosition(de->pos())) { - QDropEvent de2(d->positionAdjustedForMainItem(de->pos()).toPoint(), - de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers()); + break; + } + case QEvent::Drop: { + QDropEvent *de = static_cast(event); + if (!d->mainItemContainsPosition(de->pos())) { + QDropEvent de2(d->positionAdjustedForMainItem(de->pos()).toPoint(), + de->possibleActions(), + de->mimeData(), + de->mouseButtons(), + de->keyboardModifiers()); - if (isVisible()) { - QCoreApplication::sendEvent(this, &de2); - } - return true; + if (isVisible()) { + QCoreApplication::sendEvent(this, &de2); } - break; + return true; } + break; + } - default: - break; + default: + break; } } @@ -1400,8 +1390,8 @@ void Dialog::setOutputOnly(bool outputOnly) void Dialog::setVisible(bool visible) { - //only update real visibility when we have finished component completion - //and all flags have been set + // only update real visibility when we have finished component completion + // and all flags have been set d->visible = visible; if (d->componentComplete) { @@ -1412,7 +1402,7 @@ void Dialog::setVisible(bool visible) // Bug 381242: Qt remembers minimize state and re-applies it when showing setWindowStates(windowStates() & ~Qt::WindowMinimized); QQuickWindow::setVisible(visible); - //signal will be emitted and proxied from the QQuickWindow code + // signal will be emitted and proxied from the QQuickWindow code } else { Q_EMIT visibleChangedProxy(); } diff --git a/src/plasmaquick/dialog.h b/src/plasmaquick/dialog.h index 573cbd32b..7c8412b8c 100644 --- a/src/plasmaquick/dialog.h +++ b/src/plasmaquick/dialog.h @@ -7,10 +7,10 @@ #ifndef DIALOG_PROXY_P #define DIALOG_PROXY_P -#include -#include #include #include +#include +#include #include #include @@ -36,7 +36,6 @@ class QScreen; namespace PlasmaQuick { - class DialogPrivate; /** @@ -158,16 +157,16 @@ public: Q_ENUM(WindowType) enum BackgroundHints { - NoBackground = 0, /**< Not drawing a background under the applet, the dialog has its own implementation */ - StandardBackground = 1, /**< The standard background from the theme is drawn */ - SolidBackground = 2, /**< The solid version of the background is preferred */ + NoBackground = 0, /**< Not drawing a background under the applet, the dialog has its own implementation */ + StandardBackground = 1, /**< The standard background from the theme is drawn */ + SolidBackground = 2, /**< The solid version of the background is preferred */ }; Q_ENUM(BackgroundHints) explicit Dialog(QQuickItem *parent = nullptr); ~Dialog() override; - //PROPERTIES ACCESSORS + // PROPERTIES ACCESSORS QQuickItem *mainItem() const; void setMainItem(QQuickItem *mainItem); @@ -213,7 +212,7 @@ Q_SIGNALS: void outputOnlyChanged(); void flagsChanged(); void backgroundHintsChanged(); - void visibleChangedProxy(); //redeclaration of QQuickWindow::visibleChanged + void visibleChangedProxy(); // redeclaration of QQuickWindow::visibleChanged /** * Emitted when the @see hideOnWindowDeactivate property is @c true and this dialog lost focus to a * window that is neither a parent dialog to nor a child dialog of this dialog. @@ -226,7 +225,7 @@ protected: */ virtual void adjustGeometry(const QRect &geom); - //Reimplementations + // Reimplementations void classBegin() override; void componentComplete() override; void resizeEvent(QResizeEvent *re) override; diff --git a/src/plasmaquick/dialogshadows.cpp b/src/plasmaquick/dialogshadows.cpp index 7d38c945e..17c9a41e2 100644 --- a/src/plasmaquick/dialogshadows.cpp +++ b/src/plasmaquick/dialogshadows.cpp @@ -5,8 +5,8 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include "dialogshadows_p.h" #include "debug_p.h" +#include "dialogshadows_p.h" #include @@ -50,8 +50,8 @@ public: Q_GLOBAL_STATIC(DialogShadowsSingleton, privateDialogShadowsSelf) DialogShadows::DialogShadows(QObject *parent, const QString &prefix) - : Plasma::Svg(parent), - d(new Private(this)) + : Plasma::Svg(parent) + , d(new Private(this)) { setImagePath(prefix); connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateShadows())); @@ -75,8 +75,7 @@ void DialogShadows::addWindow(QWindow *window, Plasma::FrameSvg::EnabledBorders d->m_windows[window] = enabledBorders; d->updateShadow(window, enabledBorders); - connect(window, SIGNAL(destroyed(QObject*)), - this, SLOT(windowDestroyed(QObject*)), Qt::UniqueConnection); + connect(window, SIGNAL(destroyed(QObject *)), this, SLOT(windowDestroyed(QObject *)), Qt::UniqueConnection); } void DialogShadows::removeWindow(QWindow *window) @@ -103,7 +102,6 @@ void DialogShadows::setEnabledBorders(QWindow *window, Plasma::FrameSvg::Enabled d->updateShadow(window, enabledBorders); } - void DialogShadows::Private::windowDestroyed(QObject *deletedObject) { QWindow *window = static_cast(deletedObject); @@ -176,8 +174,7 @@ void DialogShadows::Private::updateShadow(QWindow *window, Plasma::FrameSvg::Ena shadow->setTopTile(nullptr); } - if (enabledBorders & Plasma::FrameSvg::TopBorder && - enabledBorders & Plasma::FrameSvg::RightBorder) { + if (enabledBorders & Plasma::FrameSvg::TopBorder && enabledBorders & Plasma::FrameSvg::RightBorder) { shadow->setTopRightTile(m_tiles.at(1)); } else { shadow->setTopRightTile(nullptr); @@ -189,8 +186,7 @@ void DialogShadows::Private::updateShadow(QWindow *window, Plasma::FrameSvg::Ena shadow->setRightTile(nullptr); } - if (enabledBorders & Plasma::FrameSvg::BottomBorder && - enabledBorders & Plasma::FrameSvg::RightBorder) { + if (enabledBorders & Plasma::FrameSvg::BottomBorder && enabledBorders & Plasma::FrameSvg::RightBorder) { shadow->setBottomRightTile(m_tiles.at(3)); } else { shadow->setBottomRightTile(nullptr); @@ -202,8 +198,7 @@ void DialogShadows::Private::updateShadow(QWindow *window, Plasma::FrameSvg::Ena shadow->setBottomTile(nullptr); } - if (enabledBorders & Plasma::FrameSvg::BottomBorder && - enabledBorders & Plasma::FrameSvg::LeftBorder) { + if (enabledBorders & Plasma::FrameSvg::BottomBorder && enabledBorders & Plasma::FrameSvg::LeftBorder) { shadow->setBottomLeftTile(m_tiles.at(5)); } else { shadow->setBottomLeftTile(nullptr); @@ -215,8 +210,7 @@ void DialogShadows::Private::updateShadow(QWindow *window, Plasma::FrameSvg::Ena shadow->setLeftTile(nullptr); } - if (enabledBorders & Plasma::FrameSvg::TopBorder && - enabledBorders & Plasma::FrameSvg::LeftBorder) { + if (enabledBorders & Plasma::FrameSvg::TopBorder && enabledBorders & Plasma::FrameSvg::LeftBorder) { shadow->setTopLeftTile(m_tiles.at(7)); } else { shadow->setTopLeftTile(nullptr); @@ -279,4 +273,3 @@ bool DialogShadows::enabled() const } #include "moc_dialogshadows_p.cpp" - diff --git a/src/plasmaquick/dialogshadows_p.h b/src/plasmaquick/dialogshadows_p.h index 2b81bda81..96c8de903 100644 --- a/src/plasmaquick/dialogshadows_p.h +++ b/src/plasmaquick/dialogshadows_p.h @@ -38,4 +38,3 @@ private: }; #endif - diff --git a/src/plasmaquick/packageurlinterceptor.cpp b/src/plasmaquick/packageurlinterceptor.cpp index 0fd43c826..155fb8af7 100644 --- a/src/plasmaquick/packageurlinterceptor.cpp +++ b/src/plasmaquick/packageurlinterceptor.cpp @@ -7,26 +7,26 @@ #include "packageurlinterceptor.h" #include -#include #include #include #include +#include #include -#include #include +#include #include namespace PlasmaQuick { - -class PackageUrlInterceptorPrivate { +class PackageUrlInterceptorPrivate +{ public: PackageUrlInterceptorPrivate(QQmlEngine *engine, PackageUrlInterceptor *interceptor, const KPackage::Package &p) - : q(interceptor), - package(p), - engine(engine) + : q(interceptor) + , package(p) + , engine(engine) { selector = new QFileSelector; } @@ -45,12 +45,11 @@ public: bool forcePlasmaStyle = false; }; - PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const KPackage::Package &p) - : QQmlAbstractUrlInterceptor(), - d(new PackageUrlInterceptorPrivate(engine, this, p)) + : QQmlAbstractUrlInterceptor() + , d(new PackageUrlInterceptorPrivate(engine, this, p)) { - //d->allowedPaths << d->engine->importPathList(); + // d->allowedPaths << d->engine->importPathList(); } PackageUrlInterceptor::~PackageUrlInterceptor() @@ -85,7 +84,7 @@ void PackageUrlInterceptor::setForcePlasmaStyle(bool force) QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type) { - //qDebug() << "Intercepted URL:" << path << type; + // qDebug() << "Intercepted URL:" << path << type; const QString urlPath = path.path(); // Don't intercept qmldir files, to prevent double interception @@ -93,8 +92,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept return path; } // We assume we never rewritten qml/qmldir files - if (urlPath.endsWith(QLatin1String("qml")) - || urlPath.endsWith(QLatin1String("/inline"))) { + if (urlPath.endsWith(QLatin1String("qml")) || urlPath.endsWith(QLatin1String("/inline"))) { return d->selector->select(path); } const QString prefix = QString::fromUtf8(prefixForType(type, urlPath)); @@ -103,18 +101,15 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept QString plainPath = path.toString(); const int index = plainPath.indexOf(marker); if (index != -1) { - plainPath = plainPath.leftRef(index) - + QLatin1Char('/') + prefix + QLatin1Char('/') + plainPath.midRef(index + marker.size()); + plainPath = plainPath.leftRef(index) + QLatin1Char('/') + prefix + QLatin1Char('/') + plainPath.midRef(index + marker.size()); const QUrl url = QUrl(plainPath); const QString newPath = url.path(); - //search it in a resource or as a file on disk - if (!(plainPath.contains(QLatin1String("qrc")) && QFile::exists(QLatin1Char(':') + newPath)) - && !QFile::exists(newPath)) { + // search it in a resource or as a file on disk + if (!(plainPath.contains(QLatin1String("qrc")) && QFile::exists(QLatin1Char(':') + newPath)) && !QFile::exists(newPath)) { return d->selector->select(path); } - qWarning() <<"Warning: all files used by qml by the plasmoid should be in ui/. The file in the path" - << plainPath << "was expected at" << path; + qWarning() << "Warning: all files used by qml by the plasmoid should be in ui/. The file in the path" << plainPath << "was expected at" << path; // This deprecated code path doesn't support selectors return url; } diff --git a/src/plasmaquick/packageurlinterceptor.h b/src/plasmaquick/packageurlinterceptor.h index aff1b2be2..8ef02453d 100644 --- a/src/plasmaquick/packageurlinterceptor.h +++ b/src/plasmaquick/packageurlinterceptor.h @@ -28,11 +28,10 @@ class QQmlEngine; namespace PlasmaQuick { - class PackageUrlInterceptorPrivate; -//depends from https://codereview.qt-project.org/#change,65626 -class PLASMAQUICK_EXPORT PackageUrlInterceptor: public QQmlAbstractUrlInterceptor +// depends from https://codereview.qt-project.org/#change,65626 +class PLASMAQUICK_EXPORT PackageUrlInterceptor : public QQmlAbstractUrlInterceptor { public: PackageUrlInterceptor(QQmlEngine *engine, const KPackage::Package &p); @@ -58,19 +57,18 @@ public: break; } - //failed by type, let's try by extension + // failed by type, let's try by extension const QString &extension = fileName.mid(fileName.lastIndexOf(QLatin1Char('.')) + 1).toLower(); - if (extension == QLatin1String("svg") || extension == QStringLiteral("svgz") || - extension == QLatin1String("png") || extension == QStringLiteral("gif") || - extension == QLatin1String("jpg") || extension == QStringLiteral("jpeg")) { + if (extension == QLatin1String("svg") || extension == QStringLiteral("svgz") || extension == QLatin1String("png") || extension == QStringLiteral("gif") + || extension == QLatin1String("jpg") || extension == QStringLiteral("jpeg")) { return QByteArray("images"); - //FIXME: are those necessary? are they *always* caught by type? + // FIXME: are those necessary? are they *always* caught by type? } else if (extension == QLatin1String("js")) { return QByteArray("code"); } else if (extension == QLatin1String("qml") || extension == QStringLiteral("qmldir")) { return QByteArray("ui"); - //everything else, throw it in "data" + // everything else, throw it in "data" } else { return QByteArray("data"); } diff --git a/src/plasmaquick/private/appletquickitem_p.h b/src/plasmaquick/private/appletquickitem_p.h index 8b8ecadcc..7955d7040 100644 --- a/src/plasmaquick/private/appletquickitem_p.h +++ b/src/plasmaquick/private/appletquickitem_p.h @@ -7,10 +7,10 @@ #ifndef APPLETQUICKITEM_P_H #define APPLETQUICKITEM_P_H -#include -#include -#include #include +#include +#include +#include // // W A R N I N G @@ -23,7 +23,6 @@ // We mean it. // - namespace Plasma { class Applet; @@ -36,13 +35,12 @@ class QmlObject; namespace PlasmaQuick { - class AppletQuickItem; class AppletQuickItemPrivate { public: - //weight values for the logic for when or if to preload + // weight values for the logic for when or if to preload enum PreloadWeights { DefaultPreloadWeight = 50, DefaultLauncherPreloadWeight = 100, @@ -68,17 +66,17 @@ public: QQuickItem *createFullRepresentationItem(); QQuickItem *createCompactRepresentationExpanderItem(); - //true if the applet is at a size in which it should be expanded, - //false if is too small and should be an icon + // true if the applet is at a size in which it should be expanded, + // false if is too small and should be an icon bool appletShouldBeExpanded() const; - //ensures the popup is preloaded, don't expand yet + // ensures the popup is preloaded, don't expand yet void preloadForExpansion(); - //look into item, and return the Layout attached property, if found + // look into item, and return the Layout attached property, if found void connectLayoutAttached(QObject *item); void propagateSizeHint(const QByteArray &layoutProperty); - //handlers of Layout signals, private slots + // handlers of Layout signals, private slots void compactRepresentationCheck(); void minimumWidthChanged(); void minimumHeightChanged(); @@ -106,7 +104,7 @@ public: QPointer currentRepresentationItem; QPointer testItem; - //Attached layout objects: own and the representation's one + // Attached layout objects: own and the representation's one QPointer representationLayout; QPointer ownLayout; @@ -119,7 +117,7 @@ public: bool expanded : 1; bool activationTogglesExpanded : 1; - bool initComplete: 1; + bool initComplete : 1; static QHash s_rootObjects; }; diff --git a/src/plasmaquick/private/configcategory_p.cpp b/src/plasmaquick/private/configcategory_p.cpp index 5178baea1..21a0a7ac6 100644 --- a/src/plasmaquick/private/configcategory_p.cpp +++ b/src/plasmaquick/private/configcategory_p.cpp @@ -9,7 +9,6 @@ namespace PlasmaQuick { - ///////////////////////ConfigCategory ConfigCategory::ConfigCategory(QObject *parent) @@ -19,7 +18,8 @@ ConfigCategory::ConfigCategory(QObject *parent) } ConfigCategory::~ConfigCategory() -{} +{ +} QString ConfigCategory::name() const { diff --git a/src/plasmaquick/private/configcategory_p.h b/src/plasmaquick/private/configcategory_p.h index c7a328219..22ed14533 100644 --- a/src/plasmaquick/private/configcategory_p.h +++ b/src/plasmaquick/private/configcategory_p.h @@ -23,9 +23,8 @@ namespace PlasmaQuick { - -//This class represents a single row item of the ConfigModel model in a QML friendly manner. -//the properties contains all the data needed to represent an icon in the sidebar of a configuration dialog, of applets or containments +// This class represents a single row item of the ConfigModel model in a QML friendly manner. +// the properties contains all the data needed to represent an icon in the sidebar of a configuration dialog, of applets or containments class ConfigCategory : public QObject { Q_OBJECT diff --git a/src/plasmaquick/private/packages.cpp b/src/plasmaquick/private/packages.cpp index 5b2a9dc6f..e163514ec 100644 --- a/src/plasmaquick/private/packages.cpp +++ b/src/plasmaquick/private/packages.cpp @@ -12,20 +12,20 @@ #include #include -#include #include "../plasma/config-plasma.h" +#include void LookAndFeelPackage::initPackage(Plasma::Package *package) { // https://community.kde.org/Plasma/lookAndFeelPackage package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/look-and-feel/")); - //Defaults + // Defaults package->addFileDefinition("defaults", QStringLiteral("defaults"), i18n("Default settings for theme, etc.")); - //Colors + // Colors package->addFileDefinition("colors", QStringLiteral("colors"), i18n("Color scheme to use for applications.")); - //Directories + // Directories package->addDirectoryDefinition("previews", QStringLiteral("previews"), i18n("Preview Images")); package->addFileDefinition("loginmanagerpreview", QStringLiteral("previews/loginmanager.png"), i18n("Preview for the Login Manager")); package->addFileDefinition("lockscreenpreview", QStringLiteral("previews/lockscreen.png"), i18n("Preview for the Lock Screen")); @@ -49,7 +49,9 @@ void LookAndFeelPackage::initPackage(Plasma::Package *package) package->addFileDefinition("userswitchermainscript", QStringLiteral("userswitcher/UserSwitcher.qml"), i18n("Main Script for User Switcher")); package->addDirectoryDefinition("desktopswitcher", QStringLiteral("desktopswitcher"), i18n("Virtual Desktop Switcher")); - package->addFileDefinition("desktopswitchermainscript", QStringLiteral("desktopswitcher/DesktopSwitcher.qml"), i18n("Main Script for Virtual Desktop Switcher")); + package->addFileDefinition("desktopswitchermainscript", + QStringLiteral("desktopswitcher/DesktopSwitcher.qml"), + i18n("Main Script for Virtual Desktop Switcher")); package->addDirectoryDefinition("osd", QStringLiteral("osd"), i18n("On-Screen Display Notifications")); package->addFileDefinition("osdmainscript", QStringLiteral("osd/Osd.qml"), i18n("Main Script for On-Screen Display Notifications")); @@ -61,11 +63,12 @@ void LookAndFeelPackage::initPackage(Plasma::Package *package) package->addFileDefinition("runcommandmainscript", QStringLiteral("runcommand/RunCommand.qml"), i18n("Main Script KRunner")); package->addDirectoryDefinition("windowdecoration", QStringLiteral("windowdecoration"), i18n("Window Decoration")); - package->addFileDefinition("windowdecorationmainscript", QStringLiteral("windowdecoration/WindowDecoration.qml"), i18n("Main Script for Window Decoration")); + package->addFileDefinition("windowdecorationmainscript", + QStringLiteral("windowdecoration/WindowDecoration.qml"), + i18n("Main Script for Window Decoration")); package->addDirectoryDefinition("windowswitcher", QStringLiteral("windowswitcher"), i18n("Window Switcher")); package->addFileDefinition("windowswitchermainscript", QStringLiteral("windowswitcher/WindowSwitcher.qml"), i18n("Main Script for Window Switcher")); - } void QmlWallpaperPackage::initPackage(Plasma::Package *package) diff --git a/src/plasmaquick/shellpluginloader.cpp b/src/plasmaquick/shellpluginloader.cpp index 67f7d8033..2c84e3126 100644 --- a/src/plasmaquick/shellpluginloader.cpp +++ b/src/plasmaquick/shellpluginloader.cpp @@ -10,10 +10,10 @@ #include ShellPluginLoader::ShellPluginLoader() - : Plasma::PluginLoader()/*, when BC can be broken, these should become class members - m_lnfPackage(0), - m_qmlPackage(0), - m_layoutPackage(0)*/ + : Plasma::PluginLoader() /*, when BC can be broken, these should become class members + m_lnfPackage(0), + m_qmlPackage(0), + m_layoutPackage(0)*/ { Q_ASSERT(false); } @@ -22,7 +22,7 @@ ShellPluginLoader::~ShellPluginLoader() { } -Plasma::Package ShellPluginLoader::internalLoadPackage(const QString &/*packageFormat*/, const QString &/*specialization*/) +Plasma::Package ShellPluginLoader::internalLoadPackage(const QString & /*packageFormat*/, const QString & /*specialization*/) { Q_ASSERT(false); return Plasma::Package(); @@ -32,4 +32,3 @@ void ShellPluginLoader::init() { Plasma::PluginLoader::setPluginLoader(new ShellPluginLoader); } - diff --git a/src/plasmaquick/view.cpp b/src/plasmaquick/view.cpp index 4fe0db080..d8633d170 100644 --- a/src/plasmaquick/view.cpp +++ b/src/plasmaquick/view.cpp @@ -8,25 +8,23 @@ #include "configview.h" #include -#include #include -#include -#include #include +#include +#include +#include #include #include "plasma/pluginloader.h" -#include #include +#include namespace PlasmaQuick { - class ViewPrivate { public: - ViewPrivate(Plasma::Corona *corona, View *view); ~ViewPrivate(); @@ -44,8 +42,8 @@ public: }; ViewPrivate::ViewPrivate(Plasma::Corona *cor, View *view) - : q(view), - corona(cor) + : q(view) + , corona(cor) { } @@ -66,9 +64,9 @@ void ViewPrivate::setContainment(Plasma::Containment *cont) QObject::disconnect(containment, nullptr, q, nullptr); QObject *oldGraphicObject = containment->property("_plasma_graphicObject").value(); if (oldGraphicObject) { -// qDebug() << "Old graphics Object:" << oldGraphicObject << "Old containment" << containment.data(); - //make sure the graphic object won't die with us - //FIXME:we need a way to reparent to *NO* graphics item, but this makes Qt crash + // qDebug() << "Old graphics Object:" << oldGraphicObject << "Old containment" << containment.data(); + // make sure the graphic object won't die with us + // FIXME:we need a way to reparent to *NO* graphics item, but this makes Qt crash oldGraphicObject->setParent(containment); } containment->reactToScreenChange(); @@ -87,16 +85,11 @@ void ViewPrivate::setContainment(Plasma::Containment *cont) if (cont) { cont->reactToScreenChange(); - QObject::connect(cont, &Plasma::Containment::locationChanged, - q, &View::locationChanged); - QObject::connect(cont, &Plasma::Containment::formFactorChanged, - q, &View::formFactorChanged); - QObject::connect(cont, &Plasma::Containment::configureRequested, - q, &View::showConfigurationInterface); - QObject::connect(cont, SIGNAL(destroyedChanged(bool)), - q, SLOT(updateDestroyed(bool))); - if (cont->containmentType() == Plasma::Types::PanelContainment || - cont->containmentType() == Plasma::Types::CustomPanelContainment) { + QObject::connect(cont, &Plasma::Containment::locationChanged, q, &View::locationChanged); + QObject::connect(cont, &Plasma::Containment::formFactorChanged, q, &View::formFactorChanged); + QObject::connect(cont, &Plasma::Containment::configureRequested, q, &View::showConfigurationInterface); + QObject::connect(cont, SIGNAL(destroyedChanged(bool)), q, SLOT(updateDestroyed(bool))); + if (cont->containmentType() == Plasma::Types::PanelContainment || cont->containmentType() == Plasma::Types::CustomPanelContainment) { q->setVisible(!cont->destroyed() && cont->isUiReady()); } } else { @@ -106,9 +99,9 @@ void ViewPrivate::setContainment(Plasma::Containment *cont) QQuickItem *graphicObject = qobject_cast(containment->property("_plasma_graphicObject").value()); if (graphicObject) { -// qDebug() << "using as graphic containment" << graphicObject << containment.data(); + // qDebug() << "using as graphic containment" << graphicObject << containment.data(); - //by resizing before adding, it will avoid some resizes in most cases + // by resizing before adding, it will avoid some resizes in most cases graphicObject->setSize(q->size()); graphicObject->setParentItem(q->rootObject()); if (q->rootObject()) { @@ -170,13 +163,12 @@ void ViewPrivate::updateDestroyed(bool destroyed) } View::View(Plasma::Corona *corona, QWindow *parent) - : QQuickView(parent), - d(new ViewPrivate(corona, this)) + : QQuickView(parent) + , d(new ViewPrivate(corona, this)) { setColor(Qt::transparent); - QObject::connect(screen(), &QScreen::geometryChanged, - this, &View::screenGeometryChanged); + QObject::connect(screen(), &QScreen::geometryChanged, this, &View::screenGeometryChanged); const auto pkg = corona->kPackage(); if (pkg.isValid()) { @@ -188,24 +180,26 @@ View::View(Plasma::Corona *corona, QWindow *parent) localizedContextObject->setTranslationDomain(QStringLiteral("plasma_shell_") + pkg.metadata().pluginId()); engine()->rootContext()->setContextObject(localizedContextObject); - //binds things like kconfig and icons + // binds things like kconfig and icons KDeclarative::KDeclarative::setupEngine(engine()); // ### how to make sure to do this only once per engine? } else { qWarning() << "Invalid home screen package"; } - //Force QtQuickControls to use the "Plasma" style for this engine. - //this way is possible to mix QtQuickControls and plasma components in applets - //while still having the desktop style in configuration dialogs + // Force QtQuickControls to use the "Plasma" style for this engine. + // this way is possible to mix QtQuickControls and plasma components in applets + // while still having the desktop style in configuration dialogs QQmlComponent c(engine()); - c.setData("import QtQuick 2.1\n\ + c.setData( + "import QtQuick 2.1\n\ import QtQuick.Controls 1.0\n\ import QtQuick.Controls.Private 1.0\n \ Item {\ Component.onCompleted: {\ Settings.styleName = \"Plasma\";\ }\ - }", QUrl()); + }", + QUrl()); QObject *o = c.create(); o->deleteLater(); diff --git a/src/plasmaquick/view.h b/src/plasmaquick/view.h index 04409a5aa..9d5f780e2 100644 --- a/src/plasmaquick/view.h +++ b/src/plasmaquick/view.h @@ -9,9 +9,9 @@ #include -#include -#include "plasma/corona.h" #include "plasma/containment.h" +#include "plasma/corona.h" +#include // // W A R N I N G @@ -28,7 +28,6 @@ namespace PlasmaQuick { - class ViewPrivate; /** diff --git a/src/plasmaquick/waylandintegration.cpp b/src/plasmaquick/waylandintegration.cpp index 0cb24107a..b862a7bfc 100644 --- a/src/plasmaquick/waylandintegration.cpp +++ b/src/plasmaquick/waylandintegration.cpp @@ -9,8 +9,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "waylandintegration_p.h" #include "debug_p.h" +#include "waylandintegration_p.h" #include #include @@ -39,8 +39,7 @@ WaylandIntegration::~WaylandIntegration() KWayland::Client::PlasmaShell *WaylandIntegration::waylandPlasmaShell() { if (!m_waylandPlasmaShell && m_registry) { - const KWayland::Client::Registry::AnnouncedInterface interface = - m_registry->interface(KWayland::Client::Registry::Interface::PlasmaShell); + const KWayland::Client::Registry::AnnouncedInterface interface = m_registry->interface(KWayland::Client::Registry::Interface::PlasmaShell); if (interface.name == 0) { qCWarning(LOG_PLASMAQUICK) << "The compositor does not support the plasma shell protocol"; diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 9246b530a..348b6dea0 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -15,16 +15,16 @@ #include #include -#include -#include -#include #include +#include +#include +#include -#include +#include #include #include +#include #include -#include #include "containmentinterface.h" #include "wallpaperinterface.h" @@ -32,85 +32,64 @@ #include AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariantList &args, QQuickItem *parent) - : AppletQuickItem(script->applet(), parent), - m_configuration(nullptr), - m_appletScriptEngine(script), - m_toolTipTextFormat(0), - m_toolTipItem(nullptr), - m_args(args), - m_hideOnDeactivate(true), - m_oldKeyboardShortcut(0), - m_dummyNativeInterface(nullptr), - m_positionBeforeRemoval(QPointF(-1, -1)) + : AppletQuickItem(script->applet(), parent) + , m_configuration(nullptr) + , m_appletScriptEngine(script) + , m_toolTipTextFormat(0) + , m_toolTipItem(nullptr) + , m_args(args) + , m_hideOnDeactivate(true) + , m_oldKeyboardShortcut(0) + , m_dummyNativeInterface(nullptr) + , m_positionBeforeRemoval(QPointF(-1, -1)) { qmlRegisterAnonymousType("org.kde.plasma.plasmoid", 1); - connect(this, &AppletInterface::configNeedsSaving, - applet(), &Plasma::Applet::configNeedsSaving); - connect(applet(), &Plasma::Applet::immutabilityChanged, - this, &AppletInterface::immutabilityChanged); - connect(applet(), &Plasma::Applet::userConfiguringChanged, - this, &AppletInterface::userConfiguringChanged); + connect(this, &AppletInterface::configNeedsSaving, applet(), &Plasma::Applet::configNeedsSaving); + connect(applet(), &Plasma::Applet::immutabilityChanged, this, &AppletInterface::immutabilityChanged); + connect(applet(), &Plasma::Applet::userConfiguringChanged, this, &AppletInterface::userConfiguringChanged); - connect(applet(), &Plasma::Applet::contextualActionsAboutToShow, - this, &AppletInterface::contextualActionsAboutToShow); + connect(applet(), &Plasma::Applet::contextualActionsAboutToShow, this, &AppletInterface::contextualActionsAboutToShow); - connect(applet(), &Plasma::Applet::statusChanged, - this, &AppletInterface::statusChanged); + connect(applet(), &Plasma::Applet::statusChanged, this, &AppletInterface::statusChanged); - connect(applet(), &Plasma::Applet::destroyedChanged, - this, &AppletInterface::destroyedChanged); + connect(applet(), &Plasma::Applet::destroyedChanged, this, &AppletInterface::destroyedChanged); - connect(applet(), &Plasma::Applet::titleChanged, - this, &AppletInterface::titleChanged); + connect(applet(), &Plasma::Applet::titleChanged, this, &AppletInterface::titleChanged); - connect(applet(), &Plasma::Applet::titleChanged, - this, [this]() { - if (m_toolTipMainText.isNull()) { - Q_EMIT toolTipMainTextChanged(); - } - }); + connect(applet(), &Plasma::Applet::titleChanged, this, [this]() { + if (m_toolTipMainText.isNull()) { + Q_EMIT toolTipMainTextChanged(); + } + }); - connect(applet(), &Plasma::Applet::iconChanged, - this, &AppletInterface::iconChanged); + connect(applet(), &Plasma::Applet::iconChanged, this, &AppletInterface::iconChanged); - connect(applet(), &Plasma::Applet::busyChanged, - this, &AppletInterface::busyChanged); + connect(applet(), &Plasma::Applet::busyChanged, this, &AppletInterface::busyChanged); - connect(applet(), &Plasma::Applet::backgroundHintsChanged, - this, &AppletInterface::backgroundHintsChanged); - connect(applet(), &Plasma::Applet::effectiveBackgroundHintsChanged, - this, &AppletInterface::effectiveBackgroundHintsChanged); - connect(applet(), &Plasma::Applet::userBackgroundHintsChanged, - this, &AppletInterface::userBackgroundHintsChanged); - - connect(applet(), &Plasma::Applet::configurationRequiredChanged, this, - [this](bool configurationRequired, const QString &reason) { + connect(applet(), &Plasma::Applet::backgroundHintsChanged, this, &AppletInterface::backgroundHintsChanged); + connect(applet(), &Plasma::Applet::effectiveBackgroundHintsChanged, this, &AppletInterface::effectiveBackgroundHintsChanged); + connect(applet(), &Plasma::Applet::userBackgroundHintsChanged, this, &AppletInterface::userBackgroundHintsChanged); + + connect(applet(), &Plasma::Applet::configurationRequiredChanged, this, [this](bool configurationRequired, const QString &reason) { Q_UNUSED(configurationRequired); Q_UNUSED(reason); Q_EMIT configurationRequiredChanged(); Q_EMIT configurationRequiredReasonChanged(); }); - connect(applet(), &Plasma::Applet::activated, - this, &AppletInterface::activated); - connect(applet(), &Plasma::Applet::containmentDisplayHintsChanged, - this, &AppletInterface::containmentDisplayHintsChanged); + connect(applet(), &Plasma::Applet::activated, this, &AppletInterface::activated); + connect(applet(), &Plasma::Applet::containmentDisplayHintsChanged, this, &AppletInterface::containmentDisplayHintsChanged); - connect(appletScript(), &DeclarativeAppletScript::formFactorChanged, - this, &AppletInterface::formFactorChanged); - connect(appletScript(), &DeclarativeAppletScript::locationChanged, - this, &AppletInterface::locationChanged); - connect(appletScript(), &DeclarativeAppletScript::contextChanged, - this, &AppletInterface::contextChanged); + connect(appletScript(), &DeclarativeAppletScript::formFactorChanged, this, &AppletInterface::formFactorChanged); + connect(appletScript(), &DeclarativeAppletScript::locationChanged, this, &AppletInterface::locationChanged); + connect(appletScript(), &DeclarativeAppletScript::contextChanged, this, &AppletInterface::contextChanged); if (applet()->containment()) { - connect(applet()->containment(), &Plasma::Containment::screenChanged, - this, &AppletInterface::screenChanged); + connect(applet()->containment(), &Plasma::Containment::screenChanged, this, &AppletInterface::screenChanged); // Screen change implies geo change for good measure. - connect(applet()->containment(), &Plasma::Containment::screenChanged, - this, &AppletInterface::screenGeometryChanged); + connect(applet()->containment(), &Plasma::Containment::screenChanged, this, &AppletInterface::screenGeometryChanged); connect(applet()->containment()->corona(), &Plasma::Corona::screenGeometryChanged, this, [this](int id) { if (id == applet()->containment()->screen()) { @@ -118,20 +97,16 @@ AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariant } }); - connect(applet()->containment()->corona(), &Plasma::Corona::availableScreenRegionChanged, - this, &ContainmentInterface::availableScreenRegionChanged); - connect(applet()->containment()->corona(), &Plasma::Corona::availableScreenRectChanged, - this, &ContainmentInterface::availableScreenRectChanged); + connect(applet()->containment()->corona(), &Plasma::Corona::availableScreenRegionChanged, this, &ContainmentInterface::availableScreenRegionChanged); + connect(applet()->containment()->corona(), &Plasma::Corona::availableScreenRectChanged, this, &ContainmentInterface::availableScreenRectChanged); } connect(this, &AppletInterface::expandedChanged, [=](bool expanded) { - //if both compactRepresentationItem and fullRepresentationItem exist, - //the applet is in a popup + // if both compactRepresentationItem and fullRepresentationItem exist, + // the applet is in a popup if (expanded) { - if (compactRepresentationItem() && fullRepresentationItem() && - fullRepresentationItem()->window() && compactRepresentationItem()->window() && - fullRepresentationItem()->window() != compactRepresentationItem()->window() && - fullRepresentationItem()->parentItem()) { + if (compactRepresentationItem() && fullRepresentationItem() && fullRepresentationItem()->window() && compactRepresentationItem()->window() + && fullRepresentationItem()->window() != compactRepresentationItem()->window() && fullRepresentationItem()->parentItem()) { fullRepresentationItem()->parentItem()->installEventFilter(this); } else if (fullRepresentationItem() && fullRepresentationItem()->parentItem()) { fullRepresentationItem()->parentItem()->removeEventFilter(this); @@ -166,11 +141,10 @@ void AppletInterface::init() connect(this, &AppletInterface::isLoadingChanged, this, &AppletInterface::updateUiReadyConstraint); - connect(applet(), &Plasma::Applet::activated, this, - [ = ]() { + connect(applet(), &Plasma::Applet::activated, this, [=]() { // in case the applet doesn't want to get shrunk on reactivation, // we always expand it again (only in order to conform with legacy behaviour) - bool activate = !( isExpanded() && isActivationTogglesExpanded() ); + bool activate = !(isExpanded() && isActivationTogglesExpanded()); setExpanded(activate); if (activate) { @@ -190,14 +164,14 @@ void AppletInterface::init() void AppletInterface::destroyedChanged(bool destroyed) { - //if an item loses its scene before losing the focus, will never - //be able to gain focus again + // if an item loses its scene before losing the focus, will never + // be able to gain focus again if (destroyed && window() && window()->activeFocusItem()) { QQuickItem *focus = window()->activeFocusItem(); QQuickItem *candidate = focus; bool isAncestor = false; - //search if the current focus item is a child or grandchild of the applet + // search if the current focus item is a child or grandchild of the applet while (candidate) { if (candidate == this) { isAncestor = true; @@ -207,7 +181,7 @@ void AppletInterface::destroyedChanged(bool destroyed) } if (isAncestor) { - //Found? remove focus for the whole hierarchy + // Found? remove focus for the whole hierarchy candidate = focus; while (candidate && candidate != this) { @@ -298,15 +272,15 @@ QString AppletInterface::toolTipMainText() const void AppletInterface::setToolTipMainText(const QString &text) { - //Here we are abusing the difference between a null and an empty string. - //by default is null so falls back to the name - //the fist time it gets set, an empty non null one is set, and won't fallback anymore + // Here we are abusing the difference between a null and an empty string. + // by default is null so falls back to the name + // the fist time it gets set, an empty non null one is set, and won't fallback anymore if (!m_toolTipMainText.isNull() && m_toolTipMainText == text) { return; } if (text.isEmpty()) { - m_toolTipMainText = QStringLiteral("");//this "" makes it non-null + m_toolTipMainText = QStringLiteral(""); // this "" makes it non-null } else { m_toolTipMainText = text; } @@ -325,13 +299,13 @@ QString AppletInterface::toolTipSubText() const void AppletInterface::setToolTipSubText(const QString &text) { - //Also there the difference between null and empty gets exploited + // Also there the difference between null and empty gets exploited if (!m_toolTipSubText.isNull() && m_toolTipSubText == text) { return; } if (text.isEmpty()) { - m_toolTipSubText = QStringLiteral("");//this "" makes it non-null + m_toolTipSubText = QStringLiteral(""); // this "" makes it non-null } else { m_toolTipSubText = text; } @@ -366,8 +340,7 @@ void AppletInterface::setToolTipItem(QQuickItem *toolTipItem) } m_toolTipItem = toolTipItem; - connect(m_toolTipItem.data(), &QObject::destroyed, - this, &AppletInterface::toolTipItemChanged); + connect(m_toolTipItem.data(), &QObject::destroyed, this, &AppletInterface::toolTipItemChanged); Q_EMIT toolTipItemChanged(); } @@ -562,8 +535,7 @@ bool AppletInterface::userConfiguring() const int AppletInterface::apiVersion() const { // Look for C++ plugins first - auto filter = [](const KPluginMetaData &md) -> bool - { + auto filter = [](const KPluginMetaData &md) -> bool { return md.value(QStringLiteral("X-Plasma-API")) == QLatin1String("declarativeappletscript") && md.value(QStringLiteral("X-Plasma-ComponentTypes")).contains(QLatin1String("Applet")); }; @@ -617,7 +589,7 @@ Plasma::Types::ItemStatus AppletInterface::status() const int AppletInterface::screen() const { - if (Plasma::Containment* c = applet()->containment()) { + if (Plasma::Containment *c = applet()->containment()) { return c->screen(); } @@ -647,12 +619,12 @@ bool AppletInterface::hideOnWindowDeactivate() const void AppletInterface::setConstraintHints(Plasma::Types::ConstraintHints hints) { - m_constraintHints = hints; + m_constraintHints = hints; } Plasma::Types::ConstraintHints AppletInterface::constraintHints() const { - return m_constraintHints; + return m_constraintHints; } QKeySequence AppletInterface::globalShortcut() const @@ -667,7 +639,7 @@ void AppletInterface::setGlobalShortcut(const QKeySequence &sequence) QObject *AppletInterface::nativeInterface() { - if (qstrcmp(applet()->metaObject()->className(),"Plasma::Applet") != 0) { + if (qstrcmp(applet()->metaObject()->className(), "Plasma::Applet") != 0) { return applet(); } else { if (!m_dummyNativeInterface) { @@ -705,10 +677,11 @@ QString AppletInterface::downloadPath(const QString &file) QString AppletInterface::downloadPath() const { - const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/Plasma/") + applet()->pluginMetaData().pluginId() + QLatin1Char('/'); + const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/Plasma/") + + applet()->pluginMetaData().pluginId() + QLatin1Char('/'); if (!QFile::exists(downloadDir)) { - QDir dir({ QLatin1Char('/') }); + QDir dir({QLatin1Char('/')}); dir.mkpath(downloadDir); } @@ -717,7 +690,8 @@ QString AppletInterface::downloadPath() const QStringList AppletInterface::downloadedFiles() const { - const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/Plasma/") + applet()->pluginMetaData().pluginId() + QLatin1Char('/'); + const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/Plasma/") + + applet()->pluginMetaData().pluginId() + QLatin1Char('/'); QDir dir(downloadDir); return dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable); } @@ -754,7 +728,7 @@ QVariantList AppletInterface::availableScreenRegion() const const auto itEnd = reg.end(); for (; it != itEnd; ++it) { QRect rect = *it; - //make it relative + // make it relative QRect geometry = applet()->containment()->corona()->screenGeometry(screenId); rect.moveTo(rect.topLeft() - geometry.topLeft()); regVal << QVariant::fromValue(QRectF(rect)); @@ -774,7 +748,7 @@ QRect AppletInterface::availableScreenRect() const if (screenId > -1) { rect = applet()->containment()->corona()->availableScreenRect(screenId); - //make it relative + // make it relative QRect geometry = applet()->containment()->corona()->screenGeometry(screenId); rect.moveTo(rect.topLeft() - geometry.topLeft()); } @@ -789,10 +763,10 @@ bool AppletInterface::event(QEvent *event) // so do a simple keyboard shortcut matching here if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(event); - QKeySequence seq(ke->key()|ke->modifiers()); + QKeySequence seq(ke->key() | ke->modifiers()); - QList actions = applet()->actions()->actions(); - //find the wallpaper action if we are a containment + QList actions = applet()->actions()->actions(); + // find the wallpaper action if we are a containment ContainmentInterface *ci = qobject_cast(this); if (ci) { WallpaperInterface *wi = ci->wallpaperInterface(); @@ -801,33 +775,32 @@ bool AppletInterface::event(QEvent *event) } } - //add any actions of the corona + // add any actions of the corona if (applet()->containment() && applet()->containment()->corona()) { actions << applet()->containment()->corona()->actions()->actions(); } bool keySequenceUsed = false; for (auto a : qAsConst(actions)) { - if (a->shortcut().isEmpty()) { continue; } - //this will happen on a normal, non emacs shortcut + // this will happen on a normal, non emacs shortcut if (seq.matches(a->shortcut()) == QKeySequence::ExactMatch) { event->accept(); a->trigger(); m_oldKeyboardShortcut = 0; return true; - //first part of an emacs style shortcut? + // first part of an emacs style shortcut? } else if (seq.matches(a->shortcut()) == QKeySequence::PartialMatch) { keySequenceUsed = true; - m_oldKeyboardShortcut = ke->key()|ke->modifiers(); + m_oldKeyboardShortcut = ke->key() | ke->modifiers(); - //no match at all, but it can be the second part of an emacs style shortcut + // no match at all, but it can be the second part of an emacs style shortcut } else { - QKeySequence seq(m_oldKeyboardShortcut, ke->key()|ke->modifiers()); + QKeySequence seq(m_oldKeyboardShortcut, ke->key() | ke->modifiers()); if (seq.matches(a->shortcut()) == QKeySequence::ExactMatch) { event->accept(); @@ -856,9 +829,9 @@ bool AppletInterface::eventFilter(QObject *watched, QEvent *event) if (event->type() == QEvent::MouseButtonPress) { QMouseEvent *e = static_cast(event); - //pass it up to the applet - //well, actually we have to pass it to the *containment* - //because all the code for showing an applet's contextmenu is actually in Containment. + // pass it up to the applet + // well, actually we have to pass it to the *containment* + // because all the code for showing an applet's contextmenu is actually in Containment. Plasma::Containment *c = applet()->containment(); if (c) { const QString trigger = Plasma::ContainmentActions::eventToString(event); @@ -872,9 +845,9 @@ bool AppletInterface::eventFilter(QObject *watched, QEvent *event) return false; } - //the plugin can be a single action or a context menu - //Don't have an action list? execute as single action - //and set the event position as action data + // the plugin can be a single action or a context menu + // Don't have an action list? execute as single action + // and set the event position as action data if (plugin->contextualActions().length() == 1) { // but first check whether we are not a popup // we don't want to randomly creates applets without confirmation diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index bb36294ef..dabaf121b 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -17,8 +17,8 @@ #include #include -#include #include "declarativeappletscript.h" +#include class QAction; class QActionGroup; @@ -96,7 +96,6 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem */ Q_PROPERTY(QQuickItem *toolTipItem READ toolTipItem WRITE setToolTipItem NOTIFY toolTipItemChanged) - /** * Icon to represent the plasmoid */ @@ -230,7 +229,8 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem /** * Reason why the manual user configuration is required */ - Q_PROPERTY(QString configurationRequiredReason READ configurationRequiredReason WRITE setConfigurationRequiredReason NOTIFY configurationRequiredReasonChanged) + Q_PROPERTY( + QString configurationRequiredReason READ configurationRequiredReason WRITE setConfigurationRequiredReason NOTIFY configurationRequiredReasonChanged) /** * screen area free of panels: the coordinates are relative to the containment, @@ -263,7 +263,7 @@ public: AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = nullptr); ~AppletInterface() override; -//API not intended for the QML part + // API not intended for the QML part DeclarativeAppletScript *appletScript() const; @@ -274,7 +274,7 @@ public: void executeAction(const QString &name); -//QML API------------------------------------------------------------------- + // QML API------------------------------------------------------------------- /** * Set this to true if the plasmoid needs to be configured in order to work. The containment will display reason as a message to ask the user to configure. @@ -288,14 +288,14 @@ public: Q_INVOKABLE void setActionGroup(const QString &action, const QString &group); /** * Add an action to the Plasmoid contextual menu. - * When the action is triggered a function called action_ will be called, if there is no function with that name actionTriggered(name) will be called instead. + * When the action is triggered a function called action_ will be called, if there is no function with that name actionTriggered(name) will be called + * instead. * @param: action name * @text: user visible displayed text * @icon: user visible optional displayed icon * @shortcut: shortcut to trigger this action */ - Q_INVOKABLE void setAction(const QString &name, const QString &text, - const QString &icon = QString(), const QString &shortcut = QString()); + Q_INVOKABLE void setAction(const QString &name, const QString &text, const QString &icon = QString(), const QString &shortcut = QString()); Q_INVOKABLE void removeAction(const QString &name); @@ -355,7 +355,7 @@ public: return qobject_cast(AppletQuickItem::qmlAttachedProperties(object)); } -//PROPERTY ACCESSORS------------------------------------------------------------------- + // PROPERTY ACCESSORS------------------------------------------------------------------- QString pluginName() const; QString icon() const; @@ -424,7 +424,7 @@ public: QObject *nativeInterface(); - //NOTE: setConfigurationRequiredProperty because ambiguous with the + // NOTE: setConfigurationRequiredProperty because ambiguous with the // setConfigurationRequired invokable bool configurationRequired() const; void setConfigurationRequiredProperty(bool required); @@ -458,7 +458,7 @@ Q_SIGNALS: */ void contextualActionsAboutToShow(); -//PROPERTY change notifiers-------------- + // PROPERTY change notifiers-------------- void iconChanged(); void titleChanged(); void toolTipMainTextChanged(); @@ -499,27 +499,26 @@ protected: bool event(QEvent *event) override; bool eventFilter(QObject *watched, QEvent *event) override; - /* - * Returns true if this plasmoid or a dependent feature (i.e wallpaper) is loading - */ + /* + * Returns true if this plasmoid or a dependent feature (i.e wallpaper) is loading + */ virtual bool isLoading() const; - /* - * Set UIReadyConstraint if we're not currently loading - */ + /* + * Set UIReadyConstraint if we're not currently loading + */ void updateUiReadyConstraint(); private Q_SLOTS: void destroyedChanged(bool destroyed); private: - QStringList m_actions; QHash m_actionGroups; KDeclarative::ConfigPropertyMap *m_configuration; DeclarativeAppletScript *m_appletScriptEngine; -//UI-specific members ------------------ + // UI-specific members ------------------ QString m_toolTipMainText; QString m_toolTipSubText; @@ -528,12 +527,12 @@ private: QVariantList m_args; bool m_hideOnDeactivate : 1; bool m_loading = false; - //this is used to build an emacs style shortcut + // this is used to build an emacs style shortcut int m_oldKeyboardShortcut; QObject *m_dummyNativeInterface; friend class ContainmentInterface; - //This is used by ContainmentInterface + // This is used by ContainmentInterface QPointF m_positionBeforeRemoval; Plasma::Types::ConstraintHints m_constraintHints = Plasma::Types::ConstraintHints::NoHint; }; diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 72acb5f57..ba5b7afdd 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -7,35 +7,35 @@ */ #include "containmentinterface.h" -#include "wallpaperinterface.h" #include "dropmenu.h" +#include "wallpaperinterface.h" #include +#include #include +#include #include #include -#include -#include #include -#include +#include -#include #include +#include #include -#include #include -#include -#include #include +#include +#include +#include #include #include #include -#include #include #include #include +#include #include #include @@ -45,22 +45,19 @@ #include ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args) - : AppletInterface(parent, args), - m_wallpaperInterface(nullptr), - m_activityInfo(nullptr), - m_wheelDelta(0) + : AppletInterface(parent, args) + , m_wallpaperInterface(nullptr) + , m_activityInfo(nullptr) + , m_wheelDelta(0) { m_containment = static_cast(appletScript()->applet()->containment()); setAcceptedMouseButtons(Qt::AllButtons); - connect(m_containment.data(), &Plasma::Containment::appletRemoved, - this, &ContainmentInterface::appletRemovedForward); - connect(m_containment.data(), &Plasma::Containment::appletAdded, - this, &ContainmentInterface::appletAddedForward); + connect(m_containment.data(), &Plasma::Containment::appletRemoved, this, &ContainmentInterface::appletRemovedForward); + connect(m_containment.data(), &Plasma::Containment::appletAdded, this, &ContainmentInterface::appletAddedForward); - connect(m_containment->corona(), &Plasma::Corona::editModeChanged, - this, &ContainmentInterface::editModeChanged); + connect(m_containment->corona(), &Plasma::Corona::editModeChanged, this, &ContainmentInterface::editModeChanged); if (!m_appletInterfaces.isEmpty()) { Q_EMIT appletsChanged(); @@ -74,8 +71,7 @@ void ContainmentInterface::init() } m_activityInfo = new KActivities::Info(m_containment->activity(), this); - connect(m_activityInfo, &KActivities::Info::nameChanged, - this, &ContainmentInterface::activityNameChanged); + connect(m_activityInfo, &KActivities::Info::nameChanged, this, &ContainmentInterface::activityNameChanged); Q_EMIT activityNameChanged(); if (!m_containment->wallpaper().isEmpty()) { @@ -84,7 +80,7 @@ void ContainmentInterface::init() AppletInterface::init(); - //Create the ToolBox + // Create the ToolBox if (m_containment) { KConfigGroup defaults; if (m_containment->containmentType() == Plasma::Types::DesktopContainment) { @@ -125,40 +121,33 @@ void ContainmentInterface::init() qWarning() << "Toolbox not loading, toolbox package is either invalid or disabled."; } } - } - //set parent, both as object hierarchically and visually - //do this only for containments, applets will do it in compactrepresentationcheck + // set parent, both as object hierarchically and visually + // do this only for containments, applets will do it in compactrepresentationcheck if (qmlObject()->rootObject()) { qmlObject()->rootObject()->setProperty("parent", QVariant::fromValue(this)); - //set anchors + // set anchors QQmlExpression expr(qmlObject()->engine()->rootContext(), qmlObject()->rootObject(), QStringLiteral("parent")); QQmlProperty prop(qmlObject()->rootObject(), QStringLiteral("anchors.fill")); prop.write(expr.evaluate()); } - connect(m_containment.data(), &Plasma::Containment::activityChanged, - this, &ContainmentInterface::activityChanged); - connect(m_containment.data(), &Plasma::Containment::activityChanged, this, - [ = ]() { - delete m_activityInfo; - m_activityInfo = new KActivities::Info(m_containment->activity(), this); - connect(m_activityInfo, &KActivities::Info::nameChanged, - this, &ContainmentInterface::activityNameChanged); - Q_EMIT activityNameChanged(); - }); - connect(m_containment.data(), &Plasma::Containment::wallpaperChanged, - this, &ContainmentInterface::loadWallpaper); - connect(m_containment.data(), &Plasma::Containment::containmentTypeChanged, - this, &ContainmentInterface::containmentTypeChanged); + connect(m_containment.data(), &Plasma::Containment::activityChanged, this, &ContainmentInterface::activityChanged); + connect(m_containment.data(), &Plasma::Containment::activityChanged, this, [=]() { + delete m_activityInfo; + m_activityInfo = new KActivities::Info(m_containment->activity(), this); + connect(m_activityInfo, &KActivities::Info::nameChanged, this, &ContainmentInterface::activityNameChanged); + Q_EMIT activityNameChanged(); + }); + connect(m_containment.data(), &Plasma::Containment::wallpaperChanged, this, &ContainmentInterface::loadWallpaper); + connect(m_containment.data(), &Plasma::Containment::containmentTypeChanged, this, &ContainmentInterface::containmentTypeChanged); - connect(m_containment.data()->actions(), &KActionCollection::changed, - this, &ContainmentInterface::actionsChanged); + connect(m_containment.data()->actions(), &KActionCollection::changed, this, &ContainmentInterface::actionsChanged); } -QList ContainmentInterface::applets() +QList ContainmentInterface::applets() { return m_appletInterfaces; } @@ -180,14 +169,14 @@ Plasma::Applet *ContainmentInterface::createApplet(const QString &plugin, const Plasma::Applet *ContainmentInterface::createApplet(const QString &plugin, const QVariantList &args, const QRectF &geom) { - //HACK - //This is necessary to delay the appletAdded signal (of containmentInterface) AFTER the applet graphics object has been created + // HACK + // This is necessary to delay the appletAdded signal (of containmentInterface) AFTER the applet graphics object has been created blockSignals(true); Plasma::Applet *applet = m_containment->createApplet(plugin, args); if (applet) { QQuickItem *appletGraphicObject = applet->property("_plasma_graphicObject").value(); - //invalid applet? + // invalid applet? if (!appletGraphicObject) { blockSignals(false); return applet; @@ -260,10 +249,10 @@ QPointF ContainmentInterface::mapFromApplet(AppletInterface *applet, int x, int return QPointF(); } - //x,y in absolute screen coordinates of current view + // x,y in absolute screen coordinates of current view QPointF pos = applet->mapToScene(QPointF(x, y)); pos = QPointF(pos + applet->window()->geometry().topLeft()); - //return the coordinate in the relative view's coords + // return the coordinate in the relative view's coords return pos - window()->geometry().topLeft(); } @@ -273,12 +262,12 @@ QPointF ContainmentInterface::mapToApplet(AppletInterface *applet, int x, int y) return QPointF(); } - //x,y in absolute screen coordinates of current view + // x,y in absolute screen coordinates of current view QPointF pos(x, y); pos = QPointF(pos + window()->geometry().topLeft()); - //the coordinate in the relative view's coords + // the coordinate in the relative view's coords pos = pos - applet->window()->geometry().topLeft(); - //make it relative to applet coords + // make it relative to applet coords return pos - applet->mapToScene(QPointF(0, 0)); } @@ -291,15 +280,17 @@ QPointF ContainmentInterface::adjustToAvailableScreenRegion(int x, int y, int w, } if (!reg.isEmpty()) { - //make it relative + // make it relative QRect geometry = m_containment->corona()->screenGeometry(screenId); - reg.translate(- geometry.topLeft()); + reg.translate(-geometry.topLeft()); } else { reg = QRect(0, 0, width(), height()); } const QRect rect(qBound(reg.boundingRect().left(), x, reg.boundingRect().right() + 1 - w), - qBound(reg.boundingRect().top(), y, reg.boundingRect().bottom() + 1 - h), w, h); + qBound(reg.boundingRect().top(), y, reg.boundingRect().bottom() + 1 - h), + w, + h); const QRectF ar = availableScreenRect(); QRect tempRect(rect); @@ -312,7 +303,7 @@ QPointF ContainmentInterface::adjustToAvailableScreenRegion(int x, int y, int w, // top left corner if (rect.center().x() <= ar.center().x() && rect.center().y() <= ar.center().y()) { - //QRegion::contains doesn't do what it would suggest, so do reg.intersected(rect) != rect instead + // QRegion::contains doesn't do what it would suggest, so do reg.intersected(rect) != rect instead if (reg.intersected(rect) != rect) { tempRect = QRect(qMax(rect.left(), (int)ar.left()), rect.top(), w, h); if (reg.intersected(tempRect) == tempRect) { @@ -330,7 +321,7 @@ QPointF ContainmentInterface::adjustToAvailableScreenRegion(int x, int y, int w, return rect.topLeft(); } - //bottom left corner + // bottom left corner } else if (rect.center().x() <= ar.center().x() && rect.center().y() > ar.center().y()) { if (reg.intersected(rect) != rect) { tempRect = QRect(qMax(rect.left(), (int)ar.left()), rect.top(), w, h); @@ -349,7 +340,7 @@ QPointF ContainmentInterface::adjustToAvailableScreenRegion(int x, int y, int w, return rect.topLeft(); } - //top right corner + // top right corner } else if (rect.center().x() > ar.center().x() && rect.center().y() <= ar.center().y()) { if (reg.intersected(rect) != rect) { tempRect = QRect(qMin(rect.left(), (int)(ar.right() + 1 - w)), rect.top(), w, h); @@ -368,7 +359,7 @@ QPointF ContainmentInterface::adjustToAvailableScreenRegion(int x, int y, int w, return rect.topLeft(); } - //bottom right corner + // bottom right corner } else if (rect.center().x() > ar.center().x() && rect.center().y() > ar.center().y()) { if (reg.intersected(rect) != rect) { tempRect = QRect(qMin(rect.left(), (int)(ar.right() + 1 - w)), rect.top(), w, h); @@ -408,11 +399,11 @@ void ContainmentInterface::setEditMode(bool edit) void ContainmentInterface::processMimeData(QObject *mimeDataProxy, int x, int y, KIO::DropJob *dropJob) { - QMimeData* mime = qobject_cast(mimeDataProxy); + QMimeData *mime = qobject_cast(mimeDataProxy); if (mime) { processMimeData(mime, x, y, dropJob); } else { - processMimeData(mimeDataProxy->property("mimeData").value(), x, y, dropJob); + processMimeData(mimeDataProxy->property("mimeData").value(), x, y, dropJob); } } @@ -433,7 +424,7 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI dropJob->setParent(m_dropMenu); } - //const QMimeData *mimeData = data; + // const QMimeData *mimeData = data; qDebug() << "Arrived mimeData" << mimeData->urls() << mimeData->formats() << "at" << x << ", " << y; @@ -444,16 +435,21 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI } if (mimeData->hasFormat(QStringLiteral("text/x-plasmoidservicename"))) { - QString data = QString::fromUtf8( mimeData->data(QStringLiteral("text/x-plasmoidservicename")) ); + QString data = QString::fromUtf8(mimeData->data(QStringLiteral("text/x-plasmoidservicename"))); const QStringList appletNames = data.split(QLatin1Char('\n'), Qt::SkipEmptyParts); for (const QString &appletName : appletNames) { qDebug() << "adding" << appletName; - metaObject()->invokeMethod(this, "createApplet", Qt::QueuedConnection, Q_ARG(QString, appletName), Q_ARG(QVariantList, QVariantList()), Q_ARG(QRectF, QRectF(x, y, -1, -1))); + metaObject()->invokeMethod(this, + "createApplet", + Qt::QueuedConnection, + Q_ARG(QString, appletName), + Q_ARG(QVariantList, QVariantList()), + Q_ARG(QRectF, QRectF(x, y, -1, -1))); } delete m_dropMenu.data(); } else if (mimeData->hasUrls()) { - //TODO: collect the mimetypes of available script engines and offer + // TODO: collect the mimetypes of available script engines and offer // to create widgets out of the matching URLs, if any const QList urls = KUrlMimeData::urlsFromMimeData(mimeData); m_dropMenu->setUrls(urls); @@ -477,8 +473,7 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI job->setParent(m_dropMenu.data()); QObject::connect(job, &KJob::result, this, &ContainmentInterface::dropJobResult); - QObject::connect(job, &KIO::MimetypeJob::mimeTypeFound, - this, &ContainmentInterface::mimeTypeRetrieved); + QObject::connect(job, &KIO::MimetypeJob::mimeTypeFound, this, &ContainmentInterface::mimeTypeRetrieved); } else { bool deleteDropMenu = true; @@ -499,13 +494,13 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI pluginFormats.insert(plugin.pluginId(), format); } } - //qDebug() << "Mimetype ..." << formats << seenPlugins.keys() << pluginFormats.values(); + // qDebug() << "Mimetype ..." << formats << seenPlugins.keys() << pluginFormats.values(); QString selectedPlugin; if (seenPlugins.isEmpty()) { - //do nothing - //directly create if only one offer only if the containment didn't pass an existing plugin + // do nothing + // directly create if only one offer only if the containment didn't pass an existing plugin } else if (seenPlugins.count() == 1) { selectedPlugin = seenPlugins.constBegin().key(); Plasma::Applet *applet = createApplet(selectedPlugin, QVariantList(), QRect(x, y, -1, -1)); @@ -577,7 +572,6 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet qDebug() << "No applets found matching the url (" << tjob->url() << ") or the mimetype (" << mimetype << ")"; return; } else { - qDebug() << "Received a suitable dropEvent at " << m_dropMenu->dropPoint(); qDebug() << "Bailing out. Cannot find associated dropEvent related to the TransferJob"; @@ -587,9 +581,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet QList wallpaperList; - if (m_containment->containmentType() != Plasma::Types::PanelContainment - && m_containment->containmentType() != Plasma::Types::CustomPanelContainment) { - + if (m_containment->containmentType() != Plasma::Types::PanelContainment && m_containment->containmentType() != Plasma::Types::CustomPanelContainment) { if (m_wallpaperInterface && m_wallpaperInterface->supportsMimetype(mimetype)) { wallpaperList << m_wallpaperInterface->kPackage().metadata(); } else { @@ -618,13 +610,17 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet KJob *installJob = package.update(packagePath); connect(installJob, &KJob::result, this, [this, packagePath, structure](KJob *job) { auto fail = [](const QString &text) { - KNotification::event(QStringLiteral("plasmoidInstallationFailed"), i18n("Package Installation Failed"), - text, QStringLiteral("dialog-error"), nullptr, KNotification::CloseOnTimeout, QStringLiteral("plasma_workspace")); + KNotification::event(QStringLiteral("plasmoidInstallationFailed"), + i18n("Package Installation Failed"), + text, + QStringLiteral("dialog-error"), + nullptr, + KNotification::CloseOnTimeout, + QStringLiteral("plasma_workspace")); }; // if the applet is already installed, just add it to the containment - if (job->error() != KJob::NoError - && job->error() != Package::PackageAlreadyInstalledError + if (job->error() != KJob::NoError && job->error() != Package::PackageAlreadyInstalledError && job->error() != Package::NewerVersionAlreadyInstalledError) { fail(job->errorText()); return; @@ -642,7 +638,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet return; } - createApplet(package.metadata().pluginId(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1,-1))); + createApplet(package.metadata().pluginId(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1))); }); }); } @@ -661,7 +657,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet action->setData(info.pluginId()); const QUrl url = tjob->url(); connect(action, &QAction::triggered, this, [this, action, mimetype, url]() { - Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1,-1))); + Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1))); setAppletArgs(applet, mimetype, url.toString()); }); } @@ -670,14 +666,14 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet m_dropMenu->addAction(action); action->setData(QStringLiteral("org.kde.plasma.icon")); const QUrl url = tjob->url(); - connect(action, &QAction::triggered, this, [this, action, mimetype, url](){ - Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1,-1))); + connect(action, &QAction::triggered, this, [this, action, mimetype, url]() { + Plasma::Applet *applet = createApplet(action->data().toString(), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1))); setAppletArgs(applet, mimetype, url.toString()); }); } QHash actionsToWallpapers; - if (!wallpaperList.isEmpty()) { + if (!wallpaperList.isEmpty()) { QAction *action = new QAction(i18n("Wallpaper"), m_dropMenu); action->setSeparator(true); m_dropMenu->addAction(action); @@ -697,7 +693,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet actionsToWallpapers.insert(action, info.pluginId()); const QUrl url = tjob->url(); connect(action, &QAction::triggered, this, [this, url]() { - //set wallpapery stuff + // set wallpapery stuff if (m_wallpaperInterface && url.isValid()) { m_wallpaperInterface->setUrl(url); } @@ -705,9 +701,9 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet } } } else { - //case in which we created the menu ourselves, just the "fetching type entry, directly create the icon applet + // case in which we created the menu ourselves, just the "fetching type entry, directly create the icon applet if (!m_dropMenu->isDropjobMenu()) { - Plasma::Applet *applet = createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1,-1))); + Plasma::Applet *applet = createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1))); setAppletArgs(applet, mimetype, tjob->url().toString()); } else { QAction *action; @@ -719,8 +715,8 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet m_dropMenu->addAction(action); const QUrl url = tjob->url(); - connect(action, &QAction::triggered, this, [this, mimetype, url](){ - Plasma::Applet *applet = createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1,-1))); + connect(action, &QAction::triggered, this, [this, mimetype, url]() { + Plasma::Applet *applet = createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList(), QRect(m_dropMenu->dropPoint(), QSize(-1, -1))); setAppletArgs(applet, mimetype, url.toString()); }); } @@ -738,11 +734,11 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet) AppletInterface *appletGraphicObject = applet->property("_plasma_graphicObject").value(); AppletInterface *contGraphicObject = m_containment->property("_plasma_graphicObject").value(); -// qDebug() << "Applet added on containment:" << m_containment->title() << contGraphicObject -// << "Applet: " << applet << applet->title() << appletGraphicObject; + // qDebug() << "Applet added on containment:" << m_containment->title() << contGraphicObject + // << "Applet: " << applet << applet->title() << appletGraphicObject; - //applets can not have a graphic object if they don't have a script engine loaded - //this can happen if they were loaded with an invalid metadata + // applets can not have a graphic object if they don't have a script engine loaded + // this can happen if they were loaded with an invalid metadata if (!appletGraphicObject) { return; } @@ -753,10 +749,9 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet) } m_appletInterfaces << appletGraphicObject; - connect(appletGraphicObject, &QObject::destroyed, this, - [this](QObject *obj) { - m_appletInterfaces.removeAll(obj); - }); + connect(appletGraphicObject, &QObject::destroyed, this, [this](QObject *obj) { + m_appletInterfaces.removeAll(obj); + }); Q_EMIT appletAdded(appletGraphicObject, appletGraphicObject->m_positionBeforeRemoval.x(), appletGraphicObject->m_positionBeforeRemoval.y()); Q_EMIT appletsChanged(); } @@ -774,8 +769,7 @@ void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet) void ContainmentInterface::loadWallpaper() { - if (m_containment->containmentType() != Plasma::Types::DesktopContainment && - m_containment->containmentType() != Plasma::Types::CustomContainment) { + if (m_containment->containmentType() != Plasma::Types::DesktopContainment && m_containment->containmentType() != Plasma::Types::CustomContainment) { return; } @@ -783,12 +777,12 @@ void ContainmentInterface::loadWallpaper() m_wallpaperInterface = new WallpaperInterface(this); m_wallpaperInterface->setZ(-1000); - //Qml seems happier if the parent gets set in this way + // Qml seems happier if the parent gets set in this way m_wallpaperInterface->setProperty("parent", QVariant::fromValue(this)); connect(m_wallpaperInterface, &WallpaperInterface::isLoadingChanged, this, &AppletInterface::updateUiReadyConstraint); - //set anchors + // set anchors QQmlExpression expr(qmlObject()->engine()->rootContext(), m_wallpaperInterface, QStringLiteral("parent")); QQmlProperty prop(m_wallpaperInterface, QStringLiteral("anchors.fill")); prop.write(expr.evaluate()); @@ -815,21 +809,22 @@ QString ContainmentInterface::activityName() const QList ContainmentInterface::actions() const { - //FIXME: giving directly a QList crashes + // FIXME: giving directly a QList crashes QStringList actionOrder; - actionOrder << QStringLiteral("add widgets") << QStringLiteral("manage activities") << QStringLiteral("remove") << QStringLiteral("lock widgets") << QStringLiteral("run associated application") << QStringLiteral("configure"); + actionOrder << QStringLiteral("add widgets") << QStringLiteral("manage activities") << QStringLiteral("remove") << QStringLiteral("lock widgets") + << QStringLiteral("run associated application") << QStringLiteral("configure"); QHash orderedActions; - //use a multimap to sort by action type + // use a multimap to sort by action type QMultiMap actions; int i = 0; auto listActions = m_containment->actions()->actions(); for (QAction *a : qAsConst(listActions)) { if (!actionOrder.contains(a->objectName())) { - //FIXME QML visualizations don't support menus for now, *and* there is no way to - //distinguish them on QML side + // FIXME QML visualizations don't support menus for now, *and* there is no way to + // distinguish them on QML side if (!a->menu()) { - actions.insert(a->data().toInt()*100 + i, a); + actions.insert(a->data().toInt() * 100 + i, a); ++i; } } else { @@ -841,15 +836,15 @@ QList ContainmentInterface::actions() const listActions = m_containment->corona()->actions()->actions(); for (QAction *a : qAsConst(listActions)) { if (a->objectName() == QLatin1String("lock widgets") || a->menu()) { - //It is up to the Containment to decide if the user is allowed or not - //to lock/unluck the widgets, so corona should not add one when there is none + // It is up to the Containment to decide if the user is allowed or not + // to lock/unluck the widgets, so corona should not add one when there is none //(user is not allow) and it shouldn't add another one when there is already - //one + // one continue; } if (!actionOrder.contains(a->objectName())) { - actions.insert(a->data().toInt()*100 + i, a); + actions.insert(a->data().toInt() * 100 + i, a); } else { orderedActions[a->objectName()] = a; } @@ -873,8 +868,7 @@ void ContainmentInterface::setContainmentDisplayHints(Plasma::Types::Containment m_containment->setContainmentDisplayHints(hints); } - -//PROTECTED-------------------- +// PROTECTED-------------------- void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event) { @@ -884,8 +878,8 @@ void ContainmentInterface::mouseReleaseEvent(QMouseEvent *event) void ContainmentInterface::mousePressEvent(QMouseEvent *event) { - //even if the menu is executed synchronously, other events may be processed - //by the qml incubator when plasma is loading, so we need to guard there + // even if the menu is executed synchronously, other events may be processed + // by the qml incubator when plasma is loading, so we need to guard there if (m_contextMenu) { m_contextMenu.data()->close(); return; @@ -899,9 +893,9 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) return; } - //the plugin can be a single action or a context menu - //Don't have an action list? execute as single action - //and set the event position as action data + // the plugin can be a single action or a context menu + // Don't have an action list? execute as single action + // and set the event position as action data if (plugin->contextualActions().length() == 1) { QAction *action = plugin->contextualActions().at(0); action->setData(event->pos()); @@ -910,7 +904,7 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) return; } - //FIXME: very inefficient appletAt() implementation + // FIXME: very inefficient appletAt() implementation Plasma::Applet *applet = nullptr; for (QObject *appletObject : qAsConst(m_appletInterfaces)) { if (AppletInterface *ai = qobject_cast(appletObject)) { @@ -922,14 +916,14 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) } } } - //qDebug() << "Invoking menu for applet" << applet; + // qDebug() << "Invoking menu for applet" << applet; QMenu *desktopMenu = new QMenu; - //this is a workaround where Qt now creates the menu widget - //in .exec before oxygen can polish it and set the following attribute + // this is a workaround where Qt now creates the menu widget + // in .exec before oxygen can polish it and set the following attribute desktopMenu->setAttribute(Qt::WA_TranslucentBackground); - //end workaround + // end workaround if (desktopMenu->winId()) { desktopMenu->windowHandle()->setTransientParent(window()); @@ -947,29 +941,28 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) addContainmentActions(desktopMenu, event); } - //this is a workaround where Qt will fail to realize a mouse has been released + // this is a workaround where Qt will fail to realize a mouse has been released // this happens if a window which does not accept focus spawns a new window that takes focus and X grab // whilst the mouse is depressed // https://bugreports.qt.io/browse/QTBUG-59044 // this causes the next click to go missing - //by releasing manually we avoid that situation + // by releasing manually we avoid that situation auto ungrabMouseHack = [this]() { if (window() && window()->mouseGrabberItem()) { window()->mouseGrabberItem()->ungrabMouse(); } }; - //pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)" - //post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse() + // pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)" + // post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse() if (QVersionNumber::fromString(QLatin1String(qVersion())) > QVersionNumber(5, 8, 0)) { QTimer::singleShot(0, this, ungrabMouseHack); - } - else { + } else { ungrabMouseHack(); } - //end workaround + // end workaround QPoint pos = event->globalPos(); if (window() && m_containment->containmentType() == Plasma::Types::PanelContainment) { @@ -1073,16 +1066,16 @@ void ContainmentInterface::addAppletActions(QMenu *desktopMenu, Plasma::Applet * addContainmentActions(desktopMenu, event); } - if (m_containment->immutability() == Plasma::Types::Mutable && - (m_containment->containmentType() != Plasma::Types::PanelContainment || m_containment->isUserConfiguring())) { + if (m_containment->immutability() == Plasma::Types::Mutable + && (m_containment->containmentType() != Plasma::Types::PanelContainment || m_containment->isUserConfiguring())) { QAction *closeApplet = applet->actions()->action(QStringLiteral("remove")); - //qDebug() << "checking for removal" << closeApplet; + // qDebug() << "checking for removal" << closeApplet; if (closeApplet) { if (!desktopMenu->isEmpty()) { desktopMenu->addSeparator(); } - //qDebug() << "adding close action" << closeApplet->isEnabled() << closeApplet->isVisible(); + // qDebug() << "adding close action" << closeApplet->isEnabled() << closeApplet->isVisible(); desktopMenu->addAction(closeApplet); } } @@ -1090,13 +1083,12 @@ void ContainmentInterface::addAppletActions(QMenu *desktopMenu, Plasma::Applet * void ContainmentInterface::addContainmentActions(QMenu *desktopMenu, QEvent *event) { - if (m_containment->corona()->immutability() != Plasma::Types::Mutable && - !KAuthorized::authorizeAction(QStringLiteral("plasma/containment_actions"))) { - //qDebug() << "immutability"; + if (m_containment->corona()->immutability() != Plasma::Types::Mutable && !KAuthorized::authorizeAction(QStringLiteral("plasma/containment_actions"))) { + // qDebug() << "immutability"; return; } - //this is what ContainmentPrivate::prepareContainmentActions was + // this is what ContainmentPrivate::prepareContainmentActions was const QString trigger = Plasma::ContainmentActions::eventToString(event); Plasma::ContainmentActions *plugin = m_containment->containmentActions().value(trigger); @@ -1117,11 +1109,10 @@ void ContainmentInterface::addContainmentActions(QMenu *desktopMenu, QEvent *eve QList actions = plugin->contextualActions(); if (actions.isEmpty()) { - //it probably didn't bother implementing the function. give the user a chance to set - //a better plugin. note that if the user sets no-plugin this won't happen... - if ((m_containment->containmentType() != Plasma::Types::PanelContainment && - m_containment->containmentType() != Plasma::Types::CustomPanelContainment) && - m_containment->actions()->action(QStringLiteral("configure"))) { + // it probably didn't bother implementing the function. give the user a chance to set + // a better plugin. note that if the user sets no-plugin this won't happen... + if ((m_containment->containmentType() != Plasma::Types::PanelContainment && m_containment->containmentType() != Plasma::Types::CustomPanelContainment) + && m_containment->actions()->action(QStringLiteral("configure"))) { desktopMenu->addAction(m_containment->actions()->action(QStringLiteral("configure"))); } } else { @@ -1140,5 +1131,4 @@ bool ContainmentInterface::isLoading() const return loading; } - #include "moc_containmentinterface.cpp" diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index e891a2e99..e526877ff 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -28,7 +28,6 @@ namespace KActivities class Info; } - /** * @class ContainmentInterface * @@ -44,7 +43,7 @@ class ContainmentInterface : public AppletInterface * List of applets this containment has: the containments * KF6: this should be AppletQuickItem * */ - Q_PROPERTY(QList applets READ applets NOTIFY appletsChanged) + Q_PROPERTY(QList applets READ applets NOTIFY appletsChanged) /** * Type of this containment TODO: notify @@ -75,12 +74,13 @@ class ContainmentInterface : public AppletInterface */ Q_PROPERTY(bool editMode READ isEditMode WRITE setEditMode NOTIFY editModeChanged) - Q_PROPERTY(Plasma::Types::ContainmentDisplayHints containmentDisplayHints READ containmentDisplayHints WRITE setContainmentDisplayHints NOTIFY containmentDisplayHintsChanged) + Q_PROPERTY(Plasma::Types::ContainmentDisplayHints containmentDisplayHints READ containmentDisplayHints WRITE setContainmentDisplayHints NOTIFY + containmentDisplayHintsChanged) public: ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args = QVariantList()); -//Not for QML + // Not for QML Plasma::Containment *containment() const { return m_containment.data(); @@ -91,7 +91,7 @@ public: return m_wallpaperInterface; } -//For QML use + // For QML use QList applets(); Plasma::Types::ContainmentType containmentType() const; @@ -184,7 +184,7 @@ Q_SIGNALS: */ void appletRemoved(QObject *applet); - //Property notifiers + // Property notifiers void activityChanged(); void activityNameChanged(); void appletsChanged(); diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp index d863cb639..0577829f9 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.cpp @@ -5,17 +5,17 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ +#include #include #include #include #include -#include #include #include #include -#include #include +#include #include #include @@ -29,25 +29,26 @@ #include "plasmoid/containmentinterface.h" #include "plasmoid/wallpaperinterface.h" -#include #include +#include DeclarativeAppletScript::DeclarativeAppletScript(QObject *parent, const QVariantList &args) - : Plasma::AppletScript(parent), - m_interface(nullptr), - m_args(args) + : Plasma::AppletScript(parent) + , m_interface(nullptr) + , m_args(args) { - //qmlRegisterType(); - //FIXME: use this if/when will be possible to have properties of attached items subclasses on the left hand of expressions + // qmlRegisterType(); + // FIXME: use this if/when will be possible to have properties of attached items subclasses on the left hand of expressions /*qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Plasmoid", QLatin1String("Do not create objects of type Plasmoid"));*/ - qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Plasmoid", - QStringLiteral("Do not create objects of type Plasmoid")); - qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Containment", - QStringLiteral("Do not create objects of type Containment")); + qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Plasmoid", QStringLiteral("Do not create objects of type Plasmoid")); + qmlRegisterUncreatableType("org.kde.plasma.plasmoid", + 2, + 0, + "Containment", + QStringLiteral("Do not create objects of type Containment")); - qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Wallpaper", - QStringLiteral("Do not create objects of type Wallpaper")); + qmlRegisterUncreatableType("org.kde.plasma.plasmoid", 2, 0, "Wallpaper", QStringLiteral("Do not create objects of type Wallpaper")); qmlRegisterAnonymousType("org.kde.plasma.plasmoid", 1); } @@ -58,9 +59,9 @@ DeclarativeAppletScript::~DeclarativeAppletScript() bool DeclarativeAppletScript::init() { - //make possible to import extensions from the package - //FIXME: probably to be removed, would make possible to use native code from within the package :/ - //m_interface->qmlObject()->engine()->addImportPath(package()->path()+"/contents/imports"); + // make possible to import extensions from the package + // FIXME: probably to be removed, would make possible to use native code from within the package :/ + // m_interface->qmlObject()->engine()->addImportPath(package()->path()+"/contents/imports"); Plasma::Applet *a = applet(); Plasma::Containment *pc = qobject_cast(a); @@ -68,7 +69,7 @@ bool DeclarativeAppletScript::init() if (pc && pc->isContainment()) { m_interface = new ContainmentInterface(this, m_args); - //fail? so it's a normal Applet + // fail? so it's a normal Applet } else { m_interface = new AppletInterface(this, m_args); } @@ -115,4 +116,3 @@ QList DeclarativeAppletScript::contextualActions() K_EXPORT_PLASMA_APPLETSCRIPTENGINE_WITH_JSON(plasma_appletscript_declarative, DeclarativeAppletScript, "plasma-scriptengine-applet-declarative.json") #include "declarativeappletscript.moc" - diff --git a/src/scriptengines/qml/plasmoid/dropmenu.cpp b/src/scriptengines/qml/plasmoid/dropmenu.cpp index 8e5eef070..e1c0274a0 100644 --- a/src/scriptengines/qml/plasmoid/dropmenu.cpp +++ b/src/scriptengines/qml/plasmoid/dropmenu.cpp @@ -9,20 +9,20 @@ #include "dropmenu.h" #include "containmentinterface.h" -#include -#include -#include -#include #include +#include +#include #include +#include +#include #include #include DropMenu::DropMenu(KIO::DropJob *dropJob, const QPoint &dropPoint, ContainmentInterface *parent) - : QObject(parent), - m_dropPoint(dropPoint), - m_dropJob(dropJob) + : QObject(parent) + , m_dropPoint(dropPoint) + , m_dropJob(dropJob) { if (!dropJob) { m_menu = new QMenu(i18n("Content dropped")); @@ -75,7 +75,7 @@ void DropMenu::addAction(QAction *action) bool DropMenu::isDropjobMenu() const { - return (m_dropJob? true : false); + return (m_dropJob ? true : false); } void DropMenu::setMultipleMimetypes(bool multipleMimetypes) @@ -90,5 +90,4 @@ bool DropMenu::isMultipleMimetypes() const return m_multipleMimetypes; } - #include "moc_dropmenu.cpp" diff --git a/src/scriptengines/qml/plasmoid/dropmenu.h b/src/scriptengines/qml/plasmoid/dropmenu.h index fe54ff86c..5cd3556e1 100644 --- a/src/scriptengines/qml/plasmoid/dropmenu.h +++ b/src/scriptengines/qml/plasmoid/dropmenu.h @@ -5,8 +5,8 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#ifndef DROPMENU_H -#define DROPMENU_H +#ifndef DROPMENU_H +#define DROPMENU_H #include #include diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp index 011cab366..222aa1a1b 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -11,12 +11,12 @@ #include #include -#include #include +#include #include -#include #include +#include #include #include @@ -25,15 +25,15 @@ QHash WallpaperInterface::s_rootObjects = QHash(); WallpaperInterface::WallpaperInterface(ContainmentInterface *parent) - : QQuickItem(parent), - m_containmentInterface(parent), - m_qmlObject(nullptr), - m_configuration(nullptr), - m_configLoader(nullptr) + : QQuickItem(parent) + , m_containmentInterface(parent) + , m_qmlObject(nullptr) + , m_configuration(nullptr) + , m_configLoader(nullptr) { m_actions = new KActionCollection(this); - //resize at the beginning to avoid as much resize events as possible + // resize at the beginning to avoid as much resize events as possible if (parent) { setSize(QSizeF(parent->width(), parent->height())); } @@ -41,9 +41,7 @@ WallpaperInterface::WallpaperInterface(ContainmentInterface *parent) if (!m_containmentInterface->containment()->wallpaper().isEmpty()) { syncWallpaperPackage(); } - connect(m_containmentInterface->containment(), &Plasma::Containment::wallpaperChanged, - this, &WallpaperInterface::syncWallpaperPackage); - + connect(m_containmentInterface->containment(), &Plasma::Containment::wallpaperChanged, this, &WallpaperInterface::syncWallpaperPackage); } WallpaperInterface::~WallpaperInterface() @@ -55,8 +53,7 @@ WallpaperInterface::~WallpaperInterface() QList WallpaperInterface::listWallpaperMetadataForMimetype(const QString &mimetype, const QString &formFactor) { - auto filter = [&mimetype, &formFactor](const KPluginMetaData &md) -> bool - { + auto filter = [&mimetype, &formFactor](const KPluginMetaData &md) -> bool { if (!formFactor.isEmpty() && !md.value(QStringLiteral("X-Plasma-FormFactors")).contains(formFactor)) { return false; } @@ -83,7 +80,7 @@ KDeclarative::ConfigPropertyMap *WallpaperInterface::configuration() const KConfigLoader *WallpaperInterface::configScheme() { if (!m_configLoader) { - //FIXME: do we need "mainconfigxml" in wallpaper packagestructures? + // FIXME: do we need "mainconfigxml" in wallpaper packagestructures? const QString xmlPath = m_pkg.filePath("config", QStringLiteral("main.xml")); KConfigGroup cfg = m_containmentInterface->containment()->config(); @@ -103,8 +100,7 @@ KConfigLoader *WallpaperInterface::configScheme() void WallpaperInterface::syncWallpaperPackage() { - if (m_wallpaperPlugin == m_containmentInterface->containment()->wallpaper() && - m_qmlObject->rootObject()) { + if (m_wallpaperPlugin == m_containmentInterface->containment()->wallpaper() && m_qmlObject->rootObject()) { return; } @@ -125,8 +121,10 @@ void WallpaperInterface::syncWallpaperPackage() return; } - if (m_configLoader) m_configLoader->deleteLater(); - if (m_configuration) m_configuration->deleteLater(); + if (m_configLoader) + m_configLoader->deleteLater(); + if (m_configuration) + m_configuration->deleteLater(); m_configLoader = nullptr; m_configuration = nullptr; if (configScheme()) { @@ -143,7 +141,7 @@ void WallpaperInterface::syncWallpaperPackage() m_qmlObject->setTranslationDomain(QLatin1String("plasma_wallpaper_") + m_pkg.metadata().pluginId()); } - //initialize with our size to avoid as much resize events as possible + // initialize with our size to avoid as much resize events as possible QVariantHash props; props[QStringLiteral("width")] = width(); props[QStringLiteral("height")] = height(); @@ -152,13 +150,11 @@ void WallpaperInterface::syncWallpaperPackage() void WallpaperInterface::loadFinished() { - if (m_qmlObject->mainComponent() && - m_qmlObject->rootObject() && - !m_qmlObject->mainComponent()->isError()) { + if (m_qmlObject->mainComponent() && m_qmlObject->rootObject() && !m_qmlObject->mainComponent()->isError()) { m_qmlObject->rootObject()->setProperty("z", -1000); m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this)); - //set anchors + // set anchors QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), QStringLiteral("parent")); QQmlProperty prop(m_qmlObject->rootObject(), QStringLiteral("anchors.fill")); prop.write(expr.evaluate()); @@ -246,10 +242,10 @@ void WallpaperInterface::executeAction(const QString &name) } } -WallpaperInterface * WallpaperInterface::qmlAttachedProperties(QObject* object) +WallpaperInterface *WallpaperInterface::qmlAttachedProperties(QObject *object) { - //at the moment of the attached object creation, the root item is the only one that hasn't a parent - //only way to avoid creation of this attached for everybody but the root item + // at the moment of the attached object creation, the root item is the only one that hasn't a parent + // only way to avoid creation of this attached for everybody but the root item return object->parent() ? nullptr : s_rootObjects.value(QtQml::qmlEngine(object)); } @@ -258,5 +254,4 @@ bool WallpaperInterface::isLoading() const return m_loading; } - #include "moc_wallpaperinterface.cpp" diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.h b/src/scriptengines/qml/plasmoid/wallpaperinterface.h index 8cbd3b42b..5412c0488 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.h +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.h @@ -7,8 +7,8 @@ #ifndef WALLPAPERINTERFACE_H #define WALLPAPERINTERFACE_H -#include #include +#include #include @@ -48,8 +48,7 @@ public: * @param formFactor the format of the wallpaper being search for (e.g. desktop) * @return list of wallpapers */ - static QList listWallpaperMetadataForMimetype(const QString &mimetype, - const QString &formFactor = QString()); + static QList listWallpaperMetadataForMimetype(const QString &mimetype, const QString &formFactor = QString()); KPackage::Package kPackage() const; @@ -65,8 +64,7 @@ public: void setUrl(const QUrl &urls); - Q_INVOKABLE void setAction(const QString &name, const QString &text, - const QString &icon = QString(), const QString &shortcut = QString()); + Q_INVOKABLE void setAction(const QString &name, const QString &text, const QString &icon = QString(), const QString &shortcut = QString()); Q_INVOKABLE void removeAction(const QString &name); diff --git a/templates/cpp-plasmoid/src/%{APPNAMELC}.cpp b/templates/cpp-plasmoid/src/%{APPNAMELC}.cpp index af1a5c591..e4bf53e4c 100644 --- a/templates/cpp-plasmoid/src/%{APPNAMELC}.cpp +++ b/templates/cpp-plasmoid/src/%{APPNAMELC}.cpp @@ -6,21 +6,32 @@ #include "%{APPNAMELC}.h" #include -%{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList &args) - : Plasma::Applet(parent, args), - m_nativeText(i18n("Text coming from C++ plugin")) +% +{ + APPNAME +} +:: + % {APPNAME}(QObject *parent, const QVariantList &args) + : Plasma::Applet(parent, args) +, m_nativeText(i18n("Text coming from C++ plugin")){} + + % +{ + APPNAME +} +::~ % {APPNAME}() { } -%{APPNAME}::~%{APPNAME}() +QString % { + APPNAME } - -QString %{APPNAME}::nativeText() const +::nativeText() const { return m_nativeText; } -K_EXPORT_PLASMA_APPLET_WITH_JSON(%{APPNAMELC}, %{APPNAME}, "metadata.json") +K_EXPORT_PLASMA_APPLET_WITH_JSON(% {APPNAMELC}, % {APPNAME}, "metadata.json") #include "%{APPNAMELC}.moc" diff --git a/templates/cpp-plasmoid/src/%{APPNAMELC}.h b/templates/cpp-plasmoid/src/%{APPNAMELC}.h index cc3ba148b..a5e3fa935 100644 --- a/templates/cpp-plasmoid/src/%{APPNAMELC}.h +++ b/templates/cpp-plasmoid/src/%{APPNAMELC}.h @@ -3,20 +3,19 @@ SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef %{APPNAMEUC}_H -#define %{APPNAMEUC}_H - +#ifndef % {APPNAMEUC } _H +#define % {APPNAMEUC } _H #include -class %{APPNAME} : public Plasma::Applet +class % {APPNAME} : public Plasma::Applet { Q_OBJECT Q_PROPERTY(QString nativeText READ nativeText CONSTANT) public: - %{APPNAME}( QObject *parent, const QVariantList &args ); - ~%{APPNAME}(); + % {APPNAME}(QObject * parent, const QVariantList &args); + ~ % {APPNAME}(); QString nativeText() const; diff --git a/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp b/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp index 1167a7154..cf345478d 100644 --- a/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp +++ b/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp @@ -9,10 +9,10 @@ #include // Qt #include -#include #include +#include -static QJSValue singletonTypeExampleProvider(QQmlEngine* engine, QJSEngine* scriptEngine) +static QJSValue singletonTypeExampleProvider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) @@ -21,8 +21,7 @@ static QJSValue singletonTypeExampleProvider(QQmlEngine* engine, QJSEngine* scri return helloWorld; } - -void %{APPNAME}Plugin::registerTypes(const char* uri) +void % {APPNAME} Plugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.%{APPNAMELC}")); diff --git a/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.h b/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.h index c87bd459c..93c8bd6ad 100644 --- a/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.h +++ b/templates/plasma-wallpaper-with-qml-extension/plugin/%{APPNAMELC}plugin.h @@ -3,12 +3,12 @@ SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef %{APPNAMEUC}PLUGIN_H -#define %{APPNAMEUC}PLUGIN_H +#ifndef % {APPNAMEUC } PLUGIN_H +#define % {APPNAMEUC } PLUGIN_H #include -class %{APPNAME}Plugin : public QQmlExtensionPlugin +class % {APPNAME} Plugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") diff --git a/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp b/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp index 1167a7154..cf345478d 100644 --- a/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp +++ b/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.cpp @@ -9,10 +9,10 @@ #include // Qt #include -#include #include +#include -static QJSValue singletonTypeExampleProvider(QQmlEngine* engine, QJSEngine* scriptEngine) +static QJSValue singletonTypeExampleProvider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) @@ -21,8 +21,7 @@ static QJSValue singletonTypeExampleProvider(QQmlEngine* engine, QJSEngine* scri return helloWorld; } - -void %{APPNAME}Plugin::registerTypes(const char* uri) +void % {APPNAME} Plugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.%{APPNAMELC}")); diff --git a/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.h b/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.h index c87bd459c..93c8bd6ad 100644 --- a/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.h +++ b/templates/qml-plasmoid-with-qml-extension/plugin/%{APPNAMELC}plugin.h @@ -3,12 +3,12 @@ SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef %{APPNAMEUC}PLUGIN_H -#define %{APPNAMEUC}PLUGIN_H +#ifndef % {APPNAMEUC } PLUGIN_H +#define % {APPNAMEUC } PLUGIN_H #include -class %{APPNAME}Plugin : public QQmlExtensionPlugin +class % {APPNAME} Plugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") diff --git a/tests/dpi/dpitest.cpp b/tests/dpi/dpitest.cpp index 11bea60cc..d90cc7e84 100644 --- a/tests/dpi/dpitest.cpp +++ b/tests/dpi/dpitest.cpp @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include namespace Plasma { @@ -25,8 +25,8 @@ public: QCommandLineParser *parser; }; -DPITest::DPITest(int &argc, char **argv, QCommandLineParser *parser) : - QGuiApplication(argc, argv) +DPITest::DPITest(int &argc, char **argv, QCommandLineParser *parser) + : QGuiApplication(argc, argv) { d = new DPITestPrivate; d->parser = parser; diff --git a/tests/dpi/dpitest.h b/tests/dpi/dpitest.h index 3519dfdc8..448b46c4f 100644 --- a/tests/dpi/dpitest.h +++ b/tests/dpi/dpitest.h @@ -14,7 +14,6 @@ class QCommandLineParser; namespace Plasma { - class DPITestPrivate; class DPITest : public QGuiApplication diff --git a/tests/dpi/main.cpp b/tests/dpi/main.cpp index f3c0b4369..c9b832552 100644 --- a/tests/dpi/main.cpp +++ b/tests/dpi/main.cpp @@ -5,10 +5,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ +#include +#include #include #include -#include -#include #include @@ -26,8 +26,9 @@ int main(int argc, char **argv) parser->addVersionOption(); parser->setApplicationDescription(description); - parser->addOption(QCommandLineOption(QStringList() << QStringLiteral("s") << QStringLiteral("show"), i18nc("Do not translate ", "Show icon sizes"), QStringLiteral("name"))); + parser->addOption(QCommandLineOption(QStringList() << QStringLiteral("s") << QStringLiteral("show"), + i18nc("Do not translate ", "Show icon sizes"), + QStringLiteral("name"))); return app.exec(); } - diff --git a/tests/kplugins/main.cpp b/tests/kplugins/main.cpp index 954f2a59b..78871285c 100644 --- a/tests/kplugins/main.cpp +++ b/tests/kplugins/main.cpp @@ -6,8 +6,8 @@ */ #include -#include #include +#include #include "plugintest.h" @@ -23,8 +23,9 @@ int main(int argc, char **argv) parser->addVersionOption(); parser->setApplicationDescription(description); - parser->addOption(QCommandLineOption(QStringList() << QStringLiteral("s") << QStringLiteral("show"), i18nc("Do not translate ", "Show plugins"), QStringLiteral("name"))); + parser->addOption(QCommandLineOption(QStringList() << QStringLiteral("s") << QStringLiteral("show"), + i18nc("Do not translate ", "Show plugins"), + QStringLiteral("name"))); return app.exec(); } - diff --git a/tests/kplugins/plugintest.cpp b/tests/kplugins/plugintest.cpp index 293cc673a..05f1450c2 100644 --- a/tests/kplugins/plugintest.cpp +++ b/tests/kplugins/plugintest.cpp @@ -8,32 +8,32 @@ #include -#include +#include #include #include #include #include -#include +#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include -#include #include +#include #include +#include #include #include #include #include -#include -#include #include +#include namespace Plasma { @@ -44,8 +44,8 @@ public: QCommandLineParser *parser; }; -PluginTest::PluginTest(int &argc, char **argv, QCommandLineParser *parser) : - QApplication(argc, argv) // QApp needed for CursorNotificationHandler (QWidget) +PluginTest::PluginTest(int &argc, char **argv, QCommandLineParser *parser) + : QApplication(argc, argv) // QApp needed for CursorNotificationHandler (QWidget) { d = new PluginTestPrivate; d->parser = parser; @@ -60,12 +60,12 @@ PluginTest::~PluginTest() void PluginTest::runMain() { qDebug() << "plugin test runs: "; - //loadDataEngine(); -// qDebug() << " - - - -- - - - - ------------------------------------\n"; -// qDebug() << " libs are in: " << QCoreApplication::libraryPaths(); -// //loadKQPlugin(); + // loadDataEngine(); + // qDebug() << " - - - -- - - - - ------------------------------------\n"; + // qDebug() << " libs are in: " << QCoreApplication::libraryPaths(); + // //loadKQPlugin(); qDebug() << "::: loadKPlugin() == " << loadKPlugin(); -// + // qDebug() << " - - - -- - - - - ------------------------------------\n"; qDebug() << "::: loadFromPlasma() == " << loadFromPlasma(); exit(0); @@ -78,18 +78,18 @@ bool PluginTest::loadKPlugin() qDebug() << "Load KPlugin"; QString pluginPath = QStringLiteral("/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/"); QCoreApplication::addLibraryPath(pluginPath); - //QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/libkqpluginfactory.so", this); + // QPluginLoader loader("/home/sebas/kf5/install/lib/x86_64-linux-gnu/kplugins/libkqpluginfactory.so", this); QPluginLoader loader(QStringLiteral("/home/sebas/kf5/install/lib/x86_64-linux-gnu/plugins/kf5/kplugins/libplasma_engine_time.so"), this); KPluginFactory *factory = qobject_cast(loader.instance()); - //QObject *factory = loader.instance(); + // QObject *factory = loader.instance(); if (factory) { qDebug() << "loaded successfully and cast"; qDebug() << "metadata: " << loader.metaData(); - //QObject *o = factory->createPlugin("time"); - //qDebug() << " objec name:" << o->objectName(); - //Plasma::DataEngine *time_engine = qobject_cast(factory->create(this, QVariantList())); + // QObject *o = factory->createPlugin("time"); + // qDebug() << " objec name:" << o->objectName(); + // Plasma::DataEngine *time_engine = qobject_cast(factory->create(this, QVariantList())); Plasma::DataEngine *time_engine = nullptr; -// Plasma::DataEngine *time_engine = factory->create(this, QVariantList()); + // Plasma::DataEngine *time_engine = factory->create(this, QVariantList()); time_engine = factory->create(this, QVariantList()); if (time_engine) { @@ -99,15 +99,13 @@ bool PluginTest::loadKPlugin() ok = true; } else { qDebug() << "Timeengine failed to load. :("; - } } else { qDebug() << "loading failed somehow"; } - //KQPluginFactory* factory = new KQPluginFactory(KPluginInfo(), this); + // KQPluginFactory* factory = new KQPluginFactory(KPluginInfo(), this); return ok; - } bool PluginTest::loadFromPlasma() @@ -124,7 +122,6 @@ bool PluginTest::loadFromPlasma() qDebug() << "SOURCE: " << engine->sources(); ok = true; } - } return ok; } @@ -172,4 +169,3 @@ void PluginTest::dataUpdated(QString s, Plasma::DataEngine::Data d) } // namespace Plasma #include "moc_plugintest.cpp" - diff --git a/tests/kplugins/plugintest.h b/tests/kplugins/plugintest.h index 6adc1ba27..d334b94ee 100644 --- a/tests/kplugins/plugintest.h +++ b/tests/kplugins/plugintest.h @@ -15,7 +15,6 @@ class QCommandLineParser; namespace Plasma { - class PluginTestPrivate; class PluginTest : public QApplication diff --git a/tests/testengine/testengine.cpp b/tests/testengine/testengine.cpp index fc3565676..d3df26133 100644 --- a/tests/testengine/testengine.cpp +++ b/tests/testengine/testengine.cpp @@ -7,18 +7,18 @@ #include "testengine.h" #include -#include -#include -#include #include #include #include +#include #include #include +#include #include #include #include #include +#include Q_DECLARE_METATYPE(TestEngine::MyUserType) @@ -70,7 +70,7 @@ void TestEngine::init() // QVariant::Image setData(dsn, QStringLiteral("QImage"), QVariant(QImage(56, 78, QImage::Format_Mono))); // QVariant::Int - setData(dsn, QStringLiteral("int"), QVariant((int) - 4321)); + setData(dsn, QStringLiteral("int"), QVariant((int)-4321)); // QVariant::KeySequence (???) // QVariant::Line setData(dsn, QStringLiteral("QLine"), QVariant(QLine(12, 34, 56, 78))); @@ -83,7 +83,7 @@ void TestEngine::init() // QVariant::Locale setData(dsn, QStringLiteral("QLocale"), QVariant(QLocale(QStringLiteral("fr_FR")))); // QVariant::LongLong - setData(dsn, QStringLiteral("qlonglong"), QVariant((qlonglong) - 4321)); + setData(dsn, QStringLiteral("qlonglong"), QVariant((qlonglong)-4321)); // QVariant::Map QMap map; for (int i = 0; i < 123; ++i) { diff --git a/tests/testengine/testengine.h b/tests/testengine/testengine.h index c552fbae9..802a4f748 100644 --- a/tests/testengine/testengine.h +++ b/tests/testengine/testengine.h @@ -19,7 +19,7 @@ class TestEngine : public Plasma::DataEngine public: struct MyUserType { - int a; + int a; QString b; };