diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 1a1f052d..857185e9 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -134,12 +134,10 @@ if(WIN32)
set(HEADERS ${HEADERS}
${CMAKE_CURRENT_LIST_DIR}/protocols/ikev2_vpn_protocol_windows.h
- ${CMAKE_CURRENT_LIST_DIR}/ui/framelesswindow.h
)
set(SOURCES ${SOURCES}
${CMAKE_CURRENT_LIST_DIR}/protocols/ikev2_vpn_protocol_windows.cpp
- ${CMAKE_CURRENT_LIST_DIR}/ui/framelesswindow.cpp
)
set(RESOURCES ${RESOURCES}
diff --git a/client/client.pro b/client/client.pro
index 13383b7c..f96c9944 100644
--- a/client/client.pro
+++ b/client/client.pro
@@ -164,11 +164,9 @@ win32 {
HEADERS += \
protocols/ikev2_vpn_protocol_windows.h \
- ui/framelesswindow.h
SOURCES += \
protocols/ikev2_vpn_protocol_windows.cpp \
- ui/framelesswindow.cpp
VERSION = 2.0.0.0
QMAKE_TARGET_COMPANY = "AmneziaVPN"
diff --git a/client/resources.qrc b/client/resources.qrc
index 0c325062..040bf750 100644
--- a/client/resources.qrc
+++ b/client/resources.qrc
@@ -62,7 +62,6 @@
server_scripts/website_tor/configure_container.sh
server_scripts/website_tor/run_container.sh
ui/qml/main.qml
- ui/qml/TitleBar.qml
ui/qml/Pages/PageBase.qml
ui/qml/Pages/PageAppSetting.qml
ui/qml/Pages/PageGeneralSettings.qml
diff --git a/client/ui/framelesswindow.cpp b/client/ui/framelesswindow.cpp
deleted file mode 100644
index 489ea134..00000000
--- a/client/ui/framelesswindow.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-// This code is a part of Qt-Nice-Frameless-Window
-// https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window
-// Licensed by MIT License - https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window/blob/master/LICENSE
-
-
-#include "framelesswindow.h"
-#include
-#include
-#include
-#include
-#include
-
-#ifdef Q_OS_WIN
-
-#include
-#include
-#include
-#include
-#include // Fixes error C2504: 'IUnknown' : base class undefined
-#include
-#include
-#pragma comment (lib,"Dwmapi.lib") // Adds missing library, fixes error LNK2019: unresolved external symbol __imp__DwmExtendFrameIntoClientArea
-#pragma comment (lib,"user32.lib")
-
-CFramelessWindow::CFramelessWindow(QWidget *parent)
- : QMainWindow(parent),
- m_titlebar(Q_NULLPTR),
- m_borderWidth(5),
- m_bJustMaximized(false),
- m_bResizeable(true)
-{
-// setWindowFlag(Qt::Window,true);
-// setWindowFlag(Qt::FramelessWindowHint, true);
-// setWindowFlag(Qt::WindowSystemMenuHint, true);
-// setWindowFlag() is not avaliable before Qt v5.9, so we should use setWindowFlags instead
-
- if (QOperatingSystemVersion::current() > QOperatingSystemVersion::Windows7) {
- setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
- setResizeable(m_bResizeable);
- }
-}
-
-void CFramelessWindow::setResizeable(bool resizeable)
-{
- bool visible = isVisible();
- m_bResizeable = resizeable;
- if (m_bResizeable){
- setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint);
-// setWindowFlag(Qt::WindowMaximizeButtonHint);
-
- //此行代码可以带回Aero效果,同时也带回了标题栏和边框,在nativeEvent()会再次去掉标题栏
- //
- //this line will get titlebar/thick frame/Aero back, which is exactly what we want
- //we will get rid of titlebar and thick frame again in nativeEvent() later
- HWND hwnd = (HWND)this->winId();
- DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
- ::SetWindowLong(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
- }else{
- setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
-// setWindowFlag(Qt::WindowMaximizeButtonHint,false);
-
- HWND hwnd = (HWND)this->winId();
- DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
- ::SetWindowLong(hwnd, GWL_STYLE, style & ~WS_MAXIMIZEBOX & ~WS_CAPTION);
- }
-
- //保留一个像素的边框宽度,否则系统不会绘制边框阴影
- //
- //we better left 1 piexl width of border untouch, so OS can draw nice shadow around it
- const MARGINS shadow = { 1, 1, 1, 1 };
- DwmExtendFrameIntoClientArea(HWND(winId()), &shadow);
-
- setVisible(visible);
-}
-
-void CFramelessWindow::setResizeableAreaWidth(int width)
-{
- if (1 > width) width = 1;
- m_borderWidth = width;
-}
-
-void CFramelessWindow::setTitleBar(QWidget* titlebar)
-{
- m_titlebar = titlebar;
- if (!titlebar) return;
- connect(titlebar, SIGNAL(destroyed(QObject*)), this, SLOT(onTitleBarDestroyed()));
-}
-
-void CFramelessWindow::onTitleBarDestroyed()
-{
- if (m_titlebar == QObject::sender())
- {
- m_titlebar = Q_NULLPTR;
- }
-}
-
-void CFramelessWindow::addIgnoreWidget(QWidget* widget)
-{
- if (!widget) return;
- if (m_whiteList.contains(widget)) return;
- m_whiteList.append(widget);
-}
-
-bool CFramelessWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
-{
- if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::Windows7) {
- return QMainWindow::nativeEvent(eventType, message, reinterpret_cast(result));
- }
-
- //Workaround for known bug -> check Qt forum : https://forum.qt.io/topic/93141/qtablewidget-itemselectionchanged/13
- #if (QT_VERSION == QT_VERSION_CHECK(5, 11, 1))
- MSG* msg = *reinterpret_cast(message);
- #else
- MSG* msg = reinterpret_cast(message);
- #endif
-
- switch (msg->message)
- {
- case WM_NCCALCSIZE:
- {
- NCCALCSIZE_PARAMS& params = *reinterpret_cast(msg->lParam);
- if (params.rgrc[0].top != 0)
- params.rgrc[0].top -= 1;
-
- //this kills the window frame and title bar we added with WS_THICKFRAME and WS_CAPTION
- *result = WVR_REDRAW;
- return true;
- }
- case WM_NCHITTEST:
- {
- *result = 0;
-
- const LONG border_width = m_borderWidth;
- RECT winrect;
- GetWindowRect(HWND(winId()), &winrect);
-
- long x = GET_X_LPARAM(msg->lParam);
- long y = GET_Y_LPARAM(msg->lParam);
-
- if(m_bResizeable)
- {
-
- bool resizeWidth = minimumWidth() != maximumWidth();
- bool resizeHeight = minimumHeight() != maximumHeight();
-
- if(resizeWidth)
- {
- //left border
- if (x >= winrect.left && x < winrect.left + border_width)
- {
- *result = HTLEFT;
- }
- //right border
- if (x < winrect.right && x >= winrect.right - border_width)
- {
- *result = HTRIGHT;
- }
- }
- if(resizeHeight)
- {
- //bottom border
- if (y < winrect.bottom && y >= winrect.bottom - border_width)
- {
- *result = HTBOTTOM;
- }
- //top border
- if (y >= winrect.top && y < winrect.top + border_width)
- {
- *result = HTTOP;
- }
- }
- if(resizeWidth && resizeHeight)
- {
- //bottom left corner
- if (x >= winrect.left && x < winrect.left + border_width &&
- y < winrect.bottom && y >= winrect.bottom - border_width)
- {
- *result = HTBOTTOMLEFT;
- }
- //bottom right corner
- if (x < winrect.right && x >= winrect.right - border_width &&
- y < winrect.bottom && y >= winrect.bottom - border_width)
- {
- *result = HTBOTTOMRIGHT;
- }
- //top left corner
- if (x >= winrect.left && x < winrect.left + border_width &&
- y >= winrect.top && y < winrect.top + border_width)
- {
- *result = HTTOPLEFT;
- }
- //top right corner
- if (x < winrect.right && x >= winrect.right - border_width &&
- y >= winrect.top && y < winrect.top + border_width)
- {
- *result = HTTOPRIGHT;
- }
- }
- }
- if (0!=*result) return true;
-
- //*result still equals 0, that means the cursor locate OUTSIDE the frame area
- //but it may locate in titlebar area
- if (!m_titlebar) return false;
-
- //support highdpi
- double dpr = this->devicePixelRatioF();
- QPoint pos = m_titlebar->mapFromGlobal(QPoint(x/dpr,y/dpr));
-
- if (!m_titlebar->rect().contains(pos)) return false;
- QWidget* child = m_titlebar->childAt(pos);
- if (!child)
- {
- *result = HTCAPTION;
- return true;
- }else{
- if (m_whiteList.contains(child))
- {
- *result = HTCAPTION;
- return true;
- }
- }
- return false;
- } //end case WM_NCHITTEST
- case WM_GETMINMAXINFO:
- {
- if (::IsZoomed(msg->hwnd)) {
- RECT frame = { 0, 0, 0, 0 };
- AdjustWindowRectEx(&frame, WS_OVERLAPPEDWINDOW, FALSE, 0);
-
- //record frame area data
- double dpr = this->devicePixelRatioF();
-
- m_frames.setLeft(abs(frame.left)/dpr+0.5);
- m_frames.setTop(abs(frame.bottom)/dpr+0.5);
- m_frames.setRight(abs(frame.right)/dpr+0.5);
- m_frames.setBottom(abs(frame.bottom)/dpr+0.5);
-
- QMainWindow::setContentsMargins(m_frames.left()+m_margins.left(), \
- m_frames.top()+m_margins.top(), \
- m_frames.right()+m_margins.right(), \
- m_frames.bottom()+m_margins.bottom());
- m_bJustMaximized = true;
- }else {
- if (m_bJustMaximized)
- {
- QMainWindow::setContentsMargins(m_margins);
- m_frames = QMargins();
- m_bJustMaximized = false;
- }
- }
- return false;
- }
- default:
- return QMainWindow::nativeEvent(eventType, message, reinterpret_cast(result));
- }
-}
-
-void CFramelessWindow::setContentsMargins(const QMargins &margins)
-{
- QMainWindow::setContentsMargins(margins+m_frames);
- m_margins = margins;
-}
-void CFramelessWindow::setContentsMargins(int left, int top, int right, int bottom)
-{
- QMainWindow::setContentsMargins(left+m_frames.left(),\
- top+m_frames.top(), \
- right+m_frames.right(), \
- bottom+m_frames.bottom());
- m_margins.setLeft(left);
- m_margins.setTop(top);
- m_margins.setRight(right);
- m_margins.setBottom(bottom);
-}
-QMargins CFramelessWindow::contentsMargins() const
-{
- QMargins margins = QMainWindow::contentsMargins();
- margins -= m_frames;
- return margins;
-}
-void CFramelessWindow::getContentsMargins(int *left, int *top, int *right, int *bottom) const
-{
- getContentsMargins(left,top,right,bottom);
- if (!(left&&top&&right&&bottom)) return;
- if (isMaximized())
- {
- *left -= m_frames.left();
- *top -= m_frames.top();
- *right -= m_frames.right();
- *bottom -= m_frames.bottom();
- }
-}
-QRect CFramelessWindow::contentsRect() const
-{
- QRect rect = QMainWindow::contentsRect();
- int width = rect.width();
- int height = rect.height();
- rect.setLeft(rect.left() - m_frames.left());
- rect.setTop(rect.top() - m_frames.top());
- rect.setWidth(width);
- rect.setHeight(height);
- return rect;
-}
-void CFramelessWindow::showFullScreen()
-{
- if (isMaximized())
- {
- QMainWindow::setContentsMargins(m_margins);
- m_frames = QMargins();
- }
- QMainWindow::showFullScreen();
-}
-
-#endif //Q_OS_WIN
diff --git a/client/ui/framelesswindow.h b/client/ui/framelesswindow.h
deleted file mode 100644
index ac560231..00000000
--- a/client/ui/framelesswindow.h
+++ /dev/null
@@ -1,158 +0,0 @@
-// This code is a part of Qt-Nice-Frameless-Window
-// https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window
-// Licensed by MIT License - https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window/blob/master/LICENSE
-
-
-#ifndef CFRAMELESSWINDOW_H
-#define CFRAMELESSWINDOW_H
-#include "qsystemdetection.h"
-#include
-#include
-
-//A nice frameless window for both Windows and OS X
-//Author: Bringer-of-Light
-//Github: https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window
-// Usage: use "CFramelessWindow" as base class instead of "QMainWindow", and enjoy
-#ifdef Q_OS_WIN
-#include
-#include
-#include
-#include
-class CFramelessWindow : public QMainWindow
-{
- Q_OBJECT
-public:
- explicit CFramelessWindow(QWidget *parent = 0);
-public:
-
- //设置是否可以通过鼠标调整窗口大小
- //if resizeable is set to false, then the window can not be resized by mouse
- //but still can be resized programtically
- void setResizeable(bool resizeable=true);
- bool isResizeable(){return m_bResizeable;}
-
- //设置可调整大小区域的宽度,在此区域内,可以使用鼠标调整窗口大小
- //set border width, inside this aera, window can be resized by mouse
- void setResizeableAreaWidth(int width = 5);
-protected:
- //设置一个标题栏widget,此widget会被当做标题栏对待
- //set a widget which will be treat as SYSTEM titlebar
- void setTitleBar(QWidget* titlebar);
-
- //在标题栏控件内,也可以有子控件如标签控件“label1”,此label1遮盖了标题栏,导致不能通过label1拖动窗口
- //要解决此问题,使用addIgnoreWidget(label1)
- //generally, we can add widget say "label1" on titlebar, and it will cover the titlebar under it
- //as a result, we can not drag and move the MainWindow with this "label1" again
- //we can fix this by add "label1" to a ignorelist, just call addIgnoreWidget(label1)
- void addIgnoreWidget(QWidget* widget);
-
- bool nativeEvent(const QByteArray &eventType, void *message, long *result);
-private slots:
- void onTitleBarDestroyed();
-public:
- void setContentsMargins(const QMargins &margins);
- void setContentsMargins(int left, int top, int right, int bottom);
- QMargins contentsMargins() const;
- QRect contentsRect() const;
- void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
-public slots:
- void showFullScreen();
-private:
- QWidget* m_titlebar;
- QList m_whiteList;
- int m_borderWidth;
-
- QMargins m_margins;
- QMargins m_frames;
- bool m_bJustMaximized;
-
- bool m_bResizeable;
-};
-
-#elif defined Q_OS_MAC || defined Q_OS_LINUX
-#include
-#include
-#include
-class CFramelessWindow : public QMainWindow
-{
- Q_OBJECT
-public:
- explicit CFramelessWindow(QWidget *parent = 0);
-private:
- void initUI();
-public:
- //设置可拖动区域的高度,在此区域内,可以通过鼠标拖动窗口, 0表示整个窗口都可拖动
- //In draggable area, window can be moved by mouse, (height = 0) means that the whole window is draggable
- void setDraggableAreaHeight(int height = 0);
-
- //只有OS X10.10及以后系统,才支持OS X原生样式包括:三个系统按钮、窗口圆角、窗口阴影
- //类初始化完成后,可以通过此函数查看是否已经启用了原生样式。如果未启动,需要自定义关闭按钮、最小化按钮、最大化按钮
- //Native style(three system button/ round corner/ drop shadow) works only on OS X 10.10 or later
- //after init, we should check whether NativeStyle is OK with this function
- //if NOT ok, we should implement close button/ min button/ max button ourself
- bool isNativeStyleOK() {return m_bNativeSystemBtn;}
-
- //如果设置setCloseBtnQuit(false),那么点击关闭按钮后,程序不会退出,而是会隐藏,只有在OS X 10.10 及以后系统中有效
- //if setCloseBtnQuit(false), then when close button is clicked, the application will hide itself instead of quit
- //be carefull, after you set this to false, you can NOT change it to true again
- //this function should be called inside of the constructor function of derived classes, and can NOT be called more than once
- //only works for OS X 10.10 or later
- void setCloseBtnQuit(bool bQuit = true);
-
- //启用或禁用关闭按钮,只有在isNativeStyleOK()返回true的情况下才有效
- //enable or disable Close button, only worked if isNativeStyleOK() returns true
- void setCloseBtnEnabled(bool bEnable = true);
-
- //启用或禁用最小化按钮,只有在isNativeStyleOK()返回true的情况下才有效
- //enable or disable Miniaturize button, only worked if isNativeStyleOK() returns true
- void setMinBtnEnabled(bool bEnable = true);
-
- //启用或禁用zoom(最大化)按钮,只有在isNativeStyleOK()返回true的情况下才有效
- //enable or disable Zoom button(fullscreen button), only worked if isNativeStyleOK() returns true
- void setZoomBtnEnabled(bool bEnable = true);
-
- bool isCloseBtnEnabled() {return m_bIsCloseBtnEnabled;}
- bool isMinBtnEnabled() {return m_bIsMinBtnEnabled;}
- bool isZoomBtnEnabled() {return m_bIsZoomBtnEnabled;}
-protected:
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
-private:
- int m_draggableHeight;
- bool m_bWinMoving;
- bool m_bMousePressed;
- QPoint m_MousePos;
- QPoint m_WindowPos;
- bool m_bCloseBtnQuit;
- bool m_bNativeSystemBtn;
- bool m_bIsCloseBtnEnabled, m_bIsMinBtnEnabled, m_bIsZoomBtnEnabled;
-
- //===============================================
- //TODO
- //下面的代码是试验性质的
- //tentative code
-
- //窗口从全屏状态恢复正常大小时,标题栏又会出现,原因未知。
- //默认情况下,系统的最大化按钮(zoom button)是进入全屏,为了避免标题栏重新出现的问题,
- //以上代码已经重新定义了系统zoom button的行为,是其功能变为最大化而不是全屏
- //以下代码尝试,每次窗口从全屏状态恢复正常大小时,都再次进行设置,以消除标题栏
- //after the window restore from fullscreen mode, the titlebar will show again, it looks like a BUG
- //on OS X 10.10 and later, click the system green button (zoom button) will make the app become fullscreen
- //so we have override it's action to "maximized" in the CFramelessWindow Constructor function
- //but we may try something else such as delete the titlebar again and again...
-private:
- bool m_bTitleBarVisible;
-
- void setTitlebarVisible(bool bTitlebarVisible = false);
- bool isTitlebarVisible() {return m_bTitleBarVisible;}
-private slots:
- void onRestoreFromFullScreen();
-signals:
- void restoreFromFullScreen();
-protected:
- void resizeEvent(QResizeEvent *event);
-};
-#endif
-
-#endif // CFRAMELESSWINDOW_H
diff --git a/client/ui/qml/TitleBar.qml b/client/ui/qml/TitleBar.qml
deleted file mode 100644
index cf6aed8a..00000000
--- a/client/ui/qml/TitleBar.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick
-import QtQuick.Controls
-import "./"
-import "Config"
-
-Rectangle {
- id: root
- color: "#F5F5F5"
- width: GC.screenWidth
- height: 30
- signal closeButtonClicked()
-
- Button {
- id: closeButton
- anchors.verticalCenter: parent.verticalCenter
- anchors.right: parent.right
- anchors.rightMargin: 5
- icon.source: "qrc:/images/close.png"
- icon.width: 16
- icon.height: 16
- width: height
- height: 20
- background: Item {}
- contentItem: Image {
- source: closeButton.icon.source
- anchors.fill: closeButton
- anchors.margins: ms.containsMouse ? 3 : 4
- }
- MouseArea {
- id: ms
- hoverEnabled: true
- anchors.fill: closeButton
- }
- onClicked: {
- root.closeButtonClicked()
- }
- }
-}
diff --git a/client/ui/qml/main.qml b/client/ui/qml/main.qml
index 101dd384..7f631f96 100644
--- a/client/ui/qml/main.qml
+++ b/client/ui/qml/main.qml
@@ -85,14 +85,14 @@ Window {
}
Rectangle {
- y: GC.isDesktop() ? titleBar.height : 0
+ y: 0
anchors.fill: parent
color: "white"
}
StackView {
id: pageLoader
- y: GC.isDesktop() ? titleBar.height : 0
+ y: 0
anchors.fill: parent
focus: true
diff --git a/client/ui/uilogic.cpp b/client/ui/uilogic.cpp
index 94da8103..2393f99e 100644
--- a/client/ui/uilogic.cpp
+++ b/client/ui/uilogic.cpp
@@ -267,32 +267,6 @@ void UiLogic::onGotoCurrentProtocolsPage()
emit goToPage(Page::ServerContainers);
}
-//void UiLogic::showEvent(QShowEvent *event)
-//{
-//#if defined Q_OS_MACX
-// if (!event->spontaneous()) {
-// setDockIconVisible(true);
-// }
-// if (needToHideCustomTitlebar) {
-// ui->widget_tittlebar->hide();
-// resize(width(), 640);
-// ui->stackedWidget_main->move(0,0);
-// }
-//#endif
-//}
-
-//void UiLogic::hideEvent(QHideEvent *event)
-//{
-//#if defined Q_OS_MACX
-// if (!event->spontaneous()) {
-// setDockIconVisible(false);
-// }
-//#endif
-//}
-
-
-
-
void UiLogic::installServer(QMap &containers)
{
if (containers.isEmpty()) return;