Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #31 from rupor-github/epub-gui
Browse files Browse the repository at this point in the history
Add epub processing for GUI version
  • Loading branch information
dnkorpushov authored Nov 23, 2017
2 parents 4510238 + 99935c5 commit 78f207e
Show file tree
Hide file tree
Showing 3 changed files with 351 additions and 8 deletions.
35 changes: 28 additions & 7 deletions fb2mobi-gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from ui.gui_config import GuiConfig
import ui.images_rc
import ui.ui_version
from ui.fb2meta import Fb2Meta
from ui.ebookmeta import EbookMeta
from ui.fontdb import FontDb

from modules.config import ConverterConfig
Expand Down Expand Up @@ -816,7 +816,7 @@ def saveBookInfo(self):
QApplication.setOverrideCursor(Qt.BusyCursor)

item = selected_items[0]
meta = Fb2Meta(item.text(2))
meta = EbookMeta(item.text(2))
meta.get()

if self.book_cover:
Expand Down Expand Up @@ -851,7 +851,7 @@ def saveBookInfo(self):
QApplication.setOverrideCursor(Qt.BusyCursor)

for item in selected_items:
meta = Fb2Meta(item.text(2))
meta = EbookMeta(item.text(2))
meta.get()
(series, series_number) = meta.get_first_series()
authors = meta.get_autors()
Expand Down Expand Up @@ -895,7 +895,7 @@ def changeBook(self):
self.editTitle.setEnabled(True)
self.editSeriesNumber.setEnabled(True)

meta = Fb2Meta(selected_items[0].text(2))
meta = EbookMeta(selected_items[0].text(2))
meta.get()

self.editAuthor.setText(meta.get_autors())
Expand All @@ -909,14 +909,35 @@ def changeBook(self):
self.book_cover = QPixmap()
self.book_cover.loadFromData(meta.coverdata)
self.displayCoverThumbmail(self.book_cover)

if meta.book_type == 'fb2':
self.editAuthor.setEnabled(True)
self.editTitle.setEnabled(True)
self.editSeries.setEnabled(True)
self.editSeriesNumber.setEnabled(True)
self.editBookLanguage.setEnabled(True)
self.buttonSaveBookInfo.setEnabled(True)
else:
self.editAuthor.setEnabled(False)
self.editTitle.setEnabled(False)
self.editSeries.setEnabled(False)
self.editSeriesNumber.setEnabled(False)
self.editBookLanguage.setEnabled(False)
self.buttonSaveBookInfo.setEnabled(False)

elif len(selected_items) > 1:
self.editAuthor.setEnabled(True)
self.editTitle.setEnabled(False)
self.editSeriesNumber.setEnabled(False)
self.editSeries.setEnabled(True)
self.editSeriesNumber.setEnabled(True)
self.editBookLanguage.setEnabled(True)
self.buttonSaveBookInfo.setEnabled(True)



def addFile(self, file):
if not file.lower().endswith((".fb2", ".fb2.zip", ".zip")):
if not file.lower().endswith(('.fb2', '.fb2.zip', '.zip', '.epub')):
return

found = False
Expand All @@ -929,7 +950,7 @@ def addFile(self, file):
break

if not found:
meta = Fb2Meta(file)
meta = EbookMeta(file)
meta.get()

item = QTreeWidgetItem(0)
Expand Down Expand Up @@ -963,7 +984,7 @@ def addFilesAction(self):

fileDialog = QFileDialog(self, _translate('fb2mobi-gui', 'Select files'), self.gui_config.lastUsedPath)
fileDialog.setFileMode(QFileDialog.ExistingFiles)
fileDialog.setNameFilters([_translate('fb2mobi-gui', 'Fb2 files (*.fb2 *.fb2.zip *.zip)'),
fileDialog.setNameFilters([_translate('fb2mobi-gui', 'Ebook files (*.fb2 *.fb2.zip *.zip *.epub)'),
_translate('fb2mobi-gui', 'All files (*.*)')])

if fileDialog.exec_():
Expand Down
Loading

0 comments on commit 78f207e

Please sign in to comment.