Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
4f40fb28
Commit
4f40fb28
authored
3 years ago
by
Matthias Puchner
Committed by
Wuttke, Joachim
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
simplify, add documentation
parent
8199a116
No related branches found
No related tags found
1 merge request
!706
replace SessionItem signaling by Qt signaling in RealDataPropertiesWidget;...
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/View/Edit/DoubleSpinBox.h
+6
-0
6 additions, 0 deletions
GUI/View/Edit/DoubleSpinBox.h
GUI/View/Tool/WidgetUtils.cpp
+4
-10
4 additions, 10 deletions
GUI/View/Tool/WidgetUtils.cpp
GUI/View/Tool/WidgetUtils.h
+42
-7
42 additions, 7 deletions
GUI/View/Tool/WidgetUtils.h
with
52 additions
and
17 deletions
GUI/View/Edit/DoubleSpinBox.h
+
6
−
0
View file @
4f40fb28
...
@@ -22,6 +22,12 @@
...
@@ -22,6 +22,12 @@
class
DoubleSpinBox
:
public
QDoubleSpinBox
{
class
DoubleSpinBox
:
public
QDoubleSpinBox
{
Q_OBJECT
Q_OBJECT
public:
public:
//! Create a DoubleSpinBox with the information found in a DoubleDescriptor.
//!
//! The spin box will be fully initialized (tooltip, limits, unit, current value, size policy).
//! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it
//! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed
//! changes would take place when just scrolling through the form.
DoubleSpinBox
(
QWidget
*
parent
,
const
DoubleDescriptor
&
d
);
DoubleSpinBox
(
QWidget
*
parent
,
const
DoubleDescriptor
&
d
);
//! Set a display unit.
//! Set a display unit.
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Tool/WidgetUtils.cpp
+
4
−
10
View file @
4f40fb28
...
@@ -18,7 +18,8 @@
...
@@ -18,7 +18,8 @@
#include
<QFormLayout>
#include
<QFormLayout>
#include
<QSpinBox>
#include
<QSpinBox>
QSpinBox
*
GUI
::
Util
::
createSpinBox
(
QWidget
*
parent
,
const
UIntDescriptor
&
d
)
QSpinBox
*
GUI
::
Util
::
createSpinBox
(
QWidget
*
parent
,
const
UIntDescriptor
&
d
,
std
::
function
<
void
(
uint
)
>
slot
)
{
{
auto
*
spinBox
=
new
QSpinBox
(
parent
);
auto
*
spinBox
=
new
QSpinBox
(
parent
);
spinBox
->
setFocusPolicy
(
Qt
::
StrongFocus
);
spinBox
->
setFocusPolicy
(
Qt
::
StrongFocus
);
...
@@ -34,18 +35,11 @@ QSpinBox* GUI::Util::createSpinBox(QWidget* parent, const UIntDescriptor& d)
...
@@ -34,18 +35,11 @@ QSpinBox* GUI::Util::createSpinBox(QWidget* parent, const UIntDescriptor& d)
spinBox
->
setValue
(
d
.
get
());
spinBox
->
setValue
(
d
.
get
());
return
spinBox
;
}
QSpinBox
*
GUI
::
Util
::
createSpinBox
(
QWidget
*
parent
,
const
UIntDescriptor
&
d
,
std
::
function
<
void
(
uint
)
>
slot
)
{
auto
*
sb
=
createSpinBox
(
parent
,
d
);
if
(
slot
)
if
(
slot
)
QObject
::
connect
(
s
b
,
qOverload
<
int
>
(
&
QSpinBox
::
valueChanged
),
QObject
::
connect
(
s
pinBox
,
qOverload
<
int
>
(
&
QSpinBox
::
valueChanged
),
[
=
](
int
v
)
{
slot
(
static_cast
<
uint
>
(
v
));
});
[
=
](
int
v
)
{
slot
(
static_cast
<
uint
>
(
v
));
});
return
s
b
;
return
s
pinBox
;
}
}
DoubleSpinBox
*
GUI
::
Util
::
createSpinBox
(
QFormLayout
*
parentLayout
,
const
DoubleDescriptor
&
d
)
DoubleSpinBox
*
GUI
::
Util
::
createSpinBox
(
QFormLayout
*
parentLayout
,
const
DoubleDescriptor
&
d
)
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Tool/WidgetUtils.h
+
42
−
7
View file @
4f40fb28
...
@@ -29,9 +29,17 @@ class QFormLayout;
...
@@ -29,9 +29,17 @@ class QFormLayout;
namespace
GUI
::
Util
{
namespace
GUI
::
Util
{
// #bamigration docu
//! Create a combo box with the information found in a selection descriptor.
//! Changes in the combobox will be notified to the SelectionDescriptor already. The addition slot
//!
//! exists to be notified about an already executed change.
//! The combo will be filled with the available options and will get the found tooltip.
//! The current index will be set according to the current index in the selection.
//! Furthermore, the combo box will prohibit accidental changes by the mouse wheel. Otherwise it
//! would be dangerous if the combo is on a scrollable form - unintended and unnoticed changes would
//! take place when just scrolling through the form.
//!
//! Changes in the combobox will be notified to the SelectionDescriptor already. The additional (and
//! optional) slot can be used to be notified about an already executed change.
//!
template
<
typename
T
>
template
<
typename
T
>
QComboBox
*
createSelectionCombo
(
QWidget
*
parent
,
const
SelectionDescriptor
<
T
>
d
,
QComboBox
*
createSelectionCombo
(
QWidget
*
parent
,
const
SelectionDescriptor
<
T
>
d
,
std
::
function
<
void
(
int
)
>
slot
=
nullptr
)
std
::
function
<
void
(
int
)
>
slot
=
nullptr
)
...
@@ -53,15 +61,42 @@ QComboBox* createSelectionCombo(QWidget* parent, const SelectionDescriptor<T> d,
...
@@ -53,15 +61,42 @@ QComboBox* createSelectionCombo(QWidget* parent, const SelectionDescriptor<T> d,
return
combo
;
return
combo
;
}
}
// #bamigration docu
//! Create a spin box with the information found in a UIntDescriptor.
QSpinBox
*
createSpinBox
(
QWidget
*
parent
,
const
UIntDescriptor
&
d
);
//!
QSpinBox
*
createSpinBox
(
QWidget
*
parent
,
const
UIntDescriptor
&
d
,
std
::
function
<
void
(
uint
)
>
slot
);
//! The spin box will be fully initialized (tooltip, limits, current value, size policy).
//! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it
//! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed changes
//! would take place when just scrolling through the form.
//!
//! No connections to update the descriptor will be established! Therefore changes in the spin box
//! will *not* be notified to the descriptor. The additional (and optional) slot can be used to be
//! notified about a value change.
QSpinBox
*
createSpinBox
(
QWidget
*
parent
,
const
UIntDescriptor
&
d
,
std
::
function
<
void
(
uint
)
>
slot
=
nullptr
);
//! Create a label and a spin box with the information found in a UIntDescriptor and place them in a
//! row in a form layout.
//!
//! The label will also contain the unit, if present.
//! Regarding the spin box creation see the method above.
QSpinBox
*
createSpinBox
(
QFormLayout
*
parentLayout
,
const
UIntDescriptor
&
d
);
QSpinBox
*
createSpinBox
(
QFormLayout
*
parentLayout
,
const
UIntDescriptor
&
d
);
//! Create a label and a spin box with the information found in a DoubleDescriptor and place them in
//! a row in a form layout.
//!
//! The spin box will be fully initialized (tooltip, limits, current value, unit, size policy).
//! Furthermore, the spin box will prohibit accidental changes by the mouse wheel. Otherwise it
//! would be dangerous if the spin box is on a scrollable form - unintended and unnoticed changes
//! would take place when just scrolling through the form.
//!
//! No connections to update the descriptor will be established! Therefore changes in the spin box
//! will *not* be notified to the descriptor. The additional (and optional) slot can be used to be
//! notified about a value change.
DoubleSpinBox
*
createSpinBox
(
QFormLayout
*
parentLayout
,
const
DoubleDescriptor
&
d
);
DoubleSpinBox
*
createSpinBox
(
QFormLayout
*
parentLayout
,
const
DoubleDescriptor
&
d
);
//! No trailing ':'
//! Create a label with an optional unit in brackets.
//!
//! No trailing ':' will be appended
QString
labelWithUnit
(
const
QString
&
label
,
std
::
variant
<
QString
,
Unit
>
unit
);
QString
labelWithUnit
(
const
QString
&
label
,
std
::
variant
<
QString
,
Unit
>
unit
);
}
// namespace GUI::Util
}
// namespace GUI::Util
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment