from PySide6.QtWidgets import QWidget from ui_main_window import Ui_MainWindow from file_cmds import FileCmds from PySide6.QtGui import QFont from PySide6.QtCore import QSize class MainWindow(QWidget, Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) self.windowTitle = "mediainfoSama" self.setWindowTitle(self.windowTitle) self.setAcceptDrops(True) self.setupConnections() self.splitter.setStretchFactor(0, False) self.splitter.setStretchFactor(1, True) def setupConnections(self): self.tracks_list_widget.itemSelectionChanged.connect(self.popuplate_content) def dragEnterEvent(self, event): event.accept() def dragMoveEvent(self, event): event.accept() def dropEvent(self, event): self.filePath = event.mimeData().urls()[0].toLocalFile() self.fileCmds = FileCmds(self.filePath) if self.fileCmds.file_exist() == False: return self.setWindowTitle(f"{self.filePath} - {self.windowTitle}") self.populate_tabs() self.tracks_list_widget.item(0).setSelected(True) def populate_tabs(self): self.tracks_list_widget.clear() self.tracks_list_widget.addItems(self.fileCmds.tabsList) for i in range(self.tracks_list_widget.count()): item = self.tracks_list_widget.item(i) height = self.tracks_list_widget.sizeHintForRow(0) item.setSizeHint(QSize(0, height+5)) def popuplate_content(self): itemsSelected = self.tracks_list_widget.selectedItems() if itemsSelected: text = self.fileCmds.tabsContent[itemsSelected[0].text()] self.detail_plain_text_edit.setPlainText(text)