11/***************************************************************************
2- * Copyright (C) %{CURRENT_YEAR} by %{AUTHOR} <%{EMAIL}> *
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, write to the *
16- * Free Software Foundation, Inc., *
17- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
2+ * Copyright (C) 2017 by MakG <makg@makg.eu> *
183 ***************************************************************************/
194
205import QtQuick 2.1
@@ -28,18 +13,31 @@ import "../code/bitcoin.js" as Bitcoin
2813Item {
2914 id: root
3015
31- width: units .gridUnit * 10
32- height: units .gridUnit * 2
16+ Layout .fillHeight : true
3317
3418 property string bitcoinRate: ' ...'
3519 property bool showIcon: plasmoid .configuration .showIcon
20+ property bool showText: plasmoid .configuration .showText
3621 property bool updatingRate: false
3722
3823 Plasmoid .preferredRepresentation : Plasmoid .compactRepresentation
3924 Plasmoid .toolTipTextFormat : Text .RichText
4025
4126 Plasmoid .compactRepresentation : Item {
42- Layout .fillWidth : true
27+ property int textMargin: bitcoinIcon .height * 0.25
28+ property int minWidth: {
29+ if (root .showIcon && root .showText ) {
30+ return bitcoinValue .paintedWidth + bitcoinIcon .width + textMargin;
31+ }
32+ else if (root .showIcon ) {
33+ return bitcoinIcon .width ;
34+ } else {
35+ return bitcoinValue .paintedWidth
36+ }
37+ }
38+
39+ Layout .fillWidth : false
40+ Layout .minimumWidth : minWidth
4341
4442 MouseArea {
4543 id: mouseArea
@@ -74,37 +72,28 @@ Item {
7472 anchors .top : parent .top
7573 anchors .left : parent .left
7674 anchors .topMargin : parent .height * 0.05
77- anchors .leftMargin : parent .height * 0.05
75+ anchors .leftMargin : root . showText ? parent .height * 0.05 : 0
7876
7977 source: " ../images/bitcoin.svg"
8078 visible: root .showIcon
8179 opacity: root .updatingRate ? 0.2 : mouseArea .containsMouse ? 0.8 : 1.0
82-
83- states: State {
84- name: " mouseover"
85- PropertyChanges { target: bitcoinIcon; opacity: 0.5 ; rotation: 180 }
86- }
87-
88- transitions: Transition {
89- from: " *" ; to: " mouseover"
90- NumberAnimation { properties: " opacity,rotation" ; easing .type : Easing .OutBounce ; duration: 2000 }
91- }
9280 }
9381
9482 PlasmaComponents .Label {
9583 id: bitcoinValue
9684 height: parent .height
9785 anchors .left : root .showIcon ? bitcoinIcon .right : parent .left
9886 anchors .right : parent .right
99- anchors .leftMargin : root .showIcon ? 10 : 0
87+ anchors .leftMargin : root .showIcon ? textMargin : 0
10088
10189 horizontalAlignment: root .showIcon ? Text .AlignLeft : Text .AlignHCenter
10290 verticalAlignment: Text .AlignVCenter
10391
92+ visible: root .showText
10493 opacity: root .updatingRate ? 0.2 : mouseArea .containsMouse ? 0.8 : 1.0
10594
10695 fontSizeMode: Text .Fit
107- minimumPixelSize: 10
96+ minimumPixelSize: bitcoinIcon . width * 0.7
10897 font .pixelSize : 72
10998 text: root .bitcoinRate
11099 }
0 commit comments