fix: 修复打开开始菜单会在任务栏出现图标问题,更新翻译
This commit is contained in:
parent
78afa17953
commit
d8a63029d7
|
@ -21,6 +21,7 @@ find_package(Qt${QT_VERSION_MAJOR}
|
||||||
# see: https://api.kde.org/frameworks/index.html > KWindowSystem
|
# see: https://api.kde.org/frameworks/index.html > KWindowSystem
|
||||||
find_package(KF5WindowSystem REQUIRED)
|
find_package(KF5WindowSystem REQUIRED)
|
||||||
find_package(Qt5Xdg REQUIRED)
|
find_package(Qt5Xdg REQUIRED)
|
||||||
|
find_package(ukui-quick COMPONENTS platform REQUIRED)
|
||||||
|
|
||||||
# 查找其他组件
|
# 查找其他组件
|
||||||
# see: https://cmake.org/cmake/help/v3.16/module/FindPkgConfig.html
|
# see: https://cmake.org/cmake/help/v3.16/module/FindPkgConfig.html
|
||||||
|
@ -29,7 +30,7 @@ find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
set(UKUI_MENU_EXTERNAL_LIBS "")
|
set(UKUI_MENU_EXTERNAL_LIBS "")
|
||||||
# glib-2.0 gio-unix-2.0 gsettings-qt x11 kysdk-waylandhelper
|
# 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})
|
foreach(external_lib IN ITEMS ${UKUI_MENU_PC_PKGS})
|
||||||
pkg_check_modules(${external_lib} REQUIRED ${external_lib})
|
pkg_check_modules(${external_lib} REQUIRED ${external_lib})
|
||||||
|
@ -202,6 +203,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||||
${SingleApplication}
|
${SingleApplication}
|
||||||
${UKUI_MENU_EXTERNAL_LIBS}
|
${UKUI_MENU_EXTERNAL_LIBS}
|
||||||
${UKUI_MENU_LIBRARY_TARGET}
|
${UKUI_MENU_LIBRARY_TARGET}
|
||||||
|
ukui-quick::platform
|
||||||
)
|
)
|
||||||
|
|
||||||
# 安装ukui-menu
|
# 安装ukui-menu
|
||||||
|
|
|
@ -153,7 +153,7 @@ Item {
|
||||||
Layout.preferredHeight: 36
|
Layout.preferredHeight: 36
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
||||||
UkuiItems.ToolTip.text: qsTr("Applications System")
|
UkuiItems.ToolTip.text: qsTr("Control center")
|
||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
UkuiItems.ToolTip.show(setButton.mapToGlobal(0, setButton.height));
|
UkuiItems.ToolTip.show(setButton.mapToGlobal(0, setButton.height));
|
||||||
|
|
|
@ -64,7 +64,7 @@ Item {
|
||||||
width: mainWindow.isFullScreen ? root.width : normalGeometry.width
|
width: mainWindow.isFullScreen ? root.width : normalGeometry.width
|
||||||
radius: mainWindow.isFullScreen ? 0 : Platform.Theme.windowRadius
|
radius: mainWindow.isFullScreen ? 0 : Platform.Theme.windowRadius
|
||||||
|
|
||||||
border.width: 1
|
border.width: mainWindow.isFullScreen ? 0 : 1
|
||||||
borderColor: Platform.Theme.Text
|
borderColor: Platform.Theme.Text
|
||||||
borderAlpha: 0.15
|
borderAlpha: 0.15
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "context-menu-manager.h"
|
#include "context-menu-manager.h"
|
||||||
|
|
||||||
|
#include <ukui-quick/window-helper.h>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QGSettings>
|
#include <QGSettings>
|
||||||
|
@ -31,32 +32,12 @@
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include <QTimer>
|
#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_SETTING "org.ukui.panel.settings"
|
||||||
#define UKUI_PANEL_POSITION_KEY "panelposition"
|
#define UKUI_PANEL_POSITION_KEY "panelposition"
|
||||||
#define UKUI_PANEL_SIZE_KEY "panelsize"
|
#define UKUI_PANEL_SIZE_KEY "panelsize"
|
||||||
|
|
||||||
namespace UkuiMenu {
|
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)
|
void WindowModule::defineModule(const char *uri, int versionMajor, int versionMinor)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
@ -77,57 +58,6 @@ void WindowModule::defineModule(const char *uri, int versionMajor, int versionMi
|
||||||
#endif
|
#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 ®ion)
|
void WindowHelper::windowBlur(QWindow *window, bool enable, const QRegion ®ion)
|
||||||
{
|
{
|
||||||
if (!window) {
|
if (!window) {
|
||||||
|
@ -164,8 +94,8 @@ void WindowGeometryHelper::updateGeometry()
|
||||||
if (!m_primaryScreen) {
|
if (!m_primaryScreen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QRect screenRect = m_primaryScreen->geometry(), normalMaskRect, fullRect;
|
|
||||||
|
|
||||||
|
QRect screenRect = m_primaryScreen->geometry(), normalMaskRect, fullRect;
|
||||||
int width = MenuSetting::instance()->get(MENU_WIDTH).toInt();
|
int width = MenuSetting::instance()->get(MENU_WIDTH).toInt();
|
||||||
int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt();
|
int height = MenuSetting::instance()->get(MENU_HEIGHT).toInt();
|
||||||
int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt();
|
int margin = MenuSetting::instance()->get(MENU_MARGIN).toInt();
|
||||||
|
@ -275,7 +205,7 @@ void WindowGeometryHelper::updatePrimaryScreen(QScreen *screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_primaryScreen) {
|
if (m_primaryScreen) {
|
||||||
disconnect(m_primaryScreen);
|
m_primaryScreen->disconnect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_primaryScreen = screen;
|
m_primaryScreen = screen;
|
||||||
|
@ -315,10 +245,10 @@ void MenuWindow::init()
|
||||||
setResizeMode(SizeRootObjectToView);
|
setResizeMode(SizeRootObjectToView);
|
||||||
setColor("transparent");
|
setColor("transparent");
|
||||||
|
|
||||||
// setFlags(Qt::FramelessWindowHint);
|
//setWindowState(Qt::WindowMaximized);
|
||||||
setFlags(Qt::Window);
|
setFlags(flags() | Qt::Window | Qt::FramelessWindowHint);
|
||||||
WindowHelper::setWindowAttribute(this);
|
new UkuiQuick::WindowProxy(this, UkuiQuick::WindowProxy::SkipSwitcher | UkuiQuick::WindowProxy::SkipTaskBar);
|
||||||
WindowHelper::removeHeaderBar(this);
|
KWindowSystem::setType(winId(), NET::SystemWindow);
|
||||||
|
|
||||||
// 访问窗口api
|
// 访问窗口api
|
||||||
rootContext()->setContextProperty("mainWindow", this);
|
rootContext()->setContextProperty("mainWindow", this);
|
||||||
|
@ -348,12 +278,9 @@ void MenuWindow::init()
|
||||||
|
|
||||||
void MenuWindow::updateGeometry()
|
void MenuWindow::updateGeometry()
|
||||||
{
|
{
|
||||||
QRect rect = m_geometryHelper->fullScreenGeometry();
|
UkuiQuick::WindowProxy::setWindowGeometry(this, m_geometryHelper->fullScreenGeometry());
|
||||||
if (rect != geometry()) {
|
|
||||||
WindowHelper::setWindowGeometry(this, rect);
|
|
||||||
setMinimumSize(geometry().size());
|
setMinimumSize(geometry().size());
|
||||||
setMaximumSize(geometry().size());
|
setMaximumSize(geometry().size());
|
||||||
}
|
|
||||||
|
|
||||||
updateGeometryOfMask();
|
updateGeometryOfMask();
|
||||||
WindowHelper::setRegion(this, m_maskGeometry.x(), m_maskGeometry.y(), m_maskGeometry.width(), m_maskGeometry.height(), 16);
|
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)
|
void MenuWindow::exposeEvent(QExposeEvent *event)
|
||||||
{
|
{
|
||||||
if (isExposed()) {
|
|
||||||
if (QX11Info::isPlatformX11()) {
|
|
||||||
requestActivate();
|
|
||||||
}
|
|
||||||
// WindowHelper::removeHeaderBar(this);
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
QQuickView::exposeEvent(event);
|
QQuickView::exposeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,25 +340,20 @@ bool MenuWindow::event(QEvent *event)
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event->type() == QEvent::UpdateRequest) {
|
|
||||||
WindowHelper::removeHeaderBar(this);
|
if (event->type() == QEvent::Show) {
|
||||||
|
KWindowSystem::setType(winId(), NET::SystemWindow);
|
||||||
|
updateGeometry();
|
||||||
|
if (QX11Info::isPlatformX11()) {
|
||||||
|
requestActivate();
|
||||||
}
|
}
|
||||||
if (event->type() == QEvent::MouseButtonPress) {
|
} else if (event->type() == QEvent::MouseButtonPress) {
|
||||||
ContextMenuManager::instance()->closeMenu();
|
ContextMenuManager::instance()->closeMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QQuickView::event(event);
|
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
|
bool MenuWindow::effectEnabled() const
|
||||||
{
|
{
|
||||||
return GlobalSetting::instance()->get(GlobalSetting::EffectEnabled).toBool();
|
return GlobalSetting::instance()->get(GlobalSetting::EffectEnabled).toBool();
|
||||||
|
|
|
@ -36,9 +36,6 @@ public:
|
||||||
class WindowHelper final
|
class WindowHelper final
|
||||||
{
|
{
|
||||||
public:
|
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 ®ion = QRegion());
|
static void windowBlur(QWindow *window, bool enable, const QRegion ®ion = QRegion());
|
||||||
static void setRegion(QWindow *window, qreal x, qreal y, qreal w, qreal h, qreal radius);
|
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 exposeEvent(QExposeEvent *event) override;
|
||||||
void focusOutEvent(QFocusEvent *event) override;
|
void focusOutEvent(QFocusEvent *event) override;
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
void showEvent(QShowEvent *event) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
Loading…
Reference in New Issue