mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
Added closing the config also closing the Help window, and fixed more segfaults due to mismatched flags
This commit is contained in:
parent
195ef4c02f
commit
3ce21a5ca1
@ -21,6 +21,8 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
QString previous_game = "default";
|
||||
bool isHelpOpen = false;
|
||||
HelpDialog* helpDialog;
|
||||
|
||||
EditorDialog::EditorDialog(QWidget* parent) : QDialog(parent) {
|
||||
|
||||
@ -107,6 +109,11 @@ void EditorDialog::saveFile(QString game) {
|
||||
|
||||
// Override the close event to show the save confirmation dialog only if changes were made
|
||||
void EditorDialog::closeEvent(QCloseEvent* event) {
|
||||
if (isHelpOpen) {
|
||||
helpDialog->close();
|
||||
isHelpOpen = false;
|
||||
// at this point I might have to add this flag and the help dialog to the class itself
|
||||
}
|
||||
if (hasUnsavedChanges()) {
|
||||
QMessageBox::StandardButton reply;
|
||||
reply = QMessageBox::question(this, "Save Changes", "Do you want to save changes?",
|
||||
@ -126,6 +133,10 @@ void EditorDialog::closeEvent(QCloseEvent* event) {
|
||||
}
|
||||
void EditorDialog::keyPressEvent(QKeyEvent* event) {
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
if (isHelpOpen) {
|
||||
helpDialog->close();
|
||||
isHelpOpen = false;
|
||||
}
|
||||
close(); // Trigger the close action, same as pressing the close button
|
||||
} else {
|
||||
QDialog::keyPressEvent(event); // Call the base class implementation for other keys
|
||||
@ -133,15 +144,22 @@ void EditorDialog::keyPressEvent(QKeyEvent* event) {
|
||||
}
|
||||
|
||||
void EditorDialog::onSaveClicked() {
|
||||
if (isHelpOpen) {
|
||||
helpDialog->close();
|
||||
isHelpOpen = false;
|
||||
}
|
||||
saveFile(gameComboBox->currentText());
|
||||
reject(); // Close the dialog
|
||||
}
|
||||
|
||||
void EditorDialog::onCancelClicked() {
|
||||
if (isHelpOpen) {
|
||||
helpDialog->close();
|
||||
isHelpOpen = false;
|
||||
}
|
||||
reject(); // Close the dialog
|
||||
}
|
||||
bool isHelpOpen = false;
|
||||
HelpDialog* helpDialog;
|
||||
|
||||
void EditorDialog::onHelpClicked() {
|
||||
if (!isHelpOpen) {
|
||||
helpDialog = new HelpDialog(&isHelpOpen, this);
|
||||
|
@ -62,6 +62,10 @@ void HelpDialog::closeEvent(QCloseEvent* event) {
|
||||
*help_open_ptr = false;
|
||||
close();
|
||||
}
|
||||
void HelpDialog::reject() {
|
||||
*help_open_ptr = false;
|
||||
close();
|
||||
}
|
||||
|
||||
HelpDialog::HelpDialog(bool* open_flag, QWidget* parent) : QDialog(parent) {
|
||||
help_open_ptr = open_flag;
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void reject() override;
|
||||
|
||||
private:
|
||||
bool* help_open_ptr;
|
||||
|
Loading…
Reference in New Issue
Block a user