getOpenFileName fix
This commit is contained in:
parent
ef8668dce4
commit
2a7365730b
6 changed files with 30 additions and 33 deletions
|
@ -83,7 +83,7 @@ void AppSettingsLogic::onPushButtonBackupAppConfigClicked()
|
||||||
|
|
||||||
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
void AppSettingsLogic::onPushButtonRestoreAppConfigClicked()
|
||||||
{
|
{
|
||||||
QString fileName = Utils::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
QString fileName = UiLogic::getOpenFileName(Q_NULLPTR, tr("Open backup"),
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.backup");
|
||||||
|
|
||||||
if (fileName.isEmpty()) return;
|
if (fileName.isEmpty()) return;
|
||||||
|
|
|
@ -167,7 +167,7 @@ void StartPageLogic::onPushButtonImport()
|
||||||
|
|
||||||
void StartPageLogic::onPushButtonImportOpenFile()
|
void StartPageLogic::onPushButtonImportOpenFile()
|
||||||
{
|
{
|
||||||
QString fileName = Utils::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
QString fileName = UiLogic::getOpenFileName(Q_NULLPTR, tr("Open config file"),
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn *.ovpn *.conf");
|
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn *.ovpn *.conf");
|
||||||
if (fileName.isEmpty()) return;
|
if (fileName.isEmpty()) return;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
@ -498,6 +497,24 @@ void UiLogic::shareTempFile(const QString &suggestedName, QString ext, const QSt
|
||||||
MobileUtils::shareText(filesToSend);
|
MobileUtils::shareText(filesToSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString UiLogic::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir,
|
||||||
|
const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options);
|
||||||
|
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
// patch for files containing spaces etc
|
||||||
|
const QString sep {"raw%3A%2F"};
|
||||||
|
if (fileName.startsWith("content://") && fileName.contains(sep)) {
|
||||||
|
QString contentUrl = fileName.split(sep).at(0);
|
||||||
|
QString rawUrl = fileName.split(sep).at(1);
|
||||||
|
rawUrl.replace(" ", "%20");
|
||||||
|
fileName = contentUrl + sep + rawUrl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
void UiLogic::registerPagesLogic()
|
void UiLogic::registerPagesLogic()
|
||||||
{
|
{
|
||||||
amnApp->qmlEngine()->rootContext()->setContextProperty("UiLogic", this);
|
amnApp->qmlEngine()->rootContext()->setContextProperty("UiLogic", this);
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
#ifndef UILOGIC_H
|
#ifndef UILOGIC_H
|
||||||
#define UILOGIC_H
|
#define UILOGIC_H
|
||||||
|
|
||||||
#include <QRegularExpressionValidator>
|
#include <QFileDialog>
|
||||||
#include <QQmlEngine>
|
|
||||||
#include <functional>
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QRegularExpressionValidator>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QQmlEngine>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -120,7 +121,12 @@ public:
|
||||||
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated);
|
Q_INVOKABLE amnezia::ErrorCode addAlreadyInstalledContainersGui(bool &isServerCreated);
|
||||||
|
|
||||||
void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
|
void shareTempFile(const QString &suggestedName, QString ext, const QString& data);
|
||||||
|
static QString getOpenFileName(QWidget *parent = nullptr,
|
||||||
|
const QString &caption = QString(),
|
||||||
|
const QString &dir = QString(),
|
||||||
|
const QString &filter = QString(),
|
||||||
|
QString *selectedFilter = nullptr,
|
||||||
|
QFileDialog::Options options = QFileDialog::Options());
|
||||||
signals:
|
signals:
|
||||||
void goToPage(PageEnumNS::Page page, bool reset = true, bool slide = true);
|
void goToPage(PageEnumNS::Page page, bool reset = true, bool slide = true);
|
||||||
void goToProtocolPage(Proto protocol, bool reset = true, bool slide = true);
|
void goToProtocolPage(Proto protocol, bool reset = true, bool slide = true);
|
||||||
|
|
|
@ -247,23 +247,6 @@ QString Utils::certUtilPath()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Utils::getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
|
|
||||||
{
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options);
|
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
|
||||||
// patch for files containing spaces etc
|
|
||||||
const QString sep {"raw%3A%2F"};
|
|
||||||
if (fileName.startsWith("content://") && fileName.contains(sep)) {
|
|
||||||
QString contentUrl = fileName.split(sep).at(0);
|
|
||||||
QString rawUrl = fileName.split(sep).at(1);
|
|
||||||
rawUrl.replace(" ", "%20");
|
|
||||||
fileName = contentUrl + sep + rawUrl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Inspired from http://stackoverflow.com/a/15281070/1529139
|
// Inspired from http://stackoverflow.com/a/15281070/1529139
|
||||||
// and http://stackoverflow.com/q/40059902/1529139
|
// and http://stackoverflow.com/q/40059902/1529139
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef UTILITIES_H
|
#ifndef UTILITIES_H
|
||||||
#define UTILITIES_H
|
#define UTILITIES_H
|
||||||
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
@ -51,14 +50,6 @@ public:
|
||||||
static QString wireguardExecPath();
|
static QString wireguardExecPath();
|
||||||
static QString certUtilPath();
|
static QString certUtilPath();
|
||||||
|
|
||||||
static QString getOpenFileName(QWidget *parent = nullptr,
|
|
||||||
const QString &caption = QString(),
|
|
||||||
const QString &dir = QString(),
|
|
||||||
const QString &filter = QString(),
|
|
||||||
QString *selectedFilter = nullptr,
|
|
||||||
QFileDialog::Options options = QFileDialog::Options());
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
|
static bool signalCtrl(DWORD dwProcessId, DWORD dwCtrlEvent);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue