Commit 424fcf8c authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlApp template: Use new 4.7.1 API to enable qml debugging

Qml debugging is now disabled by default, and has to be enabled
explicitly (b2016bbfc9). This has to be done before the
QDView/QDEngine is instantiated ...

The patch introduces a static create method to QmlApplicationViewer,
so that the setup can be hidden from the users main file.
parent cd6e4d6b
......@@ -5,11 +5,12 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QmlApplicationViewer viewer;
viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION
viewer.setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML
viewer.show();
QmlApplicationViewer *viewer = QmlApplicationViewer::create();
viewer->addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION
viewer->setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML
viewer->show();
return app.exec();
}
......@@ -59,8 +59,8 @@ class QmlApplicationViewerPrivate
QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
{
#ifdef Q_OS_UNIX
#ifdef Q_OS_MAC
#if defined(Q_OS_UNIX)
#if defined(Q_OS_MAC)
if (!QDir::isAbsolutePath(path))
return QCoreApplication::applicationDirPath()
+ QLatin1String("/../Resources/") + path;
......@@ -95,6 +95,16 @@ QmlApplicationViewer::~QmlApplicationViewer()
delete m_d;
}
QmlApplicationViewer *QmlApplicationViewer::create()
{
#if defined(QMLJSDEBUGGER)
QDeclarativeDebugHelper::enableDebugging();
#endif
QmlApplicationViewer *viewer = new QmlApplicationViewer();
viewer->setAttribute(Qt::WA_DeleteOnClose);
return viewer;
}
void QmlApplicationViewer::setMainQmlFile(const QString &file)
{
m_d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file);
......@@ -108,7 +118,7 @@ void QmlApplicationViewer::addImportPath(const QString &path)
void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
{
#ifdef Q_OS_SYMBIAN
#if defined(Q_OS_SYMBIAN)
if (orientation != ScreenOrientationAuto) {
#if defined(ORIENTATIONLOCK)
const CAknAppUiBase::TAppUiOrientation uiOrientation =
......@@ -146,7 +156,7 @@ void QmlApplicationViewer::setOrientation(ScreenOrientation orientation)
void QmlApplicationViewer::showExpanded()
{
#ifdef Q_OS_SYMBIAN
#if defined(Q_OS_SYMBIAN)
showFullScreen();
#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
showMaximized();
......
......@@ -23,15 +23,18 @@ public:
ScreenOrientationAuto
};
explicit QmlApplicationViewer(QWidget *parent = 0);
virtual ~QmlApplicationViewer();
static QmlApplicationViewer *create();
void setMainQmlFile(const QString &file);
void addImportPath(const QString &path);
void setOrientation(ScreenOrientation orientation);
void showExpanded();
private:
explicit QmlApplicationViewer(QWidget *parent = 0);
class QmlApplicationViewerPrivate *m_d;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment