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
77
bool
matchLabel
(
const
QString
& needle);
78
82
88
bool
dirty
()
const
;
90
95
void
prepare
();
96
102
const
SettingsItem
*
settingsItem
()
const
{
return
mSettingsItem
; }
103
107
virtual
void
acceptValue
();
108
112
virtual
void
loadCurrentValue
();
113
119
virtual
void
load
(
const
QVariant
&
value
) = 0;
120
126
virtual
QVariant
value
() = 0;
127
131
virtual
void
clearEditor
() {;}
132
133
QString
getLabel
();
134
135
public
Q_SLOTS
:
136
141
virtual
void
handleRevertModification
();
142
148
virtual
void
handleSetDefaultValue
(
bool
setAll=
false
);
149
155
void
handleItemDestroyed
();
156
157
Q_SIGNALS
:
158
162
void
valueChanged
();
163
169
void
triggerDescriptionUpdate
(
SettingsItem
* item);
170
175
void
triggerRemoveWidget
(
SettingsWidget
* widget);
176
177
protected
:
178
182
188
void
setDirty
(
bool
dirty
);
190
195
void
trigger_setting_updated
();
196
202
void
enterEvent
(
QEvent
*
event
);
203
209
void
leaveEvent
(
QEvent
*
event
);
210
211
QVBoxLayout
*
m_layout
;
212
QBoxLayout
*
mContainer
;
213
QHBoxLayout
*
m_top_bar
;
214
QLabel
*
mNameLabel
;
215
QToolButton
*
mRevertButton
;
216
QToolButton
*
mDefaultButton
;
217
218
QList<QPair<QLabel*, QString>
>
m_labels
;
219
SettingsItem
*
mSettingsItem
;
220
221
private
:
222
bool
mDirty =
false
;
223
};
224
}
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:162
hal::SettingsWidget::mRevertButton
QToolButton * mRevertButton
Definition:
settings_widget.h:215
hal::SettingsWidget::setDirty
void setDirty(bool dirty)
Sets the dirty state.
Definition:
settings_widget.cpp:116
hal::SettingsWidget::m_top_bar
QHBoxLayout * m_top_bar
Definition:
settings_widget.h:213
hal::SettingsWidget::mNameLabel
QLabel * mNameLabel
Definition:
settings_widget.h:214
hal::SettingsWidget::leaveEvent
void leaveEvent(QEvent *event)
Definition:
settings_widget.cpp:147
hal::SettingsWidget::m_layout
QVBoxLayout * m_layout
Definition:
settings_widget.h:211
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:109
hal::SettingsWidget::clearEditor
virtual void clearEditor()
Definition:
settings_widget.h:131
hal::SettingsWidget::trigger_setting_updated
void trigger_setting_updated()
Definition:
settings_widget.cpp:85
hal::SettingsWidget::m_labels
QList< QPair< QLabel *, QString > > m_labels
Definition:
settings_widget.h:218
hal::SettingsWidget::enterEvent
void enterEvent(QEvent *event)
Definition:
settings_widget.cpp:139
hal::SettingsWidget::reset_labels
void reset_labels()
Definition:
settings_widget.cpp:58
hal::SettingsWidget::acceptValue
virtual void acceptValue()
Definition:
settings_widget.cpp:155
hal::SettingsWidget::mDefaultButton
QToolButton * mDefaultButton
Definition:
settings_widget.h:216
hal::SettingsWidget::handleSetDefaultValue
virtual void handleSetDefaultValue(bool setAll=false)
Definition:
settings_widget.cpp:94
hal::SettingsWidget::dirty
bool dirty
Definition:
settings_widget.h:55
hal::SettingsWidget::mSettingsItem
SettingsItem * mSettingsItem
Definition:
settings_widget.h:219
hal::SettingsWidget::prepare
void prepare()
Definition:
settings_widget.cpp:131
hal::SettingsWidget::getLabel
QString getLabel()
Definition:
settings_widget.cpp:80
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:102
hal::SettingsWidget::mContainer
QBoxLayout * mContainer
Definition:
settings_widget.h:212
hal::SettingsWidget::value
virtual QVariant value()=0
hal::SettingsWidget::handleRevertModification
virtual void handleRevertModification()
Definition:
settings_widget.cpp:102
hal::SettingsWidget::matchLabel
bool matchLabel(const QString &needle)
Definition:
settings_widget.cpp:74
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 Feb 14 2025 14:22:41 for HAL by
1.9.1