summaryrefslogtreecommitdiffstats
path: root/tools/qmlviewer/qmlviewer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qmlviewer/qmlviewer.cpp')
-rw-r--r--tools/qmlviewer/qmlviewer.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index b2884dd..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,6 +312,9 @@ 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);
@@ -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,7 +669,8 @@ void QmlViewer::openQml(const QString& fileName)
if (!skin) {
canvas->updateGeometry();
- canvas->resize(canvas->sizeHint());
+ if (mb)
+ mb->updateGeometry();
resize(sizeHint());
} else {
if (scaleSkin)