qml ui fixes

This commit is contained in:
pokamest 2021-09-19 14:31:38 +03:00
parent a390f2e988
commit 0d9f1ba95b
26 changed files with 168 additions and 103 deletions

View file

@ -1,5 +1,3 @@
!contains( CONFIG, c\+\+1[14] ): warning("SortFilterProxyModel needs at least c++11, add CONFIG += c++11 to your .pro")
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
HEADERS += $$PWD/qqmlsortfilterproxymodel.h \ HEADERS += $$PWD/qqmlsortfilterproxymodel.h \

View file

@ -116,8 +116,9 @@ int main(int argc, char *argv[])
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
qRegisterMetaType<amnezia::DockerContainer>("amnezia::DockerContainer"); qRegisterMetaType<DockerContainer>("DockerContainer");
qRegisterMetaType<amnezia::Protocol>("amnezia::Protocol"); qRegisterMetaType<Protocol>("Protocol");
qRegisterMetaType<Page>("Page");
qRegisterMetaType<PageProtocolLogicBase *>("PageProtocolLogicBase *"); qRegisterMetaType<PageProtocolLogicBase *>("PageProtocolLogicBase *");

View file

@ -16,6 +16,7 @@ QHash<int, QByteArray> ContainersModel::roleNames() const {
QHash<int, QByteArray> roles; QHash<int, QByteArray> roles;
roles[NameRole] = "name_role"; roles[NameRole] = "name_role";
roles[DescRole] = "desc_role"; roles[DescRole] = "desc_role";
roles[DefaultRole] = "default_role";
roles[isVpnTypeRole] = "is_vpn_role"; roles[isVpnTypeRole] = "is_vpn_role";
roles[isOtherTypeRole] = "is_other_role"; roles[isOtherTypeRole] = "is_other_role";
roles[isInstalledRole] = "is_installed_role"; roles[isInstalledRole] = "is_installed_role";
@ -36,6 +37,9 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
if (role == DescRole) { if (role == DescRole) {
return containerDescriptions().value(c); return containerDescriptions().value(c);
} }
if (role == DefaultRole) {
return c == m_settings.defaultContainer(m_selectedServerIndex);
}
if (role == isVpnTypeRole) { if (role == isVpnTypeRole) {
return isContainerVpnType(c); return isContainerVpnType(c);
} }

View file

@ -18,6 +18,7 @@ public:
enum SiteRoles { enum SiteRoles {
NameRole = Qt::UserRole + 1, NameRole = Qt::UserRole + 1,
DescRole, DescRole,
DefaultRole,
isVpnTypeRole, isVpnTypeRole,
isOtherTypeRole, isOtherTypeRole,
isInstalledRole isInstalledRole

View file

@ -55,7 +55,7 @@ void ProtocolsModel::setSelectedServerIndex(int index)
endResetModel(); endResetModel();
} }
void ProtocolsModel::setSelectedDockerContainer(amnezia::DockerContainer c) void ProtocolsModel::setSelectedDockerContainer(DockerContainer c)
{ {
beginResetModel(); beginResetModel();
m_selectedDockerContainer = c; m_selectedDockerContainer = c;

View file

@ -27,7 +27,7 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
Q_INVOKABLE void setSelectedServerIndex(int index); Q_INVOKABLE void setSelectedServerIndex(int index);
Q_INVOKABLE void setSelectedDockerContainer(amnezia::DockerContainer c); Q_INVOKABLE void setSelectedDockerContainer(DockerContainer c);
protected: protected:
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;

View file

@ -7,7 +7,7 @@
namespace PageEnumNS namespace PageEnumNS
{ {
Q_NAMESPACE Q_NAMESPACE
enum Page {Start = 0, NewServer, NewServerProtocols, Vpn, enum class Page {Start = 0, NewServer, NewServerProtocols, Vpn,
Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguring, Wizard, WizardLow, WizardMedium, WizardHigh, WizardVpnMode, ServerConfiguring,
GeneralSettings, AppSettings, NetworkSettings, ServerSettings, GeneralSettings, AppSettings, NetworkSettings, ServerSettings,
ServerContainers, ServersList, ShareConnection, Sites, ServerContainers, ServersList, ShareConnection, Sites,

View file

@ -13,10 +13,6 @@ ServerContainersLogic::ServerContainersLogic(UiLogic *logic, QObject *parent):
PageLogicBase(logic, parent), PageLogicBase(logic, parent),
m_progressBarProtocolsContainerReinstallValue{0}, m_progressBarProtocolsContainerReinstallValue{0},
m_progressBarProtocolsContainerReinstallMaximium{100}, m_progressBarProtocolsContainerReinstallMaximium{100},
m_pushButtonOpenVpnContInstallChecked{false},
m_pushButtonSsOpenVpnContInstallChecked{false},
m_pushButtonCloakOpenVpnContInstallChecked{false},
m_pushButtonWireguardContInstallChecked{false},
m_pushButtonOpenVpnContInstallEnabled{false}, m_pushButtonOpenVpnContInstallEnabled{false},
m_pushButtonSsOpenVpnContInstallEnabled{false}, m_pushButtonSsOpenVpnContInstallEnabled{false},
m_pushButtonCloakOpenVpnContInstallEnabled{false}, m_pushButtonCloakOpenVpnContInstallEnabled{false},
@ -71,12 +67,7 @@ void ServerContainersLogic::updateServerContainersPage()
using SetVisibleFunc = std::function<void(bool)>; using SetVisibleFunc = std::function<void(bool)>;
using SetCheckedFunc = std::function<void(bool)>; using SetCheckedFunc = std::function<void(bool)>;
using SetEnabledFunc = std::function<void(bool)>; using SetEnabledFunc = std::function<void(bool)>;
QList<SetCheckedFunc> installButtonsCheckedFunc {
[this](bool checked) ->void {set_pushButtonOpenVpnContInstallChecked(checked);},
[this](bool checked) ->void {set_pushButtonSsOpenVpnContInstallChecked(checked);},
[this](bool checked) ->void {set_pushButtonCloakOpenVpnContInstallChecked(checked);},
[this](bool checked) ->void {set_pushButtonWireguardContInstallChecked(checked);},
};
QList<SetEnabledFunc> installButtonsEnabledFunc { QList<SetEnabledFunc> installButtonsEnabledFunc {
[this](bool enabled) ->void {set_pushButtonOpenVpnContInstallEnabled(enabled);}, [this](bool enabled) ->void {set_pushButtonOpenVpnContInstallEnabled(enabled);},
[this](bool enabled) ->void {set_pushButtonSsOpenVpnContInstallEnabled(enabled);}, [this](bool enabled) ->void {set_pushButtonSsOpenVpnContInstallEnabled(enabled);},
@ -115,22 +106,33 @@ void ServerContainersLogic::updateServerContainersPage()
defaultButtonsCheckedFunc.at(i)(defaultContainer == allContainers.at(i)); defaultButtonsCheckedFunc.at(i)(defaultContainer == allContainers.at(i));
defaultButtonsVisibleFunc.at(i)(haveAuthData && containers.contains(allContainers.at(i))); defaultButtonsVisibleFunc.at(i)(haveAuthData && containers.contains(allContainers.at(i)));
shareButtonsVisibleFunc.at(i)(haveAuthData && containers.contains(allContainers.at(i))); shareButtonsVisibleFunc.at(i)(haveAuthData && containers.contains(allContainers.at(i)));
installButtonsCheckedFunc.at(i)(containers.contains(allContainers.at(i)));
installButtonsEnabledFunc.at(i)(haveAuthData); installButtonsEnabledFunc.at(i)(haveAuthData);
framesVisibleFunc.at(i)(containers.contains(allContainers.at(i))); framesVisibleFunc.at(i)(containers.contains(allContainers.at(i)));
} }
} }
void ServerContainersLogic::onPushButtonProtoSettingsClicked(amnezia::DockerContainer c, amnezia::Protocol p) void ServerContainersLogic::onPushButtonProtoSettingsClicked(DockerContainer c, Protocol p)
{ {
qDebug()<< "ServerContainersLogic::onPushButtonProtoSettingsClicked" << c << p;
uiLogic()->selectedDockerContainer = c; uiLogic()->selectedDockerContainer = c;
uiLogic()->protocolLogic(p)->updateProtocolPage(m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p), uiLogic()->protocolLogic(p)->updateProtocolPage(m_settings.protocolConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, p),
uiLogic()->selectedDockerContainer, uiLogic()->selectedDockerContainer,
m_settings.haveAuthData(uiLogic()->selectedServerIndex)); m_settings.haveAuthData(uiLogic()->selectedServerIndex));
emit uiLogic()->goToProtocolPage(static_cast<int>(p)); emit uiLogic()->goToProtocolPage(p);
} }
void ServerContainersLogic::onPushButtonDefaultClicked(DockerContainer c)
{
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, c);
updateServerContainersPage();
}
void ServerContainersLogic::onPushButtonShareClicked(DockerContainer c)
{
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), c);
emit uiLogic()->goToPage(Page::ShareConnection);
}
void ServerContainersLogic::setupProtocolsPageConnections() void ServerContainersLogic::setupProtocolsPageConnections()
{ {
@ -146,21 +148,6 @@ void ServerContainersLogic::setupProtocolsPageConnections()
using ButtonClickedFunc = void (ServerContainersLogic::*)(bool); using ButtonClickedFunc = void (ServerContainersLogic::*)(bool);
using ButtonSetEnabledFunc = std::function<void(bool)>; using ButtonSetEnabledFunc = std::function<void(bool)>;
// default buttons
QList<ButtonClickedFunc> defaultButtonClickedSig {
&ServerContainersLogic::pushButtonOpenVpnContDefaultClicked,
&ServerContainersLogic::pushButtonSsOpenVpnContDefaultClicked,
&ServerContainersLogic::pushButtonCloakOpenVpnContDefaultClicked,
&ServerContainersLogic::pushButtonWireguardContDefaultClicked
};
for (int i = 0; i < containers.size(); ++i) {
connect(this, defaultButtonClickedSig.at(i), [this, containers, i](bool){
qDebug() << "clmm" << i;
m_settings.setDefaultContainer(uiLogic()->selectedServerIndex, containers.at(i));
updateServerContainersPage();
});
}
// install buttons // install buttons
QList<ButtonClickedFunc> installButtonsClickedSig { QList<ButtonClickedFunc> installButtonsClickedSig {
@ -253,7 +240,7 @@ void ServerContainersLogic::setupProtocolsPageConnections()
connect(this, buttonClickedFunc, [this, container](bool){ connect(this, buttonClickedFunc, [this, container](bool){
uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), container); uiLogic()->shareConnectionLogic()->updateSharingPage(uiLogic()->selectedServerIndex, m_settings.serverCredentials(uiLogic()->selectedServerIndex), container);
uiLogic()->goToPage(Page::ShareConnection); emit uiLogic()->goToPage(Page::ShareConnection);
}); });
} }
} }

View file

@ -12,26 +12,31 @@ class ServerContainersLogic : public PageLogicBase
AUTO_PROPERTY(int, progressBarProtocolsContainerReinstallValue) AUTO_PROPERTY(int, progressBarProtocolsContainerReinstallValue)
AUTO_PROPERTY(int, progressBarProtocolsContainerReinstallMaximium) AUTO_PROPERTY(int, progressBarProtocolsContainerReinstallMaximium)
AUTO_PROPERTY(bool, pushButtonOpenVpnContInstallChecked) // AUTO_PROPERTY(bool, pushButtonOpenVpnContInstallChecked)
AUTO_PROPERTY(bool, pushButtonSsOpenVpnContInstallChecked) // AUTO_PROPERTY(bool, pushButtonSsOpenVpnContInstallChecked)
AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContInstallChecked) // AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContInstallChecked)
AUTO_PROPERTY(bool, pushButtonWireguardContInstallChecked) // AUTO_PROPERTY(bool, pushButtonWireguardContInstallChecked)
AUTO_PROPERTY(bool, pushButtonOpenVpnContInstallEnabled) AUTO_PROPERTY(bool, pushButtonOpenVpnContInstallEnabled)
AUTO_PROPERTY(bool, pushButtonSsOpenVpnContInstallEnabled) AUTO_PROPERTY(bool, pushButtonSsOpenVpnContInstallEnabled)
AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContInstallEnabled) AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContInstallEnabled)
AUTO_PROPERTY(bool, pushButtonWireguardContInstallEnabled) AUTO_PROPERTY(bool, pushButtonWireguardContInstallEnabled)
AUTO_PROPERTY(bool, pushButtonOpenVpnContDefaultChecked) AUTO_PROPERTY(bool, pushButtonOpenVpnContDefaultChecked)
AUTO_PROPERTY(bool, pushButtonSsOpenVpnContDefaultChecked) AUTO_PROPERTY(bool, pushButtonSsOpenVpnContDefaultChecked)
AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContDefaultChecked) AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContDefaultChecked)
AUTO_PROPERTY(bool, pushButtonWireguardContDefaultChecked) AUTO_PROPERTY(bool, pushButtonWireguardContDefaultChecked)
AUTO_PROPERTY(bool, pushButtonOpenVpnContDefaultVisible) AUTO_PROPERTY(bool, pushButtonOpenVpnContDefaultVisible)
AUTO_PROPERTY(bool, pushButtonSsOpenVpnContDefaultVisible) AUTO_PROPERTY(bool, pushButtonSsOpenVpnContDefaultVisible)
AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContDefaultVisible) AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContDefaultVisible)
AUTO_PROPERTY(bool, pushButtonWireguardContDefaultVisible) AUTO_PROPERTY(bool, pushButtonWireguardContDefaultVisible)
AUTO_PROPERTY(bool, pushButtonOpenVpnContShareVisible) AUTO_PROPERTY(bool, pushButtonOpenVpnContShareVisible)
AUTO_PROPERTY(bool, pushButtonSsOpenVpnContShareVisible) AUTO_PROPERTY(bool, pushButtonSsOpenVpnContShareVisible)
AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContShareVisible) AUTO_PROPERTY(bool, pushButtonCloakOpenVpnContShareVisible)
AUTO_PROPERTY(bool, pushButtonWireguardContShareVisible) AUTO_PROPERTY(bool, pushButtonWireguardContShareVisible)
AUTO_PROPERTY(bool, frameOpenvpnSettingsVisible) AUTO_PROPERTY(bool, frameOpenvpnSettingsVisible)
AUTO_PROPERTY(bool, frameOpenvpnSsSettingsVisible) AUTO_PROPERTY(bool, frameOpenvpnSsSettingsVisible)
AUTO_PROPERTY(bool, frameOpenvpnSsCloakSettingsVisible) AUTO_PROPERTY(bool, frameOpenvpnSsCloakSettingsVisible)
@ -42,7 +47,9 @@ class ServerContainersLogic : public PageLogicBase
public: public:
Q_INVOKABLE void updateServerContainersPage(); Q_INVOKABLE void updateServerContainersPage();
Q_INVOKABLE void onPushButtonProtoSettingsClicked(amnezia::DockerContainer c, amnezia::Protocol p); Q_INVOKABLE void onPushButtonProtoSettingsClicked(DockerContainer c, Protocol p);
Q_INVOKABLE void onPushButtonDefaultClicked(DockerContainer c);
Q_INVOKABLE void onPushButtonShareClicked(DockerContainer c);
public: public:
explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr); explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr);

View file

@ -156,7 +156,7 @@ void StartPageLogic::onPushButtonImport()
m_settings.addServer(o); m_settings.addServer(o);
m_settings.setDefaultServer(m_settings.serversCount() - 1); m_settings.setDefaultServer(m_settings.serversCount() - 1);
uiLogic()->setStartPage(Page::Vpn); emit uiLogic()->setStartPage(Page::Vpn);
} }
else { else {
qDebug() << "Failed to import profile"; qDebug() << "Failed to import profile";

View file

@ -11,7 +11,6 @@ CloakLogic::CloakLogic(UiLogic *logic, QObject *parent):
m_comboBoxProtoCloakCipherText{"chacha20-poly1305"}, m_comboBoxProtoCloakCipherText{"chacha20-poly1305"},
m_lineEditProtoCloakSiteText{"tile.openstreetmap.org"}, m_lineEditProtoCloakSiteText{"tile.openstreetmap.org"},
m_lineEditProtoCloakPortText{}, m_lineEditProtoCloakPortText{},
m_widgetProtoCloakEnabled{false},
m_pushButtonCloakSaveVisible{false}, m_pushButtonCloakSaveVisible{false},
m_progressBarProtoCloakResetVisible{false}, m_progressBarProtoCloakResetVisible{false},
m_lineEditProtoCloakPortEnabled{false}, m_lineEditProtoCloakPortEnabled{false},
@ -26,7 +25,7 @@ CloakLogic::CloakLogic(UiLogic *logic, QObject *parent):
void CloakLogic::updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) void CloakLogic::updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData)
{ {
set_widgetProtoCloakEnabled(haveAuthData); set_pageEnabled(haveAuthData);
set_pushButtonCloakSaveVisible(haveAuthData); set_pushButtonCloakSaveVisible(haveAuthData);
set_progressBarProtoCloakResetVisible(haveAuthData); set_progressBarProtoCloakResetVisible(haveAuthData);

View file

@ -12,7 +12,6 @@ class CloakLogic : public PageProtocolLogicBase
AUTO_PROPERTY(QString, comboBoxProtoCloakCipherText) AUTO_PROPERTY(QString, comboBoxProtoCloakCipherText)
AUTO_PROPERTY(QString, lineEditProtoCloakSiteText) AUTO_PROPERTY(QString, lineEditProtoCloakSiteText)
AUTO_PROPERTY(QString, lineEditProtoCloakPortText) AUTO_PROPERTY(QString, lineEditProtoCloakPortText)
AUTO_PROPERTY(bool, widgetProtoCloakEnabled)
AUTO_PROPERTY(bool, pushButtonCloakSaveVisible) AUTO_PROPERTY(bool, pushButtonCloakSaveVisible)
AUTO_PROPERTY(bool, progressBarProtoCloakResetVisible) AUTO_PROPERTY(bool, progressBarProtoCloakResetVisible)
AUTO_PROPERTY(bool, lineEditProtoCloakPortEnabled) AUTO_PROPERTY(bool, lineEditProtoCloakPortEnabled)

View file

@ -21,7 +21,6 @@ OpenVpnLogic::OpenVpnLogic(UiLogic *logic, QObject *parent):
m_checkBoxProtoOpenVpnBlockDnsChecked{false}, m_checkBoxProtoOpenVpnBlockDnsChecked{false},
m_lineEditProtoOpenVpnPortText{}, m_lineEditProtoOpenVpnPortText{},
m_checkBoxProtoOpenVpnTlsAuthChecked{false}, m_checkBoxProtoOpenVpnTlsAuthChecked{false},
m_widgetProtoOpenVpnEnabled{true},
m_pushButtonOpenvpnSaveVisible{false}, m_pushButtonOpenvpnSaveVisible{false},
m_progressBarProtoOpenVpnResetVisible{false}, m_progressBarProtoOpenVpnResetVisible{false},
@ -39,7 +38,7 @@ OpenVpnLogic::OpenVpnLogic(UiLogic *logic, QObject *parent):
void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData) void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerContainer container, bool haveAuthData)
{ {
qDebug() << "OpenVpnLogic::updateProtocolPage"; qDebug() << "OpenVpnLogic::updateProtocolPage";
set_widgetProtoOpenVpnEnabled(haveAuthData); set_pageEnabled(haveAuthData);
set_pushButtonOpenvpnSaveVisible(haveAuthData); set_pushButtonOpenvpnSaveVisible(haveAuthData);
set_progressBarProtoOpenVpnResetVisible(haveAuthData); set_progressBarProtoOpenVpnResetVisible(haveAuthData);

View file

@ -23,7 +23,6 @@ class OpenVpnLogic : public PageProtocolLogicBase
AUTO_PROPERTY(QString, lineEditProtoOpenVpnPortText) AUTO_PROPERTY(QString, lineEditProtoOpenVpnPortText)
AUTO_PROPERTY(bool, checkBoxProtoOpenVpnTlsAuthChecked) AUTO_PROPERTY(bool, checkBoxProtoOpenVpnTlsAuthChecked)
AUTO_PROPERTY(bool, widgetProtoOpenVpnEnabled)
AUTO_PROPERTY(bool, pushButtonOpenvpnSaveVisible) AUTO_PROPERTY(bool, pushButtonOpenvpnSaveVisible)
AUTO_PROPERTY(bool, progressBarProtoOpenVpnResetVisible) AUTO_PROPERTY(bool, progressBarProtoOpenVpnResetVisible)

View file

@ -8,7 +8,6 @@ using namespace PageEnumNS;
ShadowSocksLogic::ShadowSocksLogic(UiLogic *logic, QObject *parent): ShadowSocksLogic::ShadowSocksLogic(UiLogic *logic, QObject *parent):
PageProtocolLogicBase(logic, parent), PageProtocolLogicBase(logic, parent),
m_widgetProtoShadowSocksEnabled{false},
m_comboBoxProtoShadowSocksCipherText{"chacha20-poly1305"}, m_comboBoxProtoShadowSocksCipherText{"chacha20-poly1305"},
m_lineEditProtoShadowSocksPortText{}, m_lineEditProtoShadowSocksPortText{},
m_pushButtonShadowSocksSaveVisible{false}, m_pushButtonShadowSocksSaveVisible{false},
@ -25,7 +24,7 @@ ShadowSocksLogic::ShadowSocksLogic(UiLogic *logic, QObject *parent):
void ShadowSocksLogic::updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData) void ShadowSocksLogic::updateProtocolPage(const QJsonObject &ssConfig, DockerContainer container, bool haveAuthData)
{ {
set_widgetProtoShadowSocksEnabled(haveAuthData); set_pageEnabled(haveAuthData);
set_pushButtonShadowSocksSaveVisible(haveAuthData); set_pushButtonShadowSocksSaveVisible(haveAuthData);
set_progressBarProtoShadowSocksResetVisible(haveAuthData); set_progressBarProtoShadowSocksResetVisible(haveAuthData);

View file

@ -9,7 +9,6 @@ class ShadowSocksLogic : public PageProtocolLogicBase
{ {
Q_OBJECT Q_OBJECT
AUTO_PROPERTY(bool, widgetProtoShadowSocksEnabled)
AUTO_PROPERTY(QString, comboBoxProtoShadowSocksCipherText) AUTO_PROPERTY(QString, comboBoxProtoShadowSocksCipherText)
AUTO_PROPERTY(QString, lineEditProtoShadowSocksPortText) AUTO_PROPERTY(QString, lineEditProtoShadowSocksPortText)
AUTO_PROPERTY(bool, pushButtonShadowSocksSaveVisible) AUTO_PROPERTY(bool, pushButtonShadowSocksSaveVisible)

View file

@ -4,6 +4,7 @@ import QtQuick.Controls 2.12
BasicButtonType { BasicButtonType {
id: root id: root
property alias iconMargin: img.anchors.margins property alias iconMargin: img.anchors.margins
property alias img: img
background: Item {} background: Item {}
contentItem: Image { contentItem: Image {
id: img id: img

View file

@ -7,9 +7,8 @@ import "../Config"
Item { Item {
id: root id: root
property int page: PageEnum.Start property var page: PageEnum.Start
property var logic: UiLogic property var logic: UiLogic
enabled: logic.pageEnabled
// width: GC.screenWidth // width: GC.screenWidth
// height: GC.screenHeight // height: GC.screenHeight

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 SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
import PageEnum 1.0 import PageEnum 1.0
import "./" import "./"
@ -82,7 +83,7 @@ PageBase {
ListView { ListView {
id: tb_c id: tb_c
x: 10 x: 10
width: parent.width - 40 width: parent.width - 10
height: tb_c.contentItem.height height: tb_c.contentItem.height
currentIndex: -1 currentIndex: -1
spacing: 5 spacing: 5
@ -96,7 +97,7 @@ PageBase {
Item { Item {
id: c_item id: c_item
width: parent.width width: parent.width
height: lb_container_name.height + tb_p.height height: row_container.height + tb_p.height
anchors.left: parent.left anchors.left: parent.left
Rectangle { Rectangle {
anchors.top: parent.top anchors.top: parent.top
@ -106,47 +107,108 @@ PageBase {
visible: index !== tb_c.currentIndex visible: index !== tb_c.currentIndex
} }
Rectangle { Rectangle {
anchors.top: lb_container_name.top anchors.top: row_container.top
anchors.bottom: lb_container_name.bottom anchors.bottom: row_container.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
color: "#63B4FB" color: "#63B4FB"
visible: index === tb_c.currentIndex visible: index === tb_c.currentIndex
} }
Text {
id: lb_container_name
text: name_role
font.pixelSize: 17
//font.bold: true
color: "#100A44"
topPadding: 5
bottomPadding: 5
leftPadding: 10
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
}
MouseArea { // ImageButtonType {
anchors.top: lb_container_name.top // id: button_default1
anchors.bottom: lb_container_name.bottom // z:10
// Layout.alignment: Qt.AlignRight
// checkable: true
// img.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png"
// width: 20
// img.width: 20
// height: 20
// checked: default_role
// onClicked: {
// ServerContainersLogic.onPushButtonDefaultClicked(proxyContainersModel.mapToSource(index))
// }
// }
RowLayout {
id: row_container
//width: parent.width
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
propagateComposedEvents: true
onClicked: { // anchors.top: lb_container_name.top
tb_c.currentIndex = index // anchors.bottom: lb_container_name.bottom
UiLogic.protocolsModel.setSelectedDockerContainer(proxyContainersModel.mapToSource(index))
//container_selector.containerSelected(index) Text {
//root.close() id: lb_container_name
text: name_role
font.pixelSize: 17
//font.bold: true
color: "#100A44"
topPadding: 5
bottomPadding: 5
leftPadding: 10
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
Layout.fillWidth: true
MouseArea {
anchors.top: lb_container_name.top
anchors.bottom: lb_container_name.bottom
anchors.left: parent.left
anchors.right: parent.right
propagateComposedEvents: true
onClicked: {
if (tb_c.currentIndex === index) tb_c.currentIndex = -1
else tb_c.currentIndex = index
UiLogic.protocolsModel.setSelectedDockerContainer(proxyContainersModel.mapToSource(index))
//ServerContainersLogic.setSelectedDockerContainer(proxyContainersModel.mapToSource(index))
//container_selector.containerSelected(index)
//root.close()
}
}
} }
ImageButtonType {
id: button_default
Layout.alignment: Qt.AlignRight
checkable: true
img.source: checked ? "qrc:/images/check.png" : "qrc:/images/uncheck.png"
implicitWidth: 30
implicitHeight: 30
checked: default_role
onClicked: {
ServerContainersLogic.onPushButtonDefaultClicked(proxyContainersModel.mapToSource(index))
}
}
ImageButtonType {
id: button_share
Layout.alignment: Qt.AlignRight
icon.source: "qrc:/images/share.png"
implicitWidth: 30
implicitHeight: 30
onClicked: {
ServerContainersLogic.onPushButtonShareClicked(proxyContainersModel.mapToSource(index))
}
}
} }
ListView { ListView {
id: tb_p id: tb_p
currentIndex: -1 currentIndex: -1
visible: index === tb_c.currentIndex visible: index === tb_c.currentIndex
x: 10 x: 10
anchors.top: lb_container_name.bottom anchors.top: row_container.bottom
width: parent.width - 40 width: parent.width - 40
height: visible ? tb_p.contentItem.height : 0 height: visible ? tb_p.contentItem.height : 0

View file

@ -19,7 +19,7 @@ PageProtocolBase {
y: 40 y: 40
width: 380 width: 380
height: 600 height: 600
enabled: logic.widgetProtoCloakEnabled enabled: logic.pageEnabled
ComboBoxType { ComboBoxType {
x: 190 x: 190
y: 60 y: 60

View file

@ -18,7 +18,7 @@ PageProtocolBase {
y: 40 y: 40
width: 380 width: 380
height: 600 height: 600
enabled: logic.widgetProtoOpenVpnEnabled enabled: logic.pageEnabled
CheckBoxType { CheckBoxType {
x: 30 x: 30
y: 280 y: 280

View file

@ -19,28 +19,32 @@ PageProtocolBase {
y: 40 y: 40
width: 380 width: 380
height: 600 height: 600
enabled: logic.widgetProtoShadowSocksEnabled enabled: logic.pageEnabled
ComboBoxType { ComboBoxType {
x: 190 x: 190
y: 60 y: 60
width: 151 width: 151
height: 31 height: 31
model: [ model: [
qsTr("chacha20-poly1305"), qsTr("chacha20-ietf-poly1305"),
qsTr("xchacha20-ietf-poly1305"),
qsTr("aes-256-gcm"), qsTr("aes-256-gcm"),
qsTr("aes-192-gcm"),
qsTr("aes-128-gcm") qsTr("aes-128-gcm")
] ]
currentIndex: { currentIndex: {
console.debug("logic.comboBoxProtoShadowSocksCipherText " + logic.comboBoxProtoShadowSocksCipherText)
for (let i = 0; i < model.length; ++i) { for (let i = 0; i < model.length; ++i) {
console.debug("check " + model[i])
if (logic.comboBoxProtoShadowSocksCipherText === model[i]) { if (logic.comboBoxProtoShadowSocksCipherText === model[i]) {
return i return i
} }
} }
return -1 return -1
} }
onCurrentTextChanged: { // onCurrentTextChanged: {
logic.comboBoxProtoShadowSocksCipherText = currentText // logic.comboBoxProtoShadowSocksCipherText = currentText
} // }
} }
LabelType { LabelType {
x: 30 x: 30

View file

@ -8,6 +8,6 @@ import "../../Config"
PageBase { PageBase {
id: root id: root
property int protocol: ProtocolEnum.Any property var protocol: ProtocolEnum.Any
page: PageEnum.ProtocolSettings page: PageEnum.ProtocolSettings
} }

View file

@ -73,6 +73,7 @@ Window {
VpnLogic.updateVpnPage() VpnLogic.updateVpnPage()
} }
} }
if (slide) { if (slide) {
pageLoader.push(pages[page], {}, StackView.PushTransition) pageLoader.push(pages[page], {}, StackView.PushTransition)
} else { } else {
@ -84,6 +85,7 @@ Window {
if (reset) { if (reset) {
protocolPages[protocol].logic.updatePage(); protocolPages[protocol].logic.updatePage();
} }
if (slide) { if (slide) {
pageLoader.push(protocolPages[protocol], {}, StackView.PushTransition) pageLoader.push(protocolPages[protocol], {}, StackView.PushTransition)
} else { } else {
@ -199,13 +201,9 @@ Window {
} }
} }
Component {
PageProtoOpenVPN {
}
}
function createPagesObjects(file, isProtocol) { function createPagesObjects(file, isProtocol) {
if (file.indexOf("Base") !== -1) return; // skip Base Pages
var c = Qt.createComponent("qrc" + file); var c = Qt.createComponent("qrc" + file);
var finishCreation = function (component){ var finishCreation = function (component){
@ -218,10 +216,13 @@ Window {
obj.visible = false obj.visible = false
if (isProtocol) { if (isProtocol) {
protocolPages[obj.protocol] = obj protocolPages[obj.protocol] = obj
console.debug("QML add proto page " + obj.protocol) console.debug("PPP " + obj.protocol + " " + file)
} }
else { else {
pages[obj.page] = obj pages[obj.page] = obj
console.debug("AAA " + obj.page + " " + file)
} }
@ -242,9 +243,11 @@ Window {
Connections { Connections {
target: UiLogic target: UiLogic
onGoToPage: { onGoToPage: {
console.debug("Connections onGoToPage " + page);
root.gotoPage(page, reset, slide) root.gotoPage(page, reset, slide)
} }
onGoToProtocolPage: { onGoToProtocolPage: {
console.debug("Connections onGoToProtocolPage " + protocol);
root.gotoProtocolPage(protocol, reset, slide) root.gotoProtocolPage(protocol, reset, slide)
} }
onClosePage: { onClosePage: {

View file

@ -120,10 +120,14 @@ void UiLogic::initalizeUiLogic()
// } // }
// Post initialization // Post initialization
goToPage(Page::Start, true, false); //emit goToPage(Page::Start, true, false);
if (m_settings.defaultServerIndex() >= 0 && m_settings.serversCount() > 0) { if (m_settings.serversCount() > 0) {
goToPage(Page::Vpn, true, false); if (m_settings.defaultServerIndex() < 0) m_settings.setDefaultServer(0);
emit goToPage(Page::Vpn, true, false);
}
else {
emit goToPage(Page::Start, true, false);
} }
selectedServerIndex = m_settings.defaultServerIndex(); selectedServerIndex = m_settings.defaultServerIndex();
@ -131,7 +135,7 @@ void UiLogic::initalizeUiLogic()
//goToPage(Page::NewServerProtocols, true, false); //goToPage(Page::NewServerProtocols, true, false);
// //ui->pushButton_general_settings_exit->hide(); //ui->pushButton_general_settings_exit->hide();
qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION); qInfo().noquote() << QString("Started %1 version %2").arg(APPLICATION_NAME).arg(APP_VERSION);

View file

@ -105,10 +105,10 @@ signals:
void dialogConnectErrorTextChanged(); void dialogConnectErrorTextChanged();
void goToPage(int page, bool reset = true, bool slide = true); void goToPage(PageEnumNS::Page page, bool reset = true, bool slide = true);
void goToProtocolPage(int protocol, bool reset = true, bool slide = true); void goToProtocolPage(Protocol protocol, bool reset = true, bool slide = true);
void closePage(); void closePage();
void setStartPage(int page, bool slide = true); void setStartPage(PageEnumNS::Page page, bool slide = true);
void showPublicKeyWarning(); void showPublicKeyWarning();
void showConnectErrorDialog(); void showConnectErrorDialog();
void show(); void show();
@ -179,7 +179,7 @@ public:
VpnLogic *vpnLogic() { return m_vpnLogic; } VpnLogic *vpnLogic() { return m_vpnLogic; }
WizardLogic *wizardLogic() { return m_wizardLogic; } WizardLogic *wizardLogic() { return m_wizardLogic; }
Q_INVOKABLE PageProtocolLogicBase *protocolLogic(amnezia::Protocol p) { return m_protocolLogicMap.value(p); } Q_INVOKABLE PageProtocolLogicBase *protocolLogic(Protocol p) { return m_protocolLogicMap.value(p); }
private: private:
AppSettingsLogic *m_appSettingsLogic; AppSettingsLogic *m_appSettingsLogic;