UI fixes, VPN page fixes

This commit is contained in:
pokamest 2021-11-17 15:01:48 +03:00
parent 25428c9165
commit 9dee7bb7e7
25 changed files with 251 additions and 157 deletions

BIN
client/images/animation.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
client/images/connected.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -16,8 +16,6 @@
<file>images/tray/default.png</file> <file>images/tray/default.png</file>
<file>images/tray/error.png</file> <file>images/tray/error.png</file>
<file>images/arrow_left.png</file> <file>images/arrow_left.png</file>
<file>images/connect_button_connected.png</file>
<file>images/connect_button_disconnected.png</file>
<file>fonts/Lato-Black.ttf</file> <file>fonts/Lato-Black.ttf</file>
<file>fonts/Lato-BlackItalic.ttf</file> <file>fonts/Lato-BlackItalic.ttf</file>
<file>fonts/Lato-Bold.ttf</file> <file>fonts/Lato-Bold.ttf</file>
@ -140,5 +138,8 @@
<file>server_scripts/ipsec/mobileconfig.plist</file> <file>server_scripts/ipsec/mobileconfig.plist</file>
<file>ui/qml/Pages/Share/PageShareProtoIkev2.qml</file> <file>ui/qml/Pages/Share/PageShareProtoIkev2.qml</file>
<file>server_scripts/ipsec/strongswan.profile</file> <file>server_scripts/ipsec/strongswan.profile</file>
<file>images/animation.gif</file>
<file>images/connected.png</file>
<file>images/disconnected.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -43,7 +43,7 @@ void ServerContainersLogic::onPushButtonProtoSettingsClicked(DockerContainer c,
void ServerContainersLogic::onPushButtonDefaultClicked(DockerContainer c) void ServerContainersLogic::onPushButtonDefaultClicked(DockerContainer c)
{ {
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c); m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c);
onUpdatePage(); uiLogic()->onUpdateAllPages();
} }
void ServerContainersLogic::onPushButtonShareClicked(DockerContainer c) void ServerContainersLogic::onPushButtonShareClicked(DockerContainer c)
@ -64,7 +64,7 @@ void ServerContainersLogic::onPushButtonRemoveClicked(DockerContainer container)
if (c.isEmpty()) m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None); if (c.isEmpty()) m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, DockerContainer::None);
else m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c.keys().first()); else m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c.keys().first());
} }
onUpdatePage(); uiLogic()->onUpdateAllPages();
} }
void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp) void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp)
@ -85,6 +85,6 @@ void ServerContainersLogic::onPushButtonContinueClicked(DockerContainer c, int p
} }
} }
onUpdatePage(); uiLogic()->onUpdateAllPages();
emit uiLogic()->closePage(); emit uiLogic()->closePage();
} }

View file

@ -14,7 +14,7 @@ ServerListLogic::ServerListLogic(UiLogic *logic, QObject *parent):
void ServerListLogic::onServerListPushbuttonDefaultClicked(int index) void ServerListLogic::onServerListPushbuttonDefaultClicked(int index)
{ {
m_settings.setDefaultServer(index); m_settings.setDefaultServer(index);
onUpdatePage(); uiLogic()->onUpdateAllPages();
} }
void ServerListLogic::onServerListPushbuttonSettingsClicked(int index) void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)

View file

@ -37,7 +37,7 @@ void ServerSettingsLogic::onUpdatePage()
.arg(port)); .arg(port));
set_lineEditDescriptionText(server.value(config_key::description).toString()); set_lineEditDescriptionText(server.value(config_key::description).toString());
QString selectedContainerName = m_settings.defaultContainerName(uiLogic()->selectedServerIndex); QString selectedContainerName = m_settings.defaultContainerName(uiLogic()->selectedServerIndex);
set_labelCurrentVpnProtocolText(tr("Protocol: ") + selectedContainerName); set_labelCurrentVpnProtocolText(tr("Service: ") + selectedContainerName);
} }
void ServerSettingsLogic::onPushButtonClearServer() void ServerSettingsLogic::onPushButtonClearServer()
@ -90,8 +90,7 @@ void ServerSettingsLogic::onPushButtonForgetServer()
uiLogic()->selectedServerIndex = -1; uiLogic()->selectedServerIndex = -1;
uiLogic()->onUpdateAllPages();
uiLogic()->serverListLogic()->onUpdatePage();
if (m_settings.serversCount() == 0) { if (m_settings.serversCount() == 0) {
uiLogic()->setStartPage(Page::Start); uiLogic()->setStartPage(Page::Start);
@ -121,7 +120,7 @@ void ServerSettingsLogic::onLineEditDescriptionEditingFinished()
QJsonObject server = m_settings.server(uiLogic()->selectedServerIndex); QJsonObject server = m_settings.server(uiLogic()->selectedServerIndex);
server.insert(config_key::description, newText); server.insert(config_key::description, newText);
m_settings.editServer(uiLogic()->selectedServerIndex, server); m_settings.editServer(uiLogic()->selectedServerIndex, server);
uiLogic()->serverListLogic()->onUpdatePage(); uiLogic()->onUpdateAllPages();
} }
void ServerSettingsLogic::onPushButtonShareFullClicked() void ServerSettingsLogic::onPushButtonShareFullClicked()

View file

@ -43,6 +43,15 @@ void VpnLogic::onUpdatePage()
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites); set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites);
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites); set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites);
set_pushButtonVpnAddSiteEnabled(mode != Settings::VpnAllSites); set_pushButtonVpnAddSiteEnabled(mode != Settings::VpnAllSites);
const QJsonObject &server = uiLogic()->m_settings.defaultServer();
QString serverString = QString("%2 (%3)")
.arg(server.value(config_key::description).toString())
.arg(server.value(config_key::hostName).toString());
set_labelCurrentServer(serverString);
QString selectedContainerName = m_settings.defaultContainerName(m_settings.defaultServerIndex());
set_labelCurrentService(selectedContainerName);
} }
@ -79,6 +88,7 @@ void VpnLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state)
bool pbConnectEnabled = false; bool pbConnectEnabled = false;
bool rbModeEnabled = false; bool rbModeEnabled = false;
bool pbConnectVisible = false;
set_labelStateText(VpnProtocol::textConnectionState(state)); set_labelStateText(VpnProtocol::textConnectionState(state));
uiLogic()->setTrayState(state); uiLogic()->setTrayState(state);
@ -88,39 +98,48 @@ void VpnLogic::onConnectionStateChanged(VpnProtocol::ConnectionState state)
onBytesChanged(0,0); onBytesChanged(0,0);
set_pushButtonConnectChecked(false); set_pushButtonConnectChecked(false);
pbConnectEnabled = true; pbConnectEnabled = true;
pbConnectVisible = true;
rbModeEnabled = true; rbModeEnabled = true;
break; break;
case VpnProtocol::Preparing: case VpnProtocol::Preparing:
pbConnectEnabled = false; pbConnectEnabled = false;
pbConnectVisible = false;
rbModeEnabled = false; rbModeEnabled = false;
break; break;
case VpnProtocol::Connecting: case VpnProtocol::Connecting:
pbConnectEnabled = false; pbConnectEnabled = false;
pbConnectVisible = false;
rbModeEnabled = false; rbModeEnabled = false;
break; break;
case VpnProtocol::Connected: case VpnProtocol::Connected:
pbConnectEnabled = true; pbConnectEnabled = true;
pbConnectVisible = true;
rbModeEnabled = false; rbModeEnabled = false;
break; break;
case VpnProtocol::Disconnecting: case VpnProtocol::Disconnecting:
pbConnectEnabled = false; pbConnectEnabled = false;
pbConnectVisible = false;
rbModeEnabled = false; rbModeEnabled = false;
break; break;
case VpnProtocol::Reconnecting: case VpnProtocol::Reconnecting:
pbConnectEnabled = true; pbConnectEnabled = true;
pbConnectVisible = false;
rbModeEnabled = false; rbModeEnabled = false;
break; break;
case VpnProtocol::Error: case VpnProtocol::Error:
set_pushButtonConnectEnabled(false); set_pushButtonConnectEnabled(false);
pbConnectEnabled = true; pbConnectEnabled = true;
pbConnectVisible = true;
rbModeEnabled = true; rbModeEnabled = true;
break; break;
case VpnProtocol::Unknown: case VpnProtocol::Unknown:
pbConnectEnabled = true; pbConnectEnabled = true;
pbConnectVisible = true;
rbModeEnabled = true; rbModeEnabled = true;
} }
set_pushButtonConnectEnabled(pbConnectEnabled); set_pushButtonConnectEnabled(pbConnectEnabled);
set_pushButtonConnectVisible(pbConnectVisible);
set_widgetVpnModeEnabled(rbModeEnabled); set_widgetVpnModeEnabled(rbModeEnabled);
} }

View file

@ -14,7 +14,10 @@ class VpnLogic : public PageLogicBase
AUTO_PROPERTY(QString, labelSpeedReceivedText) AUTO_PROPERTY(QString, labelSpeedReceivedText)
AUTO_PROPERTY(QString, labelSpeedSentText) AUTO_PROPERTY(QString, labelSpeedSentText)
AUTO_PROPERTY(QString, labelStateText) AUTO_PROPERTY(QString, labelStateText)
AUTO_PROPERTY(QString, labelCurrentServer)
AUTO_PROPERTY(QString, labelCurrentService)
AUTO_PROPERTY(bool, pushButtonConnectEnabled) AUTO_PROPERTY(bool, pushButtonConnectEnabled)
AUTO_PROPERTY(bool, pushButtonConnectVisible)
AUTO_PROPERTY(bool, widgetVpnModeEnabled) AUTO_PROPERTY(bool, widgetVpnModeEnabled)
AUTO_PROPERTY(QString, labelErrorText) AUTO_PROPERTY(QString, labelErrorText)
AUTO_PROPERTY(bool, pushButtonVpnAddSiteEnabled) AUTO_PROPERTY(bool, pushButtonVpnAddSiteEnabled)

View file

@ -6,8 +6,6 @@ BasicButtonType {
id: root id: root
width: parent.width - 80 width: parent.width - 80
height: 40 height: 40
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent

View file

@ -20,7 +20,7 @@ Drawer {
height: parent.height height: parent.height
modal: true modal: true
interactive: true interactive: activeFocus
SortFilterProxyModel { SortFilterProxyModel {
id: proxyModel id: proxyModel

View file

@ -30,6 +30,7 @@ PageBase {
id: pushButtonWizard id: pushButtonWizard
text: qsTr("Run Setup Wizard") text: qsTr("Run Setup Wizard")
anchors.top: labelWizard.bottom anchors.top: labelWizard.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10 anchors.topMargin: 10
onClicked: { onClicked: {
UiLogic.goToPage(PageEnum.Wizard); UiLogic.goToPage(PageEnum.Wizard);

View file

@ -110,22 +110,11 @@ PageBase {
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: desc text: desc
} }
ImageButtonType {
x: 212
y: 25
width: 32
height: 24
checkable: true
iconMargin: 0
icon.source: checked ? "qrc:/images/connect_button_connected.png"
: "qrc:/images/connect_button_disconnected.png"
visible: false
}
ImageButtonType { ImageButtonType {
x: parent.width - 30 x: parent.width - 30
y: 25 y: 15
width: 24 width: 30
height: 24 height: 30
checkable: true checkable: true
icon.source: checked ? "qrc:/images/check.png" icon.source: checked ? "qrc:/images/check.png"
: "qrc:/images/uncheck.png" : "qrc:/images/uncheck.png"
@ -138,9 +127,9 @@ PageBase {
ImageButtonType { ImageButtonType {
id: pushButtonSetting id: pushButtonSetting
x: parent.width - 60 x: parent.width - 60
y: 25 y: 15
width: 24 width: 30
height: 24 height: 30
icon.source: "qrc:/images/settings.png" icon.source: "qrc:/images/settings.png"
opacity: 0 opacity: 0

View file

@ -15,36 +15,30 @@ PageBase {
BackButton { BackButton {
id: back id: back
} }
Text {
font.family: "Lato" Caption {
font.styleName: "normal" id: caption
font.pixelSize: 16 text: SitesLogic.labelSitesAddCustomText
}
LabelType {
id: lb_addr
color: "#333333" color: "#333333"
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
text: qsTr("Web site/Hostname/IP address/Subnet") text: qsTr("Web site/Hostname/IP address/Subnet")
x: 20 x: 20
y: 110 anchors.top: caption.bottom
width: 311 anchors.topMargin: 10
width: parent.width
height: 21 height: 21
} }
Text {
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 20
color: "#100A44"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignTop
text: SitesLogic.labelSitesAddCustomText
x: 20
y: 40
width: 340
height: 60
}
TextFieldType { TextFieldType {
x: 20 anchors.top: lb_addr.bottom
y: 140 anchors.topMargin: 10
width: 231 anchors.left: parent.left
anchors.leftMargin: 20
anchors.right: sites_add.left
anchors.rightMargin: 10
height: 31 height: 31
placeholderText: qsTr("yousite.com or IP address") placeholderText: qsTr("yousite.com or IP address")
text: SitesLogic.lineEditSitesAddCustomText text: SitesLogic.lineEditSitesAddCustomText
@ -55,10 +49,13 @@ PageBase {
SitesLogic.onPushButtonAddCustomSitesClicked() SitesLogic.onPushButtonAddCustomSitesClicked()
} }
} }
BlueButtonType { BlueButtonType {
id: sites_add id: sites_add
x: 260 anchors.right: sites_import.left
y: 140 anchors.rightMargin: 10
anchors.top: lb_addr.bottom
anchors.topMargin: 10
width: 51 width: 51
height: 31 height: 31
font.pixelSize: 24 font.pixelSize: 24
@ -67,23 +64,13 @@ PageBase {
SitesLogic.onPushButtonAddCustomSitesClicked() SitesLogic.onPushButtonAddCustomSitesClicked()
} }
} }
BlueButtonType {
id: sites_delete
x: 80
y: 589
width: 231
height: 31
font.pixelSize: 16
text: qsTr("Delete selected")
onClicked: {
SitesLogic.onPushButtonSitesDeleteClicked(tb.currentRow)
}
}
BasicButtonType { BasicButtonType {
id: sites_import id: sites_import
x: 320 anchors.right: parent.right
y: 140 anchors.rightMargin: 20
anchors.top: lb_addr.bottom
anchors.topMargin: 10
width: 51 width: 51
height: 31 height: 31
background: Rectangle { background: Rectangle {
@ -116,12 +103,15 @@ PageBase {
SitesLogic.onPushButtonSitesImportClicked(fileUrl) SitesLogic.onPushButtonSitesImportClicked(fileUrl)
} }
} }
ListView { ListView {
id: tb id: tb
x: 20 x: 20
y: 200 anchors.top: sites_add.bottom
width: 341 anchors.topMargin: 10
height: 371 width: parent.width - 40
anchors.bottom: sites_delete.top
anchors.bottomMargin: 10
spacing: 1 spacing: 1
clip: true clip: true
property int currentRow: -1 property int currentRow: -1
@ -187,4 +177,17 @@ PageBase {
} }
} }
} }
BlueButtonType {
id: sites_delete
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
height: 31
font.pixelSize: 16
text: qsTr("Delete selected")
onClicked: {
SitesLogic.onPushButtonSitesDeleteClicked(tb.currentRow)
}
}
} }

View file

@ -128,7 +128,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 5 anchors.topMargin: 5
text: qsTr("Where to get connection data →") text: qsTr("How to get own server? →")
background: Item { background: Item {
anchors.fill: parent anchors.fill: parent
} }
@ -147,7 +147,7 @@ PageBase {
checkable: true checkable: true
checked: true checked: true
onClicked: { onClicked: {
Qt.openUrlExternally("https://amnezia.org") Qt.openUrlExternally("https://amnezia.org/instruction.html")
} }
} }
LabelType { LabelType {

View file

@ -1,5 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Layouts 1.15
import PageEnum 1.0 import PageEnum 1.0
import "./" import "./"
import "../Controls" import "../Controls"
@ -11,12 +12,11 @@ PageBase {
logic: VpnLogic logic: VpnLogic
Image { Image {
id: bg_top
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y: 0 y: 0
width: parent.width width: parent.width
height: parent.height * 0.28
// width: 380
// height: 325
source: "qrc:/images/background_connected.png" source: "qrc:/images/background_connected.png"
} }
@ -31,38 +31,26 @@ PageBase {
} }
} }
LabelType { AnimatedImage {
id: error_text id: connect_anim
x: 0 source: "qrc:/images/animation.gif"
y: 280 anchors.top: bg_top.bottom
width: 381 anchors.topMargin: 10
height: 61 anchors.horizontalCenter: root.horizontalCenter
horizontalAlignment: Text.AlignHCenter width: Math.min(parent.width, parent.height) / 4
verticalAlignment: Text.AlignVCenter height: width
wrapMode: Text.Wrap
text: VpnLogic.labelErrorText visible: !VpnLogic.pushButtonConnectVisible
} paused: VpnLogic.pushButtonConnectVisible
Text { //VisibleBehavior on visible { }
anchors.horizontalCenter: parent.horizontalCenter
y: 250
width: 380
height: 31
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 15
color: "#181922"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
text: VpnLogic.labelStateText
} }
BasicButtonType { BasicButtonType {
id: button_connect id: button_connect
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: connect_anim.horizontalCenter
y: 200 anchors.verticalCenter: connect_anim.verticalCenter
width: 80 width: connect_anim.width
height: 40 height: width
checkable: true checkable: true
checked: VpnLogic.pushButtonConnectChecked checked: VpnLogic.pushButtonConnectChecked
onCheckedChanged: { onCheckedChanged: {
@ -71,12 +59,96 @@ PageBase {
} }
background: Image { background: Image {
anchors.fill: parent anchors.fill: parent
source: button_connect.checked ? "qrc:/images/connect_button_connected.png" source: button_connect.checked ? "qrc:/images/connected.png"
: "qrc:/images/connect_button_disconnected.png" : "qrc:/images/disconnected.png"
} }
contentItem: Item {} contentItem: Item {}
antialiasing: true antialiasing: true
enabled: VpnLogic.pushButtonConnectEnabled enabled: VpnLogic.pushButtonConnectEnabled
opacity: VpnLogic.pushButtonConnectVisible ? 1 : 0
// transitions: Transition {
// NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad; duration: 500 }
// }
}
LabelType {
id: lb_state
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: button_connect.bottom
width: parent.width
height: 21
horizontalAlignment: Text.AlignHCenter
text: VpnLogic.labelStateText
}
RowLayout {
id: layout1
anchors.top: lb_state.bottom
//anchors.topMargin: 5
anchors.horizontalCenter: parent.horizontalCenter
height: 21
LabelType {
Layout.alignment: Qt.AlignRight
height: 21
text: qsTr("Server") + ": "
}
BasicButtonType {
Layout.alignment: Qt.AlignLeft
height: 21
background: Item {}
text: VpnLogic.labelCurrentServer
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
onClicked: {
UiLogic.goToPage(PageEnum.ServersList)
}
}
}
RowLayout {
id: layout2
anchors.top: layout1.bottom
anchors.topMargin: 5
anchors.horizontalCenter: parent.horizontalCenter
height: 21
LabelType {
Layout.alignment: Qt.AlignRight
height: 21
text: qsTr("Service") + ": "
}
BasicButtonType {
Layout.alignment: Qt.AlignLeft
height: 21
background: Item {}
text: VpnLogic.labelCurrentService
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
onClicked: {
UiLogic.onGotoCurrentProtocolsPage()
}
}
}
LabelType {
id: error_text
anchors.top: layout2.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: 21
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
text: VpnLogic.labelErrorText
} }
Item { Item {

View file

@ -36,8 +36,7 @@ PageShareProtocolBase {
ColumnLayout { ColumnLayout {
id: content id: content
enabled: logic.pageEnabled enabled: logic.pageEnabled
anchors.top: content.bottom anchors.top: parent.top
anchors.topMargin: 20
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

View file

@ -60,8 +60,7 @@ PageShareProtocolBase {
ColumnLayout { ColumnLayout {
id: content id: content
enabled: logic.pageEnabled enabled: logic.pageEnabled
anchors.top: content.bottom anchors.top: parent.top
anchors.topMargin: 20
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

View file

@ -36,8 +36,7 @@ PageShareProtocolBase {
ColumnLayout { ColumnLayout {
id: content id: content
enabled: logic.pageEnabled enabled: logic.pageEnabled
anchors.top: content.bottom anchors.top: parent.top
anchors.topMargin: 20
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

View file

@ -36,8 +36,7 @@ PageShareProtocolBase {
ColumnLayout { ColumnLayout {
id: content id: content
enabled: logic.pageEnabled enabled: logic.pageEnabled
anchors.top: content.bottom anchors.top: parent.top
anchors.topMargin: 20
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

View file

@ -36,8 +36,7 @@ PageShareProtocolBase {
ColumnLayout { ColumnLayout {
id: content id: content
enabled: logic.pageEnabled enabled: logic.pageEnabled
anchors.top: content.bottom anchors.top: parent.bottom
anchors.topMargin: 20
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

View file

@ -105,6 +105,28 @@ UiLogic::UiLogic(QObject *parent) :
} }
UiLogic::~UiLogic()
{
emit hide();
if (m_vpnConnection->connectionState() != VpnProtocol::ConnectionState::Disconnected) {
m_vpnConnection->disconnectFromVpn();
for (int i = 0; i < 50; i++) {
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
QThread::msleep(100);
if (m_vpnConnection->isDisconnected()) {
break;
}
}
}
m_vpnConnectionThread.quit();
m_vpnConnectionThread.wait(3000);
delete m_vpnConnection;
qDebug() << "Application closed";
}
void UiLogic::initalizeUiLogic() void UiLogic::initalizeUiLogic()
{ {
qDebug() << "UiLogic::initalizeUiLogic()"; qDebug() << "UiLogic::initalizeUiLogic()";
@ -210,19 +232,6 @@ void UiLogic::setTrayActionConnectEnabled(bool trayActionConnectEnabled)
} }
} }
QString UiLogic::getDialogConnectErrorText() const QString UiLogic::getDialogConnectErrorText() const
{ {
return m_dialogConnectErrorText; return m_dialogConnectErrorText;
@ -236,29 +245,6 @@ void UiLogic::setDialogConnectErrorText(const QString &dialogConnectErrorText)
} }
} }
UiLogic::~UiLogic()
{
emit hide();
if (m_vpnConnection->connectionState() != VpnProtocol::ConnectionState::Disconnected) {
m_vpnConnection->disconnectFromVpn();
for (int i = 0; i < 50; i++) {
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
QThread::msleep(100);
if (m_vpnConnection->isDisconnected()) {
break;
}
}
}
m_vpnConnectionThread.quit();
m_vpnConnectionThread.wait(3000);
delete m_vpnConnection;
qDebug() << "Application closed";
}
void UiLogic::showOnStartup() void UiLogic::showOnStartup()
{ {
if (! m_settings.isStartMinimized()) { if (! m_settings.isStartMinimized()) {
@ -270,6 +256,26 @@ void UiLogic::showOnStartup()
} }
} }
void UiLogic::onUpdateAllPages()
{
for (PageLogicBase *logic : {
(PageLogicBase *) m_appSettingsLogic,
(PageLogicBase *) m_generalSettingsLogic,
(PageLogicBase *) m_networkSettingsLogic,
(PageLogicBase *) m_serverConfiguringProgressLogic,
(PageLogicBase *) m_newServerProtocolsLogic,
(PageLogicBase *) m_serverListLogic,
(PageLogicBase *) m_serverSettingsLogic,
(PageLogicBase *) m_serverVpnProtocolsLogic,
(PageLogicBase *) m_shareConnectionLogic,
(PageLogicBase *) m_sitesLogic,
(PageLogicBase *) m_startPageLogic,
(PageLogicBase *) m_vpnLogic,
(PageLogicBase *) m_wizardLogic
}) {
logic->onUpdatePage();
}
}
void UiLogic::keyPressEvent(Qt::Key key) void UiLogic::keyPressEvent(Qt::Key key)
{ {
@ -306,9 +312,7 @@ void UiLogic::keyPressEvent(Qt::Key key)
emit goToPage(Page::ServerSettings); emit goToPage(Page::ServerSettings);
break; break;
case Qt::Key_P: case Qt::Key_P:
selectedServerIndex = m_settings.defaultServerIndex(); onGotoCurrentProtocolsPage();
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
emit goToPage(Page::ServerContainers);
break; break;
case Qt::Key_T: case Qt::Key_T:
SshConfigurator::openSshTerminal(m_settings.serverCredentials(m_settings.defaultServerIndex())); SshConfigurator::openSshTerminal(m_settings.serverCredentials(m_settings.defaultServerIndex()));
@ -351,6 +355,13 @@ QString UiLogic::containerDesc(int container)
} }
void UiLogic::onGotoCurrentProtocolsPage()
{
selectedServerIndex = m_settings.defaultServerIndex();
selectedDockerContainer = m_settings.defaultContainer(selectedServerIndex);
emit goToPage(Page::ServerContainers);
}
//void UiLogic::showEvent(QShowEvent *event) //void UiLogic::showEvent(QShowEvent *event)

View file

@ -85,6 +85,7 @@ public:
friend class OtherProtocolsLogic; friend class OtherProtocolsLogic;
Q_INVOKABLE virtual void onUpdatePage() {} // UiLogic is set as logic class for some qml pages Q_INVOKABLE virtual void onUpdatePage() {} // UiLogic is set as logic class for some qml pages
Q_INVOKABLE void onUpdateAllPages();
Q_INVOKABLE void initalizeUiLogic(); Q_INVOKABLE void initalizeUiLogic();
Q_INVOKABLE void onCloseWindow(); Q_INVOKABLE void onCloseWindow();
@ -96,6 +97,8 @@ public:
Q_INVOKABLE void onGotoProtocolPage(Protocol p, bool reset = true, bool slide = true) { emit goToProtocolPage(p, reset, slide); } Q_INVOKABLE void onGotoProtocolPage(Protocol p, bool reset = true, bool slide = true) { emit goToProtocolPage(p, reset, slide); }
Q_INVOKABLE void onGotoShareProtocolPage(Protocol p, bool reset = true, bool slide = true) { emit goToShareProtocolPage(p, reset, slide); } Q_INVOKABLE void onGotoShareProtocolPage(Protocol p, bool reset = true, bool slide = true) { emit goToShareProtocolPage(p, reset, slide); }
Q_INVOKABLE void onGotoCurrentProtocolsPage();
Q_INVOKABLE void keyPressEvent(Qt::Key key); Q_INVOKABLE void keyPressEvent(Qt::Key key);
Q_INVOKABLE bool saveTextFile(const QString& desc, const QString& ext, const QString& data); Q_INVOKABLE bool saveTextFile(const QString& desc, const QString& ext, const QString& data);