Exemplo n.º 1
0
 def add_manga(self):
     if self.list.currentItem() is None:
         return
     text = self.list.currentItem().text()
     for result in self.result_list:
         if result[0] == text:
             site = Library.site_list[result[2].get_name()]
             manga = site.create_manga_info_from_url(result[1])
             Library.add_manga(manga)
             self.parent.update_manga_list()
             self.close()
Exemplo n.º 2
0
    def read_next_unread_chapter(self, viewmode="single"):
        title = self.manga_list.currentItem().text()
        manga = Library.create_manga_from_db_by_title(title)

        chapter = manga.get_next_chapter_to_read()
        self.reader_view_window = reading_window.ReaderWindow(self, chapter, viewmode)
        self.reader_view_window.show()
Exemplo n.º 3
0
 def update_manga(self, title):
     factor = 60 - (len(title) + 2)
     self.data_updated.emit('{}: {}\n'.format(title, '-' * factor))
     chapters = Library.update_manga_by_title(title)
     if len(chapters) > 0:
         for chapter in chapters:
             self.data_updated.emit('     {}\n'.format(chapter.title))
Exemplo n.º 4
0
 def download_manga(self):
     title = self.manga_list.currentItem().text()
     manga = Library.create_manga_from_db_by_title(title)
     self.download_task = bg_downloaded.ChapterDownloadWorker(self)
     self.download_task.data_downloaded.connect(self.status_message)
     for chapter in manga.chapter_list:
         self.download_task.push(chapter)
     self.download_task.start()
Exemplo n.º 5
0
    def update_chapter_table(self):
        item = self.manga_list.currentItem()
        title = item.text()

        table = []
        manga = Library.create_manga_from_db_by_title(title)
        for chapter in manga.chapter_list:
            table.append([chapter.title, chapter.number, chapter.completed, chapter.downloaded])
        self.chapter_model.update(table)
        self.chapter_table.selectionModel().clear()
Exemplo n.º 6
0
 def set_chapter_as_complete(self):
     manga_title = self.manga_list.currentItem().text()
     manga = Library.create_manga_from_db_by_title(manga_title)
     rows = self.chapter_table.selectionModel().selectedRows()
     for index in rows:
         title = self.chapter_model.table[index.row()][0]
         Library.db.cursor().execute(
             "UPDATE chapter SET completed=1 WHERE manga_id={} and title='{}'".format(manga.hash, title)
         )
     Library.db.commit()
     self.update_chapter_table()
Exemplo n.º 7
0
    def read_chapter(self, view_mode=None):
        if not self.chapter_model.table:
            self.read_next_unread_chapter(view_mode)
            return
        title = self.manga_list.currentItem().text()
        manga = Library.create_manga_from_db_by_title(title)

        index = self.chapter_table.selectionModel().currentIndex()
        title = self.chapter_model.table[index.row()][0]

        chapter = manga.get_chapter_by_title(title)
        self.reader_view_window = reading_window.ReaderWindow(self, chapter, view_mode)
        self.reader_view_window.show()
Exemplo n.º 8
0
 def closeEvent(self, *args, **kwargs):
     Library.close()
     bg_file_io.join()
Exemplo n.º 9
0
 def remove_manga(self):
     title = self.manga_list.currentItem().text()
     manga = Library.create_manga_from_db_by_title(title)
     Library.remove_manga(manga)
     self.statusBar().showMessage("Removed: {}".format(title), 5000)
     self.update_manga_list()
Exemplo n.º 10
0
    def enter_pressed(self):
        if self.stacked.currentIndex() == 0:
            self.ml_selected_item()
        else:
            self.read_chapter()

    def r_pressed(self):
        if self.stacked.currentIndex() == 0:
            self.read_next_unread_chapter()
        else:
            self.read_chapter()

    def status_message(self, msg):
        self.statusBar().showMessage(msg)

    def closeEvent(self, *args, **kwargs):
        Library.close()
        bg_file_io.join()


if __name__ == "__main__":

    Library.init_site_list()
    Library.load()
    bg_file_io.initialize()

    app = QtGui.QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec_())