From 2b479fae26b7446f9269223d1e1fb4073839f5cc Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 10 May 2020 14:43:24 +0200 Subject: Improve difficulty and priority reading --- src/gui/color.py | 9 +++++---- src/gui/icon.py | 16 ++++++++++++++++ src/gui/icons.py | 16 ---------------- src/gui/tasks/form/widget.py | 10 +++++----- src/gui/tasks/table/menu.py | 4 ++-- src/gui/tasks/table/model.py | 16 ++++++++-------- src/gui/tasks/widget.py | 4 ++-- 7 files changed, 38 insertions(+), 37 deletions(-) create mode 100644 src/gui/icon.py delete mode 100644 src/gui/icons.py (limited to 'src/gui') diff --git a/src/gui/color.py b/src/gui/color.py index dcb21ea..fa7df8e 100644 --- a/src/gui/color.py +++ b/src/gui/color.py @@ -1,13 +1,14 @@ from PyQt5 import QtGui red: QtGui.QColor = QtGui.QColor(200, 30, 30) +orange: QtGui.QColor = QtGui.QColor(200, 100, 30) green: QtGui.QColor = QtGui.QColor(30, 180, 30) blue: QtGui.QColor = QtGui.QColor(30, 30, 200) -low_difficulty = green -medium_difficulty = blue -high_difficulty = red +easy_difficulty = green +normal_difficulty = orange +hard_difficulty = red low_priority = green -medium_priority = blue +middle_priority = orange high_priority = red diff --git a/src/gui/icon.py b/src/gui/icon.py new file mode 100644 index 0000000..2f8830e --- /dev/null +++ b/src/gui/icon.py @@ -0,0 +1,16 @@ +from PyQt5 import QtWidgets + +def new_folder(style): + return style.standardIcon(QtWidgets.QStyle.SP_FileDialogNewFolder) + +def dialog_open(style): + return style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) + +def dialog_apply(style): + return style.standardIcon(QtWidgets.QStyle.SP_DialogApplyButton) + +def dialog_cancel(style): + return style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) + +def trash(style): + return style.standardIcon(QtWidgets.QStyle.SP_TrashIcon) diff --git a/src/gui/icons.py b/src/gui/icons.py deleted file mode 100644 index 2f8830e..0000000 --- a/src/gui/icons.py +++ /dev/null @@ -1,16 +0,0 @@ -from PyQt5 import QtWidgets - -def new_folder(style): - return style.standardIcon(QtWidgets.QStyle.SP_FileDialogNewFolder) - -def dialog_open(style): - return style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton) - -def dialog_apply(style): - return style.standardIcon(QtWidgets.QStyle.SP_DialogApplyButton) - -def dialog_cancel(style): - return style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton) - -def trash(style): - return style.standardIcon(QtWidgets.QStyle.SP_TrashIcon) diff --git a/src/gui/tasks/form/widget.py b/src/gui/tasks/form/widget.py index 846ce90..adaf757 100644 --- a/src/gui/tasks/form/widget.py +++ b/src/gui/tasks/form/widget.py @@ -4,7 +4,7 @@ from typing import Optional, Tuple, List, Any import db.tasks from model.task import Task, ValidTaskForm from model import difficulty, priority -import gui.icons +import gui.icon import gui.tasks.form.state import gui.tasks.duration @@ -45,7 +45,7 @@ def widget( init_tag = task.tag if task is not None else '' tag_input = line_edit(grid, grid_layout, 2, 'Tag', init_tag) - init_difficulty = task.difficulty if task is not None else difficulty.Difficulty.MEDIUM + init_difficulty = task.difficulty if task is not None else difficulty.Difficulty.NORMAL difficulty_input = combo_box( grid, grid_layout, @@ -54,7 +54,7 @@ def widget( [difficulty.format(d) for d in difficulty.values], int(init_difficulty)) - init_priority = task.priority if task is not None else priority.Priority.MEDIUM + init_priority = task.priority if task is not None else priority.Priority.MIDDLE priority_input = combo_box( grid, grid_layout, @@ -160,7 +160,7 @@ def buttons(parent, action_title, task_form_signal, on_validate, on_cancel): validate = QtWidgets.QPushButton(action_title, widget) validate.setDisabled(True) - validate.setIcon(gui.icons.dialog_apply(validate.style())) + validate.setIcon(gui.icon.dialog_apply(validate.style())) validate.clicked.connect(on_validate); layout.addWidget(validate) @@ -173,7 +173,7 @@ def buttons(parent, action_title, task_form_signal, on_validate, on_cancel): task_form_signal.connect(on_task_form_signal) cancel = QtWidgets.QPushButton('cancel', widget) - cancel.setIcon(gui.icons.dialog_cancel(cancel.style())) + cancel.setIcon(gui.icon.dialog_cancel(cancel.style())) cancel.clicked.connect(on_cancel) layout.addWidget(cancel) diff --git a/src/gui/tasks/table/menu.py b/src/gui/tasks/table/menu.py index 51f7330..edc9833 100644 --- a/src/gui/tasks/table/menu.py +++ b/src/gui/tasks/table/menu.py @@ -10,11 +10,11 @@ def open(database, table, update_task_signal, position): menu = QtWidgets.QMenu(table) if len(rows) == 1: - modify_action = menu.addAction(gui.icons.dialog_open(menu.style()), 'modify') + modify_action = menu.addAction(gui.icon.dialog_open(menu.style()), 'modify') else: modify_action = QtWidgets.QAction(menu) - delete_action = menu.addAction(gui.icons.trash(menu.style()), 'Delete') + delete_action = menu.addAction(gui.icon.trash(menu.style()), 'Delete') action = menu.exec_(table.mapToGlobal(position)) if action == modify_action and len(rows) == 1: diff --git a/src/gui/tasks/table/model.py b/src/gui/tasks/table/model.py index 5013569..062ded6 100644 --- a/src/gui/tasks/table/model.py +++ b/src/gui/tasks/table/model.py @@ -139,17 +139,17 @@ def is_reversed(row: int, order: Qt.SortOrder) -> bool: return order == Qt.DescendingOrder def difficulty_color(d: Difficulty) -> QtGui.QColor: - if d == Difficulty.LOW: - return gui.color.low_difficulty - elif d == Difficulty.MEDIUM: - return gui.color.medium_difficulty - elif d == Difficulty.HIGH: - return gui.color.high_difficulty + if d == Difficulty.EASY: + return gui.color.easy_difficulty + elif d == Difficulty.NORMAL: + return gui.color.normal_difficulty + elif d == Difficulty.HARD: + return gui.color.hard_difficulty def priority_color(p: Priority) -> QtGui.QColor: if p == Priority.LOW: return gui.color.low_priority - elif p == Priority.MEDIUM: - return gui.color.medium_priority + elif p == Priority.MIDDLE: + return gui.color.middle_priority elif p == Priority.HIGH: return gui.color.high_priority diff --git a/src/gui/tasks/widget.py b/src/gui/tasks/widget.py index 0462f54..61ad605 100644 --- a/src/gui/tasks/widget.py +++ b/src/gui/tasks/widget.py @@ -2,7 +2,7 @@ from PyQt5 import QtWidgets, QtCore import gui.tasks.signal import gui.tasks.table.widget -import gui.icons +import gui.icon from model.task import ValidTaskForm def widget(database, parent): @@ -14,7 +14,7 @@ def widget(database, parent): add_task_signal = gui.tasks.signal.AddTask() add_task_button = QtWidgets.QPushButton('Add a task', widget) - add_task_button.setIcon(gui.icons.new_folder(widget.style())) + add_task_button.setIcon(gui.icon.new_folder(widget.style())) add_task_button.clicked.connect(lambda: gui.tasks.dialog.add( database, widget, add_task_signal).exec_()) layout.addWidget(add_task_button) -- cgit v1.2.3