fix: 修复打开开始菜单会在任务栏出现图标问题,更新翻译

This commit is contained in:
hewenfei 2024-03-07 20:29:07 +08:00 committed by He Sir
parent 78afa17953
commit d8a63029d7
5 changed files with 23 additions and 110 deletions

View File

@ -21,6 +21,7 @@ find_package(Qt${QT_VERSION_MAJOR}
# see: https://api.kde.org/frameworks/index.html > KWindowSystem
find_package(KF5WindowSystem REQUIRED)
find_package(Qt5Xdg REQUIRED)
find_package(ukui-quick COMPONENTS platform REQUIRED)
#
# see: https://cmake.org/cmake/help/v3.16/module/FindPkgConfig.html
@ -29,7 +30,7 @@ find_package(PkgConfig REQUIRED)
set(UKUI_MENU_EXTERNAL_LIBS "")
# glib-2.0 gio-unix-2.0 gsettings-qt x11 kysdk-waylandhelper
set(UKUI_MENU_PC_PKGS gsettings-qt x11 kysdk-waylandhelper ukui-search kysdk-datacollect)
set(UKUI_MENU_PC_PKGS gsettings-qt ukui-search kysdk-datacollect)
foreach(external_lib IN ITEMS ${UKUI_MENU_PC_PKGS})
pkg_check_modules(${external_lib} REQUIRED ${external_lib})
@ -202,6 +203,7 @@ target_link_libraries(${PROJECT_NAME}
${SingleApplication}
${UKUI_MENU_EXTERNAL_LIBS}
${UKUI_MENU_LIBRARY_TARGET}
ukui-quick::platform
)
# ukui-menu

View File

@ -153,7 +153,7 @@ Item {
Layout.preferredHeight: 36
Layout.alignment: Qt.AlignHCenter
UkuiItems.ToolTip.text: qsTr("Applications System")
UkuiItems.ToolTip.text: qsTr("Control center")
onEntered: {
UkuiItems.ToolTip.show(setButton.mapToGlobal(0, setButton.height));

View File

@ -64,7 +64,7 @@ Item {
width: mainWindow.isFullScreen ? root.width : normalGeometry.width
radius: mainWindow.isFullScreen ? 0 : Platform.Theme.windowRadius
border.width: 1
border.width: mainWindow.isFullScreen ? 0 : 1
borderColor: Platform.Theme.Text
borderAlpha: 0.15

View File

@ -20,6 +20,7 @@
#include "settings.h"
#include "context-menu-manager.h"
#include <ukui-quick/window-helper.h>
#include <QGuiApplication>
#include <QQuickItem>
#include <QGSettings>
@ -31,32 +32,12 @@
#include <QPainterPath>
#include <QTimer>
// kysdk
#include <kysdk/applications/windowmanager/windowmanager.h>
#include <kysdk/applications/ukuistylehelper/ukui-decoration-manager.h>
// x11
#include <X11/Xlib.h>
#define UKUI_PANEL_SETTING "org.ukui.panel.settings"
#define UKUI_PANEL_POSITION_KEY "panelposition"
#define UKUI_PANEL_SIZE_KEY "panelsize"
namespace UkuiMenu {
struct MotifWmHints {
ulong flags = 0;
ulong functions = 0;
ulong decorations = 0;
long input_mode = 0;
ulong status = 0;
};
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
void WindowModule::defineModule(const char *uri, int versionMajor, int versionMinor)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
@ -77,57 +58,6 @@ void WindowModule::defineModule(const char *uri, int versionMajor, int versionMi
#endif
}
void WindowHelper::setWindowGeometry(QWindow *window, const QRect &rect)
{
if (!window) {
return;
}
// 窗口系统不存在跟屏幕一样大的普通窗口?
window->setWindowState(Qt::WindowNoState);
if (QX11Info::isPlatformX11()) {
window->setGeometry(rect);
} else {
kdk::WindowManager::setGeometry(window, rect);
}
}
// 窗口管理器属性
void WindowHelper::setWindowAttribute(QWindow *window)
{
if (!window) {
return;
}
// kwin
KWindowSystem::setType(window->winId(), NET::SystemWindow);
// 设置跳过多任务视图,设置跳过任务栏
kdk::WindowManager::setSkipTaskBar(window, true);
kdk::WindowManager::setSkipSwitcher(window, true);
}
void WindowHelper::removeHeaderBar(QWindow *window)
{
if (!window) {
return;
}
if (QX11Info::isPlatformX11()) {
MotifWmHints hints;
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
hints.functions = MWM_FUNC_ALL;
hints.decorations = MWM_DECOR_BORDER;
unsigned long atom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true);
XChangeProperty(QX11Info::display(), window->winId(), atom, atom, 32, XCB_PROP_MODE_REPLACE,
(const unsigned char *)&hints, sizeof(MotifWmHints) / sizeof(const unsigned char));
} else {
UKUIDecorationManager::getInstance()->removeHeaderBar(window);
}
}
void WindowHelper::windowBlur(QWindow *window, bool enable, const QRegion &region)
{
if (!window) {
@ -164,8 +94,8 @@ void WindowGeometryHelper::updateGeometry()
if (!m_primaryScreen) {
return;
}
QRect screenRect = m_primaryScreen->geometry(), normalMaskRect, fullRect;
QRect screenRect = m_primaryScreen->geometry(), normalMaskRect, fullRect;
int width = MenuSetting::instance()->get(MENU_WIDTH).toInt();
int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt();
int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt();
@ -275,7 +205,7 @@ void WindowGeometryHelper::updatePrimaryScreen(QScreen *screen)
}
if (m_primaryScreen) {
disconnect(m_primaryScreen);
m_primaryScreen->disconnect(this);
}
m_primaryScreen = screen;
@ -315,10 +245,10 @@ void MenuWindow::init()
setResizeMode(SizeRootObjectToView);
setColor("transparent");
// setFlags(Qt::FramelessWindowHint);
setFlags(Qt::Window);
WindowHelper::setWindowAttribute(this);
WindowHelper::removeHeaderBar(this);
//setWindowState(Qt::WindowMaximized);
setFlags(flags() | Qt::Window | Qt::FramelessWindowHint);
new UkuiQuick::WindowProxy(this, UkuiQuick::WindowProxy::SkipSwitcher | UkuiQuick::WindowProxy::SkipTaskBar);
KWindowSystem::setType(winId(), NET::SystemWindow);
// 访问窗口api
rootContext()->setContextProperty("mainWindow", this);
@ -348,12 +278,9 @@ void MenuWindow::init()
void MenuWindow::updateGeometry()
{
QRect rect = m_geometryHelper->fullScreenGeometry();
if (rect != geometry()) {
WindowHelper::setWindowGeometry(this, rect);
setMinimumSize(geometry().size());
setMaximumSize(geometry().size());
}
UkuiQuick::WindowProxy::setWindowGeometry(this, m_geometryHelper->fullScreenGeometry());
setMinimumSize(geometry().size());
setMaximumSize(geometry().size());
updateGeometryOfMask();
WindowHelper::setRegion(this, m_maskGeometry.x(), m_maskGeometry.y(), m_maskGeometry.width(), m_maskGeometry.height(), 16);
@ -397,13 +324,6 @@ void MenuWindow::exitFullScreen()
void MenuWindow::exposeEvent(QExposeEvent *event)
{
if (isExposed()) {
if (QX11Info::isPlatformX11()) {
requestActivate();
}
// WindowHelper::removeHeaderBar(this);
updateGeometry();
}
QQuickView::exposeEvent(event);
}
@ -420,25 +340,20 @@ bool MenuWindow::event(QEvent *event)
updateGeometry();
return true;
}
if (event->type() == QEvent::UpdateRequest) {
WindowHelper::removeHeaderBar(this);
}
if (event->type() == QEvent::MouseButtonPress) {
if (event->type() == QEvent::Show) {
KWindowSystem::setType(winId(), NET::SystemWindow);
updateGeometry();
if (QX11Info::isPlatformX11()) {
requestActivate();
}
} else if (event->type() == QEvent::MouseButtonPress) {
ContextMenuManager::instance()->closeMenu();
}
return QQuickView::event(event);
}
void MenuWindow::showEvent(QShowEvent *event)
{
//为了主动触发一次updaterequet事件
update();
QQuickView::showEvent(event);
QTimer::singleShot(1,this,[=](){WindowHelper::setWindowAttribute(this);});
}
bool MenuWindow::effectEnabled() const
{
return GlobalSetting::instance()->get(GlobalSetting::EffectEnabled).toBool();

View File

@ -36,9 +36,6 @@ public:
class WindowHelper final
{
public:
static void setWindowGeometry(QWindow *window, const QRect &rect);
static void setWindowAttribute(QWindow *window);
static void removeHeaderBar(QWindow *window);
static void windowBlur(QWindow *window, bool enable, const QRegion &region = QRegion());
static void setRegion(QWindow *window, qreal x, qreal y, qreal w, qreal h, qreal radius);
};
@ -116,7 +113,6 @@ protected:
void exposeEvent(QExposeEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
bool event(QEvent *event) override;
void showEvent(QShowEvent *event) override;
private:
void init();