Overte C++ Documentation
BaseLogDialog.h
1 //
2 // BaseLogDialog.h
3 // interface/src/ui
4 //
5 // Created by Clement Brisset on 1/31/17.
6 // Copyright 2017 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_BaseLogDialog_h
13 #define hifi_BaseLogDialog_h
14 
15 #include <QDialog>
16 #include <QSyntaxHighlighter>
17 
18 const int ELEMENT_MARGIN = 7;
19 const int ELEMENT_HEIGHT = 32;
20 const int CHECKBOX_MARGIN = 12;
21 const int CHECKBOX_WIDTH = 110;
22 const int COMBOBOX_WIDTH = 160;
23 const int BUTTON_MARGIN = 8;
24 
25 class QPushButton;
26 class QLineEdit;
27 class QPlainTextEdit;
28 
29 class Highlighter : public QSyntaxHighlighter {
30 public:
31  Highlighter(QTextDocument* parent = nullptr);
32  void setBold(int indexToBold);
33  QString keyword;
34 
35 protected:
36  void highlightBlock(const QString& text) override;
37 
38 private:
39  QTextCharFormat boldFormat;
40  QTextCharFormat keywordFormat;
41 
42 };
43 
44 class BaseLogDialog : public QDialog {
45  Q_OBJECT
46 
47 public:
48  BaseLogDialog(QWidget* parent);
49  ~BaseLogDialog();
50 
51 public slots:
52  virtual void appendLogLine(QString logLine);
53 
54 private slots:
55  void updateSelection();
56  void handleSearchButton();
57  void handleSearchTextChanged(QString text);
58  void toggleSearchPrev();
59  void toggleSearchNext();
60 
61 protected:
62  int _leftPad{ 0 };
63  QString _searchTerm;
64  QPlainTextEdit* _logTextBox{ nullptr };
65  Highlighter* _highlighter{ nullptr };
66 
67  void resizeEvent(QResizeEvent* event) override;
68  void showEvent(QShowEvent* event) override;
69  virtual QString getCurrentLog() = 0;
70  void clearSearch();
71 
72 private:
73  QPushButton* _searchButton{ nullptr };
74  QLineEdit* _searchTextBox{ nullptr };
75  QPushButton* _searchPrevButton{ nullptr };
76  QPushButton* _searchNextButton{ nullptr };
77 
78  void initControls();
79  void showLogData();
80 };
81 
82 
83 #endif // hifi_BaseLogDialog_h