changeset 18873:41980d0a5fd2 gui-release

center the community news window on the screen not on the desktop (bug #42567) * main-window.cc (display_community_news): calculate the position of the news window with respect to the screen of the main window, not with respect to the desktop, which may consist of several screens
author Torsten <ttl@justmail.de>
date Tue, 17 Jun 2014 20:51:05 +0200
parents b43157d085ba
children e7b5be5a7f80
files libgui/src/main-window.cc
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Mon Jun 16 20:41:19 2014 +0200
+++ b/libgui/src/main-window.cc	Tue Jun 17 20:51:05 2014 +0200
@@ -556,9 +556,16 @@
 
       community_news_window->setLayout (vlayout);
       community_news_window->setWindowTitle (tr ("Octave Community News"));
-      community_news_window->resize (640, 480);
-      int win_x = QApplication::desktop ()->width ();
-      int win_y = QApplication::desktop ()->height ();
+
+      // center the window on the screen where octave is running
+      QDesktopWidget *m_desktop = QApplication::desktop ();
+      int screen = m_desktop->screenNumber (this);  // screen of the main window
+      QRect screen_geo = m_desktop->availableGeometry (screen);
+      int win_x = screen_geo.width ();        // width of the screen
+      int win_y = screen_geo.height ();       // height of the screen
+      int news_x = std::min (640, win_x-80);  // desired width of news window
+      int news_y = std::min (480, win_y-80);  // desired height of news window
+      community_news_window->resize (news_x, news_y);  // set size and center
       community_news_window->move ((win_x - community_news_window->width ())/2,
                                    (win_y - community_news_window->height ())/2);
     }