Skip to content

Commit

Permalink
Glossary popup title and description, closes #1441
Browse files Browse the repository at this point in the history
  • Loading branch information
zkovari committed Oct 16, 2024
1 parent 61a10f2 commit 15f5d1e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/main/python/plotlyst/view/widget/world/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from plotlyst.model.common import SelectionItemsModel, proxy
from plotlyst.service.persistence import RepositoryPersistenceManager
from plotlyst.view.common import push_btn, label
from plotlyst.view.layout import group
from plotlyst.view.widget.display import PopupDialog
from plotlyst.view.widget.input import AbstractTextBlockHighlighter
from plotlyst.view.widget.items_editor import ItemsEditorWidget
Expand Down Expand Up @@ -195,6 +196,17 @@ def __init__(self, glossary: Dict[str, GlossaryItem], term: Optional[GlossaryIte
self._glossary = glossary
self._term = term

self.title = label('Edit glossary item' if glossary else 'Add glossary item', h4=True)
sp(self.title).v_max()
self.wdgTitle = QWidget()
hbox(self.wdgTitle)
self.wdgTitle.layout().addWidget(self.title, alignment=Qt.AlignmentFlag.AlignLeft)
self.wdgTitle.layout().addWidget(self.btnReset, alignment=Qt.AlignmentFlag.AlignRight)

self.lblDesc = label("Define terms and definitions that are specific to your fictional world.",
description=True, wordWrap=True)
sp(self.lblDesc).v_max()

self.lineKey = QLineEdit()
self.lineKey.setProperty('white-bg', True)
self.lineKey.setProperty('rounded', True)
Expand All @@ -211,26 +223,25 @@ def __init__(self, glossary: Dict[str, GlossaryItem], term: Optional[GlossaryIte
self.textDefinition.setProperty('rounded', True)
self.textDefinition.setPlaceholderText('Define term')

self.wdgTitle = QWidget()
hbox(self.wdgTitle)
self.wdgTitle.layout().addWidget(self.btnReset, alignment=Qt.AlignmentFlag.AlignRight)

self.btnConfirm = push_btn(text='Confirm', properties=['confirm', 'positive'])
sp(self.btnConfirm).h_exp()
self.btnConfirm.clicked.connect(self._confirm)
self.btnConfirm.setDisabled(True)
self.btnConfirm.installEventFilter(
DisabledClickEventFilter(self.btnConfirm, lambda: qtanim.shake(self.lineKey)))
self.btnCancel = push_btn(text='Cancel', properties=['confirm', 'cancel'])
self.btnCancel.clicked.connect(self.reject)

if self._term:
self.lineKey.setText(self._term.key)
self.textDefinition.setMarkdown(self._term.text)

self.frame.layout().addWidget(self.wdgTitle)
self.frame.layout().addWidget(self.lblDesc)
self.frame.layout().addWidget(self.lineKey)
self.frame.layout().addWidget(self.lblError)
self.frame.layout().addWidget(self.textDefinition)
self.frame.layout().addWidget(self.btnConfirm)
self.frame.layout().addWidget(group(self.btnCancel, self.btnConfirm), alignment=Qt.AlignmentFlag.AlignRight)

def display(self) -> GlossaryItem:
result = self.exec()
Expand Down

0 comments on commit 15f5d1e

Please sign in to comment.