1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-12 17:26:23 +00:00

Alpha version of QT GUI

This commit is contained in:
Paweł Jastrzębski
2013-06-10 17:18:30 +02:00
parent 880f220355
commit 1c7ff5c597
21 changed files with 10134 additions and 18 deletions

3
.gitignore vendored
View File

@@ -3,5 +3,6 @@
*.cbr
.idea
build
awkcc
dist
kindlegen*
.DS_Store

23
KCC.qrc Normal file
View File

@@ -0,0 +1,23 @@
<RCC>
<qresource prefix="Icon">
<file>icons/comic2ebook.ico</file>
</qresource>
<qresource prefix="Devices">
<file>icons/Kindle.ico</file>
</qresource>
<qresource prefix="Formats">
<file>icons/CBZ.png</file>
<file>icons/EPUB.png</file>
<file>icons/MOBI.png</file>
</qresource>
<qresource prefix="Status">
<file>icons/error.ico</file>
<file>icons/info.ico</file>
<file>icons/warning.ico</file>
</qresource>
<qresource prefix="Other">
<file>icons/convert.ico</file>
<file>icons/minus.ico</file>
<file>icons/plus.ico</file>
</qresource>
</RCC>

547
KCC.ui Normal file
View File

@@ -0,0 +1,547 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KCC</class>
<widget class="QMainWindow" name="KCC">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>345</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>420</width>
<height>345</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>420</width>
<height>345</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="windowTitle">
<string>Kindle Comic Converter</string>
</property>
<property name="windowIcon">
<iconset resource="KCC.qrc">
<normaloff>:/Icon/icons/comic2ebook.ico</normaloff>:/Icon/icons/comic2ebook.ico</iconset>
</property>
<property name="locale">
<locale language="C" country="AnyCountry"/>
</property>
<widget class="QWidget" name="Form">
<widget class="QFrame" name="OptionsAdvanced">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>254</y>
<width>421</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="ProcessingBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Disable image optimizations.</string>
</property>
<property name="text">
<string>No optimisation</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="UpscaleBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image upscaling.&lt;/p&gt;&lt;p&gt;Aspect ratio will be preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Upscale images</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="StretchBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable image stretching.&lt;/p&gt;&lt;p&gt;Aspect ratio will be not preserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Stretch images</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="NoDitheringBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Create PNG files instead JPEG.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Only for non-Kindle devices!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>PNG output</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="BorderBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Fill space around images with black color.</string>
</property>
<property name="text">
<string>Black borders</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="NoRotateBox">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disable splitting and rotation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>No split/rotate</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QComboBox" name="DeviceBox">
<property name="geometry">
<rect>
<x>10</x>
<y>200</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Target device.</string>
</property>
</widget>
<widget class="QComboBox" name="FormatBox">
<property name="geometry">
<rect>
<x>260</x>
<y>200</y>
<width>151</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Output format.</string>
</property>
</widget>
<widget class="QPushButton" name="ConvertButton">
<property name="geometry">
<rect>
<x>160</x>
<y>200</y>
<width>91</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Convert</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/convert.ico</normaloff>:/Other/icons/convert.ico</iconset>
</property>
</widget>
<widget class="QPushButton" name="DirectoryButton">
<property name="geometry">
<rect>
<x>10</x>
<y>160</y>
<width>141</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Add directory</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/plus.ico</normaloff>:/Other/icons/plus.ico</iconset>
</property>
</widget>
<widget class="QPushButton" name="FileButton">
<property name="geometry">
<rect>
<x>260</x>
<y>160</y>
<width>151</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Add file</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/plus.ico</normaloff>:/Other/icons/plus.ico</iconset>
</property>
</widget>
<widget class="QPushButton" name="ClearButton">
<property name="geometry">
<rect>
<x>160</x>
<y>160</y>
<width>91</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Clear list</string>
</property>
<property name="icon">
<iconset resource="KCC.qrc">
<normaloff>:/Other/icons/minus.ico</normaloff>:/Other/icons/minus.ico</iconset>
</property>
</widget>
<widget class="QFrame" name="OptionsBasic">
<property name="geometry">
<rect>
<x>10</x>
<y>230</y>
<width>421</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<widget class="QCheckBox" name="MangaBox">
<property name="geometry">
<rect>
<x>9</x>
<y>10</y>
<width>130</width>
<height>18</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Enable right-to-left reading.</string>
</property>
<property name="text">
<string>Manga mode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="HQPVBox">
<property name="geometry">
<rect>
<x>282</x>
<y>10</y>
<width>104</width>
<height>18</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable high quality zoom.&lt;/p&gt;&lt;p&gt;Enabling it will &lt;span style=&quot; font-weight:600;&quot;&gt;highly&lt;/span&gt; increase size of output file and &lt;span style=&quot; font-weight:600;&quot;&gt;slightly&lt;/span&gt; reduce sharpness of not zoomed images.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>HQ Panel View</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="RotateBox">
<property name="geometry">
<rect>
<x>145</x>
<y>10</y>
<width>111</width>
<height>18</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Disable page spliting.&lt;/p&gt;&lt;p&gt;They will be rotated instead.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Horizontal mode</string>
</property>
</widget>
<zorder>RotateBox</zorder>
<zorder>MangaBox</zorder>
<zorder>HQPVBox</zorder>
</widget>
<widget class="QListWidget" name="JobList">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>401</width>
<height>101</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
</widget>
<widget class="QPushButton" name="BasicModeButton">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>141</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Basic</string>
</property>
</widget>
<widget class="QPushButton" name="AdvModeButton">
<property name="geometry">
<rect>
<x>160</x>
<y>10</y>
<width>91</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Advanced</string>
</property>
</widget>
<widget class="QPushButton" name="ExpertModeButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>260</x>
<y>10</y>
<width>151</width>
<height>32</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Expert</string>
</property>
</widget>
<widget class="QFrame" name="OptionsAdvancedGamma">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>305</y>
<width>401</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<widget class="QLabel" name="GammaLabel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>161</width>
<height>41</height>
</rect>
</property>
<property name="toolTip">
<string>When converting color images setting this option to 1.0 MIGHT improve readability.</string>
</property>
<property name="text">
<string>Gamma correction: Auto</string>
</property>
</widget>
<widget class="QSlider" name="GammaSlider">
<property name="geometry">
<rect>
<x>140</x>
<y>10</y>
<width>261</width>
<height>22</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When converting color images setting this option to 1.0 &lt;span style=&quot; font-weight:600;&quot;&gt;might&lt;/span&gt; improve readability.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
</widget>
<action name="ActionBasic">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="text">
<string>Basic</string>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
</action>
<action name="ActionAdvanced">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Advanced</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>DirectoryButton</tabstop>
<tabstop>FileButton</tabstop>
<tabstop>ConvertButton</tabstop>
<tabstop>ClearButton</tabstop>
</tabstops>
<resources>
<include location="KCC.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 KiB

BIN
icons/CBZ.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
icons/EPUB.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
icons/Kindle.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
icons/MOBI.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
icons/comic2ebook.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/convert.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/error.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/info.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/minus.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/plus.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
icons/warning.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

28
kcc.py
View File

@@ -21,21 +21,19 @@ __license__ = 'ISC'
__copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
__docformat__ = 'restructuredtext en'
from Tkinter import *
from kcc import gui
from sys import platform
from multiprocessing import freeze_support
import sys
import os
from PyQt4 import QtGui
from kcc import KCC_gui, KCC_ui
freeze_support()
root = Tk()
root.resizable(width=False, height=False)
root.config(padx=5, pady=5, takefocus=True)
root.title("Kindle Comic Converter v" + __version__)
#root.wm_attributes("-topmost", 1)
if platform == 'darwin':
if sys.platform == 'darwin':
os.environ['PATH'] = '/usr/local/bin:' + os.environ['PATH']
elif platform == 'win32':
root.iconbitmap(default='comic2ebook.ico')
gui.MainWindow(master=root)
root.mainloop()
app = QtGui.QApplication(sys.argv)
KCC = QtGui.QMainWindow()
ui = KCC_ui.Ui_KCC()
ui.setupUi(KCC)
gui = KCC_gui.Ui_KCC(ui, KCC)
KCC.setWindowTitle("Kindle Comic Converter " + __version__)
KCC.show()
sys.exit(app.exec_())

283
kcc/KCC_gui.py Normal file
View File

@@ -0,0 +1,283 @@
#!/usr/bin/env python
#
# Copyright (c) 2013 Ciro Mattia Gonano <ciromattia@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for
# any purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all
# copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
__version__ = '3.0'
__license__ = 'ISC'
__copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
__docformat__ = 'restructuredtext en'
import os
import sys
import shutil
import traceback
import comic2ebook
import kindlestrip
from image import ProfileData
from subprocess import call, STDOUT, PIPE
from PyQt4 import QtGui, QtCore
# noinspection PyBroadException
class Ui_KCC(object):
def selectDir(self):
if self.firstStart:
self.firstStart = False
GUI.JobList.clear()
dname = QtGui.QFileDialog.getExistingDirectory(MainWindow, 'Select directory', '')
GUI.JobList.addItem(dname)
def selectFile(self):
if self.firstStart:
self.firstStart = False
GUI.JobList.clear()
if self.UnRAR:
fname = QtGui.QFileDialog.getOpenFileName(MainWindow, 'Select file', '', '*.cbz *.cbr *.zip *.rar *.pdf')
else:
fname = QtGui.QFileDialog.getOpenFileName(MainWindow, 'Select file', '', '*.cbz *.zip *.pdf')
GUI.JobList.addItem(fname)
def clearJobs(self):
GUI.JobList.clear()
def modeBasic(self):
MainWindow.setMinimumSize(QtCore.QSize(420, 270))
MainWindow.setMaximumSize(QtCore.QSize(420, 270))
MainWindow.resize(420, 270)
GUI.BasicModeButton.setStyleSheet('font-weight:Bold;')
GUI.AdvModeButton.setStyleSheet('font-weight:Normal;')
GUI.ExpertModeButton.setStyleSheet('font-weight:Normal;')
GUI.FormatBox.setCurrentIndex(0)
GUI.FormatBox.setEnabled(False)
GUI.OptionsAdvanced.setEnabled(False)
GUI.OptionsAdvancedGamma.setEnabled(False)
GUI.ProcessingBox.hide()
GUI.UpscaleBox.hide()
GUI.NoRotateBox.hide()
GUI.ProcessingBox.setChecked(False)
GUI.UpscaleBox.setChecked(False)
GUI.NoRotateBox.setChecked(False)
GUI.BorderBox.setChecked(False)
GUI.StretchBox.setChecked(False)
GUI.NoDitheringBox.setChecked(False)
GUI.GammaSlider.setValue(0)
def modeAdvanced(self):
MainWindow.setMinimumSize(QtCore.QSize(420, 345))
MainWindow.setMaximumSize(QtCore.QSize(420, 345))
MainWindow.resize(420, 345)
GUI.BasicModeButton.setStyleSheet('font-weight:Normal;')
GUI.AdvModeButton.setStyleSheet('font-weight:Bold;')
GUI.ExpertModeButton.setStyleSheet('font-weight:Normal;')
GUI.FormatBox.setEnabled(True)
GUI.ProcessingBox.show()
GUI.UpscaleBox.show()
GUI.NoRotateBox.show()
GUI.OptionsAdvancedGamma.setEnabled(True)
GUI.OptionsAdvanced.setEnabled(True)
def modeExpert(self):
#TODO
pass
def modeConvert(self, enable):
GUI.BasicModeButton.setEnabled(enable)
GUI.AdvModeButton.setEnabled(enable)
GUI.ExpertModeButton.setEnabled(enable)
GUI.DirectoryButton.setEnabled(enable)
GUI.ClearButton.setEnabled(enable)
GUI.FileButton.setEnabled(enable)
GUI.DeviceBox.setEnabled(enable)
GUI.ConvertButton.setEnabled(enable)
GUI.FormatBox.setEnabled(enable)
GUI.OptionsBasic.setEnabled(enable)
GUI.OptionsAdvanced.setEnabled(enable)
GUI.OptionsAdvancedGamma.setEnabled(enable)
def changeGamma(self, value):
if value <= 9:
value = 'Auto'
else:
value = float(value)
value = '%.2f' % (value/100)
self.GammaValue = value
GUI.GammaLabel.setText('Gamma correction: ' + str(value))
def addMessage(self, message, icon=None, replace=False):
if icon:
item = QtGui.QListWidgetItem(icon, message)
else:
item = QtGui.QListWidgetItem(message)
if replace:
GUI.JobList.takeItem(GUI.JobList.count()-1)
GUI.JobList.addItem(item)
MainWindow.repaint()
def convertStart(self):
if self.firstStart:
self.firstStart = False
GUI.JobList.clear()
if GUI.JobList.count() == 0:
self.addMessage('No files selected! Please choose files to convert.', self.errorIcon)
self.firstStart = True
return
self.modeConvert(False)
profile = ProfileData.ProfileLabels[str(GUI.DeviceBox.currentText())]
argv = ["--profile=" + profile]
currentJobs = []
if GUI.MangaBox.isChecked():
argv.append("--manga-style")
if GUI.RotateBox.isChecked():
argv.append("--rotate")
if not GUI.HQPVBox.isChecked():
argv.append("--nopanelviewhq")
if GUI.ProcessingBox.isChecked():
argv.append("--noprocessing")
if GUI.UpscaleBox.isChecked() and not GUI.StretchBox.isChecked():
argv.append("--upscale")
if GUI.NoRotateBox.isChecked():
argv.append("--nosplitrotate")
if GUI.BorderBox.isChecked():
argv.append("--blackborders")
if GUI.StretchBox.isChecked():
argv.append("--stretch")
if GUI.NoDitheringBox.isChecked():
argv.append("--nodithering")
if self.GammaValue > 0.09:
argv.append("--gamma=" + self.GammaValue)
if str(GUI.FormatBox.currentText()) == 'CBZ':
argv.append("--cbz-output")
for i in range(GUI.JobList.count()):
#TODO UTF8!
currentJobs.append(str(GUI.JobList.item(i).text()))
GUI.JobList.clear()
for job in currentJobs:
errors = False
self.addMessage('Source: ' + job, self.infoIcon)
if str(GUI.FormatBox.currentText()) == 'CBZ':
self.addMessage('Creating CBZ file...', self.infoIcon)
else:
self.addMessage('Creating EPUB file...', self.infoIcon)
jobargv = list(argv)
jobargv.append(job)
MainWindow.repaint()
try:
outputPath = comic2ebook.main(jobargv)
except Exception as err:
errors = True
type_, value_, traceback_ = sys.exc_info()
tkMessageBox.showerror('KCC Error', "Error on file %s:\n%s\nTraceback:\n%s" % (jobargv[-1], str(err), traceback.format_tb(traceback_)))
self.addMessage('KCC failed to create EPUB!', self.errorIcon)
continue
MainWindow.repaint()
if not errors:
if str(GUI.FormatBox.currentText()) == 'CBZ':
self.addMessage('Creating CBZ file... Done!', self.infoIcon, True)
else:
self.addMessage('Creating EPUB file... Done!', self.infoIcon, True)
if str(GUI.FormatBox.currentText()) == 'MOBI':
if not os.path.getsize(outputPath) > 314572800:
self.addMessage('Creating MOBI file...', self.infoIcon)
MainWindow.repaint()
retcode = call('kindlegen "' + outputPath + '"', stdout=PIPE, stderr=STDOUT, shell=True)
MainWindow.repaint()
if retcode == 0:
self.addMessage('Creating MOBI file... Done!', self.infoIcon, True)
self.addMessage('Removing SRCS header...', self.infoIcon)
mobiPath = outputPath.replace('.epub', '.mobi')
shutil.move(mobiPath, mobiPath + '_tostrip')
MainWindow.repaint()
try:
kindlestrip.main((mobiPath + '_tostrip', mobiPath))
except Exception:
errors = True
continue
MainWindow.repaint()
if not errors:
os.remove(mobiPath + '_tostrip')
self.addMessage('Removing SRCS header... Done!', self.infoIcon, True)
else:
shutil.move(mobiPath + '_tostrip', mobiPath)
self.addMessage('KindleStrip failed to remove SRCS header!', self.warningIcon)
self.addMessage('MOBI file will work correctly but it will be highly oversized.',
self.warningIcon)
else:
os.remove(outputPath)
self.addMessage('KindleGen failed to create MOBI!', self.errorIcon)
self.addMessage('Try converting smaller batch.', self.errorIcon)
else:
os.remove(outputPath)
self.addMessage('Created EPUB file is too big for KindleGen!', self.errorIcon)
self.addMessage('Try converting smaller batch.', self.errorIcon)
self.firstStart = True
self.addMessage('All jobs completed.', self.warningIcon)
self.modeConvert(True)
def __init__(self, ui, KCC):
global GUI, MainWindow
GUI = ui
MainWindow = KCC
profiles = sorted(ProfileData.ProfileLabels.iterkeys())
kindleIcon = QtGui.QIcon()
kindleIcon.addPixmap(QtGui.QPixmap(":/Devices/icons/Kindle.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.firstStart = True
self.GammaValue = 0
self.infoIcon = QtGui.QIcon()
self.infoIcon.addPixmap(QtGui.QPixmap(":/Status/icons/info.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.warningIcon = QtGui.QIcon()
self.warningIcon.addPixmap(QtGui.QPixmap(":/Status/icons/warning.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.errorIcon = QtGui.QIcon()
self.errorIcon.addPixmap(QtGui.QPixmap(":/Status/icons/error.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.addMessage('Welcome!', self.infoIcon)
self.addMessage('Most of options have additional informations in their tooltips.', self.infoIcon)
if call('kindlegen', stdout=PIPE, stderr=STDOUT, shell=True) == 0:
self.KindleGen = True
formats = ['MOBI', 'EPUB', 'CBZ']
else:
self.KindleGen = False
formats = ['EPUB', 'CBZ']
self.addMessage('Failed to detect KindleGen! Creating MOBI files is disabled.', self.warningIcon)
if call('unrar', stdout=PIPE, stderr=STDOUT, shell=True) == 0:
self.UnRAR = True
else:
self.UnRAR = False
self.addMessage('Failed to detect UnRAR! Processing of CBR/RAR files is disabled.', self.warningIcon)
GUI.BasicModeButton.clicked.connect(self.modeBasic)
GUI.AdvModeButton.clicked.connect(self.modeAdvanced)
GUI.ExpertModeButton.clicked.connect(self.modeExpert)
GUI.DirectoryButton.clicked.connect(self.selectDir)
GUI.ClearButton.clicked.connect(self.clearJobs)
GUI.FileButton.clicked.connect(self.selectFile)
GUI.ConvertButton.clicked.connect(self.convertStart)
GUI.GammaSlider.valueChanged.connect(self.changeGamma)
for profile in profiles:
GUI.DeviceBox.addItem(kindleIcon, profile)
GUI.DeviceBox.setCurrentIndex(10)
for f in formats:
formatIcon = QtGui.QIcon()
formatIcon.addPixmap(QtGui.QPixmap(":/Formats/icons/" + f + ".png"), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
GUI.FormatBox.addItem(formatIcon, f)
GUI.FormatBox.setCurrentIndex(0)
self.modeBasic()

9017
kcc/KCC_rc.py Normal file

File diff suppressed because it is too large Load Diff

247
kcc/KCC_ui.py Normal file
View File

@@ -0,0 +1,247 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'KCC.ui'
#
# Created: Mon Jun 10 14:36:41 2013
# by: PyQt4 UI code generator 4.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_KCC(object):
def setupUi(self, KCC):
KCC.setObjectName(_fromUtf8("KCC"))
KCC.resize(420, 345)
KCC.setMinimumSize(QtCore.QSize(420, 345))
KCC.setMaximumSize(QtCore.QSize(420, 345))
font = QtGui.QFont()
font.setPointSize(9)
KCC.setFont(font)
KCC.setFocusPolicy(QtCore.Qt.NoFocus)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Icon/icons/comic2ebook.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
KCC.setWindowIcon(icon)
KCC.setLocale(QtCore.QLocale(QtCore.QLocale.C, QtCore.QLocale.AnyCountry))
self.Form = QtGui.QWidget(KCC)
self.Form.setObjectName(_fromUtf8("Form"))
self.OptionsAdvanced = QtGui.QFrame(self.Form)
self.OptionsAdvanced.setEnabled(True)
self.OptionsAdvanced.setGeometry(QtCore.QRect(10, 254, 421, 61))
font = QtGui.QFont()
font.setPointSize(9)
self.OptionsAdvanced.setFont(font)
self.OptionsAdvanced.setObjectName(_fromUtf8("OptionsAdvanced"))
self.gridLayout = QtGui.QGridLayout(self.OptionsAdvanced)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.ProcessingBox = QtGui.QCheckBox(self.OptionsAdvanced)
self.ProcessingBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.ProcessingBox.setObjectName(_fromUtf8("ProcessingBox"))
self.gridLayout.addWidget(self.ProcessingBox, 1, 0, 1, 1)
self.UpscaleBox = QtGui.QCheckBox(self.OptionsAdvanced)
self.UpscaleBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.UpscaleBox.setObjectName(_fromUtf8("UpscaleBox"))
self.gridLayout.addWidget(self.UpscaleBox, 1, 1, 1, 1)
self.StretchBox = QtGui.QCheckBox(self.OptionsAdvanced)
self.StretchBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.StretchBox.setObjectName(_fromUtf8("StretchBox"))
self.gridLayout.addWidget(self.StretchBox, 3, 1, 1, 1)
self.NoDitheringBox = QtGui.QCheckBox(self.OptionsAdvanced)
self.NoDitheringBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.NoDitheringBox.setObjectName(_fromUtf8("NoDitheringBox"))
self.gridLayout.addWidget(self.NoDitheringBox, 3, 2, 1, 1)
self.BorderBox = QtGui.QCheckBox(self.OptionsAdvanced)
self.BorderBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.BorderBox.setObjectName(_fromUtf8("BorderBox"))
self.gridLayout.addWidget(self.BorderBox, 3, 0, 1, 1)
self.NoRotateBox = QtGui.QCheckBox(self.OptionsAdvanced)
self.NoRotateBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.NoRotateBox.setObjectName(_fromUtf8("NoRotateBox"))
self.gridLayout.addWidget(self.NoRotateBox, 1, 2, 1, 1)
self.DeviceBox = QtGui.QComboBox(self.Form)
self.DeviceBox.setGeometry(QtCore.QRect(10, 200, 141, 31))
font = QtGui.QFont()
font.setPointSize(8)
self.DeviceBox.setFont(font)
self.DeviceBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.DeviceBox.setObjectName(_fromUtf8("DeviceBox"))
self.FormatBox = QtGui.QComboBox(self.Form)
self.FormatBox.setGeometry(QtCore.QRect(260, 200, 151, 31))
font = QtGui.QFont()
font.setPointSize(8)
self.FormatBox.setFont(font)
self.FormatBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.FormatBox.setObjectName(_fromUtf8("FormatBox"))
self.ConvertButton = QtGui.QPushButton(self.Form)
self.ConvertButton.setGeometry(QtCore.QRect(160, 200, 91, 32))
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.ConvertButton.setFont(font)
self.ConvertButton.setFocusPolicy(QtCore.Qt.NoFocus)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/Other/icons/convert.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.ConvertButton.setIcon(icon1)
self.ConvertButton.setObjectName(_fromUtf8("ConvertButton"))
self.DirectoryButton = QtGui.QPushButton(self.Form)
self.DirectoryButton.setGeometry(QtCore.QRect(10, 160, 141, 32))
font = QtGui.QFont()
font.setPointSize(8)
self.DirectoryButton.setFont(font)
self.DirectoryButton.setFocusPolicy(QtCore.Qt.NoFocus)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/Other/icons/plus.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DirectoryButton.setIcon(icon2)
self.DirectoryButton.setObjectName(_fromUtf8("DirectoryButton"))
self.FileButton = QtGui.QPushButton(self.Form)
self.FileButton.setGeometry(QtCore.QRect(260, 160, 151, 32))
font = QtGui.QFont()
font.setPointSize(8)
self.FileButton.setFont(font)
self.FileButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.FileButton.setIcon(icon2)
self.FileButton.setObjectName(_fromUtf8("FileButton"))
self.ClearButton = QtGui.QPushButton(self.Form)
self.ClearButton.setGeometry(QtCore.QRect(160, 160, 91, 32))
font = QtGui.QFont()
font.setPointSize(8)
self.ClearButton.setFont(font)
self.ClearButton.setFocusPolicy(QtCore.Qt.NoFocus)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/Other/icons/minus.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.ClearButton.setIcon(icon3)
self.ClearButton.setObjectName(_fromUtf8("ClearButton"))
self.OptionsBasic = QtGui.QFrame(self.Form)
self.OptionsBasic.setGeometry(QtCore.QRect(10, 230, 421, 41))
font = QtGui.QFont()
font.setPointSize(9)
self.OptionsBasic.setFont(font)
self.OptionsBasic.setObjectName(_fromUtf8("OptionsBasic"))
self.MangaBox = QtGui.QCheckBox(self.OptionsBasic)
self.MangaBox.setGeometry(QtCore.QRect(9, 10, 130, 18))
self.MangaBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.MangaBox.setChecked(True)
self.MangaBox.setObjectName(_fromUtf8("MangaBox"))
self.HQPVBox = QtGui.QCheckBox(self.OptionsBasic)
self.HQPVBox.setGeometry(QtCore.QRect(282, 10, 104, 18))
self.HQPVBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.HQPVBox.setChecked(True)
self.HQPVBox.setObjectName(_fromUtf8("HQPVBox"))
self.RotateBox = QtGui.QCheckBox(self.OptionsBasic)
self.RotateBox.setGeometry(QtCore.QRect(145, 10, 111, 18))
self.RotateBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.RotateBox.setObjectName(_fromUtf8("RotateBox"))
self.JobList = QtGui.QListWidget(self.Form)
self.JobList.setGeometry(QtCore.QRect(10, 50, 401, 101))
self.JobList.setFocusPolicy(QtCore.Qt.NoFocus)
self.JobList.setProperty("showDropIndicator", False)
self.JobList.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
self.JobList.setObjectName(_fromUtf8("JobList"))
self.BasicModeButton = QtGui.QPushButton(self.Form)
self.BasicModeButton.setGeometry(QtCore.QRect(10, 10, 141, 32))
font = QtGui.QFont()
font.setPointSize(9)
self.BasicModeButton.setFont(font)
self.BasicModeButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.BasicModeButton.setObjectName(_fromUtf8("BasicModeButton"))
self.AdvModeButton = QtGui.QPushButton(self.Form)
self.AdvModeButton.setGeometry(QtCore.QRect(160, 10, 91, 32))
font = QtGui.QFont()
font.setPointSize(9)
self.AdvModeButton.setFont(font)
self.AdvModeButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.AdvModeButton.setObjectName(_fromUtf8("AdvModeButton"))
self.ExpertModeButton = QtGui.QPushButton(self.Form)
self.ExpertModeButton.setEnabled(False)
self.ExpertModeButton.setGeometry(QtCore.QRect(260, 10, 151, 32))
font = QtGui.QFont()
font.setPointSize(9)
self.ExpertModeButton.setFont(font)
self.ExpertModeButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.ExpertModeButton.setObjectName(_fromUtf8("ExpertModeButton"))
self.OptionsAdvancedGamma = QtGui.QFrame(self.Form)
self.OptionsAdvancedGamma.setEnabled(True)
self.OptionsAdvancedGamma.setGeometry(QtCore.QRect(10, 305, 401, 41))
font = QtGui.QFont()
font.setPointSize(9)
self.OptionsAdvancedGamma.setFont(font)
self.OptionsAdvancedGamma.setObjectName(_fromUtf8("OptionsAdvancedGamma"))
self.GammaLabel = QtGui.QLabel(self.OptionsAdvancedGamma)
self.GammaLabel.setGeometry(QtCore.QRect(0, 0, 161, 41))
self.GammaLabel.setObjectName(_fromUtf8("GammaLabel"))
self.GammaSlider = QtGui.QSlider(self.OptionsAdvancedGamma)
self.GammaSlider.setGeometry(QtCore.QRect(140, 10, 261, 22))
self.GammaSlider.setFocusPolicy(QtCore.Qt.NoFocus)
self.GammaSlider.setMaximum(500)
self.GammaSlider.setSingleStep(5)
self.GammaSlider.setOrientation(QtCore.Qt.Horizontal)
self.GammaSlider.setObjectName(_fromUtf8("GammaSlider"))
KCC.setCentralWidget(self.Form)
self.ActionBasic = QtGui.QAction(KCC)
self.ActionBasic.setCheckable(True)
self.ActionBasic.setChecked(False)
font = QtGui.QFont()
font.setPointSize(9)
self.ActionBasic.setFont(font)
self.ActionBasic.setObjectName(_fromUtf8("ActionBasic"))
self.ActionAdvanced = QtGui.QAction(KCC)
self.ActionAdvanced.setCheckable(True)
self.ActionAdvanced.setObjectName(_fromUtf8("ActionAdvanced"))
self.retranslateUi(KCC)
QtCore.QMetaObject.connectSlotsByName(KCC)
KCC.setTabOrder(self.DirectoryButton, self.FileButton)
KCC.setTabOrder(self.FileButton, self.ConvertButton)
KCC.setTabOrder(self.ConvertButton, self.ClearButton)
def retranslateUi(self, KCC):
KCC.setWindowTitle(_translate("KCC", "Kindle Comic Converter", None))
self.ProcessingBox.setToolTip(_translate("KCC", "Disable image optimizations.", None))
self.ProcessingBox.setText(_translate("KCC", "No optimisation", None))
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image upscaling.</p><p>Aspect ratio will be preserved.</p></body></html>", None))
self.UpscaleBox.setText(_translate("KCC", "Upscale images", None))
self.StretchBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable image stretching.</p><p>Aspect ratio will be not preserved.</p></body></html>", None))
self.StretchBox.setText(_translate("KCC", "Stretch images", None))
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p>Create PNG files instead JPEG.</p><p><span style=\" font-weight:600;\">Only for non-Kindle devices!</span></p></body></html>", None))
self.NoDitheringBox.setText(_translate("KCC", "PNG output", None))
self.BorderBox.setToolTip(_translate("KCC", "Fill space around images with black color.", None))
self.BorderBox.setText(_translate("KCC", "Black borders", None))
self.NoRotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable splitting and rotation.</p></body></html>", None))
self.NoRotateBox.setText(_translate("KCC", "No split/rotate", None))
self.DeviceBox.setToolTip(_translate("KCC", "Target device.", None))
self.FormatBox.setToolTip(_translate("KCC", "Output format.", None))
self.ConvertButton.setText(_translate("KCC", "Convert", None))
self.DirectoryButton.setText(_translate("KCC", "Add directory", None))
self.FileButton.setText(_translate("KCC", "Add file", None))
self.ClearButton.setText(_translate("KCC", "Clear list", None))
self.MangaBox.setToolTip(_translate("KCC", "Enable right-to-left reading.", None))
self.MangaBox.setText(_translate("KCC", "Manga mode", None))
self.HQPVBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable high quality zoom.</p><p>Enabling it will <span style=\" font-weight:600;\">highly</span> increase size of output file and <span style=\" font-weight:600;\">slightly</span> reduce sharpness of not zoomed images.</p></body></html>", None))
self.HQPVBox.setText(_translate("KCC", "HQ Panel View", None))
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p>Disable page spliting.</p><p>They will be rotated instead.</p></body></html>", None))
self.RotateBox.setText(_translate("KCC", "Horizontal mode", None))
self.BasicModeButton.setText(_translate("KCC", "Basic", None))
self.AdvModeButton.setText(_translate("KCC", "Advanced", None))
self.ExpertModeButton.setText(_translate("KCC", "Expert", None))
self.GammaLabel.setToolTip(_translate("KCC", "When converting color images setting this option to 1.0 MIGHT improve readability.", None))
self.GammaLabel.setText(_translate("KCC", "Gamma correction: Auto", None))
self.GammaSlider.setToolTip(_translate("KCC", "<html><head/><body><p>When converting color images setting this option to 1.0 <span style=\" font-weight:600;\">might</span> improve readability.</p></body></html>", None))
self.ActionBasic.setText(_translate("KCC", "Basic", None))
self.ActionAdvanced.setText(_translate("KCC", "Advanced", None))
import KCC_rc

View File

@@ -41,7 +41,7 @@ class CBxArchive:
cbzFile = zipfile.ZipFile(self.origFileName)
filelist = []
for f in cbzFile.namelist():
if f.startswith('__MACOSX') or f.endswith('.DS_Store'):
if f.startswith('__MACOSX') or f.endswith('.DS_Store') or f.endswith('thumbs.db'):
pass # skip MacOS special files
elif f.endswith('/'):
try:
@@ -56,7 +56,7 @@ class CBxArchive:
cbrFile = rarfile.RarFile(self.origFileName)
filelist = []
for f in cbrFile.namelist():
if f.startswith('__MACOSX') or f.endswith('.DS_Store'):
if f.startswith('__MACOSX') or f.endswith('.DS_Store') or f.endswith('thumbs.db'):
pass # skip MacOS special files
elif f.endswith('/'):
try: