diff --git a/README.md b/README.md new file mode 100644 index 00000000..d3e925b9 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Amnezia + diff --git a/client/AmniziaVPN.pro b/client/AmniziaVPN.pro new file mode 100644 index 00000000..b2acfea6 --- /dev/null +++ b/client/AmniziaVPN.pro @@ -0,0 +1,76 @@ +QT += widgets core gui network xml + +TARGET = AmneziaVPN +TEMPLATE = app +#CONFIG += console + +DEFINES += QT_DEPRECATED_WARNINGS + +HEADERS += \ + core/router.h \ + debug.h \ + defines.h \ + runguard.h \ + ui/Controls/SlidingStackedWidget.h \ + ui/mainwindow.h \ + +SOURCES += \ + core/router.cpp \ + debug.cpp \ + main.cpp \ + runguard.cpp \ + ui/Controls/SlidingStackedWidget.cpp \ + ui/mainwindow.cpp \ + + +FORMS += ui/mainwindow.ui + +RESOURCES += \ + resources.qrc + +TRANSLATIONS = \ + translations/amneziavpn.en.ts \ + translations/amneziavpn.ru.ts + +win32 { + +OTHER_FILES += platform_win/vpnclient.rc +RC_FILE = platform_win/vpnclient.rc + +HEADERS += +SOURCES += + +#CONFIG -= embed_manifest_exe +#DEFINES += _CRT_SECURE_NO_WARNINGS VPNCLIENT_TAPSIGNED +#QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\" + +VERSION = 1.1.1.1 +QMAKE_TARGET_COMPANY = "AmneziaVPN" +QMAKE_TARGET_PRODUCT = "AmneziaVPN" + +#CONFIG -= embed_manifest_exe + +LIBS += \ + -luser32 \ + -lrasapi32 \ + -lshlwapi \ + -liphlpapi \ + -lws2_32 \ + -liphlpapi \ + -lgdi32 + +#LIBS += -L$$PWD/../../../../../../../OpenSSL-Win32/lib/ -llibcrypto + +#MT_PATH = \"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/bin/x64/mt.exe\" +#WIN_PWD = $$replace(PWD, /, \\) +#OUT_PWD_WIN = $$replace(OUT_PWD, /, \\) + +#!win32-g++: QMAKE_POST_LINK = "$$MT_PATH -manifest $$quote($$WIN_PWD\\platform_win\\$$basename(TARGET).exe.manifest) -outputresource:$$quote($$OUT_PWD_WIN\\$(DESTDIR_TARGET);1)" +# else: QMAKE_POST_LINK = "$$MT_PATH -manifest $$PWD/platform_win/$$basename(TARGET).exe.manifest -outputresource:$$OUT_PWD/$(DESTDIR_TARGET)" + +} + + +macx { +ICON = $$PWD/images/app.icns +} diff --git a/client/amnizia-client.pro b/client/amnizia-client.pro deleted file mode 100644 index e19c530d..00000000 --- a/client/amnizia-client.pro +++ /dev/null @@ -1,104 +0,0 @@ -QT += widgets core gui network xml - -TARGET = amnezia-client -TEMPLATE = app - -DEFINES += QT_DEPRECATED_WARNINGS - - -win32 { - -#win32-g++ { -# QMAKE_CXXFLAGS += -Werror -#} -#win32-msvc*{ -# QMAKE_CXXFLAGS += /WX -#} - -FORMS += ui/mainwindow.ui - -RESOURCES += \ - res.qrc - -OTHER_FILES += platform_win/vpnclient.rc -RC_FILE = platform_win/vpnclient.rc - -HEADERS += publib/winhelp.h - -SOURCES += publib/winhelp.cpp - -CONFIG -= embed_manifest_exe -DEFINES += _CRT_SECURE_NO_WARNINGS VPNCLIENT_TAPSIGNED -#QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\" - -VERSION = 1.1.1.1 -QMAKE_TARGET_COMPANY = "AmneziaVPN" -QMAKE_TARGET_PRODUCT = "AmneziaVPN" - -CONFIG -= embed_manifest_exe - -LIBS += -luser32 \ - -lrasapi32 \ - -lshlwapi \ - -liphlpapi \ - -lws2_32 \ - -liphlpapi \ - -lgdi32 - - -MT_PATH = \"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/bin/x64/mt.exe\" -WIN_PWD = $$replace(PWD, /, \\) -OUT_PWD_WIN = $$replace(OUT_PWD, /, \\) - -!win32-g++: QMAKE_POST_LINK = "$$MT_PATH -manifest $$quote($$WIN_PWD\\platform_win\\$$basename(TARGET).exe.manifest) -outputresource:$$quote($$OUT_PWD_WIN\\$(DESTDIR_TARGET);1)" - else: QMAKE_POST_LINK = "$$MT_PATH -manifest $$PWD/platform_win/$$basename(TARGET).exe.manifest -outputresource:$$OUT_PWD/$(DESTDIR_TARGET)" -} - -macx { - -OBJECTIVE_HEADERS += -OBJECTIVE_SOURCES += publib/macos_functions.mm - -HEADERS += \ - -SOURCES += \ - -QMAKE_OBJECTIVE_CFLAGS += -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks - -FORMS += ui/mainwindow_mac.ui - -LIBS += -framework CoreServices -framework Foundation -framework AppKit - -RESOURCES += \ - res_mac.qrc - -ICON = images/main.icns -} - -SOURCES += main.cpp\ - core/router.cpp \ - publib/debug.cpp \ - publib/runguard.cpp \ - publib/winhelp.cpp \ - ui/Controls/SlidingStackedWidget.cpp \ - ui/mainwindow.cpp \ - ui/customshadoweffect.cpp - -HEADERS += ui/mainwindow.h \ - core/router.h \ - publib/debug.h \ - publib/runguard.h \ - publib/winhelp.h \ - ui/customshadoweffect.h \ - ui/Controls/SlidingStackedWidget.h - -FORMS += ui/mainwindow.ui - - -TRANSLATIONS = translations/amneziavpn.en.ts \ - translations/amneziavpn.ru.ts - - - -win32: LIBS += -L$$PWD/../../../../../../../OpenSSL-Win32/lib/ -llibcrypto - diff --git a/client/core/router.cpp b/client/core/router.cpp index 247138cd..0c230879 100644 --- a/client/core/router.cpp +++ b/client/core/router.cpp @@ -3,7 +3,6 @@ #include - Router &Router::Instance() { static Router s; @@ -12,6 +11,8 @@ Router &Router::Instance() bool Router::routeAdd(const QString &ip, const QString &gw, QString mask) { +#ifdef Q_OS_WIN + qDebug().noquote() << QString("ROUTE ADD: IP:%1 %2 GW %3") .arg(ip) .arg(mask) @@ -107,6 +108,8 @@ bool Router::routeAdd(const QString &ip, const QString &gw, QString mask) free(pIpForwardTable); return (dwStatus == NO_ERROR); + +#endif } int Router::routeAddList(const QString &gw, const QStringList &ips) @@ -118,6 +121,8 @@ int Router::routeAddList(const QString &gw, const QStringList &ips) qDebug().noquote() << QString("ROUTE ADD List: IPs:\n%1") .arg(ips.join("\n")); +#ifdef Q_OS_WIN + PMIB_IPFORWARDTABLE pIpForwardTable = NULL; DWORD dwSize = 0; BOOL bOrder = FALSE; @@ -224,10 +229,14 @@ int Router::routeAddList(const QString &gw, const QStringList &ips) qDebug() << "Router::routeAddList finished, success: " << success_count << "/" << ips.size(); return success_count; + +#endif } bool Router::clearSavedRoutes() { +#ifdef Q_OS_WIN + if (ipForwardRows.isEmpty()) return true; qDebug() << "forward rows size:" << ipForwardRows.size(); @@ -274,6 +283,8 @@ bool Router::clearSavedRoutes() ipForwardRows.clear(); return true; + +#endif } bool Router::routeDelete(const QString &ip) diff --git a/client/core/router.h b/client/core/router.h index 155aa43a..655bf90b 100644 --- a/client/core/router.h +++ b/client/core/router.h @@ -52,7 +52,9 @@ private: Router(Router const &) = delete; Router& operator= (Router const&) = delete; +#ifdef Q_OS_WIN QList ipForwardRows; +#endif }; #endif // ROUTER_H diff --git a/client/publib/debug.cpp b/client/debug.cpp similarity index 96% rename from client/publib/debug.cpp rename to client/debug.cpp index 70019188..f2b83178 100644 --- a/client/publib/debug.cpp +++ b/client/debug.cpp @@ -95,10 +95,6 @@ bool Debug::init(QDir& appDir) #endif #endif -#ifndef Q_OS_WIN - if (!fixOvpnLogPermissions()) - qWarning() << "Debug: permissions for ovpn.log were not fixed"; -#endif return true; } diff --git a/client/publib/debug.h b/client/debug.h similarity index 100% rename from client/publib/debug.h rename to client/debug.h diff --git a/client/defines.h b/client/defines.h new file mode 100644 index 00000000..aa1d863b --- /dev/null +++ b/client/defines.h @@ -0,0 +1,7 @@ +#ifndef DEFINES_H +#define DEFINES_H + +#define APPLICATION_NAME "AmneziaVPN" +#define ORGANIZATION_NAME "AmneziaVPN.ORG" + +#endif // DEFINES_H diff --git a/client/images/app.icns b/client/images/app.icns new file mode 100644 index 00000000..17d67ff2 Binary files /dev/null and b/client/images/app.icns differ diff --git a/client/images/main.ico b/client/images/app.ico similarity index 100% rename from client/images/main.ico rename to client/images/app.ico diff --git a/client/main.cpp b/client/main.cpp index 2320b0b2..68676ec3 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -2,28 +2,19 @@ #include #include #include -#include #include -#include -#include "publib/runguard.h" -#include "publib/debug.h" +#include "debug.h" +#include "defines.h" +#include "runguard.h" #include "ui/mainwindow.h" -#ifdef Q_OS_WIN -#include -#endif - -#define ApplicationName "AmneziaVPN" - int main(int argc, char *argv[]) { - Q_INIT_RESOURCE(res); - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); - RunGuard::instance(ApplicationName).activate(); + RunGuard::instance(APPLICATION_NAME).activate(); QApplication app(argc, argv); @@ -44,12 +35,11 @@ int main(int argc, char *argv[]) QFontDatabase::addApplicationFont(":/fonts/Lato-Thin.ttf"); QFontDatabase::addApplicationFont(":/fonts/Lato-ThinItalic.ttf"); - { QTranslator *translator = new QTranslator; QLocale ru(QLocale("ru_RU")); QLocale::setDefault(ru); - if (translator->load(QLocale(), "amnezia-client", ".", QLatin1String(":/translations"))) { + if (translator->load(QLocale(), "amneziavpn", ".", QLatin1String(":/translations"))) { bool ok = qApp->installTranslator(translator); qDebug().noquote() << "Main: Installing translator for locale" << ru.name() << ok; } @@ -58,38 +48,23 @@ int main(int argc, char *argv[]) } } - - app.setOrganizationName("AmneziaVPN"); - app.setOrganizationDomain("AmneziaVPN.ORG"); - app.setApplicationName(ApplicationName); - app.setApplicationDisplayName(ApplicationName); + app.setApplicationName(APPLICATION_NAME); + app.setOrganizationName(ORGANIZATION_NAME); + app.setApplicationDisplayName(APPLICATION_NAME); app.setApplicationVersion("1.0.0.0"); //app.setQuitOnLastWindowClosed(false); QCommandLineParser parser; - parser.setApplicationDescription("AmneziaVPN"); + parser.setApplicationDescription(APPLICATION_NAME); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption debugToConsoleOption("d", QCoreApplication::translate("main", "Output to console instead log file")); parser.addOption(debugToConsoleOption); - -#ifdef Q_OS_MAC - QCommandLineOption forceUseBrightIconsOption("b", QCoreApplication::translate("main", "Force use bright icons")); - parser.addOption(forceUseBrightIconsOption); -#endif - - // Process the actual command line arguments given by the user - parser.process(app); + parser.process(app); // Process the actual command line arguments given by the user bool debugToConsole = parser.isSet(debugToConsoleOption); - bool forceUseBrightIcons = false; - -#ifdef Q_OS_MAC - forceUseBrightIcons = parser.isSet(forceUseBrightIconsOption); -#endif - qDebug() << "Set output to console: " << debugToConsole; if (!debugToConsole) { @@ -102,7 +77,7 @@ int main(int argc, char *argv[]) f.setStyleStrategy(QFont::PreferAntialias); app.setFont(f); - MainWindow mainWindow(forceUseBrightIcons); + MainWindow mainWindow; mainWindow.show(); return app.exec(); diff --git a/client/platform_win/vpnclient.rc b/client/platform_win/vpnclient.rc index 8ac789df..7b0155b0 100644 --- a/client/platform_win/vpnclient.rc +++ b/client/platform_win/vpnclient.rc @@ -1,7 +1,7 @@ #include LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -IDI_ICON1 ICON "../images/main.ico" +IDI_ICON1 ICON "../images/app.ico" #define VER_FILEVERSION 1,1,1,1 #define VER_FILEVERSION_STR "1.1.1.1\0" diff --git a/client/publib/macos_functions.mm b/client/publib/macos_functions.mm deleted file mode 100644 index 9be8668f..00000000 --- a/client/publib/macos_functions.mm +++ /dev/null @@ -1,37 +0,0 @@ -#include "macos_functions.h" -#include -#import - -MacOSFunctions &MacOSFunctions::instance() -{ - static MacOSFunctions s; - return s; -} - -MacOSFunctions::MacOSFunctions() -{ - registerThemeNotification(); -} - -bool MacOSFunctions::isMenuBarUseDarkTheme() const -{ - NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain]; - id style = [dict objectForKey:@"AppleInterfaceStyle"]; - BOOL darkModeOn = ( style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"] ); - - return darkModeOn; -} - - -void MacOSFunctions::registerThemeNotification() -{ - // [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(darkModeChanged:) name:@"AppleInterfaceThemeChangedNotification" object:nil]; -} - - -void darkModeChanged(NSNotification*notif) -{ - Q_UNUSED(notif); - qDebug() << "Dark mode changed" << MacOSFunctions::instance().isMenuBarUseDarkTheme(); -} - diff --git a/client/publib/winhelp.cpp b/client/publib/winhelp.cpp deleted file mode 100644 index 4e6f8d2b..00000000 --- a/client/publib/winhelp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include "winhelp.h" - -#include -#include -#include -#include -#include -#include - - -#define REG_AUTORUN_PATH "Software\\Microsoft\\Windows\\CurrentVersion\\Run" - -int winhelpGetRegistry(const char *name, const char *reg, char *value) -{ - unsigned long nType = REG_SZ, nData = MAX_PATH; - if(ERROR_SUCCESS != SHGetValueA(HKEY_CURRENT_USER, reg, - name, &nType, value, &nData)) - return -1; - return 1; -} - -int winhelpSetRegistry(const char *name, const char *reg, const char *value) -{ - if(ERROR_SUCCESS != SHSetValueA(HKEY_CURRENT_USER, reg, - name, REG_SZ, value, (DWORD)strlen(value))) - return -1; - return 1; -} - -int winhelpLaunchStartupRegister(const char *name, int enable, const char *p) -{ - char path[MAX_PATH] = {0}; - if(p && strlen(p) == 0) - p = NULL; - if(p) { - if(enable) - strcpy(path, "\""); - else - strcpy(path, ";\""); - GetModuleFileNameA(NULL, path + strlen(path), MAX_PATH); - strcat(path, "\" "); - strcat(path, p); - } else { - if(enable) - strcpy(path, ""); - else - strcpy(path, ";"); - GetModuleFileNameA(NULL, path + strlen(path), MAX_PATH); - } - if(winhelpSetRegistry(name, REG_AUTORUN_PATH, path) < 0) - return -1; - return 1; -} - -/* use the task scheduler, we do not need to care about UAC when start up */ -int winhelpLaunchStartupTaskScheduler(const char *name, int enable, const char *p) -{ - char cmd[MAX_PATH * 10] = {0}; - char path[MAX_PATH] = {0}; - UINT i = 0; - GetModuleFileNameA(NULL, path, MAX_PATH); - if (QString(path).contains("build-vpn-")) { - qDebug() << "winhelpLaunchStartupTaskScheduler : skipping auto launch for build dir"; - return 0; - } - - if(enable) { - if(p == NULL) - p = ""; - sprintf(cmd, "schtasks /create /sc onlogon /tr \"\\\"%s\\\" %s\" " - "/tn \"%s\" /f /rl highest", path, p, name); - - } else { - sprintf(cmd, "schtasks /delete /tn \"%s\" /f", name); - } - qDebug().noquote() << "winhelpLaunchStartupTaskScheduler cmd:" << cmd; - i = WinExec(cmd, SW_HIDE); - return 1; -} - -int winhelpLaunchStartup(const char *name, int enable, const char *p) -{ - OSVERSIONINFOA info = {0}; - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - if(GetVersionExA(&info) < 0) - return -2; - if(info.dwMajorVersion >= 6) - return winhelpLaunchStartupTaskScheduler(name, enable, p); - else - return winhelpLaunchStartupRegister(name, enable, p); -} - -int str2int(const char *s) -{ - int r = 0; - while(*s && *(s + 1) && *(s + 2) && *(s + 3)) { - r += ((const int *)s)[0]; - s += 4; - } - return r; -} - -int winhelpOneProcess() -{ - char path[MAX_PATH] = {0}; - int i = 0, size = 0, cur = 0; - GetModuleFileNameA(NULL, path, MAX_PATH); - size = strlen(path); - for(i = size; i >= 0 && path[i] != '\\' ; i--); - cur = i + 1; - while(path[i] != '.' && path[i])i++; - path[i] = '\0'; - sprintf(path, "ONE_%s", path + cur); - CreateEventA(NULL, FALSE, FALSE, path); - if(GetLastError()) - return 0; - return 1; -} - -int winhelpSystemBits() -{ - typedef BOOL (WINAPI *LPFN_ISWOW64)(HANDLE, PBOOL); - int b64 = FALSE; - LPFN_ISWOW64 fnIsWow64 = (LPFN_ISWOW64)GetProcAddress( - GetModuleHandleA("kernel32"), "IsWow64Process"); - if(NULL != fnIsWow64) { - if(!fnIsWow64(GetCurrentProcess(),&b64)) { - return -1; - } - } - return b64 ? 64 : 86; -} - -bool winhelpIsSystem_x64() -{ - typedef BOOL (WINAPI *LPFN_ISWOW64)(HANDLE, PBOOL); - int b64 = FALSE; - LPFN_ISWOW64 fnIsWow64 = (LPFN_ISWOW64)GetProcAddress( - GetModuleHandleA("kernel32"), "IsWow64Process"); - if(NULL != fnIsWow64) { - if(!fnIsWow64(GetCurrentProcess(),&b64)) { - return false; - } - } - return b64 ? true : false; -} - -typedef struct _PROCESS_QUERY -{ - HANDLE h; - PROCESSENTRY32 d; -}PROCESS_QUERY; - -int winhelpProcessQuery(void **p) -{ - PROCESS_QUERY *q = (PROCESS_QUERY *)malloc(sizeof(PROCESS_QUERY)); - if(q == NULL) - return -2; - q->h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if(q->h == INVALID_HANDLE_VALUE) { - free(q); - return -1; - } - if(FALSE == Process32First(q->h, &q->d)) { - CloseHandle(q->h); - free(q); - return -3; - } - *p = (void *)q; - return 1; -} - -int winhelpProcessNext(void *h, char *name) -{ - PROCESS_QUERY *q = (PROCESS_QUERY *)h; - int pid = 0; - if(q == NULL) - return 0; - if(q->h == NULL) { - free(q); - return 0; - } - if(name) - wsprintfA(name, "%ls", q->d.szExeFile); - pid = (int)q->d.th32ProcessID; - - if(FALSE == Process32Next(q->h, &q->d)) { - CloseHandle(q->h); - q->h = NULL; - } - return pid; -} - -int winhelpRecvEvent(const char *event) -{ - HANDLE hEvent = CreateEventA(NULL, FALSE, FALSE, event); - if(hEvent == NULL) - return 0; - WaitForSingleObject(hEvent, INFINITE); - CloseHandle(hEvent); - return 1; -} - -int winhelpSendEvent(const char *event) -{ - HANDLE hEvent = OpenEventA(EVENT_ALL_ACCESS, FALSE, event); - if(hEvent == NULL) - return 0; - SetEvent(hEvent); - CloseHandle(hEvent); - return 1; -} - -int winhelpSystemVersion() -{ - OSVERSIONINFOA ver = {0}; - int version = 0; - ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - GetVersionExA(&ver); - version = ver.dwMajorVersion * 0x100 + ver.dwMinorVersion; - return version; -} - -int winhelperSetMTUSize(const char *subname, int size) -{ - char cmd[MAX_PATH] = {0}; - sprintf(cmd, "netsh interface ipv4 set subinterface \"%s\" mtu=%d store=persistent", - subname, size); - return (int)WinExec(cmd, SW_HIDE); -} - -int winhelpRecvSendBytes(const char *dev, int *recv, int *send) -{ - MIB_IFTABLE *it = NULL; - DWORD size = sizeof(MIB_IFTABLE), ret = 0, i = 0; - DWORD tr = 0, ts = 0; - - if(it = (MIB_IFTABLE *)malloc(sizeof (MIB_IFTABLE)), it == NULL) - return -1; - if(GetIfTable(it, &size, FALSE) == ERROR_INSUFFICIENT_BUFFER) { - free(it); - if(it = (MIB_IFTABLE *)malloc(size), it == NULL) - return -2; - } - if(ret = GetIfTable(it, &size, FALSE), ret != NO_ERROR) { - free(it); - return -3; - } - for(i = 0; i < it->dwNumEntries; i++) { - MIB_IFROW *ir = &it->table[i]; - if(strstr((const char *)ir->bDescr, dev) == 0) - continue; - tr += (int)ir->dwInOctets; - ts += (int)ir->dwOutOctets; - } - *recv = tr; - *send = ts; - free(it); - return 1; -} - diff --git a/client/publib/winhelp.h b/client/publib/winhelp.h deleted file mode 100644 index 43e9367a..00000000 --- a/client/publib/winhelp.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef WINHELP_H -#define WINHELP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern int winhelpLaunchStartup(const char *, int, const char *); -extern int winhelpOneProcess(); -extern int winhelpSystemBits(); -extern bool winhelpIsSystem_x64(); -extern int winhelpProcessQuery(void **); -extern int winhelpProcessNext(void *, char *); -extern int winhelpRecvEvent(const char *); -extern int winhelpSendEvent(const char *); -extern int winhelpSystemVersion(); -extern int winhelperSetMTUSize(const char *, int); -extern int winhelpRecvSendBytes(const char *, int *, int *); - -#ifdef __cplusplus -} -#endif - -#endif /* WINHELP_H */ diff --git a/client/res.qrc b/client/resources.qrc similarity index 100% rename from client/res.qrc rename to client/resources.qrc diff --git a/client/publib/runguard.cpp b/client/runguard.cpp similarity index 100% rename from client/publib/runguard.cpp rename to client/runguard.cpp diff --git a/client/publib/runguard.h b/client/runguard.h similarity index 100% rename from client/publib/runguard.h rename to client/runguard.h diff --git a/client/ui/customshadoweffect.cpp b/client/ui/customshadoweffect.cpp deleted file mode 100644 index a719e81f..00000000 --- a/client/ui/customshadoweffect.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "customshadoweffect.h" -#include - -CustomShadowEffect::CustomShadowEffect(QObject *parent) : - QGraphicsEffect(parent), - _distance(4.0f), - _blurRadius(10.0f), - _color(0, 0, 0, 80) -{ -} - -QT_BEGIN_NAMESPACE - extern Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0 ); -QT_END_NAMESPACE - -void CustomShadowEffect::draw(QPainter* painter) -{ - // if nothing to show outside the item, just draw source - if ((blurRadius() + distance()) <= 0) { - drawSource(painter); - return; - } - - PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect; - QPoint offset; - const QPixmap px = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); - - // return if no source - if (px.isNull()) - return; - - // save world transform - QTransform restoreTransform = painter->worldTransform(); - painter->setWorldTransform(QTransform()); - - // Calculate size for the background image - QSize szi(px.size().width() + 2 * distance(), px.size().height() + 2 * distance()); - - QImage tmp(szi, QImage::Format_ARGB32_Premultiplied); - QPixmap scaled = px.scaled(szi); - tmp.fill(0); - QPainter tmpPainter(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); - tmpPainter.drawPixmap(QPointF(-distance(), -distance()), scaled); - tmpPainter.end(); - - // blur the alpha channel - QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); - blurred.fill(0); - QPainter blurPainter(&blurred); - qt_blurImage(&blurPainter, tmp, blurRadius(), false, true); - blurPainter.end(); - - tmp = blurred; - - // blacken the image... - tmpPainter.begin(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); - tmpPainter.fillRect(tmp.rect(), color()); - tmpPainter.end(); - - // draw the blurred shadow... - painter->drawImage(offset, tmp); - - // draw the actual pixmap... - painter->drawPixmap(offset, px, QRectF()); - - // restore world transform - painter->setWorldTransform(restoreTransform); -} - -QRectF CustomShadowEffect::boundingRectFor(const QRectF& rect) const -{ - qreal delta = blurRadius() + distance(); - return rect.united(rect.adjusted(-delta, -delta, delta, delta)); -} diff --git a/client/ui/customshadoweffect.h b/client/ui/customshadoweffect.h deleted file mode 100644 index 629986f2..00000000 --- a/client/ui/customshadoweffect.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef CUSTOMSHADOWEFFECT_H -#define CUSTOMSHADOWEFFECT_H - -#include -#include - -class CustomShadowEffect : public QGraphicsEffect -{ - Q_OBJECT -public: - explicit CustomShadowEffect(QObject *parent = 0); - - void draw(QPainter* painter); - QRectF boundingRectFor(const QRectF& rect) const; - - inline void setDistance(qreal distance) { _distance = distance; updateBoundingRect(); } - inline qreal distance() const { return _distance; } - - inline void setBlurRadius(qreal blurRadius) { _blurRadius = blurRadius; updateBoundingRect(); } - inline qreal blurRadius() const { return _blurRadius; } - - inline void setColor(const QColor& color) { _color = color; } - inline QColor color() const { return _color; } - -private: - qreal _distance; - qreal _blurRadius; - QColor _color; -}; - -#endif // CUSTOMSHADOWEFFECT_H diff --git a/client/ui/mainwindow.cpp b/client/ui/mainwindow.cpp index 72b9d861..e1a7a28d 100644 --- a/client/ui/mainwindow.cpp +++ b/client/ui/mainwindow.cpp @@ -1,32 +1,13 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "mainwindow.h" - - -#ifdef Q_OS_WIN #include "ui_mainwindow.h" -#endif -#ifdef Q_OS_MAC -#include "ui_mainwindow_mac.h" -#include "publib/macos_functions.h" -#endif - - -MainWindow::MainWindow(bool useForceUseBrightIcons, QWidget *parent) : QMainWindow(parent), - ui(new Ui::MainWindow), - forceUseBrightIcons(useForceUseBrightIcons) +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); + + // Post initialization + ui->widget_tittlebar->hide(); + ui->stackedWidget_main->setCurrentIndex(2); } MainWindow::~MainWindow() diff --git a/client/ui/mainwindow.h b/client/ui/mainwindow.h index 58b610e2..d593abf6 100644 --- a/client/ui/mainwindow.h +++ b/client/ui/mainwindow.h @@ -2,18 +2,6 @@ #define MAINWINDOW_H #include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "customshadoweffect.h" - - namespace Ui { class MainWindow; @@ -27,7 +15,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - explicit MainWindow(bool setForceUseBrightIcons = false, QWidget *parent = nullptr); + explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); public slots: @@ -37,7 +25,6 @@ private slots: private: Ui::MainWindow *ui; - bool forceUseBrightIcons = false; }; #endif // MAINWINDOW_H diff --git a/client/ui/mainwindow_mac.ui b/client/ui/mainwindow_mac.ui deleted file mode 100644 index dc9a01d0..00000000 --- a/client/ui/mainwindow_mac.ui +++ /dev/null @@ -1,1665 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 380 - 565 - - - - - - - QWidget { - font-size: 15px; - outline: none; - color: "#6B7C93"; -} -QPushButton { - border: none; - border-radius: 5px; -} - -QLineEdit { - border:1px solid rgb(120, 120, 120); - border-radius: 3px; - color: rgb(40, 40, 40); - - /*selection-background-color: darkgray;*/ - padding-left: 15px; -} -QLineEdit:focus { - /*border:2px solid rgb(66, 209, 133);*/ - border:2px solid white; -} -QLineEdit[error] { - border-bottom:1px solid rgb(213, 40, 60); - color: rgb(213, 40, 60); - background-color: rgb(40, 38, 38); -} -QLineEdit:disabled { - border-bottom:1px solid rgb(213, 40, 60); - color: rgb(213, 40, 60); - background-color: rgb(40, 38, 38); -} - -QCheckBox { - color: "#777777"; -} - - - - - - - 0 - 0 - 380 - 565 - - - - QWidget #widget_main { - background-color: white; -} - - - - - - 0 - 0 - 380 - 0 - - - - true - - - QPushButton { - padding:5px; -} -QPushButton:hover { - padding:0px; -} - - - - - - 344 - 8 - 20 - 20 - - - - image: url(:/images/close.png); - - - - - - - - - 299 - 13 - 20 - 20 - - - - image: url(:/images/min.png); - - - - - - - - - 39 - 2 - 200 - 30 - - - - true - - - AmneziaVPN - - - - - - 13 - 6 - 20 - 20 - - - - true - - - image: url(:/images/headericon.png); - - - - - - - - - - 0 - 0 - 380 - 565 - - - - QStackedWidget#stackedWidget_main{ -background: transparent; -} - - - - - QWidget#page_login{ -background: transparent; -} - - - - - - 90 - 45 - 200 - 59 - - - - image: url(:/images/amneziavpnimage.png); - - - - - - - - - 40 - 143 - 291 - 16 - - - - - - - Username - - - - - - 40 - 228 - 91 - 16 - - - - - -1 - - - - - - - Password - - - - - - 40 - 169 - 300 - 40 - - - - - - - 128 - - - Enter Username - - - - - - 40 - 254 - 300 - 40 - - - - - - - 128 - - - QLineEdit::Password - - - Enter Password - - - - - - 70 - 354 - 240 - 40 - - - - PointingHandCursor - - - QPushButton { - color: rgb(255, 255, 255); - background-color: "#42d185"; -} - -QPushButton:hover { - background-color: rgb(92, 228, 156); -} - - - Login - - - - - - 60 - 505 - 305 - 30 - - - - Launch AmneziaVPN on startup - - - - - - 60 - 465 - 305 - 30 - - - - - -1 - - - - Save Password - - - - - - 0 - 405 - 380 - 51 - - - - background-color: rgb(255, 255, 255); -color: rgb(255, 0, 0); - - - - - - Qt::AlignCenter - - - true - - - - - - 0 - 413 - 380 - 30 - - - - PointingHandCursor - - - QPushButton { - color: "#4171d6"; -} - -QPushButton:hover { - text-decoration: underline; -} - - - Do not have account? - - - - - - 140 - 395 - 81 - 10 - - - - - Open Sans - 11 - 50 - false - false - true - - - - PointingHandCursor - - - font: 11pt "Open Sans"; -color: rgb(74, 74, 74); - - - - - - - - - 126 - 300 - 211 - 25 - - - - PointingHandCursor - - - QPushButton { - color: "#4171d6"; - text-align:right; -} - -QPushButton:hover { - text-decoration: underline; -} - - - Forgot Password? - - - - - - - - - - - 25 - 65 - 331 - 44 - - - - 0 - - - - - - - - - 0 - 39 - 331 - 0 - - - - border-image: url(:/images/underline.png); - - - - - - - - - 100 - 9 - 161 - 30 - - - - font-size: 20px; - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 70 - 13 - 20 - 20 - - - - - - - - - - true - - - - - - 321 - 9 - 0 - 30 - - - - - - - - - - label_3 - label_detected_country - label_detected_flag - label_detected_location - - - - - - - 0 - 55 - 380 - 16 - - - - font-size: 12px; - - - Your current IP - - - Qt::AlignCenter - - - - - - 0 - 114 - 380 - 261 - - - - - - - 0 - 24 - 380 - 212 - - - - PointingHandCursor - - - image: url(:/images/connectbutton.png); - - - - - - true - - - - - - - - 0 - 24 - 380 - 212 - - - - PointingHandCursor - - - - - - - - - true - - - - - - 0 - 24 - 380 - 212 - - - - - - - Qt::AlignCenter - - - label_conn_animation - pushButton_cancelConnect - - - - - - 0 - 24 - 380 - 212 - - - - ArrowCursor - - - image: url(:/images/connected_green.png); - - - - - - true - - - - - - 0 - 24 - 380 - 212 - - - - ArrowCursor - - - image: url(:/images/connected_gray.png); - - - - - - true - - - - - - 114 - 149 - 148 - 3 - - - - Qt::Horizontal - - - - - - 0 - 151 - 380 - 59 - - - - PointingHandCursor - - - image: url(:/images/power.png); - - - - - - - - - 0 - 76 - 380 - 25 - - - - color: rgb(168, 168, 168); - - - DURATION - - - Qt::AlignCenter - - - - - - 0 - 101 - 380 - 40 - - - - - Open Sans - 24 - 50 - false - false - - - - color: rgb(44, 83, 120); -font: 24pt "Open Sans"; - - - 00:00:00 - - - Qt::AlignCenter - - - pushButton_d1 - pushButton_d2 - line - label_7 - label_duration - pushButton_disconnect - - - - - - 0 - 423 - 380 - 1 - - - - image: url(:/images/underline.png); -background: transparent; - - - - - - - - - 78 - 386 - 221 - 30 - - - - UK - Berkshire - - - - - - 40 - 386 - 30 - 30 - - - - - - - - - - true - - - - - - 314 - 394 - 21 - 16 - - - - > - - - - - - 20 - 385 - 331 - 41 - - - - PointingHandCursor - - - - - - - - - - - - 140 - 434 - 121 - 16 - - - - - -1 - - - - font-size: 10px; -color: rgb(180, 180, 180); - - - Select Location - - - - - - 0 - 455 - 380 - 101 - - - - - - - 78 - 20 - 283 - 41 - - - - Automatically select server - - - - - - - - 100 - 63 - 91 - 16 - - - - - - - VPN Status - - - - - - - 200 - 63 - 91 - 16 - - - - color: rgb(66, 209, 133); - - - Connected - - - - - - 0 - 80 - 380 - 20 - - - - - Open Sans - 10 - 50 - false - false - - - - font: 10pt "Open Sans"; -color: rgb(180, 180, 180); - - - - - - Qt::AlignCenter - - - - - - 0 - 7 - 380 - 50 - - - - - - 252 - 3 - 101 - 20 - - - - - -1 - - - - color: rgb(66, 209, 133); - - - Upload speed - - - - - - 252 - 19 - 118 - 30 - - - - - Open Sans Semibold - 14 - 7 - false - false - - - - color: rgb(66, 209, 133); -font: 63 14pt "Open Sans Semibold"; - - - 55.55 Mbps - - - - - - 14 - 10 - 29 - 29 - - - - image: url(:/images/download.png); - - - - - - - - - 48 - 3 - 131 - 20 - - - - - -1 - - - - color: rgb(65, 113, 214); - - - Download speed - - - - - - 48 - 19 - 118 - 30 - - - - - Open Sans Semibold - 14 - 7 - false - false - - - - color: rgb(65, 113, 214); -font: 63 14pt "Open Sans Semibold"; - - - 55.55 Mbps - - - - - - 215 - 10 - 29 - 29 - - - - image: url(:/images/upload.png); - - - - - - - widget_conn_speed - label_18 - label_19 - label_port_forward - - - - - - 0 - 350 - 380 - 20 - - - - font: 9pt "Open Sans"; - - - - - - - Qt::AlignCenter - - - - - - 330 - 10 - 30 - 30 - - - - PointingHandCursor - - - -QPushButton { - padding:0px; /* 1px for zooming */ - image: url(:/images_mac/settings.png); -} -QPushButton:hover { - padding:0px; -} - - - - - - - - - - QWidget#page_servers { - background: #ffffff; -} - -QPushButton { - color: "#4171D6"; - border-radius: 0px; - border : 2px solid "#4171D6"; - font-size: 13px; -} - -QPushButton:checked { - background: "#4171D6"; - color: white; -} - -QTableView { - outline: 0; - alternate-background-color: rgb(247, 249, 249); - background-color: white; - border-bottom-left-radius:10px; - border-bottom-right-radius:10px; - - gridline-color: white; -} - -QTableView::item -{ - padding-left: 5px; - - border-top: 1px solid lightgray; -} - -/* -QTableView::item::selected -{ - border: 0px; - padding-left: 5px; - background-color: rgb(99, 180, 251); - - border: : rgb(99, 180, 251); - -} -*/ -QTableView::item::hover -{ - border: 0px; - padding-left: 5px; - background-color: rgb(99, 180, 251); - border: : rgb(99, 180, 251); -} - - - -QScrollBar:vertical { /* The area behind the scrollbar covering entire height. */ - background-color: rgba(0, 0, 0,0); - opacity: 100; - width: 10px; /* set width to zero to hide scrollbar entirely. Can look quite clean and scrolling still works with mousewheel. */ - margin: 10px px; /* Takes the height of the buttons + 3 extra pixels to leave some free space between handle and buttons */ - -} - -QScrollBar::handle:vertical { /* The handle you scroll with */ - image-position: center; /* image is used as a small gripper in the center of the scrollbar.. You can also use background-image to use two images */ - background-color: rgb(200, 200, 200); - border: 2px solid rgb(240,240,240); - border-radius: 1px; - min-height: 10px; -} -QScrollBar::handle:vertical:hover { /* state when you hover over the handle */ - background-color: rgb(160, 160, 160); -} -QScrollBar::handle:vertical:pressed { /* state when you hover over the handle */ - background-color: rgb(120, 120, 120); -} -QScrollBar::sub-line:vertical { /* button to scroll up */ - background-color: rgb(240,240,240); - height: 10px; - subcontrol-position: top; - subcontrol-origin: margin; -} - -QScrollBar::sub-line:vertical:hover { /* hover state of button to scroll up */ - background-color: rgb(200, 200, 200); -} - -QScrollBar::up-arrow:vertical { /* arrow to scroll up with */ - top: 2px; -} - -QScrollBar::add-line:vertical { /* Button to scroll down */ - background-color: rgb(240,240,240); - height: 10px; - padding-top: 2px; - subcontrol-position: bottom; - subcontrol-origin: margin; -} -QScrollBar::add-line:vertical:hover { /* hover state of button to scroll down */ - background-color: rgb(200, 200, 200); -} - -QScrollBar::down-arrow:vertical { /* arrow to scroll down with */ - bottom: 3px; -} - -QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { - background-color: rgb(240,240,240); - -} - - - - - - - 10 - 50 - 121 - 30 - - - - border-top-left-radius: 4px; -border-bottom-left-radius: 4px; - - - All - - - true - - - true - - - true - - - - - - 129 - 50 - 122 - 30 - - - - Recommended - - - true - - - true - - - - - - 249 - 50 - 121 - 30 - - - - border-top-right-radius: 4px; -border-bottom-right-radius: 4px; - - - Favorites - - - true - - - true - - - - - - 20 - 17 - 25 - 17 - - - - PointingHandCursor - - - QPushButton { - padding: 1px; - border: none; - image: url(:/images/arrow_back.png); -} -QPushButton:hover { - padding: 0px; -} - - - - - - - - - - - 0 - 94 - 380 - 462 - - - - PointingHandCursor - - - true - - - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - QAbstractItemView::NoSelection - - - QAbstractItemView::SelectRows - - - false - - - Qt::NoPen - - - false - - - true - - - false - - - - - - 0 - 92 - 370 - 5 - - - - background-color: rgb(255, 255, 255); - - - - - - - - - - 330 - 10 - 0 - 30 - - - - PointingHandCursor - - - -QPushButton { - padding:1px; - image: url(:/images_mac/settings.png); -} -QPushButton:hover { - padding:0px; -} - - - - - - - - - - 0 - 15 - 380 - 21 - - - - font-size: 20px; -color: "#6B7C93"; - - - Servers - - - Qt::AlignCenter - - - pushButton_servers_all - pushButton_servers_recommended - pushButton_servers_favorites - tableView_servers - label_hide_first_line - pushButton_settings_2 - label_15 - pushButton_cancel - - - - - - 0 - 45 - 380 - 41 - - - - font-size: 30px; - - - Sign Up - - - Qt::AlignCenter - - - - - - 70 - 354 - 240 - 40 - - - - PointingHandCursor - - - QPushButton { - color: rgb(255, 255, 255); - background-color: "#42d185"; -} - -QPushButton:hover { - background-color: rgb(92, 228, 156); -} - - - Login - - - - - - 0 - 413 - 380 - 30 - - - - PointingHandCursor - - - QPushButton { - color: "#4171d6"; -} - -QPushButton:hover { - text-decoration: underline; -} - - - Do not have account? - - - - - - 40 - 143 - 291 - 16 - - - - - - - Username - - - - - - 40 - 254 - 300 - 40 - - - - - - - 128 - - - QLineEdit::Password - - - - - - - - - 40 - 169 - 300 - 40 - - - - - - - 128 - - - Enter Username - - - - - - 40 - 228 - 91 - 16 - - - - - -1 - - - - - - - Password - - - - - - 0 - 520 - 380 - 25 - - - - PointingHandCursor - - - QPushButton { - color: "#4171d6"; -} - -QPushButton:hover { - text-decoration: underline; -} - - - Forgot Password? - - - - - - - - - - - SlidingStackedWidget - QStackedWidget -
ui/Controls/SlidingStackedWidget.h
- 1 -
- - ServersTableView - QTableView -
ui/Controls/serverstableview.h
-
-
- - -