class UI(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.gl = QtGui.QGridLayout(self) butonh = QtGui.QPushButton("click to hide", self) butons = QtGui.QPushButton("click to show", self) self.busy = QProgressIndicator(self) self.gl.addWidget(butonh) self.gl.addWidget(self.busy) self.gl.addWidget(butons) self.busy.startAnimation() butonh.clicked.connect(self.busy.stopAnimation) butons.clicked.connect(self.busy.startAnimation)
class UI(QtGui.QWidget): def __init__(self, parent = None): QtGui.QWidget.__init__(self, parent) self.gl = QtGui.QGridLayout(self) butonh = QtGui.QPushButton("click to hide", self) butons = QtGui.QPushButton("click to show", self) self.busy = QProgressIndicator(self) self.gl.addWidget(butonh) self.gl.addWidget(self.busy) self.gl.addWidget(butons) self.busy.startAnimation() butonh.clicked.connect(self.busy.stopAnimation) butons.clicked.connect(self.busy.startAnimation)
class WebDialog(PAbstractBox, Ui_WebDialog): def __init__(self, parent): PAbstractBox.__init__(self, parent) self.setupUi(self) self.iface = parent.iface # PDS Settings self._animation = 1 self._duration = 1 self.enableOverlay() self.setOverlayOpacity(150) self._disable_parent_in_shown = True self.registerFunction(IN, lambda: parent.statusBar().hide()) self.registerFunction( FINISHED, lambda: parent.statusBar().setVisible(not self.isVisible())) self._as = 'http://appinfo.pisilinux.org' self.cancelButton.clicked.connect(self._hide) self.cancelButton.setIcon(KIcon("cancel")) # Hide Scrollbars and context menu in webview self.webView.setContextMenuPolicy(Qt.NoContextMenu) self.webView.page().mainFrame().setScrollBarPolicy( Qt.Vertical, Qt.ScrollBarAlwaysOff) self.webView.page().mainFrame().setScrollBarPolicy( Qt.Horizontal, Qt.ScrollBarAlwaysOff) self.webView.page().setLinkDelegationPolicy( QtWebKit.QWebPage.DelegateAllLinks) self.webView.page().linkClicked.connect(self.showFullImage) self.tabWidget.removeTab(0) self.busy = QProgressIndicator(self, "white") self.busy.setMaximumSize(QSize(48, 48)) self.webLayout.addWidget(self.busy) self.busy.hide() self._filesThread = PThread(self, self.getFiles, self.getFilesFinished) self.noconnection.hide() self.parent = parent def showFullImage(self, url): PreviewDialog(self, url) def showPage(self, addr): if network_available(): self.webView.load(QUrl(addr)) else: self._sync_template(status=False) self.animate(start=BOTCENTER, stop=MIDCENTER) def getFiles(self): return self.iface.getPackageFiles(str(self.packageName.text())) def getFilesFinished(self): self.filesList.addItems(self._filesThread.get()) self.filesList.sortItems() def _tabSwitched(self, index): if index == 0 and self.tabWidget.count() > 1: if self.filesList.count() == 0: self._filesThread.start() def _sync_template(self, status, package='', summary='', description=''): def _replace(key, value): self.webView.page().mainFrame().evaluateJavaScript(\ '%s.innerHTML="%s";' % (key, value)) self.busy.hide() self.busy.stopAnimation() if status: _replace('title', package) _replace('summary', summary) _replace('description', description) self.webWidget.show() self.noconnection.hide() else: self.noconnection.show() self.webWidget.hide() reset_proxy_settings() def showPackageDetails(self, package, installed, summary='', description=''): self.packageName.setText(package) self.filesList.clear() self.tabWidget.insertTab(0, self.packageFiles, i18n('Package Files')) self.tabWidget.currentChanged.connect(self._tabSwitched) if config.USE_APPINFO: self.webView.loadFinished.connect(lambda x: \ self._sync_template(x, package, summary, description)) if network_available(): set_proxy_settings() self.webWidget.hide() self.busy.show() self.busy.startAnimation() self.webView.load(QUrl('%s/?p=%s' % (self._as, package))) else: self._sync_template(status=False) else: self.tabWidget.removeTab(1) self._filesThread.start() if not installed: self.tabWidget.removeTab(0) self.tabWidget.currentChanged.disconnect(self._tabSwitched) self.animate(start=BOTCENTER, stop=MIDCENTER) def _hide(self): self.busy.stopAnimation() try: self.webView.loadFinished.disconnect() except: pass self.animate(start=MIDCENTER, stop=BOTCENTER, direction=OUT)
class WebDialog(PAbstractBox, Ui_WebDialog): def __init__(self, parent): PAbstractBox.__init__(self, parent) self.setupUi(self) self.iface = parent.iface # PDS Settings self._animation = 1 self._duration = 400 self.enableOverlay() self._disable_parent_in_shown = True self.registerFunction(IN, lambda: parent.statusBar().hide()) self.registerFunction(FINISHED, lambda: parent.statusBar().setVisible(not self.isVisible())) self._as = 'http://onurguzel.com/appinfo' self.cancelButton.clicked.connect(self._hide) self.cancelButton.setIcon(KIcon("dialog-close")) # Hide Scrollbars and context menu in webview self.webView.setContextMenuPolicy(Qt.NoContextMenu) self.webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) self.webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) self.webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) self.webView.page().linkClicked.connect(self.redirectLinks) self.tabWidget.removeTab(0) self.busy = QProgressIndicator(self, "white") self.busy.setMaximumSize(QSize(48, 48)) self.webLayout.addWidget(self.busy) self.busy.hide() self._filesThread = PThread(self, self.getFiles, self.getFilesFinished) self.filterLine.setListWidget(self.filesList) self.noconnection.hide() self.parent = parent def redirectLinks(self, url): if url.hasFragment(): if url.fragment() == 'login': self.showLogin() else: PreviewDialog(self, url) def showLogin(self): self._hide() self.parent.settingsDialog.show() self.parent.settingsDialog.tabWidget.setCurrentIndex(4) def showPage(self, addr): if network_available(): self.webView.load(QUrl(addr)) else: self._sync_template(status = False) self.animate(start = BOTCENTER, stop = MIDCENTER) def getFiles(self): return self.iface.getPackageFiles(str(self.packageName.text())) def getFilesFinished(self): self.filesList.addItems(self._filesThread.get()) self.filesList.sortItems() def _tabSwitched(self, index): if index == 0 and self.tabWidget.count() > 1: if self.filesList.count() == 0: self._filesThread.start() def _sync_template(self, status, package = '', summary = '', description = ''): def _replace(key, value): self.webView.page().mainFrame().evaluateJavaScript(\ '%s.innerHTML="%s";' % (key, value)) self.busy.hide() self.busy.stopAnimation() if status: _replace('title', package) _replace('summary', summary) _replace('description', description) self.webWidget.show() self.noconnection.hide() else: self.noconnection.show() self.webWidget.hide() reset_proxy_settings() def showPackageDetails(self, package, installed, summary='', description=''): self.packageName.setText(package) self.key = config.PMConfig().getOpenDesktopKey() self.filesList.clear() self.webView.loadFinished.connect(lambda x: \ self._sync_template(x, package, summary, description)) if network_available(): set_proxy_settings() self.webWidget.hide() self.busy.show() self.busy.startAnimation() params = {'p': package} if self.key: params['k'] = self.key self.webView.load(QUrl('%s/?%s' % (self._as, urlencode(params)))) else: self._sync_template(status = False) self.tabWidget.insertTab(0, self.packageFiles, i18n('Package Files')) self.tabWidget.currentChanged.connect(self._tabSwitched) if not installed: self.tabWidget.removeTab(0) self.tabWidget.currentChanged.disconnect(self._tabSwitched) self.animate(start = BOTCENTER, stop = MIDCENTER) def _hide(self): self.busy.stopAnimation() try: self.webView.loadFinished.disconnect() except: pass self.animate(start = MIDCENTER, stop = BOTCENTER, direction = OUT)
class WebDialog(PAbstractBox, Ui_WebDialog): finished = pyqtSignal() def __init__(self, parent): PAbstractBox.__init__(self, parent) self.setupUi(self) self.iface = backend.pm.Iface() #parent.iface # PDS Settings self._animation = 1 self._duration = 1 self.enableOverlay() self.setOverlayOpacity(150) self._disable_parent_in_shown = True self.registerFunction(IN, lambda: parent.statusBar().hide()) self.registerFunction(FINISHED, lambda: parent.statusBar().setVisible(not self.isVisible())) self._as = 'http://appinfo.pisilinux.org' self.cancelButton.clicked.connect(self._hide) self.cancelButton.setIcon(QIcon.fromTheme("cancel")) # Hide Scrollbars and context menu in webview self.webView.setContextMenuPolicy(Qt.NoContextMenu) self.webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) self.webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) self.webView.page().setLinkDelegationPolicy(QtWebKitWidgets.QWebPage.DelegateAllLinks) self.webView.page().linkClicked.connect(self.showFullImage) self.tabWidget.removeTab(0) self.busy = QProgressIndicator(self, "white") self.busy.setMaximumSize(QSize(48, 48)) self.webLayout.addWidget(self.busy) self.busy.hide() self._filesThread = PThread(self, self.getFiles, self.getFilesFinished) self.noconnection.hide() self.parent = parent def destroyed(self): self.finished.emit() def showFullImage(self, url): PreviewDialog(self, url) def showPage(self, addr): if network_available(): self.webView.load(QUrl(addr)) else: self._sync_template(status = False) self.animate(start = BOTCENTER, stop = MIDCENTER) def getFiles(self): files=self.iface.getPackageFiles(str(self.packageName.text())) self.filesList.addItems(files) self.filesList.sortItems() return files #self.iface.getPackageFiles(str(self.packageName.text())) def getFilesFinished(self): self.filesList.addItems(self._filesThread.get()) self.filesList.sortItems() def _tabSwitched(self, index): if index == 0 and self.tabWidget.count() > 1: if self.filesList.count() == 0: self._filesThread.start() def _sync_template(self, status, package = '', summary = '', description = ''): def _replace(key, value): self.webView.page().mainFrame().evaluateJavaScript(\ '%s.innerHTML="%s";' % (key, value)) self.busy.hide() self.busy.stopAnimation() if status: _replace('title', package) _replace('summary', summary) _replace('description', description) self.webWidget.show() self.noconnection.hide() else: self.noconnection.show() self.webWidget.hide() reset_proxy_settings() def showPackageDetails(self, package, installed, summary='', description=''): package = str(QVariant.value(package)) summary = str(QVariant.value(summary)) description = str(QVariant.value(description)) self.packageName.setText(package) self.filesList.clear() self.tabWidget.insertTab(0, self.packageFiles, _translate("Packaga Manager",'Package Files')) self.tabWidget.currentChanged.connect(self._tabSwitched) if config.USE_APPINFO: self.webView.loadFinished.connect(lambda x: \ self._sync_template(x, package, summary, description)) if network_available(): set_proxy_settings() self.webWidget.hide() self.busy.show() self.busy.startAnimation() self.webView.load(QUrl('%s/?p=%s' % (self._as, package))) else: self._sync_template(status = False) else: self.tabWidget.removeTab(1) self._filesThread.start() if not installed: self.tabWidget.removeTab(0) self.tabWidget.currentChanged.disconnect(self._tabSwitched) self.animate(start = BOTCENTER, stop = MIDCENTER) def _hide(self): self.busy.stopAnimation() try: self.webView.loadFinished.disconnect() except: pass self.animate(start = MIDCENTER, stop = BOTCENTER, direction = OUT)