MessageBubble::MessageBubble(QGraphicsWidget* parent) : GraphicsHudWidget(parent) , d(new MessageBubblePrivate) { d->mWidget = new QGraphicsWidget; d->mCountDownWidget = new CountDownWidget; d->mCountDownWidget->setValue(1); d->mLabel = new GraphicsHudLabel; QTimeLine* timeLine = new QTimeLine(TIMEOUT, this); connect(timeLine, SIGNAL(valueChanged(qreal)), SLOT(slotTimeLineChanged(qreal))); connect(timeLine, SIGNAL(finished()), SLOT(fadeOut())); connect(this, SIGNAL(fadedOut()), SLOT(deleteLater())); timeLine->start(); d->mLayout = new QGraphicsLinearLayout(d->mWidget); d->mLayout->setContentsMargins(0, 0, 0, 0); d->mLayout->addItem(d->mCountDownWidget); d->mLayout->addItem(d->mLabel); init(d->mWidget, GraphicsHudWidget::OptionCloseButton); }
bool KWinKScreenHelperEffect::nativeEventFilter(const QByteArray &eventType, void *message, long int *result) { Q_UNUSED(result); if (eventType != "xcb_generic_event_t") { return false; } #ifdef HAVE_XCB if (m_isValid && QX11Info::isPlatformX11()) { auto e = static_cast<xcb_generic_event_t *>(message); const uint8_t type = e->response_type & ~0x80; if (type == XCB_PROPERTY_NOTIFY) { auto *event = reinterpret_cast<xcb_property_notify_event_t *>(e); if (event->window == QX11Info::appRootWindow()) { if (event->atom != m_atom) { return false; } auto cookie = xcb_get_property(QX11Info::connection(), false, QX11Info::appRootWindow(), m_atom, XCB_ATOM_CARDINAL, 0, 1); QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply(xcb_get_property_reply(QX11Info::connection(), cookie, NULL)); if (reply.isNull() || reply.data()->value_len != 1 || reply.data()->format != uint8_t(32)) { return false; } auto *data = reinterpret_cast<uint32_t *>(xcb_get_property_value(reply.data())); if (!data) { return false; } switch(*data) { case 1: m_state = FadingOutState; break; case 2: m_state = FadedOutState; if (m_running) { Q_EMIT fadedOut(); } break; case 3: m_state = FadingInState; m_running = false; m_abortTimer.stop(); break; default: m_state = NormalState; m_running = false; } Q_EMIT stateChanged(m_state); } } } #else Q_UNUSED(message); #endif return false; }
// ---------------------- SLOTS ------------------------------------ void ImageItem::animationFinished() { mIsAnimationFinished=true; if(!fade()) emit fadedOut(); else emit fadedIn(); }
float CloudsTransitionController::getFadeValue(){ if(transitioning){ if(fadingOut()){ return 1.0 - transitionPercent; } else{ return transitionPercent; } } return fadedOut() ? 0.0 : 1.0; }
bool KWinKScreenHelperEffect::start() { m_isValid = checkValid(); if (!m_isValid) { // emit fade out right away since the effect is not available Q_EMIT fadedOut(); return false; } m_running = true; setEffectProperty(1); m_abortTimer.start(); return true; }