-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui: introduce ClickableMixin (#787)
1. click the accordion header can fold/unfold contents 2. click the cover label to show/hide nowplaying overlay (demo)
- Loading branch information
Showing
5 changed files
with
100 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import TYPE_CHECKING, cast | ||
|
||
from PyQt5.QtCore import QEvent | ||
from PyQt5.QtGui import QResizeEvent, QKeySequence | ||
from PyQt5.QtWidgets import QWidget, QShortcut | ||
|
||
if TYPE_CHECKING: | ||
from feeluown.app.gui_app import GuiApp | ||
|
||
|
||
class NowplayingOverlay(QWidget): | ||
""" | ||
TODO | ||
""" | ||
|
||
def __init__(self, app: 'GuiApp', parent=None): | ||
super().__init__(parent=parent) | ||
self._app = app | ||
self._app.installEventFilter(self) | ||
|
||
QShortcut(QKeySequence.Cancel, self).activated.connect(self.hide) | ||
|
||
self.setStyleSheet('background: pink') | ||
|
||
def show(self): | ||
self.resize(self._app.size()) | ||
super().show() | ||
|
||
def eventFilter(self, obj, event): | ||
if self.isVisible() and obj is self._app and event.type() == QEvent.Resize: | ||
event = cast(QResizeEvent, event) | ||
print('resize', event.size(), self.size()) | ||
self.resize(event.size()) | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters