aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-05-12 00:12:34 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-05-12 00:12:34 +0200
commitb74d0799472b09c71e3a36c470e5db05685b0c7b (patch)
tree6f7202668af8961d77592d9478853c8c2e0d12db
parenta09fe55258be04f77a9886e580533d2009d07943 (diff)
More fixes for split screen effect, fix qml scene when resizing
-rw-r--r--data/kdenlivemonitorsplit.qml29
-rw-r--r--src/monitor/glwidget.cpp21
-rw-r--r--src/monitor/monitor.cpp12
-rw-r--r--src/monitor/monitor.h2
-rw-r--r--src/ui/transitionsettings_ui.ui35
5 files changed, 56 insertions, 43 deletions
diff --git a/data/kdenlivemonitorsplit.qml b/data/kdenlivemonitorsplit.qml
index 91f637b..16450a4 100644
--- a/data/kdenlivemonitorsplit.qml
+++ b/data/kdenlivemonitorsplit.qml
@@ -1,28 +1,39 @@
import QtQuick 2.0
Item {
- id: rootsplit
+ id: root
objectName: "rootsplit"
// default size, but scalable by user
height: 300; width: 400
- signal qmlMoveSplit(real percent)
+ signal qmlMoveSplit()
property int splitterPos
+ property point center
+ property double scale
+ // percentage holds splitter pos relative to the scene percentage
+ property double percentage
+ // realpercent holds splitter pos relative to the frame width percentage
+ property double realpercent
+
+ percentage: 0.5
+ realpercent: 0.5
splitterPos: this.width / 2
MouseArea {
- width: rootsplit.width; height: rootsplit.height
+ width: root.width; height: root.height
anchors.centerIn: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
onPressed: {
- rootsplit.qmlMoveSplit(mouseX / width)
- rootsplit.splitterPos = mouseX
+ root.percentage = mouseX / width
+ root.splitterPos = mouseX
+ root.qmlMoveSplit()
}
onPositionChanged: {
if (pressed) {
- rootsplit.qmlMoveSplit(mouseX / width)
- rootsplit.splitterPos = mouseX
+ root.percentage = mouseX / width
+ root.splitterPos = mouseX
+ root.qmlMoveSplit()
}
timer.restart()
splitter.visible = true
@@ -33,10 +44,10 @@ Item {
Rectangle {
id: splitter
- x: rootsplit.splitterPos
+ x: root.splitterPos
y: 0
width: 1
- height: rootsplit.height
+ height: root.height
color: "red"
visible: false
}
diff --git a/src/monitor/glwidget.cpp b/src/monitor/glwidget.cpp
index cab2288..908f2ac 100644
--- a/src/monitor/glwidget.cpp
+++ b/src/monitor/glwidget.cpp
@@ -196,12 +196,19 @@ void GLWidget::resizeGL(int width, int height)
}
x = (width - w) / 2;
y = (height - h) / 2;
+ int oldX = m_rect.left();
+ int oldW = m_rect.width();
m_rect.setRect(x, y, w, h);
double scale = (double) m_rect.width() / m_consumer->profile()->width() * m_zoom;
QPoint center = m_rect.center();
- if (rootObject()) {
- rootObject()->setProperty("center", center);
- rootObject()->setProperty("scale", scale);
+ QQuickItem* rootQml = rootObject();
+ if (rootQml) {
+ rootQml->setProperty("center", center);
+ rootQml->setProperty("scale", scale);
+ if (rootQml->objectName() == "rootsplit") {
+ // Adjust splitter pos
+ rootQml->setProperty("splitterPos", x + (rootQml->property("realpercent").toDouble() * w));
+ }
}
emit rectChanged();
}
@@ -421,7 +428,7 @@ void GLWidget::wheelEvent(QWheelEvent * event)
void GLWidget::mousePressEvent(QMouseEvent* event)
{
QQuickView::mousePressEvent(event);
- if (!rootObject() || rootObject()->objectName() != "root") {
+ if (rootObject() && rootObject()->objectName() != "root") {
event->ignore();
return;
}
@@ -438,7 +445,7 @@ void GLWidget::mousePressEvent(QMouseEvent* event)
void GLWidget::mouseMoveEvent(QMouseEvent* event)
{
QQuickView::mouseMoveEvent(event);
- if (!rootObject() || rootObject()->objectName() != "root") {
+ if (rootObject() && rootObject()->objectName() != "root") {
event->ignore();
return;
}
@@ -829,7 +836,7 @@ void GLWidget::setZoom(float zoom)
void GLWidget::mouseReleaseEvent(QMouseEvent * event)
{
QQuickView::mouseReleaseEvent(event);
- if (rootObject()->objectName() != "root") {
+ if (rootObject() && rootObject()->objectName() != "root") {
return;
}
m_dragStart = QPoint();
@@ -841,7 +848,7 @@ void GLWidget::mouseReleaseEvent(QMouseEvent * event)
void GLWidget::mouseDoubleClickEvent(QMouseEvent * event)
{
QQuickView::mouseDoubleClickEvent(event);
- if (rootObject()->objectName() != "rooteffectscene") {
+ if (!rootObject() || rootObject()->objectName() != "rooteffectscene") {
emit switchFullScreen();
}
event->accept();
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index 0375b6f..f1f1765 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -1379,7 +1379,7 @@ void Monitor::slotSwitchCompare(bool enable)
render->setProducer(m_splitProducer, pos, isActive());
m_glMonitor->setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("kdenlivemonitorsplit.qml"))));
m_rootItem = m_glMonitor->rootObject();
- QObject::connect(m_rootItem, SIGNAL(qmlMoveSplit(double)), this, SLOT(slotAdjustEffectCompare(double)), Qt::UniqueConnection);
+ QObject::connect(m_rootItem, SIGNAL(qmlMoveSplit()), this, SLOT(slotAdjustEffectCompare()), Qt::UniqueConnection);
}
else if (m_splitEffect) {
render->setProducer(m_controller->masterProducer(), pos, isActive());
@@ -1410,8 +1410,16 @@ void Monitor::loadMasterQml()
m_rootItem = m_glMonitor->rootObject();
}
-void Monitor::slotAdjustEffectCompare(double percent)
+void Monitor::slotAdjustEffectCompare()
{
+ QRect r = m_glMonitor->rect();
+ double percent = 0.5;
+ if (m_rootItem && m_rootItem->objectName() == "rootsplit") {
+ // Adjust splitter pos
+ percent = (m_rootItem->property("splitterPos").toInt() - r.left()) / (double) r.width();
+ // Store real frame percentage for resize events
+ m_rootItem->setProperty("realpercent", percent);
+ }
if (m_splitEffect) m_splitEffect->set("Clip left", percent);
render->refreshIfActive();
}
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index 54649b5..bb4196b 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -183,7 +183,7 @@ private slots:
void slotEnableEffectScene(bool enable);
/** @brief split screen to compare clip with and without effect */
void slotSwitchCompare(bool enable);
- void slotAdjustEffectCompare(double percent);
+ void slotAdjustEffectCompare();
void slotShowMenu(const QPoint pos);
void slotForceSize(QAction *a);
diff --git a/src/ui/transitionsettings_ui.ui b/src/ui/transitionsettings_ui.ui
index eaefb83..8b97609 100644
--- a/src/ui/transitionsettings_ui.ui
+++ b/src/ui/transitionsettings_ui.ui
@@ -11,29 +11,6 @@
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Type</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="KComboBox" name="transitionList">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
@@ -43,7 +20,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>with track</string>
+ <string>track</string>
</property>
</widget>
</item>
@@ -66,6 +43,16 @@
</property>
</widget>
</item>
+ <item row="0" column="0" colspan="2">
+ <widget class="KComboBox" name="transitionList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<customwidgets>