mirror of
https://github.com/FAUSheppy/speech-server-client-qt
synced 2025-12-06 00:41:35 +01:00
Save settings before running check
https://github.com/FAUSheppy/speech-server-client-qt/issues/1
This commit is contained in:
11
settings.cpp
11
settings.cpp
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user