Commit ffc5da4f authored by Jason Wood's avatar Jason Wood

Moved saveModified() method to Kdenlive.cpp - why the hell was there gui stuff...

Moved saveModified() method to Kdenlive.cpp - why the hell was there gui stuff in the document anyway?!?

svn path=/trunk/kdenlive/; revision=326
parent 3583a9a3
...@@ -442,7 +442,53 @@ void KdenliveApp::readProperties(KConfig* _cfg) ...@@ -442,7 +442,53 @@ void KdenliveApp::readProperties(KConfig* _cfg)
bool KdenliveApp::queryClose() bool KdenliveApp::queryClose()
{ {
return doc->saveModified(); return saveModified();
}
bool KdenliveApp::saveModified()
{
bool completed = true;
if(doc->isModified()) {
int want_save = KMessageBox::warningYesNoCancel(this,
i18n("The current file has been modified.\n"
"Do you want to save it?"),
i18n("Warning"));
switch(want_save) {
case KMessageBox::Yes:
if (doc->URL().fileName() == i18n("Untitled")) {
slotFileSaveAs();
} else {
doc->saveDocument(doc->URL());
};
m_clipMonitor->slotClearClip();
m_workspaceMonitor->slotClearClip();
doc->deleteContents();
completed=true;
break;
case KMessageBox::No:
m_clipMonitor->slotClearClip();
m_workspaceMonitor->slotClearClip();
doc->newDocument();
completed=true;
break;
case KMessageBox::Cancel:
completed=false;
break;
default:
completed=false;
break;
}
}
return completed;
} }
bool KdenliveApp::queryExit() bool KdenliveApp::queryExit()
...@@ -459,7 +505,7 @@ void KdenliveApp::slotFileNew() ...@@ -459,7 +505,7 @@ void KdenliveApp::slotFileNew()
{ {
slotStatusMsg(i18n("Creating new document...")); slotStatusMsg(i18n("Creating new document..."));
if(!doc->saveModified()) if(!saveModified())
{ {
// here saving wasn't successful // here saving wasn't successful
...@@ -477,7 +523,7 @@ void KdenliveApp::slotFileOpen() ...@@ -477,7 +523,7 @@ void KdenliveApp::slotFileOpen()
{ {
slotStatusMsg(i18n("Opening file...")); slotStatusMsg(i18n("Opening file..."));
if(!doc->saveModified()) if(!saveModified())
{ {
// here saving wasn't successful // here saving wasn't successful
...@@ -502,7 +548,7 @@ void KdenliveApp::slotFileOpenRecent(const KURL& url) ...@@ -502,7 +548,7 @@ void KdenliveApp::slotFileOpenRecent(const KURL& url)
{ {
slotStatusMsg(i18n("Opening file...")); slotStatusMsg(i18n("Opening file..."));
if(!doc->saveModified()) if(!saveModified())
{ {
// here saving wasn't successful // here saving wasn't successful
} }
......
...@@ -100,6 +100,10 @@ class KdenliveApp : public KDockMainWindow ...@@ -100,6 +100,10 @@ class KdenliveApp : public KDockMainWindow
/** Returns the render manager. */ /** Returns the render manager. */
KRenderManager * renderManager(); KRenderManager * renderManager();
/** If the document has been modified, asks the user if they want to save it. Returns true if we
* can proceed. i.e., the document has been saved or discarded. */
bool saveModified();
protected: protected:
/** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration /** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration
* file * file
......
...@@ -115,53 +115,6 @@ void KdenliveDoc::slotUpdateAllViews(KdenliveView *sender) ...@@ -115,53 +115,6 @@ void KdenliveDoc::slotUpdateAllViews(KdenliveView *sender)
} }
} }
bool KdenliveDoc::saveModified()
{
kdDebug() << "KdenliveDoc in saveModified()" << endl;
bool completed=true;
if(m_modified)
{
KdenliveApp *win=(KdenliveApp *) parent();
int want_save = KMessageBox::warningYesNoCancel(win,
i18n("The current file has been modified.\n"
"Do you want to save it?"),
i18n("Warning"));
switch(want_save)
{
case KMessageBox::Yes:
if (m_doc_url.fileName() == i18n("Untitled"))
{
win->slotFileSaveAs();
}
else
{
saveDocument(URL());
};
deleteContents();
completed=true;
break;
case KMessageBox::No:
setModified(false);
deleteContents();
completed=true;
break;
case KMessageBox::Cancel:
completed=false;
break;
default:
completed=false;
break;
}
}
return completed;
}
void KdenliveDoc::closeDocument() void KdenliveDoc::closeDocument()
{ {
kdDebug() << "KdenliveDoc in closeDocument()" << endl; kdDebug() << "KdenliveDoc in closeDocument()" << endl;
...@@ -252,8 +205,9 @@ void KdenliveDoc::deleteContents() ...@@ -252,8 +205,9 @@ void KdenliveDoc::deleteContents()
m_projectClip = new DocClipProject(this); m_projectClip = new DocClipProject(this);
connectProjectClip(); connectProjectClip();
m_fileList.clear();
emit trackListChanged(); emit trackListChanged();
m_fileList.clear();
emit avFileListUpdated(); emit avFileListUpdated();
} }
......
...@@ -73,8 +73,6 @@ class KdenliveDoc : public QObject ...@@ -73,8 +73,6 @@ class KdenliveDoc : public QObject
* saving by the user on closing. */ * saving by the user on closing. */
bool isModified(){ return m_modified; }; bool isModified(){ return m_modified; };
/** "save modified" - asks the user for saving if the document is modified */
bool saveModified();
/** deletes the document's contents */ /** deletes the document's contents */
void deleteContents(); void deleteContents();
/** initializes the document generally */ /** initializes the document generally */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment