diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index 0cc4a1f..6233405 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -53,13 +53,6 @@ 5 - - - - Platform name - - - @@ -67,44 +60,6 @@ - - - - - - - Share platform fee* - - - - - - - Share dealing discount # of trades - - - - - - - Share dealing fee* - - - - - - - Fund dealing fee* - - - - - - - Share platform fee cap/mth - - - @@ -118,19 +73,6 @@ - - - - QAbstractSpinBox::ButtonSymbols::NoButtons - - - QAbstractSpinBox::CorrectionMode::CorrectToNearestValue - - - £ - - - @@ -144,16 +86,49 @@ - - + + + + + + + true + + + + + + + Platform name + + + + + + + + + + false + + + + + + true + + + + + QAbstractSpinBox::ButtonSymbols::NoButtons QAbstractSpinBox::CorrectionMode::CorrectToNearestValue - - % + + £ @@ -170,6 +145,47 @@ + + + + Fund dealing fee* + + + + + + + Share platform fee cap/mth + + + + + + + QAbstractSpinBox::ButtonSymbols::NoButtons + + + QAbstractSpinBox::CorrectionMode::CorrectToNearestValue + + + % + + + + + + + + + + + + + + Share dealing fee* + + + @@ -180,6 +196,60 @@ + + + + Share dealing discount # of trades + + + + + + + + + + + + + + false + + + + + + true + + + + + + + Share platform fee* + + + + + + + false + + + + + + true + + + + + + + + + + @@ -221,6 +291,13 @@ share_deal_reduce_trades_box share_deal_reduce_amount_box save_but + plat_name_check + fund_deal_fee_check + share_plat_fee_check + share_plat_max_fee_check + share_deal_fee_check + share_deal_reduce_trades_check + share_deal_reduce_amount_check diff --git a/src/platform_edit.py b/src/platform_edit.py index fda14dd..7989e83 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -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