pyloid 0.11.4__py3-none-any.whl → 0.11.5__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.
pyloid/pyloid.py CHANGED
@@ -18,7 +18,7 @@ from PySide6.QtGui import (
18
18
  QPalette,
19
19
  QColor,
20
20
  )
21
- from PySide6.QtCore import Qt, Signal, QUrl, QObject, QTimer
21
+ from PySide6.QtCore import Qt, Signal, QPoint, QUrl, QObject, QTimer, QSize
22
22
  from PySide6.QtNetwork import QLocalServer, QLocalSocket
23
23
  from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineSettings
24
24
  from .api import PyloidAPI, Bridge
@@ -32,7 +32,9 @@ import json
32
32
  from .autostart import AutoStart
33
33
  from .filewatcher import FileWatcher
34
34
  import logging
35
- from PySide6.QtCore import QCoreApplication, QtMsgType
35
+ from PySide6.QtGui import QPalette, QColor
36
+ from PySide6.QtWidgets import QWidget, QVBoxLayout, QLabel, QPushButton, QHBoxLayout, QSizePolicy
37
+ from PySide6.QtGui import QPixmap
36
38
 
37
39
  # for linux debug
38
40
  os.environ["QTWEBENGINE_DICTIONARIES_PATH"] = "/"
@@ -243,6 +245,106 @@ class WindowAPI(PyloidAPI):
243
245
  # callback(*args, **kwargs)
244
246
 
245
247
 
248
+ class CustomTitleBar(QWidget):
249
+ def __init__(self, parent=None):
250
+ super().__init__(parent)
251
+ self.layout = QHBoxLayout(self)
252
+ self.layout.setContentsMargins(5, 0, 5, 0)
253
+ self.layout.setSpacing(0)
254
+
255
+ self.icon_label = QLabel()
256
+ self.icon_label.setFixedSize(20, 20)
257
+ self.title = QLabel("Custom Title")
258
+
259
+ self.minimize_button = QPushButton("-")
260
+ self.maximize_button = QPushButton("❐")
261
+ self.close_button = QPushButton("×")
262
+
263
+ for button in (self.minimize_button, self.maximize_button, self.close_button):
264
+ button.setFixedSize(45, 30)
265
+ button.setFlat(True)
266
+
267
+ self.layout.addWidget(self.icon_label)
268
+ self.layout.addSpacing(5)
269
+ self.layout.addWidget(self.title)
270
+ self.layout.addStretch(1)
271
+ self.layout.addWidget(self.minimize_button)
272
+ self.layout.addWidget(self.maximize_button)
273
+ self.layout.addWidget(self.close_button)
274
+
275
+ self.minimize_button.clicked.connect(self.window().showMinimized)
276
+ self.maximize_button.clicked.connect(self.toggle_maximize)
277
+ self.close_button.clicked.connect(self.window().close)
278
+
279
+ self.setFixedHeight(30)
280
+ self.set_style("darkblue", "white")
281
+
282
+ def set_style(self, bg_color, text_color):
283
+ self.setAutoFillBackground(True)
284
+ palette = self.palette()
285
+ bg_qcolor = QColor(bg_color)
286
+ text_qcolor = QColor(text_color)
287
+ palette.setColor(QPalette.Window, bg_qcolor)
288
+ palette.setColor(QPalette.WindowText, text_qcolor)
289
+ self.setPalette(palette)
290
+
291
+ self.title.setStyleSheet(f"color: {text_color}; font-weight: bold;")
292
+
293
+ button_style = f"""
294
+ QPushButton {{
295
+ background-color: {bg_color};
296
+ color: {text_color};
297
+ border: none;
298
+ font-family: Arial;
299
+ font-size: 14px;
300
+ padding: 0px;
301
+ text-align: center;
302
+ }}
303
+ QPushButton:hover {{
304
+ background-color: {bg_qcolor.lighter(120).name()};
305
+ }}
306
+ QPushButton:pressed {{
307
+ background-color: {bg_qcolor.darker(110).name()};
308
+ }}
309
+ """
310
+ for button in (self.minimize_button, self.maximize_button, self.close_button):
311
+ button.setStyleSheet(button_style)
312
+
313
+ self.close_button.setStyleSheet(button_style + f"""
314
+ QPushButton:hover {{
315
+ background-color: #e81123;
316
+ color: white;
317
+ }}
318
+ """)
319
+
320
+ def mousePressEvent(self, event):
321
+ if event.button() == Qt.LeftButton:
322
+ self.window().moving = True
323
+ self.window().offset = event.pos()
324
+
325
+ def mouseMoveEvent(self, event):
326
+ if self.window().moving:
327
+ self.window().move(event.globalPos() - self.window().offset)
328
+
329
+ def mouseReleaseEvent(self, event):
330
+ if event.button() == Qt.LeftButton:
331
+ self.window().moving = False
332
+
333
+ def toggle_maximize(self):
334
+ if self.window().isMaximized():
335
+ self.window().showNormal()
336
+ self.maximize_button.setText("❐")
337
+ else:
338
+ self.window().showMaximized()
339
+ self.maximize_button.setText("❐")
340
+
341
+ def set_icon(self, icon_path):
342
+ pixmap = QPixmap(icon_path)
343
+ self.icon_label.setPixmap(pixmap.scaled(20, 20, Qt.KeepAspectRatio, Qt.SmoothTransformation))
344
+
345
+ def set_title(self, title):
346
+ self.title.setText(title)
347
+
246
348
  class BrowserWindow:
247
349
  def __init__(
248
350
  self,
@@ -280,6 +382,37 @@ class BrowserWindow:
280
382
  self.shortcuts = {}
281
383
  ###########################################################################################
282
384
 
385
+ def set_custom_frame(self, use_custom: bool, title: str = "Custom Title", bg_color: str = "darkblue", text_color: str = "white", icon_path: str = None):
386
+ """커스텀 프레임을 설정하거나 제거합니다."""
387
+ if use_custom:
388
+ self._window.setWindowFlags(Qt.FramelessWindowHint)
389
+ self.custom_title_bar = CustomTitleBar(self._window)
390
+ self.custom_title_bar.set_style(bg_color, text_color)
391
+ self.custom_title_bar.set_title(title)
392
+
393
+ if icon_path:
394
+ self.custom_title_bar.set_icon(icon_path)
395
+
396
+ layout = QVBoxLayout()
397
+ layout.setContentsMargins(0, 0, 0, 0)
398
+ layout.setSpacing(0)
399
+ layout.addWidget(self.custom_title_bar)
400
+ layout.addWidget(self.web_view)
401
+
402
+ central_widget = QWidget()
403
+ central_widget.setLayout(layout)
404
+ self._window.setCentralWidget(central_widget)
405
+
406
+ # 창 이동을 위한 속성 추가
407
+ self._window.moving = False
408
+ self._window.offset = QPoint()
409
+ else:
410
+ self._window.setWindowFlags(Qt.Window)
411
+ self._window.setCentralWidget(self.web_view)
412
+ self.custom_title_bar = None
413
+
414
+ self._window.show()
415
+
283
416
  def _load(self):
284
417
  self._window.setWindowTitle(self.title)
285
418
 
@@ -643,9 +776,15 @@ class BrowserWindow:
643
776
  """Returns the visibility of the window."""
644
777
  return self._window.isVisible()
645
778
 
779
+ def set_resizable(self, resizable: bool):
780
+ """창의 크기 조절 가능 여부를 설정합니다."""
781
+ self.resizable = resizable
782
+ if resizable:
783
+ self._window.setWindowFlags(self._window.windowFlags() & ~Qt.MSWindowsFixedSizeDialogHint)
784
+ else:
785
+ self._window.setWindowFlags(self._window.windowFlags() | Qt.MSWindowsFixedSizeDialogHint)
786
+ self._window.show() # 변경사항을 적용하기 위해 창을 다시 표시합니다.
646
787
 
647
-
648
-
649
788
 
650
789
  class _WindowController(QObject):
651
790
  create_window_signal = Signal(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyloid
3
- Version: 0.11.4
3
+ Version: 0.11.5
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -3,11 +3,11 @@ pyloid/api.py,sha256=whgfvPr1A6iwZ1Ewo-0FnOUNnt1K58c-P7YjzuQHcUM,194
3
3
  pyloid/autostart.py,sha256=K7DQYl4LHItvPp0bt1V9WwaaZmVSTeGvadkcwG-KKrI,3899
4
4
  pyloid/filewatcher.py,sha256=n8N56D65le5TpsgxXb7z-FO_0lqv4UYD4yGq_UuMrAs,1285
5
5
  pyloid/monitor.py,sha256=fqDnZ_7dpxVZLVJ5gCluDRY2USrQ5YL_fw1AnYivhsk,12741
6
- pyloid/pyloid.py,sha256=U5sj7eFQD2pHmGvZS7OEzp9t1ijFOvl9ocyxKRJeBxQ,43979
6
+ pyloid/pyloid.py,sha256=JMvWDd-3IA9wcpZSlzdMBIPK8F7v1O_1o8N58LkBlO4,49556
7
7
  pyloid/timer.py,sha256=1bYhqte3rV77vaeMUkcTgmx2ux7FtCqLCx9lIC2-COg,4360
8
8
  pyloid/tray.py,sha256=rXgdkvzGxtie_EIcTSA7fjuta4nJk5THhNkGFcfv5Ew,634
9
9
  pyloid/utils.py,sha256=DQerZWU_0o8dHcJ5y3yXf9i5OXn7KQZqU-hVBq3uPUA,711
10
- pyloid-0.11.4.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
11
- pyloid-0.11.4.dist-info/METADATA,sha256=0SydL9Dkvkujxp9ekLEmsZrAGyUrNIiw_Rk_w4omhN4,6069
12
- pyloid-0.11.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
- pyloid-0.11.4.dist-info/RECORD,,
10
+ pyloid-0.11.5.dist-info/LICENSE,sha256=F96EzotgWhhpnQTW2TcdoqrMDir1jyEo6H915tGQ-QE,11524
11
+ pyloid-0.11.5.dist-info/METADATA,sha256=vp2aFxKcfVB42nBnkWlsFPNcb-xzHrigWIQD-TiHIXw,6069
12
+ pyloid-0.11.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
+ pyloid-0.11.5.dist-info/RECORD,,