void StatusView::setMessage( BString &title, BString &details, status_t error) { D_OPERATION(("StatusView::setMessage(%s)\n", title.String())); // get the tip manager instance and reset TipManager *manager = TipManager::Instance(); manager->removeAll(this); // append error string if (error) { title << " (" << strerror(error) << ")"; } // truncate if necessary bool truncated = false; m_fullText = title; if (be_plain_font->StringWidth(title.String()) > Bounds().Width() - 25.0) { be_plain_font->TruncateString(&title, B_TRUNCATE_END, Bounds().Width() - 25.0); truncated = true; } BStringView::SetText(title.String()); if (truncated || details.CountChars() > 0) { BString tip = m_fullText; if (details.CountChars() > 0) { tip << "\n" << details; } manager->setTip(tip.String(), this); } if (error) { beep(); // set icon if (m_icon) { delete m_icon; m_icon = 0; } BRect iconRect(0.0, 0.0, 7.0, 11.0); m_icon = new BBitmap(iconRect, B_CMAP8); m_icon->SetBits(ERROR_ICON_BITS, 96, 0, B_CMAP8); } else { // set icon if (m_icon) { delete m_icon; m_icon = 0; } BRect iconRect(0.0, 0.0, 7.0, 11.0); m_icon = new BBitmap(iconRect, B_CMAP8); m_icon->SetBits(INFO_ICON_BITS, 96, 0, B_CMAP8); } m_dirty = true; startFade(); Invalidate(); }
void StatusView::setErrorMessage( BString text, bool error) { D_OPERATION(("StatusView::setErrorMessage(%s)\n", text.String())); // get the tip manager instance and reset TipManager *manager = TipManager::Instance(); manager->removeAll(this); // truncate if necessary m_fullText = text; if (be_plain_font->StringWidth(text.String()) > Bounds().Width() - 25.0) { be_plain_font->TruncateString(&text, B_TRUNCATE_END, Bounds().Width() - 25.0); manager->setTip(m_fullText.String(), this); } BStringView::SetText(text.String()); if (error) { beep(); // set icon if (m_icon) { delete m_icon; m_icon = 0; } BRect iconRect(0.0, 0.0, 7.0, 11.0); m_icon = new BBitmap(iconRect, B_CMAP8); m_icon->SetBits(ERROR_ICON_BITS, 96, 0, B_CMAP8); } else { // set icon if (m_icon) { delete m_icon; m_icon = 0; } BRect iconRect(0.0, 0.0, 7.0, 11.0); m_icon = new BBitmap(iconRect, B_CMAP8); m_icon->SetBits(INFO_ICON_BITS, 96, 0, B_CMAP8); } m_dirty = true; startFade(); Invalidate(); }
KisFloatingMessage::KisFloatingMessage(const QString &message, QWidget *parent, bool showOverParent) : QWidget(parent) , m_message(message) , m_showOverParent(showOverParent) { m_icon = koIcon("calligrakrita").pixmap(256, 256).toImage(); setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); setFocusPolicy(Qt::NoFocus); setAttribute(Qt::WA_ShowWithoutActivating); setFont(QFont("sans-serif")); #ifdef Q_WS_X11 KWindowSystem::setType( winId(), NET::Notification ); #endif m_timer.setSingleShot( true ); connect(&m_timer, SIGNAL(timeout()), SLOT(startFade())); }