]> git.sesse.net Git - kdenlive/commitdiff
Allow to edit projects with a locale different to the one used by Kdenlive. This...
authorTill Theato <root@ttill.de>
Sun, 28 Aug 2011 14:47:54 +0000 (14:47 +0000)
committerTill Theato <root@ttill.de>
Sun, 28 Aug 2011 14:47:54 +0000 (14:47 +0000)
Switching between projects with different locales can still cause problems.

[1] http://kdenlive.org/mantis/view.php?id=2270

svn path=/trunk/kdenlive/; revision=5841

src/documentvalidator.cpp
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/projectlist.cpp
src/renderer.cpp
src/trackview.cpp

index fc46f14fa37b101afaef192c748c75304f147c60..3cc588b8d96fb9c6024ec7cb642d27229d713bee 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "documentvalidator.h"
 #include "definitions.h"
+#include "initeffects.h"
 
 #include <KDebug>
 #include <KMessageBox>
@@ -55,17 +56,18 @@ bool DocumentValidator::validate(const double currentVersion)
     if (mlt.hasAttribute("LC_NUMERIC")) {
         // Set locale for the document
         documentLocale = QLocale(mlt.attribute("LC_NUMERIC"));
-        if (documentLocale.decimalPoint() != QLocale().decimalPoint()) {
-            QDomElement docProperties = kdenliveDoc.firstChildElement("documentproperties");
-            if (docProperties.isNull()) {
-                docProperties = m_doc.createElement("documentproperties");
-                kdenliveDoc.appendChild(docProperties);
-            }
-            docProperties.setAttribute("readonly", 1);
-            KMessageBox::sorry(kapp->activeWindow(), i18n("The document you are opening uses a different locale (%1) than your system. You can only open and render it, no editing is supported unless you change your system's locale.", mlt.attribute("LC_NUMERIC")), i18n("Read only project"));
-        }
     }
 
+    if (documentLocale != QLocale()) {
+        QLocale::setDefault(documentLocale);
+        // locale conversion might need to be redone
+        initEffects::parseEffectFiles();
+    }
+
+    // TODO: remove after string freeze
+    if (0)
+        KMessageBox::sorry(kapp->activeWindow(), i18n("The document you are opening uses a different locale (%1) than your system. You can only open and render it, no editing is supported unless you change your system's locale.", mlt.attribute("LC_NUMERIC")), i18n("Read only project"));
+
     // Upgrade the document to the latest version
     if (!upgrade(documentLocale.toDouble(kdenliveDoc.attribute("version")), currentVersion))
         return false;
@@ -906,6 +908,12 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
         }
     }
 
+    if (version <= 0.87) {
+        if (!m_doc.firstChildElement("mlt").hasAttribute("LC_NUMERIC")) {
+            m_doc.firstChildElement("mlt").setAttribute("LC_NUMERIC", "C");
+        }
+    }
+
     // The document has been converted: mark it as modified
     infoXml.setAttribute("version", currentVersion);
     m_modified = true;
index f453f70dc1ccaf4db089d323f8442fa6e4b195f2..86a73e612f0968f87f4c33e8636ff5467b8192a4 100644 (file)
@@ -52,7 +52,7 @@
 
 #include <mlt++/Mlt.h>
 
-const double DOCUMENTVERSION = 0.87;
+const double DOCUMENTVERSION = 0.88;
 
 KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) :
     QObject(parent),
@@ -95,6 +95,12 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
         m_documentProperties[i.key()] = i.value();
     }
 
+    if (QLocale() != QLocale::system()) {
+        QLocale::setDefault(QLocale::system());
+        // locale conversion might need to be redone
+        initEffects::parseEffectFiles();
+    }
+
     *openBackup = false;
     
     if (!url.isEmpty()) {
@@ -972,7 +978,6 @@ void KdenliveDoc::setUrl(KUrl url)
 
 void KdenliveDoc::setModified(bool mod)
 {
-    if (isReadOnly()) return;
     if (!m_url.isEmpty() && mod && KdenliveSettings::crashrecovery()) {
         m_autoSaveTimer->start(3000);
     }
@@ -1637,11 +1642,6 @@ void KdenliveDoc::backupLastSavedVersion(const QString &path)
     }    
 }
 
-bool KdenliveDoc::isReadOnly() const
-{
-    return m_documentProperties.contains("readonly");
-}
-
 void KdenliveDoc::cleanupBackupFiles()
 {
     KUrl backupFile = m_projectFolder;
index 17bbf9723991ed705de3ccd546fee82789e08427..77818ade0b87d3c5d0b90fa1465871be3c59d2c3 100644 (file)
@@ -162,8 +162,6 @@ Q_OBJECT public:
     static double getDisplayRatio(const QString &path);
     /** @brief Backup the project file */
     void backupLastSavedVersion(const QString &path);
-    /** @brief True if the document was opened in read only mode. */
-    bool isReadOnly() const;
     
 private:
     KUrl m_url;
index 4b534f62d4f630f56cde1cdecc391a763173cacf..8d9b0edc70a3752f72c30d3778c9f56098d7d565 100644 (file)
@@ -2086,13 +2086,6 @@ void MainWindow::doOpenFile(const KUrl &url, KAutoSaveFile *stale)
     m_clipMonitor->refreshMonitor(true);
 
     progressDialog.progressBar()->setValue(4);
-    bool readOnly = !doc->isReadOnly();
-    factory()->container("edit", this)->setEnabled(readOnly);
-    factory()->container("project", this)->setEnabled(readOnly);
-    factory()->container("tool", this)->setEnabled(readOnly);
-    factory()->container("clip", this)->setEnabled(readOnly);
-    factory()->container("timeline", this)->setEnabled(readOnly);
-    factory()->container("monitor", this)->setEnabled(readOnly);
     if (openBackup) slotOpenBackupDialog(url);
 }
 
@@ -2373,7 +2366,7 @@ void MainWindow::slotUpdateMousePosition(int pos)
 
 void MainWindow::slotUpdateDocumentState(bool modified)
 {
-    if (!m_activeDocument || m_activeDocument->isReadOnly()) return;
+    if (!m_activeDocument) return;
     setCaption(m_activeDocument->description(), modified);
     m_saveAction->setEnabled(modified);
     if (modified) {
index ab15315760d8299502545b3249a10de68630f80b..001395d820b0f6badf3231ef232a0ad29b7e483a 100644 (file)
@@ -1522,7 +1522,6 @@ void ProjectList::setDocument(KdenliveDoc *doc)
     m_timecode = doc->timecode();
     m_commandStack = doc->commandStack();
     m_doc = doc;
-    setEnabled(!m_doc->isReadOnly());
 
     QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
     QStringList openedFolders = doc->getExpandedFolders();
index 2142f930f8cb2f92ba923c439d65d7bd976d838d..66e16ecd695bdc2ffb29ba5aa3dd2c81cea1fa35 100644 (file)
@@ -51,6 +51,7 @@
 
 static void kdenlive_callback(void* /*ptr*/, int level, const char* fmt, va_list vl)
 {
+//     kDebug() << "log level" << level << QString().vsprintf(fmt, vl).simplified();
     if (level > MLT_LOG_ERROR) return;
     QString error;
     QApplication::postEvent(qApp->activeWindow(), new MltErrorEvent(error.vsprintf(fmt, vl).simplified()));
@@ -1051,11 +1052,9 @@ int Render::setSceneList(QString playlist, int position)
     }
 
     blockSignals(true);
-    // WARNING: disabled because it caused crashes (see Kdenlive bug #2205 and #2206) - jbm
-    /*if (KdenliveSettings::projectloading_avformatnovalidate())
-        playlist.replace(">avformat</property>", ">avformat-novalidate</property>");
-    else
-        playlist.replace(">avformat-novalidate</property>", ">avformat</property>");*/
+
+    m_locale = QLocale();
+
     m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData());
     if (!m_mltProducer || !m_mltProducer->is_valid()) {
         kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << playlist.toUtf8().constData();
index 4dbd355d928a481e14b81776d27a6bc11d8114ca..1947f5dfa86c329392f525a01d1747647a58174e 100644 (file)
@@ -118,7 +118,6 @@ TrackView::TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent) :
 
     slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
     slotSetZone(m_doc->zone(), false);
-    setEnabled(!doc->isReadOnly());
 }
 
 TrackView::~TrackView()
@@ -200,7 +199,6 @@ void TrackView::parseDocument(QDomDocument doc)
 
     // parse project tracks
     QDomElement mlt = doc.firstChildElement("mlt");
-    if (mlt.hasAttribute("LC_NUMERIC")) m_locale = QLocale(mlt.attribute("LC_NUMERIC"));
     QDomElement tractor = mlt.firstChildElement("tractor");
     QDomNodeList tracks = tractor.elementsByTagName("track");
     QDomNodeList playlists = doc.elementsByTagName("playlist");