|
|
|
@@ -1,3 +1,4 @@
|
|
|
|
|
from PySide6.QtCore import Qt, QThreadPool
|
|
|
|
|
from PySide6.QtGui import QAction, QIcon, QGuiApplication
|
|
|
|
|
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QMessageBox, QTabWidget, QTableView, QProgressBar, QMdiArea
|
|
|
|
|
from PySide6.QtWidgets import QLabel, QMainWindow
|
|
|
|
@@ -10,6 +11,7 @@ from .progress import ProgressUpdate
|
|
|
|
|
from .dialogs import ExportKontorDialog, ImportKontorDialog
|
|
|
|
|
from .model_config import KontorModelConfig
|
|
|
|
|
from .table_model import KontorTableModel
|
|
|
|
|
from .worker import VideoDownloader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MainWindow(QMainWindow):
|
|
|
|
@@ -17,6 +19,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
def __init__(self, engine: Engine, log):
|
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
|
|
self.downloader = None
|
|
|
|
|
self.tick = QIcon('res/tick.png')
|
|
|
|
|
self.cross = QIcon('res/cross.png')
|
|
|
|
|
self.import_icon = QIcon("res/application-import.png")
|
|
|
|
@@ -28,29 +31,20 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.kontor_db = KontorDB(engine, log)
|
|
|
|
|
self.log = log
|
|
|
|
|
self._subwindows = {}
|
|
|
|
|
self.media_dir = "/data/media"
|
|
|
|
|
self.dl_tool = "yt-dlp"
|
|
|
|
|
|
|
|
|
|
self._setup_ui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#self.tabs = QTabWidget()
|
|
|
|
|
#self.tabs.addTab(self.generate_data_tab("comic"), "Comics")
|
|
|
|
|
#self.tabs.addTab(self.generate_data_tab("media_file"), "MediaFile")
|
|
|
|
|
#self.tabs.currentChanged.connect(self._tab_changed)
|
|
|
|
|
#label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
|
|
|
#parent_layout.addWidget(self.tabs)
|
|
|
|
|
|
|
|
|
|
self.setCentralWidget(self.central_widget)
|
|
|
|
|
|
|
|
|
|
def _setup_ui(self):
|
|
|
|
|
self.setWindowTitle("Kontor")
|
|
|
|
|
self.setMinimumSize(1200, 800)
|
|
|
|
|
self._create_actions()
|
|
|
|
|
self.central_widget = QWidget()
|
|
|
|
|
# parent_layout = QVBoxLayout()
|
|
|
|
|
# self.central_widget.setLayout(parent_layout)
|
|
|
|
|
self.mdi_area = QMdiArea(self.central_widget)
|
|
|
|
|
self.mdi_area = QMdiArea()
|
|
|
|
|
self.setCentralWidget(self.mdi_area)
|
|
|
|
|
self.mdi_area.setObjectName('mdi_area')
|
|
|
|
|
self.setCentralWidget(self.central_widget)
|
|
|
|
|
self.mdi_area.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
|
|
|
|
self.mdi_area.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
|
|
|
|
self._create_menubar()
|
|
|
|
|
self._create_toolbars()
|
|
|
|
|
self.status_progress = QProgressBar()
|
|
|
|
@@ -77,7 +71,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.updateTitleAction = QAction("&Update Titles", self)
|
|
|
|
|
self.updateTitleAction.triggered.connect(self.update_title)
|
|
|
|
|
self.downloadAction = QAction("&Download Videos", self)
|
|
|
|
|
self.downloadAction.triggered.connect(self.download_file)
|
|
|
|
|
self.downloadAction.triggered.connect(self.start_download)
|
|
|
|
|
self.checkFileAction = QAction("&Check files", self)
|
|
|
|
|
self.checkFileAction.triggered.connect(self.check_files)
|
|
|
|
|
self.exitAction = QAction("&Beenden", self)
|
|
|
|
@@ -189,18 +183,32 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.log.info("update title for table MediaFile")
|
|
|
|
|
self.statusBar.showMessage("update title for table MediaFile", 3000)
|
|
|
|
|
self.status_progress.setEnabled(True)
|
|
|
|
|
self.kontor_db.update_title()
|
|
|
|
|
self.kontor_db.update_titles()
|
|
|
|
|
self.status_progress.setEnabled(False)
|
|
|
|
|
self.refresh()
|
|
|
|
|
|
|
|
|
|
def download_file(self):
|
|
|
|
|
self.log.info("download videos for table MediaFile")
|
|
|
|
|
self.statusBar.showMessage("download videos for table MediaFile", 3000)
|
|
|
|
|
def start_download(self):
|
|
|
|
|
self.status_progress.setEnabled(True)
|
|
|
|
|
self.kontor_db.download_file(False, self.progress_update)
|
|
|
|
|
self.status_progress.setEnabled(False)
|
|
|
|
|
self.statusBar.showMessage("download videos for table MediaFile", 3000)
|
|
|
|
|
self.downloader = VideoDownloader(self.kontor_db, self.log)
|
|
|
|
|
self.downloader.setTotalProgress.connect(self.status_progress.setMaximum)
|
|
|
|
|
self.downloader.setCurrentProgress.connect(self.downloadProgress)
|
|
|
|
|
self.downloader.succeeded.connect(self.downloadSucceeded)
|
|
|
|
|
self.downloader.finished.connect(self.downloadFinished)
|
|
|
|
|
self.downloader.start()
|
|
|
|
|
|
|
|
|
|
def downloadProgress(self, value: int):
|
|
|
|
|
self.status_progress.setValue(value)
|
|
|
|
|
self.refresh()
|
|
|
|
|
|
|
|
|
|
def downloadSucceeded(self):
|
|
|
|
|
self.status_progress.setValue(self.status_progress.maximum())
|
|
|
|
|
self.statusBar.showMessage("Download succeeded", 3000)
|
|
|
|
|
|
|
|
|
|
def downloadFinished(self):
|
|
|
|
|
self.status_progress.setEnabled(False)
|
|
|
|
|
del self.downloader
|
|
|
|
|
|
|
|
|
|
def check_files(self):
|
|
|
|
|
self.log.info("check files")
|
|
|
|
|
self.statusBar.showMessage("check files for table MediaFile", 3000)
|
|
|
|
|