diff --git a/v1/main.py b/v1/main.py index f052cc9..f81712c 100644 --- a/v1/main.py +++ b/v1/main.py @@ -1,7 +1,9 @@ import sys + +from PyQt5.QtSvg import QSvgRenderer from PyQt5.QtWidgets import QApplication, QMainWindow, QStackedWidget, QHBoxLayout, QWidget, QMessageBox, QPushButton, \ QLabel, QVBoxLayout, QFrame, QSizePolicy -from PyQt5.QtCore import Qt, QPoint +from PyQt5.QtCore import Qt, QPoint, QSize, QByteArray from views.login import LoginPage from views.nav import NavBar from views.home import Home @@ -9,13 +11,13 @@ from views.word_to_pdf import WordToPDFPage from views.pdf_tools_page import PDFToolsPage from views.app_center import AppCenter from views.history import HistoryPage -from PyQt5.QtGui import QPalette, QColor, QFont +from PyQt5.QtGui import QPalette, QColor, QFont, QPixmap, QIcon, QPainter from styles.styles import STYLES_TXT class CustomTitleBar(QWidget): - """自定义标题栏控件""" + """现代化标题栏控件(直接设置SVG图标)""" def __init__(self, parent=None): super().__init__(parent) @@ -24,55 +26,212 @@ class CustomTitleBar(QWidget): self.drag_position = QPoint() self.setObjectName("customTitleBar") self.init_ui() + self.set_style() + self.setMinimumHeight(48) def init_ui(self): """初始化标题栏UI""" layout = QHBoxLayout(self) layout.setContentsMargins(15, 8, 15, 8) - layout.setSpacing(12) + layout.setSpacing(8) - # 添加应用图标和标题 + # 应用图标和标题 + title_container = QWidget() + title_layout = QHBoxLayout(title_container) + title_layout.setContentsMargins(0, 0, 0, 0) + title_layout.setSpacing(10) + + # 应用图标(使用纯CSS实现) + icon_label = QLabel() + icon_label.setObjectName("appIcon") + icon_label.setFixedSize(24, 24) + + # 应用标题 self.title_label = QLabel("奶酪云工具箱") self.title_label.setObjectName("titleLabel") - self.title_label.setFont(QFont("Microsoft YaHei UI", 12, QFont.Bold)) - self.title_label.setAlignment(Qt.AlignCenter) + self.title_label.setFont(QFont("Microsoft YaHei UI", 10, QFont.DemiBold)) - # 添加拖拽区域(占位区域) + # 版本号 + version_label = QLabel("v2.1.0") + version_label.setObjectName("versionLabel") + version_label.setFont(QFont("Microsoft YaHei UI", 8)) + + title_layout.addWidget(icon_label) + title_layout.addWidget(self.title_label) + title_layout.addWidget(version_label) + + # 拖拽区域 self.drag_area = QWidget() - self.drag_area.setObjectName("dragArea") self.drag_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) + self.drag_area.setObjectName("dragArea") - # 添加窗口控制按钮 - self.minimize_btn = QPushButton("—") + # 窗口控制按钮 + buttons_container = QWidget() + buttons_layout = QHBoxLayout(buttons_container) + buttons_layout.setContentsMargins(0, 0, 0, 0) + buttons_layout.setSpacing(4) + + # 最小化按钮(直接设置SVG) + self.minimize_btn = QPushButton() self.minimize_btn.setObjectName("minimizeBtn") - self.minimize_btn.setFixedSize(30, 30) + self.minimize_btn.setFixedSize(34, 28) + self.minimize_btn.setToolTip("最小化") self.minimize_btn.clicked.connect(lambda: self.parent.showMinimized()) + self.minimize_btn.setIcon(self.create_svg_icon(""" + + + + """, "#8A92A6")) - self.maximize_btn = QPushButton("□") + # 最大化按钮(直接设置SVG) + self.maximize_btn = QPushButton() self.maximize_btn.setObjectName("maximizeBtn") - self.maximize_btn.setFixedSize(30, 30) + self.maximize_btn.setFixedSize(34, 28) + self.maximize_btn.setToolTip("最大化") self.maximize_btn.clicked.connect(self.toggle_maximize) + self.maximize_btn.setIcon(self.create_svg_icon(""" + + + + """, "#8A92A6")) - self.close_btn = QPushButton("×") + # 关闭按钮(直接设置SVG) + self.close_btn = QPushButton() self.close_btn.setObjectName("closeBtn") - self.close_btn.setFixedSize(30, 30) + self.close_btn.setFixedSize(34, 28) + self.close_btn.setToolTip("关闭") self.close_btn.clicked.connect(self.parent.close) + self.close_btn.setIcon(self.create_svg_icon(""" + + + + """, "#8A92A6")) - # 将控件添加到布局中 - layout.addWidget(self.title_label) + buttons_layout.addWidget(self.minimize_btn) + buttons_layout.addWidget(self.maximize_btn) + buttons_layout.addWidget(self.close_btn) + + # 添加所有组件 + layout.addWidget(title_container) layout.addWidget(self.drag_area) - layout.addWidget(self.minimize_btn) - layout.addWidget(self.maximize_btn) - layout.addWidget(self.close_btn) + layout.addWidget(buttons_container) + + def create_svg_icon(self, svg_data, color): + """从SVG数据创建QIcon""" + # 创建SVG字节数组 + svg_data = svg_data.replace(' + + + """, "#8A92A6")) else: self.parent.showMaximized() - self.maximize_btn.setText("⬜") + # 更新最大化按钮图标为还原状态 + self.maximize_btn.setIcon(self.create_svg_icon(""" + + + + + + """, "#8A92A6")) def mousePressEvent(self, event): """鼠标按下事件处理""" @@ -92,7 +251,6 @@ class CustomTitleBar(QWidget): self.toggle_maximize() event.accept() - class MainWindow(QMainWindow): def __init__(self): super().__init__() diff --git a/v1/resources.qrc b/v1/resources.qrc new file mode 100644 index 0000000..c470ab1 --- /dev/null +++ b/v1/resources.qrc @@ -0,0 +1,8 @@ + + + minimize.svg + maximize.svg + restore.svg + close.svg + + \ No newline at end of file diff --git a/v1/resources/close.svg b/v1/resources/close.svg new file mode 100644 index 0000000..2dc8c78 --- /dev/null +++ b/v1/resources/close.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/v1/resources/icon.png b/v1/resources/icon.png new file mode 100644 index 0000000..3cdfe5e Binary files /dev/null and b/v1/resources/icon.png differ diff --git a/v1/resources/maximize.svg b/v1/resources/maximize.svg new file mode 100644 index 0000000..2762754 --- /dev/null +++ b/v1/resources/maximize.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/v1/resources/minimize.svg b/v1/resources/minimize.svg new file mode 100644 index 0000000..cc61673 --- /dev/null +++ b/v1/resources/minimize.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/v1/resources/restore.svg b/v1/resources/restore.svg new file mode 100644 index 0000000..8107518 --- /dev/null +++ b/v1/resources/restore.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/v1/styles/styles.py b/v1/styles/styles.py index 7e68fe1..12e6fff 100644 --- a/v1/styles/styles.py +++ b/v1/styles/styles.py @@ -8,6 +8,18 @@ QWidget { border: none; } +/* 最小化、最大化按钮悬停状态 */ +QPushButton#minimizeBtn:hover, +QPushButton#maximizeBtn:hover { + background-color: rgba(255, 255, 255, 0.1); +} + +/* 关闭按钮悬停状态 */ +QPushButton#closeBtn:hover { + background-color: #E85050; + color: white; /* 使图标变为白色 */ +} + /* 输入框 */ QLineEdit { background-color: #2d3748; diff --git a/v1/views/app_center.py b/v1/views/app_center.py index 551d510..84b4190 100644 --- a/v1/views/app_center.py +++ b/v1/views/app_center.py @@ -616,7 +616,8 @@ class AppCenter(QWidget): self.apps_container.setVisible(True) # 计算列数并显示应用卡片 - cards_per_row = max(1, self.width() // 350) if self.width() > 0 else 3 + # cards_per_row = max(1, self.width() // 350) if self.width() > 0 else 3 + cards_per_row = 3 self.display_apps(self.apps, cards_per_row) # 重置动画状态 @@ -648,7 +649,8 @@ class AppCenter(QWidget): filtered_apps.append(app) # 计算列数并显示过滤后的应用 - cards_per_row = max(1, self.width() // 350) if self.width() > 0 else 3 + # cards_per_row = max(1, self.width() // 350) if self.width() > 0 else 3 + cards_per_row = 3 self.display_apps(filtered_apps, cards_per_row) def filter_by_category(self, category): diff --git a/v1/views/home.py b/v1/views/home.py index c60f22b..582b0fd 100644 --- a/v1/views/home.py +++ b/v1/views/home.py @@ -195,41 +195,41 @@ class Home(QWidget): "color": ("#6366F1", "#4F46E5"), # 紫色 "icon": "word_to_pdf" }, - { - "id": "ocr", - "title": "OCR文字识别", - "desc": "从图片中提取文字内容", - "color": ("#4ADE80", "#22C55E"), # 绿色 - "icon": "ocr" - }, - { - "id": "image_convert", - "title": "图片格式转换", - "desc": "转换图像文件格式并优化", - "color": ("#F97316", "#EA580C"), # 橙色 - "icon": "image_convert" - }, + # { + # "id": "ocr", + # "title": "OCR文字识别", + # "desc": "从图片中提取文字内容", + # "color": ("#4ADE80", "#22C55E"), # 绿色 + # "icon": "ocr" + # }, + # { + # "id": "image_convert", + # "title": "图片格式转换", + # "desc": "转换图像文件格式并优化", + # "color": ("#F97316", "#EA580C"), # 橙色 + # "icon": "image_convert" + # }, { "id": "pdf_merge", - "title": "PDF合并工具", - "desc": "合并多个PDF文件为一个", + "title": "PDF工具", + "desc": "合并多个PDF文件为一个,拆分PDF文件为多个文档", "color": ("#8B5CF6", "#7C3AED"), # 紫色 "icon": "pdf_merge" }, - { - "id": "pdf_split", - "title": "PDF拆分工具", - "desc": "拆分PDF文件为多个文档", - "color": ("#EC4899", "#DB2777"), # 粉色 - "icon": "pdf_split" - }, - { - "id": "video_compress", - "title": "视频压缩", - "desc": "减小视频文件大小", - "color": ("#3B82F6", "#2563EB"), # 蓝色 - "icon": "video_compress" - } + # { + # "id": "pdf_split", + # "title": "PDF拆分工具", + # "desc": "拆分PDF文件为多个文档", + # "color": ("#EC4899", "#DB2777"), # 粉色 + # "icon": "pdf_split" + # }, + # { + # "id": "video_compress", + # "title": "视频压缩", + # "desc": "减小视频文件大小", + # "color": ("#3B82F6", "#2563EB"), # 蓝色 + # "icon": "video_compress" + # } ] # 每行显示3张卡片