Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLMC
Commits
b119862e
Commit
b119862e
authored
Dec 10, 2009
by
Hugo Beauzee-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Asking for confirmation when closing the project
Refactored confirmation when closing the app.
parent
e545ea25
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
24 deletions
+33
-24
src/GUI/MainWindow.cpp
src/GUI/MainWindow.cpp
+3
-24
src/Project/ProjectManager.cpp
src/Project/ProjectManager.cpp
+29
-0
src/Project/ProjectManager.h
src/Project/ProjectManager.h
+1
-0
No files found.
src/GUI/MainWindow.cpp
View file @
b119862e
...
...
@@ -421,31 +421,10 @@ void MainWindow::on_actionProject_Preferences_triggered()
void
MainWindow
::
closeEvent
(
QCloseEvent
*
e
)
{
if
(
ProjectManager
::
getInstance
()
->
needSave
()
==
true
)
{
QMessageBox
msgBox
;
msgBox
.
setText
(
tr
(
"The project has been modified."
)
);
msgBox
.
setInformativeText
(
tr
(
"Do you want to save it ?"
)
);
msgBox
.
setStandardButtons
(
QMessageBox
::
Save
|
QMessageBox
::
Discard
|
QMessageBox
::
Cancel
);
msgBox
.
setDefaultButton
(
QMessageBox
::
Save
);
int
ret
=
msgBox
.
exec
();
switch
(
ret
)
{
case
QMessageBox
::
Save
:
ProjectManager
::
getInstance
()
->
saveProject
();
break
;
case
QMessageBox
::
Discard
:
break
;
case
QMessageBox
::
Cancel
:
default:
e
->
ignore
();
return
;
e
->
accept
();
}
}
else
if
(
ProjectManager
::
getInstance
()
->
askForSaveIfModified
()
)
e
->
accept
();
else
e
->
ignore
();
}
void
MainWindow
::
projectChanged
(
const
QString
&
projectName
,
bool
savedStatus
)
...
...
src/Project/ProjectManager.cpp
View file @
b119862e
...
...
@@ -23,6 +23,7 @@
#include <QFileDialog>
#include <QtDebug>
#include <QSettings>
#include <QMessageBox>
#include "ProjectManager.h"
#include "Library.h"
...
...
@@ -167,6 +168,8 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ )
void
ProjectManager
::
closeProject
()
{
if
(
askForSaveIfModified
()
==
false
)
return
;
if
(
m_projectFile
!=
NULL
)
{
delete
m_projectFile
;
...
...
@@ -174,3 +177,29 @@ void ProjectManager::closeProject()
}
emit
projectClosed
();
}
bool
ProjectManager
::
askForSaveIfModified
()
{
if
(
m_needSave
==
true
)
{
QMessageBox
msgBox
;
msgBox
.
setText
(
tr
(
"The project has been modified."
)
);
msgBox
.
setInformativeText
(
tr
(
"Do you want to save it ?"
)
);
msgBox
.
setStandardButtons
(
QMessageBox
::
Save
|
QMessageBox
::
Discard
|
QMessageBox
::
Cancel
);
msgBox
.
setDefaultButton
(
QMessageBox
::
Save
);
int
ret
=
msgBox
.
exec
();
switch
(
ret
)
{
case
QMessageBox
::
Save
:
saveProject
();
break
;
case
QMessageBox
::
Discard
:
break
;
case
QMessageBox
::
Cancel
:
default:
return
false
;
}
}
return
true
;
}
src/Project/ProjectManager.h
View file @
b119862e
...
...
@@ -41,6 +41,7 @@ public:
bool
needSave
()
const
;
QStringList
recentsProjects
()
const
;
void
closeProject
();
bool
askForSaveIfModified
();
private:
ProjectManager
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment