add dialog to manage highlighters

- no support for "no color"
- settings not saved to disk
This commit is contained in:
2021-10-30 16:25:34 +02:00
parent 43e85d2863
commit aee0ff9968
9 changed files with 325 additions and 62 deletions

View File

@@ -228,15 +228,19 @@ class InnerBigText(QWidget):
if self.selection_highlight.start_byte != self.selection_highlight.end_byte:
start = min(self.selection_highlight.start_byte, self.selection_highlight.end_byte)
end = max(self.selection_highlight.start_byte, self.selection_highlight.end_byte)
bytes_human_readable = humanbytes(end - start)
if end - start > (1024 ** 2) * 5:
you_sure = QMessageBox(
QMessageBox.Icon.Warning,
self.tr("copy to clipboard"),
self.tr("data selection"),
self.tr(
"You are about to copy <b>%s</b> to the clipboard. Are you sure you want to do that?" % humanbytes(
end - start)))
you_sure.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
you_sure.setDefaultButton(QMessageBox.StandardButton.No)
"You have selected <b>{0}</b> of data.").format(bytes_human_readable))
you_sure.setStandardButtons(QMessageBox.StandardButton.Cancel)
you_sure.addButton(QPushButton(self.tr("Copy {0} to Clipboard").format(bytes_human_readable)),
QMessageBox.ButtonRole.AcceptRole)
# TODO add save dialog
# you_sure.addButton(QPushButton(self.tr("Write to File")), QMessageBox.ButtonRole.YesRole)
you_sure.setDefaultButton(QMessageBox.StandardButton.Cancel)
result = you_sure.exec()
if result != QMessageBox.StandardButton.Yes:
# abort
@@ -267,7 +271,7 @@ class InnerBigText(QWidget):
for l in self.lines:
self.update_longest_line(len(l.line()))
highlighters = self.model.highlights
highlighters = self.model.highlighters()
if self.model.get_query_highlight():
highlighters = highlighters + [self.model.get_query_highlight()]
highlighters = highlighters + [self.selection_highlight] # selection highlight should be last