changed splash text to display formatted text
This commit is contained in:
+11
-12
@@ -1,36 +1,35 @@
|
||||
#include "csplashscreen.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
cSplashScreen::cSplashScreen(const QPixmap& pixmap) :
|
||||
cSplashScreen::cSplashScreen(const QPixmap& pixmap, QFont& font) :
|
||||
QSplashScreen(pixmap)
|
||||
{
|
||||
setFont(font);
|
||||
m_textDocument.setDefaultFont(font);
|
||||
}
|
||||
|
||||
void cSplashScreen::drawContents(QPainter *painter)
|
||||
{
|
||||
painter->setPen(m_color);
|
||||
painter->drawText(m_rect, m_iAlignement, m_szMessage);
|
||||
}
|
||||
|
||||
void cSplashScreen::setStatusMessageColor(const QColor& color)
|
||||
{
|
||||
m_color = color;
|
||||
painter->translate(m_rect.topLeft());
|
||||
m_textDocument.setHtml(m_szMessage);
|
||||
m_textDocument.drawContents(painter);
|
||||
}
|
||||
|
||||
void cSplashScreen::showStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage = message;
|
||||
showMessage(m_szMessage, m_iAlignement, m_color);
|
||||
showMessage(m_szMessage);
|
||||
}
|
||||
|
||||
void cSplashScreen::addStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage.append(message);
|
||||
showMessage(m_szMessage, m_iAlignement, m_color);
|
||||
showMessage(m_szMessage);
|
||||
}
|
||||
|
||||
void cSplashScreen::setMessageRect(QRect rect, int alignement)
|
||||
void cSplashScreen::setMessageRect(QRect rect)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_iAlignement = alignement;
|
||||
m_textDocument.setTextWidth(rect.width());
|
||||
}
|
||||
|
||||
+4
-5
@@ -4,23 +4,22 @@
|
||||
|
||||
#include <QSplashScreen>
|
||||
#include <QPainter>
|
||||
#include <QTextDocument>
|
||||
|
||||
|
||||
class cSplashScreen : public QSplashScreen
|
||||
{
|
||||
public:
|
||||
cSplashScreen(const QPixmap& pixmap);
|
||||
cSplashScreen(const QPixmap& pixmap, QFont &font);
|
||||
|
||||
virtual void drawContents(QPainter *painter);
|
||||
void setStatusMessageColor(const QColor& color);
|
||||
void showStatusMessage(const QString &message);
|
||||
void addStatusMessage(const QString &message);
|
||||
void setMessageRect(QRect rect, int alignment = Qt::AlignLeft);
|
||||
void setMessageRect(QRect rect);
|
||||
|
||||
private:
|
||||
QTextDocument m_textDocument;
|
||||
QString m_szMessage;
|
||||
int m_iAlignement;
|
||||
QColor m_color;
|
||||
QRect m_rect;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "csplashscreen.h"
|
||||
|
||||
#define SHOW_SPLASH
|
||||
//#define SHOW_SPLASH
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -23,7 +23,6 @@ int main(int argc, char *argv[])
|
||||
#else
|
||||
QPixmap pixmap(":/images/splashEmpty.png");
|
||||
#endif
|
||||
cSplashScreen* lpSplash = new cSplashScreen(pixmap);
|
||||
// int id = QFontDatabase::addApplicationFont(":/fonts/Stingray.otf");
|
||||
// int id = QFontDatabase::addApplicationFont(":/fonts/Luna.ttf");
|
||||
// int id = QFontDatabase::addApplicationFont(":/fonts/Tomatoes.ttf");
|
||||
@@ -31,21 +30,20 @@ int main(int argc, char *argv[])
|
||||
int id = QFontDatabase::addApplicationFont(":/fonts/Tahu!.ttf");
|
||||
QString family = QFontDatabase::applicationFontFamilies(id).at(0);
|
||||
QFont splashFont(family);
|
||||
splashFont.setPixelSize(24);
|
||||
|
||||
cSplashScreen* lpSplash = new cSplashScreen(pixmap, splashFont);
|
||||
|
||||
#ifdef SHOW_SPLASH
|
||||
lpSplash->setMessageRect(QRect(0, 110, 480, 209), Qt::AlignHCenter);
|
||||
lpSplash->setMessageRect(QRect(0, 110, 480, 209));
|
||||
#else
|
||||
lpSplash->setMessageRect(QRect(0, 20, 480, 299), Qt::AlignHCenter);
|
||||
lpSplash->setMessageRect(QRect(0, 110, 480, 209));
|
||||
#endif
|
||||
|
||||
splashFont.setPixelSize(18);
|
||||
lpSplash->setFont(splashFont);
|
||||
lpSplash->setStatusMessageColor(Qt::darkGray);
|
||||
|
||||
lpSplash->show();
|
||||
a.processEvents();
|
||||
|
||||
lpSplash->showStatusMessage(QObject::tr("initializing..."));
|
||||
lpSplash->showStatusMessage(QObject::tr("<center>initializing...</denter>"));
|
||||
|
||||
QCoreApplication::setOrganizationName("WIN-DESIGN");
|
||||
QCoreApplication::setOrganizationDomain("windesign.at");
|
||||
|
||||
Reference in New Issue
Block a user