def onCloseSaveEntry(self): if self.hasActiveEntry: #Save first FsUtils.save_book(self.activeBook) #Clear ui self.setUiInactive()
def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) uic.loadUi(FsUtils.get_resource("/ui/mainwindow.ui"), self) FsUtils.load_settings() self._book: BookEntry = None self._cost: Cost = None self._hasActiveEntry = False self.setupSlots() self.setUiInactive()
def showBooks(self, item): if item.text() == "New Batch": self.batch_id: int = FsUtils.get_new_batch_id() else: self.batch_id: int = item.text() while self.booksList.count() > 0: self.booksList.takeItem(0) books = [ n.replace(".json", "") for n in FsUtils.get_books_in_batch(self.batch_id) ] self.booksList.addItems(books)
def __init__(self, parent, active_book): super().__init__(parent) uic.loadUi(FsUtils.get_resource("/ui/bookmove.ui"), self) self.accepted.connect(self.moveBook) self.bookSelected = None self.book_id = None self.batch_id = None self.active_book = active_book batches = FsUtils.get_batches() if batches is not None: batches.append("New Batch") self.batchesList.addItems(batches) self.batchesList.itemClicked.connect(self.showBooks) self.booksList.itemClicked.connect(self.loadBook)
def __init__(self, parent): super().__init__(parent) self.main = parent uic.loadUi(FsUtils.get_resource("/ui/bookbrowser.ui"), self) self.accepted.connect(self.openBook) self.bookSelected = None self.book_id = None self.batch_id = None """ discover all batches in the main directory """ batches = FsUtils.get_batches() if batches is not None: self.batchesList.addItems(batches) self.batchesList.itemClicked.connect(self.showBooks) self.booksList.itemClicked.connect(self.loadBook)
def showBooks(self, item): self.batch_id: int = item.text() while self.booksList.count() > 0: self.booksList.takeItem(0) books = [ n.replace(".json", "") for n in FsUtils.get_books_in_batch(item.text()) ] self.booksList.addItems(books)
def loadBook(self, item): """ show the book entries """ self.book_id = item.text() self.bookSelected = FsUtils.get_book(self.book_id, self.batch_id) self.labelBox.setText(self.bookSelected.box) self.labelBookType.setText(self.bookSelected.booktype.getDisplayText()) self.labelCoverMaterial.setText(self.bookSelected.coverMaterial)
def loadBook(self, item): """ load book entry to show its data in the preview and so it can later pass it to main """ self.book_id = item.text() self.bookSelected = FsUtils.get_book(self.book_id, self.batch_id) self.labelBox.setText(self.bookSelected.box) self.labelBookType.setText(self.bookSelected.booktype.getDisplayText()) self.labelCoverMaterial.setText(self.bookSelected.coverMaterial)
def __init__(self, parent): super().__init__(parent) cost = parent.cost book = parent.activeBook uic.loadUi(FsUtils.get_resource("ui/costbreakdown.ui"), self) if cost.canBookBeEvalutated(): self.spinDisplayCover.setValue(cost.getBoardCost()) self.spinDisplayPaper.setValue(cost.getPageCost()) self.spinDisplaySew.setValue(cost.getThreadRibbonCost()) self.spinDisplaySuper.setValue(cost.getSuperCost()) self.spinDisplayCloth.setValue(cost.getClothCost()) self.spinDisplayHeadband.setValue(cost.getHeadbandCost()) self.spinDisplayExtra.setValue(cost.getExtraCosts()) if book.booktype is BookType.STAB: self.labelSewType.setText("Ribbon") else: self.labelSewType.setText("Thread")
def onNewEntryOnNewBatch(self): self.activeBook = FsUtils.create_book_new_batch() self.setUiActive()
def onNewEntryOnCurrentBatch(self): self.activeBook = FsUtils.create_book_current_batch() self.setUiActive()
def saveSettings(self): FsUtils.save_settings()
def __init__(self, parent, active_book: BookEntry): super().__init__(parent) uic.loadUi(FsUtils.get_resource("ui/discription.ui"), self) self.book_entry: BookEntry = active_book self.generateDiscription()
def moveBook(self): if self.batch_id is not None: FsUtils.move_book(self.active_book, self.batch_id) self.close()
def __init__(self, parent=None): super().__init__(parent=parent) uic.loadUi(FsUtils.get_resource("/ui/settings.ui"), self) self.pushChangeDirectory.clicked.connect(self.changeDictory) self.accepted.connect(self.saveSettings) self.lineDirectory.setText(FsUtils.get_book_dir())
def openBook(self): if self.bookSelected is not None: self.main.onEntryLoaded( FsUtils.get_book(self.book_id, self.batch_id)) self.close()
def onDirectorySelected(self, path): FsUtils.set_books_dir(path) self.lineDirectory.setText(path)