Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[port] Port to QtQuick2/Qt5 #6

Merged
merged 3 commits into from Aug 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 22 additions & 14 deletions main.cpp
@@ -1,18 +1,30 @@
#include <QtGui/QApplication>
#include <QGuiApplication>
#include <QtDebug>

#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QQuickView>
#include <QQmlEngine>

#include <QOrganizerManager>
#include <QOrganizerAbstractRequest>

QTM_USE_NAMESPACE
#ifdef HAS_BOOSTER
#include <MDeclarativeCache>
#endif

using namespace QtOrganizer;

#ifdef HAS_BOOSTER
Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
#ifdef HAS_BOOSTER
QScopedPointer<QGuiApplication> app(MDeclarativeCache::qApplication(argc, argv));
QScopedPointer<QQuickView> view(MDeclarativeCache::qQuickView());
#else
QScopedPointer<QGuiApplication> app(new QGuiApplication(argc, argv));
QScopedPointer<QQuickView> view(new QQuickView);
#endif

qRegisterMetaType<QOrganizerAbstractRequest::State>("QOrganizerAbstractRequest::State");
qRegisterMetaType<QList<QOrganizerItemId> >("QList<QOrganizerItemId>");
Expand All @@ -21,13 +33,9 @@ int main(int argc, char *argv[])
qRegisterMetaType<QOrganizerItemId>("QOrganizerItemId");
qRegisterMetaType<QOrganizerCollectionId>("QOrganizerCollectionId");

view.setSource(QUrl("/opt/qmlcalendar/qml/qmlcalendar/main.qml"));
view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
view.showFullScreen();
view.setAttribute(Qt::WA_OpaquePaintEvent);
view.setAttribute(Qt::WA_NoSystemBackground);
view.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
view.viewport()->setAttribute(Qt::WA_NoSystemBackground);
view->setSource(QUrl("/opt/qmlcalendar/qml/qmlcalendar/main.qml"));
view->setResizeMode(QQuickView::SizeRootObjectToView);
view->showFullScreen();

return app.exec();
return app->exec();
}
9 changes: 5 additions & 4 deletions qml/qmlcalendar/CalendarView.qml
Expand Up @@ -31,11 +31,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/

import QtQuick 1.1
import QtQuick 2.0
import "month.js" as Month
import com.nokia.extras 1.0
import QtMobility.organizer 1.1
import com.nokia.meego 1.0
import QtOrganizer 5.0
import com.nokia.meego 2.0

Item {
id: calendarView
Expand Down Expand Up @@ -107,6 +106,7 @@ Item {
endPeriod: Month.tomorrow(currentDate);
autoUpdate: true

/* FIXME: works in qt4, but ref to onEventsChanged could not be found anywhere else on qt4 nemo rootfs
onEventsChanged: {
console.log("Events changed...")

Expand All @@ -117,6 +117,7 @@ Item {

dayView.updateItemIds()
}
*/
}

Item {
Expand Down
6 changes: 3 additions & 3 deletions qml/qmlcalendar/DayView.qml
Expand Up @@ -31,9 +31,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/

import QtQuick 1.1
import com.nokia.meego 1.2
import QtMobility.organizer 1.1
import QtQuick 2.0
import com.nokia.meego 2.0
import QtOrganizer 5.0
import "month.js" as Month

Page {
Expand Down
6 changes: 3 additions & 3 deletions qml/qmlcalendar/MonthDaysGrid.qml
Expand Up @@ -30,10 +30,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/

import QtQuick 1.1
import QtQuick 2.0
import "month.js" as Month
import QtMobility.organizer 1.1
import com.nokia.meego 1.0
import QtOrganizer 5.0
import com.nokia.meego 2.0

Grid {
id: monthDaysGrid
Expand Down
8 changes: 3 additions & 5 deletions qml/qmlcalendar/What.qml
Expand Up @@ -30,11 +30,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/

// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.0
import QtMobility.organizer 1.1
import QtQuick 2.0
import com.nokia.meego 2.0
import QtOrganizer 5.0
import "logic.js" as Logic
import "month.js" as Month

Expand Down
4 changes: 2 additions & 2 deletions qml/qmlcalendar/main.qml
Expand Up @@ -30,8 +30,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/

import QtQuick 1.1
import com.nokia.meego 1.0
import QtQuick 2.0
import com.nokia.meego 2.0
import "month.js" as Month

PageStackWindow {
Expand Down
12 changes: 5 additions & 7 deletions qmlcalendar.desktop
@@ -1,11 +1,9 @@
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Name=Calendar
Exec=/usr/bin/single-instance /opt/qmlcalendar/bin/qmlcalendar
Categories=Applications;
Exec=invoker --type=qtcomponents-qt5 -s /opt/qmlcalendar/bin/qmlcalendar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. If you'd like to use the qtcomponents-qt5 booster, you must add PKGCONFIG += qdeclarative5-boostable and the MDeclarativeCache usage in main.cpp. Other projects like qmlcalc should have examples of what to do.

Or, that can be a separate change later and this line can be left unchanged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I shall add boostable soon after (even though now the app launches without problems). Would you like me to add boostable commit to this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's ready quickly, sure. Otherwise, a separate PR would be fine.

It will still launch without problems, but it's much slower: first the qtcomponents-qt5 booster is failing to launch, then it falls back to a direct unboosted launch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, boosted in the same PR. All tested, works

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Icon=/usr/share/icons/hicolor/80x80/apps/qmlcalendar.png
X-Window-Icon=
X-HildonDesk-ShowInToolbar=true
X-Osso-Type=application/x-executable

X-Desktop-File-Install-Version=0.20

21 changes: 15 additions & 6 deletions qmlcalendar.pro
@@ -1,19 +1,18 @@

QT += declarative
QT += qml quick

CONFIG += mobility
CONFIG += link_pkgconfig

MOBILITY = organizer
PKGCONFIG = Qt5Organizer

OTHER_FILES += \
qml/qmlcalendar/*.qml \
qml/qmlcalendar/*.js

#RESOURCES += \
# qmlcalendar.qrc

SOURCES += main.cpp

TARGET = qmlcalendar

jsFiles.path = /opt/$${TARGET}/qml/qmlcalendar
jsFiles.files = qml/qmlcalendar/*.js

Expand Down Expand Up @@ -42,3 +41,13 @@ icon.files = qmlcalendar.png
icon.path = /usr/share/icons/hicolor/80x80/apps
INSTALLS += icon

CONFIG += link_pkgconfig

packagesExist(qdeclarative5-boostable) {
message("Building with qdeclarative5-boostable support")
DEFINES += HAS_BOOSTER
PKGCONFIG += qdeclarative5-boostable
} else {
warning("qdeclarative5-boostable not available; startup times will be slower")
}

23 changes: 13 additions & 10 deletions rpm/qmlcalendar.spec
@@ -1,6 +1,6 @@
#
# Do NOT Edit the Auto-generated Part!
# Generated by: spectacle version 0.25
# Generated by: spectacle version 0.27
#

Name: qmlcalendar
Expand All @@ -9,28 +9,31 @@ Name: qmlcalendar
# << macros

Summary: Calendar application made with QML
Version: 0.2.0
Version: 0.3
Release: 1
Group: Applications/System
License: BSD
URL: https://github.com/nemomobile/qmlcalendar/
Source0: %{name}-%{version}.tar.bz2
Source100: qmlcalendar.yaml
Requires: libdeclarative-organizer
Requires: mkcal >= 0.3.11
Requires: qt-components
Requires: qt5-qtdeclarative-pim-organizer
Requires: mkcal-qt5
Requires: qt-components-qt5
Requires: mapplauncherd-booster-qtcomponents-qt5
Requires: systemd
Requires(preun): systemd
Requires(post): systemd
Requires(postun): systemd
BuildRequires: pkgconfig(QtDeclarative)
BuildRequires: pkgconfig(QtOrganizer)
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5Organizer)
BuildRequires: pkgconfig(qdeclarative5-boostable)
BuildRequires: desktop-file-utils

%description
Calendar application written using QML.


%prep
%setup -q -n %{name}-%{version}

Expand All @@ -41,7 +44,7 @@ Calendar application written using QML.
# >> build pre
# << build pre

%qmake
%qmake5

make %{?jobs:-j%jobs}

Expand All @@ -52,7 +55,7 @@ make %{?jobs:-j%jobs}
rm -rf %{buildroot}
# >> install pre
# << install pre
%qmake_install
%qmake5_install

# >> install post
# << install post
Expand Down
18 changes: 11 additions & 7 deletions rpm/qmlcalendar.yaml
@@ -1,6 +1,6 @@
Name: qmlcalendar
Summary: Calendar application made with QML
Version: 0.2.0
Version: 0.3
Release: 1
Group: Applications/System
License: BSD
Expand All @@ -10,14 +10,18 @@ Sources:
Description: Calendar application written using QML.

PkgConfigBR:
- QtDeclarative
- QtOrganizer
- Qt5Core
- Qt5Quick
- Qt5Qml
- Qt5Organizer
- qdeclarative5-boostable
Requires:
- libdeclarative-organizer
- mkcal >= 0.3.11
- qt-components
- qt5-qtdeclarative-pim-organizer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libdeclarative-organizer is a Qt4 package. It's replaced by qt5-qtdeclarative-pim-organizer, so it should be removed.

- mkcal-qt5
- qt-components-qt5
- mapplauncherd-booster-qtcomponents-qt5
Configure: none
Builder: qmake
Builder: qmake5
Files:
- "/lib/systemd/system/calenderr.service"
- "/opt/%{name}"
Expand Down