Save settings before running check

https://github.com/FAUSheppy/speech-server-client-qt/issues/1
This commit is contained in:
Yannik Schmidt
2020-09-05 22:07:48 +02:00
parent 4bee34fbd6
commit 3f6862e26b
2 changed files with 12 additions and 2 deletions

View File

@@ -97,6 +97,7 @@ void Settings::selectSettings(QSettings *selectedSettings){
}
void Settings::checkConfig(){
saveSetting();
ServerConnection *sc = new ServerConnection(this, mySettings);
connect(sc->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(handleTestConnectionResult(QNetworkReply*)));
sc->queryServerVersion();
@@ -134,6 +135,8 @@ void Settings::handleTestConnectionResult(QNetworkReply* reply){
auto cw = this->findChild<QWidget*>("centralwidget");
QGridLayout *layout = static_cast<QGridLayout*>(cw->layout());
delete currentConfigCheckDisplay; //this removes it from the layout
currentConfigCheckDisplay = testResult;
layout->addWidget(testResult, configOptions->length(), 1);
}
@@ -144,14 +147,18 @@ void Settings::cancleClose(){
this->close();
}
void Settings::okClose(){
void Settings::saveSetting(){
QSettings mySettings;
for(auto key : configLineEditMap->keys()){
QString input = configLineEditMap->take(key)->text();
QString input = configLineEditMap->value(key)->text();
if(input.compare("") != 0){
this->mySettings->setValue(key, input);
}
}
}
void Settings::okClose(){
saveSetting();
this->close();
}

View File

@@ -5,6 +5,7 @@
#include <QLineEdit>
#include <QSettings>
#include <QNetworkReply>
#include <QLabel>
namespace Ui {
class settings;
@@ -30,6 +31,8 @@ private:
QHash<QString, QLineEdit*> *configLineEditMap;
QStringList *configOptionsKeys;
QStringList *configOptions;
void saveSetting();
QLabel *currentConfigCheckDisplay;
};
#endif // SETTINGS_H