Added the advanced settings page

- added a button to scan the server for installed containers
- added a check on the presence of installed containers before configuring the server, if the containers are already installed, then we will add them to the GUI
- added new control element - PopupWarning.qml
This commit is contained in:
vladimir.kuznetsov 2023-02-20 09:46:50 +03:00
parent b5778a9cb5
commit ddc3fe7807
23 changed files with 487 additions and 156 deletions

View file

@ -27,10 +27,10 @@ void ServerSettingsLogic::onUpdatePage()
{
set_labelWaitInfoVisible(false);
set_labelWaitInfoText("");
set_pushButtonClearVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
set_pushButtonClearClientCacheVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
const QJsonObject &server = m_settings->server(uiLogic()->selectedServerIndex);
set_pushButtonClearVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex));
set_pushButtonClearClientCacheVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex));
set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->m_selectedServerIndex));
const QJsonObject &server = m_settings->server(uiLogic()->m_selectedServerIndex);
const QString &port = server.value(config_key::port).toString();
const QString &userName = server.value(config_key::userName).toString();
@ -45,7 +45,7 @@ void ServerSettingsLogic::onUpdatePage()
set_labelServerText(name);
set_lineEditDescriptionText(server.value(config_key::description).toString());
DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->m_selectedServerIndex);
QString selectedContainerName = ContainerProps::containerHumanNames().value(selectedContainer);
set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName);
}
@ -55,12 +55,12 @@ void ServerSettingsLogic::onPushButtonClearServer()
set_pageEnabled(false);
set_pushButtonClearText(tr("Uninstalling Amnezia software..."));
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex) {
if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex) {
uiLogic()->pageLogic<VpnLogic>()->onDisconnect();
}
ErrorCode e = m_serverController->removeAllContainers(m_settings->serverCredentials(uiLogic()->selectedServerIndex));
m_serverController->disconnectFromHost(m_settings->serverCredentials(uiLogic()->selectedServerIndex));
ErrorCode e = m_serverController->removeAllContainers(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
m_serverController->disconnectFromHost(m_settings->serverCredentials(uiLogic()->m_selectedServerIndex));
if (e) {
uiLogic()->set_dialogConnectErrorText(
tr("Error occurred while configuring server.") + "\n" +
@ -73,8 +73,8 @@ void ServerSettingsLogic::onPushButtonClearServer()
set_labelWaitInfoText(tr("Amnezia server successfully uninstalled"));
}
m_settings->setContainers(uiLogic()->selectedServerIndex, {});
m_settings->setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
m_settings->setContainers(uiLogic()->m_selectedServerIndex, {});
m_settings->setDefaultContainer(uiLogic()->m_selectedServerIndex, DockerContainer::None);
set_pageEnabled(true);
set_pushButtonClearText(tr("Clear server from Amnezia software"));
@ -82,15 +82,15 @@ void ServerSettingsLogic::onPushButtonClearServer()
void ServerSettingsLogic::onPushButtonForgetServer()
{
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex && uiLogic()->m_vpnConnection->isConnected()) {
uiLogic()->pageLogic<VpnLogic>()->onDisconnect();
}
m_settings->removeServer(uiLogic()->selectedServerIndex);
m_settings->removeServer(uiLogic()->m_selectedServerIndex);
if (m_settings->defaultServerIndex() == uiLogic()->selectedServerIndex) {
if (m_settings->defaultServerIndex() == uiLogic()->m_selectedServerIndex) {
m_settings->setDefaultServer(0);
}
else if (m_settings->defaultServerIndex() > uiLogic()->selectedServerIndex) {
else if (m_settings->defaultServerIndex() > uiLogic()->m_selectedServerIndex) {
m_settings->setDefaultServer(m_settings->defaultServerIndex() - 1);
}
@ -99,7 +99,7 @@ void ServerSettingsLogic::onPushButtonForgetServer()
}
uiLogic()->selectedServerIndex = -1;
uiLogic()->m_selectedServerIndex = -1;
uiLogic()->onUpdateAllPages();
if (m_settings->serversCount() == 0) {
@ -114,9 +114,9 @@ void ServerSettingsLogic::onPushButtonClearClientCacheClicked()
{
set_pushButtonClearClientCacheText(tr("Cache cleared"));
const auto &containers = m_settings->containers(uiLogic()->selectedServerIndex);
for (DockerContainer container: containers.keys()) {
m_settings->clearLastConnectionConfig(uiLogic()->selectedServerIndex, container);
const auto &containers = m_settings->containers(uiLogic()->m_selectedServerIndex);
for (DockerContainer container : containers.keys()) {
m_settings->clearLastConnectionConfig(uiLogic()->m_selectedServerIndex, container);
}
QTimer::singleShot(3000, this, [this]() {
@ -127,9 +127,9 @@ void ServerSettingsLogic::onPushButtonClearClientCacheClicked()
void ServerSettingsLogic::onLineEditDescriptionEditingFinished()
{
const QString &newText = lineEditDescriptionText();
QJsonObject server = m_settings->server(uiLogic()->selectedServerIndex);
QJsonObject server = m_settings->server(uiLogic()->m_selectedServerIndex);
server.insert(config_key::description, newText);
m_settings->editServer(uiLogic()->selectedServerIndex, server);
m_settings->editServer(uiLogic()->m_selectedServerIndex, server);
uiLogic()->onUpdateAllPages();
}
@ -168,7 +168,7 @@ void ServerSettingsLogic::onPushButtonShareFullClicked()
}
}
#else
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(uiLogic()->selectedServerIndex, DockerContainer::None);
uiLogic()->pageLogic<ShareConnectionLogic>()->updateSharingPage(uiLogic()->m_selectedServerIndex, DockerContainer::None);
emit uiLogic()->goToShareProtocolPage(Proto::Any);
#endif
}