wayland适配

This commit is contained in:
jzxc95 2022-06-14 09:51:14 +08:00
parent 68bbfe675c
commit 8c4bdd2de4
4 changed files with 37 additions and 17 deletions

2
debian/control vendored
View File

@ -25,6 +25,7 @@ Build-Depends: debhelper (>=9),
libukui-log4qt-dev,
libkysdk-qtwidgets-dev(>= 1.2.0),
libukui-common-dev,
libkysdk-waylandhelper-dev(>= 1.2.0kylin2),
libkysec-dev,
Standards-Version: 4.5.0
Rules-Requires-Root: no
@ -37,6 +38,7 @@ Architecture: any
Depends: network-manager (>=1.2.6),
ukui-control-center (>= 3.1.1+1217),
libkysdk-qtwidgets(>= 1.2.0),
libkysdk-waylandhelper(>= 1.2.0kylin2),
${shlibs:Depends},
${misc:Depends}
Description: Gui Applet tool for display and edit network simply

View File

@ -10,6 +10,9 @@
#include "kylinnetworkdeviceresource.h"
#include "../backend/dbus-interface/kylinagentinterface.h"
#include "ukuistylehelper/ukuistylehelper.h"
#include "windowmanager/windowmanager.h"
#define MAINWINDOW_WIDTH 420
#define MAINWINDOW_HEIGHT 476
@ -49,8 +52,7 @@ void MainWindow::showMainwindow()
KWindowSystem::setState(this->winId(), NET::SkipTaskbar | NET::SkipPager);
}
this->resetWindowPosition();
this->showNormal();
this->showByWaylandHelper();
this->raise();
this->activateWindow();
emit this->mainWindowVisibleChanged(true);
@ -335,7 +337,10 @@ void MainWindow::resetWindowPosition()
if (m_isShowInCenter) {
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
this->move((availableGeometry.width() - this->width())/2, (availableGeometry.height() - this->height())/2);
QRect rect((availableGeometry.width() - this->width())/2, (availableGeometry.height() - this->height())/2,
this->width(), this->height());
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
return;
}
@ -350,11 +355,12 @@ void MainWindow::resetWindowPosition()
"org.ukui.panel",
QDBusConnection::sessionBus());
}
QRect rect;
QDBusReply<QVariantList> reply = m_positionInterface->call("GetPrimaryScreenGeometry");
//reply获取的参数共5个分别是 主屏可用区域的起点x坐标主屏可用区域的起点y坐标主屏可用区域的宽度主屏可用区域高度任务栏位置
if (!m_positionInterface->isValid() || !reply.isValid() || reply.value().size() < 5) {
qCritical() << QDBusConnection::sessionBus().lastError().message();
this->setGeometry(0, 0, this->width(), this->height());
kdk::WindowManager::setGeometry(this->windowHandle(), QRect(0, 0, this->width(), this->height()));
return;
}
QVariantList position_list = reply.value();
@ -362,29 +368,30 @@ void MainWindow::resetWindowPosition()
switch(position){
case PANEL_TOP:
//任务栏位于上方
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + MARGIN,
this->width(), this->height());
rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + MARGIN,
this->width(), this->height());
break;
//任务栏位于左边
case PANEL_LEFT:
this->setGeometry(position_list.at(0).toInt() + MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
rect = QRect(position_list.at(0).toInt() + MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
//任务栏位于右边
case PANEL_RIGHT:
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
//任务栏位于下方
default:
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
}
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
qDebug() << " Position of ukui-panel is " << position << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__;
}
@ -461,6 +468,16 @@ void MainWindow::showControlCenter()
}
}
void MainWindow::showByWaylandHelper()
{
//去除窗管标题栏传入参数为QWidget*
kdk::UkuiStyleHelper::self()->removeHeader(this);
this->show();
resetWindowPosition();
//设置窗体位置传入参数为QWindow*QRect
}
/**
* @brief MainWindow::onTrayIconActivated
*/

View File

@ -126,6 +126,7 @@ private:
void initWindowTheme();
void resetWindowTheme();
void showControlCenter();
void showByWaylandHelper();
double m_transparency=1.0; //透明度
QGSettings * m_transGsettings; //透明度配置文件
int currentIconIndex=0;

View File

@ -14,7 +14,7 @@ TEMPLATE = app
CONFIG += c++14 qt warn_on link_pkgconfig
#CONFIG += release
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap kysdk-qtwidgets
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap kysdk-qtwidgets kysdk-waylandhelper
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt