removed the display of servers without containers on PageShare (#609)
* removed the display of servers without containers on PageShare * removed unused isAnyContainerInstalled() from containers model * added tab navigation to the share connection drawer * fixed display of default server without containers on PageShare
This commit is contained in:
parent
e648054c7a
commit
cd055cff62
13 changed files with 73 additions and 49 deletions
|
|
@ -25,12 +25,13 @@ ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &s
|
||||||
|
|
||||||
void ConnectionController::openConnection()
|
void ConnectionController::openConnection()
|
||||||
{
|
{
|
||||||
if (!m_containersModel->isAnyContainerInstalled()) {
|
int serverIndex = m_serversModel->getDefaultServerIndex();
|
||||||
|
|
||||||
|
if (!m_serversModel->data(serverIndex, ServersModel::Roles::HasInstalledContainers).toBool()) {
|
||||||
emit noInstalledContainers();
|
emit noInstalledContainers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int serverIndex = m_serversModel->getDefaultServerIndex();
|
|
||||||
ServerCredentials credentials = m_serversModel->getServerCredentials(serverIndex);
|
ServerCredentials credentials = m_serversModel->getServerCredentials(serverIndex);
|
||||||
|
|
||||||
DockerContainer container = qvariant_cast<DockerContainer>(m_serversModel->data(serverIndex, ServersModel::Roles::DefaultContainerRole));
|
DockerContainer container = qvariant_cast<DockerContainer>(m_serversModel->data(serverIndex, ServersModel::Roles::DefaultContainerRole));
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ bool PageController::isTriggeredByConnectButton()
|
||||||
return m_isTriggeredByConnectButton;
|
return m_isTriggeredByConnectButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PageController::setTriggeredBtConnectButton(bool trigger)
|
void PageController::setTriggeredByConnectButton(bool trigger)
|
||||||
{
|
{
|
||||||
m_isTriggeredByConnectButton = trigger;
|
m_isTriggeredByConnectButton = trigger;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public slots:
|
||||||
void showOnStartup();
|
void showOnStartup();
|
||||||
|
|
||||||
bool isTriggeredByConnectButton();
|
bool isTriggeredByConnectButton();
|
||||||
void setTriggeredBtConnectButton(bool trigger);
|
void setTriggeredByConnectButton(bool trigger);
|
||||||
|
|
||||||
void closeApplication();
|
void closeApplication();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,20 +83,6 @@ QJsonObject ContainersModel::getContainerConfig(const int containerIndex)
|
||||||
return qvariant_cast<QJsonObject>(data(index(containerIndex), ConfigRole));
|
return qvariant_cast<QJsonObject>(data(index(containerIndex), ConfigRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
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> ContainersModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,6 @@ public slots:
|
||||||
|
|
||||||
QJsonObject getContainerConfig(const int containerIndex);
|
QJsonObject getContainerConfig(const int containerIndex);
|
||||||
|
|
||||||
bool isAnyContainerInstalled();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,9 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
||||||
case DefaultContainerRole: {
|
case DefaultContainerRole: {
|
||||||
return ContainerProps::containerFromString(server.value(config_key::defaultContainer).toString());
|
return ContainerProps::containerFromString(server.value(config_key::defaultContainer).toString());
|
||||||
}
|
}
|
||||||
|
case HasInstalledContainers: {
|
||||||
|
return serverHasInstalledContainers(index.row());
|
||||||
|
}
|
||||||
case IsServerFromApiRole: {
|
case IsServerFromApiRole: {
|
||||||
return server.value(config_key::configVersion).toInt();
|
return server.value(config_key::configVersion).toInt();
|
||||||
}
|
}
|
||||||
|
|
@ -302,6 +305,7 @@ QHash<int, QByteArray> ServersModel::roleNames() const
|
||||||
roles[ContainsAmneziaDnsRole] = "containsAmneziaDns";
|
roles[ContainsAmneziaDnsRole] = "containsAmneziaDns";
|
||||||
|
|
||||||
roles[DefaultContainerRole] = "defaultContainer";
|
roles[DefaultContainerRole] = "defaultContainer";
|
||||||
|
roles[HasInstalledContainers] = "hasInstalledContainers";
|
||||||
|
|
||||||
roles[IsServerFromApiRole] = "isServerFromApi";
|
roles[IsServerFromApiRole] = "isServerFromApi";
|
||||||
return roles;
|
return roles;
|
||||||
|
|
@ -548,6 +552,19 @@ bool ServersModel::isServerFromApiAlreadyExists(const quint16 crc)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServersModel::serverHasInstalledContainers(const int serverIndex) const
|
||||||
|
{
|
||||||
|
QJsonObject server = m_servers.at(serverIndex).toObject();
|
||||||
|
const auto containers = server.value(config_key::containers).toArray();
|
||||||
|
for (auto it = containers.begin(); it != containers.end(); it++) {
|
||||||
|
auto container = ContainerProps::containerFromString(it->toObject().value(config_key::container).toString());
|
||||||
|
if (ContainerProps::containerService(container) == ServiceType::Vpn) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant ServersModel::getDefaultServerData(const QString roleString)
|
QVariant ServersModel::getDefaultServerData(const QString roleString)
|
||||||
{
|
{
|
||||||
auto roles = roleNames();
|
auto roles = roleNames();
|
||||||
|
|
@ -560,11 +577,6 @@ QVariant ServersModel::getDefaultServerData(const QString roleString)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServersModel::setDefaultServerData(const QString roleString, const QVariant &value)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant ServersModel::getProcessedServerData(const QString roleString)
|
QVariant ServersModel::getProcessedServerData(const QString roleString)
|
||||||
{
|
{
|
||||||
auto roles = roleNames();
|
auto roles = roleNames();
|
||||||
|
|
@ -577,11 +589,6 @@ QVariant ServersModel::getProcessedServerData(const QString roleString)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServersModel::setProcessedServerData(const QString roleString, const QVariant &value)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ServersModel::isDefaultServerDefaultContainerHasSplitTunneling()
|
bool ServersModel::isDefaultServerDefaultContainerHasSplitTunneling()
|
||||||
{
|
{
|
||||||
auto server = m_servers.at(m_defaultServerIndex).toObject();
|
auto server = m_servers.at(m_defaultServerIndex).toObject();
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public:
|
||||||
|
|
||||||
DefaultContainerRole,
|
DefaultContainerRole,
|
||||||
|
|
||||||
|
HasInstalledContainers,
|
||||||
IsServerFromApiRole,
|
IsServerFromApiRole,
|
||||||
|
|
||||||
HasAmneziaDns
|
HasAmneziaDns
|
||||||
|
|
@ -101,10 +102,8 @@ public slots:
|
||||||
bool isServerFromApiAlreadyExists(const quint16 crc);
|
bool isServerFromApiAlreadyExists(const quint16 crc);
|
||||||
|
|
||||||
QVariant getDefaultServerData(const QString roleString);
|
QVariant getDefaultServerData(const QString roleString);
|
||||||
void setDefaultServerData(const QString roleString, const QVariant &value);
|
|
||||||
|
|
||||||
QVariant getProcessedServerData(const QString roleString);
|
QVariant getProcessedServerData(const QString roleString);
|
||||||
void setProcessedServerData(const QString roleString, const QVariant &value);
|
|
||||||
|
|
||||||
bool isDefaultServerDefaultContainerHasSplitTunneling();
|
bool isDefaultServerDefaultContainerHasSplitTunneling();
|
||||||
|
|
||||||
|
|
@ -123,6 +122,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ServerCredentials serverCredentials(int index) const;
|
ServerCredentials serverCredentials(int index) const;
|
||||||
|
|
||||||
void updateContainersModel();
|
void updateContainersModel();
|
||||||
void updateDefaultServerContainersModel();
|
void updateDefaultServerContainersModel();
|
||||||
|
|
||||||
|
|
@ -130,6 +130,8 @@ private:
|
||||||
|
|
||||||
bool isAmneziaDnsContainerInstalled(const int serverIndex) const;
|
bool isAmneziaDnsContainerInstalled(const int serverIndex) const;
|
||||||
|
|
||||||
|
bool serverHasInstalledContainers(const int serverIndex) const;
|
||||||
|
|
||||||
QJsonArray m_servers;
|
QJsonArray m_servers;
|
||||||
|
|
||||||
std::shared_ptr<Settings> m_settings;
|
std::shared_ptr<Settings> m_settings;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,14 @@ DrawerType2 {
|
||||||
expandedContent: Item {
|
expandedContent: Item {
|
||||||
implicitHeight: root.expandedHeight
|
implicitHeight: root.expandedHeight
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root
|
||||||
|
|
||||||
|
function onOpened() {
|
||||||
|
header.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Header2Type {
|
Header2Type {
|
||||||
id: header
|
id: header
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
|
@ -48,6 +56,8 @@ DrawerType2 {
|
||||||
anchors.rightMargin: 16
|
anchors.rightMargin: 16
|
||||||
|
|
||||||
headerText: root.headerText
|
headerText: root.headerText
|
||||||
|
|
||||||
|
KeyNavigation.tab: shareButton
|
||||||
}
|
}
|
||||||
|
|
||||||
FlickableType {
|
FlickableType {
|
||||||
|
|
@ -68,12 +78,15 @@ DrawerType2 {
|
||||||
visible: root.contentVisible
|
visible: root.contentVisible
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
|
id: shareButton
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 16
|
Layout.topMargin: 16
|
||||||
|
|
||||||
text: qsTr("Share")
|
text: qsTr("Share")
|
||||||
imageSource: "qrc:/images/controls/share-2.svg"
|
imageSource: "qrc:/images/controls/share-2.svg"
|
||||||
|
|
||||||
|
KeyNavigation.tab: copyConfigTextButton
|
||||||
|
|
||||||
clickedFunc: function() {
|
clickedFunc: function() {
|
||||||
var fileName = ""
|
var fileName = ""
|
||||||
if (GC.isMobile()) {
|
if (GC.isMobile()) {
|
||||||
|
|
@ -107,6 +120,8 @@ DrawerType2 {
|
||||||
|
|
||||||
text: qsTr("Copy")
|
text: qsTr("Copy")
|
||||||
imageSource: "qrc:/images/controls/copy.svg"
|
imageSource: "qrc:/images/controls/copy.svg"
|
||||||
|
|
||||||
|
KeyNavigation.tab: copyNativeConfigStringButton.visible ? copyNativeConfigStringButton : showSettingsButton
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
|
|
@ -125,9 +140,13 @@ DrawerType2 {
|
||||||
|
|
||||||
text: qsTr("Copy config string")
|
text: qsTr("Copy config string")
|
||||||
imageSource: "qrc:/images/controls/copy.svg"
|
imageSource: "qrc:/images/controls/copy.svg"
|
||||||
|
|
||||||
|
KeyNavigation.tab: showSettingsButton
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
|
id: showSettingsButton
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
|
|
||||||
|
|
@ -143,6 +162,8 @@ DrawerType2 {
|
||||||
clickedFunc: function() {
|
clickedFunc: function() {
|
||||||
configContentDrawer.open()
|
configContentDrawer.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyNavigation.tab: header
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawerType2 {
|
DrawerType2 {
|
||||||
|
|
|
||||||
|
|
@ -33,22 +33,23 @@ Button {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
id: background_border
|
id: focusBorder
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
border.color: root.activeFocus ? root.borderFocusedColor : "transparent"
|
border.color: root.activeFocus ? root.borderFocusedColor : "transparent"
|
||||||
border.width: root.activeFocus ? root.borderFocusedWidth : "transparent"
|
border.width: root.activeFocus ? root.borderFocusedWidth : "transparent"
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
radius: 16
|
radius: 16
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: background
|
id: background
|
||||||
|
|
||||||
anchors.fill: background_border
|
anchors.fill: focusBorder
|
||||||
anchors.margins: root.activeFocus ? 2 : 0
|
anchors.margins: root.activeFocus ? 2 : 0
|
||||||
|
|
||||||
radius: 16
|
radius: root.activeFocus ? 14 : 16
|
||||||
color: {
|
color: {
|
||||||
if (root.enabled) {
|
if (root.enabled) {
|
||||||
if (root.pressed) {
|
if (root.pressed) {
|
||||||
|
|
@ -59,8 +60,8 @@ Button {
|
||||||
return disabledColor
|
return disabledColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
border.color: root.activeFocus ? "transparent" : borderColor
|
border.color: borderColor
|
||||||
border.width: root.activeFocus ? 0 : borderWidth
|
border.width: borderWidth
|
||||||
|
|
||||||
Behavior on color {
|
Behavior on color {
|
||||||
PropertyAnimation { duration: 200 }
|
PropertyAnimation { duration: 200 }
|
||||||
|
|
@ -95,13 +96,13 @@ Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: background_border
|
anchors.fill: focusBorder
|
||||||
enabled: false
|
enabled: false
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: Item {
|
contentItem: Item {
|
||||||
anchors.fill: background_border
|
anchors.fill: focusBorder
|
||||||
|
|
||||||
implicitWidth: content.implicitWidth
|
implicitWidth: content.implicitWidth
|
||||||
implicitHeight: content.implicitHeight
|
implicitHeight: content.implicitHeight
|
||||||
|
|
|
||||||
|
|
@ -187,9 +187,8 @@ PageType {
|
||||||
|
|
||||||
visible: {
|
visible: {
|
||||||
if (PageController.isTriggeredByConnectButton()) {
|
if (PageController.isTriggeredByConnectButton()) {
|
||||||
PageController.setTriggeredBtConnectButton(false)
|
PageController.setTriggeredByConnectButton(false)
|
||||||
|
return false
|
||||||
return ContainersModel.isAnyContainerInstalled()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -308,6 +308,10 @@ PageType {
|
||||||
ValueFilter {
|
ValueFilter {
|
||||||
roleName: "hasWriteAccess"
|
roleName: "hasWriteAccess"
|
||||||
value: true
|
value: true
|
||||||
|
},
|
||||||
|
ValueFilter {
|
||||||
|
roleName: "hasInstalledContainers"
|
||||||
|
value: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -324,8 +328,12 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
serverSelectorListView.currentIndex = ServersModel.isDefaultServerHasWriteAccess() ?
|
if (ServersModel.isDefaultServerHasWriteAccess() && ServersModel.getDefaultServerData("hasInstalledContainers")) {
|
||||||
proxyServersModel.mapFromSource(ServersModel.defaultIndex) : 0
|
serverSelectorListView.currentIndex = proxyServersModel.mapFromSource(ServersModel.defaultIndex)
|
||||||
|
} else {
|
||||||
|
serverSelectorListView.currentIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
serverSelectorListView.triggerCurrentItem()
|
serverSelectorListView.triggerCurrentItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,6 +488,7 @@ PageType {
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 40
|
Layout.topMargin: 40
|
||||||
|
Layout.bottomMargin: 32
|
||||||
|
|
||||||
enabled: shareButtonEnabled
|
enabled: shareButtonEnabled
|
||||||
visible: accessTypeSelector.currentIndex === 0
|
visible: accessTypeSelector.currentIndex === 0
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ PageType {
|
||||||
tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.Immediate)
|
tabBarStackView.push(pagePath, { "objectName" : pagePath }, StackView.Immediate)
|
||||||
}
|
}
|
||||||
|
|
||||||
tabBar.isServerInfoShow = page === PageEnum.PageSettingsServerInfo || PageEnum.PageSettingsSplitTunneling || tabBar.isServerInfoShow
|
tabBar.isServerInfoShow = (page === PageEnum.PageSettingsServerInfo) || (page === PageEnum.PageSettingsSplitTunneling) || tabBar.isServerInfoShow
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGoToStartPage() {
|
function onGoToStartPage() {
|
||||||
|
|
@ -122,7 +122,7 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onNoInstalledContainers() {
|
function onNoInstalledContainers() {
|
||||||
PageController.setTriggeredBtConnectButton(true)
|
PageController.setTriggeredByConnectButton(true)
|
||||||
|
|
||||||
ServersModel.processedIndex = ServersModel.getDefaultServerIndex()
|
ServersModel.processedIndex = ServersModel.getDefaultServerIndex()
|
||||||
InstallController.setShouldCreateServer(false)
|
InstallController.setShouldCreateServer(false)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue