]> git.sesse.net Git - kdenlive/commitdiff
save zoom factor in document
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 16 Jul 2008 22:55:33 +0000 (22:55 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 16 Jul 2008 22:55:33 +0000 (22:55 +0000)
svn path=/branches/KDE4/; revision=2320

src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/trackview.cpp
src/trackview.h

index 3bebe75a166691868bd5efbb71e9f4c765a43dea..8048bd6c2aefe53974650e321b36374fa461a45b 100644 (file)
@@ -37,7 +37,7 @@
 #include "mainwindow.h"
 
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0) {
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent): QObject(parent), m_render(NULL), m_url(url), m_projectFolder(projectFolder), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false), m_documentLoadingProgress(0), m_documentLoadingStep(0.0), m_startPos(0), m_zoom(4) {
     kDebug() << "// init profile, ratnum: " << profile.frame_rate_num << ", " << profile.frame_rate_num << ", width: " << profile.width;
     m_clipManager = new ClipManager(this);
     if (!url.isEmpty()) {
@@ -52,6 +52,7 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoPro
                 QDomElement infoXml = infoXmlNode.toElement();
                 QString profilePath = infoXml.attribute("profile");
                 m_startPos = infoXml.attribute("position").toInt();
+                m_zoom = infoXml.attribute("zoom").toInt();
                 if (!profilePath.isEmpty()) setProfilePath(profilePath);
                 double version = infoXml.attribute("version").toDouble();
                 if (version < 0.7) convertDocument(version);
@@ -240,6 +241,14 @@ void KdenliveDoc::slotAutoSave() {
 
 }
 
+void KdenliveDoc::setZoom(int factor) {
+    m_zoom = factor;
+}
+
+int KdenliveDoc::zoom() const {
+    return m_zoom;
+}
+
 void KdenliveDoc::convertDocument(double version) {
     // Opening a old Kdenlive document
     QDomNode westley = m_document.elementsByTagName("westley").at(1);
@@ -355,6 +364,7 @@ QDomElement KdenliveDoc::documentInfoXml() {
     addedXml.setAttribute("version", "0.7");
     addedXml.setAttribute("profile", profilePath());
     addedXml.setAttribute("position", m_render->seekPosition().frames(m_fps));
+    addedXml.setAttribute("zoom", m_zoom);
     QList <DocClipBase*> list = m_clipManager->documentClipList();
     for (int i = 0; i < list.count(); i++) {
         e = list.at(i)->toXML();
index d2102c6ee1edb8371c447ca3415a4ffe9227c88a..1e758ad6028149ae4fac832e3bfce3fdf74b2eff 100644 (file)
@@ -100,6 +100,8 @@ Q_OBJECT public:
     void loadingProgressed();
     void updateAllProjectClips();
     void syncGuides(QList <Guide *> guides);
+    void setZoom(int factor);
+    int zoom() const;
 
 private:
     KUrl m_url;
@@ -107,6 +109,7 @@ private:
     QDomDocument m_document;
     QString m_projectName;
     double m_fps;
+    int m_zoom;
     /** Cursor position at document opening */
     int m_startPos;
     int m_width;
index c3cdefbd07fbdfd2188f4fba8c8ab146da418ccd..870b10b3524550df4b64bff784cb6e8a650cfef3 100644 (file)
@@ -445,6 +445,7 @@ void MainWindow::setupActions() {
 
     m_zoomSlider = new QSlider(Qt::Horizontal, this);
     m_zoomSlider->setMaximum(13);
+    m_zoomSlider->setPageStep(1);
 
     m_zoomSlider->setMaximumWidth(150);
     m_zoomSlider->setMinimumWidth(100);
@@ -1031,7 +1032,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     connect(trackView, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotActivateEffectStackView()));
     connect(trackView, SIGNAL(transitionItemSelected(Transition*)), transitionConfig, SLOT(slotTransitionItemSelected(Transition*)));
     connect(trackView, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotActivateTransitionView()));
-    m_zoomSlider->setValue(trackView->currentZoom());
+    m_zoomSlider->setValue(doc->zoom());
     connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int)));
     connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
     connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
index d2da55749d7af5e0d3a1cb3c3b4a11949007ec64..333d2aacd56bb902fed8a508607303943cb3f9b2 100644 (file)
@@ -35,7 +35,7 @@
 #include "customtrackview.h"
 
 TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
-        : QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0), m_currentZoom(4) {
+        : QWidget(parent), m_doc(doc), m_scale(1.0), m_projectTracks(0) {
 
     view = new Ui::TimeLine_UI();
     view->setupUi(this);
@@ -74,19 +74,16 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent)
     connect(m_trackview->verticalScrollBar(), SIGNAL(valueChanged(int)), view->headers_area->verticalScrollBar(), SLOT(setValue(int)));
     connect(m_trackview, SIGNAL(trackHeightChanged()), this, SLOT(slotRebuildTrackHeaders()));
 
-    parseDocument(doc->toXml());
+    parseDocument(m_doc->toXml());
 
     connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
     connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
     connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
     connect(m_trackview, SIGNAL(clipItemSelected(ClipItem*)), this, SLOT(slotClipItemSelected(ClipItem*)));
     connect(m_trackview, SIGNAL(transitionItemSelected(Transition*)), this, SLOT(slotTransitionItemSelected(Transition*)));
-    slotChangeZoom(m_currentZoom);
+    slotChangeZoom(m_doc->zoom());
 }
 
-int TrackView::currentZoom() const {
-    return m_currentZoom;
-}
 
 int TrackView::duration() const {
     return m_trackview->duration();
@@ -262,10 +259,9 @@ void TrackView::moveCursorPos(int pos) {
 }
 
 void TrackView::slotChangeZoom(int factor) {
-
+    m_doc->setZoom(factor);
     m_ruler->setPixelPerMark(factor);
     m_scale = (double) FRAME_SIZE / m_ruler->comboScale[factor]; // m_ruler->comboScale[m_currentZoom] /
-    m_currentZoom = factor;
     m_trackview->setScale(m_scale);
 }
 
index 6b19deb3a821137054e38b76273846b14a317e8c..8198152e1ee9d093102d62e8e24049733b5c1f2e 100644 (file)
@@ -57,7 +57,6 @@ public:
     void refresh() ;
     int outPoint() const;
     int inPoint() const;
-    int currentZoom() const;
     int fitZoom() const;
 
 
@@ -74,7 +73,6 @@ private:
     int m_projectTracks;
     QString m_editMode;
     QGraphicsScene *m_scene;
-    uint m_currentZoom;
 
     KdenliveDoc *m_doc;
     QVBoxLayout *m_tracksLayout;