diff --git a/client/ui/models/containers_model.cpp b/client/ui/models/containers_model.cpp index afff44b6d..6cf855a65 100644 --- a/client/ui/models/containers_model.cpp +++ b/client/ui/models/containers_model.cpp @@ -214,6 +214,20 @@ bool ContainersModel::isAmneziaDnsContainerInstalled(const int serverIndex) return containers.contains(DockerContainer::Dns); } +bool ContainersModel::isAnyContainerInstalled() +{ + for (int row=0; row < rowCount(); row++) { + QModelIndex idx = this->index(row, 0); + + if (this->data(idx, IsInstalledRole).toBool() && + this->data(idx, ServiceTypeRole).toInt() == ServiceType::Vpn) { + return true; + } + } + + return false; +} + QHash ContainersModel::roleNames() const { QHash roles; diff --git a/client/ui/models/containers_model.h b/client/ui/models/containers_model.h index 741a0620b..2cc41cbfe 100644 --- a/client/ui/models/containers_model.h +++ b/client/ui/models/containers_model.h @@ -63,7 +63,7 @@ public slots: bool isAmneziaDnsContainerInstalled(); bool isAmneziaDnsContainerInstalled(const int serverIndex); - // bool isOnlyServicesInstalled(const int serverIndex); + bool isAnyContainerInstalled(); protected: QHash roleNames() const override; diff --git a/client/ui/qml/Components/ConnectButton.qml b/client/ui/qml/Components/ConnectButton.qml index ab28d0d05..b7484c733 100644 --- a/client/ui/qml/Components/ConnectButton.qml +++ b/client/ui/qml/Components/ConnectButton.qml @@ -5,6 +5,7 @@ import QtQuick.Shapes import Qt5Compat.GraphicalEffects import ConnectionState 1.0 +import PageEnum 1.0 Button { id: root @@ -137,6 +138,13 @@ Button { } onClicked: { + if (!ContainersModel.isAnyContainerInstalled()) { + ServersModel.currentlyProcessedIndex = ServersModel.getDefaultServerIndex() + PageController.goToPage(PageEnum.PageSetupWizardEasy) + + return + } + if (ConnectionController.isConnectionInProgress) { ConnectionController.closeConnection() } else if (ConnectionController.isConnected) { diff --git a/client/ui/qml/Pages2/PageSetupWizardEasy.qml b/client/ui/qml/Pages2/PageSetupWizardEasy.qml index b228a7a3e..4f94e9851 100644 --- a/client/ui/qml/Pages2/PageSetupWizardEasy.qml +++ b/client/ui/qml/Pages2/PageSetupWizardEasy.qml @@ -183,6 +183,8 @@ PageType { textColor: "#D7D8DB" borderWidth: 1 + visible: ContainersModel.isAnyContainerInstalled() + text: qsTr("Set up later") onClicked: function() {