17 |
17 |
18 class SearchWidget(QWidget, Ui_SearchWidget): |
18 class SearchWidget(QWidget, Ui_SearchWidget): |
19 """ |
19 """ |
20 Class implementing the search box for the shel, terminal and log viewer. |
20 Class implementing the search box for the shel, terminal and log viewer. |
21 |
21 |
22 @signal searchNext(text, caseSensitive, wholeWord) emitted when the user pressed |
22 @signal searchNext(text, caseSensitive, wholeWord) emitted when the user |
23 the next button (string, boolean, boolean) |
23 pressed the next button (string, boolean, boolean) |
24 @signal searchPrevious(text, caseSensitive, wholeWord) emitted when the user pressed |
24 @signal searchPrevious(text, caseSensitive, wholeWord) emitted when the |
25 the previous button (string, boolean, boolean) |
25 user pressed the previous button (string, boolean, boolean) |
26 """ |
26 """ |
27 searchNext = pyqtSignal(str, bool, bool) |
27 searchNext = pyqtSignal(str, bool, bool) |
28 searchPrevious = pyqtSignal(str, bool, bool) |
28 searchPrevious = pyqtSignal(str, bool, bool) |
29 |
29 |
30 def __init__(self, mainWindow, parent=None, spacer=True): |
30 def __init__(self, mainWindow, parent=None, spacer=True): |
37 main layout (boolean) |
37 main layout (boolean) |
38 """ |
38 """ |
39 super().__init__(parent) |
39 super().__init__(parent) |
40 self.setupUi(self) |
40 self.setupUi(self) |
41 if spacer: |
41 if spacer: |
42 spacerItem = QSpacerItem(20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding) |
42 spacerItem = QSpacerItem( |
|
43 20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding) |
43 self.verticalLayout.addItem(spacerItem) |
44 self.verticalLayout.addItem(spacerItem) |
44 else: |
45 else: |
45 # change the size policy of the search combo if the spacer is not wanted, |
46 # change the size policy of the search combo if the spacer is not |
46 # i.e. it is below the to be searched widget |
47 # wanted, i.e. it is below the to be searched widget |
47 sizePolicy = self.findtextCombo.sizePolicy() |
48 sizePolicy = self.findtextCombo.sizePolicy() |
48 sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding) |
49 sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding) |
49 self.findtextCombo.setSizePolicy(sizePolicy) |
50 self.findtextCombo.setSizePolicy(sizePolicy) |
50 |
51 |
51 self.__mainWindow = mainWindow |
52 self.__mainWindow = mainWindow |
55 self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow.png")) |
56 self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow.png")) |
56 self.findNextButton.setIcon(UI.PixmapCache.getIcon("1rightarrow.png")) |
57 self.findNextButton.setIcon(UI.PixmapCache.getIcon("1rightarrow.png")) |
57 |
58 |
58 self.findHistory = [] |
59 self.findHistory = [] |
59 |
60 |
60 self.findtextCombo.lineEdit().returnPressed.connect(self.__findByReturnPressed) |
61 self.findtextCombo.lineEdit().returnPressed.connect( |
|
62 self.__findByReturnPressed) |
61 |
63 |
62 @pyqtSlot() |
64 @pyqtSlot() |
63 def on_closeButton_clicked(self): |
65 def on_closeButton_clicked(self): |
64 """ |
66 """ |
65 Private slot to close the widget. |
67 Private slot to close the widget. |
135 self.findPrevButton.setEnabled(enabled) |
137 self.findPrevButton.setEnabled(enabled) |
136 self.findNextButton.setEnabled(enabled) |
138 self.findNextButton.setEnabled(enabled) |
137 |
139 |
138 def __findByReturnPressed(self): |
140 def __findByReturnPressed(self): |
139 """ |
141 """ |
140 Private slot to handle the returnPressed signal of the findtext combobox. |
142 Private slot to handle the returnPressed signal of the findtext |
|
143 combobox. |
141 """ |
144 """ |
142 if self.__findBackwards: |
145 if self.__findBackwards: |
143 self.on_findPrevButton_clicked() |
146 self.on_findPrevButton_clicked() |
144 else: |
147 else: |
145 self.on_findNextButton_clicked() |
148 self.on_findNextButton_clicked() |