Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-06-02 12:19:43 +0300
committerHannah von Reth <vonreth@kde.org>2021-06-02 13:40:18 +0300
commite8ddd54e03617452950b47ff684eee1fa74a0228 (patch)
tree8b4b120b163c6283fd043a67d4e14a2b68568ec0 /src
parent4765998c6c7f9eea0bd10907caa98d564ac49d74 (diff)
Cleanup the data location handling
Diffstat (limited to 'src')
-rw-r--r--src/gui/CMakeLists.txt10
-rw-r--r--src/gui/application.cpp6
-rw-r--r--src/gui/translations.cpp18
3 files changed, 19 insertions, 15 deletions
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index e5fde597c..ae8bbfc20 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -233,11 +233,11 @@ if(NOT APPLE)
foreach(_file ${_icons})
string(REPLACE "${OEM_THEME_DIR}/theme/colored/" "" _res ${_file})
string(REPLACE "-${APPLICATION_ICON_NAME}-icon.png" "" _res ${_res})
- install(FILES ${_file} RENAME ${APPLICATION_ICON_NAME}.png DESTINATION ${DATADIR}/icons/hicolor/${_res}x${_res}/apps)
+ install(FILES ${_file} RENAME ${APPLICATION_ICON_NAME}.png DESTINATION ${DATA_INSTALL_DIR}/icons/hicolor/${_res}x${_res}/apps)
endforeach(_file)
endif()
- install(FILES ${client_I18N} DESTINATION ${SHAREDIR}/${APPLICATION_EXECUTABLE}/i18n)
+ install(FILES ${client_I18N} DESTINATION ${DATA_INSTALL_DIR}/${APPLICATION_EXECUTABLE}/i18n)
# we may not add MACOSX_BUNDLE here, if not building one
else()
@@ -265,13 +265,13 @@ if(UNIX AND NOT APPLE)
configure_file(${CMAKE_SOURCE_DIR}/mirall.desktop.in
${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.desktop)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.desktop DESTINATION ${DATADIR}/applications )
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.desktop DESTINATION ${DATA_INSTALL_DIR}/applications )
configure_file(owncloud.xml.in ${APPLICATION_EXECUTABLE}.xml)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.xml DESTINATION ${DATADIR}/mime/packages )
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_EXECUTABLE}.xml DESTINATION ${DATA_INSTALL_DIR}/mime/packages )
find_package(SharedMimeInfo)
if(SharedMimeInfo_FOUND)
- update_xdg_mimetypes( ${DATADIR}/mime/packages )
+ update_xdg_mimetypes( ${DATA_INSTALL_DIR}/mime/packages )
endif(SharedMimeInfo_FOUND)
endif()
diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index 1f772d46c..ae683c025 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -732,6 +732,11 @@ QString substLang(const QString &lang)
void Application::setupTranslations()
{
+ const QString trPath = Translations::applicationTrPath();
+ if (trPath.isEmpty()) {
+ qCWarning(lcApplication) << "Failed to find translations";
+ return;
+ }
QStringList uiLanguages = QLocale::system().uiLanguages();
// the user can also set a locale in the settings, so we need to load the config file
@@ -761,7 +766,6 @@ void Application::setupTranslations()
for (QString lang : qAsConst(uiLanguages)) {
lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973
lang = substLang(lang);
- const QString trPath = Translations::applicationTrPath();
const QString trFile = Translations::translationsFilePrefix() + lang;
if (translator->load(trFile, trPath) || lang.startsWith(QLatin1String("en"))) {
// Permissive approach: Qt and keychain translations
diff --git a/src/gui/translations.cpp b/src/gui/translations.cpp
index 4b2529f43..4f750949a 100644
--- a/src/gui/translations.cpp
+++ b/src/gui/translations.cpp
@@ -24,6 +24,7 @@
#include <QLoggingCategory>
#include <QDir>
#include <QDirIterator>
+#include <QStandardPaths>
namespace OCC {
@@ -43,19 +44,18 @@ namespace Translations {
QString applicationTrPath()
{
- QString devTrPath = qApp->applicationDirPath() + QString::fromLatin1("/../src/gui/");
- if (QDir(devTrPath).exists()) {
+ const auto devTrPath = QDir(qApp->applicationDirPath() + QStringLiteral("/../src/gui/"));
+ if (devTrPath.exists()) {
// might miss Qt, QtKeyChain, etc.
qCWarning(lcTranslations) << "Running from build location! Translations may be incomplete!";
- return devTrPath;
+ return devTrPath.absolutePath();
}
-#if defined(Q_OS_WIN)
- return QApplication::applicationDirPath();
-#elif defined(Q_OS_MAC)
- return QApplication::applicationDirPath() + QLatin1String("/../Resources/Translations"); // path defaults to app dir.
-#elif defined(Q_OS_UNIX)
- return QStringLiteral(SHAREDIR "/" APPLICATION_EXECUTABLE "/i18n/");
+#ifdef Q_OS_MAC
+ const auto translationDir = QStringLiteral("Translations");
+#else
+ const auto translationDir = QStringLiteral("i18n");
#endif
+ return QStandardPaths::locate(QStandardPaths::DataLocation, translationDir, QStandardPaths::LocateDirectory);
}
QSet<QString> listAvailableTranslations()