def getWorkingDialog(text): """ Generates a working dialog object which blocks the UI. :param text: Text to display while working :return: The created working dialog widget """ progressDialog = QProgressDialog(text, "", 0, 0, parent=Globals.ui.tabWidgetMain) progressDialog.setMinimumDuration(0) progressDialog.setMinimum(0) progressDialog.setMaximum(0) progressDialog.setRange(0, 0) progressDialog.setFixedSize(progressDialog.width(), progressDialog.height()) # No cancel button <: progressDialog.setCancelButton(None) # No X button progressDialog.setWindowFlags(progressDialog.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint) progressBar = progressDialog.findChild(QProgressBar) # :S:S progressBar.setMinimumWidth(progressDialog.width() + 20) return progressDialog
def make_progress(msg,total_steps): progress = QProgressDialog(msg, None, 0, total_steps, None) progress.setWindowTitle("Horse") progress.setMinimumDuration(0) progress.setWindowModality(Qt.WindowModal) progress.setValue( progress.value() + 1) progress.show() return progress
def __init__(self): self.mainwindow = QMainWindow() settings.get_settings() self.access = tuple(settings.access.items()) self.progress = QProgressDialog("Setting up modules...", "cancel", 0, 7, self.mainwindow) self.progress.setWindowTitle( QApplication.translate("MainWindow", str(settings.company), None, QApplication.UnicodeUTF8))
def buildImageDataList(self): """ Build the image list with meta data to be constructed into pdf """ markerName = "" shotStatus = "" markerIndex = 1 self.fileList = [] self.tempFileDir = tempfile.gettempdir() numFiles = len(self.shotCutList) progress = QProgressDialog("Generating PDF...", "Cancel Export", 0, numFiles, hiero.ui.mainWindow()) progress.setWindowModality(Qt.WindowModal) tc = Timecode() timecodeStart = self.sequence.timecodeStart() timecodeDisplayMode = Timecode().kDisplayTimecode fps = self.sequence.framerate() count = 1 for shot in self.shotCutList: thumbPath = os.path.join(self.tempFileDir,"%s_%s.jpg" % (shot.name(), self.currentTimeString())) thumbnailFrame = self.getThumbFrameForShot(shot) # Try and get a thumbnail, assuming the media is present etc... try: thumb = shot.thumbnail( thumbnailFrame ).save(thumbPath) except: shutil.copy(self.offlineLogoPath, thumbPath) if not os.path.isfile(thumbPath) or progress.wasCanceled(): self.cleanUpTempFiles() progress.cancel() break # This file list gets cleaned up after the PDF save finishes self.fileList += [thumbPath] dataDict = {'show':self.project, 'sequence':self.sequence, 'editVersion':"*Version*", 'setup':"*setup*", 'timeString': tc.timeToString(shot.timelineIn() + timecodeStart, fps, timecodeDisplayMode) + ", %if" % shot.duration(), 'name': self.validString(shot.name()), 'version':"*version*", 'path': thumbPath, 'track': self.validString(shot.parentTrack().name()), 'shot': self.validString(shot.source().name()), 'shotLabel': self.validString(shot.name()), 'shotStatus': "*ShotStatus*", } self.imageDataList.append(dataDict) progress.setValue(count) count += 1
def collectNoise(self, seconds): """ Collect noise data and update ``noiseData``. Uses the processes/threads started in :func:`startSnifferAndAdder`. :param seconds: Amount of seconds to capture noise :return: True if noise was captured. False if the user pressed "Cancel" """ self.noiseData = [] # Setup the ProgressDialog progressDialog = QProgressDialog( Strings.filterTabCollectingNoiseMessageBoxText, "Cancel", 0, seconds) progressDialog.setMinimumDuration(0) progressDialog.setMinimum(0) progressDialog.setMaximum(seconds) progressDialog.adjustSize() progressDialog.setFixedSize(progressDialog.width() + 40, progressDialog.height()) # Users still can click on the "X" progressDialog.setCancelButton(None) # Start collecting self.startSnifferAndAdder(adderMethod=self.addSniffedNoise) progressDialog.open() secondsToCollect = seconds while secondsToCollect > 0 and not progressDialog.wasCanceled(): time.sleep(0.5) secondsToCollect -= 0.5 self.updateNoiseCollectProgress(progressDialog, seconds - secondsToCollect) self.stopSnifferAndAdder() return not progressDialog.wasCanceled()
def copy_files(self): """Initiate copy process. File size is calculated first to check that there is enough space in the destination. If there is enough space then we start the copy of the files to their destination. Input: None Output: None""" self.copyButton.setEnabled(False) self.copyWorker.must_run = True self.connect(self.copyWorker, SIGNAL("copyProgress(QString, QString, QString)"), self.copy_progress, Qt.QueuedConnection) dest_dir = self.lblDestPath.text() if dest_dir == '': QMessageBox.critical(self, "Destination not set", "Please specify a destination path", WindowModility=True) else: copy_filelist = [] for selection in self.treeView.selectedIndexes(): indexItem = self.model.index(selection.row(), 0, selection.parent()) copy_filelist.append(self.model.filePath(indexItem)) if self.cbOWDest.isChecked(): if self.rbOWEither.isChecked(): overwrite_option = 'either' elif self.rbOWLarger.isChecked(): overwrite_option = 'larger' elif self.rbOWNewer.isChecked(): overwrite_option = 'newer' else: QMessageBox.critical( self, "Overwrite option missing", """You did not select an overwrite option.""", WindowModility=True) self.copyButton.setEnabled(True) return else: overwrite_option = None if not self.ckbxTrimDir.isChecked(): flattencount = 0 else: flattencount = self.trimdirCount.value() self.progress = QProgressDialog("Copy in progress.", "Cancel", 0, 100, modal=True) self.progress.canceled.connect(self.cancel_copy) self.progress.setWindowTitle('Copy Progress') var_values = { 'destdir': dest_dir, 'filelist': copy_filelist, 'flattencount': flattencount, 'overwrite_opt': overwrite_option } self.socket.send(json.dumps(var_values)) self.copyWorker.start()
def reload(self, order_overview_widget, all_ops, all_operations, sort=1): # mainlog.debug("reload...") progress = QProgressDialog(_("Collecting data..."), None, 0, len(all_ops) + 3, order_overview_widget) progress.setWindowTitle("Horse") progress.setMinimumDuration(0) progress.setWindowModality(Qt.WindowModal) progress.setValue(progress.value() + 1) progress.show() for i in self.items(): self.removeItem(i) self.posts_offsets = dict() self.drawn_operations_data = dict() self.cursor = QGraphicsRectItem(0, 0, 50, 300) self.cursor.setBrush(QBrush(QColor(208, 208, 255, 255))) self.cursor.setPen(QPen(Qt.transparent)) self.addItem(self.cursor) bar_width = 8 bar_height = int(bar_width * 60.0 / 8.0) ascent = QFontMetrics(self.base_font).ascent() ascent_big = QFontMetrics(self.base_font_big).ascent() post_ops = {} # mainlog.debug("reload...2") # z = 0 # for op,order_part,parts in all_operations: # z = op.planned_hours # z = order_part.deadline # z = order_part.qty # z = order_part.human_identifier # all_operations = map(lambda i:i[0],all_operations) y = 0 for opdef in all_ops: progress.setValue(progress.value() + 1) operations = filter( lambda op: op.operation_definition_id == opdef. operation_definition_id, all_operations) # We're only interested in the effort/time that remains # to be put on an operation. We're only interested in # the future. # We want the oeprations that are either # - ongoing # - ready to start. # In all cases we're only interested in operations # that are "active" if sort == 1: operations = sorted( operations, key=lambda op: op.deadline or date(3000, 1, 1)) elif sort == 2: operations = sorted( operations, key=lambda op: op.planned_hours * op.qty - op.done_hours) else: # Don't sort pass maximum = 16.0 #float ! small_hours = 0 op_ndx = 0 current_x = 50 bar_drawn = False total_done_hours = total_estimated = 0 # -------------------------------------------------------------- # Started operations bars_line = BarsLine(16, bar_width, bar_height, current_x, y, self, order_overview_widget) total_hours_to_do = 0 for op in filter(lambda op: op.done_hours > 0, operations): hours_to_do = max( 0, op.planned_hours * op.qty - op.done_hours) # max protects against reporting errors total_hours_to_do += hours_to_do total_estimated += op.planned_hours * op.qty total_done_hours += op.done_hours bars_line.add_bar(hours_to_do, QBrush(Qt.green), self._operation_hoover_description(op), False, None) # op.production_file.order_part) # -------------------------------------------------------------- bars_line_unstarted_operations = BarsLine(16, bar_width, bar_height, current_x + 30, y, self, order_overview_widget) total_hours_to_do_on_unstarted_operations = 0 for op in filter(lambda op: op.done_hours == 0, operations): hours_to_do = op.planned_hours * op.qty total_hours_to_do_on_unstarted_operations += hours_to_do total_estimated += hours_to_do bars_line_unstarted_operations.add_bar( hours_to_do, QBrush(Qt.yellow), self._operation_hoover_description(op), False, None) #op.production_file.order_part) y_start = y total = total_hours_to_do + total_hours_to_do_on_unstarted_operations if total > 0: self.drawn_operations_data[ opdef.operation_definition_id] = "{}h".format( int(round(total_estimated))) gi = QGraphicsSimpleTextItem( _("{} - Estimated to do : {}h; done : {}h").format( opdef.description, int(round(total)), int(round(total_done_hours)))) gi.setFont(self.base_font_big) gi.setPos(0, y - gi.boundingRect().height()) self.addItem(gi) th = gi.boundingRect().height() gi = QGraphicsLineItem(-ascent_big, y, 1024 + 2 * ascent_big, y) gi.setPen(QPen(Qt.black)) self.addItem(gi) y += th else: continue y_bars = y if total_hours_to_do > 0: # There's something to draw head = QGraphicsSimpleTextItem(_("Started")) head.setFont(self.base_font) head.setPos(current_x, y) self.addItem(head) y += head.boundingRect().height() y += bar_height bars_line.set_start_pos(current_x, y) bars_line.finish_bar() foot = QGraphicsSimpleTextItem( _("{}h").format(int(total_hours_to_do + 0.5))) foot.setFont(self.base_font) foot.setPos(current_x, y) self.addItem(foot) y += foot.boundingRect().height() current_x = max(current_x + bars_line.estimate_width(), head.boundingRect().right(), foot.boundingRect().right()) bar_drawn = True if total_hours_to_do_on_unstarted_operations > 0: if bars_line_unstarted_operations.estimate_width( ) + current_x > 1200: x = 50 y += ascent_big else: y = y_bars x = current_x + 50 head = QGraphicsSimpleTextItem(_("Not started yet")) head.setFont(self.base_font) head.setPos(x, y) self.addItem(head) y += head.boundingRect().height() y += bar_height bars_line_unstarted_operations.set_start_pos(x, y) bars_line_unstarted_operations.finish_bar() foot = QGraphicsSimpleTextItem( _("{}h").format( int(total_hours_to_do_on_unstarted_operations + 0.5))) foot.setFont(self.base_font) foot.setPos(x, y) self.addItem(foot) y += foot.boundingRect().height() bar_drawn = True y += 3 * ascent_big r = self.sceneRect() self.posts_offsets[opdef.operation_definition_id] = \ QRectF(r.x() - 2*ascent_big, y_start - 1.5*ascent_big, r.width() + 4*ascent_big, (y - ascent_big) - (y_start - 1.5*ascent_big) ) y += ascent_big # mainlog.debug("reload...3") import functools max_width = functools.reduce(lambda acc, po: max(acc, po.width()), self.posts_offsets.values(), 0) map(lambda po: po.setWidth(max_width), self.posts_offsets.values()) # for r in self.posts_offsets.values(): # gi = QGraphicsLineItem(r.x(),r.y(),r.x()+r.width(),r.y()) # gi.setPen(QPen(Qt.lightGray)) # self.addItem(gi) progress.close()