Commit 21ae98d1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Show markers thumbnails on hover in clip monitor

parent 891149f2
Pipeline #62389 passed with stage
in 8 minutes and 22 seconds
......@@ -73,6 +73,7 @@ const double DOCUMENTVERSION = 1.00;
KdenliveDoc::KdenliveDoc(const QUrl &url, QString projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QMap<QString, QString> &properties,
const QMap<QString, QString> &metadata, const QPair<int, int> &tracks, int audioChannels, bool *openBackup, MainWindow *parent)
: QObject(parent)
, uuid(QUuid::createUuid())
, m_autosave(nullptr)
, m_url(url)
, m_clipsCount(0)
......
......@@ -29,6 +29,7 @@
#include <QDir>
#include <QList>
#include <QMap>
#include <QUuid>
#include <memory>
#include <qdom.h>
......@@ -69,6 +70,7 @@ public:
int width() const;
int height() const;
QUrl url() const;
QUuid uuid;
KAutoSaveFile *m_autosave;
Timecode timecode() const;
std::shared_ptr<DocUndoStack> commandStack();
......
......@@ -2261,6 +2261,7 @@ void MainWindow::connectDocument()
connect(project, &KdenliveDoc::reloadEffects, this, &MainWindow::slotReloadEffects);
KdenliveSettings::setProject_fps(pCore->getCurrentFps());
m_projectMonitor->slotLoadClipZone(project->zone());
m_clipMonitor->updateDocumentUuid();
connect(m_projectMonitor, &Monitor::multitrackView, getMainTimeline()->controller(), &TimelineController::slotMultitrackView, Qt::UniqueConnection);
connect(m_projectMonitor, &Monitor::activateTrack, getMainTimeline()->controller(), &TimelineController::activateTrackAndSelect, Qt::UniqueConnection);
connect(getMainTimeline()->controller(), &TimelineController::timelineClipSelected, this, [&] (bool selected) {
......
......@@ -39,6 +39,7 @@
#include "monitorproxy.h"
#include "profiles/profilemodel.hpp"
#include "timeline2/view/qml/timelineitems.h"
#include "timeline2/view/qmltypes/thumbnailprovider.h"
#include <mlt++/Mlt.h>
#include <lib/localeHandling.h>
......@@ -143,6 +144,7 @@ GLWidget::GLWidget(int id, QObject *parent)
registerTimelineItems();
m_proxy = new MonitorProxy(this);
rootContext()->setContextProperty("controller", m_proxy);
engine()->addImageProvider(QStringLiteral("thumbnail"), new ThumbnailProvider);
}
GLWidget::~GLWidget()
......
......@@ -705,24 +705,10 @@ void Monitor::updateMarkers()
}
}
void Monitor::setGuides(const QMap<double, QString> &guides)
{
// TODO: load guides model
m_markerMenu->clear();
QMapIterator<double, QString> i(guides);
QList<CommentedTime> guidesList;
while (i.hasNext()) {
i.next();
CommentedTime timeGuide(GenTime(i.key()), i.value());
guidesList << timeGuide;
int pos = timeGuide.time().frames(pCore->getCurrentFps());
QString position = pCore->timecode().getTimecode(timeGuide.time()) + QLatin1Char(' ') + timeGuide.comment();
QAction *go = m_markerMenu->addAction(position);
go->setData(pos);
}
// m_ruler->setMarkers(guidesList);
m_markerMenu->setEnabled(!m_markerMenu->isEmpty());
checkOverlay();
void Monitor::updateDocumentUuid()
{
m_glMonitor->rootObject()->setProperty("documentId", pCore->currentDoc()->uuid);
}
void Monitor::slotSeekToPreviousSnap()
......@@ -1570,6 +1556,12 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
m_snaps.reset(new SnapModel());
m_glMonitor->getControllerProxy()->resetZone();
if (controller) {
ClipType::ProducerType type = controller->clipType();
if (type == ClipType::AV || type == ClipType::Video || type == ClipType::SlideShow) {
m_glMonitor->rootObject()->setProperty("baseThumbPath", QString("image://thumbnail/%1/%2/#").arg(controller->clipId()).arg(pCore->currentDoc()->uuid.toString()));
} else {
m_glMonitor->rootObject()->setProperty("baseThumbPath", QString());
}
m_audioChannels->clear();
if (m_controller->audioInfo()) {
QMap<int, QString> audioStreamsInfo = m_controller->audioStreams();
......
......@@ -90,8 +90,6 @@ public:
void updateMarkers();
/** @brief Controller for the clip currently displayed (only valid for clip monitor). */
std::shared_ptr<ProjectClip> currentController() const;
/** @brief Add timeline guides to the ruler and context menu */
void setGuides(const QMap<double, QString> &guides);
void reloadProducer(const QString &id);
/** @brief Reimplemented from QWidget, updates the palette colors. */
void setPalette(const QPalette &p);
......@@ -156,6 +154,8 @@ public:
bool isPlaying() const;
/** @brief Enables / disables effect scene*/
void enableEffectScene(bool enable);
/** @brief Update the document's uuid - used for qml thumb cache*/
void updateDocumentUuid();
protected:
......
......@@ -552,24 +552,37 @@ Rectangle {
color: model.color
}
Rectangle {
id: markerTooltip
visible: !rulerMouseArea.pressed && (guideArea.containsMouse || (rulerMouseArea.containsMouse && Math.abs(rulerMouseArea.mouseX - markerBase.x) < 4))
property int guidePos: markerBase.x - mlabel.contentWidth / 2
x: guidePos < 0 ? 0 : (guidePos > (parent.width - mlabel.contentWidth) ? parent.width - mlabel.contentWidth : guidePos)
radius: 2
width: mlabel.contentWidth
height: mlabel.contentHeight * .8
width: Math.max(mlabel.contentWidth, imageTooltip.width + 2)
height: mlabel.contentHeight + imageTooltip.height
anchors {
bottom: parent.top
}
color: model.color
Image {
id: imageTooltip
visible: markerTooltip.visible && root.baseThumbPath != undefined
source: visible ? root.baseThumbPath + model.frame : ''
asynchronous: true
height: visible ? 4 * mlabel.height : 0
fillMode: Image.PreserveAspectFit
anchors.horizontalCenter: markerTooltip.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 1
}
Text {
id: mlabel
text: model.comment
font: fixedFont
verticalAlignment: Text.AlignVCenter
anchors {
fill: parent
}
horizontalAlignment: Text.AlignHCenter
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
color: '#000'
}
MouseArea {
......
......@@ -49,6 +49,7 @@ Item {
property color overlayColor: 'cyan'
property bool isClipMonitor: true
property int dragType: 0
property string baseThumbPath
property int overlayMargin: (audioThumb.stateVisible && !audioThumb.isAudioClip && audioThumb.visible) ? (audioThumb.height + root.zoomOffset) : root.zoomOffset + (audioThumb.isAudioClip && audioSeekZone.visible) ? audioSeekZone.height : 0
FontMetrics {
......
......@@ -176,9 +176,9 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M
rootContext()->setContextProperty("proxy", proxy);
// Create a unique id for this timeline to prevent thumbnails
// leaking from one project to another because of qml's image caching
rootContext()->setContextProperty("documentId", QUuid::createUuid());
rootContext()->setContextProperty("documentId", pCore->currentDoc()->uuid);
rootContext()->setContextProperty("audiorec", pCore->getAudioDevice());
rootContext()->setContextProperty("guidesModel", pCore->projectManager()->current()->getGuideModel().get());
rootContext()->setContextProperty("guidesModel", pCore->currentDoc()->getGuideModel().get());
rootContext()->setContextProperty("clipboard", new ClipboardProxy(this));
QFont ft = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
ft.setPointSize(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSize());
......
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