diff --git a/cuttlefish/src/main.cpp b/cuttlefish/src/main.cpp index 7dd4617..4031707 100644 --- a/cuttlefish/src/main.cpp +++ b/cuttlefish/src/main.cpp @@ -1,131 +1,136 @@ /*************************************************************************** * * * Copyright 2014 Sebastian Kügler * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ // Qt #include #include #include #include #include #include #include // Frameworks #include #include #include #include #include // Own #include "iconmodel.h" void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { if ((msg.contains("qt.svg") && msg.contains("Could not resolve property: #linearGradient")) || msg.contains("Could not resolve property: #pattern")) { return; } QByteArray localMsg = msg.toLocal8Bit(); const char *file = context.file ? context.file : ""; const char *function = context.function ? context.function : ""; switch (type) { case QtDebugMsg: fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtInfoMsg: fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtWarningMsg: fprintf(stderr, "\u001b[33mWarning\u001b[0m: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtCriticalMsg: fprintf(stderr, "\u001b[33;1mCritical\u001b[0m: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtFatalMsg: fprintf(stderr, "\u001b[31;1mFatal\u001b[0m: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; } } int main(int argc, char **argv) { qInstallMessageHandler(messageOutput); QApplication app(argc, argv); KLocalizedString::setApplicationDomain("cuttlefish"); app.setApplicationVersion(PROJECT_VERSION); app.setDesktopFileName(QStringLiteral("org.kde.cuttlefish")); app.setOrganizationName("KDE"); app.setOrganizationDomain("org.kde"); app.setApplicationName("Cuttlefish"); const static auto _category = QStringLiteral("category"); QCommandLineOption category = QCommandLineOption(QStringList() << QStringLiteral("c") << _category, i18n("Start with category"), i18n("category")); const static auto _f = QStringLiteral("fullscreen"); QCommandLineOption fullscreen = QCommandLineOption(QStringList() << QStringLiteral("f") << _f, i18n("Start full-screen")); const static auto _p = QStringLiteral("picker"); QCommandLineOption picker = QCommandLineOption(QStringList() << QStringLiteral("p") << _p, i18n("Run in icon-picker mode")); QCommandLineParser parser; parser.addVersionOption(); parser.setApplicationDescription("Cuttlefish Icon Browser"); parser.addHelpOption(); parser.addOption(category); parser.addOption(fullscreen); parser.addOption(picker); parser.process(app); QString _cc = parser.value(category); QQmlApplicationEngine engine; KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(qobject_cast(&engine)); kdeclarative.setTranslationDomain(QStringLiteral("cuttlefish")); kdeclarative.setupBindings(); auto package = KPackage::PackageLoader::self()->loadPackage("Plasma/Generic"); package.setPath("org.kde.plasma.cuttlefish"); if (!package.isValid() || !package.metadata().isValid()) { qWarning() << "Could not load package org.kde.plasma.cuttlefish:" << package.path(); return -1; } engine.load(QUrl::fromLocalFile(package.filePath("mainscript"))); if (engine.rootObjects().isEmpty()) return -1; auto iconModel = new CuttleFish::IconModel(engine.rootContext()); engine.rootContext()->setContextProperty("iconModel", iconModel); engine.rootContext()->setContextProperty("pickerMode", parser.isSet("picker")); + +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) qmlRegisterType(); +#else + qmlRegisterAnonymousType("org.kde.plasma.sdk", 1); +#endif return app.exec(); } diff --git a/lookandfeelexplorer/src/main.cpp b/lookandfeelexplorer/src/main.cpp index ff4af3e..d6a1216 100644 --- a/lookandfeelexplorer/src/main.cpp +++ b/lookandfeelexplorer/src/main.cpp @@ -1,97 +1,102 @@ /* * Copyright 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "lnflogic.h" #include "lnflistmodel.h" #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { QCommandLineParser parser; QApplication app(argc, argv); app.setApplicationVersion(PROJECT_VERSION); parser.addVersionOption(); parser.addHelpOption(); parser.setApplicationDescription(i18n("Plasma Look And Feel Explorer")); QCommandLineOption themeOption(QCommandLineOption(QStringList() << "l" << "lookandfeel", i18n("Look And Feel to open"), "lookandfeel")); parser.addOption(themeOption); parser.process(app); const QString packagePath("org.kde.plasma.lookandfeelexplorer"); //usually we have an ApplicationWindow here, so we do not need to create a window by ourselves KDeclarative::QmlObject obj; obj.setTranslationDomain(packagePath); obj.setInitializationDelayed(true); obj.engine()->rootContext()->setContextProperty("commandlineTheme", parser.value(themeOption)); obj.engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments()); obj.loadPackage(packagePath); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) qmlRegisterType(); qmlRegisterType(); +#else + qmlRegisterAnonymousType("org.kde.plasma.sdk", 1); + qmlRegisterAnonymousType("org.kde.plasma.sdk", 1); +#endif LnfLogic *lnfLogic = new LnfLogic(&obj); obj.engine()->rootContext()->setContextProperty("lnfLogic", QVariant::fromValue(lnfLogic)); obj.completeInitialization(); if (!obj.package().metadata().isValid()) { return -1; } KPluginMetaData data = obj.package().metadata(); // About data KAboutData aboutData(data.pluginId(), data.name(), data.version(), data.description(), KAboutLicense::byKeyword(data.license()).key()); for (auto author : data.authors()) { aboutData.addAuthor(author.name(), author.task(), author.emailAddress(), author.webAddress(), author.ocsUsername()); } //The root is not a window? //have to use a normal QQuickWindow since the root item is already created QWindow *window = qobject_cast(obj.rootObject()); if (window) { window->setTitle(obj.package().metadata().name()); window->setIcon(QIcon::fromTheme(obj.package().metadata().iconName())); } else { qWarning() << "Error loading the ApplicationWindow"; } return app.exec(); } diff --git a/themeexplorer/src/main.cpp b/themeexplorer/src/main.cpp index 1b78d6b..cdf76a4 100644 --- a/themeexplorer/src/main.cpp +++ b/themeexplorer/src/main.cpp @@ -1,106 +1,111 @@ /* * Copyright 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "themelistmodel.h" #include "thememodel.h" #include "coloreditor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { QApplication app(argc, argv); app.setApplicationVersion(PROJECT_VERSION); QCommandLineParser parser; parser.addVersionOption(); parser.addHelpOption(); parser.setApplicationDescription(i18n("Plasma Theme Explorer")); QCommandLineOption themeOption(QCommandLineOption(QStringList() << "t" << "theme", i18n("The theme to open"), "theme")); parser.addOption(themeOption); parser.process(app); const QString packagePath("org.kde.plasma.themeexplorer"); //usually we have an ApplicationWindow here, so we do not need to create a window by ourselves KDeclarative::QmlObject *obj = new KDeclarative::QmlObject(); obj->setTranslationDomain(packagePath); obj->setInitializationDelayed(true); obj->loadPackage(packagePath); obj->engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments()); QObject::connect(obj->engine(), &QQmlEngine::quit, &app, &QApplication::quit); +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) qmlRegisterType(); qmlRegisterType(); +#else + qmlRegisterAnonymousType("org.kde.plasma.sdk", 1); + qmlRegisterAnonymousType("org.kde.plasma.sdk", 1); +#endif ThemeModel *themeModel = new ThemeModel(obj->package()); if (parser.isSet(themeOption)) { themeModel->setTheme(parser.value(themeOption)); obj->engine()->rootContext()->setContextProperty("commandlineTheme", parser.value(themeOption)); } else { themeModel->setTheme(parser.value("default")); obj->engine()->rootContext()->setContextProperty("commandlineTheme", "default"); } obj->engine()->rootContext()->setContextProperty("themeModel", QVariant::fromValue(themeModel)); obj->completeInitialization(); if (!obj->package().metadata().isValid()) { return -1; } KPluginMetaData data = obj->package().metadata(); // About data KAboutData aboutData(data.pluginId(), data.name(), data.version(), data.description(), KAboutLicense::byKeyword(data.license()).key()); for (auto author : data.authors()) { aboutData.addAuthor(author.name(), author.task(), author.emailAddress(), author.webAddress(), author.ocsUsername()); } //The root is not a window? //have to use a normal QQuickWindow since the root item is already created QWindow *window = qobject_cast(obj->rootObject()); if (window) { window->setTitle(obj->package().metadata().name()); window->setIcon(QIcon::fromTheme(obj->package().metadata().iconName())); } else { qWarning() << "Error loading the ApplicationWindow"; } return app.exec(); }