diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index 0a0b7883..26e766b4 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -508,7 +508,7 @@ void MainWindow::showByWaylandHelper() //去除窗管标题栏,传入参数为QWidget* kdk::UkuiStyleHelper::self()->removeHeader(this); this->show(); - initPlatform(); + getTabletMode(); resetWindowPosition(); //设置窗体位置,传入参数为QWindow*,QRect @@ -529,6 +529,29 @@ void MainWindow::setCentralWidgetType(IconActiveType iconStatus) } } +void MainWindow::getTabletMode() +{ + QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interfacer"), + QString("/"), + QString("qt5-ukui-platformtheme"), + QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool))); + + QDBusInterface interface(QString("com.kylin.statusmanager.interfacer"), + QString("/"), + QString("qt5-ukui-platformtheme"), + QDBusConnection::sessionBus); + if(!interface.isValid()) { + m_isShowInCenter = true; + return; + } + QDBusReply reply = interface->call("get_current_tabletmode"); + if (!reply.isValid()) { + m_isShowInCenter = true; + return; + } + m_isShowInCenter = reply.value(); +} + /** * @brief MainWindow::onTrayIconActivated 点击托盘图标的槽函数 */ diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index 59111d42..c5169274 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -161,6 +161,7 @@ private: void showControlCenter(); void showByWaylandHelper(); void setCentralWidgetType(IconActiveType iconStatus); + void getTabletMode(); double m_transparency=1.0; //透明度 QGSettings * m_transGsettings; //透明度配置文件 int currentIconIndex=0; diff --git a/src/frontend/vpnmainwindow.cpp b/src/frontend/vpnmainwindow.cpp index e9c9b591..e91a5ecb 100644 --- a/src/frontend/vpnmainwindow.cpp +++ b/src/frontend/vpnmainwindow.cpp @@ -120,7 +120,6 @@ void vpnMainWindow::firstlyStart() initDbusConnnect(); initWindowTheme(); initTrayIcon(); - initPlatform(); installEventFilter(this); m_secondaryStartTimer = new QTimer(this); connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() { @@ -428,6 +427,7 @@ void vpnMainWindow::showByWaylandHelper() //去除窗管标题栏,传入参数为QWidget* kdk::UkuiStyleHelper::self()->removeHeader(this); this->show(); + getTabletMode(); resetWindowPosition(); //设置窗体位置,传入参数为QWindow*,QRect @@ -448,6 +448,29 @@ void vpnMainWindow::setCentralWidgetType(IconActiveType iconStatus) } } +void vpnMainWindow::getTabletMode() +{ + QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interfacer"), + QString("/"), + QString("qt5-ukui-platformtheme"), + QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool))); + + QDBusInterface interface(QString("com.kylin.statusmanager.interfacer"), + QString("/"), + QString("qt5-ukui-platformtheme"), + QDBusConnection::sessionBus); + if(!interface.isValid()) { + m_isShowInCenter = true; + return; + } + QDBusReply reply = interface->call("get_current_tabletmode"); + if (!reply.isValid()) { + m_isShowInCenter = true; + return; + } + m_isShowInCenter = reply.value(); +} + /** * @brief vpnMainWindow::onTrayIconActivated 点击托盘图标的槽函数 */ diff --git a/src/frontend/vpnmainwindow.h b/src/frontend/vpnmainwindow.h index 4a898413..3dc6fc2c 100644 --- a/src/frontend/vpnmainwindow.h +++ b/src/frontend/vpnmainwindow.h @@ -111,6 +111,7 @@ private: // void showControlCenter(); void showByWaylandHelper(); void setCentralWidgetType(IconActiveType iconStatus); + void getTabletMode(); double m_transparency=1.0; //透明度 QGSettings * m_transGsettings; //透明度配置文件 int m_currentIconIndex = 0;