Skip to content

Commit

Permalink
Node highlight for dnd
Browse files Browse the repository at this point in the history
  • Loading branch information
zkovari committed Jul 24, 2023
1 parent 4b29e94 commit 94c0199
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/python/plotlyst/view/widget/doc/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def _dragMovedOnDoc(self, wdg: DocumentWidget, edge: Qt.Edge, point: QPointF):
else:
wdg.parent().layout().insertWidget(i + 1, self._dummyWdg)

self._dummyWdg.highlightBorder()
self._dummyWdg.setVisible(True)

def _drop(self, mimeData: QMimeData):
Expand Down
23 changes: 19 additions & 4 deletions src/main/python/plotlyst/view/widget/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from qthandy import vbox, hbox, bold, margins, clear_layout, transparent, retain_when_hidden, incr_font
from qtmenu import MenuWidget

from src.main.python.plotlyst.common import PLOTLYST_MAIN_COLOR
from src.main.python.plotlyst.view.common import ButtonPressResizeEventFilter, action
from src.main.python.plotlyst.view.dialog.utility import IconSelectorDialog
from src.main.python.plotlyst.view.icons import IconRegistry
Expand Down Expand Up @@ -123,6 +124,12 @@ def setPlusMenu(self, menu: MenuWidget):
self._btnAddPressFilter = ButtonPressResizeEventFilter(self._btnAdd)
self._btnAdd.installEventFilter(self._btnAddPressFilter)

def highlightBorder(self):
self._reStyle(highlightBorder=True)

def clearHighlight(self):
self._reStyle()

def _toggleSelection(self, selected: bool):
self._selected = selected
bold(self._lblTitle, self._selected)
Expand All @@ -143,13 +150,21 @@ def _hideAll(self):
self._btnMenu.setHidden(True)
self._btnAdd.setHidden(True)

def _reStyle(self):
def _reStyle(self, highlightBorder: bool = False):
border = f'border-top: 4px solid {PLOTLYST_MAIN_COLOR};' if highlightBorder else ''
if self._selected:
self._wdgTitle.setStyleSheet('''
#wdgTitle {
self._wdgTitle.setStyleSheet(f'''
#wdgTitle {{
background-color: #D8D5D5;
}
{border}
}}
''')
elif border:
self._wdgTitle.setStyleSheet(f'''
#wdgTitle {{
{border}
}}
''')
else:
self._wdgTitle.setStyleSheet('')

Expand Down

0 comments on commit 94c0199

Please sign in to comment.