mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
* feat: added 'clear site list' button (#1747) * chore: rename 'Export/Import Sites' to 'Additional options' --------- Co-authored-by: MrMirDan <58086007+MrMirDan@users.noreply.github.com>
This commit is contained in:
@@ -78,6 +78,13 @@ void SitesController::removeSite(int index)
|
|||||||
emit finished(tr("Site removed: %1").arg(hostname));
|
emit finished(tr("Site removed: %1").arg(hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SitesController::removeSites()
|
||||||
|
{
|
||||||
|
m_sitesModel->removeSites();
|
||||||
|
|
||||||
|
emit finished(tr("Site list cleared!"));
|
||||||
|
}
|
||||||
|
|
||||||
void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
||||||
{
|
{
|
||||||
QByteArray jsonData;
|
QByteArray jsonData;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public slots:
|
|||||||
void addSite(QString hostname);
|
void addSite(QString hostname);
|
||||||
void removeSite(int index);
|
void removeSite(int index);
|
||||||
|
|
||||||
|
void removeSites();
|
||||||
void importSites(const QString &fileName, bool replaceExisting);
|
void importSites(const QString &fileName, bool replaceExisting);
|
||||||
void exportSites(const QString &fileName);
|
void exportSites(const QString &fileName);
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,16 @@ void SitesModel::removeSite(QModelIndex index)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SitesModel::removeSites()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
|
||||||
|
m_settings->removeAllVpnSites(m_currentRouteMode);
|
||||||
|
fillSites();
|
||||||
|
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
int SitesModel::getRouteMode()
|
int SitesModel::getRouteMode()
|
||||||
{
|
{
|
||||||
return m_currentRouteMode;
|
return m_currentRouteMode;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public slots:
|
|||||||
bool addSite(const QString &hostname, const QString &ip);
|
bool addSite(const QString &hostname, const QString &ip);
|
||||||
void addSites(const QMap<QString, QString> &sites, bool replaceExisting);
|
void addSites(const QMap<QString, QString> &sites, bool replaceExisting);
|
||||||
void removeSite(QModelIndex index);
|
void removeSite(QModelIndex index);
|
||||||
|
void removeSites();
|
||||||
|
|
||||||
int getRouteMode();
|
int getRouteMode();
|
||||||
void setRouteMode(int routeMode);
|
void setRouteMode(int routeMode);
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ PageType {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: 16
|
Layout.margins: 16
|
||||||
|
|
||||||
headerText: qsTr("Import / Export Sites")
|
headerText: qsTr("Additional options")
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
@@ -351,6 +351,34 @@ PageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DividerType {}
|
DividerType {}
|
||||||
|
|
||||||
|
LabelWithButtonType {
|
||||||
|
id: clearSitesButton
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
text: qsTr("Clear site list")
|
||||||
|
rightImageSource: "qrc:/images/controls/trash.svg"
|
||||||
|
|
||||||
|
clickedFunction: function() {
|
||||||
|
var headerText = qsTr("Clear site list?")
|
||||||
|
var descriptionText = qsTr("All sites will be removed from list.")
|
||||||
|
var yesButtonText = qsTr("Continue")
|
||||||
|
var noButtonText = qsTr("Cancel")
|
||||||
|
|
||||||
|
var yesButtonFunction = function() {
|
||||||
|
PageController.showBusyIndicator(true)
|
||||||
|
SitesController.removeSites()
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
|
}
|
||||||
|
var noButtonFunction = function() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
showQuestionDrawer(headerText, descriptionText, yesButtonText, noButtonText, yesButtonFunction, noButtonFunction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DividerType {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user