diff --git a/src/main/python/plotlyst/view/roadmap_view.py b/src/main/python/plotlyst/view/roadmap_view.py index 878f39092..cc1bd457f 100644 --- a/src/main/python/plotlyst/view/roadmap_view.py +++ b/src/main/python/plotlyst/view/roadmap_view.py @@ -22,19 +22,31 @@ from PyQt6.QtCore import QEvent, QThreadPool, QSize, Qt from PyQt6.QtGui import QFont -from PyQt6.QtWidgets import QWidget, QSizePolicy, QFrame, QLineEdit +from PyQt6.QtWidgets import QWidget, QSizePolicy, QFrame from overrides import overrides -from qthandy import clear_layout, hbox, spacer, margins, vbox, incr_font, retain_when_hidden +from qthandy import clear_layout, hbox, spacer, margins, vbox, incr_font, retain_when_hidden, decr_icon, translucent +from qthandy.filter import VisibilityToggleEventFilter from plotlyst.common import PLOTLYST_SECONDARY_COLOR from plotlyst.core.domain import Board, Task +from plotlyst.core.template import SelectionItem from plotlyst.env import app_env from plotlyst.service.resource import JsonDownloadWorker, JsonDownloadResult -from plotlyst.view.common import push_btn, spin, shadow +from plotlyst.view.common import push_btn, spin, shadow, tool_btn from plotlyst.view.generated.roadmap_view_ui import Ui_RoadmapView from plotlyst.view.icons import IconRegistry +from plotlyst.view.layout import group +from plotlyst.view.widget.input import AutoAdjustableLineEdit from plotlyst.view.widget.task import BaseStatusColumnWidget +tag_character = SelectionItem('character', icon='fa5s.user', icon_color='darkBlue') +tag_milieu = SelectionItem('milieu', icon='mdi.globe-model', icon_color='#2d6a4f') +tag_scene = SelectionItem('scene', icon='mdi.movie-open', icon_color=PLOTLYST_SECONDARY_COLOR) + +task_tags: Dict[str, SelectionItem] = {} +for tag in [tag_character, tag_milieu, tag_scene]: + task_tags[tag.text] = tag + class RoadmapTaskWidget(QFrame): @@ -42,12 +54,15 @@ def __init__(self, task: Task, parent=None): super().__init__(parent) self._task: Task = task + self.setProperty('relaxed-white-bg', True) + self.setProperty('rounded', True) + vbox(self, margin=5) self.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Maximum) self.setMinimumHeight(75) shadow(self, 3) - self._lineTitle = QLineEdit(self) + self._lineTitle = AutoAdjustableLineEdit(self, defaultWidth=100) self._lineTitle.setPlaceholderText('New task') self._lineTitle.setText(task.title) self._lineTitle.setFrame(False) @@ -57,13 +72,26 @@ def __init__(self, task: Task, parent=None): self._lineTitle.setFont(font) incr_font(self._lineTitle) - # top_wdg = group(self._lineTitle, spacer(), self._charSelector, margin=0, spacing=1) - self.layout().addWidget(self._lineTitle, alignment=Qt.AlignmentFlag.AlignTop) + self._btnOpenInExternal = tool_btn(IconRegistry.from_name('fa5s.external-link-alt', 'grey'), transparent_=True, + tooltip='Open in browser') + retain_when_hidden(self._btnOpenInExternal) + decr_icon(self._btnOpenInExternal, 4) + + top_wdg = group(self._lineTitle, spacer(), self._btnOpenInExternal, margin=0, spacing=1) + self.layout().addWidget(top_wdg, alignment=Qt.AlignmentFlag.AlignTop) self._wdgBottom = QWidget() retain_when_hidden(self._wdgBottom) hbox(self._wdgBottom) + for tag_name in self._task.tags: + tag = task_tags.get(tag_name) + if tag: + btn = tool_btn(IconRegistry.from_name(tag.icon, tag.icon_color), transparent_=True) + decr_icon(btn, 4) + translucent(btn, 0.7) + self._wdgBottom.layout().addWidget(btn) + # self._btnTags = TaskTagSelector(self._wdgBottom) # self._btnTags.tagSelected.connect(self._tagChanged) @@ -77,21 +105,7 @@ def __init__(self, task: Task, parent=None): # else: # self._btnTags.setHidden(True) - # self.installEventFilter(self) - - # @overrides - # def eventFilter(self, watched: QObject, event: QEvent) -> bool: - # if event.type() == QEvent.Type.Enter: - # if not self._task.character_id: - # self._charSelector.setVisible(True) - # self._btnMenu.setVisible(True) - # self._btnResolve.setVisible(True) - # self._btnTags.setVisible(True) - # elif event.type() == QEvent.Type.Leave: - # if any_menu_visible(self._charSelector, self._btnMenu, self._btnTags): - # return True - # self._onLeave() - # return super(TaskWidget, self).eventFilter(watched, event) + self.installEventFilter(VisibilityToggleEventFilter(self._btnOpenInExternal, self)) def task(self) -> Task: return self._task @@ -139,6 +153,8 @@ def __init__(self, parent=None): self.btnRoadmapIcon.setIcon(IconRegistry.from_name('fa5s.road')) self.btnPlus.setIcon(IconRegistry.from_name('mdi.certificate', color_on=PLOTLYST_SECONDARY_COLOR)) + self.splitter.setSizes([150, 550]) + self._last_fetched = None self._downloading = False self._board: Optional[Board] = None diff --git a/src/main/python/plotlyst/view/widget/task.py b/src/main/python/plotlyst/view/widget/task.py index fabf147ef..0262942f8 100644 --- a/src/main/python/plotlyst/view/widget/task.py +++ b/src/main/python/plotlyst/view/widget/task.py @@ -31,7 +31,7 @@ from qtmenu import MenuWidget from plotlyst.common import RELAXED_WHITE_COLOR -from plotlyst.core.domain import TaskStatus, Task, Novel, Character, task_tags, Board +from plotlyst.core.domain import TaskStatus, Task, Novel, Character, task_tags from plotlyst.core.template import SelectionItem from plotlyst.env import app_env from plotlyst.event.core import Event, emit_event @@ -40,7 +40,7 @@ TaskChangedFromWip from plotlyst.service.persistence import RepositoryPersistenceManager from plotlyst.view.common import ButtonPressResizeEventFilter, shadow, action, tool_btn, \ - any_menu_visible + any_menu_visible, insert_before_the_end from plotlyst.view.icons import IconRegistry from plotlyst.view.layout import group from plotlyst.view.widget.button import CollapseButton, TaskTagSelector @@ -245,13 +245,16 @@ def __init__(self, status: TaskStatus, parent=None): vbox(self, 1, 20) self._header = _StatusHeader(self._status) self._header.collapseToggled.connect(self._collapseToggled) - self._container = QWidget(self) + self._container = QFrame(self) + self._container.setProperty('darker-bg', True) + self._container.setProperty('rounded', True) spacing = 6 if app_env.is_mac() else 12 - vbox(self._container, margin=5, spacing=spacing) + vbox(self._container, margin=10, spacing=spacing) + self._container.layout().addWidget(vspacer()) + self.setMaximumWidth(TASK_WIDGET_MAX_WIDTH) self.layout().addWidget(self._header) self.layout().addWidget(self._container) - self.layout().addWidget(vspacer()) def _collapseToggled(self, toggled: bool): for i in range(self._container.layout().count()): @@ -277,7 +280,7 @@ def __init__(self, novel: Novel, status: TaskStatus, parent=None): self._btnAdd.installEventFilter(ButtonPressResizeEventFilter(self._btnAdd)) self._btnAdd.installEventFilter(OpacityEventFilter(self._btnAdd)) - self._container.layout().addWidget(self._btnAdd, alignment=Qt.AlignmentFlag.AlignLeft) + insert_before_the_end(self._container, self._btnAdd, alignment=Qt.AlignmentFlag.AlignLeft) self.installEventFilter(VisibilityToggleEventFilter(self._btnAdd, self)) self.setAcceptDrops(True) @@ -306,7 +309,7 @@ def status(self) -> TaskStatus: def addTask(self, task: Task, edit: bool = False) -> TaskWidget: wdg = TaskWidget(task, self) - self._container.layout().insertWidget(self._container.layout().count() - 1, wdg, + self._container.layout().insertWidget(self._container.layout().count() - 2, wdg, alignment=Qt.AlignmentFlag.AlignTop) wdg.installEventFilter( DragEventFilter(self, mimeType=TASK_MIME_TYPE, dataFunc=self._grabbedTaskData, @@ -322,7 +325,7 @@ def addTask(self, task: Task, edit: bool = False) -> TaskWidget: if self._status.wip: emit_event(self._novel, TaskChangedToWip(self, task)) - self._header.updateTitle(self._container.layout().count() - 1) + self._header.updateTitle(self._container.layout().count() - 2) return wdg def _addNewTask(self): @@ -371,7 +374,7 @@ def __removeTaskWidget(self, taskWidget): taskWidget.setHidden(True) self._container.layout().removeWidget(taskWidget) gc(taskWidget) - self._header.updateTitle(self._container.layout().count() - 1) + self._header.updateTitle(self._container.layout().count() - 2) class BoardWidget(QWidget): diff --git a/ui/roadmap_view.ui b/ui/roadmap_view.ui index 46550021e..c526f4e5f 100644 --- a/ui/roadmap_view.ui +++ b/ui/roadmap_view.ui @@ -111,7 +111,7 @@ - Planned, in-progress, and done tasks for the Free and Plotlyst Plus versions. Beta: not yet released but currently available features in the Beta version + Planned, in-progress, and completed tasks for both the Free and Plotlyst Plus versions. Beta: upcoming features that are currently available in the Beta version. true @@ -338,6 +338,9 @@ false + + true +