show splash screen whenever project is being loaded

... including when switching projects and reloading projects
This commit is contained in:
garak 2025-04-29 15:29:13 -04:00 committed by t
parent c2b1f5ab85
commit 9a0a7865fb
4 changed files with 17 additions and 12 deletions

View File

@ -27,7 +27,8 @@ public:
void setPixmap(QPixmap pixmap);
void showMessage(QString text);
void start() { this->timer.start(120); }
void start();
void stop ();
private:
void setupUi();

View File

@ -10,7 +10,6 @@ int main(int argc, char *argv[])
a.setStyle("fusion");
porysplash = new PorymapLoadingScreen;
porysplash->show();
QObject::connect(&a, &QCoreApplication::aboutToQuit, [=]() { delete porysplash; });

View File

@ -79,7 +79,6 @@ MainWindow::MainWindow(QWidget *parent) :
}
void MainWindow::initialize() {
porysplash->start();
this->initWindow();
if (porymapConfig.reopenOnLaunch && !porymapConfig.projectManuallyClosed && this->openProject(porymapConfig.getRecentProject(), true)) {
on_toolButton_Paint_clicked();
@ -92,8 +91,6 @@ void MainWindow::initialize() {
if (porymapConfig.checkForUpdates)
this->checkForUpdates(false);
porysplash->close();
this->restoreWindowState();
this->show();
}
@ -656,6 +653,8 @@ 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);
@ -684,6 +683,7 @@ bool MainWindow::openProject(QString dir, bool initial) {
// Make sure project looks reasonable before attempting to load it
if (!checkProjectSanity()) {
delete this->editor->project;
porysplash->stop();
return false;
}
@ -693,6 +693,7 @@ bool MainWindow::openProject(QString dir, bool initial) {
showProjectOpenFailure();
delete this->editor->project;
// TODO: Allow changing project settings at this point
porysplash->stop();
return false;
}
@ -713,6 +714,7 @@ bool MainWindow::openProject(QString dir, bool initial) {
editor->layout);
Scripting::cb_ProjectOpened(dir);
setWindowDisabled(false);
porysplash->stop();
return true;
}

View File

@ -24,6 +24,16 @@ PorymapLoadingScreen::PorymapLoadingScreen(QWidget *parent) : QWidget(parent), u
connect(&this->timer, &QTimer::timeout, this, &PorymapLoadingScreen::updateFrame);
}
void PorymapLoadingScreen::start() {
this->timer.start(120);
this->show();
}
void PorymapLoadingScreen::stop () {
this->timer.stop();
this->hide();
}
void PorymapLoadingScreen::setPixmap(QPixmap pixmap) {
if (!this->isVisible()) return;
this->ui->labelPixmap->setPixmap(pixmap);
@ -32,20 +42,13 @@ void PorymapLoadingScreen::setPixmap(QPixmap pixmap) {
void PorymapLoadingScreen::showMessage(QString text) {
if (!this->isVisible()) return;
this->ui->labelText->setText(text.mid(text.lastIndexOf("/") + 1));
//this->updateFrame();
QApplication::processEvents();
}
void PorymapLoadingScreen::updateFrame() {
//
this->frame = (this->frame + 1) % this->splashImage.frameCount();
this->setPixmap(QPixmap::fromImage(this->splashImage.frame(this->frame)));
QApplication::processEvents();
//this->showMessage("Frame Number: " + QString::number(this->frame));
//this->repaint();
}