HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
comment_dialog.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) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 
24 #pragma once
25 
26 #include <QDialog>
27 #include <QVBoxLayout>
28 #include <QHBoxLayout>
29 
30 class QLineEdit;
31 class QTextEdit;
32 class QLabel;
33 class QToolBar;
34 class QAction;
35 class QTextCharFormat;
36 
37 namespace hal
38 {
39  class CommentEntry;
43  class CommentDialog : public QDialog
44  {
45  Q_OBJECT
50  public:
51  // Perhaps remove the title-parameter and determine "New comment" and "Modify comment"
52  // through the item parameter (or perhaps 2 constructors?)
61  CommentDialog(const QString windowTitle, CommentEntry* entry = nullptr, QWidget* parent = nullptr);
63 
64  // Getter for the header and textfield if the dialog returns accapted?
65  // (Or direct interaction with the manager?)
66 
74 
81  QString getText();
82 
83  //property tests
84  QString redColor(){return mRedColor;}
85  void setRedColor(const QString& str){mRedColor = str;}
86  QString yellowColor(){return mYellowColor;}
87  void setYellowColor(const QString & str){mYellowColor = str;}
88  QString greenColor(){return mGreenColor;}
89  void setGreenColor(const QString& str){mGreenColor = str;}
90  QString defaultColor(){return mDefaultColor;}
91  void setDefaultColor(const QString& str){mDefaultColor = str;}
92 
93  private:
94  QVBoxLayout* mLayout;
95  CommentEntry* mCommentEntry;
96  QFont mDefaultFont;
97 
98  QString mRedColor;
99  QString mYellowColor;
100  QString mGreenColor;
101  QString mDefaultColor;
102 
103  // header part
104  QWidget* mHeaderContainer; // for custom margins/spacing on top as well as colored background
105  QHBoxLayout* mHeaderContainerLayout;
106  QLineEdit* mHeaderEdit;
107  QLabel* mLastModifiedLabel;
108 
109  // toolbar (Or container widget for Toolbuttons?)
110  QToolBar* mToolBar;
111  QAction* mBoldAction;
112  QAction* mItalicsAction;
113  QAction* mUnderscoreAction;
114  QAction* mColorAction; // additional widget/indicatior to show current color?
115  QAction* mListAction;
116  QAction* mCodeAction;
117 
118  // textfield
119  QTextEdit* mTextEdit;
120 
121  // helper functions
122  void init();
123  void mergeFormatOnWordOrSelection(const QTextCharFormat &format); // taken from richtext example
124  void updateColorActionPixmap(const QColor &c);
125  void handleColorSelected();
126  void handleCurrentCharFormatChanged(const QTextCharFormat &format); // for the color
127  void handleCursorPositionChanged(); // for the color (mTextEdit->textColor is the current color the curser is at)
128 
129  void boldTriggered();
130  void italicsTriggered();
131  void underscoreTriggered();
132  void colorTriggered();
133  void bulletListTriggered();
134  void codeTriggered();
135 
136  void handleOkClicked();
137  void handleCancelClicked();
138 
139  };
140 }
CommentDialog(const QString windowTitle, CommentEntry *entry=nullptr, QWidget *parent=nullptr)
void setYellowColor(const QString &str)
void setGreenColor(const QString &str)
QString defaultColor()
void setDefaultColor(const QString &str)
void setRedColor(const QString &str)
The CommentEntry class encapsulated information related to a comment.
Definition: comment_entry.h:43
Definition: defines.h:45
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const