]> git.sesse.net Git - kdenlive/commitdiff
New: option to resize monitor to current project size (50% or 100%)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Aug 2008 21:13:46 +0000 (21:13 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Aug 2008 21:13:46 +0000 (21:13 +0000)
svn path=/branches/KDE4/; revision=2373

src/mainwindow.cpp
src/mainwindow.h
src/monitor.cpp
src/monitor.h

index a3286563a2fa9020f47fd1d2fd2c0b3272813fa9..19ca4fa695564d1ae9e6e1fa9280d116d7975244 100644 (file)
@@ -414,6 +414,21 @@ void MainWindow::slotConnectMonitors() {
     connect(m_clipMonitor->render, SIGNAL(removeInvalidClip(int)), m_projectList, SLOT(slotRemoveInvalidClip(int)));
 
     connect(m_clipMonitor, SIGNAL(refreshClipThumbnail(int)), m_projectList, SLOT(slotRefreshClipThumbnail(int)));
+
+    connect(m_clipMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustClipMonitor()));
+    connect(m_projectMonitor, SIGNAL(adjustMonitorSize()), this, SLOT(slotAdjustProjectMonitor()));
+}
+
+void MainWindow::slotAdjustClipMonitor() {
+    clipMonitorDock->updateGeometry();
+    clipMonitorDock->adjustSize();
+    m_clipMonitor->resetSize();
+}
+
+void MainWindow::slotAdjustProjectMonitor() {
+    projectMonitorDock->updateGeometry();
+    projectMonitorDock->adjustSize();
+    m_projectMonitor->resetSize();
 }
 
 void MainWindow::setupActions() {
@@ -1099,7 +1114,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     m_monitorManager->setTimecode(doc->timecode());
     doc->setRenderer(m_projectMonitor->render);
     m_commandStack->setActiveStack(doc->commandStack());
-
     doc->updateAllProjectClips();
 
     if (m_commandStack->isClean()) kDebug() << "////////////  UNDO STACK IS CLEAN";
index 640d8032781dae9c2453e557429f404e1895d68e..07a54664b3f50c7bd86673fd69b68fb2b49d8866 100644 (file)
@@ -230,6 +230,9 @@ private slots:
     void slotPasteEffects();
     void slotReloadEffects();
     void slotChangeClipSpeed();
+
+    void slotAdjustClipMonitor();
+    void slotAdjustProjectMonitor();
 };
 
 
index 83572f93dc0cf17009b0b038eb3cf4e94bedf269..e198d35292df67bd551d5eb53116cdf6d6acd56e 100644 (file)
@@ -23,6 +23,7 @@
 #include <QMenu>
 #include <QToolButton>
 #include <QToolBar>
+#include <QDesktopWidget>
 
 #include <KDebug>
 #include <KLocale>
@@ -43,6 +44,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
     QVBoxLayout *layout = new QVBoxLayout;
     layout->addWidget(m_ruler);
     ui.ruler_frame->setLayout(layout);
+    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     setMinimumHeight(200);
     QToolBar *toolbar = new QToolBar(name, this);
     QVBoxLayout *layout2 = new QVBoxLayout;
@@ -76,12 +78,28 @@ Monitor::Monitor(QString name, MonitorManager *manager, QWidget *parent)
 
     playButton->setDefaultAction(m_playAction);
 
+
+    QToolButton *configButton = new QToolButton(toolbar);
+    QMenu *configMenu = new QMenu(i18n("Misc..."), this);
+    configButton->setIcon(KIcon("system-run"));
+    configButton->setMenu(configMenu);
+    configButton->setPopupMode(QToolButton::QToolButton::InstantPopup);
+    toolbar->addWidget(configButton);
+    QAction *resize1Action = configMenu->addAction(KIcon("transform-scale"), i18n("Resize (100%)"));
+    connect(resize1Action, SIGNAL(triggered()), this, SLOT(slotSetSizeOneToOne()));
+    QAction *resize2Action = configMenu->addAction(KIcon("transform-scale"), i18n("Resize (50%)"));
+    connect(resize2Action, SIGNAL(triggered()), this, SLOT(slotSetSizeOneToTwo()));
+
     m_timePos = new KRestrictedLine(this);
     m_timePos->setInputMask("99:99:99:99");
     toolbar->addWidget(m_timePos);
 
     layout2->addWidget(toolbar);
     ui.button_frame->setLayout(layout2);
+    const int toolHeight = toolbar->iconSize().height() * 3;
+    kDebug()<<"//////   MONITOR TOOL HEIGHT: "<<toolHeight;
+    ui.button_frame->setMinimumHeight(toolHeight);
+    ui.button_frame->setMaximumHeight(toolHeight);
 
     //m_ruler->setPixelPerMark(3);
 
@@ -124,9 +142,53 @@ QString Monitor::name() const {
     return m_name;
 }
 
+void Monitor::slotSetSizeOneToOne() {
+    QRect r = QApplication::desktop()->screenGeometry();
+    const int maxWidth = r.width() - 20;
+    const int maxHeight = r.height() - 20;
+    int width = render->renderWidth();
+    int height = render->renderHeight();
+    kDebug()<<"// render info: "<<width<<"x"<<height;
+    while (width >= maxWidth || height >= maxHeight) {
+       width = width * 0.8;
+       height = height * 0.8;
+    }
+    kDebug()<<"// MONITOR; set SIZE: "<<width<<", "<<height;
+    ui.video_frame->setFixedSize(width, height);
+    updateGeometry();
+    adjustSize();
+    //ui.video_frame->setMinimumSize(0, 0);
+    emit adjustMonitorSize();
+}
+
+void Monitor::slotSetSizeOneToTwo() {
+    QRect r = QApplication::desktop()->screenGeometry();
+    const int maxWidth = r.width() - 20;
+    const int maxHeight = r.height() - 20;
+    int width = render->renderWidth() / 2;
+    int height = render->renderHeight() / 2;
+    kDebug()<<"// render info: "<<width<<"x"<<height;
+    while (width >= maxWidth || height >= maxHeight) {
+       width = width * 0.8;
+       height = height * 0.8;
+    }
+    kDebug()<<"// MONITOR; set SIZE: "<<width<<", "<<height;
+    ui.video_frame->setFixedSize(width, height);
+    updateGeometry();
+    adjustSize();
+    //ui.video_frame->setMinimumSize(0, 0);
+    emit adjustMonitorSize();
+}
+
+void Monitor::resetSize() {
+    ui.video_frame->setMinimumSize(0, 0);
+}
+
 // virtual
 void Monitor::mousePressEvent(QMouseEvent * event) {
-    if (event->button() != Qt::RightButton) slotPlay();
+    if (event->button() != Qt::RightButton) {
+       slotPlay();
+    }
     else m_contextMenu->popup(event->globalPos());
 }
 
index d0814a7162fa113aa1b06e323c645121471a4dc5..ca2b52952b936dfac2621aeecc6f5e6830d8f3b1 100644 (file)
@@ -51,7 +51,7 @@ public:
     Render *render;
     void resetProfile();
     QString name() const;
-
+    void resetSize();
 
 protected:
     virtual void mousePressEvent(QMouseEvent * event);
@@ -82,6 +82,8 @@ private slots:
     void rendererStopped(int pos);
     void slotExtractCurrentFrame();
     void slotSetThumbFrame();
+    void slotSetSizeOneToOne();
+    void slotSetSizeOneToTwo();
 
 public slots:
     void slotOpenFile(const QString &);
@@ -105,6 +107,7 @@ signals:
     void renderPosition(int);
     void durationChanged(int);
     void refreshClipThumbnail(int);
+    void adjustMonitorSize();
 };
 
 #endif