This commit is contained in:
yangjiaxuan 2023-09-12 11:14:05 +08:00
parent db589e65f0
commit cc4f3866de
3 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,66 @@
#include "dialog_setlogpath.h"
#include "ui_dialog_setlogpath.h"
#include <QMessageBox>
#include <QFileDialog>
#include "base/HGUtility.h"
#include "HGUIGlobal.h"
#include "app_cfg.h"
Dialog_SetLogPath::Dialog_SetLogPath(const QString &devType, QWidget *parent) :
QDialog(parent),
m_devType(devType),
ui(new Ui::Dialog_SetLogPath)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
QFont ft;
ft.setPointSize(15);
this->setFont(ft);
}
Dialog_SetLogPath::~Dialog_SetLogPath()
{
delete ui;
}
void Dialog_SetLogPath::on_pushButton_ok_clicked()
{
if(ui->lineEdit->text().isEmpty())
{
return;
}
QString filePath = ui->lineEdit->text();
HGResult ret = HGBase_CreateDir(getStdString(filePath).c_str());
if (ret != HGBASE_ERR_OK)
{
QMessageBox::information(this, tr("tips"), tr("Create logPath failed"));
return;
}
saveCfgValue("save", "logPath", getStdFileName(filePath));
close();
}
void Dialog_SetLogPath::on_pushButton_cancel_clicked()
{
reject();
}
void Dialog_SetLogPath::on_pushButton_selectPath_clicked()
{
QString save_dir = QFileDialog::getExistingDirectory(this, tr("Browse directory"), "");
if (!save_dir.isEmpty())
{
if (save_dir[save_dir.size() - 1] != '/')
save_dir += "/";
if (save_dir.endsWith(m_devType + "/", Qt::CaseInsensitive))
ui->lineEdit->setText(getStdFileName(save_dir + "/"));
else
ui->lineEdit->setText(getStdFileName(save_dir + m_devType + "/"));
}
}

View File

@ -0,0 +1,31 @@
#ifndef DIALOG_SETLOGPATH_H
#define DIALOG_SETLOGPATH_H
#include <QDialog>
namespace Ui {
class Dialog_SetLogPath;
}
class Dialog_SetLogPath : public QDialog
{
Q_OBJECT
public:
explicit Dialog_SetLogPath(const QString &devType, QWidget *parent = nullptr);
~Dialog_SetLogPath();
private slots:
void on_pushButton_ok_clicked();
void on_pushButton_cancel_clicked();
void on_pushButton_selectPath_clicked();
private:
Ui::Dialog_SetLogPath *ui;
QString m_devType;
};
#endif // DIALOG_SETLOGPATH_H

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_SetLogPath</class>
<widget class="QDialog" name="Dialog_SetLogPath">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>571</width>
<height>154</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Log path:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>130</x>
<y>30</y>
<width>431</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_ok">
<property name="geometry">
<rect>
<x>330</x>
<y>90</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Ok</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_cancel">
<property name="geometry">
<rect>
<x>450</x>
<y>90</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_selectPath">
<property name="geometry">
<rect>
<x>160</x>
<y>90</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Select path</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>