1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <XGUI_ErrorDialog.h>
22 #include <ModuleBase_Tools.h>
23 #include <Config_Translator.h>
25 #include <QDialogButtonBox>
26 #include <QHBoxLayout>
28 #include <QVBoxLayout>
32 XGUI_ErrorDialog::XGUI_ErrorDialog(QWidget* parent)
35 QVBoxLayout* aDlgLay = new QVBoxLayout(this);
36 setWindowTitle(tr("Application errors"));
37 myErrorLog = new QTextEdit(this);
38 myErrorLog->setReadOnly(true);
39 aDlgLay->addWidget(myErrorLog);
40 QDialogButtonBox* aButtonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal,
42 aDlgLay->addWidget(aButtonBox);
43 aDlgLay->setContentsMargins(2, 2, 2, 2);
44 aDlgLay->setSpacing(2);
48 connect(aButtonBox, SIGNAL(accepted()), this, SLOT(clear()));
49 connect(aButtonBox, SIGNAL(rejected()), this, SLOT(clear()));
52 XGUI_ErrorDialog::~XGUI_ErrorDialog()
56 void XGUI_ErrorDialog::refresh()
59 foreach(QString eachError, myErrors)
61 myErrorLog->append(eachError);
65 void XGUI_ErrorDialog::clear()
72 void XGUI_ErrorDialog::addError(std::shared_ptr<Events_InfoMessage> theMsg)
74 std::string aError = Config_Translator::translate(*theMsg);
75 std::string aCodec = Config_Translator::codec(*theMsg);
76 QString aMsg = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aError.c_str());
77 myErrors.append(aMsg);
81 ModuleBase_Tools::activateWindow(this, "XGUI_ErrorDialog::addError");
85 void XGUI_ErrorDialog::removeError(const QString& theError)
87 myErrors.removeAll(theError);