mirror of
https://github.com/Aurora1949/AHNU-Portal-Authenticator.git
synced 2026-03-06 01:43:08 +08:00
Compare commits
2 Commits
56368c8839
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 71adaa3370 | |||
| 6efb0ce76b |
@@ -35,7 +35,7 @@ void MainWindow::init() {
|
||||
setWindowTitle("AHNU上号器");
|
||||
setWindowIcon(QIcon(":/images/logo.png"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint & ~Qt::WindowMinimizeButtonHint);
|
||||
setFixedSize(400, 178);
|
||||
setFixedSize(400, 200);
|
||||
|
||||
manager.setProxy(QNetworkProxy::NoProxy);
|
||||
|
||||
@@ -190,6 +190,8 @@ void MainWindow::testOnline() {
|
||||
|
||||
void MainWindow::setAutoRun(bool isStart) {
|
||||
QString appName = QApplication::applicationName(); // 获取应用名称
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QSettings settings(RegKey, QSettings::NativeFormat); // 创建QSettings对象
|
||||
|
||||
if (isStart) {
|
||||
@@ -199,12 +201,43 @@ void MainWindow::setAutoRun(bool isStart) {
|
||||
} else {
|
||||
settings.remove(appName); // 从注册表中删除
|
||||
}
|
||||
#elifdef Q_OS_LINUX
|
||||
QString autostartDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/autostart";
|
||||
QDir dir(autostartDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(autostartDir);
|
||||
|
||||
QString desktopFilePath = autostartDir + "/" + appName + ".desktop";
|
||||
|
||||
if (isStart) {
|
||||
QFile desktopFile(desktopFilePath);
|
||||
if (desktopFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
QTextStream out(&desktopFile);
|
||||
out << "[Desktop Entry]\n";
|
||||
out << "Type=Application\n";
|
||||
out << "Exec=" << QApplication::applicationFilePath() << "\n";
|
||||
out << "Icon=ahnu\n";
|
||||
out << "Hidden=false\n";
|
||||
out << "NoDisplay=false\n";
|
||||
out << "X-GNOME-Autostart-enabled=true\n";
|
||||
out << "Name=" << appName << "\n";
|
||||
desktopFile.close();
|
||||
}
|
||||
} else {
|
||||
QFile::remove(desktopFilePath);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MainWindow::isAutoRunEnabled() {
|
||||
#ifdef Q_OS_WIN
|
||||
QSettings settings(RegKey, QSettings::NativeFormat);
|
||||
QString appPath = QDir::toNativeSeparators(QApplication::applicationFilePath());
|
||||
return settings.value(QApplication::applicationName()).toString().split(" ")[0] == appPath;
|
||||
#elifdef Q_OS_LINUX
|
||||
QString desktopFilePath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/autostart/" + QApplication::applicationName() + ".desktop";
|
||||
return QFile::exists(desktopFilePath);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::on_selfStartup_checkStateChanged() {
|
||||
|
||||
@@ -73,13 +73,13 @@
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>80</number>
|
||||
<number>60</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>80</number>
|
||||
<number>60</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
|
||||
Reference in New Issue
Block a user