Merge branch 'qt_migration' into qmake-to-cmake-migration
This commit is contained in:
commit
9c188e0acd
41 changed files with 778 additions and 833 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -135,9 +135,8 @@ void StartPageLogic::onPushButtonImport()
|
|||
|
||||
void StartPageLogic::onPushButtonImportOpenFile()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open profile"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn");
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open profile"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), tr("*.vpn"));
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
QFile file(fileName);
|
||||
|
|
@ -166,14 +165,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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ New encryption keys pair will be generated.")
|
|||
Layout.bottomMargin: 10
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 40
|
||||
text: qsTr("Save to file")
|
||||
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ PageShareProtocolBase {
|
|||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 40
|
||||
|
||||
text: qsTr("Save to file")
|
||||
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ PageShareProtocolBase {
|
|||
Layout.preferredHeight: 40
|
||||
width: parent.width - 60
|
||||
|
||||
text: qsTr("Save to file")
|
||||
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ PageShareProtocolBase {
|
|||
Layout.preferredHeight: 40
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTr("Save to file")
|
||||
text: Qt.platform.os === "android" ? qsTr("Share") : qsTr("Save to file")
|
||||
enabled: tfShareCode.textArea.length > 0
|
||||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ void UiLogic::initalizeUiLogic()
|
|||
pageLogic<VpnLogic>()->onConnectionStateChanged(VpnProtocol::Connected);
|
||||
}
|
||||
});
|
||||
if (!AndroidController::instance()->initialize()) {
|
||||
if (!AndroidController::instance()->initialize(pageLogic<StartPageLogic>())) {
|
||||
qCritical() << QString("Init failed") ;
|
||||
emit VpnProtocol::Error;
|
||||
return;
|
||||
|
|
@ -267,8 +267,6 @@ void UiLogic::onGotoCurrentProtocolsPage()
|
|||
emit goToPage(Page::ServerContainers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//void UiLogic::showEvent(QShowEvent *event)
|
||||
//{
|
||||
//#if defined Q_OS_MACX
|
||||
|
|
@ -596,8 +594,9 @@ void UiLogic::saveTextFile(const QString& desc, const QString& suggestedName, QS
|
|||
if (fileName.isEmpty()) return;
|
||||
if (!fileName.toString().endsWith(ext)) fileName = QUrl(fileName.toString() + ext);
|
||||
#elif defined Q_OS_ANDROID
|
||||
fileName = QFileDialog::getSaveFileUrl(nullptr, suggestedName,
|
||||
QUrl::fromLocalFile(docDir), "*" + ext);
|
||||
qDebug() << "UiLogic::shareConfig" << data;
|
||||
AndroidController::instance()->shareConfig(data, suggestedName);
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue