Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
zkovari committed Sep 25, 2024
1 parent 45715db commit 550e4f3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 31 deletions.
58 changes: 37 additions & 21 deletions src/main/python/plotlyst/view/roadmap_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,47 @@

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):

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)
Expand All @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 12 additions & 9 deletions src/main/python/plotlyst/view/widget/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()):
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion ui/roadmap_view.ui
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>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</string>
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down Expand Up @@ -338,6 +338,9 @@
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<property name="framed" stdset="0">
<bool>true</bool>
</property>
<widget class="QWidget" name="wdgCategoriesParent" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
Expand Down

0 comments on commit 550e4f3

Please sign in to comment.