RefactoringRope/RopeProgressDialog.py

Thu, 30 Dec 2021 11:20:04 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 30 Dec 2021 11:20:04 +0100
branch
eric7
changeset 374
958f34e97952
parent 365
f740b50380df
child 389
4f53795beff0
permissions
-rw-r--r--

Updated copyright for 2022.

# -*- coding: utf-8 -*-

# Copyright (c) 2017 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a TaskHandle class with a progress dialog.
"""

from PyQt6.QtCore import QCoreApplication
from PyQt6.QtWidgets import QLabel

from EricWidgets.EricProgressDialog import EricProgressDialog


class RopeProgressDialog(EricProgressDialog):
    """
    Class implementing TaskHandle with a progress dialog.
    """
    def __init__(self, server, title, interruptable=True, parent=None):
        """
        Constructor
        
        @param server reference to the JSON server
        @type EricJsonServer
        @param title title for the dialog
        @type str
        @param interruptable flag indicating, that the task may be
            interrupted
        @type bool
        @param parent reference to the parent widget
        @type QWidget
        """
        super().__init__("", "", 0, 1, "", parent)
        if interruptable:
            self.setCancelButtonText(self.tr("Interrupt"))
        self.setFormat(self.tr("%v/%m files"))
        label = QLabel("")
        label.setWordWrap(True)
        self.setLabel(label)
        self.setWindowTitle(self.tr("eric7 - {0}").format(title))
        
        self.__server = server
    
    def updateProgress(self, params):
        """
        Public slot to handle the task progress.
        
        @param params dictionary containing the data to be set
        @type dict
        """
        if params:
            self.setLabelText(params["Text"])
        if "Maximum" in params:
            # these are always sent together
            self.setMaximum(params["Maximum"])
            self.setValue(params["Value"])
        
        QCoreApplication.processEvents()
        
        if self.wasCanceled():
            self.__server.sendJson("AbortAction", {})

eric ide

mercurial