mirror of
https://github.com/huderlem/porymap.git
synced 2026-03-22 01:54:46 -05:00
Start fixing some of the Message UI deadlocks
This commit is contained in:
parent
184025aace
commit
15e2d3cf05
|
|
@ -24,21 +24,21 @@ public:
|
|||
class ErrorMessage : public Message {
|
||||
public:
|
||||
ErrorMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
// Basic warning message with an 'Ok' button.
|
||||
class WarningMessage : public Message {
|
||||
public:
|
||||
WarningMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
// Basic informational message with a 'Close' button.
|
||||
class InfoMessage : public Message {
|
||||
public:
|
||||
InfoMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
// Basic question message with a 'Yes' and 'No' button.
|
||||
|
|
@ -53,7 +53,7 @@ public:
|
|||
class RecentErrorMessage : public ErrorMessage {
|
||||
public:
|
||||
RecentErrorMessage(const QString &message, QWidget *parent);
|
||||
static int show(const QString &message, QWidget *parent);
|
||||
static void show(const QString &message, QWidget *parent);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -653,8 +653,6 @@ bool MainWindow::openProject(QString dir, bool initial) {
|
|||
return false;
|
||||
}
|
||||
|
||||
porysplash->start();
|
||||
|
||||
const QString openMessage = QString("Opening %1").arg(projectString);
|
||||
this->statusBar()->showMessage(openMessage);
|
||||
logInfo(openMessage);
|
||||
|
|
@ -664,6 +662,8 @@ bool MainWindow::openProject(QString dir, bool initial) {
|
|||
projectConfig.projectDir = dir;
|
||||
projectConfig.load();
|
||||
|
||||
porysplash->start();
|
||||
|
||||
Scripting::init(this);
|
||||
|
||||
// Create the project
|
||||
|
|
@ -730,7 +730,7 @@ bool MainWindow::checkProjectSanity() {
|
|||
|
||||
logWarn(QString("The directory '%1' failed the project sanity check.").arg(editor->project->root));
|
||||
|
||||
ErrorMessage msgBox(QStringLiteral("The selected directory appears to be invalid."), this);
|
||||
ErrorMessage msgBox(QStringLiteral("The selected directory appears to be invalid."), porysplash);
|
||||
msgBox.setInformativeText(QString("The directory '%1' is missing key files.\n\n"
|
||||
"Make sure you selected the correct project directory "
|
||||
"(the one used to make your .gba file, e.g. 'pokeemerald').").arg(editor->project->root));
|
||||
|
|
@ -750,14 +750,15 @@ void MainWindow::showProjectOpenFailure() {
|
|||
|
||||
// Alert the user that one or more maps have been excluded while loading the project.
|
||||
void MainWindow::showMapsExcludedAlert(const QStringList &excludedMapNames) {
|
||||
RecentErrorMessage msgBox("", this);
|
||||
auto msgBox = new RecentErrorMessage("", this);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
if (excludedMapNames.length() == 1) {
|
||||
msgBox.setText(QString("Failed to load map '%1'. Saving will exclude this map from your project.").arg(excludedMapNames.first()));
|
||||
msgBox->setText(QString("Failed to load map '%1'. Saving will exclude this map from your project.").arg(excludedMapNames.first()));
|
||||
} else {
|
||||
msgBox.setText(QStringLiteral("Failed to load the maps listed below. Saving will exclude these maps from your project."));
|
||||
msgBox.setDetailedText(excludedMapNames.join("\n")); // Overwrites error details text, user will need to check the log.
|
||||
msgBox->setText(QStringLiteral("Failed to load the maps listed below. Saving will exclude these maps from your project."));
|
||||
msgBox->setDetailedText(excludedMapNames.join("\n")); // Overwrites error details text, user will need to check the log.
|
||||
}
|
||||
msgBox.exec();
|
||||
msgBox->open();
|
||||
}
|
||||
|
||||
bool MainWindow::isProjectOpen() {
|
||||
|
|
@ -867,28 +868,28 @@ void MainWindow::showFileWatcherWarning() {
|
|||
path.remove(root);
|
||||
}
|
||||
|
||||
QuestionMessage msgBox("", this);
|
||||
QPointer msgBox = new QuestionMessage("", this);
|
||||
if (modifiedFiles.count() == 1) {
|
||||
msgBox.setText(QString("The file %1 has changed on disk. Would you like to reload the project?").arg(modifiedFiles.first()));
|
||||
msgBox->setText(QString("The file %1 has changed on disk. Would you like to reload the project?").arg(modifiedFiles.first()));
|
||||
} else {
|
||||
msgBox.setText(QStringLiteral("Some project files have changed on disk. Would you like to reload the project?"));
|
||||
msgBox.setDetailedText(QStringLiteral("The following files have changed:\n") + modifiedFiles.join("\n"));
|
||||
msgBox->setText(QStringLiteral("Some project files have changed on disk. Would you like to reload the project?"));
|
||||
msgBox->setDetailedText(QStringLiteral("The following files have changed:\n") + modifiedFiles.join("\n"));
|
||||
}
|
||||
msgBox->setCheckBox(new QCheckBox("Do not ask again."));
|
||||
|
||||
QCheckBox showAgainCheck("Do not ask again.");
|
||||
msgBox.setCheckBox(&showAgainCheck);
|
||||
|
||||
auto reply = msgBox.exec();
|
||||
if (reply == QMessageBox::Yes) {
|
||||
on_action_Reload_Project_triggered();
|
||||
} else if (reply == QMessageBox::No) {
|
||||
if (showAgainCheck.isChecked()) {
|
||||
porymapConfig.monitorFiles = false;
|
||||
if (this->preferenceEditor)
|
||||
this->preferenceEditor->updateFields();
|
||||
connect(msgBox, &QuestionMessage::accepted, this, &MainWindow::on_action_Reload_Project_triggered);
|
||||
connect(msgBox, &QuestionMessage::finished, [this, msgBox] {
|
||||
if (msgBox) {
|
||||
if (msgBox->checkBox() && msgBox->checkBox()->isChecked()) {
|
||||
porymapConfig.monitorFiles = false;
|
||||
if (this->preferenceEditor)
|
||||
this->preferenceEditor->updateFields();
|
||||
}
|
||||
msgBox->deleteLater();
|
||||
}
|
||||
}
|
||||
showing = false;
|
||||
showing = false;
|
||||
});
|
||||
msgBox->open();
|
||||
}
|
||||
|
||||
QString MainWindow::getExistingDirectory(QString dir) {
|
||||
|
|
@ -903,7 +904,8 @@ void MainWindow::on_action_Open_Project_triggered()
|
|||
}
|
||||
|
||||
void MainWindow::on_action_Reload_Project_triggered() {
|
||||
openProject(editor->project->root);
|
||||
if (this->editor && this->editor->project)
|
||||
openProject(this->editor->project->root);
|
||||
}
|
||||
|
||||
void MainWindow::on_action_Close_Project_triggered() {
|
||||
|
|
@ -928,9 +930,10 @@ bool MainWindow::userSetMap(QString map_name) {
|
|||
}
|
||||
|
||||
if (map_name == editor->project->getDynamicMapName()) {
|
||||
WarningMessage msgBox(QString("Cannot open map '%1'.").arg(map_name), this);
|
||||
msgBox.setInformativeText(QStringLiteral("This map name is a placeholder to indicate that the warp's map will be set programmatically."));
|
||||
msgBox.exec();
|
||||
auto msgBox = new WarningMessage(QString("Cannot open map '%1'.").arg(map_name), this);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->setInformativeText(QStringLiteral("This map name is a placeholder to indicate that the warp's map will be set programmatically."));
|
||||
msgBox->open();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,12 @@ void PorymapLoadingScreen::start() {
|
|||
this->ui->labelVersion->setText(AboutPorymap::getVersionString());
|
||||
shownVersion = true;
|
||||
}
|
||||
|
||||
this->frame = 0;
|
||||
this->ui->labelPixmap->setPixmap(QPixmap::fromImage(this->splashImage.frame(this->frame)));
|
||||
|
||||
this->ui->labelText->setText("");
|
||||
|
||||
this->timer.start(120);
|
||||
this->show();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,19 +52,22 @@ RecentErrorMessage::RecentErrorMessage(const QString &message, QWidget *parent)
|
|||
setDetailedText(getMostRecentError());
|
||||
}
|
||||
|
||||
int RecentErrorMessage::show(const QString &message, QWidget *parent) {
|
||||
RecentErrorMessage msgBox(message, parent);
|
||||
return msgBox.exec();
|
||||
void RecentErrorMessage::show(const QString &message, QWidget *parent) {
|
||||
auto msgBox = new RecentErrorMessage(message, parent);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->open();
|
||||
};
|
||||
|
||||
int ErrorMessage::show(const QString &message, QWidget *parent) {
|
||||
ErrorMessage msgBox(message, parent);
|
||||
return msgBox.exec();
|
||||
void ErrorMessage::show(const QString &message, QWidget *parent) {
|
||||
auto msgBox = new ErrorMessage(message, parent);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->open();
|
||||
};
|
||||
|
||||
int WarningMessage::show(const QString &message, QWidget *parent) {
|
||||
WarningMessage msgBox(message, parent);
|
||||
return msgBox.exec();
|
||||
void WarningMessage::show(const QString &message, QWidget *parent) {
|
||||
auto msgBox = new WarningMessage(message, parent);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->open();
|
||||
};
|
||||
|
||||
int QuestionMessage::show(const QString &message, QWidget *parent) {
|
||||
|
|
@ -72,7 +75,8 @@ int QuestionMessage::show(const QString &message, QWidget *parent) {
|
|||
return msgBox.exec();
|
||||
};
|
||||
|
||||
int InfoMessage::show(const QString &message, QWidget *parent) {
|
||||
InfoMessage msgBox(message, parent);
|
||||
return msgBox.exec();
|
||||
void InfoMessage::show(const QString &message, QWidget *parent) {
|
||||
auto msgBox = new InfoMessage(message, parent);
|
||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
msgBox->open();
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user