Commit 33440916 authored by Julius Künzel's avatar Julius Künzel 💬
Browse files

Make use of new MarkerCategoryChooser

parent 8e2dcd46
Pipeline #255505 canceled with stage
in 8 minutes and 40 seconds
......@@ -37,15 +37,7 @@ ExportGuidesDialog::ExportGuidesDialog(const MarkerListModel *model, const GenTi
const QString defaultFormat(YT_FORMAT);
formatEdit->setText(KdenliveSettings::exportGuidesFormat().isEmpty() ? defaultFormat : KdenliveSettings::exportGuidesFormat());
static std::array<QColor, 9> markerTypes = model->markerTypes;
QPixmap pixmap(32, 32);
for (uint i = 1; i <= markerTypes.size(); ++i) {
pixmap.fill(markerTypes[size_t(i - 1)]);
QIcon colorIcon(pixmap);
markerTypeComboBox->addItem(colorIcon, i18n("Category %1", i - 1));
}
markerTypeComboBox->setCurrentIndex(0);
categoryChooser->setMarkerModel(m_markerListModel);
messageWidget->setText(i18n("If you are using the exported text for YouTube, you might want to check:\n"
"1. The start time of 00:00 must have a chapter.\n"
"2. There must be at least three timestamps in ascending order.\n"
......@@ -57,7 +49,7 @@ ExportGuidesDialog::ExportGuidesDialog(const MarkerListModel *model, const GenTi
QPushButton *btn = buttonBox->addButton(i18n("Copy to Clipboard"), QDialogButtonBox::ActionRole);
btn->setIcon(QIcon::fromTheme("edit-copy"));
connect(markerTypeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() { updateContentByModel(); });
connect(categoryChooser, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() { updateContentByModel(); });
connect(offsetTimeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int newIndex) {
offsetTimeSpinbox->setEnabled(newIndex != 0);
......@@ -137,7 +129,7 @@ QString chapterTimeStringFromMs(double timeMs)
void ExportGuidesDialog::updateContentByModel() const
{
const QString format(formatEdit->text());
const int markerIndex = markerTypeComboBox->currentIndex() - 1;
const int markerIndex = categoryChooser->currentCategory();
const GenTime offset(offsetTime());
QStringList chapterTexts;
......
......@@ -29,14 +29,7 @@ MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const Q
setWindowTitle(caption);
// Set up categories
static std::array<QColor, 9> markerTypes = pCore->projectManager()->getGuideModel()->markerTypes;
QPixmap pixmap(32, 32);
for (uint i = 0; i < markerTypes.size(); ++i) {
pixmap.fill(markerTypes[size_t(i)]);
QIcon colorIcon(pixmap);
marker_type->addItem(colorIcon, i18n("Category %1", i));
}
marker_type->setCurrentIndex(t.markerType());
marker_category->setCurrentCategory(t.markerType());
m_in->setValue(t.time());
......@@ -110,6 +103,6 @@ QImage MarkerDialog::markerImage() const
CommentedTime MarkerDialog::newMarker()
{
KdenliveSettings::setDefault_marker_type(marker_type->currentIndex());
return CommentedTime(m_in->gentime(), marker_comment->text(), marker_type->currentIndex());
KdenliveSettings::setDefault_marker_type(marker_category->currentCategory());
return CommentedTime(m_in->gentime(), marker_comment->text(), marker_category->currentCategory());
}
......@@ -468,9 +468,9 @@ void RenderWidget::reloadGuides()
QVariant endData = m_view.guide_end->currentData();
m_view.guide_start->clear();
m_view.guide_end->clear();
m_view.guideCategoryCombo->clear();
if (auto ptr = m_guidesModel.lock()) {
m_view.guideCategoryChooser->setMarkerModel(ptr.get());
QList<CommentedTime> markers = ptr->getAllMarkers();
double fps = pCore->getCurrentFps();
m_view.render_guide->setEnabled(!markers.isEmpty());
......@@ -492,18 +492,6 @@ void RenderWidget::reloadGuides()
int ix = qMax(m_view.guide_start->currentIndex() + 1, m_view.guide_end->findData(endData));
m_view.guide_end->setCurrentIndex(ix);
}
// Set up guide categories
static std::array<QColor, 9> markerTypes = ptr->markerTypes;
QPixmap pixmap(32, 32);
m_view.guideCategoryCombo->addItem(i18n("All Categories"), -1);
for (uint i = 0; i < markerTypes.size(); ++i) {
if (!ptr->getAllMarkers(i).isEmpty()) {
pixmap.fill(markerTypes[size_t(i)]);
QIcon colorIcon(pixmap);
m_view.guideCategoryCombo->addItem(colorIcon, i18n("Category %1", i), i);
}
}
} else {
if (m_view.render_guide->isChecked() || m_view.render_multi->isChecked()) {
m_view.render_full->setChecked(true);
......@@ -710,7 +698,7 @@ void RenderWidget::prepareRendering(bool delayedRendering)
generateRenderFiles(doc, in, out, outputFile, delayedRendering, subtitleFile);
} else if (m_view.render_multi->isChecked()) {
if (auto ptr = m_guidesModel.lock()) {
int category = m_view.guideCategoryCombo->currentData().toInt();
int category = m_view.guideCategoryChooser->currentCategory();
QList<CommentedTime> markers = ptr->getAllMarkers(category);
if (!markers.isEmpty()) {
bool beginParsed = false;
......
......@@ -52,13 +52,7 @@ void SceneSplitTask::start(QObject *object, bool force)
view.add_markers->setChecked(KdenliveSettings::scenesplitmarkers());
view.cut_scenes->setChecked(KdenliveSettings::scenesplitsubclips());
// Set up categories
static std::array<QColor, 9> markerTypes = pCore->projectManager()->getGuideModel()->markerTypes;
QPixmap pixmap(32, 32);
for (uint i = 0; i < markerTypes.size(); ++i) {
pixmap.fill(markerTypes[size_t(i)]);
QIcon colorIcon(pixmap);
view.marker_type->addItem(colorIcon, i18n("Category %1", i));
}
view.marker_category->setMarkerModel(pCore->projectManager()->getGuideModel().get());
d->setWindowTitle(i18nc("@title:window", "Scene Detection"));
if (d->exec() != QDialog::Accepted) {
return;
......@@ -66,7 +60,7 @@ void SceneSplitTask::start(QObject *object, bool force)
int threshold = view.threshold->value();
bool addMarkers = view.add_markers->isChecked();
bool addSubclips = view.cut_scenes->isChecked();
int markersCategory = addMarkers ? view.marker_type->currentIndex() : -1;
int markersCategory = addMarkers ? view.marker_category->currentCategory() : -1;
int minDuration = view.minDuration->value();
KdenliveSettings::setScenesplitthreshold(threshold);
KdenliveSettings::setScenesplitmarkers(view.add_markers->isChecked());
......
......@@ -31,42 +31,14 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="markerTypeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string>Any</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Any</string>
</property>
<property name="icon">
<iconset theme="edit-select-all">
<normaloff>.</normaloff>.</iconset>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Format:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="offsetTimeComboBox">
......@@ -98,7 +70,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</item>
</layout>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
......@@ -111,7 +83,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="formatEdit"/>
......@@ -149,14 +121,14 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</item>
</layout>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Exported:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QPlainTextEdit" name="generatedContent">
<property name="readOnly">
<bool>true</bool>
......@@ -166,14 +138,14 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<widget class="KMessageWidget" name="messageWidget">
<property name="closeButtonVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -183,6 +155,19 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="MarkerCategoryChooser" name="categoryChooser">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="onlyUsed">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......@@ -191,6 +176,11 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
<extends>QWidget</extends>
<header>widgets/timecodedisplay.h</header>
</customwidget>
<customwidget>
<class>MarkerCategoryChooser</class>
<extends>QComboBox</extends>
<header>widgets/markercategorychooser.h</header>
</customwidget>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
......
......@@ -73,9 +73,6 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="marker_type"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="clip_filesize_3">
<property name="text">
......@@ -99,6 +96,13 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="MarkerCategoryChooser" name="marker_category">
<property name="allowAll">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
......@@ -132,6 +136,11 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
<extends>QWidget</extends>
<header>widgets/timecodedisplay.h</header>
</customwidget>
<customwidget>
<class>MarkerCategoryChooser</class>
<extends>QComboBox</extends>
<header>widgets/markercategorychooser.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
......
......@@ -425,13 +425,16 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</widget>
</item>
<item>
<widget class="QComboBox" name="guideCategoryCombo">
<widget class="MarkerCategoryChooser" name="guideCategoryChooser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="onlyUsed">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
......@@ -1102,6 +1105,11 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>MarkerCategoryChooser</class>
<extends>QComboBox</extends>
<header>widgets/markercategorychooser.h</header>
</customwidget>
<customwidget>
<class>KUrlRequester</class>
<extends>QWidget</extends>
......@@ -1140,7 +1148,6 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
<tabstop>render_multi</tabstop>
<tabstop>guide_start</tabstop>
<tabstop>guide_end</tabstop>
<tabstop>guideCategoryCombo</tabstop>
<tabstop>options</tabstop>
<tabstop>buttonRender</tabstop>
<tabstop>buttonGenerateScript</tabstop>
......
......@@ -18,30 +18,33 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
<string>Scene Cut</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="add_markers">
<property name="text">
<string>Minimum scene length:</string>
<string>Add clip markers:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Change threshold</string>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="threshold"/>
</item>
<item row="1" column="2" colspan="3">
<widget class="QComboBox" name="marker_type">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Minimum scene length:</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="5">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
......@@ -58,20 +61,20 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</spacer>
</item>
<item row="6" column="0" colspan="5">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="4" column="2">
<widget class="QSpinBox" name="minDuration">
<property name="suffix">
<string> frames</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<widget class="QCheckBox" name="cut_scenes">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cut scenes</string>
<string>Change threshold</string>
</property>
</widget>
</item>
......@@ -88,28 +91,29 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QSpinBox" name="minDuration">
<property name="suffix">
<string> frames</string>
</property>
<property name="maximum">
<number>99999999</number>
<item row="2" column="0" colspan="5">
<widget class="QCheckBox" name="cut_scenes">
<property name="text">
<string>Cut scenes</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="add_markers">
<property name="text">
<string>Add clip markers:</string>
</property>
<property name="checked">
<bool>true</bool>
<item row="1" column="2" colspan="2">
<widget class="MarkerCategoryChooser" name="marker_category">
<property name="allowAll">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MarkerCategoryChooser</class>
<extends>QComboBox</extends>
<header>widgets/markercategorychooser.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
......@@ -176,5 +180,21 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
</hint>
</hints>
</connection>
<connection>
<sender>add_markers</sender>
<signal>toggled(bool)</signal>
<receiver>marker_category</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>77</x>
<y>59</y>
</hint>
<hint type="destinationlabel">
<x>256</x>
<y>59</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -15,33 +15,30 @@ MarkerCategoryChooser::MarkerCategoryChooser(QWidget *parent)
void MarkerCategoryChooser::refresh()
{
QList<CommentedTime> markers;
clear();
if (m_markerListModel) {
markers = m_markerListModel->getAllMarkers();
}
if (!m_markerListModel || (m_onlyUsed && markers.isEmpty())) {
setEnabled(false);
setPlaceholderText(i18n("Nothing to select"));
return;
}
setPlaceholderText(QString());
setEnabled(true);
if (m_allowAll) {
addItem(i18n("All Categories"), -1);
}
// Set up guide categories
static std::array<QColor, 9> markerTypes = m_markerListModel->markerTypes;
static std::array<QColor, 9> markerTypes = MarkerListModel::markerTypes;
QPixmap pixmap(32, 32);
for (uint i = 0; i < markerTypes.size(); ++i) {
if (m_onlyUsed && m_markerListModel->getAllMarkers(i).isEmpty()) {
if (m_onlyUsed && m_markerListModel && m_markerListModel->getAllMarkers(i).isEmpty()) {
continue;
}
pixmap.fill(markerTypes[size_t(i)]);
QIcon colorIcon(pixmap);
addItem(colorIcon, i18n("Category %1", i), i);
}
if (count() == 0) {
setEnabled(false);
setPlaceholderText(i18n("Nothing to select"));
return;
}
setEnabled(true);
setPlaceholderText(QString());
if (m_allowAll) {
insertItem(0, i18n("All Categories"), -1);
setCurrentIndex(0);
}
}
void MarkerCategoryChooser::setCurrentCategory(int category)
......
......@@ -14,10 +14,17 @@ class MarkerCategoryChooser : public QComboBox
public:
MarkerCategoryChooser(QWidget *parent = nullptr);
/** @brief Set currently selected category by its number. */
void setCurrentCategory(int category);
/** @brief get the number of the currently selected category. */
int currentCategory();
/** @brief Set the marker model of the chooser. Only needed if @property onlyUsed is true.*/
void setMarkerModel(const MarkerListModel *model);
/** @brief Whether the user should be able to select "All Categories" */
void setAllowAll(bool allowAll);
/** @brief Show only categories that are used by markers in the model.
* If no model is set, all categories will be show. @see setMarkerModel
*/
void setOnlyUsed(bool onlyUsed);
private:
......
Supports Markdown
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