Silly splash screen stunt
This commit is contained in:
parent
78d447f379
commit
963e98e9ed
9
Init.py
9
Init.py
|
@ -0,0 +1,9 @@
|
||||||
|
import os
|
||||||
|
import FreeCAD
|
||||||
|
import XternalAppsDummy
|
||||||
|
# The __file__ special variable isn't available in the Init.py file, so we load a dummy module located in the same directory to get its path.
|
||||||
|
FreeCAD.ConfigSet('SplashScreen', os.path.join(os.path.dirname(XternalAppsDummy.__file__),'splash.png'))
|
||||||
|
|
||||||
|
# See https://github.com/FreeCAD/FreeCAD/blob/eb6167ff89bc2b287c83d726dfcd52b775d1757e/src/Gui/MainWindow.cpp#L1512
|
||||||
|
# for all the ways to set a splashscreen and their precedence order. I couldn't make the ~/.FreeCAD/splash_image.png work
|
||||||
|
|
|
@ -2,6 +2,9 @@ import sys
|
||||||
|
|
||||||
import ExternalAppsList
|
import ExternalAppsList
|
||||||
|
|
||||||
|
import StealSplash
|
||||||
|
StealSplash.steal()
|
||||||
|
|
||||||
myIcon = """
|
myIcon = """
|
||||||
/* XPM */
|
/* XPM */
|
||||||
static char * icon_xpm[] = {
|
static char * icon_xpm[] = {
|
||||||
|
|
86
StealSplash.py
Normal file
86
StealSplash.py
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
class Foo():
|
||||||
|
def __del__(self):
|
||||||
|
def catchSplash():
|
||||||
|
import PySide
|
||||||
|
from PySide import QtGui, QtCore
|
||||||
|
import pprint
|
||||||
|
print(QtGui.QApplication.topLevelWidgets())
|
||||||
|
sps = [w for w in QtGui.QApplication.topLevelWidgets() if 'PySide2.QtWidgets.QWidget' in str(w)]
|
||||||
|
if len(sps) == 1:
|
||||||
|
sps[0].hide()
|
||||||
|
print("toplevel=")
|
||||||
|
pprint.pprint(QtGui.QApplication.topLevelWidgets())
|
||||||
|
print("children=")
|
||||||
|
pprint.pprint([x.children() for x in sps])
|
||||||
|
|
||||||
|
print("del")
|
||||||
|
catchSplash()
|
||||||
|
|
||||||
|
import PySide
|
||||||
|
from PySide import QtGui, QtCore
|
||||||
|
tm = QtCore.QTimer()
|
||||||
|
tm.timeout.connect(lambda: print(catchSplash))
|
||||||
|
tm.start(100)
|
||||||
|
|
||||||
|
#import FreeCAD
|
||||||
|
#setattr(FreeCAD, "stealsplash", tm)
|
||||||
|
|
||||||
|
#foo = Foo()
|
||||||
|
print("IN stealsplash")
|
||||||
|
|
||||||
|
Splash = None
|
||||||
|
|
||||||
|
def isDeleted(obj):
|
||||||
|
try:
|
||||||
|
str(obj)
|
||||||
|
return False
|
||||||
|
except:
|
||||||
|
return True
|
||||||
|
|
||||||
|
def steal():
|
||||||
|
def checkSplashStillHere(official, splash, tm):
|
||||||
|
print("check")
|
||||||
|
if isDeleted(official):
|
||||||
|
print("delete extra splash")
|
||||||
|
tm.stop()
|
||||||
|
splash.hide()
|
||||||
|
# TODO: properly de-allocate on the FreeCAD object
|
||||||
|
Splash = None
|
||||||
|
def catchSplash():
|
||||||
|
global Splash
|
||||||
|
import PySide
|
||||||
|
from PySide import QtGui, QtCore
|
||||||
|
import pprint
|
||||||
|
print(QtGui.QApplication.topLevelWidgets())
|
||||||
|
sps = [w for w in QtGui.QApplication.topLevelWidgets() if 'PySide2.QtWidgets.QWidget' in str(w)]
|
||||||
|
if len(sps) == 1:
|
||||||
|
# This does not work
|
||||||
|
try:
|
||||||
|
QtGui.QSplashScreen.setPixmap(sps[0], '/tmp/splash.png')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# this works, it's then possible to replace with a new splash but the progress text won't be displayed on the new splash
|
||||||
|
# the official splash screen also doesn't have any children, so it's not possible to get the text from there
|
||||||
|
# I could steal the info from the log, but unless FreeCAD was started with -l, I don't know how to access that log in Python.
|
||||||
|
#sps[0].hide()
|
||||||
|
|
||||||
|
# Solution: put a transparent background on this splash, make a new one and raise this one above.
|
||||||
|
|
||||||
|
splash = QtGui.QSplashScreen('/tmp/splash.png')
|
||||||
|
splash.show()
|
||||||
|
sps[0].raise_()
|
||||||
|
|
||||||
|
tm = QtCore.QTimer()
|
||||||
|
tm.timeout.connect(lambda *, official=sps[0], splash=splash, tm=tm: checkSplashStillHere(official, splash, tm))
|
||||||
|
tm.start(100)
|
||||||
|
|
||||||
|
import FreeCAD
|
||||||
|
setattr(FreeCAD, "Splash", (sps[0], splash, tm))
|
||||||
|
|
||||||
|
#print("toplevel=")
|
||||||
|
#pprint.pprint(QtGui.QApplication.topLevelWidgets())
|
||||||
|
#print("children=")
|
||||||
|
#pprint.pprint([x.children() for x in sps])
|
||||||
|
|
||||||
|
print("del")
|
||||||
|
catchSplash()
|
1
XternalAppsDummy.py
Normal file
1
XternalAppsDummy.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
"""Dummy module to extract a path to the current directory with os.path.dirname(XternalAppsDummy.__file__)"""
|
BIN
splash.png
Normal file
BIN
splash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Loading…
Reference in New Issue
Block a user