Skip to content

Commit

Permalink
Merge pull request #20 from nodedge/feature/splash-screen
Browse files Browse the repository at this point in the history
Add splash screen
  • Loading branch information
nodedge committed Nov 23, 2022
2 parents 2ab9cfa + 93b205d commit 65b08d2
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Run_tests.xml

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

5 changes: 5 additions & 0 deletions nodedge/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from nodedge.logger import highLightLoggingSetup, setupLogging
from nodedge.mdi_window import MdiWindow
from nodedge.splash_screen import SplashScreen
from nodedge.utils import dumpException

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..")) # noqa: E402
Expand All @@ -14,11 +15,15 @@

def main():
app: QApplication = QApplication(sys.argv)
splash = SplashScreen()
splash.show()
setupLogging()
highLightLoggingSetup()

window = MdiWindow()
# splash.closeSignal.connect(window.show)
window.show()

window.openFile(
f"{os.path.dirname(__file__)}/../examples/calculator/calculator.json"
)
Expand Down
6 changes: 3 additions & 3 deletions nodedge/graphics_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from typing import Optional, cast

from PySide6.QtCore import QRectF, Qt, QPointF
from PySide6.QtCore import QPointF, QRectF, Qt
from PySide6.QtGui import QBrush, QColor, QFont, QPainterPath, QPen
from PySide6.QtWidgets import (
QApplication,
Expand Down Expand Up @@ -278,7 +278,7 @@ def mouseReleaseEvent(self, event):
# Handle when node moved
if self._wasMoved:
clipSize = self.node.scene.graphicsScene.gridSize
halfClipSize = round(clipSize/2)
halfClipSize = round(clipSize / 2)
pos = event.scenePos() - event.pos()
xRest = pos.x() % clipSize
yRest = pos.y() % clipSize
Expand All @@ -293,7 +293,7 @@ def mouseReleaseEvent(self, event):
for node in graphicsScene.scene.nodes:
if node.graphicsNode.isSelected():
nodePos = node.graphicsNode.pos()
node.graphicsNode.setPos(nodePos.x()+dx, nodePos.y()+dy)
node.graphicsNode.setPos(nodePos.x() + dx, nodePos.y() + dy)
node.updateConnectedEdges()

self.__logger.debug(f"Current graphics node pos: {self.pos()}")
Expand Down
46 changes: 46 additions & 0 deletions nodedge/graphics_splash_screen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from PySide6.QtCore import QCoreApplication


class GraphicsSplashScreen(object):
def __init__(self):
self.labelLoading = None
self.labelCredits = None
self.progressBar = None
self.labelDescription = None
self.labelTitle = None
self.dropShadowFrame = None
self.verticalLayout = None
self.centralWidget = None

def setupUi(self, SplashScreen):
if not SplashScreen.objectName():
SplashScreen.setObjectName("SplashScreen")

def translateUi(self, SplashScreen):
SplashScreen.setWindowTitle(
QCoreApplication.translate("SplashScreen", "MainWindow", None)
)
self.labelTitle.setText(
QCoreApplication.translate(
"SplashScreen", "<html><head/><body><p>NODEDGE</p></body></html>", None
)
)
self.labelDescription.setText(
QCoreApplication.translate(
"SplashScreen",
"<html><head/><body><p>FOR NEXT-GENERATION SCIENTIFIC PROGRAMMING</p></body></html>",
None,
)
)
self.labelLoading.setText(
QCoreApplication.translate(
"SplashScreen", "<strong>Loading</strong> ...", None
)
)
self.labelCredits.setText(
QCoreApplication.translate(
"SplashScreen",
"<html><head/><body><p>Copyright (c) 2020-2022 Nodedge Foundation</p></body></html>",
None,
)
)
136 changes: 136 additions & 0 deletions nodedge/splash_screen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import sys

from PySide6 import QtCore
from PySide6.QtCore import QRect, Signal
from PySide6.QtGui import QColor, QFont, Qt
from PySide6.QtWidgets import *

counter = 0
SPLASH_WIDTH = 680
SPLASH_HEIGHT = 400


class SplashScreen(QMainWindow):
closed = Signal()

def __init__(self):
QMainWindow.__init__(self, None)

self.setWindowTitle("Nodedge loading")

self.setWindowFlag(
Qt.WindowType.FramelessWindowHint
^ Qt.WindowType.WindowStaysOnTopHint
^ Qt.WindowType.SplashScreen
)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)

self.resize(SPLASH_WIDTH, SPLASH_HEIGHT)
self.centralWidget = QWidget(self)
self.setCentralWidget(self.centralWidget)

self.dropShadowFrame = QFrame(self.centralWidget)
self.dropShadowFrame.setFrameShape(QFrame.Shape.StyledPanel)
self.dropShadowFrame.setFrameShadow(QFrame.Shadow.Raised)
self.dropShadowFrame.setStyleSheet(
"QFrame { \n"
" background-color: #23252E; \n"
" color: #272C36;\n"
" border-radius: 10px;\n"
"}"
)

self.verticalLayout = QVBoxLayout()
self.verticalLayout.setSpacing(0)
self.verticalLayout.setContentsMargins(10, 10, 10, 10)
self.verticalLayout.addWidget(self.dropShadowFrame)

self.labelTitle = QLabel(self.dropShadowFrame)
self.labelTitle.setGeometry(QRect(0, 90, 661, 61))
self.labelTitle.setFont(QFont(["Segoe UI"], 36, QFont.Weight.Bold))
self.labelTitle.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.labelTitle.setText("NODEDGE")
self.labelTitle.setStyleSheet("color: #007BFF;")

self.labelDescription = QLabel(self.dropShadowFrame)
self.labelDescription.setGeometry(QRect(0, 150, 661, 61))
self.labelDescription.setFont(QFont(["Segoe UI"], 14))
self.labelDescription.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.labelDescription.setText("Welcome to Nodedge")
self.labelDescription.setStyleSheet("color: rgb(75, 80, 99);")

self.progressBar = QProgressBar(self.dropShadowFrame)
self.progressBar.setGeometry(QRect(50, 280, 561, 23))
self.progressBar.setValue(0)
self.progressBar.setStyleSheet(
"QProgressBar {\n"
" \n"
" background-color: rgb(75, 80, 99);\n"
" color: rgb(200, 200, 200);\n"
" border-style: none;\n"
" border-radius: 10px;\n"
" text-align: center;\n"
"}\n"
"QProgressBar::chunk{\n"
" border-radius: 10px;\n"
" background-color: qlineargradient("
"spread:pad, x1:0, y1:0.511364, x2:1, y2:0.523, "
"stop:0 rgba(251, 255, 0, 255), "
"stop:1 rgba(255, 150, 0, 255));\n"
"}"
)

self.labelLoading = QLabel(self.dropShadowFrame)
self.labelLoading.setGeometry(QRect(0, 320, 661, 21))
self.labelLoading.setFont(QFont(["Segoe UI"], 12))
self.labelLoading.setStyleSheet("color: rgb(75, 80, 99);")
self.labelLoading.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.labelLoading.setText("Loading ...")

self.labelCredits = QLabel(self.dropShadowFrame)
self.labelCredits.setGeometry(QRect(20, 350, 621, 21))
self.labelCredits.setFont(QFont(["Segoe UI"], 10))
self.labelCredits.setStyleSheet("color: rgb(75, 80, 99);")
self.labelCredits.setAlignment(
Qt.AlignmentFlag.AlignRight
| Qt.AlignmentFlag.AlignTrailing
| Qt.AlignmentFlag.AlignVCenter
)
self.labelCredits.setText("Copyright (c) 2020-2022 Nodedge Foundation")

self.shadow = QGraphicsDropShadowEffect(self)
self.shadow.setBlurRadius(20)
self.shadow.setXOffset(0)
self.shadow.setYOffset(0)
self.shadow.setColor(QColor(0, 0, 0, 60))

self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.updateProgress)
self.timer.start(35)

# QtCore.QTimer.singleShot(1000, lambda: self.labelDescription.setText("<strong>Loading</strong> Nodedge core"))

self.show()

def updateProgress(self):

global counter
self.progressBar.setValue(counter)

if counter > 100:
self.timer.stop()

self.closed.emit()
self.close()

counter += 1


if __name__ == "__main__":
app = QApplication()

window = SplashScreen()
main = QMainWindow(None)
window.closed.connect(main.show)

sys.exit(app.exec())

0 comments on commit 65b08d2

Please sign in to comment.