feat: add mode selection and information dialog in MainWindow

This commit is contained in:
2026-03-03 16:02:54 +08:00
parent 4f150b7e56
commit 56368c8839
2 changed files with 220 additions and 170 deletions

View File

@@ -43,6 +43,8 @@ void MainWindow::init() {
ui->logoLabel->setPixmap(QPixmap(":/images/banner.png"));
for (const auto &p: provider)
ui->providerComboBox->addItem(p.name, p.value);
ui->comboBoxMode->addItem("模式一", 1);
ui->comboBoxMode->addItem("模式二", 2);
ui->selfStartup->setChecked(isAutoRunEnabled());
trayIcon->setIcon(QIcon(":/images/logo.png"));
@@ -64,6 +66,16 @@ void MainWindow::init() {
if (reason == QSystemTrayIcon::Trigger) // 单击托盘图标
onShowFromTray();
});
connect(ui->pushButtonQ, &QPushButton::clicked, this, [this] {
QMessageBox::information(this, "模式说明", ""
"模式一:需要购买校园卡,下行网速上限 100Mbps需要选择正确的运营商。\n\n"
"模式二:无需购买校园卡也可使用,下行网速上限 60Mbps运营商选项在此模式下无效。\n\n"
"如何选择?\n"
"如果你有校园卡且不想受限于模式二的网速上,建议选择模式一并正确选择运营商;如果你没有校园卡或者不想购买,建议选择模式二。\n\n"
"注意(仅高级用户):\n"
"模式一无法在校园内被其他设备访问,模式二则没有这个问题,如果你需要在校园内被其他设备访问(例如远程桌面),建议选择模式二。\n"
"模式二无法使用git的ssh方式如需使用建议使用https git或选择模式一。");
});
}
MainWindow::~MainWindow() {
@@ -104,6 +116,7 @@ void MainWindow::setInputEnable(bool enable) {
ui->usernameLe->setEnabled(enable);
ui->providerComboBox->setEnabled(enable);
ui->rememberMe->setEnabled(enable);
ui->comboBoxMode->setEnabled(enable);
}
void MainWindow::saveUserInfo() {
@@ -121,6 +134,7 @@ void MainWindow::saveUserInfo() {
userInfo["username"] = ui->usernameLe->text();
userInfo["password"] = ui->passwdLe->text();
userInfo["provider"] = ui->providerComboBox->currentText();
userInfo["mode"] = ui->comboBoxMode->currentText();
// 写入文件
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
@@ -149,6 +163,7 @@ void MainWindow::getUserInfo() {
ui->usernameLe->setText(userInfo.take("username").toString());
ui->passwdLe->setText(userInfo.take("password").toString());
ui->providerComboBox->setEditText(userInfo.take("provider").toString());
ui->comboBoxMode->setCurrentText(userInfo.take("mode").toString());
ui->rememberMe->setChecked(true);
}
}
@@ -244,9 +259,10 @@ void MainWindow::doLogin() {
ui->statusbar->showMessage(QString(StatusBarMsg::WaitForProvider).arg(ui->providerComboBox->currentText()));
QUrlQuery query;
query.addQueryItem("user_account", ui->usernameLe->text());
int mode = ui->comboBoxMode->currentData().toInt();
QString account = mode == 1 ? ui->usernameLe->text() + "@" + ui->providerComboBox->currentData().toString(): ui->usernameLe->text();
query.addQueryItem("user_account", account);
query.addQueryItem("user_password", ui->passwdLe->text());
query.addQueryItem("provider", ui->providerComboBox->currentData().toString());
baseUrl.setQuery(query);
request.setUrl(baseUrl);

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<width>425</width>
<height>219</height>
</rect>
</property>
@@ -18,14 +18,14 @@
</property>
<property name="minimumSize">
<size>
<width>402</width>
<width>425</width>
<height>178</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>402</width>
<height>219</height>
<width>425</width>
<height>227</height>
</size>
</property>
<property name="windowTitle">
@@ -33,9 +33,6 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
@@ -48,9 +45,10 @@
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="logoLabel">
<property name="minimumSize">
<size>
@@ -69,20 +67,20 @@
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>80</number>
</property>
<property name="topMargin">
<number>9</number>
<number>10</number>
</property>
<property name="rightMargin">
<number>80</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@@ -179,6 +177,44 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>模式</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxMode">
<property name="toolTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonQ">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">border: 0 0 0 0;
color: rgb(26, 95, 180);
text-decoration: underline;</string>
</property>
<property name="text">
<string>?</string>
</property>
<property name="iconSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -222,16 +258,14 @@
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<height>21</height>
<width>425</width>
<height>25</height>
</rect>
</property>
</widget>