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

Add action to focus guide search line, fine tune search: auto select first...

Add action to focus guide search line, fine tune search: auto select first match, clear search line on esc/enter
parent e1e4a9bc
Pipeline #261065 failed with stage
in 8 minutes and 47 seconds
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="211" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="212" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="file_save"/>
......@@ -144,6 +144,7 @@
<Menu name="guide_menu" ><text>&amp;Guides</text>
<Action name="add_guide" />
<Action name="edit_guide" />
<Action name="search_guide" />
<Action name="delete_guide" />
<Action name="delete_all_guides" />
<Action name="export_guides" />
......
......@@ -1787,6 +1787,7 @@ void MainWindow::setupActions()
addAction(QStringLiteral("add_guide"), i18n("Add/Remove Guide"), this, SLOT(slotAddGuide()), QIcon::fromTheme(QStringLiteral("list-add")), Qt::Key_G);
addAction(QStringLiteral("delete_guide"), i18n("Delete Guide"), this, SLOT(slotDeleteGuide()), QIcon::fromTheme(QStringLiteral("edit-delete")));
addAction(QStringLiteral("edit_guide"), i18n("Edit Guide…"), this, SLOT(slotEditGuide()), QIcon::fromTheme(QStringLiteral("document-properties")));
addAction(QStringLiteral("search_guide"), i18n("Search Guide…"), this, SLOT(slotSearchGuide()), QIcon::fromTheme(QStringLiteral("edit-find")));
addAction(QStringLiteral("export_guides"), i18n("Export Guides…"), this, SLOT(slotExportGuides()), QIcon::fromTheme(QStringLiteral("document-export")));
QAction *lockGuides =
......@@ -2816,6 +2817,11 @@ void MainWindow::slotEditGuide()
getCurrentTimeline()->controller()->editGuide();
}
void MainWindow::slotSearchGuide()
{
pCore->guidesList()->filter_line->setFocus();
}
void MainWindow::slotExportGuides()
{
pCore->currentDoc()->getGuideModel()->exportGuidesGui(this, GenTime(getCurrentTimeline()->controller()->duration() - 1, pCore->getCurrentFps()));
......
......@@ -571,6 +571,8 @@ private slots:
/** @brief Copy debug information like lib versions, gpu mode state,... to clipboard */
void slotCopyDebugInfo();
void slotRemoveBinDock(const QString &name);
/** @brief Focus the guides list search line */
void slotSearchGuide();
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -23,9 +23,29 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <QDialog>
#include <QFileDialog>
#include <QFontDatabase>
#include <QKeyEvent>
#include <QMenu>
#include <QPainter>
GuideFilterEventEater::GuideFilterEventEater(QObject *parent)
: QObject(parent)
{
}
bool GuideFilterEventEater::eventFilter(QObject *obj, QEvent *event)
{
switch (event->type()) {
case QEvent::ShortcutOverride:
if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape) {
emit clearSearchLine();
}
break;
default:
break;
}
return QObject::eventFilter(obj, event);
}
class GuidesProxyModel : public QIdentityProxyModel
{
public:
......@@ -107,6 +127,11 @@ GuidesList::GuidesList(QWidget *parent)
connect(show_categories, &QToolButton::toggled, this, &GuidesList::switchFilter);
connect(show_categories, &MarkerCategoryButton::categoriesChanged, this, &GuidesList::updateFilter);
auto *leventEater = new GuideFilterEventEater(this);
filter_line->installEventFilter(leventEater);
connect(leventEater, &GuideFilterEventEater::clearSearchLine, filter_line, &QLineEdit::clear);
connect(filter_line, &QLineEdit::returnPressed, filter_line, &QLineEdit::clear);
guide_add->setToolTip(i18n("Add new guide."));
guide_add->setWhatsThis(xi18nc("@info:whatsthis", "Add new guide. This will add a guide at the current frame position."));
guide_delete->setToolTip(i18n("Delete guide."));
......@@ -272,11 +297,12 @@ void GuidesList::setClipMarkerModel(std::shared_ptr<ProjectClip> clip)
guides_list->setModel(m_proxy);
guides_list->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(guides_list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuidesList::selectionChanged);
rebuildCategories();
if (auto markerModel = m_model.lock()) {
show_categories->setMarkerModel(markerModel.get());
switchFilter(true);
connect(markerModel.get(), &MarkerListModel::categoriesChanged, this, &GuidesList::rebuildCategories);
}
rebuildCategories();
}
void GuidesList::setModel(std::weak_ptr<MarkerListModel> model, std::shared_ptr<MarkerSortModel> viewModel)
......@@ -290,13 +316,14 @@ void GuidesList::setModel(std::weak_ptr<MarkerListModel> model, std::shared_ptr<
m_model = std::move(model);
setEnabled(true);
guideslist_label->setText(i18n("Timeline Guides"));
m_sortModel = viewModel.get();
m_proxy->setSourceModel(m_sortModel);
guides_list->setModel(m_proxy);
guides_list->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(guides_list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuidesList::selectionChanged);
if (auto markerModel = m_model.lock()) {
show_categories->setMarkerModel(markerModel.get());
m_sortModel = viewModel.get();
m_proxy->setSourceModel(m_sortModel);
guides_list->setModel(m_proxy);
guides_list->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(guides_list->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuidesList::selectionChanged);
switchFilter(true);
connect(markerModel.get(), &MarkerListModel::categoriesChanged, this, &GuidesList::rebuildCategories);
}
rebuildCategories();
......@@ -383,6 +410,13 @@ void GuidesList::filterView(const QString &text)
{
if (m_sortModel) {
m_sortModel->slotSetFilterString(text);
if (!text.isEmpty() && guides_list->model()->rowCount() > 0) {
guides_list->setCurrentIndex(guides_list->model()->index(0, 0));
}
QModelIndex current = guides_list->currentIndex();
if (current.isValid()) {
guides_list->scrollTo(current);
}
}
}
......
......@@ -16,6 +16,23 @@ class MarkerSortModel;
class QActionGroup;
class ProjectClip;
/** @class GuideFilterEventEater
@brief \@todo Describe class LineEventEater
@todo Describe class LineEventEater
*/
class GuideFilterEventEater : public QObject
{
Q_OBJECT
public:
explicit GuideFilterEventEater(QObject *parent = nullptr);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
signals:
void clearSearchLine();
};
/** @class GuidesList
@brief A widget listing project guides and allowing some advanced editing.
@author Jean-Baptiste Mardelle
......
......@@ -175,7 +175,7 @@ Item {
}
onPositionChanged: {
if (pressed) {
var newFrame = Math.round(model.frame + (mouseX - xOffset) / timeline.scaleFactor)
var newFrame = Math.max(0, Math.round(model.frame + (mouseX - xOffset) / timeline.scaleFactor))
newFrame = controller.suggestSnapPoint(newFrame, mouse.modifiers & Qt.ShiftModifier ? -1 : root.snapping)
if (newFrame != destFrame) {
var frame = timeline.moveGuideWithoutUndo(movingMarkerId, newFrame)
......
......@@ -153,17 +153,28 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MarkerCategoryButton</class>
<extends>QToolButton</extends>
<header>widgets/markercategorybutton.h</header>
</customwidget>
<customwidget>
<class>KSqueezedTextLabel</class>
<extends>QLabel</extends>
<header>ksqueezedtextlabel.h</header>
</customwidget>
<customwidget>
<class>MarkerCategoryButton</class>
<extends>QToolButton</extends>
<header>widgets/markercategorybutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>filter_line</tabstop>
<tabstop>show_categories</tabstop>
<tabstop>sort_guides</tabstop>
<tabstop>guides_list</tabstop>
<tabstop>guide_add</tabstop>
<tabstop>guide_edit</tabstop>
<tabstop>guide_delete</tabstop>
<tabstop>default_category</tabstop>
<tabstop>guides_settings</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
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