Print splashscreen text in separate statusbar

This commit is contained in:
Lars Toenning
2023-10-03 14:54:13 +02:00
parent bcc4bdd31e
commit bfc27f61a4
3 changed files with 23 additions and 30 deletions

View File

@@ -225,11 +225,11 @@ namespace BlackGui
splashFont.setFamily("Arial");
// splashFont.setBold(true);
splashFont.setPointSize(10);
splashFont.setStretch(125);
splashFont.setStretch(100);
m_splashScreen.reset(new CSplashScreen(pixmap.scaled(256, 256)));
m_splashScreen->show();
m_splashScreen->showStatusMessage(CBuildConfig::getVersionString());
m_splashScreen->showStatusMessage("Version " + CBuildConfig::getVersionString());
m_splashScreen->setSplashFont(splashFont);
this->processEventsToRefreshGui();

View File

@@ -3,35 +3,38 @@
#include "splashscreen.h"
#include <QtMath>
using namespace BlackMisc;
namespace BlackGui
{
CSplashScreen::CSplashScreen(const QPixmap &pixmap) : QSplashScreen(pixmap)
CSplashScreen::CSplashScreen(const QPixmap &pixmap)
{
const int heightTe = 60;
const int height = pixmap.height();
const int width = qRound(0.9 * pixmap.width());
const int yPos = (height - heightTe) / 2;
const int xPos = (pixmap.width() - width) / 2;
const int height = qFloor(pixmap.height() * 1.2);
const int width = pixmap.width();
QPixmap splash(pixmap.width(), height);
splash.fill(Qt::transparent);
m_label = new QLabel(this);
m_label->setGeometry(xPos, yPos, width, 80);
m_label->setAlignment(Qt::AlignCenter);
m_label->setStyleSheet("background: rgba(0,0,0,0); color: white;");
m_label->setWordWrap(true);
m_label->setVisible(false);
QPainter painter(&splash);
painter.drawPixmap(0, 0, pixmap);
m_hideTextTimer.setSingleShot(true);
connect(&m_hideTextTimer, &QTimer::timeout, this, &CSplashScreen::hideText);
const int statusbar_height = qFloor((height - pixmap.height()) / 2.0);
QPixmap statusbar(width, statusbar_height);
statusbar.fill(QColor(200, 200, 200));
painter.drawPixmap(0, height - statusbar_height, statusbar);
this->setPixmap(splash);
m_clearTextTimer.setSingleShot(true);
connect(&m_clearTextTimer, &QTimer::timeout, this, &CSplashScreen::clearMessage);
}
void CSplashScreen::showStatusMessage(const QString &html)
{
if (html.isEmpty()) { return; }
m_label->setVisible(true);
m_label->setText(html);
m_hideTextTimer.start(2000);
this->showMessage(html, Qt::AlignHCenter | Qt::AlignBottom);
m_clearTextTimer.start(2000);
}
void CSplashScreen::showStatusMessage(const BlackMisc::CStatusMessage &message)
@@ -42,11 +45,5 @@ namespace BlackGui
void CSplashScreen::setSplashFont(const QFont &font)
{
this->setFont(font);
m_label->setFont(font);
}
void CSplashScreen::hideText()
{
m_label->setVisible(false);
};
}

View File

@@ -35,12 +35,8 @@ namespace BlackGui
void setSplashFont(const QFont &font);
private:
//! Hide text
void hideText();
QString m_message;
QTimer m_hideTextTimer;
QLabel *m_label = nullptr;
QTimer m_clearTextTimer;
};
} // ns