Set locale for date formatting to French as the rest of the app.
This commit is contained in:
parent
e1b8befde4
commit
804af1bdbb
8 changed files with 37 additions and 11 deletions
|
|
@ -37,6 +37,7 @@
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
#include "core/account/AccountCore.hpp"
|
#include "core/account/AccountCore.hpp"
|
||||||
#include "core/account/AccountDeviceGui.hpp"
|
#include "core/account/AccountDeviceGui.hpp"
|
||||||
|
|
@ -479,6 +480,7 @@ void App::initCore() {
|
||||||
setQuitOnLastWindowClosed(mSettings->getExitOnClose());
|
setQuitOnLastWindowClosed(mSettings->getExitOnClose());
|
||||||
connect(mSettings.get(), &SettingsCore::exitOnCloseChanged, this, &App::onExitOnCloseChanged,
|
connect(mSettings.get(), &SettingsCore::exitOnCloseChanged, this, &App::onExitOnCloseChanged,
|
||||||
Qt::UniqueConnection);
|
Qt::UniqueConnection);
|
||||||
|
setLocale(settings->getConfigLocale());
|
||||||
|
|
||||||
const QUrl url(u"qrc:/Linphone/view/Page/Window/Main/MainWindow.qml"_qs);
|
const QUrl url(u"qrc:/Linphone/view/Page/Window/Main/MainWindow.qml"_qs);
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
|
|
@ -510,6 +512,10 @@ void App::initCore() {
|
||||||
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||||
setAutoStart(mSettings->getAutoStart());
|
setAutoStart(mSettings->getAutoStart());
|
||||||
});
|
});
|
||||||
|
QObject::connect(mSettings.get(), &SettingsCore::configLocaleChanged, [this]() {
|
||||||
|
mustBeInMainThread(log().arg(Q_FUNC_INFO));
|
||||||
|
setLocale(mSettings->getConfigLocale());
|
||||||
|
});
|
||||||
mEngine->load(url);
|
mEngine->load(url);
|
||||||
});
|
});
|
||||||
// coreModel.reset();
|
// coreModel.reset();
|
||||||
|
|
@ -948,3 +954,15 @@ void App::setSysTrayIcon() {
|
||||||
if (!mSystemTrayIcon) mSystemTrayIcon = systemTrayIcon;
|
if (!mSystemTrayIcon) mSystemTrayIcon = systemTrayIcon;
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) qInfo() << "System tray is not available";
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) qInfo() << "System tray is not available";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
// Locale TODO - App only in French now.
|
||||||
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
|
void App::setLocale(QString configLocale) {
|
||||||
|
mLocale = QLocale(QLocale::French);
|
||||||
|
}
|
||||||
|
|
||||||
|
QLocale App::getLocale() {
|
||||||
|
return mLocale;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ public:
|
||||||
void restart();
|
void restart();
|
||||||
bool autoStartEnabled();
|
bool autoStartEnabled();
|
||||||
void setSysTrayIcon();
|
void setSysTrayIcon();
|
||||||
|
QLocale getLocale();
|
||||||
|
|
||||||
void onLoggerInitialized();
|
void onLoggerInitialized();
|
||||||
void sendCommand();
|
void sendCommand();
|
||||||
|
|
@ -145,6 +146,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
void createCommandParser();
|
void createCommandParser();
|
||||||
void setAutoStart(bool enabled);
|
void setAutoStart(bool enabled);
|
||||||
|
void setLocale(QString configLocale);
|
||||||
|
|
||||||
QCommandLineParser *mParser = nullptr;
|
QCommandLineParser *mParser = nullptr;
|
||||||
Thread *mLinphoneThread = nullptr;
|
Thread *mLinphoneThread = nullptr;
|
||||||
|
|
@ -158,6 +160,7 @@ private:
|
||||||
QSharedPointer<SafeConnection<App, CoreModel>> mCoreModelConnection;
|
QSharedPointer<SafeConnection<App, CoreModel>> mCoreModelConnection;
|
||||||
QSharedPointer<SafeConnection<App, CliModel>> mCliModelConnection;
|
QSharedPointer<SafeConnection<App, CliModel>> mCliModelConnection;
|
||||||
bool mAutoStart = false;
|
bool mAutoStart = false;
|
||||||
|
QLocale mLocale = QLocale::system();
|
||||||
|
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ SettingsCore::SettingsCore(QObject *parent) : QObject(parent) {
|
||||||
INIT_CORE_MEMBER(ExitOnClose, settingsModel)
|
INIT_CORE_MEMBER(ExitOnClose, settingsModel)
|
||||||
INIT_CORE_MEMBER(SyncLdapContacts, settingsModel)
|
INIT_CORE_MEMBER(SyncLdapContacts, settingsModel)
|
||||||
INIT_CORE_MEMBER(Ipv6Enabled, settingsModel)
|
INIT_CORE_MEMBER(Ipv6Enabled, settingsModel)
|
||||||
|
INIT_CORE_MEMBER(ConfigLocale, settingsModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsCore::~SettingsCore() {
|
SettingsCore::~SettingsCore() {
|
||||||
|
|
@ -345,6 +346,8 @@ void SettingsCore::setSelf(QSharedPointer<SettingsCore> me) {
|
||||||
syncLdapContacts, SyncLdapContacts)
|
syncLdapContacts, SyncLdapContacts)
|
||||||
DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, bool, ipv6Enabled,
|
DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, bool, ipv6Enabled,
|
||||||
Ipv6Enabled)
|
Ipv6Enabled)
|
||||||
|
DEFINE_CORE_GETSET_CONNECT(mSettingsModelConnection, SettingsCore, SettingsModel, settingsModel, QString,
|
||||||
|
configLocale, ConfigLocale)
|
||||||
|
|
||||||
auto coreModelConnection = QSharedPointer<SafeConnection<SettingsCore, CoreModel>>(
|
auto coreModelConnection = QSharedPointer<SafeConnection<SettingsCore, CoreModel>>(
|
||||||
new SafeConnection<SettingsCore, CoreModel>(me, CoreModel::getInstance()), &QObject::deleteLater);
|
new SafeConnection<SettingsCore, CoreModel>(me, CoreModel::getInstance()), &QObject::deleteLater);
|
||||||
|
|
@ -516,3 +519,7 @@ bool SettingsCore::getExitOnClose() const {
|
||||||
bool SettingsCore::getSyncLdapContacts() const {
|
bool SettingsCore::getSyncLdapContacts() const {
|
||||||
return mSyncLdapContacts;
|
return mSyncLdapContacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SettingsCore::getConfigLocale() const {
|
||||||
|
return mConfigLocale;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ public:
|
||||||
DECLARE_CORE_GETSET_MEMBER(bool, ipv6Enabled, Ipv6Enabled)
|
DECLARE_CORE_GETSET_MEMBER(bool, ipv6Enabled, Ipv6Enabled)
|
||||||
DECLARE_CORE_GETSET_MEMBER(QVariantList, audioCodecs, AudioCodecs)
|
DECLARE_CORE_GETSET_MEMBER(QVariantList, audioCodecs, AudioCodecs)
|
||||||
DECLARE_CORE_GETSET_MEMBER(QVariantList, videoCodecs, VideoCodecs)
|
DECLARE_CORE_GETSET_MEMBER(QVariantList, videoCodecs, VideoCodecs)
|
||||||
|
DECLARE_CORE_GETSET(QString, configLocale, ConfigLocale)
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,16 +55,6 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
auto app = QSharedPointer<App>::create(argc, argv);
|
auto app = QSharedPointer<App>::create(argc, argv);
|
||||||
|
|
||||||
QTranslator translator;
|
|
||||||
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
|
||||||
for (const QString &locale : uiLanguages) {
|
|
||||||
const QString baseName = "Linphone_" + QLocale(locale).name();
|
|
||||||
if (translator.load(":/i18n/" + baseName)) {
|
|
||||||
app->installTranslator(&translator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ACCESSBILITY_WORKAROUND
|
#ifdef ACCESSBILITY_WORKAROUND
|
||||||
QAccessible::installUpdateHandler(DummyUpdateHandler);
|
QAccessible::installUpdateHandler(DummyUpdateHandler);
|
||||||
QAccessible::installRootObjectHandler(DummyRootObjectHandler);
|
QAccessible::installRootObjectHandler(DummyRootObjectHandler);
|
||||||
|
|
|
||||||
|
|
@ -582,6 +582,7 @@ void SettingsModel::notifyConfigReady(){
|
||||||
DEFINE_NOTIFY_CONFIG_READY(autoStart, AutoStart)
|
DEFINE_NOTIFY_CONFIG_READY(autoStart, AutoStart)
|
||||||
DEFINE_NOTIFY_CONFIG_READY(exitOnClose, ExitOnClose)
|
DEFINE_NOTIFY_CONFIG_READY(exitOnClose, ExitOnClose)
|
||||||
DEFINE_NOTIFY_CONFIG_READY(syncLdapContacts, SyncLdapContacts)
|
DEFINE_NOTIFY_CONFIG_READY(syncLdapContacts, SyncLdapContacts)
|
||||||
|
DEFINE_NOTIFY_CONFIG_READY(configLocale, ConfigLocale)
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_GETSET_CONFIG(SettingsModel, bool, Bool, disableChatFeature, DisableChatFeature, "disable_chat_feature", true)
|
DEFINE_GETSET_CONFIG(SettingsModel, bool, Bool, disableChatFeature, DisableChatFeature, "disable_chat_feature", true)
|
||||||
|
|
@ -679,4 +680,9 @@ DEFINE_GETSET_CONFIG(SettingsModel,
|
||||||
SyncLdapContacts,
|
SyncLdapContacts,
|
||||||
"sync_ldap_contacts",
|
"sync_ldap_contacts",
|
||||||
false)
|
false)
|
||||||
|
DEFINE_GETSET_CONFIG_STRING(SettingsModel,
|
||||||
|
configLocale,
|
||||||
|
ConfigLocale,
|
||||||
|
"locale",
|
||||||
|
"")
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
||||||
|
|
@ -154,6 +154,7 @@ public:
|
||||||
DECLARE_GETSET(bool, exitOnClose, ExitOnClose)
|
DECLARE_GETSET(bool, exitOnClose, ExitOnClose)
|
||||||
DECLARE_GETSET(bool, syncLdapContacts, SyncLdapContacts)
|
DECLARE_GETSET(bool, syncLdapContacts, SyncLdapContacts)
|
||||||
DECLARE_GETSET(bool, ipv6Enabled, Ipv6Enabled)
|
DECLARE_GETSET(bool, ipv6Enabled, Ipv6Enabled)
|
||||||
|
DECLARE_GETSET(QString, configLocale, ConfigLocale)
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ QString Utils::formatDate(const QDateTime &date, bool includeTime) {
|
||||||
else if (date.date() == QDate::currentDate().addDays(-1)) dateDay = tr("Hier");
|
else if (date.date() == QDate::currentDate().addDays(-1)) dateDay = tr("Hier");
|
||||||
else {
|
else {
|
||||||
QString format = date.date().year() == QDateTime::currentDateTime().date().year() ? "dd MMMM" : "dd MMMM yyyy";
|
QString format = date.date().year() == QDateTime::currentDateTime().date().year() ? "dd MMMM" : "dd MMMM yyyy";
|
||||||
dateDay = tr(date.date().toString(format).toLocal8Bit().data());
|
dateDay = App::getInstance()->getLocale().toString(date.date(), format);
|
||||||
}
|
}
|
||||||
if (!includeTime) return dateDay;
|
if (!includeTime) return dateDay;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue