diff --git a/datalocation.h b/datalocation.h new file mode 100644 index 0000000..9afef96 --- /dev/null +++ b/datalocation.h @@ -0,0 +1,25 @@ +#ifndef DATALOCATION_H +#define DATALOCATION_H + +#include +#include +#include +#include + +class DataLocation : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString path READ path) +public: + DataLocation(QObject* parent = 0) { + QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + if (!dir.exists()) { + dir.mkpath("."); + } + } + QString path() const { + return QStandardPaths::writableLocation(QStandardPaths::DataLocation); + } +}; + +#endif // DATALOCATION_H diff --git a/harbour-lidderbuch.desktop b/harbour-lidderbuch.desktop old mode 100755 new mode 100644 index 8539e21..8ac6dd2 --- a/harbour-lidderbuch.desktop +++ b/harbour-lidderbuch.desktop @@ -3,11 +3,10 @@ Type=Application X-Nemo-Application-Type=silica-qt5 Icon=harbour-lidderbuch Exec=harbour-lidderbuch -Name=harbour-lidderbuch +Name=Lidderbuch # translation example: # your app name in German locale (de) # # Remember to comment out the following line, if you do not want to use # a different app name in German locale (de). -Name[de]=harbour-lidderbuch - +#Name[de]=Liederbuch diff --git a/harbour-lidderbuch.pro b/harbour-lidderbuch.pro old mode 100755 new mode 100644 index 2144026..6ab75ec --- a/harbour-lidderbuch.pro +++ b/harbour-lidderbuch.pro @@ -14,8 +14,7 @@ TARGET = harbour-lidderbuch CONFIG += sailfishapp -SOURCES += src/harbour-lidderbuch.cpp \ - src/acelapi.cpp +SOURCES += src/harbour-lidderbuch.cpp OTHER_FILES += qml/harbour-lidderbuch.qml \ qml/cover/CoverPage.qml \ @@ -38,9 +37,11 @@ CONFIG += sailfishapp_i18n # modify the localized app name in the the .desktop file. TRANSLATIONS += translations/harbour-lidderbuch-de.ts -HEADERS += \ - src/acelapi.h - DISTFILES += \ - qml/pages/SongList.qml + qml/pages/AboutPage.qml \ + qml/pages/SettingsPage.qml \ + qml/pages/SongModel.qml \ + qml/pages/SongPage.qml +HEADERS += \ + datalocation.h diff --git a/icons/108x108/harbour-lidderbuch.png b/icons/108x108/harbour-lidderbuch.png index 27b4092..2737829 100755 Binary files a/icons/108x108/harbour-lidderbuch.png and b/icons/108x108/harbour-lidderbuch.png differ diff --git a/icons/128x128/harbour-lidderbuch.png b/icons/128x128/harbour-lidderbuch.png index 45f1af3..b25b332 100755 Binary files a/icons/128x128/harbour-lidderbuch.png and b/icons/128x128/harbour-lidderbuch.png differ diff --git a/icons/256x256/harbour-lidderbuch.png b/icons/256x256/harbour-lidderbuch.png index 1b2032b..b436d29 100755 Binary files a/icons/256x256/harbour-lidderbuch.png and b/icons/256x256/harbour-lidderbuch.png differ diff --git a/icons/86x86/harbour-lidderbuch.png b/icons/86x86/harbour-lidderbuch.png old mode 100755 new mode 100644 index 428f1fe..ad316d6 Binary files a/icons/86x86/harbour-lidderbuch.png and b/icons/86x86/harbour-lidderbuch.png differ diff --git a/icons/86x86/harbout-lidderbuch.png b/icons/86x86/harbout-lidderbuch.png new file mode 100644 index 0000000..68c353d Binary files /dev/null and b/icons/86x86/harbout-lidderbuch.png differ diff --git a/icons/acel_logo.svg b/icons/acel_logo.svg new file mode 100644 index 0000000..7a8bad1 --- /dev/null +++ b/icons/acel_logo.svg @@ -0,0 +1,441 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/icon-launcher-lidderbuch.svg b/icons/icon-launcher-lidderbuch.svg new file mode 100644 index 0000000..4676340 --- /dev/null +++ b/icons/icon-launcher-lidderbuch.svg @@ -0,0 +1,170 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/jsonpath.js b/jsonpath.js new file mode 100644 index 0000000..1c4922e --- /dev/null +++ b/jsonpath.js @@ -0,0 +1,6 @@ + +.pragma library + +function func() { + +} diff --git a/qml/cover/CoverPage.qml b/qml/cover/CoverPage.qml index 786b78f..abf3b68 100755 --- a/qml/cover/CoverPage.qml +++ b/qml/cover/CoverPage.qml @@ -1,54 +1,36 @@ -/* - Copyright (C) 2013 Jolla Ltd. - Contact: Thomas Perl - All rights reserved. - - You may use this file under the terms of BSD license as follows: - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Jolla Ltd nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - import QtQuick 2.0 import Sailfish.Silica 1.0 CoverBackground { - Label { - id: label - anchors.centerIn: parent - text: qsTr("My Cover") + Column { + width: parent.width + spacing: Theme.paddingLarge + Image { + source: "acel_logo.png" + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 2*Theme.horizontalPageMargin + fillMode: Image.PreserveAspectFit + } + Label { + text: qsTr("ACEL") + width: parent.width + horizontalAlignment: Text.AlignHCenter + } + Label { + text: qsTr("Lidderbuch") + width: parent.width + horizontalAlignment: Text.AlignHCenter + } + } - CoverActionList { + /*CoverActionList { id: coverAction CoverAction { - iconSource: "image://theme/icon-cover-next" - } - - CoverAction { - iconSource: "image://theme/icon-cover-pause" + iconSource: "image://theme/icon-cover-search" } - } + }*/ } diff --git a/qml/cover/acel_logo.png b/qml/cover/acel_logo.png new file mode 100644 index 0000000..564710c Binary files /dev/null and b/qml/cover/acel_logo.png differ diff --git a/qml/harbour-lidderbuch.qml b/qml/harbour-lidderbuch.qml index 4b07414..05d56d0 100755 --- a/qml/harbour-lidderbuch.qml +++ b/qml/harbour-lidderbuch.qml @@ -1,43 +1,11 @@ -/* - Copyright (C) 2013 Jolla Ltd. - Contact: Thomas Perl - All rights reserved. - - You may use this file under the terms of BSD license as follows: - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Jolla Ltd nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - import QtQuick 2.0 import Sailfish.Silica 1.0 import "pages" ApplicationWindow { - initialPage: Component { SongList{ } } + initialPage: Component { FirstPage{ } } cover: Qt.resolvedUrl("cover/CoverPage.qml") allowedOrientations: Orientation.All _defaultPageOrientations: Orientation.All } - - diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml new file mode 100644 index 0000000..ab1566e --- /dev/null +++ b/qml/pages/AboutPage.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Page { + id: aboutPage + + SilicaFlickable { + anchors.fill: parent + contentHeight: column.height + + Column { + id: column + + width: parent.width + spacing: Theme.paddingLarge + + PageHeader { + //: Header of the About page + title: qsTr("Iwwer d'App") + } + + Label { + x: Theme.horizontalPageMargin + text: "© Scharel Clemens 2016" + } + Label { + x: Theme.horizontalPageMargin + text: "Content provided by ACEL" + } + } + + ScrollDecorator { } + } +} diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 14d7410..d6dd684 100755 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -1,73 +1,87 @@ -/* - Copyright (C) 2013 Jolla Ltd. - Contact: Thomas Perl - All rights reserved. - - You may use this file under the terms of BSD license as follows: - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Jolla Ltd nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - import QtQuick 2.0 import Sailfish.Silica 1.0 - Page { - id: page + id: songsPage - // To enable PullDownMenu, place our content in a SilicaFlickable - SilicaFlickable { + BusyIndicator { + id: busyIndicator + size: BusyIndicatorSize.Large + anchors.centerIn: parent + running: songModel.busy + } + + SilicaListView { anchors.fill: parent - // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView PullDownMenu { + busy: songModel.busy + MenuItem { + text: qsTr("Iwwer d'App") + onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml")) + } + MenuItem { + text: qsTr("Astellungen") + onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml")) + } MenuItem { - text: qsTr("Show Page 2") - onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml")) + text: qsTr("Aktualiséieren") + onClicked: songModel.update() } } - // Tell SilicaFlickable the height of its content. - contentHeight: column.height + header: PageHeader { + title: qsTr("ACEL Lidderbuch") + /*SearchField { + width: parent.width + placeholderText: qsTr("Songs") + enabled: !busyIndicator.running - // Place our content in a Column. The PageHeader is always placed at the top - // of the page, followed by our content. - Column { - id: column + onTextChanged: { + console.log("Search: " + text) + //songsModel.query = text !== "" ? "$.[?(@.name like '" + text + "')]" : "" + }*/ + } - width: page.width - spacing: Theme.paddingLarge - PageHeader { - title: qsTr("UI Template") - } - Label { - x: Theme.paddingLarge - text: qsTr("Hello Sailors") - color: Theme.secondaryHighlightColor - font.pixelSize: Theme.fontSizeExtraLarge + model: SongModel { + id: songModel + } + + delegate: ListItem { + id: song + width: parent.width + height: Theme.itemSizeSmall + onClicked: pageStack.push(Qt.resolvedUrl("SongPage.qml"), {song: model}) + + Row { + width: parent.width + spacing: Theme.paddingMedium + x: Theme.horizontalPageMargin + anchors.verticalCenter: parent.verticalCenter + Label { + id: songNumber + text: model.number + width: Theme.iconSizeSmall + color: song.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor + opacity: model.number === 0 ? 0 : 1 + } + + Label { + id: songName + text: model.name + width: parent.width - songNumber.x - songNumber.width + truncationMode: TruncationMode.Fade + color: song.highlighted ? Theme.highlightColor : Theme.primaryColor + } } } - } -} + section.property: "category" + section.criteria: ViewSection.FullString + section.delegate: SectionHeader { + text: section + } + VerticalScrollDecorator {} + } +} diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml new file mode 100644 index 0000000..fd21699 --- /dev/null +++ b/qml/pages/SettingsPage.qml @@ -0,0 +1,58 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import org.nemomobile.configuration 1.0 + +Page { + id: settingsPage + ConfigurationGroup { + id: appSettings + path: "/apps/harbour-lidderbuch/settings" + property int appLanguage + property int fontSize + } + + SilicaFlickable { + anchors.fill: parent + contentHeight: column.height + + Column { + id: column + + width: parent.width + //spacing: Theme.paddingLarge + + PageHeader { + //: Header of the settings page + title: qsTr("Astellungen") + } + + /*ComboBox { + label: qsTr("Language") + currentIndex: appSettings.appLanguage + + menu: ContextMenu { + MenuItem { text: qsTr("System") } + MenuItem { text: qsTr("L\u00ebtzebuergesch") } + MenuItem { text: qsTr("English") } + MenuItem { text: qsTr("Deutsch") } + MenuItem { text: qsTr("Francais") } + onActivated: appSettings.setValue("appLanguage", index) + } + }*/ + ComboBox { + label: qsTr("Schrëftgréisst") + currentIndex: appSettings.fontSize + + menu: ContextMenu { + MenuItem { text: qsTr("Kleng") } + MenuItem { text: qsTr("Mëttel") } + MenuItem { text: qsTr("Grouss") } + MenuItem { text: qsTr("Ech si voll") } + onActivated: appSettings.setValue("fontSize", index) + } + } + } + + ScrollDecorator { } + } +} diff --git a/qml/pages/SongList.qml b/qml/pages/SongList.qml deleted file mode 100755 index aef0aea..0000000 --- a/qml/pages/SongList.qml +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (C) 2013 Jolla Ltd. - Contact: Thomas Perl - All rights reserved. - - You may use this file under the terms of BSD license as follows: - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Jolla Ltd nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -import QtQuick 2.0 -import Sailfish.Silica 1.0 - - -Page { - id: page - SilicaListView { - id: songList - model: ListModel { - id: songModel - } - anchors.fill: parent - header: PageHeader { - title: qsTr("Songs") - } - delegate: BackgroundItem { - id: delegate - - Label { - x: Theme.paddingLarge - text: name - anchors.verticalCenter: parent.verticalCenter - color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor - } - onClicked: console.log("Clicked " + index) - } - VerticalScrollDecorator {} - } -} - - - - - diff --git a/qml/pages/SongModel.qml b/qml/pages/SongModel.qml new file mode 100644 index 0000000..fdb73ff --- /dev/null +++ b/qml/pages/SongModel.qml @@ -0,0 +1,57 @@ +import QtQuick 2.0 + +ListModel { + property string file: dataLocation.path + "/songs.json" + property string url: "https://acel.lu/api/v1/songs" + property string json: "" + property bool busy: false + onJsonChanged: parseJson() + + function parseJson() { + var songs = JSON.parse(json); + if (songs.errors !== undefined) { + console.log("Error fetching songs: " + songs.errors[0].message) + json = "" + } + else { + clear() + append(songs) + } + } + + function update() { + busy = true + var apiReq = new XMLHttpRequest + apiReq.open("GET", url) + apiReq.onreadystatechange = function() { + if (apiReq.readyState === XMLHttpRequest.DONE) { + console.log("Loaded songs from api") + json = apiReq.responseText + var filePut = new XMLHttpRequest + filePut.open("PUT", file) + filePut.send(json) + busy = false + } + } + apiReq.send() + } + + Component.onCompleted: { + busy = true + var fileReq = new XMLHttpRequest + fileReq.open("GET", file) + fileReq.onreadystatechange = function() { + if (fileReq.readyState === XMLHttpRequest.DONE) { + if (fileReq.responseText === "") { + update() + } + else { + console.log("Loaded songs from local file") + json = fileReq.responseText + busy = false + } + } + } + fileReq.send() + } +} diff --git a/qml/pages/SongPage.qml b/qml/pages/SongPage.qml new file mode 100644 index 0000000..cce9863 --- /dev/null +++ b/qml/pages/SongPage.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import org.nemomobile.configuration 1.0 + +Page { + id: songsPage + property var song + ConfigurationGroup { + id: appSettings + path: "/apps/harbour-lidderbuch/settings" + property int appLanguage + property int fontSize + } + + SilicaListView { + anchors.fill: parent + + /*PullDownMenu { + MenuItem { + text: qsTr("Details") + onClicked: pageStack.push(Qt.resolvedUrl("DetailsPage.qml")) + } + }*/ + + header: PageHeader { + title: song.name + } + + model: song.paragraphs + + delegate: Item { + width: parent.width + height: content.height + 2*Theme.paddingMedium + Text { + id: content + x: Theme.horizontalPageMargin + width: parent.width - x + color: Theme.primaryColor + font.family: Theme.fontFamily + font.pixelSize: (appSettings.fontSize === 0) ? Theme.fontSizeSmall : (appSettings.fontSize === 1) ? Theme.fontSizeMedium : (appSettings.fontSize === 2) ? Theme.fontSizeLarge : (appSettings.fontSize === 3) ? Theme.fontSizeExtraLarge : Theme.fontSizeMedium + wrapMode: Text.Wrap + text: model.content + } + } + + VerticalScrollDecorator {} + } +} diff --git a/rpm/harbour-lidderbuch.changes.in b/rpm/harbour-lidderbuch.changes.in old mode 100755 new mode 100644 index da71d15..b11def3 --- a/rpm/harbour-lidderbuch.changes.in +++ b/rpm/harbour-lidderbuch.changes.in @@ -12,4 +12,3 @@ - Scrubbed the deck - Hoisted the sails - diff --git a/rpm/harbour-lidderbuch.spec b/rpm/harbour-lidderbuch.spec old mode 100755 new mode 100644 index cf3e9dd..c63a65c --- a/rpm/harbour-lidderbuch.spec +++ b/rpm/harbour-lidderbuch.spec @@ -28,7 +28,7 @@ BuildRequires: pkgconfig(Qt5Quick) BuildRequires: desktop-file-utils %description -Short description of my SailfishOS Application +Short description of my Sailfish OS Application %prep diff --git a/rpm/harbour-lidderbuch.yaml b/rpm/harbour-lidderbuch.yaml old mode 100755 new mode 100644 index 91e18d0..891058c --- a/rpm/harbour-lidderbuch.yaml +++ b/rpm/harbour-lidderbuch.yaml @@ -12,7 +12,7 @@ License: LICENSE Sources: - '%{name}-%{version}.tar.bz2' Description: | - Short description of my SailfishOS Application + Short description of my Sailfish OS Application Configure: none # The qtc5 builder inserts macros to allow QtCreator to have fine # control over qmake/make execution @@ -43,4 +43,3 @@ Files: # For more information about yaml and what's supported in Sailfish OS # build system, please see https://wiki.merproject.org/wiki/Spectacle - diff --git a/src/acelapi.cpp b/src/acelapi.cpp deleted file mode 100755 index 1683252..0000000 --- a/src/acelapi.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "acelapi.h" - -#include -#include -#include -#include - -AcelApi::AcelApi(QObject *parent) : QObject(parent) -{ - acel = new QNetworkAccessManager(this); - connect(acel, SIGNAL(finished(QNetworkReply*)), this, SLOT(onFinish(QNetworkReply*))); - //connect(acel, SIGNAL(error(QNetworkReply*)), this, SLOT(onError(QNetworkReply*))); - //connect(acel, SIGNAL(abort(QNetworkReply*)), this, SLOT(onAbort(QNetworkReply*))); -} - -bool AcelApi::getEvents() { - qDebug() << "Requesing ACEL events"; - QNetworkRequest request(ACEL_EVENTS); - request.setHeader(QNetworkRequest::UserAgentHeader, "Acel Lidderbuch for SailfishOS - " + QGuiApplication::applicationVersion()); - QNetworkReply* reply = acel->get(request); - return true; -} - -bool AcelApi::getEvent(uint id) { - qDebug() << "Requesing ACEL event" << id << ACEL_EVENT(id); - QNetworkRequest request(ACEL_EVENT(id)); - request.setHeader(QNetworkRequest::UserAgentHeader, "Acel Lidderbuch for SailfishOS - " + QGuiApplication::applicationVersion()); - QNetworkReply* reply = acel->get(request); - return true; -} - -bool AcelApi::getSongs() { - qDebug() << "Requesing ACEL songs"; - QNetworkRequest request(ACEL_SONGS); - request.setHeader(QNetworkRequest::UserAgentHeader, "Acel Lidderbuch for SailfishOS - " + QGuiApplication::applicationVersion()); - QNetworkReply* reply = acel->get(request); - return true; -} - -bool AcelApi::getSong(uint id) { - qDebug() << "Requesing ACEL song" << id << ACEL_SONG(id); - QNetworkRequest request(ACEL_SONG(id)); - request.setHeader(QNetworkRequest::UserAgentHeader, "Acel Lidderbuch for SailfishOS - " + QGuiApplication::applicationVersion()); - QNetworkReply* reply = acel->get(request); - return true; -} - -void AcelApi::onFinish(QNetworkReply* reply) { - if (reply->error() == QNetworkReply::NoError) { - qDebug() << "Request finished"; - QByteArray data = reply->readAll(); - //qDebug() << data; - QJsonDocument doc = QJsonDocument::fromJson(data); //, QJsonDocument::BypassValidation); - if (doc.isNull()) - qDebug() << "Json Document is not valid!"; - QJsonArray json = doc.array(); - qDebug() << json.size() << "song entries"; - - QJsonArray::iterator it; - for (it = json.begin(); it != json.end(); it++) - { - QJsonValue song = *it; - if (song.isNull()) - qDebug() << "Json entry is not valid!"; - QJsonObject obj = song.toObject(); - uint position = obj.find("id").value().toInt(); - QString name = obj.find("name").value().toString(); - QString cat = obj.find("category").value().toString(); - qDebug() << obj.keys() << position << name << cat; - } - } - else { - qDebug() << "Error in request" << reply->url(); - } - reply->deleteLater(); -} - -void AcelApi::onError(QNetworkReply* reply) { - if (reply->error() == QNetworkReply::NoError) { - // TODO - } - reply->deleteLater(); -} - -void AcelApi::onAbort(QNetworkReply* reply) { - if (reply->error() == QNetworkReply::NoError) { - // TODO - } - reply->deleteLater(); -} - diff --git a/src/acelapi.h b/src/acelapi.h deleted file mode 100755 index 9d5efbd..0000000 --- a/src/acelapi.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef ACELAPI_H -#define ACELAPI_H - -#include -#include -#include -#include -#include -#include - -#define ACEL_EVENTS QUrl("https://dev.acel.lu/api/v1/events") -#define ACEL_EVENT(ID) QUrl(QString("https://dev.acel.lu/api/v1/events/%1").arg(ID)) -#define ACEL_SONGS QUrl("https://dev.acel.lu/api/v1/songs") -#define ACEL_SONG(ID) QUrl(QString("https://dev.acel.lu/api/v1/songs/%1").arg(ID)) - -class AcelApi : public QObject -{ - Q_OBJECT -public: - explicit AcelApi(QObject *parent = 0); - -signals: - -private: - QNetworkAccessManager *acel; - QNetworkReply *reply; - -private slots: - // when all data recieved - void onFinish(QNetworkReply*); - // when error occurred - void onError(QNetworkReply*); - // abort download and delete file - void onAbort(QNetworkReply*); - -public slots: - bool getEvents(); - bool getEvent(uint id); - - bool getSongs(); - bool getSong(uint id); -}; - -// TODO, see http://doc.qt.io/qt-5/qtquick-modelviewsdata-cppmodels.html -class SongsModel : public QAbstractTableModel -{ - Q_OBJECT -public: - SongsModel(QObject *parent = 0); - int rowCount() { return songs.length(); } - int columnCount() { return columns; } - data(); -private: - QList songs; - const int columns = 5; -}; - -#endif // ACELAPI_H diff --git a/src/harbour-lidderbuch.cpp b/src/harbour-lidderbuch.cpp index c4b5147..7ec26bb 100755 --- a/src/harbour-lidderbuch.cpp +++ b/src/harbour-lidderbuch.cpp @@ -1,61 +1,18 @@ -/* - Copyright (C) 2013 Jolla Ltd. - Contact: Thomas Perl - All rights reserved. - - You may use this file under the terms of BSD license as follows: - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Jolla Ltd nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR - ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef QT_QML_DEBUG -#include -#endif - #include -#include -#include "acelapi.h" +#include +#include +#include +#include "datalocation.h" int main(int argc, char *argv[]) { - QGuiApplication* app = SailfishApp::application(argc, argv); - app->setApplicationDisplayName("ACEL Lidderbuch"); - app->setApplicationName("harbour-lidderbuch"); - app->setApplicationVersion("0.1"); - app->setOrganizationDomain("https://github.com/scharel"); - app->setOrganizationName("harbour-lidderbuch"); - - qDebug() << app->applicationDisplayName() << app->applicationVersion(); + QScopedPointer app(SailfishApp::application(argc, argv)); + QScopedPointer view(SailfishApp::createView()); - QQuickView* view = SailfishApp::createView(); - AcelApi* api = new AcelApi(); - api->getSongs(); - QObject::connect(app, SIGNAL(aboutToQuit()), api, SLOT(deleteLater())); //abortAll())); + DataLocation dataLocation; + view->engine()->rootContext()->setContextProperty("dataLocation", &dataLocation); - //view->rootContext()->setContextProperty("settings", settings); - //view->rootContext()->setContextProperty("downloader", downloader); view->setSource(SailfishApp::pathTo("qml/harbour-lidderbuch.qml")); view->show(); - return app->exec(); } diff --git a/translations/harbour-lidderbuch-de.ts b/translations/harbour-lidderbuch-de.ts old mode 100755 new mode 100644 index 3d18887..6dcbac5 --- a/translations/harbour-lidderbuch-de.ts +++ b/translations/harbour-lidderbuch-de.ts @@ -1,32 +1,69 @@ + + AboutPage + + Iwwer d'App + Header of the About page + + + CoverPage - My Cover - Mein Cover + ACEL + + + + Lidderbuch + FirstPage - Show Page 2 - Zur Seite 2 + Iwwer d'App + - UI Template - UI-Vorlage + Astellungen + - Hello Sailors - Hallo Matrosen + Aktualiséieren + + + + ACEL Lidderbuch + - SongList + SettingsPage + + Astellungen + Header of the settings page + + + + Kleng + + + + Mëttel + + + + Grouss + + + + Ech si voll + + - Songs + Schrëftgréisst diff --git a/translations/harbour-lidderbuch.ts b/translations/harbour-lidderbuch.ts old mode 100755 new mode 100644 index ebba788..6dcbac5 --- a/translations/harbour-lidderbuch.ts +++ b/translations/harbour-lidderbuch.ts @@ -1,32 +1,69 @@ + + AboutPage + + Iwwer d'App + Header of the About page + + + CoverPage - My Cover + ACEL + + + + Lidderbuch FirstPage - Show Page 2 + Iwwer d'App + + + + Astellungen - UI Template + Aktualiséieren - Hello Sailors + ACEL Lidderbuch - SongList + SettingsPage + + Astellungen + Header of the settings page + + + + Kleng + + + + Mëttel + + + + Grouss + + + + Ech si voll + + - Songs + Schrëftgréisst