51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "declarativemainwindow_p.h"
+#include "declarativemainwindowextension_p.h"
+#include <QDeclarativeInfo>
#include <QDialog>
+#include <QMainWindow>
#include <QMenuBar>
#include <QStatusBar>
#include <QToolBar>
-DeclarativeMainWindow::DeclarativeMainWindow(QObject *parent)
- : DeclarativeWidgetProxy<QMainWindow>(parent)
+DeclarativeMainWindowExtension::DeclarativeMainWindowExtension(QObject *parent)
+ : DeclarativeWidgetExtension(parent)
{
- connectAllSignals(m_proxiedObject, this);
}
-void DeclarativeMainWindow::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject)
+QMainWindow *DeclarativeMainWindowExtension::extendedMainWindow() const
+{
+ QMainWindow *mainWindow = qobject_cast<QMainWindow*>(extendedWidget());
+ Q_ASSERT(mainWindow);
+
+ return mainWindow;
+}
+
+void DeclarativeMainWindowExtension::addWidget(QWidget *widget)
{
QMenuBar *menuBar = qobject_cast<QMenuBar*>(widget);
QToolBar *toolBar = qobject_cast<QToolBar*>(widget);
QDialog *dialog = qobject_cast<QDialog*>(widget);
if (menuBar) {
- m_proxiedObject->setMenuBar(menuBar);
+ extendedMainWindow()->setMenuBar(menuBar);
} else if (toolBar) {
- m_proxiedObject->addToolBar(toolBar);
+ extendedMainWindow()->addToolBar(toolBar);
} else if (statusBar) {
- m_proxiedObject->setStatusBar(statusBar);
+ extendedMainWindow()->setStatusBar(statusBar);
} else if (dialog) {
// We allow to place dialogs on the mainwindow
- dialog->setParent(m_proxiedObject, dialog->windowFlags());
+ dialog->setParent(extendedMainWindow(), dialog->windowFlags());
} else if (widget) {
- if (m_proxiedObject->centralWidget()) {
- qmlInfo(declarativeObject) << "The QMainWindow contains a central widget already";
+ if (extendedMainWindow()->centralWidget()) {
+ qmlInfo(extendedMainWindow()) << "The MainWindow already contains a central widget";
return;
}
- m_proxiedObject->setCentralWidget(widget);
+ extendedMainWindow()->setCentralWidget(widget);
}
-
- m_children.append(declarativeObject);
}
-void DeclarativeMainWindow::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject)
+void DeclarativeMainWindowExtension::setLayout(QLayout *layout)
{
Q_UNUSED(layout);
- Q_UNUSED(declarativeObject);
- qmlInfo(this) << "Can not set a QLayout to a QMainWindow";
+ qmlInfo(this) << "Can not set a Layout to a MainWindow";
}
-
-CUSTOM_METAOBJECT(DeclarativeMainWindow, QMainWindow)
#ifndef DECLARATIVEMAINWINDOW_P_H
#define DECLARATIVEMAINWINDOW_P_H
-#include "declarativewidgetproxy_p.h"
+#include "declarativewidgetextension.h"
-#include <QMainWindow>
+class QMainWindow;
-class DeclarativeMainWindow : public DeclarativeWidgetProxy<QMainWindow>
+class DeclarativeMainWindowExtension : public DeclarativeWidgetExtension
{
- DECLARATIVE_OBJECT
+ Q_OBJECT
+
+ // repeat property declarations, qmlRegisterExtendedType doesn't see the ones from base class
+ Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data DESIGNABLE false)
+
+ Q_CLASSINFO("DefaultProperty", "data")
public:
- explicit DeclarativeMainWindow(QObject *parent = 0);
+ explicit DeclarativeMainWindowExtension(QObject *parent = 0);
+
+ QMainWindow *extendedMainWindow() const;
protected:
- void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject);
- void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject);
+ void addWidget(QWidget *widget);
+ void setLayout(QLayout *layout);
};
#endif
#include "declarativeinputdialog_p.h"
#include "declarativelcdnumber_p.h"
#include "declarativelistview_p.h"
-#include "declarativemainwindow_p.h"
+#include "declarativemainwindowextension_p.h"
#include "declarativemenubar_p.h"
#include "declarativemenu_p.h"
#include "declarativemessagebox_p.h"
#include <QDeclarativeContext>
#include <QDeclarativeEngine>
#include <QLabel>
+#include <QMainWindow>
+#include <QMenu>
+#include <QMenuBar>
#include <QRadioButton>
#include <QWebView>
qmlRegisterType<DeclarativeLabel>("QtGui", 1, 0, "Label");
qmlRegisterType<DeclarativeLCDNumber>("QtGui", 1, 0, "LCDNumber");
qmlRegisterType<DeclarativeListView>("QtGui", 1, 0, "ListView");
- qmlRegisterType<DeclarativeMainWindow>("QtGui", 1, 0, "MainWindow");
qmlRegisterType<DeclarativeMenu>("QtGui", 1, 0, "Menu");
qmlRegisterType<DeclarativeMenuBar>("QtGui", 1, 0, "MenuBar");
qmlRegisterType<DeclarativeMessageBoxAttached>();
qmlRegisterExtendedType<QCheckBox, DeclarativeWidgetExtension>("QtGui", 1, 0, "CheckBox");
qmlRegisterExtendedType<QLabel, DeclarativeWidgetExtension>("QtGui", 1, 0, "Label");
qmlRegisterExtendedType<QLineEdit, DeclarativeWidgetExtension>("QtGui", 1, 0, "LineEdit");
+ qmlRegisterExtendedType<QMainWindow, DeclarativeMainWindowExtension>("QtGui", 1, 0, "MainWindow");
qmlRegisterExtendedType<QPushButton, DeclarativeWidgetExtension>("QtGui", 1, 0, "PushButton");
qmlRegisterExtendedType<QRadioButton, DeclarativeWidgetExtension>("QtGui", 1, 0, "RadioButton");
qmlRegisterExtendedType<DeclarativeTabWidget, DeclarativeTabWidgetExtension>("QtGui", 1, 0, "TabWidget");
declarativelayoutproxy_p.h \
declarativelcdnumber_p.h \
declarativelistview_p.h \
- declarativemainwindow_p.h \
+ declarativemainwindowextension_p.h \
declarativemenubar_p.h \
declarativemenu_p.h \
declarativemessagebox_p.h \
declarativelayoutextension.cpp \
declarativelcdnumber.cpp \
declarativelistview.cpp \
- declarativemainwindow.cpp \
+ declarativemainwindowextension.cpp \
declarativemenubar.cpp \
declarativemenu.cpp \
declarativemessagebox.cpp \