Add option to allow opening multiple windows

This commit is contained in:
Fierelier 2021-03-20 16:01:51 +01:00
parent 01e77a5a0c
commit 9aba3ebf5e

View File

@ -27,6 +27,7 @@ from qtpy.QtMultimedia import QSound
import configparser
import json
import time
browserWindows = []
os.chdir(sp)
distro = os.path.splitext(s.rsplit(os.path.sep)[-1])[0]
@ -89,8 +90,10 @@ class browserWindow(QMainWindow):
def cCreateElements(self):
self.cMenuBar = self.menuBar()
self.cFileMenu = self.cMenuBar.addMenu("File")
self.cViewMenu = self.cMenuBar.addMenu("View")
self.cFileMenu = self.cMenuBar.addMenu("&File")
self.cNewWindowButton = self.cFileMenu.addAction("New &window")
self.cNewWindowButton.triggered.connect(self.cNewWindow)
self.cViewMenu = self.cMenuBar.addMenu("&View")
self.cUrlBar = QLineEdit(config["default"]["home"],self)
self.cUrlBar.returnPressed.connect(self.cNavigate)
@ -126,6 +129,10 @@ class browserWindow(QMainWindow):
self.cHeight = self.height()
self.cResizeElements()
def closeEvent(self,event):
browserWindows.remove(self)
event.accept()
def cNavigate(self,event = None):
try:
#print(prettyJson(parseUrl(self.cUrlBar.text())))
@ -152,6 +159,11 @@ class browserWindow(QMainWindow):
except Exception as e:
self.cDoc.cRenderHtml(str(e))
raise
def cNewWindow(self):
w = browserWindow()
browserWindows.append(w)
w.show()
def main():
# load program default addons
@ -183,7 +195,7 @@ def main():
app.setWindowIcon(QtGui.QIcon("assets/BirdyNet-XP.ico"))
except Exception as e:
print("Could not set window icon: " +print(e))
window = browserWindow()
browserWindows.append(browserWindow())
sys.exit(app.exec_())