Beispiel #1
0
 def fav(self):
     bookmarks = self.db.executewithreturn("""SELECT * FROM bookmarks""")
     find = False
     for i in bookmarks:
         if i[2] == self.browserWidget.url().toString():
             self.db.executewithoutreturn(
                 """DELETE FROM bookmarks WHERE id = ?""", (i[0], ))
             self.bookmark.setIcon(
                 QIcon(
                     geticonpath(
                         self,
                         os.path.join(os.path.dirname(__file__),
                                      "../Icons/NavigationBar/noFav.png"))))
             find = True
     if not find:
         self.db.executewithoutreturn(
             """INSERT INTO bookmarks(name, url, date) VALUES(?, ?, ?)""",
             (self.browserWidget.title(),
              self.browserWidget.url().toString(), getdate()))
         self.bookmark.setIcon(
             QIcon(
                 geticonpath(
                     self,
                     os.path.join(os.path.dirname(__file__),
                                  "../Icons/NavigationBar/yesFav.png"))))
     self.parameterWindow.bookmarksPage.showupdate()
Beispiel #2
0
 def checkbookmarkbutton(self):
     bookmarks = self.db.executewithreturn("""SELECT * FROM bookmarks""")
     find = False
     for i in bookmarks:
         if i[2] == self.browserWidget.url().toString():
             self.bookmark.setIcon(
                 QIcon(
                     geticonpath(
                         self,
                         os.path.join(
                             os.path.dirname(__file__),
                             "../Icons/NavigationBar/yesFav.png"))))
             find = True
     if not find:
         self.bookmark.setIcon(
             QIcon(
                 geticonpath(
                     self,
                     os.path.join(os.path.dirname(__file__),
                                  "../Icons/NavigationBar/noFav.png"))))
Beispiel #3
0
    def __init__(self, parent):
        super(TabWidget, self).__init__(parent)
        self.parent = parent
        self.closer = False
        self.addTabButton = QPushButton(
            QIcon(
                geticonpath(
                    self.parent,
                    os.path.join(os.path.dirname(__file__),
                                 "../Icons/Tabs/tabs-add.png"))), "")

        self.tabCloseRequested.connect(self.requestsremovetab)
        self.currentChanged.connect(self.ontabchange)
        self.addTabButton.clicked.connect(self.requestsaddtab)

        self.setTabsClosable(True)
        self.setMovable(True)
        self.addTabButton.setFlat(True)
        self.setCornerWidget(self.addTabButton)
        self.setElideMode(Qt.ElideRight)
Beispiel #4
0
    def __init__(self, parent):
        super(ParameterWindow, self).__init__()
        self.parent = parent
        self.setWindowTitle('Paramètres')
        self.grid = QGridLayout()
        
        self.title = QLabel("Paramètres")
        self.title.setAlignment(Qt.AlignHCenter)

        self.generalPage = GeneralPage(self)
        self.historyPage = HistoryPage(self)
        self.bookmarksPage = BookmarksPage(self)
        self.informationsPage = InformationsPage(self)
        self.raccourcisPage = RaccourcisPage(self)
        self.sessionsPage = SessionsPage(self)
        self.downloadPage = DownloadPage(self)
        self.themesPage = ThemesPage(self)
        self.addonsPage = AddonsPage(self)

        self.tabWidget = QTabWidget(self)
        self.tabWidget.setObjectName("paramTabBar")
        self.tabWidget.setTabPosition(QTabWidget.West)
        self.tabWidget.addTab(self.generalPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/General.png"))), "")
        self.tabWidget.addTab(self.historyPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/History.png"))), "")
        self.tabWidget.addTab(self.bookmarksPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/Fav.png"))), "")
        self.tabWidget.addTab(self.raccourcisPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/Raccourcis.png"))), "")
        self.tabWidget.addTab(self.sessionsPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/Sessions.png"))), "")
        self.tabWidget.addTab(self.downloadPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/Download.png"))), "")
        self.tabWidget.addTab(self.themesPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/Themes.png"))), "")
        self.tabWidget.addTab(self.addonsPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/Addons.png"))), "")
        self.tabWidget.addTab(self.informationsPage,
                              QIcon(geticonpath(self.parent,
                                                os.path.join(os.path.dirname(__file__),
                                                             "../../Icons/Parameters/Info.png"))), "")
        self.tabWidget.setTabToolTip(0, "Général")
        self.tabWidget.setTabToolTip(1, "Historique")
        self.tabWidget.setTabToolTip(2, "Favoris")
        self.tabWidget.setTabToolTip(3, "Raccourcis URL")
        self.tabWidget.setTabToolTip(4, "Sessions")
        self.tabWidget.setTabToolTip(5, "Téléchargements")
        self.tabWidget.setTabToolTip(6, "Thèmes")
        self.tabWidget.setTabToolTip(7, "Addons")
        self.tabWidget.setTabToolTip(8, "Informations")
        
        self.grid.addWidget(self.title, 0, 0)
        self.grid.addWidget(self.tabWidget, 1, 0)
        self.grid.setContentsMargins(0, 0, 0, 0)
        self.grid.setSpacing(0)
        self.setLayout(self.grid)
        self.setFixedSize(800, 800)
        self.setWindowFlags(Qt.CustomizeWindowHint)
        self.setWindowFlags(Qt.WindowTitleHint)
        self.setWindowFlags(Qt.WindowCloseButtonHint)
Beispiel #5
0
    def __init__(self):
        super(Browser, self).__init__()
        self.db = Database(os.path.join(os.path.dirname(__file__), "data.db"))
        self.db.createdb()

        self.centralWidget = QWidget(self)
        self.grid = QGridLayout(self.centralWidget)
        self.theme = ""
        self.version = "1.0.0"
        self.versionCompaDB = 1
        self.versionAccDB = self.db.executewithreturn(
            """SELECT version FROM informations""")[0][0]
        if self.versionAccDB != self.versionCompaDB:
            QMessageBox.information(
                self, "Base de donnée non à jour",
                "La Base de donnée n'est pas compatible avec "
                "cette version de Browthon.\n"
                "Elle va être mise à jour.")
            self.dbConnection.disconnect()
            self.versionAccDB = majdb(
                os.path.join(os.path.dirname(__file__), "data.db"),
                self.versionAccDB, self.versionCompaDB)
            self.dbConnection.reconnect(
                os.path.join(os.path.dirname(__file__), "data.db"))
            self.dbConnection.createdb()
        QWebEngineSettings.globalSettings().setAttribute(
            QWebEngineSettings.FullScreenSupportEnabled, True)
        if self.db.executewithreturn(
                """SELECT js FROM parameters""")[0][0] == "Activé":
            QWebEngineSettings.globalSettings().setAttribute(
                QWebEngineSettings.JavascriptEnabled, True)
        else:
            QWebEngineSettings.globalSettings().setAttribute(
                QWebEngineSettings.JavascriptEnabled, False)
        if self.db.executewithreturn(
                """SELECT private FROM parameters""")[0][0] == "Activé":
            self.privateBrowsing = True
            QWebEngineProfile.defaultProfile().setHttpCacheType(
                QWebEngineProfile.MemoryHttpCache)
        else:
            self.privateBrowsing = False
            QWebEngineProfile.defaultProfile().setHttpCacheType(
                QWebEngineProfile.DiskHttpCache)

        self.urlInput = UrlInput(self)
        self.urlInput.setObjectName("addressBar")
        self.back = PushButton(
            "", QIcon(geticonpath(self, "../Icons/NavigationBar/back.png")),
            "backButton")
        self.forward = PushButton(
            "", QIcon(geticonpath(self, "../Icons/NavigationBar/forward.png")),
            "forwardButton")
        self.reload = PushButton(
            "", QIcon(geticonpath(self, "../Icons/NavigationBar/reload.png")),
            "reloadButton")
        self.bookmark = PushButton(
            "", QIcon(geticonpath(self, "../Icons/NavigationBar/noFav.png")),
            "favButton")
        self.home = PushButton(
            "", QIcon(geticonpath(self, "../Icons/NavigationBar/home.png")),
            "homeButton")
        self.parameter = PushButton(
            "", QIcon(geticonpath(self, "../Icons/NavigationBar/param.png")),
            "paramButton")
        self.tabWidget = TabWidget(self)
        self.tabWidget.tabBar().setObjectName("tabBar")

        self.tabWidget.requestsaddtab()
        self.back.setFlat(True)
        self.forward.setFlat(True)
        self.reload.setFlat(True)
        self.bookmark.setFlat(True)
        self.home.setFlat(True)
        self.parameter.setFlat(True)

        self.reload.clicked.connect(self.browserWidget.reload)
        self.back.clicked.connect(self.browserWidget.back)
        self.forward.clicked.connect(self.browserWidget.forward)
        self.bookmark.clicked.connect(self.fav)
        self.home.clicked.connect(lambda: self.urlInput.enterurlgiven(
            self.db.executewithreturn("""SELECT home FROM parameters""")[0][0])
                                  )
        self.parameter.clicked.connect(self.openparameter)

        self.grid.addWidget(self.back, 0, 0)
        self.grid.addWidget(self.reload, 0, 1)
        self.grid.addWidget(self.forward, 0, 2)
        self.grid.addWidget(self.urlInput, 0, 3)
        self.grid.addWidget(self.bookmark, 0, 4)
        self.grid.addWidget(self.home, 0, 5)
        self.grid.addWidget(self.parameter, 0, 6)
        self.grid.addWidget(self.tabWidget, 1, 0, 1, 7)

        self.grid.setContentsMargins(0, 0, 0, 0)
        self.grid.setSpacing(0)
        self.setCentralWidget(self.centralWidget)
        self.showMaximized()
        self.setWindowTitle('Browthon')

        self.parameterWindow = ParameterWindow(self)
        QWebEngineProfile.defaultProfile().\
            downloadRequested.connect(self.parameterWindow.downloadPage.downloadrequested)

        theme = self.db.executewithreturn(
            """SELECT theme FROM parameters""")[0][0]
        if theme == "":
            self.theme = ""
            self.applytheme()
        else:
            if os.path.exists(
                    os.path.join(os.path.dirname(__file__), "..", "Themes",
                                 theme, "theme.json")):
                self.theme = os.path.join(os.path.dirname(__file__), "..",
                                          "Themes", theme)
                self.applytheme()
            else:
                print("Le theme " + theme + " n'existe pas/plus.")
                self.theme = ""
                self.applytheme()

        self.parameterWindow.addonsPage.launchaddons("load")
        self.show()
        if self.db.executewithreturn(
                """SELECT first FROM parameters""")[0][0] == "O":
            parameters = self.dbConnection.executewithreturn(
                """SELECT * FROM parameters""")
            self.db.executewithoutreturn(
                """UPDATE parameters SET first = ? WHERE id = ?""",
                ("N", parameters[0][0]))
Beispiel #6
0
 def applytheme(self):
     if self.theme == "" or self.theme == os.path.join(
             os.path.dirname(__file__), "..", "Themes"):
         self.setStyleSheet("")
         self.parameterWindow.setStyleSheet("")
     else:
         with open(self.theme + "/main.bss", 'r') as fichier:
             bss = parsetheme(fichier.read(), self.theme)
             self.setStyleSheet(bss)
             self.parameterWindow.setStyleSheet(bss)
     self.back.setIcon(
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/NavigationBar/back.png"))))
     self.forward.setIcon(
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/NavigationBar/forward.png"))))
     self.reload.setIcon(
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/NavigationBar/reload.png"))))
     self.bookmark.setIcon(
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/NavigationBar/noFav.png"))))
     self.home.setIcon(
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/NavigationBar/home.png"))))
     self.parameter.setIcon(
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/NavigationBar/param.png"))))
     self.tabWidget.addTabButton.setIcon(
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Tabs/tabs-add.png"))))
     self.parameterWindow.tabWidget.setTabIcon(
         0,
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Parameters/General.png"))))
     self.parameterWindow.tabWidget.setTabIcon(
         1,
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Parameters/History.png"))))
     self.parameterWindow.tabWidget.setTabIcon(
         2,
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Parameters/Fav.png"))))
     raccourcisimg = "../Icons/Parameters/Raccourcis.png"
     self.parameterWindow.tabWidget.setTabIcon(
         3,
         QIcon(
             geticonpath(
                 self, os.path.join(os.path.dirname(__file__),
                                    raccourcisimg))))
     self.parameterWindow.tabWidget.setTabIcon(
         4,
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Parameters/Sessions.png"))))
     self.parameterWindow.tabWidget.setTabIcon(
         5,
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Parameters/Download.png"))))
     self.parameterWindow.tabWidget.setTabIcon(
         6,
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Parameters/Themes.png"))))
     addonimg = "../Icons/Parameters/Addons.png"
     self.parameterWindow.tabWidget.setTabIcon(
         7,
         QIcon(
             geticonpath(self,
                         os.path.join(os.path.dirname(__file__),
                                      addonimg))))
     self.parameterWindow.tabWidget.setTabIcon(
         8,
         QIcon(
             geticonpath(
                 self,
                 os.path.join(os.path.dirname(__file__),
                              "../Icons/Parameters/Info.png"))))