diff --git a/Makefile b/Makefile index 655556026ee27188d8f30a0810a3456e654c6ae8..9988c5fc25b16e771097368980887ab7cc436988 100644 --- a/Makefile +++ b/Makefile @@ -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 = diff --git a/res/ui/addContactDialog.ui b/res/ui/addContactDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..73524bfafe9f52702e1b804972077c38e32e08f5 --- /dev/null +++ b/res/ui/addContactDialog.ui @@ -0,0 +1,145 @@ +<?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> diff --git a/res/ui/mainwindow.ui b/res/ui/mainwindow.ui index 3fc73a2798bfd9c2683c859a27fec5bc20c0ae18..b31de7e4eb3a0e8edc9e407be94f5ecafd6b5663 100644 --- a/res/ui/mainwindow.ui +++ b/res/ui/mainwindow.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> diff --git a/src/cutecoin/gui/addContactDialog.py b/src/cutecoin/gui/addContactDialog.py new file mode 100644 index 0000000000000000000000000000000000000000..e3e2c99c7d9c1f36bb1a372d0875d8376e412e27 --- /dev/null +++ b/src/cutecoin/gui/addContactDialog.py @@ -0,0 +1,36 @@ +''' +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 ) + diff --git a/src/cutecoin/gui/mainWindow.py b/src/cutecoin/gui/mainWindow.py index 1388d900996f0246d5df979c3046a23004ce7d3e..65c2c9b4169b01666f87eeae544547b07f102a00 100644 --- a/src/cutecoin/gui/mainWindow.py +++ b/src/cutecoin/gui/mainWindow.py @@ -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 diff --git a/src/cutecoin/models/account/__init__.py b/src/cutecoin/models/account/__init__.py index e01f9bb8aea49e04a510e8236721b4e49dbf4af4..abfa4e31761bd8638540aa6927d738ad3338dbd3 100644 --- a/src/cutecoin/models/account/__init__.py +++ b/src/cutecoin/models/account/__init__.py @@ -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()