eric7/WebBrowser/SearchWidget.py

branch
eric7
changeset 8858
a70a980e7d4f
parent 8857
8191d15b8974
child 8859
64252c7bfb87
equal deleted inserted replaced
8857:8191d15b8974 8858:a70a980e7d4f
6 """ 6 """
7 Module implementing the search bar for the web browser. 7 Module implementing the search bar for the web browser.
8 """ 8 """
9 9
10 from PyQt6.QtCore import pyqtSlot, Qt 10 from PyQt6.QtCore import pyqtSlot, Qt
11 from PyQt6.QtGui import QPalette, QBrush, QColor 11 from PyQt6.QtGui import QPalette
12 from PyQt6.QtWidgets import QWidget 12 from PyQt6.QtWidgets import QWidget
13 13
14 from .Ui_SearchWidget import Ui_SearchWidget 14 from .Ui_SearchWidget import Ui_SearchWidget
15 15
16 import UI.PixmapCache 16 import UI.PixmapCache
34 34
35 self.closeButton.setIcon(UI.PixmapCache.getIcon("close")) 35 self.closeButton.setIcon(UI.PixmapCache.getIcon("close"))
36 self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow")) 36 self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow"))
37 self.findNextButton.setIcon(UI.PixmapCache.getIcon("1rightarrow")) 37 self.findNextButton.setIcon(UI.PixmapCache.getIcon("1rightarrow"))
38 38
39 # TODO: change to use style sheets
40 # get style sheet or create one from palette
41 # see EricTextEditSearchWidget
42 self.__defaultBaseColor = ( 39 self.__defaultBaseColor = (
43 self.findtextCombo.lineEdit().palette().color( 40 self.findtextCombo.lineEdit().palette().color(
44 QPalette.ColorRole.Base) 41 QPalette.ColorRole.Base)
45 ) 42 )
46 self.__defaultTextColor = ( 43 self.__defaultTextColor = (
223 Private slot to change the findtext combo background to indicate 220 Private slot to change the findtext combo background to indicate
224 errors. 221 errors.
225 222
226 @param error flag indicating an error condition (boolean) 223 @param error flag indicating an error condition (boolean)
227 """ 224 """
228 le = self.findtextCombo.lineEdit()
229 p = le.palette()
230 if error: 225 if error:
231 p.setBrush(QPalette.ColorRole.Base, QBrush(QColor("#FF6666"))) 226 styleSheet = "color: #000000; background-color: #ff6666"
232 p.setBrush(QPalette.ColorRole.Text, QBrush(QColor("#000000")))
233 else: 227 else:
234 p.setBrush(QPalette.ColorRole.Base, self.__defaultBaseColor) 228 styleSheet = (
235 p.setBrush(QPalette.ColorRole.Text, self.__defaultTextColor) 229 f"color: {self.__defaultTextColor};"
236 le.setPalette(p) 230 f" background-color: {self.__defaultBaseColor}"
237 le.update() 231 )
232 self.findtextCombo.setStyleSheet(styleSheet)

eric ide

mercurial