Allow to finely choose on which display to output

This commit is contained in:
baydam
2016-04-22 17:00:55 +00:00
parent d8d9671b6c
commit d01dd4d356
4 changed files with 93 additions and 24 deletions
+70 -12
View File
@@ -776,6 +776,33 @@ void MainWindow::paintListEditEnd(QWidget *editor)
renamePaint(getItemId(*paintList->currentItem()), name);
}
void MainWindow::setupOutputScreen()
{
QAction *actionSender = qobject_cast<QAction *>(sender());
if (actionSender)
outputWindow->setPreferredScreen(actionSender->data().toInt());
// If want that the changes take effect immediatelly
// when the output is in fullscreen mode
if (outputFullScreenAction->isChecked()) {
// XXX: Close and reopen // It's not the best way to do
outputFullScreenAction->toggle();
outputFullScreenAction->trigger();
}
}
void MainWindow::updateScreenCount()
{
// Clear action list before
if (!screenActions.isEmpty())
screenActions.clear();
// Refresh screen action
updateScreenActions();
// Update Output menu
outputMenu->clear();
addOutputMenuActions();
}
void MainWindow::openRecentFile()
{
QAction *action = qobject_cast<QAction *>(sender());
@@ -1643,9 +1670,7 @@ void MainWindow::createActions()
addAction(outputFullScreenAction);
// Manage fullscreen/modal show of GL output window.
connect(outputFullScreenAction, SIGNAL(toggled(bool)), outputWindow, SLOT(setFullScreen(bool)));
// When closing the GL output window or hit ESC key, uncheck the action in menu.
// connect(outputWindow, SIGNAL(closed()), outputFullScreenAction, SLOT(toggle()));
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), outputWindow, SLOT(updateScreenCount(int)));
connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(updateScreenCount()));
// Create hiden action for closing output window
QAction *closeOutput = new QAction(this);
closeOutput->setShortcut(Qt::Key_Escape);
@@ -1770,6 +1795,8 @@ void MainWindow::createActions()
docAction = new QAction(tr("Documentation"), this);
connect(docAction, SIGNAL(triggered()), this, SLOT(documentation()));
// All available screen as action
updateScreenActions();
}
void MainWindow::startFullScreen()
@@ -1842,10 +1869,7 @@ void MainWindow::createMenus()
// Preferences
editMenu->addAction(preferencesAction);
// View.
//viewMenu = menuBar->addMenu(tr("&View"));
// Run.
// Playback.
playbackMenu = menuBar->addMenu(tr("&Playback"));
playbackMenu->addAction(playAction);
playbackMenu->addAction(pauseAction);
@@ -1854,10 +1878,8 @@ void MainWindow::createMenus()
// Output
outputMenu = menuBar->addMenu(tr("&Output"));
outputMenu->addAction(outputFullScreenAction);
outputMenu->addSeparator();
outputMenu->addAction(displayTestSignalAction);
outputMenu->addAction(displayControlsAction);
// Add actions
addOutputMenuActions();
// Tools
toolsMenu = menuBar->addMenu(tr("&Tools"));
@@ -1874,7 +1896,6 @@ void MainWindow::createMenus()
#ifdef Q_OS_WIN
toolBarsMenu->addAction(showMenuBarAction);
#endif
windowMenu->addSeparator();
windowMenu->addAction(displayUndoStackAction);
windowMenu->addAction(displayZoomToolAction);
windowMenu->addSeparator();
@@ -2253,6 +2274,43 @@ void MainWindow::updateRecentVideoActions()
}
}
void MainWindow:: updateScreenActions()
{
// Add new action for each screen
foreach (QScreen *screen, QApplication::screens()) {
QString actionLabel = tr("%1 - %2x%3")
.arg(screen->name())
.arg(QString::number(screen->size().width()))
.arg(QString::number(screen->size().height()));
if (screen == QApplication::primaryScreen())
actionLabel.append(" - Primary");
QAction *action = new QAction(actionLabel, this);
screenActions.append(action);
action->setData(screenActions.count() - 1);
}
// Configure actions
screenActionGroup = new QActionGroup(this);
int preferredScreen = outputWindow->getPreferredScreen();
foreach (QAction *action, screenActions) {
action->setCheckable(true);
if (action == screenActions.at(preferredScreen))
action->setChecked(true);
connect(action, SIGNAL(triggered()), this, SLOT(setupOutputScreen()));
screenActionGroup->addAction(action);
}
}
void MainWindow::addOutputMenuActions()
{
outputMenu->addAction(outputFullScreenAction);
outputMenu->addActions(screenActions);
outputMenu->addSeparator();
outputMenu->addAction(displayTestSignalAction);
outputMenu->addAction(displayControlsAction);
}
void MainWindow::clearRecentFileList()
{
recentFiles = settings.value("recentFiles").toStringList();