15 #include "messagebox.h"
16 #include "xnodeconnector.h"
17 #include <QMainWindow>
18 #include <QApplication>
19 #include <QDesktopWidget>
22 #include "ui_messageform.h"
26 static QTimer *s_timer = 0L;
28 XMessageBox::XMessageBox(QWidget *parent) {
29 s_pFrmMessage =
new FrmMessage((QWidget*)0, Qt::Tool | Qt::WindowStaysOnBottomHint);
30 s_pFrmMessage->show();
32 s_pFrmMessage->m_widget->hide();
34 QRect rect = QApplication::desktop()->availableGeometry(s_pFrmMessage);
35 int y = rect.bottom() - s_pFrmMessage->height();
36 #if defined __WIN32__ || defined WINDOWS || defined _WIN32
39 s_pFrmMessage->move(0, y);
43 QFont font(s_pFrmMessage->font());
44 font.setPointSize(font.pointSize() * 4 / 5);
45 s_pFrmMessage->m_list->setFont(font);
48 QFont font(s_pFrmMessage->font());
49 font.setPointSize(font.pointSize() * 5 / 6);
50 s_pFrmMessage->m_label->setFont(font);
53 s_timer =
new QTimer(
this);
54 connect(s_timer, SIGNAL(timeout()),
this, SLOT(hide()));
55 s_timer->setSingleShot(
true);
64 s_pFrmMessage->m_widget->hide();
67 XMessageBox::post(
XString msg,
const QIcon &icon,
bool popup,
int duration_ms,
XString tooltip) {
69 s_pFrmMessage->m_widget->hide();
73 s_pFrmMessage->m_label->setText(msg);
74 s_pFrmMessage->m_label->repaint();
75 s_pFrmMessage->m_btn->setIcon(icon);
77 s_pFrmMessage->m_widget->show();
78 s_pFrmMessage->showNormal();
79 s_pFrmMessage->raise();
82 s_pFrmMessage->m_widget->hide();
86 s_timer->setInterval(duration_ms);
92 msg = XTime::now().getTimeFmtStr(
"%H:%M:%S ",
false) + msg;
93 QListWidgetItem *item;
94 item =
new QListWidgetItem(icon, msg, s_pFrmMessage->m_list);
95 item->setToolTip(tooltip);
96 if(s_pFrmMessage->m_list->count() > 100)
97 s_pFrmMessage->m_list->takeItem(0);
98 s_pFrmMessage->m_list->scrollToBottom();