Qt Utilities  5.8.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
resources.h
Go to the documentation of this file.
1 #ifndef APPLICATION_UTILITIES_RESOURCES_H
2 #define APPLICATION_UTILITIES_RESOURCES_H
3 
4 #include "../global.h"
5 
6 #include <QtGlobal>
7 
8 #include <initializer_list>
9 
10 QT_FORWARD_DECLARE_CLASS(QString)
11 QT_FORWARD_DECLARE_CLASS(QStringList)
12 QT_FORWARD_DECLARE_CLASS(QSettings)
13 
14 
17 #define SET_QT_APPLICATION_INFO \
18  QCoreApplication::setOrganizationName(QStringLiteral(APP_AUTHOR)); \
19  QCoreApplication::setOrganizationDomain(QStringLiteral(APP_URL)); \
20  QCoreApplication::setApplicationName(QStringLiteral(APP_NAME)); \
21  QCoreApplication::setApplicationVersion(QStringLiteral(APP_VERSION)); \
22  QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true)
23 
27 #define LOAD_QT_TRANSLATIONS \
28  TranslationFiles::loadQtTranslationFile(QT_TRANSLATION_FILES); \
29  TranslationFiles::loadApplicationTranslationFile(APP_SPECIFIC_QT_TRANSLATION_FILES)
30 
32 
35 } // namespace QtUtilitiesResources
36 
37 namespace TranslationFiles {
38 
40 QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames);
41 QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames, const QString &localeName);
42 QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &applicationName);
43 QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &applicationName, const QString &localeName);
44 QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const std::initializer_list<QString> &applicationNames);
45 QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const std::initializer_list<QString> &applicationNames, const QString &localeName);
46 } // namespace TranslationFiles
47 
49 
50 #if defined(QT_UTILITIES_GUI_QTWIDGETS)
51 QT_UTILITIES_EXPORT bool hasWidgetsApp();
52 #endif
53 #if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK)
54 QT_UTILITIES_EXPORT bool hasGuiApp();
55 #endif
57 }
58 
59 namespace ConfigFile {
60 
61 QT_UTILITIES_EXPORT QString locateConfigFile(const QString &applicationName, const QString &fileName, const QSettings *settings = nullptr);
62 }
63 
64 #endif // APPLICATION_UTILITIES_RESOURCES_H
QT_UTILITIES_EXPORT void cleanup()
Frees the resources used and provided by this library.
Definition: resources.cpp:61
QT_UTILITIES_EXPORT bool hasCoreApp()
Returns whether a QCoreApplication has been instantiated yet.
Definition: resources.cpp:267
Convenience functions to load translations for Qt and the application.
Definition: resources.h:37
QT_UTILITIES_EXPORT QString locateConfigFile(const QString &applicationName, const QString &fileName, const QSettings *settings=nullptr)
Locates the config file with the specified fileName for the application with the specified applicatio...
Definition: resources.cpp:284
QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list< QString > repositoryNames, const QString &localeName)
QT_UTILITIES_EXPORT QString & additionalTranslationFilePath()
Allows to set an additional search path for translation files.
Definition: resources.cpp:76
QT_UTILITIES_EXPORT void init()
Initiates the resources used and provided by this library.
Definition: resources.cpp:52
Convenience functions to check whether a QCoreApplication/QGuiApplication/QApplication singleton has ...
Definition: resources.h:48
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const std::initializer_list< QString > &applicationNames, const QString &localeName)
Loads and installs the appropriate application translation file for the specified locale...
Definition: resources.cpp:229
Provides convenience functions for handling config files.
Definition: resources.h:59