def setWmClass(self, name, widget): ''' @param: name QString @param: widget QWidget ''' if const.APP_WS_X11: if QGuiApplication.platformName() != 'xcb': return
def __init__(self, parent=None): ''' @param parent QWidget ''' super().__init__(parent) self._ui = uic.loadUi('mc/preferences/UserAgentDialog.ui', self) self._manager = gVar.app.userAgentManager() # UserAgentManager self._knownUserAgents = [] # QStringList self.setAttribute(Qt.WA_DeleteOnClose) self._ui.globalComboBox.setLayoutDirection(Qt.LeftToRight) self._ui.table.setLayoutDirection(Qt.LeftToRight) # QString os = gVar.appTools.operatingSystemLong() if const.OS_UNIX: if QGuiApplication.platformName() == 'xcb': os += 'X11; ' elif QGuiApplication.platformName() == 'wayland': os += 'Wayland; ' chromeRx = re.compile(r'Chrome/([^\s]+)') dUserAgent = self._manager.defaultUserAgent() chromeVersion = chromeRx.search(dUserAgent).groups()[0] self._knownUserAgents.extend([ "Opera/9.80 (%s) Presto/2.12.388 Version/12.16" % os, "Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36" % (os, chromeVersion), "Mozilla/5.0 (%s) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12" % os, "Mozilla/5.0 (%s; rv:57.0) Gecko/20100101 Firefox/57.0" % os, ]) self._ui.globalComboBox.addItems(self._knownUserAgents) # QString globalUserAgent = self._manager.globalUserAgent() self._ui.changeGlobal.setChecked(bool(globalUserAgent)) self._ui.globalComboBox.lineEdit().setText(globalUserAgent) self._ui.globalComboBox.lineEdit().setCursorPosition(0) self._ui.changePerSite.setChecked(self._manager.usePerDomainUserAgents()) for siteItem, userAgentItem in self._manager.perDomainUserAgentsList(): row = self._ui.table.rowCount() self._ui.table.insertRow(row) self._ui.table.setItem(row, 0, siteItem) self._ui.table.setItem(row, 1, userAgentItem) self._ui.table.sortByColumn(-1, Qt.AscendingOrder) self._ui.add.clicked.connect(self._addSite) self._ui.remove.clicked.connect(self._removeSite) self._ui.edit.clicked.connect(self._editSite) self._ui.table.clicked.connect(self._editSite) self._ui.changeGlobal.clicked.connect(self._enableGlobalComboBox) self._ui.changePerSite.clicked.connect(self._enablePerSiteFrame) self._enableGlobalComboBox(self._ui.changeGlobal.isChecked()) self._enablePerSiteFrame(self._ui.changePerSite.isChecked())