Skip to content

Commit

Permalink
redirected to pagesetupwizardeasy when none containers installed
Browse files Browse the repository at this point in the history
  • Loading branch information
ronoaer committed Sep 24, 2023
1 parent a6d660e commit 51497d8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
14 changes: 14 additions & 0 deletions client/ui/models/containers_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, QByteArray> ContainersModel::roleNames() const
{
QHash<int, QByteArray> roles;
Expand Down
2 changes: 1 addition & 1 deletion client/ui/models/containers_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public slots:
bool isAmneziaDnsContainerInstalled();
bool isAmneziaDnsContainerInstalled(const int serverIndex);

// bool isOnlyServicesInstalled(const int serverIndex);
bool isAnyContainerInstalled();

protected:
QHash<int, QByteArray> roleNames() const override;
Expand Down
8 changes: 8 additions & 0 deletions client/ui/qml/Components/ConnectButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import QtQuick.Shapes
import Qt5Compat.GraphicalEffects

import ConnectionState 1.0
import PageEnum 1.0

Button {
id: root
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions client/ui/qml/Pages2/PageSetupWizardEasy.qml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ PageType {
textColor: "#D7D8DB"
borderWidth: 1

visible: ContainersModel.isAnyContainerInstalled()

text: qsTr("Set up later")

onClicked: function() {
Expand Down

0 comments on commit 51497d8

Please sign in to comment.