Server settings are read from QSettings and applied if they are changed.

This commit is contained in:
2026-02-03 11:17:26 +01:00
parent d4ff1ffb61
commit 6adf18caeb
5 changed files with 37 additions and 5 deletions

View File

@ -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);
}
}