citra-qt : Adding fullscreen mode

This commit is contained in:
Yacine 2017-10-11 20:21:09 +02:00
parent 74d4050924
commit e3d9e6c802
5 changed files with 57 additions and 2 deletions

View file

@ -198,6 +198,7 @@ void Config::ReadValues() {
qt_config->endGroup(); qt_config->endGroup();
UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool();
UISettings::values.fullscreen = qt_config->value("fullscreen", false).toBool();
UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool();
UISettings::values.show_filter_bar = qt_config->value("showFilterBar", true).toBool(); UISettings::values.show_filter_bar = qt_config->value("showFilterBar", true).toBool();
UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool(); UISettings::values.show_status_bar = qt_config->value("showStatusBar", true).toBool();
@ -331,6 +332,7 @@ void Config::SaveValues() {
qt_config->endGroup(); qt_config->endGroup();
qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode);
qt_config->setValue("fullscreen", UISettings::values.fullscreen);
qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar);
qt_config->setValue("showFilterBar", UISettings::values.show_filter_bar); qt_config->setValue("showFilterBar", UISettings::values.show_filter_bar);
qt_config->setValue("showStatusBar", UISettings::values.show_status_bar); qt_config->setValue("showStatusBar", UISettings::values.show_status_bar);

View file

@ -244,6 +244,8 @@ void GMainWindow::InitializeHotkeys() {
RegisterHotkey("Main Window", "Load File", QKeySequence::Open); RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
RegisterHotkey("Main Window", "Swap Screens", QKeySequence::NextChild); RegisterHotkey("Main Window", "Swap Screens", QKeySequence::NextChild);
RegisterHotkey("Main Window", "Start Emulation"); RegisterHotkey("Main Window", "Start Emulation");
RegisterHotkey("Main Window", "Fullscreen", QKeySequence::FullScreen);
RegisterHotkey("Main Window", "Exit Fullscreen", QKeySequence::Cancel, Qt::ApplicationShortcut);
LoadHotkeys(); LoadHotkeys();
connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this,
@ -252,6 +254,16 @@ void GMainWindow::InitializeHotkeys() {
SLOT(OnStartGame())); SLOT(OnStartGame()));
connect(GetHotkey("Main Window", "Swap Screens", render_window), SIGNAL(activated()), this, connect(GetHotkey("Main Window", "Swap Screens", render_window), SIGNAL(activated()), this,
SLOT(OnSwapScreens())); SLOT(OnSwapScreens()));
connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activated,
ui.action_Fullscreen, &QAction::trigger);
connect(GetHotkey("Main Window", "Fullscreen", render_window), &QShortcut::activatedAmbiguously,
ui.action_Fullscreen, &QAction::trigger);
connect(GetHotkey("Main Window", "Exit Fullscreen", this), &QShortcut::activated, this, [&] {
if (emulation_running) {
ui.action_Fullscreen->setChecked(false);
ToggleFullscreen();
}
});
} }
void GMainWindow::SetDefaultUIGeometry() { void GMainWindow::SetDefaultUIGeometry() {
@ -280,6 +292,8 @@ void GMainWindow::RestoreUIState() {
ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode); ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode);
ToggleWindowMode(); ToggleWindowMode();
ui.action_Fullscreen->setChecked(UISettings::values.fullscreen);
ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar); ui.action_Display_Dock_Widget_Headers->setChecked(UISettings::values.display_titlebar);
OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked()); OnDisplayTitleBars(ui.action_Display_Dock_Widget_Headers->isChecked());
@ -323,6 +337,8 @@ void GMainWindow::ConnectMenuEvents() {
ui.action_Show_Filter_Bar->setShortcut(tr("CTRL+F")); ui.action_Show_Filter_Bar->setShortcut(tr("CTRL+F"));
connect(ui.action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar); connect(ui.action_Show_Filter_Bar, &QAction::triggered, this, &GMainWindow::OnToggleFilterBar);
connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible); connect(ui.action_Show_Status_Bar, &QAction::triggered, statusBar(), &QStatusBar::setVisible);
ui.action_Fullscreen->setShortcut(GetHotkey("Main Window", "Fullscreen", this)->key());
connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen);
} }
void GMainWindow::OnDisplayTitleBars(bool show) { void GMainWindow::OnDisplayTitleBars(bool show) {
@ -460,6 +476,7 @@ void GMainWindow::BootGame(const QString& filename) {
render_window->setFocus(); render_window->setFocus();
emulation_running = true; emulation_running = true;
ToggleFullscreen();
OnStartGame(); OnStartGame();
} }
@ -624,6 +641,29 @@ void GMainWindow::OnStopGame() {
ShutdownGame(); ShutdownGame();
} }
void GMainWindow::ToggleFullscreen() {
if (!emulation_running) {
return;
}
if (ui.action_Fullscreen->isChecked()) {
if (ui.action_Single_Window_Mode->isChecked()) {
ui.menubar->hide();
statusBar()->hide();
showFullScreen();
} else {
render_window->showFullScreen();
}
} else {
if (ui.action_Single_Window_Mode->isChecked()) {
statusBar()->setVisible(ui.action_Show_Status_Bar->isChecked());
ui.menubar->show();
showNormal();
} else {
render_window->showNormal();
}
}
}
void GMainWindow::ToggleWindowMode() { void GMainWindow::ToggleWindowMode() {
if (ui.action_Single_Window_Mode->isChecked()) { if (ui.action_Single_Window_Mode->isChecked()) {
// Render in the main window... // Render in the main window...
@ -784,6 +824,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
UISettings::values.microprofile_visible = microProfileDialog->isVisible(); UISettings::values.microprofile_visible = microProfileDialog->isVisible();
#endif #endif
UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked();
UISettings::values.fullscreen = ui.action_Fullscreen->isChecked();
UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked(); UISettings::values.display_titlebar = ui.action_Display_Dock_Widget_Headers->isChecked();
UISettings::values.show_filter_bar = ui.action_Show_Filter_Bar->isChecked(); UISettings::values.show_filter_bar = ui.action_Show_Filter_Bar->isChecked();
UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked(); UISettings::values.show_status_bar = ui.action_Show_Status_Bar->isChecked();

View file

@ -127,6 +127,7 @@ private slots:
void OnConfigure(); void OnConfigure();
void OnToggleFilterBar(); void OnToggleFilterBar();
void OnDisplayTitleBars(bool); void OnDisplayTitleBars(bool);
void ToggleFullscreen();
void ToggleWindowMode(); void ToggleWindowMode();
void OnCreateGraphicsSurfaceViewer(); void OnCreateGraphicsSurfaceViewer();
void OnCoreError(Core::System::ResultStatus, std::string); void OnCoreError(Core::System::ResultStatus, std::string);

View file

@ -45,7 +45,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1081</width> <width>1081</width>
<height>19</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menu_File"> <widget class="QMenu" name="menu_File">
@ -85,6 +85,7 @@
<addaction name="action_Create_Pica_Surface_Viewer"/> <addaction name="action_Create_Pica_Surface_Viewer"/>
<addaction name="separator"/> <addaction name="separator"/>
</widget> </widget>
<addaction name="action_Fullscreen"/>
<addaction name="action_Single_Window_Mode"/> <addaction name="action_Single_Window_Mode"/>
<addaction name="action_Display_Dock_Widget_Headers"/> <addaction name="action_Display_Dock_Widget_Headers"/>
<addaction name="action_Show_Filter_Bar"/> <addaction name="action_Show_Filter_Bar"/>
@ -196,6 +197,14 @@
<string>Create Pica Surface Viewer</string> <string>Create Pica Surface Viewer</string>
</property> </property>
</action> </action>
<action name="action_Fullscreen">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Fullscreen</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
</ui> </ui>

View file

@ -31,6 +31,7 @@ struct Values {
bool microprofile_visible; bool microprofile_visible;
bool single_window_mode; bool single_window_mode;
bool fullscreen;
bool display_titlebar; bool display_titlebar;
bool show_filter_bar; bool show_filter_bar;
bool show_status_bar; bool show_status_bar;
@ -53,4 +54,5 @@ struct Values {
}; };
extern Values values; extern Values values;
}
} // namespace UISettings