def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) # undo # <http://doc.qt.io/qt-5/qtwidgets-tools-undoframework-example.html> self.undoStack = QUndoStack() self.ui.menuStyles.addSeparator() self.undoAction = self.undoStack.createUndoAction(self) self.undoAction.setShortcuts(QKeySequence.Undo) self.ui.menuStyles.addAction(self.undoAction) self.redoAction = self.undoStack.createRedoAction(self) self.redoAction.setShortcuts(QKeySequence.Redo) self.ui.menuStyles.addAction(self.redoAction) # constants self.chartPatternFilter = self.tr("ChartPattern (*.chartpattern)") try: self.XL = win32com.client.Dispatch("Excel.Application") except pythoncom.com_error: QMessageBox.warning(self, self.tr("Error"), self.tr("Excel isn't installed.")) sys.exit(0) # model self.pickedModel = models.ChartStyleModel(self) self.pickedDelegate = models.ChartPatternDelegate(self) self.ui.treeView.setModel(self.pickedModel) self.ui.treeView.setItemDelegate(self.pickedDelegate) if QT_VERSION_STR.startswith("5."): self.ui.treeView.header().setSectionsMovable(False) else: self.ui.treeView.header().setMovable(False) self.targetModel = QStringListModel([ self.tr("ActiveBook"), self.tr("ActiveSheet"), ], self) self.typeModel = QStringListModel([ self.tr("All Chart"), self.tr("Type of ActiveChart"), ], self) self.ui.comboBoxTarget.setModel(self.targetModel) self.ui.comboBoxType.setModel(self.typeModel) self.pickedModel.setUndoStack(self.undoStack) # general_progress self.general_progress = QProgressBar() self.ui.statusbar.addWidget(self.general_progress) self.general_progress.setVisible(False) # progress & progObj self.progress = QProgressBar() self.ui.statusbar.addWidget(self.progress) self.progress.setVisible(False) self.progObj = QtProgressObject() self.progObj.initialized.connect(self.on_progress_initialized) self.progObj.updated.connect(self.on_progress_updated) self.progObj.finished.connect(self.on_progress_finished)
def translate(*args): """ Module function to handle different PyQt 4/5 QCoreApplication.translate parameter. @param args tuple of arguments from QCoreApplication.translate (tuple) @return translated string (string) """ if QT_VERSION_STR.startswith('4.'): args = list(args) args.insert(3, QCoreApplication.CodecForTr) return QCoreApplication.translate(*args)
return "DIRECT"; }} """.format('true' if (has_secret or from_file) else 'false') res = pac.PACResolver(test_str) res.resolve(QNetworkProxyQuery(QUrl(url)), from_file=from_file) # See https://github.com/qutebrowser/qutebrowser/pull/1891#issuecomment-259222615 try: from PyQt5 import QtWebEngineWidgets except ImportError: QtWebEngineWidgets = None @pytest.mark.skipif(QT_VERSION_STR.startswith('5.7') and QtWebEngineWidgets is not None and sys.platform == "linux", reason="Segfaults when run with QtWebEngine tests on Linux" ) def test_fetch(): test_str = """ function FindProxyForURL(domain, host) { return "DIRECT; PROXY 127.0.0.1:8080; SOCKS 192.168.1.1:4444"; } """ class PACHandler(http.server.BaseHTTPRequestHandler): def do_GET(self): self.send_response(200)
ready_event.set() httpd.handle_request() httpd.server_close() serve_thread = threading.Thread(target=serve, daemon=True) serve_thread.start() try: ready_event.wait() res = pac.PACFetcher(QUrl("pac+http://127.0.0.1:8081")) assert res.fetch_error() is None finally: serve_thread.join() return res @pytest.mark.skipif(QT_VERSION_STR.startswith('5.7') and QtWebEngineWidgets is not None and sys.platform == "linux", reason="Segfaults when run with QtWebEngine tests on Linux") def test_fetch_success(): test_str = """ function FindProxyForURL(domain, host) { return "DIRECT; PROXY 127.0.0.1:8080; SOCKS 192.168.1.1:4444"; } """ res = fetcher_test(test_str) proxies = res.resolve(QNetworkProxyQuery(QUrl("https://example.com/test"))) assert len(proxies) == 3