54 |
54 |
55 class E5LineEdit(QLineEdit): |
55 class E5LineEdit(QLineEdit): |
56 """ |
56 """ |
57 Class implementing a line edit widget showing some inactive text. |
57 Class implementing a line edit widget showing some inactive text. |
58 """ |
58 """ |
59 def __init__(self, parent=None, inactiveText=""): |
59 def __init__(self, parent=None, placeholderText=""): |
60 """ |
60 """ |
61 Constructor |
61 Constructor |
62 |
62 |
63 @param parent reference to the parent widget (QWidget) |
63 @param parent reference to the parent widget |
64 @param inactiveText text to be shown on inactivity (string) |
64 @type QWidget |
|
65 @param placeholderText text to be shown on inactivity |
|
66 @type str |
65 """ |
67 """ |
66 super().__init__(parent) |
68 super().__init__(parent) |
67 |
69 |
68 self.setMinimumHeight(22) |
70 self.setMinimumHeight(22) |
69 |
71 |
70 self.setPlaceholderText(inactiveText) |
72 self.setPlaceholderText(placeholderText) |
71 |
73 |
72 self.__mainLayout = QHBoxLayout(self) |
74 self.__mainLayout = QHBoxLayout(self) |
73 self.__mainLayout.setContentsMargins(0, 0, 0, 0) |
75 self.__mainLayout.setContentsMargins(0, 0, 0, 0) |
74 self.__mainLayout.setSpacing(0) |
76 self.__mainLayout.setSpacing(0) |
75 |
77 |
237 self.__rightWidget.sizeHint().width() |
239 self.__rightWidget.sizeHint().width() |
238 ) |
240 ) |
239 if w == 0: |
241 if w == 0: |
240 return 0 |
242 return 0 |
241 return w + spacing * 2 |
243 return w + spacing * 2 |
242 |
|
243 def inactiveText(self): |
|
244 """ |
|
245 Public method to get the inactive text. |
|
246 |
|
247 @return inactive text (string) |
|
248 """ |
|
249 return self.placeholderText() |
|
250 |
|
251 def setInactiveText(self, inactiveText): |
|
252 """ |
|
253 Public method to set the inactive text. |
|
254 |
|
255 @param inactiveText text to be shown on inactivity (string) |
|
256 """ |
|
257 self.setPlaceholderText(inactiveText) |
|
258 |
|
259 |
244 |
260 class E5ClearableLineEdit(E5LineEdit): |
245 class E5ClearableLineEdit(E5LineEdit): |
261 """ |
246 """ |
262 Class implementing a line edit widget showing some inactive text and a |
247 Class implementing a line edit widget showing some inactive text and a |
263 clear button, if it has some contents. |
248 clear button, if it has some contents. |
264 """ |
249 """ |
265 def __init__(self, parent=None, inactiveText="", |
250 def __init__(self, parent=None, placeholderText="", |
266 side=E5LineEditSide.RIGHT): |
251 side=E5LineEditSide.RIGHT): |
267 """ |
252 """ |
268 Constructor |
253 Constructor |
269 |
254 |
270 @param parent reference to the parent widget |
255 @param parent reference to the parent widget |
271 @type QWidget |
256 @type QWidget |
272 @param inactiveText text to be shown on inactivity |
257 @param placeholderText text to be shown on inactivity |
273 @type str |
258 @type str |
274 @param side side the clear button should be shown at |
259 @param side side the clear button should be shown at |
275 @type E5LineEditSide |
260 @type E5LineEditSide |
276 """ |
261 """ |
277 super().__init__(parent, inactiveText) |
262 super().__init__(parent, placeholderText) |
278 |
263 |
279 self.setClearButtonEnabled(True) |
264 self.setClearButtonEnabled(True) |