Skip to content
Snippets Groups Projects
Commit 859070ae authored by inso's avatar inso
Browse files

Adding a dialog to add contacts

parent f9f64c78
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ RESOURCE_DIR = res/ui
COMPILED_DIR = src/cutecoin/gen_resources
#UI files to compile
UI_FILES = mainwindow.ui addAccountDialog.ui addCommunityDialog.ui communityTabWidget.ui issuanceDialog.ui transferDialog.ui
UI_FILES = mainwindow.ui addAccountDialog.ui addCommunityDialog.ui communityTabWidget.ui issuanceDialog.ui transferDialog.ui addContactDialog.ui
#Qt resource files to compile
RESOURCES =
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddContactDialog</class>
<widget class="QDialog" name="AddContactDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>228</width>
<height>134</height>
</rect>
</property>
<property name="windowTitle">
<string>Add a contact</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Nom</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edit_name"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Fingerprint</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edit_fingerprint"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Email</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="edit_email"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddContactDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddContactDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>edit_fingerprint</sender>
<signal>textChanged(QString)</signal>
<receiver>AddContactDialog</receiver>
<slot>fingerprintEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>145</x>
<y>52</y>
</hint>
<hint type="destinationlabel">
<x>113</x>
<y>66</y>
</hint>
</hints>
</connection>
<connection>
<sender>edit_name</sender>
<signal>textChanged(QString)</signal>
<receiver>AddContactDialog</receiver>
<slot>nameEdited()</slot>
<hints>
<hint type="sourcelabel">
<x>129</x>
<y>21</y>
</hint>
<hint type="destinationlabel">
<x>113</x>
<y>66</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>nameEdited()</slot>
<slot>fingerprintEdited()</slot>
</slots>
</ui>
......@@ -37,7 +37,7 @@
<bool>false</bool>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="walletsTab">
<attribute name="title">
......@@ -287,10 +287,27 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionAdd_a_contact</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>openAddContactDialog()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>248</x>
<y>218</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>openAddAccountDialog()</slot>
<slot>save()</slot>
<slot>openTransferMoneyDialog()</slot>
<slot>openAddContactDialog()</slot>
</slots>
</ui>
'''
Created on 2 févr. 2014
@author: inso
'''
import logging
from PyQt5.QtWidgets import QDialog, QDialogButtonBox
from cutecoin.models.person import Person
from cutecoin.gen_resources.addContactDialog_uic import Ui_AddContactDialog
class AddContactDialog(QDialog, Ui_AddContactDialog):
'''
classdocs
'''
def __init__(self, account):
'''
Constructor
'''
super(AddContactDialog, self).__init__()
self.setupUi(self)
def accept(self):
#TODO: Add a contact on acceptance
pass
def nameEdited(self, newName):
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( len(newName) > 0 )
def fingerprintEdited(self, newFingerprint):
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( len(newFingerprint) == 32 )
......@@ -9,6 +9,7 @@ from PyQt5.QtCore import QSignalMapper
from cutecoin.gui.addAccountDialog import AddAccountDialog
from cutecoin.gui.transferMoneyDialog import TransferMoneyDialog
from cutecoin.gui.communityTabWidget import CommunityTabWidget
from cutecoin.gui.addContactDialog import AddContactDialog
from cutecoin.models.account.wallets.listModel import WalletsListModel
from cutecoin.models.wallet.listModel import WalletListModel
from cutecoin.models.transaction.sentListModel import SentListModel
......@@ -57,8 +58,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def openTransferMoneyDialog(self):
transferMoneyDialog = TransferMoneyDialog(self.core.currentAccount)
transferMoneyDialog.exec_()
TransferMoneyDialog(self.core.currentAccount).exec_()
def openAddContactDialog(self):
AddContactDialog(self.core.currentAccount).exec_()
'''
Refresh main window
......
......@@ -19,7 +19,7 @@ class Account(object):
Each account has only one pgpKey, and a key can
be locally referenced by only one account.
'''
def __init__(self, pgpKeyId, name, communities, wallets):
def __init__(self, pgpKeyId, name, communities, wallets, contacts):
'''
Constructor
'''
......@@ -27,6 +27,7 @@ class Account(object):
self.name = name
self.communities = communities
self.wallets = wallets
self.contacts = contacts
@classmethod
def create(cls, pgpKeyId, name, communities):
......@@ -34,7 +35,7 @@ class Account(object):
Constructor
'''
wallets = Wallets()
account = cls(pgpKeyId, name, communities, wallets)
account = cls(pgpKeyId, name, communities, wallets, [])
for community in account.communities.communitiesList:
wallet = account.wallets.addWallet(community.currency)
wallet.refreshCoins(community, account.keyFingerprint())
......@@ -46,7 +47,12 @@ class Account(object):
name = jsonData['name']
communities = Communities()
wallets = Wallets()
account = cls(pgpKeyId, name, communities, wallets)
contacts = []
for contactData in jsonData['contacts']:
contacts.append(Person.fromJson(contactData))
account = cls(pgpKeyId, name, communities, wallets, contacts)
for communityData in jsonData['communities']:
account.communities.communitiesList.append(Community.load(communityData, account))
......@@ -56,6 +62,9 @@ class Account(object):
def addWallet(name, currency):
self.wallets.addWallet(name, currency)
def addContact(person):
self.contacts.append(person)
def keyFingerprint(self):
gpg = gnupg.GPG()
availableKeys = gpg.list_keys()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment