forked from tbourvon/qml-material
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AwesomeIcon.qml
124 lines (111 loc) · 3.47 KB
/
AwesomeIcon.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* QML Material - An application framework implementing Material Design.
* Copyright (C) 2014 Michael Spencer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
View {
id: widget
property string name
property bool rotate: widget.name.match(/.*-rotate/) !== null
property alias color: text.color
property int size: units.dp(24)
color: "transparent"
width: text.width
height: text.height
property bool shadow: false
property var icons: {
"cube": "",
"cubes": "",
"power": "",
"shopping-cart": "",
"envelope-o": "",
"grid": "",
"check-circle": "",
"check-square-o": "",
"circle": "",
"exclamation-triangle": "",
"calendar": "",
"github": "",
"file": "",
"clock": "",
"bookmark-o": "",
"user": "",
"comments-o": "",
"check": "",
"ellipse-h": "",
"ellipse-v": "",
"save": "",
"smile-o": "",
"spinner": "",
"square-o": "",
"times": "",
"times-circle": "",
"plus": "",
"bell-o": "",
"bell": "",
"chevron-left": "",
"chevron-right": "",
"chevron-down": "",
"cog": "",
"minus": "",
"dashboard": "",
"calendar-empty": "",
"calendar": "",
"bars":"",
"inbox": "",
"list": "",
"long-list": "",
"comment": "",
"download": "",
"tasks": "",
"bug": "",
"code-fork": "",
"clock-o": "",
"pencil-square-o":"",
"check-square-o":"",
"picture-o":"",
"trash": "",
"code": "",
"users": "",
"exchange": "",
"star": "",
"star-o": ""
}
property alias weight: text.font.weight
FontLoader { id: fontAwesome; source: Qt.resolvedUrl("fonts/fontawesome/FontAwesome.otf") }
Text {
id: text
anchors.centerIn: parent
property string name: widget.name.match(/.*-rotate/) !== null ? widget.name.substring(0, widget.name.length - 7) : widget.name
font.family: fontAwesome.name
font.weight: Font.Light
text: widget.icons.hasOwnProperty(name) ? widget.icons[name] : ""
color: theme.blackColor('icon')
style: shadow ? Text.Raised : Text.Normal
styleColor: Qt.rgba(0,0,0,0.5)
font.pixelSize: widget.size
Behavior on color {
ColorAnimation { duration: 200 }
}
NumberAnimation on rotation {
running: widget.rotate
from: 0
to: 360
loops: Animation.Infinite
duration: 1100
}
}
}