BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SplashScreen Class Reference
Inheritance diagram for SplashScreen:
[legend]
Collaboration diagram for SplashScreen:
[legend]

Public Slots

void setProgress (int value)
 

Public Member Functions

 SplashScreen (QWidget *parent=nullptr)
 
void start (int show_during=1500)
 

Protected Member Functions

void drawContents (QPainter *painter)
 

Private Attributes

int m_percentage_done
 

Detailed Description

Definition at line 20 of file SplashScreen.h.

Constructor & Destructor Documentation

◆ SplashScreen()

SplashScreen::SplashScreen ( QWidget *  parent = nullptr)
explicit

Definition at line 24 of file SplashScreen.cpp.

25  : QSplashScreen(QPixmap(":/images/splashscreen.png")), m_percentage_done(0)
26 
27 {
28  QSplashScreen::setCursor(Qt::BusyCursor);
29 
30  QFont font;
31  font.setPointSize(StyleUtils::SystemPointSize() * 0.9);
32  font.setBold(false);
33  QSplashScreen::setFont(font);
34 }
int m_percentage_done
Definition: SplashScreen.h:34
int SystemPointSize()
Returns size in points of default system font.
Definition: StyleUtils.cpp:116

References StyleUtils::SystemPointSize().

Here is the call graph for this function:

Member Function Documentation

◆ drawContents()

void SplashScreen::drawContents ( QPainter *  painter)
protected

Definition at line 58 of file SplashScreen.cpp.

59 {
60  QSplashScreen::drawContents(painter);
61 
62  auto img_rect = frameGeometry();
63  auto char_height = StyleUtils::SizeOfLetterM().height();
64 
65  QRect textRect(img_rect.width() * 0.02, img_rect.height() - char_height * 2.5,
66  img_rect.width() * 0.5, char_height * 3);
67 
68  QString versionText = QString("version ").append(GUIHelpers::getBornAgainVersionString());
69  style()->drawItemText(painter, textRect, 0, this->palette(), true, versionText);
70 
71  QString loadingText("loading . ");
72  for (size_t i = 0; i < size_t(m_percentage_done / 20); ++i) {
73  loadingText.append(". ");
74  }
75 
76  QRect loadingRect(img_rect.width() * 0.8, img_rect.height() - char_height * 2.5,
77  img_rect.width(), char_height * 3);
78  style()->drawItemText(painter, loadingRect, 0, this->palette(), true, loadingText);
79 }
QString getBornAgainVersionString()
Definition: GUIHelpers.cpp:130
QSize SizeOfLetterM(const QWidget *widget=nullptr)
Returns size of largest letter of default system font.
Definition: StyleUtils.cpp:110

References GUIHelpers::getBornAgainVersionString(), m_percentage_done, and StyleUtils::SizeOfLetterM().

Here is the call graph for this function:

◆ setProgress

void SplashScreen::setProgress ( int  value)
slot

Definition at line 48 of file SplashScreen.cpp.

49 {
50  m_percentage_done = value;
51  if (m_percentage_done > 100)
52  m_percentage_done = 100;
53  if (m_percentage_done < 0)
55  update();
56 }

References m_percentage_done.

Referenced by start().

◆ start()

void SplashScreen::start ( int  show_during = 1500)

Definition at line 36 of file SplashScreen.cpp.

37 {
38  show();
39  QTime dieTime = QTime::currentTime().addMSecs(show_during);
40  QElapsedTimer timer;
41  timer.start();
42  while (QTime::currentTime() < dieTime) {
43  setProgress(timer.elapsed() / (show_during / 100));
44  QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
45  }
46 }
void setProgress(int value)

References setProgress().

Here is the call graph for this function:

Member Data Documentation

◆ m_percentage_done

int SplashScreen::m_percentage_done
private

Definition at line 34 of file SplashScreen.h.

Referenced by drawContents(), and setProgress().


The documentation for this class was generated from the following files: