Esempio n. 1
0
    def _loadSettings(self):
        settings = Settings()
        settings.beginGroup('Browser-Tabs-Settings')
        self._dontCloseWithOneTab = settings.value('dontCloseWithOneTab',
                                                   False,
                                                   type=bool)
        self._showClosedTabsButton = settings.value('showClosedTabsButton',
                                                    False,
                                                    type=bool)
        self._newTabAfterActive = settings.value('newTabAfterActive',
                                                 True,
                                                 type=bool)
        self._newEmptyTabAfterActive = settings.value('newEmptyTabAfterActive',
                                                      False,
                                                      type=bool)
        settings.endGroup()

        settings.beginGroup('Web-URL-Settings')
        self._urlOnNewTab = settings.value('newTabUrl',
                                           'app:speeddial',
                                           type=QUrl)
        settings.endGroup()

        self._tabBar.loadSettings()

        self._updateClosedTabsButton()
Esempio n. 2
0
    def loadSettings(self):
        settings = Settings()
        settings.beginGroup('Language')
        # TODO:
        #langs = settings.value('acceptLanguage', AcceptLanguage.defaultLanguage(), type=[])
        settings.endGroup()
        # TODO:
        #gVar.app.webProfile().setHttpAcceptLanguage(AcceptLanguage.generateHeader(langs))

        proxy = QNetworkProxy()
        settings.beginGroup('Web-Proxy')
        proxyType = settings.value('ProxyType', 2)
        proxy.setHostName(settings.value('HostName', ''))
        proxy.setPort(settings.value('Port', 8080))
        proxy.setUser(settings.value('Username', ''))
        proxy.setPassword(settings.value('Password', ''))
        settings.endGroup()

        if proxyType == 0:
            proxy.setType(QNetworkProxy.NoProxy)
        elif proxyType == 3:
            proxy.setType(QNetworkProxy.HttpProxy)
        elif proxyType == 4:
            proxy.setType(QNetworkProxy.Socks5Proxy)

        if proxyType == 2:
            QNetworkProxy.setApplicationProxy(QNetworkProxy())
            QNetworkProxyFactory.setUseSystemConfiguration(True)
        else:
            QNetworkProxy.setApplicationProxy(proxy)
            QNetworkProxyFactory.setUseSystemConfiguration(False)

        self._urlInterceptor.loadSettings()
    def loadSettings(self):
        settings = Settings()
        settings.beginGroup('Web-Browser-Settings')
        self._globalUserAgent = settings.value('UserAgent', '', type=str)
        settings.endGroup()

        settings.beginGroup('User-Agent-Settings')
        self._usePerDomainUserAgent = settings.value('UsePerDomainUA',
                                                     False,
                                                     type=bool)
        domainList = settings.value('DomainList', [], type=list)
        userAgentsList = settings.value('UserAgentsList', [], type=list)
        settings.endGroup()

        self._usePerDomainUserAgent = self._usePerDomainUserAgent and domainList.count(
        ) == userAgentsList.count()

        if self._usePerDomainUserAgent:
            for idx in range(domainList.count()):
                self._userAgentsList[domainList[idx]] = userAgentsList[idx]

        if not self._globalUserAgent:
            userAgent = self._defaultUserAgent
        else:
            userAgent = self._globalUserAgent

        QWebEngineProfile.defaultProfile().setHttpUserAgent(userAgent)
Esempio n. 4
0
 def loadSettings(self):
     settings = Settings()
     settings.beginGroup('Cookie-Settings')
     self._allowCookies = settings.value('allowCookies', True)
     self._filterThirdParty = settings.value('filterThirdPartyCookies', False)
     self._filterTrackingCookie = settings.value('filterTrackingCookie', False)
     self._whitelist = settings.value('whitelist', [])
     self._blacklist = settings.value('blacklist', [])
     settings.endGroup()
Esempio n. 5
0
 def loadSettings(self):
     settings = Settings()
     settings.beginGroup('HTML5Notifications')
     for enumType, name in self.s_settingList:
         grantedName = '%sGranted' % name
         deniedName = '%sDenied' % name
         self._granted[enumType] = settings.value(grantedName, [])
         self._denied[enumType] = settings.value(deniedName, [])
     settings.endGroup()
Esempio n. 6
0
 def loadSettings(self):
     settings = Settings()
     settings.beginGroup('Bookmarks')
     self._showOnlyIconsInToolbar = settings.value('showOnlyIconsInToolbar',
                                                   False,
                                                   type=bool)
     self._showOnlyTextInToolbar = settings.value('showOnlyTextInToolbar',
                                                  False,
                                                  type=bool)
     settings.endGroup()
Esempio n. 7
0
 def _loadSettings(self):
     settings = Settings()
     settings.beginGroup('AddressBar')
     self._progressStyle = settings.value('ProgressStyle', 0)
     customColor = settings.value('UseCustomProgressColor', False)
     if customColor:
         self._progressColor = settings.value(
             'CustomProgressColor',
             self.palette().color(QPalette.Highlight))
     else:
         self._progressColor = QColor()
     settings.endGroup()
Esempio n. 8
0
 def loadSettings(self):
     settings = Settings()
     settings.beginGroup('Notifications')
     self._enabled = settings.value('Enabled', True)
     self._timeout = settings.value('Timeout', 6000)
     if const.OS_UNIX:  # && !defined(DISABLE_DBUS)
         if settings.value('UseNativeDesktop', True):
             self._notifType = self.DesktopNative
         else:
             self._notifType = self.PopupWidget
     else:
         self._notifType = self.PopupWidget
     self._position = settings.value('Position', QPoint(10, 10), type=QPoint)
     settings.endGroup()
Esempio n. 9
0
    def getSaveFileName(self, name, parent=None, caption='', dir_='',
            filter_='', selectedFilter='', options=QFileDialog.Options()):
        '''
        @param: name QString
        @param: parent QWidget
        @param: caption QString
        @param: dir_ QString
        @param: filter_ QString
        @param: selectedFilter QString TODO: this is an output parameter
        @param: options QFileDialog::Options
        @return: QString
        '''
        settings = Settings()
        settings.beginGroup('FileDialogPaths')

        lastDir = settings.value(name, '')
        fileName = self.getFileName(dir_)

        if not lastDir:
            lastDir = dir_
        else:
            lastDir = pathjoin(lastDir, fileName)

        path, selectedFilter = QFileDialog.getSaveFileName(parent, caption,
            lastDir, filter_, selectedFilter, options)

        if path:
            settings.setValue(name, QFileInfo(path).absolutePath())

        settings.endGroup()
        return path
Esempio n. 10
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self._ui = uic.loadUi('mc/preferences/AcceptLanguage.ui', self)

        self.setAttribute(Qt.WA_DeleteOnClose)

        self._ui.listWidget.setLayoutDirection(Qt.LeftToRight)

        settings = Settings()
        settings.beginGroup('Language')
        # QStringList
        langs = settings.value('acceptLanguage',
                               self.defaultLanguage(),
                               type=list)
        settings.endGroup()

        for code in langs:
            loc = QLocale(code.replace('-', '_'))
            label = ''

            if loc.language() == QLocale.C:
                label = _('Personal [%s]') % code
            else:
                label = '%s/%s [%s]' % (loc.languageToString(
                    loc.language()), loc.countryToString(loc.country()), code)
            self._ui.listWidget.addItem(label)

        self._ui.add.clicked.connect(self.addLanguage)
        self._ui.remove.clicked.connect(self.removeLanguage)
        self._ui.up.clicked.connect(self.upLanguage)
        self._ui.down.clicked.connect(self.downLanguage)
Esempio n. 11
0
    def loadSettings(self):
        settings = Settings()
        settings.beginGroup('Browser-Tabs-Settings')
        self._hideTabBarWithOneTab = settings.value('hideTabsWithOneTab',
                                                    False)
        activateLastTab = settings.value('ActivateLastTabWhenCloseActual',
                                         False)
        self._showCloseOnInactive = settings.value('showCloseOnInactiveTabs',
                                                   0)
        settings.endGroup()

        self.setSelectionBehaviorOnRemove(
            activateLastTab and QTabBar.SelectPreviousTab
            or QTabBar.SelectRightTab)
        self.setVisible(not (self.count() <= 1 and self._hideTabBarWithOneTab))

        self.setUpLayout()
Esempio n. 12
0
    def __init__(self, window, parent=None):
        '''
        @param: window BrowserWindow
        @param: parent QWidget
        '''
        super().__init__(parent)
        self._ui = uic.loadUi('mc/other/BrowsingLibrary.ui', self)
        self._historyManager = HistoryManager(window)  # HistoryManager
        self._bookmarksManager = BookmarksManager(window)  # BookmarksManager

        settings = Settings()
        settings.beginGroup('BrowsingLibrary')
        self.resize(settings.value('size', QSize(760, 470)))
        self._historyManager.restoreState(
            settings.value('historyState', QByteArray()))
        settings.endGroup()

        gVar.appTools.centerWidgetOnScreen(self)

        historyIcon = QIcon()
        historyIcon.addFile(':/icons/other/bighistory.svg', QSize(),
                            QIcon.Normal)
        historyIcon.addFile(':/icons/other/bighistory-selected.svg', QSize(),
                            QIcon.Selected)

        bookmarksIcon = QIcon()
        bookmarksIcon.addFile(':/icons/other/bigstar.svg', QSize(),
                              QIcon.Normal)
        bookmarksIcon.addFile(':/icons/other/bigstar-selected.svg', QSize(),
                              QIcon.Selected)

        self._ui.tabs.AddTab(self._historyManager, historyIcon, _('History'))
        self._ui.tabs.AddTab(self._bookmarksManager, bookmarksIcon,
                             _('Bookmarks'))
        self._ui.tabs.SetMode(FancyTabWidget.Mode_LargeSidebar)
        self._ui.tabs.setFocus()

        m = QMenu()
        m.addAction(_('Import Bookmarks...'), self._importBookmarks)
        m.addAction(_('Export Bookmarks...'), self._exportBookmarks)
        self._ui.importExport.setMenu(m)

        self._ui.tabs.CurrentChanged.connect(self._ui.searchLine.clear)
        self._ui.searchLine.textChanged.connect(self._search)

        gVar.appTools.setWmClass('Browsing Library', self)
Esempio n. 13
0
    def lastPathForFileDialog(self, dialogName, fallbackPath):
        settings = Settings()
        settings.beginGroup('LastFileDialogsPaths')
        path = settings.value('FileDialogs/' + dialogName)
        settings.endGroup()

        if not path:
            return fallbackPath
        return path
Esempio n. 14
0
    def loadSettings(self):
        with self._mutex:
            settings = Settings()
            settings.beginGroup('Web-Browser-Settings')
            self._sendDNT = settings.value('DoNotTrack', False)
            settings.endGroup()

            self._usePerDomainUserAgent = gVar.app.userAgentManager().usePerDomainUserAgents()
            self._userAgentsList = gVar.app.userAgentManager().perDomainUserAgentsList()
 def _init(self):
     settings = Settings()
     settings.beginGroup('ProtocolHandlers')
     keys = settings.childKeys()
     for scheme in keys:
         url = settings.value(scheme, type=QUrl)
         self._protocolHandlers[scheme] = url
         self._registerHandler(scheme, url)
     settings.endGroup()
Esempio n. 16
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)

        self._ui = uic.loadUi('mc/preferences/JsOptions.ui', self)

        if const.QTWEBENGINEWIDGETS_VERSION < const.QT_VERSION_CHECK(5, 10, 0):
            self._ui.jscanActivateWindow.setVisible(False)
        if const.QTWEBENGINEWIDGETS_VERSION < const.QT_VERSION_CHECK(5, 11, 0):
            self._ui.jscanPaste.setVisible(False)

        settings = Settings()
        settings.beginGroup('Web-Browser-Settings')
        self._ui.jscanOpenWindow.setChecked(
            settings.value('allowJavaScriptOpenWindow', False))
        self._ui.jscanActivateWindow.setChecked(
            settings.value('allowJavaScriptActivationWindow', False))
        self._ui.jscanAccessClipboard.setChecked(
            settings.value('allowJavaScriptAccessClipboard', True))
        self._ui.jscanPaste.setChecked(
            settings.value('allowJavaScriptPaste', True))
        settings.endGroup()
Esempio n. 17
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self._ui = uic.loadUi('mc/other/ClearPrivateData.ui', self)
        self._ui.buttonBox.setFocus()
        self._ui.history.clicked.connect(self._historyClicked)
        self._ui.clear.clicked.connect(self._dialogAccepted)
        self._ui.optimizeDb.clicked.connect(self._optimizeDb)
        self._ui.editCookies.clicked.connect(self._showCookieManager)

        settings = Settings()
        settings.beginGroup('ClearPrivateData')
        self._restoreState(settings.value('state', QByteArray()))
        settings.endGroup()
Esempio n. 18
0
    def loadSettings(self):
        sessionDir = QDir(DataPaths.path(DataPaths.Sessions))

        settings = Settings()
        settings.beginGroup('Web-Browser-Settings')
        self._lastActiveSessionPath = settings.value('lastActiveSessionPath', self.defaultSessionPath())
        settings.endGroup()

        if QDir.isRelativePath(self._lastActiveSessionPath):
            self._lastActiveSessionPath = sessionDir.absoluteFilePath(self._lastActiveSessionPath)

        # Fallback to default session
        if not RestoreManager.validateFile(self._lastActiveSessionPath):
            self._lastActiveSessionPath = self.defaultSessionPath()
Esempio n. 19
0
    def __init__(self, parent, preferences):
        '''
        @param: parent QWidget
        @param: preferences Preferences
        '''
        super().__init__()
        self._ui = uic.loadUi('mc/preferences/ThemeManager.ui', self)
        self._preferences = preferences  # Preferences

        self._activeTheme = ''
        self._themeHash = {}  # QHash<QString, Theme>

        self._ui.listWidget.setLayoutDirection(Qt.LeftToRight)
        self._ui.license.hide()

        settings = Settings()
        settings.beginGroup('Themes')
        self._activeTheme = settings.value('activeTheme',
                                           const.DEFAULT_THEME_NAME)
        settings.endGroup()

        themePaths = DataPaths.allPaths(DataPaths.Themes)

        for path in themePaths:
            dir_ = QDir(path)
            list_ = dir_.entryList(QDir.AllDirs | QDir.NoDotAndDotDot)
            for name in list_:
                # Theme
                themeInfo = self._parseTheme(
                    dir_.absoluteFilePath(name) + '/', name)
                if not themeInfo.isValid:
                    continue

                item = QListWidgetItem(self._ui.listWidget)
                item.setText(themeInfo.name)
                item.setIcon(themeInfo.icon)
                item.setData(Qt.UserRole, name)

                if self._activeTheme == name:
                    self._ui.listWidget.setCurrentItem(item)

                self._ui.listWidget.addItem(item)

        self._ui.listWidget.currentItemChanged.connect(self._currentChanged)
        self._ui.license.clicked.connect(self._showLicense)

        self._currentChanged()
Esempio n. 20
0
    def getExistingDirectory(self, name, parent=None, caption='', dir_='',
            options=QFileDialog.ShowDirsOnly):
        '''
        @param: name QString
        @param: parent QWidget
        @param: caption QString
        @param: dir_ QString
        @param: options QFileDialog.Options
        @return: QString
        '''
        settings = Settings()
        settings.beginGroup('FileDialogPaths')

        lastDir = settings.value(name, dir_)

        path = QFileDialog.getExistingDirectory(parent, caption, lastDir, options)

        if path:
            settings.setValue(name, QFileInfo(path).absolutePath())

        settings.endGroup()
        return path
Esempio n. 21
0
    def loadSettings(self):
        settings = Settings()
        settings.beginGroup("DownloadManager")
        self._downloadPath = settings.value("defaultDownloadPath", '')
        self._lastDownloadPath = settings.value(
            "lastDownloadPath",
            QStandardPaths.writableLocation(QStandardPaths.DownloadLocation))
        self._closeOnFinish = settings.value("CloseManagerOnFinish", False)
        self._useNativeDialog = settings.value(
            "useNativeDialog", const.DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG)

        self._useExternalManager = settings.value("UseExternalManager", False)
        self._externalExecutable = settings.value("ExternalManagerExecutable",
                                                  '')
        self._externalArguments = settings.value("ExternalManagerArguments",
                                                 '')
        settings.endGroup()

        if "%d" not in self._externalArguments:
            self._externalArguments += " %d"
Esempio n. 22
0
    def canCloseTabs(cls, settingsKey, title, description):
        settings = Settings()
        ask = settings.value('Browser-Tabs-Settings/' + settingsKey,
                             True,
                             type=bool)

        if ask:
            dialog = CheckBoxDialog(QMessageBox.Yes | QMessageBox.No,
                                    gVar.app.activeWindow())
            dialog.setDefaultButton(QMessageBox.No)
            dialog.setWindowTitle(title)
            dialog.setText(description)
            dialog.setCheckBoxText(_("Don't ask again"))
            dialog.setIcon(QMessageBox.Question)

            if dialog.exec_() != QMessageBox.Yes:
                return False

            if dialog.isChecked():
                settings.setValue('Browser-Tabs-Settings/' + settingsKey,
                                  False)

        return True
Esempio n. 23
0
    def loadSettings(self):
        self._loaded = True

        settings = Settings()
        settings.beginGroup('SpeedDial')
        allPages = settings.value('pages', '')
        self.setBackgroundImage(settings.value('background', ''))
        self._backgroundImageSize = settings.value('backsize', 'auto')
        self._maxPagesInRow = settings.value('pagesrow', 4)
        self._sizeOfSpeedDials = settings.value('sdsize', 231)
        self._sdcentered = settings.value('sdcenter', False)
        settings.endGroup()

        self.changed(allPages)

        self._thumbnailsDir = DataPaths.currentProfilePath() + '/thumbnails/'

        # If needed, create thumbnails directory
        if not pathexists(self._thumbnailsDir):
            makedirs(self._thumbnailsDir)
Esempio n. 24
0
 def loadSettings(self):
     settings = Settings()
     settings.beginGroup('Web-Browser-Settings')
     self._isSaving = settings.value('allowHistory', True, type=bool)
     settings.endGroup()
Esempio n. 25
0
    def loadSettings(self):
        settings = Settings()
        settings.beginGroup('AddressBar')
        self.selectAllOnDoubleClick = settings.value(
            'SelectAllTextOnDoubleClick', True)
        self.selectAllOnClick = settings.value('SelectAllTextOnClick', False)
        self.showLoadingProgress = settings.value('ShowLoadingProgress', True)
        self.showLocationSuggestions = settings.value('showSuggestions', 0)
        self.showSwitchTab = settings.value('showSwitchTab', True)
        self.alwaysShowGoIcon = settings.value('alwaysShowGoIcon', False)
        self.useInlineCompletion = settings.value('useInlineCompletion', True)
        settings.endGroup()

        settings.beginGroup('SearchEngines')
        self.searchOnEngineChange = settings.value('SearchOnEngineChange',
                                                   True)
        self.searchFromAddressBar = settings.value('SearchFromAddressBar',
                                                   True)
        self.searchWithDefaultEngine = settings.value(
            'SearchWithDefaultEngine', False)
        self.showABSearchSuggestions = settings.value('showSearchSuggestions',
                                                      True)
        self.showWSBSearchSuggestions = settings.value('showSuggestions', True)
        settings.endGroup()

        settings.beginGroup('Web-Browser-Settings')
        self.defaultZoomLevel = settings.value('DefaultZoomLevel',
                                               WebView.zoomLevels().index(100),
                                               type=int)
        self.loadTabsOnActivation = settings.value('LoadTabsOnActivation',
                                                   True)
        self.autoOpenProtocols = settings.value('AutomaticallyOpenProtocols',
                                                [])
        self.blockedProtocols = settings.value('BlockOpeningProtocols', [])
        settings.endGroup()

        settings.beginGroup('Browser-Tabs-Settings')
        if settings.value('OpenNewTabsSelected', False):
            self.newTabPosition = const.NT_CleanSelectedTab
        else:
            self.newTabPosition = const.NT_CleanNotSelectedTab
        self.tabsOnTop = settings.value('TabsOnTop', True)
        self.openPopupsInTabs = settings.value('OpenPopupsInTabs', False)
        self.alwaysSwitchTabsWithWheel = settings.value(
            'AlwaysSwitchTabsWithWheel', False)
        settings.endGroup()
Esempio n. 26
0
    def __init__(self, parent=None):
        '''
        @param parent QWidget
        '''
        super().__init__(parent)
        self._ui = uic.loadUi('mc/cookies/CookieManager.ui', self)

        self._domainHash = {}  # QHash<QString, QTreeWidgetItem>
        self._itemHash = {}  # QHash<QTreeWidgetItem, QNetworkCookie>

        self.setAttribute(Qt.WA_DeleteOnClose)

        gVar.appTools.centerWidgetOnScreen(self)

        if self.isRightToLeft():
            self._ui.cookieTree.headerItem().setTextAlignment(
                0, Qt.AlignRight | Qt.AlignVCenter)
            self._ui.cookieTree.headerItem().setTextAlignment(
                1, Qt.AlignRight | Qt.AlignVCenter)
            self._ui.cookieTree.setLayoutDirection(Qt.LeftToRight)
            self._ui.whiteList.setLayoutDirection(Qt.LeftToRight)
            self._ui.blackList.setLayoutDirection(Qt.LeftToRight)

        # Stored Cookies
        self._ui.cookieTree.currentItemChanged.connect(
            self._currentItemChanged)
        self._ui.removeAll.clicked.connect(self._removeAll)
        self._ui.removeOne.clicked.connect(self._remove)
        self._ui.close.clicked.connect(lambda: self._close())
        self._ui.close2.clicked.connect(lambda: self._close())
        self._ui.close3.clicked.connect(lambda: self._close())
        self._ui.search.textChanged.connect(self._filterString)

        # Cookie Filtering
        self._ui.whiteAdd.clicked.connect(self._addWhitelist)
        self._ui.whiteRemove.clicked.connect(self._removeWhitelist)
        self._ui.blackAdd.clicked.connect(self._addBlacklist)
        self._ui.blackRemove.clicked.connect(self._removeBlacklist)

        # Cookie Settings
        settings = Settings()
        settings.beginGroup('Cookie-Settings')
        self._ui.saveCookies.setChecked(settings.value('allCookies', True))
        self._ui.filter3rdParty.setChecked(
            settings.value('filterThirdPartyCookies', False))
        self._ui.filterTracking.setChecked(
            settings.value('filterTrackingCookie', False))
        self._ui.deleteCookiesOnClose.setChecked(
            settings.value('deleteCookiesOnClose', False))
        self._ui.whiteList.addItems(settings.value('whitelist', []))
        self._ui.blackList.addItems(settings.value('blacklist', []))
        settings.endGroup()

        if const.QTWEBENGINEWIDGETS_VERSION < const.QT_VERSION_CHECK(5, 11, 0):
            self._ui.filter3rdParty.hide()

        self._ui.search.setPlaceholderText(_('Search'))
        self._ui.cookieTree.setDefaultItemShowMode(TreeWidget.ItemsCollapsed)
        self._ui.cookieTree.sortItems(0, Qt.AscendingOrder)
        self._ui.cookieTree.header().setDefaultSectionSize(220)
        self._ui.cookieTree.setFocus()

        self._ui.whiteList.setSortingEnabled(True)
        self._ui.blackList.setSortingEnabled(True)

        self._removeShortcut = QShortcut(QKeySequence('Del'), self)
        self._removeShortcut.activated.connect(self._deletePressed)

        self._ui.search.textChanged.connect(self._filterString)
        cookieJar = gVar.app.cookieJar()
        cookieJar.cookieAdded.connect(self._addCookie)
        cookieJar.cookieRemoved.connect(self._removeCookie)

        # Load cookies
        for cookie in cookieJar.getAllCookies():
            self._addCookie(cookie)

        gVar.appTools.setWmClass('Cookies', self)