Skip to content
Snippets Groups Projects
Commit 761f4f70 authored by inso's avatar inso
Browse files

Polishing transactions

parent 20b5eeb1
Branches
Tags
No related merge requests found
......@@ -140,7 +140,7 @@ class TransferController(QObject):
logging.debug("checking recipient mode...")
recipient = self.selected_pubkey()
amount = self.view.spinbox_amount.value()
amount = self.view.spinbox_amount.value() * 100
#TODO: Handle other amount base than 0
amount_base = 0
......@@ -183,7 +183,7 @@ class TransferController(QObject):
else:
self.view.set_button_box(TransferView.ButtonBoxState.OK)
max_relative = self.model.quant_to_rel(amount)
max_relative = self.model.quant_to_rel(amount/100)
current_base = self.model.current_base()
self.view.set_spinboxes_parameters(pow(10, current_base), amount, max_relative)
......@@ -194,20 +194,7 @@ class TransferController(QObject):
self.refresh_amount_suffix()
def refresh_amount_suffix(self):
#TODO: Handle other exponents than 0 (using a custom spinbox ?)
unicodes = {
'0': ord('\u2070'),
'1': ord('\u00B9'),
'2': ord('\u00B2'),
'3': ord('\u00B3'),
}
for n in range(4, 10):
unicodes[str(n)] = ord('\u2070') + n
exponent = ""
for n in str('0'):
exponent += chr(unicodes[n])
self.view.spinbox_amount.setSuffix(" x10" + exponent + " " + self.model.connection.currency)
self.view.spinbox_amount.setSuffix(" " + self.model.connection.currency)
def handle_relative_change(self, value):
amount = self.model.rel_to_quant(value)
......
......@@ -36,7 +36,7 @@ class TransferModel(QObject):
amount = rel_value * dividend * pow(10, base)
# amount is rounded to the nearest power of 10 depending of last ud base
rounded = int(pow(10, base) * round(float(amount) / pow(10, base)))
return rounded
return rounded / 100
def quant_to_rel(self, amount):
"""
......@@ -45,7 +45,7 @@ class TransferModel(QObject):
:rtype: float
"""
dividend, base = self._blockchain_processor.last_ud(self.connection.currency)
relative = amount / (dividend * pow(10, base))
relative = amount * 100 / (dividend * pow(10, base))
return relative
def wallet_value(self):
......
......@@ -192,13 +192,16 @@
<bool>false</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
<enum>QAbstractSpinBox::UpDownArrows</enum>
</property>
<property name="showGroupSeparator" stdset="0">
<bool>false</bool>
</property>
<property name="decimals">
<number>0</number>
<number>2</number>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
......
......@@ -105,7 +105,7 @@ class TransferView(QDialog, Ui_TransferMoneyDialog):
:param int max_quant:
:param float max_rel:
"""
self.spinbox_amount.setMaximum(max_quant)
self.spinbox_amount.setMaximum(max_quant/100)
self.spinbox_relative.setMaximum(max_rel)
self.spinbox_amount.setSingleStep(tick_quant)
......
......@@ -34,11 +34,24 @@ class InformationsController(QObject):
@classmethod
def create(cls, parent, app, connection, blockchain_service, identities_service, sources_service):
"""
:param parent:
:param sakia.app.Application app:
:param connection:
:param blockchain_service:
:param identities_service:
:param sources_service:
:return:
"""
view = InformationsView(parent.view)
model = InformationsModel(None, app, connection, blockchain_service, identities_service, sources_service)
informations = cls(parent, view, model)
model.setParent(informations)
informations.init_view_text()
app.identity_changed.connect(informations.handle_identity_change)
app.new_transfer.connect(informations.refresh_localized_data)
app.new_dividend.connect(informations.refresh_localized_data)
return informations
@asyncify
......@@ -56,6 +69,10 @@ class InformationsController(QObject):
self.view.set_wot_text(params)
self.refresh_localized_data()
def handle_identity_change(self, identity):
if identity.pubkey == self.model.connection.pubkey and identity.uid == self.model.connection.uid:
self.refresh_localized_data()
def refresh_localized_data(self):
"""
Refresh localized data in view
......
......@@ -227,9 +227,9 @@ class HistoryTableModel(QAbstractTableModel):
for i, data in enumerate(self.transfers_data):
if data[self.columns_types.index('txhash')] == transfer.sha_hash:
if transfer.issuer == self.connection.pubkey:
self.transfers_data[self.columns_types.index('txhash')] = self.data_sent(transfer)
self.transfers_data[i] = self.data_sent(transfer)
else:
self.transfers_data[self.columns_types.index('txhash')] = self.data_received(transfer)
self.transfers_data[i] = self.data_received(transfer)
self.dataChanged.emit(self.index(i, 0), self.index(i, len(self.columns_types)))
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment