1 // Copyright (C) 2014-2024 CEA, EDF
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)
33 : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint |
34 Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
36 QVBoxLayout* aDlgLay = new QVBoxLayout(this);
37 setWindowTitle(tr("Application errors"));
38 myErrorLog = new QTextEdit(this);
39 myErrorLog->setReadOnly(true);
40 aDlgLay->addWidget(myErrorLog);
41 QDialogButtonBox* aButtonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal,
43 aDlgLay->addWidget(aButtonBox);
44 aDlgLay->setContentsMargins(2, 2, 2, 2);
45 aDlgLay->setSpacing(2);
49 connect(aButtonBox, SIGNAL(accepted()), this, SLOT(clear()));
50 connect(aButtonBox, SIGNAL(rejected()), this, SLOT(clear()));
53 XGUI_ErrorDialog::~XGUI_ErrorDialog()
57 void XGUI_ErrorDialog::refresh()
60 foreach(QString eachError, myErrors)
62 myErrorLog->append(eachError);
66 void XGUI_ErrorDialog::clear()
73 void XGUI_ErrorDialog::addError(std::shared_ptr<Events_InfoMessage> theMsg)
75 std::string aError = Config_Translator::translate(*theMsg);
76 std::string aCodec = Config_Translator::codec(*theMsg);
77 QString aMsg = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aError.c_str());
78 myErrors.append(aMsg);
82 ModuleBase_Tools::activateWindow(this, "XGUI_ErrorDialog::addError");
86 void XGUI_ErrorDialog::removeError(const QString& theError)
88 myErrors.removeAll(theError);