Made CBZ-only format work properly

This commit is contained in:
Marek Kubica 2011-10-30 18:24:48 +09:00
parent ee8d8ddef7
commit fa5c378cb8
2 changed files with 18 additions and 9 deletions

View File

@ -13,7 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import os, shutil
from PyQt4 import QtGui, QtCore
import image
@ -23,7 +24,6 @@ import cbz
class DialogConvert(QtGui.QProgressDialog):
def __init__(self, parent, book, directory):
QtGui.QProgressDialog.__init__(self)
#self.setAutoReset(False)
self.book = book
self.directory = directory
@ -47,10 +47,15 @@ class DialogConvert(QtGui.QProgressDialog):
self.timer.start(0)
def closeEvent(self, event):
print "closeEvent"
self.closing.emit()
event.accept()
def hideEvent(self, event):
"""Called when the dialog finishes processing."""
# close the archive if we created a CBZ file
if self.archive is not None:
self.archive.close()
# remove image directory if the user didn't wish for images
if 'image' not in self.book.outputFormat:
path = os.path.join(unicode(self.directory), unicode(self.book.title))
shutil.rmtree(path)
def onTimer(self):
index = self.value()

View File

@ -25,6 +25,8 @@ class DialogOptions(QtGui.QDialog):
def __init__(self, parent, book):
QtGui.QDialog.__init__(self, parent)
self.book = book
self.formats = {'image+cbz' : 0, 'image' : 1, 'cbz' : 2}
self.reverse_formats = dict((v,k) for k, v in self.formats.iteritems())
ui = uic.loadUi(os.path.join(resources.get_ui_path(), 'options.ui'), self)
self.connect(self, QtCore.SIGNAL('accepted()'), self.onAccept)
self.moveOptionsToDialog()
@ -37,8 +39,7 @@ class DialogOptions(QtGui.QDialog):
def moveOptionsToDialog(self):
self.lineEditTitle.setText(self.book.title or 'Untitled')
self.comboBoxDevice.setCurrentIndex(max(self.comboBoxDevice.findText(self.book.device), 0))
formats = {'image+cbz' : 0, 'image' : 1, 'cbz' : 2}
self.comboBoxFormat.setCurrentIndex(formats.get(self.book.outputFormat, formats['image+cbz']))
self.comboBoxFormat.setCurrentIndex(self.formats.get(self.book.outputFormat, self.formats['image+cbz']))
self.checkboxOverwrite.setChecked(self.book.overwrite)
self.checkboxOrient.setChecked(self.book.imageFlags & ImageFlags.Orient)
self.checkboxResize.setChecked(self.book.imageFlags & ImageFlags.Resize)
@ -49,6 +50,7 @@ class DialogOptions(QtGui.QDialog):
def moveDialogToOptions(self):
title = self.lineEditTitle.text()
device = self.comboBoxDevice.itemText(self.comboBoxDevice.currentIndex())
outputFormat = self.reverse_formats[self.comboBoxFormat.currentIndex()]
overwrite = self.checkboxOverwrite.isChecked()
imageFlags = 0
@ -65,7 +67,8 @@ class DialogOptions(QtGui.QDialog):
self.book.title != title or
self.book.device != device or
self.book.overwrite != overwrite or
self.book.imageFlags != imageFlags
self.book.imageFlags != imageFlags or
self.book.outputFormat != outputFormat
)
if modified:
@ -74,3 +77,4 @@ class DialogOptions(QtGui.QDialog):
self.book.device = device
self.book.overwrite = overwrite
self.book.imageFlags = imageFlags
self.book.outputFormat = outputFormat