This commit is contained in:
xibowen 2024-02-04 12:14:07 +08:00
parent 8ce35a67d2
commit 6d032170e6
387 changed files with 40287 additions and 30370 deletions

View File

@ -1,14 +1,8 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
project(ukui-panel)
option(WITH_SCREENSAVER_FALLBACK "Include support for converting the deprecated 'screensaver' plugin to 'quicklaunch'. This requires the ukui-leave (ukui-session) to be installed in runtime." OFF)
#,gcc,c++11
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
message(STATUS "optional:-std=c++11")
endif(CMAKE_COMPILER_IS_GNUCXX)
# additional cmake files
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
@ -29,22 +23,14 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(REQUIRED_QT_VERSION "5.6.1")
set(KF5_MINIMUM_VERSION "5.18.0")
set(QT_MINIMUM_VERSION "5.6.1")
set(UKUI_MINIMUM_VERSION "0.14.1")
set(QTXDG_MINIMUM_VERSION "3.3.1")
find_package(Qt5DBus ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5LinguistTools ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED)
find_package(Qt5Xml ${REQUIRED_QT_VERSION} REQUIRED)
find_package(KF5WindowSystem ${KF5_MINIMUM_VERSION} REQUIRED)
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets DBus X11Extras LinguistTools)
find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Widgets Core Quick QuickWidgets DBus X11Extras LinguistTools Xml)
find_package(Qt5Xdg ${QTXDG_MINIMUM_VERSION} REQUIRED)
find_package(X11 REQUIRED)
find_package(Qt5LinguistTools)
find_package(PkgConfig)
pkg_check_modules(Gsetting REQUIRED gsettings-qt)
@ -113,23 +99,25 @@ endif()
setByDefault(SHOWDESKTOP_PLUGIN Yes)
if(SHOWDESKTOP_PLUGIN)
list(APPEND STATIC_PLUGINS "showdesktop")
add_definitions(-DWITH_SHOWDESKTOP_PLUGIN)
list(APPEND ENABLED_PLUGINS "Show Desktop")
add_subdirectory(plugin-showdesktop)
endif()
setByDefault(TASKBAR_PLUGIN Yes)
if(TASKBAR_PLUGIN)
list(APPEND ENABLED_PLUGINS "taskbar")
add_subdirectory(plugin-taskbar)
endif()
add_subdirectory(panel-daemon)
add_subdirectory(sni-daemon)
add_subdirectory(sni-xembed-proxy)
add_subdirectory(plugin-ukcc)
setByDefault(STATUSNOTIFIER_PLUGIN Yes)
if(STATUSNOTIFIER_PLUGIN)
list(APPEND STATIC_PLUGINS "statusnotifier")
add_definitions(-DWITH_STATUSNOTIFIER_PLUGIN)
list(APPEND ENABLED_PLUGINS "Status Notifier")
list(APPEND ENABLED_PLUGINS "statusnotifier")
add_subdirectory(plugin-statusnotifier)
endif()
@ -147,12 +135,6 @@ if(CALENDAR_PLUGIN)
add_subdirectory(plugin-calendar)
endif(CALENDAR_PLUGIN)
setByDefault(NIGHTMODE_PLUGIN Yes)
if(NIGHTMODE_PLUGIN)
list(APPEND ENABLED_PLUGINS "nightmode")
add_subdirectory(plugin-nightmode)
endif(NIGHTMODE_PLUGIN)
setByDefault(STARTBAR_PLUGIN Yes)
if(STARTBAR_PLUGIN)
list(APPEND ENABLED_PLUGINS "startbar")

View File

@ -15,7 +15,6 @@ ukui-panel contains the following plugins:
* taskbar
* statusnotifier
* calendar
* nightmode
* showdesktop ...
## Getting Started

View File

@ -61,7 +61,6 @@ MACRO (BUILD_UKUI_PLUGIN NAME)
${${PROJECT_NAME}_DESKTOP_FILES_IN}
)
ukui_plugin_translation_loader(QM_LOADER ${NAME} "ukui-panel")
#************************************************
file (GLOB CONFIG_FILES resources/*.conf)
@ -79,7 +78,7 @@ MACRO (BUILD_UKUI_PLUGIN NAME)
endif()
list(FIND STATIC_PLUGINS ${NAME} IS_STATIC)
set(SRC ${HEADERS} ${SOURCES} ${QM_LOADER} ${MOC_SOURCES} ${${PROJECT_NAME}_QM_FILES} ${RESOURCES} ${UIS} ${DESKTOP_FILES})
set(SRC ${HEADERS} ${SOURCES} ${QM_LOADER} ${MOC_SOURCES} ${${NAME}_QM_FILES} ${RESOURCES} ${UIS} ${DESKTOP_FILES})
if (${IS_STATIC} EQUAL -1) # not static
add_library(${NAME} MODULE ${SRC}) # build dynamically loadable modules
install(TARGETS ${NAME} DESTINATION ${PLUGIN_DIR}) # install the *.so file

224
debian/changelog vendored
View File

@ -1,101 +1,191 @@
ukui-panel (3.14.0.1-ok3.4) unstable; urgency=medium
ukui-panel (4.0.0.0-1) unstable; urgency=medium
* BUG:#130885 触摸长安容易同时出现日历和右键菜单
需求:无
其他改动:
其他改动说明:
* New upstream release.
-- zhangyinjie <zhangyinjie@kylinos.cn> Mon, 16 Jan 2023 16:53:40 +0800
-- xibowen <xibowen@kylinos.cn> Wed, 31 Jan 2024 15:58:14 +0800
ukui-panel (3.14.0.1-ok3.3) yangtze; urgency=medium
ukui-panel (3.0.6.4-2) unstable; urgency=medium
* fix position error bug
* d/control: switch build-depends from libsensors4-dev to
libsensors-dev. (Closes: #980733)
-- buxiaoqing <buxiaoqing@kylinos.cn> Fri, 06 Jan 2023 11:34:29 +0800
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 21 Aug 2023 16:10:45 +0800
ukui-panel (3.14.0.1-ok3.2) yangtze; urgency=medium
ukui-panel (3.0.6.4-1) unstable; urgency=medium
* fix two screens bug
* showdesktop button use SDK interface instead
* New upstream bugfix release. (LP: #1966864)
-- kylin <kylin@klyin> Thu, 05 Jan 2023 10:34:09 +0800
-- handsome_feng <jianfengli@ubuntukylin.com> Tue, 29 Mar 2022 14:56:10 +0800
ukui-panel (3.14.0.1-ok3.1) yangtze; urgency=medium
ukui-panel (3.0.6.3-1) unstable; urgency=medium
* TASK #I67H4F : 新增2023年节假日信息
* New upstream release.
-- Xin Li <lixin@kylinos.cn> Tue, 03 Jan 2023 17:06:27 +0800
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 21 Feb 2022 15:24:34 +0800
ukui-panel (3.14.0.1-ok3) yangtze; urgency=medium
ukui-panel (3.0.6-1) focal; urgency=medium
* 任务栏双屏适配改用KScreen监听屏幕的改变信号
* New upstream release.
-- buxiaoqing <buxiaoqing@kylinos.cn> Thu, 15 Dec 2022 17:06:27 +0800
-- Allen <zouchang@kylinos.cn> Thu, 04 Nov 2021 17:19:50 +0800
ukui-panel (3.0.5-1) unstable; urgency=medium
ukui-panel (3.14.0.1-ok2~0822) yangtze; urgency=medium
* New upstream bugfix release.
* 更新debian/control文件
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 27 Sep 2021 14:51:15 +0800
-- buxiaoqing <buxiaoqing@kylinos.cn> Wed, 03 Aug 2022 20:38:48 +0800
ukui-panel (3.0.4-1) unstable; urgency=medium
* New upstream release.
ukui-panel (3.14.0.1-ok2~0805) yangtze; urgency=medium
-- handsome_feng <jianfengli@ubuntukylin.com> Thu, 05 Aug 2021 14:32:40 +0800
* BUG:132829 使用过程中任务栏偏移到屏幕中间
* BUG:130980 125404 任务栏无法调整位置为上
其他改动:增加多任务试图需要屏蔽的中文名的窗口
其他改动影响域:对任务栏无影响,多任务视图多屏蔽了两个窗口
ukui-panel (3.0.3.1-1) unstable; urgency=medium
-- buxiaoqing <buxiaoqing@kylinos.cn> Wed, 03 Aug 2022 20:38:48 +0800
* Fix the error caused by ukuitaskbaricon.
ukui-panel (3.14.0.1-ok2~0726.1) yangtze; urgency=medium
-- handsome_feng <jianfengli@ubuntukylin.com> Fri, 19 Mar 2021 08:52:41 +0000
* BUG:无
需求:无
其他改动:修改版本号,删除ukui-flash-disk代码
其他改动说明:对代码无影响
ukui-panel (3.0.3-1) unstable; urgency=medium
-- buxiaoqing <buxiaoqing@kylinos.cn> Wed, 20 Jul 2022 17:55:39 +0800
* New upstream bugfix release.
ukui-panel (3.14.0.1-ok2~0720.4) yangtze; urgency=medium
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 28 Sep 2020 10:31:19 +0800
ukui-panel (3.14.0.1-ok2~0720.2) yangtze; urgency=medium
ukui-panel (3.0.2-1) unstable; urgency=medium
* BUG #130312 切换平板再切回PC已经打开的应用窗口消失
* 其他改动taskbar刷新逻辑优化屏蔽窗口的逻辑优化
* New upstream bugfix release.
-- buxiaoqing <buxiaoqing@kylinos.cn> Wed, 20 Jul 2022 17:55:39 +0800
-- handsome_feng <jianfengli@ubuntukylin.com> Sun, 27 Sep 2020 18:50:43 +0800
ukui-panel (3.14.0.1-ok2~0720.1) yangtze; urgency=medium
ukui-panel (3.0.1-1) unstable; urgency=medium
* Bug #130143 : wayland 下日历窗口可以挪动
* BUG #125354修复多次点击侧边栏侧边栏显示偏离正确位置过多
* BUG #128674: 插入移动U盘或硬盘或光驱后未在右下角显示设备信息
* BUG #130322 【任务栏】已打开应用在任务栏的图标显示异常
* BUG #127640 【任务栏】右键任务栏应用图标,关闭界面弹出位置错误
* BUG #127646 【任务栏】右键任务栏图标应用,选择关闭,关不掉应用,所有应用均有此情况
* BUG #126857 【wayland】【任务栏】右键点击任务栏任意图标显示的右键菜单均显示在任务栏上右键菜单应该显示在任务栏上方
* BUG #127691 【搜狗输入法】右键点击任务栏输入法窗口后,弹出的菜单显示位置不在任务栏
* BUG #130312 切换平板再切回PC已经打开的应用图标消失
* 需求:无
* 其他改动新增x下跳过任务栏的属性;新增黑名单屏蔽窗口功能;适配跳过任务栏接口;逻辑优化
* 影响域:无
* New upstream release.
-- handsome_feng <jianfengli@ubuntukylin.com> Tue, 19 Jul 2022 15:47:57 +0800
-- handsome_feng <jianfengli@ubuntukylin.com> Sat, 01 Aug 2020 03:11:43 +0000
ukui-panel (3.14.0.1-ok2~0715) yangtze; urgency=medium
* 修改为quilt格式
* 通过AppManager判断是否具有平板特性
* wayland适配desktop文件修改
* 修复wayland下日历位置错误问题
* 修复任务栏日期右键菜单位置错误问题
* 使用图标代替窗口预览
* 任务栏隐藏不使用动画,直接设置位置
* bug修复
- #125312 托盘图标颜色未反白
- #126789 托盘日历同步商业版代码,修复显示错误问题
- #127655 【托盘】选择隐藏任务栏后任务栏还在
- #129638 【任务栏】任务栏右键菜单"关于麒麟"需要改为"关于开放麒麟"
ukui-panel (3.0.0-1) unstable; urgency=medium
-- Xie Wei <xiewei@kylinos.cn> Fri, 20 May 2022 16:38:45 +0800
* New upstream release.
* debian:
- Update ukui-panel.postinst.
- Update copyright.
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 27 Jul 2020 01:05:06 +0000
ukui-panel (2.0.7-1) unstable; urgency=medium
* New upstream bugfix release:
- Fix that panel stuck after invoke ukui-control-center.
- Fix that night mode causes the screen flicker.
- Don't exit if ukui-window-switch does not exist.
* debian/control:
- Add ukui-window-switch to suggests.
-- handsome_feng <jianfengli@ubuntukylin.com> Thu, 16 Apr 2020 16:33:48 +0800
ukui-panel (2.0.6-1) unstable; urgency=medium
* New upstream bugfix release:
- Fix that the applet window not autohide.
- Fix the i18n issue in night mode and calendar.
- Fix the coffliction between preview window and warkspace.
- Fix the wrong position of right-click menu.
- Fix the missing icon of disk.
-- handsome_feng <jianfengli@ubuntukylin.com> Thu, 09 Apr 2020 17:35:53 +0800
ukui-panel (2.0.5-1) unstable; urgency=medium
* New upstream bugfix release.
- Fix that disk popup window don't disappear.
- Fix calendar i18n issue.
- Fix the sorting issue of applets.
- Fix that sometimes applets disappear.
- Fix the wrong time of calendar.
- Fix the error when select holiday.
- Fix that panel doesn't follow the primary screen.
- Fix the wrong position of preview windows.
- Fix the error when adding application to quick launch area.
- Fix the wrong gsettings key.
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 06 Apr 2020 19:53:00 +0800
ukui-panel (2.0.4-1) unstable; urgency=medium
* New upstream bugfix-only release.
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 30 Mar 2020 21:34:53 +0800
ukui-panel (2.0.3-1) unstable; urgency=medium
* New upstream bugfix-only release.
* debian/control:
- Update the vcs location.
-- handsome_feng <jianfengli@ubuntukylin.com> Mon, 23 Mar 2020 12:35:10 +0800
ukui-panel (2.0.2-1) unstable; urgency=medium
* New upstream release:
- Update the UI of calendar by new design.
- Update the UI of plugin ukui-flash-disk.
- Fix the wrong position when panel changed direction.
-- handsome_feng <jianfengli@ubuntukylin.com> Sat, 21 Mar 2020 16:52:54 +0800
ukui-panel (2.0.1-1) unstable; urgency=medium
* New upstream release:
- Fix build under Arch.
- Fix the error when click calendar.
- Fix the error when show preview.
- Adjust the style.
- Add dbus interface.
- Add disk plugin.
- Add close button to preview.
- Add tray storage area.
* debian/control:
- Add libpoppler-dev, libpopplet-qt5-dev and libpeony-dev to
build-depends.
-- handsome_feng <jianfengli@ubuntukylin.com> Thu, 12 Mar 2020 10:45:13 +0800
ukui-panel (2.0.0-1) unstable; urgency=medium
* New upstream release.
- Migrate from gtk to qt.
* Debian/{control,compat}:
- Use debhelper-compat notation.
- Bump standards-version to 4.5.0.
- Set Rules-Requires-Root to no.
-- handsome_feng <jianfengli@ubuntukylin.com> Sun, 02 Feb 2020 14:07:37 +0800
ukui-panel (1.1.6-1) unstable; urgency=medium
* Change the default grouping type of window-list.
* Fix that window-list disappears after multi restart.
* Update the copyright.
* debian/control:
- Bump standards-version to 4.4.0.
- Drop mate-polkit.
-- handsome_feng <jianfengli@ubuntukylin.com> Wed, 07 Aug 2019 11:25:09 +0800
ukui-panel (1.1.5-1) unstable; urgency=medium
* Update es.po, fr.po, pt.po, ru.po.
* Update the theme when system theme changes.
* Fix the bug that window-list disappears accidentally.
* Fix the bug that the icon stuck after multiple clicks.
* Fix the bug that can't move the applet to the right of window-list.
-- handsome_feng <jianfengli@ubuntukylin.com> Thu, 27 Dec 2018 20:12:06 +0800
ukui-panel (1.1.4-1) unstable; urgency=medium
* Initial release. (Closes: #903943)
-- handsome_feng <jianfengli@ubuntukylin.com> Tue, 17 Jul 2018 11:15:52 +0800

67
debian/control vendored
View File

@ -3,52 +3,49 @@ Section: x11
Priority: optional
Maintainer: kylin Team <team+kylin@tracker.debian.org>
Uploaders: Aron Xu <aron@debian.org>,
handsome_feng <jianfengli@ubuntukylin.com>
Build-Depends: debhelper-compat (= 13),
cmake,
handsome_feng <jianfengli@ubuntukylin.com>,
xibowen <xibowen@kylinos.cn>
Build-Depends: cmake,
debhelper-compat (= 13),
extra-cmake-modules,
libdbusmenu-qt5-dev,
libdrm-dev,
libglib2.0-dev(>=2.36),
libkf5windowsystem-dev,
libqt5svg5-dev,
libqt5x11extras5-dev,
libx11-dev,
libxcb-damage0-dev,
libxcb-util-dev,
libxcb-xkb-dev,
libxcomposite-dev,
libxdamage-dev,
libxkbcommon-dev,
libxkbcommon-x11-dev,
libxrender-dev,
libqt5xdg-dev,
qttools5-dev,
libgsettings-qt-dev,
libdconf-dev,
libkf5i18n-dev,
libkf5screen-dev,
libkf5wayland-dev,
libkf5windowsystem-dev,
libkysdk-applications-dev,
libpipewire-0.3-dev,
libqt5x11extras5-dev,
libqt5xdg-dev,
libukcc-dev,
libukui-log4qt-dev,
libx11-dev,
libxcb-composite0-dev,
libxcb-damage0-dev,
libxcb-image0-dev,
libxcb-shape0-dev,
libxcb-util0-dev,
libxtst-dev,
plasma-wayland-protocols,
qtbase5-dev,
qtbase5-dev-tools,
qttools5-dev-tools,
libxtst-dev,
libudisks2-dev,
libxcb-render-util0-dev,
libxcb-image0-dev,
libxcb-composite0-dev,
libxcb-shape0-dev,
libukui-common-dev,
libkf5screen-dev
qtbase5-private-dev,
qtdeclarative5-dev,
qttools5-dev,
qtwayland5-dev-tools
Standards-Version: 4.6.1.0
Rules-Requires-Root: no
Vcs-Browser: https://github.com/ukui/ukui-panel
Vcs-Git: https://github.com/ukui/ukui-panel
Homepage: https://github.com/ukui/ukui-panel
Homepage: https://gitee.com/openkylin/ukui-panel
Vcs-Git: https://gitee.com/openkylin/ukui-panel.git
Vcs-Browser: https://gitee.com/openkylin/ukui-panel
Package: ukui-panel
Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends},
Depends: ${misc:Depends}, ${shlibs:Depends}
Provides: ukui-indicators
Suggests: ukui-window-switch (>=3.0.0-3),
time-shutdown
Suggests: time-shutdown, ukui-window-switch (>=3.0.0-3)
Description: ukui desktop panel
The ukui desktop panel is used on ukui desktop and has some plugins like
starmenu, quicklaunch and other useful tools.

3
debian/manpages vendored
View File

@ -1,5 +1,2 @@
man/ukui-flash-disk.1
man/ukui-panel.1
man/panel-daemon.1
man/sni-daemon.1
man/sni-xembed-proxy.1

View File

@ -1,24 +0,0 @@
+ukui-panel (3.0.1-42) v101; urgency=medium
+
+ * 更新任务栏高分屏适配代码 Link#28059
+ 提供给输入法显示toolTips的相关接口 Link #20236
+ 点击快速启动栏打开应用改为gio的方式加载 Link #24172
+ 解决任务栏注释出现的段错误问题 Link #29586
+
+ -- hepuyao <hepuyao@kylinos.cn> Thu, 24 Dec 2020 15:10:02 +0800
+
+ukui-panel (3.0.1-40~1224) v101; urgency=medium
+
+ * 解决u盘图标不消失的问题
+
+ -- hepuyao <hepuyao@kylinos.cn> Fri, 11 Dec 2020 13:49:52 +0800
+
+ukui-panel (3.0.1-39) v101; urgency=medium
+
+ * 任务栏判断配置文件异常
+ 解决翻译文件“睡眠”和“休眠”统一 #27572
+ 任务栏托盘图标高亮逻辑优化 #22328
+ 修改判断右键是否需要添加系统监视器的接口
+
+ -- hepuyao <hepuyao@kylinos.cn> Thu, 10 Dec 2020 20:25:05 +0800

View File

@ -1,6 +0,0 @@
Qt拖放(1):拖放基本原理(QDrag类)
https://blog.csdn.net/hyongilfmmm/article/details/83238239
QT---之Q_D和d指针概念2
https://blog.csdn.net/weixin_39609623/article/details/83152662
Qt中使用Q指针和D指针
https://blog.csdn.net/u013399898/article/details/83930426

View File

@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.16)
project(taskmanager LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#find QT modules
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Quick Widgets DBus X11Extras REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Quick Widgets DBus X11Extras REQUIRED)
#find kde modules
find_package(Qt5Xdg REQUIRED)
find_package(KF5Wayland)
find_package(KF5I18n)
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
include(FindQtWaylandScanner)
include(ECMQtDeclareLoggingCategory)
#find other modules
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GIO2 REQUIRED gio-2.0)
pkg_check_modules(Gsetting REQUIRED gsettings-qt)
pkg_check_modules(PipeWire REQUIRED libpipewire-0.3)
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories(${GIO2_INCLUDE_DIRS})
include_directories(${Gsetting_INCLUDE_DIRS})
include_directories(${PipeWire_INCLUDE_DIRS})
#generate libtaskmanager.so
set (PLUGIN_SRCS
screencastingrequest.cpp screencastingrequest.h
screencasting.cpp screencasting.h
pipewirecore.cpp pipewirecore.h
pipewiresourcestream.cpp pipewiresourcestream.h
pipewiresourceitem.cpp pipewiresourceitem.h
taskmanagerplugin.cpp taskmanagerplugin.h
)
add_library(${PROJECT_NAME} SHARED ${PLUGIN_SRCS})
target_compile_definitions(${PROJECT_NAME} PRIVATE PLUGIN_IMPORT_URI="${PLUGIN_IMPORT_URI}")
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt5::Core
Qt5::Gui
Qt5::Gui_EGL
Qt::GuiPrivate
Qt5::Quick
Qt5::Widgets
Qt5::DBus
Qt5::X11Extras
Qt5Xdg
${GLIB2_LIBRARIES}
${GIO2_LIBRARIES}
${Gsetting_LIBRARIES}
${PipeWire_LIBRARIES}
KF5::WaylandClient
KF5::I18n
)
#generate log files
ecm_qt_declare_logging_category(SRCS
HEADER logging.h
IDENTIFIER PIPEWIRE_LOGGING
CATEGORY_NAME plasma_workspace_pipewire_logging
DESCRIPTION "PipeWire components for window thumbnails"
EXPORT PlasmaWorkspacePipeWire)
ecm_qt_install_logging_categories(
EXPORT PlasmaWorkspacePipeWire
FILE myproject.categories
DESTINATION "./"
)
#generate wayland protocol files
set(PLASMA_WAYLAND_PROTOCOLS_DIR /usr/share/plasma-wayland-protocols)
ecm_add_qtwayland_client_protocol(SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml
BASENAME zkde-screencast-unstable-v1
)
target_sources(${PROJECT_NAME} PUBLIC pipewirecore.cpp pipewiresourceitem.cpp pipewiresourcestream.cpp
screencasting.cpp screencastingrequest.cpp ${SRCS})
set(PLUGIN_IMPORT_URI "org.ukui.panel.taskmanager")
set(PLUGIN_INSTALL_PATH "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/qml/org/ukui/panel/taskmanager")
set(taskmanager_LIB_DIR /usr/share/ukui/ukui-panel/libtaskmanager)
install(FILES qmldir DESTINATION ${PLUGIN_INSTALL_PATH})
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})

View File

@ -0,0 +1,93 @@
#include "pipewirecore.h"
#include "logging.h"
#include <KLocalizedString>
#include <QSocketNotifier>
#include <spa/utils/result.h>
PipeWireCore::PipeWireCore()
{
pw_init(nullptr, nullptr);
pwCoreEvents.version = PW_VERSION_CORE_EVENTS;
pwCoreEvents.error = &PipeWireCore::onCoreError;
}
void PipeWireCore::onCoreError(void *data, uint32_t id, int seq, int res, const char *message)
{
Q_UNUSED(seq)
qCWarning(PIPEWIRE_LOGGING) << "PipeWire remote error: " << message;
if (id == PW_ID_CORE && res == -EPIPE) {
PipeWireCore *pw = static_cast<PipeWireCore *>(data);
Q_EMIT pw->pipewireFailed(QString::fromUtf8(message));
}
}
PipeWireCore::~PipeWireCore()
{
if (pwMainLoop) {
pw_loop_leave(pwMainLoop);
}
if (pwCore) {
pw_core_disconnect(pwCore);
}
if (pwContext) {
pw_context_destroy(pwContext);
}
if (pwMainLoop) {
pw_loop_destroy(pwMainLoop);
}
}
bool PipeWireCore::init()
{
pwMainLoop = pw_loop_new(nullptr);
pw_loop_enter(pwMainLoop);
QSocketNotifier *notifier = new QSocketNotifier(pw_loop_get_fd(pwMainLoop), QSocketNotifier::Read, this);
connect(notifier, &QSocketNotifier::activated, this, [this] {
int result = pw_loop_iterate(pwMainLoop, 0);
if (result < 0)
qCWarning(PIPEWIRE_LOGGING) << "pipewire_loop_iterate failed: " << spa_strerror(result);
});
pwContext = pw_context_new(pwMainLoop, nullptr, 0);
if (!pwContext) {
qCWarning(PIPEWIRE_LOGGING) << "Failed to create PipeWire context";
m_error = i18n("Failed to create PipeWire context");
return false;
}
pwCore = pw_context_connect(pwContext, nullptr, 0);
if (!pwCore) {
qCWarning(PIPEWIRE_LOGGING) << "Failed to connect PipeWire context";
m_error = i18n("Failed to connect PipeWire context");
return false;
}
if (pw_loop_iterate(pwMainLoop, 0) < 0) {
qCWarning(PIPEWIRE_LOGGING) << "Failed to start main PipeWire loop";
m_error = i18n("Failed to start main PipeWire loop");
return false;
}
pw_core_add_listener(pwCore, &coreListener, &pwCoreEvents, this);
return true;
}
QSharedPointer<PipeWireCore> PipeWireCore::self()
{
static QWeakPointer<PipeWireCore> global;
QSharedPointer<PipeWireCore> ret;
if (global) {
ret = global.toStrongRef();
} else {
ret.reset(new PipeWireCore);
if (ret->init()) {
global = ret;
}
}
return ret;
}

View File

@ -0,0 +1,34 @@
#ifndef PIPEWIRECORE_H
#define PIPEWIRECORE_H
#include <QObject>
#include <pipewire/pipewire.h>
class PipeWireCore : public QObject
{
Q_OBJECT
public:
PipeWireCore();
static void onCoreError(void *data, uint32_t id, int seq, int res, const char *message);
~PipeWireCore();
bool init();
static QSharedPointer<PipeWireCore> self();
struct pw_core *pwCore = nullptr;
struct pw_context *pwContext = nullptr;
struct pw_loop *pwMainLoop = nullptr;
spa_hook coreListener;
QString m_error;
pw_core_events pwCoreEvents = {};
Q_SIGNALS:
void pipewireFailed(const QString &message);
};
#endif // PIPEWIRECORE_H

View File

@ -0,0 +1,284 @@
#include "pipewiresourceitem.h"
#include "pipewiresourcestream.h"
#include <QGuiApplication>
#include <QOpenGLContext>
#include <QOpenGLTexture>
#include <QQuickWindow>
#include <QRunnable>
#include <QSGImageNode>
#include <QSocketNotifier>
#include <QThread>
#include <qpa/qplatformnativeinterface.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <libdrm/drm_fourcc.h>
#include <QtPlatformHeaders/QEGLNativeContext>
static void pwInit()
{
pw_init(nullptr, nullptr);
}
Q_COREAPP_STARTUP_FUNCTION(pwInit);
class DiscardEglPixmapRunnable : public QRunnable
{
public:
DiscardEglPixmapRunnable(EGLImageKHR image, QOpenGLTexture *texture)
: m_image(image)
, m_texture(texture)
{
}
void run() override
{
if (m_image != EGL_NO_IMAGE_KHR) {
static auto eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
eglDestroyImageKHR(eglGetCurrentDisplay(), m_image);
}
delete m_texture;
}
private:
const EGLImageKHR m_image;
QOpenGLTexture *m_texture;
};
PipeWireSourceItem::PipeWireSourceItem(QQuickItem *parent)
: QQuickItem(parent)
{
setFlag(ItemHasContents, true);
connect(this, &QQuickItem::visibleChanged, this, [this]() {
if (m_stream)
m_stream->setActive(isVisible());
});
}
PipeWireSourceItem::~PipeWireSourceItem()
{
}
void PipeWireSourceItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
{
switch (change) {
case ItemVisibleHasChanged:
if (m_stream)
m_stream->setActive(isVisible() && data.boolValue && isComponentComplete());
break;
case ItemSceneChange:
m_needsRecreateTexture = true;
releaseResources();
break;
default:
break;
}
}
void PipeWireSourceItem::releaseResources()
{
if (window()) {
window()->scheduleRenderJob(new DiscardEglPixmapRunnable(m_image, m_texture.take()), QQuickWindow::NoStage);
m_image = EGL_NO_IMAGE_KHR;
}
}
void PipeWireSourceItem::setNodeId(uint nodeId)
{
if (nodeId == m_nodeId)
return;
m_nodeId = nodeId;
if (m_nodeId == 0) {
m_stream.reset(nullptr);
m_createNextTexture = [] {
return nullptr;
};
} else {
m_stream.reset(new PipeWireSourceStream(this));
m_stream->createStream(m_nodeId);
if (!m_stream->error().isEmpty()) {
m_stream.reset(nullptr);
m_nodeId = 0;
return;
}
m_stream->setActive(isVisible() && isComponentComplete());
connect(m_stream.data(), &PipeWireSourceStream::dmabufTextureReceived, this, &PipeWireSourceItem::updateTextureDmaBuf);
connect(m_stream.data(), &PipeWireSourceStream::imageTextureReceived, this, &PipeWireSourceItem::updateTextureImage);
}
Q_EMIT nodeIdChanged(nodeId);
}
QSGNode *PipeWireSourceItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *)
{
if (Q_UNLIKELY(!m_createNextTexture)) {
return node;
}
auto texture = m_createNextTexture();
if (!texture) {
delete node;
return nullptr;
}
if (m_needsRecreateTexture) {
delete node;
node = nullptr;
m_needsRecreateTexture = false;
}
QSGImageNode *textureNode = static_cast<QSGImageNode *>(node);
if (!textureNode) {
textureNode = window()->createImageNode();
textureNode->setOwnsTexture(true);
}
textureNode->setTexture(texture);
const auto br = boundingRect().toRect();
QRect rect({0, 0}, texture->textureSize().scaled(br.size(), Qt::KeepAspectRatio));
rect.moveCenter(br.center());
textureNode->setRect(rect);
return textureNode;
}
QString PipeWireSourceItem::error() const
{
return m_stream->error();
}
static EGLImage createImage(EGLDisplay display, const QVector<DmaBufPlane> &planes, uint32_t format, const QSize &size)
{
const bool hasModifiers = planes[0].modifier != DRM_FORMAT_MOD_INVALID;
QVector<EGLint> attribs;
attribs << EGL_WIDTH << size.width() << EGL_HEIGHT << size.height() << EGL_LINUX_DRM_FOURCC_EXT << EGLint(format)
<< EGL_DMA_BUF_PLANE0_FD_EXT << planes[0].fd << EGL_DMA_BUF_PLANE0_OFFSET_EXT << EGLint(planes[0].offset) << EGL_DMA_BUF_PLANE0_PITCH_EXT
<< EGLint(planes[0].stride);
if (hasModifiers) {
attribs << EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT << EGLint(planes[0].modifier & 0xffffffff) << EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT
<< EGLint(planes[0].modifier >> 32);
}
if (planes.count() > 1) {
attribs << EGL_DMA_BUF_PLANE1_FD_EXT << planes[1].fd << EGL_DMA_BUF_PLANE1_OFFSET_EXT << EGLint(planes[1].offset) << EGL_DMA_BUF_PLANE1_PITCH_EXT
<< EGLint(planes[1].stride);
if (hasModifiers) {
attribs << EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT << EGLint(planes[1].modifier & 0xffffffff) << EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT
<< EGLint(planes[1].modifier >> 32);
}
}
if (planes.count() > 2) {
attribs << EGL_DMA_BUF_PLANE2_FD_EXT << planes[2].fd << EGL_DMA_BUF_PLANE2_OFFSET_EXT << EGLint(planes[2].offset) << EGL_DMA_BUF_PLANE2_PITCH_EXT
<< EGLint(planes[2].stride);
if (hasModifiers) {
attribs << EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT << EGLint(planes[2].modifier & 0xffffffff) << EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT
<< EGLint(planes[2].modifier >> 32);
}
}
if (planes.count() > 3) {
attribs << EGL_DMA_BUF_PLANE3_FD_EXT << planes[3].fd << EGL_DMA_BUF_PLANE3_OFFSET_EXT << EGLint(planes[3].offset) << EGL_DMA_BUF_PLANE3_PITCH_EXT
<< EGLint(planes[3].stride);
if (hasModifiers) {
attribs << EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT << EGLint(planes[3].modifier & 0xffffffff) << EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT
<< EGLint(planes[3].modifier >> 32);
}
}
attribs << EGL_NONE;
static auto eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
Q_ASSERT(eglCreateImageKHR);
EGLImage ret = eglCreateImageKHR(display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, (EGLClientBuffer) nullptr, attribs.data());
if (ret == EGL_NO_IMAGE_KHR) {
qWarning() << "invalid image" << glGetError();
}
// Q_ASSERT(ret);
return ret;
}
void PipeWireSourceItem::updateTextureDmaBuf(const QVector<DmaBufPlane> &planes, uint32_t format)
{
static auto s_glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
if (!s_glEGLImageTargetTexture2DOES) {
qWarning() << "glEGLImageTargetTexture2DOES is not available" << window();
return;
}
if (!window() || !window()->openglContext() || !m_stream) {
qWarning() << "need a window and a context" << window();
return;
}
const EGLDisplay display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay"));
if (m_image) {
static auto eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
eglDestroyImageKHR(display, m_image);
}
const auto size = m_stream->size();
m_image = createImage(display, planes, format, size);
if (m_image == EGL_NO_IMAGE_KHR) {
QImage img(200, 200, QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::blue);
updateTextureImage(img);
return;
}
m_createNextTexture = [this, size, format] {
if (!m_texture) {
m_texture.reset(new QOpenGLTexture(QOpenGLTexture::Target2D));
bool created = m_texture->create();
Q_ASSERT(created);
}
m_texture->bind();
s_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)m_image);
m_texture->setWrapMode(QOpenGLTexture::ClampToEdge);
m_texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear);
m_texture->release();
m_texture->setSize(size.width(), size.height());
int textureId = m_texture->textureId();
QQuickWindow::CreateTextureOption textureOption = format == DRM_FORMAT_ARGB8888 ? QQuickWindow::TextureHasAlphaChannel : QQuickWindow::TextureIsOpaque;
return window()->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture, &textureId, 0 /*a vulkan thing?*/, size, textureOption);
};
if (window()->isVisible()) {
update();
}
}
void PipeWireSourceItem::updateTextureImage(const QImage &image)
{
if (!window()) {
qWarning() << "pass";
return;
}
m_createNextTexture = [this, image] {
return window()->createTextureFromImage(image, QQuickWindow::TextureIsOpaque);
};
if (window()->isVisible())
update();
}
void PipeWireSourceItem::componentComplete()
{
if (m_stream)
m_stream->setActive(isVisible());
QQuickItem::componentComplete();
}

View File

@ -0,0 +1,56 @@
#ifndef PIPEWIRESOURCEITEM_H
#define PIPEWIRESOURCEITEM_H
#include <QQuickItem>
#include <functional>
#include <pipewire/pipewire.h>
#include <spa/param/format-utils.h>
#include <spa/param/props.h>
#include <spa/param/video/format-utils.h>
struct DmaBufPlane;
class PipeWireSourceStream;
class QSGTexture;
class QOpenGLTexture;
typedef void *EGLImage;
class PipeWireSourceItem : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(uint nodeId READ nodeId WRITE setNodeId NOTIFY nodeIdChanged)
public:
PipeWireSourceItem(QQuickItem *parent = nullptr);
~PipeWireSourceItem() override;
QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data) override;
Q_SCRIPTABLE QString error() const;
void setNodeId(uint nodeId);
uint nodeId() const
{
return m_nodeId;
}
void componentComplete() override;
void releaseResources() override;
Q_SIGNALS:
void nodeIdChanged(uint nodeId);
private:
void itemChange(ItemChange change, const ItemChangeData &data) override;
void updateTextureDmaBuf(const QVector<DmaBufPlane> &plane, uint32_t format);
void updateTextureImage(const QImage &image);
uint m_nodeId = 0;
std::function<QSGTexture *()> m_createNextTexture;
QScopedPointer<PipeWireSourceStream> m_stream;
QScopedPointer<QOpenGLTexture> m_texture;
EGLImage m_image = nullptr;
bool m_needsRecreateTexture = false;
};
#endif // PIPEWIRESOURCEITEM_H

View File

@ -0,0 +1,364 @@
#include "pipewiresourcestream.h"
#include "logging.h"
#include "pipewirecore.h"
#include <fcntl.h>
#include <libdrm/drm_fourcc.h>
#include <spa/utils/result.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <QGuiApplication>
#include <QLoggingCategory>
#include <QOpenGLTexture>
#include <QSocketNotifier>
#include <QVersionNumber>
#include <qpa/qplatformnativeinterface.h>
#include <KLocalizedString>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <QtPlatformHeaders/QEGLNativeContext>
#undef Status
#if !PW_CHECK_VERSION(0, 3, 29)
#define SPA_POD_PROP_FLAG_MANDATORY (1u << 3)
#endif
#if !PW_CHECK_VERSION(0, 3, 33)
#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u << 4)
#endif
static uint32_t SpaPixelFormatToDrmFormat(uint32_t spa_format)
{
switch (spa_format) {
case SPA_VIDEO_FORMAT_RGBA:
return DRM_FORMAT_ABGR8888;
case SPA_VIDEO_FORMAT_RGBx:
return DRM_FORMAT_XBGR8888;
case SPA_VIDEO_FORMAT_BGRA:
return DRM_FORMAT_ARGB8888;
case SPA_VIDEO_FORMAT_BGRx:
return DRM_FORMAT_XRGB8888;
default:
return DRM_FORMAT_INVALID;
}
}
static std::vector<uint64_t> queryDmaBufModifiers(EGLDisplay display, uint32_t format)
{
static auto eglQueryDmaBufModifiersEXT = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC)eglGetProcAddress("eglQueryDmaBufModifiersEXT");
static auto eglQueryDmaBufFormatsEXT = (PFNEGLQUERYDMABUFFORMATSEXTPROC)eglGetProcAddress("eglQueryDmaBufFormatsEXT");
if (!eglQueryDmaBufFormatsEXT || !eglQueryDmaBufModifiersEXT) {
return {};
}
uint32_t drm_format = SpaPixelFormatToDrmFormat(format);
if (drm_format == DRM_FORMAT_INVALID) {
qCDebug(PIPEWIRE_LOGGING) << "Failed to find matching DRM format." << format;
return {};
}
EGLint count = 0;
EGLBoolean success = eglQueryDmaBufFormatsEXT(display, 0, nullptr, &count);
if (!success || count == 0) {
qCWarning(PIPEWIRE_LOGGING) << "Failed to query DMA-BUF format count.";
return {};
}
std::vector<uint32_t> formats(count);
if (!eglQueryDmaBufFormatsEXT(display, count, reinterpret_cast<EGLint *>(formats.data()), &count)) {
if (!success)
qCWarning(PIPEWIRE_LOGGING) << "Failed to query DMA-BUF formats.";
return {};
}
if (std::find(formats.begin(), formats.end(), drm_format) == formats.end()) {
qCDebug(PIPEWIRE_LOGGING) << "Format " << drm_format << " not supported for modifiers.";
return {DRM_FORMAT_MOD_INVALID};
}
success = eglQueryDmaBufModifiersEXT(display, drm_format, 0, nullptr, nullptr, &count);
if (!success) {
qCWarning(PIPEWIRE_LOGGING) << "Failed to query DMA-BUF modifier count.";
return {};
}
std::vector<uint64_t> modifiers(count);
if (count > 0) {
if (!eglQueryDmaBufModifiersEXT(display, drm_format, count, modifiers.data(), nullptr, &count)) {
qCWarning(PIPEWIRE_LOGGING) << "Failed to query DMA-BUF modifiers.";
}
}
// Support modifier-less buffers
modifiers.push_back(DRM_FORMAT_MOD_INVALID);
return modifiers;
}
void PipeWireSourceStream::onStreamStateChanged(void *data, pw_stream_state old, pw_stream_state state, const char *error_message)
{
PipeWireSourceStream *pw = static_cast<PipeWireSourceStream *>(data);
qCDebug(PIPEWIRE_LOGGING) << "state changed" << pw_stream_state_as_string(old) << "->" << pw_stream_state_as_string(state) << error_message;
switch (state) {
case PW_STREAM_STATE_ERROR:
qCWarning(PIPEWIRE_LOGGING) << "Stream error: " << error_message;
break;
case PW_STREAM_STATE_PAUSED:
Q_EMIT pw->streamReady();
break;
case PW_STREAM_STATE_STREAMING:
Q_EMIT pw->startStreaming();
break;
case PW_STREAM_STATE_CONNECTING:
break;
case PW_STREAM_STATE_UNCONNECTED:
if (!pw->m_stopped) {
Q_EMIT pw->stopStreaming();
}
break;
}
}
static spa_pod *buildFormat(spa_pod_builder *builder, spa_video_format format, const std::vector<uint64_t> &modifiers = {})
{
spa_pod_frame f[2];
const spa_rectangle pw_min_screen_bounds{1, 1};
const spa_rectangle pw_max_screen_bounds{UINT32_MAX, UINT32_MAX};
spa_pod_builder_push_object(builder, &f[0], SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_add(builder, SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video), 0);
spa_pod_builder_add(builder, SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), 0);
spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_format, SPA_POD_Id(format), 0);
if (modifiers.size()) {
auto pw_version = QVersionNumber::fromString(pw_get_library_version());
// SPA_POD_PROP_FLAG_DONT_FIXATE can be used with PipeWire >= 0.3.33
if (pw_version >= QVersionNumber(0, 3, 33)) {
spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE);
} else {
spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY);
}
spa_pod_builder_push_choice(builder, &f[1], SPA_CHOICE_Enum, 0);
// mofifiers from the array
for (auto it = modifiers.begin(); it != modifiers.end(); it++) {
spa_pod_builder_long(builder, *it);
if (it == modifiers.begin()) {
spa_pod_builder_long(builder, *it);
}
}
spa_pod_builder_pop(builder, &f[1]);
}
spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(&pw_min_screen_bounds, &pw_min_screen_bounds, &pw_max_screen_bounds), 0);
return static_cast<spa_pod *>(spa_pod_builder_pop(builder, &f[0]));
}
void PipeWireSourceStream::onStreamParamChanged(void *data, uint32_t id, const struct spa_pod *format)
{
if (!format || id != SPA_PARAM_Format) {
return;
}
PipeWireSourceStream *pw = static_cast<PipeWireSourceStream *>(data);
spa_format_video_raw_parse(format, &pw->videoFormat);
const int32_t width = pw->videoFormat.size.width;
const int32_t height = pw->videoFormat.size.height;
const int bpp = pw->videoFormat.format == SPA_VIDEO_FORMAT_RGB || pw->videoFormat.format == SPA_VIDEO_FORMAT_BGR ? 3 : 4;
const quint32 stride = SPA_ROUND_UP_N(width * bpp, 4);
qCDebug(PIPEWIRE_LOGGING) << "Stream format changed";
const int32_t size = height * stride;
uint8_t paramsBuffer[1024];
spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT(paramsBuffer, sizeof(paramsBuffer));
const auto bufferTypes = pw->m_allowDmaBuf && spa_pod_find_prop(format, nullptr, SPA_FORMAT_VIDEO_modifier)
? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr)
: (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr);
const spa_pod *param = (spa_pod *)spa_pod_builder_add_object(&pod_builder,
SPA_TYPE_OBJECT_ParamBuffers,
SPA_PARAM_Buffers,
SPA_PARAM_BUFFERS_buffers,
SPA_POD_CHOICE_RANGE_Int(16, 2, 16),
SPA_PARAM_BUFFERS_blocks,
SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size,
SPA_POD_Int(size),
SPA_PARAM_BUFFERS_stride,
SPA_POD_CHOICE_RANGE_Int(stride, stride, INT32_MAX),
SPA_PARAM_BUFFERS_align,
SPA_POD_Int(16),
SPA_PARAM_BUFFERS_dataType,
SPA_POD_CHOICE_FLAGS_Int(bufferTypes));
pw_stream_update_params(pw->pwStream, &param, 1);
}
static void onProcess(void *data)
{
PipeWireSourceStream *stream = static_cast<PipeWireSourceStream *>(data);
stream->process();
}
PipeWireSourceStream::PipeWireSourceStream(QObject *parent)
: QObject(parent)
{
pwStreamEvents.version = PW_VERSION_STREAM_EVENTS;
pwStreamEvents.process = &onProcess;
pwStreamEvents.state_changed = &PipeWireSourceStream::onStreamStateChanged;
pwStreamEvents.param_changed = &PipeWireSourceStream::onStreamParamChanged;
}
PipeWireSourceStream::~PipeWireSourceStream()
{
m_stopped = true;
if (pwStream) {
pw_stream_destroy(pwStream);
}
}
uint PipeWireSourceStream::framerate()
{
if (pwStream) {
return videoFormat.max_framerate.num / videoFormat.max_framerate.denom;
}
return 0;
}
uint PipeWireSourceStream::nodeId()
{
return pwNodeId;
}
bool PipeWireSourceStream::createStream(uint nodeid)
{
pwCore = PipeWireCore::self();
if (!pwCore->m_error.isEmpty()) {
m_error = pwCore->m_error;
return false;
}
connect(pwCore.data(), &PipeWireCore::pipewireFailed, this, &PipeWireSourceStream::coreFailed);
pwStream = pw_stream_new(pwCore->pwCore, "plasma-screencast", nullptr);
pwNodeId = nodeid;
pw_stream_add_listener(pwStream, &streamListener, &pwStreamEvents, this);
uint8_t buffer[4096];
spa_pod_builder podBuilder = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
const QVector<spa_video_format> formats =
{SPA_VIDEO_FORMAT_RGBx, SPA_VIDEO_FORMAT_RGBA, SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGB, SPA_VIDEO_FORMAT_BGR};
QVector<const spa_pod *> params;
params.reserve(formats.size() * 2);
const EGLDisplay display = static_cast<EGLDisplay>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay"));
for (spa_video_format format : formats) {
if (m_allowDmaBuf) {
if (auto modifiers = queryDmaBufModifiers(display, format); modifiers.size() > 0) {
params += buildFormat(&podBuilder, format, modifiers);
}
}
params += buildFormat(&podBuilder, format, {});
}
pw_stream_flags s = (pw_stream_flags)(PW_STREAM_FLAG_DONT_RECONNECT | PW_STREAM_FLAG_AUTOCONNECT);
if (pw_stream_connect(pwStream, PW_DIRECTION_INPUT, pwNodeId, s, params.data(), params.size()) != 0) {
qCWarning(PIPEWIRE_LOGGING) << "Could not connect to stream";
pw_stream_destroy(pwStream);
return false;
}
return true;
}
void PipeWireSourceStream::handleFrame(struct pw_buffer *buffer)
{
spa_buffer *spaBuffer = buffer->buffer;
if (spaBuffer->datas->chunk->size == 0) {
return;
}
if (spaBuffer->datas->type == SPA_DATA_MemFd) {
uint8_t *map =
static_cast<uint8_t *>(mmap(nullptr, spaBuffer->datas->maxsize + spaBuffer->datas->mapoffset, PROT_READ, MAP_PRIVATE, spaBuffer->datas->fd, 0));
if (map == MAP_FAILED) {
qCWarning(PIPEWIRE_LOGGING) << "Failed to mmap the memory: " << strerror(errno);
return;
}
const QImage::Format format = spaBuffer->datas->chunk->stride / videoFormat.size.width == 3 ? QImage::Format_RGB888 : QImage::Format_ARGB32;
QImage img(map, videoFormat.size.width, videoFormat.size.height, spaBuffer->datas->chunk->stride, format);
Q_EMIT imageTextureReceived(img.copy());
munmap(map, spaBuffer->datas->maxsize + spaBuffer->datas->mapoffset);
} else if (spaBuffer->datas->type == SPA_DATA_DmaBuf) {
QVector<DmaBufPlane> planes;
planes.reserve(spaBuffer->n_datas);
for (uint i = 0; i < spaBuffer->n_datas; ++i) {
const auto &data = spaBuffer->datas[i];
DmaBufPlane plane;
plane.fd = data.fd;
plane.stride = data.chunk->stride;
plane.offset = data.chunk->offset;
plane.modifier = DRM_FORMAT_MOD_INVALID;
planes += plane;
}
Q_EMIT dmabufTextureReceived(planes, DRM_FORMAT_ARGB8888);
} else if (spaBuffer->datas->type == SPA_DATA_MemPtr) {
QImage img(static_cast<uint8_t *>(spaBuffer->datas->data),
videoFormat.size.width,
videoFormat.size.height,
spaBuffer->datas->chunk->stride,
QImage::Format_ARGB32);
Q_EMIT imageTextureReceived(img);
} else {
qWarning() << "unsupported buffer type" << spaBuffer->datas->type;
QImage errorImage(200, 200, QImage::Format_ARGB32_Premultiplied);
errorImage.fill(Qt::red);
Q_EMIT imageTextureReceived(errorImage);
}
}
void PipeWireSourceStream::coreFailed(const QString &errorMessage)
{
m_error = errorMessage;
Q_EMIT stopStreaming();
}
void PipeWireSourceStream::process()
{
pw_buffer *buf = pw_stream_dequeue_buffer(pwStream);
if (!buf) {
return;
}
handleFrame(buf);
pw_stream_queue_buffer(pwStream, buf);
}
void PipeWireSourceStream::stop()
{
if (!m_stopped)
pw_stream_set_active(pwStream, false);
m_stopped = true;
delete this;
}
void PipeWireSourceStream::setActive(bool active)
{
Q_ASSERT(pwStream);
pw_stream_set_active(pwStream, active);
}

View File

@ -0,0 +1,86 @@
#ifndef PIPEWIRESOURCESTREAM_H
#define PIPEWIRESOURCESTREAM_H
#include <QHash>
#include <QObject>
#include <QSharedPointer>
#include <QSize>
#include <pipewire/pipewire.h>
#include <spa/param/format-utils.h>
#include <spa/param/props.h>
#include <spa/param/video/format-utils.h>
#undef Status
namespace KWin
{
class AbstractEglBackend;
class GLTexture;
}
class PipeWireCore;
typedef void *EGLDisplay;
struct DmaBufPlane {
int fd; /// The dmabuf file descriptor
uint32_t offset; /// The offset from the start of buffer
uint32_t stride; /// The distance from the start of a row to the next row in bytes
uint64_t modifier = 0; /// The layout modifier
};
class PipeWireSourceStream : public QObject
{
Q_OBJECT
public:
explicit PipeWireSourceStream(QObject *parent);
~PipeWireSourceStream();
static void onStreamParamChanged(void *data, uint32_t id, const struct spa_pod *format);
static void onStreamStateChanged(void *data, pw_stream_state old, pw_stream_state state, const char *error_message);
uint framerate();
uint nodeId();
QString error() const
{
return m_error;
}
QSize size() const
{
return QSize(videoFormat.size.width, videoFormat.size.height);
}
bool createStream(uint nodeid);
void stop();
void setActive(bool active);
void handleFrame(struct pw_buffer *buffer);
void process();
bool setAllowDmaBuf(bool allowed);
Q_SIGNALS:
void streamReady();
void startStreaming();
void stopStreaming();
void dmabufTextureReceived(const QVector<DmaBufPlane> &planes, uint32_t format);
void imageTextureReceived(const QImage &image);
private:
void coreFailed(const QString &errorMessage);
QSharedPointer<PipeWireCore> pwCore;
pw_stream *pwStream = nullptr;
spa_hook streamListener;
pw_stream_events pwStreamEvents = {};
uint32_t pwNodeId = 0;
bool m_stopped = false;
spa_video_info_raw videoFormat;
QString m_error;
bool m_allowDmaBuf = true;
};
#endif // PIPEWIRESOURCESTREAM_H

2
libtaskmanager/qmldir Normal file
View File

@ -0,0 +1,2 @@
module org.ukui.panel.taskmanager
plugin taskmanager

View File

@ -0,0 +1,109 @@
#include "screencasting.h"
#include "qwayland-zkde-screencast-unstable-v1.h"
#include <KWayland/Client/output.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/registry.h>
#include <QDebug>
#include <QRect>
using namespace KWayland::Client;
class ScreencastingStreamPrivate : public QtWayland::zkde_screencast_stream_unstable_v1
{
public:
ScreencastingStreamPrivate(ScreencastingStream *q)
: q(q)
{
}
~ScreencastingStreamPrivate()
{
close();
q->deleteLater();
}
void zkde_screencast_stream_unstable_v1_created(uint32_t node) override
{
m_nodeId = node;
Q_EMIT q->created(node);
}
void zkde_screencast_stream_unstable_v1_closed() override
{
Q_EMIT q->closed();
}
void zkde_screencast_stream_unstable_v1_failed(const QString &error) override
{
Q_EMIT q->failed(error);
}
uint m_nodeId = 0;
QPointer<ScreencastingStream> q;
};
ScreencastingStream::ScreencastingStream(QObject *parent)
: QObject(parent)
, d(new ScreencastingStreamPrivate(this))
{
}
ScreencastingStream::~ScreencastingStream() = default;
quint32 ScreencastingStream::nodeId() const
{
return d->m_nodeId;
}
class ScreencastingPrivate : public QtWayland::zkde_screencast_unstable_v1
{
public:
ScreencastingPrivate(Registry *registry, int id, int version, Screencasting *q)
: QtWayland::zkde_screencast_unstable_v1(*registry, id, version)
, q(q)
{
}
ScreencastingPrivate(::zkde_screencast_unstable_v1 *screencasting, Screencasting *q)
: QtWayland::zkde_screencast_unstable_v1(screencasting)
, q(q)
{
}
~ScreencastingPrivate()
{
destroy();
}
Screencasting *const q;
};
Screencasting::Screencasting(QObject *parent)
:QObject(parent)
{
}
Screencasting::Screencasting(Registry *registry, int id, int version, QObject *parent)
: QObject(parent)
, d(new ScreencastingPrivate(registry, id, version, this))
{
}
Screencasting::~Screencasting() = default;
ScreencastingStream *Screencasting::createWindowStream(const QString &uuid, CursorMode mode)
{
auto stream = new ScreencastingStream(this);
stream->d->init(d->stream_window(uuid, mode));
return stream;
}
void Screencasting::setup(::zkde_screencast_unstable_v1 *screencasting)
{
d.reset(new ScreencastingPrivate(screencasting, this));
}
void Screencasting::destroy()
{
d.reset(nullptr);
}

View File

@ -0,0 +1,67 @@
#ifndef SCREENCASTING_H
#define SCREENCASTING_H
#include <QObject>
#include <QSharedPointer>
#include <QVector>
#include <optional>
struct zkde_screencast_unstable_v1;
namespace KWayland
{
namespace Client
{
class PlasmaWindow;
class Registry;
class Output;
}
}
class ScreencastingPrivate;
class ScreencastingStreamPrivate;
class ScreencastingStream : public QObject
{
Q_OBJECT
public:
ScreencastingStream(QObject *parent);
~ScreencastingStream() override;
quint32 nodeId() const;
Q_SIGNALS:
void created(quint32 nodeid);
void failed(const QString &error);
void closed();
private:
friend class Screencasting;
QScopedPointer<ScreencastingStreamPrivate> d;
};
class Screencasting : public QObject
{
Q_OBJECT
public:
explicit Screencasting(QObject *parent = nullptr);
explicit Screencasting(KWayland::Client::Registry *registry, int id, int version, QObject *parent = nullptr);
~Screencasting() override;
enum CursorMode {
Hidden = 1,
Embedded = 2,
Metadata = 4,
};
Q_ENUM(CursorMode);
ScreencastingStream *createWindowStream(const QString &uuid, CursorMode mode);
void setup(zkde_screencast_unstable_v1 *screencasting);
void destroy();
private:
QScopedPointer<ScreencastingPrivate> d;
};
#endif // SCREENCASTING_H

View File

@ -0,0 +1,128 @@
#include "screencastingrequest.h"
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/registry.h>
#include <QCoreApplication>
#include <QDebug>
#include <QPointer>
#include <functional>
class ScreencastingSingleton : public QObject
{
Q_OBJECT
public:
ScreencastingSingleton(QObject *parent)
: QObject(parent)
{
KWayland::Client::ConnectionThread *connection = KWayland::Client::ConnectionThread::fromApplication(this);
if (!connection) {
return;
}
KWayland::Client::Registry *registry = new KWayland::Client::Registry(this);
connect(registry,
&KWayland::Client::Registry::interfaceAnnounced,
this,
[this, registry](const QByteArray &interfaceName, quint32 name, quint32 version) {
if (interfaceName != "zkde_screencast_unstable_v1")
return;
m_screencasting = new Screencasting(registry, name, version, this);
Q_EMIT created(m_screencasting);
});
registry->create(connection);
registry->setup();
}
static ScreencastingSingleton *self()
{
static QPointer<ScreencastingSingleton> s_self;
if (!s_self && QCoreApplication::instance())
s_self = new ScreencastingSingleton(QCoreApplication::instance());
return s_self;
}
void requestInterface(ScreencastingRequest *item)
{
if (!m_screencasting) {
connect(this, &ScreencastingSingleton::created, item, &ScreencastingRequest::create, Qt::UniqueConnection);
} else {
item->create(m_screencasting);
}
}
Q_SIGNALS:
void created(Screencasting *screencasting);
private:
Screencasting *m_screencasting = nullptr;
};
ScreencastingRequest::ScreencastingRequest(QObject *parent)
:QObject(parent)
{
}
ScreencastingRequest::~ScreencastingRequest() = default;
quint32 ScreencastingRequest::nodeId() const
{
return m_nodeId;
}
void ScreencastingRequest::setNodeid(uint nodeId)
{
if (nodeId == m_nodeId) {
return;
}
m_nodeId = nodeId;
Q_EMIT nodeIdChanged(nodeId);
}
QString ScreencastingRequest::uuid() const
{
return m_uuid;
}
void ScreencastingRequest::setUuid(const QString &uuid)
{
if (m_uuid == uuid) {
return;
}
Q_EMIT closeRunningStreams();
setNodeid(0);
m_uuid = uuid;
if (!m_uuid.isEmpty()) {
ScreencastingSingleton::self()->requestInterface(this);
}
Q_EMIT uuidChanged(uuid);
}
void ScreencastingRequest::create(Screencasting *screencasting)
{
auto stream = screencasting->createWindowStream(m_uuid, Screencasting::CursorMode::Hidden);
stream->setObjectName(m_uuid);
connect(stream, &ScreencastingStream::created, this, [stream, this](int nodeId) {
if (stream->objectName() == m_uuid) {
setNodeid(nodeId);
}
});
connect(stream, &ScreencastingStream::failed, this, [](const QString &error) {
qWarning() << "error creating screencast" << error;
});
connect(stream, &ScreencastingStream::closed, this, [this, stream] {
if (stream->nodeId() == m_nodeId) {
setNodeid(0);
}
});
connect(this, &ScreencastingRequest::closeRunningStreams, stream, &QObject::deleteLater);
}
#include "screencastingrequest.moc"

View File

@ -0,0 +1,39 @@
#ifndef SCREENCASTINGREQUEST_H
#define SCREENCASTINGREQUEST_H
#include "screencasting.h"
#include <QObject>
class ScreencastingStream;
class ScreencastingRequest : public QObject
{
Q_OBJECT
Q_PROPERTY(QString uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
Q_PROPERTY(quint32 nodeId READ nodeId NOTIFY nodeIdChanged)
public:
ScreencastingRequest(QObject *parent = nullptr);
~ScreencastingRequest();
void setUuid(const QString &uuid);
QString uuid() const;
quint32 nodeId() const;
void create(Screencasting *screencasting);
Q_SIGNALS:
void nodeIdChanged(quint32 nodeId);
void uuidChanged(const QString &uuid);
void closeRunningStreams();
void cursorModeChanged(Screencasting::CursorMode cursorMode);
private:
void setNodeid(uint nodeId);
ScreencastingStream *m_stream = nullptr;
QString m_uuid;
KWayland::Client::Output *m_output = nullptr;
quint32 m_nodeId = 0;
};
#endif // SCREENCASTINGREQUEST_H

View File

@ -0,0 +1,18 @@
#include "taskmanagerplugin.h"
#include "pipewiresourceitem.h"
#include "screencasting.h"
#include "screencastingrequest.h"
namespace TaskManager
{
void TaskManagerPlugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.ukui.panel.taskmanager"));
qmlRegisterType<PipeWireSourceItem>(uri, 0, 1, "PipeWireSourceItem");
qmlRegisterType<ScreencastingRequest>(uri, 0, 1, "ScreencastingRequest");
qmlRegisterUncreatableType<Screencasting>(uri, 0, 1, "Screencasting", "Use ScreencastingItem");
}
}

View File

@ -0,0 +1,20 @@
#ifndef TASKMANAGERPLUGIN_H
#define TASKMANAGERPLUGIN_H
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
namespace TaskManager
{
class TaskManagerPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char *uri) override;
};
}
#endif // TASKMANAGERPLUGIN_H

View File

@ -1,29 +0,0 @@
.TH ukui "1" "2019-08-01" "UKUI 0.10.0" "UKUI Desktop Panel Module"
.SH NAME
ukui-panel \- The Panel for the UKUI Desktop Environment
.SH SYNOPSIS
.B ukui-panel
.br
.SH DESCRIPTION
This module adds a panel, with optional plugins, to the desktop.
.SH BEHAVIOR
The panel can be run independently of \fBUKUI\fR, autostarted at logon, and have
multiple instances. A horizontal bottom panel shows by default on the desktop,
but the size, autohide, and other attributes
.P
The panel is comprised of plugins which provide a visual widget; like the startmenu,
taskbar, or quicklaunch. They can be added or removed in the panel Widget settings.
.P
Several plugins are loaded by default; the desktop menu and windows workspaces
are also managed here.
.SH CONFIGURATIONS
Right-click over any plugin to reach the panel Configure settings option, or
that of each respective plugin.
.SH "REPORTING BUGS"
Report bugs to https://github.com/ukui/ukui-panel/issues
.SH "SEE ALSO"
.SS
Ukui Panel documentation can be found under "Help" by right-clicking on \fBukui-panel\fR.
Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P

View File

@ -1,29 +0,0 @@
.TH ukui "1" "2019-08-01" "UKUI 0.10.0" "UKUI Desktop Panel Module"
.SH NAME
ukui-panel \- The Panel for the UKUI Desktop Environment
.SH SYNOPSIS
.B ukui-panel
.br
.SH DESCRIPTION
This module adds a panel, with optional plugins, to the desktop.
.SH BEHAVIOR
The panel can be run independently of \fBUKUI\fR, autostarted at logon, and have
multiple instances. A horizontal bottom panel shows by default on the desktop,
but the size, autohide, and other attributes
.P
The panel is comprised of plugins which provide a visual widget; like the startmenu,
taskbar, or quicklaunch. They can be added or removed in the panel Widget settings.
.P
Several plugins are loaded by default; the desktop menu and windows workspaces
are also managed here.
.SH CONFIGURATIONS
Right-click over any plugin to reach the panel Configure settings option, or
that of each respective plugin.
.SH "REPORTING BUGS"
Report bugs to https://github.com/ukui/ukui-panel/issues
.SH "SEE ALSO"
.SS
Ukui Panel documentation can be found under "Help" by right-clicking on \fBukui-panel\fR.
Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P

View File

@ -1,29 +0,0 @@
.TH ukui "1" "2019-08-01" "UKUI 0.10.0" "UKUI Desktop Panel Module"
.SH NAME
ukui-panel \- The Panel for the UKUI Desktop Environment
.SH SYNOPSIS
.B ukui-panel
.br
.SH DESCRIPTION
This module adds a panel, with optional plugins, to the desktop.
.SH BEHAVIOR
The panel can be run independently of \fBUKUI\fR, autostarted at logon, and have
multiple instances. A horizontal bottom panel shows by default on the desktop,
but the size, autohide, and other attributes
.P
The panel is comprised of plugins which provide a visual widget; like the startmenu,
taskbar, or quicklaunch. They can be added or removed in the panel Widget settings.
.P
Several plugins are loaded by default; the desktop menu and windows workspaces
are also managed here.
.SH CONFIGURATIONS
Right-click over any plugin to reach the panel Configure settings option, or
that of each respective plugin.
.SH "REPORTING BUGS"
Report bugs to https://github.com/ukui/ukui-panel/issues
.SH "SEE ALSO"
.SS
Ukui Panel documentation can be found under "Help" by right-clicking on \fBukui-panel\fR.
Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P

View File

@ -22,12 +22,12 @@ find_package(Qt5DBus REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(KF5WindowSystem REQUIRED)
pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0 udisks2)
pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0)
pkg_check_modules(QGS REQUIRED gsettings-qt)
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories(${QGS_INCLUDE_DIRS})
add_executable(panel-daemon
jsonwathcer/jsonwacther.cpp
jsonwathcer/jsonwacther.h
@ -53,7 +53,20 @@ add_executable(panel-daemon
add_definitions(-DQT_MESSAGELOGCONTEXT)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::DBus Qt5::Network ${GLIB2_LIBRARIES} ${QGS_LIBRARIES} KF5::WindowSystem)
pkg_check_modules(KYSDKWAYLANDHELPER_PKG kysdk-waylandhelper)
target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS} KF5::WindowSystem)
target_link_libraries(${PROJECT_NAME} ${KYSDKWAYLANDHELPER_PKG_LIBRARIES})
target_link_libraries(${PROJECT_NAME}
Qt5::Widgets
Qt5::DBus
Qt5::Network
${GLIB2_LIBRARIES}
${QGS_LIBRARIES}
KF5::WindowSystem
)
install(TARGETS panel-daemon DESTINATION bin)

View File

@ -20,23 +20,39 @@
#include <QFile>
#include <QDebug>
#include <QDir>
#include "kysdk/applications/windowmanager/windowmanager.h"
ConvertDesktopToWinId::ConvertDesktopToWinId()
{
//connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, &ConvertDesktopToWinId::tranIdToDesktop);
}
QString ConvertDesktopToWinId::tranIdToDesktop(WId id)
QString ConvertDesktopToWinId::tranIdToDesktop(int winId)
{
QString desktopName = confirmDesktopFile(id);
QString desktopName = confirmDesktopFile(winId);
qDebug() << "desktopName is :" << desktopName;
return desktopName;
}
QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
int ConvertDesktopToWinId::getPidFromInfo(int winId)
{
KWindowInfo info(id, 0, NET::WM2AllProperties);
//x环境下输入wid转成pid, wayland下windowId转pid
KWindowInfo info(winId, NET::WMPid);
if (info.valid(/* withdrawn_is_valid = */ true)) {
m_pid = info.pid();
} else {
m_pid = kdk::WindowManager::getPid(winId);
}
return m_pid;
}
QString ConvertDesktopToWinId::confirmDesktopFile(int id)
{
m_pid = getPidFromInfo(id);
if (m_pid == 0) {
return {};
}
m_desktopfilePath = "";
QDir infoDir(DEKSTOP_FILE_PATH);
m_list = infoDir.entryInfoList();
@ -52,12 +68,11 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
//第一种方法:比较名字一致性
if (m_desktopfilePath.isEmpty()) {
m_classClass = info.windowClassClass().toLower();
m_className = info.windowClassName();
m_className = kdk::WindowManager::getWindowGroup(id);
//匹配安卓兼容
if (m_className == "kylin-kmre-window") {
searchAndroidApp(info);
searchAndroidApp(id);
return m_desktopfilePath;
}
@ -67,7 +82,7 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
return m_desktopfilePath;
}
QFile file(QString("/proc/%1/status").arg(info.pid()));
QFile file(QString("/proc/%1/status").arg(m_pid));
if (file.open(QIODevice::ReadOnly)) {
char buf[1024];
qint64 len=file.readLine(buf,sizeof(buf));
@ -77,15 +92,14 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
}
compareClassName();
}
//第二种方法获取点击应用时大部分desktop文件名
if (m_desktopfilePath.isEmpty()) {
searchFromEnviron(info);
searchFromEnviron(id);
}
//第三种方法比较cmd命令行操作一致性
if (m_desktopfilePath.isEmpty()) {
QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
QFile file(QString("/proc/%1/cmdline").arg(m_pid));
if (file.open(QIODevice::ReadOnly)) {
char buf[1024];
qint64 len=file.readLine(buf,sizeof(buf));
@ -103,14 +117,14 @@ QString ConvertDesktopToWinId::confirmDesktopFile(WId id)
return m_desktopfilePath;
}
void ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info)
void ConvertDesktopToWinId::searchAndroidApp(int id)
{
QDir androidDir(QString(QDir::homePath() + ANDROID_FILE_PATH));
m_androidList = androidDir.entryInfoList();
m_androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT);
m_androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER);
QFile file(QString("/proc/%1/cmdline").arg(info.pid()));
QFile file(QString("/proc/%1/cmdline").arg(m_pid));
file.open(QIODevice::ReadOnly);
QByteArray cmd = file.readAll();
file.close();
@ -150,9 +164,9 @@ void ConvertDesktopToWinId::searchTXeduApp(WId id)
}
}
void ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info)
void ConvertDesktopToWinId::searchFromEnviron(int id)
{
QFile file("/proc/" + QString::number(info.pid()) + "/environ");
QFile file("/proc/" + QString::number(m_pid) + "/environ");
file.open(QIODevice::ReadOnly);
QByteArray BA = file.readAll();
file.close();
@ -189,7 +203,7 @@ void ConvertDesktopToWinId::compareClassName()
}
path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1);
path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf("."));
if (path_desktop_name == m_classClass || path_desktop_name == m_className || path_desktop_name == m_statusName) {
if (path_desktop_name == m_className || path_desktop_name == m_statusName) {
m_desktopfilePath = fileInfo.filePath();
break;
}

View File

@ -19,7 +19,6 @@
#ifndef CONVERTDESKTOPTOWINID_H
#define CONVERTDESKTOPTOWINID_H
#include "convertdesktoptowinid.h"
#include <QObject>
#include <KWindowSystem>
#include <QDir>
@ -57,7 +56,6 @@ public:
~ConvertDesktopToWinId();
//QList<int> InfoPidList;
QString m_desktopfilePath = nullptr;
QString m_classClass = nullptr;
QString m_className = nullptr;
QString m_statusName = nullptr;
QString m_cmdLine = nullptr;
@ -67,12 +65,13 @@ public:
QFileInfoList m_list;
QFileInfoList m_androidList;
QString tranIdToDesktop(WId id);
QString tranIdToDesktop(int winId);
int getPidFromInfo(int winId);
private:
QString confirmDesktopFile(WId id);
void searchFromEnviron(KWindowInfo info);
void searchAndroidApp(KWindowInfo info);
QString confirmDesktopFile(int id);
void searchFromEnviron(int id);
void searchAndroidApp(int id);
void searchTXeduApp(WId id);
void compareClassName();
void compareCmdExec();
@ -81,6 +80,8 @@ private:
void compareDesktopClass();
void containsName();
QString getDesktopFileName(QString cmd);
int m_pid;
};
#endif // CONVERTDESKTOPTOWINID_H

View File

@ -1,11 +1,9 @@
set(PROJECT ukui-panel)
project(ukui-panel LANGUAGES C CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
add_subdirectory(common)
#add_subdirectory(xdg)
#add_subdirectory(common_fun)
set(PRIV_HEADERS
panelpluginsmodel.h
@ -15,7 +13,7 @@ set(PRIV_HEADERS
ukuipanellayout.h
plugin.h
pluginsettings_p.h
highlight-effect.h
contextmenu.h
)
# using UKUi namespace in the public headers.
@ -24,12 +22,10 @@ set(PUB_HEADERS
pluginsettings.h
iukuipanelplugin.h
iukuipanel.h
common/ukuisettings.h
common/ukuiplugininfo.h
common/ukuitranslator.h
common/common.h
common/ukuigridlayout.h
common/ukuiglobals.h
common_fun/listengsettings.h
@ -48,25 +44,29 @@ set(SOURCES
ukuipanellayout.cpp
plugin.cpp
pluginsettings.cpp
contextmenu.cpp
common/ukuiplugininfo.cpp
common/ukuisettings.cpp
common/ukuitranslator.cpp
common/ukuigridlayout.cpp
common_fun/listengsettings.cpp
common_fun/ukuipanel_infomation.cpp
common_fun/dbus-adaptor.cpp
common_fun/panel_commission.cpp
customstyle.cpp
highlight-effect.cpp
)
############################################
set(PLUGIN_DESKTOPS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/ukui/${PROJECT_NAME}")
set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus)
set(UKUI_PANEL_MAN ../man/ukui-panel.1)
set(DESKTOP_FILE resources/ukui-panel.desktop)
set(IMAGE_DIR ./img/)
set(GSETTINGS_FILE resources/org.ukui.panel.settings.gschema.xml)
set(PANEL_GLOBAL_CONFIG_FILES resources/panel-commission.sh resources/panel-commission.ini
resources/ukui-panel-reset.sh resources/ukui-panel-config.sh)
file(GLOB UKUI_PANEL_CONFIG_FILES resources/*.conf)
add_definitions(-DCOMPILE_UKUI_PANEL)
set(PLUGIN_DESKTOPS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/ukui/${PROJECT}")
add_definitions(-DPLUGIN_DESKTOPS_DIR=\"${PLUGIN_DESKTOPS_DIR}\")
if (WITH_SCREENSAVER_FALLBACK)
@ -74,38 +74,21 @@ if (WITH_SCREENSAVER_FALLBACK)
add_definitions(-DWITH_SCREENSAVER_FALLBACK "-DUKUI_LOCK_DESKTOP=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications/ukui-lockscreen.desktop\"")
endif ()
project(${PROJECT})
set(QTX_LIBRARIES Qt5::Widgets Qt5::Xml Qt5::DBus)
#Translations
#ukui_translate_ts(QM_FILES SOURCES
# UPDATE_TRANSLATIONS
# ${UPDATE_TRANSLATIONS}
# SOURCES
# ${PUB_HEADERS}
# ${PRIV_HEADERS}
# ${SOURCES}
# ${UI}
# INSTALL_DIR
# "${UKUI_TRANSLATIONS_DIR}/${PROJECT_NAME}"
#)
ukui_app_translation_loader(SOURCES ${PROJECT_NAME})
set_property(SOURCE ${DBUS_INTERFACE_SRCS} ${DBUS_ADAPTOR_SRCS} PROPERTY SKIP_AUTOGEN ON)
list(APPEND SOURCES "${DBUS_INTERFACE_SRCS}" "${DBUS_ADAPTOR_SRCS}")
add_executable(${PROJECT}
#
file(GLOB TS_FILES "translation/*.ts")
# .qm
qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
add_executable(${PROJECT_NAME}
${PUB_HEADERS}
${PRIV_HEADERS}
${QM_FILES}
${SOURCES}
${UI}
)
find_package(PkgConfig)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GIO2 REQUIRED gio-2.0)
@ -117,9 +100,10 @@ include_directories(${Gsetting_INCLUDE_DIRS})
find_package(PkgConfig REQUIRED)
find_package(KF5WindowSystem)
find_package(KF5Screen)
pkg_check_modules(KYSDKWAYLANDHELPER_PKG kysdk-waylandhelper)
#ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
target_link_libraries(${PROJECT}
target_link_libraries(${PROJECT_NAME}
${LIBRARIES}
${QTX_LIBRARIES}
KF5::WindowSystem
@ -128,88 +112,40 @@ target_link_libraries(${PROJECT}
${GLIB2_LIBRARIES}
${GIO2_LIBRARIES}
${Gsetting_LIBRARIES}
Qt${QT_VERSION_MAJOR}::Quick
KF5::Screen
)
target_include_directories(${PROJECT} PRIVATE ${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS})
target_link_directories(${PROJECT} PRIVATE ${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS} KF5::WindowSystem)
target_link_libraries(${PROJECT} ${KYSDKWAYLANDHELPER_PKG_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS})
target_link_directories(${PROJECT_NAME} PRIVATE ${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS} KF5::WindowSystem)
target_link_libraries(${PROJECT_NAME} ${KYSDKWAYLANDHELPER_PKG_LIBRARIES})
target_compile_definitions(${PROJECT}
target_compile_definitions(${PROJECT_NAME}
PRIVATE
"UKUI_RELATIVE_SHARE_DIR=\"${UKUI_RELATIVE_SHARE_DIR}\""
#"UKUI_SHARE_DIR=\"${UKUI_SHARE_DIR}\""
"UKUI_RELATIVE_SHARE_TRANSLATIONS_DIR=\"${UKUI_RELATIVE_TRANSLATIONS_DIR}\""
"UKUI_SHARE_TRANSLATIONS_DIR=\"${UKUI_TRANSLATIONS_DIR}\""
"UKUI_GRAPHICS_DIR=\"${UKUI_GRAPHICS_DIR}\""
#"UKUI_ETC_XDG_DIR=\"${UKUI_ETC_XDG_DIR}\""
"UKUI_DATA_DIR=\"${UKUI_DATA_DIR}\""
"UKUI_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\""
#"UKUI_VERSION=\"${UKUI_VERSION}\""
#"COMPILE_LIBUKUI"
#"QT_USE_QSTRINGBUILDER"
#"QT_NO_CAST_FROM_ASCII"
#"QT_NO_CAST_TO_ASCII"
#"QT_NO_URL_CAST_FROM_STRING"
#"QT_NO_CAST_FROM_BYTEARRAY"
#"$<$<CONFIG:Release>:QT_NO_DEBUG_OUTPUT>"
#"$<$<CONFIG:Release>:QT_NO_WARNING_OUTPUT>"
)
install(TARGETS ${PROJECT} RUNTIME DESTINATION bin)
file(GLOB CONFIG_FILES resources/*.conf resources/*.qss)
install(FILES ${CONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/ukui)
#ukui-panel
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
#DESKTOP FILE
install(FILES ${DESKTOP_FILE} DESTINATION "/etc/xdg/autostart/" COMPONENT Runtime)
install(FILES ${UKUI_PANEL_CONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/ukui)
install(FILES ${PUB_HEADERS} DESTINATION include/ukui)
install(FILES
../man/ukui-panel.1
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
COMPONENT Runtime
)
install(FILES
resources/ukui-panel.desktop
DESTINATION "/etc/xdg/autostart/"
COMPONENT Runtime
)
install(FILES
resources/ukui-panel.desktop
DESTINATION "/usr/share/applications/"
COMPONENT Runtime
)
install(DIRECTORY
./img/
DESTINATION "${PACKAGE_DATA_DIR}/panel/img"
)
install(FILES
resources/ukui-panel_zh_CN.qm resources/ukui-panel_zh_CN.ts resources/ukui-panel_tr.ts
DESTINATION "${PACKAGE_DATA_DIR}/panel/resources"
COMPONENT Runtime
)
install(FILES
resources/org.ukui.panel.settings.gschema.xml
DESTINATION "/usr/share/glib-2.0/schemas"
COMPONENT Runtime
)
install(FILES
resources/panel-commission.ini
DESTINATION "/usr/share/ukui/ukui-panel"
COMPONENT Runtime
)
install(FILES
resources/panel-commission.sh resources/ukui-panel-reset.sh resources/ukui-panel-config.sh
DESTINATION "/usr/share/ukui/ukui-panel"
COMPONENT Runtime
install(FILES ${UKUI_PANEL_MAN} DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" COMPONENT Runtime)
install(FILES ${GSETTINGS_FILE} DESTINATION "/usr/share/glib-2.0/schemas" COMPONENT Runtime)
install(FILES ${PANEL_GLOBAL_CONFIG_FILES} DESTINATION "/usr/share/ukui/ukui-panel" COMPONENT Runtime
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE WORLD_EXECUTE
GROUP_EXECUTE GROUP_READ
)
install(DIRECTORY ${IMAGE_DIR} DESTINATION "${PACKAGE_DATA_DIR}/panel/img")
set(PLUGIN panel)
include(../cmake/UkuiPluginTranslationTs.cmake)
ukui_plugin_translate_ts(${PLUGIN})
set(PANEL_TRANSLATION_DIR "${PACKAGE_DATA_DIR}/panel/translation")
add_compile_definitions(PANEL_TRANSLATION_DIR="${PANEL_TRANSLATION_DIR}")
install(FILES ${QM_FILES} DESTINATION "${PANEL_TRANSLATION_DIR}")

View File

@ -67,13 +67,23 @@
#define PANEL_SIZE_SMALL_V 47
#define POPUP_BORDER_SPACING 4
#define SETTINGS_SAVE_DELAY 1000
//panel gsettings
#define PANEL_SETTINGS "org.ukui.panel.settings"
#define PANEL_SIZE_KEY "panelsize"
#define ICON_SIZE_KEY "iconsize"
#define PANEL_POSITION_KEY "panelposition"
#define SHOW_TASKVIEW "showtaskview"
#define SHOW_NIGHTMODE "shownightmode"
#define SHOW_TASKVIEW_KEY "showtaskview"
#define LOCK_PANEL_KEY "lockpanel"
#define HIDE_PANEL_KEY "hidepanel"
#define ABOUT_KYLIN_DISPLAY "aboutkylin-display"
#define GROUPING_ENABLE "groupingenable"
#define TASKBAR_BTN_SPAN "taskbarbtnspan"
//panel-daemon DBUS
#define UKUI_PANEL_DAEMON "org.ukui.panel.daemon"
#define UKUI_PANEL_DAEMON_PATH "/convert/desktopwid"
#define UKUI_PANEL_DAEMON_INTERFACE "org.ukui.panel.daemon"
#define UKUI_PANEL_DAEMON_METHOD "WIDToDesktop"
#define TRANSPARENCY_SETTINGS "org.ukui.control-center.personalise"
#define TRANSPARENCY_KEY "transparency"
@ -82,13 +92,76 @@
#define UKUI_PATH "/org/gnome/SessionManager"
#define UKUI_INTERFACE "org.gnome.SessionManager"
#define ORG_UKUI_STYLE "org.ukui.style"
#define STYLE_NAME "styleName"
#define STYLE_NAME_KEY_DARK "ukui-dark"
#define STYLE_NAME_KEY_DEFAULT "ukui-default"
#define STYLE_NAME_KEY_BLACK "ukui-black"
#define STYLE_NAME_KEY_LIGHT "ukui-light"
#define STYLE_NAME_KEY_WHITE "ukui-white"
#define ORG_UKUI_STYLE "org.ukui.style"
#define STYLE_NAME "styleName"
#define STYLE_NAME_KEY_DARK "ukui-dark"
#define STYLE_NAME_KEY_DEFAULT "ukui-default"
#define STYLE_NAME_KEY_BLACK "ukui-black"
#define STYLE_NAME_KEY_LIGHT "ukui-light"
#define STYLE_NAME_KEY_WHITE "ukui-white"
#define STYLE_NAME_KEY_ICONTHEME "iconThemeName"
#define SYSTEM_FONT_SIZE "systemFontSize"
#define WINDOW_RADIUS "windowRadius"
//USD primary screen changed Infomation
#define USD_SERVICE "org.ukui.SettingsDaemon"
#define USD_XRANDER_PATH "/org/ukui/SettingsDaemon/xrandr"
#define USD_XRANDER_INTERFACE "org.ukui.SettingsDaemon.xrandr"
#define PRIMARY_CHANGED "primaryChanged"
//开始菜单DBUS
#define UKUI_MENU_SERVICE "org.ukui.menu"
#define UKUI_MENU_PATH "/org/ukui/menu"
#define UKUI_MENU_INTERFACE "org.ukui.menu"
#define WIN_KEY_RESPONSE "WinKeyResponse"
//系统登录
#define LOGIN_SERVICE "org.freedesktop.login1"
#define LOGIN_PATH "/org/freedesktop/login1"
#define LOGIN_INTERFACE "org.freedesktop.login1.Manager"
#define CAN_SUSPEND_METHOD "CanSuspend"
#define CAN_HIBERNATE_METHOD "CanHibernate"
//系统账户
#define ACCOUNTS_SERVICE "org.freedesktop.Accounts"
#define ACCOUNTS_PATH "/org/freedesktop/Accounts"
#define HAS_MULTIPLE_USER "HasMultipleUsers"
//系统显示
#define DISPLAYMANAGER_SERVICE "org.freedesktop.DisplayManager"
#define DISPLAYMANAGER_PATH "/org/freedesktop/DisplayManager/Seat0"
#define PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
#define DISPLAYMANAGER_INTERFACE "org.freedesktop.DisplayManager.Seat"
#define CAN_SWITCH_METHOD "CanSwitch"
//系统更新
#define SYSTEMUPGRADE_SERVICE "com.kylin.systemupgrade"
#define SYSTEMUPGRADE_PATH "/com/kylin/systemupgrade"
#define SYSTEMUPGRADE_INTERFACE "com.kylin.systemupgrade.interface"
#define CHECK_INSTALL_REQUIRED "CheckInstallRequired"
#define TRIGGER_INSTALL_ON_SHUTDOWN "TriggerInstallOnShutdown"
//窗管
#define OPENGL "gl2"
#define XRENDER "xrender"
#define UKUI_KWIN_SERVICE "org.ukui.KWin"
#define UKUI_KWIN_PATH "/Compositor"
#define UKUI_KWIN_INTERFACE "org.ukui.kwin.Compositing"
#define COMPOSITING_TYPE "compositingType"
#define SDK2CPP(func) []()->QString { char* p = func(); QString str(p); free(p); return str; }
//查询desktop文件
#define UKUI_PANEL_DAEMON "org.ukui.panel.daemon"
#define UKUI_PANEL_DAEMON_PATH "/convert/desktopwid"
#define UKUI_PANEL_DAEMON_INTERFACE "org.ukui.panel.daemon"
#define UKUI_PANEL_DAEMON_METHOD "WIDToDesktop"
#define DESKTOP_FILE_PATH "/usr/share/applications/"
#define ANDROID_DESKTOP_FILE_PATH "/.local/share/applications/"
#define MAX_SIZE_OF_Thumb 16777215
#define PANEL_CONFIG_PATH "/usr/share/ukui/ukui-panel/panel-commission.ini"
#endif // COMMON_H

View File

@ -73,7 +73,7 @@ namespace
animation->setStartValue(item->geometry());
animation->setEndValue(geometry);
++layout->mAnimatedItems;
connect(animation, &QAbstractAnimation::finished, [layout] { --layout->mAnimatedItems; Q_ASSERT(0 <= layout->mAnimatedItems); });
connect(animation, &QAbstractAnimation::finished, [=] { --layout->mAnimatedItems; Q_ASSERT(0 <= layout->mAnimatedItems); animation->deleteLater();});
animation->start(DeleteWhenStopped);
}
@ -635,11 +635,9 @@ void GridLayout::setGeometry(const QRect &geometry)
qDebug() << "Item:" << "h:" << itemHeight << " w:" << itemWidth;
#endif
int remain_height = heightRemain;
int remain_width = widthRemain;
if (d->mDirection == LeftToRight)
{
int height = itemHeight + (0 < remain_height-- ? 1 : 0);
int height = itemHeight, lastHeight = height;
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
for(int i=0;i<d->mItems.size();i++){
QLayoutItem *item=d->mItems[i];
@ -649,25 +647,28 @@ void GridLayout::setGeometry(const QRect &geometry)
#endif
if (!item->widget() || item->widget()->isHidden())
continue;
int width = itemWidth + (0 < remain_width-- ? 1 : 0);
int width = itemWidth;
if(item->widget())
{
width = item->widget()->width();
height = item->widget()->height();
}
if (x + width > maxX)
{
x = geometry.left();
y += height;
height = itemHeight + (0 < remain_height-- ? 1 : 0);
remain_width = widthRemain;
y += lastHeight;
}
const int left = visual_h_reversed ? geometry.left() + geometry.right() - x - width + 1 : x;
d->setItemGeometry(item, QRect(left, y, width, height));
x += width;
lastHeight = height;
}
}
else
{
int width = itemWidth + (0 < remain_width-- ? 1 : 0);
int width = itemWidth;
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
for(int i=0;i<d->mItems.size();i++)
{
@ -679,15 +680,18 @@ void GridLayout::setGeometry(const QRect &geometry)
#endif
if (!item->widget() || item->widget()->isHidden())
continue;
int height = itemHeight + (0 < remain_height-- ? 1 : 0);
int height = itemHeight;
if (item->widget())
{
height = item->widget()->height();
}
if (y + height > maxY)
{
y = geometry.top();
x += width;
width = itemWidth + (0 < remain_width-- ? 1 : 0);
remain_height = heightRemain;
width = itemWidth;
}
const int left = visual_h_reversed ? geometry.left() + geometry.right() - x - width + 1 : x;
d->setItemGeometry(item, QRect(left, y, width, height));

View File

@ -78,7 +78,7 @@ public:
overwritten. Otherwise, it overwrites the the un-localized version. */
void setLocalizedValue(const QString &key, const QVariant &value);
signals:
Q_SIGNALS:
/*! /brief signal for backward compatibility (emitted whenever settingsChangedFromExternal() or settingsChangedByApp() is emitted)
*/
void settingsChanged();
@ -92,11 +92,11 @@ signals:
protected:
bool event(QEvent *event);
protected slots:
protected Q_SLOTS:
/*! Called when the config file is changed */
virtual void fileChanged();
private slots:
private Q_SLOTS:
void _fileChanged(QString path);
private:
@ -197,14 +197,14 @@ public:
GlobalSettings();
~GlobalSettings();
signals:
Q_SIGNALS:
/// Signal emitted when the icon theme has changed.
void iconThemeChanged();
/// Signal emitted when the ukui theme has changed.
void ukuiThemeChanged();
protected slots:
protected Q_SLOTS:
void fileChanged();
private:

View File

@ -195,6 +195,20 @@ QVariantList UKuiPanelInformation::GetPrimaryScreenPhysicalGeometry()
QString UKuiPanelInformation::GetPanelPosition()
{
QString str="bottom";
QString str;
switch(m_panelPosition) {
case PanelPosition::Top:
str="top";
break;
case PanelPosition::Left:
str="left";
break;
case PanelPosition::Right:
str="right";
break;
default:
str="bottom";
break;
}
return str;
}

View File

@ -37,6 +37,13 @@ private:
int m_panelPosition;
int m_panelSize;
enum PanelPosition{
Bottom = 0,
Top = 1,
Left = 2,
Right = 3
};
public Q_SLOTS:
QVariantList GetPrimaryScreenGeometry();
QVariantList GetPrimaryScreenAvailableGeometry();

188
panel/contextmenu.cpp Normal file
View File

@ -0,0 +1,188 @@
#include "contextmenu.h"
#include <QFileInfo>
#include <QProcess>
#include <KWindowSystem>
ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent)
{
const QByteArray id(PANEL_SETTINGS);
if (QGSettings::isSchemaInstalled(PANEL_SETTINGS)) {
m_gsettings = new QGSettings(id);
m_gsettingsKeys = m_gsettings->keys();
}
//设置任务栏
QAction *setPanel;
setPanel = new QAction(this);
setPanel->setText(tr("Set Panel"));
this->addAction(setPanel);
connect(setPanel, &QAction::triggered, [this](){
QProcess::startDetached(QString("ukui-control-center -m ukccpanel"));
});
QAction * showtaskview = this->addAction(tr("Show Taskview"));
showtaskview->setCheckable(true);
if (m_gsettingsKeys.contains(SHOW_TASKVIEW_KEY)) {
showtaskview->setChecked(m_gsettings->get(SHOW_TASKVIEW_KEY).toBool());
connect(showtaskview, &QAction::triggered, [this] { showTaskView(); });
}
this->addAction(tr("Show Desktop"),
this,[=]{showDesktop();}
);
this->addSeparator();
if(QFileInfo::exists(QString("/usr/bin/ukui-system-monitor"))) {
this->addAction(tr("Show System Monitor"),
this,[=] {systeMonitor();}
);
}
this->addSeparator();
adjustPanel();
QAction * m_lockAction = this->addAction(tr("Lock This Panel"));
m_lockAction->setCheckable(true);
m_lockAction->setChecked(m_lockPanel);
if (m_gsettingsKeys.contains(LOCK_PANEL_KEY)) {
connect(m_lockAction, &QAction::triggered, [this] { m_gsettings->set(LOCK_PANEL_KEY,!m_gsettings->get(LOCK_PANEL_KEY).toBool());});
}
QAction *about;
about = new QAction(this);
about->setText(tr("About Kylin"));
if (m_gsettingsKeys.contains(ABOUT_KYLIN_DISPLAY)) {
if (m_gsettings->get(ABOUT_KYLIN_DISPLAY).toBool()) {
this->addAction(about);
connect(about,&QAction::triggered, [this] {
QProcess::startDetached(QString("ukui-control-center -m About"));
});
}
}
}
void ContextMenu::adjustPanel()
{
if (m_gsettingsKeys.contains(LOCK_PANEL_KEY)) {
m_lockPanel = m_gsettings->get(LOCK_PANEL_KEY).toBool();
} else {
m_lockPanel = false;
}
QAction *pmenuaction_s;
QAction *pmenuaction_m;
QAction *pmenuaction_l;
pmenuaction_s = new QAction(this);
pmenuaction_s->setText(tr("Small"));
pmenuaction_m = new QAction(this);
pmenuaction_m->setText(tr("Medium"));
pmenuaction_l = new QAction(this);
pmenuaction_l->setText(tr("Large"));
QMenu *pmenu_panelsize;
pmenu_panelsize = new QMenu(this);
pmenu_panelsize->setTitle(tr("Adjustment Size"));
pmenu_panelsize->addAction(pmenuaction_s);
pmenu_panelsize->addAction(pmenuaction_m);
pmenu_panelsize->addAction(pmenuaction_l);
pmenu_panelsize->setWindowOpacity(0.9);
this->addMenu(pmenu_panelsize);
pmenuaction_s->setCheckable(true);
pmenuaction_m->setCheckable(true);
pmenuaction_l->setCheckable(true);
if (m_gsettingsKeys.contains(PANEL_SIZE_KEY)) {
pmenuaction_s->setChecked(m_gsettings->get(PANEL_SIZE_KEY).toInt()==PANEL_SIZE_SMALL);
pmenuaction_m->setChecked(m_gsettings->get(PANEL_SIZE_KEY).toInt()==PANEL_SIZE_MEDIUM);
pmenuaction_l->setChecked(m_gsettings->get(PANEL_SIZE_KEY).toInt()==PANEL_SIZE_LARGE);
}
connect(pmenuaction_s,&QAction::triggered,[this] {
m_gsettings->set(PANEL_SIZE_KEY,PANEL_SIZE_SMALL);
m_gsettings->set(ICON_SIZE_KEY,ICON_SIZE_SMALL);
});
connect(pmenuaction_m,&QAction::triggered,[this] {
m_gsettings->set(PANEL_SIZE_KEY,PANEL_SIZE_MEDIUM);
m_gsettings->set(ICON_SIZE_KEY,ICON_SIZE_MEDIUM);
});
connect(pmenuaction_l,&QAction::triggered,[this] {
m_gsettings->set(PANEL_SIZE_KEY,PANEL_SIZE_LARGE);
m_gsettings->set(ICON_SIZE_KEY,ICON_SIZE_LARGE);
});
pmenu_panelsize->setDisabled(m_lockPanel);
QAction *pmenuaction_top;
QAction *pmenuaction_bottom;
QAction *pmenuaction_left;
QAction *pmenuaction_right;
pmenuaction_top = new QAction(this);
pmenuaction_top->setText(tr("Up"));
pmenuaction_bottom = new QAction(this);
pmenuaction_bottom->setText(tr("Bottom"));
pmenuaction_left = new QAction(this);
pmenuaction_left->setText(tr("Left"));
pmenuaction_right = new QAction(this);
pmenuaction_right->setText(tr("Right"));
QMenu *pmenu_positon;
pmenu_positon = new QMenu(this);
pmenu_positon->setTitle(tr("Adjustment Position"));
pmenu_positon->addAction(pmenuaction_top);
pmenu_positon->addAction(pmenuaction_bottom);
pmenu_positon->addAction(pmenuaction_left);
pmenu_positon->addAction(pmenuaction_right);
this->addMenu(pmenu_positon);
pmenuaction_top->setCheckable(true);
pmenuaction_bottom->setCheckable(true);
pmenuaction_left->setCheckable(true);
pmenuaction_right->setCheckable(true);
if (m_gsettingsKeys.contains(PANEL_POSITION_KEY)) {
pmenuaction_top->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==1);
pmenuaction_bottom->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==0);
pmenuaction_left->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==2);
pmenuaction_right->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==3);
}
connect(pmenuaction_top,&QAction::triggered, [this] { m_gsettings->set(PANEL_POSITION_KEY,1);});
connect(pmenuaction_bottom,&QAction::triggered, [this] { m_gsettings->set(PANEL_POSITION_KEY,0);});
connect(pmenuaction_left,&QAction::triggered, [this] { m_gsettings->set(PANEL_POSITION_KEY,2);});
connect(pmenuaction_right,&QAction::triggered, [this] { m_gsettings->set(PANEL_POSITION_KEY,3);});
pmenu_positon->setWindowOpacity(0.9);
pmenu_positon->setDisabled(m_lockPanel);
QAction * hidepanel = this->addAction(tr("Hide Panel"));
hidepanel->setDisabled(m_lockPanel);
hidepanel->setCheckable(true);
if (m_gsettingsKeys.contains(HIDE_PANEL_KEY)) {
hidepanel->setChecked(m_gsettings->get(HIDE_PANEL_KEY).toBool());
connect(hidepanel, &QAction::triggered, [this] {
m_gsettings->set(HIDE_PANEL_KEY,!m_gsettings->get(HIDE_PANEL_KEY).toBool());
});
}
}
/*右键 系统监视器选项*/
void ContextMenu::systeMonitor()
{
QProcess *process = new QProcess(this);
process->startDetached("/usr/bin/ukui-system-monitor");
process->deleteLater();
}
/*右键 显示桌面选项*/
void ContextMenu::showDesktop()
{
KWindowSystem::setShowingDesktop(!KWindowSystem::showingDesktop());
}
/*右键 显示任务视图 选项*/
void ContextMenu::showTaskView()
{
if (m_gsettingsKeys.contains(SHOW_TASKVIEW_KEY)) {
m_gsettings->set(SHOW_TASKVIEW_KEY,!m_gsettings->get(SHOW_TASKVIEW_KEY).toBool());
}
}

29
panel/contextmenu.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef CONTEXTMENU_H
#define CONTEXTMENU_H
#include <QObject>
#include <QMenu>
#include <QGSettings>
#include "common/common.h"
class ContextMenu : public QMenu
{
Q_OBJECT
public:
explicit ContextMenu(QWidget *parent = nullptr);
private:
void adjustPanel();
QGSettings *m_gsettings;
QStringList m_gsettingsKeys;
bool m_lockPanel;
//signals:
private Q_SLOTS:
void systeMonitor();
void showDesktop();
void showTaskView();
};
#endif // CONTEXTMENU_H

View File

@ -54,33 +54,43 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
CustomStyle::CustomStyle(const QString &proxyStyleName, bool multileWins, QObject *parent) : QProxyStyle (proxyStyleName)
{
m_pluginName=proxyStyleName;
m_multileWindow=multileWins;
m_pluginName = proxyStyleName;
m_multileWindow = multileWins;
const QByteArray id(ORG_UKUI_STYLE);
QStringList stylelist;
stylelist<<STYLE_NAME_KEY_DARK<<STYLE_NAME_KEY_BLACK<<STYLE_NAME_KEY_DEFAULT;
if (QGSettings::isSchemaInstalled(id)) {
m_gsettings = new QGSettings(id);
if (stylelist.contains(m_gsettings->get(STYLE_NAME).toString()))
m_isDarkStyle=true;
else
m_isDarkStyle=false;
QStringList stylelist;
stylelist << STYLE_NAME_KEY_DARK << STYLE_NAME_KEY_BLACK << STYLE_NAME_KEY_DEFAULT;
if (QGSettings::isSchemaInstalled(id)) {
m_gsettings = new QGSettings(id);
if (stylelist.contains(m_gsettings->get(STYLE_NAME).toString())) {
m_isDarkStyle = true;
} else {
m_isDarkStyle = false;
}
connect(m_gsettings, &QGSettings::changed, this, [=] (const QString &key) {
if (key==STYLE_NAME) {
if (stylelist.contains(m_gsettings->get(STYLE_NAME).toString())) {
m_isDarkStyle=true;
}
else
m_isDarkStyle=false;
}
connect(m_gsettings, &QGSettings::changed, this, [=] (const QString &key) {
if (key == STYLE_NAME) {
if (stylelist.contains(m_gsettings->get(STYLE_NAME).toString())) {
m_isDarkStyle = true;
} else {
m_isDarkStyle = false;
}
});
}
});
}
CustomStyle::~CustomStyle()
{
if (NULL != m_gsettings) {
delete m_gsettings;
m_gsettings = NULL;
}
};
void CustomStyle::setOpacity(int alpha)
{
m_alpha = alpha;
}
/*Draws the given control using the provided painter with the style options specified by option.*/
void CustomStyle::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const
{
@ -116,6 +126,9 @@ void CustomStyle::drawComplexControl(QStyle::ComplexControl cc, const QStyleOpti
QStyleOption tool = *toolbutton;
if (toolbutton->subControls & SC_ToolButton) {
if(QString::compare(m_pluginName,"attentionbutton") == 0) {
proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
}
if (bflags & (State_Sunken | State_On | State_Raised)) {
tool.rect = button;
tool.state = bflags;
@ -319,6 +332,17 @@ void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOp
* PE中有两个toolbutton
*/
case PE_PanelButtonTool:{
if(QString::compare(m_pluginName,"attentionbutton") == 0) {
painter->save();
painter->setRenderHint(QPainter::Antialiasing,true);
QBrush brush = QBrush(QColor(0x23,0x24,0x26,0x14));
painter->setPen(QPen(brush, 1, Qt::SolidLine, Qt::RoundCap));
painter->setBrush(QColor(0xff,0x91,0x00, m_alpha));
painter->drawRoundedRect(option->rect.adjusted(2,2,-2,-2),6,6);
painter->restore();
return;
}
if (m_isDarkStyle) {
if(QString::compare(m_pluginName,"taskbutton")==0) {
painter->save();
@ -335,40 +359,6 @@ void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOp
painter->drawRoundedRect(option->rect.adjusted(2,2,-2,-2),6,6);
painter->restore();
/*buttom center x:22.5 y:42*/
if(m_multileWindow) {
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(Qt::NoPen);
painter->setBrush(option->palette.color(QPalette::Highlight));
painter->drawEllipse(option->rect.topLeft() + QPointF(8.5, 4.5), 2.5, 2.5);
painter->setBrush(option->palette.color(QPalette::Highlight).light(125));
painter->drawEllipse(option->rect.topLeft() + QPointF(4.5, 4.5), 2.5, 2.5);
painter->restore();
}
return;
}
else if(QString::compare(m_pluginName,"closebutton")==0) {
painter->save();
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->drawRoundedRect(option->rect,6,6);
if (option->state & State_MouseOver) {
if (option->state & State_Sunken) {
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0xd7,0x34,0x35));
painter->drawRoundedRect(option->rect,6,6);
} else {
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0xf0,0x41,0x34));
painter->drawRoundedRect(option->rect,4,4);
}
}
painter->restore();
return;
} else {
painter->save();
@ -380,7 +370,7 @@ void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOp
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0xff,0xff,0xff,0x0f));
painter->drawRoundedRect(option->rect,6,6);
painter->drawRoundedRect(option->rect.adjusted(2,2,-2,-2),6,6);
} else {
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
@ -391,6 +381,7 @@ void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOp
painter->restore();
return;
}
//浅色主题
} else {
if(QString::compare(m_pluginName,"taskbutton")==0) {
painter->save();
@ -407,38 +398,6 @@ void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOp
painter->drawRoundedRect(option->rect.adjusted(2,2,-2,-2),6,6);
painter->restore();
if(m_multileWindow) {
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(Qt::NoPen);
painter->setBrush(option->palette.color(QPalette::Highlight));
painter->drawEllipse(option->rect.topLeft() + QPointF(8.5, 4.5), 2.5, 2.5);
painter->setBrush(option->palette.color(QPalette::Highlight).light(125));
painter->drawEllipse(option->rect.topLeft() + QPointF(4.5, 4.5), 2.5, 2.5);
painter->restore();
}
return;
}
else if(QString::compare(m_pluginName,"closebutton")==0) {
painter->save();
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->drawRoundedRect(option->rect,6,6);
if (option->state & State_MouseOver) {
if (option->state & State_Sunken) {
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0xd7,0x34,0x35));
painter->drawRoundedRect(option->rect,6,6);
} else {
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0xf0,0x41,0x34));
painter->drawRoundedRect(option->rect,4,4);
}
}
painter->restore();
return;
} else {
painter->save();
@ -450,7 +409,7 @@ void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOp
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0x00,0x00,0x00,0x0f));
painter->drawRoundedRect(option->rect,6,6);
painter->drawRoundedRect(option->rect.adjusted(2,2,-2,-2),6,6);
} else {
painter->setRenderHint(QPainter::Antialiasing,true);
painter->setPen(Qt::NoPen);

View File

@ -151,13 +151,13 @@ public:
*/
virtual QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget = nullptr) const;
signals:
void setOpacity(int alpha);
public slots:
private:
QString m_pluginName;
bool m_multileWindow = false;
bool m_isDarkStyle;
QGSettings *m_gsettings;
int m_alpha;
};
#endif // CUSTOMSTYLE_H

24
panel/img/leftMask.svg Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.3.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 52 64" style="enable-background:new 0 0 52 64;" xml:space="preserve">
<style type="text/css">
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:url(#左遮罩_1_);}
</style>
<g id="桌面">
<g id="桌面-dock栏状态一览-竖屏" transform="translate(-40.000000, -367.000000)">
<g id="编组-3备份-2" transform="translate(20.000000, 303.000000)">
<g id="Dock栏备份" transform="translate(0.000000, 48.000000)">
<g id="应用区" transform="translate(20.000000, 16.000000)">
<linearGradient id="左遮罩_1_" gradientUnits="userSpaceOnUse" x1="-266.75" y1="475.9844" x2="-267.75" y2="475.9844" gradientTransform="matrix(52 0 0 -64 13923 30495)">
<stop offset="0" style="stop-color:#F5F5F5;stop-opacity:0"/>
<stop offset="1" style="stop-color:#F5F5F5"/>
</linearGradient>
<path id="左遮罩" class="st0" d="M52,0L52,0v64H0V0H52z"/>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1 @@
<svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M12.67,1H3.33A2.33,2.33,0,0,0,1,3.33v9.34A2.33,2.33,0,0,0,3.33,15h9.34A2.33,2.33,0,0,0,15,12.67V3.33A2.33,2.33,0,0,0,12.67,1ZM2,11V3.33A1.34,1.34,0,0,1,3.33,2h9.34A1.34,1.34,0,0,1,14,3.33V11Z" fill="#262626"/></svg>

After

Width:  |  Height:  |  Size: 319 B

View File

@ -96,15 +96,6 @@ public:
MiddleClick = 4 ///< The plugin was clicked with the middle mouse button
};
enum CalendarShowMode
{
lunarSunday = 0,//show lunar and first day a week is sunday
lunarMonday = 1,//show lunar and first day a week is monday
solarSunday = 2,//show solar and first day a week is sunday
solarMonday = 3,//show solar and first day a week is monday
defaultMode = 0xff
};
/**
Constructs an IUKUIPanelPlugin object with the given startupInfo. You do not have to worry
about the startupInfo parameters, IUKUIPanelPlugin processes the parameters itself.

View File

@ -23,7 +23,6 @@
*
* END_COMMON_COPYRIGHT_HEADER */
#include "ukuipanelapplication.h"
#include <QTranslator>
#include <sys/types.h>
@ -37,55 +36,6 @@
#include <QDir>
#include <X11/Xlib.h>
#include <ukui-log4qt.h>
/*! The ukui-panel is the panel of UKUI.
Usage: ukui-panel [CONFIG_ID]
CONFIG_ID Section name in config file ~/.config/ukui/panel.conf
(default main)
*/
void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QByteArray currentTime = QTime::currentTime().toString().toLocal8Bit();
QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/ukui-panel.log";
bool showDebug = true;
if (!QFile::exists(logFilePath)) {
showDebug = false;
}
FILE *log_file = nullptr;
if (showDebug) {
log_file = fopen(logFilePath.toLocal8Bit().constData(), "a+");
}
const char *file = context.file ? context.file : "";
const char *function = context.function ? context.function : "";
switch (type) {
case QtDebugMsg:
if (!log_file) {
break;
}
fprintf(log_file, "Debug: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtInfoMsg:
fprintf(log_file? log_file: stdout, "Info: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtWarningMsg:
fprintf(log_file? log_file: stderr, "Warning: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtCriticalMsg:
fprintf(log_file? log_file: stderr, "Critical: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtFatalMsg:
fprintf(log_file? log_file: stderr, "Fatal: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
}
if (log_file)
fclose(log_file);
}
int main(int argc, char *argv[])
{
@ -111,24 +61,5 @@ int main(int argc, char *argv[])
syslog(LOG_ERR, "Can't lock single file, ukui-panel is already running!");
exit(0);
}
//tanslate
// QString locale = QLocale::system().name();
// QTranslator translator;
// if (locale == "zh_CN"){
// if (translator.load("ukui-panel_zh_CN.qm", "/usr/share/ukui-panel/panel/resources/")){
// app.installTranslator(&translator);
// }
// else{
// qDebug() << "Load translations file" << locale << "failed!";
// }
// }
// if (locale == "tr_TR"){
// if (translator.load("ukui-panel_tr.qm", "/usr/share/ukui-panel/panel/resources/"))
// app.installTranslator(&translator);
// else
// qDebug() << "Load translations file" << locale << "failed!";
// }
return app.exec();
}

View File

@ -51,69 +51,6 @@
#include <XdgIcon>
// statically linked built-in plugins
#if defined(WITH_DESKTOPSWITCH_PLUGIN)
#include "../plugin-desktopswitch/desktopswitch.h" // desktopswitch
extern void * loadPluginTranslation_desktopswitch_helper;
#endif
#if defined(WITH_MAINMENU_PLUGIN)
#include "../plugin-mainmenu/ukuimainmenu.h" // mainmenu
extern void * loadPluginTranslation_mainmenu_helper;
#endif
#if defined(WITH_QUICKLAUNCH_PLUGIN)
#include "../plugin-quicklaunch/ukuiquicklaunchplugin.h" // quicklaunch
extern void * loadPluginTranslation_quicklaunch_helper;
#endif
#if defined(WITH_SHOWDESKTOP_PLUGIN)
#include "../plugin-showdesktop/showdesktop.h" // showdesktop
extern void * loadPluginTranslation_showdesktop_helper;
#endif
#if defined(WITH_SPACERX_PLUGIN)
#include "../plugin-spacerx/spacerx.h" // spacerx
extern void * loadPluginTranslation_spacerx_helper;
#endif
#if defined(WITH_SPACER_PLUGIN)
#include "../plugin-spacer/spacer.h" // spacer
extern void * loadPluginTranslation_spacer_helper;
#endif
#if defined(WITH_STATUSNOTIFIER_PLUGIN)
#include "../plugin-statusnotifier/statusnotifier.h" // statusnotifier
extern void * loadPluginTranslation_statusnotifier_helper;
#endif
#if defined(WITH_TASKBAR_PLUGIN)
#include "../plugin-taskbar/ukuitaskbarplugin.h" // taskbar
extern void * loadPluginTranslation_taskbar_helper;
#endif
#if defined(WITH_TRAY_PLUGIN)
#include "../plugin-tray/ukuitrayplugin.h" // tray
extern void * loadPluginTranslation_tray_helper;
#endif
#if defined(WITH_QUICKLAUNCH_PLUGIN)
#include "../plugin-statusnotifier/statusnotifier.h" // statusnotifier
extern void * loadPluginTranslation_quicklaunch_helper;
#endif
#if defined(WITH_WORLDCLOCK_PLUGIN)
#include "../plugin-worldclock/ukuiworldclock.h" // worldclock
extern void * loadPluginTranslation_worldclock_helper;
#endif
#if defined(WITH_CALENDAR_PLUGIN)
#include "../plugin-calendar/ukuicalendar.h" // indicatorCalendar
extern void * loadPluginTranslation_calendar_helper;
#endif
#if defined(WITH_STARTMENU_PLUGIN)
#include "../plugin-startmenu/startmenu.h" // startmenu
extern void * loadPluginTranslation_startmenu_helper;
#endif
#if defined(WITH_SEGMENTATION_PLUGIN)
#include "../plugin-segmentation/segmentation.h" // startmenu
extern void * loadPluginTranslation_segmentation_helper;
#endif
#if defined(WITH_NIGHTMODE_PLUGIN)
#include "../plugin-nightmode/nightmode.h" // startmenu
extern void * loadPluginTranslation_nightmode_helper;
#endif
QColor Plugin::m_moveMarkerColor= QColor(255, 0, 0, 255);
/************************************************
@ -244,52 +181,6 @@ namespace
// to be not stripped (as unused/unreferenced) in static linking time
static plugin_tuple_t const static_plugins[] = {
#if defined(WITH_CALENDAR_PLUGIN)
std::make_tuple(QLatin1String("calendar"), plugin_ptr_t{new IndicatorCalendarPluginLibrary}, loadPluginTranslation_calendar_helper),// desktopswitch
#endif
#if defined(WITH_DESKTOPSWITCH_PLUGIN)
std::make_tuple(QLatin1String("desktopswitch"), plugin_ptr_t{new DesktopSwitchPluginLibrary}, loadPluginTranslation_desktopswitch_helper),// desktopswitch
#endif
#if defined(WITH_MAINMENU_PLUGIN)
std::make_tuple(QLatin1String("mainmenu"), plugin_ptr_t{new UKUiMainMenuPluginLibrary}, loadPluginTranslation_mainmenu_helper),// mainmenu
#endif
#if defined(WITH_QUICKLAUNCH_PLUGIN)
std::make_tuple(QLatin1String("quicklaunch"), plugin_ptr_t{new UKUIQuickLaunchPluginLibrary}, loadPluginTranslation_quicklaunch_helper),// quicklaunch
#endif
#if defined(WITH_SHOWDESKTOP_PLUGIN)
std::make_tuple(QLatin1String("showdesktop"), plugin_ptr_t{new ShowDesktopLibrary}, loadPluginTranslation_showdesktop_helper),// showdesktop
#endif
#if defined(WITH_SPACERX_PLUGIN)
std::make_tuple(QLatin1String("spacerx"), plugin_ptr_t{new SpacerXPluginLibrary}, loadPluginTranslation_spacerx_helper),// spacerx
#endif
#if defined(WITH_SPACER_PLUGIN)
std::make_tuple(QLatin1String("spacer"), plugin_ptr_t{new SpacerPluginLibrary}, loadPluginTranslation_spacer_helper),// spacer
#endif
#if defined(WITH_STATUSNOTIFIER_PLUGIN)
std::make_tuple(QLatin1String("statusnotifier"), plugin_ptr_t{new StatusNotifierLibrary}, loadPluginTranslation_statusnotifier_helper),// statusnotifier
#endif
#if defined(WITH_TASKBAR_PLUGIN)
std::make_tuple(QLatin1String("taskbar"), plugin_ptr_t{new UKUITaskBarPluginLibrary}, loadPluginTranslation_taskbar_helper),// taskbar
#endif
#if defined(WITH_TRAY_PLUGIN)
std::make_tuple(QLatin1String("tray"), plugin_ptr_t{new UKUITrayPluginLibrary}, loadPluginTranslation_tray_helper),// tray
#endif
#if defined(WITH_WORLDCLOCK_PLUGIN)
std::make_tuple(QLatin1String("worldclock"), plugin_ptr_t{new UKUiWorldClockLibrary}, loadPluginTranslation_worldclock_helper),// worldclock
#endif
#if defined(WITH_CALENDAR_PLUGIN)
std::make_tuple(QLatin1String("calendar"), plugin_ptr_t{new UKUICalendarPluginLibrary}, loadPluginTranslation_calendar_helper),// calendar
#endif
#if defined(WITH_STARTMENU_PLUGIN)
std::make_tuple(QLatin1String("startmenu"), plugin_ptr_t{new UKUIStartMenuLibrary}, loadPluginTranslation_startmenu_helper),// startmenu
#endif
#if defined(WITH_SEGMENTATION_PLUGIN)
std::make_tuple(QLatin1String("segmentation"), plugin_ptr_t{new StartMenuLibrary}, loadPluginTranslation_segementation_helper),// startmenu
#endif
#if defined(WITH_NIGHTMODE_PLUGIN)
std::make_tuple(QLatin1String("nightmode"), plugin_ptr_t{new NightModeLibrary}, loadPluginTranslation_nightmode_helper),// nightmode
#endif
};
static constexpr plugin_tuple_t const * const plugins_begin = static_plugins;
static constexpr plugin_tuple_t const * const plugins_end = static_plugins + sizeof (static_plugins) / sizeof (static_plugins[0]);
@ -418,19 +309,6 @@ void Plugin::saveSettings()
}
/************************************************
************************************************/
void Plugin::contextMenuEvent(QContextMenuEvent *event)
{
m_panel->showPopupMenu(this);
}
/************************************************
************************************************/
void Plugin::mousePressEvent(QMouseEvent *event)
{
switch (event->button())
@ -463,8 +341,7 @@ void Plugin::mouseDoubleClickEvent(QMouseEvent*)
************************************************/
void Plugin::showEvent(QShowEvent *)
{
if (m_pluginWidget)
m_pluginWidget->adjustSize();
realign();
}

View File

@ -102,7 +102,6 @@ signals:
void dragLeft();
protected:
void contextMenuEvent(QContextMenuEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void showEvent(QShowEvent *event);

View File

@ -20,18 +20,17 @@
<summary>show TsskView</summary>
<description>control taskview show or hide</description>
</key>
<key name="shownightmode" type="b">
<key name="aboutkylin-display" type="b">
<default>true</default>
<summary>show TsskView</summary>
<description>control taskview show or hide</description>
<summary>about kylin display</summary>
<description>show or hide About Kylin</description>
</key>
<key name="quicklaunchlines" type="i">
<default>1</default>
<summary>show Quicklaunch Lines</summary>
<description>show Quicklaunch Lines</description>
</key>
<key name="quicklaunchappsnumber" type="i">
<key name="quicklaunchappsnumber" type="i">
<default>8</default>
<summary>show Apps Number</summary>
<description>the size of apps number in quicklaunch</description>
@ -71,6 +70,28 @@
<summary>show Statusnotifier button</summary>
<description>show Statusnotifier button</description>
</key>
<key name="groupingenable" type="b">
<default>true</default>
<summary>If taskbar needs to group</summary>
<description>If taskbar needs to group</description>
</key>
<key name="lockpanel" type="b">
<default>false</default>
<summary>If taskbar needs to lock</summary>
<description>If taskbar needs to lock</description>
</key>
<key name="hidepanel" type="b">
<default>false</default>
<summary>If taskbar needs to hide</summary>
<description>If taskbar needs to hide</description>
</key>
<key name="taskbarbtnspan" type="i">
<default>3</default>
<summary>Taskbar button width</summary>
<description>Taskbar button width</description>
</key>
</schema>
</schemalist>

12
panel/resources/panel-commission.ini Normal file → Executable file
View File

@ -1,15 +1,13 @@
[NightMode]
nightmode=show
active=true
;任务栏配置文件
[Hibernate]
hibernate=show
[Calendar]
CalendarVersion=new
[ShowInTray]
trayname=ukui-volume-control-applet-qt,kylin-nm,ukui-sidebar,indicator-china-weather,ukui-flash-disk,fcitx,sogouimebs-qimpanel,fcitx-qimpanel,explorer.exe,ukui-power-manager-tray,baidu-qimpanel,iflyime-qim,hedronagent,CTJManageTool
[IgnoreWindow]
ignoreWindow=ukui-menu,ukui-sidebar,ukui-search,bluetooth,Form,kylin-nm,ukui-notifications,ukui-power-manager-tray,ukui-volume-control-applet-qt,ukui-flash-disk,ukui-screensaver-dialog,网络工具,蓝牙
ignoreWindow=ukui-menu,ukui-sidebar,ukui-search
[Thumbnail]
thumbnailAvailable=true

28
panel/resources/panel-commission.sh Executable file → Normal file
View File

@ -3,35 +3,10 @@
#判断文件是否存在
commissionFile="${HOME}/.config/ukui/panel-commission.ini"
if [ ! -f "$commissionFile" ]; then
echo "file not exit"
if [[ ! -f "$commissionFile" ]]; then
cp /usr/share/ukui/ukui-panel/panel-commission.ini ${HOME}/.config/ukui
else
echo "file exit"
fi
## 华为990 屏蔽休眠接口
env | grep "XDG_SESSION_TYPE=wayland"
if [ $? -ne 0 ]; then
echo " "
else
echo "华为990"
#sed -i 's/hibernate=show/hibernate=hide/' ${HOME}/.config/ukui/panel-commission.ini
fi
## 华为990 屏蔽夜间模式
env | grep "XDG_SESSION_TYPE=wayland"
if [ $? -ne 0 ]; then
echo " "
else
echo "华为990"
while read line1
do
if [ $line1 == '*nightmode*' ];then
sed -i 's/nightmode=show/nightmode=hide/' ${HOME}/.config/ukui/panel-commission.ini
fi
done < ${HOME}/.config/ukui/panel-commission.ini
fi
##拷贝配置文件到用户目录
panelConfigFile="${HOME}/.config/ukui/panel.conf"
@ -39,3 +14,4 @@ echo $panelConfigFile
if [ ! -f "$panelConfigFile" ]; then
cp /usr/share/ukui/panel.conf ${HOME}/.config/ukui
fi

View File

@ -59,12 +59,10 @@ version=old-calendar
[statusnotifier]
alignment=Right
hideApp=
showApp=ukui-volume-control-applet-qt,kylin-nm,ukui-sidebar,indicator-china-weather,ukui-flash-disk,Fcitx,sogouimebs-qimpanel,fcitx-qimpanel,explorer.exe,ukui-power-manager-tray,baidu-qimpanel,iflyime-qim,hedronagent,CTJManageTool,evolution,ukui-bluetooth
showApp=ukui-search,kylin-nm,ukui-volume-control-applet-qt,Fcitx,fcitx-qimpanel,indicator-china-weather,ukui-flash-disk,sogouimebs-qimpanel,explorer.exe,ukui-power-manager-tray,baidu-qimpanel,iflyime-qim,hedronagent,CTJManageTool,evolution,ukui-bluetooth,kylin-virtual-keyboard
fixedApp=ukui-sidebar
type=statusnotifier
[nightmode]
type=nightmode
[showdesktop]
alignment=Right
type=showdesktop

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
echo "shell file :$0"
echo "plugins $1"
echo "第二个参数$2"

View File

@ -7,8 +7,6 @@ if [ $? -ne 0 ]; then
echo "配置文件异常"
rm ${HOME}/.config/ukui/panel.conf
cp /usr/share/ukui/panel.conf ${HOME}/.config/ukui/
else
echo "配置文件正常"
fi
plugin_conf=""

View File

@ -1,8 +1,8 @@
[Desktop Entry]
Name=ukui-panel
Comment=Panel
comment=Panel
Comment[zh_CN]=任务栏
Exec=/usr/bin/ukui-panel
Exec=ukui-panel
Terminal=false
Type=Application
Icon=panel
@ -10,4 +10,3 @@ X-UKUI-AutoRestart=true
OnlyShowIn=UKUI
NoDisplay=true
X-UKUI-Autostart-Phase=Panel
X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_plasma_activation_feedback,org_kde_kwin_keystate,org_kde_kwin_fake_input,zkde_screencast_unstable_v1

View File

@ -1,81 +0,0 @@
[LockScreen]
name=LockScreen
name[zh_CN]=锁屏
icon=system-lock-screen-symbolic
show=true
showInSession=true
showInMenu=false
showInPanel=true
Group=User Action
[SwitchUser]
name=SwitchUser
name[zh_CN]=切换用户
icon=stock-people-symbolic
show=true
showInSession=true
showInMenu=false
showInPanel=true
Group=User Action
[Logout]
name=Logout
name[zh_CN]=注销
icon=system-logout-symbolic
show=true
showInSession=true
showInMenu=true
showInPanel=true
Group=User Action
[HibernateMode]
name=Hibernate Mode
name[zh_CN]=休眠
icon=kylin-sleep-symbolic
show=true
showInSession=true
showInMenu=false
showInPanel=true
Group=User Action
Group=Sleep or Hibernate
[Sleep Mode]
name=Sleep Mode
name[zh_CN]=睡眠
icon=system-sleep
show=true
showInSession=true
showInMenu=true
showInPanel=true
Group=Sleep or Hibernate
[Restart]
name=Restart
name[zh_CN]=重启
icon=system-restart-symbolic
show=true
showInSession=true
showInMenu=true
showInPanel=true
Group=Sleep or Hibernate
[TimeShutdown]
name=TimeShutdown
name[zh_CN]=定时开关机
icon=system-restart-symbolic
show=true
showInSession=false
showInMenu=false
showInPanel=true
Group=Power Supply
[PowerOff]
name=Power Off
name[zh_CN]=关机
icon=system-shutdown-symbolic
show=true
showInSession=true
showInMenu=false
showInPanel=true
Group=Power Supply

View File

@ -2,87 +2,154 @@
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>UKUIPanel</name>
<name>ContextMenu</name>
<message>
<location filename="../ukuipanel.cpp" line="856"/>
<source>Small</source>
<translation></translation>
<location filename="../contextmenu.cpp" line="16"/>
<source>Set Panel</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="858"/>
<source>Medium</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="860"/>
<source>Large</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="865"/>
<source>Adjustment Size</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="906"/>
<source>Up</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="908"/>
<source>Bottom</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="910"/>
<source>Left</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="912"/>
<source>Right</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="915"/>
<source>Adjustment Position</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="941"/>
<source>Hide Panel</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1271"/>
<location filename="../contextmenu.cpp" line="23"/>
<source>Show Taskview</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1288"/>
<source>Show Nightmode</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1294"/>
<location filename="../contextmenu.cpp" line="30"/>
<source>Show Desktop</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1301"/>
<location filename="../contextmenu.cpp" line="37"/>
<source>Show System Monitor</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1326"/>
<location filename="../contextmenu.cpp" line="46"/>
<source>Lock This Panel</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1341"/>
<location filename="../contextmenu.cpp" line="55"/>
<source>About Kylin</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="79"/>
<source>Small</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="81"/>
<source>Medium</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="83"/>
<source>Large</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="88"/>
<source>Adjustment Size</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="123"/>
<source>Up</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="125"/>
<source>Bottom</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="127"/>
<source>Left</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="129"/>
<source>Right</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="132"/>
<source>Adjustment Position</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="157"/>
<source>Hide Panel</source>
<translation></translation>
</message>
</context>
<context>
<name>UKUIPanel</name>
<message>
<source>Small</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Medium</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Large</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Adjustment Size</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Up</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Left</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Right</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Adjustment Position</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Hide Panel</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show Taskview</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show Nightmode</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show Desktop</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Show System Monitor</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Lock This Panel</source>
<translation type="vanished"></translation>
</message>
<message>
<source>About Kylin</source>
<translation type="vanished"></translation>
</message>
</context>
<context>
<name>main</name>

View File

@ -2,90 +2,153 @@
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>UKUIPanel</name>
<name>ContextMenu</name>
<message>
<location filename="../ukuipanel.cpp" line="856"/>
<location filename="../contextmenu.cpp" line="16"/>
<source>Set Panel</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="23"/>
<source>Show Taskview</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="30"/>
<source>Show Desktop</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="37"/>
<source>Show System Monitor</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="46"/>
<source>Lock This Panel</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="55"/>
<source>About Kylin</source>
<translation></translation>
</message>
<message>
<location filename="../contextmenu.cpp" line="79"/>
<source>Small</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="858"/>
<location filename="../contextmenu.cpp" line="81"/>
<source>Medium</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="860"/>
<location filename="../contextmenu.cpp" line="83"/>
<source>Large</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="865"/>
<location filename="../contextmenu.cpp" line="88"/>
<source>Adjustment Size</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="906"/>
<location filename="../contextmenu.cpp" line="123"/>
<source>Up</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="908"/>
<location filename="../contextmenu.cpp" line="125"/>
<source>Bottom</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="910"/>
<location filename="../contextmenu.cpp" line="127"/>
<source>Left</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="912"/>
<location filename="../contextmenu.cpp" line="129"/>
<source>Right</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="915"/>
<location filename="../contextmenu.cpp" line="132"/>
<source>Adjustment Position</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="941"/>
<location filename="../contextmenu.cpp" line="157"/>
<source>Hide Panel</source>
<translation></translation>
</message>
</context>
<context>
<name>UKUIPanel</name>
<message>
<source>Small</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Medium</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Large</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Adjustment Size</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Up</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Bottom</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Left</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Right</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Adjustment Position</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Hide Panel</source>
<translation type="vanished"></translation>
</message>
<message>
<source>Set up Panel</source>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1271"/>
<source>Show Taskview</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1288"/>
<source>Show Nightmode</source>
<translation></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1294"/>
<source>Show Desktop</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1301"/>
<source>Show System Monitor</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1326"/>
<source>Lock This Panel</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../ukuipanel.cpp" line="1341"/>
<source>About Kylin</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
</context>
<context>

View File

@ -51,22 +51,18 @@
#include <QtDBus>
#include <KWindowSystem/KWindowSystem>
//#include "windowmanager/windowmanager.h"
#include <KWindowSystem/NETWM>
#include <KF5/KScreen/kscreen/output.h>
#include <KF5/KScreen/kscreen/configmonitor.h>
#include <QGSettings>
// Turn on this to show the time required to load each plugin during startup
// #define DEBUG_PLUGIN_LOADTIME
#include "common_fun/ukuipanel_infomation.h"
#include "common_fun/dbus-adaptor.h"
#include "common_fun/panel_commission.h"
#ifdef DEBUG_PLUGIN_LOADTIME
#include <QElapsedTimer>
#endif
#include "windowmanager/windowmanager.h"
/************************************************
Returns the Position by the string.
@ -111,10 +107,6 @@ QString UKUIPanel::positionToStr(IUKUIPanel::Position position)
return QString();
}
/************************************************
************************************************/
UKUIPanel::UKUIPanel(const QString &configGroup, UKUi::Settings *settings, QWidget *parent) :
QFrame(parent),
m_settings(settings),
@ -129,13 +121,11 @@ UKUIPanel::UKUIPanel(const QString &configGroup, UKUi::Settings *settings, QWidg
m_position(IUKUIPanel::PositionBottom),
m_screenNum(0), //whatever (avoid conditional on uninitialized value)
m_actualScreenNum(0),
m_hidable(false),
m_visibleMargin(true),
m_hidden(false),
m_animationTime(0),
m_reserveSpace(true),
m_animation(nullptr),
m_lockPanel(false)
m_animation(nullptr)
{
qDebug()<<"Panel :: Constructor start";
//You can find information about the flags and widget attributes in your
@ -180,11 +170,33 @@ UKUIPanel::UKUIPanel(const QString &configGroup, UKUi::Settings *settings, QWidg
PanelCommission::panelConfigFileValueInit(true);
PanelCommission::panelConfigFileReset(true);
qDebug()<<"Panel :: PanelCommission config finished";
//初始化DBus接口
UKuiPanelInformation* dbus = new UKuiPanelInformation;
new PanelAdaptor(dbus);
QDBusConnection con = QDBusConnection::sessionBus();
if(!con.registerService("org.ukui.panel") ||
!con.registerObject("/panel/position",dbus)) {
qDebug() << "fail" << con.lastError().message();
}
//初始化判断是否为wayland环境如果是wayland,则任务栏隐藏无动画,且鼠标再次移开任务栏的隐藏操作需要特殊处理
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) {
m_isWaylandEnv =true;
} else {
m_isWaylandEnv = false;
}
m_layout = new UKUIPanelLayout(this);
m_layout->setContentsMargins(0, 0, 0, 0);
//UKUIPanel (inherits QFrame) -> lav (QGridLayout) -> UKUIPanelWidget (QFrame) -> UKUIPanelLayout
UKUIPanelWidget = new QFrame(this);
UKUIPanelWidget->setObjectName("BackgroundWidget");
QGridLayout* lav = new QGridLayout();
lav->setContentsMargins(0, 0, 0, 0);
setLayout(lav);
this->layout()->addWidget(UKUIPanelWidget);
m_layout = new UKUIPanelLayout(UKUIPanelWidget);
connect(m_layout, &UKUIPanelLayout::pluginMoved, this, &UKUIPanel::pluginMoved);
this->setLayout(m_layout);
UKUIPanelWidget->setLayout(m_layout);
m_layout->setLineCount(m_lineCount);
mDelaySave.setSingleShot(true);
@ -206,12 +218,18 @@ UKUIPanel::UKUIPanel(const QString &configGroup, UKUi::Settings *settings, QWidg
*/
connect(QApplication::desktop(), &QDesktopWidget::resized, this, &UKUIPanel::ensureVisible);
connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &UKUIPanel::ensureVisible);
// connect(qApp,&QApplication::primaryScreenChanged,this,&UKUIPanel::ensureVisible);
// connecting to QDesktopWidget::workAreaResized shouldn't be necessary,
// as we've already connceted to QDesktopWidget::resized, but it actually
connect(QApplication::desktop(), &QDesktopWidget::workAreaResized,
this, &UKUIPanel::ensureVisible);
//适配KScreen后分辨率改变的信号无法获取需要从SettingsDaemon拿分辨率改变的信号
QDBusConnection::sessionBus().connect(QString(USD_SERVICE),
QString(USD_XRANDER_PATH),
QString(USD_XRANDER_INTERFACE),
QString(PRIMARY_CHANGED),
this, SLOT(primaryChangedSlot(int, int, int, int, int)));
UKUIPanelApplication *a = reinterpret_cast<UKUIPanelApplication*>(qApp);
m_primaryScreenGeometry = QGuiApplication::screens().at(0)->geometry();
KScreen::GetConfigOperation *op = new KScreen::GetConfigOperation();
@ -219,31 +237,57 @@ UKUIPanel::UKUIPanel(const QString &configGroup, UKUi::Settings *settings, QWidg
configWatch(op);
});
connect(UKUi::Settings::globalSettings(), SIGNAL(settingsChanged()), this, SLOT(update()));
connect(m_standaloneWindows.data(), &WindowNotifier::firstShown, [this] { showPanel(true); });
connect(m_standaloneWindows.data(), &WindowNotifier::lastHidden, this, &UKUIPanel::hidePanel);
const QByteArray id(PANEL_SETTINGS);
m_gsettings = new QGSettings(id);
setPosition(0,intToPosition(m_gsettings->get(PANEL_POSITION_KEY).toInt(),PositionBottom),true);
connect(m_gsettings, &QGSettings::changed, this, [=] (const QString &key){
if(key==ICON_SIZE_KEY) {
setIconSize(m_gsettings->get(ICON_SIZE_KEY).toInt(),true);
}
if(key==PANEL_SIZE_KEY) {
setPanelSize(m_gsettings->get(PANEL_SIZE_KEY).toInt(),true);
}
if(key == PANEL_POSITION_KEY) {
if (QGSettings::isSchemaInstalled(PANEL_SETTINGS)) {
m_gsettings = new QGSettings(id);
m_gsettingsKeys = m_gsettings->keys();
if (m_gsettingsKeys.contains(PANEL_POSITION_KEY)) {
setPosition(0,intToPosition(m_gsettings->get(PANEL_POSITION_KEY).toInt(),PositionBottom),true);
}
});
setPanelSize(m_gsettings->get(PANEL_SIZE_KEY).toInt(),true);
setIconSize(m_gsettings->get(ICON_SIZE_KEY).toInt(),true);
setPosition(0,intToPosition(m_gsettings->get(PANEL_POSITION_KEY).toInt(),PositionBottom),true);
if (m_gsettingsKeys.contains(HIDE_PANEL_KEY)) {
m_hidable = m_gsettings->get(HIDE_PANEL_KEY).toBool();
}
if (m_gsettingsKeys.contains(LOCK_PANEL_KEY)) {
m_lockPanel = m_gsettings->get(LOCK_PANEL_KEY).toBool();
}
connect(m_gsettings, &QGSettings::changed, this, [=] (const QString &key){
if (key == ICON_SIZE_KEY) {
setIconSize(m_gsettings->get(ICON_SIZE_KEY).toInt(), true);
}
if (key == PANEL_SIZE_KEY) {
setPanelSize(m_gsettings->get(PANEL_SIZE_KEY).toInt(), true);
}
if (key == PANEL_POSITION_KEY) {
setPosition(0, intToPosition(m_gsettings->get(PANEL_POSITION_KEY).toInt(), PositionBottom), true);
}
if (key == HIDE_PANEL_KEY) {
m_hidable = !m_gsettings->get(HIDE_PANEL_KEY).toBool();
if (m_hidable)
m_hideTimer.stop();
setHidable(!m_hidable, true);
m_hidden = m_hidable;
m_showDelayTimer.start();
m_time->start(1000);
}
if (key == LOCK_PANEL_KEY) {
m_lockPanel = m_gsettings->get(LOCK_PANEL_KEY).toBool();
}
});
}
if (m_gsettingsKeys.contains(PANEL_SIZE_KEY)) {
setPanelSize(m_gsettings->get(PANEL_SIZE_KEY).toInt(),true);
}
if (m_gsettingsKeys.contains(ICON_SIZE_KEY)) {
setIconSize(m_gsettings->get(ICON_SIZE_KEY).toInt(),true);
}
if (m_gsettingsKeys.contains(PANEL_POSITION_KEY)) {
setPosition(0,intToPosition(m_gsettings->get(PANEL_POSITION_KEY).toInt(),PositionBottom),true);
}
m_time = new QTimer(this);
connect(m_time, &QTimer::timeout, this,[=] (){
@ -268,12 +312,14 @@ UKUIPanel::UKUIPanel(const QString &configGroup, UKUi::Settings *settings, QWidg
if (m_interface->isValid()) {
QDBusReply<bool> status = m_interface->call("get_current_tabletmode");
setPanelHide(status);
QDBusConnection::sessionBus().connect("com.kylin.statusmanager.interface","/",
"com.kylin.statusmanager.interface","mode_change_signal",
this,SLOT(setPanelHide(bool)));
} else {
qWarning()<<"Cann't connect kylin-status-manager";
setPanelHide(false);
}
QDBusConnection::sessionBus().connect("com.kylin.statusmanager.interface","/",
"com.kylin.statusmanager.interface","mode_change_signal",
this,SLOT(setPanelHide(bool)));
qDebug()<<"Panel :: show UKuiPanel finished";
//给session发信号告知任务栏已经启动完成可以启动下一个组件
QDBusInterface interface(UKUI_SERVICE,
@ -284,19 +330,12 @@ UKUIPanel::UKUIPanel(const QString &configGroup, UKUi::Settings *settings, QWidg
// show it the first time, despite setting
if (m_hidable) {
showPanel(false);
QTimer::singleShot(PANEL_HIDE_FIRST_TIME, this, SLOT(hidePanel()));
hidePanel();
}
styleAdjust();
qDebug()<<"Panel :: UKuiPanel finished";
UKuiPanelInformation* dbus=new UKuiPanelInformation;
new PanelAdaptor(dbus);
QDBusConnection con=QDBusConnection::sessionBus();
if(!con.registerService("org.ukui.panel") ||
!con.registerObject("/panel/position",dbus)) {
qDebug()<<"fail";
}
}
void UKUIPanel::configWatch(KScreen::ConfigOperation *op)
@ -305,17 +344,17 @@ void UKUIPanel::configWatch(KScreen::ConfigOperation *op)
KScreen::ConfigMonitor::instance()->addConfig(m_config);
/*connect(m_config.data(), &KScreen::Config::primaryOutputChanged,
* this, [=](const KScreen::OutputPtr &output){
* if (!output.isNull()) {
* qDebug() << "primaryOutputChanged:" << output->name() << output->geometry();
* m_primaryScreenGeometry = output->geometry();
* QRect rect = caculPanelGeometry(output->geometry());
* qDebug()<<"primaryOutputChanged panel rect is"<<rect;
* //kdk::WindowManager::setGeometry(this->windowHandle(), rect);
* realign();
* }
});*/
connect(m_config.data(), &KScreen::Config::primaryOutputChanged,
this, [=](const KScreen::OutputPtr &output){
if (!output.isNull()) {
qDebug() << "primaryOutputChanged:" << output->name() << output->geometry();
m_primaryScreenGeometry = output->geometry();
QRect rect = caculPanelGeometry(output->geometry());
qDebug()<<"primaryOutputChanged panel rect is"<<rect;
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
realign();
}
});
connect(m_config.data(), &KScreen::Config::outputAdded,
this, [=](const KScreen::OutputPtr &output){
if (!output.isNull()) {
@ -324,7 +363,7 @@ void UKUIPanel::configWatch(KScreen::ConfigOperation *op)
qDebug()<<"output added primary geometry is"<<primary->geometry();
QRect rect = caculPanelGeometry(primary->geometry());
qDebug()<<"output added panel rect is"<<rect;
//kdk::WindowManager::setGeometry(this->windowHandle(), rect);
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
}
});
connect(m_config.data(), &KScreen::Config::outputRemoved,
@ -338,11 +377,10 @@ void UKUIPanel::setPanelHide(bool model)
if (model) {
hide();
} else {
//切换平板模式任务栏hide后再切回来任务栏的surface发生了改变。wayland下需要重新设置dock属性
setAttribute(Qt::WA_X11NetWmWindowTypeDock);
show();
KWindowSystem::setType(effectiveWinId(), NET::Dock);
QRect rect = caculPanelGeometry(m_primaryScreenGeometry);
//kdk::WindowManager::setGeometry(this->windowHandle(), rect);
realign();
}
}
@ -354,7 +392,6 @@ void UKUIPanel::readSettings()
// Let Hidability be the first thing we read
// so that every call to realign() is without side-effect
m_hidable = m_settings->value(CFG_KEY_HIDABLE, m_hidable).toBool();
m_hidden = m_hidable;
m_visibleMargin = m_settings->value(CFG_KEY_VISIBLE_MARGIN, m_visibleMargin).toBool();
m_animationTime = m_settings->value(CFG_KEY_ANIMATION, m_animationTime).toInt();
@ -372,16 +409,11 @@ void UKUIPanel::readSettings()
// false);
setAlignment(Alignment(m_settings->value(CFG_KEY_ALIGNMENT, m_alignment).toInt()), false);
m_reserveSpace = m_settings->value(CFG_KEY_RESERVESPACE, true).toBool();
m_lockPanel = m_settings->value(CFG_KEY_LOCKPANEL, false).toBool();
m_settings->endGroup();
}
/************************************************
************************************************/
void UKUIPanel::saveSettings(bool later)
{
mDelaySave.stop();
@ -401,19 +433,15 @@ void UKUIPanel::saveSettings(bool later)
m_settings->setValue(CFG_KEY_PERCENT, m_lengthInPercents);
m_settings->setValue(CFG_KEY_SCREENNUM, m_screenNum);
// mSettings->setValue(CFG_KEY_POSITION, positionToStr(mPosition));
m_settings->setValue(CFG_KEY_ALIGNMENT, m_alignment);
m_settings->setValue(CFG_KEY_RESERVESPACE, m_reserveSpace);
m_settings->setValue(CFG_KEY_HIDABLE, m_hidable);
m_settings->setValue(CFG_KEY_VISIBLE_MARGIN, m_visibleMargin);
m_settings->setValue(CFG_KEY_ANIMATION, m_animationTime);
m_settings->setValue(CFG_KEY_SHOW_DELAY, m_showDelayTimer.interval());
m_settings->setValue(CFG_KEY_LOCKPANEL, m_lockPanel);
m_settings->endGroup();
}
@ -421,15 +449,30 @@ void UKUIPanel::saveSettings(bool later)
/*确保任务栏在调整分辨率和增加·屏幕之后能保持显示正常*/
void UKUIPanel::ensureVisible()
{
if (!canPlacedOn(m_screenNum, m_position))
setPosition(findAvailableScreen(m_position), m_position, false);
else
m_actualScreenNum = m_screenNum;
m_actualScreenNum = m_screenNum;
// the screen size might be changed
realign();
}
void UKUIPanel::primaryChangedSlot(int x, int y, int w, int h, int r)
{
qDebug() << " primaryChanged from USD " << x << y << w << h << r;
if (QGuiApplication::screens().size() < 1) {
qWarning() << "No Valid Screen !!!";
return;
}
if (QGuiApplication::screens().at(0)->geometry().width() != w
|| QGuiApplication::screens().at(0)->geometry().height() != h)
{
qWarning() << "The Screen size obtained from USD and QGuiApplication dose not match,Follow QGuiApplication !!";
qWarning() << "---------From USD " << x << y << w << h << r;
qWarning() << "---------From QGuiApplication " << QGuiApplication::screens().at(0)->geometry();
}
m_primaryScreenGeometry = QGuiApplication::screens().at(0)->geometry();
realign();
}
UKUIPanel::~UKUIPanel()
{
@ -544,68 +587,64 @@ void UKUIPanel::priScreenChanged(int x, int y, int width, int height)
QRect UKUIPanel::caculPanelGeometry(QRect primaryscreen)
{
QRect currentScreen;
QRect rect;
// currentScreen=QGuiApplication::screens().at(0)->geometry();
currentScreen = primaryscreen;
if (isHorizontal()) {
rect.setHeight(qMax(PANEL_MINIMUM_SIZE, m_panelSize));
rect.setWidth(currentScreen.width());
rect.setWidth(primaryscreen.width());
rect.setWidth(qMax(rect.size().width(), m_layout->minimumSize().width()));
// Horiz panel***************************
if (m_position == IUKUIPanel::PositionTop) {
if (m_hidden) {
rect.moveBottom(currentScreen.top() + PANEL_HIDE_SIZE);
rect.setX(currentScreen.x());
rect.setY(currentScreen.y() - rect.height() + PANEL_HIDE_SIZE);
rect.moveBottom(primaryscreen.top() + PANEL_HIDE_SIZE);
rect.setX(primaryscreen.x());
rect.setY(primaryscreen.y() - rect.height() + PANEL_HIDE_SIZE);
}else {
rect.moveTop(currentScreen.top());
rect.setX(currentScreen.x());
rect.setY(currentScreen.y());
rect.setWidth(currentScreen.width());
rect.moveTop(primaryscreen.top());
rect.setX(primaryscreen.x());
rect.setY(primaryscreen.y());
rect.setWidth(primaryscreen.width());
}
} else {
if (m_hidden) {
rect.moveTop(currentScreen.bottom() - PANEL_HIDE_SIZE);
rect.setX(currentScreen.x());
rect.setY(currentScreen.y() + currentScreen.height() - PANEL_HIDE_SIZE);
rect.moveTop(primaryscreen.bottom() - PANEL_HIDE_SIZE);
rect.setX(primaryscreen.x());
rect.setY(primaryscreen.y() + primaryscreen.height() - PANEL_HIDE_SIZE);
}else {
rect.moveBottom(currentScreen.bottom());
rect.setX(currentScreen.x());
rect.setY(currentScreen.y() + currentScreen.height() - m_panelSize);
rect.setWidth(currentScreen.width());
rect.moveBottom(primaryscreen.bottom());
rect.setX(primaryscreen.x());
rect.setY(primaryscreen.y() + primaryscreen.height() - m_panelSize);
rect.setWidth(primaryscreen.width());
}
}
} else {
// Vert panel ***************************
rect.setWidth(qMax(PANEL_MINIMUM_SIZE, m_panelSize));
rect.setHeight(currentScreen.height());
rect.setHeight(primaryscreen.height());
rect.setHeight(qMax(rect.size().height(), m_layout->minimumSize().height()));
if (m_position == IUKUIPanel::PositionLeft) {
if (m_hidden) {
rect.moveRight(currentScreen.left() + PANEL_HIDE_SIZE);
rect.setX(currentScreen.x() - rect.width() + PANEL_HIDE_SIZE);
rect.setY(currentScreen.y());
rect.moveRight(primaryscreen.left() + PANEL_HIDE_SIZE);
rect.setX(primaryscreen.x() - rect.width() + PANEL_HIDE_SIZE);
rect.setY(primaryscreen.y());
}else {
rect.moveLeft(currentScreen.left());
rect.setX(currentScreen.x());
rect.setY(currentScreen.y());
rect.setHeight(currentScreen.height());
rect.moveLeft(primaryscreen.left());
rect.setX(primaryscreen.x());
rect.setY(primaryscreen.y());
rect.setHeight(primaryscreen.height());
}
} else {
if (m_hidden) {
rect.moveLeft(currentScreen.right() - PANEL_HIDE_SIZE);
rect.setX(currentScreen.x() + currentScreen.width() + m_panelSize - PANEL_HIDE_SIZE);
rect.setY(currentScreen.y());
rect.moveLeft(primaryscreen.right() - PANEL_HIDE_SIZE);
rect.setX(primaryscreen.x() + primaryscreen.width() - PANEL_HIDE_SIZE);
rect.setY(primaryscreen.y());
}else {
rect.moveRight(currentScreen.right());
rect.setX(currentScreen.x() + currentScreen.width() - m_panelSize);
rect.setY(currentScreen.y());
rect.setHeight(currentScreen.height());
rect.moveRight(primaryscreen.right());
rect.setX(primaryscreen.x() + primaryscreen.width() - m_panelSize);
rect.setY(primaryscreen.y());
rect.setHeight(primaryscreen.height());
}
}
}
@ -621,16 +660,17 @@ QRect UKUIPanel::caculPanelGeometry(QRect primaryscreen)
*/
void UKUIPanel::setPanelGeometry(bool animate)
{
QRect currentScreen;
QRect rect;
rect = caculPanelGeometry(m_primaryScreenGeometry);
QRect rect = caculPanelGeometry(m_primaryScreenGeometry);
if (rect != geometry()) {
setFixedSize(rect.size());
setMargins();
//kdk::WindowManager::setGeometry(this->windowHandle(), rect);
if (animate && !m_isWaylandEnv) {
setPanelAnimation(geometry(), rect);
} else {
setMargins();
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
}
}
QDBusMessage message =QDBusMessage::createSignal("/panel/position", "org.ukui.panel", "UKuiPanelPosition");
QList<QVariant> args;
args.append(m_primaryScreenGeometry.x());
@ -697,12 +737,6 @@ void UKUIPanel::realign()
emit realigned();
if (!isVisible())
return;
qDebug() << "** Realign *********************";
qDebug() << "PanelSize: " << m_panelSize;
qDebug() << "IconSize: " << m_iconSize;
qDebug() << "LineCount: " << m_lineCount;
qDebug() << "Position: " << m_position;
qDebug() << "geometry: " << this->geometry();
setPanelGeometry();
@ -728,6 +762,7 @@ void UKUIPanel::updateWmStrut()
// So, we use the geometry of the whole screen to calculate the strut rather than using the geometry of individual monitors.
// Though the spec only mention Xinerama and did not mention XRandR, the rule should still be applied.
// At least openbox is implemented like this.
switch (m_position)
{
case UKUIPanel::PositionTop:
@ -779,214 +814,6 @@ void UKUIPanel::updateWmStrut()
}
/************************************************
The panel can't be placed on boundary of two displays.
This function checks if the panel can be placed on the display
@screenNum on @position.
************************************************/
bool UKUIPanel::canPlacedOn(int screenNum, UKUIPanel::Position position)
{
QDesktopWidget* dw = QApplication::desktop();
switch (position)
{
case UKUIPanel::PositionTop:
for (int i = 0; i < dw->screenCount(); ++i)
if (dw->screenGeometry(i).bottom() < dw->screenGeometry(screenNum).top())
return false;
return true;
case UKUIPanel::PositionBottom:
for (int i = 0; i < dw->screenCount(); ++i)
if (dw->screenGeometry(i).top() > dw->screenGeometry(screenNum).bottom())
return false;
return true;
case UKUIPanel::PositionLeft:
for (int i = 0; i < dw->screenCount(); ++i)
if (dw->screenGeometry(i).right() < dw->screenGeometry(screenNum).left())
return false;
return true;
case UKUIPanel::PositionRight:
for (int i = 0; i < dw->screenCount(); ++i)
if (dw->screenGeometry(i).left() > dw->screenGeometry(screenNum).right())
return false;
return true;
}
return false;
}
/************************************************
************************************************/
int UKUIPanel::findAvailableScreen(UKUIPanel::Position position)
{
int current = m_screenNum;
for (int i = current; i < QApplication::desktop()->screenCount(); ++i)
if (canPlacedOn(i, position))
return i;
for (int i = 0; i < current; ++i)
if (canPlacedOn(i, position))
return i;
return 0;
}
/*右键 系统监视器选项*/
void UKUIPanel::systeMonitor()
{
QProcess *process =new QProcess(this);
process->startDetached("/usr/bin/ukui-system-monitor");
process->deleteLater();
}
/*任务栏大小和方向的调整*/
void UKUIPanel::adjustPanel()
{
QAction *pmenuaction_s;
QAction *pmenuaction_m;
QAction *pmenuaction_l;
pmenuaction_s=new QAction(this);
pmenuaction_s->setText(tr("Small"));
pmenuaction_m=new QAction(this);
pmenuaction_m->setText(tr("Medium"));
pmenuaction_l=new QAction(this);
pmenuaction_l->setText(tr("Large"));
QMenu *pmenu_panelsize;
pmenu_panelsize=new QMenu(this);
pmenu_panelsize->setTitle(tr("Adjustment Size"));
pmenu_panelsize->addAction(pmenuaction_s);
pmenu_panelsize->addAction(pmenuaction_m);
pmenu_panelsize->addAction(pmenuaction_l);
pmenu_panelsize->setWindowOpacity(0.9);
m_menu->addMenu(pmenu_panelsize);
pmenuaction_s->setCheckable(true);
pmenuaction_m->setCheckable(true);
pmenuaction_l->setCheckable(true);
pmenuaction_s->setChecked(m_gsettings->get(PANEL_SIZE_KEY).toInt()==PANEL_SIZE_SMALL);
pmenuaction_m->setChecked(m_gsettings->get(PANEL_SIZE_KEY).toInt()==PANEL_SIZE_MEDIUM);
pmenuaction_l->setChecked(m_gsettings->get(PANEL_SIZE_KEY).toInt()==PANEL_SIZE_LARGE);
connect(pmenuaction_s,&QAction::triggered,[this] {
m_gsettings->set(PANEL_SIZE_KEY,PANEL_SIZE_SMALL);
m_gsettings->set(ICON_SIZE_KEY,ICON_SIZE_SMALL);
setIconSize(ICON_SIZE_SMALL,true);
setPanelSize(PANEL_SIZE_SMALL, true);
});
connect(pmenuaction_m,&QAction::triggered,[this] {
m_gsettings->set(PANEL_SIZE_KEY,PANEL_SIZE_MEDIUM);
m_gsettings->set(ICON_SIZE_KEY,ICON_SIZE_MEDIUM);
setIconSize(ICON_SIZE_MEDIUM,true);
setPanelSize(PANEL_SIZE_MEDIUM, true);
});
connect(pmenuaction_l,&QAction::triggered,[this] {
m_gsettings->set(PANEL_SIZE_KEY,PANEL_SIZE_LARGE);
m_gsettings->set(ICON_SIZE_KEY,ICON_SIZE_LARGE);
setIconSize(ICON_SIZE_LARGE,true);
setPanelSize(PANEL_SIZE_LARGE, true);
});
pmenu_panelsize->setDisabled(m_lockPanel);
QAction *pmenuaction_top;
QAction *pmenuaction_bottom;
QAction *pmenuaction_left;
QAction *pmenuaction_right;
pmenuaction_top=new QAction(this);
pmenuaction_top->setText(tr("Up"));
pmenuaction_bottom=new QAction(this);
pmenuaction_bottom->setText(tr("Bottom"));
pmenuaction_left=new QAction(this);
pmenuaction_left->setText(tr("Left"));
pmenuaction_right=new QAction(this);
pmenuaction_right->setText(tr("Right"));
QMenu *pmenu_positon;
pmenu_positon=new QMenu(this);
pmenu_positon->setTitle(tr("Adjustment Position"));
pmenu_positon->addAction(pmenuaction_top);
pmenu_positon->addAction(pmenuaction_bottom);
pmenu_positon->addAction(pmenuaction_left);
pmenu_positon->addAction(pmenuaction_right);
m_menu->addMenu(pmenu_positon);
pmenuaction_top->setCheckable(true);
pmenuaction_bottom->setCheckable(true);
pmenuaction_left->setCheckable(true);
pmenuaction_right->setCheckable(true);
pmenuaction_top->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==1);
pmenuaction_bottom->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==0);
pmenuaction_left->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==2);
pmenuaction_right->setChecked(m_gsettings->get(PANEL_POSITION_KEY).toInt()==3);
connect(pmenuaction_top,&QAction::triggered, [this] { setPosition(0,PositionTop,true);});
connect(pmenuaction_bottom,&QAction::triggered, [this] { setPosition(0,PositionBottom,true);});
connect(pmenuaction_left,&QAction::triggered, [this] { setPosition(0,PositionLeft,true);});
connect(pmenuaction_right,&QAction::triggered, [this] { setPosition(0,PositionRight,true);});
pmenu_positon->setWindowOpacity(0.9);
pmenu_positon->setDisabled(m_lockPanel);
m_settings->beginGroup(m_configGroup);
QAction * hidepanel = m_menu->addAction(tr("Hide Panel"));
hidepanel->setDisabled(m_lockPanel);
hidepanel->setCheckable(true);
hidepanel->setChecked(m_hidable);
connect(hidepanel, &QAction::triggered, [this] {
m_settings->beginGroup(m_configGroup);
m_hidable = m_settings->value(CFG_KEY_HIDABLE, m_hidable).toBool();
m_settings->endGroup();
if(m_hidable)
m_hideTimer.stop();
setHidable(!m_hidable,true);
m_hidden = m_hidable;
m_showDelayTimer.start();
m_time->start(1000);
});
m_settings->endGroup();
}
/*右键 显示桌面选项*/
void UKUIPanel::showDesktop()
{
KWindowSystem::setShowingDesktop(!KWindowSystem::showingDesktop());
}
/*右键 显示任务视图 选项*/
void UKUIPanel::showTaskView()
{
// system("ukui-window-switch --show-workspace");
if(m_gsettings->keys().contains(SHOW_TASKVIEW)) {
if(m_gsettings->get(SHOW_TASKVIEW).toBool()) {
m_gsettings->set(SHOW_TASKVIEW,false);
} else {
m_gsettings->set(SHOW_TASKVIEW,true);
}
}
}
/*右键 显示夜间模式按钮 选项*/
void UKUIPanel::showNightModeButton()
{
// system("ukui-window-switch --show-workspace");
if(m_gsettings->keys().contains(SHOW_NIGHTMODE)) {
if(m_gsettings->get(SHOW_NIGHTMODE).toBool()) {
m_gsettings->set(SHOW_NIGHTMODE,false);
} else {
m_gsettings->set(SHOW_NIGHTMODE,true);
}
}
}
/*设置任务栏高度*/
void UKUIPanel::setPanelSize(int value, bool save)
{
@ -1028,10 +855,6 @@ void UKUIPanel::setLineCount(int value, bool save)
}
}
/************************************************
************************************************/
void UKUIPanel::setLength(int length, bool inPercents, bool save)
{
if (m_length == length &&
@ -1047,10 +870,6 @@ void UKUIPanel::setLength(int length, bool inPercents, bool save)
realign();
}
/************************************************
************************************************/
void UKUIPanel::setPosition(int screen, IUKUIPanel::Position position, bool save)
{
if (m_screenNum == screen &&
@ -1090,12 +909,9 @@ void UKUIPanel::setPosition(int screen, IUKUIPanel::Position position, bool save
realign();
m_gsettings->set(PANEL_POSITION_KEY,position);
QRect rect = caculPanelGeometry(m_primaryScreenGeometry);
//kdk::WindowManager::setGeometry(this->windowHandle(), rect);
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
}
/************************************************
*
************************************************/
void UKUIPanel::setAlignment(Alignment value, bool save)
{
if (m_alignment == value)
@ -1174,10 +990,6 @@ bool UKUIPanel::event(QEvent *event)
return QFrame::event(event);
}
/************************************************
************************************************/
void UKUIPanel::showEvent(QShowEvent *event)
{
QFrame::showEvent(event);
@ -1214,19 +1026,15 @@ void UKUIPanel::styleAdjust()
}
}
/* 使用paintEvent 对panel进行绘制的时候有如下问题
* 1.
* 2.
*/
void UKUIPanel::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
p.setPen(Qt::NoPen);
// p.setBrush(QBrush(QColor(19,22,28,transparency)));
QColor color= palette().color(QPalette::Base);
QColor col= palette().color(QPalette::BrightText);
col.setAlphaF(0.15);
p.setPen(col);
QColor color= palette().color(QPalette::Window);
color.setAlpha(m_transparency);
QBrush brush = QBrush(color);
p.setBrush(brush);
@ -1236,134 +1044,11 @@ void UKUIPanel::paintEvent(QPaintEvent *)
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
/*Right-Clicked Menu of ukui-panel
* it's a Popup Menu
*/
void UKUIPanel::showPopupMenu(Plugin *plugin)
void UKUIPanel::showPopupMenu()
{
m_menu = new QMenu(this);
m_menu = new ContextMenu(this);
m_menu->setAttribute(Qt::WA_DeleteOnClose);
/* @new features
* //Plugin Menu 负责显示插件的菜单项ukui.0的设计暂时不需要插件菜单项
*
*
* windows是这样做的
*/
if (plugin) {
QMenu *m = plugin->popupMenu();
if (m) {
//menu->addTitle(plugin->windowTitle());
const auto actions = m->actions();
for (auto const & action : actions) {
action->setParent(m_menu);
action->setDisabled(m_lockPanel);
m_menu->addAction(action);
}
delete m;
}
}
m_menu->addSeparator();
QAction * showtaskview = m_menu->addAction(tr("Show Taskview"));
showtaskview->setCheckable(true);
showtaskview->setChecked(m_gsettings->get(SHOW_TASKVIEW).toBool());
connect(showtaskview, &QAction::triggered, [this] { showTaskView(); });
QString filename = QDir::homePath() + "/.config/ukui/panel-commission.ini";
QSettings m_settings(filename, QSettings::IniFormat);
m_settings.setIniCodec("UTF-8");
m_settings.beginGroup("NightMode");
QString nightmode_action = m_settings.value("nightmode", "").toString();
if (nightmode_action.isEmpty()) {
nightmode_action = "show";
}
m_settings.endGroup();
if(nightmode_action == "show") {
QAction * shownightmode = m_menu->addAction(tr("Show Nightmode"));
shownightmode->setCheckable(true);
shownightmode->setChecked(m_gsettings->get(SHOW_NIGHTMODE).toBool());
connect(shownightmode, &QAction::triggered, [this] { showNightModeButton(); });
}
m_menu->addAction(tr("Show Desktop"),
this, SLOT(showDesktop())
);
m_menu->addSeparator();
if(QFileInfo::exists(QString("/usr/bin/ukui-system-monitor"))) {
m_menu->addAction(tr("Show System Monitor"),
this, SLOT(systeMonitor())
);
}
m_menu->addSeparator();
adjustPanel();
/*
UKUIPanelApplication *a = reinterpret_cast<UKUIPanelApplication*>(qApp);
menu->addAction(XdgIcon::fromTheme(QLatin1String("list-add")),
tr("Add New Panel"),
a, SLOT(addNewPanel())
);
if (a->count() > 1)
{
menu->addAction(XdgIcon::fromTheme(QLatin1String("list-remove")),
tr("Remove Panel", "Menu Item"),
this, SLOT(userRequestForDeletion())
)->setDisabled(mLockPanel);
}
*/
m_lockAction = m_menu->addAction(tr("Lock This Panel"));
m_lockAction->setCheckable(true);
m_lockAction->setChecked(m_lockPanel);
connect(m_lockAction, &QAction::triggered, [this] { m_lockPanel = !m_lockPanel; saveSettings(false); });
//Hidden features, lock the panel
/*
menu->addAction(XdgIcon::fromTheme(QLatin1String("configure")),
tr("Reset Panel"),
this, SLOT(panelReset())
)->setDisabled(mLockPanel);
*/
QAction *about;
about=new QAction(this);
about->setText(tr("About Kylin"));
m_menu->addAction(about);
connect(about,&QAction::triggered, [this] {
QProcess *process =new QProcess(this);
process->start(
"bash",
QStringList() << "-c"
<< "dpkg -l | grep ukui-control-center");
process->waitForFinished();
QString strResult = process->readAllStandardOutput() + process->readAllStandardError();
if (-1 != strResult.indexOf("3.0")) {
QProcess::startDetached(QString("ukui-control-center -a"));
} else {
QProcess::startDetached(QString("ukui-control-center -m About"));
}
});
#ifdef DEBUG
menu->addSeparator();
menu->addAction("Exit (debug only)", qApp, SLOT(quit()));
#endif
/* Note: in multihead & multipanel setup the QMenu::popup/exec places the window
* sometimes wrongly (it seems that this bug is somehow connected to misinterpretation
* of QDesktopWidget::availableGeometry)
*/
m_menu->setGeometry(calculatePopupWindowPos(QCursor::pos(), m_menu->sizeHint()));
willShowWindow(m_menu);
m_menu->show();
@ -1378,9 +1063,6 @@ Plugin* UKUIPanel::findPlugin(const IUKUIPanelPlugin* iPlugin) const
return nullptr;
}
/************************************************
************************************************/
QRect UKUIPanel::calculatePopupWindowPos(QPoint const & absolutePos, QSize const & windowSize) const
{
int x = absolutePos.x(), y = absolutePos.y();
@ -1495,13 +1177,11 @@ void UKUIPanel::hidePanel()
void UKUIPanel::hidePanelWork()
{
if (!geometry().contains(QCursor::pos())) {
if (!m_standaloneWindows->isAnyWindowShown()) {
m_hidden = true;
setPanelGeometry(m_animationTime > 0);
} else {
m_hideTimer.start();
}
if (!m_standaloneWindows->isAnyWindowShown()) {
m_hidden = true;
setPanelGeometry(m_animationTime > 0);
} else {
m_hideTimer.start();
}
QDBusMessage message =QDBusMessage::createSignal("/panel", "org.ukui.panel.settings", "PanelHided");
QDBusConnection::sessionBus().send(message);
@ -1584,10 +1264,12 @@ void UKUIPanel::keyChangedSlot(const QString &key) {
if(key == "ukui-panel") {
m_settings->beginGroup(m_configGroup);
m_settings->sync();
m_lockPanel = m_settings->value(CFG_KEY_LOCKPANEL).toBool();
if (m_gsettingsKeys.contains(LOCK_PANEL_KEY)) {
m_lockPanel = m_gsettings->get(LOCK_PANEL_KEY).toBool();
} else {
m_lockPanel = false;
}
m_settings->endGroup();
// if(m_lockAction!=nullptr)
// m_lockAction->setChecked(mLockPanel);
}
}
@ -1601,14 +1283,17 @@ void UKUIPanel::keyChangedSlot(const QString &key) {
IUKUIPanel::Position UKUIPanel::areaDivid(QPoint globalpos) {
int x = globalpos.rx();
int y = globalpos.ry();
int x_0 = QApplication::screens().at(0)->geometry().x();
int y_0 = QApplication::screens().at(0)->geometry().y();
float W = QApplication::screens().at(0)->size().width();
float H = QApplication::screens().at(0)->size().height();
float slope = H / W;
if ((x < 100 || x > W - 100) && (y > H - 100 || y < 100)) return m_position;
if (y > (int)(x * slope) && y > (int)(H - x * slope)) return PositionBottom;
if (y > (int)(x * slope) && y < (int)(H - x * slope)) return PositionLeft;
if (y < (int)(x * slope) && y < (int)(H - x * slope)) return PositionTop;
if (y < (int)(x * slope) && y > (int)(H - x * slope)) return PositionRight;
if ((x - x_0 < 100 || x -x_0 > W - 100) && (y - y_0 > H - 100 || y - y_0 < 100)) return m_position;
if ((y - y_0) > (int)((x - x_0) * slope) && (y - y_0) > (int)(H - (x - x_0) * slope)) return PositionBottom;
if ((y - y_0) > (int)((x - x_0) * slope) && (y - y_0) < (int)(H - (x - x_0) * slope)) return PositionLeft;
if ((y - y_0) < (int)((x - x_0) * slope) && (y - y_0) < (int)(H - (x - x_0) * slope)) return PositionTop;
if ((y - y_0) < (int)((x - x_0) * slope) && (y - y_0) > (int)(H - (x - x_0) * slope)) return PositionRight;
}
@ -1630,8 +1315,10 @@ void UKUIPanel::mouseMoveEvent(QMouseEvent* event)
if (panel_h <= PANEL_SIZE_LARGE && panel_h >= PANEL_SIZE_SMALL) {
setPanelSize(panel_h, true);
setIconSize(icon_size, true);
m_gsettings->set(PANEL_SIZE_KEY, panel_h);
m_gsettings->set(ICON_SIZE_KEY, icon_size);
if (m_gsettingsKeys.contains(PANEL_SIZE_KEY) && m_gsettingsKeys.contains(ICON_SIZE_KEY)) {
m_gsettings->set(PANEL_SIZE_KEY, panel_h);
m_gsettings->set(ICON_SIZE_KEY, icon_size);
}
}
return;
}
@ -1650,3 +1337,5 @@ void UKUIPanel::mouseReleaseEvent(QMouseEvent* event)
emit realigned();
m_moveLock = -1;
}

View File

@ -40,6 +40,7 @@
#include "common/ukuisettings.h"
#include "iukuipanel.h"
#include "ukuipanelglobals.h"
#include "contextmenu.h"
#include <KF5/KScreen/kscreen/config.h>
#include <KF5/KScreen/kscreen/getconfigoperation.h>
@ -53,7 +54,6 @@ class Settings;
class PluginInfo;
}
class UKUIPanelLayout;
class ConfigPanelDialog;
class PanelPluginsModel;
class WindowNotifier;
@ -86,10 +86,6 @@ class UKUI_PANEL_API UKUIPanel : public QFrame, public IUKUIPanel
Q_CLASSINFO("D-Bus Interface", "org.ukui.panel.settings")
// for configuration dialog
friend class ConfigPanelWidget;
friend class ConfigPluginsWidget;
friend class ConfigPanelDialog;
friend class PanelPluginsModel;
public:
@ -147,7 +143,7 @@ public:
* @param plugin The plugin whose menu options will be included in the
* context menu.
*/
void showPopupMenu(Plugin *plugin = 0);
void showPopupMenu();
// IUKUIPanel overrides ........
IUKUIPanel::Position position() const override { return m_position; }
@ -173,25 +169,6 @@ public:
*/
Plugin *findPlugin(const IUKUIPanelPlugin *iPlugin) const;
/**
* @brief Checks if this UKUIPanel can be placed at a given position
* on the screen with the given screenNum. The condition for doing so
* is that the panel is not located between two screens.
*
* For example, if position is PositionRight, there should be no screen to
* the right of the given screen. That means that there should be no
* screen whose left border has a higher x-coordinate than the x-coordinate
* of the right border of the given screen. This method iterates over all
* screens and checks these conditions.
* @param screenNum screen index as it is used by QDesktopWidget methods
* @param position position where the panel should be placed
* @return true if this panel can be placed at the given position on the
* given screen.
*
* \sa findAvailableScreen(), mScreenNum, mActualScreenNum.
*/
static bool canPlacedOn(int screenNum, UKUIPanel::Position position);
/**
* @brief Returns a string representation of the given position. This
* string is human-readable and can be used in config files.
@ -227,7 +204,6 @@ public:
int screenNum() const { return m_screenNum; }
QColor fontColor() const { return m_fontColor; }
int reserveSpace() const { return m_reserveSpace; }
bool hidable() const { return m_hidable; }
bool visibleMargin() const { return m_visibleMargin; }
int animationTime() const { return m_animationTime; }
int showDelay() const { return m_showDelayTimer.interval(); }
@ -247,7 +223,7 @@ public:
*/
// void updateConfigDialog() const;
public slots:
public Q_SLOTS:
/**
* @brief Shows the QWidget and makes it visible on all desktops. This
* method is NOT related to showPanel(), hidePanel() and hidePanelWork()
@ -325,8 +301,9 @@ public slots:
* where the desired position is possible.
*/
void ensureVisible();
void primaryChangedSlot(int x, int y, int w, int h, int r);
signals:
Q_SIGNALS:
/**
* @brief This signal gets emitted whenever this panel receives a
* QEvent::LayoutRequest, i.e. "Widget layout needs to be redone.".
@ -389,7 +366,7 @@ protected:
void mouseReleaseEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent *event);
public slots:
public Q_SLOTS:
/**
* @brief Shows the ConfigPanelDialog and shows the "Config Panel"
* page, i.e. calls showConfigPanelPage(). If the dialog does not
@ -406,7 +383,7 @@ public slots:
*/
// void showConfigDialog();
private slots:
private Q_SLOTS:
/**
* @brief Shows the ConfigPanelDialog and shows the "Config Plugins"
* page, i.e. calls showConfigPluginsPage(). If the dialog does not
@ -427,11 +404,6 @@ private slots:
* 2. UKUi::Application::themeChanged(), i.e. when the user changes
* the theme.
*/
void systeMonitor();
void showDesktop();
void showTaskView();
void showNightModeButton();
void adjustPanel();
void realign();
/**
* @brief Moves a plugin in PanelPluginsModel, i.e. calls
@ -443,6 +415,7 @@ private slots:
void pluginMoved(Plugin * plug);
private:
KScreen::ConfigPtr m_config;
bool m_isWaylandEnv;
/**
* @brief The UKUIPanelLayout of this panel. All the Plugins will be added
* to the UI via this layout.
@ -475,19 +448,6 @@ private:
* (for preventing hide)
*/
QScopedPointer<WindowNotifier> m_standaloneWindows;
/**
* @brief Returns the screen index of a screen on which this panel could
* be placed at the given position. If possible, the current screen index
* is preserved. So, if the panel can be placed on the current screen, the
* index of that screen will be returned.
* @param position position at which the panel should be placed.
* @return The current screen index if the panel can be placed on the
* current screen or the screen index of a screen that it can be placed on.
*
* \sa canPlacedOn(), mScreenNum, mActualScreenNum.
*/
int findAvailableScreen(UKUIPanel::Position position);
/**
* @brief Update the window manager struts _NET_WM_PARTIAL_STRUT and
* _NET_WM_STRUT for this widget. "The purpose of struts is to reserve
@ -675,9 +635,6 @@ private:
* @brief Pointer to the current ConfigPanelDialog if there is any. Make
* sure to test this pointer for validity because it is lazily loaded.
*/
// QPointer<ConfigPanelDialog> mConfigDialog;
//ConfigPanelDialog *mConfigDialog;
//QPointer<ConfigPanelWidget> mConfigWidget;
/**
* @brief The animation used for showing/hiding an auto-hiding panel.
@ -706,7 +663,7 @@ private:
void connectToServer();
private slots:
private Q_SLOTS:
void keyChangedSlot(const QString &key);
void priScreenChanged(int x, int y, int width, int height);
void setPanelHide(bool model);
@ -714,10 +671,11 @@ private slots:
public:
QGSettings *m_gsettings;
QStringList m_gsettingsKeys;
QGSettings *m_transparencyGsettings;
QTimer *m_time;
QDBusInterface *m_interface;
QDBusInterface *m_interface = nullptr;
};

View File

@ -117,14 +117,6 @@ UKUIPanelApplication::UKUIPanelApplication(int& argc, char** argv)
if(panelReset == "replace"){qDebug()<<"ukui-panel --replace";}
if(panelReset == "calendar-new"){system("/usr/share/ukui/ukui-panel/ukui-panel-config.sh calendar new && killall ukui-panel");}
if(panelReset == "calendar-old"){system("/usr/share/ukui/ukui-panel/ukui-panel-config.sh calendar old && killall ukui-panel");}
// This is a workaround for Qt 5 bug #40681.
const auto allScreens = screens();
for(QScreen* screen : allScreens)
{
connect(screen, &QScreen::destroyed, this, &UKUIPanelApplication::screenDestroyed);
}
connect(this, &QGuiApplication::screenAdded, this, &UKUIPanelApplication::handleScreenAdded);
connect(this, &QCoreApplication::aboutToQuit, this, &UKUIPanelApplication::cleanup);
@ -182,68 +174,6 @@ UKUIPanel* UKUIPanelApplication::addPanel(const QString& name)
return panel;
}
void UKUIPanelApplication::handleScreenAdded(QScreen* newScreen)
{
// qDebug() << "UKUIPanelApplication::handleScreenAdded" << newScreen;
connect(newScreen, &QScreen::destroyed, this, &UKUIPanelApplication::screenDestroyed);
}
void UKUIPanelApplication::screenDestroyed(QObject* screenObj)
{
// NOTE by PCMan: This is a workaround for Qt 5 bug #40681.
// With this very dirty workaround, we can fix ukui/ukui bug #204, #205, and #206.
// Qt 5 has two new regression bugs which breaks ukui-panel in a multihead environment.
// #40681: Regression bug: QWidget::winId() returns old value and QEvent::WinIdChange event is not emitted sometimes. (multihead setup)
// #40791: Regression: QPlatformWindow, QWindow, and QWidget::winId() are out of sync.
// Explanations for the workaround:
// Internally, Qt mantains a list of QScreens and update it when XRandR configuration changes.
// When the user turn off an monitor with xrandr --output <xxx> --off, this will destroy the QScreen
// object which represent the output. If the QScreen being destroyed contains our panel widget,
// Qt will call QWindow::setScreen(0) on the internal windowHandle() of our panel widget to move it
// to the primary screen. However, moving a window to a different screen is more than just changing
// its position. With XRandR, all screens are actually part of the same virtual desktop. However,
// this is not the case in other setups, such as Xinerama and moving a window to another screen is
// not possible unless you destroy the widget and create it again for a new screen.
// Therefore, Qt destroy the widget and re-create it when moving our panel to a new screen.
// Unfortunately, destroying the window also destroy the child windows embedded into it,
// using XEMBED such as the tray icons. (#206)
// Second, when the window is re-created, the winId of the QWidget is changed, but Qt failed to
// generate QEvent::WinIdChange event so we have no way to know that. We have to set
// some X11 window properties using the native winId() to make it a dock, but this stop working
// because we cannot get the correct winId(), so this causes #204 and #205.
//
// The workaround is very simple. Just completely destroy the panel before Qt has a chance to do
// QWindow::setScreen() for it. Later, we reload the panel ourselves. So this can bypassing the Qt bugs.
QScreen* screen = static_cast<QScreen*>(screenObj);
bool reloadNeeded = false;
qApp->setQuitOnLastWindowClosed(false);
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
for(int i=0;i<m_panels.size();i++){
UKUIPanel *panel=m_panels[i];
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,7,0))
for(UKUIPanel* panel : qAsConst(m_panels)){
#endif
QWindow* panelWindow = panel->windowHandle();
if(panelWindow && panelWindow->screen() == screen)
{
// the screen containing the panel is destroyed
// delete and then re-create the panel ourselves
QString name = panel->name();
panel->saveSettings(false);
delete panel; // delete the panel, so Qt does not have a chance to set a new screen to it.
m_panels.removeAll(panel);
reloadNeeded = true;
qDebug() << "Workaround Qt 5 bug #40681: delete panel:" << name;
}
}
if(reloadNeeded)
QTimer::singleShot(1000, this, SLOT(reloadPanelsAsNeeded()));
else
qApp->setQuitOnLastWindowClosed(true);
}
bool UKUIPanelApplication::isPluginSingletonAndRunnig(QString const & pluginId) const
{
for (auto const & panel : m_panels)
@ -259,21 +189,11 @@ void UKUIPanelApplication::sigtermHandler(int signo)
exit(signo);
}
void UKUIPanelApplication::translator(){
m_translator = new QTranslator(this);
QString locale = QLocale::system().name();
if (locale == "zh_CN"){
if (m_translator->load(QM_INSTALL))
qApp->installTranslator(m_translator);
else
qDebug() <<PLUGINNAME<<"Load translations file" << locale << "failed!";
} else if (locale == "bo_CN") {
if (m_translator->load(BO_QM_INSTALL)) {
qApp->installTranslator(m_translator);
} else {
qDebug() <<PLUGINNAME<<"Load translations file" << locale << "failed!";
}
}
void UKUIPanelApplication::translator()
{
QTranslator *translator = new QTranslator(this);
translator->load(QLocale(), "panel", "_", PANEL_TRANSLATION_DIR);
QCoreApplication::installTranslator(translator);
}
bool UKUIPanelApplication::copyFileToPath(QString sourceDir ,QString toDir, QString fileName, bool coverFileIfExist)

View File

@ -120,26 +120,11 @@ private:
* so session manager can restart the panel.
* \param caight signal number (15).
*/
QTranslator *m_translator;
static void sigtermHandler(int signo);
void translator();
bool copyFileToPath(QString sourceDir ,QString toDir, QString copyFileToPath, bool coverFileIfExist);
private slots:
/*!
* \brief Connects the QScreen::destroyed signal of a new screen to
* the screenDestroyed() slot so that we can handle this screens'
* destruction as soon as it happens.
* \param newScreen The QScreen that was created and added.
*/
void handleScreenAdded(QScreen* newScreen);
/*!
* \brief Handles screen destruction. This is a workaround for a Qt bug.
* For further information, see the implementation notes.
* \param screenObj The QScreen that was destroyed.
*/
void screenDestroyed(QObject* screenObj);
/*!
* \brief Deletes all UKUIPanel instances that are stored in mPanels.
*/

View File

@ -1,12 +1,10 @@

set(PLUGIN "calendar")
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
message(STATUS "optional:-std=c++11")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(PLUGIN "calendar")
set(HEADERS
ukuicalendar.h
ukuicalendarplugin.h
ukuicalendarwidget.h
calendarbutton.h
calendarbuttontext.h
ukuiwebviewdialog.h
lunarcalendarwidget/frmlunarcalendarwidget.h
lunarcalendarwidget/lunarcalendarinfo.h
@ -20,7 +18,10 @@ set(HEADERS
)
set(SOURCES
ukuicalendar.cpp
ukuicalendarplugin.cpp
ukuicalendarwidget.cpp
calendarbutton.cpp
calendarbuttontext.cpp
ukuiwebviewdialog.cpp
lunarcalendarwidget/frmlunarcalendarwidget.cpp
lunarcalendarwidget/lunarcalendarinfo.cpp
@ -46,19 +47,48 @@ include_directories(${Gsetting_INCLUDE_DIRS})
pkg_check_modules(CALENDAR_DEPS REQUIRED glib-2.0)
link_libraries(glib-2.0.so)
pkg_check_modules(KDKSYSTIME kysdk-systime)
if (KDKSYSTIME_FOUND)
ADD_DEFINITIONS(-DKDKSYSTIME_FOUND="true")
include_directories(${KDKSYSTIME_PKG_INCLUDE_DIRS})
link_directories(${KDKSYSTIME_PKG_LIBRARY_DIRS})
link_libraries(kydate.so)
endif()
# pkg_check_modules(KYSDKSYSTIME_PKG kysdk-systime)
# include_directories(${KYSDKSYSTIME_PKG_INCLUDE_DIRS})
# link_directories(${KYSDKSYSTIME_PKG_LIBRARY_DIRS})
# link_libraries(kydate.so)
pkg_check_modules(KYSDKQTWIDGETS_PKG kysdk-qtwidgets)
include_directories(${KYSDKQTWIDGETS_PKG_INCLUDE_DIRS})
link_directories(${KYSDKQTWIDGETS_PKG_LIBRARY_DIRS})
link_libraries(kysdk-qtwidgets.so)
pkg_check_modules(KYSDKWAYLANDHELPER_PKG kysdk-waylandhelper)
include_directories(${KYSDKWAYLANDHELPER_PKG_INCLUDE_DIRS})
link_directories(${KYSDKWAYLANDHELPER_PKG_LIBRARY_DIRS})
link_libraries(kysdk-waylandhelper.so)
include_directories(${CALENDAR_DEPS_INCLUDE_DIRS})
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
include(../cmake/UkuiPluginTranslationTs.cmake)
ukui_plugin_translate_ts(${PLUGIN})
install(DIRECTORY html/
DESTINATION ${PACKAGE_DATA_DIR}/plugin-calendar/html)
#
file(GLOB TS_FILES "${PROJECT_SOURCE_DIR}/plugin-calendar/translation/*.ts" )
#.qm
qt5_create_translation(QM_FILES ${PROJECT_SOURCE_DIR} ${TS_FILES})
set(${PLUGIN}_QM_FILES ${QM_FILES})
BUILD_UKUI_PLUGIN(${PLUGIN})
#
set(CALENDAR_TRANSLATION_DIR "${PACKAGE_DATA_DIR}/plugin-calendar/translation")
add_compile_definitions(CALENDAR_TRANSLATION_DIR="${CALENDAR_TRANSLATION_DIR}")
install(FILES ${QM_FILES} DESTINATION ${CALENDAR_TRANSLATION_DIR})

View File

@ -0,0 +1,225 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "calendarbutton.h"
#include <QStylePainter>
#include <QStyleOptionButton>
#include <QApplication>
#include <QToolTip>
#include "kysdk/applications/windowmanager/windowmanager.h"
#include "../panel/common/common.h"
#define SYSTEM_FONT_SET "org.ukui.style"
#define SYSTEM_FONT_SIZE "systemFontSize"
#define SYSTEM_FONT "systemFont"
#define CALENDAR_BUTTON_WIDTH 120
#define KYSDK_TIMERSERVER "com.kylin.kysdk.TimeServer"
#define KYSDK_TIMERPATH "/com/kylin/kysdk/Timer"
#define KYSDK_TIMERINTERFACE "com.kylin.kysdk.TimeInterface"
#define KYSDK_DATESERVER "com.kylin.kysdk.DateServer"
#define KYSDK_DATEPATH "/com/kylin/kysdk/Date"
#define KYSDK_DATEINTERFACE "com.kylin.kysdk.DateInterface"
#define UKUI_CONTROL_CENTER_SERVER "org.freedesktop.Accounts"
#define UKUI_CONTROL_CENTER_PATH "/org/freedesktop/Accounts/User1000"
#define UKUI_CONTROL_CENTER_INTERFACE "org.freedesktop.Accounts.User"
#define PANEL_SIZE_LARGE 92
#define PANEL_SIZE_MEDIUM 70
#define PANEL_SIZE_SMALL 46
#define PANEL_SIZE_KEY "panelsize"
CalendarButton::CalendarButton(IUKUIPanelPlugin *plugin, QWidget *parent):
QPushButton(parent),
m_parent(parent),
m_plugin(plugin)
{
//设置按钮样式和属性
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
this->setFlat(true);
setProperty("useButtonPalette",true);
setSystemStyle();
/*按钮边距固定0px尽可能多显示日期信息。CalendarButton不继承ToolButton的原因就是
ToolButton的边距是固定值*/
this->setStyleSheet("padding: 0px;}");
const QByteArray id(ORG_UKUI_STYLE);
if (QGSettings::isSchemaInstalled(id)) {
m_styleGsettings = new QGSettings(id);
connect(m_styleGsettings, &QGSettings::changed, this, [=] (const QString &key) {
if (key == STYLE_NAME) {
setSystemStyle();
update();
}
});
}
//初始化系统字体相关Gsetting
initFontGsettings();
//使用系统提供的sdk刷新时间显示
QDBusConnection::systemBus().connect(KYSDK_TIMERSERVER,
KYSDK_TIMERPATH,
KYSDK_TIMERINTERFACE,
"TimeSignal",
this,
SLOT(updateBtnText(QString))
);
QDBusConnection::systemBus().connect(KYSDK_TIMERSERVER,
KYSDK_TIMERPATH,
KYSDK_TIMERINTERFACE,
"TimeChangeSignal",
this,
SLOT(updateBtnText(QString))
);
QDBusConnection::sessionBus().connect(KYSDK_DATESERVER,
KYSDK_DATEPATH,
KYSDK_DATEINTERFACE,
"TimeSignal",
this,
SLOT(updateBtnText(QString))
);
QDBusConnection::sessionBus().connect(KYSDK_DATESERVER,
KYSDK_DATEPATH,
KYSDK_DATEINTERFACE,
"DateSignal",
this,
SLOT(updateBtnText(QString))
);
m_listenGsettings = new ListenGsettings();
QObject::connect(m_listenGsettings,&ListenGsettings::iconsizechanged,[this]{updateBtnText(QString());});
QObject::connect(m_listenGsettings,&ListenGsettings::panelpositionchanged,[this]{updateBtnText(QString());});
//更新日历按钮内容
updateBtnText(QString());
}
CalendarButton::~CalendarButton()
{
if(m_styleGsettings) {
m_styleGsettings->deleteLater();
}
if(m_fontGsettings) {
m_fontGsettings->deleteLater();
}
if(m_listenGsettings) {
m_listenGsettings->deleteLater();
}
}
void CalendarButton::contextMenuEvent(QContextMenuEvent *event)
{
m_menuCalender = new QMenu(this);
m_menuCalender->setAttribute(Qt::WA_DeleteOnClose);
m_menuCalender->setGeometry(m_plugin->panel()->calculatePopupWindowPos
(mapToGlobal(event->pos()),
m_menuCalender->sizeHint()));
m_menuCalender->addAction(QIcon::fromTheme("document-page-setup-symbolic"),
tr("Time and Date Setting"),
this, SLOT(setControlTime()));
m_menuCalender->show();
kdk::WindowManager::setGeometry(m_menuCalender->windowHandle(),
m_plugin->panel()->calculatePopupWindowPos(mapToGlobal(event->pos()), m_menuCalender->sizeHint()));
QObject::connect(m_menuCalender, &QMenu::destroyed, this, [&](){
this->setAttribute(Qt::WA_UnderMouse, false);
this->setDown(false);
this->update();
});
}
void CalendarButton::mousePressEvent(QMouseEvent *event)
{
if (Qt::LeftButton == event->button()){
Q_EMIT pressShowHideCalendar();
}
}
//初始化系统字体相关Gsetting
void CalendarButton::initFontGsettings()
{
const QByteArray id(SYSTEM_FONT_SET);
if (QGSettings::isSchemaInstalled(id)) {
m_fontGsettings = new QGSettings(id);
connect(m_fontGsettings, &QGSettings::changed, this, [=] (const QString &keys){
if(keys == SYSTEM_FONT_SIZE || keys == SYSTEM_FONT){
m_systemFontSize = m_fontGsettings->get(SYSTEM_FONT_SIZE).toString();
m_systemFont = m_fontGsettings->get(SYSTEM_FONT).toString();
updateBtnText(QString());
}
});
QStringList ketList = m_fontGsettings->keys();
if(ketList.contains(SYSTEM_FONT_SIZE))
m_systemFontSize = m_fontGsettings->get(SYSTEM_FONT_SIZE).toString();
if(ketList.contains(SYSTEM_FONT))
m_systemFont = m_fontGsettings->get(SYSTEM_FONT).toString();
}
}
//右键跳转到控制面板日期页面
void CalendarButton::setControlTime()
{
QProcess *process =new QProcess(this);
process->start(
"bash",
QStringList() << "-c"
<< "dpkg -l | grep ukui-control-center");
process->waitForFinished();
QString strResult = process->readAllStandardOutput() + process->readAllStandardError();
if (-1 != strResult.indexOf("3.0")) {
QProcess::startDetached(QString("ukui-control-center -t"));
} else {
QProcess::startDetached(QString("ukui-control-center -m Date"));
}
}
void CalendarButton::updateBtnText(QString timerStr)
{
Q_UNUSED(timerStr);
CalendarButtonText btnText(m_plugin,this);
this->setText(btnText.getBtnText());
}
void CalendarButton::setSystemStyle()
{
QPalette pal = this->palette();
QColor col = pal.color(QPalette::Active, QPalette::ButtonText);
col.setAlphaF(0.05);
pal.setColor(QPalette::Button, col);
this->setPalette(pal);
}
bool CalendarButton::event(QEvent *event)
{
if (event->type() == QEvent::ToolTip) {
QString toolTipText = SDK2CPP(kdk_system_get_longformat_date)();
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
QToolTip::showText(helpEvent->globalPos(), toolTipText);
return true;
}
return QWidget::event(event);
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CALENDARBUTTON_H
#define CALENDARBUTTON_H
#include <QToolButton>
#include <QTimer>
#include <QProcess>
#include <QMenu>
#include <QDir>
#include <QFile>
#include <QSettings>
#include <QtDBus/QtDBus>
#include <QMouseEvent>
#include <QContextMenuEvent>
#include <QGSettings>
#include <QPushButton>
#include "../panel/iukuipanelplugin.h"
#include "../panel/common_fun/listengsettings.h"
#include "calendarbuttontext.h"
class CalendarButton : public QPushButton
{
Q_OBJECT
public:
CalendarButton(IUKUIPanelPlugin *plugin,QWidget* parent = 0);
~CalendarButton();
protected:
void contextMenuEvent(QContextMenuEvent *event);
void mousePressEvent(QMouseEvent *event);
bool event(QEvent *event);
private:
void initTimeGsettings();
void initFontGsettings();
Q_SIGNALS:
void pressTimeText();
void pressShowHideCalendar();
private Q_SLOTS:
void setControlTime();
void updateBtnText(QString timerStr);
void setSystemStyle();
private:
IUKUIPanelPlugin * m_plugin;
QWidget *m_parent;
QGSettings *m_styleGsettings;
ListenGsettings *m_listenGsettings;
int m_panelSize;
QGSettings *m_fontGsettings;
QString m_systemFontSize;
QString m_systemFont;
QMenu *m_menuCalender;
const qreal m_btnAlphaF = 0.13; //按钮背景透明度暂时使用UKUI3.1版本的透明度
};
#endif // CALENDARBUTTON_H

View File

@ -0,0 +1,235 @@
/*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "calendarbuttontext.h"
#include "../panel/common/common.h"
#include <QtDBus/QtDBus>
#define UKUI_CONTROL_CENTER_SERVER "org.freedesktop.Accounts"
#define UKUI_CONTROL_CENTER_PATH "/org/freedesktop/Accounts/User1000"
#define UKUI_CONTROL_CENTER_INTERFACE "org.freedesktop.Accounts.User"
#define PROPERTIES_NAME "FormatsLocale"
#define SYSTEM_FONT_SET "org.ukui.style"
#define SYSTEM_FONT_SIZE "systemFontSize"
#define SYSTEM_FONT "systemFont"
#define SYSTEM_MIN_FONT 10
#define PANEL_SETTINGS "org.ukui.panel.settings"
#define PANEL_POSITION_KEY "panelposition"
#define ICON_SIZE_KEY "iconsize"
#define PANEL_SIZE_KEY "panelsize"
#define CALENDAR_BUTTON_WIDTH 120
#define PANEL_SIZE_LARGE 92
#define PANEL_SIZE_MEDIUM 70
#define PANEL_SIZE_SMALL 46
#define PANEL_SIZE_KEY "panelsize"
#define EN_FORMATS "en_US"
#define INSIDE_SPAC 6
CalendarButtonText::CalendarButtonText(IUKUIPanelPlugin *plugin, QPushButton *parent):
m_plugin(plugin),
m_parent(parent)
{
const QByteArray fontId(SYSTEM_FONT_SET);
if (QGSettings::isSchemaInstalled(fontId)) {
m_fontGsettings = new QGSettings(fontId);
}
const QByteArray panelId(PANEL_SETTINGS);
if (QGSettings::isSchemaInstalled(panelId)) {
m_panelGsettings = new QGSettings(panelId);
}
}
CalendarButtonText::~CalendarButtonText()
{
if(m_fontGsettings) {
m_fontGsettings->deleteLater();
}
if(m_panelGsettings) {
m_panelGsettings->deleteLater();
}
}
/*
*
* ()
* 24
* hh:mm ddd
* yyyy/MM/dd
* 12
* AM hh:mm ddd
* yyyy/MM/dd
*
* :
* 24
* hh:mm hh:mm
* ddd ddd
* yyyy/MM/dd MM/dd
* 12
* AM AM
* hh:mm hh:mm
* ddd ddd
* yyyy/MM/dd MM/dd
*/
QString CalendarButtonText::getBtnText()
{
QString timeStr = SDK2CPP(kdk_system_nowtime)();
QString weekStr = SDK2CPP(kdk_system_longweek)();
QString dateStr = SDK2CPP(kdk_system_get_shortformat_date)();
if(QLocale::system().name() == EN_FORMATS) {
weekStr = SDK2CPP(kdk_system_shortweek)();
}
QString btnTextStr;
if(m_plugin->panel()->isHorizontal()) {
btnTextStr = timeStr + " " + weekStr + "\n" + dateStr;
} else {
if (timeStr.contains(" ")) {
QStringList list = timeStr.split(" ");
timeStr = list.takeFirst() + "\n" + list.takeLast();
} else {
auto iter = std::find_if(timeStr.begin(), timeStr.end(), [](auto c){
return c >= "0" && c <= "9";
});
int numAt = timeStr.indexOf(*iter);
if (numAt > 0) {
QString ampmStr;
ampmStr = timeStr.left(numAt);
timeStr = ampmStr + "\n" + timeStr.mid(numAt);
}
}
if(getFormatsLocale().contains(EN_FORMATS)) {
if (dateStr.contains("/")) {
dateStr = dateStr.section("/", 0, 1);
} else if (dateStr.contains("-")) {
dateStr = dateStr.section("-", 0, 1);
} else if (dateStr.contains(".")) {
dateStr = dateStr.section(".", 0, 1);
}
} else {
if (dateStr.contains("/")) {
dateStr = dateStr.section("/", 1);
} else if (dateStr.contains("-")) {
dateStr = dateStr.section("-", 1);
} else if (dateStr.contains(".")) {
dateStr = dateStr.section(".", 1);
}
}
btnTextStr = timeStr + "\n" + weekStr + "\n" + dateStr;
}
updateFontSize(btnTextStr);
return btnTextStr;
}
void CalendarButtonText::updateFontSize(QString btnText)
{
if (m_panelGsettings == nullptr) {
qWarning()<<Q_FUNC_INFO<<__LINE__<<"gsettings init error!";
return;
}
QStringList textList = btnText.split("\n", QString::SkipEmptyParts);
int maxLength;
if(m_plugin->panel()->isHorizontal()) {
if(m_panelGsettings->get(PANEL_SIZE_KEY).toInt() < PANEL_SIZE_MEDIUM) {
if (m_fontGsettings != nullptr) {
QString systemFont = m_fontGsettings->get(SYSTEM_FONT).toString();
m_parent->setFont(QFont(systemFont, SYSTEM_MIN_FONT));
}
return;
}
maxLength = CALENDAR_BUTTON_WIDTH;
setOptimalFont(textList, maxLength);
} else {
int m_panelSize = m_panelGsettings->get(PANEL_SIZE_KEY).toInt();
if(m_panelSize >= PANEL_SIZE_SMALL && m_panelSize < PANEL_SIZE_MEDIUM) {
maxLength = PANEL_SIZE_SMALL;
} else if(m_panelSize >= PANEL_SIZE_MEDIUM && m_panelSize < PANEL_SIZE_LARGE) {
maxLength = PANEL_SIZE_MEDIUM;
} else if(m_panelSize == PANEL_SIZE_LARGE) {
maxLength = PANEL_SIZE_LARGE;
} else {
maxLength = PANEL_SIZE_SMALL;
}
setOptimalFont(textList, maxLength);
}
}
//判断最长字体的是否可以显示下,选取最优字体大小显示
void CalendarButtonText::setOptimalFont(QStringList textList, int btnMaxLength)
{
if (m_fontGsettings == nullptr) {
qWarning()<<Q_FUNC_INFO<<__LINE__<<"gsettings init error!";
return;
}
QString systemFont = m_fontGsettings->get(SYSTEM_FONT).toString();
double fontSizeCurrent = m_fontGsettings->get(SYSTEM_FONT_SIZE).toDouble();
QList<double> systemFonts;
systemFonts<<10<<12<<13.5<<15;
//获取最长的行
QFontMetrics fontMetrics(QFont(systemFont, fontSizeCurrent));
int fontWidth = fontMetrics.width(textList.first());
int maxIndex = 0;
for(int i=1; i<textList.size(); i++) {
int width = fontMetrics.width(textList.at(i));
if(width > fontWidth) {
fontWidth = width;
maxIndex = i;
}
}
//判断最长字体的是否可以显示下,选取最优字体
int maxFontWidth = fontMetrics.width(textList.at(maxIndex));
if(maxFontWidth > btnMaxLength-INSIDE_SPAC) {
int index = systemFonts.indexOf(fontSizeCurrent);
if(index>0) {
for(int i=index-1; i>=0; i--) {
QFontMetrics fontMetrics(QFont(systemFont, systemFonts.at(i)));
int width = fontMetrics.width(textList.at(maxIndex));
if(width <= btnMaxLength-INSIDE_SPAC) {
m_parent->setFont(QFont(systemFont, systemFonts.at(i)));
break;
}
}
} else {
//容错处理,如果系统 org.ukui.style system-font-size 设置错误,也可保证日期正常显示不遮挡
m_parent->setFont(QFont(systemFont, systemFonts.first()));
}
} else {
m_parent->setFont(QFont(systemFont, fontSizeCurrent));
}
}
QString CalendarButtonText::getFormatsLocale()
{
QDBusInterface interface(UKUI_CONTROL_CENTER_SERVER,
UKUI_CONTROL_CENTER_PATH,
UKUI_CONTROL_CENTER_INTERFACE,
QDBusConnection::systemBus());
QVariant ret = interface.property(PROPERTIES_NAME);
return ret.toString();
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CALENDARBUTTONTEXT_H
#define CALENDARBUTTONTEXT_H
#include <QObject>
#include <QDateTime>
#include <QGSettings>
#include <QPushButton>
#include "../panel/iukuipanelplugin.h"
#ifdef KDKSYSTIME_FOUND
#include "kysdk/kysdk-system/libkydate.h"
#endif
class CalendarButtonText : public QObject
{
Q_OBJECT
public:
CalendarButtonText(IUKUIPanelPlugin *plugin,QPushButton *parent);
~CalendarButtonText();
enum DateStyle{YEAR_MON_DAY=0, MON_DAY};
public:
QString getBtnText();
private:
void updateFontSize(QString btnText);
void setOptimalFont(QStringList textList, int btnMaxLength);
QString getFormatsLocale();
public:
QPushButton *m_parent;
IUKUIPanelPlugin * m_plugin;
QGSettings *m_fontGsettings = nullptr;
QGSettings *m_panelGsettings = nullptr;
};
#endif // CALENDARBUTTONTEXT_H

View File

@ -1444,12 +1444,12 @@
"j": "安葬."
},
"d1228": {
"y": "装修.动土.安床.订婚",
"j": ".开业.结婚.入宅.领证."
"y": "装修.动土.安床.订婚.",
"j": "开业.结婚.入宅.领证."
},
"d1229": {
"y": "开业.开工.安床.出行",
"j": ".动土.作灶.掘井."
"y": "开业.开工.安床.出行.",
"j": "动土.作灶.掘井."
},
"d1230": {
"y": "祭祀.塞穴.",

View File

@ -473,10 +473,10 @@
},
"d0429": {
"y": "作灶.祭祀.纳财.",
"j": "开业.开工.开张.破土"
"j": "开业.开工.开张.破土."
},
"d0430": {
"y": ".搬家.开业.结婚.入宅.",
"y": "搬家.开业.结婚.入宅.",
"j": "安葬."
},
"d0501": {

View File

@ -36,7 +36,7 @@
"j": "伐木."
},
"d0110": {
"y": "搬家.装修.结婚.入宅.",
"y": "搬家.装修.结婚.",
"j": "入宅."
},
"d0111": {
@ -113,7 +113,7 @@
},
"d0129": {
"y": "结婚.领证.安床.出行.",
"j": "结婚.领证.安床.出行."
"j": "."
},
"d0130": {
"y": "开业.开工.开张.开市.",
@ -305,7 +305,7 @@
},
"d0317": {
"y": "搬家.开业.开工.动土.",
"j": "搬家.装修.入宅.安门."
"j": "装修.入宅.安门."
},
"d0318": {
"y": "搬家.结婚.入宅.领证.",
@ -493,7 +493,7 @@
},
"d0503": {
"y": "搬家.装修.开业.结婚.",
"j": "祭祀.祭祀.纳畜."
"j": "祭祀.纳畜."
},
"d0504": {
"y": "搬家.装修.开业.结婚.",
@ -692,8 +692,8 @@
"j": "搬家.入宅.出行.旅游."
},
"d0622": {
"y": "开业.结婚.入宅.领证",
"j": ".盖屋.冠笄.掘井."
"y": "开业.结婚.入宅.领证.",
"j": "盖屋.冠笄.掘井."
},
"d0623": {
"y": "开业.开工.动土.安床.",
@ -788,7 +788,7 @@
"j": "."
},
"d0716": {
"y": "搬家.搬家.装修.结婚.",
"y": "搬家.装修.结婚.",
"j": "开业.开工.开张.开市."
},
"d0717": {
@ -917,7 +917,7 @@
},
"d0817": {
"y": "安床.订婚.安葬.理发.",
"j": "开业.结婚.入宅.入宅."
"j": "开业.结婚.入宅."
},
"d0818": {
"y": "祭祀.解除.造畜稠.平治道涂.",
@ -1229,7 +1229,7 @@
},
"d1103": {
"y": "搬家.装修.结婚.入宅.",
"j": "开业.入宅.开工.安门."
"j": "开业.开工.安门."
},
"d1104": {
"y": "破屋.",
@ -1269,7 +1269,7 @@
},
"d1113": {
"y": "入宅.安床.订婚.求嗣.",
"j": "安床.安葬.作灶."
"j": "安葬.作灶."
},
"d1114": {
"y": "作灶.",
@ -1389,7 +1389,7 @@
},
"d1213": {
"y": "入宅.安床.订婚.求嗣.",
"j": "安床.安葬.作灶."
"j": "安葬.作灶."
},
"d1214": {
"y": "作灶.",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +0,0 @@
{
"worktime.y2013":{"d0101":"2","d0102":"2","d0103":"2","d0105":"1","d0106":"1","d0209":"2","d0210":"2","d0211":"2","d0212":"2","d0213":"2","d0214":"2","d0215":"2","d0216":"1","d0217":"1","d0404":"2","d0405":"2","d0406":"2","d0407":"1","d0427":"1","d0428":"1","d0429":"2","d0430":"2","d0501":"2","d0608":"1","d0609":"1","d0610":"2","d0611":"2","d0612":"2","d0919":"2","d0920":"2","d0921":"2","d0922":"1","d0929":"1","d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1012":"1"},
"worktime.y2014":{"d0101":"2","d0126":"1","d0131":"2","d0201":"2","d0202":"2","d0203":"2","d0204":"2","d0205":"2","d0206":"2","d0208":"1","d0405":"2","d0407":"2","d0501":"2","d0502":"2","d0503":"2","d0504":"1","d0602":"2","d0908":"2","d0928":"1","d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1011":"1"},
"worktime.y2015":{"d0101":"2","d0102":"2","d0103":"2","d0104":"1","d0215":"1","d0218":"2","d0219":"2","d0220":"2","d0221":"2","d0222":"2","d0223":"2","d0224":"2","d0228":"1","d0404":"2","d0405":"2","d0406":"2","d0501":"2","d0502":"2","d0503":"2","d0620":"2","d0621":"2","d0622":"2","d0926":"2","d0927":"2","d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1010":"1"},
"worktime.y2018":{"d0101":"2","d0211":"1","d0215":"2","d0216":"2","d0217":"2","d0218":"2","d0219":"2","d0220":"2","d0221":"2","d0224":"1","d0405":"2","d0406":"2","d0407":"2","d0408":"1","d0428":"1","d0429":"2","d0430":"2","d0501":"2","d0616":"2","d0617":"2","d0618":"2","d0922":"2","d0923":"2","d0924":"2","d0929":"1","d0930":"1","d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1229":"1","d1230":"2","d1231":"2"},
"worktime.y2019":{"d0101":"2","d0202":"1","d0203":"1","d0204":"2","d0205":"2","d0206":"2","d0207":"2","d0208":"2","d0209":"2","d0210":"2","d0405":"2","d0406":"2","d0407":"2","d0501":"2","d0502":"2","d0503":"2","d0504":"2","d0505":"1","d0607":"2","d0608":"2","d0609":"2","d0913":"2","d0914":"2","d0915":"2","d0929":"1","d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1012":"1"},
"worktime.y2020":{"d0101":"2","d0119":"1","d0124":"2","d0125":"2","d0126":"2","d0127":"2","d0128":"2","d0129":"2","d0130":"2","d0201":"1","d0404":"2","d0405":"2","d0406":"2","d0426":"1","d0501":"2","d0502":"2","d0503":"2","d0504":"2","d0505":"2","d0509":"1","d0625":"2","d0626":"2","d0627":"2","d0628":"1","d0927":"1","d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1008":"2","d1010":"1"},
"worktime.y2021":{
"d0101":"2","d0102":"2","d0103":"2",
"d0207":"1","d0211":"2","d0212":"2","d0213":"2","d0214":"2","d0215":"2","d0216":"2","d0217":"2","d0220":"1",
"d0403":"2","d0404":"2","d0405":"2","d0425":"1",
"d0501":"2","d0502":"2","d0503":"2","d0504":"2","d0505":"2","d0508":"1",
"d0612":"2","d0613":"2","d0614":"2",
"d0918":"1","d0919":"2","d0920":"2","d0921":"2","d0926":"1",
"d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1009":"1"
},
"worktime.y2022":{
"d0101":"2","d0102":"2","d0103":"2","d0129":"1","d0130":"1","d0131":"2",
"d0201":"2","d0202":"2","d0203":"2","d0204":"2","d0205":"2","d0206":"2",
"d0402":"1","d0403":"2","d0404":"2","d0405":"2","d0424":"1","d0430":"2",
"d0501":"2","d0502":"2","d0503":"2","d0504":"2","d0507":"1",
"d0603":"2","d0604":"2","d0605":"2",
"d0910":"2","d0911":"2","d0912":"2",
"d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1008":"1","d1009":"1",
"d1231":"2"
},
"worktime.y2023":{
"d0101":"2","d0102":"2","d0121":"2","d0122":"2","d0123":"2","d0124":"2","d0125":"2","d0126":"2","d0127":"2","d0128":"1","d0129":"1",
"d0405":"2","d0423":"1","d0429":"2","d0430":"2",
"d0501":"2","d0502":"2","d0503":"2","d0506":"1",
"d0622":"2","d0623":"2","d0624":"2","d0625":"1",
"d0929":"2","d0930":"2",
"d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"1","d1008":"1"
}
}

View File

@ -0,0 +1,520 @@
{
"worktime.y2011": {
"d0101": "2",
"d0102": "2",
"d0103": "2",
"d0130": "1",
"d0202": "2",
"d0203": "2",
"d0204": "2",
"d0205": "2",
"d0206": "2",
"d0207": "2",
"d0208": "2",
"d0402": "1",
"d0403": "2",
"d0404": "2",
"d0405": "2",
"d0430": "2",
"d0501": "2",
"d0502": "2",
"d0604": "2",
"d0605": "2",
"d0606": "2",
"d0910": "2",
"d0911": "2",
"d0912": "2",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1008": "1",
"d1009": "1",
"d1231": "1"
},
"worktime.y2012": {
"d0101": "2",
"d0102": "2",
"d0103": "2",
"d0121": "1",
"d0122": "2",
"d0123": "2",
"d0124": "2",
"d0125": "2",
"d0126": "2",
"d0127": "2",
"d0128": "2",
"d0129": "1",
"d0331": "1",
"d0401": "1",
"d0402": "2",
"d0403": "2",
"d0404": "2",
"d0428": "1",
"d0429": "2",
"d0430": "2",
"d0501": "2",
"d0622": "2",
"d0623": "2",
"d0624": "2",
"d0929": "1",
"d0930": "2",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1008": "1"
},
"worktime.y2013": {
"d0101": "2",
"d0102": "2",
"d0103": "2",
"d0105": "1",
"d0106": "1",
"d0209": "2",
"d0210": "2",
"d0211": "2",
"d0212": "2",
"d0213": "2",
"d0214": "2",
"d0215": "2",
"d0216": "1",
"d0217": "1",
"d0404": "2",
"d0405": "2",
"d0406": "2",
"d0407": "1",
"d0427": "1",
"d0428": "1",
"d0429": "2",
"d0430": "2",
"d0501": "2",
"d0608": "1",
"d0609": "1",
"d0610": "2",
"d0611": "2",
"d0612": "2",
"d0919": "2",
"d0920": "2",
"d0921": "2",
"d0922": "1",
"d0929": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1012": "1"
},
"worktime.y2014": {
"d0101": "2",
"d0126": "1",
"d0131": "2",
"d0201": "2",
"d0202": "2",
"d0203": "2",
"d0204": "2",
"d0205": "2",
"d0206": "2",
"d0208": "1",
"d0405": "2",
"d0407": "2",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0504": "1",
"d0602": "2",
"d0908": "2",
"d0928": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1011": "1"
},
"worktime.y2015": {
"d0101": "2",
"d0102": "2",
"d0103": "2",
"d0104": "1",
"d0215": "1",
"d0218": "2",
"d0219": "2",
"d0220": "2",
"d0221": "2",
"d0222": "2",
"d0223": "2",
"d0224": "2",
"d0228": "1",
"d0404": "2",
"d0405": "2",
"d0406": "2",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0620": "2",
"d0621": "2",
"d0622": "2",
"d0926": "2",
"d0927": "2",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1010": "1"
},
"worktime.y2016": {
"d0101": "2",
"d0102": "2",
"d0103": "2",
"d0206": "1",
"d0207": "2",
"d0208": "2",
"d0209": "2",
"d0210": "2",
"d0211": "2",
"d0212": "2",
"d0213": "2",
"d0214": "1",
"d0402": "2",
"d0403": "2",
"d0404": "2",
"d0430": "2",
"d0501": "2",
"d0502": "2",
"d0609": "2",
"d0610": "2",
"d0611": "2",
"d0612": "1",
"d0915": "2",
"d0916": "2",
"d0917": "2",
"d0918": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1008": "1",
"d1009": "1",
"d1231": "2"
},
"worktime.y2017": {
"d0101":"2",
"d0102":"2",
"d0122":"1",
"d0127":"2",
"d0128":"2",
"d0129":"2",
"d0130":"2",
"d0131":"2",
"d0201":"2",
"d0202":"2",
"d0204":"1",
"d0401":"1",
"d0402":"2",
"d0403":"2",
"d0404":"2",
"d0429":"2",
"d0430":"2",
"d0501":"2",
"d0527":"1",
"d0528":"2",
"d0529":"2",
"d0530":"2",
"d0930":"1",
"d1001":"2",
"d1002":"2",
"d1003":"2",
"d1004":"2",
"d1005":"2",
"d1006":"2",
"d1007":"2",
"d1008":"2",
"d1230":"2",
"d1231":"2"
},
"worktime.y2018": {
"d0101": "2",
"d0211": "1",
"d0215": "2",
"d0216": "2",
"d0217": "2",
"d0218": "2",
"d0219": "2",
"d0220": "2",
"d0221": "2",
"d0224": "1",
"d0405": "2",
"d0406": "2",
"d0407": "2",
"d0408": "1",
"d0428": "1",
"d0429": "2",
"d0430": "2",
"d0501": "2",
"d0616": "2",
"d0617": "2",
"d0618": "2",
"d0922": "2",
"d0923": "2",
"d0924": "2",
"d0929": "1",
"d0930": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1229": "1",
"d1230": "2",
"d1231": "2"
},
"worktime.y2019": {
"d0101": "2",
"d0202": "1",
"d0203": "1",
"d0204": "2",
"d0205": "2",
"d0206": "2",
"d0207": "2",
"d0208": "2",
"d0209": "2",
"d0210": "2",
"d0405": "2",
"d0406": "2",
"d0407": "2",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0504": "2",
"d0505": "1",
"d0607": "2",
"d0608": "2",
"d0609": "2",
"d0913": "2",
"d0914": "2",
"d0915": "2",
"d0929": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1012": "1"
},
"worktime.y2020": {
"d0101": "2",
"d0119": "1",
"d0124": "2",
"d0125": "2",
"d0126": "2",
"d0127": "2",
"d0128": "2",
"d0129": "2",
"d0130": "2",
"d0201": "1",
"d0404": "2",
"d0405": "2",
"d0406": "2",
"d0426": "1",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0504": "2",
"d0505": "2",
"d0509": "1",
"d0625": "2",
"d0626": "2",
"d0627": "2",
"d0628": "1",
"d0927": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1008": "2",
"d1010": "1"
},
"worktime.y2021": {
"d0101": "2",
"d0102": "2",
"d0103": "2",
"d0207": "1",
"d0211": "2",
"d0212": "2",
"d0213": "2",
"d0214": "2",
"d0215": "2",
"d0216": "2",
"d0217": "2",
"d0220": "1",
"d0403": "2",
"d0404": "2",
"d0405": "2",
"d0425": "1",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0504": "2",
"d0505": "2",
"d0508": "1",
"d0612": "2",
"d0613": "2",
"d0614": "2",
"d0918": "1",
"d0919": "2",
"d0920": "2",
"d0921": "2",
"d0926": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1009": "1"
},
"worktime.y2022": {
"d0101": "2",
"d0102": "2",
"d0103": "2",
"d0129": "1",
"d0130": "1",
"d0131": "2",
"d0201": "2",
"d0202": "2",
"d0203": "2",
"d0204": "2",
"d0205": "2",
"d0206": "2",
"d0402": "1",
"d0403": "2",
"d0404": "2",
"d0405": "2",
"d0424": "1",
"d0430": "2",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0504": "2",
"d0507": "1",
"d0603": "2",
"d0604": "2",
"d0605": "2",
"d0910": "2",
"d0911": "2",
"d0912": "2",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1008": "1",
"d1009": "1",
"d1231": "2"
},
"worktime.y2023": {
"d0101": "2",
"d0102": "2",
"d0121": "2",
"d0122": "2",
"d0123": "2",
"d0124": "2",
"d0125": "2",
"d0126": "2",
"d0127": "2",
"d0128": "1",
"d0129": "1",
"d0405": "2",
"d0423": "1",
"d0429": "2",
"d0430": "2",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0506": "1",
"d0622": "2",
"d0623": "2",
"d0624": "2",
"d0625": "1",
"d0929": "2",
"d0930": "2",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "1",
"d1008": "1",
"d1230": "2",
"d1231": "2"
},
"worktime.y2024":{
"d0101": "2",
"d0204": "1",
"d0210": "2",
"d0211": "2",
"d0212": "2",
"d0213": "2",
"d0214": "2",
"d0215": "2",
"d0216": "2",
"d0217": "2",
"d0218": "1",
"d0404": "2",
"d0405": "2",
"d0406": "2",
"d0407": "1",
"d0428": "1",
"d0501": "2",
"d0502": "2",
"d0503": "2",
"d0504": "2",
"d0505": "2",
"d0511": "1",
"d0608": "2",
"d0609": "2",
"d0610": "2",
"d0914": "1",
"d0915": "2",
"d0916": "2",
"d0917": "2",
"d0929": "1",
"d1001": "2",
"d1002": "2",
"d1003": "2",
"d1004": "2",
"d1005": "2",
"d1006": "2",
"d1007": "2",
"d1012": "1"
}
}

View File

@ -16,7 +16,6 @@
*
*/
#include "calendarcolor.h"
#include <QApplication>
#include <QPalette>
@ -47,7 +46,7 @@ QColor CalendarColor::getThemeColor(Color c)
color = pal.highlightedText().color();
}break;
case OTHER_TEXT:{
color = pal.midlight().color();
color = pal.placeholderText().color();
}break;
case WORK:{
color = QColor(255, 129, 6);
@ -63,4 +62,27 @@ QColor CalendarColor::getThemeColor(Color c)
// qDebug() << (int)c << color;
return color;
}
static inline qreal mixQreal(qreal a, qreal b, qreal bias)
{
return a + (b-a)*bias;
}
QColor CalendarColor::mixColor(const QColor& in,qreal mix)
{
if (mix <= 0.0){
return in;
} else if(mix >= 1.0){
return in;
} else if(qIsNaN(mix)) {
return in;
}
QColor brightTextColor = QApplication::palette().brightText().color();
qreal r = mixQreal(in.redF(),brightTextColor.redF(),mix);
qreal g = mixQreal(in.greenF(),brightTextColor.greenF(),mix);
qreal b = mixQreal(in.blueF(),brightTextColor.blueF(),mix);
qreal a = mixQreal(in.alphaF(),brightTextColor.alphaF(),mix);
return QColor::fromRgbF(r, g, b, a);
}
}

View File

@ -16,7 +16,6 @@
*
*/
#ifndef CALENDARCOLOR_H
#define CALENDARCOLOR_H
@ -40,6 +39,8 @@ public:
CalendarColor();
public:
static QColor getThemeColor(Color c);
//混合颜色,参考主题代码
static QColor mixColor(const QColor& in,qreal mix);
};
}

View File

@ -68,37 +68,6 @@ void CustomStyle_pushbutton::drawItemText(QPainter *painter, const QRect &rectan
/// 如果你需要自己实现一个主题,这同样是你需要注意和考虑的点
void CustomStyle_pushbutton::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
// if (element == PE_PanelButtonCommand) {
// qDebug()<<"draw pe button";
// if (widget) {
// bool isPressed = false;
// bool isHover = false;
// if (!option->state.testFlag(State_Sunken)) {
// if (option->state.testFlag(State_MouseOver)) {
// isHover = true;
// }
// } else {
// isPressed = true;
// }
// QStyleOption opt = *option;
// if (isHover) {
// QColor color(255,255,255,51);
// opt.palette.setColor(QPalette::Highlight, color);
// }
// if (isPressed) {
// QColor color(255,255,255,21);
// opt.palette.setColor(QPalette::Highlight, color);
// }
// if (!isHover && !isPressed) {
// QColor color(255,255,255,31);
// opt.palette.setColor(QPalette::Button,color);
// }
// return QProxyStyle::drawPrimitive(element, &opt, painter, widget);
// }
// }
// return QProxyStyle::drawPrimitive(element, option, painter, widget);
if (element == PE_PanelButtonCommand) {
if (widget) {
if (option->state & State_MouseOver) {

View File

@ -18,6 +18,7 @@
#include "frmlunarcalendarwidget.h"
#include "ui_frmlunarcalendarwidget.h"
#include <QPainter>
#include <KWindowEffects>
#define TRANSPARENCY_SETTINGS "org.ukui.control-center.personalise"
#define TRANSPARENCY_KEY "transparency"
@ -25,20 +26,24 @@
#define LUNAR_KEY "calendar"
#define FIRST_DAY_KEY "firstday"
const int CALENDAR_WIDTH = 440;
const int CALENDAR_HEIGHT = 500;
const int CALENDAR_LUNAR_HEIGHT = 75;
const int CALENDAR_LUNAR_HEIGHT_PLUSE = 77;
frmLunarCalendarWidget::frmLunarCalendarWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmLunarCalendarWidget)
{
installEventFilter(this);
ui->setupUi(this);
connect(ui->lunarCalendarWidget,&LunarCalendarWidget::yijiChangeUp,this,&frmLunarCalendarWidget::changeUpSize);
connect(ui->lunarCalendarWidget,&LunarCalendarWidget::yijiChangeDown,this,&frmLunarCalendarWidget::changeDownSize);
connect(ui->lunarCalendarWidget,&LunarCalendarWidget::almanacChanged,this,&frmLunarCalendarWidget::showAlmanac);
connect(this, &frmLunarCalendarWidget::onShowToday,ui->lunarCalendarWidget,&LunarCalendarWidget::showToday);
this->initForm();
this->setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);//去掉标题栏
// this->setWindowFlags(Qt::Popup);
setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
setProperty("useSystemStyleBlur", true);
this->setFixedSize(440, 600);
//默认展开状态
bool showLunar = ui->lunarCalendarWidget->getShowLunar();
if(showLunar)
this->setFixedSize(CALENDAR_WIDTH, CALENDAR_HEIGHT+CALENDAR_LUNAR_HEIGHT+CALENDAR_LUNAR_HEIGHT_PLUSE);
else
this->setFixedSize(CALENDAR_WIDTH,CALENDAR_HEIGHT);
const QByteArray transparency_id(TRANSPARENCY_SETTINGS);
if(QGSettings::isSchemaInstalled(transparency_id)){
@ -68,16 +73,28 @@ frmLunarCalendarWidget::~frmLunarCalendarWidget()
delete ui;
}
void frmLunarCalendarWidget::showAlmanac(bool big)
{
qDebug() << __FILE__ <<__LINE__<<__FUNCTION__<<big;
if(big){
setFixedHeight(CALENDAR_HEIGHT+CALENDAR_LUNAR_HEIGHT+CALENDAR_LUNAR_HEIGHT_PLUSE);
}else{
setFixedHeight(CALENDAR_HEIGHT);
}
}
void frmLunarCalendarWidget::changeUpSize()
{
this->setFixedSize(440, 652);
Q_EMIT yijiChangeUp();
yijiIsUp = true;
this->setFixedSize(CALENDAR_WIDTH, CALENDAR_HEIGHT+CALENDAR_LUNAR_HEIGHT+CALENDAR_LUNAR_HEIGHT_PLUSE);
Q_EMIT yijiFChangeUp();
}
void frmLunarCalendarWidget::changeDownSize()
{
this->setFixedSize(440, 600);
Q_EMIT yijiChangeDown();
yijiIsUp = false;
this->setFixedSize(CALENDAR_WIDTH, CALENDAR_HEIGHT+CALENDAR_LUNAR_HEIGHT);
Q_EMIT yijiFChangeDown();
}
void frmLunarCalendarWidget::initForm()
@ -102,7 +119,15 @@ void frmLunarCalendarWidget::cboxWeekNameFormat_currentIndexChanged(bool FirstDa
void frmLunarCalendarWidget::ckShowLunar_stateChanged(bool arg1)
{
ui->lunarCalendarWidget->setShowLunar(arg1);
if (arg1) {
if (yijiIsUp) {
this->setFixedSize(CALENDAR_WIDTH,CALENDAR_HEIGHT+CALENDAR_LUNAR_HEIGHT+CALENDAR_LUNAR_HEIGHT_PLUSE);
} else {
this->setFixedSize(CALENDAR_WIDTH,CALENDAR_HEIGHT+CALENDAR_LUNAR_HEIGHT);
}
} else {
this->setFixedSize(CALENDAR_WIDTH,CALENDAR_HEIGHT);
}
}
void frmLunarCalendarWidget::paintEvent(QPaintEvent *)

View File

@ -46,6 +46,7 @@ private:
QGSettings *transparency_gsettings;
QGSettings *calendar_gsettings;
bool eventFilter(QObject *, QEvent *);
bool yijiIsUp = true;
private Q_SLOTS:
void initForm();
@ -53,12 +54,15 @@ private Q_SLOTS:
void cboxSelectType_currentIndexChanged(int index);
void cboxWeekNameFormat_currentIndexChanged(bool FirstDayisSun);
void ckShowLunar_stateChanged(bool arg1);
public Q_SLOTS:
void changeUpSize();
void changeDownSize();
//true: 顯示大窗口
//false: 顯示小窗口
void showAlmanac(bool big);
Q_SIGNALS:
void yijiChangeUp();
void yijiChangeDown();
void yijiFChangeUp();
void yijiFChangeDown();
void onShowToday();
};

Some files were not shown because too many files have changed in this diff Show More