Refactor qml
This commit is contained in:
parent
7ffcae3dd2
commit
7a2a677049
55
src/qml/AddFeedSheet.qml
Normal file
55
src/qml/AddFeedSheet.qml
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright 2020 Tobias Fella <fella@posteo.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14 as Controls
|
||||
import QtQuick.Layouts 1.14
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
|
||||
import org.kde.alligator 1.0
|
||||
|
||||
Kirigami.OverlaySheet {
|
||||
id: addSheet
|
||||
parent: applicationWindow().overlay
|
||||
header: Kirigami.Heading {
|
||||
text: i18n("Add new Feed")
|
||||
}
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
Controls.Label {
|
||||
text: i18n("Url:")
|
||||
}
|
||||
Controls.TextField {
|
||||
id: urlField
|
||||
Layout.fillWidth: true
|
||||
text: "https://planet.kde.org/global/atom.xml/"
|
||||
}
|
||||
}
|
||||
|
||||
footer: Controls.Button {
|
||||
text: i18n("Add Feed")
|
||||
enabled: urlField.text
|
||||
onClicked: {
|
||||
Database.addFeed(urlField.text)
|
||||
addSheet.close()
|
||||
}
|
||||
}
|
||||
}
|
54
src/qml/EntryListDelegate.qml
Normal file
54
src/qml/EntryListDelegate.qml
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright 2020 Tobias Fella <fella@posteo.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14 as Controls
|
||||
import QtQuick.Layouts 1.14
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
|
||||
import org.kde.alligator 1.0
|
||||
|
||||
Kirigami.SwipeListItem {
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Controls.Label {
|
||||
text: model.entry.title
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
opacity: 1
|
||||
}
|
||||
Controls.Label {
|
||||
id: subtitleItem
|
||||
text: model.entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (model.entry.authors.length === 0 ? "" : " " + i18nc("by <author(s)>", "by") + " " + model.entry.authors[0].name)
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
font: Kirigami.Theme.smallFont
|
||||
opacity: 0.6
|
||||
visible: text.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
pageStack.push("qrc:/EntryPage.qml", {"entry": model.entry})
|
||||
}
|
||||
}
|
52
src/qml/EntryListHeader.qml
Normal file
52
src/qml/EntryListHeader.qml
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright 2020 Tobias Fella <fella@posteo.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14 as Controls
|
||||
import QtQuick.Layouts 1.14
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
|
||||
import org.kde.alligator 1.0
|
||||
|
||||
RowLayout {
|
||||
width: parent.width
|
||||
height: root.height * 0.2
|
||||
Item {
|
||||
id: icon
|
||||
width: height
|
||||
height: parent.height
|
||||
Kirigami.Icon {
|
||||
source: Fetcher.image(page.feed.image)
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: !busy.visible
|
||||
}
|
||||
Controls.BusyIndicator {
|
||||
id: busy
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: page.feed.refreshing
|
||||
}
|
||||
}
|
||||
Kirigami.Heading {
|
||||
text: page.feed.name
|
||||
}
|
||||
}
|
@ -73,57 +73,8 @@ Kirigami.ScrollablePage {
|
||||
feed: page.feed
|
||||
}
|
||||
|
||||
header: RowLayout {
|
||||
width: parent.width
|
||||
height: root.height * 0.2
|
||||
visible: !all
|
||||
Item {
|
||||
id: icon
|
||||
width: height
|
||||
height: parent.height
|
||||
Kirigami.Icon {
|
||||
source: Fetcher.image(page.feed.image)
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: !busy.visible
|
||||
}
|
||||
Controls.BusyIndicator {
|
||||
id: busy
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: page.feed.refreshing
|
||||
}
|
||||
}
|
||||
Kirigami.Heading {
|
||||
text: page.feed.name
|
||||
}
|
||||
}
|
||||
header: EntryListHeader { }
|
||||
|
||||
delegate: Kirigami.SwipeListItem {
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Controls.Label {
|
||||
text: model.entry.title
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
opacity: 1
|
||||
}
|
||||
Controls.Label {
|
||||
id: subtitleItem
|
||||
text: model.entry.updated.toLocaleString(Qt.locale(), Locale.ShortFormat) + (model.entry.authors.length === 0 ? "" : " " + i18nc("by <author(s)>", "by") + " " + model.entry.authors[0].name)
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
font: Kirigami.Theme.smallFont
|
||||
opacity: 0.6
|
||||
visible: text.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
pageStack.push("qrc:/EntryPage.qml", {"entry": model.entry})
|
||||
}
|
||||
}
|
||||
delegate: EntryListDelegate { }
|
||||
}
|
||||
}
|
||||
|
74
src/qml/FeedListDelegate.qml
Normal file
74
src/qml/FeedListDelegate.qml
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright 2020 Tobias Fella <fella@posteo.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License or (at your option) version 3 or any later version
|
||||
* accepted by the membership of KDE e.V. (or its successor approved
|
||||
* by the membership of KDE e.V.), which shall act as a proxy
|
||||
* defined in Section 14 of version 3 of the license.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.14
|
||||
import QtQuick.Controls 2.14 as Controls
|
||||
import QtQuick.Layouts 1.14
|
||||
|
||||
import org.kde.kirigami 2.12 as Kirigami
|
||||
|
||||
import org.kde.alligator 1.0
|
||||
|
||||
Kirigami.SwipeListItem {
|
||||
height: Kirigami.Units.gridUnit*2
|
||||
|
||||
Item {
|
||||
Item {
|
||||
id: icon
|
||||
width: height
|
||||
height: parent.height
|
||||
Kirigami.Icon {
|
||||
source: Fetcher.image(model.feed.image)
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: !busy.visible
|
||||
}
|
||||
Controls.BusyIndicator {
|
||||
id: busy
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: model.feed.refreshing
|
||||
}
|
||||
}
|
||||
Controls.Label {
|
||||
text: model.feed.name
|
||||
height: parent.height
|
||||
anchors.left: icon.right
|
||||
leftPadding: 0.5*Kirigami.Units.gridUnit
|
||||
}
|
||||
}
|
||||
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
icon.name: "delete"
|
||||
onTriggered: {
|
||||
if(pageStack.depth > 1 && model.feed.url === lastFeed)
|
||||
pageStack.pop()
|
||||
feedListModel.removeFeed(index)
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
onClicked: {
|
||||
lastFeed = model.feed.url
|
||||
pageStack.push("qrc:/EntryListPage.qml", {"feed": model.feed})
|
||||
}
|
||||
}
|
@ -47,39 +47,15 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
]
|
||||
|
||||
actions.main: Kirigami.Action {
|
||||
text: i18n("Add feed")
|
||||
iconName: "list-add"
|
||||
onTriggered: {
|
||||
addSheet.open()
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.OverlaySheet {
|
||||
AddFeedSheet {
|
||||
id: addSheet
|
||||
parent: applicationWindow().overlay
|
||||
header: Kirigami.Heading {
|
||||
text: i18n("Add new Feed")
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
Controls.Label {
|
||||
text: i18n("Url:")
|
||||
}
|
||||
Controls.TextField {
|
||||
id: urlField
|
||||
Layout.fillWidth: true
|
||||
text: "https://planet.kde.org/global/atom.xml/"
|
||||
}
|
||||
}
|
||||
|
||||
footer: Controls.Button {
|
||||
text: i18n("Add Feed")
|
||||
enabled: urlField.text
|
||||
onClicked: {
|
||||
Database.addFeed(urlField.text)
|
||||
addSheet.close()
|
||||
}
|
||||
actions.main: Kirigami.Action {
|
||||
text: i18n("Add feed")
|
||||
iconName: "list-add"
|
||||
onTriggered: {
|
||||
addSheet.open()
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,51 +76,6 @@ Kirigami.ScrollablePage {
|
||||
id: feedListModel
|
||||
}
|
||||
|
||||
delegate: Kirigami.SwipeListItem {
|
||||
height: Kirigami.Units.gridUnit*2
|
||||
|
||||
Item {
|
||||
Item {
|
||||
id: icon
|
||||
width: height
|
||||
height: parent.height
|
||||
Kirigami.Icon {
|
||||
source: Fetcher.image(model.feed.image)
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: !busy.visible
|
||||
}
|
||||
Controls.BusyIndicator {
|
||||
id: busy
|
||||
width: height
|
||||
height: parent.height
|
||||
visible: model.feed.refreshing
|
||||
}
|
||||
}
|
||||
Controls.Label {
|
||||
text: model.feed.name
|
||||
height: parent.height
|
||||
anchors.left: icon.right
|
||||
leftPadding: 0.5*Kirigami.Units.gridUnit
|
||||
}
|
||||
}
|
||||
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
icon.name: "delete"
|
||||
onTriggered: {
|
||||
if(pageStack.depth > 1 && model.feed.url === lastFeed)
|
||||
pageStack.pop()
|
||||
feedListModel.removeFeed(index)
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
onClicked: {
|
||||
lastFeed = model.feed.url
|
||||
pageStack.push("qrc:/EntryListPage.qml", {"feed": model.feed})
|
||||
}
|
||||
}
|
||||
delegate: FeedListDelegate { }
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,10 @@
|
||||
<file alias="EntryPage.qml">qml/EntryPage.qml</file>
|
||||
<file alias="SettingsPage.qml">qml/SettingsPage.qml</file>
|
||||
<file alias="FeedDetailsPage.qml">qml/FeedDetailsPage.qml</file>
|
||||
<file alias="EntryListHeader.qml">qml/EntryListHeader.qml</file>
|
||||
<file alias="EntryListDelegate.qml">qml/EntryListDelegate.qml</file>
|
||||
<file alias="AddFeedSheet.qml">qml/AddFeedSheet.qml</file>
|
||||
<file alias="FeedListDelegate.qml">qml/FeedListDelegate.qml</file>
|
||||
<file>qtquickcontrols2.conf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user