mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 18:56:28 +00:00
Added simple tray icon (close #69)
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::StrongFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Kindle Comic Converter</string>
|
<string>Kindle Comic Converter</string>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::StrongFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Kindle Comic Converter</string>
|
<string>Kindle Comic Converter</string>
|
||||||
|
|||||||
2
KCC.ui
2
KCC.ui
@@ -28,7 +28,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::StrongFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Kindle Comic Converter</string>
|
<string>Kindle Comic Converter</string>
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ class Icons:
|
|||||||
self.error = QtGui.QIcon()
|
self.error = QtGui.QIcon()
|
||||||
self.error.addPixmap(QtGui.QPixmap(":/Status/icons/error.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
self.error.addPixmap(QtGui.QPixmap(":/Status/icons/error.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
|
||||||
|
self.programIcon = QtGui.QIcon()
|
||||||
|
self.programIcon.addPixmap(QtGui.QPixmap(":/Icon/icons/comic2ebook.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
|
||||||
|
|
||||||
class HTMLStripper(HTMLParser):
|
class HTMLStripper(HTMLParser):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -325,6 +328,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
GUIMain.needClean = True
|
GUIMain.needClean = True
|
||||||
self.emit(QtCore.SIGNAL("hideProgressBar"))
|
self.emit(QtCore.SIGNAL("hideProgressBar"))
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), '<b>Conversion interrupted.</b>', 'error')
|
self.emit(QtCore.SIGNAL("addMessage"), '<b>Conversion interrupted.</b>', 'error')
|
||||||
|
self.emit(QtCore.SIGNAL("addTrayMessage"), 'Conversion interrupted.', 'Critical')
|
||||||
self.emit(QtCore.SIGNAL("modeConvert"), True)
|
self.emit(QtCore.SIGNAL("modeConvert"), True)
|
||||||
|
|
||||||
def addResult(self, output):
|
def addResult(self, output):
|
||||||
@@ -404,6 +408,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
self.errors = True
|
self.errors = True
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), str(warn), 'warning')
|
self.emit(QtCore.SIGNAL("addMessage"), str(warn), 'warning')
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), 'Failed to create output file!', 'warning')
|
self.emit(QtCore.SIGNAL("addMessage"), 'Failed to create output file!', 'warning')
|
||||||
|
self.emit(QtCore.SIGNAL("addTrayMessage"), 'Failed to create output file!', 'Critical')
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
GUIMain.progress.content = ''
|
GUIMain.progress.content = ''
|
||||||
self.errors = True
|
self.errors = True
|
||||||
@@ -411,6 +416,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
self.emit(QtCore.SIGNAL("showDialog"), "Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
|
self.emit(QtCore.SIGNAL("showDialog"), "Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
|
||||||
% (jobargv[-1], str(err), traceback.format_tb(traceback_)))
|
% (jobargv[-1], str(err), traceback.format_tb(traceback_)))
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), 'Failed to create EPUB!', 'error')
|
self.emit(QtCore.SIGNAL("addMessage"), 'Failed to create EPUB!', 'error')
|
||||||
|
self.emit(QtCore.SIGNAL("addTrayMessage"), 'Failed to create EPUB!', 'Critical')
|
||||||
if not self.conversionAlive:
|
if not self.conversionAlive:
|
||||||
for item in outputPath:
|
for item in outputPath:
|
||||||
if os.path.exists(item):
|
if os.path.exists(item):
|
||||||
@@ -488,6 +494,8 @@ class WorkerThread(QtCore.QThread):
|
|||||||
if os.path.exists(mobiPath + '_toclean'):
|
if os.path.exists(mobiPath + '_toclean'):
|
||||||
os.remove(mobiPath + '_toclean')
|
os.remove(mobiPath + '_toclean')
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), 'KindleUnpack failed to clean MOBI file!', 'error')
|
self.emit(QtCore.SIGNAL("addMessage"), 'KindleUnpack failed to clean MOBI file!', 'error')
|
||||||
|
self.emit(QtCore.SIGNAL("addTrayMessage"), 'KindleUnpack failed to clean MOBI file!',
|
||||||
|
'Critical')
|
||||||
else:
|
else:
|
||||||
GUIMain.progress.content = ''
|
GUIMain.progress.content = ''
|
||||||
epubSize = (os.path.getsize(self.kindlegenErrorCode[2]))/1024/1024
|
epubSize = (os.path.getsize(self.kindlegenErrorCode[2]))/1024/1024
|
||||||
@@ -497,6 +505,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
if os.path.exists(item.replace('.epub', '.mobi')):
|
if os.path.exists(item.replace('.epub', '.mobi')):
|
||||||
os.remove(item.replace('.epub', '.mobi'))
|
os.remove(item.replace('.epub', '.mobi'))
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), 'KindleGen failed to create MOBI!', 'error')
|
self.emit(QtCore.SIGNAL("addMessage"), 'KindleGen failed to create MOBI!', 'error')
|
||||||
|
self.emit(QtCore.SIGNAL("addTrayMessage"), 'KindleGen failed to create MOBI!', 'Critical')
|
||||||
if self.kindlegenErrorCode[0] == 1 and self.kindlegenErrorCode[1] != '':
|
if self.kindlegenErrorCode[0] == 1 and self.kindlegenErrorCode[1] != '':
|
||||||
self.emit(QtCore.SIGNAL("showDialog"), "KindleGen error:\n\n" +
|
self.emit(QtCore.SIGNAL("showDialog"), "KindleGen error:\n\n" +
|
||||||
self.self.kindlegenErrorCode[1])
|
self.self.kindlegenErrorCode[1])
|
||||||
@@ -513,9 +522,32 @@ class WorkerThread(QtCore.QThread):
|
|||||||
self.emit(QtCore.SIGNAL("hideProgressBar"))
|
self.emit(QtCore.SIGNAL("hideProgressBar"))
|
||||||
GUIMain.needClean = True
|
GUIMain.needClean = True
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), '<b>All jobs completed.</b>', 'info')
|
self.emit(QtCore.SIGNAL("addMessage"), '<b>All jobs completed.</b>', 'info')
|
||||||
|
self.emit(QtCore.SIGNAL("addTrayMessage"), 'All jobs completed.', 'Information')
|
||||||
self.emit(QtCore.SIGNAL("modeConvert"), True)
|
self.emit(QtCore.SIGNAL("modeConvert"), True)
|
||||||
|
|
||||||
|
|
||||||
|
class SystemTrayIcon(QtGui.QSystemTrayIcon):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
QtGui.QSystemTrayIcon.__init__(self, parent)
|
||||||
|
self.setIcon(GUIMain.icons.programIcon)
|
||||||
|
self.activated.connect(self.catchClicks)
|
||||||
|
|
||||||
|
def catchClicks(self):
|
||||||
|
MainWindow.raise_()
|
||||||
|
MainWindow.activateWindow()
|
||||||
|
|
||||||
|
def addTrayMessage(self, message, icon):
|
||||||
|
icon = eval('QtGui.QSystemTrayIcon.' + icon)
|
||||||
|
if self.supportsMessages() and not MainWindow.isActiveWindow():
|
||||||
|
self.showMessage('Kindle Comic Converter', message, icon)
|
||||||
|
|
||||||
|
def focusChange(self, _):
|
||||||
|
if self.isSystemTrayAvailable() and not MainWindow.isActiveWindow():
|
||||||
|
self.show()
|
||||||
|
else:
|
||||||
|
self.hide()
|
||||||
|
|
||||||
|
|
||||||
class Ui_KCC(object):
|
class Ui_KCC(object):
|
||||||
def selectDir(self):
|
def selectDir(self):
|
||||||
if self.needClean:
|
if self.needClean:
|
||||||
@@ -542,6 +574,7 @@ class Ui_KCC(object):
|
|||||||
dname = dname.replace('/', '\\')
|
dname = dname.replace('/', '\\')
|
||||||
self.lastPath = os.path.abspath(os.path.join(unicode(dname), os.pardir))
|
self.lastPath = os.path.abspath(os.path.join(unicode(dname), os.pardir))
|
||||||
GUI.JobList.addItem(dname)
|
GUI.JobList.addItem(dname)
|
||||||
|
MainWindow.setFocus()
|
||||||
|
|
||||||
def selectFile(self):
|
def selectFile(self):
|
||||||
if self.needClean:
|
if self.needClean:
|
||||||
@@ -893,6 +926,7 @@ class Ui_KCC(object):
|
|||||||
purgeSettingsVersions = ['']
|
purgeSettingsVersions = ['']
|
||||||
self.icons = Icons()
|
self.icons = Icons()
|
||||||
self.webContent = WebContent()
|
self.webContent = WebContent()
|
||||||
|
self.tray = SystemTrayIcon()
|
||||||
self.settings = QtCore.QSettings('KindleComicConverter', 'KindleComicConverter')
|
self.settings = QtCore.QSettings('KindleComicConverter', 'KindleComicConverter')
|
||||||
self.settingsVersion = self.settings.value('settingsVersion', '', type=str)
|
self.settingsVersion = self.settings.value('settingsVersion', '', type=str)
|
||||||
if self.settingsVersion in purgeSettingsVersions:
|
if self.settingsVersion in purgeSettingsVersions:
|
||||||
@@ -962,6 +996,8 @@ class Ui_KCC(object):
|
|||||||
self.addMessage('Cannot find <a href="http://www.7-zip.org/download.html">7za</a>!'
|
self.addMessage('Cannot find <a href="http://www.7-zip.org/download.html">7za</a>!'
|
||||||
' Processing of CB7/7Z files will be disabled.', 'warning')
|
' Processing of CB7/7Z files will be disabled.', 'warning')
|
||||||
|
|
||||||
|
KCC.focusInEvent = self.tray.focusChange
|
||||||
|
KCC.focusOutEvent = self.tray.focusChange
|
||||||
APP.connect(APP, QtCore.SIGNAL('messageFromOtherInstance'), self.handleMessage)
|
APP.connect(APP, QtCore.SIGNAL('messageFromOtherInstance'), self.handleMessage)
|
||||||
GUI.BasicModeButton.clicked.connect(self.modeBasic)
|
GUI.BasicModeButton.clicked.connect(self.modeBasic)
|
||||||
GUI.AdvModeButton.clicked.connect(self.modeAdvanced)
|
GUI.AdvModeButton.clicked.connect(self.modeAdvanced)
|
||||||
@@ -978,6 +1014,7 @@ class Ui_KCC(object):
|
|||||||
KCC.connect(self.worker, QtCore.SIGNAL("progressBarTick"), self.updateProgressbar)
|
KCC.connect(self.worker, QtCore.SIGNAL("progressBarTick"), self.updateProgressbar)
|
||||||
KCC.connect(self.worker, QtCore.SIGNAL("modeConvert"), self.modeConvert)
|
KCC.connect(self.worker, QtCore.SIGNAL("modeConvert"), self.modeConvert)
|
||||||
KCC.connect(self.worker, QtCore.SIGNAL("addMessage"), self.addMessage)
|
KCC.connect(self.worker, QtCore.SIGNAL("addMessage"), self.addMessage)
|
||||||
|
KCC.connect(self.worker, QtCore.SIGNAL("addTrayMessage"), self.tray.addTrayMessage)
|
||||||
KCC.connect(self.worker, QtCore.SIGNAL("showDialog"), self.showDialog)
|
KCC.connect(self.worker, QtCore.SIGNAL("showDialog"), self.showDialog)
|
||||||
KCC.connect(self.worker, QtCore.SIGNAL("hideProgressBar"), self.hideProgressBar)
|
KCC.connect(self.worker, QtCore.SIGNAL("hideProgressBar"), self.hideProgressBar)
|
||||||
KCC.connect(self.versionCheck, QtCore.SIGNAL("addMessage"), self.addMessage)
|
KCC.connect(self.versionCheck, QtCore.SIGNAL("addMessage"), self.addMessage)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'KCC.ui'
|
# Form implementation generated from reading ui file 'KCC.ui'
|
||||||
#
|
#
|
||||||
# Created: Sat Oct 12 11:28:00 2013
|
# Created: Tue Nov 12 11:51:07 2013
|
||||||
# by: PyQt4 UI code generator 4.10.3
|
# by: PyQt4 UI code generator 4.10.3
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
@@ -32,7 +32,7 @@ class Ui_KCC(object):
|
|||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setPointSize(9)
|
font.setPointSize(9)
|
||||||
KCC.setFont(font)
|
KCC.setFont(font)
|
||||||
KCC.setFocusPolicy(QtCore.Qt.NoFocus)
|
KCC.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||||
icon = QtGui.QIcon()
|
icon = QtGui.QIcon()
|
||||||
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Icon/icons/comic2ebook.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Icon/icons/comic2ebook.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
KCC.setWindowIcon(icon)
|
KCC.setWindowIcon(icon)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'KCC-Linux.ui'
|
# Form implementation generated from reading ui file 'KCC-Linux.ui'
|
||||||
#
|
#
|
||||||
# Created: Sat Oct 12 11:28:11 2013
|
# Created: Tue Nov 12 11:51:18 2013
|
||||||
# by: PyQt4 UI code generator 4.10.3
|
# by: PyQt4 UI code generator 4.10.3
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
@@ -32,7 +32,7 @@ class Ui_KCC(object):
|
|||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setPointSize(9)
|
font.setPointSize(9)
|
||||||
KCC.setFont(font)
|
KCC.setFont(font)
|
||||||
KCC.setFocusPolicy(QtCore.Qt.NoFocus)
|
KCC.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||||
icon = QtGui.QIcon()
|
icon = QtGui.QIcon()
|
||||||
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Icon/icons/comic2ebook.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Icon/icons/comic2ebook.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
KCC.setWindowIcon(icon)
|
KCC.setWindowIcon(icon)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'KCC-OSX.ui'
|
# Form implementation generated from reading ui file 'KCC-OSX.ui'
|
||||||
#
|
#
|
||||||
# Created: Sat Oct 12 11:28:19 2013
|
# Created: Tue Nov 12 11:51:32 2013
|
||||||
# by: PyQt4 UI code generator 4.10.3
|
# by: PyQt4 UI code generator 4.10.3
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
@@ -32,7 +32,7 @@ class Ui_KCC(object):
|
|||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
font.setPointSize(9)
|
font.setPointSize(9)
|
||||||
KCC.setFont(font)
|
KCC.setFont(font)
|
||||||
KCC.setFocusPolicy(QtCore.Qt.NoFocus)
|
KCC.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||||
icon = QtGui.QIcon()
|
icon = QtGui.QIcon()
|
||||||
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Icon/icons/comic2ebook.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/Icon/icons/comic2ebook.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
KCC.setWindowIcon(icon)
|
KCC.setWindowIcon(icon)
|
||||||
|
|||||||
Reference in New Issue
Block a user