Mantid
Loading...
Searching...
No Matches
MessageDisplay.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------
10// Includes
11//----------------------------------
12#include "DllOption.h"
16
17#include <QHash>
18#include <QTextCharFormat>
19#include <QTextCursor>
20#include <QWidget>
21
22//----------------------------------------------------------
23// Forward declarations
24//----------------------------------------------------------
25class QAction;
26class QActionGroup;
27class QMenu;
28class QPlainTextEdit;
29class QPoint;
30class QSettings;
31class QShowEvent;
32class QSignalMapper;
33
34namespace MantidQt {
35namespace MantidWidgets {
36
44 Q_OBJECT
45 Q_PROPERTY(QString source READ source WRITE setSource)
46
47public:
48 // Configurable interface
49 void readSettings(const QSettings &storage) override;
50 void writeSettings(QSettings &storage) const override;
51
52public:
54 MessageDisplay(QWidget *parent = nullptr);
56 MessageDisplay(const QFont &font, QWidget *parent = nullptr);
57 MessageDisplay(const MessageDisplay &) = delete;
60 ~MessageDisplay() override;
61
62 // Setup logging framework connections
63 void attachLoggingChannel(int logLevel = 0);
65 void setSource(const QString &source);
67 inline const QString &source() const { return m_logChannel->source(); }
69 QPlainTextEdit *getTextEdit() { return m_textDisplay; }
71 QList<Message> getHistory() { return m_messageHistory; }
73 QMenu *generateContextMenu();
75 void filterMessages();
77 void filePathModified(const QString &oldPath, const QString &newPath);
79 void appendToHistory(const Message &msg);
81 inline bool showFrameworkOutput() const { return m_showFrameworkOutput; }
83 void setShowFrameworkOutput(const bool &show) { m_showFrameworkOutput = show; }
85 inline bool showAllScriptOutput() const { return m_showAllScriptOutput; }
87 void setShowAllScriptOutput(const bool &show) { m_showAllScriptOutput = show; }
89 inline bool showActiveScriptOutput() const { return m_showActiveScriptOutput; }
91 void setShowActiveScriptOutput(const bool &show) { m_showActiveScriptOutput = show; }
93 inline QString activeScript() const { return m_activeScript; }
95 void setActiveScript(const QString &scriptPath) { m_activeScript = scriptPath; }
96
97signals:
99 void errorReceived(const QString &text);
101 void warningReceived(const QString &text);
102
103public slots:
105 void appendFatal(const QString &text);
107 void appendError(const QString &text);
109 void appendWarning(const QString &text);
111 void appendNotice(const QString &text);
113 void appendInformation(const QString &text);
115 void appendDebug(const QString &text);
117 void append(const Message &msg);
119 void appendPython(const QString &text, const int &priority, const QString &fileName);
121 void replace(const Message &msg);
123 void clear();
125 QTextCursor moveCursorToEnd();
127 bool isScrollbarAtBottom() const;
129 void scrollToTop();
131 void scrollToBottom();
132
133private slots:
135 void showContextMenu(const QPoint &event);
137 void setLogLevel(int priority);
139 void setScrollbackLimit();
141 int maximumLineCount() const;
143 void setMaximumLineCount(int count);
144
145private:
147 void initActions();
149 void initFormats();
151 void setupTextArea(const QFont &font);
153 QTextCharFormat format(const Message::Priority priority) const;
155 bool shouldBeDisplayed(const Message &msg);
156
160 QPlainTextEdit *m_textDisplay;
164 QActionGroup *m_loglevels;
166 QSignalMapper *m_logLevelMapping;
168 QAction *m_error, *m_warning, *m_notice, *m_information, *m_debug;
172 bool m_showFrameworkOutput{true}, m_showAllScriptOutput{true}, m_showActiveScriptOutput{false};
174};
175} // namespace MantidWidgets
176} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
int count
counter
Definition: Matrix.cpp:37
Defines an interface for an object to load and store any configuration settings that should persist b...
Definition: Configurable.h:24
Provides a widget for display messages in a text box It deals with Message objects which in turn hide...
bool showFrameworkOutput() const
Get whether framework output is being displayed.
MessageDisplay(const MessageDisplay &)=delete
void errorReceived(const QString &text)
Indicate that a message of error or higher has been received.
const QString & source() const
Get the current source are emitted.
bool showAllScriptOutput() const
Get whether all script output is being displayed.
QPlainTextEdit * m_textDisplay
The actual widget holding the text.
void warningReceived(const QString &text)
Indicate that a message of warning or higher has been received.
QActionGroup * m_loglevels
Mutually exclusive log actions.
bool showActiveScriptOutput() const
Get whether only active script output is being displayed.
QPlainTextEdit * getTextEdit()
Get the window's QPlainTextEdit object.
QString activeScript() const
Get the path of the currently active script.
void setShowFrameworkOutput(const bool &show)
Set whether framework output should be displayed.
QList< Message > m_messageHistory
Keep track of the message history.
void setActiveScript(const QString &scriptPath)
Set the path of the currently active script.
QSignalMapper * m_logLevelMapping
Map action signal to log level parameter.
QtSignalChannel * m_logChannel
A reference to the log channel.
QList< Message > getHistory()
Get the window's message history.
void setShowAllScriptOutput(const bool &show)
Set whether all script output should be displayed.
QHash< Message::Priority, QTextCharFormat > m_formats
Map priority to text formatting.
void setShowActiveScriptOutput(const bool &show)
Get whether only active script output should be displayed.
MessageDisplay & operator=(const MessageDisplay &)=delete
Provides a simple binding of a text message with a priority.
Definition: Message.h:28
Mantid::Kernel::Logger::Priority Priority
Priority matches Mantid Logger priority.
Definition: Message.h:33
Provides a translation layer that takes a Poco::Message and converts it to a Qt signal.
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...