Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
67ebf72e
Commit
67ebf72e
authored
Feb 10, 2011
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] - group widgets now get hidden properly.
parent
321e7faf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
7 deletions
+106
-7
src/gui/qt4/controlPanel/WQtControlPanel.cpp
src/gui/qt4/controlPanel/WQtControlPanel.cpp
+1
-2
src/gui/qt4/controlPanel/WQtPropertyGroupWidget.cpp
src/gui/qt4/controlPanel/WQtPropertyGroupWidget.cpp
+54
-3
src/gui/qt4/controlPanel/WQtPropertyGroupWidget.h
src/gui/qt4/controlPanel/WQtPropertyGroupWidget.h
+44
-1
src/modules/template/WMTemplate.cpp
src/modules/template/WMTemplate.cpp
+2
-1
src/modules/template/WMTemplate.h
src/modules/template/WMTemplate.h
+5
-0
No files found.
src/gui/qt4/controlPanel/WQtControlPanel.cpp
View file @
67ebf72e
...
@@ -804,8 +804,7 @@ void WQtControlPanel::selectDataModule( boost::shared_ptr< WDataSet > dataSet )
...
@@ -804,8 +804,7 @@ void WQtControlPanel::selectDataModule( boost::shared_ptr< WDataSet > dataSet )
WQtPropertyGroupWidget
*
WQtControlPanel
::
buildPropWidget
(
boost
::
shared_ptr
<
WProperties
>
props
)
WQtPropertyGroupWidget
*
WQtControlPanel
::
buildPropWidget
(
boost
::
shared_ptr
<
WProperties
>
props
)
{
{
WQtPropertyGroupWidget
*
tab
=
new
WQtPropertyGroupWidget
(
props
->
getName
()
);
WQtPropertyGroupWidget
*
tab
=
new
WQtPropertyGroupWidget
(
props
);
if
(
props
.
get
()
)
if
(
props
.
get
()
)
{
{
// read lock, gets unlocked upon destruction (out of scope)
// read lock, gets unlocked upon destruction (out of scope)
...
...
src/gui/qt4/controlPanel/WQtPropertyGroupWidget.cpp
View file @
67ebf72e
...
@@ -24,18 +24,45 @@
...
@@ -24,18 +24,45 @@
#include <string>
#include <string>
#include <QtGui/QApplication>
#include <QtGui/QGroupBox>
#include <QtGui/QGroupBox>
#include <QtGui/QPushButton>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QScrollArea>
#include "../events/WEventTypes.h"
#include "../events/WPropertyChangedEvent.h"
#include "../../../common/WProperties.h"
#include "WQtPropertyGroupWidget.h"
#include "WQtPropertyGroupWidget.h"
WQtPropertyGroupWidget
::
WQtPropertyGroupWidget
(
WPropGroup
group
,
QWidget
*
parent
)
:
QWidget
(
parent
),
m_name
(
group
->
getName
().
c_str
()
),
m_numberOfWidgets
(
0
),
m_group
(
group
)
{
// note: never do layouts as none pointers
// on destruction of a widget it will try to delete them which will cause crashes
m_pageLayout
=
new
QVBoxLayout
();
m_controlLayout
=
new
QGridLayout
();
m_pageLayout
->
addLayout
(
m_controlLayout
);
// NOTE: a simple setHidden( group->isHidden() ) causes the QWidgets to popup if hidden is false. This is why we set hidden only if it really
// is needed
if
(
group
->
isHidden
()
)
{
setHidden
(
true
);
}
// setup the update callback
m_connection
=
m_group
->
getUpdateCondition
()
->
subscribeSignal
(
boost
::
bind
(
&
WQtPropertyGroupWidget
::
propertyChangeNotifier
,
this
)
);
}
WQtPropertyGroupWidget
::
WQtPropertyGroupWidget
(
std
::
string
name
,
QWidget
*
parent
)
WQtPropertyGroupWidget
::
WQtPropertyGroupWidget
(
std
::
string
name
,
QWidget
*
parent
)
:
QWidget
(
parent
),
:
QWidget
(
parent
),
m_name
(
name
.
c_str
()
),
m_name
(
name
.
c_str
()
),
// m_controlLayout(),
m_numberOfWidgets
(
0
),
// m_pageLayout(),
m_group
()
m_numberOfWidgets
(
0
)
{
{
// note: never do layouts as none pointers
// note: never do layouts as none pointers
// on destruction of a widget it will try to delete them which will cause crashes
// on destruction of a widget it will try to delete them which will cause crashes
...
@@ -46,6 +73,26 @@ WQtPropertyGroupWidget::WQtPropertyGroupWidget( std::string name, QWidget* paren
...
@@ -46,6 +73,26 @@ WQtPropertyGroupWidget::WQtPropertyGroupWidget( std::string name, QWidget* paren
WQtPropertyGroupWidget
::~
WQtPropertyGroupWidget
()
WQtPropertyGroupWidget
::~
WQtPropertyGroupWidget
()
{
{
// cleanup
m_connection
.
disconnect
();
}
void
WQtPropertyGroupWidget
::
propertyChangeNotifier
()
{
QCoreApplication
::
postEvent
(
this
,
new
WPropertyChangedEvent
()
);
}
bool
WQtPropertyGroupWidget
::
event
(
QEvent
*
event
)
{
// a property changed
if
(
event
->
type
()
==
WQT_PROPERTY_CHANGED_EVENT
)
{
setHidden
(
m_group
->
isHidden
()
);
emit
hideSignal
(
m_group
->
isHidden
()
);
return
true
;
}
return
QWidget
::
event
(
event
);
}
}
WPropertyBoolWidget
*
WQtPropertyGroupWidget
::
addProp
(
WPropBool
property
)
WPropertyBoolWidget
*
WQtPropertyGroupWidget
::
addProp
(
WPropBool
property
)
...
@@ -177,6 +224,10 @@ void WQtPropertyGroupWidget::addGroup( WQtPropertyGroupWidget* widget, bool asSc
...
@@ -177,6 +224,10 @@ void WQtPropertyGroupWidget::addGroup( WQtPropertyGroupWidget* widget, bool asSc
// insert into layout
// insert into layout
int
row
=
m_controlLayout
->
rowCount
();
int
row
=
m_controlLayout
->
rowCount
();
m_controlLayout
->
addWidget
(
box
,
row
,
0
,
1
,
2
);
m_controlLayout
->
addWidget
(
box
,
row
,
0
,
1
,
2
);
// hide the box too if the property gets hidden
box
->
setHidden
(
widget
->
isHidden
()
);
connect
(
widget
,
SIGNAL
(
hideSignal
(
bool
)
),
box
,
SLOT
(
setHidden
(
bool
)
)
);
}
}
void
WQtPropertyGroupWidget
::
addSpacer
()
void
WQtPropertyGroupWidget
::
addSpacer
()
...
...
src/gui/qt4/controlPanel/WQtPropertyGroupWidget.h
View file @
67ebf72e
...
@@ -51,12 +51,19 @@ class WQtPropertyGroupWidget : public QWidget
...
@@ -51,12 +51,19 @@ class WQtPropertyGroupWidget : public QWidget
Q_OBJECT
Q_OBJECT
public:
public:
/**
* Creates new widget for a property group. Use this constructor to provide automatic hidden-flag management.
* \param group The group
* \param parent The widget managing this widget
*/
WQtPropertyGroupWidget
(
WPropGroup
group
,
QWidget
*
parent
=
0
);
/**
/**
* Creates new widget for a property group
* Creates new widget for a property group
* \param name Name of the widget
* \param name Name of the widget
* \param parent The widget managing this widget
* \param parent The widget managing this widget
*/
*/
explicit
WQtPropertyGroupWidget
(
std
::
string
name
,
QWidget
*
parent
=
0
);
WQtPropertyGroupWidget
(
std
::
string
name
,
QWidget
*
parent
=
0
);
/**
/**
* destructor
* destructor
...
@@ -191,7 +198,33 @@ public:
...
@@ -191,7 +198,33 @@ public:
*/
*/
void
setName
(
QString
name
);
void
setName
(
QString
name
);
signals:
/**
* A Signal which gets emitted whenever the widget should be hidden. This is a useful signal for containers which embed this group.
*
* \param hide if true, the widget should be hidden.
*/
void
hideSignal
(
bool
hide
);
protected:
protected:
/**
* Callback for WPropertyBase::getChangeCondition. It emits an event to ensure all updates are done in gui thread.
*/
virtual
void
propertyChangeNotifier
();
/**
* Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
* processes property change events.
*
* \note QT Doc says: use event() for custom events.
* \param event the event that got transmitted.
*
* \return true if the event got handled properly.
*/
virtual
bool
event
(
QEvent
*
event
);
private:
private:
/**
/**
...
@@ -213,6 +246,16 @@ private:
...
@@ -213,6 +246,16 @@ private:
* The number of widgets inside this one.
* The number of widgets inside this one.
*/
*/
unsigned
int
m_numberOfWidgets
;
unsigned
int
m_numberOfWidgets
;
/**
* The property group handled here.
*/
WPropGroup
m_group
;
/**
* The connection for propertyChangeNotifier().
*/
boost
::
signals2
::
connection
m_connection
;
};
};
#endif // WQTPROPERTYGROUPWIDGET_H
#endif // WQTPROPERTYGROUPWIDGET_H
src/modules/template/WMTemplate.cpp
View file @
67ebf72e
...
@@ -266,6 +266,7 @@ void WMTemplate::properties()
...
@@ -266,6 +266,7 @@ void WMTemplate::properties()
// Properties can be hidden on the fly. The GUI updates automatically. This is a very useful feature. You can create properties which depend
// Properties can be hidden on the fly. The GUI updates automatically. This is a very useful feature. You can create properties which depend
// on a current selection and blend them in our out accordingly.
// on a current selection and blend them in our out accordingly.
m_aHiddenInt
=
m_group2
->
addProperty
(
"Hide me please"
,
"A property used to demonstrate the hidden feature."
,
1
,
true
);
m_aHiddenInt
=
m_group2
->
addProperty
(
"Hide me please"
,
"A property used to demonstrate the hidden feature."
,
1
,
true
);
m_aHiddenGroup
=
m_group2
->
addPropertyGroup
(
"Hide me please too"
,
"A property used to demonstrate the hidden feature."
,
true
);
// Add another button to group2. But this time, we do not want to wake up the main thread. We handle this directly. Fortunately,
// Add another button to group2. But this time, we do not want to wake up the main thread. We handle this directly. Fortunately,
// WPropertyVariable offers you the possibility to specify your own change callback. This callback is used for hiding the m_aColor property
// WPropertyVariable offers you the possibility to specify your own change callback. This callback is used for hiding the m_aColor property
...
@@ -754,10 +755,10 @@ void WMTemplate::hideButtonPressed()
...
@@ -754,10 +755,10 @@ void WMTemplate::hideButtonPressed()
// switch the hide flag of the color prop.
// switch the hide flag of the color prop.
m_aColor
->
setHidden
(
!
m_aColor
->
isHidden
()
);
m_aColor
->
setHidden
(
!
m_aColor
->
isHidden
()
);
m_aHiddenInt
->
setHidden
(
!
m_aHiddenInt
->
isHidden
()
);
m_aHiddenInt
->
setHidden
(
!
m_aHiddenInt
->
isHidden
()
);
m_aHiddenGroup
->
setHidden
(
!
m_aHiddenGroup
->
isHidden
()
);
// never forget to reset a trigger. If not done, the trigger is disabled in the GUI and can't be used again.
// never forget to reset a trigger. If not done, the trigger is disabled in the GUI and can't be used again.
m_hideButton
->
set
(
WPVBaseTypes
::
PV_TRIGGER_READY
);
m_hideButton
->
set
(
WPVBaseTypes
::
PV_TRIGGER_READY
);
// NOTE: this again triggers an update, which is why we need to check the state of the trigger in this if-clause.
// NOTE: this again triggers an update, which is why we need to check the state of the trigger in this if-clause.
}
}
}
}
src/modules/template/WMTemplate.h
View file @
67ebf72e
...
@@ -197,6 +197,11 @@ private:
...
@@ -197,6 +197,11 @@ private:
*/
*/
WPropInt
m_aHiddenInt
;
WPropInt
m_aHiddenInt
;
/**
* A group used to show that even hiding whole groups is possible.
*/
WPropGroup
m_aHiddenGroup
;
/**
/**
* A trigger which can be used to trigger some kind of operation.
* A trigger which can be used to trigger some kind of operation.
*/
*/
...
...
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