Init repo - gui can launch and first pad list generates from list in pads settings!
This commit is contained in:
1
gui/modules/menu/__init__.py
Normal file
1
gui/modules/menu/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .handlers import *
|
||||
11
gui/modules/menu/handlers.py
Normal file
11
gui/modules/menu/handlers.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from gui.gui import Ui_MainWindow
|
||||
from .menu import handle_menu_click
|
||||
|
||||
|
||||
def register_handlers(ui: Ui_MainWindow):
|
||||
"""
|
||||
Register this module handlers
|
||||
:param ui:
|
||||
:return:
|
||||
"""
|
||||
ui.menu.itemClicked.connect(lambda: handle_menu_click(ui.menu.currentItem().text(), ui))
|
||||
41
gui/modules/menu/menu.py
Normal file
41
gui/modules/menu/menu.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from PyQt5 import QtCore
|
||||
from gui.gui import Ui_MainWindow
|
||||
|
||||
|
||||
def open_menu(ui: Ui_MainWindow) -> None:
|
||||
"""
|
||||
Animates the menu to open and close, using animation from config
|
||||
:return:
|
||||
"""
|
||||
width = ui.menu.geometry().width()
|
||||
Ui_MainWindow.animation = QtCore.QPropertyAnimation(ui.menu, b"minimumWidth")
|
||||
Ui_MainWindow.animation.setDuration(300)
|
||||
if width == 64:
|
||||
Ui_MainWindow.animation.setStartValue(64)
|
||||
Ui_MainWindow.animation.setEndValue(200)
|
||||
else:
|
||||
Ui_MainWindow.animation.setStartValue(200)
|
||||
Ui_MainWindow.animation.setEndValue(64)
|
||||
Ui_MainWindow.animation.setEasingCurve(QtCore.QEasingCurve.InOutQuart)
|
||||
|
||||
Ui_MainWindow.animation.start()
|
||||
|
||||
|
||||
def handle_menu_click(text: str, ui: Ui_MainWindow) -> None:
|
||||
"""
|
||||
Handles the click on the menu and changes the page
|
||||
:param text:
|
||||
:param ui:
|
||||
:return:
|
||||
"""
|
||||
index = {
|
||||
"Close menu": [lambda _: open_menu(ui), None],
|
||||
"Pads": [ui.content.setCurrentWidget, ui.pads_page],
|
||||
"Explorer": [ui.content.setCurrentWidget, ui.browser_page],
|
||||
"Collections": [ui.content.setCurrentWidget, ui.collections_page],
|
||||
"Stream": [ui.content.setCurrentWidget, ui.stream_page],
|
||||
"Collab": [ui.content.setCurrentWidget, ui.collab_page],
|
||||
"Download": [ui.content.setCurrentWidget, ui.download_page],
|
||||
"Settings": [ui.content.setCurrentWidget, ui.settings_page]
|
||||
}
|
||||
index[text][0](index[text][1])
|
||||
Reference in New Issue
Block a user