Skip to content

Commit

Permalink
Resolve review comments
Browse files Browse the repository at this point in the history
Remove extra button and put copy options in a menu
  • Loading branch information
bmatherly committed Jan 13, 2025
1 parent a788aef commit 3438da2
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 36 deletions.
Binary file removed icons/dark/32x32/edit-select.png
Binary file not shown.
Binary file removed icons/light/32x32/edit-select.png
Binary file not shown.
Binary file removed icons/oxygen/32x32/actions/edit-select.png
Binary file not shown.
3 changes: 0 additions & 3 deletions icons/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,10 @@
<file>oxygen/32x32/actions/edit-copy.png</file>
<file>oxygen/32x32/actions/edit-cut.png</file>
<file>oxygen/32x32/actions/edit-paste.png</file>
<file>oxygen/32x32/actions/edit-select.png</file>
<file>oxygen/32x32/actions/edit-select-all.png</file>
<file>light/32x32/edit-copy.png</file>
<file>light/32x32/edit-cut.png</file>
<file>light/32x32/edit-paste.png</file>
<file>light/32x32/edit-select.png</file>
<file>light/32x32/edit-select-all.png</file>
<file>oxygen/32x32/actions/format-indent-less.png</file>
<file>oxygen/32x32/actions/format-indent-more.png</file>
Expand Down Expand Up @@ -269,7 +267,6 @@
<file>dark/32x32/edit-copy.png</file>
<file>dark/32x32/edit-cut.png</file>
<file>dark/32x32/edit-paste.png</file>
<file>dark/32x32/edit-select.png</file>
<file>dark/32x32/edit-select-all.png</file>
<file>dark/32x32/format-indent-less.png</file>
<file>dark/32x32/format-indent-more.png</file>
Expand Down
29 changes: 26 additions & 3 deletions src/docks/filtersdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QtWidgets/QScrollArea>
#include <QQmlEngine>
#include <QDir>
#include <QMenu>
#include <QUrl>
#include <QQmlContext>
#include <QAction>
Expand Down Expand Up @@ -148,6 +149,15 @@ void FiltersDock::openFilterMenu() const
QMetaObject::invokeMethod(m_qview.rootObject(), "openFilterMenu");
}

void FiltersDock::showCopyFilterMenu()
{
QMenu menu;
menu.addAction(Actions["filtersCopyCurrentFilterAction"]);
menu.addAction(Actions["filtersCopyFiltersAction"]);
menu.addAction(Actions["filtersCopyAllFilterAction"]);
menu.exec(QCursor::pos());
}

void FiltersDock::onServiceInChanged(int delta, Mlt::Service *service)
{
if (delta && service && m_producer.producer().is_valid()
Expand Down Expand Up @@ -183,6 +193,8 @@ void FiltersDock::load()

QObject::connect(m_qview.rootObject(), SIGNAL(currentFilterRequested(int)),
SIGNAL(currentFilterRequested(int)));
QObject::connect(m_qview.rootObject(), SIGNAL(copyFilterRequested()),
SLOT(showCopyFilterMenu()));
}

void FiltersDock::setupActions()
Expand Down Expand Up @@ -217,28 +229,39 @@ void FiltersDock::setupActions()
addAction(action);
Actions.add("filtersRemoveFilterAction", action, windowTitle());

action = new QAction(tr("Copy Filters"), this);
action = new QAction(tr("Copy Enabled Filters"), this);
action->setToolTip(tr("Copy checked filters to the clipboard"));
icon = QIcon::fromTheme("edit-copy",
QIcon(":/icons/oxygen/32x32/actions/edit-copy.png"));
action->setIcon(icon);
connect(action, &QAction::triggered, this, [ = ]() {
QmlApplication::singleton().copyFilters();
QmlApplication::singleton().copyEnabledFilters();
});
addAction(action);
Actions.add("filtersCopyFiltersAction", action, windowTitle());

action = new QAction(tr("Copy Current Filter"), this);
action->setToolTip(tr("Copy current filter to the clipboard"));
icon = QIcon::fromTheme("edit-copy",
QIcon(":/icons/oxygen/32x32/actions/edit-select.png"));
QIcon(":/icons/oxygen/32x32/actions/edit-copy.png"));
action->setIcon(icon);
connect(action, &QAction::triggered, this, [ = ]() {
QmlApplication::singleton().copyCurrentFilter();
});
addAction(action);
Actions.add("filtersCopyCurrentFilterAction", action, windowTitle());

action = new QAction(tr("Copy All Filters"), this);
action->setToolTip(tr("Copy all filters to the clipboard"));
icon = QIcon::fromTheme("edit-copy",
QIcon(":/icons/oxygen/32x32/actions/edit-copy.png"));
action->setIcon(icon);
connect(action, &QAction::triggered, this, [ = ]() {
QmlApplication::singleton().copyAllFilters();
});
addAction(action);
Actions.add("filtersCopyAllFilterAction", action, windowTitle());

action = new QAction(tr("Paste Filters"), this);
action->setToolTip(tr("Paste the filters from the clipboard"));
icon = QIcon::fromTheme("edit-paste",
Expand Down
1 change: 1 addition & 0 deletions src/docks/filtersdock.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public slots:
void onSeeked(int position);
void onShowFrame(const SharedFrame &frame);
void openFilterMenu() const;
void showCopyFilterMenu();
void onServiceInChanged(int delta, Mlt::Service *service);
void load();

Expand Down
11 changes: 5 additions & 6 deletions src/mltcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ static int indexOfFirstNonGpu(Producer &toProducer)
}

void Controller::copyFilters(Producer &fromProducer, Producer &toProducer, bool fromClipboard,
bool includeDisabled, int filterIndex)
int filterIndex)
{
int in = fromProducer.get(kFilterInProperty) ? fromProducer.get_int(kFilterInProperty) :
fromProducer.get_in();
Expand All @@ -1136,11 +1136,11 @@ void Controller::copyFilters(Producer &fromProducer, Producer &toProducer, bool
&& fromFilter->get("mlt_service")) {

filterCount++;
if (filterIndex != -1 && filterIndex != (filterCount - 1)) {
if (filterIndex >= 0 && filterIndex != (filterCount - 1)) {
continue;
}

if (!includeDisabled && fromFilter->get_int("disable")) {
if (filterIndex == FILTER_INDEX_ENABLED && fromFilter->get_int("disable")) {
continue;
}

Expand Down Expand Up @@ -1205,13 +1205,12 @@ void Controller::copyFilters(Producer &fromProducer, Producer &toProducer, bool

void Controller::copyFilters(Mlt::Producer *producer, int filterIndex)
{
bool includeDisabled = filterIndex >= 0;
if (producer && producer->is_valid()) {
initFiltersClipboard();
copyFilters(*producer, *m_filtersClipboard, false, includeDisabled, filterIndex);
copyFilters(*producer, *m_filtersClipboard, false, filterIndex);
} else if (m_producer && m_producer->is_valid()) {
initFiltersClipboard();
copyFilters(*m_producer, *m_filtersClipboard, false, includeDisabled, filterIndex);
copyFilters(*m_producer, *m_filtersClipboard, false, filterIndex);
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/mltcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class Controller
virtual int reconfigure(bool isMulti) = 0;

public:
enum {
FILTER_INDEX_ALL = -1,
FILTER_INDEX_ENABLED = -2,
};

static Controller &singleton(QObject *parent = nullptr);
virtual ~Controller();
static void destroy();
Expand Down Expand Up @@ -130,9 +135,8 @@ class Controller
void setUuid(Mlt::Properties &properties, QUuid uid) const;
QUuid ensureHasUuid(Mlt::Properties &properties) const;
static void copyFilters(Mlt::Producer &fromProducer, Mlt::Producer &toProducer,
bool fromClipboard = false, bool includeDisabled = true,
int filterIndex = -1);
void copyFilters(Mlt::Producer *producer = nullptr, int filterIndex = -1);
bool fromClipboard = false, int filterIndex = FILTER_INDEX_ENABLED);
void copyFilters(Mlt::Producer *producer = nullptr, int filterIndex = FILTER_INDEX_ENABLED);
void pasteFilters(Mlt::Producer *producer = nullptr, Mlt::Producer *fromProducer = nullptr);
static void adjustFilters(Mlt::Producer &producer, int startIndex = 0);
static void adjustFilter(Mlt::Filter *filter, int in, int out, int inDelta, int outDelta,
Expand Down
2 changes: 1 addition & 1 deletion src/qml/views/filter/CopyFiltersDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Window {
id: nameDialog

function acceptName() {
application.copyFilters();
application.copyEnabledFilters();
let name = nameField.text.trim();
if (name.length) {
metadatamodel.saveFilterSet(name);
Expand Down
20 changes: 3 additions & 17 deletions src/qml/views/filter/filterview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Rectangle {
property int selectedIndex: Shotcut.Filter.NoCurrentFilter

signal currentFilterRequested(int attachedIndex)
signal copyFilterRequested()

function clearCurrentFilter() {
if (filterConfig.item) {
Expand Down Expand Up @@ -225,25 +226,10 @@ Rectangle {
icon.source: 'qrc:///icons/oxygen/32x32/actions/edit-copy.png'
enabled: selectedIndex > Shotcut.Filter.NoCurrentFilter
opacity: enabled ? 1 : 0.5
onClicked: application.copyFilters()
onClicked: root.copyFilterRequested()

Shotcut.HoverTip {
text: qsTr('Copy checked filters')
}
}

Shotcut.Button {
id: copySelectedButton

implicitWidth: height
icon.name: 'edit-select'
icon.source: 'qrc:///icons/oxygen/32x32/actions/edit-select.png'
enabled: selectedIndex > Shotcut.Filter.NoCurrentFilter
opacity: enabled ? 1 : 0.5
onClicked: application.copyCurrentFilter()

Shotcut.HoverTip {
text: qsTr('Copy current filter')
text: qsTr('Copy filters')
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/qmltypes/qmlapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,20 @@ bool QmlApplication::hasFiltersOnClipboard()
return MLT.hasFiltersOnClipboard();
}

void QmlApplication::copyFilters()
void QmlApplication::copyEnabledFilters()
{
QScopedPointer<Mlt::Producer> producer(new Mlt::Producer(
MAIN.filterController()->attachedModel()->producer()));
MLT.copyFilters(producer.data());
MLT.copyFilters(producer.data(), MLT.FILTER_INDEX_ENABLED);
QGuiApplication::clipboard()->setText(MLT.filtersClipboardXML());
emit QmlApplication::singleton().filtersCopied();
}

void QmlApplication::copyAllFilters()
{
QScopedPointer<Mlt::Producer> producer(new Mlt::Producer(
MAIN.filterController()->attachedModel()->producer()));
MLT.copyFilters(producer.data(), MLT.FILTER_INDEX_ENABLED);
QGuiApplication::clipboard()->setText(MLT.filtersClipboardXML());
emit QmlApplication::singleton().filtersCopied();
}
Expand Down
3 changes: 2 additions & 1 deletion src/qmltypes/qmlapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class QmlApplication : public QObject
static QString OS();
static QRect mainWinRect();
static bool hasFiltersOnClipboard();
Q_INVOKABLE static void copyFilters();
Q_INVOKABLE static void copyAllFilters();
Q_INVOKABLE static void copyEnabledFilters();
Q_INVOKABLE static void copyCurrentFilter();
Q_INVOKABLE static void pasteFilters();
Q_INVOKABLE static QString clockFromFrames(int frames);
Expand Down

0 comments on commit 3438da2

Please sign in to comment.