removed the use of QFileDialog
This commit is contained in:
parent
8f6aa950cd
commit
e8862a3811
22 changed files with 224 additions and 164 deletions
|
@ -10,31 +10,34 @@ set_property(GLOBAL PROPERTY AUTOMOC_TARGETS_FOLDER "Autogen")
|
||||||
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "Autogen")
|
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "Autogen")
|
||||||
|
|
||||||
set(PACKAGES
|
set(PACKAGES
|
||||||
Widgets Core Gui Network Xml
|
Core Gui Network Xml
|
||||||
RemoteObjects Quick Svg QuickControls2
|
RemoteObjects Quick Svg QuickControls2
|
||||||
Core5Compat Concurrent LinguistTools
|
Core5Compat Concurrent LinguistTools
|
||||||
)
|
)
|
||||||
|
|
||||||
if(IOS)
|
if(IOS)
|
||||||
set(PACKAGES
|
set(PACKAGES ${PACKAGES} Multimedia)
|
||||||
${PACKAGES}
|
endif()
|
||||||
Multimedia
|
|
||||||
)
|
if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID))
|
||||||
|
set(PACKAGES ${PACKAGES} Widgets)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS ${PACKAGES})
|
find_package(Qt6 REQUIRED COMPONENTS ${PACKAGES})
|
||||||
|
|
||||||
set(LIBS ${LIBS}
|
set(LIBS ${LIBS}
|
||||||
Qt6::Widgets Qt6::Core Qt6::Gui
|
Qt6::Core Qt6::Gui
|
||||||
Qt6::Network Qt6::Xml Qt6::RemoteObjects
|
Qt6::Network Qt6::Xml Qt6::RemoteObjects
|
||||||
Qt6::Quick Qt6::Svg Qt6::QuickControls2
|
Qt6::Quick Qt6::Svg Qt6::QuickControls2
|
||||||
Qt6::Core5Compat Qt6::Concurrent
|
Qt6::Core5Compat Qt6::Concurrent
|
||||||
)
|
)
|
||||||
|
|
||||||
if(IOS)
|
if(IOS)
|
||||||
set(LIBS
|
set(LIBS ${LIBS} Qt6::Multimedia)
|
||||||
${LIBS}
|
endif()
|
||||||
Qt6::Multimedia
|
|
||||||
)
|
if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID))
|
||||||
|
set(LIBS ${LIBS} Qt6::Widgets)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
#ifndef AMNEZIA_APPLICATION_H
|
#ifndef AMNEZIA_APPLICATION_H
|
||||||
#define AMNEZIA_APPLICATION_H
|
#define AMNEZIA_APPLICATION_H
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QGuiApplication>
|
|
||||||
|
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#else
|
||||||
|
#include <QApplication>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "vpnconnection.h"
|
#include "vpnconnection.h"
|
||||||
|
@ -39,7 +41,7 @@
|
||||||
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
|
#define amnApp (static_cast<AmneziaApplication *>(QCoreApplication::instance()))
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||||
#define AMNEZIA_BASE_CLASS QApplication
|
#define AMNEZIA_BASE_CLASS QGuiApp
|
||||||
#else
|
#else
|
||||||
#define AMNEZIA_BASE_CLASS SingleApplication
|
#define AMNEZIA_BASE_CLASS SingleApplication
|
||||||
#define QAPPLICATION_CLASS QApplication
|
#define QAPPLICATION_CLASS QApplication
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "servercontroller.h"
|
#include "servercontroller.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
|
|
@ -3,35 +3,59 @@
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
void FileUtilites::saveFile(const QString &fileExtension, const QString &caption, const QString &fileName,
|
#ifdef Q_OS_ANDROID
|
||||||
const QString &data)
|
#include "platforms/android/android_controller.h"
|
||||||
{
|
#endif
|
||||||
QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
|
||||||
QUrl fileUrl = QFileDialog::getSaveFileUrl(nullptr, caption, QUrl::fromLocalFile(docDir + "/" + fileName),
|
|
||||||
"*" + fileExtension);
|
|
||||||
if (fileUrl.isEmpty())
|
|
||||||
return;
|
|
||||||
if (!fileUrl.toString().endsWith(fileExtension)) {
|
|
||||||
fileUrl = QUrl(fileUrl.toString() + fileExtension);
|
|
||||||
}
|
|
||||||
if (fileUrl.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QFile save(fileUrl.toLocalFile());
|
#ifdef Q_OS_IOS
|
||||||
|
#include "platforms/ios/MobileUtils.h"
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void FileUtilites::saveFile(QString fileName, const QString &data)
|
||||||
|
{
|
||||||
|
#if defined Q_OS_ANDROID
|
||||||
|
AndroidController::instance()->shareConfig(data, fileName);
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_IOS
|
||||||
|
QFile file(fileName);
|
||||||
|
#else
|
||||||
|
QUrl fileUrl = QUrl(fileName);
|
||||||
|
QFile file(fileUrl.toLocalFile());
|
||||||
|
#endif
|
||||||
|
|
||||||
// todo check if save successful
|
// todo check if save successful
|
||||||
save.open(QIODevice::WriteOnly);
|
file.open(QIODevice::WriteOnly);
|
||||||
save.write(data.toUtf8());
|
file.write(data.toUtf8());
|
||||||
save.close();
|
file.close();
|
||||||
|
|
||||||
|
#ifdef Q_OS_IOS
|
||||||
|
QStringList filesToSend;
|
||||||
|
filesToSend.append(fileName);
|
||||||
|
MobileUtils::shareText(filesToSend);
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
QFileInfo fi(fileUrl.toLocalFile());
|
QFileInfo fi(fileUrl.toLocalFile());
|
||||||
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FileUtilites::getFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
|
QString FileUtilites::getFileName(QString fileName)
|
||||||
QString *selectedFilter, QFileDialog::Options options)
|
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options);
|
#ifdef Q_OS_IOS
|
||||||
|
CFURLRef url = CFURLCreateWithFileSystemPath(
|
||||||
|
kCFAllocatorDefault,
|
||||||
|
CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(fileName.unicode()), fileName.length()),
|
||||||
|
kCFURLPOSIXPathStyle, 0);
|
||||||
|
|
||||||
|
if (!CFURLStartAccessingSecurityScopedResource(url)) {
|
||||||
|
qDebug() << "Could not access path " << QUrl::fromLocalFile(fileName).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
// patch for files containing spaces etc
|
// patch for files containing spaces etc
|
||||||
|
@ -42,6 +66,9 @@ QString FileUtilites::getFileName(QWidget *parent, const QString &caption, const
|
||||||
rawUrl.replace(" ", "%20");
|
rawUrl.replace(" ", "%20");
|
||||||
fileName = contentUrl + sep + rawUrl;
|
fileName = contentUrl + sep + rawUrl;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return fileName;
|
return fileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return QUrl(FileUtilites::getFileName(fileName)).toLocalFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,16 @@
|
||||||
#ifndef FILEUTILITES_H
|
#ifndef FILEUTILITES_H
|
||||||
#define FILEUTILITES_H
|
#define FILEUTILITES_H
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
class FileUtilites : public QObject
|
class FileUtilites : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void saveFile(const QString &fileExtension, const QString &caption, const QString &fileName,
|
static void saveFile(QString fileName, const QString &data);
|
||||||
const QString &data);
|
static QString getFileName(QString fileName);
|
||||||
|
|
||||||
static QString getFileName(QWidget *parent = nullptr, const QString &caption = QString(),
|
|
||||||
const QString &dir = QString(), const QString &filter = QString(),
|
|
||||||
QString *selectedFilter = nullptr, QFileDialog::Options options = QFileDialog::Options());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILEUTILITES_H
|
#endif // FILEUTILITES_H
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
void getBackendLogs(std::function<void (const QString &)> &&callback);
|
void getBackendLogs(std::function<void (const QString &)> &&callback);
|
||||||
void checkStatus();
|
void checkStatus();
|
||||||
signals:
|
signals:
|
||||||
void connectionStateChanged(VpnProtocol::VpnConnectionState state);
|
void connectionStateChanged(Vpn::ConnectionState state);
|
||||||
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
void bytesChanged(quint64 receivedBytes, quint64 sentBytes);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "core/errorstrings.h"
|
#include "core/errorstrings.h"
|
||||||
#include "fileUtilites.h"
|
#include "fileUtilites.h"
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
#include "platforms/android/android_controller.h"
|
|
||||||
#include "platforms/android/androidutils.h"
|
#include "platforms/android/androidutils.h"
|
||||||
#endif
|
#endif
|
||||||
#include "qrcodegen.hpp"
|
#include "qrcodegen.hpp"
|
||||||
|
@ -201,35 +200,9 @@ QList<QString> ExportController::getQrCodes()
|
||||||
return m_qrCodes;
|
return m_qrCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportController::saveFile(const QString &fileExtension, const QString &caption, const QString &fileName)
|
void ExportController::saveFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
#if defined Q_OS_IOS
|
FileUtilites::saveFile(fileName, m_config);
|
||||||
// ext.replace("*", "");
|
|
||||||
// QString fileName = QDir::tempPath() + "/" + suggestedName;
|
|
||||||
//
|
|
||||||
// if (fileName.isEmpty())
|
|
||||||
// return;
|
|
||||||
// if (!fileName.endsWith(ext))
|
|
||||||
// fileName.append(ext);
|
|
||||||
//
|
|
||||||
// QFile::remove(fileName);
|
|
||||||
//
|
|
||||||
// QFile save(fileName);
|
|
||||||
// save.open(QIODevice::WriteOnly);
|
|
||||||
// save.write(data.toUtf8());
|
|
||||||
// save.close();
|
|
||||||
//
|
|
||||||
// QStringList filesToSend;
|
|
||||||
// filesToSend.append(fileName);
|
|
||||||
// MobileUtils::shareText(filesToSend);
|
|
||||||
// return;
|
|
||||||
#endif
|
|
||||||
#if defined Q_OS_ANDROID
|
|
||||||
AndroidController::instance()->shareConfig(m_config, "amnezia_config");
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FileUtilites::saveFile(fileExtension, caption, fileName, m_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> ExportController::generateQrCodeImageSeries(const QByteArray &data)
|
QList<QString> ExportController::generateQrCodeImageSeries(const QByteArray &data)
|
||||||
|
|
|
@ -35,7 +35,7 @@ public slots:
|
||||||
QString getConfig();
|
QString getConfig();
|
||||||
QList<QString> getQrCodes();
|
QList<QString> getQrCodes();
|
||||||
|
|
||||||
void saveFile(const QString &fileExtension, const QString &caption, const QString &fileName);
|
void saveFile(const QString &fileName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void generateConfig(int type);
|
void generateConfig(int type);
|
||||||
|
|
|
@ -85,23 +85,9 @@ ImportController::ImportController(const QSharedPointer<ServersModel> &serversMo
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportController::extractConfigFromFile()
|
void ImportController::extractConfigFromFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
QString fileName = FileUtilites::getFileName(Q_NULLPTR, tr("Open config file"),
|
QFile file(FileUtilites::getFileName(fileName));
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),
|
|
||||||
"*.vpn *.ovpn *.conf");
|
|
||||||
QFile file(fileName);
|
|
||||||
|
|
||||||
#ifdef Q_OS_IOS
|
|
||||||
CFURLRef url = CFURLCreateWithFileSystemPath(
|
|
||||||
kCFAllocatorDefault,
|
|
||||||
CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(fileName.unicode()), fileName.length()),
|
|
||||||
kCFURLPOSIXPathStyle, 0);
|
|
||||||
|
|
||||||
if (!CFURLStartAccessingSecurityScopedResource(url)) {
|
|
||||||
qDebug() << "Could not access path " << QUrl::fromLocalFile(fileName).toString();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
QString data = file.readAll();
|
QString data = file.readAll();
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void importConfig();
|
void importConfig();
|
||||||
void extractConfigFromFile();
|
void extractConfigFromFile(const QString &fileName);
|
||||||
void extractConfigFromData(QString &data);
|
void extractConfigFromData(QString &data);
|
||||||
void extractConfigFromCode(QString code);
|
void extractConfigFromCode(QString code);
|
||||||
bool extractConfigFromQr(const QByteArray &data);
|
bool extractConfigFromQr(const QByteArray &data);
|
||||||
|
|
|
@ -68,9 +68,9 @@ void SettingsController::openLogsFolder()
|
||||||
Logger::openLogsFolder();
|
Logger::openLogsFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsController::exportLogsFile()
|
void SettingsController::exportLogsFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
FileUtilites::saveFile(".log", tr("Save log"), "AmneziaVPN", Logger::getLogFile());
|
FileUtilites::saveFile(fileName, Logger::getLogFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsController::clearLogs()
|
void SettingsController::clearLogs()
|
||||||
|
@ -79,35 +79,17 @@ void SettingsController::clearLogs()
|
||||||
Logger::clearServiceLogs();
|
Logger::clearServiceLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsController::backupAppConfig()
|
void SettingsController::backupAppConfig(const QString &fileName)
|
||||||
{
|
{
|
||||||
FileUtilites::saveFile(".backup", tr("Backup application config"), "AmneziaVPN", m_settings->backupAppConfig());
|
FileUtilites::saveFile(fileName, m_settings->backupAppConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsController::restoreAppConfig()
|
void SettingsController::restoreAppConfig(const QString &fileName)
|
||||||
{
|
{
|
||||||
QString fileName =
|
QFile file(FileUtilites::getFileName(fileName));
|
||||||
FileUtilites::getFileName(Q_NULLPTR, tr("Open backup"),
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
|
||||||
|
|
||||||
if (fileName.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(fileName);
|
|
||||||
|
|
||||||
#ifdef Q_OS_IOS
|
|
||||||
CFURLRef url = CFURLCreateWithFileSystemPath(
|
|
||||||
kCFAllocatorDefault,
|
|
||||||
CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(fileName.unicode()), fileName.length()),
|
|
||||||
kCFURLPOSIXPathStyle, 0);
|
|
||||||
|
|
||||||
if (!CFURLStartAccessingSecurityScopedResource(url)) {
|
|
||||||
qDebug() << "Could not access path " << QUrl::fromLocalFile(fileName).toString();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
|
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
|
|
||||||
bool ok = m_settings->restoreAppConfig(data);
|
bool ok = m_settings->restoreAppConfig(data);
|
||||||
|
|
|
@ -34,11 +34,11 @@ public slots:
|
||||||
void toggleLogging(bool enable);
|
void toggleLogging(bool enable);
|
||||||
|
|
||||||
void openLogsFolder();
|
void openLogsFolder();
|
||||||
void exportLogsFile();
|
void exportLogsFile(const QString &fileName);
|
||||||
void clearLogs();
|
void clearLogs();
|
||||||
|
|
||||||
void backupAppConfig();
|
void backupAppConfig(const QString &fileName);
|
||||||
void restoreAppConfig();
|
void restoreAppConfig(const QString &fileName);
|
||||||
|
|
||||||
QString getAppVersion();
|
QString getAppVersion();
|
||||||
|
|
||||||
|
|
|
@ -79,28 +79,9 @@ void SitesController::removeSite(int index)
|
||||||
emit finished(tr("Site removed: ") + hostname);
|
emit finished(tr("Site removed: ") + hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SitesController::importSites(bool replaceExisting)
|
void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
||||||
{
|
{
|
||||||
QString fileName =
|
QFile file(FileUtilites::getFileName(fileName));
|
||||||
FileUtilites::getFileName(Q_NULLPTR, tr("Open sites file"),
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.json");
|
|
||||||
|
|
||||||
if (fileName.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(fileName);
|
|
||||||
|
|
||||||
#ifdef Q_OS_IOS
|
|
||||||
CFURLRef url = CFURLCreateWithFileSystemPath(
|
|
||||||
kCFAllocatorDefault,
|
|
||||||
CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(fileName.unicode()), fileName.length()),
|
|
||||||
kCFURLPOSIXPathStyle, 0);
|
|
||||||
|
|
||||||
if (!CFURLStartAccessingSecurityScopedResource(url)) {
|
|
||||||
qDebug() << "Could not access path " << QUrl::fromLocalFile(fileName).toString();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
emit errorOccurred(tr("Can't open file: ") + fileName);
|
emit errorOccurred(tr("Can't open file: ") + fileName);
|
||||||
|
@ -149,7 +130,7 @@ void SitesController::importSites(bool replaceExisting)
|
||||||
emit finished(tr("Import completed"));
|
emit finished(tr("Import completed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SitesController::exportSites()
|
void SitesController::exportSites(const QString &fileName)
|
||||||
{
|
{
|
||||||
auto sites = m_sitesModel->getCurrentSites();
|
auto sites = m_sitesModel->getCurrentSites();
|
||||||
|
|
||||||
|
@ -163,7 +144,7 @@ void SitesController::exportSites()
|
||||||
QJsonDocument jsonDocument(jsonArray);
|
QJsonDocument jsonDocument(jsonArray);
|
||||||
QByteArray jsonData = jsonDocument.toJson();
|
QByteArray jsonData = jsonDocument.toJson();
|
||||||
|
|
||||||
FileUtilites::saveFile(".json", tr("Export sites file"), "sites", jsonData);
|
FileUtilites::saveFile(fileName, jsonData);
|
||||||
|
|
||||||
emit finished(tr("Export completed"));
|
emit finished(tr("Export completed"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ public slots:
|
||||||
void addSite(QString hostname);
|
void addSite(QString hostname);
|
||||||
void removeSite(int index);
|
void removeSite(int index);
|
||||||
|
|
||||||
void importSites(bool replaceExisting);
|
void importSites(const QString &fileName, bool replaceExisting);
|
||||||
void exportSites();
|
void exportSites(const QString &fileName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void errorOccurred(const QString &errorMessage);
|
void errorOccurred(const QString &errorMessage);
|
||||||
|
|
|
@ -3,6 +3,8 @@ import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Dialogs
|
import QtQuick.Dialogs
|
||||||
|
|
||||||
|
import QtCore
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
|
@ -67,8 +69,19 @@ DrawerType {
|
||||||
text: qsTr("Share")
|
text: qsTr("Share")
|
||||||
imageSource: "qrc:/images/controls/share-2.svg"
|
imageSource: "qrc:/images/controls/share-2.svg"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: fileDialog.open()
|
||||||
ExportController.saveFile(configExtension, configCaption, configFileName)
|
|
||||||
|
FileDialog {
|
||||||
|
id: fileDialog
|
||||||
|
acceptLabel: configCaption
|
||||||
|
nameFilters: [ "Config files (*" + configExtension + ")" ]
|
||||||
|
fileMode: FileDialog.SaveFile
|
||||||
|
|
||||||
|
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/" + configFileName
|
||||||
|
defaultSuffix: configExtension
|
||||||
|
onAccepted: {
|
||||||
|
ExportController.saveFile(fileDialog.currentFile.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,4 +146,14 @@ Item {
|
||||||
color: "#EB5757"
|
color: "#EB5757"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: root
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
onPressed: function(mouse) {
|
||||||
|
textField.forceActiveFocus()
|
||||||
|
mouse.accepted = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Dialogs
|
||||||
|
|
||||||
|
import QtCore
|
||||||
|
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
|
|
||||||
|
@ -74,14 +77,36 @@ PageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicButtonType {
|
BasicButtonType {
|
||||||
|
id: makeBackupButton
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 14
|
Layout.topMargin: 14
|
||||||
|
|
||||||
text: qsTr("Make a backup")
|
text: qsTr("Make a backup")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (GC.isMobile()) {
|
||||||
|
backupAppConfig("AmneziaVPN.backup")
|
||||||
|
} else {
|
||||||
|
saveFileDialog.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: saveFileDialog
|
||||||
|
acceptLabel: qsTr("Save backup file")
|
||||||
|
nameFilters: [ "Backup files (*.backup)" ]
|
||||||
|
fileMode: FileDialog.SaveFile
|
||||||
|
|
||||||
|
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN"
|
||||||
|
defaultSuffix: ".backup"
|
||||||
|
onAccepted: {
|
||||||
|
makeBackupButton.backupAppConfig(saveFileDialog.currentFile.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function backupAppConfig(fileName) {
|
||||||
PageController.showBusyIndicator(true)
|
PageController.showBusyIndicator(true)
|
||||||
SettingsController.backupAppConfig()
|
SettingsController.backupAppConfig(fileName)
|
||||||
PageController.showBusyIndicator(false)
|
PageController.showBusyIndicator(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,9 +125,18 @@ PageType {
|
||||||
text: qsTr("Restore from backup")
|
text: qsTr("Restore from backup")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
PageController.showBusyIndicator(true)
|
openFileDialog.open()
|
||||||
SettingsController.restoreAppConfig()
|
}
|
||||||
PageController.showBusyIndicator(false)
|
|
||||||
|
FileDialog {
|
||||||
|
id: openFileDialog
|
||||||
|
acceptLabel: qsTr("Open backup file")
|
||||||
|
nameFilters: [ "Backup files (*.backup)" ]
|
||||||
|
onAccepted: {
|
||||||
|
PageController.showBusyIndicator(true)
|
||||||
|
SettingsController.restoreAppConfig(openFileDialog.selectedFile.toString())
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Dialogs
|
||||||
|
|
||||||
|
import QtCore
|
||||||
|
|
||||||
import PageEnum 1.0
|
import PageEnum 1.0
|
||||||
|
|
||||||
|
@ -97,7 +100,20 @@ PageType {
|
||||||
|
|
||||||
image: "qrc:/images/controls/save.svg"
|
image: "qrc:/images/controls/save.svg"
|
||||||
|
|
||||||
onClicked: SettingsController.exportLogsFile()
|
onClicked: fileDialog.open()
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: fileDialog
|
||||||
|
acceptLabel: qsTr("Save logs")
|
||||||
|
nameFilters: [ "Logs files (*.log)" ]
|
||||||
|
fileMode: FileDialog.SaveFile
|
||||||
|
|
||||||
|
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN"
|
||||||
|
defaultSuffix: ".log"
|
||||||
|
onAccepted: {
|
||||||
|
ExportController.saveFile(fileDialog.currentFile.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CaptionTextType {
|
CaptionTextType {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Dialogs
|
||||||
|
|
||||||
|
import QtCore
|
||||||
|
|
||||||
import SortFilterProxyModel 0.2
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
|
@ -41,6 +44,8 @@ PageType {
|
||||||
allExceptSites
|
allExceptSites
|
||||||
]
|
]
|
||||||
|
|
||||||
|
property bool replaceExistingSites
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: onlyForwardSites
|
id: onlyForwardSites
|
||||||
property string name: qsTr("Only the addresses in the list must be opened via VPN")
|
property string name: qsTr("Only the addresses in the list must be opened via VPN")
|
||||||
|
@ -295,8 +300,21 @@ PageType {
|
||||||
text: qsTr("Save site list")
|
text: qsTr("Save site list")
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
SitesController.exportSites()
|
saveFileDialog.open()
|
||||||
moreActionsDrawer.close()
|
}
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: saveFileDialog
|
||||||
|
acceptLabel: qsTr("Save sites")
|
||||||
|
nameFilters: [ "Sites files (*.json)" ]
|
||||||
|
fileMode: FileDialog.SaveFile
|
||||||
|
|
||||||
|
currentFile: StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/sites"
|
||||||
|
defaultSuffix: ".json"
|
||||||
|
onAccepted: {
|
||||||
|
SitesController.exportSites(saveFileDialog.currentFile.toString())
|
||||||
|
moreActionsDrawer.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,6 +349,7 @@ PageType {
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
contentHeight: importSitesDrawerContent.height
|
contentHeight: importSitesDrawerContent.height
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: importSitesDrawerContent
|
id: importSitesDrawerContent
|
||||||
|
|
||||||
|
@ -351,9 +370,8 @@ PageType {
|
||||||
text: qsTr("Replace site list")
|
text: qsTr("Replace site list")
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
SitesController.importSites(true)
|
root.replaceExistingSites = true
|
||||||
importSitesDrawer.close()
|
openFileDialog.open()
|
||||||
moreActionsDrawer.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,13 +382,23 @@ PageType {
|
||||||
text: qsTr("Add imported sites to existing ones")
|
text: qsTr("Add imported sites to existing ones")
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
SitesController.importSites(false)
|
root.replaceExistingSites = false
|
||||||
importSitesDrawer.close()
|
openFileDialog.open()
|
||||||
moreActionsDrawer.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DividerType {}
|
DividerType {}
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: openFileDialog
|
||||||
|
acceptLabel: qsTr("Open sites file")
|
||||||
|
nameFilters: [ "Sites files (*.json)" ]
|
||||||
|
onAccepted: {
|
||||||
|
SitesController.importSites(openFileDialog.selectedFile.toString(), replaceExistingSites)
|
||||||
|
importSitesDrawer.close()
|
||||||
|
moreActionsDrawer.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,17 @@ It's okay as long as it's from someone you trust.")
|
||||||
leftImageSource: "qrc:/images/controls/folder-open.svg"
|
leftImageSource: "qrc:/images/controls/folder-open.svg"
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
ImportController.extractConfigFromFile()
|
fileDialog.open()
|
||||||
goToPage(PageEnum.PageSetupWizardViewConfig)
|
}
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: fileDialog
|
||||||
|
acceptLabel: qsTr("Open config file")
|
||||||
|
nameFilters: [ "Config files (*.vpn *.ovpn *.conf)" ]
|
||||||
|
onAccepted: {
|
||||||
|
ImportController.extractConfigFromFile(fileDialog.selectedFile.toString())
|
||||||
|
goToPage(PageEnum.PageSetupWizardViewConfig)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <QApplication>
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
@ -175,7 +174,8 @@ void UiLogic::showOnStartup()
|
||||||
void UiLogic::onUpdateAllPages()
|
void UiLogic::onUpdateAllPages()
|
||||||
{
|
{
|
||||||
for (auto logic : m_logicMap) {
|
for (auto logic : m_logicMap) {
|
||||||
if (dynamic_cast<ClientInfoLogic*>(logic) || dynamic_cast<ClientManagementLogic*>(logic) || dynamic_cast<QrDecoderLogic*>(logic)) {
|
if (dynamic_cast<ClientInfoLogic *>(logic) || dynamic_cast<ClientManagementLogic *>(logic)
|
||||||
|
|| dynamic_cast<QrDecoderLogic *>(logic)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
logic->onUpdatePage();
|
logic->onUpdatePage();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "qtimer.h"
|
#include "qtimer.h"
|
||||||
#include <QApplication>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue