eric7/WebBrowser/AdBlock/AdBlockTreeWidget.py

branch
eric7
changeset 9162
8b75b1668583
parent 8881
54e42bc2437a
equal deleted inserted replaced
9161:90939b08da20 9162:8b75b1668583
14 QApplication 14 QApplication
15 ) 15 )
16 16
17 from EricWidgets.EricTreeWidget import EricTreeWidget, EricTreeWidgetItemsState 17 from EricWidgets.EricTreeWidget import EricTreeWidget, EricTreeWidgetItemsState
18 from EricGui.EricOverrideCursor import EricOverrideCursor 18 from EricGui.EricOverrideCursor import EricOverrideCursor
19 from EricWidgets.EricApplication import ericApp
19 20
20 21
21 class AdBlockTreeWidget(EricTreeWidget): 22 class AdBlockTreeWidget(EricTreeWidget):
22 """ 23 """
23 Class implementing a tree widget for the AdBlock configuration dialog. 24 Class implementing a tree widget for the AdBlock configuration dialog.
40 41
41 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) 42 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
42 self.setDefaultItemShowMode(EricTreeWidgetItemsState.EXPANDED) 43 self.setDefaultItemShowMode(EricTreeWidgetItemsState.EXPANDED)
43 self.setHeaderHidden(True) 44 self.setHeaderHidden(True)
44 self.setAlternatingRowColors(True) 45 self.setAlternatingRowColors(True)
46
47 self.__darkMode = ericApp().usesDarkPalette()
45 48
46 self.customContextMenuRequested.connect(self.__contextMenuRequested) 49 self.customContextMenuRequested.connect(self.__contextMenuRequested)
47 self.itemChanged.connect(self.__itemChanged) 50 self.itemChanged.connect(self.__itemChanged)
48 self.__subscription.changed.connect(self.__subscriptionChanged) 51 self.__subscription.changed.connect(self.__subscriptionChanged)
49 self.__subscription.rulesChanged.connect(self.__subscriptionChanged) 52 self.__subscription.rulesChanged.connect(self.__subscriptionChanged)
237 @type AdBlockRule 240 @type AdBlockRule
238 """ 241 """
239 if not rule.isEnabled(): 242 if not rule.isEnabled():
240 font = QFont() 243 font = QFont()
241 font.setItalic(True) 244 font.setItalic(True)
242 itm.setForeground(0, QColor(Qt.GlobalColor.gray)) 245 if self.__darkMode:
246 itm.setForeground(0, QColor("#a3a3a3"))
247 else:
248 itm.setForeground(0, QColor(Qt.GlobalColor.gray))
243 249
244 if not rule.isComment() and not rule.isHeader(): 250 if not rule.isComment() and not rule.isHeader():
245 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) 251 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
246 itm.setCheckState(0, Qt.CheckState.Unchecked) 252 itm.setCheckState(0, Qt.CheckState.Unchecked)
247 itm.setFont(0, font) 253 itm.setFont(0, font)
250 256
251 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable) 257 itm.setFlags(itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
252 itm.setCheckState(0, Qt.CheckState.Checked) 258 itm.setCheckState(0, Qt.CheckState.Checked)
253 259
254 if rule.isCSSRule(): 260 if rule.isCSSRule():
255 itm.setForeground(0, QColor(Qt.GlobalColor.darkBlue)) 261 if self.__darkMode:
262 itm.setForeground(0, QColor("#7897d1"))
263 else:
264 itm.setForeground(0, QColor(Qt.GlobalColor.darkBlue))
256 itm.setFont(0, QFont()) 265 itm.setFont(0, QFont())
257 elif rule.isException(): 266 elif rule.isException():
258 itm.setForeground(0, QColor(Qt.GlobalColor.darkGreen)) 267 if self.__darkMode:
268 itm.setForeground(0, QColor("#75d180"))
269 else:
270 itm.setForeground(0, QColor(Qt.GlobalColor.darkGreen))
259 itm.setFont(0, QFont()) 271 itm.setFont(0, QFont())
260 else: 272 else:
261 itm.setForeground(0, QColor()) 273 if self.__darkMode:
274 itm.setForeground(0, QColor("#fefefe"))
275 else:
276 itm.setForeground(0, QColor("#000000"))
262 itm.setFont(0, QFont()) 277 itm.setFont(0, QFont())
263 278
264 def keyPressEvent(self, evt): 279 def keyPressEvent(self, evt):
265 """ 280 """
266 Protected method handling key presses. 281 Protected method handling key presses.

eric ide

mercurial