do not pre-select an item in highlight dialog

This commit is contained in:
2021-11-01 19:31:19 +01:00
parent f3f47d0ce7
commit 5b9c64fb86
2 changed files with 10 additions and 36 deletions

View File

@@ -36,41 +36,17 @@ class ColorButton(QWidget):
# grey # grey
self.tr('Light Grey'): 'cccccc', self.tr('Light Grey'): 'cccccc',
self.tr('Grey'): '999999', self.tr('Grey'): '999999',
# self.tr('Hot Pink'): 'ffaebc',
# self.tr('Light Coral'): 'f08080',
# self.tr('Red'): 'cc0000',
# self.tr('Orange'): 'fcaf3e',
# self.tr('Dark Orange'): 'ce5c00',
# self.tr('Yellow'): 'fce94f',
# self.tr('Dark Yellow'): 'c4a000',
# self.tr('Mint'): 'b4f8c8',
# self.tr('Green'): '8ae234',
# self.tr('Dark Green'): '439a06',
# self.tr('Tiffany Blue'): 'a0e7e5',
# self.tr('Blue'): '729fcf',
# self.tr('Dark Blue'): '3465a4',
# self.tr('Purple'): 'ad7fa8',
# self.tr('Dark Purple'): '5c3566',
# self.tr('Brown'): 'e9b96e',
# self.tr('Dark Brown'): 'c17d11',
# self.tr('Grey'): 'd3d7cf',
# self.tr('Dark Grey'): '888a85',
# self.tr('Brewer Light Blue'): 'ece7f2',
# self.tr('Brewer Blue'): 'a6bddb',
# self.tr('Brewer Dark Blue'): '2b8cbe',
# self.tr('Brewer Light Red'): 'fee8c8',
# self.tr('Brewer Red'): 'fdbb84',
# self.tr('Brewer Dark Red'): 'e34a33',
} }
self.color_drop_down = QComboBox() self.color_drop_down = QComboBox()
self.layout.addWidget(self.color_drop_down) self.layout.addWidget(self.color_drop_down)
self.color_drop_down.currentIndexChanged.connect(self._color_selected)
self.color_drop_down.addItem(QIcon(self._color_pixmap("ffffffff")), self.tr("transparent"), "None") self.color_drop_down.addItem(QIcon(self._color_pixmap("ffffffff")), self.tr("transparent"), "None")
for color_name in colors.keys(): for color_name in colors.keys():
color_value = colors[color_name] color_value = colors[color_name]
self.color_drop_down.addItem(QIcon(self._color_pixmap(color_value)), color_name, color_value) self.color_drop_down.addItem(QIcon(self._color_pixmap(color_value)), color_name, color_value)
if color == color_name or color == color_value:
self.color_drop_down.currentIndexChanged.connect(self._color_selected) self.color_drop_down.setCurrentIndex(self.color_drop_down.count() - 1)
self.btn_color_picker = QPushButton(QIcon.fromTheme("color-picker"), self.tr("custom")) self.btn_color_picker = QPushButton(QIcon.fromTheme("color-picker"), self.tr("custom"))
self.layout.addWidget(self.btn_color_picker) self.layout.addWidget(self.btn_color_picker)

View File

@@ -36,7 +36,7 @@ class HighlightingDialog(QDialog):
self.btn_add.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)) self.btn_add.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
self.btn_add.pressed.connect(self._add) self.btn_add.pressed.connect(self._add)
self.btn_update = QPushButton(self.tr("Update")) self.btn_update = QPushButton(QIcon.fromTheme("stock_edit"), self.tr("Update"))
self.btn_update.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)) self.btn_update.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
self.btn_update.pressed.connect(self._update) self.btn_update.pressed.connect(self._update)
@@ -71,12 +71,12 @@ class HighlightingDialog(QDialog):
row = row + 1 row = row + 1
form_grid.addWidget(QLabel(self.tr("Hit Background:")), row, 0) form_grid.addWidget(QLabel(self.tr("Hit Background:")), row, 0)
self.hit_background_color = ColorButton("ff00ff") self.hit_background_color = ColorButton("ccb400")
form_grid.addWidget(self.hit_background_color, row, 1) form_grid.addWidget(self.hit_background_color, row, 1)
row = row + 1 row = row + 1
form_grid.addWidget(QLabel(self.tr("Line Background:")), row, 0) form_grid.addWidget(QLabel(self.tr("Line Background:")), row, 0)
self.line_background_color = ColorButton("ff00ff0d") self.line_background_color = ColorButton("fff080")
form_grid.addWidget(self.line_background_color, row, 1) form_grid.addWidget(self.line_background_color, row, 1)
row = row + 1 row = row + 1
@@ -86,9 +86,11 @@ class HighlightingDialog(QDialog):
self.buttons.rejected.connect(self.close) self.buttons.rejected.connect(self.close)
form_grid.addWidget(self.buttons, row, 0, 1, 2) form_grid.addWidget(self.buttons, row, 0, 1, 2)
self._load_existing_hightlighters()
self.list.setCurrentItem(None)
self._selection_changed()
self.list.currentItemChanged.connect(self._item_changed) self.list.currentItemChanged.connect(self._item_changed)
self.list.itemSelectionChanged.connect(self._selection_changed) self.list.itemSelectionChanged.connect(self._selection_changed)
self._load_existing_hightlighters()
def _add(self): def _add(self):
highlighter = HighlightRegex( highlighter = HighlightRegex(
@@ -166,9 +168,7 @@ class HighlightingDialog(QDialog):
self.btn_move_up.setDisabled(selected_index == 0) self.btn_move_up.setDisabled(selected_index == 0)
self.btn_move_down.setDisabled(selected_index + 1 >= self.list.count()) self.btn_move_down.setDisabled(selected_index + 1 >= self.list.count())
def _item_changed(self, current, _previous): item: PayloadItem = self.list.item(selected_index)
item: PayloadItem = current
if item:
highlighter: HighlightRegex = item.payload highlighter: HighlightRegex = item.payload
self.query.setText(highlighter.query) self.query.setText(highlighter.query)
self.ignore_case.setChecked(highlighter.ignore_case) self.ignore_case.setChecked(highlighter.ignore_case)
@@ -201,5 +201,3 @@ class HighlightingDialog(QDialog):
self.list.addItem(item) self.list.addItem(item)
if not first_item: if not first_item:
first_item = item first_item = item
if first_item:
self.list.setCurrentItem(first_item)