diff --git a/harbour-batterybuddy.pro b/harbour-batterybuddy.pro index f4b63c9..7d6b82a 100644 --- a/harbour-batterybuddy.pro +++ b/harbour-batterybuddy.pro @@ -19,14 +19,13 @@ SOURCES += src/harbour-batterybuddy.cpp \ DISTFILES += qml/harbour-batterybuddy.qml \ qml/cover/CoverPage.qml \ - qml/pages/FirstPage.qml \ - qml/pages/SecondPage.qml \ rpm/harbour-batterybuddy.changes.in \ rpm/harbour-batterybuddy.changes.run.in \ rpm/harbour-batterybuddy.spec \ rpm/harbour-batterybuddy.yaml \ translations/*.ts \ - harbour-batterybuddy.desktop + harbour-batterybuddy.desktop \ + qml/pages/MainPage.qml SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172 diff --git a/qml/harbour-batterybuddy.qml b/qml/harbour-batterybuddy.qml index 829cf95..944e65e 100644 --- a/qml/harbour-batterybuddy.qml +++ b/qml/harbour-batterybuddy.qml @@ -4,7 +4,7 @@ import "pages" ApplicationWindow { - initialPage: Component { FirstPage { } } + initialPage: Component { MainPage { } } cover: Qt.resolvedUrl("cover/CoverPage.qml") allowedOrientations: defaultAllowedOrientations } diff --git a/qml/pages/FirstPage.qml b/qml/pages/MainPage.qml similarity index 57% rename from qml/pages/FirstPage.qml rename to qml/pages/MainPage.qml index 447accf..b539ae1 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/MainPage.qml @@ -11,14 +11,6 @@ Page { SilicaFlickable { anchors.fill: parent - // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView - PullDownMenu { - MenuItem { - text: qsTr("Show Page 2") - onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml")) - } - } - // Tell SilicaFlickable the height of its content. contentHeight: column.height @@ -30,13 +22,15 @@ Page { width: page.width spacing: Theme.paddingLarge PageHeader { - title: qsTr("UI Template") + title: qsTr("Battery Buddy") } - Label { - x: Theme.horizontalPageMargin - text: qsTr("Hello Sailors") - color: Theme.secondaryHighlightColor - font.pixelSize: Theme.fontSizeExtraLarge + DetailItem { + label: qsTr("Charge level") + value: battery.charge; + } + DetailItem { + label: qsTr("Charging") + value: battery.charging ? "yes" : "no"; } } } diff --git a/qml/pages/SecondPage.qml b/qml/pages/SecondPage.qml deleted file mode 100644 index 6dbadf4..0000000 --- a/qml/pages/SecondPage.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 -import Sailfish.Silica 1.0 - -Page { - id: page - - // The effective value will be restricted by ApplicationWindow.allowedOrientations - allowedOrientations: Orientation.All - - SilicaListView { - id: listView - model: 20 - anchors.fill: parent - header: PageHeader { - title: qsTr("Nested Page") - } - delegate: BackgroundItem { - id: delegate - - Label { - x: Theme.horizontalPageMargin - text: qsTr("Item") + " " + index - anchors.verticalCenter: parent.verticalCenter - color: delegate.highlighted ? Theme.highlightColor : Theme.primaryColor - } - onClicked: console.log("Clicked " + index) - } - VerticalScrollDecorator {} - } -} diff --git a/src/harbour-batterybuddy.cpp b/src/harbour-batterybuddy.cpp index 39d9995..66ded81 100644 --- a/src/harbour-batterybuddy.cpp +++ b/src/harbour-batterybuddy.cpp @@ -4,6 +4,13 @@ #include +#include +#include +#include +#include + +#include "battery.h" + int main(int argc, char *argv[]) { // SailfishApp::main() will display "qml/harbour-batterybuddy.qml", if you need more @@ -16,5 +23,14 @@ int main(int argc, char *argv[]) // // To display the view, call "show()" (will show fullscreen on device). - return SailfishApp::main(argc, argv); + QGuiApplication* app = SailfishApp::application(argc, argv); + QQuickView* view = SailfishApp::createView(); + + Battery battery; + view->engine()->addImportPath("/usr/share/harbour-carbudget/qml"); + view->rootContext()->setContextProperty("battery", &battery); + view->setSource(SailfishApp::pathTo("qml/harbour-batterybuddy.qml")); + view->showFullScreen(); + + return app->exec(); }