Switch timeline headers menu to qwidget

parent 6a068663
Pipeline #14115 passed with stage
in 14 minutes and 33 seconds
......@@ -543,6 +543,36 @@ void MainWindow::init()
QMenu *guideMenu = new QMenu(i18n("Go to Guide..."), this);
timelineMenu->addMenu(guideMenu);
// Timeline ruler menu
QMenu *timelineRulerMenu = new QMenu(this);
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_guide")));
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("edit_guide")));
timelineRulerMenu->addMenu(guideMenu);
timelineRulerMenu->addAction(actionCollection()->action(QStringLiteral("add_project_note")));
// Timeline headers menu
QMenu *timelineHeadersMenu = new QMenu(this);
timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("insert_track")));
timelineHeadersMenu->addAction(actionCollection()->action(QStringLiteral("delete_track")));
QMenu *thumbsMenu = new QMenu(i18n("Thumbnails"), this);
QActionGroup *thumbGroup = new QActionGroup(this);
QAction *inFrame = new QAction(i18n("In Frame"), thumbGroup);
inFrame->setData(QStringLiteral("2"));
inFrame->setCheckable(true);
thumbsMenu->addAction(inFrame);
QAction *inOutFrame = new QAction(i18n("In/Out Frames"), thumbGroup);
inOutFrame->setData(QStringLiteral("0"));
inOutFrame->setCheckable(true);
thumbsMenu->addAction(inOutFrame);
QAction *allFrame = new QAction(i18n("All Frames"), thumbGroup);
allFrame->setData(QStringLiteral("1"));
allFrame->setCheckable(true);
thumbsMenu->addAction(allFrame);
QAction *noFrame = new QAction(i18n("No Thumbnails"), thumbGroup);
noFrame->setData(QStringLiteral("3"));
noFrame->setCheckable(true);
thumbsMenu->addAction(noFrame);
timelineHeadersMenu->addMenu(thumbsMenu);
QMenu *openGLMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("qt_opengl"), this));
#if defined(Q_OS_WIN)
......@@ -681,7 +711,7 @@ void MainWindow::init()
#ifdef USE_JOGSHUTTLE
new JogManager(this);
#endif
getMainTimeline()->setTimelineMenu(timelineClipMenu, compositionMenu, timelineMenu, guideMenu, actionCollection()->action(QStringLiteral("edit_guide")));
getMainTimeline()->setTimelineMenu(timelineClipMenu, compositionMenu, timelineMenu, guideMenu, timelineRulerMenu, actionCollection()->action(QStringLiteral("edit_guide")), timelineHeadersMenu, thumbsMenu);
scmanager->slotCheckActiveScopes();
// m_messageLabel->setMessage(QStringLiteral("This is a beta version. Always backup your data"), MltError);
}
......@@ -1571,7 +1601,7 @@ void MainWindow::setupActions()
disablePreview->setCheckable(true);
addAction(QStringLiteral("disable_preview"), disablePreview);
addAction(QStringLiteral("add_guide"), i18n("Add Guide"), this, SLOT(slotAddGuide()), QIcon::fromTheme(QStringLiteral("list-add")));
addAction(QStringLiteral("add_guide"), i18n("Add/Remove Guide"), this, SLOT(slotAddGuide()), QIcon::fromTheme(QStringLiteral("list-add")));
addAction(QStringLiteral("delete_guide"), i18n("Delete Guide"), this, SLOT(slotDeleteGuide()), QIcon::fromTheme(QStringLiteral("edit-delete")));
addAction(QStringLiteral("edit_guide"), i18n("Edit Guide"), this, SLOT(slotEditGuide()), QIcon::fromTheme(QStringLiteral("document-properties")));
addAction(QStringLiteral("delete_all_guides"), i18n("Delete All Guides"), this, SLOT(slotDeleteAllGuides()),
......
......@@ -36,6 +36,11 @@ void NotesPlugin::setProject(KdenliveDoc *document)
connect(m_widget, SIGNAL(textChanged()), document, SLOT(setModified()));
}
void NotesPlugin::showDock()
{
m_notesDock->show();
}
void NotesPlugin::slotInsertTimecode()
{
int frames = pCore->monitorManager()->projectMonitor()->position();
......
......@@ -33,6 +33,7 @@ public:
explicit NotesPlugin(ProjectManager *projectManager);
NotesWidget *widget();
void clear();
void showDock();
private slots:
void setProject(KdenliveDoc *document);
......
......@@ -692,6 +692,7 @@ QString ProjectManager::documentNotes() const
void ProjectManager::slotAddProjectNote()
{
m_notesPlugin->showDock();
m_notesPlugin->widget()->raise();
m_notesPlugin->widget()->setFocus();
m_notesPlugin->widget()->addProjectNote();
......
......@@ -86,11 +86,12 @@ Rectangle {
onPressed: {
parent.clicked()
if (mouse.button == Qt.RightButton) {
headerMenu.trackId = trackId
/*headerMenu.trackId = trackId
headerMenu.thumbsFormat = thumbsFormat
headerMenu.audioTrack = trackHeadRoot.isAudio
headerMenu.recEnabled = trackHeadRoot.showAudioRecord
headerMenu.popup()
headerMenu.popup()*/
root.showHeaderMenu()
}
}
onClicked: {
......
......@@ -22,6 +22,8 @@ Rectangle {
signal showClipMenu()
signal showCompositionMenu()
signal showTimelineMenu()
signal showRulerMenu()
signal showHeaderMenu()
signal zoomIn(bool onMouse)
signal zoomOut(bool onMouse)
signal processingDrag(bool dragging)
......@@ -580,62 +582,6 @@ Rectangle {
clearDropData()
}
}
OLD.Menu {
id: rulermenu
property int clickedX
property int clickedY
onAboutToHide: {
timeline.ungrabHack()
editGuideMenu2.visible = false
}
OLD.MenuItem {
id: addGuideMenu2
text: i18n("Add Guide")
onTriggered: {
timeline.switchGuide(root.consumerPosition);
}
}
GuidesMenu {
title: i18n("Go to guide...")
menuModel: guidesModel
enabled: guidesDelegateModel.count > 0
onGuideSelected: {
proxy.position = assetFrame
}
}
OLD.MenuItem {
id: editGuideMenu2
text: i18n("Edit Guide")
visible: false
onTriggered: {
timeline.editGuide(root.consumerPosition);
}
}
OLD.MenuItem {
id: addProjectNote
text: i18n("Add Project Note")
onTriggered: {
timeline.triggerAction('add_project_note')
}
}
onAboutToShow: {
if (guidesModel.hasMarker(root.consumerPosition)) {
// marker at timeline position
addGuideMenu2.text = i18n("Remove Guide")
editGuideMenu2.visible = true
} else {
addGuideMenu2.text = i18n("Add Guide")
}
console.log("pop menu")
}
}
MessageDialog {
id: compositionFail
title: i18n("Timeline error")
icon: StandardIcon.Warning
text: i18n("Impossible to add a composition at that position. There might not be enough space")
standardButtons: StandardButton.Ok
}
OLD.Menu {
id: headerMenu
property int trackId: -1
......@@ -942,7 +888,7 @@ Rectangle {
root.showTimelineMenu()
} else {
// ruler menu
rulermenu.popup()
root.showRulerMenu()
}
}
}
......
......@@ -2823,3 +2823,10 @@ void TimelineController::collapseActiveTrack()
int collapsed = m_model->getTrackProperty(m_activeTrack, QStringLiteral("kdenlive:collapsed")).toInt();
m_model->setTrackProperty(m_activeTrack, QStringLiteral("kdenlive:collapsed"), collapsed > 0 ? QStringLiteral("0") : QStringLiteral("5"));
}
void TimelineController::setTrackProperty(const QString &name, const QString &value)
{
if (m_activeTrack > -1) {
m_model->setTrackProperty(m_activeTrack, name, value);
}
}
......@@ -389,6 +389,10 @@ public:
*/
void seekToMouse();
/* @brief Set a property on the active track
*/
void setTrackProperty(const QString &name, const QString &value);
/* @brief Returns a list of all luma files used in the project
*/
QStringList extractCompositionLumas() const;
......
......@@ -133,12 +133,15 @@ const QMap<QString, QString> TimelineWidget::sortedItems(const QStringList &item
return sortedItems;
}
void TimelineWidget::setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu, QMenu *timelineMenu, QMenu *guideMenu, QAction *editGuideAction)
void TimelineWidget::setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu, QMenu *timelineMenu, QMenu *guideMenu, QMenu *timelineRulerMenu, QAction *editGuideAction, QMenu *headerMenu, QMenu *thumbsMenu)
{
m_timelineClipMenu = clipMenu;
m_timelineCompositionMenu = compositionMenu;
m_timelineMenu = timelineMenu;
m_timelineRulerMenu = timelineRulerMenu;
m_guideMenu = guideMenu;
m_headerMenu = headerMenu;
m_thumbsMenu = thumbsMenu;
m_editGuideAcion = editGuideAction;
updateEffectFavorites();
updateTransitionFavorites();
......@@ -151,6 +154,9 @@ void TimelineWidget::setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu, QM
connect(m_guideMenu, &QMenu::triggered, [&] (QAction *ac) {
m_proxy->setPosition(ac->data().toInt());
});
connect(m_headerMenu, &QMenu::triggered, [&] (QAction *ac) {
m_proxy->setTrackProperty(QStringLiteral("kdenlive:thumbs_format"), ac->data().toString());
});
m_timelineClipMenu->addMenu(m_favEffects);
m_timelineClipMenu->addMenu(m_favCompositions);
m_timelineMenu->addMenu(m_favCompositions);
......@@ -189,6 +195,8 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M
connect(rootObject(), SIGNAL(showClipMenu()), this, SLOT(showClipMenu()));
connect(rootObject(), SIGNAL(showCompositionMenu()), this, SLOT(showCompositionMenu()));
connect(rootObject(), SIGNAL(showTimelineMenu()), this, SLOT(showTimelineMenu()));
connect(rootObject(), SIGNAL(showRulerMenu()), this, SLOT(showRulerMenu()));
connect(rootObject(), SIGNAL(showHeaderMenu()), this, SLOT(showHeaderMenu()));
m_proxy->setRoot(rootObject());
setVisible(true);
loading = false;
......@@ -218,6 +226,38 @@ void TimelineWidget::showCompositionMenu()
});
}
void TimelineWidget::showHeaderMenu()
{
m_headerMenu->popup(m_clickPos);
connect(m_headerMenu, &QMenu::aboutToHide, [this]() {
slotUngrabHack();
});
}
void TimelineWidget::showRulerMenu()
{
m_guideMenu->clear();
const QList<CommentedTime> guides = pCore->projectManager()->current()->getGuideModel()->getAllMarkers();
QAction *ac;
m_editGuideAcion->setEnabled(false);
double fps = pCore->getCurrentFps();
int currentPos = rootObject()->property("consumerPosition").toInt();
for (auto guide : guides) {
ac = new QAction(guide.comment(), this);
int frame = guide.time().frames(fps);
ac->setData(frame);
if (frame == currentPos) {
m_editGuideAcion->setEnabled(true);
}
m_guideMenu->addAction(ac);
}
m_timelineRulerMenu->popup(m_clickPos);
connect(m_timelineRulerMenu, &QMenu::aboutToHide, [this]() {
slotUngrabHack();
});
}
void TimelineWidget::showTimelineMenu()
{
m_guideMenu->clear();
......
......@@ -54,7 +54,7 @@ public:
/* @brief Give keyboard focus to timeline qml */
void focusTimeline();
/** @brief Initiate timeline clip context menu */
void setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu, QMenu *timelineMenu, QMenu *guideMenu, QAction *editGuideAction);
void setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu, QMenu *timelineMenu, QMenu *timelineRulerMenu, QMenu *guideMenu, QAction *editGuideAction, QMenu *headerMenu, QMenu *thumbsMenu);
bool loading;
protected:
......@@ -74,13 +74,18 @@ private slots:
void showClipMenu();
void showCompositionMenu();
void showTimelineMenu();
void showRulerMenu();
void showHeaderMenu();
private:
TimelineController *m_proxy;
QMenu *m_timelineClipMenu;
QMenu *m_timelineCompositionMenu;
QMenu *m_timelineMenu;
QMenu *m_timelineRulerMenu;
QMenu *m_guideMenu;
QMenu *m_headerMenu;
QMenu *m_thumbsMenu;
QMenu *m_favEffects;
QMenu *m_favCompositions;
QAction *m_editGuideAcion;
......
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