From: Thomas Perl Date: Wed, 11 Jan 2012 14:54:07 +0000 (+0100) Subject: Add About Box, restructure main toolbar X-Git-Url: https://vcs.maemo.org/git/?p=pywienerlinien;a=commitdiff_plain;h=70caee617339a9d947dd297da634564d5b21ad88 Add About Box, restructure main toolbar --- diff --git a/gotovienna-qml b/gotovienna-qml index 4c3491e..fd7b9a5 100755 --- a/gotovienna-qml +++ b/gotovienna-qml @@ -4,7 +4,7 @@ __author__ = 'kelvan ' __version__ = '0.9.0' -__website__ = 'https://github.com/kelvan/gotoVienna/' +__website__ = 'http://tinyurl.com/gotoVienna' __license__ = 'GNU General Public License v3 or later' from datetime import datetime @@ -23,6 +23,26 @@ import sys import threading from datetime import time +class AboutInfo(QObject): + def __init__(self): + QObject.__init__(self) + + @Slot(result=unicode) + def getAppName(self): + return u'gotoVienna %s' % __version__ + + @Slot(result=unicode) + def getWebsiteURL(self): + return __website__ + + @Slot(result=unicode) + def getCopyright(self): + return 'Copyright 2011, 2012 %s' % __author__ + + @Slot(result=unicode) + def getLicense(self): + return __license__ + class GotoViennaListModel(QAbstractListModel): def __init__(self, objects=None): QAbstractListModel.__init__(self) @@ -191,12 +211,15 @@ if __name__ == '__main__': view = QDeclarativeView() + aboutInfo = AboutInfo() + # instantiate the Python object itip = Gui() # expose the object to QML context = view.rootContext() context.setContextProperty('itip', itip) + context.setContextProperty('aboutInfo', aboutInfo) if os.path.abspath(__file__).startswith('/usr/bin/'): # Assume system-wide installation, QML from /usr/share/ diff --git a/images/gotovienna-about-logo.svg b/images/gotovienna-about-logo.svg new file mode 100644 index 0000000..a339892 --- /dev/null +++ b/images/gotovienna-about-logo.svg @@ -0,0 +1,411 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + goto + vienna + + + diff --git a/qml/AboutBox.qml b/qml/AboutBox.qml new file mode 100644 index 0000000..4500937 --- /dev/null +++ b/qml/AboutBox.qml @@ -0,0 +1,66 @@ + +import QtQuick 1.0 + +Rectangle { + id: aboutBox + property string appName: 'MyApp x.y.z' + property string websiteURL: 'http://example.org/' + property string copyright: '' + property string license: '' + property string iconFilename: '' + width: 480 + height: 800 + + function show() { opacity = 1 } + + color: '#dd000000' + opacity: 0 + Behavior on opacity { PropertyAnimation { } } + + MouseArea { + anchors.fill: parent + onClicked: aboutBox.opacity = 0 + } + + Column { + anchors.centerIn: parent + spacing: 5 + scale: Math.pow(parent.opacity, 3) + width: 440 + + Item { + height: aboutBoxIcon.sourceSize.height + width: parent.width + + Image { + id: aboutBoxIcon + anchors.centerIn: parent + source: aboutBox.iconFilename + } + } + + Text { + color: 'white' + font.pixelSize: 30 + font.bold: true + text: aboutBox.appName + anchors.horizontalCenter: parent.horizontalCenter + } + + Text { + color: 'white' + text: aboutBox.websiteURL + font.pixelSize: 25 + anchors.horizontalCenter: parent.horizontalCenter + } + + Text { + color: 'white' + font.pixelSize: 17 + text: '\n' + aboutBox.copyright + '\n' + aboutBox.license + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + } + } +} + diff --git a/qml/gotovienna-about-logo.png b/qml/gotovienna-about-logo.png new file mode 100644 index 0000000..847aee0 Binary files /dev/null and b/qml/gotovienna-about-logo.png differ diff --git a/qml/main.qml b/qml/main.qml index 36c80a2..0b34290 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -6,9 +6,21 @@ PageStackWindow { id: appWindow initialPage: mainPage + showToolBar: aboutBox.opacity == 0 MainPage { id: mainPage + + AboutBox { + id: aboutBox + anchors.fill: parent + + appName: aboutInfo.getAppName() + websiteURL: aboutInfo.getWebsiteURL() + copyright: aboutInfo.getCopyright() + license: aboutInfo.getLicense() + iconFilename: 'gotovienna-about-logo.png' + } } PositionSource { @@ -20,22 +32,16 @@ PageStackWindow { ToolBarLayout { id: commonTools - visible: true - /*ToolIcon { - platformIconId: "toolbar-view-menu" - anchors.right: (parent === undefined) ? undefined : parent.right - onClicked: (menu.status == DialogStatus.Closed) ? menu.open() : menu.close() - }*/ ToolIcon { - enabled: mainPage.canRefresh - platformIconId: enabled ? 'icon-m-toolbar-refresh' : 'icon-m-toolbar-refresh-dimmed' - anchors.right: parent.right - onClicked: mainPage.refresh() + platformIconId: "toolbar-view-menu" + anchors.right: parent.right + onClicked: menu.open() } ToolIcon { - platformIconId: enabled ? 'icon-m-toolbar-refresh' : 'icon-m-toolbar-refresh-dimmed' - anchors.right: parent.right + visible: mainPage.canRefresh + platformIconId: 'icon-m-toolbar-refresh' + anchors.centerIn: parent onClicked: mainPage.refresh() } @@ -44,21 +50,10 @@ PageStackWindow { source: 'logo.png' anchors { - bottomMargin: 10 - bottom: parent.bottom + verticalCenter: parent.verticalCenter left: parent.left leftMargin: 10 } - - MouseArea { - anchors.fill: parent - onClicked: { - //console.debug(itip.get_nearby_stations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude)) - //debugText.text = itip.get_nearby_stations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude) - //itip.load_nearby_departures(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude) - mainPage.showNearby() - } - } } Text { @@ -76,11 +71,18 @@ PageStackWindow { } } - /*Menu { + Menu { id: menu - visualParent: pageStack + MenuLayout { - MenuItem { text: "Test"; onClicked: pageStack.push(Qt.resolvedUrl("test.qml")) } + MenuItem { + text: 'Nearby stations' + onClicked: mainPage.showNearby() + } + MenuItem { + text: 'About gotoVienna' + onClicked: aboutBox.show() + } } - }*/ + } }