MCPcopy Create free account
hub / github.com/XMuli/ChineseChess / ChooseMainWindow

Method ChooseMainWindow

ChooseMainWindow.cpp:17–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <QInputDialog>
16
17ChooseMainWindow::ChooseMainWindow(QWidget *parent) : QDialog(parent)
18{
19 this->setWindowTitle(QString("选择游戏方式 %1").arg(XPROJECT_VERSION));
20 this->resize(500, 340);
21 this->setMinimumSize(480, 280);
22 this->setWindowIcon(QIcon(":/images/chess.svg"));
23
24 auto* lay = new QVBoxLayout(this);
25 lay->setContentsMargins(24, 24, 24, 24);
26 lay->setSpacing(16);
27
28 auto* title = new QLabel("选择一场对局", this);
29 title->setAlignment(Qt::AlignCenter);
30 title->setStyleSheet("font: 700 18pt 'Microsoft YaHei'; color: #222;");
31
32 auto* subtitle = new QLabel("选择你希望的开局方式", this);
33 subtitle->setAlignment(Qt::AlignCenter);
34 subtitle->setStyleSheet("color: #666;");
35
36 auto* btnLayout = new QVBoxLayout();
37 btnLayout->setSpacing(12);
38
39 const QStringList texts = {
40 "玩家自己对战",
41 "玩家和 AI 对战",
42 "双人网络对战",
43 "残局挑战"
44 };
45
46 for (int i = 0; i < 4; ++i) {
47 m_buttons[i] = new QPushButton(texts[i], this);
48 m_buttons[i]->setMinimumHeight(52);
49 m_buttons[i]->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
50 m_buttons[i]->setStyleSheet(
51 "QPushButton {"
52 " border: 1px solid #c5c5c5;"
53 " border-radius: 8px;"
54 " background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
55 " stop:0 #ffffff, stop:1 #f3f3f3);"
56 " font: 12pt 'Microsoft YaHei';"
57 " padding: 10px 14px;"
58 "}"
59 "QPushButton:hover { background: #f8f8f8; }"
60 "QPushButton:pressed { background: #e9e9e9; }"
61 );
62 btnLayout->addWidget(m_buttons[i]);
63 btnLayout->setStretch(i, 1);
64 }
65
66 lay->addWidget(title);
67 lay->addWidget(subtitle);
68 lay->addLayout(btnLayout, 1);
69
70 /*游戏方式一: 自己和自己下棋【同一台PC机器】*/
71 connect(m_buttons[0], &QPushButton::clicked,[=](){
72 this->hide();
73 m_pAgainstYourself = new ChessBoard();
74 m_pAgainstYourself->showNetworkGui(false);

Callers

nothing calls this directly

Calls 2

getBuiltinPuzzlesFunction · 0.85
showNetworkGuiMethod · 0.80

Tested by

no test coverage detected