Skip to content

Commit

Permalink
Fix tests and add icons
Browse files Browse the repository at this point in the history
  • Loading branch information
don4get committed Jun 21, 2020
1 parent 9db51e5 commit 49168fd
Show file tree
Hide file tree
Showing 167 changed files with 321 additions and 27 deletions.
8 changes: 4 additions & 4 deletions nodedge/edge_validators.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
"""Edge validators module containing the Edge Validator functions which can be
registered as callbacks to :class:`~nodedge.edge.Edge` class.
"""Edge validators module containing the Edge Validator functions which can be
registered as callbacks to :class:`~nodedge.edge.Edge` class.
Example of registering Edge Validator callbacks:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can register validation callbacks once for example on the bottom of node_edge.py
file or on the application start with calling this:
You can register validation callbacks once for example on the bottom of node_edge.py
file or on the application start with calling this:
.. code-block:: python
Expand Down
74 changes: 57 additions & 17 deletions nodedge/graphics_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
class.
"""

from typing import Optional, Union

from PyQt5.QtCore import QRectF, Qt
from PyQt5.QtGui import QBrush, QColor, QPen
from PyQt5.QtWidgets import QGraphicsItem
from PyQt5.QtGui import QBrush, QColor, QPainter, QPen
from PyQt5.QtWidgets import (
QGraphicsItem,
QGraphicsSceneHoverEvent,
QStyleOptionGraphicsItem,
QWidget,
)

SOCKET_COLORS = [
QColor("#FFFF7700"),
Expand Down Expand Up @@ -39,14 +46,15 @@ def __init__(self, socket: "Socket") -> None: # type: ignore

self.initUI()

self.isHighlighted = False
self.hovered = False

def initUI(self) -> None:
"""
Setup this ``QGraphicsItem``.
"""
self.initSizes()
self.initStyle()
self.setAcceptHoverEvents(True)

# noinspection PyAttributeOutsideInit
def initStyle(self) -> None:
Expand All @@ -55,47 +63,60 @@ def initStyle(self) -> None:
"""
self._colorBackground: QColor = getSocketColor(self.socketType)
self._colorOutline: QColor = QColor("#FF000000")
self._colorHighlight: QColor = QColor("#FF37A6FF")
self._colorHovered: QColor = QColor("#FF37A6FF")

self._pen: QPen = QPen(self._colorOutline)
self._pen.setWidthF(self.outlineWidth)
self._brush: QBrush = QBrush(self._colorBackground)
self._penHighlight: QPen = QPen(self._colorHighlight)
self._penHighlight.setWidthF(2.0)
self._penHovered: QPen = QPen(self._colorHovered)
self._penHovered.setWidthF(2.0)

# noinspection PyAttributeOutsideInit
def initSizes(self) -> None:
"""
Set up internal attributes like `width`, `height`, etc.
"""
self.radius = 6.0
self.radius: int = 6
self.outlineWidth = 1.0

@property
def socketType(self):
return self.socket.socketType
def socketType(self) -> int:
"""
:return: socket type
:rtype: ``int``
"""
return int(self.socket.socketType)

# noinspection PyAttributeOutsideInit
def updateSocketType(self):
def updateSocketType(self) -> None:
"""Change the Socket Type."""
self._colorBackground = getSocketColor(self.socketType)
self._brush = QBrush(self._colorBackground)
self.update()

def paint(self, painter, QStyleOptionGraphicsItem, widget=None):
def paint(
self,
painter: QPainter,
options: QStyleOptionGraphicsItem,
widget: Optional[QWidget] = None,
):
"""
Paint a circle.
"""
painter.setBrush(self._brush)
painter.setPen(self._pen if not self.isHighlighted else self._penHighlight)
painter.setPen(self._pen if not self.hovered else self._penHovered)

painter.drawEllipse(
-self.radius, -self.radius, 2 * self.radius, 2 * self.radius
)

def boundingRect(self):
def boundingRect(self) -> QRectF:
"""
Define Qt's bounding rectangle.
:return: Graphics socket bounding rectangle.
:rtype: ``QRectF``
"""
return QRectF(
-self.radius - self.outlineWidth,
Expand All @@ -104,11 +125,30 @@ def boundingRect(self):
2 * (self.radius + self.outlineWidth),
)

def hoverEnterEvent(self, event: QGraphicsSceneHoverEvent) -> None:
"""
Overridden Qt's slot to handle mouse hovering on the edge.
:param event: Qt's mouse hover event
:type event: ``QGraphicsSceneHoverEvent``
"""
self.hovered = True
self.update()

def hoverLeaveEvent(self, event: QGraphicsSceneHoverEvent) -> None:
"""
Overridden Qt's slot to handle mouse hovering's end on the edge.
:param event: Qt's mouse hover event
:type event: ``QGraphicsSceneHoverEvent``
"""
self.hovered = False
self.update()


def getSocketColor(key):
def getSocketColor(key: Union[int, str]) -> QColor:
"""Returns the ``QColor`` for this ``key``."""
if type(key) == int:
if isinstance(key, int):
return SOCKET_COLORS[key]
elif type(key) == str:
elif isinstance(key, str):
return QColor(key)
return Qt.transparent
224 changes: 223 additions & 1 deletion nodedge/qss/calculator-dark.qss
Original file line number Diff line number Diff line change
@@ -1 +1,223 @@
QFrame,QDialog,QMainWindow{background:#474747}QSplitter,QMainWindow::separator{background:#474747}QStatusBar{background:#474747;color:#ccc}QTabWidget{border:0}QTabBar{background:#474747;color:#ccc}QMdiArea QTabBar,QMdiArea QTabWidget,QMdiArea QTabWidget::pane,QMdiArea QTabWidget::tab-bar,QMdiArea QTabBar::tab{height:17px}QMdiArea QTabBar::tab:top:!selected,QMdiArea QTabBar::tab:top:selected,QMdiArea QTabBar::tab:top:!selected:hover{border-top-left-radius:4px;border-top-right-radius:4px;padding:2px 8px;padding-top:0;padding-bottom:3px;min-width:8ex;border:1px solid #333;border-bottom:0}QMdiArea QTabBar::tab:top:!selected,QMdiArea QTabBar::tab:top:!selected:hover{background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #6d6d6d,stop : .1 #474747,stop : .89 #3f3f3f,stop : 1 #3f3f3f)}QMdiArea QTabBar::tab:top:selected{background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #878787,stop : .1 #545454,stop : .89 #474747,stop : 1 #474747)}QMdiArea QTabBar::tab:top:!selected:hover{background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #727272,stop : .1 #4c4c4c,stop : .89 #444,stop : 1 #444)}QMdiArea QTabBar QToolButton{background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #878787,stop : .1 #616161,stop : .89 #4f4f4f,stop : 1 #4f4f4f);border:1px solid #333;border-radius:0}QMdiArea QTabBar QToolButton::left-arrow{image:url(":icons/small_arrow_left-light.png")}QMdiArea QTabBar QToolButton::right-arrow{image:url(":icons/small_arrow_right-light.png")}QMdiArea QTabBar::close-button:selected{image:url(":icons/tab_close_btn.png");origin:border;subcontrol-origin:border;subcontrol-position:right bottom}QMdiArea QTabBar::close-button:!selected{image:url(":icons/tab_close_nonselected_btn.png")}QMdiSubWindow{border-size:1px;border-style:solid;background:#616161}QTabBar::tab:selected,QTabBar::tab:hover{color:#eee}QDockWidget{color:#ddd;font-weight:bold;titlebar-close-icon:url(":icons/docktitle-close-btn-light.png");titlebar-normal-icon:url(":icons/docktitle-normal-btn-light.png")}QDockWidget::title{background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #3b3b3b,stop : 1 #2e2e2e);padding-top:4px;padding-right:22px;font-weight:bold}QDockWidget::close-button,QDockWidget::float-button{subcontrol-position:top right;subcontrol-origin:margin;text-align:center;icon-size:16px;width:14px;position:absolute;top:0;bottom:0;left:0;right:4px}QDockWidget::close-button{right:4px}QDockWidget::float-button{right:18px}QMenuBar{background:#474747}QMenuBar::item{spacing:3px;padding:3px 5px;color:#eee;background:transparent}QMenuBar::item:selected,QMenuBar::item:pressed{background:#4f9eee}QMenu{background:#474747;border:1px solid #2e2e2e}QMenu::item{background:#474747;color:#eee}QMenu::item:selected{background:#616161}QMenu::active{background:#616161;color:#eee}QMenu::separator{height:1px;background:#2e2e2e}QMenu::disabled,QMenu::item:disabled{color:#6e6e6e}QListView{background-color:#555;alternate-background-color:#434343}QListView::item{height:22px;color:#e6e6e6}QListView::item:hover{background:#6e6e6e}QListView::item::active:hover{color:#fff}QListView::item:selected,QListView::item::active:selected{color:#fff;background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #4f9eee,stop : 1 #2084ea);border:0}QPushButton{color:#e6e6e6;background:#555;border-color:#141414}QLabel{color:#e6e6e6}QLineEdit,QTextEdit{color:#e6e6e6;background:#5a5a5a}QLineEdit{border:1px solid #3a3a3a;border-radius:2px;padding:1px 2px}NodeWidget{background:transparent;}NodeWidget QFrame{background:transparent}NodeWidget QTextEdit{background:#666}NodeWidget QLabel{color:#e0e0e0}QGraphicsView{selection-background-color:#fff}
QFrame,QDialog,QMainWindow{
background:#474747;
}

QSplitter,QMainWindow::separator{
background:#474747;
}

QStatusBar{
background:#474747;
color:#cccccc;
}

QTabWidget{
border:0;
}

QTabBar{
background:#474747;
color:#cccccc;
}

QMdiArea QTabBar,QMdiArea QTabWidget,QMdiArea QTabWidget::pane,
QMdiArea QTabWidget::tab-bar,QMdiArea QTabBar::tab
{
height:17px;
}

QMdiArea QTabBar::tab:top:!selected,QMdiArea QTabBar::tab:top:selected,
QMdiArea QTabBar::tab:top:!selected:hover{
border-top-left-radius:4px;
border-top-right-radius:4px;
padding:2px 8px;
padding-top:0;
padding-bottom:3px;
min-width:8ex;
border:1px solid #333333;
border-bottom:0;}
QMdiArea QTabBar::tab:top:!selected,QMdiArea QTabBar::tab:top:!selected:hover{
background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #6d6d6d,
stop : 0.1 #474747,stop : 0.89 #3f3f3f,stop : 1 #3f3f3f);
}

QMdiArea QTabBar::tab:top:selected{
background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #878787,
stop : 0.1 #545454,stop : 0.89 #474747,stop : 1 #474747);}

QMdiArea QTabBar::tab:top:!selected:hover{
background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #727272,
stop : 0.1 #4c4c4c,stop : 0.89 #444444,stop : 1 #444444);
}


QMdiArea QTabBar QToolButton{
background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,stop : 0 #878787,
stop : 0.1 #616161,stop : 0.89 #4f4f4f,stop : 1 #4f4f4f);
border:1px solid #333333;border-radius:0;
}

QMdiArea QTabBar QToolButton::left-arrow{
image:url(":../resources/icons/small_arrow_left-light.png");
}

QMdiArea QTabBar QToolButton::right-arrow{
image:url(":icons/small_arrow_right-light.png");
}

QMdiArea QTabBar::close-button:selected{
image:url("../resources/icons/close_window_100.png");
origin: border;
subcontrol-origin:border;
subcontrol-position:right bottom;
}

QMdiArea QTabBar::close-button:!selected{
image:url("../../nodedge/resources/icons/close_window_100.png");
}

QMdiSubWindow{
border-style:solid;
background:#616161;}

QTabBar::tab:selected,QTabBar::tab:hover{
color:#eeeeee;
}

QDockWidget{
color:#dddddd;
font-weight:bold;
titlebar-close-icon:url(":icons/docktitle-close-btn-light.png");
titlebar-normal-icon:url(":icons/docktitle-normal-btn-light.png");
}

QDockWidget::title{
background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,
stop : 0 #3b3b3b,stop : 1 #2e2e2e);
padding-top:4px;
padding-right:22px;
font-weight:bold;}

QDockWidget::close-button,QDockWidget::float-button{
subcontrol-position:top right;
subcontrol-origin:margin;
text-align:center;
icon-size:16px;
width:14px;
position:absolute;
top:0;
bottom:0;
left:0;right:4px;}

QDockWidget::close-button{
right:4px;
}

QDockWidget::float-button{
right:18px;}

QMenuBar{
background:#474747;}

QMenuBar::item{
spacing:3px;
padding:3px 5px;
color:#eeeeee;
background:transparent;
}

QMenuBar::item:selected,QMenuBar::item:pressed{
background:#4f9eee;
}

QMenu{
background:#474747;
border:1px solid #2e2e2e;
}

QMenu::item{
background:#474747;
color:#eeeeee;
}

QMenu::item:selected{
background:#616161;
}

QMenu:active{
background:#616161;
color:#eeeeee;}

QMenu::separator{
height:1px;
background:#2e2e2e;
}

QMenu:disabled,
QMenu::item:disabled{
color:#6e6e6e;}

QListView{
background-color:#555555;
alternate-background-color:#434343;
}

QListView::item{
height:22px;
color:#e6e6e6;
}

QListView::item:hover{
background:#6e6e6e;
}

QListView::item:active:hover{
color:#ffffff;
}

QListView::item:selected,QListView::item:active:selected{
color:#ffffff;
background:qlineargradient(x1 : 0,y1 : 0,x2 : 0,y2 : 1,
stop : 0 #4f9eee,stop : 1 #2084ea);
border:0;}

QPushButton{
color:#e6e6e6;
background:#555555;
border-color:#141414;
}

QLabel{
color:#e6e6e6;
}

QLineEdit,QTextEdit{
color:#e6e6e6;
background:#5a5a5a;
}

QLineEdit{
border:1px solid #3a3a3a;
border-radius:2px;
padding:1px 2px;
}

NodeWidget{
background:transparent;
}

NodeWidget QFrame{
background:transparent;
}

NodeWidget QTextEdit{
background:#666666;
}

NodeWidget QLabel{
color:#e0e0e0;
}

QGraphicsView{
selection-background-color:#ffffff;
}

0 comments on commit 49168fd

Please sign in to comment.