bug/loadimage-dump
This commit is contained in:
@@ -24,8 +24,7 @@ FileConfigDecode *FileConfigDecode::getInstance()
|
||||
|
||||
FileConfigDecode::~FileConfigDecode()
|
||||
{
|
||||
// updateFile();
|
||||
// qDebug() << "write:" << autoSetup << rename << timeRename << autoCopy;
|
||||
updateFile();
|
||||
}
|
||||
|
||||
QString FileConfigDecode::getAddress()
|
||||
@@ -73,23 +72,27 @@ RenameType FileConfigDecode::getRenameType()
|
||||
return renameType;
|
||||
}
|
||||
|
||||
bool FileConfigDecode::getAutoLogin()
|
||||
{
|
||||
return autoLogin;
|
||||
}
|
||||
|
||||
void FileConfigDecode::setAddress(QString value)
|
||||
{
|
||||
this->address = value;
|
||||
// updateFile();
|
||||
updateFile();
|
||||
}
|
||||
|
||||
void FileConfigDecode::setPort(quint16 value)
|
||||
{
|
||||
this->port = value;
|
||||
// updateFile();
|
||||
updateFile();
|
||||
}
|
||||
|
||||
void FileConfigDecode::setAutoSetup(bool value)
|
||||
{
|
||||
this->autoSetup = value;
|
||||
updateFile();
|
||||
// updateFile();
|
||||
updateFile();
|
||||
}
|
||||
|
||||
void FileConfigDecode::setRename(bool value)
|
||||
@@ -101,13 +104,13 @@ void FileConfigDecode::setRename(bool value)
|
||||
else {
|
||||
renameType = (renameType == RENAME_TYPE_TIME) ? RENAME_TYPE_TIME : RENAME_TYPE_NORMAL;
|
||||
}
|
||||
qDebug() << renameType;
|
||||
updateFile();
|
||||
// updateFile();
|
||||
// qDebug() << renameType;
|
||||
updateFile();
|
||||
}
|
||||
|
||||
void FileConfigDecode::setTimeRename(bool value, int flag)
|
||||
{
|
||||
qDebug() << value;
|
||||
this->timeRename = value;
|
||||
if (value) {
|
||||
renameType = RENAME_TYPE_TIME;
|
||||
@@ -120,16 +123,14 @@ void FileConfigDecode::setTimeRename(bool value, int flag)
|
||||
if (!value && flag == 0) {
|
||||
renameType = RENAME_TYPE_NONE;
|
||||
}
|
||||
qDebug() << renameType;
|
||||
updateFile();
|
||||
// updateFile();
|
||||
// qDebug() << renameType;
|
||||
updateFile();
|
||||
}
|
||||
|
||||
void FileConfigDecode::setAutoCopy(bool value)
|
||||
{
|
||||
this->autoCopy = value;
|
||||
updateFile();
|
||||
// updateFile();
|
||||
updateFile();
|
||||
}
|
||||
|
||||
void FileConfigDecode::setUserName(QString username)
|
||||
@@ -144,8 +145,14 @@ void FileConfigDecode::setPassword(QString password)
|
||||
updateFile();
|
||||
}
|
||||
|
||||
void FileConfigDecode::fileWrite(QString path, QString address, bool autosetup,
|
||||
bool rename, bool timerename, bool autocopy, QString username, QString password)
|
||||
void FileConfigDecode::setAutoLogin(bool value)
|
||||
{
|
||||
autoLogin = value;
|
||||
updateFile();
|
||||
}
|
||||
|
||||
|
||||
void FileConfigDecode::fileWrite(QString path)
|
||||
{
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QSettings* config = new QSettings(path, QSettings::IniFormat);
|
||||
@@ -153,7 +160,6 @@ void FileConfigDecode::fileWrite(QString path, QString address, bool autosetup,
|
||||
QString section = QString("config");
|
||||
config->beginGroup(section);
|
||||
config->setValue("address", address);
|
||||
config->setValue("port", port);
|
||||
config->setValue("autosetup", autosetup);
|
||||
config->setValue("rename", rename);
|
||||
config->setValue("timerename", timerename);
|
||||
@@ -166,14 +172,13 @@ void FileConfigDecode::fileWrite(QString path, QString address, bool autosetup,
|
||||
QString section = QString("config");
|
||||
config->beginGroup(section);
|
||||
config->setValue("address", address);
|
||||
config->setValue("port", port);
|
||||
config->setValue("autosetup", autosetup);
|
||||
config->setValue("autosetup", autoSetup);
|
||||
config->setValue("rename", rename);
|
||||
config->setValue("timerename", timerename);
|
||||
config->setValue("autocopy", autocopy);
|
||||
config->setValue("username", username);
|
||||
config->setValue("timerename", timeRename);
|
||||
config->setValue("autocopy", autoCopy);
|
||||
config->setValue("username", userName);
|
||||
config->setValue("password", password);
|
||||
config->endGroup();
|
||||
config->setValue("autologin", autoLogin);
|
||||
delete config;
|
||||
#endif
|
||||
}
|
||||
@@ -196,12 +201,14 @@ void FileConfigDecode::initFile()
|
||||
this->autoCopy = config->value(section + "autocopy").toBool();
|
||||
this->userName = config->value(section+"username").toString();
|
||||
this->password = config->value(section+"password").toString();
|
||||
this->autoLogin = config->value(section+"autologin").toBool();
|
||||
|
||||
checkConfig();
|
||||
|
||||
this->firstCreate = false;
|
||||
}
|
||||
else {
|
||||
qDebug() << "file not exists";
|
||||
this->firstCreate = true;
|
||||
|
||||
this->address = "127.0.0.1:8080";
|
||||
@@ -211,8 +218,9 @@ void FileConfigDecode::initFile()
|
||||
this->autoCopy = false;
|
||||
this->userName = "admin";
|
||||
this->password = "admin";
|
||||
this->autoLogin = false;
|
||||
|
||||
fileWrite(addFilePath, address, autoSetup, rename, timeRename, autoCopy, userName, password);
|
||||
fileWrite(addFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +243,7 @@ void FileConfigDecode::updateFile()
|
||||
QString addDataPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
QString addFilePath = addDataPath + "/config.ini";
|
||||
|
||||
qDebug() << "write" << autoSetup << rename << timeRename << autoCopy;
|
||||
fileWrite(addFilePath, address, autoSetup, rename, timeRename, autoCopy, userName, password);
|
||||
// qDebug() << "write" << this->autoSetup << this->rename << this->timeRename << this->autoCopy;
|
||||
fileWrite(addFilePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
QString getUserName();
|
||||
QString getPassword();
|
||||
RenameType getRenameType();
|
||||
bool getAutoLogin();
|
||||
|
||||
void setAddress(QString value);
|
||||
void setPort(quint16 value);
|
||||
@@ -41,6 +42,7 @@ public:
|
||||
void setAutoCopy(bool value);
|
||||
void setUserName(QString username);
|
||||
void setPassword(QString password);
|
||||
void setAutoLogin(bool value);
|
||||
|
||||
void initFile();
|
||||
void updateFile();
|
||||
@@ -54,12 +56,13 @@ private:
|
||||
bool autoCopy;
|
||||
QString userName;
|
||||
QString password;
|
||||
bool autoLogin;
|
||||
|
||||
bool firstCreate;
|
||||
|
||||
RenameType renameType = RENAME_TYPE_NONE;
|
||||
|
||||
void fileWrite(QString path, QString address, bool autosetup, bool rename, bool timerename, bool autocopy, QString username, QString password);
|
||||
void fileWrite(QString path);
|
||||
|
||||
static QScopedPointer<FileConfigDecode> m_instance;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user