commit
78a0fc2f93
|
@ -45,11 +45,11 @@ VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
|
|||
connect(m_vpnConnectOperation, &KyVpnConnectOperation::activateConnectionError, this, &VpnPage::activateFailed);
|
||||
connect(m_vpnConnectOperation, &KyVpnConnectOperation::deactivateConnectionError, this, &VpnPage::deactivateFailed);
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, [&](WId activeWindowId){
|
||||
if (activeWindowId != this->winId() && activeWindowId != 0) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
// connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, [&](WId activeWindowId){
|
||||
// if (activeWindowId != this->winId() && activeWindowId != 0) {
|
||||
// hide();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
VpnPage::~VpnPage()
|
||||
|
@ -575,6 +575,16 @@ bool VpnPage::eventFilter(QObject *watched, QEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
if (watched == this) {
|
||||
//失焦退出
|
||||
if (event->type() == QEvent::ActivationChange) {
|
||||
if (QApplication::activeWindow() != this) {
|
||||
hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ void MainWindow::firstlyStart()
|
|||
initWindowTheme();
|
||||
initTrayIcon();
|
||||
initPlatform();
|
||||
installEventFilter(this);
|
||||
m_secondaryStartTimer = new QTimer(this);
|
||||
connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() {
|
||||
m_secondaryStartTimer->stop();
|
||||
|
@ -263,6 +264,21 @@ void MainWindow::paintEvent(QPaintEvent *event)
|
|||
// painter.drawRoundedRect(rect, 12, 12); //窗口圆角
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == this) {
|
||||
//失焦退出
|
||||
if (event->type() == QEvent::ActivationChange) {
|
||||
if (QApplication::activeWindow() != this) {
|
||||
hideMainwindow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void MainWindow::initTransparency()
|
||||
{
|
||||
if(QGSettings::isSchemaInstalled(TRANSPARENCY_GSETTINGS)) {
|
||||
|
@ -403,12 +419,6 @@ void MainWindow::initDbusConnnect()
|
|||
QString("/"),
|
||||
QString("com.kylin.statusmanager.interface"),
|
||||
QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this,[&](WId activeWindowId){
|
||||
if (activeWindowId != this->winId() && activeWindowId != 0) {
|
||||
hideMainwindow();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -144,6 +144,7 @@ public Q_SLOTS:
|
|||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
void firstlyStart(); //一级启动
|
||||
|
|
Loading…
Reference in New Issue