1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
6 * Created on: Apr 28, 2014
9 #include <XGUI_ErrorDialog.h>
11 #include <ModuleBase_Tools.h>
12 #include <Config_Translator.h>
14 #include <QDialogButtonBox>
15 #include <QHBoxLayout>
17 #include <QVBoxLayout>
21 XGUI_ErrorDialog::XGUI_ErrorDialog(QWidget* parent)
24 QVBoxLayout* aDlgLay = new QVBoxLayout(this);
25 setWindowTitle(tr("Application errors"));
26 myErrorLog = new QTextEdit(this);
27 myErrorLog->setReadOnly(true);
28 aDlgLay->addWidget(myErrorLog);
29 QDialogButtonBox* aButtonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal,
31 aDlgLay->addWidget(aButtonBox);
32 aDlgLay->setContentsMargins(2, 2, 2, 2);
33 aDlgLay->setSpacing(2);
37 connect(aButtonBox, SIGNAL(accepted()), this, SLOT(clear()));
38 connect(aButtonBox, SIGNAL(rejected()), this, SLOT(clear()));
41 XGUI_ErrorDialog::~XGUI_ErrorDialog()
45 void XGUI_ErrorDialog::refresh()
48 foreach(QString eachError, myErrors)
50 myErrorLog->append(eachError);
54 void XGUI_ErrorDialog::clear()
61 void XGUI_ErrorDialog::addError(std::shared_ptr<Events_InfoMessage> theMsg)
63 std::string aError = Config_Translator::translate(*theMsg);
64 std::string aCodec = Config_Translator::codec(*theMsg);
65 QString aMsg = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aError.c_str());
66 myErrors.append(aMsg);
71 ModuleBase_Tools::activateWindow(this, "XGUI_ErrorDialog::addError");
75 void XGUI_ErrorDialog::removeError(const QString& theError)
77 myErrors.removeAll(theError);