From 5c3523648e7d97ed1a3391d671d23429f43f8eb9 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 5 Jun 2020 00:20:36 +0800 Subject: [PATCH] fix: should install and use qm files --- CMakeLists.txt | 14 ++++++++++++++ languages/pineapple-music.ts | 20 ++++++++++++++++++++ main.cpp | 12 ++++++++++++ 3 files changed, 46 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84fff25..0f4b14c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,3 +125,17 @@ install ( TARGETS ${EXE_NAME} ${INSTALL_TARGETS_DEFAULT_ARGS} ) + +if (WIN32) + set (QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}/translations") +else () + set (QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/pineapple-music/translations") + target_compile_definitions(${EXE_NAME} + PRIVATE QM_FILE_INSTALL_DIR=${QM_FILE_INSTALL_DIR} + ) +endif () + +install ( + FILES ${PMUSIC_QM_FILES} + DESTINATION ${QM_FILE_INSTALL_DIR} +) diff --git a/languages/pineapple-music.ts b/languages/pineapple-music.ts index 6347214..ece592b 100644 --- a/languages/pineapple-music.ts +++ b/languages/pineapple-music.ts @@ -23,6 +23,26 @@ Audio Files + + Pineapple Player + + + + ^ + + + + No song loaded... + + + + Drag and drop file to load + + + + 0:00 + + main diff --git a/main.cpp b/main.cpp index cded6bc..17a6c86 100644 --- a/main.cpp +++ b/main.cpp @@ -6,11 +6,23 @@ #include #include #include +#include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); + QTranslator translator; + QString qmDir; +#ifdef _WIN32 + qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations"); +#else + qmDir = QT_STRINGIFY(QM_FILE_INSTALL_DIR); +#endif + translator.load(QString("pineapple-music_%1").arg(QLocale::system().name()), qmDir); + a.installTranslator(&translator); + // parse commandline arguments QCommandLineParser parser; parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));