Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
112ac379
Commit
112ac379
authored
Jul 29, 2012
by
Alexander Wiebel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD
#198
] Slider max/min buttons also for int sliders
parent
f2ad0faf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
3 deletions
+93
-3
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.cpp
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.cpp
+71
-2
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.h
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.h
+22
-1
No files found.
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.cpp
View file @
112ac379
...
...
@@ -22,13 +22,16 @@
//
//---------------------------------------------------------------------------
#include <
iostrea
m>
#include <
algorith
m>
#include <cmath>
#include <iostream>
#include <limits>
#include <string>
#include <algorithm>
#include <QtGui/QInputDialog>
#include "../WGuiConsts.h"
#include "../WQt4Gui.h"
#include "core/common/WLogger.h"
#include "core/common/WPropertyVariable.h"
...
...
@@ -40,12 +43,39 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property
m_intProperty
(
property
),
m_slider
(
Qt
::
Horizontal
,
&
m_parameterWidgets
),
m_edit
(
&
m_parameterWidgets
),
m_minButton
(
&
m_parameterWidgets
),
m_maxButton
(
&
m_parameterWidgets
),
m_layout
(
&
m_parameterWidgets
),
m_asText
(
&
m_informationWidgets
),
m_infoLayout
(
&
m_informationWidgets
)
{
// layout both against each other
if
(
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_layout
.
addWidget
(
&
m_minButton
);
m_minButton
.
setToolTip
(
"Set minimum of slider.
\n
Be aware that strange values can cause errors."
);
m_minButton
.
setMinimumWidth
(
5
);
m_minButton
.
setMaximumWidth
(
5
);
}
else
{
m_minButton
.
hide
();
}
m_layout
.
addWidget
(
&
m_slider
);
if
(
WQt4Gui
::
getSettings
().
value
(
"qt4gui/sliderMinMaxEdit"
,
false
).
toBool
()
)
{
m_layout
.
addWidget
(
&
m_maxButton
);
m_maxButton
.
setToolTip
(
"Set maximum of slider.
\n
Be aware that strange values can cause errors."
);
m_maxButton
.
setMinimumWidth
(
5
);
m_maxButton
.
setMaximumWidth
(
5
);
}
else
{
m_maxButton
.
hide
();
}
m_layout
.
addWidget
(
&
m_edit
);
m_layout
.
setMargin
(
WGLOBAL_MARGIN
);
m_layout
.
setSpacing
(
WGLOBAL_SPACING
);
...
...
@@ -65,6 +95,8 @@ WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* property
connect
(
&
m_slider
,
SIGNAL
(
valueChanged
(
int
)
),
this
,
SLOT
(
sliderChanged
(
int
)
)
);
connect
(
&
m_edit
,
SIGNAL
(
editingFinished
()
),
this
,
SLOT
(
editChanged
()
)
);
connect
(
&
m_edit
,
SIGNAL
(
textEdited
(
const
QString
&
)
),
this
,
SLOT
(
textEdited
(
const
QString
&
)
)
);
connect
(
&
m_maxButton
,
SIGNAL
(
pressed
()
),
this
,
SLOT
(
maxPressed
()
)
);
connect
(
&
m_minButton
,
SIGNAL
(
pressed
()
),
this
,
SLOT
(
minPressed
()
)
);
}
WPropertyIntWidget
::~
WPropertyIntWidget
()
...
...
@@ -149,3 +181,40 @@ void WPropertyIntWidget::textEdited( const QString& text )
invalidate
(
!
m_intProperty
->
accept
(
value
)
);
}
void
WPropertyIntWidget
::
maxPressed
()
{
bool
ok
;
int
min
=
m_intProperty
->
getMin
()
->
getMin
();
int
max
=
m_intProperty
->
getMax
()
->
getMax
();
int
newMax
=
QInputDialog
::
getInt
(
this
,
"Setting Maximum of Slider"
,
"Maximum"
,
max
,
min
,
std
::
numeric_limits
<
int
>::
max
(),
1
,
&
ok
);
if
(
ok
)
{
if
(
m_intProperty
->
get
()
>
newMax
)
{
m_intProperty
->
set
(
newMax
);
m_slider
.
setValue
(
newMax
);
}
m_slider
.
setMaximum
(
newMax
);
m_intProperty
->
setMax
(
newMax
);
}
}
void
WPropertyIntWidget
::
minPressed
()
{
bool
ok
;
int
min
=
m_intProperty
->
getMin
()
->
getMin
();
int
max
=
m_intProperty
->
getMax
()
->
getMax
();
int
newMin
=
QInputDialog
::
getInt
(
this
,
"Setting Minimum of Slider"
,
"Minimum"
,
min
,
-
std
::
numeric_limits
<
int
>::
max
(),
max
,
1
,
&
ok
);
if
(
ok
)
{
if
(
m_intProperty
->
get
()
<
newMin
)
{
m_intProperty
->
set
(
newMin
);
m_slider
.
setValue
(
newMin
);
}
m_slider
.
setMinimum
(
newMin
);
m_intProperty
->
setMin
(
newMin
);
}
}
src/qt4gui/qt4/controlPanel/WPropertyIntWidget.h
View file @
112ac379
...
...
@@ -27,9 +27,10 @@
#include <string>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QSlider>
#include <QtGui/Q
HBoxLayout
>
#include <QtGui/Q
ToolButton
>
#include "WPropertyWidget.h"
...
...
@@ -75,6 +76,16 @@ protected:
*/
QLineEdit
m_edit
;
/**
* The button bringing up the dialog for modifying min of the slider
*/
QToolButton
m_minButton
;
/**
* The button bringing up the dialog for modifying max of the slider
*/
QToolButton
m_maxButton
;
/**
* Layout used to position the label and the checkbox
*/
...
...
@@ -111,6 +122,16 @@ public slots:
* \param text
*/
void
textEdited
(
const
QString
&
text
);
/**
* Called when the maxMin button is pressed to open maxMinDialog.
*/
void
maxPressed
();
/**
* Called when the maxMin button is pressed to open maxMinDialog.
*/
void
minPressed
();
};
#endif // WPROPERTYINTWIDGET_H
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment