Commit 8394f051 authored by Till Theato's avatar Till Theato
Browse files

- Add controls to zoom monitor scene

- Save whether parameters should be updated while monitor scene changes

svn path=/trunk/kdenlive/; revision=4738
parent ca57dec0
......@@ -68,14 +68,13 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
m_ui.buttonSync->setIcon(KIcon("insert-link"));
m_ui.buttonSync->setToolTip(i18n("Synchronize with timeline cursor"));
m_ui.buttonSync->setCheckable(true);
m_ui.buttonSync->setChecked(KdenliveSettings::transitionfollowcursor());
connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));
connect(m_timeline, SIGNAL(keyframeMoved(int)), this, SLOT(slotKeyframeMoved(int)));
connect(m_timeline, SIGNAL(addKeyframe(int)), this, SLOT(slotAddKeyframe(int)));
connect(m_timeline, SIGNAL(removeKeyframe(int)), this, SLOT(slotDeleteKeyframe(int)));
connect(m_timePos, SIGNAL(editingFinished()), this , SLOT(slotPositionChanged()));
connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotPositionChanged()));
connect(m_ui.buttonPrevious, SIGNAL(clicked()), this, SLOT(slotPreviousKeyframe()));
connect(m_ui.buttonNext, SIGNAL(clicked()), this, SLOT(slotNextKeyframe()));
connect(m_ui.buttonAddDelete, SIGNAL(clicked()), this, SLOT(slotAddDeleteKeyframe()));
......@@ -123,14 +122,35 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
m_ui.buttonConfig->setIcon(KIcon("system-run"));
m_ui.buttonConfig->setToolTip(i18n("Show/Hide settings"));
m_ui.buttonConfig->setCheckable(true);
m_ui.groupSettings->setHidden(true);
m_ui.checkDirectUpdate->setChecked(m_scene->getDirectUpdate());
m_ui.buttonShowScene->setIcon(KIcon("video-display"));
m_ui.buttonShowScene->setToolTip(i18n("Show monitor scene"));
m_ui.buttonDirectUpdate->setIcon(KIcon("transform-scale"));
m_ui.buttonDirectUpdate->setToolTip(i18n("Update parameters while monitor scene changes"));
m_ui.buttonDirectUpdate->setChecked(KdenliveSettings::monitorscene_directupdate());
m_ui.buttonZoomFit->setIcon(KIcon("zoom-fit-best"));
m_ui.buttonZoomFit->setToolTip(i18n("Fit zoom to monitor size"));
m_ui.buttonZoomOriginal->setIcon(KIcon("zoom-original"));
m_ui.buttonZoomOriginal->setToolTip(i18n("Original size"));
m_ui.buttonZoomIn->setIcon(KIcon("zoom-in"));
m_ui.buttonZoomIn->setToolTip(i18n("Zoom in"));
m_ui.buttonZoomOut->setIcon(KIcon("zoom-out"));
m_ui.buttonZoomOut->setToolTip(i18n("Zoom out"));
connect(m_ui.buttonConfig, SIGNAL(toggled(bool)), m_ui.groupSettings, SLOT(setVisible(bool)));
connect(m_ui.checkShowScene, SIGNAL(toggled(bool)), this, SLOT(slotShowScene(bool)));
connect(m_ui.checkDirectUpdate, SIGNAL(toggled(bool)), m_scene, SLOT(slotSetDirectUpdate(bool)));
connect(m_ui.sliderZoom, SIGNAL(valueChanged(int)), m_scene, SLOT(slotZoom(int)));
connect(m_scene, SIGNAL(zoomChanged(int)), m_ui.sliderZoom, SLOT(setValue(int)));
connect(m_ui.buttonZoomFit, SIGNAL(clicked()), m_scene, SLOT(slotZoomFit()));
connect(m_ui.buttonZoomOriginal, SIGNAL(clicked()), m_scene, SLOT(slotZoomOriginal()));
connect(m_ui.buttonZoomIn, SIGNAL(clicked()), m_scene, SLOT(slotZoomIn()));
connect(m_ui.buttonZoomOut, SIGNAL(clicked()), m_scene, SLOT(slotZoomOut()));
m_scene->slotZoomFit();
connect(m_ui.buttonShowScene, SIGNAL(toggled(bool)), this, SLOT(slotShowScene(bool)));
connect(m_ui.buttonDirectUpdate, SIGNAL(toggled(bool)), m_scene, SLOT(slotSetDirectUpdate(bool)));
connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateGeometry()));
......
......@@ -593,6 +593,11 @@
<label>True if slideshow default method is mimetype.</label>
<default>true</default>
</entry>
<entry name="monitorscene_directupdate" type="Bool">
<label>Update parameters while monitor scene changes.</label>
<default>false</default>
</entry>
</group>
</kcfg>
......@@ -36,7 +36,7 @@ MonitorScene::MonitorScene(Render *renderer, QObject* parent) :
m_backgroundImage(QImage()),
m_enabled(true),
m_modified(false),
m_directUpdate(false)
m_zoom(1.0)
{
setBackgroundBrush(QBrush(QColor(KdenliveSettings::window_background().name())));
......@@ -93,10 +93,8 @@ void MonitorScene::slotUpdateBackground(bool fit)
if (m_view && m_view->isVisible()) {
if (m_lastUpdate.elapsed() > 200) {
m_background->setPixmap(QPixmap::fromImage(m_backgroundImage, Qt::ThresholdDither));
if (fit) {
m_view->fitInView(m_frameBorder, Qt::KeepAspectRatio);
m_view->centerOn(m_frameBorder);
}
if (fit)
slotZoomFit();
m_lastUpdate.start();
}
}
......@@ -104,12 +102,7 @@ void MonitorScene::slotUpdateBackground(bool fit)
void MonitorScene::slotSetDirectUpdate(bool directUpdate)
{
m_directUpdate = directUpdate;
}
bool MonitorScene::getDirectUpdate()
{
return m_directUpdate;
KdenliveSettings::setMonitorscene_directupdate(directUpdate);
}
void MonitorScene::slotSetBackgroundImage(const QImage &image)
......@@ -118,6 +111,45 @@ void MonitorScene::slotSetBackgroundImage(const QImage &image)
slotUpdateBackground();
}
void MonitorScene::slotZoom(int value)
{
if (m_view) {
m_zoom = value / 100.0;
m_view->resetTransform();
m_view->scale(m_zoom, m_zoom);
emit zoomChanged(value);
}
}
void MonitorScene::slotZoomFit()
{
if (m_view) {
m_view->fitInView(m_frameBorder, Qt::KeepAspectRatio);
m_view->centerOn(m_frameBorder);
m_zoom = m_view->matrix().m11();
emit zoomChanged((int)(m_zoom * 100));
}
}
void MonitorScene::slotZoomOriginal()
{
slotZoom(100);
if (m_view)
m_view->centerOn(m_frameBorder);
}
void MonitorScene::slotZoomOut()
{
slotZoom(qMax(0, (int)(m_zoom * 100 - 1)));
}
void MonitorScene::slotZoomIn()
{
slotZoom(qMin(300, (int)(m_zoom * 100 + 1)));
}
resizeModes MonitorScene::getResizeMode(QGraphicsRectItem *item, QPoint pos)
{
if (!m_view)
......@@ -311,7 +343,7 @@ void MonitorScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QGraphicsScene::mouseMoveEvent(event);
}
if (m_modified && m_directUpdate) {
if (m_modified && KdenliveSettings::monitorscene_directupdate()) {
emit actionFinished();
m_modified = false;
}
......
......@@ -35,7 +35,6 @@ public:
MonitorScene(Render *renderer, QObject* parent = 0);
void setUp();
void setEnabled(bool enabled = true);
bool getDirectUpdate();
void resetProfile();
protected:
......@@ -47,6 +46,12 @@ public slots:
void slotUpdateBackground(bool fit = false);
void slotSetDirectUpdate(bool directUpdate);
void slotZoom(int value);
void slotZoomFit();
void slotZoomOriginal();
void slotZoomIn();
void slotZoomOut();
private slots:
void slotSetBackgroundImage(const QImage &image);
......@@ -64,10 +69,11 @@ private:
QImage m_backgroundImage;
bool m_enabled;
bool m_modified;
bool m_directUpdate;
qreal m_zoom;
signals:
void actionFinished();
void zoomChanged(int);
};
#endif
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>366</width>
<height>282</height>
<height>305</height>
</rect>
</property>
<property name="windowTitle">
......@@ -375,26 +375,23 @@
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<widget class="Line" name="line_3">
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>15</width>
<height>20</height>
</size>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
......@@ -419,6 +416,9 @@
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
......@@ -464,7 +464,7 @@
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>4</number>
</property>
......@@ -477,27 +477,77 @@
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QCheckBox" name="checkShowScene">
<item row="0" column="0">
<widget class="QToolButton" name="buttonShowScene">
<property name="text">
<string>Show on-monitor scene</string>
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkDirectUpdate">
<item row="1" column="0">
<widget class="QToolButton" name="buttonZoomFit">
<property name="text">
<string>Update while monitor scene changes</string>
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSlider" name="sliderZoom">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>300</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="buttonZoomOriginal">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="buttonDirectUpdate">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QToolButton" name="buttonZoomIn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="buttonZoomOut">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="4">
<item row="4" column="0" colspan="4">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment