-
Notifications
You must be signed in to change notification settings - Fork 2
/
baseBrowser.py
79 lines (53 loc) · 2.07 KB
/
baseBrowser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from PyQt4 import QtCore, QtWebKit, QtGui
from GUI.main import BrowserGUI, BrowserTabGUI
actions = {"Alt+Left" : QtWebKit.QWebPage.Back, "Alt+Right" : QtWebKit.QWebPage.Forward, "F5" : QtWebKit.QWebPage.Reload }
class BaseBrowser(BrowserGUI):
"""
This class is the base for a simple web browser
Inherit from this class and override all the virtual methods
to make a full functional browser
"""
def __init__(self):
BrowserGUI.__init__(self)
self.connect(self.ui.tb_url, QtCore.SIGNAL("returnPressed()"), self.browse)
self.connect(self.ui.tab_pages, QtCore.SIGNAL("tabCloseRequested(int)"), self.tab_closed)
self.connect(self.ui.tab_pages, QtCore.SIGNAL("currentChanged(int)"), self.tab_changed)
# overridable methods section
def browse():
pass
def tab_closed(index):
pass
def tab_changed(index):
pass
def add_tab():
pass
class BaseBrowserTab(BrowserTabGUI):
"""
This class is the base for a browser tab
Inherit from this class and override all the virtual methods
to make a browser tab
"""
def __init__(self, parent):
BrowserTabGUI.__init__(self, parent)
self.connect(self.parent.bt_back, QtCore.SIGNAL("clicked()"), self.back)
self.connect(self.parent.bt_ahead, QtCore.SIGNAL("clicked()"), self.ahead)
self.connect(self.parent.bt_reload, QtCore.SIGNAL("clicked()"), self.reload)
self.connect(self.html, QtCore.SIGNAL("loadStarted()"), self.load_start)
self.connect(self.html, QtCore.SIGNAL("loadFinished(bool)"), self.loaded_bar)
self.connect(self.html, QtCore.SIGNAL("loadProgress(int)"), self.load_bar)
self.connect(self.html, QtCore.SIGNAL("urlChanged(const QUrl)"), self.url_changed)
# overridable methods section
def load_start(self):
pass
def load_bar(self):
pass
def loaded_bar(self):
pass
def url_changed(self):
pass
def back(self):
pass
def ahead(self):
pass
def reload():
pass