Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the marker color cycle action to the timeline dock #1387

Merged
merged 1 commit into from Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 1 addition & 32 deletions src/docks/markersdock.cpp
Expand Up @@ -135,7 +135,6 @@ MarkersDock::MarkersDock(QWidget *parent) :
QIcon filterIcon = QIcon::fromTheme("marker", QIcon(":/icons/oxygen/32x32/actions/marker.png"));
setWindowIcon(filterIcon);
toggleViewAction()->setIcon(windowIcon());
setupActions();

QScrollArea *scrollArea = new QScrollArea();
scrollArea->setFrameShape(QFrame::NoFrame);
Expand Down Expand Up @@ -163,7 +162,7 @@ MarkersDock::MarkersDock(QWidget *parent) :
mainMenu->addAction(Actions["timelineNextMarkerAction"]);
mainMenu->addAction(Actions["timelineDeleteMarkerAction"]);
mainMenu->addAction(Actions["timelineMarkSelectedClipAction"]);
mainMenu->addAction(Actions["markerCycleColorAction"]);
mainMenu->addAction(Actions["timelineCycleMarkerColorAction"]);
mainMenu->addAction(tr("Remove All Markers"), this, SLOT(onRemoveAllRequested()));
QAction *action;
QMenu *columnsMenu = new QMenu(tr("Columns"), this);
Expand Down Expand Up @@ -258,36 +257,6 @@ MarkersDock::~MarkersDock()
{
}

void MarkersDock::setupActions()
{
QAction *action;

action = new QAction(tr("Cycle Color On Selected Marker"), this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_M));
connect(action, &QAction::triggered, this, [&]() {
if (m_model && m_proxyModel) {
QModelIndexList indices = m_treeView->selectedIndexes();
if (indices.size() > 0) {
QModelIndex realIndex = m_proxyModel->mapToSource(indices[0]);
if (realIndex.isValid()) {
show();
raise();
auto marker = m_model->getMarker(realIndex.row());
auto allColors = m_model->allColors();
int colorIndex = allColors.indexOf(marker.color);
if (colorIndex >= 0) {
show();
raise();
colorIndex = (colorIndex + 1) % allColors.size();
m_model->setColor(realIndex.row(), allColors[colorIndex]);
}
}
}
}
});
Actions.add("markerCycleColorAction", action);
}

void MarkersDock::setModel(MarkersModel *model)
{
m_treeView->blockSelectionEvent(true);
Expand Down
1 change: 0 additions & 1 deletion src/docks/markersdock.h
Expand Up @@ -67,7 +67,6 @@ private slots:

private:
void enableButtons(bool enable);
void setupActions();

MarkersModel *m_model;
QSortFilterProxyModel *m_proxyModel;
Expand Down
17 changes: 17 additions & 0 deletions src/docks/timelinedock.cpp
Expand Up @@ -132,6 +132,7 @@ TimelineDock::TimelineDock(QWidget *parent) :
markerMenu->addAction(Actions["timelineNextMarkerAction"]);
markerMenu->addAction(Actions["timelineDeleteMarkerAction"]);
markerMenu->addAction(Actions["timelineMarkSelectedClipAction"]);
markerMenu->addAction(Actions["timelineCycleMarkerColorAction"]);
m_mainMenu->addMenu(markerMenu);
Actions.loadFromMenu(m_mainMenu);

Expand Down Expand Up @@ -753,6 +754,22 @@ void TimelineDock::setupActions()
});
Actions.add("timelineDeleteMarkerAction", action);

action = new QAction(tr("Cycle Marker Color"), this);
action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_M));
connect(action, &QAction::triggered, this, [&]() {
int markerIndex = m_markersModel.markerIndexForPosition(m_position);
if (markerIndex >= 0) {
auto marker = m_markersModel.getMarker(markerIndex);
auto allColors = m_markersModel.allColors();
int colorIndex = allColors.indexOf(marker.color);
if (colorIndex >= 0) {
colorIndex = (colorIndex + 1) % allColors.size();
m_markersModel.setColor(markerIndex, allColors[colorIndex]);
}
}
});
Actions.add("timelineCycleMarkerColorAction", action);

action = new QAction(tr("Create Marker Around Selected Clip"), this);
action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_M));
connect(action, &QAction::triggered, this, [&]() {
Expand Down