added PageSettingsAbout, PageSettingsApplication, PageSettingsBackup, PageSettingsConnection, PageSettingsDns
- added SettingsController
This commit is contained in:
parent
be7386f0d7
commit
7b14ad9616
28 changed files with 1054 additions and 63 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QHostAddress>
|
||||
#include <QHostInfo>
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
#include <QRandomGenerator>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
|
||||
#include "defines.h"
|
||||
#include "utilities.h"
|
||||
|
|
@ -247,6 +249,58 @@ QString Utils::certUtilPath()
|
|||
#endif
|
||||
}
|
||||
|
||||
void Utils::saveFile(const QString &fileExtension,
|
||||
const QString &caption,
|
||||
const QString &fileName,
|
||||
const QString &data)
|
||||
{
|
||||
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());
|
||||
|
||||
//todo check if save successful
|
||||
save.open(QIODevice::WriteOnly);
|
||||
save.write(data.toUtf8());
|
||||
save.close();
|
||||
|
||||
QFileInfo fi(fileUrl.toLocalFile());
|
||||
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
||||
}
|
||||
|
||||
QString Utils::getFileName(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
|
||||
// Inspired from http://stackoverflow.com/a/15281070/1529139
|
||||
// and http://stackoverflow.com/q/40059902/1529139
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue