PrintRemover/ConfigurationPage/PrintRemoverPage.py

branch
eric7
changeset 57
8e12947695cb
parent 54
d061dda35cef
child 59
79247c15c319
equal deleted inserted replaced
56:c14026de3d4c 57:8e12947695cb
7 Module implementing the Print Remover configuration page. 7 Module implementing the Print Remover configuration page.
8 """ 8 """
9 9
10 import os 10 import os
11 11
12 from PyQt5.QtCore import pyqtSlot 12 from PyQt6.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QListWidgetItem, QInputDialog, QLineEdit 13 from PyQt6.QtWidgets import QListWidgetItem, QInputDialog, QLineEdit
14 14
15 from E5Gui.E5Application import e5App 15 from EricWidgets.EricApplication import ericApp
16 16
17 from Preferences.ConfigurationPages.ConfigurationPageBase import ( 17 from Preferences.ConfigurationPages.ConfigurationPageBase import (
18 ConfigurationPageBase 18 ConfigurationPageBase
19 ) 19 )
20 from .Ui_PrintRemoverPage import Ui_PrintRemoverPage 20 from .Ui_PrintRemoverPage import Ui_PrintRemoverPage
29 def __init__(self, plugin): 29 def __init__(self, plugin):
30 """ 30 """
31 Constructor 31 Constructor
32 32
33 @param plugin reference to the plugin object 33 @param plugin reference to the plugin object
34 @type PrintRemoverPlugin
34 """ 35 """
35 super().__init__() 36 super().__init__()
36 self.setupUi(self) 37 self.setupUi(self)
37 self.setObjectName("PrintRemoverPage") 38 self.setObjectName("PrintRemoverPage")
38 39
39 try: 40 usesDarkPalette = ericApp().usesDarkPalette()
40 usesDarkPalette = e5App().usesDarkPalette()
41 except AttributeError:
42 # for eric6 < 20.4
43 from PyQt5.QtGui import QPalette
44 palette = e5App().palette()
45 lightness = palette.color(QPalette.Window).lightness()
46 usesDarkPalette = lightness <= 128
47 iconSuffix = "dark" if usesDarkPalette else "light" 41 iconSuffix = "dark" if usesDarkPalette else "light"
48 42
49 self.editButton.setIcon(UI.PixmapCache.getIcon( 43 self.editButton.setIcon(UI.PixmapCache.getIcon(
50 os.path.join("PrintRemover", "icons", 44 os.path.join("PrintRemover", "icons",
51 "edit-{0}".format(iconSuffix)))) 45 "edit-{0}".format(iconSuffix))))
109 itm = self.patternList.selectedItems()[0] 103 itm = self.patternList.selectedItems()[0]
110 pattern, ok = QInputDialog.getText( 104 pattern, ok = QInputDialog.getText(
111 self, 105 self,
112 self.tr("Line Start Pattern"), 106 self.tr("Line Start Pattern"),
113 self.tr("Enter a line start pattern:"), 107 self.tr("Enter a line start pattern:"),
114 QLineEdit.Normal, 108 QLineEdit.EchoMode.Normal,
115 itm.text()) 109 itm.text())
116 if ok and pattern: 110 if ok and pattern:
117 itm.setText(pattern) 111 itm.setText(pattern)
118 112
119 @pyqtSlot() 113 @pyqtSlot()
123 """ 117 """
124 pattern, ok = QInputDialog.getText( 118 pattern, ok = QInputDialog.getText(
125 self, 119 self,
126 self.tr("Line Start Pattern"), 120 self.tr("Line Start Pattern"),
127 self.tr("Enter a line start pattern:"), 121 self.tr("Enter a line start pattern:"),
128 QLineEdit.Normal) 122 QLineEdit.EchoMode.Normal)
129 if ok and pattern: 123 if ok and pattern:
130 itm = QListWidgetItem(pattern) 124 itm = QListWidgetItem(pattern)
131 if len(self.patternList.selectedItems()): 125 if len(self.patternList.selectedItems()):
132 row = self.patternList.row( 126 row = self.patternList.row(
133 self.patternList.selectedItems()[0]) + 1 127 self.patternList.selectedItems()[0]) + 1
179 173
180 def __moveSelectedEntry(self, moveUp): 174 def __moveSelectedEntry(self, moveUp):
181 """ 175 """
182 Private method to move the selected entry up or down. 176 Private method to move the selected entry up or down.
183 177
184 @param moveUp flag indicating to move the entry up (boolean) 178 @param moveUp flag indicating to move the entry up
179 @type bool
185 """ 180 """
186 itm = self.patternList.selectedItems()[0] 181 itm = self.patternList.selectedItems()[0]
187 row = self.patternList.row(itm) 182 row = self.patternList.row(itm)
188 newRow = row - 1 if moveUp else row + 1 183 newRow = row - 1 if moveUp else row + 1
189 self.patternList.takeItem(row) 184 self.patternList.takeItem(row)

eric ide

mercurial