Skip to content

Commit

Permalink
Add new favorites screen in QML
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Nov 9, 2020
1 parent 15d8d64 commit 761202b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
41 changes: 41 additions & 0 deletions src/gui-qml/src/components/FavoritesScreen.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.12

Page {
id: root

signal openFavorite(string favorite)

property var favorites

header: ToolBar {
RowLayout {
anchors.fill: parent

ToolButton {
icon.source: "/images/icons/menu.png"
onClicked: drawer.open()
}

Label {
text: qsTr("Favorites")
elide: Label.ElideRight
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
}
}

ListView {
anchors.fill: parent
model: favorites

delegate: ItemDelegate {
width: parent.width
text: modelData

onClicked: root.openFavorite(modelData)
}
}
}
2 changes: 1 addition & 1 deletion src/gui-qml/src/components/MainDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Drawer {
page: "favorites"
name: qsTr("Favorites")
icon: "/images/icons/favorites.png"
enabled: false
enabled: true
}
ListElement {
page: "log"
Expand Down
13 changes: 13 additions & 0 deletions src/gui-qml/src/main-screen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ApplicationWindow {
id: mainScreen

SearchScreen {
id: searchScreen
visible: currentPage == "search"
anchors.fill: parent
site: window.site
Expand All @@ -86,6 +87,18 @@ ApplicationWindow {
onOpenSources: mainStackView.push(sourcesScreen)
}

FavoritesScreen {
id: favoritesScreen
visible: currentPage == "favorites"
anchors.fill: parent
favorites: backend.favorites

onOpenFavorite: {
searchScreen.load(favorite)
currentPage = "search"
}
}

LogScreen {
id: logScreen
visible: currentPage == "log"
Expand Down
1 change: 1 addition & 0 deletions src/gui-qml/src/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<file>components/ResultsView.qml</file>
<file>components/settings/pages/SourcesSettingsPage.qml</file>
<file>components/SearchEdit.qml</file>
<file>components/FavoritesScreen.qml</file>
</qresource>
</RCC>

0 comments on commit 761202b

Please sign in to comment.