Merge branch 'dev' into feature/qt6-libssh-support
This commit is contained in:
commit
ad77d74f4b
10 changed files with 64 additions and 26 deletions
|
|
@ -69,7 +69,7 @@ void AdvancedServerSettingsLogic::onPushButtonScanServerClicked()
|
|||
|
||||
bool isServerCreated;
|
||||
auto containersCount = m_settings->containers(uiLogic()->m_selectedServerIndex).size();
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(false, isServerCreated);
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated);
|
||||
if (errorCode != ErrorCode::NoError) {
|
||||
emit uiLogic()->showWarningMessage(tr("Error occurred while scanning the server.") + "\n" +
|
||||
tr("Error message: ") + errorString(errorCode) + "\n" +
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
#include <utilities.h>
|
||||
|
||||
using namespace amnezia;
|
||||
using namespace PageEnumNS;
|
||||
|
|
@ -82,8 +83,8 @@ void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
|
|||
|
||||
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
QString fileName = Utils::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
|
|
@ -98,6 +99,5 @@ void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
|||
} else {
|
||||
emit uiLogic()->showWarningMessage(tr("Can't import config, file is corrupted."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
|
||||
#include "protocols/CloakLogic.h"
|
||||
#include "protocols/OpenVpnLogic.h"
|
||||
#include "protocols/ShadowSocksLogic.h"
|
||||
#include "protocols/PageProtocolLogicBase.h"
|
||||
|
||||
#include "core/servercontroller.h"
|
||||
#include <functional>
|
||||
|
|
@ -92,7 +90,7 @@ void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int p
|
|||
qApp->processEvents();
|
||||
|
||||
bool isServerCreated = false;
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(false, isServerCreated);
|
||||
ErrorCode errorCode = uiLogic()->addAlreadyInstalledContainersGui(isServerCreated);
|
||||
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
if (!uiLogic()->isContainerAlreadyAddedToGui(c)) {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ void StartPageLogic::onPushButtonImport()
|
|||
|
||||
void StartPageLogic::onPushButtonImportOpenFile()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
||||
QString fileName = Utils::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn *.ovpn *.conf");
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ void UiLogic::installServer(QPair<DockerContainer, QJsonObject> &container)
|
|||
};
|
||||
|
||||
bool isServerCreated = false;
|
||||
ErrorCode errorCode = addAlreadyInstalledContainersGui(true, isServerCreated);
|
||||
ErrorCode errorCode = addAlreadyInstalledContainersGui(isServerCreated);
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
if (!isContainerAlreadyAddedToGui(container.first)) {
|
||||
progressBarFunc.setTextFunc(QString("Installing %1").arg(ContainerProps::containerToString(container.first)));
|
||||
|
|
@ -519,14 +519,22 @@ void UiLogic::registerPagesLogic()
|
|||
registerPageLogic<AdvancedServerSettingsLogic>();
|
||||
}
|
||||
|
||||
ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool createNewServer, bool &isServerCreated)
|
||||
ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool &isServerCreated)
|
||||
{
|
||||
isServerCreated = false;
|
||||
ServerCredentials credentials;
|
||||
if (createNewServer) {
|
||||
credentials = m_installCredentials;
|
||||
} else {
|
||||
credentials = m_settings->serverCredentials(m_selectedServerIndex);
|
||||
ServerCredentials installCredentials = m_installCredentials;
|
||||
bool createNewServer = true;
|
||||
int serverIndex;
|
||||
|
||||
for (int i = 0; i < m_settings->serversCount(); i++) {
|
||||
const ServerCredentials credentials = m_settings->serverCredentials(i);
|
||||
if (m_installCredentials.hostName == credentials.hostName && m_installCredentials.port == credentials.port) {
|
||||
createNewServer = false;
|
||||
isServerCreated = true;
|
||||
installCredentials = credentials;
|
||||
serverIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||
|
|
@ -540,10 +548,10 @@ ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool createNewServer, bool &
|
|||
QJsonObject server;
|
||||
QJsonArray containerConfigs;
|
||||
if (createNewServer) {
|
||||
server.insert(config_key::hostName, credentials.hostName);
|
||||
server.insert(config_key::userName, credentials.userName);
|
||||
server.insert(config_key::password, credentials.password);
|
||||
server.insert(config_key::port, credentials.port);
|
||||
server.insert(config_key::hostName, installCredentials.hostName);
|
||||
server.insert(config_key::userName, installCredentials.userName);
|
||||
server.insert(config_key::password, installCredentials.password);
|
||||
server.insert(config_key::port, installCredentials.port);
|
||||
server.insert(config_key::description, m_settings->nextAvailableServerName());
|
||||
}
|
||||
|
||||
|
|
@ -556,8 +564,8 @@ ErrorCode UiLogic::addAlreadyInstalledContainersGui(bool createNewServer, bool &
|
|||
containerConfigs.append(container.value());
|
||||
server.insert(config_key::containers, containerConfigs);
|
||||
} else {
|
||||
m_settings->setContainerConfig(m_selectedServerIndex, container.key(), container.value());
|
||||
m_settings->setDefaultContainer(m_selectedServerIndex, installedContainers.firstKey());
|
||||
m_settings->setContainerConfig(serverIndex, container.key(), container.value());
|
||||
m_settings->setDefaultContainer(serverIndex, installedContainers.firstKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public:
|
|||
Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data);
|
||||
Q_INVOKABLE void copyToClipboard(const QString& text);
|
||||
|
||||
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool createNewServer, bool &isServerCreated);
|
||||
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated);
|
||||
|
||||
void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue