swift
splashscreen.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
4 #include "splashscreen.h"
5 
6 #include <QPainter>
7 #include <QtMath>
8 
9 using namespace swift::misc;
10 
11 namespace swift::gui
12 {
13  CSplashScreen::CSplashScreen(const QPixmap &pixmap, const QFont &font)
14  {
15  const int height = qFloor(pixmap.height() * 1.2);
16  const int width = pixmap.width();
17  QPixmap splash(pixmap.width(), height);
18  splash.fill(Qt::transparent);
19 
20  QPainter painter(&splash);
21  painter.drawPixmap(0, 0, pixmap);
22 
23  const int statusbar_height = qFloor((height - pixmap.height()) / 2.0);
24  QPixmap statusbar(width, statusbar_height);
25  statusbar.fill(QColor(200, 200, 200));
26  painter.drawPixmap(0, height - statusbar_height, statusbar);
27 
28  this->setPixmap(splash);
29  this->setFont(font);
30  }
31 
32  void CSplashScreen::showStatusMessage(const QString &msg)
33  {
34  if (msg.isEmpty()) { return; }
35  this->showMessage(msg, Qt::AlignHCenter | Qt::AlignBottom);
36  }
37 } // namespace swift::gui
GUI related classes.
Free functions in swift::misc.