Commit 3c593714 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - removed the dummyButton crap. Set minimum width and height of the...

[CHANGE] - removed the dummyButton crap. Set minimum width and height of the toolbars to reserve space even if they are empty
parent 3b9f3532
...@@ -46,6 +46,9 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc ...@@ -46,6 +46,9 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc
setAllowedAreas( Qt::AllToolBarAreas ); setAllowedAreas( Qt::AllToolBarAreas );
setObjectName( QString( "Compatible Modules" ) ); setObjectName( QString( "Compatible Modules" ) );
setMinimumWidth( 50 );
setMinimumHeight( 30 );
// this sets the toolbar style // this sets the toolbar style
int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style int compToolBarStyle = parent->getToolbarStyle(); // this defaults to the global toolbar style
WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle ); WPreferences::getPreference( "qt4gui.compatiblesToolBarStyle", &compToolBarStyle );
...@@ -59,7 +62,6 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc ...@@ -59,7 +62,6 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent, const WQtCombinerAc
// create the list of actions possible // create the list of actions possible
addActions( compatibles ); addActions( compatibles );
insertDummyButton();
} }
WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent ) WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent )
...@@ -79,9 +81,6 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent ) ...@@ -79,9 +81,6 @@ WQtCombinerToolbar::WQtCombinerToolbar( WMainWindow* parent )
// cast and set // cast and set
setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( compToolBarStyle ) ); setToolButtonStyle( static_cast< Qt::ToolButtonStyle >( compToolBarStyle ) );
// reserve size
insertDummyButton();
} }
WQtCombinerToolbar::~WQtCombinerToolbar() WQtCombinerToolbar::~WQtCombinerToolbar()
...@@ -91,23 +90,11 @@ WQtCombinerToolbar::~WQtCombinerToolbar() ...@@ -91,23 +90,11 @@ WQtCombinerToolbar::~WQtCombinerToolbar()
void WQtCombinerToolbar::makeEmpty() void WQtCombinerToolbar::makeEmpty()
{ {
clear(); clear();
insertDummyButton();
} }
void WQtCombinerToolbar::updateButtons( const WQtCombinerActionList& compatibles ) void WQtCombinerToolbar::updateButtons( const WQtCombinerActionList& compatibles )
{ {
clear(); clear();
addActions( compatibles ); addActions( compatibles );
insertDummyButton();
} }
void WQtCombinerToolbar::insertDummyButton()
{
// this is needed to ensure a constant height or width (if toolbar is in vertical mode). We use a label as an empty label has no graphical
// representation. The width and height are set both because we do not know a priori how the toolbar is oriented as it might change after
// creation.
QLabel* dummy = new QLabel;
dummy->setFixedWidth( 50 );
dummy->setFixedHeight( 30 );
addWidget( dummy );
}
...@@ -73,13 +73,7 @@ public: ...@@ -73,13 +73,7 @@ public:
void makeEmpty(); void makeEmpty();
protected: protected:
private: private:
/**
* Insert dummy button so that the toolbar is not hidden.
*/
void insertDummyButton();
WMainWindow* m_parent; //!< The widget managing this widget. WMainWindow* m_parent; //!< The widget managing this widget.
}; };
......
...@@ -35,10 +35,8 @@ WQtToolBar::WQtToolBar( const QString & title, QWidget* parent ) ...@@ -35,10 +35,8 @@ WQtToolBar::WQtToolBar( const QString & title, QWidget* parent )
this->setAllowedAreas( Qt::AllToolBarAreas ); this->setAllowedAreas( Qt::AllToolBarAreas );
// The following makes the bar having button size from the beginning. setMinimumWidth( 50 );
QPushButton* dummyButton = new QPushButton; setMinimumHeight( 30 );
dummyButton->setFixedWidth( 0 );
addWidget( dummyButton );
} }
WQtToolBar::~WQtToolBar() WQtToolBar::~WQtToolBar()
...@@ -79,9 +77,5 @@ void WQtToolBar::clearButtons() ...@@ -79,9 +77,5 @@ void WQtToolBar::clearButtons()
// clear the lists // clear the lists
m_widgets.clear(); m_widgets.clear();
// The following prevents the bar from changing size when it has no real buttons.
QPushButton* dummyButton = new QPushButton;
dummyButton->setFixedWidth( 0 );
addWidget( dummyButton );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment