Skip to content

Commit

Permalink
some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed May 7, 2024
1 parent f03f430 commit 59eca6d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion feeluown/gui/assets/themes/common.qss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ QWidget {
/* border: 1px solid red; */
}

LeftPanel QLabel {
LeftPanel QLabel, TriagleButton, PlusButton {
color: #888;
}

Expand Down
50 changes: 30 additions & 20 deletions feeluown/gui/uimain/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
from feeluown.utils import aio
from feeluown.utils.reader import create_reader
from feeluown.utils.aio import run_fn
from feeluown.gui.components import Avatar, CollectionListView
from feeluown.gui.widgets import (
DiscoveryButton,
HomeButton,
PlusButton,
TriagleButton,
StarButton,
)

from feeluown.gui.widgets.separator import Separator
from feeluown.gui.widgets.playlists import PlaylistsView
from feeluown.gui.components import CollectionListView
from feeluown.gui.widgets.my_music import MyMusicView

if TYPE_CHECKING:
Expand Down Expand Up @@ -121,6 +121,8 @@ def __init__(self, app: 'GuiApp', parent=None):
self.home_btn = HomeButton(height=30, parent=self)
self.discovery_btn = DiscoveryButton(height=30, padding=0.2, parent=self)
self.fav_btn = StarButton('我的收藏', height=30, parent=self)
self.fold_top_btn = TriagleButton(length=14, padding=0.2)
self.fold_top_btn.setCheckable(True)
self.collections_header = QLabel('本地收藏集', self)
self.collections_header.setToolTip('我们可以在本地建立『收藏集』来收藏自己喜欢的音乐资源\n\n'
'每个收藏集都以一个独立 .fuo 文件的存在,'
Expand All @@ -143,27 +145,22 @@ def __init__(self, app: 'GuiApp', parent=None):
self.playlists_view.setModel(self._app.pl_uimgr.model)
self.my_music_view.setModel(self._app.mymusic_uimgr.model)

self._top_separator = Separator(self._app)
self._layout = QVBoxLayout(self)
self._sub_layout = QVBoxLayout()
self._top_layout = QVBoxLayout()
self._avatar_layout = QHBoxLayout()

self._layout.setSpacing(0)
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.addLayout(self._top_layout)
self._layout.addLayout(self._sub_layout)

self._top_layout.setContentsMargins(15, 16, 16, 0)
self._top_layout.addWidget(self.home_btn)
self._sub_layout.setContentsMargins(16, 8, 16, 0)
self._sub_layout.addWidget(self.collections_con)
from feeluown.gui.widgets.separator import Separator
from feeluown.gui.components import Avatar
self._sub_layout.addWidget(Separator(self._app))
self._sub_layout.addWidget(Avatar(self._app, height=48))
self._sub_layout.addWidget(self.discovery_btn)
self._sub_layout.addWidget(self.fav_btn)
self._sub_layout.addWidget(self.my_music_con)
self._sub_layout.addWidget(self.playlists_con)
self._layout.setContentsMargins(16, 10, 16, 0)
self._layout.addWidget(self.home_btn)
self._layout.addWidget(self.collections_con)
self._layout.addWidget(self._top_separator)
self._layout.addLayout(self._avatar_layout)
self._avatar_layout.addWidget(Avatar(self._app, height=48))
self._avatar_layout.addWidget(self.fold_top_btn)
self._layout.addWidget(self.discovery_btn)
self._layout.addWidget(self.fav_btn)
self._layout.addWidget(self.my_music_con)
self._layout.addWidget(self.playlists_con)
self._layout.addStretch(0)

self.playlists_view.setFrameShape(QFrame.NoFrame)
Expand All @@ -177,6 +174,7 @@ def __init__(self, app: 'GuiApp', parent=None):
self.discovery_btn.setDisabled(True)
self.fav_btn.setDisabled(True)
self.discovery_btn.setToolTip('当前资源提供方未知')
self.fold_top_btn.setToolTip('折叠/打开“主页和本地收藏集”功能')

if self._app.config.ENABLE_NEW_HOMEPAGE is True:
self.home_btn.clicked.connect(
Expand All @@ -200,6 +198,18 @@ def __init__(self, app: 'GuiApp', parent=None):
lambda: self._app.browser.goto(page='/rec'))
self.fav_btn.clicked.connect(
lambda: self._app.browser.goto(page='/my_fav'))
self.fold_top_btn.clicked.connect(self._toggle_top_layout)

def _toggle_top_layout(self, checked):
widgets = [self._top_separator, self.collections_con, self.home_btn]
if checked:
self.fold_top_btn.set_direction('down')
for w in widgets:
w.hide()
else:
self.fold_top_btn.set_direction('up')
for w in widgets:
w.show()

def popup_collection_adding_dialog(self):
dialog = QDialog(self)
Expand Down

0 comments on commit 59eca6d

Please sign in to comment.