]> git.sesse.net Git - kdenlive/commitdiff
Fix locale problem (inserted a thousand separator into numbers when converting to...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Sep 2011 11:02:49 +0000 (11:02 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 6 Sep 2011 11:02:49 +0000 (11:02 +0000)
svn path=/trunk/kdenlive/; revision=5856

src/documentvalidator.cpp
src/effectstackedit.cpp
src/initeffects.cpp
src/kdenlivedoc.cpp
src/mainwindow.cpp
src/trackview.cpp
src/trackview.h

index 64c595c790932a845e561d1319e056274ff0b02b..d13fd99eec742d9db2416b5dc6e5129b93baad34 100644 (file)
@@ -62,7 +62,8 @@ bool DocumentValidator::validate(const double currentVersion)
         setlocale(LC_NUMERIC, mlt.attribute("LC_NUMERIC").toUtf8().constData());
         documentLocale = QLocale(mlt.attribute("LC_NUMERIC"));
     }
-
+    
+    documentLocale.setNumberOptions(QLocale::OmitGroupSeparator);
     if (documentLocale != QLocale()) {
         QLocale::setDefault(documentLocale);
         // locale conversion might need to be redone
index 2ed0bc631b4c2e2c24c2585370b9fee01ecfd649..7ade3c50e773669ecd4746635f664b5c46007524 100644 (file)
@@ -646,11 +646,10 @@ QString EffectStackEdit::getWipeString(wipeInfo info)
 void EffectStackEdit::collectAllParameters()
 {
     if (m_valueItems.isEmpty() || m_params.isNull()) return;
-    QLocale locale;
-    locale.setNumberOptions(QLocale::OmitGroupSeparator);
     const QDomElement oldparam = m_params.cloneNode().toElement();
     QDomElement newparam = oldparam.cloneNode().toElement();
     QDomNodeList namenode = newparam.elementsByTagName("parameter");
+    QLocale locale;
 
     for (int i = 0; i < namenode.count() ; i++) {
         QDomNode pa = namenode.item(i);
index 1cf161b37f8b58ad9cb9f15fba5d6cc35b5b4016..a388b11394a7ab463d6e3d33fb6e1636eff79c99 100644 (file)
@@ -344,9 +344,10 @@ void initEffects::parseEffectFile(EffectsList *customEffectList, EffectsList *au
         kDebug() << "Effect broken: " << name;
         return;
     }
-    QLocale locale;
+
     bool needsLocaleConversion = false;
     for (int i = 0; !effects.item(i).isNull(); ++i) {
+        QLocale locale;
         documentElement = effects.item(i).toElement();
         QString tag = documentElement.attribute("tag", QString());
         if (documentElement.hasAttribute("LC_NUMERIC")) {
@@ -356,6 +357,7 @@ void initEffects::parseEffectFile(EffectsList *customEffectList, EffectsList *au
                 needsLocaleConversion = true;
             }
         }
+        locale.setNumberOptions(QLocale::OmitGroupSeparator);
 
         if (needsLocaleConversion) {
             // we need to convert all numbers to the system's locale (for example 0.5 -> 0,5)
index 23484f674f44fc3e6ec3ae863be1115466af2c2a..fced33349963a9128fc6abb3380ea7b6cb06f8f5 100644 (file)
@@ -101,7 +101,9 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
 
     if (QLocale() != QLocale::system()) {
         setlocale(LC_NUMERIC, "");
-        QLocale::setDefault(QLocale::system());
+        QLocale systemLocale = QLocale::system();
+        systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
+        QLocale::setDefault(systemLocale);
         // locale conversion might need to be redone
         initEffects::parseEffectFiles();
     }
index c3efd3dabd70eab4dd1ee5422be529f0b67f5c73..d8a46d373371173a04b5243e8fe1b7aee0b637f5 100644 (file)
@@ -87,7 +87,6 @@
 #include <KProcess>
 #include <KActionMenu>
 #include <KMenu>
-#include <locale.h>
 #include <ktogglefullscreenaction.h>
 #include <KFileItem>
 #include <KNotification>
@@ -148,12 +147,19 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
 #endif /* NO_JOGSHUTTLE */
     m_findActivated(false),
     m_stopmotion(NULL)
-{
+{   
     qRegisterMetaType<QVector<int16_t> > ();
+
+    // Init locale
+    QLocale systemLocale = QLocale();
+    systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
+    QLocale::setDefault(systemLocale);
+
     // Create DBus interface
     new MainWindowAdaptor(this);
     QDBusConnection dbus = QDBusConnection::sessionBus();
     dbus.registerObject("/MainWindow", this);
+
     if (!KdenliveSettings::colortheme().isEmpty()) slotChangePalette(NULL, KdenliveSettings::colortheme());
     setFont(KGlobalSettings::toolBarFont());
     parseProfiles(MltPath);
index 1d2af8aef72e9ee5e86c9078141fddb74974cc0f..471706eb505385c1043489299e25392f6fc278c9 100644 (file)
@@ -406,8 +406,6 @@ void TrackView::parseDocument(QDomDocument doc)
             }
         }
     }
-
-
     QDomElement infoXml = mlt.firstChildElement("kdenlivedoc");
 
     // Add guides
@@ -600,8 +598,9 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNod
             double speed = 1.0;
             int strobe = 1;
             if (idString.startsWith("slowmotion")) {
+                QLocale locale;
                 id = idString.section(':', 1, 1);
-                speed = m_locale.toDouble(idString.section(':', 2, 2));
+                speed = locale.toDouble(idString.section(':', 2, 2));
                 strobe = idString.section(':', 3, 3).toInt();
                 if (strobe == 0) strobe = 1;
             }
@@ -742,6 +741,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNod
 void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex)
 {
     int effectNb = 0;
+    QLocale locale;
     for (int ix = 0; ix < effects.count(); ix++) {
         bool disableeffect = false;
         QDomElement effect = effects.at(ix).toElement();
@@ -823,8 +823,8 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                 // add first keyframe
                 if (effectout <= effectin) {
                     // there is only one keyframe
-                    keyframes.append(QString::number(effectin) + ':' + m_locale.toString(startvalue) + ';');
-                } else keyframes.append(QString::number(effectin) + ':' + m_locale.toString(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
+                    keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';');
+                } else keyframes.append(QString::number(effectin) + ':' + locale.toString(startvalue) + ';' + QString::number(effectout) + ':' + QString::number(endvalue) + ';');
                 QDomNode lastParsedEffect;
                 ix++;
                 QDomNode n2 = effects.at(ix);
@@ -849,7 +849,7 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                         }
                     }
                     if (continueParsing) {
-                        keyframes.append(QString::number(effectout) + ':' + m_locale.toString(endvalue) + ';');
+                        keyframes.append(QString::number(effectout) + ':' + locale.toString(endvalue) + ';');
                         ix++;
                     }
                 }
@@ -896,14 +896,14 @@ void TrackView::slotAddProjectEffects(QDomNodeList effects, QDomElement parentNo
                             QStringList kfrs = paramvalue.split(";");
                             for (int l = 0; l < kfrs.count(); l++) {
                                 QString fr = kfrs.at(l).section('=', 0, 0);
-                                double val = m_locale.toDouble(kfrs.at(l).section('=', 1, 1));
-                                //kfrs[l] = fr + ":" + m_locale.toString((int)(val * fact));
+                                double val = locale.toDouble(kfrs.at(l).section('=', 1, 1));
+                                //kfrs[l] = fr + ":" + locale.toString((int)(val * fact));
                                 kfrs[l] = fr + ":" + QString::number((int) (val * fact));
                             }
                             e.setAttribute("keyframes", kfrs.join(";"));
                         } else if (type == "double" || type == "constant") {
                             bool ok;
-                            e.setAttribute("value", m_locale.toDouble(paramvalue, &ok) * fact);
+                            e.setAttribute("value", locale.toDouble(paramvalue, &ok) * fact);
                             if (!ok)
                                 e.setAttribute("value", paramvalue);
                         } else {
index b7ea50dbeda36b1a84f5a041807944c15ee240c1..5208fbce00d7840f010c6b23515e1e20b177eb4c 100644 (file)
@@ -100,11 +100,11 @@ private:
     KdenliveDoc *m_doc;
     int m_verticalZoom;
     QString m_documentErrors;
-    QLocale m_locale;
     void parseDocument(QDomDocument doc);
     int slotAddProjectTrack(int ix, QDomElement xml, bool locked, QDomNodeList producers);
     DocClipBase *getMissingProducer(const QString id) const;
     void adjustTrackHeaders();
+    /** @brief Add effects from the xml. Returns true if some effect was upgraded, false if everything went fine.*/
     void slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex);
 
 private slots: