void MessageWidget::setMessage(const QString &msg, MessageType type, bool showCloseButton) { if (isActive() && !msg.isEmpty() && type!=msgType) { setVisible(false); } msgType=type; if (msg.isEmpty() && isVisible()) { setVisible(false); return; } // QString text=msg; // if (text.length()>154) { // text=text.left(150)+QLatin1String("..."); // } // if (msg.length()>500) { // setToolTip(msg.left(500)+QLatin1String("...")); // } else { // setToolTip(msg); // } // setText(text); setText(msg); setToolTip(msg); setMessageType(type); setCloseButtonVisible(showCloseButton); #if defined NO_ANIMATED_SHOW setVisible(true); #else if (!parentWidget()->isVisible()) { show(); setVisible(true); } else { animatedShow(); } #endif }
PasswordBar::PasswordBar(QWidget *parent) :KMessageWidget(parent) { setCloseButtonVisible(false); setMessageType(KMessageWidget::Information); QAction* action = new QAction(i18nc("@action:remember password", "&Remember"), this); connect(action, SIGNAL(triggered()), this, SLOT(onRememberButtonClicked())); addAction(action); action = new QAction(i18nc("@action:never for this site", "Ne&ver for this site"), this); connect(action, SIGNAL(triggered()), this, SLOT(onNeverButtonClicked())); addAction(action); action = new QAction(i18nc("@action:not now", "N&ot now"), this); connect(action, SIGNAL(triggered()), this, SLOT(onNotNowButtonClicked())); addAction(action); }
CrashMessageBar::CrashMessageBar(const QString &message, QWidget *parent) : KMessageWidget(parent) { connect(this, SIGNAL(accepted()), this, SLOT(hideAndDelete())); connect(this, SIGNAL(rejected()), this, SLOT(hideAndDelete())); setMessageType(KMessageWidget::Warning); QSize sz = size(); sz.setWidth(qobject_cast<QWidget *>(parent)->size().width()); resize(sz); setCloseButtonVisible(false); setText(message); QAction *acceptAction = new QAction(i18n("Yes"), this); connect(acceptAction, SIGNAL(triggered(bool)), this, SIGNAL(accepted())); addAction(acceptAction); QAction *rejectAction = new QAction(i18n("No"), this); connect(rejectAction, SIGNAL(triggered(bool)), this, SIGNAL(rejected())); addAction(rejectAction); }