mirror of
https://github.com/RolandWH/SIPPCompare.git
synced 2025-05-10 00:31:49 +01:00
switch from un-used trade QComboBox to FastEditQSpinBox
This commit is contained in:
parent
2422395759
commit
78323c2ad8
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>240</height>
|
||||
<height>243</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@ -16,12 +16,6 @@
|
||||
<height>240</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>420</width>
|
||||
<height>240</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SIPPCompare</string>
|
||||
</property>
|
||||
@ -35,7 +29,7 @@
|
||||
<x>10</x>
|
||||
<y>0</y>
|
||||
<width>401</width>
|
||||
<height>184</height>
|
||||
<height>188</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@ -145,18 +139,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="fund_trades_combo">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="calc_but">
|
||||
<property name="enabled">
|
||||
@ -173,14 +155,35 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="share_trades_combo">
|
||||
<widget class="FastEditQSpinBox" name="share_trades_box">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="FastEditQSpinBox" name="fund_trades_box">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -235,11 +238,16 @@
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FastEditQSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>widgets/fastedit_spinbox</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>value_input</tabstop>
|
||||
<tabstop>mix_slider</tabstop>
|
||||
<tabstop>share_trades_combo</tabstop>
|
||||
<tabstop>fund_trades_combo</tabstop>
|
||||
<tabstop>calc_but</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
@ -39,20 +39,16 @@ class SIPPCompare(QMainWindow):
|
||||
self.mix_slider.valueChanged.connect(self.update_slider_lab)
|
||||
self.value_input.valueChanged.connect(self.check_valid)
|
||||
# Validate input
|
||||
self.share_trades_combo.currentTextChanged.connect(self.check_valid)
|
||||
self.fund_trades_combo.currentTextChanged.connect(self.check_valid)
|
||||
|
||||
## Set validators
|
||||
self.share_trades_combo.setValidator(QIntValidator(0, 999))
|
||||
self.fund_trades_combo.setValidator(QIntValidator(0, 99))
|
||||
self.share_trades_box.valueChanged.connect(self.check_valid)
|
||||
self.fund_trades_box.valueChanged.connect(self.check_valid)
|
||||
|
||||
## Restore last session
|
||||
prev_session_data = self.db.retrieve_user_details()
|
||||
if "NO_RECORD" not in prev_session_data:
|
||||
self.value_input.setValue(prev_session_data["pension_val"])
|
||||
self.mix_slider.setValue(prev_session_data["slider_val"])
|
||||
self.share_trades_combo.setCurrentText(str(prev_session_data["share_trades"]))
|
||||
self.fund_trades_combo.setCurrentText(str(prev_session_data["fund_trades"]))
|
||||
self.share_trades_box.setValue(prev_session_data["share_trades"])
|
||||
self.fund_trades_box.setValue(prev_session_data["fund_trades"])
|
||||
self.calc_but.setFocus()
|
||||
|
||||
# Display slider position as mix between two nums (funds/shares)
|
||||
@ -63,9 +59,7 @@ class SIPPCompare(QMainWindow):
|
||||
|
||||
# Ensure that trade fields aren't blank and pension value > 0
|
||||
def check_valid(self):
|
||||
if self.share_trades_combo.currentText() != "" \
|
||||
and self.fund_trades_combo.currentText() != "" \
|
||||
and self.value_input.value() != 0:
|
||||
if self.value_input.value() != 0:
|
||||
self.calc_but.setEnabled(True)
|
||||
else:
|
||||
self.calc_but.setEnabled(False)
|
||||
@ -82,8 +76,8 @@ class SIPPCompare(QMainWindow):
|
||||
# Get user input
|
||||
value_num = float(self.value_input.value())
|
||||
slider_val: int = self.mix_slider.value()
|
||||
fund_trades_num = int(self.fund_trades_combo.currentText())
|
||||
share_trades_num = int(self.share_trades_combo.currentText())
|
||||
fund_trades_num = int(self.fund_trades_box.value())
|
||||
share_trades_num = int(self.share_trades_box.value())
|
||||
shares_value = (1 - (slider_val / 100)) * value_num
|
||||
index = 0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user