37 Public method to handle events. |
37 Public method to handle events. |
38 |
38 |
39 @param evt reference to the event (QEvent) |
39 @param evt reference to the event (QEvent) |
40 @return flag indicating, whether the event was recognized (boolean) |
40 @return flag indicating, whether the event was recognized (boolean) |
41 """ |
41 """ |
42 if evt.type() == QEvent.LayoutRequest: |
42 if evt.type() == QEvent.Type.LayoutRequest: |
43 self.sizeHintChanged.emit() |
43 self.sizeHintChanged.emit() |
44 return QWidget.event(self, evt) |
44 return QWidget.event(self, evt) |
45 |
45 |
46 |
46 |
47 class E5LineEdit(QLineEdit): |
47 class E5LineEdit(QLineEdit): |
72 self.__leftWidget = E5LineEditSideWidget(self) |
72 self.__leftWidget = E5LineEditSideWidget(self) |
73 self.__leftWidget.resize(0, 0) |
73 self.__leftWidget.resize(0, 0) |
74 self.__leftLayout = QHBoxLayout(self.__leftWidget) |
74 self.__leftLayout = QHBoxLayout(self.__leftWidget) |
75 self.__leftLayout.setContentsMargins(0, 0, 2, 0) |
75 self.__leftLayout.setContentsMargins(0, 0, 2, 0) |
76 if QApplication.isRightToLeft(): |
76 if QApplication.isRightToLeft(): |
77 self.__leftLayout.setDirection(QBoxLayout.RightToLeft) |
77 self.__leftLayout.setDirection(QBoxLayout.Direction.RightToLeft) |
78 else: |
78 else: |
79 self.__leftLayout.setDirection(QBoxLayout.LeftToRight) |
79 self.__leftLayout.setDirection(QBoxLayout.Direction.LeftToRight) |
80 self.__leftLayout.setSizeConstraint(QLayout.SetFixedSize) |
80 self.__leftLayout.setSizeConstraint( |
|
81 QLayout.SizeConstraint.SetFixedSize) |
81 |
82 |
82 self.__rightWidget = E5LineEditSideWidget(self) |
83 self.__rightWidget = E5LineEditSideWidget(self) |
83 self.__rightWidget.resize(0, 0) |
84 self.__rightWidget.resize(0, 0) |
84 self.__rightLayout = QHBoxLayout(self.__rightWidget) |
85 self.__rightLayout = QHBoxLayout(self.__rightWidget) |
85 self.__rightLayout.setContentsMargins(0, 0, 2, 0) |
86 self.__rightLayout.setContentsMargins(0, 0, 2, 0) |
86 if self.isRightToLeft(): |
87 if self.isRightToLeft(): |
87 self.__rightLayout.setDirection(QBoxLayout.RightToLeft) |
88 self.__rightLayout.setDirection(QBoxLayout.Direction.RightToLeft) |
88 else: |
89 else: |
89 self.__rightLayout.setDirection(QBoxLayout.LeftToRight) |
90 self.__rightLayout.setDirection(QBoxLayout.Direction.LeftToRight) |
90 |
91 |
91 horizontalSpacer = QSpacerItem( |
92 horizontalSpacer = QSpacerItem( |
92 0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) |
93 0, 0, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) |
93 self.__mainLayout.addWidget( |
94 self.__mainLayout.addWidget( |
94 self.__leftWidget, 0, Qt.AlignVCenter | Qt.AlignLeft) |
95 self.__leftWidget, 0, |
|
96 Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft) |
95 self.__mainLayout.addItem(horizontalSpacer) |
97 self.__mainLayout.addItem(horizontalSpacer) |
96 self.__mainLayout.addWidget( |
98 self.__mainLayout.addWidget( |
97 self.__rightWidget, 0, Qt.AlignVCenter | Qt.AlignRight) |
99 self.__rightWidget, 0, |
|
100 Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight) |
98 if self.isRightToLeft(): |
101 if self.isRightToLeft(): |
99 self.__mainLayout.setDirection(QBoxLayout.RightToLeft) |
102 self.__mainLayout.setDirection(QBoxLayout.Direction.RightToLeft) |
100 else: |
103 else: |
101 self.__mainLayout.setDirection(QBoxLayout.LeftToRight) |
104 self.__mainLayout.setDirection(QBoxLayout.Direction.LeftToRight) |
102 |
105 |
103 self.setWidgetSpacing(3) |
106 self.setWidgetSpacing(3) |
104 self.__leftWidget.sizeHintChanged.connect(self._updateTextMargins) |
107 self.__leftWidget.sizeHintChanged.connect(self._updateTextMargins) |
105 self.__rightWidget.sizeHintChanged.connect(self._updateTextMargins) |
108 self.__rightWidget.sizeHintChanged.connect(self._updateTextMargins) |
106 |
109 |
125 Public method to handle events. |
128 Public method to handle events. |
126 |
129 |
127 @param evt reference to the event (QEvent) |
130 @param evt reference to the event (QEvent) |
128 @return flag indicating, whether the event was recognized (boolean) |
131 @return flag indicating, whether the event was recognized (boolean) |
129 """ |
132 """ |
130 if evt.type() == QEvent.LayoutDirectionChange: |
133 if evt.type() == QEvent.Type.LayoutDirectionChange: |
131 if self.isRightToLeft(): |
134 if self.isRightToLeft(): |
132 self.__mainLayout.setDirection(QBoxLayout.RightToLeft) |
135 self.__mainLayout.setDirection( |
133 self.__leftLayout.setDirection(QBoxLayout.RightToLeft) |
136 QBoxLayout.Direction.RightToLeft) |
134 self.__rightLayout.setDirection(QBoxLayout.RightToLeft) |
137 self.__leftLayout.setDirection( |
|
138 QBoxLayout.Direction.RightToLeft) |
|
139 self.__rightLayout.setDirection( |
|
140 QBoxLayout.Direction.RightToLeft) |
135 else: |
141 else: |
136 self.__mainLayout.setDirection(QBoxLayout.LeftToRight) |
142 self.__mainLayout.setDirection( |
137 self.__leftLayout.setDirection(QBoxLayout.LeftToRight) |
143 QBoxLayout.Direction.LeftToRight) |
138 self.__rightLayout.setDirection(QBoxLayout.LeftToRight) |
144 self.__leftLayout.setDirection( |
|
145 QBoxLayout.Direction.LeftToRight) |
|
146 self.__rightLayout.setDirection( |
|
147 QBoxLayout.Direction.LeftToRight) |
139 return QLineEdit.event(self, evt) |
148 return QLineEdit.event(self, evt) |
140 |
149 |
141 def _updateTextMargins(self): |
150 def _updateTextMargins(self): |
142 """ |
151 """ |
143 Protected slot to update the text margins. |
152 Protected slot to update the text margins. |