Reorganize menus, disable timeline clip actions when not available

parent 7eb73ea8
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="155" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="156" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="dvd_wizard" />
......@@ -18,32 +18,12 @@
<Action name="add_text_template_clip" />
<Action name="add_folder" />
<Action name="download_resource" />
<Menu name="extract_audio" ><text>Extract Audio</text>
<ActionList name="audio_transcoders_list" />
</Menu>
<Menu name="clip_actions" ><text>Clip Jobs</text>
<ActionList name="clip_jobs" />
</Menu>
<Menu name="transcoders" ><text>Transcode</text>
<ActionList name="transcoders_list" />
</Menu>
<Menu name="generators" ><text>Generators</text>
</Menu>
<Separator />
<Action name="bin_view_mode" />
<Action name="stopmotion" />
<Separator />
<Action name="locate_clip" />
<Action name="reload_clip" />
<Action name="duplicate_clip" />
<Action name="proxy_clip" />
<Menu name="clip_in_timeline"><text>Clip in Timeline</text>
<ActionList name="timeline_occurences" />
</Menu>
<Action name="clip_properties" />
<Action name="edit_clip" />
<Action name="delete_clip" />
<Separator />
<Action name="project_clean" />
<Action name="project_render" />
<Action name="project_adjust_profile" />
......@@ -71,10 +51,26 @@
<Action name="delete_all_clip_markers" />
</Menu>
<Action name="auto_transition" />
<Action name="split_audio" />
<Separator />
<Action name="clip_video_only" />
<Action name="clip_audio_only" />
<Menu name="extract_audio" ><text>Extract Audio</text>
<ActionList name="audio_transcoders_list" />
</Menu>
<Menu name="clip_actions" ><text>Clip Jobs</text>
<ActionList name="clip_jobs" />
</Menu>
<Menu name="transcoders" ><text>Transcode</text>
<ActionList name="transcoders_list" />
</Menu>
<Separator />
<Action name="locate_clip" />
<Action name="reload_clip" />
<Action name="duplicate_clip" />
<Action name="proxy_clip" />
<Menu name="clip_in_timeline"><text>Clip in Timeline</text>
<ActionList name="timeline_occurences" />
</Menu>
<Action name="clip_properties" />
<Action name="edit_clip" />
<Action name="delete_clip" />
</Menu>
<Menu name="timeline" ><text>Timeline</text>
......@@ -101,14 +97,16 @@
<Action name="unset_render_timeline_zone" />
<Action name="clear_render_timeline_zone"/>
</Menu>
<Action name="resize_timeline_clip_start" />
<Action name="resize_timeline_clip_end" />
<Menu name="current_clip" ><text>Current clip</text>
<Action name="cut_timeline_clip" />
<Action name="delete_timeline_clip" />
<Action name="edit_item_duration" />
<Action name="clip_in_project_tree" />
<Action name="expand_timeline_clip" />
<Action name="resize_timeline_clip_start" />
<Action name="resize_timeline_clip_end" />
<Menu name="current_clip" ><text>Current clip</text>
<Action name="cut_timeline_clip" />
<Action name="delete_timeline_clip" />
<Action name="edit_item_duration" />
<Action name="clip_split" />
<Action name="clip_disable" />
<Action name="clip_in_project_tree" />
<Action name="expand_timeline_clip" />
</Menu>
<Menu name="guide_menu" ><text>Guides</text>
<Action name="add_guide" />
......
This diff is collapsed.
......@@ -88,10 +88,10 @@ public:
static QMap<QString, QStringList> m_lumaFiles;
/** @brief Adds an action to the action collection and stores the name. */
void addAction(const QString &name, QAction *action);
void addAction(const QString &name, QAction *action, KActionCategory *category = nullptr);
/** @brief Adds an action to the action collection and stores the name. */
QAction *addAction(const QString &name, const QString &text, const QObject *receiver, const char *member, const QIcon &icon = QIcon(),
const QKeySequence &shortcut = QKeySequence());
const QKeySequence &shortcut = QKeySequence(), KActionCategory *category = nullptr);
/**
* @brief Adds a new dock widget to this window.
......@@ -180,7 +180,7 @@ private:
QMenu *m_effectsMenu;
QMenu *m_transitionsMenu;
QMenu *m_timelineContextMenu;
QMenu *m_timelineContextClipMenu;
QList <QAction *> m_timelineClipActions;
QMenu *m_timelineContextTransitionMenu;
KDualAction *m_useTimelineZone;
......@@ -216,7 +216,6 @@ private:
QAction *m_playZone;
QAction *m_loopClip;
QAction *m_proxyClip;
QActionGroup *m_clipTypeGroup;
QString m_theme;
KIconLoader *m_iconLoader;
KToolBar *m_timelineToolBar;
......@@ -388,7 +387,7 @@ private slots:
void slotEditItemDuration();
void slotClipInProjectTree();
// void slotClipToProjectTree();
void slotSplitAudio();
void slotSplitAV();
void slotSetAudioAlignReference();
void slotAlignAudio();
void slotUpdateClipType(QAction *action);
......
......@@ -63,6 +63,7 @@ TimelineController::TimelineController(QObject *parent)
{
m_disablePreview = pCore->currentDoc()->getAction(QStringLiteral("disable_preview"));
connect(m_disablePreview, &QAction::triggered, this, &TimelineController::disablePreview);
connect(this, &TimelineController::selectionChanged, this, &TimelineController::updateClipActions);
m_disablePreview->setEnabled(false);
}
......@@ -1443,6 +1444,21 @@ void TimelineController::switchEnableState(int clipId)
TimelineFunctions::switchEnableState(m_model, clipId);
}
bool TimelineController::splitAV()
{
int cid = m_selection.selectedItems.first();
if (m_model->isClip(cid)) {
std::shared_ptr<ClipModel> clip = m_model->getClipPtr(cid);
if (clip->clipState() == PlaylistState::AudioOnly) {
return TimelineFunctions::requestSplitVideo(m_model, cid, videoTarget());
} else {
return TimelineFunctions::requestSplitAudio(m_model, cid, audioTarget());
}
}
pCore->displayMessage(i18n("No clip found to perform AV split operation"), InformationMessage, 500);
return false;
}
void TimelineController::splitAudio(int clipId)
{
TimelineFunctions::requestSplitAudio(m_model, clipId, audioTarget());
......@@ -1656,3 +1672,43 @@ void TimelineController::editItemDuration(int id)
}
}
}
void TimelineController::updateClipActions()
{
if (m_selection.selectedItems.isEmpty()) {
for(QAction *act : clipActions) {
act->setEnabled(false);
}
return;
}
std::shared_ptr<ClipModel> clip(nullptr);
int item = m_selection.selectedItems.first();
if (m_model->isClip(item)) {
clip = m_model->getClipPtr(item);
}
for(QAction *act : clipActions) {
bool enableAction = true;
const QChar actionData = act->data().toChar();
if (actionData == QLatin1Char('G')) {
enableAction = m_selection.selectedItems.size() > 1;
} else if (actionData == QLatin1Char('U')) {
enableAction = m_model->m_groups->isInGroup(item) && !m_model->isInSelection(item);
} else if (actionData == QLatin1Char('A')) {
enableAction = clip && clip->clipState() == PlaylistState::AudioOnly;
} else if (actionData == QLatin1Char('V')) {
enableAction = clip && clip->clipState() == PlaylistState::VideoOnly;
} else if (actionData == QLatin1Char('D')) {
enableAction = clip && clip->clipState() == PlaylistState::Disabled;
} else if (actionData == QLatin1Char('E')) {
enableAction = clip && clip->clipState() != PlaylistState::Disabled;
} else if (actionData == QLatin1Char('X') || actionData == QLatin1Char('S')) {
enableAction = clip && clip->canBeVideo() && clip->canBeAudio();
if (enableAction && actionData == QLatin1Char('S')) {
act->setText(clip->clipState() == PlaylistState::AudioOnly ? i18n("Split video") : i18n("Split audio"));
}
} else if (actionData == QLatin1Char('C') && clip == nullptr) {
enableAction = false;
}
act->setEnabled(enableAction);
}
}
......@@ -271,6 +271,7 @@ public:
Q_INVOKABLE void splitAudio(int clipId);
Q_INVOKABLE void splitVideo(int clipId);
bool splitAV();
/* @brief Seeks to selected clip start / end
*/
......@@ -394,6 +395,11 @@ public slots:
private slots:
void slotUpdateSelection(int itemId);
void updateClipActions();
public:
/** @brief a list of actions that have to be enabled/disabled depending on the timeline selection */
QList <QAction *>clipActions;
private:
QQuickItem *m_root;
......
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