Skip to content

Commit 9dc0e5f

Browse files
committed
1.2 new exchange sources, showDecimals & showBackground options
1 parent 0365655 commit 9dc0e5f

8 files changed

Lines changed: 87 additions & 4 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Use additional `-g` flag to install plasmoid globally, for all users.
1818
- Bitmaszyna.pl
1919
- BitBay
2020
- Blockchain.info
21+
- Bitfinex
22+
- Bitstamp
23+
- Kraken
24+
- GDAX
2125

2226
## Supported currencies
2327
- USD ($) - US Dollar
@@ -41,6 +45,11 @@ Use additional `-g` flag to install plasmoid globally, for all users.
4145

4246
## Changelog
4347

48+
### 1.2
49+
- Added new exchange sources: Bitfinex, Bitstamp, Kraken, GDAX
50+
- Added "Show decimals" option to show/hide decimals in the price
51+
- Added "Show background" option to show/hide plasmoid background on the desktop
52+
4453
### 1.1
4554
- Fixed displaying on panels (issue #1)
4655
- Added "Show text" option

bitcoin-price-config.png

8.79 KB
Loading

bitcoin-price.plasmoid

325 Bytes
Binary file not shown.

package/contents/code/bitcoin.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,42 @@ var sources = [
4444
return data.USD.last;
4545
}
4646
},
47+
{
48+
name: 'Bitfinex',
49+
url: 'https://api.bitfinex.com/v1/pubticker/btcusd',
50+
homepage: 'https://www.bitfinex.com/',
51+
currency: 'USD',
52+
getRate: function(data) {
53+
return data.ask;
54+
}
55+
},
56+
{
57+
name: 'Bitstamp',
58+
url: 'https://www.bitstamp.net/api/ticker',
59+
homepage: 'https://www.bitstamp.net/',
60+
currency: 'USD',
61+
getRate: function(data) {
62+
return data.ask;
63+
}
64+
},
65+
{
66+
name: 'Kraken',
67+
url: 'https://api.kraken.com/0/public/Ticker?pair=XXBTZUSD',
68+
homepage: 'https://www.kraken.com',
69+
currency: 'USD',
70+
getRate: function(data) {
71+
return data.result.XXBTZUSD.a[0];
72+
}
73+
},
74+
{
75+
name: 'GDAX',
76+
url: 'https://api-public.sandbox.gdax.com/products/BTC-USD/ticker',
77+
homepage: 'https://www.gdax.com/',
78+
currency: 'USD',
79+
getRate: function(data) {
80+
return data.ask;
81+
}
82+
},
4783
];
4884

4985
var currencyApiUrl = 'http://api.fixer.io';

package/contents/config/main.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,13 @@
2929
<label>On click</label>
3030
<default>refresh</default>
3131
</entry>
32+
<entry name="showDecimals" type="bool">
33+
<label>Show decimals</label>
34+
<default>true</default>
35+
</entry>
36+
<entry name="showBackground" type="bool">
37+
<label>Show background</label>
38+
<default>true</default>
39+
</entry>
3240
</group>
3341
</kcfg>

package/contents/ui/config/configGeneral.qml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Item {
1414
property alias cfg_refreshRate: refreshRate.value
1515
property alias cfg_showIcon: showIcon.checked
1616
property alias cfg_showText: showText.checked
17+
property alias cfg_showDecimals: showDecimals.checked
18+
property alias cfg_showBackground: showBackground.checked
1719
property variant sourceList: { Bitcoin.getAllSources() }
1820
property variant currencyList: { Bitcoin.getAllCurrencies() }
1921

@@ -104,14 +106,32 @@ Item {
104106
}
105107
}
106108

109+
Label {
110+
text: ""
111+
}
112+
113+
CheckBox {
114+
id: showDecimals
115+
text: i18n("Show decimals")
116+
}
117+
118+
Label {
119+
text: ""
120+
}
121+
122+
CheckBox {
123+
id: showBackground
124+
text: i18n("Show background")
125+
}
126+
107127
Label {
108128
text: i18n("On click:")
109129
}
110130

111131
ExclusiveGroup { id: clickGroup }
112132

113133
RadioButton {
114-
Layout.row: 5
134+
Layout.row: 7
115135
Layout.column: 1
116136
exclusiveGroup: clickGroup
117137
checked: cfg_onClickAction == 'refresh'
@@ -122,7 +142,7 @@ Item {
122142
}
123143

124144
RadioButton {
125-
Layout.row: 6
145+
Layout.row: 8
126146
Layout.column: 1
127147
exclusiveGroup: clickGroup
128148
checked: cfg_onClickAction == 'website'

package/contents/ui/main.qml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Item {
2222

2323
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
2424
Plasmoid.toolTipTextFormat: Text.RichText
25+
Plasmoid.backgroundHints: plasmoid.configuration.showBackground ? "StandardBackground" : "NoBackground"
2526

2627
Plasmoid.compactRepresentation: Item {
2728
property int textMargin: bitcoinIcon.height * 0.25
@@ -116,6 +117,9 @@ Item {
116117
onRefreshRateChanged: {
117118
bitcoinTimer.restart();
118119
}
120+
onShowDecimalsChanged: {
121+
bitcoinTimer.restart();
122+
}
119123
}
120124

121125
Timer {
@@ -128,7 +132,13 @@ Item {
128132
root.updatingRate = true;
129133

130134
var result = Bitcoin.getRate(plasmoid.configuration.source, plasmoid.configuration.currency, function(rate) {
131-
root.bitcoinRate = Number(rate).toLocaleCurrencyString(Qt.locale(), Bitcoin.currencySymbols[plasmoid.configuration.currency]);
135+
if(!plasmoid.configuration.showDecimals) rate = Math.floor(rate);
136+
137+
var rateText = Number(rate).toLocaleCurrencyString(Qt.locale(), Bitcoin.currencySymbols[plasmoid.configuration.currency]);
138+
139+
if(!plasmoid.configuration.showDecimals) rateText = rateText.replace(Qt.locale().decimalPoint + '00', '');
140+
141+
root.bitcoinRate = rateText;
132142

133143
var toolTipSubText = '<b>' + root.bitcoinRate + '</b>';
134144
toolTipSubText += '<br />';

package/metadata.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ServiceTypes=Plasma/Applet
1212

1313
X-KDE-PluginInfo-Author=Maciej Gierej
1414
X-KDE-PluginInfo-Email=makg@makg.eu
15-
X-KDE-PluginInfo-Version=1.1
15+
X-KDE-PluginInfo-Version=1.2
1616
X-KDE-PluginInfo-Website=http://maciej.gierej.pl
1717
X-KDE-PluginInfo-Category=Utilities
1818
X-KDE-PluginInfo-Depends=

0 commit comments

Comments
 (0)