mirror of
https://github.com/Aurora1949/AHNU-Portal-Authenticator.git
synced 2026-03-04 09:33:08 +08:00
feat: add mode selection and information dialog in MainWindow
This commit is contained in:
@@ -43,6 +43,8 @@ void MainWindow::init() {
|
|||||||
ui->logoLabel->setPixmap(QPixmap(":/images/banner.png"));
|
ui->logoLabel->setPixmap(QPixmap(":/images/banner.png"));
|
||||||
for (const auto &p: provider)
|
for (const auto &p: provider)
|
||||||
ui->providerComboBox->addItem(p.name, p.value);
|
ui->providerComboBox->addItem(p.name, p.value);
|
||||||
|
ui->comboBoxMode->addItem("模式一", 1);
|
||||||
|
ui->comboBoxMode->addItem("模式二", 2);
|
||||||
ui->selfStartup->setChecked(isAutoRunEnabled());
|
ui->selfStartup->setChecked(isAutoRunEnabled());
|
||||||
|
|
||||||
trayIcon->setIcon(QIcon(":/images/logo.png"));
|
trayIcon->setIcon(QIcon(":/images/logo.png"));
|
||||||
@@ -64,6 +66,16 @@ void MainWindow::init() {
|
|||||||
if (reason == QSystemTrayIcon::Trigger) // 单击托盘图标
|
if (reason == QSystemTrayIcon::Trigger) // 单击托盘图标
|
||||||
onShowFromTray();
|
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() {
|
MainWindow::~MainWindow() {
|
||||||
@@ -104,6 +116,7 @@ void MainWindow::setInputEnable(bool enable) {
|
|||||||
ui->usernameLe->setEnabled(enable);
|
ui->usernameLe->setEnabled(enable);
|
||||||
ui->providerComboBox->setEnabled(enable);
|
ui->providerComboBox->setEnabled(enable);
|
||||||
ui->rememberMe->setEnabled(enable);
|
ui->rememberMe->setEnabled(enable);
|
||||||
|
ui->comboBoxMode->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::saveUserInfo() {
|
void MainWindow::saveUserInfo() {
|
||||||
@@ -121,6 +134,7 @@ void MainWindow::saveUserInfo() {
|
|||||||
userInfo["username"] = ui->usernameLe->text();
|
userInfo["username"] = ui->usernameLe->text();
|
||||||
userInfo["password"] = ui->passwdLe->text();
|
userInfo["password"] = ui->passwdLe->text();
|
||||||
userInfo["provider"] = ui->providerComboBox->currentText();
|
userInfo["provider"] = ui->providerComboBox->currentText();
|
||||||
|
userInfo["mode"] = ui->comboBoxMode->currentText();
|
||||||
|
|
||||||
// 写入文件
|
// 写入文件
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
@@ -149,6 +163,7 @@ void MainWindow::getUserInfo() {
|
|||||||
ui->usernameLe->setText(userInfo.take("username").toString());
|
ui->usernameLe->setText(userInfo.take("username").toString());
|
||||||
ui->passwdLe->setText(userInfo.take("password").toString());
|
ui->passwdLe->setText(userInfo.take("password").toString());
|
||||||
ui->providerComboBox->setEditText(userInfo.take("provider").toString());
|
ui->providerComboBox->setEditText(userInfo.take("provider").toString());
|
||||||
|
ui->comboBoxMode->setCurrentText(userInfo.take("mode").toString());
|
||||||
ui->rememberMe->setChecked(true);
|
ui->rememberMe->setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,9 +259,10 @@ void MainWindow::doLogin() {
|
|||||||
ui->statusbar->showMessage(QString(StatusBarMsg::WaitForProvider).arg(ui->providerComboBox->currentText()));
|
ui->statusbar->showMessage(QString(StatusBarMsg::WaitForProvider).arg(ui->providerComboBox->currentText()));
|
||||||
|
|
||||||
QUrlQuery query;
|
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("user_password", ui->passwdLe->text());
|
||||||
query.addQueryItem("provider", ui->providerComboBox->currentData().toString());
|
|
||||||
baseUrl.setQuery(query);
|
baseUrl.setQuery(query);
|
||||||
|
|
||||||
request.setUrl(baseUrl);
|
request.setUrl(baseUrl);
|
||||||
|
|||||||
370
mainwindow.ui
370
mainwindow.ui
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>402</width>
|
<width>425</width>
|
||||||
<height>219</height>
|
<height>219</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -18,14 +18,14 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>402</width>
|
<width>425</width>
|
||||||
<height>178</height>
|
<height>178</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>402</width>
|
<width>425</width>
|
||||||
<height>219</height>
|
<height>227</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -33,9 +33,6 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="sizeConstraint">
|
|
||||||
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -48,176 +45,213 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<widget class="QLabel" name="logoLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>16777209</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</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>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>80</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="logoLabel">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="minimumSize">
|
<item>
|
||||||
<size>
|
<widget class="QLabel" name="label">
|
||||||
<width>400</width>
|
<property name="sizePolicy">
|
||||||
<height>40</height>
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
</size>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
<property name="maximumSize">
|
</sizepolicy>
|
||||||
<size>
|
</property>
|
||||||
<width>16777215</width>
|
<property name="minimumSize">
|
||||||
<height>16777209</height>
|
<size>
|
||||||
</size>
|
<width>40</width>
|
||||||
</property>
|
<height>0</height>
|
||||||
<property name="text">
|
</size>
|
||||||
<string>TextLabel</string>
|
</property>
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string>账 号</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="usernameLe"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="leftMargin">
|
|
||||||
<number>80</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>80</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>9</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<widget class="QLabel" name="label_2">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QLabel" name="label">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="minimumSize">
|
||||||
</property>
|
<size>
|
||||||
<property name="minimumSize">
|
<width>40</width>
|
||||||
<size>
|
<height>0</height>
|
||||||
<width>40</width>
|
</size>
|
||||||
<height>0</height>
|
</property>
|
||||||
</size>
|
<property name="text">
|
||||||
</property>
|
<string>密 码</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>账 号</string>
|
<property name="alignment">
|
||||||
</property>
|
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
<property name="alignment">
|
</property>
|
||||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="usernameLe"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<widget class="QLineEdit" name="passwdLe">
|
||||||
<item>
|
<property name="echoMode">
|
||||||
<widget class="QLabel" name="label_2">
|
<enum>QLineEdit::EchoMode::Password</enum>
|
||||||
<property name="sizePolicy">
|
</property>
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
</widget>
|
||||||
<horstretch>0</horstretch>
|
</item>
|
||||||
<verstretch>0</verstretch>
|
</layout>
|
||||||
</sizepolicy>
|
</item>
|
||||||
</property>
|
<item>
|
||||||
<property name="minimumSize">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<size>
|
<item>
|
||||||
<width>40</width>
|
<widget class="QLabel" name="label_3">
|
||||||
<height>0</height>
|
<property name="sizePolicy">
|
||||||
</size>
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
</property>
|
<horstretch>0</horstretch>
|
||||||
<property name="text">
|
<verstretch>0</verstretch>
|
||||||
<string>密 码</string>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="minimumSize">
|
||||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
<size>
|
||||||
</property>
|
<width>40</width>
|
||||||
</widget>
|
<height>0</height>
|
||||||
</item>
|
</size>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QLineEdit" name="passwdLe">
|
<property name="text">
|
||||||
<property name="echoMode">
|
<string>运营商</string>
|
||||||
<enum>QLineEdit::EchoMode::Password</enum>
|
</property>
|
||||||
</property>
|
<property name="alignment">
|
||||||
</widget>
|
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<widget class="QComboBox" name="providerComboBox">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QLabel" name="label_3">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
</widget>
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>运营商</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="providerComboBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<item>
|
<property name="text">
|
||||||
<spacer name="horizontalSpacer">
|
<string>模式</string>
|
||||||
<property name="orientation">
|
</property>
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
<property name="sizeHint" stdset="0">
|
<item>
|
||||||
<size>
|
<widget class="QComboBox" name="comboBoxMode">
|
||||||
<width>40</width>
|
<property name="toolTip">
|
||||||
<height>20</height>
|
<string/>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<property name="whatsThis">
|
||||||
</spacer>
|
<string/>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
</widget>
|
||||||
<widget class="QCheckBox" name="selfStartup">
|
</item>
|
||||||
<property name="text">
|
<item>
|
||||||
<string>开机自启</string>
|
<widget class="QPushButton" name="pushButtonQ">
|
||||||
</property>
|
<property name="cursor">
|
||||||
</widget>
|
<cursorShape>PointingHandCursor</cursorShape>
|
||||||
</item>
|
</property>
|
||||||
<item>
|
<property name="styleSheet">
|
||||||
<widget class="QCheckBox" name="rememberMe">
|
<string notr="true">border: 0 0 0 0;
|
||||||
<property name="text">
|
color: rgb(26, 95, 180);
|
||||||
<string>记住我</string>
|
text-decoration: underline;</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="text">
|
||||||
</item>
|
<string>?</string>
|
||||||
<item>
|
</property>
|
||||||
<widget class="QPushButton" name="loginBtn">
|
<property name="iconSize">
|
||||||
<property name="text">
|
<size>
|
||||||
<string>登录</string>
|
<width>0</width>
|
||||||
</property>
|
<height>0</height>
|
||||||
</widget>
|
</size>
|
||||||
</item>
|
</property>
|
||||||
</layout>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="selfStartup">
|
||||||
|
<property name="text">
|
||||||
|
<string>开机自启</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="rememberMe">
|
||||||
|
<property name="text">
|
||||||
|
<string>记住我</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="loginBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>登录</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@@ -230,8 +264,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>402</width>
|
<width>425</width>
|
||||||
<height>21</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user