mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Print splashscreen text in separate statusbar
This commit is contained in:
@@ -225,11 +225,11 @@ namespace BlackGui
|
|||||||
splashFont.setFamily("Arial");
|
splashFont.setFamily("Arial");
|
||||||
// splashFont.setBold(true);
|
// splashFont.setBold(true);
|
||||||
splashFont.setPointSize(10);
|
splashFont.setPointSize(10);
|
||||||
splashFont.setStretch(125);
|
splashFont.setStretch(100);
|
||||||
|
|
||||||
m_splashScreen.reset(new CSplashScreen(pixmap.scaled(256, 256)));
|
m_splashScreen.reset(new CSplashScreen(pixmap.scaled(256, 256)));
|
||||||
m_splashScreen->show();
|
m_splashScreen->show();
|
||||||
m_splashScreen->showStatusMessage(CBuildConfig::getVersionString());
|
m_splashScreen->showStatusMessage("Version " + CBuildConfig::getVersionString());
|
||||||
m_splashScreen->setSplashFont(splashFont);
|
m_splashScreen->setSplashFont(splashFont);
|
||||||
|
|
||||||
this->processEventsToRefreshGui();
|
this->processEventsToRefreshGui();
|
||||||
|
|||||||
@@ -3,35 +3,38 @@
|
|||||||
|
|
||||||
#include "splashscreen.h"
|
#include "splashscreen.h"
|
||||||
|
|
||||||
|
#include <QtMath>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
CSplashScreen::CSplashScreen(const QPixmap &pixmap) : QSplashScreen(pixmap)
|
CSplashScreen::CSplashScreen(const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
const int heightTe = 60;
|
const int height = qFloor(pixmap.height() * 1.2);
|
||||||
const int height = pixmap.height();
|
const int width = pixmap.width();
|
||||||
const int width = qRound(0.9 * pixmap.width());
|
QPixmap splash(pixmap.width(), height);
|
||||||
const int yPos = (height - heightTe) / 2;
|
splash.fill(Qt::transparent);
|
||||||
const int xPos = (pixmap.width() - width) / 2;
|
|
||||||
|
|
||||||
m_label = new QLabel(this);
|
QPainter painter(&splash);
|
||||||
m_label->setGeometry(xPos, yPos, width, 80);
|
painter.drawPixmap(0, 0, pixmap);
|
||||||
m_label->setAlignment(Qt::AlignCenter);
|
|
||||||
m_label->setStyleSheet("background: rgba(0,0,0,0); color: white;");
|
|
||||||
m_label->setWordWrap(true);
|
|
||||||
m_label->setVisible(false);
|
|
||||||
|
|
||||||
m_hideTextTimer.setSingleShot(true);
|
const int statusbar_height = qFloor((height - pixmap.height()) / 2.0);
|
||||||
connect(&m_hideTextTimer, &QTimer::timeout, this, &CSplashScreen::hideText);
|
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)
|
void CSplashScreen::showStatusMessage(const QString &html)
|
||||||
{
|
{
|
||||||
if (html.isEmpty()) { return; }
|
if (html.isEmpty()) { return; }
|
||||||
m_label->setVisible(true);
|
this->showMessage(html, Qt::AlignHCenter | Qt::AlignBottom);
|
||||||
m_label->setText(html);
|
m_clearTextTimer.start(2000);
|
||||||
m_hideTextTimer.start(2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSplashScreen::showStatusMessage(const BlackMisc::CStatusMessage &message)
|
void CSplashScreen::showStatusMessage(const BlackMisc::CStatusMessage &message)
|
||||||
@@ -42,11 +45,5 @@ namespace BlackGui
|
|||||||
void CSplashScreen::setSplashFont(const QFont &font)
|
void CSplashScreen::setSplashFont(const QFont &font)
|
||||||
{
|
{
|
||||||
this->setFont(font);
|
this->setFont(font);
|
||||||
m_label->setFont(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSplashScreen::hideText()
|
|
||||||
{
|
|
||||||
m_label->setVisible(false);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,8 @@ namespace BlackGui
|
|||||||
void setSplashFont(const QFont &font);
|
void setSplashFont(const QFont &font);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Hide text
|
|
||||||
void hideText();
|
|
||||||
|
|
||||||
QString m_message;
|
QString m_message;
|
||||||
QTimer m_hideTextTimer;
|
QTimer m_clearTextTimer;
|
||||||
QLabel *m_label = nullptr;
|
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user