RinUI 0.1.5.1__py3-none-any.whl → 0.1.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
RinUI/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .core import *
2
2
 
3
- __version__ = "0.1.5.1"
3
+ __version__ = "0.1.5.2"
4
4
  __author__ = "RinLit"
RinUI/core/launcher.py CHANGED
@@ -3,6 +3,7 @@ from typing import Union
3
3
 
4
4
  from PySide6.QtCore import QCoreApplication, QUrl, QObject
5
5
  from PySide6.QtGui import QIcon
6
+ from PySide6.QtQuick import QQuickWindow
6
7
  from PySide6.QtWidgets import QApplication
7
8
  from PySide6.QtQml import QQmlApplicationEngine
8
9
  from pathlib import Path
@@ -19,6 +20,7 @@ class RinUIWindow:
19
20
  :param qml_path: str or Path, QML file path (eg = "path/to/main.qml")
20
21
  """
21
22
  super().__init__()
23
+ self.windows = None
22
24
  if hasattr(self, "_initialized") and self._initialized:
23
25
  return
24
26
 
@@ -72,8 +74,10 @@ class RinUIWindow:
72
74
 
73
75
  # 窗口设置
74
76
  self.root_window = self.engine.rootObjects()[0]
77
+ self.windows = [self.root_window] + self.root_window.findChildren(QQuickWindow)
75
78
 
76
- self.theme_manager.set_window(self.root_window)
79
+ for window in self.windows:
80
+ self.theme_manager.set_window(window)
77
81
 
78
82
  # 窗口句柄管理
79
83
  self._window_handle_setup()
@@ -90,7 +94,7 @@ class RinUIWindow:
90
94
 
91
95
  from .window import WinEventFilter, WinEventManager
92
96
 
93
- self.win_event_filter = WinEventFilter(self.root_window)
97
+ self.win_event_filter = WinEventFilter(self.windows)
94
98
  self.win_event_manager = WinEventManager()
95
99
 
96
100
  app_instance = QApplication.instance()
RinUI/core/theme.py CHANGED
@@ -135,8 +135,6 @@ class ThemeManager(QObject):
135
135
  except Exception as e:
136
136
  print(f"Failed to load config because of {e}, using default config")
137
137
 
138
- # self.hwnd = None # 窗口句柄
139
-
140
138
  self.start_listener()
141
139
 
142
140
  def start_listener(self):
RinUI/core/window.py CHANGED
@@ -113,35 +113,38 @@ class WinEventManager(QObject):
113
113
 
114
114
 
115
115
  class WinEventFilter(QAbstractNativeEventFilter):
116
- def __init__(self, window: QQuickWindow):
116
+ def __init__(self, windows: list):
117
117
  super().__init__()
118
- self.window = window
119
- self.hwnd: Optional[int] = None
118
+ self.windows = windows # 接受多个窗口
119
+ self.hwnds = {} # 用于存储每个窗口的 hwnd
120
120
  self.resize_border = 8
121
121
 
122
- if not self.window.isVisible():
123
- self.window.visibleChanged.connect(self._on_visible_changed)
124
- else:
125
- self._init_window_handle()
122
+ for window in self.windows:
123
+ window.visibleChanged.connect(self._on_visible_changed)
124
+ if window.isVisible():
125
+ self._init_window_handle(window)
126
126
 
127
127
  def _on_visible_changed(self, visible: bool):
128
- if visible and self.hwnd is None:
129
- self._init_window_handle()
130
-
131
- def _init_window_handle(self):
132
- self.hwnd = int(self.window.winId())
133
- self.set_window_styles()
134
- print(f"Window handle set: {self.hwnd}")
135
-
136
- def set_window_styles(self):
137
- """设置必要的窗口样式以启用原生窗口行为"""
138
- style = user32.GetWindowLongPtrW(self.hwnd, -16) # GWL_STYLE
128
+ for window in self.windows:
129
+ if visible and self.hwnds.get(window) is None:
130
+ self._init_window_handle(window)
131
+
132
+ def _init_window_handle(self, window: QQuickWindow):
133
+ hwnd = int(window.winId())
134
+ self.hwnds[window] = hwnd
135
+ self.set_window_styles(window)
136
+
137
+ def set_window_styles(self, window: QQuickWindow):
138
+ hwnd = self.hwnds.get(window)
139
+ if hwnd is None:
140
+ return
139
141
 
142
+ style = user32.GetWindowLongPtrW(hwnd, -16) # GWL_STYLE
140
143
  style |= WS_CAPTION | WS_THICKFRAME
141
- user32.SetWindowLongPtrW(self.hwnd, -16, style) # GWL_STYLE
144
+ user32.SetWindowLongPtrW(hwnd, -16, style) # GWL_STYLE
142
145
 
143
146
  # 重绘
144
- user32.SetWindowPos(self.hwnd, 0, 0, 0, 0, 0,
147
+ user32.SetWindowPos(hwnd, 0, 0, 0, 0, 0,
145
148
  0x0002 | 0x0001 | 0x0040) # SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED
146
149
 
147
150
  def nativeEventFilter(self, eventType: QByteArray, message):
@@ -160,69 +163,73 @@ class WinEventFilter(QAbstractNativeEventFilter):
160
163
  wParam = wintypes.WPARAM.from_address(message_addr + 2 * ctypes.sizeof(ctypes.c_void_p)).value
161
164
  lParam = wintypes.LPARAM.from_address(message_addr + 3 * ctypes.sizeof(ctypes.c_void_p)).value
162
165
 
163
- if message_id == WM_NCHITTEST:
164
- x = ctypes.c_short(lParam & 0xFFFF).value
165
- y = ctypes.c_short((lParam >> 16) & 0xFFFF).value
166
-
167
- rect = wintypes.RECT()
168
- user32.GetWindowRect(self.hwnd, ctypes.byref(rect))
169
- left, top, right, bottom = rect.left, rect.top, rect.right, rect.bottom
170
- border = self.resize_border
171
-
172
- if left <= x < left + border:
173
- if top <= y < top + border:
174
- return True, 13 # HTTOPLEFT
175
- elif bottom - border <= y < bottom:
176
- return True, 16 # HTBOTTOMLEFT
177
- else:
178
- return True, 10 # HTLEFT
179
- elif right - border <= x < right:
180
- if top <= y < top + border:
181
- return True, 14 # HTTOPRIGHT
182
- elif bottom - border <= y < bottom:
183
- return True, 17 # HTBOTTOMRIGHT
184
- else:
185
- return True, 11 # HTRIGHT
186
- elif top <= y < top + border:
187
- return True, 12 # HTTOP
188
- elif bottom - border <= y < bottom:
189
- return True, 15 # HTBOTTOM
190
-
191
- # 其他区域不处理
192
- return False, 0
193
-
194
- # 移除标题栏
195
- elif message_id == WM_NCCALCSIZE and wParam:
196
- return True, 0
197
-
198
- # 支持动画
199
- elif message_id == WM_SYSCOMMAND:
200
- return False, 0
201
-
202
- # 处理 WM_GETMINMAXINFO 消息以支持 Snap 功能
203
- elif message_id == WM_GETMINMAXINFO:
204
- # 获取屏幕工作区大小
205
- monitor = user32.MonitorFromWindow(self.hwnd, 2) # MONITOR_DEFAULTTONEAREST
206
-
207
- # 使用自定义的 MONITORINFO 结构
208
- monitor_info = MONITORINFO()
209
- monitor_info.cbSize = ctypes.sizeof(MONITORINFO)
210
- monitor_info.dwFlags = 0
211
- user32.GetMonitorInfoW(monitor, ctypes.byref(monitor_info))
212
-
213
- # 获取 MINMAXINFO 结构
214
- minmax_info = MINMAXINFO.from_address(lParam)
215
-
216
- # 设置最大化位置和大小
217
- minmax_info.ptMaxPosition.x = monitor_info.rcWork.left - monitor_info.rcMonitor.left
218
- minmax_info.ptMaxPosition.y = monitor_info.rcWork.top - monitor_info.rcMonitor.top
219
- minmax_info.ptMaxSize.x = monitor_info.rcWork.right - monitor_info.rcWork.left
220
- minmax_info.ptMaxSize.y = monitor_info.rcWork.bottom - monitor_info.rcWork.top
221
-
222
- # 设置最小跟踪大小
223
- minmax_info.ptMinTrackSize.x = 200 # 最小宽度
224
- minmax_info.ptMinTrackSize.y = 150 # 最小高度
225
-
226
- return True, 0
166
+ # 遍历每个窗口,检查哪个窗口收到了消息
167
+ for window in self.windows:
168
+ hwnd_window = self.hwnds.get(window)
169
+ if hwnd_window == hwnd:
170
+ if message_id == WM_NCHITTEST:
171
+ x = ctypes.c_short(lParam & 0xFFFF).value
172
+ y = ctypes.c_short((lParam >> 16) & 0xFFFF).value
173
+
174
+ rect = wintypes.RECT()
175
+ user32.GetWindowRect(hwnd_window, ctypes.byref(rect))
176
+ left, top, right, bottom = rect.left, rect.top, rect.right, rect.bottom
177
+ border = self.resize_border
178
+
179
+ if left <= x < left + border:
180
+ if top <= y < top + border:
181
+ return True, 13 # HTTOPLEFT
182
+ elif bottom - border <= y < bottom:
183
+ return True, 16 # HTBOTTOMLEFT
184
+ else:
185
+ return True, 10 # HTLEFT
186
+ elif right - border <= x < right:
187
+ if top <= y < top + border:
188
+ return True, 14 # HTTOPRIGHT
189
+ elif bottom - border <= y < bottom:
190
+ return True, 17 # HTBOTTOMRIGHT
191
+ else:
192
+ return True, 11 # HTRIGHT
193
+ elif top <= y < top + border:
194
+ return True, 12 # HTTOP
195
+ elif bottom - border <= y < bottom:
196
+ return True, 15 # HTBOTTOM
197
+
198
+ # 其他区域不处理
199
+ return False, 0
200
+
201
+ # 移除标题栏
202
+ elif message_id == WM_NCCALCSIZE and wParam:
203
+ return True, 0
204
+
205
+ # 支持动画
206
+ elif message_id == WM_SYSCOMMAND:
207
+ return False, 0
208
+
209
+ # 处理 WM_GETMINMAXINFO 消息以支持 Snap 功能
210
+ elif message_id == WM_GETMINMAXINFO:
211
+ # 获取屏幕工作区大小
212
+ monitor = user32.MonitorFromWindow(hwnd_window, 2) # MONITOR_DEFAULTTONEAREST
213
+
214
+ # 使用自定义的 MONITORINFO 结构
215
+ monitor_info = MONITORINFO()
216
+ monitor_info.cbSize = ctypes.sizeof(MONITORINFO)
217
+ monitor_info.dwFlags = 0
218
+ user32.GetMonitorInfoW(monitor, ctypes.byref(monitor_info))
219
+
220
+ # 获取 MINMAXINFO 结构
221
+ minmax_info = MINMAXINFO.from_address(lParam)
222
+
223
+ # 设置最大化位置和大小
224
+ minmax_info.ptMaxPosition.x = monitor_info.rcWork.left - monitor_info.rcMonitor.left
225
+ minmax_info.ptMaxPosition.y = monitor_info.rcWork.top - monitor_info.rcMonitor.top
226
+ minmax_info.ptMaxSize.x = monitor_info.rcWork.right - monitor_info.rcWork.left
227
+ minmax_info.ptMaxSize.y = monitor_info.rcWork.bottom - monitor_info.rcWork.top
228
+
229
+ # 设置最小跟踪大小
230
+ minmax_info.ptMinTrackSize.x = 200 # 最小宽度
231
+ minmax_info.ptMinTrackSize.y = 150 # 最小高度
232
+
233
+ return True, 0
227
234
 
228
235
  return False, 0
RinUI/windows/CtrlBtn.qml CHANGED
@@ -26,7 +26,11 @@ Base {
26
26
  } else if (mode===1) {
27
27
  window.showMinimized();
28
28
  } else if (mode===2) {
29
- window.close();
29
+ if (window.transientParent) {
30
+ window.visible = false;
31
+ } else {
32
+ window.close();
33
+ }
30
34
  }
31
35
  }
32
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: RinUI
3
- Version: 0.1.5.1
3
+ Version: 0.1.5.2
4
4
  Summary: A Fluent Design-like UI library for Qt Quick (QML) based on PySide6
5
5
  Author-email: RinLit <lintu233_qwq@icloud.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,4 +1,4 @@
1
- RinUI/__init__.py,sha256=GSLJRklPDTp2IWAkG_7YNn3tTmOWUVAsAj0TROxW5Wc,67
1
+ RinUI/__init__.py,sha256=68D7COFIrSHlQKtabW1X-SFZtRz27mLAEQdjxIJWMB0,67
2
2
  RinUI/qmldir,sha256=M0TVfvNm_nrx1s6rxXvUIP-8m3Oc9UhqHDxQfEIdQTA,3959
3
3
  RinUI/assets/fonts/FluentSystemIcons-Index.js,sha256=M2fUmCiOI7A1rxLWMFaekrB4KmasTSwbociYOzHJegE,253422
4
4
  RinUI/assets/fonts/FluentSystemIcons-Resizable.ttf,sha256=-IfF3NT1eODD0vOLVLC0Z2U5bsR6woSQAziX3qD1TqU,1447252
@@ -72,10 +72,10 @@ RinUI/components/Text/TextField.qml,sha256=BXuJ16AUQaSh-Og7jaYSNEu9r1PcyG7FQ95Da
72
72
  RinUI/components/Text/TextInput.qml,sha256=gyTJmrYi5yuc-j5dDRSbu5PCxiuQo2xNBm6jWL9ezYk,1611
73
73
  RinUI/core/__init__.py,sha256=xNbsFDXuObMebyn0Xsxieenh0fsAEjULqBd9qd8suTY,283
74
74
  RinUI/core/config.py,sha256=h5tbQurVtpnfB10OMTWEZstzsF93zDOPDmbP9NRgvJk,3683
75
- RinUI/core/launcher.py,sha256=oWRsnfH2vNjwFKPiZJ-YTC1eSp4MUnATL-ChEKNzg2U,5841
76
- RinUI/core/theme.py,sha256=r47QltFKy_s-B1neVAjYIx_jOxxtsdJEMP-u-YJ8mpA,9832
75
+ RinUI/core/launcher.py,sha256=pUKcpErcDsDqfTIcZHqG8ErQOHGqkqPnwkUKiEtujBQ,6024
76
+ RinUI/core/theme.py,sha256=GfLFtorGVvRmBCR97hpvwKGVwfrN4AD9FFEIDupVszM,9788
77
77
  RinUI/core/translator.py,sha256=5GK7Iy7-2iMicF8hQr79CwU9UWvCwE-8vGd8QkhJ1h8,1037
78
- RinUI/core/window.py,sha256=9nLjdPmFRp8Yx-qvz1_Cbi6u7JwWJZ5pDH1yFyA1etQ,7649
78
+ RinUI/core/window.py,sha256=vSbcos5B2gioKev6jiVBMtNzn01_ZvieCly6Pw6U5kI,8408
79
79
  RinUI/hooks/__init__.py,sha256=7sQJlly1ZbiZTzZUkCV2hI_gY-DAxWP_0kLyhZQ2Tm8,74
80
80
  RinUI/hooks/hook-RinUI.py,sha256=VvQui-b3YNuxvhqjRJqLPKdtnWQ6Ev8G9DEgzGNUUUI,116
81
81
  RinUI/languages/en_US.qm,sha256=mVm1ELFdGJN4SK0TAH4wRZ0umTxn5WS62_wY-TVpXIU,16
@@ -96,7 +96,7 @@ RinUI/utils/Position.qml,sha256=QuD_cYdU7ku3L1zxFX8e0ZKDvOOW7xbilP2_ebr7WB8,256
96
96
  RinUI/utils/Severity.qml,sha256=fN3YQ_88kNGB-Z57pzcDrz15r-JPMLPJfNUVqKkYbas,155
97
97
  RinUI/utils/Typography.qml,sha256=EJIlEymSWH4lWyRIrdWD9UZaExgGld81YQF1diaKKq8,232
98
98
  RinUI/utils/qmldir,sha256=W2UTrZ5VPdRO64FZ3Pw-_8B2UPj7A_eHsGrLPvWtiZY,189
99
- RinUI/windows/CtrlBtn.qml,sha256=8wQH3PWYmZ_e6A0_CIdmYa7uIrU6O6MZCG_RR4S4fkg,3152
99
+ RinUI/windows/CtrlBtn.qml,sha256=7o67Ci1eKI22tl00s2klnwdmU9mhyzp8UQOTzF_5XtI,3273
100
100
  RinUI/windows/FluentPage.qml,sha256=J7mXTOyMahdWA8U13rSjesJVsvxklZFQyqwVMiJarT8,2748
101
101
  RinUI/windows/FluentWindow.qml,sha256=CUx9H5crOKtPSCnA6_AUst4PcLEbhSjDRrSuWH8novA,969
102
102
  RinUI/windows/FluentWindowBase.qml,sha256=QV0WwRTL997c2Q8TNvsl8fNXLfkZabQvh0O0kT9NxhI,4308
@@ -105,11 +105,11 @@ RinUI/windows/WindowManager.qml,sha256=f-Il6FCPf3_o6edj5BbscK2XxQd3mmUVnZPZuOO88
105
105
  RinUI/windows/qmldir,sha256=oxyWR7Q8dWCrwwCwGNyf3l60qe6s4-beiZWWMAEkKcM,252
106
106
  RinUI/windows/window/ApplicationWindow.qml,sha256=qRaM8IY0TJxfq1j1DogTMyrPjyoXkuWVzxtZQLzRtOQ,167
107
107
  RinUI/windows/window/Window.qml,sha256=90YjjRoaul9qK4FxNy73zTaPuUmLvk_RjcPlBEa7DNI,3189
108
- rinui-0.1.5.1.data/data/LICENSE,sha256=vgoqqpny5vKYu34VDBUWYQKzT7Nn-Xy9y8USmcOCyZQ,1063
109
- rinui-0.1.5.1.data/data/README.md,sha256=8ZcR55RYV2slRAQbhoYhqDTPOLXmewkFSvuA_cE6zD0,3044
110
- rinui-0.1.5.1.dist-info/licenses/LICENSE,sha256=vgoqqpny5vKYu34VDBUWYQKzT7Nn-Xy9y8USmcOCyZQ,1063
111
- rinui-0.1.5.1.dist-info/METADATA,sha256=nQrnatWMZMHFBk427BhBBo5fadWyACzw2Z5b_JVNwPM,3577
112
- rinui-0.1.5.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
- rinui-0.1.5.1.dist-info/entry_points.txt,sha256=taxuZYCggoQa2LPubwcurQYRjBRC4cNYOjWaqOYZVxw,54
114
- rinui-0.1.5.1.dist-info/top_level.txt,sha256=vKKjXBXEw5OFRIzTxZWUC5ZOj0CK5e3atbymBB4eJ6w,6
115
- rinui-0.1.5.1.dist-info/RECORD,,
108
+ rinui-0.1.5.2.data/data/LICENSE,sha256=vgoqqpny5vKYu34VDBUWYQKzT7Nn-Xy9y8USmcOCyZQ,1063
109
+ rinui-0.1.5.2.data/data/README.md,sha256=8ZcR55RYV2slRAQbhoYhqDTPOLXmewkFSvuA_cE6zD0,3044
110
+ rinui-0.1.5.2.dist-info/licenses/LICENSE,sha256=vgoqqpny5vKYu34VDBUWYQKzT7Nn-Xy9y8USmcOCyZQ,1063
111
+ rinui-0.1.5.2.dist-info/METADATA,sha256=19MjmBD4L9YAwV7JCrooUGMA_4OCccUYkULYwJk_FjA,3577
112
+ rinui-0.1.5.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
113
+ rinui-0.1.5.2.dist-info/entry_points.txt,sha256=taxuZYCggoQa2LPubwcurQYRjBRC4cNYOjWaqOYZVxw,54
114
+ rinui-0.1.5.2.dist-info/top_level.txt,sha256=vKKjXBXEw5OFRIzTxZWUC5ZOj0CK5e3atbymBB4eJ6w,6
115
+ rinui-0.1.5.2.dist-info/RECORD,,
File without changes