X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=1dbdef51b7b2dbb1c34999cebaee6bc309a4683e;hb=574472e8c2d42cc2828750920c9171ef7cc9c992;hp=9cdd2456bdf055b1a50a09d636addb2695cce2d8;hpb=920a6970886bec21928ba78ee132b8d6b50a44f0;p=kdenlive diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9cdd2456..1dbdef51 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,7 +58,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -262,19 +264,23 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent m_projectMonitor->setupMenu(static_cast(factory()->container("monitor_go", this)), m_playZone, m_loopZone); m_clipMonitor->setupMenu(static_cast(factory()->container("monitor_go", this)), m_playZone, m_loopZone, static_cast(factory()->container("marker_menu", this))); - m_projectList->setupGeneratorMenu(static_cast(factory()->container("generators", this)), static_cast(factory()->container("transcoders", this))); - QAction *action; + QMenu *clipInTimeline = static_cast(factory()->container("clip_in_timeline", this)); + clipInTimeline->setIcon(KIcon("go-jump")); + m_projectList->setupGeneratorMenu(static_cast(factory()->container("generators", this)), + static_cast(factory()->container("transcoders", this)), + clipInTimeline); + + KAction *action; // build themes menus QMenu *themesMenu = static_cast(factory()->container("themes_menu", this)); QActionGroup *themegroup = new QActionGroup(this); themegroup->setExclusive(true); - action = new QAction(i18n("Default"), this); + action = new KAction(i18n("Default"), this); action->setCheckable(true); themegroup->addAction(action); if (KdenliveSettings::colortheme().isEmpty()) action->setChecked(true); - const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates); for (int i = 0; i < schemeFiles.size(); ++i) { @@ -287,7 +293,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent QIcon icon = createSchemePreviewIcon(config); KConfigGroup group(config, "General"); const QString name = group.readEntry("Name", info.baseName()); - action = new QAction(name, this); + action = new KAction(name, this); action->setData(filename); action->setIcon(icon); action->setCheckable(true); @@ -295,11 +301,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent if (KdenliveSettings::colortheme() == filename) action->setChecked(true); } - - - - - /*KGlobal::dirs()->addResourceDir("themes", KStandardDirs::installPath("data") + QString("kdenlive/themes")); QStringList themes = KGlobal::dirs()->findAllResources("themes", QString(), KStandardDirs::Recursive | KStandardDirs::NoDuplicates); for (QStringList::const_iterator it = themes.constBegin(); it != themes.constEnd(); ++it) @@ -314,95 +315,51 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent themesMenu->addActions(themegroup->actions()); connect(themesMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotChangePalette(QAction*))); - // build effects menus - QMenu *videoEffectsMenu = static_cast(factory()->container("video_effects_menu", this)); - - QStringList effectInfo; - QMap effectsList; - for (int ix = 0; ix < videoEffects.count(); ix++) { - effectInfo = videoEffects.effectIdInfo(ix); - effectsList.insert(effectInfo.at(0).toLower(), effectInfo); - } - - foreach(const QStringList &value, effectsList) { - action = new QAction(value.at(0), this); - action->setData(value); - videoEffectsMenu->addAction(action); - } - - QMenu *audioEffectsMenu = static_cast(factory()->container("audio_effects_menu", this)); - - - effectsList.clear(); - for (int ix = 0; ix < audioEffects.count(); ix++) { - effectInfo = audioEffects.effectIdInfo(ix); - effectsList.insert(effectInfo.at(0).toLower(), effectInfo); - } - - foreach(const QStringList &value, effectsList) { - action = new QAction(value.at(0), this); - action->setData(value); - audioEffectsMenu->addAction(action); - } - + // Setup and fill effects and transitions menus. + m_videoEffectsMenu = static_cast(factory()->container("video_effects_menu", this)); + for (int i = 0; i < videoEffects.count(); ++i) + m_videoEffectsMenu->addAction(m_videoEffects[i]); + m_audioEffectsMenu = static_cast(factory()->container("audio_effects_menu", this)); + for (int i = 0; i < audioEffects.count(); ++i) + m_audioEffectsMenu->addAction(m_audioEffects[i]); m_customEffectsMenu = static_cast(factory()->container("custom_effects_menu", this)); - - if (customEffects.isEmpty()) m_customEffectsMenu->setEnabled(false); - else m_customEffectsMenu->setEnabled(true); - - effectsList.clear(); - for (int ix = 0; ix < customEffects.count(); ix++) { - effectInfo = customEffects.effectIdInfo(ix); - effectsList.insert(effectInfo.at(0).toLower(), effectInfo); - } - - foreach(const QStringList &value, effectsList) { - action = new QAction(value.at(0), this); - action->setData(value); - m_customEffectsMenu->addAction(action); - } + if (customEffects.isEmpty()) + m_customEffectsMenu->setEnabled(false); + else + m_customEffectsMenu->setEnabled(true); + for (int i = 0; i < customEffects.count(); ++i) + m_customEffectsMenu->addAction(m_customEffects[i]); + m_transitionsMenu = new QMenu(i18n("Add Transition"), this); + for (int i = 0; i < transitions.count(); ++i) + m_transitionsMenu->addAction(m_transitions[i]); + + connect(m_videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *))); + connect(m_audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *))); + connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *))); + connect(m_transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *))); QMenu *newEffect = new QMenu(this); - newEffect->addMenu(videoEffectsMenu); - newEffect->addMenu(audioEffectsMenu); + newEffect->addMenu(m_videoEffectsMenu); + newEffect->addMenu(m_audioEffectsMenu); newEffect->addMenu(m_customEffectsMenu); m_effectStack->setMenu(newEffect); - QMenu *viewMenu = static_cast(factory()->container("dockwindows", this)); const QList viewActions = createPopupMenu()->actions(); viewMenu->insertActions(NULL, viewActions); - connect(videoEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddVideoEffect(QAction *))); - connect(audioEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddAudioEffect(QAction *))); - connect(m_customEffectsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddCustomEffect(QAction *))); - m_timelineContextMenu = new QMenu(this); m_timelineContextClipMenu = new QMenu(this); m_timelineContextTransitionMenu = new QMenu(this); - - QMenu *transitionsMenu = new QMenu(i18n("Add Transition"), this); - QStringList effects = transitions.effectNames(); - - effectsList.clear(); - for (int ix = 0; ix < transitions.count(); ix++) { - effectInfo = transitions.effectIdInfo(ix); - effectsList.insert(effectInfo.at(0).toLower(), effectInfo); - } - foreach(const QStringList &value, effectsList) { - action = new QAction(value.at(0), this); - action->setData(value); - transitionsMenu->addAction(action); - } - connect(transitionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotAddTransition(QAction *))); - m_timelineContextMenu->addAction(actionCollection()->action("insert_space")); m_timelineContextMenu->addAction(actionCollection()->action("delete_space")); m_timelineContextMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Paste))); - m_timelineContextClipMenu->addAction(actionCollection()->action("edit_clip_duration")); - m_timelineContextClipMenu->addAction(actionCollection()->action("delete_timeline_clip")); + m_timelineContextClipMenu->addAction(actionCollection()->action("clip_in_project_tree")); + //m_timelineContextClipMenu->addAction(actionCollection()->action("clip_to_project_tree")); + m_timelineContextClipMenu->addAction(actionCollection()->action("edit_item_duration")); + m_timelineContextClipMenu->addAction(actionCollection()->action("delete_item")); m_timelineContextClipMenu->addAction(actionCollection()->action("group_clip")); m_timelineContextClipMenu->addAction(actionCollection()->action("ungroup_clip")); m_timelineContextClipMenu->addAction(actionCollection()->action("cut_timeline_clip")); @@ -412,14 +369,14 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent QMenu *markersMenu = (QMenu*)(factory()->container("marker_menu", this)); m_timelineContextClipMenu->addMenu(markersMenu); - m_timelineContextClipMenu->addMenu(transitionsMenu); - m_timelineContextClipMenu->addMenu(videoEffectsMenu); - m_timelineContextClipMenu->addMenu(audioEffectsMenu); + m_timelineContextClipMenu->addMenu(m_transitionsMenu); + m_timelineContextClipMenu->addMenu(m_videoEffectsMenu); + m_timelineContextClipMenu->addMenu(m_audioEffectsMenu); //TODO: re-enable custom effects menu when it is implemented m_timelineContextClipMenu->addMenu(m_customEffectsMenu); - m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_clip_duration")); - m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_timeline_clip")); + m_timelineContextTransitionMenu->addAction(actionCollection()->action("edit_item_duration")); + m_timelineContextTransitionMenu->addAction(actionCollection()->action("delete_item")); m_timelineContextTransitionMenu->addAction(actionCollection()->action(KStandardAction::name(KStandardAction::Copy))); m_timelineContextTransitionMenu->addAction(actionCollection()->action("auto_transition")); @@ -496,7 +453,10 @@ bool MainWindow::queryClose() } saveOptions(); if (m_monitorManager) m_monitorManager->stopActiveMonitor(); - if (m_activeDocument && m_activeDocument->isModified()) { + // warn the user to save if document is modified and we have clips in our project list + if (m_activeDocument && m_activeDocument->isModified() + && ((m_projectList->documentClipList().isEmpty() && !m_activeDocument->url().isEmpty()) + || !m_projectList->documentClipList().isEmpty())) { switch (KMessageBox::warningYesNoCancel(this, i18n("Save changes to document?"))) { case KMessageBox::Yes : // save document here. If saving fails, return false; @@ -576,7 +536,8 @@ void MainWindow::generateClip() QAction *action = qobject_cast(sender()); ClipGenerator *iGenerator = qobject_cast(action->parent()); - KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), QStringList(), QStringList(), 25, 720, 576); + KUrl clipUrl = iGenerator->generatedClip(action->data().toString(), m_activeDocument->projectFolder(), + QStringList(), QStringList(), m_activeDocument->fps(), m_activeDocument->width(), m_activeDocument->height()); if (!clipUrl.isEmpty()) { m_projectList->slotAddClip(QList () << clipUrl); } @@ -709,7 +670,6 @@ void MainWindow::slotUpdateClip(const QString &id) void MainWindow::slotConnectMonitors() { - m_projectList->setRenderer(m_projectMonitor->render); //connect(m_projectList, SIGNAL(receivedClipDuration(const QString &)), this, SLOT(slotUpdateClip(const QString &))); connect(m_projectList, SIGNAL(deleteProjectClips(QStringList, QMap)), this, SLOT(slotDeleteProjectClips(QStringList, QMap))); @@ -764,6 +724,7 @@ void MainWindow::setupActions() toolbar->setMovable(false); statusBar()->setStyleSheet(QString("QStatusBar QLabel {font-size:%1pt;} QStatusBar::item { border: 0px; font-size:%1pt;padding:0px; }").arg(statusBar()->font().pointSize())); QString style1 = "QToolBar { border: 0px } QToolButton { border-style: inset; border:1px solid #999999;border-radius: 3px;margin: 0px 3px;padding: 0px;} QToolButton:checked { background-color: rgba(224, 224, 0, 100); border-style: inset; border:1px solid #cc6666;border-radius: 3px;}"; + QString styleBorderless = "QToolButton { border-width: 0px;margin: 1px 3px 0px;padding: 0px;}"; //create edit mode buttons m_normalEditTool = new KAction(KIcon("kdenlive-normal-edit"), i18n("Normal mode"), this); @@ -855,20 +816,54 @@ void MainWindow::setupActions() m_buttonFitZoom = new KAction(KIcon("zoom-fit-best"), i18n("Fit zoom to project"), this); toolbar->addAction(m_buttonFitZoom); m_buttonFitZoom->setCheckable(false); - connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom())); - actionWidget = toolbar->widgetForAction(m_buttonFitZoom); - actionWidget->setMaximumWidth(max); - actionWidget->setMaximumHeight(max - 4); + m_zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this); + toolbar->addAction(m_zoomOut); + m_zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus); m_zoomSlider = new QSlider(Qt::Horizontal, this); m_zoomSlider->setMaximum(13); m_zoomSlider->setPageStep(1); + m_zoomSlider->setInvertedAppearance(true); m_zoomSlider->setMaximumWidth(150); m_zoomSlider->setMinimumWidth(100); toolbar->addWidget(m_zoomSlider); + m_zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this); + toolbar->addAction(m_zoomIn); + m_zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus); + + actionWidget = toolbar->widgetForAction(m_buttonFitZoom); + actionWidget->setMaximumWidth(max); + actionWidget->setMaximumHeight(max - 4); + actionWidget->setStyleSheet(styleBorderless); + + actionWidget = toolbar->widgetForAction(m_zoomIn); + actionWidget->setMaximumWidth(max); + actionWidget->setMaximumHeight(max - 4); + actionWidget->setStyleSheet(styleBorderless); + + actionWidget = toolbar->widgetForAction(m_zoomOut); + actionWidget->setMaximumWidth(max); + actionWidget->setMaximumHeight(max - 4); + actionWidget->setStyleSheet(styleBorderless); + + connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSetZoom(int))); + connect(m_zoomSlider, SIGNAL(sliderMoved(int)), this, SLOT(slotShowZoomSliderToolTip(int))); + connect(m_buttonFitZoom, SIGNAL(triggered()), this, SLOT(slotFitZoom())); + connect(m_zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn())); + connect(m_zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut())); + + toolbar->addSeparator(); + + //create automatic audio split button + m_buttonAutomaticSplitAudio = new KAction(KIcon("kdenlive-split-audio"), i18n("Split audio and video automatically"), this); + toolbar->addAction(m_buttonAutomaticSplitAudio); + m_buttonAutomaticSplitAudio->setCheckable(true); + m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio()); + connect(m_buttonAutomaticSplitAudio, SIGNAL(triggered()), this, SLOT(slotSwitchSplitAudio())); + m_buttonVideoThumbs = new KAction(KIcon("kdenlive-show-videothumb"), i18n("Show video thumbnails"), this); toolbar->addAction(m_buttonVideoThumbs); m_buttonVideoThumbs->setCheckable(true); @@ -893,6 +888,10 @@ void MainWindow::setupActions() m_buttonSnap->setChecked(KdenliveSettings::snaptopoints()); connect(m_buttonSnap, SIGNAL(triggered()), this, SLOT(slotSwitchSnap())); + actionWidget = toolbar->widgetForAction(m_buttonAutomaticSplitAudio); + actionWidget->setMaximumWidth(max); + actionWidget->setMaximumHeight(max - 4); + actionWidget = toolbar->widgetForAction(m_buttonVideoThumbs); actionWidget->setMaximumWidth(max); actionWidget->setMaximumHeight(max - 4); @@ -926,21 +925,14 @@ void MainWindow::setupActions() collection->addAction("razor_tool", m_buttonRazorTool); collection->addAction("spacer_tool", m_buttonSpacerTool); + collection->addAction("automatic_split_audio", m_buttonAutomaticSplitAudio); collection->addAction("show_video_thumbs", m_buttonVideoThumbs); collection->addAction("show_audio_thumbs", m_buttonAudioThumbs); collection->addAction("show_markers", m_buttonShowMarkers); collection->addAction("snap", m_buttonSnap); collection->addAction("zoom_fit", m_buttonFitZoom); - - KAction* zoomIn = new KAction(KIcon("zoom-in"), i18n("Zoom In"), this); - collection->addAction("zoom_in", zoomIn); - connect(zoomIn, SIGNAL(triggered(bool)), this, SLOT(slotZoomIn())); - zoomIn->setShortcut(Qt::CTRL + Qt::Key_Plus); - - KAction* zoomOut = new KAction(KIcon("zoom-out"), i18n("Zoom Out"), this); - collection->addAction("zoom_out", zoomOut); - connect(zoomOut, SIGNAL(triggered(bool)), this, SLOT(slotZoomOut())); - zoomOut->setShortcut(Qt::CTRL + Qt::Key_Minus); + collection->addAction("zoom_in", m_zoomIn); + collection->addAction("zoom_out", m_zoomOut); m_projectSearch = new KAction(KIcon("edit-find"), i18n("Find"), this); collection->addAction("project_find", m_projectSearch); @@ -957,13 +949,10 @@ void MainWindow::setupActions() collection->addAction("manage_profiles", profilesAction); connect(profilesAction, SIGNAL(triggered(bool)), this, SLOT(slotEditProfiles())); - KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas"); - - KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles"); - + KNS3::standardAction(i18n("Download New Wipes..."), this, SLOT(slotGetNewLumaStuff()), actionCollection(), "get_new_lumas"); + KNS3::standardAction(i18n("Download New Render Profiles..."), this, SLOT(slotGetNewRenderStuff()), actionCollection(), "get_new_profiles"); KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles"); - - KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles"); + KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles"); KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this); collection->addAction("run_wizard", wizAction); @@ -1113,10 +1102,10 @@ void MainWindow::setupActions() collection->addAction("monitor_seek_snap_forward", monitorSeekSnapForward); connect(monitorSeekSnapForward, SIGNAL(triggered(bool)), this, SLOT(slotSnapForward())); - KAction* deleteTimelineClip = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this); - deleteTimelineClip->setShortcut(Qt::Key_Delete); - collection->addAction("delete_timeline_clip", deleteTimelineClip); - connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip())); + KAction* deleteItem = new KAction(KIcon("edit-delete"), i18n("Delete Selected Item"), this); + deleteItem->setShortcut(Qt::Key_Delete); + collection->addAction("delete_timeline_clip", deleteItem); + connect(deleteItem, SIGNAL(triggered(bool)), this, SLOT(slotDeleteItem())); /*KAction* editTimelineClipSpeed = new KAction(i18n("Change Clip Speed"), this); collection->addAction("change_clip_speed", editTimelineClipSpeed); @@ -1141,9 +1130,17 @@ void MainWindow::setupActions() ungroupClip->setData("ungroup_clip"); connect(ungroupClip, SIGNAL(triggered(bool)), this, SLOT(slotUnGroupClips())); - KAction* editClipDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this); - collection->addAction("edit_clip_duration", editClipDuration); - connect(editClipDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditClipDuration())); + KAction* editItemDuration = new KAction(KIcon("measure"), i18n("Edit Duration"), this); + collection->addAction("edit_item_duration", editItemDuration); + connect(editItemDuration, SIGNAL(triggered(bool)), this, SLOT(slotEditItemDuration())); + + KAction* clipInProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Clip in Project Tree"), this); + collection->addAction("clip_in_project_tree", clipInProjectTree); + connect(clipInProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipInProjectTree())); + + /*KAction* clipToProjectTree = new KAction(KIcon("go-jump-definition"), i18n("Add Clip to Project Tree"), this); + collection->addAction("clip_to_project_tree", clipToProjectTree); + connect(clipToProjectTree, SIGNAL(triggered(bool)), this, SLOT(slotClipToProjectTree()));*/ KAction* insertOvertwrite = new KAction(KIcon(), i18n("Insert Clip Zone in Timeline (Overwrite)"), this); insertOvertwrite->setShortcut(Qt::Key_V); @@ -1243,9 +1240,9 @@ void MainWindow::setupActions() collection->addAction("delete_track", deleteTrack); connect(deleteTrack, SIGNAL(triggered()), this, SLOT(slotDeleteTrack())); - KAction *changeTrack = new KAction(KIcon(), i18n("Change Track"), this); - collection->addAction("change_track", changeTrack); - connect(changeTrack, SIGNAL(triggered()), this, SLOT(slotChangeTrack())); + KAction *configTracks = new KAction(KIcon("configure"), i18n("Configure Tracks"), this); + collection->addAction("config_tracks", configTracks); + connect(configTracks, SIGNAL(triggered()), this, SLOT(slotConfigTrack())); KAction *addGuide = new KAction(KIcon("document-new"), i18n("Add Guide"), this); collection->addAction("add_guide", addGuide); @@ -1287,26 +1284,19 @@ void MainWindow::setupActions() maxCurrent->setChecked(false); connect(maxCurrent, SIGNAL(triggered(bool)), this, SLOT(slotMaximizeCurrent(bool)));*/ - - m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection); - - KStandardAction::quit(this, SLOT(queryQuit()), collection); - - KStandardAction::open(this, SLOT(openFile()), collection); - - m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection); - - KStandardAction::saveAs(this, SLOT(saveFileAs()), collection); - - KStandardAction::openNew(this, SLOT(newFile()), collection); - - KStandardAction::preferences(this, SLOT(slotPreferences()), collection); - - KStandardAction::configureNotifications(this , SLOT(configureNotifications()), collection); - - KStandardAction::copy(this, SLOT(slotCopy()), collection); - - KStandardAction::paste(this, SLOT(slotPaste()), collection); + m_closeAction = KStandardAction::close(this, SLOT(closeCurrentDocument()), collection); + KStandardAction::quit(this, SLOT(queryQuit()), collection); + KStandardAction::open(this, SLOT(openFile()), collection); + m_saveAction = KStandardAction::save(this, SLOT(saveFile()), collection); + KStandardAction::saveAs(this, SLOT(saveFileAs()), collection); + KStandardAction::openNew(this, SLOT(newFile()), collection); + // TODO: make the following connection to slotEditKeys work + KStandardAction::keyBindings(this, SLOT(slotEditKeys()), collection); + KStandardAction::preferences(this, SLOT(slotPreferences()), collection); + KStandardAction::configureNotifications(this, SLOT(configureNotifications()), collection); + KStandardAction::copy(this, SLOT(slotCopy()), collection); + KStandardAction::paste(this, SLOT(slotPaste()), collection); + KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection); KAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), collection); undo->setEnabled(false); @@ -1316,8 +1306,6 @@ void MainWindow::setupActions() redo->setEnabled(false); connect(m_commandStack, SIGNAL(canRedoChanged(bool)), redo, SLOT(setEnabled(bool))); - KStandardAction::fullScreen(this, SLOT(slotFullScreen()), this, collection); - /* //TODO: Add status tooltip to actions ? connect(collection, SIGNAL(actionHovered(QAction*)), @@ -1386,6 +1374,50 @@ void MainWindow::setupActions() addClips->addAction(deleteClip); m_projectList->setupMenu(addClips, addClip); + // Setup effects and transitions actions. + m_effectsActionCollection = new KActionCollection(this, KGlobal::mainComponent()); + //KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), m_effectsActionCollection); + KActionCategory *videoEffectActions = new KActionCategory(i18n("Video Effects"), collection); + m_videoEffects = new KAction*[videoEffects.count()]; + for (int i = 0; i < videoEffects.count(); ++i) { + QStringList effectInfo = videoEffects.effectIdInfo(i); + m_videoEffects[i] = new KAction(KIcon("kdenlive-show-video"), effectInfo.at(0), this); + m_videoEffects[i]->setData(effectInfo); + m_videoEffects[i]->setIconVisibleInMenu(false); + videoEffectActions->addAction("video_effect_" + effectInfo.at(0), m_videoEffects[i]); + } + //KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), m_effectsActionCollection); + KActionCategory *audioEffectActions = new KActionCategory(i18n("Audio Effects"), collection); + m_audioEffects = new KAction*[audioEffects.count()]; + for (int i = 0; i < audioEffects.count(); ++i) { + QStringList effectInfo = audioEffects.effectIdInfo(i); + m_audioEffects[i] = new KAction(KIcon("kdenlive-show-audio"), effectInfo.at(0), this); + m_audioEffects[i]->setData(effectInfo); + m_audioEffects[i]->setIconVisibleInMenu(false); + audioEffectActions->addAction("audio_effect_" + effectInfo.at(0), m_audioEffects[i]); + } + //KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), m_effectsActionCollection); + KActionCategory *customEffectActions = new KActionCategory(i18n("Custom Effects"), collection); + m_customEffects = new KAction*[customEffects.count()]; + for (int i = 0; i < customEffects.count(); ++i) { + QStringList effectInfo = customEffects.effectIdInfo(i); + m_customEffects[i] = new KAction(KIcon("kdenlive-custom-effect"), effectInfo.at(0), this); + m_customEffects[i]->setData(effectInfo); + m_customEffects[i]->setIconVisibleInMenu(false); + customEffectActions->addAction("custom_effect_" + effectInfo.at(0), m_customEffects[i]); + } + //KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), m_effectsActionCollection); + KActionCategory *transitionActions = new KActionCategory(i18n("Transitions"), collection); + m_transitions = new KAction*[transitions.count()]; + for (int i = 0; i < transitions.count(); i++) { + QStringList effectInfo = transitions.effectIdInfo(i); + m_transitions[i] = new KAction(effectInfo.at(0), this); + m_transitions[i]->setData(effectInfo); + m_transitions[i]->setIconVisibleInMenu(false); + transitionActions->addAction("transition_" + effectInfo.at(0), m_transitions[i]); + } + m_effectsActionCollection->readSettings(); + //connect(collection, SIGNAL( clearStatusText() ), //statusBar(), SLOT( clear() ) ); } @@ -1580,15 +1612,12 @@ bool MainWindow::saveFileAs(const QString &outputFileName) bool MainWindow::saveFileAs() { - // Check that the Kdenlive mime type is correctly installed - QString mimetype = "application/x-kdenlive"; - KMimeType::Ptr mime = KMimeType::mimeType(mimetype); - if (!mime) mimetype = "*.kdenlive"; - - QString outputFile = KFileDialog::getSaveFileName(KUrl(), mimetype); + QString outputFile = KFileDialog::getSaveFileName(KUrl(), getMimeType()); if (outputFile.isEmpty()) return false; if (QFile::exists(outputFile)) { - if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) return false; + // Show the file dialog again if the user does not want to overwrite the file + if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it?")) == KMessageBox::No) + return saveFileAs(); } return saveFileAs(outputFile); } @@ -1612,12 +1641,7 @@ void MainWindow::openFile() m_startUrl = KUrl(); return; } - // Check that the Kdenlive mime type is correctly installed - QString mimetype = "application/x-kdenlive"; - KMimeType::Ptr mime = KMimeType::mimeType(mimetype); - if (!mime) mimetype = "*.kdenlive"; - - KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), mimetype); + KUrl url = KFileDialog::getOpenUrl(KUrl("kfiledialog:///projectfolder"), getMimeType()); if (url.isEmpty()) return; m_fileOpenRecent->addUrl(url); openFile(url); @@ -1728,11 +1752,8 @@ void MainWindow::recoverFiles(QList staleFiles) } } - void MainWindow::parseProfiles(const QString &mltPath) { - // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <exec() == QDialog::Rejected) { + ::exit(0); + } + KUrl rendererPath = getUrl->selectedUrl(); + delete getUrl; + if (rendererPath.isEmpty()) ::exit(0); + KdenliveSettings::setRendererpath(rendererPath.path()); + } + QStringList profilesFilter; profilesFilter << "*"; QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); - if (profilesList.isEmpty()) { // Cannot find MLT path, try finding melt QString profilePath = KdenliveSettings::rendererpath(); if (!profilePath.isEmpty()) { profilePath = profilePath.section('/', 0, -3); KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/"); - QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); + profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); } - if (profilesList.isEmpty()) { // Cannot find the MLT profiles, ask for location - KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this); + KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this); getUrl->fileDialog()->setMode(KFile::Directory); if (getUrl->exec() == QDialog::Rejected) { ::exit(0); @@ -1772,25 +1805,13 @@ void MainWindow::parseProfiles(const QString &mltPath) delete getUrl; if (mltPath.isEmpty()) ::exit(0); KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash)); - QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); + profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); } } - if (KdenliveSettings::rendererpath().isEmpty()) { - // Cannot find the MLT melt renderer, ask for location - KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this); - if (getUrl->exec() == QDialog::Rejected) { - ::exit(0); - } - KUrl rendererPath = getUrl->selectedUrl(); - delete getUrl; - if (rendererPath.isEmpty()) ::exit(0); - KdenliveSettings::setRendererpath(rendererPath.path()); - } - kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath(); - // Parse MLT profiles to build a list of available video formats + // Parse again MLT profiles to build a list of available video formats if (profilesList.isEmpty()) parseProfiles(); } @@ -1897,6 +1918,7 @@ void MainWindow::slotRenderProject() m_renderWidget->setRenderProfile(m_activeDocument->getDocumentProperty("renderdestination"), m_activeDocument->getDocumentProperty("rendercategory"), m_activeDocument->getDocumentProperty("renderprofile"), m_activeDocument->getDocumentProperty("renderurl")); } } + slotCheckRenderStatus(); /*TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); if (currentTab) m_renderWidget->setTimeline(currentTab); m_renderWidget->setDocument(m_activeDocument);*/ @@ -1904,6 +1926,12 @@ void MainWindow::slotRenderProject() m_renderWidget->showNormal(); } +void MainWindow::slotCheckRenderStatus() +{ + // Make sure there are no missing clips + if (m_renderWidget) m_renderWidget->missingClips(m_projectList->hasMissingClips()); +} + void MainWindow::setRenderingProgress(const QString &url, int progress) { if (m_renderWidget) m_renderWidget->setRenderJob(url, progress); @@ -1981,13 +2009,12 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool))); disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *))); disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay())); - disconnect(m_zoomSlider, SIGNAL(valueChanged(int)), m_activeTimeline, SLOT(slotChangeZoom(int))); disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType))); disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, const int)), m_clipMonitor, SLOT(slotSetXml(DocClipBase *, QPoint, const int))); disconnect(m_activeTimeline, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor())); disconnect(m_activeTimeline, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int))); disconnect(m_activeTimeline, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int))); - disconnect(m_activeTimeline, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int))); + disconnect(m_activeTimeline, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int))); disconnect(m_activeDocument, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool))); disconnect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), m_activeTimeline->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int))); disconnect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), m_activeTimeline->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement))); @@ -2001,6 +2028,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha disconnect(m_activeTimeline, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int))); disconnect(m_projectList, SIGNAL(loadingIsOver()), m_activeTimeline->projectView(), SLOT(slotUpdateAllThumbs())); disconnect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int))); + disconnect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus())); disconnect(m_projectList, SIGNAL(clipNeedsReload(const QString&, bool)), m_activeTimeline->projectView(), SLOT(slotUpdateClip(const QString &, bool))); m_effectStack->clear(); } @@ -2022,11 +2050,13 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha connect(m_projectList, SIGNAL(projectModified()), doc, SLOT(setModified())); connect(m_projectList, SIGNAL(clipNameChanged(const QString, const QString)), trackView->projectView(), SLOT(clipNameChanged(const QString, const QString))); + connect(m_projectList, SIGNAL(findInTimeline(const QString&)), this, SLOT(slotClipInTimeline(const QString&))); + connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor())); connect(trackView, SIGNAL(insertTrack(int)), this, SLOT(slotInsertTrack(int))); connect(trackView, SIGNAL(deleteTrack(int)), this, SLOT(slotDeleteTrack(int))); - connect(trackView, SIGNAL(changeTrack(int)), this, SLOT(slotChangeTrack(int))); + connect(trackView, SIGNAL(configTrack(int)), this, SLOT(slotConfigTrack(int))); connect(trackView, SIGNAL(updateTracksInfo()), this, SLOT(slotUpdateTrackInfo())); connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int))); connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int))); @@ -2053,7 +2083,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool))); connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *))); m_zoomSlider->setValue(doc->zoom().x()); - connect(m_zoomSlider, SIGNAL(valueChanged(int)), trackView, SLOT(slotChangeZoom(int))); connect(trackView->projectView(), SIGNAL(zoomIn()), this, SLOT(slotZoomIn())); connect(trackView->projectView(), SIGNAL(zoomOut()), this, SLOT(slotZoomOut())); connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int))); @@ -2064,6 +2093,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha connect(m_effectStack, SIGNAL(updateClipEffect(ClipItem*, QDomElement, QDomElement, int)), trackView->projectView(), SLOT(slotUpdateClipEffect(ClipItem*, QDomElement, QDomElement, int))); + connect(m_effectStack, SIGNAL(updateClipRegion(ClipItem*, int, QString)), trackView->projectView(), SLOT(slotUpdateClipRegion(ClipItem*, int, QString))); connect(m_effectStack, SIGNAL(removeEffect(ClipItem*, QDomElement)), trackView->projectView(), SLOT(slotDeleteEffect(ClipItem*, QDomElement))); connect(m_effectStack, SIGNAL(changeEffectState(ClipItem*, int, bool)), trackView->projectView(), SLOT(slotChangeEffectState(ClipItem*, int, bool))); connect(m_effectStack, SIGNAL(changeEffectPosition(ClipItem*, int, int)), trackView->projectView(), SLOT(slotChangeEffectPosition(ClipItem*, int, int))); @@ -2077,11 +2107,13 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha connect(trackView, SIGNAL(zoneMoved(int, int)), this, SLOT(slotZoneMoved(int, int))); connect(m_projectList, SIGNAL(loadingIsOver()), trackView->projectView(), SLOT(slotUpdateAllThumbs())); connect(m_projectList, SIGNAL(displayMessage(const QString&, int)), this, SLOT(slotGotProgressInfo(const QString&, int))); + connect(m_projectList, SIGNAL(updateRenderStatus()), this, SLOT(slotCheckRenderStatus())); trackView->projectView()->setContextMenu(m_timelineContextMenu, m_timelineContextClipMenu, m_timelineContextTransitionMenu, m_clipTypeGroup, (QMenu*)(factory()->container("marker_menu", this))); m_activeTimeline = trackView; if (m_renderWidget) { + slotCheckRenderStatus(); m_renderWidget->setProfile(doc->mltProfile()); m_renderWidget->setGuides(doc->guidesXml(), doc->projectDuration()); m_renderWidget->setDocumentPath(doc->projectFolder().path(KUrl::AddTrailingSlash)); @@ -2120,6 +2152,14 @@ void MainWindow::slotGuidesUpdated() if (m_renderWidget) m_renderWidget->setGuides(m_activeDocument->guidesXml(), m_activeDocument->projectDuration()); } +void MainWindow::slotEditKeys() +{ + KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this); + dialog.addCollection(actionCollection(), i18nc("general keyboard shortcuts", "General")); + dialog.addCollection(m_effectsActionCollection, i18nc("effects and transitions keyboard shortcuts", "Effects & Transitions")); + dialog.configure(); +} + void MainWindow::slotPreferences(int page, int option) { //An instance of your dialog could be already created and could be @@ -2165,6 +2205,7 @@ void MainWindow::updateConfiguration() } m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails()); m_buttonVideoThumbs->setChecked(KdenliveSettings::videothumbnails()); + m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio()); // Update list of transcoding profiles loadTranscoders(); @@ -2174,6 +2215,11 @@ void MainWindow::updateConfiguration() } +void MainWindow::slotSwitchSplitAudio() +{ + KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio()); + m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio()); +} void MainWindow::slotSwitchVideoThumbs() { @@ -2211,11 +2257,27 @@ void MainWindow::slotSwitchSnap() } -void MainWindow::slotDeleteTimelineClip() +void MainWindow::slotDeleteItem() { - if (QApplication::focusWidget() && QApplication::focusWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) m_projectList->slotRemoveClip(); - else if (m_activeTimeline) { - m_activeTimeline->projectView()->deleteSelectedClips(); + if (QApplication::focusWidget() + && QApplication::focusWidget()->parentWidget() + && QApplication::focusWidget()->parentWidget()->parentWidget() + && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) { + m_projectList->slotRemoveClip(); + + } else { + QWidget *widget = QApplication::focusWidget(); + while (widget) { + if (widget == m_effectStackDock) { + m_effectStack->slotItemDel(); + return; + } + widget = widget->parentWidget(); + } + + // effect stack has no focus + if (m_activeTimeline) + m_activeTimeline->projectView()->deleteSelectedClips(); } } @@ -2365,6 +2427,8 @@ void MainWindow::slotInsertTrack(int ix) m_projectMonitor->activateMonitor(); if (m_activeTimeline) m_activeTimeline->projectView()->slotInsertTrack(ix); + if (m_activeDocument) + m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList()); } void MainWindow::slotDeleteTrack(int ix) @@ -2372,13 +2436,17 @@ void MainWindow::slotDeleteTrack(int ix) m_projectMonitor->activateMonitor(); if (m_activeTimeline) m_activeTimeline->projectView()->slotDeleteTrack(ix); + if (m_activeDocument) + m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList()); } -void MainWindow::slotChangeTrack(int ix) +void MainWindow::slotConfigTrack(int ix) { m_projectMonitor->activateMonitor(); if (m_activeTimeline) - m_activeTimeline->projectView()->slotChangeTrack(ix); + m_activeTimeline->projectView()->slotConfigTracks(ix); + if (m_activeDocument) + m_transitionConfig->updateProjectFormat(m_activeDocument->mltProfile(), m_activeDocument->timecode(), m_activeDocument->tracksList()); } void MainWindow::slotEditGuide() @@ -2470,10 +2538,10 @@ void MainWindow::slotUnGroupClips() } } -void MainWindow::slotEditClipDuration() +void MainWindow::slotEditItemDuration() { if (m_activeTimeline) { - m_activeTimeline->projectView()->editClipDuration(); + m_activeTimeline->projectView()->editItemDuration(); } } @@ -2524,11 +2592,13 @@ void MainWindow::slotAddCustomEffect(QAction *result) void MainWindow::slotZoomIn() { m_zoomSlider->setValue(m_zoomSlider->value() - 1); + slotShowZoomSliderToolTip(); } void MainWindow::slotZoomOut() { m_zoomSlider->setValue(m_zoomSlider->value() + 1); + slotShowZoomSliderToolTip(); } void MainWindow::slotFitZoom() @@ -2540,7 +2610,32 @@ void MainWindow::slotFitZoom() void MainWindow::slotSetZoom(int value) { + if (m_activeTimeline) + m_activeTimeline->slotChangeZoom(value); + + m_zoomOut->setEnabled(value < m_zoomSlider->maximum()); + m_zoomIn->setEnabled(value > m_zoomSlider->minimum()); + slotUpdateZoomSliderToolTip(value); + + m_zoomSlider->blockSignals(true); m_zoomSlider->setValue(value); + m_zoomSlider->blockSignals(false); +} + +void MainWindow::slotShowZoomSliderToolTip(int zoomlevel) +{ + if (zoomlevel != -1) + slotUpdateZoomSliderToolTip(zoomlevel); + + QPoint global = m_zoomSlider->rect().topLeft(); + global.ry() += m_zoomSlider->height() / 2; + QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), m_zoomSlider->mapToGlobal(global)); + QApplication::sendEvent(m_zoomSlider, &toolTipEvent); +} + +void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel) +{ + m_zoomSlider->setToolTip(i18n("Zoom Level: %1/13", (13 - zoomlevel))); } void MainWindow::slotGotProgressInfo(const QString &message, int progress) @@ -2549,6 +2644,9 @@ void MainWindow::slotGotProgressInfo(const QString &message, int progress) if (progress >= 0) { if (!message.isEmpty()) m_messageLabel->setMessage(message, InformationMessage);//statusLabel->setText(message); m_statusProgressBar->setVisible(true); + } else if (progress == -2) { + if (!message.isEmpty()) m_messageLabel->setMessage(message, ErrorMessage); + m_statusProgressBar->setVisible(false); } else { m_messageLabel->setMessage(QString(), DefaultMessage); m_statusProgressBar->setVisible(false); @@ -2622,9 +2720,9 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip) if (dia_ui->exec() == QDialog::Accepted) { QMap newprops; newprops.insert("xmldata", dia_ui->xml().toString()); - if (dia_ui->duration() != clip->duration().frames(m_activeDocument->fps()) - 1) { + if (dia_ui->outPoint() != clip->duration().frames(m_activeDocument->fps()) - 1) { // duration changed, we need to update duration - newprops.insert("out", QString::number(dia_ui->duration())); + newprops.insert("out", QString::number(dia_ui->outPoint())); } EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true); m_activeDocument->commandStack()->push(command); @@ -2827,6 +2925,73 @@ void MainWindow::findTimeout() removeEventFilter(this); } +void MainWindow::slotClipInTimeline(const QString &clipId) +{ + if (m_activeTimeline && m_activeDocument) { + QList matching = m_activeTimeline->projectView()->findId(clipId); + + QMenu *inTimelineMenu = static_cast(factory()->container("clip_in_timeline", this)); + inTimelineMenu->clear(); + + QList actionList; + + for (int i = 0; i < matching.count(); ++i) { + QString track = QString::number(matching.at(i).track); + QString start = m_activeDocument->timecode().getTimecode(matching.at(i).startPos); + int j = 0; + QAction *a = new QAction(track + ": " + start, this); + a->setData(QStringList() << track << start); + connect(a, SIGNAL(triggered()), this, SLOT(slotSelectClipInTimeline())); + while (j < actionList.count()) { + if (actionList.at(j)->text() > a->text()) break; + j++; + } + actionList.insert(j, a); + } + inTimelineMenu->addActions(actionList); + + if (matching.empty()) + inTimelineMenu->setEnabled(false); + else + inTimelineMenu->setEnabled(true); + } +} + +void MainWindow::slotClipInProjectTree() +{ + if (m_activeTimeline) { + const QStringList &clipIds = m_activeTimeline->projectView()->selectedClips(); + if (clipIds.isEmpty()) return; + m_projectListDock->raise(); + for (int i = 0; i < clipIds.count(); i++) { + m_projectList->selectItemById(clipIds.at(i)); + } + if (m_projectMonitor->isActive()) + slotSwitchMonitors(); + } +} + +/*void MainWindow::slotClipToProjectTree() +{ + if (m_activeTimeline) { + const QList clips = m_activeTimeline->projectView()->selectedClipItems(); + if (clips.isEmpty()) return; + for (int i = 0; i < clips.count(); i++) { + m_projectList->slotAddXmlClip(clips.at(i)->itemXml()); + } + //m_projectList->selectItemById(clipIds.at(i)); + } +}*/ + +void MainWindow::slotSelectClipInTimeline() +{ + if (m_activeTimeline) { + QAction *action = qobject_cast(sender()); + QStringList data = action->data().toStringList(); + m_activeTimeline->projectView()->selectFound(data.at(0), data.at(1)); + } +} + void MainWindow::keyPressEvent(QKeyEvent *ke) { if (m_findActivated) { @@ -2862,12 +3027,9 @@ void MainWindow::keyPressEvent(QKeyEvent *ke) /** Gets called when the window gets hidden */ void MainWindow::hideEvent(QHideEvent */*event*/) { - // kDebug() << "I was hidden"; - // issue http://www.kdenlive.org/mantis/view.php?id=231 - if (isMinimized()) { - // kDebug() << "I am minimized"; - if (m_monitorManager) m_monitorManager->stopActiveMonitor(); - } + if (isMinimized()) + if (m_monitorManager) + m_monitorManager->stopActiveMonitor(); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) @@ -2963,9 +3125,8 @@ int MainWindow::getNewStuff(const QString &configFile) void MainWindow::slotGetNewTitleStuff() { - if (getNewStuff("kdenlive_titles.knsrc") > 0) { + if (getNewStuff("kdenlive_titles.knsrc") > 0) TitleWidget::refreshTitleTemplates(); - } } void MainWindow::slotGetNewLumaStuff() @@ -2978,10 +3139,9 @@ void MainWindow::slotGetNewLumaStuff() void MainWindow::slotGetNewRenderStuff() { - if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0) { + if (getNewStuff("kdenlive_renderprofiles.knsrc") > 0) if (m_renderWidget) m_renderWidget->reloadProfiles(); - } } void MainWindow::slotGetNewMltProfileStuff() @@ -3203,7 +3363,10 @@ void MainWindow::slotUpdateTimecodeFormat(int ix) KdenliveSettings::setFrametimecode(ix == 1); m_clipMonitor->updateTimecodeFormat(); m_projectMonitor->updateTimecodeFormat(); - m_activeTimeline->projectView()->clearSelection(); + m_transitionConfig->updateTimecodeFormat(); + m_effectStack->updateTimecodeFormat(); + //m_activeTimeline->projectView()->clearSelection(); + m_activeTimeline->updateRuler(); } void MainWindow::slotRemoveFocus() @@ -3269,6 +3432,8 @@ void MainWindow::slotChangePalette(QAction *action, const QString &themename) ((QWidget*)subchild)->setPalette(plt); } } + if (m_activeTimeline) + m_activeTimeline->projectView()->updatePalette(); } @@ -3314,7 +3479,7 @@ QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config) void MainWindow::slotSwitchMonitors() { - m_monitorManager->slotSwitchMonitors(m_clipMonitor->isActive()); + m_monitorManager->slotSwitchMonitors(!m_clipMonitor->isActive()); if (m_projectMonitor->isActive()) m_activeTimeline->projectView()->setFocus(); else m_projectList->focusTree(); } @@ -3336,12 +3501,16 @@ void MainWindow::slotInsertZoneToTimeline() void MainWindow::slotDeleteProjectClips(QStringList ids, QMap folderids) { - for (int i = 0; i < ids.size(); ++i) { - m_activeTimeline->slotDeleteClip(ids.at(i)); + if (m_activeDocument && m_activeTimeline) { + if (!ids.isEmpty()) { + for (int i = 0; i < ids.size(); ++i) { + m_activeTimeline->slotDeleteClip(ids.at(i)); + } + m_activeDocument->clipManager()->slotDeleteClips(ids); + } + if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids); + m_activeDocument->setModified(true); } - m_activeDocument->clipManager()->slotDeleteClips(ids); - if (!folderids.isEmpty()) m_projectList->deleteProjectFolder(folderids); - } void MainWindow::slotShowTitleBars(bool show) @@ -3350,7 +3519,9 @@ void MainWindow::slotShowTitleBars(bool show) m_effectStackDock->setTitleBarWidget(0); m_clipMonitorDock->setTitleBarWidget(0); m_projectMonitorDock->setTitleBarWidget(0); +#ifndef Q_WS_MAC m_recMonitorDock->setTitleBarWidget(0); +#endif m_effectListDock->setTitleBarWidget(0); m_transitionConfigDock->setTitleBarWidget(0); m_projectListDock->setTitleBarWidget(0); @@ -3359,7 +3530,9 @@ void MainWindow::slotShowTitleBars(bool show) if (!m_effectStackDock->isFloating()) m_effectStackDock->setTitleBarWidget(new QWidget(this)); if (!m_clipMonitorDock->isFloating()) m_clipMonitorDock->setTitleBarWidget(new QWidget(this)); if (!m_projectMonitorDock->isFloating()) m_projectMonitorDock->setTitleBarWidget(new QWidget(this)); +#ifndef Q_WS_MAC if (!m_recMonitorDock->isFloating()) m_recMonitorDock->setTitleBarWidget(new QWidget(this)); +#endif if (!m_effectListDock->isFloating()) m_effectListDock->setTitleBarWidget(new QWidget(this)); if (!m_transitionConfigDock->isFloating()) m_transitionConfigDock->setTitleBarWidget(new QWidget(this)); if (!m_projectListDock->isFloating()) m_projectListDock->setTitleBarWidget(new QWidget(this)); @@ -3373,5 +3546,13 @@ void MainWindow::slotSwitchTitles() slotShowTitleBars(!KdenliveSettings::showtitlebars()); } +QString MainWindow::getMimeType() +{ + QString mimetype = "application/x-kdenlive"; + KMimeType::Ptr mime = KMimeType::mimeType(mimetype); + if (!mime) mimetype = "*.kdenlive"; + return mimetype; +} + #include "mainwindow.moc"