X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=1b73b4bb7432600700e2dcdb9142316feb8f00a5;hb=94a0c37c6bc015e90d472b7d6b412e351fe6136d;hp=feb61ef41deb881d4e49c228ae2de0c39e235756;hpb=86930a8503d9ea42a4df2f58cf687d6f1d922bf6;p=kdenlive diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index feb61ef4..1b73b4bb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -69,11 +69,16 @@ MainWindow::MainWindow(QWidget *parent) m_commandStack = new QUndoGroup; m_timelineArea = new KTabWidget(this); - m_timelineArea->setHoverCloseButton(true); m_timelineArea->setTabReorderingEnabled(true); m_timelineArea->setTabBarHidden(true); + + QToolButton *closeTabButton = new QToolButton; + connect(closeTabButton, SIGNAL(clicked()), this, SLOT(slotRemoveTab())); + closeTabButton->setIcon(KIcon("tab-close")); + closeTabButton->adjustSize(); + closeTabButton->setToolTip(i18n("Close the current tab")); + m_timelineArea->setCornerWidget(closeTabButton); connect(m_timelineArea, SIGNAL(currentChanged(int)), this, SLOT(activateDocument())); - connect(m_timelineArea, SIGNAL(closeRequest(QWidget *)), this, SLOT(closeDocument(QWidget *))); initEffects::parseEffectFiles(&m_audioEffects, &m_videoEffects); @@ -161,6 +166,7 @@ MainWindow::MainWindow(QWidget *parent) timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails()); connect(timeline_buttons_ui.buttonVideo, SIGNAL(clicked()), this, SLOT(slotSwitchVideoThumbs())); connect(timeline_buttons_ui.buttonAudio, SIGNAL(clicked()), this, SLOT(slotSwitchAudioThumbs())); + connect(timeline_buttons_ui.buttonFitZoom, SIGNAL(clicked()), this, SLOT(slotFitZoom())); statusBar()->insertPermanentWidget(0, statusProgressBar, 1); statusBar()->insertPermanentWidget(1, statusLabel, 1); @@ -169,10 +175,12 @@ MainWindow::MainWindow(QWidget *parent) statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat); statusBar()->setMaximumHeight(statusBar()->font().pointSize() * 4); - timeline_buttons_ui.buttonVideo->setIcon(KIcon("display-video")); + timeline_buttons_ui.buttonVideo->setIcon(KIcon("video-mpeg")); timeline_buttons_ui.buttonVideo->setToolTip(i18n("Show video thumbnails")); - timeline_buttons_ui.buttonAudio->setIcon(KIcon("display-audio")); + timeline_buttons_ui.buttonAudio->setIcon(KIcon("audio-mpeg")); timeline_buttons_ui.buttonAudio->setToolTip(i18n("Show audio thumbnails")); + timeline_buttons_ui.buttonFitZoom->setIcon(KIcon("zoom-fit-best")); + timeline_buttons_ui.buttonFitZoom->setToolTip(i18n("Fit zoom to project")); setupGUI(Default, "kdenliveui.rc"); @@ -270,6 +278,13 @@ void MainWindow::setupActions() { actionCollection()->addAction("monitor_play", monitorPlay); connect(monitorPlay, SIGNAL(triggered(bool)), m_monitorManager, SLOT(slotPlay())); + KAction* deleteTimelineClip = new KAction(this); + deleteTimelineClip->setText(i18n("Delete Clip")); + deleteTimelineClip->setShortcut(Qt::Key_Delete); + deleteTimelineClip->setIcon(KIcon("edit-delete")); + actionCollection()->addAction("delete_timeline_clip", deleteTimelineClip); + connect(deleteTimelineClip, SIGNAL(triggered(bool)), this, SLOT(slotDeleteTimelineClip())); + KStandardAction::quit(kapp, SLOT(quit()), actionCollection()); @@ -342,7 +357,7 @@ void MainWindow::newFile() { MltVideoProfile prof = ProfilesDialog::getVideoProfile(profileName); if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal"); KdenliveDoc *doc = new KdenliveDoc(KUrl(), prof, m_commandStack); - TrackView *trackView = new TrackView(doc); + TrackView *trackView = new TrackView(doc, this); m_timelineArea->addTab(trackView, KIcon("kdenlive"), i18n("Untitled") + " / " + prof.description); if (m_timelineArea->count() == 1) connectDocument(trackView, doc); @@ -355,17 +370,16 @@ void MainWindow::activateDocument() { connectDocument(currentTab, currentDoc); } -void MainWindow::closeDocument(QWidget *w) { - if (w == m_timelineArea->currentWidget()) { - // closing current document - int ix = m_timelineArea->currentIndex() + 1; - if (ix == m_timelineArea->count()) ix = 0; - m_timelineArea->setCurrentIndex(ix); - } - +void MainWindow::slotRemoveTab() { + QWidget *w = m_timelineArea->currentWidget(); + // closing current document + int ix = m_timelineArea->currentIndex() + 1; + if (ix == m_timelineArea->count()) ix = 0; + m_timelineArea->setCurrentIndex(ix); TrackView *tabToClose = (TrackView *) w; KdenliveDoc *docToClose = tabToClose->document(); m_timelineArea->removeTab(m_timelineArea->indexOf(w)); + if (m_timelineArea->count() == 1) m_timelineArea->setTabBarHidden(true); delete docToClose; delete w; } @@ -408,7 +422,7 @@ void MainWindow::openFile(const KUrl &url) { //new MltVideoProfile prof = ProfilesDialog::getVideoProfile(KdenliveSettings::default_profile()); if (prof.width == 0) prof = ProfilesDialog::getVideoProfile("dv_pal"); KdenliveDoc *doc = new KdenliveDoc(url, prof, m_commandStack); - TrackView *trackView = new TrackView(doc); + TrackView *trackView = new TrackView(doc, this); m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, KIcon("kdenlive"), doc->description())); m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path()); if (m_timelineArea->count() > 1) m_timelineArea->setTabBarHidden(false); @@ -556,7 +570,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha m_activeDocument->backupMltPlaylist(); if (m_activeTimeline) { disconnect(m_projectMonitor, SIGNAL(renderPosition(int)), m_activeTimeline, SLOT(moveCursorPos(int))); - disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline->projectView(), SLOT(setDuration(int))); + disconnect(m_projectMonitor, SIGNAL(durationChanged(int)), m_activeTimeline, SLOT(setDuration(int))); disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *))); disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int))); disconnect(m_activeDocument, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int))); @@ -581,7 +595,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha connect(trackView, SIGNAL(cursorMoved()), m_projectMonitor, SLOT(activateMonitor())); connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int))); connect(m_projectMonitor, SIGNAL(renderPosition(int)), trackView, SLOT(moveCursorPos(int))); - connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView->projectView(), SLOT(setDuration(int))); + connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int))); connect(doc, SIGNAL(addProjectClip(DocClipBase *)), m_projectList, SLOT(slotAddClip(DocClipBase *))); connect(doc, SIGNAL(signalDeleteProjectClip(int)), m_projectList, SLOT(slotDeleteClip(int))); connect(doc, SIGNAL(updateClipDisplay(int)), m_projectList, SLOT(slotUpdateClip(int))); @@ -607,9 +621,11 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha m_monitorManager->setTimecode(doc->timecode()); doc->setRenderer(m_projectMonitor->render); m_commandStack->setActiveStack(doc->commandStack()); + if (m_commandStack->isClean()) kDebug() << "//////////// UNDO STACK IS CLEAN"; + else kDebug() << "//////////// UNDO STACK IS NOT CLEAN*******************"; m_overView->setScene(trackView->projectScene()); - m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber())); + //m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber())); //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio); setCaption(doc->description()); @@ -662,6 +678,13 @@ void MainWindow::slotSwitchAudioThumbs() { timeline_buttons_ui.buttonAudio->setDown(KdenliveSettings::audiothumbnails()); } +void MainWindow::slotDeleteTimelineClip() { + TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); + if (currentTab) { + currentTab->projectView()->deleteSelectedClips(); + } +} + void MainWindow::slotZoomIn() { timeline_buttons_ui.zoom_slider->setValue(timeline_buttons_ui.zoom_slider->value() - 1); } @@ -670,6 +693,13 @@ void MainWindow::slotZoomOut() { timeline_buttons_ui.zoom_slider->setValue(timeline_buttons_ui.zoom_slider->value() + 1); } +void MainWindow::slotFitZoom() { + TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget(); + if (currentTab) { + timeline_buttons_ui.zoom_slider->setValue(currentTab->fitZoom()); + } +} + void MainWindow::slotGotProgressInfo(KUrl url, int progress) { statusProgressBar->setValue(progress); if (progress > 0) {