переделай код чтобы был стильный современный красочный, но минималистичный дизайн со сменой тем

from PyQt5.QtWidgets import (
QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout,
QLineEdit, QCheckBox, QSpinBox, QTabWidget, QMessageBox,
QApplication, QComboBox, QStyleFactory
)
from PyQt5.QtGui import QPalette, QColor, QFont
from PyQt5.QtCore import Qt, QTimer
from password_manager import PasswordManager
from password_generator import PasswordGenerator
from password_checker import PasswordChecker
import sys

class MainWindow(QWidget):
def init(self):
super().init()
self.setWindowTitle('Password Manager')
self.setGeometry(100, 100, 800, 450)
self.password_manager = PasswordManager()
self.init_ui()

def init_ui(self):
# Добавляем выбор темы
theme_layout = QHBoxLayout()
theme_label = QLabel('Выбор темы:')
self.theme_combo = QComboBox()
self.theme_combo.addItems(['Светлая', 'Тёмная', 'Чёрная'])
self.theme_combo.currentIndexChanged.connect(self.change_theme)
theme_layout.addWidget(theme_label)
theme_layout.addWidget(self.theme_combo)

self.tabs = QTabWidget()
self.tabs.addTab(self.generate_tab(), 'Генератор паролей')
self.tabs.addTab(self.manage_tab(), 'Управление паролями')
self.tabs.addTab(self.check_tab(), 'Проверка пароля')

main_layout = QVBoxLayout()
main_layout.addLayout(theme_layout)
main_layout.addWidget(self.tabs)
self.setLayout(main_layout)

# Устанавливаем начальную тему
self.change_theme(0)

def change_theme(self, index):
palette = QPalette()
if index == 0: # Светлая тема
QApplication.setStyle(QStyleFactory.create('Fusion'))
palette.setColor(QPalette.Window, QColor(240, 240, 240))
palette.setColor(QPalette.WindowText, Qt.black)
palette.setColor(QPalette.Base, QColor(255, 255, 255))
palette.setColor(QPalette.AlternateBase, QColor(225, 225, 225))
palette.setColor(QPalette.ToolTipBase, Qt.black)
palette.setColor(QPalette.ToolTipText, Qt.black)
palette.setColor(QPalette.Text, Qt.black)
palette.setColor(QPalette.Button, QColor(240, 240, 240))
palette.setColor(QPalette.ButtonText, Qt.black)
palette.setColor(QPalette.BrightText, Qt.red)
palette.setColor(QPalette.Link, QColor(42, 130, 218))
elif index == 1: # Тёмная тема
QApplication.setStyle(QStyleFactory.create('Fusion'))
palette.setColor(QPalette.Window, QColor(53, 53, 53))
palette.setColor(QPalette.WindowText, Qt.white)
palette.setColor(QPalette.Base, QColor(42, 42, 42))
palette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
palette.setColor(QPalette.ToolTipBase, Qt.white)
palette.setColor(QPalette.ToolTipText, Qt.white)
palette.setColor(QPalette.Text, Qt.white)
palette.setColor(QPalette.Button, QColor(53, 53, 53))
palette.setColor(QPalette.ButtonText, Qt.white)
palette.setColor(QPalette.BrightText, Qt.red)
palette.setColor(QPalette.Link, QColor(42, 130, 218))
elif index == 2: # Чёрная тема
QApplication.setStyle(QStyleFactory.create('Fusion'))
palette.setColor(QPalette.Window, QColor(0, 0, 0))
palette.setColor(QPalette.WindowText, Qt.white)
palette.setColor(QPalette.Base, QColor(10, 10, 10))
palette.setColor(QPalette.AlternateBase, QColor(20, 20, 20))
palette.setColor(QPalette.ToolTipBase, Qt.white)
palette.setColor(QPalette.ToolTipText, Qt.white)
palette.setColor(QPalette.Text, Qt.white)
palette.setColor(QPalette.Button, QColor(0, 0, 0))
palette.setColor(QPalette.ButtonText, Qt.white)
palette.setColor(QPalette.BrightText, Qt.red)
palette.setColor(QPalette.Link, QColor(42, 130, 218))
QApplication.setPalette(palette)
# Дополнительные стили для привлекательности
self.setStyleSheet("""
QLabel {
font-size: 14px;
}
QPushButton {
font-size: 14px;
padding: 5px;
}
QLineEdit {
font-size: 14px;
padding: 5px;
}
QCheckBox {
font-size: 14px;
}
QComboBox {
font-size: 14px;
}
QSpinBox {
font-size: 14px;
}
QTabWidget::pane {
border: 1px solid #444;
}
QTabBar::tab {
background: #555;
color: white;
padding: 10px;
}
QTabBar::tab:selected {
background: #777;
}
""")

def generate_tab(self):
tab = QWidget()
layout = QVBoxLayout()

length_layout = QHBoxLayout()
length_label = QLabel('Длина пароля:')
self.length_spin = QSpinBox()
self.length_spin.setRange(6, 128)
self.length_spin.setValue(12)
length_layout.addWidget(length_label)
length_layout.addWidget(self.length_spin)
length_layout.addStretch()

options_layout = QHBoxLayout()
self.uppercase_cb = QCheckBox('Верхний регистр')
self.lowercase_cb = QCheckBox('Нижний регистр')
self.digits_cb = QCheckBox('Цифры')
self.symbols_cb = QCheckBox('Символы')
self.exclude_ambiguous_cb = QCheckBox('Без неоднозначных')
self.uppercase_cb.setChecked(True)
self.lowercase_cb.setChecked(True)
self.digits_cb.setChecked(True)
self.symbols_cb.setChecked(True)
options_layout.addWidget(self.uppercase_cb)
options_layout.addWidget(self.lowercase_cb)
options_layout.addWidget(self.digits_cb)
options_layout.addWidget(self.symbols_cb)
options_layout.addWidget(self.exclude_ambiguous_cb)

self.password_display = QLineEdit()
self.password_display.setEchoMode(QLineEdit.Password)
self.password_display.setReadOnly(True)
self.password_display.installEventFilter(self)

generate_btn = QPushButton('Сгенерировать')
generate_btn.clicked.connect(self.generate_password)
copy_btn = QPushButton('Скопировать')
copy_btn.clicked.connect(self.copy_password)

btn_layout = QHBoxLayout()
btn_layout.addWidget(generate_btn)
btn_layout.addWidget(copy_btn)
btn_layout.addStretch()

layout.addLayout(length_layout)
layout.addLayout(options_layout)
layout.addWidget(self.password_display)
layout.addLayout(btn_layout)
layout.addStretch()
tab.setLayout(layout)
return tab

def generate_password(self):
generator = PasswordGenerator()
length = self.length_spin.value()
options = {
'uppercase': self.uppercase_cb.isChecked(),
'lowercase': self.lowercase_cb.isChecked(),
'digits': self.digits_cb.isChecked(),
'symbols': self.symbols_cb.isChecked(),
'exclude_ambiguous': self.exclude_ambiguous_cb.isChecked()
}
password = generator.generate(length, **options)
self.password_display.setText(password)

def copy_password(self):
password = self.password_display.text()
if password:
from PyQt5.QtGui import QClipboard
clipboard = QApplication.clipboard()
clipboard.setText(password)
QTimer.singleShot(5000, lambda: clipboard.clear())

def manage_tab(self):
tab = QWidget()
layout = QVBoxLayout()
info_label = QLabel('Управление паролями будет доступно в будущих версиях.')
layout.addWidget(info_label)
layout.addStretch()
tab.setLayout(layout)
return tab

def check_tab(self):
tab = QWidget()
layout = QVBoxLayout()
self.check_input = QLineEdit()
self.check_input.setEchoMode(QLineEdit.Password)
self.check_input.installEventFilter(self)
check_btn = QPushButton('Проверить пароль')
check_btn.clicked.connect(self.check_password)

self.check_result = QLabel('')
copy_btn = QPushButton('Скопировать')
copy_btn.clicked.connect(self.copy_checked_password)

layout.addWidget(self.check_input)
layout.addWidget(check_btn)
layout.addWidget(self.check_result)
layout.addWidget(copy_btn)
layout.addStretch()
tab.setLayout(layout)
return tab

def check_password(self):
password = self.check_input.text()
if password:
checker = PasswordChecker()
strength = checker.check_strength(password)
leaked = checker.check_leak_async(password)
self.check_result.setText(f'Надежность: {strength}\nУтечки: {"Найдены" if leaked else "Не обнаружены"}')

def copy_checked_password(self):
password = self.check_input.text()
if password:
from PyQt5.QtGui import QClipboard
clipboard = QApplication.clipboard()
clipboard.setText(password)
QTimer.singleShot(5000, lambda: clipboard.clear())

def eventFilter(self, source, event):
if event.type() == event.Enter and isinstance(source, QLineEdit):
source.setEchoMode(QLineEdit.Normal)
elif event.type() == event.Leave and isinstance(source, QLineEdit):
source.setEchoMode(QLineEdit.Password)
return super().eventFilter(source, event)