Exemple #1
0
    def __init__(self):
        super().__init__()
        self.scheduler = injector.get_scheduler()
        self.db = injector.get_database_handler()
        self.task_map = {}
        self.new_tasks = []
        self.deleted_tasks = []
        self.load_ui()
        self.schedule_download_button.clicked.connect(self.add_task)

        self.scheduled_downloads_list_widget.setContextMenuPolicy(
            Qt.CustomContextMenu)
        self.scheduled_downloads_list_widget.customContextMenuRequested.connect(
            self.task_list_widget_context_menu)
Exemple #2
0
def main():
    logger.make_logger()
    sys.excepthook = log_unhandled_exception

    check_args(sys.argv[1:])

    check_migration()

    app = QtWidgets.QApplication(sys.argv)

    queue = injector.get_message_queue()
    message_thread = QtCore.QThread()
    receiver = MessageReceiver(queue)
    scheduler = injector.get_scheduler()

    window = DownloaderForRedditGUI(queue, receiver, scheduler)

    receiver.text_output.connect(window.handle_message)
    receiver.non_text_output.connect(window.handle_progress)

    receiver.moveToThread(message_thread)
    message_thread.started.connect(receiver.run)
    receiver.finished.connect(message_thread.quit)
    receiver.finished.connect(receiver.deleteLater)
    message_thread.finished.connect(message_thread.deleteLater)
    message_thread.start()

    schedule_thread = QtCore.QThread()
    scheduler.moveToThread(schedule_thread)
    scheduler.run_task.connect(window.run_scheduled_download)
    scheduler.countdown.connect(window.update_scheduled_download)
    scheduler.finished.connect(schedule_thread.quit)
    scheduler.finished.connect(scheduler.deleteLater)
    schedule_thread.finished.connect(schedule_thread.deleteLater)
    schedule_thread.started.connect(scheduler.run)
    schedule_thread.start()

    window.show()
    sys.exit(app.exec_())