cuissedemouche
0ffc67e04a
Increase the height of the QListWidget Now populate the content with selectionChanged insted of Clicked, allow to select with arrow keys
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
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()
|
|
|
|
font = "UbuntuMono NF"
|
|
self.tracks_list_widget.setFont(QFont(font, 12))
|
|
self.detail_plain_text_edit.setFont(QFont(font, 12))
|
|
|
|
|
|
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) |