KDEGames

KgItem.qml
1 /*
2  Copyright 2012 Viranch Mehta <[email protected]>
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 as published by
6  the Free Software Foundation, either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 import QtQuick 2.3
19 
20 Image {
21  // frontend sprite: shown after a rendered sprite is received
22  id: frontend
23 
24  property variant provider
25  property string spriteKey
26 
27  smooth: true
28 
29  Image {
30  // backend sprite: triggers requests for new sprite
31 
32  property alias prov: frontend.provider
33  property string provName: prov==undefined ? "" : prov.name
34  property string theme: prov==undefined ? "" : prov.currentThemeName
35  property alias key: frontend.spriteKey
36  property string size: Math.round(width)+"x"+Math.round(height)
37  property string sourceUrl: "image://"+provName+"/"+theme+"/"+key+"/"+size
38  source: prov==undefined || key=="" || width*height==0 ? "" : sourceUrl
39 
40  anchors.fill: parent
41  smooth: parent.smooth
42  cache: parent.cache
43  asynchronous: true
44  visible: false
45 
46  onStatusChanged: { // loads the sprite received from ImageProvider
47  if (status == Image.Ready) parent.source = source;
48  }
49  onSourceChanged: { // loads sprite from cache as status does not change in this case
50  if (status == Image.Ready) parent.source = source;
51  }
52  }
53 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Nov 26 2020 22:36:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.