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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
|
// Copyright (c) 2014-2024, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.9
import QtQuick.Controls 2.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2
import FontAwesome 1.0
import "../components" as MoneroComponents
import "../components/effects/" as MoneroEffects
import moneroComponents.Clipboard 1.0
import moneroComponents.Wallet 1.0
import moneroComponents.WalletManager 1.0
import moneroComponents.TransactionHistory 1.0
import moneroComponents.TransactionHistoryModel 1.0
import "../js/TxUtils.js" as TxUtils
Rectangle {
id: pageAccount
color: "transparent"
property var model
property alias accountHeight: mainLayout.height
property alias balanceAllText: balanceAll.text
property alias unlockedBalanceAllText: unlockedBalanceAll.text
property bool selectAndSend: false
property int currentAccountIndex
function renameSubaddressAccountLabel(_index){
inputDialog.labelText = qsTr("Set the label of the selected account:") + translationManager.emptyString;
inputDialog.onAcceptedCallback = function() {
appWindow.currentWallet.setSubaddressLabel(_index, 0, inputDialog.inputText)
appWindow.currentWallet.subaddressAccount.refresh()
}
inputDialog.onRejectedCallback = null;
inputDialog.open(appWindow.currentWallet.getSubaddressLabel(_index, 0))
}
Clipboard { id: clipboard }
/* main layout */
ColumnLayout {
id: mainLayout
anchors.margins: 20
anchors.topMargin: 40
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
spacing: 20
ColumnLayout {
id: balanceRow
visible: !selectAndSend
spacing: 0
MoneroComponents.LabelSubheader {
Layout.fillWidth: true
fontSize: 24
textFormat: Text.RichText
text: qsTr("Balance All") + translationManager.emptyString
}
RowLayout {
Layout.topMargin: 22
MoneroComponents.TextPlain {
text: qsTr("Total balance: ") + translationManager.emptyString
Layout.fillWidth: true
color: MoneroComponents.Style.defaultFontColor
font.pixelSize: 16
font.family: MoneroComponents.Style.fontRegular.name
themeTransition: false
}
MoneroComponents.TextPlain {
id: balanceAll
Layout.rightMargin: 87
font.family: MoneroComponents.Style.fontMonoRegular.name;
font.pixelSize: 16
color: MoneroComponents.Style.defaultFontColor
MouseArea {
hoverEnabled: true
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onEntered: parent.color = MoneroComponents.Style.orange
onExited: parent.color = MoneroComponents.Style.defaultFontColor
onClicked: {
console.log("Copied to clipboard");
var balanceAllNumberOnly = parent.text.slice(0, -4);
clipboard.setText(balanceAllNumberOnly);
appWindow.showStatusMessage(qsTr("Copied to clipboard"),3)
}
}
}
}
RowLayout {
Layout.topMargin: 10
MoneroComponents.TextPlain {
text: qsTr("Total unlocked balance: ") + translationManager.emptyString
Layout.fillWidth: true
color: MoneroComponents.Style.defaultFontColor
font.pixelSize: 16
font.family: MoneroComponents.Style.fontRegular.name
themeTransition: false
}
MoneroComponents.TextPlain {
id: unlockedBalanceAll
Layout.rightMargin: 87
font.family: MoneroComponents.Style.fontMonoRegular.name;
font.pixelSize: 16
color: MoneroComponents.Style.defaultFontColor
MouseArea {
hoverEnabled: true
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onEntered: parent.color = MoneroComponents.Style.orange
onExited: parent.color = MoneroComponents.Style.defaultFontColor
onClicked: {
console.log("Copied to clipboard");
var unlockedBalanceAllNumberOnly = parent.text.slice(0, -4);
clipboard.setText(unlockedBalanceAllNumberOnly);
appWindow.showStatusMessage(qsTr("Copied to clipboard"),3)
}
}
}
}
}
ColumnLayout {
id: addressRow
spacing: 0
RowLayout {
spacing: 0
MoneroComponents.LabelSubheader {
Layout.fillWidth: true
fontSize: 24
textFormat: Text.RichText
text: qsTr("Accounts") + translationManager.emptyString
}
MoneroComponents.StandardButton {
id: createNewAccountButton
visible: !selectAndSend
small: true
text: qsTr("Create new account") + translationManager.emptyString
fontSize: 13
onClicked: {
inputDialog.labelText = qsTr("Set the label of the new account:") + translationManager.emptyString
inputDialog.onAcceptedCallback = function() {
appWindow.currentWallet.subaddressAccount.addRow(inputDialog.inputText)
appWindow.currentWallet.switchSubaddressAccount(appWindow.currentWallet.numSubaddressAccounts() - 1)
appWindow.onWalletUpdate();
}
inputDialog.onRejectedCallback = null;
inputDialog.open()
}
Rectangle {
anchors.top: createNewAccountButton.bottom
anchors.topMargin: 8
anchors.left: createNewAccountButton.left
anchors.right: createNewAccountButton.right
height: 2
color: MoneroComponents.Style.appWindowBorderColor
MoneroEffects.ColorTransition {
targetObj: parent
blackColor: MoneroComponents.Style._b_appWindowBorderColor
whiteColor: MoneroComponents.Style._w_appWindowBorderColor
}
}
}
}
ColumnLayout {
id: subaddressAccountListRow
property int subaddressAccountListItemHeight: 50
Layout.topMargin: 6
Layout.fillWidth: true
Layout.minimumWidth: 240
Layout.preferredHeight: subaddressAccountListItemHeight * subaddressAccountListView.count
visible: subaddressAccountListView.count >= 1
ListView {
id: subaddressAccountListView
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
boundsBehavior: ListView.StopAtBounds
interactive: false
currentIndex: currentAccountIndex
delegate: Rectangle {
id: tableItem2
height: subaddressAccountListRow.subaddressAccountListItemHeight
width: parent ? parent.width : undefined
Layout.fillWidth: true
color: itemMouseArea.containsMouse || index === currentAccountIndex ? MoneroComponents.Style.titleBarButtonHoverColor : "transparent"
Rectangle {
visible: index === currentAccountIndex
Layout.fillHeight: true
anchors.top: parent.top
anchors.bottom: parent.bottom
color: MoneroComponents.Style.accountColors[currentAccountIndex % MoneroComponents.Style.accountColors.length]
width: 2
}
Rectangle {
color: MoneroComponents.Style.appWindowBorderColor
anchors.right: parent.right
anchors.left: parent.left
anchors.top: parent.top
height: 1
visible: index !== 0
MoneroEffects.ColorTransition {
targetObj: parent
blackColor: MoneroComponents.Style._b_appWindowBorderColor
whiteColor: MoneroComponents.Style._w_appWindowBorderColor
}
}
Rectangle {
anchors.fill: parent
anchors.topMargin: 5
anchors.rightMargin: 80
color: "transparent"
MoneroComponents.Label {
id: idLabel
color: index === currentAccountIndex ? MoneroComponents.Style.defaultFontColor : "#757575"
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 6
fontSize: 16
text: "#" + index
themeTransition: false
}
MoneroComponents.Label {
id: nameLabel
color: index === currentAccountIndex ? MoneroComponents.Style.defaultFontColor : MoneroComponents.Style.dimmedFontColor
anchors.verticalCenter: parent.verticalCenter
anchors.left: idLabel.right
anchors.leftMargin: 6
fontSize: 16
text: label
elide: Text.ElideRight
textWidth: addressLabel.x - nameLabel.x - 1
themeTransition: false
}
MoneroComponents.Label {
id: addressLabel
color: MoneroComponents.Style.defaultFontColor
anchors.verticalCenter: parent.verticalCenter
anchors.left: balanceNumberLabel.left
anchors.leftMargin: -addressLabel.width - 30
fontSize: 16
fontFamily: MoneroComponents.Style.fontMonoRegular.name;
text: TxUtils.addressTruncatePretty(address, mainLayout.width < 740 ? 1 : (mainLayout.width < 900 ? 2 : 3))
themeTransition: false
}
MoneroComponents.Label {
id: balanceNumberLabel
color: MoneroComponents.Style.defaultFontColor
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.right
anchors.leftMargin: -balanceNumberLabel.width
fontSize: 16
fontFamily: MoneroComponents.Style.fontMonoRegular.name;
text: balance + " XMR"
elide: Text.ElideRight
textWidth: 180
themeTransition: false
}
MouseArea {
id: itemMouseArea
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onClicked: {
appWindow.currentWallet.switchSubaddressAccount(index);
if (selectAndSend)
appWindow.showPageRequest("Transfer");
}
}
}
RowLayout {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 6
height: 21
spacing: 10
MoneroComponents.IconButton {
id: renameButton
image: "qrc:///images/edit.svg"
fontAwesomeFallbackIcon: FontAwesome.edit
fontAwesomeFallbackSize: 22
color: MoneroComponents.Style.defaultFontColor
opacity: isOpenGL ? 0.5 : 1
fontAwesomeFallbackOpacity: 0.5
Layout.preferredWidth: 23
Layout.preferredHeight: 21
tooltip: qsTr("Edit account label") + translationManager.emptyString
onClicked: pageAccount.renameSubaddressAccountLabel(index);
}
MoneroComponents.IconButton {
id: copyButton
image: "qrc:///images/copy.svg"
fontAwesomeFallbackIcon: FontAwesome.clipboard
fontAwesomeFallbackSize: 22
color: MoneroComponents.Style.defaultFontColor
opacity: isOpenGL ? 0.5 : 1
fontAwesomeFallbackOpacity: 0.5
Layout.preferredWidth: 16
Layout.preferredHeight: 21
tooltip: qsTr("Copy address to clipboard") + translationManager.emptyString
onClicked: {
console.log("Address copied to clipboard");
clipboard.setText(address);
appWindow.showStatusMessage(qsTr("Address copied to clipboard"),3);
}
}
}
}
onCurrentIndexChanged: {
appWindow.onWalletUpdate();
}
}
}
Rectangle {
color: MoneroComponents.Style.appWindowBorderColor
Layout.fillWidth: true
height: 1
MoneroEffects.ColorTransition {
targetObj: parent
blackColor: MoneroComponents.Style._b_appWindowBorderColor
whiteColor: MoneroComponents.Style._w_appWindowBorderColor
}
}
}
}
function onPageCompleted() {
console.log("account");
if (appWindow.currentWallet !== undefined) {
appWindow.currentWallet.subaddressAccount.refresh();
subaddressAccountListView.model = appWindow.currentWallet.subaddressAccountModel;
appWindow.currentWallet.subaddress.refresh(appWindow.currentWallet.currentSubaddressAccount)
balanceAll.text = walletManager.displayAmount(appWindow.currentWallet.balanceAll()) + " XMR"
unlockedBalanceAll.text = walletManager.displayAmount(appWindow.currentWallet.unlockedBalanceAll()) + " XMR"
}
}
function onPageClosed() {
selectAndSend = false;
}
}
|