merge:合并openkylin代码
This commit is contained in:
parent
c051d72b6b
commit
b8b1eef135
|
@ -154,6 +154,7 @@ void MainWindow::firstlyStart()
|
|||
{
|
||||
initWindowProperties();
|
||||
initTransparency();
|
||||
registerTrayIcon();
|
||||
initUI();
|
||||
initDbusConnnect();
|
||||
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)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
@ -325,7 +350,6 @@ void MainWindow::initTrayIcon()
|
|||
iconTimer = new QTimer(this);
|
||||
connect(iconTimer, &QTimer::timeout, this, &MainWindow::onSetTrayIconLoading);
|
||||
|
||||
m_trayIcon = new QSystemTrayIcon();
|
||||
m_trayIconMenu = new QMenu();
|
||||
m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
|
||||
m_showSettingsAction = new QAction(tr("Settings"),this);
|
||||
|
@ -334,7 +358,6 @@ void MainWindow::initTrayIcon()
|
|||
// m_trayIconMenu->addAction(m_showMainwindowAction);
|
||||
m_trayIconMenu->addAction(m_showSettingsAction);
|
||||
m_trayIcon->setContextMenu(m_trayIconMenu);
|
||||
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||
iconStatus = IconActiveType::LAN_CONNECTED;
|
||||
onRefreshTrayIcon();
|
||||
|
||||
|
@ -994,6 +1017,7 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
|
|||
});
|
||||
m_createPagePtrMap.insert(devName, netDetail);
|
||||
netDetail->show();
|
||||
netDetail->centerToScreen();
|
||||
}
|
||||
|
||||
void MainWindow::showAddOtherWlanWidget(QString devName)
|
||||
|
|
|
@ -155,6 +155,7 @@ private:
|
|||
void paintWithTrans();
|
||||
void initUI();
|
||||
void initDbusConnnect();
|
||||
void registerTrayIcon();
|
||||
void initTrayIcon();
|
||||
|
||||
void resetTrayIconTool();
|
||||
|
@ -205,6 +206,9 @@ private:
|
|||
|
||||
NetworkMode *m_networkMode;
|
||||
|
||||
uint m_intervalTime = 100;
|
||||
uint m_registerCount = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onShowMainWindow(int type);
|
||||
|
||||
|
|
|
@ -288,3 +288,18 @@ void JoinHiddenWiFiPage::onPaletteChanged()
|
|||
}
|
||||
}
|
||||
#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 <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#include "windowmanager/windowmanager.h"
|
||||
#include "coninfo.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "securitypage.h"
|
||||
|
@ -43,6 +45,7 @@ public:
|
|||
JoinHiddenWiFiPage(QString devName, KDialog *parent = nullptr);
|
||||
~JoinHiddenWiFiPage();
|
||||
|
||||
void centerToScreen();
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
|
|
|
@ -293,11 +293,10 @@ void NetDetail::centerToScreen()
|
|||
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()));
|
||||
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()));
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
void centerToScreen();
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *w, QEvent *event);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void centerToScreen();
|
||||
void initComponent();
|
||||
void getConInfo(ConInfo &conInfo);
|
||||
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);
|
||||
m_lanPagePtrMap.insert(p_item->m_connectPath, netDetail);
|
||||
netDetail->show();
|
||||
netDetail->centerToScreen();
|
||||
|
||||
connect(netDetail, &NetDetail::detailPageClose, [&](QString deviceName, QString lanName, QString lanUuid){
|
||||
if (lanUuid.isEmpty()) {
|
||||
|
|
|
@ -1632,6 +1632,7 @@ void WlanPage::showHiddenWlanPage(QString devName)
|
|||
|
||||
m_joinHiddenWiFiPagePtrMap.insert(devName, hiddenWiFi);
|
||||
hiddenWiFi->show();
|
||||
hiddenWiFi->centerToScreen();
|
||||
}
|
||||
|
||||
void WlanPage::showDetailPage(QString devName, QString ssid)
|
||||
|
@ -1661,6 +1662,7 @@ void WlanPage::showDetailPage(QString devName, QString ssid)
|
|||
}
|
||||
});
|
||||
netDetail->show();
|
||||
netDetail->centerToScreen();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue