def browserFolder(self): directory = QtGui.QFileDialog.getExistingDirectory(self, QtGui.QApplication.translate("mainwidget", "Select folder to resize", None, QtGui.QApplication.UnicodeUTF8), os.path.expanduser("~")) if directory: directory = os.path.normpath(unicode(directory)) if os.path.exists(directory): d = self._addFilesFromDir(directory) if len(d)<=0: dlg = MessageDialog(self.parentWidget()) dlg.setText(QtGui.QApplication.translate("config", "Selected folder does not have any image files.", None, QtGui.QApplication.UnicodeUTF8)) common.show_dialog_on_top(dlg, self.parentWidget()) return else: self.filesTable.updateValue(d) self._change_btns_state()
def doRegister(self): key = self.keyLineEdit.text() parent = self.parentWidget() if not key: dlg = MessageDialog(self.parentWidget()) message = unicode(QtGui.QApplication.translate("dialogs", "Please enter a license key.", None, QtGui.QApplication.UnicodeUTF8)) dlg.setText(message) common.show_dialog_on_top(dlg, self.parentWidget()) else: if common.verify_license_key(key): self.close() dlg = MessageDialog(self.parentWidget()) message = unicode(QtGui.QApplication.translate("dialogs", "Registration is complete, Thank you.", None, QtGui.QApplication.UnicodeUTF8)) dlg.setText(message) common.show_dialog_on_top(dlg, self.parentWidget()) self.parentWidget().registrationCompleted() else: dlg = WrongLicenseDialog(parent) r = common.show_dialog_on_top(dlg, self.parentWidget()) if r==QtGui.QDialog.Accepted: pass else: self.close()
def browserFolder(self): directory = QtGui.QFileDialog.getExistingDirectory( self, QtGui.QApplication.translate("mainwidget", "Select folder to resize", None, QtGui.QApplication.UnicodeUTF8), os.path.expanduser("~")) if directory: directory = os.path.normpath(unicode(directory)) if os.path.exists(directory): d = self._addFilesFromDir(directory) if len(d) <= 0: dlg = MessageDialog(self.parentWidget()) dlg.setText( QtGui.QApplication.translate( "config", "Selected folder does not have any image files.", None, QtGui.QApplication.UnicodeUTF8)) common.show_dialog_on_top(dlg, self.parentWidget()) return else: self.filesTable.updateValue(d) self._change_btns_state()
def doRegister(self): dlg = RegisterDialog(self) common.show_dialog_on_top(dlg, self)
def newVersionAvailable(self, prog_name, version, revision, required_mini_revision, url, download_url): dlg = UpdateDialog(self, prog_name, version, download_url) common.show_dialog_on_top(dlg, self)
def doAbout(self): dlg = AboutDialog(self) common.show_dialog_on_top(dlg, self)
def doSettingsAndStart(self): dlg = SettingsDialog(self) dlg.initForStart() dlg.restore() common.show_dialog_on_top(dlg, self)
def doIt(self): files = self.centralViewer.filesTable.data[:] progress_dialog = ProcessingDialog(self) #common.show_dialog_on_top(progress_dialog, self) dialog_geometry = progress_dialog.geometry() width = dialog_geometry.width() height = dialog_geometry.height() main_geometry = self.geometry() dialog_geometry.setY(main_geometry.y()) dialog_geometry.setX( main_geometry.x() + (main_geometry.width() - dialog_geometry.width()) / 2) dialog_geometry.setWidth(width) dialog_geometry.setHeight(height) progress_dialog.setGeometry(dialog_geometry) ### progress_dialog.setMinimumDuration(0) progress_dialog.setCancelButtonText('Stop') process_total = len(files) process_total += 1 progress_dialog.setRange(0, process_total) process_val = 0 do_thread_list = [] progress_dialog.show() progress_dialog.updateProgress(process_total, '') processed_count = 0 complete_normal = True used_times = -1 auto_open = self.centralViewer.openOutputCheckBox.isChecked() output_dir = os.path.normpath( unicode(self.centralViewer.outputComboBox.currentText())) progress_dialog.updateProgress(process_total, '') while True: while files and len(do_thread_list) < config.sync_processes_count: f = files.pop(0) if self.has_registered: thread = self._createDoThread(progress_dialog, process_total, f, True, \ outputDir = output_dir,\ autoOpen = auto_open,\ **self.settings) do_thread_list.append(thread) else: if (processed_count >= config.trial_version_each_count): # trial version process limitation progress_dialog.updateProgress(process_total, '') else: thread = self._createDoThread(progress_dialog, process_total, f, True, \ outputDir = output_dir,\ **self.settings) do_thread_list.append(thread) processed_count += 1 QtGui.qApp.processEvents() if progress_dialog.wasCanceled(): complete_normal = False for t in do_thread_list: t.cancel() t.exit() return if len(do_thread_list) <= 0: progress_dialog.close() break else: for t in do_thread_list: if t.isFinished(): do_thread_list.remove(t) if complete_normal: if self.settings.get("playSound", False): config.play_sound(config.compete_sound_file) if auto_open: common.open_folder(output_dir) dlg = CompleteDialog(self.has_registered, self) common.show_dialog_on_top(dlg, self)
def doIt(self): files = self.centralViewer.filesTable.data[:] progress_dialog = ProcessingDialog(self) #common.show_dialog_on_top(progress_dialog, self) dialog_geometry = progress_dialog.geometry() width = dialog_geometry.width() height = dialog_geometry.height() main_geometry = self.geometry() dialog_geometry.setY(main_geometry.y()) dialog_geometry.setX(main_geometry.x()+(main_geometry.width()-dialog_geometry.width())/2) dialog_geometry.setWidth(width) dialog_geometry.setHeight(height) progress_dialog.setGeometry(dialog_geometry) ### progress_dialog.setMinimumDuration(0) progress_dialog.setCancelButtonText('Stop') process_total = len(files) process_total += 1 progress_dialog.setRange(0, process_total) process_val = 0 do_thread_list = [] progress_dialog.show() progress_dialog.updateProgress(process_total, '') processed_count = 0 complete_normal = True used_times = -1 auto_open = self.centralViewer.openOutputCheckBox.isChecked() output_dir = os.path.normpath(unicode(self.centralViewer.outputComboBox.currentText())) progress_dialog.updateProgress(process_total, '') while True: while files and len(do_thread_list)<config.sync_processes_count: f = files.pop(0) if self.has_registered: thread = self._createDoThread(progress_dialog, process_total, f, True, \ outputDir = output_dir,\ autoOpen = auto_open,\ **self.settings) do_thread_list.append(thread) else: if (processed_count >= config.trial_version_each_count): # trial version process limitation progress_dialog.updateProgress(process_total, '') else: thread = self._createDoThread(progress_dialog, process_total, f, True, \ outputDir = output_dir,\ **self.settings) do_thread_list.append(thread) processed_count += 1 QtGui.qApp.processEvents() if progress_dialog.wasCanceled(): complete_normal = False for t in do_thread_list: t.cancel() t.exit() return if len(do_thread_list)<=0: progress_dialog.close() break; else: for t in do_thread_list: if t.isFinished(): do_thread_list.remove(t) if complete_normal: if self.settings.get("playSound", False): config.play_sound(config.compete_sound_file) if auto_open: common.open_folder(output_dir) dlg = CompleteDialog(self.has_registered, self) common.show_dialog_on_top(dlg, self)
def updateValue(self, lst): if not lst: showPrompt = True self.clear() self.data = [] self.emit(QtCore.SIGNAL("tablecleared()")) x=1 font = self.fontMetrics() PROMPT_HEIGHT = 120 promptLines = int(PROMPT_HEIGHT/font.lineSpacing()) prompt_pos= (self.linePerPage-promptLines)/2 + 1 while x<=self.linePerPage: if x==prompt_pos: i = QtGui.QTreeWidgetItem([""]) i.setData(0, QtCore.Qt.ToolTipRole, QtCore.QVariant("")) self.addTopLevelItem(i) else: i = QtGui.QTreeWidgetItem([""]) i.setData(0, QtCore.Qt.ToolTipRole, QtCore.QVariant("")) self.addTopLevelItem(i) x+=1 self.centerPrompt(showPrompt) else: supportedList = [] supported_types = config.supported_formats['image'] for fullFilePath in lst: ext = os.path.splitext(os.path.basename(fullFilePath))[1].lower() if ext in supported_types: if fullFilePath not in supportedList: supportedList.append(fullFilePath) if self.data: self.centerPrompt(False) if supportedList: for p in supportedList: if p not in self.data: self.data.append(p) else: centerWidget = self.parentWidget().parentWidget().parentWidget().parentWidget() dlg = MessageDialog(centerWidget) dlg.setText(QtGui.QApplication.translate("mytreewidget", "Please drag JPEG, PNG, TIFF, BMP, GIF files/folders.", None, QtGui.QApplication.UnicodeUTF8)) common.show_dialog_on_top(dlg, centerWidget) return else: if not supportedList: centerWidget = self.parentWidget().parentWidget().parentWidget().parentWidget() dlg = MessageDialog(centerWidget) dlg.setText(QtGui.QApplication.translate("mytreewidget", "Please drag JPEG, PNG, TIFF, BMP, GIF files/folders.", None, QtGui.QApplication.UnicodeUTF8)) common.show_dialog_on_top(dlg, centerWidget) self.centerPrompt(True) return else: self.data = supportedList self.centerPrompt(False) self.clear() for itm in self.data: base_itm = os.path.basename(itm) i = QtGui.QTreeWidgetItem([base_itm]) i.setData(0, QtCore.Qt.ToolTipRole, QtCore.QVariant(itm)) #i.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsDragEnabled|QtCore.Qt.ItemIsDropEnabled) self.addTopLevelItem(i) if len(lst)<self.linePerPage: for x in xrange(self.linePerPage-len(lst)-1): i = QtGui.QTreeWidgetItem([""]) i.setData(0, QtCore.Qt.ToolTipRole, QtCore.QVariant("")) #i.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsDragEnabled|QtCore.Qt.ItemIsDropEnabled) self.addTopLevelItem(i)