mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 16:15:45 -04:00
Qt: Add copy/clear game settings
This commit is contained in:
@ -2737,7 +2737,7 @@ bool MainWindow::requestShutdown(bool allow_confirm /* = true */, bool allow_sav
|
||||
save_state &= allow_save_to_state;
|
||||
|
||||
// Only confirm on UI thread because we need to display a msgbox.
|
||||
if (!m_is_closing && allow_confirm && g_settings.confim_power_off)
|
||||
if (!m_is_closing && allow_confirm && Host::GetBaseBoolSettingValue("Main", "ConfirmPowerOff", true))
|
||||
{
|
||||
SystemLock lock(pauseAndLockSystem());
|
||||
|
||||
|
@ -43,10 +43,11 @@ SettingsWindow::SettingsWindow() : QWidget()
|
||||
m_ui.setupUi(this);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
addPages();
|
||||
connectUi();
|
||||
}
|
||||
|
||||
SettingsWindow::SettingsWindow(const std::string& path, const std::string& serial, DiscRegion region,
|
||||
const GameDatabase::Entry* entry, std::unique_ptr<SettingsInterface> sif)
|
||||
const GameDatabase::Entry* entry, std::unique_ptr<INISettingsInterface> sif)
|
||||
: QWidget(), m_sif(std::move(sif))
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
@ -57,6 +58,7 @@ SettingsWindow::SettingsWindow(const std::string& path, const std::string& seria
|
||||
tr("<strong>Summary</strong><hr>This page shows information about the selected game, and allows you to "
|
||||
"validate your disc was dumped correctly."));
|
||||
addPages();
|
||||
connectUi();
|
||||
|
||||
s_open_game_properties_dialogs.push_back(this);
|
||||
}
|
||||
@ -167,10 +169,41 @@ void SettingsWindow::addPages()
|
||||
|
||||
connect(m_advanced_settings, &AdvancedSettingsWidget::onShowDebugOptionsChanged, m_graphics_settings,
|
||||
&GraphicsSettingsWidget::onShowDebugSettingsChanged);
|
||||
}
|
||||
|
||||
void SettingsWindow::reloadPages()
|
||||
{
|
||||
const int min_count = isPerGameSettings() ? 1 : 0;
|
||||
while (m_ui.settingsContainer->count() > min_count)
|
||||
{
|
||||
const int row = m_ui.settingsContainer->count() - 1;
|
||||
|
||||
delete m_ui.settingsCategory->takeItem(row);
|
||||
|
||||
QWidget* widget = m_ui.settingsContainer->widget(row);
|
||||
m_ui.settingsContainer->removeWidget(widget);
|
||||
delete widget;
|
||||
}
|
||||
|
||||
addPages();
|
||||
}
|
||||
|
||||
void SettingsWindow::connectUi()
|
||||
{
|
||||
if (isPerGameSettings())
|
||||
{
|
||||
m_ui.buttonBox->button(QDialogButtonBox::RestoreDefaults)->setVisible(false);
|
||||
m_ui.footerLayout->removeWidget(m_ui.restoreDefaults);
|
||||
m_ui.restoreDefaults->deleteLater();
|
||||
m_ui.restoreDefaults = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui.footerLayout->removeWidget(m_ui.copyGlobalSettings);
|
||||
m_ui.copyGlobalSettings->deleteLater();
|
||||
m_ui.copyGlobalSettings = nullptr;
|
||||
m_ui.footerLayout->removeWidget(m_ui.clearGameSettings);
|
||||
m_ui.clearGameSettings->deleteLater();
|
||||
m_ui.clearGameSettings = nullptr;
|
||||
}
|
||||
|
||||
m_ui.settingsCategory->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
@ -178,9 +211,13 @@ void SettingsWindow::addPages()
|
||||
m_ui.settingsContainer->setCurrentIndex(0);
|
||||
m_ui.helpText->setText(m_category_help_text[0]);
|
||||
connect(m_ui.settingsCategory, &QListWidget::currentRowChanged, this, &SettingsWindow::onCategoryCurrentRowChanged);
|
||||
connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &SettingsWindow::close);
|
||||
connect(m_ui.buttonBox->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this,
|
||||
&SettingsWindow::onRestoreDefaultsClicked);
|
||||
connect(m_ui.close, &QPushButton::clicked, this, &SettingsWindow::close);
|
||||
if (m_ui.restoreDefaults)
|
||||
connect(m_ui.restoreDefaults, &QPushButton::clicked, this, &SettingsWindow::onRestoreDefaultsClicked);
|
||||
if (m_ui.copyGlobalSettings)
|
||||
connect(m_ui.copyGlobalSettings, &QPushButton::clicked, this, &SettingsWindow::onCopyGlobalSettingsClicked);
|
||||
if (m_ui.clearGameSettings)
|
||||
connect(m_ui.clearGameSettings, &QPushButton::clicked, this, &SettingsWindow::onClearSettingsClicked);
|
||||
}
|
||||
|
||||
void SettingsWindow::addWidget(QWidget* widget, QString title, QString icon, QString help_text)
|
||||
@ -232,6 +269,56 @@ void SettingsWindow::onRestoreDefaultsClicked()
|
||||
g_emu_thread->setDefaultSettings(true, false);
|
||||
}
|
||||
|
||||
void SettingsWindow::onCopyGlobalSettingsClicked()
|
||||
{
|
||||
if (!isPerGameSettings())
|
||||
return;
|
||||
|
||||
if (QMessageBox::question(
|
||||
this, tr("DuckStation Settings"),
|
||||
tr("The configuration for this game will be replaced by the current global settings.\n\nAny current setting "
|
||||
"values will be overwritten.\n\nDo you want to continue?"),
|
||||
QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
auto lock = Host::GetSettingsLock();
|
||||
Settings temp;
|
||||
temp.Load(*Host::Internal::GetBaseSettingsLayer());
|
||||
temp.Save(*m_sif.get(), true);
|
||||
}
|
||||
m_sif->Save();
|
||||
g_emu_thread->reloadGameSettings();
|
||||
|
||||
reloadPages();
|
||||
|
||||
QMessageBox::information(this, tr("DuckStation Settings"), tr("Per-game configuration copied from global settings."));
|
||||
}
|
||||
|
||||
void SettingsWindow::onClearSettingsClicked()
|
||||
{
|
||||
if (!isPerGameSettings())
|
||||
return;
|
||||
|
||||
if (QMessageBox::question(this, tr("DuckStation Settings"),
|
||||
tr("The configuration for this game will be cleared.\n\nAny current setting values will be "
|
||||
"lost.\n\nDo you want to continue?"),
|
||||
QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Settings::Clear(*m_sif.get());
|
||||
m_sif->Save();
|
||||
g_emu_thread->reloadGameSettings();
|
||||
|
||||
reloadPages();
|
||||
|
||||
QMessageBox::information(this, tr("DuckStation Settings"), tr("Per-game configuration cleared."));
|
||||
}
|
||||
|
||||
void SettingsWindow::registerWidgetHelp(QObject* object, QString title, QString recommended_value, QString text)
|
||||
{
|
||||
// construct rich text with formatted description
|
||||
|
@ -4,6 +4,8 @@
|
||||
#pragma once
|
||||
#include "ui_settingswindow.h"
|
||||
|
||||
#include "util/ini_settings_interface.h"
|
||||
|
||||
#include "common/types.h"
|
||||
|
||||
#include <QtCore/QMap>
|
||||
@ -13,8 +15,6 @@
|
||||
|
||||
class QWheelEvent;
|
||||
|
||||
class SettingsInterface;
|
||||
|
||||
enum class DiscRegion : u8;
|
||||
|
||||
namespace GameDatabase {
|
||||
@ -41,7 +41,7 @@ class SettingsWindow final : public QWidget
|
||||
public:
|
||||
SettingsWindow();
|
||||
SettingsWindow(const std::string& path, const std::string& serial, DiscRegion region,
|
||||
const GameDatabase::Entry* entry, std::unique_ptr<SettingsInterface> sif);
|
||||
const GameDatabase::Entry* entry, std::unique_ptr<INISettingsInterface> sif);
|
||||
~SettingsWindow();
|
||||
|
||||
static void openGamePropertiesDialog(const std::string& path, const std::string& serial, DiscRegion region);
|
||||
@ -51,7 +51,7 @@ public:
|
||||
static bool setGameSettingsBoolForSerial(const std::string& serial, const char* section, const char* key, bool value);
|
||||
|
||||
ALWAYS_INLINE bool isPerGameSettings() const { return static_cast<bool>(m_sif); }
|
||||
ALWAYS_INLINE SettingsInterface* getSettingsInterface() const { return m_sif.get(); }
|
||||
ALWAYS_INLINE INISettingsInterface* getSettingsInterface() const { return m_sif.get(); }
|
||||
|
||||
ALWAYS_INLINE InterfaceSettingsWidget* getGeneralSettingsWidget() const { return m_general_settings; }
|
||||
ALWAYS_INLINE BIOSSettingsWidget* getBIOSSettingsWidget() const { return m_bios_settings; }
|
||||
@ -98,6 +98,8 @@ public Q_SLOTS:
|
||||
private Q_SLOTS:
|
||||
void onCategoryCurrentRowChanged(int row);
|
||||
void onRestoreDefaultsClicked();
|
||||
void onCopyGlobalSettingsClicked();
|
||||
void onClearSettingsClicked();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
@ -109,13 +111,16 @@ private:
|
||||
MAX_SETTINGS_WIDGETS = 12
|
||||
};
|
||||
|
||||
void connectUi();
|
||||
void addPages();
|
||||
void reloadPages();
|
||||
|
||||
void addWidget(QWidget* widget, QString title, QString icon, QString help_text);
|
||||
bool handleWheelEvent(QWheelEvent* event);
|
||||
|
||||
Ui::SettingsWindow m_ui;
|
||||
|
||||
std::unique_ptr<SettingsInterface> m_sif;
|
||||
std::unique_ptr<INISettingsInterface> m_sif;
|
||||
|
||||
InterfaceSettingsWidget* m_general_settings = nullptr;
|
||||
BIOSSettingsWidget* m_bios_settings = nullptr;
|
||||
@ -134,4 +139,6 @@ private:
|
||||
|
||||
QObject* m_current_help_widget = nullptr;
|
||||
QMap<QObject*, QString> m_widget_help_text_map;
|
||||
|
||||
std::string m_game_list_filename;
|
||||
};
|
||||
|
@ -24,16 +24,6 @@
|
||||
<normaloff>:/icons/duck.png</normaloff>:/icons/duck.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QStackedWidget" name="settingsContainer">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="settingsCategory">
|
||||
<property name="sizePolicy">
|
||||
@ -62,10 +52,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close|QDialogButtonBox::RestoreDefaults</set>
|
||||
<item row="0" column="1">
|
||||
<widget class="QStackedWidget" name="settingsContainer">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -88,6 +81,51 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="footerLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="restoreDefaults">
|
||||
<property name="text">
|
||||
<string>Restore Defaults</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="copyGlobalSettings">
|
||||
<property name="text">
|
||||
<string>Copy Global Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearGameSettings">
|
||||
<property name="text">
|
||||
<string>Clear Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="close">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
|
Reference in New Issue
Block a user