Merge branch 'dev' into feature/ovpn-config-import

This commit is contained in:
pokamest 2022-12-12 14:01:57 +01:00
commit ce02d3a829
27 changed files with 218 additions and 340 deletions

View file

@ -83,8 +83,8 @@ void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
{
QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open backup"),
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open backup"),
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
if (fileName.isEmpty()) return;

View file

@ -15,6 +15,7 @@ void ServerListLogic::onServerListPushbuttonDefaultClicked(int index)
{
m_settings->setDefaultServer(index);
uiLogic()->onUpdateAllPages();
emit currServerIdxChanged();
}
void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
@ -23,6 +24,11 @@ void ServerListLogic::onServerListPushbuttonSettingsClicked(int index)
uiLogic()->goToPage(Page::ServerSettings);
}
int ServerListLogic::currServerIdx() const
{
return m_settings->defaultServerIndex();
}
void ServerListLogic::onUpdatePage()
{
const QJsonArray &servers = m_settings->serversArray();

View file

@ -10,8 +10,11 @@ class ServerListLogic : public PageLogicBase
Q_OBJECT
READONLY_PROPERTY(QObject *, serverListModel)
Q_PROPERTY(int currServerIdx READ currServerIdx NOTIFY currServerIdxChanged)
public:
int currServerIdx() const;
Q_INVOKABLE void onUpdatePage() override;
Q_INVOKABLE void onServerListPushbuttonDefaultClicked(int index);
Q_INVOKABLE void onServerListPushbuttonSettingsClicked(int index);
@ -20,5 +23,8 @@ public:
explicit ServerListLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~ServerListLogic() = default;
signals:
void currServerIdxChanged();
};
#endif // SERVER_LIST_LOGIC_H

View file

@ -165,9 +165,8 @@ void StartPageLogic::onPushButtonImport()
void StartPageLogic::onPushButtonImportOpenFile()
{
QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open profile"),
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open config file"),
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn *.ovpn *.conf");
if (fileName.isEmpty()) return;
QFile file(fileName);
@ -203,14 +202,6 @@ bool StartPageLogic::importConnection(const QJsonObject &profile)
return false;
}
if (!profile.contains(config_key::containers)) {
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
uiLogic()->onUpdateAllPages();
emit uiLogic()->goToPage(Page::ServerContainers);
}
return true;
}

View file

@ -61,7 +61,17 @@ void ViewConfigLogic::importConfig()
m_settings->addServer(configJson());
m_settings->setDefaultServer(m_settings->serversCount() - 1);
emit uiLogic()->goToPage(Page::Vpn);
emit uiLogic()->setStartPage(Page::Vpn);
if (!configJson().contains(config_key::containers) || configJson().value(config_key::containers).toArray().isEmpty()) {
uiLogic()->selectedServerIndex = m_settings->defaultServerIndex();
uiLogic()->selectedDockerContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);
uiLogic()->onUpdateAllPages();
emit uiLogic()->goToPage(Page::Vpn);
emit uiLogic()->setStartPage(Page::Vpn);
emit uiLogic()->goToPage(Page::ServerContainers);
} else {
emit uiLogic()->goToPage(Page::Vpn);
emit uiLogic()->setStartPage(Page::Vpn);
}
}

View file

@ -26,7 +26,7 @@ PageBase {
}
Connections {
target: Qt.platform.os != "ios" ? QrDecoderLogic : nil
target: Qt.platform.os != "ios" ? QrDecoderLogic : null
function onStartDecode() {
console.debug("Starting QR decoder")
loader.sourceComponent = component
@ -71,7 +71,7 @@ PageBase {
anchors.right: parent.right
autoOrientation: true
fillMode: VideoOutput.PreserveAspectFit
filters: [ zxingFilter ]
// filters: [ zxingFilter ]
Rectangle {

View file

@ -25,7 +25,7 @@ PageBase {
}
Connections {
target: Qt.platform.os == "ios" ? QrDecoderLogic : nil
target: Qt.platform.os == "ios" ? QrDecoderLogic : null
function onStartDecode() {
console.debug("Starting QR decoder")
loader.sourceComponent = component
@ -40,11 +40,29 @@ PageBase {
id: loader
anchors.top: caption.bottom
anchors.bottom: parent.bottom
anchors.bottom: progressColumn.top
anchors.left: parent.left
anchors.right: parent.right
}
Column{
height: 40
id: progressColumn
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
ProgressBar {
id: progress
anchors.left: parent.left
anchors.right: parent.right
value: QrDecoderLogic.totalChunksCount === 0? 0 : (QrDecoderLogic.receivedChunksCount/QrDecoderLogic.totalChunksCount)
}
Text {
id: chunksCount
text: "Progress: " + QrDecoderLogic.receivedChunksCount +"/"+QrDecoderLogic.totalChunksCount
}
}
Component {
id: component

View file

@ -42,6 +42,9 @@ PageBase {
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
model: ServerListLogic.serverListModel
highlightRangeMode: ListView.ApplyRange
highlightMoveVelocity: -1
currentIndex: ServerListLogic.currServerIdx
spacing: 5
clip: true
delegate: Item {
@ -55,10 +58,6 @@ PageBase {
if (GC.isMobile()) {
ServerListLogic.onServerListPushbuttonSettingsClicked(index)
}
else {
listWidget_servers.currentIndex = index
}
mouse.accepted = false
}
onEntered: {

View file

@ -27,7 +27,6 @@ PageProtocolBase {
anchors.top: caption.bottom
anchors.left: root.left
anchors.right: root.right
anchors.bottom: pb_save.top
anchors.margins: 20
anchors.topMargin: 10

View file

@ -266,8 +266,6 @@ void UiLogic::onGotoCurrentProtocolsPage()
emit goToPage(Page::ServerContainers);
}
//void UiLogic::showEvent(QShowEvent *event)
//{
//#if defined Q_OS_MACX