1 #include <QApplication>
2 #include <QMainWindow>
3 #include <QVBoxLayout>
4 #include <QHBoxLayout>
5 #include <QPushButton>
6 #include <QLabel>
7 #include <QFrame>
8 #include <QTabWidget>
9 #include <QListWidget>
10 #include <QProgressBar>
11 #include <QSlider>
12 #include <QCheckBox>
13 #include <QGroupBox>
14 #include <QStackedWidget>
15 #include <QMouseEvent>
16 // 火绒黑色风格样式表
17 const QString HUORONG_DARK_STYLE = R"(
18 /* ===== 全局样式 ===== */
19 * {
20 font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
21 outline: none;
22 }
23 QWidget {
24 background-color: #1e1e1f;
25 color: #d0d0d0;
26 }
27 /* ===== 火绒颜色变量 ===== */
28 :root {
29 --primary: #2d8cf0; /* 火绒主蓝色 */
30 --primary-dark: #1e6bb8;
31 --primary-light: #5cadff;
32 --success: #19be6b; /* 安全绿色 */
33 --warning: #ff9900; /* 警告橙色 */
34 --danger: #ed3f14; /* 危险红色 */
35 --info: #2db7f5;
36 /* 深色主题颜色 */
37 --bg-primary: #1e1e1f; /* 主背景 */
38 --bg-secondary: #252526; /* 次级背景 */
39 --bg-tertiary: #2a2a2b; /* 三级背景 */
40 --text-primary: #e8e8e8; /* 主文字 */
41 --text-secondary: #b0b0b0; /* 次级文字 */
42 --text-muted: #808080; /* 弱化文字 */
43 --border: #3a3a3a; /* 边框色 */
44 --border-light: #4a4a4a;
45 --border-dark: #2a2a2a;
46 }
47 /* ===== 主窗口样式 ===== */
48 QMainWindow {
49 background-color: var(--bg-primary);
50 border: 1px solid var(--border-dark);
51 }
52 /* ===== 标题栏样式 ===== */
53 TitleBar {
54 background-color: var(--bg-secondary);
55 border-bottom: 1px solid var(--border-dark);
56 height: 40px;
57 }
58 TitleBar QLabel {
59 font-size: 14px;
60 font-weight: bold;
61 color: var(--text-primary);
62 padding-left: 15px;
63 }
64 TitleButton {
65 background-color: transparent;
66 border: none;
67 color: var(--text-secondary);
68 padding: 8px 12px;
69 font-size: 12px;
70 }
71 TitleButton:hover {
72 background-color: var(--bg-tertiary);
73 color: var(--text-primary);
74 }
75 TitleButton#closeButton:hover {
76 background-color: #e74c3c;
77 color: white;
78 }
79 /* ===== 左侧导航栏样式 ===== */
80 NavigationBar {
81 background-color: var(--bg-secondary);
82 border-right: 1px solid var(--border-dark);
83 width: 200px;
84 }
85 NavButton {
86 background-color: transparent;
87 border: none;
88 color: var(--text-secondary);
89 text-align: left;
90 padding: 15px 20px;
91 font-size: 13px;
92 border-left: 3px solid transparent;
93 }
94 NavButton:hover {
95 background-color: var(--bg-tertiary);
96 color: var(--text-primary);
97 }
98 NavButton:checked {
99 background-color: var(--bg-primary);
100 color: var(--primary);
101 border-left: 3px solid var(--primary);
102 font-weight: 500;
103 }
104 NavButton Icon {
105 margin-right: 10px;
106 width: 18px;
107 height: 18px;
108 }
109 /* ===== 内容区域样式 ===== */
110 ContentArea {
111 background-color: var(--bg-primary);
112 margin: 0;
113 }
114 /* ===== 状态卡片样式 ===== */
115 StatusCard {
116 background-color: var(--bg-secondary);
117 border: 1px solid var(--border);
118 border-radius: 6px;
119 margin: 15px;
120 }
121 StatusCard#safe {
122 border-left: 4px solid var(--success);
123 }
124 StatusCard#warning {
125 border-left: 4px solid var(--warning);
126 }
127 StatusCard#danger {
128 border-left: 4px solid var(--danger);
129 }
130 StatusIcon {
131 width: 32px;
132 height: 32px;
133 margin: 15px;
134 }
135 StatusTitle {
136 font-size: 16px;
137 font-weight: 500;
138 color: var(--text-primary);
139 }
140 StatusDesc {
141 font-size: 12px;
142 color: var(--text-muted);
143 margin-top: 5px;
144 }
145 /* ===== 功能卡片样式 ===== */
146 FunctionCard {
147 background-color: var(--bg-secondary);
148 border: 1px solid var(--border);
149 border-radius: 6px;
150 margin: 10px 15px;
151 }
152 CardHeader {
153 background-color: var(--bg-tertiary);
154 border-bottom: 1px solid var(--border);
155 padding: 12px 20px;
156 font-size: 14px;
157 font-weight: 500;
158 color: var(--text-primary);
159 border-top-left-radius: 6px;
160 border-top-right-radius: 6px;
161 }
162 CardContent {
163 padding: 20px;
164 background-color: var(--bg-secondary);
165 border-bottom-left-radius: 6px;
166 border-bottom-right-radius: 6px;
167 }
168 /* ===== 按钮样式 ===== */
169 QPushButton {
170 background-color: var(--bg-tertiary);
171 border: 1px solid var(--border);
172 border-radius: 4px;
173 color: var(--text-primary);
174 padding: 8px 16px;
175 font-size: 12px;
176 font-weight: 400;
177 min-height: 32px;
178 }
179 QPushButton:hover {
180 background-color: #2a2a2b;
181 border-color: var(--border-light);
182 }
183 QPushButton:pressed {
184 background-color: var(--border);
185 border-color: var(--primary);
186 }
187 QPushButton:focus {
188 border-color: var(--primary);
189 }
190 QPushButton:disabled {
191 background-color: var(--bg-secondary);
192 color: var(--text-muted);
193 border-color: var(--border-dark);
194 }
195 QPushButton.primary {
196 background-color: var(--primary);
197 border-color: var(--primary);
198 color: white;
199 font-weight: 500;
200 }
201 QPushButton.primary:hover {
202 background-color: var(--primary-light);
203 border-color: var(--primary-light);
204 }
205 QPushButton.primary:pressed {
206 background-color: var(--primary-dark);
207 border-color: var(--primary-dark);
208 }
209 QPushButton.success {
210 background-color: var(--success);
211 border-color: var(--success);
212 color: white;
213 }
214 QPushButton.success:hover {
215 background-color: #1ed16f;
216 border-color: #1ed16f;
217 }
218 QPushButton.large {
219 padding: 12px 24px;
220 min-height: 40px;
221 font-size: 14px;
222 font-weight: 500;
223 }
224 /* ===== 标签样式 ===== */
225 QLabel {
226 background: transparent;
227 color: var(--text-primary);
228 }
229 QLabel.title {
230 font-size: 16px;
231 font-weight: 500;
232 }
233 QLabel.subtitle {
234 font-size: 14px;
235 color: var(--text-secondary);
236 }
237 QLabel.caption {
238 font-size: 12px;
239 color: var(--text-muted);
240 }
241 /* ===== 进度条样式 ===== */
242 QProgressBar {
243 border: none;
244 background-color: var(--bg-tertiary);
245 border-radius: 10px;
246 text-align: center;
247 color: white;
248 font-size: 11px;
249 height: 20px;
250 }
251 QProgressBar::chunk {
252 background: qlineargradient(x1:0, y1:0, x2:0, y2:1,
253 stop:0 var(--primary), stop:1 var(--primary-dark));
254 border-radius: 10px;
255 }
256 /* ===== 复选框样式 ===== */
257 QCheckBox {
258 spacing: 8px;
259 color: var(--text-primary);
260 font-size: 13px;
261 }
262 QCheckBox::indicator {
263 width: 16px;
264 height: 16px;
265 border: 1px solid var(--border);
266 border-radius: 3px;
267 background-color: var(--bg-tertiary);
268 }
269 QCheckBox::indicator:checked {
270 background-color: var(--primary);
271 border-color: var(--primary);
272 image: url(:/icons/check_white.svg);
273 }
274 QCheckBox:disabled {
275 color: var(--text-muted);
276 }
277 QCheckBox::indicator:disabled {
278 background-color: var(--bg-secondary);
279 border-color: var(--border-dark);
280 }
281 /* ===== 列表样式 ===== */
282 QListWidget {
283 background-color: var(--bg-tertiary);
284 border: 1px solid var(--border);
285 border-radius: 4px;
286 outline: none;
287 }
288 QListWidget::item {
289 background-color: transparent;
290 color: var(--text-primary);
291 padding: 10px 15px;
292 border-bottom: 1px solid var(--border-dark);
293 }
294 QListWidget::item:selected {
295 background-color: var(--primary);
296 color: white;
297 border: none;
298 }
299 QListWidget::item:hover {
300 background-color: var(--bg-secondary);
301 }
302 /* ===== 选项卡样式 ===== */
303 QTabWidget::pane {
304 border: 1px solid var(--border);
305 border-radius: 4px;
306 background-color: var(--bg-secondary);
307 }
308 QTabWidget::tab-bar {
309 alignment: center;
310 }
311 QTabBar::tab {
312 background-color: transparent;
313 color: var(--text-secondary);
314 padding: 8px 16px;
315 border: none;
316 border-bottom: 2px solid transparent;
317 font-size: 13px;
318 }
319 QTabBar::tab:selected {
320 color: var(--primary);
321 border-bottom: 2px solid var(--primary);
322 font-weight: 500;
323 }
324 QTabBar::tab:hover:!selected {
325 color: var(--text-primary);
326 }
327 /* ===== 滚动条样式 ===== */
328 QScrollBar:vertical {
329 background-color: var(--bg-tertiary);
330 width: 10px;
331 border-radius: 5px;
332 }
333 QScrollBar::handle:vertical {
334 background-color: var(--border);
335 border-radius: 5px;
336 min-height: 20px;
337 }
338 QScrollBar::handle:vertical:hover {
339 background-color: var(--border-light);
340 }
341 /* ===== 工具提示样式 ===== */
342 QToolTip {
343 background-color: var(--bg-secondary);
344 color: var(--text-primary);
345 border: 1px solid var(--border);
346 border-radius: 4px;
347 padding: 8px 12px;
348 }
349 )";
350 // 火绒风格主窗口
351 class HuorongMainWindow : public QMainWindow {
352 Q_OBJECT
353 public:
354 HuorongMainWindow(QWidget* parent = nullptr) : QMainWindow(parent) {
355 setupUI();
356 setWindowTitle("火绒安全软件");
357 resize(1000, 700);
358 // 设置窗口属性
359 setWindowFlags(Qt::FramelessWindowHint);
360 setAttribute(Qt::WA_TranslucentBackground);
361 // 应用样式
362 setStyleSheet(HUORONG_DARK_STYLE);
363 }
364 protected:
365 void mousePressEvent(QMouseEvent* event) override {
366 if (event->button() == Qt::LeftButton) {
367 m_dragPosition = event->globalPos() - frameGeometry().topLeft();
368 event->accept();
369 }
370 }
371 void mouseMoveEvent(QMouseEvent* event) override {
372 if (event->buttons() & Qt::LeftButton) {
373 move(event->globalPos() - m_dragPosition);
374 event->accept();
375 }
376 }
377 private:
378 QPoint m_dragPosition;
379 void setupUI() {
380 // 创建中心部件
381 QWidget* centralWidget = new QWidget(this);
382 centralWidget->setObjectName("centralWidget");
383 centralWidget->setStyleSheet(
384 "QWidget#centralWidget {"
385 " "
386 " border: 1px solid #3a3a3a;"
387 " border-radius: 8px;"
388 "}"
389 );
390 setCentralWidget(centralWidget);
391 QVBoxLayout* mainLayout = new QVBoxLayout(centralWidget);
392 mainLayout->setSpacing(0);
393 mainLayout->setContentsMargins(0, 0, 0, 0);
394 // 添加标题栏
395 mainLayout->addWidget(createTitleBar());
396 QVBoxLayout* contentLayout = new QVBoxLayout();
397 contentLayout->setSpacing(0);
398 contentLayout->setContentsMargins(0, 40, 0, 0); // 为标题栏留出空间
399 // 添加内容区域
400 contentLayout->addWidget(createContentArea());
401 mainLayout->addLayout(contentLayout);
402 }
403 QWidget* createTitleBar() {
404 QWidget* titleBar = new QWidget();
405 titleBar->setFixedHeight(40);
406 titleBar->setStyleSheet(
407 "QWidget {"
408 " background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
409 " stop:0 #2a2a2a, stop:1 #252525);"
410 " border-bottom: 1px solid #3a3a3a;"
411 " border-top-left-radius: 8px;"
412 "}"
413 );
414 QHBoxLayout* titleLayout = new QHBoxLayout(titleBar);
415 titleLayout->setContentsMargins(15, 0, 0, 0);
416 titleLayout->setSpacing(0);
417 // 图标和标题
418 QLabel* iconLabel = new QLabel("🔥");
419 iconLabel->setStyleSheet("font-size: 16px; margin-right: 8px;");
420 QLabel* titleLabel = new QLabel("火绒安全");
421 titleLabel->setStyleSheet(
422 "QLabel {"
423 " color: #e8e8e8;"
424 " font-size: 14px;"
425 " font-weight: bold;"
426 "}"
427 );
428 titleLayout->addWidget(iconLabel);
429 titleLayout->addWidget(titleLabel);
430 titleLayout->addStretch();
431 // 标题栏按钮
432 QPushButton* minBtn = createTitleButton("—");
433 QPushButton* maxBtn = createTitleButton("□");
434 QPushButton* closeBtn = createTitleButton("×");
435 closeBtn->setStyleSheet(
436 "QPushButton {"
437 " background: transparent;"
438 " border: none;"
439 " color: #b0b0b0;"
440 " font-size: 16px;"
441 " padding: 8px 12px;"
442 " border-top-right-radius: 8px;"
443 "}"
444 "QPushButton:hover {"
445 " "
446 " color: white;"
447 "}"
448 );
449 connect(minBtn, &QPushButton::clicked, this, &QMainWindow::showMinimized);
450 connect(closeBtn, &QPushButton::clicked, this, &QMainWindow::close);
451 titleLayout->addWidget(minBtn);
452 titleLayout->addWidget(maxBtn);
453 titleLayout->addWidget(closeBtn);
454 return titleBar;
455 }
456 QPushButton* createTitleButton(const QString& text) {
457 QPushButton* btn = new QPushButton(text);
458 btn->setFixedSize(40, 40);
459 btn->setStyleSheet(
460 "QPushButton {"
461 " background: transparent;"
462 " border: none;"
463 " color: #b0b0b0;"
464 " font-size: 14px;"
465 " padding: 8px 12px;"
466 "}"
467 "QPushButton:hover {"
468 " "
469 " color: white;"
470 "}"
471 );
472 return btn;
473 }
474 QWidget* createContentArea() {
475 QWidget* contentArea = new QWidget();
476 contentArea->setStyleSheet("QWidget { }");
477 QHBoxLayout* contentLayout = new QHBoxLayout(contentArea);
478 contentLayout->setSpacing(0);
479 contentLayout->setContentsMargins(0, 0, 0, 0);
480 // 左侧导航栏
481 contentLayout->addWidget(createNavigationBar());
482 // 右侧内容区域
483 contentLayout->addWidget(createMainContent());
484 return contentArea;
485 }
486 QWidget* createNavigationBar() {
487 QWidget* navBar = new QWidget();
488 navBar->setFixedWidth(200);
489 navBar->setStyleSheet(
490 "QWidget {"
491 " "
492 " border-right: 1px solid #3a3a3a;"
493 "}"
494 );
495 QVBoxLayout* navLayout = new QVBoxLayout(navBar);
496 navLayout->setSpacing(0);
497 navLayout->setContentsMargins(0, 0, 0, 0);
498 // 用户信息区域
499 QWidget* userInfo = new QWidget();
500 userInfo->setFixedHeight(80);
501 userInfo->setStyleSheet(
502 "QWidget {"
503 " background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
504 " stop:0 #2a2a2b, stop:1 #252526);"
505 " border-bottom: 1px solid #3a3a3a;"
506 "}"
507 );
508 QVBoxLayout* userLayout = new QVBoxLayout(userInfo);
509 userLayout->setContentsMargins(20, 15, 20, 15);
510 QLabel* userStatus = new QLabel("🔒 安全状态");
511 userStatus->setStyleSheet(
512 "QLabel {"
513 " color: #19be6b;"
514 " font-size: 14px;"
515 " font-weight: 500;"
516 "}"
517 );
518 QLabel* userName = new QLabel("已保护");
519 userName->setStyleSheet(
520 "QLabel {"
521 " color: #b0b0b0;"
522 " font-size: 12px;"
523 " margin-top: 5px;"
524 "}"
525 );
526 userLayout->addWidget(userStatus);
527 userLayout->addWidget(userName);
528 navLayout->addWidget(userInfo);
529 // 导航按钮
530 QStringList navItems = {
531 "病毒查杀", "防护中心", "访问控制",
532 "安全工具", "家长控制", "扩展功能", "设置"
533 };
534 for (const QString& item : navItems) {
535 QPushButton* navBtn = new QPushButton(item);
536 navBtn->setCheckable(true);
537 navBtn->setFixedHeight(50);
538 navBtn->setStyleSheet(
539 "QPushButton {"
540 " "
541 " border: none;"
542 " color: #b0b0b0;"
543 " text-align: left;"
544 " padding: 15px 20px;"
545 " font-size: 13px;"
546 " border-left: 3px solid transparent;"
547 "}"
548 "QPushButton:hover {"
549 " "
550 " color: #e8e8e8;"
551 "}"
552 "QPushButton:checked {"
553 " "
554 " color: #2d8cf0;"
555 " border-left: 3px solid #2d8cf0;"
556 " font-weight: 500;"
557 "}"
558 );
559 if (item == "病毒查杀") {
560 navBtn->setChecked(true);
561 connect(navBtn, &QPushButton::clicked, this, [this]() {
562 m_stackedWidget->setCurrentIndex(0);
563 });
564 } else if (item == "防护中心") {
565 connect(navBtn, &QPushButton::clicked, this, [this]() {
566 m_stackedWidget->setCurrentIndex(1);
567 });
568 }
569 navLayout->addWidget(navBtn);
570 }
571 navLayout->addStretch();
572 // 底部信息
573 QWidget* bottomInfo = new QWidget();
574 bottomInfo->setFixedHeight(60);
575 bottomInfo->setStyleSheet(
576 "QWidget {"
577 " "
578 " border-top: 1px solid #3a3a3a;"
579 "}"
580 );
581 QVBoxLayout* bottomLayout = new QVBoxLayout(bottomInfo);
582 bottomLayout->setContentsMargins(20, 10, 20, 10);
583 QLabel* versionLabel = new QLabel("v6.0.0.1000");
584 versionLabel->setStyleSheet(
585 "QLabel {"
586 " color: #808080;"
587 " font-size: 11px;"
588 "}"
589 );
590 QLabel* updateLabel = new QLabel("已是最新版本");
591 updateLabel->setStyleSheet(
592 "QLabel {"
593 " color: #19be6b;"
594 " font-size: 11px;"
595 " margin-top: 2px;"
596 "}"
597 );
598 bottomLayout->addWidget(versionLabel);
599 bottomLayout->addWidget(updateLabel);
600 navLayout->addWidget(bottomInfo);
601 return navBar;
602 }
603 QWidget* createMainContent() {
604 QWidget* contentWidget = new QWidget();
605 contentWidget->setStyleSheet("QWidget { }");
606 QVBoxLayout* contentLayout = new QVBoxLayout(contentWidget);
607 contentLayout->setSpacing(0);
608 contentLayout->setContentsMargins(0, 0, 0, 0);
609 // 创建堆叠窗口用于页面切换
610 m_stackedWidget = new QStackedWidget();
611 // 病毒查杀页面
612 m_stackedWidget->addWidget(createVirusScanPage());
613 // 防护中心页面
614 m_stackedWidget->addWidget(createProtectionCenterPage());
615 contentLayout->addWidget(m_stackedWidget);
616 return contentWidget;
617 }
618 QWidget* createVirusScanPage() {
619 QWidget* page = new QWidget();
620 QVBoxLayout* pageLayout = new QVBoxLayout(page);
621 pageLayout->setSpacing(0);
622 pageLayout->setContentsMargins(0, 0, 0, 0);
623 // 安全状态卡片
624 pageLayout->addWidget(createSecurityStatusCard());
625 // 扫描选项卡片
626 pageLayout->addWidget(createScanOptionsCard());
627 // 扫描记录卡片
628 pageLayout->addWidget(createScanHistoryCard());
629 pageLayout->addStretch();
630 return page;
631 }
632 QWidget* createSecurityStatusCard() {
633 QWidget* card = new QWidget();
634 card->setStyleSheet(
635 "QWidget {"
636 " "
637 " border: 1px solid #3a3a3a;"
638 " border-left: 4px solid #19be6b;"
639 " border-radius: 6px;"
640 " margin: 15px;"
641 "}"
642 );
643 QHBoxLayout* cardLayout = new QHBoxLayout(card);
644 cardLayout->setContentsMargins(20, 15, 20, 15);
645 // 状态图标
646 QLabel* statusIcon = new QLabel("🛡️");
647 statusIcon->setStyleSheet("font-size: 32px; margin-right: 15px;");
648 // 状态信息
649 QVBoxLayout* infoLayout = new QVBoxLayout();
650 infoLayout->setSpacing(5);
651 QLabel* statusTitle = new QLabel("您的电脑很安全");
652 statusTitle->setStyleSheet(
653 "QLabel {"
654 " font-size: 16px;"
655 " font-weight: 500;"
656 " color: #e8e8e8;"
657 "}"
658 );
659 QLabel* statusDesc = new QLabel("上次扫描时间: 2024-01-15 14:30:25 未发现风险");
660 statusDesc->setStyleSheet(
661 "QLabel {"
662 " font-size: 12px;"
663 " color: #808080;"
664 "}"
665 );
666 infoLayout->addWidget(statusTitle);
667 infoLayout->addWidget(statusDesc);
668 infoLayout->addStretch();
669 cardLayout->addWidget(statusIcon);
670 cardLayout->addLayout(infoLayout);
671 cardLayout->addStretch();
672 // 扫描按钮
673 QPushButton* scanBtn = new QPushButton("快速扫描");
674 scanBtn->setFixedSize(120, 36);
675 scanBtn->setStyleSheet(
676 "QPushButton {"
677 " "
678 " border: 1px solid #2d8cf0;"
679 " border-radius: 4px;"
680 " color: white;"
681 " font-size: 13px;"
682 " font-weight: 500;"
683 "}"
684 "QPushButton:hover {"
685 " "
686 " border-color: #5cadff;"
687 "}"
688 );
689 cardLayout->addWidget(scanBtn);
690 return card;
691 }
692 QWidget* createScanOptionsCard() {
693 QWidget* card = new QWidget();
694 card->setStyleSheet(
695 "QWidget {"
696 " "
697 " border: 1px solid #3a3a3a;"
698 " border-radius: 6px;"
699 " margin: 0 15px 15px 15px;"
700 "}"
701 );
702 QVBoxLayout* cardLayout = new QVBoxLayout(card);
703 cardLayout->setSpacing(0);
704 cardLayout->setContentsMargins(0, 0, 0, 0);
705 // 卡片标题
706 QWidget* cardHeader = new QWidget();
707 cardHeader->setStyleSheet(
708 "QWidget {"
709 " "
710 " border-bottom: 1px solid #3a3a3a;"
711 " border-top-left-radius: 6px;"
712 " border-top-right-radius: 6px;"
713 "}"
714 );
715 QHBoxLayout* headerLayout = new QHBoxLayout(cardHeader);
716 headerLayout->setContentsMargins(20, 12, 20, 12);
717 QLabel* headerTitle = new QLabel("扫描选项");
718 headerTitle->setStyleSheet(
719 "QLabel {"
720 " font-size: 14px;"
721 " font-weight: 500;"
722 " color: #e8e8e8;"
723 "}"
724 );
725 headerLayout->addWidget(headerTitle);
726 headerLayout->addStretch();
727 cardLayout->addWidget(cardHeader);
728 // 卡片内容
729 QWidget* cardContent = new QWidget();
730 QHBoxLayout* contentLayout = new QHBoxLayout(cardContent);
731 contentLayout->setContentsMargins(20, 20, 20, 20);
732 contentLayout->setSpacing(20);
733 // 扫描选项
734 contentLayout->addWidget(createScanOption("快速扫描", "扫描系统关键位置", "推荐日常使用", "5-10分钟"));
735 contentLayout->addWidget(createScanOption("全盘扫描", "扫描整个计算机", "全面检查", "30-60分钟"));
736 contentLayout->addWidget(createScanOption("自定义扫描", "选择指定位置扫描", "针对性扫描", "时间自定"));
737 contentLayout->addStretch();
738 cardLayout->addWidget(cardContent);
739 return card;
740 }
741 QWidget* createScanOption(const QString& title, const QString& desc, const QString& tip, const QString& time) {
742 QWidget* option = new QWidget();
743 option->setFixedSize(160, 140);
744 option->setStyleSheet(
745 "QWidget {"
746 " "
747 " border: 1px solid #3a3a3a;"
748 " border-radius: 4px;"
749 "}"
750 );
751 QVBoxLayout* optionLayout = new QVBoxLayout(option);
752 optionLayout->setContentsMargins(15, 15, 15, 15);
753 optionLayout->setSpacing(10);
754 QLabel* titleLabel = new QLabel(title);
755 titleLabel->setStyleSheet(
756 "QLabel {"
757 " font-size: 14px;"
758 " font-weight: 500;"
759 " color: #e8e8e8;"
760 " text-align: center;"
761 "}"
762 );
763 QLabel* descLabel = new QLabel(desc);
764 descLabel->setStyleSheet(
765 "QLabel {"
766 " font-size: 12px;"
767 " color: #b0b0b0;"
768 " text-align: center;"
769 "}"
770 );
771 descLabel->setWordWrap(true);
772 QLabel* tipLabel = new QLabel("💡 " + tip);
773 tipLabel->setStyleSheet(
774 "QLabel {"
775 " font-size: 11px;"
776 " color: #808080;"
777 " text-align: center;"
778 "}"
779 );
780 QLabel* timeLabel = new QLabel("⏱️ 预计时间: " + time);
781 timeLabel->setStyleSheet(
782 "QLabel {"
783 " font-size: 11px;"
784 " color: #2d8cf0;"
785 " text-align: center;"
786 "}"
787 );
788 QPushButton* scanBtn = new QPushButton("开始扫描");
789 scanBtn->setFixedHeight(28);
790 scanBtn->setStyleSheet(
791 "QPushButton {"
792 " "
793 " border: 1px solid #2d8cf0;"
794 " border-radius: 4px;"
795 " color: white;"
796 " font-size: 12px;"
797 "}"
798 "QPushButton:hover {"
799 " "
800 " border-color: #5cadff;"
801 "}"
802 );
803 optionLayout->addWidget(titleLabel);
804 optionLayout->addWidget(descLabel);
805 optionLayout->addWidget(tipLabel);
806 optionLayout->addWidget(timeLabel);
807 optionLayout->addWidget(scanBtn);
808 return option;
809 }
810 QWidget* createScanHistoryCard() {
811 QWidget* card = new QWidget();
812 card->setStyleSheet(
813 "QWidget {"
814 " "
815 " border: 1px solid #3a3a3a;"
816 " border-radius: 6px;"
817 " margin: 0 15px 15px 15px;"
818 "}"
819 );
820 QVBoxLayout* cardLayout = new QVBoxLayout(card);
821 cardLayout->setSpacing(0);
822 cardLayout->setContentsMargins(0, 0, 0, 0);
823 // 卡片标题
824 QWidget* cardHeader = new QWidget();
825 cardHeader->setStyleSheet(
826 "QWidget {"
827 " "
828 " border-bottom: 1px solid #3a3a3a;"
829 " border-top-left-radius: 6px;"
830 " border-top-right-radius: 6px;"
831 "}"
832 );
833 QHBoxLayout* headerLayout = new QHBoxLayout(cardHeader);
834 headerLayout->setContentsMargins(20, 12, 20, 12);
835 QLabel* headerTitle = new QLabel("扫描记录");
836 headerTitle->setStyleSheet(
837 "QLabel {"
838 " font-size: 14px;"
839 " font-weight: 500;"
840 " color: #e8e8e8;"
841 "}"
842 );
843 QPushButton* clearBtn = new QPushButton("清空记录");
844 clearBtn->setFixedSize(80, 24);
845 clearBtn->setStyleSheet(
846 "QPushButton {"
847 " "
848 " border: 1px solid #4a4a4a;"
849 " border-radius: 3px;"
850 " color: #b0b0b0;"
851 " font-size: 11px;"
852 "}"
853 "QPushButton:hover {"
854 " "
855 " color: #e8e8e8;"
856 "}"
857 );
858 headerLayout->addWidget(headerTitle);
859 headerLayout->addStretch();
860 headerLayout->addWidget(clearBtn);
861 cardLayout->addWidget(cardHeader);
862 // 扫描记录列表
863 QListWidget* scanList = new QListWidget();
864 scanList->setStyleSheet(
865 "QListWidget {"
866 " "
867 " border: none;"
868 " border-radius: 0 0 6px 6px;"
869 " outline: none;"
870 "}"
871 "QListWidget::item {"
872 " "
873 " color: #e8e8e8;"
874 " padding: 10px 20px;"
875 " border-bottom: 1px solid #3a3a3a;"
876 "}"
877 "QListWidget::item:selected {"
878 " "
879 " color: white;"
880 " border: none;"
881 "}"
882 "QListWidget::item:hover {"
883 " "
884 "}"
885 );
886 // 添加示例扫描记录
887 QStringList scanRecords = {
888 "2024-01-15 14:30:25 快速扫描 - 未发现风险",
889 "2024-01-14 09:15:10 全盘扫描 - 未发现风险",
890 "2024-01-12 16:45:30 自定义扫描 - 未发现风险",
891 "2024-01-10 11:20:15 快速扫描 - 发现1个风险项,已处理"
892 };
893 for (const QString& record : scanRecords) {
894 QListWidgetItem* item = new QListWidgetItem(record);
895 scanList->addItem(item);
896 }
897 cardLayout->addWidget(scanList);
898 return card;
899 }
900 QWidget* createProtectionCenterPage() {
901 QWidget* page = new QWidget();
902 QVBoxLayout* pageLayout = new QVBoxLayout(page);
903 pageLayout->setSpacing(0);
904 pageLayout->setContentsMargins(0, 0, 0, 0);
905 QLabel* title = new QLabel("防护中心 - 开发中...");
906 title->setStyleSheet(
907 "QLabel {"
908 " font-size: 16px;"
909 " font-weight: 500;"
910 " color: #e8e8e8;"
911 " padding: 20px;"
912 "}"
913 );
914 title->setAlignment(Qt::AlignCenter);
915 pageLayout->addWidget(title);
916 pageLayout->addStretch();
917 return page;
918 }
919 private:
920 QStackedWidget* m_stackedWidget;
921 };
922 // 应用火绒黑色风格
923 void applyHuorongDarkStyle(QApplication* app) {
924 app->setStyleSheet(HUORONG_DARK_STYLE);
925 }
926 int main(int argc, char *argv[]) {
927 QApplication app(argc, argv);
928 // 应用火绒黑色风格
929 applyHuorongDarkStyle(&app);
930 // 创建主窗口
931 HuorongMainWindow window;
932 window.show();
933 return app.exec();
934 }
935 #include "main.moc"