Skip to content

Commit

Permalink
添加 Mica Alt 特效
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyiYo committed Aug 29, 2023
1 parent dba468a commit bb81749
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/acrylic_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, parent=None):
# self.windowEffect.setAcrylicEffect(self.winId(), "106EBE99")

# you can also enable mica effect on Win11
# self.windowEffect.setMicaEffect(self.winId(), False)
# self.windowEffect.setMicaEffect(self.winId(), isDarkMode=False, isAlt=False)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion qframelesswindow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:license: GPLv3, see LICENSE for more details.
"""

__version__ = "0.3.1"
__version__ = "0.3.2"

import sys

Expand Down
5 changes: 4 additions & 1 deletion qframelesswindow/linux/window_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setAcrylicEffect(self, hWnd, gradientColor="F2F2F230", isEnableShadow=True,
"""
pass

def setMicaEffect(self, hWnd, isDarkMode=False):
def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
""" Add mica effect to the window (Win11 only)
Parameters
Expand All @@ -35,6 +35,9 @@ def setMicaEffect(self, hWnd, isDarkMode=False):
isDarkMode: bool
whether to use dark mode mica effect
isAlt: bool
whether to use mica alt effect
"""
pass

Expand Down
5 changes: 4 additions & 1 deletion qframelesswindow/mac/window_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setAcrylicEffect(self, hWnd, gradientColor="F2F2F230", isEnableShadow=True,
content.addSubview_positioned_relativeTo_(
visualEffectView, Cocoa.NSWindowBelow, container)

def setMicaEffect(self, hWnd, isDarkMode=False):
def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
""" Add mica effect to the window (Win11 only)
Parameters
Expand All @@ -56,6 +56,9 @@ def setMicaEffect(self, hWnd, isDarkMode=False):
isDarkMode: bool
whether to use dark mode mica effect
isAlt: bool
whether to use mica alt effect
"""
self.setAcrylicEffect(hWnd)

Expand Down
7 changes: 5 additions & 2 deletions qframelesswindow/windows/window_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def setAcrylicEffect(self, hWnd, gradientColor="F2F2F299", enableShadow=True, an
self.winCompAttrData.Attribute = WINDOWCOMPOSITIONATTRIB.WCA_ACCENT_POLICY.value
self.SetWindowCompositionAttribute(hWnd, pointer(self.winCompAttrData))

def setMicaEffect(self, hWnd, isDarkMode=False):
def setMicaEffect(self, hWnd, isDarkMode=False, isAlt=False):
""" Add the mica effect to the window (Win11 only)
Parameters
Expand All @@ -92,6 +92,9 @@ def setMicaEffect(self, hWnd, isDarkMode=False):
isDarkMode: bool
whether to use dark mode mica effect
isAlt: bool
whether to enable mica alt effect
"""
if not isGreaterEqualWin11():
warnings.warn("The mica effect is only available on Win11")
Expand All @@ -112,7 +115,7 @@ def setMicaEffect(self, hWnd, isDarkMode=False):
if sys.getwindowsversion().build < 22523:
self.DwmSetWindowAttribute(hWnd, 1029, byref(c_int(1)), 4)
else:
self.DwmSetWindowAttribute(hWnd, 38, byref(c_int(2)), 4)
self.DwmSetWindowAttribute(hWnd, 38, byref(c_int(4 if isAlt else 2)), 4)

self.DwmSetWindowAttribute(hWnd, 20, byref(c_int(1*isDarkMode)), 4)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="PyQt5-Frameless-Window",
version="0.3.1",
version="0.3.2",
keywords="pyqt frameless",
author="zhiyiYo",
author_email="shokokawaii@outlook.com",
Expand Down

0 comments on commit bb81749

Please sign in to comment.