From 0ffc67e04a338f2124f075fd1dd146b0d5d5966c Mon Sep 17 00:00:00 2001 From: cuissedemouche Date: Wed, 14 Dec 2022 12:53:21 +0000 Subject: [PATCH] New list height + new populate signal Increase the height of the QListWidget Now populate the content with selectionChanged insted of Clicked, allow to select with arrow keys --- QT/main_window.ui | 4 ++-- QT/ui_main_window.py | 20 ++++++++++---------- main_window.py | 30 ++++++++++++++++++------------ ui_main_window.py | 20 ++++++++++---------- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/QT/main_window.ui b/QT/main_window.ui index 884f2cf..38d9204 100644 --- a/QT/main_window.ui +++ b/QT/main_window.ui @@ -29,11 +29,11 @@ - + - + false diff --git a/QT/ui_main_window.py b/QT/ui_main_window.py index ac400f7..d1687e7 100644 --- a/QT/ui_main_window.py +++ b/QT/ui_main_window.py @@ -39,18 +39,18 @@ class Ui_MainWindow(object): self.verticalLayout.addWidget(self.lineEdit) - self.media_tracks_list_widget = QListWidget(self.layoutWidget) - self.media_tracks_list_widget.setObjectName(u"media_tracks_list_widget") + self.tracks_list_widget = QListWidget(self.layoutWidget) + self.tracks_list_widget.setObjectName(u"tracks_list_widget") - self.verticalLayout.addWidget(self.media_tracks_list_widget) + self.verticalLayout.addWidget(self.tracks_list_widget) self.splitter.addWidget(self.layoutWidget) - self.media_detail_plain_text_edit = QPlainTextEdit(self.splitter) - self.media_detail_plain_text_edit.setObjectName(u"media_detail_plain_text_edit") - self.media_detail_plain_text_edit.setUndoRedoEnabled(False) - self.media_detail_plain_text_edit.setLineWrapMode(QPlainTextEdit.NoWrap) - self.media_detail_plain_text_edit.setReadOnly(True) - self.splitter.addWidget(self.media_detail_plain_text_edit) + self.detail_plain_text_edit = QPlainTextEdit(self.splitter) + self.detail_plain_text_edit.setObjectName(u"detail_plain_text_edit") + self.detail_plain_text_edit.setUndoRedoEnabled(False) + self.detail_plain_text_edit.setLineWrapMode(QPlainTextEdit.NoWrap) + self.detail_plain_text_edit.setReadOnly(True) + self.splitter.addWidget(self.detail_plain_text_edit) self.verticalLayout_2.addWidget(self.splitter) @@ -63,6 +63,6 @@ class Ui_MainWindow(object): def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Form", None)) self.lineEdit.setText(QCoreApplication.translate("MainWindow", u"Search", None)) - self.media_detail_plain_text_edit.setPlainText("") + self.detail_plain_text_edit.setPlainText("") # retranslateUi diff --git a/main_window.py b/main_window.py index 2d1b138..a6b95c2 100644 --- a/main_window.py +++ b/main_window.py @@ -2,6 +2,7 @@ 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): @@ -13,13 +14,13 @@ class MainWindow(QWidget, Ui_MainWindow): self.setAcceptDrops(True) self.setupConnections() - #TEMP to remove - #Set font to Mononoki system wise - self.media_detail_plain_text_edit.setFont(QFont("Mononoki Nerd Font", 10)) + font = "UbuntuMono NF" + self.tracks_list_widget.setFont(QFont(font, 12)) + self.detail_plain_text_edit.setFont(QFont(font, 12)) def setupConnections(self): - self.media_tracks_list_widget.itemClicked.connect(self.popuplate_content) + self.tracks_list_widget.itemSelectionChanged.connect(self.popuplate_content) def dragEnterEvent(self, event): @@ -39,16 +40,21 @@ class MainWindow(QWidget, Ui_MainWindow): self.setWindowTitle(f"{self.filePath} - {self.windowTitle}") self.populate_tabs() - item = self.media_tracks_list_widget.item(0).setSelected(True) - self.popuplate_content() - + self.tracks_list_widget.item(0).setSelected(True) + def populate_tabs(self): - self.media_tracks_list_widget.clear() - self.media_tracks_list_widget.addItems(self.fileCmds.tabsList) + 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): - itemSelected = self.media_tracks_list_widget.selectedItems()[0].text() - text = self.fileCmds.tabsContent[itemSelected] - self.media_detail_plain_text_edit.setPlainText(text) \ No newline at end of file + itemsSelected = self.tracks_list_widget.selectedItems() + if itemsSelected: + text = self.fileCmds.tabsContent[itemsSelected[0].text()] + self.detail_plain_text_edit.setPlainText(text) \ No newline at end of file diff --git a/ui_main_window.py b/ui_main_window.py index ac400f7..d1687e7 100644 --- a/ui_main_window.py +++ b/ui_main_window.py @@ -39,18 +39,18 @@ class Ui_MainWindow(object): self.verticalLayout.addWidget(self.lineEdit) - self.media_tracks_list_widget = QListWidget(self.layoutWidget) - self.media_tracks_list_widget.setObjectName(u"media_tracks_list_widget") + self.tracks_list_widget = QListWidget(self.layoutWidget) + self.tracks_list_widget.setObjectName(u"tracks_list_widget") - self.verticalLayout.addWidget(self.media_tracks_list_widget) + self.verticalLayout.addWidget(self.tracks_list_widget) self.splitter.addWidget(self.layoutWidget) - self.media_detail_plain_text_edit = QPlainTextEdit(self.splitter) - self.media_detail_plain_text_edit.setObjectName(u"media_detail_plain_text_edit") - self.media_detail_plain_text_edit.setUndoRedoEnabled(False) - self.media_detail_plain_text_edit.setLineWrapMode(QPlainTextEdit.NoWrap) - self.media_detail_plain_text_edit.setReadOnly(True) - self.splitter.addWidget(self.media_detail_plain_text_edit) + self.detail_plain_text_edit = QPlainTextEdit(self.splitter) + self.detail_plain_text_edit.setObjectName(u"detail_plain_text_edit") + self.detail_plain_text_edit.setUndoRedoEnabled(False) + self.detail_plain_text_edit.setLineWrapMode(QPlainTextEdit.NoWrap) + self.detail_plain_text_edit.setReadOnly(True) + self.splitter.addWidget(self.detail_plain_text_edit) self.verticalLayout_2.addWidget(self.splitter) @@ -63,6 +63,6 @@ class Ui_MainWindow(object): def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Form", None)) self.lineEdit.setText(QCoreApplication.translate("MainWindow", u"Search", None)) - self.media_detail_plain_text_edit.setPlainText("") + self.detail_plain_text_edit.setPlainText("") # retranslateUi