pyloid 0.17.2__py3-none-any.whl → 0.17.4__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pyloid/api.py CHANGED
@@ -1,4 +1,9 @@
1
1
  from PySide6.QtCore import QObject, Slot
2
+ from typing import TYPE_CHECKING
3
+
4
+ if TYPE_CHECKING:
5
+ from pyloid.pyloid import Pyloid
6
+ from pyloid.browser_window import BrowserWindow
2
7
 
3
8
 
4
9
  class PyloidAPI(QObject):
@@ -45,6 +50,9 @@ class PyloidAPI(QObject):
45
50
 
46
51
  def __init__(self):
47
52
  super().__init__()
53
+ self.window_id: str = None
54
+ self.window: "BrowserWindow" = None
55
+ self.app: "Pyloid" = None
48
56
 
49
57
 
50
58
  def Bridge(*args, **kwargs):
pyloid/browser_window.py CHANGED
@@ -72,7 +72,7 @@ class CustomWebEngineView(QWebEngineView):
72
72
  super().__init__(parent._window)
73
73
  self.parent: "BrowserWindow" = parent
74
74
 
75
- # 커스텀 페이지 설정
75
+ # Custom Web Page
76
76
  self.custom_page = CustomWebPage()
77
77
  self.setPage(self.custom_page)
78
78
 
@@ -81,36 +81,63 @@ class CustomWebEngineView(QWebEngineView):
81
81
  self.resize_direction = None
82
82
  self.screen_geometry = self.screen().virtualGeometry()
83
83
  self.is_resizing_enabled = True
84
+
85
+ self.setAttribute(Qt.WA_SetCursor, False)
86
+
87
+ self.is_in_resize_area = False
84
88
 
85
89
  def mouse_press_event(self, event):
90
+ if self.parent.frame or not self.is_resizing_enabled:
91
+ return
92
+
86
93
  if event.button() == Qt.LeftButton:
87
- if not self.parent.frame and self.is_resizing_enabled:
88
- self.resize_direction = self.get_resize_direction(event.pos())
89
- if self.resize_direction:
90
- self.is_resizing = True
91
- self.resize_start_pos = event.globalPos()
94
+ self.resize_direction = self.get_resize_direction(event.pos())
95
+ if self.resize_direction:
96
+ self.is_resizing = True
97
+ self.resize_start_pos = event.globalPos()
92
98
 
93
99
  def start_system_drag(self):
94
- """네이티브 시스템 이동 시작"""
100
+ """Start system window move"""
95
101
  if self.parent._window.windowHandle():
96
102
  self.parent._window.windowHandle().startSystemMove()
97
103
 
98
104
  def mouse_move_event(self, event):
99
- if self.is_resizing and self.is_resizing_enabled:
105
+ if self.parent.frame or not self.is_resizing_enabled:
106
+ return
107
+
108
+ # Check resize direction
109
+ was_in_resize_area = self.is_in_resize_area
110
+ resize_direction = self.get_resize_direction(event.pos())
111
+ self.is_in_resize_area = bool(resize_direction)
112
+
113
+ if resize_direction and not self.is_resizing:
114
+ self.set_cursor_for_resize_direction(resize_direction)
115
+
116
+ if self.is_resizing:
100
117
  self.resize_window(event.globalPos())
101
- else:
102
- # Change cursor based on resize direction
103
- resize_direction = self.get_resize_direction(event.pos())
104
- if resize_direction and self.is_resizing_enabled:
105
- self.set_cursor_for_resize_direction(resize_direction)
118
+ return
119
+
120
+ # Change cursor when entering/leaving resize area
121
+ if self.is_in_resize_area != was_in_resize_area:
122
+ if self.is_in_resize_area:
123
+ # self.setAttribute(Qt.WA_SetCursor, True)
124
+ pass
106
125
  else:
107
126
  self.unsetCursor()
127
+ # self.setAttribute(Qt.WA_SetCursor, False)
108
128
 
109
129
  def mouse_release_event(self, event):
130
+ if self.parent.frame or not self.is_resizing_enabled:
131
+ return
132
+
110
133
  if event.button() == Qt.LeftButton:
111
134
  self.is_resizing = False
112
- self.resize_direction = None
113
- self.unsetCursor()
135
+
136
+ if self.resize_direction:
137
+ self.unsetCursor()
138
+ self.resize_direction = None
139
+
140
+ self.setAttribute(Qt.WA_SetCursor, False)
114
141
 
115
142
  def eventFilter(self, source, event):
116
143
  if self.focusProxy() is source:
@@ -126,7 +153,7 @@ class CustomWebEngineView(QWebEngineView):
126
153
  if (
127
154
  not self.parent.frame and self.is_resizing_enabled
128
155
  ): # Check if frame is not present and resizing is enabled
129
- margin = 5 # Margin in pixels to detect edge
156
+ margin = 8 # Margin in pixels to detect edge
130
157
  rect = self.rect()
131
158
  direction = None
132
159
 
@@ -144,17 +171,20 @@ class CustomWebEngineView(QWebEngineView):
144
171
  return None
145
172
 
146
173
  def set_cursor_for_resize_direction(self, direction):
147
- if (
148
- not self.parent.frame and direction and self.is_resizing_enabled
149
- ): # Check if frame is not present and resizing is enabled
174
+ if not self.parent.frame and direction and self.is_resizing_enabled:
175
+ cursor = None
150
176
  if direction in ["left", "right"]:
151
- self.setCursor(Qt.SizeHorCursor)
177
+ cursor = Qt.SizeHorCursor
152
178
  elif direction in ["top", "bottom"]:
153
- self.setCursor(Qt.SizeVerCursor)
179
+ cursor = Qt.SizeVerCursor
154
180
  elif direction in ["left-top", "right-bottom"]:
155
- self.setCursor(Qt.SizeFDiagCursor)
181
+ cursor = Qt.SizeFDiagCursor
156
182
  elif direction in ["right-top", "left-bottom"]:
157
- self.setCursor(Qt.SizeBDiagCursor)
183
+ cursor = Qt.SizeBDiagCursor
184
+
185
+ if cursor:
186
+ self.setCursor(cursor)
187
+ self.setAttribute(Qt.WA_SetCursor, True)
158
188
 
159
189
  def resize_window(self, global_pos):
160
190
  if (
@@ -209,7 +239,7 @@ class BrowserWindow:
209
239
  self.frame = frame
210
240
  self.context_menu = context_menu
211
241
  self.dev_tools = dev_tools
212
- self.js_apis = [WindowAPI(self.id, self.app)]
242
+ self.js_apis = [WindowAPI()]
213
243
  for js_api in js_apis:
214
244
  self.js_apis.append(js_api)
215
245
  self.shortcuts = {}
@@ -344,6 +374,11 @@ class BrowserWindow:
344
374
  # Register additional JS APIs
345
375
  if self.js_apis:
346
376
  for js_api in self.js_apis:
377
+ # Define window_id, window, and app for each JS API
378
+ js_api.window_id = self.id
379
+ js_api.window = self
380
+ js_api.app = self.app
381
+
347
382
  self.channel.registerObject(js_api.__class__.__name__, js_api)
348
383
 
349
384
  self.web_view.page().setWebChannel(self.channel)
@@ -1856,7 +1891,7 @@ class BrowserWindow:
1856
1891
  Parameters
1857
1892
  ----------
1858
1893
  handler : callable
1859
- 요청을 처리할 핸들러 함수. QWebEngineDesktopMediaRequest 인자로 받습니다.
1894
+ 요청을 처리할 핸들러 함수. QWebEngineDesktopMediaRequest��� 인자로 받습니다.
1860
1895
 
1861
1896
  Examples
1862
1897
  --------
@@ -8,10 +8,10 @@ if TYPE_CHECKING:
8
8
  from ..pyloid import Pyloid
9
9
 
10
10
  class WindowAPI(PyloidAPI):
11
- def __init__(self, window_id: str, app: 'Pyloid'):
12
- super().__init__()
13
- self.window_id: str = window_id
14
- self.app: 'Pyloid' = app
11
+ # def __init__(self, window_id: str, app: 'Pyloid'):
12
+ # super().__init__()
13
+ # self.window_id: str = window_id
14
+ # self.app: 'Pyloid' = app
15
15
 
16
16
  @Bridge(result=str)
17
17
  def getWindowId(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyloid
3
- Version: 0.17.2
3
+ Version: 0.17.4
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -1,18 +1,18 @@
1
1
  pyloid/__init__.py,sha256=OOPhOKNQVmAM8hnfTeE7lHzxb8LsFNcgegBAvDrA-vY,293
2
- pyloid/api.py,sha256=np0pFVUlen_GpN0svY0A3awY_ZjVFk-RpHQZZKFUMuo,2157
2
+ pyloid/api.py,sha256=A61Kmddh8BlpT3LfA6NbPQNzFmD95vQ4WKX53oKsGYU,2419
3
3
  pyloid/autostart.py,sha256=K7DQYl4LHItvPp0bt1V9WwaaZmVSTeGvadkcwG-KKrI,3899
4
- pyloid/browser_window.py,sha256=BYjzcP6tPg-3Splai-v60-0LZ2gXeyk0QUrcy6rHydA,61946
4
+ pyloid/browser_window.py,sha256=6Es-DH45URUV6rlCBWj3ZWwrXLMUvqp5700WlU8Sdwo,62984
5
5
  pyloid/custom/titlebar.py,sha256=itzK9pJbZMQ7BKca9kdbuHMffurrw15UijR6OU03Xsk,3894
6
6
  pyloid/filewatcher.py,sha256=3M5zWVUf1OhlkWJcDFC8ZA9agO4Q-U8WdgGpy6kaVz0,4601
7
7
  pyloid/js_api/event_api.py,sha256=_52yyBonqecmMvJpFW7OMNi_jX8Nrteqw_kI6r-DGG0,951
8
- pyloid/js_api/window_api.py,sha256=QutXXAOZkpYmytOYSenpzVSCl15-OFEjDDr75fHfLvk,8481
8
+ pyloid/js_api/window_api.py,sha256=BsAO4VBkqfUPib4f7AHxaMRXvN3FvzMXDBsqSUAay3c,8489
9
9
  pyloid/monitor.py,sha256=1mXvHm5deohnNlTLcRx4sT4x-stnOIb0dUQnnxN50Uo,28295
10
10
  pyloid/pyloid.py,sha256=YKE2a5yZFbBZrtMND2X5I7CVnFRK40NFzDp3kYN-oQg,44091
11
11
  pyloid/thread_pool.py,sha256=fKOBb8jMfZn_7crA_fJCno8dObBRZE31EIWaNQ759aw,14616
12
12
  pyloid/timer.py,sha256=RqMsChFUd93cxMVgkHWiIKrci0QDTBgJSTULnAtYT8M,8712
13
13
  pyloid/tray.py,sha256=D12opVEc2wc2T4tK9epaN1oOdeziScsIVNM2uCN7C-A,1710
14
14
  pyloid/utils.py,sha256=XPM2PxO0LQ_eAnba5pKJ3vYsCev91JMFmv13EFuAy5o,2620
15
- pyloid-0.17.2.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
16
- pyloid-0.17.2.dist-info/METADATA,sha256=lJOqRUrgEu8dFENvWV7l2qH5w7oQVKD3RxHyr5zaNjM,3054
17
- pyloid-0.17.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
18
- pyloid-0.17.2.dist-info/RECORD,,
15
+ pyloid-0.17.4.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
16
+ pyloid-0.17.4.dist-info/METADATA,sha256=bqZ7DTwKxdvSw2wurQBe5EiCCOa-vXEEW6gXYVrg3rY,3054
17
+ pyloid-0.17.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
18
+ pyloid-0.17.4.dist-info/RECORD,,