changeset 27087:4092ffc1e43c

fix size of the welcome wizard (bug #56265) * welcome-wizard.cc (welcome_wizard): initialize new class variables for width and height, do not use screen size but get the required size for all three pages and resize widget accordingly; (adjust_size): new method for updating the required size; (initial_page::initial_page) (setup_community_news::setup_community_news) (final_page::final_page): adjust spacing and size policy * welcome-wizard.h: new method adjust_size and new class variables for max. width and heigth
author Torsten Lilge <ttl-octave@mailbox.org>
date Fri, 10 May 2019 22:15:37 +0200
parents 007fcab79721
children 9326c2258e60
files libgui/src/welcome-wizard.cc libgui/src/welcome-wizard.h
diffstat 2 files changed, 43 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/welcome-wizard.cc	Wed Apr 10 21:45:54 2019 -0700
+++ b/libgui/src/welcome-wizard.cc	Fri May 10 22:15:37 2019 +0200
@@ -53,7 +53,8 @@
   welcome_wizard::welcome_wizard (QWidget *p)
     : QDialog (p), m_page_ctor_list (), m_page_list_iterator (),
       m_current_page (initial_page::create (this)),
-      m_allow_web_connect_state (false)
+      m_allow_web_connect_state (false),
+      m_max_height (0), m_max_width (0)
   {
     m_page_ctor_list.push_back (initial_page::create);
     m_page_ctor_list.push_back (setup_community_news::create);
@@ -65,19 +66,21 @@
 
     setEnabled (true);
 
-    QDesktopWidget *m_desktop = QApplication::desktop ();
-    int screen = m_desktop->screenNumber (this);  // screen of the main window
-    QRect screen_geo = m_desktop->availableGeometry (screen);
+    setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
 
-    int win_x = screen_geo.width ();        // width of the screen
-    int win_y = screen_geo.height ();       // height of the screen
-    int ww_x = std::max (win_x/2, 600);    // desired width
-    int ww_y = std::max (win_y*2/3, 480);  // desired height
+    // Create all pages for pre-setting the minimal required size for all pages
+    show_page ();
+    adjust_size ();
+    next_page ();
+    adjust_size ();
+    next_page ();
+    adjust_size ();
+    // now go back to the first page
+    previous_page ();
+    previous_page ();
 
-    resize (ww_x, ww_y);
-    setMinimumSize (QSize (ww_x, ww_y));
-
-    show_page ();
+    // Set the size determined above
+    resize (m_max_width, m_max_height);
 
 #if defined (OCTAVE_USE_WINDOWS_API)
     // HACK to forceshow of dialog if started minimized
@@ -85,6 +88,21 @@
 #endif
   }
 
+  void welcome_wizard::adjust_size (void)
+  {
+    // Get adjusted size for the current page
+    adjustSize ();
+    QSize sz = size ();
+
+    // Update the max. size of the three pages if required
+
+    if (sz.height () > m_max_height)
+      m_max_height = sz.height ();
+
+    if (sz.width () > m_max_width)
+      m_max_width = sz.width ();
+  }
+
   void welcome_wizard::handle_web_connect_option (int state)
   {
     m_allow_web_connect_state = state == Qt::Checked;
@@ -180,8 +198,11 @@
 
     page_layout->addLayout (message_and_logo);
     page_layout->addStretch (10);
+    page_layout->addSpacing (20);
     page_layout->addLayout (button_bar);
 
+    setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+
     m_next->setDefault (true);
     m_next->setFocus ();
 
@@ -267,8 +288,11 @@
 
     page_layout->addLayout (message_logo_and_checkbox);
     page_layout->addStretch (10);
+    page_layout->addSpacing (20);
     page_layout->addLayout (button_bar);
 
+    setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+
     m_next->setDefault (true);
     m_next->setFocus ();
 
@@ -345,8 +369,11 @@
     page_layout->addSpacing (20);
     page_layout->addWidget (m_links);
     page_layout->addStretch (10);
+    page_layout->addSpacing (20);
     page_layout->addLayout (button_bar);
 
+    setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+
     m_finish->setDefault (true);
     m_finish->setFocus ();
 
--- a/libgui/src/welcome-wizard.h	Wed Apr 10 21:45:54 2019 -0700
+++ b/libgui/src/welcome-wizard.h	Fri May 10 22:15:37 2019 +0200
@@ -42,12 +42,16 @@
 
     ~welcome_wizard (void) = default;
 
+    void adjust_size (void);
+
   private:
 
     QList<page_creator_fptr> m_page_ctor_list;
     QList<page_creator_fptr>::iterator m_page_list_iterator;
     QWidget *m_current_page;
     bool m_allow_web_connect_state;
+    int m_max_height;
+    int m_max_width;
 
   private slots: