From: Mads Bondo Dydensborg Date: Sat, 25 Oct 2008 20:22:07 +0000 (+0000) Subject: Fix issue 254: starting up with project supplied on CLI should not result in 'Untitle... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b2a49357aaba842416da302dcc932b8eb94b7d18;p=kdenlive Fix issue 254: starting up with project supplied on CLI should not result in 'Untitled' project tab (http://www.kdenlive.org/mantis/view.php?id=254) svn path=/branches/KDE4/; revision=2563 --- diff --git a/src/main.cpp b/src/main.cpp index 25e1d43e..0b93c072 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,11 +64,12 @@ int main(int argc, char *argv[]) { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); //new QString mltPath = args->getOption("mlt-path"); - MainWindow* window = new MainWindow(mltPath); - window->show(); - if (args->count()) { //new - window->openFile(args->url(0)); //new + KUrl url; + if (args->count()) { + url = args->url(0); } + MainWindow* window = new MainWindow(mltPath, url); + window->show(); args->clear(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 40b1a73a..d214cd2f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -98,7 +98,7 @@ EffectsList MainWindow::audioEffects; EffectsList MainWindow::customEffects; EffectsList MainWindow::transitions; -MainWindow::MainWindow(const QString &MltPath, QWidget *parent) +MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent) : KXmlGuiWindow(parent), m_activeDocument(NULL), m_activeTimeline(NULL), m_renderWidget(NULL), #ifndef NO_JOGSHUTTLE @@ -321,17 +321,17 @@ MainWindow::MainWindow(const QString &MltPath, QWidget *parent) m_monitorManager->initMonitors(m_clipMonitor, m_projectMonitor); slotConnectMonitors(); - if (KdenliveSettings::openlastproject()) { - openLastFile(); + // Open or create a file. Command line argument passed in Url has + // precedence, then "openlastproject", then just a plain empty file. + // If opening Url fails, openlastproject will _not_ be used. + if (!Url.isEmpty()) { + openFile(Url); } else { - /*QList staleFiles = KAutoSaveFile::allStaleFiles(); - if (!staleFiles.isEmpty()) { - if (KMessageBox::questionYesNo(this, i18n("Auto-saved files exist. Do you want to recover them now?"), i18n("File Recovery"), KGuiItem(i18n("Recover")), KGuiItem(i18n("Don't recover"))) == KMessageBox::Yes) { - recoverFiles(staleFiles); - } - else newFile(); + if (KdenliveSettings::openlastproject()) { + openLastFile(); } - else*/ + } + if (m_timelineArea->count() == 0) { newFile(false); } diff --git a/src/mainwindow.h b/src/mainwindow.h index dad33684..f629ce8d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -63,7 +63,15 @@ class MainWindow : public KXmlGuiWindow { Q_OBJECT public: - MainWindow(const QString &MltPath = QString(), QWidget *parent = 0); + /** Constructor + * \param MltPath path to MLT environment + * \param Url Url to open + * \param parent Std. widget parent + * + * The constructor inits the main window. If Url is present, it will be opened. + * If Url is not present, and openLastproject is set, last project will be set + * If no file is open after trying this, a default "newfile" will be created. */ + MainWindow(const QString &MltPath = QString(), const KUrl & Url = KUrl(), QWidget *parent = 0); void parseProfiles(const QString &mltPath = QString()); static EffectsList videoEffects;