begin adding optional fields

This commit is contained in:
Roland W-H 2025-02-11 10:57:19 +00:00
parent b62518875f
commit 9143afc176
2 changed files with 156 additions and 63 deletions

View File

@ -53,13 +53,6 @@
<property name="verticalSpacing">
<number>5</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="plat_name_lab">
<property name="text">
<string>Platform name</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="share_deal_reduce_amount_lab">
<property name="text">
@ -67,44 +60,6 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="plat_name_box"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="share_plat_fee_lab">
<property name="text">
<string>Share platform fee*</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="share_deal_reduce_trades_lab">
<property name="text">
<string>Share dealing discount # of trades</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="share_deal_fee_lab">
<property name="text">
<string>Share dealing fee*</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="fund_deal_fee_lab">
<property name="text">
<string>Fund dealing fee*</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="share_plat_max_fee_lab">
<property name="text">
<string>Share platform fee cap/mth</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QDoubleSpinBox" name="share_deal_reduce_amount_box">
<property name="buttonSymbols">
@ -118,19 +73,6 @@
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QDoubleSpinBox" name="share_deal_fee_box">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="prefix">
<string>£</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QDoubleSpinBox" name="share_plat_max_fee_box">
<property name="buttonSymbols">
@ -144,16 +86,49 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="share_plat_fee_box">
<item row="0" column="3">
<widget class="QCheckBox" name="plat_name_check">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="plat_name_lab">
<property name="text">
<string>Platform name</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="plat_name_box"/>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="share_plat_fee_check">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QDoubleSpinBox" name="share_deal_fee_box">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="suffix">
<string>%</string>
<property name="prefix">
<string>£</string>
</property>
</widget>
</item>
@ -170,6 +145,47 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="fund_deal_fee_lab">
<property name="text">
<string>Fund dealing fee*</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="share_plat_max_fee_lab">
<property name="text">
<string>Share platform fee cap/mth</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="share_plat_fee_box">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="suffix">
<string>%</string>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QCheckBox" name="share_deal_reduce_trades_check">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="share_deal_fee_lab">
<property name="text">
<string>Share dealing fee*</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QSpinBox" name="share_deal_reduce_trades_box">
<property name="buttonSymbols">
@ -180,6 +196,60 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="share_deal_reduce_trades_lab">
<property name="text">
<string>Share dealing discount # of trades</string>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QCheckBox" name="share_deal_reduce_amount_check">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QCheckBox" name="share_deal_fee_check">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="share_plat_fee_lab">
<property name="text">
<string>Share platform fee*</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="fund_deal_fee_check">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="share_plat_max_fee_check">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="save_but">
@ -221,6 +291,13 @@
<tabstop>share_deal_reduce_trades_box</tabstop>
<tabstop>share_deal_reduce_amount_box</tabstop>
<tabstop>save_but</tabstop>
<tabstop>plat_name_check</tabstop>
<tabstop>fund_deal_fee_check</tabstop>
<tabstop>share_plat_fee_check</tabstop>
<tabstop>share_plat_max_fee_check</tabstop>
<tabstop>share_deal_fee_check</tabstop>
<tabstop>share_deal_reduce_trades_check</tabstop>
<tabstop>share_deal_reduce_amount_check</tabstop>
</tabstops>
<resources/>
<connections>

View File

@ -30,6 +30,13 @@ class PlatformEdit(QWidget):
if autofill:
self.save_but.setEnabled(True)
self.optional_check_boxes = [
self.plat_name_check,
self.share_plat_max_fee_check,
self.share_deal_reduce_trades_check,
self.share_deal_reduce_amount_check
]
# Create main window object, passing this instance as param
self.main_win = main_window.SIPPCompare(self)
@ -40,6 +47,9 @@ class PlatformEdit(QWidget):
self.share_plat_fee_box.valueChanged.connect(self.check_valid)
self.share_deal_fee_box.valueChanged.connect(self.check_valid)
for check_box in self.optional_check_boxes:
check_box.checkStateChanged.connect(self.check_valid)
# Install event filter on input boxes in order to select all text on focus
self.fund_deal_fee_box.installEventFilter(self)
self.share_plat_fee_box.installEventFilter(self)
@ -48,6 +58,9 @@ class PlatformEdit(QWidget):
self.share_deal_reduce_trades_box.installEventFilter(self)
self.share_deal_reduce_amount_box.installEventFilter(self)
#for check_box in self.optional_check_boxes:
# check_box.installEventFilter(self)
# Set validators
# Regex accepts any characters that match [a-Z], [0-9] or _
self.plat_name_box.setValidator(
@ -79,10 +92,13 @@ class PlatformEdit(QWidget):
# When focus is given to an input box, select all text in it (easier to edit)
def eventFilter(self, obj: QObject, event: QEvent):
if event.type() == QEvent.Type.FocusIn:
if obj.staticMetaObject.className() == "QDoubleSpinBox" and event.type() == QEvent.Type.FocusIn:
# Alternative condition for % suffix - currently unused
#if obj.value() == 0 or obj == self.share_plat_fee_box:
QTimer.singleShot(0, obj.selectAll)
#if obj in self.optional_check_boxes and \
#event.type() == QEvent.Type.FocusIn or event.type() == QEvent.Type.FocusOut:
# print("Working")
return False
# Check if all required fields have valid (non-zero) input