| 32 | namespace Internal { |
| 33 | |
| 34 | class FadingIndicatorPrivate : public QWidget |
| 35 | { |
| 36 | Q_OBJECT |
| 37 | |
| 38 | public: |
| 39 | FadingIndicatorPrivate(QWidget *parent, FadingIndicator::TextSize size) |
| 40 | : QWidget(parent) |
| 41 | { |
| 42 | setAttribute(Qt::WA_TransparentForMouseEvents, true); |
| 43 | m_effect = new QGraphicsOpacityEffect(this); |
| 44 | setGraphicsEffect(m_effect); |
| 45 | m_effect->setOpacity(.999); |
| 46 | |
| 47 | m_label = new QLabel; |
| 48 | QFont font = m_label->font(); |
| 49 | font.setPixelSize(size == FadingIndicator::LargeText ? 30 : 18); |
| 50 | m_label->setFont(font); |
| 51 | QPalette pal = palette(); |
| 52 | pal.setColor(QPalette::WindowText, pal.color(QPalette::Window)); |
| 53 | m_label->setPalette(pal); |
| 54 | auto layout = new QHBoxLayout; |
| 55 | setLayout(layout); |
| 56 | layout->addWidget(m_label); |
| 57 | } |
| 58 | |
| 59 | void setText(const QString &text) |
| 60 | { |
| 61 | m_pixmap = QPixmap(); |
| 62 | m_label->setText(text); |
| 63 | m_effect->setOpacity(.6); // because of the fat opaque background color |
| 64 | layout()->setSizeConstraint(QLayout::SetFixedSize); |
| 65 | adjustSize(); |
| 66 | QWidget *parent = parentWidget(); |
| 67 | QPoint pos = parent ? (parent->rect().center() - rect().center()) : QPoint(); |
| 68 | if (pixmapIndicator && pixmapIndicator->geometry().intersects(QRect(pos, size()))) |
| 69 | pos.setY(pixmapIndicator->geometry().bottom() + 1); |
| 70 | move(pos); |
| 71 | } |
| 72 | |
| 73 | void setPixmap(const QString &uri) |
| 74 | { |
| 75 | m_label->hide(); |
| 76 | m_pixmap.load(uri); |
| 77 | layout()->setSizeConstraint(QLayout::SetNoConstraint); |
| 78 | resize(m_pixmap.size() / m_pixmap.devicePixelRatio()); |
| 79 | QWidget *parent = parentWidget(); |
| 80 | QPoint pos = parent ? (parent->rect().center() - rect().center()) : QPoint(); |
| 81 | if (textIndicator && textIndicator->geometry().intersects(QRect(pos, size()))) |
| 82 | pos.setY(textIndicator->geometry().bottom() + 1); |
| 83 | move(pos); |
| 84 | } |
| 85 | |
| 86 | void run(int ms) |
| 87 | { |
| 88 | show(); |
| 89 | raise(); |
| 90 | QTimer::singleShot(ms, this, &FadingIndicatorPrivate::runInternal); |
| 91 | } |
nothing calls this directly
no outgoing calls
no test coverage detected