Add actual browser
This commit is contained in:
parent
fbe968af73
commit
f0c9977fa4
27
qutebrowser/browser.py
Normal file
27
qutebrowser/browser.py
Normal file
@ -0,0 +1,27 @@
|
||||
from PyQt5.QtCore import QObject, pyqtSlot, QUrl
|
||||
from PyQt5.QtWebKitWidgets import QWebView
|
||||
from qutebrowser.widgets.tabbar import TabWidget
|
||||
|
||||
class TabbedBrowser(TabWidget):
|
||||
tabs = []
|
||||
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
self.tabopen("http://ddg.gg/")
|
||||
|
||||
@pyqtSlot(str)
|
||||
def tabopen(self, url):
|
||||
tab = BrowserTab(self)
|
||||
tab.openurl(url)
|
||||
self.tabs.append(tab)
|
||||
self.addTab(tab, url)
|
||||
|
||||
class BrowserTab(QWebView):
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
self.show()
|
||||
|
||||
def openurl(self, url):
|
||||
if not url.startswith('http://'):
|
||||
url = 'http://' + url
|
||||
super().load(QUrl(url))
|
@ -1,6 +1,6 @@
|
||||
from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, QWidget)
|
||||
from qutebrowser.widgets.statusbar import StatusBar
|
||||
from qutebrowser.widgets.tabbar import TabWidget
|
||||
from qutebrowser.browser import TabbedBrowser
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
@ -16,7 +16,7 @@ class MainWindow(QMainWindow):
|
||||
self.vbox.setContentsMargins(0, 0, 0, 0)
|
||||
self.vbox.setSpacing(0)
|
||||
|
||||
self.tabs = TabWidget(self.cwidget)
|
||||
self.tabs = TabbedBrowser(self)
|
||||
self.tabs.setObjectName("tabs")
|
||||
self.vbox.addWidget(self.tabs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user