diff --git a/discover/qml/DiscoverWindow.qml b/discover/qml/DiscoverWindow.qml
index 426add84..106c9991 100644
--- a/discover/qml/DiscoverWindow.qml
+++ b/discover/qml/DiscoverWindow.qml
@@ -1,177 +1,176 @@
import QtQuick 2.1
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.1
import org.kde.discover 2.0
import org.kde.discover.app 1.0
import org.kde.kirigami 2.0 as Kirigami
import "navigation.js" as Navigation
Kirigami.ApplicationWindow
{
id: window
readonly property string applicationListComp: ("qrc:/qml/ApplicationsListPage.qml")
readonly property string applicationComp: ("qrc:/qml/ApplicationPage.qml")
readonly property string reviewsComp: ("qrc:/qml/ReviewsPage.qml")
//toplevels
readonly property string topBrowsingComp: ("qrc:/qml/BrowsingPage.qml")
readonly property string topInstalledComp: ("qrc:/qml/InstalledPage.qml")
readonly property string topUpdateComp: ("qrc:/qml/UpdatesPage.qml")
readonly property string topSourcesComp: ("qrc:/qml/SourcesPage.qml")
readonly property string loadingComponent: ("qrc:/qml/LoadingPage.qml")
readonly property QtObject stack: window.pageStack
property string currentTopLevel: defaultStartup ? topBrowsingComp : loadingComponent
property bool defaultStartup: true
- property bool navigationEnabled: true
objectName: "DiscoverMainWindow"
title: leftPage ? leftPage.title : ""
header: null
visible: true
minimumWidth: 300
minimumHeight: 300
pageStack.defaultColumnWidth: Kirigami.Units.gridUnit * 25
readonly property var leftPage: window.stack.depth>0 ? window.stack.get(0) : null
Component.onCompleted: {
Helpers.mainWindow = window
if (app.isRoot)
showPassiveNotification(i18n("Running as root is discouraged and unnecessary."));
}
TopLevelPageData {
iconName: "tools-wizard"
text: i18n("Discover")
component: topBrowsingComp
objectName: "discover"
shortcut: "Alt+D"
}
TopLevelPageData {
id: installedAction
text: i18n("Installed")
component: topInstalledComp
objectName: "installed"
shortcut: "Alt+I"
}
TopLevelPageData {
id: updateAction
iconName: enabled ? "update-low" : "update-none"
text: ResourcesModel.updatesCount<=0 ? (ResourcesModel.isFetching ? i18n("Checking for updates...") : i18n("No Updates") ) : i18nc("Update section name", "Update (%1)", ResourcesModel.updatesCount)
component: topUpdateComp
objectName: "update"
shortcut: "Alt+U"
}
TopLevelPageData {
id: settingsAction
iconName: "settings"
text: i18n("Settings")
component: topSourcesComp
objectName: "settings"
shortcut: "Alt+S"
}
Connections {
target: app
onOpenApplicationInternal: {
Navigation.clearStack()
Navigation.openApplication(app)
}
onOpenUrl: {
currentTopLevel = topBrowsingComp;
Navigation.openUrlResources(url)
}
onListMimeInternal: {
currentTopLevel = topBrowsingComp;
Navigation.openApplicationMime(mime)
}
onListCategoryInternal: {
currentTopLevel = topBrowsingComp;
Navigation.openCategory(cat, "")
}
onPreventedClose: showPassiveNotification(i18n("Could not close the application, there are tasks that need to be done."), 3000)
onUnableToFind: {
showPassiveNotification(i18n("Unable to find resource: %1", resid));
Navigation.openHome()
}
}
Connections {
target: ResourcesModel
onPassiveMessage: {
showPassiveNotification(message, 3000)
console.log("message:", message)
}
}
Component {
id: proceedDialog
Kirigami.OverlaySheet {
id: sheet
property QtObject transaction
property alias title: heading.text
property alias description: desc.text
property bool acted: false
ColumnLayout {
Kirigami.Heading {
id: heading
}
Kirigami.Label {
id: desc
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
Button {
Layout.alignment: Qt.AlignRight
iconName: "dialog-ok"
onClicked: {
transaction.proceed()
sheet.acted = true
sheet.close()
}
}
}
onSheetOpenChanged: if(!sheetOpen) {
sheet.destroy(1000)
if (!sheet.acted)
transaction.cancel()
}
}
}
Instantiator {
model: TransactionModel
delegate: Connections {
target: model.transaction ? model.transaction : null
onProceedRequest: {
var dialog = proceedDialog.createObject(window, {transaction: transaction, title: title, description: description})
dialog.open()
}
onPassiveMessage: {
window.showPassiveNotification(message)
}
}
}
globalDrawer: DiscoverDrawer {
focus: true
}
onCurrentTopLevelChanged: {
window.pageStack.clear()
if (currentTopLevel)
window.pageStack.push(currentTopLevel, {}, window.status!=Component.Ready)
}
UnityLauncher {
launcherId: "org.kde.discover.desktop"
progressVisible: TransactionModel.count > 0
progress: TransactionModel.progress
}
}
diff --git a/discover/qml/TopLevelPageData.qml b/discover/qml/TopLevelPageData.qml
index bac2b16f..60c0c127 100644
--- a/discover/qml/TopLevelPageData.qml
+++ b/discover/qml/TopLevelPageData.qml
@@ -1,33 +1,32 @@
/*
* Copyright (C) 2012 Aleix Pol Gonzalez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library/Lesser General Public License
* version 2, or (at your option) any later version, as published by the
* Free Software Foundation
*
* 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 Library/Lesser General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import org.kde.kirigami 2.0
import "navigation.js" as Navigation
Action {
property string component
checked: window.currentTopLevel==component
- enabled: window.navigationEnabled
onTriggered: {
if(window.currentTopLevel!=component)
window.currentTopLevel=component
}
}
diff --git a/discover/qml/UpdatesPage.qml b/discover/qml/UpdatesPage.qml
index 9ccfbed2..3f49c253 100644
--- a/discover/qml/UpdatesPage.qml
+++ b/discover/qml/UpdatesPage.qml
@@ -1,252 +1,250 @@
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import QtQuick 2.4
import org.kde.discover 2.0
import org.kde.discover.app 1.0
import org.kde.kquickcontrolsaddons 2.0
import org.kde.kcoreaddons 1.0
import "navigation.js" as Navigation
import org.kde.kirigami 2.0 as Kirigami
DiscoverPage
{
id: page
title: i18n("Updates")
function start() {
resourcesUpdatesModel.updateAll()
}
property string search: ""
property string footerLabel: ""
//TODO: use supportsRefreshing to fetch updates
mainItem: ListView
{
id: updatesView
currentIndex: -1
ResourcesUpdatesModel {
id: resourcesUpdatesModel
onIsProgressingChanged: {
- window.navigationEnabled = !isProgressing
-
if (!isProgressing) {
resourcesUpdatesModel.prepare()
}
}
Component.onCompleted: {
if (!isProgressing) {
resourcesUpdatesModel.prepare()
}
}
}
UpdateModel {
id: updateModel
backend: resourcesUpdatesModel
}
headerPositioning: ListView.OverlayHeader
header: PageHeader {
backgroundImage.source: "qrc:/banners/updatescrop.jpg"
extra: RowLayout {
id: updateControls
anchors.topMargin: Kirigami.Units.smallSpacing
Layout.fillWidth: true
visible: (updateModel.totalUpdatesCount > 0 && resourcesUpdatesModel.isProgressing) || updateModel.hasUpdates
LabelBackground {
Layout.leftMargin: Kirigami.Units.gridUnit
text: updateModel.toUpdateCount + " (" + updateModel.updateSize+")"
}
Label {
text: i18n("updates selected")
}
LabelBackground {
id: unselectedItem
readonly property int unselected: (updateModel.totalUpdatesCount - updateModel.toUpdateCount)
text: unselected
visible: unselected>0
}
Label {
text: i18n("updates not selected")
visible: unselectedItem.visible
}
Item { Layout.fillWidth: true}
Button {
Layout.minimumWidth: Kirigami.Units.gridUnit * 6
Layout.rightMargin: Kirigami.Units.gridUnit
text: unselectedItem.visible ? i18n("Update Selected") : i18n("Update All")
enabled: !resourcesUpdatesModel.isProgressing
onClicked: page.start()
}
}
}
footer: ColumnLayout {
anchors.right: parent.right
anchors.left: parent.left
Kirigami.Heading {
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
horizontalAlignment: Text.AlignHCenter
visible: page.footerLabel !== ""
text: page.footerLabel
}
Kirigami.Icon {
Layout.alignment: Qt.AlignHCenter
visible: page.footerLabel !== ""
source: "update-none"
opacity: 0.3
width: 200
height: 200
}
Item {
visible: page.footerLabel === ""
height: Kirigami.Units.gridUnit
width: 1
}
}
model: updateModel
section {
property: "section"
delegate: Kirigami.Heading {
x: Kirigami.Units.gridUnit
level: 2
text: section
}
}
spacing: Kirigami.Units.smallSpacing
delegate: Kirigami.AbstractListItem {
x: Kirigami.Units.gridUnit
width: ListView.view.width - Kirigami.Units.gridUnit * 2
highlighted: ListView.isCurrentItem || (page.search.length>0 && display.indexOf(page.search)>=0)
onEnabledChanged: if (!enabled) {
layout.extended = false;
}
Keys.onReturnPressed: {
itemChecked.clicked()
}
Keys.onPressed: if (event.key===Qt.Key_Alt) layout.extended = true
Keys.onReleased: if (event.key===Qt.Key_Alt) layout.extended = false
ColumnLayout {
id: layout
property bool extended: false
onExtendedChanged: if (extended) {
updateModel.fetchChangelog(index)
}
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
CheckBox {
id: itemChecked
anchors.verticalCenter: parent.verticalCenter
checked: model.checked == Qt.Checked
onClicked: model.checked = (model.checked==Qt.Checked ? Qt.Unchecked : Qt.Checked)
}
Kirigami.Icon {
Layout.fillHeight: true
Layout.preferredWidth: height
source: decoration
}
Label {
Layout.fillWidth: true
text: i18n("%1 (%2)", display, version)
elide: Text.ElideRight
}
LabelBackground {
Layout.minimumWidth: Kirigami.Units.gridUnit * 6
text: size
progress: resourceProgress/100
}
}
ScrollView {
id: view
Layout.fillHeight: true
Layout.fillWidth: true
frameVisible: true
visible: layout.extended && changelog.length>0
Label {
width: view.viewport.width
text: changelog
textFormat: Text.RichText
wrapMode: Text.WordWrap
onLinkActivated: Qt.openUrlExternally(link)
}
}
Button {
text: i18n("Open")
visible: layout.extended
enabled: !resourcesUpdatesModel.isProgressing
onClicked: Navigation.openApplication(resource)
}
}
onClicked: {
layout.extended = !layout.extended
}
}
}
readonly property alias secSinceUpdate: resourcesUpdatesModel.secsToLastUpdate
state: ( updateModel.hasUpdates ? "has-updates"
: resourcesUpdatesModel.isProgressing ? "progressing"
: secSinceUpdate < 0 ? "unknown"
: secSinceUpdate === 0 ? "now-uptodate"
: secSinceUpdate < 1000 * 60 * 60 * 24 ? "uptodate"
: secSinceUpdate < 1000 * 60 * 60 * 24 * 7 ? "medium"
: "low"
)
states: [
State {
name: "progressing"
PropertyChanges { target: page; title: i18nc("@info", "Updating...") }
PropertyChanges { target: page; footerLabel: resourcesUpdatesModel.progress<=0 ? i18nc("@info", "Fetching updates") : "" }
},
State {
name: "has-updates"
PropertyChanges { target: page; title: i18nc("@info", "Updates") }
},
State {
name: "now-uptodate"
PropertyChanges { target: page; title: i18nc("@info", "The system is up to date") }
PropertyChanges { target: page; footerLabel: i18nc("@info", "No updates") }
},
State {
name: "uptodate"
PropertyChanges { target: page; title: i18nc("@info", "The system is up to date") }
PropertyChanges { target: page; footerLabel: i18nc("@info", "No updates") }
},
State {
name: "medium"
PropertyChanges { target: page; title: i18nc("@info", "No updates are available") }
},
State {
name: "low"
PropertyChanges { target: page; title: i18nc("@info", "Should check for updates") }
},
State {
name: "unknown"
PropertyChanges { target: page; title: i18nc("@info", "It is unknown when the last check for updates was") }
}
]
}