X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=1dbdef51b7b2dbb1c34999cebaee6bc309a4683e;hb=574472e8c2d42cc2828750920c9171ef7cc9c992;hp=4bfe7c677b7b90a09d0f5e93504e707963ee04a0;hpb=3c83ad1b5407a43cee1feffa65e1ab74d61a00f2;p=kdenlive diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4bfe7c67..1dbdef51 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,7 +58,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -269,17 +271,16 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent static_cast(factory()->container("transcoders", this)), clipInTimeline); - QAction *action; + 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) { @@ -292,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); @@ -300,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) @@ -319,94 +315,49 @@ 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("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")); @@ -418,9 +369,9 @@ 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); @@ -502,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; @@ -582,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); } @@ -715,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))); @@ -770,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); @@ -861,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); @@ -899,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); @@ -932,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); @@ -963,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); @@ -1155,6 +1138,10 @@ void MainWindow::setupActions() 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); collection->addAction("overwrite_to_in_point", insertOvertwrite); @@ -1253,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); @@ -1297,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); @@ -1326,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*)), @@ -1396,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() ) ); } @@ -1590,12 +1612,7 @@ 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)) { // Show the file dialog again if the user does not want to overwrite the file @@ -1624,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); @@ -1997,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))); @@ -2045,7 +2056,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha 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))); @@ -2072,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))); @@ -2083,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))); @@ -2141,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 @@ -2186,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(); @@ -2195,6 +2215,11 @@ void MainWindow::updateConfiguration() } +void MainWindow::slotSwitchSplitAudio() +{ + KdenliveSettings::setSplitaudio(!KdenliveSettings::splitaudio()); + m_buttonAutomaticSplitAudio->setChecked(KdenliveSettings::splitaudio()); +} void MainWindow::slotSwitchVideoThumbs() { @@ -2235,22 +2260,24 @@ void MainWindow::slotSwitchSnap() void MainWindow::slotDeleteItem() { if (QApplication::focusWidget() - && QApplication::focusWidget()->parentWidget() - && QApplication::focusWidget()->parentWidget()->parentWidget() - && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) { + && QApplication::focusWidget()->parentWidget() + && QApplication::focusWidget()->parentWidget()->parentWidget() + && QApplication::focusWidget()->parentWidget()->parentWidget() == m_projectListDock) { m_projectList->slotRemoveClip(); - } else if (QApplication::focusWidget() - && QApplication::focusWidget()->parentWidget() - && QApplication::focusWidget()->parentWidget()->parentWidget() - && QApplication::focusWidget()->parentWidget()->parentWidget()->parentWidget() - && QApplication::focusWidget()->parentWidget()->parentWidget()->parentWidget()->parentWidget() - && QApplication::focusWidget()->parentWidget()->parentWidget()->parentWidget()->parentWidget() == m_effectStackDock) { - // TODO: also delete effect when an effect widget (slider, geomtryval, ...) has focus - m_effectStack->slotItemDel(); - - } else if (m_activeTimeline) { - m_activeTimeline->projectView()->deleteSelectedClips(); + } 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(); } } @@ -2413,11 +2440,13 @@ void MainWindow::slotDeleteTrack(int ix) 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() @@ -2563,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() @@ -2579,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) @@ -2891,7 +2947,6 @@ void MainWindow::slotClipInTimeline(const QString &clipId) j++; } actionList.insert(j, a); - } inTimelineMenu->addActions(actionList); @@ -2916,6 +2971,18 @@ void MainWindow::slotClipInProjectTree() } } +/*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) { @@ -3058,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() @@ -3073,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() @@ -3298,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() @@ -3364,6 +3432,8 @@ void MainWindow::slotChangePalette(QAction *action, const QString &themename) ((QWidget*)subchild)->setPalette(plt); } } + if (m_activeTimeline) + m_activeTimeline->projectView()->updatePalette(); } @@ -3431,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) @@ -3472,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"