new design
This commit is contained in:
parent
d1816bb0b6
commit
33736a11fd
10
app_new.py
Normal file
10
app_new.py
Normal file
@ -0,0 +1,10 @@
|
||||
import sys
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from ui.main_window_new import MainWindowNew
|
||||
|
||||
|
||||
def run_app_new():
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindowNew(app)
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
5
main.py
5
main.py
@ -1,4 +1,5 @@
|
||||
from app import run_app
|
||||
# from app import run_app
|
||||
from app_new import run_app_new
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_app()
|
||||
run_app_new()
|
||||
|
||||
4
main_new.py
Normal file
4
main_new.py
Normal file
@ -0,0 +1,4 @@
|
||||
from app_new import run_app_new
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_app_new()
|
||||
@ -9,11 +9,13 @@ from PySide6.QtWidgets import (
|
||||
QSlider,
|
||||
QSizePolicy,
|
||||
)
|
||||
from PySide6.QtCore import Qt, QSize, QTimer
|
||||
from PySide6.QtCore import Qt, QSize, QTimer, Signal
|
||||
from PySide6.QtGui import QFont
|
||||
|
||||
|
||||
class MediaScreen(QWidget):
|
||||
source_changed = Signal(str)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
root = QVBoxLayout(self)
|
||||
@ -205,7 +207,9 @@ class MediaScreen(QWidget):
|
||||
if album:
|
||||
self.album.setText(album)
|
||||
if source:
|
||||
self.source.setText(f"Источник: {source}")
|
||||
text = f"Источник: {source}"
|
||||
self.source.setText(text)
|
||||
self.source_changed.emit(text)
|
||||
if duration is not None and duration > 0:
|
||||
self.progress.setRange(0, duration)
|
||||
self.time_total.setText(self._format_time(duration))
|
||||
|
||||
@ -3,6 +3,22 @@ QWidget { background: #F4F6F8; color: #111827; }
|
||||
#TopBar, #BottomBar { background: #FFFFFF; }
|
||||
#Divider { background: #E5E7EB; }
|
||||
|
||||
#MenuButton, #SettingsButton {
|
||||
background: #FFFFFF;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #E5E7EB;
|
||||
padding: 6px 12px;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
#MenuButton:hover, #SettingsButton:hover { background: #F9FAFB; }
|
||||
QMenu {
|
||||
background: #FFFFFF;
|
||||
color: #111827;
|
||||
border: 1px solid #E5E7EB;
|
||||
}
|
||||
QMenu::item:selected { background: #F3F4F6; }
|
||||
|
||||
#SettingsSection { color: rgba(55,65,81,0.9); letter-spacing: 0.5px; }
|
||||
#SettingsRow {
|
||||
background: #FFFFFF;
|
||||
|
||||
@ -3,6 +3,21 @@ QWidget { background: #0B0E11; color: #E6EAF0; }
|
||||
#TopBar, #BottomBar { background: #0F1318; }
|
||||
#Divider { background: #1B2330; }
|
||||
|
||||
#MenuButton, #SettingsButton {
|
||||
background: #141A22;
|
||||
border-radius: 12px;
|
||||
padding: 6px 12px;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
#MenuButton:hover, #SettingsButton:hover { background: #1B2330; }
|
||||
QMenu {
|
||||
background: #0F1318;
|
||||
color: #E6EAF0;
|
||||
border: 1px solid #1B2330;
|
||||
}
|
||||
QMenu::item:selected { background: #1B2330; }
|
||||
|
||||
#SettingsSection { color: rgba(138,147,166,0.95); letter-spacing: 0.5px; }
|
||||
#SettingsRow {
|
||||
background: #141A22;
|
||||
|
||||
127
ui/main_window_new.py
Normal file
127
ui/main_window_new.py
Normal file
@ -0,0 +1,127 @@
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QMainWindow,
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QHBoxLayout,
|
||||
QStackedWidget,
|
||||
QToolButton,
|
||||
QMenu,
|
||||
QPushButton,
|
||||
QLabel,
|
||||
)
|
||||
from PySide6.QtCore import QSize, Qt, QTimer
|
||||
from PySide6.QtGui import QFont
|
||||
from themes import THEME_DAY, THEME_NIGHT
|
||||
from screens.media import MediaScreen
|
||||
from screens.stub import StubScreen
|
||||
from screens.settings import SettingsScreen
|
||||
|
||||
|
||||
class MainWindowNew(QMainWindow):
|
||||
def __init__(self, app: QApplication):
|
||||
super().__init__()
|
||||
self.app = app
|
||||
self.is_night = True
|
||||
|
||||
self.setWindowTitle("Car UI (New)")
|
||||
self.setMinimumSize(QSize(1024, 600))
|
||||
self.showFullScreen()
|
||||
|
||||
central = QWidget()
|
||||
outer = QVBoxLayout(central)
|
||||
outer.setContentsMargins(0, 0, 0, 0)
|
||||
outer.setSpacing(0)
|
||||
|
||||
self.topbar = QWidget()
|
||||
self.topbar.setObjectName("TopBar")
|
||||
self.topbar.setMinimumHeight(86)
|
||||
top = QHBoxLayout(self.topbar)
|
||||
top.setContentsMargins(18, 14, 18, 14)
|
||||
top.setSpacing(14)
|
||||
|
||||
self.menu_button = QToolButton()
|
||||
self.menu_button.setObjectName("MenuButton")
|
||||
self.menu_button.setText("▼")
|
||||
self.menu_button.setPopupMode(QToolButton.InstantPopup)
|
||||
self.menu_button.setCursor(Qt.PointingHandCursor)
|
||||
|
||||
menu = QMenu(self.menu_button)
|
||||
self.menu_button.setMenu(menu)
|
||||
self.act_media = menu.addAction("Media")
|
||||
self.act_car = menu.addAction("Car")
|
||||
self.act_maps = menu.addAction("Maps")
|
||||
|
||||
self.lbl_source = QLabel("Media")
|
||||
self.lbl_source.setFont(QFont("", 20, 600))
|
||||
|
||||
self.lbl_bt = QLabel("Источник")
|
||||
self.lbl_bt.setObjectName("BluetoothStatus")
|
||||
self.lbl_bt.setFont(QFont("", 18, 600))
|
||||
|
||||
self.lbl_time = QLabel("--:--")
|
||||
self.lbl_time.setFont(QFont("", 20, 600))
|
||||
|
||||
self.btn_settings = QPushButton("⚙")
|
||||
self.btn_settings.setObjectName("SettingsButton")
|
||||
self.btn_settings.setMinimumSize(56, 48)
|
||||
self.btn_settings.clicked.connect(self.toggle_settings)
|
||||
|
||||
top.addWidget(self.menu_button)
|
||||
top.addWidget(self.lbl_source)
|
||||
top.addStretch(1)
|
||||
top.addWidget(self.lbl_bt)
|
||||
top.addWidget(self.lbl_time)
|
||||
top.addWidget(self.btn_settings)
|
||||
|
||||
self.stack = QStackedWidget()
|
||||
self.media_screen = MediaScreen()
|
||||
self.stack.addWidget(self.media_screen) # 0
|
||||
self.stack.addWidget(StubScreen("Car")) # 1
|
||||
self.stack.addWidget(StubScreen("Maps")) # 2
|
||||
self.stack.addWidget(SettingsScreen()) # 3
|
||||
|
||||
self.settings_idx = 3
|
||||
self.last_non_settings_idx = 0
|
||||
|
||||
self.act_media.triggered.connect(lambda: self.go(0))
|
||||
self.act_car.triggered.connect(lambda: self.go(1))
|
||||
self.act_maps.triggered.connect(lambda: self.go(2))
|
||||
self.media_screen.source_changed.connect(self.lbl_bt.setText)
|
||||
|
||||
outer.addWidget(self.topbar)
|
||||
outer.addWidget(self.stack, 1)
|
||||
|
||||
self.setCentralWidget(central)
|
||||
|
||||
self._clock_timer = QTimer(self)
|
||||
self._clock_timer.timeout.connect(self.update_time)
|
||||
self._clock_timer.start(500)
|
||||
|
||||
self.apply_theme()
|
||||
self.go(0)
|
||||
self.lbl_bt.setText(self.media_screen.source.text())
|
||||
|
||||
def apply_theme(self):
|
||||
self.app.setStyleSheet(THEME_NIGHT if self.is_night else THEME_DAY)
|
||||
|
||||
def toggle_settings(self):
|
||||
if self.stack.currentIndex() == self.settings_idx:
|
||||
self.go(self.last_non_settings_idx)
|
||||
else:
|
||||
self.go(self.settings_idx)
|
||||
|
||||
def update_time(self):
|
||||
from datetime import datetime
|
||||
self.lbl_time.setText(datetime.now().strftime("%H:%M"))
|
||||
|
||||
def go(self, idx: int):
|
||||
if idx != self.settings_idx:
|
||||
self.last_non_settings_idx = idx
|
||||
self.stack.setCurrentIndex(idx)
|
||||
if idx == 0:
|
||||
self.lbl_source.setText("Media")
|
||||
elif idx == 1:
|
||||
self.lbl_source.setText("Car")
|
||||
elif idx == 2:
|
||||
self.lbl_source.setText("Maps")
|
||||
Loading…
x
Reference in New Issue
Block a user