From f0c9977fa4e181f28525c26367f2853e4b21c36c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 15 Dec 2013 21:40:15 +0100 Subject: [PATCH] Add actual browser --- qutebrowser/browser.py | 27 +++++++++++++++++++++++++++ qutebrowser/widgets/mainwindow.py | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 qutebrowser/browser.py diff --git a/qutebrowser/browser.py b/qutebrowser/browser.py new file mode 100644 index 000000000..f58c5e3be --- /dev/null +++ b/qutebrowser/browser.py @@ -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)) diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index 9ca2c4c28..1d3a94aca 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -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)