Skip to content
Snippets Groups Projects
Commit ac71bee0 authored by Frantisek Vacek's avatar Frantisek Vacek Committed by Nicolas Arnaud-Cormos
Browse files

Qnx: Cascades project template is obsolete


Qt Creator QTCREATORBUG-10375

The old Cascades template application was more sample than template
and it was simplified.

The application UI object name doesn't follow the project name anymore.
This change was introduced because C++ class name rules are more
restrictive than the project ones. More than that, it is harder
to start with some test project and then refractor it to some real one.
There is no gain to have UI object class name same as the enclosing
project one.

The application icon added to the bar-descriptor.xml

Change-Id: I198f61a631fa2c758f3e8ac377c06ce7560cc911
Reviewed-by: default avatarNicolas Arnaud-Cormos <nicolas@kdab.com>
parent 1d9d3885
No related branches found
No related tags found
No related merge requests found
Showing
with 95 additions and 110 deletions
import bb.cascades 1.0
Page {
id: seconPage
paneProperties: NavigationPaneProperties {
backButton: ActionItem {
onTriggered: {
navigationPane.pop()
}
}
}
Container {
layout: DockLayout {}
Label {
text: qsTr("Hello Cascades!")
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText
}
}
}
}
import bb.cascades 1.0 import bb.cascades 1.0
NavigationPane { Page {
id: navigationPane Container {
Page { layout: DockLayout { }
Container { Label {
layout: DockLayout {} text: qsTr("Hello World")
Button { textStyle.base: SystemDefaults.TextStyles.BigText
horizontalAlignment: HorizontalAlignment.Center verticalAlignment: VerticalAlignment.Center
verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center
text: qsTr("Next")
onClicked: {
var page = getSecondPage();
navigationPane.push(page);
}
property Page secondPage
function getSecondPage() {
if (! secondPage) {
secondPage = secondPageDefinition.createObject();
}
return secondPage;
}
attachedObjects: [
ComponentDefinition {
id: secondPageDefinition
source: "SecondPage.qml"
}
]
}
} }
} }
onCreationCompleted: {
console.log("NavigationPane - onCreationCompleted()");
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
}
} }
...@@ -4,14 +4,25 @@ ...@@ -4,14 +4,25 @@
<name>%ProjectName%</name> <name>%ProjectName%</name>
<versionNumber>1.0.0</versionNumber> <versionNumber>1.0.0</versionNumber>
<description>DESCRIPTION</description> <description>DESCRIPTION</description>
<initialWindow> <initialWindow>
<systemChrome>none</systemChrome> <systemChrome>none</systemChrome>
<transparent>false</transparent> <transparent>false</transparent>
<autoOrients>true</autoOrients> <autoOrients>true</autoOrients>
<aspectRatio>landscape</aspectRatio> <aspectRatio>landscape</aspectRatio>
</initialWindow> </initialWindow>
<!-- The icon for the application, which should be 114x114. -->
<icon>
<image>icon.png</image>
</icon>
<env value="app/native/lib:/usr/lib/qt4/lib/" var="LD_LIBRARY_PATH"/> <env value="app/native/lib:/usr/lib/qt4/lib/" var="LD_LIBRARY_PATH"/>
<action system="true">run_native</action> <action system="true">run_native</action>
<asset path="%ProjectName%" type="Qnx/Elf" entry="true">%ProjectName%</asset>
<!-- Application assets -->
<asset path="%SRC_DIR%/icon.png">icon.png</asset>
<asset path="%SRC_DIR%/assets">assets</asset> <asset path="%SRC_DIR%/assets">assets</asset>
<asset path="%ProjectName%" type="Qnx/Elf" entry="true">%ProjectName%</asset>
</qnx> </qnx>
#include "%ProjectName%.hpp"
#include <bb/cascades/Application>
#include <Qt/qdeclarativedebug.h>
Q_DECL_EXPORT int main(int argc, char **argv)
{
bb::cascades::Application app(argc, argv);
new %ProjectName:s%(&app);
return bb::cascades::Application::exec();
}
#include "%ProjectName%.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
%ProjectName:s%::%ProjectName:s%(bb::cascades::Application *app)
: QObject(app)
{
bb::cascades::QmlDocument *qml = bb::cascades::QmlDocument::create("asset:///main.qml").parent(this);
bb::cascades::AbstractPane *root = qml->createRootObject<bb::cascades::AbstractPane>();
app->setScene(root);
}
#ifndef %ProjectName:h%_HPP_
#define %ProjectName:h%_HPP_
#include <QObject>
namespace bb { namespace cascades { class Application; }}
class %ProjectName:s% : public QObject
{
Q_OBJECT
public:
%ProjectName:s%(bb::cascades::Application *app);
virtual ~%ProjectName:s%() {}
};
#endif /* %ProjectName:h%_HPP_ */
...@@ -3,11 +3,15 @@ TEMPLATE = app ...@@ -3,11 +3,15 @@ TEMPLATE = app
LIBS += -lbbdata -lbb -lbbcascades LIBS += -lbbdata -lbb -lbbcascades
QT += declarative xml QT += declarative xml
SOURCES += main.cpp \ SOURCES += \
%ProjectName%.cpp src/main.cpp \
src/applicationui.cpp \
HEADERS += %ProjectName%.hpp HEADERS += \
src/applicationui.h \
OTHER_FILES += bar-descriptor.xml \ OTHER_FILES += \
bar-descriptor.xml \
assets/main.qml \ assets/main.qml \
assets/SecondPage.qml
#include "applicationui.h"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
using namespace bb::cascades;
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
QObject(app)
{
// By default the QmlDocument object is owned by the Application instance
// and will have the lifespan of the application
QmlDocument *qml = QmlDocument::create("asset:///main.qml");
// Create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// Set created root object as the application scene
app->setScene(root);
}
#ifndef APPLICATIONUI_H
#define APPLICATIONUI_H
#include <QObject>
namespace bb {
namespace cascades {
class Application;
}
}
class ApplicationUI : public QObject
{
Q_OBJECT
public:
ApplicationUI(bb::cascades::Application *app);
virtual ~ApplicationUI() {}
};
#endif /* APPLICATIONUI_H */
#include "applicationui.h"
#include <bb/cascades/Application>
#include <Qt/qdeclarativedebug.h>
using namespace bb::cascades;
Q_DECL_EXPORT int main(int argc, char **argv)
{
Application app(argc, argv);
// Create the Application UI object, this is where the main.qml file
// is loaded and the application scene is set.
new ApplicationUI(&app);
// Enter the application main event loop.
return Application::exec();
}
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
<displayname>BlackBerry Cascades Application</displayname>; <displayname>BlackBerry Cascades Application</displayname>;
<description>Creates a Cascades application for BlackBerry 10.</description> <description>Creates a Cascades application for BlackBerry 10.</description>
<files> <files>
<file source="main.cpp" openeditor="true"/>
<file source="assets/main.qml" openeditor="true"/> <file source="assets/main.qml" openeditor="true"/>
<file source="assets/SecondPage.qml" openeditor="true"/>
<file source="bar-descriptor.xml" openeditor="true"/> <file source="bar-descriptor.xml" openeditor="true"/>
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/> <file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
<file source="project.hpp" target="%ProjectName%.hpp" openproject="true"/> <file source="src/main.cpp" openeditor="true"/>
<file source="project.cpp" target="%ProjectName%.cpp" openproject="true"/> <file source="src/applicationui.h" openproject="true"/>
</files> <file source="src/applicationui.cpp" openproject="true"/>
<file source="icon.png"/>
</files>
</wizard> </wizard>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment