HAL
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
;
40
class
CommentDialog
:
public
QDialog
41
{
42
Q_OBJECT
43
Q_PROPERTY
(
QString
redColor
READ
redColor
WRITE
setRedColor
)
44
Q_PROPERTY
(
QString
yellowColor
READ
yellowColor
WRITE
setYellowColor
)
45
Q_PROPERTY
(
QString
greenColor
READ
greenColor
WRITE
setGreenColor
)
46
Q_PROPERTY
(
QString
defaultColor
READ
defaultColor
WRITE
setDefaultColor
)
47
public
:
48
// Perhaps remove the title-parameter and determine "New comment" and "Modify comment"
49
// through the item parameter (or perhaps 2 constructors?)
58
CommentDialog
(
const
QString
windowTitle
,
CommentEntry
* entry =
nullptr
,
QWidget
*
parent
=
nullptr
);
59
~CommentDialog
();
60
61
// Getter for the header and textfield if the dialog returns accapted?
62
// (Or direct interaction with the manager?)
63
70
QString
getHeader
();
71
78
QString
getText
();
79
80
//property tests
81
QString
redColor
(){
return
mRedColor;}
82
void
setRedColor
(
const
QString
&
str
){mRedColor =
str
;}
83
QString
yellowColor
(){
return
mYellowColor;}
84
void
setYellowColor
(
const
QString
&
str
){mYellowColor =
str
;}
85
QString
greenColor
(){
return
mGreenColor;}
86
void
setGreenColor
(
const
QString
&
str
){mGreenColor =
str
;}
87
QString
defaultColor
(){
return
mDefaultColor;}
88
void
setDefaultColor
(
const
QString
&
str
){mDefaultColor =
str
;}
89
90
private
:
91
QVBoxLayout
* mLayout;
92
CommentEntry
* mCommentEntry;
93
QFont
mDefaultFont;
94
95
QString
mRedColor;
96
QString
mYellowColor;
97
QString
mGreenColor;
98
QString
mDefaultColor;
99
100
// header part
101
QWidget
* mHeaderContainer;
// for custom margins/spacing on top as well as colored background
102
QHBoxLayout
* mHeaderContainerLayout;
103
QLineEdit
* mHeaderEdit;
104
QLabel
* mLastModifiedLabel;
105
106
// toolbar (Or container widget for Toolbuttons?)
107
QToolBar
* mToolBar;
108
QAction
* mBoldAction;
109
QAction
* mItalicsAction;
110
QAction
* mUnderscoreAction;
111
QAction
* mColorAction;
// additional widget/indicatior to show current color?
112
QAction
* mListAction;
113
QAction
* mCodeAction;
114
115
// textfield
116
QTextEdit
* mTextEdit;
117
118
// helper functions
119
void
init();
120
void
mergeFormatOnWordOrSelection(
const
QTextCharFormat
&format);
// taken from richtext example
121
void
updateColorActionPixmap(
const
QColor
&c);
122
void
handleColorSelected();
123
void
handleCurrentCharFormatChanged(
const
QTextCharFormat
&format);
// for the color
124
void
handleCursorPositionChanged();
// for the color (mTextEdit->textColor is the current color the curser is at)
125
126
void
boldTriggered();
127
void
italicsTriggered();
128
void
underscoreTriggered();
129
void
colorTriggered();
130
void
bulletListTriggered();
131
void
codeTriggered();
132
133
void
handleOkClicked();
134
void
handleCancelClicked();
135
136
};
137
}
hal::CommentDialog
Definition:
comment_dialog.h:41
hal::CommentDialog::redColor
QString redColor()
Definition:
comment_dialog.h:81
hal::CommentDialog::CommentDialog
CommentDialog(const QString windowTitle, CommentEntry *entry=nullptr, QWidget *parent=nullptr)
Definition:
comment_dialog.cpp:24
hal::CommentDialog::greenColor
QString greenColor
Definition:
comment_dialog.h:45
hal::CommentDialog::getHeader
QString getHeader()
Definition:
comment_dialog.cpp:49
hal::CommentDialog::redColor
QString redColor
Definition:
comment_dialog.h:43
hal::CommentDialog::greenColor
QString greenColor()
Definition:
comment_dialog.h:85
hal::CommentDialog::setYellowColor
void setYellowColor(const QString &str)
Definition:
comment_dialog.h:84
hal::CommentDialog::setGreenColor
void setGreenColor(const QString &str)
Definition:
comment_dialog.h:86
hal::CommentDialog::getText
QString getText()
Definition:
comment_dialog.cpp:54
hal::CommentDialog::~CommentDialog
~CommentDialog()
Definition:
comment_dialog.cpp:44
hal::CommentDialog::yellowColor
QString yellowColor
Definition:
comment_dialog.h:44
hal::CommentDialog::yellowColor
QString yellowColor()
Definition:
comment_dialog.h:83
hal::CommentDialog::defaultColor
QString defaultColor()
Definition:
comment_dialog.h:87
hal::CommentDialog::defaultColor
QString defaultColor
Definition:
comment_dialog.h:46
hal::CommentDialog::setDefaultColor
void setDefaultColor(const QString &str)
Definition:
comment_dialog.h:88
hal::CommentDialog::setRedColor
void setRedColor(const QString &str)
Definition:
comment_dialog.h:82
hal::CommentEntry
The CommentEntry class encapsulated information related to a comment.
Definition:
comment_entry.h:43
control.str
str
Definition:
control.py:14
hal
Definition:
parser_liberty.cpp:10
QAction
QColor
QDialog
QFont
QHBoxLayout
QLabel
QLineEdit
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::Q_PROPERTY
Q_PROPERTY(...)
QObject::parent
QObject * parent() const const
QString
QTextCharFormat
QTextEdit
QToolBar
QVBoxLayout
QWidget
QWidget::windowTitle
windowTitle
plugins
gui
include
gui
comment_system
widgets
comment_dialog.h
Generated on Fri Feb 14 2025 14:22:41 for HAL by
1.9.1