Skip to content

Commit 188156c

Browse files
committed
enhance webview settings
ref #13
1 parent 51f963b commit 188156c

6 files changed

+19
-6
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.idea
1+
storage/
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

plus/__pycache__/util.cpython-34.pyc

0 Bytes
Binary file not shown.

plus/__pycache__/web.cpython-34.pyc

643 Bytes
Binary file not shown.

plus/web.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from PyQt5.QtWebKitWidgets import QWebView, QWebPage, QWebInspector
44
from PyQt5.QtWebKit import QWebSettings
55
from PyQt5.QtWidgets import QShortcut, QDialog, QGridLayout, QWidget
6-
from PyQt5.QtCore import Qt
6+
from PyQt5.QtCore import Qt, QDir
77

88

99
class WebViewPlus(QWebView):
@@ -26,15 +26,28 @@ def __init__(self):
2626
self._setupWebview()
2727

2828
def _setupWebview(self):
29-
self.settings().setAttribute(QWebSettings.LocalStorageEnabled, True)
30-
self.settings().setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
31-
self.settings().setLocalStoragePath("storage")
29+
settings = self.settings()
30+
currentPath = QDir.currentPath()
31+
settings.setAttribute(QWebSettings.LocalStorageEnabled, True)
32+
settings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, True)
33+
settings.setAttribute(QWebSettings.OfflineWebApplicationCacheEnabled, True)
34+
settings.setAttribute(QWebSettings.DnsPrefetchEnabled, True)
35+
settings.setAttribute(QWebSettings.CSSGridLayoutEnabled, True)
36+
settings.setAttribute(QWebSettings.JavascriptCanOpenWindows, True)
37+
settings.setAttribute(QWebSettings.JavascriptCanCloseWindows, True)
38+
settings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
39+
settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
40+
settings.setOfflineStoragePath(currentPath + "/storage/offline")
41+
settings.setOfflineWebApplicationCachePath(currentPath + "/storage/webcache")
42+
settings.setLocalStoragePath(currentPath + "/storage/local")
43+
settings.setOfflineStorageDefaultQuota(5 * 1024 * 1024)
44+
settings.setOfflineWebApplicationCacheQuota(5 * 1024 * 1024)
45+
settings.enablePersistentStorage()
3246

3347
"""
3448
F12키를 누르면 "개발자 도구"가 노출됨
3549
"""
3650
# webinspector
37-
self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
3851
self.webInspector = QWebInspector(self)
3952
self.webInspector.setPage(self.page())
4053

0 commit comments

Comments
 (0)