mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 06:39:04 +08:00
Merge branch 'feature_new_splash_window'
CURA-4215
This commit is contained in:
commit
6a9c7539c4
@ -1,38 +1,117 @@
|
||||
# Copyright (c) 2015 Ultimaker B.V.
|
||||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Uranium is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from threading import Thread, Event
|
||||
import time
|
||||
|
||||
from PyQt5.QtCore import Qt, QCoreApplication
|
||||
from PyQt5.QtGui import QPixmap, QColor, QFont, QFontMetrics
|
||||
from PyQt5.QtGui import QPixmap, QColor, QFont, QFontMetrics, QImage, QPen
|
||||
from PyQt5.QtWidgets import QSplashScreen
|
||||
|
||||
from UM.Resources import Resources
|
||||
from UM.Application import Application
|
||||
|
||||
|
||||
class CuraSplashScreen(QSplashScreen):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._scale = round(QFontMetrics(QCoreApplication.instance().font()).ascent() / 12)
|
||||
self._scale = 0.7
|
||||
|
||||
splash_image = QPixmap(Resources.getPath(Resources.Images, "cura.png"))
|
||||
self.setPixmap(splash_image.scaled(splash_image.size() * self._scale))
|
||||
self.setPixmap(splash_image)
|
||||
|
||||
self._current_message = ""
|
||||
|
||||
self._loading_image = QImage(Resources.getPath(Resources.Images, "loading.png"))
|
||||
self._loading_image = self._loading_image.scaled(30, 30, Qt.KeepAspectRatio)
|
||||
self._loading_image_rotation_angle = 0
|
||||
|
||||
self._to_stop = False
|
||||
self._loading_tick_thread = LoadingTickThread(self)
|
||||
|
||||
def show(self):
|
||||
super().show()
|
||||
self._loading_tick_thread.start()
|
||||
|
||||
def updateLoadingImage(self):
|
||||
if self._to_stop:
|
||||
return
|
||||
|
||||
self._loading_image_rotation_angle -= 10
|
||||
self.repaint()
|
||||
|
||||
def drawContents(self, painter):
|
||||
if self._to_stop:
|
||||
return
|
||||
|
||||
painter.save()
|
||||
painter.setPen(QColor(0, 0, 0, 255))
|
||||
painter.setPen(QColor(255, 255, 255, 255))
|
||||
|
||||
version = Application.getInstance().getVersion().split("-")
|
||||
buildtype = Application.getInstance().getBuildType()
|
||||
if buildtype:
|
||||
version[0] += " (%s)" %(buildtype)
|
||||
version[0] += " (%s)" % buildtype
|
||||
|
||||
font = QFont() # Using system-default font here
|
||||
font.setPointSize(20)
|
||||
# draw version text
|
||||
font = QFont() # Using system-default font here
|
||||
font.setPointSize(34)
|
||||
painter.setFont(font)
|
||||
painter.drawText(0, 0, 330 * self._scale, 230 * self._scale, Qt.AlignHCenter | Qt.AlignBottom, version[0])
|
||||
painter.drawText(275, 87, 330 * self._scale, 230 * self._scale, Qt.AlignLeft | Qt.AlignBottom, version[0])
|
||||
if len(version) > 1:
|
||||
font.setPointSize(12)
|
||||
painter.setFont(font)
|
||||
painter.drawText(0, 0, 330 * self._scale, 255 * self._scale, Qt.AlignHCenter | Qt.AlignBottom, version[1])
|
||||
painter.drawText(320, 82, 330 * self._scale, 255 * self._scale, Qt.AlignLeft | Qt.AlignBottom, version[1])
|
||||
|
||||
# draw the loading image
|
||||
pen = QPen()
|
||||
pen.setWidth(4 * self._scale)
|
||||
pen.setColor(QColor(255, 255, 255, 255))
|
||||
painter.setPen(pen)
|
||||
painter.drawArc(130, 380, 32 * self._scale, 32 * self._scale, self._loading_image_rotation_angle * 16, 300 * 16)
|
||||
|
||||
# draw message text
|
||||
if self._current_message:
|
||||
font = QFont() # Using system-default font here
|
||||
font.setPointSize(16)
|
||||
painter.setFont(font)
|
||||
painter.drawText(180, 243, 330 * self._scale, 230 * self._scale, Qt.AlignLeft | Qt.AlignBottom,
|
||||
self._current_message)
|
||||
|
||||
painter.restore()
|
||||
super().drawContents(painter)
|
||||
|
||||
def showMessage(self, message, *args, **kwargs):
|
||||
if self._to_stop:
|
||||
return
|
||||
|
||||
self._current_message = message
|
||||
self.messageChanged.emit(message)
|
||||
self.repaint()
|
||||
|
||||
def close(self):
|
||||
# set stop flags
|
||||
self._to_stop = True
|
||||
self._loading_tick_thread.setToStop()
|
||||
super().close()
|
||||
|
||||
|
||||
class LoadingTickThread(Thread):
|
||||
|
||||
def __init__(self, splash):
|
||||
super().__init__(daemon = True)
|
||||
self._splash = splash
|
||||
self._to_stop = False
|
||||
self._time_interval = 0.05
|
||||
self._event = Event()
|
||||
|
||||
def setToStop(self):
|
||||
self._to_stop = True
|
||||
self._event.set()
|
||||
|
||||
def run(self):
|
||||
while not self._to_stop:
|
||||
self._event.wait(self._time_interval)
|
||||
if self._event.is_set():
|
||||
break
|
||||
|
||||
self._splash.updateLoadingImage()
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 54 KiB |
BIN
resources/images/loading.png
Normal file
BIN
resources/images/loading.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
@ -1,8 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="82px" height="18px" viewBox="0 0 82 18" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||
<polygon fill="#20A6DB" points="82 10.3797468 77.8757345 10.3797468 75.7721519 12.4764557 75.7721519 16.6075949 79.9067798 16.6075949 82 14.5108861" />
|
||||
<path fill="black" d="M0,9.32538529 C0,14.168804 3.22511,17.6455696 8.53908129,17.6455696 L16.6075949,17.6455696 L16.6075949,13.294146 L8.53908129,13.294146 C5.8534025,13.2832128 4.53351762,11.4792306 4.53351762,9.32538529 C4.53351762,7.17153994 5.8534025,5.40035747 8.53908129,5.37849102 L16.6075949,5.37849102 L16.6075949,1.03800064 L8.53908129,1.03800064 C3.21363275,1.02706742 0,4.47103333 0,9.32538529 Z" />
|
||||
<path fill="black" d="M33.004725,9.78605176 C33.004725,12.2613239 31.20074,13.5835846 29.0468913,13.5835846 C26.8930426,13.5835846 25.1218573,12.2613239 25.1218573,9.78605176 L25.1218573,1.03797468 L20.7594937,1.03797468 L20.7594937,9.78605176 C20.7594937,14.6837056 24.203465,17.6455696 29.0468913,17.6455696 C33.8903176,17.6455696 37.3670886,14.6731275 37.3670886,9.78605176 L37.3670886,1.03797468 L33.004725,1.03797468 L33.004725,9.78605176 L33.004725,9.78605176 Z" />
|
||||
<path fill="black" d="M62.1251127,1.03797468 C57.0530042,1.03797468 53.9746835,4.47968021 53.9746835,9.31992005 C53.9746835,14.1601599 57.0530042,17.6346436 62.1251127,17.6346436 L63.9217127,17.6346436 L63.9217127,13.297002 L62.1251127,13.297002 C59.5616713,13.2860759 58.3018603,11.4832778 58.3018603,9.3308461 C58.3018603,7.17841439 59.5616713,5.4083944 62.1251127,5.38654231 L66.2112822,5.38654231 L66.2112822,11.0680879 L66.2112822,13.297002 L66.2112822,17.6455696 L70.5822785,17.6455696 L70.5822785,17.3942705 L70.5822785,13.297002 L70.5822785,5.38654231 L70.5822785,1.80279813 L70.5822785,1.03797468 L62.1251127,1.03797468 Z" />
|
||||
<path fill="black" d="M41.5189873,8.10074451 L41.5189873,16.6075949 L45.8823067,16.6075949 L45.8823067,8.10074451 C45.8823067,5.99540589 47.1558644,4.26411221 49.7472774,4.24273822 L52.9367089,4.24273822 L52.9367089,0 L49.7472774,0 C44.6198234,0 41.5189873,3.36640438 41.5189873,8.10074451 Z" />
|
||||
</svg>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="82px"
|
||||
height="18px"
|
||||
viewBox="0 0 82 18"
|
||||
version="1.1"
|
||||
id="svg12"
|
||||
sodipodi:docname="logo.svg"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)">
|
||||
<metadata
|
||||
id="metadata18">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs16" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1156"
|
||||
inkscape:window-height="480"
|
||||
id="namedview14"
|
||||
showgrid="false"
|
||||
inkscape:zoom="3.4634146"
|
||||
inkscape:cx="41"
|
||||
inkscape:cy="9"
|
||||
inkscape:window-x="3138"
|
||||
inkscape:window-y="329"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg12" />
|
||||
<polygon
|
||||
fill="#20A6DB"
|
||||
points="82 10.3797468 77.8757345 10.3797468 75.7721519 12.4764557 75.7721519 16.6075949 79.9067798 16.6075949 82 14.5108861"
|
||||
id="polygon2" />
|
||||
<path
|
||||
fill="black"
|
||||
d="M0,9.32538529 C0,14.168804 3.22511,17.6455696 8.53908129,17.6455696 L16.6075949,17.6455696 L16.6075949,13.294146 L8.53908129,13.294146 C5.8534025,13.2832128 4.53351762,11.4792306 4.53351762,9.32538529 C4.53351762,7.17153994 5.8534025,5.40035747 8.53908129,5.37849102 L16.6075949,5.37849102 L16.6075949,1.03800064 L8.53908129,1.03800064 C3.21363275,1.02706742 0,4.47103333 0,9.32538529 Z"
|
||||
id="path4" />
|
||||
<path
|
||||
fill="black"
|
||||
d="M33.004725,9.78605176 C33.004725,12.2613239 31.20074,13.5835846 29.0468913,13.5835846 C26.8930426,13.5835846 25.1218573,12.2613239 25.1218573,9.78605176 L25.1218573,1.03797468 L20.7594937,1.03797468 L20.7594937,9.78605176 C20.7594937,14.6837056 24.203465,17.6455696 29.0468913,17.6455696 C33.8903176,17.6455696 37.3670886,14.6731275 37.3670886,9.78605176 L37.3670886,1.03797468 L33.004725,1.03797468 L33.004725,9.78605176 L33.004725,9.78605176 Z"
|
||||
id="path6" />
|
||||
<path
|
||||
fill="black"
|
||||
d="M62.1251127,1.03797468 C57.0530042,1.03797468 53.9746835,4.47968021 53.9746835,9.31992005 C53.9746835,14.1601599 57.0530042,17.6346436 62.1251127,17.6346436 L63.9217127,17.6346436 L63.9217127,13.297002 L62.1251127,13.297002 C59.5616713,13.2860759 58.3018603,11.4832778 58.3018603,9.3308461 C58.3018603,7.17841439 59.5616713,5.4083944 62.1251127,5.38654231 L66.2112822,5.38654231 L66.2112822,11.0680879 L66.2112822,13.297002 L66.2112822,17.6455696 L70.5822785,17.6455696 L70.5822785,17.3942705 L70.5822785,13.297002 L70.5822785,5.38654231 L70.5822785,1.80279813 L70.5822785,1.03797468 L62.1251127,1.03797468 Z"
|
||||
id="path8" />
|
||||
<path
|
||||
d="M 41.518987,9.13915 V 17.646 h 4.36332 V 9.13915 c 0,-2.1053391 1.273557,-3.8366328 3.86497,-3.8580068 h 3.189432 V 1.038405 h -3.189432 c -5.127454,0 -8.22829,3.3664044 -8.22829,8.100745 z"
|
||||
id="path10"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.5 KiB |
Loading…
x
Reference in New Issue
Block a user