36 #include <QApplication>
37 #include <QDesktopWidget>
49 this->setWindowTitle(
"View Layout");
56 void print(QString header, QRect r)
58 std::cout << header <<
" (" << r.left() <<
", " << r.top() <<
", " << r.width() <<
", " << r.height() <<
")"<< std::endl;
61 QString SecondaryViewLayoutWindow::toString(QRect r)
const
63 return QString(
"%1, %2, %3, %4").arg(r.left()).arg(r.top()).arg(r.width()).arg(r.height());
70 int bestScreen = this->findSmallestSecondaryScreen();
72 QDesktopWidget* desktop = QApplication::desktop();
74 if (desktop->primaryScreen()==bestScreen)
76 report(QString(
"No secondary screen found. Displaying secondary view layout on primary screen."));
80 QRect rect = desktop->screenGeometry(bestScreen);
81 report(QString(
"Displaying secondary view layout on fullscreen %1 of %2, size=[%3]")
83 .arg(desktop->screenCount())
84 .arg(this->toString(rect)));
85 this->setGeometry(rect);
86 this->move(rect.topLeft());
87 this->setWindowState(this->windowState() | Qt::WindowFullScreen);
91 int SecondaryViewLayoutWindow::findSmallestSecondaryScreen()
93 QDesktopWidget* desktop = QApplication::desktop();
96 for (
int i=1; i<desktop->screenCount(); ++i)
98 if (desktop->primaryScreen()==i)
100 QRect last = desktop->screenGeometry(best);
101 QRect current = desktop->screenGeometry(i);
102 if (current.height()*current.width() < last.height()*last.width())
104 if (desktop->primaryScreen()==best)
113 this->setCentralWidget(
viewService()->createLayoutWidget(
this, 1));
115 viewService()->setActiveLayout(
"LAYOUT_OBLIQUE_3DAnyDual_x1", 1);
void tryShowOnSecondaryScreen()
virtual void closeEvent(QCloseEvent *event)
cxLogicManager_EXPORT ViewServicePtr viewService()
SecondaryViewLayoutWindow(QWidget *parent)
~SecondaryViewLayoutWindow()
virtual void showEvent(QShowEvent *event)
void print(QString header, QRect r)
virtual void hideEvent(QCloseEvent *event)