Files
amnezia-client/client/ui/mainwindow.h
T

94 lines
2.3 KiB
C++
Raw Normal View History

2020-11-23 16:20:25 +03:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
2021-01-09 19:55:16 +03:00
#include <QLabel>
2020-11-23 16:20:25 +03:00
#include <QMainWindow>
2021-01-09 19:55:16 +03:00
#include <QProgressBar>
#include <QPushButton>
#include <QSystemTrayIcon>
2020-11-23 16:20:25 +03:00
2021-01-03 21:18:20 +03:00
#include "framelesswindow.h"
2021-01-06 17:12:24 +03:00
#include "protocols/vpnprotocol.h"
2020-12-26 15:03:51 +03:00
2020-12-30 17:03:05 +03:00
class Settings;
2020-12-26 15:03:51 +03:00
class VpnConnection;
2020-11-23 16:20:25 +03:00
namespace Ui {
class MainWindow;
}
/**
* @brief The MainWindow class - Main application window
*/
2021-01-03 23:55:04 +03:00
#ifdef Q_OS_WIN
2021-01-03 21:18:20 +03:00
class MainWindow : public CFramelessWindow
2021-01-03 23:55:04 +03:00
#else
class MainWindow : public QMainWindow
#endif
2020-11-23 16:20:25 +03:00
{
Q_OBJECT
public:
2020-12-04 00:45:21 +03:00
explicit MainWindow(QWidget *parent = nullptr);
2020-11-23 16:20:25 +03:00
~MainWindow();
2021-01-09 19:55:16 +03:00
enum Page {Start, NewServer, Vpn, GeneralSettings, ServerSettings, ShareConnection, Sites};
Q_ENUM(Page)
2020-11-23 16:20:25 +03:00
private slots:
2020-12-30 17:03:05 +03:00
void onBytesChanged(quint64 receivedBytes, quint64 sentBytes);
void onConnectionStateChanged(VpnProtocol::ConnectionState state);
2021-01-08 16:51:58 +03:00
void onVpnProtocolError(amnezia::ErrorCode errorCode);
2021-01-09 19:55:16 +03:00
void onPushButtonConnectClicked(bool checked);
void onPushButtonNewServerConnectWithNewData(bool);
void onPushButtonReinstallServer(bool);
void onPushButtonClearServer(bool);
void onPushButtonForgetServer(bool);
void onTrayActionConnect(); // connect from context menu
void setTrayState(VpnProtocol::ConnectionState state);
void onTrayActivated(QSystemTrayIcon::ActivationReason reason);
void onConnect();
void onDisconnect();
2020-12-16 06:02:22 +03:00
2021-01-03 19:14:54 +03:00
2020-11-23 16:20:25 +03:00
private:
2021-01-09 19:55:16 +03:00
void goToPage(Page page, bool reset = true, bool slide = true);
QWidget *getPageWidget(Page page);
Page currentPage();
bool installServer(ServerCredentials credentials, QWidget *page, QProgressBar *progress, QPushButton *button, QLabel *info);
void setupTray();
void setTrayIcon(const QString &iconPath);
void setupUiConnections();
2020-12-16 06:02:22 +03:00
2020-11-23 16:20:25 +03:00
Ui::MainWindow *ui;
2020-12-26 15:03:51 +03:00
VpnConnection* m_vpnConnection;
2020-12-30 17:03:05 +03:00
Settings* m_settings;
2021-01-03 19:14:54 +03:00
2021-01-09 19:55:16 +03:00
QAction* m_trayActionConnect;
QAction* m_trayActionDisconnect;
QSystemTrayIcon m_tray;
QMenu* m_menu;
2021-01-03 19:14:54 +03:00
bool canMove = false;
QPoint offset;
bool eventFilter(QObject *obj, QEvent *event) override;
void keyPressEvent(QKeyEvent* event) override;
2021-01-09 19:55:16 +03:00
void closeEvent(QCloseEvent *event) override;
const QString ConnectedTrayIconName = "active.png";
const QString DisconnectedTrayIconName = "default.png";
const QString ErrorTrayIconName = "error.png";
2020-11-23 16:20:25 +03:00
};
#endif // MAINWINDOW_H