Add actual browser

This commit is contained in:
Florian Bruhin 2013-12-15 21:40:15 +01:00
parent fbe968af73
commit f0c9977fa4
2 changed files with 29 additions and 2 deletions

27
qutebrowser/browser.py Normal file
View 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))

View File

@ -1,6 +1,6 @@
from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, QWidget) from PyQt5.QtWidgets import (QApplication, QMainWindow, QVBoxLayout, QWidget)
from qutebrowser.widgets.statusbar import StatusBar from qutebrowser.widgets.statusbar import StatusBar
from qutebrowser.widgets.tabbar import TabWidget from qutebrowser.browser import TabbedBrowser
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
def __init__(self): def __init__(self):
@ -16,7 +16,7 @@ class MainWindow(QMainWindow):
self.vbox.setContentsMargins(0, 0, 0, 0) self.vbox.setContentsMargins(0, 0, 0, 0)
self.vbox.setSpacing(0) self.vbox.setSpacing(0)
self.tabs = TabWidget(self.cwidget) self.tabs = TabbedBrowser(self)
self.tabs.setObjectName("tabs") self.tabs.setObjectName("tabs")
self.vbox.addWidget(self.tabs) self.vbox.addWidget(self.tabs)