Dynamically retranslate some aspects of the UI
There are still many places missing but this is a first step.
This commit is contained in:
parent
10aafceb68
commit
4effd6045b
|
@ -8,7 +8,7 @@ endforeach ()
|
||||||
set(TS_FILES ../translations/${META_PROJECT_NAME}_de_DE.ts ../translations/${META_PROJECT_NAME}_en_US.ts)
|
set(TS_FILES ../translations/${META_PROJECT_NAME}_de_DE.ts ../translations/${META_PROJECT_NAME}_en_US.ts)
|
||||||
|
|
||||||
# find qtutilities
|
# find qtutilities
|
||||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.7.0 REQUIRED)
|
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.13.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find qtforkawesomequickimageprovider
|
# find qtforkawesomequickimageprovider
|
||||||
|
|
|
@ -125,7 +125,7 @@ SettingsDialog::SettingsDialog(Plasmoid::SyncthingApplet &applet)
|
||||||
|
|
||||||
category = new OptionCategory;
|
category = new OptionCategory;
|
||||||
m_appearanceOptionPage = new AppearanceOptionPage(applet);
|
m_appearanceOptionPage = new AppearanceOptionPage(applet);
|
||||||
category->setDisplayName(QCoreApplication::translate("Plasmoid::SettingsDialog", "Plasmoid"));
|
translateCategory(category, [] { return QCoreApplication::translate("Plasmoid::SettingsDialog", "Plasmoid"); });
|
||||||
category->assignPages({ new ConnectionOptionPage(applet.connection()), new NotificationsOptionPage(GuiType::Plasmoid), m_appearanceOptionPage,
|
category->assignPages({ new ConnectionOptionPage(applet.connection()), new NotificationsOptionPage(GuiType::Plasmoid), m_appearanceOptionPage,
|
||||||
new IconsOptionPage, new ShortcutOptionPage(applet) });
|
new IconsOptionPage, new ShortcutOptionPage(applet) });
|
||||||
category->setIcon(QIcon::fromTheme(QStringLiteral("plasma")));
|
category->setIcon(QIcon::fromTheme(QStringLiteral("plasma")));
|
||||||
|
@ -133,15 +133,19 @@ SettingsDialog::SettingsDialog(Plasmoid::SyncthingApplet &applet)
|
||||||
|
|
||||||
// most startup options don't make much sense for a Plasmoid, so merge webview with startup
|
// most startup options don't make much sense for a Plasmoid, so merge webview with startup
|
||||||
auto *const generalWebViewPage = new GeneralWebViewOptionPage;
|
auto *const generalWebViewPage = new GeneralWebViewOptionPage;
|
||||||
generalWebViewPage->widget()->setWindowTitle(QCoreApplication::translate("Plasmoid::SettingsDialog", "General web view settings"));
|
|
||||||
auto *const builtinWebViewPage = new BuiltinWebViewOptionPage;
|
auto *const builtinWebViewPage = new BuiltinWebViewOptionPage;
|
||||||
builtinWebViewPage->widget()->setWindowTitle(QCoreApplication::translate("Plasmoid::SettingsDialog", "Built-in web view"));
|
auto setWindowTitle = [generalWebViewPage, builtinWebViewPage] {
|
||||||
|
generalWebViewPage->widget()->setWindowTitle(QCoreApplication::translate("Plasmoid::SettingsDialog", "General web view settings"));
|
||||||
|
builtinWebViewPage->widget()->setWindowTitle(QCoreApplication::translate("Plasmoid::SettingsDialog", "Built-in web view"));
|
||||||
|
};
|
||||||
|
setWindowTitle();
|
||||||
|
connect(this, &QtUtilities::SettingsDialog::retranslationRequired, this, std::move(setWindowTitle));
|
||||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||||
auto *const systemdPage = new SystemdOptionPage;
|
auto *const systemdPage = new SystemdOptionPage;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
category = new OptionCategory;
|
category = new OptionCategory;
|
||||||
category->setDisplayName(QCoreApplication::translate("Plasmoid::SettingsDialog", "Extras"));
|
translateCategory(category, [] { return QCoreApplication::translate("Plasmoid::SettingsDialog", "Extras"); });
|
||||||
category->assignPages({ generalWebViewPage, builtinWebViewPage
|
category->assignPages({ generalWebViewPage, builtinWebViewPage
|
||||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||||
,
|
,
|
||||||
|
|
|
@ -91,7 +91,7 @@ find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFF
|
||||||
use_cpp_utilities(VISIBILITY PUBLIC)
|
use_cpp_utilities(VISIBILITY PUBLIC)
|
||||||
|
|
||||||
# find qtutilities
|
# find qtutilities
|
||||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.11.0 REQUIRED)
|
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.13.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find backend libraries
|
# find backend libraries
|
||||||
|
|
|
@ -1618,21 +1618,21 @@ SettingsDialog::SettingsDialog(Data::SyncthingConnection *connection, QWidget *p
|
||||||
OptionCategory *category;
|
OptionCategory *category;
|
||||||
|
|
||||||
category = new OptionCategory(this);
|
category = new OptionCategory(this);
|
||||||
category->setDisplayName(tr("Tray"));
|
translateCategory(category, [] { return tr("Tray"); });
|
||||||
category->assignPages({ m_connectionsOptionPage = new ConnectionOptionPage(connection), new NotificationsOptionPage, new AppearanceOptionPage,
|
category->assignPages({ m_connectionsOptionPage = new ConnectionOptionPage(connection), new NotificationsOptionPage, new AppearanceOptionPage,
|
||||||
new IconsOptionPage(IconsOptionPage::Context::UI), new IconsOptionPage(IconsOptionPage::Context::System) });
|
new IconsOptionPage(IconsOptionPage::Context::UI), new IconsOptionPage(IconsOptionPage::Context::System) });
|
||||||
category->setIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg")));
|
category->setIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg")));
|
||||||
categories << category;
|
categories << category;
|
||||||
|
|
||||||
category = new OptionCategory(this);
|
category = new OptionCategory(this);
|
||||||
category->setDisplayName(tr("Web view"));
|
translateCategory(category, [] { return tr("Web view"); });
|
||||||
category->assignPages({ new GeneralWebViewOptionPage, new BuiltinWebViewOptionPage });
|
category->assignPages({ new GeneralWebViewOptionPage, new BuiltinWebViewOptionPage });
|
||||||
category->setIcon(
|
category->setIcon(
|
||||||
QIcon::fromTheme(QStringLiteral("internet-web-browser"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/internet-web-browser.svg"))));
|
QIcon::fromTheme(QStringLiteral("internet-web-browser"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/internet-web-browser.svg"))));
|
||||||
categories << category;
|
categories << category;
|
||||||
|
|
||||||
category = new OptionCategory(this);
|
category = new OptionCategory(this);
|
||||||
category->setDisplayName(tr("Startup"));
|
translateCategory(category, [] { return tr("Startup"); });
|
||||||
category->assignPages({ new AutostartOptionPage, new LauncherOptionPage,
|
category->assignPages({ new AutostartOptionPage, new LauncherOptionPage,
|
||||||
new LauncherOptionPage(QStringLiteral("Process"), tr("additional tool"), tr("Extra launcher"))
|
new LauncherOptionPage(QStringLiteral("Process"), tr("additional tool"), tr("Extra launcher"))
|
||||||
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
||||||
|
|
|
@ -104,7 +104,7 @@ find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFF
|
||||||
use_cpp_utilities()
|
use_cpp_utilities()
|
||||||
|
|
||||||
# find qtutilities
|
# find qtutilities
|
||||||
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.12.0 REQUIRED)
|
find_package(${PACKAGE_NAMESPACE_PREFIX}qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.13.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find backend libraries
|
# find backend libraries
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
// use meta-data of syncthingtray application here
|
// use meta-data of syncthingtray application here
|
||||||
#include "resources/../../tray/resources/config.h"
|
#include "resources/../../tray/resources/config.h"
|
||||||
|
#include "resources/../../tray/resources/qtconfig.h"
|
||||||
|
|
||||||
#include "ui_traywidget.h"
|
#include "ui_traywidget.h"
|
||||||
|
|
||||||
|
@ -627,6 +628,14 @@ bool TrayWidget::event(QEvent *event)
|
||||||
setLabelPixmaps();
|
setLabelPixmaps();
|
||||||
setTrafficPixmaps(true);
|
setTrafficPixmaps(true);
|
||||||
break;
|
break;
|
||||||
|
case QEvent::LanguageChange:
|
||||||
|
m_ui->retranslateUi(this);
|
||||||
|
applyLauncherSettings(false, true, false);
|
||||||
|
handleStatusChanged(m_connection.status());
|
||||||
|
if (m_menu && m_menu->icon()) {
|
||||||
|
m_menu->icon()->updateStatusIconAndText();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -634,7 +643,12 @@ bool TrayWidget::event(QEvent *event)
|
||||||
|
|
||||||
void TrayWidget::applySettingsOnAllInstances()
|
void TrayWidget::applySettingsOnAllInstances()
|
||||||
{
|
{
|
||||||
Settings::values().qt.apply();
|
auto &qtSettings = Settings::values().qt;
|
||||||
|
qtSettings.apply();
|
||||||
|
if (qtSettings.hasLocaleChanged()) {
|
||||||
|
QtUtilities::TranslationFiles::clearTranslationFiles();
|
||||||
|
LOAD_QT_TRANSLATIONS;
|
||||||
|
}
|
||||||
for (TrayWidget *instance : s_instances) {
|
for (TrayWidget *instance : s_instances) {
|
||||||
instance->applySettings();
|
instance->applySettings();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue