Commit e78f2fd9 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Fix keyboard shortcuts display in actions tooltips (avoid update loop), add...

Fix keyboard shortcuts display in actions tooltips (avoid update loop), add one for timeline target menu
parent bebf685e
......@@ -771,6 +771,15 @@ void Core::triggerAction(const QString &name)
}
}
const QString Core::actionText(const QString &name)
{
QAction *action = m_mainWindow->actionCollection()->action(name);
if (action) {
return action->toolTip();
}
return QString();
}
void Core::clean()
{
m_self.reset();
......
......@@ -258,7 +258,10 @@ private:
QMutex m_thumbProfileMutex;
public slots:
/** @brief Trigger (launch) an action by its actionCollection name */
void triggerAction(const QString &name);
/** @brief Get an action's descriptive text by its actionCollection name */
const QString actionText(const QString &name);
/** @brief display a user info/warning message in the project bin */
void displayBinMessage(const QString &text, int type, const QList<QAction *> &actions = QList<QAction *>(), bool showClose = false, BinMessage::BinCategory messageCategory = BinMessage::BinCategory::NoMessage);
void displayBinLogMessage(const QString &text, int type, const QString &logInfo);
......
......@@ -518,7 +518,7 @@ void MainWindow::init()
}
}
}
updateActionsToolTip();
m_timelineToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
m_timelineToolBar->setProperty("otherToolbar", true);
timelinePreview->setToolButtonStyle(m_timelineToolBar->toolButtonStyle());
......@@ -742,6 +742,7 @@ void MainWindow::init()
if (!QDir(KdenliveSettings::currenttmpfolder()).isReadable())
KdenliveSettings::setCurrenttmpfolder(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
updateActionsToolTip();
QTimer::singleShot(0, this, &MainWindow::GUISetupDone);
#ifdef USE_JOGSHUTTLE
......@@ -804,27 +805,22 @@ void MainWindow::updateActionsToolTip()
for (int i = 0; i < collections.count(); ++i) {
KActionCollection *coll = collections.at(i);
for (QAction *tempAction : coll->actions()) {
if (tempAction == m_timeFormatButton) {
continue;
}
// find the shortcut pattern and delete (note the preceding space in the RegEx)
QString strippedTooltip = tempAction->toolTip().remove(QRegExp(QStringLiteral("\\s\\(.*\\)")));
// append shortcut if it exists for action
if (tempAction->shortcut() == QKeySequence()) {
QString toolTip = KLocalizedString::removeAcceleratorMarker(tempAction->toolTip());
QString strippedTooltip = toolTip.remove(QRegExp(QStringLiteral("\\s\\(.*\\)")));
QKeySequence shortCut = tempAction->shortcut();
if (shortCut == QKeySequence()) {
tempAction->setToolTip(strippedTooltip);
} else {
tempAction->setToolTip(strippedTooltip + QStringLiteral(" (") + tempAction->shortcut().toString() + QLatin1Char(')'));
tempAction->setToolTip(QString("%1 (%2)").arg(strippedTooltip).arg(shortCut.toString()));
}
connect(tempAction, &QAction::changed, this, &MainWindow::updateAction);
}
}
}
void MainWindow::updateAction()
{
auto *action = qobject_cast<QAction *>(sender());
QString toolTip = KLocalizedString::removeAcceleratorMarker(action->toolTip());
QString strippedTooltip = toolTip.remove(QRegExp(QStringLiteral("\\s\\(.*\\)")));
action->setToolTip(i18nc("@info:tooltip Tooltip of toolbar button", "%1 (%2)", strippedTooltip, action->shortcut().toString()));
}
MainWindow::~MainWindow()
{
pCore->prepareShutdown();
......@@ -2319,6 +2315,7 @@ void MainWindow::slotEditKeys()
}
dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General"));
dialog.configure();
updateActionsToolTip();
}
void MainWindow::slotPreferences(int page, int option)
......
......@@ -477,7 +477,6 @@ private slots:
/** @brief Set timeline toolbar icon size. */
void setTimelineToolbarIconSize(QAction *a);
void slotEditItemSpeed();
void updateAction();
/** @brief Request adjust of timeline track height */
void resetTimelineTracks();
/** @brief Set keyboard grabbing on current timeline item */
......
......@@ -137,6 +137,7 @@ Rectangle {
}
}
ToolButton {
id: targetMouse
focusPolicy: Qt.NoFocus
visible: trackHeadRoot.isAudio && timeline.clipTargets > 1 && trackHeadRoot.height > (2 * expandButton.height)
background: Rectangle {
......@@ -155,6 +156,20 @@ Rectangle {
onClicked: {
root.showTargetMenu(trackId)
}
ToolTip {
visible: targetMouse.hovered
font: miniFont
delay: 1500
timeout: 5000
background: Rectangle {
color: activePalette.alternateBase
border.color: activePalette.light
}
contentItem: Label {
color: activePalette.text
text: timeline.actionText("switch_target_stream")
}
}
}
}
ToolTip {
......
......@@ -545,6 +545,11 @@ void TimelineController::triggerAction(const QString &name)
pCore->triggerAction(name);
}
const QString TimelineController::actionText(const QString &name)
{
return pCore->actionText(name);
}
QString TimelineController::timecode(int frames) const
{
return KdenliveSettings::frametimecode() ? QString::number(frames) : m_model->tractor()->frames_to_time(frames, mlt_time_smpte_df);
......
......@@ -235,6 +235,7 @@ public:
Q_INVOKABLE void deleteSelectedClips();
Q_INVOKABLE void triggerAction(const QString &name);
Q_INVOKABLE const QString actionText(const QString &name);
/* @brief Returns id of the timeline selcted clip if there is only 1 clip selected
* or an AVSplit group. If allowComposition is true, returns composition id if
......
Markdown is supported
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