Removed text from playlist tabs and added QLineEdit to them to have an input for renaming playlists.

This commit is contained in:
The Wobbler 2025-01-27 16:28:55 +01:00
parent 120d04359e
commit 9d844ae2dd
2 changed files with 36 additions and 2 deletions

View file

@ -1,6 +1,8 @@
#!/usr/bin/python3
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QDragEnterEvent, QMouseEvent
from PyQt6.QtWidgets import QTabWidget, QTabBar
from PyQt6.QtWidgets import QTabWidget, QTabBar, QLineEdit
class PlaylistTabs(QTabWidget):
@ -9,12 +11,22 @@ class PlaylistTabs(QTabWidget):
super().__init__(parent)
self.setTabBar(PlaylistTabBar(self))
self.tab_bar = PlaylistTabBar(self)
self.setTabBar(self.tab_bar)
self.setDocumentMode(True)
self.setMovable(True)
self.setAcceptDrops(True)
def addTab(self, widget, label):
super().addTab(widget, None)
index = self.tab_bar.count() - 1
title = TabTitle(label, self.tab_bar, index)
self.tab_bar.setTabButton(index, QTabBar.ButtonPosition.RightSide, title)
class PlaylistTabBar(QTabBar):
def __init__(self, parent=None):
@ -45,3 +57,22 @@ class PlaylistTabBar(QTabBar):
self.app.player.start_playlist(playlist)
class TabTitle(QLineEdit):
def __init__(self, label, parent, index: int):
super().__init__(label, parent)
self.tab_bar: PlaylistTabBar = parent
self.index = index
self.setStyleSheet("QLineEdit {background: transparent;}")
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
def mouseDoubleClickEvent(self, event: QMouseEvent):
self.tab_bar.tabBarDoubleClicked.emit(self.index)
def mousePressEvent(self, event: QMouseEvent):
self.tab_bar.tabBarClicked.emit(self.index)
self.tab_bar.setCurrentIndex(self.index)

View file

@ -1,5 +1,6 @@
#!/usr/bin/python3
from PyQt6.QtGui import QPalette
from PyQt6.QtWidgets import QWidget, QLineEdit, QFormLayout
@ -11,5 +12,7 @@ class FileSettings(QWidget):
self.setLayout(self.layout)
self.library_path_input = QLineEdit(self)
self.library_path_input.setStyleSheet("QLineEdit { background: transparent; }")
self.layout.addRow("Library Path:", self.library_path_input)