Bugzilla – Attachment 307 Details for
Bug 952
"confirm unsaved" dialog is not in focus when it pops up
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
patch for dialog keyboard focus research
patch--confirm-unsaved--focus-research.diff (text/plain), 3.38 KB, created by
Gerhard Sittig
on 2017-05-26 11:25:17 CEST
(
hide
)
Description:
patch for dialog keyboard focus research
Filename:
MIME Type:
Creator:
Gerhard Sittig
Created:
2017-05-26 11:25:17 CEST
Size:
3.38 KB
patch
obsolete
>commit 992a40b4b1351a7187c9c9e78e4a71694e450cd0 >Author: Gerhard Sittig <gerhard.sittig@gmx.net> >Date: 2017-05-26 10:40:20 +0200 > > HACK WIP research into "confirm unsaved" dialog focus issues > > When a view or the program gets closed while it has data that was not > saved to disk yet, a dialog pops up. Because that dialog is not in focus > when it pops up, confirming it is tedious and annoying since it requires > mouse movement. > > Research into the Qt induced(?) focus issue. Factor out code from call > sites, and try to force the focus into the dialog. Did not work so far. :( >--- > pv/mainwindow.cpp | 46 ++++++++++++++++++++++++++++++++++++---------- > pv/mainwindow.hpp | 1 + > 2 files changed, 37 insertions(+), 10 deletions(-) > >diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp >index 205c95ca95a7..1b27b4ee8270 100644 >--- a/pv/mainwindow.cpp >+++ b/pv/mainwindow.cpp >@@ -697,9 +697,7 @@ void MainWindow::on_view_close_clicked() > // Also destroy the entire session if its main view is closing... > if (view == session->main_view()) { > // ...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)) >+ if (session->data_saved() || this->confirm_unsaved()) > remove_session(session); > break; > } else >@@ -716,15 +714,43 @@ void MainWindow::on_tab_changed(int index) > on_focused_session_changed(session); > } > >-void MainWindow::on_tab_close_requested(int index) >-{ >- shared_ptr<Session> session = get_tab_session(index); >+/* >+ * Inspired by >+ * http://grokbase.com/t/gg/android-qt/126wkx3efa/pop-window-for-qt-android-app >+ * >+ * Some Linux environments are reported to have keyboard focus issues. >+ * See if we can work around it. Meh, did't help. :( Except that this >+ * method reduces redundancy at call sites. >+ * >+ * TODO: Suppress the annoying dialog in the first place, depending on >+ * some additional "No bothering dialogs please" configuration item? >+ */ >+// typeof(QMessageBox::Yes) >+int MainWindow::confirm_unsaved() { > >- assert(session); >- >- if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"), >+ QMessageBox mb(QMessageBox::Question, >+ tr("Confirmation"), > tr("This session contains unsaved data. Close it anyway?"), >- QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)) >+ QMessageBox::Yes | QMessageBox::No, >+ this); >+ mb.setDefaultButton(QMessageBox::Yes); >+ mb.show(); >+ QPoint pos = mapToGlobal(QPoint(width() / 2 - mb.width() / 2, height() / 2 - mb.height() / 2)); >+ mb.move(pos); >+ int yes_pressed = mb.exec() == QMessageBox::Yes; >+ // typeof(QMessageBox::Yes) pressed = mb.exec(); >+ // return pressed; >+ // return pressed == QMessageBox::Yes; >+ return yes_pressed; >+} >+ >+void MainWindow::on_tab_close_requested(int index) >+{ >+ shared_ptr<Session> session = get_tab_session(index); >+ >+ assert(session); >+ >+ if (session->data_saved() || this->confirm_unsaved()) > remove_session(session); > } > >diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp >index 6541ccc6dff1..12e0dfca1d7a 100644 >--- a/pv/mainwindow.hpp >+++ b/pv/mainwindow.hpp >@@ -123,6 +123,7 @@ private Q_SLOTS: > void on_new_view(Session *session); > void on_view_close_clicked(); > >+ int confirm_unsaved(); > void on_tab_changed(int index); > void on_tab_close_requested(int index); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 952
: 307