kylin-nm/mainwindow.h

246 lines
6.7 KiB
C
Raw Normal View History

/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QWidget>
#include <QLabel>
#include <QSystemTrayIcon>
#include <QDesktopWidget>
#include <QScrollBar>
#include <QScrollArea>
#include <QPushButton>
#include <QScreen>
#include <QMenu>
#include <QAction>
2020-02-18 14:01:09 +08:00
#include <QWidgetAction>
#include <QHBoxLayout>
#include <QPainter>
#include <QDebug>
#include <QString>
#include <QTimer>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusObjectPath>
#include <QDBusObjectPath>
#include <QVariant>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syslog.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include "ksimplenm.h"
#include "loadingdiv.h"
2020-02-18 14:01:09 +08:00
#include "networkspeed.h"
#include "kylin-dbus-interface.h"
#include "kylin-network-interface.h"
class OneConnForm;
class ConfForm;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void startLoading();
void stopLoading();
void setTrayIcon(QIcon icon);
void setTrayLoading(bool isLoading);
void initTimer();
void changeTimerState();
2019-12-12 19:05:54 +08:00
void checkIsWirelessDeviceOn();
2020-02-18 14:01:09 +08:00
void init_widget_action(QWidget *wid, QString iconstr, QString textstr);
QIcon iconLanOnline, iconLanOffline;
QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
QIcon iconConnecting;
QList<QIcon> loadIcons;
QString mwBandWidth;
KylinDBus *objKyDBus;
2020-02-18 14:01:09 +08:00
NetworkSpeed *objNetSpeed;
//状态设置,0为假1为真
int is_update_wifi_list = 0; //是否是update wifi列表而不是load wifi列表
int is_by_click_connect = 0; //是否是通过点击连接按钮进行的连接
int is_btnNetList_clicked = 1; //是否处于有线网界面
int is_btnWifiList_clicked = 0; //是否处于无线网界面
int is_wired_line_ready = 1; //主机是否连接网线
int is_wireless_adapter_ready = 1; //主机是否插入无线网卡
int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式
int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态
2020-02-18 14:01:09 +08:00
int is_fly_mode_on = 0; //是否打开飞行模式
int is_hot_sopt_on = 0; //是否已经打开热点
QString currSelNetName = ""; //当前ScrollArea中选中的网络名称
public slots:
void onPhysicalCarrierChanged(bool flag);
void onCarrierUpHandle();
void onCarrierDownHandle();
2020-01-13 09:38:25 +08:00
void onDeleteLan();
void onWirelessDeviceAdded(QDBusObjectPath objPath);
void onWirelessDeviceRemoved(QDBusObjectPath objPath);
void getLanBandWidth();
2020-02-18 14:01:09 +08:00
void oneLanFormSelected(QString lanName);
void oneTopLanFormSelected(QString lanName);
void oneWifiFormSelected(QString wifiName);
void oneTopWifiFormSelected(QString wifiName);
void on_btnHotspot_clicked();
void on_btnHotspotState();
private:
void checkSingle();
void getActiveInfo();
void initNetwork();
void createTrayIcon();
2020-02-18 14:01:09 +08:00
void handleIconClicked();
bool checkLanOn();
bool checkWlOn();
void getLanList();
void getWifiList();
void getInitLanSlist();
Ui::MainWindow *ui;
LoadingDiv *loading;
QDesktopWidget desktop;
KSimpleNM *ksnm;
ConfForm *confForm;
2020-02-18 14:01:09 +08:00
QWidget *topLanListWidget;
QWidget *topWifiListWidget;
QWidget *lanListWidget;
QWidget *wifiListWidget;
QWidget *optWifiWidget;
2020-02-18 14:01:09 +08:00
QLabel *lbLoadDown;
QLabel *lbLoadUp;
QScrollArea *scrollAreal, *scrollAreaw;
2020-02-18 14:01:09 +08:00
QLabel *lbTopLanList, *lbTopWifiList, *lbLanList, *lbWifiList;
QLabel *lbBb;
QPushButton *btnAddNet;
QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu;
2020-02-18 14:01:09 +08:00
QWidgetAction *mShowWindow;
QWidgetAction *mAdvConf;
QWidget *widShowWindow;
QWidget *widAdvConf;
2020-02-18 14:01:09 +08:00
QString lname, wname; // 以太网卡和无线网卡名称
2020-02-18 14:01:09 +08:00
QString btnOffQss, btnOnQss, btnBgOffQss, btnBgOnQss; // 主界面按钮底色
2020-02-18 14:01:09 +08:00
QStringList oldLanSlist; //上一次获取Lan列表
2020-02-18 14:01:09 +08:00
QStringList oldWifiSlist; //上一次获取wifi列表
//循环检测网络连接状态
QTimer *iconTimer;
QTimer *wiredCableUpTimer;
QTimer *wiredCableDownTimer;
2020-01-13 09:38:25 +08:00
QTimer *deleteLanTimer;
QTimer *checkWifiListChanged;
QTimer *checkIfLanConnect;
QTimer *checkIfWifiConnect;
QTimer *checkIfNetworkOn;
2020-02-18 14:01:09 +08:00
QTimer *setNetSpeed;
int currentIconIndex;
2020-02-18 14:01:09 +08:00
int activeWifiSignalLv;
long int start_rcv_rates = 0; //保存开始时的流量计数
long int end_rcv_rates = 0; //保存结束时的流量计数
long int start_tx_rates = 0; //保存开始时的流量计数
long int end_tx_rates = 0; //保存结束时的流量计数
private slots:
void iconActivated(QSystemTrayIcon::ActivationReason reason);
2020-02-18 14:01:09 +08:00
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
void on_btnNet_clicked();
void on_btnWifi_clicked();
void on_btnNetList_clicked(int flag=0);
void on_btnWifiList_clicked();
void getLanListDone(QStringList slist);
void getWifiListDone(QStringList slist);
void loadWifiListDone(QStringList slist);
void updateWifiListDone(QStringList slist);
2020-02-18 14:01:09 +08:00
void on_showWindowAction();
void on_btnAdvConf_clicked();
void on_btnNetList_pressed();
void on_btnWifiList_pressed();
void activeLanDisconn();
void activeWifiDisconn();
void activeStartLoading();
void activeGetWifiList();
void on_btnAdvConf_pressed();
void on_btnAdvConf_released();
void on_checkWifiListChanged();
2020-02-18 14:01:09 +08:00
void on_setNetSpeed();
void on_isLanConnect();
void on_isWifiConnect();
void on_isNetOn();
// 后台回调
void enNetDone();
void disNetDone();
void enWifiDone();
void launchLanDone();
void disWifiDone();
void keepDisWifiState();
void connLanDone(int connFlag);
void connWifiDone(int connFlag);
void iconStep();
2020-02-18 14:01:09 +08:00
void on_btnFlyMode_clicked();
void on_btnAddNet_clicked();
signals:
void deleteRedundantNet();
void waitWifiStop();
void waitLanStop();
};
#endif // MAINWINDOW_H