Fix audio/video only buttons on clip monitor

parent 98034fb5
......@@ -876,14 +876,6 @@ void Monitor::slotStartDrag()
}
auto *drag = new QDrag(this);
auto *mimeData = new QMimeData;
// Get drag state
QQuickItem *root = m_glMonitor->rootObject();
int dragType = 0;
if (root) {
dragType = root->property("dragType").toInt();
root->setProperty("dragType", 0);
}
QByteArray prodData;
QPoint p = m_glMonitor->getControllerProxy()->zone();
if (p.x() == -1 || p.y() == -1) {
......@@ -895,18 +887,6 @@ void Monitor::slotStartDrag()
list.append(QString::number(p.y()));
prodData.append(list.join(QLatin1Char('/')).toUtf8());
}
switch (dragType) {
case 1:
// Audio only drag
prodData.prepend('A');
break;
case 2:
// Audio only drag
prodData.prepend('V');
break;
default:
break;
}
mimeData->setData(QStringLiteral("kdenlive/producerslist"), prodData);
drag->setMimeData(mimeData);
/*QPixmap pix = m_currentClip->thumbnail();
......@@ -1464,7 +1444,7 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
m_glMonitor->getControllerProxy()->setAudioThumb(m_audioMeterWidget->audioChannels == 0 ? QUrl() : ThumbnailCache::get()->getAudioThumbPath(m_controller->clipId()));
}
m_controller->getMarkerModel()->registerSnapModel(m_snaps);
m_glMonitor->getControllerProxy()->setClipProperties(controller->clipType(), controller->hasAudioAndVideo(), controller->clipName());
m_glMonitor->getControllerProxy()->setClipProperties(controller->clipId().toInt(), controller->clipType(), controller->hasAudioAndVideo(), controller->clipName());
m_glMonitor->setProducer(m_controller->originalProducer(), isActive(), in);
// hasEffects = controller->hasEffects();
} else {
......@@ -1472,7 +1452,7 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
m_glMonitor->setProducer(nullptr, isActive());
m_glMonitor->getControllerProxy()->setAudioThumb();
m_audioMeterWidget->audioChannels = 0;
m_glMonitor->getControllerProxy()->setClipProperties(ClipType::Unknown, false, QString());
m_glMonitor->getControllerProxy()->setClipProperties(-1, ClipType::Unknown, false, QString());
}
if (slotActivateMonitor()) {
start();
......
......@@ -40,6 +40,7 @@ MonitorProxy::MonitorProxy(GLWidget *parent)
, m_zoneOut(-1)
, m_hasAV(false)
, m_clipType(0)
, m_clipId(-1)
, m_seekFinished(true)
{
}
......@@ -282,7 +283,7 @@ QString MonitorProxy::toTimecode(int frames) const
return KdenliveSettings::frametimecode() ? QString::number(frames) : q->frameToTime(frames);
}
void MonitorProxy::setClipProperties(ClipType::ProducerType type, bool hasAV, const QString clipName)
void MonitorProxy::setClipProperties(int clipId, ClipType::ProducerType type, bool hasAV, const QString clipName)
{
if (hasAV != m_hasAV) {
m_hasAV = hasAV;
......@@ -298,6 +299,10 @@ void MonitorProxy::setClipProperties(ClipType::ProducerType type, bool hasAV, co
m_clipType = type;
emit clipTypeChanged();
}
if (clipId != m_clipId) {
m_clipId = clipId;
emit clipIdChanged();
}
}
void MonitorProxy::setAudioThumb(const QUrl thumbPath)
......
......@@ -55,6 +55,7 @@ class MonitorProxy : public QObject
/** @brief: Contains the name of clip currently displayed in monitor
* */
Q_PROPERTY(int clipType MEMBER m_clipType NOTIFY clipTypeChanged)
Q_PROPERTY(int clipId MEMBER m_clipId NOTIFY clipIdChanged)
public:
MonitorProxy(GLWidget *parent);
......@@ -88,7 +89,7 @@ public:
Q_INVOKABLE void endZoneMove();
Q_INVOKABLE double fps() const;
QPoint profile();
void setClipProperties(ClipType::ProducerType type, bool hasAV, const QString clipName);
void setClipProperties(int clipId, ClipType::ProducerType type, bool hasAV, const QString clipName);
void setAudioThumb(const QUrl thumbPath = QUrl());
signals:
......@@ -111,6 +112,7 @@ signals:
void clipHasAVChanged();
void clipNameChanged();
void clipTypeChanged();
void clipIdChanged();
void audioThumbChanged();
void profileChanged();
......@@ -124,6 +126,7 @@ private:
QString m_markerComment;
QString m_clipName;
int m_clipType;
int m_clipId;
bool m_seekFinished;
QPoint m_undoZone;
};
......
......@@ -313,46 +313,55 @@ Item {
radius: 4
opacity: (dragAudioArea.containsMouse || dragVideoArea.containsMouse || thumbMouseArea.containsMouse || (barOverArea.containsMouse && barOverArea.mouseY >= y)) ? 1 : 0
visible: controller.clipHasAV
onOpacityChanged: {
if (opacity == 1) {
videoDragButton.x = 0
videoDragButton.y = 0
audioDragButton.x = videoDragButton.x + videoDragButton.width
audioDragButton.y = 0
}
}
Row {
id: dragRow
ToolButton {
id: videoDragButton
icon.name: "kdenlive-show-video"
Drag.active: dragVideoArea.drag.active
Drag.dragType: Drag.Automatic
Drag.mimeData: {
"kdenlive/producerslist" : "V" + controller.clipId + "/" + controller.zoneIn + "/" + controller.zoneOut
}
MouseArea {
id: dragVideoArea
hoverEnabled: true
acceptedButtons: Qt.LeftButton
anchors.fill: parent
propagateComposedEvents: true
cursorShape: Qt.PointingHand
onPressed: {
parent.enabled = false
mouse.accepted = false
dragType = 2
}
drag.target: parent
onExited: {
parent.enabled = true
parent.clicked()
parent.x = 0
parent.y = 0
}
}
}
ToolButton {
id: audioDragButton
icon.name: "audio-volume-medium"
Drag.active: dragAudioArea.drag.active
Drag.dragType: Drag.Automatic
Drag.mimeData: {
"kdenlive/producerslist" : "A" + controller.clipId + "/" + controller.zoneIn + "/" + controller.zoneOut
}
MouseArea {
id: dragAudioArea
hoverEnabled: true
acceptedButtons: Qt.LeftButton
anchors.fill: parent
propagateComposedEvents: true
cursorShape: Qt.PointingHand
onPressed: {
parent.enabled = false
mouse.accepted = false
dragType = 1
}
drag.target: parent
onExited: {
parent.enabled = true
parent.x = videoDragButton.x + videoDragButton.width
parent.y = 0
}
}
}
......
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