projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5ccfc97
)
Confirm with user also when trying to close the session's main dock
author
Soeren Apel
<soeren@apelpie.net>
Fri, 20 Jan 2017 09:59:50 +0000
(10:59 +0100)
committer
Soeren Apel
<soeren@apelpie.net>
Fri, 20 Jan 2017 09:59:50 +0000
(10:59 +0100)
pv/mainwindow.cpp
patch
|
blob
|
history
diff --git
a/pv/mainwindow.cpp
b/pv/mainwindow.cpp
index 4aeecb260466c6a0885951f94a687dbe132058dc..1821ad1e67a69276bd3e6b04c607df0e2c1f121f 100644
(file)
--- a/
pv/mainwindow.cpp
+++ b/
pv/mainwindow.cpp
@@
-213,6
+213,12
@@
shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
this, SLOT(on_new_view(Session*)));
main_bar->action_view_show_cursors()->setChecked(v->cursors_shown());
this, SLOT(on_new_view(Session*)));
main_bar->action_view_show_cursors()->setChecked(v->cursors_shown());
+
+ /* For the main view we need to prevent the dock widget from
+ * closing itself when its close button is clicked. This is
+ * so we can confirm with the user first. Regular views don't
+ * need this */
+ close_btn->disconnect(SIGNAL(clicked()), dock, SLOT(close()));
} else {
/* Additional view, create a standard bar */
pv::views::trace::StandardBar *standard_bar =
} else {
/* Additional view, create a standard bar */
pv::views::trace::StandardBar *standard_bar =
@@
-674,11
+680,16
@@
void MainWindow::on_view_close_clicked()
if (!session->has_view(view))
continue;
if (!session->has_view(view))
continue;
- // Also destroy the entire session if its main view is closing
+ // Also destroy the entire session if its main view is closing
...
if (view == session->main_view()) {
if (view == session->main_view()) {
- remove_session(session);
+ // ...but only if data is saved or the user confirms closing
+ if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"),
+ tr("This session contains unsaved data. Close it anyway?"),
+ QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes))
+ remove_session(session);
break;
} else
break;
} else
+ // All other views can be closed at any time as no data will be lost
remove_view(view);
}
}
remove_view(view);
}
}