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

View File

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