Fix resetting last.fm import dialog on close when finished

This commit is contained in:
Jonas Kvinge 2020-08-30 18:28:51 +02:00
parent 5aaa5231b8
commit 3bea58cf56
2 changed files with 21 additions and 17 deletions

View File

@ -22,7 +22,6 @@
#include <QPushButton>
#include <QLabel>
#include <QProgressBar>
#include <QShowEvent>
#include <QCloseEvent>
#include "lastfmimportdialog.h"
@ -47,7 +46,7 @@ LastFMImportDialog::LastFMImportDialog(LastFMImport *lastfm_import, QWidget *par
Reset();
connect(ui_->button_close, SIGNAL(clicked()), SLOT(hide()));
connect(ui_->button_close, SIGNAL(clicked()), SLOT(Close()));
connect(ui_->button_go, SIGNAL(clicked()), SLOT(Start()));
connect(ui_->button_cancel, SIGNAL(clicked()), SLOT(Cancel()));
@ -58,21 +57,9 @@ LastFMImportDialog::LastFMImportDialog(LastFMImport *lastfm_import, QWidget *par
LastFMImportDialog::~LastFMImportDialog() { delete ui_; }
void LastFMImportDialog::showEvent(QShowEvent*) {
if (ui_->stackedWidget->currentWidget() == ui_->page_start) {
Reset();
}
}
void LastFMImportDialog::closeEvent(QCloseEvent*) {
if (ui_->stackedWidget->currentWidget() == ui_->page_progress && finished_) {
finished_ = false;
Reset();
ui_->stackedWidget->setCurrentWidget(ui_->page_start);
}
ResetFinished();
}
@ -98,6 +85,23 @@ void LastFMImportDialog::Cancel() {
}
void LastFMImportDialog::Close() {
ResetFinished();
hide();
}
void LastFMImportDialog::ResetFinished() {
if (finished_ && ui_->stackedWidget->currentWidget() == ui_->page_progress) {
finished_ = false;
Reset();
ui_->stackedWidget->setCurrentWidget(ui_->page_start);
}
}
void LastFMImportDialog::Reset() {
ui_->button_go->show();

View File

@ -28,7 +28,6 @@
#include "ui_lastfmimportdialog.h"
class QShowEvent;
class QCloseEvent;
class LastFMImport;
@ -40,15 +39,16 @@ class LastFMImportDialog : public QDialog {
~LastFMImportDialog() override;
protected:
void showEvent(QShowEvent*);
void closeEvent(QCloseEvent*);
private:
void ResetFinished();
void Reset();
private slots:
void Start();
void Cancel();
void Close();
void UpdateGoButtonState();
void UpdateTotal(const int lastplayed_total, const int playcount_total);