Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/NewStuffList.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | * later version accepted by the membership of KDE e.V. (or its | ||||
9 | * successor approved by the membership of KDE e.V.), which shall | ||||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | * | ||||
12 | * This library is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | * Lesser General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU Lesser General Public | ||||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | * | ||||
20 | */ | ||||
21 | | ||||
22 | import QtQuick 2.2 | ||||
23 | | ||||
24 | import org.kde.newstuff 1.0 as NewStuff | ||||
25 | | ||||
26 | /** | ||||
27 | * To use NewStuffList, simply instantiate it and pass the | ||||
28 | * local file location of a knsrc file to the configFile property. | ||||
29 | * The components will, in this case, take care of the rest for you. | ||||
30 | * If you want more, you can look at what NewStuffItem does with the | ||||
31 | * various bits, and be inspired by that. | ||||
32 | * | ||||
33 | * An (overly simple) example which might be used for managing | ||||
34 | * wallpapers and just outputting any messages onto the console can | ||||
35 | * be seen below. Note that you should obviously not be using | ||||
36 | * hardcoded paths, it is done here to get the idea across. | ||||
37 | * | ||||
38 | * \code | ||||
39 | NewStuff.NewStuffList { | ||||
40 | configFile: "/some/filesystem/location/wallpaper.knsrc"; | ||||
41 | onMessage: console.log("KNS Message: " + message); | ||||
42 | onIdleMessage: console.log("KNS Idle: " + message); | ||||
43 | onBusyMessage: console.log("KNS Busy: " + message); | ||||
44 | onErrorMessage: console.log("KNS Error: " + message); | ||||
45 | } | ||||
46 | \endcode | ||||
47 | */ | ||||
48 | ListView { | ||||
49 | id: root; | ||||
50 | /** | ||||
51 | * @brief The configuration file which describes the application (knsrc) | ||||
52 | * | ||||
53 | * The format and location of this file is found in the documentation for | ||||
54 | * KNS3::DownloadDialog | ||||
55 | */ | ||||
56 | property alias configFile: newStuffEngine.configFile; | ||||
57 | signal message(string message); | ||||
58 | signal idleMessage(string message); | ||||
59 | signal busyMessage(string message); | ||||
60 | signal errorMessage(string message); | ||||
61 | signal downloadedItemClicked(variant installedFiles); | ||||
62 | delegate: NewStuffItem { | ||||
63 | listModel: newStuffModel; | ||||
64 | onClicked: { | ||||
65 | if(model.status == NewStuff.ItemsModel.InstalledStatus) { | ||||
66 | root.downloadedItemClicked(model.installedFiles); | ||||
67 | } | ||||
68 | } | ||||
69 | } | ||||
70 | model: NewStuff.ItemsModel { | ||||
71 | id: newStuffModel; | ||||
72 | engine: newStuffEngine.engine; | ||||
73 | } | ||||
74 | NewStuff.Engine { | ||||
75 | id: newStuffEngine; | ||||
76 | onMessage: root.message(message); | ||||
77 | onIdleMessage: root.idleMessage(message); | ||||
78 | onBusyMessage: root.busyMessage(message); | ||||
79 | onErrorMessage: root.errorMessage(message); | ||||
80 | } | ||||
81 | } |