| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qeffects.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | class QAlphaWidget: public QWidget, private QEffects | - | ||||||||||||
| 5 | { | - | ||||||||||||
| 6 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||
| 7 | #pragma GCC diagnostic push | - | ||||||||||||
| 8 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||
| 9 | #pragma GCC diagnostic pop | - | ||||||||||||
| 10 | struct QPrivateSignal {}; | - | ||||||||||||
| 11 | public: | - | ||||||||||||
| 12 | QAlphaWidget(QWidget* w, Qt::WindowFlags f = 0); | - | ||||||||||||
| 13 | ~QAlphaWidget(); | - | ||||||||||||
| 14 | - | |||||||||||||
| 15 | void run(int time); | - | ||||||||||||
| 16 | - | |||||||||||||
| 17 | protected: | - | ||||||||||||
| 18 | void paintEvent(QPaintEvent* e) override; | - | ||||||||||||
| 19 | void closeEvent(QCloseEvent*) override; | - | ||||||||||||
| 20 | void alphaBlend(); | - | ||||||||||||
| 21 | bool eventFilter(QObject *, QEvent *) override; | - | ||||||||||||
| 22 | - | |||||||||||||
| 23 | protected : | - | ||||||||||||
| 24 | void render(); | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | private: | - | ||||||||||||
| 27 | QPixmap pm; | - | ||||||||||||
| 28 | double alpha; | - | ||||||||||||
| 29 | QImage backImage; | - | ||||||||||||
| 30 | QImage frontImage; | - | ||||||||||||
| 31 | QImage mixedImage; | - | ||||||||||||
| 32 | QPointer<QWidget> widget; | - | ||||||||||||
| 33 | int duration; | - | ||||||||||||
| 34 | int elapsed; | - | ||||||||||||
| 35 | bool showWidget; | - | ||||||||||||
| 36 | QTimer anim; | - | ||||||||||||
| 37 | QElapsedTimer checkTime; | - | ||||||||||||
| 38 | }; | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | static QAlphaWidget* q_blend = 0; | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | - | |||||||||||||
| 43 | - | |||||||||||||
| 44 | - | |||||||||||||
| 45 | QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f) | - | ||||||||||||
| 46 | : QWidget(QApplication::desktop()->screen(QApplication::desktop()->screenNumber(w)), f) | - | ||||||||||||
| 47 | { | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | setEnabled(false); | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | setAttribute(Qt::WA_NoSystemBackground, true); | - | ||||||||||||
| 52 | widget = w; | - | ||||||||||||
| 53 | alpha = 0; | - | ||||||||||||
| 54 | } never executed: end of block | 0 | ||||||||||||
| 55 | - | |||||||||||||
| 56 | QAlphaWidget::~QAlphaWidget() | - | ||||||||||||
| 57 | { | - | ||||||||||||
| 58 | - | |||||||||||||
| 59 | - | |||||||||||||
| 60 | - | |||||||||||||
| 61 | - | |||||||||||||
| 62 | - | |||||||||||||
| 63 | } | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | - | |||||||||||||
| 66 | - | |||||||||||||
| 67 | - | |||||||||||||
| 68 | void QAlphaWidget::paintEvent(QPaintEvent*) | - | ||||||||||||
| 69 | { | - | ||||||||||||
| 70 | QPainter p(this); | - | ||||||||||||
| 71 | p.drawPixmap(0, 0, pm); | - | ||||||||||||
| 72 | } never executed: end of block | 0 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | - | |||||||||||||
| 75 | - | |||||||||||||
| 76 | - | |||||||||||||
| 77 | - | |||||||||||||
| 78 | void QAlphaWidget::run(int time) | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | duration = time; | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | if (duration < 0
| 0 | ||||||||||||
| 83 | duration = 150; never executed: duration = 150; | 0 | ||||||||||||
| 84 | - | |||||||||||||
| 85 | if (!widget
| 0 | ||||||||||||
| 86 | return; never executed: return; | 0 | ||||||||||||
| 87 | - | |||||||||||||
| 88 | elapsed = 0; | - | ||||||||||||
| 89 | checkTime.start(); | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | showWidget = true; | - | ||||||||||||
| 92 | widget->setAttribute(Qt::WA_WState_ExplicitShowHide, true); | - | ||||||||||||
| 93 | widget->setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(this); | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | move(widget->geometry().x(),widget->geometry().y()); | - | ||||||||||||
| 98 | resize(widget->size().width(), widget->size().height()); | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | frontImage = widget->grab().toImage(); | - | ||||||||||||
| 101 | backImage = QGuiApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId(), | - | ||||||||||||
| 102 | widget->geometry().x(), widget->geometry().y(), | - | ||||||||||||
| 103 | widget->geometry().width(), widget->geometry().height()).toImage(); | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | if (!backImage.isNull()
| 0 | ||||||||||||
| 106 | mixedImage = backImage.copy(); | - | ||||||||||||
| 107 | pm = QPixmap::fromImage(mixedImage); | - | ||||||||||||
| 108 | show(); | - | ||||||||||||
| 109 | setEnabled(false); | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | connect(&anim, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "174"), this, qFlagLocation("1""render()" "\0" __FILE__ ":" "174")); | - | ||||||||||||
| 112 | anim.start(1); | - | ||||||||||||
| 113 | } never executed: else {end of block | 0 | ||||||||||||
| 114 | duration = 0; | - | ||||||||||||
| 115 | render(); | - | ||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||
| 117 | - | |||||||||||||
| 118 | } | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | - | |||||||||||||
| 121 | - | |||||||||||||
| 122 | - | |||||||||||||
| 123 | bool QAlphaWidget::eventFilter(QObject *o, QEvent *e) | - | ||||||||||||
| 124 | { | - | ||||||||||||
| 125 | switch (e->type()) { | - | ||||||||||||
| 126 | case never executed: QEvent::Move:case QEvent::Move:never executed: case QEvent::Move: | 0 | ||||||||||||
| 127 | if (o != widget
| 0 | ||||||||||||
| 128 | break; never executed: break; | 0 | ||||||||||||
| 129 | move(widget->geometry().x(),widget->geometry().y()); | - | ||||||||||||
| 130 | update(); | - | ||||||||||||
| 131 | break; never executed: break; | 0 | ||||||||||||
| 132 | case never executed: QEvent::Hide:case QEvent::Hide:never executed: case QEvent::Hide: | 0 | ||||||||||||
| 133 | case never executed: QEvent::Close:case QEvent::Close:never executed: case QEvent::Close: | 0 | ||||||||||||
| 134 | if (o != widget
| 0 | ||||||||||||
| 135 | break; never executed: break; | 0 | ||||||||||||
| 136 | case never executed: QEvent::MouseButtonPress:case QEvent::MouseButtonPress:never executed: case QEvent::MouseButtonPress:code before this statement never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||
| 137 | case never executed: QEvent::MouseButtonDblClick:case QEvent::MouseButtonDblClick:never executed: case QEvent::MouseButtonDblClick: | 0 | ||||||||||||
| 138 | showWidget = false; | - | ||||||||||||
| 139 | render(); | - | ||||||||||||
| 140 | break; never executed: break; | 0 | ||||||||||||
| 141 | case never executed: QEvent::KeyPress:case QEvent::KeyPress:never executed: {case QEvent::KeyPress: | 0 | ||||||||||||
| 142 | QKeyEvent *ke = (QKeyEvent*)e; | - | ||||||||||||
| 143 | if (ke->matches(QKeySequence::Cancel)
| 0 | ||||||||||||
| 144 | showWidget = false; | - | ||||||||||||
| 145 | } never executed: else {end of block | 0 | ||||||||||||
| 146 | duration = 0; | - | ||||||||||||
| 147 | } never executed: end of block | 0 | ||||||||||||
| 148 | render(); | - | ||||||||||||
| 149 | break; never executed: break; | 0 | ||||||||||||
| 150 | } | - | ||||||||||||
| 151 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 152 | break; never executed: break; | 0 | ||||||||||||
| 153 | } | - | ||||||||||||
| 154 | return never executed: QWidget::eventFilter(o, e);return QWidget::eventFilter(o, e);never executed: return QWidget::eventFilter(o, e); | 0 | ||||||||||||
| 155 | } | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | - | |||||||||||||
| 159 | - | |||||||||||||
| 160 | void QAlphaWidget::closeEvent(QCloseEvent *e) | - | ||||||||||||
| 161 | { | - | ||||||||||||
| 162 | e->accept(); | - | ||||||||||||
| 163 | if (!q_blend
| 0 | ||||||||||||
| 164 | return; never executed: return; | 0 | ||||||||||||
| 165 | - | |||||||||||||
| 166 | showWidget = false; | - | ||||||||||||
| 167 | render(); | - | ||||||||||||
| 168 | - | |||||||||||||
| 169 | QWidget::closeEvent(e); | - | ||||||||||||
| 170 | } never executed: end of block | 0 | ||||||||||||
| 171 | - | |||||||||||||
| 172 | - | |||||||||||||
| 173 | - | |||||||||||||
| 174 | - | |||||||||||||
| 175 | - | |||||||||||||
| 176 | - | |||||||||||||
| 177 | - | |||||||||||||
| 178 | void QAlphaWidget::render() | - | ||||||||||||
| 179 | { | - | ||||||||||||
| 180 | int tempel = checkTime.elapsed(); | - | ||||||||||||
| 181 | if (elapsed >= tempel
| 0 | ||||||||||||
| 182 | elapsed++; never executed: elapsed++; | 0 | ||||||||||||
| 183 | else | - | ||||||||||||
| 184 | elapsed = tempel; never executed: elapsed = tempel; | 0 | ||||||||||||
| 185 | - | |||||||||||||
| 186 | if (duration != 0
| 0 | ||||||||||||
| 187 | alpha = tempel / double(duration); never executed: alpha = tempel / double(duration); | 0 | ||||||||||||
| 188 | else | - | ||||||||||||
| 189 | alpha = 1; never executed: alpha = 1; | 0 | ||||||||||||
| 190 | if (alpha >= 1
| 0 | ||||||||||||
| 191 | anim.stop(); | - | ||||||||||||
| 192 | (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(this); | - | ||||||||||||
| 193 | - | |||||||||||||
| 194 | if (widget
| 0 | ||||||||||||
| 195 | if (!showWidget
| 0 | ||||||||||||
| 196 | - | |||||||||||||
| 197 | - | |||||||||||||
| 198 | - | |||||||||||||
| 199 | - | |||||||||||||
| 200 | widget->hide(); | - | ||||||||||||
| 201 | } never executed: else {end of block | 0 | ||||||||||||
| 202 | - | |||||||||||||
| 203 | - | |||||||||||||
| 204 | widget->setAttribute(Qt::WA_WState_Hidden, true); | - | ||||||||||||
| 205 | widget->show(); | - | ||||||||||||
| 206 | lower(); | - | ||||||||||||
| 207 | } never executed: end of block | 0 | ||||||||||||
| 208 | } | - | ||||||||||||
| 209 | q_blend = 0; | - | ||||||||||||
| 210 | deleteLater(); | - | ||||||||||||
| 211 | } never executed: else {end of block | 0 | ||||||||||||
| 212 | alphaBlend(); | - | ||||||||||||
| 213 | pm = QPixmap::fromImage(mixedImage); | - | ||||||||||||
| 214 | repaint(); | - | ||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||
| 216 | - | |||||||||||||
| 217 | } | - | ||||||||||||
| 218 | - | |||||||||||||
| 219 | - | |||||||||||||
| 220 | - | |||||||||||||
| 221 | - | |||||||||||||
| 222 | void QAlphaWidget::alphaBlend() | - | ||||||||||||
| 223 | { | - | ||||||||||||
| 224 | const int a = qRound(alpha*256); | - | ||||||||||||
| 225 | const int ia = 256 - a; | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | const int sw = frontImage.width(); | - | ||||||||||||
| 228 | const int sh = frontImage.height(); | - | ||||||||||||
| 229 | const int bpl = frontImage.bytesPerLine(); | - | ||||||||||||
| 230 | switch(frontImage.depth()) { | - | ||||||||||||
| 231 | case never executed: 32:case 32:never executed: case 32: | 0 | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | uchar *mixed_data = mixedImage.bits(); | - | ||||||||||||
| 234 | const uchar *back_data = backImage.bits(); | - | ||||||||||||
| 235 | const uchar *front_data = frontImage.bits(); | - | ||||||||||||
| 236 | - | |||||||||||||
| 237 | for (int sy = 0; sy < sh
| 0 | ||||||||||||
| 238 | quint32* mixed = (quint32*)mixed_data; | - | ||||||||||||
| 239 | const quint32* back = (const quint32*)back_data; | - | ||||||||||||
| 240 | const quint32* front = (const quint32*)front_data; | - | ||||||||||||
| 241 | for (int sx = 0; sx < sw
| 0 | ||||||||||||
| 242 | quint32 bp = back[sx]; | - | ||||||||||||
| 243 | quint32 fp = front[sx]; | - | ||||||||||||
| 244 | - | |||||||||||||
| 245 | mixed[sx] = qRgb((qRed(bp)*ia + qRed(fp)*a)>>8, | - | ||||||||||||
| 246 | (qGreen(bp)*ia + qGreen(fp)*a)>>8, | - | ||||||||||||
| 247 | (qBlue(bp)*ia + qBlue(fp)*a)>>8); | - | ||||||||||||
| 248 | } never executed: end of block | 0 | ||||||||||||
| 249 | mixed_data += bpl; | - | ||||||||||||
| 250 | back_data += bpl; | - | ||||||||||||
| 251 | front_data += bpl; | - | ||||||||||||
| 252 | } never executed: end of block | 0 | ||||||||||||
| 253 | } | - | ||||||||||||
| 254 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||
| 255 | break; never executed: break; | 0 | ||||||||||||
| 256 | } | - | ||||||||||||
| 257 | } | - | ||||||||||||
| 258 | class QRollEffect : public QWidget, private QEffects | - | ||||||||||||
| 259 | { | - | ||||||||||||
| 260 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||
| 261 | #pragma GCC diagnostic push | - | ||||||||||||
| 262 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||
| 263 | #pragma GCC diagnostic pop | - | ||||||||||||
| 264 | struct QPrivateSignal {}; | - | ||||||||||||
| 265 | public: | - | ||||||||||||
| 266 | QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient); | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | void run(int time); | - | ||||||||||||
| 269 | - | |||||||||||||
| 270 | protected: | - | ||||||||||||
| 271 | void paintEvent(QPaintEvent*) override; | - | ||||||||||||
| 272 | void closeEvent(QCloseEvent*) override; | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | private : | - | ||||||||||||
| 275 | void scroll(); | - | ||||||||||||
| 276 | - | |||||||||||||
| 277 | private: | - | ||||||||||||
| 278 | QPointer<QWidget> widget; | - | ||||||||||||
| 279 | - | |||||||||||||
| 280 | int currentHeight; | - | ||||||||||||
| 281 | int currentWidth; | - | ||||||||||||
| 282 | int totalHeight; | - | ||||||||||||
| 283 | int totalWidth; | - | ||||||||||||
| 284 | - | |||||||||||||
| 285 | int duration; | - | ||||||||||||
| 286 | int elapsed; | - | ||||||||||||
| 287 | bool done; | - | ||||||||||||
| 288 | bool showWidget; | - | ||||||||||||
| 289 | int orientation; | - | ||||||||||||
| 290 | - | |||||||||||||
| 291 | QTimer anim; | - | ||||||||||||
| 292 | QElapsedTimer checkTime; | - | ||||||||||||
| 293 | - | |||||||||||||
| 294 | QPixmap pm; | - | ||||||||||||
| 295 | }; | - | ||||||||||||
| 296 | - | |||||||||||||
| 297 | static QRollEffect* q_roll = 0; | - | ||||||||||||
| 298 | - | |||||||||||||
| 299 | - | |||||||||||||
| 300 | - | |||||||||||||
| 301 | - | |||||||||||||
| 302 | QRollEffect::QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient) | - | ||||||||||||
| 303 | : QWidget(0, f), orientation(orient) | - | ||||||||||||
| 304 | { | - | ||||||||||||
| 305 | - | |||||||||||||
| 306 | setEnabled(false); | - | ||||||||||||
| 307 | - | |||||||||||||
| 308 | - | |||||||||||||
| 309 | widget = w; | - | ||||||||||||
| 310 | ((!(widget)) ? qt_assert("widget",__FILE__,389) : qt_noop()); | - | ||||||||||||
| 311 | - | |||||||||||||
| 312 | setAttribute(Qt::WA_NoSystemBackground, true); | - | ||||||||||||
| 313 | - | |||||||||||||
| 314 | if (widget->testAttribute(Qt::WA_Resized)
| 0 | ||||||||||||
| 315 | totalWidth = widget->width(); | - | ||||||||||||
| 316 | totalHeight = widget->height(); | - | ||||||||||||
| 317 | } never executed: else {end of block | 0 | ||||||||||||
| 318 | totalWidth = widget->sizeHint().width(); | - | ||||||||||||
| 319 | totalHeight = widget->sizeHint().height(); | - | ||||||||||||
| 320 | } never executed: end of block | 0 | ||||||||||||
| 321 | - | |||||||||||||
| 322 | currentHeight = totalHeight; | - | ||||||||||||
| 323 | currentWidth = totalWidth; | - | ||||||||||||
| 324 | - | |||||||||||||
| 325 | if (orientation & (RightScroll|LeftScroll)
| 0 | ||||||||||||
| 326 | currentWidth = 0; never executed: currentWidth = 0; | 0 | ||||||||||||
| 327 | if (orientation & (DownScroll|UpScroll)
| 0 | ||||||||||||
| 328 | currentHeight = 0; never executed: currentHeight = 0; | 0 | ||||||||||||
| 329 | - | |||||||||||||
| 330 | pm = widget->grab(); | - | ||||||||||||
| 331 | } never executed: end of block | 0 | ||||||||||||
| 332 | - | |||||||||||||
| 333 | - | |||||||||||||
| 334 | - | |||||||||||||
| 335 | - | |||||||||||||
| 336 | void QRollEffect::paintEvent(QPaintEvent*) | - | ||||||||||||
| 337 | { | - | ||||||||||||
| 338 | int x = orientation & RightScroll
| 0 | ||||||||||||
| 339 | int y = orientation & DownScroll
| 0 | ||||||||||||
| 340 | - | |||||||||||||
| 341 | QPainter p(this); | - | ||||||||||||
| 342 | p.drawPixmap(x, y, pm); | - | ||||||||||||
| 343 | } never executed: end of block | 0 | ||||||||||||
| 344 | - | |||||||||||||
| 345 | - | |||||||||||||
| 346 | - | |||||||||||||
| 347 | - | |||||||||||||
| 348 | void QRollEffect::closeEvent(QCloseEvent *e) | - | ||||||||||||
| 349 | { | - | ||||||||||||
| 350 | e->accept(); | - | ||||||||||||
| 351 | if (done
| 0 | ||||||||||||
| 352 | return; never executed: return; | 0 | ||||||||||||
| 353 | - | |||||||||||||
| 354 | showWidget = false; | - | ||||||||||||
| 355 | done = true; | - | ||||||||||||
| 356 | scroll(); | - | ||||||||||||
| 357 | - | |||||||||||||
| 358 | QWidget::closeEvent(e); | - | ||||||||||||
| 359 | } never executed: end of block | 0 | ||||||||||||
| 360 | - | |||||||||||||
| 361 | - | |||||||||||||
| 362 | - | |||||||||||||
| 363 | - | |||||||||||||
| 364 | - | |||||||||||||
| 365 | - | |||||||||||||
| 366 | - | |||||||||||||
| 367 | void QRollEffect::run(int time) | - | ||||||||||||
| 368 | { | - | ||||||||||||
| 369 | if (!widget
| 0 | ||||||||||||
| 370 | return; never executed: return; | 0 | ||||||||||||
| 371 | - | |||||||||||||
| 372 | duration = time; | - | ||||||||||||
| 373 | elapsed = 0; | - | ||||||||||||
| 374 | - | |||||||||||||
| 375 | if (duration < 0
| 0 | ||||||||||||
| 376 | int dist = 0; | - | ||||||||||||
| 377 | if (orientation & (RightScroll|LeftScroll)
| 0 | ||||||||||||
| 378 | dist += totalWidth - currentWidth; never executed: dist += totalWidth - currentWidth; | 0 | ||||||||||||
| 379 | if (orientation & (DownScroll|UpScroll)
| 0 | ||||||||||||
| 380 | dist += totalHeight - currentHeight; never executed: dist += totalHeight - currentHeight; | 0 | ||||||||||||
| 381 | duration = qMin(qMax(dist/3, 50), 120); | - | ||||||||||||
| 382 | } never executed: end of block | 0 | ||||||||||||
| 383 | - | |||||||||||||
| 384 | connect(&anim, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "463"), this, qFlagLocation("1""scroll()" "\0" __FILE__ ":" "463")); | - | ||||||||||||
| 385 | - | |||||||||||||
| 386 | move(widget->geometry().x(),widget->geometry().y()); | - | ||||||||||||
| 387 | resize(qMin(currentWidth, totalWidth), qMin(currentHeight, totalHeight)); | - | ||||||||||||
| 388 | - | |||||||||||||
| 389 | - | |||||||||||||
| 390 | widget->setAttribute(Qt::WA_WState_ExplicitShowHide, true); | - | ||||||||||||
| 391 | widget->setAttribute(Qt::WA_WState_Hidden, false); | - | ||||||||||||
| 392 | - | |||||||||||||
| 393 | show(); | - | ||||||||||||
| 394 | setEnabled(false); | - | ||||||||||||
| 395 | - | |||||||||||||
| 396 | showWidget = true; | - | ||||||||||||
| 397 | done = false; | - | ||||||||||||
| 398 | anim.start(1); | - | ||||||||||||
| 399 | checkTime.start(); | - | ||||||||||||
| 400 | } never executed: end of block | 0 | ||||||||||||
| 401 | - | |||||||||||||
| 402 | - | |||||||||||||
| 403 | - | |||||||||||||
| 404 | - | |||||||||||||
| 405 | void QRollEffect::scroll() | - | ||||||||||||
| 406 | { | - | ||||||||||||
| 407 | if (!done
| 0 | ||||||||||||
| 408 | int tempel = checkTime.elapsed(); | - | ||||||||||||
| 409 | if (elapsed >= tempel
| 0 | ||||||||||||
| 410 | elapsed++; never executed: elapsed++; | 0 | ||||||||||||
| 411 | else | - | ||||||||||||
| 412 | elapsed = tempel; never executed: elapsed = tempel; | 0 | ||||||||||||
| 413 | - | |||||||||||||
| 414 | if (currentWidth != totalWidth
| 0 | ||||||||||||
| 415 | currentWidth = totalWidth * (elapsed/duration) | - | ||||||||||||
| 416 | + (2 * totalWidth * (elapsed%duration) + duration) | - | ||||||||||||
| 417 | / (2 * duration); | - | ||||||||||||
| 418 | - | |||||||||||||
| 419 | done = (currentWidth >= totalWidth); | - | ||||||||||||
| 420 | } never executed: end of block | 0 | ||||||||||||
| 421 | if (currentHeight != totalHeight
| 0 | ||||||||||||
| 422 | currentHeight = totalHeight * (elapsed/duration) | - | ||||||||||||
| 423 | + (2 * totalHeight * (elapsed%duration) + duration) | - | ||||||||||||
| 424 | / (2 * duration); | - | ||||||||||||
| 425 | - | |||||||||||||
| 426 | done = (currentHeight >= totalHeight); | - | ||||||||||||
| 427 | } never executed: end of block | 0 | ||||||||||||
| 428 | done = (
| 0 | ||||||||||||
| 429 | (
| 0 | ||||||||||||
| 430 | - | |||||||||||||
| 431 | int w = totalWidth; | - | ||||||||||||
| 432 | int h = totalHeight; | - | ||||||||||||
| 433 | int x = widget->geometry().x(); | - | ||||||||||||
| 434 | int y = widget->geometry().y(); | - | ||||||||||||
| 435 | - | |||||||||||||
| 436 | if (orientation & RightScroll
| 0 | ||||||||||||
| 437 | w = qMin(currentWidth, totalWidth); never executed: w = qMin(currentWidth, totalWidth); | 0 | ||||||||||||
| 438 | if (orientation & DownScroll
| 0 | ||||||||||||
| 439 | h = qMin(currentHeight, totalHeight); never executed: h = qMin(currentHeight, totalHeight); | 0 | ||||||||||||
| 440 | - | |||||||||||||
| 441 | setUpdatesEnabled(false); | - | ||||||||||||
| 442 | if (orientation & UpScroll
| 0 | ||||||||||||
| 443 | y = widget->geometry().y() + qMax(0, totalHeight - currentHeight); never executed: y = widget->geometry().y() + qMax(0, totalHeight - currentHeight); | 0 | ||||||||||||
| 444 | if (orientation & LeftScroll
| 0 | ||||||||||||
| 445 | x = widget->geometry().x() + qMax(0, totalWidth - currentWidth); never executed: x = widget->geometry().x() + qMax(0, totalWidth - currentWidth); | 0 | ||||||||||||
| 446 | if (orientation & UpScroll
| 0 | ||||||||||||
| 447 | move(x, y); never executed: move(x, y); | 0 | ||||||||||||
| 448 | - | |||||||||||||
| 449 | resize(w, h); | - | ||||||||||||
| 450 | setUpdatesEnabled(true); | - | ||||||||||||
| 451 | repaint(); | - | ||||||||||||
| 452 | } never executed: end of block | 0 | ||||||||||||
| 453 | if (done
| 0 | ||||||||||||
| 454 | anim.stop(); | - | ||||||||||||
| 455 | if (widget
| 0 | ||||||||||||
| 456 | if (!showWidget
| 0 | ||||||||||||
| 457 | - | |||||||||||||
| 458 | - | |||||||||||||
| 459 | - | |||||||||||||
| 460 | - | |||||||||||||
| 461 | widget->hide(); | - | ||||||||||||
| 462 | } never executed: else {end of block | 0 | ||||||||||||
| 463 | - | |||||||||||||
| 464 | - | |||||||||||||
| 465 | widget->setAttribute(Qt::WA_WState_Hidden, true); | - | ||||||||||||
| 466 | widget->show(); | - | ||||||||||||
| 467 | lower(); | - | ||||||||||||
| 468 | } never executed: end of block | 0 | ||||||||||||
| 469 | } | - | ||||||||||||
| 470 | q_roll = 0; | - | ||||||||||||
| 471 | deleteLater(); | - | ||||||||||||
| 472 | } never executed: end of block | 0 | ||||||||||||
| 473 | } never executed: end of block | 0 | ||||||||||||
| 474 | - | |||||||||||||
| 475 | - | |||||||||||||
| 476 | - | |||||||||||||
| 477 | - | |||||||||||||
| 478 | - | |||||||||||||
| 479 | void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time) | - | ||||||||||||
| 480 | { | - | ||||||||||||
| 481 | if (q_roll
| 0 | ||||||||||||
| 482 | q_roll->deleteLater(); | - | ||||||||||||
| 483 | q_roll = 0; | - | ||||||||||||
| 484 | } never executed: end of block | 0 | ||||||||||||
| 485 | - | |||||||||||||
| 486 | if (!w
| 0 | ||||||||||||
| 487 | return; never executed: return; | 0 | ||||||||||||
| 488 | - | |||||||||||||
| 489 | QApplication::sendPostedEvents(w, QEvent::Move); | - | ||||||||||||
| 490 | QApplication::sendPostedEvents(w, QEvent::Resize); | - | ||||||||||||
| 491 | Qt::WindowFlags flags = Qt::ToolTip; | - | ||||||||||||
| 492 | - | |||||||||||||
| 493 | - | |||||||||||||
| 494 | q_roll = new QRollEffect(w, flags, orient); | - | ||||||||||||
| 495 | q_roll->run(time); | - | ||||||||||||
| 496 | } never executed: end of block | 0 | ||||||||||||
| 497 | - | |||||||||||||
| 498 | - | |||||||||||||
| 499 | - | |||||||||||||
| 500 | - | |||||||||||||
| 501 | void qFadeEffect(QWidget* w, int time) | - | ||||||||||||
| 502 | { | - | ||||||||||||
| 503 | if (q_blend
| 0 | ||||||||||||
| 504 | q_blend->deleteLater(); | - | ||||||||||||
| 505 | q_blend = 0; | - | ||||||||||||
| 506 | } never executed: end of block | 0 | ||||||||||||
| 507 | - | |||||||||||||
| 508 | if (!w
| 0 | ||||||||||||
| 509 | return; never executed: return; | 0 | ||||||||||||
| 510 | - | |||||||||||||
| 511 | QApplication::sendPostedEvents(w, QEvent::Move); | - | ||||||||||||
| 512 | QApplication::sendPostedEvents(w, QEvent::Resize); | - | ||||||||||||
| 513 | - | |||||||||||||
| 514 | Qt::WindowFlags flags = Qt::ToolTip; | - | ||||||||||||
| 515 | - | |||||||||||||
| 516 | - | |||||||||||||
| 517 | q_blend = new QAlphaWidget(w, flags); | - | ||||||||||||
| 518 | - | |||||||||||||
| 519 | q_blend->run(time); | - | ||||||||||||
| 520 | } never executed: end of block | 0 | ||||||||||||
| 521 | - | |||||||||||||
| 522 | - | |||||||||||||
| 523 | - | |||||||||||||
| 524 | - | |||||||||||||
| 525 | - | |||||||||||||
| 526 | - | |||||||||||||
| 527 | - | |||||||||||||
| Switch to Source code | Preprocessed file |