diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-10-07 01:19:38 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-10-07 01:19:38 (GMT) |
commit | 0d0d1691f8c73f9040a0d7020bda96fc7673536a (patch) | |
tree | 4913936c00130167b4ae64e0114e61b977425ab4 /tools | |
parent | e1452cfc79a1fed77e646427092e181b7eb2ca2f (diff) | |
parent | afcad4b4393b4f7187737fb8b4e528887b07d943 (diff) | |
download | Qt-0d0d1691f8c73f9040a0d7020bda96fc7673536a.zip Qt-0d0d1691f8c73f9040a0d7020bda96fc7673536a.tar.gz Qt-0d0d1691f8c73f9040a0d7020bda96fc7673536a.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index e185536..07b68ea 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -55,6 +55,26 @@ QT_BEGIN_NAMESPACE + +class SizedMenuBar : public QMenuBar +{ + Q_OBJECT +public: + SizedMenuBar(QWidget *parent, QWidget *referenceWidget) + : QMenuBar(parent), refWidget(referenceWidget) + { + } + + virtual QSize sizeHint() const + { + return QSize(refWidget->sizeHint().width(), QMenuBar::sizeHint().height()); + } + +private: + QWidget *refWidget; +}; + + class PreviewDeviceSkin : public DeviceSkin { Q_OBJECT @@ -281,10 +301,6 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) } else { recdlg->warning->hide(); } - - - if (!(flags & Qt::FramelessWindowHint)) - createMenu(menuBar(),0); canvas = new QmlView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); @@ -296,13 +312,16 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors())); + if (!(flags & Qt::FramelessWindowHint)) + createMenu(menuBar(),0); + QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); setLayout(layout); if (mb) layout->addWidget(mb); - layout->addWidget(canvas, 0, Qt::AlignLeft); + layout->addWidget(canvas); setupProxy(); canvas->engine()->networkAccessManager()->setCookieJar(new PersistentCookieJar(this)); @@ -319,7 +338,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) QMenuBar *QmlViewer::menuBar() const { if (!mb) - mb = new QMenuBar((QWidget*)this); + mb = new SizedMenuBar((QWidget*)this, canvas); return mb; } @@ -650,8 +669,8 @@ void QmlViewer::openQml(const QString& fileName) if (!skin) { canvas->updateGeometry(); - canvas->resize(canvas->sizeHint()); - canvas->updateGeometry(); + if (mb) + mb->updateGeometry(); resize(sizeHint()); } else { if (scaleSkin) |