mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 21:24:36 +00:00
Provide more feedback during scans
- Add output for number of collected files / folders - Update to allow indeterminate progress bar - Remove unused hscommon\jobprogress\qt.py
This commit is contained in:
parent
b0baa5bfd6
commit
4c3dfe2f1f
@ -11,6 +11,7 @@ import logging
|
||||
from hscommon.jobprogress import job
|
||||
from hscommon.path import Path
|
||||
from hscommon.util import FileOrPath
|
||||
from hscommon.trans import tr
|
||||
|
||||
from . import fs
|
||||
|
||||
@ -182,8 +183,12 @@ class Directories:
|
||||
"""
|
||||
if fileclasses is None:
|
||||
fileclasses = [fs.File]
|
||||
file_count = 0
|
||||
for path in self._dirs:
|
||||
for file in self._get_files(path, fileclasses=fileclasses, j=j):
|
||||
file_count += 1
|
||||
if type(j) != job.NullJob:
|
||||
j.set_progress(-1, tr("Collected {} files to scan").format(file_count))
|
||||
yield file
|
||||
|
||||
def get_folders(self, folderclass=None, j=job.nulljob):
|
||||
@ -193,9 +198,13 @@ class Directories:
|
||||
"""
|
||||
if folderclass is None:
|
||||
folderclass = fs.Folder
|
||||
folder_count = 0
|
||||
for path in self._dirs:
|
||||
from_folder = folderclass(path)
|
||||
for folder in self._get_folders(from_folder, j):
|
||||
folder_count += 1
|
||||
if type(j) != job.NullJob:
|
||||
j.set_progress(-1, tr("Collected {} folders to scan").format(folder_count))
|
||||
yield folder
|
||||
|
||||
def get_state(self, path):
|
||||
|
@ -139,8 +139,6 @@ class Job:
|
||||
self._progress = progress
|
||||
if self._progress > self._currmax:
|
||||
self._progress = self._currmax
|
||||
if self._progress < 0:
|
||||
self._progress = 0
|
||||
self._do_update(desc)
|
||||
|
||||
|
||||
|
@ -1,52 +0,0 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-09-14
|
||||
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, Qt, QTimer
|
||||
from PyQt5.QtWidgets import QProgressDialog
|
||||
|
||||
from . import performer
|
||||
|
||||
|
||||
class Progress(QProgressDialog, performer.ThreadedJobPerformer):
|
||||
finished = pyqtSignal(["QString"])
|
||||
|
||||
def __init__(self, parent):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
QProgressDialog.__init__(self, "", "Cancel", 0, 100, parent, flags)
|
||||
self.setModal(True)
|
||||
self.setAutoReset(False)
|
||||
self.setAutoClose(False)
|
||||
self._timer = QTimer()
|
||||
self._jobid = ""
|
||||
self._timer.timeout.connect(self.updateProgress)
|
||||
|
||||
def updateProgress(self):
|
||||
# the values might change before setValue happens
|
||||
last_progress = self.last_progress
|
||||
last_desc = self.last_desc
|
||||
if not self._job_running or last_progress is None:
|
||||
self._timer.stop()
|
||||
self.close()
|
||||
if not self.job_cancelled:
|
||||
self.finished.emit(self._jobid)
|
||||
return
|
||||
if self.wasCanceled():
|
||||
self.job_cancelled = True
|
||||
return
|
||||
if last_desc:
|
||||
self.setLabelText(last_desc)
|
||||
self.setValue(last_progress)
|
||||
|
||||
def run(self, jobid, title, target, args=()):
|
||||
self._jobid = jobid
|
||||
self.reset()
|
||||
self.setLabelText("")
|
||||
self.run_threaded(target, args)
|
||||
self.setWindowTitle(title)
|
||||
self.show()
|
||||
self._timer.start(500)
|
@ -7,6 +7,8 @@
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtWidgets import QProgressDialog
|
||||
|
||||
from hscommon.trans import tr
|
||||
|
||||
|
||||
class ProgressWindow:
|
||||
def __init__(self, parent, model):
|
||||
@ -27,11 +29,15 @@ class ProgressWindow:
|
||||
|
||||
def set_progress(self, last_progress):
|
||||
if self._window is not None:
|
||||
if last_progress < 0:
|
||||
self._window.setRange(0, 0)
|
||||
else:
|
||||
self._window.setRange(0, 100)
|
||||
self._window.setValue(last_progress)
|
||||
|
||||
def show(self):
|
||||
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
||||
self._window = QProgressDialog("", "Cancel", 0, 100, self.parent, flags)
|
||||
self._window = QProgressDialog("", tr("Cancel"), 0, 100, self.parent, flags)
|
||||
self._window.setModal(True)
|
||||
self._window.setAutoReset(False)
|
||||
self._window.setAutoClose(False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user