Skip to content

Commit

Permalink
feat(qml): add a sources page in the main drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Apr 20, 2024
1 parent 9065111 commit b4d707b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
6 changes: 6 additions & 0 deletions src/gui-qml/src/components/MainDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ Drawer {
icon: "/images/icons/favorites.png"
enabled: true
}
ListElement {
page: "sources"
name: qsTr("Sources")
icon: "/images/icons/cloud.png"
enabled: true
}
ListElement {
page: "log"
name: qsTr("Log")
Expand Down
23 changes: 11 additions & 12 deletions src/gui-qml/src/components/SearchScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,20 @@ Page {
onClicked: searchTab.openSources()
}

Rectangle {
Label {
text: pageLoader.status == TagSearchLoader.Ready
? (results
? qsTr("Page %1 of %2\n(%3 of %4)").arg(page).arg(pageLoader.pageCount).arg(results.length).arg(pageLoader.imageCount)
: qsTr("No result"))
: ''
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
rightPadding: sourcesButton.width
Layout.fillWidth: true
Layout.fillHeight: true
color: sourcesButton.background.color

Text {
anchors.fill: parent
text: pageLoader.status == TagSearchLoader.Ready
? (results
? qsTr("Page %1 of %2\n(%3 of %4)").arg(page).arg(pageLoader.pageCount).arg(results.length).arg(pageLoader.imageCount)
: qsTr("No result"))
: ''
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
rightPadding: sourcesButton.width
background: Rectangle {
color: sourcesButton.background.color
}
}

Expand Down
18 changes: 8 additions & 10 deletions src/gui-qml/src/components/SourcesScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import QtQuick.Layouts 1.12
Page {
id: root

signal accepted(string source)
signal rejected()
signal back()
signal addSource()
signal editSource(var source)

Expand All @@ -18,8 +17,14 @@ Page {
anchors.fill: parent

ToolButton {
visible: mainStackView.depth > 1
icon.source: "/images/icons/back.png"
onClicked: root.accepted(buttonGroup.checkedButton.url)
onClicked: root.back()
}
ToolButton {
visible: mainStackView.depth <= 1
icon.source: "/images/icons/menu.png"
onClicked: drawer.open()
}

Label {
Expand Down Expand Up @@ -76,11 +81,4 @@ Page {
}
}
}

Keys.onReleased: {
if (event.key === Qt.Key_Back || event.key === Qt.Key_Escape) {
root.accepted(buttonGroup.checkedButton.url)
event.accepted = true
}
}
}
12 changes: 12 additions & 0 deletions src/gui-qml/src/main-screen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ ApplicationWindow {
}
}

SourcesScreen {
visible: currentPage == "sources"
anchors.fill: parent
sources: backend.sites
activeSource: gSettings.activeSource.value

onActiveSourceChanged: { gSettings.activeSource.setValue(activeSource); }
onBack: mainStackView.pop()
onAddSource: mainStackView.push(addSourceScreen)
onEditSource: mainStackView.push(editSourceScreen, { site: activeSource })
}

LogScreen {
id: logScreen
visible: currentPage == "log"
Expand Down

0 comments on commit b4d707b

Please sign in to comment.