From 791f4e3c93d479ccbb93c1ae2e1cc806053dfd3c Mon Sep 17 00:00:00 2001 From: Pedro Beirao Date: Sat, 25 May 2024 21:04:34 +0100 Subject: [PATCH] Move demodialog accept logic to inside the demodialog class --- src/demodialog.cpp | 15 +++++++++++++++ src/demodialog.h | 3 +++ src/mainwindow.cpp | 17 +---------------- src/mainwindow.h | 36 +++++++++++++++++------------------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/demodialog.cpp b/src/demodialog.cpp index 3cd90d6..e8be120 100644 --- a/src/demodialog.cpp +++ b/src/demodialog.cpp @@ -106,3 +106,18 @@ QStringList demodialog::get_files_list() } return files_list; } + +void demodialog::accept() +{ + MainWindow::pMainWindow->iwad_comboBox()->setCurrentIndex(get_iwad_index()); + MainWindow::pMainWindow->wads_listWidget()->clear(); + + QStringList files_list = get_files_list(); + foreach (QString filePath, files_list) + { + MainWindow::pMainWindow->wads_listWidget()->addItem(getFileName(filePath)); + MainWindow::pMainWindow->wads_listWidget()->item(MainWindow::pMainWindow->wads_listWidget()->count() - 1)->setToolTip(filePath); + } + + this->close(); +} diff --git a/src/demodialog.h b/src/demodialog.h index 6874b5b..d4c8eb4 100644 --- a/src/demodialog.h +++ b/src/demodialog.h @@ -28,6 +28,9 @@ class demodialog : public QDialog QLabel *selected_count; void update_selected_count(); QFileInfoList files; + + private slots: + void accept(); }; #endif // DEMODIALOG_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6efbeb8..fca1233 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -336,10 +336,8 @@ void MainWindow::dropLmp(QString filePath) if (openDemoDialog) { demodialog *demoDialogNew = new demodialog(missing_iwad, missing_files, this); + demoDialogNew->setAttribute(Qt::WA_DeleteOnClose); demoDialogNew->open(); - - demoDialog = demoDialogNew; - connect(demoDialog, SIGNAL(accepted()), this, SLOT(demoDialog_accepted())); } } @@ -367,19 +365,6 @@ void MainWindow::dropFile(QString fileName) } } -void MainWindow::demoDialog_accepted() -{ - ui->iwad_comboBox->setCurrentIndex(demoDialog->get_iwad_index()); - ui->wads_listWidget->clear(); - - QStringList files_list = demoDialog->get_files_list(); - foreach (QString filePath, files_list) - { - ui->wads_listWidget->addItem(getFileName(filePath)); - ui->wads_listWidget->item(ui->wads_listWidget->count() - 1)->setToolTip(filePath); - } -} - void MainWindow::dropEvent(QDropEvent *e) { foreach (const QUrl &url, e->mimeData()->urls()) diff --git a/src/mainwindow.h b/src/mainwindow.h index 1d96bda..d9a766f 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -68,7 +68,6 @@ class MainWindow : public QMainWindow Settings *settingsWindow; Console *consoleWindow; historyList *historyListWindow; - demodialog *demoDialog; endoom *endoomWindow; QString endoomString; @@ -155,24 +154,23 @@ public slots: void readyReadStandardOutput(); void started(); -private slots: - void demoDialog_accepted(); - void on_viddump_lineEdit_textChanged(const QString &arg1); - void on_playback_comboBox_currentIndexChanged(int index); - void on_viddump_pushButton_clicked(); - void on_showCommandLine_pushButton_clicked(); - void on_episode_lineEdit_textChanged(const QString &arg1); - void on_nextPage_pushButton_clicked(); - void on_previousPage_pushButton_clicked(); - void on_hud_lineEdit_textChanged(const QString &arg1); - void on_config_lineEdit_textChanged(const QString &arg1); - void on_hud_pushButton_clicked(); - void on_config_pushButton_clicked(); - void on_playback_lineEdit_textChanged(const QString &arg1); - void loadSelected(); - void saveSelected(); - void setStyles(); - QStringList getArguments(); + private slots: + void on_viddump_lineEdit_textChanged(const QString &arg1); + void on_playback_comboBox_currentIndexChanged(int index); + void on_viddump_pushButton_clicked(); + void on_showCommandLine_pushButton_clicked(); + void on_episode_lineEdit_textChanged(const QString &arg1); + void on_nextPage_pushButton_clicked(); + void on_previousPage_pushButton_clicked(); + void on_hud_lineEdit_textChanged(const QString &arg1); + void on_config_lineEdit_textChanged(const QString &arg1); + void on_hud_pushButton_clicked(); + void on_config_pushButton_clicked(); + void on_playback_lineEdit_textChanged(const QString &arg1); + void loadSelected(); + void saveSelected(); + void setStyles(); + QStringList getArguments(); }; extern QSettings *settings;