mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-14 08:12:16 +00:00
QT: Various interface fixes (#2496)
* QT: Various interface fixes * fix close without saving * + * + using the save and close buttons, everything works fine, but when using the X button it doesn't work very well... * fix close (X) without saving
This commit is contained in:
parent
22ca57b1f2
commit
e1ae052185
5 changed files with 70 additions and 5 deletions
|
@ -26,8 +26,10 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <common/logging/log.h>
|
|
||||||
#include "cheats_patches.h"
|
#include "cheats_patches.h"
|
||||||
|
#include "common/config.h"
|
||||||
|
#include "common/logging/log.h"
|
||||||
#include "common/memory_patcher.h"
|
#include "common/memory_patcher.h"
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "core/module.h"
|
#include "core/module.h"
|
||||||
|
@ -92,7 +94,7 @@ void CheatsPatches::setupUI() {
|
||||||
gameVersionLabel->setAlignment(Qt::AlignLeft);
|
gameVersionLabel->setAlignment(Qt::AlignLeft);
|
||||||
gameInfoLayout->addWidget(gameVersionLabel);
|
gameInfoLayout->addWidget(gameVersionLabel);
|
||||||
|
|
||||||
if (m_gameSize.left(4) != "0.00") {
|
if (Config::GetLoadGameSizeEnabled()) {
|
||||||
QLabel* gameSizeLabel = new QLabel(tr("Size: ") + m_gameSize);
|
QLabel* gameSizeLabel = new QLabel(tr("Size: ") + m_gameSize);
|
||||||
gameSizeLabel->setAlignment(Qt::AlignLeft);
|
gameSizeLabel->setAlignment(Qt::AlignLeft);
|
||||||
gameInfoLayout->addWidget(gameSizeLabel);
|
gameInfoLayout->addWidget(gameSizeLabel);
|
||||||
|
|
|
@ -84,7 +84,9 @@ public:
|
||||||
copyMenu->addAction(copyName);
|
copyMenu->addAction(copyName);
|
||||||
copyMenu->addAction(copySerial);
|
copyMenu->addAction(copySerial);
|
||||||
copyMenu->addAction(copyVersion);
|
copyMenu->addAction(copyVersion);
|
||||||
copyMenu->addAction(copySize);
|
if (Config::GetLoadGameSizeEnabled()) {
|
||||||
|
copyMenu->addAction(copySize);
|
||||||
|
}
|
||||||
copyMenu->addAction(copyNameAll);
|
copyMenu->addAction(copyNameAll);
|
||||||
|
|
||||||
menu.addMenu(copyMenu);
|
menu.addMenu(copyMenu);
|
||||||
|
@ -362,12 +364,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected == copyNameAll) {
|
if (selected == copyNameAll) {
|
||||||
|
QString GameSizeEnabled;
|
||||||
|
if (Config::GetLoadGameSizeEnabled()) {
|
||||||
|
GameSizeEnabled = " | Size:" + QString::fromStdString(m_games[itemID].size);
|
||||||
|
}
|
||||||
|
|
||||||
QClipboard* clipboard = QGuiApplication::clipboard();
|
QClipboard* clipboard = QGuiApplication::clipboard();
|
||||||
QString combinedText = QString("Name:%1 | Serial:%2 | Version:%3 | Size:%4")
|
QString combinedText = QString("Name:%1 | Serial:%2 | Version:%3%4")
|
||||||
.arg(QString::fromStdString(m_games[itemID].name))
|
.arg(QString::fromStdString(m_games[itemID].name))
|
||||||
.arg(QString::fromStdString(m_games[itemID].serial))
|
.arg(QString::fromStdString(m_games[itemID].serial))
|
||||||
.arg(QString::fromStdString(m_games[itemID].version))
|
.arg(QString::fromStdString(m_games[itemID].version))
|
||||||
.arg(QString::fromStdString(m_games[itemID].size));
|
.arg(GameSizeEnabled);
|
||||||
|
|
||||||
clipboard->setText(combinedText);
|
clipboard->setText(combinedText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,6 +290,27 @@ void MainWindow::CreateConnects() {
|
||||||
connect(settingsDialog, &SettingsDialog::CompatibilityChanged, this,
|
connect(settingsDialog, &SettingsDialog::CompatibilityChanged, this,
|
||||||
&MainWindow::RefreshGameTable);
|
&MainWindow::RefreshGameTable);
|
||||||
|
|
||||||
|
connect(settingsDialog, &SettingsDialog::accepted, this, &MainWindow::RefreshGameTable);
|
||||||
|
connect(settingsDialog, &SettingsDialog::rejected, this, &MainWindow::RefreshGameTable);
|
||||||
|
connect(settingsDialog, &SettingsDialog::close, this, &MainWindow::RefreshGameTable);
|
||||||
|
|
||||||
|
connect(settingsDialog, &SettingsDialog::BackgroundOpacityChanged, this,
|
||||||
|
[this](int opacity) {
|
||||||
|
Config::setBackgroundImageOpacity(opacity);
|
||||||
|
if (m_game_list_frame) {
|
||||||
|
QTableWidgetItem* current = m_game_list_frame->GetCurrentItem();
|
||||||
|
if (current) {
|
||||||
|
m_game_list_frame->SetListBackgroundImage(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_game_grid_frame) {
|
||||||
|
if (m_game_grid_frame->IsValidCellSelected()) {
|
||||||
|
m_game_grid_frame->SetGridBackgroundImage(m_game_grid_frame->crtRow,
|
||||||
|
m_game_grid_frame->crtColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
settingsDialog->exec();
|
settingsDialog->exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -302,6 +323,10 @@ void MainWindow::CreateConnects() {
|
||||||
connect(settingsDialog, &SettingsDialog::CompatibilityChanged, this,
|
connect(settingsDialog, &SettingsDialog::CompatibilityChanged, this,
|
||||||
&MainWindow::RefreshGameTable);
|
&MainWindow::RefreshGameTable);
|
||||||
|
|
||||||
|
connect(settingsDialog, &SettingsDialog::accepted, this, &MainWindow::RefreshGameTable);
|
||||||
|
connect(settingsDialog, &SettingsDialog::rejected, this, &MainWindow::RefreshGameTable);
|
||||||
|
connect(settingsDialog, &SettingsDialog::close, this, &MainWindow::RefreshGameTable);
|
||||||
|
|
||||||
connect(settingsDialog, &SettingsDialog::BackgroundOpacityChanged, this,
|
connect(settingsDialog, &SettingsDialog::BackgroundOpacityChanged, this,
|
||||||
[this](int opacity) {
|
[this](int opacity) {
|
||||||
Config::setBackgroundImageOpacity(opacity);
|
Config::setBackgroundImageOpacity(opacity);
|
||||||
|
|
|
@ -63,6 +63,9 @@ QMap<QString, QString> logTypeMap;
|
||||||
QMap<QString, QString> fullscreenModeMap;
|
QMap<QString, QString> fullscreenModeMap;
|
||||||
QMap<QString, QString> chooseHomeTabMap;
|
QMap<QString, QString> chooseHomeTabMap;
|
||||||
|
|
||||||
|
int backgroundImageOpacitySlider_backup;
|
||||||
|
int bgm_volume_backup;
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
|
SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
|
||||||
std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
||||||
QWidget* parent)
|
QWidget* parent)
|
||||||
|
@ -115,6 +118,7 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::clicked, this,
|
connect(ui->buttonBox, &QDialogButtonBox::clicked, this,
|
||||||
[this, config_dir](QAbstractButton* button) {
|
[this, config_dir](QAbstractButton* button) {
|
||||||
if (button == ui->buttonBox->button(QDialogButtonBox::Save)) {
|
if (button == ui->buttonBox->button(QDialogButtonBox::Save)) {
|
||||||
|
is_saving = true;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
Config::save(config_dir / "config.toml");
|
Config::save(config_dir / "config.toml");
|
||||||
QWidget::close();
|
QWidget::close();
|
||||||
|
@ -126,6 +130,10 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
|
||||||
Config::save(config_dir / "config.toml");
|
Config::save(config_dir / "config.toml");
|
||||||
LoadValuesFromConfig();
|
LoadValuesFromConfig();
|
||||||
} else if (button == ui->buttonBox->button(QDialogButtonBox::Close)) {
|
} else if (button == ui->buttonBox->button(QDialogButtonBox::Close)) {
|
||||||
|
ui->backgroundImageOpacitySlider->setValue(backgroundImageOpacitySlider_backup);
|
||||||
|
emit BackgroundOpacityChanged(backgroundImageOpacitySlider_backup);
|
||||||
|
ui->BGMVolumeSlider->setValue(bgm_volume_backup);
|
||||||
|
BackgroundMusicPlayer::getInstance().setVolume(bgm_volume_backup);
|
||||||
ResetInstallFolders();
|
ResetInstallFolders();
|
||||||
}
|
}
|
||||||
if (Common::Log::IsActive()) {
|
if (Common::Log::IsActive()) {
|
||||||
|
@ -197,6 +205,12 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
|
||||||
|
|
||||||
// Gui TAB
|
// Gui TAB
|
||||||
{
|
{
|
||||||
|
connect(ui->backgroundImageOpacitySlider, &QSlider::valueChanged, this,
|
||||||
|
[this](int value) { emit BackgroundOpacityChanged(value); });
|
||||||
|
|
||||||
|
connect(ui->BGMVolumeSlider, &QSlider::valueChanged, this,
|
||||||
|
[](int value) { BackgroundMusicPlayer::getInstance().setVolume(value); });
|
||||||
|
|
||||||
connect(ui->chooseHomeTabComboBox, &QComboBox::currentTextChanged, this,
|
connect(ui->chooseHomeTabComboBox, &QComboBox::currentTextChanged, this,
|
||||||
[](const QString& hometab) { Config::setChooseHomeTab(hometab.toStdString()); });
|
[](const QString& hometab) { Config::setChooseHomeTab(hometab.toStdString()); });
|
||||||
|
|
||||||
|
@ -330,6 +344,16 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::closeEvent(QCloseEvent* event) {
|
||||||
|
if (!is_saving) {
|
||||||
|
ui->backgroundImageOpacitySlider->setValue(backgroundImageOpacitySlider_backup);
|
||||||
|
emit BackgroundOpacityChanged(backgroundImageOpacitySlider_backup);
|
||||||
|
ui->BGMVolumeSlider->setValue(bgm_volume_backup);
|
||||||
|
BackgroundMusicPlayer::getInstance().setVolume(bgm_volume_backup);
|
||||||
|
}
|
||||||
|
QDialog::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::LoadValuesFromConfig() {
|
void SettingsDialog::LoadValuesFromConfig() {
|
||||||
|
|
||||||
std::filesystem::path userdir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
std::filesystem::path userdir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||||
|
@ -460,6 +484,9 @@ void SettingsDialog::LoadValuesFromConfig() {
|
||||||
ResetInstallFolders();
|
ResetInstallFolders();
|
||||||
ui->backgroundImageOpacitySlider->setValue(Config::getBackgroundImageOpacity());
|
ui->backgroundImageOpacitySlider->setValue(Config::getBackgroundImageOpacity());
|
||||||
ui->showBackgroundImageCheckBox->setChecked(Config::getShowBackgroundImage());
|
ui->showBackgroundImageCheckBox->setChecked(Config::getShowBackgroundImage());
|
||||||
|
|
||||||
|
backgroundImageOpacitySlider_backup = Config::getBackgroundImageOpacity();
|
||||||
|
bgm_volume_backup = Config::getBGMvolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::InitializeEmulatorLanguages() {
|
void SettingsDialog::InitializeEmulatorLanguages() {
|
||||||
|
|
|
@ -42,6 +42,7 @@ private:
|
||||||
void InitializeEmulatorLanguages();
|
void InitializeEmulatorLanguages();
|
||||||
void OnLanguageChanged(int index);
|
void OnLanguageChanged(int index);
|
||||||
void OnCursorStateChanged(s16 index);
|
void OnCursorStateChanged(s16 index);
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
std::unique_ptr<Ui::SettingsDialog> ui;
|
std::unique_ptr<Ui::SettingsDialog> ui;
|
||||||
|
|
||||||
|
@ -50,4 +51,6 @@ private:
|
||||||
QString defaultTextEdit;
|
QString defaultTextEdit;
|
||||||
|
|
||||||
int initialHeight;
|
int initialHeight;
|
||||||
|
|
||||||
|
bool is_saving = false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue