1515import math
1616timerDelay = 1
1717widgetCount = 0
18+ try :
19+ from ctypes import windll
20+ windll .shell32 .SetCurrentProcessExplicitAppUserModelID (LingmoApp .appid )
21+ except ImportError :
22+ pass
1823class LingmoAnimation (QVariantAnimation ):
1924 Variable = 1
2025 Callable = 2
@@ -1755,10 +1760,12 @@ def __init__(self,parent=None,title='Lingmo Window',windowIcon=LingmoApp.windowI
17551760 super ().__init__ (parent ,show = False )
17561761 self .resize (width ,height )
17571762 self .loadWidget = LingmoFrame (show = False )
1758- self .loadWidget .setWindowFlags (Qt .WindowType .FramelessWindowHint )
1763+ self .loadWidget .setWindowFlags (Qt .WindowType .FramelessWindowHint | Qt . WindowType . ToolTip )
17591764 self .loadWidget .setAttribute (Qt .WidgetAttribute .WA_TranslucentBackground )
17601765 self .loadBackground = LingmoFrame (self .loadWidget )
17611766 self .loadBackground .addStyleSheet ('background-color' ,'#44000000' )
1767+ self .loadRing = LingmoProgressRing (self .loadBackground )
1768+ self .loadText = LingmoText (self .loadBackground ,text = self .tr ('Loading...' ))
17621769 self .loadWidget .show ()
17631770 self .isLazyInit = True
17641771 self .setAttribute (Qt .WidgetAttribute .WA_TranslucentBackground )
@@ -1809,12 +1816,15 @@ def __init__(self,parent=None,title='Lingmo Window',windowIcon=LingmoApp.windowI
18091816 self .timerUpdateImage .timeout .connect (self .onTimerTimeout )
18101817 self .timerUpdateImage .start (150 )
18111818 self .infoBar = LingmoInfoBar (self .contentItem )
1812- self .loadWidgetOpacity = 0
1819+ self .loadWidgetOpacity = 1
18131820 self .loadWidgetOpacityAnimation = QSequentialAnimationGroup ()
18141821 self .loadWidgetOpacityAnimation .addPause (83 )
18151822 self .loadWidgetOpacityAnimation1 = LingmoAnimation (self ,'loadWidgetOpacity' )
18161823 self .loadWidgetOpacityAnimation1 .setDuration (167 )
1824+ self .loadWidgetOpacityAnimation .addAnimation (self .loadWidgetOpacityAnimation1 )
18171825 self .unloaded = True
1826+ self .cancel = False
1827+ self .loadBackground .pressed .connect (self .cancelLoading )
18181828 def updateEvent (self ):
18191829 try :
18201830 self .resizeBorderColor = (QColor (51 ,51 ,51 ,255 )if LingmoTheme .instance .dark () else QColor (110 ,110 ,110 ,255 ))if self .isActiveWindow () else (QColor (61 ,61 ,61 ,255 )if LingmoTheme .instance .dark ()else QColor (167 ,167 ,167 ,255 ))
@@ -1839,12 +1849,14 @@ def updateEvent(self):
18391849 self .imgBack .resize (LingmoTools .desktopAvailableGeometry (self ).size ())
18401850 self .loadWidget .setGeometry (self .geometry ())
18411851 self .loadBackground .resize (self .loadWidget .size ())
1842- print ( self .loadWidgetOpacity )
1852+ self .loadWidget . show ( )
18431853 if self .unloaded :
18441854 self .unloaded = False
1845- self .setLoadWidgetOpacity (1 )
1855+ self .setLoadWidgetOpacity (0 )
18461856 self .loadWidget .setWindowOpacity (self .loadWidgetOpacity )
1847- except :
1857+ self .loadRing .move (self .background .width ()/ 2 - self .loadRing .width ()/ 2 ,self .height ()/ 2 - (self .loadRing .height ()+ 8 + self .loadText .height ())/ 2 )
1858+ self .loadText .move (self .background .width ()/ 2 - self .loadText .width ()/ 2 ,self .loadRing .y ()+ self .loadRing .height ()+ 8 )
1859+ except :
18481860 pass
18491861 def setStayTop (self ,val ):
18501862 self .stayTop = val
@@ -1896,17 +1908,28 @@ def onBlurBehindWindowEnabledChanged(self):
18961908 self .imgBack .setPixmap (QPixmap (LingmoTheme .instance ._desktopImagePath ))
18971909 else :
18981910 self .imgBack .setPixmap (QPixmap ())
1899- def showSuccess (self ,text ,duration = 2000 ,moremsg = '' ):
1911+ def showSuccess (self ,text ,duration = 1000 ,moremsg = '' ):
19001912 return self .infoBar .showSuccess (text ,duration ,moremsg )
1901- def showInfo (self ,text ,duration = 2000 ,moremsg = '' ):
1913+ def showInfo (self ,text ,duration = 1000 ,moremsg = '' ):
19021914 return self .infoBar .showInfo (text ,duration ,moremsg )
1903- def showWarning (self ,text ,duration = 2000 ,moremsg = '' ):
1915+ def showWarning (self ,text ,duration = 1000 ,moremsg = '' ):
19041916 return self .infoBar .showWarning (text ,duration ,moremsg )
1905- def showError (self ,text ,duration = 2000 ,moremsg = '' ):
1917+ def showError (self ,text ,duration = 1000 ,moremsg = '' ):
19061918 return self .infoBar .showError (text ,duration ,moremsg )
19071919 def clearAllInfo (self ):
19081920 return self .infoBar .clearAllInfo ()
19091921 def setLoadWidgetOpacity (self ,val ):
19101922 self .loadWidgetOpacityAnimation1 .setStartValue (self .loadWidgetOpacity )
19111923 self .loadWidgetOpacityAnimation1 .setEndValue (val )
19121924 self .loadWidgetOpacityAnimation .start ()
1925+ def showLoading (self ,text = '' ,cancel = True ):
1926+ if text == '' :
1927+ text = self .tr ('Loading' )
1928+ self .cancel = cancel
1929+ self .setLoadWidgetOpacity (1 )
1930+ def hideLoading (self ):
1931+ self .setLoadWidgetOpacity (0 )
1932+ def cancelLoading (self ):
1933+ if self .cancel :
1934+ self .hideLoading ()
1935+
0 commit comments