Skip to content

Commit

Permalink
Fix: Translations in app menu on macOS
Browse files Browse the repository at this point in the history
Create a global, "empty" main menu, so it gets translated on macOS.
  • Loading branch information
mhoeher committed Oct 14, 2021
1 parent ed75317 commit 7523723
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/appstartup.cpp
Expand Up @@ -35,6 +35,9 @@ AppStartup::AppStartup()
m_trayIcon(nullptr),
#endif
m_trayMenu(nullptr),
#ifdef Q_OS_MACOS
m_menuBar(nullptr),
#endif
m_parser(),
m_engine(nullptr),
m_translations(nullptr),
Expand Down Expand Up @@ -62,6 +65,9 @@ AppStartup::~AppStartup()
m_backgroundService = nullptr;
delete m_cache;
m_cache = nullptr;
#ifdef Q_OS_MACOS
delete m_menuBar;
#endif
delete m_app;
m_app = nullptr;
}
Expand Down Expand Up @@ -143,6 +149,10 @@ void AppStartup::createApp(int& argc, char* argv[])
qWarning() << screen->name() << screen->devicePixelRatio();
}
}

#ifdef Q_OS_MACOS
m_menuBar = new QMenuBar();
#endif
}

void AppStartup::setupFonts()
Expand Down
6 changes: 6 additions & 0 deletions app/appstartup.h
Expand Up @@ -38,6 +38,9 @@
#include <QScreen>
#include <QSslSocket>
#include <QSysInfo>
#ifdef Q_OS_MACOS
# include <QMenuBar>
#endif

#ifdef OPENTODOLIST_WITH_KNOTIFICATIONS
# include <KStatusNotifierItem>
Expand Down Expand Up @@ -94,6 +97,9 @@ class AppStartup : public QObject
#endif
QPointer<QMenu> m_trayMenu;
static QVector<QtMessageHandler> s_prevMessageHandler;
#ifdef Q_OS_MACOS
QMenuBar* m_menuBar;
#endif

QCommandLineParser m_parser;
QQmlApplicationEngine* m_engine;
Expand Down
7 changes: 5 additions & 2 deletions ci/macos-build.sh
Expand Up @@ -45,15 +45,18 @@ cmake --build . --target test
for ts_file in ../app/translations/*.ts; do
lang="$(basename $ts_file | tr - . | cut -f 2 -d .)"
mkdir -p app/OpenTodoList.app/Contents/Resources/${lang}.lproj
echo '"Empty Translation" = "Empty Translation";' > app/OpenTodoList.app/Contents/Resources/${lang}.lproj/Empty.strings
done

# Include Qt Runtime in App Bundle. Also sign the bundle
# and prepare it for notarization:
pushd app
$QT_DIR/bin/macdeployqt \
app/OpenTodoList.app/ \
-qmldir=../app \
OpenTodoList.app/ \
-qmldir=../../app \
-appstore-compliant \
-sign-for-notarization="Developer ID Application: Martin Hoeher (786Z636JV9)"
popd

# Create a zip archive suitable for uploading to the notarization
# service:
Expand Down

0 comments on commit 7523723

Please sign in to comment.