コード例 #1
0
class ProgressDialog(PAbstractBox, Ui_ProgressDialog):
    def __init__(self, state, parent=None):
        PAbstractBox.__init__(self, parent)
        self.iface = backend.pm.Iface()
        self.state = state
        self.setupUi(self)

        self.busy = QProgressIndicator(self, "white")
        self.busy.setMinimumSize(QSize(48, 48))
        self.mainLayout.addWidget(self.busy)

        # PDS Settings
        self._animation = 2
        self._duration = 1
        self.last_msg = None
        self.enableOverlay()
        self.setOverlayOpacity(150)
        self._disable_parent_in_shown = True

        self.registerFunction(FINISHED, self.busy.startAnimation)
        self.registerFunction(OUT, self.busy.stopAnimation)

        self.cancelButton.clicked.connect(self.cancel)
        self.cancelButton.setIcon(QIcon.fromTheme("list-remove"))
        self.parent = parent
        self.widget.setStyleSheet("QTextEdit { \
            background:rgba(0,0,0,0); \
            color:white;}")

        self._last_action = ''
        self._shown = False

    def _show(self):
        self.animate(start=MIDCENTER, stop=MIDCENTER)
        self._shown = True
        print("start")

    def _hide(self):
        if self._shown:
            self.animate(direction=OUT, start=MIDCENTER, stop=MIDCENTER)
            self.parent.setWindowTitle(
                _translate("Package Manager", "Package Manager"))
            self._shown = False

    def updateProgress(self, progress):
        self.busy.stopAnimation()
        self.busy.hide()
        self.widget.show()
        if not self.isVisible():
            if not self.parent.cw._started:
                self.disableCancel()
            self._show()
        self.progressBar.setValue(progress)
        self.percentage.setText(
            _translate("Package Manager",
                       "<p align='right'>{0} %</p>").format(progress))
        self.parent.setWindowTitle(
            _translate("Package Manager", "Operation - {0}%").format(progress))

    def updateOperation(self, operation, arg):
        if operation in [
                _translate("Package Manager", "configuring"),
                _translate("Package Manager", "extracting")
        ]:
            self.disableCancel()

        if operation == "updatingrepo":
            operationInfo = _translate(
                "Package Manager",
                "Downloading package list of {0}").format(arg)
        else:
            operationInfo = _translate("Package Manager",
                                       '{0} {1}').format(operation, arg)

        self.operationInfo.setText(operationInfo)

    def updateStatus(self, packageNo, totalPackages, operation):
        text = _translate("Package Manager",
                          "[{0} / {1}]").format(packageNo, totalPackages)
        self.actionLabel.setText("%s %s" % (text, self._last_action))

    def updateRemainingTime(self, time):
        self.timeRemaining.setText("<p align='right'>%s</p>" % time)

    def updateCompletedInfo(self, completed, total, rate):
        text = _translate("Package Manager",
                          "{0} / {1}, {2}").format(completed, total, rate)
        self.completedInfo.setText(text)

    def updateActionLabel(self, action):
        self.actionLabel.setText("<i>%s</i>" %
                                 self.state.getActionCurrent(action))
        self._last_action = self.actionLabel.toPlainText()

    def enableCancel(self):
        self.cancelButton.setEnabled(True)

    def disableCancel(self):
        self.cancelButton.setEnabled(False)

    def reset(self):
        self.widget.hide()
        self.busy.show()

        self.actionLabel.setText(
            _translate("Package Manager", "Preparing PiSi..."))
        self.progressBar.setValue(0)
        self.operationInfo.setText("")
        self.completedInfo.setText("")
        self.timeRemaining.setText("<p align='right'>--:--:--</p>")
        self.timeRemaining.show()

    def cancel(self):
        self.widget.hide()
        self.busy.show()

        self.actionLabel.setText(
            _translate("Package Manager", "<b>Cancelling operation...</b>"))
        self.disableCancel()
        QTimer.singleShot(100, self.iface.cancel)

    def repoOperationView(self):
        self.timeRemaining.setText("")
        self.timeRemaining.hide()
コード例 #2
0
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)
コード例 #3
0
ファイル: webdialog.py プロジェクト: SamiBabat/playground
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)
コード例 #4
0
ファイル: progressdialog.py プロジェクト: vdemir/pisi-2.0
class ProgressDialog(PAbstractBox, Ui_ProgressDialog):

    def __init__(self, state, parent=None):
        PAbstractBox.__init__(self, parent)
        self.iface = backend.pm.Iface()
        self.state = state
        self.setupUi(self)

        self.busy = QProgressIndicator(self, "white")
        self.busy.setMinimumSize(QSize(48, 48))
        self.mainLayout.addWidget(self.busy)

        # PDS Settings
        self._animation = 2
        self._duration = 1
        self.last_msg = None
        self.enableOverlay()
        self.setOverlayOpacity(150)
        self._disable_parent_in_shown = True

        self.registerFunction(FINISHED, self.busy.startAnimation)
        self.registerFunction(OUT, self.busy.stopAnimation)

        self.connect(self.cancelButton, SIGNAL("clicked()"), self.cancel)
        self.cancelButton.setIcon(KIcon("cancel"))
        self.parent = parent

        self.setStyleSheet("QLabel, QTextEdit, QTextBrowser{background:rgba(0,0,0,0);color:white;}")

        self._last_action = ''
        self._shown = False

    def _show(self):
        self.animate(start = MIDCENTER, stop = MIDCENTER)
        self._shown = True

    def _hide(self):
        if self._shown:
            self.animate(direction = OUT, start = MIDCENTER, stop = MIDCENTER)
            self.parent.setWindowTitle(i18n("Package Manager"))
            self._shown = False

    def updateProgress(self, progress):
        self.busy.stopAnimation()
        self.busy.hide()
        self.widget.show()
        if not self.isVisible():
            if not self.parent.cw._started:
                self.disableCancel()
            self._show()
        self.progressBar.setValue(progress)
        self.percentage.setText(i18n("<p align='right'>%1 %</p>", progress))
        self.parent.setWindowTitle(i18n("Operation - %1%", progress))

    def updateOperation(self, operation, arg):
        if operation in [i18n("configuring"),  i18n("extracting")]:
            self.disableCancel()

        if operation == "updatingrepo":
            operationInfo = i18n("Downloading package list of %1", arg)
        else:
            operationInfo = i18n('%1 %2', operation, arg)

        self.operationInfo.setText(operationInfo)

    def updateStatus(self, packageNo, totalPackages, operation):
        text = i18n("[%1 / %2]", packageNo, totalPackages)
        self.actionLabel.setText("%s %s" % (text, self._last_action))

    def updateRemainingTime(self, time):
        self.timeRemaining.setText("<p align='right'>%s</p>" % time)

    def updateCompletedInfo(self, completed, total, rate):
        text = i18n("%1 / %2, %3", completed, total, rate)
        self.completedInfo.setText(text)

    def updateActionLabel(self, action):
        self.actionLabel.setText("<i>%s</i>" % self.state.getActionCurrent(action))
        self._last_action = self.actionLabel.toPlainText()

    def enableCancel(self):
        self.cancelButton.setEnabled(True)

    def disableCancel(self):
        self.cancelButton.setEnabled(False)

    def reset(self):
        self.widget.hide()
        self.busy.show()

        self.actionLabel.setText(i18n("Preparing PiSi..."))
        self.progressBar.setValue(0)
        self.operationInfo.setText("")
        self.completedInfo.setText("")
        self.timeRemaining.setText("<p align='right'>--:--:--</p>")
        self.timeRemaining.show()

    def cancel(self):
        self.widget.hide()
        self.busy.show()

        self.actionLabel.setText(i18n("<b>Cancelling operation...</b>"))
        self.disableCancel()
        QTimer.singleShot(100, self.iface.cancel)

    def repoOperationView(self):
        self.timeRemaining.setText("")
        self.timeRemaining.hide()
コード例 #5
0
class ProgressDialog(PAbstractBox, Ui_ProgressDialog):
    def __init__(self, state, parent=None):
        PAbstractBox.__init__(self, parent)
        self.iface = backend.pm.Iface()
        self.state = state
        self.setupUi(self)

        self.busy = QProgressIndicator(self, "white")
        self.busy.setMinimumSize(QSize(48, 48))
        self.mainLayout.addWidget(self.busy)

        # PDS Settings
        self._animation = 2
        self._duration = 500
        self.last_msg = None
        self.enableOverlay()
        self._disable_parent_in_shown = True

        self.registerFunction(FINISHED, self.busy.startAnimation)
        self.registerFunction(OUT, self.busy.stopAnimation)

        self.connect(self.cancelButton, SIGNAL("clicked()"), self.cancel)
        self.parent = parent

        self.setStyleSheet(
            "QLabel, QTextEdit, QTextBrowser{background:rgba(0,0,0,0);color:white;}"
        )

        self._last_action = ''
        self._shown = False

    def _show(self):
        self.animate(start=MIDCENTER, stop=MIDCENTER)
        self._shown = True

    def _hide(self):
        if self._shown:
            self.animate(direction=OUT, start=MIDCENTER, stop=MIDCENTER)
            self.parent.setWindowTitle(i18n("Package Manager"))
            self._shown = False

    def updateProgress(self, progress):
        self.busy.stopAnimation()
        self.busy.hide()
        self.widget.show()
        if not self.isVisible():
            if not self.parent.cw._started:
                self.disableCancel()
            self._show()
        self.progressBar.setValue(progress)
        self.percentage.setText(i18n("<p align='right'>%1 %</p>", progress))
        self.parent.setWindowTitle(i18n("Operation - %1%", progress))

    def updateOperation(self, operation, arg):
        if operation in [i18n("configuring"), i18n("extracting")]:
            self.disableCancel()

        if operation == "updatingrepo":
            operationInfo = i18n("Downloading package list of %1", arg)
        else:
            operationInfo = i18n('%1 %2', operation, arg)

        self.operationInfo.setText(operationInfo)

    def updateStatus(self, packageNo, totalPackages, operation):
        text = i18n("[%1 / %2]", packageNo, totalPackages)
        self.actionLabel.setText("%s %s" % (text, self._last_action))

    def updateRemainingTime(self, time):
        self.timeRemaining.setText("<p align='right'>%s</p>" % time)

    def updateCompletedInfo(self, completed, total, rate):
        text = i18n("%1 / %2, %3", completed, total, rate)
        self.completedInfo.setText(text)

    def updateActionLabel(self, action):
        self.actionLabel.setText("<i>%s</i>" %
                                 self.state.getActionCurrent(action))
        self._last_action = self.actionLabel.toPlainText()

    def enableCancel(self):
        self.cancelButton.setEnabled(True)

    def disableCancel(self):
        self.cancelButton.setEnabled(False)

    def reset(self):
        self.widget.hide()
        self.busy.show()

        self.actionLabel.setText(i18n("Preparing PiSi..."))
        self.progressBar.setValue(0)
        self.operationInfo.setText("")
        self.completedInfo.setText("")
        self.timeRemaining.setText("<p align='right'>--:--:--</p>")
        self.timeRemaining.show()

    def cancel(self):
        self.widget.hide()
        self.busy.show()

        self.actionLabel.setText(i18n("<b>Cancelling operation...</b>"))
        self.disableCancel()
        QTimer.singleShot(100, self.iface.cancel)

    def repoOperationView(self):
        self.timeRemaining.setText("")
        self.timeRemaining.hide()
コード例 #6
0
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)