File indexing completed on 2024-04-28 15:40:12
0001 /* SPDX-FileCopyrightText: 2003-2018 Jesper K. Pedersen <blackie@kde.org> 0002 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "SplashScreen.h" 0007 0008 #include <KAboutData> 0009 #include <KLocalizedString> 0010 #include <QPainter> 0011 #include <QRegExp> 0012 #include <QStandardPaths> 0013 0014 MainWindow::SplashScreen *MainWindow::SplashScreen::s_instance = nullptr; 0015 0016 MainWindow::SplashScreen::SplashScreen() 0017 : QSplashScreen(QStandardPaths::locate(QStandardPaths::DataLocation, QString::fromLatin1("pics/splash-large.png"))) 0018 { 0019 s_instance = this; 0020 } 0021 0022 MainWindow::SplashScreen *MainWindow::SplashScreen::instance() 0023 { 0024 return s_instance; 0025 } 0026 0027 void MainWindow::SplashScreen::done() 0028 { 0029 s_instance = nullptr; 0030 (void)close(); 0031 deleteLater(); 0032 } 0033 0034 void MainWindow::SplashScreen::message(const QString &message) 0035 { 0036 m_message = message; 0037 repaint(); 0038 } 0039 0040 void MainWindow::SplashScreen::drawContents(QPainter *painter) 0041 { 0042 painter->save(); 0043 QFont font = painter->font(); 0044 font.setPointSize(10); 0045 painter->setFont(font); 0046 // Currently background is white, we need a contrast color 0047 painter->setPen(Qt::black); 0048 QRect r = QRect(QPoint(20, 265), QSize(360, 25)); 0049 0050 // Version String 0051 QString txt; 0052 QString version = KAboutData::applicationData().version(); 0053 txt = i18n("%1", version); 0054 painter->drawText(r, Qt::AlignRight | Qt::AlignTop, txt); 0055 0056 // Message 0057 painter->drawText(r, Qt::AlignLeft | Qt::AlignTop, m_message); 0058 painter->restore(); 0059 } 0060 0061 // vi:expandtab:tabstop=4 shiftwidth=4: 0062 0063 #include "moc_SplashScreen.cpp"