pyloid 0.15.0__tar.gz → 0.15.2__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyloid-0.15.0 → pyloid-0.15.2}/LICENSE +1 -1
- {pyloid-0.15.0 → pyloid-0.15.2}/PKG-INFO +1 -1
- {pyloid-0.15.0 → pyloid-0.15.2}/pyproject.toml +1 -1
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/browser_window.py +76 -25
- {pyloid-0.15.0 → pyloid-0.15.2}/README.md +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/__init__.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/api.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/autostart.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/custom/titlebar.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/filewatcher.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/js_api/event_api.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/js_api/window_api.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/monitor.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/pyloid.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/timer.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/tray.py +0 -0
- {pyloid-0.15.0 → pyloid-0.15.2}/src/pyloid/utils.py +0 -0
@@ -198,4 +198,4 @@ Apache License
|
|
198
198
|
distributed under the License is distributed on an "AS IS" BASIS,
|
199
199
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
200
|
See the License for the specific language governing permissions and
|
201
|
-
limitations under the License.
|
201
|
+
limitations under the License.
|
@@ -10,7 +10,7 @@ from PySide6.QtGui import (
|
|
10
10
|
QShortcut,
|
11
11
|
QCursor,
|
12
12
|
)
|
13
|
-
from PySide6.QtCore import Qt, QPoint, QUrl, QEvent
|
13
|
+
from PySide6.QtCore import Qt, QPoint, QUrl, QEvent, QFile
|
14
14
|
from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineSettings
|
15
15
|
from .api import PyloidAPI
|
16
16
|
import uuid
|
@@ -24,7 +24,6 @@ from .custom.titlebar import CustomTitleBar
|
|
24
24
|
from .js_api.window_api import WindowAPI
|
25
25
|
|
26
26
|
|
27
|
-
|
28
27
|
# 어차피 load 부분에만 쓰이니까 나중에 분리해서 load 위에서 선언하자.
|
29
28
|
class CustomWebEngineView(QWebEngineView):
|
30
29
|
def __init__(self, parent=None):
|
@@ -40,7 +39,7 @@ class CustomWebEngineView(QWebEngineView):
|
|
40
39
|
|
41
40
|
def mouse_press_event(self, event):
|
42
41
|
if event.button() == Qt.LeftButton:
|
43
|
-
self.drag_relative_position = event.pos()
|
42
|
+
self.drag_relative_position = event.globalPos() - self.parent._window.pos()
|
44
43
|
if not self.parent.frame and self.is_resizing_enabled:
|
45
44
|
self.resize_direction = self.get_resize_direction(event.pos())
|
46
45
|
if self.resize_direction:
|
@@ -103,47 +102,56 @@ class CustomWebEngineView(QWebEngineView):
|
|
103
102
|
return super().eventFilter(source, event)
|
104
103
|
|
105
104
|
def get_resize_direction(self, pos):
|
106
|
-
if
|
105
|
+
if (
|
106
|
+
not self.parent.frame and self.is_resizing_enabled
|
107
|
+
): # Check if frame is not present and resizing is enabled
|
107
108
|
margin = 5 # Margin in pixels to detect edge
|
108
109
|
rect = self.rect()
|
109
110
|
direction = None
|
110
111
|
|
111
112
|
if pos.x() <= margin:
|
112
|
-
direction =
|
113
|
+
direction = "left"
|
113
114
|
elif pos.x() >= rect.width() - margin:
|
114
|
-
direction =
|
115
|
+
direction = "right"
|
115
116
|
|
116
117
|
if pos.y() <= margin:
|
117
|
-
direction =
|
118
|
+
direction = "top" if direction is None else direction + "-top"
|
118
119
|
elif pos.y() >= rect.height() - margin:
|
119
|
-
direction =
|
120
|
+
direction = "bottom" if direction is None else direction + "-bottom"
|
120
121
|
|
121
122
|
return direction
|
122
123
|
return None
|
123
124
|
|
124
125
|
def set_cursor_for_resize_direction(self, direction):
|
125
|
-
if
|
126
|
-
|
126
|
+
if (
|
127
|
+
not self.parent.frame and direction and self.is_resizing_enabled
|
128
|
+
): # Check if frame is not present and resizing is enabled
|
129
|
+
if direction in ["left", "right"]:
|
127
130
|
self.setCursor(Qt.SizeHorCursor)
|
128
|
-
elif direction in [
|
131
|
+
elif direction in ["top", "bottom"]:
|
129
132
|
self.setCursor(Qt.SizeVerCursor)
|
130
|
-
elif direction in [
|
133
|
+
elif direction in ["left-top", "right-bottom"]:
|
131
134
|
self.setCursor(Qt.SizeFDiagCursor)
|
132
|
-
elif direction in [
|
135
|
+
elif direction in ["right-top", "left-bottom"]:
|
133
136
|
self.setCursor(Qt.SizeBDiagCursor)
|
134
137
|
|
135
138
|
def resize_window(self, global_pos):
|
136
|
-
if
|
139
|
+
if (
|
140
|
+
not self.parent.frame
|
141
|
+
and self.resize_start_pos
|
142
|
+
and self.resize_direction
|
143
|
+
and self.is_resizing_enabled
|
144
|
+
): # Check if frame is not present and resizing is enabled
|
137
145
|
delta = global_pos - self.resize_start_pos
|
138
146
|
new_geometry = self.parent._window.geometry()
|
139
147
|
|
140
|
-
if
|
148
|
+
if "left" in self.resize_direction:
|
141
149
|
new_geometry.setLeft(new_geometry.left() + delta.x())
|
142
|
-
if
|
150
|
+
if "right" in self.resize_direction:
|
143
151
|
new_geometry.setRight(new_geometry.right() + delta.x())
|
144
|
-
if
|
152
|
+
if "top" in self.resize_direction:
|
145
153
|
new_geometry.setTop(new_geometry.top() + delta.y())
|
146
|
-
if
|
154
|
+
if "bottom" in self.resize_direction:
|
147
155
|
new_geometry.setBottom(new_geometry.bottom() + delta.y())
|
148
156
|
|
149
157
|
self.parent._window.setGeometry(new_geometry)
|
@@ -278,6 +286,14 @@ class BrowserWindow:
|
|
278
286
|
def _on_load_finished(self, ok):
|
279
287
|
"""Handles the event when the web page finishes loading."""
|
280
288
|
if ok and self.js_apis:
|
289
|
+
|
290
|
+
# Load qwebchannel.js
|
291
|
+
qwebchannel_js = QFile("://qtwebchannel/qwebchannel.js")
|
292
|
+
if qwebchannel_js.open(QFile.ReadOnly):
|
293
|
+
source = bytes(qwebchannel_js.readAll()).decode("utf-8")
|
294
|
+
self.web_view.page().runJavaScript(source)
|
295
|
+
qwebchannel_js.close()
|
296
|
+
|
281
297
|
js_code = """
|
282
298
|
if (typeof QWebChannel !== 'undefined') {
|
283
299
|
new QWebChannel(qt.webChannelTransport, function (channel) {
|
@@ -702,7 +718,7 @@ class BrowserWindow:
|
|
702
718
|
def is_fullscreen(self) -> bool:
|
703
719
|
"""
|
704
720
|
Returns True if the window is fullscreen.
|
705
|
-
|
721
|
+
|
706
722
|
Examples
|
707
723
|
--------
|
708
724
|
>>> app = Pyloid(app_name="Pyloid-App")
|
@@ -1062,7 +1078,7 @@ class BrowserWindow:
|
|
1062
1078
|
```
|
1063
1079
|
"""
|
1064
1080
|
return self._window.isVisible()
|
1065
|
-
|
1081
|
+
|
1066
1082
|
def get_frame(self) -> bool:
|
1067
1083
|
"""
|
1068
1084
|
Returns the frame enabled state of the window.
|
@@ -1085,7 +1101,7 @@ class BrowserWindow:
|
|
1085
1101
|
```
|
1086
1102
|
"""
|
1087
1103
|
return self.frame
|
1088
|
-
|
1104
|
+
|
1089
1105
|
###########################################################################################
|
1090
1106
|
# Resize
|
1091
1107
|
###########################################################################################
|
@@ -1192,7 +1208,10 @@ class BrowserWindow:
|
|
1192
1208
|
app.run()
|
1193
1209
|
```
|
1194
1210
|
"""
|
1195
|
-
return {
|
1211
|
+
return {
|
1212
|
+
"width": self._window.minimumWidth(),
|
1213
|
+
"height": self._window.minimumHeight(),
|
1214
|
+
}
|
1196
1215
|
|
1197
1216
|
def get_maximum_size(self) -> Dict[str, int]:
|
1198
1217
|
"""
|
@@ -1215,8 +1234,11 @@ class BrowserWindow:
|
|
1215
1234
|
app.run()
|
1216
1235
|
```
|
1217
1236
|
"""
|
1218
|
-
return {
|
1219
|
-
|
1237
|
+
return {
|
1238
|
+
"width": self._window.maximumWidth(),
|
1239
|
+
"height": self._window.maximumHeight(),
|
1240
|
+
}
|
1241
|
+
|
1220
1242
|
def get_resizable(self) -> bool:
|
1221
1243
|
"""
|
1222
1244
|
Returns the resizability of the window.
|
@@ -1238,4 +1260,33 @@ class BrowserWindow:
|
|
1238
1260
|
app.run()
|
1239
1261
|
```
|
1240
1262
|
"""
|
1241
|
-
return self.resizable
|
1263
|
+
return self.resizable
|
1264
|
+
|
1265
|
+
###########################################################################################
|
1266
|
+
# Custom Pyside6 Features
|
1267
|
+
###########################################################################################
|
1268
|
+
def get_QMainWindow(self) -> QMainWindow:
|
1269
|
+
"""
|
1270
|
+
Returns the QMainWindow object of the window.
|
1271
|
+
you can use all the features of QMainWindow for customizing the window.
|
1272
|
+
|
1273
|
+
Returns
|
1274
|
+
-------
|
1275
|
+
QMainWindow
|
1276
|
+
QMainWindow object of the window
|
1277
|
+
|
1278
|
+
Examples
|
1279
|
+
--------
|
1280
|
+
```python
|
1281
|
+
from PySide6.QtCore import Qt
|
1282
|
+
from pyloid import Pyloid
|
1283
|
+
|
1284
|
+
app = Pyloid(app_name="Pyloid-App")
|
1285
|
+
|
1286
|
+
window = app.create_window("pyloid-window")
|
1287
|
+
qmain = window.get_QMainWindow()
|
1288
|
+
|
1289
|
+
qmain.setWindowFlags(qmain.windowFlags() | Qt.WindowStaysOnTopHint) # window stays on top
|
1290
|
+
```
|
1291
|
+
"""
|
1292
|
+
return self._window
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|