Permalink
Browse files

Fix MessageBar on OSX (don't resize to fill window!)

  • Loading branch information...
1 parent f3a4674 commit b5f307f266b2c7fe6300cebe4f06431253f6c7eb @jonocole jonocole committed Sep 10, 2009
Showing with 23 additions and 13 deletions.
  1. +13 −8 app/radio/MainWindow.cpp
  2. +3 −0 app/radio/MainWindow.h
  3. +6 −4 app/radio/widgets/MessageBar.cpp
  4. +1 −1 app/radio/widgets/MessageBar.h
View
@@ -26,7 +26,6 @@
#include <QLineEdit>
#include <QSizeGrip>
#include <QStatusBar>
-#include <QStackedLayout>
MainWindow::MainWindow()
{
@@ -57,12 +56,12 @@ MainWindow::MainWindow()
MainWidget* mw;
QWidget* w = new QWidget();
- // a stacked layout so the messagebar can intrude over the top
- QStackedLayout* sl = new QStackedLayout(w);
- sl->setStackingMode(QStackedLayout::StackAll);
- sl->addWidget(m_messageBar = new MessageBar());
- sl->addWidget(mw = new MainWidget());
- sl->setCurrentWidget(m_messageBar); // make sure it's on top.
+
+ new QVBoxLayout( w );
+ w->layout()->addWidget(mw = new MainWidget());
+
+ m_messageBar = new MessageBar( this );
+
connect(mw, SIGNAL(startRadio(RadioStation)), SIGNAL(startRadio(RadioStation)));
AuthenticatedUser user;
@@ -74,6 +73,7 @@ MainWindow::MainWindow()
setCentralWidget( w );
finishUi();
+ m_messageBar->raise();
}
void
@@ -105,4 +105,9 @@ MainWindow::onRadioError(int code, const QVariant& data)
break;
}
}
-
+#include <QResizeEvent>
+void
+MainWindow::resizeEvent(QResizeEvent* event)
+{
+ m_messageBar->resize( event->size().width(), m_messageBar->height());
+}
View
@@ -38,6 +38,9 @@ class MainWindow : public unicorn::MainWindow
public slots:
void onRadioError(int code, const QVariant& data);
+protected:
+ virtual void resizeEvent(QResizeEvent* event);
+
private:
MessageBar* m_messageBar;
};
@@ -22,12 +22,14 @@
#include <QtGui>
-MessageBar::MessageBar()
+MessageBar::MessageBar( QWidget* parent )
+ :QWidget( parent )
{
+ setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
+ updateGeometry();
setFixedHeight( 0 );
-
ui.papyrus = new QWidget( this );
-
+
QPalette p = palette();
p.setColor( QPalette::Text, Qt::black );
p.setColor( QPalette::Window, QColor( 0xfa, 0xfa, 0xc7 ) );
@@ -130,7 +132,7 @@ MessageBar::onLabelDestroyed()
void
-MessageBar::resizeEvent( QResizeEvent* )
+MessageBar::resizeEvent( QResizeEvent* e )
{
ui.papyrus->setFixedWidth( width() );
foreach (QLabel* l, findChildren<QLabel*>())
@@ -39,7 +39,7 @@ class MessageBar : public QWidget
void doLayout();
public:
- MessageBar();
+ MessageBar( QWidget* parent = 0 );
public slots:
void show( const QString&, const QString& id = QString() );

0 comments on commit b5f307f

Please sign in to comment.