diff --git a/kcms/lookandfeel/CMakeLists.txt b/kcms/lookandfeel/CMakeLists.txt index 0bbad4ea6..60d9431c8 100644 --- a/kcms/lookandfeel/CMakeLists.txt +++ b/kcms/lookandfeel/CMakeLists.txt @@ -1,59 +1,110 @@ # KI18N Translation Domain for this library add_definitions(-DTRANSLATION_DOMAIN=\"kcm_lookandfeel\") configure_file (config-kcm.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kcm.h ) set(kcm_lookandfeel_SRCS kcm.cpp ../krdb/krdb.cpp ../cursortheme/xcursor/cursortheme.cpp ../cursortheme/xcursor/xcursortheme.cpp ) set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml) qt5_add_dbus_interface(kcm_lookandfeel_SRCS ${klauncher_xml} klauncher_iface) add_library(kcm_lookandfeel MODULE ${kcm_lookandfeel_SRCS}) target_link_libraries(kcm_lookandfeel KF5::KIOWidgets KF5::CoreAddons KF5::KCMUtils KF5::I18n KF5::Plasma KF5::PlasmaQuick KF5::KDELibs4Support KF5::Declarative KF5::QuickAddons KF5::NewStuff Qt5::DBus Qt5::Widgets Qt5::QuickWidgets ${X11_LIBRARIES} ) if(X11_FOUND) target_link_libraries(kcm_lookandfeel Qt5::X11Extras) endif() if (X11_Xcursor_FOUND) target_link_libraries(kcm_lookandfeel ${X11_Xcursor_LIB}) endif () if (X11_Xfixes_FOUND) target_link_libraries(kcm_lookandfeel ${X11_Xfixes_LIB}) endif () kcoreaddons_desktop_to_json(kcm_lookandfeel "kcm_lookandfeel.desktop" SERVICE_TYPES kcmodule.desktop) #this desktop file is installed only for retrocompatibility with sycoca install(FILES kcm_lookandfeel.desktop DESTINATION ${SERVICES_INSTALL_DIR}) install(TARGETS kcm_lookandfeel DESTINATION ${PLUGIN_INSTALL_DIR}/kcms) install(FILES lookandfeel.knsrc DESTINATION ${KDE_INSTALL_CONFDIR}) if(BUILD_TESTING) find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED) add_subdirectory(autotests) endif() kpackage_install_package(package kcm_lookandfeel kcms) + +###### Command line tool + +set(lookandfeeltool_SRCS + lnftool.cpp + kcm.cpp + ../krdb/krdb.cpp + ../cursortheme/xcursor/cursortheme.cpp + ../cursortheme/xcursor/xcursortheme.cpp +) + +qt5_add_dbus_interface(lookandfeeltool_SRCS ${klauncher_xml} klauncher_iface) + +add_executable(lookandfeeltool ${lookandfeeltool_SRCS}) + +target_link_libraries(lookandfeeltool +# Qt5::Gui +# Qt5::Widgets +# KF5::Package +# KF5::I18n + + KF5::KIOWidgets + KF5::CoreAddons + KF5::KCMUtils + KF5::I18n + #TODO:kpackage +KF5::Plasma +KF5::PlasmaQuick + KF5::KDELibs4Support + KF5::Declarative + KF5::QuickAddons + KF5::NewStuff + + Qt5::DBus + Qt5::Widgets + Qt5::QuickWidgets + ${X11_LIBRARIES} +) + +if(X11_FOUND) + target_link_libraries(lookandfeeltool Qt5::X11Extras) +endif() +if (X11_Xcursor_FOUND) + target_link_libraries(lookandfeeltool ${X11_Xcursor_LIB}) +endif () +if (X11_Xfixes_FOUND) + target_link_libraries(lookandfeeltool ${X11_Xfixes_LIB}) +endif () + +install( TARGETS lookandfeeltool ${INSTALL_TARGETS_DEFAULT_ARGS} ) + diff --git a/kcms/lookandfeel/lnftool.cpp b/kcms/lookandfeel/lnftool.cpp new file mode 100644 index 000000000..df5fa2771 --- /dev/null +++ b/kcms/lookandfeel/lnftool.cpp @@ -0,0 +1,98 @@ +/* + * Copyright 2017 Marco MArtin + * + * 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, + * 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 "kcm.h" + +#include + +#include +#include +#include + +// Frameworks +#include +#include + +#include +#include + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + const QString description = i18n("Look and feel tool"); + const char version[] = "1.0"; + + // About data + KAboutData aboutData("lookandfeeltool", i18n("Look and feel tool"), version, i18n("Command line tool to apply look and feel packages."), KAboutLicense::GPL, i18n("Copyright 2017, Marco Martin")); + aboutData.addAuthor(i18n("Marco Martin"), i18n("Maintainer"), "mart@kde.org"); + aboutData.setDesktopFileName("org.kde.lookandfeeltool"); + KAboutData::setApplicationData(aboutData); + + const static auto _l = QStringLiteral("list"); + const static auto _a = QStringLiteral("apply"); + const static auto _r = QStringLiteral("resetLayout"); + + QCommandLineOption _list = QCommandLineOption(QStringList() << QStringLiteral("l") << _l, + i18n("List available Look and feel packages")); + QCommandLineOption _apply = QCommandLineOption(QStringList() << QStringLiteral("a") << _a, + i18n("Apply a look and feel package"), i18n("packagename")); + QCommandLineOption _resetLayout = QCommandLineOption(QStringList() << + _r, i18n("Reset the Plasma Desktop layout")); + + QCommandLineParser parser; + parser.addOption(_list); + parser.addOption(_apply); + parser.addOption(_resetLayout); + aboutData.setupCommandLine(&parser); + + parser.process(app); + aboutData.processCommandLine(&parser); + + if (!parser.isSet(_list) && !parser.isSet(_apply)) { + parser.showHelp(); + } + + if (parser.isSet(_list)) { + QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); + + for (const KPluginMetaData &data : pkgs) { + std::cout << data.pluginId().toStdString() << std::endl; + } + + } else if (parser.isSet(_apply)) { + KPackage::Package p = KPackage::PackageLoader::self()->loadPackage("Plasma/LookAndFeel"); + p.setPath(parser.value(_apply)); + + //can't use package.isValid as lnf packages always fallback, even when not existing + if (p.metadata().pluginId() != parser.value(_apply)) { + std::cout << "Unable to find the look and feel package named " << parser.value(_apply).toStdString() << std::endl; + return 1; + } + + KCMLookandFeel *kcm = new KCMLookandFeel(nullptr, QVariantList()); + kcm->load(); + kcm->setResetDefaultLayout(parser.isSet(_resetLayout)); + kcm->setSelectedPlugin(parser.value(_apply)); + kcm->save(); + } + + return 0; +} +