Files
@ d1a9a47788f8
Branch filter:
Location: linux-tools/kusbff/forms/format_dlgs.py - annotation
d1a9a47788f8
3.1 KiB
text/x-python
Progress bar for mass formatting
f3f4cf108453 d1a9a47788f8 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 d1a9a47788f8 f3f4cf108453 d1a9a47788f8 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 d1a9a47788f8 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 f3f4cf108453 | from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication
from floppyemu import format_images
from ui import format_dialog, format_one_dialog
class FormatManyDialog(QtWidgets.QDialog, format_dialog.Ui_Dialog):
def __init__(self, device, temp_path, parent=None):
super().__init__(parent)
self.__device = device
self.__temp_path = temp_path
self.setupUi(self)
@staticmethod
def show_dialog(device, temp_path):
dlg = FormatManyDialog(device, temp_path)
dlg.exec()
def accept(self):
try:
if self.rb_size_720.isChecked():
size = 720
elif self.rb_size_1440.isChecked():
size = 1440
else:
QtWidgets.QMessageBox.critical(
self, 'Error',
'Please choose image size before proceeding'
)
return
self.rb_size_720.setDisabled(True)
self.rb_size_1440.setDisabled(True)
self.sb_from.setDisabled(True)
self.sb_to.setDisabled(True)
self.buttonBox.setDisabled(True)
format_images(
self.__device, ((self.sb_from.value(), self.sb_to.value() + 1),), self.__temp_path, size,
self.__update_progress
)
except PermissionError:
QtWidgets.QMessageBox.critical(
self, 'Permission error',
'You have no access to the device %s. '
'Please restart program as user with proper rights' % (self.__device,)
)
return
super().accept()
def __update_progress(self, indices, index):
self.progressBar.setMaximum(indices[1] - indices[0])
self.progressBar.setValue(index - indices[0])
QApplication.instance().processEvents()
class FormatOneDialog(QtWidgets.QDialog, format_one_dialog.Ui_Dialog):
def __init__(self, index, device, temp_path, parent=None):
super().__init__(parent)
self.__index = index
self.__device = device
self.__temp_path = temp_path
self.setupUi(self)
@staticmethod
def show_dialog(index, device, temp_path):
dlg = FormatOneDialog(index, device, temp_path)
dlg.exec()
def accept(self):
try:
if self.rb_size_720.isChecked():
format_images(self.__device, (self.__index, ), self.__temp_path, 720)
elif self.rb_size_1440.isChecked():
format_images(self.__device, (self.__index, ), self.__temp_path, 1440)
else:
QtWidgets.QMessageBox.critical(
self, 'Error',
'Please choose image size before proceeding'
)
return
except PermissionError:
QtWidgets.QMessageBox.critical(
self, 'Permission error',
'You have no access to the device %s. '
'Please restart program as user with proper rights' % (self.__device,)
)
return
super().accept()
|