pyloid 0.12.3__tar.gz → 0.13.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyloid
3
- Version: 0.12.3
3
+ Version: 0.13.0
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyloid"
3
- version = "0.12.3"
3
+ version = "0.13.0"
4
4
  description = ""
5
5
  authors = ["aesthetics-of-record <111675679+aesthetics-of-record@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -262,17 +262,28 @@ class CustomWebEngineView(QWebEngineView):
262
262
  self.parent = parent
263
263
  self.drag_relative_position = None
264
264
  self.is_dragging = False
265
+ self.is_resizing = False
266
+ self.resize_start_pos = None
267
+ self.resize_direction = None
265
268
  self.screen_geometry = self.screen().availableGeometry()
269
+ self.is_resizing_enabled = True
266
270
 
267
271
  def mouse_press_event(self, event):
268
272
  if event.button() == Qt.LeftButton:
269
273
  self.drag_relative_position = event.pos()
274
+ if not self.parent.frame and self.is_resizing_enabled:
275
+ self.resize_direction = self.get_resize_direction(event.pos())
276
+ if self.resize_direction:
277
+ self.is_resizing = True
278
+ self.resize_start_pos = event.globalPos()
270
279
 
271
280
  def start_system_drag(self):
272
281
  self.is_dragging = True
273
282
 
274
283
  def mouse_move_event(self, event):
275
- if not self.parent.frame and self.is_dragging:
284
+ if self.is_resizing and self.is_resizing_enabled:
285
+ self.resize_window(event.globalPos())
286
+ elif not self.parent.frame and self.is_dragging:
276
287
  # 현재 마우스 위치를 전역 좌표로 가져옵니다
277
288
  current_global_pos = event.globalPos()
278
289
 
@@ -296,10 +307,20 @@ class CustomWebEngineView(QWebEngineView):
296
307
 
297
308
  # 창을 새 위치로 이동합니다
298
309
  self.parent._window.move(new_window_pos)
310
+ else:
311
+ # Change cursor based on resize direction
312
+ resize_direction = self.get_resize_direction(event.pos())
313
+ if resize_direction and self.is_resizing_enabled:
314
+ self.set_cursor_for_resize_direction(resize_direction)
315
+ else:
316
+ self.unsetCursor()
299
317
 
300
318
  def mouse_release_event(self, event):
301
319
  if event.button() == Qt.LeftButton:
302
320
  self.is_dragging = False
321
+ self.is_resizing = False
322
+ self.resize_direction = None
323
+ self.unsetCursor()
303
324
 
304
325
  def eventFilter(self, source, event):
305
326
  if self.focusProxy() is source:
@@ -311,6 +332,53 @@ class CustomWebEngineView(QWebEngineView):
311
332
  self.mouse_release_event(event)
312
333
  return super().eventFilter(source, event)
313
334
 
335
+ def get_resize_direction(self, pos):
336
+ if not self.parent.frame and self.is_resizing_enabled: # Check if frame is not present and resizing is enabled
337
+ margin = 5 # Margin in pixels to detect edge
338
+ rect = self.rect()
339
+ direction = None
340
+
341
+ if pos.x() <= margin:
342
+ direction = 'left'
343
+ elif pos.x() >= rect.width() - margin:
344
+ direction = 'right'
345
+
346
+ if pos.y() <= margin:
347
+ direction = 'top' if direction is None else direction + '-top'
348
+ elif pos.y() >= rect.height() - margin:
349
+ direction = 'bottom' if direction is None else direction + '-bottom'
350
+
351
+ return direction
352
+ return None
353
+
354
+ def set_cursor_for_resize_direction(self, direction):
355
+ if not self.parent.frame and direction and self.is_resizing_enabled: # Check if frame is not present and resizing is enabled
356
+ if direction in ['left', 'right']:
357
+ self.setCursor(Qt.SizeHorCursor)
358
+ elif direction in ['top', 'bottom']:
359
+ self.setCursor(Qt.SizeVerCursor)
360
+ elif direction in ['left-top', 'right-bottom']:
361
+ self.setCursor(Qt.SizeFDiagCursor)
362
+ elif direction in ['right-top', 'left-bottom']:
363
+ self.setCursor(Qt.SizeBDiagCursor)
364
+
365
+ def resize_window(self, global_pos):
366
+ if not self.parent.frame and self.resize_start_pos and self.resize_direction and self.is_resizing_enabled: # Check if frame is not present and resizing is enabled
367
+ delta = global_pos - self.resize_start_pos
368
+ new_geometry = self.parent._window.geometry()
369
+
370
+ if 'left' in self.resize_direction:
371
+ new_geometry.setLeft(new_geometry.left() + delta.x())
372
+ if 'right' in self.resize_direction:
373
+ new_geometry.setRight(new_geometry.right() + delta.x())
374
+ if 'top' in self.resize_direction:
375
+ new_geometry.setTop(new_geometry.top() + delta.y())
376
+ if 'bottom' in self.resize_direction:
377
+ new_geometry.setBottom(new_geometry.bottom() + delta.y())
378
+
379
+ self.parent._window.setGeometry(new_geometry)
380
+ self.resize_start_pos = global_pos
381
+
314
382
 
315
383
  class BrowserWindow:
316
384
  def __init__(
@@ -758,20 +826,49 @@ class BrowserWindow:
758
826
  def get_visible(self) -> bool:
759
827
  """Returns the visibility of the window."""
760
828
  return self._window.isVisible()
761
-
829
+
830
+ def get_frame(self) -> bool:
831
+ """Returns the frame enabled state of the window."""
832
+ return self.frame
833
+
834
+ ###########################################################################################
835
+ # Resize
836
+ ###########################################################################################
762
837
  def set_resizable(self, resizable: bool):
763
838
  """Sets the resizability of the window."""
764
839
  self.resizable = resizable
765
- if resizable:
766
- self._window.setWindowFlags(
767
- self._window.windowFlags() & ~Qt.MSWindowsFixedSizeDialogHint
768
- )
840
+ if self.frame:
841
+ flags = self._window.windowFlags() | Qt.WindowCloseButtonHint
842
+ if resizable:
843
+ pass
844
+ else:
845
+ flags |= Qt.MSWindowsFixedSizeDialogHint
846
+ self._window.setWindowFlags(flags)
769
847
  else:
770
- self._window.setWindowFlags(
771
- self._window.windowFlags() | Qt.MSWindowsFixedSizeDialogHint
772
- )
848
+ # 프레임이 없는 경우 커스텀 리사이징 로직을 설정합니다.
849
+ self.web_view.is_resizing_enabled = resizable
850
+
773
851
  self._window.show() # 변경사항을 적용하기 위해 창을 다시 표시합니다.
774
852
 
853
+ def set_minimum_size(self, min_width: int, min_height: int):
854
+ """Sets the minimum size of the window."""
855
+ self._window.setMinimumSize(min_width, min_height)
856
+
857
+ def set_maximum_size(self, max_width: int, max_height: int):
858
+ """Sets the maximum size of the window."""
859
+ self._window.setMaximumSize(max_width, max_height)
860
+
861
+ def get_minimum_size(self):
862
+ """Returns the minimum size of the window."""
863
+ return {'width': self._window.minimumWidth(), 'height': self._window.minimumHeight()}
864
+
865
+ def get_maximum_size(self):
866
+ """Returns the maximum size of the window."""
867
+ return {'width': self._window.maximumWidth(), 'height': self._window.maximumHeight()}
868
+
869
+ def get_resizable(self):
870
+ """Returns the resizability of the window."""
871
+ return self.resizable
775
872
 
776
873
  class _WindowController(QObject):
777
874
  create_window_signal = Signal(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes