Skip to content

Commit

Permalink
CommandPalette: support marker title
Browse files Browse the repository at this point in the history
'marker:X my first marker,Y my second marker' etc ...
  • Loading branch information
rodlie committed Aug 2, 2024
1 parent ebe4aee commit 3570610
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/app/GUI/extraactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ void MainWindow::setupMenuExtras()
const auto act = menu->addAction(QIcon::fromTheme("sequence"/* TODO: find new (blender) icon! */),
tr("Marker at ..."));
act->setData("cmd:marker");
act->setToolTip(QString("<p><b>%1</b> %2 <i>%3</i></p>").arg(tr("Marker"),
tr("at"),
tr("TIME (frame/sec/min)."
" Use <b>,</b> to add multiple markers.")));
act->setToolTip(QString("<p><b>%1</b> %2 <i>%3</i><br><br>%4</p>").arg(tr("Marker"),
tr("at"),
tr("TIME TITLE."),
tr("Time can be frame, sec (<i>X</i><b>s</b>) or min (<i>X</i><b>m</b>)."
" Use <b>,</b> to add multiple markers. Title is optional.")));
cmdAddAction(act);
}
// clear markers
Expand Down
11 changes: 7 additions & 4 deletions src/ui/dialogs/commandpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CommandPalette::CommandPalette(Document& document,
lay->addWidget(mUserInput);
lay->addWidget(mLabel);
lay->addWidget(mSuggestions);
lay->addStretch();

mSuggestions->setObjectName("CommandPaletteSuggestions");
mSuggestions->setMinimumHeight(150);
Expand Down Expand Up @@ -219,8 +220,7 @@ void CommandPalette::parseCmd(const QString &input)
const bool doMove = (validMoveCmd.match(input).hasMatch() && input != "move:");
qDebug() << "do move?" << doMove;

static QRegularExpression validMarkersCmd("^marker[:][0-9sm,-]*$");
const bool doMarkers = (validMarkersCmd.match(input).hasMatch() && input != "marker:");
const bool doMarkers = (input.startsWith("marker:") && input != "marker:");
qDebug() << "do markers?" << doMarkers;

static QRegularExpression validFrameInCmd("^in[:][-]?[0-9]*[sm]?$");
Expand Down Expand Up @@ -302,7 +302,9 @@ void CommandPalette::parseCmd(const QString &input)
const auto scene = *mDocument.fActiveScene;
if (!scene) { return; }
for (const auto &arg : args.split(",")) {
QString mark = arg.simplified();
const auto args = arg.split(" ");
bool hasTitle = args.count() > 1;
QString mark = hasTitle ? args.at(0).simplified() : arg.simplified();
const bool hasSec = mark.endsWith("s");
const bool hasMin = mark.endsWith("m");
if (hasSec && hasMin) { continue; }
Expand All @@ -311,7 +313,8 @@ void CommandPalette::parseCmd(const QString &input)
if (hasSec) { value *= scene->getFps(); }
else if (hasMin) { value = (value * 60) * scene->getFps(); }
qDebug() << "do marker" << value;
scene->setMarker(value);
if (hasTitle) { scene->setMarker(args.mid(1).join(" "), value); }
else { scene->setMarker(value); }
}
appendHistory(input);
accept();
Expand Down

0 comments on commit 3570610

Please sign in to comment.