Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
c10f6110
Commit
c10f6110
authored
10 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
Add new wallet in wallets context menu
parent
9655c216
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cutecoin/core/app.py
+20
-6
20 additions, 6 deletions
src/cutecoin/core/app.py
src/cutecoin/gui/mainwindow.py
+1
-1
1 addition, 1 deletion
src/cutecoin/gui/mainwindow.py
src/cutecoin/gui/wallets_tab.py
+33
-3
33 additions, 3 deletions
src/cutecoin/gui/wallets_tab.py
with
54 additions
and
10 deletions
src/cutecoin/core/app.py
+
20
−
6
View file @
c10f6110
...
@@ -239,17 +239,17 @@ class Application(QObject):
...
@@ -239,17 +239,17 @@ class Application(QObject):
data
[
'
version
'
]
=
__version__
data
[
'
version
'
]
=
__version__
json
.
dump
(
data
,
outfile
,
indent
=
4
,
sort_keys
=
True
)
json
.
dump
(
data
,
outfile
,
indent
=
4
,
sort_keys
=
True
)
def
save_
cache
(
self
,
account
):
def
save_
wallet
(
self
,
account
,
wallet
):
'''
"""
Save
the cache
of
an
account
Save
wallet
of account
in cache
:param account: The account object to save the cache
:param cutecoin.core.account.Account account: Account instance
'''
:param cutecoin.core.wallet.Wallet wallet: Wallet instance
"""
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
account
.
name
,
'
__cache__
'
)):
account
.
name
,
'
__cache__
'
)):
os
.
makedirs
(
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
os
.
makedirs
(
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
account
.
name
,
'
__cache__
'
))
account
.
name
,
'
__cache__
'
))
for
wallet
in
account
.
wallets
:
wallet_path
=
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
wallet_path
=
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
account
.
name
,
'
__cache__
'
,
wallet
.
pubkey
)
account
.
name
,
'
__cache__
'
,
wallet
.
pubkey
)
with
open
(
wallet_path
,
'
w
'
)
as
outfile
:
with
open
(
wallet_path
,
'
w
'
)
as
outfile
:
...
@@ -257,6 +257,19 @@ class Application(QObject):
...
@@ -257,6 +257,19 @@ class Application(QObject):
data
[
'
version
'
]
=
__version__
data
[
'
version
'
]
=
__version__
json
.
dump
(
data
,
outfile
,
indent
=
4
,
sort_keys
=
True
)
json
.
dump
(
data
,
outfile
,
indent
=
4
,
sort_keys
=
True
)
def
save_cache
(
self
,
account
):
'''
Save the cache of an account
:param account: The account object to save the cache
'''
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
account
.
name
,
'
__cache__
'
)):
os
.
makedirs
(
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
account
.
name
,
'
__cache__
'
))
for
wallet
in
account
.
wallets
:
self
.
save_wallet
(
account
,
wallet
)
for
community
in
account
.
communities
:
for
community
in
account
.
communities
:
community_path
=
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
community_path
=
os
.
path
.
join
(
config
.
parameters
[
'
home
'
],
account
.
name
,
'
__cache__
'
,
account
.
name
,
'
__cache__
'
,
...
@@ -267,6 +280,7 @@ class Application(QObject):
...
@@ -267,6 +280,7 @@ class Application(QObject):
community
.
currency
+
'
_network
'
)
community
.
currency
+
'
_network
'
)
with
open
(
network_path
,
'
w
'
)
as
outfile
:
with
open
(
network_path
,
'
w
'
)
as
outfile
:
data
=
dict
()
data
[
'
network
'
]
=
community
.
jsonify_network
()
data
[
'
network
'
]
=
community
.
jsonify_network
()
data
[
'
version
'
]
=
__version__
data
[
'
version
'
]
=
__version__
json
.
dump
(
data
,
outfile
,
indent
=
4
,
sort_keys
=
True
)
json
.
dump
(
data
,
outfile
,
indent
=
4
,
sort_keys
=
True
)
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/mainwindow.py
+
1
−
1
View file @
c10f6110
...
@@ -57,7 +57,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -57,7 +57,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def
__init__
(
self
,
app
):
def
__init__
(
self
,
app
):
"""
"""
Init
Init
:param
.
.core.app.Application app:
:param
cutecoin
.core.app.Application app:
application
"""
"""
# Set up the user interface from Designer.
# Set up the user interface from Designer.
super
().
__init__
()
super
().
__init__
()
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/gui/wallets_tab.py
+
33
−
3
View file @
c10f6110
...
@@ -10,6 +10,7 @@ from PyQt5.QtCore import QDateTime, QModelIndex, Qt, QLocale
...
@@ -10,6 +10,7 @@ from PyQt5.QtCore import QDateTime, QModelIndex, Qt, QLocale
from
PyQt5.QtGui
import
QCursor
from
PyQt5.QtGui
import
QCursor
from
..core.person
import
Person
from
..core.person
import
Person
from
..core.wallet
import
Wallet
from
..core.wallet
import
Wallet
from
..gui.password_asker
import
PasswordAskerDialog
from
..models.wallets
import
WalletsTableModel
,
WalletsFilterProxyModel
from
..models.wallets
import
WalletsTableModel
,
WalletsFilterProxyModel
from
.transfer
import
TransferMoneyDialog
from
.transfer
import
TransferMoneyDialog
from
..tools.exceptions
import
MembershipNotFoundError
from
..tools.exceptions
import
MembershipNotFoundError
...
@@ -22,9 +23,13 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab):
...
@@ -22,9 +23,13 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab):
'''
'''
def
__init__
(
self
,
app
,
account
,
community
,
password_asker
):
def
__init__
(
self
,
app
,
account
,
community
,
password_asker
):
'''
"""
Constructor
Init
'''
:param cutecoin.core.app.Application app: Application instance
:param cutecoin.core.account.Account account: Account instance
:param cutecoin.core.community.Community community: Community instance
:param cutecoin.gui.password_asker.PasswordAskerDialog password_asker: PasswordAskerDialog instance
"""
super
().
__init__
()
super
().
__init__
()
self
.
setupUi
(
self
)
self
.
setupUi
(
self
)
self
.
app
=
app
self
.
app
=
app
...
@@ -156,6 +161,9 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab):
...
@@ -156,6 +161,9 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab):
pubkey
=
model
.
sourceModel
().
data
(
pubkey_index
,
Qt
.
DisplayRole
)
pubkey
=
model
.
sourceModel
().
data
(
pubkey_index
,
Qt
.
DisplayRole
)
menu
=
QMenu
(
model
.
data
(
index
,
Qt
.
DisplayRole
),
self
)
menu
=
QMenu
(
model
.
data
(
index
,
Qt
.
DisplayRole
),
self
)
new_wallet
=
QAction
(
self
.
tr
(
"
New Wallet
"
),
self
)
new_wallet
.
triggered
.
connect
(
self
.
new_wallet
)
rename
=
QAction
(
self
.
tr
(
"
Rename
"
),
self
)
rename
=
QAction
(
self
.
tr
(
"
Rename
"
),
self
)
rename
.
triggered
.
connect
(
self
.
rename_wallet
)
rename
.
triggered
.
connect
(
self
.
rename_wallet
)
rename
.
setData
(
name_index
)
rename
.
setData
(
name_index
)
...
@@ -175,12 +183,34 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab):
...
@@ -175,12 +183,34 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab):
transfer_action
.
setData
(
wallets
)
transfer_action
.
setData
(
wallets
)
transfer_to
.
addAction
(
transfer_action
)
transfer_to
.
addAction
(
transfer_action
)
menu
.
addAction
(
new_wallet
)
menu
.
addAction
(
rename
)
menu
.
addAction
(
rename
)
menu
.
addAction
(
copy_pubkey
)
menu
.
addAction
(
copy_pubkey
)
menu
.
addMenu
(
transfer_to
)
menu
.
addMenu
(
transfer_to
)
# Show the context menu.
# Show the context menu.
menu
.
exec_
(
QCursor
.
pos
())
menu
.
exec_
(
QCursor
.
pos
())
def
new_wallet
(
self
):
"""
Create a new wallet
"""
password_asker
=
PasswordAskerDialog
(
self
.
app
.
current_account
)
password
=
password_asker
.
exec_
()
if
password_asker
.
result
()
==
QDialog
.
Rejected
:
return
None
# create new wallet by increasing wallet pool size
self
.
account
.
set_walletpool_size
(
len
(
self
.
account
.
wallets
)
+
1
,
password
)
# capture new wallet
wallet
=
self
.
account
.
wallets
[
len
(
self
.
account
.
wallets
)
-
1
]
# feed cache data of the wallet
wallet
.
refresh_cache
(
self
.
community
,
list
())
# save wallet cache on disk
self
.
app
.
save_wallet
(
self
.
account
,
self
.
account
.
wallets
[
len
(
self
.
account
.
wallets
)
-
1
])
# save account cache on disk (update number of wallets)
self
.
app
.
save
(
self
.
account
)
# refresh wallet list in gui
self
.
refresh
()
def
rename_wallet
(
self
):
def
rename_wallet
(
self
):
index
=
self
.
sender
().
data
()
index
=
self
.
sender
().
data
()
self
.
table_wallets
.
edit
(
index
)
self
.
table_wallets
.
edit
(
index
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment