Skip to content

Commit

Permalink
Merge pull request #19 from nodedge/feature/palette
Browse files Browse the repository at this point in the history
Add palette viewer.
  • Loading branch information
nodedge committed Nov 21, 2022
2 parents 880bc84 + dceb51e commit 1a0f0c1
Show file tree
Hide file tree
Showing 391 changed files with 551 additions and 65 deletions.
8 changes: 4 additions & 4 deletions .idea/nodedge.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/runConfigurations/Run_tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .idea/runConfigurations/dats.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions .idea/runConfigurations/nodedge.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ include mypy.ini
include .bumpversion.cfg
include CODE_OF_CONDUCT.md
include logging.yaml
include deploy.py

include .flake8
include .isort.cfg
Expand All @@ -22,7 +23,6 @@ include pytest.ini
include .coveragerc

recursive-include nodedge/qss *
recursive-include nodedge/resources *
recursive-include tests *
recursive-include examples *
recursive-include tools *
Expand Down Expand Up @@ -53,3 +53,11 @@ recursive-include docs *.png
recursive-include docs *.txt
include SECURITY.md
include docs/CNAME

recursive-include nodedge/resources *
recursive-include resources *.ico
recursive-include resources *.png
recursive-include resources *.psd
recursive-include resources *.py
recursive-include resources *.qss
recursive-include resources *.yml
Empty file added components/__init__.py
Empty file.
123 changes: 123 additions & 0 deletions components/flow_layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Copyright (C) 2013 Riverbank Computing Limited.
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

"""PySide6 port of the widgets/layouts/flowlayout example from Qt v6.x"""

import sys

from PySide6.QtCore import QMargins, QPoint, QRect, QSize, Qt
from PySide6.QtWidgets import QApplication, QLayout, QPushButton, QSizePolicy, QWidget


class Window(QWidget):
def __init__(self):
super().__init__()

flow_layout = FlowLayout(self)
flow_layout.addWidget(QPushButton("Short"))
flow_layout.addWidget(QPushButton("Longer"))
flow_layout.addWidget(QPushButton("Different text"))
flow_layout.addWidget(QPushButton("More text"))
flow_layout.addWidget(QPushButton("Even longer button text"))

self.setWindowTitle("Flow Layout")


class FlowLayout(QLayout):
def __init__(self, parent=None):
super().__init__(parent)

if parent is not None:
self.setContentsMargins(QMargins(0, 0, 0, 0))

self._item_list = []

def __del__(self):
item = self.takeAt(0)
while item:
item = self.takeAt(0)

def addItem(self, item):
self._item_list.append(item)

def count(self):
return len(self._item_list)

def itemAt(self, index):
if 0 <= index < len(self._item_list):
return self._item_list[index]

return None

def takeAt(self, index):
if 0 <= index < len(self._item_list):
return self._item_list.pop(index)

return None

def expandingDirections(self):
return Qt.Orientation(0)

def hasHeightForWidth(self):
return True

def heightForWidth(self, width):
height = self._do_layout(QRect(0, 0, width, 0), True)
return height

def setGeometry(self, rect):
super(FlowLayout, self).setGeometry(rect)
self._do_layout(rect, False)

def sizeHint(self):
return self.minimumSize()

def minimumSize(self):
size = QSize()

for item in self._item_list:
size = size.expandedTo(item.minimumSize())

size += QSize(
2 * self.contentsMargins().top(), 2 * self.contentsMargins().top()
)
return size

def _do_layout(self, rect, test_only):
x = rect.x()
y = rect.y()
line_height = 0
spacing = self.spacing()

for item in self._item_list:
style = item.widget().style()
layout_spacing_x = style.layoutSpacing(
QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Horizontal
)
layout_spacing_y = style.layoutSpacing(
QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Vertical
)
space_x = spacing + layout_spacing_x
space_y = spacing + layout_spacing_y
next_x = x + item.sizeHint().width() + space_x
if next_x - space_x > rect.right() and line_height > 0:
x = rect.x()
y = y + line_height + space_y
next_x = x + item.sizeHint().width() + space_x
line_height = 0

if not test_only:
item.setGeometry(QRect(QPoint(x, y), item.sizeHint()))

x = next_x
line_height = max(line_height, item.sizeHint().height())

return y + line_height - rect.y()


if __name__ == "__main__":
app = QApplication(sys.argv)
main_win = Window()
main_win.show()
sys.exit(app.exec())
13 changes: 13 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ ignore_missing_imports = True
[mypy-numpy.*]
ignore_missing_imports = True

[mypy-pyqtgraph.*]
ignore_missing_imports = True


[mypy-h5py.*]
ignore_missing_imports = True

[mypy-asammdf.*]
ignore_missing_imports = True

[mypy-pandas.*]
ignore_missing_imports = True

;
;disallow_untyped_calls = True
;disallow_untyped_defs = True
Expand Down
61 changes: 34 additions & 27 deletions nodedge/application_styler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
"""

import logging
import os

# import pyqtconsole.highlighter as hl
import yaml
from PySide6.QtGui import QColor, QGuiApplication, QPalette
from PySide6.QtWidgets import QApplication

from nodedge.logger import logger


class ApplicationStyler:
""":class:`~nodedge.application_styler.ApplicationStyler` class ."""
Expand All @@ -21,33 +24,37 @@ def __init__(self):
app = QGuiApplication.instance()

QApplication.setStyle("Fusion")
logger.debug(os.getcwd())

with open("resources/palette/dark_palette.yml", "r") as file:
colors = yaml.safe_load(file)
p = QApplication.palette()
raisinBlackDark = QColor("#1B1D23")
raisinBlackLight = QColor("#272C36")
raisinBlackMid = QColor("#23252E")
charCoal = QColor("#363A46")
independence = QColor("#464B5B")
white = QColor("#DDFFFFFF")
blue = QColor("#007BFF")
spanishGray = QColor("#8791AF")
dimGray = QColor("#6C748C")
p.setColor(QPalette.AlternateBase, blue)
p.setColor(QPalette.Base, charCoal)
p.setColor(QPalette.BrightText, blue)
p.setColor(QPalette.Button, raisinBlackDark)
p.setColor(QPalette.ButtonText, white)
p.setColor(QPalette.Dark, raisinBlackDark)
p.setColor(QPalette.Highlight, blue)
p.setColor(QPalette.HighlightedText, white)
p.setColor(QPalette.Light, independence)
p.setColor(QPalette.Link, spanishGray)
p.setColor(QPalette.LinkVisited, dimGray)
p.setColor(QPalette.Mid, raisinBlackMid)
p.setColor(QPalette.Midlight, raisinBlackLight)
p.setColor(QPalette.Shadow, independence)
p.setColor(QPalette.Text, white)
p.setColor(QPalette.Window, charCoal)
p.setColor(QPalette.WindowText, white)
dark = QColor(colors["dark"])
midLight = QColor(colors["midLight"])
mid = QColor(colors["mid"])
base = QColor(colors["base"])
light = QColor(colors["light"])
text = QColor(colors["text"])
highlight = QColor(colors["highlight"])
link = QColor(colors["link"])
visitedLink = QColor(colors["visitedLink"])
p.setColor(QPalette.AlternateBase, highlight)
p.setColor(QPalette.Base, base)
p.setColor(QPalette.BrightText, highlight)
p.setColor(QPalette.Button, dark)
p.setColor(QPalette.ButtonText, text)
p.setColor(QPalette.Dark, dark)
p.setColor(QPalette.Highlight, highlight)
p.setColor(QPalette.HighlightedText, text)
p.setColor(QPalette.Light, light)
p.setColor(QPalette.Link, link)
p.setColor(QPalette.LinkVisited, visitedLink)
p.setColor(QPalette.Mid, mid)
p.setColor(QPalette.Midlight, midLight)
p.setColor(QPalette.Shadow, light)
p.setColor(QPalette.Text, text)
p.setColor(QPalette.Window, base)
p.setColor(QPalette.WindowText, text)
app.setPalette(p)

# self.consoleStyle = {
Expand Down
2 changes: 1 addition & 1 deletion nodedge/blocks/block_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# BlockType = TypeVar("BlockType", bound=Block)
BLOCKS: Dict[int, type] = {}

BLOCKS_ICONS_PATH = f"{os.path.dirname(__file__)}/../resources/node_icons"
BLOCKS_ICONS_PATH = f"{os.path.dirname(__file__)}/../../resources/node_icons"


# Way to register by function call
Expand Down
6 changes: 3 additions & 3 deletions nodedge/dats/logs_list_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, parent=None):

self.logs = {}

self.itemClicked.connect(self.onItemClicked) # type: ignore
self.itemClicked.connect(self.onItemClicked)

def addLog(self, filename) -> Optional[MDF]:
shortname = filename.split("/")[-1]
Expand Down Expand Up @@ -50,10 +50,10 @@ def addLog(self, filename) -> Optional[MDF]:
item.setToolTip(startTimeStr)
self.addItem(item)

self.logSelected.emit(log) # type: ignore
self.logSelected.emit(log)
self.setCurrentItem(item)

return log

def onItemClicked(self, item):
self.logSelected.emit(self.logs[item.text()]) # type: ignore
self.logSelected.emit(self.logs[item.text()])

0 comments on commit 1a0f0c1

Please sign in to comment.