Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit 273f252

Browse files
committed
finish LingmoWindow
1 parent 6e418dd commit 273f252

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

LingmoPyUI/LingmoApp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77

88
from . import LingmoIconDef
9+
appid='com.lingmo.pyui.1.0'
910
windowIcon='./LingmoPyUI/Image/icon.png'
1011
locale=QLocale()
1112
launcher=QObject()

LingmoPyUI/__init__.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
import math
1616
timerDelay=1
1717
widgetCount=0
18+
try:
19+
from ctypes import windll
20+
windll.shell32.SetCurrentProcessExplicitAppUserModelID(LingmoApp.appid)
21+
except ImportError:
22+
pass
1823
class 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+

example.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,15 @@ def setup_ui(self):
8282

8383
self.progressButton.pressed.connect(lambda:self.window.showSuccess('This is all the widgets',1500,'OK'))
8484
self.filledButton.pressed.connect(lambda:self.window.showWarning('This is all the widgets',1500,'OK'))
85-
self.loadingButton.pressed.connect(self.showInfos)
86-
self.iconButton.pressed.connect(lambda:self.window.showError('This is all the widgets',1500,'OK'))
85+
self.loadingButton.pressed.connect(self.window.showLoading)
86+
self.iconButton.pressed.connect(lambda:self.window.showInfo('This is all the widgets',1500,'OK'))
8787

8888
def run(self):
8989
LingmoPyUI.LingmoApp.run()
9090

9191
def progress(self):
9292
self.progressButton.setProgress(1)
9393

94-
def showInfos(self):
95-
self.window.showInfo('111',1500,'222')
96-
self.window.showInfo('222',2000,'333')
97-
self.window.showInfo('333',2500,'444')
9894

9995
if __name__ == "__main__":
10096
app = ExampleApp()

0 commit comments

Comments
 (0)