~ubuntu-branches/ubuntu/hardy/kdenlive/hardy

« back to all changes in this revision

Viewing changes to kdenlive/kdenlive.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Albin Tonnerre
  • Date: 2008-01-30 17:07:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130170751-lyc8p6xvd7o98ur5
Tags: 0.5.svn20071228-0.0ubuntu1
* Merge from debian-multimedia (LP: #150453). Remaining changes:
  - Bump compat to 5
  - Suggest dvgrab and ffmpeg (needed for firewire capture)
  - debian/{rules,control}: add a kdenlive-data package
  - Add .install files for kdenlive and kdenlive-data
  - debian/copyright: add some copyright information
  - Modify Maintainer value to match the DebianMaintainerField specification

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
#include <kinputdialog.h>
58
58
#include <kpassivepopup.h>
59
59
#include <kprogress.h>
 
60
#include <kpopupmenu.h>
60
61
 
61
62
// application specific includes
62
63
// p.s., get the idea this class is kind, central to everything?
63
64
#include "capturemonitor.h"
64
65
#include "clipdrag.h"
65
 
#include "clippropertiesdialog.h"
66
66
#include "configureprojectdialog.h"
67
67
#include "docclipbase.h"
68
68
#include "docclipavfile.h"
73
73
#include "effectlistdialog.h"
74
74
#include "effectparamdialog.h"
75
75
#include "effectstackdialog.h"
76
 
#include "clippropertiesdialog.h"
77
76
#include "kaddclipcommand.h"
78
77
#include "kaddeffectcommand.h"
79
78
#include "kaddavfilecommand.h"
109
108
#include "keditmarkercommand.h"
110
109
#include "docclipvirtual.h"
111
110
#include "firstrun_ui.h"
 
111
#include "printproperties.h"
 
112
#include "playlist.h"
 
113
#include "saveprojectnativefilter.h"
112
114
 
113
115
#include "trackpanelclipmovefunction.h"
114
116
#include "trackpanelrazorfunction.h"
127
129
#define ID_EDITMODE_MSG 2
128
130
#define ID_TIMELINE_MSG 3
129
131
 
 
132
 
130
133
namespace Gui {
131
134
 
132
135
    KdenliveApp::KdenliveApp(bool newDoc, QWidget *parent,
133
136
        const char *name):KDockMainWindow(parent, name), m_monitorManager(this),
134
 
    m_workspaceMonitor(NULL), m_clipMonitor(NULL), m_captureMonitor(NULL), m_exportWidget(NULL), m_renderManager(NULL), m_doc(NULL), m_selectedFile(NULL), m_copiedClip(NULL), m_projectList(NULL), m_effectStackDialog(NULL), m_effectListDialog(NULL), m_projectFormat("dv_pal"), m_timelinePopupMenu(NULL), m_rulerPopupMenu(NULL), m_exportDvd(NULL), m_transitionPanel(NULL), m_resizeFunction(NULL), m_moveFunction(NULL), m_rollFunction(NULL), m_markerFunction(NULL),m_newLumaDialog(NULL), m_externalMonitor(0) {
 
137
    m_workspaceMonitor(NULL), m_clipMonitor(NULL), m_captureMonitor(NULL), m_exportWidget(NULL), m_renderManager(NULL), m_doc(NULL), m_selectedFile(NULL), m_copiedClip(NULL), m_projectList(NULL), m_effectStackDialog(NULL), m_effectListDialog(NULL), m_projectFormat("dv_pal"), m_timelinePopupMenu(NULL), m_rulerPopupMenu(NULL), m_exportDvd(NULL), m_transitionPanel(NULL), m_resizeFunction(NULL), m_moveFunction(NULL), m_rollFunction(NULL), m_markerFunction(NULL),m_newLumaDialog(NULL), m_externalMonitor(0), m_debugDialog(NULL) {
135
138
 
136
139
        parseProfiles();
137
140
        config = kapp->config();
175
178
        int videoTracks = KdenliveSettings::videotracks();
176
179
        QString newProjectName;
177
180
        KdenliveSettings::setMultitrackview(false);
178
 
 
179
 
        if (!KdenliveSettings::openlast() && !KdenliveSettings::openblank() && !newDoc) {
 
181
        bool crashRecovery = false;
 
182
        m_recoveryFile = KGlobal::dirs()->saveLocation("appdata") + "recovery.kdenlive" ;
 
183
 
 
184
        QFile backup(m_recoveryFile);
 
185
        if (backup.exists()) {
 
186
            if (KMessageBox::questionYesNo(this, i18n("It seems like Kdenlive did not close properly during the previous session.\nDo you want to recover the project file?")) == KMessageBox::Yes) {
 
187
                crashRecovery = true;
 
188
            }
 
189
        }
 
190
 
 
191
        config->setGroup("RecentFiles");
 
192
        QString Lastproject = config->readPathEntry("File1");
 
193
 
 
194
        if (!crashRecovery && !KdenliveSettings::openlast() && !KdenliveSettings::openblank() && !newDoc) {
180
195
                slotNewProject(&newProjectName, &m_selectedFile, &videoTracks, &audioTracks, false, true);
181
196
        }
182
 
        else if (KdenliveSettings::openblank() && !newDoc) {
 
197
        else if (!crashRecovery && (KdenliveSettings::openblank() || (KdenliveSettings::openlast() && Lastproject.isEmpty())) && !newDoc) {
183
198
                slotNewProject(&newProjectName, &m_selectedFile, &videoTracks, &audioTracks, true, true);
184
199
        }
185
200
 
198
213
 
199
214
        // call inits to invoke all other construction parts
200
215
        m_commandHistory = new KCommandHistory(actionCollection(), true);
 
216
   
201
217
        initActions();
202
218
 
203
219
        m_effectList.setAutoDelete(true);
204
220
 
205
 
        initEffects::initializeEffects( &m_effectList );
 
221
        initEffects::parseEffectFiles( &m_effectList );
206
222
 
207
 
        // init transitions & effects menu
208
 
        transitionsMenu = ((QPopupMenu *) factory()->container("add_transition_menu", this));
 
223
        // init dynamic transitions & effects menu
 
224
        transitionsMenu = new QPopupMenu;
209
225
        transitionsMenu->insertItem(i18n("Crossfade"));
210
226
        transitionsMenu->insertItem(i18n("Push"));
211
227
        transitionsMenu->insertItem(i18n("Pip"));
212
228
        transitionsMenu->insertItem(i18n("Wipe"));
213
229
        connect(transitionsMenu, SIGNAL(activated(int)), this, SLOT(slotAddTransition(int)));
214
230
 
215
 
        audioEffectsMenu = ((QPopupMenu *) factory()->container("audio_effect", this));
216
 
        videoEffectsMenu = ((QPopupMenu *) factory()->container("video_effect", this));
217
 
        removeEffectsMenu = ((QPopupMenu *) factory()->container("remove_effect", this));
 
231
        audioEffectsMenu = new QPopupMenu;
 
232
        videoEffectsMenu = new QPopupMenu;
 
233
        removeEffectsMenu = new QPopupMenu;
 
234
 
 
235
        QPopupMenu * menu = ((QPopupMenu *) factory()->container("timeline_clip_context", this));
 
236
        menu->insertItem(i18n("Add Transition"), transitionsMenu, -1, 0);
 
237
        menu->insertItem(i18n("Add Video Effect"), videoEffectsMenu, -1, 3);
 
238
        menu->insertItem(i18n("Add Audio Effect"), audioEffectsMenu, -1, 4);
 
239
        menu->insertItem(i18n("Delete Effect"), removeEffectsMenu, -1, 5);
 
240
 
 
241
        menu = ((QPopupMenu *) factory()->container("timeline_playlist_context", this));
 
242
        menu->insertItem(i18n("Add Transition"), transitionsMenu, -1, 0);
 
243
        menu->insertItem(i18n("Add Video Effect"), videoEffectsMenu, -1, 3);
 
244
        menu->insertItem(i18n("Add Audio Effect"), audioEffectsMenu, -1, 4);
 
245
        menu->insertItem(i18n("Delete Effect"), removeEffectsMenu, -1, 5);
 
246
 
218
247
        QPtrListIterator < EffectDesc > itt(m_effectList);
219
248
        QStringList videoEffectsList;
220
249
        QStringList audioEffectsList;
251
280
        if (KdenliveSettings::autosave())
252
281
            m_autoSaveTimer->start(KdenliveSettings::autosavetime() * 60000, false);
253
282
        // Reopen last project if user asked it
254
 
        if (KdenliveSettings::openlast()) openLastFile();
 
283
        if (crashRecovery) {
 
284
            openDocumentFile(m_recoveryFile);
 
285
            setCaption(i18n("Untitled") + ".kdenlive" + " - " + projectFormatName(m_projectFormat), false);
 
286
            m_doc->setProjectName( i18n("Untitled") + ".kdenlive");
 
287
        }
 
288
        else if (KdenliveSettings::openlast() && !Lastproject.isEmpty()) openDocumentFile(KURL(Lastproject));
255
289
        else if (!m_selectedFile.isEmpty()) openSelectedFile();
256
 
        else if (!newDoc || KdenliveSettings::openblank()) {
 
290
        else {
257
291
            initView();
258
292
            setCaption(newProjectName + ".kdenlive" + " - " + projectFormatName(m_projectFormat), false);
259
293
            m_doc->setProjectName( newProjectName + ".kdenlive");
263
297
        if (KdenliveSettings::showsplash()) QTimer::singleShot(500, this, SLOT(slotSplashTimeout()));
264
298
        connect(manager(), SIGNAL(change()), this, SLOT(slotUpdateLayoutState()));
265
299
        setAutoSaveSettings();
 
300
 
 
301
        m_crashTimer = new QTimer( this );
 
302
        connect( m_crashTimer, SIGNAL(timeout()), this, SLOT(crashPrevent()) );
 
303
        m_crashTimer->start(20000);
266
304
    }
267
305
 
268
306
 
272
310
        if (KdenliveSettings::mltpath().isEmpty()) {
273
311
            KdenliveSettings::setMltpath(MLT_PREFIX);
274
312
        }
275
 
 
276
313
        QString profilePath = KdenliveSettings::mltpath() + "/share/mlt/profiles/";
277
314
        QStringList profilesList = QDir(profilePath).entryList("*", QDir::Files);
278
315
 
369
406
    
370
407
    KdenliveApp::~KdenliveApp() {
371
408
        KdenliveSettings::writeConfig();
 
409
        QFile backup(m_recoveryFile);
 
410
        backup.remove();
 
411
        if (m_crashTimer) delete m_crashTimer;
372
412
        if (m_statusBarTimer) delete m_statusBarTimer;
373
413
        if (splash) delete splash;
374
414
        if (m_renderManager) delete m_renderManager;
390
430
        if (m_dockTransition) delete m_dockTransition;
391
431
        if (m_commandHistory) delete m_commandHistory;
392
432
    }
 
433
 
 
434
 
 
435
    void KdenliveApp::crashPrevent()
 
436
    {
 
437
        if (m_doc->backupModified()) {
 
438
            m_projectFormatManager.backupDocument(KURL(m_recoveryFile), m_doc);
 
439
            kdDebug()<<"/ / / / / SAVING RECOVERY FILE"<<endl;
 
440
            m_doc->setBackupModified(false);
 
441
        }
 
442
        
 
443
    }
 
444
 
393
445
    
394
446
    const EffectDescriptionList & KdenliveApp::effectList() const
395
447
    {
396
448
        return m_effectList;
397
449
    }
398
450
 
399
 
    void KdenliveApp::slotAddEffect(const QString & effectName)
 
451
    void KdenliveApp::slotAddEffect(const QString & effectName, const QString &groupName)
400
452
    {
401
453
        DocClipRefList list = getDocument()->projectClip().selectedClipList();
402
454
        QString effectId = getDocument()->getEffectStringId(effectName);
403
455
        if (list.isEmpty() || !effectList().effectDescription(effectId)) return;
404
456
        Effect *effect = effectList().effectDescription(effectId)->createEffect();
 
457
        if (!groupName.isEmpty()) effect->setGroup(groupName);
405
458
        KMacroCommand *macroCommand = new KMacroCommand(i18n("Add Effect"));
406
459
        DocClipRef *refClip;
407
460
 
408
461
        for (refClip = list.first(); refClip; refClip = list.next()) {
409
 
                macroCommand->addCommand(Command::KAddEffectCommand::insertEffect(getDocument(), refClip, refClip->numEffects(), effect));      
 
462
                macroCommand->addCommand(Command::KAddEffectCommand::insertEffect(getDocument(), refClip, refClip->numEffects(), effect));
410
463
        }
411
464
        addCommand(macroCommand, true);
412
465
 
454
507
        openDocumentFile(m_selectedFile);
455
508
    }
456
509
 
457
 
    void KdenliveApp::openLastFile()
458
 
    {
459
 
        config->setGroup("RecentFiles");
460
 
        QString Lastproject = config->readPathEntry("File1");
461
 
        if (!Lastproject.isEmpty())
462
 
            openDocumentFile(KURL(Lastproject));
463
 
    }
464
 
 
465
510
    void KdenliveApp::initActions() {
466
511
 
467
512
        setStandardToolBarMenuEnabled(true);
489
534
            KStdAction::saveAs(this, SLOT(slotFileSaveAs()),
490
535
            actionCollection());
491
536
        //fileClose = KStdAction::close(this, SLOT(slotFileClose()), actionCollection());
492
 
        //  filePrint = KStdAction::print(this, SLOT(slotFilePrint()), actionCollection());
 
537
 
 
538
        KStdAction::print(this, SLOT(slotPrint()), actionCollection());
 
539
 
493
540
        fileQuit =
494
541
            KStdAction::quit(this, SLOT(slotFileQuit()),
495
542
            actionCollection());
628
675
 
629
676
        showAllMarkers->setChecked(KdenliveSettings::showallmarkers());
630
677
 
 
678
        KAction *syncTimeline = new KAction(i18n("Sync Timeline"), "reload", 0, this, SLOT(forceTimelineRefresh()), actionCollection(), "sync_timeline");
 
679
 
 
680
        /*KAction *syncDiskTimeline = new KAction(i18n("Sync Disk Timeline"), "reload", 0, this, SLOT(forceDiskTimelineRefresh()), actionCollection(), "sync_disk_timeline");*/
 
681
 
631
682
        KAction *defineThumb = new KAction(i18n("Define Clip Thumbnail"), 0, this, SLOT(slotDefineClipThumb()), actionCollection(), "define_thumb");
632
683
        defineThumb->setToolTip(i18n("Define thumbnail for the current clip"));
633
684
 
673
724
        projectClean =
674
725
            new KAction(i18n("Clean Project"), "cleanproject.png", 0, this,
675
726
            SLOT(slotProjectClean()), actionCollection(), "project_clean");
 
727
 
 
728
        projectFixPlaylist =
 
729
            new KAction(i18n("Fix Playlist Clips"), "cleanproject.png", 0, this,
 
730
            SLOT(slotFixPlaylists()), actionCollection(), "fix_playlists");
 
731
 
676
732
/*      projectClipProperties =
677
733
            new KAction(i18n("Clip properties"), "clipproperties.png", 0,
678
734
            this, SLOT(slotProjectClipProperties()), actionCollection(),
737
793
            SLOT(slotProjectExtractAudio()), actionCollection(), "project_extract_audio");
738
794
        projectExtractAudio->setToolTip(i18n("Extract Audio From Clip"));
739
795
 
 
796
        KAction *projectImportCueSheet = new KAction(i18n("Import Cue Sheet"), 0, this,
 
797
            SLOT(slotProjectImportCue()), actionCollection(), "project_attach_cue");
 
798
        projectImportCueSheet->setToolTip(i18n("Import Markers From Cue Sheet"));
 
799
 
 
800
        KAction *projectDeleteMarkers = new KAction(i18n("Delete Markers"), 0, this,
 
801
            SLOT(slotProjectDeleteClipMarkers()), actionCollection(), "project_delete_markers");
 
802
        projectImportCueSheet->setToolTip(i18n("Delete Clip Markers"));
 
803
 
 
804
 
 
805
 
740
806
        actionNextFrame =
741
807
            new KAction(i18n("Forward one frame"),
742
808
            KShortcut(Qt::Key_Right), this, SLOT(slotNextFrame()),
894
960
        "save_subclip");
895
961
        saveSubClip->setToolTip(i18n("Save selected clip as playlist for future use"));
896
962
 
 
963
        KAction *explodePlaylist = new KAction(i18n("Explode Playlist"), 0, this,
 
964
        SLOT(slotExplodePlaylist()), actionCollection(),
 
965
        "explode_playlist");
 
966
        explodePlaylist->setToolTip(i18n("Explode playlist in several clips"));
 
967
 
897
968
 
898
969
        KAction *renderZone = new KAction(i18n("Render Selected Zone"), 0, this,
899
970
        SLOT(slotRenderZone()), actionCollection(),
1176
1247
        m_statusBarTimer = new QTimer(this);
1177
1248
        connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(slotStatusMsg()));
1178
1249
 
 
1250
        statusBar()->insertItem(i18n("Move/Resize mode"), ID_EDITMODE_MSG,
 
1251
            0, true);
 
1252
        statusBar()->insertItem(QString::null, ID_TIMELINE_MSG,
 
1253
            0, true);
 
1254
 
1179
1255
        // Stop export button
1180
1256
        KIconLoader loader;
1181
1257
        QIconSet eff;
1202
1278
        effectsButton->setToggleButton(true);
1203
1279
        effectsButton->setFlat(true);
1204
1280
        effectsButton->setMaximumSize(QSize(18, 18));
1205
 
        statusBar()->addWidget(effectsButton);
 
1281
        statusBar()->addWidget(effectsButton, 0, true);
1206
1282
 
1207
1283
        eff.setPixmap(loader.loadIcon("kdenlive_transitions", KIcon::Small, 16), QIconSet::Small, QIconSet::Normal, QIconSet::Off);
1208
1284
        eff.setPixmap(loader.loadIcon("kdenlive_transitionsoff", KIcon::Small, 16), QIconSet::Small, QIconSet::Normal, QIconSet::On);
1212
1288
        transitionsButton->setToggleButton(true);
1213
1289
        transitionsButton->setFlat(true);
1214
1290
        transitionsButton->setMaximumSize(QSize(18, 18));
1215
 
        statusBar()->addWidget(transitionsButton);
 
1291
        statusBar()->addWidget(transitionsButton, 0, true);
1216
1292
 
1217
1293
        eff.setPixmap(loader.loadIcon("kdenlive_thumbs", KIcon::Small, 16), QIconSet::Small, QIconSet::Normal, QIconSet::Off);
1218
1294
        eff.setPixmap(loader.loadIcon("kdenlive_thumbsoff", KIcon::Small, 16), QIconSet::Small, QIconSet::Normal, QIconSet::On);
1223
1299
        thumbsButton->setFlat(true);
1224
1300
        thumbsButton->setOn(!KdenliveSettings::videothumbnails());
1225
1301
        thumbsButton->setMaximumSize(QSize(18, 18));
1226
 
        statusBar()->addWidget(thumbsButton);
 
1302
        statusBar()->addWidget(thumbsButton, 0, true);
1227
1303
 
1228
1304
        eff.setPixmap(loader.loadIcon("kdenlive_audiothumbs", KIcon::Small, 16), QIconSet::Small, QIconSet::Normal, QIconSet::Off);
1229
1305
        eff.setPixmap(loader.loadIcon("kdenlive_audiothumbsoff", KIcon::Small, 16), QIconSet::Small, QIconSet::Normal, QIconSet::On);
1234
1310
        audioThumbsButton->setFlat(true);
1235
1311
        audioThumbsButton->setOn(!KdenliveSettings::audiothumbnails());
1236
1312
        audioThumbsButton->setMaximumSize(QSize(18, 18));
1237
 
        statusBar()->addWidget(audioThumbsButton);
 
1313
        statusBar()->addWidget(audioThumbsButton, 0, true);
1238
1314
 
1239
1315
        KdenliveSettings::setShoweffects(true);
1240
1316
        KdenliveSettings::setShowtransitions(true);
1241
1317
 
1242
 
        statusBar()->insertItem(i18n("Move/Resize mode"), ID_EDITMODE_MSG,
1243
 
            0, true);
1244
 
        statusBar()->insertItem(QString::null, ID_TIMELINE_MSG,
1245
 
            0, true);
1246
1318
    }
1247
1319
 
1248
1320
    void KdenliveApp::slotStopExport() {
1251
1323
 
1252
1324
    void KdenliveApp::initDocument(int vtracks, int atracks) {
1253
1325
        if (m_doc) delete m_doc;
 
1326
    kdDebug()<<"---------  close 1b"<<endl;
1254
1327
        renderManager()->resetRenderers();
 
1328
    kdDebug()<<"---------  close 2b"<<endl;
1255
1329
        m_doc = new KdenliveDoc(KdenliveSettings::defaultfps(), KdenliveSettings::defaultwidth(), KdenliveSettings::defaultheight(), this, this);
1256
1330
        m_doc->newDocument(vtracks, atracks);
 
1331
    kdDebug()<<"---------  close 3b"<<endl;
1257
1332
        connect(m_doc, SIGNAL(modified(bool)), this, SLOT(documentModified(bool)));
1258
1333
    }
1259
1334
 
1330
1405
        m_dockEffectStack->manualDock(m_dockProjectList, KDockWidget::DockCenter);
1331
1406
        m_dockEffectStack->setToolTipString(i18n("Effect Stack"));
1332
1407
 
 
1408
/*      m_dockDebug = createDockWidget("Debug", QPixmap(), 0, i18n("Debug"));
 
1409
        m_dockDebug->setDockSite(KDockWidget::DockFullSite);
 
1410
        m_dockDebug->manualDock(m_dockProjectList, KDockWidget::DockCenter);
 
1411
        m_dockDebug->setToolTipString(i18n("Debug"));*/
 
1412
 
 
1413
 
1333
1414
        m_dockWorkspaceMonitor = createDockWidget("Workspace Monitor", QPixmap(), 0, i18n("Timeline Monitor"));
1334
1415
 
1335
1416
        m_dockWorkspaceMonitor->setDockSite(KDockWidget::DockFullSite);
1363
1444
            connect(m_workspaceMonitor, SIGNAL(activatedSlider(int)), m_timeline,SLOT(slotActivateSlider(int)));
1364
1445
            connect(m_workspaceMonitor,SIGNAL(outpointPositionChanged(const GenTime &)), m_timeline, SLOT(setOutpointTimeline(const GenTime &)));
1365
1446
            connect(getDocument(), SIGNAL(documentChanged(DocClipBase *)), m_workspaceMonitor, SLOT(slotSetClip(DocClipBase *)));
 
1447
            connect(getDocument(), SIGNAL(updateMonitorPlaytime()), m_workspaceMonitor, SLOT(slotCheckLength()));
1366
1448
        }
1367
1449
 
1368
1450
        connect(m_resizeFunction,
1404
1486
 
1405
1487
        m_dockProjectList->update();
1406
1488
 
 
1489
        /*if (m_debugDialog) delete m_debugDialog;
 
1490
        m_debugDialog =
 
1491
            new KTextEdit();
 
1492
        m_debugDialog->setReadOnly(true);
 
1493
        m_dockDebug->setWidget(m_debugDialog);
 
1494
        m_debugDialog->show();
 
1495
        m_dockDebug->update();*/
 
1496
 
1407
1497
        if (m_effectListDialog) delete m_effectListDialog;
1408
1498
        m_effectListDialog =
1409
1499
            new EffectListDialog(effectList(), m_timelineWidget, "effect list");
1410
1500
        m_dockEffectList->setWidget(m_effectListDialog);
1411
1501
        m_effectListDialog->show();
1412
1502
        m_dockEffectList->update();
 
1503
 
1413
1504
        if (m_effectStackDialog) delete m_effectStackDialog;
1414
1505
        m_effectStackDialog =
1415
1506
            new EffectStackDialog(this, getDocument(), m_dockEffectStack,
1451
1542
        connect(m_effectStackDialog, SIGNAL(generateSceneList()),
1452
1543
            getDocument(), SLOT(hasBeenModified()));
1453
1544
 
1454
 
        connect(m_effectListDialog, SIGNAL(effectSelected(const QString &)), this,
1455
 
        SLOT(slotAddEffect(const QString &)));
 
1545
        connect(m_effectListDialog, SIGNAL(effectSelected(const QString &, const QString &)), this,
 
1546
        SLOT(slotAddEffect(const QString &, const QString &)));
 
1547
 
 
1548
        connect(m_effectListDialog, SIGNAL(refreshEffects()), this,
 
1549
        SLOT(refreshEffects()));
1456
1550
 
1457
1551
        connect(m_effectStackDialog, SIGNAL(redrawTrack(int, GenTime, GenTime)), m_timeline,
1458
1552
            SLOT(drawPartialTrack(int, GenTime, GenTime)));
1476
1570
            m_projectList, SLOT(slot_nodeDeleted(DocumentBaseNode *)));
1477
1571
 
1478
1572
        connect(getDocument()->renderer(),
1479
 
            SIGNAL(effectListChanged(const QPtrList < EffectDesc > &)),
1480
 
            m_effectListDialog,
1481
 
            SLOT(setEffectList(const QPtrList < EffectDesc > &)));
1482
 
 
1483
 
        connect(getDocument()->renderer(),
1484
1573
            SIGNAL(rendering(const GenTime &)), this,
1485
1574
            SLOT(slotSetRenderProgress(const GenTime &)));
1486
1575
        connect(getDocument()->renderer(), SIGNAL(renderFinished()), this,
1499
1588
        connect(m_projectList, SIGNAL(clipSelected(DocClipRef *)), this,
1500
1589
            SLOT(slotSetClipMonitorSource(DocClipRef *)));
1501
1590
 
 
1591
        connect(m_projectList, SIGNAL(playlistItemSelected(QDomDocument, GenTime)), this,
 
1592
            SLOT(slotSetClipMonitorSource(QDomDocument, GenTime)));
 
1593
 
1502
1594
        connect(m_projectList, SIGNAL(dragDropOccured(QDropEvent *, QListViewItem *)), this,
1503
1595
            SLOT(slot_insertClips(QDropEvent *, QListViewItem *)));
1504
1596
        
1558
1650
        connect(m_transitionPanel, SIGNAL(transitionChanged(bool)),
1559
1651
                getDocument(), SLOT(activateSceneListGeneration(bool)));
1560
1652
 
1561
 
        connect(keyFrameFunction, SIGNAL(signalKeyFrameChanged(bool)),
1562
 
            getDocument(), SLOT(activateSceneListGeneration(bool)));
 
1653
        connect(m_transitionPanel, SIGNAL(redrawTransition(int, GenTime, GenTime)), m_timeline,
 
1654
            SLOT(drawPartialTrack(int, GenTime, GenTime)));
 
1655
 
 
1656
        connect(m_transitionPanel, SIGNAL(adjustCursorPosition(const GenTime)), this,
 
1657
            SLOT(setCursorPosition(const GenTime)));
 
1658
 
 
1659
 
 
1660
        connect(m_transitionPanel, SIGNAL(resizeTransition(const QString &)),
 
1661
                getDocument(), SLOT(slotResizeClipTransition(const QString &)));
 
1662
 
 
1663
        /*connect(keyFrameFunction, SIGNAL(signalKeyFrameChanged(bool)),
 
1664
            getDocument(), SLOT(activateSceneListGeneration(bool)));*/
1563
1665
        
1564
1666
        connect(transitionMoveFunction, SIGNAL(transitionChanged(bool)),
1565
1667
                getDocument(), SLOT(activateSceneListGeneration(bool)));
1570
1672
        connect(transitionResizeFunction, SIGNAL(transitionChanged(bool)),
1571
1673
                getDocument(), SLOT(activateSceneListGeneration(bool)));
1572
1674
 
 
1675
        connect(transitionResizeFunction, SIGNAL(signalTransitionDurationChanged(Transition *)),
 
1676
                this, SLOT(slotCheckTransitionDuration(Transition *)));
 
1677
 
1573
1678
        connect(keyFrameFunction, SIGNAL(redrawTrack()),
1574
1679
            m_effectStackDialog, SLOT(updateKeyFrames()));
1575
1680
 
1765
1870
 
1766
1871
    void KdenliveApp::slotEditTransition(Transition *transition) {
1767
1872
        m_dockTransition->makeDockVisible();
1768
 
        m_transitionPanel->setTransition(transition);
 
1873
        m_transitionPanel->setTransition(transition, getDocument());
1769
1874
        m_timeline->drawTrackViewBackBuffer();
1770
1875
    }
1771
1876
 
 
1877
    void KdenliveApp::slotCheckTransitionDuration(Transition *transition) {
 
1878
        if (transition && m_transitionPanel->isActiveTransition(transition)) {
 
1879
            QString currentDuration = getDocument()->timeCode().getTimecode(transition->transitionDuration(), KdenliveSettings::defaultfps());
 
1880
            m_transitionPanel->setDuration(currentDuration);
 
1881
        }
 
1882
    }
 
1883
 
1772
1884
    void KdenliveApp::slotCheckTransition(DocClipRef *clip) {
1773
1885
        if (!m_transitionPanel->checkTransition(clip))
1774
1886
            m_timeline->drawTrackViewBackBuffer();
1791
1903
        m_dockEffectList->changeHideShowState();
1792
1904
    }
1793
1905
 
 
1906
    void KdenliveApp::refreshEffects() {
 
1907
        m_effectList.clear();
 
1908
        initEffects::parseEffectFiles( &m_effectList );
 
1909
        m_effectListDialog->setEffectList(m_effectList);
 
1910
    }
 
1911
 
1794
1912
    void KdenliveApp::slotToggleEffectStack() {
1795
1913
        m_dockEffectStack->changeHideShowState();
1796
1914
    }
1825
1943
 
1826
1944
    void KdenliveApp::slotFocusEffectStack() {
1827
1945
        m_dockEffectStack->makeDockVisible();
1828
 
        m_effectStackDialog->m_effectList->setFocus();
 
1946
        m_effectStackDialog->setFocus();
1829
1947
    }
1830
1948
 
1831
1949
    void KdenliveApp::slotFocusProjectList() {
1896
2014
            QTime t;
1897
2015
            t.start();
1898
2016
            m_projectFormatManager.openDocument(url, m_doc);
1899
 
            if (!m_exportWidget) slotRenderExportTimeline(false);
 
2017
            initRenderExport();
1900
2018
            m_exportWidget->setMetaData(getDocument()->metadata());
1901
2019
            documentModified(false);
1902
 
            fileOpenRecent->addURL(m_doc->URL());
1903
 
            if (m_exportWidget) m_exportWidget->resetValues();
 
2020
            if (m_doc->URL() != KURL(m_recoveryFile)) fileOpenRecent->addURL(m_doc->URL());
 
2021
            m_transitionPanel->refreshTracks(getDocument()->trackList().count());
1904
2022
            kdDebug()<<" + + +  Loading Time : "<<t.elapsed()<<"ms"<<endl;
1905
2023
        }
1906
2024
        else {
2124
2242
                KdenliveSettings::setRenderratio(it.data().aspect());
2125
2243
                KdenliveSettings::setCorrectionratio((double)it.data().width() * it.data().aspect() / it.data().height() / it.data().display());
2126
2244
                KdenliveSettings::setDisplaywidth(it.data().height() * it.data().display() + 0.5);
2127
 
                KdenliveSettings::setDisplaywidth(it.data().height() * it.data().display() + 0.5);
2128
2245
                profileName = it.key();
2129
2246
                break;
2130
2247
            }
2270
2387
 
2271
2388
    void KdenliveApp::initMonitors() {
2272
2389
        activateClipMonitor();
2273
 
        if (m_clipMonitor) m_clipMonitor->screen()->play(1.0);
 
2390
        //if (m_clipMonitor) m_clipMonitor->screen()->play(1.0);
2274
2391
        activateWorkspaceMonitor();
2275
 
        if (m_workspaceMonitor) m_workspaceMonitor->screen()->play(1.0);
 
2392
        //if (m_workspaceMonitor) m_workspaceMonitor->screen()->play(1.0);
2276
2393
        }
2277
2394
 
2278
2395
 
2418
2535
            KMessageBox::sorry(this, i18n("No clip in clipboard"));
2419
2536
            return;
2420
2537
        }
 
2538
 
 
2539
        DocClipRefList list = getDocument()->projectClip().selectedClipList();
 
2540
        if (list.isEmpty()) return;
 
2541
        DocClipRef *refClip;
 
2542
 
2421
2543
        DocClipRef *clipUnderMouse = getDocument()->projectClip().selectedClip();
2422
2544
        if (!clipUnderMouse) return;
2423
2545
        slotStatusMsg(i18n("Pasting clip %1 effects.").arg(m_copiedClip->name()));
2424
2546
        EffectStack effectStack = m_copiedClip->effectStack();
2425
2547
        KMacroCommand *macroCommand = new KMacroCommand(i18n("Copy Effects"));
2426
2548
 
2427
 
        EffectStack::iterator itt = effectStack.begin();
2428
 
        while (itt != effectStack.end()) {
2429
 
                macroCommand->addCommand(Command::KAddEffectCommand::insertEffect(getDocument(), clipUnderMouse, clipUnderMouse->numEffects(), *itt));  
2430
 
            ++itt;
 
2549
        for (refClip = list.first(); refClip; refClip = list.next()) {
 
2550
            EffectStack::iterator itt = effectStack.begin();
 
2551
            while (itt != effectStack.end()) {
 
2552
                macroCommand->addCommand(Command::KAddEffectCommand::insertEffect(getDocument(), refClip, refClip->numEffects(), *itt));        
 
2553
                ++itt;
 
2554
            }
2431
2555
        }
2432
2556
        addCommand(macroCommand, true);
2433
 
        getDocument()->activateSceneListGeneration(true);
 
2557
        //getDocument()->activateSceneListGeneration(true);
2434
2558
        slotStatusMsg(i18n("Ready."));
2435
2559
    }
2436
2560
 
2455
2579
            ++itt;
2456
2580
        }
2457
2581
        addCommand(macroCommand, true);
2458
 
        getDocument()->activateSceneListGeneration(true);
 
2582
        //getDocument()->activateSceneListGeneration(true);
2459
2583
        slotStatusMsg(i18n("Ready."));
2460
2584
    }
2461
2585
 
2476
2600
        DocClipRefList selectedClip;
2477
2601
        selectedClip.append(m_pastedClip);
2478
2602
        if (getDocument()->projectClip().canAddClipsToTracks(selectedClip, ix, insertTime)) {
 
2603
                kdDebug()<<"/ / / PASTING CLPI TOP TRACK: "<<ix<<endl;
2479
2604
                m_pastedClip->setParentTrack(getDocument()->track(ix), ix);
2480
2605
                m_pastedClip->moveTrackStart(insertTime);
2481
 
                getDocument()->track(ix)->addClip(m_pastedClip, false);
 
2606
                //getDocument()->track(ix)->addClip(m_pastedClip, false);
2482
2607
 
2483
 
                KMacroCommand *macroCommand = new KMacroCommand(i18n("Paste"));
 
2608
                /*KMacroCommand *macroCommand = new KMacroCommand(i18n("Paste"));
2484
2609
                macroCommand->addCommand(Command::KSelectClipCommand::selectNone(getDocument()));
2485
2610
                macroCommand->addCommand(new Command::KSelectClipCommand(getDocument(), m_pastedClip, true));
2486
 
                addCommand(macroCommand, true);
 
2611
                addCommand(macroCommand, true);*/
2487
2612
 
2488
 
                addCommand(new Command::KAddRefClipCommand(effectList(), *m_doc, m_pastedClip, true), false);
 
2613
                addCommand(new Command::KAddRefClipCommand(*m_doc, m_pastedClip, true), true);
2489
2614
 
2490
2615
                if (m_pastedClip->trackEnd() > getDocument()->projectClip().duration())
2491
2616
                         getDocument()->track(ix)->checkTrackLength();
2492
 
                getDocument()->activateSceneListGeneration(true);
 
2617
                // getDocument()->activateSceneListGeneration(true);
2493
2618
                slotStatusMsg(i18n("Ready."));
2494
2619
        }
2495
2620
        else {
2520
2645
        if (KMessageBox::warningContinueCancel(this, i18n("Remove track %1 ?\nThis will remove all clips on that track.").arg(ix),i18n("Delete Track")) != KMessageBox::Continue) return;
2521
2646
        //kdDebug()<<"+++++++++++++++++++++  ASK TRACK DELETION: "<<ix<<endl;
2522
2647
        addCommand(Command::KAddRefClipCommand::deleteAllTrackClips(getDocument(), ix));
2523
 
        if (m_transitionPanel->isOnTrack(ix)) m_transitionPanel->setTransition(0); 
 
2648
        if (m_transitionPanel->isOnTrack(ix)) m_transitionPanel->setTransition(0, getDocument()); 
2524
2649
        getDocument()->slotDeleteTrack(ix);
 
2650
        m_transitionPanel->refreshTracks(getDocument()->trackList().count());
2525
2651
    }
2526
2652
 
2527
2653
    void KdenliveApp::slotAddTrack()
2541
2667
                if (addTrack->trackVideo->isChecked())
2542
2668
                        getDocument()->addVideoTrack(ix);
2543
2669
                else getDocument()->addSoundTrack(ix);
 
2670
                m_transitionPanel->refreshTracks(getDocument()->trackList().count());
2544
2671
        }
2545
2672
    }
2546
2673
 
2571
2698
 
2572
2699
    void KdenliveApp::slotRenderZone()
2573
2700
    {
2574
 
        if (!m_exportWidget) slotRenderExportTimeline(false);
 
2701
        initRenderExport(false);
2575
2702
        m_exportWidget->renderSelectedZone(NULL);
2576
2703
    }
2577
2704
 
2582
2709
        fd->setOperationMode(KFileDialog::Saving);
2583
2710
        fd->setMode(KFile::File);
2584
2711
        if (fd->exec() == QDialog::Accepted) {
2585
 
                if (!m_exportWidget) slotRenderExportTimeline(false);
 
2712
                initRenderExport(false);
2586
2713
                m_exportWidget->renderSelectedZone(fd->selectedURL().path(), true);
2587
2714
        }
2588
2715
        delete addToProject;
2591
2718
 
2592
2719
    void KdenliveApp::slotSaveZone()
2593
2720
    {
2594
 
        QCheckBox * addToProject = new QCheckBox(i18n("Add new clip to project"),this);
2595
 
        KFileDialog *fd = new KFileDialog(m_fileDialogPath.path(), "application/vnd.westley.scenelist", this, "save_westley", true,addToProject);
 
2721
        QWidget *container = new QWidget();
 
2722
        QGridLayout *lo = new QGridLayout ( container, 4, 2 );
 
2723
        lo->setSpacing( KDialog::spacingHint() );
 
2724
 
 
2725
        QLabel *lab = new QLabel(i18n("Clip description:"), container);
 
2726
        KLineEdit *le = new KLineEdit(container);
 
2727
        lo->addWidget(lab, 0, 0);
 
2728
        lo->addWidget(le, 0, 1);
 
2729
        QCheckBox * addToProject = new QCheckBox(i18n("Add new clip to project"),container);
 
2730
        addToProject->setChecked(KdenliveSettings::addnewlysaved());
 
2731
        lo->addMultiCellWidget( addToProject, 1, 1, 0, 1 );
 
2732
 
 
2733
        KFileDialog *fd = new KFileDialog(m_fileDialogPath.path(), "application/vnd.westley.scenelist", this, "save_westley", true, container);
2596
2734
        fd->setOperationMode(KFileDialog::Saving);
2597
2735
        fd->setMode(KFile::File);
2598
2736
        if (fd->exec() == QDialog::Accepted) {
2599
 
                QDomDocument partial = getDocument()->projectClip().generatePartialSceneList(m_timeline->inpointPosition(), m_timeline->outpointPosition(), -1);
2600
 
                QFile file(fd->selectedURL().path());
2601
 
                file.open( IO_WriteOnly );
2602
 
                QCString save = partial.toString().utf8();
2603
 
                file.writeBlock(save, save.length());
2604
 
                file.close();
2605
 
                if (addToProject->isChecked()) insertClipFromUrl(fd->selectedURL().path());
 
2737
                bool doIt = true;
 
2738
                if (KIO::NetAccess::exists(fd->selectedURL(), false, this)) {
 
2739
                    if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) ==  KMessageBox::No) doIt = false;
 
2740
                }
 
2741
                if (doIt) {
 
2742
                    QDomDocument partial = getDocument()->projectClip().generatePartialSceneList(m_timeline->inpointPosition(), m_timeline->outpointPosition(), -1);
 
2743
 
 
2744
                    if (!le->text().isEmpty()) {
 
2745
                        QDomElement documentElement = partial.documentElement();
 
2746
                        if (documentElement.tagName() != "westley") {
 
2747
                            kdWarning() << "KdenliveDoc::loadFromXML() document element has unknown tagName : " << documentElement.tagName() << endl;
 
2748
                        }
 
2749
                        documentElement.setAttribute("title", le->text());
 
2750
                    }
 
2751
                
 
2752
                    QFile file(fd->selectedURL().path());
 
2753
                    file.open( IO_WriteOnly );
 
2754
                    QCString save = partial.toString().utf8();
 
2755
                    file.writeBlock(save, save.length());
 
2756
                    file.close();
 
2757
                    if (addToProject->isChecked()) insertClipFromUrl(fd->selectedURL().path());
 
2758
                }
2606
2759
        }
2607
2760
        delete addToProject;
2608
2761
        delete fd;
2609
2762
    }
2610
2763
 
 
2764
    void KdenliveApp::slotExplodePlaylist()
 
2765
    {
 
2766
        DocClipRefList list = getDocument()->projectClip().selectedClipList();
 
2767
        DocClipRef *clipUnderMouse;
 
2768
 
 
2769
        // check if all clips are on the same track. If not, user needs to save selected zone
 
2770
        int track;
 
2771
        clipUnderMouse = list.first();
 
2772
 
 
2773
        while (clipUnderMouse) {
 
2774
            if (clipUnderMouse->clipType() == DocClipBase::PLAYLIST) {
 
2775
                track = clipUnderMouse->trackNum();
 
2776
                PlayList::explodePlaylist(clipUnderMouse, this);
 
2777
 
 
2778
            }
 
2779
            clipUnderMouse = list.next();
 
2780
        }
 
2781
 
 
2782
    }
 
2783
 
2611
2784
    void KdenliveApp::slotSaveSubClip()
2612
2785
    {
2613
 
        QCheckBox * addToProject = new QCheckBox(i18n("Add new clip to project"),this);
2614
 
        addToProject->setChecked(true);
2615
 
        KFileDialog *fd = new KFileDialog(m_fileDialogPath.path(), "application/vnd.westley.scenelist", this, "save_westley", true, addToProject);
 
2786
 
 
2787
        DocClipRefList list = getDocument()->projectClip().selectedClipList();
 
2788
        DocClipRef *clipUnderMouse;
 
2789
 
 
2790
        // check if all clips are on the same track. If not, user needs to save selected zone
 
2791
        int track;
 
2792
        clipUnderMouse = list.first();
 
2793
        track = clipUnderMouse->trackNum();
 
2794
        clipUnderMouse = list.next();
 
2795
        for (; clipUnderMouse; clipUnderMouse = list.next()) {
 
2796
            if (track != clipUnderMouse->trackNum()) {  
 
2797
                KMessageBox::sorry(this, i18n("You have selected clips on several tracks.\nSaving a subclip does not allow this, please use the \"Save selected zone\" option."));
 
2798
                return;
 
2799
            }
 
2800
        }
 
2801
 
 
2802
        QWidget *container = new QWidget();
 
2803
        QGridLayout *lo = new QGridLayout ( container, 4, 2 );
 
2804
        lo->setSpacing( KDialog::spacingHint() );
 
2805
 
 
2806
        QLabel *lab = new QLabel(i18n("Clip description:"), container);
 
2807
        KLineEdit *le = new KLineEdit(container);
 
2808
        lo->addWidget(lab, 0, 0);
 
2809
        lo->addWidget(le, 0, 1);
 
2810
        QCheckBox * addToProject = new QCheckBox(i18n("Add new clip to project"),container);
 
2811
        addToProject->setChecked(KdenliveSettings::addnewlysaved());
 
2812
        lo->addMultiCellWidget( addToProject, 1, 1, 0, 1 );
 
2813
        KFileDialog *fd = new KFileDialog(QString::null, "application/vnd.westley.scenelist", this, "save_westley", true, container);
2616
2814
        fd->setCaption(i18n("Save Subclip"));
2617
2815
        fd->setOperationMode(KFileDialog::Saving);
2618
2816
        fd->setMode(KFile::File);
2619
2817
        if (fd->exec() == QDialog::Accepted) {
 
2818
                bool doIt = true;
2620
2819
                if (KIO::NetAccess::exists(fd->selectedURL(), false, this)) {
2621
 
                    if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) ==  KMessageBox::No) return;
 
2820
                    if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) ==  KMessageBox::No) doIt = false;
2622
2821
                }
2623
 
                DocClipRef *clipUnderMouse = getDocument()->projectClip().selectedClip();
2624
 
                QDomDocument partial = clipUnderMouse->generateXMLClip();
2625
 
                QFile file(fd->selectedURL().path());
2626
 
                file.open( IO_WriteOnly );
2627
 
                QCString save = QString("<westley><producer id=\"" + QString::number(clipUnderMouse->referencedClip()->getId()) + "\" resource=\"" + clipUnderMouse->fileURL().path() + "\" /><playlist>"+partial.toString()+"</playlist></westley>").utf8();
2628
 
                file.writeBlock(save, save.length());
2629
 
                file.close();
2630
 
                if (addToProject->isChecked()) insertClipFromUrl(fd->selectedURL().path());
2631
 
        }
 
2822
 
 
2823
                if (doIt) {
 
2824
                    QDomDocument doc;
 
2825
                    QDomElement westley = doc.createElement("westley");
 
2826
                    doc.appendChild(westley);
 
2827
                    if (!le->text().isEmpty()) westley.setAttribute("title", le->text());
 
2828
                    QDomElement playlist = doc.createElement("playlist");
 
2829
 
 
2830
                    clipUnderMouse = list.first();
 
2831
                    double fps = KdenliveSettings::defaultfps();
 
2832
                    int timestart = clipUnderMouse->trackStart().frames(fps);
 
2833
                    QDomElement producer, blank;
 
2834
                    QStringList resources;
 
2835
 
 
2836
                    for (; clipUnderMouse; clipUnderMouse = list.next()) {
 
2837
                        QDomDocument partial = clipUnderMouse->generateXMLClip();
 
2838
                        int producerId = clipUnderMouse->referencedClip()->getId();
 
2839
                        DocumentBaseNode *node = getDocument()->findClipNodeById(producerId);
 
2840
                        if (node && resources.find(QString::number(producerId)) == resources.end()) {
 
2841
                            DocumentClipNode *clipNode = node->asClipNode();
 
2842
                                if (clipNode) {
 
2843
                                    QDomElement avfile = doc.createElement("producer");
 
2844
                                    westley.appendChild(SaveProjectNativeFilter::processedNode(clipNode, avfile));
 
2845
                                    resources.append(QString::number(producerId));
 
2846
                                }
 
2847
                        }
 
2848
 
 
2849
                        if (clipUnderMouse->trackStart().frames(fps) - timestart > 0.01) {
 
2850
                            blank = doc.createElement("blank");
 
2851
                            blank.setAttribute("length", clipUnderMouse->trackStart().frames(fps) - timestart);
 
2852
                            playlist.appendChild(blank);
 
2853
                        }
 
2854
                        playlist.appendChild(partial.firstChild());
 
2855
                        timestart = (int)(clipUnderMouse->trackEnd()).frames(fps);
 
2856
                    }
 
2857
                    westley.appendChild(playlist);
 
2858
 
 
2859
                    QCString save = doc.toString().utf8();
 
2860
 
 
2861
                    QFile file(fd->selectedURL().path());
 
2862
                    file.open( IO_WriteOnly );
 
2863
                    file.writeBlock(save, save.length());
 
2864
                    file.close();
 
2865
                    KdenliveSettings::setAddnewlysaved(addToProject->isChecked());
 
2866
                    if (addToProject->isChecked()) insertClipFromUrl(fd->selectedURL().path());
 
2867
                }
 
2868
            }
 
2869
        delete le;
 
2870
        delete lab;
2632
2871
        delete addToProject;
 
2872
        delete lo;
 
2873
        delete container;
2633
2874
        delete fd;
2634
2875
    }
2635
2876
 
2712
2953
 
2713
2954
 
2714
2955
    void KdenliveApp::slotFileSave() {
2715
 
        if (m_doc->URL().isEmpty()) slotFileSaveAs(m_doc->projectName());
 
2956
        if (m_doc->URL().isEmpty() || m_doc->URL() == KURL(m_recoveryFile)) slotFileSaveAs(m_doc->projectName());
2716
2957
        else {
2717
2958
                slotStatusMsg(i18n("Saving file..."));
2718
2959
                if (KIO::NetAccess::exists(m_doc->URL(), true, this)) {
2934
3175
    }
2935
3176
 
2936
3177
/** Called when the user activates the "Export Timeline" action */
2937
 
    void KdenliveApp::slotRenderExportTimeline(bool show) {
2938
 
        slotStatusMsg(i18n("Exporting Timeline..."));
2939
 
            if (!m_exportWidget) { 
 
3178
    void KdenliveApp::initRenderExport(bool reset) {
 
3179
        if (!m_exportWidget) {
2940
3180
            m_exportWidget=new exportWidget(this, m_timeline, projectFormatParameters(m_projectFormat), this,"exporter");
2941
3181
            m_exportWidget->setMetaData(getDocument()->metadata());
2942
3182
            connect(m_workspaceMonitor->screen(),SIGNAL(exportOver()),m_exportWidget,SLOT(endExport()));
2943
3183
            connect(m_exportWidget,SIGNAL(exportToFirewire(QString, int, GenTime, GenTime)),m_workspaceMonitor->screen(),SLOT(exportToFirewire(QString, int, GenTime, GenTime)));
2944
3184
            connect(m_exportWidget,SIGNAL(addFileToProject(const QString &)),this,SLOT(slotAddFileToProject(const QString &)));
2945
3185
            connect(m_exportWidget,SIGNAL(metadataChanged(const QStringList)), this, SLOT(slotSetDocumentMetadata(const QStringList)));
2946
 
            }
2947
 
            if (show) {
2948
 
                if (m_exportWidget->isVisible()) m_exportWidget->hide();
2949
 
                else m_exportWidget->show();
2950
 
            }
 
3186
        }
 
3187
        else if (reset) m_exportWidget->resetValues();
 
3188
    }
 
3189
 
 
3190
/** Called when the user activates the "Export Timeline" action */
 
3191
    void KdenliveApp::slotRenderExportTimeline() {
 
3192
        slotStatusMsg(i18n("Exporting Timeline..."));
 
3193
        initRenderExport(false);
 
3194
        if (m_exportWidget->isVisible()) m_exportWidget->hide();
 
3195
        else m_exportWidget->show();
2951
3196
        slotStatusMsg(i18n("Ready."));
2952
3197
    }
2953
3198
 
2964
3209
 
2965
3210
 
2966
3211
    void KdenliveApp::slotRenderDvd() {
2967
 
        if (!m_exportWidget) slotRenderExportTimeline(false);
 
3212
        initRenderExport(false);
2968
3213
        if (!m_exportDvd) m_exportDvd = new ExportDvdDialog(&getDocument()->projectClip(), m_exportWidget, projectFormatParameters(m_projectFormat), this, "dvd");
2969
3214
        m_exportDvd->fillStructure(xmlGuides());
2970
3215
        m_exportDvd->show();
3017
3262
 
3018
3263
 
3019
3264
    void KdenliveApp::slotProjectRenameFolder(QString message) {
3020
 
        if (m_projectList->currentClip()) return;
 
3265
        if (!m_projectList->currentItemIsFolder()) return;
 
3266
        
3021
3267
        QString currentFolderName = m_projectList->currentItemName();
3022
3268
        QString folderName = KInputDialog::getText(i18n("Rename Folder"), message + i18n("Enter new folder name: "), currentFolderName);
3023
3269
        if (folderName.isEmpty()) return;
3024
3270
        // check folder name doesn't exist
3025
 
        /*QListViewItemIterator it( m_projectList->m_listView );
3026
 
        while ( it.current() ) {
3027
 
            if (it.current()->text(1) == folderName && (!static_cast<AVListViewItem *>(it.current())->clip())) {
3028
 
                slotProjectRenameFolder(i18n("Folder %1 already exists\n").arg(folderName));
3029
 
                return;
3030
 
            }
3031
 
            ++it;
3032
 
        }*/
3033
 
 
3034
 
        DocumentGroupNode *folder = getDocument()->findClipNode(currentFolderName)->asGroupNode();
3035
 
        folder->rename(folderName);
 
3271
        if (m_projectList->renameFolder(folderName)) {
 
3272
            DocumentGroupNode *folder = getDocument()->findClipNode(currentFolderName)->asGroupNode();
 
3273
            folder->rename(folderName);
 
3274
        }
 
3275
        else slotProjectRenameFolder(i18n("Folder %1 already exists\n").arg(folderName));
3036
3276
    }
3037
3277
 
3038
3278
    void KdenliveApp::slotProjectDeleteFolder() {
3039
3279
        //TODO: implement icon view folder deletion
3040
3280
        if (m_projectList->isEmpty() || m_projectList->currentClip() || !m_projectList->isListView()) return;
3041
3281
        if (m_projectList->hasChildren())
3042
 
        if (KMessageBox::questionYesNo(this, i18n("Deleting this folder will remove all reference to its clips in your project.\nDelete this folder ?")) ==  KMessageBox::No) return;
 
3282
            if (KMessageBox::questionYesNo(this, i18n("Deleting this folder will remove all reference to its clips in your project.\nDelete this folder ?")) ==  KMessageBox::No) return;
3043
3283
        QString folderName = m_projectList->currentItemName();
3044
3284
        QStringList folderItems = m_projectList->currentItemChildrenIds();
3045
3285
        /*
3050
3290
            myChild = m_projectList->m_listView->findItem(folderName, 1, Qt::CaseSensitive);
3051
3291
        }*/
3052
3292
        slotProjectDeleteClips(folderItems);
3053
 
        getDocument()->deleteGroupNode(folderName);     getDocument()->activateSceneListGeneration(true);
 
3293
        getDocument()->deleteGroupNode(folderName);     
 
3294
        getDocument()->activateSceneListGeneration(true);
3054
3295
    }
3055
3296
 
3056
3297
    void KdenliveApp::slotProjectAddFolder(QString message) {
3070
3311
        //AVListViewItem *item = new AVListViewItem(getDocument(), m_projectList->m_listView->firstChild(), nFolder);
3071
3312
        //item->setExpandable(true);
3072
3313
        getDocument()->addClipNode(i18n("Clips"), nFolder);
 
3314
        documentModified(true);
3073
3315
    }
3074
3316
 
3075
3317
/** Add clips to the project */
3076
 
    void KdenliveApp::slotProjectAddClips() {
 
3318
    void KdenliveApp::slotProjectAddClips(KURL::List urlList, bool silent) {
3077
3319
        slotStatusMsg(i18n("Adding Clips"));
3078
 
 
3079
 
        // Make a reasonable filter for video / audio files.
3080
 
        QString filter = "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/x-msvideo video/mpeg video/x-ms-wmv audio/x-mp3 audio/x-wav application/ogg *.m2t *.dv video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr";
3081
 
        KURL::List urlList =
3082
 
            KFileDialog::getOpenURLs(m_fileDialogPath.path(), filter, this,
3083
 
        i18n("Open File..."));
3084
 
 
 
3320
        if (urlList.isEmpty()) {
 
3321
            // Make a reasonable filter for video / audio files.
 
3322
            QString filter = "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/x-msvideo video/mpeg video/x-ms-wmv audio/x-mp3 audio/x-wav application/ogg *.m2t *.dv video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr";
 
3323
            urlList = KFileDialog::getOpenURLs(m_fileDialogPath.path(), filter, this, i18n("Open File..."));
 
3324
        }
3085
3325
        KURL::List::Iterator it;
3086
3326
        KURL url;
3087
3327
        
3090
3330
            url = (*it);
3091
3331
            if (!url.isEmpty()) {
3092
3332
                if (m_doc->URL() == url) {
3093
 
                        KMessageBox::sorry(this, i18n("You cannot include the current Kdenlive document in itself."));
3094
 
                }
3095
 
                else if (getDocument()->clipManager().findClip(url)) KMessageBox::sorry(this, i18n("The clip %1 is already present in this project").arg(url.filename()));
 
3333
                    KMessageBox::sorry(this, i18n("You cannot include the current Kdenlive document in itself."));
 
3334
                }
 
3335
                else if (getDocument()->clipManager().findClip(url)) {
 
3336
                    if (!silent) KMessageBox::sorry(this, i18n("The clip %1 is already present in this project").arg(url.filename()));
 
3337
                }
3096
3338
                else { 
3097
 
                        Command::KAddClipCommand * command;
3098
 
                        command = new Command::KAddClipCommand(*m_doc, m_projectList->parentName(), url, true);
3099
 
                        macroCommand->addCommand(command);
 
3339
                    Command::KAddClipCommand * command;
 
3340
                    command = new Command::KAddClipCommand(*m_doc, m_projectList->parentName(), url, true);
 
3341
                    macroCommand->addCommand(command);
3100
3342
                }
3101
3343
                m_fileDialogPath = url;
3102
3344
            }
3103
3345
        }
3104
3346
        addCommand(macroCommand, true);
3105
 
 
3106
3347
        m_fileDialogPath.setFileName(QString::null);
3107
 
 
3108
3348
        slotStatusMsg(i18n("Ready."));
3109
3349
    }
3110
3350
 
3114
3354
        slotStatusMsg(i18n("Adding Clips"));
3115
3355
        KDialogBase *dia = new KDialogBase(  KDialogBase::Swallow, i18n("Create Color Clip"), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, this, "create_clip", true);
3116
3356
        createColorClip_UI *clipChoice = new createColorClip_UI(dia);
3117
 
        clipChoice->edit_name->setText(i18n("Color Clip"));
 
3357
        clipChoice->edit_name->setText(DocClipBase::getTypeName(DocClipBase::COLOR));
3118
3358
        clipChoice->edit_duration->setText(KdenliveSettings::colorclipduration());
3119
3359
        dia->setMainWidget(clipChoice);
3120
3360
        dia->adjustSize();
3133
3373
        slotStatusMsg(i18n("Ready."));
3134
3374
    }
3135
3375
 
3136
 
    void KdenliveApp::slotProjectAddImageClip(KURL imageUrl) {
 
3376
    void KdenliveApp::slotProjectAddImageClip(KURL imageUrl, bool silent) {
3137
3377
        slotStatusMsg(i18n("Adding Clips"));
3138
3378
        KDialogBase *dia;
3139
3379
        KURL fileUrl;
3167
3407
        }
3168
3408
        else {
3169
3409
            if (getDocument()->clipManager().findClip(imageUrl)) {
3170
 
                KMessageBox::sorry(this, i18n("The clip %1 is already present in this project").arg(imageUrl.filename()));
 
3410
                if (!silent) KMessageBox::sorry(this, i18n("The clip %1 is already present in this project").arg(imageUrl.filename()));
3171
3411
                return;
3172
3412
            }
3173
3413
            fileUrl = imageUrl;
3201
3441
            int lumaduration = (int) getDocument()->getTimecodePosition(slideDialog->lumaDuration(), MAXFRAMEDURATION).frames(getDocument()->framesPerSecond());
3202
3442
            if (slideDialog->useLuma()) lumaFile = m_transitionPanel->getLumaFilePath(slideDialog->currentLuma());
3203
3443
            KCommand *command =
3204
 
                new Command::KAddClipCommand(*m_doc, m_projectList->parentName(), KURL(url), extension, ttl, slideDialog->hasCrossfade(), lumaFile, lumasoftness, lumaduration, duration, slideDialog->description(), slideDialog->isTransparent(), true);
 
3444
                new Command::KAddClipCommand(*m_doc, m_projectList->parentName(), KURL(url), extension, ttl, slideDialog->hasCrossfade(), lumaFile, lumasoftness, lumaduration, duration, slideDialog->description(), slideDialog->isTransparent(), slideDialog->loop(), true);
3205
3445
            addCommand(command, true);
3206
3446
        }
3207
3447
        delete slideDialog;
3217
3457
        txtWidget->edit_duration->setText(KdenliveSettings::textclipduration());
3218
3458
        if (txtWidget->exec() == QDialog::Accepted) {
3219
3459
            GenTime duration = getDocument()->getTimecodePosition(txtWidget->edit_duration->text(), MAXFRAMEDURATION);
3220
 
            QPixmap thumb = txtWidget->thumbnail(50, 40);
 
3460
            QPixmap thumb = txtWidget->thumbnail(getDocument()->thumbSize());
3221
3461
            QDomDocument xml = txtWidget->toXml();
3222
3462
            
3223
3463
            KCommand *command =
3238
3478
        if (m_monitorManager.hasActiveMonitor() && m_monitorManager.activeMonitor()->clip()) {
3239
3479
            QString filter = "image/png";
3240
3480
            QCheckBox * addToProject = new QCheckBox(i18n("Add image to project"),this);
3241
 
            addToProject->setChecked(true);
 
3481
            addToProject->setChecked(KdenliveSettings::addnewlysaved());
3242
3482
            KFileDialog *fd = new KFileDialog(m_fileDialogPath.path(), filter, this, "save_frame", true,addToProject);
3243
3483
            fd->setOperationMode(KFileDialog::Saving);
3244
3484
            fd->setMode(KFile::File);
3245
3485
            if (fd->exec() == QDialog::Accepted) {
3246
 
                m_monitorManager.activeMonitor()->exportCurrentFrame(fd->selectedURL(), addToProject->isChecked());
 
3486
                KdenliveSettings::setAddnewlysaved(addToProject->isChecked());
 
3487
                bool doIt = true;
 
3488
                if (KIO::NetAccess::exists(fd->selectedURL(), false, this)) {
 
3489
                    if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) ==  KMessageBox::No) doIt = false;
 
3490
                }
 
3491
                if (doIt) m_monitorManager.activeMonitor()->exportCurrentFrame(fd->selectedURL(), addToProject->isChecked());
3247
3492
            }
3248
3493
            delete addToProject;
3249
3494
            delete fd;
3331
3576
                txtWidget->transparentTitle->setChecked(clip->toDocClipTextFile()->isTransparent());
3332
3577
                if (txtWidget->exec() == QDialog::Accepted) {
3333
3578
                    GenTime duration = getDocument()->getTimecodePosition(txtWidget->edit_duration->text(), MAXFRAMEDURATION);
3334
 
                    QPixmap thumb = txtWidget->thumbnail(50, 40);
 
3579
                    QPixmap thumb = txtWidget->thumbnail(getDocument()->thumbSize());
3335
3580
                    QDomDocument xml = txtWidget->toXml();
3336
3581
                    Command::KEditClipCommand(*m_doc, refClip, duration, txtWidget->titleName->text(), clip->description(), xml , txtWidget->previewFile(), thumb, txtWidget->transparentTitle->isChecked());
3337
 
 
3338
3582
                    if (refClip->numReferences() > 0) getDocument()->activateSceneListGeneration(true);
3339
3583
                }
3340
3584
                delete txtWidget;
3358
3602
                                duration, dia->name(), dia->description());
3359
3603
                    }
3360
3604
                    else if (refClip->clipType() == DocClipBase::IMAGE) {
3361
 
                        QString url = dia->url();
 
3605
                        KURL url;
 
3606
                        url.setPath(dia->url());
3362
3607
                        if (duration > GenTime(MAXFRAMEDURATION, getDocument()->framesPerSecond())) duration = GenTime(MAXFRAMEDURATION, getDocument()->framesPerSecond());
3363
3608
                        Command::KEditClipCommand(*m_doc, refClip, url, duration, dia->description(), dia->transparency());
3364
3609
                    }
3365
3610
                    else if (refClip->clipType() == DocClipBase::SLIDESHOW) {
3366
3611
                        QString lumaFile = m_transitionPanel->getLumaFilePath(dia->lumaFile());
3367
 
                        QString url = dia->url() + "/.all." + dia->extension();
 
3612
                        KURL url;
 
3613
                        url.setPath( dia->url() + "/.all." + dia->extension());
3368
3614
                        if (duration > GenTime(MAXFRAMEDURATION, getDocument()->framesPerSecond())) duration = GenTime(MAXFRAMEDURATION, getDocument()->framesPerSecond());
3369
3615
                        Command::KEditClipCommand(*m_doc, refClip, url, "",dia->ttl(), dia->crossfading(), lumaFile, dia->lumaSoftness(), dia->lumaDuration(), duration, dia->description(), dia->transparency());
3370
3616
                    }
3371
3617
                    else { // Video clip
3372
 
                        Command::KEditClipCommand(*m_doc, refClip, dia->url(),dia->description());
 
3618
                        KURL url;
 
3619
                        url.setPath(dia->url());
 
3620
                        Command::KEditClipCommand(*m_doc, refClip, url, dia->description());
3373
3621
                    }
3374
 
                if (refClip->numReferences() > 0)     getDocument()->activateSceneListGeneration(true);
 
3622
                if (refClip->numReferences() > 0) getDocument()->activateSceneListGeneration(true);
3375
3623
                }
3376
3624
                delete dia;
3377
3625
            }
3396
3644
                    }
3397
3645
            }
3398
3646
            DocClipRef *refClip;
3399
 
 
 
3647
            bool usedClip = false;
3400
3648
            // Create a macro command that will delete all clips from the timeline involving this avfile. Then, delete it.
3401
3649
            KMacroCommand *macroCommand = new KMacroCommand(i18n("Delete Clip"));
3402
 
 
3403
3650
            for (refClip = refClipList.first(); refClip; refClip = refClipList.next()) {
3404
3651
                DocClipBase *clip = refClip->referencedClip();
3405
 
 
 
3652
                if (clip->numReferences() > 0) usedClip = true;
3406
3653
                // NOTE - we clear the monitors of the clip here - this does _not_ go into the macro command.
3407
3654
                int id = clip->getId();
3408
3655
                m_monitorManager.clearClip(clip);
3409
 
 
 
3656
                        
3410
3657
                DocClipRefList list = m_doc->referencedClips(clip);
3411
3658
                QPtrListIterator < DocClipRef > itt(list);
3412
3659
 
3413
3660
                while (itt.current()) {
3414
 
                    Command::KAddRefClipCommand * command = new Command::KAddRefClipCommand(effectList(), *m_doc, itt.current(), false);
3415
 
                    if (m_transitionPanel->belongsToClip(itt.current())) m_transitionPanel->setTransition(0);
 
3661
                    Command::KAddRefClipCommand * command = new Command::KAddRefClipCommand(*m_doc, itt.current(), false);
 
3662
                    if (m_transitionPanel->belongsToClip(itt.current())) m_transitionPanel->setTransition(0, getDocument());
3416
3663
                    macroCommand->addCommand(command);
3417
3664
                    ++itt;
3418
3665
                }
3419
 
 
3420
3666
                // remove audio thumbnail and tmp files
3421
3667
                clip->removeTmpFile();
3422
 
 
3423
3668
                DocumentBaseNode *node = m_doc->findClipNodeById(id);
3424
3669
                if (!node) kdDebug()<<"++++++  CANNOT FIND NODE: "<<id<<endl;
3425
3670
                macroCommand->addCommand(new Command::KAddClipCommand(*m_doc, node->name(), clip, node->parent(), false));
3426
3671
            }
3427
3672
            addCommand(macroCommand, true);
3428
 
            if (confirm) getDocument()->activateSceneListGeneration(true);
 
3673
            if (confirm && usedClip) getDocument()->activateSceneListGeneration(true);
3429
3674
        }
3430
3675
        else if (confirm) slotProjectDeleteFolder();
3431
3676
        slotStatusMsg(i18n("Ready."));
3451
3696
            QPtrListIterator < DocClipRef > itt(list);
3452
3697
 
3453
3698
            while (itt.current()) {
3454
 
                    Command::KAddRefClipCommand * command = new Command::KAddRefClipCommand(effectList(), *m_doc, itt.current(), false);
3455
 
                    if (m_transitionPanel->belongsToClip(itt.current())) m_transitionPanel->setTransition(0);
 
3699
                    Command::KAddRefClipCommand * command = new Command::KAddRefClipCommand(*m_doc, itt.current(), false);
 
3700
                    if (m_transitionPanel->belongsToClip(itt.current())) m_transitionPanel->setTransition(0, getDocument());
3456
3701
                    macroCommand->addCommand(command);
3457
3702
                    ++itt;
3458
3703
            }
3470
3715
    }
3471
3716
 
3472
3717
 
3473
 
/** Cleans the project of unwanted clips */
 
3718
/** Cleans the project of unused clips */
3474
3719
    void KdenliveApp::slotProjectClean() {
3475
3720
        slotStatusMsg(i18n("Cleaning Project"));
3476
3721
 
3488
3733
        slotStatusMsg(i18n("Ready."));
3489
3734
    }
3490
3735
 
3491
 
/*
3492
 
    void KdenliveApp::slotProjectClipProperties() {
3493
 
        slotStatusMsg(i18n("Viewing clip properties"));
3494
 
        m_clipPropertyDialog->setClip(m_projectList->currentSelection());
3495
 
        makeDockVisible(clipWidget);
3496
 
        slotStatusMsg(i18n("Ready."));
3497
 
    }
3498
 
 
3499
 
    void KdenliveApp::slotProjectClipProperties(DocClipRef * ) {
3500
 
        slotStatusMsg(i18n("Viewing clip properties"));
3501
 
        m_clipPropertyDialog->setClip(m_projectList->currentSelection());
3502
 
        slotStatusMsg(i18n("Ready."));
3503
 
    }
3504
 
*/
3505
 
 
 
3736
/** Fix broken paths in playlist clips */
 
3737
    void KdenliveApp::slotFixPlaylists() {
 
3738
        slotStatusMsg(i18n("Fixing Playlist clips"));
 
3739
        m_projectList->fixPlaylists();
 
3740
        slotStatusMsg(i18n("Ready."));
 
3741
    }
3506
3742
 
3507
3743
    void KdenliveApp::slotPlay() {
3508
3744
        slotStatusMsg(i18n("Play / Pause"));
3606
3842
        slotExtractClipAudio(clip);
3607
3843
    }
3608
3844
 
 
3845
 
 
3846
    void KdenliveApp::slotProjectDeleteClipMarkers() {
 
3847
        DocClipRef *clip = m_projectList->currentClip();
 
3848
        if (!clip) return;
 
3849
        deleteClipMarkers(clip);
 
3850
    }
 
3851
 
 
3852
    void KdenliveApp::slotProjectImportCue() {
 
3853
        DocClipRef *clip = m_projectList->currentClip();
 
3854
        if (!clip) return;
 
3855
 
 
3856
        QCheckBox * mergeCues = new QCheckBox(i18n("Merge with existing cues"),this);
 
3857
        KFileDialog *fd = new KFileDialog(m_fileDialogPath.path(), "*.cue", this, "import_cue", true, mergeCues);
 
3858
        fd->setCaption(i18n("Open File..."));
 
3859
        fd->setOperationMode(KFileDialog::Opening);
 
3860
        fd->setMode(KFile::File);
 
3861
        if (fd->exec() == QDialog::Accepted) {
 
3862
            QFile file(fd->selectedFile());
 
3863
            if ( file.open(IO_ReadOnly) ) {
 
3864
                QString cueTime;
 
3865
                QString line;
 
3866
                QString title;
 
3867
                GenTime time;
 
3868
                int fps = KdenliveSettings::defaultfps();
 
3869
                int id = clip->referencedClip()->getId();
 
3870
                if (!mergeCues->isChecked()) deleteClipMarkers(clip);
 
3871
                KMacroCommand *macroCommand = new KMacroCommand(i18n("Import Markers"));
 
3872
                QTextStream t( &file );        // use a text stream
 
3873
                while ( !t.eof() ) {
 
3874
                    line = t.readLine();
 
3875
                    line = line.simplifyWhiteSpace();
 
3876
                    if (line.startsWith("title", false)) {
 
3877
                        title = line.section("\"", 1, 1);
 
3878
                    }
 
3879
                    else if (line.startsWith("index", false)) {
 
3880
                        cueTime = line.section(" ", -1);
 
3881
                        int frames = (int) (cueTime.section(":", 0, 0).toInt() * 60 * fps + cueTime.section(":", 1, 1).toInt() * fps + cueTime.section(":", 2, 2).toInt() * fps / 74);
 
3882
                        time = GenTime(frames, fps);
 
3883
                        Command::KAddMarkerCommand * command = new Command::KAddMarkerCommand(*getDocument(), id, time, title, true);
 
3884
                        macroCommand->addCommand(command);
 
3885
                        title = QString::null;
 
3886
                    }
 
3887
                }
 
3888
                file.close();
 
3889
                addCommand(macroCommand, true);
 
3890
            }
 
3891
        }
 
3892
        delete mergeCues;
 
3893
        delete fd;
 
3894
    }
 
3895
 
3609
3896
    void KdenliveApp::slotExtractClipAudio(DocClipRef *clip) {
3610
3897
        QCheckBox * addToProject = new QCheckBox(i18n("Add new audio clip to project"),this);
3611
3898
        addToProject->setChecked(true);
3614
3901
        fd->setOperationMode(KFileDialog::Saving);
3615
3902
        fd->setMode(KFile::File);
3616
3903
        if (fd->exec() == QDialog::Accepted) {
 
3904
                bool doIt = true;
3617
3905
                if (KIO::NetAccess::exists(fd->selectedURL(), false, this)) {
3618
 
                    if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) ==  KMessageBox::No) return;
 
3906
                    if (KMessageBox::questionYesNo(this, i18n("File already exists.\nDo you want to overwrite it ?")) ==  KMessageBox::No) doIt = false;
3619
3907
                }
3620
 
 
3621
 
                QDomDocument partial = clip->generateXMLClip();
3622
 
                QString save = "<westley><producer id=\"" + QString::number(clip->referencedClip()->getId()) + "\" resource=\"" + clip->fileURL().path() + "\" /><playlist>"+partial.toString()+"</playlist></westley>";
3623
 
 
3624
 
                if (!m_exportWidget) slotRenderExportTimeline(false);
3625
 
                m_exportWidget->renderSelectedClipAudio(save, fd->selectedURL().path());
 
3908
                if (doIt) {
 
3909
                    QDomDocument partial = clip->generateXMLClip();
 
3910
                    QString save = "<westley><producer id=\"" + QString::number(clip->referencedClip()->getId()) + "\" resource=\"" + clip->fileURL().path() + "\" /><playlist>"+partial.toString()+"</playlist></westley>";
 
3911
 
 
3912
                    initRenderExport(false);
 
3913
                    m_exportWidget->renderSelectedClipAudio(save, fd->selectedURL().path(), addToProject->isChecked());
 
3914
                }
3626
3915
        }
 
3916
        delete addToProject;
 
3917
        delete fd;
3627
3918
    }
3628
3919
 
3629
3920
    void KdenliveApp::slotSeekTo(GenTime time) {
3753
4044
        addCommand(Command::KSelectClipCommand::selectNone(getDocument()), true);
3754
4045
    }
3755
4046
 
 
4047
    void KdenliveApp::forceTimelineRefresh() {
 
4048
        getDocument()->forceTimelineRefresh();
 
4049
    }
 
4050
 
 
4051
    /*void KdenliveApp::forceDiskTimelineRefresh() {
 
4052
        getDocument()->renderer()->mltSavePlaylist();
 
4053
        
 
4054
    QFile file( "/home/one/playlist.xml" ); // Read the text from a file
 
4055
    if ( file.open( IO_ReadOnly ) ) {
 
4056
        QTextStream stream( &file );
 
4057
        m_debugDialog->setText( stream.read() );
 
4058
    }
 
4059
    }*/
 
4060
 
3756
4061
    void KdenliveApp::slotDefineClipThumb() {
3757
4062
        DocClipRef *clip = m_projectList->currentClip();
3758
4063
        if (!clip) return;
3759
4064
        clip->referencedClip()->setProjectThumbFrame((int) m_clipMonitor->editPanel()->point().frames(getDocument()->framesPerSecond()) );
3760
 
        getDocument()->renderer()->getImage(clip->fileURL(), clip->referencedClip()->getProjectThumbFrame(), 50, 40);
 
4065
        getDocument()->renderer()->getImage(clip->fileURL(), clip->referencedClip()->getProjectThumbFrame(), getDocument()->thumbSize());
3761
4066
    }
3762
4067
 
3763
4068
    void KdenliveApp::slotSetInpoint() {
3782
4087
        DocClipRefList list = getDocument()->listSelected();
3783
4088
        QPtrListIterator < DocClipRef > itt(list);
3784
4089
        while (itt.current()) {
3785
 
                if (m_transitionPanel->belongsToClip(itt.current())) m_transitionPanel->setTransition(0);
 
4090
                if (m_transitionPanel->belongsToClip(itt.current())) m_transitionPanel->setTransition(0, getDocument());
3786
4091
                ++itt;
3787
4092
        }
3788
4093
 
3789
4094
        addCommand(Command::KAddRefClipCommand::
3790
4095
            deleteSelectedClips(getDocument()), true);
3791
 
        getDocument()->activateSceneListGeneration(true);
3792
4096
        slotStatusMsg(i18n("Ready."));
3793
4097
    }
3794
4098
    
3823
4127
        }
3824
4128
        else activateWorkspaceMonitor();
3825
4129
    }
3826
 
    
 
4130
 
 
4131
/** Sets the clip monitor source to be the given playlist. */
 
4132
    void KdenliveApp::slotSetClipMonitorSource(QDomDocument playlist, GenTime duration) {
 
4133
        if (!playlist.isNull()) {
 
4134
            slotFocusClipMonitor();
 
4135
            m_clipMonitor->slotSetClip(playlist, duration);
 
4136
        }
 
4137
        else activateWorkspaceMonitor();
 
4138
    }
 
4139
 
3827
4140
            /** Sets the clip monitor source to be the given clip. */
3828
4141
    void KdenliveApp::slotSetClipMonitorSourceAndSeek(DocClipRef * clip) {
3829
4142
        if (clip) {
3989
4302
        DocumentBaseNode *parentNode;
3990
4303
        // find folder on which the item was dropped
3991
4304
        if (parent) {
3992
 
                //kdDebug()<<"+++++++ dropped on: "<<parent->text(1)<<endl;
3993
 
                if (static_cast<AVListViewItem *>(parent)->clip() == 0) {
3994
 
                        parentNode = getDocument()->findClipNode(parent->text(1));
3995
 
                }
3996
 
                else if (parent->parent() && (static_cast<AVListViewItem *>(parent->parent()))->clip() == 0) { 
3997
 
                        parentNode = getDocument()->findClipNode(parent->parent()->text(1));
 
4305
                BaseListViewItem::ITEMTYPE type = BaseListViewItem::CLIP;
 
4306
                while (parent) {
 
4307
                    type = ((BaseListViewItem *) parent)->getType();
 
4308
                    if (type == BaseListViewItem::FOLDER) {
 
4309
                        break;
 
4310
                    }
 
4311
                    else parent = parent->parent();
 
4312
                } 
 
4313
                if (parent) {
 
4314
                    parentNode = getDocument()->findClipNode(parent->text(1));
3998
4315
                }
3999
4316
                else parentNode = getDocument()->clipHierarch();
4000
4317
        }
4002
4319
 
4003
4320
        // reparent the item
4004
4321
        while (itt.current()) {
4005
 
            DocumentBaseNode *node = m_doc->findClipNode(itt.current()->name());
 
4322
            DocumentBaseNode *node = m_doc->findClipNodeById(itt.current()->referencedClip()->getId());
4006
4323
            if (node->hasParent() && node->parent()->name() != parentNode->name()) {
4007
4324
                DocumentBaseNode *oldParentNode = node->parent();
4008
4325
                oldParentNode->removeChild(node);
4028
4345
        QPtrListIterator < DocClipRef > itt(clips);
4029
4346
        DocumentBaseNode *parentNode;
4030
4347
        if (parent) {
4031
 
                if (parent->pixmap(0) == 0) parentNode = getDocument()->findClipNode(parent->text(1));
4032
 
                else if (parent->parent() && parent->parent()->pixmap(0) == 0) 
4033
 
                        parentNode = getDocument()->findClipNode(parent->parent()->text(1));
 
4348
                BaseListViewItem::ITEMTYPE type = BaseListViewItem::CLIP;
 
4349
                while (parent) {
 
4350
                    type = ((BaseListViewItem *) parent)->getType();
 
4351
                    if (type == BaseListViewItem::FOLDER) {
 
4352
                        break;
 
4353
                    }
 
4354
                    else parent = parent->parent();
 
4355
                } 
 
4356
                if (parent) parentNode = getDocument()->findClipNode(parent->text(1));
4034
4357
                else parentNode = getDocument()->clipHierarch();
4035
4358
        }
4036
4359
        else parentNode = getDocument()->clipHierarch();
4168
4491
        addCommand(command);
4169
4492
    }
4170
4493
 
 
4494
    void KdenliveApp::deleteClipMarkers(DocClipRef *clip)
 
4495
    {
 
4496
        QValueVector < CommentedTime > markers = clip->commentedSnapMarkers();
 
4497
        QValueVector < CommentedTime >::iterator markerItt = markers.begin();
 
4498
        KMacroCommand *macroCommand = new KMacroCommand(i18n("Delete Markers"));
 
4499
        int id = clip->referencedClip()->getId();
 
4500
        while (markerItt != markers.end()) {
 
4501
            Command::KAddMarkerCommand * command = new Command::KAddMarkerCommand(*getDocument(), id, (*markerItt).time(), (*markerItt).comment(), false);
 
4502
            macroCommand->addCommand(command);
 
4503
            ++markerItt;
 
4504
        }
 
4505
        addCommand(macroCommand);
 
4506
    }
 
4507
 
4171
4508
    void KdenliveApp::toggleMarkerUnderCursor()
4172
4509
    {
4173
4510
        DocClipRef *clipUnderMouse;
4192
4529
                itt(clip.track(track)->firstClip(selectedClips));
4193
4530
 
4194
4531
            while (itt.current()) {
4195
 
            QValueVector < CommentedTime > markers = itt.current()->commentedSnapMarkers();
 
4532
                QValueVector < CommentedTime > markers = itt.current()->commentedSnapMarkers();
4196
4533
                QValueVector < CommentedTime >::iterator markerItt = markers.begin();
4197
4534
                while (markerItt != markers.end()) {
4198
4535
                    Command::KAddMarkerCommand * command =
4254
4591
              removeEffectsMenu->insertItem(*it, ix);
4255
4592
              ix++;
4256
4593
          }
4257
 
          m_timelinePopupMenu = (QPopupMenu *) factory()->container("timeline_clip_context", this);
 
4594
          if (clip->clipType() != DocClipBase::PLAYLIST)
 
4595
              m_timelinePopupMenu = (QPopupMenu *) factory()->container("timeline_clip_context", this);
 
4596
          else m_timelinePopupMenu = (QPopupMenu *) factory()->container("timeline_playlist_context", this);
4258
4597
        }
4259
4598
        else {
4260
4599
            m_timeline->selectTrack(ix);
4302
4641
        if (b_clip)
4303
4642
            addCommand(Command::KAddTransitionCommand::appendTransition(getDocument(), getDocument()->projectClip().selectedClip(), b_clip, transitionName), true);
4304
4643
        else addCommand(Command::KAddTransitionCommand::appendTransition(getDocument(), getDocument()->projectClip().selectedClip(), mouseTime, transitionName), true);
4305
 
        getDocument()->indirectlyModified();
 
4644
        slotEditCurrentTransition();
 
4645
        //getDocument()->indirectlyModified();
4306
4646
    }
4307
4647
    
4308
4648
    void KdenliveApp::slotDeleteTransition() {
4315
4655
        mouseTime = m_timeline->timeUnderMouse(m_timeline->trackView()->mapFromGlobal(position).x());
4316
4656
        Transition *transit = getDocument()->projectClip().selectedClip()->transitionAt(mouseTime);
4317
4657
        if (transit) {
4318
 
            if (m_transitionPanel->isActiveTransition(transit)) m_transitionPanel->setTransition(0); 
 
4658
            if (m_transitionPanel->isActiveTransition(transit)) m_transitionPanel->setTransition(0, getDocument()); 
4319
4659
            addCommand(Command::KAddTransitionCommand::removeTransition(getDocument(), getDocument()->projectClip().selectedClip(), transit), true);
4320
4660
            getDocument()->indirectlyModified();
4321
4661
        }
4333
4673
        Transition *transit = getDocument()->projectClip().selectedClip()->transitionAt(mouseTime);
4334
4674
        if (transit) {
4335
4675
            m_dockTransition->makeDockVisible();
4336
 
            m_transitionPanel->setTransition(transit);
 
4676
            m_transitionPanel->setTransition(transit, getDocument());
4337
4677
            m_timeline->drawTrackViewBackBuffer();
4338
4678
        }
4339
4679
    }
4427
4767
        if (!clip) return;
4428
4768
        GenTime curr = m_timeline->seekPosition();
4429
4769
        if ((curr <= clip->trackStart()) || (curr >= clip->trackEnd())) return;
4430
 
        getDocument()->activateSceneListGeneration(false);
4431
 
        addCommand(Command::DocumentMacroCommands::razorSelectedClipsAt(getDocument(), curr), true);
4432
 
        getDocument()->activateSceneListGeneration(true);
 
4770
        //getDocument()->activateSceneListGeneration(false);
 
4771
        addCommand(Command::DocumentMacroCommands::razorSelectedClipsAt(this, getDocument(), curr), true);
 
4772
        //getDocument()->activateSceneListGeneration(true);
4433
4773
    }
4434
4774
 
 
4775
void KdenliveApp::slotPrint()
 
4776
{
 
4777
        // create the KPrinter object with default options
 
4778
        KPrinter        printer;
 
4779
 
 
4780
        printer.addDialogPage(new PrintSettings);
 
4781
 
 
4782
        // start the print dialog to initialize the KPrinter object
 
4783
        if (printer.setup(this))
 
4784
        {
 
4785
                // do the actual printing job
 
4786
                doPrint(&printer);
 
4787
        }
 
4788
}
 
4789
 
 
4790
void KdenliveApp::doPrint(KPrinter *printer)
 
4791
{
 
4792
        // create the painter object
 
4793
        QPainter        painter(printer);
 
4794
 
 
4795
        // at this moment we print the image using default options,
 
4796
        // later we may want to customize printing.
 
4797
        
 
4798
        bool printFullPath = (printer->option("kde-kdenlive-fullpath") == "true") ? true : false;
 
4799
        bool printFilter = (printer->option("kde-kdenlive-filter") == "true") ? true : false;
 
4800
        bool printGray = (printer->option("kde-kdenlive-gray") == "true") ? true : false;
 
4801
        // do the actual painting job
 
4802
        m_projectList->doPrinting(printer, &painter, printer->option("kde-kdenlive-images").toInt(), printFullPath, printGray, printFilter);
 
4803
}
 
4804
 
4435
4805
}                               // namespace Gui