15 #include <QApplication> 16 #include <QDesktopWidget> 28 this->setWindowTitle(
"View Layout");
35 void print(QString header, QRect r)
37 std::cout << header <<
" (" << r.left() <<
", " << r.top() <<
", " << r.width() <<
", " << r.height() <<
")"<< std::endl;
40 QString SecondaryViewLayoutWindow::toString(QRect r)
const 42 return QString(
"%1, %2, %3, %4").arg(r.left()).arg(r.top()).arg(r.width()).arg(r.height());
49 int bestScreen = this->findSmallestSecondaryScreen();
51 QDesktopWidget* desktop = QApplication::desktop();
53 if (desktop->primaryScreen()==bestScreen)
55 report(QString(
"No secondary screen found. Displaying secondary view layout on primary screen."));
59 QRect rect = desktop->screenGeometry(bestScreen);
60 report(QString(
"Displaying secondary view layout on fullscreen %1 of %2, size=[%3]")
62 .arg(desktop->screenCount())
63 .arg(this->toString(rect)));
64 this->setGeometry(rect);
65 this->move(rect.topLeft());
66 this->setWindowState(this->windowState() | Qt::WindowFullScreen);
70 int SecondaryViewLayoutWindow::findSmallestSecondaryScreen()
72 QDesktopWidget* desktop = QApplication::desktop();
75 for (
int i=1; i<desktop->screenCount(); ++i)
77 if (desktop->primaryScreen()==i)
79 QRect last = desktop->screenGeometry(best);
80 QRect current = desktop->screenGeometry(i);
81 if (current.height()*current.width() < last.height()*last.width())
83 if (desktop->primaryScreen()==best)
92 this->setCentralWidget(
logicManager()->getViewService()->createLayoutWidget(
this, 1));
93 if (
logicManager()->getViewService()->getActiveLayout(1).isEmpty())
void tryShowOnSecondaryScreen()
virtual void closeEvent(QCloseEvent *event)
LogicManager * logicManager()
SecondaryViewLayoutWindow(QWidget *parent)
~SecondaryViewLayoutWindow()
ViewServicePtr getViewService()
virtual void showEvent(QShowEvent *event)
void print(QString header, QRect r)
virtual void hideEvent(QCloseEvent *event)
Namespace for all CustusX production code.