Commit 9af87f11 authored by Jakob Leben's avatar Jakob Leben

Qt: remedy faulty locationBar layout

parent cd22ae1d
...@@ -521,24 +521,22 @@ void LocationBar::invoke( int i_id ) ...@@ -521,24 +521,22 @@ void LocationBar::invoke( int i_id )
void LocationBar::layOut( const QSize& size ) void LocationBar::layOut( const QSize& size )
{ {
menuMore->clear(); menuMore->clear();
widths.clear();
int count = buttons.count(); int count = buttons.count();
QList<int> widths;
int totalWidth = 0; int totalWidth = 0;
for( int i = 0; i < count; i++ ) for( int i = 0; i < count; i++ )
{ {
int w = buttons[i]->sizeHint().width(); int w = buttons[i]->sizeHint().width();
if( i == 0 || totalWidth + w <= size.width() ) widths.append( w );
{ totalWidth += w;
totalWidth += w;
widths.append( w );
}
if( totalWidth > size.width() ) break; if( totalWidth > size.width() ) break;
} }
int x = 0; int x = 0;
int shown = widths.count(); int shown = widths.count();
if( shown < count )
if( totalWidth > size.width() && count > 1 )
{ {
QSize sz = btnMore->sizeHint(); QSize sz = btnMore->sizeHint();
btnMore->setGeometry( 0, 0, sz.width(), size.height() ); btnMore->setGeometry( 0, 0, sz.width(), size.height() );
...@@ -550,28 +548,20 @@ void LocationBar::layOut( const QSize& size ) ...@@ -550,28 +548,20 @@ void LocationBar::layOut( const QSize& size )
{ {
btnMore->hide(); btnMore->hide();
} }
shown--;
for( int i = count - 1; i >= 0; i-- ) for( int i = count - 1; i >= 0; i-- )
{ {
if( i > shown ) if( totalWidth <= size.width() || i == 0)
{
menuMore->addAction( actions[i] );
buttons[i]->hide();
}
else if( i > 0 && totalWidth > size.width() )
{ {
menuMore->addAction( actions[i] ); buttons[i]->setGeometry( x, 0, qMin( size.width() - x, widths[i] ), size.height() );
buttons[i]->hide(); buttons[i]->show();
x += widths[i];
totalWidth -= widths[i]; totalWidth -= widths[i];
} }
else else
{ {
buttons[i]->setGeometry( x, 0, menuMore->addAction( actions[i] );
qMin( widths[i], size.width() - x ), buttons[i]->hide();
size.height() ); if( i < shown ) totalWidth -= widths[i];
buttons[i]->show();
totalWidth -= widths[i];
x += widths[i];
} }
} }
} }
......
...@@ -152,6 +152,7 @@ private: ...@@ -152,6 +152,7 @@ private:
QList<QAction*> actions; QList<QAction*> actions;
LocationButton *btnMore; LocationButton *btnMore;
QMenu *menuMore; QMenu *menuMore;
QList<int> widths;
}; };
#endif #endif
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