Merge branch 'dev' into feature/amnezia-wireguard-client-impl
This commit is contained in:
commit
135726f177
52 changed files with 4380 additions and 2197 deletions
|
@ -50,10 +50,29 @@ endif()
|
|||
|
||||
qt6_add_resources(QRC ${QRC} ${CMAKE_CURRENT_LIST_DIR}/resources.qrc)
|
||||
|
||||
qt6_add_translations(${PROJECT} TS_FILES
|
||||
# -- i18n begin
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(AMNEZIAVPN_TS_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_ru.ts
|
||||
${CMAKE_CURRENT_LIST_DIR}/translations/amneziavpn_zh_CN.ts
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE AMNEZIAVPN_TS_SOURCES *.qrc *.cpp *.h *.ui)
|
||||
|
||||
qt_create_translation(AMNEZIAVPN_QM_FILES ${AMNEZIAVPN_TS_SOURCES} ${AMNEZIAVPN_TS_FILES})
|
||||
|
||||
set(QM_FILE_LIST "")
|
||||
foreach(FILE ${AMNEZIAVPN_QM_FILES})
|
||||
get_filename_component(QM_FILE_NAME ${FILE} NAME)
|
||||
list(APPEND QM_FILE_LIST "<file>${QM_FILE_NAME}</file>")
|
||||
endforeach()
|
||||
string(REPLACE ";" "" QM_FILE_LIST ${QM_FILE_LIST})
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/translations/translations.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||
qt6_add_resources(QRC ${I18NQRC} ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||
# -- i18n end
|
||||
|
||||
if(IOS)
|
||||
#execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/scripts/run-build-cloak.sh)
|
||||
execute_process(COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/ios/scripts/openvpn.sh args
|
||||
|
@ -324,5 +343,5 @@ if(NOT IOS AND NOT ANDROID)
|
|||
|
||||
endif()
|
||||
|
||||
target_sources(${PROJECT} PRIVATE ${SOURCES} ${HEADERS} ${RESOURCES} ${QRC})
|
||||
target_sources(${PROJECT} PRIVATE ${SOURCES} ${HEADERS} ${RESOURCES} ${QRC} ${I18NQRC})
|
||||
qt_finalize_target(${PROJECT})
|
||||
|
|
|
@ -87,6 +87,7 @@ void AmneziaApplication::init()
|
|||
m_vpnConnectionThread.start();
|
||||
|
||||
initModels();
|
||||
loadTranslator();
|
||||
initControllers();
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
|
@ -138,6 +139,7 @@ void AmneziaApplication::init()
|
|||
&ConnectionController::openConnection);
|
||||
connect(m_notificationHandler.get(), &NotificationHandler::disconnectRequested, m_connectionController.get(),
|
||||
&ConnectionController::closeConnection);
|
||||
connect(this, &AmneziaApplication::translationsUpdated, m_notificationHandler.get(), &NotificationHandler::onTranslationsUpdated);
|
||||
|
||||
m_engine->load(url);
|
||||
m_systemController->setQmlRoot(m_engine->rootObjects().value(0));
|
||||
|
@ -221,34 +223,27 @@ void AmneziaApplication::loadTranslator()
|
|||
{
|
||||
auto locale = m_settings->getAppLanguage();
|
||||
m_translator.reset(new QTranslator());
|
||||
if (locale != QLocale::English) {
|
||||
if (m_translator->load(locale, QString("amneziavpn"), QLatin1String("_"), QLatin1String(":/i18n"))) {
|
||||
if (QCoreApplication::installTranslator(m_translator.get())) {
|
||||
m_settings->setAppLanguage(locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateTranslator(locale);
|
||||
}
|
||||
|
||||
|
||||
void AmneziaApplication::updateTranslator(const QLocale &locale)
|
||||
{
|
||||
QResource::registerResource(":/translations.qrc");
|
||||
if (!m_translator->isEmpty())
|
||||
if (!m_translator->isEmpty()) {
|
||||
QCoreApplication::removeTranslator(m_translator.get());
|
||||
|
||||
if (locale == QLocale::English) {
|
||||
m_settings->setAppLanguage(locale);
|
||||
m_engine->retranslate();
|
||||
}
|
||||
|
||||
if (m_translator->load(locale, QString("amneziavpn"), QLatin1String("_"), QLatin1String(":/i18n"))) {
|
||||
QString strFileName = QString(":/translations/amneziavpn")+QLatin1String("_")+locale.name()+".qm";
|
||||
if (m_translator->load(strFileName)) {
|
||||
if (QCoreApplication::installTranslator(m_translator.get())) {
|
||||
m_settings->setAppLanguage(locale);
|
||||
}
|
||||
|
||||
m_engine->retranslate();
|
||||
} else {
|
||||
m_settings->setAppLanguage(QLocale::English);
|
||||
}
|
||||
|
||||
m_engine->retranslate();
|
||||
|
||||
emit translationsUpdated();
|
||||
}
|
||||
|
||||
|
@ -338,6 +333,8 @@ void AmneziaApplication::initControllers()
|
|||
m_connectionController.reset(new ConnectionController(m_serversModel, m_containersModel, m_vpnConnection));
|
||||
m_engine->rootContext()->setContextProperty("ConnectionController", m_connectionController.get());
|
||||
|
||||
connect(this, &AmneziaApplication::translationsUpdated, m_connectionController.get(), &ConnectionController::onTranslationsUpdated);
|
||||
|
||||
m_pageController.reset(new PageController(m_serversModel, m_settings));
|
||||
m_engine->rootContext()->setContextProperty("PageController", m_pageController.get());
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ int main(int argc, char *argv[])
|
|||
app.setOrganizationName(ORGANIZATION_NAME);
|
||||
app.setApplicationDisplayName(APPLICATION_NAME);
|
||||
|
||||
app.loadTranslator();
|
||||
app.loadFonts();
|
||||
|
||||
bool doExec = app.parseCommands();
|
||||
|
|
|
@ -101,8 +101,6 @@ void WireguardProtocol::stop()
|
|||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(Q_OS_LINUX)
|
||||
ErrorCode WireguardProtocol::startMzImpl()
|
||||
{
|
||||
|
||||
qDebug() << "WireguardProtocol::startMzImpl():" << m_rawConfig;
|
||||
m_impl->activate(m_rawConfig);
|
||||
return ErrorCode::NoError;
|
||||
}
|
||||
|
|
|
@ -178,6 +178,15 @@ public:
|
|||
m_settings.setValue("Conf/appLanguage", locale);
|
||||
};
|
||||
|
||||
bool isScreenshotsEnabled() const
|
||||
{
|
||||
return m_settings.value("Conf/screenshotsEnabled", false).toBool();
|
||||
}
|
||||
void setScreenshotsEnabled(bool enabled)
|
||||
{
|
||||
m_settings.setValue("Conf/screenshotsEnabled", enabled);
|
||||
}
|
||||
|
||||
void clearSettings();
|
||||
|
||||
signals:
|
||||
|
|
File diff suppressed because it is too large
Load diff
2725
client/translations/amneziavpn_zh_CN.ts
Normal file
2725
client/translations/amneziavpn_zh_CN.ts
Normal file
File diff suppressed because it is too large
Load diff
5
client/translations/translations.qrc.in
Normal file
5
client/translations/translations.qrc.in
Normal file
|
@ -0,0 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/translations">
|
||||
@QM_FILE_LIST@
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -19,23 +19,8 @@ ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &s
|
|||
Qt::QueuedConnection);
|
||||
connect(this, &ConnectionController::disconnectFromVpn, m_vpnConnection.get(), &VpnConnection::disconnectFromVpn,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
ConnectionController::~ConnectionController()
|
||||
{
|
||||
// todo use ConnectionController instead of using m_vpnConnection directly
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (m_vpnConnection->connectionState() != Vpn::ConnectionState::Disconnected) {
|
||||
m_vpnConnection->disconnectFromVpn();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
QThread::msleep(100);
|
||||
if (m_vpnConnection->isDisconnected()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
m_state = Vpn::ConnectionState::Disconnected;
|
||||
}
|
||||
|
||||
void ConnectionController::openConnection()
|
||||
|
@ -70,6 +55,8 @@ QString ConnectionController::getLastConnectionError()
|
|||
|
||||
void ConnectionController::onConnectionStateChanged(Vpn::ConnectionState state)
|
||||
{
|
||||
m_state = state;
|
||||
|
||||
m_isConnected = false;
|
||||
m_connectionStateText = tr("Connection...");
|
||||
switch (state) {
|
||||
|
@ -126,6 +113,17 @@ void ConnectionController::onCurrentContainerUpdated()
|
|||
}
|
||||
}
|
||||
|
||||
void ConnectionController::onTranslationsUpdated()
|
||||
{
|
||||
// get translated text of current state
|
||||
onConnectionStateChanged(getCurrentConnectionState());
|
||||
}
|
||||
|
||||
Vpn::ConnectionState ConnectionController::getCurrentConnectionState()
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
QString ConnectionController::connectionStateText() const
|
||||
{
|
||||
return m_connectionStateText;
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const QSharedPointer<VpnConnection> &vpnConnection, QObject *parent = nullptr);
|
||||
|
||||
~ConnectionController();
|
||||
~ConnectionController() = default;
|
||||
|
||||
bool isConnected() const;
|
||||
bool isConnectionInProgress() const;
|
||||
|
@ -34,6 +34,8 @@ public slots:
|
|||
|
||||
void onCurrentContainerUpdated();
|
||||
|
||||
void onTranslationsUpdated();
|
||||
|
||||
signals:
|
||||
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container,
|
||||
const QJsonObject &containerConfig);
|
||||
|
@ -44,6 +46,8 @@ signals:
|
|||
void reconnectWithUpdatedContainer(const QString &message);
|
||||
|
||||
private:
|
||||
Vpn::ConnectionState getCurrentConnectionState();
|
||||
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
QSharedPointer<ContainersModel> m_containersModel;
|
||||
|
||||
|
@ -52,6 +56,8 @@ private:
|
|||
bool m_isConnected = false;
|
||||
bool m_isConnectionInProgress = false;
|
||||
QString m_connectionStateText = tr("Connect");
|
||||
|
||||
Vpn::ConnectionState m_state;
|
||||
};
|
||||
|
||||
#endif // CONNECTIONCONTROLLER_H
|
||||
|
|
|
@ -61,15 +61,6 @@ ImportController::ImportController(const QSharedPointer<ServersModel> &serversMo
|
|||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
mInstance = this;
|
||||
// Set security screen for Android app
|
||||
AndroidUtils::runOnAndroidThreadSync([]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>("addFlags", "(I)V", FLAG_SECURE);
|
||||
}
|
||||
});
|
||||
|
||||
AndroidUtils::runOnAndroidThreadAsync([]() {
|
||||
JNINativeMethod methods[] {
|
||||
|
|
|
@ -107,14 +107,12 @@ void InstallController::installServer(DockerContainer container, QJsonObject &co
|
|||
if (!installedContainers.contains(container)) {
|
||||
errorCode = serverController.setupContainer(m_currentlyInstalledServerCredentials, container, config);
|
||||
installedContainers.insert(container, config);
|
||||
finishMessage = ContainerProps::containerHumanNames().value(container) + tr(" installed successfully. ");
|
||||
finishMessage = tr("%1 installed successfully. ").arg(ContainerProps::containerHumanNames().value(container));
|
||||
} else {
|
||||
finishMessage =
|
||||
ContainerProps::containerHumanNames().value(container) + tr(" is already installed on the server. ");
|
||||
finishMessage = tr("%1 is already installed on the server. ").arg(ContainerProps::containerHumanNames().value(container));
|
||||
}
|
||||
if (installedContainers.size() > 1) {
|
||||
finishMessage += tr("\nAlready installed containers were found on the server. "
|
||||
"All installed containers have been added to the application");
|
||||
finishMessage += tr("\nAdded containers that were already installed on the server");
|
||||
}
|
||||
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
|
@ -160,10 +158,9 @@ void InstallController::installContainer(DockerContainer container, QJsonObject
|
|||
if (!installedContainers.contains(container)) {
|
||||
errorCode = serverController.setupContainer(serverCredentials, container, config);
|
||||
installedContainers.insert(container, config);
|
||||
finishMessage = ContainerProps::containerHumanNames().value(container) + tr(" installed successfully. ");
|
||||
finishMessage = tr("%1 installed successfully. ").arg(ContainerProps::containerHumanNames().value(container));
|
||||
} else {
|
||||
finishMessage =
|
||||
ContainerProps::containerHumanNames().value(container) + tr(" is already installed on the server. ");
|
||||
finishMessage = tr("%1 is already installed on the server. ").arg(ContainerProps::containerHumanNames().value(container));
|
||||
}
|
||||
|
||||
bool isInstalledContainerAddedToGui = false;
|
||||
|
@ -278,7 +275,7 @@ void InstallController::removeCurrentlyProcessedServer()
|
|||
QString serverName = m_serversModel->data(serverIndex, ServersModel::Roles::NameRole).toString();
|
||||
|
||||
m_serversModel->removeServer();
|
||||
emit removeCurrentlyProcessedServerFinished(tr("Server '") + serverName + tr("' was removed"));
|
||||
emit removeCurrentlyProcessedServerFinished(tr("Server '%1' was removed").arg(serverName));
|
||||
}
|
||||
|
||||
void InstallController::removeAllContainers()
|
||||
|
@ -288,7 +285,7 @@ void InstallController::removeAllContainers()
|
|||
|
||||
ErrorCode errorCode = m_containersModel->removeAllContainers();
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
emit removeAllContainersFinished(tr("All containers from server '") + serverName + ("' have been removed"));
|
||||
emit removeAllContainersFinished(tr("All containers from server '%1' have been removed").arg(serverName));
|
||||
return;
|
||||
}
|
||||
emit installationErrorOccurred(errorString(errorCode));
|
||||
|
@ -304,8 +301,8 @@ void InstallController::removeCurrentlyProcessedContainer()
|
|||
|
||||
ErrorCode errorCode = m_containersModel->removeCurrentlyProcessedContainer();
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
emit removeCurrentlyProcessedContainerFinished(containerName + tr(" has been removed from the server '")
|
||||
+ serverName + "'");
|
||||
|
||||
emit removeCurrentlyProcessedContainerFinished(tr("%1 has been removed from the server '%2'").arg(containerName).arg(serverName));
|
||||
return;
|
||||
}
|
||||
emit installationErrorOccurred(errorString(errorCode));
|
||||
|
|
|
@ -37,6 +37,8 @@ PageController::PageController(const QSharedPointer<ServersModel> &serversModel,
|
|||
connect(this, &PageController::raiseMainWindow, []() { setDockIconVisible(true); });
|
||||
connect(this, &PageController::hideMainWindow, []() { setDockIconVisible(false); });
|
||||
#endif
|
||||
|
||||
m_isTriggeredByConnectButton = false;
|
||||
}
|
||||
|
||||
QString PageController::getInitialPage()
|
||||
|
@ -145,3 +147,13 @@ void PageController::drawerClose()
|
|||
m_drawerLayer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool PageController::isTriggeredByConnectButton()
|
||||
{
|
||||
return m_isTriggeredByConnectButton;
|
||||
}
|
||||
|
||||
void PageController::setTriggeredBtConnectButton(bool trigger)
|
||||
{
|
||||
m_isTriggeredByConnectButton = trigger;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,10 @@ public slots:
|
|||
void drawerOpen();
|
||||
void drawerClose();
|
||||
|
||||
|
||||
bool isTriggeredByConnectButton();
|
||||
void setTriggeredBtConnectButton(bool trigger);
|
||||
|
||||
signals:
|
||||
void goToPage(PageLoader::PageEnum page, bool slide = true);
|
||||
void goToStartPage();
|
||||
|
@ -121,6 +125,8 @@ private:
|
|||
|
||||
PageLoader::PageEnum m_currentRootPage;
|
||||
int m_drawerLayer;
|
||||
|
||||
bool m_isTriggeredByConnectButton;
|
||||
};
|
||||
|
||||
#endif // PAGECONTROLLER_H
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
#include "systemController.h"
|
||||
#include "ui/qautostart.h"
|
||||
#include "version.h"
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "../../platforms/android/android_controller.h"
|
||||
#include "../../platforms/android/androidutils.h"
|
||||
#include <QJniObject>
|
||||
#endif
|
||||
|
||||
SettingsController::SettingsController(const QSharedPointer<ServersModel> &serversModel,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
|
@ -18,6 +23,20 @@ SettingsController::SettingsController(const QSharedPointer<ServersModel> &serve
|
|||
m_settings(settings)
|
||||
{
|
||||
m_appVersion = QString("%1: %2 (%3)").arg(tr("Software version"), QString(APP_MAJOR_VERSION), __DATE__);
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
if (!m_settings->isScreenshotsEnabled()) {
|
||||
// Set security screen for Android app
|
||||
AndroidUtils::runOnAndroidThreadSync([]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>("addFlags", "(I)V", FLAG_SECURE);
|
||||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingsController::toggleAmneziaDns(bool enable)
|
||||
|
@ -152,3 +171,26 @@ void SettingsController::toggleStartMinimized(bool enable)
|
|||
{
|
||||
m_settings->setStartMinimized(enable);
|
||||
}
|
||||
|
||||
bool SettingsController::isScreenshotsEnabled()
|
||||
{
|
||||
return m_settings->isScreenshotsEnabled();
|
||||
}
|
||||
|
||||
void SettingsController::toggleScreenshotsEnabled(bool enable)
|
||||
{
|
||||
m_settings->setScreenshotsEnabled(enable);
|
||||
#ifdef Q_OS_ANDROID
|
||||
std::string command = enable ? "clearFlags" : "addFlags";
|
||||
|
||||
// Set security screen for Android app
|
||||
AndroidUtils::runOnAndroidThreadSync([&command]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>(command.c_str(), "(I)V", FLAG_SECURE);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
|
@ -54,6 +54,9 @@ public slots:
|
|||
bool isStartMinimizedEnabled();
|
||||
void toggleStartMinimized(bool enable);
|
||||
|
||||
bool isScreenshotsEnabled();
|
||||
void toggleScreenshotsEnabled(bool enable);
|
||||
|
||||
signals:
|
||||
void primaryDnsChanged();
|
||||
void secondaryDnsChanged();
|
||||
|
|
|
@ -64,7 +64,7 @@ void SitesController::addSite(QString hostname)
|
|||
QHostInfo::lookupHost(hostname, this, resolveCallback);
|
||||
}
|
||||
|
||||
emit finished(tr("New site added: ") + hostname);
|
||||
emit finished(tr("New site added: %1").arg(hostname));
|
||||
}
|
||||
|
||||
void SitesController::removeSite(int index)
|
||||
|
@ -77,7 +77,7 @@ void SitesController::removeSite(int index)
|
|||
Q_ARG(QStringList, QStringList() << hostname));
|
||||
QMetaObject::invokeMethod(m_vpnConnection.get(), "flushDns", Qt::QueuedConnection);
|
||||
|
||||
emit finished(tr("Site removed: ") + hostname);
|
||||
emit finished(tr("Site removed: %1").arg(hostname));
|
||||
}
|
||||
|
||||
void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
||||
|
@ -85,19 +85,19 @@ void SitesController::importSites(const QString &fileName, bool replaceExisting)
|
|||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
emit errorOccurred(tr("Can't open file: ") + fileName);
|
||||
emit errorOccurred(tr("Can't open file: %1").arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray jsonData = file.readAll();
|
||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonData);
|
||||
if (jsonDocument.isNull()) {
|
||||
emit errorOccurred(tr("Failed to parse JSON data from file: ") + fileName);
|
||||
emit errorOccurred(tr("Failed to parse JSON data from file: %1").arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!jsonDocument.isArray()) {
|
||||
emit errorOccurred(tr("The JSON data is not an array in file: ") + fileName);
|
||||
emit errorOccurred(tr("The JSON data is not an array in file: ").arg(fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -214,6 +214,20 @@ bool ContainersModel::isAmneziaDnsContainerInstalled(const int serverIndex)
|
|||
return containers.contains(DockerContainer::Dns);
|
||||
}
|
||||
|
||||
bool ContainersModel::isAnyContainerInstalled()
|
||||
{
|
||||
for (int row=0; row < rowCount(); row++) {
|
||||
QModelIndex idx = this->index(row, 0);
|
||||
|
||||
if (this->data(idx, IsInstalledRole).toBool() &&
|
||||
this->data(idx, ServiceTypeRole).toInt() == ServiceType::Vpn) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ContainersModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
|
|
|
@ -63,7 +63,7 @@ public slots:
|
|||
bool isAmneziaDnsContainerInstalled();
|
||||
bool isAmneziaDnsContainerInstalled(const int serverIndex);
|
||||
|
||||
// bool isOnlyServicesInstalled(const int serverIndex);
|
||||
bool isAnyContainerInstalled();
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
|
|
@ -6,7 +6,8 @@ LanguageModel::LanguageModel(std::shared_ptr<Settings> settings, QObject *parent
|
|||
QMetaEnum metaEnum = QMetaEnum::fromType<LanguageSettings::AvailableLanguageEnum>();
|
||||
for (int i = 0; i < metaEnum.keyCount(); i++) {
|
||||
m_availableLanguages.push_back(
|
||||
LanguageModelData { metaEnum.valueToKey(i), static_cast<LanguageSettings::AvailableLanguageEnum>(i) });
|
||||
LanguageModelData {getLocalLanguageName(static_cast<LanguageSettings::AvailableLanguageEnum>(i)),
|
||||
static_cast<LanguageSettings::AvailableLanguageEnum>(i) });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,11 +37,26 @@ QHash<int, QByteArray> LanguageModel::roleNames() const
|
|||
return roles;
|
||||
}
|
||||
|
||||
QString LanguageModel::getLocalLanguageName(const LanguageSettings::AvailableLanguageEnum language)
|
||||
{
|
||||
QString strLanguage("");
|
||||
switch (language) {
|
||||
case LanguageSettings::AvailableLanguageEnum::English: strLanguage = "English"; break;
|
||||
case LanguageSettings::AvailableLanguageEnum::Russian: strLanguage = "Русский"; break;
|
||||
case LanguageSettings::AvailableLanguageEnum::China_cn: strLanguage = "\347\256\200\344\275\223\344\270\255\346\226\207"; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return strLanguage;
|
||||
}
|
||||
|
||||
void LanguageModel::changeLanguage(const LanguageSettings::AvailableLanguageEnum language)
|
||||
{
|
||||
switch (language) {
|
||||
case LanguageSettings::AvailableLanguageEnum::English: emit updateTranslations(QLocale::English); break;
|
||||
case LanguageSettings::AvailableLanguageEnum::Russian: emit updateTranslations(QLocale::Russian); break;
|
||||
case LanguageSettings::AvailableLanguageEnum::China_cn: emit updateTranslations(QLocale::Chinese); break;
|
||||
default: emit updateTranslations(QLocale::English); break;
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +67,7 @@ int LanguageModel::getCurrentLanguageIndex()
|
|||
switch (locale.language()) {
|
||||
case QLocale::English: return static_cast<int>(LanguageSettings::AvailableLanguageEnum::English); break;
|
||||
case QLocale::Russian: return static_cast<int>(LanguageSettings::AvailableLanguageEnum::Russian); break;
|
||||
case QLocale::Chinese: return static_cast<int>(LanguageSettings::AvailableLanguageEnum::China_cn); break;
|
||||
default: return static_cast<int>(LanguageSettings::AvailableLanguageEnum::English); break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ namespace LanguageSettings
|
|||
Q_NAMESPACE
|
||||
enum class AvailableLanguageEnum {
|
||||
English,
|
||||
Russian
|
||||
Russian,
|
||||
China_cn
|
||||
};
|
||||
Q_ENUM_NS(AvailableLanguageEnum)
|
||||
|
||||
|
@ -59,6 +60,8 @@ protected:
|
|||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
QString getLocalLanguageName(const LanguageSettings::AvailableLanguageEnum language);
|
||||
|
||||
QVector<LanguageModelData> m_availableLanguages;
|
||||
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
|
|
@ -88,6 +88,10 @@ void NotificationHandler::setConnectionState(Vpn::ConnectionState state)
|
|||
}
|
||||
}
|
||||
|
||||
void NotificationHandler::onTranslationsUpdated()
|
||||
{
|
||||
}
|
||||
|
||||
void NotificationHandler::unsecuredNetworkNotification(const QString& networkName) {
|
||||
qDebug() << "Unsecured network notification shown";
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
|
||||
public slots:
|
||||
virtual void setConnectionState(Vpn::ConnectionState state);
|
||||
virtual void onTranslationsUpdated();
|
||||
|
||||
signals:
|
||||
void notificationShown(const QString& title, const QString& message);
|
||||
|
|
|
@ -5,6 +5,7 @@ import QtQuick.Shapes
|
|||
import Qt5Compat.GraphicalEffects
|
||||
|
||||
import ConnectionState 1.0
|
||||
import PageEnum 1.0
|
||||
|
||||
Button {
|
||||
id: root
|
||||
|
@ -137,6 +138,15 @@ Button {
|
|||
}
|
||||
|
||||
onClicked: {
|
||||
if (!ContainersModel.isAnyContainerInstalled()) {
|
||||
PageController.setTriggeredBtConnectButton(true)
|
||||
|
||||
ServersModel.currentlyProcessedIndex = ServersModel.getDefaultServerIndex()
|
||||
PageController.goToPage(PageEnum.PageSetupWizardEasy)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (ConnectionController.isConnectionInProgress) {
|
||||
ConnectionController.closeConnection()
|
||||
} else if (ConnectionController.isConnected) {
|
||||
|
|
|
@ -114,7 +114,7 @@ DrawerType {
|
|||
|
||||
BasicButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 8
|
||||
Layout.topMargin: 24
|
||||
|
||||
defaultColor: "transparent"
|
||||
hoveredColor: Qt.rgba(1, 1, 1, 0.08)
|
||||
|
@ -123,7 +123,7 @@ DrawerType {
|
|||
textColor: "#D7D8DB"
|
||||
borderWidth: 1
|
||||
|
||||
text: qsTr("Show content")
|
||||
text: qsTr("Show connection settings")
|
||||
|
||||
onClicked: {
|
||||
configContentDrawer.visible = true
|
||||
|
|
|
@ -23,6 +23,9 @@ Item {
|
|||
image: backButtonImage
|
||||
imageColor: "#D7D8DB"
|
||||
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
|
||||
onClicked: {
|
||||
if (backButtonFunction && typeof backButtonFunction === "function") {
|
||||
backButtonFunction()
|
||||
|
|
|
@ -90,6 +90,9 @@ Button {
|
|||
anchors.centerIn: parent
|
||||
|
||||
Image {
|
||||
Layout.preferredHeight: 20
|
||||
Layout.preferredWidth: 20
|
||||
|
||||
source: root.imageSource
|
||||
visible: root.imageSource === "" ? false : true
|
||||
|
||||
|
|
|
@ -123,4 +123,11 @@ RadioButton {
|
|||
Layout.bottomMargin: 16
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import QtQuick.Controls
|
|||
Drawer {
|
||||
id: drawer
|
||||
property bool needCloseButton: true
|
||||
property bool isOpened: false
|
||||
|
||||
Connections {
|
||||
target: PageController
|
||||
|
@ -50,51 +49,22 @@ Drawer {
|
|||
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
|
||||
PageController.updateNavigationBarColor(0xFF1C1D21)
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: {
|
||||
if (needCloseButton) {
|
||||
PageController.drawerOpen()
|
||||
}
|
||||
}
|
||||
|
||||
onAboutToHide: {
|
||||
onClosed: {
|
||||
if (needCloseButton) {
|
||||
PageController.drawerClose()
|
||||
}
|
||||
}
|
||||
|
||||
onOpened: {
|
||||
isOpened = true
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
isOpened = false
|
||||
|
||||
var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor()
|
||||
if (initialPageNavigationBarColor !== 0xFF1C1D21) {
|
||||
PageController.updateNavigationBarColor(initialPageNavigationBarColor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onPositionChanged: {
|
||||
if (isOpened && (position <= 0.99 && position >= 0.95)) {
|
||||
mouseArea.canceled()
|
||||
drawer.close()
|
||||
mouseArea.exited()
|
||||
dropArea.exited()
|
||||
}
|
||||
}
|
||||
|
||||
DropArea {
|
||||
id: dropArea
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
|
||||
onPressed: {
|
||||
isOpened = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ Item {
|
|||
property string rootButtonImage: "qrc:/images/controls/chevron-down.svg"
|
||||
property string rootButtonImageColor: "#D7D8DB"
|
||||
property string rootButtonBackgroundColor: "#1C1D21"
|
||||
property string rootButtonBackgroundHoveredColor: "#1C1D21"
|
||||
property string rootButtonBackgroundPressedColor: "#1C1D21"
|
||||
|
||||
property string rootButtonHoveredBorderColor: "#494B50"
|
||||
property string rootButtonDefaultBorderColor: "#2C2D30"
|
||||
|
@ -71,6 +73,10 @@ Item {
|
|||
Behavior on border.color {
|
||||
PropertyAnimation { duration: 200 }
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
PropertyAnimation { duration: 200 }
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
@ -112,6 +118,9 @@ Item {
|
|||
ImageButtonType {
|
||||
Layout.rightMargin: 16
|
||||
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
|
||||
hoverEnabled: false
|
||||
image: rootButtonImage
|
||||
imageColor: rootButtonImageColor
|
||||
|
@ -126,12 +135,20 @@ Item {
|
|||
onEntered: {
|
||||
if (menu.visible === false) {
|
||||
rootButtonBackground.border.color = rootButtonHoveredBorderColor
|
||||
rootButtonBackground.color = rootButtonBackgroundHoveredColor
|
||||
}
|
||||
}
|
||||
|
||||
onExited: {
|
||||
if (menu.visible === false) {
|
||||
rootButtonBackground.border.color = rootButtonDefaultBorderColor
|
||||
rootButtonBackground.color = rootButtonBackgroundColor
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
if (menu.visible === false) {
|
||||
rootButtonBackground.color = pressed ? rootButtonBackgroundPressedColor : entered ? rootButtonHoveredBorderColor : rootButtonDefaultBorderColor
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@ Item {
|
|||
ImageButtonType {
|
||||
id: headerActionButton
|
||||
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
|
||||
image: root.actionButtonImage
|
||||
imageColor: "#D7D8DB"
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@ Item {
|
|||
ImageButtonType {
|
||||
id: headerActionButton
|
||||
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
|
||||
Layout.alignment: Qt.AlignRight
|
||||
|
||||
image: root.actionButtonImage
|
||||
|
|
|
@ -15,8 +15,8 @@ Button {
|
|||
property string imageColor: "#878B91"
|
||||
property string disableImageColor: "#2C2D30"
|
||||
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
property alias backgroundColor: background.color
|
||||
property alias backgroundRadius: background.radius
|
||||
|
||||
hoverEnabled: true
|
||||
|
||||
|
@ -31,16 +31,16 @@ Button {
|
|||
id: background
|
||||
|
||||
anchors.fill: parent
|
||||
radius: 12
|
||||
color: {
|
||||
if (root.enabled) {
|
||||
if(root.pressed) {
|
||||
if (root.pressed) {
|
||||
return pressedColor
|
||||
}
|
||||
return hovered ? hoveredColor : defaultColor
|
||||
}
|
||||
return defaultColor
|
||||
}
|
||||
radius: 12
|
||||
Behavior on color {
|
||||
PropertyAnimation { duration: 200 }
|
||||
}
|
||||
|
|
|
@ -119,6 +119,9 @@ Item {
|
|||
ImageButtonType {
|
||||
id: rightImage
|
||||
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
|
||||
hoverEnabled: false
|
||||
image: rightImageSource
|
||||
imageColor: rightImageColor
|
||||
|
|
|
@ -9,71 +9,99 @@ Rectangle {
|
|||
property alias textArea: textArea
|
||||
property alias textAreaText: textArea.text
|
||||
|
||||
property string borderHoveredColor: "#494B50"
|
||||
property string borderNormalColor: "#2C2D30"
|
||||
property string borderFocusedColor: "#d7d8db"
|
||||
|
||||
height: 148
|
||||
color: "#1C1D21"
|
||||
border.width: 1
|
||||
border.color: "#2C2D30"
|
||||
border.color: getBorderColor(borderNormalColor)
|
||||
radius: 16
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
interactive: false
|
||||
MouseArea {
|
||||
id: parentMouse
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.IBeamCursor
|
||||
onClicked: textArea.forceActiveFocus()
|
||||
hoverEnabled: true
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
contentHeight: textArea.implicitHeight
|
||||
TextArea {
|
||||
id: textArea
|
||||
FlickableType {
|
||||
id: fl
|
||||
interactive: false
|
||||
|
||||
width: parent.width
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
contentHeight: textArea.implicitHeight
|
||||
TextArea {
|
||||
id: textArea
|
||||
|
||||
topPadding: 16
|
||||
leftPadding: 16
|
||||
anchors.topMargin: 16
|
||||
anchors.bottomMargin: 16
|
||||
width: parent.width
|
||||
|
||||
color: "#D7D8DB"
|
||||
selectionColor: "#633303"
|
||||
selectedTextColor: "#D7D8DB"
|
||||
placeholderTextColor: "#878B91"
|
||||
topPadding: 16
|
||||
leftPadding: 16
|
||||
anchors.topMargin: 16
|
||||
anchors.bottomMargin: 16
|
||||
|
||||
font.pixelSize: 16
|
||||
font.weight: Font.Medium
|
||||
font.family: "PT Root UI VF"
|
||||
color: "#D7D8DB"
|
||||
selectionColor: "#633303"
|
||||
selectedTextColor: "#D7D8DB"
|
||||
placeholderTextColor: "#878B91"
|
||||
|
||||
placeholderText: root.placeholderText
|
||||
text: root.text
|
||||
font.pixelSize: 16
|
||||
font.weight: Font.Medium
|
||||
font.family: "PT Root UI VF"
|
||||
|
||||
onCursorVisibleChanged: {
|
||||
if (textArea.cursorVisible) {
|
||||
fl.interactive = true
|
||||
} else {
|
||||
fl.interactive = false
|
||||
placeholderText: root.placeholderText
|
||||
text: root.text
|
||||
|
||||
onCursorVisibleChanged: {
|
||||
if (textArea.cursorVisible) {
|
||||
fl.interactive = true
|
||||
} else {
|
||||
fl.interactive = false
|
||||
}
|
||||
}
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
|
||||
MouseArea {
|
||||
id: textAreaMouse
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
fl.interactive = true
|
||||
contextMenu.open()
|
||||
}
|
||||
}
|
||||
|
||||
onFocusChanged: {
|
||||
root.border.color = getBorderColor(borderNormalColor)
|
||||
}
|
||||
|
||||
ContextMenuType {
|
||||
id: contextMenu
|
||||
textObj: textArea
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
onPressed: {
|
||||
root.border.color = getBorderColor(borderFocusedColor)
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
onClicked: {
|
||||
fl.interactive = true
|
||||
contextMenu.open()
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
root.border.color = getBorderColor(borderNormalColor)
|
||||
}
|
||||
|
||||
ContextMenuType {
|
||||
id: contextMenu
|
||||
textObj: textArea
|
||||
}
|
||||
onEntered: {
|
||||
root.border.color = getBorderColor(borderHoveredColor)
|
||||
}
|
||||
}
|
||||
|
||||
//todo make whole background clickable, with code below we lose ability to select text by mouse
|
||||
// MouseArea {
|
||||
// anchors.fill: parent
|
||||
// cursorShape: Qt.IBeamCursor
|
||||
// onClicked: textArea.forceActiveFocus()
|
||||
// }
|
||||
|
||||
function getBorderColor(noneFocusedColor) {
|
||||
return textArea.focus ? root.borderFocusedColor : noneFocusedColor
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ Item {
|
|||
|
||||
property string backgroundColor: "#1c1d21"
|
||||
property string backgroundDisabledColor: "transparent"
|
||||
property string bgBorderHoveredColor: "#494B50"
|
||||
|
||||
implicitWidth: content.implicitWidth
|
||||
implicitHeight: content.implicitHeight
|
||||
|
@ -45,7 +46,7 @@ Item {
|
|||
Layout.preferredHeight: input.implicitHeight
|
||||
color: root.enabled ? root.backgroundColor : root.backgroundDisabledColor
|
||||
radius: 16
|
||||
border.color: textField.focus ? root.borderFocusedColor : root.borderColor
|
||||
border.color: getBackgroundBorderColor(root.borderColor)
|
||||
border.width: 1
|
||||
|
||||
Behavior on border.color {
|
||||
|
@ -109,12 +110,17 @@ Item {
|
|||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
onClicked: contextMenu.open()
|
||||
enabled: true
|
||||
}
|
||||
|
||||
ContextMenuType {
|
||||
id: contextMenu
|
||||
textObj: textField
|
||||
}
|
||||
|
||||
onFocusChanged: {
|
||||
backgroud.border.color = getBackgroundBorderColor(root.borderColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,11 +162,28 @@ Item {
|
|||
|
||||
MouseArea {
|
||||
anchors.fill: root
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
cursorShape: Qt.IBeamCursor
|
||||
|
||||
hoverEnabled: true
|
||||
|
||||
onPressed: function(mouse) {
|
||||
textField.forceActiveFocus()
|
||||
mouse.accepted = false
|
||||
|
||||
backgroud.border.color = getBackgroundBorderColor(root.borderColor)
|
||||
}
|
||||
|
||||
onEntered: {
|
||||
backgroud.border.color = getBackgroundBorderColor(bgBorderHoveredColor)
|
||||
}
|
||||
|
||||
|
||||
onExited: {
|
||||
backgroud.border.color = getBackgroundBorderColor(root.borderColor)
|
||||
}
|
||||
}
|
||||
|
||||
function getBackgroundBorderColor(noneFocusedColor) {
|
||||
return textField.focus ? root.borderFocusedColor : noneFocusedColor
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ Text {
|
|||
|
||||
color: "#D7D8DB"
|
||||
font.pixelSize: 16
|
||||
font.weight: 500
|
||||
font.weight: 600
|
||||
font.family: "PT Root UI VF"
|
||||
|
||||
wrapMode: Text.WordWrap
|
||||
|
|
|
@ -23,6 +23,9 @@ Popup {
|
|||
image: "qrc:/images/svg/close_black_24dp.svg"
|
||||
imageColor: "#D7D8DB"
|
||||
|
||||
implicitWidth: 40
|
||||
implicitHeight: 40
|
||||
|
||||
onClicked: {
|
||||
PageController.goToDrawerRootPage()
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ PageType {
|
|||
Layout.fillWidth: true
|
||||
Layout.topMargin: 20
|
||||
|
||||
headerText: qsTr("Removing services from ") + name
|
||||
headerText: qsTr("Removing services from %1").arg(name)
|
||||
}
|
||||
|
||||
ProgressBarType {
|
||||
|
|
|
@ -26,11 +26,17 @@ PageType {
|
|||
property string defaultServerHostName: ServersModel.defaultServerHostName
|
||||
property string defaultContainerName: ContainersModel.defaultContainerName
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: buttonContent.state === "expanded"
|
||||
onClicked: {
|
||||
buttonContent.state = "collapsed"
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: buttonBackground.top
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.fill: parent
|
||||
anchors.bottomMargin: buttonContent.collapsedHeight
|
||||
|
||||
ConnectButton {
|
||||
anchors.centerIn: parent
|
||||
|
@ -41,17 +47,66 @@ PageType {
|
|||
target: PageController
|
||||
|
||||
function onRestorePageHomeState(isContainerInstalled) {
|
||||
menu.visible = true
|
||||
buttonContent.state = "expanded"
|
||||
if (isContainerInstalled) {
|
||||
containersDropDown.menuVisible = true
|
||||
}
|
||||
}
|
||||
function onForceCloseDrawer() {
|
||||
buttonContent.state = "collapsed"
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: dragArea
|
||||
|
||||
anchors.fill: buttonBackground
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
|
||||
drag.target: buttonContent
|
||||
drag.axis: Drag.YAxis
|
||||
drag.maximumY: root.height - buttonContent.collapsedHeight
|
||||
drag.minimumY: root.height - root.height * 0.9
|
||||
|
||||
/** If drag area is released at any point other than min or max y, transition to the other state */
|
||||
onReleased: {
|
||||
if (buttonContent.state === "collapsed" && buttonContent.y < dragArea.drag.maximumY) {
|
||||
buttonContent.state = "expanded"
|
||||
return
|
||||
}
|
||||
if (buttonContent.state === "expanded" && buttonContent.y > dragArea.drag.minimumY) {
|
||||
buttonContent.state = "collapsed"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
onEntered: {
|
||||
collapsedButtonChevron.backgroundColor = collapsedButtonChevron.hoveredColor
|
||||
collapsedButtonHeader.opacity = 0.8
|
||||
}
|
||||
onExited: {
|
||||
collapsedButtonChevron.backgroundColor = collapsedButtonChevron.defaultColor
|
||||
collapsedButtonHeader.opacity = 1
|
||||
}
|
||||
onPressedChanged: {
|
||||
collapsedButtonChevron.backgroundColor = pressed ? collapsedButtonChevron.pressedColor : entered ? collapsedButtonChevron.hoveredColor : collapsedButtonChevron.defaultColor
|
||||
collapsedButtonHeader.opacity = 0.7
|
||||
}
|
||||
|
||||
|
||||
onClicked: {
|
||||
if (buttonContent.state === "collapsed") {
|
||||
buttonContent.state = "expanded"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: buttonBackground
|
||||
anchors.fill: buttonContent
|
||||
|
||||
anchors { left: buttonContent.left; right: buttonContent.right; top: buttonContent.top }
|
||||
height: root.height
|
||||
radius: 16
|
||||
color: root.defaultColor
|
||||
border.color: root.borderColor
|
||||
|
@ -69,19 +124,99 @@ PageType {
|
|||
|
||||
ColumnLayout {
|
||||
id: buttonContent
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
/** Initial height of button content */
|
||||
property int collapsedHeight: 0
|
||||
/** True when expanded objects should be visible */
|
||||
property bool expandedVisibility: buttonContent.state === "expanded" || (buttonContent.state === "collapsed" && dragArea.drag.active === true)
|
||||
/** True when collapsed objects should be visible */
|
||||
property bool collapsedVisibility: buttonContent.state === "collapsed" && dragArea.drag.active === false
|
||||
|
||||
Drag.active: dragArea.drag.active
|
||||
anchors.right: root.right
|
||||
anchors.left: root.left
|
||||
y: root.height - buttonContent.height
|
||||
|
||||
Component.onCompleted: {
|
||||
buttonContent.state = "collapsed"
|
||||
}
|
||||
|
||||
/** Set once based on first implicit height change once all children are layed out */
|
||||
onImplicitHeightChanged: {
|
||||
if (buttonContent.state === "collapsed" && collapsedHeight == 0) {
|
||||
collapsedHeight = implicitHeight
|
||||
}
|
||||
}
|
||||
|
||||
onStateChanged: {
|
||||
if (buttonContent.state === "collapsed") {
|
||||
var initialPageNavigationBarColor = PageController.getInitialPageNavigationBarColor()
|
||||
if (initialPageNavigationBarColor !== 0xFF1C1D21) {
|
||||
PageController.updateNavigationBarColor(initialPageNavigationBarColor)
|
||||
}
|
||||
PageController.drawerClose()
|
||||
return
|
||||
}
|
||||
if (buttonContent.state === "expanded") {
|
||||
if (PageController.getInitialPageNavigationBarColor() !== 0xFF1C1D21) {
|
||||
PageController.updateNavigationBarColor(0xFF1C1D21)
|
||||
}
|
||||
PageController.drawerOpen()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/** Two states of buttonContent, great place to add any future animations for the drawer */
|
||||
states: [
|
||||
State {
|
||||
name: "collapsed"
|
||||
PropertyChanges {
|
||||
target: buttonContent
|
||||
y: root.height - collapsedHeight
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "expanded"
|
||||
PropertyChanges {
|
||||
target: buttonContent
|
||||
y: dragArea.drag.minimumY
|
||||
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
from: "collapsed"
|
||||
to: "expanded"
|
||||
PropertyAnimation {
|
||||
target: buttonContent
|
||||
properties: "y"
|
||||
duration: 200
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
from: "expanded"
|
||||
to: "collapsed"
|
||||
PropertyAnimation {
|
||||
target: buttonContent
|
||||
properties: "y"
|
||||
duration: 200
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
RowLayout {
|
||||
Layout.topMargin: 24
|
||||
Layout.leftMargin: 24
|
||||
Layout.rightMargin: 24
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
visible: buttonContent.collapsedVisibility
|
||||
|
||||
spacing: 0
|
||||
|
||||
Header1TextType {
|
||||
id: collapsedButtonHeader
|
||||
Layout.maximumWidth: buttonContent.width - 48 - 18 - 12 // todo
|
||||
|
||||
maximumLineCount: 2
|
||||
|
@ -89,21 +224,40 @@ PageType {
|
|||
|
||||
text: root.defaultServerName
|
||||
horizontalAlignment: Qt.AlignHCenter
|
||||
|
||||
Behavior on opacity {
|
||||
PropertyAnimation { duration: 200 }
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
Layout.preferredWidth: 18
|
||||
Layout.preferredHeight: 18
|
||||
ImageButtonType {
|
||||
id: collapsedButtonChevron
|
||||
|
||||
Layout.leftMargin: 12
|
||||
Layout.leftMargin: 8
|
||||
|
||||
source: "qrc:/images/controls/chevron-down.svg"
|
||||
hoverEnabled: false
|
||||
image: "qrc:/images/controls/chevron-down.svg"
|
||||
imageColor: "#d7d8db"
|
||||
|
||||
icon.width: 18
|
||||
icon.height: 18
|
||||
backgroundRadius: 16
|
||||
horizontalPadding: 4
|
||||
topPadding: 4
|
||||
bottomPadding: 3
|
||||
|
||||
onClicked: {
|
||||
if (buttonContent.state === "collapsed") {
|
||||
buttonContent.state = "expanded"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LabelTextType {
|
||||
Layout.bottomMargin: 44
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
visible: buttonContent.collapsedVisibility
|
||||
|
||||
text: {
|
||||
var description = ""
|
||||
|
@ -122,38 +276,13 @@ PageType {
|
|||
return description
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: buttonBackground
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
menu.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
DrawerType {
|
||||
id: menu
|
||||
|
||||
interactive: {
|
||||
if (stackView && stackView.currentItem) {
|
||||
return (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) ? true : false
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
dragMargin: buttonBackground.height + 56 // page start tabBar height
|
||||
|
||||
width: parent.width
|
||||
height: parent.height * 0.9
|
||||
|
||||
ColumnLayout {
|
||||
id: serversMenuHeader
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
|
||||
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||
Layout.fillWidth: true
|
||||
visible: buttonContent.expandedVisibility
|
||||
|
||||
Header1TextType {
|
||||
Layout.fillWidth: true
|
||||
|
@ -183,8 +312,10 @@ PageType {
|
|||
|
||||
rootButtonImageColor: "#0E0E11"
|
||||
rootButtonBackgroundColor: "#D7D8DB"
|
||||
rootButtonBackgroundHoveredColor: Qt.rgba(215, 216, 219, 0.8)
|
||||
rootButtonBackgroundPressedColor: Qt.rgba(215, 216, 219, 0.65)
|
||||
rootButtonHoveredBorderColor: "transparent"
|
||||
rootButtonPressedBorderColor: "transparent"
|
||||
rootButtonDefaultBorderColor: "transparent"
|
||||
rootButtonTextTopMargin: 8
|
||||
rootButtonTextBottomMargin: 8
|
||||
|
||||
|
@ -232,13 +363,14 @@ PageType {
|
|||
Layout.topMargin: 48
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
visible: buttonContent.expandedVisibility
|
||||
|
||||
actionButtonImage: "qrc:/images/controls/plus.svg"
|
||||
|
||||
headerText: qsTr("Servers")
|
||||
|
||||
actionButtonFunction: function() {
|
||||
menu.visible = false
|
||||
buttonContent.state = "collapsed"
|
||||
connectionTypeSelection.visible = true
|
||||
}
|
||||
}
|
||||
|
@ -248,10 +380,23 @@ PageType {
|
|||
}
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
anchors.top: serversMenuHeader.bottom
|
||||
anchors.topMargin: 16
|
||||
Flickable {
|
||||
id: serversContainer
|
||||
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 16
|
||||
contentHeight: col.implicitHeight
|
||||
implicitHeight: root.height - (root.height * 0.1) - serversMenuHeader.implicitHeight - 52 //todo 52 is tabbar height
|
||||
visible: buttonContent.expandedVisibility
|
||||
clip: true
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
id: scrollBar
|
||||
policy: serversContainer.height >= serversContainer.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn
|
||||
}
|
||||
|
||||
Keys.onUpPressed: scrollBar.decrease()
|
||||
Keys.onDownPressed: scrollBar.increase()
|
||||
|
||||
Column {
|
||||
id: col
|
||||
|
@ -346,13 +491,15 @@ PageType {
|
|||
onClicked: function() {
|
||||
ServersModel.currentlyProcessedIndex = index
|
||||
PageController.goToPage(PageEnum.PageSettingsServerInfo)
|
||||
menu.visible = false
|
||||
buttonContent.state = "collapsed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 0
|
||||
Layout.rightMargin: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ PageType {
|
|||
textColor: "#EB5757"
|
||||
|
||||
clickedFunction: function() {
|
||||
questionDrawer.headerText = qsTr("Remove ") + ContainersModel.getCurrentlyProcessedContainerName() + qsTr(" from server?")
|
||||
questionDrawer.headerText = qsTr("Remove %1 from server?").arg(ContainersModel.getCurrentlyProcessedContainerName())
|
||||
questionDrawer.descriptionText = qsTr("All users with whom you shared a connection will no longer be able to connect to it")
|
||||
questionDrawer.yesButtonText = qsTr("Continue")
|
||||
questionDrawer.noButtonText = qsTr("Cancel")
|
||||
|
|
|
@ -63,7 +63,7 @@ PageType {
|
|||
textColor: "#EB5757"
|
||||
|
||||
clickedFunction: function() {
|
||||
questionDrawer.headerText = qsTr("Remove ") + ContainersModel.getCurrentlyProcessedContainerName() + qsTr(" from server?")
|
||||
questionDrawer.headerText = qsTr("Remove %1 from server?").arg(ContainersModel.getCurrentlyProcessedContainerName())
|
||||
questionDrawer.yesButtonText = qsTr("Continue")
|
||||
questionDrawer.noButtonText = qsTr("Cancel")
|
||||
|
||||
|
|
|
@ -43,6 +43,26 @@ PageType {
|
|||
headerText: qsTr("Application")
|
||||
}
|
||||
|
||||
SwitcherType {
|
||||
visible: GC.isMobile()
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: 16
|
||||
|
||||
text: qsTr("Allow application screenshots")
|
||||
|
||||
checked: SettingsController.isScreenshotsEnabled()
|
||||
onCheckedChanged: {
|
||||
if (checked !== SettingsController.isScreenshotsEnabled()) {
|
||||
SettingsController.toggleScreenshotsEnabled(checked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {
|
||||
visible: GC.isMobile()
|
||||
}
|
||||
|
||||
SwitcherType {
|
||||
visible: !GC.isMobile()
|
||||
|
||||
|
|
|
@ -66,7 +66,8 @@ PageType {
|
|||
Layout.fillWidth: true
|
||||
Layout.margins: 16
|
||||
|
||||
text: qsTr("Use AmneziaDNS if installed on the server")
|
||||
text: qsTr("Use AmneziaDNS")
|
||||
descriptionText: qsTr("If AmneziaDNS is installed on the server")
|
||||
|
||||
checked: SettingsController.isAmneziaDnsEnabled()
|
||||
onCheckedChanged: {
|
||||
|
|
|
@ -53,7 +53,7 @@ PageType {
|
|||
id: primaryDns
|
||||
|
||||
Layout.fillWidth: true
|
||||
headerText: "Primary DNS"
|
||||
headerText: qsTr("Primary DNS")
|
||||
|
||||
textFieldText: SettingsController.primaryDns
|
||||
textField.validator: RegularExpressionValidator {
|
||||
|
@ -65,7 +65,7 @@ PageType {
|
|||
id: secondaryDns
|
||||
|
||||
Layout.fillWidth: true
|
||||
headerText: "Secondary DNS"
|
||||
headerText: qsTr("Secondary DNS")
|
||||
|
||||
textFieldText: SettingsController.secondaryDns
|
||||
textField.validator: RegularExpressionValidator {
|
||||
|
|
|
@ -105,7 +105,7 @@ PageType {
|
|||
if (GC.isMobile()) {
|
||||
fileName = "AmneziaVPN.log"
|
||||
} else {
|
||||
fileName = SystemController.getFileName(qsTr("Save logs"),
|
||||
fileName = SystemController.getFileName(qsTr("Save"),
|
||||
qsTr("Logs files (*.log)"),
|
||||
StandardPaths.standardLocations(StandardPaths.DocumentsLocation) + "/AmneziaVPN",
|
||||
true,
|
||||
|
|
|
@ -113,7 +113,7 @@ PageType {
|
|||
textColor: "#EB5757"
|
||||
|
||||
clickedFunction: function() {
|
||||
questionDrawer.headerText = qsTr("Remove ") + ContainersModel.getCurrentlyProcessedContainerName() + qsTr(" from server?")
|
||||
questionDrawer.headerText = qsTr("Remove %1 from server?").arg(ContainersModel.getCurrentlyProcessedContainerName())
|
||||
questionDrawer.descriptionText = qsTr("All users with whom you shared a connection will no longer be able to connect to it")
|
||||
questionDrawer.yesButtonText = qsTr("Continue")
|
||||
questionDrawer.noButtonText = qsTr("Cancel")
|
||||
|
|
|
@ -62,6 +62,7 @@ PageType {
|
|||
id: header
|
||||
|
||||
implicitWidth: parent.width
|
||||
headerTextMaximumLineCount: 10
|
||||
|
||||
headerText: qsTr("What is the level of internet control in your region?")
|
||||
}
|
||||
|
@ -145,14 +146,13 @@ PageType {
|
|||
|
||||
Item {
|
||||
implicitWidth: 1
|
||||
implicitHeight: 1
|
||||
implicitHeight: 54
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
id: continueButton
|
||||
|
||||
implicitWidth: parent.width
|
||||
anchors.topMargin: 24
|
||||
|
||||
text: qsTr("Continue")
|
||||
|
||||
|
@ -183,6 +183,17 @@ PageType {
|
|||
textColor: "#D7D8DB"
|
||||
borderWidth: 1
|
||||
|
||||
visible: {
|
||||
if (PageController.isTriggeredByConnectButton()) {
|
||||
PageController.setTriggeredBtConnectButton(false)
|
||||
|
||||
return ContainersModel.isAnyContainerInstalled()
|
||||
}
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
text: qsTr("Set up later")
|
||||
|
||||
onClicked: function() {
|
||||
|
|
|
@ -72,7 +72,7 @@ PageType {
|
|||
|
||||
Layout.fillWidth: true
|
||||
|
||||
headerText: qsTr("Installing ") + name
|
||||
headerText: qsTr("Installing %1").arg(name)
|
||||
descriptionText: description
|
||||
}
|
||||
|
||||
|
|
|
@ -219,13 +219,14 @@ PageType {
|
|||
|
||||
if (accessTypeSelector.currentIndex !== 0) {
|
||||
shareConnectionDrawer.headerText = qsTr("Accessing ") + serverSelector.text
|
||||
shareConnectionDrawer.configContentHeaderText = qsTr("File with connection settings to ") + serverSelector.text
|
||||
shareConnectionDrawer.configContentHeaderText = qsTr("File with accessing settings to ") + serverSelector.text
|
||||
}
|
||||
serverSelector.menuVisible = false
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
handler()
|
||||
serverSelector.severSelectorIndexChanged()
|
||||
}
|
||||
|
||||
function handler() {
|
||||
|
@ -240,12 +241,14 @@ PageType {
|
|||
DropDownType {
|
||||
id: protocolSelector
|
||||
|
||||
visible: accessTypeSelector.currentIndex === 0
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 16
|
||||
|
||||
drawerHeight: 0.5
|
||||
|
||||
descriptionText: qsTr("Protocols")
|
||||
descriptionText: qsTr("Protocol")
|
||||
headerText: qsTr("Protocol")
|
||||
|
||||
listView: ListViewWithRadioButtonType {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
|
||||
NotificationHandler(parent),
|
||||
m_systemTrayIcon(parent)
|
||||
|
@ -26,8 +25,7 @@ SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
|
|||
m_systemTrayIcon.show();
|
||||
connect(&m_systemTrayIcon, &QSystemTrayIcon::activated, this, &SystemTrayNotificationHandler::onTrayActivated);
|
||||
|
||||
|
||||
m_menu.addAction(QIcon(":/images/tray/application.png"), tr("Show") + " " + APPLICATION_NAME, this, [this](){
|
||||
m_trayActionShow = m_menu.addAction(QIcon(":/images/tray/application.png"), tr("Show") + " " + APPLICATION_NAME, this, [this](){
|
||||
emit raiseRequested();
|
||||
});
|
||||
m_menu.addSeparator();
|
||||
|
@ -36,11 +34,11 @@ SystemTrayNotificationHandler::SystemTrayNotificationHandler(QObject* parent) :
|
|||
|
||||
m_menu.addSeparator();
|
||||
|
||||
m_menu.addAction(QIcon(":/images/tray/link.png"), tr("Visit Website"), [&](){
|
||||
m_trayActionVisitWebSite = m_menu.addAction(QIcon(":/images/tray/link.png"), tr("Visit Website"), [&](){
|
||||
QDesktopServices::openUrl(QUrl("https://amnezia.org"));
|
||||
});
|
||||
|
||||
m_menu.addAction(QIcon(":/images/tray/cancel.png"), tr("Quit") + " " + APPLICATION_NAME, this, [&](){
|
||||
m_trayActionQuit = m_menu.addAction(QIcon(":/images/tray/cancel.png"), tr("Quit") + " " + APPLICATION_NAME, this, [&](){
|
||||
qApp->quit();
|
||||
});
|
||||
|
||||
|
@ -57,6 +55,15 @@ void SystemTrayNotificationHandler::setConnectionState(Vpn::ConnectionState stat
|
|||
NotificationHandler::setConnectionState(state);
|
||||
}
|
||||
|
||||
void SystemTrayNotificationHandler::onTranslationsUpdated()
|
||||
{
|
||||
m_trayActionShow->setText(tr("Show") + " " + APPLICATION_NAME);
|
||||
m_trayActionConnect->setText(tr("Connect"));
|
||||
m_trayActionDisconnect->setText(tr("Disconnect"));
|
||||
m_trayActionVisitWebSite->setText(tr("Visit Website"));
|
||||
m_trayActionQuit->setText(tr("Quit")+ " " + APPLICATION_NAME);
|
||||
}
|
||||
|
||||
void SystemTrayNotificationHandler::setTrayIcon(const QString &iconPath)
|
||||
{
|
||||
QIcon trayIconMask(QPixmap(iconPath).scaled(128,128));
|
||||
|
|
|
@ -19,6 +19,8 @@ public:
|
|||
|
||||
void setConnectionState(Vpn::ConnectionState state) override;
|
||||
|
||||
void onTranslationsUpdated() override;
|
||||
|
||||
protected:
|
||||
virtual void notify(Message type, const QString& title,
|
||||
const QString& message, int timerMsec) override;
|
||||
|
@ -35,9 +37,11 @@ private:
|
|||
QMenu m_menu;
|
||||
QSystemTrayIcon m_systemTrayIcon;
|
||||
|
||||
QAction* m_trayActionShow = nullptr;
|
||||
QAction* m_trayActionConnect = nullptr;
|
||||
QAction* m_trayActionDisconnect = nullptr;
|
||||
QAction* m_preferencesAction = nullptr;
|
||||
QAction* m_trayActionVisitWebSite = nullptr;
|
||||
QAction* m_trayActionQuit = nullptr;
|
||||
QAction* m_statusLabel = nullptr;
|
||||
QAction* m_separator = nullptr;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue