Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
1d67c11f
Commit
1d67c11f
authored
Mar 18, 2013
by
Sebastian Eichelbaum
Browse files
[CHANGE] dock widget help button only appears if help is available
parent
5f084028
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
src/qt4gui/guiElements/WQtDockTitleWidget.cpp
src/qt4gui/guiElements/WQtDockTitleWidget.cpp
+16
-3
src/qt4gui/guiElements/WQtDockTitleWidget.h
src/qt4gui/guiElements/WQtDockTitleWidget.h
+11
-2
src/qt4gui/guiElements/WQtDockWidget.cpp
src/qt4gui/guiElements/WQtDockWidget.cpp
+3
-0
No files found.
src/qt4gui/guiElements/WQtDockTitleWidget.cpp
View file @
1d67c11f
...
@@ -25,10 +25,11 @@
...
@@ -25,10 +25,11 @@
#include "../WQt4Gui.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "../WMainWindow.h"
#include "WQtDockWidget.h"
#include "WQtDockTitleWidget.h"
#include "WQtDockTitleWidget.h"
#include "WQtDockTitleWidget.moc"
#include "WQtDockTitleWidget.moc"
WQtDockTitleWidget
::
WQtDockTitleWidget
(
Q
DockWidget
*
parent
)
:
WQtDockTitleWidget
::
WQtDockTitleWidget
(
WQt
DockWidget
*
parent
)
:
QWidget
(
parent
),
QWidget
(
parent
),
dockParent
(
parent
)
dockParent
(
parent
)
{
{
...
@@ -111,6 +112,7 @@ void WQtDockTitleWidget::construct()
...
@@ -111,6 +112,7 @@ void WQtDockTitleWidget::construct()
setupSizeConstraints
(
m_helpBtn
);
setupSizeConstraints
(
m_helpBtn
);
m_helpBtn
->
setMinimumSize
(
24
,
24
);
m_helpBtn
->
setMinimumSize
(
24
,
24
);
m_helpBtn
->
setMaximumSize
(
24
,
24
);
m_helpBtn
->
setMaximumSize
(
24
,
24
);
m_helpBtn
->
setVisible
(
false
);
// fill layout
// fill layout
titleWidgetLayout
->
addWidget
(
m_title
);
titleWidgetLayout
->
addWidget
(
m_title
);
...
@@ -204,7 +206,7 @@ void WQtDockTitleWidget::addTitleSeperator()
...
@@ -204,7 +206,7 @@ void WQtDockTitleWidget::addTitleSeperator()
void
WQtDockTitleWidget
::
updateLayouts
(
int
width
)
void
WQtDockTitleWidget
::
updateLayouts
(
int
width
)
{
{
// calc the size of widgets and the title and the mandatory close button
// calc
ulate
the size of widgets and the title and the mandatory close button
int
minRequired
=
m_title
->
calculateSize
(
m_title
->
text
().
length
()
)
+
int
minRequired
=
m_title
->
calculateSize
(
m_title
->
text
().
length
()
)
+
m_moreBtn
->
sizeHint
().
width
()
+
m_moreBtn
->
sizeHint
().
width
()
+
m_helpBtn
->
isVisible
()
*
m_helpBtn
->
sizeHint
().
width
()
+
m_helpBtn
->
isVisible
()
*
m_helpBtn
->
sizeHint
().
width
()
+
...
@@ -240,6 +242,17 @@ void WQtDockTitleWidget::updateLayouts( int width )
...
@@ -240,6 +242,17 @@ void WQtDockTitleWidget::updateLayouts( int width )
m_toolsMenuLayout
->
addWidget
(
*
i
);
m_toolsMenuLayout
->
addWidget
(
*
i
);
}
}
// hide more button if nothing needs to be hiden
// hide more button if nothing needs to be hid
d
en
m_moreBtn
->
setHidden
(
!
(
hidden
.
size
()
)
);
m_moreBtn
->
setHidden
(
!
(
hidden
.
size
()
)
);
}
}
void
WQtDockTitleWidget
::
updateHelp
()
{
// hide button if no help is available.
if
(
dockParent
->
getHelpContext
()
==
""
)
{
m_helpBtn
->
setVisible
(
false
);
return
;
}
m_helpBtn
->
setVisible
(
true
);
}
src/qt4gui/guiElements/WQtDockTitleWidget.h
View file @
1d67c11f
...
@@ -35,6 +35,11 @@
...
@@ -35,6 +35,11 @@
#include "WScaleLabel.h"
#include "WScaleLabel.h"
/**
* We need the dock widget class.
*/
class
WQtDockWidget
;
/**
/**
* Class for managing dock widget title bars.
* Class for managing dock widget title bars.
*/
*/
...
@@ -47,7 +52,7 @@ public:
...
@@ -47,7 +52,7 @@ public:
*
*
* \param parent the parent
* \param parent the parent
*/
*/
explicit
WQtDockTitleWidget
(
Q
DockWidget
*
parent
);
explicit
WQtDockTitleWidget
(
WQt
DockWidget
*
parent
);
/**
/**
* Add the given action to the titlebar. It gets added after the previously added ones.
* Add the given action to the titlebar. It gets added after the previously added ones.
...
@@ -90,6 +95,10 @@ public:
...
@@ -90,6 +95,10 @@ public:
*/
*/
virtual
void
removeTitleWidget
(
QWidget
*
widget
);
virtual
void
removeTitleWidget
(
QWidget
*
widget
);
/**
* Update help button.
*/
virtual
void
updateHelp
();
protected:
protected:
/**
/**
* Called upon resize. Used to switch between the more menu and the tools widget
* Called upon resize. Used to switch between the more menu and the tools widget
...
@@ -167,7 +176,7 @@ private:
...
@@ -167,7 +176,7 @@ private:
/**
/**
* The parent as dock pointer
* The parent as dock pointer
*/
*/
Q
DockWidget
*
dockParent
;
WQt
DockWidget
*
dockParent
;
/**
/**
* We keep track of the widgets that we add
* We keep track of the widgets that we add
...
...
src/qt4gui/guiElements/WQtDockWidget.cpp
View file @
1d67c11f
...
@@ -36,6 +36,7 @@ WQtDockWidget::WQtDockWidget( const QString& title, QWidget* parent, Qt::WindowF
...
@@ -36,6 +36,7 @@ WQtDockWidget::WQtDockWidget( const QString& title, QWidget* parent, Qt::WindowF
// thats it. we now have the title bar
// thats it. we now have the title bar
m_titleBar
=
new
WQtDockTitleWidget
(
this
);
m_titleBar
=
new
WQtDockTitleWidget
(
this
);
setTitleBarWidget
(
m_titleBar
);
setTitleBarWidget
(
m_titleBar
);
m_titleBar
->
updateHelp
();
// some standard dock features
// some standard dock features
setAllowedAreas
(
Qt
::
AllDockWidgetAreas
);
setAllowedAreas
(
Qt
::
AllDockWidgetAreas
);
...
@@ -48,6 +49,7 @@ WQtDockWidget::WQtDockWidget( QWidget* parent, Qt::WindowFlags flags ):
...
@@ -48,6 +49,7 @@ WQtDockWidget::WQtDockWidget( QWidget* parent, Qt::WindowFlags flags ):
// thats it. we now have the title bar
// thats it. we now have the title bar
m_titleBar
=
new
WQtDockTitleWidget
(
this
);
m_titleBar
=
new
WQtDockTitleWidget
(
this
);
setTitleBarWidget
(
m_titleBar
);
setTitleBarWidget
(
m_titleBar
);
m_titleBar
->
updateHelp
();
// some standard dock features
// some standard dock features
setAllowedAreas
(
Qt
::
AllDockWidgetAreas
);
setAllowedAreas
(
Qt
::
AllDockWidgetAreas
);
...
@@ -92,6 +94,7 @@ void WQtDockWidget::removeTitleWidget( QWidget* widget )
...
@@ -92,6 +94,7 @@ void WQtDockWidget::removeTitleWidget( QWidget* widget )
void
WQtDockWidget
::
setHelpContext
(
const
QString
&
id
)
void
WQtDockWidget
::
setHelpContext
(
const
QString
&
id
)
{
{
m_helpContextId
=
id
;
m_helpContextId
=
id
;
m_titleBar
->
updateHelp
();
}
}
const
QString
&
WQtDockWidget
::
getHelpContext
()
const
QString
&
WQtDockWidget
::
getHelpContext
()
...
...
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