Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:rhabacker:branches:windows:mingw:win32:KF565
mingw32-kconfig
kconfig-desktop-translations.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kconfig-desktop-translations.patch of Package mingw32-kconfig
Index: kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfig.cpp =================================================================== --- kconfig-5.44.0git.20180504T173454~5625e0d.orig/src/core/kconfig.cpp +++ kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfig.cpp @@ -983,6 +983,19 @@ QByteArray KConfigPrivate::lookupData(co return it->mValue; } +QByteArray KConfigPrivate::lookupExactData(const QByteArray &group, const char *key, + KEntryMap::SearchFlags flags) const +{ + if (bReadDefaults) { + flags |= KEntryMap::SearchDefaults; + } + const KEntryMapConstIterator it = entryMap.findExactEntry(group, key, flags); + if (it == entryMap.constEnd()) { + return QByteArray(); + } + return it->mValue; +} + QString KConfigPrivate::lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const { Index: kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfig_p.h =================================================================== --- kconfig-5.44.0git.20180504T173454~5625e0d.orig/src/core/kconfig_p.h +++ kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfig_p.h @@ -47,6 +47,7 @@ public: QString lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags, bool *expand) const; QByteArray lookupData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const; + QByteArray lookupExactData(const QByteArray &group, const char *key, KEntryMap::SearchFlags flags) const; void putData(const QByteArray &group, const char *key, const QByteArray &value, KConfigBase::WriteConfigFlags flags, bool expand = false); Index: kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfigdata.h =================================================================== --- kconfig-5.44.0git.20180504T173454~5625e0d.orig/src/core/kconfigdata.h +++ kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfigdata.h @@ -180,6 +180,19 @@ public: Iterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); + ConstIterator findExactEntry(const QByteArray &group, const QByteArray &key = QByteArray(), + SearchFlags flags = SearchFlags()) const + { + KEntryKey theKey(group, key, false, bool(flags & SearchDefaults)); + + // try the localized key first + if (flags & SearchLocalized) { + theKey.bLocal = true; + return find(theKey); + } + return find(theKey); + } + Iterator findEntry(const QByteArray &group, const QByteArray &key = QByteArray(), SearchFlags flags = SearchFlags()); Index: kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfiggroup.cpp =================================================================== --- kconfig-5.44.0git.20180504T173454~5625e0d.orig/src/core/kconfiggroup.cpp +++ kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfiggroup.cpp @@ -1201,6 +1201,18 @@ bool KConfigGroup::hasKey(const char *ke return !config()->d_func()->lookupData(d->fullName(), key, flags).isNull(); } +bool KConfigGroup::hasTranslatedKey(const char *key) const +{ + Q_ASSERT_X(isValid(), "KConfigGroup::hasTranslatedKey", "accessing an invalid group"); + + KEntryMap::SearchFlags flags = KEntryMap::SearchLocalized; + if (config()->readDefaults()) { + flags |= KEntryMap::SearchDefaults; + } + + return !config()->d_func()->lookupExactData(d->fullName(), key, flags).isNull(); +} + bool KConfigGroup::hasKey(const QString &key) const { return hasKey(key.toUtf8().constData()); Index: kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfiggroup.h =================================================================== --- kconfig-5.44.0git.20180504T173454~5625e0d.orig/src/core/kconfiggroup.h +++ kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kconfiggroup.h @@ -623,6 +623,11 @@ public: */ QMap<QString, QString> entryMap() const; + /** + * @internal + */ + bool hasTranslatedKey(const char *key) const; + protected: bool hasGroupImpl(const QByteArray &group) const override; KConfigGroup groupImpl(const QByteArray &b) override; Index: kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kdesktopfile.cpp =================================================================== --- kconfig-5.44.0git.20180504T173454~5625e0d.orig/src/core/kdesktopfile.cpp +++ kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kdesktopfile.cpp @@ -29,6 +29,7 @@ #include <QFileInfo> #include <QUrl> #include <qstandardpaths.h> +#include <libintl.h> #include "kauthorized.h" #include "kconfig_p.h" @@ -169,6 +170,33 @@ bool KDesktopFile::isAuthorizedDesktopFi return false; } +QString KDesktopFile::translatedEntry(const char *key) const +{ + Q_D(const KDesktopFile); + if (d->desktopGroup.hasTranslatedKey(key)) { + return d->desktopGroup.readEntry(key); + } + + if (d->desktopGroup.hasKey(key)) { + QString value = d->desktopGroup.readEntryUntranslated(key); + QString fName = fileName(); + fName = fName.mid(fName.lastIndexOf(QLatin1Char('/'))+1); + QString po_lookup_key = QString::fromLatin1(key) + QStringLiteral("(") + fName + QStringLiteral("): ") + value; + char *msgid = strdup(po_lookup_key.toUtf8().constData()); + const char *po_value = dgettext("desktop_translations", msgid); + + if (po_value == msgid) { + free(msgid); + return value; + } + + free(msgid); + return QString::fromUtf8(po_value); + } + + return QString(); +} + QString KDesktopFile::readType() const { Q_D(const KDesktopFile); @@ -183,20 +211,17 @@ QString KDesktopFile::readIcon() const QString KDesktopFile::readName() const { - Q_D(const KDesktopFile); - return d->desktopGroup.readEntry("Name", QString()); + return translatedEntry("Name"); } QString KDesktopFile::readComment() const { - Q_D(const KDesktopFile); - return d->desktopGroup.readEntry("Comment", QString()); + return translatedEntry("Comment"); } QString KDesktopFile::readGenericName() const { - Q_D(const KDesktopFile); - return d->desktopGroup.readEntry("GenericName", QString()); + return translatedEntry("GenericName"); } QString KDesktopFile::readPath() const Index: kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kdesktopfile.h =================================================================== --- kconfig-5.44.0git.20180504T173454~5625e0d.orig/src/core/kdesktopfile.h +++ kconfig-5.44.0git.20180504T173454~5625e0d/src/core/kdesktopfile.h @@ -255,6 +255,8 @@ protected: // virtual void virtual_hook( int id, void* data ); private: + QString translatedEntry(const char *) const; + Q_DISABLE_COPY(KDesktopFile) Q_DECLARE_PRIVATE(KDesktopFile)
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