Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:rhabacker:branches:windows:mingw:win64
mingw64-kdelibs4support
0001-kf5-config-Add-support-for-printing-all-QL...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-kf5-config-Add-support-for-printing-all-QLibraryInfo.patch of Package mingw64-kdelibs4support
From e39cfa13cbfb9e6dd642a8a546e267a973b13ce3 Mon Sep 17 00:00:00 2001 From: Ralf Habacker <ralf.habacker@freenet.de> Date: Sat, 15 Aug 2020 14:40:22 +0200 Subject: [PATCH] kf5-config: Add support for printing all QLibraryInfo and QStandardPaths components --- kde-config.cpp | 116 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/kde-config.cpp b/kde-config.cpp index 0f2f429b..2a2c9b17 100644 --- a/kde-config.cpp +++ b/kde-config.cpp @@ -5,6 +5,7 @@ * Copyright (c) 2008 David Jarvie <djarvie@kde.org> * Copyright (c) 2006-2007 Christian Ehrlicher <Ch.Ehrlicher@gmx.de> * Copyright (c) 2000-2007 Stephan Kulow <coolo@kde.org> + * Copyright (c) 2020 Ralf Habacker <ralf.habacker@freenet.de> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -51,6 +52,74 @@ static void printResult(const QString &s) } } +static void printResult(const QStringList &l) +{ + if (l.size() == 0) { + printf("\n"); + } else { + Q_FOREACH(const QString &s, l) { + const QString path = QDir::toNativeSeparators(s); + printf("%s\n", path.toLocal8Bit().constData()); + } + } +} + +template <typename T> +class Type +{ +public: + T _value; + const char *_help; + + Type(T value = static_cast<T>(0), const char *help = "") + : _value(value) + , _help(help) + {} +}; + +typedef Type<QLibraryInfo::LibraryLocation> QLIType; +typedef Type<QStandardPaths::StandardLocation> QSPType; +typedef QString(*QLibraryInfoLocation)(QLibraryInfo::LibraryLocation); +typedef QStringList(*QStandardPathsStandardLocation)(QStandardPaths::StandardLocation); + +template <typename T, typename FType> +class TypeMap : public QMap<const char*,Type<T>> +{ +public: + typedef QMap<const char*,Type<T>> MapType; + TypeMap(const char *prefix, FType function) + : _prefix(prefix) + , _function(function) + { + } + + void addToOptions(KCmdLineOptions &options, const char *defaultText = "") + { + MapType &map = *this; + Q_FOREACH(const char *key, map.keys()) { + options.add(QString("%1-%2").arg(_prefix, key).toLocal8Bit(), + ki18n(map[key]._help && *map[key]._help ? map[key]._help : + QString(QLatin1String(defaultText)).arg(key).toLocal8Bit().constData())); + } + } + + bool processArgs(KCmdLineArgs *args) + { + MapType &map = *this; + Q_FOREACH(const char *key, map.keys()) { + if (args->isSet(QString("%1-%2").arg(_prefix, key).toLocal8Bit())) { + printResult((*_function)(map[key]._value)); + return true; + } + } + return false; + } + +protected: + const char *_prefix; + FType _function; +}; + int main(int argc, char **argv) { QCoreApplication app(argc, argv); @@ -60,6 +129,45 @@ int main(int argc, char **argv) ki18n("(C) 2000 Stephan Kulow")); KCmdLineArgs::init(argc, argv, &about); + TypeMap<QLibraryInfo::LibraryLocation, QLibraryInfoLocation> qMap("qli", &QLibraryInfo::location); + qMap["archdata"] = QLIType(QLibraryInfo::ArchDataPath); + qMap["binaries"] = QLIType(QLibraryInfo::BinariesPath); + qMap["data"] = QLIType(QLibraryInfo::DataPath); + qMap["documentation"] = QLIType(QLibraryInfo::DocumentationPath); + qMap["examples"] = QLIType(QLibraryInfo::ExamplesPath); + qMap["headers"] = QLIType(QLibraryInfo::HeadersPath); + qMap["imports"] = QLIType(QLibraryInfo::ImportsPath); + qMap["libraries"] = QLIType(QLibraryInfo::LibrariesPath); + qMap["libraryexecutables"] = QLIType(QLibraryInfo::LibraryExecutablesPath); + qMap["plugins"] = QLIType(QLibraryInfo::PluginsPath); + qMap["prefix"] = QLIType(QLibraryInfo::PrefixPath, "Installation prefix for Qt"); + qMap["qml2imports"] = QLIType(QLibraryInfo::Qml2ImportsPath); + qMap["settings"] = QLIType(QLibraryInfo::SettingsPath); + qMap["tests"] = QLIType(QLibraryInfo::TestsPath); + qMap["translations"] = QLIType(QLibraryInfo::TranslationsPath); + + TypeMap<QStandardPaths::StandardLocation, QStandardPathsStandardLocation> qspMap("qsp", &QStandardPaths::standardLocations); + qspMap["AppConfig"] = QSPType(QStandardPaths::AppConfigLocation); + qspMap["AppData"] = QSPType(QStandardPaths::AppDataLocation); + qspMap["AppLocalData"] = QSPType(QStandardPaths::AppLocalDataLocation); + qspMap["Applications"] = QSPType(QStandardPaths::ApplicationsLocation); + qspMap["Cache"] = QSPType(QStandardPaths::CacheLocation); + qspMap["Config"] = QSPType(QStandardPaths::ConfigLocation); + qspMap["Data"] = QSPType(QStandardPaths::DataLocation); + qspMap["Desktop"] = QSPType(QStandardPaths::DesktopLocation); + qspMap["Documents"] = QSPType(QStandardPaths::DocumentsLocation); + qspMap["Download"] = QSPType(QStandardPaths::DownloadLocation); + qspMap["Fonts"] = QSPType(QStandardPaths::FontsLocation); + qspMap["GenericCache"] = QSPType(QStandardPaths::GenericCacheLocation); + qspMap["GenericConfig"] = QSPType(QStandardPaths::GenericConfigLocation); + qspMap["GenericData"] = QSPType(QStandardPaths::GenericDataLocation); + qspMap["Home"] = QSPType(QStandardPaths::HomeLocation); + qspMap["Movies"] = QSPType(QStandardPaths::MoviesLocation); + qspMap["Music"] = QSPType(QStandardPaths::MusicLocation); + qspMap["Pictures"] = QSPType(QStandardPaths::PicturesLocation); + qspMap["Runtime"] = QSPType(QStandardPaths::RuntimeLocation); + qspMap["Temp"] = QSPType(QStandardPaths::TempLocation); + KCmdLineOptions options; options.add("expandvars", ki18n("Left for legacy support")); options.add("prefix", ki18n("Compiled in prefix for KDE libraries")); @@ -76,6 +184,8 @@ int main(int argc, char **argv) options.add("qt-binaries", ki18n("Location of installed Qt binaries")); options.add("qt-libraries", ki18n("Location of installed Qt libraries")); options.add("qt-plugins", ki18n("Location of installed Qt plugins")); + qMap.addToOptions(options, "Location of QLibraryInfo component (%1)"); + qspMap.addToOptions(options, "Location of QStandardPaths component (%1)"); KCmdLineArgs::addCmdLineOptions(options); // Add my own options. (void)KGlobal::dirs(); // trigger the creation @@ -167,6 +277,12 @@ int main(int argc, char **argv) return 0; } + if (qMap.processArgs(args)) + return 0; + + if (qspMap.processArgs(args)) + return 0; + QString type = args->getOption("path"); if (!type.isEmpty()) { QString fileName = args->getOption("locate"); -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor