| 1 |
/* |
| 2 |
* Copyright (C) 2012-2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License version 3 as |
| 6 |
* published by the Free Software Foundation. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Authors: |
| 17 |
* Eric Gregory <[email protected]> |
| 18 |
*/ |
| 19 |
|
| 20 |
import QtQuick 2.9 |
| 21 |
import Gallery 1.0 |
| 22 |
|
| 23 |
/*! |
| 24 |
*/ |
| 25 |
ListModel { |
| 26 |
id: albumCoverList |
| 27 |
|
| 28 |
// Returns an element given the nickname. |
| 29 |
function elementForCoverName(name) { |
| 30 |
// TODO: optimize. |
| 31 |
for (var i = 0; i < albumCoverList.count; i++) { |
| 32 |
if (albumCoverList.get(i).coverName === name) |
| 33 |
return albumCoverList.get(i); |
| 34 |
} |
| 35 |
|
| 36 |
return albumCoverList.get(0); // default |
| 37 |
} |
| 38 |
|
| 39 |
/*! |
| 40 |
*/ |
| 41 |
function getDefault() { |
| 42 |
return albumCoverList.get(0); |
| 43 |
} |
| 44 |
|
| 45 |
// A note about the image paths here: the imageFull and imagePreview images |
| 46 |
// are used in qml/Components/AlbumCover.qml (and the actual cover images are |
| 47 |
// only needed there, so they're in qml/Components/img). So, our path in |
| 48 |
// those cases is relative to the Components directory. However, the |
| 49 |
// iconFilename is actually used by qml/Capetown/Widgets/SomethingOrOther |
| 50 |
// (and thus its images live in the shared img directory). So, our path in |
| 51 |
// that case is relative to the Capetown Widgets directory. |
| 52 |
// TODO: fix this so images don't have such strict requirements; maybe make |
| 53 |
// a js utility function to give us the path to any image from wherever it's |
| 54 |
// being used. |
| 55 |
|
| 56 |
// First item in the list must be the default. |
| 57 |
ListElement { |
| 58 |
title: "" |
| 59 |
coverName: "default" |
| 60 |
imageFull: "img/album-cover-default-large.png" |
| 61 |
imagePreview: "img/album-cover-default.png" |
| 62 |
iconFilename: "../../img/album-cover-default-icon.png" |
| 63 |
addFilename: "img/album-add-default.png" |
| 64 |
hasBottomBorder: true |
| 65 |
} |
| 66 |
|
| 67 |
ListElement { |
| 68 |
title: "" |
| 69 |
coverName: "blue" |
| 70 |
imageFull: "img/album-cover-blue-large.png" |
| 71 |
imagePreview: "img/album-cover-blue.png" |
| 72 |
iconFilename: "../../img/album-cover-blue-icon.png" |
| 73 |
addFilename: "img/album-add-blue.png" |
| 74 |
hasBottomBorder: true |
| 75 |
} |
| 76 |
|
| 77 |
ListElement { |
| 78 |
title: "" |
| 79 |
coverName: "green" |
| 80 |
imageFull: "img/album-cover-green-large.png" |
| 81 |
imagePreview: "img/album-cover-green.png" |
| 82 |
iconFilename: "../../img/album-cover-green-icon.png" |
| 83 |
addFilename: "img/album-add-green.png" |
| 84 |
hasBottomBorder: true |
| 85 |
} |
| 86 |
|
| 87 |
ListElement { |
| 88 |
title: "" |
| 89 |
coverName: "pattern" |
| 90 |
imageFull: "img/album-cover-pattern-large.png" |
| 91 |
imagePreview: "img/album-cover-pattern.png" |
| 92 |
iconFilename: "../../img/album-cover-pattern-icon.png" |
| 93 |
addFilename: "img/album-add-pattern.png" |
| 94 |
hasBottomBorder: true |
| 95 |
} |
| 96 |
|
| 97 |
ListElement { |
| 98 |
title: "" |
| 99 |
coverName: "red" |
| 100 |
imageFull: "img/album-cover-red-large.png" |
| 101 |
imagePreview: "img/album-cover-red.png" |
| 102 |
iconFilename: "../../img/album-cover-red-icon.png" |
| 103 |
addFilename: "img/album-add-red.png" |
| 104 |
hasBottomBorder: true |
| 105 |
} |
| 106 |
|
| 107 |
Component.onCompleted: { |
| 108 |
// Script expressions are not allowed for the property values of a list element |
| 109 |
// The the translated titles are set here |
| 110 |
for (var i = 0; i < albumCoverList.count; i++) { |
| 111 |
var elem = albumCoverList. get(i); |
| 112 |
switch (i) { |
| 113 |
case 0: elem.title = i18n.tr("Default"); break; |
| 114 |
case 1: elem.title = i18n.tr("Blue"); break; |
| 115 |
case 2: elem.title = i18n.tr("Green"); break; |
| 116 |
case 3: elem.title = i18n.tr("Pattern"); break; |
| 117 |
case 4: elem.title = i18n.tr("Red"); break; |
| 118 |
default: elem.title = ""; |
| 119 |
} |
| 120 |
albumCoverList.set(i, elem); |
| 121 |
} |
| 122 |
} |
| 123 |
} |