Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: redesign ImgListView #741

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion feeluown/gui/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import random
import sys
import logging
from contextlib import contextmanager
from typing import TypeVar, List, Optional, Generic, Union, cast, TYPE_CHECKING

try:
# helper module should work in no-window mode
from PyQt5.QtCore import QModelIndex, QSize, Qt, pyqtSignal, QSortFilterProxyModel, \
QAbstractListModel
from PyQt5.QtGui import QPalette, QFontMetrics, QColor
from PyQt5.QtGui import QPalette, QFontMetrics, QColor, QPainter
from PyQt5.QtWidgets import QApplication, QScrollArea, QWidget
except ImportError:
pass
Expand Down Expand Up @@ -557,6 +558,23 @@ def random_solarized_color():
return QColor(random.choice(list(SOLARIZED_COLORS.values())))


@contextmanager
def painter_save(painter: QPainter):
painter.save()
yield
painter.restore()


def secondary_text_color(palette: QPalette):
text_color: QColor = palette.color(QPalette.Text)
if text_color.lightness() > 150:
non_text_color = text_color.darker(140)
else:
non_text_color = text_color.lighter(150)
non_text_color.setAlpha(100)
return non_text_color


# https://ethanschoonover.com/solarized/
SOLARIZED_COLORS = {
'yellow': '#b58900',
Expand Down
42 changes: 24 additions & 18 deletions feeluown/gui/page_containers/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
from feeluown.gui.helpers import BgTransparentMixin, \
disconnect_slots_if_has, fetch_cover_wrapper
from feeluown.gui.components import SongMenuInitializer
from feeluown.gui.widgets.imglist import ImgListView
from feeluown.gui.widgets.album import AlbumListModel, AlbumListView, \
AlbumFilterProxyModel
from feeluown.gui.widgets.artist import ArtistListModel, ArtistListView, \
ArtistFilterProxyModel
from feeluown.gui.widgets.video_list import VideoListModel, VideoListView, \
VideoFilterProxyModel
from feeluown.gui.widgets.playlist import PlaylistListModel, PlaylistListView, \
PlaylistFilterProxyModel
from feeluown.gui.widgets.img_card_list import ImgCardListView
from feeluown.gui.widgets.img_card_list import (
AlbumCardListModel, AlbumCardListView, AlbumFilterProxyModel, AlbumCardListDelegate,
ArtistCardListModel, ArtistCardListView, ArtistFilterProxyModel,
VideoCardListModel, VideoCardListView, VideoFilterProxyModel, VideoCardListDelegate,
PlaylistCardListModel, PlaylistCardListView, PlaylistFilterProxyModel,
PlaylistCardListDelegate, ArtistCardListDelegate,
)
from feeluown.gui.widgets.songs import ColumnsMode, SongsTableModel, SongsTableView, \
SongFilterProxyModel
from feeluown.gui.widgets.comment_list import CommentListView, CommentListModel
Expand Down Expand Up @@ -93,25 +92,25 @@ async def show_cover(self, cover, cover_uid, as_background=False):
def show_albums(self, reader):
self._show_model_with_cover(reader,
self.albums_table,
AlbumListModel,
AlbumCardListModel,
AlbumFilterProxyModel)

def show_artists(self, reader):
self._show_model_with_cover(reader,
self.artists_table,
ArtistListModel,
ArtistCardListModel,
ArtistFilterProxyModel)

def show_videos(self, reader):
self._show_model_with_cover(reader,
self.videos_table,
VideoListModel,
VideoCardListModel,
VideoFilterProxyModel)

def show_playlists(self, reader):
self._show_model_with_cover(reader,
self.playlists_table,
PlaylistListModel,
PlaylistCardListModel,
PlaylistFilterProxyModel)

def _show_model_with_cover(self, reader, table, model_cls, filter_model_cls):
Expand Down Expand Up @@ -257,10 +256,16 @@ def __init__(self, app, parent=None):
self.tabbar = TableTabBarV2()
self.meta_widget = TableMetaWidget(parent=self)
self.songs_table = SongsTableView(app=self._app, parent=self)
self.albums_table = AlbumListView(parent=self, img_min_width=120)
self.artists_table = ArtistListView(parent=self)
self.videos_table = VideoListView(parent=self)
self.playlists_table = PlaylistListView(parent=self)
self.albums_table = AlbumCardListView(parent=self)
self.albums_table.setItemDelegate(
AlbumCardListDelegate(self.albums_table, img_min_width=120))
self.artists_table = ArtistCardListView(parent=self)
self.artists_table.setItemDelegate(ArtistCardListDelegate(self.artists_table))
self.videos_table = VideoCardListView(parent=self)
self.videos_table.setItemDelegate(VideoCardListDelegate(self.videos_table))
self.playlists_table = PlaylistCardListView(parent=self)
self.playlists_table.setItemDelegate(
PlaylistCardListDelegate(self.playlists_table))
self.comments_table = CommentListView(parent=self)
self.desc_widget = DescLabel(parent=self)

Expand Down Expand Up @@ -306,6 +311,7 @@ def _setup_ui(self):
self._v_layout = QVBoxLayout()

self._v_layout.addWidget(self.meta_widget)
self._v_layout.addSpacing(15)
self._v_layout.addWidget(self.toolbar)
self._v_layout.addWidget(self.desc_widget)

Expand Down Expand Up @@ -360,7 +366,7 @@ def current_table(self, table):
self.toolbar.albums_mode()
if table is self.songs_table:
self.toolbar.songs_mode()
if isinstance(self._table, ImgListView):
if isinstance(self._table, ImgCardListView):
self._table.setModel(None)
self._table = table

Expand Down
7 changes: 4 additions & 3 deletions feeluown/gui/pages/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from feeluown.models import SearchType
from feeluown.gui.page_containers.table import TableContainer, Renderer
from feeluown.gui.page_containers.scroll_area import ScrollArea
from feeluown.gui.widgets.imglist import ImgListView
from feeluown.gui.widgets.img_card_list import ImgCardListDelegate
from feeluown.gui.widgets.songs import SongsTableView, ColumnsMode
from feeluown.gui.base_renderer import TabBarRendererMixin
from feeluown.gui.helpers import BgTransparentMixin
Expand Down Expand Up @@ -58,9 +58,10 @@ async def render(req, **kwargs): # pylint: disable=too-many-locals,too-many-bra
# HACK: set fixed row for tables.
# pylint: disable=protected-access
for table in table_container._tables:
if isinstance(table, ImgListView):
delegate = table.itemDelegate()
if isinstance(delegate, ImgCardListDelegate):
table._fixed_row_count = 2
table.img_min_width = 100
delegate.update_settings("card_min_width", 100)
elif isinstance(table, SongsTableView):
table._fixed_row_count = 8
table._row_height = table.verticalHeader().defaultSectionSize()
Expand Down
71 changes: 0 additions & 71 deletions feeluown/gui/widgets/album.py

This file was deleted.

37 changes: 0 additions & 37 deletions feeluown/gui/widgets/artist.py

This file was deleted.

Loading
Loading