Skip to content

Commit

Permalink
Move demodialog accept logic to inside the demodialog class
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro-Beirao committed May 25, 2024
1 parent 59e135b commit 791f4e3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
15 changes: 15 additions & 0 deletions src/demodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
3 changes: 3 additions & 0 deletions src/demodialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class demodialog : public QDialog
QLabel *selected_count;
void update_selected_count();
QFileInfoList files;

private slots:
void accept();
};

#endif // DEMODIALOG_H
Expand Down
17 changes: 1 addition & 16 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down Expand Up @@ -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())
Expand Down
36 changes: 17 additions & 19 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class MainWindow : public QMainWindow
Settings *settingsWindow;
Console *consoleWindow;
historyList *historyListWindow;
demodialog *demoDialog;
endoom *endoomWindow;

QString endoomString;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 791f4e3

Please sign in to comment.