aboutsummaryrefslogtreecommitdiff
path: root/todo/gui/tags/panel
diff options
context:
space:
mode:
Diffstat (limited to 'todo/gui/tags/panel')
-rw-r--r--todo/gui/tags/panel/dialog.py8
-rw-r--r--todo/gui/tags/panel/form/widget.py38
-rw-r--r--todo/gui/tags/panel/table/menu.py2
-rw-r--r--todo/gui/tags/panel/table/model.py2
-rw-r--r--todo/gui/tags/panel/table/widget.py2
-rw-r--r--todo/gui/tags/panel/widget.py2
6 files changed, 12 insertions, 42 deletions
diff --git a/todo/gui/tags/panel/dialog.py b/todo/gui/tags/panel/dialog.py
index 6a0e5c4..fde1f1f 100644
--- a/todo/gui/tags/panel/dialog.py
+++ b/todo/gui/tags/panel/dialog.py
@@ -12,7 +12,7 @@ def add(parent_widget, add_tag_signal):
todo.database.commit()
add_tag_signal.emit(tag)
- return widget(parent_widget, "Add a tag", "add", None, on_add)
+ return widget(parent_widget, "Ajouter une étiquette", "Ajouter", None, on_add)
def update(parent_widget, update_tag_signal, row, tag):
@@ -21,13 +21,13 @@ def update(parent_widget, update_tag_signal, row, tag):
update_tag_signal.emit(row, updated_tag)
todo.database.commit()
- return widget(parent_widget, "Modify a tag", "modify", tag, on_update)
+ return widget(parent_widget, "Modifier une étiquette", "Modifier", tag, on_update)
def confirm_delete(table, rows):
confirm = QtWidgets.QMessageBox.question(
table,
- "Tag deletion",
- "Do you really want to delete the selected tags ?",
+ "Suppression des étiquettes",
+ "Voulez-vous vraiment supprimer les étiquettes sélectionnées ?",
QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes,
QtWidgets.QMessageBox.Yes)
diff --git a/todo/gui/tags/panel/form/widget.py b/todo/gui/tags/panel/form/widget.py
index 9ac4eb1..1b1744d 100644
--- a/todo/gui/tags/panel/form/widget.py
+++ b/todo/gui/tags/panel/form/widget.py
@@ -2,10 +2,10 @@ from PyQt5 import QtWidgets, QtCore, QtGui
from typing import Optional, Tuple, List, Any
from todo.model.tag import Tag, ValidTagForm
-from todo.model import difficulty, priority
import todo.gui.icon
import todo.gui.tags.panel.form.state
import todo.gui.color
+from todo.util.gui.color_input import ColorInput
def widget(
parent: QtWidgets.QWidget,
@@ -24,10 +24,10 @@ def widget(
grid.setLayout(grid_layout)
init_name = tag.name if tag is not None else ""
- name_input = line_edit(grid, grid_layout, 0, "Name", init_name)
+ name_input = line_edit(grid, grid_layout, 0, "Nom", init_name)
init_color = tag.color if tag is not None else "#FFFFFF"
- color_input = color_edit(grid, grid_layout, 1, "Color", QtGui.QColor(init_color))
+ color_input = color_edit(grid, grid_layout, 1, "Couleur", QtGui.QColor(init_color))
tag_form_edition = todo.gui.tags.panel.form.state.TagFormEdition(
init_name,
@@ -81,36 +81,6 @@ def color_edit(
return edit
-class ColorInput(QtWidgets.QLineEdit):
-
- def __init__(self, init_color: QtGui.QColor, parent):
- super().__init__(parent)
- self.setReadOnly(True)
- self.installEventFilter(self)
- self._color = init_color
- self.update(init_color)
- self._is_editing = False
-
- def eventFilter(self, source, event):
- if source is self and event.type() == QtCore.QEvent.FocusIn:
- if not self._is_editing:
- self._is_editing = True
- color = QtWidgets.QColorDialog.getColor(self._color, self)
- if color.isValid():
- self.update(color)
- else:
- self._is_editing = False
- self.clearFocus()
- return super(ColorInput, self).eventFilter(source, event)
-
- def update(self, color: QtGui.QColor):
- self._color = color
- self.setText(color.name().upper())
- palette = QtGui.QPalette()
- palette.setColor(QtGui.QPalette.Base, color)
- palette.setColor(QtGui.QPalette.Text, color)
- self.setPalette(palette)
-
def buttons(parent, action_title, tag_form_signal, on_validate, on_cancel):
widget = QtWidgets.QWidget(parent)
layout = QtWidgets.QHBoxLayout(widget)
@@ -129,7 +99,7 @@ def buttons(parent, action_title, tag_form_signal, on_validate, on_cancel):
tag_form_signal.connect(on_tag_form_signal)
- cancel = QtWidgets.QPushButton("cancel", widget)
+ cancel = QtWidgets.QPushButton("Annuler", widget)
cancel.setIcon(todo.gui.icon.dialog_cancel(cancel.style()))
cancel.clicked.connect(on_cancel)
layout.addWidget(cancel)
diff --git a/todo/gui/tags/panel/table/menu.py b/todo/gui/tags/panel/table/menu.py
index 0446841..7ceded7 100644
--- a/todo/gui/tags/panel/table/menu.py
+++ b/todo/gui/tags/panel/table/menu.py
@@ -31,5 +31,5 @@ def open(table, update_tag_signal, position):
row = list(rows)[0]
tag = table.model().get_at(row)
todo.gui.tags.panel.dialog.update(table, update_tag_signal, row, tag).exec_()
- elif action == delete_action:
+ elif action == delete_action and len(rows) > 0:
todo.gui.tags.panel.dialog.confirm_delete(table, rows)
diff --git a/todo/gui/tags/panel/table/model.py b/todo/gui/tags/panel/table/model.py
index 6f9d71a..0112b03 100644
--- a/todo/gui/tags/panel/table/model.py
+++ b/todo/gui/tags/panel/table/model.py
@@ -10,7 +10,7 @@ import todo.util.range
columns = 1
-headers = ["Name", "Color"]
+headers = ["Nom", "Couleur"]
default_sort = (0, Qt.AscendingOrder)
diff --git a/todo/gui/tags/panel/table/widget.py b/todo/gui/tags/panel/table/widget.py
index 1d10c73..dc2f1c5 100644
--- a/todo/gui/tags/panel/table/widget.py
+++ b/todo/gui/tags/panel/table/widget.py
@@ -62,7 +62,7 @@ class Widget(QtWidgets.QTableView):
elif event.key() == Qt.Key_Delete:
rows = self.get_selected_rows()
tags = self.model().row_ids(rows)
- if not todo.db.task_tags.one_is_used(todo.database.cursor(), tags):
+ if not todo.db.task_tags.one_is_used(todo.database.cursor(), tags) and len(rows) > 0:
todo.gui.tags.panel.dialog.confirm_delete(self, rows)
def get_selected_rows(self):
diff --git a/todo/gui/tags/panel/widget.py b/todo/gui/tags/panel/widget.py
index 071442e..675b0ff 100644
--- a/todo/gui/tags/panel/widget.py
+++ b/todo/gui/tags/panel/widget.py
@@ -15,7 +15,7 @@ def widget(parent):
add_tag_signal = todo.gui.tags.panel.signal.AddTag()
- add_tag_button = QtWidgets.QPushButton(" Add a tag", widget)
+ add_tag_button = QtWidgets.QPushButton(" Ajouter une étiquette", widget)
add_tag_button.setFixedHeight(30)
add_tag_button.setIcon(todo.gui.icon.new_folder(widget.style()))