void KalziumTip::display() { if( !m_tippedElement ) return; delete m_richText; QString elementname = m_tippedElement->elname(); QString number = i18n( "Number: %1" ) .arg( QString::number(m_tippedElement->number()) ); QString mass = i18n( "Mass: %1" ) .arg( KalziumUtils::localizedValue(m_tippedElement->mass(), 6) ); m_richText = new QSimpleRichText("<qt><h1>" + elementname + "</h1><p>" + number + "</p><p>" + mass +"</p></qt>", font()); m_richText->setWidth(400); m_maskEffect = isVisible() ? Plain : Dissolve; m_dissolveSize = 24; m_dissolveDelta = -1; displayInternal(); m_frameTimer.start(500/30); move(m_mousePointer); show(); }
void KalziumTip::paintEvent(QPaintEvent* e) { if (m_dirty) { displayInternal(); m_dirty = false; } QPainter p(this); p.drawPixmap(e->rect().topLeft(), m_pixmap, e->rect()); }
void KickerTip::display() { if (!tippingEnabled()) { return; } { // prevent tips from showing when the active window is fullscreened NETRootInfo ri(qt_xdisplay(), NET::ActiveWindow); NETWinInfo wi(qt_xdisplay(), ri.activeWindow(), ri.rootWindow(), NET::WMState); if (wi.state() & NET::FullScreen) { return; } } QWidget *widget = const_cast<QWidget*>(m_tippingFor); KickerTip::Client *client = dynamic_cast<KickerTip::Client*>(widget); if (!client) { return; } // delete the mimefactory and create a new one so any old pixmaps used in the // richtext area are freed but the mimefactory is ready to be added to in // the call to updateKickerTip delete m_mimeFactory; m_mimeFactory = new QMimeSourceFactory(); // Declare interchange object and define defaults. Data data; data.maskEffect = Dissolve; data.duration = 2000; data.direction = KPanelApplet::Up; data.mimeFactory = m_mimeFactory; // Tickle the information out of the bastard. client->updateKickerTip(data); if (data.message.isEmpty() && data.subtext.isEmpty() && data.icon.isNull()) { return; } delete m_richText; m_richText = new QSimpleRichText("<qt><h3>" + data.message + "</h3><p>" + data.subtext + "</p></qt>", font(), QString::null, 0, m_mimeFactory); m_richText->setWidth(400); m_direction = data.direction; if (KickerSettings::mouseOversShowIcon()) { m_icon = data.icon; } else if (KickerSettings::mouseOversShowText()) { m_icon = QPixmap(); } else { // don't bother since we have NOTHING to show return; } m_maskEffect = isVisible() ? Plain : data.maskEffect; m_dissolveSize = 24; m_dissolveDelta = -1; displayInternal(); m_frameTimer.start(1000 / DEFAULT_FRAMES_PER_SECOND); // close the message window after given mS if (data.duration > 0) { disconnect(&m_timer, SIGNAL(timeout()), 0, 0); connect(&m_timer, SIGNAL(timeout()), SLOT(hide())); m_timer.start(data.duration, true); } else { m_timer.stop(); } move(KickerLib::popupPosition(m_direction, this, m_tippingFor)); show(); }