SelectionEncloser/ConfigurationPage/SelectionEncloserPage.py

changeset 41
e747eb5f3f43
parent 39
401d0bab970d
child 43
135907873e65
equal deleted inserted replaced
40:e534c4399087 41:e747eb5f3f43
5 5
6 """ 6 """
7 Module implementing Selection Encloser configuration page. 7 Module implementing Selection Encloser configuration page.
8 """ 8 """
9 9
10 from __future__ import unicode_literals
11
12 import os 10 import os
13 11
14 from PyQt5.QtCore import pyqtSlot, Qt 12 from PyQt5.QtCore import pyqtSlot, Qt
15 from PyQt5.QtWidgets import QTreeWidgetItem, QInputDialog, QLineEdit, QDialog 13 from PyQt5.QtWidgets import QTreeWidgetItem, QInputDialog, QLineEdit, QDialog
16 14
17 from E5Gui.E5Application import e5App 15 from E5Gui.E5Application import e5App
18 16
19 from Preferences.ConfigurationPages.ConfigurationPageBase import \ 17 from Preferences.ConfigurationPages.ConfigurationPageBase import (
20 ConfigurationPageBase 18 ConfigurationPageBase
19 )
21 from .Ui_SelectionEncloserPage import Ui_SelectionEncloserPage 20 from .Ui_SelectionEncloserPage import Ui_SelectionEncloserPage
22 21
23 import UI.PixmapCache 22 import UI.PixmapCache
24 23
25 24
43 from PyQt5.QtGui import QPalette 42 from PyQt5.QtGui import QPalette
44 palette = e5App().palette() 43 palette = e5App().palette()
45 lightness = palette.color(QPalette.Window).lightness() 44 lightness = palette.color(QPalette.Window).lightness()
46 usesDarkPalette = lightness <= 128 45 usesDarkPalette = lightness <= 128
47 if usesDarkPalette: 46 if usesDarkPalette:
48 iconSuffix = "dark" 47 iconSuffix = "dark"
49 else: 48 else:
50 iconSuffix = "light" 49 iconSuffix = "light"
51 50
52 self.editButton.setIcon(UI.PixmapCache.getIcon( 51 self.editButton.setIcon(UI.PixmapCache.getIcon(
53 os.path.join("SelectionEncloser", "icons", 52 os.path.join("SelectionEncloser", "icons",
217 QLineEdit.Normal, 216 QLineEdit.Normal,
218 itm.text(0)) 217 itm.text(0))
219 if ok and menuTitle: 218 if ok and menuTitle:
220 itm.setText(0, menuTitle) 219 itm.setText(0, menuTitle)
221 else: 220 else:
222 from .SelectionEncloserEditDialog import \ 221 from .SelectionEncloserEditDialog import (
223 SelectionEncloserEditDialog 222 SelectionEncloserEditDialog
223 )
224 dlg = SelectionEncloserEditDialog( 224 dlg = SelectionEncloserEditDialog(
225 itm.text(0), itm.data(0, Qt.UserRole), self) 225 itm.text(0), itm.data(0, Qt.UserRole), self)
226 if dlg.exec_() == QDialog.Accepted: 226 if dlg.exec_() == QDialog.Accepted:
227 title, encString = dlg.getData() 227 title, encString = dlg.getData()
228 itm.setText(0, title) 228 itm.setText(0, title)
248 parent = itm.parent() 248 parent = itm.parent()
249 if parent is None: 249 if parent is None:
250 # top level item 250 # top level item
251 if self.menuTree.indexOfTopLevelItem(itm) == 0: 251 if self.menuTree.indexOfTopLevelItem(itm) == 0:
252 upEnable = False 252 upEnable = False
253 if self.menuTree.indexOfTopLevelItem(itm) == \ 253 if (
254 self.menuTree.topLevelItemCount() - 1: 254 self.menuTree.indexOfTopLevelItem(itm) ==
255 self.menuTree.topLevelItemCount() - 1
256 ):
255 downEnable = False 257 downEnable = False
256 else: 258 else:
257 # sub item 259 # sub item
258 if parent.indexOfChild(itm) == 0: 260 if parent.indexOfChild(itm) == 0:
259 upEnable = False 261 upEnable = False
260 if parent.indexOfChild(itm) == \ 262 if parent.indexOfChild(itm) == parent.childCount() - 1:
261 parent.childCount() - 1:
262 downEnable = False 263 downEnable = False
263 addEnable = False 264 addEnable = False
264 self.addButton.setEnabled(addEnable) 265 self.addButton.setEnabled(addEnable)
265 self.addSeparatorButton.setEnabled(True) 266 self.addSeparatorButton.setEnabled(True)
266 self.deleteButton.setEnabled(True) 267 self.deleteButton.setEnabled(True)

eric ide

mercurial