HAL
logger_widget.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
30 #include "hal_core/utilities/log.h"
31 #include "gui/gui_utils/graphics.h"
33 
34 #include <QLabel>
35 #include <QMenu>
36 #include <QPlainTextEdit>
37 #include <QString>
38 #include <QToolButton>
39 #include <QWidget>
40 #include <QtCore/qreadwritelock.h>
41 #include <QScrollBar>
42 #include <QPushButton>
43 
44 namespace hal
45 {
46  class LoggerMarshall;
47  class ChannelSelector;
48  class Searchbar;
49 
56  class LoggerWidget : public ContentWidget
57  {
58  Q_OBJECT
61 
62  public:
68  LoggerWidget(QWidget* parent = nullptr);
69  ~LoggerWidget() override;
70 
77  virtual void setupToolbar(Toolbar* toolbar) override;
78 
85 
92  void resizeEvent(QResizeEvent* event) override;
93 
99  QString searchIconPath() const;
100 
106  QString searchIconStyle() const;
107 
113  void setSearchIconPath(const QString &path);
114 
120  void setSearchIconStyle(const QString &style);
121 
122  public Q_SLOTS:
129  void handleCurrentChannelUpdated(spdlog::level::level_enum t, QString const& msg);
130 
138  void handleChannelUpdated(spdlog::level::level_enum t, const std::string& logger_name, std::string const& msg);
139 
146  void handleCurrentFilterChanged(int p);
147 
153  void handleSeverityChanged(bool state);
154 
160  void handleSearchChanged(QString filter, int SearchOptions);
161 
168  void handleFirstUserInteraction(int value);
169 
173  void handleCustomChannel();
174 
178  void toggleSearchbar();
179  bool isMatching(QString searchString, QString stringToCheck);
180 
181  private:
182  Searchbar* mSearchbar;
183  SearchOptions mSearchOptions;
184  QAction* mSearchAction;
185 
186  QString mSearchIconPath;
187  QString mSearchIconStyle;
188 
189  void saveSettings();
190  void restoreSettings();
191 
192  void scrollToBottom();
193 
194  QPlainTextEdit* mPlainTextEdit;
195 
196  ChannelSelector* mSelector;
197  QLabel* mChannelLabel;
198 
199  QPushButton* mMuteButton;
200  QPushButton* mVerboseButton;
201  QPushButton* mDebugButton;
202  QPushButton* mInfoButton;
203  QPushButton* mWarningButton;
204  QPushButton* mErrorButton;
205 
206  bool mInfoSeverity;
207  bool mWarningSeverity;
208  bool mErrorSeverity;
209  bool mDebugSeverity;
210 
211  QString mSearchFilter;
212 
213  LoggerMarshall* mLogMarshall;
214  int mCurrentChannelIndex = -2;
215  std::string mCurrentChannel;
216  QReadWriteLock mLock;
217  QScrollBar* mPlainTextEditScrollbar;
218  bool mUserInteractedWithScrollbar;
219  };
220 }
A combobox for selecting a logger channel.
Abstract class for Widgets within HAL's ContentArea.
Appends log messages to the corresponding LoggerWidget.
Displays the logs in the gui.
Definition: logger_widget.h:57
void resizeEvent(QResizeEvent *event) override
virtual void setupToolbar(Toolbar *toolbar) override
void handleCurrentFilterChanged(int p)
~LoggerWidget() override
QString searchIconStyle
Definition: logger_widget.h:60
void handleSearchChanged(QString filter, int SearchOptions)
void setSearchIconStyle(const QString &style)
QString searchIconPath
Definition: logger_widget.h:59
void setSearchIconPath(const QString &path)
QPlainTextEdit * getPlainTextEdit()
void handleFirstUserInteraction(int value)
bool isMatching(QString searchString, QString stringToCheck)
void handleCurrentChannelUpdated(spdlog::level::level_enum t, QString const &msg)
void handleSeverityChanged(bool state)
void handleChannelUpdated(spdlog::level::level_enum t, const std::string &logger_name, std::string const &msg)
LoggerWidget(QWidget *parent=nullptr)
A QFrame with a QLineEdit that can be used to input a substring to search for.
Definition: searchbar.h:48
Toolbar for all ContentFrames and ContentWidgets.
Definition: toolbar.h:39
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
QObject * parent() const const
virtual bool event(QEvent *event) override
QStyle * style() const const