mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
Disable buttons on set import until done.
This commit is contained in:
parent
e3d6267647
commit
8f6f172169
2 changed files with 23 additions and 0 deletions
|
|
@ -295,6 +295,11 @@ LoadSetsPage::LoadSetsPage(QWidget *parent) : OracleWizardPage(parent)
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LoadSetsPage::isComplete() const
|
||||||
|
{
|
||||||
|
return !loadActive;
|
||||||
|
}
|
||||||
|
|
||||||
void LoadSetsPage::initializePage()
|
void LoadSetsPage::initializePage()
|
||||||
{
|
{
|
||||||
urlLineEdit->setText(wizard()->settings->value("allsetsurl", ALLSETS_URL).toString());
|
urlLineEdit->setText(wizard()->settings->value("allsetsurl", ALLSETS_URL).toString());
|
||||||
|
|
@ -522,6 +527,11 @@ void LoadSetsPage::beginLoadSets(bool compressedFile)
|
||||||
progressLabel->show();
|
progressLabel->show();
|
||||||
progressBar->show();
|
progressBar->show();
|
||||||
|
|
||||||
|
// Keep Next disabled (via completeChanged) until the worker reports in;
|
||||||
|
// updateButtonStates() re-evaluates button state whenever we re-enable.
|
||||||
|
loadActive = true;
|
||||||
|
emit completeChanged();
|
||||||
|
|
||||||
wizard()->downloadedPlainXml = false;
|
wizard()->downloadedPlainXml = false;
|
||||||
wizard()->xmlData.clear();
|
wizard()->xmlData.clear();
|
||||||
|
|
||||||
|
|
@ -606,6 +616,8 @@ void LoadSetsPage::zipDownloadFailed(const QString &message)
|
||||||
|
|
||||||
void LoadSetsPage::importFinished()
|
void LoadSetsPage::importFinished()
|
||||||
{
|
{
|
||||||
|
loadActive = false;
|
||||||
|
emit completeChanged();
|
||||||
wizard()->enableButtons();
|
wizard()->enableButtons();
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
|
|
||||||
|
|
@ -684,6 +696,11 @@ SaveSetsPage::SaveSetsPage(QWidget *parent) : OracleWizardPage(parent)
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SaveSetsPage::isComplete() const
|
||||||
|
{
|
||||||
|
return !importActive;
|
||||||
|
}
|
||||||
|
|
||||||
void SaveSetsPage::cleanupPage()
|
void SaveSetsPage::cleanupPage()
|
||||||
{
|
{
|
||||||
cancelWork();
|
cancelWork();
|
||||||
|
|
@ -718,6 +735,7 @@ void SaveSetsPage::initializePage()
|
||||||
|
|
||||||
wizard()->disableButtons();
|
wizard()->disableButtons();
|
||||||
importActive = true;
|
importActive = true;
|
||||||
|
emit completeChanged();
|
||||||
|
|
||||||
const QPointer<OracleImporter> importer = wizard()->importer;
|
const QPointer<OracleImporter> importer = wizard()->importer;
|
||||||
importFuture = QtConcurrent::run([importer] { return importer ? importer->startImport() : 0; });
|
importFuture = QtConcurrent::run([importer] { return importer ? importer->startImport() : 0; });
|
||||||
|
|
@ -732,6 +750,7 @@ void SaveSetsPage::cancelWork()
|
||||||
// Ask the worker to stop at the next set boundary, then wait it out so the
|
// Ask the worker to stop at the next set boundary, then wait it out so the
|
||||||
// wizard (and the importer it owns) is never torn down under a running thread.
|
// wizard (and the importer it owns) is never torn down under a running thread.
|
||||||
importActive = false;
|
importActive = false;
|
||||||
|
emit completeChanged();
|
||||||
wizard()->importer->cancelImport();
|
wizard()->importer->cancelImport();
|
||||||
importFuture.cancel();
|
importFuture.cancel();
|
||||||
importWatcher.cancel();
|
importWatcher.cancel();
|
||||||
|
|
@ -744,6 +763,7 @@ void SaveSetsPage::importFinished()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
importActive = false;
|
importActive = false;
|
||||||
|
emit completeChanged();
|
||||||
|
|
||||||
wizard()->enableButtons();
|
wizard()->enableButtons();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ class LoadSetsPage : public OracleWizardPage
|
||||||
public:
|
public:
|
||||||
explicit LoadSetsPage(QWidget *parent = nullptr);
|
explicit LoadSetsPage(QWidget *parent = nullptr);
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
|
bool isComplete() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initializePage() override;
|
void initializePage() override;
|
||||||
|
|
@ -96,6 +97,7 @@ private:
|
||||||
|
|
||||||
QFutureWatcher<LoadSetsResult> watcher;
|
QFutureWatcher<LoadSetsResult> watcher;
|
||||||
QFuture<LoadSetsResult> future;
|
QFuture<LoadSetsResult> future;
|
||||||
|
bool loadActive = false;
|
||||||
|
|
||||||
void beginLoadSets(bool compressedFile = false);
|
void beginLoadSets(bool compressedFile = false);
|
||||||
|
|
||||||
|
|
@ -116,6 +118,7 @@ class SaveSetsPage : public OracleWizardPage
|
||||||
public:
|
public:
|
||||||
explicit SaveSetsPage(QWidget *parent = nullptr);
|
explicit SaveSetsPage(QWidget *parent = nullptr);
|
||||||
void retranslateUi() override;
|
void retranslateUi() override;
|
||||||
|
bool isComplete() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTextEdit *messageLog;
|
QTextEdit *messageLog;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue