Mercurial > octave
changeset 28742:6d35c0db5d2f stable
fix moving editor find dialog (bug #59047)
* find-dialog.cc: add includes QApplication and QDesktopwidget;
(save_settings): remove erroneous correction of dialog position
(restore_settings): check whether dialog position is outside the
visible screen and test alternative positions
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Fri, 11 Sep 2020 20:20:01 +0200 |
parents | f98fd55b9557 |
children | 2cb815b72d2f |
files | libgui/src/m-editor/find-dialog.cc |
diffstat | 1 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/find-dialog.cc Mon Sep 14 09:17:41 2020 -0700 +++ b/libgui/src/m-editor/find-dialog.cc Fri Sep 11 20:20:01 2020 +0200 @@ -67,9 +67,11 @@ #if defined (HAVE_QSCINTILLA) +#include <QApplication> #include <QCheckBox> #include <QCheckBox> #include <QCompleter> +#include <QDesktopWidget> #include <QDialogButtonBox> #include <QGridLayout> #include <QIcon> @@ -220,15 +222,9 @@ resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *s = rmgr.get_settings (); - // Save position and fix offset it by the frame geometry - int fy = 2; - if (m_editor->isFloating ()) - fy = 1; - - int dy = geometry ().y () - frameGeometry ().y (); + // Save position QPoint dlg_pos = pos (); - - m_last_position = QPoint (dlg_pos.x (), dlg_pos.y () + fy*dy); + m_last_position = QPoint (dlg_pos.x (), dlg_pos.y ()); s->setValue (ed_fdlg_pos.key, m_last_position); @@ -295,8 +291,22 @@ int yp = ed_bottom_right.y () - sizeHint ().height (); m_last_position = s->value (ed_fdlg_pos.key, QPoint (xp,yp)).toPoint (); + move (m_last_position); - move (m_last_position); + if (QApplication::desktop ()->screenNumber (this) == -1) + { + // Last used position is not on screen anymore, use default pos. + m_last_position = QPoint (xp,yp); + move (m_last_position); + + if (QApplication::desktop ()->screenNumber (this) == -1) + { + // Default position is not on screen, last resort + m_last_position = QPoint (50,100); // upper left + move (m_last_position); + } + } + } // set text of "search from start" depending on backward search