Skip to content

Commit

Permalink
fix #1044 (high cpu usage)
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment committed Nov 22, 2022
1 parent d50145f commit fa41dac
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ElevenClock.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "ElevenClock"
#define MyAppVersion "3.9.5"
#define MyAppVersion "3.9.6"
#define MyAppPublisher "Martí Climent"
#define MyAppURL "https://github.com/martinet101/ElevenClock"
#define MyAppExeName "ElevenClock.exe"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ In order to translate ElevenClock to other languages or to update an old transla
| Simplified Chinese (China) | 100% | <img src='https://flagcdn.com/cn.svg' width=20> |
| Traditional Chinese (Taiwan) | 100% | <img src='https://flagcdn.com/tw.svg' width=20> |

Last updated: Tue Nov 22 01:12:40 2022
Last updated: Tue Nov 22 14:47:34 2022
<!-- END Autogenerated translations -->


Expand Down
4 changes: 2 additions & 2 deletions elevenclock-version-info
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ StringFileInfo(
[
StringStruct(u'CompanyName', u'Martí Climent'),
StringStruct(u'FileDescription', u'ElevenClock'),
StringStruct(u'FileVersion', u'3.9.5'),
StringStruct(u'ProductVersion', u'3.9.5'),
StringStruct(u'FileVersion', u'3.9.6'),
StringStruct(u'ProductVersion', u'3.9.6'),
StringStruct(u'InternalName', u'ElevenClock'),
StringStruct(u'LegalCopyright', u'Martí Climent'),
StringStruct(u'OriginalFilename', u'elevenclock.exe'),
Expand Down
15 changes: 7 additions & 8 deletions elevenclock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,15 +1229,17 @@ def checkAndUpdateBackground(self):
if not self.isCover:
alphaUpdated = False
shouldBeTransparent = False
self.oldTextColor = ""
try:
if self.UseTaskbarBackgroundColor and not globals.trayIcon.contextMenu().isVisible():
if self.isVisible():
gotColor = False
intColor = 0
if not self.tempMakeClockTransparent:
if self.showBlurryBackground:
self.callInMainSignal.emit(lambda: self.backgroundTexture.show())
g = self.screen().geometry()
intColor = self.screen().grabWindow(0, self.x()-g.x()+self.label.x()+(self.label.width() if self.clockOnTheLeft else 0), self.y()-g.y(), 1, 1).toImage().pixel(0, 0)
gotColor = True
alphaUpdated = False
shouldBeTransparent = False
else:
Expand All @@ -1251,7 +1253,6 @@ def checkAndUpdateBackground(self):
intColor = self.oldBgColor
if intColor != self.oldBgColor:
self.oldBgColor = intColor
cprint(intColor)
try:
color = QColor(intColor)
except OverflowError as e:
Expand All @@ -1260,16 +1261,15 @@ def checkAndUpdateBackground(self):
color = QColor(intColor-10)
except OverflowError as e:
color = QColor(Qt.GlobalColor.white)
print(intColor)
report(e)
self.styler.emit(self.widgetStyleSheet.replace("bgColor", f"{color.red()}, {color.green()}, {color.blue()}, {100 if not shouldBeTransparent else 0}"))
if not getSettings("DisableAutomaticTextColor"):
g = self.screen().geometry()
intColor = self.screen().grabWindow(0, self.x()-g.x()+self.label.x()+(self.label.width() if self.clockOnTheLeft else 0), self.y()-g.y(), 1, 1).toImage().pixel(0, 0)
self.oldBgColor = intColor
if not gotColor: # If it was not already calculated
intColor = self.screen().grabWindow(0, self.x()-g.x()+self.label.x()+(self.label.width() if self.clockOnTheLeft else 0), self.y()-g.y(), 1, 1).toImage().pixel(0, 0)
try:
color = QColor(intColor)
except OverflowError as e:
except OverflowError:
print("🟣 Expected AttributeError on bgcolor function (line 1273)")
try:
color = QColor(intColor-1)
Expand All @@ -1278,12 +1278,11 @@ def checkAndUpdateBackground(self):
cprint(intColor)
intColor = 0
report(e)
alphaUpdated = False
shouldBeTransparent = False
avgColorValue = color.red()/3 + color.green()/3 + color.blue()/3
textcolor = "black" if (avgColorValue>=127) else "white"
if textcolor != self.oldTextColor:
self.oldTextColor = textcolor
cprint("Changing color!")
styleSheetString = self.makeLabelStyleSheet(0, 3, 9, 5, textcolor)
self.callInMainSignal.emit(partial(self.label.setStyleSheet, styleSheetString))

Expand Down
4 changes: 2 additions & 2 deletions elevenclock/versions.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 3.95
versionName = "3.9.5"
version = 3.96
versionName = "3.9.6"

0 comments on commit fa41dac

Please sign in to comment.