Skip to content

Commit

Permalink
Add TFTP server configuration to settings
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Dec 4, 2024
1 parent 317ba9f commit ee9164a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ en-US:
- Fix the main window error raise
- Add the ability to add custom data to the log
- Improve the log file path setting option
- Add TFTP server configuration to settings

zh-CN:

- 修复主窗口错误的提升
- 增加日志中允许添加自定义数据功能
- 改进记录日志文件路径设置选项
- 增加TFTP服务器配置到设置中

## [[V0.5.1](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.5.1)] - 2024-09-26

Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fix the main window error raise
- Add the ability to add custom data to the log
- Improve the log file path setting option
- Add TFTP server configuration to settings

## [[V0.5.1](https://github.com/QQxiaoming/quardCRT/releases/tag/V0.5.1)] - 2024-09-26

Expand Down
29 changes: 25 additions & 4 deletions src/starttftpseverwindow/starttftpseverwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "filedialog.h"
#include "starttftpseverwindow.h"
#include "globalsetting.h"
#include "ui_starttftpseverwindow.h"

StartTftpSeverWindow::StartTftpSeverWindow(QWidget *parent) :
Expand All @@ -34,19 +35,35 @@ StartTftpSeverWindow::StartTftpSeverWindow(QWidget *parent) :
ui->uploadLineEdit->setText(QDir::homePath());
ui->downloadLineEdit->setText(QDir::homePath());

GlobalSetting settings;
int port = settings.value("Global/misc/TftpSeverPort", 69).toInt();
if(port < 0 || port > 65535) {
port = 69;
}
ui->spinBox->setValue(port);
settings.setValue("Global/misc/TftpSeverPort", port);

connect(ui->uploadToolButton, &QToolButton::clicked, this, [&](){
GlobalSetting settings;
QString uploadDir = settings.value("Global/misc/TftpSeverUploadDir",QDir::homePath()).toString();
QString dir = FileDialog::getExistingDirectory(this, tr("Open Directory"),
QDir::homePath(),
uploadDir,
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
ui->uploadLineEdit->setText(dir);
if(!dir.isEmpty()){
ui->uploadLineEdit->setText(dir);
}
});
connect(ui->downloadToolButton, &QToolButton::clicked, this, [&](){
GlobalSetting settings;
QString downloadDir = settings.value("Global/misc/TftpSeverDownloadDir",QDir::homePath()).toString();
QString dir = FileDialog::getExistingDirectory(this, tr("Open Directory"),
QDir::homePath(),
downloadDir,
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
ui->downloadLineEdit->setText(dir);
if(!dir.isEmpty()){
ui->downloadLineEdit->setText(dir);
}
});

connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &StartTftpSeverWindow::buttonBoxAccepted);
Expand Down Expand Up @@ -77,6 +94,10 @@ void StartTftpSeverWindow::buttonBoxAccepted(void)
QMessageBox::warning(this, tr("Warning"), tr("Please select a valid directory!"));
return;
}
GlobalSetting settings;
settings.setValue("Global/misc/TftpSeverUploadDir", ui->uploadLineEdit->text());
settings.setValue("Global/misc/TftpSeverDownloadDir", ui->downloadLineEdit->text());
settings.setValue("Global/misc/TftpSeverPort", ui->spinBox->value());
emit setTftpInfo(ui->spinBox->value(), ui->uploadLineEdit->text(), ui->downloadLineEdit->text());

emit this->accepted();
Expand Down

0 comments on commit ee9164a

Please sign in to comment.