mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-28 14:20:30 +00:00
Qt: Add additional toolbar properties for labels/icons
This commit is contained in:
parent
bf36432432
commit
ee0cb6076c
@ -172,6 +172,7 @@ void MainWindow::initialize()
|
|||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
setupAdditionalUi();
|
setupAdditionalUi();
|
||||||
updateToolbarActions();
|
updateToolbarActions();
|
||||||
|
updateToolbarIconStyle();
|
||||||
updateEmulationActions(false, false, false);
|
updateEmulationActions(false, false, false);
|
||||||
connectSignals();
|
connectSignals();
|
||||||
|
|
||||||
@ -1308,11 +1309,48 @@ void MainWindow::onViewToolbarActionToggled(bool checked)
|
|||||||
m_ui.toolBar->setVisible(checked);
|
m_ui.toolBar->setVisible(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onViewLockToolbarActionToggled(bool checked)
|
void MainWindow::onViewToolbarLockActionToggled(bool checked)
|
||||||
{
|
{
|
||||||
Host::SetBaseBoolSettingValue("UI", "LockToolbar", checked);
|
Host::SetBaseBoolSettingValue("UI", "LockToolbar", !checked);
|
||||||
Host::CommitBaseSettingChanges();
|
Host::CommitBaseSettingChanges();
|
||||||
m_ui.toolBar->setMovable(!checked);
|
m_ui.toolBar->setMovable(!checked);
|
||||||
|
|
||||||
|
// ensure synced
|
||||||
|
const QSignalBlocker sb(m_ui.actionViewLockToolbar);
|
||||||
|
m_ui.actionViewLockToolbar->setChecked(checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onViewToolbarSmallIconsActionToggled(bool checked)
|
||||||
|
{
|
||||||
|
Host::SetBaseBoolSettingValue("UI", "ToolbarSmallIcons", checked);
|
||||||
|
Host::CommitBaseSettingChanges();
|
||||||
|
updateToolbarIconStyle();
|
||||||
|
|
||||||
|
// ensure synced
|
||||||
|
const QSignalBlocker sb(m_ui.actionViewSmallToolbarIcons);
|
||||||
|
m_ui.actionViewSmallToolbarIcons->setChecked(checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onViewToolbarLabelsActionToggled(bool checked)
|
||||||
|
{
|
||||||
|
Host::SetBaseBoolSettingValue("UI", "ToolbarLabels", checked);
|
||||||
|
Host::CommitBaseSettingChanges();
|
||||||
|
updateToolbarIconStyle();
|
||||||
|
|
||||||
|
// ensure synced
|
||||||
|
const QSignalBlocker sb(m_ui.actionViewToolbarLabels);
|
||||||
|
m_ui.actionViewToolbarLabels->setChecked(checked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onViewToolbarLabelsBesideIconsActionToggled(bool checked)
|
||||||
|
{
|
||||||
|
Host::SetBaseBoolSettingValue("UI", "ToolbarLabelsBesideIcons", checked);
|
||||||
|
Host::CommitBaseSettingChanges();
|
||||||
|
updateToolbarIconStyle();
|
||||||
|
|
||||||
|
// ensure synced
|
||||||
|
const QSignalBlocker sb(m_ui.actionViewToolbarLabelsBesidesText);
|
||||||
|
m_ui.actionViewToolbarLabelsBesidesText->setChecked(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onViewStatusBarActionToggled(bool checked)
|
void MainWindow::onViewStatusBarActionToggled(bool checked)
|
||||||
@ -1672,6 +1710,11 @@ void MainWindow::setupAdditionalUi()
|
|||||||
m_ui.actionViewLockToolbar->setChecked(toolbars_locked);
|
m_ui.actionViewLockToolbar->setChecked(toolbars_locked);
|
||||||
m_ui.toolBar->setMovable(!toolbars_locked);
|
m_ui.toolBar->setMovable(!toolbars_locked);
|
||||||
|
|
||||||
|
m_ui.actionViewSmallToolbarIcons->setChecked(Host::GetBaseBoolSettingValue("UI", "ToolbarSmallIcons", false));
|
||||||
|
m_ui.actionViewToolbarLabels->setChecked(Host::GetBaseBoolSettingValue("UI", "ToolbarLabels", true));
|
||||||
|
m_ui.actionViewToolbarLabelsBesidesText->setChecked(
|
||||||
|
Host::GetBaseBoolSettingValue("UI", "ToolbarLabelsBesideIcons", false));
|
||||||
|
|
||||||
m_game_list_widget = new GameListWidget(m_ui.mainContainer);
|
m_game_list_widget = new GameListWidget(m_ui.mainContainer);
|
||||||
m_game_list_widget->initialize();
|
m_game_list_widget->initialize();
|
||||||
m_ui.mainContainer->addWidget(m_game_list_widget);
|
m_ui.mainContainer->addWidget(m_game_list_widget);
|
||||||
@ -1768,6 +1811,27 @@ void MainWindow::updateToolbarActions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateToolbarIconStyle()
|
||||||
|
{
|
||||||
|
const bool show_labels = Host::GetBaseBoolSettingValue("UI", "ToolbarLabels", true);
|
||||||
|
const bool small_icons = Host::GetBaseBoolSettingValue("UI", "ToolbarSmallIcons", false);
|
||||||
|
const bool labels_beside_icons = Host::GetBaseBoolSettingValue("UI", "ToolbarLabelsBesideIcons", false);
|
||||||
|
|
||||||
|
Qt::ToolButtonStyle style;
|
||||||
|
if (!show_labels)
|
||||||
|
style = Qt::ToolButtonIconOnly;
|
||||||
|
else if (labels_beside_icons)
|
||||||
|
style = Qt::ToolButtonTextBesideIcon;
|
||||||
|
else
|
||||||
|
style = Qt::ToolButtonTextUnderIcon;
|
||||||
|
if (m_ui.toolBar->toolButtonStyle() != style)
|
||||||
|
m_ui.toolBar->setToolButtonStyle(style);
|
||||||
|
|
||||||
|
const QSize icon_size = QSize(small_icons ? 16 : 32, small_icons ? 16 : 32);
|
||||||
|
if (m_ui.toolBar->iconSize() != icon_size)
|
||||||
|
m_ui.toolBar->setIconSize(icon_size);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onToolbarContextMenuRequested(const QPoint& pos)
|
void MainWindow::onToolbarContextMenuRequested(const QPoint& pos)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -1778,6 +1842,28 @@ void MainWindow::onToolbarContextMenuRequested(const QPoint& pos)
|
|||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
||||||
|
QAction* action = menu.addAction(tr("Lock Toolbar"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(m_ui.toolBar->isMovable());
|
||||||
|
connect(action, &QAction::toggled, this, &MainWindow::onViewToolbarLockActionToggled);
|
||||||
|
|
||||||
|
action = menu.addAction(tr("Small Icons"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(Host::GetBaseBoolSettingValue("UI", "ToolbarSmallIcons", false));
|
||||||
|
connect(action, &QAction::toggled, this, &MainWindow::onViewToolbarSmallIconsActionToggled);
|
||||||
|
|
||||||
|
action = menu.addAction(tr("Show Labels"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(Host::GetBaseBoolSettingValue("UI", "ToolbarLabels", true));
|
||||||
|
connect(action, &QAction::toggled, this, &MainWindow::onViewToolbarLabelsActionToggled);
|
||||||
|
|
||||||
|
action = menu.addAction(tr("Labels Beside Icons"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(Host::GetBaseBoolSettingValue("UI", "ToolbarLabelsBesideIcons", false));
|
||||||
|
connect(action, &QAction::toggled, this, &MainWindow::onViewToolbarLabelsBesideIconsActionToggled);
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
for (const auto& [name, action_ptr] : s_toolbar_actions)
|
for (const auto& [name, action_ptr] : s_toolbar_actions)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
@ -1786,8 +1872,7 @@ void MainWindow::onToolbarContextMenuRequested(const QPoint& pos)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* action = (m_ui.*action_ptr);
|
QAction* menu_action = menu.addAction((m_ui.*action_ptr)->text());
|
||||||
QAction* menu_action = menu.addAction(action->text());
|
|
||||||
menu_action->setCheckable(true);
|
menu_action->setCheckable(true);
|
||||||
menu_action->setChecked(StringUtil::IsInStringList(active_buttons, name));
|
menu_action->setChecked(StringUtil::IsInStringList(active_buttons, name));
|
||||||
connect(menu_action, &QAction::toggled, this, [&active_buttons, &active_buttons_changed, name](bool checked) {
|
connect(menu_action, &QAction::toggled, this, [&active_buttons, &active_buttons_changed, name](bool checked) {
|
||||||
@ -1801,12 +1886,12 @@ void MainWindow::onToolbarContextMenuRequested(const QPoint& pos)
|
|||||||
|
|
||||||
menu.exec(m_ui.toolBar->mapToGlobal(pos));
|
menu.exec(m_ui.toolBar->mapToGlobal(pos));
|
||||||
|
|
||||||
if (!active_buttons_changed)
|
if (active_buttons_changed)
|
||||||
return;
|
{
|
||||||
|
|
||||||
Host::SetBaseStringSettingValue("UI", "ToolbarButtons", StringUtil::JoinString(active_buttons, ',').c_str());
|
Host::SetBaseStringSettingValue("UI", "ToolbarButtons", StringUtil::JoinString(active_buttons, ',').c_str());
|
||||||
Host::CommitBaseSettingChanges();
|
Host::CommitBaseSettingChanges();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateToolbarActions();
|
updateToolbarActions();
|
||||||
}
|
}
|
||||||
@ -2107,7 +2192,11 @@ void MainWindow::connectSignals()
|
|||||||
connect(m_ui.actionAdvancedSettings, &QAction::triggered, [this]() { doSettings("Advanced"); });
|
connect(m_ui.actionAdvancedSettings, &QAction::triggered, [this]() { doSettings("Advanced"); });
|
||||||
connect(m_ui.actionControllerProfiles, &QAction::triggered, this, &MainWindow::onSettingsControllerProfilesTriggered);
|
connect(m_ui.actionControllerProfiles, &QAction::triggered, this, &MainWindow::onSettingsControllerProfilesTriggered);
|
||||||
connect(m_ui.actionViewToolbar, &QAction::toggled, this, &MainWindow::onViewToolbarActionToggled);
|
connect(m_ui.actionViewToolbar, &QAction::toggled, this, &MainWindow::onViewToolbarActionToggled);
|
||||||
connect(m_ui.actionViewLockToolbar, &QAction::toggled, this, &MainWindow::onViewLockToolbarActionToggled);
|
connect(m_ui.actionViewLockToolbar, &QAction::toggled, this, &MainWindow::onViewToolbarLockActionToggled);
|
||||||
|
connect(m_ui.actionViewSmallToolbarIcons, &QAction::toggled, this, &MainWindow::onViewToolbarSmallIconsActionToggled);
|
||||||
|
connect(m_ui.actionViewToolbarLabels, &QAction::toggled, this, &MainWindow::onViewToolbarLabelsActionToggled);
|
||||||
|
connect(m_ui.actionViewToolbarLabelsBesidesText, &QAction::toggled, this,
|
||||||
|
&MainWindow::onViewToolbarLabelsBesideIconsActionToggled);
|
||||||
connect(m_ui.actionViewStatusBar, &QAction::toggled, this, &MainWindow::onViewStatusBarActionToggled);
|
connect(m_ui.actionViewStatusBar, &QAction::toggled, this, &MainWindow::onViewStatusBarActionToggled);
|
||||||
connect(m_ui.actionViewGameList, &QAction::triggered, this, &MainWindow::onViewGameListActionTriggered);
|
connect(m_ui.actionViewGameList, &QAction::triggered, this, &MainWindow::onViewGameListActionTriggered);
|
||||||
connect(m_ui.actionViewGameGrid, &QAction::triggered, this, &MainWindow::onViewGameGridActionTriggered);
|
connect(m_ui.actionViewGameGrid, &QAction::triggered, this, &MainWindow::onViewGameGridActionTriggered);
|
||||||
|
@ -182,7 +182,10 @@ private Q_SLOTS:
|
|||||||
void onRemoveDiscActionTriggered();
|
void onRemoveDiscActionTriggered();
|
||||||
void onScanForNewGamesTriggered();
|
void onScanForNewGamesTriggered();
|
||||||
void onViewToolbarActionToggled(bool checked);
|
void onViewToolbarActionToggled(bool checked);
|
||||||
void onViewLockToolbarActionToggled(bool checked);
|
void onViewToolbarLockActionToggled(bool checked);
|
||||||
|
void onViewToolbarSmallIconsActionToggled(bool checked);
|
||||||
|
void onViewToolbarLabelsActionToggled(bool checked);
|
||||||
|
void onViewToolbarLabelsBesideIconsActionToggled(bool checked);
|
||||||
void onViewStatusBarActionToggled(bool checked);
|
void onViewStatusBarActionToggled(bool checked);
|
||||||
void onViewGameListActionTriggered();
|
void onViewGameListActionTriggered();
|
||||||
void onViewGameGridActionTriggered();
|
void onViewGameGridActionTriggered();
|
||||||
@ -238,6 +241,7 @@ private:
|
|||||||
void connectSignals();
|
void connectSignals();
|
||||||
|
|
||||||
void updateToolbarActions();
|
void updateToolbarActions();
|
||||||
|
void updateToolbarIconStyle();
|
||||||
void updateEmulationActions(bool starting, bool running, bool cheevos_challenge_mode);
|
void updateEmulationActions(bool starting, bool running, bool cheevos_challenge_mode);
|
||||||
void updateShortcutActions(bool starting);
|
void updateShortcutActions(bool starting);
|
||||||
void updateStatusBarWidgetVisibility();
|
void updateStatusBarWidgetVisibility();
|
||||||
|
@ -198,6 +198,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionViewToolbar"/>
|
<addaction name="actionViewToolbar"/>
|
||||||
<addaction name="actionViewLockToolbar"/>
|
<addaction name="actionViewLockToolbar"/>
|
||||||
|
<addaction name="actionViewSmallToolbarIcons"/>
|
||||||
|
<addaction name="actionViewToolbarLabels"/>
|
||||||
|
<addaction name="actionViewToolbarLabelsBesidesText"/>
|
||||||
<addaction name="actionViewStatusBar"/>
|
<addaction name="actionViewStatusBar"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionViewGameList"/>
|
<addaction name="actionViewGameList"/>
|
||||||
@ -746,6 +749,30 @@
|
|||||||
<string>Lock Toolbar</string>
|
<string>Lock Toolbar</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionViewSmallToolbarIcons">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Small Toolbar Icons</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionViewToolbarLabels">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Toolbar Labels</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionViewToolbarLabelsBesidesText">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Toolbar Labels Besides Text</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="actionViewStatusBar">
|
<action name="actionViewStatusBar">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user