Server settings are read from QSettings and applied if they are changed.
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
#include "CoreConfig.h"
|
||||
#include "constants.h"
|
||||
#include "data/filehandler.h"
|
||||
#include "data/settingshandler.h"
|
||||
#include "model/generalsortfiltermodel.h"
|
||||
#include "model/metadata.h"
|
||||
#include "model/tablemodel.h"
|
||||
@ -134,6 +135,14 @@ bool GenericCore::exportCSVFile(const QString& filePath) {
|
||||
return FileHandler::exportToCSVFile(itemsAsStringLists, filePath);
|
||||
}
|
||||
|
||||
void GenericCore::applySettings(QVariantMap settingMap, QString group) {
|
||||
SettingsHandler::saveSettings(settingMap, group);
|
||||
|
||||
if (group == "Server") {
|
||||
setupServerConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
bool GenericCore::isSyncServerSetup() const {
|
||||
if (m_serverCommunicator) {
|
||||
return true;
|
||||
@ -254,7 +263,15 @@ void GenericCore::setupServerConfiguration() {
|
||||
connect(m_serverCommunicator.get(), &ServerCommunicator::deleteRequestFailure, this,
|
||||
&GenericCore::onDeleteRequestFailure);
|
||||
|
||||
/// fetching/posting items on startup to test the communication with the server
|
||||
// m_serverCommunicator->fetchItems();
|
||||
// m_serverCommunicator->postItems();
|
||||
applyServerConfiguration();
|
||||
}
|
||||
|
||||
void GenericCore::applyServerConfiguration() {
|
||||
const QVariantMap serverSettings = SettingsHandler::getSettings("Server");
|
||||
const QString urlValue = serverSettings.value("url").toString();
|
||||
if (!urlValue.isEmpty()) {
|
||||
const QString emailValue = serverSettings.value("email").toString();
|
||||
const QString passwordValue = serverSettings.value("password").toString();
|
||||
m_serverCommunicator->setServerConfiguration(urlValue, emailValue, passwordValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user