merge:合并openkylin代码
This commit is contained in:
parent
c051d72b6b
commit
b8b1eef135
|
@ -154,6 +154,7 @@ void MainWindow::firstlyStart()
|
||||||
{
|
{
|
||||||
initWindowProperties();
|
initWindowProperties();
|
||||||
initTransparency();
|
initTransparency();
|
||||||
|
registerTrayIcon();
|
||||||
initUI();
|
initUI();
|
||||||
initDbusConnnect();
|
initDbusConnnect();
|
||||||
initWindowTheme();
|
initWindowTheme();
|
||||||
|
@ -229,6 +230,30 @@ void MainWindow::initWindowProperties()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::registerTrayIcon 注册托盘图标
|
||||||
|
*/
|
||||||
|
void MainWindow::registerTrayIcon()
|
||||||
|
{
|
||||||
|
m_registerCount++;
|
||||||
|
if (QSystemTrayIcon::isSystemTrayAvailable() || m_registerCount > 10) {
|
||||||
|
m_trayIcon = new QSystemTrayIcon();
|
||||||
|
if (nullptr == m_trayIcon) {
|
||||||
|
qWarning()<< "分配空间trayIcon失败";
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||||
|
m_trayIcon->setToolTip(QString(tr("kylin-nm")));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (m_registerCount <= 10) {
|
||||||
|
QTimer::singleShot(m_intervalTime,[this] {
|
||||||
|
registerTrayIcon();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::paintEvent(QPaintEvent *event)
|
void MainWindow::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
@ -325,7 +350,6 @@ void MainWindow::initTrayIcon()
|
||||||
iconTimer = new QTimer(this);
|
iconTimer = new QTimer(this);
|
||||||
connect(iconTimer, &QTimer::timeout, this, &MainWindow::onSetTrayIconLoading);
|
connect(iconTimer, &QTimer::timeout, this, &MainWindow::onSetTrayIconLoading);
|
||||||
|
|
||||||
m_trayIcon = new QSystemTrayIcon();
|
|
||||||
m_trayIconMenu = new QMenu();
|
m_trayIconMenu = new QMenu();
|
||||||
m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
|
m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
|
||||||
m_showSettingsAction = new QAction(tr("Settings"),this);
|
m_showSettingsAction = new QAction(tr("Settings"),this);
|
||||||
|
@ -334,7 +358,6 @@ void MainWindow::initTrayIcon()
|
||||||
// m_trayIconMenu->addAction(m_showMainwindowAction);
|
// m_trayIconMenu->addAction(m_showMainwindowAction);
|
||||||
m_trayIconMenu->addAction(m_showSettingsAction);
|
m_trayIconMenu->addAction(m_showSettingsAction);
|
||||||
m_trayIcon->setContextMenu(m_trayIconMenu);
|
m_trayIcon->setContextMenu(m_trayIconMenu);
|
||||||
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
|
||||||
iconStatus = IconActiveType::LAN_CONNECTED;
|
iconStatus = IconActiveType::LAN_CONNECTED;
|
||||||
onRefreshTrayIcon();
|
onRefreshTrayIcon();
|
||||||
|
|
||||||
|
@ -994,6 +1017,7 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
|
||||||
});
|
});
|
||||||
m_createPagePtrMap.insert(devName, netDetail);
|
m_createPagePtrMap.insert(devName, netDetail);
|
||||||
netDetail->show();
|
netDetail->show();
|
||||||
|
netDetail->centerToScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showAddOtherWlanWidget(QString devName)
|
void MainWindow::showAddOtherWlanWidget(QString devName)
|
||||||
|
|
|
@ -155,6 +155,7 @@ private:
|
||||||
void paintWithTrans();
|
void paintWithTrans();
|
||||||
void initUI();
|
void initUI();
|
||||||
void initDbusConnnect();
|
void initDbusConnnect();
|
||||||
|
void registerTrayIcon();
|
||||||
void initTrayIcon();
|
void initTrayIcon();
|
||||||
|
|
||||||
void resetTrayIconTool();
|
void resetTrayIconTool();
|
||||||
|
@ -205,6 +206,9 @@ private:
|
||||||
|
|
||||||
NetworkMode *m_networkMode;
|
NetworkMode *m_networkMode;
|
||||||
|
|
||||||
|
uint m_intervalTime = 100;
|
||||||
|
uint m_registerCount = 0;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onShowMainWindow(int type);
|
void onShowMainWindow(int type);
|
||||||
|
|
||||||
|
|
|
@ -288,3 +288,18 @@ void JoinHiddenWiFiPage::onPaletteChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void JoinHiddenWiFiPage::centerToScreen()
|
||||||
|
{
|
||||||
|
QDesktopWidget* m = QApplication::desktop();
|
||||||
|
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
|
||||||
|
int desk_x = desk_rect.width();
|
||||||
|
int desk_y = desk_rect.height();
|
||||||
|
int x = this->width();
|
||||||
|
int y = this->height();
|
||||||
|
// this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
||||||
|
kdk::WindowManager::setGeometry(this->windowHandle(), QRect(desk_x / 2 - x / 2 + desk_rect.left(),
|
||||||
|
desk_y / 2 - y / 2 + desk_rect.top(),
|
||||||
|
this->width(),
|
||||||
|
this->height()));
|
||||||
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
|
#include "windowmanager/windowmanager.h"
|
||||||
#include "coninfo.h"
|
#include "coninfo.h"
|
||||||
#include "kywirelessconnectoperation.h"
|
#include "kywirelessconnectoperation.h"
|
||||||
#include "securitypage.h"
|
#include "securitypage.h"
|
||||||
|
@ -43,6 +45,7 @@ public:
|
||||||
JoinHiddenWiFiPage(QString devName, KDialog *parent = nullptr);
|
JoinHiddenWiFiPage(QString devName, KDialog *parent = nullptr);
|
||||||
~JoinHiddenWiFiPage();
|
~JoinHiddenWiFiPage();
|
||||||
|
|
||||||
|
void centerToScreen();
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
|
|
@ -293,11 +293,10 @@ void NetDetail::centerToScreen()
|
||||||
int desk_y = desk_rect.height();
|
int desk_y = desk_rect.height();
|
||||||
int x = this->width();
|
int x = this->width();
|
||||||
int y = this->height();
|
int y = this->height();
|
||||||
this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
kdk::WindowManager::setGeometry(this->windowHandle(), QRect(desk_x / 2 - x / 2 + desk_rect.left(),
|
||||||
// kdk::WindowManager::setGeometry(this->windowHandle(), QRect(desk_x / 2 - x / 2 + desk_rect.left(),
|
desk_y / 2 - y / 2 + desk_rect.top(),
|
||||||
// desk_y / 2 - y / 2 + desk_rect.top(),
|
this->width(),
|
||||||
// this->width(),
|
this->height()));
|
||||||
// this->height()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDetail::initUI()
|
void NetDetail::initUI()
|
||||||
|
|
|
@ -97,13 +97,14 @@ public:
|
||||||
NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent = nullptr);
|
NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent = nullptr);
|
||||||
~NetDetail();
|
~NetDetail();
|
||||||
|
|
||||||
|
void centerToScreen();
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
bool eventFilter(QObject *w, QEvent *event);
|
bool eventFilter(QObject *w, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
void centerToScreen();
|
|
||||||
void initComponent();
|
void initComponent();
|
||||||
void getConInfo(ConInfo &conInfo);
|
void getConInfo(ConInfo &conInfo);
|
||||||
void loadPage();
|
void loadPage();
|
||||||
|
|
|
@ -1276,6 +1276,7 @@ void LanPage::showDetailPage(QString devName, QString uuid)
|
||||||
NetDetail *netDetail = new NetDetail(devName, p_item->m_connectName, uuid, isActive, false, false);
|
NetDetail *netDetail = new NetDetail(devName, p_item->m_connectName, uuid, isActive, false, false);
|
||||||
m_lanPagePtrMap.insert(p_item->m_connectPath, netDetail);
|
m_lanPagePtrMap.insert(p_item->m_connectPath, netDetail);
|
||||||
netDetail->show();
|
netDetail->show();
|
||||||
|
netDetail->centerToScreen();
|
||||||
|
|
||||||
connect(netDetail, &NetDetail::detailPageClose, [&](QString deviceName, QString lanName, QString lanUuid){
|
connect(netDetail, &NetDetail::detailPageClose, [&](QString deviceName, QString lanName, QString lanUuid){
|
||||||
if (lanUuid.isEmpty()) {
|
if (lanUuid.isEmpty()) {
|
||||||
|
|
|
@ -1632,6 +1632,7 @@ void WlanPage::showHiddenWlanPage(QString devName)
|
||||||
|
|
||||||
m_joinHiddenWiFiPagePtrMap.insert(devName, hiddenWiFi);
|
m_joinHiddenWiFiPagePtrMap.insert(devName, hiddenWiFi);
|
||||||
hiddenWiFi->show();
|
hiddenWiFi->show();
|
||||||
|
hiddenWiFi->centerToScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WlanPage::showDetailPage(QString devName, QString ssid)
|
void WlanPage::showDetailPage(QString devName, QString ssid)
|
||||||
|
@ -1661,6 +1662,7 @@ void WlanPage::showDetailPage(QString devName, QString ssid)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
netDetail->show();
|
netDetail->show();
|
||||||
|
netDetail->centerToScreen();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue