Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
75e57704
Commit
75e57704
authored
Aug 31, 2020
by
Jean-Baptiste Mardelle
Browse files
Attempt to mimic Shotcut's locale handling
Related to
#780
parent
45cbc455
Pipeline
#32481
passed with stage
in 21 minutes and 13 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/projectitemmodel.cpp
View file @
75e57704
...
...
@@ -39,6 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "projectclip.h"
#include "projectfolder.h"
#include "projectsubclip.h"
#include "lib/localeHandling.h"
#include "xml/xml.hpp"
#include <KLocalizedString>
...
...
@@ -993,8 +994,8 @@ void ProjectItemModel::loadBinPlaylist(Mlt::Tractor *documentTractor, Mlt::Tract
emit
pCore
->
loadingMessageUpdated
(
i18n
(
"Loading project clips..."
));
}
// Load bin clips
auto
currentLocale
=
strdup
(
setlocale
(
LC_ALL
,
nullptr
));
qDebug
()
<<
"Init bin; Current LC
_ALL
"
<<
currentLocale
;
auto
currentLocale
=
strdup
(
setlocale
(
MLT_LC_CATEGORY
,
nullptr
));
qDebug
()
<<
"Init bin; Current LC"
<<
currentLocale
;
// Load folders
Mlt
::
Properties
folderProperties
;
Mlt
::
Properties
playlistProps
(
playlist
.
get_properties
());
...
...
src/lib/localeHandling.cpp
View file @
75e57704
...
...
@@ -21,12 +21,12 @@ auto LocaleHandling::setLocale(const QString &lcName) -> QString
localesToTest
<<
lcName
<<
lcName
+
".utf-8"
<<
lcName
+
".UTF-8"
<<
lcName
+
".utf8"
<<
lcName
+
".UTF8"
;
for
(
const
auto
&
locale
:
qAsConst
(
localesToTest
))
{
#ifdef Q_OS_FREEBSD
auto
*
result
=
setlocale
(
LC_NUMERIC
,
locale
.
toStdString
().
c_str
());
auto
*
result
=
setlocale
(
MLT_LC_CATEGORY
,
locale
.
toStdString
().
c_str
());
#else
auto
*
result
=
std
::
setlocale
(
LC_NUMERIC
,
locale
.
toStdString
().
c_str
());
auto
*
result
=
std
::
setlocale
(
MLT_LC_CATEGORY
,
locale
.
toStdString
().
c_str
());
#endif
if
(
result
!=
nullptr
)
{
::
qputenv
(
"
LC_N
U
ME
RIC"
,
locale
.
toStdString
().
c_str
());
::
qputenv
(
MLT_
LC_N
A
ME
,
locale
.
toStdString
().
c_str
());
newLocale
=
locale
;
break
;
}
...
...
@@ -40,11 +40,11 @@ auto LocaleHandling::setLocale(const QString &lcName) -> QString
void
LocaleHandling
::
resetLocale
()
{
#ifdef Q_OS_FREEBSD
setlocale
(
LC_NUMERIC
,
"C"
);
setlocale
(
MLT_LC_CATEGORY
,
"C"
);
#else
std
::
setlocale
(
LC_NUMERIC
,
"C"
);
std
::
setlocale
(
MLT_LC_CATEGORY
,
"C"
);
#endif
::
qputenv
(
"
LC_N
U
ME
RIC"
,
"C"
);
::
qputenv
(
MLT_
LC_N
A
ME
,
"C"
);
qDebug
()
<<
"LC_NUMERIC reset to C"
;
}
...
...
src/lib/localeHandling.h
View file @
75e57704
...
...
@@ -13,6 +13,15 @@ the Free Software Foundation, either version 3 of the License, or
#include <QtCore/QLocale>
#include <QtCore/QString>
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
# define MLT_LC_CATEGORY LC_NUMERIC
# define MLT_LC_NAME "LC_NUMERIC"
#else
# define MLT_LC_CATEGORY LC_ALL
# define MLT_LC_NAME "LC_ALL"
#endif
class
LocaleHandling
{
public:
...
...
src/main.cpp
View file @
75e57704
...
...
@@ -92,6 +92,7 @@ int main(int argc, char *argv[])
QCoreApplication
::
setAttribute
(
Qt
::
AA_UseOpenGLES
,
true
);
}
#endif
qputenv
(
"LANG"
,
QLocale
().
name
().
toUtf8
());
QApplication
app
(
argc
,
argv
);
app
.
setApplicationName
(
QStringLiteral
(
"kdenlive"
));
app
.
setOrganizationDomain
(
QStringLiteral
(
"kde.org"
));
...
...
src/mltconnection.cpp
View file @
75e57704
...
...
@@ -89,9 +89,9 @@ MltConnection::MltConnection(const QString &mltPath)
LocaleHandling
::
resetLocale
();
#ifdef Q_OS_FREEBSD
auto
locale
=
strdup
(
setlocale
(
LC_ALL
,
nullptr
));
auto
locale
=
strdup
(
setlocale
(
MLT_LC_CATEGORY
,
nullptr
));
#else
auto
locale
=
strdup
(
std
::
setlocale
(
LC_ALL
,
nullptr
));
auto
locale
=
strdup
(
std
::
setlocale
(
MLT_LC_CATEGORY
,
nullptr
));
#endif
qDebug
()
<<
"NEW LC_ALL"
<<
locale
;
...
...
src/monitor/monitor.cpp
View file @
75e57704
...
...
@@ -1693,20 +1693,7 @@ void Monitor::resetConsumer(bool fullReset)
const
QString
Monitor
::
sceneList
(
const
QString
&
root
,
const
QString
&
fullPath
)
{
// on Windows, the xml consumer doesn't follow LC_NUMERIC, so enforce locale
#ifdef Q_OS_WIN
auto
currentLocale
=
strdup
(
setlocale
(
LC_ALL
,
nullptr
));
std
::
setlocale
(
LC_ALL
,
"C"
);
::
qputenv
(
"LC_ALL"
,
"C"
);
qDebug
()
<<
"Current locale is "
<<
currentLocale
;
#endif
const
QString
resultScene
=
m_glMonitor
->
sceneList
(
root
,
fullPath
);
#ifdef Q_OS_WIN
::
qputenv
(
"LC_ALL"
,
currentLocale
);
std
::
setlocale
(
LC_ALL
,
currentLocale
);
LocaleHandling
::
resetLocale
();
#endif
return
resultScene
;
return
m_glMonitor
->
sceneList
(
root
,
fullPath
);
}
void
Monitor
::
updateClipZone
(
const
QPoint
zone
)
...
...
Eugen Mohr
@emohr
mentioned in issue
#780 (closed)
·
Aug 31, 2020
mentioned in issue
#780 (closed)
mentioned in issue #780
Toggle commit list
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