Skip to content

Commit

Permalink
Merge pull request #200 from krnekhelesh/master
Browse files Browse the repository at this point in the history
[Ubuntu Touch] Minor UI Polish
  • Loading branch information
smurfy committed May 21, 2015
2 parents 868aff9 + ee0b44c commit b97a8aa
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 145 deletions.
1 change: 1 addition & 0 deletions data/fahrplan2_ubuntu.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Exec=./bin/fahrplan2
Icon=fahrplan2-square.svg
X-Ubuntu-Touch=true
X-Ubuntu-StageHint=SideStage
X-Ubuntu-Splash-Color=#F5F5F5
11 changes: 2 additions & 9 deletions src/gui/ubuntu/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ Page {

ListItems.Standard {
showDivider: false
height: units.gu(8)
Button {
id: timetableSearch

Expand Down Expand Up @@ -324,27 +325,19 @@ Page {
model: parserBackendModel
delegate: ListItems.Standard {
text: modelData

// FIXME: This is a workaround for the theme not being context sensitive. I.e. the
// ListItems don't know that they are sitting in a themed Popover where the color
// needs to be inverted.
__foregroundColor: Theme.palette.selected.backgroundText

onClicked: {
fahrplanBackend.setParser(index);
PopupUtils.close(selectBackendDialog)
}
}

},

Button {
text: "Close"
text: qsTr("Close")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: PopupUtils.close(selectBackendDialog)
}
]

}
}

Expand Down
214 changes: 79 additions & 135 deletions src/gui/ubuntu/components/StationSelect.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import QtQuick 2.3
import QtLocation 5.0
import QtPositioning 5.2
import Ubuntu.Components 1.1
import Ubuntu.Components.ListItems 0.1 as ListItems
import Ubuntu.Components.ListItems 1.0 as ListItems
import "."
import ".."

Expand All @@ -31,7 +31,7 @@ Page {

signal stationSelected ()
property int type: FahrplanBackend.DepartureStation
// property QtObject fahrplanBackend
// property QtObject fahrplanBackend

property bool showFavorites: true

Expand All @@ -41,162 +41,106 @@ Page {
onTriggered: {
stationSelect.showFavorites = !stationSelect.showFavorites
}
}
},

Action {
iconName: "location"
onTriggered: {
stationSelect.showFavorites = false;
positionSource.start();
indicator.running = true;
}
}
]

Item {
width: stationSelect.width
height: stationSelect.height
TextField {
id: search

Item {
id: search
anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(2) }
inputMethodHints: Qt.ImhNoPredictiveText

height: units.gu(7)
onTextChanged: searchTimer.restart();
Keys.onReturnPressed: search.findStationsByName();
Keys.onEnterPressed: search.findStationsByName();

anchors {
left: parent.left
right: parent.right
placeholderText: qsTr("Search for Station...")
secondaryItem: Icon {
width: height
height: parent.height - units.gu(2)
name: "find"
MouseArea {
anchors.fill: parent
onClicked: search.findStationsByName();
}
}

TextField {
id: searchBox
anchors {
left: parent.left
leftMargin: units.gu(1)
right: gpsButton.left
//right: parent.right
rightMargin: units.gu(1)
top: parent.top
topMargin: units.gu(1)
}
inputMethodHints: Qt.ImhNoPredictiveText

onTextChanged: searchTimer.restart();
Keys.onReturnPressed: search.findStationsByName();
Keys.onEnterPressed: search.findStationsByName();


placeholderText: qsTr("Search for Station...")
secondaryItem: [
Icon {
id: searchButton
height: parent.height - units.gu(1)
width: height
name: "find"
MouseArea {
anchors.fill: parent
onClicked: {
search.findStationsByName();
}
}
}
]
}
Timer {
id: searchTimer
interval: 500
onTriggered: search.findStationsByName();
}

Timer {
id: searchTimer
interval: 500
onTriggered: {
search.findStationsByName();
}
function findStationsByName()
{
if (search.text == "") {
stationSelect.showFavorites = true;
return;
}

function findStationsByName()
{
if (searchBox.text == "") {
stationSelect.showFavorites = true;
return;
}
if (searchTimer.running)
searchTimer.stop();

indicator.running = true;
stationSelect.showFavorites = false;
fahrplanBackend.findStationsByName(search.text);
}
}

if (searchTimer.running)
searchTimer.stop();
Label {
width: parent.width
wrapMode: Text.WordWrap
color: "DarkGrey"
fontSize: "large"
horizontalAlignment: Text.AlignHCenter
visible: fahrplanBackend.favorites.count == 0 && listView.model == fahrplanBackend.favorites
text: qsTr("Click the star icon on the search results to add or remove a station as a favorite")
anchors { top: search.bottom; bottom: parent.bottom; left: parent.left; right: parent.right; margins: units.gu(2) }
}

indicator.running = true;
stationSelect.showFavorites = false;
fahrplanBackend.findStationsByName(searchBox.text);
}
UbuntuListView {
id: listView

Button {
id: gpsButton
anchors {
right: parent.right
rightMargin: visible ? units.gu(1) : 0
top: parent.top
topMargin: units.gu(1)
}
iconName: "location"
width: visible ? height : 0
anchors { top: search.bottom; bottom: parent.bottom; margins: units.gu(1) }
clip: true
width: parent.width
model: stationSelect.showFavorites ? fahrplanBackend.favorites : fahrplanBackend.stationSearchResults

onClicked: {
stationSelect.showFavorites = false;
positionSource.start();
indicator.running = true;
}
}
}
delegate: ListItems.Standard {
id: delegateItem

Label {
width: parent.width
wrapMode: Text.WordWrap
height: parent.height - search.top
text: qsTr("Click the star icon on the search results to add or remove a station as a favorite");
color: "DarkGrey"
fontSize: "large"
visible: (fahrplanBackend.favorites.count == 0 && listView.model == fahrplanBackend.favorites)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors {
top: search.bottom
left: parent.left
leftMargin: units.gu(2)
right: parent.right
rightMargin: units.gu(2)
}
}
text: name
iconFrame: false
iconName: model.isFavorite ? "starred" : "non-starred"

ListView {
id: listView
anchors {
topMargin: units.gu(1)
top: search.bottom
bottomMargin: units.gu(1)
onClicked: {
listView.model.selectStation(stationSelect.type, model.index);
stationSelect.stationSelected()
}
height: parent.height
width: parent.width
model: stationSelect.showFavorites ? fahrplanBackend.favorites : fahrplanBackend.stationSearchResults
delegate: ListItems.Standard {
id: delegateItem
text: name
iconName: model.isFavorite ? "starred" : "non-starred"

onClicked: {
listView.model.selectStation(stationSelect.type, model.index);
stationSelect.stationSelected()
}
MouseArea {
anchors { top: parent.top; left: parent.left; leftMargin: units.gu(1); bottom: parent.bottom }
width: height

MouseArea {
anchors {
top: parent.top
left: parent.left
leftMargin: units.gu(1)
bottom: parent.bottom
}
width: height

onClicked: {
if (model.isFavorite) {
listView.model.removeFromFavorites(index);
delegateItem.iconName = "non-starred";
} else {
listView.model.addToFavorites(index);
delegateItem.iconName = "starred";
}
onClicked: {
if (model.isFavorite) {
listView.model.removeFromFavorites(index);
delegateItem.iconName = "non-starred";
} else {
listView.model.addToFavorites(index);
delegateItem.iconName = "starred";
}
}
}

clip: true
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/ubuntu/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ MainView {

width: units.gu(40); height: units.gu(71)
useDeprecatedToolbar: false
anchorToKeyboard: true

FahrplanBackend {
id: fahrplanBackend
Expand Down
1 change: 0 additions & 1 deletion ubuntu_res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<file>src/gui/ubuntu/AboutPage.qml</file>
<file>src/gui/ubuntu/TimeTableResultsPage.qml</file>
<file>src/gui/ubuntu/SettingsPage.qml</file>
<file>src/gui/ubuntu/components/Scroller.qml</file>
<file>src/gui/ubuntu/components/DatePicker.qml</file>
<file>src/gui/ubuntu/components/TimePicker.qml</file>
<file>src/gui/ubuntu/components/StationSelect.qml</file>
Expand Down

0 comments on commit b97a8aa

Please sign in to comment.