BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
JobMessagePanel.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/JobWidgets/JobMessagePanel.cpp
6 //! @brief Implements class JobMessagePanel
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
17 #include <QScrollBar>
18 #include <QStackedWidget>
19 #include <QTextEdit>
20 #include <QVBoxLayout>
21 
22 JobMessagePanel::JobMessagePanel(QWidget* parent) : InfoPanel(parent), m_plainLog(new QTextEdit)
23 {
24  setWindowTitle(Constants::JobMessagePanelName);
25  setObjectName("JobMessagePanel");
26 
27  m_plainLog->setReadOnly(true);
28  // m_plainLog->setMaximumBlockCount(100000);
29  QFont f("unexistent");
30  f.setStyleHint(QFont::Monospace);
31  m_plainLog->setFont(f);
32 
33  m_stackedWidget->addWidget(m_plainLog);
34 
35  setContentVisible(false);
36 }
37 
39 {
40  m_plainLog->clear();
41 }
42 
43 void JobMessagePanel::onMessage(const QString& message, const QColor& color)
44 {
45  QScrollBar* scrollbar = m_plainLog->verticalScrollBar();
46  bool autoscroll = scrollbar->value() == scrollbar->maximum();
47  // m_plainLog->appendPlainText(message);
48  m_plainLog->setTextColor(color);
49  m_plainLog->append(message);
50  if (autoscroll) {
51  QTextCursor c = m_plainLog->textCursor();
52  c.movePosition(QTextCursor::End);
53  m_plainLog->setTextCursor(c);
54  }
55 }
Defines class JobMessagePanel.
Frame for widgets with tool bar on top and collapse/expand button functionality.
Definition: InfoPanel.h:29
QStackedWidget * m_stackedWidget
Definition: InfoPanel.h:49
void setContentVisible(bool editor_status, bool dock_notify=false)
Definition: InfoPanel.cpp:71
QTextEdit * m_plainLog
void onMessage(const QString &message, const QColor &color=QColor(Qt::black))
JobMessagePanel(QWidget *parent=0)
Defines namespace Constants.
const QString JobMessagePanelName