minor ui fixes

This commit is contained in:
vladimir.kuznetsov 2023-08-22 14:37:29 +05:00
parent 420c616e9d
commit f7926847ac
11 changed files with 50 additions and 34 deletions

View file

@ -249,3 +249,13 @@ QString ContainerProps::easySetupDescription(DockerContainer container)
default: return "";
}
}
bool ContainerProps::isShareable(DockerContainer container)
{
switch (container) {
case DockerContainer::TorWebSite: return false;
case DockerContainer::Dns: return false;
case DockerContainer::Sftp: return false;
default: return true;
}
}

View file

@ -64,6 +64,8 @@ namespace amnezia
static bool isEasySetupContainer(amnezia::DockerContainer container);
static QString easySetupHeader(amnezia::DockerContainer container);
static QString easySetupDescription(amnezia::DockerContainer container);
static bool isShareable(amnezia::DockerContainer container);
};
static void declareQmlContainerEnum()

View file

@ -12,6 +12,7 @@
#include "configurators/openvpn_configurator.h"
#include "configurators/wireguard_configurator.h"
#include "core/errorstrings.h"
#include "utilities.h"
#ifdef Q_OS_ANDROID
#include "platforms/android/android_controller.h"
#include "platforms/android/androidutils.h"
@ -201,7 +202,7 @@ QList<QString> ExportController::getQrCodes()
return m_qrCodes;
}
void ExportController::saveFile()
void ExportController::saveFile(const QString &fileExtension, const QString &caption, const QString &fileName)
{
#if defined Q_OS_IOS
// ext.replace("*", "");
@ -229,27 +230,7 @@ void ExportController::saveFile()
return;
#endif
QString fileExtension = ".vpn";
QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
QUrl fileName;
fileName = QFileDialog::getSaveFileUrl(nullptr, tr("Save AmneziaVPN config"),
QUrl::fromLocalFile(docDir + "/" + "amnezia_config"), "*" + fileExtension);
if (fileName.isEmpty())
return;
if (!fileName.toString().endsWith(fileExtension)) {
fileName = QUrl(fileName.toString() + fileExtension);
}
if (fileName.isEmpty())
return;
QFile save(fileName.toLocalFile());
save.open(QIODevice::WriteOnly);
save.write(m_config.toUtf8());
save.close();
QFileInfo fi(fileName.toLocalFile());
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
Utils::saveFile(fileExtension, caption, fileName, m_config);
}
QList<QString> ExportController::generateQrCodeImageSeries(const QByteArray &data)

View file

@ -35,7 +35,7 @@ public slots:
QString getConfig();
QList<QString> getQrCodes();
void saveFile();
void saveFile(const QString &fileExtension, const QString &caption, const QString &fileName);
signals:
void generateConfig(int type);

View file

@ -79,6 +79,7 @@ QVariant ContainersModel::data(const QModelIndex &index, int role) const
case IsCurrentlyProcessedRole: return container == static_cast<DockerContainer>(m_currentlyProcessedContainerIndex);
case IsDefaultRole: return container == m_defaultContainerIndex;
case IsSupportedRole: return ContainerProps::isSupportedByCurrentPlatform(container);
case IsShareableRole: return ContainerProps::isShareable(container);
}
return QVariant();
@ -235,5 +236,6 @@ QHash<int, QByteArray> ContainersModel::roleNames() const
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
roles[IsDefaultRole] = "isDefault";
roles[IsSupportedRole] = "isSupported";
roles[IsShareableRole] = "isShareable";
return roles;
}

View file

@ -30,7 +30,8 @@ public:
IsInstalledRole,
IsCurrentlyProcessedRole,
IsDefaultRole,
IsSupportedRole
IsSupportedRole,
IsShareableRole
};
int rowCount(const QModelIndex &parent = QModelIndex()) const override;

View file

@ -19,9 +19,19 @@ DrawerType {
property alias configContentHeaderText: configContentHeader.headerText
property alias contentVisible: content.visible
property string configExtension: ".vpn"
property string configCaption: qsTr("Save AmneziaVPN config")
property string configFileName: "amnezia_config.vpn"
width: parent.width
height: parent.height * 0.9
onClosed: {
configExtension = ".vpn"
configCaption = qsTr("Save AmneziaVPN config")
configFileName = "amnezia_config.vpn"
}
Item {
anchors.fill: parent
@ -58,7 +68,7 @@ DrawerType {
imageSource: "qrc:/images/controls/share-2.svg"
onClicked: {
ExportController.saveFile()
ExportController.saveFile(configExtension, configCaption, configFileName)
}
}

View file

@ -161,7 +161,7 @@ And if you don't like the app, all the more support it - the donation will be us
leftImageSource: "qrc:/images/controls/amnezia.svg"
clickedFunction: function() {
Qt.openUrlExternally(qsTr("amnezia.org/"))
Qt.openUrlExternally(qsTr("https://amnezia.org"))
}
}

View file

@ -67,7 +67,6 @@ PageType {
Layout.rightMargin: 16
text: qsTr("Use AmneziaDNS if installed on the server")
descriptionText: qsTr("Internal IP address 172.29.172.254")
checked: SettingsController.isAmneziaDnsEnabled()
onCheckedChanged: {

View file

@ -73,10 +73,6 @@ PageType {
}
Component.onCompleted: {
console.log(qrCodeRectange.x)
console.log(qrCodeRectange.y)
console.log(qrCodeRectange.width)
qrCodeReader.setCameraSize(Qt.rect(qrCodeRectange.x,
qrCodeRectange.y,
qrCodeRectange.width,

View file

@ -41,8 +41,20 @@ PageType {
}
break;
}
case PageShare.ConfigType.OpenVpn: ExportController.generateOpenVpnConfig(); break;
case PageShare.ConfigType.WireGuard: ExportController.generateWireGuardConfig(); break;
case PageShare.ConfigType.OpenVpn: {
ExportController.generateOpenVpnConfig();
shareConnectionDrawer.configCaption = qsTr("Save OpenVPN config")
shareConnectionDrawer.configExtension = ".ovpn"
shareConnectionDrawer.configFileName = "amnezia_for_openvpn"
break;
}
case PageShare.ConfigType.WireGuard: {
ExportController.generateWireGuardConfig();
shareConnectionDrawer.configCaption = qsTr("Save WireGuard config")
shareConnectionDrawer.configExtension = ".conf"
shareConnectionDrawer.configFileName = "amnezia_for_wireguard"
break;
}
}
PageController.showBusyIndicator(false)
@ -267,6 +279,10 @@ PageType {
ValueFilter {
roleName: "isInstalled"
value: true
},
ValueFilter {
roleName: "isShareable"
value: true
}
]
}
@ -339,7 +355,6 @@ PageType {
listView: ListViewWithRadioButtonType {
onCurrentIndexChanged: {
console.log(currentIndex)
exportTypeSelector.currentIndex = currentIndex
exportTypeSelector.text = selectedText
}