Skip to content
Snippets Groups Projects
Commit 5cebfce8 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

GUI: rm splashscreen

Claim was outdated (GISAS only).

This resolves Redmine2486
parent 78088a86
No related branches found
No related tags found
1 merge request!31GUI: rm splashscreen
Pipeline #35141 passed
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/coregui/mainwindow/SplashScreen.cpp
//! @brief Implements class SplashScreen
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/coregui/mainwindow/SplashScreen.h"
#include "GUI/coregui/utils/GUIHelpers.h"
#include "GUI/coregui/utils/StyleUtils.h"
#include <QCoreApplication>
#include <QDebug>
#include <QElapsedTimer>
#include <QStyle>
#include <QTime>
SplashScreen::SplashScreen(QWidget*)
: QSplashScreen(QPixmap(":/images/splashscreen.png")), m_percentage_done(0)
{
QSplashScreen::setCursor(Qt::BusyCursor);
QFont font;
font.setPointSize(StyleUtils::SystemPointSize() * 0.9);
font.setBold(false);
QSplashScreen::setFont(font);
}
void SplashScreen::start(int show_during)
{
show();
QTime dieTime = QTime::currentTime().addMSecs(show_during);
QElapsedTimer timer;
timer.start();
while (QTime::currentTime() < dieTime) {
setProgress(timer.elapsed() / (show_during / 100));
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
}
void SplashScreen::setProgress(int value)
{
m_percentage_done = value;
if (m_percentage_done > 100)
m_percentage_done = 100;
if (m_percentage_done < 0)
m_percentage_done = 0;
update();
}
void SplashScreen::drawContents(QPainter* painter)
{
QSplashScreen::drawContents(painter);
auto img_rect = frameGeometry();
auto char_height = StyleUtils::SizeOfLetterM().height();
QRect textRect(img_rect.width() * 0.02, img_rect.height() - char_height * 2.5,
img_rect.width() * 0.5, char_height * 3);
QString versionText = QString("version ").append(GUIHelpers::getBornAgainVersionString());
style()->drawItemText(painter, textRect, 0, this->palette(), true, versionText);
QString loadingText("loading . ");
for (size_t i = 0; i < size_t(m_percentage_done / 20); ++i) {
loadingText.append(". ");
}
QRect loadingRect(img_rect.width() * 0.8, img_rect.height() - char_height * 2.5,
img_rect.width(), char_height * 3);
style()->drawItemText(painter, loadingRect, 0, this->palette(), true, loadingText);
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/coregui/mainwindow/SplashScreen.h
//! @brief Defines class SplashScreen
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_COREGUI_MAINWINDOW_SPLASHSCREEN_H
#define BORNAGAIN_GUI_COREGUI_MAINWINDOW_SPLASHSCREEN_H
#include <QSplashScreen>
class SplashScreen : public QSplashScreen {
Q_OBJECT
public:
explicit SplashScreen(QWidget* parent = nullptr);
void start(int show_during = 1500);
public slots:
void setProgress(int value);
protected:
void drawContents(QPainter* painter);
private:
int m_percentage_done;
};
#endif // BORNAGAIN_GUI_COREGUI_MAINWINDOW_SPLASHSCREEN_H
...@@ -50,7 +50,6 @@ ApplicationOptions::ApplicationOptions(int argc, char** argv) : m_options_is_con ...@@ -50,7 +50,6 @@ ApplicationOptions::ApplicationOptions(int argc, char** argv) : m_options_is_con
{ {
m_options.add_options()("help,h", "print help message"); m_options.add_options()("help,h", "print help message");
m_options.add_options()("with-debug", "run application with debug printout"); m_options.add_options()("with-debug", "run application with debug printout");
m_options.add_options()("no-splash", "do not show splash screen");
m_options.add_options()(geometry, bpo::value<std::string>(), m_options.add_options()(geometry, bpo::value<std::string>(),
"Main window geometry, e.g. 1600x1000"); "Main window geometry, e.g. 1600x1000");
m_options.add_options()(nohighdpi, "Run without high-dpi support"); m_options.add_options()(nohighdpi, "Run without high-dpi support");
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
// ************************************************************************************************ // ************************************************************************************************
#include "GUI/coregui/Views/FitWidgets/FitProgressInfo.h" #include "GUI/coregui/Views/FitWidgets/FitProgressInfo.h"
#include "GUI/coregui/mainwindow/SplashScreen.h"
#include "GUI/coregui/mainwindow/mainwindow.h" #include "GUI/coregui/mainwindow/mainwindow.h"
#include "GUI/coregui/utils/hostosinfo.h" #include "GUI/coregui/utils/hostosinfo.h"
#include "GUI/main/MessageHandler.h" #include "GUI/main/MessageHandler.h"
...@@ -39,20 +38,11 @@ int main(int argc, char* argv[]) ...@@ -39,20 +38,11 @@ int main(int argc, char* argv[])
qInstallMessageHandler(MessageHandler); qInstallMessageHandler(MessageHandler);
std::unique_ptr<SplashScreen> splash;
if (!options.find("no-splash")) {
splash.reset(new SplashScreen);
splash->start(/*show_during*/ 1200);
}
MainWindow win; MainWindow win;
if (options.find("geometry")) if (options.find("geometry"))
win.resize(options.mainWindowSize()); win.resize(options.mainWindowSize());
win.show(); win.show();
if (splash)
splash->finish(&win);
return QApplication::exec(); return QApplication::exec();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment