Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
2f833894
Commit
2f833894
authored
Jun 07, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(src/app/App): use preferred locale at startup
parent
3ce3a5cc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
57 deletions
+47
-57
App.cpp
linphone-desktop/src/app/App.cpp
+45
-53
App.hpp
linphone-desktop/src/app/App.hpp
+2
-3
main.cpp
linphone-desktop/src/main.cpp
+0
-1
No files found.
linphone-desktop/src/app/App.cpp
View file @
2f833894
...
@@ -33,11 +33,12 @@
...
@@ -33,11 +33,12 @@
#include "../components/Components.hpp"
#include "../components/Components.hpp"
#include "../Utils.hpp"
#include "../Utils.hpp"
#include "cli/Cli.hpp"
#include "logger/Logger.hpp"
#include "logger/Logger.hpp"
#include "paths/Paths.hpp"
#include "providers/AvatarProvider.hpp"
#include "providers/AvatarProvider.hpp"
#include "providers/ThumbnailProvider.hpp"
#include "providers/ThumbnailProvider.hpp"
#include "translator/DefaultTranslator.hpp"
#include "translator/DefaultTranslator.hpp"
#include "cli/Cli.hpp"
#include "App.hpp"
#include "App.hpp"
...
@@ -71,12 +72,28 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true) {
...
@@ -71,12 +72,28 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true) {
setApplicationVersion
(
LINPHONE_QT_GIT_VERSION
);
setApplicationVersion
(
LINPHONE_QT_GIT_VERSION
);
setWindowIcon
(
QIcon
(
WINDOW_ICON_PATH
));
setWindowIcon
(
QIcon
(
WINDOW_ICON_PATH
));
parseArgs
();
// List available locales.
// List available locales.
for
(
const
auto
&
locale
:
QDir
(
LANGUAGES_PATH
).
entryList
())
for
(
const
auto
&
locale
:
QDir
(
LANGUAGES_PATH
).
entryList
())
mAvailableLocales
<<
QLocale
(
locale
);
mAvailableLocales
<<
QLocale
(
locale
);
mTranslator
=
new
DefaultTranslator
(
this
);
mTranslator
=
new
DefaultTranslator
(
this
);
// Try to use preferred locale.
QString
locale
=
::
Utils
::
coreStringToAppString
(
linphone
::
Config
::
newWithFactory
(
Paths
::
getConfigFilePath
(
mParser
.
value
(
"config"
)),
""
)
->
getString
(
SettingsModel
::
UI_SECTION
,
"locale"
,
""
)
);
if
(
!
locale
.
isEmpty
()
&&
installLocale
(
*
this
,
*
mTranslator
,
QLocale
(
locale
)))
{
mLocale
=
locale
;
qInfo
()
<<
QStringLiteral
(
"Use preferred locale: %1"
).
arg
(
locale
);
return
;
}
// Try to use system locale.
// Try to use system locale.
QLocale
sysLocale
=
QLocale
::
system
();
QLocale
sysLocale
=
QLocale
::
system
();
if
(
installLocale
(
*
this
,
*
mTranslator
,
sysLocale
))
{
if
(
installLocale
(
*
this
,
*
mTranslator
,
sysLocale
))
{
...
@@ -200,33 +217,6 @@ void App::initContentApp () {
...
@@ -200,33 +217,6 @@ void App::initContentApp () {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
App
::
parseArgs
()
{
mParser
.
setApplicationDescription
(
tr
(
"applicationDescription"
));
mParser
.
addHelpOption
();
mParser
.
addVersionOption
();
mParser
.
addOptions
({
{
"config"
,
tr
(
"commandLineOptionConfig"
),
tr
(
"commandLineOptionConfigArg"
)
},
#ifndef Q_OS_MACOS
{
"iconified"
,
tr
(
"commandLineOptionIconified"
)
},
#endif // ifndef Q_OS_MACOS
{
"self-test"
,
tr
(
"commandLineOptionSelfTest"
)
},
{
{
"V"
,
"verbose"
},
tr
(
"commandLineOptionVerbose"
)
},
{
{
"c"
,
"cmd"
},
tr
(
"commandLineOptionCmd"
),
tr
(
"commandLineOptionCmdArg"
)
}
});
mParser
.
process
(
*
this
);
// Initialize logger. (Do not do this before this point because the
// application has to be created for the logs to be put in the correct
// directory.)
Logger
::
init
();
if
(
mParser
.
isSet
(
"verbose"
))
{
Logger
::
getInstance
()
->
setVerbose
(
true
);
}
}
// -----------------------------------------------------------------------------
QString
App
::
getCommandArgument
()
{
QString
App
::
getCommandArgument
()
{
return
mParser
.
value
(
"cmd"
);
return
mParser
.
value
(
"cmd"
);
}
}
...
@@ -239,29 +229,6 @@ void App::executeCommand (const QString &command) {
...
@@ -239,29 +229,6 @@ void App::executeCommand (const QString &command) {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
App
::
tryToUsePreferredLocale
()
{
QString
locale
=
getConfigLocale
();
if
(
!
locale
.
isEmpty
())
{
DefaultTranslator
*
translator
=
new
DefaultTranslator
(
this
);
if
(
installLocale
(
*
this
,
*
translator
,
QLocale
(
locale
)))
{
// Use config.
mTranslator
->
deleteLater
();
mTranslator
=
translator
;
mLocale
=
locale
;
qInfo
()
<<
QStringLiteral
(
"Use preferred locale: %1"
).
arg
(
locale
);
}
else
{
// Reset config.
setConfigLocale
(
""
);
translator
->
deleteLater
();
}
}
}
// -----------------------------------------------------------------------------
QQuickWindow
*
App
::
getCallsWindow
()
{
QQuickWindow
*
App
::
getCallsWindow
()
{
if
(
!
mCallsWindow
)
if
(
!
mCallsWindow
)
mCallsWindow
=
createSubWindow
(
this
,
QML_VIEW_CALLS_WINDOW
);
mCallsWindow
=
createSubWindow
(
this
,
QML_VIEW_CALLS_WINDOW
);
...
@@ -318,6 +285,33 @@ bool App::hasFocus () const {
...
@@ -318,6 +285,33 @@ bool App::hasFocus () const {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
App
::
parseArgs
()
{
mParser
.
setApplicationDescription
(
tr
(
"applicationDescription"
));
mParser
.
addHelpOption
();
mParser
.
addVersionOption
();
mParser
.
addOptions
({
{
"config"
,
tr
(
"commandLineOptionConfig"
),
tr
(
"commandLineOptionConfigArg"
)
},
#ifndef Q_OS_MACOS
{
"iconified"
,
tr
(
"commandLineOptionIconified"
)
},
#endif // ifndef Q_OS_MACOS
{
"self-test"
,
tr
(
"commandLineOptionSelfTest"
)
},
{
{
"V"
,
"verbose"
},
tr
(
"commandLineOptionVerbose"
)
},
{
{
"c"
,
"cmd"
},
tr
(
"commandLineOptionCmd"
),
tr
(
"commandLineOptionCmdArg"
)
}
});
mParser
.
process
(
*
this
);
// Initialize logger. (Do not do this before this point because the
// application has to be created for the logs to be put in the correct
// directory.)
Logger
::
init
();
if
(
mParser
.
isSet
(
"verbose"
))
{
Logger
::
getInstance
()
->
setVerbose
(
true
);
}
}
// -----------------------------------------------------------------------------
#define registerSharedSingletonType(TYPE, NAME, METHOD) qmlRegisterSingletonType<TYPE>( \
#define registerSharedSingletonType(TYPE, NAME, METHOD) qmlRegisterSingletonType<TYPE>( \
"Linphone", 1, 0, NAME, \
"Linphone", 1, 0, NAME, \
[](QQmlEngine *, QJSEngine *) -> QObject *{ \
[](QQmlEngine *, QJSEngine *) -> QObject *{ \
...
@@ -468,8 +462,6 @@ QString App::getLocale () const {
...
@@ -468,8 +462,6 @@ QString App::getLocale () const {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
App
::
openAppAfterInit
()
{
void
App
::
openAppAfterInit
()
{
tryToUsePreferredLocale
();
qInfo
()
<<
QStringLiteral
(
"Open linphone app."
);
qInfo
()
<<
QStringLiteral
(
"Open linphone app."
);
QQuickWindow
*
mainWindow
=
getMainWindow
();
QQuickWindow
*
mainWindow
=
getMainWindow
();
...
...
linphone-desktop/src/app/App.hpp
View file @
2f833894
...
@@ -50,13 +50,10 @@ public:
...
@@ -50,13 +50,10 @@ public:
~
App
();
~
App
();
void
initContentApp
();
void
initContentApp
();
void
parseArgs
();
QString
getCommandArgument
();
QString
getCommandArgument
();
void
executeCommand
(
const
QString
&
command
);
void
executeCommand
(
const
QString
&
command
);
void
tryToUsePreferredLocale
();
QQmlEngine
*
getEngine
()
{
QQmlEngine
*
getEngine
()
{
return
mEngine
;
return
mEngine
;
}
}
...
@@ -91,6 +88,8 @@ signals:
...
@@ -91,6 +88,8 @@ signals:
void
configLocaleChanged
(
const
QString
&
locale
);
void
configLocaleChanged
(
const
QString
&
locale
);
private:
private:
void
parseArgs
();
void
registerTypes
();
void
registerTypes
();
void
registerSharedTypes
();
void
registerSharedTypes
();
void
setTrayIcon
();
void
setTrayIcon
();
...
...
linphone-desktop/src/main.cpp
View file @
2f833894
...
@@ -70,7 +70,6 @@ int main (int argc, char *argv[]) {
...
@@ -70,7 +70,6 @@ int main (int argc, char *argv[]) {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
App
app
(
argc
,
argv
);
App
app
(
argc
,
argv
);
app
.
parseArgs
();
if
(
app
.
isSecondary
())
{
if
(
app
.
isSecondary
())
{
QString
command
=
app
.
getCommandArgument
();
QString
command
=
app
.
getCommandArgument
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment