OpenCoverage

qsplashscreen.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qsplashscreen.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13class QSplashScreenPrivate : public QWidgetPrivate-
14{-
15 inline QSplashScreen* q_func() { return static_cast<QSplashScreen *>(q_ptr); } inline const QSplashScreen* q_func() const { return static_cast<const QSplashScreen *>(q_ptr); } friend class QSplashScreen;-
16public:-
17 QPixmap pixmap;-
18 QString currStatus;-
19 QColor currColor;-
20 int currAlign;-
21-
22 inline QSplashScreenPrivate();-
23};-
24QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)-
25 : QWidget(*(new QSplashScreenPrivate()), 0, Qt::SplashScreen | Qt::FramelessWindowHint | f)-
26{-
27 setPixmap(pixmap);-
28}
never executed: end of block
0
29QSplashScreen::QSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowFlags f)-
30 : QWidget(*new QSplashScreenPrivate, parent, Qt::SplashScreen | f)-
31{-
32 d_func()->pixmap = pixmap;-
33 setPixmap(d_func()->pixmap);-
34}
never executed: end of block
0
35-
36-
37-
38-
39QSplashScreen::~QSplashScreen()-
40{-
41}-
42-
43-
44-
45-
46void QSplashScreen::mousePressEvent(QMouseEvent *)-
47{-
48 hide();-
49}
never executed: end of block
0
50-
51-
52-
53-
54-
55-
56-
57void QSplashScreen::repaint()-
58{-
59 QWidget::repaint();-
60 QApplication::flush();-
61}
never executed: end of block
0
62void QSplashScreen::showMessage(const QString &message, int alignment,-
63 const QColor &color)-
64{-
65 QSplashScreenPrivate * const d = d_func();-
66 d->currStatus = message;-
67 d->currAlign = alignment;-
68 d->currColor = color;-
69 messageChanged(d->currStatus);-
70 repaint();-
71}
never executed: end of block
0
72QString QSplashScreen::message() const-
73{-
74 const QSplashScreenPrivate * const d = d_func();-
75 return
never executed: return d->currStatus;
d->currStatus;
never executed: return d->currStatus;
0
76}-
77-
78-
79-
80-
81-
82-
83void QSplashScreen::clearMessage()-
84{-
85 d_func()->currStatus.clear();-
86 messageChanged(d_func()->currStatus);-
87 repaint();-
88}
never executed: end of block
0
89-
90-
91inline static bool waitForWindowExposed(QWindow *window, int timeout = 1000)-
92{-
93 enum { TimeOutMs = 10 };-
94 QElapsedTimer timer;-
95 timer.start();-
96 while (!window->isExposed()
!window->isExposed()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
97 const int remaining = timeout - int(timer.elapsed());-
98 if (remaining <= 0
remaining <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
99 break;
never executed: break;
0
100 QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);-
101 QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);-
102-
103-
104-
105-
106-
107 struct timespec ts = { TimeOutMs / 1000, (TimeOutMs % 1000) * 1000 * 1000 };-
108 nanosleep(&ts, __null);-
109-
110 }
never executed: end of block
0
111 return
never executed: return window->isExposed();
window->isExposed();
never executed: return window->isExposed();
0
112}-
113-
114-
115-
116-
117-
118-
119void QSplashScreen::finish(QWidget *mainWin)-
120{-
121 if (mainWin
mainWinDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
122 if (!mainWin->windowHandle()
!mainWin->windowHandle()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
123 mainWin->createWinId();
never executed: mainWin->createWinId();
0
124 waitForWindowExposed(mainWin->windowHandle());-
125 }
never executed: end of block
0
126 close();-
127}
never executed: end of block
0
128-
129-
130-
131-
132-
133void QSplashScreen::setPixmap(const QPixmap &pixmap)-
134{-
135 QSplashScreenPrivate * const d = d_func();-
136-
137 d->pixmap = pixmap;-
138 setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha());-
139-
140 QRect r(QPoint(), d->pixmap.size() / d->pixmap.devicePixelRatio());-
141 resize(r.size());-
142 move(QApplication::desktop()->screenGeometry().center() - r.center());-
143 if (isVisible()
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
144 repaint();
never executed: repaint();
0
145}
never executed: end of block
0
146-
147-
148-
149-
150-
151const QPixmap QSplashScreen::pixmap() const-
152{-
153 return
never executed: return d_func()->pixmap;
d_func()->pixmap;
never executed: return d_func()->pixmap;
0
154}-
155-
156-
157-
158-
159inline QSplashScreenPrivate::QSplashScreenPrivate() : currAlign(Qt::AlignLeft)-
160{-
161}
never executed: end of block
0
162-
163-
164-
165-
166-
167-
168-
169void QSplashScreen::drawContents(QPainter *painter)-
170{-
171 QSplashScreenPrivate * const d = d_func();-
172 painter->setPen(d->currColor);-
173 QRect r = rect().adjusted(5, 5, -5, -5);-
174 if (Qt::mightBeRichText(d->currStatus)
Qt::mightBeRic...d->currStatus)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
175 QTextDocument doc;-
176-
177-
178-
179 doc.setHtml(d->currStatus);-
180-
181 doc.setTextWidth(r.width());-
182 QTextCursor cursor(&doc);-
183 cursor.select(QTextCursor::Document);-
184 QTextBlockFormat fmt;-
185 fmt.setAlignment(Qt::Alignment(d->currAlign));-
186 cursor.mergeBlockFormat(fmt);-
187 painter->save();-
188 painter->translate(r.topLeft());-
189 doc.drawContents(painter);-
190 painter->restore();-
191 }
never executed: end of block
else {
0
192 painter->drawText(r, d->currAlign, d->currStatus);-
193 }
never executed: end of block
0
194}-
195-
196-
197bool QSplashScreen::event(QEvent *e)-
198{-
199 if (e->type() == QEvent::Paint
e->type() == QEvent::PaintDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
200 QSplashScreenPrivate * const d = d_func();-
201 QPainter painter(this);-
202 if (!d->pixmap.isNull()
!d->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
203 painter.drawPixmap(QPoint(), d->pixmap);
never executed: painter.drawPixmap(QPoint(), d->pixmap);
0
204 drawContents(&painter);-
205 }
never executed: end of block
0
206 return
never executed: return QWidget::event(e);
QWidget::event(e);
never executed: return QWidget::event(e);
0
207}-
208-
209-
210-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9