Warning, file /multimedia/kdenlive/src/dialogs/markerdialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2008 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 
0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #include "markerdialog.h"
0008 
0009 #include "bin/model/markerlistmodel.hpp"
0010 #include "core.h"
0011 #include "doc/kthumb.h"
0012 #include "kdenlivesettings.h"
0013 #include "mltcontroller/clipcontroller.h"
0014 #include "project/projectmanager.h"
0015 
0016 #include "kdenlive_debug.h"
0017 #include <QFontDatabase>
0018 #include <QTimer>
0019 #include <QWheelEvent>
0020 
0021 #include "klocalizedstring.h"
0022 
0023 MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const QString &caption, bool allowMultipleMarksers, QWidget *parent)
0024     : QDialog(parent)
0025     , m_clip(clip)
0026 {
0027     setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
0028     setupUi(this);
0029     setWindowTitle(caption);
0030 
0031     // Set  up categories
0032     marker_category->setCurrentCategory(t.markerType());
0033 
0034     m_in->setValue(t.time());
0035     if (!allowMultipleMarksers) {
0036         multimarker_box->setVisible(false);
0037     }
0038     interval->setValue(GenTime(KdenliveSettings::multipleguidesinterval()));
0039     m_previewTimer = new QTimer(this);
0040 
0041     if (m_clip != nullptr) {
0042         m_in->setRange(0, m_clip->getFramePlaytime());
0043         m_previewTimer->setInterval(100);
0044         connect(m_previewTimer, &QTimer::timeout, this, &MarkerDialog::slotUpdateThumb);
0045         int width = int(200 * pCore->getCurrentDar());
0046         QPixmap p(width, 200);
0047         p.fill(Qt::transparent);
0048         switch (m_clip->clipType()) {
0049         case ClipType::Video:
0050         case ClipType::AV:
0051         case ClipType::SlideShow:
0052         case ClipType::Playlist:
0053             QTimer::singleShot(0, this, &MarkerDialog::slotUpdateThumb);
0054             connect(this, &MarkerDialog::updateThumb, m_previewTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
0055             break;
0056         case ClipType::Image:
0057         case ClipType::Text:
0058         case ClipType::QText:
0059         case ClipType::Color:
0060             QTimer::singleShot(0, this, &MarkerDialog::slotUpdateThumb);
0061             // p = m_clip->pixmap(m_in->getValue(), width, height);
0062             break;
0063         // UNKNOWN, AUDIO, VIRTUAL:
0064         default:
0065             p.fill(Qt::black);
0066         }
0067 
0068         if (!p.isNull()) {
0069             clip_thumb->setScaledContents(true);
0070             clip_thumb->setPixmap(p);
0071         }
0072         connect(m_in, &TimecodeDisplay::timeCodeEditingFinished, this, &MarkerDialog::updateThumb);
0073     } else {
0074         clip_thumb->setHidden(true);
0075         label_category->setHidden(true);
0076     }
0077 
0078     marker_comment->setText(t.comment());
0079     marker_comment->selectAll();
0080     marker_comment->setFocus();
0081     adjustSize();
0082 }
0083 
0084 MarkerDialog::~MarkerDialog()
0085 {
0086     delete m_previewTimer;
0087 }
0088 
0089 void MarkerDialog::slotUpdateThumb()
0090 {
0091     m_previewTimer->stop();
0092     int pos = m_in->getValue();
0093     const QPixmap p = m_clip->pixmap(pos);
0094     if (!p.isNull()) {
0095         clip_thumb->setFixedSize(p.width(), p.height());
0096         clip_thumb->setPixmap(p);
0097     } else {
0098         qCDebug(KDENLIVE_LOG) << "!!!!!!!!!!!  ERROR CREATING THUMB";
0099     }
0100 }
0101 
0102 QImage MarkerDialog::markerImage() const
0103 {
0104     return clip_thumb->pixmap(Qt::ReturnByValue).toImage();
0105 }
0106 
0107 CommentedTime MarkerDialog::newMarker()
0108 {
0109     KdenliveSettings::setDefault_marker_type(marker_category->currentCategory());
0110     return CommentedTime(m_in->gentime(), marker_comment->text(), marker_category->currentCategory());
0111 }
0112 
0113 GenTime MarkerDialog::getInterval() const
0114 {
0115     return interval->gentime();
0116 }
0117 
0118 int MarkerDialog::getOccurrences() const
0119 {
0120     return occurrences->value();
0121 }
0122 
0123 bool MarkerDialog::addMultiMarker() const
0124 {
0125     return multimarker_box->isExpanded();
0126 }