[vlc-devel] commit: Qt: remedy faulty locationBar layout (Jakob Leben )
git version control
git at videolan.org
Thu Feb 18 02:35:30 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Thu Feb 18 01:13:26 2010 +0100| [9af87f11844b8a398263e17e64e0898c94ea69f3] | committer: Jakob Leben
Qt: remedy faulty locationBar layout
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9af87f11844b8a398263e17e64e0898c94ea69f3
---
.../gui/qt4/components/playlist/standardpanel.cpp | 34 +++++++-------------
.../gui/qt4/components/playlist/standardpanel.hpp | 1 +
2 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 4ceeaeb..bc4a001 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -521,24 +521,22 @@ void LocationBar::invoke( int i_id )
void LocationBar::layOut( const QSize& size )
{
menuMore->clear();
+ widths.clear();
int count = buttons.count();
- QList<int> widths;
int totalWidth = 0;
for( int i = 0; i < count; i++ )
{
int w = buttons[i]->sizeHint().width();
- if( i == 0 || totalWidth + w <= size.width() )
- {
- totalWidth += w;
- widths.append( w );
- }
+ widths.append( w );
+ totalWidth += w;
if( totalWidth > size.width() ) break;
}
int x = 0;
int shown = widths.count();
- if( shown < count )
+
+ if( totalWidth > size.width() && count > 1 )
{
QSize sz = btnMore->sizeHint();
btnMore->setGeometry( 0, 0, sz.width(), size.height() );
@@ -550,28 +548,20 @@ void LocationBar::layOut( const QSize& size )
{
btnMore->hide();
}
- shown--;
for( int i = count - 1; i >= 0; i-- )
{
- if( i > shown )
- {
- menuMore->addAction( actions[i] );
- buttons[i]->hide();
- }
- else if( i > 0 && totalWidth > size.width() )
+ if( totalWidth <= size.width() || i == 0)
{
- menuMore->addAction( actions[i] );
- buttons[i]->hide();
+ buttons[i]->setGeometry( x, 0, qMin( size.width() - x, widths[i] ), size.height() );
+ buttons[i]->show();
+ x += widths[i];
totalWidth -= widths[i];
}
else
{
- buttons[i]->setGeometry( x, 0,
- qMin( widths[i], size.width() - x ),
- size.height() );
- buttons[i]->show();
- totalWidth -= widths[i];
- x += widths[i];
+ menuMore->addAction( actions[i] );
+ buttons[i]->hide();
+ if( i < shown ) totalWidth -= widths[i];
}
}
}
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index 66fb613..ab1cd03 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -152,6 +152,7 @@ private:
QList<QAction*> actions;
LocationButton *btnMore;
QMenu *menuMore;
+ QList<int> widths;
};
#endif
More information about the vlc-devel
mailing list