Qt: Add toggles for toolbar/status bar

This commit is contained in:
Connor McLaughlin 2020-08-20 23:39:29 +10:00
parent c3ce9135bf
commit 5fca2d1d1c
3 changed files with 92 additions and 1 deletions

View File

@ -310,6 +310,34 @@ void MainWindow::onRemoveDiscActionTriggered()
m_host_interface->changeDisc(QString()); m_host_interface->changeDisc(QString());
} }
void MainWindow::onViewToolbarActionToggled(bool checked)
{
m_host_interface->SetBoolSettingValue("UI", "ShowToolbar", checked);
m_ui.toolBar->setVisible(checked);
}
void MainWindow::onViewStatusBarActionToggled(bool checked)
{
m_host_interface->SetBoolSettingValue("UI", "ShowStatusBar", checked);
m_ui.statusBar->setVisible(checked);
}
void MainWindow::onViewGameListActionTriggered()
{
if (m_emulation_running)
m_host_interface->pauseSystem(true);
switchToGameListView();
}
void MainWindow::onViewSystemDisplayTriggered()
{
if (m_emulation_running)
{
switchToEmulationView();
m_host_interface->pauseSystem(false);
}
}
void MainWindow::onGitHubRepositoryActionTriggered() void MainWindow::onGitHubRepositoryActionTriggered()
{ {
QtUtils::OpenURL(this, "https://github.com/stenzek/duckstation/"); QtUtils::OpenURL(this, "https://github.com/stenzek/duckstation/");
@ -431,6 +459,14 @@ void MainWindow::setupAdditionalUi()
{ {
setWindowTitle(getWindowTitle()); setWindowTitle(getWindowTitle());
const bool toolbar_visible = m_host_interface->GetBoolSettingValue("UI", "ShowToolbar", true);
m_ui.actionViewToolbar->setChecked(toolbar_visible);
m_ui.toolBar->setVisible(toolbar_visible);
const bool status_bar_visible = m_host_interface->GetBoolSettingValue("UI", "ShowStatusBar", true);
m_ui.actionViewStatusBar->setChecked(status_bar_visible);
m_ui.statusBar->setVisible(status_bar_visible);
m_game_list_widget = new GameListWidget(m_ui.mainContainer); m_game_list_widget = new GameListWidget(m_ui.mainContainer);
m_game_list_widget->initialize(m_host_interface); m_game_list_widget->initialize(m_host_interface);
m_ui.mainContainer->insertWidget(0, m_game_list_widget); m_ui.mainContainer->insertWidget(0, m_game_list_widget);
@ -509,6 +545,7 @@ void MainWindow::updateEmulationActions(bool starting, bool running)
m_ui.actionPause->setDisabled(starting || !running); m_ui.actionPause->setDisabled(starting || !running);
m_ui.actionChangeDisc->setDisabled(starting || !running); m_ui.actionChangeDisc->setDisabled(starting || !running);
m_ui.actionScreenshot->setDisabled(starting || !running); m_ui.actionScreenshot->setDisabled(starting || !running);
m_ui.actionViewSystemDisplay->setEnabled(starting || running);
m_ui.menuChangeDisc->setDisabled(starting || !running); m_ui.menuChangeDisc->setDisabled(starting || !running);
m_ui.actionSaveState->setDisabled(starting || !running); m_ui.actionSaveState->setDisabled(starting || !running);
@ -617,6 +654,10 @@ void MainWindow::connectSignals()
[this]() { doSettings(SettingsDialog::Category::AudioSettings); }); [this]() { doSettings(SettingsDialog::Category::AudioSettings); });
connect(m_ui.actionAdvancedSettings, &QAction::triggered, connect(m_ui.actionAdvancedSettings, &QAction::triggered,
[this]() { doSettings(SettingsDialog::Category::AdvancedSettings); }); [this]() { doSettings(SettingsDialog::Category::AdvancedSettings); });
connect(m_ui.actionViewToolbar, &QAction::toggled, this, &MainWindow::onViewToolbarActionToggled);
connect(m_ui.actionViewStatusBar, &QAction::toggled, this, &MainWindow::onViewStatusBarActionToggled);
connect(m_ui.actionViewGameList, &QAction::triggered, this, &MainWindow::onViewGameListActionTriggered);
connect(m_ui.actionViewSystemDisplay, &QAction::triggered, this, &MainWindow::onViewSystemDisplayTriggered);
connect(m_ui.actionGitHubRepository, &QAction::triggered, this, &MainWindow::onGitHubRepositoryActionTriggered); connect(m_ui.actionGitHubRepository, &QAction::triggered, this, &MainWindow::onGitHubRepositoryActionTriggered);
connect(m_ui.actionIssueTracker, &QAction::triggered, this, &MainWindow::onIssueTrackerActionTriggered); connect(m_ui.actionIssueTracker, &QAction::triggered, this, &MainWindow::onIssueTrackerActionTriggered);
connect(m_ui.actionDiscordServer, &QAction::triggered, this, &MainWindow::onDiscordServerActionTriggered); connect(m_ui.actionDiscordServer, &QAction::triggered, this, &MainWindow::onDiscordServerActionTriggered);

View File

@ -62,6 +62,10 @@ private Q_SLOTS:
void onChangeDiscFromPlaylistMenuAboutToShow(); void onChangeDiscFromPlaylistMenuAboutToShow();
void onChangeDiscFromPlaylistMenuAboutToHide(); void onChangeDiscFromPlaylistMenuAboutToHide();
void onRemoveDiscActionTriggered(); void onRemoveDiscActionTriggered();
void onViewToolbarActionToggled(bool checked);
void onViewStatusBarActionToggled(bool checked);
void onViewGameListActionTriggered();
void onViewSystemDisplayTriggered();
void onGitHubRepositoryActionTriggered(); void onGitHubRepositoryActionTriggered();
void onIssueTrackerActionTriggered(); void onIssueTrackerActionTriggered();
void onDiscordServerActionTriggered(); void onDiscordServerActionTriggered();

View File

@ -30,7 +30,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>754</width> <width>754</width>
<height>22</height> <height>30</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuSystem"> <widget class="QMenu" name="menuSystem">
@ -161,8 +161,19 @@
<addaction name="actionDebugShowTimersState"/> <addaction name="actionDebugShowTimersState"/>
<addaction name="actionDebugShowMDECState"/> <addaction name="actionDebugShowMDECState"/>
</widget> </widget>
<widget class="QMenu" name="menu_View">
<property name="title">
<string>&amp;View</string>
</property>
<addaction name="actionViewToolbar"/>
<addaction name="actionViewStatusBar"/>
<addaction name="separator"/>
<addaction name="actionViewGameList"/>
<addaction name="actionViewSystemDisplay"/>
</widget>
<addaction name="menuSystem"/> <addaction name="menuSystem"/>
<addaction name="menuSettings"/> <addaction name="menuSettings"/>
<addaction name="menu_View"/>
<addaction name="menuDebug"/> <addaction name="menuDebug"/>
<addaction name="menuHelp"/> <addaction name="menuHelp"/>
</widget> </widget>
@ -560,6 +571,41 @@
<string>Resumes the last save state created.</string> <string>Resumes the last save state created.</string>
</property> </property>
</action> </action>
<action name="actionViewToolbar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Toolbar</string>
</property>
</action>
<action name="actionViewStatusBar">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Status Bar</string>
</property>
</action>
<action name="actionViewGameList">
<property name="text">
<string>&amp;Game List</string>
</property>
</action>
<action name="actionViewSystemDisplay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>System &amp;Display</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="resources/icons.qrc"/> <include location="resources/icons.qrc"/>