Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
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
Valentin Platzgummer
qgroundcontrol
Commits
a3b87e1f
Commit
a3b87e1f
authored
Jun 12, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle text to speech locale
parent
eee967c5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
30 deletions
+45
-30
AudioOutput.cc
src/Audio/AudioOutput.cc
+7
-0
AudioOutput.h
src/Audio/AudioOutput.h
+1
-0
QGCApplication.cc
src/QGCApplication.cc
+30
-29
QGCApplication.h
src/QGCApplication.h
+7
-1
No files found.
src/Audio/AudioOutput.cc
View file @
a3b87e1f
...
...
@@ -20,7 +20,14 @@ AudioOutput::AudioOutput(QGCApplication* app, QGCToolbox* toolbox)
:
QGCTool
(
app
,
toolbox
)
,
_tts
(
new
QTextToSpeech
(
this
))
{
_tts
->
setLocale
(
QLocale
::
system
());
connect
(
_tts
,
&
QTextToSpeech
::
stateChanged
,
this
,
&
AudioOutput
::
_stateChanged
);
connect
(
qgcApp
(),
&
QGCApplication
::
languageChanged
,
this
,
&
AudioOutput
::
_languageChanged
);
}
void
AudioOutput
::
_languageChanged
(
const
QLocale
locale
)
{
_tts
->
setLocale
(
locale
);
}
bool
AudioOutput
::
say
(
const
QString
&
inText
)
...
...
src/Audio/AudioOutput.h
View file @
a3b87e1f
...
...
@@ -33,6 +33,7 @@ public slots:
private
slots
:
void
_stateChanged
(
QTextToSpeech
::
State
state
);
void
_languageChanged
(
const
QLocale
locale
);
protected:
QTextToSpeech
*
_tts
;
...
...
src/QGCApplication.cc
View file @
a3b87e1f
...
...
@@ -351,74 +351,74 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
void
QGCApplication
::
setLanguage
()
{
QLocale
locale
=
QLocale
::
system
();
qDebug
()
<<
"System reported locale:"
<<
locale
<<
locale
.
name
();
_
locale
=
QLocale
::
system
();
qDebug
()
<<
"System reported locale:"
<<
_locale
<<
_
locale
.
name
();
int
langID
=
toolbox
()
->
settingsManager
()
->
appSettings
()
->
language
()
->
rawValue
().
toInt
();
//-- See App.SettinsGroup.json for index
if
(
langID
)
{
switch
(
langID
)
{
case
1
:
locale
=
QLocale
(
QLocale
::
Bulgarian
);
_
locale
=
QLocale
(
QLocale
::
Bulgarian
);
break
;
case
2
:
locale
=
QLocale
(
QLocale
::
Chinese
);
_
locale
=
QLocale
(
QLocale
::
Chinese
);
break
;
case
3
:
locale
=
QLocale
(
QLocale
::
Dutch
);
_
locale
=
QLocale
(
QLocale
::
Dutch
);
break
;
case
4
:
locale
=
QLocale
(
QLocale
::
English
);
_
locale
=
QLocale
(
QLocale
::
English
);
break
;
case
5
:
locale
=
QLocale
(
QLocale
::
Finnish
);
_
locale
=
QLocale
(
QLocale
::
Finnish
);
break
;
case
6
:
locale
=
QLocale
(
QLocale
::
French
);
_
locale
=
QLocale
(
QLocale
::
French
);
break
;
case
7
:
locale
=
QLocale
(
QLocale
::
German
);
_
locale
=
QLocale
(
QLocale
::
German
);
break
;
case
8
:
locale
=
QLocale
(
QLocale
::
Greek
);
_
locale
=
QLocale
(
QLocale
::
Greek
);
break
;
case
9
:
locale
=
QLocale
(
QLocale
::
Hebrew
);
_
locale
=
QLocale
(
QLocale
::
Hebrew
);
break
;
case
10
:
locale
=
QLocale
(
QLocale
::
Italian
);
_
locale
=
QLocale
(
QLocale
::
Italian
);
break
;
case
11
:
locale
=
QLocale
(
QLocale
::
Japanese
);
_
locale
=
QLocale
(
QLocale
::
Japanese
);
break
;
case
12
:
locale
=
QLocale
(
QLocale
::
Korean
);
_
locale
=
QLocale
(
QLocale
::
Korean
);
break
;
case
13
:
locale
=
QLocale
(
QLocale
::
Norwegian
);
_
locale
=
QLocale
(
QLocale
::
Norwegian
);
break
;
case
14
:
locale
=
QLocale
(
QLocale
::
Polish
);
_
locale
=
QLocale
(
QLocale
::
Polish
);
break
;
case
15
:
locale
=
QLocale
(
QLocale
::
Portuguese
);
_
locale
=
QLocale
(
QLocale
::
Portuguese
);
break
;
case
16
:
locale
=
QLocale
(
QLocale
::
Russian
);
_
locale
=
QLocale
(
QLocale
::
Russian
);
break
;
case
17
:
locale
=
QLocale
(
QLocale
::
Spanish
);
_
locale
=
QLocale
(
QLocale
::
Spanish
);
break
;
case
18
:
locale
=
QLocale
(
QLocale
::
Swedish
);
_
locale
=
QLocale
(
QLocale
::
Swedish
);
break
;
case
19
:
locale
=
QLocale
(
QLocale
::
Turkish
);
_
locale
=
QLocale
(
QLocale
::
Turkish
);
break
;
}
}
//-- We have specific fonts for Korean
if
(
locale
==
QLocale
::
Korean
)
{
qDebug
()
<<
"Loading Korean fonts"
<<
locale
.
name
();
if
(
_
locale
==
QLocale
::
Korean
)
{
qDebug
()
<<
"Loading Korean fonts"
<<
_
locale
.
name
();
if
(
QFontDatabase
::
addApplicationFont
(
":/fonts/NanumGothic-Regular"
)
<
0
)
{
qWarning
()
<<
"Could not load /fonts/NanumGothic-Regular font"
;
}
...
...
@@ -426,22 +426,23 @@ void QGCApplication::setLanguage()
qWarning
()
<<
"Could not load /fonts/NanumGothic-Bold font"
;
}
}
qDebug
()
<<
"Loading localization for"
<<
locale
.
name
();
qDebug
()
<<
"Loading localization for"
<<
_
locale
.
name
();
_app
->
removeTranslator
(
&
_QGCTranslator
);
_app
->
removeTranslator
(
&
_QGCTranslatorQt
);
if
(
_QGCTranslatorQt
.
load
(
"qt_"
+
locale
.
name
(),
QLibraryInfo
::
location
(
QLibraryInfo
::
TranslationsPath
)))
{
if
(
_QGCTranslatorQt
.
load
(
"qt_"
+
_
locale
.
name
(),
QLibraryInfo
::
location
(
QLibraryInfo
::
TranslationsPath
)))
{
_app
->
installTranslator
(
&
_QGCTranslatorQt
);
}
else
{
qDebug
()
<<
"Error loading Qt localization for"
<<
locale
.
name
();
qDebug
()
<<
"Error loading Qt localization for"
<<
_
locale
.
name
();
}
if
(
_QGCTranslator
.
load
(
locale
,
QLatin1String
(
"qgc_"
),
""
,
":/i18n"
))
{
QLocale
::
setDefault
(
locale
);
if
(
_QGCTranslator
.
load
(
_
locale
,
QLatin1String
(
"qgc_"
),
""
,
":/i18n"
))
{
QLocale
::
setDefault
(
_
locale
);
_app
->
installTranslator
(
&
_QGCTranslator
);
}
else
{
qDebug
()
<<
"Error loading application localization for"
<<
locale
.
name
();
qDebug
()
<<
"Error loading application localization for"
<<
_
locale
.
name
();
}
if
(
_qmlAppEngine
)
_qmlAppEngine
->
retranslate
();
emit
languageChanged
(
_locale
);
}
void
QGCApplication
::
_shutdown
()
...
...
src/QGCApplication.h
View file @
a3b87e1f
...
...
@@ -118,10 +118,15 @@ public slots:
/// Check that the telemetry save path is set correctly
void
checkTelemetrySavePathOnMainThread
();
/// Get current language
const
QLocale
getCurrentLanguage
()
{
return
_locale
;
}
signals:
/// This is connected to MAVLinkProtocol::checkForLostLogFiles. We signal this to ourselves to call the slot
/// on the MAVLinkProtocol thread;
void
checkForLostLogFiles
();
void
checkForLostLogFiles
();
void
languageChanged
(
const
QLocale
locale
);
public:
// Although public, these methods are internal and should only be called by UnitTest code
...
...
@@ -184,6 +189,7 @@ private:
bool
_bluetoothAvailable
=
false
;
QTranslator
_QGCTranslator
;
QTranslator
_QGCTranslatorQt
;
QLocale
_locale
;
static
const
char
*
_settingsVersionKey
;
///< Settings key which hold settings version
static
const
char
*
_deleteAllSettingsKey
;
///< If this settings key is set on boot, all settings will be deleted
...
...
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