Mercurial > jwe > octave
comparison libgui/src/m-editor/find-dialog.cc @ 31011:35d37e433532 stable
replace use of depreciated QDesktopWidget in GUI
* gui-utils.cc: include QApplication, QRect and QScreen;
(get_screen_geometry): return QRect with geometry of primary screen;
(adjust_to_screen): adjust given QRect to be completely on the screen
that contains the largest part of the QRect, use a default geometry if
no part is on an available screen
* gui-utils.h: include QRect;
new function get_screen_geometry and adjust_to_screen
* community-news.cc: do not include QDesktopWidget, but gui-utils.h;
(get_screen_geometry); move function to gui-utils.cc;
* community-news.h: move get_screen_geometry to gui-utils.h
* find-dialog.cc: do not include QDesktopWidget, but gui-utils.h;
(restore_settings): use new function adjust_to_screen
* main-window.cc: do not include QDesktopWidget, but gui-utils.h;
(get_screen_geometry: move function to gui-utils.cc
* main-window.h: move function get_screen_geometry to gui.utils.h;
* octave-dock-widget.cc: do not include QDesktopWidget, but gui-utils.h
QScreen and QWindow;
(handle_settings): use adjust_to_screen and QGuiApplication->primaryScreen
* release-notes.cc: do not include QDesktopWidget, but gui-utils.h
and QScreen;
(get_screen_geometry): move to gui-utils.cc;
* release-notes.h: move get:screen_geometry to gui-utils.h
* terminal-dock-widget.cc: do not include QDesktopWidget but QScreen;
(terminal_dock_widget): use QGuiApplication->primaryScreen instead
of QDesktopWidget->screenGeometry
* welcome-wizard.cc: remove include of QDesktopWidget
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sun, 30 Jan 2022 16:41:44 +0100 |
parents | 796f54d4ddbf |
children | 04601f6c47f4 |
comparison
equal
deleted
inserted
replaced
31009:2b4f7287aa3a | 31011:35d37e433532 |
---|---|
69 | 69 |
70 #include <QApplication> | 70 #include <QApplication> |
71 #include <QCheckBox> | 71 #include <QCheckBox> |
72 #include <QCheckBox> | 72 #include <QCheckBox> |
73 #include <QCompleter> | 73 #include <QCompleter> |
74 #include <QDesktopWidget> | |
75 #include <QDialogButtonBox> | 74 #include <QDialogButtonBox> |
76 #include <QGridLayout> | 75 #include <QGridLayout> |
77 #include <QIcon> | 76 #include <QIcon> |
78 #include <QLabel> | 77 #include <QLabel> |
79 #include <QLineEdit> | 78 #include <QLineEdit> |
81 #include <QPushButton> | 80 #include <QPushButton> |
82 #include <QVBoxLayout> | 81 #include <QVBoxLayout> |
83 | 82 |
84 #include "find-dialog.h" | 83 #include "find-dialog.h" |
85 #include "gui-preferences-ed.h" | 84 #include "gui-preferences-ed.h" |
85 #include "gui-utils.h" | |
86 #include "resource-manager.h" | 86 #include "resource-manager.h" |
87 #include "octave-qobject.h" | 87 #include "octave-qobject.h" |
88 | 88 |
89 namespace octave | 89 namespace octave |
90 { | 90 { |
291 m_regex_check_box->setChecked (FIND_DLG_REGX & opts); | 291 m_regex_check_box->setChecked (FIND_DLG_REGX & opts); |
292 m_whole_words_check_box->setChecked (FIND_DLG_WORDS & opts); | 292 m_whole_words_check_box->setChecked (FIND_DLG_WORDS & opts); |
293 m_backward_check_box->setChecked (FIND_DLG_BACK & opts); | 293 m_backward_check_box->setChecked (FIND_DLG_BACK & opts); |
294 m_search_selection_check_box->setChecked (FIND_DLG_SEL & opts); | 294 m_search_selection_check_box->setChecked (FIND_DLG_SEL & opts); |
295 | 295 |
296 // Position: lower right of editor's position | 296 // Default position: lower right of editor's position |
297 int xp = ed_bottom_right.x () - sizeHint ().width (); | 297 int xp = ed_bottom_right.x () - sizeHint ().width (); |
298 int yp = ed_bottom_right.y () - sizeHint ().height (); | 298 int yp = ed_bottom_right.y () - sizeHint ().height (); |
299 | 299 QRect default_geometry (xp, yp, sizeHint ().width (), sizeHint ().height ()); |
300 | |
301 // Last position from settings | |
300 m_last_position = s->value (ed_fdlg_pos.key, QPoint (xp, yp)).toPoint (); | 302 m_last_position = s->value (ed_fdlg_pos.key, QPoint (xp, yp)).toPoint (); |
303 QRect last_geometry (m_last_position, | |
304 QSize (sizeHint ().width (), sizeHint ().height ())); | |
305 | |
306 // Make sure we are on the screen | |
307 adjust_to_screen (last_geometry, default_geometry); | |
308 m_last_position = last_geometry.topLeft (); | |
309 | |
301 move (m_last_position); | 310 move (m_last_position); |
302 | |
303 if (QApplication::desktop ()->screenNumber (this) == -1) | |
304 { | |
305 // Last used position is not on screen anymore, use default pos. | |
306 m_last_position = QPoint (xp, yp); | |
307 move (m_last_position); | |
308 | |
309 if (QApplication::desktop ()->screenNumber (this) == -1) | |
310 { | |
311 // Default position is not on screen, last resort | |
312 m_last_position = QPoint (50, 100); // upper left | |
313 move (m_last_position); | |
314 } | |
315 } | |
316 | |
317 } | 311 } |
318 | 312 |
319 // set text of "search from start" depending on backward search | 313 // set text of "search from start" depending on backward search |
320 void find_dialog::handle_backward_search_changed (int backward) | 314 void find_dialog::handle_backward_search_changed (int backward) |
321 { | 315 { |