comparison libgui/src/main-window.cc @ 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 6504a1932637
children e7b5be5a7f80
comparison
equal deleted inserted replaced
18872:b43157d085ba 18873:41980d0a5fd2
554 554
555 vlayout->addWidget (browser); 555 vlayout->addWidget (browser);
556 556
557 community_news_window->setLayout (vlayout); 557 community_news_window->setLayout (vlayout);
558 community_news_window->setWindowTitle (tr ("Octave Community News")); 558 community_news_window->setWindowTitle (tr ("Octave Community News"));
559 community_news_window->resize (640, 480); 559
560 int win_x = QApplication::desktop ()->width (); 560 // center the window on the screen where octave is running
561 int win_y = QApplication::desktop ()->height (); 561 QDesktopWidget *m_desktop = QApplication::desktop ();
562 int screen = m_desktop->screenNumber (this); // screen of the main window
563 QRect screen_geo = m_desktop->availableGeometry (screen);
564 int win_x = screen_geo.width (); // width of the screen
565 int win_y = screen_geo.height (); // height of the screen
566 int news_x = std::min (640, win_x-80); // desired width of news window
567 int news_y = std::min (480, win_y-80); // desired height of news window
568 community_news_window->resize (news_x, news_y); // set size and center
562 community_news_window->move ((win_x - community_news_window->width ())/2, 569 community_news_window->move ((win_x - community_news_window->width ())/2,
563 (win_y - community_news_window->height ())/2); 570 (win_y - community_news_window->height ())/2);
564 } 571 }
565 572
566 if (! community_news_window->isVisible ()) 573 if (! community_news_window->isVisible ())