HAL
settings_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
28
#include <QVariant>
29
#include <QToolButton>
30
#include <QBoxLayout>
31
#include <QFrame>
32
#include <QPair>
33
34
class
QColor
;
35
class
QLabel
;
36
class
QRegularExpression
;
37
class
QVBoxLayout
;
38
39
namespace
hal
40
{
41
class
SettingsItem
;
42
52
class
SettingsWidget
:
public
QFrame
53
{
54
Q_OBJECT
55
Q_PROPERTY
(
bool
dirty
READ
dirty
WRITE
setDirty
)
56
57
public
:
64
explicit
SettingsWidget
(
SettingsItem
* item,
QWidget
*
parent
=
nullptr
);
65
69
void
reset_labels
();
70
74
80
bool
dirty
()
const
;
82
87
void
prepare
();
88
94
const
SettingsItem
*
settingsItem
()
const
{
return
mSettingsItem
; }
95
99
virtual
void
acceptValue
();
100
104
virtual
void
loadCurrentValue
();
105
111
virtual
void
load
(
const
QVariant
&
value
) = 0;
112
118
virtual
QVariant
value
() = 0;
119
123
virtual
void
clearEditor
() {;}
124
125
QString
getLabel
();
126
127
public
Q_SLOTS
:
128
133
virtual
void
handleRevertModification
();
134
140
virtual
void
handleSetDefaultValue
(
bool
setAll=
false
);
141
147
void
handleItemDestroyed
();
148
149
Q_SIGNALS
:
150
154
void
valueChanged
();
155
161
void
triggerDescriptionUpdate
(
SettingsItem
* item);
162
167
void
triggerRemoveWidget
(
SettingsWidget
* widget);
168
169
protected
:
170
174
180
void
setDirty
(
bool
dirty
);
182
187
void
trigger_setting_updated
();
188
194
void
enterEvent
(
QEvent
*
event
);
195
201
void
leaveEvent
(
QEvent
*
event
);
202
203
QVBoxLayout
*
m_layout
;
204
QBoxLayout
*
mContainer
;
205
QHBoxLayout
*
m_top_bar
;
206
QLabel
*
mNameLabel
;
207
QToolButton
*
mRevertButton
;
208
QToolButton
*
mDefaultButton
;
209
210
QList<QPair<QLabel*, QString>
>
m_labels
;
211
SettingsItem
*
mSettingsItem
;
212
213
private
:
214
bool
mDirty =
false
;
215
};
216
}
hal::SettingsItem
The interface for the logical part of a setting.
Definition:
settings_item.h:46
hal::SettingsWidget
The base class for all specific SettingsWidgets.
Definition:
settings_widget.h:53
hal::SettingsWidget::loadCurrentValue
virtual void loadCurrentValue()
Definition:
settings_widget.cpp:156
hal::SettingsWidget::mRevertButton
QToolButton * mRevertButton
Definition:
settings_widget.h:207
hal::SettingsWidget::setDirty
void setDirty(bool dirty)
Sets the dirty state.
Definition:
settings_widget.cpp:110
hal::SettingsWidget::m_top_bar
QHBoxLayout * m_top_bar
Definition:
settings_widget.h:205
hal::SettingsWidget::mNameLabel
QLabel * mNameLabel
Definition:
settings_widget.h:206
hal::SettingsWidget::leaveEvent
void leaveEvent(QEvent *event)
Definition:
settings_widget.cpp:141
hal::SettingsWidget::m_layout
QVBoxLayout * m_layout
Definition:
settings_widget.h:203
hal::SettingsWidget::SettingsWidget
SettingsWidget(SettingsItem *item, QWidget *parent=nullptr)
Definition:
settings_widget.cpp:14
hal::SettingsWidget::valueChanged
void valueChanged()
hal::SettingsWidget::handleItemDestroyed
void handleItemDestroyed()
Definition:
settings_widget.cpp:103
hal::SettingsWidget::clearEditor
virtual void clearEditor()
Definition:
settings_widget.h:123
hal::SettingsWidget::trigger_setting_updated
void trigger_setting_updated()
Definition:
settings_widget.cpp:79
hal::SettingsWidget::m_labels
QList< QPair< QLabel *, QString > > m_labels
Definition:
settings_widget.h:210
hal::SettingsWidget::enterEvent
void enterEvent(QEvent *event)
Definition:
settings_widget.cpp:133
hal::SettingsWidget::reset_labels
void reset_labels()
Definition:
settings_widget.cpp:58
hal::SettingsWidget::acceptValue
virtual void acceptValue()
Definition:
settings_widget.cpp:149
hal::SettingsWidget::mDefaultButton
QToolButton * mDefaultButton
Definition:
settings_widget.h:208
hal::SettingsWidget::handleSetDefaultValue
virtual void handleSetDefaultValue(bool setAll=false)
Definition:
settings_widget.cpp:88
hal::SettingsWidget::dirty
bool dirty
Definition:
settings_widget.h:55
hal::SettingsWidget::mSettingsItem
SettingsItem * mSettingsItem
Definition:
settings_widget.h:211
hal::SettingsWidget::prepare
void prepare()
Definition:
settings_widget.cpp:125
hal::SettingsWidget::getLabel
QString getLabel()
Definition:
settings_widget.cpp:74
hal::SettingsWidget::triggerRemoveWidget
void triggerRemoveWidget(SettingsWidget *widget)
hal::SettingsWidget::triggerDescriptionUpdate
void triggerDescriptionUpdate(SettingsItem *item)
hal::SettingsWidget::settingsItem
const SettingsItem * settingsItem() const
Definition:
settings_widget.h:94
hal::SettingsWidget::mContainer
QBoxLayout * mContainer
Definition:
settings_widget.h:204
hal::SettingsWidget::value
virtual QVariant value()=0
hal::SettingsWidget::handleRevertModification
virtual void handleRevertModification()
Definition:
settings_widget.cpp:96
hal::SettingsWidget::load
virtual void load(const QVariant &value)=0
hal
Definition:
parser_liberty.cpp:10
QBoxLayout
QColor
QEvent
QFrame
QFrame::event
virtual bool event(QEvent *e) override
QHBoxLayout
QLabel
QList
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::Q_PROPERTY
Q_PROPERTY(...)
QObject::Q_SIGNALS
Q_SIGNALSQ_SIGNALS
QObject::Q_SLOTS
Q_SLOTSQ_SLOTS
QObject::parent
QObject * parent() const const
QRegularExpression
QString
QToolButton
QVariant
QVBoxLayout
QWidget
plugins
gui
include
gui
settings
settings_widgets
settings_widget.h
Generated on Fri Apr 24 2026 12:13:04 for HAL by
1.9.1