5 |
5 |
6 """ |
6 """ |
7 Module implementing specialized line edits. |
7 Module implementing specialized line edits. |
8 """ |
8 """ |
9 |
9 |
|
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
|
11 |
10 from PyQt4.QtCore import pyqtSignal, Qt, QEvent, qVersion |
12 from PyQt4.QtCore import pyqtSignal, Qt, QEvent, qVersion |
11 from PyQt4.QtGui import QLineEdit, QStyle, QPainter, QPalette, QStyleOptionFrameV2, \ |
13 from PyQt4.QtGui import QLineEdit, QStyle, QPainter, QPalette, QStyleOptionFrameV2, \ |
12 QWidget, QHBoxLayout, QBoxLayout, QLayout, QApplication, QSpacerItem, QSizePolicy |
14 QWidget, QHBoxLayout, QBoxLayout, QLayout, QApplication, QSpacerItem, QSizePolicy |
13 |
15 |
14 import UI.PixmapCache |
16 import UI.PixmapCache |
52 Constructor |
54 Constructor |
53 |
55 |
54 @param parent reference to the parent widget (QWidget) |
56 @param parent reference to the parent widget (QWidget) |
55 @param inactiveText text to be shown on inactivity (string) |
57 @param inactiveText text to be shown on inactivity (string) |
56 """ |
58 """ |
57 super().__init__(parent) |
59 super(E5LineEdit, self).__init__(parent) |
58 |
60 |
59 self.setMinimumHeight(22) |
61 self.setMinimumHeight(22) |
60 |
62 |
61 if qVersion() < "4.7.0": |
63 if qVersion() < "4.7.0": |
62 self.__inactiveText = inactiveText |
64 self.__inactiveText = inactiveText |
140 """ |
142 """ |
141 Protected method handling a paint event. |
143 Protected method handling a paint event. |
142 |
144 |
143 @param evt reference to the paint event (QPaintEvent) |
145 @param evt reference to the paint event (QPaintEvent) |
144 """ |
146 """ |
145 super().paintEvent(evt) |
147 super(E5LineEdit, self).paintEvent(evt) |
146 |
148 |
147 if qVersion() < "4.7.0": |
149 if qVersion() < "4.7.0": |
148 if not self.text() and \ |
150 if not self.text() and \ |
149 self.__inactiveText and \ |
151 self.__inactiveText and \ |
150 not self.hasFocus(): |
152 not self.hasFocus(): |
280 @keyparam side side the clear button should be shown at (E5LineEdit.RightSide, |
282 @keyparam side side the clear button should be shown at (E5LineEdit.RightSide, |
281 E5LineEdit.LeftSide) |
283 E5LineEdit.LeftSide) |
282 """ |
284 """ |
283 assert side in [E5LineEdit.RightSide, E5LineEdit.LeftSide] |
285 assert side in [E5LineEdit.RightSide, E5LineEdit.LeftSide] |
284 |
286 |
285 super().__init__(parent, inactiveText) |
287 super(E5ClearableLineEdit, self).__init__(parent, inactiveText) |
286 |
288 |
287 from E5Gui.E5LineEditButton import E5LineEditButton |
289 from E5Gui.E5LineEditButton import E5LineEditButton |
288 self.__clearButton = E5LineEditButton(self) |
290 self.__clearButton = E5LineEditButton(self) |
289 self.__clearButton.setIcon(UI.PixmapCache.getIcon("clearLeft.png")) |
291 self.__clearButton.setIcon(UI.PixmapCache.getIcon("clearLeft.png")) |
290 self.addWidget(self.__clearButton, side) |
292 self.addWidget(self.__clearButton, side) |