优化界面提示:1. 统一所有提示框样式,使用自定义美观对话框 2. 添加复制按钮功能,方便用户操作 3. 优化未激活会员时的提示信息展示

This commit is contained in:
huangzhenpc
2025-02-12 14:57:23 +08:00
parent 4531f12c0d
commit 4e11deb530
2 changed files with 284 additions and 57 deletions

View File

@@ -6,7 +6,7 @@ from PIL import Image
from PyQt5.QtWidgets import (QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QLabel, QLineEdit, QPushButton, QFrame, QTextEdit,
QMessageBox, QApplication, QSystemTrayIcon, QMenu,
QDialog, QProgressBar)
QDialog, QProgressBar, QStyle)
from PyQt5.QtCore import Qt, QTimer, QThread, pyqtSignal
from PyQt5.QtGui import QIcon, QPixmap
@@ -162,6 +162,23 @@ class MainWindow(QMainWindow):
# 激活区域
activation_frame = QFrame()
activation_layout = QVBoxLayout(activation_frame)
# 使用说明
usage_label = QLabel()
usage_label.setText("使用说明:\n\n1. 输入激活码并点击激活\n2. 激活成功后点击\"刷新Cursor编辑器授权\"即可正常使用\n3. 如果刷新无效,请点击\"突破Cursor0.45.x限制\"\n4. 建议点击\"禁用Cursor版本更新\"保持长期稳定")
usage_label.setStyleSheet("""
QLabel {
color: #6c757d;
font-size: 13px;
padding: 10px;
background-color: #f8f9fa;
border-radius: 4px;
border: 1px solid #dee2e6;
}
""")
activation_layout.addWidget(usage_label)
# 激活码输入区域
activation_layout.addWidget(QLabel("激活(叠加)会员,多个激活码可叠加整体时长"))
input_frame = QFrame()
input_layout = QHBoxLayout(input_frame)
@@ -274,23 +291,92 @@ class MainWindow(QMainWindow):
"""激活账号"""
code = self.activation_edit.text().strip()
if not code:
msg = QMessageBox(self)
# 创建自定义消息框
msg = QDialog(self)
msg.setWindowTitle("提示")
msg.setText("请输入激活码")
msg.setIcon(QMessageBox.Warning)
msg.setStyleSheet("""
QMessageBox {
background-color: #f8f9fa;
min-width: 400px;
padding: 20px;
}
QMessageBox QLabel {
msg.setFixedWidth(400)
msg.setWindowFlags(msg.windowFlags() & ~Qt.WindowContextHelpButtonHint)
# 创建布局
layout = QVBoxLayout()
# 添加图标和文本
icon_label = QLabel()
icon_label.setPixmap(self.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap(32, 32))
icon_label.setAlignment(Qt.AlignCenter)
layout.addWidget(icon_label)
text_label = QLabel("请输入激活码")
text_label.setAlignment(Qt.AlignCenter)
text_label.setStyleSheet("font-size: 14px; font-weight: bold; color: #333333; padding: 10px;")
layout.addWidget(text_label)
# 添加购买信息
info_text = "获取会员激活码,请通过以下方式:\n\n" \
"• 官方自助网站cursor.nosqli.com\n" \
"• 微信客服behikcigar\n" \
"• 闲鱼店铺xxx\n\n" \
"————————————————————\n" \
"诚招代理商,欢迎加盟合作!"
info_label = QLabel(info_text)
info_label.setAlignment(Qt.AlignLeft)
info_label.setStyleSheet("""
QLabel {
color: #333333;
font-size: 14px;
min-height: 40px;
padding: 10px;
qproperty-alignment: AlignCenter;
padding: 15px;
background-color: #f8f9fa;
border-radius: 4px;
border: 1px solid #dee2e6;
margin: 10px;
}
""")
layout.addWidget(info_label)
# 添加复制按钮区域
btn_layout = QHBoxLayout()
# 复制网站按钮
copy_web_btn = QPushButton("复制网站")
copy_web_btn.clicked.connect(lambda: self.copy_and_show_tip(msg, "cursor.nosqli.com", "网站地址已复制到剪贴板"))
copy_web_btn.setStyleSheet("""
QPushButton {
background-color: #0d6efd;
color: white;
border: none;
padding: 8px 15px;
border-radius: 4px;
font-size: 13px;
}
QPushButton:hover {
background-color: #0b5ed7;
}
""")
btn_layout.addWidget(copy_web_btn)
# 复制微信按钮
copy_wx_btn = QPushButton("复制微信")
copy_wx_btn.clicked.connect(lambda: self.copy_and_show_tip(msg, "behikcigar", "微信号已复制到剪贴板"))
copy_wx_btn.setStyleSheet("""
QPushButton {
background-color: #198754;
color: white;
border: none;
padding: 8px 15px;
border-radius: 4px;
font-size: 13px;
}
QPushButton:hover {
background-color: #157347;
}
""")
btn_layout.addWidget(copy_wx_btn)
# 确定按钮
ok_btn = QPushButton("确定")
ok_btn.clicked.connect(msg.accept)
ok_btn.setStyleSheet("""
QPushButton {
background-color: #0d6efd;
color: white;
@@ -299,12 +385,15 @@ class MainWindow(QMainWindow):
border-radius: 4px;
font-size: 13px;
min-width: 100px;
margin: 10px;
}
QPushButton:hover {
background-color: #0b5ed7;
}
""")
btn_layout.addWidget(ok_btn)
layout.addLayout(btn_layout)
msg.setLayout(layout)
msg.exec_()
return
@@ -355,6 +444,11 @@ class MainWindow(QMainWindow):
""")
msg.exec_()
def copy_and_show_tip(self, parent, text, tip):
"""复制文本并显示提示"""
QApplication.clipboard().setText(text)
QMessageBox.information(parent, "提示", tip)
def on_activation_complete(self, result):
"""激活完成回调"""
success, data = result
@@ -579,45 +673,92 @@ class MainWindow(QMainWindow):
return self.check_status()
if not self._activation_status:
msg = QMessageBox(self)
# 创建自定义消息框
msg = QDialog(self)
msg.setWindowTitle("会员未激活")
msg.setText("您还未激活会员或会员已过期")
msg.setInformativeText(
"获取会员激活码,请通过以下方式:\n\n"
" • 官方自助网站cursor.nosqli.com\n"
" • 微信客服behikcigar\n"
" • 闲鱼店铺xxx\n\n"
"————————————————————\n"
"诚招代理商,欢迎加盟合作!"
)
msg.setIcon(QMessageBox.Information)
msg.setStyleSheet("""
QMessageBox {
background-color: #f8f9fa;
min-width: 400px;
padding: 20px;
}
QMessageBox QLabel {
msg.setFixedWidth(400)
msg.setWindowFlags(msg.windowFlags() & ~Qt.WindowContextHelpButtonHint)
# 创建布局
layout = QVBoxLayout()
# 添加图标和文本
icon_label = QLabel()
icon_label.setPixmap(self.style().standardIcon(QStyle.SP_MessageBoxWarning).pixmap(32, 32))
icon_label.setAlignment(Qt.AlignCenter)
layout.addWidget(icon_label)
text_label = QLabel("您还未激活会员或会员已过期")
text_label.setAlignment(Qt.AlignCenter)
text_label.setStyleSheet("font-size: 14px; font-weight: bold; color: #333333; padding: 10px;")
layout.addWidget(text_label)
# 添加购买信息
info_text = "获取会员激活码,请通过以下方式:\n\n" \
"• 官方自助网站cursor.nosqli.com\n" \
"• 微信客服behikcigar\n" \
"• 闲鱼店铺xxx\n\n" \
"————————————————————\n" \
"诚招代理商,欢迎加盟合作!"
info_label = QLabel(info_text)
info_label.setAlignment(Qt.AlignLeft)
info_label.setStyleSheet("""
QLabel {
color: #333333;
font-size: 14px;
padding: 10px;
padding: 15px;
background-color: #f8f9fa;
border-radius: 4px;
border: 1px solid #dee2e6;
margin: 10px;
}
QMessageBox QLabel:first-child {
font-weight: bold;
font-size: 16px;
color: #0d6efd;
qproperty-alignment: AlignCenter;
""")
layout.addWidget(info_label)
# 添加复制按钮区域
btn_layout = QHBoxLayout()
# 复制网站按钮
copy_web_btn = QPushButton("复制网站")
copy_web_btn.clicked.connect(lambda: self.copy_and_show_tip(msg, "cursor.nosqli.com", "网站地址已复制到剪贴板"))
copy_web_btn.setStyleSheet("""
QPushButton {
background-color: #0d6efd;
color: white;
border: none;
padding: 8px 15px;
border-radius: 4px;
font-size: 13px;
}
QMessageBox QLabel:last-child {
font-family: 'Microsoft YaHei', sans-serif;
font-size: 14px;
color: #333333;
padding: 15px;
margin: 5px;
line-height: 1.8;
qproperty-alignment: AlignLeft;
QPushButton:hover {
background-color: #0b5ed7;
}
""")
btn_layout.addWidget(copy_web_btn)
# 复制微信按钮
copy_wx_btn = QPushButton("复制微信")
copy_wx_btn.clicked.connect(lambda: self.copy_and_show_tip(msg, "behikcigar", "微信号已复制到剪贴板"))
copy_wx_btn.setStyleSheet("""
QPushButton {
background-color: #198754;
color: white;
border: none;
padding: 8px 15px;
border-radius: 4px;
font-size: 13px;
}
QPushButton:hover {
background-color: #157347;
}
""")
btn_layout.addWidget(copy_wx_btn)
# 确定按钮
ok_btn = QPushButton("确定")
ok_btn.clicked.connect(msg.accept)
ok_btn.setStyleSheet("""
QPushButton {
background-color: #0d6efd;
color: white;
@@ -626,12 +767,15 @@ class MainWindow(QMainWindow):
border-radius: 4px;
font-size: 13px;
min-width: 100px;
margin: 10px;
}
QPushButton:hover {
background-color: #0b5ed7;
}
""")
btn_layout.addWidget(ok_btn)
layout.addLayout(btn_layout)
msg.setLayout(layout)
msg.exec_()
return self._activation_status
@@ -652,7 +796,7 @@ class MainWindow(QMainWindow):
except Exception as e:
self.hide_loading_dialog()
QMessageBox.critical(self, "错误", f"刷新授权失败: {str(e)}")
self.show_custom_error("刷新授权失败", str(e))
def on_refresh_auth_complete(self, result):
"""刷新授权完成回调"""
@@ -662,11 +806,11 @@ class MainWindow(QMainWindow):
if isinstance(data, tuple):
success, message = data
if success:
QMessageBox.information(self, "成功", message)
self.show_custom_message("成功", "刷新授权成功", message, QStyle.SP_DialogApplyButton, "#198754")
else:
QMessageBox.critical(self, "失败", message)
self.show_custom_error("刷新授权失败", message)
else:
QMessageBox.critical(self, "错误", f"刷新授权失败: {data}")
self.show_custom_error("刷新授权失败", str(data))
def disable_cursor_update(self):
"""禁用Cursor更新"""
@@ -676,15 +820,98 @@ class MainWindow(QMainWindow):
try:
success, message = self.switcher.disable_cursor_update()
if success:
QMessageBox.information(self, "成功", message)
self.show_custom_message("成功", "禁用更新成功", message, QStyle.SP_DialogApplyButton, "#198754")
else:
QMessageBox.critical(self, "失败", message)
self.show_custom_error("禁用更新失败", message)
except Exception as e:
QMessageBox.critical(self, "错误", f"禁用更新失败: {str(e)}")
self.show_custom_error("禁用更新失败", str(e))
def dummy_function(self):
"""突破版本限制"""
if not self.check_activation_status():
return
QMessageBox.information(self, "提示", "此功能暂未实现")
self.show_custom_message(
"提示",
"功能未实现",
"此功能暂未实现,请等待后续更新。",
QStyle.SP_MessageBoxInformation,
"#0d6efd"
)
def show_custom_message(self, title, header, message, icon_type, color):
"""显示自定义消息框"""
msg = QDialog(self)
msg.setWindowTitle(title)
msg.setFixedWidth(400)
msg.setWindowFlags(msg.windowFlags() & ~Qt.WindowContextHelpButtonHint)
layout = QVBoxLayout()
# 添加图标
icon_label = QLabel()
icon_label.setPixmap(self.style().standardIcon(icon_type).pixmap(32, 32))
icon_label.setAlignment(Qt.AlignCenter)
layout.addWidget(icon_label)
# 添加标题
text_label = QLabel(header)
text_label.setAlignment(Qt.AlignCenter)
text_label.setStyleSheet(f"""
font-size: 14px;
font-weight: bold;
color: {color};
padding: 10px;
""")
layout.addWidget(text_label)
# 添加详细信息
info_label = QLabel(message)
info_label.setAlignment(Qt.AlignLeft)
info_label.setWordWrap(True)
info_label.setStyleSheet("""
QLabel {
color: #333333;
font-size: 14px;
padding: 15px;
background-color: #f8f9fa;
border-radius: 4px;
border: 1px solid #dee2e6;
margin: 10px;
}
""")
layout.addWidget(info_label)
# 确定按钮
btn_layout = QHBoxLayout()
ok_btn = QPushButton("确定")
ok_btn.clicked.connect(msg.accept)
ok_btn.setStyleSheet(f"""
QPushButton {{
background-color: {color};
color: white;
border: none;
padding: 8px 25px;
border-radius: 4px;
font-size: 13px;
min-width: 100px;
}}
QPushButton:hover {{
background-color: {color.replace('fd', 'd7') if 'fd' in color else color.replace('54', '47')};
}}
""")
btn_layout.addWidget(ok_btn)
layout.addLayout(btn_layout)
msg.setLayout(layout)
msg.exec_()
def show_custom_error(self, header, message):
"""显示自定义错误消息框"""
self.show_custom_message(
"错误",
header,
message,
QStyle.SP_MessageBoxCritical,
"#dc3545"
)

View File

@@ -1 +1 @@
3.3.2
3.3.4