Message info
 
To:kde-commits@kde.org From:Aleix Pol Subject:[muon] /: Improve the support for displaying different app screenshots Date:Thu, 12 Apr 2012 17:42:37 +0200 (CEST)
 

Git commit 15bf974fa9e5d4b88f52df56d663e26c48ee6576 by Aleix Pol.
Committed on 12/04/2012 at 17:39.
Pushed by apol into branch 'master'.

Improve the support for displaying different app screenshots

Display the different available screenshots for a program
Make it possible to select which one to see

M +1 -0 libmuon/Application.h
M +30 -2 muon-mobile/qml/ApplicationOverview.qml
A +25 -0 muon-mobile/qml/ScreenshotsModel.qml [License: UNKNOWN] *
M +1 -0 muon-mobile/resources.qrc

The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


http://commits.kde.org/muon/15bf974fa9e5d4b88f52df56d663e26c48ee6576

diff --git a/libmuon/Application.h b/libmuon/Application.h
index b815ba2..d25a6a0 100644
--- a/libmuon/Application.h
+++ b/libmuon/Application.h
@@ -53,6 +53,7 @@ Q_PROPERTY(QString installedVersion READ installedVersion CONSTANT)
Q_PROPERTY(QString availableVersion READ availableVersion CONSTANT)
Q_PROPERTY(QString sizeDescription READ sizeDescription NOTIFY installChanged)
Q_PROPERTY(QString origin READ origin CONSTANT)
+Q_PROPERTY(QString packageName READ packageName CONSTANT)
Q_PROPERTY(bool isValid READ isValid CONSTANT)
Q_PROPERTY(bool isTechnical READ isTechnical CONSTANT)
Q_PROPERTY(bool isInstalled READ isInstalled NOTIFY installChanged)
diff --git a/muon-mobile/qml/ApplicationOverview.qml b/muon-mobile/qml/ApplicationOverview.qml
index 3cb90c2..dca9240 100644
--- a/muon-mobile/qml/ApplicationOverview.qml
+++ b/muon-mobile/qml/ApplicationOverview.qml
@@ -116,6 +116,7 @@ Item {

asynchronous: true
fillMode: Image.PreserveAspectFit
+ source: thumbnailsView.model.get(thumbnailsView.currentIndex).large_image_url

onStatusChanged: if(status==Image.Error) {
sourceSize.width = sourceSize.height = 200
@@ -130,7 +131,7 @@ Item {
PropertyChanges { target: shadow; height: parent.height }
PropertyChanges { target: shadow; x: 0 }
PropertyChanges { target: shadow; y: 5 }
- PropertyChanges { target: screenshot; source: application.screenshotUrl(0) }
+ PropertyChanges { target: thumbnailsView; opacity: 1 }
},
State { name: "full"
PropertyChanges { target: shadowItem; opacity: 0.7 }
@@ -139,7 +140,7 @@ Item {
PropertyChanges { target: shadow; height: appInfo.height }
PropertyChanges { target: shadow; width: appInfo.width }
PropertyChanges { target: shadow; z: 0 }
- PropertyChanges { target: screenshot; source: application.screenshotUrl(1) }
+ PropertyChanges { target: thumbnailsView; opacity: 0.3 }
}
]
Behavior on y { NumberAnimation { easing.type: Easing.OutQuad; duration: 500 } }
@@ -150,5 +151,32 @@ Item {
anchors.fill: parent
onClicked: { shadow.state = shadow.state == "thumbnail" ? "full" : "thumbnail" }
}
+
+ GridView {
+ id: thumbnailsView
+ cellHeight: 45
+ cellWidth: 45
+ interactive: false
+
+ anchors {
+ fill: shadow
+ bottomMargin: 5
+ }
+
+ model: ScreenshotsModel {
+ application: appInfo.application
+ }
+ highlight: Rectangle { color: "white"; opacity: 0.5 }
+
+ delegate: Image {
+ source: small_image_url
+ anchors.top: parent.top
+ height: 40; width: 40
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ MouseArea { anchors.fill: parent; onClicked: thumbnailsView.currentIndex=index}
+ }
+ Behavior on opacity { NumberAnimation { easing.type: Easing.OutQuad; duration: 500 } }
+ }
}
}
\ No newline at end of file
diff --git a/muon-mobile/qml/ScreenshotsModel.qml b/muon-mobile/qml/ScreenshotsModel.qml
new file mode 100644
index 0000000..13d8c1a
--- /dev/null
+++ b/muon-mobile/qml/ScreenshotsModel.qml
@@ -0,0 +1,25 @@
+import QtQuick 1.1
+
+ListModel {
+ id: model
+ property QtObject application
+ Component.onCompleted: {
+// if(application.screenshotUrl(0).indexOf("http://screenshots.debian.net")<0)
+// append({
+// 'small_image_url': application.screenshotUrl(0),
+// 'large_image_url': application.screenshotUrl(1)
+// })
+
+ var xhr = new XMLHttpRequest;
+ xhr.open("GET", "http://screenshots.debian.net/json/package/"+application.packageName);
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == XMLHttpRequest.DONE) {
+ var data = JSON.parse(xhr.responseText)
+ for(var app in data.screenshots) {
+ model.append(data.screenshots[app])
+ }
+ }
+ }
+ xhr.send();
+ }
+}
\ No newline at end of file
diff --git a/muon-mobile/resources.qrc b/muon-mobile/resources.qrc
index e161fe2..2572ea2 100644
--- a/muon-mobile/resources.qrc
+++ b/muon-mobile/resources.qrc
@@ -6,6 +6,7 @@
<file>qml/CategoryHeader.qml</file>
<file>qml/ApplicationsListPage.qml</file>
<file>qml/ApplicationPage.qml</file>
+ <file>qml/ScreenshotsModel.qml</file>
<file>qml/ReviewsView.qml</file>
<file>qml/ApplicationOverview.qml</file>
<file>qml/AddonsView.qml</file>