| 1 |
#ifndef APPLICATION_UTILITIES_RESOURCES_H |
| 2 |
#define APPLICATION_UTILITIES_RESOURCES_H |
| 3 |
|
| 4 |
#include "../global.h" |
| 5 |
|
| 6 |
#include <QString> |
| 7 |
#include <QtContainerFwd> |
| 8 |
#include <QtGlobal> |
| 9 |
|
| 10 |
#include <initializer_list> |
| 11 |
#include <memory> |
| 12 |
|
| 13 |
QT_FORWARD_DECLARE_CLASS(QString) |
| 14 |
QT_FORWARD_DECLARE_CLASS(QSettings) |
| 15 |
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) |
| 16 |
QT_FORWARD_DECLARE_CLASS(QStringList) |
| 17 |
#endif |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
#define SET_QT_DESKTOP_FILE_NAME |
| 26 |
#if defined(Q_OS_LINUX) && defined(qGuiApp) && defined(APP_ID) |
| 27 |
#undef SET_QT_DESKTOP_FILE_NAME |
| 28 |
#define SET_QT_DESKTOP_FILE_NAME QGuiApplication::setDesktopFileName(QStringLiteral(APP_ID)); |
| 29 |
#endif |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
#define SET_QT_APPLICATION_INFO \ |
| 37 |
QCoreApplication::setOrganizationName(QStringLiteral(APP_AUTHOR)); \ |
| 38 |
QCoreApplication::setOrganizationDomain(QStringLiteral(APP_DOMAIN)); \ |
| 39 |
QCoreApplication::setApplicationName(QStringLiteral(APP_NAME)); \ |
| 40 |
QCoreApplication::setApplicationVersion(QStringLiteral(APP_VERSION)); \ |
| 41 |
SET_QT_DESKTOP_FILE_NAME \ |
| 42 |
::QtUtilities::setupCommonQtApplicationAttributes() |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
#define LOAD_QT_TRANSLATIONS \ |
| 48 |
QtUtilities::TranslationFiles::loadQtTranslationFile(QT_TRANSLATION_FILES); \ |
| 49 |
QtUtilities::TranslationFiles::loadApplicationTranslationFile(QStringLiteral(PROJECT_CONFIG_NAME), APP_SPECIFIC_QT_TRANSLATION_FILES) |
| 50 |
|
| 51 |
namespace QtUtilities { |
| 52 |
|
| 53 |
namespace QtUtilitiesResources { |
| 54 |
|
| 55 |
QT_UTILITIES_EXPORT void init(); |
| 56 |
QT_UTILITIES_EXPORT void cleanup(); |
| 57 |
} |
| 58 |
|
| 59 |
namespace TranslationFiles { |
| 60 |
|
| 61 |
QT_UTILITIES_EXPORT QString &additionalTranslationFilePath(); |
| 62 |
QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames); |
| 63 |
QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames, const QString &localeName); |
| 64 |
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &configName, const QString &applicationName); |
| 65 |
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &configName, const QString &applicationName, const QString &localeName); |
| 66 |
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &configName, const std::initializer_list<QString> &applicationNames); |
| 67 |
QT_UTILITIES_EXPORT void loadApplicationTranslationFile( |
| 68 |
const QString &configName, const std::initializer_list<QString> &applicationNames, const QString &localeName); |
| 69 |
QT_UTILITIES_EXPORT void clearTranslationFiles(); |
| 70 |
} |
| 71 |
|
| 72 |
namespace ApplicationInstances { |
| 73 |
|
| 74 |
#if defined(QT_UTILITIES_GUI_QTWIDGETS) |
| 75 |
QT_UTILITIES_EXPORT bool hasWidgetsApp(); |
| 76 |
#endif |
| 77 |
#if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) |
| 78 |
QT_UTILITIES_EXPORT bool hasGuiApp(); |
| 79 |
#endif |
| 80 |
QT_UTILITIES_EXPORT bool hasCoreApp(); |
| 81 |
} |
| 82 |
|
| 83 |
QT_UTILITIES_EXPORT void setupCommonQtApplicationAttributes(); |
| 84 |
QT_UTILITIES_EXPORT std::unique_ptr<QSettings> getSettings(const QString &organization, const QString &application = QString()); |
| 85 |
QT_UTILITIES_EXPORT QString errorMessageForSettings(const QSettings &settings); |
| 86 |
QT_UTILITIES_EXPORT void loadSettingsWithLogging(QSettings &settings); |
| 87 |
QT_UTILITIES_EXPORT void saveSettingsWithLogging(QSettings &settings); |
| 88 |
QT_UTILITIES_EXPORT void deletePipelineCacheIfNeeded(); |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
#endif |