1 #include "WarningWidget.h"
23 QString sToolIconDir =
FileName(
"$ISISROOT/appdata/images/icons").
expanded();
24 QString qsIconFile(sToolIconDir);
27 mNoWarning =
new QPushButton(mSBar);
28 mNoWarning->setFixedSize(22, 22) ;
29 mNoWarning->setFlat(
true);
30 mNoWarning->setIconSize(QSize(15, 15));
31 mNoWarning->setIcon(QPixmap(qsIconFile +
"/qview_NoWarning.png"));
32 mNoWarning->setToolTip(
"No Warning");
33 mNoWarning->setVisible(
true);
35 mSBar->insertPermanentWidget(0, mNoWarning);
37 mSBar->showMessage(
"Ready");
38 mMsgStr = QString(
"Ready");
41 mbWarningFlag =
false;
45 mDialog->setWindowTitle(
"Warning");
46 mDialog->setSizeGripEnabled(
true);
48 mWindow->installEventFilter(
this);
50 mTextEdit =
new QTextEdit(mDialog);
51 mTextEdit->setReadOnly(
true);
52 QFont font(
"Helvetica", 11);
53 mTextEdit->setFont(font);
56 QPushButton *okButton =
new QPushButton(
"Ok", mDialog);
57 okButton->setShortcut(Qt::Key_Enter);
58 connect(okButton, SIGNAL(clicked()),
this, SLOT(
resetWarning()));
60 QGridLayout *layout =
new QGridLayout();
61 layout->addWidget(mTextEdit, 0, 0, 1, 3);
62 layout->addWidget(okButton, 1, 1, 1, 1);
63 mDialog->setLayout(layout);
66 mWarning =
new QPushButton(mSBar);
67 mWarning->setFixedSize(22, 22) ;
68 mWarning->setFlat(
false);
69 mWarning->setIconSize(QSize(15, 15));
70 mWarning->setIcon(QPixmap(qsIconFile +
"/qview_Warning.png"));
71 mWarning->setToolTip(
"Warning");
72 mWarning->setVisible(
false);
73 mSBar->insertPermanentWidget(0, mWarning);
75 connect(mWarning, SIGNAL(clicked()), mDialog, SLOT(show()));
76 mDialog->resize(800, 250);
77 mTextEdit->setBaseSize(750, 200) ;
100 int findChar1 = pStr.find(
'[', 0);
101 std::string redStr = pStr.substr(0, findChar1 + 1);
102 redStr +=
"<font color=#ff0000>";
103 int findChar2 = pStr.find(
']', 0);
104 redStr += pStr.substr(findChar1 + 1, findChar2 - findChar1 - 1);
106 redStr += pStr.substr(findChar2, pStr.length() - findChar2);
107 mSBar->showMessage(QString(redStr.c_str()));
108 mTextEdit->setText(QString(redStr.c_str()));
119 if(mbWarningFlag ==
true) {
120 mWarning->setVisible(
false);
121 mNoWarning->setVisible(
true);
122 mDialog->setVisible(
false);
123 mbWarningFlag =
false;
124 mSBar->showMessage(
"Ready");
135 if(mbWarningFlag ==
true && mMsgStr.length()) {
136 if(mSBar->currentMessage() != mMsgStr)
137 mSBar->showMessage(mMsgStr);
150 mbWarningFlag =
true;
151 mWarning->setVisible(
true);
152 mNoWarning->setVisible(
false);
153 std::string sStr =
"**PROGRAMMER ERROR** " + pStr;
154 mMsgStr = sStr.c_str();