Files
amnezia-client/client/ui/controllers/exportController.h
T

59 lines
1.7 KiB
C++
Raw Normal View History

2023-06-13 20:03:20 +09:00
#ifndef EXPORTCONTROLLER_H
#define EXPORTCONTROLLER_H
#include <QObject>
#include "configurators/vpn_configurator.h"
#include "ui/models/containers_model.h"
#include "ui/models/servers_model.h"
class ExportController : public QObject
{
Q_OBJECT
public:
explicit ExportController(const QSharedPointer<ServersModel> &serversModel,
const QSharedPointer<ContainersModel> &containersModel,
const std::shared_ptr<Settings> &settings,
const std::shared_ptr<VpnConfigurator> &configurator, QObject *parent = nullptr);
2023-06-13 20:03:20 +09:00
Q_PROPERTY(QList<QString> qrCodes READ getQrCodes NOTIFY exportConfigChanged)
Q_PROPERTY(int qrCodesCount READ getQrCodesCount NOTIFY exportConfigChanged)
Q_PROPERTY(QString formattedConfig READ getFormattedConfig NOTIFY exportConfigChanged)
2023-06-13 20:03:20 +09:00
public slots:
void generateFullAccessConfig();
void generateConnectionConfig();
void generateOpenVpnConfig();
void generateWireGuardConfig();
QString getFormattedConfig();
2023-06-13 20:03:20 +09:00
QList<QString> getQrCodes();
void saveFile();
signals:
void generateConfig(int type);
void exportErrorOccurred(QString errorMessage);
void exportConfigChanged();
2023-06-13 20:03:20 +09:00
private:
QList<QString> generateQrCodeImageSeries(const QByteArray &data);
QString svgToBase64(const QString &image);
int getQrCodesCount();
void clearPreviousConfig();
2023-06-13 20:03:20 +09:00
QSharedPointer<ServersModel> m_serversModel;
QSharedPointer<ContainersModel> m_containersModel;
std::shared_ptr<Settings> m_settings;
std::shared_ptr<VpnConfigurator> m_configurator;
QString m_rawConfig;
QString m_formattedConfig;
2023-06-13 20:03:20 +09:00
QList<QString> m_qrCodes;
};
#endif // EXPORTCONTROLLER_H