From 8cd2a128e4bdde609ee81785bc6d549dc32163b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=82=9C?= Date: Fri, 20 May 2022 16:38:18 +0800 Subject: [PATCH 01/12] Import Upstream version 3.14.0.0 --- .github/workflows/build.yml | 0 COPYING | 0 NEWS | 0 README.md | 0 data/img/mainviewwidget/.DS_Store | Bin data/img/mainviewwidget/DM-all-2x.png | Bin data/img/mainviewwidget/DM-all.png | Bin data/img/mainviewwidget/DM-all.svg | 0 data/img/mainviewwidget/DM-arrow-2x.png | Bin data/img/mainviewwidget/DM-arrow.png | Bin data/img/mainviewwidget/DM-arrow.svg | 0 data/img/mainviewwidget/DM-close-2x.png | Bin data/img/mainviewwidget/DM-close.png | Bin data/img/mainviewwidget/DM-close.svg | 0 data/img/mainviewwidget/DM-function-2x.png | Bin data/img/mainviewwidget/DM-function.png | Bin data/img/mainviewwidget/DM-function.svg | 0 data/img/mainviewwidget/DM-icon-check.png | Bin data/img/mainviewwidget/DM-icon-check.svg | 0 data/img/mainviewwidget/DM-icon-check@2x.png | Bin .../{DM-icon-选项.svg => DM-icon-option.svg} | 0 data/img/mainviewwidget/DM-icon-search.png | Bin data/img/mainviewwidget/DM-icon-search.svg | 0 data/img/mainviewwidget/DM-icon-search@2x.png | Bin data/img/mainviewwidget/DM-icon-返回.png | Bin data/img/mainviewwidget/DM-icon-返回.svg | 0 data/img/mainviewwidget/DM-icon-返回@2x.png | Bin data/img/mainviewwidget/DM-icon-选项.png | Bin data/img/mainviewwidget/DM-icon-选项@2x.png | Bin data/img/mainviewwidget/DM-letter-2x.png | Bin data/img/mainviewwidget/DM-letter.png | Bin data/img/mainviewwidget/DM-letter.svg | 0 data/img/mainviewwidget/DM-max-2x.png | Bin data/img/mainviewwidget/DM-max.png | Bin data/img/mainviewwidget/DM-max.svg | 0 .../mainviewwidget/Development-Checked.svg | 0 .../mainviewwidget/Development-Disabled.svg | 0 .../mainviewwidget/Development-Enabled.svg | 0 .../img/mainviewwidget/Development-Normal.svg | 0 data/img/mainviewwidget/Education-Checked.svg | 0 .../img/mainviewwidget/Education-Disabled.svg | 0 data/img/mainviewwidget/Education-Enabled.svg | 0 data/img/mainviewwidget/Education-Normal.svg | 0 data/img/mainviewwidget/Game-Checked.svg | 0 data/img/mainviewwidget/Game-Disabled.svg | 0 data/img/mainviewwidget/Game-Enabled.svg | 0 data/img/mainviewwidget/Game-Normal.svg | 0 data/img/mainviewwidget/Image-Checked.svg | 0 data/img/mainviewwidget/Image-Disabled.svg | 0 data/img/mainviewwidget/Image-Enabled.svg | 0 data/img/mainviewwidget/Image-Normal.svg | 0 data/img/mainviewwidget/Internet-Checked.svg | 0 data/img/mainviewwidget/Internet-Disabled.svg | 0 data/img/mainviewwidget/Internet-Enabled.svg | 0 data/img/mainviewwidget/Internet-Normal.svg | 0 data/img/mainviewwidget/Mobile-Checked.svg | 0 data/img/mainviewwidget/Mobile-Disabled.svg | 0 data/img/mainviewwidget/Mobile-Enabled.svg | 0 data/img/mainviewwidget/Mobile-Normal.svg | 0 data/img/mainviewwidget/Office-Checked.svg | 0 data/img/mainviewwidget/Office-Disabled.svg | 0 data/img/mainviewwidget/Office-Enabled.svg | 0 data/img/mainviewwidget/Office-Normal.svg | 0 data/img/mainviewwidget/Others-Checked.svg | 0 data/img/mainviewwidget/Others-Disabled.svg | 0 data/img/mainviewwidget/Others-Enabled.svg | 0 data/img/mainviewwidget/Others-Normal.svg | 0 data/img/mainviewwidget/Social-Checked.svg | 0 data/img/mainviewwidget/Social-Disabled.svg | 0 data/img/mainviewwidget/Social-Enabled.svg | 0 data/img/mainviewwidget/Social-Normal.svg | 0 data/img/mainviewwidget/System-Checked.svg | 0 data/img/mainviewwidget/System-Disabled.svg | 0 data/img/mainviewwidget/System-Enabled.svg | 0 data/img/mainviewwidget/System-Normal.svg | 0 data/img/mainviewwidget/Video-Checked.svg | 0 data/img/mainviewwidget/Video-Disabled.svg | 0 data/img/mainviewwidget/Video-Enabled.svg | 0 data/img/mainviewwidget/Video-Normal.svg | 0 data/img/mainviewwidget/all-2x.png | Bin data/img/mainviewwidget/all.png | Bin data/img/mainviewwidget/all.svg | 0 data/img/mainviewwidget/attributeaction.svg | 0 data/img/mainviewwidget/close-2x.png | Bin data/img/mainviewwidget/close.png | Bin data/img/mainviewwidget/close.svg | 0 data/img/mainviewwidget/downarrow-pressed.svg | 0 data/img/mainviewwidget/downarrow.svg | 0 data/img/mainviewwidget/drop-down-2x.png | Bin data/img/mainviewwidget/drop-down.png | Bin data/img/mainviewwidget/drop-down.svg | 0 data/img/mainviewwidget/fixed.svg | 0 data/img/mainviewwidget/full-all-2x.png | Bin data/img/mainviewwidget/full-close-2x.png | Bin data/img/mainviewwidget/full-close.png | Bin data/img/mainviewwidget/full-close.svg | 0 data/img/mainviewwidget/full-drop-down-2x.png | Bin data/img/mainviewwidget/full-drop-down.png | Bin data/img/mainviewwidget/full-drop-down.svg | 0 data/img/mainviewwidget/full-function-2x.png | Bin data/img/mainviewwidget/full-function.png | Bin data/img/mainviewwidget/full-function.svg | 0 data/img/mainviewwidget/full-letter-2x.png | Bin data/img/mainviewwidget/full-letter.png | Bin data/img/mainviewwidget/full-letter.svg | 0 data/img/mainviewwidget/full-min-2x.png | Bin data/img/mainviewwidget/full-min.png | Bin data/img/mainviewwidget/full-min.svg | 0 data/img/mainviewwidget/full-search-2x.png | Bin data/img/mainviewwidget/full-search.png | Bin data/img/mainviewwidget/full-search.svg | 0 data/img/mainviewwidget/fullicon-all.png | Bin data/img/mainviewwidget/fullicon-all.svg | 0 data/img/mainviewwidget/function-2x.png | Bin data/img/mainviewwidget/function.png | Bin data/img/mainviewwidget/function.svg | 0 data/img/mainviewwidget/icon- search-2x.png | Bin data/img/mainviewwidget/icon- search.png | Bin data/img/mainviewwidget/icon- search.svg | 0 data/img/mainviewwidget/icon- 返回.png | Bin data/img/mainviewwidget/icon- 返回.svg | 0 data/img/mainviewwidget/icon- 返回@2x.png | Bin data/img/mainviewwidget/icon- 选项.png | Bin data/img/mainviewwidget/icon- 选项.svg | 0 data/img/mainviewwidget/icon- 选项@2x.png | Bin data/img/mainviewwidget/icon-check.png | Bin data/img/mainviewwidget/icon-check.svg | 0 data/img/mainviewwidget/icon-check@2x.png | Bin data/img/mainviewwidget/leftarrow-hover.svg | 0 data/img/mainviewwidget/leftarrow.svg | 0 data/img/mainviewwidget/letter-2x.png | Bin data/img/mainviewwidget/letter.png | Bin data/img/mainviewwidget/letter.svg | 0 data/img/mainviewwidget/lock-fs.svg | 0 data/img/mainviewwidget/lock.svg | 0 data/img/mainviewwidget/max-2x.png | Bin data/img/mainviewwidget/max.png | Bin data/img/mainviewwidget/max.svg | 0 data/img/mainviewwidget/power-2x.png | Bin data/img/mainviewwidget/power.png | Bin data/img/mainviewwidget/power.svg | 0 data/img/mainviewwidget/recent-disabled.svg | 0 data/img/mainviewwidget/recent-enabled.svg | 0 data/img/mainviewwidget/recent-gray.svg | 0 data/img/mainviewwidget/recent.svg | 0 data/img/mainviewwidget/rightarrow-hover.svg | 0 data/img/mainviewwidget/rightarrow.svg | 0 data/img/mainviewwidget/search.svg | 0 data/img/mainviewwidget/select.svg | 0 data/img/mainviewwidget/selected.svg | 0 data/img/mainviewwidget/ukui-search-blue.svg | 0 data/img/mainviewwidget/ukui-search.svg | 0 data/img/mainviewwidget/unfixed.svg | 0 data/img/mainviewwidget/uninstall.svg | 0 data/img/mainviewwidget/uparrow-pressed.svg | 0 data/img/mainviewwidget/uparrow.svg | 0 data/img/sidebarwidget/commonuse.svg | 0 data/img/sidebarwidget/computer.svg | 0 data/img/sidebarwidget/control.svg | 0 data/img/sidebarwidget/fixed.svg | 0 data/img/sidebarwidget/fullusericon.png | Bin data/img/sidebarwidget/function.svg | 0 data/img/sidebarwidget/letter.svg | 0 data/img/sidebarwidget/lock.svg | 0 data/img/sidebarwidget/max.svg | 0 data/img/sidebarwidget/min.svg | 0 data/img/sidebarwidget/personal.svg | 0 data/img/sidebarwidget/rightarrow.svg | 0 data/img/sidebarwidget/setting.svg | 0 data/img/sidebarwidget/shutdown.svg | 0 data/img/sidebarwidget/trash.svg | 0 data/img/sidebarwidget/unfixed.svg | 0 data/img/sidebarwidget/usericon-darkcolor.svg | 0 .../img/sidebarwidget/usericon-lightcolor.svg | 0 main.cpp | 0 man/ukui-menu.1 | 0 res.qrc | 2 +- src/BackProcess/DBus/dbus-adaptor.cpp | 0 src/BackProcess/DBus/dbus-adaptor.h | 0 src/BackProcess/DBus/dbus.cpp | 0 src/BackProcess/DBus/dbus.h | 0 src/BackProcess/DBus/org.ukui.menu.xml | 0 .../FileWatcher/convert_winid_to_desktop.cpp | 0 .../FileWatcher/convert_winid_to_desktop.h | 0 .../FileWatcher/desktop_watcher.cpp | 0 src/BackProcess/FileWatcher/desktop_watcher.h | 0 .../FileWatcher/directory_changed_thread.cpp | 0 .../FileWatcher/directory_changed_thread.h | 0 .../software_database_update_thread.cpp | 0 .../software_database_update_thread.h | 0 .../tablet_directorychanged_thread.cpp | 0 .../tablet_directorychanged_thread.h | 0 .../Interface/currenttime_interface.cpp | 0 .../Interface/currenttime_interface.h | 0 .../Interface/ukui_chineseletter.cpp | 0 .../Interface/ukui_chineseletter.h | 0 .../Interface/ukuimenuinterface.cpp | 2 - src/BackProcess/Interface/ukuimenuinterface.h | 0 src/BackProcess/Search/file-utils.cpp | 0 src/BackProcess/Search/file-utils.h | 0 src/BackProcess/Search/pinyinWithTone.txt | 0 src/BackProcess/Search/pinyinWithoutTone.txt | 0 src/BackProcess/Search/searchappthread.cpp | 0 src/BackProcess/Search/searchappthread.h | 0 .../XEventMonitor/xeventmonitor.cpp | 0 src/BackProcess/XEventMonitor/xeventmonitor.h | 0 src/BackProcess/backprocess.pri | 0 src/BackProcess/tablet/getmodeldata.cpp | 0 src/BackProcess/tablet/getmodeldata.h | 0 src/BackProcess/tablet/pagemanager.cpp | 0 src/BackProcess/tablet/pagemanager.h | 0 src/QtSingleApplication/QtLockedFile | 0 src/QtSingleApplication/QtSingleApplication | 0 src/QtSingleApplication/qtlocalpeer.cpp | 0 src/QtSingleApplication/qtlocalpeer.h | 0 src/QtSingleApplication/qtlockedfile.cpp | 0 src/QtSingleApplication/qtlockedfile.h | 0 src/QtSingleApplication/qtlockedfile_unix.cpp | 0 src/QtSingleApplication/qtlockedfile_win.cpp | 0 .../qtsingleapplication.cpp | 0 src/QtSingleApplication/qtsingleapplication.h | 0 .../qtsingleapplication.pri | 0 .../qtsinglecoreapplication.cpp | 0 .../qtsinglecoreapplication.h | 0 .../qtsinglecoreapplication.pri | 0 .../Button/function_classify_button.cpp | 18 +- .../Button/function_classify_button.h | 0 .../Button/letter_classify_button.cpp | 30 +- .../Button/letter_classify_button.h | 0 src/UserInterface/Button/tool_button.cpp | 0 src/UserInterface/Button/tool_button.h | 0 src/UserInterface/ListView/fulllistview.cpp | 0 src/UserInterface/ListView/fulllistview.h | 0 src/UserInterface/ListView/klistview.cpp | 0 src/UserInterface/ListView/klistview.h | 0 src/UserInterface/ListView/listview.cpp | 10 +- src/UserInterface/ListView/listview.h | 0 src/UserInterface/ListView/rightlistview.cpp | 18 +- src/UserInterface/ListView/rightlistview.h | 5 +- src/UserInterface/ListView/tabletlistview.cpp | 0 src/UserInterface/ListView/tabletlistview.h | 0 .../Other/classify_btn_scrollarea.cpp | 0 .../Other/classify_btn_scrollarea.h | 0 src/UserInterface/Other/lettertooltip.cpp | 0 src/UserInterface/Other/lettertooltip.h | 0 src/UserInterface/Other/scrollarea.cpp | 0 src/UserInterface/Other/scrollarea.h | 0 src/UserInterface/RightClickMenu/menubox.cpp | 0 src/UserInterface/RightClickMenu/menubox.h | 0 .../RightClickMenu/rightclickmenu.cpp | 0 .../RightClickMenu/rightclickmenu.h | 0 .../RightClickMenu/tabletrightclickmenu.cpp | 0 .../RightClickMenu/tabletrightclickmenu.h | 0 .../ViewItem/full_item_delegate.cpp | 0 .../ViewItem/full_item_delegate.h | 0 src/UserInterface/ViewItem/itemdelegate.cpp | 33 +- src/UserInterface/ViewItem/itemdelegate.h | 0 src/UserInterface/ViewItem/kitemdelegate.cpp | 0 src/UserInterface/ViewItem/kitemdelegate.h | 0 .../ViewItem/recent_item_delegate.cpp | 0 .../ViewItem/recent_item_delegate.h | 0 .../ViewItem/right_item_delegate.cpp | 21 +- .../ViewItem/right_item_delegate.h | 0 .../ViewItem/tablet_full_itemdelegate.cpp | 0 .../ViewItem/tablet_full_itemdelegate.h | 0 src/UserInterface/Widget/animationpage.cpp | 0 src/UserInterface/Widget/animationpage.h | 0 .../Widget/full_commonuse_widget.cpp | 0 .../Widget/full_commonuse_widget.h | 0 .../Widget/full_function_widget.cpp | 0 .../Widget/full_function_widget.h | 0 .../Widget/full_letter_widget.cpp | 0 src/UserInterface/Widget/full_letter_widget.h | 0 .../Widget/full_searchresult_widget.cpp | 0 .../Widget/full_searchresult_widget.h | 0 src/UserInterface/Widget/function_Widget.cpp | 0 src/UserInterface/Widget/function_Widget.h | 0 .../Widget/function_button_widget.cpp | 3 +- .../Widget/function_button_widget.h | 0 .../Widget/letter_button_widget.cpp | 13 +- .../Widget/letter_button_widget.h | 0 src/UserInterface/Widget/main_view_widget.cpp | 20 +- src/UserInterface/Widget/main_view_widget.h | 4 + src/UserInterface/Widget/plugin_widget.cpp | 0 src/UserInterface/Widget/plugin_widget.h | 0 src/UserInterface/Widget/splitbar_frame.cpp | 0 src/UserInterface/Widget/splitbar_frame.h | 0 src/UserInterface/Widget/tabview_widget.cpp | 0 src/UserInterface/Widget/tabview_widget.h | 0 src/UserInterface/full_mainwindow.cpp | 2 +- src/UserInterface/full_mainwindow.h | 0 src/UserInterface/mainwindow.cpp | 120 ++++--- src/UserInterface/mainwindow.h | 8 +- src/UserInterface/tabletwindow.cpp | 77 ++--- src/UserInterface/tabletwindow.h | 7 +- src/UserInterface/userinterface.pri | 0 src/UtilityFunction/AbstractInterface.h | 0 src/UtilityFunction/KySmallPluginInterface.h | 0 src/UtilityFunction/Style/style.cpp | 15 +- src/UtilityFunction/Style/style.h | 4 +- src/UtilityFunction/abstractInterface.h | 0 src/UtilityFunction/thumbnail.cpp | 0 src/UtilityFunction/thumbnail.h | 0 src/UtilityFunction/utility.cpp | 1 + src/UtilityFunction/utility.h | 1 + src/UtilityFunction/utilityfunction.pri | 0 translations/ukui-menu_bo.qm | 0 translations/ukui-menu_bo.ts | 0 translations/ukui-menu_tr.qm | Bin translations/ukui-menu_tr.ts | 0 translations/ukui-menu_zh_CN.qm | Bin translations/ukui-menu_zh_CN.ts | 0 ukui-menu.desktop | 0 ukui-menu.ini | 0 ukui-menu.pro | 0 ukui-menu.pro.user | 314 ++++++++++++++++++ 316 files changed, 576 insertions(+), 152 deletions(-) mode change 100755 => 100644 .github/workflows/build.yml mode change 100755 => 100644 COPYING mode change 100755 => 100644 NEWS mode change 100755 => 100644 README.md mode change 100755 => 100644 data/img/mainviewwidget/.DS_Store mode change 100755 => 100644 data/img/mainviewwidget/DM-all-2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-all.png mode change 100755 => 100644 data/img/mainviewwidget/DM-all.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-arrow-2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-arrow.png mode change 100755 => 100644 data/img/mainviewwidget/DM-arrow.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-close-2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-close.png mode change 100755 => 100644 data/img/mainviewwidget/DM-close.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-function-2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-function.png mode change 100755 => 100644 data/img/mainviewwidget/DM-function.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-check.png mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-check.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-check@2x.png rename data/img/mainviewwidget/{DM-icon-选项.svg => DM-icon-option.svg} (100%) mode change 100755 => 100644 mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-search.png mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-search.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-search@2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-返回.png mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-返回.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-返回@2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-选项.png mode change 100755 => 100644 data/img/mainviewwidget/DM-icon-选项@2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-letter-2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-letter.png mode change 100755 => 100644 data/img/mainviewwidget/DM-letter.svg mode change 100755 => 100644 data/img/mainviewwidget/DM-max-2x.png mode change 100755 => 100644 data/img/mainviewwidget/DM-max.png mode change 100755 => 100644 data/img/mainviewwidget/DM-max.svg mode change 100755 => 100644 data/img/mainviewwidget/Development-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Development-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Development-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Development-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/all-2x.png mode change 100755 => 100644 data/img/mainviewwidget/all.png mode change 100755 => 100644 data/img/mainviewwidget/all.svg mode change 100755 => 100644 data/img/mainviewwidget/attributeaction.svg mode change 100755 => 100644 data/img/mainviewwidget/close-2x.png mode change 100755 => 100644 data/img/mainviewwidget/close.png mode change 100755 => 100644 data/img/mainviewwidget/close.svg mode change 100755 => 100644 data/img/mainviewwidget/downarrow-pressed.svg mode change 100755 => 100644 data/img/mainviewwidget/downarrow.svg mode change 100755 => 100644 data/img/mainviewwidget/drop-down-2x.png mode change 100755 => 100644 data/img/mainviewwidget/drop-down.png mode change 100755 => 100644 data/img/mainviewwidget/drop-down.svg mode change 100755 => 100644 data/img/mainviewwidget/fixed.svg mode change 100755 => 100644 data/img/mainviewwidget/full-all-2x.png mode change 100755 => 100644 data/img/mainviewwidget/full-close-2x.png mode change 100755 => 100644 data/img/mainviewwidget/full-close.png mode change 100755 => 100644 data/img/mainviewwidget/full-close.svg mode change 100755 => 100644 data/img/mainviewwidget/full-drop-down-2x.png mode change 100755 => 100644 data/img/mainviewwidget/full-drop-down.png mode change 100755 => 100644 data/img/mainviewwidget/full-drop-down.svg mode change 100755 => 100644 data/img/mainviewwidget/full-function-2x.png mode change 100755 => 100644 data/img/mainviewwidget/full-function.png mode change 100755 => 100644 data/img/mainviewwidget/full-function.svg mode change 100755 => 100644 data/img/mainviewwidget/full-letter-2x.png mode change 100755 => 100644 data/img/mainviewwidget/full-letter.png mode change 100755 => 100644 data/img/mainviewwidget/full-letter.svg mode change 100755 => 100644 data/img/mainviewwidget/full-min-2x.png mode change 100755 => 100644 data/img/mainviewwidget/full-min.png mode change 100755 => 100644 data/img/mainviewwidget/full-min.svg mode change 100755 => 100644 data/img/mainviewwidget/full-search-2x.png mode change 100755 => 100644 data/img/mainviewwidget/full-search.png mode change 100755 => 100644 data/img/mainviewwidget/full-search.svg mode change 100755 => 100644 data/img/mainviewwidget/fullicon-all.png mode change 100755 => 100644 data/img/mainviewwidget/fullicon-all.svg mode change 100755 => 100644 data/img/mainviewwidget/function-2x.png mode change 100755 => 100644 data/img/mainviewwidget/function.png mode change 100755 => 100644 data/img/mainviewwidget/function.svg mode change 100755 => 100644 data/img/mainviewwidget/icon- search-2x.png mode change 100755 => 100644 data/img/mainviewwidget/icon- search.png mode change 100755 => 100644 data/img/mainviewwidget/icon- search.svg mode change 100755 => 100644 data/img/mainviewwidget/icon- 返回.png mode change 100755 => 100644 data/img/mainviewwidget/icon- 返回.svg mode change 100755 => 100644 data/img/mainviewwidget/icon- 返回@2x.png mode change 100755 => 100644 data/img/mainviewwidget/icon- 选项.png mode change 100755 => 100644 data/img/mainviewwidget/icon- 选项.svg mode change 100755 => 100644 data/img/mainviewwidget/icon- 选项@2x.png mode change 100755 => 100644 data/img/mainviewwidget/icon-check.png mode change 100755 => 100644 data/img/mainviewwidget/icon-check.svg mode change 100755 => 100644 data/img/mainviewwidget/icon-check@2x.png mode change 100755 => 100644 data/img/mainviewwidget/leftarrow-hover.svg mode change 100755 => 100644 data/img/mainviewwidget/leftarrow.svg mode change 100755 => 100644 data/img/mainviewwidget/letter-2x.png mode change 100755 => 100644 data/img/mainviewwidget/letter.png mode change 100755 => 100644 data/img/mainviewwidget/letter.svg mode change 100755 => 100644 data/img/mainviewwidget/lock-fs.svg mode change 100755 => 100644 data/img/mainviewwidget/lock.svg mode change 100755 => 100644 data/img/mainviewwidget/max-2x.png mode change 100755 => 100644 data/img/mainviewwidget/max.png mode change 100755 => 100644 data/img/mainviewwidget/max.svg mode change 100755 => 100644 data/img/mainviewwidget/power-2x.png mode change 100755 => 100644 data/img/mainviewwidget/power.png mode change 100755 => 100644 data/img/mainviewwidget/power.svg mode change 100755 => 100644 data/img/mainviewwidget/recent-disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/recent-enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/recent-gray.svg mode change 100755 => 100644 data/img/mainviewwidget/recent.svg mode change 100755 => 100644 data/img/mainviewwidget/rightarrow-hover.svg mode change 100755 => 100644 data/img/mainviewwidget/rightarrow.svg mode change 100755 => 100644 data/img/mainviewwidget/search.svg mode change 100755 => 100644 data/img/mainviewwidget/select.svg mode change 100755 => 100644 data/img/mainviewwidget/selected.svg mode change 100755 => 100644 data/img/mainviewwidget/ukui-search-blue.svg mode change 100755 => 100644 data/img/mainviewwidget/ukui-search.svg mode change 100755 => 100644 data/img/mainviewwidget/unfixed.svg mode change 100755 => 100644 data/img/mainviewwidget/uninstall.svg mode change 100755 => 100644 data/img/mainviewwidget/uparrow-pressed.svg mode change 100755 => 100644 data/img/mainviewwidget/uparrow.svg mode change 100755 => 100644 data/img/sidebarwidget/commonuse.svg mode change 100755 => 100644 data/img/sidebarwidget/computer.svg mode change 100755 => 100644 data/img/sidebarwidget/control.svg mode change 100755 => 100644 data/img/sidebarwidget/fixed.svg mode change 100755 => 100644 data/img/sidebarwidget/fullusericon.png mode change 100755 => 100644 data/img/sidebarwidget/function.svg mode change 100755 => 100644 data/img/sidebarwidget/letter.svg mode change 100755 => 100644 data/img/sidebarwidget/lock.svg mode change 100755 => 100644 data/img/sidebarwidget/max.svg mode change 100755 => 100644 data/img/sidebarwidget/min.svg mode change 100755 => 100644 data/img/sidebarwidget/personal.svg mode change 100755 => 100644 data/img/sidebarwidget/rightarrow.svg mode change 100755 => 100644 data/img/sidebarwidget/setting.svg mode change 100755 => 100644 data/img/sidebarwidget/shutdown.svg mode change 100755 => 100644 data/img/sidebarwidget/trash.svg mode change 100755 => 100644 data/img/sidebarwidget/unfixed.svg mode change 100755 => 100644 data/img/sidebarwidget/usericon-darkcolor.svg mode change 100755 => 100644 data/img/sidebarwidget/usericon-lightcolor.svg mode change 100755 => 100644 main.cpp mode change 100755 => 100644 man/ukui-menu.1 mode change 100755 => 100644 res.qrc mode change 100755 => 100644 src/BackProcess/DBus/dbus-adaptor.cpp mode change 100755 => 100644 src/BackProcess/DBus/dbus-adaptor.h mode change 100755 => 100644 src/BackProcess/DBus/dbus.cpp mode change 100755 => 100644 src/BackProcess/DBus/dbus.h mode change 100755 => 100644 src/BackProcess/DBus/org.ukui.menu.xml mode change 100755 => 100644 src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp mode change 100755 => 100644 src/BackProcess/FileWatcher/convert_winid_to_desktop.h mode change 100755 => 100644 src/BackProcess/FileWatcher/desktop_watcher.cpp mode change 100755 => 100644 src/BackProcess/FileWatcher/desktop_watcher.h mode change 100755 => 100644 src/BackProcess/FileWatcher/directory_changed_thread.cpp mode change 100755 => 100644 src/BackProcess/FileWatcher/directory_changed_thread.h mode change 100755 => 100644 src/BackProcess/FileWatcher/software_database_update_thread.cpp mode change 100755 => 100644 src/BackProcess/FileWatcher/software_database_update_thread.h mode change 100755 => 100644 src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp mode change 100755 => 100644 src/BackProcess/FileWatcher/tablet_directorychanged_thread.h mode change 100755 => 100644 src/BackProcess/Interface/currenttime_interface.cpp mode change 100755 => 100644 src/BackProcess/Interface/currenttime_interface.h mode change 100755 => 100644 src/BackProcess/Interface/ukui_chineseletter.cpp mode change 100755 => 100644 src/BackProcess/Interface/ukui_chineseletter.h mode change 100755 => 100644 src/BackProcess/Interface/ukuimenuinterface.cpp mode change 100755 => 100644 src/BackProcess/Interface/ukuimenuinterface.h mode change 100755 => 100644 src/BackProcess/Search/file-utils.cpp mode change 100755 => 100644 src/BackProcess/Search/file-utils.h mode change 100755 => 100644 src/BackProcess/Search/pinyinWithTone.txt mode change 100755 => 100644 src/BackProcess/Search/pinyinWithoutTone.txt mode change 100755 => 100644 src/BackProcess/Search/searchappthread.cpp mode change 100755 => 100644 src/BackProcess/Search/searchappthread.h mode change 100755 => 100644 src/BackProcess/XEventMonitor/xeventmonitor.cpp mode change 100755 => 100644 src/BackProcess/XEventMonitor/xeventmonitor.h mode change 100755 => 100644 src/BackProcess/backprocess.pri mode change 100755 => 100644 src/BackProcess/tablet/getmodeldata.cpp mode change 100755 => 100644 src/BackProcess/tablet/getmodeldata.h mode change 100755 => 100644 src/BackProcess/tablet/pagemanager.cpp mode change 100755 => 100644 src/BackProcess/tablet/pagemanager.h mode change 100755 => 100644 src/QtSingleApplication/QtLockedFile mode change 100755 => 100644 src/QtSingleApplication/QtSingleApplication mode change 100755 => 100644 src/QtSingleApplication/qtlocalpeer.cpp mode change 100755 => 100644 src/QtSingleApplication/qtlocalpeer.h mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile.cpp mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile.h mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile_unix.cpp mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile_win.cpp mode change 100755 => 100644 src/QtSingleApplication/qtsingleapplication.cpp mode change 100755 => 100644 src/QtSingleApplication/qtsingleapplication.h mode change 100755 => 100644 src/QtSingleApplication/qtsingleapplication.pri mode change 100755 => 100644 src/QtSingleApplication/qtsinglecoreapplication.cpp mode change 100755 => 100644 src/QtSingleApplication/qtsinglecoreapplication.h mode change 100755 => 100644 src/QtSingleApplication/qtsinglecoreapplication.pri mode change 100755 => 100644 src/UserInterface/Button/function_classify_button.cpp mode change 100755 => 100644 src/UserInterface/Button/function_classify_button.h mode change 100755 => 100644 src/UserInterface/Button/letter_classify_button.cpp mode change 100755 => 100644 src/UserInterface/Button/letter_classify_button.h mode change 100755 => 100644 src/UserInterface/Button/tool_button.cpp mode change 100755 => 100644 src/UserInterface/Button/tool_button.h mode change 100755 => 100644 src/UserInterface/ListView/fulllistview.cpp mode change 100755 => 100644 src/UserInterface/ListView/fulllistview.h mode change 100755 => 100644 src/UserInterface/ListView/klistview.cpp mode change 100755 => 100644 src/UserInterface/ListView/klistview.h mode change 100755 => 100644 src/UserInterface/ListView/listview.cpp mode change 100755 => 100644 src/UserInterface/ListView/listview.h mode change 100755 => 100644 src/UserInterface/ListView/rightlistview.cpp mode change 100755 => 100644 src/UserInterface/ListView/rightlistview.h mode change 100755 => 100644 src/UserInterface/ListView/tabletlistview.cpp mode change 100755 => 100644 src/UserInterface/ListView/tabletlistview.h mode change 100755 => 100644 src/UserInterface/Other/classify_btn_scrollarea.cpp mode change 100755 => 100644 src/UserInterface/Other/classify_btn_scrollarea.h mode change 100755 => 100644 src/UserInterface/Other/lettertooltip.cpp mode change 100755 => 100644 src/UserInterface/Other/lettertooltip.h mode change 100755 => 100644 src/UserInterface/Other/scrollarea.cpp mode change 100755 => 100644 src/UserInterface/Other/scrollarea.h mode change 100755 => 100644 src/UserInterface/RightClickMenu/menubox.cpp mode change 100755 => 100644 src/UserInterface/RightClickMenu/menubox.h mode change 100755 => 100644 src/UserInterface/RightClickMenu/rightclickmenu.cpp mode change 100755 => 100644 src/UserInterface/RightClickMenu/rightclickmenu.h mode change 100755 => 100644 src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp mode change 100755 => 100644 src/UserInterface/RightClickMenu/tabletrightclickmenu.h mode change 100755 => 100644 src/UserInterface/ViewItem/full_item_delegate.cpp mode change 100755 => 100644 src/UserInterface/ViewItem/full_item_delegate.h mode change 100755 => 100644 src/UserInterface/ViewItem/itemdelegate.cpp mode change 100755 => 100644 src/UserInterface/ViewItem/itemdelegate.h mode change 100755 => 100644 src/UserInterface/ViewItem/kitemdelegate.cpp mode change 100755 => 100644 src/UserInterface/ViewItem/kitemdelegate.h mode change 100755 => 100644 src/UserInterface/ViewItem/recent_item_delegate.cpp mode change 100755 => 100644 src/UserInterface/ViewItem/recent_item_delegate.h mode change 100755 => 100644 src/UserInterface/ViewItem/right_item_delegate.cpp mode change 100755 => 100644 src/UserInterface/ViewItem/right_item_delegate.h mode change 100755 => 100644 src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp mode change 100755 => 100644 src/UserInterface/ViewItem/tablet_full_itemdelegate.h mode change 100755 => 100644 src/UserInterface/Widget/animationpage.cpp mode change 100755 => 100644 src/UserInterface/Widget/animationpage.h mode change 100755 => 100644 src/UserInterface/Widget/full_commonuse_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/full_commonuse_widget.h mode change 100755 => 100644 src/UserInterface/Widget/full_function_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/full_function_widget.h mode change 100755 => 100644 src/UserInterface/Widget/full_letter_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/full_letter_widget.h mode change 100755 => 100644 src/UserInterface/Widget/full_searchresult_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/full_searchresult_widget.h mode change 100755 => 100644 src/UserInterface/Widget/function_Widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/function_Widget.h mode change 100755 => 100644 src/UserInterface/Widget/function_button_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/function_button_widget.h mode change 100755 => 100644 src/UserInterface/Widget/letter_button_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/letter_button_widget.h mode change 100755 => 100644 src/UserInterface/Widget/main_view_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/main_view_widget.h mode change 100755 => 100644 src/UserInterface/Widget/plugin_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/plugin_widget.h mode change 100755 => 100644 src/UserInterface/Widget/splitbar_frame.cpp mode change 100755 => 100644 src/UserInterface/Widget/splitbar_frame.h mode change 100755 => 100644 src/UserInterface/Widget/tabview_widget.cpp mode change 100755 => 100644 src/UserInterface/Widget/tabview_widget.h mode change 100755 => 100644 src/UserInterface/full_mainwindow.cpp mode change 100755 => 100644 src/UserInterface/full_mainwindow.h mode change 100755 => 100644 src/UserInterface/mainwindow.cpp mode change 100755 => 100644 src/UserInterface/mainwindow.h mode change 100755 => 100644 src/UserInterface/tabletwindow.cpp mode change 100755 => 100644 src/UserInterface/tabletwindow.h mode change 100755 => 100644 src/UserInterface/userinterface.pri mode change 100755 => 100644 src/UtilityFunction/AbstractInterface.h mode change 100755 => 100644 src/UtilityFunction/KySmallPluginInterface.h mode change 100755 => 100644 src/UtilityFunction/Style/style.cpp mode change 100755 => 100644 src/UtilityFunction/Style/style.h mode change 100755 => 100644 src/UtilityFunction/abstractInterface.h mode change 100755 => 100644 src/UtilityFunction/thumbnail.cpp mode change 100755 => 100644 src/UtilityFunction/thumbnail.h mode change 100755 => 100644 src/UtilityFunction/utility.cpp mode change 100755 => 100644 src/UtilityFunction/utility.h mode change 100755 => 100644 src/UtilityFunction/utilityfunction.pri mode change 100755 => 100644 translations/ukui-menu_bo.qm mode change 100755 => 100644 translations/ukui-menu_bo.ts mode change 100755 => 100644 translations/ukui-menu_tr.qm mode change 100755 => 100644 translations/ukui-menu_tr.ts mode change 100755 => 100644 translations/ukui-menu_zh_CN.qm mode change 100755 => 100644 translations/ukui-menu_zh_CN.ts mode change 100755 => 100644 ukui-menu.desktop mode change 100755 => 100644 ukui-menu.ini mode change 100755 => 100644 ukui-menu.pro create mode 100644 ukui-menu.pro.user diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml old mode 100755 new mode 100644 diff --git a/COPYING b/COPYING old mode 100755 new mode 100644 diff --git a/NEWS b/NEWS old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/.DS_Store b/data/img/mainviewwidget/.DS_Store old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-all-2x.png b/data/img/mainviewwidget/DM-all-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-all.png b/data/img/mainviewwidget/DM-all.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-all.svg b/data/img/mainviewwidget/DM-all.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-arrow-2x.png b/data/img/mainviewwidget/DM-arrow-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-arrow.png b/data/img/mainviewwidget/DM-arrow.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-arrow.svg b/data/img/mainviewwidget/DM-arrow.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-close-2x.png b/data/img/mainviewwidget/DM-close-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-close.png b/data/img/mainviewwidget/DM-close.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-close.svg b/data/img/mainviewwidget/DM-close.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-function-2x.png b/data/img/mainviewwidget/DM-function-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-function.png b/data/img/mainviewwidget/DM-function.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-function.svg b/data/img/mainviewwidget/DM-function.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-check.png b/data/img/mainviewwidget/DM-icon-check.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-check.svg b/data/img/mainviewwidget/DM-icon-check.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-check@2x.png b/data/img/mainviewwidget/DM-icon-check@2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-选项.svg b/data/img/mainviewwidget/DM-icon-option.svg old mode 100755 new mode 100644 similarity index 100% rename from data/img/mainviewwidget/DM-icon-选项.svg rename to data/img/mainviewwidget/DM-icon-option.svg diff --git a/data/img/mainviewwidget/DM-icon-search.png b/data/img/mainviewwidget/DM-icon-search.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-search.svg b/data/img/mainviewwidget/DM-icon-search.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-search@2x.png b/data/img/mainviewwidget/DM-icon-search@2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-返回.png b/data/img/mainviewwidget/DM-icon-返回.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-返回.svg b/data/img/mainviewwidget/DM-icon-返回.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-返回@2x.png b/data/img/mainviewwidget/DM-icon-返回@2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-选项.png b/data/img/mainviewwidget/DM-icon-选项.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-icon-选项@2x.png b/data/img/mainviewwidget/DM-icon-选项@2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-letter-2x.png b/data/img/mainviewwidget/DM-letter-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-letter.png b/data/img/mainviewwidget/DM-letter.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-letter.svg b/data/img/mainviewwidget/DM-letter.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-max-2x.png b/data/img/mainviewwidget/DM-max-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-max.png b/data/img/mainviewwidget/DM-max.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/DM-max.svg b/data/img/mainviewwidget/DM-max.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Checked.svg b/data/img/mainviewwidget/Development-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Disabled.svg b/data/img/mainviewwidget/Development-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Enabled.svg b/data/img/mainviewwidget/Development-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Normal.svg b/data/img/mainviewwidget/Development-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Checked.svg b/data/img/mainviewwidget/Education-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Disabled.svg b/data/img/mainviewwidget/Education-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Enabled.svg b/data/img/mainviewwidget/Education-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Normal.svg b/data/img/mainviewwidget/Education-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Checked.svg b/data/img/mainviewwidget/Game-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Disabled.svg b/data/img/mainviewwidget/Game-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Enabled.svg b/data/img/mainviewwidget/Game-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Normal.svg b/data/img/mainviewwidget/Game-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Checked.svg b/data/img/mainviewwidget/Image-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Disabled.svg b/data/img/mainviewwidget/Image-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Enabled.svg b/data/img/mainviewwidget/Image-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Normal.svg b/data/img/mainviewwidget/Image-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Checked.svg b/data/img/mainviewwidget/Internet-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Disabled.svg b/data/img/mainviewwidget/Internet-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Enabled.svg b/data/img/mainviewwidget/Internet-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Normal.svg b/data/img/mainviewwidget/Internet-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Checked.svg b/data/img/mainviewwidget/Mobile-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Disabled.svg b/data/img/mainviewwidget/Mobile-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Enabled.svg b/data/img/mainviewwidget/Mobile-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Normal.svg b/data/img/mainviewwidget/Mobile-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Checked.svg b/data/img/mainviewwidget/Office-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Disabled.svg b/data/img/mainviewwidget/Office-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Enabled.svg b/data/img/mainviewwidget/Office-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Normal.svg b/data/img/mainviewwidget/Office-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Checked.svg b/data/img/mainviewwidget/Others-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Disabled.svg b/data/img/mainviewwidget/Others-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Enabled.svg b/data/img/mainviewwidget/Others-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Normal.svg b/data/img/mainviewwidget/Others-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Checked.svg b/data/img/mainviewwidget/Social-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Disabled.svg b/data/img/mainviewwidget/Social-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Enabled.svg b/data/img/mainviewwidget/Social-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Normal.svg b/data/img/mainviewwidget/Social-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Checked.svg b/data/img/mainviewwidget/System-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Disabled.svg b/data/img/mainviewwidget/System-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Enabled.svg b/data/img/mainviewwidget/System-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Normal.svg b/data/img/mainviewwidget/System-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Checked.svg b/data/img/mainviewwidget/Video-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Disabled.svg b/data/img/mainviewwidget/Video-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Enabled.svg b/data/img/mainviewwidget/Video-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Normal.svg b/data/img/mainviewwidget/Video-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/all-2x.png b/data/img/mainviewwidget/all-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/all.png b/data/img/mainviewwidget/all.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/all.svg b/data/img/mainviewwidget/all.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/attributeaction.svg b/data/img/mainviewwidget/attributeaction.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/close-2x.png b/data/img/mainviewwidget/close-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/close.png b/data/img/mainviewwidget/close.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/close.svg b/data/img/mainviewwidget/close.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/downarrow-pressed.svg b/data/img/mainviewwidget/downarrow-pressed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/downarrow.svg b/data/img/mainviewwidget/downarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/drop-down-2x.png b/data/img/mainviewwidget/drop-down-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/drop-down.png b/data/img/mainviewwidget/drop-down.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/drop-down.svg b/data/img/mainviewwidget/drop-down.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/fixed.svg b/data/img/mainviewwidget/fixed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-all-2x.png b/data/img/mainviewwidget/full-all-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-close-2x.png b/data/img/mainviewwidget/full-close-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-close.png b/data/img/mainviewwidget/full-close.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-close.svg b/data/img/mainviewwidget/full-close.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-drop-down-2x.png b/data/img/mainviewwidget/full-drop-down-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-drop-down.png b/data/img/mainviewwidget/full-drop-down.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-drop-down.svg b/data/img/mainviewwidget/full-drop-down.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-function-2x.png b/data/img/mainviewwidget/full-function-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-function.png b/data/img/mainviewwidget/full-function.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-function.svg b/data/img/mainviewwidget/full-function.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-letter-2x.png b/data/img/mainviewwidget/full-letter-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-letter.png b/data/img/mainviewwidget/full-letter.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-letter.svg b/data/img/mainviewwidget/full-letter.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-min-2x.png b/data/img/mainviewwidget/full-min-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-min.png b/data/img/mainviewwidget/full-min.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-min.svg b/data/img/mainviewwidget/full-min.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-search-2x.png b/data/img/mainviewwidget/full-search-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-search.png b/data/img/mainviewwidget/full-search.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/full-search.svg b/data/img/mainviewwidget/full-search.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/fullicon-all.png b/data/img/mainviewwidget/fullicon-all.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/fullicon-all.svg b/data/img/mainviewwidget/fullicon-all.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/function-2x.png b/data/img/mainviewwidget/function-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/function.png b/data/img/mainviewwidget/function.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/function.svg b/data/img/mainviewwidget/function.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- search-2x.png b/data/img/mainviewwidget/icon- search-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- search.png b/data/img/mainviewwidget/icon- search.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- search.svg b/data/img/mainviewwidget/icon- search.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- 返回.png b/data/img/mainviewwidget/icon- 返回.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- 返回.svg b/data/img/mainviewwidget/icon- 返回.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- 返回@2x.png b/data/img/mainviewwidget/icon- 返回@2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- 选项.png b/data/img/mainviewwidget/icon- 选项.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- 选项.svg b/data/img/mainviewwidget/icon- 选项.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon- 选项@2x.png b/data/img/mainviewwidget/icon- 选项@2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon-check.png b/data/img/mainviewwidget/icon-check.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon-check.svg b/data/img/mainviewwidget/icon-check.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/icon-check@2x.png b/data/img/mainviewwidget/icon-check@2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/leftarrow-hover.svg b/data/img/mainviewwidget/leftarrow-hover.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/leftarrow.svg b/data/img/mainviewwidget/leftarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/letter-2x.png b/data/img/mainviewwidget/letter-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/letter.png b/data/img/mainviewwidget/letter.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/letter.svg b/data/img/mainviewwidget/letter.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/lock-fs.svg b/data/img/mainviewwidget/lock-fs.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/lock.svg b/data/img/mainviewwidget/lock.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/max-2x.png b/data/img/mainviewwidget/max-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/max.png b/data/img/mainviewwidget/max.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/max.svg b/data/img/mainviewwidget/max.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/power-2x.png b/data/img/mainviewwidget/power-2x.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/power.png b/data/img/mainviewwidget/power.png old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/power.svg b/data/img/mainviewwidget/power.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent-disabled.svg b/data/img/mainviewwidget/recent-disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent-enabled.svg b/data/img/mainviewwidget/recent-enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent-gray.svg b/data/img/mainviewwidget/recent-gray.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent.svg b/data/img/mainviewwidget/recent.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/rightarrow-hover.svg b/data/img/mainviewwidget/rightarrow-hover.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/rightarrow.svg b/data/img/mainviewwidget/rightarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/search.svg b/data/img/mainviewwidget/search.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/select.svg b/data/img/mainviewwidget/select.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/selected.svg b/data/img/mainviewwidget/selected.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/ukui-search-blue.svg b/data/img/mainviewwidget/ukui-search-blue.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/ukui-search.svg b/data/img/mainviewwidget/ukui-search.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/unfixed.svg b/data/img/mainviewwidget/unfixed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/uninstall.svg b/data/img/mainviewwidget/uninstall.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/uparrow-pressed.svg b/data/img/mainviewwidget/uparrow-pressed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/uparrow.svg b/data/img/mainviewwidget/uparrow.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/commonuse.svg b/data/img/sidebarwidget/commonuse.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/computer.svg b/data/img/sidebarwidget/computer.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/control.svg b/data/img/sidebarwidget/control.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/fixed.svg b/data/img/sidebarwidget/fixed.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/fullusericon.png b/data/img/sidebarwidget/fullusericon.png old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/function.svg b/data/img/sidebarwidget/function.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/letter.svg b/data/img/sidebarwidget/letter.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/lock.svg b/data/img/sidebarwidget/lock.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/max.svg b/data/img/sidebarwidget/max.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/min.svg b/data/img/sidebarwidget/min.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/personal.svg b/data/img/sidebarwidget/personal.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/rightarrow.svg b/data/img/sidebarwidget/rightarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/setting.svg b/data/img/sidebarwidget/setting.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/shutdown.svg b/data/img/sidebarwidget/shutdown.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/trash.svg b/data/img/sidebarwidget/trash.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/unfixed.svg b/data/img/sidebarwidget/unfixed.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/usericon-darkcolor.svg b/data/img/sidebarwidget/usericon-darkcolor.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/usericon-lightcolor.svg b/data/img/sidebarwidget/usericon-lightcolor.svg old mode 100755 new mode 100644 diff --git a/main.cpp b/main.cpp old mode 100755 new mode 100644 diff --git a/man/ukui-menu.1 b/man/ukui-menu.1 old mode 100755 new mode 100644 diff --git a/res.qrc b/res.qrc old mode 100755 new mode 100644 index 3a10c26..47d0ea3 --- a/res.qrc +++ b/res.qrc @@ -27,7 +27,6 @@ data/img/mainviewwidget/DM-icon-返回.svg data/img/mainviewwidget/DM-icon-返回@2x.png data/img/mainviewwidget/DM-icon-选项.png - data/img/mainviewwidget/DM-icon-选项.svg data/img/mainviewwidget/DM-icon-选项@2x.png data/img/mainviewwidget/DM-icon-check.png data/img/mainviewwidget/DM-icon-check.svg @@ -171,5 +170,6 @@ data/img/sidebarwidget/usericon-lightcolor.svg src/BackProcess/Search/pinyinWithoutTone.txt src/BackProcess/Search/pinyinWithTone.txt + data/img/mainviewwidget/DM-icon-option.svg diff --git a/src/BackProcess/DBus/dbus-adaptor.cpp b/src/BackProcess/DBus/dbus-adaptor.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/DBus/dbus-adaptor.h b/src/BackProcess/DBus/dbus-adaptor.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/DBus/dbus.cpp b/src/BackProcess/DBus/dbus.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/DBus/dbus.h b/src/BackProcess/DBus/dbus.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/DBus/org.ukui.menu.xml b/src/BackProcess/DBus/org.ukui.menu.xml old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp b/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/convert_winid_to_desktop.h b/src/BackProcess/FileWatcher/convert_winid_to_desktop.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/desktop_watcher.cpp b/src/BackProcess/FileWatcher/desktop_watcher.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/desktop_watcher.h b/src/BackProcess/FileWatcher/desktop_watcher.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/directory_changed_thread.cpp b/src/BackProcess/FileWatcher/directory_changed_thread.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/directory_changed_thread.h b/src/BackProcess/FileWatcher/directory_changed_thread.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/software_database_update_thread.cpp b/src/BackProcess/FileWatcher/software_database_update_thread.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/software_database_update_thread.h b/src/BackProcess/FileWatcher/software_database_update_thread.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/Interface/currenttime_interface.cpp b/src/BackProcess/Interface/currenttime_interface.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/Interface/currenttime_interface.h b/src/BackProcess/Interface/currenttime_interface.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/Interface/ukui_chineseletter.cpp b/src/BackProcess/Interface/ukui_chineseletter.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/Interface/ukui_chineseletter.h b/src/BackProcess/Interface/ukui_chineseletter.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/Interface/ukuimenuinterface.cpp b/src/BackProcess/Interface/ukuimenuinterface.cpp old mode 100755 new mode 100644 index 50e4f9a..0f7386c --- a/src/BackProcess/Interface/ukuimenuinterface.cpp +++ b/src/BackProcess/Interface/ukuimenuinterface.cpp @@ -576,8 +576,6 @@ QVector UkuiMenuInterface::createAppInfoVector() sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName)); if (sql.next()) { - myDebug() << "数据库执行成功"; - for (int j = 0; j < vector.size(); j++) { if (vector.at(j).contains(sql.value(0).toString())) { appInfoList.append(QString::number(j)); diff --git a/src/BackProcess/Interface/ukuimenuinterface.h b/src/BackProcess/Interface/ukuimenuinterface.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/Search/file-utils.cpp b/src/BackProcess/Search/file-utils.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/Search/file-utils.h b/src/BackProcess/Search/file-utils.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/Search/pinyinWithTone.txt b/src/BackProcess/Search/pinyinWithTone.txt old mode 100755 new mode 100644 diff --git a/src/BackProcess/Search/pinyinWithoutTone.txt b/src/BackProcess/Search/pinyinWithoutTone.txt old mode 100755 new mode 100644 diff --git a/src/BackProcess/Search/searchappthread.cpp b/src/BackProcess/Search/searchappthread.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/Search/searchappthread.h b/src/BackProcess/Search/searchappthread.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/XEventMonitor/xeventmonitor.cpp b/src/BackProcess/XEventMonitor/xeventmonitor.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/XEventMonitor/xeventmonitor.h b/src/BackProcess/XEventMonitor/xeventmonitor.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/backprocess.pri b/src/BackProcess/backprocess.pri old mode 100755 new mode 100644 diff --git a/src/BackProcess/tablet/getmodeldata.cpp b/src/BackProcess/tablet/getmodeldata.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/tablet/getmodeldata.h b/src/BackProcess/tablet/getmodeldata.h old mode 100755 new mode 100644 diff --git a/src/BackProcess/tablet/pagemanager.cpp b/src/BackProcess/tablet/pagemanager.cpp old mode 100755 new mode 100644 diff --git a/src/BackProcess/tablet/pagemanager.h b/src/BackProcess/tablet/pagemanager.h old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/QtSingleApplication b/src/QtSingleApplication/QtSingleApplication old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtlocalpeer.cpp b/src/QtSingleApplication/qtlocalpeer.cpp old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtlocalpeer.h b/src/QtSingleApplication/qtlocalpeer.h old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/src/QtSingleApplication/qtlockedfile.cpp old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtlockedfile.h b/src/QtSingleApplication/qtlockedfile.h old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/src/QtSingleApplication/qtlockedfile_unix.cpp old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/src/QtSingleApplication/qtlockedfile_win.cpp old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/src/QtSingleApplication/qtsingleapplication.cpp old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsingleapplication.h b/src/QtSingleApplication/qtsingleapplication.h old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/src/QtSingleApplication/qtsingleapplication.pri old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/src/QtSingleApplication/qtsinglecoreapplication.cpp old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/src/QtSingleApplication/qtsinglecoreapplication.h old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/src/QtSingleApplication/qtsinglecoreapplication.pri old mode 100755 new mode 100644 diff --git a/src/UserInterface/Button/function_classify_button.cpp b/src/UserInterface/Button/function_classify_button.cpp old mode 100755 new mode 100644 index f9b58ef..2494be4 --- a/src/UserInterface/Button/function_classify_button.cpp +++ b/src/UserInterface/Button/function_classify_button.cpp @@ -89,8 +89,22 @@ void FunctionClassifyButton::paintEvent(QPaintEvent *e) painter.setPen(Qt::NoPen); if (!m_fullscreen) { - QColor color = option.palette.color(QPalette::Text); - color.setAlphaF(0.15); + QColor color; + + if (option.state & QStyle::State_Selected) { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#33FFFFFF"); + } else { + color.setNamedColor("#D1FFFFFF"); + } + } else { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#1AFFFFFF"); + } else { + color.setNamedColor("#8CFFFFFF"); + } + } + painter.setBrush(color); } else { painter.setOpacity(0.15); diff --git a/src/UserInterface/Button/function_classify_button.h b/src/UserInterface/Button/function_classify_button.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Button/letter_classify_button.cpp b/src/UserInterface/Button/letter_classify_button.cpp old mode 100755 new mode 100644 index 8fb9340..5bc882f --- a/src/UserInterface/Button/letter_classify_button.cpp +++ b/src/UserInterface/Button/letter_classify_button.cpp @@ -19,6 +19,7 @@ #include "letter_classify_button.h" #include #include +#include "utility.h" LetterClassifyButton::LetterClassifyButton(QWidget *parent, bool fullscreen, @@ -55,8 +56,22 @@ void LetterClassifyButton::paintEvent(QPaintEvent *e) painter.setPen(Qt::NoPen); if (!m_fullscreen) { - QColor color = option.palette.color(QPalette::Text); - color.setAlphaF(0.15); + QColor color; + + if (option.state & QStyle::State_Selected) { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#33FFFFFF"); + } else { + color.setNamedColor("#D1FFFFFF"); + } + } else { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#1AFFFFFF"); + } else { + color.setNamedColor("#8CFFFFFF"); + } + } + painter.setBrush(color); } else { painter.setOpacity(0.15); @@ -81,10 +96,13 @@ void LetterClassifyButton::paintEvent(QPaintEvent *e) QStyleOptionButton subopt = option; subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); - // if(m_fullscreen) - // subopt.palette.setBrush(QPalette::ButtonText, QColor(Qt::white)); - // else - // subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); + + if (m_fullscreen) { + subopt.palette.setBrush(QPalette::ButtonText, QColor(Qt::white)); + } else { + subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); + } + painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); return; } diff --git a/src/UserInterface/Button/letter_classify_button.h b/src/UserInterface/Button/letter_classify_button.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Button/tool_button.cpp b/src/UserInterface/Button/tool_button.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Button/tool_button.h b/src/UserInterface/Button/tool_button.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ListView/fulllistview.cpp b/src/UserInterface/ListView/fulllistview.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/ListView/fulllistview.h b/src/UserInterface/ListView/fulllistview.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ListView/klistview.cpp b/src/UserInterface/ListView/klistview.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/ListView/klistview.h b/src/UserInterface/ListView/klistview.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ListView/listview.cpp b/src/UserInterface/ListView/listview.cpp old mode 100755 new mode 100644 index 9bd82c4..b034145 --- a/src/UserInterface/ListView/listview.cpp +++ b/src/UserInterface/ListView/listview.cpp @@ -129,8 +129,14 @@ void ListView::paintEvent(QPaintEvent *e) { //滚动条 QPalette p = this->verticalScrollBar()->palette(); - QColor color(255, 255, 255); - color.setAlphaF(0.25); + QColor color; + + if (g_curStyle == "ukui-dark") { + color = QColor("#26FFFFFF"); + } else { + color = QColor("#1A000000"); + } + p.setColor(QPalette::Active, QPalette::Button, color); this->verticalScrollBar()->setPalette(p); QListView::paintEvent(e); diff --git a/src/UserInterface/ListView/listview.h b/src/UserInterface/ListView/listview.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ListView/rightlistview.cpp b/src/UserInterface/ListView/rightlistview.cpp old mode 100755 new mode 100644 index a70a58f..e8dec33 --- a/src/UserInterface/ListView/rightlistview.cpp +++ b/src/UserInterface/ListView/rightlistview.cpp @@ -39,7 +39,9 @@ RightListView::~RightListView() void RightListView::initWidget() { + setAttribute(Qt::WA_TranslucentBackground); viewport()->setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAutoFillBackground(false); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -62,10 +64,10 @@ void RightListView::dropEvent(QDropEvent *event) RightListView *source = qobject_cast(event->source()); if (source && source == this) { - dropPos = event->pos(); + m_dropPos = event->pos(); - if (this->indexAt(dropPos).isValid()) { - QVariant var = listmodel->data(indexAt(dropPos), Qt::DisplayRole); + if (this->indexAt(m_dropPos).isValid()) { + QVariant var = listmodel->data(indexAt(m_dropPos), Qt::DisplayRole); QString desktopfp = var.value(); QFileInfo fileInfo(desktopfp); QString desktopfn = fileInfo.fileName(); @@ -88,6 +90,11 @@ void RightListView::selectFirstItem() } } +void RightListView::paintEvent(QPaintEvent *e) +{ + QListView::paintEvent(e); +} + void RightListView::keyPressEvent(QKeyEvent *e) { if (e->type() == QEvent::KeyPress) { @@ -106,6 +113,11 @@ void RightListView::keyPressEvent(QKeyEvent *e) } } +void RightListView::changeStyleColor(const QColor &color) +{ + m_styleColor = color; +} + void RightListView::enterEvent(QEvent *e) { Q_UNUSED(e); diff --git a/src/UserInterface/ListView/rightlistview.h b/src/UserInterface/ListView/rightlistview.h old mode 100755 new mode 100644 index e85e07c..c75e0cc --- a/src/UserInterface/ListView/rightlistview.h +++ b/src/UserInterface/ListView/rightlistview.h @@ -26,12 +26,14 @@ protected: void keyPressEvent(QKeyEvent *e); void dropEvent(QDropEvent *event); void enterEvent(QEvent *e); + void paintEvent(QPaintEvent *e); private: RightClickMenu *menu = nullptr; //右键菜单 QStringList data; QGSettings *gsetting; - QPoint dropPos; + QPoint m_dropPos; + QColor m_styleColor; // bool inCurView; @@ -39,6 +41,7 @@ public Q_SLOTS: // void rightClickedSlot(const QPoint &pos);//右键菜单 void selectFirstItem(); + void changeStyleColor(const QColor &color); Q_SIGNALS: diff --git a/src/UserInterface/ListView/tabletlistview.cpp b/src/UserInterface/ListView/tabletlistview.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/ListView/tabletlistview.h b/src/UserInterface/ListView/tabletlistview.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Other/classify_btn_scrollarea.cpp b/src/UserInterface/Other/classify_btn_scrollarea.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Other/classify_btn_scrollarea.h b/src/UserInterface/Other/classify_btn_scrollarea.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Other/lettertooltip.cpp b/src/UserInterface/Other/lettertooltip.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Other/lettertooltip.h b/src/UserInterface/Other/lettertooltip.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Other/scrollarea.cpp b/src/UserInterface/Other/scrollarea.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Other/scrollarea.h b/src/UserInterface/Other/scrollarea.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/RightClickMenu/menubox.cpp b/src/UserInterface/RightClickMenu/menubox.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/RightClickMenu/menubox.h b/src/UserInterface/RightClickMenu/menubox.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/RightClickMenu/rightclickmenu.cpp b/src/UserInterface/RightClickMenu/rightclickmenu.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/RightClickMenu/rightclickmenu.h b/src/UserInterface/RightClickMenu/rightclickmenu.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp b/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/RightClickMenu/tabletrightclickmenu.h b/src/UserInterface/RightClickMenu/tabletrightclickmenu.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/full_item_delegate.cpp b/src/UserInterface/ViewItem/full_item_delegate.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/full_item_delegate.h b/src/UserInterface/ViewItem/full_item_delegate.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/itemdelegate.cpp b/src/UserInterface/ViewItem/itemdelegate.cpp old mode 100755 new mode 100644 index 69f6631..aa7f169 --- a/src/UserInterface/ViewItem/itemdelegate.cpp +++ b/src/UserInterface/ViewItem/itemdelegate.cpp @@ -20,7 +20,7 @@ #include #include #include -#include "src/UtilityFunction/utility.h" +#include "utility.h" ItemDelegate::ItemDelegate(QObject *parent, int module): KItemDelegate(parent) @@ -58,8 +58,22 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->setRenderHint(QPainter::Antialiasing); if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - QColor color = option.palette.text().color(); - color.setAlphaF(0.15); + QColor color; + + if (option.state & QStyle::State_Selected) { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#33FFFFFF"); + } else { + color.setNamedColor("#D1FFFFFF"); + } + } else { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#1AFFFFFF"); + } else { + color.setNamedColor("#8CFFFFFF"); + } + } + painter->save(); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(color); @@ -153,10 +167,13 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, // QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); QRect textRect = QRect(rect.x() + 11, rect.y(), rect.width(), rect.height()); painter->drawText(textRect, Qt::AlignVCenter, strlist.at(0)); - painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(QPen(QColor(option.palette.text().color()), 1)); - painter->setOpacity(0.1); - painter->drawLine(QPoint(5, rect.bottom()), QPoint(rect.right(), rect.bottom())); + painter->setRenderHints(QPainter::SmoothPixmapTransform, true); + QPixmap pixmap = getCurIcon(":/data/img/mainviewwidget/DM-icon-option.svg", true).pixmap(QSize(16, 16)); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + painter->drawPixmap(rect.width() - 25, rect.y() + 15, pixmap); + } + painter->restore(); } } else if (module == -1) { @@ -279,7 +296,7 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, QString desktopfn = fileInfo.fileName(); if (checkIfLocked(desktopfn)) { - QIcon icon(QString(":/data/img/mainviewwidget/lock.svg")); + QIcon icon = getCurIcon(":/data/img/mainviewwidget/lock.svg", true); icon.paint(painter, QRect(rect.topRight().x() - 22, rect.y() + (rect.height() - 16) / 2, 16, 16)); } diff --git a/src/UserInterface/ViewItem/itemdelegate.h b/src/UserInterface/ViewItem/itemdelegate.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/kitemdelegate.cpp b/src/UserInterface/ViewItem/kitemdelegate.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/kitemdelegate.h b/src/UserInterface/ViewItem/kitemdelegate.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/recent_item_delegate.cpp b/src/UserInterface/ViewItem/recent_item_delegate.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/recent_item_delegate.h b/src/UserInterface/ViewItem/recent_item_delegate.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/right_item_delegate.cpp b/src/UserInterface/ViewItem/right_item_delegate.cpp old mode 100755 new mode 100644 index c463c4a..a67a6ca --- a/src/UserInterface/ViewItem/right_item_delegate.cpp +++ b/src/UserInterface/ViewItem/right_item_delegate.cpp @@ -1,5 +1,5 @@ #include "right_item_delegate.h" -#include "src/UtilityFunction/utility.h" +#include "utility.h" #include RightItemDelegate::RightItemDelegate(QObject *parent): @@ -37,16 +37,27 @@ void RightItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt painter->setRenderHint(QPainter::Antialiasing); painter->save(); painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(option.palette.base().color()); if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { if (option.state & QStyle::State_Selected) { - painter->setOpacity(0.8); + if (g_curStyle == "ukui-dark") { + painter->setBrush(QColor("#7A000000")); + } else { + painter->setBrush(QColor("#BFFFFFFF")); + } } else { - painter->setOpacity(0.6); + if (g_curStyle == "ukui-dark") { + painter->setBrush(QColor("#66000000")); + } else { + painter->setBrush(QColor("#99FFFFFF")); + } } } else { - painter->setOpacity(0.4); + if (g_curStyle == "ukui-dark") { + painter->setBrush(QColor("#40000000")); + } else { + painter->setBrush(QColor("#66FFFFFF")); + } } painter->drawPath(path); diff --git a/src/UserInterface/ViewItem/right_item_delegate.h b/src/UserInterface/ViewItem/right_item_delegate.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp b/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/ViewItem/tablet_full_itemdelegate.h b/src/UserInterface/ViewItem/tablet_full_itemdelegate.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/animationpage.cpp b/src/UserInterface/Widget/animationpage.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/animationpage.h b/src/UserInterface/Widget/animationpage.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_commonuse_widget.cpp b/src/UserInterface/Widget/full_commonuse_widget.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_commonuse_widget.h b/src/UserInterface/Widget/full_commonuse_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_function_widget.cpp b/src/UserInterface/Widget/full_function_widget.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_function_widget.h b/src/UserInterface/Widget/full_function_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_letter_widget.cpp b/src/UserInterface/Widget/full_letter_widget.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_letter_widget.h b/src/UserInterface/Widget/full_letter_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_searchresult_widget.cpp b/src/UserInterface/Widget/full_searchresult_widget.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/full_searchresult_widget.h b/src/UserInterface/Widget/full_searchresult_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/function_Widget.cpp b/src/UserInterface/Widget/function_Widget.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/function_Widget.h b/src/UserInterface/Widget/function_Widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/function_button_widget.cpp b/src/UserInterface/Widget/function_button_widget.cpp old mode 100755 new mode 100644 index f23f976..cd7b8f8 --- a/src/UserInterface/Widget/function_button_widget.cpp +++ b/src/UserInterface/Widget/function_button_widget.cpp @@ -48,9 +48,8 @@ void FunctionButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground, true); - this->resize(Style::LeftBtnWidth * 2 + 5, Style::LeftBtnHeight * 6 + 25); QGridLayout *gridLayout = new QGridLayout; - gridLayout->setContentsMargins(0, 0, 0, 0); + gridLayout->setContentsMargins(40, 80, 40, 80); gridLayout->setSpacing(5); this->setLayout(gridLayout); diff --git a/src/UserInterface/Widget/function_button_widget.h b/src/UserInterface/Widget/function_button_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/letter_button_widget.cpp b/src/UserInterface/Widget/letter_button_widget.cpp old mode 100755 new mode 100644 index f68a685..68e3a74 --- a/src/UserInterface/Widget/letter_button_widget.cpp +++ b/src/UserInterface/Widget/letter_button_widget.cpp @@ -35,9 +35,8 @@ void LetterButtonWidget::initUi() this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground, true); this->setFocusPolicy(Qt::NoFocus); - this->resize(235, 366); QGridLayout *gridLayout = new QGridLayout; - gridLayout->setContentsMargins(0, 0, 0, 0); + gridLayout->setContentsMargins(35, 80, 35, 80); gridLayout->setSpacing(5); this->setLayout(gridLayout); QStringList letterlist; @@ -51,13 +50,13 @@ void LetterButtonWidget::initUi() letterlist.append("&&"); letterlist.append("#"); - for (int row = 0; row < 7; row++) { - for (int col = 0; col < 4; col++) { - if (row * 4 + col < letterlist.size()) { - LetterClassifyButton *btn = new LetterClassifyButton(this, false, letterlist.at(row * 4 + col)); + for (int row = 0; row < 6; row++) { + for (int col = 0; col < 5; col++) { + if (row * 5 + col < letterlist.size()) { + LetterClassifyButton *btn = new LetterClassifyButton(this, false, letterlist.at(row * 5 + col)); btn->setFlat(true); btn->setCheckable(false); - btn->setFixedSize(55, 48); + btn->setFixedSize(38, 38); gridLayout->addWidget(btn, row, col); connect(btn, &LetterClassifyButton::buttonClicked, this, &LetterButtonWidget::letterBtnClickedSlot); } else { diff --git a/src/UserInterface/Widget/letter_button_widget.h b/src/UserInterface/Widget/letter_button_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/main_view_widget.cpp b/src/UserInterface/Widget/main_view_widget.cpp old mode 100755 new mode 100644 index 4cf9778..8a883d8 --- a/src/UserInterface/Widget/main_view_widget.cpp +++ b/src/UserInterface/Widget/main_view_widget.cpp @@ -42,9 +42,20 @@ MainViewWidget::~MainViewWidget() { } +void MainViewWidget::styleChangeSlot(const QString &style) +{ + m_curStyle = style; + + if (style == "ukui-dark") { + m_backColor.setNamedColor("#800D0D0D"); + } else { + m_backColor.setNamedColor("#94FFFFFF"); + } +} + void MainViewWidget::paintEvent(QPaintEvent *event) { - double transparency = getTransparency(); +// double transparency = getTransparency(); QRect rect = this->rect(); QPainterPath path; QPainter painter(this); @@ -60,11 +71,8 @@ void MainViewWidget::paintEvent(QPaintEvent *event) path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter.setBrush(this->palette().base()); painter.setPen(Qt::transparent); - painter.setOpacity(transparency + 0.1); - painter.fillPath(path, this->palette().base()); - // setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - // KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); + painter.setOpacity(0.58); + painter.fillPath(path, m_backColor); QWidget::paintEvent(event); } diff --git a/src/UserInterface/Widget/main_view_widget.h b/src/UserInterface/Widget/main_view_widget.h old mode 100755 new mode 100644 index 6926777..ebebf5a --- a/src/UserInterface/Widget/main_view_widget.h +++ b/src/UserInterface/Widget/main_view_widget.h @@ -55,12 +55,16 @@ protected: void paintEvent(QPaintEvent *event); public Q_SLOTS: + void styleChangeSlot(const QString &style); Q_SIGNALS: void directoryChangedSignal(); void sendDirectoryPath(); +private: + QString m_curStyle; + QColor m_backColor; }; #endif // MAINVIEWWIDGET_H diff --git a/src/UserInterface/Widget/plugin_widget.cpp b/src/UserInterface/Widget/plugin_widget.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/plugin_widget.h b/src/UserInterface/Widget/plugin_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/splitbar_frame.cpp b/src/UserInterface/Widget/splitbar_frame.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/splitbar_frame.h b/src/UserInterface/Widget/splitbar_frame.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/tabview_widget.cpp b/src/UserInterface/Widget/tabview_widget.cpp old mode 100755 new mode 100644 diff --git a/src/UserInterface/Widget/tabview_widget.h b/src/UserInterface/Widget/tabview_widget.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/full_mainwindow.cpp b/src/UserInterface/full_mainwindow.cpp old mode 100755 new mode 100644 index 9b37d38..5cf9707 --- a/src/UserInterface/full_mainwindow.cpp +++ b/src/UserInterface/full_mainwindow.cpp @@ -41,7 +41,7 @@ FullMainWindow::FullMainWindow(QWidget *parent) : queryWidLayout->setSpacing(5); m_queryWid->setLayout(queryWidLayout); char style[200]; - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/full-search.svg"), 16); if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { QGSettings *gsetting = new QGSettings("org.ukui.style", QByteArray(), this); diff --git a/src/UserInterface/full_mainwindow.h b/src/UserInterface/full_mainwindow.h old mode 100755 new mode 100644 diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp old mode 100755 new mode 100644 index 8d7f369..7060f62 --- a/src/UserInterface/mainwindow.cpp +++ b/src/UserInterface/mainwindow.cpp @@ -50,18 +50,18 @@ MainWindow::MainWindow(QWidget *parent) : m_viewWidget = new MainViewWidget(m_centralwidget); m_mainLeftVerticalLayout = new QVBoxLayout(m_viewWidget); m_mainLeftVerticalLayout->setSpacing(0); - m_mainLeftVerticalLayout->setContentsMargins(8, 8, 0, 0); + m_mainLeftVerticalLayout->setContentsMargins(8, 4, 0, 0); //搜索框部分 m_topStackedWidget = new QStackedWidget(m_viewWidget); m_topStackedWidget->setFixedHeight(48); //搜索框收起页 m_minMenuPage = new QWidget(); - m_minMenuPage->setMinimumSize(QSize(0, 48)); + m_minMenuPage->setMinimumSize(QSize(0, 40)); m_letfTopSelectHorizontalLayout = new QHBoxLayout(m_minMenuPage); - m_letfTopSelectHorizontalLayout->setSpacing(8); - m_letfTopSelectHorizontalLayout->setContentsMargins(8, 0, 8, 12); + m_letfTopSelectHorizontalLayout->setSpacing(2); + m_letfTopSelectHorizontalLayout->setContentsMargins(8, 0, 4, 12); m_minSelectTextLabel = new QLabel(m_minMenuPage); - m_horizontalSpacer = new QSpacerItem(68, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_horizontalSpacer = new QSpacerItem(58, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); m_searchPushButton = new QPushButton(m_minMenuPage); // m_searchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); m_searchPushButton->setFixedSize(QSize(26, 26)); @@ -71,20 +71,21 @@ MainWindow::MainWindow(QWidget *parent) : m_minSelectButton->setFixedSize(QSize(26, 26)); m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-all.svg", true)); m_minSelectButton->installEventFilter(this); - m_selectMenuButton = new QToolButton(m_minMenuPage); + m_selectMenuButton = new QLabel(m_minMenuPage); + m_selectMenuButton->installEventFilter(this); m_selectMenuButton->setStyleSheet("background: transparent;"); m_selectMenuButton->setFixedSize(QSize(16, 26)); m_selectMenuButton->setAcceptDrops(true); - m_selectMenuButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-arrow.svg", true)); - m_selectMenuButton->setPopupMode(QToolButton::InstantPopup); -// m_selectMenuButton->setStyleSheet(QString::fromUtf8("QToolButton::menu-indicator { image: None; }")); + m_selectMenuButton->setFocusPolicy(Qt::StrongFocus); + m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true) + .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); //搜索框展开页 m_minSearchPage = new QWidget(); m_leftTopSearchHorizontalLayout = new QHBoxLayout(m_minSearchPage); m_leftTopSearchHorizontalLayout->setContentsMargins(8, 0, 8, 12); m_lineEdit = new QLineEdit(m_minSearchPage); m_lineEdit->setMinimumSize(QSize(30, 26)); - m_lineEdit->setStyleSheet(QString::fromUtf8("border-radius: 13px; border:2px solid rgba(5, 151, 255, 1); background: transparent;")); + m_lineEdit->setStyleSheet(QString::fromUtf8("border-radius: 13px; border:1px solid rgba(5, 151, 255, 1); background: transparent;")); m_lineEdit->setFrame(false); m_lineEdit->setPlaceholderText(tr("Search")); m_cancelSearchPushButton = new QPushButton(m_minSearchPage); @@ -127,19 +128,21 @@ MainWindow::MainWindow(QWidget *parent) : //右侧窗口 m_mainRightVerticalLayout = new QVBoxLayout(); m_mainRightVerticalLayout->setSpacing(0); - m_mainRightVerticalLayout->setContentsMargins(8, 8, 8, 8); + m_mainRightVerticalLayout->setContentsMargins(8, 4, 8, 8); m_mainRightVerticalLayout_1 = new QVBoxLayout(); m_rightTopHorizontalLayout = new QHBoxLayout(); m_rightTopHorizontalLayout->setSpacing(30); - m_rightTopHorizontalLayout->setContentsMargins(8, 0, 10, 0); + m_rightTopHorizontalLayout->setContentsMargins(8, 0, 10, 8); //收藏按键 m_collectPushButton = new QLabel(m_centralwidget); + m_collectPushButton->setFocusPolicy(Qt::StrongFocus); m_collectPushButton->setFixedHeight(34); // m_collectPushButton->setFlat(true); m_collectPushButton->installEventFilter(this); //最近按键 m_recentPushButton = new QLabel(m_centralwidget); m_recentPushButton->setFixedHeight(34); + m_recentPushButton->setFocusPolicy(Qt::StrongFocus); // m_recentPushButton->setFlat(true); m_recentPushButton->installEventFilter(this); m_horizontalSpacer_3 = new QSpacerItem(332, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -190,15 +193,18 @@ MainWindow::MainWindow(QWidget *parent) : m_rightBottomHorizontalLayout->setSizeConstraint(QLayout::SetDefaultConstraint); m_rightBottomHorizontalLayout->setContentsMargins(0, 0, 8, 0); m_horizontalSpacer_2 = new QSpacerItem(332, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_horizontalSpacer_4 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Minimum); m_powerOffButton = new QPushButton(m_centralwidget); - m_powerOffButton->setFixedSize(QSize(24, 24)); + m_powerOffButton->setFixedSize(QSize(32, 32)); m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); m_powerOffButton->setIcon(QIcon(":/data/img/mainviewwidget/power.svg")); + m_powerOffButton->setIconSize(QSize(24, 24)); m_powerOffButton->setFlat(true); m_powerOffButton->installEventFilter(this); m_letfTopSelectHorizontalLayout->addWidget(m_minSelectTextLabel); m_letfTopSelectHorizontalLayout->addItem(m_horizontalSpacer); m_letfTopSelectHorizontalLayout->addWidget(m_searchPushButton); + m_letfTopSelectHorizontalLayout->addItem(m_horizontalSpacer_4); m_letfTopSelectHorizontalLayout->addWidget(m_minSelectButton); m_letfTopSelectHorizontalLayout->addWidget(m_selectMenuButton); m_leftTopSearchHorizontalLayout->addWidget(m_lineEdit); @@ -330,8 +336,9 @@ MainWindow::MainWindow(QWidget *parent) : } } }); - m_maxAnimation = new QPropertyAnimation(&m_animationPage, "geometry"); - m_minAnimation = new QPropertyAnimation(&m_animationPage, "geometry"); + m_animationPage = new AnimationPage(); + m_maxAnimation = new QPropertyAnimation(m_animationPage, "geometry", this); + m_minAnimation = new QPropertyAnimation(m_animationPage, "geometry", this); connect(m_maxAnimation, &QPropertyAnimation::finished, this, &MainWindow::maxAnimationFinished); connect(m_minAnimation, &QPropertyAnimation::finished, this, &MainWindow::minAnimationFinished); connect(m_lineEdit, &QLineEdit::textChanged, this, &MainWindow::searchAppSlot); @@ -340,11 +347,13 @@ MainWindow::MainWindow(QWidget *parent) : connect(m_fullWindow, &FullMainWindow::showNormalWindow, this, &MainWindow::showNormalWindowSlot); connect(m_fullWindow, &FullMainWindow::sendUpdateOtherView, this, &MainWindow::updateMinAllView); connect(m_minSelectButton, &QToolButton::clicked, this, &MainWindow::on_minSelectButton_clicked); - connect(m_selectMenuButton, &QToolButton::triggered, this, &MainWindow::on_selectMenuButton_triggered); + connect(m_dropDownMenu, &MenuBox::triggered, this, &MainWindow::on_selectMenuButton_triggered); + connect(m_dropDownMenu, &MenuBox::sendMainWinActiveSignal, [ = ]() { + m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true) + .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); + }); connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &MainWindow::on_powerOffButton_customContextMenuRequested); connect(m_powerOffButton, &QPushButton::clicked, this, &MainWindow::on_powerOffButton_clicked); -// connect(m_collectPushButton, &QPushButton::clicked, this, &MainWindow::on_collectPushButton_clicked); -// connect(m_recentPushButton, &QPushButton::clicked, this, &MainWindow::on_recentPushButton_clicked); connect(m_cancelSearchPushButton, &QPushButton::clicked, this, &MainWindow::on_cancelSearchPushButton_clicked); connect(m_searchPushButton, &QPushButton::clicked, this, &MainWindow::on_searchPushButton_clicked); connect(m_minMaxChangeButton, &QPushButton::clicked, this, &MainWindow::on_minMaxChangeButton_clicked); @@ -399,6 +408,11 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { closeDataBase("MainThread"); + + if (m_animationPage != nullptr) { + delete m_animationPage; + m_animationPage = nullptr; + } } void MainWindow::initUi() @@ -414,21 +428,21 @@ void MainWindow::initUi() m_minLetterListView->addData(m_modaldata->getMinLetterData(), 2); m_collectListView->addData(m_modaldata->getcollectData()); m_recentListView->addData(m_modaldata->getRecentData(), -1); - QMenu *m_menu = new QMenu; - m_allAction = new QAction(m_menu); - m_letterAction = new QAction(m_menu); - m_funcAction = new QAction(m_menu); + m_dropDownMenu = new MenuBox(this); + m_dropDownMenu->setFixedSize(Style::DropMenuWidth, Style::DropMenuHeight); + m_allAction = new QAction(m_dropDownMenu); + m_letterAction = new QAction(m_dropDownMenu); + m_funcAction = new QAction(m_dropDownMenu); m_allAction->setText(tr("All")); m_allAction->setCheckable(true); m_letterAction->setText(tr("Letter")); m_letterAction->setCheckable(true); m_funcAction->setText(tr("Function")); m_funcAction->setCheckable(true); - m_menu->addAction(m_allAction); - m_menu->addAction(m_letterAction); - m_menu->addAction(m_funcAction); + m_dropDownMenu->addAction(m_allAction); + m_dropDownMenu->addAction(m_letterAction); + m_dropDownMenu->addAction(m_funcAction); m_allAction->setChecked(true); - m_selectMenuButton->setMenu(m_menu); m_collectPushButton->setStyleSheet("color:#3790FA;"); // m_collectPushButton->setStyleSheet("border: 1px solid red;"); QColor textColor = this->palette().color(QPalette::Text); @@ -450,6 +464,7 @@ void MainWindow::initUi() connect(m_collectListView, &RightListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); connect(m_desktopWatcher, &DesktopWatcher::directoryChangedSignal, this, &MainWindow::updateView); connect(m_desktopWatcher, &DesktopWatcher::updateRecentList, this, &MainWindow::updateRecentView); + connect(this, &MainWindow::sendStyleChangeSignal, m_viewWidget, &MainViewWidget::styleChangeSlot); changeStyle(); } @@ -467,10 +482,17 @@ void MainWindow::changeStyle() if (gsetting.keys().contains(QString("styleName"))) { if (gsetting.get("style-name").toString() == "ukui-light" || gsetting.get("style-name").toString() == "ukui-default") { + g_curStyle = "ukui-light"; buttonColorDefault = "rgba(16, 23, 29, 0.06)"; buttonColorHover = "rgba(16, 23, 29, 0.12)"; buttonColorPress = "rgba(16, 23, 29, 0.17)"; + m_windowColor.setNamedColor("#C7E9EEF2"); + Q_EMIT sendStyleChangeSignal("ukui-light"); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius:16px; background: rgba(255, 255, 255, 0.4);}" + "QPushButton:pressed {border-radius:16px; background: rgba(255, 255, 255, 0.65);}"); } else { + g_curStyle = "ukui-dark"; buttonColor = linePe.color(QPalette::Light); QRgb rgbDefault = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 25); buttonColorDefault = "#" + QString::number(rgbDefault, 16); @@ -478,6 +500,11 @@ void MainWindow::changeStyle() buttonColorHover = "#" + QString::number(rgbHover, 16); QRgb rgbPress = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 75); buttonColorPress = "#" + QString::number(rgbPress, 16); + m_windowColor.setNamedColor("#FF383838"); + Q_EMIT sendStyleChangeSignal("ukui-dark"); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius:16px; background: rgba(255, 255, 255, 0.12);}" + "QPushButton:pressed {border-radius:16px; background: rgba(255, 255, 255, 0.25);}"); } } } @@ -488,10 +515,7 @@ void MainWindow::changeStyle() m_searchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); m_minSelectButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); m_cancelSearchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); - m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" - "QPushButton:hover {border-radius:12px; background: rgba(255, 255, 255, 0.2);}" - "QPushButton:pressed {border-radius:12px; background: rgba(255, 255, 255, 0.3);}"); - m_searchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/search.svg", true)); + m_searchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/full-search.svg", true)); QAction *lineAction = m_lineEdit->actions().at(0); if (lineAction != nullptr) { @@ -501,7 +525,7 @@ void MainWindow::changeStyle() } QAction *action = new QAction(); - action->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-icon-search.svg", true)); + action->setIcon(getCurIcon(":/data/img/mainviewwidget/full-search.svg", true)); m_lineEdit->addAction(action, QLineEdit::LeadingPosition); m_cancelSearchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-close-2x.png", true)); @@ -533,7 +557,7 @@ void MainWindow::paintEvent(QPaintEvent *event) path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter.setBrush(this->palette().base()); + painter.setBrush(m_windowColor); painter.setPen(Qt::transparent); painter.setOpacity(transparency); painter.drawPath(path); @@ -581,7 +605,7 @@ bool MainWindow::event(QEvent *event) if (m_minSelectButton->hasFocus()) { m_minSelectButton->click(); } else if (m_selectMenuButton->hasFocus()) { - m_selectMenuButton->click(); + QApplication::postEvent(m_selectMenuButton, new QEvent(QEvent::MouseButtonPress)); } if (m_lineEdit->hasFocus()) { @@ -611,7 +635,7 @@ void MainWindow::minAnimationFinished() QEventLoop loop; QTimer::singleShot(100, &loop, SLOT(quit())); loop.exec(); - m_animationPage.hide(); + m_animationPage->hide(); } void MainWindow::maxAnimationFinished() { @@ -621,7 +645,7 @@ void MainWindow::maxAnimationFinished() QEventLoop loop; QTimer::singleShot(100, &loop, SLOT(quit())); loop.exec(); - m_animationPage.hide(); + m_animationPage->hide(); } void MainWindow::resetLetterPage() { @@ -745,6 +769,13 @@ bool MainWindow::eventFilter(QObject *target, QEvent *event) on_collectPushButton_clicked(); return false; } + + if (target == m_selectMenuButton) { + m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/uparrow.svg", true) + .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); + m_dropDownMenu->raise(); + m_dropDownMenu->exec(this->mapToGlobal(QPoint(m_selectMenuButton->x() - 105, m_selectMenuButton->y() + 50))); + } } if (event->type() == QEvent::KeyPress) { @@ -929,13 +960,12 @@ void MainWindow::searchAppSlot(QString arg) } void MainWindow::on_selectMenuButton_triggered(QAction *arg1) { - qDebug() << "void MainWindow::on_selectMenuButton_triggered(QAction *arg1)" << m_allAction << arg1; + m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true).pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); if (arg1 == m_allAction) { m_leftStackedWidget->setCurrentIndex(0); m_state = 0; m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-all.svg", true)); -// m_minSelectButton->setIcon(QIcon(":/data/img/mainviewwidget/DM-all.svg")); m_minSelectTextLabel->setText(tr("All")); m_allAction->setChecked(true); m_letterAction->setChecked(false); @@ -1026,10 +1056,10 @@ void MainWindow::on_minMaxChangeButton_clicked() { m_canHide = true; m_isFullScreen = true; - m_animationPage.setGeometry(this->x(), this->y(), Style::minw, Style::minh); - m_animationPage.show(); - m_animationPage.raise(); - m_animationPage.repaint(); + m_animationPage->setGeometry(this->x(), this->y(), Style::minw, Style::minh); + m_animationPage->show(); + m_animationPage->raise(); + m_animationPage->repaint(); QEventLoop loop; QTimer::singleShot(100, &loop, SLOT(quit())); loop.exec(); @@ -1095,10 +1125,10 @@ void MainWindow::repaintWidget() void MainWindow::showNormalWindowSlot() { myDebug() << "Style::m_availableScreenWidth" << Style::m_availableScreenWidth << "Style::m_availableScreenHeight" << Style::m_availableScreenHeight; - m_animationPage.setGeometry(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight); - m_animationPage.show(); - m_animationPage.raise(); - myDebug() << m_animationPage.rect(); + m_animationPage->setGeometry(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight); + m_animationPage->show(); + m_animationPage->raise(); + myDebug() << m_animationPage->rect(); QEventLoop loop; QTimer::singleShot(100, &loop, SLOT(quit())); loop.exec(); diff --git a/src/UserInterface/mainwindow.h b/src/UserInterface/mainwindow.h old mode 100755 new mode 100644 index b551565..4e55abb --- a/src/UserInterface/mainwindow.h +++ b/src/UserInterface/mainwindow.h @@ -106,6 +106,7 @@ Q_SIGNALS: void sendClassificationbtnList(); void sendLetterClassificationList(QStringList list); void sendSetFullWindowItemHide(bool flag); + void sendStyleChangeSignal(QString style); public Q_SLOTS: void updateCollectView(); @@ -160,7 +161,7 @@ private: QSpacerItem *m_horizontalSpacer = nullptr; QPushButton *m_searchPushButton = nullptr; QPushButton *m_minSelectButton = nullptr; - QToolButton *m_selectMenuButton = nullptr; + QLabel *m_selectMenuButton = nullptr; QWidget *m_minSearchPage = nullptr; QHBoxLayout *m_leftTopSearchHorizontalLayout = nullptr; QLineEdit *m_lineEdit = nullptr; @@ -192,8 +193,10 @@ private: QSpacerItem *m_verticalSpacer_2 = nullptr; QHBoxLayout *m_rightBottomHorizontalLayout = nullptr; QSpacerItem *m_horizontalSpacer_2 = nullptr; + QSpacerItem *m_horizontalSpacer_4 = nullptr; QPushButton *m_powerOffButton = nullptr; - AnimationPage m_animationPage; + AnimationPage *m_animationPage = nullptr; + MenuBox *m_dropDownMenu = nullptr; bool m_canHide = true; bool m_isFullScreen = false; @@ -218,6 +221,7 @@ private: FunctionButtonWidget *m_functionBtnWid = nullptr; LetterButtonWidget *m_letterBtnWid = nullptr; SoftwareDatabaseUpdateThread *m_softwareDbThread = nullptr; + QColor m_windowColor; }; #endif // MAINWINDOW_H diff --git a/src/UserInterface/tabletwindow.cpp b/src/UserInterface/tabletwindow.cpp old mode 100755 new mode 100644 index 45f3152..aaaab25 --- a/src/UserInterface/tabletwindow.cpp +++ b/src/UserInterface/tabletwindow.cpp @@ -98,28 +98,6 @@ void TabletWindow::initUi() initStatusManager(); initTransparency(); registDbusService(); - /*//备用待窗管修改后启用 - connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { - if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) - { - QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); - if (gsetting.keys().contains("winKeyRelease")) { - if (gsetting.get(QString("winKeyRelease")).toBool()) { - return; - } - } - } - if (QApplication::activeWindow() == this) - { - myDebug() << "win键触发窗口隐藏事件"; - this->hide(); - } else - { - myDebug() << "win键触发窗口显示事件"; - this->showPCMenu(); - } - }); - */ ways(); buttonWidgetShow(); connect(m_leftWidget, &FunctionWidget::hideTabletWindow, this, &TabletWindow::recvHideMainWindowSlot); @@ -232,15 +210,13 @@ void TabletWindow::setBackground() void TabletWindow::registDbusService() { - m_dbus = new DBus; - new MenuAdaptor(m_dbus); - QDBusConnection con = QDBusConnection::sessionBus(); - - if (!con.registerService("org.ukui.menu") || - !con.registerObject("/org/ukui/menu", m_dbus)) { - qDebug() << "error:" << con.lastError().message(); - } - +// m_dbus = new DBus; +// new MenuAdaptor(m_dbus); +// QDBusConnection con = QDBusConnection::sessionBus(); +// if (!con.registerService("org.ukui.menu") || +// !con.registerObject("/org/ukui/menu", m_dbus)) { +// qDebug() << "error:" << con.lastError().message(); +// } // connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { // if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) // { @@ -261,21 +237,6 @@ void TabletWindow::registDbusService() // this->showPCMenu(); // } // }); - ways(); - buttonWidgetShow(); -// connect(this,&TabletWindow::pagenumchanged,this,&TabletWindow::pageNumberChanged); - connect(m_leftWidget, &FunctionWidget::hideTabletWindow, this, &TabletWindow::recvHideMainWindowSlot); - - if (checkapplist()) { - directoryChangedSlot();//更新应用列表 - } - - //pc下鼠标功能 - XEventMonitor::instance()->start(); - connect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), - this, SLOT(XkbEventsRelease(QString))); - connect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), - this, SLOT(XkbEventsPress(QString))); } bool TabletWindow::checkapplist() @@ -413,6 +374,8 @@ void TabletWindow::showPCMenu() this->raise(); this->activateWindow(); g_menuStatus = true; + menuStatusChange(); + myDebug() << "showMenu显示开始菜单"; } //改变搜索框及工具栏透明度 @@ -560,9 +523,10 @@ bool TabletWindow::event(QEvent *event) //if(QEvent::WindowDeactivate == event->type())//窗口停用 { if (QApplication::activeWindow() != this) { - qDebug() << " * 鼠标点击窗口外部事件"; + myDebug() << " * 鼠标点击窗口外部事件"; this->hide(); g_menuStatus = false; + menuStatusChange(); } } @@ -576,6 +540,7 @@ bool TabletWindow::event(QEvent *event) if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { this->hide(); g_menuStatus = false; + myDebug() << "鼠标点击事件触发隐藏"; } } @@ -674,19 +639,17 @@ void TabletWindow::execApplication(QString desktopfp) return; } - QString exe = execnamestr; + QString exe = execnamestr.simplified(); QStringList parameters; if (exe.indexOf("%") != -1) { exe = exe.left(exe.indexOf("%") - 1); - //qDebug()<<"=====dd====="<setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); this->hide(); g_menuStatus = false; + myDebug() << "信号触发隐藏窗口"; } void TabletWindow::btnGroupClickedSlot(int prePageNum, int pageNum) @@ -1080,7 +1044,7 @@ void TabletWindow::winKeyReleaseSlot(const QString &key) if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) { QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); - if (gsetting.keys().contains("winKeyRelease")) + if (gsetting.keys().contains("winKeyRelease")) { if (gsetting.get(QString("winKeyRelease")).toBool()) { disconnect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), this, SLOT(xkbEventsRelease(QString))); @@ -1092,7 +1056,16 @@ void TabletWindow::winKeyReleaseSlot(const QString &key) connect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), this, SLOT(xkbEventsPress(QString))); } + } } } } +void TabletWindow::menuStatusChange() +{ + QDBusMessage message = QDBusMessage::createSignal("/com/ukui/menu", "com.ukui.menu", "statusChangeSignal"); + //给信号赋值 + message << g_menuStatus; + //发射 + QDBusConnection::sessionBus().send(message); +} diff --git a/src/UserInterface/tabletwindow.h b/src/UserInterface/tabletwindow.h old mode 100755 new mode 100644 index efb1a2d..7b6a03d --- a/src/UserInterface/tabletwindow.h +++ b/src/UserInterface/tabletwindow.h @@ -46,8 +46,6 @@ #include "tabletlistview.h" #include "pagemanager.h" #include "tablet_directorychanged_thread.h" -#include "dbus.h" -#include "dbus-adaptor.h" class TabletWindow : public QWidget { @@ -123,8 +121,9 @@ private: QFileSystemWatcher *m_configFileWatcher = nullptr; TabletDirectoryChangedThread *m_directoryChangedThread = nullptr; QSettings *m_disableAppSet = nullptr; - DBus *m_dbus = nullptr; + QLabel m_animationPage; +// DBus *m_dbus = nullptr; protected: /** @@ -183,6 +182,8 @@ protected: bool checkapplist(); + void menuStatusChange(); + public Q_SLOTS: /** * @brief Open the application diff --git a/src/UserInterface/userinterface.pri b/src/UserInterface/userinterface.pri old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/AbstractInterface.h b/src/UtilityFunction/AbstractInterface.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/KySmallPluginInterface.h b/src/UtilityFunction/KySmallPluginInterface.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/Style/style.cpp b/src/UtilityFunction/Style/style.cpp old mode 100755 new mode 100644 index dcc3831..2832bc6 --- a/src/UtilityFunction/Style/style.cpp +++ b/src/UtilityFunction/Style/style.cpp @@ -100,6 +100,10 @@ int Style::ButtonWidgetWidth = 56; int Style::ToolWidgetLeft = 24; bool Style::IsWideScreen = false; +int Style::DropMenuWidth = 0; +int Style::DropMenuHeight = 0; +int Style::miniIconSize = 0; + void Style::initWidStyle() { if (!g_projectCodeName.contains("V10SP1-edu")) { @@ -121,10 +125,12 @@ void Style::initWidStyle() if (m_availableScreenWidth == 800 && m_availableScreenHeight == 600) { minw = 320; minh = 500; + leftPageWidth = 300; + leftPageHeight = 517; } else { minw = 652; minh = 590; - leftPageWidth = 292; + leftPageWidth = 300; leftPageHeight = 517; } @@ -194,11 +200,14 @@ void Style::initWidStyle() AppSpaceBetweenIconText = 14; } - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; + LeftBtnWidth = 68 + 5 * len; + LeftBtnHeight = 34; QueryLineEditHeight = 30; LeftLetterBtnHeight = 25; LeftIconSize = 19; + DropMenuWidth = 128; + DropMenuHeight = 112; + miniIconSize = 8; LeftSpaceIconText = 14; m_applistWidWidth = m_availableScreenWidth / 1.25; m_applistWidWidth = m_applistWidWidth - (m_applistWidWidth % m_applistGridSizeWidth) + 1; diff --git a/src/UtilityFunction/Style/style.h b/src/UtilityFunction/Style/style.h old mode 100755 new mode 100644 index 09ab7dd..0a46ea4 --- a/src/UtilityFunction/Style/style.h +++ b/src/UtilityFunction/Style/style.h @@ -169,7 +169,9 @@ public: static int WideAppListItemSizeHeight; static int WideAppViewLeftMargin; static bool IsWideScreen; - + static int DropMenuWidth; + static int DropMenuHeight; + static int miniIconSize; }; diff --git a/src/UtilityFunction/abstractInterface.h b/src/UtilityFunction/abstractInterface.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/thumbnail.cpp b/src/UtilityFunction/thumbnail.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/thumbnail.h b/src/UtilityFunction/thumbnail.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp old mode 100755 new mode 100644 index c7e4521..a524fb2 --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -32,6 +32,7 @@ #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" QString g_projectCodeName = "V10SP1"; bool g_menuStatus = false; +QString g_curStyle = ""; const QPixmap loadSvg(const QString &fileName, const int size) { diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h old mode 100755 new mode 100644 index 75c43e7..f5e9a2e --- a/src/UtilityFunction/utility.h +++ b/src/UtilityFunction/utility.h @@ -87,6 +87,7 @@ enum PanelPositon { extern QString g_projectCodeName; extern bool g_menuStatus; +extern QString g_curStyle; #endif // UTILITY_H diff --git a/src/UtilityFunction/utilityfunction.pri b/src/UtilityFunction/utilityfunction.pri old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_bo.qm b/translations/ukui-menu_bo.qm old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_bo.ts b/translations/ukui-menu_bo.ts old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_tr.qm b/translations/ukui-menu_tr.qm old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_tr.ts b/translations/ukui-menu_tr.ts old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_zh_CN.qm b/translations/ukui-menu_zh_CN.qm old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_zh_CN.ts b/translations/ukui-menu_zh_CN.ts old mode 100755 new mode 100644 diff --git a/ukui-menu.desktop b/ukui-menu.desktop old mode 100755 new mode 100644 diff --git a/ukui-menu.ini b/ukui-menu.ini old mode 100755 new mode 100644 diff --git a/ukui-menu.pro b/ukui-menu.pro old mode 100755 new mode 100644 diff --git a/ukui-menu.pro.user b/ukui-menu.pro.user new file mode 100644 index 0000000..6d1e613 --- /dev/null +++ b/ukui-menu.pro.user @@ -0,0 +1,314 @@ + + + + + + EnvironmentId + {b9d686e0-ada0-41c1-ad9c-96f1279f7707} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + 桌面 + 桌面 + {9d9f9a2c-403b-48c4-83ee-e52b4e889b83} + 0 + 0 + 0 + + /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu3.1/ukui-menu/ukui-menu.pro + /home/ztz/ukui-menu3.1/ukui-menu/ukui-menu.pro + + false + + false + true + true + false + false + true + + /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + From 421495ce0a4098fe573e09e27938ebd0863b6cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=82=9C?= Date: Fri, 20 May 2022 16:38:24 +0800 Subject: [PATCH 02/12] Import Upstream version 3.0.2.0216 --- README.md | 21 - data/img/mainviewwidget/.DS_Store | Bin 6148 -> 0 bytes data/img/mainviewwidget/DM-all-2x.png | Bin 633 -> 0 bytes data/img/mainviewwidget/DM-all.png | Bin 361 -> 0 bytes data/img/mainviewwidget/DM-all.svg | 6 - data/img/mainviewwidget/DM-arrow-2x.png | Bin 360 -> 0 bytes data/img/mainviewwidget/DM-arrow.png | Bin 230 -> 0 bytes data/img/mainviewwidget/DM-arrow.svg | 4 - data/img/mainviewwidget/DM-close-2x.png | Bin 460 -> 0 bytes data/img/mainviewwidget/DM-close.png | Bin 323 -> 0 bytes data/img/mainviewwidget/DM-close.svg | 13 - data/img/mainviewwidget/DM-function-2x.png | Bin 427 -> 0 bytes data/img/mainviewwidget/DM-function.png | Bin 292 -> 0 bytes data/img/mainviewwidget/DM-function.svg | 13 - data/img/mainviewwidget/DM-icon-check.png | Bin 285 -> 0 bytes data/img/mainviewwidget/DM-icon-check.svg | 6 - data/img/mainviewwidget/DM-icon-check@2x.png | Bin 486 -> 0 bytes data/img/mainviewwidget/DM-icon-option.svg | 4 - data/img/mainviewwidget/DM-icon-search.png | Bin 432 -> 0 bytes data/img/mainviewwidget/DM-icon-search.svg | 10 - data/img/mainviewwidget/DM-icon-search@2x.png | Bin 762 -> 0 bytes data/img/mainviewwidget/DM-icon-返回.png | Bin 373 -> 0 bytes data/img/mainviewwidget/DM-icon-返回.svg | 6 - data/img/mainviewwidget/DM-icon-返回@2x.png | Bin 627 -> 0 bytes data/img/mainviewwidget/DM-icon-选项.png | Bin 180 -> 0 bytes data/img/mainviewwidget/DM-icon-选项@2x.png | Bin 214 -> 0 bytes data/img/mainviewwidget/DM-letter-2x.png | Bin 669 -> 0 bytes data/img/mainviewwidget/DM-letter.png | Bin 392 -> 0 bytes data/img/mainviewwidget/DM-letter.svg | 7 - data/img/mainviewwidget/DM-max-2x.png | Bin 559 -> 0 bytes data/img/mainviewwidget/DM-max.png | Bin 378 -> 0 bytes data/img/mainviewwidget/DM-max.svg | 8 - data/img/mainviewwidget/all-2x.png | Bin 536 -> 0 bytes data/img/mainviewwidget/all.png | Bin 327 -> 0 bytes data/img/mainviewwidget/all.svg | 4 - data/img/mainviewwidget/close-2x.png | Bin 491 -> 0 bytes data/img/mainviewwidget/close.png | Bin 345 -> 0 bytes data/img/mainviewwidget/close.svg | 13 - data/img/mainviewwidget/drop-down-2x.png | Bin 371 -> 0 bytes data/img/mainviewwidget/drop-down.png | Bin 226 -> 0 bytes data/img/mainviewwidget/drop-down.svg | 4 - data/img/mainviewwidget/full-all-2x.png | Bin 899 -> 0 bytes data/img/mainviewwidget/full-close-2x.png | Bin 477 -> 0 bytes data/img/mainviewwidget/full-close.png | Bin 304 -> 0 bytes data/img/mainviewwidget/full-close.svg | 4 - data/img/mainviewwidget/full-drop-down-2x.png | Bin 393 -> 0 bytes data/img/mainviewwidget/full-drop-down.png | Bin 260 -> 0 bytes data/img/mainviewwidget/full-drop-down.svg | 4 - data/img/mainviewwidget/full-function-2x.png | Bin 550 -> 0 bytes data/img/mainviewwidget/full-function.png | Bin 380 -> 0 bytes data/img/mainviewwidget/full-function.svg | 11 - data/img/mainviewwidget/full-letter-2x.png | Bin 867 -> 0 bytes data/img/mainviewwidget/full-letter.png | Bin 472 -> 0 bytes data/img/mainviewwidget/full-letter.svg | 7 - data/img/mainviewwidget/full-min-2x.png | Bin 566 -> 0 bytes data/img/mainviewwidget/full-min.png | Bin 382 -> 0 bytes data/img/mainviewwidget/full-min.svg | 10 - data/img/mainviewwidget/full-search-2x.png | Bin 695 -> 0 bytes data/img/mainviewwidget/full-search.png | Bin 379 -> 0 bytes data/img/mainviewwidget/full-search.svg | 7 - data/img/mainviewwidget/fullicon-all.png | Bin 482 -> 0 bytes data/img/mainviewwidget/fullicon-all.svg | 4 - data/img/mainviewwidget/function-2x.png | Bin 467 -> 0 bytes data/img/mainviewwidget/function.png | Bin 312 -> 0 bytes data/img/mainviewwidget/function.svg | 11 - data/img/mainviewwidget/icon- search-2x.png | Bin 838 -> 0 bytes data/img/mainviewwidget/icon- search.png | Bin 430 -> 0 bytes data/img/mainviewwidget/icon- search.svg | 10 - data/img/mainviewwidget/icon- 返回.png | Bin 377 -> 0 bytes data/img/mainviewwidget/icon- 返回.svg | 4 - data/img/mainviewwidget/icon- 返回@2x.png | Bin 660 -> 0 bytes data/img/mainviewwidget/icon- 选项.png | Bin 176 -> 0 bytes data/img/mainviewwidget/icon- 选项.svg | 4 - data/img/mainviewwidget/icon- 选项@2x.png | Bin 206 -> 0 bytes data/img/mainviewwidget/icon-check.png | Bin 330 -> 0 bytes data/img/mainviewwidget/icon-check.svg | 4 - data/img/mainviewwidget/icon-check@2x.png | Bin 541 -> 0 bytes data/img/mainviewwidget/letter-2x.png | Bin 688 -> 0 bytes data/img/mainviewwidget/letter.png | Bin 421 -> 0 bytes data/img/mainviewwidget/letter.svg | 7 - data/img/mainviewwidget/max-2x.png | Bin 559 -> 0 bytes data/img/mainviewwidget/max.png | Bin 390 -> 0 bytes data/img/mainviewwidget/max.svg | 8 - data/img/mainviewwidget/power-2x.png | Bin 1264 -> 0 bytes data/img/mainviewwidget/power.png | Bin 632 -> 0 bytes data/img/mainviewwidget/power.svg | 5 - data/img/mainviewwidget/select.svg | 4 - data/img/mainviewwidget/selected.svg | 4 - data/img/mainviewwidget/ukui-search-blue.svg | 16 - data/img/mainviewwidget/ukui-search.svg | 16 - main.cpp | 66 +- res.qrc | 184 +- src/BackProcess/DBus/dbus.cpp | 29 - src/BackProcess/DBus/dbus.h | 24 - .../FileWatcher/desktop_watcher.cpp | 38 - src/BackProcess/FileWatcher/desktop_watcher.h | 32 - .../tablet_directorychanged_thread.cpp | 147 - .../tablet_directorychanged_thread.h | 53 - .../Interface/currenttime_interface.cpp | 90 - .../Interface/currenttime_interface.h | 35 - .../Interface/ukui_chineseletter.cpp | 6252 ----------------- .../Interface/ukuimenuinterface.cpp | 1642 ----- .../XEventMonitor/xeventmonitor.cpp | 238 - src/BackProcess/XEventMonitor/xeventmonitor.h | 75 - src/BackProcess/backprocess.pri | 44 - src/BackProcess/tablet/getmodeldata.cpp | 180 - src/BackProcess/tablet/getmodeldata.h | 97 - src/BackProcess/tablet/pagemanager.cpp | 84 - src/BackProcess/tablet/pagemanager.h | 20 - src/CommonUseWidget/commonusewidget.cpp | 144 + src/CommonUseWidget/commonusewidget.h | 109 + src/CommonUseWidget/fullcommonusewidget.cpp | 189 + .../fullcommonusewidget.h} | 40 +- src/{BackProcess => }/DBus/dbus-adaptor.cpp | 15 +- src/{BackProcess => }/DBus/dbus-adaptor.h | 10 +- src/DBus/dbus.cpp | 46 + src/DBus/dbus.h | 41 + src/{BackProcess => }/DBus/org.ukui.menu.xml | 0 src/FunctionWidget/fullfunctionwidget.cpp | 492 ++ .../fullfunctionwidget.h} | 47 +- .../functionbuttonwidget.cpp} | 29 +- .../functionbuttonwidget.h} | 10 +- src/FunctionWidget/functionwidget.cpp | 239 + src/FunctionWidget/functionwidget.h | 141 + src/Interface/ukuichineseletter.cpp | 5827 +++++++++++++++ .../ukuichineseletter.h} | 2 +- src/Interface/ukuimenuinterface.cpp | 1045 +++ .../Interface/ukuimenuinterface.h | 43 +- .../fullletterwidget.cpp} | 323 +- .../fullletterwidget.h} | 71 +- .../letterbuttonwidget.cpp} | 76 +- .../letterbuttonwidget.h} | 5 +- src/LetterWidget/letterwidget.cpp | 271 + src/LetterWidget/letterwidget.h | 128 + .../directorychangedthread.cpp} | 33 +- .../directorychangedthread.h} | 4 +- src/MainViewWidget/mainviewwidget.cpp | 1012 +++ src/MainViewWidget/mainviewwidget.h | 293 + src/MainWindow/mainwindow.cpp | 622 ++ src/MainWindow/mainwindow.h | 123 + src/QtSingleApplication/QtLockedFile | 18 + src/QtSingleApplication/QtSingleApplication | 18 + src/QtSingleApplication/qtlocalpeer.cpp | 88 +- src/QtSingleApplication/qtlocalpeer.h | 8 +- src/QtSingleApplication/qtlockedfile.cpp | 1 - src/QtSingleApplication/qtlockedfile.h | 29 +- src/QtSingleApplication/qtlockedfile_unix.cpp | 41 +- src/QtSingleApplication/qtlockedfile_win.cpp | 116 +- .../qtsingleapplication.cpp | 27 +- src/QtSingleApplication/qtsingleapplication.h | 41 +- .../qtsinglecoreapplication.cpp | 4 +- .../qtsinglecoreapplication.h | 3 +- src/RightClickMenu/menubox.cpp | 53 + .../menubox.h} | 38 +- .../RightClickMenu/rightclickmenu.cpp | 254 +- .../RightClickMenu/rightclickmenu.h | 15 +- src/RightClickMenu/uninstallwhitelist.cpp | 84 + src/RightClickMenu/uninstallwhitelist.h | 47 + .../file-utils.cpp | 170 +- .../file-utils.h | 10 +- .../fullsearchresultwidget.cpp | 142 + .../fullsearchresultwidget.h} | 50 +- .../pinyinWithTone.txt | 2 +- .../pinyinWithoutTone.txt | 2 +- .../searchappthread.cpp | 34 +- .../searchappthread.h | 5 +- src/SearchResultWidget/searchresultwidget.cpp | 96 + src/SearchResultWidget/searchresultwidget.h | 86 + src/SideBarWidget/sidebarwidget.cpp | 1026 +++ src/SideBarWidget/sidebarwidget.h | 249 + src/Style/style.cpp | 505 ++ src/{UtilityFunction => }/Style/style.h | 116 +- src/UserInterface/ListView/fulllistview.cpp | 133 - src/UserInterface/ListView/klistview.cpp | 106 - src/UserInterface/ListView/klistview.h | 41 - src/UserInterface/ListView/rightlistview.cpp | 125 - src/UserInterface/ListView/rightlistview.h | 51 - src/UserInterface/ListView/tabletlistview.cpp | 809 --- src/UserInterface/ListView/tabletlistview.h | 145 - src/UserInterface/Other/lettertooltip.cpp | 54 - src/UserInterface/Other/lettertooltip.h | 24 - src/UserInterface/RightClickMenu/menubox.cpp | 21 - src/UserInterface/RightClickMenu/menubox.h | 25 - .../RightClickMenu/tabletrightclickmenu.cpp | 335 - .../RightClickMenu/tabletrightclickmenu.h | 159 - src/UserInterface/ViewItem/itemdelegate.cpp | 347 - src/UserInterface/ViewItem/kitemdelegate.cpp | 6 - src/UserInterface/ViewItem/kitemdelegate.h | 16 - .../ViewItem/recent_item_delegate.h | 24 - .../ViewItem/right_item_delegate.cpp | 195 - .../ViewItem/right_item_delegate.h | 25 - .../ViewItem/tablet_full_itemdelegate.cpp | 221 - .../ViewItem/tablet_full_itemdelegate.h | 55 - src/UserInterface/Widget/animationpage.cpp | 26 - src/UserInterface/Widget/animationpage.h | 14 - .../Widget/full_commonuse_widget.cpp | 304 - .../Widget/full_function_widget.cpp | 581 -- .../Widget/full_searchresult_widget.cpp | 273 - src/UserInterface/Widget/function_Widget.cpp | 278 - src/UserInterface/Widget/function_Widget.h | 85 - src/UserInterface/Widget/main_view_widget.cpp | 78 - src/UserInterface/Widget/main_view_widget.h | 70 - src/UserInterface/Widget/plugin_widget.cpp | 21 - src/UserInterface/Widget/plugin_widget.h | 28 - src/UserInterface/Widget/tabview_widget.cpp | 36 - src/UserInterface/Widget/tabview_widget.h | 25 - src/UserInterface/full_mainwindow.cpp | 462 -- src/UserInterface/full_mainwindow.h | 88 - src/UserInterface/mainwindow.cpp | 1152 --- src/UserInterface/mainwindow.h | 227 - src/UserInterface/tabletwindow.cpp | 1071 --- src/UserInterface/tabletwindow.h | 246 - src/UserInterface/userinterface.pri | 82 - src/UtilityFunction/AbstractInterface.h | 13 - src/UtilityFunction/KySmallPluginInterface.h | 31 - src/UtilityFunction/Style/style.cpp | 246 - src/UtilityFunction/abstractInterface.h | 20 - .../classifybtnscrollarea.cpp} | 69 +- .../classifybtnscrollarea.h} | 3 +- .../convertdesktoptowinid.cpp} | 194 +- .../convertdesktoptowinid.h} | 34 +- .../fullitemdelegate.cpp} | 60 +- .../fullitemdelegate.h} | 16 +- src/UtilityFunction/fulllistview.cpp | 259 + .../fulllistview.h | 39 +- .../functionclassifybutton.cpp} | 89 +- .../functionclassifybutton.h} | 48 +- .../itemdelegate.cpp} | 107 +- .../itemdelegate.h | 12 +- .../letterclassifybutton.cpp} | 139 +- .../letterclassifybutton.h} | 23 +- .../ListView => UtilityFunction}/listview.cpp | 160 +- .../ListView => UtilityFunction}/listview.h | 36 +- src/UtilityFunction/proxystyle.cpp | 64 + src/UtilityFunction/proxystyle.h | 45 + .../Other => UtilityFunction}/scrollarea.cpp | 96 +- .../Other => UtilityFunction}/scrollarea.h | 6 +- .../softwaredatabaseupdatethread.cpp} | 36 +- .../softwaredatabaseupdatethread.h | 27 + .../splitbarframe.cpp} | 28 +- .../splitbarframe.h} | 32 +- src/UtilityFunction/thumbnail.cpp | 244 - src/UtilityFunction/thumbnail.h | 34 - .../toolbutton.cpp} | 38 +- .../toolbutton.h} | 9 +- src/UtilityFunction/utility.cpp | 307 +- src/UtilityFunction/utility.h | 28 +- src/UtilityFunction/utilityfunction.pri | 16 - translations/ukui-menu_bo.qm | 1 - translations/ukui-menu_bo.ts | 262 - translations/ukui-menu_bo_CN.ts | 302 + translations/ukui-menu_tr.qm | Bin 2709 -> 0 bytes translations/ukui-menu_tr.ts | 390 +- translations/ukui-menu_zh_CN.qm | Bin 2320 -> 0 bytes translations/ukui-menu_zh_CN.ts | 449 +- ukui-menu.pro | 106 +- ukui-menu.pro.user | 314 - 257 files changed, 15794 insertions(+), 21099 deletions(-) delete mode 100644 data/img/mainviewwidget/.DS_Store delete mode 100644 data/img/mainviewwidget/DM-all-2x.png delete mode 100644 data/img/mainviewwidget/DM-all.png delete mode 100644 data/img/mainviewwidget/DM-all.svg delete mode 100644 data/img/mainviewwidget/DM-arrow-2x.png delete mode 100644 data/img/mainviewwidget/DM-arrow.png delete mode 100644 data/img/mainviewwidget/DM-arrow.svg delete mode 100644 data/img/mainviewwidget/DM-close-2x.png delete mode 100644 data/img/mainviewwidget/DM-close.png delete mode 100644 data/img/mainviewwidget/DM-close.svg delete mode 100644 data/img/mainviewwidget/DM-function-2x.png delete mode 100644 data/img/mainviewwidget/DM-function.png delete mode 100644 data/img/mainviewwidget/DM-function.svg delete mode 100644 data/img/mainviewwidget/DM-icon-check.png delete mode 100644 data/img/mainviewwidget/DM-icon-check.svg delete mode 100644 data/img/mainviewwidget/DM-icon-check@2x.png delete mode 100644 data/img/mainviewwidget/DM-icon-option.svg delete mode 100644 data/img/mainviewwidget/DM-icon-search.png delete mode 100644 data/img/mainviewwidget/DM-icon-search.svg delete mode 100644 data/img/mainviewwidget/DM-icon-search@2x.png delete mode 100644 data/img/mainviewwidget/DM-icon-返回.png delete mode 100644 data/img/mainviewwidget/DM-icon-返回.svg delete mode 100644 data/img/mainviewwidget/DM-icon-返回@2x.png delete mode 100644 data/img/mainviewwidget/DM-icon-选项.png delete mode 100644 data/img/mainviewwidget/DM-icon-选项@2x.png delete mode 100644 data/img/mainviewwidget/DM-letter-2x.png delete mode 100644 data/img/mainviewwidget/DM-letter.png delete mode 100644 data/img/mainviewwidget/DM-letter.svg delete mode 100644 data/img/mainviewwidget/DM-max-2x.png delete mode 100644 data/img/mainviewwidget/DM-max.png delete mode 100644 data/img/mainviewwidget/DM-max.svg delete mode 100644 data/img/mainviewwidget/all-2x.png delete mode 100644 data/img/mainviewwidget/all.png delete mode 100644 data/img/mainviewwidget/all.svg delete mode 100644 data/img/mainviewwidget/close-2x.png delete mode 100644 data/img/mainviewwidget/close.png delete mode 100644 data/img/mainviewwidget/close.svg delete mode 100644 data/img/mainviewwidget/drop-down-2x.png delete mode 100644 data/img/mainviewwidget/drop-down.png delete mode 100644 data/img/mainviewwidget/drop-down.svg delete mode 100644 data/img/mainviewwidget/full-all-2x.png delete mode 100644 data/img/mainviewwidget/full-close-2x.png delete mode 100644 data/img/mainviewwidget/full-close.png delete mode 100644 data/img/mainviewwidget/full-close.svg delete mode 100644 data/img/mainviewwidget/full-drop-down-2x.png delete mode 100644 data/img/mainviewwidget/full-drop-down.png delete mode 100644 data/img/mainviewwidget/full-drop-down.svg delete mode 100644 data/img/mainviewwidget/full-function-2x.png delete mode 100644 data/img/mainviewwidget/full-function.png delete mode 100644 data/img/mainviewwidget/full-function.svg delete mode 100644 data/img/mainviewwidget/full-letter-2x.png delete mode 100644 data/img/mainviewwidget/full-letter.png delete mode 100644 data/img/mainviewwidget/full-letter.svg delete mode 100644 data/img/mainviewwidget/full-min-2x.png delete mode 100644 data/img/mainviewwidget/full-min.png delete mode 100644 data/img/mainviewwidget/full-min.svg delete mode 100644 data/img/mainviewwidget/full-search-2x.png delete mode 100644 data/img/mainviewwidget/full-search.png delete mode 100644 data/img/mainviewwidget/full-search.svg delete mode 100644 data/img/mainviewwidget/fullicon-all.png delete mode 100644 data/img/mainviewwidget/fullicon-all.svg delete mode 100644 data/img/mainviewwidget/function-2x.png delete mode 100644 data/img/mainviewwidget/function.png delete mode 100644 data/img/mainviewwidget/function.svg delete mode 100644 data/img/mainviewwidget/icon- search-2x.png delete mode 100644 data/img/mainviewwidget/icon- search.png delete mode 100644 data/img/mainviewwidget/icon- search.svg delete mode 100644 data/img/mainviewwidget/icon- 返回.png delete mode 100644 data/img/mainviewwidget/icon- 返回.svg delete mode 100644 data/img/mainviewwidget/icon- 返回@2x.png delete mode 100644 data/img/mainviewwidget/icon- 选项.png delete mode 100644 data/img/mainviewwidget/icon- 选项.svg delete mode 100644 data/img/mainviewwidget/icon- 选项@2x.png delete mode 100644 data/img/mainviewwidget/icon-check.png delete mode 100644 data/img/mainviewwidget/icon-check.svg delete mode 100644 data/img/mainviewwidget/icon-check@2x.png delete mode 100644 data/img/mainviewwidget/letter-2x.png delete mode 100644 data/img/mainviewwidget/letter.png delete mode 100644 data/img/mainviewwidget/letter.svg delete mode 100644 data/img/mainviewwidget/max-2x.png delete mode 100644 data/img/mainviewwidget/max.png delete mode 100644 data/img/mainviewwidget/max.svg delete mode 100644 data/img/mainviewwidget/power-2x.png delete mode 100644 data/img/mainviewwidget/power.png delete mode 100644 data/img/mainviewwidget/power.svg delete mode 100644 data/img/mainviewwidget/select.svg delete mode 100644 data/img/mainviewwidget/selected.svg delete mode 100644 data/img/mainviewwidget/ukui-search-blue.svg delete mode 100644 data/img/mainviewwidget/ukui-search.svg delete mode 100644 src/BackProcess/DBus/dbus.cpp delete mode 100644 src/BackProcess/DBus/dbus.h delete mode 100644 src/BackProcess/FileWatcher/desktop_watcher.cpp delete mode 100644 src/BackProcess/FileWatcher/desktop_watcher.h delete mode 100644 src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp delete mode 100644 src/BackProcess/FileWatcher/tablet_directorychanged_thread.h delete mode 100644 src/BackProcess/Interface/currenttime_interface.cpp delete mode 100644 src/BackProcess/Interface/currenttime_interface.h delete mode 100644 src/BackProcess/Interface/ukui_chineseletter.cpp delete mode 100644 src/BackProcess/Interface/ukuimenuinterface.cpp delete mode 100644 src/BackProcess/XEventMonitor/xeventmonitor.cpp delete mode 100644 src/BackProcess/XEventMonitor/xeventmonitor.h delete mode 100644 src/BackProcess/backprocess.pri delete mode 100644 src/BackProcess/tablet/getmodeldata.cpp delete mode 100644 src/BackProcess/tablet/getmodeldata.h delete mode 100644 src/BackProcess/tablet/pagemanager.cpp delete mode 100644 src/BackProcess/tablet/pagemanager.h create mode 100644 src/CommonUseWidget/commonusewidget.cpp create mode 100644 src/CommonUseWidget/commonusewidget.h create mode 100644 src/CommonUseWidget/fullcommonusewidget.cpp rename src/{UserInterface/Widget/full_commonuse_widget.h => CommonUseWidget/fullcommonusewidget.h} (77%) rename src/{BackProcess => }/DBus/dbus-adaptor.cpp (74%) rename src/{BackProcess => }/DBus/dbus-adaptor.h (87%) create mode 100644 src/DBus/dbus.cpp create mode 100644 src/DBus/dbus.h rename src/{BackProcess => }/DBus/org.ukui.menu.xml (100%) create mode 100644 src/FunctionWidget/fullfunctionwidget.cpp rename src/{UserInterface/Widget/full_function_widget.h => FunctionWidget/fullfunctionwidget.h} (86%) rename src/{UserInterface/Widget/function_button_widget.cpp => FunctionWidget/functionbuttonwidget.cpp} (85%) rename src/{UserInterface/Widget/function_button_widget.h => FunctionWidget/functionbuttonwidget.h} (89%) create mode 100644 src/FunctionWidget/functionwidget.cpp create mode 100644 src/FunctionWidget/functionwidget.h create mode 100644 src/Interface/ukuichineseletter.cpp rename src/{BackProcess/Interface/ukui_chineseletter.h => Interface/ukuichineseletter.h} (96%) create mode 100644 src/Interface/ukuimenuinterface.cpp rename src/{BackProcess => }/Interface/ukuimenuinterface.h (70%) rename src/{UserInterface/Widget/full_letter_widget.cpp => LetterWidget/fullletterwidget.cpp} (54%) rename src/{UserInterface/Widget/full_letter_widget.h => LetterWidget/fullletterwidget.h} (70%) rename src/{UserInterface/Widget/letter_button_widget.cpp => LetterWidget/letterbuttonwidget.cpp} (53%) rename src/{UserInterface/Widget/letter_button_widget.h => LetterWidget/letterbuttonwidget.h} (93%) create mode 100644 src/LetterWidget/letterwidget.cpp create mode 100644 src/LetterWidget/letterwidget.h rename src/{BackProcess/FileWatcher/directory_changed_thread.cpp => MainViewWidget/directorychangedthread.cpp} (59%) rename src/{BackProcess/FileWatcher/directory_changed_thread.h => MainViewWidget/directorychangedthread.h} (92%) create mode 100644 src/MainViewWidget/mainviewwidget.cpp create mode 100644 src/MainViewWidget/mainviewwidget.h create mode 100644 src/MainWindow/mainwindow.cpp create mode 100644 src/MainWindow/mainwindow.h create mode 100644 src/RightClickMenu/menubox.cpp rename src/{BackProcess/FileWatcher/software_database_update_thread.h => RightClickMenu/menubox.h} (62%) rename src/{UserInterface => }/RightClickMenu/rightclickmenu.cpp (53%) rename src/{UserInterface => }/RightClickMenu/rightclickmenu.h (92%) create mode 100644 src/RightClickMenu/uninstallwhitelist.cpp create mode 100644 src/RightClickMenu/uninstallwhitelist.h rename src/{BackProcess/Search => SearchResultWidget}/file-utils.cpp (68%) rename src/{BackProcess/Search => SearchResultWidget}/file-utils.h (90%) create mode 100644 src/SearchResultWidget/fullsearchresultwidget.cpp rename src/{UserInterface/Widget/full_searchresult_widget.h => SearchResultWidget/fullsearchresultwidget.h} (66%) rename src/{BackProcess/Search => SearchResultWidget}/pinyinWithTone.txt (99%) rename src/{BackProcess/Search => SearchResultWidget}/pinyinWithoutTone.txt (99%) rename src/{BackProcess/Search => SearchResultWidget}/searchappthread.cpp (80%) rename src/{BackProcess/Search => SearchResultWidget}/searchappthread.h (94%) create mode 100644 src/SearchResultWidget/searchresultwidget.cpp create mode 100644 src/SearchResultWidget/searchresultwidget.h create mode 100644 src/SideBarWidget/sidebarwidget.cpp create mode 100644 src/SideBarWidget/sidebarwidget.h create mode 100644 src/Style/style.cpp rename src/{UtilityFunction => }/Style/style.h (63%) delete mode 100644 src/UserInterface/ListView/fulllistview.cpp delete mode 100644 src/UserInterface/ListView/klistview.cpp delete mode 100644 src/UserInterface/ListView/klistview.h delete mode 100644 src/UserInterface/ListView/rightlistview.cpp delete mode 100644 src/UserInterface/ListView/rightlistview.h delete mode 100644 src/UserInterface/ListView/tabletlistview.cpp delete mode 100644 src/UserInterface/ListView/tabletlistview.h delete mode 100644 src/UserInterface/Other/lettertooltip.cpp delete mode 100644 src/UserInterface/Other/lettertooltip.h delete mode 100644 src/UserInterface/RightClickMenu/menubox.cpp delete mode 100644 src/UserInterface/RightClickMenu/menubox.h delete mode 100644 src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp delete mode 100644 src/UserInterface/RightClickMenu/tabletrightclickmenu.h delete mode 100644 src/UserInterface/ViewItem/itemdelegate.cpp delete mode 100644 src/UserInterface/ViewItem/kitemdelegate.cpp delete mode 100644 src/UserInterface/ViewItem/kitemdelegate.h delete mode 100644 src/UserInterface/ViewItem/recent_item_delegate.h delete mode 100644 src/UserInterface/ViewItem/right_item_delegate.cpp delete mode 100644 src/UserInterface/ViewItem/right_item_delegate.h delete mode 100644 src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp delete mode 100644 src/UserInterface/ViewItem/tablet_full_itemdelegate.h delete mode 100644 src/UserInterface/Widget/animationpage.cpp delete mode 100644 src/UserInterface/Widget/animationpage.h delete mode 100644 src/UserInterface/Widget/full_commonuse_widget.cpp delete mode 100644 src/UserInterface/Widget/full_function_widget.cpp delete mode 100644 src/UserInterface/Widget/full_searchresult_widget.cpp delete mode 100644 src/UserInterface/Widget/function_Widget.cpp delete mode 100644 src/UserInterface/Widget/function_Widget.h delete mode 100644 src/UserInterface/Widget/main_view_widget.cpp delete mode 100644 src/UserInterface/Widget/main_view_widget.h delete mode 100644 src/UserInterface/Widget/plugin_widget.cpp delete mode 100644 src/UserInterface/Widget/plugin_widget.h delete mode 100644 src/UserInterface/Widget/tabview_widget.cpp delete mode 100644 src/UserInterface/Widget/tabview_widget.h delete mode 100644 src/UserInterface/full_mainwindow.cpp delete mode 100644 src/UserInterface/full_mainwindow.h delete mode 100644 src/UserInterface/mainwindow.cpp delete mode 100644 src/UserInterface/mainwindow.h delete mode 100644 src/UserInterface/tabletwindow.cpp delete mode 100644 src/UserInterface/tabletwindow.h delete mode 100644 src/UserInterface/userinterface.pri delete mode 100644 src/UtilityFunction/AbstractInterface.h delete mode 100644 src/UtilityFunction/KySmallPluginInterface.h delete mode 100644 src/UtilityFunction/Style/style.cpp delete mode 100644 src/UtilityFunction/abstractInterface.h rename src/{UserInterface/Other/classify_btn_scrollarea.cpp => UtilityFunction/classifybtnscrollarea.cpp} (61%) rename src/{UserInterface/Other/classify_btn_scrollarea.h => UtilityFunction/classifybtnscrollarea.h} (92%) rename src/{BackProcess/FileWatcher/convert_winid_to_desktop.cpp => UtilityFunction/convertdesktoptowinid.cpp} (50%) rename src/{BackProcess/FileWatcher/convert_winid_to_desktop.h => UtilityFunction/convertdesktoptowinid.h} (73%) rename src/{UserInterface/ViewItem/full_item_delegate.cpp => UtilityFunction/fullitemdelegate.cpp} (84%) rename src/{UserInterface/ViewItem/full_item_delegate.h => UtilityFunction/fullitemdelegate.h} (78%) create mode 100644 src/UtilityFunction/fulllistview.cpp rename src/{UserInterface/ListView => UtilityFunction}/fulllistview.h (51%) rename src/{UserInterface/Button/function_classify_button.cpp => UtilityFunction/functionclassifybutton.cpp} (63%) rename src/{UserInterface/Button/function_classify_button.h => UtilityFunction/functionclassifybutton.h} (67%) rename src/{UserInterface/ViewItem/recent_item_delegate.cpp => UtilityFunction/itemdelegate.cpp} (72%) rename src/{UserInterface/ViewItem => UtilityFunction}/itemdelegate.h (86%) rename src/{UserInterface/Button/letter_classify_button.cpp => UtilityFunction/letterclassifybutton.cpp} (50%) rename src/{UserInterface/Button/letter_classify_button.h => UtilityFunction/letterclassifybutton.h} (75%) rename src/{UserInterface/ListView => UtilityFunction}/listview.cpp (54%) rename src/{UserInterface/ListView => UtilityFunction}/listview.h (60%) create mode 100644 src/UtilityFunction/proxystyle.cpp create mode 100644 src/UtilityFunction/proxystyle.h rename src/{UserInterface/Other => UtilityFunction}/scrollarea.cpp (56%) rename src/{UserInterface/Other => UtilityFunction}/scrollarea.h (90%) rename src/{BackProcess/FileWatcher/software_database_update_thread.cpp => UtilityFunction/softwaredatabaseupdatethread.cpp} (62%) create mode 100644 src/UtilityFunction/softwaredatabaseupdatethread.h rename src/{UserInterface/Widget/splitbar_frame.cpp => UtilityFunction/splitbarframe.cpp} (73%) rename src/{UserInterface/Widget/splitbar_frame.h => UtilityFunction/splitbarframe.h} (67%) delete mode 100644 src/UtilityFunction/thumbnail.cpp delete mode 100644 src/UtilityFunction/thumbnail.h rename src/{UserInterface/Button/tool_button.cpp => UtilityFunction/toolbutton.cpp} (83%) rename src/{UserInterface/Button/tool_button.h => UtilityFunction/toolbutton.h} (92%) delete mode 100644 src/UtilityFunction/utilityfunction.pri delete mode 100644 translations/ukui-menu_bo.qm delete mode 100644 translations/ukui-menu_bo.ts create mode 100644 translations/ukui-menu_bo_CN.ts delete mode 100644 translations/ukui-menu_tr.qm delete mode 100644 translations/ukui-menu_zh_CN.qm delete mode 100644 ukui-menu.pro.user diff --git a/README.md b/README.md index 3a66c1d..e1d44df 100644 --- a/README.md +++ b/README.md @@ -33,24 +33,3 @@ Note: build-depends references the paragraph in debian/control. > sudo make install Note: If you want to run ukui-menu, You just need to execute the ukui-menu command at the terminal. - -## DBUS interface - -BUS Name:org.ukui.menu - -path:/org/ukui/menu - -Interface:org.ukui.menu - -Method name: - -GetMenuStatus () <---> Get ukui-menu display hidden status - -WinKeyResponse () <---> ukui-menu display hidden state change interface - -GetSecurityConfigPath () <---> Get security control profile path - -## Configuration file - -.config/ukui/Ukuimenu.db - diff --git a/data/img/mainviewwidget/.DS_Store b/data/img/mainviewwidget/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0g0%imoB-!uha1yBay{C&~NCfBG(6_mV350Iqhu*b2`g8wj?iGgR%#E8aGe> z7op`A$7s>A=UBMrKbCErVt6u8Z%ED5QwcbA!%)2X z`MFH?<^1Qk=BSqDGI)Q!^VN0-+v4KJZS7LVQygx0vp+87ypzj1>A}LkcNZS}a!cTC z$fC8!QX}U%WiuKtxsvpCyX(iO|wdlJ#DNb*Ce2<7z zMQ35^dZs&;r%qPe6&?(FE|?G=ee1xt$94)X(qPaWK*KxymWQT^(ASS)O6Z zZ9*BDXKyF&VtKcX=}+=)xh$Xcyce6|GmdJ?Dc@_lHGek4;qQ-f^hLKky;<;!caCQA z?%kh+7!nvCbZzF|X7xw)N#|9~!`qJDIr8w4qkYZYAIn95FdmJ(aN>5y%{`zb;OXk; Jvd$@?2>|3A|GWSI diff --git a/data/img/mainviewwidget/DM-all.png b/data/img/mainviewwidget/DM-all.png deleted file mode 100644 index b05d7fa12f2216b254defd31629a0407729de68a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1gh1Cceo z%o`e0neI5;IUp#pFz*pZ&jU6iCh0Al+y)E*?@eukJ^xJPuRZzt?$=YvTJ249XS&exP zcj`w@Tk7Pta_hPWtW}?F - - - - - diff --git a/data/img/mainviewwidget/DM-arrow-2x.png b/data/img/mainviewwidget/DM-arrow-2x.png deleted file mode 100644 index 7cd5c3520da8dbb74887fe8a25651c5c56f0b786..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1uz}^K@|xiQs%2yqousfk3aI zko1L%7afnXg%~*Q(mBC0vtg2+Y^;~s0-By!V~fB%jpqvAX8d^cv`}q9^WE$tX79XTmTD!uNKZ6*JVpJ4;PdG}_x@B~ zZdu$cdLroJk$JZl>@ diff --git a/data/img/mainviewwidget/DM-arrow.png b/data/img/mainviewwidget/DM-arrow.png deleted file mode 100644 index 3b4fe22971642754637c3109f80466dc94fc457b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1&f!t(F` z|M^@;k_?_V-f)=1^jP__&j}foZ-xriJgWp#0yG5V-6yphOFq;wVGG!-9N;0TRWp6! z#6tU7LI%@WXDfK{EMd&xu - - - diff --git a/data/img/mainviewwidget/DM-close-2x.png b/data/img/mainviewwidget/DM-close-2x.png deleted file mode 100644 index 5dbfa4e02a5994cf04ff6fe2cd09763d090194ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 460 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yB4$z7VnJ6*0V zeew(5$QuuC$~Jym>2R<;Tcxh;d}7}G_-=+f8Lb;SjO)Y>FeQqHGiNB+JW^xeJfxk+ z=HW0WV2SvRh_^`xFWSqklIocI;aHB}!;+q~ehb;9b_Q&5zYcDEG}G=}&d0xJRN{9r zEXzN)CA{LZ`LtuV4bL(Z9(1hX?ciIzI(b%>f*8N7-YU-0<1Aa&2^J=M%`xNCZ_#45 z{HWi=uf)AT^t)3BLs%idi_ih>yw(YQ4}Y{Dx&3fi+SbQ{Pv^X2o}cF`cB80X>VL;a gVTVFJ$rGs$n0+o9a7{UT!Wk5*p00i_>zopr06H0^c>n+a diff --git a/data/img/mainviewwidget/DM-close.png b/data/img/mainviewwidget/DM-close.png deleted file mode 100644 index af003706014c62554e7bd97ae20d5f531dedd074..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 323 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1N<#6s|H&_!M*MIP42 z4C@ZC?dnvXBfX<>^&O7w2YVOzIm~=u#&F+wl7qAG{`H>xUcckk^Ut|G{iuZckDIf& zb_RRBy!ebix8X1Mz8(*bZ}-+)K3`x^>tPTRCDi2lq_gzh>bakPHGJgXlTh8tZ9P5c zo?;7UVY)L@Scp)AIro`e%Jyv=Kex%a?v*t4>;AF!@tLpNFaB*hyl{haP}9}~8TNae uzs+}uMX6M^>{gY?YshceZWMlL?i%^K#T7Q2;v2VvJmcx==d#Wzp$Pzfi*A4b diff --git a/data/img/mainviewwidget/DM-close.svg b/data/img/mainviewwidget/DM-close.svg deleted file mode 100644 index 8992eda..0000000 --- a/data/img/mainviewwidget/DM-close.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/data/img/mainviewwidget/DM-function-2x.png b/data/img/mainviewwidget/DM-function-2x.png deleted file mode 100644 index aefcb56934b25e5746414adc5cf6dc769900497b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 427 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9k(bL5-B!cs8*jwI13IeQ; z8Tt~`H%Q;`Ti};uzQJ$7>=n`v*zy9x3Yco9J2?L^P&9qX-`^rr@Lu+~wyHYI_WE## zWh@eHiTX=z4uvmXA2j2TX=;yUc<556xG4>H|A;Zw8@dbS&NyNuxMQ(tgS>$)$9fhw zg+SNWAIwvVd3TuBglp_-etS{+%SPQ}6J;58Y(1>Ez4F9QGj|@|dVh%{_a=Oep3+bp zwP?2ArhATyeoygDxYWm*;@2SRv6q=O+@t5cqu@#A^Zz*2v>WR8eB_%Vo3+;Wl;v)w zISkqdxKcznO!awnT{q5o%`A@i#MJ{`}l5ed2mU=feg08#Zm)<>~Eh?>4di!-IogcbC8arNDh}fBk<3Bl#n2D;Zb1 zil;Mh{c{&TlE&b{yD3Vo#CORjO|yp93B5b^FkW`Qz~JiY%044W!gj}@hDQ!AW)Ik^ zoSJ@0&TLz?lTo-?{poW5`KSK<`&%s@(3B9AmYiHXebS^V7UPtJOa=}C>l^+#4|zeZ N^>p=fS?83{1OQJFT|oc< diff --git a/data/img/mainviewwidget/DM-function.svg b/data/img/mainviewwidget/DM-function.svg deleted file mode 100644 index 3e1c659..0000000 --- a/data/img/mainviewwidget/DM-function.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/data/img/mainviewwidget/DM-icon-check.png b/data/img/mainviewwidget/DM-icon-check.png deleted file mode 100644 index 69c4da6b0fbbcbafb2763bee0adeb9e15bec80cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 285 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1x^Xr>mdKI;Vst E0A?#taR2}S diff --git a/data/img/mainviewwidget/DM-icon-check.svg b/data/img/mainviewwidget/DM-icon-check.svg deleted file mode 100644 index bca4fc6..0000000 --- a/data/img/mainviewwidget/DM-icon-check.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/data/img/mainviewwidget/DM-icon-check@2x.png b/data/img/mainviewwidget/DM-icon-check@2x.png deleted file mode 100644 index b4a1b706f47970c6596f22f2cecfcbda20dfc192..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 486 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9E#?!?yB!ctp2{-}G>-P3Vb?3P`F|E8Lo$#zMtJ4 z$sT@ZB5VH{?r+PaUU4-Xmfyr&F9zWH5tnj zW6t<%E->bMaY}yMZ`mTo^_m+}m8Znc-L06>J6Y#IxwP8q#&c6HA1-~q^qNuE-urCp zj8AF@H1OP*UO#JH`T?2wPCraPwC!D+bD4?dQniKjX+J~zChhBPtQr@*|7qE8xqo1) z`cF0|flqo3cW=r4>sq*f(Z;>aXR7#n{JLaVW+(!KtEPj(+tbz0 JWt~$(69C4Xz2g7? diff --git a/data/img/mainviewwidget/DM-icon-option.svg b/data/img/mainviewwidget/DM-icon-option.svg deleted file mode 100644 index a1e8d2b..0000000 --- a/data/img/mainviewwidget/DM-icon-option.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/img/mainviewwidget/DM-icon-search.png b/data/img/mainviewwidget/DM-icon-search.png deleted file mode 100644 index c446f1cc3924bc8a99a0a7b69664b284e61f75a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 432 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1C)mLwAw^ADaSqbZ1b|+ ztM9E2*)Q(<`@Mh`v*)CW%6a|=OSS(kc)cq>^4hk!_38qy7t153F|jr#O1O)qM1JEu zqucc;<@UEVx`*(FDf@hCftaw4t{VT&wjPv>s!b>?}NdYdVvX^O}F&C(lnh7suCewaC)&Fev0aUHx3vIVCg! E0F!i{G5`Po diff --git a/data/img/mainviewwidget/DM-icon-search.svg b/data/img/mainviewwidget/DM-icon-search.svg deleted file mode 100644 index 3b4b9c6..0000000 --- a/data/img/mainviewwidget/DM-icon-search.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/data/img/mainviewwidget/DM-icon-search@2x.png b/data/img/mainviewwidget/DM-icon-search@2x.png deleted file mode 100644 index d7a01d6082f4c60e4cd4a85432ca68a0838a2007..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 762 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yAbz|+MsB!ctpw6ha$IS90} z9=)5AAjoLJEW?=6(2+2g@fJ_b=d;(+7MyM1nbylNk+FLDf%}uIH6o=HRo3cn+nx1d zX5jwo>#M&w3;fw$zn8h$jQ7U-?+*(sVq)~BtL`vNPWvJI&q9Ld(&wLlY-aix-Oev5 z=iG2aTFAY(hebif@x)_WCn?qmHJlImD?$q!I@0H8-J5m%>D(Eog?C?ID^n@!?f7#2 z(*NpUhLg(P>yE4sa1qd|T-!La(2&tQbV8?xNq(x=ywsbn&6Rh!d^Q-c{@KL${w>3U z30!duy(=F~T=m$hDf;(^n%3uy60*nDD>fDV*{~<^wZ!@->tiQ(v%e89?C2IW)(R6$ zxVm1)XqCdP{3kLcNviLR_9!(p{Mi$*?s;W6+m_gF=a{zDceuAQF?{ih6L`JjosfW3 zLA1gP>$5v8+W1o!d9ic+%5d~6mAst#c1K!jfvbb%1ON5fOgj?!rfpfYt$oIv({d;8 zXJ|3)m=$^C&Yxezbm=z+TB9V-iu+VQPt2$texIQXostV zwTU~-YUC2?xX5F~ahPGj*-Z+Z3V$W$pH(nbXt>IKK!clo*8xe5df^wXFMseH%3?T? zG9kR7t%Y&s{RTsWxl0^aBpH}4%s9bhWZBrZHYgy#f^C|ElEEPc&pyVK*SELl&u)D9 vkws(PhYt^(Cu~2#yr5v=35HK=RGq{b1hyp2U2U;)8OZydu6{1-oD!M - - - - - diff --git a/data/img/mainviewwidget/DM-icon-返回@2x.png b/data/img/mainviewwidget/DM-icon-返回@2x.png deleted file mode 100644 index 9830a10d9b08e2b9d45859b2692f126ff1630d38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 627 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yBarKgKyNCfBGFx`A6M}fWi ztt>hZjaM$^T(wOqwtAb?W&6fs^N!71I!%gYS{n<81)oYAL+#}sy6;=aVKQM^B*jih548=rsv$;aTulf>k=@0Mgj!STYRf;;sQdefcN78_@$ zCRoj##_&e{Afp&V%?jpOTSU_v4#Zx6`(VpXmxcvFDW|MwM^*#ncNreC2n2#=XiF`3EKzrPaF`p*F3p&)rZUdpvd=h^>bP0l+XkK DY#sqd diff --git a/data/img/mainviewwidget/DM-icon-选项.png b/data/img/mainviewwidget/DM-icon-选项.png deleted file mode 100644 index 9447a802c9ef91b7dc1295ff879eac02617fa939..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1}%WVj-BEAdzu^qv$|0 yJO97Qj|Es+SvS-bec@BLUEJu=dP9cSg^i8j)kz+f^U;hJAl;s>elF{r5}E+n)Ff;G diff --git a/data/img/mainviewwidget/DM-icon-选项@2x.png b/data/img/mainviewwidget/DM-icon-选项@2x.png deleted file mode 100644 index c8cd4e1c8f167603daaf6b7ef76ea733eaa58712..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1u!Qc)B=-L~tf2NU$o~vPdK{ zet2-O`M-ggZ3ZhV>xR2NUpC}i>ANT(!P|II;D9*OVpYX`7bK@jgSZlsiUv_aeLWR& fU!P`hJm6+zus^`VwNhk_8OVH3S3j3^P6g0%imoB-!uha1y9Q*we)^B!cs8=xN_01_Gsv z?nJ)R&Q+3%u=3#aX17yRex-c39-`$V6QO#Q>AEfa1Fsg|3uKGMNS@MRE#U#6n+Cscm^Ovmh*J0L`uyFq5&D8v-Z{gX` ze_~j_Pi&TC_#2~Q-|)$H?~D_SC&f}ed#?J$;?Hn!(yO^lCMRaxn7in+Q1dhf(RH19 zA%9v=iD$9hIF_my7BbtHFEv5?z$(drm6Pp^^>&?_%^0%7;p==BMz(+_=XKeC?=VfY zZ{K_M^2=EQY!C)=EBL%29W_tx%iNb9TDrYyr{Uv#d+Z_skWYxRK}Eq?%1S(fZT9t(Nrg zTke+I`Rz>~sIA*Gsqm*dJCJe6zjrVT0%8FKn^@3|VLVb{CF2@Lh0Q+14o5`~1pk zFP<-2_-*l}V23wxM~b35R&%QU-Lx?$BKWqz<6D!CsXDM8E3Th)@(VxD^S=qn4q@># zg(_a8t~qkaDNXXgnYGXNwIu~Gq~AG|aq8ypgGU(DeXMRjKUeE)=lizUeui2A*A_2l u-f)i|BaJDu3^Wcr`ZGOZnu&U_4D)>ljfZ!BzPZo`N+zDJelF{r5}E*$IuZx~ diff --git a/data/img/mainviewwidget/DM-letter.png b/data/img/mainviewwidget/DM-letter.png deleted file mode 100644 index 97722c960978e8bffabeb968eef81e2318a0ebfd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 392 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_18e0omVjG4Ei z-7f$8)sk4T=vCCF|DI8eQ8m%oomH_c|}+-a1D9*z4*gD>b@g znB7(}o{H~yToD?2_29O*>Y|B{_Q?fIdn&d5{ZFREM?a$9t>vAh5;@^u;T&UW$<4=X zzJ{@JyyvLv+BMnHD*1s(wGOkEIj@;@*kH16&%~pxO-o~DNEOjG50H@XSA&CN5c88=jSK?&bNp^ P3JMWVS3j3^P6 - - - - - - diff --git a/data/img/mainviewwidget/DM-max-2x.png b/data/img/mainviewwidget/DM-max-2x.png deleted file mode 100644 index db956e42c8e930947c7fac65e928b88aeeac9486..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 559 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9^si%u$NCfBG@Y99O1_G?d z*!!MwEH9Z*lCZRSNz;zzDFVxzO9aXjE-{uo5UOG9vrx~Qu${&5&yq-EuN?~{byRHM z+P(Kbv`H*)o9ExmS#~$K)t;YFSs45M^yfXV+ZfXvH|g9C5B=KN-m2gANbp$Od# zJ6O|}Do%}Y`KbNW=2BMocaFci-~XQ2^KRw6!a3b*rW}~hS^PQjf`+}XX2S({*-o4D z+cmRSw zDs12NVVP(1x7BXViTb@93CkUH1*|wft#)gFxbCXnf^Mer=FFH}#&hAlAwDUEGYx`R dm!5I`Ex+%2b4@5mWiu$^JYD@<);T3K0RSVF*PQ?W diff --git a/data/img/mainviewwidget/DM-max.png b/data/img/mainviewwidget/DM-max.png deleted file mode 100644 index 14aa676c9cb67d0dcae89bf72f1649c44ff3ba98..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 378 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1*uK`*qZ2fk7w8!@NPhVLzg}SX{D~7UPGnW< z=ob?a`NJ^9o+0@2pP$8S3ltOdgncH&%qnAJVAgx^^78WMjbCa7q|dhUH~i_9k&zKE zU{eYZ_LyiR(EO*`F)Heoz!5k0BUOycU40g4Fx}cF=dyTa9K)8MN&#;a4R%Rgcp?y! zFvWs__XqzX!9_2})MH@yl%4q9@&A@SP#Ac+`njxgN@xNAi}rte diff --git a/data/img/mainviewwidget/DM-max.svg b/data/img/mainviewwidget/DM-max.svg deleted file mode 100644 index 3b820ce..0000000 --- a/data/img/mainviewwidget/DM-max.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/data/img/mainviewwidget/all-2x.png b/data/img/mainviewwidget/all-2x.png deleted file mode 100644 index 15a02b1be7d9c696e1d7e6c315c9be9b428f14d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 536 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yAv&(p;*B!ctp)VqO)4Fp0BxRA+-^~2i--a18-gpcu8emM8$MO|37>!vxY zW*NLa@R9F~X6}RX#`j;COjww%dKH^}c{=xj*2%ib(;N?p-Z{8`g{IB}o_l4!FOQU( zmp%O(Anf{sNj^dFm+0w5i&jbfy42d&B^}XZv(&p_Zc2MfIfr|9%=tS^Zq=_QT-?&o zeYdgd#hZT@%Wd;z7V~HIf4KZI(zAA9YucJy7flzZRVY<#USh&FYnPFcw&5jnm!?T! zww31+ncjP6G$k||?+cooC~tc5B6C&KHu3k)?>WBtGOhh1GiP=AUgprb|1V5)GimcM zSTa4mfpd@Yjk2!LMLv^RU)pZ5SDyKrHTtlO60hzjJ@pN{T)e%FlAU9BT?i~>_MWi3 zgtJI~QS2fq^+MZXZi(j;)pz)C@3_~kJ6teT@jJ& zb3D(UtKInK)jXfV zd=q$Q@t$H!ZRtC}Q6lV?z+#r+me8CAq;gNH%X<7Z;kP(>!*0?88O1lT>f#Aaedp9) z#MLo~XI^5m(a@_|p|rzPId@<4`G!!lLbH$h;qnjGPnhuN-K0BazaIa&xDwrY3s% wYW>1r4E8SfKBrzhz*%vs|G{>X&TRgm`0_@n6^@4Y&VoGT>FVdQ&MBb@08?gdSO5S3 diff --git a/data/img/mainviewwidget/all.svg b/data/img/mainviewwidget/all.svg deleted file mode 100644 index 43587e7..0000000 --- a/data/img/mainviewwidget/all.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/img/mainviewwidget/close-2x.png b/data/img/mainviewwidget/close-2x.png deleted file mode 100644 index 100fd90805d5671da91966e5bc45a2aff548cb16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 491 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9E(bL5-B!ctpG~c`y1D@7} zqB<948hKwAwR}^vJ@mz+xXJR+7mn1kZTA%J_Bu5E%1jYaoOC0sTvdqc=f?Z(g=wywKIns3IU%DC)p-NNXM2jphX^zZdxISGpa{$^JW6`00UbC;WZl zHg_C0i(tR;F|L2H#re-OuY26NC>VR(M*pQR!;j}2)+`=>*dJ~e(Y~>oaT}+5eB9*u zeF{FJ!Bd%|3)dCY`31Nf5fv5`U~W0`kmW3wB9lj_y+DqDC&S7eqDou~M7KMzFs^wN z)$zda33un#LklB%AOG-jkd-@W+w}0d+|0dvJ^J+z4{OxUkQJQZ`at}op8FoDbAsxi OK=*X@b6Mw<&;$UpP`xw& diff --git a/data/img/mainviewwidget/close.png b/data/img/mainviewwidget/close.png deleted file mode 100644 index ce9b7d3bb5d2db1288025d2900a4a07276c8f689..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 345 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1koR6`oQerJQP^)F^%_KHq?#VabZOh_YBBn)VSN|$o zySm3v`uUyC@8LEJD<%ZRWveih$Ci6*=31tmoh)$3JG+*h)28T)@r*<5-}kxe&OXEV z{RV@|ms^U*ejGV{WqxDhN}&Y@J>0xjC!Fy$b$FXxG1E*UQ@Eq*-_-PVUI+5kCe?aJ zY!Fpibl{-C8daUNMAm~Me`Ez8$$J(y1- - - - - - - - - - - - - diff --git a/data/img/mainviewwidget/drop-down-2x.png b/data/img/mainviewwidget/drop-down-2x.png deleted file mode 100644 index a33369be2cde947857f66f720fdc8e7497de90f9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 371 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1uzp^mK6yiQs%Yc_H5+1A#Vf zi6<;fjWZk+CUVFzoK*Jtkiqdpj`sdIJh&1f@N8G&qr=}P*akN6ary3K3YqLY zWhqap9!b`Id&f&cfB; zH`$>`u7g+TFvA%MC4okH2Q8M4_Y8*o0_qGO - - - diff --git a/data/img/mainviewwidget/full-all-2x.png b/data/img/mainviewwidget/full-all-2x.png deleted file mode 100644 index 0b9e8625a3def0d9cd627af2d001ba813d08eb2d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 899 zcmV-}1AP36P)Px#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91FrWhf z1ONa40RR91FaQ7m0Qmn-HUIzu`AI}URA>e5Sut)@F%ZonTHpk^K%hnnlj{NM6q$kDtdg{@(HT#>SxG zfyeEEnK%9Ue7*_!7nE(37oJW*b_@CWY&JXc+JXBK@?DfyUVB0I6LR8y1}^y}$|fMj zUqGwH@Fh?@Tw$>HRtVg0c&0N_a!IPFD|MDIovbWlE8ekb)}5l|X{dnp(e zC$v6sI_uJD@qB$_--zdH-ROE|NUW1;GrWlA}}J*>4C9?Ivv>E zeMDe|3z>XPPF@5w(b|&SrrHQe+Eib0_9yuP zFoL-dQ}kXs0_Il>l0`riuC3AAC}w##*DJR7qJXb%ZB)7O|uYFnY^ znrDblt?^b@mIKcQ#MP|Vs(3sn&(uDgEj)!Gdq@wgT0$RSSj!UPJhqS7n#XqYBQ9b4@%A;l)tQ7e~N89hK)s|nWqIW~XoIYH{ zN%EuyDZ>-2Y_B* zwP2|(9hqHEWlKo1Ki-Xg0%imoB-!uha1y9E*we)^B!cs8=-#!>1_H-6 zI9MGKaooW0GHBTuvps_Mr1HC_3!V@OSmwk0#7CRtz!5!R#YYdm89gu()LLh>A(g4{3%l>1`PQfTc=+FQ89019qAjPw zx8@du!y%VXugb2@Ze~AR#WP>?_5KpAw0n_u#b?UH!X3uCrCbot zICnH$MCRe*b+3iB7N#<=Md<21JI-~4t7Z=qzjK#(K*X+XaiC!KboFyt=akR{0D8Q$ AGXMYp diff --git a/data/img/mainviewwidget/full-close.png b/data/img/mainviewwidget/full-close.png deleted file mode 100644 index e0aa44f3568ab150ac580e2f5698a5392e1727d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1qN2(gOLGE! z3#&FXM^Aapbm#BAsNJmvM<+N{8CaNf2J2UyjN?s6`gSEnmdzoJ~`?AW(%0VxE&WXCU ZcNvfPMOrP;n(q#Bxu>h2%Q~loCIE&3VYUDO diff --git a/data/img/mainviewwidget/full-close.svg b/data/img/mainviewwidget/full-close.svg deleted file mode 100644 index 397d1b9..0000000 --- a/data/img/mainviewwidget/full-close.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/img/mainviewwidget/full-drop-down-2x.png b/data/img/mainviewwidget/full-drop-down-2x.png deleted file mode 100644 index 61353ab82e25f96b97377804c395ee30092b026d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 393 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1u!U_jGX#iQs%Y#gOli0gtP+ z%8i*fEScC779MYF?d()8U{w>7I8}eaW1`0$6YYPKG&k*kJO94Jb;~=9^{7M^&nYv=jPLIr}4XKqk;6`5w-92qI{o*{=f<)vd|uV8uY&z-`@ zK25%7ZyPy->BS1ci@WChoXoV$B|v;f!AtAoWuKpzG-@#l@TzN=>n`6I#qgww!%Oh0 zdOz=GmJ2BzGxpA@+{`NCVxpTbHlgFeda*fc=ii$CX#Tqf>j!*0m@C=u&5B6+$Fn?N P926v;u6{1-oD!M}%WVj-BEAi;WtxAFh~ z|J6(zS@nV)ixf;xeDXOVqwrf?Ks(WxMQa&LDD(BUyaS30&QzB;PcUhI;*j;ALGWCY zQA1Z`qmQ_P7|WyTfW!%B70y;mNJ`c_A3Y$_#;6cz;_ToQVcM*+L5g9LgAvP-qZ=eu dEVx#PFfkO)Gu*Ixs+cIqHJ+}1F6*2UngE$tL(TvI diff --git a/data/img/mainviewwidget/full-drop-down.svg b/data/img/mainviewwidget/full-drop-down.svg deleted file mode 100644 index 5252b3c..0000000 --- a/data/img/mainviewwidget/full-drop-down.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/img/mainviewwidget/full-function-2x.png b/data/img/mainviewwidget/full-function-2x.png deleted file mode 100644 index 816f16cac3c5d9e8633e7a8370de892354dbf5aa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 550 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>f0%imoB>CgNpBYf`98VX=kPOzhk#BPk83?GZ zU_Rh-!S4XuNw+lzRC;eNm_5O7!airq*E<>(CG5CyHPYx??Txzc^XdgEw|<(Y$Xt8> z`U~A(thF!QB%;1lP0~`yZA;;a+$OfdY|{iUDUNL$zF(UD&?Y4GtK}iq54={}`Ghy+ zuaecRdT?M@{yYAlw4LlaEuGQEw-_cK2<&MOJjBC(ZT}VqE2(O)Cg#JP;T)Xe7VCSQ z7rl6X#8O%Gz|R}6x}R$*e^be6nHbexyWJ%6^7#w%cIoZ;aaWn4{83LwsF=c|r#^cd zmToO#jcIgY`@^LwG-J;lQIBN?h0Tvde|V@Q6z%+zY(Ddki_=Fgk@y3**I!t@kNrj2 zL#uDUrird^5MQ9Wbz3ZB_OY*(>l)II+$v*TBYFM#PNrFc*|$YEq{YmC&XwV|=577b z1M5wzi_b~RSyXr)(GvafP-BwxymS*emT5pY6bNy;iv+G-<$9ycE27|0;GC*QKhH)> z2r)BR^QBqM`#5)RdQK4Ir-?r4d}$U!W|dRlIkyOXSt5Di>1~}eu2P8#I%jLQyo;UI ZXutVs>iMZZ)qa5D%hT1*Wt~$(695tF-5US^ diff --git a/data/img/mainviewwidget/full-function.png b/data/img/mainviewwidget/full-function.png deleted file mode 100644 index 8e6f47f7558e4ba17ded1381cbad8110236a5459..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 380 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp21zqcxI}CFf_A3kYFNxrI(EM@I{J8h)zHblLGkqo<6dKB6 z6wqX;qU@O7nI<#O>vhL}ny*lizCTn++~)m_34c50hvjYRW7aReyK0K`BvBcl - - - - - - - - - - diff --git a/data/img/mainviewwidget/full-letter-2x.png b/data/img/mainviewwidget/full-letter-2x.png deleted file mode 100644 index a5212da75c3cbe7d1462a9fabb1dd2c354599c2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 867 zcmV-p1DyPcP)Px#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91FrWhf z1ONa40RR91FaQ7m0Qmn-HUIzu*-1n}RA>e5SV2w$F$|=LD@7cU$_si2@dK_1sXyQy zyr)QrYkyF|1Kfd_?OG&8EjLh zHXjTI^Y6!B@)r)=qd$j!Ukmnb4Z|V&$HMk;kO`5`V-*Jg?J5B;B}=H~iQH=dksblU zg976OwXjg;I*Ds!Kt_57RMff2IhGZTt{Fh|hd@IGdk|1vhVeFxZx~OJh4=7YJa}i| z9EceFf~YglCm$P{Bc1JR$bh8I38RF3f?kDE-7)}x^iPYala7cy`}EAm#+6dt8~{LB zpi_Cy!}An6+@vncHa8;rBXLCNs1TK|HH*&L0^^HU24qBMh&UJR3PzC0V0l zWQXWa=v<_Hf%}04I%h(U))4I$HIEGZpiT`DvOqUd&dzpFDx#RAPR$AEyHaXV1^}js zIyE0$DYeJ}Ae4o;Mx7e^t)Wyzzm+;QCrZ}FHcK)fqo1VCcr$+AIHe+jX6j_n@ksT9 z&eYqPQoClrOr0@se%~miB63;O$)MvAc8V!AI|Gz@0MTxpF~+v{VoJ?+0ElGqny6Fr z!h=$?J}D9X_=Eid;9fLw`A?Ekd`IdUqqMtX747gCIwkzy+qEr(L!MG=NYCd$L zRFebPQ5J6zb!zB6C^cyt(eHfgOd4zucG=640U7z2I$)S7>xEpotgs?r4lCl tkHPSKOcBtG_azTm827c`|2}^%0-sXOXEGJ%?eG8q002ovPDHLkV1iDjdRqVh diff --git a/data/img/mainviewwidget/full-letter.png b/data/img/mainviewwidget/full-letter.png deleted file mode 100644 index 00aff387d209b74ae5e002eb8444e6459ccf4c24..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 472 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp21z-m>k1@RxHJZzbKnc}UAdG16E# zh)3hP`Mf(lN#8>!oQ}IYhwax4>-7Pa8@_)!YS9{M?PifDY#p2L+t0B+;!k1jLzYAX2l_n*Af;`Yx??z85^>Rqe<_7)Vvp00i_>zopr0H092cmMzZ diff --git a/data/img/mainviewwidget/full-letter.svg b/data/img/mainviewwidget/full-letter.svg deleted file mode 100644 index ee2cc83..0000000 --- a/data/img/mainviewwidget/full-letter.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/data/img/mainviewwidget/full-min-2x.png b/data/img/mainviewwidget/full-min-2x.png deleted file mode 100644 index 46b8a3c7ced5a8deb6b592c268ceb3e4bf560d97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 566 zcmeAS@N?(olHy`uVBq!ia0vp^h9Jzr1|*B;ILZJi#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)><0%imoB zHn2)CNHp+DED*lHxr>3hq;ZpjT7&Ja|Cbme7Vrq%dp&h`&62`Dep-1G-<9mWGEHai zbB&@)CZZnKOSxZ2{aV#BSwuNonq|NBuRF`9%=7wte~OgF`Te1Pu1{;3_H>seigEBLJ_wsz z5ViYo6aNMG7h=CUgKvx1={rw2Aalz2^Sb4G>OP)0Fo%=H%6&mH`#)8QL{lT-%PJEX zwqIZ`d9!BE@gHZ3vLo%)clXZh6rY|#BI<1^*qQ*-MX9}aIjQ*6Mv s=gPd*Jg?5=OzkxP@$__}S%1BreRoW)WnHt+BvAZ$y85}Sb4q9e0704OxBvhE diff --git a/data/img/mainviewwidget/full-min.png b/data/img/mainviewwidget/full-min.png deleted file mode 100644 index 1016551363088b860c747c16ea4b085b996dbf70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 382 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~%1|*NXY)uAIjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp&1t_V#~YuWWe2dF4Zl z%ru*$igpc$4k%1yOA1zawzSi@fz6-w(d>X4DUWP{Y{9^vEEx+-E;xv*IR9*T!=hpr zrxrMk!IvSjiEl&a!qtqQJGVZu3iz6CBK&Q^$HF4X!cz-88Jf@VXo#>JQIMaLl#(*1 zXIV3qPQ5wbn1jVuM7ZmT6s}TLVPxpKf BeJ}t3 diff --git a/data/img/mainviewwidget/full-min.svg b/data/img/mainviewwidget/full-min.svg deleted file mode 100644 index 5bc8fb4..0000000 --- a/data/img/mainviewwidget/full-min.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/data/img/mainviewwidget/full-search-2x.png b/data/img/mainviewwidget/full-search-2x.png deleted file mode 100644 index 5419253cf31b1045d2ce47dc9a87e5fd3ebd3938..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 695 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9Q*VDx@B!ctl^oNDB9Rykf zwH7pAaD1V#gejOw_K2(t5Z_QeB07VwN1H=-2H%wTmb;fb3t3H=_`f3k-kp2*-tFG5 z&E^^T?PjiVIm7O|>r}q8g($G!I&F2KSj{H6~8W& zbKu?c+s7`W;T+q8Z=aI{4PJaoPZoL^woydUl68W>_TM3AFIrCh_|*3Ig|~s9TpDIc zdF;rU$-%XUIdRT+SF5dZ4Qwz(twW*3-h}y!n{I%uQz^#*~^w{k&`0)AUkyiGC zP={;k-kwzz-l@K7=Y1O18=uSF)Z#L~DXS*ugH?UN9P>2o)AyR4Y3m?V5s zzkqq4^ppQ=^^LRbK1-FzZ3z9^tv)fhgq=;KO^JKh8Kxi zy!TEX*vI@!_Tr|#9;v5WA4HcdxFdh@->!8o4Hs3`RX^q|6TZ0V)GT4m`6gfZXSbh{ THy25t2}(eou6{1-oD!M<;uamE diff --git a/data/img/mainviewwidget/full-search.png b/data/img/mainviewwidget/full-search.png deleted file mode 100644 index 3603ba3b4fb6075e2658277cb0786f7f974dec7f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 379 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1SN*wd?##Q^3ZDOBFPl7l!1T^R zb)DnBDzSxZJPR0RvL!sPe);^U>Wtpw*#>-%QWvnNzIi!C=0(f;!)6NdJqKofOKK4l zY20yPg0`dR4USvCK9@){FyXXf^@v~5-SGa)do_&3YVy#I?9uT=O93ItDAKbLh*2~7a1 C0gRRa diff --git a/data/img/mainviewwidget/full-search.svg b/data/img/mainviewwidget/full-search.svg deleted file mode 100644 index 89c630a..0000000 --- a/data/img/mainviewwidget/full-search.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/data/img/mainviewwidget/fullicon-all.png b/data/img/mainviewwidget/fullicon-all.png deleted file mode 100644 index 8f6176b36f7182edf35264bd770d143610a05802..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 482 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp21d7Sye^s-uh|B?GY10@qQR;eEU zwmJFt{~MA#|9G#K+OqC%wy*x-*xp)yRrqkZ`Gb{7+L{dI7q&lePxSL!u>OE~+g>NV zgFXFQ7!1~}dSz7{;qLqN45xElnY-<;RQLY@efuXpXL8RsixXVF)cHq2xFCyJ*NmHy zeca+(+RpuaW-+ZpdF93>PtHww)L|IDD2+cOa{2W8>&_K--~6}9qHKQYt3}^Cswcno zS6H)MmvzRUz?fpD-LoP+9{HA)W*;z4dA@tc15>|)zWJQ2KjbyV80?Jfw_D^IZT$8& zjM*-E%>)bAUmc&+SML6vz-e4ROQo|3kZ zXW5Kq`;^~I2xD;a)voD5UW>AVjLYfo1{mvv4F FO#lSNy{7;G diff --git a/data/img/mainviewwidget/fullicon-all.svg b/data/img/mainviewwidget/fullicon-all.svg deleted file mode 100644 index a991c98..0000000 --- a/data/img/mainviewwidget/fullicon-all.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/img/mainviewwidget/function-2x.png b/data/img/mainviewwidget/function-2x.png deleted file mode 100644 index ad6c487cfcabd254a1a5fa9291e898824d79d347..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 467 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yB4)6>NMWo4a8j8)rVtCh5HU`)V0uc{}7KC4b7h=*RDqIV`MDC=tNGWM;OF(_x?e zg*$8tZyAmh9AHUzlyq?YrtoZi{C=*2$i8*#^8XnH8f=(C7x%9dJIrXns?cj-w$$W| z@{LQve(V8Rnj3$)%Nj^ANjzoP*vY<(FHG*hj~y>Ir=L%nD)m8Qfdvc4)E0w$=I)Au zlbnwazhLBV3}o+VJCMQgfQK=_n{8US=F-s6P+o^L25B|9oyh?tV zV63oa%>?%b-icK!fhx>kUdPxxc6O_qVnU8$P%ucz7^9WocaZ+#%dqOI~D^ m!<>$LN@`c<1b#hi%))SDUUuj2V6#k6;Cj0HxvX-hco9|L?8;|8M8rz180hyY{SF^{Q0io1<7yPtTwJGwd53v#wmZ zvhMJanF%~@Zf?D|x98_Kek{BgU|JAFN6I z$3=X^4Fn!GdT$hGo6cx{L0IU_`4c7{yc(v5jyzyovSy7Ax6i5F4xC(Soz43`K0h!2 iz54q*+e3=}>4^+?cnlc!Dl44=`M}fF&t;ucLK6TwHfX*8 diff --git a/data/img/mainviewwidget/function.svg b/data/img/mainviewwidget/function.svg deleted file mode 100644 index da7fb57..0000000 --- a/data/img/mainviewwidget/function.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/data/img/mainviewwidget/icon- search-2x.png b/data/img/mainviewwidget/icon- search-2x.png deleted file mode 100644 index 8f286b4dd7a3e5406b09a175d17ce6e9a1f3b25b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 838 zcmV-M1G)T(P)Px#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91AfN*P z1ONa40RR91AOHXW0FO>U$p8QXyh%hsR9Fe^R=aNEKorG1q*R0eeOU2m<1%H^r3>lO z1&Zyr-X`!B+igg>RZN$X{DJ8rkWlggNKOrcJ;$1BS>rL-Ube~Zl}7XMJ?EaeGvk?D z?!W!(8L-kMpaCnDO4q=2Q7V>Y*~D+RTNjmw;;dGy@f!^7M3zW^3Ve@%y(FvpT$w*wJ0(G~T!2bTU(4aq#5uvwWQaRpiwNKy4yBLELvF$VkhX!HKO%;lruTvIGQ!2-V%_=xH)^$-#fya` zX|2_2{RHL;9s(L7AS+)c95YDE1pc(3-)OZx(Z5OZ QUjP6A07*qoM6N<$g5$wyj{pDw diff --git a/data/img/mainviewwidget/icon- search.png b/data/img/mainviewwidget/icon- search.png deleted file mode 100644 index c2da345bcc9d7e006f2a61ea7a0a811d7307744b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 430 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1V#g?ndZe{;qxi9r>?5rzh2TGMA3U6)OYv_AfSTEM@)J*5Z{g-aIW=OETeXcl( zA9(GmIPNF|1}e^nLO=p_m`r?h8Gz3YojBqC;hY^ - - - - - - - - - diff --git a/data/img/mainviewwidget/icon- 返回.png b/data/img/mainviewwidget/icon- 返回.png deleted file mode 100644 index 94dc40f362f5d5450008f68bf4e8fe71bf205565..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 377 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1kixs4K0^3a+!3 zMNi&f!hdG(wO^6fw{kTl^zPo4IcxIDndSePN-R>nJZ8NA1_}aCS3j3^P6 - - - diff --git a/data/img/mainviewwidget/icon- 返回@2x.png b/data/img/mainviewwidget/icon- 返回@2x.png deleted file mode 100644 index f3ffab08cb4bc042fb61c668a2ba7ca52a689cc7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 660 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yA5%hSa%B!cs8*lxc=0TRo^ zg^u<0?JADGyKC3fwTwcir9ZH}l71l^AgqvgYFY3{PK^yatad$2V`AL5|KW_qnsdB4 zJ10)w^8DBT`}IHnU4B+{{M&uygg4dpXf7Y^@4XaPQRb}dRQ)YRg%5HP+`RClceWf!jnOO29j+y_+ z+A5{+f1S_2lUlh#Y>p3f#Jb&I6nF}nHr)SSwO3)L$G$B*3I!8%nx2QYEoS!HbV}2M zxqY5===qrsy#yU*hCVE9|6a2*X4|j7btgnteY?aaU~x)^so}80rl!eqD@FdWx$m=A zj6VIyve-$2@&0%Jz%XSFm3hJza^epRgC{K&cRR32r@v8H;FJ7Y?m1sLc@Ol8J-Q>o zpDnlUZpW%d-ISNDY!`an%%u<6J!puz!>s&>ZTm9QEh$SLS^S&jx19fJ(M*fSlX!w2 zKKR&u^bz~FEk6}f85o0R`=~if7`mD0F~l7RV%!_9HC0C9<0P4&8qU=UzW0~uIKK(q z@mDb@bn;&gLrX>W8;<*yYuz~1?J-q6O7KCiqialZ-O;sY4f0BN-&N1ceI3xroEdeg zqOsU+htr%&-^mZJ8%aByV)(+QWY;|5`HXov3^5@mcCT>SVzGho$Hk=|ndJ4ojz5&{ mka!TjwzlGl@}u~k15(B62j{(Cykr$9b$Gh^xvX - - - diff --git a/data/img/mainviewwidget/icon- 选项@2x.png b/data/img/mainviewwidget/icon- 选项@2x.png deleted file mode 100644 index b6b765d8c5a69e59bde1dd9b02bb4b721c5a05e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1uzlc)B=-L~y>nvXG0xfP>Xx z`~Uyx?A~gNj~a8fwW~`k+{QhJX~NR^8TH@hdQ5U`U}*F^p#G-h42QrC#RtOgc5K$= aEMej=WMt-wl8mecnd|B5=d#Wzp$PyCFfkth diff --git a/data/img/mainviewwidget/icon-check.png b/data/img/mainviewwidget/icon-check.png deleted file mode 100644 index 29e9a1762af5371ea17392d43c562038e520dc05..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1hJkrq7(ZT9a`t$$)|M47`c`mg-Vw#}j=H~YA{r&yw zc{esZWcFa>a5(zdaaQ=6h=~khEkZgcWYpA_aXPp@x3sWeX?WDf$jHbvXU?3@jc*uo zW;s^PbY$U)*;n(kwXcuwf?yA)!>q=sQ@1i}JZCu4>M&b7;njpp5&Z)y4UMG?C$_PF zY&276GSz3;xRG&9Bgd5~3`gWSGmoV`@DO2UFywIW$_~G_9^@xaS3j3^P6 - - - diff --git a/data/img/mainviewwidget/icon-check@2x.png b/data/img/mainviewwidget/icon-check@2x.png deleted file mode 100644 index 5c1a31e5b84e0084ef8040a3d17d4865dc9e28c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 541 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9^vZsqYgr|wJg&xi*euk+siW7U3fV~_~Z%B%c~i7d3^l0gze=o z<#ToW~3do`!iVrIQc z^~~p$4|lzjHgIgVcCP9AYC3VTg;nwF=MH-qe$F}Woc2=i1Iyd}QU<=mCN zh8^EEUJ3ngH$B>Z>j6^-!}Rx83+Hg&;XJWCP$ZX6HSG5kCNIXN4B-#ByZx8{n|kbI Q9w?eTUHx3vIVCg!0H4p@%m4rY diff --git a/data/img/mainviewwidget/letter-2x.png b/data/img/mainviewwidget/letter-2x.png deleted file mode 100644 index edb749320937df9af3e699b38646c753c5f4dd9e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 688 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9Q&C|s(B!cs8sG}c~p-5_h z!kd-?21B-M6-<^*_Y%U?j5Xt?wX;=Y}%8w@yEKh`DfFP%S)^}=X!2Rqtn8I(+@l+*%Sm#vpQv` z9L)CW>n|0KCg%zBC-HpJesVIwV8xFK!msBtPH>-4N;Cg$ zOF8s%X^nE}y4Bb94{**_x*Km%8L1jr-+iJh%k0!X$%r{}7n6KlR!)}SO$mQGhcP5h za_RSz0=p&!dkcT#(kj~Iy?u4zIR}Zhi3RUpyo!BcbwnfLVN%>2^9kplr)DJ=?|8bN z@!C%#t6YaKf0YIJb8X{qv>mwG(x1BCd-7#AhF*^O=bz`U+qN)4N!ssLkp99wF)K=c z*(BEmZ|D)&CieF7%Pp2ty;W0un-g9q^s8IGn!jV3=$=%asb1FuV)Is-+XWjRU}NUr zc2E1vcHaEY$2rYv=6|h?Xid#Op6X?=TYKqZ2l-z{ZD)^GahBHJ7xUS=b07b)_=dUC zzxR2iO#b=1pyTM~+$#AT$%0H9v$|VJj1x8^P+(n(z8^S;@P*-QWW zw_5ABw_bg+%P?<bBg&nT_({r!Fq|ZX6p9 ON;#gcelF{r5}E*2CnQM# diff --git a/data/img/mainviewwidget/letter.png b/data/img/mainviewwidget/letter.png deleted file mode 100644 index 393bf639d2d61554b748e46b5a24194a980dcdd7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 421 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1sV`aHE&T4Tu}J6i^ktb=*Gnyv-)vj=y8Q0`D~I;I|IIv8 zbzbgcEe5u2N1H3>?GI!~ywq_#YlZZYM2UT~mYrm*%e=+Q^JPxz&E`}7Og86>b8hc* zIIuTM$%f~!`|WLOR%tojd7^({OR~Tu6W?N^6{2#XO19^Z_@^=StG(N$rx>_?#X|R| u^-N6)HyR7Hx*i3au87D|e;K;e{>c5wX3=r?bcBRJ!R6`d=d#Wzp$P!&Kb;-` diff --git a/data/img/mainviewwidget/letter.svg b/data/img/mainviewwidget/letter.svg deleted file mode 100644 index 368f9fe..0000000 --- a/data/img/mainviewwidget/letter.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/data/img/mainviewwidget/max-2x.png b/data/img/mainviewwidget/max-2x.png deleted file mode 100644 index 7a8d03f3c86c3815ce25e29c2cb86707e7115138..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 559 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9^si%u$NCfBG@YA_11_H5* zIh|yV5swRcr z*H|>pB=3LK>7lb!k|Rs}#FJf*`C0GA=p58OR>jVh?D+1;rc8Y$1$#A(&F7~qEuOqt zXR+{mkBJVy)pSl?FKalrtb^g+srL*@C!V-edkSrqc>CmFLn$B6v;UEIIdTLeY?)RG z6j~+wzYm-;FLM5itMO-#%=o%kknu{3MA(W<{eP=3GU>1#5qhxJyW6tc$(6S2CW}kQ50E#$IS3j3^P6Hd4B-jP<`)Dd9Mv!ImawV^m|x)iz$J5vZ62rRUpY_COpVMZs`~Gj*WUk~Ju}%c zQG#vV>t(;LF3Y^%ZgJW5QdX@KYUz^C|1dQi;Bw&j==#B% z(Is$6NPGXS`KPiNlDQ@B$l1=5NM`J^4hwZ{mRa$>`r+??!kbL;7#Wzhn~N|m*tG8T zoRYa~q8vnzxy+H{+;rD7>jnD_`2udc=I5N+H<=tJ&Dp>4&DN|$&Lq(1Q1`6TF%$j6@M)Hp{g)lSlR)9& M>FVdQ&MBb@0Orq!&j0`b diff --git a/data/img/mainviewwidget/max.svg b/data/img/mainviewwidget/max.svg deleted file mode 100644 index f6f73fd..0000000 --- a/data/img/mainviewwidget/max.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/data/img/mainviewwidget/power-2x.png b/data/img/mainviewwidget/power-2x.png deleted file mode 100644 index 926bc5904d7b35718fcb865fe5c5eb8c19d19b00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1264 zcmVPx#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91FrWhf z1ONa40RR91FaQ7m0Qmn-HUIzwW=TXrRA>e5SzB_{MilMangGKO-T_(yJHQ*T5r3&< zT#Q!$JHR`@SpiPrO689M7Jykn$O_`@!2B=K>*mf6 z_NMYWzLfFvtfa@c{+NBNn;Z7G4xulTz2Yk4_X3augq41QvX9Hb%E2+86uWJ4TN%I| zsz|?HZi@z+SP}O7wnTOFfB`H!Za7Fxn5SZU>&r$1&g1n_sCqX3b9U}`c5fLB!HQSv zmu*a}HL&;qnb-{Q`-^`7FW#l6>q^)CQLYuQX1^4HDBWS zWdBHx0}uY6DwDZ-+}F2idc>{w*L?8`yy^S5m9(6NGS8FJ!%OzlXK0i5M62uj3bAN#$F z*`~hWm|ufjc%peC~-FsoZOCvk`KK+C)oiAP}fkxf674 zuSsRzL>3ufR^GN*DcZ_zk`&6c>-LA*FcujYRr)KHNmLXh?FHQD8916TUUPFR+Cn;+Q0 znrk1Uu%{$dA9oSAVkWnyr(M4MQ|ah+}%*L#boB+?w-DVX4_3=Cj$U8do=4~5pk~x zywf;#JiM?CF&|>K3L$q92=0vJPRgBf`!}fr3z%KSgR}D!aD|#593v#4oF>R@Kp-Te8^ a?!bQlOtb!R0^v9S0000t=`Lp*q|hThFRWFWAQ zdrPaiS%z7IUlHAb@p<_Qk9x?0Rrc)6svD1TYHQ1nMty1E||i<6wzRsN5O z_4dy{^E3S4n|P0vg@2y6`Il!6QlV+53*+WZ7UxJUu$(Q$ShdrV=S+S-X}w5>^SO@YuZGaDlVhx8=Doy_S)r&Lk}e#A{)E!MUA-`$#>JC@`dtjaIQ zS!9|Nc8Z~4Syfj?$Xs1tnPg+--qb!eg{5Knyd`@D-!(p1Y*jCrwkp*pgRi*qmhZc{ zrU4H>I*05$|6^hJk=`vS_oNt_w3%I&ZvEn(%l>}PE`OF&cf?QgZVi%pwxU$SG~&VW zg?@XO&iQ>=@%$>+i>$7vZBa%N(h4sx<&;G8l7kd^eNURnV3S!&t-)$P-^5WF~qOe&det%Bq_lsJcmpUA?cA`Rp(zb8mjZM{QvyIw5)HISM1aBu*tK$Bl(Q` zKg?tkba-_--@AGKB(?P1O;d}{xd-}r7db1RoBwTp - - - - diff --git a/data/img/mainviewwidget/select.svg b/data/img/mainviewwidget/select.svg deleted file mode 100644 index bddfc1a..0000000 --- a/data/img/mainviewwidget/select.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/img/mainviewwidget/selected.svg b/data/img/mainviewwidget/selected.svg deleted file mode 100644 index c610131..0000000 --- a/data/img/mainviewwidget/selected.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/img/mainviewwidget/ukui-search-blue.svg b/data/img/mainviewwidget/ukui-search-blue.svg deleted file mode 100644 index 4665b8a..0000000 --- a/data/img/mainviewwidget/ukui-search-blue.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - ukui-global search-search-blue - - - - - - - - - - - - - \ No newline at end of file diff --git a/data/img/mainviewwidget/ukui-search.svg b/data/img/mainviewwidget/ukui-search.svg deleted file mode 100644 index e931c1d..0000000 --- a/data/img/mainviewwidget/ukui-search.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - ukui-global search-search - - - - - - - - - - - - - \ No newline at end of file diff --git a/main.cpp b/main.cpp index f30ac71..2a97a60 100644 --- a/main.cpp +++ b/main.cpp @@ -16,8 +16,7 @@ * */ -#include "mainwindow.h" -#include "tabletwindow.h" +#include "src/MainWindow/mainwindow.h" #include #include #include @@ -26,20 +25,20 @@ #include #include #include -#include "utility.h" -#include "file-utils.h" +#include "src/UtilityFunction/proxystyle.h" +#include +#include "src/UtilityFunction/utility.h" +#include "src/SearchResultWidget/file-utils.h" #include #include -#define UKUI_SERVICE "org.gnome.SessionManager" -#define UKUI_PATH "/org/gnome/SessionManager" -#define UKUI_INTERFACE "org.gnome.SessionManager" +#include "src/UtilityFunction/utility.h" #include int main(int argc, char *argv[]) { initUkuiLog4qt("ukui-menu"); - g_projectCodeName = KDKGetPrjCodeName().c_str(); + projectCodeName = KDKGetPrjCodeName().c_str(); qRegisterMetaType>("QVector"); #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -64,45 +63,14 @@ int main(int argc, char *argv[]) myDebug() << "Load translations file" << QLocale() << "failed!"; } - if (!g_projectCodeName.contains("V10SP1-edu")) { - FileUtils::loadHanziTable(":/src/BackProcess/Search/pinyinWithoutTone.txt"); - MainWindow w; - app.setActivationWindow(&w); - - if (Style::m_panelPosition == 0) { - w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + Style::m_availableScreenHeight - Style::minh - 3, - Style::minw, Style::minh)); - } else if (Style::m_panelPosition == 1) { - w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::minw, Style::minh)); - } else if (Style::m_panelPosition == 2) { - w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::minw, Style::minh)); - } else { - w.setGeometry(QRect(Style::m_primaryScreenX + Style::m_availableScreenWidth - Style::minw - 4, Style::m_primaryScreenY + 4, - Style::minw, Style::minh)); - } - - w.show(); - w.raise(); - w.update(); - w.activateWindow(); - w.hide(); - return app.exec(); - } else { - TabletWindow w; - app.setActivationWindow(&w); - centerToScreen(&w); - w.setAttribute(Qt::WA_TranslucentBackground, true); - w.setAttribute(Qt::WA_X11NetWmWindowTypeDesktop, false); - w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); - w.raise(); - w.activateWindow(); - //拉起后通知session - QDBusInterface interface(UKUI_SERVICE, - UKUI_PATH, - UKUI_INTERFACE, - QDBusConnection::sessionBus()); - interface.call("startupfinished", "ukui-menu", "finish"); - return app.exec(); - } + Zeeker::FileUtils::loadHanziTable(":/src/SearchResultWidget/pinyinWithoutTone.txt"); + MainWindow w; + app.setActivationWindow(&w); + w.show(); + w.raise(); + w.update(); + w.activateWindow(); + w.hide(); + //测试 + return app.exec(); } - diff --git a/res.qrc b/res.qrc index 47d0ea3..fc6c8ee 100644 --- a/res.qrc +++ b/res.qrc @@ -1,128 +1,13 @@ - data/img/mainviewwidget/all-2x.png - data/img/mainviewwidget/all.png - data/img/mainviewwidget/all.svg data/img/mainviewwidget/attributeaction.svg - data/img/mainviewwidget/close-2x.png - data/img/mainviewwidget/close.png - data/img/mainviewwidget/close.svg - data/img/mainviewwidget/Development-Checked.svg - data/img/mainviewwidget/Development-Disabled.svg - data/img/mainviewwidget/Development-Enabled.svg - data/img/mainviewwidget/Development-Normal.svg - data/img/mainviewwidget/DM-all-2x.png - data/img/mainviewwidget/DM-all.png - data/img/mainviewwidget/DM-all.svg - data/img/mainviewwidget/DM-close-2x.png - data/img/mainviewwidget/DM-close.png - data/img/mainviewwidget/DM-close.svg - data/img/mainviewwidget/DM-function-2x.png - data/img/mainviewwidget/DM-function.png - data/img/mainviewwidget/DM-function.svg - data/img/mainviewwidget/DM-arrow.png - data/img/mainviewwidget/DM-arrow.svg - data/img/mainviewwidget/DM-arrow-2x.png - data/img/mainviewwidget/DM-icon-返回.png - data/img/mainviewwidget/DM-icon-返回.svg - data/img/mainviewwidget/DM-icon-返回@2x.png - data/img/mainviewwidget/DM-icon-选项.png - data/img/mainviewwidget/DM-icon-选项@2x.png - data/img/mainviewwidget/DM-icon-check.png - data/img/mainviewwidget/DM-icon-check.svg - data/img/mainviewwidget/DM-icon-check@2x.png - data/img/mainviewwidget/DM-icon-search.png - data/img/mainviewwidget/DM-icon-search.svg - data/img/mainviewwidget/DM-icon-search@2x.png - data/img/mainviewwidget/DM-letter-2x.png - data/img/mainviewwidget/DM-letter.png - data/img/mainviewwidget/DM-letter.svg - data/img/mainviewwidget/DM-max-2x.png - data/img/mainviewwidget/DM-max.png - data/img/mainviewwidget/DM-max.svg data/img/mainviewwidget/downarrow-pressed.svg data/img/mainviewwidget/downarrow.svg - data/img/mainviewwidget/drop-down-2x.png - data/img/mainviewwidget/drop-down.png - data/img/mainviewwidget/drop-down.svg - data/img/mainviewwidget/Education-Checked.svg - data/img/mainviewwidget/Education-Disabled.svg - data/img/mainviewwidget/Education-Enabled.svg - data/img/mainviewwidget/Education-Normal.svg data/img/mainviewwidget/fixed.svg - data/img/mainviewwidget/full-all-2x.png - data/img/mainviewwidget/full-close-2x.png - data/img/mainviewwidget/full-close.png - data/img/mainviewwidget/full-close.svg - data/img/mainviewwidget/full-drop-down-2x.png - data/img/mainviewwidget/full-drop-down.png - data/img/mainviewwidget/full-drop-down.svg - data/img/mainviewwidget/full-function-2x.png - data/img/mainviewwidget/full-function.png - data/img/mainviewwidget/full-function.svg - data/img/mainviewwidget/full-letter-2x.png - data/img/mainviewwidget/full-letter.png - data/img/mainviewwidget/full-letter.svg - data/img/mainviewwidget/full-min-2x.png - data/img/mainviewwidget/full-min.png - data/img/mainviewwidget/full-min.svg - data/img/mainviewwidget/full-search-2x.png - data/img/mainviewwidget/full-search.png - data/img/mainviewwidget/full-search.svg - data/img/mainviewwidget/fullicon-all.png - data/img/mainviewwidget/fullicon-all.svg - data/img/mainviewwidget/function-2x.png - data/img/mainviewwidget/function.png - data/img/mainviewwidget/function.svg - data/img/mainviewwidget/Game-Checked.svg - data/img/mainviewwidget/Game-Disabled.svg - data/img/mainviewwidget/Game-Enabled.svg - data/img/mainviewwidget/Game-Normal.svg - data/img/mainviewwidget/icon- 返回.png - data/img/mainviewwidget/icon- 返回.svg - data/img/mainviewwidget/icon- 返回@2x.png - data/img/mainviewwidget/icon- 选项.png - data/img/mainviewwidget/icon- 选项.svg - data/img/mainviewwidget/icon- 选项@2x.png - data/img/mainviewwidget/icon- search-2x.png - data/img/mainviewwidget/icon- search.png - data/img/mainviewwidget/icon- search.svg - data/img/mainviewwidget/icon-check.png - data/img/mainviewwidget/icon-check.svg - data/img/mainviewwidget/icon-check@2x.png - data/img/mainviewwidget/Image-Checked.svg - data/img/mainviewwidget/Image-Disabled.svg - data/img/mainviewwidget/Image-Enabled.svg - data/img/mainviewwidget/Image-Normal.svg - data/img/mainviewwidget/Internet-Checked.svg - data/img/mainviewwidget/Internet-Disabled.svg - data/img/mainviewwidget/Internet-Enabled.svg - data/img/mainviewwidget/Internet-Normal.svg data/img/mainviewwidget/leftarrow-hover.svg data/img/mainviewwidget/leftarrow.svg - data/img/mainviewwidget/letter-2x.png - data/img/mainviewwidget/letter.png - data/img/mainviewwidget/letter.svg data/img/mainviewwidget/lock-fs.svg data/img/mainviewwidget/lock.svg - data/img/mainviewwidget/max-2x.png - data/img/mainviewwidget/max.png - data/img/mainviewwidget/max.svg - data/img/mainviewwidget/Mobile-Checked.svg - data/img/mainviewwidget/Mobile-Disabled.svg - data/img/mainviewwidget/Mobile-Enabled.svg - data/img/mainviewwidget/Mobile-Normal.svg - data/img/mainviewwidget/Office-Checked.svg - data/img/mainviewwidget/Office-Disabled.svg - data/img/mainviewwidget/Office-Enabled.svg - data/img/mainviewwidget/Office-Normal.svg - data/img/mainviewwidget/Others-Checked.svg - data/img/mainviewwidget/Others-Disabled.svg - data/img/mainviewwidget/Others-Enabled.svg - data/img/mainviewwidget/Others-Normal.svg - data/img/mainviewwidget/power-2x.png - data/img/mainviewwidget/power.png - data/img/mainviewwidget/power.svg data/img/mainviewwidget/recent-disabled.svg data/img/mainviewwidget/recent-enabled.svg data/img/mainviewwidget/recent-gray.svg @@ -130,26 +15,10 @@ data/img/mainviewwidget/rightarrow-hover.svg data/img/mainviewwidget/rightarrow.svg data/img/mainviewwidget/search.svg - data/img/mainviewwidget/select.svg - data/img/mainviewwidget/selected.svg - data/img/mainviewwidget/Social-Checked.svg - data/img/mainviewwidget/Social-Disabled.svg - data/img/mainviewwidget/Social-Enabled.svg - data/img/mainviewwidget/Social-Normal.svg - data/img/mainviewwidget/System-Checked.svg - data/img/mainviewwidget/System-Disabled.svg - data/img/mainviewwidget/System-Enabled.svg - data/img/mainviewwidget/System-Normal.svg - data/img/mainviewwidget/ukui-search-blue.svg - data/img/mainviewwidget/ukui-search.svg data/img/mainviewwidget/unfixed.svg data/img/mainviewwidget/uninstall.svg data/img/mainviewwidget/uparrow-pressed.svg data/img/mainviewwidget/uparrow.svg - data/img/mainviewwidget/Video-Checked.svg - data/img/mainviewwidget/Video-Disabled.svg - data/img/mainviewwidget/Video-Enabled.svg - data/img/mainviewwidget/Video-Normal.svg data/img/sidebarwidget/commonuse.svg data/img/sidebarwidget/computer.svg data/img/sidebarwidget/control.svg @@ -160,16 +29,59 @@ data/img/sidebarwidget/lock.svg data/img/sidebarwidget/max.svg data/img/sidebarwidget/min.svg - data/img/sidebarwidget/personal.svg data/img/sidebarwidget/rightarrow.svg data/img/sidebarwidget/setting.svg data/img/sidebarwidget/shutdown.svg - data/img/sidebarwidget/trash.svg data/img/sidebarwidget/unfixed.svg data/img/sidebarwidget/usericon-darkcolor.svg data/img/sidebarwidget/usericon-lightcolor.svg - src/BackProcess/Search/pinyinWithoutTone.txt - src/BackProcess/Search/pinyinWithTone.txt - data/img/mainviewwidget/DM-icon-option.svg + data/img/sidebarwidget/personal.svg + data/img/sidebarwidget/trash.svg + data/img/mainviewwidget/Development-Checked.svg + data/img/mainviewwidget/Development-Disabled.svg + data/img/mainviewwidget/Development-Enabled.svg + data/img/mainviewwidget/Development-Normal.svg + data/img/mainviewwidget/Education-Checked.svg + data/img/mainviewwidget/Education-Disabled.svg + data/img/mainviewwidget/Education-Enabled.svg + data/img/mainviewwidget/Education-Normal.svg + data/img/mainviewwidget/Game-Checked.svg + data/img/mainviewwidget/Game-Disabled.svg + data/img/mainviewwidget/Game-Enabled.svg + data/img/mainviewwidget/Game-Normal.svg + data/img/mainviewwidget/Image-Checked.svg + data/img/mainviewwidget/Image-Disabled.svg + data/img/mainviewwidget/Image-Enabled.svg + data/img/mainviewwidget/Image-Normal.svg + data/img/mainviewwidget/Internet-Checked.svg + data/img/mainviewwidget/Internet-Disabled.svg + data/img/mainviewwidget/Internet-Enabled.svg + data/img/mainviewwidget/Internet-Normal.svg + data/img/mainviewwidget/Office-Checked.svg + data/img/mainviewwidget/Office-Disabled.svg + data/img/mainviewwidget/Office-Enabled.svg + data/img/mainviewwidget/Office-Normal.svg + data/img/mainviewwidget/Others-Checked.svg + data/img/mainviewwidget/Others-Disabled.svg + data/img/mainviewwidget/Others-Enabled.svg + data/img/mainviewwidget/Others-Normal.svg + data/img/mainviewwidget/Social-Checked.svg + data/img/mainviewwidget/Social-Disabled.svg + data/img/mainviewwidget/Social-Enabled.svg + data/img/mainviewwidget/Social-Normal.svg + data/img/mainviewwidget/System-Checked.svg + data/img/mainviewwidget/System-Disabled.svg + data/img/mainviewwidget/System-Enabled.svg + data/img/mainviewwidget/System-Normal.svg + data/img/mainviewwidget/Video-Checked.svg + data/img/mainviewwidget/Video-Disabled.svg + data/img/mainviewwidget/Video-Enabled.svg + data/img/mainviewwidget/Video-Normal.svg + data/img/mainviewwidget/Mobile-Checked.svg + data/img/mainviewwidget/Mobile-Disabled.svg + data/img/mainviewwidget/Mobile-Enabled.svg + data/img/mainviewwidget/Mobile-Normal.svg + src/SearchResultWidget/pinyinWithTone.txt + src/SearchResultWidget/pinyinWithoutTone.txt diff --git a/src/BackProcess/DBus/dbus.cpp b/src/BackProcess/DBus/dbus.cpp deleted file mode 100644 index 42f7109..0000000 --- a/src/BackProcess/DBus/dbus.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "dbus.h" -#include -#include -#include "utility.h" - -DBus::DBus(QObject *parent) : QObject(parent) -{ -} - -void DBus::ReloadSecurityConfig() -{ - Q_EMIT sendReloadSignal(); -} - -QString DBus::GetSecurityConfigPath() -{ - QString path = QDir::homePath() + "/.config/ukui-menu-security-config.json"; - return path; -} - -void DBus::WinKeyResponse() -{ - Q_EMIT winKeyResponseSignal(); -} - -bool DBus::GetMenuStatus() -{ - return g_menuStatus; -} diff --git a/src/BackProcess/DBus/dbus.h b/src/BackProcess/DBus/dbus.h deleted file mode 100644 index 44f3be4..0000000 --- a/src/BackProcess/DBus/dbus.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef DBUS_H -#define DBUS_H - -#include - -class DBus : public QObject -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") -public: - explicit DBus(QObject *parent = 0); - -Q_SIGNALS: - void sendReloadSignal(); - void winKeyResponseSignal(); - -public Q_SLOTS: - QString GetSecurityConfigPath(); - void ReloadSecurityConfig(); - void WinKeyResponse(); - bool GetMenuStatus(); -}; - -#endif // DBUS_H diff --git a/src/BackProcess/FileWatcher/desktop_watcher.cpp b/src/BackProcess/FileWatcher/desktop_watcher.cpp deleted file mode 100644 index e3c6141..0000000 --- a/src/BackProcess/FileWatcher/desktop_watcher.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "desktop_watcher.h" -#include -#include - -DesktopWatcher::DesktopWatcher() -{ - //监控.desktop文件目录 - m_fileWatcher = new QFileSystemWatcher; - m_fileWatcher->addPaths(QStringList() << QString("/usr/share/applications") - << QString(QDir::homePath() + "/.local/share/applications/") - << QString("/var/lib/snapd/desktop/applications/") - << QString("/var/lib/flatpak/exports/share/applications/")); - connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &DesktopWatcher::directoryChangedSlot); - // m_recentFile = new QFileSystemWatcher; - // m_recentFile->addPath(QString(QDir::homePath()+"/.local/share/recently-used.xbel")); - // connect(m_recentFile,&QFileSystemWatcher::fileChanged,this,[=](){ - // m_recentFile->addPath(QDir::homePath()+"/.local/share/recently-used.xbel"); - // Q_EMIT updateRecentList();}); - m_directoryChangedThread = new DirectoryChangedThread; - connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &DesktopWatcher::requestUpdateSlot); -} - -/** - * desktop文件目录改变信号槽 - */ -void DesktopWatcher::directoryChangedSlot(const QString &path) -{ - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - m_directoryChangedThread->start(); -} - -void DesktopWatcher::requestUpdateSlot() -{ - m_directoryChangedThread->quit(); - Q_EMIT directoryChangedSignal(); -} diff --git a/src/BackProcess/FileWatcher/desktop_watcher.h b/src/BackProcess/FileWatcher/desktop_watcher.h deleted file mode 100644 index 874a98d..0000000 --- a/src/BackProcess/FileWatcher/desktop_watcher.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef DESKTOPWATCHER_H -#define DESKTOPWATCHER_H -#include -#include "directory_changed_thread.h" - - -class DesktopWatcher : public QObject -{ - Q_OBJECT -public: - DesktopWatcher(); - -public: -Q_SIGNALS: - /** - * @brief Desktop file directory change signal - */ - void directoryChangedSignal(); - void updateRecentList(); - -public Q_SLOTS: - - void directoryChangedSlot(const QString &path); - void requestUpdateSlot(); - -private: - QFileSystemWatcher *m_fileWatcher = nullptr; //Monitor desktop folder status -// QFileSystemWatcher *m_recentFile=nullptr; - DirectoryChangedThread *m_directoryChangedThread = nullptr; -}; - -#endif // DESKTOPWATCHER_H diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp deleted file mode 100644 index 1d01699..0000000 --- a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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 -#include -#include -#include "tabletlistview.h" -#include -#include - -TabletDirectoryChangedThread::TabletDirectoryChangedThread() -{ - m_ukuiMenuInterface = new UkuiMenuInterface; - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - setting = new QSettings(path, QSettings::IniFormat); -} - -TabletDirectoryChangedThread::~TabletDirectoryChangedThread() -{ - if (m_ukuiMenuInterface) { - delete m_ukuiMenuInterface; - } - - if (setting) { - delete setting; - } - - m_ukuiMenuInterface = nullptr; - setting = nullptr; -} - - -void TabletDirectoryChangedThread::run() -{ - QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath(); - myDebug() << "应用列表desktopfpList" << desktopfpList.size() << desktopfpList; - myDebug() << "应用列表desktopfpVector" << UkuiMenuInterface::desktopfpVector.size() << UkuiMenuInterface::desktopfpVector; - QString m_desktopfp; - - for (int i = 0; i < desktopfpList.count(); i++) { - myDebug() << desktopfpList.at(i) << "是否存在于已安装应用列表中" << - UkuiMenuInterface::desktopfpVector.contains(QString(desktopfpList.at(i))); - - if (!UkuiMenuInterface::desktopfpVector.contains(QString(desktopfpList.at(i)))) { - m_desktopfp = desktopfpList.at(i); - myDebug() << "安装应用" << m_desktopfp; - //获取当前时间戳 - QDateTime dt = QDateTime::currentDateTime(); - int datetime = dt.toTime_t(); - QString str = desktopfpList.at(i).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - QString desktopfn = str; - setting->beginGroup("recentapp"); - setting->setValue(desktopfn, datetime); - setting->sync(); - setting->endGroup(); - //wgx - setting->beginGroup("application"); - QStringList applist = setting->allKeys(); - int appnum = setting->allKeys().count(); - int maxindex = 0; - - for (int i = 0; i < appnum; i++) { - if (setting->value(applist.at(i)).toInt() > maxindex) { - maxindex = setting->value(applist.at(i)).toInt(); - } - } - - setting->setValue(desktopfn, maxindex + 1); //setting->allKeys().count() - setting->sync(); - setting->endGroup(); - // - QString iconstr = m_ukuiMenuInterface->getAppIcon(desktopfpList.at(i)); - syslog(LOG_LOCAL0 | LOG_DEBUG, "%s", iconstr.toLocal8Bit().data()); - syslog(LOG_LOCAL0 | LOG_DEBUG, "软件安装desktop文件名:%s", desktopfn.toLocal8Bit().data()); - - Q_FOREACH (QString path, QIcon::themeSearchPaths()) { - syslog(LOG_LOCAL0 | LOG_DEBUG, "%s", path.toLocal8Bit().data()); - } - } - } - - for (int i = 0; i < UkuiMenuInterface::desktopfpVector.count(); i++) { - if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) { - QString desktopfp = UkuiMenuInterface::desktopfpVector.at(i); - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - myDebug() << "卸载" << desktopfn; - setting->beginGroup("lockapplication"); - setting->remove(desktopfn); - setting->sync(); - setting->endGroup(); - setting->beginGroup("application"); - - if (!setting->contains(desktopfn)) { - setting->sync(); - setting->endGroup(); - continue; - } - - int val = setting->value(desktopfn).toInt(); - myDebug() << "卸载val" << val; - setting->remove(desktopfn); - QStringList desktopfnList = setting->allKeys(); - - for (int i = 0; i < desktopfnList.count(); i++) { - if (setting->value(desktopfnList.at(i)).toInt() > val) { - setting->setValue(desktopfnList.at(i), setting->value(desktopfnList.at(i)).toInt() - 1); - } - } - - setting->sync(); - setting->endGroup(); - setting->beginGroup("recentapp"); - setting->remove(desktopfn); - setting->sync(); - setting->endGroup(); - syslog(LOG_LOCAL0 | LOG_DEBUG, "软件卸载desktop文件名:%s", desktopfn.toLocal8Bit().data()); - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - iface.call("RemoveFromTaskbar", desktopfp); - } - } - - UkuiMenuInterface::appInfoVector.clear(); - UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); - Q_EMIT requestUpdateSignal(m_desktopfp); -} diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h deleted file mode 100644 index 279dec1..0000000 --- a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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 -#include -#include -#include "ukuimenuinterface.h" -#include -#include - -class TabletDirectoryChangedThread: public QThread -{ - Q_OBJECT -public: - TabletDirectoryChangedThread(); - ~TabletDirectoryChangedThread(); - void run(); - -private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QSettings *setting = nullptr; - TabletListView *m_listView = nullptr; - QStandardItemModel *listmodel = nullptr; - - int index = 0; - -Q_SIGNALS: - /** - * @brief Request update signal - */ - void requestUpdateSignal(QString desktopfp); - void deleteAppSignal(); - -}; - -#endif // DIRECTORYCHANGEDTHREAD_H diff --git a/src/BackProcess/Interface/currenttime_interface.cpp b/src/BackProcess/Interface/currenttime_interface.cpp deleted file mode 100644 index 4608040..0000000 --- a/src/BackProcess/Interface/currenttime_interface.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "currenttime_interface.h" -#include -#define TIME_FORMAT "org.ukui.control-center.panel.plugins" -#define TIME_FORMAT_KEY "hoursystem" -#include -#include - -CurrentTimeInterface::CurrentTimeInterface() -{ - //获得语言环境 - dateTime = new QDateTime; - myTimer = new QTimer(); - myTimer->start(1000); - - if (QGSettings::isSchemaInstalled(TIME_FORMAT)) { - timeSetting = new QGSettings(TIME_FORMAT); - - if (timeSetting->keys().contains(TIME_FORMAT_KEY) && timeSetting->keys().contains("date")) { - timeFormat = timeSetting->get(TIME_FORMAT_KEY).toString(); - timeSlash = timeSetting->get("date").toString(); - getDateTime(timeFormat); - connect(timeSetting, &QGSettings::changed, this, [ = ](const QString & key) { - if (key == "hoursystem") { - timeFormat = timeSetting->get(TIME_FORMAT_KEY).toString(); - getDateTime(timeFormat); - } else if (key == "date") { - timeSlash = timeSetting->get("date").toString(); - - if (timeSlash == "en") { - currentDate = currentDate.replace("/", "-"); - } else { - currentDate = currentDate.replace("-", "/"); - } - } - }); - } - } - - connect(myTimer, &QTimer::timeout, [this]() { - getDateTime(timeFormat); - }); -} - -CurrentTimeInterface::~CurrentTimeInterface() -{ - if (myTimer) { - delete myTimer; - } - - if (timeSetting) { - delete timeSetting; - } - - if (dateTime) { - delete dateTime; - } - - myTimer = nullptr; - timeSetting = nullptr; - dateTime = nullptr; -} - -void CurrentTimeInterface::getDateTime(QString timeFormat) -{ - if (timeFormat == "12") { - twelveHourTime(); - } else if (timeFormat == "24") { - twentyFourHourTime(); - } - - if (timeSlash == "cn") { - currentDate = currentDate.replace("-", "/"); - } -} - -//12制小时时间 -void CurrentTimeInterface::twelveHourTime() -{ - currentTime = dateTime->currentDateTime().time().toString("hh:mm AP").split(" ").first(); - currentDate = dateTime->currentDateTime().date().toString("ddd MM-dd"); - currentWeek = dateTime->currentDateTime().time().toString("AP"); -} - -//24小时制时间 -void CurrentTimeInterface::twentyFourHourTime() -{ - currentTime = dateTime->currentDateTime().time().toString("hh:mm"); - currentDate = dateTime->currentDateTime().date().toString("MM-dd"); - currentWeek = dateTime->currentDateTime().date().toString("ddd"); -} diff --git a/src/BackProcess/Interface/currenttime_interface.h b/src/BackProcess/Interface/currenttime_interface.h deleted file mode 100644 index cf08151..0000000 --- a/src/BackProcess/Interface/currenttime_interface.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef CURRENTTIMEINTERFACE_H -#define CURRENTTIMEINTERFACE_H -#include -#include -#include -#include -#include -#include - -class CurrentTimeInterface : QObject -{ - -public: - CurrentTimeInterface(); - ~CurrentTimeInterface(); - - QString currentTime; - QString currentWeek; - QString currentDate; - -protected: - void twelveHourTime(); - void twentyFourHourTime(); - void getDateTime(QString timeFormat); - -private: - QDateTime *dateTime; - QTimer *myTimer; - QGSettings *timeSetting = nullptr; - QString timeFormat; - QString timeSlash; - -}; - -#endif // CURRENTTIMEINTERFACE_H diff --git a/src/BackProcess/Interface/ukui_chineseletter.cpp b/src/BackProcess/Interface/ukui_chineseletter.cpp deleted file mode 100644 index 882be2f..0000000 --- a/src/BackProcess/Interface/ukui_chineseletter.cpp +++ /dev/null @@ -1,6252 +0,0 @@ -/* - * 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 -#include - -UkuiChineseLetter::UkuiChineseLetter() -{ -} - -bool UkuiChineseLetter::In(wchar_t start, wchar_t end, wchar_t code) -{ - if (code >= start && code <= end) { - return true; - } - - return false; -} - -char UkuiChineseLetter::Convert(int n)//此方法有缺陷,只能识别一级字库中的汉字 -{ - /* - * GB2312码范围 (B0A1-F7FE) - * HiByte (B0-F7) LoByte (A1-FE) - * - * GBK编码范围 (8140-FEFE) - * 包含三大部分 - * 1.汉字区 - * a. GB2312汉字区。即GBK/2 - * b. GB13000.1扩充汉字区。包括GBK/3(CJK汉字)和GBK/4(CJK汉字和增补汉字) - * 2.图形符号区 - * a. GB2312非汉字区。即GBK/1 A1A1-A9FE。还有10个小写罗马数字和GB12345增补符号 - * b. GB13000.1扩充非汉字区。即GBK/5 A840-A9A0非汉字符号、结构符... - * 3.用户自定义区 - * - */ - if (In(0xB0A1, 0xB0C4, n)) { - return 'A'; - } - - if (In(0XB0C5, 0XB2C0, n)) { - return 'B'; - } - - if (In(0xB2C1, 0xB4ED, n)) { - return 'C'; - } - - if (In(0xB4EE, 0xB6E9, n)) { - return 'D'; - } - - if (In(0xB6EA, 0xB7A1, n)) { - return 'E'; - } - - if (In(0xB7A2, 0xB8c0, n)) { - return 'F'; - } - - if (In(0xB8C1, 0xB9FD, n)) { - return 'G'; - } - - if (In(0xB9FE, 0xBBF6, n)) { - return 'H'; - } - - if (In(0xBBF7, 0xBFA5, n)) { - return 'J'; - } - - if (In(0xBFA6, 0xC0AB, n)) { - return 'K'; - } - - if (In(0xC0AC, 0xC2E7, n)) { - return 'L'; - } - - if (In(0xC2E8, 0xC4C2, n)) { - return 'M'; - } - - if (In(0xC4C3, 0xC5B5, n)) { - return 'N'; - } - - if (In(0xC5B6, 0xC5BD, n)) { - return 'O'; - } - - if (In(0xC5BE, 0xC6D9, n)) { - return 'P'; - } - - if (In(0xC6DA, 0xC8BA, n)) { - return 'Q'; - } - - if (In(0xC8BB, 0xC8F5, n)) { - return 'R'; - } - - if (In(0xC8F6, 0xCBF0, n)) { - return 'S'; - } - - if (In(0xCBFA, 0xCDD9, n)) { - return 'T'; - } - - if (In(0xCDDA, 0xCEF3, n)) { - return 'W'; - } - - if (In(0xCEF4, 0xD1B8, n)) { - return 'X'; - } - - if (In(0xD1B9, 0xD4D0, n)) { - return 'Y'; - } - - if (In(0xD4D1, 0xD7F9, n)) { - return 'Z'; - } - - if (In(0x00, 0x7f, n)) { - return n; - } - - return '\0'; -} - -QString UkuiChineseLetter::getFirstLetter(const QString &src) -{ - // wchar_t wchr = 0; - // QString firstLetter; - // if(src.size() > 0) - // { - // QString str = src.at(0); - // QTextCodec* pCodec = QTextCodec::codecForName("gb2312"); - // if(!pCodec) return QChar(' '); - // QByteArray arr = pCodec->fromUnicode(str); - // if(arr.size() == 1) - // { - // wchr = arr.at(0) & 0xff; - // } - // else if(arr.size() == 2) - // { - // wchr = (arr.at(0) & 0xff) << 8; - // wchr |= (arr.at(1) & 0xff); - // } - // else - // { - //// qDebug() << "unknown word"; - // } - // char c = Convert(wchr); - // if(c != 0) - // { - // firstLetter.append(c); - // } - // } - QString appnamePy = getPinyins(src); - - if (!appnamePy.isEmpty()) { - return QString(appnamePy.at(0)); - } else { - return QString(); - } -} - -QString UkuiChineseLetter::getFirstLetters(const QString &src) -{ - QString firstLetters; - - for (int i = 0; i < src.length(); i++) { - QString str = src.at(i); - QTextCodec *pCodec = QTextCodec::codecForName("gb2312"); - - if (!pCodec) { - return QChar(' '); - } - - QByteArray arr = pCodec->fromUnicode(str); - wchar_t wchr = 0; - - if (arr.size() == 1) { - wchr = arr.at(0) & 0xff; - } else if (arr.size() == 2) { - wchr = (arr.at(0) & 0xff) << 8; - wchr |= (arr.at(1) & 0xff); - } else { - //qDebug() << "unknown word"; - } - - char c = Convert(wchr); - - if (c != 0) { - firstLetters.append(c); - } - } - - return firstLetters; -} - -QString UkuiChineseLetter::getFirstLettersAll(const QString &src) -{ - QString pinyins; - - for (int i = 0; i < src.length(); i++) { - QString str = src.at(i); - QTextCodec *pCodec = QTextCodec::codecForName("gb2312"); - - if (!pCodec) { - return QChar(' '); - } - - QByteArray arr = pCodec->fromUnicode(str); - unsigned char high = 0; - unsigned char low = 0; - int code = 0; - - if (arr.size() == 1) { - high = 0; - low = arr.at(0) & 0xff; - } else if (arr.size() == 2) { - high = arr.at(0) & 0xff; - low = arr.at(1) & 0xff; - } - - if (high < 0xa1 || low < 0xa1) { - continue; - } else { - code = (high - 0xa0) * 100 + low - 0xa0; - } - - pinyins += getPinyin(code).at(0); - } - - return pinyins; -} - - -QString UkuiChineseLetter::getPinyins(const QString &text) -{ - QString pinyins; - - for (int i = 0; i < text.length(); i++) { - QChar c = text.at(i); - - if ((c >= 0 && c <= 127)) { - pinyins += c.toUpper(); - continue; - } - - QString str = text.at(i); - QTextCodec *pCodec = QTextCodec::codecForName("gb2312"); - - if (!pCodec) { - return QChar(' '); - } - - QByteArray arr = pCodec->fromUnicode(str); - unsigned char high = 0; - unsigned char low = 0; - int code = 0; - - if (arr.size() == 1) { - high = 0; - low = arr.at(0) & 0xff; - } else if (arr.size() == 2) { - high = arr.at(0) & 0xff; - low = arr.at(1) & 0xff; - } - - if (high < 0xa1 || low < 0xa1) { - continue; - } else { - code = (high - 0xa0) * 100 + low - 0xa0; - } - - pinyins += getPinyin(code); - } - - return pinyins; -} - - -QString UkuiChineseLetter::getPinyin(int code)//此方法可以获取所有汉字的拼音 -{ - QString pinyin; - - switch (code) { - case 6325: - case 6436: - case 7571: - case 7925: - pinyin = "A"; - break; - - case 6263: - case 6440: - case 7040: - case 7208: - case 7451: - case 7733: - case 7945: - case 8616: - pinyin = "AI"; - break; - - case 5847: - case 5991: - case 6278: - case 6577: - case 6654: - case 7281: - case 7907: - case 8038: - case 8786: - pinyin = "AN"; - break; - pinyin = "ANG"; - break; - - case 5974: - case 6254: - case 6427: - case 6514: - case 6658: - case 6959: - case 7033: - case 7081: - case 7365: - case 8190: - case 8292: - case 8643: - case 8701: - case 8773: - pinyin = "AO"; - break; - - case 6056: - case 6135: - case 6517: - case 7857: - case 8446: - case 8649: - case 8741: - pinyin = "BA"; - break; - - case 6267: - case 6334: - case 7494: - pinyin = "BAI"; - break; - - case 5870: - case 5964: - case 7851: - case 8103: - case 8113: - case 8418: - pinyin = "BAN"; - break; - - case 6182: - case 6826: - pinyin = "BANG"; - break; - - case 6165: - case 7063: - case 7650: - case 8017: - case 8157: - case 8532: - case 8621: - pinyin = "BAO"; - break; - - case 5635: - case 5873: - case 5893: - case 5993: - case 6141: - case 6703: - case 7753: - case 8039: - case 8156: - case 8645: - case 8725: - pinyin = "BEI"; - break; - - case 5946: - case 5948: - case 7458: - case 7928: - pinyin = "BEN"; - break; - - case 6452: - case 7420: - pinyin = "BENG"; - break; - - case 5616: - case 5734: - case 6074: - case 6109: - case 6221: - case 6333: - case 6357: - case 6589: - case 6656: - case 6725: - case 6868: - case 6908: - case 6986: - case 6994: - case 7030: - case 7052: - case 7221: - case 7815: - case 7873: - case 7985: - case 8152: - case 8357: - case 8375: - case 8387: - case 8416: - case 8437: - case 8547: - case 8734: - pinyin = "BI"; - break; - - case 5650: - case 5945: - case 6048: - case 6677: - case 6774: - case 7134: - case 7614: - case 7652: - case 7730: - case 7760: - case 8125: - case 8159: - case 8289: - case 8354: - case 8693: - pinyin = "BIAN"; - break; - - case 7027: - case 7084: - case 7609: - case 7613: - case 7958: - case 7980: - case 8106: - case 8149: - case 8707: - case 8752: - pinyin = "BIAO"; - break; - - case 8531: - pinyin = "BIE"; - break; - - case 5747: - case 6557: - case 7145: - case 7167: - case 7336: - case 7375: - case 7587: - case 7957: - case 8738: - case 8762: - pinyin = "BIN"; - break; - - case 5787: - case 5891: - case 6280: - pinyin = "BING"; - break; - - case 5781: - case 6403: - case 6636: - case 7362: - case 7502: - case 7771: - case 7864: - case 8030: - case 8404: - case 8543: - case 8559: - pinyin = "BO"; - break; - - case 6318: - case 6945: - case 7419: - case 7446: - case 7848: - case 7863: - case 8519: - pinyin = "BU"; - break; - - case 6474: - case 7769: - pinyin = "CA"; - break; - pinyin = "CAI"; - break; - - case 6978: - case 7078: - case 7218: - case 8451: - case 8785: - pinyin = "CAN"; - break; - - case 5687: - pinyin = "CANG"; - break; - - case 6448: - case 6878: - case 8309: - case 8429: - pinyin = "CAO"; - break; - - case 6692: - pinyin = "CE"; - break; - - case 6515: - case 6825: - pinyin = "CEN"; - break; - - case 6465: - pinyin = "CENG"; - break; - - case 6639: - case 6766: - case 7017: - case 7230: - case 7311: - case 7322: - case 7363: - case 7942: - case 7979: - case 8135: - pinyin = "CHA"; - break; - - case 5713: - case 7846: - case 8091: - case 8218: - pinyin = "CHAI"; - break; - - case 5770: - case 5838: - case 6159: - case 6667: - case 6893: - case 6904: - case 6981: - case 7031: - case 7086: - case 7472: - case 7688: - case 7966: - case 8324: - case 8580: - pinyin = "CHAN"; - break; - - case 5686: - case 5943: - case 6041: - case 6137: - case 6660: - case 6568: - case 6749: - case 7029: - case 7047: - case 7438: - case 7509: - case 8680: - pinyin = "CHANG"; - break; - - case 6687: - case 7443: - case 8173: - pinyin = "CHAO"; - break; - - case 5969: - case 7726: - pinyin = "CHE"; - break; - - case 5840: - case 5863: - case 6251: - case 6433: - case 6923: - case 7201: - case 7320: - case 7755: - case 8619: - pinyin = "CHEN"; - break; - - case 5609: - case 5984: - case 7239: - case 7263: - case 7583: - case 7810: - case 7881: - case 7905: - case 8146: - case 8241: - case 8508: - pinyin = "CHENG"; - break; - - case 5749: - case 6015: - case 6061: - case 6319: - case 6374: - case 6420: - case 6445: - case 6633: - case 7042: - case 7523: - case 7787: - case 8023: - case 8101: - case 8161: - case 8231: - case 8304: - case 8355: - case 8388: - case 8489: - case 8556: - case 8746: - pinyin = "CHI"; - break; - - case 6091: - case 6671: - case 6731: - case 8409: - case 8430: - pinyin = "CHONG"; - break; - - case 5717: - case 6492: - case 6716: - case 8112: - case 8637: - pinyin = "CHOU"; - break; - - case 5601: - case 5927: - case 6680: - case 6732: - case 7109: - case 7238: - case 7290: - case 7343: - case 8150: - case 8260: - case 8573: - case 8777: - pinyin = "CHU"; - break; - - case 6285: - case 6408: - case 7590: - case 8563: - pinyin = "CHUAI"; - break; - - case 6622: - case 6955: - case 7516: - case 7843: - case 8413: - pinyin = "CHUAN"; - break; - - case 6675: - pinyin = "CHUANG"; - break; - - case 5879: - case 7302: - case 7319: - pinyin = "CHUI"; - break; - - case 6127: - case 8040: - case 8277: - pinyin = "CHUN"; - break; - - case 7401: - case 8554: - case 8626: - pinyin = "CHUO"; - break; - pinyin = "CI"; - break; - - case 6075: - case 6358: - case 7684: - case 8043: - case 8457: - pinyin = "4337 伺"; - break; - - case 6042: - case 6840: - case 7085: - case 7193: - case 7214: - case 7240: - pinyin = "CONG"; - break; - - case 7308: - case 7403: - case 7577: - pinyin = "COU"; - break; - - case 6180: - case 6562: - case 6607: - case 7367: - case 8501: - case 8530: - case 8577: - pinyin = "CU"; - break; - - case 5764: - case 6305: - case 7664: - case 7973: - pinyin = "CUAN"; - break; - - case 6718: - case 6145: - case 6393: - case 7213: - case 7333: - case 7505: - case 8631: - pinyin = "CUI"; - break; - - case 6666: - case 8169: - pinyin = "CUN"; - break; - - case 5640: - case 6547: - case 7566: - case 7917: - case 7983: - case 8078: - case 8526: - case 8567: - pinyin = "CUO"; - break; - - case 6239: - case 6353: - case 6410: - case 6682: - case 7007: - case 8155: - case 8346: - case 8716: - case 8718: - pinyin = "DA"; - break; - - case 6004: - case 6316: - case 6523: - case 6942: - case 7110: - case 7173: - case 8776: - pinyin = "DAI"; - break; - - case 5757: - case 6144: - case 6402: - case 7373: - case 7470: - case 7781: - case 8067: - case 8087: - case 8185: - case 8376: - pinyin = "DAN"; - break; - - case 5852: - case 5942: - case 6148: - case 6920: - case 7724: - case 7885: - case 8141: - pinyin = "DANG"; - break; - - case 6322: - case 6665: - case 7514: - case 8478: - pinyin = "DAO"; - break; - - case 7929: - pinyin = "DE"; - break; - - case 6466: - case 6556: - case 7413: - case 7767: - case 7975: - case 8403: - pinyin = "DENG"; - break; - - case 5621: - case 5765: - case 5814: - case 5848: - case 5901: - case 5970: - case 6122: - case 6454: - case 7023: - case 7116: - case 7260: - case 7306: - case 7475: - case 7738: - case 7758: - case 7791: - case 7965: - case 8438: - case 8730: - pinyin = "DI"; - break; - - case 6439: - pinyin = "DIA"; - break; - - case 5871: - case 5967: - case 6559: - case 7172: - case 7868: - case 8116: - case 8118: - case 8401: - case 8558: - pinyin = "DIAN"; - break; - - case 7886: - case 8585: - case 8684: - pinyin = "DIAO"; - break; - - case 5976: - case 6006: - case 6273: - case 6409: - case 7526: - case 8012: - case 8183: - case 8562: - case 8688: - pinyin = "DIE"; - break; - - case 5674: - case 6404: - case 7164: - case 7575: - case 7754: - case 7814: - case 8059: - case 8184: - case 8490: - pinyin = "DING"; - break; - - case 7891: - pinyin = "DIU"; - break; - - case 5977: - case 6343: - case 6520: - case 6528: - case 7517: - case 7543: - case 7556: - case 7747: - case 8020: - pinyin = "DONG"; - break; - - case 6190: - case 8128: - case 8229: - case 8391: - pinyin = "DOU"; - break; - - case 6022: - case 6429: - case 6834: - case 7292: - case 7525: - case 8328: - case 8338: - case 8739: - case 8782: - pinyin = "DU"; - break; - - case 7318: - case 7649: - case 8393: - pinyin = "DUAN"; - break; - - case 7701: - case 7713: - case 7752: - pinyin = "DUI"; - break; - - case 6771: - case 7632: - case 7727: - case 7766: - case 7779: - case 7970: - case 8527: - pinyin = "DUN"; - break; - - case 6345: - case 6365: - case 6785: - case 7122: - case 7876: - case 8154: - case 8566: - pinyin = "DUO"; - break; - - case 5612: - case 5832: - case 5844: - case 5949: - case 6035: - case 6113: - case 6164: - case 6332: - case 6721: - case 6977: - case 7025: - case 7378: - case 7581: - case 7916: - case 7941: - case 8042: - case 8206: - case 8689: - pinyin = "E"; - break; - - case 6176: - case 6284: - pinyin = "EN"; - break; - - case 5706: - case 6939: - case 7177: - case 7879: - case 8025: - case 8660: - pinyin = "ER"; - break; - - case 5950: - case 7732: - pinyin = "FA"; - break; - - case 6212: - case 6232: - case 6506: - case 7283: - case 7660: - case 7818: - case 8576: - pinyin = "FAN"; - break; - - case 5890: - case 7242: - case 7853: - case 8419: - case 8648: - pinyin = "FANG"; - break; - - case 6032: - case 6584: - case 6713: - case 6839: - case 6990: - case 7119: - case 7328: - case 7572: - case 7619: - case 7673: - case 7948: - case 8082: - case 8267: - case 8385: - case 8468: - case 8613: - case 8678: - pinyin = "FEI"; - break; - - case 5739: - case 6915: - case 7291: - case 8687: - case 8787: - pinyin = "FEN"; - break; - - case 5726: - case 5926: - case 6155: - case 6384: - case 6767: - case 7731: - pinyin = "FENG"; - break; - pinyin = "FO"; - break; - - case 8330: - pinyin = "FOU"; - break; - - case 5775: - case 5776: - case 5914: - case 6029: - case 6062: - case 6119: - case 6142: - case 6252: - case 6327: - case 6505: - case 6686: - case 6870: - case 6985: - case 7058: - case 7066: - case 7106: - case 7108: - case 7285: - case 7471: - case 7680: - case 7741: - case 7774: - case 7775: - case 7823: - case 7991: - case 8005: - case 8222: - case 8261: - case 8280: - case 8283: - case 8479: - case 8535: - case 8538: - case 8654: - case 8691: - pinyin = "FU"; - break; - - case 6246: - case 7056: - case 7057: - case 7424: - case 7837: - pinyin = " GA"; - break; - - case 5604: - case 5875: - case 5982: - case 7414: - case 7464: - pinyin = "GAI"; - break; - - case 5965: - case 6053: - case 6247: - case 6306: - case 6779: - case 6838: - case 6887: - case 7104: - case 7347: - case 7426: - case 7723: - case 8065: - case 8491: - pinyin = "GAN"; - break; - - case 7716: - case 7824: - case 8364: - pinyin = "GANG"; - break; - - case 5626: - case 5830: - case 5912: - case 6227: - case 7141: - case 7332: - case 7334: - case 7429: - case 7915: - pinyin = "GAO"; - break; - - case 5610: - case 5678: - case 5933: - case 5957: - case 6010: - case 6435: - case 7092: - case 7501: - case 7585: - case 7749: - case 7951: - case 8143: - case 8220: - case 8420: - case 8732: - pinyin = "GE"; - break; - pinyin = "GEI"; - break; - - case 5608: - case 6102: - case 6371: - case 8462: - pinyin = "GEN"; - break; - - case 6376: - case 6657: - case 7114: - case 8665: - pinyin = "GENG"; - break; - - case 7178: - case 7537: - case 8228: - case 8601: - pinyin = "GONG"; - break; - - case 5694: - case 5824: - case 6524: - case 6960: - case 7037: - case 7135: - case 7259: - case 7477: - case 7616: - case 8349: - case 8384: - case 8724: - pinyin = "GOU"; - break; - - case 5637: - case 5812: - case 6152: - case 6536: - case 6773: - case 7284: - case 7379: - case 7484: - case 7486: - case 7591: - case 7617: - case 7813: - case 7825: - case 7860: - case 7932: - case 8019: - case 8083: - case 8233: - case 8494: - case 8593: - case 8681: - case 8729: - pinyin = "GU"; - break; - - case 5652: - case 5820: - case 6341: - case 7273: - case 7550: - case 8027: - pinyin = "GUA"; - break; - pinyin = "GUAI"; - break; - - case 5736: - case 6124: - case 6272: - case 6842: - case 7834: - case 8057: - case 8170: - case 8704: - pinyin = "GUAN"; - break; - - case 6359: - case 6578: - case 7270: - case 7555: - pinyin = "GUANG"; - break; - - case 5648: - case 5659: - case 6649: - case 7003: - case 7277: - case 7433: - case 7448: - case 8007: - case 8394: - case 8657: - case 8712: - pinyin = "GUI"; - break; - - case 5782: - case 7121: - case 7762: - case 8671: - pinyin = "GUN"; - break; - - case 5769: - case 6266: - case 6335: - case 6494: - case 6538: - case 6603: - case 7304: - case 7529: - case 8188: - case 8268: - case 8269: - pinyin = "GUO"; - break; - - case 7894: - pinyin = "HA"; - break; - - case 6443: - case 7560: - case 8516: - pinyin = "HAI"; - break; - - case 5885: - case 6153: - case 6294: - case 6759: - case 6911: - case 7447: - case 7642: - case 8192: - case 8205: - case 8232: - case 8793: - pinyin = "HAN"; - break; - - case 6776: - case 7112: - case 8194: - pinyin = "HANG"; - break; - - case 6179: - case 6222: - case 6438: - case 6467: - case 6909: - case 6916: - case 7427: - case 8009: - case 8211: - case 8226: - pinyin = "HAO"; - break; - - case 5813: - case 5932: - case 5954: - case 6432: - case 6756: - case 7434: - case 7833: - case 8202: - case 8234: - case 8471: - pinyin = "HE"; - break; - pinyin = "HEI"; - break; - pinyin = "HEN"; - break; - - case 6231: - case 7181: - case 7276: - pinyin = "HENG"; - break; - - case 5768: - case 5774: - case 5807: - case 6106: - case 6214: - case 6216: - case 6740: - case 6792: - pinyin = "HONG"; - break; - - case 6009: - case 6565: - case 6943: - case 8090: - case 8383: - case 8455: - case 8655: - case 8731: - pinyin = "HOU"; - break; - - case 5792: - case 6392: - case 6481: - case 6518: - case 6609: - case 6679: - case 6717: - case 6816: - case 6879: - case 7190: - case 7346: - case 7385: - case 7618: - case 7635: - case 7646: - case 7670: - case 7672: - case 7679: - case 8013: - case 8032: - case 8041: - case 8055: - case 8343: - case 8513: - case 8590: - pinyin = "HU"; - break; - - case 7072: - case 7275: - case 7725: - case 7892: - pinyin = "HUA"; - break; - - case 8555: - pinyin = "HUAI"; - break; - - case 5928: - case 6140: - case 6307: - case 6487: - case 6621: - case 6801: - case 6829: - case 6881: - case 6930: - case 6953: - case 7157: - case 7944: - case 8673: - case 8763: - pinyin = "HUAN"; - break; - - case 5882: - case 6569: - case 6850: - case 6874: - case 6956: - case 7211: - case 7533: - case 8105: - case 8308: - case 8382: - case 8692: - pinyin = "HUANG"; - break; - - case 5822: - case 6078: - case 6086: - case 6205: - case 6352: - case 6360: - case 6425: - case 6736: - case 6807: - case 6811: - case 6971: - case 7132: - case 7185: - case 7445: - case 7703: - case 8219: - case 8319: - case 8766: - pinyin = "HUI"; - break; - - case 5827: - case 6638: - case 6752: - case 6867: - pinyin = "HUN"; - break; - - case 5669: - case 6229: - case 6311: - case 6475: - case 6623: - case 7856: - case 7933: - case 7976: - case 8175: - case 8322: - pinyin = "HUO"; - break; - - case 5629: - case 5632: - case 5662: - case 5705: - case 5742: - case 5952: - case 6024: - case 6033: - case 6193: - case 6210: - case 6265: - case 6320: - case 6350: - case 6383: - case 6507: - case 6553: - case 6809: - case 6976: - case 7087: - case 7160: - case 7165: - case 7314: - case 7374: - case 7410: - case 7411: - case 7469: - case 7473: - case 7487: - case 7620: - case 7722: - case 7831: - case 7990: - case 8002: - case 8104: - case 8217: - case 8337: - case 8339: - case 8463: - case 8550: - case 8611: - case 8661: - case 8674: - case 8757: - case 8768: - pinyin = "JI"; - break; - - case 5704: - case 5903: - case 6171: - case 6521: - case 6804: - case 6940: - case 7176: - case 7409: - case 7546: - case 7702: - case 7882: - case 7956: - case 8072: - case 8142: - case 8244: - case 8353: - case 8434: - case 8542: - pinyin = "JIA"; - break; - - case 5752: - case 5841: - case 5857: - case 6149: - case 6183: - case 6286: - case 6853: - case 6931: - case 6932: - case 7144: - case 7237: - case 7305: - case 7407: - case 7415: - case 7480: - case 7489: - case 7506: - case 7576: - case 7790: - case 7921: - case 8047: - case 8148: - case 8340: - case 8469: - case 8534: - case 8561: - case 8668: - case 8721: - pinyin = "JIAN"; - break; - - case 6092: - case 6814: - case 7113: - case 7154: - case 7481: - case 7768: - case 8180: - case 8461: - case 8488: - pinyin = "JIANG"; - break; - - case 5714: - case 5753: - case 6020: - case 6090: - case 6256: - case 6461: - case 6572: - case 7015: - case 7524: - case 8008: - case 8052: - case 8252: - case 8520: - case 8551: - case 8662: - pinyin = "JIAO"; - break; - - case 5806: - case 5821: - case 6255: - case 6414: - case 7028: - case 7061: - case 7278: - case 7757: - case 8060: - case 8201: - case 8227: - case 8441: - case 8658: - case 8726: - pinyin = "JIE"; - break; - - case 5865: - case 6103: - case 6132: - case 6468: - case 6643: - case 6659: - case 7138: - case 7210: - case 7340: - case 7465: - case 7478: - case 8138: - pinyin = "JIN"; - break; - - case 5751: - case 5869: - case 6128: - case 6616: - case 6729: - case 6794: - case 6941: - case 6982: - case 7026: - case 7534: - case 7554: - case 7570: - case 7626: - pinyin = "JIANG"; - break; - - case 6936: - case 7671: - pinyin = "JIONG"; - break; - - case 5754: - case 6417: - case 6746: - case 7249: - case 7274: - case 8015: - case 8053: - case 8481: - case 8761: - pinyin = "JIU"; - break; - - case 5738: - case 5810: - case 6036: - case 6058: - case 6076: - case 6268: - case 6965: - case 6980: - case 7202: - case 7307: - case 7316: - case 7323: - case 7357: - case 7381: - case 7488: - case 7611: - case 7850: - case 7924: - case 8022: - case 8132: - case 8153: - case 8482: - case 8522: - case 8565: - case 8620: - case 8634: - case 8722: - pinyin = "JU"; - break; - - case 5918: - case 6590: - case 6824: - case 7280: - case 7835: - case 7935: - case 7952: - case 8633: - pinyin = "JUAN"; - break; - - case 5642: - case 5667: - case 5860: - case 5939: - case 6207: - case 6421: - case 6457: - case 6469: - case 6540: - case 6617: - case 7062: - case 7169: - case 7286: - case 7351: - case 7663: - case 7967: - case 8574: - case 8591: - pinyin = "JUE"; - break; - - case 6260: - case 8168: - case 8362: - case 8769: - pinyin = "JUN"; - break; - - case 5671: - case 6339: - case 7544: - pinyin = "KA"; - break; - - case 5660: - case 5978: - case 6160: - case 6673: - case 6693: - case 7888: - case 7920: - case 7939: - pinyin = "KAI"; - break; - - case 5709: - case 6108: - case 7412: - case 7772: - case 7811: - pinyin = "KAN"; - break; - - case 5688: - case 6742: - case 7854: - pinyin = "KANG"; - break; - - case 6974: - case 7264: - case 7491: - case 7877: - pinyin = "KAO"; - break; - - case 6430: - case 6519: - case 6701: - case 6859: - case 7076: - case 7128: - case 7170: - case 7380: - case 7520: - case 7807: - case 7861: - case 7930: - case 7993: - case 8066: - case 8129: - case 8204: - case 8282: - case 8733: - pinyin = "KE"; - break; - - case 8144: - pinyin = "KEN"; - break; - - case 7912: - pinyin = "KENG"; - break; - - case 5737: - case 6539: - case 8377: - pinyin = "KONG"; - break; - - case 6050: - case 6202: - case 6321: - case 7778: - case 8356: - pinyin = "KOU"; - break; - - case 5658: - case 6005: - case 6423: - case 7111: - case 8728: - pinyin = "KU"; - break; - - case 5708: - pinyin = "KUA"; - break; - - case 5665: - case 5906: - case 6364: - case 6586: - case 7558: - pinyin = "KUAI"; - break; - - case 8737: - pinyin = "KUAN"; - break; - - case 5818: - case 5831: - case 5887: - case 5959: - case 6237: - case 6349: - case 7094: - case 7460: - pinyin = "KUANG"; - break; - - case 5624: - case 5649: - case 5771: - case 6162: - case 6281: - case 6413: - case 6416: - case 6720: - case 6951: - case 7450: - case 7805: - case 8606: - case 8743: - pinyin = "KUI"; - break; - - case 6204: - case 6245: - case 6458: - case 6618: - case 6928: - case 7152: - case 7841: - case 8051: - pinyin = "LIAO"; - break; - - case 5793: - case 5988: - case 6270: - case 6354: - case 6803: - case 8483: - case 8581: - case 8764: - pinyin = "LIE"; - break; - - case 6194: - case 6388: - case 6555: - case 6662: - case 6733: - case 6964: - case 7361: - case 7405: - case 7602: - case 7812: - case 8452: - case 8579: - case 8775: - pinyin = "LIN"; - break; - - case 5925: - case 6063: - case 6342: - case 6482: - case 6786: - case 7117: - case 7258: - case 7289: - case 7418: - case 8186: - case 8240: - case 8465: - case 8676: - pinyin = "LING"; - break; - - case 6815: - case 6962: - case 7082: - case 7124: - case 7628: - case 7654: - case 7919: - case 7954: - case 8050: - case 8644: - pinyin = "LIU"; - break; - - case 5966: - case 6055: - case 6781: - case 7171: - case 7248: - case 7542: - case 7735: - case 8110: - pinyin = "LONG"; - break; - - case 5745: - case 6168: - case 6422: - case 6548: - case 7946: - case 8092: - case 8179: - case 8287: - case 8735: - pinyin = "LOU"; - break; - - case 6744: - case 7321: - case 7586: - case 7918: - case 7989: - case 8158: - pinyin = "Lü"; - break; - - case 5968: - case 6303: - case 6464: - case 6782: - case 6843: - case 6885: - case 6954: - case 7220: - case 7251: - case 7354: - case 7391: - case 7404: - case 7510: - case 7545: - case 7969: - case 8021: - case 8056: - case 8392: - case 8421: - case 8652: - pinyin = "LU"; - break; - - case 5785: - case 7014: - case 7279: - case 8029: - case 8639: - pinyin = "LUAN"; - break; - pinyin = "LǖE"; - break; - pinyin = "LUN"; - break; - - case 5732: - case 5789: - case 6093: - case 6259: - case 6291: - case 6604: - case 6788: - case 6880: - case 7183: - case 7301: - case 7565: - case 7961: - case 8107: - case 8635: - pinyin = "LUO"; - break; - - case 6328: - pinyin = "M"; - break; - - case 6373: - case 6579: - case 7054: - case 7231: - case 8301: - pinyin = "MA"; - break; - - case 5929: - case 6104: - case 8618: - pinyin = "MAI"; - break; - - case 6012: - case 6503: - case 7147: - case 7655: - case 7960: - case 8209: - case 8293: - case 8709: - case 8720: - pinyin = "MAN"; - break; - - case 5888: - case 6861: - case 7743: - case 8294: - pinyin = "MANG"; - break; - - case 5783: - case 6066: - case 6525: - case 6787: - case 7203: - case 7436: - case 7483: - case 7503: - case 7624: - case 7714: - case 7806: - case 8317: - case 8754: - pinyin = "MAO"; - break; - - case 6114: - case 6550: - case 6613: - case 6828: - case 6856: - case 7325: - case 7949: - case 8044: - case 8139: - case 8740: - pinyin = "MEI"; - break; - - case 6249: - case 7643: - case 7715: - case 7845: - pinyin = "MEN"; - break; - - case 5934: - case 6189: - case 6211: - case 6734: - case 7592: - case 7770: - case 8221: - case 8276: - case 8323: - case 8427: - case 8431: - pinyin = "MENG"; - break; - - case 5634: - case 5855: - case 6234: - case 6368: - case 6455: - case 6608: - case 6772: - case 6921: - case 6984: - case 7563: - case 7682: - case 8445: - case 8767: - case 8771: - pinyin = "MI"; - break; - - case 6770: - case 6837: - case 6847: - case 7579: - case 7777: - pinyin = "MIAN"; - break; - - case 6387: - case 6967: - case 7131: - case 7149: - case 7234: - case 7721: - case 7780: - case 8037: - pinyin = "MIAO"; - break; - - case 5631: - case 6367: - case 8326: - case 8390: - pinyin = "MIE"; - break; - - case 6069: - case 6526: - case 6741: - case 6793: - case 7137: - case 7168: - case 7175: - case 7710: - case 8710: - case 8628: - pinyin = "MIN"; - break; - - case 5804: - case 6088: - case 6873: - case 7452: - case 7808: - case 8504: - pinyin = "MING"; - break; - pinyin = "MIU"; - break; - - case 5851: - case 6052: - case 6175: - case 6641: - case 7038: - case 7366: - case 7950: - case 7987: - case 8102: - case 8182: - case 8586: - case 8588: - case 8765: - pinyin = "MO"; - break; - - case 5716: - case 6372: - case 7788: - case 8254: - case 8290: - case 8642: - pinyin = "MOU"; - break; - - case 5679: - case 5973: - case 6057: - case 6769: - case 7504: - case 7866: - pinyin = "MU"; - break; - - case 6437: - pinyin = "N"; - break; - - case 6264: - case 7539: - case 7953: - case 8136: - pinyin = "NA"; - break; - - case 5630: - case 6021: - case 6133: - case 7245: - pinyin = "NAI"; - break; - - case 6411: - case 6478: - case 6479: - case 7310: - case 7578: - case 8279: - case 8486: - pinyin = "NAN"; - break; - - case 6313: - case 6476: - case 6646: - case 7457: - pinyin = "NANG"; - break; - - case 5611: - case 5981: - case 6346: - case 6614: - case 7207: - case 7748: - case 7883: - case 8245: - pinyin = "NAO"; - break; - - case 5811: - pinyin = "NE"; - break; - pinyin = "NEI"; - break; - - case 7705: - pinyin = "NEN"; - break; - pinyin = "NENG"; - break; - - case 5703: - case 5972: - case 6605: - case 6685: - case 7439: - case 7627: - case 7711: - case 7794: - case 7874: - case 8682: - pinyin = "NI"; - break; - - case 5605: - case 5994: - case 7393: - case 8004: - case 8651: - case 8683: - pinyin = "NIAN"; - break; - pinyin = "NIANG"; - break; - - case 6064: - case 7053: - case 7569: - case 8433: - pinyin = "NIAO"; - break; - - case 5877: - case 6233: - case 6431: - case 8208: - case 8411: - case 8570: - pinyin = "NIE"; - break; - pinyin = "NIN"; - break; - - case 5690: - case 6344: - case 6924: - case 8187: - pinyin = "NING"; - break; - - case 6580: - case 6678: - case 7004: - pinyin = "NIU"; - break; - - case 5715: - case 6370: - pinyin = "NONG"; - break; - - case 8181: - pinyin = "NOU"; - break; - - case 6983: - case 7032: - case 7059: - case 7069: - pinyin = "NU"; - break; - - case 7704: - case 7847: - case 8412: - pinyin = "Nǖ"; - break; - pinyin = "NUAN"; - break; - pinyin = "NUE"; - break; - - case 5748: - case 6289: - case 6386: - case 7927: - pinyin = "NUO"; - break; - - case 6424: - case 6462: - pinyin = "O"; - break; - - case 5809: - case 6670: - case 7417: - case 8178: - pinyin = "OU"; - break; - - case 6166: - case 7243: - case 8365: - pinyin = "PA"; - break; - - case 5729: - case 6169: - case 6363: - pinyin = "PAI"; - break; - - case 6761: - case 6790: - case 8140: - case 8165: - case 8320: - case 8571: - pinyin = "PAN"; - break; - - case 6561: - case 6872: - case 6944: - case 8306: - pinyin = "PANG"; - break; - - case 6243: - case 6583: - case 6650: - case 7567: - case 8069: - pinyin = "PAO"; - break; - - case 6446: - case 6490: - case 7623: - case 7934: - case 8512: - case 8612: - pinyin = "PEI"; - break; - - case 6852: - pinyin = "PEN"; - break; - - case 6001: - case 6456: - case 6681: - case 8318: - pinyin = "PENG"; - break; - - case 5607: - case 5682: - case 5880: - case 5892: - case 5915: - case 5960: - case 6017: - case 6037: - case 6308: - case 6472: - case 6647: - case 6836: - case 7039: - case 7102: - case 7233: - case 7422: - case 7802: - case 7828: - case 7875: - case 8117: - case 8166: - case 8223: - case 8271: - case 8589: - pinyin = "PI"; - break; - - case 5850: - case 7073: - case 7490: - case 7561: - case 8470: - case 8568: - pinyin = "PIAN"; - break; - - case 5666: - case 6449: - case 7046: - case 7146: - case 7372: - case 7809: - case 8310: - pinyin = "PIAO"; - break; - - case 6054: - case 7513: - pinyin = "PIE"; - break; - - case 7041: - case 6253: - case 7016: - case 7315: - case 7482: - case 8213: - pinyin = "PIN"; - break; - - case 5723: - case 7019: - case 7250: - case 8650: - pinyin = "PING"; - break; - - case 5647: - case 5922: - case 7174: - case 7839: - case 7862: - case 8011: - case 8345: - pinyin = "PO"; - break; - - case 5786: - case 6269: - pinyin = "POU"; - break; - - case 5773: - case 6459: - case 6863: - case 6907: - case 7217: - case 7511: - case 7968: - case 7972: - case 8575: - pinyin = "PU"; - break; - - case 5633: - case 5725: - case 5963: - case 6027: - case 6046: - case 6089: - case 6129: - case 6134: - case 6161: - case 6213: - case 6366: - case 6450: - case 6508: - case 6510: - case 6764: - case 6831: - case 7075: - case 7118: - case 7187: - case 7189: - case 7229: - case 7271: - case 7342: - case 7440: - case 7605: - case 7687: - case 7712: - case 7751: - case 8193: - case 8251: - case 8264: - case 8475: - case 8476: - case 8572: - case 8702: - case 8772: - pinyin = "QI"; - break; - - case 6154: - case 8736: - pinyin = "QIA"; - break; - - case 5727: - case 5761: - case 5868: - case 6023: - case 6045: - case 6071: - case 6271: - case 6509: - case 6705: - case 6727: - case 6925: - case 6926: - case 6929: - case 7155: - case 7293: - case 7541: - case 7709: - case 7852: - case 8215: - case 8373: - pinyin = "QIAN"; - break; - - case 6762: - case 7045: - case 7341: - case 7408: - case 7633: - case 7926: - case 7947: - case 7974: - case 8163: - case 8262: - case 8439: - case 8536: - pinyin = "QIANG"; - break; - - case 5668: - case 5829: - case 5859: - case 6081: - case 6529: - case 6724: - case 6730: - case 7352: - case 7745: - case 8546: - case 8719: - pinyin = "QIAO"; - break; - - case 5907: - case 6711: - case 7010: - case 7492: - case 7938: - case 8370: - pinyin = "QIE"; - break; - - case 6043: - case 6276: - case 6336: - case 6426: - case 6463: - case 6858: - case 7353: - case 7923: - case 8291: - case 8432: - pinyin = "QIN"; - break; - - case 6060: - case 6485: - case 7349: - case 7764: - case 8263: - case 8332: - case 8368: - case 8605: - case 8675: - case 8784: - pinyin = "QING"; - break; - - case 5886: - case 6068: - case 8123: - case 8243: - case 8344: - case 8528: - case 8638: - pinyin = "QIONG"; - break; - - case 5720: - case 5947: - case 6576: - case 6848: - case 6947: - case 6957: - case 7317: - case 7468: - case 8216: - case 8239: - case 8288: - case 8435: - case 8460: - case 8690: - case 8792: - pinyin = "QIU"; - break; - - case 5816: - case 5930: - case 6201: - case 6230: - case 6511: - case 6573: - case 6754: - case 7219: - case 7479: - case 7512: - case 7552: - case 7678: - case 7765: - case 8119: - case 8248: - case 8329: - case 8480: - case 8636: - case 8781: - pinyin = "QU"; - break; - - case 5825: - case 6085: - case 6710: - case 7125: - case 7390: - case 7816: - case 7893: - case 8273: - case 8360: - case 8760: - pinyin = "QUAN"; - break; - - case 6755: - case 6758: - case 7708: - pinyin = "QUE"; - break; - - case 6950: - pinyin = "QUN"; - break; - - case 6059: - case 8237: - case 8755: - pinyin = "RAN"; - break; - - case 7692: - case 8006: - pinyin = "RANG"; - break; - - case 6073: - case 7012: - case 7267: - pinyin = "RAO"; - break; - pinyin = "RE"; - break; - - case 5680: - case 6083: - case 6156: - case 6631: - case 7377: - case 7994: - case 8137: - pinyin = "REN"; - break; - pinyin = "RENG"; - break; - pinyin = "RI"; - break; - - case 6541: - case 6585: - case 7337: - case 7532: - case 8278: - pinyin = "RONG"; - break; - - case 8459: - case 8569: - case 8723: - pinyin = "ROU"; - break; - - case 6174: - case 6224: - case 6473: - case 6818: - case 6865: - case 6906: - case 7140: - case 7908: - case 8164: - case 8212: - pinyin = "RU"; - break; - - case 7535: - pinyin = "RUAN"; - break; - - case 6039: - case 6208: - case 7236: - case 7803: - case 8224: - pinyin = "RUI"; - break; - pinyin = "RUN"; - break; - - case 5728: - case 8372: - pinyin = "RUO"; - break; - - case 5606: - case 5677: - case 7493: - case 7559: - case 7610: - pinyin = "SA"; - break; - - case 6471: - pinyin = "SAI"; - break; - - case 6644: - case 7507: - case 8454: - pinyin = "SAN"; - break; - - case 6290: - case 7763: - case 8210: - pinyin = "SANG"; - break; - - case 6003: - case 7150: - case 7156: - case 7593: - case 8094: - case 8694: - pinyin = "SAO"; - break; - pinyin = "SE"; - break; - pinyin = "SEN"; - break; - pinyin = "SENG"; - break; - - case 6394: - case 7606: - case 7901: - case 8080: - case 8436: - case 8614: - case 8672: - pinyin = "SHA"; - break; - - case 8507: - pinyin = "SHAI"; - break; - - case 5663: - case 5808: - case 5923: - case 5979: - case 6047: - case 6890: - case 7009: - case 7051: - case 7083: - case 7594: - case 7844: - case 8062: - case 8321: - case 8414: - case 8539: - case 8713: - pinyin = "SHAN"; - break; - - case 5980: - case 7120: - case 7368: - case 7656: - case 8592: - pinyin = "SHANG"; - break; - - case 5931: - case 6070: - case 6891: - case 7228: - case 8366: - case 8425: - pinyin = "SHAO"; - break; - - case 5639: - case 5760: - case 6606: - case 6860: - case 7608: - case 7820: - case 8774: - pinyin = "SHE"; - break; - - case 5837: - case 6123: - case 6351: - case 6841: - case 7309: - case 7547: - case 7982: - case 8255: - pinyin = "SHEN"; - break; - - case 6551: - case 7441: - case 7782: - case 8347: - pinyin = "SHENG"; - break; - - case 5854: - case 5985: - case 6110: - case 6173: - case 6317: - case 7388: - case 7459: - case 7634: - case 7870: - case 8307: - case 8334: - case 8363: - case 8525: - case 8669: - case 8685: - pinyin = "SHI"; - break; - - case 6587: - case 7123: - case 8428: - pinyin = "SHOU"; - break; - - case 5731: - case 5951: - case 6136: - case 6283: - case 6780: - case 6888: - case 7013: - case 7508: - case 7582: - case 7988: - pinyin = "SHU"; - break; - - case 6407: - pinyin = "SHUA"; - break; - - case 8316: - pinyin = "SHUAI"; - break; - - case 6737: - case 6844: - pinyin = "SHUAN"; - break; - - case 7055: - pinyin = "SHUANG"; - break; - pinyin = "SHUI"; - break; - pinyin = "SHUN"; - break; - - case 6184: - case 6287: - case 6989: - case 7335: - case 7869: - pinyin = "SHUO"; - break; - - case 5643: - case 5778: - case 5944: - case 6348: - case 6765: - case 6784: - case 6889: - case 7006: - case 7065: - case 7133: - case 7675: - case 7940: - case 8024: - case 8174: - case 8247: - case 8351: - pinyin = "SI"; - break; - - case 5801: - case 6131: - case 6534: - case 6552: - case 6676: - case 6704: - case 6833: - case 8121: - pinyin = "SONG"; - break; - - case 5937: - case 6220: - case 6418: - case 6453: - case 6640: - case 6849: - case 7612: - case 7804: - case 7943: - case 8284: - pinyin = "SOU"; - break; - - case 5777: - case 5853: - case 6188: - case 6428: - case 6726: - case 6819: - case 8389: - case 8602: - case 8653: - pinyin = "SU"; - break; - - case 6601: - pinyin = "SUAN"; - break; - - case 5839: - case 6120: - case 6901: - case 6968: - case 7661: - case 7785: - case 7801: - pinyin = "SUI"; - break; - - case 6105: - case 6588: - case 6624: - case 7330: - case 8632: - pinyin = "SUN"; - break; - - case 6379: - case 6434: - case 6442: - case 7022: - case 7288: - case 7792: - case 8440: - pinyin = "SUO"; - break; - - case 6743: - case 6866: - case 6961: - case 7329: - case 7719: - case 7872: - case 8533: - case 8703: - pinyin = "TA"; - break; - - case 5902: - case 6223: - case 6330: - case 7070: - case 7536: - case 7638: - case 7849: - case 8544: - case 8656: - pinyin = "TAI"; - break; - - case 5916: - case 6903: - case 7428: - case 7694: - case 7867: - case 7936: - case 8191: - pinyin = "TAN"; - break; - - case 5746: - case 6491: - case 6871: - case 7209: - case 7344: - case 7906: - case 7959: - case 8177: - case 8305: - case 8311: - case 8442: - case 8517: - pinyin = "TANG"; - break; - - case 5627: - case 6391: - case 6812: - case 7226: - case 7666: - pinyin = "TAO"; - break; - pinyin = "1845 餐"; - break; - - case 6315: - case 7693: - case 7911: - pinyin = "TE"; - break; - - case 7588: - pinyin = "TENG"; - break; - - case 5735: - case 6709: - case 6949: - case 7130: - case 8035: - case 8151: - case 8514: - pinyin = "TI"; - break; - - case 6261: - case 6735: - case 6757: - case 7369: - case 7817: - pinyin = "TIAN"; - break; - - case 5712: - case 7686: - case 8127: - case 8272: - case 8352: - case 8448: - case 8622: - case 8670: - case 8756: - pinyin = "TIAO"; - break; - - case 6138: - case 8749: - pinyin = "TIE"; - break; - - case 6080: - case 6167: - case 7035: - case 7272: - case 7890: - case 8249: - case 8610: - pinyin = "TING"; - break; - - case 5701: - case 5758: - case 6077: - case 6444: - case 6690: - case 6892: - case 7737: - pinyin = "TONG"; - break; - - case 7855: - case 7822: - case 8727: - pinyin = "TOU"; - break; - - case 6002: - case 6117: - case 6143: - case 7842: - case 8509: - pinyin = "TU"; - break; - - case 6250: - case 6972: - pinyin = "TUAN"; - break; - - case 7653: - pinyin = "TUI"; - break; - - case 5759: - case 6629: - case 7453: - case 7564: - pinyin = "TUN"; - break; - - case 5617: - case 5702: - case 5971: - case 6653: - case 6791: - case 7256: - case 7262: - case 7350: - case 7740: - case 8374: - case 8502: - case 8541: - case 8630: - pinyin = "TUO"; - break; - - case 5684: - case 7020: - case 7580: - pinyin = "WA"; - break; - pinyin = "WAI"; - break; - - case 5664: - case 6025: - case 6150: - case 7093: - case 7126: - case 7194: - case 7568: - case 7821: - case 8274: - pinyin = "WAN"; - break; - - case 5672: - case 6244: - case 6715: - case 7394: - case 8745: - pinyin = "WANG"; - break; - - case 5743: - case 5835: - case 5881: - case 5883: - case 6158: - case 6217: - case 6488: - case 6501: - case 6543: - case 6545: - case 6611: - case 6612: - case 6739: - case 6777: - case 6802: - case 6822: - case 6952: - case 7024: - case 7166: - case 7224: - case 7406: - case 7631: - case 7648: - case 8084: - case 8426: - case 8659: - pinyin = "WEI"; - break; - - case 5656: - case 6751: - case 6775: - case 7223: - case 8609: - pinyin = "WEN"; - break; - - case 6178: - case 6219: - pinyin = "WENG"; - break; - - case 5733: - case 6111: - case 6502: - case 6855: - case 7531: - case 7750: - case 8627: - pinyin = "WO"; - break; - - case 5603: - case 5685: - case 5867: - case 5889: - case 5956: - case 6044: - case 6377: - case 6648: - case 6668: - case 6672: - case 6820: - case 6927: - case 6935: - case 6992: - case 7036: - case 7080: - case 7227: - case 7485: - case 7641: - case 8036: - case 8045: - case 8077: - case 8258: - case 8640: - case 8789: - pinyin = "WU"; - break; - - case 5750: - case 5766: - case 5884: - case 5913: - case 6130: - case 6163: - case 6191: - case 6241: - case 6381: - case 6567: - case 6630: - case 6750: - case 6827: - case 6832: - case 6979: - case 7050: - case 7184: - case 7356: - case 7456: - case 7474: - case 7604: - case 7668: - case 7689: - case 7691: - case 8010: - case 8122: - case 8265: - case 8303: - case 8312: - case 8410: - case 8424: - case 8443: - case 8449: - case 8466: - case 8521: - case 8791: - pinyin = "XI"; - break; - - case 6340: - case 6582: - case 6958: - case 7206: - case 7252: - case 7744: - case 8093: - case 8333: - case 8779: - pinyin = "XIA"; - break; - - case 5794: - case 5823: - case 6040: - case 6118: - case 6226: - case 6513: - case 6593: - case 6963: - case 7021: - case 7515: - case 7662: - case 7676: - case 8034: - case 8079: - case 8225: - case 8358: - case 8444: - case 8503: - case 8548: - case 8549: - case 8617: - pinyin = "XIAN"; - break; - - case 6028: - case 6157: - case 6635: - case 6652: - case 7088: - case 7129: - case 8313: - case 8663: - case 8747: - pinyin = "XIANG"; - break; - - case 6356: - case 6537: - case 6876: - case 6948: - case 7071: - case 7115: - case 7241: - case 7253: - case 8257: - case 8367: - case 8379: - case 8744: - pinyin = "XIAO"; - break; - - case 5741: - case 5784: - case 5936: - case 5938: - case 6215: - case 6302: - case 6619: - case 6661: - case 6845: - case 6912: - case 6966: - case 7105: - case 7151: - case 7331: - case 7339: - case 8583: - pinyin = "XIE"; - break; - - case 5622: - case 6016: - case 7431: - case 7607: - case 8646: - pinyin = "XIN"; - break; - - case 5874: - case 6084: - case 6309: - case 6712: - case 7742: - pinyin = "XING"; - break; - - case 6026: - pinyin = "XIONG"; - break; - - case 6361: - case 6522: - case 6642: - case 6651: - case 6869: - case 8028: - case 8587: - case 8759: - pinyin = "XIU"; - break; - - case 5828: - case 5935: - case 5955: - case 6203: - case 6810: - case 6851: - case 7179: - case 7282: - case 7667: - case 7776: - case 8167: - case 8458: - case 8515: - pinyin = "XU"; - break; - - case 5756: - case 5846: - case 6170: - case 6279: - case 6789: - case 6854: - case 6886: - case 7215: - case 7324: - case 7449: - case 7637: - case 7651: - case 7759: - case 7871: - case 7964: - case 8071: - pinyin = "XUAN"; - break; - - case 5842: - case 7720: - case 8529: - case 8708: - pinyin = "XUE"; - break; - - case 5767: - case 5908: - case 5987: - case 6087: - case 6101: - case 6206: - case 6225: - case 6530: - case 6563: - case 6620: - case 6694: - case 6813: - case 6817: - case 7454: - case 8131: - case 8524: - case 8664: - pinyin = "XUN"; - break; - - case 5683: - case 5975: - case 6275: - case 6512: - case 6934: - case 7011: - case 7180: - case 7266: - case 7518: - case 7728: - case 7793: - case 8073: - pinyin = "YA"; - break; - - case 5641: - case 5645: - case 5718: - case 5740: - case 5780: - case 5861: - case 5917: - case 5919: - case 6030: - case 6146: - case 6535: - case 6691: - case 6738: - case 6753: - case 6846: - case 6857: - case 6991: - case 7044: - case 7192: - case 7360: - case 7444: - case 7557: - case 7645: - case 7827: - case 8359: - case 8506: - case 8742: - case 8748: - case 8790: - pinyin = "YAN"; - break; - - case 6564: - case 6683: - case 7630: - case 7640: - case 7706: - case 8253: - case 8717: - pinyin = "YANG"; - break; - - case 5618: - case 5619: - case 6326: - case 6542: - case 6570: - case 7159: - case 7182: - case 7235: - case 7387: - case 7455: - case 7540: - case 7902: - case 8046: - case 8126: - case 8477: - case 8705: - pinyin = "YAO"; - break; - - case 5644: - case 5843: - case 5894: - case 6262: - case 7442: - case 7639: - case 7884: - pinyin = "YE"; - break; - - case 5655: - case 5657: - case 5670: - case 5693: - case 5711: - case 5817: - case 5961: - case 5992: - case 6018: - case 6051: - case 6072: - case 6218: - case 6236: - case 6240: - case 6258: - case 6314: - case 6329: - case 6355: - case 6362: - case 6441: - case 6470: - case 6527: - case 6558: - case 6602: - case 6634: - case 6688: - case 6689: - case 6708: - case 6884: - case 6938: - case 7068: - case 7143: - case 7376: - case 7383: - case 7461: - case 7629: - case 7658: - case 7784: - case 7838: - case 7955: - case 7978: - case 8074: - case 8089: - case 8115: - case 8120: - case 8270: - case 8415: - case 8464: - case 8472: - case 8493: - case 8780: - pinyin = "YI"; - break; - - case 5623: - case 5920: - case 5983: - case 6007: - case 6065: - case 6337: - case 6419: - case 6594: - case 6625: - case 6806: - case 7519: - case 7887: - case 8111: - case 8230: - case 8615: - case 8624: - pinyin = "YIN"; - break; - - case 5788: - case 5911: - case 6067: - case 6094: - case 6126: - case 6151: - case 6186: - case 6292: - case 6451: - case 6663: - case 6862: - case 6875: - case 6913: - case 7188: - case 7212: - case 7326: - case 7584: - case 8048: - case 8108: - case 8203: - case 8331: - pinyin = "YING"; - break; - - case 6401: - pinyin = "YO"; - break; - - case 5724: - case 5953: - case 6013: - case 6415: - case 6728: - case 7163: - case 7962: - case 8014: - case 8711: - case 8751: - pinyin = "YONG"; - break; - - case 5653: - case 5692: - case 5707: - case 6112: - case 6115: - case 6121: - case 6347: - case 6483: - case 6922: - case 7254: - case 7364: - case 7527: - case 7880: - case 8064: - case 8236: - case 8242: - case 8286: - case 8647: - case 8778: - case 8788: - pinyin = "YOU"; - break; - - case 5614: - case 5625: - case 5681: - case 5722: - case 5836: - case 5845: - case 6139: - case 6187: - case 6277: - case 6484: - case 6486: - case 6546: - case 6592: - case 6632: - case 6637: - case 6655: - case 6748: - case 6987: - case 6993: - case 7005: - case 7090: - case 7204: - case 7437: - case 7476: - case 7573: - case 7603: - case 7622: - case 7647: - case 7659: - case 7718: - case 7858: - case 8033: - case 8054: - case 8085: - case 8086: - case 8130: - case 8133: - case 8266: - case 8285: - case 8336: - case 8407: - case 8408: - case 8607: - case 8625: - pinyin = "YU"; - break; - - case 5989: - case 6011: - case 6282: - case 6768: - case 7034: - case 7205: - case 7358: - case 7528: - case 7783: - case 8016: - case 8302: - case 8378: - case 8629: - pinyin = "YUAN"; - break; - - case 5763: - case 6914: - case 7348: - case 7530: - case 7865: - pinyin = "YUE"; - break; - - case 5909: - case 6031: - case 6581: - case 6702: - case 6719: - case 7101: - case 7225: - case 7370: - case 7432: - case 7521: - case 7657: - pinyin = "YUN"; - break; - - case 6257: - case 6338: - pinyin = "ZA"; - break; - - case 6544: - case 7162: - pinyin = "ZAI"; - break; - - case 7222: - case 7435: - case 8402: - case 8456: - case 8485: - case 8641: - pinyin = "ZAN"; - break; - - case 6242: - case 7064: - case 7416: - pinyin = "ZANG"; - break; - - case 6380: - pinyin = "ZAO"; - break; - - case 5638: - case 8369: - case 5651: - case 6385: - case 6493: - case 6937: - case 7430: - case 8348: - case 8423: - pinyin = "ZE"; - break; - pinyin = "ZEI"; - break; - - case 5858: - pinyin = "ZEN"; - break; - - case 7153: - case 7421: - case 7832: - case 7913: - pinyin = "ZENG"; - break; - - case 6610: - case 6274: - case 6324: - case 6369: - case 6378: - case 7736: - case 8068: - case 8238: - case 8794: - pinyin = "ZHA"; - break; - - case 7746: - case 8109: - pinyin = "ZHAI"; - break; - - case 5862: - case 6288: - case 7625: - pinyin = "ZHAN"; - break; - - case 5675: - case 5921: - case 6504: - case 6554: - case 6615: - case 7049: - case 7216: - case 8315: - pinyin = "ZHANG"; - break; - - case 5815: - case 7294: - case 7840: - case 8341: - pinyin = "ZHAO"; - break; - - case 5856: - case 6301: - case 7247: - case 7392: - case 7761: - case 8049: - case 8162: - case 8256: - case 8487: - pinyin = "ZHE"; - break; - - case 5958: - case 6172: - case 6805: - case 7139: - case 7269: - case 7327: - case 7384: - case 7466: - case 7551: - case 7562: - case 7685: - case 7819: - case 8001: - case 8018: - case 8380: - pinyin = "ZHEN"; - break; - - case 5826: - case 6531: - case 6571: - case 7859: - case 7903: - case 8361: - pinyin = "ZHENG"; - break; - - case 5620: - case 5876: - case 5904: - case 5990: - case 6038: - case 6293: - case 6489: - case 6669: - case 6973: - case 6975: - case 7079: - case 7246: - case 7255: - case 7257: - case 7268: - case 7382: - case 7389: - case 7462: - case 7553: - case 7589: - case 7677: - case 7683: - case 7773: - case 7984: - case 8026: - case 8075: - case 8246: - case 8474: - case 8505: - case 8537: - case 8557: - case 8560: - case 8584: - case 8603: - pinyin = "ZHI"; - break; - - case 5803: - case 7981: - case 8314: - case 8417: - case 8564: - pinyin = "ZHONG"; - break; - - case 6107: - case 6390: - case 7008: - case 7091: - case 7107: - case 7548: - case 7756: - case 8406: - case 8492: - pinyin = "ZHOU"; - break; - - case 5689: - case 5710: - case 5905: - case 6049: - case 6079: - case 6808: - case 6830: - case 6883: - case 7244: - case 7338: - case 7345: - case 7636: - case 7889: - case 8070: - case 8081: - case 8335: - case 8371: - case 8422: - case 8467: - case 8578: - case 8770: - pinyin = "ZHU"; - break; - pinyin = "ZHUA"; - break; - pinyin = "ZHUAI"; - break; - - case 6389: - case 6645: - case 8207: - pinyin = "ZHUAN"; - break; - - case 5755: - pinyin = "ZHUANG"; - break; - - case 6723: - case 7077: - case 7136: - pinyin = "ZHUI"; - break; - - case 7538: - case 8124: - pinyin = "ZHUN"; - break; - - case 5730: - case 5834: - case 6310: - case 6823: - case 6835: - case 6910: - case 7644: - case 7690: - case 7729: - case 7977: - pinyin = "ZHUO"; - break; - - case 5849: - case 6549: - case 7002: - case 7060: - case 7127: - case 7287: - case 7402: - case 7463: - case 7707: - case 7786: - case 7937: - case 7986: - case 8172: - case 8342: - case 8450: - case 8484: - case 8594: - case 8604: - case 8623: - case 8686: - case 8758: - pinyin = "ZI"; - break; - - case 5744: - case 7574: - case 8453: - pinyin = "ZONG"; - break; - - case 5833: - case 5878: - case 5924: - case 7067: - case 8677: - pinyin = "ZOU"; - break; - - case 5762: - case 6147: - case 7963: - pinyin = "ZU"; - break; - - case 6312: - case 7158: - case 8582: - pinyin = "ZUAN"; - break; - - case 6209: - pinyin = "ZUI"; - break; - - case 6304: - case 7355: - case 8714: - pinyin = "ZUN"; - break; - - case 5872: - case 6382: - case 6460: - case 6684: - case 7549: - case 7681: - pinyin = "ZUO"; - break; - - default: - if (code >= 1601 && code <= 1602) { - pinyin = "A"; - break; - } - - if (code >= 1603 && code <= 1615) { - pinyin = "AI"; - break; - } - - if (code >= 1616 && code <= 1624) { - pinyin = "AN"; - break; - } - - if (code >= 1625 && code <= 1627) { - pinyin = "ANG"; - break; - } - - if (code >= 1628 && code <= 1636) { - pinyin = "AO"; - break; - } - - if (code >= 1637 && code <= 1654) { - pinyin = "BA"; - break; - } - - if (code >= 1655 && code <= 1662) { - pinyin = "BAI"; - break; - } - - if (code >= 1663 && code <= 1677) { - pinyin = "BAN"; - break; - } - - if (code >= 1678 && code <= 1689) { - pinyin = "BANG"; - break; - } - - if (code >= 1690 && code <= 1712) { - pinyin = "BAO"; - break; - } - - if (code >= 1713 && code <= 1727) { - pinyin = "BEI"; - break; - } - - if (code >= 1728 && code <= 1731) { - pinyin = "BEN"; - break; - } - - if (code >= 1732 && code <= 1737) { - pinyin = "BENG"; - break; - } - - if (code > 1738 && code <= 1761) { - pinyin = "BI"; - break; - } - - if (code >= 1762 && code <= 1773) { - pinyin = "BIAN"; - break; - } - - if (code >= 1774 && code <= 1777) { - pinyin = "BIAO"; - break; - } - - if (code >= 1778 && code <= 1781) { - pinyin = "BIE"; - break; - } - - if (code >= 1782 && code <= 1787) { - pinyin = "BIN"; - break; - } - - if (code >= 1788 && code <= 1794) { - pinyin = "BING"; - break; - } - - if (code >= 1801 && code <= 1802) { - pinyin = "BING"; - break; - } - - if (code >= 1803 && code <= 1821) { - pinyin = "BO"; - break; - } - - if (code >= 1822 && code <= 1832) { - pinyin = "BU"; - break; - } - - if (code == 1833) { - pinyin = "CA"; - break; - } - - if (code >= 1834 && code <= 1844) { - pinyin = "CAI"; - break; - } - - if (code >= 1845 && code <= 1851) { - pinyin = "CAN"; - break; - } - - if (code >= 1852 && code <= 1856) { - pinyin = "CANG"; - break; - } - - if (code >= 1857 && code <= 1861) { - pinyin = "CAO"; - break; - } - - if (code >= 1862 && code <= 1866) { - pinyin = "CE"; - break; - } - - if (code >= 1867 && code <= 1868) { - pinyin = "CENG"; - break; - } - - if (code >= 1869 && code <= 1879) { - pinyin = "CHA"; - break; - } - - if (code >= 1880 && code <= 1882) { - pinyin = "CHAI"; - break; - } - - if (code >= 1883 && code <= 1892) { - pinyin = "CHAN"; - break; - } - - if (code >= 1893 && code <= 1911) { - pinyin = "CHANG"; - break; - } - - if (code >= 1912 && code <= 1920) { - pinyin = "CHAO"; - break; - } - - if (code >= 1921 && code <= 1926) { - pinyin = "CHE"; - break; - } - - if (code >= 1927 && code <= 1936) { - pinyin = "CHEN"; - break; - } - - if (code >= 1937 && code <= 1951) { - pinyin = "CHENG"; - break; - } - - if (code >= 1952 && code <= 1967) { - pinyin = "CHI"; - break; - } - - if (code >= 1968 && code <= 1972) { - pinyin = "CHONG"; - break; - } - - if (code >= 1973 && code <= 1984) { - pinyin = "CHOU"; - break; - } - - if (code >= 1985 && code <= 2006) { - pinyin = "CHU"; - break; - } - - if (code == 2007) { - pinyin = "CHUAI"; - break; - } - - if (code >= 2008 && code <= 2014) { - pinyin = "CHUAN"; - break; - } - - if (code >= 2015 && code <= 2020) { - pinyin = "CHUANG"; - break; - } - - if (code >= 2021 && code <= 2025) { - pinyin = "CHUI"; - break; - } - - if (code >= 2026 && code <= 2032) { - pinyin = "CHUN"; - break; - } - - if (code >= 2033 && code <= 2034) { - pinyin = "CHUO"; - break; - } - - if (code >= 2035 && code <= 2046) { - pinyin = "CI"; - break; - } - - if (code >= 2047 && code <= 2052) { - pinyin = "CONG"; - break; - } - - if (code >= 2054 && code <= 2057) { - pinyin = "CU"; - break; - } - - if (code >= 2058 && code <= 2060) { - pinyin = "CUAN"; - break; - } - - if (code >= 2061 && code <= 2068) { - pinyin = "CUI"; - break; - } - - if (code >= 2069 && code <= 2071) { - pinyin = "CUN"; - break; - } - - if (code >= 2072 && code <= 2077) { - pinyin = "CUO"; - break; - } - - if (code >= 2078 && code <= 2083) { - pinyin = "DA"; - break; - } - - if (code >= 2084 && code <= 2094) { - pinyin = "DAI"; - break; - } - - if (code >= 2102 && code <= 2116) { - pinyin = "DAN"; - break; - } - - if (code >= 2117 && code <= 2121) { - pinyin = "DANG"; - break; - } - - if (code >= 2122 && code <= 2133) { - pinyin = "DAO"; - break; - } - - if (code >= 2134 && code <= 2136) { - pinyin = "DE"; - break; - } - - if (code >= 2137 && code <= 2143) { - pinyin = "DENG"; - break; - } - - if (code >= 2144 && code <= 2162) { - pinyin = "DI"; - break; - } - - if (code >= 2163 && code <= 2178) { - pinyin = "DIAN"; - break; - } - - if (code >= 2179 && code <= 2187) { - pinyin = "DIAO"; - break; - } - - if (code >= 2188 && code <= 2194) { - pinyin = "DIE"; - break; - } - - if (code >= 2201 && code <= 2209) { - pinyin = "DING"; - break; - } - - if (code == 2210) { - pinyin = "DIU"; - break; - } - - if (code >= 2211 && code <= 2220) { - pinyin = "DONG"; - break; - } - - if (code >= 2221 && code <= 2227) { - pinyin = "DOU"; - break; - } - - if (code >= 2228 && code <= 2242) { - pinyin = "DU"; - break; - } - - if (code >= 2243 && code <= 2248) { - pinyin = "DUAN"; - break; - } - - if (code >= 2249 && code <= 2252) { - pinyin = "DUI"; - break; - } - - if (code >= 2253 && code <= 2261) { - pinyin = "DUN"; - break; - } - - if (code >= 2262 && code <= 2273) { - pinyin = "DUO"; - break; - } - - if (code >= 2274 && code <= 2286) { - pinyin = "E"; - break; - } - - if (code == 2287) { - pinyin = "EN"; - break; - } - - if (code >= 2288 && code <= 2231) { - pinyin = "ER"; - break; - } - - if (code >= 2302 && code <= 2309) { - pinyin = "FA"; - break; - } - - if (code >= 2310 && code <= 2326) { - pinyin = "FAN"; - break; - } - - if (code >= 2327 && code <= 2337) { - pinyin = "FANG"; - break; - } - - if (code >= 2338 && code <= 2349) { - pinyin = "FEI"; - break; - } - - if (code >= 2350 && code <= 2364) { - pinyin = "FEN"; - break; - } - - if (code >= 2365 && code <= 2379) { - pinyin = "FENG"; - break; - } - - if (code == 2380) { - pinyin = "FO"; - break; - } - - if (code == 2381) { - pinyin = "FOU"; - break; - } - - if (code >= 2382 && code <= 2432) { - pinyin = "FU"; - break; - } - - if (code >= 2435 && code <= 2440) { - pinyin = "GAI"; - break; - } - - if (code >= 2441 && code <= 2451) { - pinyin = "GAN"; - break; - } - - if (code >= 2452 && code <= 2460) { - pinyin = "GANG"; - break; - } - - if (code >= 2461 && code <= 2470) { - pinyin = "GAO"; - break; - } - - if (code >= 2471 && code <= 2487) { - pinyin = "GE"; - break; - } - - if (code == 2488) { - pinyin = "GEI"; - break; - } - - if (code >= 2489 && code <= 2490) { - pinyin = "GEN"; - break; - } - - if (code >= 2491 && code <= 2503) { - pinyin = "GENG"; - break; - } - - if (code >= 2504 && code <= 2518) { - pinyin = "GONG"; - break; - } - - if (code >= 2519 && code <= 2527) { - pinyin = "GOU"; - break; - } - - if (code >= 2528 && code <= 2545) { - pinyin = "GU"; - break; - } - - if (code >= 2546 && code <= 2551) { - pinyin = "GUA"; - break; - } - - if (code >= 2552 && code <= 2554) { - pinyin = "GUAI"; - break; - } - - if (code >= 2555 && code <= 2565) { - pinyin = "GUAN"; - break; - } - - if (code >= 2566 && code <= 2568) { - pinyin = "GUANG"; - break; - } - - if (code >= 2569 && code <= 2584) { - pinyin = "GUI"; - break; - } - - if (code >= 2585 && code <= 2587) { - pinyin = "GUN"; - break; - } - - if (code >= 2588 && code <= 2593) { - pinyin = "GUO"; - break; - } - - if (code == 2594) { - pinyin = "HA"; - break; - } - - if (code >= 2601 && code <= 2607) { - pinyin = "HAI"; - break; - } - - if (code >= 2608 && code <= 2626) { - pinyin = "HAN"; - break; - } - - if (code >= 2627 && code <= 2629) { - pinyin = "HANG"; - break; - } - - if (code >= 2630 && code <= 2638) { - pinyin = "HAO"; - break; - } - - if (code >= 2639 && code <= 2656) { - pinyin = "HE"; - break; - } - - if (code >= 2657 && code <= 2658) { - pinyin = "HEI"; - break; - } - - if (code >= 2659 && code <= 2662) { - pinyin = "HEN"; - break; - } - - if (code >= 2663 && code <= 2667) { - pinyin = "HENG"; - break; - } - - if (code >= 2668 && code <= 2676) { - pinyin = "HONG"; - break; - } - - if (code >= 2677 && code <= 2683) { - pinyin = "HOU"; - break; - } - - if (code >= 2684 && code <= 2707) { - pinyin = "HU"; - break; - } - - if (code >= 2708 && code <= 2716) { - pinyin = "HUA"; - break; - } - - if (code >= 2717 && code <= 2721) { - pinyin = "HUAI"; - break; - } - - if (code >= 2722 && code <= 2735) { - pinyin = "HUAN"; - break; - } - - if (code >= 2736 && code <= 2749) { - pinyin = "HUANG"; - break; - } - - if (code >= 2750 && code <= 2770) { - pinyin = "HUI"; - break; - } - - if (code >= 2771 && code <= 2776) { - pinyin = "HUN"; - break; - } - - if (code >= 2777 && code <= 2786) { - pinyin = "HUO"; - break; - } - - if (code >= 2787 && code <= 2845) { - pinyin = "JI"; - break; - } - - if (code >= 2846 && code <= 2862) { - pinyin = "JIA"; - break; - } - - if (code >= 2863 && code <= 2908) { - pinyin = "JIAN"; - break; - } - - if (code >= 2909 && code <= 2921) { - pinyin = "JIANG"; - break; - } - - if (code >= 2922 && code <= 2949) { - pinyin = "JIAO"; - break; - } - - if (code >= 2950 && code <= 2976) { - pinyin = "JIE"; - break; - } - - if (code >= 2977 && code <= 3002) { - pinyin = "JIN"; - break; - } - - if (code >= 3003 && code <= 3027) { - pinyin = "JING"; - break; - } - - if (code >= 3028 && code <= 3029) { - pinyin = "JIONG"; - break; - } - - if (code >= 3030 && code <= 3046) { - pinyin = "JIU"; - break; - } - - if (code >= 3047 && code <= 3071) { - pinyin = "JU"; - break; - } - - if (code >= 3072 && code <= 3078) { - pinyin = "JUAN"; - break; - } - - if (code >= 3079 && code <= 3088) { - pinyin = "JUE"; - break; - } - - if (code >= 3089 && code <= 3105) { - pinyin = "JUN"; - break; - } - - if (code >= 3106 && code <= 3109) { - pinyin = "KA"; - break; - } - - if (code >= 3110 && code <= 3114) { - pinyin = "KAI"; - break; - } - - if (code >= 3115 && code <= 3120) { - pinyin = "KAN"; - break; - } - - if (code >= 3121 && code <= 3127) { - pinyin = "KANG"; - break; - } - - if (code >= 3128 && code <= 3131) { - pinyin = "KAO"; - break; - } - - if (code >= 3132 && code <= 3146) { - pinyin = "KE"; - break; - } - - if (code >= 3147 && code <= 3150) { - pinyin = "KEN"; - break; - } - - if (code >= 3151 && code <= 3152) { - pinyin = "KENG"; - break; - } - - if (code >= 3153 && code <= 3156) { - pinyin = "KONG"; - break; - } - - if (code >= 3157 && code <= 3160) { - pinyin = "KOU"; - break; - } - - if (code >= 3161 && code <= 3167) { - pinyin = "KU"; - break; - } - - if (code >= 3168 && code <= 3172) { - pinyin = "KUA"; - break; - } - - if (code >= 3173 && code <= 3176) { - pinyin = "KUAI"; - break; - } - - if (code >= 3177 && code <= 3178) { - pinyin = "KUAN"; - break; - } - - if (code >= 3179 && code <= 3186) { - pinyin = "KUANG"; - break; - } - - if (code >= 3187 && code <= 3203) { - pinyin = "KUI"; - break; - } - - if (code >= 3204 && code <= 3207) { - pinyin = "KUN"; - break; - } - - if (code >= 3208 && code <= 3211) { - pinyin = "KUO"; - break; - } - - if (code >= 3212 && code <= 3218) { - pinyin = "LA"; - break; - } - - if (code >= 3219 && code <= 3221) { - pinyin = "LAI"; - break; - } - - if (code >= 3222 && code <= 3236) { - pinyin = "LAN"; - break; - } - - if (code >= 3237 && code <= 3243) { - pinyin = "LANG"; - break; - } - - if (code >= 3244 && code <= 3252) { - pinyin = "LAO"; - break; - } - - if (code >= 3253 && code <= 3254) { - pinyin = "LE"; - break; - } - - if (code >= 3255 && code <= 3265) { - pinyin = "LEI"; - break; - } - - if (code >= 3266 && code <= 3268) { - pinyin = "LENG"; - break; - } - - if (code >= 3269 && code <= 3308) { - pinyin = "LI"; - } - - if (code == 3309) { - pinyin = "LIA"; - break; - } - - if (code >= 3310 && code <= 3323) { - pinyin = "LIAN"; - break; - } - - if (code >= 3324 && code <= 3334) { - pinyin = "LIANG"; - break; - } - - if (code >= 3335 && code <= 3347) { - pinyin = "LIAO"; - break; - } - - if (code >= 3348 && code <= 3352) { - pinyin = "LIE"; - break; - } - - if (code >= 3353 && code <= 3363) { - pinyin = "LIN"; - break; - } - - if (code >= 3364 && code <= 3378) { - pinyin = "LING"; - break; - } - - if (code >= 3379 && code <= 3389) { - pinyin = "LIU"; - break; - } - - if (code >= 3390 && code <= 3404) { - pinyin = "LONG"; - break; - } - - if (code >= 3405 && code <= 3410) { - pinyin = "LOU"; - break; - } - - if (code >= 3411 && code <= 3444) { - pinyin = "LU"; - break; - } - - if (code >= 3445 && code <= 3450) { - pinyin = "LUAN"; - break; - } - - if (code >= 3451 && code <= 3452) { - pinyin = "LUE"; - break; - } - - if (code >= 3453 && code <= 3459) { - pinyin = "LUN"; - break; - } - - if (code >= 3460 && code <= 3471) { - pinyin = "LUO"; - break; - } - - if (code >= 3472 && code <= 3480) { - pinyin = "MA"; - break; - } - - if (code >= 3481 && code <= 3486) { - pinyin = "MAI"; - break; - } - - if (code >= 3487 && code <= 3501) { - pinyin = "MAN"; - break; - } - - if (code >= 3502 && code <= 3507) { - pinyin = "MANG"; - break; - } - - if (code >= 3508 && code <= 3519) { - pinyin = "MAO"; - break; - } - - if (code == 3520) { - pinyin = "ME"; - break; - } - - if (code >= 3521 && code <= 3536) { - pinyin = "MEI"; - break; - } - - if (code >= 3537 && code <= 3539) { - pinyin = "MEN"; - break; - } - - if (code >= 3540 && code <= 3547) { - pinyin = "MENG"; - break; - } - - if (code >= 3548 && code <= 3561) { - pinyin = "MI"; - } - - if (code >= 3562 && code <= 3570) { - pinyin = "MIAN"; - break; - } - - if (code >= 3571 && code <= 3578) { - pinyin = "MIAO"; - break; - } - - if (code >= 3579 && code <= 3580) { - pinyin = "MIE"; - break; - } - - if (code >= 3581 && code <= 3586) { - pinyin = "MIN"; - break; - } - - if (code >= 3587 && code <= 3592) { - pinyin = "MING"; - break; - } - - if (code == 3593) { - pinyin = "MIU"; - break; - } - - if (code >= 3594 && code <= 3616) { - pinyin = "MO"; - break; - } - - if (code >= 3617 && code <= 3619) { - pinyin = "MOU"; - break; - } - - if (code >= 3620 && code <= 3634) { - pinyin = "MU"; - break; - } - - if (code >= 3635 && code <= 3641) { - pinyin = "NA"; - break; - } - - if (code >= 3642 && code <= 3646) { - pinyin = "NAI"; - break; - } - - if (code >= 3647 && code <= 3649) { - pinyin = "NAN"; - break; - } - - if (code == 3650) { - pinyin = "NANG"; - break; - } - - if (code >= 3651 && code <= 3655) { - pinyin = "NAO"; - break; - } - - if (code == 3656) { - pinyin = "NE"; - break; - } - - if (code >= 3657 && code <= 3658) { - pinyin = "NEI"; - break; - } - - if (code == 3659) { - pinyin = "NEN"; - break; - } - - if (code == 3660) { - pinyin = "NENG"; - break; - } - - if (code >= 3661 && code <= 3671) { - pinyin = "NI"; - break; - } - - if (code >= 3672 && code <= 3678) { - pinyin = "NIAN"; - break; - } - - if (code >= 3679 && code <= 3680) { - pinyin = "NIANG"; - break; - } - - if (code >= 3681 && code <= 3682) { - pinyin = "NIAO"; - break; - } - - if (code >= 3683 && code <= 3689) { - pinyin = "NIE"; - break; - } - - if (code == 3690) { - pinyin = "NIN"; - break; - } - - if (code >= 3691 && code <= 3702) { - pinyin = "NING"; - break; - } - - if (code >= 3703 && code <= 3706) { - pinyin = "NIU"; - break; - } - - if (code >= 3707 && code <= 3710) { - pinyin = "NONG"; - break; - } - - if (code >= 3711 && code <= 3714) { - pinyin = "NU"; - break; - } - - if (code == 3715) { - pinyin = "NUAN"; - break; - } - - if (code >= 3716 && code <= 3717) { - pinyin = "NUE"; - break; - } - - if (code >= 3718 && code <= 3721) { - pinyin = "NUO"; - break; - } - - if (code == 3722) { - pinyin = "O"; - break; - } - - if (code >= 3723 && code <= 3729) { - pinyin = "OU"; - break; - } - - if (code >= 3730 && code <= 3735) { - pinyin = "PA"; - break; - } - - if (code >= 3736 && code <= 3741) { - pinyin = "PAI"; - break; - } - - if (code >= 3742 && code <= 3749) { - pinyin = "PAN"; - break; - } - - if (code >= 3750 && code <= 3754) { - pinyin = "PANG"; - break; - } - - if (code >= 3755 && code <= 3761) { - pinyin = "PAO"; - break; - } - - if (code >= 3762 && code <= 3770) { - pinyin = "PEI"; - break; - } - - if (code >= 3771 && code <= 3772) { - pinyin = "PEN"; - break; - } - - if (code >= 3773 && code <= 3786) { - pinyin = "PENG"; - break; - } - - if (code >= 3787 && code <= 3809) { - pinyin = "PI"; - break; - } - - if (code >= 3810 && code <= 3813) { - pinyin = "PIAN"; - break; - } - - if (code >= 3814 && code <= 3817) { - pinyin = "PIAO"; - break; - } - - if (code >= 3818 && code <= 3819) { - pinyin = "PIE"; - break; - } - - if (code >= 3820 && code <= 3824) { - pinyin = "PIN"; - break; - } - - if (code >= 3825 && code <= 3833) { - pinyin = "PING"; - break; - } - - if (code >= 3834 && code <= 3841) { - pinyin = "PO"; - break; - } - - if (code == 3842) { - pinyin = "POU"; - break; - } - - if (code >= 3843 && code <= 3857) { - pinyin = "PU"; - break; - } - - if (code >= 3858 && code <= 3893) { - pinyin = "QI"; - break; - } - - if (code == 3894 || (code >= 3901 && code <= 3902)) { - pinyin = "QIA"; - break; - } - - if (code >= 3903 && code <= 3924) { - pinyin = "QIAN"; - break; - } - - if (code >= 3925 && code <= 3932) { - pinyin = "QIANG"; - break; - } - - if (code >= 3933 && code <= 3947) { - pinyin = "QIAO"; - break; - } - - if (code >= 3948 && code <= 3952) { - pinyin = "QIE"; - break; - } - - if (code >= 3953 && code <= 3963) { - pinyin = "QIN"; - break; - } - - if (code >= 3964 && code <= 3976) { - pinyin = "QING"; - break; - } - - if (code >= 3977 && code <= 3978) { - pinyin = "QIONG"; - break; - } - - if (code >= 3979 && code <= 3986) { - pinyin = "QIU"; - break; - } - - if (code >= 3987 && code <= 4005) { - pinyin = "QU"; - break; - } - - if (code >= 4006 && code <= 4016) { - pinyin = "QUAN"; - break; - } - - if (code >= 4017 && code <= 4024) { - pinyin = "QUE"; - break; - } - - if (code >= 4025 && code <= 4026) { - pinyin = "QUN"; - break; - } - - if (code >= 4027 && code <= 4030) { - pinyin = "RAN"; - break; - } - - if (code >= 4031 && code <= 4035) { - pinyin = "RANG"; - } - - if (code >= 4036 && code <= 4038) { - pinyin = "RAO"; - break; - } - - if (code >= 4039 && code <= 4040) { - pinyin = "RE"; - break; - } - - if (code >= 4041 && code <= 4050) { - pinyin = "REN"; - break; - } - - if (code >= 4051 && code <= 4052) { - pinyin = "RENG"; - break; - } - - if (code == 4053) { - pinyin = "RI"; - break; - } - - if (code >= 4054 && code <= 4063) { - pinyin = "RONG"; - break; - } - - if (code >= 4064 && code <= 4066) { - pinyin = "ROU"; - break; - } - - if (code >= 4067 && code <= 4076) { - pinyin = "RU"; - break; - } - - if (code >= 4077 && code <= 4078) { - pinyin = "RUAN"; - break; - } - - if (code >= 4079 && code <= 4081) { - pinyin = "RUI"; - break; - } - - if (code >= 4082 && code <= 4083) { - pinyin = "RUN"; - break; - } - - if (code >= 4084 && code <= 4085) { - pinyin = "RUO"; - break; - } - - if (code >= 4086 && code <= 4088) { - pinyin = "SA"; - break; - } - - if (code >= 4089 && code <= 4092) { - pinyin = "SAI"; - break; - } - - if (code >= 4093 && code <= 4094) { - pinyin = "SAN"; - break; - } - - if (code >= 4101 && code <= 4102) { - pinyin = "SAN"; - break; - } - - if (code >= 4103 && code <= 4105) { - pinyin = "SANG"; - break; - } - - if (code >= 4106 && code <= 4109) { - pinyin = "SAO"; - break; - } - - if (code >= 4110 && code <= 4112) { - pinyin = "SE"; - break; - } - - if (code == 4113) { - pinyin = "SEN"; - } - - if (code == 4114) { - pinyin = "SENG"; - break; - } - - if (code >= 4115 && code <= 4123) { - pinyin = "SHA"; - break; - } - - if (code >= 4124 && code <= 4125) { - pinyin = "SHAI"; - break; - } - - if (code >= 4126 && code <= 4141) { - pinyin = "SHAN"; - break; - } - - if (code >= 4142 && code <= 4149) { - pinyin = "SHANG"; - break; - } - - if (code >= 4150 && code <= 4160) { - pinyin = "SHAO"; - break; - } - - if (code >= 4161 && code <= 4172) { - pinyin = "SHE"; - break; - } - - if (code >= 4173 && code <= 4188) { - pinyin = "SHEN"; - break; - } - - if (code >= 4189 && code <= 4205) { - pinyin = "SHENG"; - break; - } - - if (code >= 4206 && code <= 4252) { - pinyin = "SHI"; - break; - } - - if (code >= 4253 && code <= 4262) { - pinyin = "SHOU"; - break; - } - - if (code >= 4263 && code <= 4301) { - pinyin = "SHU"; - break; - } - - if (code >= 4302 && code <= 4303) { - pinyin = "SHUA"; - break; - } - - if (code >= 4304 && code <= 4307) { - pinyin = "SHUAI"; - break; - } - - if (code >= 4308 && code <= 4309) { - pinyin = "SHUAN"; - break; - } - - if (code >= 4310 && code <= 4312) { - pinyin = "SHUANG"; - break; - } - - if (code >= 4313 && code <= 4316) { - pinyin = "SHUI"; - break; - } - - if (code >= 4317 && code <= 4320) { - pinyin = "SHUN"; - break; - } - - if (code >= 4321 && code <= 4324) { - pinyin = "SHUO"; - break; - } - - if (code >= 4325 && code <= 4340) { - pinyin = "SI"; - break; - } - - if (code >= 4341 && code <= 4348) { - pinyin = "SONG"; - break; - } - - if (code >= 4349 && code <= 4352) { - pinyin = "SOU"; - break; - } - - if (code >= 4353 && code <= 4364) { - pinyin = "SU"; - break; - } - - if (code >= 4365 && code <= 4367) { - pinyin = "SUAN"; - break; - } - - if (code >= 4368 && code <= 4378) { - pinyin = "SUI"; - break; - } - - if (code >= 4379 && code <= 4381) { - pinyin = "SUN"; - break; - } - - if (code >= 4382 && code <= 4389) { - pinyin = "SUO"; - break; - } - - if (code >= 4390 && code <= 4404) { - pinyin = "TA"; - break; - } - - if (code >= 4405 && code <= 4413) { - pinyin = "TAI"; - break; - } - - if (code >= 4414 && code <= 4431) { - pinyin = "TAN"; - break; - } - - if (code >= 4432 && code <= 4444) { - pinyin = "TANG"; - break; - } - - if (code >= 4445 && code <= 4455) { - pinyin = "TAO"; - break; - } - - if (code == 4456) { - pinyin = "TE"; - break; - } - - if (code >= 4457 && code <= 4460) { - pinyin = "TENG"; - break; - } - - if (code >= 4461 && code <= 4475) { - pinyin = "TI"; - break; - } - - if (code >= 4476 && code <= 4483) { - pinyin = "TIAN"; - break; - } - - if (code >= 4484 && code <= 4488) { - pinyin = "TIAO"; - break; - } - - if (code >= 4489 && code <= 4491) { - pinyin = "TIE"; - break; - } - - if (code >= 4492 && code <= 4507) { - pinyin = "TING"; - break; - } - - if (code >= 4508 && code <= 4520) { - pinyin = "TONG"; - break; - } - - if (code >= 4521 && code <= 4524) { - pinyin = "TOU"; - break; - } - - if (code >= 4525 && code <= 4535) { - pinyin = "TU"; - break; - } - - if (code >= 4536 && code <= 4537) { - pinyin = "TUAN"; - break; - } - - if (code >= 4538 && code <= 4543) { - pinyin = "TUI"; - break; - } - - if (code >= 4544 && code <= 4546) { - pinyin = "TUN"; - break; - } - - if (code >= 4547 && code <= 4557) { - pinyin = "TUO"; - break; - } - - if (code >= 4558 && code <= 4564) { - pinyin = "WA"; - break; - } - - if (code >= 4565 && code <= 4566) { - pinyin = "WAI"; - break; - } - - if (code >= 4567 && code <= 4583) { - pinyin = "WAN"; - break; - } - - if (code >= 4584 && code <= 4593) { - pinyin = "WANG"; - break; - } - - if (code >= 4594 && code <= 4632) { - pinyin = "WEI"; - break; - } - - if (code >= 4633 && code <= 4642) { - pinyin = "WEN"; - break; - } - - if (code >= 4643 && code <= 4645) { - pinyin = "WENG"; - break; - } - - if (code >= 4646 && code <= 4654) { - pinyin = "WO"; - break; - } - - if (code >= 4655 && code <= 4683) { - pinyin = "WU"; - break; - } - - if (code >= 4684 && code <= 4724) { - pinyin = "XI"; - break; - } - - if (code >= 4725 && code <= 4737) { - pinyin = "XIA"; - break; - } - - if (code >= 4738 && code <= 4763) { - pinyin = "XIAN"; - break; - } - - if (code >= 4764 && code <= 4783) { - pinyin = "XIANG"; - break; - } - - if (code >= 4784 && code <= 4807) { - pinyin = "XIAO"; - break; - } - - if (code >= 4809 && code <= 4828) { - pinyin = "XIE"; - break; - } - - if (code >= 4829 && code <= 4838) { - pinyin = "XIN"; - break; - } - - if (code >= 4839 && code <= 4853) { - pinyin = "XING"; - break; - } - - if (code >= 4854 && code <= 4860) { - pinyin = "XIONG"; - break; - } - - if (code >= 4861 && code <= 4869) { - pinyin = "XIU"; - break; - } - - if (code >= 4870 && code <= 4888) { - pinyin = "XU"; - break; - } - - if (code >= 4889 && code <= 4904) { - pinyin = "XUAN"; - break; - } - - if (code >= 4905 && code <= 4910) { - pinyin = "XUE"; - break; - } - - if (code >= 4911 && code <= 4924) { - pinyin = "XUN"; - break; - } - - if (code >= 4925 && code <= 4940) { - pinyin = "YA"; - break; - } - - if (code >= 4941 && code <= 4973) { - pinyin = "YAN"; - break; - } - - if (code >= 4974 && code <= 4990) { - pinyin = "YANG"; - break; - } - - if (code >= 4991 && code <= 5011) { - pinyin = "YAO"; - break; - } - - if (code >= 5012 && code <= 5026) { - pinyin = "YE"; - break; - } - - if (code >= 5027 && code <= 5079) { - pinyin = "YI"; - break; - } - - if (code >= 5080 && code <= 5101) { - pinyin = "YIN"; - break; - } - - if (code >= 5102 && code <= 5119) { - pinyin = "YING"; - break; - } - - if (code == 5120) { - pinyin = "YO"; - break; - } - - if (code >= 5121 && code <= 5135) { - pinyin = "YONG"; - break; - } - - if (code >= 5136 && code <= 5155) { - pinyin = "YOU"; - break; - } - - if (code >= 5156 && code <= 5206) { - pinyin = "YU"; - break; - } - - if (code >= 5207 && code <= 5226) { - pinyin = "YUAN"; - break; - } - - if (code >= 5227 && code <= 5236) { - pinyin = "YUE"; - break; - } - - if (code >= 5237 && code <= 5248) { - pinyin = "YUN"; - break; - } - - if (code >= 5249 && code <= 5251) { - pinyin = "ZA"; - break; - } - - if (code >= 5252 && code <= 5258) { - pinyin = "ZAI"; - break; - } - - if (code >= 5259 && code <= 5262) { - pinyin = "ZAN"; - break; - } - - if (code >= 5263 && code <= 5265) { - pinyin = "ZANG"; - break; - } - - if (code >= 5266 && code <= 5279) { - pinyin = "ZAO"; - break; - } - - if (code >= 5280 && code <= 5283) { - pinyin = "ZE"; - break; - } - - if (code == 5284) { - pinyin = "ZEI"; - break; - } - - if (code == 5285) { - pinyin = "ZEN"; - break; - } - - if (code >= 5286 && code <= 5289) { - pinyin = "ZENG"; - break; - } - - if (code >= 5290 && code <= 5309) { - pinyin = "ZHA"; - break; - } - - if (code >= 5310 && code <= 5315) { - pinyin = "ZHAI"; - break; - } - - if (code >= 5316 && code <= 5332) { - pinyin = "ZHAN"; - break; - } - - if (code >= 5333 && code <= 5347) { - pinyin = "ZHANG"; - break; - } - - if (code >= 5348 && code <= 5357) { - pinyin = "ZHAO"; - break; - } - - if (code >= 5358 && code <= 5367) { - pinyin = "ZHE"; - break; - } - - if (code >= 5368 && code <= 5383) { - pinyin = "ZHEN"; - break; - } - - if (code >= 5384 && code <= 5404) { - pinyin = "ZHENG"; - break; - } - - if (code >= 5405 && code <= 5447) { - pinyin = "ZHI"; - break; - } - - if (code >= 5448 && code <= 5458) { - pinyin = "ZHONG"; - break; - } - - if (code >= 5459 && code <= 5472) { - pinyin = "ZHOU"; - break; - } - - if (code >= 5473 && code <= 5504) { - pinyin = "ZHU"; - break; - } - - if (code >= 5505 && code <= 5506) { - pinyin = "ZHUA"; - break; - } - - if (code == 5507) { - pinyin = "ZHUAI"; - break; - } - - if (code >= 5508 && code <= 5513) { - pinyin = "ZHUAN"; - break; - } - - if (code >= 5514 && code <= 5520) { - pinyin = "ZHUANG"; - break; - } - - if (code >= 5521 && code <= 5526) { - pinyin = "ZHUI"; - break; - } - - if (code >= 5527 && code <= 5528) { - pinyin = "ZHUN"; - break; - } - - if (code >= 5529 && code <= 5539) { - pinyin = "ZHUO"; - break; - } - - if (code >= 5540 && code <= 5554) { - pinyin = "ZI"; - break; - } - - if (code >= 5555 && code <= 5561) { - pinyin = "ZONG"; - break; - } - - if (code >= 5562 && code <= 5565) { - pinyin = "ZOU"; - break; - } - - if (code >= 5566 && code <= 5573) { - pinyin = "ZU"; - break; - } - - if (code >= 5574 && code <= 5575) { - pinyin = "ZUAN"; - break; - } - - if (code >= 5576 && code <= 5579) { - pinyin = "ZUI"; - break; - } - - if (code >= 5580 && code <= 5581) { - pinyin = "ZUN"; - break; - } - - if (code >= 5582 && code <= 5589) { - pinyin = "ZUO"; - break; - } - } - - if (pinyin.isEmpty()) { - pinyin = ""; - } - - return pinyin; -} - diff --git a/src/BackProcess/Interface/ukuimenuinterface.cpp b/src/BackProcess/Interface/ukuimenuinterface.cpp deleted file mode 100644 index 0f7386c..0000000 --- a/src/BackProcess/Interface/ukuimenuinterface.cpp +++ /dev/null @@ -1,1642 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include "ukui_chineseletter.h" - -UkuiMenuInterface::UkuiMenuInterface() -{ - if (!g_projectCodeName.contains("V10SP1-edu")) { - } else { - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - setting = new QSettings(path, QSettings::IniFormat); - QString syspath = QDir::homePath() + "/.config/ukui/menusysapplist.ini"; - syssetting = new QSettings(syspath, QSettings::IniFormat); - } -} - -QVector UkuiMenuInterface::appInfoVector = QVector(); -QVector UkuiMenuInterface::desktopfpVector = QVector(); -QVector UkuiMenuInterface::collectAppVector = QVector(); -QVector UkuiMenuInterface::alphabeticVector = QVector(); -QVector UkuiMenuInterface::functionalVector = QVector(); -QVector UkuiMenuInterface::allAppVector = QVector(); -QStringList UkuiMenuInterface::androidDesktopfnList = QStringList(); -QVector UkuiMenuInterface::tencentInitVector = QVector(); -QVector UkuiMenuInterface::customizedVector = QVector(); -QVector UkuiMenuInterface::thirdPartyVector = QVector(); -QVector UkuiMenuInterface::applicationVector = QVector(); - -UkuiMenuInterface::~UkuiMenuInterface() -{ - if (!g_projectCodeName.contains("V10SP1-edu")) { - } else { - if (setting) { - delete setting; - } - - if (syssetting) { - delete syssetting; - } - - setting = nullptr; - syssetting = nullptr; - } -} - -QStringList UkuiMenuInterface::getFunctionClassName() -{ - QStringList functionList; - functionList.append(QObject::tr("Office")); - functionList.append(QObject::tr("Development")); - functionList.append(QObject::tr("Image")); - functionList.append(QObject::tr("Video")); - functionList.append(QObject::tr("Internet")); - functionList.append(QObject::tr("Game")); - functionList.append(QObject::tr("Education")); - functionList.append(QObject::tr("Social")); - functionList.append(QObject::tr("System")); - functionList.append(QObject::tr("Safe")); - functionList.append(QObject::tr("Others")); - return functionList; -} -//文件递归查询 -void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) -{ - if (!g_projectCodeName.contains("V10SP1-edu")) { - QDir dir(_filePath); - - if (!dir.exists()) { - return; - } - - dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); - dir.setSorting(QDir::DirsFirst); - QFileInfoList list = dir.entryInfoList(); - - if (list.size() < 1) { - return; - } - - int i = 0; - - //递归算法的核心部分 - do { - QFileInfo fileInfo = list.at(i); - //如果是文件夹,递归 - bool isDir = fileInfo.isDir(); - - if (isDir) { - recursiveSearchFile(fileInfo.filePath()); - } else { - //过滤后缀不是.desktop的文件 - QString filePathStr = fileInfo.filePath(); - - if (!filePathStr.endsWith(".desktop")) { - i++; - continue; - } - - QByteArray fpbyte = filePathStr.toLocal8Bit(); - char *filepath = fpbyte.data(); - - if (0 != access(filepath, R_OK)) { //判断文件是否可读 - i++; - continue; - } - - keyfile = g_key_file_new(); - - if (!g_key_file_load_from_file(keyfile, filepath, flags, error)) { - return; - } - - char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); - - if (ret_1 != nullptr) { - QString str = QString::fromLocal8Bit(ret_1); - - if (str.contains("true")) { - g_key_file_free(keyfile); - i++; - continue; - } - } - - char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); - - if (ret_2 != nullptr) { - QString str = QString::fromLocal8Bit(ret_2); - - if (str.contains("UKUI")) { - g_key_file_free(keyfile); - i++; - continue; - } - } - - //过滤LXQt、KDE - char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); - - if (ret != nullptr) { - QString str = QString::fromLocal8Bit(ret); - - if (str.contains("LXQt") || str.contains("KDE")) { - g_key_file_free(keyfile); - i++; - continue; - } - } - - g_key_file_free(keyfile); - m_filePathList.append(filePathStr); - } - - i++; - } while (i < list.size()); - } else { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QDir dir(_filePath); - - if (!dir.exists()) { - return; - } - - dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); - dir.setSorting(QDir::DirsFirst); - QFileInfoList list = dir.entryInfoList(); - list.removeAll(QFileInfo("/usr/share/applications/screensavers")); - - if (list.size() < 1) { - return; - } - - int i = 0; - - //递归算法的核心部分 - do { - QFileInfo fileInfo = list.at(i); - //如果是文件夹,递归 - bool isDir = fileInfo.isDir(); - - if (isDir) { - recursiveSearchFile(fileInfo.filePath()); - } else { - //过滤后缀不是.desktop的文件 - QString filePathStr = fileInfo.filePath(); - - if (!filePathStr.endsWith(".desktop")) { - i++; - continue; - } - - QByteArray fpbyte = filePathStr.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); - - if (ret_1 != nullptr) { - QString str = QString::fromLocal8Bit(ret_1); - - if (str.contains("true")) { - i++; - continue; - } - } - - char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); - - if (ret_2 != nullptr) { - QString str = QString::fromLocal8Bit(ret_2); - - if (str.contains("UKUI")) { - i++; - continue; - } - } - - //过滤LXQt、KDE - char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); - - if (ret != nullptr) { - QString str = QString::fromLocal8Bit(ret); - - if (str.contains("LXQt") || str.contains("KDE")) { - i++; - continue; - } - } - - //过滤中英文名为空的情况 - QLocale cn; - QString language = cn.languageToString(cn.language()); - - if (QString::compare(language, "Chinese") == 0) { - char *nameCh = g_key_file_get_string(keyfile, "Desktop Entry", "Name[zh_CN]", nullptr); - char *nameEn = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); - - if (QString::fromLocal8Bit(nameCh).isEmpty() && QString::fromLocal8Bit(nameEn).isEmpty()) { - i++; - continue; - } - } else { - char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); - - if (QString::fromLocal8Bit(name).isEmpty()) { - i++; - continue; - } - } - - m_filePathList.append(filePathStr); - } - - i++; - } while (i < list.size()); - - g_key_file_free(keyfile); - } -} - -//获取系统desktop文件路径 -QStringList UkuiMenuInterface::getDesktopFilePath() -{ - if (!g_projectCodeName.contains("V10SP1-edu")) { - m_filePathList.clear(); - QString jsonPath = QDir::homePath() + "/.config/ukui-menu-security-config.json"; - QFile file(jsonPath); - - if (file.exists()) { - file.open(QIODevice::ReadOnly); - QByteArray readBy = file.readAll(); - QJsonParseError error; - QJsonDocument readDoc = QJsonDocument::fromJson(readBy, &error); - - if (!readDoc.isNull() && error.error == QJsonParseError::NoError) { - QJsonObject obj = readDoc.object().value("ukui-menu").toObject(); - - if (obj.value("mode").toString() == "whitelist") { - QJsonArray blArray = obj.value("whitelist").toArray(); - QJsonArray enArray = blArray.at(0).toObject().value("entries").toArray(); - - for (int index = 0; index < enArray.size(); index++) { - QJsonObject obj = enArray.at(index).toObject(); - m_filePathList.append(obj.value("path").toString()); - // qDebug()< reply = desktopfpListiface.call("GetDesktopAppList",username); - //1、获取系统应用列表 - //filePathList; - QStringList ifFileDesktopList; - /*新的应用列表*/ - myDebug() << "sysapplistnum初始化默认应用列表" << m_filePathList.count(); - - for (int i = 0; i < m_filePathList.count(); i++) { //过滤 得到真实存在的应用 - QString tmp = m_filePathList.at(i); - QFileInfo fileInfo(tmp); - - if (!fileInfo.isFile()) { //判断是否存在 - //qDebug()<beginGroup("ukui-menu-sysapplist"); - int sysapplistnum = syssetting->allKeys().count(); - syssetting->sync(); - syssetting->endGroup(); - //qDebug()<<"sysapplistnum初始化默认应用列表3"<beginGroup("ukui-menu-sysapplist"); - myDebug() << "isnottencent" << str; - syssetting->setValue(str, 0); - syssetting->sync(); - syssetting->endGroup(); - } - }/*else{ - - //用户隔离/etc/skel/桌面 - QString tmp=QString("%1%2").arg("/usr/share/applications/").arg(str); - QString appid=getTencentAppid(tmp); - qDebug()<<"appid"< UkuiMenuInterface::createAppInfoVector() -{ - desktopfpVector.clear(); - QVector appInfoVector; - QVector vector; - vector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公 - vector.append(QStringList() << "develop" << "Development"); //1开发 - vector.append(QStringList() << "graphic" << "Graphics"); //2图像 - vector.append(QStringList() << "video" << "Audio" << "Video"); //3影音 - vector.append(QStringList() << "network" << "Network"); //4网络 - vector.append(QStringList() << "game" << "Game"); //5游戏 - vector.append(QStringList() << "education" << "Education"); //6教育 - vector.append(QStringList() << "social" << "Messaging"); //7社交 - vector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统 - vector.append(QStringList() << "safe"); //9安全 - vector.append(QStringList() << "others"); //10其他 - QStringList desktopfpList = getDesktopFilePath(); - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); - QSqlQuery sql(db); - - for (int i = 0; i < desktopfpList.count(); i++) { - QStringList appInfoList; - QString desktopfp = desktopfpList.at(i); - QString name = getAppName(desktopfpList.at(i)); - - if (!name.isEmpty()) { - QString englishName = getAppEnglishName(desktopfpList.at(i)); - QString letter = getAppNameInitial(desktopfpList.at(i)); - QString letters = getAppNameInitials(desktopfpList.at(i)); - desktopfpVector.append(desktopfp); - appInfoList << desktopfp << name << englishName << letter << letters; - - if (!g_projectCodeName.contains("V10SP1-edu")) { - QString desktopfpExecName = getAppExec(desktopfpList.at(i)); - desktopfpExecName = desktopfpExecName.mid(desktopfpExecName.lastIndexOf("/") + 1); - desktopfpExecName = desktopfpExecName.left(desktopfpExecName.lastIndexOf(" ")); - sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName)); - - if (sql.next()) { - for (int j = 0; j < vector.size(); j++) { - if (vector.at(j).contains(sql.value(0).toString())) { - appInfoList.append(QString::number(j)); - } - } - - appInfoVector.append(appInfoList); - continue; - } - } - - bool is_owned = false; - - for (int j = 0; j < vector.size(); j++) { - if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { //有对应分类 - is_owned = true; - appInfoList.append(QString::number(j)); - } - } - - if (!is_owned) { //该应用无对应分类 - appInfoList.append(QString::number(10)); - } - - appInfoVector.append(appInfoList); - } - } - - return appInfoVector; -} -//获取tencent应用名 -QString UkuiMenuInterface::getTencentAppid(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *Appid = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Appid", nullptr, nullptr); - g_key_file_free(keyfile); - return QString::fromLocal8Bit(Appid); -} -//获取应用名称 -QString UkuiMenuInterface::getAppName(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Name", nullptr, nullptr); - QString namestr = QString::fromLocal8Bit(name); - g_key_file_free(keyfile); - return namestr; -} -//获取英应用英文名 -QString UkuiMenuInterface::getAppEnglishName(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); - QString namestr = QString::fromLocal8Bit(name); - return namestr; -} -//获取应用分类 -QString UkuiMenuInterface::getAppCategories(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *category = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); - g_key_file_free(keyfile); - return QString::fromLocal8Bit(category); -} -//获取应用图标 -QString UkuiMenuInterface::getAppIcon(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *icon = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Icon", nullptr, nullptr); - g_key_file_free(keyfile); - return QString::fromLocal8Bit(icon); -} -//获取应用命令 -QString UkuiMenuInterface::getAppExec(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *exec = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); - g_key_file_free(keyfile); - return QString::fromLocal8Bit(exec); -} -//获取应用注释 -QString UkuiMenuInterface::getAppComment(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *comment = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Comment", nullptr, nullptr); - g_key_file_free(keyfile); - return QString::fromLocal8Bit(comment); -} -//获取应用类型 -QString UkuiMenuInterface::getAppType(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *type = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Type", nullptr, nullptr); - g_key_file_free(keyfile); - return QString::fromLocal8Bit(type); -} -bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2) -{ - QLocale local; - QString language = local.languageToString(local.language()); - - if (QString::compare(language, "Chinese") == 0) { - local = QLocale(QLocale::Chinese); - } else { - local = QLocale(QLocale::English); - } - - QCollator collator(local); - - if (collator.compare(arg_1.at(1), arg_2.at(1)) < 0) { - return true; - } else { - return false; - } -} -bool UkuiMenuInterface::initAppIni() -{ - if (false) { - QVector appInitVector; - QVector tencentInitVectorList; - QVector customizedVectorList; - QVector thirdPartyVectorList; - QString tencent_math = "/usr/share/applications/tencent-math-precise-practice.desktop"; - QString tencent_chinese = "/usr/share/applications/tencent-chinese-precise-practice.desktop"; - QString tencent_english = "/usr/share/applications/tencent-english-precise-practice.desktop"; - QVector precise_practiceVector; - QStringList math; - QStringList english; - QStringList chainese; - setting->beginGroup("application"); - QStringList desktopfnList = setting->allKeys(); - setting->endGroup(); - - if (desktopfnList.count() == 0) { - for (int i = 0; i < appInfoVector.count(); i++) { - //qDebug()<<"appInfoVector"<beginGroup("tencent"); - - for (int i = 0; i < tencentInitVectorList.count(); i++) { - QString str = tencentInitVectorList.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - //qDebug()<setValue(str, i); - } - - setting->sync(); - setting->endGroup(); - // int a=tencentInitVectorList.count(); - setting->beginGroup("customized"); - - for (int i = 0; i < customizedVectorList.count(); i++) { - QString str = customizedVectorList.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - setting->setValue(str, i); - } - - setting->sync(); - setting->endGroup(); - // int b=customizedVector.count(); - setting->beginGroup("thirdParty"); - - for (int i = 0; i < thirdPartyVectorList.count(); i++) { - QString str = thirdPartyVectorList.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - setting->setValue(str, i); - } - - setting->sync(); - setting->endGroup(); - // int c=thirdPartyVectorList.count(); - setting->beginGroup("application"); - - for (int i = 0; i < appInitVector.count(); i++) { //赋值 - QString str = appInitVector.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - setting->setValue(str, i); - } - - setting->sync(); - setting->endGroup(); - return 1; - } - - return 0; - } else { - QVector appInitVector; - QVector tencentInitVector; - QVector customizedVector; - QVector thirdPartyVector; - QString tencent_math = "/usr/share/applications/tencent-math-precise-practice.desktop"; - QString tencent_chinese = "/usr/share/applications/tencent-chinese-precise-practice.desktop"; - QString tencent_english = "/usr/share/applications/tencent-english-precise-practice.desktop"; - QVector precise_practiceVector; - QStringList math; - QStringList english; - QStringList chainese; - setting->beginGroup("application"); - QStringList desktopfnList = setting->allKeys(); - setting->endGroup(); - - if (desktopfnList.count() == 0) { - for (int i = 0; i < desktopfpVector.count(); i++) { - //qDebug()<<"appInfoVector"<beginGroup("application"); - - for (int i = 0; i < tencentInitVector.count(); i++) { - QString str = tencentInitVector.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - //qDebug()<setValue(str, i); - } - - int a = tencentInitVector.count(); - - for (int i = 0; i < customizedVector.count(); i++) { - QString str = customizedVector.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - setting->setValue(str, i + a); - } - - int b = customizedVector.count(); - - for (int i = 0; i < thirdPartyVector.count(); i++) { - QString str = thirdPartyVector.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - setting->setValue(str, i + a + b); - } - - int c = thirdPartyVector.count(); - - for (int i = 0; i < appInitVector.count(); i++) { //赋值 - QString str = appInitVector.at(i).at(0).section(' ', 0, 0); - QStringList list = str.split('/'); - str = list[list.size() - 1]; - setting->setValue(str, i + a + b + c); - } - - int d = appInitVector.count(); - setting->setValue("kylin-user-guide.desktop", a + b + c + d); - setting->sync(); - setting->endGroup(); - return 1; - } - - return 0; - } -} -QVector UkuiMenuInterface::getAllClassification() -{ - QVector allAppVector; - QVector commonVector; - QVector appVector; - allAppVector.clear(); - commonVector.clear(); - appVector.clear(); - commonVector = getCommonUseApp(); - int index = 0; - - Q_FOREACH (QString desktopfp, desktopfpVector) { - if (!commonVector.contains(desktopfp)) { - appVector.append(appInfoVector.at(index)); - } - - index++; - } - - qSort(appVector.begin(), appVector.end(), cmpApp); - - Q_FOREACH (QString desktopfp, commonVector) { - allAppVector.append(desktopfp); - } - - for (int index = 0; index < appVector.size(); index++) { - allAppVector.append(appVector.at(index).at(0)); - } - - return allAppVector; -} -QVector UkuiMenuInterface::getCommonUseApp() -{ - // QDateTime dt=QDateTime::currentDateTime(); - // int currentDateTime=dt.toTime_t(); - // int nDaySec=24*60*60; - // setting->beginGroup("datetime"); - // QStringList dateTimeKeys=setting->allKeys(); - // QStringList timeOutKeys; - // timeOutKeys.clear(); - // for(int i=0;ivalue(dateTimeKeys.at(i)).toInt())/nDaySec >= 4) - // { - // timeOutKeys.append(dateTimeKeys.at(i)); - // } - // } - // setting->endGroup(); - // for(int i=0;ibeginGroup("application"); - // setting->remove(timeOutKeys.at(i)); - // setting->sync(); - // setting->endGroup(); - // setting->beginGroup("datetime"); - // setting->remove(timeOutKeys.at(i)); - // setting->sync(); - // setting->endGroup(); - // } - // setting->beginGroup("lockapplication"); - // QStringList lockdesktopfnList=setting->allKeys(); - // for(int i=0;ivalue(lockdesktopfnList.at(j)).toInt(); - // int value_2=setting->value(lockdesktopfnList.at(j+1)).toInt(); - // if(value_1 > value_2) - // { - // QString tmp=lockdesktopfnList.at(j); - // lockdesktopfnList.replace(j,lockdesktopfnList.at(j+1)); - // lockdesktopfnList.replace(j+1,tmp); - // } - // } - // setting->endGroup(); - // setting->beginGroup("application"); - // QStringList desktopfnList=setting->allKeys(); - // for(int i=0;ivalue(desktopfnList.at(j)).toInt(); - // int value_2=setting->value(desktopfnList.at(j+1)).toInt(); - // if(value_1 < value_2) - // { - // QString tmp=desktopfnList.at(j); - // desktopfnList.replace(j,desktopfnList.at(j+1)); - // desktopfnList.replace(j+1,tmp); - // } - // } - // setting->endGroup(); - // QVector data; - // Q_FOREACH(QString desktopfn,lockdesktopfnList) - // { - // QString desktopfp; - // if(androidDesktopfnList.contains(desktopfn)) - // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); - // else - // desktopfp=QString("/usr/share/applications/"+desktopfn); - // QFileInfo fileInfo(desktopfp); - // if(!fileInfo.isFile()|| !desktopfpVector.contains(desktopfp)) - // continue; - // data.append(desktopfp); - // } - // Q_FOREACH(QString desktopfn,desktopfnList) - // { - // QString desktopfp; - // if(androidDesktopfnList.contains(desktopfn)) - // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); - // else - // desktopfp=QString("/usr/share/applications/"+desktopfn); - // QFileInfo fileInfo(desktopfp); - // if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) - // continue; - // data.append(desktopfp); - // } - if (!g_projectCodeName.contains("V10SP1-edu")) { - QVector data; - - Q_FOREACH (QString desktopfn, getLockAppList()) { - QString desktopfp; - - if (androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - - QFileInfo fileInfo(desktopfp); - - if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { - continue; - } - - data.append(desktopfp); - } - - Q_FOREACH (QString desktopfn, getUnlockAllList()) { - QString desktopfp; - - if (androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - - QFileInfo fileInfo(desktopfp); - - if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { - continue; - } - - data.append(desktopfp); - } - - return data; - } -} - -QVector UkuiMenuInterface::sortDesktopList(QString group) -{ - setting->beginGroup(group); - QStringList desktopfnList = setting->allKeys(); - - for (int i = 0; i < desktopfnList.count() - 1; i++) - for (int j = 0; j < desktopfnList.count() - 1 - i; j++) { //冒泡排序常用的应用从大到小排列desktopfnList - int value_1 = setting->value(desktopfnList.at(j)).toInt(); - int value_2 = setting->value(desktopfnList.at(j + 1)).toInt(); - - if (value_1 > value_2) { - QString tmp = desktopfnList.at(j); - desktopfnList.replace(j, desktopfnList.at(j + 1)); - desktopfnList.replace(j + 1, tmp); - } - } - - setting->sync(); - setting->endGroup(); - QVector data; - - Q_FOREACH (QString desktopfn, desktopfnList) { - QString desktopfp; - - if (androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - - data.append(desktopfp); - } - - return data; -} -QVector UkuiMenuInterface::getCollectApp() -{ - QVector data; - - Q_FOREACH (QString desktopfn, getCollectAppList()) { - QString desktopfp; - - if (androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - - QFileInfo fileInfo(desktopfp); - - if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { - continue; - } - - data.append(desktopfp); - } - - return data; -} -QVector UkuiMenuInterface::getLockApp() -{ - setting->beginGroup("lockapplication"); - QStringList lockdesktopfnList = setting->allKeys(); - - for (int i = 0; i < lockdesktopfnList.count() - 1; i++) //冒泡排序锁住的应用从小到大排列lockdesktopfnList - for (int j = 0; j < lockdesktopfnList.count() - 1 - i; j++) { - int value_1 = setting->value(lockdesktopfnList.at(j)).toInt(); - int value_2 = setting->value(lockdesktopfnList.at(j + 1)).toInt(); - - if (value_1 > value_2) { - QString tmp = lockdesktopfnList.at(j); - lockdesktopfnList.replace(j, lockdesktopfnList.at(j + 1)); - lockdesktopfnList.replace(j + 1, tmp); - } - } - - setting->endGroup(); - QVector data; - - Q_FOREACH (QString desktopfn, lockdesktopfnList) { - QString desktopfp; - // if(androidDesktopfnList.contains(desktopfn))//如果锁的应用在安卓列表 - // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); - // else - desktopfp = QString("/usr/share/applications/" + desktopfn); - // QFileInfo fileInfo(desktopfp); - // if(!fileInfo.isFile())//判断是否存在 - // continue; - data.append(desktopfp);//加入data - } - - return data; -} -QVector UkuiMenuInterface::getAlphabeticClassification() -{ - QVector data; - QStringList appnameList; - appnameList.clear(); - QVector appVector[27]; - int index = 0; - - while (index < appInfoVector.size()) { - QString appname = appInfoVector.at(index).at(1); - QString appnamepy = UkuiChineseLetter::getPinyins(appname); - - if (!appnamepy.isEmpty()) { - char c = appnamepy.at(0).toLatin1(); - - switch (c) { - case 'A': - appVector[0].append(appInfoVector.at(index)); - break; - - case 'B': - appVector[1].append(appInfoVector.at(index)); - break; - - case 'C': - appVector[2].append(appInfoVector.at(index)); - break; - - case 'D': - appVector[3].append(appInfoVector.at(index)); - break; - - case 'E': - appVector[4].append(appInfoVector.at(index)); - break; - - case 'F': - appVector[5].append(appInfoVector.at(index)); - break; - - case 'G': - appVector[6].append(appInfoVector.at(index)); - break; - - case 'H': - appVector[7].append(appInfoVector.at(index)); - break; - - case 'I': - appVector[8].append(appInfoVector.at(index)); - break; - - case 'J': - appVector[9].append(appInfoVector.at(index)); - break; - - case 'K': - appVector[10].append(appInfoVector.at(index)); - break; - - case 'L': - appVector[11].append(appInfoVector.at(index)); - break; - - case 'M': - appVector[12].append(appInfoVector.at(index)); - break; - - case 'N': - appVector[13].append(appInfoVector.at(index)); - break; - - case 'O': - appVector[14].append(appInfoVector.at(index)); - break; - - case 'P': - appVector[15].append(appInfoVector.at(index)); - break; - - case 'Q': - appVector[16].append(appInfoVector.at(index)); - break; - - case 'R': - appVector[17].append(appInfoVector.at(index)); - break; - - case 'S': - appVector[18].append(appInfoVector.at(index)); - break; - - case 'T': - appVector[19].append(appInfoVector.at(index)); - break; - - case 'U': - appVector[20].append(appInfoVector.at(index)); - break; - - case 'V': - appVector[21].append(appInfoVector.at(index)); - break; - - case 'W': - appVector[22].append(appInfoVector.at(index)); - break; - - case 'X': - appVector[23].append(appInfoVector.at(index)); - break; - - case 'Y': - appVector[24].append(appInfoVector.at(index)); - break; - - case 'Z': - appVector[25].append(appInfoVector.at(index)); - break; - - default: - appVector[26].append(appInfoVector.at(index)); - break; - } - } - - index++; - } - - for (int i = 0; i < 26; i++) { - QStringList desktopfpList; - desktopfpList.clear(); - qSort(appVector[i].begin(), appVector[i].end(), cmpApp); - - for (int j = 0; j < appVector[i].size(); j++) { - desktopfpList.append(appVector[i].at(j).at(0)); - } - - data.append(desktopfpList); - } - - QVector otherVector; - QVector numberVector; - - for (int i = 0; i < appVector[26].count(); i++) { - QString appname = appVector[26].at(i).at(2); - QChar c = appname.at(0); - - if (c < 48 || (c > 57 && c < 65) || c > 90) { - otherVector.append(appVector[26].at(i)); - } else { - numberVector.append(appVector[26].at(i)); - } - } - - qSort(otherVector.begin(), otherVector.end(), cmpApp); - qSort(numberVector.begin(), numberVector.end(), cmpApp); - QStringList otherfpList; - otherfpList.clear(); - - for (int i = 0; i < otherVector.size(); i++) { - otherfpList.append(otherVector.at(i).at(0)); - } - - QStringList numberfpList; - numberfpList.clear(); - - for (int i = 0; i < numberVector.size(); i++) { - numberfpList.append(numberVector.at(i).at(0)); - } - - data.append(otherfpList); - data.append(numberfpList); - return data; -} -QVector UkuiMenuInterface::getFunctionalClassification() -{ - QVector appVector[11]; - int index = 0; - - while (index < appInfoVector.size()) { - int count = appInfoVector.at(index).size() - 5; - - for (int i = 0; i < count; i++) { - int category = appInfoVector.at(index).at(5 + i).toInt(); - - switch (category) { - case 0: - appVector[0].append(appInfoVector.at(index)); - break; - - case 1: - appVector[1].append(appInfoVector.at(index)); - break; - - case 2: - appVector[2].append(appInfoVector.at(index)); - break; - - case 3: - appVector[3].append(appInfoVector.at(index)); - break; - - case 4: - appVector[4].append(appInfoVector.at(index)); - break; - - case 5: - appVector[5].append(appInfoVector.at(index)); - break; - - case 6: - appVector[6].append(appInfoVector.at(index)); - break; - - case 7: - appVector[7].append(appInfoVector.at(index)); - break; - - case 8: - appVector[8].append(appInfoVector.at(index)); - break; - - case 9: - appVector[9].append(appInfoVector.at(index)); - break; - - case 10: - appVector[10].append(appInfoVector.at(index)); - break; - - default: - break; - } - } - - index++; - } - - QVector data; - data.clear(); - - for (int i = 0; i < 11; i++) { - QStringList desktopfpList; - desktopfpList.clear(); - qSort(appVector[i].begin(), appVector[i].end(), cmpApp); - - for (int j = 0; j < appVector[i].size(); j++) { - desktopfpList.append(appVector[i].at(j).at(0)); - } - - data.append(desktopfpList); - } - - return data; -} -bool UkuiMenuInterface::matchingAppCategories(QString desktopfp, QStringList categorylist) -{ - QString category = getAppCategories(desktopfp); - int index; - - for (index = 0; index < categorylist.count(); index++) { - if (category.contains(categorylist.at(index), Qt::CaseInsensitive)) { - return true; - } - } - - if (index == categorylist.count()) { - return false; - } - - return false; -} -void UkuiMenuInterface::getAndroidApp() -{ - androidDesktopfnList.clear(); - QVector androidVector; - androidVector.clear(); - QString path = QDir::homePath() + "/.local/share/applications/"; - QDir dir(path); - - if (!dir.exists()) { - return; - } - - dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); - dir.setSorting(QDir::DirsFirst); - QFileInfoList list = dir.entryInfoList(); - - if (list.size() < 1) { - return; - } - - int i = 0; - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - - do { - QFileInfo fileInfo = list.at(i); - - if (!fileInfo.isFile()) { - i++; - continue; - } - - //过滤后缀不是.desktop的文件 - QString filePathStr = fileInfo.filePath(); - - if (!filePathStr.endsWith(".desktop")) { - i++; - continue; - } - - QByteArray fpbyte = filePathStr.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); - - if (ret_1 != nullptr) { - // QString str=QString::fromLocal8Bit(ret_1); - // if(!str.contains("Android")) - // { - // i++; - // continue; - // } - // else - // { - m_filePathList.append(filePathStr); - androidDesktopfnList.append(fileInfo.fileName()); - // } - } - - i++; - } while (i < list.size()); - - g_key_file_free(keyfile); -} -QString UkuiMenuInterface::getAppNameInitials(QString desktopfp) -{ - QString firstLetters; - QString appname = getAppName(desktopfp); - QStringList appnamestr = appname.split(" "); - QString letters; - - Q_FOREACH (QString name, appnamestr) { - letters.clear(); - letters = UkuiChineseLetter::getFirstLettersAll(name); - - if (letters.isEmpty()) { - letters = UkuiChineseLetter::getFirstLetter(name); - } - - firstLetters.append(letters); - } - - return firstLetters; -} -QString UkuiMenuInterface::getAppNameInitial(QString desktopfp) -{ - return UkuiChineseLetter::getFirstLetter(getAppName(desktopfp)); -} -//获取应用拼音 -QString UkuiMenuInterface::getAppNamePinyin(QString appname) -{ - return UkuiChineseLetter::getPinyins(appname); -} -bool UkuiMenuInterface::checkKreApp(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *value = g_key_file_get_locale_string(keyfile, "Desktop Entry", "environment", nullptr, nullptr); - g_key_file_free(keyfile); - - if (!value) { - return false; - } else if (QString::compare(QString::fromLocal8Bit(value), "kre-environment") == 0) { - return true; - } - - return false; -} -//获取指定类型应用列表 -QStringList UkuiMenuInterface::getSpecifiedCategoryAppList(QString categorystr) -{ - QByteArray categorybyte = categorystr.toLocal8Bit(); - char *category = categorybyte.data(); - QStringList desktopfpList = getDesktopFilePath(); - QStringList appnameList; - appnameList.clear(); - - for (int index = 0; index < desktopfpList.count(); index++) { - QString appcategorystr = getAppCategories(desktopfpList.at(index)); - - if (!appcategorystr.isEmpty()) { - QByteArray appcategorybyte = appcategorystr.toLocal8Bit(); - char *appcategory = appcategorybyte.data(); - int len = static_cast(strlen(appcategory) - 6); - - for (int i = 0; i < len; i++) { - if (strncmp(appcategory + i, category, strlen(category)) == 0) { - QString appname = getAppName(desktopfpList.at(index)); - - if (QString::compare(appname, "访问提示") == 0) { - appnameList.append(appname); - } - - break; - } - } - } - } - - return appnameList; -} diff --git a/src/BackProcess/XEventMonitor/xeventmonitor.cpp b/src/BackProcess/XEventMonitor/xeventmonitor.cpp deleted file mode 100644 index f593faf..0000000 --- a/src/BackProcess/XEventMonitor/xeventmonitor.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- - * -*- coding: utf-8 -*- - * - * Copyright (C) 2011 ~ 2017 Deepin, Inc. - * 2011 ~ 2017 Wang Yong - * Copyright (C) 2018 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 of the License, or - * 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 . - */ - -#include "xeventmonitor.h" -#include -#include -#include -#include -#include -#include -#include -#include - -// Virtual button codes that are not defined by X11. -#define Button1 1 -#define Button2 2 -#define Button3 3 -#define WheelUp 4 -#define WheelDown 5 -#define WheelLeft 6 -#define WheelRight 7 -#define XButton1 8 -#define XButton2 9 - -XEventMonitor *XEventMonitor::instance_ = new XEventMonitor(); - -QVector ModifiersVec{ - XK_Control_L, - XK_Control_R, - XK_Shift_L, - XK_Shift_R, - XK_Super_L, - XK_Super_R, - XK_Alt_L, - XK_Alt_R -}; - -class XEventMonitorPrivate -{ -public: - XEventMonitorPrivate(XEventMonitor *parent); - virtual ~XEventMonitorPrivate(); - void run(); - -protected: - XEventMonitor *q_ptr; - QSet modifiers; - -// bool filterWheelEvent(int detail); - static void callback(XPointer trash, XRecordInterceptData *data); - void handleRecordEvent(XRecordInterceptData *); - void emitKeySignal(const char *member, xEvent *event); - void updateModifier(xEvent *event, bool isAdd); - -private: - Q_DECLARE_PUBLIC(XEventMonitor) -}; - -XEventMonitorPrivate::XEventMonitorPrivate(XEventMonitor *parent) - : q_ptr(parent) -{ -} - -XEventMonitorPrivate::~XEventMonitorPrivate() -{ -} - -void XEventMonitorPrivate::emitKeySignal(const char *member, xEvent *event) -{ - Display *display = XOpenDisplay(NULL); - int keyCode = event->u.u.detail; - KeySym keySym = XkbKeycodeToKeysym(display, event->u.u.detail, 0, 0); - QString keyStrSplice; - - for (auto modifier : modifiers) { - keyStrSplice += QString(XKeysymToString(modifier)) + "+"; - } - - //按键是修饰键 - if (ModifiersVec.contains(keySym) && !modifiers.isEmpty()) { - keyStrSplice.remove(keyStrSplice.length() - 1, 1); - } else { - keyStrSplice += XKeysymToString(keySym); - } - - QMetaObject::invokeMethod(q_ptr, member, - Qt::AutoConnection, - Q_ARG(int, keyCode)); - QMetaObject::invokeMethod(q_ptr, member, - Qt::AutoConnection, - Q_ARG(QString, keyStrSplice)); - XCloseDisplay(display); -} - -void XEventMonitorPrivate::run() -{ - Display *display = XOpenDisplay(0); - - if (display == 0) { - fprintf(stderr, "unable to open display\n"); - XCloseDisplay(display); - return; - } - - // Receive from ALL clients, including future clients. - XRecordClientSpec clients = XRecordAllClients; - XRecordRange *range = XRecordAllocRange(); - - if (range == 0) { - fprintf(stderr, "unable to allocate XRecordRange\n"); - XCloseDisplay(display); - return; - } - - // Receive KeyPress, KeyRelease, events. - memset(range, 0, sizeof(XRecordRange)); - range->device_events.first = KeyPress; - range->device_events.last = KeyRelease; - // And create the XRECORD context. - XRecordContext context = XRecordCreateContext(display, 0, &clients, 1, &range, 1); - - if (context == 0) { - fprintf(stderr, "XRecordCreateContext failed\n"); - XCloseDisplay(display); - return; - } - - XFree(range); - XSync(display, True); - Display *display_datalink = XOpenDisplay(0); - - if (display_datalink == 0) { - fprintf(stderr, "unable to open second display\n"); - XCloseDisplay(display_datalink); - XCloseDisplay(display); - return; - } - - if (!XRecordEnableContext(display_datalink, context, callback, (XPointer) this)) { - fprintf(stderr, "XRecordEnableContext() failed\n"); - XCloseDisplay(display_datalink); - XCloseDisplay(display); - return; - } - - XCloseDisplay(display_datalink); - XCloseDisplay(display); -} - -void XEventMonitorPrivate::callback(XPointer ptr, XRecordInterceptData *data) -{ - ((XEventMonitorPrivate *) ptr)->handleRecordEvent(data); -} - -void XEventMonitorPrivate::handleRecordEvent(XRecordInterceptData *data) -{ - if (data->category == XRecordFromServer) { - xEvent *event = (xEvent *)data->data; - - switch (event->u.u.type) { - case KeyPress: - updateModifier(event, true); - emitKeySignal("keyPress", event); - break; - - case KeyRelease: - updateModifier(event, false); - emitKeySignal("keyRelease", event); - break; - - default: - break; - } - } - - fflush(stdout); - XRecordFreeData(data); -} - -//bool XEventMonitorPrivate::filterWheelEvent(int detail) -//{ -// return detail != WheelUp && detail != WheelDown && detail != WheelLeft && detail != WheelRight; -//} - -void XEventMonitorPrivate::updateModifier(xEvent *event, bool isAdd) -{ - Display *display = XOpenDisplay(NULL); - KeySym keySym = XkbKeycodeToKeysym(display, event->u.u.detail, 0, 0); - - if (ModifiersVec.contains(keySym)) { - if (isAdd) { - modifiers.insert(keySym); - } else { - modifiers.remove(keySym); - } - } - - XCloseDisplay(display); -} - -XEventMonitor::XEventMonitor(QObject *parent) - : QThread(parent), - d_ptr(new XEventMonitorPrivate(this)) -{ - Q_D(XEventMonitor); -} - -XEventMonitor::~XEventMonitor() -{ - requestInterruption(); - quit(); - wait(); -} - -void XEventMonitor::run() -{ - if (!isInterruptionRequested()) { - d_ptr->run(); - } -} diff --git a/src/BackProcess/XEventMonitor/xeventmonitor.h b/src/BackProcess/XEventMonitor/xeventmonitor.h deleted file mode 100644 index 8f646ca..0000000 --- a/src/BackProcess/XEventMonitor/xeventmonitor.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- - * -*- coding: utf-8 -*- - * - * Copyright (C) 2018 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 of the License, or - * 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 . - */ - -#ifndef XEVENTMONITOR_H -#define XEVENTMONITOR_H - -#include -#include -#include -#include -#include -#include -#undef min - -class XEventMonitorPrivate; -class XEventMonitor : public QThread -{ - Q_OBJECT - -public: - static XEventMonitor *instance() - { - return instance_; - } - -private: - XEventMonitor(QObject *parent = 0); - ~XEventMonitor(); - -Q_SIGNALS: - - /// - /// \brief keyPress - /// \param 按键键码,不包含修饰键 - /// - void keyPress(int keyCode); - void keyRelease(int keyCode); - - /// - /// \brief keyPress - /// \param 按键名称,如果是组合键,则包含修饰键的名称,如Ctrl_L+r - /// - void keyPress(const QString &key); - void keyRelease(const QString &key); - - -protected: - void run(); - -private: - Q_DECLARE_PRIVATE(XEventMonitor) - XEventMonitorPrivate *d_ptr; - - static XEventMonitor *instance_; -}; - - -#endif diff --git a/src/BackProcess/backprocess.pri b/src/BackProcess/backprocess.pri deleted file mode 100644 index aa6805a..0000000 --- a/src/BackProcess/backprocess.pri +++ /dev/null @@ -1,44 +0,0 @@ -DISTFILES += \ - $$PWD/FileWatcher/filewatcher.pri - -INCLUDEPATH += \ - $$PWD/DBus \ - $$PWD/FileWatcher \ - $$PWD/Interface \ - $$PWD/Search \ - $$PWD/tablet \ - $$PWD/XEventMonitor - -HEADERS += \ - $$PWD/DBus/dbus-adaptor.h \ - $$PWD/DBus/dbus.h \ - $$PWD/FileWatcher/convert_winid_to_desktop.h \ - $$PWD/FileWatcher/desktop_watcher.h \ - $$PWD/FileWatcher/directory_changed_thread.h \ - $$PWD/FileWatcher/software_database_update_thread.h \ - $$PWD/FileWatcher/tablet_directorychanged_thread.h \ - $$PWD/Interface/currenttime_interface.h \ - $$PWD/Interface/ukui_chineseletter.h \ - $$PWD/Interface/ukuimenuinterface.h \ - $$PWD/Search/file-utils.h \ - $$PWD/Search/searchappthread.h \ - $$PWD/XEventMonitor/xeventmonitor.h \ - $$PWD/tablet/getmodeldata.h \ - $$PWD/tablet/pagemanager.h - -SOURCES += \ - $$PWD/DBus/dbus-adaptor.cpp \ - $$PWD/DBus/dbus.cpp \ - $$PWD/FileWatcher/convert_winid_to_desktop.cpp \ - $$PWD/FileWatcher/desktop_watcher.cpp \ - $$PWD/FileWatcher/directory_changed_thread.cpp \ - $$PWD/FileWatcher/software_database_update_thread.cpp \ - $$PWD/FileWatcher/tablet_directorychanged_thread.cpp \ - $$PWD/Interface/currenttime_interface.cpp \ - $$PWD/Interface/ukui_chineseletter.cpp \ - $$PWD/Interface/ukuimenuinterface.cpp \ - $$PWD/Search/file-utils.cpp \ - $$PWD/Search/searchappthread.cpp \ - $$PWD/XEventMonitor/xeventmonitor.cpp \ - $$PWD/tablet/getmodeldata.cpp \ - $$PWD/tablet/pagemanager.cpp diff --git a/src/BackProcess/tablet/getmodeldata.cpp b/src/BackProcess/tablet/getmodeldata.cpp deleted file mode 100644 index 7854aa0..0000000 --- a/src/BackProcess/tablet/getmodeldata.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include "getmodeldata.h" -#include -#include -#include "src/UtilityFunction/utility.h" - -GetModelData::GetModelData() -{ - m_ukuiMenuInterface = new UkuiMenuInterface; - loadDesktopVercor(); -} - -void GetModelData::loadDesktopVercor() -{ - UkuiMenuInterface::appInfoVector.clear(); - UkuiMenuInterface::alphabeticVector.clear(); - UkuiMenuInterface::functionalVector.clear(); - UkuiMenuInterface::allAppVector.clear(); - UkuiMenuInterface::collectAppVector.clear(); - UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); - UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); - UkuiMenuInterface::allAppVector = m_ukuiMenuInterface->getAllClassification(); - UkuiMenuInterface::collectAppVector = m_ukuiMenuInterface->getCollectApp(); -} - -QVector GetModelData::getMinAllData() -{ - m_minAllData.clear(); - - Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { - m_minAllData.append(QStringList() << desktopfp << "1"); - } - - return m_minAllData; -} - -QStringList GetModelData::getcollectData() -{ - m_collectData.clear(); - - Q_FOREACH (QString desktopfp, UkuiMenuInterface::collectAppVector) { - m_collectData.append(QString(desktopfp)); - } - - return m_collectData; -} - -bool GetModelData::cmpApp(QStringList &arg_1, QStringList &arg_2) -{ - if (arg_1.at(4) >= arg_2.at(4)) { - return true; - } else { - return false; - } -} - - -QVector GetModelData::getRecentData() -{ - QVector recentDataVector = QVector(); - enumerator = new Peony::FileEnumerator(this); - enumerator->setEnumerateDirectory("recent:///"); - enumerator->enumerateSync(); - QString uri; - - for (auto fileInfo : enumerator->getChildren()) { - QStringList recentData; - Peony::FileInfoJob infoJob(fileInfo); - infoJob.querySync(); - QString targetUri = fileInfo.get()->targetUri(); - QString displayName = fileInfo.get()->displayName(); - QString symlinkTarget = fileInfo.get()->symlinkTarget(); - QString iconName = fileInfo.get()->iconName(); - QString accessDate = fileInfo.get()->modifiedDate(); - recentData << targetUri << displayName << symlinkTarget << iconName << accessDate; - - if (!displayName.endsWith(".desktop")) { - recentDataVector.append(recentData); - } - } - - qSort(recentDataVector.begin(), recentDataVector.end(), cmpApp); - return recentDataVector; -} - -QStringList GetModelData::getFuncClassificationList() -{ - return m_classificationList; -} - -QStringList GetModelData::getLetterClassificationList() -{ - return m_letterList; -} - -QStringList GetModelData::getFuncClassificationBtnRowList() -{ - return m_classificationBtnRowList; -} - -QStringList GetModelData::getLetterClassificationBtnRowList() -{ - return m_letterBtnRowList; -} - -QVector GetModelData::getMinLetterData() -{ - m_minLetterData.clear(); - m_letterList.clear(); - m_letterBtnRowList.clear(); - int row = 0; - QVector vector = UkuiMenuInterface::alphabeticVector; - - for (int i = 0; i < vector.size(); i++) { - QStringList appList = vector.at(i); - - if (!appList.isEmpty()) { - QString letterstr; - - if (i < 26) { - letterstr = QString(QChar(static_cast(i + 65))); - } else if (i == 26) { - letterstr = "&"; - } else { - letterstr = "#"; - } - - m_letterList.append(letterstr);//存储分类字符 - m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 - m_minLetterData.append(QStringList() << letterstr << "0"); - - for (int i = 0; i < appList.count(); i++) { - m_minLetterData.append(QStringList() << appList.at(i) << "1"); - } - - row += (appList.count() + 1); - } - } - - return m_minLetterData; -} - -QVector GetModelData::getMinFuncData() -{ - m_funcRow = 0; - m_minFuncData.clear(); - m_classificationList.clear(); - m_classificationBtnRowList.clear(); - QVector vector = UkuiMenuInterface::functionalVector; - QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); - - for (int i = 0; i < vector.size(); i++) { - if (!(vector.at(i).isEmpty())) { - QString functionName = functionList.at(i); - insertClassificationBtn(functionName); - insertAppList(vector.at(i)); - } - } - - return m_minFuncData; -} - - - -void GetModelData::insertClassificationBtn(QString btnname) -{ - m_classificationList.append(btnname); - m_minFuncData.append(QStringList() << btnname << "0"); - m_classificationBtnRowList.append(QString::number(m_funcRow)); -} - -void GetModelData::insertAppList(QStringList appnamelist) -{ - m_funcRow += (appnamelist.count() + 1); - - for (int i = 0; i < appnamelist.count(); i++) { - m_minFuncData.append(QStringList() << appnamelist.at(i) << "1"); - } -} - diff --git a/src/BackProcess/tablet/getmodeldata.h b/src/BackProcess/tablet/getmodeldata.h deleted file mode 100644 index 2c00c9d..0000000 --- a/src/BackProcess/tablet/getmodeldata.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef GETMODELDATA_H -#define GETMODELDATA_H -#include "ukuimenuinterface.h" -#include -#include -#include - -class GetModelData : public QObject -{ - Q_OBJECT - -public: - GetModelData(); - -public: - /** - * @brief 获取默认窗口全部分类数据 - * @return - */ - QVector getMinAllData(); - /** - * @brief 获取默认窗口字母分类数据 - * @return - */ - QVector getMinLetterData(); - /** - * @brief 获取默认窗口功能分类数据 - * @return - */ - QVector getMinFuncData(); - /** - * @brief 获取收藏列表数据 - * @return - */ - QStringList getcollectData(); - /** - * @brief 获取功能分类类别列表 - * @return - */ - QStringList getFuncClassificationList(); - /** - * @brief 获取字母分类类别列表 - * @return - */ - QStringList getLetterClassificationList(); - /** - * @brief 获取对应类别所在行数 - * @return - */ - QStringList getFuncClassificationBtnRowList(); - QStringList getLetterClassificationBtnRowList(); - /** - * @brief 获取最近页面所展示应用列表 - * @return - */ - QVector getRecentData(); - - /** - * @brief 重新加载各个部分数据,用于初始化和整体更新 - */ - void loadDesktopVercor(); - -protected: - /** - * @brief 插入分类按键 - * @param btnname - */ - void insertClassificationBtn(QString btnname); - /** - * @brief 插入应用列表 - * @param appnamelist - */ - void insertAppList(QStringList appnamelist); - /** - * @brief 修改时间比较 - * @param arg_1 - * @param arg_2 - * @return - */ - static bool cmpApp(QStringList &arg_1, QStringList &arg_2); - -private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QVector m_minAllData; - QStringList m_collectData; - QVector m_minLetterData; - QStringList m_letterList; - QStringList m_letterBtnRowList; - QVector m_minFuncData; - QStringList m_classificationList; - QStringList m_classificationBtnRowList; - int m_funcRow; - Peony::FileEnumerator *enumerator = nullptr; - QList> m_childrens; -}; - -#endif // GETMODELDATA_H diff --git a/src/BackProcess/tablet/pagemanager.cpp b/src/BackProcess/tablet/pagemanager.cpp deleted file mode 100644 index 59134f5..0000000 --- a/src/BackProcess/tablet/pagemanager.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "pagemanager.h" -#include "ukuimenuinterface.h" -#include "style.h" -PageManager::PageManager() -{ - //获取数据 - m_ukuiMenuInterface = new UkuiMenuInterface(); - UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); - m_ukuiMenuInterface->initAppIni(); -} - -int PageManager::getPageNum(int appnum) -{ - int pageNum = 0; - Style::appColumn = 6; - Style::appLine = 4; - - if (appnum % (Style::appColumn * Style::appLine) == 0) { - pageNum = appnum / (Style::appColumn * Style::appLine); - } else { - pageNum = appnum / (Style::appColumn * Style::appLine) + 1; - } - - return pageNum; -} - -QVector PageManager::sortAppInPage(QVector appvector) -{ - QVector m_data; - QVector pageData; - QStringList onePageData; - - Q_FOREACH (QString desktopfp, appvector) { - m_data.append(desktopfp); - } - - int pageSize = getPageNum(m_data.size()); - - for (int i = 0; i < pageSize; i++) { - onePageData.clear(); - - for (int j = 0; j < Style::appColumn * Style::appLine; j++) { - if (m_data.size() > 0) { - onePageData.append(m_data.at(0)); - m_data.pop_front(); - } else { - // pageData.append(onePageData); - break; - } - } - - pageData.append(onePageData); - } - - return pageData; -} - -QVector PageManager::getAppPageVector() -{ - UkuiMenuInterface::tencentInitVector = m_ukuiMenuInterface->sortDesktopList("tencent"); - UkuiMenuInterface::customizedVector = m_ukuiMenuInterface->sortDesktopList("customized"); - UkuiMenuInterface::thirdPartyVector = m_ukuiMenuInterface->sortDesktopList("thirdParty"); - UkuiMenuInterface::applicationVector = m_ukuiMenuInterface->sortDesktopList("application"); - QVector appPagelist; - QVector allAppList = UkuiMenuInterface::tencentInitVector + UkuiMenuInterface::customizedVector + UkuiMenuInterface::thirdPartyVector + UkuiMenuInterface::applicationVector; - - Q_FOREACH (QStringList desktopfp, sortAppInPage(/*UkuiMenuInterface::tencentInitVector*/allAppList)) { - appPagelist.append(desktopfp); - } - -// Q_FOREACH(QStringList desktopfp,sortAppInPage(UkuiMenuInterface::customizedVector)) -// { -// appPagelist.append(desktopfp); -// } -// Q_FOREACH(QStringList desktopfp,sortAppInPage(UkuiMenuInterface::thirdPartyVector)) -// { -// appPagelist.append(desktopfp); -// } -// Q_FOREACH(QStringList desktopfp,sortAppInPage(UkuiMenuInterface::applicationVector)) -// { -// appPagelist.append(desktopfp); -// } - return appPagelist; -} diff --git a/src/BackProcess/tablet/pagemanager.h b/src/BackProcess/tablet/pagemanager.h deleted file mode 100644 index bc0b878..0000000 --- a/src/BackProcess/tablet/pagemanager.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef PAGEMANAGER_H -#define PAGEMANAGER_H - -#include -#include "ukuimenuinterface.h" - -class PageManager : public QObject -{ - Q_OBJECT -public: - PageManager(); - - int getPageNum(int appnum); - QVector sortAppInPage(QVector appvector); - QVector getAppPageVector(); -private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; -}; - -#endif // PAGEMANAGER_H diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp new file mode 100644 index 0000000..c19abb7 --- /dev/null +++ b/src/CommonUseWidget/commonusewidget.cpp @@ -0,0 +1,144 @@ +/* + * 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 +#include +#include +#include + +CommonUseWidget::CommonUseWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +CommonUseWidget::~CommonUseWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void CommonUseWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + fillAppList(); +} + +/** + * 初始化应用列表界面 + */ +void CommonUseWidget::initAppListWidget() +{ + m_listView = new ListView(this, this->width(), this->height() - 6, 0); + m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_listView->show(); + connect(m_listView, &ListView::sendItemClickedSignal, this, &CommonUseWidget::execApplication); + connect(m_listView, &ListView::sendUpdateAppListSignal, this, &CommonUseWidget::updateListViewSlot); + connect(m_listView, &ListView::sendHideMainWindowSignal, this, &CommonUseWidget::sendHideMainWindowSignal); + connect(m_listView, &ListView::sendMainWinActiveSignal, this, &CommonUseWidget::sendMainWinActiveSignal); +} + +/** + * 填充应用列表 + */ +void CommonUseWidget::fillAppList() +{ + m_data.clear(); + + Q_FOREACH (QString desktopfp, UkuiMenuInterface::m_allAppVector) { + m_data.append(QStringList() << desktopfp << "1"); + } + + m_listView->addData(m_data); +} + +void CommonUseWidget::selectFirstItem() +{ + this->focusNextChild(); + m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); +} + +void CommonUseWidget::selectFirstItemTab() +{ + this->setFocus(); + + if (m_listView->currentIndex().row() == -1) { + m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + } +} +/** + * 执行应用程序 + */ +void CommonUseWidget::execApplication(QStringList arg) +{ + Q_EMIT sendHideMainWindowSignal(); + QString desktopfp = arg.at(0); + execApp(desktopfp); +} + + +/** + * 更新应用列表槽函数 + */ +void CommonUseWidget::updateListViewSlot() +{ + updateListView(); +} + +void CommonUseWidget::updateListView() +{ + m_data.clear(); + + Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { + m_data.append(QStringList() << desktopfp << "1"); + } + + m_listView->updateData(m_data); +// m_listView->setFocus(); +} + +void CommonUseWidget::widgetMakeZero() +{ + m_listView->verticalScrollBar()->setSliderPosition(0); +} + +void CommonUseWidget::moveScrollBar(int type) +{ + if (type == 0) { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - 100); + } else { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + 100); + } +} + +void CommonUseWidget::repaintWidget() +{ + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_listView->show(); +} + diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h new file mode 100644 index 0000000..aeacf4b --- /dev/null +++ b/src/CommonUseWidget/commonusewidget.h @@ -0,0 +1,109 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include "src/RightClickMenu/rightclickmenu.h" +#include "src/UtilityFunction/listview.h" +#include "src/UtilityFunction/itemdelegate.h" +#include "src/UtilityFunction/utility.h" + +class CommonUseWidget : public QWidget +{ + Q_OBJECT + +public: + explicit CommonUseWidget(QWidget *parent = nullptr); + ~CommonUseWidget(); + /** + * @brief Initializes the interface state + */ + void widgetMakeZero(); + /** + * @brief Update application list + */ + void updateListView(); + /** + * @brief Move the scroll bar + * @param type: Scroll way,Only the following parameters can be entered: + * 0: moving up + * 1: moving down + */ + void moveScrollBar(int type); + /** + * @brief Repaint window + */ + void repaintWidget(); + +private: + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + ListView* m_listView=nullptr; + QVector m_data; + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + /** + * @brief Initialize the application list interface + */ + void initAppListWidget(); + /** + * @brief fill application list + */ + void fillAppList(); + +public Q_SLOTS: + /** + * @brief Open the application + * @param arg: The desktop file information that the application contains + */ + void execApplication(QStringList arg); + /** + * @brief Update the application list slot function + */ + void updateListViewSlot(); + + void selectFirstItem(); + + void selectFirstItemTab(); + +Q_SIGNALS: + /** + * @brief Send a hidden main window signal to the MainViewWidget + */ + void sendHideMainWindowSignal(); + void sendMainWinActiveSignal(bool flag); +}; + +#endif // COMMONUSEWIDGET_H diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp new file mode 100644 index 0000000..34bb7a1 --- /dev/null +++ b/src/CommonUseWidget/fullcommonusewidget.cpp @@ -0,0 +1,189 @@ +/* + * 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 +#include "src/Style/style.h" +#include "src/UtilityFunction/utility.h" +#include + +FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +FullCommonUseWidget::~FullCommonUseWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void FullCommonUseWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + myDebug() << "width" << this->width() << "height" << this->height(); + this->setFocusPolicy(Qt::NoFocus); + mainLayout = new QHBoxLayout; + mainLayout->setContentsMargins(0, 0, 0, 0); + this->setLayout(mainLayout); + m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + mainLayout->addItem(m_spaceItem); + m_scrollArea = new ScrollArea(this); + m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); + m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setWidgetResizable(true); + m_scrollAreaWidLayout = new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(10); + m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); + mainLayout->addWidget(m_scrollArea); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + fillAppList(); +} + +void FullCommonUseWidget::initAppListWidget() +{ + m_listView = new FullListView(this, 0); + m_scrollAreaWidLayout->addWidget(m_listView); + connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullCommonUseWidget::execApplication); + connect(m_listView, &FullListView::sendUpdateAppListSignal, this, &FullCommonUseWidget::updateListViewSlot); + connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullCommonUseWidget::sendHideMainWindowSignal); + connect(m_listView, &FullListView::sendSetslidebar, this, &FullCommonUseWidget::onSetSlider); +} + +void FullCommonUseWidget::resizeScrollAreaControls() +{ + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); + QWidget *wid = widItem->widget(); + FullListView *listview = qobject_cast(wid); + listview->adjustSize(); + int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; + int rowcount = 0; + + if (listview->model()->rowCount() % dividend > 0) { + rowcount = listview->model()->rowCount() / dividend + 1; + } else { + rowcount = listview->model()->rowCount() / dividend; + } + + listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); + m_scrollArea->widget()->adjustSize(); +} + +void FullCommonUseWidget::fillAppList() +{ + m_data.clear(); + + Q_FOREACH (QString desktopfp, UkuiMenuInterface::m_allAppVector) { + m_data.append(desktopfp); + } + + m_listView->addData(m_data); + resizeScrollAreaControls(); +} + +/** + * 执行应用程序 + */ +void FullCommonUseWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +void FullCommonUseWidget::selectFirstItem() +{ + m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); +} + +void FullCommonUseWidget::selectFirstItemTab() +{ + this->setFocus(); + + if (m_listView->currentIndex().row() == -1) { + m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + } +} + +void FullCommonUseWidget::onSetSlider(int value) +{ + if (value == 0) { + m_scrollArea->verticalScrollBar()->setValue(0); + } else { + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + } +} +/** + * 更新应用列表 + */ +void FullCommonUseWidget::updateListViewSlot() +{ + updateListView(); +} + +void FullCommonUseWidget::updateListView() +{ + m_data.clear(); + + Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { + m_data.append(desktopfp); + } + + m_listView->updateData(m_data); +} + +void FullCommonUseWidget::repaintWidget() +{ + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); + m_scrollAreaWidLayout->removeWidget(m_listView); + m_listView->setParent(nullptr); + delete m_listView; + initAppListWidget(); + fillAppList(); +} + +void FullCommonUseWidget::widgetMakeZero() +{ + m_listView->verticalScrollBar()->setSliderPosition(0); +} + +void FullCommonUseWidget::moveScrollBar(int type) +{ + int height = Style::primaryScreenHeight; + + if (type == 0) { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); + } else { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); + } +} diff --git a/src/UserInterface/Widget/full_commonuse_widget.h b/src/CommonUseWidget/fullcommonusewidget.h similarity index 77% rename from src/UserInterface/Widget/full_commonuse_widget.h rename to src/CommonUseWidget/fullcommonusewidget.h index 9f60538..966cb86 100644 --- a/src/UserInterface/Widget/full_commonuse_widget.h +++ b/src/CommonUseWidget/fullcommonusewidget.h @@ -32,12 +32,11 @@ #include #include #include -#include "ukuimenuinterface.h" -#include "rightclickmenu.h" -#include "fulllistview.h" -#include "style.h" -#include "scrollarea.h" -#include "getmodeldata.h" +#include "src/Interface/ukuimenuinterface.h" +#include "src/RightClickMenu/rightclickmenu.h" +#include "src/UtilityFunction/fulllistview.h" +#include "src/Style/style.h" +#include "src/UtilityFunction/scrollarea.h" class FullCommonUseWidget : public QWidget { @@ -66,23 +65,16 @@ public: */ void moveScrollBar(int type); - FullListView *m_listView = nullptr; - private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QStringList m_data; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; QSpacerItem *m_spaceItem = nullptr; ScrollArea *m_scrollArea = nullptr; ScrollAreaWid *m_scrollAreaWid = nullptr; + QHBoxLayout *mainLayout = nullptr; QVBoxLayout *m_scrollAreaWidLayout = nullptr; - bool flag; - QTimer *time = nullptr; - GetModelData *modaldata = nullptr; - QScrollBar *m_verticalScrollBar = nullptr; - int m_scrollAreaWidHeight = 0; - QString m_scrollBarStyle; - QPushButton *m_powerOffButton = nullptr; - + FullListView *m_listView = nullptr; protected: /** * @brief Initializes UI @@ -97,9 +89,6 @@ protected: */ void fillAppList(); void resizeScrollAreaControls(); - void initVerticalScrollBar(); - - bool eventFilter(QObject *watched, QEvent *event); public Q_SLOTS: /** @@ -112,28 +101,17 @@ public Q_SLOTS: */ void updateListViewSlot(); - void on_setScrollBarValue(int value); - void onSetSlider(int value); void selectFirstItem(); void selectFirstItemTab(); - void on_setAreaScrollBarValue(int value); - - void on_powerOffButton_clicked(); - - void on_powerOffButton_customContextMenuRequested(const QPoint &pos); - Q_SIGNALS: /** * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); - void changeScrollValue(int value, int maximumValue); - void setFocusToSideWin(); - void sendUpdateOtherView(); }; #endif // FULLCOMMONUSEWIDGET_H diff --git a/src/BackProcess/DBus/dbus-adaptor.cpp b/src/DBus/dbus-adaptor.cpp similarity index 74% rename from src/BackProcess/DBus/dbus-adaptor.cpp rename to src/DBus/dbus-adaptor.cpp index 9df5c62..4fdf0cf 100644 --- a/src/BackProcess/DBus/dbus-adaptor.cpp +++ b/src/DBus/dbus-adaptor.cpp @@ -37,25 +37,26 @@ QString MenuAdaptor::GetSecurityConfigPath() { // handle method call org.ukui.menu.GetSecurityConfigPath QString out0; - QMetaObject::invokeMethod(parent(), "GetSecurityConfigPath", Q_RETURN_ARG(QString, out0)); + QMetaObject::invokeMethod(parent(), "getSecurityConfigPath", Q_RETURN_ARG(QString, out0)); return out0; } void MenuAdaptor::ReloadSecurityConfig() { // handle method call org.ukui.menu.ReloadSecurityConfig - QMetaObject::invokeMethod(parent(), "ReloadSecurityConfig"); + QMetaObject::invokeMethod(parent(), "reloadSecurityConfig"); } void MenuAdaptor::WinKeyResponse() { // handle method call org.ukui.menu.WinKeyResponse - QMetaObject::invokeMethod(parent(), "WinKeyResponse"); + QMetaObject::invokeMethod(parent(), "winKeyResponse"); } -bool MenuAdaptor::GetMenuStatus() +QStringList MenuAdaptor::GetPkgNameWhiteList() { - bool status; - QMetaObject::invokeMethod(parent(), "GetMenuStatus", Q_RETURN_ARG(bool, status)); - return status; + QStringList pkgList; + QMetaObject::invokeMethod(parent(), "getPkgNameWhiteList", Q_RETURN_ARG(QStringList, pkgList)); + return pkgList; } + diff --git a/src/BackProcess/DBus/dbus-adaptor.h b/src/DBus/dbus-adaptor.h similarity index 87% rename from src/BackProcess/DBus/dbus-adaptor.h rename to src/DBus/dbus-adaptor.h index cc29f87..f1800fc 100644 --- a/src/BackProcess/DBus/dbus-adaptor.h +++ b/src/DBus/dbus-adaptor.h @@ -9,8 +9,8 @@ * before re-generating it. */ -#ifndef DBUS_ADAPTOR_H -#define DBUS_ADAPTOR_H +#ifndef DBUS-ADAPTOR_H +#define DBUS-ADAPTOR_H #include #include @@ -38,8 +38,8 @@ class MenuAdaptor: public QDBusAbstractAdaptor " \n" " \n" " \n" - " \n" - " \n" + " \n" + " \n" " \n" " \n" "") @@ -52,7 +52,7 @@ public Q_SLOTS: // METHODS QString GetSecurityConfigPath(); void ReloadSecurityConfig(); void WinKeyResponse(); - bool GetMenuStatus(); + QStringList GetPkgNameWhiteList(); Q_SIGNALS: // SIGNALS }; diff --git a/src/DBus/dbus.cpp b/src/DBus/dbus.cpp new file mode 100644 index 0000000..6dc9888 --- /dev/null +++ b/src/DBus/dbus.cpp @@ -0,0 +1,46 @@ +/* + * 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 +#include +#include "src/RightClickMenu/uninstallwhitelist.h" + +DBus::DBus(QObject *parent) : QObject(parent) +{ +} + +void DBus::reloadSecurityConfig() +{ + Q_EMIT sendReloadSignal(); +} + +QString DBus::getSecurityConfigPath() +{ + QString path = QDir::homePath() + "/.config/ukui-menu-security-config.json"; + return path; +} + +void DBus::winKeyResponse() +{ + Q_EMIT winKeyResponseSignal(); +} + +QStringList DBus::getPkgNameWhiteList() +{ + return UninstallWhitelist::getInstance()->getPkgNameWhiteList(); +} diff --git a/src/DBus/dbus.h b/src/DBus/dbus.h new file mode 100644 index 0000000..3db1556 --- /dev/null +++ b/src/DBus/dbus.h @@ -0,0 +1,41 @@ +/* + * 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 + +class DBus : public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") +public: + explicit DBus(QObject *parent = 0); + +Q_SIGNALS: + void sendReloadSignal(); + void winKeyResponseSignal(); + +public Q_SLOTS: + QString getSecurityConfigPath(); + void reloadSecurityConfig(); + void winKeyResponse(); + QStringList getPkgNameWhiteList(); +}; + +#endif // DBUS_H diff --git a/src/BackProcess/DBus/org.ukui.menu.xml b/src/DBus/org.ukui.menu.xml similarity index 100% rename from src/BackProcess/DBus/org.ukui.menu.xml rename to src/DBus/org.ukui.menu.xml diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp new file mode 100644 index 0000000..3b84dd4 --- /dev/null +++ b/src/FunctionWidget/fullfunctionwidget.cpp @@ -0,0 +1,492 @@ +/* + * 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 +#include +#include "src/Style/style.h" +#include +#include +#include + +FullFunctionWidget::FullFunctionWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +FullFunctionWidget::~FullFunctionWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void FullFunctionWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setAttribute(Qt::WA_TranslucentBackground); + m_applistWid = new QWidget(this); + m_iconListWid = new QWidget(this); + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); + m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height()); + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->setContentsMargins(0, 0, 0, 0); + mainLayout->setSpacing(0); + mainLayout->addWidget(m_iconListWid); + mainLayout->addWidget(m_applistWid); + this->setLayout(mainLayout); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + initIconListWidget(); + m_flag = true; + //翻页灵敏度时间调节 + m_time = new QTimer(this); + connect(m_time, &QTimer::timeout, [ = ]() { + if (m_flag == false) { + m_flag = true; + m_time->stop(); + } + }); +} + +/** + * 初始化应用列表界面 + */ +void FullFunctionWidget::initAppListWidget() +{ + layout = new QHBoxLayout(m_applistWid); + layout->setContentsMargins(0, 0, 0, 0); + m_applistWid->setLayout(layout); + m_scrollArea = new ScrollArea(this); + m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); + m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setWidgetResizable(true); + m_scrollAreaWidLayout = new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(10); + m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); + layout->addWidget(m_scrollArea); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullFunctionWidget::valueChangedSlot); + m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + fillSoftwareAppList(); +} + +/** + * 填充应用列表 + */ +void FullFunctionWidget::fillSoftwareAppList() +{ + m_classificationList.clear(); + QVector vector = UkuiMenuInterface::m_functionalVector; + QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + + for (int i = 0; i < vector.size(); i++) { + if (!(vector.at(i).isEmpty())) { + insertClassificationBtn(functionList.at(i)); + insertAppList(vector.at(i)); + } + } + + resizeScrollAreaControls(); +} + +void FullFunctionWidget::insertClassificationBtn(QString category) +{ + SplitBarFrame *classificationbtn = new SplitBarFrame(this, category, m_scrollArea->width() - 16, 30, 2); + m_scrollAreaWidLayout->addWidget(classificationbtn); + m_classificationList.append(category); +} + +void FullFunctionWidget::insertAppList(QStringList desktopfplist) +{ + FullListView *listview = new FullListView(this, 2); + connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider); + connect(this, &FullFunctionWidget::selectFirstItem, listview, &FullListView::selectFirstItem); + listview->installEventFilter(this); + m_scrollAreaWidLayout->addWidget(listview); + m_data.clear(); + + for (int i = 0; i < desktopfplist.count(); i++) { + m_data.append(desktopfplist.at(i)); + } + + listview->addData(m_data); + connect(listview, &FullListView::sendItemClickedSignal, this, &FullFunctionWidget::execApplication); + connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullFunctionWidget::sendHideMainWindowSignal); +} + +/** + * 执行应用程序 + */ +void FullFunctionWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +/** + * 更新应用列表 + */ +void FullFunctionWidget::updateAppListView() +{ + //刷新应用列表界面 + QLayoutItem *child; + m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer); + + while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { + QWidget *wid = child->widget(); + m_scrollAreaWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + + fillSoftwareAppList(); + + //刷新图标列表界面 + Q_FOREACH (QAbstractButton *button, m_buttonList) { + m_btnGroup->removeButton(button); + } + + m_buttonList.clear(); + m_iconListScrollAreaWidLayout->removeItem(m_topSpacerItem); + m_iconListScrollAreaWidLayout->removeItem(m_bottomSpacerItem); + + while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { + QWidget *wid = child->widget(); + m_iconListScrollAreaWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + + initIconListScrollArea(); +} + +/** + * 设置scrollarea所填充控件大小 + */ +void FullFunctionWidget::resizeScrollAreaControls() +{ + int row = 0; + + while (row < m_scrollAreaWidLayout->count() / 2) { + //应用界面 + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1); + QWidget *wid = widItem->widget(); + FullListView *listview = qobject_cast(wid); + listview->adjustSize(); + int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; + int rowcount = 0; + + if (listview->model()->rowCount() % dividend > 0) { + rowcount = listview->model()->rowCount() / dividend + 1; + } else { + rowcount = listview->model()->rowCount() / dividend; + } + + listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height() * rowcount); + row++; + } + + m_scrollArea->widget()->adjustSize(); +} + +/** + * 初始化图标列表界面 + */ +void FullFunctionWidget::initIconListWidget() +{ + m_iconListScrollArea = new ClassifyBtnScrollArea(m_iconListWid); + m_iconListScrollAreaWid = new ClassifyBtnScrollAreaWid(m_iconListScrollArea); + m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, + m_iconListWid->height()); + m_iconListScrollAreaWidLayout = new QVBoxLayout; + m_iconListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_iconListScrollAreaWidLayout->setSpacing(Style::LeftSpaceBetweenItem); + m_iconListScrollAreaWid->setLayout(m_iconListScrollAreaWidLayout); + m_iconListScrollArea->setWidget(m_iconListScrollAreaWid); + m_topSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_bottomSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_btnGroup = new QButtonGroup(m_iconListScrollAreaWid); + m_animation = new QPropertyAnimation(m_iconListScrollArea, "geometry"); + m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); + m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); + connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullFunctionWidget::animationFinishSlot); + connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullFunctionWidget::animationValueChangedSlot); + initIconListScrollArea(); +} + +/** + * 初始化图标列表界面数据表格iconlisttableWid + */ +void FullFunctionWidget::initIconListScrollArea() +{ + m_iconListScrollAreaWidLayout->addItem(m_topSpacerItem); + + for (int i = 0; i < m_classificationList.size(); i++) { + FunctionClassifyButton *iconbtn = new FunctionClassifyButton( + Style::LeftBtnWidth, + Style::LeftBtnHeight, + Style::LeftIconSize, + m_classificationList.at(i), + true, + true, this); + iconbtn->setChecked(false); + m_buttonList.append(iconbtn); + m_iconListScrollAreaWidLayout->addWidget(iconbtn); + } + + m_iconListScrollAreaWidLayout->addItem(m_bottomSpacerItem); + int id = 0; + + Q_FOREACH (QAbstractButton *btn, m_buttonList) { + m_btnGroup->addButton(btn, id++); + } + + connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullFunctionWidget::btnGroupClickedSlot); + +// m_iconListScrollArea->widget()->adjustSize(); + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } +} + +void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn) +{ + disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullFunctionWidget::valueChangedSlot); + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) { + m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition(); + m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y(); + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollAnimation->stop(); + m_scrollAnimation->setStartValue(m_beginPos); + m_scrollAnimation->setEndValue(m_endPos); + m_scrollAnimation->start(); + button->setChecked(true); + } else { + button->setChecked(false); + } + } +} + +void FullFunctionWidget::animationFinishSlot() +{ + if (m_scrollArea->verticalScrollBar()->value() == m_endPos || + m_scrollArea->verticalScrollBar()->value() == m_scrollArea->verticalScrollBar()->maximum()) { + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullFunctionWidget::valueChangedSlot); + } +} + +void FullFunctionWidget::animationValueChangedSlot(const QVariant &value) +{ + Q_UNUSED(value); + + if (sender() != m_scrollAnimation) { + return; + } + + QPropertyAnimation *ani = qobject_cast(sender()); + + if (m_endPos != ani->endValue()) { + ani->setEndValue(m_endPos); + } +} + +void FullFunctionWidget::valueChangedSlot(int value) +{ + int index = 0; + + while (index <= m_classificationList.count() - 1) { + int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y(); + int max = 0; + + if (index == m_classificationList.count() - 1) { + max = m_scrollAreaWid->height(); + } else { + max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y(); + } + + if (value >= min && value < max) { + Q_FOREACH (QAbstractButton *button, m_buttonList) { + FunctionClassifyButton *fcbutton = qobject_cast(button); + + if (index == m_buttonList.indexOf(button)) { + fcbutton->setChecked(true); + } else { + fcbutton->setChecked(false); + } + } + + break; + } else { + index++; + } + } +} + +QAbstractButton *FullFunctionWidget::getCurLetterButton(int value) +{ + return m_buttonList.at(value); +} + + +void FullFunctionWidget::enterAnimation() +{ + m_animation->setDuration(200);//动画总时间 + m_animation->setStartValue(QRect(0, 0, + 0, m_iconListWid->height())); + m_animation->setEndValue(QRect(Style::LeftMargin, + 0, + Style::LeftBtnWidth, + m_iconListWid->height())); + m_animation->setEasingCurve(QEasingCurve::InQuart); + m_animation->start(); + m_iconListScrollArea->show(); +} + +void FullFunctionWidget::setFunctionBtnGeometry() +{ +// int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; + m_iconListScrollArea->setGeometry(QRect(Style::LeftMargin, + 0, + Style::LeftBtnWidth, + m_iconListWid->height())); + m_iconListScrollArea->show(); +} + +void FullFunctionWidget::repaintWidget() +{ + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); + m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height()); + m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, + m_iconListWid->height()); + updateAppListView(); +} + +void FullFunctionWidget::widgetMakeZero() +{ + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } + + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); +} + +void FullFunctionWidget::moveScrollBar(int type) +{ + int height = Style::primaryScreenHeight; + + if (type == 0) { + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() - height * 100 / 1080); + } else { + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() + height * 100 / 1080); + } +} + +void FullFunctionWidget::onSetSlider(int value) +{ + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); +} + +bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); + QWidget *wid = widItem->widget(); + FullListView *m_listview = qobject_cast(wid); + QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget *widTop = widItemTop->widget(); + FullListView *m_listviewTop = qobject_cast(widTop); + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + Q_EMIT setFocusToSideWin(); + } + + if (ke->key() == Qt::Key_Up) { + if (!m_listviewTop->hasFocus()) { + QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); + btnGroupClickedSlot(buttonTop); + this->m_scrollArea->setFocusToPreChild(); + } else { + m_listview->setFocus(); + QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); + btnGroupClickedSlot(button); + m_index = m_buttonList.size() - 1; + } + + Q_EMIT selectFirstItem(); + return true; + } + + if (ke->key() == Qt::Key_Down) { + if (!m_listview->hasFocus()) { + QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); + btnGroupClickedSlot(button); + this->m_scrollArea->setFocusToNextChild(); + } else { + m_listviewTop->setFocus(); + QAbstractButton *buttonTop = getCurLetterButton(0); + btnGroupClickedSlot(buttonTop); + m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0, 0)); + m_index = 0; + } + + Q_EMIT selectFirstItem(); + return true; + } + } + + return QWidget::eventFilter(watched, event); +} + +void FullFunctionWidget::functionButtonClick() +{ + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } + + m_index = 0; +} + +void FullFunctionWidget::setFocusToThis() +{ + functionButtonClick(); + this->setFocus(); + Q_EMIT selectFirstItem(); +} diff --git a/src/UserInterface/Widget/full_function_widget.h b/src/FunctionWidget/fullfunctionwidget.h similarity index 86% rename from src/UserInterface/Widget/full_function_widget.h rename to src/FunctionWidget/fullfunctionwidget.h index ead61ff..9b44f87 100644 --- a/src/UserInterface/Widget/full_function_widget.h +++ b/src/FunctionWidget/fullfunctionwidget.h @@ -33,14 +33,14 @@ #include #include #include -#include "ukuimenuinterface.h" -#include "scrollarea.h" -#include "splitbar_frame.h" -#include "fulllistview.h" -#include "classify_btn_scrollarea.h" -#include "tool_button.h" -#include "function_classify_button.h" -#include "style.h" +#include "src/Interface/ukuimenuinterface.h" +#include "src/UtilityFunction/scrollarea.h" +#include "src/UtilityFunction/splitbarframe.h" +#include "src/UtilityFunction/fulllistview.h" +#include "src/UtilityFunction/classifybtnscrollarea.h" +#include "src/UtilityFunction/toolbutton.h" +#include "src/UtilityFunction/functionclassifybutton.h" +#include "src/Style/style.h" #include class FullFunctionWidget : public QWidget @@ -68,6 +68,10 @@ public: * 0: moving up * 1: moving down */ + void moveScrollBar(int type); + /** + * @brief Adjust function classification button position + */ void setFunctionBtnGeometry(); void functionButtonClick(); @@ -83,18 +87,19 @@ private: QVBoxLayout *m_scrollAreaWidLayout = nullptr; QStringList m_classificationList;//Store the list of category buttons QStringList m_data; - QString m_scrollBarStyle; - QTimer *time = nullptr; - bool flag; + QTimer *m_time = nullptr; + bool m_flag; /*Function classification list interface*/ QWidget *m_iconListWid = nullptr; ClassifyBtnScrollArea *m_iconListScrollArea = nullptr; ClassifyBtnScrollAreaWid *m_iconListScrollAreaWid = nullptr; - QVBoxLayout *m_iconListWidLayout = nullptr; + QVBoxLayout *m_iconListScrollAreaWidLayout = nullptr; + QHBoxLayout *layout = nullptr; QList m_buttonList; QButtonGroup *m_btnGroup = nullptr; QSpacerItem *m_topSpacerItem = nullptr; QSpacerItem *m_bottomSpacerItem = nullptr; + QSpacerItem *m_appListBottomSpacer = nullptr; /*Animation*/ QPropertyAnimation *m_animation = nullptr; //Function category button animation @@ -102,9 +107,6 @@ private: int m_beginPos = 0; //Application list scrollbar starting value int m_endPos = 0; //Application list scrollbar end value int m_index = 0; - QScrollBar *m_verticalScrollBar = nullptr; - int m_scrollAreaWidHeight = 0; - QPushButton *m_powerOffButton = nullptr; protected: /** @@ -123,7 +125,7 @@ protected: /** * @brief fill application list */ - void fillAppList(); + void fillSoftwareAppList(); /** * @brief Insert category button * @param category: Functional classification name @@ -138,7 +140,7 @@ protected: * @brief Set the control size in qscrollarea */ void resizeScrollAreaControls(); - void initVerticalScrollBar(); + bool eventFilter(QObject *watched, QEvent *event); public Q_SLOTS: @@ -175,14 +177,6 @@ public Q_SLOTS: void setFocusToThis(); - void on_setScrollBarValue(int value); - - void on_setAreaScrollBarValue(int value); - - void on_powerOffButton_clicked(); - - void on_powerOffButton_customContextMenuRequested(const QPoint &pos); - Q_SIGNALS: /** * @brief Send a hidden main window signal to the MainViewWidget @@ -192,9 +186,6 @@ Q_SIGNALS: void setFocusToSideWin(); void selectFirstItem(); - - void changeScrollValue(int value, int maximumValue); - }; #endif // FULLFUNCTIONWIDGET_H diff --git a/src/UserInterface/Widget/function_button_widget.cpp b/src/FunctionWidget/functionbuttonwidget.cpp similarity index 85% rename from src/UserInterface/Widget/function_button_widget.cpp rename to src/FunctionWidget/functionbuttonwidget.cpp index cd7b8f8..6b36844 100644 --- a/src/UserInterface/Widget/function_button_widget.cpp +++ b/src/FunctionWidget/functionbuttonwidget.cpp @@ -16,8 +16,8 @@ * */ -#include "function_button_widget.h" -#include "style.h" +#include "functionbuttonwidget.h" +#include "src/Style/style.h" #include #include #include @@ -48,19 +48,20 @@ void FunctionButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground, true); + this->resize(Style::LeftBtnWidth * 2 + 5, Style::LeftBtnHeight * 6 + 25); QGridLayout *gridLayout = new QGridLayout; - gridLayout->setContentsMargins(40, 80, 40, 80); + gridLayout->setContentsMargins(0, 0, 0, 0); gridLayout->setSpacing(5); this->setLayout(gridLayout); - for (int row = 0; row < 6; row++) + for (int row = 0; row < 6; row++) { for (int col = 0; col < 2; col++) { FunctionClassifyButton *iconbtn = new FunctionClassifyButton(Style::LeftBtnWidth, Style::LeftBtnHeight, Style::LeftIconSize, m_categoryList.at(row * 2 + col), false, - false); + false, this); gridLayout->addWidget(iconbtn, row, col); m_buttonList.append(iconbtn); connect(iconbtn, &FunctionClassifyButton::buttonClicked, this, &FunctionButtonWidget::functionBtnClickedSlot); @@ -69,10 +70,11 @@ void FunctionButtonWidget::initUi() break; } } + } if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); - connect(gsetting, &QGSettings::changed, this, [ = ] { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + connect(&gsetting, &QGSettings::changed, this, [ = ] { Q_FOREACH (QAbstractButton *btn, m_buttonList) { FunctionClassifyButton *fbtn = qobject_cast(btn); @@ -93,12 +95,6 @@ void FunctionButtonWidget::functionBtnClickedSlot() Q_EMIT sendFunctionBtnSignal(label->text()); } -void FunctionButtonWidget::hideEvent(QHideEvent *event) -{ - Q_EMIT sendResetFunctionPage(); - return QWidget::hideEvent(event); -} - /** * 接收FunctionWidget界面分类按钮列表 */ @@ -106,12 +102,12 @@ void FunctionButtonWidget::recvClassificationBtnList() { QGridLayout *gridLayout = qobject_cast(this->layout()); - for (int row = 0; row < 6; row++) - for (int col = 0; col < 2; col++) { + for (int row = 0; row < 6; row++) { + for (int col = 0 ; col < 2; col++) { QLayoutItem *item = gridLayout->itemAtPosition(row, col); FunctionClassifyButton *btn = qobject_cast(item->widget()); - if (UkuiMenuInterface::functionalVector.at(row * 2 + col).isEmpty()) { + if (UkuiMenuInterface::m_functionalVector.at(row * 2 + col).isEmpty()) { btn->m_enabled = false; } else { btn->m_enabled = true; @@ -124,4 +120,5 @@ void FunctionButtonWidget::recvClassificationBtnList() break; } } + } } diff --git a/src/UserInterface/Widget/function_button_widget.h b/src/FunctionWidget/functionbuttonwidget.h similarity index 89% rename from src/UserInterface/Widget/function_button_widget.h rename to src/FunctionWidget/functionbuttonwidget.h index 3faed62..581fa62 100644 --- a/src/UserInterface/Widget/function_button_widget.h +++ b/src/FunctionWidget/functionbuttonwidget.h @@ -26,8 +26,9 @@ #include #include #include -#include "function_classify_button.h" -#include "ukuimenuinterface.h" +#include "src/UtilityFunction/functionclassifybutton.h" +#include "src/Interface/ukuimenuinterface.h" +#include class FunctionButtonWidget : public QWidget { @@ -39,7 +40,7 @@ public: private: QStringList m_categoryList; - QList m_buttonList; + QList m_buttonList; protected: /** @@ -47,15 +48,12 @@ protected: */ void initUi(); - void hideEvent(QHideEvent *event); - Q_SIGNALS: /** * @brief Send button click signal to functionwidget interface * @param btnname: Category button name */ void sendFunctionBtnSignal(QString btnname); - void sendResetFunctionPage(); public Q_SLOTS: /** diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp new file mode 100644 index 0000000..d30fee1 --- /dev/null +++ b/src/FunctionWidget/functionwidget.cpp @@ -0,0 +1,239 @@ +/* + * 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 + +FunctionWidget::FunctionWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +FunctionWidget::~FunctionWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +/** + * 主界面初始化 + */ +void FunctionWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + m_functionBtnWid = new FunctionButtonWidget(this); + m_functionBtnWid->hide(); + connect(this, &FunctionWidget::sendClassificationbtnList, m_functionBtnWid, &FunctionButtonWidget::recvClassificationBtnList); + connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal, this, &FunctionWidget::recvFunctionBtnSignal); + m_enterAnimation = new QPropertyAnimation(this); + m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); + m_leaveAnimation = new QPropertyAnimation(this); + m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); + connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot); + connect(m_enterAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot); +} + +/** + * 初始化应用列表界面 + */ +void FunctionWidget::initAppListWidget() +{ + m_appListView = new ListView(this, this->width() - 6, this->height() - 6, 2); + m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->show(); + fillSoftwareAppListView(m_addDate); + connect(m_appListView, &ListView::sendItemClickedSignal, this, &FunctionWidget::recvItemClickedSlot); + connect(m_appListView, &ListView::sendHideMainWindowSignal, this, &FunctionWidget::sendHideMainWindowSignal); + connect(m_appListView, &ListView::sendMainWinActiveSignal, this, &FunctionWidget::sendMainWinActiveSignal); +} + +/** + * 填充应用列表 + */ +void FunctionWidget::fillSoftwareAppListView(int type) +{ + m_row = 0; + m_data.clear(); + m_classificationList.clear(); + m_classificationBtnRowList.clear(); + QVector vector = UkuiMenuInterface::m_functionalVector; + QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + + for (int i = 0; i < vector.size(); i++) { + if (!(vector.at(i).isEmpty())) { + QString functionName = functionList.at(i); + insertClassificationBtn(functionName); + insertAppList(vector.at(i)); + } + } + + if (type == 0) { + m_appListView->addData(m_data); + } else { + m_appListView->updateData(m_data); + } +} + +void FunctionWidget::insertClassificationBtn(QString btnname) +{ + m_classificationList.append(btnname); + m_data.append(QStringList() << btnname << "0"); + m_classificationBtnRowList.append(QString::number(m_row)); +} + +void FunctionWidget::insertAppList(QStringList appnamelist) +{ + m_row += (appnamelist.count() + 1); + + for (int i = 0; i < appnamelist.count(); i++) { + m_data.append(QStringList() << appnamelist.at(i) << "1"); + } +} + +void FunctionWidget::recvItemClickedSlot(QStringList arg) +{ + if (arg.at(1).toInt() == 0) { + appClassificationBtnClickedSlot(); + } else { + execApplication(arg.at(0)); + } +} + +/** + * 执行应用程序 + */ +void FunctionWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +/** + * 更新应用列表 + */ +void FunctionWidget::updateAppListView() +{ + fillSoftwareAppListView(m_updateDate); +} + +/** + * 应用列表功能分类按钮槽函数 + */ +void FunctionWidget::appClassificationBtnClickedSlot() +{ + m_leaveAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); +// m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); + m_leaveAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_enterAnimation->setStartValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); + m_enterAnimation->setEndValue(QRect((this->width() - Style::LeftBtnWidth * 2 - 5) / 2, + (this->height() - Style::LeftBtnHeight * 6 - 25) / 2, + Style::LeftBtnWidth * 2 + 5, + Style::LeftBtnHeight * 6 + 25)); + m_leaveAnimation->setDuration(10); + m_enterAnimation->setDuration(100); + //加载FunctionButtonWidget界面 + Q_EMIT sendClassificationbtnList(); + m_leaveAnimation->setTargetObject(m_appListView); + m_enterAnimation->setTargetObject(m_functionBtnWid); + m_leaveAnimation->start(); + m_widgetState = 1; +} + +/** + * 接收FunctionButtonWidget界面按钮信号 + */ +void FunctionWidget::recvFunctionBtnSignal(QString btnname) +{ + //此处需实现将功能为btnname的应用列表移动到applistWid界面最顶端 + int index = m_classificationList.indexOf(btnname); + + if (index != -1) { + int row = m_classificationBtnRowList.at(index).toInt(); + m_appListView->verticalScrollBar()->setValue(row); + } + + m_leaveAnimation->setStartValue(QRect((this->width() - Style::LeftBtnWidth * 2 - 5) / 2, + (this->height() - Style::LeftBtnHeight * 6 - 25) / 2, + Style::LeftBtnWidth * 2 + 5, + Style::LeftBtnHeight * 6 + 25)); + m_leaveAnimation->setEndValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); +// m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40)); + m_enterAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_enterAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_leaveAnimation->setDuration(100); + m_enterAnimation->setDuration(10); + m_leaveAnimation->setTargetObject(m_functionBtnWid); + m_enterAnimation->setTargetObject(m_appListView); + m_leaveAnimation->start(); + m_widgetState = 0; +} + +void FunctionWidget::animationFinishedSLot() +{ + if (m_widgetState == 1) { + m_appListView->hide(); + m_enterAnimation->start(); + m_widgetState = -1; + m_functionBtnWid->show(); + } + + if (m_widgetState == 0) { + m_functionBtnWid->hide(); + m_enterAnimation->start(); + m_widgetState = -1; + m_appListView->show(); + } +} + +void FunctionWidget::widgetMakeZero() +{ + m_functionBtnWid->hide(); + m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->show(); + m_appListView->verticalScrollBar()->setValue(0); +} + +void FunctionWidget::moveScrollBar(int type) +{ + if (type == 0) { + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() - 100); + } else { + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() + 100); + } +} + +void FunctionWidget::repaintWidget() +{ + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->show(); +} + +void FunctionWidget::setFocusToThis() +{ + this->setFocus(); +} diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h new file mode 100644 index 0000000..5eec927 --- /dev/null +++ b/src/FunctionWidget/functionwidget.h @@ -0,0 +1,141 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include "functionbuttonwidget.h" +#include "src/RightClickMenu/rightclickmenu.h" +#include "src/UtilityFunction/listview.h" +#include "src/UtilityFunction/itemdelegate.h" + +class FunctionWidget : public QWidget +{ + Q_OBJECT + +public: + explicit FunctionWidget(QWidget *parent=nullptr); + ~FunctionWidget(); + /** + * @brief Initializes the interface state + */ + void widgetMakeZero(); + /** + * @brief Move the scroll bar + * @param type: Scroll way,Only the following parameters can be entered: + * 0: moving up + * 1: moving down + */ + void moveScrollBar(int type); + /** + * @brief Repaint window + */ + void repaintWidget(); + +private: + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + FunctionButtonWidget* m_functionBtnWid=nullptr;//Classification list interface + ListView* m_appListView=nullptr; + QVector m_data; + QStringList m_classificationList;//Store the list of category buttons + QStringList m_classificationBtnRowList;//Store the row in which the category button is located + int m_row=0; + int m_addDate = 0; + int m_updateDate = 1; + /*Interface switching animation*/ + QPropertyAnimation* m_enterAnimation=nullptr; + QPropertyAnimation* m_leaveAnimation=nullptr; + int m_widgetState=-1; + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + /** + * @brief Initialize the application list interface + */ + void initAppListWidget(); + /** + * @brief fill application list + */ + void fillSoftwareAppListView(int type); + /** + * @brief Insert the software center category button + * @param category: Functional classification name + */ + void insertClassificationBtn(QString btnname); + /** + * @brief Insert application list + * @param desktopfplist: Desktop file path list + */ + void insertAppList(QStringList appnamelist); + +public Q_SLOTS: + /** + * @brief Switch to the function classification button interface + */ + void appClassificationBtnClickedSlot(); + /** + * @brief Receive function classification button interface signal + * @param Category button name + */ + void recvFunctionBtnSignal(QString btnname); + /** + * @brief Open the application + * @param arg: Desktop file path + */ + void execApplication(QString desktopfp); + /** + * @brief Update application list slot function + */ + void updateAppListView(); + /** + * @brief Respond to the list item click + * @param arg: The desktop file information that the application contains + */ + void recvItemClickedSlot(QStringList arg); + /** + * @brief Respond to animation finish + */ + void animationFinishedSLot(); + + void setFocusToThis(); + +Q_SIGNALS: + /** + * @brief Send the classification button click signal to functionbuttonwidget + */ + void sendClassificationbtnList(); + /** + * @brief Send a hidden main window signal to the MainViewWidget + */ + void sendHideMainWindowSignal(); + + void sendMainWinActiveSignal(bool flag); +}; + +#endif // FUNCTIONWIDGET_H diff --git a/src/Interface/ukuichineseletter.cpp b/src/Interface/ukuichineseletter.cpp new file mode 100644 index 0000000..f7a1afa --- /dev/null +++ b/src/Interface/ukuichineseletter.cpp @@ -0,0 +1,5827 @@ +/* + * 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 +#include + +UkuiChineseLetter::UkuiChineseLetter() +{ + +} + +bool UkuiChineseLetter::In(wchar_t start, wchar_t end, wchar_t code) +{ + if (code >= start && code <= end) + { + return true; + } + return false; +} + +char UkuiChineseLetter::Convert(int n)//此方法有缺陷,只能识别一级字库中的汉字 +{ + /* + * GB2312码范围 (B0A1-F7FE) + * HiByte (B0-F7) LoByte (A1-FE) + * + * GBK编码范围 (8140-FEFE) + * 包含三大部分 + * 1.汉字区 + * a. GB2312汉字区。即GBK/2 + * b. GB13000.1扩充汉字区。包括GBK/3(CJK汉字)和GBK/4(CJK汉字和增补汉字) + * 2.图形符号区 + * a. GB2312非汉字区。即GBK/1 A1A1-A9FE。还有10个小写罗马数字和GB12345增补符号 + * b. GB13000.1扩充非汉字区。即GBK/5 A840-A9A0非汉字符号、结构符... + * 3.用户自定义区 + * + */ + + if (In(0xB0A1,0xB0C4,n)) return 'A'; + if (In(0XB0C5,0XB2C0,n)) return 'B'; + if (In(0xB2C1,0xB4ED,n)) return 'C'; + if (In(0xB4EE,0xB6E9,n)) return 'D'; + if (In(0xB6EA,0xB7A1,n)) return 'E'; + if (In(0xB7A2,0xB8c0,n)) return 'F'; + if (In(0xB8C1,0xB9FD,n)) return 'G'; + if (In(0xB9FE,0xBBF6,n)) return 'H'; + if (In(0xBBF7,0xBFA5,n)) return 'J'; + if (In(0xBFA6,0xC0AB,n)) return 'K'; + if (In(0xC0AC,0xC2E7,n)) return 'L'; + if (In(0xC2E8,0xC4C2,n)) return 'M'; + if (In(0xC4C3,0xC5B5,n)) return 'N'; + if (In(0xC5B6,0xC5BD,n)) return 'O'; + if (In(0xC5BE,0xC6D9,n)) return 'P'; + if (In(0xC6DA,0xC8BA,n)) return 'Q'; + if (In(0xC8BB,0xC8F5,n)) return 'R'; + if (In(0xC8F6,0xCBF0,n)) return 'S'; + if (In(0xCBFA,0xCDD9,n)) return 'T'; + if (In(0xCDDA,0xCEF3,n)) return 'W'; + if (In(0xCEF4,0xD1B8,n)) return 'X'; + if (In(0xD1B9,0xD4D0,n)) return 'Y'; + if (In(0xD4D1,0xD7F9,n)) return 'Z'; + if (In(0x00, 0x7f, n)) return n; + return '\0'; +} + +QString UkuiChineseLetter::getFirstLetter(const QString &src) +{ +// wchar_t wchr = 0; +// QString firstLetter; +// if(src.size() > 0) +// { +// QString str = src.at(0); +// QTextCodec* pCodec = QTextCodec::codecForName("gb2312"); +// if(!pCodec) return QChar(' '); +// QByteArray arr = pCodec->fromUnicode(str); + +// if(arr.size() == 1) +// { +// wchr = arr.at(0) & 0xff; +// } +// else if(arr.size() == 2) +// { +// wchr = (arr.at(0) & 0xff) << 8; +// wchr |= (arr.at(1) & 0xff); +// } +// else +// { +//// qDebug() << "unknown word"; +// } + +// char c = Convert(wchr); +// if(c != 0) +// { +// firstLetter.append(c); +// } +// } + + QString appnamePy=getPinyins(src); + if(!appnamePy.isEmpty()) + return QString(appnamePy.at(0)); + else + return QString(); +} + +QString UkuiChineseLetter::getFirstLetters(const QString &src) +{ + QString firstLetters; + for (int i=0; ifromUnicode(str); + wchar_t wchr = 0; + + if(arr.size() == 1) + { + wchr = arr.at(0) & 0xff; + } + else if(arr.size() == 2) + { + wchr = (arr.at(0) & 0xff) << 8; + wchr |= (arr.at(1) & 0xff); + } + else + { + //qDebug() << "unknown word"; + } + + char c = Convert(wchr); + if(c != 0) + { + firstLetters.append(c); + } + } + return firstLetters; +} + +QString UkuiChineseLetter::getFirstLettersAll(const QString &src) +{ + QString pinyins; + for (int i=0; ifromUnicode(str); + unsigned char high = 0; + unsigned char low = 0; + int code = 0; + + if(arr.size() == 1) + { + high = 0; + low = arr.at(0) & 0xff; + } + else if(arr.size() == 2) + { + high = arr.at(0) & 0xff; + low = arr.at(1) & 0xff; + } + + if ( high < 0xa1 || low < 0xa1) + { + continue; + } + else + { + code = (high - 0xa0) * 100 + low - 0xa0; + } + + pinyins += getPinyin(code).at(0); + } + return pinyins; +} + + +QString UkuiChineseLetter::getPinyins(const QString &text) +{ + QString pinyins; + for (int i=0; i= 0 && c <= 127)) + { + pinyins+=c.toUpper(); + continue; + } + + QString str = text.at(i); + QTextCodec* pCodec = QTextCodec::codecForName("gb2312"); + if(!pCodec) return QChar(' '); + QByteArray arr = pCodec->fromUnicode(str); + unsigned char high = 0; + unsigned char low = 0; + int code = 0; + + if(arr.size() == 1) + { + high = 0; + low = arr.at(0) & 0xff; + } + else if(arr.size() == 2) + { + high = arr.at(0) & 0xff; + low = arr.at(1) & 0xff; + } + + if ( high < 0xa1 || low < 0xa1) + { + continue; + } + else + { + code = (high - 0xa0) * 100 + low - 0xa0; + } + + pinyins += getPinyin(code); + } + return pinyins; +} + + +QString UkuiChineseLetter::getPinyin(int code)//此方法可以获取所有汉字的拼音 +{ + QString pinyin; + switch(code) + { + case 6325: + case 6436: + case 7571: + case 7925: + pinyin="A"; + break; + case 6263: + case 6440: + case 7040: + case 7208: + case 7451: + case 7733: + case 7945: + case 8616: + pinyin="AI"; + break; + case 5847: + case 5991: + case 6278: + case 6577: + case 6654: + case 7281: + case 7907: + case 8038: + case 8786: + pinyin="AN"; + break; + pinyin="ANG"; + break; + case 5974: + case 6254: + case 6427: + case 6514: + case 6658: + case 6959: + case 7033: + case 7081: + case 7365: + case 8190: + case 8292: + case 8643: + case 8701: + case 8773: + pinyin="AO"; + break; + case 6056: + case 6135: + case 6517: + case 7857: + case 8446: + case 8649: + case 8741: + pinyin="BA"; + break; + case 6267: + case 6334: + case 7494: + pinyin="BAI"; + break; + case 5870: + case 5964: + case 7851: + case 8103: + case 8113: + case 8418: + pinyin="BAN"; + break; + case 6182: + case 6826: + pinyin="BANG"; + break; + case 6165: + case 7063: + case 7650: + case 8017: + case 8157: + case 8532: + case 8621: + pinyin="BAO"; + break; + case 5635: + case 5873: + case 5893: + case 5993: + case 6141: + case 6703: + case 7753: + case 8039: + case 8156: + case 8645: + case 8725: + pinyin="BEI"; + break; + case 5946: + case 5948: + case 7458: + case 7928: + pinyin="BEN"; + break; + case 6452: + case 7420: + pinyin="BENG"; + break; + case 5616: + case 5734: + case 6074: + case 6109: + case 6221: + case 6333: + case 6357: + case 6589: + case 6656: + case 6725: + case 6868: + case 6908: + case 6986: + case 6994: + case 7030: + case 7052: + case 7221: + case 7815: + case 7873: + case 7985: + case 8152: + case 8357: + case 8375: + case 8387: + case 8416: + case 8437: + case 8547: + case 8734: + pinyin="BI"; + break; + case 5650: + case 5945: + case 6048: + case 6677: + case 6774: + case 7134: + case 7614: + case 7652: + case 7730: + case 7760: + case 8125: + case 8159: + case 8289: + case 8354: + case 8693: + pinyin="BIAN"; + break; + case 7027: + case 7084: + case 7609: + case 7613: + case 7958: + case 7980: + case 8106: + case 8149: + case 8707: + case 8752: + pinyin="BIAO"; + break; + case 8531: + pinyin="BIE"; + break; + case 5747: + case 6557: + case 7145: + case 7167: + case 7336: + case 7375: + case 7587: + case 7957: + case 8738: + case 8762: + pinyin="BIN"; + break; + case 5787: + case 5891: + case 6280: + pinyin="BING"; + break; + case 5781: + case 6403: + case 6636: + case 7362: + case 7502: + case 7771: + case 7864: + case 8030: + case 8404: + case 8543: + case 8559: + pinyin="BO"; + break; + case 6318: + case 6945: + case 7419: + case 7446: + case 7848: + case 7863: + case 8519: + pinyin="BU"; + break; + case 6474: + case 7769: + pinyin="CA"; + break; + pinyin="CAI"; + break; + case 6978: + case 7078: + case 7218: + case 8451: + case 8785: + pinyin="CAN"; + break; + case 5687: + pinyin="CANG"; + break; + case 6448: + case 6878: + case 8309: + case 8429: + pinyin="CAO"; + break; + case 6692: + pinyin="CE"; + break; + case 6515: + case 6825: + pinyin="CEN"; + break; + case 6465: + pinyin="CENG"; + break; + case 6639: + case 6766: + case 7017: + case 7230: + case 7311: + case 7322: + case 7363: + case 7942: + case 7979: + case 8135: + pinyin="CHA"; + break; + case 5713: + case 7846: + case 8091: + case 8218: + pinyin="CHAI"; + break; + case 5770: + case 5838: + case 6159: + case 6667: + case 6893: + case 6904: + case 6981: + case 7031: + case 7086: + case 7472: + case 7688: + case 7966: + case 8324: + case 8580: + pinyin="CHAN"; + break; + case 5686: + case 5943: + case 6041: + case 6137: + case 6660: + case 6568: + case 6749: + case 7029: + case 7047: + case 7438: + case 7509: + case 8680: + pinyin="CHANG"; + break; + case 6687: + case 7443: + case 8173: + pinyin="CHAO"; + break; + case 5969: + case 7726: + pinyin="CHE"; + break; + case 5840: + case 5863: + case 6251: + case 6433: + case 6923: + case 7201: + case 7320: + case 7755: + case 8619: + pinyin="CHEN"; + break; + case 5609: + case 5984: + case 7239: + case 7263: + case 7583: + case 7810: + case 7881: + case 7905: + case 8146: + case 8241: + case 8508: + pinyin="CHENG"; + break; + case 5749: + case 6015: + case 6061: + case 6319: + case 6374: + case 6420: + case 6445: + case 6633: + case 7042: + case 7523: + case 7787: + case 8023: + case 8101: + case 8161: + case 8231: + case 8304: + case 8355: + case 8388: + case 8489: + case 8556: + case 8746: + pinyin="CHI"; + break; + case 6091: + case 6671: + case 6731: + case 8409: + case 8430: + pinyin="CHONG"; + break; + case 5717: + case 6492: + case 6716: + case 8112: + case 8637: + pinyin="CHOU"; + break; + case 5601: + case 5927: + case 6680: + case 6732: + case 7109: + case 7238: + case 7290: + case 7343: + case 8150: + case 8260: + case 8573: + case 8777: + pinyin="CHU"; + break; + case 6285: + case 6408: + case 7590: + case 8563: + pinyin="CHUAI"; + break; + case 6622: + case 6955: + case 7516: + case 7843: + case 8413: + pinyin="CHUAN"; + break; + case 6675: + pinyin="CHUANG"; + break; + case 5879: + case 7302: + case 7319: + pinyin="CHUI"; + break; + case 6127: + case 8040: + case 8277: + pinyin="CHUN"; + break; + case 7401: + case 8554: + case 8626: + pinyin="CHUO"; + break; + pinyin="CI"; + break; + case 6075: + case 6358: + case 7684: + case 8043: + case 8457: + pinyin="4337 伺"; + break; + case 6042: + case 6840: + case 7085: + case 7193: + case 7214: + case 7240: + pinyin="CONG"; + break; + case 7308: + case 7403: + case 7577: + pinyin="COU"; + break; + case 6180: + case 6562: + case 6607: + case 7367: + case 8501: + case 8530: + case 8577: + pinyin="CU"; + break; + case 5764: + case 6305: + case 7664: + case 7973: + pinyin="CUAN"; + break; + case 6718: + case 6145: + case 6393: + case 7213: + case 7333: + case 7505: + case 8631: + pinyin="CUI"; + break; + case 6666: + case 8169: + pinyin="CUN"; + break; + case 5640: + case 6547: + case 7566: + case 7917: + case 7983: + case 8078: + case 8526: + case 8567: + pinyin="CUO"; + break; + case 6239: + case 6353: + case 6410: + case 6682: + case 7007: + case 8155: + case 8346: + case 8716: + case 8718: + pinyin="DA"; + break; + case 6004: + case 6316: + case 6523: + case 6942: + case 7110: + case 7173: + case 8776: + pinyin="DAI"; + break; + case 5757: + case 6144: + case 6402: + case 7373: + case 7470: + case 7781: + case 8067: + case 8087: + case 8185: + case 8376: + pinyin="DAN"; + break; + case 5852: + case 5942: + case 6148: + case 6920: + case 7724: + case 7885: + case 8141: + pinyin="DANG"; + break; + case 6322: + case 6665: + case 7514: + case 8478: + pinyin="DAO"; + break; + case 7929: + pinyin="DE"; + break; + case 6466: + case 6556: + case 7413: + case 7767: + case 7975: + case 8403: + pinyin="DENG"; + break; + case 5621: + case 5765: + case 5814: + case 5848: + case 5901: + case 5970: + case 6122: + case 6454: + case 7023: + case 7116: + case 7260: + case 7306: + case 7475: + case 7738: + case 7758: + case 7791: + case 7965: + case 8438: + case 8730: + pinyin="DI"; + break; + case 6439: + pinyin="DIA"; + break; + case 5871: + case 5967: + case 6559: + case 7172: + case 7868: + case 8116: + case 8118: + case 8401: + case 8558: + pinyin="DIAN"; + break; + case 7886: + case 8585: + case 8684: + pinyin="DIAO"; + break; + case 5976: + case 6006: + case 6273: + case 6409: + case 7526: + case 8012: + case 8183: + case 8562: + case 8688: + pinyin="DIE"; + break; + case 5674: + case 6404: + case 7164: + case 7575: + case 7754: + case 7814: + case 8059: + case 8184: + case 8490: + pinyin="DING"; + break; + case 7891: + pinyin="DIU"; + break; + case 5977: + case 6343: + case 6520: + case 6528: + case 7517: + case 7543: + case 7556: + case 7747: + case 8020: + pinyin="DONG"; + break; + case 6190: + case 8128: + case 8229: + case 8391: + pinyin="DOU"; + break; + case 6022: + case 6429: + case 6834: + case 7292: + case 7525: + case 8328: + case 8338: + case 8739: + case 8782: + pinyin="DU"; + break; + case 7318: + case 7649: + case 8393: + pinyin="DUAN"; + break; + case 7701: + case 7713: + case 7752: + pinyin="DUI"; + break; + case 6771: + case 7632: + case 7727: + case 7766: + case 7779: + case 7970: + case 8527: + pinyin="DUN"; + break; + case 6345: + case 6365: + case 6785: + case 7122: + case 7876: + case 8154: + case 8566: + pinyin="DUO"; + break; + case 5612: + case 5832: + case 5844: + case 5949: + case 6035: + case 6113: + case 6164: + case 6332: + case 6721: + case 6977: + case 7025: + case 7378: + case 7581: + case 7916: + case 7941: + case 8042: + case 8206: + case 8689: + pinyin="E"; + break; + case 6176: + case 6284: + pinyin="EN"; + break; + case 5706: + case 6939: + case 7177: + case 7879: + case 8025: + case 8660: + pinyin="ER"; + break; + case 5950: + case 7732: + pinyin="FA"; + break; + case 6212: + case 6232: + case 6506: + case 7283: + case 7660: + case 7818: + case 8576: + pinyin="FAN"; + break; + case 5890: + case 7242: + case 7853: + case 8419: + case 8648: + pinyin="FANG"; + break; + case 6032: + case 6584: + case 6713: + case 6839: + case 6990: + case 7119: + case 7328: + case 7572: + case 7619: + case 7673: + case 7948: + case 8082: + case 8267: + case 8385: + case 8468: + case 8613: + case 8678: + pinyin="FEI"; + break; + case 5739: + case 6915: + case 7291: + case 8687: + case 8787: + pinyin="FEN"; + break; + case 5726: + case 5926: + case 6155: + case 6384: + case 6767: + case 7731: + pinyin="FENG"; + break; + pinyin="FO"; + break; + case 8330: + pinyin="FOU"; + break; + case 5775: + case 5776: + case 5914: + case 6029: + case 6062: + case 6119: + case 6142: + case 6252: + case 6327: + case 6505: + case 6686: + case 6870: + case 6985: + case 7058: + case 7066: + case 7106: + case 7108: + case 7285: + case 7471: + case 7680: + case 7741: + case 7774: + case 7775: + case 7823: + case 7991: + case 8005: + case 8222: + case 8261: + case 8280: + case 8283: + case 8479: + case 8535: + case 8538: + case 8654: + case 8691: + pinyin="FU"; + break; + case 6246: + case 7056: + case 7057: + case 7424: + case 7837: + pinyin=" GA"; + break; + case 5604: + case 5875: + case 5982: + case 7414: + case 7464: + pinyin="GAI"; + break; + case 5965: + case 6053: + case 6247: + case 6306: + case 6779: + case 6838: + case 6887: + case 7104: + case 7347: + case 7426: + case 7723: + case 8065: + case 8491: + pinyin="GAN"; + break; + case 7716: + case 7824: + case 8364: + pinyin="GANG"; + break; + case 5626: + case 5830: + case 5912: + case 6227: + case 7141: + case 7332: + case 7334: + case 7429: + case 7915: + pinyin="GAO"; + break; + case 5610: + case 5678: + case 5933: + case 5957: + case 6010: + case 6435: + case 7092: + case 7501: + case 7585: + case 7749: + case 7951: + case 8143: + case 8220: + case 8420: + case 8732: + pinyin="GE"; + break; + pinyin="GEI"; + break; + case 5608: + case 6102: + case 6371: + case 8462: + pinyin="GEN"; + break; + case 6376: + case 6657: + case 7114: + case 8665: + pinyin="GENG"; + break; + case 7178: + case 7537: + case 8228: + case 8601: + pinyin="GONG"; + break; + case 5694: + case 5824: + case 6524: + case 6960: + case 7037: + case 7135: + case 7259: + case 7477: + case 7616: + case 8349: + case 8384: + case 8724: + pinyin="GOU"; + break; + case 5637: + case 5812: + case 6152: + case 6536: + case 6773: + case 7284: + case 7379: + case 7484: + case 7486: + case 7591: + case 7617: + case 7813: + case 7825: + case 7860: + case 7932: + case 8019: + case 8083: + case 8233: + case 8494: + case 8593: + case 8681: + case 8729: + pinyin="GU"; + break; + case 5652: + case 5820: + case 6341: + case 7273: + case 7550: + case 8027: + pinyin="GUA"; + break; + pinyin="GUAI"; + break; + case 5736: + case 6124: + case 6272: + case 6842: + case 7834: + case 8057: + case 8170: + case 8704: + pinyin="GUAN"; + break; + case 6359: + case 6578: + case 7270: + case 7555: + pinyin="GUANG"; + break; + case 5648: + case 5659: + case 6649: + case 7003: + case 7277: + case 7433: + case 7448: + case 8007: + case 8394: + case 8657: + case 8712: + pinyin="GUI"; + break; + case 5782: + case 7121: + case 7762: + case 8671: + pinyin="GUN"; + break; + case 5769: + case 6266: + case 6335: + case 6494: + case 6538: + case 6603: + case 7304: + case 7529: + case 8188: + case 8268: + case 8269: + pinyin="GUO"; + break; + case 7894: + pinyin="HA"; + break; + case 6443: + case 7560: + case 8516: + pinyin="HAI"; + break; + case 5885: + case 6153: + case 6294: + case 6759: + case 6911: + case 7447: + case 7642: + case 8192: + case 8205: + case 8232: + case 8793: + pinyin="HAN"; + break; + case 6776: + case 7112: + case 8194: + pinyin="HANG"; + break; + case 6179: + case 6222: + case 6438: + case 6467: + case 6909: + case 6916: + case 7427: + case 8009: + case 8211: + case 8226: + pinyin="HAO"; + break; + case 5813: + case 5932: + case 5954: + case 6432: + case 6756: + case 7434: + case 7833: + case 8202: + case 8234: + case 8471: + pinyin="HE"; + break; + pinyin="HEI"; + break; + pinyin="HEN"; + break; + case 6231: + case 7181: + case 7276: + pinyin="HENG"; + break; + case 5768: + case 5774: + case 5807: + case 6106: + case 6214: + case 6216: + case 6740: + case 6792: + pinyin="HONG"; + break; + case 6009: + case 6565: + case 6943: + case 8090: + case 8383: + case 8455: + case 8655: + case 8731: + pinyin="HOU"; + break; + case 5792: + case 6392: + case 6481: + case 6518: + case 6609: + case 6679: + case 6717: + case 6816: + case 6879: + case 7190: + case 7346: + case 7385: + case 7618: + case 7635: + case 7646: + case 7670: + case 7672: + case 7679: + case 8013: + case 8032: + case 8041: + case 8055: + case 8343: + case 8513: + case 8590: + pinyin="HU"; + break; + case 7072: + case 7275: + case 7725: + case 7892: + pinyin="HUA"; + break; + case 8555: + pinyin="HUAI"; + break; + case 5928: + case 6140: + case 6307: + case 6487: + case 6621: + case 6801: + case 6829: + case 6881: + case 6930: + case 6953: + case 7157: + case 7944: + case 8673: + case 8763: + pinyin="HUAN"; + break; + case 5882: + case 6569: + case 6850: + case 6874: + case 6956: + case 7211: + case 7533: + case 8105: + case 8308: + case 8382: + case 8692: + pinyin="HUANG"; + break; + case 5822: + case 6078: + case 6086: + case 6205: + case 6352: + case 6360: + case 6425: + case 6736: + case 6807: + case 6811: + case 6971: + case 7132: + case 7185: + case 7445: + case 7703: + case 8219: + case 8319: + case 8766: + pinyin="HUI"; + break; + case 5827: + case 6638: + case 6752: + case 6867: + pinyin="HUN"; + break; + case 5669: + case 6229: + case 6311: + case 6475: + case 6623: + case 7856: + case 7933: + case 7976: + case 8175: + case 8322: + pinyin="HUO"; + break; + case 5629: + case 5632: + case 5662: + case 5705: + case 5742: + case 5952: + case 6024: + case 6033: + case 6193: + case 6210: + case 6265: + case 6320: + case 6350: + case 6383: + case 6507: + case 6553: + case 6809: + case 6976: + case 7087: + case 7160: + case 7165: + case 7314: + case 7374: + case 7410: + case 7411: + case 7469: + case 7473: + case 7487: + case 7620: + case 7722: + case 7831: + case 7990: + case 8002: + case 8104: + case 8217: + case 8337: + case 8339: + case 8463: + case 8550: + case 8611: + case 8661: + case 8674: + case 8757: + case 8768: + pinyin="JI"; + break; + case 5704: + case 5903: + case 6171: + case 6521: + case 6804: + case 6940: + case 7176: + case 7409: + case 7546: + case 7702: + case 7882: + case 7956: + case 8072: + case 8142: + case 8244: + case 8353: + case 8434: + case 8542: + pinyin="JIA"; + break; + case 5752: + case 5841: + case 5857: + case 6149: + case 6183: + case 6286: + case 6853: + case 6931: + case 6932: + case 7144: + case 7237: + case 7305: + case 7407: + case 7415: + case 7480: + case 7489: + case 7506: + case 7576: + case 7790: + case 7921: + case 8047: + case 8148: + case 8340: + case 8469: + case 8534: + case 8561: + case 8668: + case 8721: + pinyin="JIAN"; + break; + case 6092: + case 6814: + case 7113: + case 7154: + case 7481: + case 7768: + case 8180: + case 8461: + case 8488: + pinyin="JIANG"; + break; + case 5714: + case 5753: + case 6020: + case 6090: + case 6256: + case 6461: + case 6572: + case 7015: + case 7524: + case 8008: + case 8052: + case 8252: + case 8520: + case 8551: + case 8662: + pinyin="JIAO"; + break; + case 5806: + case 5821: + case 6255: + case 6414: + case 7028: + case 7061: + case 7278: + case 7757: + case 8060: + case 8201: + case 8227: + case 8441: + case 8658: + case 8726: + pinyin="JIE"; + break; + case 5865: + case 6103: + case 6132: + case 6468: + case 6643: + case 6659: + case 7138: + case 7210: + case 7340: + case 7465: + case 7478: + case 8138: + pinyin="JIN"; + break; + case 5751: + case 5869: + case 6128: + case 6616: + case 6729: + case 6794: + case 6941: + case 6982: + case 7026: + case 7534: + case 7554: + case 7570: + case 7626: + pinyin="JIANG"; + break; + case 6936: + case 7671: + pinyin="JIONG"; + break; + case 5754: + case 6417: + case 6746: + case 7249: + case 7274: + case 8015: + case 8053: + case 8481: + case 8761: + pinyin="JIU"; + break; + case 5738: + case 5810: + case 6036: + case 6058: + case 6076: + case 6268: + case 6965: + case 6980: + case 7202: + case 7307: + case 7316: + case 7323: + case 7357: + case 7381: + case 7488: + case 7611: + case 7850: + case 7924: + case 8022: + case 8132: + case 8153: + case 8482: + case 8522: + case 8565: + case 8620: + case 8634: + case 8722: + pinyin="JU"; + break; + case 5918: + case 6590: + case 6824: + case 7280: + case 7835: + case 7935: + case 7952: + case 8633: + pinyin="JUAN"; + break; + case 5642: + case 5667: + case 5860: + case 5939: + case 6207: + case 6421: + case 6457: + case 6469: + case 6540: + case 6617: + case 7062: + case 7169: + case 7286: + case 7351: + case 7663: + case 7967: + case 8574: + case 8591: + pinyin="JUE"; + break; + case 6260: + case 8168: + case 8362: + case 8769: + pinyin="JUN"; + break; + case 5671: + case 6339: + case 7544: + pinyin="KA"; + break; + case 5660: + case 5978: + case 6160: + case 6673: + case 6693: + case 7888: + case 7920: + case 7939: + pinyin="KAI"; + break; + case 5709: + case 6108: + case 7412: + case 7772: + case 7811: + pinyin="KAN"; + break; + case 5688: + case 6742: + case 7854: + pinyin="KANG"; + break; + case 6974: + case 7264: + case 7491: + case 7877: + pinyin="KAO"; + break; + case 6430: + case 6519: + case 6701: + case 6859: + case 7076: + case 7128: + case 7170: + case 7380: + case 7520: + case 7807: + case 7861: + case 7930: + case 7993: + case 8066: + case 8129: + case 8204: + case 8282: + case 8733: + pinyin="KE"; + break; + case 8144: + pinyin="KEN"; + break; + case 7912: + pinyin="KENG"; + break; + case 5737: + case 6539: + case 8377: + pinyin="KONG"; + break; + case 6050: + case 6202: + case 6321: + case 7778: + case 8356: + pinyin="KOU"; + break; + case 5658: + case 6005: + case 6423: + case 7111: + case 8728: + pinyin="KU"; + break; + case 5708: + pinyin="KUA"; + break; + case 5665: + case 5906: + case 6364: + case 6586: + case 7558: + pinyin="KUAI"; + break; + case 8737: + pinyin="KUAN"; + break; + case 5818: + case 5831: + case 5887: + case 5959: + case 6237: + case 6349: + case 7094: + case 7460: + pinyin="KUANG"; + break; + case 5624: + case 5649: + case 5771: + case 6162: + case 6281: + case 6413: + case 6416: + case 6720: + case 6951: + case 7450: + case 7805: + case 8606: + case 8743: + pinyin="KUI"; + break; + case 6204: + case 6245: + case 6458: + case 6618: + case 6928: + case 7152: + case 7841: + case 8051: + pinyin="LIAO"; + break; + case 5793: + case 5988: + case 6270: + case 6354: + case 6803: + case 8483: + case 8581: + case 8764: + pinyin="LIE"; + break; + case 6194: + case 6388: + case 6555: + case 6662: + case 6733: + case 6964: + case 7361: + case 7405: + case 7602: + case 7812: + case 8452: + case 8579: + case 8775: + pinyin="LIN"; + break; + case 5925: + case 6063: + case 6342: + case 6482: + case 6786: + case 7117: + case 7258: + case 7289: + case 7418: + case 8186: + case 8240: + case 8465: + case 8676: + pinyin="LING"; + break; + case 6815: + case 6962: + case 7082: + case 7124: + case 7628: + case 7654: + case 7919: + case 7954: + case 8050: + case 8644: + pinyin="LIU"; + break; + case 5966: + case 6055: + case 6781: + case 7171: + case 7248: + case 7542: + case 7735: + case 8110: + pinyin="LONG"; + break; + case 5745: + case 6168: + case 6422: + case 6548: + case 7946: + case 8092: + case 8179: + case 8287: + case 8735: + pinyin="LOU"; + break; + case 6744: + case 7321: + case 7586: + case 7918: + case 7989: + case 8158: + pinyin="Lü"; + break; + case 5968: + case 6303: + case 6464: + case 6782: + case 6843: + case 6885: + case 6954: + case 7220: + case 7251: + case 7354: + case 7391: + case 7404: + case 7510: + case 7545: + case 7969: + case 8021: + case 8056: + case 8392: + case 8421: + case 8652: + pinyin="LU"; + break; + case 5785: + case 7014: + case 7279: + case 8029: + case 8639: + pinyin="LUAN"; + break; + pinyin="LǖE"; + break; + pinyin="LUN"; + break; + case 5732: + case 5789: + case 6093: + case 6259: + case 6291: + case 6604: + case 6788: + case 6880: + case 7183: + case 7301: + case 7565: + case 7961: + case 8107: + case 8635: + pinyin="LUO"; + break; + case 6328: + pinyin="M"; + break; + case 6373: + case 6579: + case 7054: + case 7231: + case 8301: + pinyin="MA"; + break; + case 5929: + case 6104: + case 8618: + pinyin="MAI"; + break; + case 6012: + case 6503: + case 7147: + case 7655: + case 7960: + case 8209: + case 8293: + case 8709: + case 8720: + pinyin="MAN"; + break; + case 5888: + case 6861: + case 7743: + case 8294: + pinyin="MANG"; + break; + case 5783: + case 6066: + case 6525: + case 6787: + case 7203: + case 7436: + case 7483: + case 7503: + case 7624: + case 7714: + case 7806: + case 8317: + case 8754: + pinyin="MAO"; + break; + case 6114: + case 6550: + case 6613: + case 6828: + case 6856: + case 7325: + case 7949: + case 8044: + case 8139: + case 8740: + pinyin="MEI"; + break; + case 6249: + case 7643: + case 7715: + case 7845: + pinyin="MEN"; + break; + case 5934: + case 6189: + case 6211: + case 6734: + case 7592: + case 7770: + case 8221: + case 8276: + case 8323: + case 8427: + case 8431: + pinyin="MENG"; + break; + case 5634: + case 5855: + case 6234: + case 6368: + case 6455: + case 6608: + case 6772: + case 6921: + case 6984: + case 7563: + case 7682: + case 8445: + case 8767: + case 8771: + pinyin="MI"; + break; + case 6770: + case 6837: + case 6847: + case 7579: + case 7777: + pinyin="MIAN"; + break; + case 6387: + case 6967: + case 7131: + case 7149: + case 7234: + case 7721: + case 7780: + case 8037: + pinyin="MIAO"; + break; + case 5631: + case 6367: + case 8326: + case 8390: + pinyin="MIE"; + break; + case 6069: + case 6526: + case 6741: + case 6793: + case 7137: + case 7168: + case 7175: + case 7710: + case 8710: + case 8628: + pinyin="MIN"; + break; + case 5804: + case 6088: + case 6873: + case 7452: + case 7808: + case 8504: + pinyin="MING"; + break; + pinyin="MIU"; + break; + case 5851: + case 6052: + case 6175: + case 6641: + case 7038: + case 7366: + case 7950: + case 7987: + case 8102: + case 8182: + case 8586: + case 8588: + case 8765: + pinyin="MO"; + break; + case 5716: + case 6372: + case 7788: + case 8254: + case 8290: + case 8642: + pinyin="MOU"; + break; + case 5679: + case 5973: + case 6057: + case 6769: + case 7504: + case 7866: + pinyin="MU"; + break; + case 6437: + pinyin="N"; + break; + case 6264: + case 7539: + case 7953: + case 8136: + pinyin="NA"; + break; + case 5630: + case 6021: + case 6133: + case 7245: + pinyin="NAI"; + break; + case 6411: + case 6478: + case 6479: + case 7310: + case 7578: + case 8279: + case 8486: + pinyin="NAN"; + break; + case 6313: + case 6476: + case 6646: + case 7457: + pinyin="NANG"; + break; + case 5611: + case 5981: + case 6346: + case 6614: + case 7207: + case 7748: + case 7883: + case 8245: + pinyin="NAO"; + break; + case 5811: + pinyin="NE"; + break; + pinyin="NEI"; + break; + case 7705: + pinyin="NEN"; + break; + pinyin="NENG"; + break; + case 5703: + case 5972: + case 6605: + case 6685: + case 7439: + case 7627: + case 7711: + case 7794: + case 7874: + case 8682: + pinyin="NI"; + break; + case 5605: + case 5994: + case 7393: + case 8004: + case 8651: + case 8683: + pinyin="NIAN"; + break; + pinyin="NIANG"; + break; + case 6064: + case 7053: + case 7569: + case 8433: + pinyin="NIAO"; + break; + case 5877: + case 6233: + case 6431: + case 8208: + case 8411: + case 8570: + pinyin="NIE"; + break; + pinyin="NIN"; + break; + case 5690: + case 6344: + case 6924: + case 8187: + pinyin="NING"; + break; + case 6580: + case 6678: + case 7004: + pinyin="NIU"; + break; + case 5715: + case 6370: + pinyin="NONG"; + break; + case 8181: + pinyin="NOU"; + break; + case 6983: + case 7032: + case 7059: + case 7069: + pinyin="NU"; + break; + case 7704: + case 7847: + case 8412: + pinyin="Nǖ"; + break; + pinyin="NUAN"; + break; + pinyin="NUE"; + break; + case 5748: + case 6289: + case 6386: + case 7927: + pinyin="NUO"; + break; + case 6424: + case 6462: + pinyin="O"; + break; + case 5809: + case 6670: + case 7417: + case 8178: + pinyin="OU"; + break; + case 6166: + case 7243: + case 8365: + pinyin="PA"; + break; + case 5729: + case 6169: + case 6363: + pinyin="PAI"; + break; + case 6761: + case 6790: + case 8140: + case 8165: + case 8320: + case 8571: + pinyin="PAN"; + break; + case 6561: + case 6872: + case 6944: + case 8306: + pinyin="PANG"; + break; + case 6243: + case 6583: + case 6650: + case 7567: + case 8069: + pinyin="PAO"; + break; + case 6446: + case 6490: + case 7623: + case 7934: + case 8512: + case 8612: + pinyin="PEI"; + break; + case 6852: + pinyin="PEN"; + break; + case 6001: + case 6456: + case 6681: + case 8318: + pinyin="PENG"; + break; + case 5607: + case 5682: + case 5880: + case 5892: + case 5915: + case 5960: + case 6017: + case 6037: + case 6308: + case 6472: + case 6647: + case 6836: + case 7039: + case 7102: + case 7233: + case 7422: + case 7802: + case 7828: + case 7875: + case 8117: + case 8166: + case 8223: + case 8271: + case 8589: + pinyin="PI"; + break; + case 5850: + case 7073: + case 7490: + case 7561: + case 8470: + case 8568: + pinyin="PIAN"; + break; + case 5666: + case 6449: + case 7046: + case 7146: + case 7372: + case 7809: + case 8310: + pinyin="PIAO"; + break; + case 6054: + case 7513: + pinyin="PIE"; + break; + case 7041: + case 6253: + case 7016: + case 7315: + case 7482: + case 8213: + pinyin="PIN"; + break; + case 5723: + case 7019: + case 7250: + case 8650: + pinyin="PING"; + break; + case 5647: + case 5922: + case 7174: + case 7839: + case 7862: + case 8011: + case 8345: + pinyin="PO"; + break; + case 5786: + case 6269: + pinyin="POU"; + break; + case 5773: + case 6459: + case 6863: + case 6907: + case 7217: + case 7511: + case 7968: + case 7972: + case 8575: + pinyin="PU"; + break; + case 5633: + case 5725: + case 5963: + case 6027: + case 6046: + case 6089: + case 6129: + case 6134: + case 6161: + case 6213: + case 6366: + case 6450: + case 6508: + case 6510: + case 6764: + case 6831: + case 7075: + case 7118: + case 7187: + case 7189: + case 7229: + case 7271: + case 7342: + case 7440: + case 7605: + case 7687: + case 7712: + case 7751: + case 8193: + case 8251: + case 8264: + case 8475: + case 8476: + case 8572: + case 8702: + case 8772: + pinyin="QI"; + break; + case 6154: + case 8736: + pinyin="QIA"; + break; + case 5727: + case 5761: + case 5868: + case 6023: + case 6045: + case 6071: + case 6271: + case 6509: + case 6705: + case 6727: + case 6925: + case 6926: + case 6929: + case 7155: + case 7293: + case 7541: + case 7709: + case 7852: + case 8215: + case 8373: + pinyin="QIAN"; + break; + case 6762: + case 7045: + case 7341: + case 7408: + case 7633: + case 7926: + case 7947: + case 7974: + case 8163: + case 8262: + case 8439: + case 8536: + pinyin="QIANG"; + break; + case 5668: + case 5829: + case 5859: + case 6081: + case 6529: + case 6724: + case 6730: + case 7352: + case 7745: + case 8546: + case 8719: + pinyin="QIAO"; + break; + case 5907: + case 6711: + case 7010: + case 7492: + case 7938: + case 8370: + pinyin="QIE"; + break; + case 6043: + case 6276: + case 6336: + case 6426: + case 6463: + case 6858: + case 7353: + case 7923: + case 8291: + case 8432: + pinyin="QIN"; + break; + case 6060: + case 6485: + case 7349: + case 7764: + case 8263: + case 8332: + case 8368: + case 8605: + case 8675: + case 8784: + pinyin="QING"; + break; + case 5886: + case 6068: + case 8123: + case 8243: + case 8344: + case 8528: + case 8638: + pinyin="QIONG"; + break; + case 5720: + case 5947: + case 6576: + case 6848: + case 6947: + case 6957: + case 7317: + case 7468: + case 8216: + case 8239: + case 8288: + case 8435: + case 8460: + case 8690: + case 8792: + pinyin="QIU"; + break; + case 5816: + case 5930: + case 6201: + case 6230: + case 6511: + case 6573: + case 6754: + case 7219: + case 7479: + case 7512: + case 7552: + case 7678: + case 7765: + case 8119: + case 8248: + case 8329: + case 8480: + case 8636: + case 8781: + pinyin="QU"; + break; + case 5825: + case 6085: + case 6710: + case 7125: + case 7390: + case 7816: + case 7893: + case 8273: + case 8360: + case 8760: + pinyin="QUAN"; + break; + case 6755: + case 6758: + case 7708: + pinyin="QUE"; + break; + case 6950: + pinyin="QUN"; + break; + case 6059: + case 8237: + case 8755: + pinyin="RAN"; + break; + case 7692: + case 8006: + pinyin="RANG"; + break; + case 6073: + case 7012: + case 7267: + pinyin="RAO"; + break; + pinyin="RE"; + break; + case 5680: + case 6083: + case 6156: + case 6631: + case 7377: + case 7994: + case 8137: + pinyin="REN"; + break; + pinyin="RENG"; + break; + pinyin="RI"; + break; + case 6541: + case 6585: + case 7337: + case 7532: + case 8278: + pinyin="RONG"; + break; + case 8459: + case 8569: + case 8723: + pinyin="ROU"; + break; + case 6174: + case 6224: + case 6473: + case 6818: + case 6865: + case 6906: + case 7140: + case 7908: + case 8164: + case 8212: + pinyin="RU"; + break; + case 7535: + pinyin="RUAN"; + break; + case 6039: + case 6208: + case 7236: + case 7803: + case 8224: + pinyin="RUI"; + break; + pinyin="RUN"; + break; + case 5728: + case 8372: + pinyin="RUO"; + break; + case 5606: + case 5677: + case 7493: + case 7559: + case 7610: + pinyin="SA"; + break; + case 6471: + pinyin="SAI"; + break; + case 6644: + case 7507: + case 8454: + pinyin="SAN"; + break; + case 6290: + case 7763: + case 8210: + pinyin="SANG"; + break; + case 6003: + case 7150: + case 7156: + case 7593: + case 8094: + case 8694: + pinyin="SAO"; + break; + pinyin="SE"; + break; + pinyin="SEN"; + break; + pinyin="SENG"; + break; + case 6394: + case 7606: + case 7901: + case 8080: + case 8436: + case 8614: + case 8672: + pinyin="SHA"; + break; + case 8507: + pinyin="SHAI"; + break; + case 5663: + case 5808: + case 5923: + case 5979: + case 6047: + case 6890: + case 7009: + case 7051: + case 7083: + case 7594: + case 7844: + case 8062: + case 8321: + case 8414: + case 8539: + case 8713: + pinyin="SHAN"; + break; + case 5980: + case 7120: + case 7368: + case 7656: + case 8592: + pinyin="SHANG"; + break; + case 5931: + case 6070: + case 6891: + case 7228: + case 8366: + case 8425: + pinyin="SHAO"; + break; + case 5639: + case 5760: + case 6606: + case 6860: + case 7608: + case 7820: + case 8774: + pinyin="SHE"; + break; + case 5837: + case 6123: + case 6351: + case 6841: + case 7309: + case 7547: + case 7982: + case 8255: + pinyin="SHEN"; + break; + case 6551: + case 7441: + case 7782: + case 8347: + pinyin="SHENG"; + break; + case 5854: + case 5985: + case 6110: + case 6173: + case 6317: + case 7388: + case 7459: + case 7634: + case 7870: + case 8307: + case 8334: + case 8363: + case 8525: + case 8669: + case 8685: + pinyin="SHI"; + break; + case 6587: + case 7123: + case 8428: + pinyin="SHOU"; + break; + case 5731: + case 5951: + case 6136: + case 6283: + case 6780: + case 6888: + case 7013: + case 7508: + case 7582: + case 7988: + pinyin="SHU"; + break; + case 6407: + pinyin="SHUA"; + break; + case 8316: + pinyin="SHUAI"; + break; + case 6737: + case 6844: + pinyin="SHUAN"; + break; + case 7055: + pinyin="SHUANG"; + break; + pinyin="SHUI"; + break; + pinyin="SHUN"; + break; + case 6184: + case 6287: + case 6989: + case 7335: + case 7869: + pinyin="SHUO"; + break; + case 5643: + case 5778: + case 5944: + case 6348: + case 6765: + case 6784: + case 6889: + case 7006: + case 7065: + case 7133: + case 7675: + case 7940: + case 8024: + case 8174: + case 8247: + case 8351: + pinyin="SI"; + break; + case 5801: + case 6131: + case 6534: + case 6552: + case 6676: + case 6704: + case 6833: + case 8121: + pinyin="SONG"; + break; + case 5937: + case 6220: + case 6418: + case 6453: + case 6640: + case 6849: + case 7612: + case 7804: + case 7943: + case 8284: + pinyin="SOU"; + break; + case 5777: + case 5853: + case 6188: + case 6428: + case 6726: + case 6819: + case 8389: + case 8602: + case 8653: + pinyin="SU"; + break; + case 6601: + pinyin="SUAN"; + break; + case 5839: + case 6120: + case 6901: + case 6968: + case 7661: + case 7785: + case 7801: + pinyin="SUI"; + break; + case 6105: + case 6588: + case 6624: + case 7330: + case 8632: + pinyin="SUN"; + break; + case 6379: + case 6434: + case 6442: + case 7022: + case 7288: + case 7792: + case 8440: + pinyin="SUO"; + break; + case 6743: + case 6866: + case 6961: + case 7329: + case 7719: + case 7872: + case 8533: + case 8703: + pinyin="TA"; + break; + case 5902: + case 6223: + case 6330: + case 7070: + case 7536: + case 7638: + case 7849: + case 8544: + case 8656: + pinyin="TAI"; + break; + case 5916: + case 6903: + case 7428: + case 7694: + case 7867: + case 7936: + case 8191: + pinyin="TAN"; + break; + case 5746: + case 6491: + case 6871: + case 7209: + case 7344: + case 7906: + case 7959: + case 8177: + case 8305: + case 8311: + case 8442: + case 8517: + pinyin="TANG"; + break; + case 5627: + case 6391: + case 6812: + case 7226: + case 7666: + pinyin="TAO"; + break; + pinyin="1845 餐"; + break; + case 6315: + case 7693: + case 7911: + pinyin="TE"; + break; + case 7588: + pinyin="TENG"; + break; + case 5735: + case 6709: + case 6949: + case 7130: + case 8035: + case 8151: + case 8514: + pinyin="TI"; + break; + case 6261: + case 6735: + case 6757: + case 7369: + case 7817: + pinyin="TIAN"; + break; + case 5712: + case 7686: + case 8127: + case 8272: + case 8352: + case 8448: + case 8622: + case 8670: + case 8756: + pinyin="TIAO"; + break; + case 6138: + case 8749: + pinyin="TIE"; + break; + case 6080: + case 6167: + case 7035: + case 7272: + case 7890: + case 8249: + case 8610: + pinyin="TING"; + break; + case 5701: + case 5758: + case 6077: + case 6444: + case 6690: + case 6892: + case 7737: + pinyin="TONG"; + break; + case 7855: + case 7822: + case 8727: + pinyin="TOU"; + break; + case 6002: + case 6117: + case 6143: + case 7842: + case 8509: + pinyin="TU"; + break; + case 6250: + case 6972: + pinyin="TUAN"; + break; + case 7653: + pinyin="TUI"; + break; + case 5759: + case 6629: + case 7453: + case 7564: + pinyin="TUN"; + break; + case 5617: + case 5702: + case 5971: + case 6653: + case 6791: + case 7256: + case 7262: + case 7350: + case 7740: + case 8374: + case 8502: + case 8541: + case 8630: + pinyin="TUO"; + break; + case 5684: + case 7020: + case 7580: + pinyin="WA"; + break; + pinyin="WAI"; + break; + case 5664: + case 6025: + case 6150: + case 7093: + case 7126: + case 7194: + case 7568: + case 7821: + case 8274: + pinyin="WAN"; + break; + case 5672: + case 6244: + case 6715: + case 7394: + case 8745: + pinyin="WANG"; + break; + case 5743: + case 5835: + case 5881: + case 5883: + case 6158: + case 6217: + case 6488: + case 6501: + case 6543: + case 6545: + case 6611: + case 6612: + case 6739: + case 6777: + case 6802: + case 6822: + case 6952: + case 7024: + case 7166: + case 7224: + case 7406: + case 7631: + case 7648: + case 8084: + case 8426: + case 8659: + pinyin="WEI"; + break; + case 5656: + case 6751: + case 6775: + case 7223: + case 8609: + pinyin="WEN"; + break; + case 6178: + case 6219: + pinyin="WENG"; + break; + case 5733: + case 6111: + case 6502: + case 6855: + case 7531: + case 7750: + case 8627: + pinyin="WO"; + break; + case 5603: + case 5685: + case 5867: + case 5889: + case 5956: + case 6044: + case 6377: + case 6648: + case 6668: + case 6672: + case 6820: + case 6927: + case 6935: + case 6992: + case 7036: + case 7080: + case 7227: + case 7485: + case 7641: + case 8036: + case 8045: + case 8077: + case 8258: + case 8640: + case 8789: + pinyin="WU"; + break; + case 5750: + case 5766: + case 5884: + case 5913: + case 6130: + case 6163: + case 6191: + case 6241: + case 6381: + case 6567: + case 6630: + case 6750: + case 6827: + case 6832: + case 6979: + case 7050: + case 7184: + case 7356: + case 7456: + case 7474: + case 7604: + case 7668: + case 7689: + case 7691: + case 8010: + case 8122: + case 8265: + case 8303: + case 8312: + case 8410: + case 8424: + case 8443: + case 8449: + case 8466: + case 8521: + case 8791: + pinyin="XI"; + break; + case 6340: + case 6582: + case 6958: + case 7206: + case 7252: + case 7744: + case 8093: + case 8333: + case 8779: + pinyin="XIA"; + break; + case 5794: + case 5823: + case 6040: + case 6118: + case 6226: + case 6513: + case 6593: + case 6963: + case 7021: + case 7515: + case 7662: + case 7676: + case 8034: + case 8079: + case 8225: + case 8358: + case 8444: + case 8503: + case 8548: + case 8549: + case 8617: + pinyin="XIAN"; + break; + case 6028: + case 6157: + case 6635: + case 6652: + case 7088: + case 7129: + case 8313: + case 8663: + case 8747: + pinyin="XIANG"; + break; + case 6356: + case 6537: + case 6876: + case 6948: + case 7071: + case 7115: + case 7241: + case 7253: + case 8257: + case 8367: + case 8379: + case 8744: + pinyin="XIAO"; + break; + case 5741: + case 5784: + case 5936: + case 5938: + case 6215: + case 6302: + case 6619: + case 6661: + case 6845: + case 6912: + case 6966: + case 7105: + case 7151: + case 7331: + case 7339: + case 8583: + pinyin="XIE"; + break; + case 5622: + case 6016: + case 7431: + case 7607: + case 8646: + pinyin="XIN"; + break; + case 5874: + case 6084: + case 6309: + case 6712: + case 7742: + pinyin="XING"; + break; + case 6026: + pinyin="XIONG"; + break; + case 6361: + case 6522: + case 6642: + case 6651: + case 6869: + case 8028: + case 8587: + case 8759: + pinyin="XIU"; + break; + case 5828: + case 5935: + case 5955: + case 6203: + case 6810: + case 6851: + case 7179: + case 7282: + case 7667: + case 7776: + case 8167: + case 8458: + case 8515: + pinyin="XU"; + break; + case 5756: + case 5846: + case 6170: + case 6279: + case 6789: + case 6854: + case 6886: + case 7215: + case 7324: + case 7449: + case 7637: + case 7651: + case 7759: + case 7871: + case 7964: + case 8071: + pinyin="XUAN"; + break; + case 5842: + case 7720: + case 8529: + case 8708: + pinyin="XUE"; + break; + case 5767: + case 5908: + case 5987: + case 6087: + case 6101: + case 6206: + case 6225: + case 6530: + case 6563: + case 6620: + case 6694: + case 6813: + case 6817: + case 7454: + case 8131: + case 8524: + case 8664: + pinyin="XUN"; + break; + case 5683: + case 5975: + case 6275: + case 6512: + case 6934: + case 7011: + case 7180: + case 7266: + case 7518: + case 7728: + case 7793: + case 8073: + pinyin="YA"; + break; + case 5641: + case 5645: + case 5718: + case 5740: + case 5780: + case 5861: + case 5917: + case 5919: + case 6030: + case 6146: + case 6535: + case 6691: + case 6738: + case 6753: + case 6846: + case 6857: + case 6991: + case 7044: + case 7192: + case 7360: + case 7444: + case 7557: + case 7645: + case 7827: + case 8359: + case 8506: + case 8742: + case 8748: + case 8790: + pinyin="YAN"; + break; + case 6564: + case 6683: + case 7630: + case 7640: + case 7706: + case 8253: + case 8717: + pinyin="YANG"; + break; + case 5618: + case 5619: + case 6326: + case 6542: + case 6570: + case 7159: + case 7182: + case 7235: + case 7387: + case 7455: + case 7540: + case 7902: + case 8046: + case 8126: + case 8477: + case 8705: + pinyin="YAO"; + break; + case 5644: + case 5843: + case 5894: + case 6262: + case 7442: + case 7639: + case 7884: + pinyin="YE"; + break; + case 5655: + case 5657: + case 5670: + case 5693: + case 5711: + case 5817: + case 5961: + case 5992: + case 6018: + case 6051: + case 6072: + case 6218: + case 6236: + case 6240: + case 6258: + case 6314: + case 6329: + case 6355: + case 6362: + case 6441: + case 6470: + case 6527: + case 6558: + case 6602: + case 6634: + case 6688: + case 6689: + case 6708: + case 6884: + case 6938: + case 7068: + case 7143: + case 7376: + case 7383: + case 7461: + case 7629: + case 7658: + case 7784: + case 7838: + case 7955: + case 7978: + case 8074: + case 8089: + case 8115: + case 8120: + case 8270: + case 8415: + case 8464: + case 8472: + case 8493: + case 8780: + pinyin="YI"; + break; + case 5623: + case 5920: + case 5983: + case 6007: + case 6065: + case 6337: + case 6419: + case 6594: + case 6625: + case 6806: + case 7519: + case 7887: + case 8111: + case 8230: + case 8615: + case 8624: + pinyin="YIN"; + break; + case 5788: + case 5911: + case 6067: + case 6094: + case 6126: + case 6151: + case 6186: + case 6292: + case 6451: + case 6663: + case 6862: + case 6875: + case 6913: + case 7188: + case 7212: + case 7326: + case 7584: + case 8048: + case 8108: + case 8203: + case 8331: + pinyin="YING"; + break; + case 6401: + pinyin="YO"; + break; + case 5724: + case 5953: + case 6013: + case 6415: + case 6728: + case 7163: + case 7962: + case 8014: + case 8711: + case 8751: + pinyin="YONG"; + break; + case 5653: + case 5692: + case 5707: + case 6112: + case 6115: + case 6121: + case 6347: + case 6483: + case 6922: + case 7254: + case 7364: + case 7527: + case 7880: + case 8064: + case 8236: + case 8242: + case 8286: + case 8647: + case 8778: + case 8788: + pinyin="YOU"; + break; + case 5614: + case 5625: + case 5681: + case 5722: + case 5836: + case 5845: + case 6139: + case 6187: + case 6277: + case 6484: + case 6486: + case 6546: + case 6592: + case 6632: + case 6637: + case 6655: + case 6748: + case 6987: + case 6993: + case 7005: + case 7090: + case 7204: + case 7437: + case 7476: + case 7573: + case 7603: + case 7622: + case 7647: + case 7659: + case 7718: + case 7858: + case 8033: + case 8054: + case 8085: + case 8086: + case 8130: + case 8133: + case 8266: + case 8285: + case 8336: + case 8407: + case 8408: + case 8607: + case 8625: + pinyin="YU"; + break; + case 5989: + case 6011: + case 6282: + case 6768: + case 7034: + case 7205: + case 7358: + case 7528: + case 7783: + case 8016: + case 8302: + case 8378: + case 8629: + pinyin="YUAN"; + break; + case 5763: + case 6914: + case 7348: + case 7530: + case 7865: + pinyin="YUE"; + break; + case 5909: + case 6031: + case 6581: + case 6702: + case 6719: + case 7101: + case 7225: + case 7370: + case 7432: + case 7521: + case 7657: + pinyin="YUN"; + break; + case 6257: + case 6338: + pinyin="ZA"; + break; + case 6544: + case 7162: + pinyin="ZAI"; + break; + case 7222: + case 7435: + case 8402: + case 8456: + case 8485: + case 8641: + pinyin="ZAN"; + break; + case 6242: + case 7064: + case 7416: + pinyin="ZANG"; + break; + case 6380: + pinyin="ZAO"; + break; + case 5638: + case 8369: + case 5651: + case 6385: + case 6493: + case 6937: + case 7430: + case 8348: + case 8423: + pinyin="ZE"; + break; + pinyin="ZEI"; + break; + case 5858: + pinyin="ZEN"; + break; + case 7153: + case 7421: + case 7832: + case 7913: + pinyin="ZENG"; + break; + case 6610: + case 6274: + case 6324: + case 6369: + case 6378: + case 7736: + case 8068: + case 8238: + case 8794: + pinyin="ZHA"; + break; + case 7746: + case 8109: + pinyin="ZHAI"; + break; + case 5862: + case 6288: + case 7625: + pinyin="ZHAN"; + break; + case 5675: + case 5921: + case 6504: + case 6554: + case 6615: + case 7049: + case 7216: + case 8315: + pinyin="ZHANG"; + break; + case 5815: + case 7294: + case 7840: + case 8341: + pinyin="ZHAO"; + break; + case 5856: + case 6301: + case 7247: + case 7392: + case 7761: + case 8049: + case 8162: + case 8256: + case 8487: + pinyin="ZHE"; + break; + case 5958: + case 6172: + case 6805: + case 7139: + case 7269: + case 7327: + case 7384: + case 7466: + case 7551: + case 7562: + case 7685: + case 7819: + case 8001: + case 8018: + case 8380: + pinyin="ZHEN"; + break; + case 5826: + case 6531: + case 6571: + case 7859: + case 7903: + case 8361: + pinyin="ZHENG"; + break; + case 5620: + case 5876: + case 5904: + case 5990: + case 6038: + case 6293: + case 6489: + case 6669: + case 6973: + case 6975: + case 7079: + case 7246: + case 7255: + case 7257: + case 7268: + case 7382: + case 7389: + case 7462: + case 7553: + case 7589: + case 7677: + case 7683: + case 7773: + case 7984: + case 8026: + case 8075: + case 8246: + case 8474: + case 8505: + case 8537: + case 8557: + case 8560: + case 8584: + case 8603: + pinyin="ZHI"; + break; + case 5803: + case 7981: + case 8314: + case 8417: + case 8564: + pinyin="ZHONG"; + break; + case 6107: + case 6390: + case 7008: + case 7091: + case 7107: + case 7548: + case 7756: + case 8406: + case 8492: + pinyin="ZHOU"; + break; + case 5689: + case 5710: + case 5905: + case 6049: + case 6079: + case 6808: + case 6830: + case 6883: + case 7244: + case 7338: + case 7345: + case 7636: + case 7889: + case 8070: + case 8081: + case 8335: + case 8371: + case 8422: + case 8467: + case 8578: + case 8770: + pinyin="ZHU"; + break; + pinyin="ZHUA"; + break; + pinyin="ZHUAI"; + break; + case 6389: + case 6645: + case 8207: + pinyin="ZHUAN"; + break; + case 5755: + pinyin="ZHUANG"; + break; + case 6723: + case 7077: + case 7136: + pinyin="ZHUI"; + break; + case 7538: + case 8124: + pinyin="ZHUN"; + break; + case 5730: + case 5834: + case 6310: + case 6823: + case 6835: + case 6910: + case 7644: + case 7690: + case 7729: + case 7977: + pinyin="ZHUO"; + break; + case 5849: + case 6549: + case 7002: + case 7060: + case 7127: + case 7287: + case 7402: + case 7463: + case 7707: + case 7786: + case 7937: + case 7986: + case 8172: + case 8342: + case 8450: + case 8484: + case 8594: + case 8604: + case 8623: + case 8686: + case 8758: + pinyin="ZI"; + break; + case 5744: + case 7574: + case 8453: + pinyin="ZONG"; + break; + case 5833: + case 5878: + case 5924: + case 7067: + case 8677: + pinyin="ZOU"; + break; + case 5762: + case 6147: + case 7963: + pinyin="ZU"; + break; + case 6312: + case 7158: + case 8582: + pinyin="ZUAN"; + break; + case 6209: + pinyin="ZUI"; + break; + case 6304: + case 7355: + case 8714: + pinyin="ZUN"; + break; + case 5872: + case 6382: + case 6460: + case 6684: + case 7549: + case 7681: + pinyin="ZUO"; + break; + default: + if(code>=1601 && code<=1602) + { + pinyin="A"; + break; + } + if(code>=1603 && code<=1615) + { + pinyin="AI"; + break; + } + if(code>=1616 && code<=1624) + { + pinyin="AN"; + break; + } + if(code>=1625 && code<=1627) + { + pinyin="ANG"; + break; + } + if(code>=1628 && code<=1636) + { + pinyin="AO"; + break; + } + if(code>=1637 && code<=1654) + { + pinyin="BA"; + break; + } + if(code>=1655 && code<=1662) + { + pinyin="BAI"; + break; + } + if(code>=1663 && code<=1677) + { + pinyin="BAN"; + break; + } + if(code>=1678 && code<=1689) + { + pinyin="BANG"; + break; + } + if(code>=1690 && code<=1712) + { + pinyin="BAO"; + break; + } + if(code>=1713 && code<=1727) + { + pinyin="BEI"; + break; + } + if(code>=1728 && code<=1731) + { + pinyin="BEN"; + break; + } + if(code>=1732 && code<=1737) + { + pinyin="BENG"; + break; + } + if(code>1738 && code<=1761) + { + pinyin="BI"; + break; + } + if(code>=1762 && code<=1773) + { + pinyin="BIAN"; + break; + } + if(code>=1774 && code<=1777) + { + pinyin="BIAO"; + break; + } + if(code>=1778 && code<=1781) + { + pinyin="BIE"; + break; + } + if(code>=1782 && code<=1787) + { + pinyin="BIN"; + break; + } + if(code>=1788 && code<=1794) + { + pinyin="BING"; + break; + } + if(code>=1801 && code<=1802) + { + pinyin="BING"; + break; + } + if(code>=1803 && code<=1821) + { + pinyin="BO"; + break; + } + if(code>=1822 && code<=1832) + { + pinyin="BU"; + break; + } + if(code==1833) + { + pinyin="CA"; + break; + } + if(code>=1834 && code<=1844) + { + pinyin="CAI"; + break; + } + if(code>=1845 && code<=1851) + { + pinyin="CAN"; + break; + } + if(code>=1852 && code<=1856) + { + pinyin="CANG"; + break; + } + if(code>=1857 && code<=1861) + { + pinyin="CAO"; + break; + } + if(code>=1862 && code<=1866) + { + pinyin="CE"; + break; + } + if(code>=1867 && code<=1868) + { + pinyin="CENG"; + break; + } + if(code>=1869 && code<=1879) + { + pinyin="CHA"; + break; + } + if(code>=1880 && code<=1882) + { + pinyin="CHAI"; + break; + } + if(code>=1883 && code<=1892) + { + pinyin="CHAN"; + break; + } + if(code>=1893 && code<=1911) + { + pinyin="CHANG"; + break; + } + if(code>=1912 && code<=1920) + { + pinyin="CHAO"; + break; + } + if(code>=1921 && code<=1926) + { + pinyin="CHE"; + break; + } + if(code>=1927 && code<=1936) + { + pinyin="CHEN"; + break; + } + if(code>=1937 && code<=1951) + { + pinyin="CHENG"; + break; + } + if(code>=1952 && code<=1967) + { + pinyin="CHI"; + break; + } + if(code>=1968 && code<=1972) + { + pinyin="CHONG"; + break; + } + if(code>=1973 && code<=1984) + { + pinyin="CHOU"; + break; + } + if(code>=1985 && code<=2006) + { + pinyin="CHU"; + break; + } + if(code==2007) + { + pinyin="CHUAI"; + break; + } + if(code>=2008 && code<=2014) + { + pinyin="CHUAN"; + break; + } + if(code>=2015 && code<=2020) + { + pinyin="CHUANG"; + break; + } + if(code>=2021 && code<=2025) + { + pinyin="CHUI"; + break; + } + if(code>=2026 && code<=2032) + { + pinyin="CHUN"; + break; + } + if(code>=2033 && code<=2034) + { + pinyin="CHUO"; + break; + } + if(code>=2035 && code<=2046) + { + pinyin="CI"; + break; + } + if(code>=2047 && code<=2052) + { + pinyin="CONG"; + break; + } + if(code>=2054 && code<=2057) + { + pinyin="CU"; + break; + } + if(code>=2058 && code<=2060) + { + pinyin="CUAN"; + break; + } + if(code>=2061 && code<=2068) + { + pinyin="CUI"; + break; + } + if(code>=2069 && code<=2071) + { + pinyin="CUN"; + break; + } + if(code>=2072 && code<=2077) + { + pinyin="CUO"; + break; + } + if(code>=2078 && code<=2083) + { + pinyin="DA"; + break; + } + if(code>=2084 && code<=2094) + { + pinyin="DAI"; + break; + } + if(code>=2102 && code<=2116) + { + pinyin="DAN"; + break; + } + if(code>=2117 && code<=2121) + { + pinyin="DANG"; + break; + } + if(code>=2122 && code<=2133) + { + pinyin="DAO"; + break; + } + if(code>=2134 && code<=2136) + { + pinyin="DE"; + break; + } + if(code>=2137 && code<=2143) + { + pinyin="DENG"; + break; + } + if(code>=2144 && code<=2162) + { + pinyin="DI"; + break; + } + if(code>=2163 && code<=2178) + { + pinyin="DIAN"; + break; + } + if(code>=2179 && code<=2187) + { + pinyin="DIAO"; + break; + } + if(code>=2188 && code<=2194) + { + pinyin="DIE"; + break; + } + if(code>=2201 && code<=2209) + { + pinyin="DING"; + break; + } + if(code==2210) + { + pinyin="DIU"; + break; + } + if(code>=2211 && code<=2220) + { + pinyin="DONG"; + break; + } + if(code>=2221 && code<=2227) + { + pinyin="DOU"; + break; + } + if(code>=2228 && code<=2242) + { + pinyin="DU"; + break; + } + if(code>=2243 && code<=2248) + { + pinyin="DUAN"; + break; + } + if(code>=2249 && code<=2252) + { + pinyin="DUI"; + break; + } + if(code>=2253 && code<=2261) + { + pinyin="DUN"; + break; + } + if(code>=2262 && code<=2273) + { + pinyin="DUO"; + break; + } + if(code>=2274 && code<=2286) + { + pinyin="E"; + break; + } + if(code==2287) + { + pinyin="EN"; + break; + } + if(code>=2288 && code<=2231) + { + pinyin="ER"; + break; + } + if(code>=2302 && code<=2309) + { + pinyin="FA"; + break; + } + if(code>=2310 && code<=2326) + { + pinyin="FAN"; + break; + } + if(code>=2327 && code<=2337) + { + pinyin="FANG"; + break; + } + if(code>=2338 && code<=2349) + { + pinyin="FEI"; + break; + } + if(code>=2350 && code<=2364) + { + pinyin="FEN"; + break; + } + if(code>=2365 && code<=2379) + { + pinyin="FENG"; + break; + } + if(code==2380) + { + pinyin="FO"; + break; + } + if(code==2381) + { + pinyin="FOU"; + break; + } + if(code>=2382 && code<=2432) + { + pinyin="FU"; + break; + } + if(code>=2435 && code<=2440) + { + pinyin="GAI"; + break; + } + if(code>=2441 && code<=2451) + { + pinyin="GAN"; + break; + } + if(code>=2452 && code<=2460) + { + pinyin="GANG"; + break; + } + if(code>=2461 && code<=2470) + { + pinyin="GAO"; + break; + } + if(code>=2471 && code<=2487) + { + pinyin="GE"; + break; + } + if(code==2488) + { + pinyin="GEI"; + break; + } + if(code>=2489 && code<=2490) + { + pinyin="GEN"; + break; + } + if(code>=2491 && code<=2503) + { + pinyin="GENG"; + break; + } + if(code>=2504 && code<=2518) + { + pinyin="GONG"; + break; + } + if(code>=2519 && code<=2527) + { + pinyin="GOU"; + break; + } + if(code>=2528 && code<=2545) + { + pinyin="GU"; + break; + } + if(code>=2546 && code<=2551) + { + pinyin="GUA"; + break; + } + if(code>=2552 && code<=2554) + { + pinyin="GUAI"; + break; + } + if(code>=2555 && code<=2565) + { + pinyin="GUAN"; + break; + } + if(code>=2566 && code<=2568) + { + pinyin="GUANG"; + break; + } + if(code>=2569 && code<=2584) + { + pinyin="GUI"; + break; + } + if(code>=2585 && code<=2587) + { + pinyin="GUN"; + break; + } + if(code>=2588 && code<=2593) + { + pinyin="GUO"; + break; + } + if(code==2594) + { + pinyin="HA"; + break; + } + if(code>=2601 && code<=2607) + { + pinyin="HAI"; + break; + } + if(code>=2608 && code<=2626) + { + pinyin="HAN"; + break; + } + if(code>=2627 && code<=2629) + { + pinyin="HANG"; + break; + } + if(code>=2630 && code<=2638) + { + pinyin="HAO"; + break; + } + if(code>=2639 && code<=2656) + { + pinyin="HE"; + break; + } + if(code>=2657 && code<=2658) + { + pinyin="HEI"; + break; + } + if(code>=2659 && code<=2662) + { + pinyin="HEN"; + break; + } + if(code>=2663 && code<=2667) + { + pinyin="HENG"; + break; + } + if(code>=2668 && code<=2676) + { + pinyin="HONG"; + break; + } + if(code>=2677 && code<=2683) + { + pinyin="HOU"; + break; + } + if(code>=2684 && code<=2707) + { + pinyin="HU"; + break; + } + if(code>=2708 && code<=2716) + { + pinyin="HUA"; + break; + } + if(code>=2717 && code<=2721) + { + pinyin="HUAI"; + break; + } + if(code>=2722 && code<=2735) + { + pinyin="HUAN"; + break; + } + if(code>=2736 && code<=2749) + { + pinyin="HUANG"; + break; + } + if(code>=2750 && code<=2770) + { + pinyin="HUI"; + break; + } + if(code>=2771 && code<=2776) + { + pinyin="HUN"; + break; + } + if(code>=2777 && code<=2786) + { + pinyin="HUO"; + break; + } + if(code>=2787 && code<=2845) + { + pinyin="JI"; + break; + } + if(code>=2846 && code<=2862) + { + pinyin="JIA"; + break; + } + if(code>=2863 && code<=2908) + { + pinyin="JIAN"; + break; + } + if(code>=2909 && code<=2921) + { + pinyin="JIANG"; + break; + } + if(code>=2922 && code<=2949) + { + pinyin="JIAO"; + break; + } + if(code>=2950 && code<=2976) + { + pinyin="JIE"; + break; + } + if(code>=2977 && code<=3002) + { + pinyin="JIN"; + break; + } + if(code>=3003 && code<=3027) + { + pinyin="JING"; + break; + } + if(code>=3028 && code<=3029) + { + pinyin="JIONG"; + break; + } + if(code>=3030 && code<=3046) + { + pinyin="JIU"; + break; + } + if(code>=3047 && code<=3071) + { + pinyin="JU"; + break; + } + if(code>=3072 && code<=3078) + { + pinyin="JUAN"; + break; + } + if(code>=3079 && code<=3088) + { + pinyin="JUE"; + break; + } + if(code>=3089 && code<=3105) + { + pinyin="JUN"; + break; + } + if(code>=3106 && code<=3109) + { + pinyin="KA"; + break; + } + if(code>=3110 && code<=3114) + { + pinyin="KAI"; + break; + } + if(code>=3115 && code<=3120) + { + pinyin="KAN"; + break; + } + if(code>=3121 && code<=3127) + { + pinyin="KANG"; + break; + } + if(code>=3128 && code<=3131) + { + pinyin="KAO"; + break; + } + if(code>=3132 && code<=3146) + { + pinyin="KE"; + break; + } + if(code>=3147 && code<=3150) + { + pinyin="KEN"; + break; + } + if(code>=3151 && code<=3152) + { + pinyin="KENG"; + break; + } + if(code>=3153 && code<=3156) + { + pinyin="KONG"; + break; + } + if(code>=3157 && code<=3160) + { + pinyin="KOU"; + break; + } + if(code>=3161 && code<=3167) + { + pinyin="KU"; + break; + } + if(code>=3168 && code<=3172) + { + pinyin="KUA"; + break; + } + if(code>=3173 && code<=3176) + { + pinyin="KUAI"; + break; + } + if(code>=3177 && code<=3178) + { + pinyin="KUAN"; + break; + } + if(code>=3179 && code<=3186) + { + pinyin="KUANG"; + break; + } + if(code>=3187 && code<=3203) + { + pinyin="KUI"; + break; + } + if(code>=3204 && code<=3207) + { + pinyin="KUN"; + break; + } + if(code>=3208 && code<=3211) + { + pinyin="KUO"; + break; + } + if(code>=3212 && code<=3218) + { + pinyin="LA"; + break; + } + if(code>=3219 && code<=3221) + { + pinyin="LAI"; + break; + } + if(code>=3222 && code<=3236) + { + pinyin="LAN"; + break; + } + if(code>=3237 && code<=3243) + { + pinyin="LANG"; + break; + } + if(code>=3244 && code<=3252) + { + pinyin="LAO"; + break; + } + if(code>=3253 && code<=3254) + { + pinyin="LE"; + break; + } + if(code>=3255 && code<=3265) + { + pinyin="LEI"; + break; + } + if(code>=3266 && code<=3268) + { + pinyin="LENG"; + break; + } + if(code>=3269 && code<=3308) + { + pinyin="LI"; + } + if(code==3309) + { + pinyin="LIA"; + break; + } + if(code>=3310 && code<=3323) + { + pinyin="LIAN"; + break; + } + if(code>=3324 && code<=3334) + { + pinyin="LIANG"; + break; + } + if(code>=3335 && code<=3347) + { + pinyin="LIAO"; + break; + } + if(code>=3348 && code<=3352) + { + pinyin="LIE"; + break; + } + if(code>=3353 && code<=3363) + { + pinyin="LIN"; + break; + } + if(code>=3364 && code<=3378) + { + pinyin="LING"; + break; + } + if(code>=3379 && code<=3389) + { + pinyin="LIU"; + break; + } + if(code>=3390 && code<=3404) + { + pinyin="LONG"; + break; + } + if(code>=3405 && code<=3410) + { + pinyin="LOU"; + break; + } + if(code>=3411 && code<=3444) + { + pinyin="LU"; + break; + } + if(code>=3445 && code<=3450) + { + pinyin="LUAN"; + break; + } + if(code>=3451 && code<=3452) + { + pinyin="LUE"; + break; + } + if(code>=3453 && code<=3459) + { + pinyin="LUN"; + break; + } + if(code>=3460 && code<=3471) + { + pinyin="LUO"; + break; + } + if(code>=3472 && code<=3480) + { + pinyin="MA"; + break; + } + if(code>=3481 && code<=3486) + { + pinyin="MAI"; + break; + } + if(code>=3487 && code<=3501) + { + pinyin="MAN"; + break; + } + if(code>=3502 && code<=3507) + { + pinyin="MANG"; + break; + } + if(code>=3508 && code<=3519) + { + pinyin="MAO"; + break; + } + if(code==3520) + { + pinyin="ME"; + break; + } + if(code>=3521 && code<=3536) + { + pinyin="MEI"; + break; + } + if(code>=3537 && code<=3539) + { + pinyin="MEN"; + break; + } + if(code>=3540 && code<=3547) + { + pinyin="MENG"; + break; + } + if(code>=3548 && code<=3561) + { + pinyin="MI"; + } + if(code>=3562 && code<=3570) + { + pinyin="MIAN"; + break; + } + if(code>=3571 && code<=3578) + { + pinyin="MIAO"; + break; + } + if(code>=3579 && code<=3580) + { + pinyin="MIE"; + break; + } + if(code>=3581 && code<=3586) + { + pinyin="MIN"; + break; + } + if(code>=3587 && code<=3592) + { + pinyin="MING"; + break; + } + if(code==3593) + { + pinyin="MIU"; + break; + } + if(code>=3594 && code<=3616) + { + pinyin="MO"; + break; + } + if(code>=3617 && code<=3619) + { + pinyin="MOU"; + break; + } + if(code>=3620 && code<=3634) + { + pinyin="MU"; + break; + } + if(code>=3635 && code<=3641) + { + pinyin="NA"; + break; + } + if(code>=3642 && code<=3646) + { + pinyin="NAI"; + break; + } + if(code>=3647 && code<=3649) + { + pinyin="NAN"; + break; + } + if(code==3650) + { + pinyin="NANG"; + break; + } + if(code>=3651 && code<=3655) + { + pinyin="NAO"; + break; + } + if(code==3656) + { + pinyin="NE"; + break; + } + if(code>=3657 && code<=3658) + { + pinyin="NEI"; + break; + } + if(code==3659) + { + pinyin="NEN"; + break; + } + if(code==3660) + { + pinyin="NENG"; + break; + } + if(code>=3661 && code<=3671) + { + pinyin="NI"; + break; + } + if(code>=3672 && code<=3678) + { + pinyin="NIAN"; + break; + } + if(code>=3679 && code<=3680) + { + pinyin="NIANG"; + break; + } + if(code>=3681 && code<=3682) + { + pinyin="NIAO"; + break; + } + if(code>=3683 && code<=3689) + { + pinyin="NIE"; + break; + } + if(code==3690) + { + pinyin="NIN"; + break; + } + if(code>=3691 && code<=3702) + { + pinyin="NING"; + break; + } + if(code>=3703 && code<=3706) + { + pinyin="NIU"; + break; + } + if(code>=3707 && code<=3710) + { + pinyin="NONG"; + break; + } + if(code>=3711 && code<=3714) + { + pinyin="NU"; + break; + } + if(code==3715) + { + pinyin="NUAN"; + break; + } + if(code>=3716 && code<=3717) + { + pinyin="NUE"; + break; + } + if(code>=3718 && code<=3721) + { + pinyin="NUO"; + break; + } + if(code==3722) + { + pinyin="O"; + break; + } + if(code>=3723 && code<=3729) + { + pinyin="OU"; + break; + } + if(code>=3730 && code<=3735) + { + pinyin="PA"; + break; + } + if(code>=3736 && code<=3741) + { + pinyin="PAI"; + break; + } + if(code>=3742 && code<=3749) + { + pinyin="PAN"; + break; + } + if(code>=3750 && code<=3754) + { + pinyin="PANG"; + break; + } + if(code>=3755 && code<=3761) + { + pinyin="PAO"; + break; + } + if(code>=3762 && code<=3770) + { + pinyin="PEI"; + break; + } + if(code>=3771 && code<=3772) + { + pinyin="PEN"; + break; + } + if(code>=3773 && code<=3786) + { + pinyin="PENG"; + break; + } + if(code>=3787 && code<=3809) + { + pinyin="PI"; + break; + } + if(code>=3810 && code<=3813) + { + pinyin="PIAN"; + break; + } + if(code>=3814 && code<=3817) + { + pinyin="PIAO"; + break; + } + if(code>=3818 && code<=3819) + { + pinyin="PIE"; + break; + } + if(code>=3820 && code<=3824) + { + pinyin="PIN"; + break; + } + if(code>=3825 && code<=3833) + { + pinyin="PING"; + break; + } + if(code>=3834 && code<=3841) + { + pinyin="PO"; + break; + } + if(code==3842) + { + pinyin="POU"; + break; + } + if(code>=3843 && code<=3857) + { + pinyin="PU"; + break; + } + if(code>=3858 && code<=3893) + { + pinyin="QI"; + break; + } + if(code==3894 || (code>=3901 && code<=3902)) + { + pinyin="QIA"; + break; + } + if(code>=3903 && code<=3924) + { + pinyin="QIAN"; + break; + } + if(code>=3925 && code<=3932) + { + pinyin="QIANG"; + break; + } + if(code>=3933 && code<=3947) + { + pinyin="QIAO"; + break; + } + if(code>=3948 && code<=3952) + { + pinyin="QIE"; + break; + } + if(code>=3953 && code<=3963) + { + pinyin="QIN"; + break; + } + if(code>=3964 && code<=3976) + { + pinyin="QING"; + break; + } + if(code>=3977 && code<=3978) + { + pinyin="QIONG"; + break; + } + if(code>=3979 && code<=3986) + { + pinyin="QIU"; + break; + } + if(code>=3987 && code<=4005) + { + pinyin="QU"; + break; + } + if(code>=4006 && code<=4016) + { + pinyin="QUAN"; + break; + } + if(code>=4017 && code<=4024) + { + pinyin="QUE"; + break; + } + if(code>=4025 && code<=4026) + { + pinyin="QUN"; + break; + } + if(code>=4027 && code<=4030) + { + pinyin="RAN"; + break; + } + if(code>=4031 && code<=4035) + { + pinyin="RANG"; + } + if(code>=4036 && code<=4038) + { + pinyin="RAO"; + break; + } + if(code>=4039 && code<=4040) + { + pinyin="RE"; + break; + } + if(code>=4041 && code<=4050) + { + pinyin="REN"; + break; + } + if(code>=4051 && code<=4052) + { + pinyin="RENG"; + break; + } + if(code==4053) + { + pinyin="RI"; + break; + } + if(code>=4054 && code<=4063) + { + pinyin="RONG"; + break; + } + if(code>=4064 && code<=4066) + { + pinyin="ROU"; + break; + } + if(code>=4067 && code<=4076) + { + pinyin="RU"; + break; + } + if(code>=4077 && code<=4078) + { + pinyin="RUAN"; + break; + } + if(code>=4079 && code<=4081) + { + pinyin="RUI"; + break; + } + if(code>=4082 && code<=4083) + { + pinyin="RUN"; + break; + } + if(code>=4084 && code<=4085) + { + pinyin="RUO"; + break; + } + if(code>=4086 && code<=4088) + { + pinyin="SA"; + break; + } + if(code>=4089 && code<=4092) + { + pinyin="SAI"; + break; + } + if(code>=4093 && code<=4094) + { + pinyin="SAN"; + break; + } + if(code>=4101 && code<=4102) + { + pinyin="SAN"; + break; + } + if(code>=4103 && code<=4105) + { + pinyin="SANG"; + break; + } + if(code>=4106 && code<=4109) + { + pinyin="SAO"; + break; + } + if(code>=4110 && code<=4112) + { + pinyin="SE"; + break; + } + if(code==4113) + { + pinyin="SEN"; + } + if(code==4114) + { + pinyin="SENG"; + break; + } + if(code>=4115 && code<=4123) + { + pinyin="SHA"; + break; + } + if(code>=4124 && code<=4125) + { + pinyin="SHAI"; + break; + } + if(code>=4126 && code<=4141) + { + pinyin="SHAN"; + break; + } + if(code>=4142 && code<=4149) + { + pinyin="SHANG"; + break; + } + if(code>=4150 && code<=4160) + { + pinyin="SHAO"; + break; + } + if(code>=4161 && code<=4172) + { + pinyin="SHE"; + break; + } + if(code>=4173 && code<=4188) + { + pinyin="SHEN"; + break; + } + if(code>=4189 && code<=4205) + { + pinyin="SHENG"; + break; + } + if(code>=4206 && code<=4252) + { + pinyin="SHI"; + break; + } + if(code>=4253 && code<=4262) + { + pinyin="SHOU"; + break; + } + if(code>=4263 && code<=4301) + { + pinyin="SHU"; + break; + } + if(code>=4302 && code<=4303) + { + pinyin="SHUA"; + break; + } + if(code>=4304 && code<=4307) + { + pinyin="SHUAI"; + break; + } + if(code>=4308 && code<=4309) + { + pinyin="SHUAN"; + break; + } + if(code>=4310 && code<=4312) + { + pinyin="SHUANG"; + break; + } + if(code>=4313 && code<=4316) + { + pinyin="SHUI"; + break; + } + if(code>=4317 && code<=4320) + { + pinyin="SHUN"; + break; + } + if(code>=4321 && code<=4324) + { + pinyin="SHUO"; + break; + } + if(code>=4325 && code<=4340) + { + pinyin="SI"; + break; + } + if(code>=4341 && code<=4348) + { + pinyin="SONG"; + break; + } + if(code>=4349 && code<=4352) + { + pinyin="SOU"; + break; + } + if(code>=4353 && code<=4364) + { + pinyin="SU"; + break; + } + if(code>=4365 && code<=4367) + { + pinyin="SUAN"; + break; + } + if(code>=4368 && code<=4378) + { + pinyin="SUI"; + break; + } + if(code>=4379 && code<=4381) + { + pinyin="SUN"; + break; + } + if(code>=4382 && code<=4389) + { + pinyin="SUO"; + break; + } + if(code>=4390 && code<=4404) + { + pinyin="TA"; + break; + } + if(code>=4405 && code<=4413) + { + pinyin="TAI"; + break; + } + if(code>=4414 && code<=4431) + { + pinyin="TAN"; + break; + } + if(code>=4432 && code<=4444) + { + pinyin="TANG"; + break; + } + if(code>=4445 && code<=4455) + { + pinyin="TAO"; + break; + } + if(code==4456) + { + pinyin="TE"; + break; + } + if(code>=4457 && code<=4460) + { + pinyin="TENG"; + break; + } + if(code>=4461 && code<=4475) + { + pinyin="TI"; + break; + } + if(code>=4476 && code<=4483) + { + pinyin="TIAN"; + break; + } + if(code>=4484 && code<=4488) + { + pinyin="TIAO"; + break; + } + if(code>=4489 && code<=4491) + { + pinyin="TIE"; + break; + } + if(code>=4492 && code<=4507) + { + pinyin="TING"; + break; + } + if(code>=4508 && code<=4520) + { + pinyin="TONG"; + break; + } + if(code>=4521 && code<=4524) + { + pinyin="TOU"; + break; + } + if(code>=4525 && code<=4535) + { + pinyin="TU"; + break; + } + if(code>=4536 && code<=4537) + { + pinyin="TUAN"; + break; + } + if(code>=4538 && code<=4543) + { + pinyin="TUI"; + break; + } + if(code>=4544 && code<=4546) + { + pinyin="TUN"; + break; + } + if(code>=4547 && code<=4557) + { + pinyin="TUO"; + break; + } + if(code>=4558 && code<=4564) + { + pinyin="WA"; + break; + } + if(code>=4565 && code<=4566) + { + pinyin="WAI"; + break; + } + if(code>=4567 && code<=4583) + { + pinyin="WAN"; + break; + } + if(code>=4584 && code<=4593) + { + pinyin="WANG"; + break; + } + if(code>=4594 && code<=4632) + { + pinyin="WEI"; + break; + } + if(code>=4633 && code<=4642) + { + pinyin="WEN"; + break; + } + if(code>=4643 && code<=4645) + { + pinyin="WENG"; + break; + } + if(code>=4646 && code<=4654) + { + pinyin="WO"; + break; + } + if(code>=4655 && code<=4683) + { + pinyin="WU"; + break; + } + if(code>=4684 && code<=4724) + { + pinyin="XI"; + break; + } + if(code>=4725 && code<=4737) + { + pinyin="XIA"; + break; + } + if(code>=4738 && code<=4763) + { + pinyin="XIAN"; + break; + } + if(code>=4764 && code<=4783) + { + pinyin="XIANG"; + break; + } + if(code>=4784 && code<=4807) + { + pinyin="XIAO"; + break; + } + if(code>=4809 && code<=4828) + { + pinyin="XIE"; + break; + } + if(code>=4829 && code<=4838) + { + pinyin="XIN"; + break; + } + if(code>=4839 && code<=4853) + { + pinyin="XING"; + break; + } + if(code>=4854 && code<=4860) + { + pinyin="XIONG"; + break; + } + if(code>=4861 && code<=4869) + { + pinyin="XIU"; + break; + } + if(code>=4870 && code<=4888) + { + pinyin="XU"; + break; + } + if(code>=4889 && code<=4904) + { + pinyin="XUAN"; + break; + } + if(code>=4905 && code<=4910) + { + pinyin="XUE"; + break; + } + if(code>=4911 && code<=4924) + { + pinyin="XUN"; + break; + } + if(code>=4925 && code<=4940) + { + pinyin="YA"; + break; + } + if(code>=4941 && code<=4973) + { + pinyin="YAN"; + break; + } + if(code>=4974 && code<=4990) + { + pinyin="YANG"; + break; + } + if(code>=4991 && code<=5011) + { + pinyin="YAO"; + break; + } + if(code>=5012 && code<=5026) + { + pinyin="YE"; + break; + } + if(code>=5027 && code<=5079) + { + pinyin="YI"; + break; + } + if(code>=5080 && code<=5101) + { + pinyin="YIN"; + break; + } + if(code>=5102 && code<=5119) + { + pinyin="YING"; + break; + } + if(code==5120) + { + pinyin="YO"; + break; + } + if(code>=5121 && code<=5135) + { + pinyin="YONG"; + break; + } + if(code>=5136 && code<=5155) + { + pinyin="YOU"; + break; + } + if(code>=5156 && code<=5206) + { + pinyin="YU"; + break; + } + if(code>=5207 && code<=5226) + { + pinyin="YUAN"; + break; + } + if(code>=5227 && code<=5236) + { + pinyin="YUE"; + break; + } + if(code>=5237 && code<=5248) + { + pinyin="YUN"; + break; + } + if(code>=5249 && code<=5251) + { + pinyin="ZA"; + break; + } + if(code>=5252 && code<=5258) + { + pinyin="ZAI"; + break; + } + if(code>=5259 && code<=5262) + { + pinyin="ZAN"; + break; + } + if(code>=5263 && code<=5265) + { + pinyin="ZANG"; + break; + } + if(code>=5266 && code<=5279) + { + pinyin="ZAO"; + break; + } + if(code>=5280 && code<=5283) + { + pinyin="ZE"; + break; + } + if(code==5284) + { + pinyin="ZEI"; + break; + } + if(code==5285) + { + pinyin="ZEN"; + break; + } + if(code>=5286 && code<=5289) + { + pinyin="ZENG"; + break; + } + if(code>=5290 && code<=5309) + { + pinyin="ZHA"; + break; + } + if(code>=5310 && code<=5315) + { + pinyin="ZHAI"; + break; + } + if(code>=5316 && code<=5332) + { + pinyin="ZHAN"; + break; + } + if(code>=5333 && code<=5347) + { + pinyin="ZHANG"; + break; + } + if(code>=5348 && code<=5357) + { + pinyin="ZHAO"; + break; + } + if(code>=5358 && code<=5367) + { + pinyin="ZHE"; + break; + } + if(code>=5368 && code<=5383) + { + pinyin="ZHEN"; + break; + } + if(code>=5384 && code<=5404) + { + pinyin="ZHENG"; + break; + } + if(code>=5405 && code<=5447) + { + pinyin="ZHI"; + break; + } + if(code>=5448 && code<=5458) + { + pinyin="ZHONG"; + break; + } + if(code>=5459 && code<=5472) + { + pinyin="ZHOU"; + break; + } + if(code>=5473 && code<=5504) + { + pinyin="ZHU"; + break; + } + if(code>=5505 && code<=5506) + { + pinyin="ZHUA"; + break; + } + if(code==5507) + { + pinyin="ZHUAI"; + break; + } + if(code>=5508 && code<=5513) + { + pinyin="ZHUAN"; + break; + } + if(code>=5514 && code<=5520) + { + pinyin="ZHUANG"; + break; + } + if(code>=5521 && code<=5526) + { + pinyin="ZHUI"; + break; + } + if(code>=5527 && code<=5528) + { + pinyin="ZHUN"; + break; + } + if(code>=5529 && code<=5539) + { + pinyin="ZHUO"; + break; + } + if(code>=5540 && code<=5554) + { + pinyin="ZI"; + break; + } + if(code>=5555 && code<=5561) + { + pinyin="ZONG"; + break; + } + if(code>=5562 && code<=5565) + { + pinyin="ZOU"; + break; + } + if(code>=5566 && code<=5573) + { + pinyin="ZU"; + break; + } + if(code>=5574 && code<=5575) + { + pinyin="ZUAN"; + break; + } + if(code>=5576 && code<=5579) + { + pinyin="ZUI"; + break; + } + if(code>=5580 && code<=5581) + { + pinyin="ZUN"; + break; + } + if(code>=5582 && code<=5589) + { + pinyin="ZUO"; + break; + } + } + if (pinyin.isEmpty()) + { + pinyin=""; + } + return pinyin; +} + diff --git a/src/BackProcess/Interface/ukui_chineseletter.h b/src/Interface/ukuichineseletter.h similarity index 96% rename from src/BackProcess/Interface/ukui_chineseletter.h rename to src/Interface/ukuichineseletter.h index c1da729..749025c 100644 --- a/src/BackProcess/Interface/ukui_chineseletter.h +++ b/src/Interface/ukuichineseletter.h @@ -41,7 +41,7 @@ public: static QString getPinyin(int code); // 获取所有汉字的汉语拼音 - static QString getPinyins(const QString &text); + static QString getPinyins(const QString& text); }; #endif // UKUICHINESELETTER_H diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp new file mode 100644 index 0000000..3350aaa --- /dev/null +++ b/src/Interface/ukuimenuinterface.cpp @@ -0,0 +1,1045 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include "ukuichineseletter.h" +#include "src/UtilityFunction/utility.h" + +UkuiMenuInterface::UkuiMenuInterface() +{ +} + +QVector UkuiMenuInterface::m_appInfoVector = QVector(); +QVector UkuiMenuInterface::m_desktopfpVector = QVector(); +QVector UkuiMenuInterface::m_alphabeticVector = QVector(); +QVector UkuiMenuInterface::m_functionalVector = QVector(); +QVector UkuiMenuInterface::m_allAppVector = QVector(); +QStringList UkuiMenuInterface::m_androidDesktopfnList = QStringList(); + +UkuiMenuInterface::~UkuiMenuInterface() +{ +} + +QStringList UkuiMenuInterface::getFunctionClassName() +{ + QStringList functionList; + functionList.append(QObject::tr("Office")); + functionList.append(QObject::tr("Development")); + functionList.append(QObject::tr("Image")); + functionList.append(QObject::tr("Video")); + functionList.append(QObject::tr("Internet")); + functionList.append(QObject::tr("Game")); + functionList.append(QObject::tr("Education")); + functionList.append(QObject::tr("Social")); + functionList.append(QObject::tr("System")); + functionList.append(QObject::tr("Safe")); + functionList.append(QObject::tr("Others")); + return functionList; +} +//文件递归查询 +void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) +{ + QDir dir(_filePath); + + if (!dir.exists()) { + return; + } + + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + dir.setSorting(QDir::DirsFirst); + QFileInfoList list = dir.entryInfoList(); + list.removeAll(QFileInfo("/usr/share/applications/screensavers")); + + if (list.size() < 1) { + return; + } + + int i = 0; + + //递归算法的核心部分 + do { + QFileInfo fileInfo = list.at(i); + //如果是文件夹,递归 + bool isDir = fileInfo.isDir(); + + if (isDir) { + recursiveSearchFile(fileInfo.filePath()); + } else { + //过滤后缀不是.desktop的文件 + QString filePathStr = fileInfo.filePath(); + + if (!filePathStr.endsWith(".desktop")) { + i++; + continue; + } + + QByteArray fpbyte = filePathStr.toLocal8Bit(); + char *filepath = fpbyte.data(); + + if (0 != access(filepath, R_OK)) { //判断文件是否可读 + i++; + continue; + } + + m_keyfile = g_key_file_new(); + + if (!g_key_file_load_from_file(m_keyfile, filepath, m_flags, m_error)) { + return; + } + + char *ret_0 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "Categories", nullptr, nullptr); + + if (ret_0 != nullptr) { + QString str = QString::fromLocal8Bit(ret_0); + + if (str.contains("Android")) { + g_key_file_free(m_keyfile); + i++; + continue; + } + } + + char *ret_1 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); + + if (ret_1 != nullptr) { + QString str = QString::fromLocal8Bit(ret_1); + + if (str.contains("true")) { + g_key_file_free(m_keyfile); + i++; + continue; + } + } + + char *ret_2 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); + + if (ret_2 != nullptr) { + QString str = QString::fromLocal8Bit(ret_2); + + if (str.contains("UKUI")) { + g_key_file_free(m_keyfile); + i++; + continue; + } + } + + //过滤LXQt、KDE + char *ret = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); + + if (ret != nullptr) { + QString str = QString::fromLocal8Bit(ret); + + if (str.contains("LXQt") || str.contains("KDE")) { + g_key_file_free(m_keyfile); + i++; + continue; + } + } + + g_key_file_free(m_keyfile); + m_filePathList.append(filePathStr); + } + + i++; + } while (i < list.size()); +} + +//获取系统desktop文件路径 +QStringList UkuiMenuInterface::getDesktopFilePath() +{ + m_filePathList.clear(); + QString jsonPath = QDir::homePath() + "/.config/ukui-menu-security-config.json"; + QFile file(jsonPath); + + if (file.exists()) { + file.open(QIODevice::ReadOnly); + QByteArray readBy = file.readAll(); + QJsonParseError error; + QJsonDocument readDoc = QJsonDocument::fromJson(readBy, &error); + + if (!readDoc.isNull() && error.error == QJsonParseError::NoError) { + QJsonObject obj = readDoc.object().value("ukui-menu").toObject(); + + if (obj.value("mode").toString() == "whitelist") { + QJsonArray blArray = obj.value("whitelist").toArray(); + QJsonArray enArray = blArray.at(0).toObject().value("entries").toArray(); + + for (int index = 0; index < enArray.size(); index++) { + QJsonObject obj = enArray.at(index).toObject(); + m_filePathList.append(obj.value("path").toString()); +// qDebug()< UkuiMenuInterface::createSoftwareAppInfoVector() +{ + m_desktopfpVector.clear(); + QVector appInfoVector; + QVector vector; + vector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公 + vector.append(QStringList() << "develop" << "Development"); //1开发 + vector.append(QStringList() << "graphic" << "Graphics"); //2图像 + vector.append(QStringList() << "video" << "Audio" << "Video"); //3影音 + vector.append(QStringList() << "network" << "Network"); //4网络 + vector.append(QStringList() << "game" << "Game"); //5游戏 + vector.append(QStringList() << "education" << "Education"); //6教育 + vector.append(QStringList() << "social" << "Messaging"); //7社交 + vector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统 + vector.append(QStringList() << "safe"); //9安全 + vector.append(QStringList() << "others"); //10其他 + QStringList desktopfpList = getDesktopFilePath(); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlQuery sql(db); + + for (int i = 0; i < desktopfpList.count(); i++) { + QStringList appInfoList; + QString desktopfp = desktopfpList.at(i); + QString name = getAppName(desktopfpList.at(i)); + + if (!name.isEmpty()) { + QString englishName = getAppEnglishName(desktopfpList.at(i)); + QString letter = getAppNameInitial(desktopfpList.at(i)); + QString letters = getAppNameInitials(desktopfpList.at(i)); + m_desktopfpVector.append(desktopfp); + appInfoList << desktopfp << name << englishName << letter << letters; + QString desktopfpExecName = getAppExec(desktopfpList.at(i)); + desktopfpExecName = desktopfpExecName.mid(desktopfpExecName.lastIndexOf("/") + 1); + desktopfpExecName = desktopfpExecName.left(desktopfpExecName.lastIndexOf(" ")); + sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName)); + + if (sql.next()) { + myDebug() << "数据库执行成功"; + + for (int j = 0; j < vector.size(); j++) { + if (vector.at(j).contains(sql.value(0).toString())) { + appInfoList.append(QString::number(j)); + } + } + } else { + myDebug() << "数据库执行失败"; + bool is_owned = false; + + for (int j = 0; j < vector.size(); j++) { + //有对应分类 + if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { + is_owned = true; + appInfoList.append(QString::number(j)); + break; + } + } + + if (!is_owned) { //该应用无对应分类 + appInfoList.append(QString::number(10)); + } + } + + appInfoVector.append(appInfoList); + } + } + + return appInfoVector; +} + +//获取应用名称 +QString UkuiMenuInterface::getAppName(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Name", nullptr, nullptr); + QString namestr = QString::fromLocal8Bit(name); + g_key_file_free(keyfile); + return namestr; +} + +//获取英应用英文名 +QString UkuiMenuInterface::getAppEnglishName(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); + g_key_file_free(keyfile); + QString namestr = QString::fromLocal8Bit(name); + return namestr; +} + +//获取应用分类 +QString UkuiMenuInterface::getAppCategories(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *category = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(category); +} + +//获取应用图标 +QString UkuiMenuInterface::getAppIcon(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *icon = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Icon", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(icon); +} + +//获取应用命令 +QString UkuiMenuInterface::getAppExec(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *exec = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(exec); +} + +//获取应用注释 +QString UkuiMenuInterface::getAppComment(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *comment = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Comment", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(comment); +} + +//获取应用类型 +QString UkuiMenuInterface::getAppType(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *type = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Type", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(type); +} + +bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2) +{ + QLocale local; + QString language = local.languageToString(local.language()); + + if (QString::compare(language, "Chinese") == 0) { + local = QLocale(QLocale::Chinese); + } else { + local = QLocale(QLocale::English); + } + + QCollator collator(local); + + if (collator.compare(arg_1.at(1), arg_2.at(1)) < 0) { + return true; + } else { + return false; + } +} + +bool UkuiMenuInterface::cmpfixedApp(QStringList &arg_1, QStringList &arg_2) +{ + QLocale local; + QString language = local.languageToString(local.language()); + + if (QString::compare(language, "Chinese") == 0) { + local = QLocale(QLocale::Chinese); + } else { + local = QLocale(QLocale::English); + } + + QCollator collator(local); + + //数组中分别存放desktop、中文名称、英文名称、首字母、全拼 首字母,按首字母排列,对下标3进行比较 + if (collator.compare(arg_1.at(3), arg_2.at(3)) < 0) { + return true; + } else { + return false; + } +} + +QVector UkuiMenuInterface::getAllClassification() +{ + QVector allAppVector; + QVector commonVector; + QVector appVector; + allAppVector.clear(); + commonVector.clear(); + appVector.clear(); + commonVector = getCommonUseApp(); + int index = 0; + + Q_FOREACH (QString desktopfp, m_desktopfpVector) { + if (!commonVector.contains(desktopfp)) { + appVector.append(m_appInfoVector.at(index)); + } + + index++; + } + + qSort(appVector.begin(), appVector.end(), cmpApp); + + Q_FOREACH (QString desktopfp, commonVector) { + allAppVector.append(desktopfp); + } + + for (int index = 0; index < appVector.size(); index++) { + allAppVector.append(appVector.at(index).at(0)); + } + + return allAppVector; +} + +QVector UkuiMenuInterface::getCommonUseApp() +{ + QVector data; + QStringList lockAppListSort; + QStringList lockAppListFp; + QVector lockAppVector; + int index = 0; + + Q_FOREACH (QString desktopfn, getLockAppList()) { + QString desktopfp; + + if (m_androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + lockAppListFp.append(desktopfp); + } + + Q_FOREACH (QString desktopfp, m_desktopfpVector) { + if (lockAppListFp.contains(desktopfp)) { + lockAppVector.append(m_appInfoVector.at(index)); + } + + index++; + } + + qSort(lockAppVector.begin(), lockAppVector.end(), cmpfixedApp); + + for (int index = 0; index < lockAppVector.size(); index++) { + lockAppListSort.append(lockAppVector.at(index).at(0)); + } + + Q_FOREACH (QString desktopfp, lockAppListSort) { + data.append(desktopfp); + } + + Q_FOREACH (QString desktopfn, getUnlockAllList()) { + QString desktopfp; + + if (m_androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + QFileInfo fileInfo(desktopfp); + + if (!fileInfo.isFile() || !m_desktopfpVector.contains(desktopfp)) { + continue; + } + + data.append(desktopfp); + } + + return data; +} + +QVector UkuiMenuInterface::getAlphabeticClassification() +{ + QVector data; + QStringList appnameList; + appnameList.clear(); + QVector appVector[27]; + int index = 0; + + while (index < m_appInfoVector.size()) { + QString appname = m_appInfoVector.at(index).at(1); + QString appnamepy = UkuiChineseLetter::getPinyins(appname); + + if (!appnamepy.isEmpty()) { + char c = appnamepy.at(0).toLatin1(); + + switch (c) { + case 'A': + appVector[0].append(m_appInfoVector.at(index)); + break; + + case 'B': + appVector[1].append(m_appInfoVector.at(index)); + break; + + case 'C': + appVector[2].append(m_appInfoVector.at(index)); + break; + + case 'D': + appVector[3].append(m_appInfoVector.at(index)); + break; + + case 'E': + appVector[4].append(m_appInfoVector.at(index)); + break; + + case 'F': + appVector[5].append(m_appInfoVector.at(index)); + break; + + case 'G': + appVector[6].append(m_appInfoVector.at(index)); + break; + + case 'H': + appVector[7].append(m_appInfoVector.at(index)); + break; + + case 'I': + appVector[8].append(m_appInfoVector.at(index)); + break; + + case 'J': + appVector[9].append(m_appInfoVector.at(index)); + break; + + case 'K': + appVector[10].append(m_appInfoVector.at(index)); + break; + + case 'L': + appVector[11].append(m_appInfoVector.at(index)); + break; + + case 'M': + appVector[12].append(m_appInfoVector.at(index)); + break; + + case 'N': + appVector[13].append(m_appInfoVector.at(index)); + break; + + case 'O': + appVector[14].append(m_appInfoVector.at(index)); + break; + + case 'P': + appVector[15].append(m_appInfoVector.at(index)); + break; + + case 'Q': + appVector[16].append(m_appInfoVector.at(index)); + break; + + case 'R': + appVector[17].append(m_appInfoVector.at(index)); + break; + + case 'S': + appVector[18].append(m_appInfoVector.at(index)); + break; + + case 'T': + appVector[19].append(m_appInfoVector.at(index)); + break; + + case 'U': + appVector[20].append(m_appInfoVector.at(index)); + break; + + case 'V': + appVector[21].append(m_appInfoVector.at(index)); + break; + + case 'W': + appVector[22].append(m_appInfoVector.at(index)); + break; + + case 'X': + appVector[23].append(m_appInfoVector.at(index)); + break; + + case 'Y': + appVector[24].append(m_appInfoVector.at(index)); + break; + + case 'Z': + appVector[25].append(m_appInfoVector.at(index)); + break; + + default: + appVector[26].append(m_appInfoVector.at(index)); + break; + } + } + + index++; + } + + for (int i = 0; i < 26; i++) { + QStringList desktopfpList; + desktopfpList.clear(); + qSort(appVector[i].begin(), appVector[i].end(), cmpApp); + + for (int j = 0; j < appVector[i].size(); j++) { + desktopfpList.append(appVector[i].at(j).at(0)); + } + + data.append(desktopfpList); + } + + QVector otherVector; + QVector numberVector; + + for (int i = 0; i < appVector[26].count(); i++) { + QString appname = appVector[26].at(i).at(2); + QChar c = appname.at(0); + + if (c < 48 || (c > 57 && c < 65) || c > 90) { + otherVector.append(appVector[26].at(i)); + } else { + numberVector.append(appVector[26].at(i)); + } + } + + qSort(otherVector.begin(), otherVector.end(), cmpApp); + qSort(numberVector.begin(), numberVector.end(), cmpApp); + QStringList otherfpList; + otherfpList.clear(); + + for (int i = 0; i < otherVector.size(); i++) { + otherfpList.append(otherVector.at(i).at(0)); + } + + QStringList numberfpList; + numberfpList.clear(); + + for (int i = 0; i < numberVector.size(); i++) { + numberfpList.append(numberVector.at(i).at(0)); + } + + data.append(otherfpList); + data.append(numberfpList); + return data; +} + +QVector UkuiMenuInterface::getFunctionalClassification() +{ + QVector appVector[11]; + int index = 0; + + while (index < m_appInfoVector.size()) { + int count = m_appInfoVector.at(index).size() - 5; + + for (int i = 0; i < count; i++) { + int category = m_appInfoVector.at(index).at(5 + i).toInt(); + + switch (category) { + case 0: + appVector[0].append(m_appInfoVector.at(index)); + break; + + case 1: + appVector[1].append(m_appInfoVector.at(index)); + break; + + case 2: + appVector[2].append(m_appInfoVector.at(index)); + break; + + case 3: + appVector[3].append(m_appInfoVector.at(index)); + break; + + case 4: + appVector[4].append(m_appInfoVector.at(index)); + break; + + case 5: + appVector[5].append(m_appInfoVector.at(index)); + break; + + case 6: + appVector[6].append(m_appInfoVector.at(index)); + break; + + case 7: + appVector[7].append(m_appInfoVector.at(index)); + break; + + case 8: + appVector[8].append(m_appInfoVector.at(index)); + break; + + case 9: + appVector[9].append(m_appInfoVector.at(index)); + break; + + case 10: + appVector[10].append(m_appInfoVector.at(index)); + break; + + default: + break; + } + } + + index++; + } + + QVector data; + data.clear(); + + for (int i = 0; i < 11; i++) { + QStringList desktopfpList; + desktopfpList.clear(); + qSort(appVector[i].begin(), appVector[i].end(), cmpApp); + + for (int j = 0; j < appVector[i].size(); j++) { + desktopfpList.append(appVector[i].at(j).at(0)); + } + + data.append(desktopfpList); + } + + return data; +} + +bool UkuiMenuInterface::matchingAppCategories(QString desktopfp, QStringList categorylist) +{ + QString category = getAppCategories(desktopfp); + int index; + + for (index = 0; index < categorylist.count(); index++) { + if (category.contains(categorylist.at(index), Qt::CaseInsensitive)) { + return true; + } + } + + if (index == categorylist.count()) { + return false; + } + + return false; +} + +void UkuiMenuInterface::getAndroidApp() +{ + m_androidDesktopfnList.clear(); + QVector androidVector; + androidVector.clear(); + QString path = QDir::homePath() + "/.local/share/applications/"; + QDir dir(path); + + if (!dir.exists()) { + return; + } + + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + dir.setSorting(QDir::DirsFirst); + QFileInfoList list = dir.entryInfoList(); + + if (list.size() < 1) { + return; + } + + int i = 0; + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + + do { + QFileInfo fileInfo = list.at(i); + + if (!fileInfo.isFile()) { + i++; + continue; + } + + //过滤后缀不是.desktop的文件 + QString filePathStr = fileInfo.filePath(); + + if (!filePathStr.endsWith(".desktop")) { + i++; + continue; + } + + QByteArray fpbyte = filePathStr.toLocal8Bit(); + char *filepath = fpbyte.data(); + + if (0 != access(filepath, R_OK)) { //判断文件是否可读 + i++; + continue; + } + + m_keyfile = g_key_file_new(); + + if (!g_key_file_load_from_file(m_keyfile, filepath, m_flags, m_error)) { + return; + } + + char *ret_1 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); + + if (ret_1 != nullptr) { + QString str = QString::fromLocal8Bit(ret_1); + + if (str.contains("true")) { + g_key_file_free(m_keyfile); + i++; + continue; + } + } + + char *ret_2 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); + + if (ret_2 != nullptr) { + QString str = QString::fromLocal8Bit(ret_2); + + if (str.contains("UKUI")) { + g_key_file_free(m_keyfile); + i++; + continue; + } + } + + //过滤LXQt、KDE + char *ret = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); + + if (ret != nullptr) { + QString str = QString::fromLocal8Bit(ret); + + if (str.contains("LXQt") || str.contains("KDE")) { + g_key_file_free(m_keyfile); + i++; + continue; + } + } + + m_filePathList.append(filePathStr); + m_androidDesktopfnList.append(fileInfo.fileName()); + i++; + } while (i < list.size()); + + g_key_file_free(keyfile); +} + +QString UkuiMenuInterface::getAppNameInitials(QString desktopfp) +{ + QString firstLetters; + QString appname = getAppName(desktopfp); + QStringList appnamestr = appname.split(" "); + QString letters; + + Q_FOREACH (QString name, appnamestr) { + letters.clear(); + letters = UkuiChineseLetter::getFirstLettersAll(name); + + if (letters.isEmpty()) { + letters = UkuiChineseLetter::getFirstLetter(name); + } + + firstLetters.append(letters); + } + + return firstLetters; +} + +QString UkuiMenuInterface::getAppNameInitial(QString desktopfp) +{ + return UkuiChineseLetter::getFirstLetter(getAppName(desktopfp)); +} + +//获取应用拼音 +QString UkuiMenuInterface::getAppNamePinyin(QString appname) +{ + return UkuiChineseLetter::getPinyins(appname); +} + +bool UkuiMenuInterface::checkKreApp(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *value = g_key_file_get_locale_string(keyfile, "Desktop Entry", "environment", nullptr, nullptr); + g_key_file_free(keyfile); + + if (!value) { + return false; + } else if (QString::compare(QString::fromLocal8Bit(value), "kre-environment") == 0) { + return true; + } + + return false; +} + +//获取指定类型应用列表 +QStringList UkuiMenuInterface::getSpecifiedCategoryAppList(QString categorystr) +{ + QByteArray categorybyte = categorystr.toLocal8Bit(); + char *category = categorybyte.data(); + QStringList desktopfpList = getDesktopFilePath(); + QStringList appnameList; + appnameList.clear(); + + for (int index = 0; index < desktopfpList.count(); index++) { + QString appcategorystr = getAppCategories(desktopfpList.at(index)); + + if (!appcategorystr.isEmpty()) { + QByteArray appcategorybyte = appcategorystr.toLocal8Bit(); + char *appcategory = appcategorybyte.data(); + int len = static_cast(strlen(appcategory) - 6); + + for (int i = 0; i < len; i++) { + if (strncmp(appcategory + i, category, strlen(category)) == 0) { + QString appname = getAppName(desktopfpList.at(index)); + + if (QString::compare(appname, "访问提示") == 0) { + appnameList.append(appname); + } + + break; + } + } + } + } + + return appnameList; +} diff --git a/src/BackProcess/Interface/ukuimenuinterface.h b/src/Interface/ukuimenuinterface.h similarity index 70% rename from src/BackProcess/Interface/ukuimenuinterface.h rename to src/Interface/ukuimenuinterface.h index 1c8ca58..521786a 100644 --- a/src/BackProcess/Interface/ukuimenuinterface.h +++ b/src/Interface/ukuimenuinterface.h @@ -27,16 +27,15 @@ #include #include #include -#include "utility.h" class UkuiMenuInterface { private: QStringList m_filePathList; - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = nullptr; + GError **m_error = nullptr; + GKeyFileFlags m_flags = G_KEY_FILE_NONE; + GKeyFile *m_keyfile = nullptr; protected: void recursiveSearchFile(const QString &_filePath);//遍历/usr/share/applications/文件夹 @@ -45,19 +44,13 @@ protected: public: UkuiMenuInterface(); ~UkuiMenuInterface(); - QVector createAppInfoVector();//创建应用信息容器 - static QVector appInfoVector; - static QVector desktopfpVector; - static QVector alphabeticVector; - static QVector functionalVector; - static QVector allAppVector; - static QVector collectAppVector; - static QStringList androidDesktopfnList; - - static QVector tencentInitVector; - static QVector customizedVector; - static QVector thirdPartyVector; - static QVector applicationVector; + QVector createSoftwareAppInfoVector();//创建软件商店应用信息容器 + static QVector m_appInfoVector; + static QVector m_desktopfpVector; + static QVector m_alphabeticVector; + static QVector m_functionalVector; + static QVector m_allAppVector; + static QStringList m_androidDesktopfnList; /** * 获取系统应用名称 @@ -71,31 +64,21 @@ public: QString getAppExec(QString desktopfp);//获取应用命令 QString getAppType(QString desktopfp);//获取应用类型 QString getAppComment(QString desktopfp);//获取应用注释 - QStringList getDesktopFilePath();//获取系统desktop文件路径 + QStringList getDesktopFilePath();//获取系统deskyop文件路径 QStringList getFunctionClassName();//获取功能类别名称 - QVector getCollectApp();//获取收藏应用 + QVector getAlphabeticClassification();//字母分类模块 QVector getFunctionalClassification();//功能分类模块 QVector getCommonUseApp();//获取常用App QVector getAllClassification();//所有软件模块 void getAndroidApp();//获取安卓应用 static bool cmpApp(QStringList &arg_1, QStringList &arg_2); + static bool cmpfixedApp(QStringList &arg_1, QStringList &arg_2); bool matchingAppCategories(QString desktopfp, QStringList categorylist); //匹配应用Categories QString getAppNameInitials(QString desktopfp);//获取应用名所有首字母 QString getAppNameInitial(QString desktopfp);//获取应用名所有首字母 QString getAppNamePinyin(QString appname);//获取应用名拼音 bool checkKreApp(QString desktopfp); - - QStringList getInstalledAppList(); - QString getTencentAppid(QString desktopfp); - bool initAppIni(); - QVector getAllApp(); - QVector getLockApp(); - QVector sortDesktopList(QString group); - - /**/ - QSettings *setting = nullptr; - QSettings *syssetting = nullptr; }; #endif // UKUIMENUINTERFACE_H diff --git a/src/UserInterface/Widget/full_letter_widget.cpp b/src/LetterWidget/fullletterwidget.cpp similarity index 54% rename from src/UserInterface/Widget/full_letter_widget.cpp rename to src/LetterWidget/fullletterwidget.cpp index 5b7d21b..4f4d021 100644 --- a/src/UserInterface/Widget/full_letter_widget.cpp +++ b/src/LetterWidget/fullletterwidget.cpp @@ -16,7 +16,7 @@ * */ -#include "full_letter_widget.h" +#include "fullletterwidget.h" #include #include @@ -28,8 +28,10 @@ FullLetterWidget::FullLetterWidget(QWidget *parent) : FullLetterWidget::~FullLetterWidget() { - delete m_ukuiMenuInterface; - delete m_letterListBottomSpacer; + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } } /** @@ -40,16 +42,18 @@ void FullLetterWidget::initUi() this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); this->setAttribute(Qt::WA_TranslucentBackground); + m_applistWid = new QWidget(this); m_letterListWid = new QWidget(this); - m_letterListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); - m_verticalScrollBar = new QScrollBar(m_scrollArea); - m_verticalScrollBar->installEventFilter(this); - m_verticalScrollBar->setOrientation(Qt::Vertical); - m_mainLayout = new QHBoxLayout; - m_mainLayout->setContentsMargins(0, 0, 40, 0); - m_mainLayout->setSpacing(0); - m_mainLayout->addWidget(m_letterListWid); - this->setLayout(m_mainLayout); + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); + m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height()); + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->setContentsMargins(0, 0, 0, 0); + mainLayout->setSpacing(0); + mainLayout->addWidget(m_letterListWid); + mainLayout->addWidget(m_applistWid); + this->setLayout(mainLayout); m_ukuiMenuInterface = new UkuiMenuInterface; initAppListWidget(); initLetterListWidget(); @@ -62,10 +66,6 @@ void FullLetterWidget::initUi() time->stop(); } }); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullLetterWidget::on_setScrollBarValue); - connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullLetterWidget::on_setAreaScrollBarValue); - connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullLetterWidget::on_powerOffButton_customContextMenuRequested); - connect(m_powerOffButton, &QPushButton::clicked, this, &FullLetterWidget::on_powerOffButton_clicked); } /** @@ -73,94 +73,30 @@ void FullLetterWidget::initUi() */ void FullLetterWidget::initAppListWidget() { - // QHBoxLayout* layout=new QHBoxLayout(m_applistWid); - // layout->setContentsMargins(0,0,0,0); - // m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea(); - m_scrollArea->setStyleSheet("background:transparent"); - m_scrollAreaWid = new ScrollAreaWid(this); + QHBoxLayout *layout = new QHBoxLayout(m_applistWid); + layout->setContentsMargins(0, 0, 0, 0); + m_applistWid->setLayout(layout); + m_scrollArea = new ScrollArea(this); + m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollArea->setWidgetResizable(true); - // m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_scrollAreaWidLayout = new QVBoxLayout; m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); m_scrollAreaWidLayout->setSpacing(10); m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); - m_mainLayout->addWidget(m_scrollArea); - QSpacerItem *m_spaceItem1 = nullptr; - m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - m_mainLayout->addItem(m_spaceItem1); - QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); - rightButtonLayout->setContentsMargins(0, 0, 0, 20); - rightButtonLayout->setSpacing(0); - QSpacerItem *m_spaceItem2 = nullptr; - m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem2); - m_powerOffButton = new QPushButton(this); - m_powerOffButton->setFixedSize(QSize(40, 40)); - m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); - QIcon powerIcon; - powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); - m_powerOffButton->setIcon(powerIcon); - m_powerOffButton->setIconSize(QSize(28, 28)); - m_powerOffButton->setFlat(true); - m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" - "QPushButton:hover {border-radius:20px; background: rgba(255, 255, 255, 0.2);}" - "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); - rightButtonLayout->addWidget(m_verticalScrollBar); - QSpacerItem *m_spaceItem3 = nullptr; - m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem3); - rightButtonLayout->addWidget(m_powerOffButton); - rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); - m_mainLayout->addLayout(rightButtonLayout); + layout->addWidget(m_scrollArea); connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullLetterWidget::valueChangedSlot); + m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); fillAppList(); - m_scrollAreaWidHeight = m_scrollAreaWid->height(); - initVerticalScrollBar(); -} - -void FullLetterWidget::initVerticalScrollBar() -{ - m_verticalScrollBar->setFixedHeight(200); - int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; - - if (scrollBarSize >= 200) { - m_verticalScrollBar->hide(); - } else { - m_verticalScrollBar->show(); - } - - m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); " - "margin: 0px,0px,0px,0px; border-radius: %3px;}" - "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);" - "border-radius: %3px; min-height: %1;}" - "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" - "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); -} - -void FullLetterWidget::on_powerOffButton_clicked() -{ - QProcess::startDetached(QString("ukui-session-tools")); -} - -void FullLetterWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) -{ - RightClickMenu m_otherMenu(this); - m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(pos)); - qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; } void FullLetterWidget::setFocusToThis() { - QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget *widTop = widItemTop->widget(); - FullListView *m_listviewTop = qobject_cast(widTop); letterButtonClick(); - m_listviewTop->setFocus(); + this->setFocus(); Q_EMIT selectFirstItem(); } @@ -170,7 +106,7 @@ void FullLetterWidget::setFocusToThis() void FullLetterWidget::fillAppList() { m_letterList.clear(); - QVector vector = UkuiMenuInterface::alphabeticVector; + QVector vector = UkuiMenuInterface::m_alphabeticVector; for (int i = 0; i < vector.size(); i++) { QStringList appList = vector.at(i); @@ -188,17 +124,13 @@ void FullLetterWidget::fillAppList() m_letterList.append(letterstr);//存储分类字符 //插入字母分类按钮 - SplitBarFrame *letterbtn = new SplitBarFrame(this, letterstr, m_scrollArea->width() - 12, 30, 1); + SplitBarFrame *letterbtn = new SplitBarFrame(this, letterstr, m_scrollArea->width() - 16, 30, 1); m_scrollAreaWidLayout->addWidget(letterbtn); //插入应用列表 FullListView *listview = new FullListView(this, 1); connect(listview, &FullListView::sendSetslidebar, this, &FullLetterWidget::onSetSlider); connect(this, &FullLetterWidget::selectFirstItem, listview, &FullListView::selectFirstItem); listview->installEventFilter(this); - //修复异常黑框问题 - connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { - listview->repaint(listview->rect()); - }); m_scrollAreaWidLayout->addWidget(listview); m_data.clear(); @@ -212,6 +144,7 @@ void FullLetterWidget::fillAppList() } } + m_scrollAreaWidLayout->addItem(m_appListBottomSpacer); resizeScrollAreaControls(); } @@ -224,12 +157,6 @@ void FullLetterWidget::execApplication(QString desktopfp) execApp(desktopfp); } -void FullLetterWidget::on_setAreaScrollBarValue(int value) -{ - // m_scrollArea->verticalScrollBar()->setMaximum(maxmumValue); - m_scrollArea->verticalScrollBar()->setValue(value); -} - /** * 更新应用列表 */ @@ -237,6 +164,7 @@ void FullLetterWidget::updateAppListView() { //刷新应用列表界面 QLayoutItem *child; + m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer); while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { QWidget *wid = child->widget(); @@ -254,12 +182,11 @@ void FullLetterWidget::updateAppListView() } m_buttonList.clear(); - m_letterListWidLayout->removeItem(m_topSpacerItem); - m_letterListWidLayout->removeItem(m_letterListBottomSpacer); + m_letterListScrollAreaWidLayout->removeItem(m_letterListBottomSpacer); - while ((child = m_letterListWidLayout->takeAt(0)) != 0) { + while ((child = m_letterListScrollAreaWidLayout->takeAt(0)) != 0) { QWidget *wid = child->widget(); - m_letterListWidLayout->removeWidget(wid); + m_letterListScrollAreaWidLayout->removeWidget(wid); wid->setParent(nullptr); delete wid; delete child; @@ -267,14 +194,6 @@ void FullLetterWidget::updateAppListView() //防止按钮位置偏移 initLetterListScrollArea(); - m_scrollAreaWidHeight = m_scrollAreaWid->height(); - initVerticalScrollBar(); -} - -void FullLetterWidget::on_setScrollBarValue(int value) -{ - m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); - m_verticalScrollBar->setValue(value); } /** @@ -283,7 +202,6 @@ void FullLetterWidget::on_setScrollBarValue(int value) void FullLetterWidget::resizeScrollAreaControls() { int row = 0; - int areaHeight = 0; while (row < m_scrollAreaWidLayout->count() / 2) { //应用界面 @@ -291,7 +209,7 @@ void FullLetterWidget::resizeScrollAreaControls() QWidget *wid = widItem->widget(); FullListView *listview = qobject_cast(wid); listview->adjustSize(); - int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; + int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; int rowcount = 0; if (listview->model()->rowCount() % dividend > 0) { @@ -300,12 +218,11 @@ void FullLetterWidget::resizeScrollAreaControls() rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_scrollArea->width(), listview->gridSize().height()*rowcount); - areaHeight += listview->height() + 50; + listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); row++; } - m_scrollArea->widget()->setFixedSize(m_scrollArea->width(), areaHeight - 10); + m_scrollArea->widget()->adjustSize(); } /** @@ -313,14 +230,18 @@ void FullLetterWidget::resizeScrollAreaControls() */ void FullLetterWidget::initLetterListWidget() { - m_letterListWidLayout = new QVBoxLayout(m_letterListWid); - m_letterListWidLayout->setContentsMargins(45, 0, 0, 0); - m_letterListWidLayout->setSpacing(0); - m_topSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_letterListScrollArea = new ClassifyBtnScrollArea(m_letterListWid); + m_letterListScrollAreaWid = new ClassifyBtnScrollAreaWid(m_letterListScrollArea); + m_letterListScrollAreaWidLayout = new QVBoxLayout; + m_letterListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_letterListScrollAreaWidLayout->setSpacing(0); + m_letterListScrollAreaWid->setLayout(m_letterListScrollAreaWidLayout); + m_letterListScrollArea->setWidget(m_letterListScrollAreaWid); + m_letterListScrollArea->setWidgetResizable(true); m_letterListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_btnGroup = new QButtonGroup(m_letterListWid); - m_animation = new QPropertyAnimation(m_letterListWid, "geometry"); - m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); + m_btnGroup = new QButtonGroup(m_letterListScrollAreaWid); + m_animation = new QPropertyAnimation(m_letterListScrollArea, "geometry"); + m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value", this); m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullLetterWidget::animationFinishSlot); connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullLetterWidget::animationValueChangedSlot); @@ -332,24 +253,22 @@ void FullLetterWidget::initLetterListWidget() */ void FullLetterWidget::initLetterListScrollArea() { - m_letterListWidLayout->addItem(m_topSpacerItem); - if (m_letterList.contains("&")) { m_letterList.replace(m_letterList.indexOf("&"), "&&"); } for (int i = 0; i < m_letterList.size(); i++) { - LetterClassifyButton *letterbtn = new LetterClassifyButton(m_letterListWid, + LetterClassifyButton *letterbtn = new LetterClassifyButton(m_letterListScrollAreaWid, true, m_letterList.at(i)); letterbtn->setFixedSize(Style::LeftLetterBtnHeight, Style::LeftLetterBtnHeight); m_buttonList.append(letterbtn); - m_letterListWidLayout->addWidget(letterbtn); - m_letterListWidLayout->setAlignment(letterbtn, Qt::AlignLeft); + m_letterListScrollAreaWidLayout->addWidget(letterbtn); + m_letterListScrollAreaWidLayout->setAlignment(letterbtn, Qt::AlignHCenter); connect(letterbtn, &LetterClassifyButton::buttonClicked, m_btnGroup, static_cast(&QButtonGroup::buttonClicked)); } - m_letterListWidLayout->addItem(m_letterListBottomSpacer); + m_letterListScrollAreaWidLayout->addItem(m_letterListBottomSpacer); int id = 0; Q_FOREACH (QAbstractButton *btn, m_buttonList) { @@ -357,8 +276,8 @@ void FullLetterWidget::initLetterListScrollArea() } connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullLetterWidget::btnGroupClickedSlot); + m_letterListScrollArea->widget()->adjustSize(); - // m_letterListWid->widget()->adjustSize(); if (m_btnGroup->button(0) != nullptr) { m_btnGroup->button(0)->click(); } @@ -448,6 +367,19 @@ void FullLetterWidget::valueChangedSlot(int value) index++; } } + +// //向下滚动 +// if((m_buttonList.at(index)->pos().y()+m_buttonList.at(index)->height()+m_letterListScrollArea->widget()->pos().y()) >= m_letterListScrollArea->height()) +// { +// int val=m_letterListScrollArea->verticalScrollBar()->sliderPosition()+m_buttonList.at(index)->height(); +// m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); +// } +// //向上滚动 +// if((m_buttonList.at(index)->pos().y()+m_letterListScrollArea->widget()->pos().y()) <= 0) +// { +// int val=m_letterListScrollArea->verticalScrollBar()->value()-m_buttonList.at(index)->height(); +// m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); +// } } void FullLetterWidget::enterAnimation() @@ -461,22 +393,26 @@ void FullLetterWidget::enterAnimation() (m_letterList.size() + 1)*Style::LeftLetterBtnHeight)); m_animation->setEasingCurve(QEasingCurve::InQuart); m_animation->start(); - // m_letterListScrollArea->show(); + m_letterListScrollArea->show(); } void FullLetterWidget::setLetterBtnGeometry() { - // m_letterListScrollArea->setGeometry(QRect(Style::LeftMargin, - // (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, - // Style::LeftLetterBtnHeight*2, - // (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); - // m_letterListScrollArea->show(); + m_letterListScrollArea->setGeometry(QRect(Style::LeftMargin, + (m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2, + Style::LeftLetterBtnHeight * 2, + (m_letterList.size() + 1)*Style::LeftLetterBtnHeight)); + m_letterListScrollArea->show(); } void FullLetterWidget::repaintWidget() { - m_letterListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); - m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); + m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height()); updateAppListView(); } @@ -488,7 +424,7 @@ void FullLetterWidget::widgetMakeZero() if (num != -1) { m_btnGroup->button(num)->click(); - // m_letterListScrollArea->verticalScrollBar()->setSliderPosition(0); + m_letterListScrollArea->verticalScrollBar()->setSliderPosition(0); break; } } @@ -498,7 +434,7 @@ void FullLetterWidget::widgetMakeZero() void FullLetterWidget::moveScrollBar(int type) { - int height = Style::m_availableScreenHeight; + int height = Style::primaryScreenHeight; if (type == 0) { m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() - height * 100 / 1080); @@ -509,13 +445,13 @@ void FullLetterWidget::moveScrollBar(int type) void FullLetterWidget::onSetSlider(int value) { - // if(flag) - // { - // flag = false; - // time->start(100); +// if(flag) +// { +// flag = false; +// time->start(100); int curvalue = m_scrollArea->verticalScrollBar()->value(); m_scrollArea->verticalScrollBar()->setValue(curvalue + value); - // } +// } } QAbstractButton *FullLetterWidget::getCurLetterButton(int value) @@ -525,63 +461,52 @@ QAbstractButton *FullLetterWidget::getCurLetterButton(int value) bool FullLetterWidget::eventFilter(QObject *watched, QEvent *event) { - if (watched == m_verticalScrollBar) { - if (event->type() == QEvent::Enter) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4)); + if (event->type() == QEvent::KeyPress) { + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); + QWidget *wid = widItem->widget(); + FullListView *m_listview = qobject_cast(wid); + QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget *widTop = widItemTop->widget(); + FullListView *m_listviewTop = qobject_cast(widTop); + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + // m_letterListScrollAreaWid->setFocus(); + // m_letterListScrollArea->setFocus(); + // return true; + Q_EMIT setFocusToSideWin(); } - if (event->type() == QEvent::Leave) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); + if (ke->key() == Qt::Key_Up) { + if (!m_listviewTop->hasFocus()) { + QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); + btnGroupClickedSlot(buttonTop); + this->m_scrollArea->setFocusToPreChild(); + } else { + m_listview->setFocus(); + QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); + btnGroupClickedSlot(button); + m_index = m_buttonList.size() - 1; + } + + Q_EMIT selectFirstItem(); + return true; } - } else { - if (event->type() == QEvent::KeyPress) { - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); - QWidget *wid = widItem->widget(); - FullListView *m_listview = qobject_cast(wid); - QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget *widTop = widItemTop->widget(); - FullListView *m_listviewTop = qobject_cast(widTop); - QKeyEvent *ke = (QKeyEvent *)event; - if (ke->key() == Qt::Key_Tab) { - // m_letterListScrollAreaWid->setFocus(); - // m_letterListScrollArea->setFocus(); - // return true; - Q_EMIT setFocusToSideWin(); - return true; + if (ke->key() == Qt::Key_Down) { + if (!m_listview->hasFocus()) { + QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); + btnGroupClickedSlot(button); + this->m_scrollArea->setFocusToNextChild(); + } else { + m_listviewTop->setFocus(); + QAbstractButton *buttonTop = getCurLetterButton(0); + btnGroupClickedSlot(buttonTop); + m_index = 0; } - if (ke->key() == Qt::Key_Up) { - if (!m_listviewTop->hasFocus()) { - QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); - btnGroupClickedSlot(buttonTop); - this->m_scrollArea->setFocusToPreChild(); - } else { - m_listview->setFocus(); - QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); - btnGroupClickedSlot(button); - m_index = m_buttonList.size() - 1; - } - - Q_EMIT selectFirstItem(); - return true; - } - - if (ke->key() == Qt::Key_Down) { - if (!m_listview->hasFocus()) { - QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); - btnGroupClickedSlot(button); - this->m_scrollArea->setFocusToNextChild(); - } else { - m_listviewTop->setFocus(); - QAbstractButton *buttonTop = getCurLetterButton(0); - btnGroupClickedSlot(buttonTop); - m_index = 0; - } - - Q_EMIT selectFirstItem(); - return true; - } + Q_EMIT selectFirstItem(); + return true; } } diff --git a/src/UserInterface/Widget/full_letter_widget.h b/src/LetterWidget/fullletterwidget.h similarity index 70% rename from src/UserInterface/Widget/full_letter_widget.h rename to src/LetterWidget/fullletterwidget.h index 5f94658..4b7e2e6 100644 --- a/src/UserInterface/Widget/full_letter_widget.h +++ b/src/LetterWidget/fullletterwidget.h @@ -30,30 +30,31 @@ #include #include #include -#include "ukuimenuinterface.h" +#include "src/Interface/ukuimenuinterface.h" #include #include #include #include #include +#include "src/Interface/ukuimenuinterface.h" #include #include #include #include -#include "letter_classify_button.h" -#include "scrollarea.h" -#include "splitbar_frame.h" -#include "fulllistview.h" -#include "classify_btn_scrollarea.h" -#include "tool_button.h" -#include "style.h" +#include "src/UtilityFunction/letterclassifybutton.h" +#include "src/UtilityFunction/scrollarea.h" +#include "src/UtilityFunction/splitbarframe.h" +#include "src/UtilityFunction/fulllistview.h" +#include "src/UtilityFunction/classifybtnscrollarea.h" +#include "src/UtilityFunction/toolbutton.h" +#include "src/Style/style.h" class FullLetterWidget : public QWidget { Q_OBJECT public: - explicit FullLetterWidget(QWidget *parent = nullptr); + explicit FullLetterWidget(QWidget *parent=nullptr); ~FullLetterWidget(); /** * @brief Initializes the interface state @@ -81,45 +82,42 @@ public: void letterButtonClick(); - QAbstractButton *getCurLetterButton(int value); + QAbstractButton* getCurLetterButton(int value); private: /*Application list interface*/ - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QWidget *m_applistWid = nullptr; - ScrollArea *m_scrollArea = nullptr; - ScrollAreaWid *m_scrollAreaWid = nullptr; - QVBoxLayout *m_scrollAreaWidLayout = nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + QWidget* m_applistWid=nullptr; + ScrollArea* m_scrollArea=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; + QVBoxLayout* m_scrollAreaWidLayout=nullptr; QStringList m_letterList;//Store the list of letter buttons QStringList m_data; bool flag; QTimer *time = nullptr; int m_index = 0; /*Alphabetic classification list interface*/ - QWidget *m_letterListWid = nullptr; - QVBoxLayout *m_letterListWidLayout = nullptr; - QList m_buttonList; - QButtonGroup *m_btnGroup = nullptr; - QSpacerItem *m_letterListBottomSpacer = nullptr; - QSpacerItem *m_topSpacerItem = nullptr; + QWidget* m_letterListWid=nullptr; + ClassifyBtnScrollArea* m_letterListScrollArea=nullptr; + ClassifyBtnScrollAreaWid* m_letterListScrollAreaWid=nullptr; + QVBoxLayout* m_letterListScrollAreaWidLayout=nullptr; + QList m_buttonList; + QButtonGroup* m_btnGroup=nullptr; + QSpacerItem* m_letterListBottomSpacer=nullptr; + QSpacerItem* m_appListBottomSpacer=nullptr; /*Animation*/ - QPropertyAnimation *m_animation = nullptr; //Letter category button animation - int m_beginPos = 0; //Application list scrollbar starting value - int m_endPos = 0; //Application list scrollbar end value - QPropertyAnimation *m_scrollAnimation = nullptr; //Application list animation - QScrollBar *m_verticalScrollBar = nullptr; - int m_scrollAreaWidHeight = 0; - QString m_scrollBarStyle; - QHBoxLayout *m_mainLayout = nullptr; - QPushButton *m_powerOffButton = nullptr; + QPropertyAnimation* m_animation=nullptr;//Letter category button animation + int m_beginPos=0;//Application list scrollbar starting value + int m_endPos=0;//Application list scrollbar end value + QPropertyAnimation* m_scrollAnimation=nullptr;//Application list animation protected: /** * @brief Initializes UI */ void initUi(); - // void paintEvent(QPaintEvent *event); +// void paintEvent(QPaintEvent *event); /** * @brief fill application list */ @@ -137,7 +135,6 @@ protected: * @brief Set the control size in qscrollarea */ void resizeScrollAreaControls(); - void initVerticalScrollBar(); bool eventFilter(QObject *watched, QEvent *event); @@ -174,15 +171,6 @@ public Q_SLOTS: void onSetSlider(int); void setFocusToThis(); - - void on_setScrollBarValue(int value); - - void on_setAreaScrollBarValue(int value); - - void on_powerOffButton_clicked(); - - void on_powerOffButton_customContextMenuRequested(const QPoint &pos); - public: Q_SIGNALS: /** @@ -196,7 +184,6 @@ Q_SIGNALS: void selectFirstItem(); - void changeScrollValue(int value, int maximumValue); }; #endif // FULLLETTERWIDGET_H diff --git a/src/UserInterface/Widget/letter_button_widget.cpp b/src/LetterWidget/letterbuttonwidget.cpp similarity index 53% rename from src/UserInterface/Widget/letter_button_widget.cpp rename to src/LetterWidget/letterbuttonwidget.cpp index 68e3a74..bcf298f 100644 --- a/src/UserInterface/Widget/letter_button_widget.cpp +++ b/src/LetterWidget/letterbuttonwidget.cpp @@ -16,8 +16,9 @@ * */ -#include "letter_button_widget.h" -#include "style.h" +#include "letterbuttonwidget.h" +#include "src/Style/style.h" +#include "letterwidget.h" #include LetterButtonWidget::LetterButtonWidget(QWidget *parent) : @@ -33,52 +34,52 @@ LetterButtonWidget::~LetterButtonWidget() void LetterButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); + this->setAttribute(Qt::WA_StyledBackground,true); this->setFocusPolicy(Qt::NoFocus); - QGridLayout *gridLayout = new QGridLayout; - gridLayout->setContentsMargins(35, 80, 35, 80); + this->resize(235,366); + + QGridLayout* gridLayout=new QGridLayout; + gridLayout->setContentsMargins(0,0,0,0); gridLayout->setSpacing(5); this->setLayout(gridLayout); + QStringList letterlist; letterlist.clear(); - - for (int i = 0; i < 26; i++) { - char letter = static_cast(65 + i); + for(int i=0;i<26;i++) + { + char letter=static_cast(65+i); letterlist.append(QString(QChar(letter))); } - letterlist.append("&&"); letterlist.append("#"); - for (int row = 0; row < 6; row++) { - for (int col = 0; col < 5; col++) { - if (row * 5 + col < letterlist.size()) { - LetterClassifyButton *btn = new LetterClassifyButton(this, false, letterlist.at(row * 5 + col)); + for(int row=0;row<7;row++) + { + for(int col=0;col<4;col++) + { + if(row*4+colsetFlat(true); btn->setCheckable(false); - btn->setFixedSize(38, 38); - gridLayout->addWidget(btn, row, col); - connect(btn, &LetterClassifyButton::buttonClicked, this, &LetterButtonWidget::letterBtnClickedSlot); - } else { + btn->setFixedSize(55,48); + gridLayout->addWidget(btn,row,col); + connect(btn,&LetterClassifyButton::buttonClicked,this, &LetterButtonWidget::letterBtnClickedSlot); + } + else { break; } } } } -void LetterButtonWidget::hideEvent(QHideEvent *event) -{ - Q_EMIT sendResetLetterPage(); - return QWidget::hideEvent(event); -} - /** * 字母分类按钮槽函数 */ void LetterButtonWidget::letterBtnClickedSlot() { - LetterClassifyButton *btn = dynamic_cast(QObject::sender()); - QString btnname = btn->text(); + LetterClassifyButton* btn=dynamic_cast(QObject::sender()); + QString btnname=btn->text(); Q_EMIT sendLetterBtnSignal(btnname); } @@ -87,23 +88,20 @@ void LetterButtonWidget::letterBtnClickedSlot() */ void LetterButtonWidget::recvLetterBtnList(QStringList list) { - QGridLayout *gridLayout = qobject_cast(this->layout()); - - for (int row = 0; row < 7; row++) { - for (int col = 0; col < 4; col++) { - QLayoutItem *item = gridLayout->itemAt(row * 4 + col); - LetterClassifyButton *btn = static_cast(item->widget()); - QString letterstr = btn->text(); - - if (list.indexOf(letterstr.at(0)) == -1) { + QGridLayout* gridLayout=qobject_cast(this->layout()); + for(int row=0;row<7;row++) + { + for(int col=0;col<4;col++) + { + QLayoutItem* item=gridLayout->itemAt(row*4+col); + LetterClassifyButton* btn=static_cast(item->widget()); + QString letterstr=btn->text(); + if(list.indexOf(letterstr.at(0))==-1) btn->setEnabled(false); - } else { + else btn->setEnabled(true); - } - if (row * 4 + col == 27) { - break; - } + if(row*4+col==27) break; } } } diff --git a/src/UserInterface/Widget/letter_button_widget.h b/src/LetterWidget/letterbuttonwidget.h similarity index 93% rename from src/UserInterface/Widget/letter_button_widget.h rename to src/LetterWidget/letterbuttonwidget.h index bf50598..7c03a67 100644 --- a/src/UserInterface/Widget/letter_button_widget.h +++ b/src/LetterWidget/letterbuttonwidget.h @@ -26,7 +26,7 @@ #include #include #include -#include "letter_classify_button.h" +#include "src/UtilityFunction/letterclassifybutton.h" class LetterButtonWidget : public QWidget { @@ -42,15 +42,12 @@ protected: */ void initUi(); - void hideEvent(QHideEvent *event); - Q_SIGNALS: /** * @brief Send button click signal to letterwidget interface * @param btnname: Category button name */ void sendLetterBtnSignal(QString btnname); - void sendResetLetterPage(); public Q_SLOTS: /** diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp new file mode 100644 index 0000000..e5b1767 --- /dev/null +++ b/src/LetterWidget/letterwidget.cpp @@ -0,0 +1,271 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/UtilityFunction/itemdelegate.h" +#include "src/UtilityFunction/utility.h" + +LetterWidget::LetterWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +LetterWidget::~LetterWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +/** + * 主界面初始化 + */ +void LetterWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + m_letterBtnWid = new LetterButtonWidget(this); + m_letterBtnWid->hide(); + connect(this, &LetterWidget::sendLetterBtnList, m_letterBtnWid, &LetterButtonWidget::recvLetterBtnList); + connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal, this, &LetterWidget::recvLetterBtnSlot); + m_enterAnimation = new QPropertyAnimation; + m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); + m_leaveAnimation = new QPropertyAnimation; + m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); + connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &LetterWidget::animationFinishedSLot); + connect(m_enterAnimation, &QPropertyAnimation::finished, this, &LetterWidget::animationFinishedSLot); +} + +/** + * 初始化应用列表界面 + */ +void LetterWidget::initAppListWidget() +{ + m_appListView = new ListView(this, this->width() - 6, this->height() - 6, 1); + m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->show(); + fillAppListView(); + connect(m_appListView, &ListView::sendItemClickedSignal, this, &LetterWidget::recvItemClickedSlot); + connect(m_appListView, &ListView::sendHideMainWindowSignal, this, &LetterWidget::sendHideMainWindowSignal); + connect(m_appListView, &ListView::sendMainWinActiveSignal, this, &LetterWidget::sendMainWinActiveSignal); +} + + +/** + * 填充应用列表 + */ +void LetterWidget::fillAppListView() +{ + m_data.clear(); + int row = 0; + QVector vector = UkuiMenuInterface::m_alphabeticVector; + + for (int i = 0; i < vector.size(); i++) { + QStringList appList = vector.at(i); + + if (!appList.isEmpty()) { + QString letterstr; + + if (i < 26) { + letterstr = QString(QChar(static_cast(i + 65))); + } else if (i == 26) { + letterstr = "&"; + } else { + letterstr = "#"; + } + + m_letterList.append(letterstr);//存储分类字符 + m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 + m_data.append(QStringList() << letterstr << "0"); + + for (int i = 0; i < appList.count(); i++) { + m_data.append(QStringList() << appList.at(i) << "1"); + } + + row += (appList.count() + 1); + } + } + + m_appListView->addData(m_data); +} + +void LetterWidget::recvItemClickedSlot(QStringList arg) +{ + if (arg.at(1).toInt() == 0) { + appClassificationBtnClickedSlot(); + } else { + execApplication(arg.at(0)); + } +} + +/** + * 执行应用程序 + */ +void LetterWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +/** + * 更新应用列表 + */ +void LetterWidget::updateAppListView() +{ + int row = 0; + m_data.clear(); + m_letterList.clear(); + m_letterBtnRowList.clear(); + QVector vector = UkuiMenuInterface::m_alphabeticVector; + + for (int i = 0; i < vector.size(); i++) { + QStringList appList = vector.at(i); + + if (!appList.isEmpty()) { + QString letterstr; + + if (i < 26) { + letterstr = QString(QChar(static_cast(i + 65))); + } else if (i == 26) { + letterstr = "&"; + } else { + letterstr = "#"; + } + + m_letterList.append(letterstr);//存储分类字符 + m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 + m_data.append(QStringList() << letterstr << "0"); + + for (int i = 0; i < appList.count(); i++) { + m_data.append(QStringList() << appList.at(i) << "1"); + } + + row += (appList.count() + 1); + } + } + + m_appListView->updateData(m_data); +} + +/** + * 应用列表字母分类按钮槽函数 + */ +void LetterWidget::appClassificationBtnClickedSlot() +{ + m_leaveAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_leaveAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); +// m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); + m_enterAnimation->setStartValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); + m_enterAnimation->setEndValue(QRect((this->width() - 235) / 2, (this->height() - 366) / 2, 235, 366)); + //加载LetterBUttonWidget界面 + m_enterAnimation->setDuration(100); + m_leaveAnimation->setDuration(10); + Q_EMIT sendLetterBtnList(m_letterList); + m_leaveAnimation->setTargetObject(m_appListView); + m_enterAnimation->setTargetObject(m_letterBtnWid); + m_leaveAnimation->start(); + m_widgetState = 1; +} + +/** + * 接收LetterButtonWidget界面按钮信号 + */ +void LetterWidget::recvLetterBtnSlot(QString btnname) +{ + //此处需实现将字母为btnname的应用列表移动到applistWid界面最顶端 + int num = m_letterList.indexOf(QString(QChar(btnname.at(0)))); + + if (num != -1) { + int row = m_letterBtnRowList.at(num).toInt(); + m_appListView->verticalScrollBar()->setValue(row); + } + + m_leaveAnimation->setStartValue(QRect((this->width() - 235) / 2, (this->height() - 366) / 2, 235, 366)); + m_leaveAnimation->setEndValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); +// m_enterAnimation->setStartValue(QRect(16,10,this->width()-20,this->height()-20)); + m_enterAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_enterAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_enterAnimation->setDuration(10); + m_leaveAnimation->setDuration(100); + m_leaveAnimation->setTargetObject(m_letterBtnWid); + m_enterAnimation->setTargetObject(m_appListView); + m_leaveAnimation->start(); + m_widgetState = 0; +} + +void LetterWidget::animationFinishedSLot() +{ + if (m_widgetState == 1) { + m_enterAnimation->start(); + m_widgetState = -1; + m_appListView->hide(); + m_letterBtnWid->show(); + } + + if (m_widgetState == 0) { + m_enterAnimation->start(); + m_widgetState = -1; + m_letterBtnWid->hide(); + m_appListView->show(); + } +} + +void LetterWidget::widgetMakeZero() +{ + m_letterBtnWid->hide(); + m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->show(); + m_appListView->verticalScrollBar()->setValue(0); +} + +void LetterWidget::moveScrollBar(int type) +{ + if (type == 0) { + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() - 100); + } else { + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() + 100); + } +} + +void LetterWidget::repaintWidget() +{ + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->show(); +} + +void LetterWidget::setFocusToThis() +{ + this->setFocus(); +} diff --git a/src/LetterWidget/letterwidget.h b/src/LetterWidget/letterwidget.h new file mode 100644 index 0000000..215dbdd --- /dev/null +++ b/src/LetterWidget/letterwidget.h @@ -0,0 +1,128 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include "letterbuttonwidget.h" +#include "src/UtilityFunction/listview.h" +#include "src/UtilityFunction/itemdelegate.h" + +class LetterWidget : public QWidget +{ + Q_OBJECT + +public: + explicit LetterWidget(QWidget *parent=nullptr); + ~LetterWidget(); + /** + * @brief Initializes the interface state + */ + void widgetMakeZero(); + /** + * @brief Move the scroll bar + * @param type: Scroll way,Only the following parameters can be entered: + * 0: moving up + * 1: moving down + */ + void moveScrollBar(int type); + /** + * @brief Repaint window + */ + void repaintWidget(); + +private: + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + LetterButtonWidget* m_letterBtnWid=nullptr; + ListView* m_appListView=nullptr; + QVector m_data; + QStringList m_letterList; + QStringList m_letterBtnRowList; + + /*Interface switching animation*/ + QPropertyAnimation* m_enterAnimation=nullptr; + QPropertyAnimation* m_leaveAnimation=nullptr; + int m_widgetState=-1; + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + /** + * @brief Initialize the application list interface + */ + void initAppListWidget(); + /** + * @brief fill application list + */ + void fillAppListView(); + +public Q_SLOTS: + /** + * @brief Switch to the alphabetic classification button interface + */ + void appClassificationBtnClickedSlot(); + /** + * @brief Receive alphabetic classification button interface signal + * @param Category button name + */ + void recvLetterBtnSlot(QString btnname); + /** + * @brief Open the application + * @param arg: Desktop file path + */ + void execApplication(QString desktopfp); + /** + * @brief Update application list slot function + */ + void updateAppListView(); + /** + * @brief Respond to the list item click + * @param arg: The desktop file information that the application contains + */ + void recvItemClickedSlot(QStringList arg); + /** + * @brief Respond to animation finish + */ + void animationFinishedSLot(); + + void setFocusToThis(); + +Q_SIGNALS: + /** + * @brief Send alphabetic classification list to the letterbuttonwidget + * @param list: Alphabetic classification list + */ + void sendLetterBtnList(QStringList list); + /** + * @brief Send a hidden main window signal to the MainViewWidget + */ + void sendHideMainWindowSignal(); + void sendMainWinActiveSignal(bool flag); +}; + +#endif // LETTERWIDGET_H diff --git a/src/BackProcess/FileWatcher/directory_changed_thread.cpp b/src/MainViewWidget/directorychangedthread.cpp similarity index 59% rename from src/BackProcess/FileWatcher/directory_changed_thread.cpp rename to src/MainViewWidget/directorychangedthread.cpp index 3ef8938..d261771 100644 --- a/src/BackProcess/FileWatcher/directory_changed_thread.cpp +++ b/src/MainViewWidget/directorychangedthread.cpp @@ -16,19 +16,23 @@ * */ -#include "directory_changed_thread.h" +#include "directorychangedthread.h" #include #include -#include "utility.h" +#include "src/UtilityFunction/utility.h" -DirectoryChangedThread::DirectoryChangedThread() +DirectoryChangedThread::DirectoryChangedThread(QObject *parent): + QThread(parent) { m_ukuiMenuInterface = new UkuiMenuInterface; } DirectoryChangedThread::~DirectoryChangedThread() { - delete m_ukuiMenuInterface; + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } } void DirectoryChangedThread::run() @@ -37,33 +41,26 @@ void DirectoryChangedThread::run() openDataBase("DirectoryChangedThread"); QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath(); - if (desktopfpList.size() > UkuiMenuInterface::desktopfpVector.size()) { //有新的应用安装 + if (desktopfpList.size() >= UkuiMenuInterface::m_desktopfpVector.size()) { //有新的应用安装 for (int i = 0; i < desktopfpList.count(); i++) { - if (!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i))) { + if (!UkuiMenuInterface::m_desktopfpVector.contains(desktopfpList.at(i))) { QFileInfo fileInfo(desktopfpList.at(i)); QString desktopfn = fileInfo.fileName(); updateDataBaseTableRecent(desktopfn); - break; + //break; } } } else { //软件卸载 - for (int i = 0; i < UkuiMenuInterface::desktopfpVector.size(); i++) { - if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) { - QString desktopfp = UkuiMenuInterface::appInfoVector.at(i).at(0); + for (int i = 0; i < UkuiMenuInterface::m_desktopfpVector.size(); i++) { + if (!desktopfpList.contains(UkuiMenuInterface::m_desktopfpVector.at(i))) { + QString desktopfp = UkuiMenuInterface::m_appInfoVector.at(i).at(0); QFileInfo fileInfo(desktopfp); QString desktopfn = fileInfo.fileName(); deleteAppRecord(desktopfn); - break; + // break; } } } - myDebug() << "DirectoryChangedThread::run()"; - UkuiMenuInterface::appInfoVector.clear(); - UkuiMenuInterface::alphabeticVector.clear(); - UkuiMenuInterface::functionalVector.clear(); - UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); - UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT requestUpdateSignal(); } diff --git a/src/BackProcess/FileWatcher/directory_changed_thread.h b/src/MainViewWidget/directorychangedthread.h similarity index 92% rename from src/BackProcess/FileWatcher/directory_changed_thread.h rename to src/MainViewWidget/directorychangedthread.h index da6130c..ef4ac44 100644 --- a/src/BackProcess/FileWatcher/directory_changed_thread.h +++ b/src/MainViewWidget/directorychangedthread.h @@ -21,13 +21,13 @@ #include #include #include -#include "ukuimenuinterface.h" +#include "src/Interface/ukuimenuinterface.h" class DirectoryChangedThread: public QThread { Q_OBJECT public: - DirectoryChangedThread(); + DirectoryChangedThread(QObject *parent = nullptr); ~DirectoryChangedThread(); void run(); diff --git a/src/MainViewWidget/mainviewwidget.cpp b/src/MainViewWidget/mainviewwidget.cpp new file mode 100644 index 0000000..3e0e9ca --- /dev/null +++ b/src/MainViewWidget/mainviewwidget.cpp @@ -0,0 +1,1012 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +MainViewWidget::MainViewWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +MainViewWidget::~MainViewWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void MainViewWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setAttribute(Qt::WA_TranslucentBackground); + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->setContentsMargins(0, 0, 0, 0); + mainLayout->setSpacing(0); + m_topWidget = new QWidget(this); + m_contentWid = new QWidget(this); + mainLayout->addWidget(m_topWidget); + mainLayout->addWidget(m_contentWid); + this->setLayout(mainLayout); + this->setFocusPolicy(Qt::NoFocus); + m_commonUseWid = new CommonUseWidget(m_contentWid); + m_fullCommonUseWid = new FullCommonUseWidget(m_contentWid); + m_letterWid = new LetterWidget(m_contentWid); + m_functionWid = new FunctionWidget(m_contentWid); + m_fullLetterWid = new FullLetterWidget(m_contentWid); + m_fullFunctionWid = new FullFunctionWidget(m_contentWid); + m_fullSearchResultWid = new FullSearchResultWidget(m_contentWid); + m_searchResultWid = new SearchResultWidget(m_contentWid); + hideWidget(); + m_ukuiMenuInterface = new UkuiMenuInterface; + //监控.desktop文件目录 + m_fileWatcher = new QFileSystemWatcher(this); + m_fileWatcher->addPaths(QStringList() << QString("/usr/share/applications") + << QString(QDir::homePath() + "/.local/share/applications/") + << QString("/var/lib/snapd/desktop/applications/") + << QString("/var/lib/flatpak/exports/share/applications/")); + connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &MainViewWidget::directoryChangedSlot); + m_directoryChangedThread = new DirectoryChangedThread(this); + connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &MainViewWidget::requestUpdateSlot); + connect(this, &MainViewWidget::directoryChangedSignal, m_letterWid, &LetterWidget::updateAppListView); + connect(this, &MainViewWidget::directoryChangedSignal, m_fullLetterWid, &FullLetterWidget::updateAppListView); + connect(this, &MainViewWidget::directoryChangedSignal, m_functionWid, &FunctionWidget::updateAppListView); + connect(this, &MainViewWidget::directoryChangedSignal, m_fullFunctionWid, &FullFunctionWidget::updateAppListView); + connect(this, &MainViewWidget::directoryChangedSignal, m_commonUseWid, &CommonUseWidget::updateListViewSlot); + connect(this, &MainViewWidget::directoryChangedSignal, m_fullCommonUseWid, &FullCommonUseWidget::updateListViewSlot); + connect(this, &MainViewWidget::selectFirstItem, m_commonUseWid, &CommonUseWidget::selectFirstItem); + connect(this, &MainViewWidget::selectFirstItem, m_fullCommonUseWid, &FullCommonUseWidget::selectFirstItem); + connect(this, &MainViewWidget::selectFirstItemTab, m_commonUseWid, &CommonUseWidget::selectFirstItemTab); + connect(this, &MainViewWidget::selectFirstItemTab, m_letterWid, &LetterWidget::setFocusToThis); + connect(this, &MainViewWidget::selectFirstItemTab, m_functionWid, &FunctionWidget::setFocusToThis); + connect(this, &MainViewWidget::selectFirstItemTab, m_fullCommonUseWid, &FullCommonUseWidget::selectFirstItemTab); + connect(this, &MainViewWidget::selectFirstItemTab, m_fullLetterWid, &FullLetterWidget::setFocusToThis); + connect(this, &MainViewWidget::selectFirstItemTab, m_fullFunctionWid, &FullFunctionWidget::setFocusToThis); + connect(this, &MainViewWidget::setSlideBar, m_fullCommonUseWid, &FullCommonUseWidget::onSetSlider); + connect(m_fullLetterWid, &FullLetterWidget::setFocusToSideWin, this, &MainViewWidget::setFocusToSideWin); + connect(m_fullFunctionWid, &FullFunctionWidget::setFocusToSideWin, this, &MainViewWidget::setFocusToSideWin); + //发送隐藏主界面信号 + connect(m_commonUseWid, &CommonUseWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_fullCommonUseWid, &FullCommonUseWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_letterWid, &LetterWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_fullLetterWid, &FullLetterWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_functionWid, &FunctionWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_fullFunctionWid, &FullFunctionWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_searchResultWid, &SearchResultWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_fullSearchResultWid, &FullSearchResultWidget::sendHideMainWindowSignal, this, &MainViewWidget::sendHideMainWindowSignal); + connect(m_commonUseWid, &CommonUseWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); + connect(m_functionWid, &FunctionWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); + connect(m_letterWid, &LetterWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); + addTopControl(); + //加载默认视图 + //搜索区 + this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh); + m_topWidget->setFixedSize(this->width(), Style::defaultTopWidHeight); + m_topLayout->setContentsMargins(0, 0, 0, 0); + m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter); + m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth, Style::defaultQueryLineEditHeight); + m_queryText->adjustSize(); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, + m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_queryWid->show(); + //内容区 + m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); + m_commonUseWid->setGeometry(0, 0, Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_commonUseWid->show(); + m_widgetState = 1; + m_saveCurrentWidState = 1; + //监控应用进程开启 + connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [ = ](WId id) { + ConvertDesktopToWinId reply; + QString desktopfp = reply.tranIdToDesktop(id); + + if (!desktopfp.isEmpty()) { + ViewOpenedSlot(desktopfp); + } + }); + + //监控图标主题与字体变化 + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + m_gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit(), QByteArray(), this); + connect(m_gsetting, &QGSettings::changed, [ = ](QString key) { + if (key == "iconThemeName" || key == "icon-theme-name") { + Q_EMIT directoryChangedSignal(); + } + + if (key == "systemFont" || key == "systemFontSize") { + repaintWidget(); + repaintTextline(); + } + }); + } +} + +/** + * 添加顶部控件 + */ +void MainViewWidget::addTopControl() +{ + m_topLayout = new QHBoxLayout; + m_topLayout->setSpacing(0); + m_queryLineEdit = new MyLineEdit(this); + m_queryLineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); + m_queryLineEdit->setAttribute(Qt::WA_KeyCompression); + m_topLayout->addWidget(m_queryLineEdit); + m_topWidget->setLayout(m_topLayout); + QPalette linePe = m_queryLineEdit->palette(); + QColor colorDark = linePe.color(QPalette::Dark); + QColor colorLight = linePe.color(QPalette::Light); + QString queryLineStyle; + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.get("style-name").toString() == "ukui-light") { + queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + } else { + queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + + m_queryLineEdit->setStyleSheet(queryLineStyle); + initQueryLineEdit(); +} + +//void MainViewWidget::focusInEvent(QFocusEvent *event) +//{ +// Q_UNUSED(event); +// if(this->hasFocus()) +// { +// this->focusNextChild(); +// } +// return QWidget::focusInEvent(event); +//} + +/** + * 添加搜索框 + */ +void MainViewWidget::initQueryLineEdit() +{ + m_queryWid = new QWidget(m_queryLineEdit); + m_queryWid->setFocusPolicy(Qt::NoFocus); + QHBoxLayout *queryWidLayout = new QHBoxLayout; + queryWidLayout->setContentsMargins(0, 0, 0, 0); + queryWidLayout->setSpacing(5); + m_queryWid->setLayout(queryWidLayout); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + } + + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_queryIcon = new QLabel(this); + m_queryIcon->setFixedSize(pixmap.size()); + m_queryIcon->setPixmap(pixmap); + m_queryText = new QLabel(this); + m_queryText->setText(tr("Search")); + queryWidLayout->addWidget(m_queryIcon); + queryWidLayout->addWidget(m_queryText); + queryWidLayout->setAlignment(m_queryIcon, Qt::AlignVCenter); + queryWidLayout->setAlignment(m_queryText, Qt::AlignVCenter); + m_queryLineEdit->setFocusPolicy(Qt::ClickFocus); + m_queryLineEdit->installEventFilter(this); + m_queryLineEdit->setContextMenuPolicy(Qt::NoContextMenu); + m_animation = new QPropertyAnimation(m_queryWid, "geometry", this); + m_animation->setDuration(100); + connect(m_animation, &QPropertyAnimation::finished, this, &MainViewWidget::animationFinishedSlot); + m_searchAppThread = new SearchAppThread(this); + connect(this, &MainViewWidget::sendSearchKeyword, + m_searchAppThread, &SearchAppThread::recvSearchKeyword); + connect(m_searchAppThread, &SearchAppThread::sendSearchResult, + this, &MainViewWidget::recvSearchResult); + connect(m_queryLineEdit, &MyLineEdit::textChanged, this, &MainViewWidget::searchAppSlot); +} + +bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_queryLineEdit) { + if ((m_queryIcon->x() == 0) && + (event->type() == QEvent::MouseButtonPress || + event->type() == QEvent::InputMethod)) { + if (m_queryLineEdit->text().isEmpty() || (m_queryWid->layout()->count() != 2)) { + QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn)); + return false; + } + } + + QPalette linePe = m_queryLineEdit->palette(); + QColor colorDark = linePe.color(QPalette::Dark); + QColor colorLight = linePe.color(QPalette::Light); + QString queryLineStyle; + + if (event->type() == QEvent::FocusIn && m_queryLineEdit->hasFocus()) { + if (!m_isFullScreen) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.get("style-name").toString() == "ukui-light") { + queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditClickedDefaultBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + } else { + queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + } else { + queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditClickedBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + + m_queryLineEdit->setStyleSheet(queryLineStyle); + + if (!m_queryLineEdit->text().isEmpty() && (m_queryLineEdit->text().size() >= 1)) { + if (m_searchKeyWords.isEmpty()) { + searchAppSlot(m_queryLineEdit->text()); + } + } else { + m_queryWid->layout()->removeWidget(m_queryText); + m_queryText->setParent(nullptr); + m_animation->stop(); + m_animation->setStartValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, + m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_animation->setEndValue(QRect(0, 0, + m_queryIcon->width() + 5, Style::QueryLineEditHeight)); + m_animation->setEasingCurve(QEasingCurve::OutQuad); + m_animation->start(); + m_queryLineEdit->setTextMargins(-5, 0, 0, 0); + } + + m_isSearching = true; + } else if (event->type() == QEvent::FocusOut) { + m_searchKeyWords.clear(); + + if (m_queryLineEdit->text().isEmpty()) { + if (m_isSearching || m_queryLineEdit->hasFocus()) { + if (!m_isFullScreen) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.get("style-name").toString() == "ukui-light") { + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + } else { + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + } else { + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + + m_queryLineEdit->setStyleSheet(queryLineStyle); + m_animation->stop(); + m_queryText->adjustSize(); + m_animation->setStartValue(QRect(0, 0, + m_queryIcon->width() + 5, Style::QueryLineEditHeight)); + m_animation->setEndValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, + m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_animation->setEasingCurve(QEasingCurve::InQuad); + m_animation->start(); + } + } else { + if (!m_isFullScreen) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.get("style-name").toString() == "ukui-light") { + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedDefaultBackground).arg(QueryLineEditDefaultBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + } else { + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + } else { + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + + m_queryLineEdit->setStyleSheet(queryLineStyle); + } + + m_isSearching = false; + } + } + + return QWidget::eventFilter(watched, event); // 最后将事件交给上层对话框 +} + +void MainViewWidget::setLineEditFocus(QString arg) +{ + if (!m_queryLineEdit->hasFocus()) { + m_searchKeyWords = arg; + m_queryLineEdit->setFocus(); + + if (!m_queryLineEdit->text().isEmpty()) { + m_queryLineEdit->setText(arg); + } + } +} + +void MainViewWidget::repaintTextline() +{ + m_queryWid->layout()->removeWidget(m_queryIcon); + m_queryIcon->setParent(nullptr); + m_queryWid->layout()->removeWidget(m_queryText); + m_queryText->setParent(nullptr); + m_queryWid->layout()->addWidget(m_queryIcon); + m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); +} + +/** + * 搜索程序和文件槽函数 + */ +void MainViewWidget::searchAppSlot(QString arg) +{ + //切换至搜索模块 + if (!arg.isEmpty()) { + if (m_widgetState != 0) { + m_widgetState = 0; + + if (!m_isFullScreen) { + loadSearchResultWidget(); + } else { + loadFullSearchResultWidget(); + } + } + + // 如果搜索时依然还有搜索框和搜索的文字描述两个组件,则进行处理;置为搜索状态 + if (m_queryWid->layout()->count() == 2) { + QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn)); + m_queryWid->layout()->removeWidget(m_queryText); + m_queryText->setParent(nullptr); + m_animation->stop(); + m_animation->setStartValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, + m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_animation->setEndValue(QRect(0, 0, + m_queryIcon->width() + 5, Style::QueryLineEditHeight)); + m_animation->setEasingCurve(QEasingCurve::OutQuad); + m_animation->start(); + m_queryLineEdit->setTextMargins(-5, 0, 0, 0); + } + + myDebug() << QTime::currentTime() << "m_queryWid(x, y) = (" << m_queryWid->x() << "," << m_queryWid->y() << ")"; + Q_EMIT sendSearchKeyword(arg); + m_searchAppThread->start(); + } else { //搜索模块显示所有的软件 + if (m_isFullScreen) { + switch (m_saveCurrentWidState) { + case 1: + loadFullCommonUseWidget(); + break; + + case 2: + loadFullLetterWidget(); + break; + + case 3: + loadFullFunctionWidget(); + + default: + break; + } + } else { + switch (m_saveCurrentWidState) { + case 1: + loadCommonUseWidget(); + break; + + case 2: + loadLetterWidget(); + break; + + case 3: + loadFunctionWidget(); + break; + + default: + break; + } + } + } +} + +void MainViewWidget::recvSearchResult(QVector arg) +{ + m_searchAppThread->quit(); +// m_searchAppThread->wait(); + m_fullSearchResultWid->updateAppListView(arg); + m_searchResultWid->updateAppListView(arg); +} + +void MainViewWidget::animationFinishedSlot() +{ + //进入搜索状态 + if (m_isSearching) { + // m_queryWid->layout()->removeWidget(m_queryText); + // m_queryText->setParent(nullptr); + m_queryLineEdit->setTextMargins(20, 0, 0, 0); + + if (!m_searchKeyWords.isEmpty()) { + m_queryLineEdit->setText(m_searchKeyWords); + m_searchKeyWords.clear(); + } + } + //退出搜索状态 + else { + m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + QPalette pe = m_queryText->palette(); + + if (!m_isFullScreen) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + //反黑 + if (gsetting.get("style-name").toString() == "ukui-light") { + pe.setColor(QPalette::Text, QColor(Qt::black)); + } else { + pe.setColor(QPalette::Text, QColor(Qt::white)); + } + } else { + pe.setColor(QPalette::Text, QColor(Qt::white)); + } + + m_queryText->setPalette(pe); + } +} + +/** + * 加载默认主视图 + */ +void MainViewWidget::loadMinMainView() +{ + this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh); + //搜索区 + m_topWidget->setFixedSize(this->width(), Style::defaultTopWidHeight); + m_topLayout->setContentsMargins(0, 0, 0, 0); + m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter); + m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth, Style::defaultQueryLineEditHeight); + + if (m_queryLineEdit->text().isEmpty()) { + if (m_queryWid->layout()->count() == 1) { + m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + } + + m_queryText->adjustSize(); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, + m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_queryWid->show(); + } + + QPalette linePe = m_queryLineEdit->palette(); + QColor colorDark = linePe.color(QPalette::Dark); + QColor colorLight = linePe.color(QPalette::Light); + QString queryLineStyle; + QPalette pe = m_queryText->palette(); + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.get("style-name").toString() == "ukui-light") { + pixmap = drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pe.setColor(QPalette::Text, QColor(Qt::black)); + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pe.setColor(QPalette::Text, QColor(Qt::white)); + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + + m_queryLineEdit->setStyleSheet(queryLineStyle); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_queryIcon->setPixmap(pixmap); + m_queryText->setPalette(pe); + //内容区 + m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); + + if (m_widgetState == 0) { + loadSearchResultWidget(); + } else if (m_widgetState == 1) { + loadCommonUseWidget(); + } else if (m_widgetState == 2) { + loadLetterWidget(); + } else if (m_widgetState == 3) { + loadFunctionWidget(); + } + + m_isFullScreen = false; +} + +/** + * 加载全屏主视图 + */ +void MainViewWidget::loadMaxMainView() +{ + this->setFixedSize(Style::MainViewWidWidth, + Style::heightavailable); + myDebug() << "width" << this->width() << "height" << this->height(); + //搜索区 + m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight); + m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight); + m_topLayout->setContentsMargins((m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2 + Style::LeftWidWidth, + 0, + (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2, + 0); + + if (m_queryLineEdit->text().isEmpty()) { + if (m_queryWid->layout()->count() == 1) { + m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + } + + m_queryText->adjustSize(); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, + m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_queryWid->show(); + } + + QPalette linePe = m_queryLineEdit->palette(); + QColor colorLight = linePe.color(QPalette::Light); + QString queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + m_queryLineEdit->setStyleSheet(queryLineStyle); + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); + pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + QPalette pe = m_queryText->palette(); + pe.setColor(QPalette::Text, QColor(Qt::white)); + m_queryText->setPalette(pe); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_queryIcon->setPixmap(pixmap); + //内容区 + m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); + myDebug() << "m_contentWid size" << m_contentWid->size() << "m_widgetState" << m_widgetState; + + if (m_widgetState == 0) { + loadFullSearchResultWidget(); + } else if (m_widgetState == 1) { + loadFullCommonUseWidget(); + } else if (m_widgetState == 2) { + loadFullLetterWidget(); + } else if (m_widgetState == 3) { + loadFullFunctionWidget(); + } + + m_isFullScreen = true; +} + +void MainViewWidget::resizeControl() +{ + if (m_isFullScreen) { + if (m_widgetState == 2) { + m_fullLetterWid->setLetterBtnGeometry(); + } + + if (m_widgetState == 3) { + m_fullFunctionWid->setFunctionBtnGeometry(); + } + + this->setFixedSize(Style::MainViewWidWidth, + Style::heightavailable); + m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight); + m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight); + m_topLayout->setContentsMargins((m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2 + Style::LeftWidWidth, + 0, + (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2, + 0); + m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); + myDebug() << "void MainViewWidget::resizeControl()" << m_contentWid->size(); + } else { + this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh); + m_topWidget->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultTopWidHeight); + m_topLayout->setContentsMargins(0, 0, 0, 0); + m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter); + m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); + } +} + +void MainViewWidget::resetQueryLine() +{ + if (!m_queryLineEdit->text().isEmpty()) { + m_queryLineEdit->clear(); + m_isSearching = false; + + if (m_queryWid->layout()->count() == 1) { + m_queryWid->layout()->addWidget(m_queryText); + m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + } + + m_queryText->adjustSize(); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, + m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + QPalette linePe = m_queryLineEdit->palette(); + QColor colorDark = linePe.color(QPalette::Dark); + QColor colorLight = linePe.color(QPalette::Light); + QString queryLineStyle; + const auto ratio = devicePixelRatioF(); + QPalette pe = m_queryText->palette(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); + + if (!m_isFullScreen) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.get("style-name").toString() == "ukui-light") { + pixmap = drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pe.setColor(QPalette::Text, QColor(Qt::black)); + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pe.setColor(QPalette::Text, QColor(Qt::white)); + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + } + } else { + queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). + arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). + arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pe.setColor(QPalette::Text, QColor(Qt::white)); + } + + m_queryLineEdit->setStyleSheet(queryLineStyle); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_queryIcon->setPixmap(pixmap); + m_queryText->setPalette(pe); + } +} + +/** + * 加载常用分类界面 + */ +void MainViewWidget::loadCommonUseWidget() +{ + m_fullCommonUseWid->widgetMakeZero(); + m_letterWid->widgetMakeZero(); + m_fullLetterWid->widgetMakeZero(); + m_functionWid->widgetMakeZero(); + m_fullFunctionWid->widgetMakeZero(); + hideWidget(); + m_commonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_commonUseWid->show(); + m_commonUseWid->updateListView(); + this->layout()->update(); + m_widgetState = 1; + m_saveCurrentWidState = 1; + resetQueryLine(); +} + +/** + * 加载字母分类界面 + */ +void MainViewWidget::loadLetterWidget() +{ + m_commonUseWid->widgetMakeZero(); + m_fullCommonUseWid->widgetMakeZero(); + m_fullLetterWid->widgetMakeZero(); + m_functionWid->widgetMakeZero(); + m_fullFunctionWid->widgetMakeZero(); + hideWidget(); + m_letterWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_letterWid->show(); + m_widgetState = 2; + m_saveCurrentWidState = 2; + resetQueryLine(); +} + +/** + * 加载功能分类界面 + */ +void MainViewWidget::loadFunctionWidget() +{ + m_commonUseWid->widgetMakeZero(); + m_fullCommonUseWid->widgetMakeZero(); + m_letterWid->widgetMakeZero(); + m_fullLetterWid->widgetMakeZero(); + m_fullFunctionWid->widgetMakeZero(); + hideWidget(); + m_functionWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_functionWid->show(); + m_widgetState = 3; + m_saveCurrentWidState = 3; + resetQueryLine(); +} + +/** + * 加载全屏常用分类界面 + */ +void MainViewWidget::loadFullCommonUseWidget() +{ + m_commonUseWid->widgetMakeZero(); + m_letterWid->widgetMakeZero(); + m_fullLetterWid->widgetMakeZero(); + m_functionWid->widgetMakeZero(); + m_fullFunctionWid->widgetMakeZero(); + hideWidget(); + m_fullCommonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + myDebug() << "m_fullCommonUseWid size" << m_fullCommonUseWid->size() << "mainViewWidget size" << this->size() << "m_topWidget size" << m_topWidget->size(); + m_fullCommonUseWid->show(); + m_fullCommonUseWid->updateListView(); + m_widgetState = 1; + m_saveCurrentWidState = 1; + resetQueryLine(); +} + +/** + * 加载全屏字母分类界面 + */ +void MainViewWidget::loadFullLetterWidget() +{ + m_commonUseWid->widgetMakeZero(); + m_fullCommonUseWid->widgetMakeZero(); + m_letterWid->widgetMakeZero(); + m_functionWid->widgetMakeZero(); + m_fullFunctionWid->widgetMakeZero(); + hideWidget(); + m_fullLetterWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_fullLetterWid->show(); +// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2)) + m_fullLetterWid->enterAnimation(); + m_widgetState = 2; + m_saveCurrentWidState = 2; + resetQueryLine(); +} + +/** + * 加载全屏功能分类界面 + */ +void MainViewWidget::loadFullFunctionWidget() +{ + m_commonUseWid->widgetMakeZero(); + m_fullCommonUseWid->widgetMakeZero(); + m_letterWid->widgetMakeZero(); + m_fullLetterWid->widgetMakeZero(); + m_functionWid->widgetMakeZero(); + hideWidget(); + m_fullFunctionWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_fullFunctionWid->show(); +// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3)) + m_fullFunctionWid->enterAnimation(); + m_widgetState = 3; + m_saveCurrentWidState = 3; + resetQueryLine(); +} + +void MainViewWidget::loadSearchResultWidget() +{ + hideWidget(); + m_searchResultWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_searchResultWid->show(); +} + +void MainViewWidget::loadFullSearchResultWidget() +{ + hideWidget(); + m_fullSearchResultWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_fullSearchResultWid->show(); +} + +void MainViewWidget::hideWidget() +{ + m_commonUseWid->hide(); + m_fullCommonUseWid->hide(); + m_letterWid->hide(); + m_fullLetterWid->hide(); + m_functionWid->hide(); + m_fullFunctionWid->hide(); + m_searchResultWid->hide(); + m_fullSearchResultWid->hide(); +} + +void MainViewWidget::changeFocuUp() +{ + this->focusPreviousChild(); +} + +void MainViewWidget::changeFocuDown() +{ + this->focusNextChild(); +} + +/** + * 进程开启监控槽函数 + */ +void MainViewWidget::ViewOpenedSlot(QString desktopfp) +{ + QVector desktopfpVec = UkuiMenuInterface::m_desktopfpVector; + + if (desktopfpVec.contains(desktopfp)) { + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + QString dateTimeKey; + dateTimeKey.clear(); + + if (!desktopfn.isEmpty()) { + updateDataBaseTableTimes(desktopfn); + } + } +} + +/** + * desktop文件目录改变信号槽 + */ +void MainViewWidget::directoryChangedSlot(const QString &path) +{ + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); + m_directoryChangedThread->start(); +} + +void MainViewWidget::requestUpdateSlot() +{ + m_directoryChangedThread->quit(); + UkuiMenuInterface::m_appInfoVector.clear(); + UkuiMenuInterface::m_alphabeticVector.clear(); + UkuiMenuInterface::m_functionalVector.clear(); + UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); + UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + Q_EMIT directoryChangedSignal(); +} + +void MainViewWidget::reloadUkuiMenu() +{ + Q_EMIT directoryChangedSignal(); +} + +void MainViewWidget::repaintWidget() +{ + this->setMinimumSize(Style::minw, Style::minh); + m_commonUseWid->repaintWidget(); + m_fullCommonUseWid->repaintWidget(); + m_letterWid->repaintWidget(); + m_fullLetterWid->repaintWidget(); + m_functionWid->repaintWidget(); + m_fullFunctionWid->repaintWidget(); + m_searchResultWid->repaintWidget(); + m_fullSearchResultWid->repaintWidget(); +} + +void MainViewWidget::repaintFullWidget() +{ + m_fullCommonUseWid->repaintWidget(); + m_fullLetterWid->repaintWidget(); + m_fullFunctionWid->repaintWidget(); + m_fullSearchResultWid->repaintWidget(); +} + +void MainViewWidget::widgetMakeZero() +{ + m_isSearching = false; + m_widgetState = m_saveCurrentWidState; + m_commonUseWid->widgetMakeZero(); + m_fullCommonUseWid->widgetMakeZero(); + m_letterWid->widgetMakeZero(); + m_fullLetterWid->widgetMakeZero(); + m_functionWid->widgetMakeZero(); + m_fullFunctionWid->widgetMakeZero(); + m_queryLineEdit->blockSignals(true); + m_queryLineEdit->clear(); + m_queryLineEdit->clearFocus(); + m_queryLineEdit->blockSignals(false); + m_queryLineEdit->setTextMargins(0, 0, 0, 0); +} + +void MainViewWidget::moveScrollBar(int type) +{ + if (m_widgetState == 0) { + if (m_isFullScreen) { + m_fullSearchResultWid->moveScrollBar(type); + } else { + m_searchResultWid->moveScrollBar(type); + } + } + + if (m_widgetState == 1) { + if (m_isFullScreen) { + m_fullCommonUseWid->moveScrollBar(type); + } else { + m_commonUseWid->moveScrollBar(type); + } + } + + if (m_widgetState == 2) { + if (m_isFullScreen) { + m_fullLetterWid->moveScrollBar(type); + } else { + m_letterWid->moveScrollBar(type); + } + } + + if (m_widgetState == 3) { + if (m_isFullScreen) { + m_fullFunctionWid->moveScrollBar(type); + } else { + m_functionWid->moveScrollBar(type); + } + } +} + +void MainViewWidget::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + if (e->key() == Qt::Key_Escape) { + Q_EMIT setMainWinHideSignal(); + } + + switch (e->key()) { + case Qt::Key_Enter : + case Qt::Key_Return : + case Qt::Key_Down : { + if (m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty()) { + if (m_isFullScreen) { + m_fullSearchResultWid->setViewFocus(); + } else { + m_searchResultWid->setViewFocus(); + } + } + } + break; + + default: + break; + } + } +} + +void MainViewWidget::setFocusToThis() +{ + this->setFocus(); + //// this->focusProxy(); +// m_fullLetterWid->letterButtonClick(); +// m_fullFunctionWid->functionButtonClick(); +} diff --git a/src/MainViewWidget/mainviewwidget.h b/src/MainViewWidget/mainviewwidget.h new file mode 100644 index 0000000..fe96abd --- /dev/null +++ b/src/MainViewWidget/mainviewwidget.h @@ -0,0 +1,293 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include "src/CommonUseWidget/commonusewidget.h" +#include "src/LetterWidget/letterwidget.h" +#include "src/FunctionWidget/functionwidget.h" +#include "src/CommonUseWidget/fullcommonusewidget.h" +#include "src/FunctionWidget/fullfunctionwidget.h" +#include "src/LetterWidget/fullletterwidget.h" +#include "src/SearchResultWidget/fullsearchresultwidget.h" +#include "src/SearchResultWidget/searchresultwidget.h" +#include "src/SearchResultWidget/searchappthread.h" +#include "src/UtilityFunction/convertdesktoptowinid.h" +#include "directorychangedthread.h" +#include "src/Style/style.h" + +class MyLineEdit : public QLineEdit +{ + Q_OBJECT + +public: + explicit MyLineEdit(QWidget *parent = nullptr) + { + unsetCursor(); + } + ~MyLineEdit() + { + if (m_focusEvent != nullptr) { + delete m_focusEvent; + m_focusEvent = nullptr; + } + + if (m_focusOut != nullptr) { + delete m_focusOut; + m_focusOut = nullptr; + } + } + + void simulateFocusOutEvent(QKeyEvent *e) + { + m_focusOut = new QEvent(QEvent::FocusOut); + QApplication::postEvent(this, m_focusOut); + m_focusEvent = new QFocusEvent(QEvent::FocusOut); + this->focusOutEvent(m_focusEvent); + } +private: + QFocusEvent *m_focusEvent = nullptr; + QEvent *m_focusOut = nullptr; +}; + +class MainViewWidget : public QWidget +{ + Q_OBJECT + +public: + explicit MainViewWidget(QWidget *parent = nullptr); + ~MainViewWidget(); + /** + * @brief Load the default main view + */ + void loadMinMainView(); + /** + * @brief Load the full screen main view + */ + void loadMaxMainView(); + /** + * @brief Initializes the interface state + */ + void widgetMakeZero(); + /** + * @brief Set the focus of the search box + * @param arg: Text + */ + void setLineEditFocus(QString arg); + /** + * @brief Repaint window + */ + void repaintWidget(); + /** + * @brief Only repaint full window + */ + void repaintFullWidget(); + /** + * @brief changeFocuUp + */ + void changeFocuUp(); + + /** + * @brief Move the scroll bar + * @param type: Scroll way,Only the following parameters can be entered: + * 0: moving up + * 1: moving down + */ + void moveScrollBar(int type); + /** + * @brief Resize the control + */ + void resizeControl(); + void reloadUkuiMenu(); + + void resetQueryLine(); + + MyLineEdit *getQueryLineEditer() + { + return m_queryLineEdit; + } + +private: + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QWidget *m_topWidget = nullptr; + QHBoxLayout *m_topLayout = nullptr; + + QWidget *m_contentWid = nullptr; + + MyLineEdit *m_queryLineEdit = nullptr; + QWidget *m_queryWid = nullptr; + QLabel *m_queryIcon = nullptr; + QLabel *m_queryText = nullptr; + bool m_isSearching = false; + QString m_searchKeyWords; + QPropertyAnimation *m_animation = nullptr; + + FullSearchResultWidget *m_fullSearchResultWid = nullptr; + SearchResultWidget *m_searchResultWid = nullptr; + SearchAppThread *m_searchAppThread = nullptr; + CommonUseWidget *m_commonUseWid = nullptr; + LetterWidget *m_letterWid = nullptr; + FunctionWidget *m_functionWid = nullptr; + FullCommonUseWidget *m_fullCommonUseWid = nullptr; + FullLetterWidget *m_fullLetterWid = nullptr; + FullFunctionWidget *m_fullFunctionWid = nullptr; + + DirectoryChangedThread *m_directoryChangedThread = nullptr; + + int m_widgetState = 1; //Classification window number + int m_saveCurrentWidState = -1; //Store the current category window number + + bool m_isFullScreen = false; +// bool m_isHiden=false; + + QFileSystemWatcher *m_fileWatcher = nullptr; //Monitor desktop folder status + + QGSettings *m_gsetting = nullptr; + + void repaintTextline(); + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + /** + * @brief Add a top window control + */ + void addTopControl(); + /** + * @brief Initializes the query box + */ + void initQueryLineEdit(); +// void paintEvent(QPaintEvent* event); + void loadSearchResultWidget(); + void loadFullSearchResultWidget(); + void hideWidget(); + void keyPressEvent(QKeyEvent *e); +// void focusInEvent(QFocusEvent *event); + +public Q_SLOTS: + /** + * @brief Search box focus event filtering + */ + bool eventFilter(QObject *watched, QEvent *event); + /** + * @brief Load the common classification interface + */ + void loadCommonUseWidget(); + /** + * @brief Load the letter classification interface + */ + void loadLetterWidget(); + /** + * @brief Load function classification interface + */ + void loadFunctionWidget(); + /** + * @brief Load full screen common classification interface + */ + void loadFullCommonUseWidget(); + /** + * @brief Load the full screen letter classification interface + */ + void loadFullLetterWidget(); + /** + * @brief Load the full screen function classification interface + */ + void loadFullFunctionWidget(); + /** + * @brief Respond to search box + * @param arg: Search keywords + */ + void searchAppSlot(QString arg); + /** + * @brief Respond to search box animation finish + */ + void animationFinishedSlot(); + /** + * @brief Monitor application startup + */ + void ViewOpenedSlot(QString desktopfp); + /** + * @brief Monitor desktop file directory changes + */ + void directoryChangedSlot(const QString &path); + /** + * @brief Receive search results + * @param arg: Search results + */ + void recvSearchResult(QVector arg); + /** + * @brief Monitor icon theme changes + * @param key: Key + */ + void requestUpdateSlot(); + + void setFocusToThis(); + + /** + * @brief changeFocuDown + */ + void changeFocuDown(); + +Q_SIGNALS: + /** + * @brief Desktop file directory change signal + */ + void directoryChangedSignal(); + /** + * @brief Send the search keyword to the SearchAppThread + * @param arg: Search keyword + */ + void sendSearchKeyword(QString arg); + /** + * @brief Send mounting and unmounting signals to DirectoryChangedThread + */ + void sendDirectoryPath(); + /** + * @brief Send a hidden main window signal to the MainViewWidget + */ + void sendHideMainWindowSignal(); + + void sendMainWinActiveSignal(bool flag); + + void setFocusToSideWin(); + + void selectFirstItem(); + + void selectFirstItemTab(); + + void setSlideBar(int value); + + void setMainWinHideSignal(); +}; + +#endif // MAINVIEWWIDGET_H diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp new file mode 100644 index 0000000..ff5ef81 --- /dev/null +++ b/src/MainWindow/mainwindow.cpp @@ -0,0 +1,622 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/Style/style.h" +#include "src/UtilityFunction/utility.h" +#include +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent) +{ + getCurrentCPU(); + openDataBase("MainThreadDataBase"); + initDatabase(); + m_softwareDbThread = new SoftwareDatabaseUpdateThread(this); + //获取软件商店类别信号 + QDBusConnection::sessionBus().connect("com.kylin.softwarecenter.getsearchresults", + "/com/kylin/softwarecenter/getsearchresults", + "com.kylin.getsearchresults", + "get_app_category_list_signal", + this, + SLOT(updateAppCategorySlot(QString)) + ); + m_ukuiMenuInterface = new UkuiMenuInterface; + UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); + UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::m_allAppVector = m_ukuiMenuInterface->getAllClassification(); + Style::initWidStyle(); + initUi(); + m_dbus = new DBus(this); + new MenuAdaptor(m_dbus); + QDBusConnection con = QDBusConnection::sessionBus(); + + if (!con.registerService("org.ukui.menu") || + !con.registerObject("/org/ukui/menu", m_dbus)) { + qDebug() << "error:" << con.lastError().message(); + } + + connect(m_dbus, &DBus::sendReloadSignal, this, [ = ] { + UkuiMenuInterface::m_appInfoVector.clear(); + UkuiMenuInterface::m_alphabeticVector.clear(); + UkuiMenuInterface::m_functionalVector.clear(); + + UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); + UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + Q_EMIT m_mainViewWid->reloadUkuiMenu(); + }); + connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { + if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); + + if (gsetting.keys().contains("winKeyRelease")) + if (gsetting.get("winKeyRelease").toBool()) { + return; + } + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit()); + + if (gsetting.keys().contains("isrunning")) + if (gsetting.get("isrunning").toBool()) { + return; + } + } + + if (this->isVisible()) + { + this->hide(); + m_mainViewWid->widgetMakeZero(); + } else + { + this->loadMainWindow(); + this->show(); + this->raise(); + this->activateWindow(); + } + }); +} + +MainWindow::~MainWindow() +{ + closeDataBase("MainThreadDataBase"); + + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void MainWindow::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); + this->setAttribute(Qt::WA_TranslucentBackground, true); + this->setAttribute(Qt::WA_InputMethodEnabled); + this->setAttribute(Qt::WA_KeyCompression); + this->setAutoFillBackground(false); + this->setFocusPolicy(Qt::NoFocus); + this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + this->setMinimumSize(Style::minw, Style::minh); + this->setContentsMargins(0, 0, 0, 0); + m_frame = new QFrame(this); + m_mainViewWid = new MainViewWidget(this); + m_sideBarWid = new SideBarWidget(this); + this->setCentralWidget(m_frame); + QHBoxLayout *mainlayout = new QHBoxLayout(this); + mainlayout->setContentsMargins(0, 0, 0, 0); + mainlayout->setSpacing(0); + m_frame->setLayout(mainlayout); + mainlayout->addWidget(m_mainViewWid); + m_line = new QFrame(this); + m_line->installEventFilter(this); + m_line->setFrameShape(QFrame::VLine); + m_line->setFixedSize(1, this->height() - 5); + m_line->setEnabled(false); + m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); + mainlayout->addWidget(m_line); + mainlayout->addWidget(m_sideBarWid); + m_sideBarWid->loadMinSidebar(); + m_mainViewWid->loadMinMainView(); + m_animation = new QPropertyAnimation(this, "geometry"); + connect(m_animation, &QPropertyAnimation::finished, this, &MainWindow::animationValueFinishedSlot); + connect(m_sideBarWid, &SideBarWidget::setFocusToMainWin, m_mainViewWid, &MainViewWidget::selectFirstItemTab); + connect(m_sideBarWid, &SideBarWidget::setLineEditFocus, m_mainViewWid, &MainViewWidget::setLineEditFocus); + connect(m_sideBarWid, &SideBarWidget::sendCommonUseBtnSignal, m_mainViewWid, &MainViewWidget::loadCommonUseWidget); + connect(m_sideBarWid, &SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget); + connect(m_sideBarWid, &SideBarWidget::sendFunctionBtnSignal, m_mainViewWid, &MainViewWidget::loadFunctionWidget); + connect(m_sideBarWid, &SideBarWidget::sendFullScreenCommonUseBtnSignal, + m_mainViewWid, &MainViewWidget::loadFullCommonUseWidget); + connect(m_sideBarWid, &SideBarWidget::sendFullScreenLetterBtnSignal, + m_mainViewWid, &MainViewWidget::loadFullLetterWidget); + connect(m_sideBarWid, &SideBarWidget::sendFullScreenFunctionBtnSignal, + m_mainViewWid, &MainViewWidget::loadFullFunctionWidget); + connect(m_sideBarWid, &SideBarWidget::setSlideBar, m_mainViewWid, &MainViewWidget::setSlideBar); + connect(m_sideBarWid, &SideBarWidget::sendFullScreenBtnSignal, this, &MainWindow::showFullScreenWidget); + connect(m_sideBarWid, &SideBarWidget::sendDefaultBtnSignal, this, &MainWindow::showDefaultWidget); + connect(m_sideBarWid, &SideBarWidget::sendShowMainWindowSignal, this, &MainWindow::activeWindowSolt); + connect(m_mainViewWid, &MainViewWidget::sendHideMainWindowSignal, this, &MainWindow::recvHideMainWindowSlot); + connect(m_sideBarWid, &SideBarWidget::sendHideMainWindowSignal, this, &MainWindow::recvHideMainWindowSlot); + connect(m_mainViewWid, &MainViewWidget::setFocusToSideWin, m_sideBarWid, &SideBarWidget::setFocusToThis); + connect(this, &MainWindow::setFocusSignal, m_mainViewWid, &MainViewWidget::selectFirstItem); + connect(m_mainViewWid, &MainViewWidget::sendMainWinActiveSignal, this, &MainWindow::activeWindowSolt); + connect(m_mainViewWid, &MainViewWidget::setMainWinHideSignal, this, &MainWindow::mainWinHideSlot); +// connect(QApplication::desktop(),&QDesktopWidget::resized,this, [=]{ +// repaintWidget(); +// }); +// connect(QApplication::desktop(),&QDesktopWidget::primaryScreenChanged,this,[=]{ +// repaintWidget(); +// }); +// connect(QApplication::desktop(),&QDesktopWidget::screenCountChanged,this,[=]{ +// repaintWidget(); +// }); + QDBusConnection::sessionBus().connect(DBUS_NAME, DBUS_PATH, DBUS_INTERFACE, QString("PanelGeometryRefresh"), this, SLOT(primaryScreenChangeSlot())); + + //监听屏幕缩放 + if (QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) { + QGSettings xsetting(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); + connect(&xsetting, &QGSettings::changed, this, [ = ](const QString & key) { + if (key == "scalingFactor") { + repaintWidget(); + } + }); + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { + QGSettings psetting(QString("org.ukui.panel.settings").toLocal8Bit()); + connect(&psetting, &QGSettings::changed, + this, &MainWindow::panelChangedSlot); + } +} + +void MainWindow::getCurrentCPU() +{ + QProcess *processCpuInfo = new QProcess(this); + processCpuInfo->start(QString("cat /proc/cpuinfo")); + connect(processCpuInfo, static_cast(&QProcess::finished), this, [ = ]() { + processCpuInfo->deleteLater(); + }); + processCpuInfo->waitForFinished(); + QString ctrCpuInfo = processCpuInfo->readAll(); + + if (ctrCpuInfo.indexOf("HUAWEI Kirin") != -1) { + isHuaWeiPC = true; + } + + if (ctrCpuInfo.indexOf("HUAWEI kirin 9006C") != -1) { + isHuaWei9006C = true; + } +} + +void MainWindow::paintEvent(QPaintEvent *event) +{ + double transparency = getTransparency(); + QRect rect = this->rect().adjusted(4, 3, -3, -3); + QPainterPath path; + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(Qt::transparent); + + if (!m_isFullScreen) { + qreal radius; + + if (projectCodeName == "V10SP2") { + radius = 12; + } else { + radius = 6; + } + + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawPath(path); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); + QColor color(Qt::black); + + for (int i = 0; i < 5; i++) { + rect = this->rect().adjusted(i, i, - i, - i); + color.setAlpha(transparency * (20 + (i * 10))); + painter.setBrush(Qt::NoBrush); + painter.setPen(QPen(color, 1)); + painter.drawRoundRect(rect, 6, 6); + } + } else { //全屏固定背景色(黑底白字) +// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) +// { +// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); +// if(gsetting.keys().contains(QString("effect"))) +// { +// if(gsetting.get("effect").toBool()) +// { +// painter.setBrush(Qt::black); +// painter.setPen(Qt::transparent); +// painter.setOpacity(0.25); +// painter.drawRect(this->rect()); +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); +// } + QPainterPath path; + path.addRect(this->rect()); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); + } + + QMainWindow::paintEvent(event); +} + +/** + * 显示全屏窗口 + */ +void MainWindow::showFullScreenWidget() +{ + m_isFullScreen = true; + this->setContentsMargins(0, 0, 0, 0); + int position = Style::panelPosition; + int x = Style::primaryScreenX; + int y = Style::primaryScreenY; + int width = Style::widthavailable; + int height = Style::heightavailable; + QRect startRect; + QRect endRect; + + if (position == BOTTOM) { + startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); + } else if (position == RIGHT) { + startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + } else { + startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + } + endRect.setRect(x, y, width, height); + + this->centralWidget()->layout()->removeWidget(m_mainViewWid); + m_mainViewWid->setParent(nullptr); + this->centralWidget()->layout()->removeWidget(m_line); + m_line->setParent(nullptr); + this->centralWidget()->layout()->removeWidget(m_sideBarWid); + m_sideBarWid->setParent(nullptr); + + if (isHuaWei9006C || isHuaWeiPC) { + is_repaint = false; + this->hide(); + QEventLoop loop; + QTimer::singleShot(150, &loop, SLOT(quit())); + loop.exec(); + m_animation->setDuration(1);//动画总时间 + m_animation->setStartValue(startRect); + m_animation->setEndValue(endRect); + m_animation->setEasingCurve(QEasingCurve::Linear); + m_animation->start(); + this->show(); + this->activateWindow(); + is_repaint = true; + } else { + m_animation->setDuration(100);//动画总时间 + m_animation->setStartValue(startRect); + m_animation->setEndValue(endRect); + m_animation->setEasingCurve(QEasingCurve::Linear); + m_animation->start(); + } +} + +void MainWindow::mouseReleaseEvent(QMouseEvent *event) +{ + if (m_isFullScreen && event->button() == Qt::LeftButton) { + this->hide(); + } +} + +void MainWindow::inputMethodEvent(QInputMethodEvent *event) +{ + QInputMethodEvent *iEvent = dynamic_cast(event); + m_mainViewWid->setLineEditFocus(iEvent->commitString()); + myDebug() << iEvent->commitString(); +} + + +/** + * 显示默认窗口 + */ +void MainWindow::showDefaultWidget() +{ + m_isFullScreen = false; + this->setContentsMargins(0, 0, 0, 0); + int position = Style::panelPosition; + int x = Style::primaryScreenX; + int y = Style::primaryScreenY; + int width = Style::widthavailable; + int height = Style::heightavailable; + QRect startRect; + QRect endRect; + + startRect.setRect(x, y, width, height); + if (position == BOTTOM) { + endRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); + } else if (position == RIGHT) { + endRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + } else { + endRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + } + + this->centralWidget()->layout()->removeWidget(m_mainViewWid); + m_mainViewWid->setParent(nullptr); + this->centralWidget()->layout()->removeWidget(m_sideBarWid); + m_sideBarWid->setParent(nullptr); + + if (isHuaWei9006C || isHuaWeiPC) { + this->setGeometry(endRect); + animationValueFinishedSlot(); + } else { + m_animation->setDuration(100);//动画总时间 + m_animation->setStartValue(startRect); + m_animation->setEndValue(endRect); + m_animation->setEasingCurve(QEasingCurve::Linear); + m_animation->start(); + } +} + +void MainWindow::animationValueChangedSlot(const QVariant &value) +{ + if (m_isFullScreen) { + QPainterPath path; + path.addRect(this->rect()); +// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); + } +} + +void MainWindow::animationValueFinishedSlot() +{ + if (m_isFullScreen) { + this->centralWidget()->layout()->addWidget(m_mainViewWid); + this->centralWidget()->layout()->addWidget(m_sideBarWid); + m_sideBarWid->loadMaxSidebar(); + m_mainViewWid->loadMaxMainView(); + m_sideBarWid->enterAnimation(); + } else { + this->centralWidget()->layout()->addWidget(m_mainViewWid); + this->centralWidget()->layout()->addWidget(m_line); + this->centralWidget()->layout()->addWidget(m_sideBarWid); + m_sideBarWid->loadMinSidebar(); + m_mainViewWid->loadMinMainView(); + } +} +void MainWindow::activeWindowSolt(bool flag) +{ +// qDebug() << "void MainWindow::activeWindowSolt(bool flag)"; + if (isHuaWei9006C || isHuaWeiPC) { + QTimer::singleShot(50, this, SLOT(mainWinShowSlot())); + } +} +void MainWindow::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + if ((e->key() >= 0x30 && e->key() <= 0x39) || (e->key() >= 0x41 && e->key() <= 0x5a)) { + m_mainViewWid->setLineEditFocus(e->text()); + } + } +} +void MainWindow::mainWinShowSlot() +{ + this->activateWindow(); + + if (!this->geometry().contains(QCursor::pos())) { + this->hide(); + } + + qDebug() << "void MainWindow::activeWindowSolt()"; +} +/** + * 鼠标点击窗口外部事件 + */ +bool MainWindow::event(QEvent *event) +{ + if (event->type() == QEvent::ActivationChange && is_repaint) + // if(QEvent::WindowDeactivate == event->type() && m_canHide)//窗口停用 + { + qDebug() << " * 鼠标点击窗口外部事件"; + + if (QApplication::activeWindow() != this) { + this->hide(); + m_mainViewWid->widgetMakeZero(); + } + } + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = (QKeyEvent *) event; + + if (keyEvent->key() == Qt::Key_Escape) { + this->hide(); + } + + if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || + keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || + keyEvent->key() == Qt::Key_Tab) { + m_mainViewWid->setFocus(); + Q_EMIT setFocusSignal(); + } + } + + return QWidget::event(event); +} +/** + * 隐藏窗口 + */ +void MainWindow::recvHideMainWindowSlot() +{ + this->hide(); +// m_mainViewWid->widgetMakeZero(); +// m_sideBarWid->widgetMakeZero(); +} +void MainWindow::loadMainWindow() +{ + cleanTimeoutApp(); + int position = Style::panelPosition; + int x = Style::primaryScreenX; + int y = Style::primaryScreenY; + int width = Style::widthavailable; + int height = Style::heightavailable; + this->setFocus(); + + if (m_isFullScreen) { + //修复界面黑框问题 + QRect startRect; + QRect endRect; + + if (position == BOTTOM) { + startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); + } else if (position == RIGHT) { + startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + } else { + startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + } + endRect.setRect(x, y, width, height); + + this->centralWidget()->layout()->removeWidget(m_mainViewWid); + m_mainViewWid->setParent(nullptr); + this->centralWidget()->layout()->removeWidget(m_line); + m_line->setParent(nullptr); + this->centralWidget()->layout()->removeWidget(m_sideBarWid); + m_sideBarWid->setParent(nullptr); + m_animation->setDuration(1);//动画总时间 + m_animation->setStartValue(startRect); + m_animation->setEndValue(endRect); + m_animation->setEasingCurve(QEasingCurve::Linear); + m_animation->start(); + } else { + if (position == BOTTOM) { + this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); + } else if (position == RIGHT) { + this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); + } + m_sideBarWid->loadMinSidebar(); + m_mainViewWid->loadMinMainView(); + } +} +void MainWindow::panelChangedSlot(QString key) +{ + Q_UNUSED(key); + repaintWidget(); +} +void MainWindow::primaryScreenChangeSlot() +{ + Style::initWidStyle(); + m_mainViewWid->repaintFullWidget(); + resizeWidget(); +} +void MainWindow::repaintWidget() +{ + Style::initWidStyle(); + this->setMinimumSize(Style::minw, Style::minh); + m_line->setFixedSize(1, this->height() - 1); + m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); + m_mainViewWid->repaintWidget(); + resizeWidget(); +} +void MainWindow::resizeWidget() +{ + if (QApplication::activeWindow() == this) { + int position = Style::panelPosition; + int x = Style::primaryScreenX; + int y = Style::primaryScreenY; + int width = Style::widthavailable; + int height = Style::heightavailable; + + if (m_isFullScreen) { + this->setGeometry(x, y, width, height); + m_sideBarWid->loadMaxSidebar(); + m_sideBarWid->setSideBarBtnGeometry(); + } else { + if (position == BOTTOM) { + this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); + } else if (position == RIGHT) { + this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); + } + m_sideBarWid->loadMinSidebar(); + } + m_mainViewWid->resizeControl(); + } +} +void MainWindow::mainWinHideSlot() +{ + this->hide(); + m_mainViewWid->widgetMakeZero(); +} +void MainWindow::updateAppCategorySlot(QString category) +{ + m_softwareDbThread->getDatabaseList(category); + m_softwareDbThread->start(); + connect(m_softwareDbThread, &SoftwareDatabaseUpdateThread::updateDatabaseSignal, this, &MainWindow::databaseThreadCloseSlot); +} +void MainWindow::databaseThreadCloseSlot() +{ + m_softwareDbThread->quit(); + UkuiMenuInterface::m_appInfoVector.clear(); + UkuiMenuInterface::m_functionalVector.clear(); + UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); + UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + m_mainViewWid->reloadUkuiMenu(); +} diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h new file mode 100644 index 0000000..401c6aa --- /dev/null +++ b/src/MainWindow/mainwindow.h @@ -0,0 +1,123 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include +#include +#include +#include +#include +#include "src/Style/style.h" +#include "src/SideBarWidget/sidebarwidget.h" +#include "src/MainViewWidget/mainviewwidget.h" +#include "src/DBus/dbus.h" +#include "src/DBus/dbus-adaptor.h" +#include "src/UtilityFunction/softwaredatabaseupdatethread.h" +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + /** + * @brief Load the main window + */ + void loadMainWindow(); + void getCurrentCPU(); + +private: + + bool m_isFullScreen = false; + bool m_winFlag = false; + bool is_repaint = true; + + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QFrame *m_line = nullptr; //Vertical dividing line + QFrame *m_frame = nullptr; + SideBarWidget *m_sideBarWid = nullptr; + MainViewWidget *m_mainViewWid = nullptr; + QPropertyAnimation *m_animation = nullptr; + DBus *m_dbus = nullptr; + SoftwareDatabaseUpdateThread *m_softwareDbThread = nullptr; + +protected: + void initUi(); + /** + * @brief Handle events clicking on the outside of the window + */ + bool event(QEvent *event); + void paintEvent(QPaintEvent *event); + /** + * @brief The query box responds to keyboard events + */ + + void repaintWidget(); + void resizeWidget(); + + void mouseReleaseEvent(QMouseEvent *event); + + void inputMethodEvent(QInputMethodEvent *event); + + void keyPressEvent(QKeyEvent *e); + +public Q_SLOTS: + /** + * @brief Load the full screen window + */ + void showFullScreenWidget(); + /** + * @brief Load the default window + */ + void showDefaultWidget(); + void recvHideMainWindowSlot();//接收隐藏主窗口信号 + /** + * @brief Monitor taskbar key changes + * @param key: Key + */ + void panelChangedSlot(QString key); + void animationValueChangedSlot(const QVariant &value);//动画当前值变化监控 + void animationValueFinishedSlot(); + void primaryScreenChangeSlot(); + void activeWindowSolt(bool flag); + void mainWinShowSlot(); + void mainWinHideSlot(); + void updateAppCategorySlot(QString category); + void databaseThreadCloseSlot(); + +public: +Q_SIGNALS: + void setFocusSignal(); +}; + +#endif // MAINWINDOW_H diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile index 16b48ba..f22ce73 100644 --- a/src/QtSingleApplication/QtLockedFile +++ b/src/QtSingleApplication/QtLockedFile @@ -1 +1,19 @@ +/* + * 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 #if defined(Q_OS_WIN) - #include - #include - typedef BOOL(WINAPI *PProcessIdToSessionId)(DWORD, DWORD *); - static PProcessIdToSessionId pProcessIdToSessionId = 0; +#include +#include +typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); +static PProcessIdToSessionId pProcessIdToSessionId = 0; #endif #if defined(Q_OS_UNIX) - #include - #include - #include +#include +#include +#include #endif -namespace QtLP_Private -{ +namespace QtLP_Private { #include "qtlockedfile.cpp" #if defined(Q_OS_WIN) - #include "qtlockedfile_win.cpp" +#include "qtlockedfile_win.cpp" #else - #include "qtlockedfile_unix.cpp" +#include "qtlockedfile_unix.cpp" #endif } -const char *QtLocalPeer::ack = "ack"; +const char* QtLocalPeer::ack = "ack"; -QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId) +QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) : QObject(parent), id(appId) { QString prefix = id; - if (id.isEmpty()) { id = QCoreApplication::applicationFilePath(); #if defined(Q_OS_WIN) @@ -80,30 +78,30 @@ QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId) #endif prefix = id.section(QLatin1Char('/'), -1); } - prefix.remove(QRegExp("[^a-zA-Z]")); prefix.truncate(6); + QByteArray idc = id.toUtf8(); quint16 idNum = qChecksum(idc.constData(), idc.size()); socketName = QLatin1String("qtsingleapp-") + prefix + QLatin1Char('-') + QString::number(idNum, 16); -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) if (!pProcessIdToSessionId) { QLibrary lib("kernel32"); pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); } - if (pProcessIdToSessionId) { DWORD sessionId = 0; pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); socketName += QLatin1Char('-') + QString::number(sessionId, 16); } - #else socketName += QLatin1Char('-') + QString::number(::getuid(), 16); #endif + socketName += qgetenv("DISPLAY"); + server = new QLocalServer(this); QString lockName = QDir(QDir::tempPath()).absolutePath() + QLatin1Char('/') + socketName @@ -116,29 +114,22 @@ QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId) bool QtLocalPeer::isClient() { - if (lockFile.isLocked()) { + if (lockFile.isLocked()) return false; - } - if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) { + if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) return true; - } bool res = server->listen(socketName); #if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) - // ### Workaround if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { - QFile::remove(QDir::cleanPath(QDir::tempPath()) + QLatin1Char('/') + socketName); + QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); res = server->listen(socketName); } - #endif - - if (!res) { + if (!res) qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); - } - QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); return false; } @@ -146,22 +137,17 @@ bool QtLocalPeer::isClient() bool QtLocalPeer::sendMessage(const QString &message, int timeout) { - if (!isClient()) { + if (!isClient()) return false; - } QLocalSocket socket; bool connOk = false; - - for (int i = 0; i < 2; i++) { + for(int i = 0; i < 2; i++) { // Try twice, in case the other instance is just starting up socket.connectToServer(socketName); - connOk = socket.waitForConnected(timeout / 2); - - if (connOk || i) { + connOk = socket.waitForConnected(timeout/2); + if (connOk || i) break; - } - int ms = 250; #if defined(Q_OS_WIN) Sleep(DWORD(ms)); @@ -170,35 +156,27 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout) nanosleep(&ts, NULL); #endif } - - if (!connOk) { + if (!connOk) return false; - } QByteArray uMsg(message.toUtf8()); QDataStream ds(&socket); ds.writeBytes(uMsg.constData(), uMsg.size()); bool res = socket.waitForBytesWritten(timeout); - if (res) { res &= socket.waitForReadyRead(timeout); // wait for ack - - if (res) { + if (res) res &= (socket.read(qstrlen(ack)) == ack); - } } - return res; } void QtLocalPeer::receiveConnection() { - QLocalSocket *socket = server->nextPendingConnection(); - - if (!socket) { + QLocalSocket* socket = server->nextPendingConnection(); + if (!socket) return; - } while (true) { if (socket->state() == QLocalSocket::UnconnectedState) { @@ -206,11 +184,8 @@ void QtLocalPeer::receiveConnection() delete socket; return; } - - if (socket->bytesAvailable() >= qint64(sizeof(quint32))) { + if (socket->bytesAvailable() >= qint64(sizeof(quint32))) break; - } - socket->waitForReadyRead(); } @@ -220,20 +195,17 @@ void QtLocalPeer::receiveConnection() ds >> remaining; uMsg.resize(remaining); int got = 0; - char *uMsgBuf = uMsg.data(); - + char* uMsgBuf = uMsg.data(); do { got = ds.readRawData(uMsgBuf, remaining); remaining -= got; uMsgBuf += got; } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); - if (got < 0) { qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); delete socket; return; } - QString message(QString::fromUtf8(uMsg)); socket->write(ack, qstrlen(ack)); socket->waitForBytesWritten(1000); diff --git a/src/QtSingleApplication/qtlocalpeer.h b/src/QtSingleApplication/qtlocalpeer.h index 4e63426..1b533b1 100644 --- a/src/QtSingleApplication/qtlocalpeer.h +++ b/src/QtSingleApplication/qtlocalpeer.h @@ -56,9 +56,7 @@ public: bool isClient(); bool sendMessage(const QString &message, int timeout); QString applicationId() const - { - return id; - } + { return id; } Q_SIGNALS: void messageReceived(const QString &message); @@ -69,11 +67,11 @@ protected Q_SLOTS: protected: QString id; QString socketName; - QLocalServer *server; + QLocalServer* server; QtLP_Private::QtLockedFile lockFile; private: - static const char *ack; + static const char* ack; }; #endif // QTLOCALPEER_H diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/src/QtSingleApplication/qtlockedfile.cpp index 2204343..c142a86 100644 --- a/src/QtSingleApplication/qtlockedfile.cpp +++ b/src/QtSingleApplication/qtlockedfile.cpp @@ -126,7 +126,6 @@ bool QtLockedFile::open(OpenMode mode) qWarning("QtLockedFile::open(): Truncate mode not allowed."); return false; } - return QFile::open(mode); } diff --git a/src/QtSingleApplication/qtlockedfile.h b/src/QtSingleApplication/qtlockedfile.h index e73d39a..84c18e5 100644 --- a/src/QtSingleApplication/qtlockedfile.h +++ b/src/QtSingleApplication/qtlockedfile.h @@ -43,27 +43,26 @@ #include #ifdef Q_OS_WIN - #include +#include #endif #if defined(Q_OS_WIN) - #if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) - #define QT_QTLOCKEDFILE_EXPORT - #elif defined(QT_QTLOCKEDFILE_IMPORT) - #if defined(QT_QTLOCKEDFILE_EXPORT) - #undef QT_QTLOCKEDFILE_EXPORT - #endif - #define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) - #elif defined(QT_QTLOCKEDFILE_EXPORT) - #undef QT_QTLOCKEDFILE_EXPORT - #define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) - #endif +# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) +# define QT_QTLOCKEDFILE_EXPORT +# elif defined(QT_QTLOCKEDFILE_IMPORT) +# if defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# endif +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) +# elif defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) +# endif #else - #define QT_QTLOCKEDFILE_EXPORT +# define QT_QTLOCKEDFILE_EXPORT #endif -namespace QtLP_Private -{ +namespace QtLP_Private { class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile { diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/src/QtSingleApplication/qtlockedfile_unix.cpp index 9e9a5a6..976c1b9 100644 --- a/src/QtSingleApplication/qtlockedfile_unix.cpp +++ b/src/QtSingleApplication/qtlockedfile_unix.cpp @@ -51,41 +51,31 @@ bool QtLockedFile::lock(LockMode mode, bool block) qWarning("QtLockedFile::lock(): file is not opened"); return false; } - - if (mode == NoLock) { + + if (mode == NoLock) return unlock(); - } - - if (mode == m_lock_mode) { + + if (mode == m_lock_mode) return true; - } - if (m_lock_mode != NoLock) { + if (m_lock_mode != NoLock) unlock(); - } struct flock fl; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; - fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; - int cmd = block ? F_SETLKW : F_SETLK; - int ret = fcntl(handle(), cmd, &fl); - + if (ret == -1) { - if (errno != EINTR && errno != EAGAIN) { + if (errno != EINTR && errno != EAGAIN) qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); - } - return false; } + m_lock_mode = mode; return true; } @@ -98,35 +88,28 @@ bool QtLockedFile::unlock() return false; } - if (!isLocked()) { + if (!isLocked()) return true; - } struct flock fl; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; - fl.l_type = F_UNLCK; - int ret = fcntl(handle(), F_SETLKW, &fl); - + if (ret == -1) { qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); return false; } - + m_lock_mode = NoLock; return true; } QtLockedFile::~QtLockedFile() { - if (isOpen()) { + if (isOpen()) unlock(); - } } diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/src/QtSingleApplication/qtlockedfile_win.cpp index 38500e4..6144ea7 100644 --- a/src/QtSingleApplication/qtlockedfile_win.cpp +++ b/src/QtSingleApplication/qtlockedfile_win.cpp @@ -47,7 +47,7 @@ #define MAX_READERS MAXIMUM_WAIT_OBJECTS #if QT_VERSION >= 0x050000 - #define QT_WA(unicode, ansi) unicode +#define QT_WA(unicode, ansi) unicode #endif Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) @@ -57,36 +57,28 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) mutexname = QString::fromLatin1(MUTEX_PREFIX) + fi.absoluteFilePath().toLower(); } - QString mname(mutexname); - - if (idx >= 0) { + if (idx >= 0) mname += QString::number(idx); - } Qt::HANDLE mutex; - if (doCreate) { - QT_WA({ mutex = CreateMutexW(NULL, FALSE, (TCHAR *)mname.utf16()); }, - { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); }); - + QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); if (!mutex) { qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); return 0; } - } else { - QT_WA({ mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR *)mname.utf16()); }, - { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); }); - + } + else { + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); if (!mutex) { - if (GetLastError() != ERROR_FILE_NOT_FOUND) { + if (GetLastError() != ERROR_FILE_NOT_FOUND) qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); - } - return 0; } } - return mutex; } @@ -94,20 +86,16 @@ bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) { Q_ASSERT(mutex); DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); - switch (res) { - case WAIT_OBJECT_0: - case WAIT_ABANDONED: - return true; - break; - - case WAIT_TIMEOUT: - break; - - default: - qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + return true; + break; + case WAIT_TIMEOUT: + break; + default: + qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); } - return false; } @@ -120,83 +108,61 @@ bool QtLockedFile::lock(LockMode mode, bool block) return false; } - if (mode == NoLock) { + if (mode == NoLock) return unlock(); - } - if (mode == m_lock_mode) { + if (mode == m_lock_mode) return true; - } - if (m_lock_mode != NoLock) { + if (m_lock_mode != NoLock) unlock(); - } - if (!wmutex && !(wmutex = getMutexHandle(-1, true))) { + if (!wmutex && !(wmutex = getMutexHandle(-1, true))) return false; - } - if (!waitMutex(wmutex, block)) { + if (!waitMutex(wmutex, block)) return false; - } if (mode == ReadLock) { int idx = 0; - for (; idx < MAX_READERS; idx++) { rmutex = getMutexHandle(idx, false); - - if (!rmutex || waitMutex(rmutex, false)) { + if (!rmutex || waitMutex(rmutex, false)) break; - } - CloseHandle(rmutex); } - bool ok = true; - if (idx >= MAX_READERS) { qWarning("QtLockedFile::lock(): too many readers"); rmutex = 0; ok = false; - } else if (!rmutex) { - rmutex = getMutexHandle(idx, true); - - if (!rmutex || !waitMutex(rmutex, false)) { - ok = false; - } } - + else if (!rmutex) { + rmutex = getMutexHandle(idx, true); + if (!rmutex || !waitMutex(rmutex, false)) + ok = false; + } if (!ok && rmutex) { CloseHandle(rmutex); rmutex = 0; } - ReleaseMutex(wmutex); - - if (!ok) { + if (!ok) return false; - } - } else { + } + else { Q_ASSERT(rmutexes.isEmpty()); - for (int i = 0; i < MAX_READERS; i++) { Qt::HANDLE mutex = getMutexHandle(i, false); - - if (mutex) { + if (mutex) rmutexes.append(mutex); - } } - if (rmutexes.size()) { DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), TRUE, block ? INFINITE : 0); - if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { - if (res != WAIT_TIMEOUT) { + if (res != WAIT_TIMEOUT) qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); - } - m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky unlock(); return false; @@ -215,20 +181,19 @@ bool QtLockedFile::unlock() return false; } - if (!isLocked()) { + if (!isLocked()) return true; - } if (m_lock_mode == ReadLock) { ReleaseMutex(rmutex); CloseHandle(rmutex); rmutex = 0; - } else { - Q_FOREACH (Qt::HANDLE mutex, rmutexes) { + } + else { + Q_FOREACH(Qt::HANDLE mutex, rmutexes) { ReleaseMutex(mutex); CloseHandle(mutex); } - rmutexes.clear(); ReleaseMutex(wmutex); } @@ -239,11 +204,8 @@ bool QtLockedFile::unlock() QtLockedFile::~QtLockedFile() { - if (isOpen()) { + if (isOpen()) unlock(); - } - - if (wmutex) { + if (wmutex) CloseHandle(wmutex); - } } diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/src/QtSingleApplication/qtsingleapplication.cpp index 961677e..3c3788e 100644 --- a/src/QtSingleApplication/qtsingleapplication.cpp +++ b/src/QtSingleApplication/qtsingleapplication.cpp @@ -40,15 +40,14 @@ #include "qtsingleapplication.h" -#include "src/UtilityFunction/utility.h" #include "qtlocalpeer.h" #include #include #include #include #include -#include "mainwindow.h" -#include "tabletwindow.h" +#include "src/MainWindow/mainwindow.h" +#include "src/UtilityFunction/utility.h" /*! @@ -347,22 +346,16 @@ QWidget *QtSingleApplication::activationWindow() const void QtSingleApplication::activateWindow() { if (actWin) { - if (!g_projectCodeName.contains("V10SP1-edu")) { + if (this->applicationState() & Qt::ApplicationInactive) { MainWindow *w = qobject_cast(actWin); - - if (this->applicationState() & Qt::ApplicationInactive) { - actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); - // actWin->raise(); - // actWin->showNormal(); - // actWin->activateWindow(); - w->showWindow(); - } else { - actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized); - w->hideWindow(); - } + w->loadMainWindow(); + actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); + actWin->raise(); + actWin->showNormal(); + actWin->activateWindow(); } else { - TabletWindow *w = qobject_cast(actWin); - w->showPCMenu(); + actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized); + actWin->hide(); } } } diff --git a/src/QtSingleApplication/qtsingleapplication.h b/src/QtSingleApplication/qtsingleapplication.h index 3bbc700..0b36bea 100644 --- a/src/QtSingleApplication/qtsingleapplication.h +++ b/src/QtSingleApplication/qtsingleapplication.h @@ -46,19 +46,19 @@ class QtLocalPeer; #if defined(Q_OS_WIN) - #if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) - #define QT_QTSINGLEAPPLICATION_EXPORT - #elif defined(QT_QTSINGLEAPPLICATION_IMPORT) - #if defined(QT_QTSINGLEAPPLICATION_EXPORT) - #undef QT_QTSINGLEAPPLICATION_EXPORT - #endif - #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) - #elif defined(QT_QTSINGLEAPPLICATION_EXPORT) - #undef QT_QTSINGLEAPPLICATION_EXPORT - #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) - #endif +# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) +# define QT_QTSINGLEAPPLICATION_EXPORT +# elif defined(QT_QTSINGLEAPPLICATION_IMPORT) +# if defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# endif +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) +# elif defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) +# endif #else - #define QT_QTSINGLEAPPLICATION_EXPORT +# define QT_QTSINGLEAPPLICATION_EXPORT #endif class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication @@ -71,24 +71,21 @@ public: #if QT_VERSION < 0x050000 QtSingleApplication(int &argc, char **argv, Type type); # if defined(Q_WS_X11) - QtSingleApplication(Display *dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); - QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); - QtSingleApplication(Display *dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); + QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); + QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); + QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); # endif // Q_WS_X11 #endif // QT_VERSION < 0x050000 bool isRunning(); QString id() const; - void setActivationWindow(QWidget *aw, bool activateOnMessage = true); - QWidget *activationWindow() const; + void setActivationWindow(QWidget* aw, bool activateOnMessage = true); + QWidget* activationWindow() const; // Obsolete: void initialize(bool dummy = true) - { - isRunning(); - Q_UNUSED(dummy) - } + { isRunning(); Q_UNUSED(dummy) } public Q_SLOTS: bool sendMessage(const QString &message, int timeout = 5000); @@ -99,7 +96,7 @@ Q_SIGNALS: void messageReceived(const QString &message); protected: - // bool notify(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + // bool notify(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; private: void sysInit(const QString &appId = QString()); diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/src/QtSingleApplication/qtsinglecoreapplication.cpp index d06a75b..5634537 100644 --- a/src/QtSingleApplication/qtsinglecoreapplication.cpp +++ b/src/QtSingleApplication/qtsinglecoreapplication.cpp @@ -74,7 +74,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this); - connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &))); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); } @@ -87,7 +87,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this, appId); - connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &))); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); } diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/src/QtSingleApplication/qtsinglecoreapplication.h index 571b37d..b87fffe 100644 --- a/src/QtSingleApplication/qtsinglecoreapplication.h +++ b/src/QtSingleApplication/qtsinglecoreapplication.h @@ -59,12 +59,13 @@ public: public Q_SLOTS: bool sendMessage(const QString &message, int timeout = 5000); + Q_SIGNALS: void messageReceived(const QString &message); private: - QtLocalPeer *peer; + QtLocalPeer* peer; }; #endif // QTSINGLECOREAPPLICATION_H diff --git a/src/RightClickMenu/menubox.cpp b/src/RightClickMenu/menubox.cpp new file mode 100644 index 0000000..ac4597d --- /dev/null +++ b/src/RightClickMenu/menubox.cpp @@ -0,0 +1,53 @@ +/* + * 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 +#include +#include +#include + +MenuBox::MenuBox(QWidget *parent): + QMenu(parent) +{ + this->activateWindow(); +} + +void MenuBox::mousePressEvent(QMouseEvent *event) +{ + this->activateWindow(); + Q_EMIT sendMainWinActiveSignal(true); + return QMenu::mousePressEvent(event); +} + +//void MenuBox::mouseReleaseEvent(QMouseEvent *event) +//{ +// Q_UNUSED(event); +// this->activateWindow(); +// Q_EMIT sendMainWinActiveSignal(true); +// if(this->geometry().contains(QCursor::pos())) +// { +// return QMenu::mousePressEvent(event); +// } +// else +// { +// this->raise(); +// this->activateWindow(); +// } + +// return QMenu::mouseReleaseEvent(event); +//} diff --git a/src/BackProcess/FileWatcher/software_database_update_thread.h b/src/RightClickMenu/menubox.h similarity index 62% rename from src/BackProcess/FileWatcher/software_database_update_thread.h rename to src/RightClickMenu/menubox.h index 51d7d8d..caa87ba 100644 --- a/src/BackProcess/FileWatcher/software_database_update_thread.h +++ b/src/RightClickMenu/menubox.h @@ -15,31 +15,33 @@ * along with this program; if not, see #include -#include -#include -#include -#include -#include -#include -class SoftwareDatabaseUpdateThread:public QThread +class MenuBox : public QMenu { Q_OBJECT public: - SoftwareDatabaseUpdateThread(); - ~SoftwareDatabaseUpdateThread(); - void run(); - void getDatabaseList(QString category); + MenuBox(QWidget *parent = nullptr); + +protected: + + void mousePressEvent(QMouseEvent *event); + +// void mouseReleaseEvent(QMouseEvent *event); + +// void focusInEvent(QFocusEvent *event); + +// void focusOutEvent(QFocusEvent *event); +public: Q_SIGNALS: - void updateDatabaseSignal(); + void sendMainWinActiveSignal(bool flag); + private: - QString m_category; + bool isFocusIn = false; }; -#endif // SOFTWAREDATABASEUPDATETHREAD_H +#endif // MENUBOX_H diff --git a/src/UserInterface/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp similarity index 53% rename from src/UserInterface/RightClickMenu/rightclickmenu.cpp rename to src/RightClickMenu/rightclickmenu.cpp index 45f7b46..b9e4bb3 100644 --- a/src/UserInterface/RightClickMenu/rightclickmenu.cpp +++ b/src/RightClickMenu/rightclickmenu.cpp @@ -18,37 +18,23 @@ #include "rightclickmenu.h" #include "src/UtilityFunction/utility.h" +#include "uninstallwhitelist.h" #include RightClickMenu::RightClickMenu(QWidget *parent): QWidget(parent) { - m_cmdProc = new QProcess; - m_whiteList.append("kylin-screenshot.desktop"); - m_whiteList.append("ukui-notebook.desktop"); - m_whiteList.append("ukui-clock.desktop"); - m_whiteList.append("kylin-calculator.desktop"); - m_whiteList.append("kylin-recorder.desktop"); - m_whiteList.append("kylin-software-center.desktop"); - m_whiteList.append("kylin-camera.desktop"); - m_whiteList.append("biometric-manager.desktop"); - m_whiteList.append("yhkylin-backup-tools.desktop"); - m_whiteList.append("box-manager.desktop"); - m_whiteList.append("ukui-system-monitor.desktop"); - m_whiteList.append("ksc-defender.desktop"); - m_whiteList.append("logview.desktop"); - m_whiteList.append("kylin-service-support.desktop"); - m_whiteList.append("kylin-user-guide.desktop"); - m_whiteList.append("ukui-control-center.desktop"); - m_whiteList.append("peony.desktop"); - m_whiteList.append("engrampa.desktop"); + m_cmdProc = new QProcess(this); + m_whiteList = UninstallWhitelist::getInstance()->getWhiteList(); m_ukuiMenuInterface = new UkuiMenuInterface; } RightClickMenu::~RightClickMenu() { - delete m_cmdProc; - delete m_ukuiMenuInterface; + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } } QPixmap RightClickMenu::getIconPixmap(QString iconstr, int type) @@ -84,40 +70,43 @@ void RightClickMenu::unfixedFromAllActionTriggerSlot() updateDataBaseTableType(desktopfn, 0); } -void RightClickMenu::pincToCollectionActionTriggerSlot() -{ - QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); - QStringList appList = getCollectAppList(); - updateDataBaseCollect(desktopfn, appList.size() + 1); - m_actionNumber = 18; -} - -void RightClickMenu::removeFromCollectionActionTriggerSlot() -{ - QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); - updateDataBaseCollect(desktopfn, 0); - m_actionNumber = 18; -} - void RightClickMenu::fixToTaskbarActionTriggerSlot() { - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret = iface.call("AddToTaskbar", m_desktopfp); + QProcess *process = new QProcess(); + process->start(QString("dpkg -s ukui-panel")); + process->waitForFinished(); + QString str = process->readAll(); + delete process; + + QList strList = str.split('\n'); + QString version; + for(int i = 0; i < strList.size(); i++) { + if(strList.at(i).startsWith("Version")) { + version = strList.at(i); + version = version.mid(version.indexOf(" ") + 1); + break; + } + } + + if (version.startsWith("3.0")) { + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); + } else { + QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "AddToTaskbar"); + message << m_desktopfp; + QDBusConnection::sessionBus().send(message); + } m_actionNumber = 3; } void RightClickMenu::unfixedFromTaskbarActionTriggerSlot() { - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret = iface.call("RemoveFromTaskbar", m_desktopfp); + QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "RemoveFromTaskbar"); + message << m_desktopfp; + QDBusConnection::sessionBus().send(message); m_actionNumber = 4; } @@ -141,11 +130,28 @@ void RightClickMenu::addToDesktopActionTriggerSlot() void RightClickMenu::uninstallActionTriggerSlot() { +// if(!checkOsRelease()) +// { QString cmd = QString("kylin-uninstaller %1") .arg(m_desktopfp.toLocal8Bit().data()); bool ret = QProcess::startDetached(cmd); myDebug() << "卸载:" << cmd << ret; myDebug() << "kylin-uninstaller"; +// } +// else +// { +// QString cmd=QString("dpkg -S "+m_desktopfp); +// m_cmdProc->start("sh",QStringList()<<"-c"<waitForFinished(); +// QString output=m_cmdProc->readAllStandardOutput().trimmed(); +// QString packageName=output.split(":").at(0); +// cmd.clear(); +// cmd=QString("kylin-installer -remove %1") +// .arg(packageName.toLocal8Bit().data()); +// bool ret=QProcess::startDetached(cmd); +// qDebug()<<"卸载:"<m_desktopfp = desktopfp; MenuBox m_showAppMenu; connect(&m_showAppMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); - // m_showAppMenu.setWindowFlag(Qt::Popup); + m_showAppMenu.setWindowFlag(Qt::Popup); //添加菜单项,指定图标、名称、响应函数 QFileInfo fileInfo(desktopfp); QString desktopfn = fileInfo.fileName(); @@ -216,13 +222,7 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from all"), this, SLOT(unfixedFromAllActionTriggerSlot())); - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret = iface.call("CheckIfExist", desktopfp); - - if (!ret) + if (!checkIfFixedToTaskbar(desktopfn)) m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to taskbar"), this, SLOT(fixToTaskbarActionTriggerSlot())); else @@ -231,15 +231,6 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) m_showAppMenu.addAction(tr("Add to desktop shortcuts"), this, SLOT(addToDesktopActionTriggerSlot())); - - if (!checkIfCollected(desktopfn)) { - m_showAppMenu.addAction(tr("Pin to collection"), - this, SLOT(pincToCollectionActionTriggerSlot())); - } else { - m_showAppMenu.addAction(tr("Remove from collection"), - this, SLOT(removeFromCollectionActionTriggerSlot())); - } - //检查桌面快捷方式是否存在 QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QString path = QString(desktopPath + "/" + QFileInfo(m_desktopfp).fileName()); @@ -257,7 +248,6 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) m_showAppMenu.setAttribute(Qt::WA_TranslucentBackground); m_showAppMenu.setAttribute(Qt::WA_DeleteOnClose); m_showAppMenu.exec(pos); - qDebug() << "RightClickMenu::showAppBtnMenu(QString desktopfp)"; return m_actionNumber; } @@ -266,57 +256,19 @@ int RightClickMenu::showShutdownMenu(const QPoint &pos) m_actionNumber = 0; MenuBox m_showShutMenu; connect(&m_showShutMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); - QDBusInterface iface(DBUS_SESSION_NAME, DBUS_SESSION_PATH, - DBUS_SESSION_INTERFACE, QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("canSwitch"); - - if (reply.isValid() && reply.value() == true) { - m_showShutMenu.addAction(QIcon(getIconPixmap("stock-people-symbolic", 1)), tr("Switch user"), - this, SLOT(switchUserActionTriggerSlot())); - } - - reply = iface.call("canHibernate"); - - if (reply.isValid() && reply.value() == true) { - m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-sleep-symbolic", 1)), tr("Hibernate"), - this, SLOT(hibernateActionTriggerSlot())); - } - - reply = iface.call("canSuspend"); - - if (reply.isValid() && reply.value() == true) { - m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic", 1)), tr("Sleep"), - this, SLOT(sleepActionTriggerSlot())); - } - - m_showShutMenu.addAction(QIcon(getIconPixmap("system-lock-screen-symbolic", 1)), tr("Lock Screen"), - this, SLOT(lockScreenActionTriggerSlot())); - reply = iface.call("canLogout"); - - if (reply.isValid() && reply.value() == true) { - m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic", 1)), tr("Log Out"), - this, SLOT(logoutActionTriggerSlot())); - } - - reply = iface.call("canReboot"); - - if (reply.isValid() && reply.value() == true) { - m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic", 1)), tr("Restart"), - this, SLOT(rebootActionTriggerSlot())); - } - - reply = iface.call("canPowerOff"); - - if (reply.isValid() && reply.value() == true) { - m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic", 1)), tr("Power Off"), - this, SLOT(shutdownActionTriggerSlot())); - } - + m_showShutMenu.setWindowFlag(Qt::Popup); + m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic", 1)), tr("Sleep"), + this, SLOT(hibernateActionTriggerSlot())); //休眠睡眠相同 + m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic", 1)), tr("Log Out"), + this, SLOT(logoutActionTriggerSlot())); + m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic", 1)), tr("Restart"), + this, SLOT(rebootActionTriggerSlot())); + m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic", 1)), tr("Power Off"), + this, SLOT(shutdownActionTriggerSlot())); m_showShutMenu.setAttribute(Qt::WA_TranslucentBackground); m_showShutMenu.setAttribute(Qt::WA_DeleteOnClose); m_showShutMenu.raise(); m_showShutMenu.exec(pos); - myDebug() << "RightClickMenu::showShutdownMenu()"; return m_actionNumber; } @@ -327,23 +279,59 @@ int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) this->m_desktopfp = desktopfp; MenuBox m_showOtherMenu; connect(&m_showOtherMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); - // m_showOtherMenu.setWindowFlag(Qt::Popup); - // QDBusInterface iface("com.ukui.panel.desktop", - // "/", - // "com.ukui.panel.desktop", - // QDBusConnection::sessionBus()); - // QDBusReply ret=iface.call("CheckIfExist",this->m_desktopfp); - // if(!ret) - // menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"), - // this,SLOT(fixToTaskbarActionTriggerSlot())); - // else - // menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"), - // this,SLOT(unfixedFromTaskbarActionTriggerSlot())); + m_showOtherMenu.setWindowFlag(Qt::Popup); +// QDBusInterface iface("com.ukui.panel.desktop", +// "/", +// "com.ukui.panel.desktop", +// QDBusConnection::sessionBus()); +// QDBusReply ret=iface.call("CheckIfExist",this->m_desktopfp); +// if(!ret) +// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"), +// this,SLOT(fixToTaskbarActionTriggerSlot())); +// else +// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"), +// this,SLOT(unfixedFromTaskbarActionTriggerSlot())); m_showOtherMenu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg", 0)), tr("Personalize this list"), this, SLOT(otherListActionTriggerSlot())); m_showOtherMenu.setAttribute(Qt::WA_TranslucentBackground); m_showOtherMenu.setAttribute(Qt::WA_DeleteOnClose); m_showOtherMenu.exec(pos); - qDebug() << "RightClickMenu::showOtherMenu(QString desktopfp)"; return m_actionNumber; } + +QList > RightClickMenu::getTaskbarFixedList() +{ + QSettings settings(QDir::homePath() + "/.config/ukui/panel.conf", QSettings::IniFormat); + QList > array; + int size = settings.beginReadArray("/taskbar/apps"); + + for (int i = 0; i < size; ++i) { + settings.setArrayIndex(i); + QMap hash; + const auto keys = settings.childKeys(); + + for (const QString &key : keys) { + hash[key] = settings.value(key); + } + + array << hash; + } + + return array; +} + +bool RightClickMenu::checkIfFixedToTaskbar(const QString &desktopfp) +{ + QString fixdDesktop; + const auto apps = getTaskbarFixedList(); + + for (const QMap &app : apps) { + fixdDesktop = app.value("desktop", "").toString(); + + if (fixdDesktop.contains(desktopfp)) { + return true; + } + } + + return false; +} diff --git a/src/UserInterface/RightClickMenu/rightclickmenu.h b/src/RightClickMenu/rightclickmenu.h similarity index 92% rename from src/UserInterface/RightClickMenu/rightclickmenu.h rename to src/RightClickMenu/rightclickmenu.h index a96c65d..2177159 100644 --- a/src/UserInterface/RightClickMenu/rightclickmenu.h +++ b/src/RightClickMenu/rightclickmenu.h @@ -34,13 +34,10 @@ #include #include #include -#include "ukuimenuinterface.h" -#include "style.h" +#include "src/Interface/ukuimenuinterface.h" +#include "src/Style/style.h" #include "menubox.h" - -#define DBUS_SESSION_NAME "org.gnome.SessionManager" -#define DBUS_SESSION_PATH "/org/gnome/SessionManager" -#define DBUS_SESSION_INTERFACE "org.gnome.SessionManager" +#include class RightClickMenu : public QWidget { @@ -147,8 +144,10 @@ private Q_SLOTS: * @brief Personalize this list */ void otherListActionTriggerSlot(); - void pincToCollectionActionTriggerSlot(); - void removeFromCollectionActionTriggerSlot(); + + QList > getTaskbarFixedList(); + + bool checkIfFixedToTaskbar(const QString &desktopfp); public: Q_SIGNALS: diff --git a/src/RightClickMenu/uninstallwhitelist.cpp b/src/RightClickMenu/uninstallwhitelist.cpp new file mode 100644 index 0000000..51e5cbe --- /dev/null +++ b/src/RightClickMenu/uninstallwhitelist.cpp @@ -0,0 +1,84 @@ +/* + * 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 + +UninstallWhitelist *UninstallWhitelist::instance = nullptr; + +UninstallWhitelist::UninstallWhitelist() +{ + m_whiteList.append("kylin-screenshot.desktop"); + m_whiteList.append("ukui-notebook.desktop"); + m_whiteList.append("ukui-clock.desktop"); + m_whiteList.append("kylin-calculator.desktop"); + m_whiteList.append("kylin-recorder.desktop"); + m_whiteList.append("kylin-software-center.desktop"); + m_whiteList.append("kylin-camera.desktop"); + m_whiteList.append("biometric-manager.desktop"); + m_whiteList.append("yhkylin-backup-tools.desktop"); + m_whiteList.append("box-manager.desktop"); + m_whiteList.append("ukui-system-monitor.desktop"); + m_whiteList.append("ksc-defender.desktop"); + m_whiteList.append("logview.desktop"); + m_whiteList.append("kylin-service-support.desktop"); + m_whiteList.append("kylin-user-guide.desktop"); + m_whiteList.append("ukui-control-center.desktop"); + m_whiteList.append("peony.desktop"); + m_whiteList.append("engrampa.desktop"); + + if (isHuaWei9006C || isHuaWeiPC) { + m_whiteList.append("org.gnome.FileRoller.desktop"); + m_whiteList.append("mate-terminal.desktop"); + m_whiteList.append("hwaudioui.desktop"); + } +} + +UninstallWhitelist *UninstallWhitelist::getInstance() +{ + if (instance == nullptr) { + instance = new UninstallWhitelist(); + } + + return instance; +} + +QStringList UninstallWhitelist::getPkgNameWhiteList() +{ + QStringList pkgNameList; + + Q_FOREACH (QString desktop, m_whiteList) { + QProcess *processPkgName = new QProcess(); + processPkgName->start(QString("dpkg -S /usr/share/applications/%1").arg(desktop)); + connect(processPkgName, static_cast(&QProcess::finished), this, [ = ]() { + processPkgName->deleteLater(); + }); + processPkgName->waitForFinished(); + QString pkgName = processPkgName->readAll(); + pkgName = pkgName.left(pkgName.indexOf(":")); + pkgNameList.append(pkgName); + } + + return pkgNameList; +} + +QStringList UninstallWhitelist::getWhiteList() +{ + return m_whiteList; +} diff --git a/src/RightClickMenu/uninstallwhitelist.h b/src/RightClickMenu/uninstallwhitelist.h new file mode 100644 index 0000000..a478292 --- /dev/null +++ b/src/RightClickMenu/uninstallwhitelist.h @@ -0,0 +1,47 @@ +/* + * 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 + +class UninstallWhitelist : public QObject +{ + Q_OBJECT + +public: + static UninstallWhitelist *getInstance(); + /** + * @brief 获取不可卸载包名列表 + * @return + */ + QStringList getPkgNameWhiteList(); + /** + * @brief 获取不可卸载desktop列表 + * @return + */ + QStringList getWhiteList(); +private: + UninstallWhitelist(); +private: + static UninstallWhitelist *instance; + + QStringList m_whiteList; +}; + +#endif // UNINSTALLWHITELIST_H diff --git a/src/BackProcess/Search/file-utils.cpp b/src/SearchResultWidget/file-utils.cpp similarity index 68% rename from src/BackProcess/Search/file-utils.cpp rename to src/SearchResultWidget/file-utils.cpp index 81130d7..06f1bf9 100644 --- a/src/BackProcess/Search/file-utils.cpp +++ b/src/SearchResultWidget/file-utils.cpp @@ -22,42 +22,39 @@ #include "file-utils.h" #include +using namespace Zeeker; QMap FileUtils::map_chinese2pinyin = QMap(); -FileUtils::FileUtils() -{ +FileUtils::FileUtils() { } -void FileUtils::loadHanziTable(const QString &fileName) -{ +void FileUtils::loadHanziTable(const QString &fileName) { QFile file(fileName); - - if (!file.open(QFile::ReadOnly | QFile::Text)) { + if(!file.open(QFile::ReadOnly | QFile::Text)) { qDebug("File: '%s' open failed!", file.fileName().toStdString().c_str()); return; } /* 读取汉字对照表文件并转换为QMap存储 */ - while (!file.atEnd()) { + while(!file.atEnd()) { QString content = QString::fromUtf8(file.readLine()); FileUtils::map_chinese2pinyin[content.split(" ").last().trimmed()] = content.split(" ").first().split(","); } file.close(); + return; } //DFS多音字太多直接GG -void stitchMultiToneWordsDFS(const QString &hanzi, const QString &resultAllPinYin, const QString &resultFirst, QStringList &resultList) -{ - if (hanzi.size() == 0) { +void stitchMultiToneWordsDFS(const QString& hanzi, const QString& resultAllPinYin, const QString& resultFirst, QStringList& resultList) { + if(hanzi.size() == 0) { resultList.append(resultAllPinYin); resultList.append(resultFirst); return; } - - if (FileUtils::map_chinese2pinyin.contains(hanzi.at(0))) { - for (auto i : FileUtils::map_chinese2pinyin[hanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(hanzi.at(0))) { + for(auto i : FileUtils::map_chinese2pinyin[hanzi.at(0)]) { stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), resultAllPinYin + i, resultFirst + i.at(0), resultList); } } else { @@ -66,119 +63,98 @@ void stitchMultiToneWordsDFS(const QString &hanzi, const QString &resultAllPinYi } //BFS+Stack多音字太多会爆栈 -void stitchMultiToneWordsBFSStack(const QString &hanzi, QStringList &resultList) -{ +void stitchMultiToneWordsBFSStack(const QString& hanzi, QStringList& resultList) { QString tempHanzi, resultAllPinYin, resultFirst; QQueue tempQueue; tempHanzi = hanzi; int tempQueueSize = 0; - - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(i); } } else { tempQueue.enqueue(tempHanzi.at(0)); } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - - while (tempHanzi.size() != 0) { + while(tempHanzi.size() != 0) { tempQueueSize = tempQueue.size(); - - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (int j = 0; j < tempQueueSize; ++j) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(int j = 0; j < tempQueueSize; ++j) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(tempQueue.head() + i); } - tempQueue.dequeue(); } } else { - for (int j = 0; j < tempQueueSize; ++j) { + for(int j = 0; j < tempQueueSize; ++j) { tempQueue.enqueue(tempQueue.head() + tempHanzi.at(0)); tempQueue.dequeue(); } } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - - while (!tempQueue.empty()) { + while(!tempQueue.empty()) { resultList.append(tempQueue.dequeue()); } } //BFS+Heap,多音字太多会耗尽内存 -void stitchMultiToneWordsBFSHeap(const QString &hanzi, QStringList &resultList) -{ +void stitchMultiToneWordsBFSHeap(const QString& hanzi, QStringList& resultList) { QString tempHanzi, resultAllPinYin, resultFirst; - QQueue *tempQueue = new QQueue; + QQueue* tempQueue = new QQueue; tempHanzi = hanzi; int tempQueueSize = 0; - - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(i); } } else { tempQueue->enqueue(tempHanzi.at(0)); } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - - while (tempHanzi.size() != 0) { + while(tempHanzi.size() != 0) { tempQueueSize = tempQueue->size(); - - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (int j = 0; j < tempQueueSize; ++j) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(int j = 0; j < tempQueueSize; ++j) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(tempQueue->head() + i); } - tempQueue->dequeue(); } } else { - for (int j = 0; j < tempQueueSize; ++j) { + for(int j = 0; j < tempQueueSize; ++j) { tempQueue->enqueue(tempQueue->head() + tempHanzi.at(0)); tempQueue->dequeue(); } } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - - while (!tempQueue->empty()) { + while(!tempQueue->empty()) { resultList.append(tempQueue->dequeue()); } - delete tempQueue; tempQueue = nullptr; } //BFS+Heap+超过3个多音字只建一个索引,比较折中的方案 -void stitchMultiToneWordsBFSHeapLess3(const QString &hanzi, QStringList &resultList) -{ +void stitchMultiToneWordsBFSHeapLess3(const QString& hanzi, QStringList& resultList) { QString tempHanzi, resultAllPinYin, resultFirst; - QQueue *tempQueue = new QQueue; - QQueue *tempQueueFirst = new QQueue; + QQueue* tempQueue = new QQueue; + QQueue* tempQueueFirst = new QQueue; tempHanzi = hanzi; int tempQueueSize = 0; int multiToneWordNum = 0; - - for (auto i : hanzi) { - if (FileUtils::map_chinese2pinyin.contains(i)) { - if (FileUtils::map_chinese2pinyin[i].size() > 1) { + for(auto i : hanzi) { + if(FileUtils::map_chinese2pinyin.contains(i)) { + if(FileUtils::map_chinese2pinyin[i].size() > 1) { ++multiToneWordNum; } } } - - if (multiToneWordNum > 3) { + if(multiToneWordNum > 3) { QString oneResult, oneResultFirst; - - for (auto i : hanzi) { - if (FileUtils::map_chinese2pinyin.contains(i)) { + for(auto i : hanzi) { + if(FileUtils::map_chinese2pinyin.contains(i)) { oneResult += FileUtils::map_chinese2pinyin[i].first(); oneResultFirst += FileUtils::map_chinese2pinyin[i].first().at(0); } else { @@ -186,14 +162,13 @@ void stitchMultiToneWordsBFSHeapLess3(const QString &hanzi, QStringList &resultL oneResultFirst += i; } } - resultList.append(oneResult); resultList.append(oneResultFirst); return; } - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(i); tempQueueFirst->enqueue(i.at(0)); } @@ -201,39 +176,32 @@ void stitchMultiToneWordsBFSHeapLess3(const QString &hanzi, QStringList &resultL tempQueue->enqueue(tempHanzi.at(0)); tempQueueFirst->enqueue(tempHanzi.at(0)); } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - - while (tempHanzi.size() != 0) { + while(tempHanzi.size() != 0) { tempQueueSize = tempQueue->size(); - - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (int j = 0; j < tempQueueSize; ++j) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(int j = 0; j < tempQueueSize; ++j) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(tempQueue->head() + i); tempQueueFirst->enqueue(tempQueueFirst->head() + i.at(0)); } - tempQueue->dequeue(); tempQueueFirst->dequeue(); } } else { - for (int j = 0; j < tempQueueSize; ++j) { + for(int j = 0; j < tempQueueSize; ++j) { tempQueue->enqueue(tempQueue->head() + tempHanzi.at(0)); tempQueueFirst->enqueue(tempQueueFirst->head() + tempHanzi.at(0)); tempQueue->dequeue(); tempQueueFirst->dequeue(); } } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - - while (!tempQueue->empty()) { + while(!tempQueue->empty()) { resultList.append(tempQueue->dequeue()); resultList.append(tempQueueFirst->dequeue()); } - delete tempQueue; delete tempQueueFirst; tempQueue = nullptr; @@ -242,28 +210,24 @@ void stitchMultiToneWordsBFSHeapLess3(const QString &hanzi, QStringList &resultL } //BFS+Stack+超过3个多音字只建一个索引,比较折中的方案 -void stitchMultiToneWordsBFSStackLess3(const QString &hanzi, QStringList &resultList) -{ +void stitchMultiToneWordsBFSStackLess3(const QString& hanzi, QStringList& resultList) { QString tempHanzi, resultAllPinYin, resultFirst; QQueue tempQueue; QQueue tempQueueFirst; tempHanzi = hanzi; int tempQueueSize = 0; int multiToneWordNum = 0; - - for (auto i : hanzi) { - if (FileUtils::map_chinese2pinyin.contains(i)) { - if (FileUtils::map_chinese2pinyin[i].size() > 1) { + for(auto i : hanzi) { + if(FileUtils::map_chinese2pinyin.contains(i)) { + if(FileUtils::map_chinese2pinyin[i].size() > 1) { ++multiToneWordNum; } } } - - if (multiToneWordNum > 3) { + if(multiToneWordNum > 3) { QString oneResult, oneResultFirst; - - for (auto i : hanzi) { - if (FileUtils::map_chinese2pinyin.contains(i)) { + for(auto i : hanzi) { + if(FileUtils::map_chinese2pinyin.contains(i)) { oneResult += FileUtils::map_chinese2pinyin[i].first(); oneResultFirst += FileUtils::map_chinese2pinyin[i].first().at(0); } else { @@ -271,14 +235,13 @@ void stitchMultiToneWordsBFSStackLess3(const QString &hanzi, QStringList &result oneResultFirst += i; } } - resultList.append(oneResult); resultList.append(oneResultFirst); return; } - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(i); tempQueueFirst.enqueue(i.at(0)); } @@ -286,39 +249,32 @@ void stitchMultiToneWordsBFSStackLess3(const QString &hanzi, QStringList &result tempQueue.enqueue(tempHanzi.at(0)); tempQueueFirst.enqueue(tempHanzi.at(0)); } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - - while (tempHanzi.size() != 0) { + while(tempHanzi.size() != 0) { tempQueueSize = tempQueue.size(); - - if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for (int j = 0; j < tempQueueSize; ++j) { - for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for(int j = 0; j < tempQueueSize; ++j) { + for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(tempQueue.head() + i); tempQueueFirst.enqueue(tempQueueFirst.head() + i.at(0)); } - tempQueue.dequeue(); tempQueueFirst.dequeue(); } } else { - for (int j = 0; j < tempQueueSize; ++j) { + for(int j = 0; j < tempQueueSize; ++j) { tempQueue.enqueue(tempQueue.head() + tempHanzi.at(0)); tempQueueFirst.enqueue(tempQueueFirst.head() + tempHanzi.at(0)); tempQueue.dequeue(); tempQueueFirst.dequeue(); } } - tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - - while (!tempQueue.empty()) { + while(!tempQueue.empty()) { resultList.append(tempQueue.dequeue()); resultList.append(tempQueueFirst.dequeue()); } - // delete tempQueue; // delete tempQueueFirst; // tempQueue = nullptr; @@ -326,12 +282,12 @@ void stitchMultiToneWordsBFSStackLess3(const QString &hanzi, QStringList &result return; } -QStringList FileUtils::findMultiToneWords(const QString &hanzi) -{ +QStringList FileUtils::findMultiToneWords(const QString& hanzi) { // QStringList* output = new QStringList(); QStringList output; QString tempAllPinYin, tempFirst; QStringList stringList = hanzi.split(""); + // stitchMultiToneWordsDFS(hanzi, tempAllPinYin, tempFirst, output); stitchMultiToneWordsBFSStackLess3(hanzi, output); // qDebug() << output; diff --git a/src/BackProcess/Search/file-utils.h b/src/SearchResultWidget/file-utils.h similarity index 90% rename from src/BackProcess/Search/file-utils.h rename to src/SearchResultWidget/file-utils.h index 1621f00..097055c 100644 --- a/src/BackProcess/Search/file-utils.h +++ b/src/SearchResultWidget/file-utils.h @@ -40,17 +40,19 @@ #define MAX_CONTENT_LENGTH 20480000 -class FileUtils -{ +namespace Zeeker { +class FileUtils { public: //chinese character to pinyin static QMap map_chinese2pinyin; - static QStringList findMultiToneWords(const QString &); - static void loadHanziTable(const QString &); + static QStringList findMultiToneWords(const QString&); + static void loadHanziTable(const QString&); private: FileUtils(); }; +} + #endif // FILEUTILS_H diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp new file mode 100644 index 0000000..ffb7b6f --- /dev/null +++ b/src/SearchResultWidget/fullsearchresultwidget.cpp @@ -0,0 +1,142 @@ +/* + * 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 +#include "src/Style/style.h" +#include "src/UtilityFunction/utility.h" +#include + +FullSearchResultWidget::FullSearchResultWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +FullSearchResultWidget::~FullSearchResultWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void FullSearchResultWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->setContentsMargins(0, 0, 0, 0); + m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + mainLayout->addItem(m_spaceItem); + m_listView = new FullListView(this, 3); + this->setLayout(mainLayout); + m_scrollArea = new ScrollArea(this); + m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); + m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setWidgetResizable(true); + m_scrollAreaWidLayout = new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(10); + m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); + mainLayout->addWidget(m_scrollArea); + m_scrollAreaWidLayout->addWidget(m_listView); + m_scrollAreaWidLayout->addItem(new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding)); + m_data.clear(); + m_listView->addData(m_data); + m_ukuiMenuInterface = new UkuiMenuInterface; + connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); + connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal); +} + +/** + * 执行应用程序 + */ +void FullSearchResultWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +void FullSearchResultWidget::updateAppListView(QVector arg) +{ + m_data.clear(); + + Q_FOREACH (QStringList appinfo, arg) { + m_data.append(appinfo.at(0)); + } + + m_listView->updateData(m_data); + resizeScrollAreaControls(); +} + +void FullSearchResultWidget::resizeScrollAreaControls() +{ + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); + QWidget *wid = widItem->widget(); + FullListView *listview = qobject_cast(wid); + listview->adjustSize(); + int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; + int rowcount = 0; + + if (listview->model()->rowCount() % dividend > 0) { + rowcount = listview->model()->rowCount() / dividend + 1; + } else { + rowcount = listview->model()->rowCount() / dividend; + } + + listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); + m_scrollArea->widget()->adjustSize(); +} + +void FullSearchResultWidget::repaintWidget() +{ + this->setFixedSize(Style::MainViewWidWidth, + Style::AppListWidHeight); + m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollAreaWidLayout->removeWidget(m_listView); + m_listView->setParent(nullptr); + delete m_listView; + m_listView = new FullListView(this, 3); + m_scrollAreaWidLayout->insertWidget(0, m_listView); + m_listView->addData(m_data); + resizeScrollAreaControls(); + connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); + connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal); +} + +void FullSearchResultWidget::moveScrollBar(int type) +{ + int height = Style::primaryScreenHeight; + + if (type == 0) { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); + } else { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); + } +} + +void FullSearchResultWidget::setViewFocus() +{ + m_listView->setFocus(); +} diff --git a/src/UserInterface/Widget/full_searchresult_widget.h b/src/SearchResultWidget/fullsearchresultwidget.h similarity index 66% rename from src/UserInterface/Widget/full_searchresult_widget.h rename to src/SearchResultWidget/fullsearchresultwidget.h index 43c1955..f132160 100644 --- a/src/UserInterface/Widget/full_searchresult_widget.h +++ b/src/SearchResultWidget/fullsearchresultwidget.h @@ -20,7 +20,6 @@ #define FULLSEARCHRESULTWIDGET_H #include -#include #include #include #include @@ -28,10 +27,10 @@ #include #include #include -#include "ukuimenuinterface.h" -#include "fulllistview.h" -#include "style.h" -#include "scrollarea.h" +#include "src/Interface/ukuimenuinterface.h" +#include "src/UtilityFunction/fulllistview.h" +#include "src/Style/style.h" +#include "src/UtilityFunction/scrollarea.h" class FullSearchResultWidget : public QWidget { @@ -59,61 +58,34 @@ public: void setViewFocus(); private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - FullListView *m_listView = nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + FullListView* m_listView=nullptr; QStringList m_data; - QSpacerItem *m_spaceItem = nullptr; + QSpacerItem *m_spaceItem=nullptr; - ScrollArea *m_scrollArea = nullptr; - ScrollAreaWid *m_scrollAreaWid = nullptr; - QVBoxLayout *m_scrollAreaWidLayout = nullptr; - - QScrollBar *m_verticalScrollBar = nullptr; - int m_scrollAreaWidHeight = 0; - QString m_scrollBarStyle; - QPushButton *m_powerOffButton = nullptr; + ScrollArea* m_scrollArea=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; + QVBoxLayout* m_scrollAreaWidLayout=nullptr; protected: /** * @brief Initializes UI */ void initUi(); - - void initAppListWidget(); - - void fillAppList(); - void resizeScrollAreaControls(); - void initVerticalScrollBar(); - - bool eventFilter(QObject *watched, QEvent *event); - -public Q_SLOTS: +private Q_SLOTS: /** * @brief Open the application * @param arg: Desktop file path */ void execApplication(QString desktopfp); - void selectFirstItemTab(); - - void on_setScrollBarValue(int value); - - void onSetSlider(int value); - - void on_setAreaScrollBarValue(int value); - - void on_powerOffButton_clicked(); - - void on_powerOffButton_customContextMenuRequested(const QPoint &pos); - Q_SIGNALS: /** * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); - void setFocusToSideWin(); }; #endif // FULLSEARCHRESULTWIDGET_H diff --git a/src/BackProcess/Search/pinyinWithTone.txt b/src/SearchResultWidget/pinyinWithTone.txt similarity index 99% rename from src/BackProcess/Search/pinyinWithTone.txt rename to src/SearchResultWidget/pinyinWithTone.txt index 41eaeec..ef4f6e3 100644 --- a/src/BackProcess/Search/pinyinWithTone.txt +++ b/src/SearchResultWidget/pinyinWithTone.txt @@ -6669,7 +6669,7 @@ gāng 冈 rǎn,nán,dān 冉 cè 冊 jiōng,jiǒng 冋 -cè,zhà 册 +cè 册 zài 再 guǎ 冎 jiǒng,jiōng 冏 diff --git a/src/BackProcess/Search/pinyinWithoutTone.txt b/src/SearchResultWidget/pinyinWithoutTone.txt similarity index 99% rename from src/BackProcess/Search/pinyinWithoutTone.txt rename to src/SearchResultWidget/pinyinWithoutTone.txt index 07421f0..7267609 100644 --- a/src/BackProcess/Search/pinyinWithoutTone.txt +++ b/src/SearchResultWidget/pinyinWithoutTone.txt @@ -6669,7 +6669,7 @@ gang 冈 dan,nan,ran 冉 ce 冊 jiong 冋 -zha,ce 册 +ce 册 zai 再 gua 冎 jiong 冏 diff --git a/src/BackProcess/Search/searchappthread.cpp b/src/SearchResultWidget/searchappthread.cpp similarity index 80% rename from src/BackProcess/Search/searchappthread.cpp rename to src/SearchResultWidget/searchappthread.cpp index 128aeed..36d69a0 100644 --- a/src/BackProcess/Search/searchappthread.cpp +++ b/src/SearchResultWidget/searchappthread.cpp @@ -18,22 +18,26 @@ #include "searchappthread.h" #include -#include "file-utils.h" +#include "src/SearchResultWidget/file-utils.h" -SearchAppThread::SearchAppThread() +SearchAppThread::SearchAppThread(QObject *parent): + QThread(parent) { m_ukuiMenuInterface = new UkuiMenuInterface; } SearchAppThread::~SearchAppThread() { - delete m_ukuiMenuInterface; + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } } void SearchAppThread::run() { m_appInfoVector.clear(); - m_appInfoVector = UkuiMenuInterface::appInfoVector; + m_appInfoVector = UkuiMenuInterface::m_appInfoVector; m_searchResultVector.clear(); m_searchFirstVector.clear(); m_searchRestVector.clear(); @@ -43,18 +47,23 @@ void SearchAppThread::run() int index = 0; while (index < m_appInfoVector.size()) { - QString appName = m_appInfoVector.at(index).at(1); - QString appEnglishName = m_appInfoVector.at(index).at(2); - QStringList appNameLs; //中文音标全拼列表 - QStringList appNameFls; //中文拼音首字母简拼列表 - QStringList appNamePyLst = FileUtils::findMultiToneWords(appName); //获取中文拼音列表 + // QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(m_appInfoVector.at(index).at(1)); + QStringList appNameLs; + QStringList appNameFls; + QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords(m_appInfoVector.at(index).at(1)); + // QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords("奇安信可信"); for (int i = 0; i < appNamePyLst.size() / 2; i++) { appNameLs.append(appNamePyLst.at(i * 2)); appNameFls.append(appNamePyLst.at(i * 2 + 1)); } - if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { //中文正则表达式 + QString appName = m_appInfoVector.at(index).at(1); + QString appEnglishName = m_appInfoVector.at(index).at(2); + //QString appNameFls=m_appInfoVector.at(index).at(4); + + if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { + //中文正则表达式 if (appName.toUpper().contains(m_keyWord.toUpper())) { m_searchResultVector.append(m_appInfoVector.at(index)); } @@ -62,13 +71,11 @@ void SearchAppThread::run() for (int var = 0; var < appNameLs.size(); ++var) { if (appNameLs[var].left(str.length()).contains(str, Qt::CaseInsensitive) || appNameFls[var].left(str.length()).contains(str, Qt::CaseInsensitive)) { - //按照顺序从首字母开始严格匹配查找 m_searchFirstVector.append(m_appInfoVector.at(index)); break; } else if (appNameLs[var].contains(str, Qt::CaseInsensitive) || appNameFls[var].contains(str, Qt::CaseInsensitive) || appEnglishName.contains(str, Qt::CaseInsensitive)) { - //只要应用名存在包含输入信息就匹配 m_searchRestVector.append(m_appInfoVector.at(index)); break; } @@ -82,17 +89,14 @@ void SearchAppThread::run() qSort(m_searchFirstVector.begin(), m_searchFirstVector.end(), UkuiMenuInterface::cmpApp); qSort(m_searchRestVector.begin(), m_searchRestVector.end(), UkuiMenuInterface::cmpApp); - //对中文搜索结果进行排序 if (m_searchResultVector.size() != 0) { qSort(m_searchResultVector.begin(), m_searchResultVector.end(), UkuiMenuInterface::cmpApp); } - //优先将严格匹配结果加入列表 for (int i = 0; i < m_searchFirstVector.size(); i++) { m_searchResultVector.append(m_searchFirstVector.at(i)); } - //将模糊匹配结果加入列表 for (int i = 0; i < m_searchRestVector.size(); i++) { m_searchResultVector.append(m_searchRestVector.at(i)); } diff --git a/src/BackProcess/Search/searchappthread.h b/src/SearchResultWidget/searchappthread.h similarity index 94% rename from src/BackProcess/Search/searchappthread.h rename to src/SearchResultWidget/searchappthread.h index 972ba2b..852d311 100644 --- a/src/BackProcess/Search/searchappthread.h +++ b/src/SearchResultWidget/searchappthread.h @@ -19,16 +19,17 @@ #ifndef SEARCHAPPTHREAD_H #define SEARCHAPPTHREAD_H #include -#include "ukuimenuinterface.h" +#include "src/Interface/ukuimenuinterface.h" #include class SearchAppThread : public QThread { Q_OBJECT public: - SearchAppThread(); + SearchAppThread(QObject *parent = nullptr); ~SearchAppThread(); void run(); + private: QString m_keyWord; QVector m_searchResultVector; diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp new file mode 100644 index 0000000..116ffcb --- /dev/null +++ b/src/SearchResultWidget/searchresultwidget.cpp @@ -0,0 +1,96 @@ +/* + * 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 +#include +#include "src/UtilityFunction/utility.h" + +SearchResultWidget::SearchResultWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +SearchResultWidget::~SearchResultWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void SearchResultWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + this->setFocusPolicy(Qt::StrongFocus); + m_listView = new ListView(this, this->width() - 6, this->height() - 6, 3); + m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_listView->show(); + m_data.clear(); + m_listView->addData(m_data); + m_ukuiMenuInterface = new UkuiMenuInterface; + connect(m_listView, &ListView::sendItemClickedSignal, this, &SearchResultWidget::execApplication); + connect(m_listView, &ListView::sendHideMainWindowSignal, this, &SearchResultWidget::sendHideMainWindowSignal); +} + +/** + * 执行应用程序 + */ +void SearchResultWidget::execApplication(QStringList arg) +{ + Q_EMIT sendHideMainWindowSignal(); + QString desktopfp = arg.at(0); + execApp(desktopfp); +} + +void SearchResultWidget::updateAppListView(QVector arg) +{ + m_data.clear(); + + Q_FOREACH (QStringList appinfo, arg) { + m_data.append(QStringList() << appinfo.at(0) << "1"); + } + + m_listView->updateData(m_data); +} + +void SearchResultWidget::moveScrollBar(int type) +{ + if (type == 0) { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - 100); + } else { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + 100); + } +} + +void SearchResultWidget::repaintWidget() +{ + this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_listView->show(); +} + +void SearchResultWidget::setViewFocus() +{ + m_listView->setFocus(); +} diff --git a/src/SearchResultWidget/searchresultwidget.h b/src/SearchResultWidget/searchresultwidget.h new file mode 100644 index 0000000..2897b23 --- /dev/null +++ b/src/SearchResultWidget/searchresultwidget.h @@ -0,0 +1,86 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +//#include "searchappthread.h" +#include "src/UtilityFunction/listview.h" +#include "src/UtilityFunction/itemdelegate.h" + +class SearchResultWidget : public QWidget +{ + Q_OBJECT + +public: + explicit SearchResultWidget(QWidget *parent = nullptr); + ~SearchResultWidget(); + /** + * @brief Update application list + */ + void updateAppListView(QVector arg); + /** + * @brief Move the scroll bar + * @param type: Scroll way,Only the following parameters can be entered: + * 0: moving up + * 1: moving down + */ + void moveScrollBar(int type); + /** + * @brief Repaint window + */ + void repaintWidget(); + + void setViewFocus(); + +private: + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + ListView* m_listView=nullptr; + QVector m_data; + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + +private Q_SLOTS: + /** + * @brief Open the application + * @param arg: The desktop file information that the application contains + */ + void execApplication(QStringList arg); + +Q_SIGNALS: + /** + * @brief Send a hidden main window signal to the MainViewWidget + */ + void sendHideMainWindowSignal(); +}; + +#endif // SEARCHRESULTWIDGET_H diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp new file mode 100644 index 0000000..57e70ac --- /dev/null +++ b/src/SideBarWidget/sidebarwidget.cpp @@ -0,0 +1,1026 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include "src/Style/style.h" +#include "src/UtilityFunction/utility.h" + +SideBarWidget::SideBarWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); + m_allBtn->click(); +} + +SideBarWidget::~SideBarWidget() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +/** + * 侧边栏初始化 + */ +void SideBarWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setAttribute(Qt::WA_InputMethodEnabled); + this->setAttribute(Qt::WA_KeyCompression); + this->setFocusPolicy(Qt::NoFocus); + addSidebarBtn(); + loadMinSidebar(); + m_minMaxBtn->installEventFilter(this); + m_minMaxBtn->setAttribute(Qt::WA_KeyCompression); + m_minMaxBtn->setAttribute(Qt::WA_InputMethodEnabled); + m_allBtn->installEventFilter(this); + m_letterBtn->installEventFilter(this); + m_functionBtn->installEventFilter(this); + m_userIconBtn->installEventFilter(this); + m_userIconBtn->setAttribute(Qt::WA_KeyCompression); + m_userIconBtn->setAttribute(Qt::WA_InputMethodEnabled); + m_computerBtn->installEventFilter(this); + m_computerBtn->setAttribute(Qt::WA_KeyCompression); + m_computerBtn->setAttribute(Qt::WA_InputMethodEnabled); + m_personalBtn->installEventFilter(this); + m_controlBtn->installEventFilter(this); + m_controlBtn->setAttribute(Qt::WA_KeyCompression); + m_controlBtn->setAttribute(Qt::WA_InputMethodEnabled); + m_trashBtn->installEventFilter(this); + m_shutDownBtn->installEventFilter(this); + m_shutDownBtn->setAttribute(Qt::WA_KeyCompression); + m_shutDownBtn->setAttribute(Qt::WA_InputMethodEnabled); + m_ukuiMenuInterface = new UkuiMenuInterface; +// m_shutDownMenu=new RightClickMenu; +// m_otherMenu=new RightClickMenu; +} + +bool SideBarWidget::eventFilter(QObject *target, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + Q_EMIT setFocusToMainWin(); + // return true; + } + + if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Left) { + if (m_minMaxBtn->hasFocus()) { + m_shutDownBtn->setFocus(); + return true; + } + } + + if (ke->key() == Qt::Key_Down || ke->key() == Qt::Key_Right) { + if (m_shutDownBtn->hasFocus()) { + this->setFocus(); + } + } + } + + if (event->type() == QEvent::InputMethod) { + QInputMethodEvent *iEvent = dynamic_cast(event); + Q_EMIT setLineEditFocus(iEvent->commitString()); + } + + return QWidget::eventFilter(target, event); +} + + + +/** + * 侧边栏添加控件 + */ +void SideBarWidget::addSidebarBtn() +{ + m_mainWidget = new QWidget(this); + m_mainWidgetLayout = new QVBoxLayout; + m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6); + m_mainWidgetLayout->setSpacing(10); + m_mainWidget->setLayout(m_mainWidgetLayout); + // m_mainWidget->setFocusPolicy(Qt::StrongFocus); +// m_mainWidget->setAutoFillBackground(true); +// QPalette palette; +// palette.setBrush(QPalette::Background,Qt::red); +// m_mainWidget->setPalette(palette); + //放大缩小按钮界面 + m_minMaxWidget = new QWidget(this); + m_minMaxLayout = new QHBoxLayout; + m_minMaxBtn = new QPushButton(this); + m_minMaxBtn->setFlat(true); + m_minMaxBtn->setProperty("useButtonPalette", true); +// m_minMaxBtn->setProperty("doNotAnimate",true); +// m_minMaxBtn->setProperty("useButtonPalette", true); +// m_minMaxBtn->setFlat(true); +// m_minMaxBtn->setProperty("doNotAnimate",true); +// m_minMaxBtn->setShortcut(QKeySequence::InsertParagraphSeparator); +// m_minMaxBtn->setShortcut(Qt::Key_Enter); +// m_minMaxBtn->setShortcut(Qt::Key_Return); +// QShortcut *key_1 = new QShortcut(QKeySequence(Qt::Key_Enter),this); +// connect(key_1,&QShortcut::activated,m_minMaxBtn,&QPushButton::click); +// QShortcut *key_2 = new QShortcut(QKeySequence(Qt::Key_Return),this); +// connect(key_2,&QShortcut::activated,m_minMaxBtn,&QPushButton::click); + m_minMaxLayout->addWidget(m_minMaxBtn); + m_minMaxWidget->setLayout(m_minMaxLayout); +// m_minMaxWidget->setAttribute(Qt::WA_StyledBackground,true); +// m_minMaxWidget->hasFocus(); + //分类按钮 + m_buttonList.clear(); + m_allBtn = new QPushButton(this); + initBtn(m_allBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"), tr("All"), 0); + m_letterBtn = new QPushButton(this); + initBtn(m_letterBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"), tr("Letter"), 1); + m_functionBtn = new QPushButton(this); + initBtn(m_functionBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"), tr("Function"), 2); + int id = 0; + + Q_FOREACH (QAbstractButton *btn, m_buttonList) { + // m_btnGroup->addButton(btn,id++); + btn->setCheckable(true); + btn->setAttribute(Qt::WA_KeyCompression); + btn->setAttribute(Qt::WA_InputMethodEnabled); + } + + QString usericon = getUserIcon(); + QString username = getUserName(); + m_userIconBtn = new QPushButton; + initBtn(m_userIconBtn, usericon, username, 3); + m_personalBtn = new QPushButton; + initBtn(m_personalBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"), tr("Personal"), 4); + m_trashBtn = new QPushButton; + initBtn(m_trashBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"), tr("Trash"), 5); + m_computerBtn = new QPushButton; + initBtn(m_computerBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"), tr("Computer"), 6); + m_controlBtn = new QPushButton; + initBtn(m_controlBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/control.svg"), tr("Settings"), 7); + m_shutDownBtn = new QPushButton; + initBtn(m_shutDownBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/shutdown.svg"), tr("Power"), 8); + connect(m_allBtn, &QPushButton::clicked, this, &SideBarWidget::btnAllClickedSlot); + connect(m_letterBtn, &QPushButton::clicked, this, &SideBarWidget::btnLetterClickedSlot); + connect(m_functionBtn, &QPushButton::clicked, this, &SideBarWidget::btnFuncClickedSlot); + connect(m_computerBtn, &QPushButton::clicked, this, &SideBarWidget::computerBtnClickedSlot); + connect(m_personalBtn, &QPushButton::clicked, this, &SideBarWidget::personalBtnClickedSlot); + connect(m_controlBtn, &QPushButton::clicked, this, &SideBarWidget::controlBtnClickedSlot); + connect(m_trashBtn, &QPushButton::clicked, this, &SideBarWidget::trashBtnClickedSlot); + connect(m_shutDownBtn, &QPushButton::clicked, this, &SideBarWidget::shutdownBtnClickedSlot); + connect(m_userIconBtn, &QPushButton::clicked, this, &SideBarWidget::userIconBtnClickedSlot); + + // 判断控制面版版本号,选择是否屏蔽右键菜单 + QProcess *prosess = new QProcess(this); + prosess->start(QString("dpkg -s ukui-control-center")); + prosess->waitForFinished(); + QString str = prosess->readAll(); + delete prosess; + QList strList = str.split('\n'); + QString version; + + for(int i = 0; i < strList.size(); i++) { + if(strList.at(i).startsWith("Version")) { + version = strList.at(i); + version = version.mid(version.indexOf(" ") + 1); + } + } + + if (version.startsWith("3.0")) { + Q_FOREACH (QAbstractButton *button, m_buttonList) { + QPushButton *btn = qobject_cast(button); + if (m_buttonList.indexOf(button) > 3 && m_buttonList.indexOf(button) < m_buttonList.count() - 1) { + button->setCheckable(false); + addRightClickMenu(btn); + } + } + } + + m_shutDownBtn->setContextMenuPolicy(Qt::CustomContextMenu); + connect(m_shutDownBtn, &QPushButton::customContextMenuRequested, this, + &SideBarWidget::shutdownBtnRightClickSlot); + //监控用户账户信息更改 + qint64 uid = static_cast(getuid()); + QDBusInterface iface("org.freedesktop.Accounts", + "/org/freedesktop/Accounts", + "org.freedesktop.Accounts", + QDBusConnection::systemBus()); + QDBusReplyobjPath = iface.call("FindUserById", uid); + QDBusConnection::systemBus().connect("org.freedesktop.Accounts", + objPath.value().path(), + "org.freedesktop.Accounts.User", + QString("Changed"), this, SLOT(userAccountsChanged())); + m_mainWidgetLayout->addWidget(m_minMaxWidget); + m_mainWidgetLayout->addWidget(m_buttonList.at(0)); + m_mainWidgetLayout->addWidget(m_buttonList.at(1)); + m_mainWidgetLayout->addWidget(m_buttonList.at(2)); + m_verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_mainWidgetLayout->addItem(m_verticalSpacer); + m_mainWidgetLayout->addWidget(m_buttonList.at(3)); + + if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) { + m_gsetting = new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit(), QByteArray(), this); + + if (m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(4)); + } + + if (m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(5)); + } + + if (m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(6)); + } + + if (m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(7)); + } + + connect(m_gsetting, &QGSettings::changed, + this, &SideBarWidget::resetSidebarBtnSlot); + } + + m_mainWidgetLayout->addWidget(m_buttonList.at(8)); + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting, &QGSettings::changed, this, &SideBarWidget::themeModeChangeSlot); + } + + m_animation = new QPropertyAnimation(m_mainWidget, "geometry", this); +} + +void SideBarWidget::resetSidebarBtnSlot() +{ + QLayoutItem *child; + + while ((child = m_mainWidgetLayout->takeAt(6)) != 0) { + QWidget *wid = child->widget(); + m_mainWidgetLayout->removeWidget(wid); + wid->setParent(nullptr); + delete child; + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) { + if (m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(4)); + } + + if (m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(5)); + } + + if (m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(6)); + } + + if (m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) { + m_mainWidgetLayout->addWidget(m_buttonList.at(7)); + } + } + + m_mainWidgetLayout->addWidget(m_buttonList.at(8)); +} + +/** + * 设置按钮样式 + */ +void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int num) +{ + btn->setFlat(true); + btn->setProperty("useButtonPalette", true); + QHBoxLayout *btnLayout = new QHBoxLayout; + QLabel *labelicon = new QLabel(this); + labelicon->setAlignment(Qt::AlignCenter); + const auto ratio = devicePixelRatioF(); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (num != 3) { + QPixmap pixmap = loadSvg(btnicon, Style::SideBarIconSize * ratio); + + if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + } + + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + labelicon->setFixedSize(Style::SideBarIconSize, Style::SideBarIconSize); + labelicon->setPixmap(pixmap); + } else { + if (!QFile::exists(btnicon)) { + btnicon = QString("/usr/share/ukui/faces/default.png"); + } + + labelicon->setObjectName("faceLabel"); + labelicon->setFocusPolicy(Qt::NoFocus); + labelicon->setAlignment(Qt::AlignCenter); + labelicon->setFixedSize(Style::SideBarIconSize + 4, Style::SideBarIconSize + 4); + QPixmap facePixmap(btnicon); + facePixmap = facePixmap.scaled((Style::SideBarIconSize + 4) * ratio, (Style::SideBarIconSize + 4) * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); + facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize + 4) * ratio / 2); + facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + labelicon->setPixmap(facePixmap); + } + + btnLayout->setSpacing(0); + btnLayout->addWidget(labelicon); +// btnLayout->addStretch(); + QLabel *textLabel = new QLabel(this); + + if (num == 3) { + textLabel->setObjectName("nameLabel"); + } + + textLabel->setText(text); + btnLayout->addWidget(textLabel); + btnLayout->addStretch(); + btn->setLayout(btnLayout); + btn->setFocusPolicy(Qt::StrongFocus); + m_buttonList.append(btn); + m_textList.append(text); + m_labelList.append(textLabel); +} + +QPixmap SideBarWidget::PixmapToRound(const QPixmap &src, int radius) +{ + if (src.isNull()) { + return QPixmap(); + } + + QPixmap pixmapa(src); + QPixmap pixmap(radius * 2, radius * 2); + pixmap.fill(Qt::transparent); + QPainter painter(&pixmap); + painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + QPainterPath path; + path.addEllipse(0, 0, radius * 2, radius * 2); + painter.setClipPath(path); + painter.drawPixmap(0, 0, radius * 2, radius * 2, pixmapa); + return pixmap; +} + + +/** + * 加载关机按钮右键菜单 + */ +void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos) +{ + RightClickMenu m_otherMenu(this); + int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos)); + Q_EMIT sendShowMainWindowSignal(false); + + if (ret >= 10 && ret <= 17) { + Q_EMIT sendHideMainWindowSignal(); + + switch (ret) { + case 10: + QProcess::startDetached(QString("ukui-screensaver-command -l")); + break; + + case 11: + QProcess::startDetached(QString("ukui-session-tools --switchuser")); + break; + + case 12: + QProcess::startDetached(QString("ukui-session-tools --logout")); + break; + + case 13: + QProcess::startDetached(QString("ukui-session-tools --reboot")); + break; + + case 14: + QProcess::startDetached(QString("ukui-session-tools --shutdown")); + break; + + case 16: + QProcess::startDetached(QString("ukui-session-tools --suspend")); + break; + + case 17: + QProcess::startDetached(QString("ukui-session-tools --sleep")); + break; + + default: + break; + } + } +} + +void SideBarWidget::addRightClickMenu(QPushButton *btn) +{ + btn->setContextMenuPolicy(Qt::CustomContextMenu); + connect(btn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::otherBtnRightClickSlot); +} + +void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) +{ + QPushButton *btn = dynamic_cast(QObject::sender()); + int index = m_buttonList.indexOf(btn); + QString desktopfp; + + switch (index) { + case 4: + desktopfp = QString("/usr/share/applications/peony-home.desktop"); + break; + + case 5: + desktopfp = QString("/usr/share/applications/peony-trash.desktop"); + break; + + case 6: + desktopfp = QString("/usr/share/applications/peony-computer.desktop"); + break; + + case 7: + desktopfp = QString("/usr/share/applications/ukui-control-center.desktop"); + break; + + default: + break; + } + + RightClickMenu m_otherMenu; + int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); + Q_EMIT sendShowMainWindowSignal(false); + + if (ret == 15) { + Q_EMIT sendHideMainWindowSignal(); + QProcess::startDetached(QString("ukui-control-center -d")); + } +} + +void SideBarWidget::computerBtnClickedSlot() +{ + Q_EMIT sendHideMainWindowSignal(); + QProcess::startDetached(QString("/usr/bin/peony computer:///")); +} + +void SideBarWidget::personalBtnClickedSlot() +{ + Q_EMIT sendHideMainWindowSignal(); + QProcess::startDetached(QString("/usr/bin/peony")); +} + +void SideBarWidget::controlBtnClickedSlot() +{ + Q_EMIT sendHideMainWindowSignal(); + execApp("/usr/share/applications/ukui-control-center.desktop"); +} + +void SideBarWidget::trashBtnClickedSlot() +{ + Q_EMIT sendHideMainWindowSignal(); + QProcess::startDetached(QString("/usr/bin/peony trash:///")); +} + +void SideBarWidget::shutdownBtnClickedSlot() +{ + Q_EMIT sendHideMainWindowSignal(); + QProcess::startDetached(QString("ukui-session-tools")); +} + +void SideBarWidget::userIconBtnClickedSlot() +{ + Q_EMIT sendHideMainWindowSignal(); + QProcess *prosess = new QProcess(this); + prosess->start(QString("dpkg -s ukui-control-center")); + prosess->waitForFinished(); + QString str = prosess->readAll(); + delete prosess; + QList strList = str.split('\n'); + QString version; + + for(int i = 0; i < strList.size(); i++) { + if(strList.at(i).startsWith("Version")) { + version = strList.at(i); + version = version.mid(version.indexOf(" ") + 1); + } + } + if (version.startsWith("3.0")) { + QProcess::startDetached(QString("ukui-control-center -u")); + } else { + QProcess::startDetached(QString("ukui-control-center -m Userinfo")); + } +} + +void SideBarWidget::userAccountsChanged() +{ + const auto ratio = devicePixelRatioF(); + QString usericon = getUserIcon(); + + if (!QFile::exists(usericon)) { + usericon = QString("/usr/share/ukui/faces/default.png"); + } + + QPixmap facePixmap(usericon); + facePixmap = facePixmap.scaled((Style::SideBarIconSize + 2) * ratio, (Style::SideBarIconSize + 2) * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); + facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize + 2) * ratio / 2); + QLabel *labelicon = m_userIconBtn->findChild("faceLabel"); + facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + labelicon->setPixmap(facePixmap); + QLabel *labelname = m_userIconBtn->findChild("nameLabel"); + QString userName = fontMetrics().elidedText(getUserName(), Qt::ElideRight, labelname->width() - 10, Qt::TextShowMnemonic); + labelname->setText(userName);//更新用户名 + m_textList.replace(3, getUserName()); //更新用户名 +} + +/** + * 加载默认侧边栏 + */ +void SideBarWidget::loadMinSidebar() +{ + m_isFullScreen = false; + setMaxBtn(); + m_animation->stop(); + this->setFixedSize(Style::defaultSideBarWidWidth, Style::minh); + m_mainWidget->setGeometry(QRect(0, 0, this->width(), this->height())); + m_mainWidget->show(); + m_minMaxWidget->setFixedSize(37, 70); + m_minMaxLayout->setContentsMargins(0, 0, 0, 0); + m_mainWidgetLayout->setContentsMargins(8, 0, 10, 6); + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + QPushButton *btn = qobject_cast(button); + setMinSidebarBtn(btn); + btn->setToolTip(m_textList.at(m_buttonList.indexOf(button))); + } + + changeIconColor(false); + disconnect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendDefaultBtnSignal); + connect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendFullScreenBtnSignal); +} + +/** + * 设置全屏按钮 + */ +void SideBarWidget::setMaxBtn() +{ + const auto ratio = devicePixelRatioF(); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + QPixmap pixmap = loadSvg(QString(":/data/img/sidebarwidget/max.svg"), 14 * ratio); + + if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + } + + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_minMaxBtn->setFixedSize(37, 37); + m_minMaxBtn->setIcon(QIcon(pixmap)); + m_minMaxBtn->setToolTip(tr("Max")); +// m_minMaxBtn->setFocus(); +} + +/** + * 设置默认侧边栏按钮 + */ +void SideBarWidget::setMinSidebarBtn(QPushButton *btn) +{ + btn->setFixedSize(37, 37); + + if (m_buttonList.indexOf(btn) == 3) { + btn->layout()->setContentsMargins(7, 0, 17, 0); + } else { + btn->layout()->setContentsMargins(9, 0, 17, 0); + } + + btn->layout()->setSpacing(0); + m_labelList.at(m_buttonList.indexOf(btn))->setVisible(false); + //移除按钮文本 +// QLayoutItem *child; +// if((child = btn->layout()->takeAt(1)) != nullptr) { +// QWidget* childwid=child->widget(); +// if(childwid!=nullptr) +// { +// btn->layout()->removeWidget(childwid); +// childwid->setParent(nullptr); +// delete childwid; +// delete child; +// } +// } +} + +/** + * 加载全屏侧边栏 + */ +void SideBarWidget::loadMaxSidebar() +{ + m_isFullScreen = true; + setMinBtn(); + this->setFixedSize(Style::SideBarWidWidth, Style::heightavailable); + m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth, Style::MinMaxWidHeight); + m_minMaxLayout->setContentsMargins(m_minMaxWidget->width() - m_minMaxBtn->width(), 0, 0, 0); + m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6); + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + QPushButton *btn = qobject_cast(button); + setMaxSidebarBtn(btn); + } + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + QPushButton *btn = qobject_cast(button); + btn->setFixedSize(m_btnWidth, Style::SideBarBtnHeight); + } + + changeIconColor(true); + disconnect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendFullScreenBtnSignal); + connect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendDefaultBtnSignal); +} + +/** + * 设置还原按钮 + */ +void SideBarWidget::setMinBtn() +{ + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/sidebarwidget/min.svg"), 14 * ratio); + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth, Style::MinMaxBtnWidth); + m_minMaxBtn->setIcon(QIcon(pixmap)); + m_minMaxBtn->setToolTip(""); +// m_minMaxBtn->setFocus(); +} + +/** + * 设置全屏侧边栏按钮 + */ +void SideBarWidget::setMaxSidebarBtn(QPushButton *btn) +{ + QHBoxLayout *layout = qobject_cast(btn->layout()); + + if (m_buttonList.indexOf(btn) == 3) { + layout->setContentsMargins(13, 0, 0, 0); + layout->setSpacing(8); + } else { + layout->setContentsMargins(15, 0, 0, 0); + layout->setSpacing(10); + } + + QLabel *labeltext = m_labelList.at(m_buttonList.indexOf(btn)); + labeltext->setVisible(true); + + //修复修改字体大小时获取文本Label大小无效 + //移除按钮文本 +// QLayoutItem *child; +// if((child = btn->layout()->takeAt(1)) != nullptr) { +// QWidget* childwid=child->widget(); +// if(childwid!=nullptr) +// { +// btn->layout()->removeWidget(childwid); +// childwid->setParent(nullptr); +// delete childwid; +// delete child; +// } +// } + //添加文本 +// QLabel* labeltext=new QLabel; + if (m_buttonList.indexOf(btn) <= 2) { + labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + labeltext->setText(m_textList.at(m_buttonList.indexOf(btn))); + labeltext->adjustSize(); + m_btnWidth = 44 + labeltext->width() + 10; + btn->setToolTip(""); + } else { + QFont ft; + QFontMetrics fm(ft); + QString text = fm.elidedText(m_textList.at(m_buttonList.indexOf(btn)), Qt::ElideRight, m_btnWidth - 44); + labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + labeltext->setText(text); + labeltext->setFixedSize(m_btnWidth - 44, Style::SideBarBtnHeight); + labeltext->adjustSize(); + + if (fm.boundingRect(m_textList.at(m_buttonList.indexOf(btn))).width() > labeltext->width()) { + btn->setToolTip(m_textList.at(m_buttonList.indexOf(btn))); + } else { + btn->setToolTip(""); + } + } + + QPalette pe = labeltext->palette(); + pe.setColor(QPalette::ButtonText, QColor(Qt::white)); + labeltext->setPalette(pe); +// btn->layout()->addWidget(labeltext); +} + +void SideBarWidget::btnAllClickedSlot() +{ + m_allBtn->setChecked(true); + m_letterBtn->setChecked(false); + m_functionBtn->setChecked(false); + + if (m_isFullScreen) { + Q_EMIT sendFullScreenCommonUseBtnSignal(); + Q_EMIT setSlideBar(0); + } else { + Q_EMIT sendCommonUseBtnSignal(); + } +} + +void SideBarWidget::btnLetterClickedSlot() +{ + m_allBtn->setChecked(false); + m_letterBtn->setChecked(true); + m_functionBtn->setChecked(false); + + if (m_isFullScreen) { + Q_EMIT sendFullScreenLetterBtnSignal(); + } else { + Q_EMIT sendLetterBtnSignal(); + } +} + +void SideBarWidget::btnFuncClickedSlot() +{ + m_allBtn->setChecked(false); + m_letterBtn->setChecked(false); + m_functionBtn->setChecked(true); + + if (m_isFullScreen) { + Q_EMIT sendFullScreenFunctionBtnSignal(); + } else { + Q_EMIT sendFunctionBtnSignal(); + } +} + +void SideBarWidget::themeModeChangeSlot(QString styleName) +{ + if (styleName == "styleName") { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + QPushButton *btn = qobject_cast(button); + QLayoutItem *item = btn->layout()->itemAt(0); + QLabel *label = qobject_cast(item->widget()); + QString iconStr; + QIcon buttIcon; + + switch (m_buttonList.indexOf(button)) { + case 0: + iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); + buttIcon = QIcon::fromTheme("commonuse.svg"); + break; + + case 1: + iconStr = QString(":/data/img/sidebarwidget/letter.svg"); + buttIcon = QIcon::fromTheme("letter.svg"); + break; + + case 2: + iconStr = QString(":/data/img/sidebarwidget/function.svg"); + buttIcon = QIcon::fromTheme("function.svg"); + break; + + case 3: + userAccountsChanged(); + break; + + case 4: + iconStr = QString(":/data/img/sidebarwidget/personal.svg"); + buttIcon = QIcon::fromTheme("personal.svg"); + break; + + case 5: + iconStr = QString(":/data/img/sidebarwidget/trash.svg"); + buttIcon = QIcon::fromTheme("trash.svg"); + break; + + case 6: + iconStr = QString(":/data/img/sidebarwidget/computer.svg"); + buttIcon = QIcon::fromTheme("computer.svg"); + break; + + case 7: + iconStr = QString(":/data/img/sidebarwidget/setting.svg"); + buttIcon = QIcon::fromTheme("setting.svg"); + break; + + case 8: + iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); + buttIcon = QIcon::fromTheme("shutdown.svg"); + break; + + default: + break; + } + + if (m_buttonList.indexOf(button) != 3) { + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(iconStr, 19 * ratio); + + if (buttIcon.isNull()) { + pixmap = loadSvg(iconStr, 19 * ratio); + } else { + pixmap = buttIcon.pixmap(QSize(19 * ratio, 19 * ratio)); + } + + if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + } + + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + label->setPixmap(pixmap); + } + } + } +} + +void SideBarWidget::changeIconColor(bool isFullScreen) +{ + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + QPushButton *btn = qobject_cast(button); + QLayoutItem *item = btn->layout()->itemAt(0); + QLabel *label = qobject_cast(item->widget()); + QString iconStr; + QIcon buttIcon; + + switch (m_buttonList.indexOf(button)) { + case 0: + iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); + buttIcon = QIcon::fromTheme("commonuse.svg"); + break; + + case 1: + iconStr = QString(":/data/img/sidebarwidget/letter.svg"); + buttIcon = QIcon::fromTheme("letter.svg"); + break; + + case 2: + iconStr = QString(":/data/img/sidebarwidget/function.svg"); + buttIcon = QIcon::fromTheme("function.svg"); + break; + + case 3: + userAccountsChanged(); + break; + + case 4: + iconStr = QString(":/data/img/sidebarwidget/personal.svg"); + buttIcon = QIcon::fromTheme("personal.svg"); + break; + + case 5: + iconStr = QString(":/data/img/sidebarwidget/trash.svg"); + buttIcon = QIcon::fromTheme("trash.svg"); + break; + + case 6: + iconStr = QString(":/data/img/sidebarwidget/computer.svg"); + buttIcon = QIcon::fromTheme("computer.svg"); + break; + + case 7: + iconStr = QString(":/data/img/sidebarwidget/setting.svg"); + buttIcon = QIcon::fromTheme("setting.svg"); + break; + + case 8: + iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); + buttIcon = QIcon::fromTheme("shutdown.svg"); + break; + + default: + break; + } + + if (m_buttonList.indexOf(button) != 3) { + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(iconStr, 19 * ratio); + + if (buttIcon.isNull()) { + pixmap = loadSvg(iconStr, 19 * ratio); + } else { + pixmap = buttIcon.pixmap(QSize(19 * ratio, 19 * ratio)); + } + + if (gsetting.get("style-name").toString() == "ukui-light" && !isFullScreen) { //反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + } + + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + label->setPixmap(pixmap); + } + } +} + +void SideBarWidget::enterAnimation() +{ + m_animation->stop(); + m_animation->setDuration(200);//动画总时间 + m_animation->setStartValue(QRect(this->width(), 0, + 0, this->height())); + m_animation->setEndValue(QRect(this->width() - m_btnWidth - Style::SideBarMargin, 0, + m_btnWidth, this->height())); + m_animation->setEasingCurve(QEasingCurve::InQuart); + m_animation->start(); + m_mainWidget->show(); +} + +void SideBarWidget::setSideBarBtnGeometry() +{ + m_mainWidget->setGeometry(QRect(this->width() - m_btnWidth - Style::SideBarMargin, 0, + m_btnWidth, this->height())); + m_mainWidget->show(); +} + +//void SideBarWidget::mousePressEvent(QMouseEvent *event) +//{ +// if(m_isFullScreen && event->button()==Qt::LeftButton) +// { +// int x=event->x(); +// int y=event->y(); +// QRect rect_1(0,0,this->width()-Style::SideBarBtnWidth-Style::SideBarMargin,this->height()); +// QRect rect_2(this->width()-Style::SideBarBtnWidth-Style::SideBarMargin,0,Style::MinMaxWidWidth,Style::MinMaxWidHeight); +// QRect rect_3(rect_1.width()+m_functionBtn->x(),m_functionBtn->y()+m_functionBtn->height(),Style::SideBarBtnWidth,m_otherButtonList.at(0)->y()-m_functionBtn->y()-m_functionBtn->height()); +// syslog(LOG_LOCAL0 | LOG_DEBUG ,"坐标:%d:%d:%d",x,rect_1.x(),rect_3.x()); +// if((x>=rect_1.x() && x<=rect_1.x()+rect_1.width() && y>=rect_1.y() && y<=rect_1.y()+rect_1.height()) || +// (x>=rect_2.x() && x<=rect_2.x()+rect_2.width() && y>=rect_2.y() && y<=rect_2.y()+rect_2.height()) || +// (x>=rect_3.x() && x<=rect_3.x()+rect_3.width() && y>=rect_3.y() && y<=rect_3.y()+rect_3.height())) +// this->parentWidget()->parentWidget()->hide(); +// } +//} + +void SideBarWidget::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + if (m_allBtn->hasFocus()) { + m_allBtn->click(); + } else if (m_letterBtn->hasFocus()) { + m_letterBtn->click(); + } else if (m_functionBtn->hasFocus()) { + m_functionBtn->click(); + } else { + QWidget *current_focus_widget; + current_focus_widget = QWidget::focusWidget(); + QPushButton *le = qobject_cast(current_focus_widget); + le->clicked(); + } + } + break; + + case Qt::Key_Down: + myDebug() << "key_Down"; + // focusNextChild(); +// if(m_buttonList.at(2)->hasFocus()) +// { +// m_buttonList.at(3)->setFocus(); +// } +// if(m_shutDownBtn->hasFocus()) +// { +// m_minMaxBtn->setFocus(); +// } + break; + + case Qt::Key_Up: + myDebug() << "key_Up"; + // /* focusPreviousChild(); +// if(m_buttonList.at(0)->hasFocus()) +// { +// m_minMaxBtn->setFocus(); +// } + break; + + default: + return QWidget::keyPressEvent(e); + break; + } + } +} + +void SideBarWidget::setFocusToThis() +{ + this->setFocus(); +} diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h new file mode 100644 index 0000000..35fb1c2 --- /dev/null +++ b/src/SideBarWidget/sidebarwidget.h @@ -0,0 +1,249 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "src/Interface/ukuimenuinterface.h" +#include +#include +#include +#include +#include "src/Style/style.h" +#include "src/RightClickMenu/rightclickmenu.h" + +class SideBarWidget : public QWidget +{ + Q_OBJECT + +public: + explicit SideBarWidget(QWidget *parent = nullptr); + ~SideBarWidget(); + /** + * @brief Load the default sidebar + */ + void loadMinSidebar(); + /** + * @brief Load the full-screen sidebar + */ + void loadMaxSidebar(); + /** + * @brief Sidebar animation + */ + void enterAnimation(); + /** + * @brief Adjust the position of the sidebar buttons + */ + void setSideBarBtnGeometry(); + +private: + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + + QWidget *m_mainWidget = nullptr; + QVBoxLayout *m_mainWidgetLayout = nullptr; + + QWidget *m_minMaxWidget = nullptr; + QHBoxLayout *m_minMaxLayout = nullptr; + QPushButton *m_minMaxBtn = nullptr; + + QList m_buttonList; + QList m_labelList; + QStringList m_textList; + QPushButton *m_allBtn = nullptr; + QPushButton *m_letterBtn = nullptr; + QPushButton *m_functionBtn = nullptr; + + QPushButton *m_userIconBtn = nullptr; + QPushButton *m_computerBtn = nullptr; + QPushButton *m_personalBtn = nullptr; + QPushButton *m_controlBtn = nullptr; + QPushButton *m_trashBtn = nullptr; + QPushButton *m_shutDownBtn = nullptr; + QSpacerItem *m_verticalSpacer = nullptr; + bool m_isFullScreen = false; + QGSettings *m_gsetting = nullptr; + // RightClickMenu *m_shutDownMenu=nullptr; + // RightClickMenu *m_otherMenu=nullptr; + QPropertyAnimation *m_animation = nullptr; + + int m_btnWidth, m_btnheight; + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + /** + * @brief Add a sidebar button + */ + void addSidebarBtn(); + /** + * @brief Set button style + * @param btn: QPushButton + * @param btnicon: Button icon + * @param label: QLabel + * @param text: Button text + * @param num: Button Number + */ + void initBtn(QPushButton *btn, QString btnicon, QString text, int num); + /** + * @brief Set the default sidebar button + * @param btn: QPushButton + */ + void setMinSidebarBtn(QPushButton *btn); + /** + * @brief Set the full-screen sidebar button + * @param btn: QPushButton + */ + void setMaxSidebarBtn(QPushButton *btn); + /** + * @brief Add right-click menu + * @param btn: QPushButton + */ + void addRightClickMenu(QPushButton *btn); + /** + * @brief Set the minimize button + */ + void setMinBtn(); + /** + * @brief Set the maximize button + */ + void setMaxBtn(); + QPixmap PixmapToRound(const QPixmap &src, int radius); + void changeIconColor(bool isFullScreen); +// void mousePressEvent(QMouseEvent* event); + void keyPressEvent(QKeyEvent *e); + + bool eventFilter(QObject *target, QEvent *event); + +private Q_SLOTS: + /** + * @brief btnAllClickedSlot + */ + void btnAllClickedSlot(); + /** + * @brief btnLetterClickedSlot + */ + void btnLetterClickedSlot(); + /** + * @brief btnFuncClickedSlot + */ + void btnFuncClickedSlot(); + /** + * @brief Load power button right-click menu + */ + void shutdownBtnRightClickSlot(const QPoint &pos); + /** + * @brief Load other application right-click menu + */ + void otherBtnRightClickSlot(const QPoint &pos); + /** + * @brief Respond to computer btn + */ + void computerBtnClickedSlot(); + /** + * @brief Respond to personal btn + */ + void personalBtnClickedSlot(); + /** + * @brief Respond to control btn + */ + void controlBtnClickedSlot(); + /** + * @brief Respond to trash btn + */ + void trashBtnClickedSlot(); + /** + * @brief Respond to power btn + */ + void shutdownBtnClickedSlot(); + /** + * @brief Respond to user icon btn + */ + void userIconBtnClickedSlot(); + /** + * @brief Monitor user account changes + */ + void userAccountsChanged(); + /** + * @brief Reset the sidebar button + */ + void resetSidebarBtnSlot(); + void themeModeChangeSlot(QString styleName); + +public Q_SLOTS: + + void setFocusToThis(); + +Q_SIGNALS: + /** + * @brief Send all category button signal + */ + void sendCommonUseBtnSignal(); + /** + * @brief Send the letter classification button signal + */ + void sendLetterBtnSignal(); + /** + * @brief Send function classification button signal + */ + void sendFunctionBtnSignal(); + /** + * @brief Send all category button signal of full screen + */ + void sendFullScreenCommonUseBtnSignal(); + /** + * @brief Send the letter classification button of full screen + */ + void sendFullScreenLetterBtnSignal(); + /** + * @brief Send function classification button signal of full screen + */ + void sendFullScreenFunctionBtnSignal(); + /** + * @brief Send a full-screen button click signal + */ + void sendFullScreenBtnSignal(); + /** + * @brief Send the default button click signal + */ + void sendDefaultBtnSignal();//发送默认(还原)按钮点击信号 + /** + * @brief Send a hidden main window signal to the MainWindow + */ + void sendHideMainWindowSignal(); + + void sendShowMainWindowSignal(bool flag); + + void setFocusToMainWin(); + + void setSlideBar(int value); + + void setLineEditFocus(QString arg); +}; + +#endif // SIDEBARWIDGET_H diff --git a/src/Style/style.cpp b/src/Style/style.cpp new file mode 100644 index 0000000..3397119 --- /dev/null +++ b/src/Style/style.cpp @@ -0,0 +1,505 @@ +/* + * 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 + +Style::Style() +{ +} + +int Style::primaryScreenX = 0; +int Style::primaryScreenY = 0; +int Style::primaryScreenWidth = 0; +int Style::primaryScreenHeight = 0; +int Style::panelPosition = 0; +int Style::panelSize = 0; +//默认窗口 +int Style::minw = 0; +int Style::minh = 0; +int Style::defaultMainViewWidWidth = 0; +int Style::defaultTopWidHeight = 0; +int Style::defaultQueryLineEditWidth = 0; +int Style::defaultQueryLineEditHeight = 0; +int Style::defaultQueryLineEditIconSize = 0; +int Style::defaultContentWidHeight = 0; +int Style::defaultSideBarWidWidth = 0; +int Style::defaultIconSize = 32; +/** + * 全屏窗口 + */ +//主窗口 +int Style::widthavailable = 0; +int Style::heightavailable = 0; +//主视图 +int Style::MainViewWidWidth = 0; +//搜索栏 +int Style::TopWidgetHeight = 0; +int Style::QueryLineEditWidth = 0; +int Style::QueryLineEditHeight = 0; +int Style::QueryLineEditFontSize = 0; +int Style::QueryLineEditIconSize = 0; +//左侧栏 +int Style::LeftWidWidth = 0; +int Style::LeftWidHeight = 0; +int Style::LeftMargin = 0; +int Style::RightMargin = 0; +int Style::LeftBtnWidth = 0; +int Style::LeftBtnHeight = 0; +int Style::LeftLetterBtnHeight = 0; +int Style::LeftFontSize = 0; +int Style::LeftLetterFontSize = 0; +int Style::LeftIconSize = 0; +int Style::LeftSpaceIconLeft = 0; +int Style::LeftSpaceIconText = 0; +int Style::LeftSpaceBetweenItem = 0; +//应用列表栏 +int Style::AppListWidWidth = 0; +int Style::AppListWidHeight = 0; +int Style::AppListFontSize = 0; +int Style::AppListIconSize = 0; +int Style::AppListItemSizeWidth = 0; +int Style::AppListGridSizeWidth = 0; +int Style::AppLeftSpace = 0; +int Style::AppTopSpace = 0; +int Style::AppSpaceBetweenIconText = 0; +int Style::AppBottomSpace = 0; +int Style::SliderSize = 0; + +//侧边栏primaryScreen +int Style::SideBarWidWidth = 0; +int Style::SideBarMargin = 0; +int Style::MinMaxWidWidth = 0; +int Style::MinMaxWidHeight = 0; +int Style::MinMaxBtnWidth = 0; +int Style::MinMaxIconSize = 0; +int Style::SideBarBtnWidth = 0; +int Style::SideBarBtnHeight = 0; +int Style::SideBarFontSize = 0; +int Style::SideBarIconSize = 0; +int Style::SideBarSpaceIconLeft = 0; +int Style::SideBarSpaceIconText = 0; +int Style::SideBarSpaceBetweenItem = 0; + + +void Style::initWidStyle() +{ + getScreenAvailableGeometry(); + + int fontSize = 10; + if (QGSettings::isSchemaInstalled(QString("org.mate.interface").toLocal8Bit())) { + QGSettings *setting = new QGSettings(QString("org.mate.interface").toLocal8Bit()); + if (setting->keys().contains(QString("font-name"))) { + QString value = setting->get("font-name").toString(); + QStringList valstr = value.split(" "); + fontSize = valstr.at(valstr.count() - 1).toInt(); + } + } + + int len = 0; + QString locale = QLocale::system().name(); + + if (locale == "zh_CN") { + len = 0; + } else { + len = 10; + } + + primaryScreenWidth = qApp->primaryScreen()->geometry().width(); + primaryScreenHeight = qApp->primaryScreen()->geometry().height(); + + if (primaryScreenWidth == 800 && primaryScreenHeight == 600) { + minw = 320; + minh = 500; + defaultMainViewWidWidth = 264; + defaultTopWidHeight = 54; + defaultQueryLineEditWidth = 245; + defaultQueryLineEditHeight = 32; + defaultContentWidHeight = 446; + defaultSideBarWidWidth = 55; + } else { + minw = 382; + minh = 594; + defaultMainViewWidWidth = 320; + defaultTopWidHeight = 54; + defaultQueryLineEditWidth = 288; + defaultQueryLineEditHeight = 32; + defaultContentWidHeight = 536; + defaultSideBarWidWidth = 55; + } + + if (widthavailable >= 2000 && widthavailable <= 4000) { + AppListWidWidth = 1652; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = 107; + QueryLineEditIconSize = 16; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 20; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 25; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 14; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 15; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 96; + AppListItemSizeWidth = 168; + AppListGridSizeWidth = 202; + AppLeftSpace = 36; + AppTopSpace = 15; + AppSpaceBetweenIconText = 20; +// AppBottomSpace=27; + SliderSize = 20; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 20; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110 + 2 * len; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } else if (widthavailable >= 1920 && widthavailable < 2000) { + myDebug() << "[1920,2000)"; + AppListWidWidth = 1322; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = 107; + QueryLineEditIconSize = 16; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 20; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 25; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 14; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 15; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 86; + AppListItemSizeWidth = 150; + AppListGridSizeWidth = 186; + AppLeftSpace = 32; + AppTopSpace = 13; + AppSpaceBetweenIconText = 18; +// AppBottomSpace=27; + SliderSize = 20; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 20; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110 + 2 * len; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } else if (widthavailable >= 1600 && widthavailable < 1920) { + myDebug() << "[1600,1920)"; + AppListWidWidth = 1070; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = 107; + QueryLineEditIconSize = 14; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 10; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 25; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 11; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 10; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 86; + AppListItemSizeWidth = 150; + AppListGridSizeWidth = 178; + AppLeftSpace = 32; + AppTopSpace = 10; + AppSpaceBetweenIconText = 14; +// AppBottomSpace=static_cast(round(27*0.84)); + SliderSize = 18; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 10; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110 + 2 * len; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } else if (widthavailable >= 1366 && widthavailable < 1600) { + AppListWidWidth = 858; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = round(107 * 0.78); + QueryLineEditIconSize = 14; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 10; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 20; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 11; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 10; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + AppListGridSizeWidth = 138; + AppLeftSpace = 24; + AppTopSpace = 10; + AppSpaceBetweenIconText = 0; +// AppBottomSpace=static_cast(round(27*0.74)); + SliderSize = 18; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 10; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110 + 2 * len; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } else if (widthavailable >= 1280 && widthavailable < 1366) { + AppListWidWidth = 726; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = round(107 * 0.78); + QueryLineEditIconSize = 14; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 10; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 20; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 11; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 10; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + AppListGridSizeWidth = 140; + AppLeftSpace = 24; + AppTopSpace = 10; + AppSpaceBetweenIconText = 14; +// AppBottomSpace=static_cast(round(27*0.65)); + SliderSize = 16; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 10; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110 + 2 * len; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } else if (widthavailable >= 1152 && widthavailable < 1280) { + AppListWidWidth = 726; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = round(107 * 0.78); + QueryLineEditIconSize = 14; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 10; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 20; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 11; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 10; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + AppListGridSizeWidth = 140; + AppLeftSpace = 24; + AppTopSpace = 10; + AppSpaceBetweenIconText = 14; +// AppBottomSpace=static_cast(round(27*0.65)); + SliderSize = 16; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 10; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110 + 2 * len; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } else if (widthavailable > 800 && widthavailable < 1152) { + AppListWidWidth = 580; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = round(107 * 0.78); + QueryLineEditIconSize = 14; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 10; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 20; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 11; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 10; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + AppListGridSizeWidth = 139; + AppLeftSpace = 25; + AppTopSpace = 10; + AppSpaceBetweenIconText = 14; +// AppBottomSpace=static_cast(round(27*0.52)); + SliderSize = 16; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 10; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110 + 2 * len; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } else { + AppListWidWidth = 568; + MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); + TopWidgetHeight = round(107 * 0.78); + QueryLineEditIconSize = 14; + LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); + LeftWidHeight = heightavailable - TopWidgetHeight; + LeftMargin = 10; + LeftBtnWidth = 100 + 5 * len; + LeftBtnHeight = 43; + LeftLetterBtnHeight = 20; + RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; + LeftLetterFontSize = 11; + LeftIconSize = 17; + LeftSpaceIconLeft = 15; + LeftSpaceIconText = 14; + LeftSpaceBetweenItem = 10; + AppListWidHeight = heightavailable - TopWidgetHeight; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + AppListGridSizeWidth = 136; + AppLeftSpace = 25; + AppTopSpace = 10; + AppSpaceBetweenIconText = 14; +// AppBottomSpace=static_cast(round(27*0.52)); + SliderSize = 16; + SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); + SideBarMargin = 10; + MinMaxWidWidth = 110; + MinMaxWidHeight = TopWidgetHeight; + MinMaxBtnWidth = 49; + MinMaxIconSize = 19; + SideBarBtnWidth = 110; + SideBarBtnHeight = 43; + SideBarFontSize = fontSize; + SideBarIconSize = 19; + SideBarSpaceIconLeft = 14; + SideBarSpaceIconText = 10; + SideBarSpaceBetweenItem = 16; + } + + QueryLineEditWidth = 350; + QueryLineEditHeight = 32; + LeftFontSize = fontSize; + QueryLineEditFontSize = fontSize; + AppListFontSize = fontSize; +} + +//不通过任务栏获取屏幕可用区域数据 +void Style::getScreenAvailableGeometry() +{ + QRect rect; + rect = qApp->primaryScreen()->geometry(); + + QDBusInterface iface(DBUS_NAME, + DBUS_PATH, + DBUS_INTERFACE, + QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); + if (reply.isValid()) { + panelSize = reply.value().at(4).toInt(); + panelPosition = reply.value().at(5).toInt(); + } + + QList posIndex; + switch (panelPosition) { + case BOTTOM: + posIndex = {0, 0, 0, -1}; + break; + case TOP: + posIndex = {0, 1, 0, -1}; + break; + case LEFT: + posIndex = {1, 0, -1, 0}; + break; + case RIGHT: + posIndex = {0, 0, -1, 0}; + } + + primaryScreenX = rect.x() + posIndex[0] * panelSize; + primaryScreenY = rect.y() + posIndex[1] * panelSize; + widthavailable = rect.width() + posIndex[2] * panelSize; + heightavailable = rect.height() + posIndex[3] * panelSize; +} diff --git a/src/UtilityFunction/Style/style.h b/src/Style/style.h similarity index 63% rename from src/UtilityFunction/Style/style.h rename to src/Style/style.h index 0a46ea4..c5ef25c 100644 --- a/src/UtilityFunction/Style/style.h +++ b/src/Style/style.h @@ -27,10 +27,12 @@ #include #include #include +#include //颜色 #define BORDERCOLOR "rgba(37,41,43)" //边框 #define SHADOWCOLOR "#80000000" //阴影 + #define UserIconBackground "#ffffff" #define UserIconOpacity 0.20 #define RightClickMenuBackground "rgba(12, 12, 13, 0.7)"//右键菜单背景 @@ -51,7 +53,7 @@ #define QueryLineEditClickedDefaultBackground "rgba(0, 0, 0,0.04)" //搜索框默认态背景选中 #define QueryLineEditClickedBackground "rgba(255, 255, 255,0.06)" //搜索框背景选中 #define QueryLineEditClickedBorderDefault "rgba(0, 0, 0,0.1)" //搜索框默认态背景选中边框 -#define QueryLineEditClickedBorder "rgba(5, 151, 255, 1)" //搜索框背景选中边框 +#define QueryLineEditClickedBorder "rgba(255, 255, 255,0.15)" //搜索框背景选中边框 #define AppBtnHover "#ffffff" //按钮悬浮 /** @@ -60,15 +62,22 @@ ////左侧栏 //#define LeftWidSize leftsize //大小 //#define LeftMarginLeftSize Leftmarginleftsize //内左侧边距 +//#define LeftFontSize leftfontsize //字体大小 +//#define LeftIconSize lefticonsize //图标大小 +//#define LeftSpaceIconLeft leftspaceiconleft //按钮内左侧边距 //#define LeftSpaceIconText leftspaceicontext //按钮图标与文字内边距 //#define LeftSpaceBetweenItem leftspacebetweenitem //item间距 ////应用列表栏 +//#define AppListWidSize applistwidsize //大小 +//#define AppListFontSize applistfontsize //字体大小 //#define AppListIconSize applisticonsize //图标大小 //#define AppListSpaceBetweenItem applistspacebetweenitem //item间距 +//#define SliderSize slidersize //滑块大小 ////右侧栏 //#define RightWidSize rightsize //大小 +//#define RightMarginLeftSize rightmarginleftsize //内右侧边距 //#define RightFontSize rightfontsize //字体大小 //#define RightIconSize righticonsize //图标大小 //#define RightSpaceIconLeft rightspaceiconleft //按钮内左侧边距 @@ -81,97 +90,84 @@ public: Style(); static void initWidStyle(); - static int m_primaryScreenX; - static int m_primaryScreenY; - static int m_panelPosition; + static int primaryScreenX; + static int primaryScreenY; + static int primaryScreenWidth; + static int primaryScreenHeight; + static int panelPosition; + static int panelSize; //默认窗口 static int minw; static int minh; - static int leftPageWidth; - static int leftPageHeight; + static int defaultMainViewWidWidth; + static int defaultTopWidHeight; + static int defaultIconSize; + static int defaultQueryLineEditWidth; + static int defaultQueryLineEditHeight; static int defaultQueryLineEditIconSize; + static int defaultContentWidHeight; + static int defaultSideBarWidWidth; /** * 全屏 */ //主窗口 - static int m_availableScreenWidth; - static int m_availableScreenHeight; + static int widthavailable; + static int heightavailable; + //主视图 + static int MainViewWidWidth;//宽度 //搜索栏 + static int TopWidgetHeight;//高度 + static int QueryLineEditWidth;//搜索框宽度 static int QueryLineEditHeight;//搜索框高度 + static int QueryLineEditIconSize;//搜索框图标 + static int QueryLineEditFontSize;//搜索框字体大小 //左侧栏 - static int m_leftWidWidth; //宽度 + static int LeftWidWidth; //宽度 + static int LeftWidHeight; //高度 static int LeftMargin; //内左侧边距 + static int RightMargin;//内右侧边距 static int LeftBtnWidth;//按钮宽度 static int LeftBtnHeight;//按钮高度 static int LeftLetterBtnHeight;//按钮高度 + static int LeftFontSize; //字体大小 static int LeftLetterFontSize; //字体大小 static int LeftIconSize; //图标大小 + static int LeftSpaceIconLeft; //按钮内左侧边距 static int LeftSpaceIconText; //按钮图标与文字内边距 static int LeftSpaceBetweenItem; //item间距 //应用列表栏 - static int m_applistWidWidth; //宽度 - static int m_applistWidHeight; //高度 + static int AppListWidWidth; //宽度 + static int AppListWidHeight; //高度 + static int AppListFontSize; //字体大小 static int AppListIconSize; //图标大小 - static int AppListBigIconSize; static int AppListItemSizeWidth; //item大小 - static int TabletItemSizeWidthFirst; - static int TabletItemSizeWidthOther; - static int FirsPageViewWidth; - static int OtherPageViewWidth; - static int m_applistGridSizeWidth; //网格大小 + static int AppListGridSizeWidth; //网格大小 static int AppLeftSpace;//左侧边距 static int AppTopSpace;//上侧边距 static int AppSpaceBetweenIconText;//图标与文字边距 - static int FirstPageSpace; - static int OtherPageSpace; + static int AppBottomSpace;//下侧边距 + static int SliderSize; //滑块大小 /** * 侧边栏 */ static int SideBarWidWidth; //宽度 + static int SideBarMargin; //内右侧边距 + static int MinMaxWidWidth; //放大缩小界面宽度 + static int MinMaxWidHeight; //放大缩小界面高度 + static int MinMaxBtnWidth; //放大缩小按钮宽度 + static int MinMaxIconSize; //放大缩小按钮大小 + static int SideBarBtnWidth;//按钮宽度 + static int SideBarBtnHeight;//按钮高度 + static int SideBarFontSize; //字体大小 + static int SideBarIconSize; //图标大小 + static int SideBarSpaceIconLeft; //按钮内左侧边距 + static int SideBarSpaceIconText; //按钮图标与文字内边距 + static int SideBarSpaceBetweenItem; //item间距 - static int appLine; - static int appColumn; - static int appNum; - static int appPage; - static int nowpagenum; - static int appRows; //app的总行数 - static bool ScreenRotation; - - static int AppListItemSizeHeight; - -// static int ScreenWidth; -// static int ScreenHeight; - - - static int LeftWidgetWidth; - - static int ScreenWidth; - static int ScreenHeight; - static int AppListViewTopMargin; - static int AppListViewLeftMargin; - static int AppListViewBottomMargin; - static int AppListViewRightMargin; - static int CenterWindHeight; - - static int GroupAppRow; - static int GroupAppColumn; - - static int TimeWidgetTop; - static int TimeWidgetLeft; - - static int ButtonWidgetWidth; - - //扩展的开始菜单应用列表 - static int ToolWidgetLeft; - static int WideAppListItemSizeWidth; - static int WideAppListItemSizeHeight; - static int WideAppViewLeftMargin; - static bool IsWideScreen; - static int DropMenuWidth; - static int DropMenuHeight; - static int miniIconSize; +private: + static void getScreenAvailableGeometry(); //获取屏幕可用区域 }; diff --git a/src/UserInterface/ListView/fulllistview.cpp b/src/UserInterface/ListView/fulllistview.cpp deleted file mode 100644 index 3206c8a..0000000 --- a/src/UserInterface/ListView/fulllistview.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 -#include -#include -#include - -FullListView::FullListView(QWidget *parent, int module): - KListView(parent) -{ - this->module = module; - initWidget(); - m_delegate = new FullItemDelegate(this, module); - this->setItemDelegate(m_delegate); - pUkuiMenuInterface = new UkuiMenuInterface; -} - -FullListView::~FullListView() -{ - delete menu; - delete gsetting; -} - -void FullListView::initWidget() -{ - viewport()->setAttribute(Qt::WA_TranslucentBackground); - this->setSelectionMode(QAbstractItemView::SingleSelection); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setViewMode(QListView::IconMode); - this->setContextMenuPolicy(Qt::CustomContextMenu); - this->setResizeMode(QListView::Adjust); - this->setTextElideMode(Qt::ElideRight); - this->setMouseTracking(true); - this->setMovement(QListView::Static); - this->setEditTriggers(QAbstractItemView::NoEditTriggers); - this->setGridSize(QSize(Style::m_applistGridSizeWidth, Style::m_applistGridSizeWidth)); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - this->setFrameShape(QFrame::NoFrame);//移除边框 - //this->setStyleSheet(QString::fromUtf8("QStandardItemModel#listmodel{border:3px solid #FFFFFF; }QWidget#widget:focus{ border:5px solid #A5A6A1; } ")); - connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); - connect(this, &FullListView::clicked, this, &FullListView::onClicked); -} - -void FullListView::selectFirstItem() -{ - if (this->currentIndex().row() == -1) { - this->setCurrentIndex(this->model()->index(0, 0)); - } -} - -void FullListView::keyPressEvent(QKeyEvent *e) -{ - QRect center = visualRect(currentIndex()); - - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - break; - } - - case Qt::Key_Left: { - this->clearFocus(); - - if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::m_applistGridSizeWidth) { - Q_EMIT sendSetslidebar(-Style::m_applistGridSizeWidth); - } - - this->setFocus(); - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Right: { - this->clearFocus(); - - if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::m_applistGridSizeWidth)) { - Q_EMIT sendSetslidebar(Style::m_applistGridSizeWidth); - } - - this->setFocus(); - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Up: { - if (module == 0) { - if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::m_applistGridSizeWidth)) { - Q_EMIT sendSetslidebar(-Style::m_applistGridSizeWidth); - } - } - - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Down: { - if (module == 0) { - if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::m_applistGridSizeWidth)) { - Q_EMIT sendSetslidebar(Style::m_applistGridSizeWidth); - } - } - - return QListView::keyPressEvent(e); - break; - } - - default: - return QListView::keyPressEvent(e); - } - } -} diff --git a/src/UserInterface/ListView/klistview.cpp b/src/UserInterface/ListView/klistview.cpp deleted file mode 100644 index 012b52a..0000000 --- a/src/UserInterface/ListView/klistview.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include "klistview.h" -#include "utility.h" -#include -#include "rightclickmenu.h" - -KListView::KListView(QWidget *parent): - QListView(parent) -{ -} - -KListView::~KListView() -{ - delete m_delegate; - delete listmodel; - delete pUkuiMenuInterface; -} - -void KListView::addData(QStringList data) -{ - listmodel = new QStandardItemModel(this); - this->setModel(listmodel); - - Q_FOREACH (QString desktopfp, data) { - QStandardItem *item = new QStandardItem; - item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); - listmodel->appendRow(item); - } -} - -void KListView::updateData(QStringList data) -{ - listmodel->clear(); - - Q_FOREACH (QString desktopfp, data) { - QStandardItem *item = new QStandardItem; - item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); - listmodel->appendRow(item); - } -} - -void KListView::onClicked(QModelIndex index) -{ - QVariant var = listmodel->data(index, Qt::DisplayRole); - - if (var.isValid()) { - QString desktopfp = var.value(); - execApp(desktopfp); - } -} - -void KListView::paintEvent(QPaintEvent *e) -{ - double transparency = getTransparency(); - QPainter painter(this->viewport()); - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); - QListView::paintEvent(e); -} - -void KListView::mousePressEvent(QMouseEvent *event) -{ - if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { - Q_EMIT sendHideMainWindowSignal(); - } else { - pressApp = listmodel->data(this->indexAt(event->pos()), Qt::DisplayRole); - return QListView::mousePressEvent(event); - } -} - -void KListView::rightClickedSlot(const QPoint &pos) -{ - Q_UNUSED(pos) - - if (!(this->selectionModel()->selectedIndexes().isEmpty())) { - QModelIndex index = this->currentIndex(); - QVariant var = listmodel->data(index, Qt::DisplayRole); - QStringList strlist = var.value(); - - if (strlist.count() == 1 || ((strlist.count() == 2) && (strlist.at(1).toInt() == 1))) { - RightClickMenu menu; - int ret = menu.showAppBtnMenu(this->mapToGlobal(pos), strlist.at(0)); - - switch (ret) { - case 1: - case 2: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 6: - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - - case 18: - Q_EMIT sendCollectViewUpdate(); - break; - - default: - break; - } - } - } -} diff --git a/src/UserInterface/ListView/klistview.h b/src/UserInterface/ListView/klistview.h deleted file mode 100644 index 1d86cce..0000000 --- a/src/UserInterface/ListView/klistview.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef KLISTVIEW_H -#define KLISTVIEW_H -#include -#include "kitemdelegate.h" -#include -#include -#include - -class KListView : public QListView -{ - Q_OBJECT -public: - KListView(QWidget *parent); - ~KListView(); - void initWidget(); - - KItemDelegate *m_delegate = nullptr; - QStandardItemModel *listmodel = nullptr; - int module = 0; - double transparency; - QVariant pressApp; - UkuiMenuInterface *pUkuiMenuInterface = nullptr; -protected: - void paintEvent(QPaintEvent *e); - void mousePressEvent(QMouseEvent *event); -public: - void addData(QStringList data); - void updateData(QStringList data); - -Q_SIGNALS: - void sendHideMainWindowSignal(); - void sendItemClickedSignal(QString arg);//发送item点击信号 - void sendUpdateAppListSignal(); - void sendCollectViewUpdate(); - -public Q_SLOTS: - void rightClickedSlot(const QPoint &pos); - void onClicked(QModelIndex index); -}; - -#endif // KLISTVIEW_H diff --git a/src/UserInterface/ListView/rightlistview.cpp b/src/UserInterface/ListView/rightlistview.cpp deleted file mode 100644 index e8dec33..0000000 --- a/src/UserInterface/ListView/rightlistview.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 -#include -#include -#include - -RightListView::RightListView(QWidget *parent): - KListView(parent) -{ - initWidget(); - m_delegate = new RightItemDelegate(this); - this->setItemDelegate(m_delegate); - pUkuiMenuInterface = new UkuiMenuInterface; -} - -RightListView::~RightListView() -{ - delete pUkuiMenuInterface; -} - -void RightListView::initWidget() -{ - setAttribute(Qt::WA_TranslucentBackground); - viewport()->setAttribute(Qt::WA_TranslucentBackground); - viewport()->setAutoFillBackground(false); - this->setSelectionMode(QAbstractItemView::SingleSelection); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setViewMode(QListView::IconMode); - this->setContextMenuPolicy(Qt::CustomContextMenu); - this->setResizeMode(QListView::Adjust); - this->setTextElideMode(Qt::ElideRight); - this->setMouseTracking(true); - this->setMovement(QListView::Static); - this->setEditTriggers(QAbstractItemView::NoEditTriggers); - this->setGridSize(QSize(107, 107)); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - this->setFrameShape(QFrame::NoFrame);//移除边框 - connect(this, &RightListView::customContextMenuRequested, this, &RightListView::rightClickedSlot); - connect(this, &RightListView::clicked, this, &RightListView::onClicked); -} - -void RightListView::dropEvent(QDropEvent *event) -{ - RightListView *source = qobject_cast(event->source()); - - if (source && source == this) { - m_dropPos = event->pos(); - - if (this->indexAt(m_dropPos).isValid()) { - QVariant var = listmodel->data(indexAt(m_dropPos), Qt::DisplayRole); - QString desktopfp = var.value(); - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - QString dragDesktopfp = pressApp.value(); - QFileInfo dragFileInfo(dragDesktopfp); - QString dragDesktopfn = dragFileInfo.fileName(); - changeCollectSort(dragDesktopfn, desktopfn); - } - } - - Q_EMIT sendCollectViewUpdate(); -} - -void RightListView::selectFirstItem() -{ - myDebug() << "选择首个元素"; - - if (this->currentIndex().row() == -1) { - this->setCurrentIndex(this->model()->index(0, 0)); - } -} - -void RightListView::paintEvent(QPaintEvent *e) -{ - QListView::paintEvent(e); -} - -void RightListView::keyPressEvent(QKeyEvent *e) -{ - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - break; - } - - default: - return QListView::keyPressEvent(e); - break; - } - } -} - -void RightListView::changeStyleColor(const QColor &color) -{ - m_styleColor = color; -} - -void RightListView::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - this->selectionModel()->clear(); -} diff --git a/src/UserInterface/ListView/rightlistview.h b/src/UserInterface/ListView/rightlistview.h deleted file mode 100644 index c75e0cc..0000000 --- a/src/UserInterface/ListView/rightlistview.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef RIGHTLISTVIEW_H -#define RIGHTLISTVIEW_H -#include -#include -#include "rightclickmenu.h" -#include "ukuimenuinterface.h" -#include -#include -#include -#include -#include "right_item_delegate.h" -#include "style.h" -#include "utility.h" -#include "klistview.h" - -class RightListView : public KListView -{ - Q_OBJECT -public: - RightListView(QWidget *parent); - ~RightListView(); - - void initWidget(); -protected: - - void keyPressEvent(QKeyEvent *e); - void dropEvent(QDropEvent *event); - void enterEvent(QEvent *e); - void paintEvent(QPaintEvent *e); - -private: - RightClickMenu *menu = nullptr; //右键菜单 - QStringList data; - QGSettings *gsetting; - QPoint m_dropPos; - QColor m_styleColor; - -// bool inCurView; - -public Q_SLOTS: - -// void rightClickedSlot(const QPoint &pos);//右键菜单 - void selectFirstItem(); - void changeStyleColor(const QColor &color); - -Q_SIGNALS: - - void sendSetslidebar(int value); -}; - -#endif // FULLLISTVIEW_H diff --git a/src/UserInterface/ListView/tabletlistview.cpp b/src/UserInterface/ListView/tabletlistview.cpp deleted file mode 100644 index 6a957f4..0000000 --- a/src/UserInterface/ListView/tabletlistview.cpp +++ /dev/null @@ -1,809 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#define TABLED_SCHEMA "org.ukui.SettingsDaemon.plugins.tablet-mode" -#define TABLET_MODE "tablet-mode" -/*初始化*/ -TabletListView::TabletListView(QWidget *parent, int pageNum): - QListView(parent) -{ - QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(this); - shadowEffect->setOffset(0, 0); - shadowEffect->setColor(QColor(26, 26, 28, 150)); - shadowEffect->setBlurRadius(15); - this->setGraphicsEffect(shadowEffect); - this->setAcceptDrops(true); - this->m_pageNum = pageNum; - initWidget(); - pUkuiMenuInterface = new UkuiMenuInterface; - menu = new TabletRightClickMenu; - //应用列表 - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - setting = new QSettings(path, QSettings::IniFormat); - //禁用列表 - QString pathini = QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"; - disableSetting = new QSettings(pathini, QSettings::IniFormat); - //不可卸载列表 - QString syspath = QDir::homePath() + "/.config/ukui/menusysapplist.ini"; - syssetting = new QSettings(syspath, QSettings::IniFormat); - setDragEnabled(true); - //翻页灵敏度时间调节 - m_time = new QTimer(this); - connect(m_time, &QTimer::timeout, [ = ]() { - if (m_flat == false) { - m_flat = true; - m_time->stop(); - } - }); -} - -TabletListView::~TabletListView() -{ - if (pUkuiMenuInterface) { - delete pUkuiMenuInterface; - } - - if (menu) { - delete menu; - } - - if (setting) { - delete setting; - } - - if (disableSetting) { - delete disableSetting; - } - - if (tabletMode) { - delete tabletMode; - } - - if (m_animation) { - delete m_animation; - } - - if (m_time) { - delete m_time; - } - - if (listmodel) { - delete listmodel; - } - - if (m_delegate) { //can - delete m_delegate; - } - - pUkuiMenuInterface = nullptr; - menu = nullptr; - setting = nullptr; - disableSetting = nullptr; - tabletMode = nullptr; - m_animation = nullptr; - m_time = nullptr; - listmodel = nullptr; - m_delegate = nullptr; - - if (syssetting) { - delete syssetting; - } - - syssetting = nullptr; -} - -void TabletListView::initWidget() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSelectionMode(QAbstractItemView::SingleSelection); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setAutoFillBackground(false); - this->setAttribute(Qt::WA_TranslucentBackground); - this->setWindowFlags(Qt::FramelessWindowHint);//无边框 - viewport()->setAttribute(Qt::WA_TranslucentBackground); - this->viewport()->setUpdatesEnabled(true); - this->setViewMode(QListView::IconMode); - this->setContextMenuPolicy(Qt::CustomContextMenu); - this->setResizeMode(QListView::Adjust); - this->setTextElideMode(Qt::ElideRight); - this->setMouseTracking(true); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setFocusPolicy(Qt::NoFocus); - this->setMovement(QListView::Snap); - this->setFrameShape(QFrame::NoFrame); - this->setContentsMargins(0, 0, 0, 0); - this->setSpacing(0); - this->setEditTriggers(QAbstractItemView::NoEditTriggers); - connect(this, &TabletListView::customContextMenuRequested, this, &TabletListView::rightClickedSlot); -} -//添加数据 -void TabletListView::addData(QStringList data) -{ - listmodel = new QStandardItemModel(this); - this->setModel(listmodel); - - Q_FOREACH (QString desktopfp, data) { - QStandardItem *item = new QStandardItem; - item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); - bool appDis = appDisable(desktopfp); - item->setData(QVariant::fromValue(appDis), Qt::UserRole + 2); - listmodel->appendRow(item); - } - - m_delegate = new TabletFullItemDelegate(this, m_pageNum); - this->setItemDelegate(m_delegate); -} - -void TabletListView::updateData(QStringList data) -{ - listmodel->clear(); - - Q_FOREACH (QString desktopfp, data) { - QStandardItem *p_item = new QStandardItem; - p_item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); - bool appDis = appDisable(desktopfp); - p_item->setData(QVariant::fromValue(appDis), Qt::UserRole + 2); - listmodel->appendRow(p_item); - } - - m_delegate = new TabletFullItemDelegate(this, m_pageNum); - this->setItemDelegate(m_delegate); -} - -bool TabletListView::appDisable(QString desktopfp) //判断是否是禁用应用(这个还有问题暂时不会用) -{ - QString str; - //打开文件.desktop - GError **pp_error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *p_keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *p_filepath = fpbyte.data(); - g_key_file_load_from_file(p_keyfile, p_filepath, flags, pp_error); - char *p_name = g_key_file_get_locale_string(p_keyfile, "Desktop Entry", "Exec", nullptr, nullptr); - //取出value值 - QString execnamestr = QString::fromLocal8Bit(p_name); - //处理value值 - str = execnamestr; - // str = execnamestr.section(' ', 0, 0); - // QStringList list = str.split('/'); - // str = list[list.size()-1]; - //关闭文件 - g_key_file_free(p_keyfile); - QString desktopfp1 = str; - disableSetting->beginGroup("application"); - //判断 - bool bo = disableSetting->contains(desktopfp1.toLocal8Bit().data());// iskey - bool bo1 = disableSetting->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool();//isvalue - disableSetting->endGroup(); - - //qDebug()<setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); - m_item->setData(QVariant::fromValue(0), Qt::UserRole); - listmodel->appendRow(m_item); -} - -/*点击执行*/ -void TabletListView::onClicked(QModelIndex index) -{ - QVariant var = listmodel->data(index, Qt::DisplayRole); - - if (var.isValid()) { - QString desktopfp = var.value(); - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - setting->beginGroup("groupname"); - bool iscontain = setting->contains(desktopfn); - setting->endGroup(); - - if (!appDisable(desktopfp)) { - Q_EMIT sendHideMainWindowSignal(); - } - - if (iscontain) { - // Q_EMIT sendGroupClickSignal(desktopfn); - } else { - Q_EMIT sendItemClickedSignal(desktopfp); - } - } -} - -bool TabletListView::uninstall(QString desktopfp) //判断是否可以卸载 -{ - syssetting->beginGroup("ukui-menu-sysapplist"); - QStringList sysapplist = syssetting->allKeys(); - syssetting->sync(); - syssetting->endGroup(); - QString appstr = desktopfp.section(' ', 0, 0); - QStringList strlist = appstr.split('/'); - appstr = strlist[strlist.size() - 1]; - - if (sysapplist.contains(appstr)) { - myDebug() << "默认应用"; - return 0; - } - - return 1; -} - -/*右键*/ -void TabletListView::rightClickedSlot(const QPoint &pos) -{ - Q_UNUSED(pos) - this->model()->setData(this->indexAt(right_pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); - - if (!(this->selectionModel()->selectedIndexes().isEmpty())) { - QModelIndex index = this->currentIndex(); - QVariant var = listmodel->data(index, Qt::DisplayRole); - QString desktopfp = var.value(); - bool isinstall = uninstall(desktopfp);//判断是否为安装的应用可卸载 - int ret = menu->showAppBtnMenu(desktopfp, isinstall); - - switch (ret) { - case 1: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 2: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - - default: - break; - } - - right_iconClick = false; - this->selectionModel()->clear(); - } -} - -void TabletListView::mousePressEvent(QMouseEvent *event) -{ - myDebug() << "鼠标点击事件触发"; - pressedpos = event->pos(); - - if (event->button() == Qt::LeftButton) { - //左键 - myDebug() << "左键点击,当前点坐标" << event->pos(); - - if (((this->indexAt(event->pos()).isValid()) && (m_pageNum == FIRSTPAGE) && (((pressedpos.x() % Style::TabletItemSizeWidthFirst) >= Style::FirstPageSpace) && - ((pressedpos.x() % Style::TabletItemSizeWidthFirst) <= (Style::FirstPageSpace + Style::AppListIconSize)) && - ((pressedpos.y() % Style::AppListItemSizeHeight) >= Style::AppTopSpace) && - ((pressedpos.y() % Style::AppListItemSizeHeight) <= (Style::AppTopSpace + Style::AppListIconSize)))) || - ((this->indexAt(event->pos()).isValid()) && (m_pageNum == OTHERPAGE) && - (pressedpos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace && - pressedpos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize && - pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && - pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) { - pressApp = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole); - iconClick = true; - startPos = event->pos(); - listmodel->setData(this->indexAt(pressedpos), 1, Qt::UserRole + 2); - repaint(); - } else { - iconClick = false; - listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); - pressedpos = event->pos(); - moveing_pressedpos = pressedpos; - press_time = event->timestamp(); - } - } else if (event->button() == Qt::RightButton) { - //右键 - myDebug() << "右键点击,当前点坐标" << event->pos(); - - if (((this->indexAt(event->pos()).isValid()) && (m_pageNum == FIRSTPAGE) && ((pressedpos.x()) % Style::TabletItemSizeWidthFirst >= Style::FirstPageSpace && - (pressedpos.x()) % Style::TabletItemSizeWidthFirst <= Style::FirstPageSpace + Style::AppListIconSize && - pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && - pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize)) || - ((this->indexAt(event->pos()).isValid()) && (m_pageNum == OTHERPAGE) && - (pressedpos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace && - pressedpos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize && - pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && - pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) { - pressApp = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole); - right_iconClick = true; - right_pressedpos = pressedpos; - listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(1), Qt::UserRole + 2); - this->selectionModel()->setCurrentIndex(this->indexAt(event->pos()), QItemSelectionModel::SelectCurrent); - } else { - right_iconClick = false; - listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); - } - } - - event->accept(); -} - -void TabletListView::mouseMoveEvent(QMouseEvent *event) -{ - if (event->buttons() & Qt::LeftButton & this->indexAt(event->pos()).isValid()) { - if (iconClick) { - if ((event->pos() - startPos).manhattanLength() >= QApplication::startDragDistance()) { - myDebug() << "进入拖拽事件"; - //this->setCursor(Qt::ClosedHandCursor); - QModelIndex theDragIndex = indexAt(startPos); - theDragRow = theDragIndex.row(); - //[1]把拖拽数据放在QMimeData容器中 - QString desktopfp = this->indexAt(startPos).data(Qt::DisplayRole).value(); - QByteArray itemData = desktopfp.toLocal8Bit();; - QMimeData *mimeData = new QMimeData; - ThumbNail *dragImage = new ThumbNail(this); - QDrag *drag = new QDrag(this); - mimeData->setData("INFO", itemData); - //[2]设置拖拽时的缩略图 - dragImage->setupthumbnail(desktopfp); - QPixmap pixmap = dragImage->grab(); - drag->setMimeData(mimeData); - drag->setPixmap(pixmap); - drag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2)); - m_isDraging = true; - - if (drag->exec(Qt::MoveAction) == Qt::MoveAction) { - } - - m_isDraging = false; - delete drag; //setMimeData 使得mimeData归drag所有,不需要单独进行delele处理 - delete dragImage; - drag = nullptr; - dragImage = nullptr; - } - } - } - - event->ignore(); -} -void TabletListView::dragMoveEvent(QDragMoveEvent *event) -{ - moveing_pressedpos = event->pos(); - - //拖拽特效绘制 - if (m_flat == true) { - m_flat = false; - m_time->start(500); - - if (m_pageNum == OTHERPAGE) { - if (event->pos().x() >= (Style::OtherPageViewWidth - (Style::OtherPageSpace / 2)) || event->pos().x() <= (Style::OtherPageSpace / 2)) { - if (event->pos().x() <= (Style::OtherPageSpace / 2)) { - Q_EMIT pagenumchanged(false); - } - - if (event->pos().x() >= (Style::OtherPageViewWidth - (Style::OtherPageSpace / 2))) { - Q_EMIT pagenumchanged(true); - } - } - } else { - if (event->pos().x() >= (Style::FirsPageViewWidth - (Style::FirstPageSpace / 2))) { - Q_EMIT pagenumchanged(true); - } - } - } - - event->accept(); -} - -void TabletListView::dragEnterEvent(QDragEnterEvent *event) -{ - iconClick = true; - event->accept(); -} - -void TabletListView::dropEvent(QDropEvent *event) -{ - dropPos = event->pos(); - pressDesktopfp = (QString)event->mimeData()->data("INFO"); - insertApplication(startPos, dropPos); - this->model()->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); -} -void TabletListView::mouseReleaseEvent(QMouseEvent *e) -{ - releasepos = e->pos();//释放的位置坐标 - - if (iconClick) { - if (e->button() == Qt::LeftButton) { - if (qAbs(releasepos.x() - pressedpos.x()) <= 5 && qAbs(releasepos.y() - pressedpos.y()) <= 5 - && this->indexAt(releasepos) == this->indexAt(pressedpos)) { - QEventLoop loop1; - QTimer::singleShot(200, &loop1, SLOT(quit())); - loop1.exec(); - listmodel->setData(this->indexAt(pressedpos), 0, Qt::UserRole + 2); - QEventLoop loop; - QTimer::singleShot(200, &loop, SLOT(quit())); - loop.exec(); - Q_EMIT onClicked(this->indexAt(e->pos())); - } - } - } else { - if (e->button() == Qt::LeftButton) { - int dist_y = releasepos.y() - pressedpos.y(); - int dist_x = releasepos.x() - pressedpos.x(); - - if (((pressedpos - releasepos).manhattanLength() <= QApplication::startDragDistance() || pressedpos == releasepos)) { - qDebug() << "sendHideMainWindowSignal"; - Q_EMIT sendHideMainWindowSignal(); - } else { - if (2 * qAbs(dist_x) >= qAbs(dist_y)) { - if (qAbs(dist_x) >= 80) { - if ((dist_x >= 80)) { - Q_EMIT pagenumchanged(false); - } else if ((dist_x <= -80)) { - Q_EMIT pagenumchanged(true); - } - } - } - } - } - - if (right_iconClick) { - this->selectionModel()->setCurrentIndex(this->indexAt(right_pressedpos), QItemSelectionModel::SelectCurrent); - Q_EMIT customContextMenuRequested(right_pressedpos); - } - } - - e->accept(); - listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); - iconClick = false;//是否点钟图标 - right_iconClick = false;//是否右键点中图标 - theDragRow = -1; - this->setCursor(Qt::ArrowCursor); -} - -//拖拽移动的时候,如果不是应用的话,就交换位置 -void TabletListView::insertApplication(QPoint pressedpos, QPoint releasepos) -{ - if (false) {//不同分类分页显示备用 - QVariant var2 = pressApp; - QString desktopfp2 = var2.value(); - QFileInfo fileInfo2(desktopfp2); - QString desktopfn2 = fileInfo2.fileName(); - - if (m_pageNum == FIRSTPAGE) { - releasepos.setX(releasepos.x() + Style::OtherPageSpace); - } else { - releasepos.setX(releasepos.x() + Style::FirstPageSpace); - } - - QVariant var3 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//释放位置右侧有应用 - QString desktopfp3 = var3.value();//释放位置的应用 - QFileInfo fileInfo3(desktopfp3); - QString desktopfn3 = fileInfo3.fileName(); - - if (m_pageNum == FIRSTPAGE) { - releasepos.setX(releasepos.x() - (Style::OtherPageSpace * 2)); - } else { - releasepos.setX(releasepos.x() - (Style::FirstPageSpace * 2)); - } - - QVariant var4 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//右侧没有左侧有 - QString desktopfp4 = var4.value();//释放位置的应用 - QFileInfo fileInfo4(desktopfp4); - QString desktopfn4 = fileInfo4.fileName(); - //qDebug()<<"4rel"<beginGroup("application"); - QStringList keyList = setting->allKeys(); - setting->sync(); - setting->endGroup(); - - if (keyList.contains(desktopfn2)) { - editString = "application"; - } - - setting->beginGroup("tencent"); - QStringList keyTecentList = setting->allKeys(); - setting->sync(); - setting->endGroup(); - - if (keyTecentList.contains(desktopfn2)) { - editString = "tencent"; - } - - setting->beginGroup("thirdParty"); - QStringList keyThirdList = setting->allKeys(); - setting->sync(); - setting->endGroup(); - - if (keyThirdList.contains(desktopfn2)) { - editString = "thirdParty"; - } - - setting->beginGroup("customized"); - QStringList customizedList = setting->allKeys(); - setting->sync(); - setting->endGroup(); - - if (customizedList.contains(desktopfn2)) { - editString = "customized"; - } - - if (var3.isValid() && desktopfp3 != desktopfp2) { - setting->beginGroup(editString); - int indexPre = setting->value(desktopfn2).toInt(); - int indexRel = setting->value(desktopfn3).toInt(); - QStringList keyList = setting->allKeys(); - - if (indexPre > indexRel) { - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() >= indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); - } - } - - setting->setValue(desktopfn2, indexRel); - } else if (indexPre < indexRel) { - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() < indexRel) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); - } - } - - setting->setValue(desktopfn2, indexRel - 1); - } - - setting->sync(); - setting->endGroup(); - } else if (var4.isValid() && desktopfp4 != desktopfp2) { - setting->beginGroup(editString); - int indexPre = setting->value(desktopfn2).toInt(); - int indexRel = setting->value(desktopfn4).toInt(); - QStringList keyList = setting->allKeys(); - - if (indexPre < indexRel) { - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() <= indexRel) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); - } - } - - setting->setValue(desktopfn2, indexRel); - } else if (indexPre > indexRel) { - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() > indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); - } - } - - setting->setValue(desktopfn2, indexRel + 1); - } - - setting->sync(); - setting->endGroup(); - } - - Q_EMIT sendUpdateAppListSignal(); - } else { - QFileInfo fileInfo2(pressDesktopfp); - QString desktopfn2 = fileInfo2.fileName(); - - if (((this->indexAt(releasepos).isValid()) && (m_pageNum == FIRSTPAGE) && ((releasepos.x()) % Style::TabletItemSizeWidthFirst >= Style::FirstPageSpace && - (releasepos.x()) % Style::TabletItemSizeWidthFirst <= Style::FirstPageSpace + Style::AppListIconSize && - releasepos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && - releasepos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize)) || - ((this->indexAt(releasepos).isValid()) && (m_pageNum == OTHERPAGE) && - (releasepos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace && - releasepos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize && - releasepos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && - releasepos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) { - return; - } - - if (m_pageNum == FIRSTPAGE) { - releasepos.setX(releasepos.x() + Style::FirstPageSpace); - } else { - releasepos.setX(releasepos.x() + Style::OtherPageSpace); - } - - QVariant var3 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//释放位置右侧有应用 - QString desktopfp3 = var3.value();//释放位置的应用 - QFileInfo fileInfo3(desktopfp3); - QString desktopfn3 = fileInfo3.fileName(); - - if (m_pageNum == FIRSTPAGE) { - releasepos.setX(releasepos.x() - Style::FirstPageSpace * 2); - } else { - releasepos.setX(releasepos.x() - Style::OtherPageSpace * 2); - } - - QVariant var4 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//右侧没有左侧有 - QString desktopfp4 = var4.value();//释放位置的应用 - QFileInfo fileInfo4(desktopfp4); - QString desktopfn4 = fileInfo4.fileName(); - - //qDebug()<<"4rel"<beginGroup("application"); - int indexPre = setting->value(desktopfn2).toInt(); - int indexRel = setting->value(desktopfn3).toInt(); - QStringList keyList = setting->allKeys(); - - if (indexPre > indexRel) { - myDebug() << ">"; - - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() >= indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); - } - } - - setting->setValue(desktopfn2, indexRel); - } else if (indexPre < indexRel) { - qDebug() << "<"; - - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() < indexRel) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); - } - } - - setting->setValue(desktopfn2, indexRel - 1); - } - - setting->sync(); - setting->endGroup(); - } else if (var4.isValid() && desktopfp4 != pressDesktopfp) { - setting->beginGroup("application"); - int indexPre = setting->value(desktopfn2).toInt(); - int indexRel = setting->value(desktopfn4).toInt(); - QStringList keyList = setting->allKeys(); - - if (indexPre < indexRel) { - // qDebug()<<"4 <"; - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() <= indexRel) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); - } - } - - setting->setValue(desktopfn2, indexRel); - } else if (indexPre > indexRel) { - qDebug() << ">"; - - for (int i = 0; i < keyList.count(); i++) { - if (setting->value(keyList.at(i)).toInt() > indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { - setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); - } - } - - setting->setValue(desktopfn2, indexRel + 1); - } - - setting->sync(); - setting->endGroup(); - } - - // } - Q_EMIT sendUpdateAppListSignal(); - } -} - -//拖拽移动的时候,如果是应用,就组成组合框 -void TabletListView::mergeApplication(QPoint pressedpos, QPoint releasepos) -{ - QVariant var1 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole); - QVariant var2 = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole); - - if (var1 != var2) { - QString desktopfp1 = var1.value(); //鼠标释放位置的应用 - QFileInfo fileInfo1(desktopfp1); - QString desktopfn1 = fileInfo1.fileName(); - QString desktopfp2 = var2.value(); //鼠标点击位置的应用 - QFileInfo fileInfo2(desktopfp2); - QString desktopfn2 = fileInfo2.fileName(); - setting->beginGroup("groupname"); - bool isgroup = setting->contains(desktopfn2); - setting->endGroup(); - - if (!isgroup) { - // qDebug() <<"拖拽"; - //合并 - setting->beginGroup("groupname"); - QStringList groupList = setting->allKeys(); - bool iscontain = setting->contains(desktopfn1); - setting->endGroup(); - - if (iscontain) { //组存在,把应用加入组中,同时去掉position里的键值。 - qDebug() << "组存在,找到这个组,把应用加入里边"; - setting->beginGroup(desktopfn1); - setting->setValue(desktopfn2, setting->allKeys().count()); - setting->sync(); - setting->endGroup(); - setting->beginGroup("application"); - int indexPre = setting->value(desktopfn2).toInt(); - QStringList appList = setting->allKeys(); - - for (int i = 0; i < appList.count(); i++) { - if (setting->value(appList.at(i)).toInt() >= indexPre) { - setting->setValue(appList.at(i), setting->value(appList.at(i)).toInt() - 1); - } - } - - setting->remove(desktopfn2); - setting->sync(); - setting->endGroup(); - listmodel->removeRow(this->indexAt(pressedpos).row()); - this->viewport()->update(); - } else { //如果组不存在的话 - setting->beginGroup("groupname"); - QString group = QString("group%1").arg(groupList.count() + 1); - QString groupname = QString("group%1").arg(groupList.count() + 1); - setting->setValue(group, groupname); - setting->sync(); - setting->endGroup(); - setting->beginGroup(group); - setting->setValue(desktopfn2, 0); - setting->setValue(desktopfn1, 1); - setting->sync(); - setting->endGroup(); - setting->beginGroup("application"); - int indexPre = setting->value(desktopfn2).toInt(); - int indexRel = setting->value(desktopfn1).toInt(); - setting->setValue(groupname, indexRel); - QStringList appList = setting->allKeys(); - - for (int i = 0; i < appList.count(); i++) { - if (setting->value(appList.at(i)).toInt() >= indexPre) { - setting->setValue(appList.at(i), setting->value(appList.at(i)).toInt() - 1); - } - } - - setting->remove(desktopfn1); - setting->remove(desktopfn2); - setting->sync(); - setting->endGroup(); - listmodel->removeRow(this->indexAt(pressedpos).row()); - listmodel->removeRow(this->indexAt(releasepos).row()); - listmodel->insertRow(this->indexAt(releasepos).row()); - QVariant variant = QVariant::fromValue(QString("usr/share/application/%1").arg(group)); - listmodel->setData(this->indexAt(releasepos), variant); - } - } - } -} - - - diff --git a/src/UserInterface/ListView/tabletlistview.h b/src/UserInterface/ListView/tabletlistview.h deleted file mode 100644 index 5980d2c..0000000 --- a/src/UserInterface/ListView/tabletlistview.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 -#include "ukuimenuinterface.h" -#include "rightclickmenu.h" -//#include "src/GroupListView/grouplistview.h" -//#include "src/GroupListView/grouplistwidget.h" -#include -#include -#include -#include -#include "tablet_full_itemdelegate.h" -#include "style.h" -#include "thumbnail.h" -#include -#include -#include -#include -#include -#include "full_item_delegate.h" -#include "tabletrightclickmenu.h" -#include "klistview.h" - -enum Page { - FIRSTPAGE = 0, - OTHERPAGE -}; - -class TabletListView : public QListView -{ - Q_OBJECT -public: - TabletListView(QWidget *parent, int pageNum); - ~TabletListView(); - - void addData(QStringList data);//字母排序模块添加数据 - void updateData(QStringList data); - void insertData(QString desktopfp); - bool appDisable(QString desktopfp);//判断是否是禁用的应用 - bool isDraging() - { - return m_isDraging; - } - QStandardItemModel *listmodel = nullptr; -// void paintPixmap(const QModelIndex &index,QPoint position); - -protected: - void initWidget(); - void mouseReleaseEvent(QMouseEvent *e); - void mousePressEvent(QMouseEvent *event); -// void wheelEvent(QWheelEvent *e); - void mouseMoveEvent(QMouseEvent *event); - void paintGroupItem(const QModelIndex &index, QString group); - - void dropEvent(QDropEvent *event); - void dragEnterEvent(QDragEnterEvent *event) override; -// void dragLeaveEvent(QDragLeaveEvent *event) override; - void dragMoveEvent(QDragMoveEvent *event) override; - - void insertApplication(QPoint pressedpos, QPoint releasepos); - void mergeApplication(QPoint pressedpos, QPoint releasepos); - - -private: - QVariantAnimation *m_animation = nullptr; //翻页动画 - TabletRightClickMenu *menu = nullptr; //右键菜单 - TabletFullItemDelegate *m_delegate = nullptr; - QStringList data; - UkuiMenuInterface *pUkuiMenuInterface = nullptr; - int m_pageNum = 0; - - /*鼠标事件的参数变量*/ - int dist;//翻页的鼠标移动长度 - - QPoint pressedpos; //鼠标按下的位置 - QPoint releasepos; //鼠标释放的位置 - QPoint moveing_pressedpos;// 鼠标移动的位置 - QPoint right_pressedpos;// 右键点击的位置 - - - QPoint startPos;//开始点击的位置 - QVariant pressApp;//点击位置的app想、 - QPoint dropPos;//dropPos的位置 - - //拖动 - int theDragRow = -1; - bool iconClick = false; //是否点钟图标 - bool right_iconClick = false; //是否右键点中图标 - - ulong press_time = -1; - ulong move_time = -1; - ulong release_time = -1; - - - - QSettings *setting = nullptr; //应用列表settings - QSettings *disableSetting = nullptr; //禁用的settings - QSettings *syssetting = nullptr; //不可卸载列表 - - - //鼠标滚轮灵密度限制 - QTimer *m_time = nullptr; - bool m_flat = true; - - QGSettings *tabletMode = nullptr; - - bool m_isDraging = false; - - QString pressDesktopfp; - -private Q_SLOTS: - void onClicked(QModelIndex index);//点击item - void rightClickedSlot(const QPoint &pos);//右键菜单 - bool uninstall(QString desktopfp); - -Q_SIGNALS: - void sendItemClickedSignal(QString arg);//发送item点击信号 - void sendGroupClickSignal(QString desktopfn);//发送组合框点击信号 - void sendHideMainWindowSignal();//界面隐藏信号 - void sendUpdateAppListSignal();//界面更新信号 - void pagenumchanged(bool nextPage);//页面数改变信号 - void sendPageLeft(); - void sendPageRight(); //右滑页面展开 - -}; - -#endif // FULLLISTVIEW_H diff --git a/src/UserInterface/Other/lettertooltip.cpp b/src/UserInterface/Other/lettertooltip.cpp deleted file mode 100644 index 176b48b..0000000 --- a/src/UserInterface/Other/lettertooltip.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "lettertooltip.h" -#include -#include -#include - -LetterToolTip::LetterToolTip(QWidget *parent): - QDialog(parent) -{ - this->setWindowFlags(/*Qt::FramelessWindowHint *//*| */Qt::X11BypassWindowManagerHint); - this->setAttribute(Qt::WA_TranslucentBackground, true); - this->setContentsMargins(0, 0, 0, 0); - this->setAutoFillBackground(false); - this->setFixedSize(83, 46); - QHBoxLayout *mainlayout = new QHBoxLayout; - this->setLayout(mainlayout); - mainlayout->setAlignment(Qt::AlignCenter); - mainlayout->addWidget(&textLabel); - // this->raise(); - // this->activateWindow(); -} - -LetterToolTip::~LetterToolTip() -{ -} - -void LetterToolTip::setText(QString str) -{ - QFont font; - QPalette pa; - pa.setColor(QPalette::WindowText, Qt::black); - font.setPixelSize(30); - font.setBold(true); - textLabel.setContentsMargins(0, 0, 0, 0); - textLabel.setAlignment(Qt::AlignCenter); - textLabel.setFont(font); - textLabel.setPalette(pa); - textLabel.setText(str); -} - -void LetterToolTip::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - painter.setRenderHints(QPainter::Antialiasing); - painter.setPen(Qt::NoPen); - painter.setBrush(QColor("#F2FAFF")); - painter.drawRoundedRect(5, 0, width() - 5, height(), 4, 4); - QPointF points[3] = { - QPointF(0, height() / 2), - QPointF(5, height() / 2 - 5), - QPointF(5, height() / 2 + 5), - }; - painter.drawPolygon(points, 3); - QWidget::paintEvent(event); -} diff --git a/src/UserInterface/Other/lettertooltip.h b/src/UserInterface/Other/lettertooltip.h deleted file mode 100644 index 4f64e0a..0000000 --- a/src/UserInterface/Other/lettertooltip.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef LETTERTOOLTIP_H -#define LETTERTOOLTIP_H -#include -#include - -class LetterToolTip : public QDialog -{ - Q_OBJECT -public: - LetterToolTip(QWidget *parent = nullptr); - - ~LetterToolTip(); - - void setText(QString str); - -protected: - - void paintEvent(QPaintEvent *event); - -private: - QLabel textLabel; -}; - -#endif // LETTERTOOLTIP_H diff --git a/src/UserInterface/RightClickMenu/menubox.cpp b/src/UserInterface/RightClickMenu/menubox.cpp deleted file mode 100644 index b6a8932..0000000 --- a/src/UserInterface/RightClickMenu/menubox.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "menubox.h" -#include -#include -#include -#include - -MenuBox::MenuBox(QWidget *parent): - QMenu(parent) -{ -} - -void MenuBox::mousePressEvent(QMouseEvent *event) -{ - if (!this->actionAt(event->pos())) { - Q_EMIT sendMainWinActiveSignal(true); - } - - qDebug() << "void MenuBox::mousePressEvent(QMouseEvent *event)"; - return QMenu::mousePressEvent(event); -} - diff --git a/src/UserInterface/RightClickMenu/menubox.h b/src/UserInterface/RightClickMenu/menubox.h deleted file mode 100644 index 8502af3..0000000 --- a/src/UserInterface/RightClickMenu/menubox.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MENUBOX_H -#define MENUBOX_H -#include -#include - -class MenuBox : public QMenu -{ - Q_OBJECT -public: - MenuBox(QWidget *parent = nullptr); - -protected: - - void mousePressEvent(QMouseEvent *event); - -public: -Q_SIGNALS: - void sendMainWinActiveSignal(bool flag); - - -private: - bool isFocusIn = false; -}; - -#endif // MENUBOX_H diff --git a/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp b/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp deleted file mode 100644 index 3dfdc5d..0000000 --- a/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * 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 - -TabletRightClickMenu::TabletRightClickMenu(QWidget *parent): - QWidget(parent) -{ - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - m_setting = new QSettings(path, QSettings::IniFormat); - m_cmdProc = new QProcess; - connect(m_cmdProc, &QProcess::readyReadStandardOutput, this, &TabletRightClickMenu::onReadOutput); - sprintf(m_style, "QMenu{padding-left:2px;padding-top:6px;padding-right:2px;padding-bottom:6px;border:1px solid %s;border-radius:6px;background-color:%s;}\ - QMenu::item:selected{background-color:%s;border-radius:6px;}\ - QMenu::separator{height:1px;background-color:%s;margin-top:2px;margin-bottom:2px;}", - RightClickMenuBorder, RightClickMenuBackground, RightClickMenuSelected, RightClickMenuSeparator); -} - -TabletRightClickMenu::~TabletRightClickMenu() -{ - if (m_cmdProc) { - delete m_cmdProc; - } - - if (m_setting) { - delete m_setting; - } - - m_cmdProc = nullptr; - m_setting = nullptr; -} - -QPixmap TabletRightClickMenu::getIconPixmap(QString iconstr, int type) -{ - const auto ratio = devicePixelRatioF(); - QPixmap pixmap; - - if (type == 0) { - pixmap = loadSvg(iconstr, 16 * ratio); - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - } else { - QIcon icon = QIcon::fromTheme(iconstr); - QPixmap pixmap_1 = icon.pixmap(QSize(16 * ratio, 16 * ratio)); - pixmap = drawSymbolicColoredPixmap(pixmap_1); - } - - return pixmap; -} - -QPixmap TabletRightClickMenu::drawSymbolicColoredPixmap(const QPixmap &source) -{ - QColor gray(128, 128, 128); - QColor standard(31, 32, 34); - QImage img = source.toImage(); - - for (int x = 0; x < img.width(); x++) { - for (int y = 0; y < img.height(); y++) { - auto color = img.pixelColor(x, y); - - if (color.alpha() > 0) { - if (qAbs(color.red() - gray.red()) < 20 && qAbs(color.green() - gray.green()) < 20 && qAbs(color.blue() - gray.blue()) < 20) { - color.setRed(255); - color.setGreen(255); - color.setBlue(255); - img.setPixelColor(x, y, color); - } else if (qAbs(color.red() - standard.red()) < 20 && qAbs(color.green() - standard.green()) < 20 && qAbs(color.blue() - standard.blue()) < 20) { - color.setRed(255); - color.setGreen(255); - color.setBlue(255); - img.setPixelColor(x, y, color); - } else { - img.setPixelColor(x, y, color); - } - } - } - } - - return QPixmap::fromImage(img); -} - -void TabletRightClickMenu::fixToAllActionTriggerSlot() -{ - m_actionNumber = 1; - QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); - m_setting->beginGroup("lockapplication"); - m_setting->setValue(desktopfn, m_setting->allKeys().size()); - m_setting->sync(); - m_setting->endGroup(); - // m_setting->beginGroup("application");//wgx - // m_setting->remove(desktopfn); - // m_setting->sync(); - // m_setting->endGroup(); - // m_setting->beginGroup("datetime"); - // m_setting->remove(desktopfn); - // m_setting->sync(); - // m_setting->endGroup(); - m_setting->beginGroup("recentapp"); - m_setting->remove(desktopfn); - m_setting->sync(); - m_setting->endGroup(); -} - -void TabletRightClickMenu::unfixedFromAllActionTriggerSlot() -{ - m_actionNumber = 2; - QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); - m_setting->beginGroup("lockapplication"); - - Q_FOREACH (QString desktop, m_setting->allKeys()) { - if (m_setting->value(desktop).toInt() > m_setting->value(desktopfn).toInt()) { - m_setting->setValue(desktop, m_setting->value(desktop).toInt() - 1); - } - } - - m_setting->remove(desktopfn); - m_setting->sync(); - m_setting->endGroup(); - // m_setting->beginGroup("application"); - // m_setting->remove(desktopfn); - // m_setting->sync(); - // m_setting->endGroup(); - // m_setting->beginGroup("datetime"); - // m_setting->remove(desktopfn); - // m_setting->sync(); - // m_setting->endGroup(); -} - -void TabletRightClickMenu::fixToTaskbarActionTriggerSlot() -{ - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret = iface.call("AddToTaskbar", m_desktopfp); - //qDebug()< ret = iface.call("RemoveFromTaskbar", m_desktopfp); - m_actionNumber = 4; -} - -void TabletRightClickMenu::addToDesktopActionTriggerSlot() -{ - QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); - QFile file(m_desktopfp); - QString newname = QString(path + "/" + desktopfn); - bool ret = file.copy(QString(path + "/" + desktopfn)); - - if (ret) { - char command[200]; - sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data()); - QProcess::startDetached(QString::fromLocal8Bit(command)); - } - - m_actionNumber = 5; -} - -void TabletRightClickMenu::uninstallActionTriggerSlot() -{ -// QString cmd = QString("dpkg -S " + m_desktopfp); -// myDebug() << "void TabletRightClickMenu::uninstallActionTriggerSlot()" << m_desktopfp; -// m_cmdProc->setReadChannel(QProcess::StandardOutput); -// m_cmdProc->start("sh", QStringList() << "-c" << cmd); -// m_cmdProc->waitForFinished(); -// m_cmdProc->waitForReadyRead(); -// m_cmdProc->close(); - onReadOutput(); - m_actionNumber = 6; -} - -void TabletRightClickMenu::onReadOutput() -{ -// QString packagestr = QString::fromLocal8Bit(m_cmdProc->readAllStandardOutput().data()); -// QString packageName = packagestr.split(":").at(0); -//目前仅调用起软件商店,不传递参数 - char command[100]; -// sprintf(command, "kylin-software-center -remove %s", packageName.toLocal8Bit().data()); - sprintf(command, "kylin-software-center"); - QProcess::startDetached(command); -} - -void TabletRightClickMenu::attributeActionTriggerSlot() -{ - char command[100]; - sprintf(command, "ukui-menu-attr %s", m_desktopfp.toLocal8Bit().data()); - QProcess::startDetached(command); - m_actionNumber = 7; -} -int TabletRightClickMenu::showAppBtnMenu(QString desktopfp, bool isinstall) -{ - m_actionNumber = 0; - this->m_desktopfp.clear(); - this->m_desktopfp = desktopfp; - QMenu menu; - //添加菜单项,指定图标、名称、响应函数 - // m_setting->beginGroup("lockapplication"); - // QFileInfo fileInfo(desktopfp); - // QString desktopfn=fileInfo.fileName(); - // if(!m_setting->contains(desktopfn)) - // menu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg",0)),tr("Pin to all"), - // this,SLOT(fixToAllActionTriggerSlot())); - // else - // menu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from all"), - // this,SLOT(unfixedFromAllActionTriggerSlot())); - // m_setting->endGroup(); - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret = iface.call("CheckIfExist", desktopfp); - - if (!ret) - menu.addAction(QIcon(getIconPixmap(":/img/fixed.svg", 0)), tr("Pin to taskbar"), - this, SLOT(fixToTaskbarActionTriggerSlot())); - else - menu.addAction(QIcon(getIconPixmap(":/img/unfixed.svg", 0)), tr("Unpin from taskbar"), - this, SLOT(unfixedFromTaskbarActionTriggerSlot())); - - // menu.addAction(QIcon(getIconPixmap(":/img/fixed.svg",0)),tr("Add to desktop shortcuts"), - // this,SLOT(addToDesktopActionTriggerSlot())); - QAction *clickaction = new QAction(this); - clickaction->setText(tr("Add to desktop shortcuts")); - clickaction->setIcon(QIcon(getIconPixmap(":/img/fixed.svg", 0))); - connect(clickaction, &QAction::triggered, this, &TabletRightClickMenu::addToDesktopActionTriggerSlot); - menu.addAction(clickaction); - myDebug() << "desktopfp" << desktopfp; - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - QString desktopfp1 = QDir::homePath() + "/桌面/" + desktopfn; - QFileInfo fileInfo1(desktopfp1); - - if (fileInfo1.exists()) { - clickaction->setEnabled(false); - } else { - clickaction->setEnabled(true); - } - - menu.addSeparator(); - - if (isinstall) { - menu.addAction(QIcon(getIconPixmap(":/img/uninstall.svg", 0)), tr("Uninstall"), - this, SLOT(uninstallActionTriggerSlot())); - } - - menu.setAttribute(Qt::WA_TranslucentBackground); - menu.exec(QCursor::pos()); - return m_actionNumber; -} - -//int RightClickMenu::showShutdownMenu() -//{ -// m_actionNumber=0; -// QMenu menu; -// menu.addAction(QIcon(getIconPixmap("stock-people-symbolic",1)),tr("Switch User"), -// this,SLOT(switchUserActionTriggerSlot())); -// if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) -// { -// QGSettings* gsetting=new QGSettings(QString("org.ukui.session").toLocal8Bit()); -// if(gsetting->keys().contains(QString("canhibernate"))) -// { -// if(gsetting->get("canhibernate").toBool()) -// menu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Hibernate"), -// this,SLOT(hibernateActionTriggerSlot())); -// } -// } -// menu.addAction(QIcon(getIconPixmap("kylin-sleep-symbolic",1)),tr("Sleep"), -// this,SLOT(sleepActionTriggerSlot())); -// menu.addAction(QIcon(getIconPixmap("system-lock-screen-symbolic",1)),tr("Lock Screen"), -// this,SLOT(lockScreenActionTriggerSlot())); -// menu.addAction(QIcon(getIconPixmap("system-logout-symbolic",1)),tr("Log Out"), -// this,SLOT(logoutActionTriggerSlot())); -// menu.addAction(QIcon(getIconPixmap("system-restart-symbolic",1)),tr("Restart"), -// this,SLOT(rebootActionTriggerSlot())); -// menu.addAction(QIcon(getIconPixmap("exit-symbolic",1)),tr("Power Off"), -// this,SLOT(shutdownActionTriggerSlot())); -// menu.setAttribute(Qt::WA_TranslucentBackground); -//// menu.setStyleSheet(m_style); -// menu.exec(QCursor::pos()); -// return m_actionNumber; -//} - -//int RightClickMenu::showOtherMenu(QString desktopfp) -//{ -// m_actionNumber=0; -// this->m_desktopfp.clear(); -// this->m_desktopfp=desktopfp; - -// QMenu menu; -// QDBusInterface iface("com.ukui.panel.desktop", -// "/", -// "com.ukui.panel.desktop", -// QDBusConnection::sessionBus()); - -// QDBusReply ret=iface.call("CheckIfExist",this->m_desktopfp); -// if(!ret) -// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"), -// this,SLOT(fixToTaskbarActionTriggerSlot())); -// else -// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"), -// this,SLOT(unfixedFromTaskbarActionTriggerSlot())); -// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg",0)),tr("Personalize this list"), -// this,SLOT(otherListActionTriggerSlot())); -// menu.setAttribute(Qt::WA_TranslucentBackground); -//// menu.setStyleSheet(m_style); -// menu.exec(QCursor::pos()); -// return m_actionNumber; -//} diff --git a/src/UserInterface/RightClickMenu/tabletrightclickmenu.h b/src/UserInterface/RightClickMenu/tabletrightclickmenu.h deleted file mode 100644 index 6fbd906..0000000 --- a/src/UserInterface/RightClickMenu/tabletrightclickmenu.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include "ukuimenuinterface.h" -#include "style.h" - -class TabletRightClickMenu : public QWidget -{ - Q_OBJECT -public: - /** - * @brief Right-click menu - * @param module: Right-click menu type, Only the following parameters can be entered: - * 0: application - * 1: power - * 2: others - */ - explicit TabletRightClickMenu(QWidget *parent = nullptr); - virtual ~TabletRightClickMenu(); - /** - * @brief Displays the application right-click menu - * @param desktopfp: Application desktop file - * @return return action number - */ - int showAppBtnMenu(QString desktopfp, bool isinstall); - /** - * @brief Displays the power right-click menu - * @return return action number - */ - //int showShutdownMenu(); - /** - * @brief Displays other application right-click menus - * @param desktopfp: Application desktop file - * @return return action number - */ - //int showOtherMenu(QString desktopfp); - -private: - QString m_desktopfp; - int m_actionNumber; - QSettings *m_setting = nullptr; - - char m_style[400]; - - QProcess *m_cmdProc = nullptr; - -protected: - /** - * @brief Get icon pixmap - * @param iconstr: Icon names - * @param type: Icon type, Only the following parameters can be entered: - * 0: Resource icon - * 1: System icon - * @return - */ - QPixmap getIconPixmap(QString iconstr, int type); - /** - * @brief Process image color - * @param source: QPixmap icon - * @return return QPixmap icon - */ - QPixmap drawSymbolicColoredPixmap(const QPixmap &source); - -private Q_SLOTS: - /** - * @brief Fixed to all software - */ - void fixToAllActionTriggerSlot(); - /** - * @brief Unfix from all software - */ - void unfixedFromAllActionTriggerSlot(); - /** - * @brief Fixed to the taskbar - */ - void fixToTaskbarActionTriggerSlot(); - /** - * @brief Unfix from the taskbar - */ - void unfixedFromTaskbarActionTriggerSlot(); - /** - * @brief Add to the desktop shortcut - */ - void addToDesktopActionTriggerSlot(); - /** - * @brief Uninstall - */ - void uninstallActionTriggerSlot(); - /** - * @brief Attribute - */ - void attributeActionTriggerSlot(); - /** - * @brief Lock Screen - */ - //void lockScreenActionTriggerSlot(); - /** - * @brief Switch user - */ - //void switchUserActionTriggerSlot(); - /** - * @brief Log out - */ - //void logoutActionTriggerSlot(); - /** - * @brief Reboot - */ - //void rebootActionTriggerSlot(); - /** - * @brief Shut down - */ - //void shutdownActionTriggerSlot(); - //void hibernateActionTriggerSlot(); - //void sleepActionTriggerSlot(); - /** - * @brief Personalize this list - */ - //void otherListActionTriggerSlot(); - /** - * @brief Read command output - */ - void onReadOutput(); -}; - -#endif // RIGHTCLICKMENU_H diff --git a/src/UserInterface/ViewItem/itemdelegate.cpp b/src/UserInterface/ViewItem/itemdelegate.cpp deleted file mode 100644 index aa7f169..0000000 --- a/src/UserInterface/ViewItem/itemdelegate.cpp +++ /dev/null @@ -1,347 +0,0 @@ -/* - * 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 -#include -#include -#include "utility.h" - -ItemDelegate::ItemDelegate(QObject *parent, int module): - KItemDelegate(parent) -{ - this->module = module; - pUkuiMenuInterface = new UkuiMenuInterface; -} - -ItemDelegate::~ItemDelegate() -{ - delete pUkuiMenuInterface; -} - -void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - if (index.isValid()) { - QRectF rect; - rect.setX(option.rect.x()); - rect.setY(option.rect.y()); - rect.setWidth(option.rect.width()); - rect.setHeight(option.rect.height() - 2); - //QPainterPath画圆角矩形 - const qreal radius = 4; - QPainterPath path; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - QStringList strlist = index.model()->data(index, Qt::DisplayRole).toStringList(); - painter->setRenderHint(QPainter::Antialiasing); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - QColor color; - - if (option.state & QStyle::State_Selected) { - if (g_curStyle == "ukui-dark") { - color.setNamedColor("#33FFFFFF"); - } else { - color.setNamedColor("#D1FFFFFF"); - } - } else { - if (g_curStyle == "ukui-dark") { - color.setNamedColor("#1AFFFFFF"); - } else { - color.setNamedColor("#8CFFFFFF"); - } - } - - painter->save(); - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(color); - painter->drawPath(path); - painter->restore(); - } - - painter->setOpacity(1); - - if (module > 0) { - if (strlist.at(1).toInt() == 1) { - QRect iconRect = QRect(rect.x() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); - QString iconstr = pUkuiMenuInterface->getAppIcon(strlist.at(0)); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull()) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); - } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } - } - } - - painter->save(); - icon.paint(painter, iconRect, Qt::AlignCenter); - QString appname = pUkuiMenuInterface->getAppName(strlist.at(0)); - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); - painter->drawText(QRect(iconRect.right() + 15, rect.y(), - rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); - painter->restore(); - painter->save(); - QFileInfo fileInfo(strlist.at(0)); - QString desktopfn = fileInfo.fileName(); - - if (checkIfRecent(desktopfn)) { - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(QColor("#4d94ff")); - painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); - } - - painter->restore(); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = fm.boundingRect(appname).width(); - - if (len > rect.width() - 62) { - if (option.state & QStyle::State_MouseOver) { - QToolTip::showText(QCursor::pos(), appname); - } else { - QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.bottomRight().x(), rect.center().y())), appname); - } - } else { - QToolTip::hideText(); - } - } - } else { - //绘制分割线 - painter->save(); - // QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); - QRect textRect = QRect(rect.x() + 11, rect.y(), rect.width(), rect.height()); - painter->drawText(textRect, Qt::AlignVCenter, strlist.at(0)); - painter->setRenderHints(QPainter::SmoothPixmapTransform, true); - QPixmap pixmap = getCurIcon(":/data/img/mainviewwidget/DM-icon-option.svg", true).pixmap(QSize(16, 16)); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - painter->drawPixmap(rect.width() - 25, rect.y() + 15, pixmap); - } - - painter->restore(); - } - } else if (module == -1) { - QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); - QString iconstr = strlist.at(3); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull()) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); - } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } - } - } - - icon.paint(painter, iconRect, Qt::AlignCenter); - QString appname = strlist.at(1); - painter->setOpacity(1); - painter->save(); - painter->setPen(QPen(option.palette.text().color())); - painter->setBrush(Qt::NoBrush); - painter->setOpacity(1); - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); - painter->drawText(QRect(iconRect.right() + 15, rect.y(), - rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); - painter->restore(); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = fm.boundingRect(appname).width(); - - if (len > rect.width() - 64) { - if (option.state & QStyle::State_MouseOver) { - QToolTip::showText(QCursor::pos(), appname); - } else { - QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.bottomRight().x(), rect.center().y())), appname); - } - } else { - QToolTip::hideText(); - } - } - } else { - QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); - QString iconstr = pUkuiMenuInterface->getAppIcon(strlist.at(0)); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull()) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); - } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } - } - } - - icon.paint(painter, iconRect, Qt::AlignCenter); - QString appname = pUkuiMenuInterface->getAppName(strlist.at(0)); - QFileInfo fileInfo(strlist.at(0)); - QString desktopfn = fileInfo.fileName(); - - if (checkIfLocked(desktopfn)) { - QIcon icon = getCurIcon(":/data/img/mainviewwidget/lock.svg", true); - icon.paint(painter, QRect(rect.topRight().x() - 22, rect.y() + (rect.height() - 16) / 2, 16, 16)); - } - - painter->setOpacity(1); - painter->save(); - - if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(QColor("#4d94ff")); - painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); - } - - painter->restore(); - painter->save(); - painter->setPen(QPen(option.palette.text().color())); - painter->setBrush(Qt::NoBrush); - painter->setOpacity(1); - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); - painter->drawText(QRect(iconRect.right() + 15, rect.y(), - rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); - painter->restore(); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = fm.boundingRect(appname).width(); - - if (len > rect.width() - 62) { - if (option.state & QStyle::State_MouseOver) { - QToolTip::showText(QCursor::pos(), appname); - } else { - QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.bottomRight().x(), rect.center().y())), appname); - } - } else { - QToolTip::hideText(); - } - } - } - } -} - -QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - // QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); - // if(strlist.at(1).toInt()==1) - return QSize(310, 47); - // else - // return QSize(310,48); -} diff --git a/src/UserInterface/ViewItem/kitemdelegate.cpp b/src/UserInterface/ViewItem/kitemdelegate.cpp deleted file mode 100644 index 540536e..0000000 --- a/src/UserInterface/ViewItem/kitemdelegate.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "kitemdelegate.h" - -KItemDelegate::KItemDelegate(QObject *parent): - QStyledItemDelegate(parent) -{ -} diff --git a/src/UserInterface/ViewItem/kitemdelegate.h b/src/UserInterface/ViewItem/kitemdelegate.h deleted file mode 100644 index 5145b78..0000000 --- a/src/UserInterface/ViewItem/kitemdelegate.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef KITEMDELEGATE_H -#define KITEMDELEGATE_H -#include -#include "ukuimenuinterface.h" - -class KItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT -public: - KItemDelegate(QObject *parent); - - int module = 0; - UkuiMenuInterface *pUkuiMenuInterface = nullptr; -}; - -#endif // KITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/recent_item_delegate.h b/src/UserInterface/ViewItem/recent_item_delegate.h deleted file mode 100644 index a613d90..0000000 --- a/src/UserInterface/ViewItem/recent_item_delegate.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef RECENTITEMDELEGATE_H -#define RECENTITEMDELEGATE_H -#include "itemdelegate.h" -#include -#include -#include -#include -#include "src/UtilityFunction/utility.h" -#include "kitemdelegate.h" - -class recentitemdelegate : public KItemDelegate -{ - Q_OBJECT -public: - /** - * @param module为0时为常用模块,1为字母模块、2为功能模块、3为搜索模块 - */ - recentitemdelegate(QObject *parent, int module); - ~recentitemdelegate(); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; -}; - -#endif // RECENTITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/right_item_delegate.cpp b/src/UserInterface/ViewItem/right_item_delegate.cpp deleted file mode 100644 index a67a6ca..0000000 --- a/src/UserInterface/ViewItem/right_item_delegate.cpp +++ /dev/null @@ -1,195 +0,0 @@ -#include "right_item_delegate.h" -#include "utility.h" -#include - -RightItemDelegate::RightItemDelegate(QObject *parent): - KItemDelegate(parent) -{ - pUkuiMenuInterface = new UkuiMenuInterface; -} - -RightItemDelegate::~RightItemDelegate() -{ - delete pUkuiMenuInterface; -} - -void RightItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - if (index.isValid()) { - QStyleOptionViewItem viewOption(option);//用来在视图中画一个item - QRectF rect; - rect.setX(option.rect.x()); - rect.setY(option.rect.y()); - rect.setWidth(option.rect.width()); - rect.setHeight(option.rect.height()); - //QPainterPath画圆角矩形 - const qreal radius = 10; - QPainterPath path; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter->setRenderHint(QPainter::Antialiasing); - painter->save(); - painter->setPen(QPen(Qt::NoPen)); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - if (option.state & QStyle::State_Selected) { - if (g_curStyle == "ukui-dark") { - painter->setBrush(QColor("#7A000000")); - } else { - painter->setBrush(QColor("#BFFFFFFF")); - } - } else { - if (g_curStyle == "ukui-dark") { - painter->setBrush(QColor("#66000000")); - } else { - painter->setBrush(QColor("#99FFFFFF")); - } - } - } else { - if (g_curStyle == "ukui-dark") { - painter->setBrush(QColor("#40000000")); - } else { - painter->setBrush(QColor("#66FFFFFF")); - } - } - - painter->drawPath(path); - painter->restore(); - painter->save(); - painter->setOpacity(1); - QString desktopfp = index.data(Qt::DisplayRole).value(); - QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull()) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } - } - } - - QString appname = pUkuiMenuInterface->getAppName(desktopfp); - QRect iconRect; - QRect textRect; - iconRect = QRect(rect.x() + 28, - rect.y() + 16, - 48, - 48); - icon.paint(painter, iconRect); - painter->restore(); - painter->save(); - bool is_locked = false; - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - painter->restore(); - textRect = QRect(rect.x(), - iconRect.bottom(), - rect.width(), - rect.height() - iconRect.height()); - painter->save(); - //添加最近安装蓝色标签 - bool is_recentapp = false; - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic); - - if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { - is_recentapp = true; - appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic); - textRect = QRect(rect.x() + 18, - iconRect.bottom() + Style::AppSpaceBetweenIconText, - rect.width() - 23, - rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(QColor("#4d94ff")); - int x = 0; - - if (rect.width() < (23 + fm.boundingRect(appname).width())) { - x = rect.x() + 9; - } else { - x = rect.x() + (rect.width() - 13 - fm.boundingRect(appname).width()) / 2 + 4; - } - - painter->drawEllipse(QPoint(x, - textRect.y() + (fm.boundingRect(appname).height() - 8) / 2 + 4), - 4, - 4); - } - - painter->restore(); - painter->save(); - painter->setPen(QPen(option.palette.text().color())); -// painter->setPen(QPen(Qt::white)); - painter->setBrush(Qt::NoBrush); - painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText); - // painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); - painter->restore(); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = 0; - - if (!is_locked && is_recentapp) { - len = fm.boundingRect(appname).width() + 23; - } else { - len = fm.boundingRect(appname).width() + 10; - } - - if (len > rect.width()) { - if (option.state & QStyle::State_MouseOver) { - QToolTip::showText(QCursor::pos(), appname); - } else { - QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); - } - } else { - QToolTip::hideText(); - } - } - } -} - -QSize RightItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - return QSize(104, 104); -} diff --git a/src/UserInterface/ViewItem/right_item_delegate.h b/src/UserInterface/ViewItem/right_item_delegate.h deleted file mode 100644 index ee62ed6..0000000 --- a/src/UserInterface/ViewItem/right_item_delegate.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef RIGHTITEMDELEGATE_H -#define RIGHTITEMDELEGATE_H -#include -#include "style.h" -#include -#include -#include -#include -#include -#include -#include "ukuimenuinterface.h" -#include "style.h" -#include "kitemdelegate.h" - -class RightItemDelegate : public KItemDelegate -{ - Q_OBJECT -public: - RightItemDelegate(QObject *parent); - ~RightItemDelegate(); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; -}; - -#endif // FULLITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp b/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp deleted file mode 100644 index 1bb5b74..0000000 --- a/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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 -#include "ukuimenuinterface.h" -#include "style.h" -#include -#include - -TabletFullItemDelegate::TabletFullItemDelegate(QObject *parent, int module): - QStyledItemDelegate(parent) -{ - this->module = module; - pUkuiMenuInterface = new UkuiMenuInterface; - //打开ini文件 - QString pathini = QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"; - settt = new QSettings(pathini, QSettings::IniFormat); - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - setting = new QSettings(path, QSettings::IniFormat); - // qDebug() << "---------------------gengxinleziti---------------------"; -} - -TabletFullItemDelegate::~TabletFullItemDelegate() -{ - if (pUkuiMenuInterface) { - delete pUkuiMenuInterface; - } - - if (settt) { - delete settt; - } - - if (setting) { - delete setting; - } - - pUkuiMenuInterface = nullptr; - settt = nullptr; - setting = nullptr; -} - -void TabletFullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - if (index.isValid()) { - painter->save(); - QStyleOptionViewItem viewOption(option);//用来在视图中画一个item - QRectF rect; - rect.setX(option.rect.x()); - rect.setY(option.rect.y()); - rect.setWidth(option.rect.width()); - rect.setHeight(option.rect.height()); - painter->setOpacity(1); - QString desktopfp = index.model()->data(index, Qt::DisplayRole).value(); - QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - QString appname = pUkuiMenuInterface->getAppName(desktopfp); - QRect iconRect; - QRect textRect; - // QString desktopfn=desktopfp.split('/').last(); - // setting->beginGroup("groupname"); - // bool iscontain=setting->contains(desktopfn); - // setting->sync(); - // setting->endGroup(); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - //qDebug()<<"str-----------"<beginGroup("application"); - //判断禁用 - settt->sync(); - bool bo = settt->contains(desktopfp1.toLocal8Bit().data()); // iskey - bool bo1 = settt->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool(); //isvalue - settt->endGroup(); - - if (bo && bo1 == false) { //都存在//存在并且为false - QPixmap pixmap; - - if (bigIcon) { - pixmap = icon.pixmap((Style::AppListBigIconSize, Style::AppListBigIconSize), QIcon::Disabled, QIcon::Off); //wgx - pixmap = pixmap.scaled(Style::AppListBigIconSize, Style::AppListBigIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - } else { - pixmap = icon.pixmap((Style::AppListIconSize, Style::AppListIconSize), QIcon::Disabled, QIcon::Off); //wgx - } - - icon = QIcon(pixmap); - } else { - QPixmap mPixmap; - - if (bigIcon) { - mPixmap = icon.pixmap((Style::AppListBigIconSize, Style::AppListBigIconSize)); //wgx - mPixmap = mPixmap.scaled(Style::AppListBigIconSize, Style::AppListBigIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - } else { - mPixmap = icon.pixmap((Style::AppListIconSize, Style::AppListIconSize)); //wgx - } - - icon = QIcon(mPixmap); - } - - // qDebug()<<"iconRect"<setPen(shadow); - QRect textLineRect; - textLineRect.setLeft(textRect.left() + 1); - textLineRect.setRight(textRect.right() + 1); - textLineRect.setTop(textRect.top() + 1); - textLineRect.setBottom(textRect.bottom() + 1); - painter->drawText(textLineRect, Qt::TextWordWrap | Qt::AlignCenter, appname); - painter->setPen(QPen(Qt::white)); - painter->drawText(textRect, Qt::TextWordWrap | Qt::AlignCenter, appname); - painter->restore(); - } -} - -QSize TabletFullItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - // if(index.row()>=Style::appNum) - // { - // return QSize(0,0); - // } - return QSize(Style::TabletItemSizeWidthFirst, Style::AppListItemSizeHeight); -} - diff --git a/src/UserInterface/ViewItem/tablet_full_itemdelegate.h b/src/UserInterface/ViewItem/tablet_full_itemdelegate.h deleted file mode 100644 index 8407557..0000000 --- a/src/UserInterface/ViewItem/tablet_full_itemdelegate.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 -#include "style.h" -#include -#include -#include -#include -#include -#include "ukuimenuinterface.h" -#include "style.h" -#include - -class TabletFullItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT -public: - TabletFullItemDelegate(QObject *parent, int module); - ~TabletFullItemDelegate(); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - int module = 0; - UkuiMenuInterface *pUkuiMenuInterface = nullptr; - QSettings *settt; - QSettings *setting = nullptr; - // int i=0; - // int j=1; - - - -protected: - // bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index); -}; - -#endif // FULLITEMDELEGATE_H diff --git a/src/UserInterface/Widget/animationpage.cpp b/src/UserInterface/Widget/animationpage.cpp deleted file mode 100644 index 2676f29..0000000 --- a/src/UserInterface/Widget/animationpage.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "animationpage.h" -#include "utility.h" -#include -#include -#include - -AnimationPage::AnimationPage(QWidget *parent) - : QWidget(parent) - -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); - this->setAutoFillBackground(false); - this->setAttribute(Qt::WA_TranslucentBackground); -} -void AnimationPage::paintEvent(QPaintEvent *event) -{ - double transparency = getTransparency(); - QRect rect = this->rect(); - QPainter painter(this); - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(rect); - KWindowEffects::enableBlurBehind(this->winId(), true, QRect(rect)); - return QWidget::paintEvent(event); -} diff --git a/src/UserInterface/Widget/animationpage.h b/src/UserInterface/Widget/animationpage.h deleted file mode 100644 index 9cefa24..0000000 --- a/src/UserInterface/Widget/animationpage.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef ANIMATIONPAGE_H -#define ANIMATIONPAGE_H -#include - -class AnimationPage : public QWidget -{ - Q_OBJECT -public: - AnimationPage(QWidget *parent = nullptr); -protected: - void paintEvent(QPaintEvent *event); -}; - -#endif // ANIMATIONPAGE_H diff --git a/src/UserInterface/Widget/full_commonuse_widget.cpp b/src/UserInterface/Widget/full_commonuse_widget.cpp deleted file mode 100644 index 04691ab..0000000 --- a/src/UserInterface/Widget/full_commonuse_widget.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 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 -#include "style.h" -#include "utility.h" -#include - -FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) : - QWidget(parent) -{ - Style::initWidStyle(); - initUi(); -} - -FullCommonUseWidget::~FullCommonUseWidget() -{ - delete m_ukuiMenuInterface; -} - -void FullCommonUseWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - this->setFocusPolicy(Qt::NoFocus); - QHBoxLayout *mainLayout = new QHBoxLayout(this); - mainLayout->setContentsMargins(40, 0, 40, 0); - mainLayout->setSpacing(0); - m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); - mainLayout->addItem(m_spaceItem); - m_scrollArea = new ScrollArea(); - m_scrollAreaWid = new ScrollAreaWid(this); - m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setStyleSheet("QWidget{background:transparent;}"); - m_scrollArea->setWidgetResizable(true); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAreaWidLayout = new QVBoxLayout(m_scrollAreaWid); - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); - m_scrollAreaWidLayout->setSpacing(10); - QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); - rightButtonLayout->setContentsMargins(0, 0, 0, 20); - rightButtonLayout->setSpacing(0); - QSpacerItem *m_spaceItem2 = nullptr; - m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem2); - m_verticalScrollBar = new QScrollBar(this); - m_verticalScrollBar->installEventFilter(this); - m_verticalScrollBar->setOrientation(Qt::Vertical); - mainLayout->addWidget(m_scrollArea); - QSpacerItem *m_spaceItem1 = nullptr; - m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - mainLayout->addItem(m_spaceItem1); - m_powerOffButton = new QPushButton(this); - m_powerOffButton->setFixedSize(QSize(40, 40)); - m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); - QIcon powerIcon; - powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); - m_powerOffButton->setIcon(powerIcon); - m_powerOffButton->setIconSize(QSize(28, 28)); - m_powerOffButton->setFlat(true); - m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" - "QPushButton:hover {border-radius :20px; background: rgba(255, 255, 255, 0.2);}" - "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); - rightButtonLayout->addWidget(m_verticalScrollBar); - QSpacerItem *m_spaceItem3 = nullptr; - m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem3); - rightButtonLayout->addWidget(m_powerOffButton); - rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); - mainLayout->addLayout(rightButtonLayout); - m_ukuiMenuInterface = new UkuiMenuInterface; - initAppListWidget(); - fillAppList(); - m_scrollAreaWid->adjustSize(); - flag = true; - //翻页灵敏度时间调节 - time = new QTimer(this); - connect(time, &QTimer::timeout, [ = ]() { - if (flag == false) { - flag = true; - time->stop(); - } - }); - m_scrollAreaWidHeight = m_scrollAreaWid->height(); - initVerticalScrollBar(); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullCommonUseWidget::on_setScrollBarValue); - connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullCommonUseWidget::on_setAreaScrollBarValue); - connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullCommonUseWidget::on_powerOffButton_customContextMenuRequested); - connect(m_powerOffButton, &QPushButton::clicked, this, &FullCommonUseWidget::on_powerOffButton_clicked); -} - -void FullCommonUseWidget::initVerticalScrollBar() -{ - m_verticalScrollBar->setFixedHeight(200); - int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; - - if (scrollBarSize >= 200) { - m_verticalScrollBar->hide(); - } else { - m_verticalScrollBar->show(); - } - - m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); " - "margin: 0px,0px,0px,0px; border-radius: %3px;}" - "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);" - "border-radius: %3px; min-height: %1;}" - "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" - "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); -} - -void FullCommonUseWidget::on_powerOffButton_clicked() -{ - QProcess::startDetached(QString("ukui-session-tools")); -} - -void FullCommonUseWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) -{ - RightClickMenu m_otherMenu(this); - m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(pos)); - myDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; -} - -void FullCommonUseWidget::initAppListWidget() -{ - m_listView = new FullListView(this, 0); - m_listView->installEventFilter(this); - m_scrollAreaWidLayout->addWidget(m_listView); - m_listView->setFixedWidth(m_scrollArea->width()); - connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullCommonUseWidget::execApplication); - connect(m_listView, &FullListView::sendUpdateAppListSignal, this, &FullCommonUseWidget::updateListViewSlot); - connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullCommonUseWidget::sendHideMainWindowSignal); - connect(m_listView, &FullListView::sendSetslidebar, this, &FullCommonUseWidget::onSetSlider); -} - -void FullCommonUseWidget::resizeScrollAreaControls() -{ - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); - QWidget *wid = widItem->widget(); - FullListView *listview = qobject_cast(wid); - listview->adjustSize(); - int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; - int rowcount = 0; - - if (listview->model()->rowCount() % dividend > 0) { - rowcount = listview->model()->rowCount() / dividend + 1; - } else { - rowcount = listview->model()->rowCount() / dividend; - } - - listview->setFixedSize(m_listView->width(), listview->gridSize().height() * rowcount); - m_scrollArea->widget()->setFixedSize(listview->size()); -} - -void FullCommonUseWidget::fillAppList() -{ - m_data.clear(); - - Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { - m_data.append(desktopfp); - } - - m_listView->addData(m_data); - resizeScrollAreaControls(); -} - -/** - * 执行应用程序 - */ -void FullCommonUseWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -void FullCommonUseWidget::selectFirstItem() -{ - m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); -} - -void FullCommonUseWidget::on_setScrollBarValue(int value) -{ - m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); - m_verticalScrollBar->setValue(value); -} - -bool FullCommonUseWidget::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == m_listView) { - if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Tab) { - Q_EMIT setFocusToSideWin(); - return true; - } - } - } - - if (watched == m_verticalScrollBar) { - if (event->type() == QEvent::Enter) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4)); - } - - if (event->type() == QEvent::Leave) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); - } - } - - return QWidget::eventFilter(watched, event); -} - -void FullCommonUseWidget::onSetSlider(int value) -{ - if (value == 0) { - m_scrollArea->verticalScrollBar()->setValue(0); - } else { - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); - } -} - -void FullCommonUseWidget::selectFirstItemTab() -{ - m_listView->setFocus(); - m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); - onSetSlider(0); -} - -void FullCommonUseWidget::on_setAreaScrollBarValue(int value) -{ - m_scrollArea->verticalScrollBar()->setValue(value); -} -/** - * 更新应用列表 - */ -void FullCommonUseWidget::updateListViewSlot() -{ - updateListView(); - Q_EMIT sendUpdateOtherView(); -} - -void FullCommonUseWidget::updateListView() -{ - m_data.clear(); - - Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { - m_data.append(desktopfp); - } - - m_listView->updateData(m_data); - m_data.clear(); - resizeScrollAreaControls(); - m_scrollAreaWidHeight = m_scrollAreaWid->height(); - initVerticalScrollBar(); -} - -void FullCommonUseWidget::repaintWidget() -{ - m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); - m_scrollAreaWidLayout->removeWidget(m_listView); - m_listView->setParent(nullptr); - delete m_listView; - initAppListWidget(); - fillAppList(); - m_scrollAreaWidHeight = m_scrollAreaWid->height(); - initVerticalScrollBar(); - on_setAreaScrollBarValue(0); -} - -void FullCommonUseWidget::widgetMakeZero() -{ - m_listView->verticalScrollBar()->setSliderPosition(0); -} - -void FullCommonUseWidget::moveScrollBar(int type) -{ - int height = Style::m_availableScreenHeight; - - if (type == 0) { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); - } else { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); - } -} diff --git a/src/UserInterface/Widget/full_function_widget.cpp b/src/UserInterface/Widget/full_function_widget.cpp deleted file mode 100644 index c3e2520..0000000 --- a/src/UserInterface/Widget/full_function_widget.cpp +++ /dev/null @@ -1,581 +0,0 @@ -/* - * 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 -#include -#include "style.h" -#include -#include -#include - -FullFunctionWidget::FullFunctionWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullFunctionWidget::~FullFunctionWidget() -{ - delete m_ukuiMenuInterface; -} - -void FullFunctionWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - this->setAttribute(Qt::WA_TranslucentBackground); - this->setFocusPolicy(Qt::NoFocus); - m_applistWid = new QWidget(this); - m_iconListWid = new QWidget(this); - m_iconListWid->setAttribute(Qt::WA_TranslucentBackground); - m_iconListWid->setAutoFillBackground(false); - m_applistWid->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); - m_iconListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); - m_verticalScrollBar = new QScrollBar(m_scrollArea); - m_verticalScrollBar->installEventFilter(this); - m_verticalScrollBar->setOrientation(Qt::Vertical); - QHBoxLayout *mainLayout = new QHBoxLayout(this); - mainLayout->setContentsMargins(0, 0, 40, 0); - mainLayout->setSpacing(0); - mainLayout->addWidget(m_iconListWid); - mainLayout->addWidget(m_applistWid); - QSpacerItem *m_spaceItem1 = nullptr; - m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - mainLayout->addItem(m_spaceItem1); - QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); - rightButtonLayout->setContentsMargins(0, 0, 0, 20); - rightButtonLayout->setSpacing(0); - m_powerOffButton = new QPushButton(this); - m_powerOffButton->setFixedSize(QSize(40, 40)); - m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); - QIcon powerIcon; - powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); - m_powerOffButton->setIcon(powerIcon); - m_powerOffButton->setIconSize(QSize(28, 28)); - m_powerOffButton->setFlat(true); - m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" - "QPushButton:hover {border-radius:20px; background: rgba(255, 255, 255, 0.2);}" - "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); - QSpacerItem *m_spaceItem2 = nullptr; - m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem2); - rightButtonLayout->addWidget(m_verticalScrollBar); - QSpacerItem *m_spaceItem3 = nullptr; - m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem3); - rightButtonLayout->addWidget(m_powerOffButton); - rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); - mainLayout->addLayout(rightButtonLayout); - // mainLayout->addWidget(verticalScrollBar); - // this->setLayout(mainLayout); - m_ukuiMenuInterface = new UkuiMenuInterface; - initAppListWidget(); - initIconListWidget(); - flag = true; - //翻页灵敏度时间调节 - time = new QTimer(this); - connect(time, &QTimer::timeout, [ = ]() { - if (flag == false) { - flag = true; - time->stop(); - } - }); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullFunctionWidget::on_setScrollBarValue); - connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullFunctionWidget::on_setAreaScrollBarValue); - connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullFunctionWidget::on_powerOffButton_customContextMenuRequested); - connect(m_powerOffButton, &QPushButton::clicked, this, &FullFunctionWidget::on_powerOffButton_clicked); -} - -/** - * 初始化应用列表界面 - */ -void FullFunctionWidget::initAppListWidget() -{ - QHBoxLayout *layout = new QHBoxLayout(m_applistWid); - layout->setContentsMargins(0, 0, 0, 0); - m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea; - m_scrollArea->setStyleSheet("background:transparent"); - m_scrollAreaWid = new ScrollAreaWid(this); - m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout = new QVBoxLayout(m_scrollAreaWid); - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); - m_scrollAreaWidLayout->setSpacing(10); - layout->addWidget(m_scrollArea); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullFunctionWidget::valueChangedSlot); - fillAppList(); - m_scrollAreaWidHeight = m_scrollAreaWid->height(); - initVerticalScrollBar(); -} - -void FullFunctionWidget::initVerticalScrollBar() -{ - m_verticalScrollBar->setFixedHeight(200); - int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; - - if (scrollBarSize >= 200) { - m_verticalScrollBar->hide(); - } else { - m_verticalScrollBar->show(); - } - - m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); " - "margin: 0px,0px,0px,0px; border-radius: %3px;}" - "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);" - "border-radius: %3px; min-height: %1;}" - "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" - "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); -} - -void FullFunctionWidget::on_powerOffButton_clicked() -{ - QProcess::startDetached(QString("ukui-session-tools")); -} - -void FullFunctionWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) -{ - RightClickMenu m_otherMenu(this); - m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(pos)); - myDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; -} - - -/** - * 填充应用列表 - */ -void FullFunctionWidget::fillAppList() -{ - m_classificationList.clear(); - QVector vector = UkuiMenuInterface::functionalVector; - QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); - - for (int i = 0; i < vector.size(); i++) { - if (!(vector.at(i).isEmpty())) { - insertClassificationBtn(functionList.at(i)); - insertAppList(vector.at(i)); - } - } - - resizeScrollAreaControls(); -} - -void FullFunctionWidget::insertClassificationBtn(QString category) -{ - SplitBarFrame *classificationbtn = new SplitBarFrame(this, category, m_scrollArea->width() - 12, 30, 2); - classificationbtn->setAttribute(Qt::WA_TranslucentBackground); - classificationbtn->setAutoFillBackground(false); - m_scrollAreaWidLayout->addWidget(classificationbtn); - m_classificationList.append(category); -} - -void FullFunctionWidget::insertAppList(QStringList desktopfplist) -{ - FullListView *listview = new FullListView(this, 2); - //修复异常黑框问题 - connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { - listview->repaint(listview->rect()); - }); - connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider); - connect(this, &FullFunctionWidget::selectFirstItem, listview, &FullListView::selectFirstItem); - listview->installEventFilter(this); - m_scrollAreaWidLayout->addWidget(listview); - m_data.clear(); - - for (int i = 0; i < desktopfplist.count(); i++) { - m_data.append(desktopfplist.at(i)); - } - - listview->addData(m_data); - connect(listview, &FullListView::sendItemClickedSignal, this, &FullFunctionWidget::execApplication); - connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullFunctionWidget::sendHideMainWindowSignal); -} - -/** - * 执行应用程序 - */ -void FullFunctionWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -void FullFunctionWidget::on_setAreaScrollBarValue(int value) -{ - // m_scrollArea->verticalScrollBar()->setMaximum(maxmumValue); - m_scrollArea->verticalScrollBar()->setValue(value); -} - -/** - * 更新应用列表 - */ -void FullFunctionWidget::updateAppListView() -{ - //刷新应用列表界面 - QLayoutItem *child; - - while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { - QWidget *wid = child->widget(); - m_scrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - - fillAppList(); - - //刷新图标列表界面 - Q_FOREACH (QAbstractButton *button, m_buttonList) { - m_btnGroup->removeButton(button); - } - - m_buttonList.clear(); - m_iconListWidLayout->removeItem(m_topSpacerItem); - m_iconListWidLayout->removeItem(m_bottomSpacerItem); - - while ((child = m_iconListWidLayout->takeAt(0)) != 0) { - QWidget *wid = child->widget(); - m_iconListWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - - initIconListScrollArea(); - m_scrollAreaWidHeight = m_scrollAreaWid->height(); - initVerticalScrollBar(); -} - -/** - * 设置scrollarea所填充控件大小 - */ -void FullFunctionWidget::resizeScrollAreaControls() -{ - int row = 0; - int areaHeight = 0; - - while (row < m_scrollAreaWidLayout->count() / 2) { - //应用界面 - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1); - QWidget *wid = widItem->widget(); - FullListView *listview = qobject_cast(wid); - listview->adjustSize(); - int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; - int rowcount = 0; - - if (listview->model()->rowCount() % dividend > 0) { - rowcount = listview->model()->rowCount() / dividend + 1; - } else { - rowcount = listview->model()->rowCount() / dividend; - } - - listview->setFixedSize(m_scrollArea->width(), listview->gridSize().height()*rowcount); - areaHeight += listview->height() + 50; - row++; - } - - m_scrollArea->widget()->setFixedSize(m_scrollArea->width(), areaHeight - 10); -} - -/** - * 初始化图标列表界面 - */ -void FullFunctionWidget::initIconListWidget() -{ - m_iconListWidLayout = new QVBoxLayout(m_iconListWid); - m_iconListWidLayout->setSpacing(Style::LeftSpaceBetweenItem); - m_iconListWidLayout->setContentsMargins(45, 0, 0, 0); - m_topSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_bottomSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_btnGroup = new QButtonGroup(m_iconListWid); - m_animation = new QPropertyAnimation(m_iconListWid, "geometry"); - m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); - m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); - connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullFunctionWidget::animationFinishSlot); - connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullFunctionWidget::animationValueChangedSlot); - initIconListScrollArea(); -} - -void FullFunctionWidget::on_setScrollBarValue(int value) -{ - m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); - m_verticalScrollBar->setValue(value); -} - -/** - * 初始化图标列表界面数据表格iconlisttableWid - */ -void FullFunctionWidget::initIconListScrollArea() -{ - m_iconListWidLayout->addItem(m_topSpacerItem); - - for (int i = 0; i < m_classificationList.size(); i++) { - FunctionClassifyButton *iconbtn = new FunctionClassifyButton( - Style::LeftBtnWidth, - Style::LeftBtnHeight, - Style::LeftIconSize, - m_classificationList.at(i), - true, - true); - iconbtn->setChecked(false); - m_buttonList.append(iconbtn); - m_iconListWidLayout->addWidget(iconbtn); - m_iconListWidLayout->setAlignment(iconbtn, Qt::AlignLeft); - } - - m_iconListWidLayout->addItem(m_bottomSpacerItem); - int id = 0; - - Q_FOREACH (QAbstractButton *btn, m_buttonList) { - m_btnGroup->addButton(btn, id++); - } - - connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullFunctionWidget::btnGroupClickedSlot); - - // m_iconListScrollArea->widget()->adjustSize(); - if (m_btnGroup->button(0) != nullptr) { - m_btnGroup->button(0)->click(); - } -} - -void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn) -{ - disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullFunctionWidget::valueChangedSlot); - - Q_FOREACH (QAbstractButton *button, m_buttonList) { - if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) { - m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition(); - m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y(); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAnimation->stop(); - m_scrollAnimation->setStartValue(m_beginPos); - m_scrollAnimation->setEndValue(m_endPos); - m_scrollAnimation->start(); - button->setChecked(true); - } else { - button->setChecked(false); - } - } -} - -void FullFunctionWidget::animationFinishSlot() -{ - // if(m_scrollArea->verticalScrollBar()->value()==m_endPos || - // m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) - // { - // m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullFunctionWidget::valueChangedSlot); - // } -} - -void FullFunctionWidget::animationValueChangedSlot(const QVariant &value) -{ - Q_UNUSED(value); - - if (sender() != m_scrollAnimation) { - return; - } - - QPropertyAnimation *ani = qobject_cast(sender()); - - if (m_endPos != ani->endValue()) { - ani->setEndValue(m_endPos); - } -} - -void FullFunctionWidget::valueChangedSlot(int value) -{ - int index = 0; - - while (index <= m_classificationList.count() - 1) { - int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y(); - int max = 0; - - if (index == m_classificationList.count() - 1) { - max = m_scrollAreaWid->height(); - } else { - max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y(); - } - - if (value >= min && value < max) { - Q_FOREACH (QAbstractButton *button, m_buttonList) { - FunctionClassifyButton *fcbutton = qobject_cast(button); - - if (index == m_buttonList.indexOf(button)) { - fcbutton->setChecked(true); - } else { - fcbutton->setChecked(false); - } - } - - break; - } else { - index++; - } - } -} - -QAbstractButton *FullFunctionWidget::getCurLetterButton(int value) -{ - return m_buttonList.at(value); -} - - -void FullFunctionWidget::enterAnimation() -{ - m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0, 0, - 0, m_iconListWid->height())); - m_animation->setEndValue(QRect(Style::LeftMargin, - 0, - Style::LeftBtnWidth, - m_iconListWid->height())); - m_animation->setEasingCurve(QEasingCurve::InQuart); - m_animation->start(); - m_iconListScrollAreaWid->show(); -} - -void FullFunctionWidget::setFunctionBtnGeometry() -{ - // int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; - m_iconListScrollAreaWid->setGeometry(QRect(Style::LeftMargin, - 0, - Style::LeftBtnWidth, - m_iconListWid->height())); - m_iconListScrollAreaWid->show(); -} - -void FullFunctionWidget::repaintWidget() -{ - m_applistWid->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); - m_iconListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); - m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - updateAppListView(); -} - -void FullFunctionWidget::widgetMakeZero() -{ - if (m_btnGroup->button(0) != nullptr) { - m_btnGroup->button(0)->click(); - } - - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); -} - -void FullFunctionWidget::onSetSlider(int value) -{ - // if(flag) - // { - // flag = false; - // time->start(100); - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); - // qDebug() << "FullFunctionWidget::onSetSlider" << curvalue; - // } -} - -bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == m_verticalScrollBar) { - if (watched == m_verticalScrollBar) { - if (event->type() == QEvent::Enter) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4)); - } - - if (event->type() == QEvent::Leave) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); - } - } - } else { - if (event->type() == QEvent::KeyPress) { - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); - QWidget *wid = widItem->widget(); - FullListView *m_listview = qobject_cast(wid); - QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget *widTop = widItemTop->widget(); - FullListView *m_listviewTop = qobject_cast(widTop); - QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Tab) { - Q_EMIT setFocusToSideWin(); - return true; - } - - if (ke->key() == Qt::Key_Up) { - if (!m_listviewTop->hasFocus()) { - QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); - btnGroupClickedSlot(buttonTop); - this->m_scrollArea->setFocusToPreChild(); - } else { - m_listview->setFocus(); - QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); - btnGroupClickedSlot(button); - m_index = m_buttonList.size() - 1; - } - - Q_EMIT selectFirstItem(); - return true; - } - - if (ke->key() == Qt::Key_Down) { - if (!m_listview->hasFocus()) { - QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); - btnGroupClickedSlot(button); - this->m_scrollArea->setFocusToNextChild(); - } else { - m_listviewTop->setFocus(); - QAbstractButton *buttonTop = getCurLetterButton(0); - btnGroupClickedSlot(buttonTop); - m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0, 0)); - m_index = 0; - } - - Q_EMIT selectFirstItem(); - return true; - } - } - } - - return QWidget::eventFilter(watched, event); -} - -void FullFunctionWidget::functionButtonClick() -{ - if (m_btnGroup->button(0) != nullptr) { - m_btnGroup->button(0)->click(); - } - - m_index = 0; -} - -void FullFunctionWidget::setFocusToThis() -{ - QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget *widTop = widItemTop->widget(); - FullListView *m_listviewTop = qobject_cast(widTop); - functionButtonClick(); - m_listviewTop->setFocus(); - Q_EMIT selectFirstItem(); -} diff --git a/src/UserInterface/Widget/full_searchresult_widget.cpp b/src/UserInterface/Widget/full_searchresult_widget.cpp deleted file mode 100644 index 3f4eff6..0000000 --- a/src/UserInterface/Widget/full_searchresult_widget.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * 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 -#include "style.h" -#include "utility.h" -#include - -FullSearchResultWidget::FullSearchResultWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullSearchResultWidget::~FullSearchResultWidget() -{ - delete m_ukuiMenuInterface; -} - -void FullSearchResultWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - this->setFocusPolicy(Qt::NoFocus); - QHBoxLayout *mainLayout = new QHBoxLayout(this); - mainLayout->setContentsMargins(40, 0, 40, 0); - mainLayout->setSpacing(0); - m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); - mainLayout->addItem(m_spaceItem); - m_scrollArea = new ScrollArea; - m_scrollArea->setStyleSheet("background:transparent"); - m_scrollAreaWid = new ScrollAreaWid(this); - m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setWidgetResizable(true); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAreaWidLayout = new QVBoxLayout(m_scrollAreaWid); - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); - m_scrollAreaWidLayout->setSpacing(10); - QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); - rightButtonLayout->setContentsMargins(0, 0, 0, 20); - rightButtonLayout->setSpacing(0); - QSpacerItem *m_spaceItem2 = nullptr; - m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem2); - m_verticalScrollBar = new QScrollBar(m_scrollArea); - m_verticalScrollBar->installEventFilter(this); - m_verticalScrollBar->setOrientation(Qt::Vertical); - mainLayout->addWidget(m_scrollArea); - QSpacerItem *m_spaceItem1 = nullptr; - m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - mainLayout->addItem(m_spaceItem1); - m_powerOffButton = new QPushButton(this); - m_powerOffButton->setFixedSize(QSize(40, 40)); - m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); - QIcon powerIcon; - powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); - m_powerOffButton->setIcon(powerIcon); - m_powerOffButton->setIconSize(QSize(28, 28)); - m_powerOffButton->setFlat(true); - m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" - "QPushButton:hover {border-radius:20px; background: rgba(255, 255, 255, 0.2);}" - "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); - rightButtonLayout->addWidget(m_verticalScrollBar); - QSpacerItem *m_spaceItem3 = nullptr; - m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - rightButtonLayout->addItem(m_spaceItem3); - rightButtonLayout->addWidget(m_powerOffButton); - rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); - mainLayout->addLayout(rightButtonLayout); - m_ukuiMenuInterface = new UkuiMenuInterface; - initAppListWidget(); - fillAppList(); - m_scrollAreaWid->adjustSize(); - m_scrollAreaWidHeight = m_scrollAreaWid->height() + 1; - initVerticalScrollBar(); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullSearchResultWidget::on_setScrollBarValue); - connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullSearchResultWidget::on_setAreaScrollBarValue); - connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullSearchResultWidget::on_powerOffButton_customContextMenuRequested); - connect(m_powerOffButton, &QPushButton::clicked, this, &FullSearchResultWidget::on_powerOffButton_clicked); -} - -void FullSearchResultWidget::initVerticalScrollBar() -{ - m_verticalScrollBar->setFixedHeight(200); - int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; - - if (scrollBarSize >= 200) { - m_verticalScrollBar->hide(); - } else { - m_verticalScrollBar->show(); - } - - m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, 1); " - "margin: 0px,0px,0px,0px; border-radius: %3px;}" - "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, 1);" - "border-radius: %3px; min-height: %1;}" - "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" - "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); -} - -void FullSearchResultWidget::on_powerOffButton_clicked() -{ - QProcess::startDetached(QString("ukui-session-tools")); -} - -void FullSearchResultWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) -{ - RightClickMenu m_otherMenu(this); - m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(pos)); - myDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; -} - -void FullSearchResultWidget::initAppListWidget() -{ - m_listView = new FullListView(this, 0); - m_listView->installEventFilter(this); - m_scrollAreaWidLayout->addWidget(m_listView); - m_listView->setFixedWidth(m_scrollArea->width()); - connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); - connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal); - connect(m_listView, &FullListView::sendSetslidebar, this, &FullSearchResultWidget::onSetSlider); -} - -void FullSearchResultWidget::fillAppList() -{ - m_data.clear(); - m_listView->addData(m_data); - resizeScrollAreaControls(); -} -/** - * 执行应用程序 - */ -void FullSearchResultWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -void FullSearchResultWidget::updateAppListView(QVector arg) -{ - m_data.clear(); - - Q_FOREACH (QStringList appinfo, arg) { - m_data.append(appinfo.at(0)); - } - - m_listView->updateData(m_data); - resizeScrollAreaControls(); - m_scrollAreaWidHeight = m_scrollAreaWid->height() + 1; - initVerticalScrollBar(); -} - -void FullSearchResultWidget::resizeScrollAreaControls() -{ - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); - QWidget *wid = widItem->widget(); - FullListView *listview = qobject_cast(wid); - listview->adjustSize(); - int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; - int rowcount = 0; - - if (listview->model()->rowCount() % dividend > 0) { - rowcount = listview->model()->rowCount() / dividend + 1; - } else { - rowcount = listview->model()->rowCount() / dividend; - } - - listview->setFixedSize(m_scrollArea->width(), listview->gridSize().height() * rowcount); - m_scrollArea->widget()->setFixedSize(listview->size()); -} - -bool FullSearchResultWidget::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == m_listView) { - if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Tab) { - Q_EMIT setFocusToSideWin(); - return true; - } - } - } - - if (watched == m_verticalScrollBar) { - if (event->type() == QEvent::Enter) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4)); - } - - if (event->type() == QEvent::Leave) { - m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2)); - } - } - - return QWidget::eventFilter(watched, event); -} - -void FullSearchResultWidget::selectFirstItemTab() -{ - m_listView->setFocus(); - m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); - m_scrollArea->verticalScrollBar()->setValue(0); -} - -void FullSearchResultWidget::repaintWidget() -{ - m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); - m_scrollAreaWidLayout->removeWidget(m_listView); - m_listView->setParent(nullptr); - delete m_listView; - initAppListWidget(); - fillAppList(); - m_scrollAreaWidHeight = m_scrollAreaWid->height() + 1; - initVerticalScrollBar(); -} - -void FullSearchResultWidget::moveScrollBar(int type) -{ - int height = Style::m_availableScreenHeight; - - if (type == 0) { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); - } else { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); - } -} - -void FullSearchResultWidget::onSetSlider(int value) -{ - myDebug() << value; - - if (value == 0) { - m_scrollArea->verticalScrollBar()->setValue(0); - } else { - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); - } -} - -void FullSearchResultWidget::setViewFocus() -{ - m_listView->setFocus(); -} - -void FullSearchResultWidget::on_setScrollBarValue(int value) -{ - m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); - m_verticalScrollBar->setValue(value); -} - -void FullSearchResultWidget::on_setAreaScrollBarValue(int value) -{ - m_scrollArea->verticalScrollBar()->setValue(value); -} diff --git a/src/UserInterface/Widget/function_Widget.cpp b/src/UserInterface/Widget/function_Widget.cpp deleted file mode 100644 index efadea4..0000000 --- a/src/UserInterface/Widget/function_Widget.cpp +++ /dev/null @@ -1,278 +0,0 @@ -#include "function_Widget.h" -#include "style.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "currenttime_interface.h" -#include "style.h" -#include -#define TIME_FORMAT "org.ukui.control-center.panel.plugins" -#define TIME_FORMAT_KEY "hoursystem" -#include -#include - -FunctionWidget::FunctionWidget(QWidget *parent): QWidget(parent) -{ - // if(QGSettings::isSchemaInstalled("org.ukui.style")){ - // themeSetting=new QGSettings("org.ukui.style"); - // themeName=themeSetting->get("style-name").toString(); - // } - // connect(themeSetting,&QGSettings::changed,this,[=](){ - // changeSearchBoxBackground(); - // }); - usrInterface = new QDBusInterface("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - QDBusConnection::sessionBus()); - QDBusConnection::sessionBus().connect("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - "stylename_change_signal", - this, - SLOT(changeSearchBoxBackground(QString)) - ); - initUi(); - myTimer = new QTimer(); - myTimer->start(10000); - connect(myTimer, &QTimer::timeout, [this]() { - timeLabel->setText(Time->currentTime); - weekLabel->setText(Time->currentWeek); - dateLabel->setText(Time->currentDate); - }); - - if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) { - timeSetting = new QGSettings(TIME_FORMAT); - connect(timeSetting, &QGSettings::changed, this, [ = ](const QString & key) { - timeLabel->setText(Time->currentTime); - weekLabel->setText(Time->currentWeek); - dateLabel->setText(Time->currentDate); - }); - } -} - -FunctionWidget::~FunctionWidget() -{ - if (themeSetting) { - delete themeSetting; - } - - if (myTimer) { - delete myTimer; - } - - if (upWidget) { - delete upWidget; - } - - if (upLayout) { - delete upLayout; - } - - if (leftUpWidget) { - delete leftUpWidget; - } - - if (leftUpLayout) { - delete leftUpLayout; - } - - if (upLeftWidget) { - delete upLeftWidget; - } - - if (upLeftLayout) { - delete upLeftLayout; - } - - if (upRightWidget) { - delete upRightWidget; - } - - if (upRightLayout) { - delete upRightLayout; - } - - if (downWidget) { - delete downWidget; - } - - if (downLayout) { - delete downLayout; - } - - if (timeLabel) { - delete timeLabel; - } - - if (weekLabel) { - delete weekLabel; - } - - if (dateLabel) { - delete dateLabel; - } - - if (searchEditBtn) { - delete searchEditBtn; - } - - if (focusPlug) { - delete focusPlug; - } - - if (effect) { - delete effect; - } - - themeSetting = nullptr; - myTimer = nullptr; - upWidget = nullptr; - upLayout = nullptr; - leftUpWidget = nullptr; - leftUpLayout = nullptr; - upRightWidget = nullptr; - downWidget = nullptr; - downLayout = nullptr; - timeLabel = nullptr; - weekLabel = nullptr; - dateLabel = nullptr; - searchEditBtn = nullptr; - focusPlug = nullptr; - effect = nullptr; -} - -void FunctionWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setStyleSheet("border:0px solid #ff0000;background:transparent;"); - this->setFocusPolicy(Qt::NoFocus); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - mainLayout->setSpacing(0); - this->setLayout(mainLayout); - //时间+搜索框 - upWidget = new QWidget(); - upWidget->setFixedSize(400, 232); - upLayout = new QVBoxLayout(); - upWidget->setLayout(upLayout); - upLayout->setContentsMargins(0, 0, 0, 32); - upLayout->setSpacing(0); - //上 - leftUpWidget = new QWidget(); - leftUpWidget->setFixedSize(400, 96); - leftUpLayout = new QHBoxLayout(); - leftUpWidget->setLayout(leftUpLayout); - leftUpLayout->setContentsMargins(0, 0, 0, 0); - leftUpLayout->setSpacing(0); - //左上左 - upLeftWidget = new QWidget; - upLeftWidget->setFixedSize(263, 96); - upLeftLayout = new QHBoxLayout(); - upLeftWidget->setLayout(upLeftLayout); - upLeftLayout->setContentsMargins(0, 0, 0, 0); - // upLeftWidget->setStyleSheet("border-width:1px;border-style:solid;border-color:red"); - //左上右 - upRightWidget = new QWidget; - upRightWidget->setFixedSize(170, 96); - upRightLayout = new QVBoxLayout(); - upRightWidget->setLayout(upRightLayout); - upRightLayout->setContentsMargins(0, 0, 0, 0); - upRightLayout->setSpacing(0); - // upRightWidget->setStyleSheet("border-width:1px;border-style:solid;border-color:red"); - //左下 - downWidget = new QWidget; - downLayout = new QVBoxLayout(); - downWidget->setLayout(downLayout); - downWidget->setFixedSize(400, 104); - downLayout->setSpacing(0); - downLayout->setContentsMargins(0, 24, 0, 0); - //左侧控件 - timeLabel = new QLabel(); - weekLabel = new QLabel(); - dateLabel = new QLabel(); - //搜索 - searchEditBtn = new QPushButton(); - searchEditBtn->setFocusPolicy(Qt::NoFocus); - searchEditBtn->setFixedSize(400, 80); - searchEditBtn->setIcon(QIcon(":/data/img/mainviewwidget/ukui-search-blue.svg")); - searchEditBtn->setIconSize(QPixmap(":/data/img/mainviewwidget/ukui-search-blue.svg").size()); - searchEditBtn->setText(tr("Search")); - QDBusReply styleName = usrInterface->call(QString("get_current_stylename")); - changeSearchBoxBackground(styleName); - connect(searchEditBtn, &QPushButton::clicked, this, &FunctionWidget::obtainSearchResult); - downLayout->addWidget(searchEditBtn); - upLayout->addWidget(leftUpWidget); - upLayout->addWidget(downWidget); - mainLayout->addWidget(upWidget); - focusPlug = new pluginwidget(this); - //加入专注模式 - // if(plugin) - // { - mainLayout->addWidget(focusPlug); - focusPlug->setFixedSize(400, 638); - // } - mainLayout->addStretch(); - leftUpLayout->addWidget(upLeftWidget); - leftUpLayout->addWidget(upRightWidget); - Time = new CurrentTimeInterface; - timeLabel->setText(Time->currentTime); - weekLabel->setText(Time->currentWeek); - dateLabel->setText(Time->currentDate); - upLeftLayout->addWidget(timeLabel); - upRightLayout->addWidget(weekLabel); - upRightLayout->addWidget(dateLabel); - upRightLayout->setContentsMargins(0, 0, 0, 0); - upRightLayout->setSpacing(0); - weekLabel->setContentsMargins(10, 8, 0, 0); - dateLabel->setContentsMargins(10, 6, 0, 0); - timeLabel->setStyleSheet("border:0px;background:transparent;font-size:96px;color:white;"); - dateLabel->setStyleSheet("border:0px;background:transparent;font-size:32px;color:white;"); - weekLabel->setStyleSheet("border:0px;background:transparent;font-size:38px;color:white;"); - effect = new QGraphicsDropShadowEffect(this); - effect->setXOffset(0); - effect->setYOffset(0); - effect->setBlurRadius(8); - effect->setColor(QColor(38, 38, 38, 100)); - upWidget->setGraphicsEffect(effect); -} - -void FunctionWidget::setDownOpacityEffect(const qreal &num) -{ - opacity = num; - QDBusReply styleName = usrInterface->call(QString("get_current_stylename")); - changeSearchBoxBackground(styleName); -} - -void FunctionWidget::obtainSearchResult() -{ - QDBusInterface iface("com.ukui.search.service", - "/", - "org.ukui.search.service", - QDBusConnection::sessionBus()); - - if (iface.isValid()) { - iface.call("showWindow"); - } -} - -//搜索框适配主题 -void FunctionWidget::changeSearchBoxBackground(QString styleName) -{ - QString styleSheetDark = QString("border-radius:40px;background:rgba(44,50,57,%1);color:white;font-size:24px;text-align:left;padding-left:24px;").arg(opacity); - QString styleSheetLight = QString("border-radius:40px;background:rgba(255,255,255,%1);" - "color:rgba(58,67,78,0.25);font-size:24px;text-align:left;padding-left:24px;").arg(opacity); - - // themeName=themeSetting->get("style-name").toString(); - if (styleName == "ukui-dark") { - searchEditBtn->setStyleSheet(styleSheetDark); - } else { - searchEditBtn->setStyleSheet(styleSheetLight); - } -} - - diff --git a/src/UserInterface/Widget/function_Widget.h b/src/UserInterface/Widget/function_Widget.h deleted file mode 100644 index 0298a62..0000000 --- a/src/UserInterface/Widget/function_Widget.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef FUNCTIONWIDGET_H -#define FUNCTIONWIDGET_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "AbstractInterface.h" -#include -#include "plugin_widget.h" -#include "currenttime_interface.h" - -class FunctionWidget : public QWidget -{ - Q_OBJECT -public: - FunctionWidget(QWidget *parent); - ~FunctionWidget(); - //QWidget* focusPlug=nullptr; - pluginwidget *focusPlug = nullptr; - void setDownOpacityEffect(const qreal &num); - -protected: - void initUi(); - -private: - CurrentTimeInterface *Time = nullptr; - QGSettings *themeSetting = nullptr; - QGSettings *timeSetting = nullptr; - QString themeName; - QObject *plugin = nullptr; - AbstractInterface *app; - QGraphicsDropShadowEffect *effect; - QPalette palette; - QTimer *myTimer = nullptr; - - //上方(时间+搜索) - QWidget *upWidget = nullptr; - QWidget *leftUpWidget = nullptr; - QWidget *upLeftWidget = nullptr; - QWidget *downWidget = nullptr; - - - QVBoxLayout *upLayout; - QHBoxLayout *leftUpLayout; - QVBoxLayout *downLayout; - QVBoxLayout *focusModeLayout; - - QHBoxLayout *upLeftLayout; - QVBoxLayout *upRightLayout; - - QLabel *timeLabel; - QLabel *weekLabel; - QLabel *dateLabel; - QPushButton *searchEditBtn; - - QDBusInterface *usrInterface = nullptr; - - //右侧 - QWidget *upRightWidget = nullptr; - - qreal opacity; //透明系数 - -private Q_SLOTS: - - void obtainSearchResult(); - -public Q_SLOTS: - - void changeSearchBoxBackground(QString styleName); -public: -Q_SIGNALS: - void hideTabletWindow(); - - - -}; - -#endif // TIMEWIDGET_H diff --git a/src/UserInterface/Widget/main_view_widget.cpp b/src/UserInterface/Widget/main_view_widget.cpp deleted file mode 100644 index 8a883d8..0000000 --- a/src/UserInterface/Widget/main_view_widget.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -MainViewWidget::MainViewWidget(QWidget *parent) : - QWidget(parent) -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setAutoFillBackground(false); - this->setAttribute(Qt::WA_TranslucentBackground); - this->setFocusPolicy(Qt::StrongFocus); -} - -MainViewWidget::~MainViewWidget() -{ -} - -void MainViewWidget::styleChangeSlot(const QString &style) -{ - m_curStyle = style; - - if (style == "ukui-dark") { - m_backColor.setNamedColor("#800D0D0D"); - } else { - m_backColor.setNamedColor("#94FFFFFF"); - } -} - -void MainViewWidget::paintEvent(QPaintEvent *event) -{ -// double transparency = getTransparency(); - QRect rect = this->rect(); - QPainterPath path; - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(Qt::transparent); - qreal radius = 10; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter.setPen(Qt::transparent); - painter.setOpacity(0.58); - painter.fillPath(path, m_backColor); - QWidget::paintEvent(event); -} diff --git a/src/UserInterface/Widget/main_view_widget.h b/src/UserInterface/Widget/main_view_widget.h deleted file mode 100644 index ebebf5a..0000000 --- a/src/UserInterface/Widget/main_view_widget.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ukuimenuinterface.h" -#include "searchappthread.h" -#include "directory_changed_thread.h" -#include "convert_winid_to_desktop.h" -#include "style.h" -#include "src/UtilityFunction/utility.h" -#include -#include - -class MainViewWidget : public QWidget -{ - Q_OBJECT - -public: - explicit MainViewWidget(QWidget *parent = nullptr); - ~MainViewWidget(); - -protected: - - void initUi(); - - void paintEvent(QPaintEvent *event); - -public Q_SLOTS: - void styleChangeSlot(const QString &style); - -Q_SIGNALS: - - void directoryChangedSignal(); - - void sendDirectoryPath(); -private: - QString m_curStyle; - QColor m_backColor; -}; - -#endif // MAINVIEWWIDGET_H diff --git a/src/UserInterface/Widget/plugin_widget.cpp b/src/UserInterface/Widget/plugin_widget.cpp deleted file mode 100644 index 2881e05..0000000 --- a/src/UserInterface/Widget/plugin_widget.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "plugin_widget.h" -#include "KySmallPluginInterface.h" -#include -pluginwidget::pluginwidget(QWidget *parent) : QWidget(parent) -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setFocusPolicy(Qt::NoFocus); - init(); -} -void pluginwidget::init() -{ - QPluginLoader loader("/opt/small-plugin/bin/libsmall-plugin-manage.so"); - QObject *plugin = loader.instance(); - - if (plugin) { - KySmallPluginInterface *app = qobject_cast(plugin); - QWidget *widget = app->createWidget(this); - widget->setFixedSize(400, 638); - } -} diff --git a/src/UserInterface/Widget/plugin_widget.h b/src/UserInterface/Widget/plugin_widget.h deleted file mode 100644 index af41deb..0000000 --- a/src/UserInterface/Widget/plugin_widget.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PLUGINWIDGET_H -#define PLUGINWIDGET_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class pluginwidget : public QWidget -{ - Q_OBJECT -public: - explicit pluginwidget(QWidget *parent = nullptr); - void init(); -}; - -#endif // PLUGINWIDGET_H diff --git a/src/UserInterface/Widget/tabview_widget.cpp b/src/UserInterface/Widget/tabview_widget.cpp deleted file mode 100644 index c07987b..0000000 --- a/src/UserInterface/Widget/tabview_widget.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "tabview_widget.h" -#include - -TabViewWidget::TabViewWidget() -{ - setStyleSheet("background:transparent"); - collectionTab = new QWidget(); - recentTab = new QWidget(); - collectionTab->setObjectName(QString::fromUtf8("collectionTab")); - recentTab->setObjectName(QString::fromUtf8("recentTab")); - this->addTab(collectionTab, QString()); - this->addTab(recentTab, QString()); - this->tabBar()->hide(); - this->setCurrentIndex(0); - initAppListWidget(); - updateListView(); -} - -void TabViewWidget::initAppListWidget() -{ - m_collectListView = new RightListView(collectionTab); - m_collectListView->setFixedSize(352, 428); - m_collectListView->show(); -} - -void TabViewWidget::updateListView() -{ - m_data.clear(); - - Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { - m_data.append(desktopfp); - } - - m_collectListView->addData(m_data); -} - diff --git a/src/UserInterface/Widget/tabview_widget.h b/src/UserInterface/Widget/tabview_widget.h deleted file mode 100644 index ca9e999..0000000 --- a/src/UserInterface/Widget/tabview_widget.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TABVIEWWIDGET_H -#define TABVIEWWIDGET_H -#include -#include "rightlistview.h" - -class TabViewWidget: public QTabWidget -{ -public: - TabViewWidget(); - -protected: - - void initAppListWidget(); - void updateListView(); - -private: - - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QWidget *collectionTab = nullptr; - QWidget *recentTab = nullptr; - RightListView *m_collectListView = nullptr; - QStringList m_data; -}; - -#endif // TABVIEWWIDGET_H diff --git a/src/UserInterface/full_mainwindow.cpp b/src/UserInterface/full_mainwindow.cpp deleted file mode 100644 index 5cf9707..0000000 --- a/src/UserInterface/full_mainwindow.cpp +++ /dev/null @@ -1,462 +0,0 @@ -#include "full_mainwindow.h" -#include -#include -#include -#include "src/UtilityFunction/utility.h" - -FullMainWindow::FullMainWindow(QWidget *parent) : - QMainWindow(parent) -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); - this->setAttribute(Qt::WA_TranslucentBackground, true); - this->setAutoFillBackground(false); - m_searchAppThread = new SearchAppThread; - Style::initWidStyle(); - m_buttonStyle = QString("%1{border-radius:24px; background: rgba(255, 255, 255, 0.1);}" - "%1:hover {border-radius:24px; background: rgba(255, 255, 255, 0.2);}" - "%1:pressed {border-radius:24px; background: rgba(255, 255, 255, 0.3);}"); - this->setFixedSize(Style::m_availableScreenWidth, Style::m_availableScreenHeight); - centralwidget = new QWidget(this); - verticalLayout = new QVBoxLayout(centralwidget); - verticalLayout->setSpacing(0); - verticalLayout->setContentsMargins(0, 48, 0, 0); - topHorizontalLayout = new QHBoxLayout(); - topHorizontalLayout->setSpacing(8); - topHorizontalLayout->setContentsMargins(155, 0, 35, 0); - horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - bottomHorizonLayout = new QHBoxLayout(); - bottomHorizonLayout->setSpacing(0); - bottomHorizonLayout->setContentsMargins(0, 0, 0, 0); - m_lineEdit = new QLineEdit(centralwidget); - m_lineEdit->setFixedSize(QSize(372, 36)); - m_lineEdit->setLayoutDirection(Qt::LeftToRight); - m_lineEdit->installEventFilter(this); - m_lineEdit->setFrame(false); - m_queryWid = new QWidget; - m_queryWid->setParent(m_lineEdit); - m_queryWid->setFocusPolicy(Qt::NoFocus); - m_queryWid->setFixedSize(372, 36); - QHBoxLayout *queryWidLayout = new QHBoxLayout; - queryWidLayout->setContentsMargins(0, 0, 0, 0); - queryWidLayout->setSpacing(5); - m_queryWid->setLayout(queryWidLayout); - char style[200]; - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/full-search.svg"), 16); - - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings("org.ukui.style", QByteArray(), this); - - if (gsetting->keys().contains("styleName")) { - if (/*gsetting->get("styleName").toString() == "ukui-light"*/false) { - pixmap = drawSymbolicBlackColoredPixmap(pixmap); - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:17px;color:#000000;}", - QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:17px;color:#ffffff;}", - QueryLineEditClickedBorderDefault, QueryLineEditBackground); - } - } - - connect(gsetting, &QGSettings::changed, [ = ](QString key) { - if ("systemFont" == key || "systemFontSize" == key) { - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); - resetEditline(); - m_fullCommonPage->repaintWidget(); - m_fullFunctionPage->repaintWidget(); - m_fullLetterPage->repaintWidget(); - } - - if (key.contains(QString("styleName"))) { - changeStyle(); - } - }); - } - - m_lineEdit->setStyleSheet(style); - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon = new QLabel; - m_queryIcon->setFixedSize(pixmap.size()); - m_queryIcon->setPixmap(pixmap); - m_queryText = new QLabel; - QPalette pa; - pa.setColor(QPalette::Text, Qt::white); - m_queryText->setPalette(pa); - m_queryText->setText(tr("Search")); - m_queryText->adjustSize(); - queryWidLayout->addWidget(m_queryIcon); - queryWidLayout->addWidget(m_queryText); - queryWidLayout->setAlignment(Qt::AlignCenter); - m_lineEdit->setFocusPolicy(Qt::StrongFocus); - horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - fullSelectToolButton = new QPushButton(centralwidget); -// fullSelectToolButton->setStyleSheet(m_buttonStyle.arg("QToolButton")); - fullSelectToolButton->setObjectName(QString::fromUtf8("fullSelectToolButton")); - fullSelectToolButton->setMinimumSize(QSize(48, 48)); - fullSelectToolButton->installEventFilter(this); - fullSelectToolButton->setFocus(); - QIcon selectIcon; - selectIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/full-function.svg"), QSize(), QIcon::Normal, QIcon::Off); - fullSelectToolButton->setIcon(selectIcon); - fullSelectMenuButton = new QToolButton(centralwidget); - QIcon menuBottonIcon; - fullSelectMenuButton->setStyleSheet("QToolButton{background:transparent;}"); - fullSelectMenuButton->setProperty("useIconHighlightEffect", 0x0); - fullSelectMenuButton->setFixedSize(20, 20); - fullSelectMenuButton->setObjectName(QString::fromUtf8("fullSelectMenuButton")); - fullSelectMenuButton->setPopupMode(QToolButton::InstantPopup); - fullSelectMenuButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - fullSelectMenuButton->installEventFilter(this); - QPalette palete; - palete.setColor(QPalette::NoRole, Qt::white); - fullSelectMenuButton->setPalette(palete); - minPushButton = new QPushButton(centralwidget); - minPushButton->setObjectName(QString::fromUtf8("minPushButton")); - minPushButton->setFixedSize(QSize(48, 48)); - minPushButton->setFlat(true); - minPushButton->installEventFilter(this); - m_fullStackedWidget = new QStackedWidget(centralwidget); - m_fullCommonPage = new FullCommonUseWidget(m_fullStackedWidget); - m_fullStackedWidget->addWidget(m_fullCommonPage); - m_fullLetterPage = new FullLetterWidget(m_fullStackedWidget); - m_fullStackedWidget->addWidget(m_fullLetterPage); - m_fullFunctionPage = new FullFunctionWidget(m_fullStackedWidget); - m_fullStackedWidget->addWidget(m_fullFunctionPage); - m_fullResultPage = new FullSearchResultWidget(m_fullStackedWidget); - m_fullStackedWidget->addWidget(m_fullResultPage); - bottomHorizonLayout->addWidget(m_fullStackedWidget); - // bottomHorizonLayout->addWidget(verticalScrollBar); - topHorizontalLayout->addItem(horizontalSpacer); - topHorizontalLayout->addWidget(m_lineEdit); - topHorizontalLayout->addItem(horizontalSpacer_2); - topHorizontalLayout->addWidget(fullSelectToolButton); - topHorizontalLayout->addWidget(fullSelectMenuButton); - topHorizontalLayout->addWidget(minPushButton); - verticalLayout->addLayout(topHorizontalLayout); - verticalLayout->addLayout(bottomHorizonLayout); - this->setCentralWidget(centralwidget); - m_fullStackedWidget->setCurrentIndex(0); - m_menu = new QMenu; - m_allAction = new QAction(m_menu); - m_letterAction = new QAction(m_menu); - m_funcAction = new QAction(m_menu); - m_allAction->setText(tr("All")); - m_allAction->setCheckable(true); - m_letterAction->setText(tr("Letter")); - m_letterAction->setCheckable(true); - m_funcAction->setText(tr("Function")); - m_funcAction->setCheckable(true); - m_menu->addAction(m_allAction); - m_menu->addAction(m_letterAction); - m_menu->addAction(m_funcAction); - m_allAction->setChecked(true); - fullSelectMenuButton->setMenu(m_menu); - setTabOrder(m_lineEdit, fullSelectToolButton); - setTabOrder(fullSelectToolButton, fullSelectMenuButton); - setTabOrder(fullSelectMenuButton, minPushButton); - changeStyle(); - connect(m_lineEdit, &QLineEdit::textChanged, this, &FullMainWindow::searchAppSlot); - connect(this, &FullMainWindow::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword); - connect(m_searchAppThread, &SearchAppThread::sendSearchResult, this, &FullMainWindow::recvSearchResult); - connect(minPushButton, &QPushButton::clicked, this, &FullMainWindow::on_minPushButton_clicked); - connect(fullSelectToolButton, &QToolButton::clicked, this, &FullMainWindow::on_fullSelectToolButton_clicked); - connect(fullSelectMenuButton, &QToolButton::triggered, this, &FullMainWindow::on_fullSelectMenuButton_triggered); - connect(m_fullFunctionPage, &FullFunctionWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); - connect(m_fullLetterPage, &FullLetterWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); - connect(m_fullCommonPage, &FullCommonUseWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); - connect(m_fullResultPage, &FullSearchResultWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); - connect(this, &FullMainWindow::sendSetFocusToCom, m_fullCommonPage, &FullCommonUseWidget::selectFirstItemTab); - connect(this, &FullMainWindow::sendSetFocusToLet, m_fullLetterPage, &FullLetterWidget::setFocusToThis); - connect(this, &FullMainWindow::sendSetFocusToFun, m_fullFunctionPage, &FullFunctionWidget::setFocusToThis); - connect(this, &FullMainWindow::sendSetFocusToResult, m_fullResultPage, &FullSearchResultWidget::selectFirstItemTab); - connect(fullSelectMenuButton, &QToolButton::clicked, this, &FullMainWindow::on_fullSelectMenuButton_clicked); - connect(m_fullCommonPage, &FullCommonUseWidget::sendUpdateOtherView, this, &FullMainWindow::sendUpdateOtherView); -} - -FullMainWindow::~FullMainWindow() -{ -} - -void FullMainWindow::updateView() -{ - m_fullCommonPage->updateListView(); - m_fullFunctionPage->updateAppListView(); - m_fullLetterPage->updateAppListView(); -} - -void FullMainWindow::changeStyle() -{ - QPalette linePe; - QString buttonColorDefault; - QString buttonColorHover; - QString buttonColorPress; - QColor buttonColor; - - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.keys().contains(QString("styleName"))) { - if (/*gsetting.get("style-name").toString() == "ukui-light"*/false) { - buttonColorDefault = "rgba(16, 23, 29, 0.06)"; - buttonColorHover = "rgba(16, 23, 29, 0.12)"; - buttonColorPress = "rgba(16, 23, 29, 0.17)"; - } else { - buttonColor = linePe.color(QPalette::Light); - QRgb rgbDefault = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 25); - buttonColorDefault = "#" + QString::number(rgbDefault, 16); - QRgb rgbHover = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 50); - buttonColorHover = "#" + QString::number(rgbHover, 16); - QRgb rgbPress = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 75); - buttonColorPress = "#" + QString::number(rgbPress, 16); - } - } - } - - m_buttonStyle = QString("%1{border-radius:24px; background:" + buttonColorDefault + ";}" - "%1:hover {border-radius:24px; background:" + buttonColorHover + ";}" - "%1:pressed {border-radius:24px; background:" + buttonColorPress + ";}"); - fullSelectToolButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); - fullSelectMenuButton->setIcon(getCurIcon(":/data/img/mainviewwidget/full-drop-down.svg", false)); - minPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/full-min.svg", false)); - minPushButton->setProperty("useIconHighlightEffect", 0x0); -} - -void FullMainWindow::on_minPushButton_clicked() -{ - Q_EMIT showNormalWindow(); -} - -void FullMainWindow::paintEvent(QPaintEvent *event) -{ - double transparency = getTransparency(); - QPainterPath path; - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(Qt::transparent); - painter.setBrush(this->palette().dark()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); - path.addRect(this->rect()); - KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - QMainWindow::paintEvent(event); -} - -bool FullMainWindow::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == m_lineEdit) { - isSearching = true; - char style[200]; - - if (event->type() == QEvent::FocusIn) { - sprintf(style, "QLineEdit{border:2px solid %s;background-color:%s;border-radius:17px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditClickedBackground); - m_lineEdit->setStyleSheet(style); - - if (m_lineEdit->text().isEmpty()) { - qDebug() << "bool FullMainWindow::eventFilter(QObject *watched, QEvent *event)" << m_queryWid->layout()->count(); - - if (m_queryWid->layout()->count() == 2) { - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); - } - - m_queryWid->setGeometry(6, 2, m_queryIcon->width() + 5, Style::QueryLineEditHeight); - m_queryWid->layout()->setAlignment(Qt::AlignVCenter); - m_lineEdit->setTextMargins(26, 0, 0, 0); - } - } else if (event->type() == QEvent::FocusOut && m_lineEdit->text().isEmpty()) { - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:17px;color:#ffffff;}", - QueryLineEditClickedBorderDefault, QueryLineEditClickedBackground); - m_lineEdit->setStyleSheet(style); - resetEditline(); - } - - if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) { - Q_EMIT sendSetFocusToResult(); - } - } - } - - if (watched == minPushButton) { - if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Tab) { - if (m_fullStackedWidget->currentIndex() == 0) { - Q_EMIT sendSetFocusToCom(); - } else if (m_fullStackedWidget->currentIndex() == 1) { - Q_EMIT sendSetFocusToLet(); - } else if (m_fullStackedWidget->currentIndex() == 2) { - Q_EMIT sendSetFocusToFun(); - } else { - Q_EMIT sendSetFocusToResult(); - } - - return true; - } - } - } - - if (watched == minPushButton || watched == fullSelectToolButton || watched == fullSelectMenuButton) { - if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down || - ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { - return true; - } - } - } - - return QWidget::eventFilter(watched, event); -} - -void FullMainWindow::resetEditline() -{ - m_lineEdit->clear(); - m_lineEdit->clearFocus(); - m_queryWid->layout()->addWidget(m_queryIcon); - m_queryWid->layout()->addWidget(m_queryText); - m_queryIcon->adjustSize(); - m_queryText->adjustSize(); - m_queryWid->layout()->setAlignment(Qt::AlignCenter); - m_queryWid->setFixedSize(372, 36); -} - -bool FullMainWindow::event(QEvent *event) -{ - if (event->type() == QEvent::ActivationChange) { - qDebug() << " * 鼠标点击窗口外部事件"; - - if (QApplication::activeWindow() != this) { - this->hide(); - } /*else { - - fullLetterPage->repaintWidget(); - fullFunctionPage->repaintWidget(); - }*/ - } - - if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = (QKeyEvent *) event; - - if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { - if (fullSelectToolButton->hasFocus()) { - fullSelectToolButton->click(); - } else if (fullSelectMenuButton->hasFocus()) { - fullSelectMenuButton->click(); - } - - if (m_lineEdit->hasFocus()) { - m_fullResultPage->setFocus(); - } else { - QWidget *current_focus_widget; - current_focus_widget = QWidget::focusWidget(); - QPushButton *le = qobject_cast(current_focus_widget); - - if (le != nullptr) { - le->clicked(); - } - } - } - - if (keyEvent->key() == Qt::Key_Escape) { - this->hide(); - } - } - - return QWidget::event(event); -} - -void FullMainWindow::setFocusToButton() -{ - qDebug() << "设置lineEdit焦点"; - m_lineEdit->setFocus(); -} - -void FullMainWindow::searchAppSlot(QString arg) -{ - if (!arg.isEmpty()) { //切换至搜索模块 - Q_EMIT sendSearchKeyword(arg); - m_searchAppThread->start(); - m_fullStackedWidget->setCurrentIndex(3); - } else { - m_fullStackedWidget->setCurrentIndex(m_state); - m_fullFunctionPage->repaintWidget(); - m_fullLetterPage->repaintWidget(); - } -} - -void FullMainWindow::mousePressEvent(QMouseEvent *event) -{ - resetEditline(); - return QMainWindow::mousePressEvent(event); -} - -void FullMainWindow::recvSearchResult(QVector arg) -{ - m_searchAppThread->quit(); - m_fullResultPage->updateAppListView(arg); -} - -void FullMainWindow::on_fullSelectToolButton_clicked() -{ - resetEditline(); - fullSelectToolButton->setFocus(); - - if (m_fullStackedWidget->currentIndex() == 0) { - on_fullSelectMenuButton_triggered(m_letterAction); - } else if (m_fullStackedWidget->currentIndex() == 1) { - on_fullSelectMenuButton_triggered(m_funcAction); - } else if (m_fullStackedWidget->currentIndex() == 2) { - on_fullSelectMenuButton_triggered(m_allAction); - } -} - -void FullMainWindow::on_fullSelectMenuButton_clicked() -{ - resetEditline(); -} - -void FullMainWindow::on_fullSelectMenuButton_triggered(QAction *arg1) -{ - if (arg1 == m_allAction) { - m_fullStackedWidget->setCurrentIndex(0); - m_fullCommonPage->repaintWidget(); - //fullCommonPage->updateListView(); - m_state = 0; - fullSelectToolButton->setIcon(QIcon(":/data/img/mainviewwidget/full-all-2x.png")); - m_allAction->setChecked(true); - m_letterAction->setChecked(false); - m_funcAction->setChecked(false); - } else if (arg1 == m_letterAction) { - m_fullStackedWidget->setCurrentIndex(1); - m_fullLetterPage->repaintWidget(); - m_state = 1; - fullSelectToolButton->setIcon(QIcon(":/data/img/mainviewwidget/full-letter.svg")); - m_allAction->setChecked(false); - m_letterAction->setChecked(true); - m_funcAction->setChecked(false); - } else if (arg1 == m_funcAction) { - m_fullStackedWidget->setCurrentIndex(2); - m_fullFunctionPage->repaintWidget(); - m_state = 2; - fullSelectToolButton->setIcon(QIcon(":/data/img/mainviewwidget/full-function.svg")); - m_allAction->setChecked(false); - m_letterAction->setChecked(false); - m_funcAction->setChecked(true); - } -} - -void FullMainWindow::repaintWidget() -{ - m_fullCommonPage->repaintWidget(); - m_fullFunctionPage->repaintWidget(); - m_fullLetterPage->repaintWidget(); - m_fullResultPage->repaintWidget(); -} diff --git a/src/UserInterface/full_mainwindow.h b/src/UserInterface/full_mainwindow.h deleted file mode 100644 index 3e41bb9..0000000 --- a/src/UserInterface/full_mainwindow.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef FULLMAINWINDOW_H -#define FULLMAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include "full_commonuse_widget.h" -#include "full_function_widget.h" -#include "full_letter_widget.h" -#include "searchappthread.h" -#include "full_searchresult_widget.h" - -class FullMainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit FullMainWindow(QWidget *parent = nullptr); - ~FullMainWindow(); -public: - void updateView(); - void resetEditline(); - void repaintWidget(); - -Q_SIGNALS: - - void showNormalWindow(); - void sendSearchKeyword(QString arg); - void sendSetFocusToCom(); - void sendSetFocusToFun(); - void sendSetFocusToLet(); - void sendSetFocusToResult(); - void sendUpdateOtherView(); - -private Q_SLOTS: - - void on_minPushButton_clicked(); - void on_fullSelectToolButton_clicked(); - void on_fullSelectMenuButton_triggered(QAction *arg1); - void searchAppSlot(QString arg); - void recvSearchResult(QVector arg); - void setFocusToButton(); - void on_fullSelectMenuButton_clicked(); - - -protected: - void paintEvent(QPaintEvent *event); - bool event(QEvent *event); - bool eventFilter(QObject *watched, QEvent *event); - void mousePressEvent(QMouseEvent *event); - void changeStyle(); - -private: - QAction *m_allAction = nullptr; - QAction *m_letterAction = nullptr; - QAction *m_funcAction = nullptr; - QMenu *m_menu = nullptr; - - QWidget *centralwidget; - QVBoxLayout *verticalLayout; - QHBoxLayout *topHorizontalLayout; - QHBoxLayout *bottomHorizonLayout; - QSpacerItem *horizontalSpacer; - QLineEdit *m_lineEdit; - QSpacerItem *horizontalSpacer_2; - QPushButton *fullSelectToolButton; - QToolButton *fullSelectMenuButton; - QPushButton *minPushButton; - QStackedWidget *m_fullStackedWidget; - - FullCommonUseWidget *m_fullCommonPage; - FullLetterWidget *m_fullLetterPage; - FullFunctionWidget *m_fullFunctionPage; - FullSearchResultWidget *m_fullResultPage; - - SearchAppThread *m_searchAppThread = nullptr; - int m_state = 0; - QWidget *m_queryWid = nullptr; - QLabel *m_queryIcon = nullptr; - QLabel *m_queryText = nullptr; - bool isSearching = false; - QString m_buttonStyle; -}; - -#endif // FULLMAINWINDOW_H diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp deleted file mode 100644 index 7060f62..0000000 --- a/src/UserInterface/mainwindow.cpp +++ /dev/null @@ -1,1152 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "style.h" -#include -#include -#include -#include - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent) -{ - Style::initWidStyle(); - openDataBase("MainThreadDataBase"); - initDatabase(); - this->resize(Style::minw, Style::minh); - this->setAutoFillBackground(false); - m_centralwidget = new QWidget(this); - m_centerLayout = new QHBoxLayout(m_centralwidget); - m_centerLayout->setSpacing(0); - m_centerLayout->setContentsMargins(0, 0, 0, 0); - //左侧 - m_viewWidget = new MainViewWidget(m_centralwidget); - m_mainLeftVerticalLayout = new QVBoxLayout(m_viewWidget); - m_mainLeftVerticalLayout->setSpacing(0); - m_mainLeftVerticalLayout->setContentsMargins(8, 4, 0, 0); - //搜索框部分 - m_topStackedWidget = new QStackedWidget(m_viewWidget); - m_topStackedWidget->setFixedHeight(48); - //搜索框收起页 - m_minMenuPage = new QWidget(); - m_minMenuPage->setMinimumSize(QSize(0, 40)); - m_letfTopSelectHorizontalLayout = new QHBoxLayout(m_minMenuPage); - m_letfTopSelectHorizontalLayout->setSpacing(2); - m_letfTopSelectHorizontalLayout->setContentsMargins(8, 0, 4, 12); - m_minSelectTextLabel = new QLabel(m_minMenuPage); - m_horizontalSpacer = new QSpacerItem(58, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); - m_searchPushButton = new QPushButton(m_minMenuPage); -// m_searchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); - m_searchPushButton->setFixedSize(QSize(26, 26)); - m_searchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/search.svg", true)); - m_searchPushButton->installEventFilter(this); - m_minSelectButton = new QPushButton(m_minMenuPage); - m_minSelectButton->setFixedSize(QSize(26, 26)); - m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-all.svg", true)); - m_minSelectButton->installEventFilter(this); - m_selectMenuButton = new QLabel(m_minMenuPage); - m_selectMenuButton->installEventFilter(this); - m_selectMenuButton->setStyleSheet("background: transparent;"); - m_selectMenuButton->setFixedSize(QSize(16, 26)); - m_selectMenuButton->setAcceptDrops(true); - m_selectMenuButton->setFocusPolicy(Qt::StrongFocus); - m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true) - .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); - //搜索框展开页 - m_minSearchPage = new QWidget(); - m_leftTopSearchHorizontalLayout = new QHBoxLayout(m_minSearchPage); - m_leftTopSearchHorizontalLayout->setContentsMargins(8, 0, 8, 12); - m_lineEdit = new QLineEdit(m_minSearchPage); - m_lineEdit->setMinimumSize(QSize(30, 26)); - m_lineEdit->setStyleSheet(QString::fromUtf8("border-radius: 13px; border:1px solid rgba(5, 151, 255, 1); background: transparent;")); - m_lineEdit->setFrame(false); - m_lineEdit->setPlaceholderText(tr("Search")); - m_cancelSearchPushButton = new QPushButton(m_minSearchPage); - m_cancelSearchPushButton->setFixedSize(QSize(26, 26)); -// m_cancelSearchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); - m_cancelSearchPushButton->installEventFilter(this); - m_cancelSearchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-close-2x.png", true)); - m_topStackedWidget->addWidget(m_minMenuPage); - m_topStackedWidget->addWidget(m_minSearchPage); - //左侧列表区 - m_leftStackedWidget = new QStackedWidget(m_viewWidget); - m_leftStackedWidget->setFixedSize(QSize(300, Style::leftPageHeight)); - m_minAllPage = new QWidget(); - m_minAllPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minAllListView = new ListView(m_minAllPage); - m_minAllListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minAllListView->setFrameShape(QFrame::NoFrame); - m_leftStackedWidget->addWidget(m_minAllPage); - m_minAllListView->installEventFilter(this); - m_minLetterPage = new QWidget(); - m_minLetterPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minLetterListView = new ListView(m_minLetterPage); - m_minLetterListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minLetterListView->setFrameShape(QFrame::NoFrame); - m_leftStackedWidget->addWidget(m_minLetterPage); - m_minLetterListView->installEventFilter(this); - m_minFuncPage = new QWidget(); - m_minFuncPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minFuncListView = new ListView(m_minFuncPage); - m_minFuncListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minFuncListView->setFrameShape(QFrame::NoFrame); - m_leftStackedWidget->addWidget(m_minFuncPage); - m_minFuncListView->installEventFilter(this); - m_minSearchResultPage = new QWidget(); - m_minSearchResultPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minSearchResultListView = new ListView(m_minSearchResultPage); - m_minSearchResultListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); - m_minSearchResultListView->installEventFilter(this); - m_leftStackedWidget->addWidget(m_minSearchResultPage); - //右侧窗口 - m_mainRightVerticalLayout = new QVBoxLayout(); - m_mainRightVerticalLayout->setSpacing(0); - m_mainRightVerticalLayout->setContentsMargins(8, 4, 8, 8); - m_mainRightVerticalLayout_1 = new QVBoxLayout(); - m_rightTopHorizontalLayout = new QHBoxLayout(); - m_rightTopHorizontalLayout->setSpacing(30); - m_rightTopHorizontalLayout->setContentsMargins(8, 0, 10, 8); - //收藏按键 - m_collectPushButton = new QLabel(m_centralwidget); - m_collectPushButton->setFocusPolicy(Qt::StrongFocus); - m_collectPushButton->setFixedHeight(34); -// m_collectPushButton->setFlat(true); - m_collectPushButton->installEventFilter(this); - //最近按键 - m_recentPushButton = new QLabel(m_centralwidget); - m_recentPushButton->setFixedHeight(34); - m_recentPushButton->setFocusPolicy(Qt::StrongFocus); -// m_recentPushButton->setFlat(true); - m_recentPushButton->installEventFilter(this); - m_horizontalSpacer_3 = new QSpacerItem(332, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - //放大缩小按键 - m_minMaxChangeButton = new QPushButton(m_centralwidget); - m_minMaxChangeButton->setFixedSize(QSize(24, 24)); - m_minMaxChangeButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-max.svg", true)); - m_minMaxChangeButton->setFlat(true); - m_rightTopHorizontalLayout->addWidget(m_collectPushButton); - m_rightTopHorizontalLayout->addWidget(m_recentPushButton); - m_rightTopHorizontalLayout->addItem(m_horizontalSpacer_3); - m_rightTopHorizontalLayout->addWidget(m_minMaxChangeButton); - m_verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - //右侧列表区 - m_rightStackedWidget = new QStackedWidget(m_centralwidget); - m_rightStackedWidget->setFixedSize(QSize(324, 490)); - m_rightStackedWidget->setFocusPolicy(Qt::StrongFocus); - m_collectPage = new QWidget(); - m_collectPage->setFixedSize(QSize(324, 480)); - m_rightCollectLayout = new QVBoxLayout(m_collectPage); - m_rightCollectLayout->setContentsMargins(0, 0, 0, 0); - //收藏视图 - m_collectListView = new RightListView(m_collectPage); - m_collectListView->setFixedSize(QSize(324, 428)); - m_collectListView->setAcceptDrops(true); - m_collectListView->setAutoFillBackground(false); - m_collectListView->setProperty("showDropIndicator", QVariant(true)); - m_collectListView->setDragEnabled(true); - m_collectListView->setDragDropMode(QAbstractItemView::InternalMove); - m_collectListView->setDefaultDropAction(Qt::MoveAction); - m_collectListView->setMovement(QListView::Snap); - m_collectListView->setProperty("isWrapping", QVariant(true)); - m_collectListView->setWordWrap(true); - m_collectListView->setSelectionRectVisible(true); - m_collectListView->installEventFilter(this); - m_recentPage = new QWidget(); - m_recentPage->setFixedSize(QSize(324, 490)); - m_rightRecentLayout = new QVBoxLayout(m_recentPage); - m_rightRecentLayout->setContentsMargins(0, 20, 0, 0); - //最近视图 - m_recentListView = new ListView(m_recentPage); - m_recentListView->installEventFilter(this); - m_recentListView->setFixedSize(QSize(324, 470)); - m_rightStackedWidget->addWidget(m_collectPage); - m_rightStackedWidget->addWidget(m_recentPage); - m_verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - m_rightBottomHorizontalLayout = new QHBoxLayout(); - m_rightBottomHorizontalLayout->setSizeConstraint(QLayout::SetDefaultConstraint); - m_rightBottomHorizontalLayout->setContentsMargins(0, 0, 8, 0); - m_horizontalSpacer_2 = new QSpacerItem(332, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - m_horizontalSpacer_4 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Minimum); - m_powerOffButton = new QPushButton(m_centralwidget); - m_powerOffButton->setFixedSize(QSize(32, 32)); - m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); - m_powerOffButton->setIcon(QIcon(":/data/img/mainviewwidget/power.svg")); - m_powerOffButton->setIconSize(QSize(24, 24)); - m_powerOffButton->setFlat(true); - m_powerOffButton->installEventFilter(this); - m_letfTopSelectHorizontalLayout->addWidget(m_minSelectTextLabel); - m_letfTopSelectHorizontalLayout->addItem(m_horizontalSpacer); - m_letfTopSelectHorizontalLayout->addWidget(m_searchPushButton); - m_letfTopSelectHorizontalLayout->addItem(m_horizontalSpacer_4); - m_letfTopSelectHorizontalLayout->addWidget(m_minSelectButton); - m_letfTopSelectHorizontalLayout->addWidget(m_selectMenuButton); - m_leftTopSearchHorizontalLayout->addWidget(m_lineEdit); - m_leftTopSearchHorizontalLayout->addWidget(m_cancelSearchPushButton); - m_mainLeftVerticalLayout->addWidget(m_topStackedWidget); - m_mainLeftVerticalLayout->addWidget(m_leftStackedWidget); - m_mainRightVerticalLayout_1->addLayout(m_rightTopHorizontalLayout); - m_rightCollectLayout->addItem(m_verticalSpacer); - m_rightCollectLayout->addWidget(m_collectListView); - m_rightCollectLayout->addItem(m_verticalSpacer_2); - m_rightRecentLayout->addWidget(m_recentListView); - m_mainRightVerticalLayout_1->addWidget(m_rightStackedWidget); - m_rightBottomHorizontalLayout->addItem(m_horizontalSpacer_2); - m_rightBottomHorizontalLayout->addWidget(m_powerOffButton); - m_mainRightVerticalLayout->addLayout(m_mainRightVerticalLayout_1); - m_mainRightVerticalLayout->addLayout(m_rightBottomHorizontalLayout); - m_centerLayout->addWidget(m_viewWidget); - m_centerLayout->addLayout(m_mainRightVerticalLayout); - this->setCentralWidget(m_centralwidget); - m_minSelectTextLabel->setText(QApplication::translate("MainWindow", "All", nullptr)); - m_searchPushButton->setText(QString()); - m_minSelectButton->setText(QString()); - m_selectMenuButton->setText(QString()); - m_cancelSearchPushButton->setText(QString()); - m_collectPushButton->setText(QApplication::translate("MainWindow", "collection", nullptr)); - m_recentPushButton->setText(QApplication::translate("MainWindow", "recent", nullptr)); - m_minMaxChangeButton->setToolTip(QApplication::translate("MainWindow", "Max", nullptr)); - m_minMaxChangeButton->setText(QString()); - m_powerOffButton->setToolTip(QApplication::translate("MainWindow", "PowerOff", nullptr)); - m_powerOffButton->setText(QString()); - m_topStackedWidget->setCurrentIndex(0); - m_leftStackedWidget->setCurrentIndex(0); - m_minMaxChangeButton->setDefault(false); - m_rightStackedWidget->setCurrentIndex(0); - //设置tab切换顺序 - // setTabOrder(widget, searchPushButton); - setTabOrder(m_searchPushButton, m_minSelectButton); - setTabOrder(m_minSelectButton, m_selectMenuButton); - setTabOrder(m_selectMenuButton, m_collectPushButton); - setTabOrder(m_collectPushButton, m_recentPushButton); - setTabOrder(m_recentPushButton, m_minMaxChangeButton); - setTabOrder(m_minMaxChangeButton, m_powerOffButton); - m_softwareDbThread = new SoftwareDatabaseUpdateThread; - //获取软件商店类别信号 - QDBusConnection::sessionBus().connect("com.kylin.softwarecenter.getsearchresults", - "/com/kylin/softwarecenter/getsearchresults", - "com.kylin.getsearchresults", - "get_app_category_list_signal", - this, - SLOT(updateAppCategorySlot(QString)) - ); - initUi(); - m_functionBtnWid = new FunctionButtonWidget(m_minFuncPage); - m_functionBtnWid->hide(); - m_letterBtnWid = new LetterButtonWidget(m_minLetterPage); - m_letterBtnWid->hide(); - m_enterAnimation = new QPropertyAnimation; - m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation = new QPropertyAnimation; - m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - connect(this, &MainWindow::sendClassificationbtnList, m_functionBtnWid, &FunctionButtonWidget::recvClassificationBtnList); - connect(this, &MainWindow::sendLetterClassificationList, m_letterBtnWid, &LetterButtonWidget::recvLetterBtnList); - // connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal,this,&FunctionWidget::recvFunctionBtnSignal); - connect(m_minFuncListView, &ListView::sendAppClassificationBtnClicked, this, &MainWindow::appClassificationBtnClickedSlot); - connect(m_minLetterListView, &ListView::sendAppClassificationBtnClicked, this, &MainWindow::appClassificationBtnClickedSlot); - connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &MainWindow::animationFinishedSLot); - connect(m_enterAnimation, &QPropertyAnimation::finished, this, &MainWindow::animationFinishedSLot); - connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal, this, &MainWindow::recvFunctionBtnSignal); - connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal, this, &MainWindow::recvFunctionBtnSignal); - connect(m_functionBtnWid, &FunctionButtonWidget::sendResetFunctionPage, this, &MainWindow::resetFunctionPage); - connect(m_letterBtnWid, &LetterButtonWidget::sendResetLetterPage, this, &MainWindow::resetLetterPage); - m_searchAppThread = new SearchAppThread; - m_dbus = new DBus; - new MenuAdaptor(m_dbus); - m_fullWindow = new FullMainWindow; - QDBusConnection con = QDBusConnection::sessionBus(); - - if (!con.registerService("org.ukui.menu") || - !con.registerObject("/org/ukui/menu", m_dbus)) { - qDebug() << "error:" << con.lastError().message(); - } - - connect(m_dbus, &DBus::sendReloadSignal, this, [ = ] { - updateView(); - }); - connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { - if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) - { - QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); - - if (gsetting.keys().contains("winKeyRelease")) - if (gsetting.get("winKeyRelease").toBool()) { - return; - } - } - if (QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) - { - QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit()); - - if (gsetting.keys().contains("isrunning")) - if (gsetting.get("isrunning").toBool()) { - return; - } - } - - if (this->isVisible()) - { - this->hide(); - this->clearFocus(); - m_isFullScreen = false; - } else if (m_fullWindow->isVisible()) - { - m_fullWindow->hide(); - m_fullWindow->clearFocus(); - m_isFullScreen = true; - } else - { - if (!m_isFullScreen) { - this->show(); - this->raise(); - this->activateWindow(); -// m_collectPushButton->clicked(true); - on_collectPushButton_clicked(); - m_viewWidget->setFocus(); - } else { - m_fullWindow->show(); - // fullWindow->raise(); - m_fullWindow->activateWindow(); - } - } - }); - m_animationPage = new AnimationPage(); - m_maxAnimation = new QPropertyAnimation(m_animationPage, "geometry", this); - m_minAnimation = new QPropertyAnimation(m_animationPage, "geometry", this); - connect(m_maxAnimation, &QPropertyAnimation::finished, this, &MainWindow::maxAnimationFinished); - connect(m_minAnimation, &QPropertyAnimation::finished, this, &MainWindow::minAnimationFinished); - connect(m_lineEdit, &QLineEdit::textChanged, this, &MainWindow::searchAppSlot); - connect(this, &MainWindow::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword); - connect(m_searchAppThread, &SearchAppThread::sendSearchResult, this, &MainWindow::recvSearchResult); - connect(m_fullWindow, &FullMainWindow::showNormalWindow, this, &MainWindow::showNormalWindowSlot); - connect(m_fullWindow, &FullMainWindow::sendUpdateOtherView, this, &MainWindow::updateMinAllView); - connect(m_minSelectButton, &QToolButton::clicked, this, &MainWindow::on_minSelectButton_clicked); - connect(m_dropDownMenu, &MenuBox::triggered, this, &MainWindow::on_selectMenuButton_triggered); - connect(m_dropDownMenu, &MenuBox::sendMainWinActiveSignal, [ = ]() { - m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true) - .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); - }); - connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &MainWindow::on_powerOffButton_customContextMenuRequested); - connect(m_powerOffButton, &QPushButton::clicked, this, &MainWindow::on_powerOffButton_clicked); - connect(m_cancelSearchPushButton, &QPushButton::clicked, this, &MainWindow::on_cancelSearchPushButton_clicked); - connect(m_searchPushButton, &QPushButton::clicked, this, &MainWindow::on_searchPushButton_clicked); - connect(m_minMaxChangeButton, &QPushButton::clicked, this, &MainWindow::on_minMaxChangeButton_clicked); - QDBusConnection::sessionBus().connect(DBUS_NAME, DBUS_PATH, DBUS_INTERFACE, QString("PanelGeometryRefresh"), this, SLOT(primaryScreenChangeSlot())); - - //监听屏幕缩放 - if (QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) { - QGSettings *m_gsetting = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); - connect(m_gsetting, &QGSettings::changed, this, [ = ](const QString & key) { - if (key == "scalingFactor") { - repaintWidget(); - } - }); - } - - if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); - connect(gsetting, &QGSettings::changed, - this, &MainWindow::repaintWidget); - } - - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings("org.ukui.style", QByteArray(), this); - connect(gsetting, &QGSettings::changed, [ = ](QString key) { - if ("systemFont" == key || "systemFontSize" == key) { - m_leftTopSearchHorizontalLayout->removeWidget(m_lineEdit); - m_leftTopSearchHorizontalLayout->removeWidget(m_cancelSearchPushButton); - m_lineEdit->setParent(nullptr); - m_leftTopSearchHorizontalLayout->addWidget(m_lineEdit); - m_leftTopSearchHorizontalLayout->addWidget(m_cancelSearchPushButton); - m_lineEdit->setPlaceholderText("搜索应用"); - m_fullWindow->updateView(); - } - - if (key.contains(QString("styleName"))) { - changeStyle(); - } - }); - } - - //监控应用进程开启 - connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [ = ](WId id) { - ConvertWinidToDesktop reply; - QString desktopfp = reply.tranIdToDesktop(id); - - if (!desktopfp.isEmpty()) { - ViewOpenedSlot(desktopfp); - } - }); -} - -MainWindow::~MainWindow() -{ - closeDataBase("MainThread"); - - if (m_animationPage != nullptr) { - delete m_animationPage; - m_animationPage = nullptr; - } -} - -void MainWindow::initUi() -{ - qDebug() << "init UI"; - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); - this->setAttribute(Qt::WA_TranslucentBackground, true); - this->setAutoFillBackground(false); - this->setFocusPolicy(Qt::NoFocus); - m_modaldata = new GetModelData; - m_minAllListView->addData(m_modaldata->getMinAllData(), 0); - m_minFuncListView->addData(m_modaldata->getMinFuncData(), 1); - m_minLetterListView->addData(m_modaldata->getMinLetterData(), 2); - m_collectListView->addData(m_modaldata->getcollectData()); - m_recentListView->addData(m_modaldata->getRecentData(), -1); - m_dropDownMenu = new MenuBox(this); - m_dropDownMenu->setFixedSize(Style::DropMenuWidth, Style::DropMenuHeight); - m_allAction = new QAction(m_dropDownMenu); - m_letterAction = new QAction(m_dropDownMenu); - m_funcAction = new QAction(m_dropDownMenu); - m_allAction->setText(tr("All")); - m_allAction->setCheckable(true); - m_letterAction->setText(tr("Letter")); - m_letterAction->setCheckable(true); - m_funcAction->setText(tr("Function")); - m_funcAction->setCheckable(true); - m_dropDownMenu->addAction(m_allAction); - m_dropDownMenu->addAction(m_letterAction); - m_dropDownMenu->addAction(m_funcAction); - m_allAction->setChecked(true); - m_collectPushButton->setStyleSheet("color:#3790FA;"); -// m_collectPushButton->setStyleSheet("border: 1px solid red;"); - QColor textColor = this->palette().color(QPalette::Text); - QRgb rgbDefault = qRgb(textColor.red(), textColor.green(), textColor.blue()); - QString textColorDefault = "#" + QString::number(rgbDefault, 16); - m_recentPushButton->setStyleSheet(QString("color:%1;").arg(textColorDefault)); - QAction *action = new QAction(); - action->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-icon-search.svg", true)); - m_lineEdit->addAction(action, QLineEdit::LeadingPosition); - m_desktopWatcher = new DesktopWatcher(); - connect(m_minAllListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); - connect(m_minFuncListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); - connect(m_minLetterListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); - connect(m_minSearchResultListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); - connect(m_minAllListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); - connect(m_minFuncListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); - connect(m_minSearchResultListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); - connect(m_minLetterListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); - connect(m_collectListView, &RightListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); - connect(m_desktopWatcher, &DesktopWatcher::directoryChangedSignal, this, &MainWindow::updateView); - connect(m_desktopWatcher, &DesktopWatcher::updateRecentList, this, &MainWindow::updateRecentView); - connect(this, &MainWindow::sendStyleChangeSignal, m_viewWidget, &MainViewWidget::styleChangeSlot); - changeStyle(); -} - -void MainWindow::changeStyle() -{ - QPalette linePe; - QString buttonColorDefault; - QString buttonColorHover; - QString buttonColorPress; - QColor buttonColor; - - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.keys().contains(QString("styleName"))) { - if (gsetting.get("style-name").toString() == "ukui-light" - || gsetting.get("style-name").toString() == "ukui-default") { - g_curStyle = "ukui-light"; - buttonColorDefault = "rgba(16, 23, 29, 0.06)"; - buttonColorHover = "rgba(16, 23, 29, 0.12)"; - buttonColorPress = "rgba(16, 23, 29, 0.17)"; - m_windowColor.setNamedColor("#C7E9EEF2"); - Q_EMIT sendStyleChangeSignal("ukui-light"); - m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" - "QPushButton:hover {border-radius:16px; background: rgba(255, 255, 255, 0.4);}" - "QPushButton:pressed {border-radius:16px; background: rgba(255, 255, 255, 0.65);}"); - } else { - g_curStyle = "ukui-dark"; - buttonColor = linePe.color(QPalette::Light); - QRgb rgbDefault = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 25); - buttonColorDefault = "#" + QString::number(rgbDefault, 16); - QRgb rgbHover = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 50); - buttonColorHover = "#" + QString::number(rgbHover, 16); - QRgb rgbPress = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 75); - buttonColorPress = "#" + QString::number(rgbPress, 16); - m_windowColor.setNamedColor("#FF383838"); - Q_EMIT sendStyleChangeSignal("ukui-dark"); - m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" - "QPushButton:hover {border-radius:16px; background: rgba(255, 255, 255, 0.12);}" - "QPushButton:pressed {border-radius:16px; background: rgba(255, 255, 255, 0.25);}"); - } - } - } - - m_buttonStyle = QString("%1{border-radius:13px; background:" + buttonColorDefault + ";}" - "%1:hover {border-radius:13px; background:" + buttonColorHover + ";}" - "%1:pressed {border-radius:13px; background:" + buttonColorPress + ";}"); - m_searchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); - m_minSelectButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); - m_cancelSearchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); - m_searchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/full-search.svg", true)); - QAction *lineAction = m_lineEdit->actions().at(0); - - if (lineAction != nullptr) { - m_lineEdit->removeAction(lineAction); - delete lineAction; - lineAction = nullptr; - } - - QAction *action = new QAction(); - action->setIcon(getCurIcon(":/data/img/mainviewwidget/full-search.svg", true)); - m_lineEdit->addAction(action, QLineEdit::LeadingPosition); - m_cancelSearchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-close-2x.png", true)); - - if (m_leftStackedWidget->currentIndex() == 0) { - on_selectMenuButton_triggered(m_allAction); - } else if (m_leftStackedWidget->currentIndex() == 1) { - on_selectMenuButton_triggered(m_letterAction); - } else if (m_leftStackedWidget->currentIndex() == 2) { - on_selectMenuButton_triggered(m_funcAction); - } -} - -void MainWindow::paintEvent(QPaintEvent *event) -{ - double transparency = getTransparency(); - QRect rect = this->rect(); - QPainterPath path; - // rect.setTopLeft(QPoint(rect.x()+320,rect.y())); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(Qt::transparent); - qreal radius = 10; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter.setBrush(m_windowColor); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawPath(path); - // setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - QMainWindow::paintEvent(event); -} -/** - * 鼠标点击窗口外部事件 - */ -bool MainWindow::event(QEvent *event) -{ - if (QEvent::WindowDeactivate == event->type()) { //窗口停用 - if (QApplication::activeWindow() != this) { - qDebug() << " * 鼠标点击窗口外部事件"; - this->hide(); - } - } - - if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = (QKeyEvent *) event; - - if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || - keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || - keyEvent->key() == Qt::Key_Tab) { - if (!m_collectListView->hasFocus()) { - m_viewWidget->setFocus(); - - if (m_state == 0) { - m_minAllListView->setFocus(); - m_minAllListView->setCurrentIndex(m_minAllListView->model()->index(0, 0)); - } else if (m_state == 1) { - m_minLetterListView->setFocus(); - m_minLetterListView->setCurrentIndex(m_minLetterListView->model()->index(0, 0)); - } else { - m_minFuncListView->setFocus(); - m_minFuncListView->setCurrentIndex(m_minFuncListView->model()->index(0, 0)); - } - } - - return true; - } - - if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { - if (m_minSelectButton->hasFocus()) { - m_minSelectButton->click(); - } else if (m_selectMenuButton->hasFocus()) { - QApplication::postEvent(m_selectMenuButton, new QEvent(QEvent::MouseButtonPress)); - } - - if (m_lineEdit->hasFocus()) { - m_minSearchResultListView->setFocus(); - } else { - QWidget *current_focus_widget; - current_focus_widget = QWidget::focusWidget(); - QPushButton *le = qobject_cast(current_focus_widget); - - if (le != nullptr) { - le->clicked(); - } - } - } - } - - return QWidget::event(event); -} -void MainWindow::minAnimationFinished() -{ - this->show(); - this->raise(); - this->activateWindow(); - m_viewWidget->setFocus(); -// m_collectPushButton->clicked(true); - on_collectPushButton_clicked(); - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - m_animationPage->hide(); -} -void MainWindow::maxAnimationFinished() -{ - m_fullWindow->raise(); - m_fullWindow->showNormal(); - m_fullWindow->activateWindow(); - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - m_animationPage->hide(); -} -void MainWindow::resetLetterPage() -{ - m_minLetterListView->show(); - m_letterBtnWid->hide(); -} -void MainWindow::resetFunctionPage() -{ - m_minFuncListView->show(); - m_functionBtnWid->hide(); -} -/** - * 接收FunctionButtonWidget界面按钮信号 - */ -void MainWindow::recvFunctionBtnSignal(QString btnName) -{ - //此处需实现将功能为btnname的应用列表移动到applistWid界面最顶端 - if (m_state == 1) { - int index = m_modaldata->getLetterClassificationList().indexOf(btnName); - - if (index != -1) { - int row = m_modaldata->getLetterClassificationBtnRowList().at(index).toInt(); - m_minLetterListView->verticalScrollBar()->setValue(row); - m_leaveAnimation->setTargetObject(m_letterBtnWid); - m_enterAnimation->setTargetObject(m_minLetterListView); - } - } else { - int index = m_modaldata->getFuncClassificationList().indexOf(btnName); - - if (index != -1) { - int row = m_modaldata->getFuncClassificationBtnRowList().at(index).toInt(); - m_minFuncListView->verticalScrollBar()->setValue(row); - m_leaveAnimation->setTargetObject(m_functionBtnWid); - m_enterAnimation->setTargetObject(m_minFuncListView); - } - } - - m_leaveAnimation->setStartValue(QRect(0, 0, m_minFuncPage->width(), m_minFuncPage->height())); - m_leaveAnimation->setEndValue(QRect(0, 0, 0, 0)); - m_enterAnimation->setStartValue(QRect(0, 0, 0, 0)); - m_enterAnimation->setEndValue(QRect(0, 0, m_minFuncPage->width(), m_minFuncPage->height())); - m_leaveAnimation->setDuration(10); - m_enterAnimation->setDuration(100); - m_leaveAnimation->start(); - m_widgetState = 0; -} -void MainWindow::primaryScreenChangeSlot() -{ - repaintWidget(); -} -void MainWindow::appClassificationBtnClickedSlot() -{ - m_leaveAnimation->setStartValue(QRect(0, 0, Style::leftPageWidth, Style::leftPageHeight)); - m_leaveAnimation->setEndValue(QRect(0, 0, 0, 0)); - m_enterAnimation->setStartValue(QRect(-40, -40, Style::leftPageWidth + 80, Style::leftPageHeight + 80)); - m_enterAnimation->setEndValue(QRect(10, 0, Style::leftPageWidth - 20, Style::leftPageHeight - 60)); - m_leaveAnimation->setDuration(10); - m_enterAnimation->setDuration(100); - - if (m_state == 1) { - Q_EMIT sendLetterClassificationList(m_modaldata->getLetterClassificationList()); - m_leaveAnimation->setTargetObject(m_minLetterListView); - m_enterAnimation->setTargetObject(m_letterBtnWid); - } else if (m_state == 2) { - //加载FunctionButtonWidget界面 - Q_EMIT sendClassificationbtnList(); - m_leaveAnimation->setTargetObject(m_minFuncListView); - m_enterAnimation->setTargetObject(m_functionBtnWid); - } - - m_leaveAnimation->start(); - m_widgetState = 1; -} -void MainWindow::animationFinishedSLot() -{ - if (m_widgetState == 1) { - if (m_state == 1) { - m_minLetterListView->hide(); - m_letterBtnWid->show(); - } else { - m_minFuncListView->hide(); - m_functionBtnWid->show(); - } - - m_enterAnimation->start(); - m_widgetState = -1; - } - - if (m_widgetState == 0) { - if (m_state == 1) { - m_letterBtnWid->hide(); - m_minLetterListView->show(); - } else { - m_functionBtnWid->hide(); - m_minFuncListView->show(); - } - - m_enterAnimation->start(); - m_widgetState = -1; - } -} -void MainWindow::on_minSelectButton_clicked() -{ - if (m_leftStackedWidget->currentIndex() == 0) { - on_selectMenuButton_triggered(m_letterAction); - } else if (m_leftStackedWidget->currentIndex() == 1) { - on_selectMenuButton_triggered(m_funcAction); - } else if (m_leftStackedWidget->currentIndex() == 2) { - on_selectMenuButton_triggered(m_allAction); - } -} -bool MainWindow::eventFilter(QObject *target, QEvent *event) -{ - if (event->type() == QEvent::MouseButtonPress) { - if (target == m_recentPushButton) { - on_recentPushButton_clicked(); - return false; - } - - if (target == m_collectPushButton) { - on_collectPushButton_clicked(); - return false; - } - - if (target == m_selectMenuButton) { - m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/uparrow.svg", true) - .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); - m_dropDownMenu->raise(); - m_dropDownMenu->exec(this->mapToGlobal(QPoint(m_selectMenuButton->x() - 105, m_selectMenuButton->y() + 50))); - } - } - - if (event->type() == QEvent::KeyPress) { - QKeyEvent *ke = (QKeyEvent *)event; - - if (target == m_powerOffButton) { - if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Right) { - if (m_topStackedWidget->currentIndex() == 0) { - m_topStackedWidget->setFocus(); - } else { - m_lineEdit->setFocus(); - return true; - } - } - - if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { - return true; - } - } - - if (target == m_collectPushButton) { - if (ke->key() == Qt::Key_Down) { - if (m_rightStackedWidget->currentIndex() == 0) { - m_collectListView->setFocus(); - return true; - } else { - return true; - } - } - - if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { - return true; - } - } - - if (target == m_collectListView) { - if (ke->key() == Qt::Key_Tab) { - m_collectPushButton->setFocus(); - return true; - } - } - - if (target == m_recentListView) { - if (ke->key() == Qt::Key_Tab) { - m_recentPushButton->setFocus(); - return true; - } - - if (ke->key() == Qt::Key_Left || ke->key() == Qt::Key_Right) { - return true; - } - } - - if (target == m_minAllListView || target == m_minLetterListView || target == m_minFuncListView) { - if (ke->key() == Qt::Key_Tab) { - m_searchPushButton->setFocus(); - } - } - - if (target == m_cancelSearchPushButton) { - if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Right) { - m_collectPushButton->setFocus(); - return true; - } - - if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { - return true; - } - } - - if (target == m_minSearchResultListView) { - if (ke->key() == Qt::Key_Tab) { - m_lineEdit->setFocus(); - return true; - } - } - - if (target == m_minSelectButton) { - if (ke->key() == Qt::Key_Down) { - if (m_state == 0) { - m_minAllListView->setFocus(); - m_minAllListView->setCurrentIndex(m_minAllListView->model()->index(0, 0)); - } else if (m_state == 1) { - m_minLetterListView->setFocus(); - m_minLetterListView->setCurrentIndex(m_minLetterListView->model()->index(0, 0)); - } else { - m_minFuncListView->setFocus(); - m_minFuncListView->setCurrentIndex(m_minFuncListView->model()->index(0, 0)); - } - - return true; - } - - if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { - return true; - } - } - - if (target == m_recentPushButton) { - if (ke->key() == Qt::Key_Down) { - if (m_rightStackedWidget->currentIndex() == 1) { - m_recentListView->setFocus(); - return true; - } else { - return true; - } - } - - if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { - return true; - } - } - } - - return QWidget::eventFilter(target, event); -} -void MainWindow::keyPressEvent(QKeyEvent *e) -{ - if (e->type() == QEvent::KeyPress) { - if ((e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) || (e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z)) { - qDebug() << "void MainWindow::keyPressEvent(QKeyEvent *e)" << e->text(); - m_topStackedWidget->setCurrentIndex(1); - m_lineEdit->setFocus(); - m_lineEdit->setText(e->text()); - } - - if (e->key() == Qt::Key_Backspace) { - if (!m_lineEdit->text().isEmpty()) { - m_lineEdit->setText(""); - } else { - m_topStackedWidget->setCurrentIndex(0); - } - } - - if (e->key() == Qt::Key_Escape) { - this->hide(); - } - } -} -/** - * 进程开启监控槽函数 - */ -void MainWindow::ViewOpenedSlot(QString desktopfp) -{ - myDebug() << "open software:" << desktopfp; - QVector desktopfpVec = UkuiMenuInterface::desktopfpVector; - - if (desktopfpVec.contains(desktopfp)) { - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - QString dateTimeKey; - dateTimeKey.clear(); - - if (!desktopfn.isEmpty()) { - updateDataBaseTableTimes(desktopfn); - updateView(); - } - } -} -void MainWindow::recvSearchResult(QVector arg) -{ - m_searchAppThread->quit(); - QVector m_data; - m_data.clear(); - m_minSearchResultListView->addData(m_data, 3); - - Q_FOREACH (QStringList appinfo, arg) { - m_data.append(QStringList() << appinfo.at(0) << "1"); - } - - m_minSearchResultListView->updateData(m_data); -} -void MainWindow::searchAppSlot(QString arg) -{ - if (!arg.isEmpty()) { //切换至搜索模块 - m_leftStackedWidget->setCurrentIndex(3); - Q_EMIT sendSearchKeyword(arg); - m_searchAppThread->start(); - } else { - m_leftStackedWidget->setCurrentIndex(m_state); - } -} -void MainWindow::on_selectMenuButton_triggered(QAction *arg1) -{ - m_selectMenuButton->setPixmap(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true).pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); - - if (arg1 == m_allAction) { - m_leftStackedWidget->setCurrentIndex(0); - m_state = 0; - m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-all.svg", true)); - m_minSelectTextLabel->setText(tr("All")); - m_allAction->setChecked(true); - m_letterAction->setChecked(false); - m_funcAction->setChecked(false); - } else if (arg1 == m_letterAction) { - m_leftStackedWidget->setCurrentIndex(1); - m_state = 1; - m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-letter.svg", true)); - m_minSelectTextLabel->setText(tr("Letter")); - m_allAction->setChecked(false); - m_letterAction->setChecked(true); - m_funcAction->setChecked(false); - } else if (arg1 == m_funcAction) { - m_leftStackedWidget->setCurrentIndex(2); - m_state = 2; - m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-function.svg", true)); - m_minSelectTextLabel->setText(tr("Function")); - m_allAction->setChecked(false); - m_letterAction->setChecked(false); - m_funcAction->setChecked(true); - } -} -void MainWindow::updateCollectView() -{ - m_modaldata->loadDesktopVercor(); - m_collectListView->updateData(m_modaldata->getcollectData()); -} -void MainWindow::updateMinAllView() -{ - m_modaldata->loadDesktopVercor(); - m_minAllListView->updateData(m_modaldata->getMinAllData()); -} -void MainWindow::updateRecentView() -{ - m_modaldata->loadDesktopVercor(); - m_recentListView->updateData(m_modaldata->getRecentData()); -} -void MainWindow::updateView() -{ - m_modaldata->loadDesktopVercor(); - m_minAllListView->updateData(m_modaldata->getMinAllData()); - m_collectListView->updateData(m_modaldata->getcollectData()); - m_minFuncListView->updateData(m_modaldata->getMinFuncData()); - m_minLetterListView->updateData(m_modaldata->getMinLetterData()); - m_fullWindow->updateView(); -} -void MainWindow::updateAppCategorySlot(QString category) -{ - m_softwareDbThread->getDatabaseList(category); - m_softwareDbThread->start(); - connect(m_softwareDbThread, &SoftwareDatabaseUpdateThread::updateDatabaseSignal, this, &MainWindow::databaseThreadCloseSlot); -} -void MainWindow::databaseThreadCloseSlot() -{ - m_softwareDbThread->quit(); - updateView(); -} -void MainWindow::on_collectPushButton_clicked() -{ - m_rightStackedWidget->setCurrentIndex(0); - m_collectPushButton->setStyleSheet("color:#3790FA;"); - QColor textColor = this->palette().color(QPalette::Text); - QRgb rgbDefault = qRgb(textColor.red(), textColor.green(), textColor.blue()); - QString textColorDefault = "#" + QString::number(rgbDefault, 16); - m_recentPushButton->setStyleSheet(QString("color:%1;").arg(textColorDefault)); -} -void MainWindow::on_recentPushButton_clicked() -{ - m_rightStackedWidget->setCurrentIndex(1); - QColor textColor = this->palette().color(QPalette::Text); - QRgb rgbDefault = qRgb(textColor.red(), textColor.green(), textColor.blue()); - QString textColorDefault = "#" + QString::number(rgbDefault, 16); - m_collectPushButton->setStyleSheet(QString("color:%1").arg(textColorDefault)); -// m_collectPushButton->setStyleSheet("color:white"); - m_recentPushButton->setStyleSheet("color:#3790FA"); -} -void MainWindow::on_cancelSearchPushButton_clicked() -{ - m_topStackedWidget->setCurrentIndex(0); - m_lineEdit->clear(); -} -void MainWindow::on_searchPushButton_clicked() -{ - m_topStackedWidget->setCurrentIndex(1); - m_lineEdit->setFocus(); -} -void MainWindow::on_minMaxChangeButton_clicked() -{ - m_canHide = true; - m_isFullScreen = true; - m_animationPage->setGeometry(this->x(), this->y(), Style::minw, Style::minh); - m_animationPage->show(); - m_animationPage->raise(); - m_animationPage->repaint(); - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - m_maxAnimation->setEasingCurve(QEasingCurve::OutExpo); -// m_maxAnimation->setStartValue(QRect(Style::m_primaryScreenX, Style::m_primaryScreenY + Style::m_availableScreenHeight - Style::minh, Style::minw, Style::minh)); - m_maxAnimation->setStartValue(QRect(this->x(), this->y(), Style::minw, Style::minh)); - m_maxAnimation->setEndValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight)); - m_maxAnimation->setDuration(260); - m_maxAnimation->start(); - this->hide(); -} -void MainWindow::showWindow() -{ - if (m_isFullScreen) { - m_fullWindow->raise(); - m_fullWindow->showNormal(); - m_fullWindow->activateWindow(); - } else { - this->raise(); - this->showNormal(); - this->activateWindow(); -// m_collectPushButton->clicked(true); - on_collectPushButton_clicked(); - m_viewWidget->setFocus(); - } -} -void MainWindow::hideWindow() -{ - if (m_fullWindow->isVisible()) { - m_fullWindow->hide(); - this->clearFocus(); - m_isFullScreen = true; - } else { - this->hide(); - this->clearFocus(); - m_isFullScreen = false; - } -} -void MainWindow::repaintWidget() -{ - Style::initWidStyle(); - this->setMinimumSize(Style::minw, Style::minh); - int position = Style::m_panelPosition; - int x = Style::m_primaryScreenX; - int y = Style::m_primaryScreenY; - int width = Style::m_availableScreenWidth; - int height = Style::m_availableScreenHeight; - - if (position == 0) { - this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); - } else if (position == 1) { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } else if (position == 2) { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } else { - this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); - } - - m_fullWindow->move(x, y); - m_fullWindow->setFixedSize(width, height); - m_fullWindow->repaintWidget(); -} -void MainWindow::showNormalWindowSlot() -{ - myDebug() << "Style::m_availableScreenWidth" << Style::m_availableScreenWidth << "Style::m_availableScreenHeight" << Style::m_availableScreenHeight; - m_animationPage->setGeometry(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight); - m_animationPage->show(); - m_animationPage->raise(); - myDebug() << m_animationPage->rect(); - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - m_isFullScreen = false; - m_minAnimation->setEasingCurve(QEasingCurve::OutExpo); - m_minAnimation->setStartValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight)); - m_minAnimation->setEndValue(QRect(this->x(), this->y(), Style::minw, Style::minh)); - m_minAnimation->setDuration(260); - m_minAnimation->start(); - m_fullWindow->hide(); -} -void MainWindow::on_powerOffButton_clicked() -{ - QProcess::startDetached(QString("ukui-session-tools")); -} -void MainWindow::on_powerOffButton_customContextMenuRequested(const QPoint &pos) -{ - RightClickMenu m_otherMenu(this); - m_otherMenu.showShutdownMenu(this->mapToGlobal(m_centralwidget->rect().bottomRight())); - qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; -} diff --git a/src/UserInterface/mainwindow.h b/src/UserInterface/mainwindow.h deleted file mode 100644 index 4e55abb..0000000 --- a/src/UserInterface/mainwindow.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "ukuimenuinterface.h" -#include -#include -#include -#include -#include -#include -#include "convert_winid_to_desktop.h" -#include "style.h" -#include "main_view_widget.h" -#include "tabview_widget.h" -#include "dbus.h" -#include "dbus-adaptor.h" -#include "software_database_update_thread.h" -#include -#include -#include -#include -#include "listview.h" -#include "getmodeldata.h" -#include "full_mainwindow.h" -#include "desktop_watcher.h" -#include "function_button_widget.h" -#include "letter_button_widget.h" -#include "animationpage.h" - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - - void showWindow(); - - void hideWindow(); - -protected: - void initUi(); - /** - * @brief 处理外部点击事件和主窗口键盘控制 - * @param event - * @return - */ - bool event(QEvent *event); - /** - * @brief 主窗口圆角绘制 - * @param event - */ - void paintEvent(QPaintEvent *event); - - /** - * @brief 键盘字符输入处理 - * @param e - */ - void keyPressEvent(QKeyEvent *e); - - /** - * @brief searchAppSlot - * @param arg - */ - void searchAppSlot(QString arg); - - void recvSearchResult(QVector arg); - - void ViewOpenedSlot(QString desktopfp); - - bool eventFilter(QObject *target, QEvent *event); - - // void mouseReleaseEvent(QMouseEvent *event); - -public: -Q_SIGNALS: - void sendSearchKeyword(QString arg); - void sendClassificationbtnList(); - void sendLetterClassificationList(QStringList list); - void sendSetFullWindowItemHide(bool flag); - void sendStyleChangeSignal(QString style); - -public Q_SLOTS: - void updateCollectView(); - void on_minSelectButton_clicked(); - void updateMinAllView(); - void updateView(); - void recvFunctionBtnSignal(QString btnname); - void primaryScreenChangeSlot(); - void repaintWidget(); - void updateRecentView(); - void updateAppCategorySlot(QString category); - void databaseThreadCloseSlot(); - void resetLetterPage(); - void resetFunctionPage(); - void minAnimationFinished(); - void maxAnimationFinished(); - void changeStyle(); -private Q_SLOTS: - void on_selectMenuButton_triggered(QAction *arg1); - - void on_collectPushButton_clicked(); - - void on_recentPushButton_clicked(); - - void on_cancelSearchPushButton_clicked(); - - void on_searchPushButton_clicked(); - - void on_minMaxChangeButton_clicked(); - - void on_powerOffButton_clicked(); - - void on_powerOffButton_customContextMenuRequested(const QPoint &pos); - - void appClassificationBtnClickedSlot(); - - void animationFinishedSLot(); - - void showNormalWindowSlot(); - -private: - - QWidget *m_centralwidget = nullptr; - QHBoxLayout *m_centerLayout = nullptr; - MainViewWidget *m_viewWidget = nullptr; - QGridLayout *m_gridLayout = nullptr; - QVBoxLayout *m_mainLeftVerticalLayout = nullptr; - QStackedWidget *m_topStackedWidget = nullptr; - QWidget *m_minMenuPage = nullptr; - QHBoxLayout *m_letfTopSelectHorizontalLayout = nullptr; - QLabel *m_minSelectTextLabel = nullptr; - QSpacerItem *m_horizontalSpacer = nullptr; - QPushButton *m_searchPushButton = nullptr; - QPushButton *m_minSelectButton = nullptr; - QLabel *m_selectMenuButton = nullptr; - QWidget *m_minSearchPage = nullptr; - QHBoxLayout *m_leftTopSearchHorizontalLayout = nullptr; - QLineEdit *m_lineEdit = nullptr; - QPushButton *m_cancelSearchPushButton = nullptr; - QStackedWidget *m_leftStackedWidget = nullptr; - QWidget *m_minAllPage = nullptr; - ListView *m_minAllListView = nullptr; - QWidget *m_minLetterPage = nullptr; - ListView *m_minLetterListView = nullptr; - QWidget *m_minFuncPage = nullptr; - ListView *m_minFuncListView = nullptr; - QWidget *m_minSearchResultPage = nullptr; - ListView *m_minSearchResultListView = nullptr; - QVBoxLayout *m_mainRightVerticalLayout = nullptr; - QVBoxLayout *m_mainRightVerticalLayout_1 = nullptr; - QHBoxLayout *m_rightTopHorizontalLayout = nullptr; - QVBoxLayout *m_rightCollectLayout = nullptr; - QVBoxLayout *m_rightRecentLayout = nullptr; - QLabel *m_collectPushButton = nullptr; - QLabel *m_recentPushButton = nullptr; - QSpacerItem *m_horizontalSpacer_3 = nullptr; - QPushButton *m_minMaxChangeButton = nullptr; - QSpacerItem *m_verticalSpacer = nullptr; - QStackedWidget *m_rightStackedWidget = nullptr; - QWidget *m_collectPage = nullptr; - RightListView *m_collectListView = nullptr; - QWidget *m_recentPage = nullptr; - ListView *m_recentListView = nullptr; - QSpacerItem *m_verticalSpacer_2 = nullptr; - QHBoxLayout *m_rightBottomHorizontalLayout = nullptr; - QSpacerItem *m_horizontalSpacer_2 = nullptr; - QSpacerItem *m_horizontalSpacer_4 = nullptr; - QPushButton *m_powerOffButton = nullptr; - AnimationPage *m_animationPage = nullptr; - MenuBox *m_dropDownMenu = nullptr; - - bool m_canHide = true; - bool m_isFullScreen = false; - QString m_buttonStyle; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QPropertyAnimation *m_animation = nullptr; - bool m_winFlag = false; - DBus *m_dbus = nullptr; - GetModelData *m_modaldata = nullptr; - QAction *m_allAction = nullptr; - QAction *m_letterAction = nullptr; - QAction *m_funcAction = nullptr; - SearchAppThread *m_searchAppThread = nullptr; - int m_state = 0; - FullMainWindow *m_fullWindow = nullptr; - DesktopWatcher *m_desktopWatcher = nullptr; - QPropertyAnimation *m_enterAnimation = nullptr; - QPropertyAnimation *m_leaveAnimation = nullptr; - QPropertyAnimation *m_minAnimation = nullptr; - QPropertyAnimation *m_maxAnimation = nullptr; - int m_widgetState = -1; - FunctionButtonWidget *m_functionBtnWid = nullptr; - LetterButtonWidget *m_letterBtnWid = nullptr; - SoftwareDatabaseUpdateThread *m_softwareDbThread = nullptr; - QColor m_windowColor; -}; - -#endif // MAINWINDOW_H diff --git a/src/UserInterface/tabletwindow.cpp b/src/UserInterface/tabletwindow.cpp deleted file mode 100644 index aaaab25..0000000 --- a/src/UserInterface/tabletwindow.cpp +++ /dev/null @@ -1,1071 +0,0 @@ -/* - * 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 -#include -#include "style.h" -#include -#include -#include -#include "tabletlistview.h" -#include "xeventmonitor.h" -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -extern void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); -QT_END_NAMESPACE - -TabletWindow::TabletWindow(QWidget *parent) : - QWidget(parent), - m_scrollArea(new QScrollArea(this)), - m_scrollAreaWid(new ScrollAreaWid(this)), - m_backPixmap(new QPixmap), - m_leftWidget(new FunctionWidget(this)), - m_firstPageWidget(new QWidget(this)), - m_pagemanager(new PageManager()), - m_buttonBoxLayout(new QHBoxLayout), - m_buttonGroup(new QButtonGroup), - m_buttonWidget(new QWidget(this)), - m_appFileWatcher(new QFileSystemWatcher), - m_appListFileWatcher(new QFileSystemWatcher), - m_configFileWatcher(new QFileSystemWatcher), - m_directoryChangedThread(new TabletDirectoryChangedThread) - -{ - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - m_setting = new QSettings(path, QSettings::IniFormat); - setProperty("useStyleWindowManager", false); - initSize(); - initUi(); -} - -TabletWindow::~TabletWindow() -{ -} - -QVector TabletWindow::m_keyVector = QVector(); -QVector TabletWindow::m_keyValueVector = QVector(); - -void TabletWindow::initSize() -{ - Style::initWidStyle(); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - this->setFixedSize(Style::ScreenWidth, Style::ScreenHeight); - m_leftWidget->setFixedSize(Style::m_leftWidWidth, Style::CenterWindHeight); - m_leftWidget->layout()->setContentsMargins(Style::TimeWidgetLeft, Style::TimeWidgetTop, 0, 0); - m_scrollAreaWid->setFixedHeight(Style::CenterWindHeight); - m_scrollArea->setFixedSize(Style::ScreenWidth, Style::CenterWindHeight); - m_buttonWidget->setFixedSize(Style::OtherPageViewWidth, 30); -} - -void TabletWindow::initUi() -{ - this->setAttribute(Qt::WA_TranslucentBackground, true); - this->setAutoFillBackground(false); - this->setFocusPolicy(Qt::NoFocus); - m_animationPage.setParent(this); - m_firstPageWidget->installEventFilter(this); - m_buttonBoxLayout->setAlignment(Qt::AlignHCenter); - m_buttonBoxLayout->setSpacing(0); - m_buttonWidget->setLayout(m_buttonBoxLayout); - m_buttonBoxLayout->setContentsMargins(0, 0, 0, 0); - m_scrollAnimation = new QPropertyAnimation(&m_animationPage, "pos"); - connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &TabletWindow::animationFinishSlot); - m_scrollAnimation->setEasingCurve(QEasingCurve::OutExpo); - setOpacityEffect(0.7); - fileWatcher(); - initAppListWidget(); - setBackground(); - initStatusManager(); - initTransparency(); - registDbusService(); - ways(); - buttonWidgetShow(); - connect(m_leftWidget, &FunctionWidget::hideTabletWindow, this, &TabletWindow::recvHideMainWindowSlot); - - if (checkapplist()) { - directoryChangedSlot();//更新应用列表 - } - - initXEventMonitor(); -} - -void TabletWindow::initXEventMonitor() -{ - //pc下鼠标功能 - XEventMonitor::instance()->start(); - connect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), - this, SLOT(xkbEventsRelease(QString))); - connect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), - this, SLOT(xkbEventsPress(QString))); -} - -void TabletWindow::fileWatcher() -{ - m_configFileWatcher->addPath(QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"); - connect(m_configFileWatcher, &QFileSystemWatcher::fileChanged, this, [ = ]() { - m_configFileWatcher->addPath(QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"); - this->repaint(); - }); - m_appFileWatcher->addPaths(QStringList() << QString("/usr/share/applications") - << QString(QDir::homePath() + "/.local/share/applications/")); - connect(m_appFileWatcher, &QFileSystemWatcher::directoryChanged, this, &TabletWindow::directoryChangedSlot); - m_appListFileWatcher->addPath(QDir::homePath() + "/.config/ukui/desktop_applist"); - connect(m_appListFileWatcher, &QFileSystemWatcher::fileChanged, this, &TabletWindow::directoryChangedSlot); - connect(m_directoryChangedThread, &TabletDirectoryChangedThread::requestUpdateSignal, this, &TabletWindow::requestUpdateSlot); - connect(m_directoryChangedThread, &TabletDirectoryChangedThread::deleteAppSignal, this, &TabletWindow::requestDeleteAppSlot); -} - -void TabletWindow::initTransparency() -{ - //特效模式,此处Gsetting不明确,需进一步确认 - if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) { - m_bgEffect = new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); - - if (m_bgEffect->keys().contains("transparency")) { - setOpacityEffect(m_bgEffect->get("transparency").toReal()); - connect(m_bgEffect, &QGSettings::changed, [this](const QString & key) { - if (key == "effect") { - if (m_bgEffect->get("effect").toBool()) { - setOpacityEffect(m_bgEffect->get("transparency").toReal()); - } else { - setOpacityEffect(m_bgEffect->get("transparency").toReal()); - } - } - }); - } - } -} - -void TabletWindow::initStatusManager() -{ - m_usrInterface = new QDBusInterface("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - QDBusConnection::sessionBus()); - QDBusConnection::sessionBus().connect("com.kylin.statusmanager.interface", - "/", - "com.kylin.statusmanager.interface", - "mode_change_signal", - this, - SLOT(modelChanged(bool)) - ); -} - -void TabletWindow::setBackground() -{ - if (QGSettings::isSchemaInstalled(QString("org.mate.background").toLocal8Bit())) { - m_bgSetting = new QGSettings(QString("org.mate.background").toLocal8Bit()); - - if (m_bgSetting->keys().contains("pictureFilename")) { - m_bgPath = m_bgSetting->get("pictureFilename").toString(); - } - - if (m_bgSetting->keys().contains("pictureOptions")) { - m_bgOption = m_bgSetting->get("pictureOptions").toString(); - } - - connect(m_bgSetting, &QGSettings::changed, this, [ = ](const QString & key) { - if (key == "pictureFilename") { - //在每个屏幕上绘制背景 - if (m_bgSetting->keys().contains("pictureFilename") && - m_bgSetting->keys().contains("pictureOptions")) { - m_bgPath = m_bgSetting->get("pictureFilename").toString(); - m_bgOption = m_bgSetting->get("pictureOptions").toString(); - } - - ways();//壁纸显示方式 - } - - if (key == "pictureOptions") { - //在每个屏幕上绘制背景 - if (m_bgSetting->keys().contains("pictureOptions")) { - m_bgOption = m_bgSetting->get("pictureOptions").toString(); - } - - ways(); - } - }); - } -} - -void TabletWindow::registDbusService() -{ -// m_dbus = new DBus; -// new MenuAdaptor(m_dbus); -// QDBusConnection con = QDBusConnection::sessionBus(); -// if (!con.registerService("org.ukui.menu") || -// !con.registerObject("/org/ukui/menu", m_dbus)) { -// qDebug() << "error:" << con.lastError().message(); -// } -// connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { -// if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) -// { -// QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); -// if (gsetting.keys().contains("winKeyRelease")) { -// if (gsetting.get(QString("winKeyRelease")).toBool()) { -// return; -// } -// } -// } -// if (QApplication::activeWindow() == this) -// { -// myDebug() << "win键触发窗口隐藏事件"; -// this->hide(); -// } else -// { -// myDebug() << "win键触发窗口显示事件"; -// this->showPCMenu(); -// } -// }); -} - -bool TabletWindow::checkapplist() -{ - qDebug() << "MainWindow checkapplist"; - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - QSettings *setting = new QSettings(path, QSettings::IniFormat); - setting->beginGroup("application"); - QStringList keyList = setting->allKeys(); - setting->sync(); - setting->endGroup(); - delete setting; -// if(keyList.count() == UkuiMenuInterface::desktopfpVector.count()) -// { -// return false; -// }else - { - UkuiMenuInterface::desktopfpVector.clear(); - - for (int i = 0; i < keyList.count(); i++) { - QString tmp; - - if (UkuiMenuInterface::androidDesktopfnList.contains(keyList.at(i))) { - tmp = QString(QDir::homePath() + "/.local/share/applications/" + keyList.at(i)); - } else { - tmp = QString("%1%2").arg("/usr/share/applications/").arg(keyList.at(i)); - } - - UkuiMenuInterface::desktopfpVector.append(tmp); - } - - return true; - } -} - -bool TabletWindow::eventFilter(QObject *target, QEvent *event) -{ - if (target == m_scrollArea->viewport()) { - if (event->type() == QEvent::Wheel) { - event->ignore(); - return true; - } - } - - if (target == m_firstPageWidget || target == m_buttonWidget) { - if (event->type() == QEvent::MouseMove) { - return true; - } - } - - if (target == m_firstPageWidget) { - if (event->type() == QEvent::MouseButtonRelease) {//因触控拖拽会触发press事件,所以改为release时隐藏 - recvHideMainWindowSlot(); - } - } - - return false; -} - - -void TabletWindow::wheelEvent(QWheelEvent *e) -{ - if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { - if (qAbs(e->angleDelta().y()) >= qAbs(e->angleDelta().x())) { - if ((e->angleDelta().y() >= 120)) { - on_pageNumberChanged(false); - } else if ((e->angleDelta().y() <= -120)) { - on_pageNumberChanged(true); - } - } else if (qAbs(e->angleDelta().y()) < qAbs(e->angleDelta().x())) { - if ((e->angleDelta().x() >= 120)) { - on_pageNumberChanged(false); - } else if ((e->angleDelta().x() <= -120)) { - on_pageNumberChanged(true); - } - } - } - - e->ignore(); -} - -/** - * 初始化应用列表界面 - */ -void TabletWindow::initAppListWidget() -{ - m_layout = new QVBoxLayout(this); - m_layout->setContentsMargins(0, 0, 0, 0); - this->setLayout(m_layout); - m_firstPageLayout = new QHBoxLayout(); -// m_scrollAreaWid->setStyleSheet("border:0px; background:transparent;"); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setWidgetResizable(true); - m_scrollArea->setStyleSheet("border:0px; background:transparent;"); - m_scrollArea->setProperty("notUseSlideGesture", true); - m_scrollArea->setFocusPolicy(Qt::NoFocus); - m_scrollArea->viewport()->installEventFilter(this); - m_scrollAreaWidLayout = new QHBoxLayout(m_scrollAreaWid); - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); - m_scrollAreaWidLayout->setSpacing(0); - m_layout->addWidget(m_scrollArea); - m_layout->addWidget(m_buttonWidget); - m_buttonWidget->installEventFilter(this); - fillAppList(); -} - -void TabletWindow::modelChanged(bool value) -{ - if (value) { - ways(); - recvHideMainWindowSlot(); - } - - QEventLoop loop; - QTimer::singleShot(500, &loop, SLOT(quit())); - loop.exec(); - QDBusReply res = m_usrInterface->call("get_current_tabletmode"); - - if (!res) { - initSize(); - reloadWidget(); - } - -// reloadAppList(); - myDebug() << "平板模式切换"; -} - -//打开PC模式下的开始菜单 -void TabletWindow::showPCMenu() -{ -// this->setAttribute(Qt::WA_TranslucentBackground,true); -// this->setAttribute(Qt::WA_X11NetWmWindowTypeDesktop,false); -// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - this->show(); - this->raise(); - this->activateWindow(); - g_menuStatus = true; - menuStatusChange(); - myDebug() << "showMenu显示开始菜单"; -} - -//改变搜索框及工具栏透明度 -void TabletWindow::setOpacityEffect(const qreal &num) -{ - m_leftWidget->setDownOpacityEffect(num); //全局搜索框透明度 -} - -void TabletWindow::reloadAppList() -{ -// qDebug() << "void TabletWindow::reloadAppList()"; - QVector vector; - m_data.clear(); - m_keyVector.clear(); - m_keyValueVector.clear(); - vector = m_pagemanager->getAppPageVector(); - - if (!vector.at(0).isEmpty()) { - QLayoutItem *widItem = m_firstPageLayout->itemAt(1); - QWidget *wid = widItem->widget(); - TabletListView *m_listview = qobject_cast(wid); - m_listview->updateData(vector.at(0)); - } - - for (int i = 1; i < vector.size(); i++) { - if (!vector.at(i).isEmpty()) { - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(i); - QWidget *wid = widItem->widget(); - TabletListView *m_listview = qobject_cast(wid); - m_listview->updateData(vector.at(i)); - } - } -} - -void TabletWindow::reloadWidget() -{ - QLayoutItem *child; - - if (m_firstPageLayout->count() == 2) { - QLayoutItem *widItem = m_firstPageLayout->itemAt(1); - QWidget *wid = widItem->widget(); - TabletListView *m_listview = qobject_cast(wid); - delete m_listview; - m_firstPageLayout->removeWidget(m_leftWidget); - } - - while ((child = m_scrollAreaWidLayout->takeAt(1)) != 0) { - if (child->widget() != 0) { - delete child->widget(); - } - - delete child; - } - - m_isFirstPage = true; - fillAppList(); - buttonWidgetShow(); -} -/** - * 填充应用列表 - */ -void TabletWindow::fillAppList() -{ - QVector vector; - m_data.clear(); - m_keyVector.clear(); - m_keyValueVector.clear(); - vector = m_pagemanager->getAppPageVector(); - - for (int i = 0; i < vector.size(); i++) { - QStringList applist = vector.at(i); - - if (!applist.isEmpty()) { -// if (!m_isFirstPage) { -// insertAppList(QStringList()); -// } - insertAppList(applist); - } - } -} -bool TabletWindow::cmpApp(QString &arg_1, QString &arg_2) -{ - if (m_keyValueVector.at(m_keyVector.indexOf(arg_1)) < m_keyValueVector.at(m_keyVector.indexOf(arg_2))) { - return true; - } else { - return false; - } -} - -void TabletWindow::directoryChangedSlot() -{ - myDebug() << "监测到desktop文件变化"; - m_appFileWatcher->addPaths(QStringList() << QString("/usr/share/applications") - << QString(QDir::homePath() + "/.local/share/applications/")); - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - m_directoryChangedThread->start(); -} -void TabletWindow::requestUpdateSlot(QString desktopfp) -{ - m_directoryChangedThread->quit(); - reloadWidget(); - connect(m_appListFileWatcher, &QFileSystemWatcher::fileChanged, this, &TabletWindow::directoryChangedSlot); -} - -void TabletWindow::requestDeleteAppSlot() -{ - m_directoryChangedThread->quit(); - reloadWidget(); - connect(m_appListFileWatcher, &QFileSystemWatcher::fileChanged, this, &TabletWindow::directoryChangedSlot); -} - -void TabletWindow::on_pageNumberChanged(bool nextPage) -{ -// qDebug() << "void TabletWindow::on_pageNumberChanged(bool nextPage)"; -// if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { - int preNum = m_curPageNum; - - if (nextPage) { - m_curPageNum++; - - if (m_curPageNum > (m_scrollAreaWidLayout->count() - 1)) { - m_curPageNum = (m_scrollAreaWidLayout->count() - 1); - return; - } - } else { - m_curPageNum--; - - if (m_curPageNum < 0) { - m_curPageNum = 0; - return; - } - } - - m_scrollArea->horizontalScrollBar()->setMaximum(m_scrollAreaWidLayout->count() * 1920); - btnGroupClickedSlot(preNum, m_curPageNum); - pageNumberChanged(m_curPageNum + 1); -// } -} - -bool TabletWindow::event(QEvent *event) -{ - if (event->type() == QEvent::ActivationChange) - //if(QEvent::WindowDeactivate == event->type())//窗口停用 - { - if (QApplication::activeWindow() != this) { - myDebug() << " * 鼠标点击窗口外部事件"; - this->hide(); - g_menuStatus = false; - menuStatusChange(); - } - } - - if (event->type() == QEvent::MouseMove) { - qDebug() << "bool TabletWindow::event ( QEvent * event ) 鼠标移动"; - //return true; - event->ignore(); - } - - if (event->type() == QEvent::MouseButtonPress) { - if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { - this->hide(); - g_menuStatus = false; - myDebug() << "鼠标点击事件触发隐藏"; - } - } - - return QWidget::event(event); -} - -void TabletWindow::insertAppList(QStringList desktopfplist) -{ - TabletListView *listview = nullptr; - - if (m_isFirstPage) { - listview = new TabletListView(this, 0); - m_firstPageLayout->setSpacing(0); - m_firstPageLayout->setContentsMargins(0, 0, 0, 0); - m_firstPageWidget->setLayout(m_firstPageLayout); - m_firstPageLayout->addWidget(m_leftWidget); - listview->setFixedSize(Style::FirsPageViewWidth, Style::CenterWindHeight); - m_firstPageLayout->addWidget(listview); - m_scrollAreaWidLayout->addWidget(m_firstPageWidget); - listview->setGridSize(QSize(Style::TabletItemSizeWidthFirst, Style::AppListItemSizeHeight)); - m_isFirstPage = false; - } else { - listview = new TabletListView(this, 1); - listview->setFixedSize(Style::OtherPageViewWidth, Style::CenterWindHeight); - listview->setGridSize(QSize(Style::TabletItemSizeWidthOther, Style::AppListItemSizeHeight)); - m_scrollAreaWidLayout->addWidget(listview); - } - -// //修复异常黑框问题 -// connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ -// listview->repaint(listview->rect()); -// }); - connect(listview, &TabletListView::pagenumchanged, this, &TabletWindow::on_pageNumberChanged); - listview->setProperty("notUseSlideGesture", true); - m_data.clear(); - - for (int i = 0; i < desktopfplist.count(); i++) { - m_data.append(desktopfplist.at(i)); - } - - listview->addData(m_data); - connect(listview, &TabletListView::sendItemClickedSignal, this, &TabletWindow::execApplication); - connect(listview, &TabletListView::sendHideMainWindowSignal, this, &TabletWindow::recvHideMainWindowSlot); - connect(listview, &TabletListView::sendUpdateAppListSignal, this, &TabletWindow::reloadAppList); -} - -//void TabletWindow::recvStartMenuSlot() -//{ -// QDBusReply res = usrInterface->call("get_current_tabletmode"); - -// if (this->isVisible()) { -// if (!res) { //平板模式 下禁止wi隐藏菜单 -// this->hide(); -// } -// } else { -// if (!res) { //平板模式 下禁止win隐藏菜单 -// this->showPCMenu(); -// } -// } -//} - -/** - * 执行应用程序 - */ -void TabletWindow::execApplication(QString desktopfp) -{ -// Q_EMIT sendHideMainWindowSignal(); -// execApp(desktopfp); - QString str; - //打开文件.desktop - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); - //取出value值 - QString execnamestr = QString::fromLocal8Bit(name); - str = execnamestr; - //qDebug()<<"2 exec"<beginGroup("application"); - QString desktopfp1 = str; - //判断 - bool bo = m_disableAppSet->contains(desktopfp1.toLocal8Bit().data()); // iskey - bool bo1 = m_disableAppSet->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool(); //isvalue - m_disableAppSet->endGroup(); - - if (bo && bo1 == false) { //都存在//存在并且为false,从filepathlist中去掉 - //qDebug()<<"bool"<toImage(); - //qt_blurImage(&painter,srcImg,2,true,false);//top 27000//150 - QGraphicsBlurEffect *blur = new QGraphicsBlurEffect; - blur->setBlurRadius(70); - QImage result = applyEffectToImage(srcImg, blur, 70); - qt_blurImage(&painter, result, 1, false, false); //top 27000//150 - painter.end(); - return pixmap; -} - -void TabletWindow::pageNumberChanged(int pageNum) -{ - if (m_pagemanager->getAppPageVector().size() != 1) { - for (int page = 1; page <= m_pagemanager->getAppPageVector().size(); page++) { - if (pageNum == page) { - m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/selected.svg);}" - "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/selected.svg);}" - "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/selected.svg);}"); - } else { - m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/select.svg);}" - "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/select.svg);}" - "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/select.svg);}"); - } - } - } -} - -void TabletWindow::ways() -{ - m_pixmap = QPixmap(m_bgPath); - - if (m_bgOption == "zoom" || m_bgOption == "" || m_bgOption == NULL) { - m_bgOption = "scaled"; - } - - if (m_bgOption == "centered") { //居中 - m_backPixmap->load(m_bgPath); - } else if (m_bgOption == "stretched") { //拉伸 - m_pixmap = m_pixmap.scaled(this->size()); - m_backPixmap = &m_pixmap; - } else if (m_bgOption == "scaled") { //填充 - m_backPixmap->load(m_bgPath); - } else if (m_bgOption == "wallpaper") { //平铺 - m_backPixmap->load(m_bgPath); - } else { - m_pixmap = m_pixmap.scaled(this->size()); - m_backPixmap = &m_pixmap; - } - - m_backPixmap = blurPixmap(m_backPixmap); -} - -/** - * @brief FullBackgroundWidget::getPaddingPixmap - * @param pixmap 需要填充的图像 - * @param width 容器宽度 - * @param height 容器高度 - * @return - */ -QPixmap TabletWindow::getPaddingPixmap(QPixmap pixmap, int width, int height) -{ - if (pixmap.isNull() || pixmap.width() == 0 || pixmap.height() == 0) { - return QPixmap(); - } - - bool useHeight; - float scaled = 0.0; - QPixmap scaledPixmap; - QPixmap paddingPixmap; - qint64 rw = qint64(height) * qint64(pixmap.width()) / qint64(pixmap.height()); - useHeight = (rw >= width); - - if (useHeight) { - scaled = float(height) / float(pixmap.height()); - scaledPixmap = pixmap.scaled(pixmap.width() * scaled, height); - paddingPixmap = scaledPixmap.copy((pixmap.width() * scaled - width) / 2, 0, width, height); - } else { - scaled = float(width) / float(pixmap.width()); - scaledPixmap = pixmap.scaled(width, pixmap.height() * scaled); - paddingPixmap = scaledPixmap.copy(0, (pixmap.height() * scaled - height) / 2, width, height); - } - - return paddingPixmap; -} - -void TabletWindow::backgroundPic() //const QString &bgPath,QRect rect -{ -// qDebug()<<"5、绘制背景"; - QPainter painter(this); - - if (/*hideBackground*/false) { - QColor cor; - cor = "#252729"; - painter.setBrush(cor); - painter.drawRect(this->rect()); - } else if (m_bgOption == "zoom" || m_bgOption == "" || m_bgOption == NULL) { - m_bgOption = "scaled"; - } else if (m_bgOption == "centered") { - QColor cor; - cor = "#000000"; - painter.setBrush(cor); - painter.drawRect(this->rect()); - painter.drawPixmap(this->width() / 2 - m_backPixmap->width() / 2, - this->height() / 2 - m_backPixmap->height() / 2, - *m_backPixmap); - } else if (m_bgOption == "stretched") { - //qDebug() << "---------" << "stretched" << "----------"; - painter.drawPixmap(this->rect(), *m_backPixmap); - } else if (m_bgOption == "scaled") { - painter.setPen(QColor(0, 0, 0, 64));//蒙层效果 - painter.setBrush(QColor(0, 0, 0, 64)); - painter.drawPixmap(this->geometry(), getPaddingPixmap(*m_backPixmap, this->size().width(), this->size().height())); - painter.drawRect(this->geometry()); - } else if (m_bgOption == "wallpaper") { - //qDebug() << "---------" << "wallpaper" << "----------"; - int drawedWidth = 0; - int drawedHeight = 0; - - while (1) { - drawedWidth = 0; - - while (1) { - painter.drawPixmap(drawedWidth, drawedHeight, *m_backPixmap); - drawedWidth += m_backPixmap->width(); - - if (drawedWidth >= this->width()) { - break; - } - } - - drawedHeight += m_backPixmap->height(); - - if (drawedHeight >= this->height()) { - break; - } - } - } else { - painter.drawPixmap(this->rect(), *m_backPixmap); - } -} - -void TabletWindow::recvHideMainWindowSlot() -{ -// this->setAttribute(Qt::WA_TranslucentBackground,true); -// this->setAttribute(Qt::WA_X11NetWmWindowTypeDesktop,false); -// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); - this->hide(); - g_menuStatus = false; - myDebug() << "信号触发隐藏窗口"; -} - -void TabletWindow::btnGroupClickedSlot(int prePageNum, int pageNum) -{ - qDebug() << "void TabletWindow::btnGroupClickedSlot(int pageNum)"; - int durationTime = 200; - - if (prePageNum == pageNum) { - durationTime = 1; - } - - if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { - QPixmap p = m_scrollAreaWid->grab(m_scrollAreaWid->rect()); - m_animationPage.setFixedSize(m_scrollAreaWid->size()); - m_animationPage.setPixmap(p); - m_beginPos = m_scrollArea->horizontalScrollBar()->sliderPosition(); - m_endPos = m_scrollAreaWidLayout->itemAt(pageNum)->widget()->x(); - m_scrollArea->horizontalScrollBar()->setValue(m_endPos); - m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAnimation->setDuration(durationTime); - m_scrollAnimation->setStartValue(QPoint(-m_beginPos, m_scrollArea->y())); - m_scrollAnimation->setEndValue(QPoint(-m_endPos, m_scrollArea->y())); - m_scrollAnimation->start(); - m_animationPage.show(); - m_animationPage.raise(); - m_scrollAreaWid->hide(); - } -} - -void TabletWindow::buttonWidgetShow() -{ - //qDebug()<<"4、buttonWidgetShow"; - delete m_buttonBoxLayout; - m_buttonBoxLayout = new QHBoxLayout; - m_buttonWidget->setLayout(m_buttonBoxLayout); - m_buttonBoxLayout->setAlignment(Qt::AlignHCenter); - m_buttonBoxLayout->setSpacing(16); - m_buttonBoxLayout->setContentsMargins(0, 0, 0, 0); - - for (auto button : m_buttonGroup->buttons()) { - m_buttonGroup->removeButton(button); - button->deleteLater(); - } - - QDBusReply var = m_usrInterface->call("get_current_tabletmode"); - -// res = var; - for (int page = 1; page <= m_pagemanager->getAppPageVector().size(); page++) { - m_pageButton = new QPushButton; - m_pageButton->setFocusPolicy(Qt::NoFocus); - m_pageButton->setFixedSize(24, 24); - m_pageButton->setStyleSheet("QPushButton{border-image: url(:/data/img/mainviewwidget/select.svg);}" - "QPushButton:hover{border-image: url(:/img/mainviewwidget/select.svg);}" - "QPushButton:pressed{border-image:url(:/img/mainviewwidget/select.svg);}"); - - if (page == 1) { - m_pageButton->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/selected.svg);}" - "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/selected.svg);}" - "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/selected.svg);}"); - } - - m_buttonBoxLayout->addWidget(m_pageButton); - m_buttonGroup->addButton(m_pageButton, page); - } - - btnGroupClickedSlot(0, 0); - m_curPageNum = 0; - connect(m_buttonGroup, QOverload::of(&QButtonGroup::buttonClicked), this, &TabletWindow::buttonClicked); -} - -void TabletWindow::buttonClicked(QAbstractButton *button) -{ - if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { - int idd = m_buttonGroup->id(button); - int preNum = m_curPageNum; - Style::nowpagenum = idd; - -// QDBusReply res = usrInterface->call("get_current_tabletmode"); - for (int page = 1; page <= m_pagemanager->getAppPageVector().size(); page++) { - if (idd == page) { - m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/selected.svg);}" - "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/selected.svg);}" - "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/selected.svg);}"); - } else { - m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/select.svg);}" - "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/select.svg);}" - "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/select.svg);}"); - } - } - - m_curPageNum = idd - 1; - btnGroupClickedSlot(preNum, m_curPageNum); - } -} - -void TabletWindow::animationFinishSlot() -{ - m_scrollAreaWid->show(); - m_scrollAreaWid->raise(); - m_animationPage.hide(); -// if(m_scrollArea->horizontalScrollBar()->value()==m_endPos || -// m_scrollArea->horizontalScrollBar()->value()==m_scrollArea->horizontalScrollBar()->maximum()) -// { -// m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); -// } -} - -void TabletWindow::animationValueChangedSlot(const QVariant &value) -{ - Q_UNUSED(value); - - if (sender() != m_scrollAnimation) { - return; - } - - QPropertyAnimation *ani = qobject_cast(sender()); - - if (m_endPos != ani->endValue()) { - ani->setEndValue(m_endPos); - } -} - -void TabletWindow::xkbEventsPress(const QString &keycode) -{ - myDebug() << keycode; - QString KeyName; - - if (keycode.length() >= 8) { - KeyName = keycode.left(8); - } - - if (KeyName.compare("Super_L+") == 0) {//组合按键 - m_winFlag = true; - } - - if (keycode == "Super_L") {//win键 - m_winFlag = false; - } -} - -void TabletWindow::xkbEventsRelease(const QString &keycode) -{ - myDebug() << "触发按键释放" << keycode; - QString KeyName; - - if (keycode.length() >= 8) { - KeyName = keycode.left(8); - } - - if (KeyName.compare("Super_L+") == 0 || //组合释放 - (m_winFlag && keycode == "Super_L")) { //组合按下单独释放 - return; - } - - QDBusReply res = m_usrInterface->call("get_current_tabletmode"); - - if (m_usrInterface && res) { - qWarning() << QTime::currentTime() - << " Now is tablet mode, and it is forbidden to hide or show the menu after 'win'.'Esc'"; - return; - } - - /**以下代码是非平板模式需要处理的键盘按键**/ - if ((keycode == "Super_L") || (keycode == "Super_R")) { - qDebug() << "(ActiveWindow, SelfWindow):(" << QApplication::activeWindow() << ", " << this << ")"; - - if (QApplication::activeWindow() == this) { -// if (m_CommonUseWidget->m_listView->isDraging()) { -// qWarning() << "Icon is been draging"; -// } - qDebug() << "win键触发窗口隐藏事件"; - this->hide(); - g_menuStatus = false; - } else { - qDebug() << "win键触发窗口显示事件"; - this->showPCMenu(); - g_menuStatus = true; - } - } - - if (keycode == "Escape") { - this->hide(); - } -} - -void TabletWindow::winKeyReleaseSlot(const QString &key) -{ - if (key == "winKeyRelease" || key == "win-key-release") { - if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); - - if (gsetting.keys().contains("winKeyRelease")) { - if (gsetting.get(QString("winKeyRelease")).toBool()) { - disconnect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), - this, SLOT(xkbEventsRelease(QString))); - disconnect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), - this, SLOT(xkbEventsPress(QString))); - } else { - connect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), - this, SLOT(xkbEventsRelease(QString))); - connect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), - this, SLOT(xkbEventsPress(QString))); - } - } - } - } -} - -void TabletWindow::menuStatusChange() -{ - QDBusMessage message = QDBusMessage::createSignal("/com/ukui/menu", "com.ukui.menu", "statusChangeSignal"); - //给信号赋值 - message << g_menuStatus; - //发射 - QDBusConnection::sessionBus().send(message); -} diff --git a/src/UserInterface/tabletwindow.h b/src/UserInterface/tabletwindow.h deleted file mode 100644 index 7b6a03d..0000000 --- a/src/UserInterface/tabletwindow.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ukuimenuinterface.h" -#include "scrollarea.h" -#include "splitbar_frame.h" -#include "fulllistview.h" -#include "classify_btn_scrollarea.h" -#include "tool_button.h" -#include "function_classify_button.h" -#include "style.h" -#include -#include "function_Widget.h" -#include "tabletlistview.h" -#include "pagemanager.h" -#include "tablet_directorychanged_thread.h" - -class TabletWindow : public QWidget -{ - Q_OBJECT - -public: - explicit TabletWindow(QWidget *parent = nullptr); - - ~TabletWindow(); - - void repaintWidget(); - - void showPCMenu(); //打开pc的开始菜单 - - static bool cmpApp(QString &arg_1, QString &arg_2); - - void setOpacityEffect(const qreal &num); - -private: - /*Application list interface*/ - QScrollArea *m_scrollArea = nullptr; - ScrollAreaWid *m_scrollAreaWid = nullptr; - QHBoxLayout *m_scrollAreaWidLayout = nullptr; - QStringList m_data; - /*Function classification list interface*/ - QWidget *m_iconListWid = nullptr; - ClassifyBtnScrollArea *m_iconListScrollArea = nullptr; - ClassifyBtnScrollAreaWid *m_iconListScrollAreaWid = nullptr; - QVBoxLayout *m_iconListWidLayout = nullptr; - QList m_buttonList; - QButtonGroup *m_btnGroup = nullptr; - QSpacerItem *m_topSpacerItem = nullptr; - QSpacerItem *m_bottomSpacerItem = nullptr; - - /*Animation*/ - QPropertyAnimation *m_scrollAnimation = nullptr;//Application list animation - int m_beginPos = 0;//Application list scrollbar starting value - int m_endPos = 0;//Application list scrollbar end value - int m_index = 0; - int m_scrollAreaWidHeight = 0; - - int m_width; - int m_height; - - QString m_bgPath; - QString m_bgOption; - QPixmap m_pixmap; - - QPixmap *m_backPixmap = nullptr; - QGSettings *m_bgSetting = nullptr; - QGSettings *m_bgEffect = nullptr; - - QDBusInterface *m_usrInterface = nullptr; - bool m_winFlag = false; - int m_curPageNum = 0; - QVBoxLayout *m_layout = nullptr; - FunctionWidget *m_leftWidget = nullptr; - bool m_isFirstPage = true; - QWidget *m_firstPageWidget = nullptr; - static QVector m_keyVector; - static QVector m_keyValueVector; - QSettings *m_setting = nullptr; - PageManager *m_pagemanager = nullptr; - TabletListView *m_listView = nullptr; - QHBoxLayout *m_firstPageLayout = nullptr; - QHBoxLayout *m_buttonBoxLayout = nullptr; - QButtonGroup *m_buttonGroup = nullptr; - QWidget *m_buttonWidget = nullptr; - QPushButton *m_pageButton = nullptr; - - QFileSystemWatcher *m_appFileWatcher = nullptr; - QFileSystemWatcher *m_appListFileWatcher = nullptr; - QFileSystemWatcher *m_configFileWatcher = nullptr; - TabletDirectoryChangedThread *m_directoryChangedThread = nullptr; - QSettings *m_disableAppSet = nullptr; - - QLabel m_animationPage; -// DBus *m_dbus = nullptr; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief initSize - */ - void initSize(); - - void fileWatcher(); - - void setBackground(); - - void registDbusService(); - - void initTransparency(); - - void initStatusManager(); - - void initXEventMonitor(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppList(); - /** - * @brief Insert application list - * @param desktopfplist: Desktop file path list - */ - void insertAppList(QStringList desktopfplist); - - void paintEvent(QPaintEvent *event); - - void backgroundPic(); - - QPixmap *blurPixmap(QPixmap *pixmap); - - void ways(); - - QPixmap getPaddingPixmap(QPixmap pixmap, int width, int height); - - QImage applyEffectToImage(QImage src, QGraphicsEffect *effect, int extent = 0); - - void buttonWidgetShow(); - - bool event(QEvent *event); - - void wheelEvent(QWheelEvent *e); - - bool eventFilter(QObject *target, QEvent *event); - - bool checkapplist(); - - void menuStatusChange(); - -public Q_SLOTS: - /** - * @brief Open the application - * @param arg: Desktop file path - */ - void execApplication(QString desktopfp); - /** - * @brief Respond to button click - * @param btn: QButtonGroup button - */ - void btnGroupClickedSlot(int prePageNum, int pageNum); - - void reloadAppList(); - - /** - * @brief Respond to application list animation finish - */ - void animationFinishSlot(); - /** - * @brief Respond to application list animation current value change - * @param value: animation current value - */ - void animationValueChangedSlot(const QVariant &value); - - void recvHideMainWindowSlot(); - -// void recvStartMenuSlot(); - - void modelChanged(bool value); - - void xkbEventsPress(const QString &keycode); - void xkbEventsRelease(const QString &keycode); - void winKeyReleaseSlot(const QString &key); - void on_pageNumberChanged(bool nextPage); - void buttonClicked(QAbstractButton *m_pageButton); - void pageNumberChanged(int pageNum); - void requestDeleteAppSlot(); - void requestUpdateSlot(QString desktopfp); - void directoryChangedSlot(); - void reloadWidget(); -Q_SIGNALS: - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); - - void setFocusToSideWin(); - - void selectFirstItem(); - - void changeScrollValue(int value, int maximumValue); - - void pagenumchanged(int pageNum); //翻页信号 - - void sendDirectoryPath(QString arg); - - void UpdateSignal(); -}; - -#endif // FULLFUNCTIONWIDGET_H diff --git a/src/UserInterface/userinterface.pri b/src/UserInterface/userinterface.pri deleted file mode 100644 index 1bc7ffe..0000000 --- a/src/UserInterface/userinterface.pri +++ /dev/null @@ -1,82 +0,0 @@ -INCLUDEPATH += \ - $$PWD \ - $$PWD/Button \ - $$PWD/ListView \ - $$PWD/Other \ - $$PWD/RightClickMenu \ - $$PWD/ViewItem \ - $$PWD/Widget - -HEADERS += \ - $$PWD/Button/function_classify_button.h \ - $$PWD/Button/letter_classify_button.h \ - $$PWD/Button/tool_button.h \ - $$PWD/ListView/fulllistview.h \ - $$PWD/ListView/klistview.h \ - $$PWD/ListView/listview.h \ - $$PWD/ListView/rightlistview.h \ - $$PWD/ListView/tabletlistview.h \ - $$PWD/Other/classify_btn_scrollarea.h \ - $$PWD/Other/lettertooltip.h \ - $$PWD/Other/scrollarea.h \ - $$PWD/RightClickMenu/menubox.h \ - $$PWD/RightClickMenu/rightclickmenu.h \ - $$PWD/RightClickMenu/tabletrightclickmenu.h \ - $$PWD/ViewItem/full_item_delegate.h \ - $$PWD/ViewItem/itemdelegate.h \ - $$PWD/ViewItem/kitemdelegate.h \ - $$PWD/ViewItem/recent_item_delegate.h \ - $$PWD/ViewItem/right_item_delegate.h \ - $$PWD/ViewItem/tablet_full_itemdelegate.h \ - $$PWD/Widget/animationpage.h \ - $$PWD/Widget/full_commonuse_widget.h \ - $$PWD/Widget/full_function_widget.h \ - $$PWD/Widget/full_letter_widget.h \ - $$PWD/Widget/full_searchresult_widget.h \ - $$PWD/Widget/function_Widget.h \ - $$PWD/Widget/function_button_widget.h \ - $$PWD/Widget/letter_button_widget.h \ - $$PWD/Widget/main_view_widget.h \ - $$PWD/Widget/plugin_widget.h \ - $$PWD/Widget/splitbar_frame.h \ - $$PWD/Widget/tabview_widget.h \ - $$PWD/full_mainwindow.h \ - $$PWD/mainwindow.h \ - $$PWD/tabletwindow.h - -SOURCES += \ - $$PWD/Button/function_classify_button.cpp \ - $$PWD/Button/letter_classify_button.cpp \ - $$PWD/Button/tool_button.cpp \ - $$PWD/ListView/fulllistview.cpp \ - $$PWD/ListView/klistview.cpp \ - $$PWD/ListView/listview.cpp \ - $$PWD/ListView/rightlistview.cpp \ - $$PWD/ListView/tabletlistview.cpp \ - $$PWD/Other/classify_btn_scrollarea.cpp \ - $$PWD/Other/lettertooltip.cpp \ - $$PWD/Other/scrollarea.cpp \ - $$PWD/RightClickMenu/menubox.cpp \ - $$PWD/RightClickMenu/rightclickmenu.cpp \ - $$PWD/RightClickMenu/tabletrightclickmenu.cpp \ - $$PWD/ViewItem/full_item_delegate.cpp \ - $$PWD/ViewItem/itemdelegate.cpp \ - $$PWD/ViewItem/kitemdelegate.cpp \ - $$PWD/ViewItem/recent_item_delegate.cpp \ - $$PWD/ViewItem/right_item_delegate.cpp \ - $$PWD/ViewItem/tablet_full_itemdelegate.cpp \ - $$PWD/Widget/animationpage.cpp \ - $$PWD/Widget/full_commonuse_widget.cpp \ - $$PWD/Widget/full_function_widget.cpp \ - $$PWD/Widget/full_letter_widget.cpp \ - $$PWD/Widget/full_searchresult_widget.cpp \ - $$PWD/Widget/function_Widget.cpp \ - $$PWD/Widget/function_button_widget.cpp \ - $$PWD/Widget/letter_button_widget.cpp \ - $$PWD/Widget/main_view_widget.cpp \ - $$PWD/Widget/plugin_widget.cpp \ - $$PWD/Widget/splitbar_frame.cpp \ - $$PWD/Widget/tabview_widget.cpp \ - $$PWD/full_mainwindow.cpp \ - $$PWD/mainwindow.cpp \ - $$PWD/tabletwindow.cpp diff --git a/src/UtilityFunction/AbstractInterface.h b/src/UtilityFunction/AbstractInterface.h deleted file mode 100644 index 90ed8ff..0000000 --- a/src/UtilityFunction/AbstractInterface.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ABSTRACTINTERFACE_H -#define ABSTRACTINTERFACE_H -#include -class QWidget; -class AbstractInterface -{ -public: - virtual ~AbstractInterface() {} - virtual QWidget *createPluginWidget(QWidget *parent, bool type) = 0; -}; -#define AbstractInterface_iid "Welcome to use focusmode" -Q_DECLARE_INTERFACE(AbstractInterface, AbstractInterface_iid) -#endif // ABSTRACTINTERFACE_H diff --git a/src/UtilityFunction/KySmallPluginInterface.h b/src/UtilityFunction/KySmallPluginInterface.h deleted file mode 100644 index cf9ad21..0000000 --- a/src/UtilityFunction/KySmallPluginInterface.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef KYSMALLPLUGININTERFACE_H -#define KYSMALLPLUGININTERFACE_H - -#include -#include -#include -#include - -class QWidget; -class KySmallPluginInterface -{ - -public: - virtual ~KySmallPluginInterface() {} - virtual const QString name() const = 0; - virtual const QString nameCN() const = 0; - virtual const QString description() const = 0; - virtual int sortNum() const = 0; - virtual QWidget *createWidget(QWidget *parent) = 0; -}; -QT_BEGIN_NAMESPACE -/* - * 声明接口,Q_DECLARE_INTERFACE 宏告诉Qt 这个纯虚类是一个插件接口类 - * Q_DECLARE_INTERFACE(接口类名, 接口标识符) - * 如果我们稍后更改接口,则必须使用不同的字符串来标识新接口;否则,应用程序可能会崩溃。因此,在字符串中包含一个版本号是一个好主意 -*/ -#define SP_PLUGIN_IID "org.Kylin.SmallPlugin.widgetInterface/1.0" -Q_DECLARE_INTERFACE(KySmallPluginInterface, SP_PLUGIN_IID) -QT_END_NAMESPACE - -#endif // KYSMALLPLUGININTERFACE_H diff --git a/src/UtilityFunction/Style/style.cpp b/src/UtilityFunction/Style/style.cpp deleted file mode 100644 index 2832bc6..0000000 --- a/src/UtilityFunction/Style/style.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 -#include "src/UtilityFunction/utility.h" -#include "src/UtilityFunction/utility.h" -#include - -Style::Style() -{ -} - -int Style::m_primaryScreenX = 0; -int Style::m_primaryScreenY = 0; -int Style::m_panelPosition = 0; -//默认窗口 -int Style::minw = 0; -int Style::minh = 0; -int Style::leftPageWidth = 0; -int Style::leftPageHeight = 0; -int Style::defaultQueryLineEditIconSize = 0; -/** - * 全屏窗口 - */ -//主窗口 -int Style::m_availableScreenWidth = 0; -int Style::m_availableScreenHeight = 0; -//搜索栏 -int Style::QueryLineEditHeight = 0; -//左侧栏 -int Style::m_leftWidWidth = 0; -int Style::LeftMargin = 0; -int Style::LeftBtnWidth = 0; -int Style::LeftBtnHeight = 0; -int Style::LeftLetterBtnHeight = 0; -int Style::LeftLetterFontSize = 0; -int Style::LeftIconSize = 0; -int Style::LeftSpaceIconText = 0; -int Style::LeftSpaceBetweenItem = 0; -//应用列表栏 -int Style::m_applistWidWidth = 0; -int Style::m_applistWidHeight = 0; -int Style::AppListIconSize = 0; -int Style::AppListBigIconSize = 0; -int Style::AppListItemSizeWidth = 0; -int Style::TabletItemSizeWidthOther = 0; -int Style::TabletItemSizeWidthFirst = 0; -int Style::FirsPageViewWidth = 0; -int Style::OtherPageViewWidth = 0; -int Style::m_applistGridSizeWidth = 0; -int Style::AppLeftSpace = 0; -int Style::AppTopSpace = 0; -int Style::AppSpaceBetweenIconText = 0; -int Style::FirstPageSpace = 0; -int Style::OtherPageSpace = 0; - -//侧边栏primaryScreen -int Style::SideBarWidWidth = 0; - -int Style::appLine = 0; -int Style::appColumn = 0; -int Style::appPage = 1; -int Style::appNum = 0; -int Style::nowpagenum = 1; -int Style::appRows = 0; -bool Style::ScreenRotation = false; -int Style::AppListItemSizeHeight = 270; -int Style::AppListViewTopMargin = 0; -int Style::ScreenWidth = 0; -int Style::ScreenHeight = 0; -int Style::AppListViewLeftMargin = 52; -int Style::AppListViewBottomMargin = 20; -int Style::AppListViewRightMargin = 0; -int Style::TimeWidgetTop = 81; -int Style::TimeWidgetLeft = 112; -int Style::CenterWindHeight = 0; - -int Style::GroupAppColumn = 1; -int Style::GroupAppRow = 1; - -int Style::ButtonWidgetWidth = 56; - -int Style::ToolWidgetLeft = 24; -bool Style::IsWideScreen = false; - -int Style::DropMenuWidth = 0; -int Style::DropMenuHeight = 0; -int Style::miniIconSize = 0; - -void Style::initWidStyle() -{ - if (!g_projectCodeName.contains("V10SP1-edu")) { - QVariantList list = getScreenGeometryList(); - m_primaryScreenX = list.at(0).toInt(); - m_primaryScreenY = list.at(1).toInt(); - m_availableScreenWidth = list.at(2).toInt(); - m_availableScreenHeight = list.at(3).toInt(); - m_panelPosition = list.at(5).toInt(); - int len = 0; - QString locale = QLocale::system().name(); - - if (locale == "zh_CN") { - len = 0; - } else { - len = 10; - } - - if (m_availableScreenWidth == 800 && m_availableScreenHeight == 600) { - minw = 320; - minh = 500; - leftPageWidth = 300; - leftPageHeight = 517; - } else { - minw = 652; - minh = 590; - leftPageWidth = 300; - leftPageHeight = 517; - } - - if (m_availableScreenWidth >= 2000 && m_availableScreenWidth <= 4000) { - LeftMargin = 20; - LeftLetterFontSize = 14; - LeftSpaceBetweenItem = 15; - AppListIconSize = 96; - AppListItemSizeWidth = 168; - m_applistGridSizeWidth = 240; - AppSpaceBetweenIconText = 20; - } else if (m_availableScreenWidth >= 1920 && m_availableScreenWidth < 2000) { - LeftMargin = 20; - LeftLetterFontSize = 14; - LeftSpaceBetweenItem = 15; - AppListIconSize = 86; - AppListItemSizeWidth = 150; - m_applistGridSizeWidth = 220; - AppSpaceBetweenIconText = 18; - } else if (m_availableScreenWidth >= 1600 && m_availableScreenWidth < 1920) { - LeftMargin = 10; - LeftLetterFontSize = 11; - LeftSpaceBetweenItem = 10; - AppListIconSize = 86; - AppListItemSizeWidth = 150; - m_applistGridSizeWidth = 180; - AppSpaceBetweenIconText = 14; - } else if (m_availableScreenWidth >= 1366 && m_availableScreenWidth < 1600) { - LeftMargin = 10; - LeftLetterFontSize = 11; - LeftSpaceBetweenItem = 10; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - m_applistGridSizeWidth = 140; - AppSpaceBetweenIconText = 0; - } else if (m_availableScreenWidth >= 1280 && m_availableScreenWidth < 1366) { - LeftMargin = 10; - LeftLetterFontSize = 11; - LeftSpaceBetweenItem = 10; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - m_applistGridSizeWidth = 142; - AppSpaceBetweenIconText = 14; - } else if (m_availableScreenWidth >= 1152 && m_availableScreenWidth < 1280) { - LeftMargin = 10; - LeftLetterFontSize = 11; - LeftSpaceBetweenItem = 10; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - m_applistGridSizeWidth = 142; - AppSpaceBetweenIconText = 14; - } else if (m_availableScreenWidth > 800 && m_availableScreenWidth < 1152) { - LeftMargin = 10; - LeftLetterFontSize = 11; - LeftSpaceBetweenItem = 10; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - m_applistGridSizeWidth = 141; - AppSpaceBetweenIconText = 14; - } else { - LeftMargin = 10; - LeftLetterFontSize = 11; - LeftSpaceBetweenItem = 10; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - m_applistGridSizeWidth = 138; - AppSpaceBetweenIconText = 14; - } - - LeftBtnWidth = 68 + 5 * len; - LeftBtnHeight = 34; - QueryLineEditHeight = 30; - LeftLetterBtnHeight = 25; - LeftIconSize = 19; - DropMenuWidth = 128; - DropMenuHeight = 112; - miniIconSize = 8; - LeftSpaceIconText = 14; - m_applistWidWidth = m_availableScreenWidth / 1.25; - m_applistWidWidth = m_applistWidWidth - (m_applistWidWidth % m_applistGridSizeWidth) + 1; - m_applistWidHeight = m_availableScreenHeight - 120; - m_applistWidHeight = m_applistWidHeight - (m_applistWidHeight % m_applistGridSizeWidth) + 1; - m_leftWidWidth = (m_availableScreenWidth - m_applistWidWidth) / 2 + 1; - } else { - ScreenWidth = QApplication::primaryScreen()->geometry().width(); - ScreenHeight = QApplication::primaryScreen()->geometry().height(); - - if (ScreenHeight != 1080) { - AppListViewTopMargin = 30; - } else { - AppListViewTopMargin = 70; - } - - AppListViewLeftMargin = 52; - AppListViewBottomMargin = AppListViewTopMargin - 30; - AppListViewRightMargin = 0; - m_leftWidWidth = ScreenWidth * 0.3; - FirsPageViewWidth = ScreenWidth - m_leftWidWidth - 5; - OtherPageViewWidth = ScreenWidth; - TabletItemSizeWidthFirst = FirsPageViewWidth / 6; - TabletItemSizeWidthOther = (ScreenWidth - 5) / 6; - CenterWindHeight = ScreenHeight - AppListViewBottomMargin - AppListViewTopMargin; - AppListItemSizeHeight = CenterWindHeight / 4; - AppListIconSize = 96; - AppListBigIconSize = 108; - AppTopSpace = (AppListItemSizeHeight - AppListIconSize) / 2; - AppLeftSpace = (TabletItemSizeWidthFirst - AppListIconSize) / 2; - TimeWidgetTop = (CenterWindHeight - 870) / 2; - TimeWidgetLeft = (m_leftWidWidth - 400) / 2; - FirstPageSpace = AppLeftSpace; - OtherPageSpace = (TabletItemSizeWidthOther - AppListIconSize) / 2; - } -} diff --git a/src/UtilityFunction/abstractInterface.h b/src/UtilityFunction/abstractInterface.h deleted file mode 100644 index 255507a..0000000 --- a/src/UtilityFunction/abstractInterface.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef OOBE_PLUGIN_INFACE_H -#define OOBE_PLUGIN_INFACE_H - -#include -#include -#include -#include - -class QWidget; -class kyMenuPluginInterface -{ - -public: - virtual ~kyMenuPluginInterface() {} - virtual const QString name() = 0; - virtual const QString description() = 0; - virtual QWidget *createWidget(QWidget *parent) = 0; -}; -Q_DECLARE_INTERFACE(kyMenuPluginInterface, "org.kyMenuPlugin.AbstractInterface") -#endif diff --git a/src/UserInterface/Other/classify_btn_scrollarea.cpp b/src/UtilityFunction/classifybtnscrollarea.cpp similarity index 61% rename from src/UserInterface/Other/classify_btn_scrollarea.cpp rename to src/UtilityFunction/classifybtnscrollarea.cpp index 95c2619..26a37da 100644 --- a/src/UserInterface/Other/classify_btn_scrollarea.cpp +++ b/src/UtilityFunction/classifybtnscrollarea.cpp @@ -16,8 +16,8 @@ * */ -#include "classify_btn_scrollarea.h" -#include "src/UtilityFunction/utility.h" +#include "classifybtnscrollarea.h" +#include "utility.h" #include #include #include @@ -27,47 +27,46 @@ ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid(QWidget *parent): { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); - this->setAutoFillBackground(false); } void ClassifyBtnScrollAreaWid::paintEvent(QPaintEvent *event) { double transparency = getTransparency(); QPainter painter(this); - // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) - // { - // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); - // if(gsetting.keys().contains(QString("effect"))) - // { - // if(gsetting.get("effect").toBool()) - // { - // painter.setBrush(Qt::black); - // painter.setPen(Qt::transparent); - // painter.setOpacity(0.25); - // painter.drawRect(this->rect()); - // } - // else - // { - // painter.setBrush(this->palette().base()); - // painter.setPen(Qt::transparent); - // painter.setOpacity(transparency); - // painter.drawRect(this->rect()); - // } - // } - // else - // { - // painter.setBrush(this->palette().base()); - // painter.setPen(Qt::transparent); - // painter.setOpacity(transparency); - // painter.drawRect(this->rect()); - // } - // } - // else{ +// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) +// { +// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); +// if(gsetting.keys().contains(QString("effect"))) +// { +// if(gsetting.get("effect").toBool()) +// { +// painter.setBrush(Qt::black); +// painter.setPen(Qt::transparent); +// painter.setOpacity(0.25); +// painter.drawRect(this->rect()); +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else{ painter.setBrush(this->palette().base()); painter.setPen(Qt::transparent); painter.setOpacity(transparency); painter.drawRect(this->rect()); - // } +// } QWidget::paintEvent(event); } @@ -104,8 +103,8 @@ ClassifyBtnScrollArea::ClassifyBtnScrollArea(QWidget *parent): void ClassifyBtnScrollArea::initWid() { - this->verticalScrollBar()->setHidden(false); - this->horizontalScrollBar()->setHidden(false); + this->verticalScrollBar()->setHidden(true); + this->horizontalScrollBar()->setHidden(true); this->setWidgetResizable(true); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); diff --git a/src/UserInterface/Other/classify_btn_scrollarea.h b/src/UtilityFunction/classifybtnscrollarea.h similarity index 92% rename from src/UserInterface/Other/classify_btn_scrollarea.h rename to src/UtilityFunction/classifybtnscrollarea.h index 743c8d1..797c7e8 100644 --- a/src/UserInterface/Other/classify_btn_scrollarea.h +++ b/src/UtilityFunction/classifybtnscrollarea.h @@ -25,10 +25,11 @@ class ClassifyBtnScrollAreaWid: public QWidget { public: - ClassifyBtnScrollAreaWid(QWidget *parent); + ClassifyBtnScrollAreaWid(QWidget *parent = nullptr); protected: void paintEvent(QPaintEvent *event); + // void keyPressEvent(QKeyEvent* e); }; class ClassifyBtnScrollArea : public QScrollArea diff --git a/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp b/src/UtilityFunction/convertdesktoptowinid.cpp similarity index 50% rename from src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp rename to src/UtilityFunction/convertdesktoptowinid.cpp index cf17b36..cbea3f1 100644 --- a/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp +++ b/src/UtilityFunction/convertdesktoptowinid.cpp @@ -16,48 +16,51 @@ * */ -#include "convert_winid_to_desktop.h" -#include "utility.h" +#include "convertdesktoptowinid.h" +#include "src/UtilityFunction/utility.h" #include #include #include #include -ConvertWinidToDesktop::ConvertWinidToDesktop(QObject *parent) : QObject(parent) +ConvertDesktopToWinId::ConvertDesktopToWinId() { + } -QString ConvertWinidToDesktop::tranIdToDesktop(WId id) +QString ConvertDesktopToWinId::tranIdToDesktop(WId id) { KWindowInfo info(id, 0, NET::WM2AllProperties); - myDebug() << "the pid is :" << info.pid(); QString desktopName = confirmDesktopFile(info); myDebug() << "desktopName is :" << desktopName; return desktopName; } -QString ConvertWinidToDesktop::confirmDesktopFile(KWindowInfo info) +QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info) { - QString desktopFilePath = nullptr; - QDir dir = QDir(DESKTOP_FILE_PATH); - QFileInfoList list = dir.entryInfoList(); + m_desktopfilePath = ""; + + m_dir = new QDir(DEKSTOP_FILE_PATH); + m_list = m_dir->entryInfoList(); //跳过 ./ 和 ../ 目录 - list.removeAll(QFile(USR_SHARE_APP_CURRENT)); - list.removeAll(QFile(USR_SHARE_APP_UPER)); + m_list.removeAll(QFile(USR_SHARE_APP_CURRENT)); + m_list.removeAll(QFile(USR_SHARE_APP_UPER)); //第一种方法:获取点击应用时大部分desktop文件名 - desktopFilePath = searchFromEnviron(info, list); + searchFromEnviron(info); //第二种方法:比较名字一致性 - if (desktopFilePath.isEmpty()) { + if (m_desktopfilePath.isEmpty()) { m_classClass = info.windowClassClass().toLower(); m_className = info.windowClassName(); //匹配安卓兼容 if (m_className == "kylin-kmre-window") { - return searchAndroidApp(info); + searchAndroidApp(info); + return m_desktopfilePath; } + QFile file(QString("/proc/%1/status").arg(info.pid())); if (file.open(QIODevice::ReadOnly)) { char buf[1024]; @@ -66,11 +69,11 @@ QString ConvertWinidToDesktop::confirmDesktopFile(KWindowInfo info) m_statusName = QString::fromLocal8Bit(buf).remove("Name:").remove("\t").remove("\n"); } } - desktopFilePath = compareClassName(list); + compareClassName(); } //第三种方法:比较cmd命令行操作一致性 - if (desktopFilePath.isEmpty()) { + if (m_desktopfilePath.isEmpty()) { QFile file(QString("/proc/%1/cmdline").arg(info.pid())); if (file.open(QIODevice::ReadOnly)) { char buf[1024]; @@ -79,30 +82,30 @@ QString ConvertWinidToDesktop::confirmDesktopFile(KWindowInfo info) m_cmdLine = QString::fromLocal8Bit(buf).remove("\n"); } } - desktopFilePath = compareCmdExec(list); + compareCmdExec(); } //第四种方法:匹配部分字段 - if (desktopFilePath.isEmpty()) { - desktopFilePath = compareLastStrategy(list); + if (m_desktopfilePath.isEmpty()) { + compareLastStrategy(); } - return desktopFilePath; + return m_desktopfilePath; } -QString ConvertWinidToDesktop::searchAndroidApp(KWindowInfo info) +void ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info) { - QDir androidDir = QString(QDir::homePath() + ANDROID_FILE_PATH); - QFileInfoList androidList = androidDir.entryInfoList(); - androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT); - androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER); + m_androidDir = new QDir(QString(QDir::homePath() + ANDROID_FILE_PATH)); + m_androidList = m_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())); file.open(QIODevice::ReadOnly); QByteArray cmd = file.readAll(); file.close(); QList cmdList = cmd.split('\0'); - for (int i = 0; i < androidList.size(); i++) { - QFileInfo fileInfo = androidList.at(i); + for (int i = 0; i < m_androidList.size(); i++) { + QFileInfo fileInfo = m_androidList.at(i); QString desktopName = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; @@ -110,65 +113,59 @@ QString ConvertWinidToDesktop::searchAndroidApp(KWindowInfo info) desktopName = desktopName.mid(desktopName.lastIndexOf("/") + 1); desktopName = desktopName.left(desktopName.lastIndexOf(".")); if(desktopName == cmdList.at(10)){ - return fileInfo.filePath(); + m_desktopfilePath = fileInfo.filePath(); } } - return nullptr; } -QString ConvertWinidToDesktop::searchFromEnviron(KWindowInfo info, QFileInfoList list) +void ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info) { QFile file("/proc/" + QString::number(info.pid()) + "/environ"); file.open(QIODevice::ReadOnly); QByteArray BA = file.readAll(); file.close(); QList list_BA = BA.split('\0'); - - QString desktopFilePath = nullptr; for (int i = 0; i < list_BA.length(); i++) { if (list_BA.at(i).startsWith("GIO_LAUNCHED_DESKTOP_FILE=")) { - desktopFilePath = list_BA.at(i); - desktopFilePath = desktopFilePath.mid(desktopFilePath.indexOf("=") + 1); + m_desktopfilePath = list_BA.at(i); + m_desktopfilePath = m_desktopfilePath.mid(m_desktopfilePath.indexOf("=") + 1); //desktop文件地址需要重写 - desktopFilePath = desktopFilePath.mid(desktopFilePath.lastIndexOf("/") + 1); - break; + m_desktopfilePath = m_desktopfilePath.mid(m_desktopfilePath.lastIndexOf("/") + 1); } } //desktop文件地址重写 - if (!desktopFilePath.isEmpty()) { - for (int i = 0; i < list.size(); i++) { - QFileInfo fileInfo = list.at(i); - if (fileInfo.filePath() == DESKTOP_FILE_PATH + desktopFilePath) { - desktopFilePath = fileInfo.filePath(); - return desktopFilePath; + if (!m_desktopfilePath.isEmpty()) { + for (int i = 0; i < m_list.size(); i++) { + QFileInfo fileInfo = m_list.at(i);; + if (fileInfo.filePath() == DEKSTOP_FILE_PATH + m_desktopfilePath) { + m_desktopfilePath = fileInfo.filePath(); } } } - return desktopFilePath; + } -QString ConvertWinidToDesktop::compareClassName(QFileInfoList list) +void ConvertDesktopToWinId::compareClassName() { - for (int i = 0; i < list.size(); i++) { - QFileInfo fileInfo = list.at(i);; - QString pathDesktopName = fileInfo.filePath(); + for (int i = 0; i < m_list.size(); i++) { + QFileInfo fileInfo = m_list.at(i);; + QString path_desktop_name = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } - pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1); - pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf(".")); - if (pathDesktopName == m_classClass || pathDesktopName == m_className || pathDesktopName == m_statusName) { - return fileInfo.filePath(); + 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) { + m_desktopfilePath = fileInfo.filePath(); } } - return nullptr; } -QString ConvertWinidToDesktop::compareCmdExec(QFileInfoList list) +void ConvertDesktopToWinId::compareCmdExec() { - for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < m_list.size(); i++) { QString cmd; - QFileInfo fileInfo = list.at(i); + QFileInfo fileInfo = m_list.at(i); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } @@ -180,38 +177,38 @@ QString ConvertWinidToDesktop::compareCmdExec(QFileInfoList list) } if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) { - return fileInfo.filePath(); + m_desktopfilePath = fileInfo.filePath(); } //仅仅是为了适配微信 - desktopFileExeName = "/usr/lib/" + desktopFileExeName; - if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) { - return fileInfo.filePath(); + if (m_desktopfilePath.isEmpty()) { + desktopFileExeName = "/usr/lib/" + desktopFileExeName; + if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) { + m_desktopfilePath = fileInfo.filePath(); + } } } - return nullptr; } //最后的匹配策略汇总 -QString ConvertWinidToDesktop::compareLastStrategy(QFileInfoList list) +void ConvertDesktopToWinId::compareLastStrategy() { - QString desktopFilePath = compareCmdName(list); + compareCmdName(); - if (desktopFilePath.isEmpty()) { - desktopFilePath = compareDesktopClass(list); + if (m_desktopfilePath.isEmpty()) { + compareDesktopClass(); } - if (desktopFilePath.isEmpty()) { - desktopFilePath = containsName(list); + if (m_desktopfilePath.isEmpty()) { + containsName(); } - return desktopFilePath; } -QString ConvertWinidToDesktop::compareCmdName(QFileInfoList list) +void ConvertDesktopToWinId::compareCmdName() { - for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < m_list.size(); i++) { QString cmd; - QFileInfo fileInfo = list.at(i); + QFileInfo fileInfo = m_list.at(i); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } @@ -223,39 +220,37 @@ QString ConvertWinidToDesktop::compareCmdName(QFileInfoList list) } if (desktopFileExeName.startsWith(m_className) || desktopFileExeName.endsWith(m_className)) { - return fileInfo.filePath(); + m_desktopfilePath = fileInfo.filePath(); } } - return nullptr; } -QString ConvertWinidToDesktop::compareDesktopClass(QFileInfoList list) +void ConvertDesktopToWinId::compareDesktopClass() { - for (int i = 0; i < list.size(); i++) { - QFileInfo fileInfo = list.at(i); - QString pathDesktopName = fileInfo.filePath(); + for (int i = 0; i < m_list.size(); i++) { + QFileInfo fileInfo = m_list.at(i); + QString path_desktop_name = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } - pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1); - pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf(".")); + path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1); + path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf(".")); - if (pathDesktopName.startsWith(m_className) || pathDesktopName.endsWith(m_className)) { - return fileInfo.filePath(); + if (path_desktop_name.startsWith(m_className) || path_desktop_name.endsWith(m_className)) { + m_desktopfilePath = fileInfo.filePath(); } - else if (m_className.startsWith(pathDesktopName) || m_className.endsWith(pathDesktopName)) { - return fileInfo.filePath(); + else if (m_className.startsWith(path_desktop_name) || m_className.endsWith(path_desktop_name)) { + m_desktopfilePath = fileInfo.filePath(); } } - return nullptr; } -QString ConvertWinidToDesktop::containsName(QFileInfoList list) +void ConvertDesktopToWinId::containsName() { - for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < m_list.size(); i++) { QString cmd; - QFileInfo fileInfo = list.at(i); - QString pathDesktopName = fileInfo.filePath(); + QFileInfo fileInfo = m_list.at(i); + QString path_desktop_name = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; @@ -264,30 +259,37 @@ QString ConvertWinidToDesktop::containsName(QFileInfoList list) cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data()); QString desktopFileExeName = getDesktopFileName(cmd).remove("\n"); - pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1); - pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf(".")); + path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1); + path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf(".")); - if (pathDesktopName.contains(m_className) || desktopFileExeName.contains(m_className)) { - return fileInfo.filePath(); + if (path_desktop_name.contains(m_className) || desktopFileExeName.contains(m_className)) { + m_desktopfilePath = fileInfo.filePath(); } } - return nullptr; } //执行头文件中宏定义写好的终端指令获取对应的Exec字段 -QString ConvertWinidToDesktop::getDesktopFileName(QString cmd) +QString ConvertDesktopToWinId::getDesktopFileName(QString cmd) { char name[200]; FILE *fp1 = NULL; - if ((fp1 = popen(cmd.toStdString().data(), "r")) == NULL) { + if ((fp1 = popen(cmd.toStdString().data(), "r")) == NULL) return QString(); - } memset(name, 0, sizeof(name)); fgets(name, sizeof(name), fp1); pclose(fp1); return QString(name); } -ConvertWinidToDesktop::~ConvertWinidToDesktop() + +ConvertDesktopToWinId::~ConvertDesktopToWinId() { + if (m_dir != nullptr) { + delete m_dir; + m_dir = nullptr; + } + if (m_androidDir) { + delete m_androidDir; + m_androidDir = nullptr; + } } diff --git a/src/BackProcess/FileWatcher/convert_winid_to_desktop.h b/src/UtilityFunction/convertdesktoptowinid.h similarity index 73% rename from src/BackProcess/FileWatcher/convert_winid_to_desktop.h rename to src/UtilityFunction/convertdesktoptowinid.h index ba6a77f..671672e 100644 --- a/src/BackProcess/FileWatcher/convert_winid_to_desktop.h +++ b/src/UtilityFunction/convertdesktoptowinid.h @@ -23,7 +23,7 @@ #include #include -#define DESKTOP_FILE_PATH "/usr/share/applications/" +#define DEKSTOP_FILE_PATH "/usr/share/applications/" #define USR_SHARE_APP_CURRENT "/usr/share/applications/." #define USR_SHARE_APP_UPER "/usr/share/applications/.." #define PEONY_TRASH "/usr/share/applications/peony-trash.desktop" @@ -38,35 +38,41 @@ /** - * @brief The ConvertWinidToDesktop class + * @brief The ConvertDesktopToWinId class * 需要实现的功能,desktop文件与windowId的转换 - * 传入(int)WindowId,转化为desktop文件的路径 + * 传入desktop文件的路径,转化为(int)WindowId */ -class ConvertWinidToDesktop : public QObject +class ConvertDesktopToWinId: public QObject { Q_OBJECT public: - explicit ConvertWinidToDesktop(QObject *parent = nullptr); - ~ConvertWinidToDesktop(); + ConvertDesktopToWinId(); + ~ConvertDesktopToWinId(); QString tranIdToDesktop(WId id); private: + QString m_desktopfilePath = nullptr; QString m_classClass = nullptr; QString m_className = nullptr; QString m_statusName = nullptr; QString m_cmdLine = nullptr; + QDir *m_dir = nullptr; + QDir *m_androidDir = nullptr; + QFileInfoList m_list; + QFileInfoList m_androidList; + QString confirmDesktopFile(KWindowInfo info); - QString searchFromEnviron(KWindowInfo info, QFileInfoList list); - QString searchAndroidApp(KWindowInfo info); - QString compareClassName(QFileInfoList list); - QString compareCmdExec(QFileInfoList list); - QString compareLastStrategy(QFileInfoList list); - QString compareCmdName(QFileInfoList list); - QString compareDesktopClass(QFileInfoList list); - QString containsName(QFileInfoList list); + void searchFromEnviron(KWindowInfo info); + void searchAndroidApp(KWindowInfo info); + void compareClassName(); + void compareCmdExec(); + void compareLastStrategy(); + void compareCmdName(); + void compareDesktopClass(); + void containsName(); QString getDesktopFileName(QString cmd); }; diff --git a/src/UserInterface/ViewItem/full_item_delegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp similarity index 84% rename from src/UserInterface/ViewItem/full_item_delegate.cpp rename to src/UtilityFunction/fullitemdelegate.cpp index 9dc4076..c471d7c 100644 --- a/src/UserInterface/ViewItem/full_item_delegate.cpp +++ b/src/UtilityFunction/fullitemdelegate.cpp @@ -16,20 +16,23 @@ * */ -#include "full_item_delegate.h" +#include "fullitemdelegate.h" #include "src/UtilityFunction/utility.h" #include FullItemDelegate::FullItemDelegate(QObject *parent, int module): - KItemDelegate(parent) + QStyledItemDelegate(parent) { this->module = module; - pUkuiMenuInterface = new UkuiMenuInterface; + m_ukuiMenuInterface = new UkuiMenuInterface; } FullItemDelegate::~FullItemDelegate() { - delete pUkuiMenuInterface; + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } } void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -56,8 +59,8 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti painter->setRenderHint(QPainter::Antialiasing); if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - // QColor color = option.palette.text().color(); - // color.setAlphaF(0.15); +// QColor color = option.palette.text().color(); +// color.setAlphaF(0.15); painter->save(); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(Qt::white); @@ -69,7 +72,7 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti painter->save(); painter->setOpacity(1); QString desktopfp = index.data(Qt::DisplayRole).value(); - QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); + QString iconstr = m_ukuiMenuInterface->getAppIcon(desktopfp); QIcon icon; QFileInfo iconFileInfo(iconstr); @@ -80,7 +83,8 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti iconstr.remove(".svg"); icon = QIcon::fromTheme(iconstr); - if (icon.isNull()) { + if (icon.isNull() || icon.actualSize(QSize(Style::AppListIconSize, + Style::AppListIconSize)).width() < Style::AppListIconSize) { if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { @@ -109,19 +113,23 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); + } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); } else { icon = QIcon::fromTheme(QString("application-x-desktop")); } } } - QString appname = pUkuiMenuInterface->getAppName(desktopfp); + QString appname = m_ukuiMenuInterface->getAppName(desktopfp); QRect iconRect; QRect textRect; - iconRect = QRect(/*rect.x()+66*/rect.x() + (rect.width() - Style::AppListIconSize) / 2, - /*rect.y()+40*/rect.y() + 40, - Style::AppListIconSize, - Style::AppListIconSize); + iconRect = QRect(rect.x() + Style::AppLeftSpace, + rect.y() + Style::AppTopSpace, + Style::AppListIconSize, + Style::AppListIconSize); icon.paint(painter, iconRect); painter->restore(); painter->save(); @@ -174,23 +182,11 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti painter->restore(); painter->save(); - - // painter->setPen(QPen(option.palette.text().color())); - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.keys().contains("styleName")) { - if (/*gsetting.get("styleName").toString() == "ukui-light"*/false) { - painter->setPen(QPen(Qt::black)); - } else { - painter->setPen(QPen(Qt::white)); - } - } - } - +// painter->setPen(QPen(option.palette.text().color())); + painter->setPen(QPen(Qt::white)); painter->setBrush(Qt::NoBrush); painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText); - // painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); +// painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); painter->restore(); if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { @@ -203,11 +199,7 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti } if (len > rect.width()) { - if (option.state & QStyle::State_MouseOver) { - QToolTip::showText(QCursor::pos(), appname); - } else { - QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); - } + QToolTip::showText(QCursor::pos(), appname); } else { QToolTip::hideText(); } @@ -217,5 +209,5 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti QSize FullItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - return QSize(/*Style::AppListItemSizeWidth*/220, /*Style::AppListItemSizeWidth*/220); + return QSize(Style::AppListItemSizeWidth, Style::AppListItemSizeWidth); } diff --git a/src/UserInterface/ViewItem/full_item_delegate.h b/src/UtilityFunction/fullitemdelegate.h similarity index 78% rename from src/UserInterface/ViewItem/full_item_delegate.h rename to src/UtilityFunction/fullitemdelegate.h index 601939e..c845642 100644 --- a/src/UserInterface/ViewItem/full_item_delegate.h +++ b/src/UtilityFunction/fullitemdelegate.h @@ -19,18 +19,17 @@ #ifndef FULLITEMDELEGATE_H #define FULLITEMDELEGATE_H #include -#include "style.h" +#include "src/Style/style.h" #include #include #include #include #include #include -#include "ukuimenuinterface.h" -#include "style.h" -#include "kitemdelegate.h" +#include "src/Interface/ukuimenuinterface.h" -class FullItemDelegate : public KItemDelegate + +class FullItemDelegate : public QStyledItemDelegate { Q_OBJECT public: @@ -38,6 +37,13 @@ public: ~FullItemDelegate(); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + +private: + int module = 0; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + +protected: +// bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index); }; #endif // FULLITEMDELEGATE_H diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp new file mode 100644 index 0000000..7755089 --- /dev/null +++ b/src/UtilityFunction/fulllistview.cpp @@ -0,0 +1,259 @@ +/* + * 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 +#include +#include +#include + +FullListView::FullListView(QWidget *parent, int module): + QListView(parent) +{ + this->module = module; + initWidget(); + m_ukuiMenuInterface = new UkuiMenuInterface; +} + +FullListView::~FullListView() +{ + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } +} + +void FullListView::initWidget() +{ + viewport()->setAttribute(Qt::WA_TranslucentBackground); + this->setSelectionMode(QAbstractItemView::SingleSelection); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +// if(module==1 || module==2)s + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setViewMode(QListView::IconMode); + this->setContextMenuPolicy(Qt::CustomContextMenu); + this->setResizeMode(QListView::Adjust); + this->setTextElideMode(Qt::ElideRight); + this->setMouseTracking(true); + // this->setFocusPolicy(Qt::StrongFocus); + this->setMovement(QListView::Static); + this->setEditTriggers(QAbstractItemView::NoEditTriggers); + this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth)); + myDebug() << "GridSize" << this->gridSize(); + this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->setFrameShape(QFrame::NoFrame);//移除边框 + this->setStyleSheet(QString::fromUtf8("QStandardItemModel#listmodel{border:3px solid #FFFFFF; }QWidget#widget:focus{ border:5px solid #A5A6A1; } ")); + connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); + connect(this, &FullListView::clicked, this, &FullListView::onClicked); +} + +void FullListView::addData(QStringList data) +{ + myDebug() << "FullListView::addData"; + listmodel = new QStandardItemModel(this); + this->setModel(listmodel); + + Q_FOREACH (QString desktopfp, data) { + QStandardItem *item = new QStandardItem; + item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + listmodel->appendRow(item); + } + + m_delegate = new FullItemDelegate(this, module); + this->setItemDelegate(m_delegate); +} + +void FullListView::focusInEvent(QFocusEvent *event) +{ + return QListView::focusInEvent(event); +} + +void FullListView::focusOutEvent(QFocusEvent *event) +{ + return QListView::focusOutEvent(event); +} + +void FullListView::updateData(QStringList data) +{ + myDebug() << "FullListView::updateData"; + listmodel->clear(); + + Q_FOREACH (QString desktopfp, data) { + QStandardItem *item = new QStandardItem; + item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + listmodel->appendRow(item); + } + + this->setItemDelegate(m_delegate); +} + +void FullListView::onClicked(QModelIndex index) +{ + QVariant var = listmodel->data(index, Qt::DisplayRole); + + if (var.isValid()) { + QString desktopfp = var.value(); + Q_EMIT sendItemClickedSignal(desktopfp); + } +} + +void FullListView::rightClickedSlot(const QPoint &pos) +{ + Q_UNUSED(pos) + + if (!(this->selectionModel()->selectedIndexes().isEmpty())) { + QModelIndex index = this->currentIndex(); + QVariant var = listmodel->data(index, Qt::DisplayRole); + QString desktopfp = var.value(); + RightClickMenu menu; + int ret = menu.showAppBtnMenu(this->mapToGlobal(pos), desktopfp); + + if (module > 0) { + switch (ret) { + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + + default: + break; + } + } else { + switch (ret) { + case 1: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 2: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + + default: + break; + } + } + + //this->selectionModel()->clear(); + } +} + +void FullListView::enterEvent(QEvent *e) +{ + Q_UNUSED(e); + this->selectionModel()->clear(); + this->verticalScrollBar()->setVisible(true); +} + +void FullListView::leaveEvent(QEvent *e) +{ + Q_UNUSED(e); + this->verticalScrollBar()->setVisible(false); +// QWidget *current_focus_widget; + // current_focus_widget = QApplication::focusWidget(); +// current_focus_widget = QWidget::focusWidget(); +// QPushButton *le= qobject_cast(current_focus_widget); +} + +void FullListView::selectFirstItem() +{ + if (this->currentIndex().row() == -1) { + this->setCurrentIndex(this->model()->index(0, 0)); + } +} + + +void FullListView::keyPressEvent(QKeyEvent *e) +{ + QRect center = visualRect(currentIndex()); + + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + break; + } + + case Qt::Key_Left: { + if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { + Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Right: { + if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { + Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Up: { + if (module == 0) { + if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) { + Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + } + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Down: { + if (module == 0) { + if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { + Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); + } + } + + return QListView::keyPressEvent(e); + break; + } + + default: + return QListView::keyPressEvent(e); + break; + } + } +} + +void FullListView::mouseReleaseEvent(QMouseEvent *event) +{ + if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { + Q_EMIT sendHideMainWindowSignal(); + } else { + return QListView::mouseReleaseEvent(event); + } +} diff --git a/src/UserInterface/ListView/fulllistview.h b/src/UtilityFunction/fulllistview.h similarity index 51% rename from src/UserInterface/ListView/fulllistview.h rename to src/UtilityFunction/fulllistview.h index 93c06b2..4e4be10 100644 --- a/src/UserInterface/ListView/fulllistview.h +++ b/src/UtilityFunction/fulllistview.h @@ -20,36 +20,57 @@ #define FULLLISTVIEW_H #include #include -#include "rightclickmenu.h" -#include "ukuimenuinterface.h" +#include "src/RightClickMenu/rightclickmenu.h" +#include "src/Interface/ukuimenuinterface.h" #include #include #include #include -#include "full_item_delegate.h" -#include "style.h" -#include "klistview.h" +#include "fullitemdelegate.h" +#include "src/Style/style.h" -class FullListView : public KListView +class FullListView : public QListView { Q_OBJECT public: - explicit FullListView(QWidget *parent, int module); + FullListView(QWidget *parent, int module); ~FullListView(); + void addData(QStringList data);//字母排序模块添加数据 + void updateData(QStringList data); + protected: void initWidget(); + void keyPressEvent(QKeyEvent *e); + void enterEvent(QEvent *e) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; + + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); + void mouseReleaseEvent(QMouseEvent *event); private: - RightClickMenu *menu = nullptr;//右键菜单 + FullItemDelegate *m_delegate = nullptr; + QStandardItemModel *listmodel = nullptr; + int module = 0; + double transparency; + RightClickMenu *menu = nullptr; //右键菜单 QStringList data; - QGSettings *gsetting = nullptr; + + QGSettings *gsetting; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; +// bool inCurView; public Q_SLOTS: + void onClicked(QModelIndex index);//点击item + void rightClickedSlot(const QPoint &pos);//右键菜单 void selectFirstItem(); Q_SIGNALS: + void sendItemClickedSignal(QString arg);//发送item点击信号 + void sendHideMainWindowSignal(); + void sendUpdateAppListSignal(); void sendSetslidebar(int value); }; diff --git a/src/UserInterface/Button/function_classify_button.cpp b/src/UtilityFunction/functionclassifybutton.cpp similarity index 63% rename from src/UserInterface/Button/function_classify_button.cpp rename to src/UtilityFunction/functionclassifybutton.cpp index 2494be4..8d7527d 100644 --- a/src/UserInterface/Button/function_classify_button.cpp +++ b/src/UtilityFunction/functionclassifybutton.cpp @@ -16,8 +16,8 @@ * */ -#include "function_classify_button.h" -#include "src/UtilityFunction/utility.h" +#include "functionclassifybutton.h" +#include "utility.h" #include #include #include @@ -37,23 +37,23 @@ FunctionClassifyButton::FunctionClassifyButton(int width, m_category(category), m_fullscreen(fullscreen), m_enabled(enabled), - m_iconLabel(new QLabel), - m_textLabel(new QLabel) + m_iconLabel(new QLabel(this)), + m_textLabel(new QLabel(this)) { this->setFlat(true); this->setFixedSize(m_width, m_height); this->setFocusPolicy(Qt::NoFocus); m_iconLabel->setFixedSize(m_iconSize, m_iconSize); m_textLabel->adjustSize(); - m_textLabel->setText(m_category); - m_textLabel->setAlignment(Qt::AlignCenter); if (m_fullscreen) { QPalette pe = m_textLabel->palette(); - pe.setColor(QPalette::ButtonText, Qt::white); + pe.setColor(QPalette::ButtonText, QColor(Qt::white)); m_textLabel->setPalette(pe); } + m_textLabel->setText(m_category); + if (m_fullscreen) { updateIconState(Normal); this->setCheckable(true); @@ -68,10 +68,10 @@ FunctionClassifyButton::FunctionClassifyButton(int width, } QHBoxLayout *mainlayout = new QHBoxLayout; - mainlayout->setContentsMargins(0, 0, 0, 0); + mainlayout->setContentsMargins(Style::LeftSpaceIconLeft, 0, 0, 0); mainlayout->setSpacing(Style::LeftSpaceIconText); this->setLayout(mainlayout); -// mainlayout->addWidget(m_iconLabel); + //mainlayout->addWidget(m_iconLabel); mainlayout->addWidget(m_textLabel); connect(this, &FunctionClassifyButton::toggled, this, &FunctionClassifyButton::reactToToggle); connect(this, &FunctionClassifyButton::clicked, this, &FunctionClassifyButton::buttonClickedSlot); @@ -89,22 +89,8 @@ void FunctionClassifyButton::paintEvent(QPaintEvent *e) painter.setPen(Qt::NoPen); if (!m_fullscreen) { - QColor color; - - if (option.state & QStyle::State_Selected) { - if (g_curStyle == "ukui-dark") { - color.setNamedColor("#33FFFFFF"); - } else { - color.setNamedColor("#D1FFFFFF"); - } - } else { - if (g_curStyle == "ukui-dark") { - color.setNamedColor("#1AFFFFFF"); - } else { - color.setNamedColor("#8CFFFFFF"); - } - } - + QColor color = option.palette.color(QPalette::Text); + color.setAlphaF(0.15); painter.setBrush(color); } else { painter.setOpacity(0.15); @@ -118,9 +104,9 @@ void FunctionClassifyButton::paintEvent(QPaintEvent *e) if (m_fullscreen && (option.state & QStyle::State_On)) { painter.save(); painter.setPen(Qt::NoPen); - QColor color = option.palette.color(QPalette::Text); - // color.setAlphaF(0.15); - painter.setBrush(color); +// QColor color = option.palette.color(QPalette::Text); +// color.setAlphaF(0.15); +// painter.setBrush(color); painter.setOpacity(0.15); painter.setBrush(Qt::white); painter.drawRoundedRect(option.rect, 4, 4); @@ -208,17 +194,6 @@ void FunctionClassifyButton::updateIconState() default: break; } - -// const auto ratio = devicePixelRatioF(); -// QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize * ratio); -// QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); -// if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 -// pixmap = drawSymbolicBlackColoredPixmap(pixmap); -// } else { -// pixmap = drawSymbolicColoredPixmap(pixmap); //反白 -// } -// pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); -// m_iconLabel->setPixmap(pixmap); } void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State state) @@ -251,51 +226,37 @@ void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State break; } -// const auto ratio = devicePixelRatioF(); -// QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize * ratio); -// if (!m_fullscreen) { -// QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); -// if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 -// pixmap = drawSymbolicBlackColoredPixmap(pixmap); -// } else { -// pixmap = drawSymbolicColoredPixmap(pixmap); //反白 -// } -// } else { -// pixmap = drawSymbolicColoredPixmap(pixmap); //反白 -// } -// pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); -// m_iconLabel->setPixmap(pixmap); updateTextState(state); } void FunctionClassifyButton::updateTextState(const FunctionClassifyButton::State state) { - // QPalette p= m_textLabel->palette(); +// QPalette p= m_textLabel->palette(); switch (state) { case Enabled: - // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); - // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255);"); +// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); +// m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255);"); break; case Disabled: - // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.25)); - // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 25%);"); +// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.25)); +// m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 25%);"); break; case Normal: - // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.50)); - // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 50%);"); +// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.50)); +// m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 50%);"); break; case Checked: - // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); - // m_textLabel->setStyleSheet("background:transparent;color:rgba(255, 255, 255);"); +// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); +// m_textLabel->setStyleSheet("background:transparent;color:rgba(255, 255, 255);"); break; default: break; } - // p.setColor(QPalette::Window,Qt::transparent); - // m_textLabel->setPalette(p); +// p.setColor(QPalette::Window,Qt::transparent); +// m_textLabel->setPalette(p); } diff --git a/src/UserInterface/Button/function_classify_button.h b/src/UtilityFunction/functionclassifybutton.h similarity index 67% rename from src/UserInterface/Button/function_classify_button.h rename to src/UtilityFunction/functionclassifybutton.h index e99f2c3..0e311a8 100644 --- a/src/UserInterface/Button/function_classify_button.h +++ b/src/UtilityFunction/functionclassifybutton.h @@ -27,23 +27,23 @@ #include #include #include -#include "style.h" -#include "utility.h" +#include "src/Style/style.h" +#include "src/UtilityFunction/utility.h" -class FunctionClassifyButton : public QPushButton +class FunctionClassifyButton :public QPushButton { Q_OBJECT public: /** * @param iconstr正常图片 */ - FunctionClassifyButton(int width, - int height, - int iconSize, - QString category, - bool fullscreen, - bool enabled, - QWidget *parent = nullptr); + FunctionClassifyButton(int width, + int height, + int iconSize, + QString category, + bool fullscreen, + bool enabled, + QWidget *parent=nullptr); enum State { Enabled, @@ -52,23 +52,39 @@ public: Checked, }; + enum Category{ + Mobile, + Internet, + Social, + Video, + Development, + Image, + Game, + Office, + Education, + System, + Safe, + Others, + }; + Q_ENUM(Category) + int m_width; int m_height; int m_iconSize; QString m_category; bool m_fullscreen; bool m_enabled; - QLabel *m_iconLabel = nullptr; - QLabel *m_textLabel = nullptr; - State m_state = Checked; + QLabel* m_iconLabel=nullptr; + QLabel* m_textLabel=nullptr; + State m_state=Checked; void updateBtnState(); void updateIconState();//根据主题修改图标 protected: - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); - void paintEvent(QPaintEvent *e); + void enterEvent(QEvent* e); + void leaveEvent(QEvent* e); + void paintEvent(QPaintEvent* e); void updateIconState(const State state); void updateTextState(const State state); diff --git a/src/UserInterface/ViewItem/recent_item_delegate.cpp b/src/UtilityFunction/itemdelegate.cpp similarity index 72% rename from src/UserInterface/ViewItem/recent_item_delegate.cpp rename to src/UtilityFunction/itemdelegate.cpp index db471cf..bd525e5 100644 --- a/src/UserInterface/ViewItem/recent_item_delegate.cpp +++ b/src/UtilityFunction/itemdelegate.cpp @@ -1,21 +1,46 @@ -#include "recent_item_delegate.h" +/* + * 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 +#include +#include +#include "src/UtilityFunction/utility.h" + +ItemDelegate::ItemDelegate(QObject *parent, int module): + QStyledItemDelegate(parent) { this->module = module; - pUkuiMenuInterface = new UkuiMenuInterface; + m_ukuiMenuInterface = new UkuiMenuInterface; } -recentitemdelegate::~recentitemdelegate() +ItemDelegate::~ItemDelegate() { - delete pUkuiMenuInterface; + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } } -void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.isValid()) { - // QStyleOptionViewItem viewOption(option);//用来在视图中画一个item +// QStyleOptionViewItem viewOption(option);//用来在视图中画一个item QRectF rect; rect.setX(option.rect.x()); rect.setY(option.rect.y()); @@ -50,9 +75,8 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op if (module > 0) { if (strlist.at(1).toInt() == 1) { - QRect iconRect = QRect(rect.x() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); - // QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0)); - QString iconstr = "wps-office2019-etmain"; + QRect iconRect = QRect(rect.x() + 11, rect.y() + (rect.height() - 32) / 2, Style::defaultIconSize, Style::defaultIconSize); + QString iconstr = m_ukuiMenuInterface->getAppIcon(strlist.at(0)); QIcon icon; QFileInfo iconFileInfo(iconstr); @@ -63,7 +87,7 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op iconstr.remove(".svg"); icon = QIcon::fromTheme(iconstr); - if (icon.isNull()) { + if (icon.isNull() || icon.actualSize(QSize(Style::defaultIconSize, Style::defaultIconSize)).width() < Style::defaultIconSize) { if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { @@ -72,10 +96,22 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); + } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); } else { icon = QIcon::fromTheme(QString("application-x-desktop")); } @@ -83,9 +119,8 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } painter->save(); - icon.paint(painter, iconRect, Qt::AlignLeft); - // QString appname=pUkuiMenuInterface->getAppName(strlist.at(0)); - QString appname = "这是一个测试文件.xlsx"; + icon.paint(painter, iconRect, Qt::AlignCenter); + QString appname = m_ukuiMenuInterface->getAppName(strlist.at(0)); QFontMetrics fm = painter->fontMetrics(); QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); painter->drawText(QRect(iconRect.right() + 15, rect.y(), @@ -107,11 +142,7 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op int len = fm.boundingRect(appname).width(); if (len > rect.width() - 62) { - if (option.state & QStyle::State_MouseOver) { - QToolTip::showText(QCursor::pos(), appname); - } else { - QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); - } + QToolTip::showText(QCursor::pos(), appname); } else { QToolTip::hideText(); } @@ -119,7 +150,7 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } else { //绘制分割线 painter->save(); - // QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); +// QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); QRect textRect = QRect(rect.x() + 11, rect.y(), rect.width(), rect.height()); painter->drawText(textRect, Qt::AlignVCenter, strlist.at(0)); painter->setRenderHint(QPainter::Antialiasing, true); @@ -130,7 +161,7 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } } else { QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); - QString iconstr = pUkuiMenuInterface->getAppIcon(strlist.at(0)); + QString iconstr = m_ukuiMenuInterface->getAppIcon(strlist.at(0)); QIcon icon; QFileInfo iconFileInfo(iconstr); @@ -141,15 +172,15 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op iconstr.remove(".svg"); icon = QIcon::fromTheme(iconstr); - if (icon.isNull()) { + if (icon.isNull() || icon.actualSize(QSize(32, 32)).width() < 32) { if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { @@ -164,8 +195,6 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); - } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); } else { icon = QIcon::fromTheme(QString("application-x-desktop")); } @@ -173,13 +202,13 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } icon.paint(painter, iconRect, Qt::AlignCenter); - QString appname = pUkuiMenuInterface->getAppName(strlist.at(0)); + QString appname = m_ukuiMenuInterface->getAppName(strlist.at(0)); QFileInfo fileInfo(strlist.at(0)); QString desktopfn = fileInfo.fileName(); if (checkIfLocked(desktopfn)) { QIcon icon(QString(":/data/img/mainviewwidget/lock.svg")); - icon.paint(painter, QRect(rect.topRight().x() - 22, rect.y() + (rect.height() - 16) / 2, 16, 16)); + icon.paint(painter, QRect(rect.topRight().x() - 30, rect.y() + (rect.height() - 16) / 2, 16, 16)); } painter->setOpacity(1); @@ -188,7 +217,7 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { painter->setPen(QPen(Qt::NoPen)); painter->setBrush(QColor("#4d94ff")); - painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); + painter->drawEllipse(QPoint(rect.topRight().x() - 30, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); } painter->restore(); @@ -206,11 +235,7 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op int len = fm.boundingRect(appname).width(); if (len > rect.width() - 62) { - if (option.state & QStyle::State_MouseOver) { - QToolTip::showText(QCursor::pos(), appname); - } else { - QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); - } + QToolTip::showText(QCursor::pos(), appname); } else { QToolTip::hideText(); } @@ -219,11 +244,11 @@ void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } } -QSize recentitemdelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - // QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); - // if(strlist.at(1).toInt()==1) - return QSize(310, 47); - // else - // return QSize(310,48); +// QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); +// if(strlist.at(1).toInt()==1) + return QSize(298, 44); +// else +// return QSize(310,48); } diff --git a/src/UserInterface/ViewItem/itemdelegate.h b/src/UtilityFunction/itemdelegate.h similarity index 86% rename from src/UserInterface/ViewItem/itemdelegate.h rename to src/UtilityFunction/itemdelegate.h index a57708e..8906406 100644 --- a/src/UserInterface/ViewItem/itemdelegate.h +++ b/src/UtilityFunction/itemdelegate.h @@ -19,14 +19,13 @@ #ifndef ITEMDELEGATE_H #define ITEMDELEGATE_H #include -#include "style.h" +#include "src/Style/style.h" #include #include #include -#include "ukuimenuinterface.h" -#include "kitemdelegate.h" +#include "src/Interface/ukuimenuinterface.h" -class ItemDelegate : public KItemDelegate +class ItemDelegate : public QStyledItemDelegate { Q_OBJECT public: @@ -37,6 +36,11 @@ public: ~ItemDelegate(); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + +private: + int module = 0; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + }; #endif // ITEMDELEGATE_H diff --git a/src/UserInterface/Button/letter_classify_button.cpp b/src/UtilityFunction/letterclassifybutton.cpp similarity index 50% rename from src/UserInterface/Button/letter_classify_button.cpp rename to src/UtilityFunction/letterclassifybutton.cpp index 5bc882f..403281a 100644 --- a/src/UserInterface/Button/letter_classify_button.cpp +++ b/src/UtilityFunction/letterclassifybutton.cpp @@ -16,78 +16,59 @@ * */ -#include "letter_classify_button.h" +#include "letterclassifybutton.h" #include #include -#include "utility.h" LetterClassifyButton::LetterClassifyButton(QWidget *parent, - bool fullscreen, - QString letter): + bool fullscreen, + QString letter): QPushButton(parent), m_fullscreen(fullscreen) { this->setFlat(true); - - if (m_fullscreen) { + if(m_fullscreen) + { QFont font; font.setPixelSize(Style::LeftLetterFontSize); this->setFont(font); - QPalette pe = this->palette(); - pe.setColor(QPalette::ButtonText, Qt::white); - this->setPalette(pe); } - this->setText(letter); this->setFocusPolicy(Qt::NoFocus); this->setCheckable(true); this->setStyleSheet("padding: 0px;"); - connect(this, &LetterClassifyButton::toggled, this, &LetterClassifyButton::reactToToggle); + connect(this,&LetterClassifyButton::toggled,this,&LetterClassifyButton::reactToToggle); } -void LetterClassifyButton::paintEvent(QPaintEvent *e) +void LetterClassifyButton::paintEvent(QPaintEvent* e) { QStylePainter painter(this); QStyleOptionButton option; initStyleOption(&option); - if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver || option.state & QStyle::State_HasFocus)) { painter.save(); painter.setPen(Qt::NoPen); - - if (!m_fullscreen) { - QColor color; - - if (option.state & QStyle::State_Selected) { - if (g_curStyle == "ukui-dark") { - color.setNamedColor("#33FFFFFF"); - } else { - color.setNamedColor("#D1FFFFFF"); - } - } else { - if (g_curStyle == "ukui-dark") { - color.setNamedColor("#1AFFFFFF"); - } else { - color.setNamedColor("#8CFFFFFF"); - } - } - + if(!m_fullscreen) + { + QColor color = option.palette.color(QPalette::Text); + color.setAlphaF(0.15); painter.setBrush(color); - } else { + } + else + { painter.setOpacity(0.15); painter.setBrush(Qt::white); } - painter.drawRoundedRect(option.rect, 4, 4); painter.restore(); } - - if (m_fullscreen && (option.state & QStyle::State_On)) { + if(m_fullscreen && (option.state & QStyle::State_On)) + { painter.save(); painter.setPen(Qt::NoPen); - // QColor color = option.palette.color(QPalette::Text); - // color.setAlphaF(0.15); - // painter.setBrush(color); +// QColor color = option.palette.color(QPalette::Text); +// color.setAlphaF(0.15); +// painter.setBrush(color); painter.setOpacity(0.15); painter.setBrush(Qt::white); painter.drawRoundedRect(option.rect, 4, 4); @@ -96,13 +77,10 @@ void LetterClassifyButton::paintEvent(QPaintEvent *e) QStyleOptionButton subopt = option; subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); - - if (m_fullscreen) { + if(m_fullscreen) subopt.palette.setBrush(QPalette::ButtonText, QColor(Qt::white)); - } else { + else subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); - } - painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); return; } @@ -110,80 +88,73 @@ void LetterClassifyButton::paintEvent(QPaintEvent *e) void LetterClassifyButton::enterEvent(QEvent *e) { Q_UNUSED(e); - - if (m_fullscreen) { - // QFont font; - // font.setPixelSize(Style::LeftLetterFontSize*3); - // this->setFont(font); - // this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - tooltip = new LetterToolTip(); - QPoint oPoint = this->mapToGlobal(QPoint(this->rect().x() + 35, this->rect().y() - 10)); - tooltip->setText(this->text()); - tooltip->raise(); - tooltip->move(oPoint); - tooltip->show(); + if(m_fullscreen) + { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize*3); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); } } void LetterClassifyButton::leaveEvent(QEvent *e) { Q_UNUSED(e); - - if (m_fullscreen) { + if(m_fullscreen) + { QFont font; font.setPixelSize(Style::LeftLetterFontSize); this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight, Style::LeftLetterBtnHeight); - tooltip->close(); - delete tooltip; - tooltip = nullptr; + this->setFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); } } void LetterClassifyButton::mousePressEvent(QMouseEvent *event) { Q_UNUSED(event); - - if (m_fullscreen) { - // QFont font; - // font.setPixelSize(Style::LeftLetterFontSize*3); - // this->setFont(font); - // this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - is_pressed = true; + if(m_fullscreen) + { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize*3); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + is_pressed=true; } } -void LetterClassifyButton::focusInEvent(QEvent *e) +void LetterClassifyButton::focusInEvent(QEvent* e) { Q_UNUSED(e); - - if (m_fullscreen) { + if(m_fullscreen) + { QFont font; - font.setPixelSize(Style::LeftLetterFontSize * 3); + font.setPixelSize(Style::LeftLetterFontSize*3); this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight * 2, Style::LeftLetterBtnHeight * 2); + this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); } } void LetterClassifyButton::mouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event); - - if (m_fullscreen) { - // QFont font; - // font.setPixelSize(Style::LeftLetterFontSize*3); - // this->setFont(font); - // this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + if(m_fullscreen) + { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize*3); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); } - Q_EMIT buttonClicked(this); } void LetterClassifyButton::reactToToggle(bool checked) { - if (checked) { - this->is_pressed = true; - } else { - this->is_pressed = false; + if(checked) + { + this->is_pressed=true; + } + else + { + this->is_pressed=false; } } diff --git a/src/UserInterface/Button/letter_classify_button.h b/src/UtilityFunction/letterclassifybutton.h similarity index 75% rename from src/UserInterface/Button/letter_classify_button.h rename to src/UtilityFunction/letterclassifybutton.h index b6b2a3d..be5f601 100644 --- a/src/UserInterface/Button/letter_classify_button.h +++ b/src/UtilityFunction/letterclassifybutton.h @@ -21,9 +21,7 @@ #include #include #include -#include "style.h" -#include "lettertooltip.h" -#include +#include "src/Style/style.h" class LetterClassifyButton : public QPushButton { @@ -32,25 +30,24 @@ public: LetterClassifyButton(QWidget *parent, bool fullscreen, QString letter - ); + ); - bool is_pressed = false; + bool is_pressed=false; private: - bool m_fullscreen = false; - LetterToolTip *tooltip = nullptr; + bool m_fullscreen=false; protected: - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); - void paintEvent(QPaintEvent *e); + void enterEvent(QEvent* e); + void leaveEvent(QEvent* e); + void paintEvent(QPaintEvent* e); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); - void focusInEvent(QEvent *e); - void focusOutEvent(QEvent *e); + void focusInEvent(QEvent* e); + void focusOutEvent(QEvent* e); Q_SIGNALS: - void buttonClicked(QAbstractButton *btn); + void buttonClicked(QAbstractButton* btn); private Q_SLOTS: void reactToToggle(bool checked); diff --git a/src/UserInterface/ListView/listview.cpp b/src/UtilityFunction/listview.cpp similarity index 54% rename from src/UserInterface/ListView/listview.cpp rename to src/UtilityFunction/listview.cpp index b034145..fccbc4a 100644 --- a/src/UserInterface/ListView/listview.cpp +++ b/src/UtilityFunction/listview.cpp @@ -17,34 +17,32 @@ */ #include "listview.h" -#include "function_button_widget.h" #include "utility.h" #include -#include +#include -ListView::ListView(QWidget *parent/*, int width, int height, int module*/): - KListView(parent) +ListView::ListView(QWidget *parent, int width, int height, int module): + QListView(parent) { - this->w = 300; - this->h = 540; - this->module = 1; + this->w = width; + this->h = height; + this->module = module; initWidget(); - listmodel = new QStandardItemModel(this); - this->setModel(listmodel); - pUkuiMenuInterface = new UkuiMenuInterface; - this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); + m_ukuiMenuInterface = new UkuiMenuInterface; + menu = new RightClickMenu(this); } - ListView::~ListView() { - delete pUkuiMenuInterface; + if (m_ukuiMenuInterface != nullptr) { + delete m_ukuiMenuInterface; + m_ukuiMenuInterface = nullptr; + } } void ListView::initWidget() { setAttribute(Qt::WA_TranslucentBackground); viewport()->setAttribute(Qt::WA_TranslucentBackground); - viewport()->setAutoFillBackground(false); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -53,7 +51,8 @@ void ListView::initWidget() this->setViewMode(QListView::ListMode); this->setContextMenuPolicy(Qt::CustomContextMenu); this->setFocusPolicy(Qt::StrongFocus); - this->setMovement(QListView::Static); + this->setMovement(QListView::Free); + this->setDragEnabled(QListView::Free); this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setUpdatesEnabled(true); this->setSpacing(0); @@ -62,14 +61,15 @@ void ListView::initWidget() this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame); this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + this->setFocus(); connect(this, &ListView::customContextMenuRequested, this, &ListView::rightClickedSlot); connect(this, &ListView::clicked, this, &ListView::onClicked); } -void ListView::addData(QVector data, int module) +void ListView::addData(QVector data) { - this->module = module; - listmodel->clear(); + listmodel = new QStandardItemModel(this); + this->setModel(listmodel); Q_FOREACH (QStringList desktopfp, data) { QStandardItem *item = new QStandardItem; @@ -90,28 +90,84 @@ void ListView::updateData(QVector data) item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); listmodel->appendRow(item); } + +// Q_EMIT dataChanged(createIndex(0,0), createIndex(listmodel->rowCount()-1,0)); } void ListView::onClicked(QModelIndex index) { QVariant var = listmodel->data(index, Qt::DisplayRole); - QString desktopfp = var.value().at(0); if (var.isValid()) { - if ((var.value().size() == 5) && (!desktopfp.endsWith(".desktop"))) { //专用于处理最近页的uri - QUrl url(desktopfp); - QDesktopServices::openUrl(url); - return; - } + Q_EMIT sendItemClickedSignal(var.value()); + } +} - if (var.value().at(1).toInt() == 0) { - Q_EMIT sendAppClassificationBtnClicked(); - } else { - execApp(desktopfp); +void ListView::rightClickedSlot(const QPoint &pos) +{ + if (!this->selectionModel()->selectedIndexes().isEmpty()) { + QModelIndex index = this->currentIndex(); +// QRect center = visualRect(index); + QVariant var = listmodel->data(index, Qt::DisplayRole); + QStringList strlist = var.value(); + + if (strlist.at(1).toInt() == 1) { + int ret = menu->showAppBtnMenu(this->mapToGlobal(pos), strlist.at(0)); + Q_EMIT sendMainWinActiveSignal(false); + + if (module > 0) { + if (strlist.at(1).toInt() == 1) { + switch (ret) { + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + + default: + break; + } + } + } else { + switch (ret) { + case 1: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 2: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + + default: + break; + } + } + + // this->selectionModel()->clear(); } } } +void ListView::dragMoveEvent(QDragMoveEvent *e) +{ + Q_UNUSED(e); +} + +void ListView::dropEvent(QDropEvent *e) +{ + Q_UNUSED(e); +} + void ListView::enterEvent(QEvent *e) { Q_UNUSED(e); @@ -127,21 +183,45 @@ void ListView::leaveEvent(QEvent *e) void ListView::paintEvent(QPaintEvent *e) { + double transparency = getTransparency(); + QPainter painter(this->viewport()); + painter.setOpacity(transparency); + painter.setPen(Qt::NoPen); + painter.setBrush(this->palette().base()); + painter.fillRect(this->rect(), this->palette().base()); //滚动条 QPalette p = this->verticalScrollBar()->palette(); - QColor color; - - if (g_curStyle == "ukui-dark") { - color = QColor("#26FFFFFF"); - } else { - color = QColor("#1A000000"); - } - + QColor color = p.color(QPalette::Light); + color.setAlphaF(0.25); p.setColor(QPalette::Active, QPalette::Button, color); this->verticalScrollBar()->setPalette(p); QListView::paintEvent(e); } +void ListView::dragLeaveEvent(QDragLeaveEvent *e) +{ + QVariant pressApp = listmodel->data(this->indexAt(startPos), Qt::DisplayRole); + QStringList m_desktopfp = pressApp.value(); + QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QFileInfo fileInfo(m_desktopfp.at(0)); + QString desktopfn = fileInfo.fileName(); + QFile file(m_desktopfp.at(0)); + QString newname = QString(path + "/" + desktopfn); + bool ret = file.copy(QString(path + "/" + desktopfn)); + + if (ret) { + char command[200]; + sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data()); + QProcess::startDetached(QString::fromLocal8Bit(command)); + } +} + +void ListView::mousePressEvent(QMouseEvent *event) +{ + startPos = event->pos(); + return QListView::mousePressEvent(event); +} + void ListView::keyPressEvent(QKeyEvent *e) { if (e->type() == QEvent::KeyPress) { @@ -173,14 +253,6 @@ void ListView::keyPressEvent(QKeyEvent *e) break; } - case Qt::Key_Right: { - break; - } - - case Qt::Key_Left: { - break; - } - default: return QListView::keyPressEvent(e); break; diff --git a/src/UserInterface/ListView/listview.h b/src/UtilityFunction/listview.h similarity index 60% rename from src/UserInterface/ListView/listview.h rename to src/UtilityFunction/listview.h index 5b14550..b20f468 100644 --- a/src/UserInterface/ListView/listview.h +++ b/src/UtilityFunction/listview.h @@ -23,25 +23,22 @@ #include #include #include -#include "style.h" -#include "rightclickmenu.h" +#include "src/Style/style.h" +#include "src/RightClickMenu/rightclickmenu.h" #include #include #include -#include "ukuimenuinterface.h" +#include "src/Interface/ukuimenuinterface.h" #include "itemdelegate.h" -#include "klistview.h" -#include -class ListView : public KListView +class ListView : public QListView { Q_OBJECT - public: - ListView(QWidget *parent/*, int width, int height, int module*/); + ListView(QWidget *parent, int width, int height, int module); ~ListView(); - void addData(QVector data, int module); + void addData(QVector data); void updateData(QVector data); protected: @@ -50,20 +47,35 @@ protected: void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *e) override; void keyPressEvent(QKeyEvent *e); + void dropEvent(QDropEvent *event); + void mousePressEvent(QMouseEvent *event); + void dragLeaveEvent(QDragLeaveEvent *e); + void dragMoveEvent(QDragMoveEvent *event); private: + QStandardItemModel *listmodel = nullptr; int w = 0; int h = 0; + int module = 0; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + + RightClickMenu *menu = nullptr; //右键菜单 + QVector data; + ItemDelegate *m_delegate = nullptr; int m_preRowCount; + QPoint startPos; +// QMimeData *mimeData = nullptr; +// QDrag *drag = nullptr; private Q_SLOTS: void onClicked(QModelIndex index);//点击item -// void rightClickedSlot(const QPoint &pos);//右键菜单 - + void rightClickedSlot(const QPoint &pos);//右键菜单 Q_SIGNALS: + void sendItemClickedSignal(QStringList arg);//发送item点击信号 + void sendHideMainWindowSignal(); + void sendUpdateAppListSignal(); void sendMainWinActiveSignal(bool flag); - void sendAppClassificationBtnClicked(); }; #endif // LISTVIEW_H diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp new file mode 100644 index 0000000..8fbc0dc --- /dev/null +++ b/src/UtilityFunction/proxystyle.cpp @@ -0,0 +1,64 @@ +/* + * 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 +#include + +ProxyStyle::ProxyStyle() +{ + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + connect(&gsetting, &QGSettings::changed, this, [ = ] { + for (auto widget : QApplication::allWidgets()) + { + widget->update(); + } + }); + } +} + +QPalette ProxyStyle::standardPalette() const +{ + auto m_palette = QProxyStyle::standardPalette(); + QColor m_highlightbg; + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting->keys().contains(QString("styleName"))) { + if (gsetting->get("style-name").toString() == "ukui-light") { + m_highlightbg = QColor(0, 0, 0); + m_highlightbg.setAlphaF(0.15); + } else { + m_highlightbg = QColor(255, 255, 255); + m_highlightbg.setAlphaF(0.14); + } + } + + m_palette.setBrush(QPalette::Highlight, m_highlightbg); + return m_palette; + } + + return m_palette; +} + +void ProxyStyle::polish(QPalette &pal) +{ + pal = standardPalette(); +// QProxyStyle::polish(pal); +} diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h new file mode 100644 index 0000000..93403a0 --- /dev/null +++ b/src/UtilityFunction/proxystyle.h @@ -0,0 +1,45 @@ +/* + * 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 +#include +#include +#include +#include +#include + +class ProxyStyle : public QProxyStyle +{ + Q_OBJECT +public: + ProxyStyle(); + +// void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; +// void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; +// void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const; + void polish(QPalette &pal); +// void polish(QWidget *widget); + QPalette standardPalette() const; + +private: + double transparency; + +}; + +#endif // INTERNALSTYLE_H diff --git a/src/UserInterface/Other/scrollarea.cpp b/src/UtilityFunction/scrollarea.cpp similarity index 56% rename from src/UserInterface/Other/scrollarea.cpp rename to src/UtilityFunction/scrollarea.cpp index 65c26e5..9c2c543 100644 --- a/src/UserInterface/Other/scrollarea.cpp +++ b/src/UtilityFunction/scrollarea.cpp @@ -20,7 +20,7 @@ #include #include #include -#include "src/UtilityFunction/utility.h" +#include "utility.h" ScrollAreaWid::ScrollAreaWid(QWidget *parent): QWidget(parent) @@ -33,64 +33,64 @@ void ScrollAreaWid::paintEvent(QPaintEvent *event) { double transparency = getTransparency(); QPainter painter(this); - // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) - // { - // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); - // if(gsetting.keys().contains(QString("effect"))) - // { - // if(gsetting.get("effect").toBool()) - // { - // painter.setBrush(Qt::black); - //// painter.setBrush(Qt::red); - // painter.setPen(Qt::transparent); - // painter.setOpacity(0.25); - // painter.drawRect(this->rect()); - // } - // else - // { - // painter.setBrush(this->palette().base()); - // painter.setPen(Qt::transparent); - // painter.setOpacity(transparency); - // painter.drawRect(this->rect()); - // } - // } - // else - // { - // painter.setBrush(this->palette().base()); - // painter.setPen(Qt::transparent); - // painter.setOpacity(transparency); - // painter.drawRect(this->rect()); - // } - // } - // else - // { +// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) +// { +// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); +// if(gsetting.keys().contains(QString("effect"))) +// { +// if(gsetting.get("effect").toBool()) +// { +// painter.setBrush(Qt::black); +//// painter.setBrush(Qt::red); +// painter.setPen(Qt::transparent); +// painter.setOpacity(0.25); +// painter.drawRect(this->rect()); +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { painter.setBrush(this->palette().base()); painter.setPen(Qt::transparent); painter.setOpacity(transparency); painter.drawRect(this->rect()); - // } +// } QWidget::paintEvent(event); } -ScrollArea::ScrollArea() +ScrollArea::ScrollArea(QWidget *parent): + QScrollArea(parent) { - // this->verticalScrollBar()->setVisible(false); - // this->setFocusPolicy(Qt::NoFocus); - //// this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - this->setFixedWidth(1330); - // this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - this->setFrameShape(QFrame::NoFrame); - // this->verticalScrollBar()->setProperty("drawScrollBarGroove",false); - // this->verticalScrollBar()->setAttribute(Qt::WA_TranslucentBackground, false); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->verticalScrollBar()->setVisible(false); + this->setFocusPolicy(Qt::NoFocus); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->setFrameShape(QFrame::NoFrame); + this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + this->verticalScrollBar()->setAttribute(Qt::WA_TranslucentBackground, false); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //滚动条设置 QPalette p = this->verticalScrollBar()->palette(); - QColor color(255, 255, 255); + QColor color = p.color(QPalette::Light); color.setAlphaF(0.25); p.setColor(QPalette::Active, QPalette::Button, color); this->verticalScrollBar()->setPalette(p); + this->setStyleSheet("QWidget{background:transparent;}QScrollBar:vertical{" + "background:none}"); } void ScrollArea::setFocusToNextChild() @@ -105,7 +105,7 @@ void ScrollArea::setFocusToPreChild() void ScrollArea::enterEvent(QEvent *e) { Q_UNUSED(e); - // this->verticalScrollBar()->setVisible(true); + this->verticalScrollBar()->setVisible(true); } //void ScrollArea::keyPressEvent(QKeyEvent* e) @@ -140,6 +140,6 @@ void ScrollArea::scrollContentsBy(int dx, int dy) { QScrollArea::scrollContentsBy(dx, dy); Q_EMIT requestUpdate(); - // update(); - // viewport()->update(); +// update(); +// viewport()->update(); } diff --git a/src/UserInterface/Other/scrollarea.h b/src/UtilityFunction/scrollarea.h similarity index 90% rename from src/UserInterface/Other/scrollarea.h rename to src/UtilityFunction/scrollarea.h index 96a5f57..e4f6d8c 100644 --- a/src/UserInterface/Other/scrollarea.h +++ b/src/UtilityFunction/scrollarea.h @@ -28,7 +28,7 @@ class ScrollAreaWid: public QWidget { public: - ScrollAreaWid(QWidget *parent); + ScrollAreaWid(QWidget *parent = nullptr); protected: void paintEvent(QPaintEvent *event); @@ -38,7 +38,7 @@ class ScrollArea : public QScrollArea { Q_OBJECT public: - ScrollArea(); + ScrollArea(QWidget *parent = nullptr); void setFocusToNextChild(); void setFocusToPreChild(); @@ -48,7 +48,7 @@ Q_SIGNALS: protected: void enterEvent(QEvent *e) Q_DECL_OVERRIDE; void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; - // void keyPressEvent(QKeyEvent* e) Q_DECL_OVERRIDE; +// void keyPressEvent(QKeyEvent* e) Q_DECL_OVERRIDE; void scrollContentsBy(int dx, int dy) override; private: diff --git a/src/BackProcess/FileWatcher/software_database_update_thread.cpp b/src/UtilityFunction/softwaredatabaseupdatethread.cpp similarity index 62% rename from src/BackProcess/FileWatcher/software_database_update_thread.cpp rename to src/UtilityFunction/softwaredatabaseupdatethread.cpp index b8c98f4..68429d2 100644 --- a/src/BackProcess/FileWatcher/software_database_update_thread.cpp +++ b/src/UtilityFunction/softwaredatabaseupdatethread.cpp @@ -1,22 +1,4 @@ -/* - * 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 #include #include @@ -27,14 +9,13 @@ #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" -SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread() +SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread(QObject *parent): + QThread(parent) { - } SoftwareDatabaseUpdateThread::~SoftwareDatabaseUpdateThread() { - } void SoftwareDatabaseUpdateThread::run() @@ -42,12 +23,12 @@ void SoftwareDatabaseUpdateThread::run() QSqlDatabase db; db = QSqlDatabase::addDatabase("QSQLITE", "SoftwareThreadDatabase"); db.setDatabaseName(DATABASENAME); - if (false == db.open()){ - myDebug() << db.lastError().text(); + + if (false == db.open()) { + qDebug() << db.lastError().text(); } QSqlQuery sql(db); - QJsonDocument jsonDocument = QJsonDocument::fromJson(m_category.toLocal8Bit().data()); QJsonObject jsonObject = jsonDocument.object(); QJsonArray jsonArray = jsonObject[jsonObject.keys()[0]].toArray(); @@ -67,13 +48,12 @@ void SoftwareDatabaseUpdateThread::run() if (number % 5000 == 0) { db.commit(); db.transaction(); - } + } } db.commit(); - + myDebug() << "数据库已经更新"; Q_EMIT updateDatabaseSignal(); - } void SoftwareDatabaseUpdateThread::getDatabaseList(QString category) diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.h b/src/UtilityFunction/softwaredatabaseupdatethread.h new file mode 100644 index 0000000..44b460d --- /dev/null +++ b/src/UtilityFunction/softwaredatabaseupdatethread.h @@ -0,0 +1,27 @@ +#ifndef SOFTWAREDATABASEUPDATETHREAD_H +#define SOFTWAREDATABASEUPDATETHREAD_H + +#include +#include +#include +#include +#include +#include +#include + +class SoftwareDatabaseUpdateThread: public QThread +{ + Q_OBJECT +public: + SoftwareDatabaseUpdateThread(QObject *parent = nullptr); + ~SoftwareDatabaseUpdateThread(); + void run(); + void getDatabaseList(QString category); +Q_SIGNALS: + void updateDatabaseSignal(); + +private: + QString m_category; +}; + +#endif // SOFTWAREDATABASEUPDATETHREAD_H diff --git a/src/UserInterface/Widget/splitbar_frame.cpp b/src/UtilityFunction/splitbarframe.cpp similarity index 73% rename from src/UserInterface/Widget/splitbar_frame.cpp rename to src/UtilityFunction/splitbarframe.cpp index 00b9d4a..68f5999 100644 --- a/src/UserInterface/Widget/splitbar_frame.cpp +++ b/src/UtilityFunction/splitbarframe.cpp @@ -16,16 +16,16 @@ * */ -#include "splitbar_frame.h" +#include "splitbarframe.h" SplitBarFrame::SplitBarFrame(QWidget *parent, QString category, int width, int height, int module): - QWidget(parent), + QFrame(parent), m_category(category), m_width(width), m_height(height), m_module(module), - m_textLabel(new QLabel), - m_line(new QFrame) + m_textLabel(new QLabel(this)), + m_line(new QFrame(this)) { initAppBtn(); } @@ -37,7 +37,7 @@ SplitBarFrame::~SplitBarFrame() void SplitBarFrame::initAppBtn() { this->setFixedSize(m_width, m_height); - // this->setStyleSheet("background:transparent"); +// this->setStyleSheet("background:transparent"); //按钮透明 this->setFocusPolicy(Qt::NoFocus); this->setAttribute(Qt::WA_TranslucentBackground); @@ -49,14 +49,14 @@ void SplitBarFrame::initAppBtn() m_textLabel->setText(m_category); m_textLabel->adjustSize(); QPalette pe = m_textLabel->palette(); - pe.setColor(QPalette::WindowText, /*pe.color(QPalette::Text)*/Qt::white); + pe.setColor(QPalette::WindowText, Qt::white); m_textLabel->setPalette(pe); m_line->setFrameShape(QFrame::HLine); m_line->setFixedHeight(1); - m_line->setFixedSize(m_width - m_textLabel->width() - 15, 1); + m_line->setFixedSize(m_width - m_textLabel->width() - 5, 1); m_line->setEnabled(false); QPalette linePe = m_line->palette(); - QColor color = /*linePe.color(QPalette::Text)*/Qt::white; + QColor color = linePe.color(QPalette::Dark); color.setAlphaF(0.10); linePe.setColor(QPalette::WindowText, color); m_line->setPalette(linePe); @@ -64,15 +64,3 @@ void SplitBarFrame::initAppBtn() layout->addWidget(m_textLabel); layout->addWidget(m_line); } - -void SplitBarFrame::paintEvent(QPaintEvent *event) -{ - double transparency = getTransparency(); - QPainter painter(this); - painter.setBrush(Qt::transparent); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); - QWidget::paintEvent(event); -} - diff --git a/src/UserInterface/Widget/splitbar_frame.h b/src/UtilityFunction/splitbarframe.h similarity index 67% rename from src/UserInterface/Widget/splitbar_frame.h rename to src/UtilityFunction/splitbarframe.h index cafd1e0..de45c3d 100644 --- a/src/UserInterface/Widget/splitbar_frame.h +++ b/src/UtilityFunction/splitbarframe.h @@ -23,12 +23,13 @@ #include #include #include -#include "style.h" -#include "ukuimenuinterface.h" -#include "rightclickmenu.h" +#include "src/Style/style.h" +#include "src/Interface/ukuimenuinterface.h" +#include "src/Style/style.h" +#include "src/RightClickMenu/rightclickmenu.h" #include "utility.h" -class SplitBarFrame : public QWidget //全屏分隔栏 +class SplitBarFrame : public QFrame //全屏分隔栏 { Q_OBJECT public: @@ -36,20 +37,35 @@ public: * @param classify为0时为分类按钮、1为应用按钮 * @param module为0时为常用模块,1为字母模块、2为功能模块 */ - SplitBarFrame(QWidget *parent, QString category, int width, int height, int module); + SplitBarFrame(QWidget *parent,QString category,int width,int height,int module); ~SplitBarFrame(); + enum Category{ + Mobile, + Internet, + Social, + Video, + Development, + Image, + Game, + Office, + Education, + System, + Safe, + Others, + }; + Q_ENUM(Category) + private: QString m_category; int m_width; int m_height; int m_module; - QLabel *m_textLabel = nullptr; - QFrame *m_line = nullptr; + QLabel* m_textLabel=nullptr; + QFrame* m_line=nullptr; protected: void initAppBtn(); - void paintEvent(QPaintEvent *event); }; #endif // PUSHBUTTON_H diff --git a/src/UtilityFunction/thumbnail.cpp b/src/UtilityFunction/thumbnail.cpp deleted file mode 100644 index 55a1f79..0000000 --- a/src/UtilityFunction/thumbnail.cpp +++ /dev/null @@ -1,244 +0,0 @@ -#include "thumbnail.h" -#include -#include "style.h" -#include -#include -#include -#include - -ThumbNail::ThumbNail(QWidget *parent): - QWidget(parent) -{ - pUkuiMenuInterface = new UkuiMenuInterface; - initUi(); - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; - setting = new QSettings(path, QSettings::IniFormat); - QString pathini = QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"; - disableSetting = new QSettings(pathini, QSettings::IniFormat); -} - -void ThumbNail::initUi() -{ - setWindowFlags(Qt::FramelessWindowHint); - setAttribute(Qt::WA_TranslucentBackground); - this->setStyleSheet("border:0px;background:transparent;"); - this->setFixedSize(Style::AppListIconSize, Style::AppListIconSize); - iconLabel = new QLabel(this); - iconLabel->setStyleSheet("border:0px;background-color:transparent;"); - iconLabel->setFocusPolicy(Qt::NoFocus); - iconLabel->setFixedSize(Style::AppListIconSize, Style::AppListIconSize); - layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - layout->addWidget(iconLabel); -} - -ThumbNail::~ThumbNail() -{ - if (pUkuiMenuInterface) { - delete pUkuiMenuInterface; - } - - if (setting) { - delete setting; - } - - if (disableSetting) { - delete disableSetting; - } - - if (iconLabel) { - delete iconLabel; - } - - if (m_icon) { - delete m_icon; - } - - pUkuiMenuInterface = nullptr; - setting = nullptr; - disableSetting = nullptr; - iconLabel = nullptr; - - if (layout) { - delete layout; - } -} - -void ThumbNail::setupthumbnail(QString desktopfp) -{ - QString fn = desktopfp.split('/').last(); - setting->beginGroup("groupname"); - QStringList keyList = setting->allKeys(); - bool isgroup = setting->contains(fn); - - if (!isgroup) { - QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); - QString appname = pUkuiMenuInterface->getAppName(desktopfp); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull()) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } - } - } - - // QPixmap pixmap = icon.pixmap((Style::AppListIconSize,Style::AppListIconSize),QIcon::Selected,QIcon::Off); - QPixmap pixmap ; - - if (appDisable(desktopfp) == 1) { - pixmap = icon.pixmap((Style::AppListIconSize, Style::AppListIconSize), QIcon::Disabled, QIcon::Off); - //qDebug()<<"appDisable(desktopfp)"<setPixmap(pixmap); - } else { - int k = 0; - iconLabel->setStyleSheet("border:0px;background: rgba(0, 0, 0, 0.25);border-radius: 16px;"); - QGridLayout *iconLayout = new QGridLayout(); - iconLayout->setContentsMargins(0, 0, 0, 0); - iconLayout->setSpacing(0); - iconLabel->setLayout(iconLayout); - - for (int i = 0; i < 3; i++) { - for (int j = 1; j < 4; j++) { - if (k < keyList.size()) { - QString fp; - - if (UkuiMenuInterface::androidDesktopfnList.contains(keyList.at(k))) { - fp = QString(QDir::homePath() + "/.local/share/applications/" + keyList.at(i)); - } else { - fp = "/usr/share/applications/" + keyList.at(k); - } - - m_icon = new QLabel; - m_icon->setFixedSize(28, 28); - QPixmap pixmap = getIcon(fp, 28, 28); - // QPixmap pixmap = icon.pixmap((28,28),QIcon::Selected,QIcon::Off); - m_icon->setPixmap(pixmap); - iconLayout->addWidget(m_icon, i, j - 1); - k = k + 1; - } else { - break; - } - } - } - } -} - -QPixmap ThumbNail::getIcon(QString desktopfp, int width, int height) -{ - QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull()) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } - } - } - - if (appDisable(desktopfp) == 1) { - //return icon.pixmap((width,height),QIcon::Selected,QIcon::Off); - return icon.pixmap((width, height), QIcon::Disabled, QIcon::Off); - } - - return icon.pixmap((width, height), QIcon::Selected, QIcon::Off); -} - -bool ThumbNail::appDisable(QString desktopfp)//判断是否是禁用应用(这个还有问题暂时不会用) -{ - QString str; - //打开文件.desktop - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); - //取出value值 - QString execnamestr = QString::fromLocal8Bit(name); - //处理value值 - str = execnamestr; - // str = execnamestr.section(' ', 0, 0); - // QStringList list = str.split('/'); - // str = list[list.size()-1]; - //关闭文件 - g_key_file_free(keyfile); - QString desktopfp1 =/*"application/"+*/str; - //QString group=desktopfp.split('/').last(); - disableSetting->beginGroup("application"); - //判断 - bool bo = disableSetting->contains(desktopfp1.toLocal8Bit().data()); // iskey - bool bo1 = disableSetting->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool(); //isvalue - disableSetting->endGroup(); - - //qDebug()< -#include -#include -#include "ukuimenuinterface.h" -#define TEXT_LENGTH 100 //文字长度 - -class ThumbNail : public QWidget -{ - Q_OBJECT -public: - ThumbNail(QWidget *parent = nullptr); - ~ThumbNail(); - void setupthumbnail(QString desktopfp); - QPixmap getIcon(QString desktopfp, int width, int height); - bool appDisable(QString desktopfp); - -private: - QLabel *iconLabel = nullptr; - QVBoxLayout *layout = nullptr; - QLabel *m_icon = nullptr; - QLabel *textLabel = nullptr; - UkuiMenuInterface *pUkuiMenuInterface = nullptr; - QString appIcon = nullptr; - QSettings *setting = nullptr; - QSettings *disableSetting = nullptr; - -private: - void initUi(); -}; - -#endif // THUMBNAIL_H diff --git a/src/UserInterface/Button/tool_button.cpp b/src/UtilityFunction/toolbutton.cpp similarity index 83% rename from src/UserInterface/Button/tool_button.cpp rename to src/UtilityFunction/toolbutton.cpp index 9e430e6..51b1f92 100644 --- a/src/UserInterface/Button/tool_button.cpp +++ b/src/UtilityFunction/toolbutton.cpp @@ -16,7 +16,7 @@ * */ -#include "tool_button.h" +#include "toolbutton.h" #include ToolButton::ToolButton(int width, @@ -55,11 +55,18 @@ ToolButton::ToolButton(int width, if (module == 2) { this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->setText(tr(text.toLocal8Bit().data())); - // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); +// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); } - // else - // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); +// else +// this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); +} +ToolButton::~ToolButton() +{ + if (pixmap != nullptr) { + delete pixmap; + pixmap = nullptr; + } } void ToolButton::enterEvent(QEvent *e) @@ -75,6 +82,7 @@ void ToolButton::enterEvent(QEvent *e) sprintf(style, "border:0px;padding-left:0px;background-color:%s;", hover); } +// this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; svgRender = new QSvgRenderer(this); svgRender->load(piconstr); @@ -96,15 +104,15 @@ void ToolButton::enterEvent(QEvent *e) void ToolButton::leaveEvent(QEvent *e) { Q_UNUSED(e); - // if(module==2) - // { - // if(!is_pressed) - // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); - // else - // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255);font-size:14px;"); - // } - // else - // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); +// if(module==2) +// { +// if(!is_pressed) +// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); +// else +// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255);font-size:14px;"); +// } +// else +// this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); delete svgRender; svgRender = new QSvgRenderer(this); @@ -141,7 +149,7 @@ void ToolButton::mousePressEvent(QMouseEvent *event) } if (event->button() == Qt::LeftButton) { - // this->setStyleSheet(QString::fromLocal8Bit(style)); +// this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; svgRender = new QSvgRenderer(this); svgRender->load(piconstr); @@ -175,7 +183,7 @@ void ToolButton::mouseReleaseEvent(QMouseEvent *event) } if (event->button() == Qt::LeftButton) { - // this->setStyleSheet(QString::fromLocal8Bit(style)); +// this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; svgRender = new QSvgRenderer(this); svgRender->load(piconstr); diff --git a/src/UserInterface/Button/tool_button.h b/src/UtilityFunction/toolbutton.h similarity index 92% rename from src/UserInterface/Button/tool_button.h rename to src/UtilityFunction/toolbutton.h index 8634fb2..24caaf7 100644 --- a/src/UserInterface/Button/tool_button.h +++ b/src/UtilityFunction/toolbutton.h @@ -46,6 +46,7 @@ public: QString pressedbg, int module, QString text); + ~ToolButton(); bool is_pressed = false; //记录功能分类模块点击状态 @@ -55,10 +56,10 @@ private: QString hoverbg; QString pressedbg; int module; - QLabel *label; - QHBoxLayout *layout; - QPixmap *pixmap; - QSvgRenderer *svgRender; + QLabel *label = nullptr; + QHBoxLayout *layout = nullptr; + QPixmap *pixmap = nullptr; + QSvgRenderer *svgRender = nullptr; QString text; protected: diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp index a524fb2..48a16f3 100644 --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -27,12 +27,12 @@ #include #include #include -#include #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" -QString g_projectCodeName = "V10SP1"; -bool g_menuStatus = false; -QString g_curStyle = ""; + +bool isHuaWeiPC = false; +bool isHuaWei9006C = false; +QString projectCodeName = ""; const QPixmap loadSvg(const QString &fileName, const int size) { @@ -99,81 +99,6 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) return QPixmap::fromImage(img); } -QIcon getCurIcon(const QString &iconPath, bool autoSet) -{ - QPixmap pixmap; - - if (iconPath.endsWith("png")) { - pixmap = QPixmap(iconPath); - } else { - pixmap = loadSvg(iconPath, 16); - } - - if (!autoSet) { - return drawSymbolicColoredPixmap(pixmap); - } - - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.keys().contains(QString("styleName"))) { - if (gsetting.get("style-name").toString() == "ukui-light" - || gsetting.get("style-name").toString() == "ukui-default") { - pixmap = drawSymbolicBlackColoredPixmap(pixmap); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); - } - } - } - - return QIcon(pixmap); -} - -//不通过任务栏获取屏幕可用区域数据 -QVariantList getScreenGeometryList() -{ - QRect rect; - rect = qApp->primaryScreen()->geometry(); - int panelSize = 0; - int position = 0; - QVariantList list; - list.clear(); - QDBusInterface iface(DBUS_NAME, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); - - if (reply.isValid()) { - panelSize = reply.value().at(4).toInt(); - position = reply.value().at(5).toInt(); - } - - QList posIndex; - - switch (position) { - case BOTTOM: - posIndex = {0, 0, 0, -1}; - break; - case TOP: - posIndex = {0, 1, 0, -1}; - break; - case LEFT: - posIndex = {1, 0, -1, 0}; - break; - case RIGHT: - posIndex = {0, 0, -1, 0}; - } - - list.append(rect.x() + posIndex[0] * panelSize); - list.append(rect.y() + posIndex[1] * panelSize); - list.append(rect.width() + posIndex[2] * panelSize); - list.append(rect.height() + posIndex[3] * panelSize); - list.append(panelSize); - list.append(position); - return list; -} - double getTransparency() { double transparency = 0.0; @@ -189,21 +114,6 @@ double getTransparency() return transparency; } -void centerToScreen(QWidget *widget) -{ - if (!widget) { - return; - } - - QDesktopWidget *deskTopWidget = QApplication::desktop(); - QRect deskRect = deskTopWidget->screenGeometry(deskTopWidget->screenNumber(QCursor::pos())); - int deskWidth = deskRect.width(); - int deskHeight = deskRect.height(); - int x = QApplication::primaryScreen()->geometry().width(); - int y = QApplication::primaryScreen()->geometry().height(); - widget->move(deskWidth / 2 - x / 2 + deskRect.left(), deskHeight / 2 - y / 2 + deskRect.top()); -} - void debugLog(QString strMsg) { QString path = QDir::homePath() + "/.config/ukui/ukui-menu.log"; @@ -220,29 +130,6 @@ void debugLog(QString strMsg) } } -QString getEnvOverriddenDesktopFile(int pid) -{ - QString ret; - QString path = QString("/proc/%1/environ") - .arg(pid); - QFile file(path); - - if (file.open(QIODevice::ReadOnly)) { - QList list = file.readLine().split('\x00'); - - Q_FOREACH (QByteArray array, list) { - if (array.contains("GIO_LAUNCHED_DESKTOP_FILE=")) { - ret = QString(array.split('=').at(1)); - break; - } - } - - file.close(); - } - - return ret; -} - void openDataBase(QString connectionName) { QSqlDatabase db; @@ -271,15 +158,15 @@ void initDatabase() if (sql.next()) { if (sql.value(0).toInt() == 0) { - QSettings *setting = new QSettings("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); - setting->beginGroup("application"); + QSettings setting("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); + setting.beginGroup("application"); QString desktopfp; - Q_FOREACH (QString desktopfn, setting->allKeys()) { - if (setting->value(desktopfn).toInt() == 1) { + Q_FOREACH (QString desktopfn, setting.allKeys()) { + if (setting.value(desktopfn).toInt() == 1) { desktopfp.clear(); - if (UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) { + if (UkuiMenuInterface::m_androidDesktopfnList.contains(desktopfn)) { desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); } else { desktopfp = QString("/usr/share/applications/" + desktopfn); @@ -287,7 +174,7 @@ void initDatabase() QFileInfo info(desktopfp); - if (!info.isFile() || !UkuiMenuInterface::desktopfpVector.contains(desktopfp)) { + if (!info.isFile() || !UkuiMenuInterface::m_desktopfpVector.contains(desktopfp)) { continue; } @@ -295,27 +182,22 @@ void initDatabase() } } - setting->endGroup(); - delete setting; + setting.endGroup(); } } - bool b = sql.exec("create table if not exists appInfo(desktop char primary key, times int, time int, type int, recent int, num int, collect int)"); + sql.exec("create table if not exists appInfo(desktop char primary key, times int, time int, type int, recent int)"); Q_FOREACH (QString desktopfn, desktopfnList) { - myDebug() << "void initDatabase()" << desktopfn; QDateTime dt = QDateTime::currentDateTime(); int datetime = dt.toTime_t(); - QString cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") + QString cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") .arg(desktopfn) .arg(0) .arg(datetime) .arg(1) - .arg(0) - .arg(0) .arg(0); - bool a = sql.exec(cmd); - myDebug() << "数据库执行是否成功" << a; + sql.exec(cmd); } sql.exec("create table appCategory(app_name char primary key, name_en char, name_zh char)"); @@ -355,13 +237,11 @@ bool updateDataBaseTableTimes(QString desktopfn) .arg(0) .arg(desktopfn); } else { - cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") + cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") .arg(desktopfn) .arg(1) .arg(datetime) .arg(0) - .arg(0) - .arg(0) .arg(0); } @@ -371,137 +251,6 @@ bool updateDataBaseTableTimes(QString desktopfn) return ret; } -bool updateDataBaseCollect(QString desktopfn, int type) -{ - bool ret = false; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); - QSqlQuery sql(db); - QString cmd; - - switch (type) { - case 0: { //取消收藏 - cmd = QString("update appInfo set collect=%1 where desktop=\"%2\"") - .arg(type) - .arg(desktopfn); - ret = sql.exec(cmd); - } - break; - - default: { //收藏 - cmd = QString("select type from appInfo where desktop=\"%1\"") - .arg(desktopfn); - - if (sql.exec(cmd)) { - if (sql.next()) { //更新记录 - cmd = QString("update appInfo set collect=%1 where desktop=\"%2\"") - .arg(type) - .arg(desktopfn); - } else { //添加记录 - QDateTime dt = QDateTime::currentDateTime(); - int datetime = dt.toTime_t(); - cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") - .arg(desktopfn) - .arg(0) - .arg(datetime) - .arg(0) - .arg(0) - .arg(0) - .arg(type); - } - - ret = sql.exec(cmd); - } - } - break; - } - - return ret; -} - -QStringList getCollectAppList() -{ - QStringList list; - int count = 0; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); - QSqlQuery sql(db); - QSqlQuery sqlque(db); - QString cmd = QString("select desktop from appInfo where collect!=0 order by collect"); - - if (sql.exec(cmd)) { - while (sql.next()) { - list.append(sql.value(0).toString()); - sqlque.exec(QString("update appInfo set collect=%1 where desktop=\"%2\"") - .arg(++count) - .arg(sql.value(0).toString())); - } - } - - collectCount = list.size() + 1; - return list; -} - -int getCollectAppCount(QString desktopfn) -{ - int appCount = 0; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); - QSqlQuery sql(db); - QString cmd = QString("select collect from appInfo where desktop=\"%1\"") - .arg(desktopfn); - - if (sql.exec(cmd)) { - if (sql.next()) { - appCount = sql.value(0).toInt(); - } - } - - return appCount; -} - -void changeCollectSort(QString dragDesktopfn, QString dropDesktopfn) -{ - int endNum = getCollectAppCount(dropDesktopfn); - int startNum = getCollectAppCount(dragDesktopfn); - QStringList applist = getCollectAppList(); - - if (startNum < endNum) { - updateDataBaseCollect(dragDesktopfn, endNum + 1); - - for (int i = endNum; i < applist.count(); i++) { - updateDataBaseCollect(applist.at(i), i + 2); - } - } else { - updateDataBaseCollect(dragDesktopfn, endNum); - - for (int i = endNum - 1; i < applist.count(); i++) { - if (dragDesktopfn != applist.at(i)) { - updateDataBaseCollect(applist.at(i), i + 2); - } - } - } -} - -bool checkIfCollected(QString desktopfn) -{ - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); - QSqlQuery sql(db); - QString cmd = QString("select collect from appInfo where desktop=\"%1\"") - .arg(desktopfn); - - if (sql.exec(cmd)) { - if (!sql.next()) { - return false; - } else { - if (sql.value(0).toInt() == 0) { - return false; - } else { - return true; - } - } - } - - return false; -} - bool updateDataBaseTableType(QString desktopfn, int type) { bool ret = false; @@ -511,9 +260,7 @@ bool updateDataBaseTableType(QString desktopfn, int type) switch (type) { case 0: { //解除锁定 - cmd = QString("update appInfo set times=%1,type=%2 where desktop=\"%3\"") - .arg(0) - .arg(type) + cmd = QString("delete from appInfo where desktop=\"%1\"") .arg(desktopfn); ret = sql.exec(cmd); } @@ -531,13 +278,11 @@ bool updateDataBaseTableType(QString desktopfn, int type) } else { //添加记录 QDateTime dt = QDateTime::currentDateTime(); int datetime = dt.toTime_t(); - cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") + cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") .arg(desktopfn) .arg(0) .arg(datetime) .arg(type) - .arg(0) - .arg(0) .arg(0); } @@ -561,13 +306,12 @@ bool updateDataBaseTableRecent(QString desktopfn) QString cmd; QDateTime dt = QDateTime::currentDateTime(); int datetime = dt.toTime_t(); - cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5)") + cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") .arg(desktopfn) .arg(0) .arg(datetime) .arg(0) - .arg(1) - .arg(0); + .arg(1); ret = sql.exec(cmd); return ret; } @@ -759,12 +503,13 @@ QString getUserName() objPath.value().path(), "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); - // QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","RealName"); - // name=var.value().toString(); - // if(name.isEmpty()) - // { - QDBusReply var = useriface.call("Get", "org.freedesktop.Accounts.User", "UserName"); + QDBusReply var = useriface.call("Get", "org.freedesktop.Accounts.User", "RealName"); name = var.value().toString(); - // } + + if (name.isEmpty()) { + var = useriface.call("Get", "org.freedesktop.Accounts.User", "UserName"); + name = var.value().toString(); + } + return name; } diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h index f5e9a2e..1a5bc82 100644 --- a/src/UtilityFunction/utility.h +++ b/src/UtilityFunction/utility.h @@ -23,17 +23,22 @@ #include #include #include -#include +#include +#include #include -#include "ukuimenuinterface.h" +#include "src/Interface/ukuimenuinterface.h" #define DBUS_NAME "org.ukui.panel" #define DBUS_PATH "/panel/position" #define DBUS_INTERFACE "org.ukui.panel" #define myDebug() qDebug() << QString("%1 %2 行 %3").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__) +#define KFILENAME QString(__FILE__).mid(QString(__FILE__).lastIndexOf("/") + 1) +#define KFUNCNAME QString(__FUNCTION__) -static int collectCount = 0; +extern bool isHuaWeiPC; +extern bool isHuaWei9006C; +extern QString projectCodeName; const QPixmap loadSvg(const QString &fileName, const int size); @@ -45,9 +50,8 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source); //调试日志 void debugLog(QString strMsg); -QVariantList getScreenGeometryList(); + double getTransparency(); -QString getEnvOverriddenDesktopFile(int pid); //数据库操作 void openDataBase(QString connectionName); void closeDataBase(QString connectionName); @@ -57,10 +61,6 @@ bool updateDataBaseTableType(QString desktopfn, int type);//更新是否锁定 bool updateDataBaseTableRecent(QString desktopfn);//更新最近添加 bool checkIfLocked(QString desktopfn);//检查是否被锁定 bool checkIfRecent(QString desktopfn);//检查是否最近安装 -bool checkIfCollected(QString desktopfn); -QStringList getCollectAppList(); -void changeCollectSort(QString dragDesktopfn, QString dropDesktopfn); -bool updateDataBaseCollect(QString desktopfn, int type); QStringList getLockAppList();//获取被锁定应用 QStringList getUnlockAllList();//获取未被锁定应用 void cleanTimeoutApp();//清理超时应用 @@ -70,24 +70,16 @@ bool deleteAppRecord(QString desktopfn);//删除应用记录 void execApp(QString desktopfp); bool checkOsRelease();//区分社区办与商业版 -void centerToScreen(QWidget *widget); -QIcon getCurIcon(const QString &iconPath, bool autoSet); - //获取用户图像 QString getUserIcon(); //获取用户姓名 QString getUserName(); -enum PanelPositon { +enum PanelPositon{ BOTTOM = 0, TOP = 1, LEFT = 2, RIGHT = 3 }; -extern QString g_projectCodeName; -extern bool g_menuStatus; -extern QString g_curStyle; - - #endif // UTILITY_H diff --git a/src/UtilityFunction/utilityfunction.pri b/src/UtilityFunction/utilityfunction.pri deleted file mode 100644 index 3cc89d4..0000000 --- a/src/UtilityFunction/utilityfunction.pri +++ /dev/null @@ -1,16 +0,0 @@ -INCLUDEPATH += \ - $$PWD \ - $$PWD/Style - -HEADERS += \ - $$PWD/AbstractInterface.h \ - $$PWD/KySmallPluginInterface.h \ - $$PWD/Style/style.h \ - $$PWD/abstractInterface.h \ - $$PWD/thumbnail.h \ - $$PWD/utility.h - -SOURCES += \ - $$PWD/Style/style.cpp \ - $$PWD/thumbnail.cpp \ - $$PWD/utility.cpp diff --git a/translations/ukui-menu_bo.qm b/translations/ukui-menu_bo.qm deleted file mode 100644 index be651ee..0000000 --- a/translations/ukui-menu_bo.qm +++ /dev/null @@ -1 +0,0 @@ - - - - - FullMainWindow - - - Search - - - - - All - - - - - Letter - - - - - Function - - - - - FunctionWidget - - - Search - - - - - MainWindow - - - ... - - - - - collection - - - - - - - All - - - - - Search - - - - - recent - - - - - Max - - - - - PowerOff - - - - - - Letter - - - - - - Function - - - - - QObject - - - - Office - - - - - - Development - - - - - - Image - - - - - - Video - - - - - - Internet - - - - - - Game - - - - - - Education - - - - - - Social - - - - - - System - - - - - - Safe - - - - - - Others - - - - - RightClickMenu - - - Pin to all - - - - - Unpin from all - - - - - Pin to taskbar - - - - - Unpin from taskbar - - - - - Add to desktop shortcuts - - - - - Pin to collection - - - - - Remove from collection - - - - - Uninstall - - - - - Switch user - - - - - Hibernate - - - - - Sleep - - - - - Lock Screen - - - - - Log Out - - - - - Restart - - - - - Power Off - - - - - Personalize this list - - - - - TabletRightClickMenu - - - Pin to taskbar - - - - - Unpin from taskbar - - - - - Add to desktop shortcuts - - - - - Uninstall - - - - diff --git a/translations/ukui-menu_bo_CN.ts b/translations/ukui-menu_bo_CN.ts new file mode 100644 index 0000000..f3b9875 --- /dev/null +++ b/translations/ukui-menu_bo_CN.ts @@ -0,0 +1,302 @@ + + + + + FunctionClassifyButton + + + Mobile + གནས་སྤོར། + + + + Internet + སྦྲེལ་རེས་དྲ་རྒྱ། + + + + Social + འབྲེལ་འདྲིས། + + + + Video + བརྙན་ཟློས། + + + + Development + གསར་སྤེལ། + + + + Image + པར་རིས།། + + + + Game + རོལ་རྩེད། + + + + Office + གཞུང་ལས།དྲ་རྒྱ། + + + + Education + སློབ་གསོ། + + + + System + རྒྱུད་ཁོངས། + + + + Safe + + + + + Others + གཞན་དག + + + + MainViewWidget + + + Search + འཚོལ་བ། + + + + QObject + + + Office + གཞུང་ལས།དྲ་རྒྱ། + + + + Development + གསར་སྤེལ། + + + + Image + པར་རིས།། + + + + Video + བརྙན་ཟློས། + + + + Internet + སྦྲེལ་རེས་དྲ་རྒྱ། + + + + Game + རོལ་རྩེད། + + + + Education + སློབ་གསོ། + + + + Social + འབྲེལ་འདྲིས། + + + + System + རྒྱུད་ཁོངས། + + + + Safe + + + + + Others + གཞན་དག + + + + RightClickMenu + + + Pin to all + “ མཉེན་ཆས་ཆ་ཚང་། ” དུ་འཇོག་པ། + + + + Unpin from all + “ མཉེན་ཆས་ཆ་ཚང་། ” ལས་ལེན་པ། + + + + Pin to taskbar + འགན་བྱང་དུ་འཇོག་པ། + + + + Unpin from taskbar + འགན་བྱང་ནས་ལེན་པ། + + + + Add to desktop shortcuts + ཅོག་ངོས་སུ་མྱུར་འཐེབ་སྣོན་པ། + + + + Uninstall + ལྷུ་གཏོར + + + + Sleep + མལ་གསོ། + + + + Log Out + རྩིས་ཐེམ་ནས་བསུབ་པ། + + + + Restart + བསྐྱར་སློང་། + + + + Power Off + འཁོར་ཁ་རྒྱག་པ། + + + + Personalize this list + མགོ་རྩོམ་གདམ་བྱང་གི་རིམ་བྱང་སྒྲིག་འགོད་བྱེད་པ། + + + + SideBarWidget + + + All + མཉེན་ཆས་ཚང་མ། + + + + Letter + འཕྲིན་ཡིག + + + + Function + བྱེད་ནུས། + + + + Trash + སྙིགས་སྒམ། + + + + Computer + རྩིས་ཆས། + + + + Max + ཆེས་ཆེ་བ། + + + + Personal + མི་སྒེར། + + + + Settings + སྒྲིག་འགོད། + + + + Power + ཁ་རྒྱག་པ། + + + + SplitBarFrame + + + Mobile + གནས་སྤོར། + + + + Internet + སྦྲེལ་རེས་དྲ་རྒྱ། + + + + Social + འབྲེལ་འདྲིས། + + + + Video + བརྙན་ཟློས། + + + + Development + གསར་སྤེལ། + + + + Image + པར་རིས།། + + + + Game + རོལ་རྩེད། + + + + Office + གཞུང་ལས།དྲ་རྒྱ། + + + + Education + སློབ་གསོ། + + + + System + རྒྱུད་ཁོངས། + + + + Safe + सुरक्षा + + + + Others + གཞན་དག + + + diff --git a/translations/ukui-menu_tr.qm b/translations/ukui-menu_tr.qm deleted file mode 100644 index 927e24f891f983acc5806a2019044d7970e5bc5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2709 zcmcgsU1%It6h4#9%>E=UC8*>f;Mhlvu~oDPeMxMRRui&jo7C1qJ3DiC_jYIREHigo z5_}RLe2Rz`f-Q)kA`-+0AF5C)p&~7a&?1Q7llb#c6nu~%dGNb4o7wE{Y%E0$?4Hcd zIp6ut_nmtWUvWln{(kx5*AI_fJNxd{AEt;jlj!I;g?}n)12p*EQ$zz#QsL0Ih!&lC z^a~l#sNE%n&eTd4aob#fVT@QObE`6l3a6g68v{mn(-Z0hIk zyor26zx3KV-oMw1x1*@Nt-t>c@KaCd8*f}k{+j;DM_2KDR=;se09P2luKtMU&!U*# zOn*8GzWQS3hOvbAk7RCsh&p2;yME{oqV#MOGvDW4-*^Rim!g9>~BaHR-x(#QaRt zb>}TEPH^FP7c`ZsC6r6zREvv^IVL6Z z`;{6f^~q|d7n$YT)q6{iSf1ccg~@QH{tD#oZTjxAyPUkcY>%nCQy-)P1oB`CWP+J) z_}vz4=ml-{A|do+~K%>tZr3$llN%{0IT-PN5q=M;F)6r8zNXQ|NWq&zymUA3B)R( z))F8hs2z+^jD>QU+r52rbc8rmK;K=tvda7*VW1+U4$#RWx1C+|Y;J`Ir$ek^Du&$D zOl@_I;z}S{y$3r-%gA<+>&3|WGIyBQllnBxgFt}KHohgkO{!@J!(UcF(A^mxLRxso zsD@uy3_CjMIHvSWhXpn1HO!#u`O!Wg4z&`?V%K-I);!a+*y-fn6`bDmu@i?+{Lbe$xy$ zxPN-itC$PTa7B{3Phf&3x~h&!GBpFo^PjYe|CL}&JA>aj7;+LZ?gItvfhR1NuQF3s zd0@Ic=-Xv%=SGF_$`oZ$33#0|<_cUW`K{Jvn=s-y&4QW_YUcs-3#gZLFmMwS}m~Y~YsBKG9aEwlZj=(f(M+Hbskp<1vd28dO z7g-=Jzpp|g;W@2^Ud&@v9cso}>qVEbM!){UA#0Z$c;7y$*(JdRI`)_HK+BUZ(ZW53 z>!IH`KA55#JHI3vaH{Nk^}W2B*~2Rbuu7^9zgkB~tzS~xkzH;7!O8#hBDnv!RdSh3 WSfGDxJNvh|8@Kyc|4)`A6ZjiS|3C}? diff --git a/translations/ukui-menu_tr.ts b/translations/ukui-menu_tr.ts index 6dc6e3e..a89dde3 100644 --- a/translations/ukui-menu_tr.ts +++ b/translations/ukui-menu_tr.ts @@ -1,74 +1,67 @@ - - FullMainWindow - - - Search - Ara - - - - All - Tümü - - - - Letter - Alfabetik - - - - Function - Kategori - - FunctionClassifyButton + Mobile - Mobil + Mobil + Internet - İnternet + İnternet + Social - Sosyal + Sosyal + Video - Video + Video + Development - Programlama + Programlama + Image - Grafik + Grafik + Game - Oyunlar + Oyunlar + Office - Ofis Uygulamaları + Ofis Uygulamaları + Education - Eğitim + Eğitim + System - Sistem + Sistem + + Safe + + + + Others - Diğer + Diğer @@ -117,128 +110,13 @@ Others Diğer - - - Search - Ara - - - - GetModelData - - Mobile - Mobil - - - Internet - İnternet - - - Social - Sosyal - - - Video - Video - - - Development - Programlama - - - Image - Grafik - - - Game - Oyunlar - - - Office - Ofis Uygulamaları - - - Education - Eğitim - - - System - Sistem - - - Others - Diğer - MainViewWidget - All - Tümü - - - Letter - Alfabetik - - - Function - Kategori - - + Search - Ara - - - - MainWindow - - - ... - - - - - collection - - - - - - - All - Tümü - - - - Search - Ara - - - - recent - - - - - Max - - - - - PowerOff - - - - - - Letter - Alfabetik - - - - - Function - Kategori + Ara @@ -291,68 +169,57 @@ QObject - - + Office Ofis Uygulamaları - - + Development Programlama - - + Image Grafik - - + Video Video - - + Internet İnternet - - + Game Oyunlar - - + Education Eğitim - - + Social Sosyal - - + System Sistem - - + Safe - - + Others Diğer @@ -360,86 +227,69 @@ RightClickMenu - + Pin to all Tümünü sabitle - + Unpin from all Tüm sabitlemeleri kaldır - + Pin to taskbar Görev çubuğuna sabitle - + Unpin from taskbar Görev çubuğundan sabitlemeyi kaldır - + Add to desktop shortcuts Masaüstü kısayollarına ekle - - Pin to collection - - - - - Remove from collection - - - - + Uninstall Kaldır - - Switch user - - - - Hibernate - Beklemeye Al + Beklemeye Al - + Sleep Uyku Modu - Lock Screen - Ekranı Kilitle + Ekranı Kilitle Switch User Kullanıcı Değiştir - + Log Out Çıkış - + Restart Yeniden Başlat - + Power Off Kapat - + Personalize this list Bu listeyi özelleştirin @@ -447,59 +297,123 @@ SideBarWidget + All - Tümü + Tümü + Letter - Alfabetik + Alfabetik + Function - Kategori + Kategori + Trash - Çöp + Çöp + Computer - Bilgisayar + Bilgisayar + + Max + + + + Personal - Kişisel + Kişisel + Settings - Ayarlar + Ayarlar Recycle Bin Çöp + Power - Kapat + Kapat SplitBarFrame + Mobile - Mobil + Mobil + Internet - İnternet + İnternet + Social - Sosyal + Sosyal + Video - Video + Video + + + + Development + Programlama + + + + Image + Grafik + + + + Game + Oyunlar + + + + Office + Ofis Uygulamaları + + + + Education + Eğitim + + + + System + Sistem + + + + Safe + + + + + Others + Diğer + + + + UkuiMenuInterface + + Office + Ofis Uygulamaları Development @@ -509,18 +423,26 @@ Image Grafik + + Video + Video + + + Internet + İnternet + Game Oyunlar - - Office - Ofis Uygulamaları - Education Eğitim + + Social + Sosyal + System Sistem @@ -530,34 +452,4 @@ Diğer - - TabletRightClickMenu - - - Pin to taskbar - Görev çubuğuna sabitle - - - - Unpin from taskbar - Görev çubuğundan sabitlemeyi kaldır - - - - Add to desktop shortcuts - Masaüstü kısayollarına ekle - - - - Uninstall - Kaldır - - - - TimeWidget - - Search - Ara - - diff --git a/translations/ukui-menu_zh_CN.qm b/translations/ukui-menu_zh_CN.qm deleted file mode 100644 index e8865871b3920806150ebcecabebfd9694b0317c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2320 zcmb7EZDo9}ctv&&QsuhI*)O*X1LiqxZPS);&gu z>9mlIy0e}-c)#D1nfMOyriIMog=2RgfIhtF%ZVY#V}*r|^>18Sei(eJysPm>@Oe`~ zh&|;51{IKhoN>VoV&Lc8q^c~Sw;`pfO@gAeE1IOI9VXMokMDlLGXvicwyPnfiH4$U z6(wEm(JAq#o(z#Njo2`7qM|^m*}1%DIQ3pZ5X3@4lq(7Xa(BHcsvxlPYgeQQHXP1> z;UYw5ZEdY->zP%jeMe@q=IKTmeXdT-CR4bsT!_4%<@k zhu>czRF9~uDkg&~iylFltAxxXu!uFo*0mP}3&e$=;y$eE@mQYC2AV_LAWCj`DBQ98 zIPr9UCZ$B-)#8*Awe_LJgh+iZ#IPB7-2)QFyn$o-o9ekt@y1D-qfFL{-FS6V_7J9Mzc-L?W_{dW36E<(g{8_O(6l`h{P^)r9IJ z?u_n#%DqLjo)$$jLksy2j!iI+B`?|CrFmKD3fl!=WU2jG{*YX#*qhfILNXc>tnZLb zXev;Aw%ob1#pMr|T`-S-+Dx-QyH6q&R`EEd_hBxa&|}>E`BHnQT2~V>%j2XWBr3L+ zN(*U@u<4+RaoileU2;@#M`kDCy0>VG2HutXUge)I9$D~uY|!i_aqw=@;xN2iU31th t@lRXLFEj8J8O$??{0hDP_AYA`LMk?FX8XSvqq4 - FullMainWindow + FunctionClassifyButton - - Search - 搜索应用 + + Mobile + 移动 - - All - 全部 + + Internet + 网络 - - Letter - 字母排序 + + Social + 社交 - - Function - 功能分类 + + Video + 影音 + + + + Development + 开发 + + + + Image + 图像 + + + + Game + 游戏 + + + + Office + 办公 + + + + Education + 教育 + + + + System + 系统 + + + + Safe + 安全 + + + + Others + 其它 FunctionWidget - - Search - 全局搜索 + Mobile + 移动 + + + Internet + 网络 + + + Social + 社交 + + + Video + 影音 + + + Development + 开发 + + + Image + 图像 + + + Game + 游戏 + + + Office + 办公 + + + Education + 教育 + + + System + 系统 + + + Others + 其它 + + + Safe + 安全 - MainWindow + MainViewWidget - + Search - 搜索应用 + 搜索 + + + + PushButton + + Mobile + 移动 - - - - All - 全部 + Internet + 网络 - - ... - + Social + 社交 - - collection - 收藏 + Video + 影音 - - recent - 最近 + Development + 开发 - - Max - 放大 + Image + 图像 - - PowerOff - 关机 + Game + 游戏 - - - Letter - 字母排序 + Office + 办公 - - - Function - 功能分类 + Education + 教育 + + + System + 系统 + + + Others + 其它 QObject - - + Office - 办公 + 办公 - - + Development - 开发 + 开发 - - + Image - 图像 + 图像 - - + Video - 影音 + 影音 - - + Internet - 网络 + 网络 - - + Game - 游戏 + 游戏 - - + Education - 教育 + 教育 - - + Social - 社交 + 社交 - - + System - 系统 + 系统 - - + Safe - 安全 + 安全 - - + Others - 其他 + 其它 RightClickMenu - + Pin to all 固定到“所有软件” - + Unpin from all 从“所有软件”取消固定 - + Pin to taskbar 固定到任务栏 - + Unpin from taskbar 从任务栏取消固定 - + Add to desktop shortcuts 添加到桌面快捷方式 - - Pin to collection - 固定到收藏 - - - - Remove from collection - 从收藏移除 - - - + Uninstall 卸载 - - Switch user - 切换用户 - - - Hibernate - 休眠 + 休眠 - + Sleep 睡眠 - Lock Screen - 锁屏 + 锁屏 - + Switch User + 切换用户 + + + Log Out 注销 - + Restart 重启 - + Power Off 关机 - + Personalize this list - + 设置开始菜单显示列表 - TabletRightClickMenu + SideBarWidget - - Pin to taskbar - 固定到任务栏 + + All + 所有软件 - - Unpin from taskbar - 从任务栏取消固定 + + Letter + 字母排序 - - Add to desktop shortcuts - 固定到桌面快捷方式 + + Function + 功能分类 - - Uninstall - 卸载 + + Trash + 回收站 + + + + Computer + 计算机 + + + + Max + 放大 + + + + Personal + 个人 + + + + Settings + 设置 + + + Recycle Bin + 回收站 + + + + Power + 电源 + + + + SplitBarFrame + + + Mobile + 移动 + + + + Internet + 网络 + + + + Social + 社交 + + + + Video + 影音 + + + + Development + 开发 + + + + Image + 图像 + + + + Game + 游戏 + + + + Office + 办公 + + + + Education + 教育 + + + + System + 系统 + + + + Safe + 安全 + + + + Others + 其它 + + + + UkuiMenuInterface + + Office + 办公 + + + Development + 开发 + + + Image + 图像 + + + Video + 影音 + + + Internet + 网络 + + + Game + 游戏 + + + Education + 教育 + + + Social + 社交 + + + System + 系统 + + + Safe + 安全 + + + Others + 其它 diff --git a/ukui-menu.pro b/ukui-menu.pro index 9cf7362..cfb10e7 100644 --- a/ukui-menu.pro +++ b/ukui-menu.pro @@ -4,14 +4,10 @@ # #------------------------------------------------- -QT += core gui svg dbus x11extras KWindowSystem sql +QT += core gui svg dbus x11extras KWindowSystem sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -include(./src/BackProcess/backprocess.pri) -include(./src/QtSingleApplication/qtsingleapplication.pri) -include(./src/UserInterface/userinterface.pri) -include(./src/UtilityFunction/utilityfunction.pri) +include(src/QtSingleApplication/qtsingleapplication.pri) QMAKE_CXXFLAGS += -g TARGET = ukui-menu @@ -20,7 +16,7 @@ TEMPLATE = app target.path = /usr/bin TRANSLATIONS+=\ - translations/ukui-menu_bo.ts \ + translations/ukui-menu_bo_CN.ts \ translations/ukui-menu_zh_CN.ts \ translations/ukui-menu_tr.ts @@ -48,22 +44,98 @@ INSTALLS += qm_files # So we can access it from main.cpp DEFINES += QM_FILES_INSTALL_PATH='\\"$${QM_FILES_INSTALL_PATH}\\"' -PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt libbamf3 x11 xtst +SOURCES += \ + src/CommonUseWidget/commonusewidget.cpp \ + src/CommonUseWidget/fullcommonusewidget.cpp \ + src/FunctionWidget/fullfunctionwidget.cpp \ + src/FunctionWidget/functionbuttonwidget.cpp \ + src/FunctionWidget/functionwidget.cpp \ + src/LetterWidget/fullletterwidget.cpp \ + src/LetterWidget/letterbuttonwidget.cpp \ + src/LetterWidget/letterwidget.cpp \ + src/MainViewWidget/directorychangedthread.cpp \ + src/MainViewWidget/mainviewwidget.cpp \ + src/MainWindow/mainwindow.cpp \ + src/RightClickMenu/menubox.cpp \ + src/RightClickMenu/rightclickmenu.cpp \ + src/RightClickMenu/uninstallwhitelist.cpp \ + src/SearchResultWidget/file-utils.cpp \ + src/SearchResultWidget/fullsearchresultwidget.cpp \ + src/SearchResultWidget/searchappthread.cpp \ + src/SearchResultWidget/searchresultwidget.cpp \ + src/SideBarWidget/sidebarwidget.cpp \ + src/Style/style.cpp \ + src/UtilityFunction/classifybtnscrollarea.cpp \ + src/UtilityFunction/convertdesktoptowinid.cpp \ + src/UtilityFunction/fullitemdelegate.cpp \ + src/UtilityFunction/fulllistview.cpp \ + src/UtilityFunction/functionclassifybutton.cpp \ + src/UtilityFunction/itemdelegate.cpp \ + src/UtilityFunction/letterclassifybutton.cpp \ + src/UtilityFunction/listview.cpp \ + src/UtilityFunction/proxystyle.cpp \ + src/UtilityFunction/scrollarea.cpp \ + src/UtilityFunction/softwaredatabaseupdatethread.cpp \ + src/UtilityFunction/splitbarframe.cpp \ + src/UtilityFunction/toolbutton.cpp \ + src/Interface/ukuichineseletter.cpp \ + src/Interface/ukuimenuinterface.cpp \ + main.cpp \ + src/UtilityFunction/utility.cpp \ + src/DBus/dbus.cpp \ + src/DBus/dbus-adaptor.cpp + +HEADERS += \ + src/CommonUseWidget/commonusewidget.h \ + src/CommonUseWidget/fullcommonusewidget.h \ + src/FunctionWidget/fullfunctionwidget.h \ + src/FunctionWidget/functionbuttonwidget.h \ + src/FunctionWidget/functionwidget.h \ + src/LetterWidget/fullletterwidget.h \ + src/LetterWidget/letterbuttonwidget.h \ + src/LetterWidget/letterwidget.h \ + src/MainViewWidget/directorychangedthread.h \ + src/MainViewWidget/mainviewwidget.h \ + src/MainWindow/mainwindow.h \ + src/RightClickMenu/menubox.h \ + src/RightClickMenu/rightclickmenu.h \ + src/RightClickMenu/uninstallwhitelist.h \ + src/SearchResultWidget/file-utils.h \ + src/SearchResultWidget/fullsearchresultwidget.h \ + src/SearchResultWidget/searchappthread.h \ + src/SearchResultWidget/searchresultwidget.h \ + src/SideBarWidget/sidebarwidget.h \ + src/Style/style.h \ + src/UtilityFunction/classifybtnscrollarea.h \ + src/UtilityFunction/convertdesktoptowinid.h \ + src/UtilityFunction/fullitemdelegate.h \ + src/UtilityFunction/fulllistview.h \ + src/UtilityFunction/functionclassifybutton.h \ + src/UtilityFunction/itemdelegate.h \ + src/UtilityFunction/letterclassifybutton.h \ + src/UtilityFunction/listview.h \ + src/UtilityFunction/proxystyle.h \ + src/UtilityFunction/scrollarea.h \ + src/UtilityFunction/softwaredatabaseupdatethread.h \ + src/UtilityFunction/splitbarframe.h \ + src/UtilityFunction/toolbutton.h \ + src/Interface/ukuichineseletter.h \ + src/Interface/ukuimenuinterface.h \ + src/UtilityFunction/utility.h \ + src/DBus/dbus.h \ + src/DBus/dbus-adaptor.h + +RESOURCES += \ + res.qrc + +PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt CONFIG += no_keywords link_pkgconfig -LIBS+=-pthread -luchardet -lukui-log4qt -lukui-com4c -lukui-com4cxx -lpeony +LIBS+=-pthread -luchardet -lukui-log4qt -lukui-com4c -lukui-com4cxx desktop_file.files = ukui-menu.desktop desktop_file.path = /etc/xdg/autostart INSTALLS += \ target desktop_file - -FORMS += - -SOURCES += \ - main.cpp - -RESOURCES += \ - res.qrc diff --git a/ukui-menu.pro.user b/ukui-menu.pro.user deleted file mode 100644 index 6d1e613..0000000 --- a/ukui-menu.pro.user +++ /dev/null @@ -1,314 +0,0 @@ - - - - - - EnvironmentId - {b9d686e0-ada0-41c1-ad9c-96f1279f7707} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - 桌面 - 桌面 - {9d9f9a2c-403b-48c4-83ee-e52b4e889b83} - 0 - 0 - 0 - - /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Debug - - - true - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Release - - - true - QtProjectManager.QMakeBuildStep - false - - false - false - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Profile - - - true - QtProjectManager.QMakeBuildStep - true - - false - true - true - - - true - Qt4ProjectManager.MakeStep - - false - - - false - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - - true - clean - - false - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu3.1/ukui-menu/ukui-menu.pro - /home/ztz/ukui-menu3.1/ukui-menu/ukui-menu.pro - - false - - false - true - true - false - false - true - - /home/ztz/ukui-menu3.1/build-ukui-menu-unknown-Debug - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - From e956f5f064cb6b80350277945b0ac1cb646ec7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=82=9C?= Date: Fri, 20 May 2022 16:38:28 +0800 Subject: [PATCH 03/12] Import Upstream version 3.0.2.0509hw1 --- .github/workflows/build.yml | 0 COPYING | 0 NEWS | 0 README.md | 0 .../mainviewwidget/Development-Checked.svg | 0 .../mainviewwidget/Development-Disabled.svg | 0 .../mainviewwidget/Development-Enabled.svg | 0 .../img/mainviewwidget/Development-Normal.svg | 0 data/img/mainviewwidget/Education-Checked.svg | 0 .../img/mainviewwidget/Education-Disabled.svg | 0 data/img/mainviewwidget/Education-Enabled.svg | 0 data/img/mainviewwidget/Education-Normal.svg | 0 data/img/mainviewwidget/Game-Checked.svg | 0 data/img/mainviewwidget/Game-Disabled.svg | 0 data/img/mainviewwidget/Game-Enabled.svg | 0 data/img/mainviewwidget/Game-Normal.svg | 0 data/img/mainviewwidget/Image-Checked.svg | 0 data/img/mainviewwidget/Image-Disabled.svg | 0 data/img/mainviewwidget/Image-Enabled.svg | 0 data/img/mainviewwidget/Image-Normal.svg | 0 data/img/mainviewwidget/Internet-Checked.svg | 0 data/img/mainviewwidget/Internet-Disabled.svg | 0 data/img/mainviewwidget/Internet-Enabled.svg | 0 data/img/mainviewwidget/Internet-Normal.svg | 0 data/img/mainviewwidget/Mobile-Checked.svg | 0 data/img/mainviewwidget/Mobile-Disabled.svg | 0 data/img/mainviewwidget/Mobile-Enabled.svg | 0 data/img/mainviewwidget/Mobile-Normal.svg | 0 data/img/mainviewwidget/Office-Checked.svg | 0 data/img/mainviewwidget/Office-Disabled.svg | 0 data/img/mainviewwidget/Office-Enabled.svg | 0 data/img/mainviewwidget/Office-Normal.svg | 0 data/img/mainviewwidget/Others-Checked.svg | 0 data/img/mainviewwidget/Others-Disabled.svg | 0 data/img/mainviewwidget/Others-Enabled.svg | 0 data/img/mainviewwidget/Others-Normal.svg | 0 data/img/mainviewwidget/Social-Checked.svg | 0 data/img/mainviewwidget/Social-Disabled.svg | 0 data/img/mainviewwidget/Social-Enabled.svg | 0 data/img/mainviewwidget/Social-Normal.svg | 0 data/img/mainviewwidget/System-Checked.svg | 0 data/img/mainviewwidget/System-Disabled.svg | 0 data/img/mainviewwidget/System-Enabled.svg | 0 data/img/mainviewwidget/System-Normal.svg | 0 data/img/mainviewwidget/Video-Checked.svg | 0 data/img/mainviewwidget/Video-Disabled.svg | 0 data/img/mainviewwidget/Video-Enabled.svg | 0 data/img/mainviewwidget/Video-Normal.svg | 0 data/img/mainviewwidget/attributeaction.svg | 0 data/img/mainviewwidget/downarrow-pressed.svg | 0 data/img/mainviewwidget/downarrow.svg | 0 data/img/mainviewwidget/fixed.svg | 0 data/img/mainviewwidget/leftarrow-hover.svg | 0 data/img/mainviewwidget/leftarrow.svg | 0 data/img/mainviewwidget/lock-fs.svg | 0 data/img/mainviewwidget/lock.svg | 0 data/img/mainviewwidget/recent-disabled.svg | 0 data/img/mainviewwidget/recent-enabled.svg | 0 data/img/mainviewwidget/recent-gray.svg | 0 data/img/mainviewwidget/recent.svg | 0 data/img/mainviewwidget/rightarrow-hover.svg | 0 data/img/mainviewwidget/rightarrow.svg | 0 data/img/mainviewwidget/search.svg | 0 data/img/mainviewwidget/unfixed.svg | 0 data/img/mainviewwidget/uninstall.svg | 0 data/img/mainviewwidget/uparrow-pressed.svg | 0 data/img/mainviewwidget/uparrow.svg | 0 data/img/sidebarwidget/commonuse.svg | 0 data/img/sidebarwidget/computer.svg | 0 data/img/sidebarwidget/control.svg | 0 data/img/sidebarwidget/default.svg | 1 + data/img/sidebarwidget/fixed.svg | 0 data/img/sidebarwidget/fullusericon.png | Bin data/img/sidebarwidget/function.svg | 0 data/img/sidebarwidget/letter.svg | 0 data/img/sidebarwidget/lock.svg | 0 data/img/sidebarwidget/max.svg | 0 data/img/sidebarwidget/min.svg | 0 data/img/sidebarwidget/personal.svg | 0 data/img/sidebarwidget/rightarrow.svg | 0 data/img/sidebarwidget/setting.svg | 0 data/img/sidebarwidget/shutdown.svg | 0 data/img/sidebarwidget/trash.svg | 0 data/img/sidebarwidget/unfixed.svg | 0 data/img/sidebarwidget/usericon-darkcolor.svg | 0 .../img/sidebarwidget/usericon-lightcolor.svg | 0 main.cpp | 20 +- man/ukui-menu.1 | 0 res.qrc | 1 + src/CommonUseWidget/commonusewidget.cpp | 5 +- src/CommonUseWidget/commonusewidget.h | 0 src/CommonUseWidget/fullcommonusewidget.cpp | 22 +- src/CommonUseWidget/fullcommonusewidget.h | 16 +- src/DBus/dbus-adaptor.cpp | 13 +- src/DBus/dbus-adaptor.h | 20 +- src/DBus/dbus.cpp | 15 +- src/DBus/dbus.h | 9 +- src/DBus/org.ukui.menu.xml | 0 src/FunctionWidget/fullfunctionwidget.cpp | 158 ++- src/FunctionWidget/fullfunctionwidget.h | 47 +- src/FunctionWidget/functionbuttonwidget.cpp | 107 +- src/FunctionWidget/functionbuttonwidget.h | 1 - src/FunctionWidget/functionwidget.cpp | 100 +- src/FunctionWidget/functionwidget.h | 8 +- src/Interface/ukuichineseletter.cpp | 0 src/Interface/ukuichineseletter.h | 0 src/Interface/ukuimenuinterface.cpp | 527 +++++----- src/Interface/ukuimenuinterface.h | 30 +- src/LetterWidget/fullletterwidget.cpp | 19 +- src/LetterWidget/fullletterwidget.h | 0 src/LetterWidget/letterbuttonwidget.cpp | 0 src/LetterWidget/letterbuttonwidget.h | 0 src/LetterWidget/letterwidget.cpp | 4 +- src/LetterWidget/letterwidget.h | 0 src/MainViewWidget/directorychangedthread.cpp | 19 +- src/MainViewWidget/directorychangedthread.h | 4 +- src/MainViewWidget/mainviewwidget.cpp | 276 ++---- src/MainViewWidget/mainviewwidget.h | 100 +- src/MainWindow/mainwindow.cpp | 366 ++++--- src/MainWindow/mainwindow.h | 34 +- src/QtSingleApplication/QtLockedFile | 0 src/QtSingleApplication/QtSingleApplication | 0 src/QtSingleApplication/qtlocalpeer.cpp | 0 src/QtSingleApplication/qtlocalpeer.h | 0 src/QtSingleApplication/qtlockedfile.cpp | 0 src/QtSingleApplication/qtlockedfile.h | 0 src/QtSingleApplication/qtlockedfile_unix.cpp | 0 src/QtSingleApplication/qtlockedfile_win.cpp | 0 .../qtsingleapplication.cpp | 1 - src/QtSingleApplication/qtsingleapplication.h | 0 .../qtsingleapplication.pri | 0 .../qtsinglecoreapplication.cpp | 0 .../qtsinglecoreapplication.h | 0 .../qtsinglecoreapplication.pri | 0 src/RightClickMenu/menubox.cpp | 0 src/RightClickMenu/menubox.h | 0 src/RightClickMenu/rightclickmenu.cpp | 127 ++- src/RightClickMenu/rightclickmenu.h | 8 +- src/RightClickMenu/uninstallwhitelist.cpp | 84 -- src/RightClickMenu/uninstallwhitelist.h | 47 - src/SearchResultWidget/file-utils.cpp | 0 src/SearchResultWidget/file-utils.h | 0 .../fullsearchresultwidget.cpp | 6 +- .../fullsearchresultwidget.h | 0 src/SearchResultWidget/pinyinWithTone.txt | 0 src/SearchResultWidget/pinyinWithoutTone.txt | 0 src/SearchResultWidget/searchappthread.cpp | 47 +- src/SearchResultWidget/searchappthread.h | 4 +- src/SearchResultWidget/searchresultwidget.cpp | 1 + src/SearchResultWidget/searchresultwidget.h | 6 +- src/SideBarWidget/sidebarwidget.cpp | 217 ++--- src/SideBarWidget/sidebarwidget.h | 6 +- src/Style/style.cpp | 917 +++++++++--------- src/Style/style.h | 4 - src/UtilityFunction/classifybtnscrollarea.cpp | 14 +- src/UtilityFunction/classifybtnscrollarea.h | 8 +- src/UtilityFunction/convertdesktoptowinid.cpp | 2 +- src/UtilityFunction/convertdesktoptowinid.h | 3 +- src/UtilityFunction/fullitemdelegate.cpp | 0 src/UtilityFunction/fullitemdelegate.h | 0 src/UtilityFunction/fulllistview.cpp | 161 ++- src/UtilityFunction/fulllistview.h | 9 +- .../functionclassifybutton.cpp | 261 ++--- src/UtilityFunction/functionclassifybutton.h | 2 +- src/UtilityFunction/itemdelegate.cpp | 0 src/UtilityFunction/itemdelegate.h | 0 src/UtilityFunction/letterclassifybutton.cpp | 0 src/UtilityFunction/letterclassifybutton.h | 0 src/UtilityFunction/listview.cpp | 7 +- src/UtilityFunction/listview.h | 0 src/UtilityFunction/proxystyle.cpp | 38 +- src/UtilityFunction/proxystyle.h | 0 src/UtilityFunction/scrollarea.cpp | 29 +- src/UtilityFunction/scrollarea.h | 10 +- .../softwaredatabaseupdatethread.cpp | 62 -- .../softwaredatabaseupdatethread.h | 27 - src/UtilityFunction/splitbarframe.cpp | 72 +- src/UtilityFunction/splitbarframe.h | 2 +- src/UtilityFunction/toolbutton.cpp | 177 ++-- src/UtilityFunction/toolbutton.h | 17 +- src/UtilityFunction/utility.cpp | 156 ++- src/UtilityFunction/utility.h | 17 +- .../{ukui-menu_bo_CN.ts => ukui-menu_bo.ts} | 298 +++--- translations/ukui-menu_tr.ts | 228 ++--- translations/ukui-menu_zh_CN.ts | 236 ++--- ukui-menu.desktop | 0 ukui-menu.ini | 0 ukui-menu.pro | 10 +- 188 files changed, 2540 insertions(+), 2703 deletions(-) mode change 100644 => 100755 .github/workflows/build.yml mode change 100644 => 100755 COPYING mode change 100644 => 100755 NEWS mode change 100644 => 100755 README.md mode change 100644 => 100755 data/img/mainviewwidget/Development-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Development-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Development-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Development-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/attributeaction.svg mode change 100644 => 100755 data/img/mainviewwidget/downarrow-pressed.svg mode change 100644 => 100755 data/img/mainviewwidget/downarrow.svg mode change 100644 => 100755 data/img/mainviewwidget/fixed.svg mode change 100644 => 100755 data/img/mainviewwidget/leftarrow-hover.svg mode change 100644 => 100755 data/img/mainviewwidget/leftarrow.svg mode change 100644 => 100755 data/img/mainviewwidget/lock-fs.svg mode change 100644 => 100755 data/img/mainviewwidget/lock.svg mode change 100644 => 100755 data/img/mainviewwidget/recent-disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/recent-enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/recent-gray.svg mode change 100644 => 100755 data/img/mainviewwidget/recent.svg mode change 100644 => 100755 data/img/mainviewwidget/rightarrow-hover.svg mode change 100644 => 100755 data/img/mainviewwidget/rightarrow.svg mode change 100644 => 100755 data/img/mainviewwidget/search.svg mode change 100644 => 100755 data/img/mainviewwidget/unfixed.svg mode change 100644 => 100755 data/img/mainviewwidget/uninstall.svg mode change 100644 => 100755 data/img/mainviewwidget/uparrow-pressed.svg mode change 100644 => 100755 data/img/mainviewwidget/uparrow.svg mode change 100644 => 100755 data/img/sidebarwidget/commonuse.svg mode change 100644 => 100755 data/img/sidebarwidget/computer.svg mode change 100644 => 100755 data/img/sidebarwidget/control.svg create mode 100755 data/img/sidebarwidget/default.svg mode change 100644 => 100755 data/img/sidebarwidget/fixed.svg mode change 100644 => 100755 data/img/sidebarwidget/fullusericon.png mode change 100644 => 100755 data/img/sidebarwidget/function.svg mode change 100644 => 100755 data/img/sidebarwidget/letter.svg mode change 100644 => 100755 data/img/sidebarwidget/lock.svg mode change 100644 => 100755 data/img/sidebarwidget/max.svg mode change 100644 => 100755 data/img/sidebarwidget/min.svg mode change 100644 => 100755 data/img/sidebarwidget/personal.svg mode change 100644 => 100755 data/img/sidebarwidget/rightarrow.svg mode change 100644 => 100755 data/img/sidebarwidget/setting.svg mode change 100644 => 100755 data/img/sidebarwidget/shutdown.svg mode change 100644 => 100755 data/img/sidebarwidget/trash.svg mode change 100644 => 100755 data/img/sidebarwidget/unfixed.svg mode change 100644 => 100755 data/img/sidebarwidget/usericon-darkcolor.svg mode change 100644 => 100755 data/img/sidebarwidget/usericon-lightcolor.svg mode change 100644 => 100755 main.cpp mode change 100644 => 100755 man/ukui-menu.1 mode change 100644 => 100755 res.qrc mode change 100644 => 100755 src/CommonUseWidget/commonusewidget.cpp mode change 100644 => 100755 src/CommonUseWidget/commonusewidget.h mode change 100644 => 100755 src/CommonUseWidget/fullcommonusewidget.cpp mode change 100644 => 100755 src/CommonUseWidget/fullcommonusewidget.h mode change 100644 => 100755 src/DBus/dbus-adaptor.cpp mode change 100644 => 100755 src/DBus/dbus-adaptor.h mode change 100644 => 100755 src/DBus/dbus.cpp mode change 100644 => 100755 src/DBus/dbus.h mode change 100644 => 100755 src/DBus/org.ukui.menu.xml mode change 100644 => 100755 src/FunctionWidget/fullfunctionwidget.cpp mode change 100644 => 100755 src/FunctionWidget/fullfunctionwidget.h mode change 100644 => 100755 src/FunctionWidget/functionbuttonwidget.cpp mode change 100644 => 100755 src/FunctionWidget/functionbuttonwidget.h mode change 100644 => 100755 src/FunctionWidget/functionwidget.cpp mode change 100644 => 100755 src/FunctionWidget/functionwidget.h mode change 100644 => 100755 src/Interface/ukuichineseletter.cpp mode change 100644 => 100755 src/Interface/ukuichineseletter.h mode change 100644 => 100755 src/Interface/ukuimenuinterface.cpp mode change 100644 => 100755 src/Interface/ukuimenuinterface.h mode change 100644 => 100755 src/LetterWidget/fullletterwidget.cpp mode change 100644 => 100755 src/LetterWidget/fullletterwidget.h mode change 100644 => 100755 src/LetterWidget/letterbuttonwidget.cpp mode change 100644 => 100755 src/LetterWidget/letterbuttonwidget.h mode change 100644 => 100755 src/LetterWidget/letterwidget.cpp mode change 100644 => 100755 src/LetterWidget/letterwidget.h mode change 100644 => 100755 src/MainViewWidget/directorychangedthread.cpp mode change 100644 => 100755 src/MainViewWidget/directorychangedthread.h mode change 100644 => 100755 src/MainViewWidget/mainviewwidget.cpp mode change 100644 => 100755 src/MainViewWidget/mainviewwidget.h mode change 100644 => 100755 src/MainWindow/mainwindow.cpp mode change 100644 => 100755 src/MainWindow/mainwindow.h mode change 100644 => 100755 src/QtSingleApplication/QtLockedFile mode change 100644 => 100755 src/QtSingleApplication/QtSingleApplication mode change 100644 => 100755 src/QtSingleApplication/qtlocalpeer.cpp mode change 100644 => 100755 src/QtSingleApplication/qtlocalpeer.h mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile.cpp mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile.h mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile_unix.cpp mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile_win.cpp mode change 100644 => 100755 src/QtSingleApplication/qtsingleapplication.cpp mode change 100644 => 100755 src/QtSingleApplication/qtsingleapplication.h mode change 100644 => 100755 src/QtSingleApplication/qtsingleapplication.pri mode change 100644 => 100755 src/QtSingleApplication/qtsinglecoreapplication.cpp mode change 100644 => 100755 src/QtSingleApplication/qtsinglecoreapplication.h mode change 100644 => 100755 src/QtSingleApplication/qtsinglecoreapplication.pri mode change 100644 => 100755 src/RightClickMenu/menubox.cpp mode change 100644 => 100755 src/RightClickMenu/menubox.h mode change 100644 => 100755 src/RightClickMenu/rightclickmenu.cpp mode change 100644 => 100755 src/RightClickMenu/rightclickmenu.h delete mode 100644 src/RightClickMenu/uninstallwhitelist.cpp delete mode 100644 src/RightClickMenu/uninstallwhitelist.h mode change 100644 => 100755 src/SearchResultWidget/file-utils.cpp mode change 100644 => 100755 src/SearchResultWidget/file-utils.h mode change 100644 => 100755 src/SearchResultWidget/fullsearchresultwidget.cpp mode change 100644 => 100755 src/SearchResultWidget/fullsearchresultwidget.h mode change 100644 => 100755 src/SearchResultWidget/pinyinWithTone.txt mode change 100644 => 100755 src/SearchResultWidget/pinyinWithoutTone.txt mode change 100644 => 100755 src/SearchResultWidget/searchappthread.cpp mode change 100644 => 100755 src/SearchResultWidget/searchappthread.h mode change 100644 => 100755 src/SearchResultWidget/searchresultwidget.cpp mode change 100644 => 100755 src/SearchResultWidget/searchresultwidget.h mode change 100644 => 100755 src/SideBarWidget/sidebarwidget.cpp mode change 100644 => 100755 src/SideBarWidget/sidebarwidget.h mode change 100644 => 100755 src/Style/style.cpp mode change 100644 => 100755 src/Style/style.h mode change 100644 => 100755 src/UtilityFunction/classifybtnscrollarea.cpp mode change 100644 => 100755 src/UtilityFunction/classifybtnscrollarea.h mode change 100644 => 100755 src/UtilityFunction/convertdesktoptowinid.cpp mode change 100644 => 100755 src/UtilityFunction/convertdesktoptowinid.h mode change 100644 => 100755 src/UtilityFunction/fullitemdelegate.cpp mode change 100644 => 100755 src/UtilityFunction/fullitemdelegate.h mode change 100644 => 100755 src/UtilityFunction/fulllistview.cpp mode change 100644 => 100755 src/UtilityFunction/fulllistview.h mode change 100644 => 100755 src/UtilityFunction/functionclassifybutton.cpp mode change 100644 => 100755 src/UtilityFunction/functionclassifybutton.h mode change 100644 => 100755 src/UtilityFunction/itemdelegate.cpp mode change 100644 => 100755 src/UtilityFunction/itemdelegate.h mode change 100644 => 100755 src/UtilityFunction/letterclassifybutton.cpp mode change 100644 => 100755 src/UtilityFunction/letterclassifybutton.h mode change 100644 => 100755 src/UtilityFunction/listview.cpp mode change 100644 => 100755 src/UtilityFunction/listview.h mode change 100644 => 100755 src/UtilityFunction/proxystyle.cpp mode change 100644 => 100755 src/UtilityFunction/proxystyle.h mode change 100644 => 100755 src/UtilityFunction/scrollarea.cpp mode change 100644 => 100755 src/UtilityFunction/scrollarea.h delete mode 100644 src/UtilityFunction/softwaredatabaseupdatethread.cpp delete mode 100644 src/UtilityFunction/softwaredatabaseupdatethread.h mode change 100644 => 100755 src/UtilityFunction/splitbarframe.cpp mode change 100644 => 100755 src/UtilityFunction/splitbarframe.h mode change 100644 => 100755 src/UtilityFunction/toolbutton.cpp mode change 100644 => 100755 src/UtilityFunction/toolbutton.h mode change 100644 => 100755 src/UtilityFunction/utility.cpp mode change 100644 => 100755 src/UtilityFunction/utility.h rename translations/{ukui-menu_bo_CN.ts => ukui-menu_bo.ts} (54%) mode change 100644 => 100755 mode change 100644 => 100755 translations/ukui-menu_tr.ts mode change 100644 => 100755 translations/ukui-menu_zh_CN.ts mode change 100644 => 100755 ukui-menu.desktop mode change 100644 => 100755 ukui-menu.ini mode change 100644 => 100755 ukui-menu.pro diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml old mode 100644 new mode 100755 diff --git a/COPYING b/COPYING old mode 100644 new mode 100755 diff --git a/NEWS b/NEWS old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Checked.svg b/data/img/mainviewwidget/Development-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Disabled.svg b/data/img/mainviewwidget/Development-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Enabled.svg b/data/img/mainviewwidget/Development-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Normal.svg b/data/img/mainviewwidget/Development-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Checked.svg b/data/img/mainviewwidget/Education-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Disabled.svg b/data/img/mainviewwidget/Education-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Enabled.svg b/data/img/mainviewwidget/Education-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Normal.svg b/data/img/mainviewwidget/Education-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Checked.svg b/data/img/mainviewwidget/Game-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Disabled.svg b/data/img/mainviewwidget/Game-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Enabled.svg b/data/img/mainviewwidget/Game-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Normal.svg b/data/img/mainviewwidget/Game-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Checked.svg b/data/img/mainviewwidget/Image-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Disabled.svg b/data/img/mainviewwidget/Image-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Enabled.svg b/data/img/mainviewwidget/Image-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Normal.svg b/data/img/mainviewwidget/Image-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Checked.svg b/data/img/mainviewwidget/Internet-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Disabled.svg b/data/img/mainviewwidget/Internet-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Enabled.svg b/data/img/mainviewwidget/Internet-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Normal.svg b/data/img/mainviewwidget/Internet-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Checked.svg b/data/img/mainviewwidget/Mobile-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Disabled.svg b/data/img/mainviewwidget/Mobile-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Enabled.svg b/data/img/mainviewwidget/Mobile-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Normal.svg b/data/img/mainviewwidget/Mobile-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Checked.svg b/data/img/mainviewwidget/Office-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Disabled.svg b/data/img/mainviewwidget/Office-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Enabled.svg b/data/img/mainviewwidget/Office-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Normal.svg b/data/img/mainviewwidget/Office-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Checked.svg b/data/img/mainviewwidget/Others-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Disabled.svg b/data/img/mainviewwidget/Others-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Enabled.svg b/data/img/mainviewwidget/Others-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Normal.svg b/data/img/mainviewwidget/Others-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Checked.svg b/data/img/mainviewwidget/Social-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Disabled.svg b/data/img/mainviewwidget/Social-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Enabled.svg b/data/img/mainviewwidget/Social-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Normal.svg b/data/img/mainviewwidget/Social-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Checked.svg b/data/img/mainviewwidget/System-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Disabled.svg b/data/img/mainviewwidget/System-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Enabled.svg b/data/img/mainviewwidget/System-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Normal.svg b/data/img/mainviewwidget/System-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Checked.svg b/data/img/mainviewwidget/Video-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Disabled.svg b/data/img/mainviewwidget/Video-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Enabled.svg b/data/img/mainviewwidget/Video-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Normal.svg b/data/img/mainviewwidget/Video-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/attributeaction.svg b/data/img/mainviewwidget/attributeaction.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/downarrow-pressed.svg b/data/img/mainviewwidget/downarrow-pressed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/downarrow.svg b/data/img/mainviewwidget/downarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/fixed.svg b/data/img/mainviewwidget/fixed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/leftarrow-hover.svg b/data/img/mainviewwidget/leftarrow-hover.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/leftarrow.svg b/data/img/mainviewwidget/leftarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/lock-fs.svg b/data/img/mainviewwidget/lock-fs.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/lock.svg b/data/img/mainviewwidget/lock.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-disabled.svg b/data/img/mainviewwidget/recent-disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-enabled.svg b/data/img/mainviewwidget/recent-enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-gray.svg b/data/img/mainviewwidget/recent-gray.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent.svg b/data/img/mainviewwidget/recent.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/rightarrow-hover.svg b/data/img/mainviewwidget/rightarrow-hover.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/rightarrow.svg b/data/img/mainviewwidget/rightarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/search.svg b/data/img/mainviewwidget/search.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/unfixed.svg b/data/img/mainviewwidget/unfixed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uninstall.svg b/data/img/mainviewwidget/uninstall.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uparrow-pressed.svg b/data/img/mainviewwidget/uparrow-pressed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uparrow.svg b/data/img/mainviewwidget/uparrow.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/commonuse.svg b/data/img/sidebarwidget/commonuse.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/computer.svg b/data/img/sidebarwidget/computer.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/control.svg b/data/img/sidebarwidget/control.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/default.svg b/data/img/sidebarwidget/default.svg new file mode 100755 index 0000000..7b506cb --- /dev/null +++ b/data/img/sidebarwidget/default.svg @@ -0,0 +1 @@ +avatar \ No newline at end of file diff --git a/data/img/sidebarwidget/fixed.svg b/data/img/sidebarwidget/fixed.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/fullusericon.png b/data/img/sidebarwidget/fullusericon.png old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/function.svg b/data/img/sidebarwidget/function.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/letter.svg b/data/img/sidebarwidget/letter.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/lock.svg b/data/img/sidebarwidget/lock.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/max.svg b/data/img/sidebarwidget/max.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/min.svg b/data/img/sidebarwidget/min.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/personal.svg b/data/img/sidebarwidget/personal.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/rightarrow.svg b/data/img/sidebarwidget/rightarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/setting.svg b/data/img/sidebarwidget/setting.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/shutdown.svg b/data/img/sidebarwidget/shutdown.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/trash.svg b/data/img/sidebarwidget/trash.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/unfixed.svg b/data/img/sidebarwidget/unfixed.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/usericon-darkcolor.svg b/data/img/sidebarwidget/usericon-darkcolor.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/usericon-lightcolor.svg b/data/img/sidebarwidget/usericon-lightcolor.svg old mode 100644 new mode 100755 diff --git a/main.cpp b/main.cpp old mode 100644 new mode 100755 index 2a97a60..05ffbaa --- a/main.cpp +++ b/main.cpp @@ -29,16 +29,12 @@ #include #include "src/UtilityFunction/utility.h" #include "src/SearchResultWidget/file-utils.h" -#include -#include -#include "src/UtilityFunction/utility.h" #include int main(int argc, char *argv[]) { initUkuiLog4qt("ukui-menu"); - projectCodeName = KDKGetPrjCodeName().c_str(); qRegisterMetaType>("QVector"); #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -55,17 +51,31 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } +// auto Style=new ProxyStyle; +// app.setStyle(Style); QTranslator translator; if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) { app.installTranslator(&translator); } else { - myDebug() << "Load translations file" << QLocale() << "failed!"; + qDebug() << "Load translations file" << QLocale() << "failed!"; } Zeeker::FileUtils::loadHanziTable(":/src/SearchResultWidget/pinyinWithoutTone.txt"); MainWindow w; app.setActivationWindow(&w); +// w.setProperty("useSystemStyleBlur", true); + //测试 +// if(Style::panelPosition==0) +// w.setGeometry(QRect(Style::primaryScreenX+4,Style::primaryScreenY+Style::primaryScreenHeight-Style::panelSize-Style::minh-3, +// Style::minw,Style::minh)); +// else if(Style::panelPosition==1) +// w.setGeometry(QRect(Style::primaryScreenX+4,Style::primaryScreenY+Style::panelSize+4,Style::minw,Style::minh)); +// else if(Style::panelPosition==2) +// w.setGeometry(QRect(Style::primaryScreenX+Style::panelSize+4,Style::primaryScreenY+4,Style::minw,Style::minh)); +// else +// w.setGeometry(QRect(Style::primaryScreenX+Style::primaryScreenWidth-Style::panelSize-Style::minw-4,Style::primaryScreenY+4, +// Style::minw,Style::minh)); w.show(); w.raise(); w.update(); diff --git a/man/ukui-menu.1 b/man/ukui-menu.1 old mode 100644 new mode 100755 diff --git a/res.qrc b/res.qrc old mode 100644 new mode 100755 index fc6c8ee..c09c00d --- a/res.qrc +++ b/res.qrc @@ -83,5 +83,6 @@ data/img/mainviewwidget/Mobile-Normal.svg src/SearchResultWidget/pinyinWithTone.txt src/SearchResultWidget/pinyinWithoutTone.txt + data/img/sidebarwidget/default.svg diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp old mode 100644 new mode 100755 index c19abb7..3c49d1c --- a/src/CommonUseWidget/commonusewidget.cpp +++ b/src/CommonUseWidget/commonusewidget.cpp @@ -54,7 +54,8 @@ void CommonUseWidget::initUi() void CommonUseWidget::initAppListWidget() { m_listView = new ListView(this, this->width(), this->height() - 6, 0); - m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_listView->setFixedSize(this->width(), this->height() - 6); +//m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); connect(m_listView, &ListView::sendItemClickedSignal, this, &CommonUseWidget::execApplication); connect(m_listView, &ListView::sendUpdateAppListSignal, this, &CommonUseWidget::updateListViewSlot); @@ -69,7 +70,7 @@ void CommonUseWidget::fillAppList() { m_data.clear(); - Q_FOREACH (QString desktopfp, UkuiMenuInterface::m_allAppVector) { + Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { m_data.append(QStringList() << desktopfp << "1"); } diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h old mode 100644 new mode 100755 diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp old mode 100644 new mode 100755 index 34bb7a1..a3afed2 --- a/src/CommonUseWidget/fullcommonusewidget.cpp +++ b/src/CommonUseWidget/fullcommonusewidget.cpp @@ -43,18 +43,16 @@ void FullCommonUseWidget::initUi() this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - myDebug() << "width" << this->width() << "height" << this->height(); this->setFocusPolicy(Qt::NoFocus); - mainLayout = new QHBoxLayout; + QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); this->setLayout(mainLayout); m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); mainLayout->addItem(m_spaceItem); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); m_scrollAreaWidLayout = new QVBoxLayout; @@ -70,7 +68,16 @@ void FullCommonUseWidget::initUi() void FullCommonUseWidget::initAppListWidget() { m_listView = new FullListView(this, 0); +// m_listView->setFixedSize(this->width()-Style::LeftWidWidth+3,this->height()); +// QHBoxLayout *mainLayout=qobject_cast(this->layout()); +// mainLayout->insertWidget(1,m_listView); m_scrollAreaWidLayout->addWidget(m_listView); + connect(m_scrollArea, &ScrollArea::requestUpdate, m_listView->viewport(), [ = ]() { + QEventLoop loop; + QTimer::singleShot(1, &loop, SLOT(quit())); + loop.exec(); + m_listView->repaint(); + }); connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullCommonUseWidget::execApplication); connect(m_listView, &FullListView::sendUpdateAppListSignal, this, &FullCommonUseWidget::updateListViewSlot); connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullCommonUseWidget::sendHideMainWindowSignal); @@ -100,7 +107,7 @@ void FullCommonUseWidget::fillAppList() { m_data.clear(); - Q_FOREACH (QString desktopfp, UkuiMenuInterface::m_allAppVector) { + Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { m_data.append(desktopfp); } @@ -119,6 +126,8 @@ void FullCommonUseWidget::execApplication(QString desktopfp) void FullCommonUseWidget::selectFirstItem() { + // this->focusNextChild(); + qDebug() << "void FullCommonUseWidget::selectFirstItem()"; m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); } @@ -164,7 +173,6 @@ void FullCommonUseWidget::repaintWidget() this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollAreaWidLayout->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; diff --git a/src/CommonUseWidget/fullcommonusewidget.h b/src/CommonUseWidget/fullcommonusewidget.h old mode 100644 new mode 100755 index 966cb86..1afe6f4 --- a/src/CommonUseWidget/fullcommonusewidget.h +++ b/src/CommonUseWidget/fullcommonusewidget.h @@ -65,16 +65,16 @@ public: */ void moveScrollBar(int type); -private: + FullListView* m_listView=nullptr; +private: + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; QStringList m_data; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QSpacerItem *m_spaceItem = nullptr; - ScrollArea *m_scrollArea = nullptr; - ScrollAreaWid *m_scrollAreaWid = nullptr; - QHBoxLayout *mainLayout = nullptr; - QVBoxLayout *m_scrollAreaWidLayout = nullptr; - FullListView *m_listView = nullptr; + QSpacerItem *m_spaceItem=nullptr; + ScrollArea* m_scrollArea=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; + QVBoxLayout* m_scrollAreaWidLayout=nullptr; + protected: /** * @brief Initializes UI diff --git a/src/DBus/dbus-adaptor.cpp b/src/DBus/dbus-adaptor.cpp old mode 100644 new mode 100755 index 4fdf0cf..46418e7 --- a/src/DBus/dbus-adaptor.cpp +++ b/src/DBus/dbus-adaptor.cpp @@ -37,26 +37,19 @@ QString MenuAdaptor::GetSecurityConfigPath() { // handle method call org.ukui.menu.GetSecurityConfigPath QString out0; - QMetaObject::invokeMethod(parent(), "getSecurityConfigPath", Q_RETURN_ARG(QString, out0)); + QMetaObject::invokeMethod(parent(), "GetSecurityConfigPath", Q_RETURN_ARG(QString, out0)); return out0; } void MenuAdaptor::ReloadSecurityConfig() { // handle method call org.ukui.menu.ReloadSecurityConfig - QMetaObject::invokeMethod(parent(), "reloadSecurityConfig"); + QMetaObject::invokeMethod(parent(), "ReloadSecurityConfig"); } void MenuAdaptor::WinKeyResponse() { // handle method call org.ukui.menu.WinKeyResponse - QMetaObject::invokeMethod(parent(), "winKeyResponse"); -} - -QStringList MenuAdaptor::GetPkgNameWhiteList() -{ - QStringList pkgList; - QMetaObject::invokeMethod(parent(), "getPkgNameWhiteList", Q_RETURN_ARG(QStringList, pkgList)); - return pkgList; + QMetaObject::invokeMethod(parent(), "WinKeyResponse"); } diff --git a/src/DBus/dbus-adaptor.h b/src/DBus/dbus-adaptor.h old mode 100644 new mode 100755 index f1800fc..0d51f6d --- a/src/DBus/dbus-adaptor.h +++ b/src/DBus/dbus-adaptor.h @@ -32,17 +32,14 @@ class MenuAdaptor: public QDBusAbstractAdaptor Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") Q_CLASSINFO("D-Bus Introspection", "" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "") +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") public: MenuAdaptor(QObject *parent); virtual ~MenuAdaptor(); @@ -52,7 +49,6 @@ public Q_SLOTS: // METHODS QString GetSecurityConfigPath(); void ReloadSecurityConfig(); void WinKeyResponse(); - QStringList GetPkgNameWhiteList(); Q_SIGNALS: // SIGNALS }; diff --git a/src/DBus/dbus.cpp b/src/DBus/dbus.cpp old mode 100644 new mode 100755 index 6dc9888..7196fc0 --- a/src/DBus/dbus.cpp +++ b/src/DBus/dbus.cpp @@ -18,29 +18,24 @@ #include "dbus.h" #include #include -#include "src/RightClickMenu/uninstallwhitelist.h" DBus::DBus(QObject *parent) : QObject(parent) { + } -void DBus::reloadSecurityConfig() +void DBus::ReloadSecurityConfig() { Q_EMIT sendReloadSignal(); } -QString DBus::getSecurityConfigPath() +QString DBus::GetSecurityConfigPath() { - QString path = QDir::homePath() + "/.config/ukui-menu-security-config.json"; + QString path=QDir::homePath()+"/.config/ukui-menu-security-config.json"; return path; } -void DBus::winKeyResponse() +void DBus::WinKeyResponse() { Q_EMIT winKeyResponseSignal(); } - -QStringList DBus::getPkgNameWhiteList() -{ - return UninstallWhitelist::getInstance()->getPkgNameWhiteList(); -} diff --git a/src/DBus/dbus.h b/src/DBus/dbus.h old mode 100644 new mode 100755 index 3db1556..4a70f04 --- a/src/DBus/dbus.h +++ b/src/DBus/dbus.h @@ -23,7 +23,7 @@ class DBus : public QObject { Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") + Q_CLASSINFO("D-Bus Interface","org.ukui.menu") public: explicit DBus(QObject *parent = 0); @@ -32,10 +32,9 @@ Q_SIGNALS: void winKeyResponseSignal(); public Q_SLOTS: - QString getSecurityConfigPath(); - void reloadSecurityConfig(); - void winKeyResponse(); - QStringList getPkgNameWhiteList(); + QString GetSecurityConfigPath(); + void ReloadSecurityConfig(); + void WinKeyResponse(); }; #endif // DBUS_H diff --git a/src/DBus/org.ukui.menu.xml b/src/DBus/org.ukui.menu.xml old mode 100644 new mode 100755 diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp old mode 100644 new mode 100755 index 3b84dd4..9d564a5 --- a/src/FunctionWidget/fullfunctionwidget.cpp +++ b/src/FunctionWidget/fullfunctionwidget.cpp @@ -58,13 +58,13 @@ void FullFunctionWidget::initUi() m_ukuiMenuInterface = new UkuiMenuInterface; initAppListWidget(); initIconListWidget(); - m_flag = true; + flag = true; //翻页灵敏度时间调节 - m_time = new QTimer(this); - connect(m_time, &QTimer::timeout, [ = ]() { - if (m_flag == false) { - m_flag = true; - m_time->stop(); + time = new QTimer(this); + connect(time, &QTimer::timeout, [ = ]() { + if (flag == false) { + flag = true; + time->stop(); } }); } @@ -74,14 +74,13 @@ void FullFunctionWidget::initUi() */ void FullFunctionWidget::initAppListWidget() { - layout = new QHBoxLayout(m_applistWid); + QHBoxLayout *layout = new QHBoxLayout(m_applistWid); layout->setContentsMargins(0, 0, 0, 0); m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); m_scrollAreaWidLayout = new QVBoxLayout; @@ -92,25 +91,94 @@ void FullFunctionWidget::initAppListWidget() connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullFunctionWidget::valueChangedSlot); m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - fillSoftwareAppList(); + fillAppList(); } /** * 填充应用列表 */ -void FullFunctionWidget::fillSoftwareAppList() +void FullFunctionWidget::fillAppList() { m_classificationList.clear(); - QVector vector = UkuiMenuInterface::m_functionalVector; - QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + QVector vector = UkuiMenuInterface::functionalVector; + QStringList androidlist = vector.at(0); - for (int i = 0; i < vector.size(); i++) { - if (!(vector.at(i).isEmpty())) { - insertClassificationBtn(functionList.at(i)); - insertAppList(vector.at(i)); - } + if (!androidlist.isEmpty()) { + insertClassificationBtn("Mobile"); + insertAppList(androidlist); } + QStringList netlist = vector.at(1); + + if (!netlist.isEmpty()) { + insertClassificationBtn("Internet"); + insertAppList(netlist); + } + + QStringList sociallist = vector.at(2); + + if (!sociallist.isEmpty()) { + insertClassificationBtn("Social"); + insertAppList(sociallist); + } + + QStringList avlist = vector.at(3); + + if (!avlist.isEmpty()) { + insertClassificationBtn("Video"); + insertAppList(avlist); + } + + QStringList developlist = vector.at(4); + + if (!developlist.isEmpty()) { + insertClassificationBtn("Development"); + insertAppList(developlist); + } + + QStringList graphicslist = vector.at(5); + + if (!graphicslist.isEmpty()) { + insertClassificationBtn("Image"); + insertAppList(graphicslist); + } + + QStringList gamelist = vector.at(6); + + if (!gamelist.isEmpty()) { + insertClassificationBtn("Game"); + insertAppList(gamelist); + } + + QStringList officelist = vector.at(7); + + if (!officelist.isEmpty()) { + insertClassificationBtn("Office"); + insertAppList(officelist); + } + + QStringList educationlist = vector.at(8); + + if (!educationlist.isEmpty()) { + insertClassificationBtn("Education"); + insertAppList(educationlist); + } + + QStringList systemadminlist = vector.at(9); + + if (!systemadminlist.isEmpty()) { + insertClassificationBtn("System"); + insertAppList(systemadminlist); + } + + QStringList otherlist = vector.at(10); + + if (!otherlist.isEmpty()) { + insertClassificationBtn("Others"); + insertAppList(otherlist); + } + + m_scrollAreaWidLayout->addItem(m_appListBottomSpacer); resizeScrollAreaControls(); } @@ -124,6 +192,13 @@ void FullFunctionWidget::insertClassificationBtn(QString category) void FullFunctionWidget::insertAppList(QStringList desktopfplist) { FullListView *listview = new FullListView(this, 2); + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { + QEventLoop loop; + QTimer::singleShot(1, &loop, SLOT(quit())); + loop.exec(); + listview->repaint(listview->rect()); + }); connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider); connect(this, &FullFunctionWidget::selectFirstItem, listview, &FullListView::selectFirstItem); listview->installEventFilter(this); @@ -165,7 +240,7 @@ void FullFunctionWidget::updateAppListView() delete child; } - fillSoftwareAppList(); + fillAppList(); //刷新图标列表界面 Q_FOREACH (QAbstractButton *button, m_buttonList) { @@ -209,7 +284,7 @@ void FullFunctionWidget::resizeScrollAreaControls() rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height() * rowcount); + listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); row++; } @@ -222,7 +297,9 @@ void FullFunctionWidget::resizeScrollAreaControls() void FullFunctionWidget::initIconListWidget() { m_iconListScrollArea = new ClassifyBtnScrollArea(m_iconListWid); - m_iconListScrollAreaWid = new ClassifyBtnScrollAreaWid(m_iconListScrollArea); +// m_iconListScrollArea->resize(Style::LeftBtnWidth, +// m_iconListWid->height()); + m_iconListScrollAreaWid = new ClassifyBtnScrollAreaWid; m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, m_iconListWid->height()); m_iconListScrollAreaWidLayout = new QVBoxLayout; @@ -255,7 +332,7 @@ void FullFunctionWidget::initIconListScrollArea() Style::LeftIconSize, m_classificationList.at(i), true, - true, this); + true); iconbtn->setChecked(false); m_buttonList.append(iconbtn); m_iconListScrollAreaWidLayout->addWidget(iconbtn); @@ -390,7 +467,6 @@ void FullFunctionWidget::repaintWidget() Style::AppListWidHeight); m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height()); m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, m_iconListWid->height()); @@ -419,8 +495,14 @@ void FullFunctionWidget::moveScrollBar(int type) void FullFunctionWidget::onSetSlider(int value) { +// if(flag) +// { +// flag = false; +// time->start(100); int curvalue = m_scrollArea->verticalScrollBar()->value(); m_scrollArea->verticalScrollBar()->setValue(curvalue + value); +// qDebug() << "FullFunctionWidget::onSetSlider" << curvalue; +// } } bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) @@ -438,6 +520,34 @@ bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) Q_EMIT setFocusToSideWin(); } +// if(ke->key() == Qt::Key_Up) +// { +// QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); +// QWidget* widTop = widItemTop->widget(); +// FullListView* m_listviewTop = qobject_cast(widTop); +// if(!m_listviewTop->hasFocus()) +// { +// QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size()); +// btnGroupClickedSlot(buttonTop); +// this->m_scrollArea->setFocusToPreChild(); +// return true; +// } +// } +// if(ke->key() == Qt::Key_Down) +// { +// QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); +// QWidget* wid = widItem->widget(); +// FullListView* m_listview = qobject_cast(wid); + +// if(!m_listview->hasFocus()) +// { +// QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size()); +// btnGroupClickedSlot(button); +// this->m_scrollArea->setFocusToNextChild(); +// return true; +// } +// } + if (ke->key() == Qt::Key_Up) { if (!m_listviewTop->hasFocus()) { QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); diff --git a/src/FunctionWidget/fullfunctionwidget.h b/src/FunctionWidget/fullfunctionwidget.h old mode 100644 new mode 100755 index 9b44f87..81551b7 --- a/src/FunctionWidget/fullfunctionwidget.h +++ b/src/FunctionWidget/fullfunctionwidget.h @@ -48,7 +48,7 @@ class FullFunctionWidget : public QWidget Q_OBJECT public: - explicit FullFunctionWidget(QWidget *parent = nullptr); + explicit FullFunctionWidget(QWidget *parent=nullptr); ~FullFunctionWidget(); /** * @brief Initializes the interface state @@ -76,36 +76,35 @@ public: void functionButtonClick(); - QAbstractButton *getCurLetterButton(int value); + QAbstractButton* getCurLetterButton(int value); private: /*Application list interface*/ - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QWidget *m_applistWid = nullptr; - ScrollArea *m_scrollArea = nullptr; - ScrollAreaWid *m_scrollAreaWid = nullptr; - QVBoxLayout *m_scrollAreaWidLayout = nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + QWidget* m_applistWid=nullptr; + ScrollArea* m_scrollArea=nullptr; + ScrollAreaWid* m_scrollAreaWid=nullptr; + QVBoxLayout* m_scrollAreaWidLayout=nullptr; QStringList m_classificationList;//Store the list of category buttons QStringList m_data; - QTimer *m_time = nullptr; - bool m_flag; + QTimer *time = nullptr; + bool flag; /*Function classification list interface*/ - QWidget *m_iconListWid = nullptr; - ClassifyBtnScrollArea *m_iconListScrollArea = nullptr; - ClassifyBtnScrollAreaWid *m_iconListScrollAreaWid = nullptr; - QVBoxLayout *m_iconListScrollAreaWidLayout = nullptr; - QHBoxLayout *layout = nullptr; - QList m_buttonList; - QButtonGroup *m_btnGroup = nullptr; - QSpacerItem *m_topSpacerItem = nullptr; - QSpacerItem *m_bottomSpacerItem = nullptr; - QSpacerItem *m_appListBottomSpacer = nullptr; + QWidget* m_iconListWid=nullptr; + ClassifyBtnScrollArea* m_iconListScrollArea=nullptr; + ClassifyBtnScrollAreaWid* m_iconListScrollAreaWid=nullptr; + QVBoxLayout* m_iconListScrollAreaWidLayout=nullptr; + QList m_buttonList; + QButtonGroup* m_btnGroup=nullptr; + QSpacerItem* m_topSpacerItem=nullptr; + QSpacerItem* m_bottomSpacerItem=nullptr; + QSpacerItem* m_appListBottomSpacer=nullptr; /*Animation*/ - QPropertyAnimation *m_animation = nullptr; //Function category button animation - QPropertyAnimation *m_scrollAnimation = nullptr; //Application list animation - int m_beginPos = 0; //Application list scrollbar starting value - int m_endPos = 0; //Application list scrollbar end value + QPropertyAnimation* m_animation=nullptr;//Function category button animation + QPropertyAnimation* m_scrollAnimation=nullptr;//Application list animation + int m_beginPos= 0;//Application list scrollbar starting value + int m_endPos= 0;//Application list scrollbar end value int m_index = 0; protected: @@ -125,7 +124,7 @@ protected: /** * @brief fill application list */ - void fillSoftwareAppList(); + void fillAppList(); /** * @brief Insert category button * @param category: Functional classification name diff --git a/src/FunctionWidget/functionbuttonwidget.cpp b/src/FunctionWidget/functionbuttonwidget.cpp old mode 100644 new mode 100755 index 6b36844..0cde546 --- a/src/FunctionWidget/functionbuttonwidget.cpp +++ b/src/FunctionWidget/functionbuttonwidget.cpp @@ -25,18 +25,18 @@ FunctionButtonWidget::FunctionButtonWidget(QWidget *parent) : QWidget(parent) { - m_categoryList.clear(); - m_categoryList.append(QObject::tr("Office")); - m_categoryList.append(QObject::tr("Development")); - m_categoryList.append(QObject::tr("Image")); - m_categoryList.append(QObject::tr("Video")); - m_categoryList.append(QObject::tr("Internet")); - m_categoryList.append(QObject::tr("Game")); - m_categoryList.append(QObject::tr("Education")); - m_categoryList.append(QObject::tr("Social")); - m_categoryList.append(QObject::tr("System")); - m_categoryList.append(QObject::tr("Safe")); - m_categoryList.append(QObject::tr("Others")); + m_categoryList.append("Mobile"); + m_categoryList.append("Internet"); + m_categoryList.append("Social"); + m_categoryList.append("Video"); + m_categoryList.append("Development"); + m_categoryList.append("Image"); + m_categoryList.append("Game"); + m_categoryList.append("Office"); + m_categoryList.append("Education"); + m_categoryList.append("System"); + m_categoryList.append("Others"); + initUi(); } @@ -47,37 +47,36 @@ FunctionButtonWidget::~FunctionButtonWidget() void FunctionButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->resize(Style::LeftBtnWidth * 2 + 5, Style::LeftBtnHeight * 6 + 25); - QGridLayout *gridLayout = new QGridLayout; - gridLayout->setContentsMargins(0, 0, 0, 0); + this->setAttribute(Qt::WA_StyledBackground,true); + this->resize(Style::LeftBtnWidth*2+5,Style::LeftBtnHeight*6+25); + + QGridLayout* gridLayout=new QGridLayout; + gridLayout->setContentsMargins(0,0,0,0); gridLayout->setSpacing(5); this->setLayout(gridLayout); - for (int row = 0; row < 6; row++) { - for (int col = 0; col < 2; col++) { - FunctionClassifyButton *iconbtn = new FunctionClassifyButton(Style::LeftBtnWidth, - Style::LeftBtnHeight, - Style::LeftIconSize, - m_categoryList.at(row * 2 + col), - false, - false, this); - gridLayout->addWidget(iconbtn, row, col); + for(int row=0;row<6;row++) + for(int col=0;col<2;col++) + { + FunctionClassifyButton* iconbtn=new FunctionClassifyButton(Style::LeftBtnWidth, + Style::LeftBtnHeight, + Style::LeftIconSize, + m_categoryList.at(row*2+col), + false, + false); + + gridLayout->addWidget(iconbtn,row,col); m_buttonList.append(iconbtn); - connect(iconbtn, &FunctionClassifyButton::buttonClicked, this, &FunctionButtonWidget::functionBtnClickedSlot); - - if (row * 2 + col == 10) { - break; - } + connect(iconbtn,&FunctionClassifyButton::buttonClicked,this, &FunctionButtonWidget::functionBtnClickedSlot); + if(row*2+col==10)break; } - } - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - connect(&gsetting, &QGSettings::changed, this, [ = ] { - Q_FOREACH (QAbstractButton *btn, m_buttonList) - { - FunctionClassifyButton *fbtn = qobject_cast(btn); + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,[=]{ + Q_FOREACH (QAbstractButton* btn, m_buttonList) { + FunctionClassifyButton *fbtn=qobject_cast(btn); fbtn->updateIconState(); } }); @@ -89,9 +88,9 @@ void FunctionButtonWidget::initUi() */ void FunctionButtonWidget::functionBtnClickedSlot() { - FunctionClassifyButton *btn = dynamic_cast(sender()); - QWidget *wid = btn->layout()->itemAt(0)->widget(); - QLabel *label = qobject_cast(wid); + FunctionClassifyButton* btn=dynamic_cast(sender()); + QWidget* wid=btn->layout()->itemAt(1)->widget(); + QLabel* label=qobject_cast(wid); Q_EMIT sendFunctionBtnSignal(label->text()); } @@ -100,25 +99,19 @@ void FunctionButtonWidget::functionBtnClickedSlot() */ void FunctionButtonWidget::recvClassificationBtnList() { - QGridLayout *gridLayout = qobject_cast(this->layout()); - - for (int row = 0; row < 6; row++) { - for (int col = 0 ; col < 2; col++) { - QLayoutItem *item = gridLayout->itemAtPosition(row, col); - FunctionClassifyButton *btn = qobject_cast(item->widget()); - - if (UkuiMenuInterface::m_functionalVector.at(row * 2 + col).isEmpty()) { - btn->m_enabled = false; - } else { - btn->m_enabled = true; - } - + QGridLayout* gridLayout=qobject_cast(this->layout()); + for(int row=0;row<6;row++) + for(int col=0;col<2;col++) + { + QLayoutItem* item=gridLayout->itemAtPosition(row,col); + FunctionClassifyButton* btn=qobject_cast(item->widget()); + if(UkuiMenuInterface::functionalVector.at(row*2+col).isEmpty()) + btn->m_enabled=false; + else + btn->m_enabled=true; btn->setEnabled(btn->m_enabled); btn->updateBtnState(); - if (row * 2 + col == 10) { - break; - } + if(row*2+col==10)break; } - } } diff --git a/src/FunctionWidget/functionbuttonwidget.h b/src/FunctionWidget/functionbuttonwidget.h old mode 100644 new mode 100755 index 581fa62..e2cc5d1 --- a/src/FunctionWidget/functionbuttonwidget.h +++ b/src/FunctionWidget/functionbuttonwidget.h @@ -28,7 +28,6 @@ #include #include "src/UtilityFunction/functionclassifybutton.h" #include "src/Interface/ukuimenuinterface.h" -#include class FunctionButtonWidget : public QWidget { diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp old mode 100644 new mode 100755 index d30fee1..a70ec66 --- a/src/FunctionWidget/functionwidget.cpp +++ b/src/FunctionWidget/functionwidget.cpp @@ -49,9 +49,9 @@ void FunctionWidget::initUi() m_functionBtnWid->hide(); connect(this, &FunctionWidget::sendClassificationbtnList, m_functionBtnWid, &FunctionButtonWidget::recvClassificationBtnList); connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal, this, &FunctionWidget::recvFunctionBtnSignal); - m_enterAnimation = new QPropertyAnimation(this); + m_enterAnimation = new QPropertyAnimation; m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation = new QPropertyAnimation(this); + m_leaveAnimation = new QPropertyAnimation; m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot); connect(m_enterAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot); @@ -65,30 +65,98 @@ void FunctionWidget::initAppListWidget() m_appListView = new ListView(this, this->width() - 6, this->height() - 6, 2); m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); m_appListView->show(); - fillSoftwareAppListView(m_addDate); + fillAppListView(0); connect(m_appListView, &ListView::sendItemClickedSignal, this, &FunctionWidget::recvItemClickedSlot); connect(m_appListView, &ListView::sendHideMainWindowSignal, this, &FunctionWidget::sendHideMainWindowSignal); connect(m_appListView, &ListView::sendMainWinActiveSignal, this, &FunctionWidget::sendMainWinActiveSignal); } + /** * 填充应用列表 */ -void FunctionWidget::fillSoftwareAppListView(int type) +void FunctionWidget::fillAppListView(int type) { - m_row = 0; + row = 0; m_data.clear(); m_classificationList.clear(); m_classificationBtnRowList.clear(); - QVector vector = UkuiMenuInterface::m_functionalVector; - QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + QVector vector = UkuiMenuInterface::functionalVector; + QStringList androidlist = vector.at(0); - for (int i = 0; i < vector.size(); i++) { - if (!(vector.at(i).isEmpty())) { - QString functionName = functionList.at(i); - insertClassificationBtn(functionName); - insertAppList(vector.at(i)); - } + if (!androidlist.isEmpty()) { + insertClassificationBtn(tr("Mobile")); + insertAppList(androidlist); + } + + QStringList netlist = vector.at(1); + + if (!netlist.isEmpty()) { + insertClassificationBtn(tr("Internet")); + insertAppList(netlist); + } + + QStringList sociallist = vector.at(2); + + if (!sociallist.isEmpty()) { + insertClassificationBtn(tr("Social")); + insertAppList(sociallist); + } + + QStringList avlist = vector.at(3); + + if (!avlist.isEmpty()) { + insertClassificationBtn(tr("Video")); + insertAppList(avlist); + } + + QStringList developlist = vector.at(4); + + if (!developlist.isEmpty()) { + insertClassificationBtn(tr("Development")); + insertAppList(developlist); + } + + QStringList graphicslist = vector.at(5); + + if (!graphicslist.isEmpty()) { + insertClassificationBtn(tr("Image")); + insertAppList(graphicslist); + } + + QStringList gamelist = vector.at(6); + + if (!gamelist.isEmpty()) { + insertClassificationBtn(tr("Game")); + insertAppList(gamelist); + } + + QStringList officelist = vector.at(7); + + if (!officelist.isEmpty()) { + insertClassificationBtn(tr("Office")); + insertAppList(officelist); + } + + QStringList educationlist = vector.at(8); + + if (!educationlist.isEmpty()) { + insertClassificationBtn(tr("Education")); + insertAppList(educationlist); + } + + QStringList systemadminlist = vector.at(9); + + if (!systemadminlist.isEmpty()) { + insertClassificationBtn(tr("System")); + insertAppList(systemadminlist); + } + + QStringList otherlist = vector.at(10); + + if (!otherlist.isEmpty()) { + insertClassificationBtn(tr("Others")); + insertAppList(otherlist); } if (type == 0) { @@ -102,12 +170,12 @@ void FunctionWidget::insertClassificationBtn(QString btnname) { m_classificationList.append(btnname); m_data.append(QStringList() << btnname << "0"); - m_classificationBtnRowList.append(QString::number(m_row)); + m_classificationBtnRowList.append(QString::number(row)); } void FunctionWidget::insertAppList(QStringList appnamelist) { - m_row += (appnamelist.count() + 1); + row += (appnamelist.count() + 1); for (int i = 0; i < appnamelist.count(); i++) { m_data.append(QStringList() << appnamelist.at(i) << "1"); @@ -137,7 +205,7 @@ void FunctionWidget::execApplication(QString desktopfp) */ void FunctionWidget::updateAppListView() { - fillSoftwareAppListView(m_updateDate); + fillAppListView(1); } /** diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h old mode 100644 new mode 100755 index 5eec927..beffaa3 --- a/src/FunctionWidget/functionwidget.h +++ b/src/FunctionWidget/functionwidget.h @@ -62,9 +62,7 @@ private: QVector m_data; QStringList m_classificationList;//Store the list of category buttons QStringList m_classificationBtnRowList;//Store the row in which the category button is located - int m_row=0; - int m_addDate = 0; - int m_updateDate = 1; + int row=0; /*Interface switching animation*/ QPropertyAnimation* m_enterAnimation=nullptr; QPropertyAnimation* m_leaveAnimation=nullptr; @@ -82,9 +80,9 @@ protected: /** * @brief fill application list */ - void fillSoftwareAppListView(int type); + void fillAppListView(int type); /** - * @brief Insert the software center category button + * @brief Insert category button * @param category: Functional classification name */ void insertClassificationBtn(QString btnname); diff --git a/src/Interface/ukuichineseletter.cpp b/src/Interface/ukuichineseletter.cpp old mode 100644 new mode 100755 diff --git a/src/Interface/ukuichineseletter.h b/src/Interface/ukuichineseletter.h old mode 100644 new mode 100755 diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp old mode 100644 new mode 100755 index 3350aaa..884ddd0 --- a/src/Interface/ukuimenuinterface.cpp +++ b/src/Interface/ukuimenuinterface.cpp @@ -32,33 +32,17 @@ UkuiMenuInterface::UkuiMenuInterface() { } -QVector UkuiMenuInterface::m_appInfoVector = QVector(); -QVector UkuiMenuInterface::m_desktopfpVector = QVector(); -QVector UkuiMenuInterface::m_alphabeticVector = QVector(); -QVector UkuiMenuInterface::m_functionalVector = QVector(); -QVector UkuiMenuInterface::m_allAppVector = QVector(); -QStringList UkuiMenuInterface::m_androidDesktopfnList = QStringList(); +QVector UkuiMenuInterface::appInfoVector = QVector(); +QVector UkuiMenuInterface::desktopfpVector = QVector(); +QVector UkuiMenuInterface::alphabeticVector = QVector(); +QVector UkuiMenuInterface::functionalVector = QVector(); +QVector UkuiMenuInterface::allAppVector = QVector(); +QStringList UkuiMenuInterface::androidDesktopfnList = QStringList(); UkuiMenuInterface::~UkuiMenuInterface() { } -QStringList UkuiMenuInterface::getFunctionClassName() -{ - QStringList functionList; - functionList.append(QObject::tr("Office")); - functionList.append(QObject::tr("Development")); - functionList.append(QObject::tr("Image")); - functionList.append(QObject::tr("Video")); - functionList.append(QObject::tr("Internet")); - functionList.append(QObject::tr("Game")); - functionList.append(QObject::tr("Education")); - functionList.append(QObject::tr("Social")); - functionList.append(QObject::tr("System")); - functionList.append(QObject::tr("Safe")); - functionList.append(QObject::tr("Others")); - return functionList; -} //文件递归查询 void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) { @@ -104,63 +88,63 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) continue; } - m_keyfile = g_key_file_new(); + keyfile = g_key_file_new(); - if (!g_key_file_load_from_file(m_keyfile, filepath, m_flags, m_error)) { + if (!g_key_file_load_from_file(keyfile, filepath, flags, error)) { return; } - char *ret_0 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "Categories", nullptr, nullptr); + char *ret_0 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); if (ret_0 != nullptr) { QString str = QString::fromLocal8Bit(ret_0); if (str.contains("Android")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } - char *ret_1 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); + char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); if (ret_1 != nullptr) { QString str = QString::fromLocal8Bit(ret_1); if (str.contains("true")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } - char *ret_2 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); + char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); if (ret_2 != nullptr) { QString str = QString::fromLocal8Bit(ret_2); if (str.contains("UKUI")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } //过滤LXQt、KDE - char *ret = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); + char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); if (ret != nullptr) { QString str = QString::fromLocal8Bit(ret); if (str.contains("LXQt") || str.contains("KDE")) { - g_key_file_free(m_keyfile); + g_key_file_free(keyfile); i++; continue; } } - g_key_file_free(m_keyfile); - m_filePathList.append(filePathStr); + g_key_file_free(keyfile); + filePathList.append(filePathStr); } i++; @@ -170,7 +154,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) //获取系统desktop文件路径 QStringList UkuiMenuInterface::getDesktopFilePath() { - m_filePathList.clear(); + filePathList.clear(); QString jsonPath = QDir::homePath() + "/.config/ukui-menu-security-config.json"; QFile file(jsonPath); @@ -189,11 +173,11 @@ QStringList UkuiMenuInterface::getDesktopFilePath() for (int index = 0; index < enArray.size(); index++) { QJsonObject obj = enArray.at(index).toObject(); - m_filePathList.append(obj.value("path").toString()); + filePathList.append(obj.value("path").toString()); // qDebug()< UkuiMenuInterface::createSoftwareAppInfoVector() +//创建应用信息容器 +QVector UkuiMenuInterface::createAppInfoVector() { - m_desktopfpVector.clear(); + desktopfpVector.clear(); QVector appInfoVector; QVector vector; - vector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公 - vector.append(QStringList() << "develop" << "Development"); //1开发 - vector.append(QStringList() << "graphic" << "Graphics"); //2图像 - vector.append(QStringList() << "video" << "Audio" << "Video"); //3影音 - vector.append(QStringList() << "network" << "Network"); //4网络 - vector.append(QStringList() << "game" << "Game"); //5游戏 - vector.append(QStringList() << "education" << "Education"); //6教育 - vector.append(QStringList() << "social" << "Messaging"); //7社交 - vector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统 - vector.append(QStringList() << "safe"); //9安全 - vector.append(QStringList() << "others"); //10其他 + vector.append(QStringList() << "Android"); //0安卓 + vector.append(QStringList() << "Network"); //1网络 + vector.append(QStringList() << "Messaging"); //2社交 + vector.append(QStringList() << "Audio" << "Video"); //3影音 + vector.append(QStringList() << "Development"); //4开发 + vector.append(QStringList() << "Graphics"); //5图像 + vector.append(QStringList() << "Game"); //6游戏 + vector.append(QStringList() << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //7办公 + vector.append(QStringList() << "Education"); //8教育 + vector.append(QStringList() << "System" << "Settings" << "Security"); //9系统 QStringList desktopfpList = getDesktopFilePath(); - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); - QSqlQuery sql(db); for (int i = 0; i < desktopfpList.count(); i++) { QStringList appInfoList; @@ -310,37 +291,19 @@ QVector UkuiMenuInterface::createSoftwareAppInfoVector() QString englishName = getAppEnglishName(desktopfpList.at(i)); QString letter = getAppNameInitial(desktopfpList.at(i)); QString letters = getAppNameInitials(desktopfpList.at(i)); - m_desktopfpVector.append(desktopfp); + desktopfpVector.append(desktopfp); appInfoList << desktopfp << name << englishName << letter << letters; - QString desktopfpExecName = getAppExec(desktopfpList.at(i)); - desktopfpExecName = desktopfpExecName.mid(desktopfpExecName.lastIndexOf("/") + 1); - desktopfpExecName = desktopfpExecName.left(desktopfpExecName.lastIndexOf(" ")); - sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName)); + bool is_owned = false; - if (sql.next()) { - myDebug() << "数据库执行成功"; - - for (int j = 0; j < vector.size(); j++) { - if (vector.at(j).contains(sql.value(0).toString())) { - appInfoList.append(QString::number(j)); - } + for (int j = 0; j < vector.size(); j++) { + if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { //有对应分类 + is_owned = true; + appInfoList.append(QString::number(j)); } - } else { - myDebug() << "数据库执行失败"; - bool is_owned = false; + } - for (int j = 0; j < vector.size(); j++) { - //有对应分类 - if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { - is_owned = true; - appInfoList.append(QString::number(j)); - break; - } - } - - if (!is_owned) { //该应用无对应分类 - appInfoList.append(QString::number(10)); - } + if (!is_owned) { //该应用无对应分类 + appInfoList.append(QString::number(10)); } appInfoVector.append(appInfoList); @@ -375,7 +338,6 @@ QString UkuiMenuInterface::getAppEnglishName(QString desktopfp) char *filepath = fpbyte.data(); g_key_file_load_from_file(keyfile, filepath, flags, error); char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); - g_key_file_free(keyfile); QString namestr = QString::fromLocal8Bit(name); return namestr; } @@ -470,27 +432,6 @@ bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2) } } -bool UkuiMenuInterface::cmpfixedApp(QStringList &arg_1, QStringList &arg_2) -{ - QLocale local; - QString language = local.languageToString(local.language()); - - if (QString::compare(language, "Chinese") == 0) { - local = QLocale(QLocale::Chinese); - } else { - local = QLocale(QLocale::English); - } - - QCollator collator(local); - - //数组中分别存放desktop、中文名称、英文名称、首字母、全拼 首字母,按首字母排列,对下标3进行比较 - if (collator.compare(arg_1.at(3), arg_2.at(3)) < 0) { - return true; - } else { - return false; - } -} - QVector UkuiMenuInterface::getAllClassification() { QVector allAppVector; @@ -502,9 +443,9 @@ QVector UkuiMenuInterface::getAllClassification() commonVector = getCommonUseApp(); int index = 0; - Q_FOREACH (QString desktopfp, m_desktopfpVector) { + Q_FOREACH (QString desktopfp, desktopfpVector) { if (!commonVector.contains(desktopfp)) { - appVector.append(m_appInfoVector.at(index)); + appVector.append(appInfoVector.at(index)); } index++; @@ -525,46 +466,93 @@ QVector UkuiMenuInterface::getAllClassification() QVector UkuiMenuInterface::getCommonUseApp() { +// QDateTime dt=QDateTime::currentDateTime(); +// int currentDateTime=dt.toTime_t(); +// int nDaySec=24*60*60; +// setting->beginGroup("datetime"); +// QStringList dateTimeKeys=setting->allKeys(); +// QStringList timeOutKeys; +// timeOutKeys.clear(); +// for(int i=0;ivalue(dateTimeKeys.at(i)).toInt())/nDaySec >= 4) +// { +// timeOutKeys.append(dateTimeKeys.at(i)); +// } +// } +// setting->endGroup(); +// for(int i=0;ibeginGroup("application"); +// setting->remove(timeOutKeys.at(i)); +// setting->sync(); +// setting->endGroup(); +// setting->beginGroup("datetime"); +// setting->remove(timeOutKeys.at(i)); +// setting->sync(); +// setting->endGroup(); +// } +// setting->beginGroup("lockapplication"); +// QStringList lockdesktopfnList=setting->allKeys(); +// for(int i=0;ivalue(lockdesktopfnList.at(j)).toInt(); +// int value_2=setting->value(lockdesktopfnList.at(j+1)).toInt(); +// if(value_1 > value_2) +// { +// QString tmp=lockdesktopfnList.at(j); +// lockdesktopfnList.replace(j,lockdesktopfnList.at(j+1)); +// lockdesktopfnList.replace(j+1,tmp); +// } +// } +// setting->endGroup(); +// setting->beginGroup("application"); +// QStringList desktopfnList=setting->allKeys(); +// for(int i=0;ivalue(desktopfnList.at(j)).toInt(); +// int value_2=setting->value(desktopfnList.at(j+1)).toInt(); +// if(value_1 < value_2) +// { +// QString tmp=desktopfnList.at(j); +// desktopfnList.replace(j,desktopfnList.at(j+1)); +// desktopfnList.replace(j+1,tmp); +// } +// } +// setting->endGroup(); +// QVector data; +// Q_FOREACH(QString desktopfn,lockdesktopfnList) +// { +// QString desktopfp; +// if(androidDesktopfnList.contains(desktopfn)) +// desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); +// else +// desktopfp=QString("/usr/share/applications/"+desktopfn); +// QFileInfo fileInfo(desktopfp); +// if(!fileInfo.isFile()|| !desktopfpVector.contains(desktopfp)) +// continue; +// data.append(desktopfp); +// } +// Q_FOREACH(QString desktopfn,desktopfnList) +// { +// QString desktopfp; +// if(androidDesktopfnList.contains(desktopfn)) +// desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); +// else +// desktopfp=QString("/usr/share/applications/"+desktopfn); +// QFileInfo fileInfo(desktopfp); +// if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) +// continue; +// data.append(desktopfp); +// } QVector data; - QStringList lockAppListSort; - QStringList lockAppListFp; - QVector lockAppVector; - int index = 0; Q_FOREACH (QString desktopfn, getLockAppList()) { QString desktopfp; - if (m_androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - - lockAppListFp.append(desktopfp); - } - - Q_FOREACH (QString desktopfp, m_desktopfpVector) { - if (lockAppListFp.contains(desktopfp)) { - lockAppVector.append(m_appInfoVector.at(index)); - } - - index++; - } - - qSort(lockAppVector.begin(), lockAppVector.end(), cmpfixedApp); - - for (int index = 0; index < lockAppVector.size(); index++) { - lockAppListSort.append(lockAppVector.at(index).at(0)); - } - - Q_FOREACH (QString desktopfp, lockAppListSort) { - data.append(desktopfp); - } - - Q_FOREACH (QString desktopfn, getUnlockAllList()) { - QString desktopfp; - - if (m_androidDesktopfnList.contains(desktopfn)) { + if (androidDesktopfnList.contains(desktopfn)) { desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); } else { desktopfp = QString("/usr/share/applications/" + desktopfn); @@ -572,7 +560,25 @@ QVector UkuiMenuInterface::getCommonUseApp() QFileInfo fileInfo(desktopfp); - if (!fileInfo.isFile() || !m_desktopfpVector.contains(desktopfp)) { + if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { + continue; + } + + data.append(desktopfp); + } + + Q_FOREACH (QString desktopfn, getUnlockAllList()) { + QString desktopfp; + + if (androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + QFileInfo fileInfo(desktopfp); + + if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { continue; } @@ -590,8 +596,8 @@ QVector UkuiMenuInterface::getAlphabeticClassification() QVector appVector[27]; int index = 0; - while (index < m_appInfoVector.size()) { - QString appname = m_appInfoVector.at(index).at(1); + while (index < appInfoVector.size()) { + QString appname = appInfoVector.at(index).at(1); QString appnamepy = UkuiChineseLetter::getPinyins(appname); if (!appnamepy.isEmpty()) { @@ -599,111 +605,111 @@ QVector UkuiMenuInterface::getAlphabeticClassification() switch (c) { case 'A': - appVector[0].append(m_appInfoVector.at(index)); + appVector[0].append(appInfoVector.at(index)); break; case 'B': - appVector[1].append(m_appInfoVector.at(index)); + appVector[1].append(appInfoVector.at(index)); break; case 'C': - appVector[2].append(m_appInfoVector.at(index)); + appVector[2].append(appInfoVector.at(index)); break; case 'D': - appVector[3].append(m_appInfoVector.at(index)); + appVector[3].append(appInfoVector.at(index)); break; case 'E': - appVector[4].append(m_appInfoVector.at(index)); + appVector[4].append(appInfoVector.at(index)); break; case 'F': - appVector[5].append(m_appInfoVector.at(index)); + appVector[5].append(appInfoVector.at(index)); break; case 'G': - appVector[6].append(m_appInfoVector.at(index)); + appVector[6].append(appInfoVector.at(index)); break; case 'H': - appVector[7].append(m_appInfoVector.at(index)); + appVector[7].append(appInfoVector.at(index)); break; case 'I': - appVector[8].append(m_appInfoVector.at(index)); + appVector[8].append(appInfoVector.at(index)); break; case 'J': - appVector[9].append(m_appInfoVector.at(index)); + appVector[9].append(appInfoVector.at(index)); break; case 'K': - appVector[10].append(m_appInfoVector.at(index)); + appVector[10].append(appInfoVector.at(index)); break; case 'L': - appVector[11].append(m_appInfoVector.at(index)); + appVector[11].append(appInfoVector.at(index)); break; case 'M': - appVector[12].append(m_appInfoVector.at(index)); + appVector[12].append(appInfoVector.at(index)); break; case 'N': - appVector[13].append(m_appInfoVector.at(index)); + appVector[13].append(appInfoVector.at(index)); break; case 'O': - appVector[14].append(m_appInfoVector.at(index)); + appVector[14].append(appInfoVector.at(index)); break; case 'P': - appVector[15].append(m_appInfoVector.at(index)); + appVector[15].append(appInfoVector.at(index)); break; case 'Q': - appVector[16].append(m_appInfoVector.at(index)); + appVector[16].append(appInfoVector.at(index)); break; case 'R': - appVector[17].append(m_appInfoVector.at(index)); + appVector[17].append(appInfoVector.at(index)); break; case 'S': - appVector[18].append(m_appInfoVector.at(index)); + appVector[18].append(appInfoVector.at(index)); break; case 'T': - appVector[19].append(m_appInfoVector.at(index)); + appVector[19].append(appInfoVector.at(index)); break; case 'U': - appVector[20].append(m_appInfoVector.at(index)); + appVector[20].append(appInfoVector.at(index)); break; case 'V': - appVector[21].append(m_appInfoVector.at(index)); + appVector[21].append(appInfoVector.at(index)); break; case 'W': - appVector[22].append(m_appInfoVector.at(index)); + appVector[22].append(appInfoVector.at(index)); break; case 'X': - appVector[23].append(m_appInfoVector.at(index)); + appVector[23].append(appInfoVector.at(index)); break; case 'Y': - appVector[24].append(m_appInfoVector.at(index)); + appVector[24].append(appInfoVector.at(index)); break; case 'Z': - appVector[25].append(m_appInfoVector.at(index)); + appVector[25].append(appInfoVector.at(index)); break; default: - appVector[26].append(m_appInfoVector.at(index)); + appVector[26].append(appInfoVector.at(index)); break; } } @@ -763,55 +769,55 @@ QVector UkuiMenuInterface::getFunctionalClassification() QVector appVector[11]; int index = 0; - while (index < m_appInfoVector.size()) { - int count = m_appInfoVector.at(index).size() - 5; + while (index < appInfoVector.size()) { + int count = appInfoVector.at(index).size() - 5; for (int i = 0; i < count; i++) { - int category = m_appInfoVector.at(index).at(5 + i).toInt(); + int category = appInfoVector.at(index).at(5 + i).toInt(); switch (category) { case 0: - appVector[0].append(m_appInfoVector.at(index)); + appVector[0].append(appInfoVector.at(index)); break; case 1: - appVector[1].append(m_appInfoVector.at(index)); + appVector[1].append(appInfoVector.at(index)); break; case 2: - appVector[2].append(m_appInfoVector.at(index)); + appVector[2].append(appInfoVector.at(index)); break; case 3: - appVector[3].append(m_appInfoVector.at(index)); + appVector[3].append(appInfoVector.at(index)); break; case 4: - appVector[4].append(m_appInfoVector.at(index)); + appVector[4].append(appInfoVector.at(index)); break; case 5: - appVector[5].append(m_appInfoVector.at(index)); + appVector[5].append(appInfoVector.at(index)); break; case 6: - appVector[6].append(m_appInfoVector.at(index)); + appVector[6].append(appInfoVector.at(index)); break; case 7: - appVector[7].append(m_appInfoVector.at(index)); + appVector[7].append(appInfoVector.at(index)); break; case 8: - appVector[8].append(m_appInfoVector.at(index)); + appVector[8].append(appInfoVector.at(index)); break; case 9: - appVector[9].append(m_appInfoVector.at(index)); + appVector[9].append(appInfoVector.at(index)); break; case 10: - appVector[10].append(m_appInfoVector.at(index)); + appVector[10].append(appInfoVector.at(index)); break; default: @@ -860,7 +866,7 @@ bool UkuiMenuInterface::matchingAppCategories(QString desktopfp, QStringList cat void UkuiMenuInterface::getAndroidApp() { - m_androidDesktopfnList.clear(); + androidDesktopfnList.clear(); QVector androidVector; androidVector.clear(); QString path = QDir::homePath() + "/.local/share/applications/"; @@ -901,57 +907,22 @@ void UkuiMenuInterface::getAndroidApp() QByteArray fpbyte = filePathStr.toLocal8Bit(); char *filepath = fpbyte.data(); - - if (0 != access(filepath, R_OK)) { //判断文件是否可读 - i++; - continue; - } - - m_keyfile = g_key_file_new(); - - if (!g_key_file_load_from_file(m_keyfile, filepath, m_flags, m_error)) { - return; - } - - char *ret_1 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); - - if (ret_1 != nullptr) { - QString str = QString::fromLocal8Bit(ret_1); - - if (str.contains("true")) { - g_key_file_free(m_keyfile); - i++; - continue; - } - } - - char *ret_2 = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); - - if (ret_2 != nullptr) { - QString str = QString::fromLocal8Bit(ret_2); - - if (str.contains("UKUI")) { - g_key_file_free(m_keyfile); - i++; - continue; - } - } - - //过滤LXQt、KDE - char *ret = g_key_file_get_locale_string(m_keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); - - if (ret != nullptr) { - QString str = QString::fromLocal8Bit(ret); - - if (str.contains("LXQt") || str.contains("KDE")) { - g_key_file_free(m_keyfile); - i++; - continue; - } - } - - m_filePathList.append(filePathStr); - m_androidDesktopfnList.append(fileInfo.fileName()); + g_key_file_load_from_file(keyfile, filepath, flags, error); +// char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); +// if(ret_1!=nullptr) +// { +// QString str=QString::fromLocal8Bit(ret_1); +// if(!str.contains("Android")) +// { +// i++; +// continue; +// } +// else +// { + filePathList.append(filePathStr); + androidDesktopfnList.append(fileInfo.fileName()); +// } +// } i++; } while (i < list.size()); diff --git a/src/Interface/ukuimenuinterface.h b/src/Interface/ukuimenuinterface.h old mode 100644 new mode 100755 index 521786a..c241c27 --- a/src/Interface/ukuimenuinterface.h +++ b/src/Interface/ukuimenuinterface.h @@ -31,26 +31,26 @@ class UkuiMenuInterface { private: - QStringList m_filePathList; + QStringList filePathList; - GError **m_error = nullptr; - GKeyFileFlags m_flags = G_KEY_FILE_NONE; - GKeyFile *m_keyfile = nullptr; + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=nullptr; protected: - void recursiveSearchFile(const QString &_filePath);//遍历/usr/share/applications/文件夹 + void recursiveSearchFile(const QString& _filePath);//遍历/usr/share/applications/文件夹 QStringList getSpecifiedCategoryAppList(QString categorystr);//获取指定类型应用列表 public: UkuiMenuInterface(); ~UkuiMenuInterface(); - QVector createSoftwareAppInfoVector();//创建软件商店应用信息容器 - static QVector m_appInfoVector; - static QVector m_desktopfpVector; - static QVector m_alphabeticVector; - static QVector m_functionalVector; - static QVector m_allAppVector; - static QStringList m_androidDesktopfnList; + QVector createAppInfoVector();//创建应用信息容器 + static QVector appInfoVector; + static QVector desktopfpVector; + static QVector alphabeticVector; + static QVector functionalVector; + static QVector allAppVector; + static QStringList androidDesktopfnList; /** * 获取系统应用名称 @@ -65,16 +65,14 @@ public: QString getAppType(QString desktopfp);//获取应用类型 QString getAppComment(QString desktopfp);//获取应用注释 QStringList getDesktopFilePath();//获取系统deskyop文件路径 - QStringList getFunctionClassName();//获取功能类别名称 QVector getAlphabeticClassification();//字母分类模块 QVector getFunctionalClassification();//功能分类模块 QVector getCommonUseApp();//获取常用App QVector getAllClassification();//所有软件模块 void getAndroidApp();//获取安卓应用 - static bool cmpApp(QStringList &arg_1, QStringList &arg_2); - static bool cmpfixedApp(QStringList &arg_1, QStringList &arg_2); - bool matchingAppCategories(QString desktopfp, QStringList categorylist); //匹配应用Categories + static bool cmpApp(QStringList &arg_1,QStringList &arg_2); + bool matchingAppCategories(QString desktopfp,QStringList categorylist);//匹配应用Categories QString getAppNameInitials(QString desktopfp);//获取应用名所有首字母 QString getAppNameInitial(QString desktopfp);//获取应用名所有首字母 QString getAppNamePinyin(QString appname);//获取应用名拼音 diff --git a/src/LetterWidget/fullletterwidget.cpp b/src/LetterWidget/fullletterwidget.cpp old mode 100644 new mode 100755 index 4f4d021..d0aa93a --- a/src/LetterWidget/fullletterwidget.cpp +++ b/src/LetterWidget/fullletterwidget.cpp @@ -76,11 +76,10 @@ void FullLetterWidget::initAppListWidget() QHBoxLayout *layout = new QHBoxLayout(m_applistWid); layout->setContentsMargins(0, 0, 0, 0); m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollArea->setWidgetResizable(true); m_scrollAreaWidLayout = new QVBoxLayout; m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); @@ -106,7 +105,7 @@ void FullLetterWidget::setFocusToThis() void FullLetterWidget::fillAppList() { m_letterList.clear(); - QVector vector = UkuiMenuInterface::m_alphabeticVector; + QVector vector = UkuiMenuInterface::alphabeticVector; for (int i = 0; i < vector.size(); i++) { QStringList appList = vector.at(i); @@ -131,6 +130,13 @@ void FullLetterWidget::fillAppList() connect(listview, &FullListView::sendSetslidebar, this, &FullLetterWidget::onSetSlider); connect(this, &FullLetterWidget::selectFirstItem, listview, &FullListView::selectFirstItem); listview->installEventFilter(this); + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { + QEventLoop loop; + QTimer::singleShot(1, &loop, SLOT(quit())); + loop.exec(); + listview->repaint(listview->rect()); + }); m_scrollAreaWidLayout->addWidget(listview); m_data.clear(); @@ -231,7 +237,7 @@ void FullLetterWidget::resizeScrollAreaControls() void FullLetterWidget::initLetterListWidget() { m_letterListScrollArea = new ClassifyBtnScrollArea(m_letterListWid); - m_letterListScrollAreaWid = new ClassifyBtnScrollAreaWid(m_letterListScrollArea); + m_letterListScrollAreaWid = new ClassifyBtnScrollAreaWid; m_letterListScrollAreaWidLayout = new QVBoxLayout; m_letterListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); m_letterListScrollAreaWidLayout->setSpacing(0); @@ -241,7 +247,7 @@ void FullLetterWidget::initLetterListWidget() m_letterListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); m_btnGroup = new QButtonGroup(m_letterListScrollAreaWid); m_animation = new QPropertyAnimation(m_letterListScrollArea, "geometry"); - m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value", this); + m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullLetterWidget::animationFinishSlot); connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullLetterWidget::animationValueChangedSlot); @@ -411,7 +417,6 @@ void FullLetterWidget::repaintWidget() Style::AppListWidHeight); m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height()); updateAppListView(); } diff --git a/src/LetterWidget/fullletterwidget.h b/src/LetterWidget/fullletterwidget.h old mode 100644 new mode 100755 diff --git a/src/LetterWidget/letterbuttonwidget.cpp b/src/LetterWidget/letterbuttonwidget.cpp old mode 100644 new mode 100755 diff --git a/src/LetterWidget/letterbuttonwidget.h b/src/LetterWidget/letterbuttonwidget.h old mode 100644 new mode 100755 diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp old mode 100644 new mode 100755 index e5b1767..f029f1f --- a/src/LetterWidget/letterwidget.cpp +++ b/src/LetterWidget/letterwidget.cpp @@ -89,7 +89,7 @@ void LetterWidget::fillAppListView() { m_data.clear(); int row = 0; - QVector vector = UkuiMenuInterface::m_alphabeticVector; + QVector vector = UkuiMenuInterface::alphabeticVector; for (int i = 0; i < vector.size(); i++) { QStringList appList = vector.at(i); @@ -147,7 +147,7 @@ void LetterWidget::updateAppListView() m_data.clear(); m_letterList.clear(); m_letterBtnRowList.clear(); - QVector vector = UkuiMenuInterface::m_alphabeticVector; + QVector vector = UkuiMenuInterface::alphabeticVector; for (int i = 0; i < vector.size(); i++) { QStringList appList = vector.at(i); diff --git a/src/LetterWidget/letterwidget.h b/src/LetterWidget/letterwidget.h old mode 100644 new mode 100755 diff --git a/src/MainViewWidget/directorychangedthread.cpp b/src/MainViewWidget/directorychangedthread.cpp old mode 100644 new mode 100755 index d261771..6ff4c21 --- a/src/MainViewWidget/directorychangedthread.cpp +++ b/src/MainViewWidget/directorychangedthread.cpp @@ -21,8 +21,7 @@ #include #include "src/UtilityFunction/utility.h" -DirectoryChangedThread::DirectoryChangedThread(QObject *parent): - QThread(parent) +DirectoryChangedThread::DirectoryChangedThread() { m_ukuiMenuInterface = new UkuiMenuInterface; } @@ -41,9 +40,9 @@ void DirectoryChangedThread::run() openDataBase("DirectoryChangedThread"); QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath(); - if (desktopfpList.size() >= UkuiMenuInterface::m_desktopfpVector.size()) { //有新的应用安装 + if (desktopfpList.size() >= UkuiMenuInterface::desktopfpVector.size()) { //有新的应用安装 for (int i = 0; i < desktopfpList.count(); i++) { - if (!UkuiMenuInterface::m_desktopfpVector.contains(desktopfpList.at(i))) { + if (!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i))) { QFileInfo fileInfo(desktopfpList.at(i)); QString desktopfn = fileInfo.fileName(); updateDataBaseTableRecent(desktopfn); @@ -51,9 +50,9 @@ void DirectoryChangedThread::run() } } } else { //软件卸载 - for (int i = 0; i < UkuiMenuInterface::m_desktopfpVector.size(); i++) { - if (!desktopfpList.contains(UkuiMenuInterface::m_desktopfpVector.at(i))) { - QString desktopfp = UkuiMenuInterface::m_appInfoVector.at(i).at(0); + for (int i = 0; i < UkuiMenuInterface::desktopfpVector.size(); i++) { + if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) { + QString desktopfp = UkuiMenuInterface::appInfoVector.at(i).at(0); QFileInfo fileInfo(desktopfp); QString desktopfn = fileInfo.fileName(); deleteAppRecord(desktopfn); @@ -62,5 +61,11 @@ void DirectoryChangedThread::run() } } + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::alphabeticVector.clear(); + UkuiMenuInterface::functionalVector.clear(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT requestUpdateSignal(); } diff --git a/src/MainViewWidget/directorychangedthread.h b/src/MainViewWidget/directorychangedthread.h old mode 100644 new mode 100755 index ef4ac44..63f9ef4 --- a/src/MainViewWidget/directorychangedthread.h +++ b/src/MainViewWidget/directorychangedthread.h @@ -27,12 +27,12 @@ class DirectoryChangedThread: public QThread { Q_OBJECT public: - DirectoryChangedThread(QObject *parent = nullptr); + DirectoryChangedThread(); ~DirectoryChangedThread(); void run(); private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; Q_SIGNALS: /** diff --git a/src/MainViewWidget/mainviewwidget.cpp b/src/MainViewWidget/mainviewwidget.cpp old mode 100644 new mode 100755 index 3e0e9ca..e3ef9a0 --- a/src/MainViewWidget/mainviewwidget.cpp +++ b/src/MainViewWidget/mainviewwidget.cpp @@ -48,8 +48,8 @@ void MainViewWidget::initUi() QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); - m_topWidget = new QWidget(this); - m_contentWid = new QWidget(this); + m_topWidget = new QWidget; + m_contentWid = new QWidget; mainLayout->addWidget(m_topWidget); mainLayout->addWidget(m_contentWid); this->setLayout(mainLayout); @@ -71,7 +71,8 @@ void MainViewWidget::initUi() << QString("/var/lib/snapd/desktop/applications/") << QString("/var/lib/flatpak/exports/share/applications/")); connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &MainViewWidget::directoryChangedSlot); - m_directoryChangedThread = new DirectoryChangedThread(this); + m_directoryChangedThread = new DirectoryChangedThread; + m_directoryChangedThread->setParent(this); connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &MainViewWidget::requestUpdateSlot); connect(this, &MainViewWidget::directoryChangedSignal, m_letterWid, &LetterWidget::updateAppListView); connect(this, &MainViewWidget::directoryChangedSignal, m_fullLetterWid, &FullLetterWidget::updateAppListView); @@ -102,6 +103,7 @@ void MainViewWidget::initUi() connect(m_commonUseWid, &CommonUseWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); connect(m_functionWid, &FunctionWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); connect(m_letterWid, &LetterWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); + connect(m_searchResultWid, &SearchResultWidget::sendMainWinActiveSignal, this, &MainViewWidget::sendMainWinActiveSignal); addTopControl(); //加载默认视图 //搜索区 @@ -130,19 +132,10 @@ void MainViewWidget::initUi() } }); - //监控图标主题与字体变化 + //监控图标主题 if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - m_gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit(), QByteArray(), this); - connect(m_gsetting, &QGSettings::changed, [ = ](QString key) { - if (key == "iconThemeName" || key == "icon-theme-name") { - Q_EMIT directoryChangedSignal(); - } - - if (key == "systemFont" || key == "systemFontSize") { - repaintWidget(); - repaintTextline(); - } - }); + m_gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(m_gsetting, &QGSettings::changed, this, &MainViewWidget::iconThemeChangeSlot); } } @@ -153,28 +146,20 @@ void MainViewWidget::addTopControl() { m_topLayout = new QHBoxLayout; m_topLayout->setSpacing(0); - m_queryLineEdit = new MyLineEdit(this); - m_queryLineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); - m_queryLineEdit->setAttribute(Qt::WA_KeyCompression); + m_queryLineEdit = new MyLineEdit; m_topLayout->addWidget(m_queryLineEdit); m_topWidget->setLayout(m_topLayout); - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); initQueryLineEdit(); } @@ -193,7 +178,8 @@ void MainViewWidget::addTopControl() */ void MainViewWidget::initQueryLineEdit() { - m_queryWid = new QWidget(m_queryLineEdit); + m_queryWid = new QWidget; + m_queryWid->setParent(m_queryLineEdit); m_queryWid->setFocusPolicy(Qt::NoFocus); QHBoxLayout *queryWidLayout = new QHBoxLayout; queryWidLayout->setContentsMargins(0, 0, 0, 0); @@ -209,11 +195,12 @@ void MainViewWidget::initQueryLineEdit() } pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon = new QLabel(this); + m_queryIcon = new QLabel; m_queryIcon->setFixedSize(pixmap.size()); m_queryIcon->setPixmap(pixmap); - m_queryText = new QLabel(this); + m_queryText = new QLabel; m_queryText->setText(tr("Search")); + m_queryText->adjustSize(); queryWidLayout->addWidget(m_queryIcon); queryWidLayout->addWidget(m_queryText); queryWidLayout->setAlignment(m_queryIcon, Qt::AlignVCenter); @@ -221,10 +208,11 @@ void MainViewWidget::initQueryLineEdit() m_queryLineEdit->setFocusPolicy(Qt::ClickFocus); m_queryLineEdit->installEventFilter(this); m_queryLineEdit->setContextMenuPolicy(Qt::NoContextMenu); - m_animation = new QPropertyAnimation(m_queryWid, "geometry", this); + m_animation = new QPropertyAnimation(m_queryWid, "geometry", m_queryWid); m_animation->setDuration(100); connect(m_animation, &QPropertyAnimation::finished, this, &MainViewWidget::animationFinishedSlot); - m_searchAppThread = new SearchAppThread(this); + m_searchAppThread = new SearchAppThread; + m_searchAppThread->setParent(this); connect(this, &MainViewWidget::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword); connect(m_searchAppThread, &SearchAppThread::sendSearchResult, @@ -235,40 +223,30 @@ void MainViewWidget::initQueryLineEdit() bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) { if (watched == m_queryLineEdit) { - if ((m_queryIcon->x() == 0) && - (event->type() == QEvent::MouseButtonPress || - event->type() == QEvent::InputMethod)) { + if ((m_queryIcon->x() == 0) && (event->type() == QEvent::KeyPress || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::InputMethod)) { if (m_queryLineEdit->text().isEmpty() || (m_queryWid->layout()->count() != 2)) { QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn)); return false; } } - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; if (event->type() == QEvent::FocusIn && m_queryLineEdit->hasFocus()) { if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditClickedDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } - } else { - queryLineStyle = QString("QLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditClickedBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditClickedDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditClickedBackground); + } else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditClickedBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); if (!m_queryLineEdit->text().isEmpty() && (m_queryLineEdit->text().size() >= 1)) { if (m_searchKeyWords.isEmpty()) { @@ -296,22 +274,17 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + } else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); m_animation->stop(); m_queryText->adjustSize(); m_animation->setStartValue(QRect(0, 0, @@ -325,22 +298,17 @@ bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if (gsetting.get("style-name").toString() == "ukui-light") { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedDefaultBackground).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } - } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - } + if (gsetting.get("style-name").toString() == "ukui-light") + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedDefaultBackground, QueryLineEditDefaultBackground); + else + sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + } else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); } m_isSearching = false; @@ -362,25 +330,12 @@ void MainViewWidget::setLineEditFocus(QString arg) } } -void MainViewWidget::repaintTextline() -{ - m_queryWid->layout()->removeWidget(m_queryIcon); - m_queryIcon->setParent(nullptr); - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); - m_queryWid->layout()->addWidget(m_queryIcon); - m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); -} - /** * 搜索程序和文件槽函数 */ void MainViewWidget::searchAppSlot(QString arg) { - //切换至搜索模块 - if (!arg.isEmpty()) { + if (!arg.isEmpty()) { //切换至搜索模块 if (m_widgetState != 0) { m_widgetState = 0; @@ -406,7 +361,7 @@ void MainViewWidget::searchAppSlot(QString arg) m_queryLineEdit->setTextMargins(-5, 0, 0, 0); } - myDebug() << QTime::currentTime() << "m_queryWid(x, y) = (" << m_queryWid->x() << "," << m_queryWid->y() << ")"; + qDebug() << QTime::currentTime() << "m_queryWid(x, y) = (" << m_queryWid->x() << "," << m_queryWid->y() << ")"; Q_EMIT sendSearchKeyword(arg); m_searchAppThread->start(); } else { //搜索模块显示所有的软件 @@ -457,19 +412,16 @@ void MainViewWidget::recvSearchResult(QVector arg) void MainViewWidget::animationFinishedSlot() { - //进入搜索状态 - if (m_isSearching) { - // m_queryWid->layout()->removeWidget(m_queryText); - // m_queryText->setParent(nullptr); + if (m_isSearching) { //进入搜索状态 +// m_queryWid->layout()->removeWidget(m_queryText); +// m_queryText->setParent(nullptr); m_queryLineEdit->setTextMargins(20, 0, 0, 0); if (!m_searchKeyWords.isEmpty()) { m_queryLineEdit->setText(m_searchKeyWords); m_searchKeyWords.clear(); } - } - //退出搜索状态 - else { + } else { //退出搜索状态 m_queryWid->layout()->addWidget(m_queryText); m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); @@ -478,8 +430,7 @@ void MainViewWidget::animationFinishedSlot() if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - //反黑 - if (gsetting.get("style-name").toString() == "ukui-light") { + if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 pe.setColor(QPalette::Text, QColor(Qt::black)); } else { pe.setColor(QPalette::Text, QColor(Qt::white)); @@ -517,30 +468,25 @@ void MainViewWidget::loadMinMainView() m_queryWid->show(); } - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; QPalette pe = m_queryText->palette(); const auto ratio = devicePixelRatioF(); QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); if (gsetting.get("style-name").toString() == "ukui-light") { - pixmap = drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑 pe.setColor(QPalette::Text, QColor(Qt::black)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); } else { - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 pe.setColor(QPalette::Text, QColor(Qt::white)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); } - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon->setPixmap(pixmap); m_queryText->setPalette(pe); @@ -567,7 +513,6 @@ void MainViewWidget::loadMaxMainView() { this->setFixedSize(Style::MainViewWidWidth, Style::heightavailable); - myDebug() << "width" << this->width() << "height" << this->height(); //搜索区 m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight); m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight); @@ -589,15 +534,13 @@ void MainViewWidget::loadMaxMainView() m_queryWid->show(); } - QPalette linePe = m_queryLineEdit->palette(); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - m_queryLineEdit->setStyleSheet(queryLineStyle); + char style[200]; + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + m_queryLineEdit->setStyleSheet(style); const auto ratio = devicePixelRatioF(); QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 QPalette pe = m_queryText->palette(); pe.setColor(QPalette::Text, QColor(Qt::white)); m_queryText->setPalette(pe); @@ -605,7 +548,6 @@ void MainViewWidget::loadMaxMainView() m_queryIcon->setPixmap(pixmap); //内容区 m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - myDebug() << "m_contentWid size" << m_contentWid->size() << "m_widgetState" << m_widgetState; if (m_widgetState == 0) { loadFullSearchResultWidget(); @@ -640,7 +582,6 @@ void MainViewWidget::resizeControl() (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2, 0); m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - myDebug() << "void MainViewWidget::resizeControl()" << m_contentWid->size(); } else { this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh); m_topWidget->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultTopWidHeight); @@ -665,10 +606,7 @@ void MainViewWidget::resetQueryLine() m_queryText->adjustSize(); m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); - QPalette linePe = m_queryLineEdit->palette(); - QColor colorDark = linePe.color(QPalette::Dark); - QColor colorLight = linePe.color(QPalette::Light); - QString queryLineStyle; + char style[200]; const auto ratio = devicePixelRatioF(); QPalette pe = m_queryText->palette(); QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); @@ -677,31 +615,33 @@ void MainViewWidget::resetQueryLine() QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); if (gsetting.get("style-name").toString() == "ukui-light") { - pixmap = drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑 pe.setColor(QPalette::Text, QColor(Qt::black)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditDefaultBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorDark.red()).arg(colorDark.green()).arg(colorDark.blue()).arg(colorDark.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); } else { - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 pe.setColor(QPalette::Text, QColor(Qt::white)); - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); } } else { - queryLineStyle = QString("MyLineEdit{border: 1px solid %1; background-color:%2;border-radius:4px;color:%3;}"). - arg(QueryLineEditClickedBorder).arg(QueryLineEditBackground). - arg(QString("rgba(%1,%2,%3,%4)").arg(colorLight.red()).arg(colorLight.green()).arg(colorLight.blue()).arg(colorLight.alpha())); - pixmap = drawSymbolicColoredPixmap(pixmap);//反白 + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder, QueryLineEditBackground); + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 pe.setColor(QPalette::Text, QColor(Qt::white)); } - m_queryLineEdit->setStyleSheet(queryLineStyle); + m_queryLineEdit->setStyleSheet(style); pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon->setPixmap(pixmap); m_queryText->setPalette(pe); } + + m_queryLineEdit->setFocus(); + QTimer::singleShot(1, this, [ = ]() { + m_queryLineEdit->simulateFocusOutEvent(nullptr); + }); } /** @@ -772,7 +712,6 @@ void MainViewWidget::loadFullCommonUseWidget() m_fullFunctionWid->widgetMakeZero(); hideWidget(); m_fullCommonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); - myDebug() << "m_fullCommonUseWid size" << m_fullCommonUseWid->size() << "mainViewWidget size" << this->size() << "m_topWidget size" << m_topWidget->size(); m_fullCommonUseWid->show(); m_fullCommonUseWid->updateListView(); m_widgetState = 1; @@ -861,7 +800,7 @@ void MainViewWidget::changeFocuDown() */ void MainViewWidget::ViewOpenedSlot(QString desktopfp) { - QVector desktopfpVec = UkuiMenuInterface::m_desktopfpVector; + QVector desktopfpVec = UkuiMenuInterface::desktopfpVector; if (desktopfpVec.contains(desktopfp)) { QFileInfo fileInfo(desktopfp); @@ -889,15 +828,16 @@ void MainViewWidget::directoryChangedSlot(const QString &path) void MainViewWidget::requestUpdateSlot() { m_directoryChangedThread->quit(); - UkuiMenuInterface::m_appInfoVector.clear(); - UkuiMenuInterface::m_alphabeticVector.clear(); - UkuiMenuInterface::m_functionalVector.clear(); - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT directoryChangedSignal(); } +void MainViewWidget::iconThemeChangeSlot(QString key) +{ + if (key == "iconThemeName" || key == "icon-theme-name") { + Q_EMIT directoryChangedSignal(); + } +} + void MainViewWidget::reloadUkuiMenu() { Q_EMIT directoryChangedSignal(); @@ -916,14 +856,6 @@ void MainViewWidget::repaintWidget() m_fullSearchResultWid->repaintWidget(); } -void MainViewWidget::repaintFullWidget() -{ - m_fullCommonUseWid->repaintWidget(); - m_fullLetterWid->repaintWidget(); - m_fullFunctionWid->repaintWidget(); - m_fullSearchResultWid->repaintWidget(); -} - void MainViewWidget::widgetMakeZero() { m_isSearching = false; @@ -984,9 +916,9 @@ void MainViewWidget::keyPressEvent(QKeyEvent *e) } switch (e->key()) { - case Qt::Key_Enter : - case Qt::Key_Return : - case Qt::Key_Down : { + case Qt::Key_Enter: + case Qt::Key_Return: + case Qt::Key_Down: { if (m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty()) { if (m_isFullScreen) { m_fullSearchResultWid->setViewFocus(); diff --git a/src/MainViewWidget/mainviewwidget.h b/src/MainViewWidget/mainviewwidget.h old mode 100644 new mode 100755 index fe96abd..67332c8 --- a/src/MainViewWidget/mainviewwidget.h +++ b/src/MainViewWidget/mainviewwidget.h @@ -44,38 +44,17 @@ #include "directorychangedthread.h" #include "src/Style/style.h" -class MyLineEdit : public QLineEdit -{ +class MyLineEdit : public QLineEdit{ Q_OBJECT public: - explicit MyLineEdit(QWidget *parent = nullptr) - { - unsetCursor(); - } - ~MyLineEdit() - { - if (m_focusEvent != nullptr) { - delete m_focusEvent; - m_focusEvent = nullptr; - } + explicit MyLineEdit(QLineEdit *parent = nullptr){unsetCursor();} + ~MyLineEdit(){} - if (m_focusOut != nullptr) { - delete m_focusOut; - m_focusOut = nullptr; - } + void simulateFocusOutEvent(QKeyEvent *e){ + QApplication::postEvent(this, new QEvent(QEvent::FocusOut)); + this->focusOutEvent(new QFocusEvent(QEvent::FocusOut)); } - - void simulateFocusOutEvent(QKeyEvent *e) - { - m_focusOut = new QEvent(QEvent::FocusOut); - QApplication::postEvent(this, m_focusOut); - m_focusEvent = new QFocusEvent(QEvent::FocusOut); - this->focusOutEvent(m_focusEvent); - } -private: - QFocusEvent *m_focusEvent = nullptr; - QEvent *m_focusOut = nullptr; }; class MainViewWidget : public QWidget @@ -106,10 +85,6 @@ public: * @brief Repaint window */ void repaintWidget(); - /** - * @brief Only repaint full window - */ - void repaintFullWidget(); /** * @brief changeFocuUp */ @@ -130,49 +105,44 @@ public: void resetQueryLine(); - MyLineEdit *getQueryLineEditer() - { - return m_queryLineEdit; - } + MyLineEdit* getQueryLineEditer() {return m_queryLineEdit;} private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QWidget *m_topWidget = nullptr; - QHBoxLayout *m_topLayout = nullptr; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + QWidget *m_topWidget=nullptr; + QHBoxLayout *m_topLayout=nullptr; - QWidget *m_contentWid = nullptr; + QWidget *m_contentWid=nullptr; - MyLineEdit *m_queryLineEdit = nullptr; - QWidget *m_queryWid = nullptr; - QLabel *m_queryIcon = nullptr; - QLabel *m_queryText = nullptr; - bool m_isSearching = false; + MyLineEdit *m_queryLineEdit=nullptr; + QWidget *m_queryWid=nullptr; + QLabel *m_queryIcon=nullptr; + QLabel *m_queryText=nullptr; + bool m_isSearching; QString m_searchKeyWords; - QPropertyAnimation *m_animation = nullptr; + QPropertyAnimation *m_animation=nullptr; - FullSearchResultWidget *m_fullSearchResultWid = nullptr; - SearchResultWidget *m_searchResultWid = nullptr; - SearchAppThread *m_searchAppThread = nullptr; - CommonUseWidget *m_commonUseWid = nullptr; - LetterWidget *m_letterWid = nullptr; - FunctionWidget *m_functionWid = nullptr; - FullCommonUseWidget *m_fullCommonUseWid = nullptr; - FullLetterWidget *m_fullLetterWid = nullptr; - FullFunctionWidget *m_fullFunctionWid = nullptr; + FullSearchResultWidget *m_fullSearchResultWid=nullptr; + SearchResultWidget *m_searchResultWid=nullptr; + SearchAppThread *m_searchAppThread=nullptr; + CommonUseWidget *m_commonUseWid=nullptr; + LetterWidget *m_letterWid=nullptr; + FunctionWidget *m_functionWid=nullptr; + FullCommonUseWidget *m_fullCommonUseWid=nullptr; + FullLetterWidget *m_fullLetterWid=nullptr; + FullFunctionWidget *m_fullFunctionWid=nullptr; - DirectoryChangedThread *m_directoryChangedThread = nullptr; + DirectoryChangedThread *m_directoryChangedThread=nullptr; - int m_widgetState = 1; //Classification window number - int m_saveCurrentWidState = -1; //Store the current category window number + int m_widgetState=1;//Classification window number + int m_saveCurrentWidState=-1;//Store the current category window number - bool m_isFullScreen = false; + bool m_isFullScreen=false; // bool m_isHiden=false; - QFileSystemWatcher *m_fileWatcher = nullptr; //Monitor desktop folder status + QFileSystemWatcher *m_fileWatcher=nullptr;//Monitor desktop folder status - QGSettings *m_gsetting = nullptr; - - void repaintTextline(); + QGSettings *m_gsetting=nullptr; protected: /** @@ -191,7 +161,7 @@ protected: void loadSearchResultWidget(); void loadFullSearchResultWidget(); void hideWidget(); - void keyPressEvent(QKeyEvent *e); + void keyPressEvent(QKeyEvent* e); // void focusInEvent(QFocusEvent *event); public Q_SLOTS: @@ -249,6 +219,10 @@ public Q_SLOTS: * @brief Monitor icon theme changes * @param key: Key */ + void iconThemeChangeSlot(QString key); + /** + * @brief Request for updating the application list + */ void requestUpdateSlot(); void setFocusToThis(); diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp old mode 100644 new mode 100755 index ff5ef81..214d35d --- a/src/MainWindow/mainwindow.cpp +++ b/src/MainWindow/mainwindow.cpp @@ -37,25 +37,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { getCurrentCPU(); - openDataBase("MainThreadDataBase"); - initDatabase(); - m_softwareDbThread = new SoftwareDatabaseUpdateThread(this); - //获取软件商店类别信号 - QDBusConnection::sessionBus().connect("com.kylin.softwarecenter.getsearchresults", - "/com/kylin/softwarecenter/getsearchresults", - "com.kylin.getsearchresults", - "get_app_category_list_signal", - this, - SLOT(updateAppCategorySlot(QString)) - ); + openDataBase("MainThread"); m_ukuiMenuInterface = new UkuiMenuInterface; - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); - UkuiMenuInterface::m_allAppVector = m_ukuiMenuInterface->getAllClassification(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + initDatabase(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::allAppVector = m_ukuiMenuInterface->getAllClassification(); Style::initWidStyle(); initUi(); - m_dbus = new DBus(this); + m_dbus = new DBus; new MenuAdaptor(m_dbus); QDBusConnection con = QDBusConnection::sessionBus(); @@ -65,13 +56,12 @@ MainWindow::MainWindow(QWidget *parent) : } connect(m_dbus, &DBus::sendReloadSignal, this, [ = ] { - UkuiMenuInterface::m_appInfoVector.clear(); - UkuiMenuInterface::m_alphabeticVector.clear(); - UkuiMenuInterface::m_functionalVector.clear(); - - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::alphabeticVector.clear(); + UkuiMenuInterface::functionalVector.clear(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT m_mainViewWid->reloadUkuiMenu(); }); connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { @@ -79,12 +69,14 @@ MainWindow::MainWindow(QWidget *parent) : { QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); +// if(gsetting.keys().contains("win-key-release")) +// if(gsetting.get("win-key-release").toBool()) +// return; if (gsetting.keys().contains("winKeyRelease")) if (gsetting.get("winKeyRelease").toBool()) { return; } } - if (QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) { QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit()); @@ -98,7 +90,6 @@ MainWindow::MainWindow(QWidget *parent) : if (this->isVisible()) { this->hide(); - m_mainViewWid->widgetMakeZero(); } else { this->loadMainWindow(); @@ -106,12 +97,13 @@ MainWindow::MainWindow(QWidget *parent) : this->raise(); this->activateWindow(); } + m_mainViewWid->widgetMakeZero(); }); } MainWindow::~MainWindow() { - closeDataBase("MainThreadDataBase"); + closeDataBase("MainThread"); if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; @@ -123,28 +115,31 @@ void MainWindow::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); this->setAttribute(Qt::WA_TranslucentBackground, true); - this->setAttribute(Qt::WA_InputMethodEnabled); - this->setAttribute(Qt::WA_KeyCompression); this->setAutoFillBackground(false); this->setFocusPolicy(Qt::NoFocus); this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); this->setMinimumSize(Style::minw, Style::minh); this->setContentsMargins(0, 0, 0, 0); - m_frame = new QFrame(this); - m_mainViewWid = new MainViewWidget(this); - m_sideBarWid = new SideBarWidget(this); +// this->setFocus(); + m_frame = new QFrame; + m_mainViewWid = new MainViewWidget; + m_sideBarWid = new SideBarWidget; +// m_frame->installEventFilter(this); +// m_mainViewWid->installEventFilter(this); +// m_sideBarWid->installEventFilter(this); +// setTabOrder(m_mainViewWid , m_sideBarWid); +// setTabOrder(m_sideBarWid , m_mainViewWid); this->setCentralWidget(m_frame); - QHBoxLayout *mainlayout = new QHBoxLayout(this); + QHBoxLayout *mainlayout = new QHBoxLayout; mainlayout->setContentsMargins(0, 0, 0, 0); mainlayout->setSpacing(0); m_frame->setLayout(mainlayout); mainlayout->addWidget(m_mainViewWid); - m_line = new QFrame(this); + m_line = new QFrame; m_line->installEventFilter(this); m_line->setFrameShape(QFrame::VLine); - m_line->setFixedSize(1, this->height() - 5); + m_line->setFixedSize(1, this->height() - 1); m_line->setEnabled(false); - m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); mainlayout->addWidget(m_line); mainlayout->addWidget(m_sideBarWid); m_sideBarWid->loadMinSidebar(); @@ -152,7 +147,6 @@ void MainWindow::initUi() m_animation = new QPropertyAnimation(this, "geometry"); connect(m_animation, &QPropertyAnimation::finished, this, &MainWindow::animationValueFinishedSlot); connect(m_sideBarWid, &SideBarWidget::setFocusToMainWin, m_mainViewWid, &MainViewWidget::selectFirstItemTab); - connect(m_sideBarWid, &SideBarWidget::setLineEditFocus, m_mainViewWid, &MainViewWidget::setLineEditFocus); connect(m_sideBarWid, &SideBarWidget::sendCommonUseBtnSignal, m_mainViewWid, &MainViewWidget::loadCommonUseWidget); connect(m_sideBarWid, &SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget); connect(m_sideBarWid, &SideBarWidget::sendFunctionBtnSignal, m_mainViewWid, &MainViewWidget::loadFunctionWidget); @@ -185,8 +179,8 @@ void MainWindow::initUi() //监听屏幕缩放 if (QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) { - QGSettings xsetting(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); - connect(&xsetting, &QGSettings::changed, this, [ = ](const QString & key) { + QGSettings *m_gsetting = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); + connect(m_gsetting, &QGSettings::changed, this, [ = ](const QString & key) { if (key == "scalingFactor") { repaintWidget(); } @@ -194,8 +188,8 @@ void MainWindow::initUi() } if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { - QGSettings psetting(QString("org.ukui.panel.settings").toLocal8Bit()); - connect(&psetting, &QGSettings::changed, + QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); + connect(gsetting, &QGSettings::changed, this, &MainWindow::panelChangedSlot); } } @@ -210,33 +204,27 @@ void MainWindow::getCurrentCPU() processCpuInfo->waitForFinished(); QString ctrCpuInfo = processCpuInfo->readAll(); - if (ctrCpuInfo.indexOf("HUAWEI Kirin") != -1) { + if (ctrCpuInfo.contains("HUAWEI") || ctrCpuInfo.contains("Kirin")) { isHuaWeiPC = true; } - if (ctrCpuInfo.indexOf("HUAWEI kirin 9006C") != -1) { - isHuaWei9006C = true; + if (ctrCpuInfo.contains("PANGU")) { + isPANGU = true; } } + void MainWindow::paintEvent(QPaintEvent *event) { double transparency = getTransparency(); - QRect rect = this->rect().adjusted(4, 3, -3, -3); + QRect rect = this->rect(); QPainterPath path; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; painter.setPen(Qt::transparent); if (!m_isFullScreen) { - qreal radius; - - if (projectCodeName == "V10SP2") { - radius = 12; - } else { - radius = 6; - } - + qreal radius = 6; path.moveTo(rect.topRight() - QPointF(radius, 0)); path.lineTo(rect.topLeft() + QPointF(radius, 0)); path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); @@ -250,16 +238,8 @@ void MainWindow::paintEvent(QPaintEvent *event) painter.setPen(Qt::transparent); painter.setOpacity(transparency); painter.drawPath(path); +// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - QColor color(Qt::black); - - for (int i = 0; i < 5; i++) { - rect = this->rect().adjusted(i, i, - i, - i); - color.setAlpha(transparency * (20 + (i * 10))); - painter.setBrush(Qt::NoBrush); - painter.setPen(QPen(color, 1)); - painter.drawRoundRect(rect, 6, 6); - } } else { //全屏固定背景色(黑底白字) // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { @@ -309,24 +289,31 @@ void MainWindow::paintEvent(QPaintEvent *event) */ void MainWindow::showFullScreenWidget() { + QRect availableGeometry = getScreenAvailableGeometry(); m_isFullScreen = true; this->setContentsMargins(0, 0, 0, 0); int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; +// int width = Style::primaryScreenWidth; +// int height = Style::primaryScreenHeight; QRect startRect; QRect endRect; - if (position == BOTTOM) { - startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + if (position == 0) { + startRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); + } else if (position == 1) { + startRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); + endRect.setRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height()); + } else if (position == 2) { + startRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height()); } else { - startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); } - endRect.setRect(x, y, width, height); this->centralWidget()->layout()->removeWidget(m_mainViewWid); m_mainViewWid->setParent(nullptr); @@ -335,7 +322,7 @@ void MainWindow::showFullScreenWidget() this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); - if (isHuaWei9006C || isHuaWeiPC) { + if (isPANGU || isHuaWeiPC) { is_repaint = false; this->hide(); QEventLoop loop; @@ -365,36 +352,35 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event) } } -void MainWindow::inputMethodEvent(QInputMethodEvent *event) -{ - QInputMethodEvent *iEvent = dynamic_cast(event); - m_mainViewWid->setLineEditFocus(iEvent->commitString()); - myDebug() << iEvent->commitString(); -} - - /** * 显示默认窗口 */ void MainWindow::showDefaultWidget() { + QRect availableGeometry = getScreenAvailableGeometry(); m_isFullScreen = false; this->setContentsMargins(0, 0, 0, 0); int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; + int width = Style::primaryScreenWidth; + int height = Style::primaryScreenHeight; QRect startRect; QRect endRect; - startRect.setRect(x, y, width, height); - if (position == BOTTOM) { - endRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - endRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + if (position == 0) { + endRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); + startRect.setRect(x, y, width, height - panelSize); + } else if (position == 1) { + endRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); + startRect.setRect(x, y + panelSize, width, height - panelSize); + } else if (position == 2) { + endRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x + panelSize, y, width - panelSize, height); } else { - endRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x, y, width - panelSize, height); } this->centralWidget()->layout()->removeWidget(m_mainViewWid); @@ -402,7 +388,7 @@ void MainWindow::showDefaultWidget() this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); - if (isHuaWei9006C || isHuaWeiPC) { + if (isPANGU || isHuaWeiPC) { this->setGeometry(endRect); animationValueFinishedSlot(); } else { @@ -439,22 +425,25 @@ void MainWindow::animationValueFinishedSlot() m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); } + + m_mainViewWid->getQueryLineEditer()->setFocus(); + + if (m_mainViewWid->getQueryLineEditer()->text().isEmpty()) { + qDebug() << "there is no letter in search lineEditer"; + QTimer::singleShot(1, this, [ = ]() { + m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); + }); + } } + void MainWindow::activeWindowSolt(bool flag) { // qDebug() << "void MainWindow::activeWindowSolt(bool flag)"; - if (isHuaWei9006C || isHuaWeiPC) { + if (isPANGU || isHuaWeiPC) { QTimer::singleShot(50, this, SLOT(mainWinShowSlot())); } } -void MainWindow::keyPressEvent(QKeyEvent *e) -{ - if (e->type() == QEvent::KeyPress) { - if ((e->key() >= 0x30 && e->key() <= 0x39) || (e->key() >= 0x41 && e->key() <= 0x5a)) { - m_mainViewWid->setLineEditFocus(e->text()); - } - } -} + void MainWindow::mainWinShowSlot() { this->activateWindow(); @@ -465,6 +454,7 @@ void MainWindow::mainWinShowSlot() qDebug() << "void MainWindow::activeWindowSolt()"; } + /** * 鼠标点击窗口外部事件 */ @@ -484,20 +474,31 @@ bool MainWindow::event(QEvent *event) if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = (QKeyEvent *) event; - if (keyEvent->key() == Qt::Key_Escape) { - this->hide(); - } - +// if (keyEvent->key() == Qt::Key_Tab) +// { +// m_mainViewWid->setFocus(); +// Q_EMIT setFocusSignal(); +// return true; +// } if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || keyEvent->key() == Qt::Key_Tab) { m_mainViewWid->setFocus(); Q_EMIT setFocusSignal(); + // return true; } } + if (event->type() == QEvent::FocusIn) { + m_mainViewWid->getQueryLineEditer()->setFocus(); + QTimer::singleShot(1, this, [ = ]() { + m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); + }); + } + return QWidget::event(event); } + /** * 隐藏窗口 */ @@ -507,14 +508,17 @@ void MainWindow::recvHideMainWindowSlot() // m_mainViewWid->widgetMakeZero(); // m_sideBarWid->widgetMakeZero(); } + void MainWindow::loadMainWindow() { cleanTimeoutApp(); + QRect availableGeometry = getScreenAvailableGeometry(); int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; + int width = Style::primaryScreenWidth; + int height = Style::primaryScreenHeight; this->setFocus(); if (m_isFullScreen) { @@ -522,14 +526,19 @@ void MainWindow::loadMainWindow() QRect startRect; QRect endRect; - if (position == BOTTOM) { - startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); + if (position == 0) { + startRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); + } else if (position == 1) { + startRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); + endRect.setRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height()); + } else if (position == 2) { + startRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height()); } else { - startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); + startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); + endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); } - endRect.setRect(x, y, width, height); this->centralWidget()->layout()->removeWidget(m_mainViewWid); m_mainViewWid->setParent(nullptr); @@ -537,86 +546,157 @@ void MainWindow::loadMainWindow() m_line->setParent(nullptr); this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); +// m_sideBarWid->clearFocus(); +// m_mainViewWid->clearFocus(); m_animation->setDuration(1);//动画总时间 m_animation->setStartValue(startRect); m_animation->setEndValue(endRect); m_animation->setEasingCurve(QEasingCurve::Linear); m_animation->start(); } else { - if (position == BOTTOM) { - this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); - } else if (position == RIGHT) { - this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); - } else { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } +// QGSettings* setting1 = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); +// QString value1 = setting1->get("scaling-factor").toString(); +// double scaling = value1.toDouble(); + qDebug() << "availableGeometry.height();" << availableGeometry.height(); + + if (position == 0) + this->setGeometry(QRect(x + 4, y + availableGeometry.height() - Style::minh - 3, + Style::minw, Style::minh)); + else if (position == 1) { + this->setGeometry(QRect(x + 4, y + panelSize + 4, Style::minw, Style::minh)); + } else if (position == 2) { + this->setGeometry(QRect(x + panelSize + 4, y + 4, Style::minw, Style::minh)); + } else + this->setGeometry(QRect(x + availableGeometry.width() - Style::minw - 4, y + 4, + Style::minw, Style::minh)); + m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); + m_mainViewWid->getQueryLineEditer()->setFocus(); + QTimer::singleShot(1, this, [ = ]() { + m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); + }); } } + void MainWindow::panelChangedSlot(QString key) { Q_UNUSED(key); repaintWidget(); } + void MainWindow::primaryScreenChangeSlot() { Style::initWidStyle(); - m_mainViewWid->repaintFullWidget(); resizeWidget(); } + void MainWindow::repaintWidget() { Style::initWidStyle(); + QRect availableGeometry = getScreenAvailableGeometry();/*qApp->primaryScreen()->availableGeometry();*/ this->setMinimumSize(Style::minw, Style::minh); m_line->setFixedSize(1, this->height() - 1); - m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); m_mainViewWid->repaintWidget(); resizeWidget(); } + void MainWindow::resizeWidget() { + QRect availableGeometry = getScreenAvailableGeometry(); + if (QApplication::activeWindow() == this) { int position = Style::panelPosition; + int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; + int width = Style::primaryScreenWidth; + int height = Style::primaryScreenHeight; if (m_isFullScreen) { - this->setGeometry(x, y, width, height); + if (position == 0) { + this->setGeometry(QRect(x, y, availableGeometry.width(), availableGeometry.height())); + } else if (position == 1) { + this->setGeometry(QRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height())); + } else if (position == 2) { + this->setGeometry(QRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height())); + } else { + this->setGeometry(QRect(x, y, availableGeometry.width(), availableGeometry.height())); + } + m_sideBarWid->loadMaxSidebar(); m_sideBarWid->setSideBarBtnGeometry(); + m_mainViewWid->resizeControl(); } else { - if (position == BOTTOM) { - this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); - } else if (position == RIGHT) { - this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); - } else { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } + if (position == 0) + this->setGeometry(QRect(x + 4, y + availableGeometry.height() - Style::minh - 3, + Style::minw, Style::minh)); + else if (position == 1) { + this->setGeometry(QRect(x + 4, y + panelSize + 4, Style::minw, Style::minh)); + } else if (position == 2) { + this->setGeometry(QRect(x + panelSize + 4, y + 4, Style::minw, Style::minh)); + } else + this->setGeometry(QRect(x + availableGeometry.width() - Style::minw - 4, y + 4, + Style::minw, Style::minh)); + m_sideBarWid->loadMinSidebar(); + m_mainViewWid->resizeControl(); } - m_mainViewWid->resizeControl(); } } +//void MainWindow::setFrameStyle() +//{ +// int position=0; +// int panelSize=0; +// if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) +// { +// QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); +// if(gsetting->keys().contains(QString("panelposition"))) +// position=gsetting->get("panelposition").toInt(); +// else +// position=0; +// if(gsetting->keys().contains(QString("panelsize"))) +// panelSize=gsetting->get("panelsize").toInt(); +// else +// panelSize=46; +// } +// else +// { +// position=0; +// panelSize=46; +// } + +// QRectF rect; +// rect.setX(this->rect().x()+1); +// rect.setY(this->rect().y()+1); +// rect.setWidth(this->rect().width()-2); +// rect.setHeight(this->rect().height()-2); +// qreal radius = 0; +// QPainterPath path; +// if(!m_isFullScreen) +// { +// radius=12; +// } +// else +// { +// radius=0; +// } + +// path.moveTo(rect.topRight() - QPointF(radius, 0)); +// path.lineTo(rect.topLeft() + QPointF(radius, 0)); +// path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); +// path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); +// path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); +// path.lineTo(rect.bottomRight() - QPointF(radius, 0)); +// path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); +// path.lineTo(rect.topRight() + QPointF(0, radius)); +// path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + +// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); +//} + void MainWindow::mainWinHideSlot() { this->hide(); m_mainViewWid->widgetMakeZero(); } -void MainWindow::updateAppCategorySlot(QString category) -{ - m_softwareDbThread->getDatabaseList(category); - m_softwareDbThread->start(); - connect(m_softwareDbThread, &SoftwareDatabaseUpdateThread::updateDatabaseSignal, this, &MainWindow::databaseThreadCloseSlot); -} -void MainWindow::databaseThreadCloseSlot() -{ - m_softwareDbThread->quit(); - UkuiMenuInterface::m_appInfoVector.clear(); - UkuiMenuInterface::m_functionalVector.clear(); - UkuiMenuInterface::m_appInfoVector = m_ukuiMenuInterface->createSoftwareAppInfoVector(); - UkuiMenuInterface::m_functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); - m_mainViewWid->reloadUkuiMenu(); -} diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h old mode 100644 new mode 100755 index 401c6aa..c848ce0 --- a/src/MainWindow/mainwindow.h +++ b/src/MainWindow/mainwindow.h @@ -39,7 +39,6 @@ #include "src/MainViewWidget/mainviewwidget.h" #include "src/DBus/dbus.h" #include "src/DBus/dbus-adaptor.h" -#include "src/UtilityFunction/softwaredatabaseupdatethread.h" #include class MainWindow : public QMainWindow @@ -49,7 +48,10 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); - + /** + * @brief Set the QFrame style + */ +// void setFrameStyle(); /** * @brief Load the main window */ @@ -58,18 +60,18 @@ public: private: - bool m_isFullScreen = false; + bool m_isFullScreen=false; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + + QFrame *m_line=nullptr;//Vertical dividing line + QFrame *m_frame=nullptr; + SideBarWidget *m_sideBarWid=nullptr; + MainViewWidget *m_mainViewWid=nullptr; + + QPropertyAnimation *m_animation=nullptr; bool m_winFlag = false; bool is_repaint = true; - - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - QFrame *m_line = nullptr; //Vertical dividing line - QFrame *m_frame = nullptr; - SideBarWidget *m_sideBarWid = nullptr; - MainViewWidget *m_mainViewWid = nullptr; - QPropertyAnimation *m_animation = nullptr; - DBus *m_dbus = nullptr; - SoftwareDatabaseUpdateThread *m_softwareDbThread = nullptr; + DBus *m_dbus=nullptr; protected: void initUi(); @@ -77,7 +79,7 @@ protected: * @brief Handle events clicking on the outside of the window */ bool event(QEvent *event); - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent* event); /** * @brief The query box responds to keyboard events */ @@ -87,10 +89,6 @@ protected: void mouseReleaseEvent(QMouseEvent *event); - void inputMethodEvent(QInputMethodEvent *event); - - void keyPressEvent(QKeyEvent *e); - public Q_SLOTS: /** * @brief Load the full screen window @@ -112,8 +110,6 @@ public Q_SLOTS: void activeWindowSolt(bool flag); void mainWinShowSlot(); void mainWinHideSlot(); - void updateAppCategorySlot(QString category); - void databaseThreadCloseSlot(); public: Q_SIGNALS: diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/QtSingleApplication b/src/QtSingleApplication/QtSingleApplication old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlocalpeer.cpp b/src/QtSingleApplication/qtlocalpeer.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlocalpeer.h b/src/QtSingleApplication/qtlocalpeer.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/src/QtSingleApplication/qtlockedfile.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile.h b/src/QtSingleApplication/qtlockedfile.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/src/QtSingleApplication/qtlockedfile_unix.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/src/QtSingleApplication/qtlockedfile_win.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/src/QtSingleApplication/qtsingleapplication.cpp old mode 100644 new mode 100755 index 3c3788e..51a3587 --- a/src/QtSingleApplication/qtsingleapplication.cpp +++ b/src/QtSingleApplication/qtsingleapplication.cpp @@ -47,7 +47,6 @@ #include #include #include "src/MainWindow/mainwindow.h" -#include "src/UtilityFunction/utility.h" /*! diff --git a/src/QtSingleApplication/qtsingleapplication.h b/src/QtSingleApplication/qtsingleapplication.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/src/QtSingleApplication/qtsingleapplication.pri old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/src/QtSingleApplication/qtsinglecoreapplication.cpp old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/src/QtSingleApplication/qtsinglecoreapplication.h old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/src/QtSingleApplication/qtsinglecoreapplication.pri old mode 100644 new mode 100755 diff --git a/src/RightClickMenu/menubox.cpp b/src/RightClickMenu/menubox.cpp old mode 100644 new mode 100755 diff --git a/src/RightClickMenu/menubox.h b/src/RightClickMenu/menubox.h old mode 100644 new mode 100755 diff --git a/src/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp old mode 100644 new mode 100755 index b9e4bb3..290eae6 --- a/src/RightClickMenu/rightclickmenu.cpp +++ b/src/RightClickMenu/rightclickmenu.cpp @@ -18,19 +18,45 @@ #include "rightclickmenu.h" #include "src/UtilityFunction/utility.h" -#include "uninstallwhitelist.h" #include RightClickMenu::RightClickMenu(QWidget *parent): QWidget(parent) { - m_cmdProc = new QProcess(this); - m_whiteList = UninstallWhitelist::getInstance()->getWhiteList(); + m_cmdProc = new QProcess; + m_whiteList.append("kylin-screenshot.desktop"); + m_whiteList.append("ukui-notebook.desktop"); + m_whiteList.append("ukui-clock.desktop"); + m_whiteList.append("kylin-calculator.desktop"); + m_whiteList.append("kylin-recorder.desktop"); + m_whiteList.append("kylin-software-center.desktop"); + m_whiteList.append("kylin-camera.desktop"); + m_whiteList.append("biometric-manager.desktop"); + m_whiteList.append("yhkylin-backup-tools.desktop"); + m_whiteList.append("box-manager.desktop"); + m_whiteList.append("ukui-system-monitor.desktop"); + m_whiteList.append("ksc-defender.desktop"); + m_whiteList.append("logview.desktop"); + m_whiteList.append("kylin-service-support.desktop"); + m_whiteList.append("kylin-user-guide.desktop"); + m_whiteList.append("ukui-control-center.desktop"); + m_whiteList.append("peony.desktop"); + m_whiteList.append("engrampa.desktop"); + + if (isPANGU || isHuaWeiPC) { + m_whiteList.append("org.gnome.FileRoller.desktop"); + m_whiteList.append("mate-terminal.desktop"); + m_whiteList.append("hwaudioui.desktop"); + m_whiteList.append("kylin-sogouIme-configtool.desktop"); + } + m_ukuiMenuInterface = new UkuiMenuInterface; } RightClickMenu::~RightClickMenu() { + delete m_cmdProc; + if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; m_ukuiMenuInterface = nullptr; @@ -72,41 +98,24 @@ void RightClickMenu::unfixedFromAllActionTriggerSlot() void RightClickMenu::fixToTaskbarActionTriggerSlot() { - QProcess *process = new QProcess(); - process->start(QString("dpkg -s ukui-panel")); - process->waitForFinished(); - QString str = process->readAll(); - delete process; - - QList strList = str.split('\n'); - QString version; - for(int i = 0; i < strList.size(); i++) { - if(strList.at(i).startsWith("Version")) { - version = strList.at(i); - version = version.mid(version.indexOf(" ") + 1); - break; - } - } - - if (version.startsWith("3.0")) { - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); - } else { - QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "AddToTaskbar"); - message << m_desktopfp; - QDBusConnection::sessionBus().send(message); - } +// QDBusInterface iface("com.ukui.panel.desktop", +// "/", +// "com.ukui.panel.desktop", +// QDBusConnection::sessionBus()); +// QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); + QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "AddToTaskbar"); + message << m_desktopfp; + QDBusConnection::sessionBus().send(message); m_actionNumber = 3; } void RightClickMenu::unfixedFromTaskbarActionTriggerSlot() { - QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "RemoveFromTaskbar"); - message << m_desktopfp; - QDBusConnection::sessionBus().send(message); + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("RemoveFromTaskbar", m_desktopfp); m_actionNumber = 4; } @@ -135,8 +144,8 @@ void RightClickMenu::uninstallActionTriggerSlot() QString cmd = QString("kylin-uninstaller %1") .arg(m_desktopfp.toLocal8Bit().data()); bool ret = QProcess::startDetached(cmd); - myDebug() << "卸载:" << cmd << ret; - myDebug() << "kylin-uninstaller"; + qDebug() << "卸载:" << cmd << ret; + qDebug() << "kylin-uninstaller"; // } // else // { @@ -222,7 +231,13 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from all"), this, SLOT(unfixedFromAllActionTriggerSlot())); - if (!checkIfFixedToTaskbar(desktopfn)) + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("CheckIfExist", desktopfp); + + if (!ret) m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to taskbar"), this, SLOT(fixToTaskbarActionTriggerSlot())); else @@ -248,6 +263,7 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) m_showAppMenu.setAttribute(Qt::WA_TranslucentBackground); m_showAppMenu.setAttribute(Qt::WA_DeleteOnClose); m_showAppMenu.exec(pos); + qDebug() << "RightClickMenu::showAppBtnMenu(QString desktopfp)"; return m_actionNumber; } @@ -269,6 +285,7 @@ int RightClickMenu::showShutdownMenu(const QPoint &pos) m_showShutMenu.setAttribute(Qt::WA_DeleteOnClose); m_showShutMenu.raise(); m_showShutMenu.exec(pos); + qDebug() << "RightClickMenu::showShutdownMenu()"; return m_actionNumber; } @@ -296,42 +313,6 @@ int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) m_showOtherMenu.setAttribute(Qt::WA_TranslucentBackground); m_showOtherMenu.setAttribute(Qt::WA_DeleteOnClose); m_showOtherMenu.exec(pos); + qDebug() << "RightClickMenu::showOtherMenu(QString desktopfp)"; return m_actionNumber; } - -QList > RightClickMenu::getTaskbarFixedList() -{ - QSettings settings(QDir::homePath() + "/.config/ukui/panel.conf", QSettings::IniFormat); - QList > array; - int size = settings.beginReadArray("/taskbar/apps"); - - for (int i = 0; i < size; ++i) { - settings.setArrayIndex(i); - QMap hash; - const auto keys = settings.childKeys(); - - for (const QString &key : keys) { - hash[key] = settings.value(key); - } - - array << hash; - } - - return array; -} - -bool RightClickMenu::checkIfFixedToTaskbar(const QString &desktopfp) -{ - QString fixdDesktop; - const auto apps = getTaskbarFixedList(); - - for (const QMap &app : apps) { - fixdDesktop = app.value("desktop", "").toString(); - - if (fixdDesktop.contains(desktopfp)) { - return true; - } - } - - return false; -} diff --git a/src/RightClickMenu/rightclickmenu.h b/src/RightClickMenu/rightclickmenu.h old mode 100644 new mode 100755 index 2177159..5760972 --- a/src/RightClickMenu/rightclickmenu.h +++ b/src/RightClickMenu/rightclickmenu.h @@ -73,8 +73,8 @@ public: private: QString m_desktopfp; int m_actionNumber; - QProcess *m_cmdProc = nullptr; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QProcess *m_cmdProc=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; QStringList m_whiteList; @@ -145,10 +145,6 @@ private Q_SLOTS: */ void otherListActionTriggerSlot(); - QList > getTaskbarFixedList(); - - bool checkIfFixedToTaskbar(const QString &desktopfp); - public: Q_SIGNALS: void sendMainWinActiveSignal(bool flag); diff --git a/src/RightClickMenu/uninstallwhitelist.cpp b/src/RightClickMenu/uninstallwhitelist.cpp deleted file mode 100644 index 51e5cbe..0000000 --- a/src/RightClickMenu/uninstallwhitelist.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - -UninstallWhitelist *UninstallWhitelist::instance = nullptr; - -UninstallWhitelist::UninstallWhitelist() -{ - m_whiteList.append("kylin-screenshot.desktop"); - m_whiteList.append("ukui-notebook.desktop"); - m_whiteList.append("ukui-clock.desktop"); - m_whiteList.append("kylin-calculator.desktop"); - m_whiteList.append("kylin-recorder.desktop"); - m_whiteList.append("kylin-software-center.desktop"); - m_whiteList.append("kylin-camera.desktop"); - m_whiteList.append("biometric-manager.desktop"); - m_whiteList.append("yhkylin-backup-tools.desktop"); - m_whiteList.append("box-manager.desktop"); - m_whiteList.append("ukui-system-monitor.desktop"); - m_whiteList.append("ksc-defender.desktop"); - m_whiteList.append("logview.desktop"); - m_whiteList.append("kylin-service-support.desktop"); - m_whiteList.append("kylin-user-guide.desktop"); - m_whiteList.append("ukui-control-center.desktop"); - m_whiteList.append("peony.desktop"); - m_whiteList.append("engrampa.desktop"); - - if (isHuaWei9006C || isHuaWeiPC) { - m_whiteList.append("org.gnome.FileRoller.desktop"); - m_whiteList.append("mate-terminal.desktop"); - m_whiteList.append("hwaudioui.desktop"); - } -} - -UninstallWhitelist *UninstallWhitelist::getInstance() -{ - if (instance == nullptr) { - instance = new UninstallWhitelist(); - } - - return instance; -} - -QStringList UninstallWhitelist::getPkgNameWhiteList() -{ - QStringList pkgNameList; - - Q_FOREACH (QString desktop, m_whiteList) { - QProcess *processPkgName = new QProcess(); - processPkgName->start(QString("dpkg -S /usr/share/applications/%1").arg(desktop)); - connect(processPkgName, static_cast(&QProcess::finished), this, [ = ]() { - processPkgName->deleteLater(); - }); - processPkgName->waitForFinished(); - QString pkgName = processPkgName->readAll(); - pkgName = pkgName.left(pkgName.indexOf(":")); - pkgNameList.append(pkgName); - } - - return pkgNameList; -} - -QStringList UninstallWhitelist::getWhiteList() -{ - return m_whiteList; -} diff --git a/src/RightClickMenu/uninstallwhitelist.h b/src/RightClickMenu/uninstallwhitelist.h deleted file mode 100644 index a478292..0000000 --- a/src/RightClickMenu/uninstallwhitelist.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 - -class UninstallWhitelist : public QObject -{ - Q_OBJECT - -public: - static UninstallWhitelist *getInstance(); - /** - * @brief 获取不可卸载包名列表 - * @return - */ - QStringList getPkgNameWhiteList(); - /** - * @brief 获取不可卸载desktop列表 - * @return - */ - QStringList getWhiteList(); -private: - UninstallWhitelist(); -private: - static UninstallWhitelist *instance; - - QStringList m_whiteList; -}; - -#endif // UNINSTALLWHITELIST_H diff --git a/src/SearchResultWidget/file-utils.cpp b/src/SearchResultWidget/file-utils.cpp old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/file-utils.h b/src/SearchResultWidget/file-utils.h old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp old mode 100644 new mode 100755 index ffb7b6f..49ee973 --- a/src/SearchResultWidget/fullsearchresultwidget.cpp +++ b/src/SearchResultWidget/fullsearchresultwidget.cpp @@ -49,8 +49,8 @@ void FullSearchResultWidget::initUi() mainLayout->addItem(m_spaceItem); m_listView = new FullListView(this, 3); this->setLayout(mainLayout); - m_scrollArea = new ScrollArea(this); - m_scrollAreaWid = new ScrollAreaWid(m_scrollArea); + m_scrollArea = new ScrollArea; + m_scrollAreaWid = new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); m_scrollArea->setWidget(m_scrollAreaWid); @@ -114,11 +114,13 @@ void FullSearchResultWidget::repaintWidget() this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); +// this->layout()->setContentsMargins(Style::LeftWidWidth,0,0,0); m_scrollAreaWidLayout->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; m_listView = new FullListView(this, 3); m_scrollAreaWidLayout->insertWidget(0, m_listView); + m_data.clear(); m_listView->addData(m_data); resizeScrollAreaControls(); connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); diff --git a/src/SearchResultWidget/fullsearchresultwidget.h b/src/SearchResultWidget/fullsearchresultwidget.h old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/pinyinWithTone.txt b/src/SearchResultWidget/pinyinWithTone.txt old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/pinyinWithoutTone.txt b/src/SearchResultWidget/pinyinWithoutTone.txt old mode 100644 new mode 100755 diff --git a/src/SearchResultWidget/searchappthread.cpp b/src/SearchResultWidget/searchappthread.cpp old mode 100644 new mode 100755 index 36d69a0..a332168 --- a/src/SearchResultWidget/searchappthread.cpp +++ b/src/SearchResultWidget/searchappthread.cpp @@ -20,8 +20,7 @@ #include #include "src/SearchResultWidget/file-utils.h" -SearchAppThread::SearchAppThread(QObject *parent): - QThread(parent) +SearchAppThread::SearchAppThread() { m_ukuiMenuInterface = new UkuiMenuInterface; } @@ -37,7 +36,7 @@ SearchAppThread::~SearchAppThread() void SearchAppThread::run() { m_appInfoVector.clear(); - m_appInfoVector = UkuiMenuInterface::m_appInfoVector; + m_appInfoVector = UkuiMenuInterface::appInfoVector; m_searchResultVector.clear(); m_searchFirstVector.clear(); m_searchRestVector.clear(); @@ -45,7 +44,45 @@ void SearchAppThread::run() if (!this->m_keyWord.isEmpty()) { QString str = m_ukuiMenuInterface->getAppNamePinyin(m_keyWord); int index = 0; +// if(str.size()==1) +// { +// int num=static_cast(str.toLocal8Bit().at(0)); +// QStringList searchDesktopList; +// searchDesktopList.clear(); +// if(num>=65 && num<=90) +// { +// for(int i=0;igetAppNamePinyin(m_appInfoVector.at(index).at(1)); +//// QString appEnglishName=m_appInfoVector.at(index).at(2); +// QString appNameFl=m_appInfoVector.at(index).at(3); +// if(appNameFl==str)//匹配首字母 +// { +// m_searchResultVector.append(m_appInfoVector.at(index)); +// } +// index++; +// } +// } +//// else if(num<48 || (num>57 && num<65) || num>90) +//// for(int i=0;igetAppName(searchDesktopList.at(i))); +// } +// } +// else + //{ while (index < m_appInfoVector.size()) { // QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(m_appInfoVector.at(index).at(1)); QStringList appNameLs; @@ -62,8 +99,7 @@ void SearchAppThread::run() QString appEnglishName = m_appInfoVector.at(index).at(2); //QString appNameFls=m_appInfoVector.at(index).at(4); - if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { - //中文正则表达式 + if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { //中文正则表达式 if (appName.toUpper().contains(m_keyWord.toUpper())) { m_searchResultVector.append(m_appInfoVector.at(index)); } @@ -83,6 +119,7 @@ void SearchAppThread::run() } index++; + //} } } diff --git a/src/SearchResultWidget/searchappthread.h b/src/SearchResultWidget/searchappthread.h old mode 100644 new mode 100755 index 852d311..9447d73 --- a/src/SearchResultWidget/searchappthread.h +++ b/src/SearchResultWidget/searchappthread.h @@ -26,7 +26,7 @@ class SearchAppThread : public QThread { Q_OBJECT public: - SearchAppThread(QObject *parent = nullptr); + SearchAppThread(); ~SearchAppThread(); void run(); @@ -36,7 +36,7 @@ private: QVector m_searchFirstVector; QVector m_searchRestVector; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; QVector m_appInfoVector; public Q_SLOTS: diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp old mode 100644 new mode 100755 index 116ffcb..691eff5 --- a/src/SearchResultWidget/searchresultwidget.cpp +++ b/src/SearchResultWidget/searchresultwidget.cpp @@ -51,6 +51,7 @@ void SearchResultWidget::initUi() m_ukuiMenuInterface = new UkuiMenuInterface; connect(m_listView, &ListView::sendItemClickedSignal, this, &SearchResultWidget::execApplication); connect(m_listView, &ListView::sendHideMainWindowSignal, this, &SearchResultWidget::sendHideMainWindowSignal); + connect(m_listView, &ListView::sendMainWinActiveSignal, this, &SearchResultWidget::sendMainWinActiveSignal); } /** diff --git a/src/SearchResultWidget/searchresultwidget.h b/src/SearchResultWidget/searchresultwidget.h old mode 100644 new mode 100755 index 2897b23..ce3b5ec --- a/src/SearchResultWidget/searchresultwidget.h +++ b/src/SearchResultWidget/searchresultwidget.h @@ -59,8 +59,8 @@ public: void setViewFocus(); private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - ListView* m_listView=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + ListView *m_listView = nullptr; QVector m_data; protected: @@ -81,6 +81,8 @@ Q_SIGNALS: * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); + + void sendMainWinActiveSignal(bool flag); }; #endif // SEARCHRESULTWIDGET_H diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp old mode 100644 new mode 100755 index 57e70ac..7cb2b3e --- a/src/SideBarWidget/sidebarwidget.cpp +++ b/src/SideBarWidget/sidebarwidget.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include "src/Style/style.h" #include "src/UtilityFunction/utility.h" @@ -49,31 +48,19 @@ void SideBarWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_StyledBackground, true); - this->setAttribute(Qt::WA_InputMethodEnabled); - this->setAttribute(Qt::WA_KeyCompression); this->setFocusPolicy(Qt::NoFocus); addSidebarBtn(); loadMinSidebar(); m_minMaxBtn->installEventFilter(this); - m_minMaxBtn->setAttribute(Qt::WA_KeyCompression); - m_minMaxBtn->setAttribute(Qt::WA_InputMethodEnabled); m_allBtn->installEventFilter(this); m_letterBtn->installEventFilter(this); m_functionBtn->installEventFilter(this); m_userIconBtn->installEventFilter(this); - m_userIconBtn->setAttribute(Qt::WA_KeyCompression); - m_userIconBtn->setAttribute(Qt::WA_InputMethodEnabled); m_computerBtn->installEventFilter(this); - m_computerBtn->setAttribute(Qt::WA_KeyCompression); - m_computerBtn->setAttribute(Qt::WA_InputMethodEnabled); m_personalBtn->installEventFilter(this); m_controlBtn->installEventFilter(this); - m_controlBtn->setAttribute(Qt::WA_KeyCompression); - m_controlBtn->setAttribute(Qt::WA_InputMethodEnabled); m_trashBtn->installEventFilter(this); m_shutDownBtn->installEventFilter(this); - m_shutDownBtn->setAttribute(Qt::WA_KeyCompression); - m_shutDownBtn->setAttribute(Qt::WA_InputMethodEnabled); m_ukuiMenuInterface = new UkuiMenuInterface; // m_shutDownMenu=new RightClickMenu; // m_otherMenu=new RightClickMenu; @@ -103,11 +90,6 @@ bool SideBarWidget::eventFilter(QObject *target, QEvent *event) } } - if (event->type() == QEvent::InputMethod) { - QInputMethodEvent *iEvent = dynamic_cast(event); - Q_EMIT setLineEditFocus(iEvent->commitString()); - } - return QWidget::eventFilter(target, event); } @@ -118,7 +100,8 @@ bool SideBarWidget::eventFilter(QObject *target, QEvent *event) */ void SideBarWidget::addSidebarBtn() { - m_mainWidget = new QWidget(this); + m_mainWidget = new QWidget; + m_mainWidget->setParent(this); m_mainWidgetLayout = new QVBoxLayout; m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6); m_mainWidgetLayout->setSpacing(10); @@ -129,9 +112,9 @@ void SideBarWidget::addSidebarBtn() // palette.setBrush(QPalette::Background,Qt::red); // m_mainWidget->setPalette(palette); //放大缩小按钮界面 - m_minMaxWidget = new QWidget(this); + m_minMaxWidget = new QWidget; m_minMaxLayout = new QHBoxLayout; - m_minMaxBtn = new QPushButton(this); + m_minMaxBtn = new QPushButton; m_minMaxBtn->setFlat(true); m_minMaxBtn->setProperty("useButtonPalette", true); // m_minMaxBtn->setProperty("doNotAnimate",true); @@ -151,19 +134,17 @@ void SideBarWidget::addSidebarBtn() // m_minMaxWidget->hasFocus(); //分类按钮 m_buttonList.clear(); - m_allBtn = new QPushButton(this); + m_allBtn = new QPushButton; initBtn(m_allBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"), tr("All"), 0); - m_letterBtn = new QPushButton(this); + m_letterBtn = new QPushButton; initBtn(m_letterBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"), tr("Letter"), 1); - m_functionBtn = new QPushButton(this); + m_functionBtn = new QPushButton; initBtn(m_functionBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"), tr("Function"), 2); int id = 0; Q_FOREACH (QAbstractButton *btn, m_buttonList) { // m_btnGroup->addButton(btn,id++); btn->setCheckable(true); - btn->setAttribute(Qt::WA_KeyCompression); - btn->setAttribute(Qt::WA_InputMethodEnabled); } QString usericon = getUserIcon(); @@ -189,33 +170,13 @@ void SideBarWidget::addSidebarBtn() connect(m_trashBtn, &QPushButton::clicked, this, &SideBarWidget::trashBtnClickedSlot); connect(m_shutDownBtn, &QPushButton::clicked, this, &SideBarWidget::shutdownBtnClickedSlot); connect(m_userIconBtn, &QPushButton::clicked, this, &SideBarWidget::userIconBtnClickedSlot); - - // 判断控制面版版本号,选择是否屏蔽右键菜单 - QProcess *prosess = new QProcess(this); - prosess->start(QString("dpkg -s ukui-control-center")); - prosess->waitForFinished(); - QString str = prosess->readAll(); - delete prosess; - QList strList = str.split('\n'); - QString version; - - for(int i = 0; i < strList.size(); i++) { - if(strList.at(i).startsWith("Version")) { - version = strList.at(i); - version = version.mid(version.indexOf(" ") + 1); - } - } - - if (version.startsWith("3.0")) { - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QPushButton *btn = qobject_cast(button); - if (m_buttonList.indexOf(button) > 3 && m_buttonList.indexOf(button) < m_buttonList.count() - 1) { - button->setCheckable(false); - addRightClickMenu(btn); - } - } - } - +// Q_FOREACH (QAbstractButton *button, m_buttonList) { +// QPushButton *btn = qobject_cast(button); +// if (m_buttonList.indexOf(button) > 3 && m_buttonList.indexOf(button) < m_buttonList.count() - 1) { +// button->setCheckable(false); +// addRightClickMenu(btn); +// } +// } m_shutDownBtn->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_shutDownBtn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::shutdownBtnRightClickSlot); @@ -239,7 +200,7 @@ void SideBarWidget::addSidebarBtn() m_mainWidgetLayout->addWidget(m_buttonList.at(3)); if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) { - m_gsetting = new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit(), QByteArray(), this); + m_gsetting = new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit()); if (m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) { m_mainWidgetLayout->addWidget(m_buttonList.at(4)); @@ -268,7 +229,7 @@ void SideBarWidget::addSidebarBtn() connect(gsetting, &QGSettings::changed, this, &SideBarWidget::themeModeChangeSlot); } - m_animation = new QPropertyAnimation(m_mainWidget, "geometry", this); + m_animation = new QPropertyAnimation(m_mainWidget, "geometry"); } void SideBarWidget::resetSidebarBtnSlot() @@ -311,7 +272,7 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int btn->setFlat(true); btn->setProperty("useButtonPalette", true); QHBoxLayout *btnLayout = new QHBoxLayout; - QLabel *labelicon = new QLabel(this); + QLabel *labelicon = new QLabel; labelicon->setAlignment(Qt::AlignCenter); const auto ratio = devicePixelRatioF(); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); @@ -330,7 +291,7 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int labelicon->setPixmap(pixmap); } else { if (!QFile::exists(btnicon)) { - btnicon = QString("/usr/share/ukui/faces/default.png"); + btnicon = QString(":/data/img/sidebarwidget/default.svg"); } labelicon->setObjectName("faceLabel"); @@ -347,7 +308,7 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int btnLayout->setSpacing(0); btnLayout->addWidget(labelicon); // btnLayout->addStretch(); - QLabel *textLabel = new QLabel(this); + QLabel *textLabel = new QLabel; if (num == 3) { textLabel->setObjectName("nameLabel"); @@ -390,6 +351,7 @@ void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos) RightClickMenu m_otherMenu(this); int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos)); Q_EMIT sendShowMainWindowSignal(false); + qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; if (ret >= 10 && ret <= 17) { Q_EMIT sendHideMainWindowSignal(); @@ -427,50 +389,55 @@ void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos) break; } } + + qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 结束"; } -void SideBarWidget::addRightClickMenu(QPushButton *btn) -{ - btn->setContextMenuPolicy(Qt::CustomContextMenu); - connect(btn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::otherBtnRightClickSlot); -} +//void SideBarWidget::addRightClickMenu(QPushButton *btn) +//{ +// btn->setContextMenuPolicy(Qt::CustomContextMenu); +// connect(btn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::otherBtnRightClickSlot); +//} -void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) -{ - QPushButton *btn = dynamic_cast(QObject::sender()); - int index = m_buttonList.indexOf(btn); - QString desktopfp; +//void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) +//{ +// qDebug() << "SideBarWidget::otherBtnRightClickSlot() 开始"; +// QPushButton *btn = dynamic_cast(QObject::sender()); +// int index = m_buttonList.indexOf(btn); +// QString desktopfp; - switch (index) { - case 4: - desktopfp = QString("/usr/share/applications/peony-home.desktop"); - break; +// switch (index) { +// case 4: +// desktopfp = QString("/usr/share/applications/peony-home.desktop"); +// break; - case 5: - desktopfp = QString("/usr/share/applications/peony-trash.desktop"); - break; +// case 5: +// desktopfp = QString("/usr/share/applications/peony-trash.desktop"); +// break; - case 6: - desktopfp = QString("/usr/share/applications/peony-computer.desktop"); - break; +// case 6: +// desktopfp = QString("/usr/share/applications/peony-computer.desktop"); +// break; - case 7: - desktopfp = QString("/usr/share/applications/ukui-control-center.desktop"); - break; +// case 7: +// desktopfp = QString("/usr/share/applications/ukui-control-center.desktop"); +// break; - default: - break; - } +// default: +// break; +// } - RightClickMenu m_otherMenu; - int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); - Q_EMIT sendShowMainWindowSignal(false); +// RightClickMenu m_otherMenu; +// int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); +// Q_EMIT sendShowMainWindowSignal(false); - if (ret == 15) { - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-control-center -d")); - } -} +// if (ret == 15) { +// Q_EMIT sendHideMainWindowSignal(); +// QProcess::startDetached(QString("ukui-control-center -d")); +// } + +// qDebug() << "SideBarWidget::otherBtnRightClickSlot() 结束"; +//} void SideBarWidget::computerBtnClickedSlot() { @@ -505,25 +472,7 @@ void SideBarWidget::shutdownBtnClickedSlot() void SideBarWidget::userIconBtnClickedSlot() { Q_EMIT sendHideMainWindowSignal(); - QProcess *prosess = new QProcess(this); - prosess->start(QString("dpkg -s ukui-control-center")); - prosess->waitForFinished(); - QString str = prosess->readAll(); - delete prosess; - QList strList = str.split('\n'); - QString version; - - for(int i = 0; i < strList.size(); i++) { - if(strList.at(i).startsWith("Version")) { - version = strList.at(i); - version = version.mid(version.indexOf(" ") + 1); - } - } - if (version.startsWith("3.0")) { - QProcess::startDetached(QString("ukui-control-center -u")); - } else { - QProcess::startDetached(QString("ukui-control-center -m Userinfo")); - } + QProcess::startDetached(QString("ukui-control-center -m Userinfo")); } void SideBarWidget::userAccountsChanged() @@ -532,7 +481,7 @@ void SideBarWidget::userAccountsChanged() QString usericon = getUserIcon(); if (!QFile::exists(usericon)) { - usericon = QString("/usr/share/ukui/faces/default.png"); + usericon = QString(":/data/img/sidebarwidget/default.svg"); } QPixmap facePixmap(usericon); @@ -770,29 +719,25 @@ void SideBarWidget::btnFuncClickedSlot() void SideBarWidget::themeModeChangeSlot(QString styleName) { if (styleName == "styleName") { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); Q_FOREACH (QAbstractButton *button, m_buttonList) { QPushButton *btn = qobject_cast(button); QLayoutItem *item = btn->layout()->itemAt(0); QLabel *label = qobject_cast(item->widget()); QString iconStr; - QIcon buttIcon; switch (m_buttonList.indexOf(button)) { case 0: iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); - buttIcon = QIcon::fromTheme("commonuse.svg"); break; case 1: iconStr = QString(":/data/img/sidebarwidget/letter.svg"); - buttIcon = QIcon::fromTheme("letter.svg"); break; case 2: iconStr = QString(":/data/img/sidebarwidget/function.svg"); - buttIcon = QIcon::fromTheme("function.svg"); break; case 3: @@ -801,27 +746,22 @@ void SideBarWidget::themeModeChangeSlot(QString styleName) case 4: iconStr = QString(":/data/img/sidebarwidget/personal.svg"); - buttIcon = QIcon::fromTheme("personal.svg"); break; case 5: iconStr = QString(":/data/img/sidebarwidget/trash.svg"); - buttIcon = QIcon::fromTheme("trash.svg"); break; case 6: iconStr = QString(":/data/img/sidebarwidget/computer.svg"); - buttIcon = QIcon::fromTheme("computer.svg"); break; case 7: iconStr = QString(":/data/img/sidebarwidget/setting.svg"); - buttIcon = QIcon::fromTheme("setting.svg"); break; case 8: iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); - buttIcon = QIcon::fromTheme("shutdown.svg"); break; default: @@ -832,13 +772,7 @@ void SideBarWidget::themeModeChangeSlot(QString styleName) const auto ratio = devicePixelRatioF(); QPixmap pixmap = loadSvg(iconStr, 19 * ratio); - if (buttIcon.isNull()) { - pixmap = loadSvg(iconStr, 19 * ratio); - } else { - pixmap = buttIcon.pixmap(QSize(19 * ratio, 19 * ratio)); - } - - if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 + if (gsetting->get("style-name").toString() == "ukui-light") { //反黑 pixmap = drawSymbolicBlackColoredPixmap(pixmap); } else { pixmap = drawSymbolicColoredPixmap(pixmap); //反白 @@ -853,29 +787,25 @@ void SideBarWidget::themeModeChangeSlot(QString styleName) void SideBarWidget::changeIconColor(bool isFullScreen) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); Q_FOREACH (QAbstractButton *button, m_buttonList) { QPushButton *btn = qobject_cast(button); QLayoutItem *item = btn->layout()->itemAt(0); QLabel *label = qobject_cast(item->widget()); QString iconStr; - QIcon buttIcon; switch (m_buttonList.indexOf(button)) { case 0: iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); - buttIcon = QIcon::fromTheme("commonuse.svg"); break; case 1: iconStr = QString(":/data/img/sidebarwidget/letter.svg"); - buttIcon = QIcon::fromTheme("letter.svg"); break; case 2: iconStr = QString(":/data/img/sidebarwidget/function.svg"); - buttIcon = QIcon::fromTheme("function.svg"); break; case 3: @@ -884,27 +814,22 @@ void SideBarWidget::changeIconColor(bool isFullScreen) case 4: iconStr = QString(":/data/img/sidebarwidget/personal.svg"); - buttIcon = QIcon::fromTheme("personal.svg"); break; case 5: iconStr = QString(":/data/img/sidebarwidget/trash.svg"); - buttIcon = QIcon::fromTheme("trash.svg"); break; case 6: iconStr = QString(":/data/img/sidebarwidget/computer.svg"); - buttIcon = QIcon::fromTheme("computer.svg"); break; case 7: iconStr = QString(":/data/img/sidebarwidget/setting.svg"); - buttIcon = QIcon::fromTheme("setting.svg"); break; case 8: iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); - buttIcon = QIcon::fromTheme("shutdown.svg"); break; default: @@ -913,15 +838,9 @@ void SideBarWidget::changeIconColor(bool isFullScreen) if (m_buttonList.indexOf(button) != 3) { const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(iconStr, 19 * ratio); + QPixmap pixmap = loadSvg(iconStr, 18 * ratio); - if (buttIcon.isNull()) { - pixmap = loadSvg(iconStr, 19 * ratio); - } else { - pixmap = buttIcon.pixmap(QSize(19 * ratio, 19 * ratio)); - } - - if (gsetting.get("style-name").toString() == "ukui-light" && !isFullScreen) { //反黑 + if (gsetting->get("style-name").toString() == "ukui-light" && !isFullScreen) { //反黑 pixmap = drawSymbolicBlackColoredPixmap(pixmap); } else { pixmap = drawSymbolicColoredPixmap(pixmap); //反白 @@ -992,7 +911,7 @@ void SideBarWidget::keyPressEvent(QKeyEvent *e) break; case Qt::Key_Down: - myDebug() << "key_Down"; + qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Down"; // focusNextChild(); // if(m_buttonList.at(2)->hasFocus()) // { @@ -1005,7 +924,7 @@ void SideBarWidget::keyPressEvent(QKeyEvent *e) break; case Qt::Key_Up: - myDebug() << "key_Up"; + qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Up"; // /* focusPreviousChild(); // if(m_buttonList.at(0)->hasFocus()) // { diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h old mode 100644 new mode 100755 index 35fb1c2..6e800d1 --- a/src/SideBarWidget/sidebarwidget.h +++ b/src/SideBarWidget/sidebarwidget.h @@ -124,7 +124,7 @@ protected: * @brief Add right-click menu * @param btn: QPushButton */ - void addRightClickMenu(QPushButton *btn); +// void addRightClickMenu(QPushButton* btn); /** * @brief Set the minimize button */ @@ -160,7 +160,7 @@ private Q_SLOTS: /** * @brief Load other application right-click menu */ - void otherBtnRightClickSlot(const QPoint &pos); +// void otherBtnRightClickSlot(const QPoint &pos); /** * @brief Respond to computer btn */ @@ -242,8 +242,6 @@ Q_SIGNALS: void setFocusToMainWin(); void setSlideBar(int value); - - void setLineEditFocus(QString arg); }; #endif // SIDEBARWIDGET_H diff --git a/src/Style/style.cpp b/src/Style/style.cpp old mode 100644 new mode 100755 index 3397119..71719e8 --- a/src/Style/style.cpp +++ b/src/Style/style.cpp @@ -22,484 +22,509 @@ Style::Style() { + } -int Style::primaryScreenX = 0; -int Style::primaryScreenY = 0; -int Style::primaryScreenWidth = 0; -int Style::primaryScreenHeight = 0; -int Style::panelPosition = 0; -int Style::panelSize = 0; +int Style::primaryScreenX=0; +int Style::primaryScreenY=0; +int Style::primaryScreenWidth=0; +int Style::primaryScreenHeight=0; +int Style::panelPosition=0; +int Style::panelSize=0; //默认窗口 -int Style::minw = 0; -int Style::minh = 0; -int Style::defaultMainViewWidWidth = 0; -int Style::defaultTopWidHeight = 0; -int Style::defaultQueryLineEditWidth = 0; -int Style::defaultQueryLineEditHeight = 0; -int Style::defaultQueryLineEditIconSize = 0; -int Style::defaultContentWidHeight = 0; -int Style::defaultSideBarWidWidth = 0; -int Style::defaultIconSize = 32; +int Style::minw=0; +int Style::minh=0; +int Style::defaultMainViewWidWidth=0; +int Style::defaultTopWidHeight=0; +int Style::defaultQueryLineEditWidth=0; +int Style::defaultQueryLineEditHeight=0; +int Style::defaultQueryLineEditIconSize=0; +int Style::defaultContentWidHeight=0; +int Style::defaultSideBarWidWidth=0; +int Style::defaultIconSize=32; /** * 全屏窗口 */ //主窗口 -int Style::widthavailable = 0; -int Style::heightavailable = 0; +int Style::widthavailable=0; +int Style::heightavailable=0; //主视图 -int Style::MainViewWidWidth = 0; +int Style::MainViewWidWidth=0; //搜索栏 -int Style::TopWidgetHeight = 0; -int Style::QueryLineEditWidth = 0; -int Style::QueryLineEditHeight = 0; -int Style::QueryLineEditFontSize = 0; -int Style::QueryLineEditIconSize = 0; +int Style::TopWidgetHeight=0; +int Style::QueryLineEditWidth=0; +int Style::QueryLineEditHeight=0; +int Style::QueryLineEditFontSize=0; +int Style::QueryLineEditIconSize=0; //左侧栏 -int Style::LeftWidWidth = 0; -int Style::LeftWidHeight = 0; -int Style::LeftMargin = 0; -int Style::RightMargin = 0; -int Style::LeftBtnWidth = 0; -int Style::LeftBtnHeight = 0; -int Style::LeftLetterBtnHeight = 0; -int Style::LeftFontSize = 0; -int Style::LeftLetterFontSize = 0; -int Style::LeftIconSize = 0; -int Style::LeftSpaceIconLeft = 0; -int Style::LeftSpaceIconText = 0; -int Style::LeftSpaceBetweenItem = 0; +int Style::LeftWidWidth=0; +int Style::LeftWidHeight=0; +int Style::LeftMargin=0; +int Style::RightMargin=0; +int Style::LeftBtnWidth=0; +int Style::LeftBtnHeight=0; +int Style::LeftLetterBtnHeight=0; +int Style::LeftFontSize=0; +int Style::LeftLetterFontSize=0; +int Style::LeftIconSize=0; +int Style::LeftSpaceIconLeft=0; +int Style::LeftSpaceIconText=0; +int Style::LeftSpaceBetweenItem=0; //应用列表栏 -int Style::AppListWidWidth = 0; -int Style::AppListWidHeight = 0; -int Style::AppListFontSize = 0; -int Style::AppListIconSize = 0; -int Style::AppListItemSizeWidth = 0; -int Style::AppListGridSizeWidth = 0; -int Style::AppLeftSpace = 0; -int Style::AppTopSpace = 0; -int Style::AppSpaceBetweenIconText = 0; -int Style::AppBottomSpace = 0; -int Style::SliderSize = 0; +int Style::AppListWidWidth=0; +int Style::AppListWidHeight=0; +int Style::AppListFontSize=0; +int Style::AppListIconSize=0; +int Style::AppListItemSizeWidth=0; +int Style::AppListGridSizeWidth=0; +int Style::AppLeftSpace=0; +int Style::AppTopSpace=0; +int Style::AppSpaceBetweenIconText=0; +int Style::AppBottomSpace=0; +int Style::SliderSize=0; //侧边栏primaryScreen -int Style::SideBarWidWidth = 0; -int Style::SideBarMargin = 0; -int Style::MinMaxWidWidth = 0; -int Style::MinMaxWidHeight = 0; -int Style::MinMaxBtnWidth = 0; -int Style::MinMaxIconSize = 0; -int Style::SideBarBtnWidth = 0; -int Style::SideBarBtnHeight = 0; -int Style::SideBarFontSize = 0; -int Style::SideBarIconSize = 0; -int Style::SideBarSpaceIconLeft = 0; -int Style::SideBarSpaceIconText = 0; -int Style::SideBarSpaceBetweenItem = 0; +int Style::SideBarWidWidth=0; +int Style::SideBarMargin=0; +int Style::MinMaxWidWidth=0; +int Style::MinMaxWidHeight=0; +int Style::MinMaxBtnWidth=0; +int Style::MinMaxIconSize=0; +int Style::SideBarBtnWidth=0; +int Style::SideBarBtnHeight=0; +int Style::SideBarFontSize=0; +int Style::SideBarIconSize=0; +int Style::SideBarSpaceIconLeft=0; +int Style::SideBarSpaceIconText=0; +int Style::SideBarSpaceBetweenItem=0; void Style::initWidStyle() { - getScreenAvailableGeometry(); - int fontSize = 10; - if (QGSettings::isSchemaInstalled(QString("org.mate.interface").toLocal8Bit())) { - QGSettings *setting = new QGSettings(QString("org.mate.interface").toLocal8Bit()); - if (setting->keys().contains(QString("font-name"))) { - QString value = setting->get("font-name").toString(); - QStringList valstr = value.split(" "); - fontSize = valstr.at(valstr.count() - 1).toInt(); - } + QVariantList list=getScreenGeometry(); + if(list.count()>=6) + { + primaryScreenX=list.at(0).toInt(); + primaryScreenY=list.at(1).toInt(); + primaryScreenWidth=list.at(2).toInt(); + primaryScreenHeight=list.at(3).toInt(); + panelSize=list.at(4).toInt(); + panelPosition=list.at(5).toInt(); } - int len = 0; + QGSettings* setting=new QGSettings(QString("org.mate.interface").toLocal8Bit()); + QString value=setting->get("font-name").toString(); + QStringList valstr=value.split(" "); + int fontSize=valstr.at(valstr.count()-1).toInt(); + + if(panelPosition==0 || panelPosition==1) + { + widthavailable=primaryScreenWidth; + heightavailable=primaryScreenHeight-panelSize; + } + if(panelPosition==2 || panelPosition==3) + { + widthavailable=primaryScreenWidth-panelSize; + heightavailable=primaryScreenHeight; + } + int len=0; QString locale = QLocale::system().name(); + if (locale == "zh_CN") + len=0; + else + len=10; - if (locale == "zh_CN") { - len = 0; - } else { - len = 10; + if(primaryScreenWidth==800 && primaryScreenHeight==600) + { + minw=320; + minh=500; + defaultMainViewWidWidth=264; + defaultTopWidHeight=54; + defaultQueryLineEditWidth=245; + defaultQueryLineEditHeight=30; + defaultContentWidHeight=446; + defaultSideBarWidWidth=55; + } + else + { + minw=376; + minh=590; + defaultMainViewWidWidth=320; + defaultTopWidHeight=54; + defaultQueryLineEditWidth=288; + defaultQueryLineEditHeight=30; + defaultContentWidHeight=536; + defaultSideBarWidWidth=55; } - primaryScreenWidth = qApp->primaryScreen()->geometry().width(); - primaryScreenHeight = qApp->primaryScreen()->geometry().height(); + if(widthavailable>=2000 && widthavailable<=4000) + { + MainViewWidWidth=widthavailable-round((widthavailable-1644)/2); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=16; + LeftWidWidth=round((widthavailable-1644)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=20; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=25; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=14; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=15; + AppListWidWidth=1644; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=96; + AppListItemSizeWidth=168; + AppListGridSizeWidth=204; + AppLeftSpace=36; + AppTopSpace=15; + AppSpaceBetweenIconText=20; +// AppBottomSpace=27; + SliderSize=12; - if (primaryScreenWidth == 800 && primaryScreenHeight == 600) { - minw = 320; - minh = 500; - defaultMainViewWidWidth = 264; - defaultTopWidHeight = 54; - defaultQueryLineEditWidth = 245; - defaultQueryLineEditHeight = 32; - defaultContentWidHeight = 446; - defaultSideBarWidWidth = 55; - } else { - minw = 382; - minh = 594; - defaultMainViewWidWidth = 320; - defaultTopWidHeight = 54; - defaultQueryLineEditWidth = 288; - defaultQueryLineEditHeight = 32; - defaultContentWidHeight = 536; - defaultSideBarWidWidth = 55; + SideBarWidWidth=round((widthavailable-1644)/2); + SideBarMargin=20; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; } + else if (widthavailable>=1920 && widthavailable<2000) { + MainViewWidWidth=widthavailable-round((widthavailable-1314)/2); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=16; + LeftWidWidth=round((widthavailable-1314)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=20; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=25; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=14; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=15; + AppListWidWidth=1314; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=86; + AppListItemSizeWidth=150; + AppListGridSizeWidth=186; + AppLeftSpace=32; + AppTopSpace=13; + AppSpaceBetweenIconText=18; +// AppBottomSpace=27; + SliderSize=12; - if (widthavailable >= 2000 && widthavailable <= 4000) { - AppListWidWidth = 1652; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = 107; - QueryLineEditIconSize = 16; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 20; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 25; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 14; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 15; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 96; - AppListItemSizeWidth = 168; - AppListGridSizeWidth = 202; - AppLeftSpace = 36; - AppTopSpace = 15; - AppSpaceBetweenIconText = 20; -// AppBottomSpace=27; - SliderSize = 20; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 20; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1920 && widthavailable < 2000) { - myDebug() << "[1920,2000)"; - AppListWidWidth = 1322; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = 107; - QueryLineEditIconSize = 16; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 20; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 25; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 14; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 15; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 86; - AppListItemSizeWidth = 150; - AppListGridSizeWidth = 186; - AppLeftSpace = 32; - AppTopSpace = 13; - AppSpaceBetweenIconText = 18; -// AppBottomSpace=27; - SliderSize = 20; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 20; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1600 && widthavailable < 1920) { - myDebug() << "[1600,1920)"; - AppListWidWidth = 1070; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = 107; - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 25; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 86; - AppListItemSizeWidth = 150; - AppListGridSizeWidth = 178; - AppLeftSpace = 32; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SideBarWidWidth=round((widthavailable-1314)/2); + SideBarMargin=20; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1600 && widthavailable<1920) { + MainViewWidWidth=widthavailable-round((widthavailable-1090)/2); + TopWidgetHeight=107; + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-1090)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=25; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=1090; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=86; + AppListItemSizeWidth=150; + AppListGridSizeWidth=180; + AppLeftSpace=32; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.84)); - SliderSize = 18; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1366 && widthavailable < 1600) { - AppListWidWidth = 858; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 138; - AppLeftSpace = 24; - AppTopSpace = 10; - AppSpaceBetweenIconText = 0; + SliderSize=10; + + SideBarWidWidth=round((widthavailable-1090)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1366 && widthavailable<1600) { + MainViewWidWidth=widthavailable-round((widthavailable-850)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-850)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=850; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=140; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=0; // AppBottomSpace=static_cast(round(27*0.74)); - SliderSize = 18; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1280 && widthavailable < 1366) { - AppListWidWidth = 726; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 140; - AppLeftSpace = 24; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=10; + + SideBarWidWidth=round((widthavailable-850)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1280 && widthavailable<1366) { + MainViewWidWidth=widthavailable-round((widthavailable-718)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-718)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=718; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=142; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.65)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable >= 1152 && widthavailable < 1280) { - AppListWidWidth = 726; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 140; - AppLeftSpace = 24; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=8; + + SideBarWidWidth=round((widthavailable-718)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>=1152 && widthavailable<1280) { + MainViewWidWidth=widthavailable-round((widthavailable-718)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-718)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=718; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=142; + AppLeftSpace=24; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.65)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else if (widthavailable > 800 && widthavailable < 1152) { - AppListWidWidth = 580; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 139; - AppLeftSpace = 25; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=8; + + SideBarWidWidth=round((widthavailable-718)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else if (widthavailable>800 && widthavailable<1152){ + MainViewWidWidth=widthavailable-round((widthavailable-572)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-572)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=572; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=141; + AppLeftSpace=25; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.52)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110 + 2 * len; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } else { - AppListWidWidth = 568; - MainViewWidWidth = widthavailable - round((widthavailable - AppListWidWidth) / 2); - TopWidgetHeight = round(107 * 0.78); - QueryLineEditIconSize = 14; - LeftWidWidth = round((widthavailable - AppListWidWidth) / 2); - LeftWidHeight = heightavailable - TopWidgetHeight; - LeftMargin = 10; - LeftBtnWidth = 100 + 5 * len; - LeftBtnHeight = 43; - LeftLetterBtnHeight = 20; - RightMargin = LeftWidWidth - LeftMargin - LeftBtnWidth; - LeftLetterFontSize = 11; - LeftIconSize = 17; - LeftSpaceIconLeft = 15; - LeftSpaceIconText = 14; - LeftSpaceBetweenItem = 10; - AppListWidHeight = heightavailable - TopWidgetHeight; - AppListIconSize = 64; - AppListItemSizeWidth = 112; - AppListGridSizeWidth = 136; - AppLeftSpace = 25; - AppTopSpace = 10; - AppSpaceBetweenIconText = 14; + SliderSize=8; + + SideBarWidWidth=round((widthavailable-572)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110+2*len; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } + else{ + MainViewWidWidth=widthavailable-round((widthavailable-560)/2); + TopWidgetHeight=round(107*0.78); + QueryLineEditWidth=350; + QueryLineEditHeight=30; + QueryLineEditFontSize=fontSize; + QueryLineEditIconSize=14; + LeftWidWidth=round((widthavailable-560)/2); + LeftWidHeight=heightavailable-TopWidgetHeight; + LeftMargin=10; + LeftBtnWidth=100+5*len; + LeftBtnHeight=43; + LeftLetterBtnHeight=20; + RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; + LeftFontSize=fontSize; + LeftLetterFontSize=11; + LeftIconSize=17; + LeftSpaceIconLeft=15; + LeftSpaceIconText=14; + LeftSpaceBetweenItem=10; + AppListWidWidth=560; + AppListWidHeight=heightavailable-TopWidgetHeight; + AppListFontSize=fontSize; + AppListIconSize=64; + AppListItemSizeWidth=112; + AppListGridSizeWidth=138; + AppLeftSpace=25; + AppTopSpace=10; + AppSpaceBetweenIconText=14; // AppBottomSpace=static_cast(round(27*0.52)); - SliderSize = 16; - SideBarWidWidth = round((widthavailable - AppListWidWidth) / 2); - SideBarMargin = 10; - MinMaxWidWidth = 110; - MinMaxWidHeight = TopWidgetHeight; - MinMaxBtnWidth = 49; - MinMaxIconSize = 19; - SideBarBtnWidth = 110; - SideBarBtnHeight = 43; - SideBarFontSize = fontSize; - SideBarIconSize = 19; - SideBarSpaceIconLeft = 14; - SideBarSpaceIconText = 10; - SideBarSpaceBetweenItem = 16; - } + SliderSize=8; - QueryLineEditWidth = 350; - QueryLineEditHeight = 32; - LeftFontSize = fontSize; - QueryLineEditFontSize = fontSize; - AppListFontSize = fontSize; -} - -//不通过任务栏获取屏幕可用区域数据 -void Style::getScreenAvailableGeometry() -{ - QRect rect; - rect = qApp->primaryScreen()->geometry(); - - QDBusInterface iface(DBUS_NAME, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); - if (reply.isValid()) { - panelSize = reply.value().at(4).toInt(); - panelPosition = reply.value().at(5).toInt(); - } - - QList posIndex; - switch (panelPosition) { - case BOTTOM: - posIndex = {0, 0, 0, -1}; - break; - case TOP: - posIndex = {0, 1, 0, -1}; - break; - case LEFT: - posIndex = {1, 0, -1, 0}; - break; - case RIGHT: - posIndex = {0, 0, -1, 0}; - } - - primaryScreenX = rect.x() + posIndex[0] * panelSize; - primaryScreenY = rect.y() + posIndex[1] * panelSize; - widthavailable = rect.width() + posIndex[2] * panelSize; - heightavailable = rect.height() + posIndex[3] * panelSize; + SideBarWidWidth=round((widthavailable-560)/2); + SideBarMargin=10; + MinMaxWidWidth=110; + MinMaxWidHeight=TopWidgetHeight; + MinMaxBtnWidth=49; + MinMaxIconSize=19; + SideBarBtnWidth=110; + SideBarBtnHeight=43; + SideBarFontSize=fontSize; + SideBarIconSize=19; + SideBarSpaceIconLeft=14; + SideBarSpaceIconText=10; + SideBarSpaceBetweenItem=16; + } } diff --git a/src/Style/style.h b/src/Style/style.h old mode 100644 new mode 100755 index c5ef25c..548a846 --- a/src/Style/style.h +++ b/src/Style/style.h @@ -27,7 +27,6 @@ #include #include #include -#include //颜色 #define BORDERCOLOR "rgba(37,41,43)" //边框 @@ -166,9 +165,6 @@ public: static int SideBarSpaceIconText; //按钮图标与文字内边距 static int SideBarSpaceBetweenItem; //item间距 -private: - static void getScreenAvailableGeometry(); //获取屏幕可用区域 - }; #endif // STYLE_H diff --git a/src/UtilityFunction/classifybtnscrollarea.cpp b/src/UtilityFunction/classifybtnscrollarea.cpp old mode 100644 new mode 100755 index 26a37da..ea0e400 --- a/src/UtilityFunction/classifybtnscrollarea.cpp +++ b/src/UtilityFunction/classifybtnscrollarea.cpp @@ -22,8 +22,7 @@ #include #include -ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid(QWidget *parent): - QWidget(parent) +ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); @@ -31,8 +30,9 @@ ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid(QWidget *parent): void ClassifyBtnScrollAreaWid::paintEvent(QPaintEvent *event) { - double transparency = getTransparency(); + double transparency=getTransparency(); QPainter painter(this); + // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); @@ -62,10 +62,10 @@ void ClassifyBtnScrollAreaWid::paintEvent(QPaintEvent *event) // } // } // else{ - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); // } QWidget::paintEvent(event); } diff --git a/src/UtilityFunction/classifybtnscrollarea.h b/src/UtilityFunction/classifybtnscrollarea.h old mode 100644 new mode 100755 index 797c7e8..41b9bb2 --- a/src/UtilityFunction/classifybtnscrollarea.h +++ b/src/UtilityFunction/classifybtnscrollarea.h @@ -25,17 +25,17 @@ class ClassifyBtnScrollAreaWid: public QWidget { public: - ClassifyBtnScrollAreaWid(QWidget *parent = nullptr); + ClassifyBtnScrollAreaWid(); protected: - void paintEvent(QPaintEvent *event); - // void keyPressEvent(QKeyEvent* e); + void paintEvent(QPaintEvent* event); + // void keyPressEvent(QKeyEvent* e); }; class ClassifyBtnScrollArea : public QScrollArea { public: - explicit ClassifyBtnScrollArea(QWidget *parent = nullptr); + explicit ClassifyBtnScrollArea(QWidget* parent=nullptr); protected: void initWid(); diff --git a/src/UtilityFunction/convertdesktoptowinid.cpp b/src/UtilityFunction/convertdesktoptowinid.cpp old mode 100644 new mode 100755 index cbea3f1..672f8d1 --- a/src/UtilityFunction/convertdesktoptowinid.cpp +++ b/src/UtilityFunction/convertdesktoptowinid.cpp @@ -32,7 +32,7 @@ QString ConvertDesktopToWinId::tranIdToDesktop(WId id) { KWindowInfo info(id, 0, NET::WM2AllProperties); QString desktopName = confirmDesktopFile(info); - myDebug() << "desktopName is :" << desktopName; + qDebug() << "desktopName is :" << desktopName; return desktopName; } diff --git a/src/UtilityFunction/convertdesktoptowinid.h b/src/UtilityFunction/convertdesktoptowinid.h old mode 100644 new mode 100755 index 671672e..09d99f4 --- a/src/UtilityFunction/convertdesktoptowinid.h +++ b/src/UtilityFunction/convertdesktoptowinid.h @@ -36,11 +36,10 @@ #define ANDROID_APP_CURRENT "/.local/share/applications/." #define ANDROID_APP_UPER "/.local/share/applications/.." - /** * @brief The ConvertDesktopToWinId class * 需要实现的功能,desktop文件与windowId的转换 - * 传入desktop文件的路径,转化为(int)WindowId + * 传入WindowId 转化为desktop文件路径 */ class ConvertDesktopToWinId: public QObject diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/fullitemdelegate.h b/src/UtilityFunction/fullitemdelegate.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp old mode 100644 new mode 100755 index 7755089..9bc0aa3 --- a/src/UtilityFunction/fulllistview.cpp +++ b/src/UtilityFunction/fulllistview.cpp @@ -28,11 +28,14 @@ FullListView::FullListView(QWidget *parent, int module): { this->module = module; initWidget(); +// inCurView = false; m_ukuiMenuInterface = new UkuiMenuInterface; +// menu=new RightClickMenu; } FullListView::~FullListView() { +// delete menu; if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; m_ukuiMenuInterface = nullptr; @@ -42,6 +45,8 @@ FullListView::~FullListView() void FullListView::initWidget() { viewport()->setAttribute(Qt::WA_TranslucentBackground); + viewport()->setStyleSheet("background:transparent");//在paint中绘制,滚动页面会导致透明效果绘制不及时出现黑影,将paintEvent替换为样式表 + this->setAutoFillBackground(false); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // if(module==1 || module==2)s @@ -55,17 +60,24 @@ void FullListView::initWidget() this->setMovement(QListView::Static); this->setEditTriggers(QAbstractItemView::NoEditTriggers); this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth)); - myDebug() << "GridSize" << this->gridSize(); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame);//移除边框 this->setStyleSheet(QString::fromUtf8("QStandardItemModel#listmodel{border:3px solid #FFFFFF; }QWidget#widget:focus{ border:5px solid #A5A6A1; } ")); connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); connect(this, &FullListView::clicked, this, &FullListView::onClicked); + flag = true; + //翻页灵敏度时间调节 + time = new QTimer(this); + connect(time, &QTimer::timeout, [ = ]() { + if (flag == false) { + flag = true; + time->stop(); + } + }); } void FullListView::addData(QStringList data) { - myDebug() << "FullListView::addData"; listmodel = new QStandardItemModel(this); this->setModel(listmodel); @@ -81,17 +93,18 @@ void FullListView::addData(QStringList data) void FullListView::focusInEvent(QFocusEvent *event) { + //inCurView = true; return QListView::focusInEvent(event); } void FullListView::focusOutEvent(QFocusEvent *event) { + //inCurView = false; return QListView::focusOutEvent(event); } void FullListView::updateData(QStringList data) { - myDebug() << "FullListView::updateData"; listmodel->clear(); Q_FOREACH (QString desktopfp, data) { @@ -99,8 +112,6 @@ void FullListView::updateData(QStringList data) item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); listmodel->appendRow(item); } - - this->setItemDelegate(m_delegate); } void FullListView::onClicked(QModelIndex index) @@ -183,77 +194,135 @@ void FullListView::leaveEvent(QEvent *e) void FullListView::selectFirstItem() { + qDebug() << "void FullListView::selectFirstItem()"; + if (this->currentIndex().row() == -1) { this->setCurrentIndex(this->model()->index(0, 0)); } } +//void FullListView::paintEvent(QPaintEvent *e) +//{ +// double transparency=getTransparency(); +// QPainter painter(this->viewport()); + +// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) +// { +// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); +// if(gsetting.keys().contains(QString("effect"))) +// { +// if(gsetting.get("effect").toBool()) +// { +// painter.setBrush(Qt::black); +// painter.setPen(Qt::transparent); +// painter.setOpacity(0.25); +// painter.drawRect(this->rect()); +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// } +// else +// { +// painter.setBrush(this->palette().base()); +// painter.setPen(Qt::transparent); +// painter.setOpacity(transparency); +// painter.drawRect(this->rect()); +// } +// QListView::paintEvent(e); +//} void FullListView::keyPressEvent(QKeyEvent *e) { - QRect center = visualRect(currentIndex()); + if (flag) { //避免长按按键界面滚动过快 + flag = false; + time->start(100); + QRect center = visualRect(currentIndex()); - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - break; - } - - case Qt::Key_Left: { - if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { - Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + break; } - return QListView::keyPressEvent(e); - break; - } + case Qt::Key_Left: { + this->clearFocus(); - case Qt::Key_Right: { - if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { - Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); - } - - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Up: { - if (module == 0) { - if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) { + if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); } + + this->setFocus(); + return QListView::keyPressEvent(e); + break; } - return QListView::keyPressEvent(e); - break; - } + case Qt::Key_Right: { + this->clearFocus(); - case Qt::Key_Down: { - if (module == 0) { if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); } + + this->setFocus(); + return QListView::keyPressEvent(e); + break; } - return QListView::keyPressEvent(e); - break; - } + case Qt::Key_Up: { + if (module == 0) { + if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) { + this->clearFocus(); + Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + this->setFocus(); + } + } - default: - return QListView::keyPressEvent(e); - break; + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Down: { + if (module == 0) { + if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { + this->clearFocus(); + Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); + this->setFocus(); + } + } + + return QListView::keyPressEvent(e); + break; + } + + default: + return QListView::keyPressEvent(e); + break; + } } } } -void FullListView::mouseReleaseEvent(QMouseEvent *event) +void FullListView::mousePressEvent(QMouseEvent *event) { if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { Q_EMIT sendHideMainWindowSignal(); } else { - return QListView::mouseReleaseEvent(event); + return QListView::mousePressEvent(event); } } diff --git a/src/UtilityFunction/fulllistview.h b/src/UtilityFunction/fulllistview.h old mode 100644 new mode 100755 index 4e4be10..c5c87d5 --- a/src/UtilityFunction/fulllistview.h +++ b/src/UtilityFunction/fulllistview.h @@ -41,14 +41,13 @@ public: protected: void initWidget(); - void keyPressEvent(QKeyEvent *e); void enterEvent(QEvent *e) Q_DECL_OVERRIDE; void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; - +// void paintEvent(QPaintEvent *e) override; void focusInEvent(QFocusEvent *event); void focusOutEvent(QFocusEvent *event); - void mouseReleaseEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); private: FullItemDelegate *m_delegate = nullptr; @@ -57,9 +56,11 @@ private: double transparency; RightClickMenu *menu = nullptr; //右键菜单 QStringList data; - QGSettings *gsetting; UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + bool flag; + QTimer *time = nullptr; + // bool inCurView; public Q_SLOTS: diff --git a/src/UtilityFunction/functionclassifybutton.cpp b/src/UtilityFunction/functionclassifybutton.cpp old mode 100644 new mode 100755 index 8d7527d..21ee26a --- a/src/UtilityFunction/functionclassifybutton.cpp +++ b/src/UtilityFunction/functionclassifybutton.cpp @@ -24,84 +24,83 @@ #include FunctionClassifyButton::FunctionClassifyButton(int width, - int height, - int iconSize, - QString category, - bool fullscreen, - bool enabled, - QWidget *parent): - QPushButton(parent), + int height, + int iconSize, + QString category, + bool fullscreen, + bool enabled, + QWidget *parent): + QPushButton (parent), m_width(width), m_height(height), m_iconSize(iconSize), m_category(category), m_fullscreen(fullscreen), m_enabled(enabled), - m_iconLabel(new QLabel(this)), - m_textLabel(new QLabel(this)) + m_iconLabel(new QLabel), + m_textLabel(new QLabel) { this->setFlat(true); - this->setFixedSize(m_width, m_height); + this->setFixedSize(m_width,m_height); this->setFocusPolicy(Qt::NoFocus); - m_iconLabel->setFixedSize(m_iconSize, m_iconSize); + m_iconLabel->setFixedSize(m_iconSize,m_iconSize); m_textLabel->adjustSize(); - - if (m_fullscreen) { + if(m_fullscreen) + { QPalette pe = m_textLabel->palette(); - pe.setColor(QPalette::ButtonText, QColor(Qt::white)); + pe.setColor(QPalette::ButtonText,QColor(Qt::white)); m_textLabel->setPalette(pe); } - - m_textLabel->setText(m_category); - - if (m_fullscreen) { + setLabelText(); + if(m_fullscreen) + { updateIconState(Normal); this->setCheckable(true); - } else { - if (m_enabled) { + } + else + { + if(m_enabled) updateIconState(Enabled); - } else { + else updateIconState(Disabled); - } - this->setCheckable(false); } - QHBoxLayout *mainlayout = new QHBoxLayout; - mainlayout->setContentsMargins(Style::LeftSpaceIconLeft, 0, 0, 0); + QHBoxLayout* mainlayout=new QHBoxLayout; + mainlayout->setContentsMargins(Style::LeftSpaceIconLeft,0,0,0); mainlayout->setSpacing(Style::LeftSpaceIconText); this->setLayout(mainlayout); - //mainlayout->addWidget(m_iconLabel); + mainlayout->addWidget(m_iconLabel); mainlayout->addWidget(m_textLabel); - connect(this, &FunctionClassifyButton::toggled, this, &FunctionClassifyButton::reactToToggle); - connect(this, &FunctionClassifyButton::clicked, this, &FunctionClassifyButton::buttonClickedSlot); + connect(this,&FunctionClassifyButton::toggled,this,&FunctionClassifyButton::reactToToggle); + connect(this,&FunctionClassifyButton::clicked,this,&FunctionClassifyButton::buttonClickedSlot); } -void FunctionClassifyButton::paintEvent(QPaintEvent *e) +void FunctionClassifyButton::paintEvent(QPaintEvent* e) { Q_UNUSED(e); QStylePainter painter(this); QStyleOptionButton option; initStyleOption(&option); - if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver)) { painter.save(); painter.setPen(Qt::NoPen); - - if (!m_fullscreen) { + if(!m_fullscreen) + { QColor color = option.palette.color(QPalette::Text); color.setAlphaF(0.15); painter.setBrush(color); - } else { + } + else + { painter.setOpacity(0.15); painter.setBrush(Qt::white); } - painter.drawRoundedRect(option.rect, 4, 4); painter.restore(); } - - if (m_fullscreen && (option.state & QStyle::State_On)) { + if(m_fullscreen && (option.state & QStyle::State_On)) + { painter.save(); painter.setPen(Qt::NoPen); // QColor color = option.palette.color(QPalette::Text); @@ -122,18 +121,17 @@ void FunctionClassifyButton::paintEvent(QPaintEvent *e) void FunctionClassifyButton::updateBtnState() { - if (m_enabled) { + if(m_enabled) updateIconState(Enabled); - } else { + else updateIconState(Disabled); - } } void FunctionClassifyButton::enterEvent(QEvent *e) { Q_UNUSED(e); - - if (m_enabled) { + if(m_enabled) + { updateIconState(Checked); } } @@ -141,26 +139,26 @@ void FunctionClassifyButton::enterEvent(QEvent *e) void FunctionClassifyButton::leaveEvent(QEvent *e) { Q_UNUSED(e); - - if (m_fullscreen) { - if (!isChecked()) { + if(m_fullscreen) + { + if(!isChecked()) updateIconState(Normal); - } - } else { - if (m_enabled) { + } + else + { + if(m_enabled) updateIconState(Enabled); - } } } void FunctionClassifyButton::reactToToggle(bool checked) { - if (m_fullscreen) { - if (checked) { + if(m_fullscreen) + { + if(checked) updateIconState(Checked); - } else { + else updateIconState(Normal); - } } } @@ -173,90 +171,131 @@ void FunctionClassifyButton::updateIconState() { this->setFlat(true); QString picState; - - switch (m_state) { - case Enabled: - picState = "Enabled"; - break; - - case Disabled: - picState = "Disabled"; - break; - - case Normal: - picState = "Normal"; - break; - - case Checked: - picState = "Checked"; - break; - - default: - break; + switch (m_state) + { + case Enabled: picState="Enabled"; break; + case Disabled: picState="Disabled"; break; + case Normal: picState="Normal"; break; + case Checked: picState="Checked"; break; + default: break; } + + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + } + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_iconLabel->setPixmap(pixmap); } void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State state) { - if (state == m_state) { + if (state == m_state) return; - } - m_state = state; + QString picState; - - switch (state) { - case Enabled: - picState = "Enabled"; - break; - - case Disabled: - picState = "Disabled"; - break; - - case Normal: - picState = "Normal"; - break; - - case Checked: - picState = "Checked"; - break; - - default: - break; + switch (state) + { + case Enabled: picState="Enabled"; break; + case Disabled: picState="Disabled"; break; + case Normal: picState="Normal"; break; + case Checked: picState="Checked"; break; + default: break; } + const auto ratio = devicePixelRatioF(); + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); + if(!m_fullscreen) + { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + } + } + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_iconLabel->setPixmap(pixmap); updateTextState(state); } void FunctionClassifyButton::updateTextState(const FunctionClassifyButton::State state) { // QPalette p= m_textLabel->palette(); - switch (state) { - case Enabled: + switch (state) + { + case Enabled: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255);"); - break; - - case Disabled: + break; + case Disabled: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.25)); // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 25%);"); - break; - - case Normal: + break; + case Normal: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.50)); // m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 50%);"); - break; - - case Checked: + break; + case Checked: // p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); // m_textLabel->setStyleSheet("background:transparent;color:rgba(255, 255, 255);"); - break; - - default: - break; + break; + default: + break; } - // p.setColor(QPalette::Window,Qt::transparent); // m_textLabel->setPalette(p); } + +void FunctionClassifyButton::setLabelText() +{ + QMetaEnum metaEnum=QMetaEnum::fromType(); + switch (metaEnum.keyToValue(m_category.toLocal8Bit().data())) { + case Mobile: + m_textLabel->setText(tr("Mobile")); + break; + case Internet: + m_textLabel->setText(tr("Internet")); + break; + case Social: + m_textLabel->setText(tr("Social")); + break; + case Video: + m_textLabel->setText(tr("Video")); + break; + case Development: + m_textLabel->setText(tr("Development")); + break; + case Image: + m_textLabel->setText(tr("Image")); + break; + case Game: + m_textLabel->setText(tr("Game")); + break; + case Office: + m_textLabel->setText(tr("Office")); + break; + case Education: + m_textLabel->setText(tr("Education")); + break; + case System: + m_textLabel->setText(tr("System")); + break; + default: + m_textLabel->setText(tr("Others")); + break; + } +} diff --git a/src/UtilityFunction/functionclassifybutton.h b/src/UtilityFunction/functionclassifybutton.h old mode 100644 new mode 100755 index 0e311a8..1b80037 --- a/src/UtilityFunction/functionclassifybutton.h +++ b/src/UtilityFunction/functionclassifybutton.h @@ -63,7 +63,6 @@ public: Office, Education, System, - Safe, Others, }; Q_ENUM(Category) @@ -87,6 +86,7 @@ protected: void paintEvent(QPaintEvent* e); void updateIconState(const State state); void updateTextState(const State state); + void setLabelText(); Q_SIGNALS: void buttonClicked(); diff --git a/src/UtilityFunction/itemdelegate.cpp b/src/UtilityFunction/itemdelegate.cpp old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/itemdelegate.h b/src/UtilityFunction/itemdelegate.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/src/UtilityFunction/letterclassifybutton.cpp old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/letterclassifybutton.h b/src/UtilityFunction/letterclassifybutton.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/listview.cpp b/src/UtilityFunction/listview.cpp old mode 100644 new mode 100755 index fccbc4a..f554276 --- a/src/UtilityFunction/listview.cpp +++ b/src/UtilityFunction/listview.cpp @@ -29,10 +29,12 @@ ListView::ListView(QWidget *parent, int width, int height, int module): this->module = module; initWidget(); m_ukuiMenuInterface = new UkuiMenuInterface; - menu = new RightClickMenu(this); + menu = new RightClickMenu; } ListView::~ListView() { + delete menu; + if (m_ukuiMenuInterface != nullptr) { delete m_ukuiMenuInterface; m_ukuiMenuInterface = nullptr; @@ -191,7 +193,8 @@ void ListView::paintEvent(QPaintEvent *e) painter.fillRect(this->rect(), this->palette().base()); //滚动条 QPalette p = this->verticalScrollBar()->palette(); - QColor color = p.color(QPalette::Light); + QColor color(255, 255, 255); +// QColor color=p.color(QPalette::Active,QPalette::Button); color.setAlphaF(0.25); p.setColor(QPalette::Active, QPalette::Button, color); this->verticalScrollBar()->setPalette(p); diff --git a/src/UtilityFunction/listview.h b/src/UtilityFunction/listview.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp old mode 100644 new mode 100755 index 8fbc0dc..0ffa9ef --- a/src/UtilityFunction/proxystyle.cpp +++ b/src/UtilityFunction/proxystyle.cpp @@ -21,10 +21,11 @@ ProxyStyle::ProxyStyle() { - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - connect(&gsetting, &QGSettings::changed, this, [ = ] { - for (auto widget : QApplication::allWidgets()) + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,[=]{ + for(auto widget: QApplication::allWidgets()) { widget->update(); } @@ -34,31 +35,32 @@ ProxyStyle::ProxyStyle() QPalette ProxyStyle::standardPalette() const { - auto m_palette = QProxyStyle::standardPalette(); + auto m_palette=QProxyStyle::standardPalette(); QColor m_highlightbg; - - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting->keys().contains(QString("styleName"))) { - if (gsetting->get("style-name").toString() == "ukui-light") { - m_highlightbg = QColor(0, 0, 0); + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + if(gsetting->keys().contains(QString("styleName"))) + { + if(gsetting->get("style-name").toString()=="ukui-light") + { + m_highlightbg=QColor(0, 0, 0); m_highlightbg.setAlphaF(0.15); - } else { - m_highlightbg = QColor(255, 255, 255); + } + else + { + m_highlightbg=QColor(255,255,255); m_highlightbg.setAlphaF(0.14); } } - - m_palette.setBrush(QPalette::Highlight, m_highlightbg); + m_palette.setBrush(QPalette::Highlight,m_highlightbg); return m_palette; } - return m_palette; } void ProxyStyle::polish(QPalette &pal) { - pal = standardPalette(); + pal=standardPalette(); // QProxyStyle::polish(pal); } diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h old mode 100644 new mode 100755 diff --git a/src/UtilityFunction/scrollarea.cpp b/src/UtilityFunction/scrollarea.cpp old mode 100644 new mode 100755 index 9c2c543..3d9bee5 --- a/src/UtilityFunction/scrollarea.cpp +++ b/src/UtilityFunction/scrollarea.cpp @@ -22,8 +22,7 @@ #include #include "utility.h" -ScrollAreaWid::ScrollAreaWid(QWidget *parent): - QWidget(parent) +ScrollAreaWid::ScrollAreaWid() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); @@ -31,8 +30,9 @@ ScrollAreaWid::ScrollAreaWid(QWidget *parent): void ScrollAreaWid::paintEvent(QPaintEvent *event) { - double transparency = getTransparency(); + double transparency=getTransparency(); QPainter painter(this); + // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); @@ -64,33 +64,30 @@ void ScrollAreaWid::paintEvent(QPaintEvent *event) // } // else // { - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); // } QWidget::paintEvent(event); } -ScrollArea::ScrollArea(QWidget *parent): - QScrollArea(parent) +ScrollArea::ScrollArea() { this->verticalScrollBar()->setVisible(false); this->setFocusPolicy(Qt::NoFocus); this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame); - this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + this->verticalScrollBar()->setProperty("drawScrollBarGroove",false); this->verticalScrollBar()->setAttribute(Qt::WA_TranslucentBackground, false); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //滚动条设置 - QPalette p = this->verticalScrollBar()->palette(); - QColor color = p.color(QPalette::Light); + QPalette p=this->verticalScrollBar()->palette(); + QColor color(255, 255, 255); color.setAlphaF(0.25); p.setColor(QPalette::Active, QPalette::Button, color); this->verticalScrollBar()->setPalette(p); - this->setStyleSheet("QWidget{background:transparent;}QScrollBar:vertical{" - "background:none}"); } void ScrollArea::setFocusToNextChild() @@ -138,8 +135,10 @@ void ScrollArea::leaveEvent(QEvent *e) void ScrollArea::scrollContentsBy(int dx, int dy) { - QScrollArea::scrollContentsBy(dx, dy); + QScrollArea::scrollContentsBy(dx,dy); + Q_EMIT requestUpdate(); + // update(); // viewport()->update(); } diff --git a/src/UtilityFunction/scrollarea.h b/src/UtilityFunction/scrollarea.h old mode 100644 new mode 100755 index e4f6d8c..730ccc0 --- a/src/UtilityFunction/scrollarea.h +++ b/src/UtilityFunction/scrollarea.h @@ -28,17 +28,17 @@ class ScrollAreaWid: public QWidget { public: - ScrollAreaWid(QWidget *parent = nullptr); + ScrollAreaWid(); protected: - void paintEvent(QPaintEvent *event); + void paintEvent(QPaintEvent* event); }; class ScrollArea : public QScrollArea { Q_OBJECT public: - ScrollArea(QWidget *parent = nullptr); + ScrollArea(); void setFocusToNextChild(); void setFocusToPreChild(); @@ -46,8 +46,8 @@ Q_SIGNALS: void requestUpdate(); protected: - void enterEvent(QEvent *e) Q_DECL_OVERRIDE; - void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; + void enterEvent(QEvent* e) Q_DECL_OVERRIDE; + void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; // void keyPressEvent(QKeyEvent* e) Q_DECL_OVERRIDE; void scrollContentsBy(int dx, int dy) override; diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.cpp b/src/UtilityFunction/softwaredatabaseupdatethread.cpp deleted file mode 100644 index 68429d2..0000000 --- a/src/UtilityFunction/softwaredatabaseupdatethread.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "softwaredatabaseupdatethread.h" -#include -#include -#include -#include -#include -#include -#include "src/UtilityFunction/utility.h" - -#define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" - -SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread(QObject *parent): - QThread(parent) -{ -} - -SoftwareDatabaseUpdateThread::~SoftwareDatabaseUpdateThread() -{ -} - -void SoftwareDatabaseUpdateThread::run() -{ - QSqlDatabase db; - db = QSqlDatabase::addDatabase("QSQLITE", "SoftwareThreadDatabase"); - db.setDatabaseName(DATABASENAME); - - if (false == db.open()) { - qDebug() << db.lastError().text(); - } - - QSqlQuery sql(db); - QJsonDocument jsonDocument = QJsonDocument::fromJson(m_category.toLocal8Bit().data()); - QJsonObject jsonObject = jsonDocument.object(); - QJsonArray jsonArray = jsonObject[jsonObject.keys()[0]].toArray(); - - int number = 0; - db.transaction(); - - Q_FOREACH(QJsonValue jsonValue, jsonArray){ - QJsonObject arrObject = jsonValue.toObject(); - QString execline = QString("replace into appCategory values(\"%0\", \"%1\", \"%2\")") - .arg(arrObject[arrObject.keys()[0]].toString()) - .arg(arrObject[arrObject.keys()[1]].toString()) - .arg(arrObject[arrObject.keys()[2]].toString()); - sql.exec(execline); - - ++number; - if (number % 5000 == 0) { - db.commit(); - db.transaction(); - } - } - db.commit(); - - myDebug() << "数据库已经更新"; - Q_EMIT updateDatabaseSignal(); -} - -void SoftwareDatabaseUpdateThread::getDatabaseList(QString category) -{ - this->m_category = category; -} diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.h b/src/UtilityFunction/softwaredatabaseupdatethread.h deleted file mode 100644 index 44b460d..0000000 --- a/src/UtilityFunction/softwaredatabaseupdatethread.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SOFTWAREDATABASEUPDATETHREAD_H -#define SOFTWAREDATABASEUPDATETHREAD_H - -#include -#include -#include -#include -#include -#include -#include - -class SoftwareDatabaseUpdateThread: public QThread -{ - Q_OBJECT -public: - SoftwareDatabaseUpdateThread(QObject *parent = nullptr); - ~SoftwareDatabaseUpdateThread(); - void run(); - void getDatabaseList(QString category); -Q_SIGNALS: - void updateDatabaseSignal(); - -private: - QString m_category; -}; - -#endif // SOFTWAREDATABASEUPDATETHREAD_H diff --git a/src/UtilityFunction/splitbarframe.cpp b/src/UtilityFunction/splitbarframe.cpp old mode 100644 new mode 100755 index 68f5999..6a9b517 --- a/src/UtilityFunction/splitbarframe.cpp +++ b/src/UtilityFunction/splitbarframe.cpp @@ -24,8 +24,8 @@ SplitBarFrame::SplitBarFrame(QWidget *parent, QString category, int width, int h m_width(width), m_height(height), m_module(module), - m_textLabel(new QLabel(this)), - m_line(new QFrame(this)) + m_textLabel(new QLabel), + m_line(new QFrame) { initAppBtn(); } @@ -35,32 +35,78 @@ SplitBarFrame::~SplitBarFrame() } void SplitBarFrame::initAppBtn() -{ - this->setFixedSize(m_width, m_height); +{ + this->setFixedSize(m_width,m_height); // this->setStyleSheet("background:transparent"); //按钮透明 this->setFocusPolicy(Qt::NoFocus); this->setAttribute(Qt::WA_TranslucentBackground); - QHBoxLayout *layout = new QHBoxLayout; - layout->setContentsMargins(15, 0, 0, 0); + QHBoxLayout* layout=new QHBoxLayout; + layout->setContentsMargins(15,0,0,0); layout->setSpacing(6); + m_textLabel->setAutoFillBackground(false); m_textLabel->setAlignment(Qt::AlignCenter); - m_textLabel->setText(m_category); + if(m_module==1) + m_textLabel->setText(m_category); + else + setLabelText(); m_textLabel->adjustSize(); - QPalette pe = m_textLabel->palette(); - pe.setColor(QPalette::WindowText, Qt::white); + QPalette pe=m_textLabel->palette(); + pe.setColor(QPalette::WindowText,Qt::white); m_textLabel->setPalette(pe); m_line->setFrameShape(QFrame::HLine); m_line->setFixedHeight(1); - m_line->setFixedSize(m_width - m_textLabel->width() - 5, 1); + m_line->setFixedSize(m_width-m_textLabel->width()-15,1); m_line->setEnabled(false); - QPalette linePe = m_line->palette(); - QColor color = linePe.color(QPalette::Dark); + QPalette linePe=m_line->palette(); + QColor color(255,255,255); color.setAlphaF(0.10); - linePe.setColor(QPalette::WindowText, color); + linePe.setColor(QPalette::WindowText,color); m_line->setPalette(linePe); + this->setLayout(layout); layout->addWidget(m_textLabel); layout->addWidget(m_line); } + +void SplitBarFrame::setLabelText() +{ + QMetaEnum metaEnum=QMetaEnum::fromType(); + switch (metaEnum.keyToValue(m_category.toLocal8Bit().data())) + { + case Mobile: + m_textLabel->setText(tr("Mobile")); + break; + case Internet: + m_textLabel->setText(tr("Internet")); + break; + case Social: + m_textLabel->setText(tr("Social")); + break; + case Video: + m_textLabel->setText(tr("Video")); + break; + case Development: + m_textLabel->setText(tr("Development")); + break; + case Image: + m_textLabel->setText(tr("Image")); + break; + case Game: + m_textLabel->setText(tr("Game")); + break; + case Office: + m_textLabel->setText(tr("Office")); + break; + case Education: + m_textLabel->setText(tr("Education")); + break; + case System: + m_textLabel->setText(tr("System")); + break; + default: + m_textLabel->setText(tr("Others")); + break; + } +} diff --git a/src/UtilityFunction/splitbarframe.h b/src/UtilityFunction/splitbarframe.h old mode 100644 new mode 100755 index de45c3d..ee33748 --- a/src/UtilityFunction/splitbarframe.h +++ b/src/UtilityFunction/splitbarframe.h @@ -51,7 +51,6 @@ public: Office, Education, System, - Safe, Others, }; Q_ENUM(Category) @@ -66,6 +65,7 @@ private: protected: void initAppBtn(); + void setLabelText(); }; #endif // PUSHBUTTON_H diff --git a/src/UtilityFunction/toolbutton.cpp b/src/UtilityFunction/toolbutton.cpp old mode 100644 new mode 100755 index 51b1f92..a0824ab --- a/src/UtilityFunction/toolbutton.cpp +++ b/src/UtilityFunction/toolbutton.cpp @@ -28,73 +28,58 @@ ToolButton::ToolButton(int width, int module, QString text) { - this->setFixedSize(width, height); - this->iconstr = iconstr; - this->piconstr = piconstr; - this->hoverbg = hoverbg; - this->pressedbg = pressedbg; - this->module = module; - this->text = text; + this->setFixedSize(width,height); + this->iconstr=iconstr; + this->piconstr=piconstr; + this->hoverbg=hoverbg; + this->pressedbg=pressedbg; + this->module=module; + this->text=text; + this->setFocusPolicy(Qt::StrongFocus); - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(iconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); this->setIcon(QIcon(*pixmap)); - if (module == 2) { + if(module==2) + { this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->setText(tr(text.toLocal8Bit().data())); // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); } - // else // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); } -ToolButton::~ToolButton() -{ - if (pixmap != nullptr) { - delete pixmap; - pixmap = nullptr; - } -} void ToolButton::enterEvent(QEvent *e) { Q_UNUSED(e); - QByteArray byte = hoverbg.toLocal8Bit(); - char *hover = byte.data(); + QByteArray byte=hoverbg.toLocal8Bit(); + char* hover=byte.data(); char style[100]; - - if (module == 2) { - sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", hover); - } else { - sprintf(style, "border:0px;padding-left:0px;background-color:%s;", hover); - } - + if(module==2) + sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",hover); + else + sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); // this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(piconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); @@ -114,22 +99,17 @@ void ToolButton::leaveEvent(QEvent *e) // else // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); delete svgRender; - svgRender = new QSvgRenderer(this); - - if (module == 2 && is_pressed) { + svgRender=new QSvgRenderer(this); + if(module==2 && is_pressed) svgRender->load(piconstr); - } else { + else svgRender->load(iconstr); - } - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); @@ -138,74 +118,63 @@ void ToolButton::leaveEvent(QEvent *e) void ToolButton::mousePressEvent(QMouseEvent *event) { - QByteArray byte = pressedbg.toLocal8Bit(); - char *pressed = byte.data(); + QByteArray byte=pressedbg.toLocal8Bit(); + char* pressed=byte.data(); char style[100]; - - if (module == 2) { - sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", pressed); - } else { - sprintf(style, "border:0px;padding-left:0px;background-color:%s;", pressed); - } - - if (event->button() == Qt::LeftButton) { + if(module==2) + sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",pressed); + else + sprintf(style,"border:0px;padding-left:0px;background-color:%s;",pressed); + if(event->button()==Qt::LeftButton) + { // this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(piconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); this->setIcon(QIcon(*pixmap)); - is_pressed = true; + + is_pressed=true; } } void ToolButton::mouseReleaseEvent(QMouseEvent *event) { - QByteArray byte = hoverbg.toLocal8Bit(); - char *hover = byte.data(); + QByteArray byte=hoverbg.toLocal8Bit(); + char* hover=byte.data(); char style[100]; - - if (module == 2) { - sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", hover); - } else { - sprintf(style, "border:0px;padding-left:0px;background-color:%s;", hover); - } - - if (event->button() == Qt::LeftButton) { + if(module==2) + sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",hover); + else + sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); + if(event->button()==Qt::LeftButton) + { // this->setStyleSheet(QString::fromLocal8Bit(style)); delete svgRender; - svgRender = new QSvgRenderer(this); + svgRender=new QSvgRenderer(this); svgRender->load(piconstr); - - if (module == 1) { - pixmap = new QPixmap(14, 14); - } else if (module == 2) { - pixmap = new QPixmap(19, 19); - } else { - pixmap = new QPixmap(9, 9); - } - + if(module==1) + pixmap=new QPixmap(14,14); + else if(module==2) + pixmap=new QPixmap(19,19); + else + pixmap=new QPixmap(9,9); pixmap->fill(Qt::transparent); QPainter p(pixmap); svgRender->render(&p); this->setIcon(QIcon(*pixmap)); - - if (module == 2) { + if(module==2) Q_EMIT buttonClicked(this); - } else { + else Q_EMIT clicked(); - } } } diff --git a/src/UtilityFunction/toolbutton.h b/src/UtilityFunction/toolbutton.h old mode 100644 new mode 100755 index 24caaf7..8b1f07b --- a/src/UtilityFunction/toolbutton.h +++ b/src/UtilityFunction/toolbutton.h @@ -46,9 +46,8 @@ public: QString pressedbg, int module, QString text); - ~ToolButton(); - bool is_pressed = false; //记录功能分类模块点击状态 + bool is_pressed=false;//记录功能分类模块点击状态 private: QString iconstr; @@ -56,21 +55,21 @@ private: QString hoverbg; QString pressedbg; int module; - QLabel *label = nullptr; - QHBoxLayout *layout = nullptr; - QPixmap *pixmap = nullptr; - QSvgRenderer *svgRender = nullptr; + QLabel* label; + QHBoxLayout* layout; + QPixmap* pixmap; + QSvgRenderer* svgRender; QString text; protected: - void enterEvent(QEvent *e); - void leaveEvent(QEvent *e); + void enterEvent(QEvent* e); + void leaveEvent(QEvent* e); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); Q_SIGNALS: - void buttonClicked(QAbstractButton *btn); + void buttonClicked(QAbstractButton* btn); }; #endif // TOOLBUTTON_H diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp old mode 100644 new mode 100755 index 48a16f3..5bb639a --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -31,8 +31,7 @@ #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" bool isHuaWeiPC = false; -bool isHuaWei9006C = false; -QString projectCodeName = ""; +bool isPANGU = false; const QPixmap loadSvg(const QString &fileName, const int size) { @@ -99,6 +98,76 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) return QPixmap::fromImage(img); } +QRect getScreenAvailableGeometry() +{ + QRect rect; + QVariantList list; + list.clear(); + QDBusInterface iface(DBUS_NAME, + DBUS_PATH, + DBUS_INTERFACE, + QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("GetPrimaryScreenAvailableGeometry"); + + if (iface.isValid() && reply.isValid()) { + list = reply.value(); + rect = QRect(list.at(0).toInt(), list.at(1).toInt(), list.at(2).toInt(), list.at(3).toInt()); + } else { + rect = qApp->primaryScreen()->availableGeometry(); + } + + return rect; +} + +QVariantList getScreenGeometry() +{ + QVariantList list; + list.clear(); + QDBusInterface iface(DBUS_NAME, + DBUS_PATH, + DBUS_INTERFACE, + QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); + + if (iface.isValid() && reply.isValid()) { + list = reply.value(); + } else { + QRect rect = QApplication::desktop()->screenGeometry(0); + list.append(QString::number(rect.x())); + list.append(QString::number(rect.y())); + list.append(QString::number(rect.width())); + list.append(QString::number(rect.height())); + int position = 0; + int panelSize = 0; + + if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { + QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); + + if (gsetting->keys().contains(QString("panelposition"))) { + position = gsetting->get("panelposition").toInt(); + } else { + position = 0; + } + + if (gsetting->keys().contains(QString("panelsize"))) { + panelSize = gsetting->get("panelsize").toInt(); + } else { + panelSize = 46; + } + + delete gsetting; + } else { + position = 0; + panelSize = 46; + } + + list.append(QString::number(panelSize)); + list.append(QString::number(position)); + } + + return list; +} + double getTransparency() { double transparency = 0.0; @@ -130,6 +199,29 @@ void debugLog(QString strMsg) } } +QString getEnvOverriddenDesktopFile(int pid) +{ + QString ret; + QString path = QString("/proc/%1/environ") + .arg(pid); + QFile file(path); + + if (file.open(QIODevice::ReadOnly)) { + QList list = file.readLine().split('\x00'); + + Q_FOREACH (QByteArray array, list) { + if (array.contains("GIO_LAUNCHED_DESKTOP_FILE=")) { + ret = QString(array.split('=').at(1)); + break; + } + } + + file.close(); + } + + return ret; +} + void openDataBase(QString connectionName) { QSqlDatabase db; @@ -143,7 +235,7 @@ void openDataBase(QString connectionName) void closeDataBase(QString connectionName) { - QSqlDatabase db = QSqlDatabase::database(connectionName); + QSqlDatabase db = QSqlDatabase::database("connectionName"); db.close(); QSqlDatabase::removeDatabase(connectionName); } @@ -152,21 +244,21 @@ void initDatabase() { QStringList desktopfnList; desktopfnList.clear(); - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); sql.exec("select count(*) from sqlite_master where type='table' and name='appInfo'"); if (sql.next()) { if (sql.value(0).toInt() == 0) { - QSettings setting("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); - setting.beginGroup("application"); + QSettings *setting = new QSettings("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); + setting->beginGroup("application"); QString desktopfp; - Q_FOREACH (QString desktopfn, setting.allKeys()) { - if (setting.value(desktopfn).toInt() == 1) { + Q_FOREACH (QString desktopfn, setting->allKeys()) { + if (setting->value(desktopfn).toInt() == 1) { desktopfp.clear(); - if (UkuiMenuInterface::m_androidDesktopfnList.contains(desktopfn)) { + if (UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) { desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); } else { desktopfp = QString("/usr/share/applications/" + desktopfn); @@ -174,7 +266,7 @@ void initDatabase() QFileInfo info(desktopfp); - if (!info.isFile() || !UkuiMenuInterface::m_desktopfpVector.contains(desktopfp)) { + if (!info.isFile() || !UkuiMenuInterface::desktopfpVector.contains(desktopfp)) { continue; } @@ -182,7 +274,8 @@ void initDatabase() } } - setting.endGroup(); + setting->endGroup(); + delete setting; } } @@ -199,28 +292,12 @@ void initDatabase() .arg(0); sql.exec(cmd); } - - sql.exec("create table appCategory(app_name char primary key, name_en char, name_zh char)"); - sql.exec("insert into appCategory values('indicator-china-weather', '其他', 'others')"); - sql.exec("insert into appCategory values('peony', '其他', 'others')"); - sql.exec("insert into appCategory values('kylin-usb-creator', '其他', 'others')"); - sql.exec("insert into appCategory values('kylin-burner', '其他', 'others')"); - sql.exec("insert into appCategory values('sc-reader', '办公', 'office')"); - sql.exec("insert into appCategory values('kylin-scanner', '办公', 'office')"); - sql.exec("insert into appCategory values('onboard', '系统', 'system')"); - sql.exec("insert into appCategory values('evolution', '系统', 'system')"); - sql.exec("insert into appCategory values('kylin-screenshot', '系统', 'system')"); - sql.exec("insert into appCategory values('kylin-ipmsg', '网络', 'network')"); - sql.exec("insert into appCategory values('ksc-defender', '安全', 'safe')"); - sql.exec("insert into appCategory values('yhkylin-backup-tools', '安全', 'safe')"); - sql.exec("insert into appCategory values('box-manager', '安全', 'safe')"); - sql.exec("insert into appCategory values('ukui-system-monitor', '安全', 'safe')"); } bool updateDataBaseTableTimes(QString desktopfn) { bool ret = false; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd; cmd = QString("select times from appInfo where desktop=\"%1\"").arg(desktopfn); @@ -248,13 +325,14 @@ bool updateDataBaseTableTimes(QString desktopfn) ret = sql.exec(cmd); } + qDebug() << "数据库更新应用使用频率成功"; return ret; } bool updateDataBaseTableType(QString desktopfn, int type) { bool ret = false; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd; @@ -318,7 +396,7 @@ bool updateDataBaseTableRecent(QString desktopfn) bool checkIfLocked(QString desktopfn) { - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select type from appInfo where desktop=\"%1\"") .arg(desktopfn); @@ -340,7 +418,7 @@ bool checkIfLocked(QString desktopfn) bool checkIfRecent(QString desktopfn) { - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select recent from appInfo where desktop=\"%1\"") .arg(desktopfn); @@ -363,7 +441,7 @@ bool checkIfRecent(QString desktopfn) QStringList getLockAppList() { QStringList list; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select desktop from appInfo where type=1"); @@ -379,7 +457,7 @@ QStringList getLockAppList() QStringList getUnlockAllList() { QStringList list; - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd = QString("select desktop from appInfo where type=0 and times>=1 order by times desc"); @@ -394,7 +472,7 @@ QStringList getUnlockAllList() void cleanTimeoutApp() { - QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlDatabase db = QSqlDatabase::database("MainThread"); QDateTime dt = QDateTime::currentDateTime(); int datetime = dt.toTime_t() - 24 * 60 * 60 * 3; QString cmd = QString("select desktop from appInfo where time < %1") @@ -438,22 +516,18 @@ void execApp(QString desktopfp) QString appName = interface.getAppExec(desktopfp); QStringList strList = (appName.replace("\"", "")).split(" "); +// for(int i = 1; i < strList.size(); i++) +// { if (QString(strList.at(0)) == "kmplayer") { QProcess::startDetached(strList.at(0)); return; } +// } GDesktopAppInfo *desktopAppInfo = g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); g_app_info_launch(G_APP_INFO(desktopAppInfo), nullptr, nullptr, nullptr); g_object_unref(desktopAppInfo); } - - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - - if (desktopfn.startsWith("app.web.")) { - updateDataBaseTableTimes(desktopfn); - } } bool checkOsRelease() diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h old mode 100644 new mode 100755 index 1a5bc82..33fcc5a --- a/src/UtilityFunction/utility.h +++ b/src/UtilityFunction/utility.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "src/Interface/ukuimenuinterface.h" @@ -32,13 +31,8 @@ #define DBUS_PATH "/panel/position" #define DBUS_INTERFACE "org.ukui.panel" -#define myDebug() qDebug() << QString("%1 %2 行 %3").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__) -#define KFILENAME QString(__FILE__).mid(QString(__FILE__).lastIndexOf("/") + 1) -#define KFUNCNAME QString(__FUNCTION__) - extern bool isHuaWeiPC; -extern bool isHuaWei9006C; -extern QString projectCodeName; +extern bool isPANGU; const QPixmap loadSvg(const QString &fileName, const int size); @@ -51,7 +45,10 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source); //调试日志 void debugLog(QString strMsg); +QVariantList getScreenGeometry(); +QRect getScreenAvailableGeometry(); double getTransparency(); +QString getEnvOverriddenDesktopFile(int pid); //数据库操作 void openDataBase(QString connectionName); void closeDataBase(QString connectionName); @@ -75,11 +72,5 @@ QString getUserIcon(); //获取用户姓名 QString getUserName(); -enum PanelPositon{ - BOTTOM = 0, - TOP = 1, - LEFT = 2, - RIGHT = 3 -}; #endif // UTILITY_H diff --git a/translations/ukui-menu_bo_CN.ts b/translations/ukui-menu_bo.ts old mode 100644 new mode 100755 similarity index 54% rename from translations/ukui-menu_bo_CN.ts rename to translations/ukui-menu_bo.ts index f3b9875..52e731e --- a/translations/ukui-menu_bo_CN.ts +++ b/translations/ukui-menu_bo.ts @@ -1,302 +1,292 @@ - + FunctionClassifyButton - - - Mobile - གནས་སྤོར། - - Internet - སྦྲེལ་རེས་དྲ་རྒྱ། + Mobile + - Social - འབྲེལ་འདྲིས། + Internet + - Video - བརྙན་ཟློས། + Social + - Development - གསར་སྤེལ། + Video + - Image - པར་རིས།། + Development + - Game - རོལ་རྩེད། + Image + - Office - གཞུང་ལས།དྲ་རྒྱ། + Game + - Education - སློབ་གསོ། + Office + - System - རྒྱུད་ཁོངས། + Education + - Safe - + System + Others - གཞན་དག + + + + + FunctionWidget + + + Mobile + + + + + Internet + + + + + Social + + + + + Video + + + + + Development + + + + + Image + + + + + Game + + + + + Office + + + + + Education + + + + + System + + + + + Others + MainViewWidget - + Search - འཚོལ་བ། - - - - QObject - - - Office - གཞུང་ལས།དྲ་རྒྱ། - - - - Development - གསར་སྤེལ། - - - - Image - པར་རིས།། - - - - Video - བརྙན་ཟློས། - - - - Internet - སྦྲེལ་རེས་དྲ་རྒྱ། - - - - Game - རོལ་རྩེད། - - - - Education - སློབ་གསོ། - - - - Social - འབྲེལ་འདྲིས། - - - - System - རྒྱུད་ཁོངས། - - - - Safe - - - - - Others - གཞན་དག + RightClickMenu - + Pin to all - “ མཉེན་ཆས་ཆ་ཚང་། ” དུ་འཇོག་པ། + - + Unpin from all - “ མཉེན་ཆས་ཆ་ཚང་། ” ལས་ལེན་པ། + - + Pin to taskbar - འགན་བྱང་དུ་འཇོག་པ། + - + Unpin from taskbar - འགན་བྱང་ནས་ལེན་པ། + - + Add to desktop shortcuts - ཅོག་ངོས་སུ་མྱུར་འཐེབ་སྣོན་པ། + - + Uninstall - ལྷུ་གཏོར + - + Sleep - མལ་གསོ། + - + Log Out - རྩིས་ཐེམ་ནས་བསུབ་པ། + - + Restart - བསྐྱར་སློང་། + - + Power Off - འཁོར་ཁ་རྒྱག་པ། + - + Personalize this list - མགོ་རྩོམ་གདམ་བྱང་གི་རིམ་བྱང་སྒྲིག་འགོད་བྱེད་པ། + SideBarWidget - + All - མཉེན་ཆས་ཚང་མ། + - + Letter - འཕྲིན་ཡིག + - + Function - བྱེད་ནུས། + - + Trash - སྙིགས་སྒམ། + - + Computer - རྩིས་ཆས། + - + Max - ཆེས་ཆེ་བ། + - + Personal - མི་སྒེར། + - + Settings - སྒྲིག་འགོད། + - + Power - ཁ་རྒྱག་པ། + SplitBarFrame - + Mobile - གནས་སྤོར། + - + Internet - སྦྲེལ་རེས་དྲ་རྒྱ། + - + Social - འབྲེལ་འདྲིས། + - + Video - བརྙན་ཟློས། + - + Development - གསར་སྤེལ། + - + Image - པར་རིས།། + - + Game - རོལ་རྩེད། + - + Office - གཞུང་ལས།དྲ་རྒྱ། + - + Education - སློབ་གསོ། + - + System - རྒྱུད་ཁོངས། + - - Safe - सुरक्षा - - - + Others - གཞན་དག + diff --git a/translations/ukui-menu_tr.ts b/translations/ukui-menu_tr.ts old mode 100644 new mode 100755 index a89dde3..691fbea --- a/translations/ukui-menu_tr.ts +++ b/translations/ukui-menu_tr.ts @@ -4,60 +4,55 @@ FunctionClassifyButton - + Mobile Mobil - + Internet İnternet - + Social Sosyal - + Video Video - + Development Programlama - + Image Grafik - + Game Oyunlar - + Office Ofis Uygulamaları - + Education Eğitim - + System Sistem - - - Safe - - Others @@ -67,54 +62,65 @@ FunctionWidget + Mobile - Mobil + Mobil + Internet - İnternet + İnternet + Social - Sosyal + Sosyal + Video - Video + Video + Development - Programlama + Programlama + Image - Grafik + Grafik + Game - Oyunlar + Oyunlar + Office - Ofis Uygulamaları + Ofis Uygulamaları + Education - Eğitim + Eğitim + System - Sistem + Sistem + Others - Diğer + Diğer MainViewWidget - + Search Ara @@ -166,93 +172,35 @@ Diğer - - QObject - - - Office - Ofis Uygulamaları - - - - Development - Programlama - - - - Image - Grafik - - - - Video - Video - - - - Internet - İnternet - - - - Game - Oyunlar - - - - Education - Eğitim - - - - Social - Sosyal - - - - System - Sistem - - - - Safe - - - - - Others - Diğer - - RightClickMenu - + Pin to all Tümünü sabitle - + Unpin from all Tüm sabitlemeleri kaldır - + Pin to taskbar Görev çubuğuna sabitle - + Unpin from taskbar Görev çubuğundan sabitlemeyi kaldır - + Add to desktop shortcuts Masaüstü kısayollarına ekle - + Uninstall Kaldır @@ -261,7 +209,7 @@ Beklemeye Al - + Sleep Uyku Modu @@ -274,22 +222,22 @@ Kullanıcı Değiştir - + Log Out Çıkış - + Restart Yeniden Başlat - + Power Off Kapat - + Personalize this list Bu listeyi özelleştirin @@ -297,42 +245,42 @@ SideBarWidget - + All Tümü - + Letter Alfabetik - + Function Kategori - + Trash Çöp - + Computer Bilgisayar - + Max - + Personal Kişisel - + Settings Ayarlar @@ -341,7 +289,7 @@ Çöp - + Power Kapat @@ -349,107 +297,59 @@ SplitBarFrame - + Mobile Mobil - + Internet İnternet - + Social Sosyal - + Video Video - + Development Programlama - + Image Grafik - + Game Oyunlar - + Office Ofis Uygulamaları - + Education Eğitim - + System Sistem - - Safe - - - - + Others Diğer - - UkuiMenuInterface - - Office - Ofis Uygulamaları - - - Development - Programlama - - - Image - Grafik - - - Video - Video - - - Internet - İnternet - - - Game - Oyunlar - - - Education - Eğitim - - - Social - Sosyal - - - System - Sistem - - - Others - Diğer - - diff --git a/translations/ukui-menu_zh_CN.ts b/translations/ukui-menu_zh_CN.ts old mode 100644 new mode 100755 index 675c51d..f4c522a --- a/translations/ukui-menu_zh_CN.ts +++ b/translations/ukui-menu_zh_CN.ts @@ -4,60 +4,55 @@ FunctionClassifyButton - + Mobile 移动 - + Internet 网络 - + Social 社交 - + Video 影音 - + Development 开发 - + Image 图像 - + Game 游戏 - + Office 办公 - + Education 教育 - + System 系统 - - - Safe - 安全 - Others @@ -67,58 +62,65 @@ FunctionWidget + Mobile - 移动 + 移动 + Internet - 网络 + 网络 + Social - 社交 + 社交 + Video - 影音 + 影音 + Development - 开发 + 开发 + Image - 图像 + 图像 + Game - 游戏 + 游戏 + Office - 办公 + 办公 + Education - 教育 + 教育 + System - 系统 + 系统 + Others - 其它 - - - Safe - 安全 + 其它 MainViewWidget - + Search 搜索 @@ -170,93 +172,35 @@ 其它 - - QObject - - - Office - 办公 - - - - Development - 开发 - - - - Image - 图像 - - - - Video - 影音 - - - - Internet - 网络 - - - - Game - 游戏 - - - - Education - 教育 - - - - Social - 社交 - - - - System - 系统 - - - - Safe - 安全 - - - - Others - 其它 - - RightClickMenu - + Pin to all 固定到“所有软件” - + Unpin from all 从“所有软件”取消固定 - + Pin to taskbar 固定到任务栏 - + Unpin from taskbar 从任务栏取消固定 - + Add to desktop shortcuts 添加到桌面快捷方式 - + Uninstall 卸载 @@ -265,7 +209,7 @@ 休眠 - + Sleep 睡眠 @@ -278,22 +222,22 @@ 切换用户 - + Log Out 注销 - + Restart 重启 - + Power Off 关机 - + Personalize this list 设置开始菜单显示列表 @@ -301,42 +245,42 @@ SideBarWidget - + All 所有软件 - + Letter 字母排序 - + Function 功能分类 - + Trash 回收站 - + Computer 计算机 - + Max 放大 - + Personal 个人 - + Settings 设置 @@ -345,7 +289,7 @@ 回收站 - + Power 电源 @@ -353,111 +297,59 @@ SplitBarFrame - + Mobile 移动 - + Internet 网络 - + Social 社交 - + Video 影音 - + Development 开发 - + Image 图像 - + Game 游戏 - + Office 办公 - + Education 教育 - + System 系统 - - Safe - 安全 - - - + Others 其它 - - UkuiMenuInterface - - Office - 办公 - - - Development - 开发 - - - Image - 图像 - - - Video - 影音 - - - Internet - 网络 - - - Game - 游戏 - - - Education - 教育 - - - Social - 社交 - - - System - 系统 - - - Safe - 安全 - - - Others - 其它 - - diff --git a/ukui-menu.desktop b/ukui-menu.desktop old mode 100644 new mode 100755 diff --git a/ukui-menu.ini b/ukui-menu.ini old mode 100644 new mode 100755 diff --git a/ukui-menu.pro b/ukui-menu.pro old mode 100644 new mode 100755 index cfb10e7..a5b48e5 --- a/ukui-menu.pro +++ b/ukui-menu.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui svg dbus x11extras KWindowSystem sql +QT += core gui svg dbus x11extras KWindowSystem sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets include(src/QtSingleApplication/qtsingleapplication.pri) @@ -16,7 +16,7 @@ TEMPLATE = app target.path = /usr/bin TRANSLATIONS+=\ - translations/ukui-menu_bo_CN.ts \ + translations/ukui-menu_bo.ts \ translations/ukui-menu_zh_CN.ts \ translations/ukui-menu_tr.ts @@ -58,7 +58,6 @@ SOURCES += \ src/MainWindow/mainwindow.cpp \ src/RightClickMenu/menubox.cpp \ src/RightClickMenu/rightclickmenu.cpp \ - src/RightClickMenu/uninstallwhitelist.cpp \ src/SearchResultWidget/file-utils.cpp \ src/SearchResultWidget/fullsearchresultwidget.cpp \ src/SearchResultWidget/searchappthread.cpp \ @@ -75,7 +74,6 @@ SOURCES += \ src/UtilityFunction/listview.cpp \ src/UtilityFunction/proxystyle.cpp \ src/UtilityFunction/scrollarea.cpp \ - src/UtilityFunction/softwaredatabaseupdatethread.cpp \ src/UtilityFunction/splitbarframe.cpp \ src/UtilityFunction/toolbutton.cpp \ src/Interface/ukuichineseletter.cpp \ @@ -99,7 +97,6 @@ HEADERS += \ src/MainWindow/mainwindow.h \ src/RightClickMenu/menubox.h \ src/RightClickMenu/rightclickmenu.h \ - src/RightClickMenu/uninstallwhitelist.h \ src/SearchResultWidget/file-utils.h \ src/SearchResultWidget/fullsearchresultwidget.h \ src/SearchResultWidget/searchappthread.h \ @@ -116,7 +113,6 @@ HEADERS += \ src/UtilityFunction/listview.h \ src/UtilityFunction/proxystyle.h \ src/UtilityFunction/scrollarea.h \ - src/UtilityFunction/softwaredatabaseupdatethread.h \ src/UtilityFunction/splitbarframe.h \ src/UtilityFunction/toolbutton.h \ src/Interface/ukuichineseletter.h \ @@ -132,7 +128,7 @@ PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt CONFIG += no_keywords link_pkgconfig -LIBS+=-pthread -luchardet -lukui-log4qt -lukui-com4c -lukui-com4cxx +LIBS+=-pthread -luchardet -lukui-log4qt desktop_file.files = ukui-menu.desktop desktop_file.path = /etc/xdg/autostart From d56635f2e86c0286bda91a74090d2226dcb39649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=82=9C?= Date: Fri, 20 May 2022 16:38:32 +0800 Subject: [PATCH 04/12] Import Upstream version 3.0.2.0510hw1 --- .github/workflows/build.yml | 0 COPYING | 0 NEWS | 0 README.md | 0 .../mainviewwidget/Development-Checked.svg | 0 .../mainviewwidget/Development-Disabled.svg | 0 .../mainviewwidget/Development-Enabled.svg | 0 .../img/mainviewwidget/Development-Normal.svg | 0 data/img/mainviewwidget/Education-Checked.svg | 0 .../img/mainviewwidget/Education-Disabled.svg | 0 data/img/mainviewwidget/Education-Enabled.svg | 0 data/img/mainviewwidget/Education-Normal.svg | 0 data/img/mainviewwidget/Game-Checked.svg | 0 data/img/mainviewwidget/Game-Disabled.svg | 0 data/img/mainviewwidget/Game-Enabled.svg | 0 data/img/mainviewwidget/Game-Normal.svg | 0 data/img/mainviewwidget/Image-Checked.svg | 0 data/img/mainviewwidget/Image-Disabled.svg | 0 data/img/mainviewwidget/Image-Enabled.svg | 0 data/img/mainviewwidget/Image-Normal.svg | 0 data/img/mainviewwidget/Internet-Checked.svg | 0 data/img/mainviewwidget/Internet-Disabled.svg | 0 data/img/mainviewwidget/Internet-Enabled.svg | 0 data/img/mainviewwidget/Internet-Normal.svg | 0 data/img/mainviewwidget/Mobile-Checked.svg | 0 data/img/mainviewwidget/Mobile-Disabled.svg | 0 data/img/mainviewwidget/Mobile-Enabled.svg | 0 data/img/mainviewwidget/Mobile-Normal.svg | 0 data/img/mainviewwidget/Office-Checked.svg | 0 data/img/mainviewwidget/Office-Disabled.svg | 0 data/img/mainviewwidget/Office-Enabled.svg | 0 data/img/mainviewwidget/Office-Normal.svg | 0 data/img/mainviewwidget/Others-Checked.svg | 0 data/img/mainviewwidget/Others-Disabled.svg | 0 data/img/mainviewwidget/Others-Enabled.svg | 0 data/img/mainviewwidget/Others-Normal.svg | 0 data/img/mainviewwidget/Social-Checked.svg | 0 data/img/mainviewwidget/Social-Disabled.svg | 0 data/img/mainviewwidget/Social-Enabled.svg | 0 data/img/mainviewwidget/Social-Normal.svg | 0 data/img/mainviewwidget/System-Checked.svg | 0 data/img/mainviewwidget/System-Disabled.svg | 0 data/img/mainviewwidget/System-Enabled.svg | 0 data/img/mainviewwidget/System-Normal.svg | 0 data/img/mainviewwidget/Video-Checked.svg | 0 data/img/mainviewwidget/Video-Disabled.svg | 0 data/img/mainviewwidget/Video-Enabled.svg | 0 data/img/mainviewwidget/Video-Normal.svg | 0 data/img/mainviewwidget/attributeaction.svg | 0 data/img/mainviewwidget/downarrow-pressed.svg | 0 data/img/mainviewwidget/downarrow.svg | 0 data/img/mainviewwidget/fixed.svg | 0 data/img/mainviewwidget/leftarrow-hover.svg | 0 data/img/mainviewwidget/leftarrow.svg | 0 data/img/mainviewwidget/lock-fs.svg | 0 data/img/mainviewwidget/lock.svg | 0 data/img/mainviewwidget/recent-disabled.svg | 0 data/img/mainviewwidget/recent-enabled.svg | 0 data/img/mainviewwidget/recent-gray.svg | 0 data/img/mainviewwidget/recent.svg | 0 data/img/mainviewwidget/rightarrow-hover.svg | 0 data/img/mainviewwidget/rightarrow.svg | 0 data/img/mainviewwidget/search.svg | 0 data/img/mainviewwidget/unfixed.svg | 0 data/img/mainviewwidget/uninstall.svg | 0 data/img/mainviewwidget/uparrow-pressed.svg | 0 data/img/mainviewwidget/uparrow.svg | 0 data/img/sidebarwidget/commonuse.svg | 0 data/img/sidebarwidget/computer.svg | 0 data/img/sidebarwidget/control.svg | 0 data/img/sidebarwidget/default.svg | 1 - data/img/sidebarwidget/fixed.svg | 0 data/img/sidebarwidget/fullusericon.png | Bin data/img/sidebarwidget/function.svg | 0 data/img/sidebarwidget/letter.svg | 0 data/img/sidebarwidget/lock.svg | 0 data/img/sidebarwidget/max.svg | 0 data/img/sidebarwidget/min.svg | 0 data/img/sidebarwidget/personal.svg | 0 data/img/sidebarwidget/rightarrow.svg | 0 data/img/sidebarwidget/setting.svg | 0 data/img/sidebarwidget/shutdown.svg | 0 data/img/sidebarwidget/trash.svg | 0 data/img/sidebarwidget/unfixed.svg | 0 data/img/sidebarwidget/usericon-darkcolor.svg | 0 .../img/sidebarwidget/usericon-lightcolor.svg | 0 main.cpp | 0 man/ukui-menu.1 | 0 res.qrc | 1 - src/CommonUseWidget/commonusewidget.cpp | 0 src/CommonUseWidget/commonusewidget.h | 0 src/CommonUseWidget/fullcommonusewidget.cpp | 0 src/CommonUseWidget/fullcommonusewidget.h | 0 src/DBus/dbus-adaptor.cpp | 0 src/DBus/dbus-adaptor.h | 0 src/DBus/dbus.cpp | 0 src/DBus/dbus.h | 0 src/DBus/org.ukui.menu.xml | 0 src/FunctionWidget/fullfunctionwidget.cpp | 0 src/FunctionWidget/fullfunctionwidget.h | 0 src/FunctionWidget/functionbuttonwidget.cpp | 0 src/FunctionWidget/functionbuttonwidget.h | 0 src/FunctionWidget/functionwidget.cpp | 0 src/FunctionWidget/functionwidget.h | 0 src/Interface/ukuichineseletter.cpp | 0 src/Interface/ukuichineseletter.h | 0 src/Interface/ukuimenuinterface.cpp | 924 ++++++++---------- src/Interface/ukuimenuinterface.h | 0 src/LetterWidget/fullletterwidget.cpp | 0 src/LetterWidget/fullletterwidget.h | 0 src/LetterWidget/letterbuttonwidget.cpp | 0 src/LetterWidget/letterbuttonwidget.h | 0 src/LetterWidget/letterwidget.cpp | 0 src/LetterWidget/letterwidget.h | 0 src/MainViewWidget/directorychangedthread.cpp | 0 src/MainViewWidget/directorychangedthread.h | 0 src/MainViewWidget/mainviewwidget.cpp | 0 src/MainViewWidget/mainviewwidget.h | 0 src/MainWindow/mainwindow.cpp | 22 +- src/MainWindow/mainwindow.h | 0 src/QtSingleApplication/QtLockedFile | 0 src/QtSingleApplication/QtSingleApplication | 0 src/QtSingleApplication/qtlocalpeer.cpp | 0 src/QtSingleApplication/qtlocalpeer.h | 0 src/QtSingleApplication/qtlockedfile.cpp | 0 src/QtSingleApplication/qtlockedfile.h | 0 src/QtSingleApplication/qtlockedfile_unix.cpp | 0 src/QtSingleApplication/qtlockedfile_win.cpp | 0 .../qtsingleapplication.cpp | 30 +- src/QtSingleApplication/qtsingleapplication.h | 0 .../qtsingleapplication.pri | 0 .../qtsinglecoreapplication.cpp | 0 .../qtsinglecoreapplication.h | 0 .../qtsinglecoreapplication.pri | 0 src/RightClickMenu/menubox.cpp | 0 src/RightClickMenu/menubox.h | 0 src/RightClickMenu/rightclickmenu.cpp | 1 - src/RightClickMenu/rightclickmenu.h | 0 src/SearchResultWidget/file-utils.cpp | 0 src/SearchResultWidget/file-utils.h | 0 .../fullsearchresultwidget.cpp | 0 .../fullsearchresultwidget.h | 0 src/SearchResultWidget/pinyinWithTone.txt | 0 src/SearchResultWidget/pinyinWithoutTone.txt | 0 src/SearchResultWidget/searchappthread.cpp | 0 src/SearchResultWidget/searchappthread.h | 0 src/SearchResultWidget/searchresultwidget.cpp | 0 src/SearchResultWidget/searchresultwidget.h | 0 src/SideBarWidget/sidebarwidget.cpp | 4 +- src/SideBarWidget/sidebarwidget.h | 0 src/Style/style.cpp | 0 src/Style/style.h | 0 src/UtilityFunction/classifybtnscrollarea.cpp | 0 src/UtilityFunction/classifybtnscrollarea.h | 0 src/UtilityFunction/convertdesktoptowinid.cpp | 0 src/UtilityFunction/convertdesktoptowinid.h | 0 src/UtilityFunction/fullitemdelegate.cpp | 0 src/UtilityFunction/fullitemdelegate.h | 0 src/UtilityFunction/fulllistview.cpp | 0 src/UtilityFunction/fulllistview.h | 0 .../functionclassifybutton.cpp | 0 src/UtilityFunction/functionclassifybutton.h | 0 src/UtilityFunction/itemdelegate.cpp | 0 src/UtilityFunction/itemdelegate.h | 0 src/UtilityFunction/letterclassifybutton.cpp | 0 src/UtilityFunction/letterclassifybutton.h | 0 src/UtilityFunction/listview.cpp | 0 src/UtilityFunction/listview.h | 0 src/UtilityFunction/proxystyle.cpp | 0 src/UtilityFunction/proxystyle.h | 0 src/UtilityFunction/scrollarea.cpp | 0 src/UtilityFunction/scrollarea.h | 0 src/UtilityFunction/splitbarframe.cpp | 0 src/UtilityFunction/splitbarframe.h | 0 src/UtilityFunction/toolbutton.cpp | 0 src/UtilityFunction/toolbutton.h | 0 src/UtilityFunction/utility.cpp | 497 +++++----- src/UtilityFunction/utility.h | 0 translations/ukui-menu_bo.ts | 0 translations/ukui-menu_tr.ts | 0 translations/ukui-menu_zh_CN.ts | 0 ukui-menu.desktop | 0 ukui-menu.ini | 0 ukui-menu.pro | 0 ukui-menu.pro.user | 314 ++++++ 185 files changed, 1013 insertions(+), 781 deletions(-) mode change 100755 => 100644 .github/workflows/build.yml mode change 100755 => 100644 COPYING mode change 100755 => 100644 NEWS mode change 100755 => 100644 README.md mode change 100755 => 100644 data/img/mainviewwidget/Development-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Development-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Development-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Development-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Education-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Game-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Image-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Internet-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Mobile-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Office-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Others-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Social-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/System-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Checked.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/Video-Normal.svg mode change 100755 => 100644 data/img/mainviewwidget/attributeaction.svg mode change 100755 => 100644 data/img/mainviewwidget/downarrow-pressed.svg mode change 100755 => 100644 data/img/mainviewwidget/downarrow.svg mode change 100755 => 100644 data/img/mainviewwidget/fixed.svg mode change 100755 => 100644 data/img/mainviewwidget/leftarrow-hover.svg mode change 100755 => 100644 data/img/mainviewwidget/leftarrow.svg mode change 100755 => 100644 data/img/mainviewwidget/lock-fs.svg mode change 100755 => 100644 data/img/mainviewwidget/lock.svg mode change 100755 => 100644 data/img/mainviewwidget/recent-disabled.svg mode change 100755 => 100644 data/img/mainviewwidget/recent-enabled.svg mode change 100755 => 100644 data/img/mainviewwidget/recent-gray.svg mode change 100755 => 100644 data/img/mainviewwidget/recent.svg mode change 100755 => 100644 data/img/mainviewwidget/rightarrow-hover.svg mode change 100755 => 100644 data/img/mainviewwidget/rightarrow.svg mode change 100755 => 100644 data/img/mainviewwidget/search.svg mode change 100755 => 100644 data/img/mainviewwidget/unfixed.svg mode change 100755 => 100644 data/img/mainviewwidget/uninstall.svg mode change 100755 => 100644 data/img/mainviewwidget/uparrow-pressed.svg mode change 100755 => 100644 data/img/mainviewwidget/uparrow.svg mode change 100755 => 100644 data/img/sidebarwidget/commonuse.svg mode change 100755 => 100644 data/img/sidebarwidget/computer.svg mode change 100755 => 100644 data/img/sidebarwidget/control.svg delete mode 100755 data/img/sidebarwidget/default.svg mode change 100755 => 100644 data/img/sidebarwidget/fixed.svg mode change 100755 => 100644 data/img/sidebarwidget/fullusericon.png mode change 100755 => 100644 data/img/sidebarwidget/function.svg mode change 100755 => 100644 data/img/sidebarwidget/letter.svg mode change 100755 => 100644 data/img/sidebarwidget/lock.svg mode change 100755 => 100644 data/img/sidebarwidget/max.svg mode change 100755 => 100644 data/img/sidebarwidget/min.svg mode change 100755 => 100644 data/img/sidebarwidget/personal.svg mode change 100755 => 100644 data/img/sidebarwidget/rightarrow.svg mode change 100755 => 100644 data/img/sidebarwidget/setting.svg mode change 100755 => 100644 data/img/sidebarwidget/shutdown.svg mode change 100755 => 100644 data/img/sidebarwidget/trash.svg mode change 100755 => 100644 data/img/sidebarwidget/unfixed.svg mode change 100755 => 100644 data/img/sidebarwidget/usericon-darkcolor.svg mode change 100755 => 100644 data/img/sidebarwidget/usericon-lightcolor.svg mode change 100755 => 100644 main.cpp mode change 100755 => 100644 man/ukui-menu.1 mode change 100755 => 100644 res.qrc mode change 100755 => 100644 src/CommonUseWidget/commonusewidget.cpp mode change 100755 => 100644 src/CommonUseWidget/commonusewidget.h mode change 100755 => 100644 src/CommonUseWidget/fullcommonusewidget.cpp mode change 100755 => 100644 src/CommonUseWidget/fullcommonusewidget.h mode change 100755 => 100644 src/DBus/dbus-adaptor.cpp mode change 100755 => 100644 src/DBus/dbus-adaptor.h mode change 100755 => 100644 src/DBus/dbus.cpp mode change 100755 => 100644 src/DBus/dbus.h mode change 100755 => 100644 src/DBus/org.ukui.menu.xml mode change 100755 => 100644 src/FunctionWidget/fullfunctionwidget.cpp mode change 100755 => 100644 src/FunctionWidget/fullfunctionwidget.h mode change 100755 => 100644 src/FunctionWidget/functionbuttonwidget.cpp mode change 100755 => 100644 src/FunctionWidget/functionbuttonwidget.h mode change 100755 => 100644 src/FunctionWidget/functionwidget.cpp mode change 100755 => 100644 src/FunctionWidget/functionwidget.h mode change 100755 => 100644 src/Interface/ukuichineseletter.cpp mode change 100755 => 100644 src/Interface/ukuichineseletter.h mode change 100755 => 100644 src/Interface/ukuimenuinterface.cpp mode change 100755 => 100644 src/Interface/ukuimenuinterface.h mode change 100755 => 100644 src/LetterWidget/fullletterwidget.cpp mode change 100755 => 100644 src/LetterWidget/fullletterwidget.h mode change 100755 => 100644 src/LetterWidget/letterbuttonwidget.cpp mode change 100755 => 100644 src/LetterWidget/letterbuttonwidget.h mode change 100755 => 100644 src/LetterWidget/letterwidget.cpp mode change 100755 => 100644 src/LetterWidget/letterwidget.h mode change 100755 => 100644 src/MainViewWidget/directorychangedthread.cpp mode change 100755 => 100644 src/MainViewWidget/directorychangedthread.h mode change 100755 => 100644 src/MainViewWidget/mainviewwidget.cpp mode change 100755 => 100644 src/MainViewWidget/mainviewwidget.h mode change 100755 => 100644 src/MainWindow/mainwindow.cpp mode change 100755 => 100644 src/MainWindow/mainwindow.h mode change 100755 => 100644 src/QtSingleApplication/QtLockedFile mode change 100755 => 100644 src/QtSingleApplication/QtSingleApplication mode change 100755 => 100644 src/QtSingleApplication/qtlocalpeer.cpp mode change 100755 => 100644 src/QtSingleApplication/qtlocalpeer.h mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile.cpp mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile.h mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile_unix.cpp mode change 100755 => 100644 src/QtSingleApplication/qtlockedfile_win.cpp mode change 100755 => 100644 src/QtSingleApplication/qtsingleapplication.cpp mode change 100755 => 100644 src/QtSingleApplication/qtsingleapplication.h mode change 100755 => 100644 src/QtSingleApplication/qtsingleapplication.pri mode change 100755 => 100644 src/QtSingleApplication/qtsinglecoreapplication.cpp mode change 100755 => 100644 src/QtSingleApplication/qtsinglecoreapplication.h mode change 100755 => 100644 src/QtSingleApplication/qtsinglecoreapplication.pri mode change 100755 => 100644 src/RightClickMenu/menubox.cpp mode change 100755 => 100644 src/RightClickMenu/menubox.h mode change 100755 => 100644 src/RightClickMenu/rightclickmenu.cpp mode change 100755 => 100644 src/RightClickMenu/rightclickmenu.h mode change 100755 => 100644 src/SearchResultWidget/file-utils.cpp mode change 100755 => 100644 src/SearchResultWidget/file-utils.h mode change 100755 => 100644 src/SearchResultWidget/fullsearchresultwidget.cpp mode change 100755 => 100644 src/SearchResultWidget/fullsearchresultwidget.h mode change 100755 => 100644 src/SearchResultWidget/pinyinWithTone.txt mode change 100755 => 100644 src/SearchResultWidget/pinyinWithoutTone.txt mode change 100755 => 100644 src/SearchResultWidget/searchappthread.cpp mode change 100755 => 100644 src/SearchResultWidget/searchappthread.h mode change 100755 => 100644 src/SearchResultWidget/searchresultwidget.cpp mode change 100755 => 100644 src/SearchResultWidget/searchresultwidget.h mode change 100755 => 100644 src/SideBarWidget/sidebarwidget.cpp mode change 100755 => 100644 src/SideBarWidget/sidebarwidget.h mode change 100755 => 100644 src/Style/style.cpp mode change 100755 => 100644 src/Style/style.h mode change 100755 => 100644 src/UtilityFunction/classifybtnscrollarea.cpp mode change 100755 => 100644 src/UtilityFunction/classifybtnscrollarea.h mode change 100755 => 100644 src/UtilityFunction/convertdesktoptowinid.cpp mode change 100755 => 100644 src/UtilityFunction/convertdesktoptowinid.h mode change 100755 => 100644 src/UtilityFunction/fullitemdelegate.cpp mode change 100755 => 100644 src/UtilityFunction/fullitemdelegate.h mode change 100755 => 100644 src/UtilityFunction/fulllistview.cpp mode change 100755 => 100644 src/UtilityFunction/fulllistview.h mode change 100755 => 100644 src/UtilityFunction/functionclassifybutton.cpp mode change 100755 => 100644 src/UtilityFunction/functionclassifybutton.h mode change 100755 => 100644 src/UtilityFunction/itemdelegate.cpp mode change 100755 => 100644 src/UtilityFunction/itemdelegate.h mode change 100755 => 100644 src/UtilityFunction/letterclassifybutton.cpp mode change 100755 => 100644 src/UtilityFunction/letterclassifybutton.h mode change 100755 => 100644 src/UtilityFunction/listview.cpp mode change 100755 => 100644 src/UtilityFunction/listview.h mode change 100755 => 100644 src/UtilityFunction/proxystyle.cpp mode change 100755 => 100644 src/UtilityFunction/proxystyle.h mode change 100755 => 100644 src/UtilityFunction/scrollarea.cpp mode change 100755 => 100644 src/UtilityFunction/scrollarea.h mode change 100755 => 100644 src/UtilityFunction/splitbarframe.cpp mode change 100755 => 100644 src/UtilityFunction/splitbarframe.h mode change 100755 => 100644 src/UtilityFunction/toolbutton.cpp mode change 100755 => 100644 src/UtilityFunction/toolbutton.h mode change 100755 => 100644 src/UtilityFunction/utility.cpp mode change 100755 => 100644 src/UtilityFunction/utility.h mode change 100755 => 100644 translations/ukui-menu_bo.ts mode change 100755 => 100644 translations/ukui-menu_tr.ts mode change 100755 => 100644 translations/ukui-menu_zh_CN.ts mode change 100755 => 100644 ukui-menu.desktop mode change 100755 => 100644 ukui-menu.ini mode change 100755 => 100644 ukui-menu.pro create mode 100644 ukui-menu.pro.user diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml old mode 100755 new mode 100644 diff --git a/COPYING b/COPYING old mode 100755 new mode 100644 diff --git a/NEWS b/NEWS old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Checked.svg b/data/img/mainviewwidget/Development-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Disabled.svg b/data/img/mainviewwidget/Development-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Enabled.svg b/data/img/mainviewwidget/Development-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Development-Normal.svg b/data/img/mainviewwidget/Development-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Checked.svg b/data/img/mainviewwidget/Education-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Disabled.svg b/data/img/mainviewwidget/Education-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Enabled.svg b/data/img/mainviewwidget/Education-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Education-Normal.svg b/data/img/mainviewwidget/Education-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Checked.svg b/data/img/mainviewwidget/Game-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Disabled.svg b/data/img/mainviewwidget/Game-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Enabled.svg b/data/img/mainviewwidget/Game-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Game-Normal.svg b/data/img/mainviewwidget/Game-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Checked.svg b/data/img/mainviewwidget/Image-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Disabled.svg b/data/img/mainviewwidget/Image-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Enabled.svg b/data/img/mainviewwidget/Image-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Image-Normal.svg b/data/img/mainviewwidget/Image-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Checked.svg b/data/img/mainviewwidget/Internet-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Disabled.svg b/data/img/mainviewwidget/Internet-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Enabled.svg b/data/img/mainviewwidget/Internet-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Internet-Normal.svg b/data/img/mainviewwidget/Internet-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Checked.svg b/data/img/mainviewwidget/Mobile-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Disabled.svg b/data/img/mainviewwidget/Mobile-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Enabled.svg b/data/img/mainviewwidget/Mobile-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Mobile-Normal.svg b/data/img/mainviewwidget/Mobile-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Checked.svg b/data/img/mainviewwidget/Office-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Disabled.svg b/data/img/mainviewwidget/Office-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Enabled.svg b/data/img/mainviewwidget/Office-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Office-Normal.svg b/data/img/mainviewwidget/Office-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Checked.svg b/data/img/mainviewwidget/Others-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Disabled.svg b/data/img/mainviewwidget/Others-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Enabled.svg b/data/img/mainviewwidget/Others-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Others-Normal.svg b/data/img/mainviewwidget/Others-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Checked.svg b/data/img/mainviewwidget/Social-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Disabled.svg b/data/img/mainviewwidget/Social-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Enabled.svg b/data/img/mainviewwidget/Social-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Social-Normal.svg b/data/img/mainviewwidget/Social-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Checked.svg b/data/img/mainviewwidget/System-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Disabled.svg b/data/img/mainviewwidget/System-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Enabled.svg b/data/img/mainviewwidget/System-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/System-Normal.svg b/data/img/mainviewwidget/System-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Checked.svg b/data/img/mainviewwidget/Video-Checked.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Disabled.svg b/data/img/mainviewwidget/Video-Disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Enabled.svg b/data/img/mainviewwidget/Video-Enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/Video-Normal.svg b/data/img/mainviewwidget/Video-Normal.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/attributeaction.svg b/data/img/mainviewwidget/attributeaction.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/downarrow-pressed.svg b/data/img/mainviewwidget/downarrow-pressed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/downarrow.svg b/data/img/mainviewwidget/downarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/fixed.svg b/data/img/mainviewwidget/fixed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/leftarrow-hover.svg b/data/img/mainviewwidget/leftarrow-hover.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/leftarrow.svg b/data/img/mainviewwidget/leftarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/lock-fs.svg b/data/img/mainviewwidget/lock-fs.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/lock.svg b/data/img/mainviewwidget/lock.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent-disabled.svg b/data/img/mainviewwidget/recent-disabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent-enabled.svg b/data/img/mainviewwidget/recent-enabled.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent-gray.svg b/data/img/mainviewwidget/recent-gray.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/recent.svg b/data/img/mainviewwidget/recent.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/rightarrow-hover.svg b/data/img/mainviewwidget/rightarrow-hover.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/rightarrow.svg b/data/img/mainviewwidget/rightarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/search.svg b/data/img/mainviewwidget/search.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/unfixed.svg b/data/img/mainviewwidget/unfixed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/uninstall.svg b/data/img/mainviewwidget/uninstall.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/uparrow-pressed.svg b/data/img/mainviewwidget/uparrow-pressed.svg old mode 100755 new mode 100644 diff --git a/data/img/mainviewwidget/uparrow.svg b/data/img/mainviewwidget/uparrow.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/commonuse.svg b/data/img/sidebarwidget/commonuse.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/computer.svg b/data/img/sidebarwidget/computer.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/control.svg b/data/img/sidebarwidget/control.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/default.svg b/data/img/sidebarwidget/default.svg deleted file mode 100755 index 7b506cb..0000000 --- a/data/img/sidebarwidget/default.svg +++ /dev/null @@ -1 +0,0 @@ -avatar \ No newline at end of file diff --git a/data/img/sidebarwidget/fixed.svg b/data/img/sidebarwidget/fixed.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/fullusericon.png b/data/img/sidebarwidget/fullusericon.png old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/function.svg b/data/img/sidebarwidget/function.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/letter.svg b/data/img/sidebarwidget/letter.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/lock.svg b/data/img/sidebarwidget/lock.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/max.svg b/data/img/sidebarwidget/max.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/min.svg b/data/img/sidebarwidget/min.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/personal.svg b/data/img/sidebarwidget/personal.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/rightarrow.svg b/data/img/sidebarwidget/rightarrow.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/setting.svg b/data/img/sidebarwidget/setting.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/shutdown.svg b/data/img/sidebarwidget/shutdown.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/trash.svg b/data/img/sidebarwidget/trash.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/unfixed.svg b/data/img/sidebarwidget/unfixed.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/usericon-darkcolor.svg b/data/img/sidebarwidget/usericon-darkcolor.svg old mode 100755 new mode 100644 diff --git a/data/img/sidebarwidget/usericon-lightcolor.svg b/data/img/sidebarwidget/usericon-lightcolor.svg old mode 100755 new mode 100644 diff --git a/main.cpp b/main.cpp old mode 100755 new mode 100644 diff --git a/man/ukui-menu.1 b/man/ukui-menu.1 old mode 100755 new mode 100644 diff --git a/res.qrc b/res.qrc old mode 100755 new mode 100644 index c09c00d..fc6c8ee --- a/res.qrc +++ b/res.qrc @@ -83,6 +83,5 @@ data/img/mainviewwidget/Mobile-Normal.svg src/SearchResultWidget/pinyinWithTone.txt src/SearchResultWidget/pinyinWithoutTone.txt - data/img/sidebarwidget/default.svg diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp old mode 100755 new mode 100644 diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h old mode 100755 new mode 100644 diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp old mode 100755 new mode 100644 diff --git a/src/CommonUseWidget/fullcommonusewidget.h b/src/CommonUseWidget/fullcommonusewidget.h old mode 100755 new mode 100644 diff --git a/src/DBus/dbus-adaptor.cpp b/src/DBus/dbus-adaptor.cpp old mode 100755 new mode 100644 diff --git a/src/DBus/dbus-adaptor.h b/src/DBus/dbus-adaptor.h old mode 100755 new mode 100644 diff --git a/src/DBus/dbus.cpp b/src/DBus/dbus.cpp old mode 100755 new mode 100644 diff --git a/src/DBus/dbus.h b/src/DBus/dbus.h old mode 100755 new mode 100644 diff --git a/src/DBus/org.ukui.menu.xml b/src/DBus/org.ukui.menu.xml old mode 100755 new mode 100644 diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp old mode 100755 new mode 100644 diff --git a/src/FunctionWidget/fullfunctionwidget.h b/src/FunctionWidget/fullfunctionwidget.h old mode 100755 new mode 100644 diff --git a/src/FunctionWidget/functionbuttonwidget.cpp b/src/FunctionWidget/functionbuttonwidget.cpp old mode 100755 new mode 100644 diff --git a/src/FunctionWidget/functionbuttonwidget.h b/src/FunctionWidget/functionbuttonwidget.h old mode 100755 new mode 100644 diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp old mode 100755 new mode 100644 diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h old mode 100755 new mode 100644 diff --git a/src/Interface/ukuichineseletter.cpp b/src/Interface/ukuichineseletter.cpp old mode 100755 new mode 100644 diff --git a/src/Interface/ukuichineseletter.h b/src/Interface/ukuichineseletter.h old mode 100755 new mode 100644 diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp old mode 100755 new mode 100644 index 884ddd0..ae5e94d --- a/src/Interface/ukuimenuinterface.cpp +++ b/src/Interface/ukuimenuinterface.cpp @@ -32,98 +32,91 @@ UkuiMenuInterface::UkuiMenuInterface() { } -QVector UkuiMenuInterface::appInfoVector = QVector(); -QVector UkuiMenuInterface::desktopfpVector = QVector(); -QVector UkuiMenuInterface::alphabeticVector = QVector(); -QVector UkuiMenuInterface::functionalVector = QVector(); -QVector UkuiMenuInterface::allAppVector = QVector(); -QStringList UkuiMenuInterface::androidDesktopfnList = QStringList(); +QVector UkuiMenuInterface::appInfoVector=QVector(); +QVector UkuiMenuInterface::desktopfpVector=QVector(); +QVector UkuiMenuInterface::alphabeticVector=QVector(); +QVector UkuiMenuInterface::functionalVector=QVector(); +QVector UkuiMenuInterface::allAppVector=QVector(); +QStringList UkuiMenuInterface::androidDesktopfnList=QStringList(); UkuiMenuInterface::~UkuiMenuInterface() { } //文件递归查询 -void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) +void UkuiMenuInterface::recursiveSearchFile(const QString& _filePath) { QDir dir(_filePath); - if (!dir.exists()) { return; } - dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + dir.setFilter(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot); dir.setSorting(QDir::DirsFirst); QFileInfoList list = dir.entryInfoList(); list.removeAll(QFileInfo("/usr/share/applications/screensavers")); - - if (list.size() < 1) { + if(list.size()< 1 ) { return; } - - int i = 0; + int i=0; //递归算法的核心部分 - do { + do{ QFileInfo fileInfo = list.at(i); //如果是文件夹,递归 bool isDir = fileInfo.isDir(); - - if (isDir) { + if(isDir) { recursiveSearchFile(fileInfo.filePath()); - } else { + } + else{ //过滤后缀不是.desktop的文件 - QString filePathStr = fileInfo.filePath(); - - if (!filePathStr.endsWith(".desktop")) { + QString filePathStr=fileInfo.filePath(); + if(!filePathStr.endsWith(".desktop")) + { i++; continue; } - QByteArray fpbyte = filePathStr.toLocal8Bit(); - char *filepath = fpbyte.data(); - - if (0 != access(filepath, R_OK)) { //判断文件是否可读 + QByteArray fpbyte=filePathStr.toLocal8Bit(); + char* filepath=fpbyte.data(); + if(0!=access(filepath,R_OK))//判断文件是否可读 + { i++; continue; } - keyfile = g_key_file_new(); - - if (!g_key_file_load_from_file(keyfile, filepath, flags, error)) { + keyfile=g_key_file_new(); + if(!g_key_file_load_from_file(keyfile,filepath,flags,error)) return; - } - char *ret_0 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); - - if (ret_0 != nullptr) { + char* ret_0 = g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); + if(ret_0 != nullptr) + { QString str = QString::fromLocal8Bit(ret_0); - - if (str.contains("Android")) { + if(str.contains("Android")) + { g_key_file_free(keyfile); i++; continue; } } - - char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); - - if (ret_1 != nullptr) { - QString str = QString::fromLocal8Bit(ret_1); - - if (str.contains("true")) { + char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","NoDisplay", nullptr, nullptr); + if(ret_1!=nullptr) + { + QString str=QString::fromLocal8Bit(ret_1); + if(str.contains("true")) + { g_key_file_free(keyfile); i++; continue; } } - - char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); - - if (ret_2 != nullptr) { - QString str = QString::fromLocal8Bit(ret_2); - - if (str.contains("UKUI")) { + char* ret_2=g_key_file_get_locale_string(keyfile,"Desktop Entry","NotShowIn", nullptr, nullptr); + if(ret_2!=nullptr) + { + QString str=QString::fromLocal8Bit(ret_2); + if(str.contains("UKUI")) + { g_key_file_free(keyfile); i++; continue; @@ -131,12 +124,12 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) } //过滤LXQt、KDE - char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); - - if (ret != nullptr) { - QString str = QString::fromLocal8Bit(ret); - - if (str.contains("LXQt") || str.contains("KDE")) { + char* ret=g_key_file_get_locale_string(keyfile,"Desktop Entry","OnlyShowIn", nullptr, nullptr); + if(ret!=nullptr) + { + QString str=QString::fromLocal8Bit(ret); + if(str.contains("LXQt") || str.contains("KDE")) + { g_key_file_free(keyfile); i++; continue; @@ -146,61 +139,68 @@ void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) g_key_file_free(keyfile); filePathList.append(filePathStr); } - i++; - } while (i < list.size()); + + } while(i < list.size()); } //获取系统desktop文件路径 QStringList UkuiMenuInterface::getDesktopFilePath() { filePathList.clear(); - QString jsonPath = QDir::homePath() + "/.config/ukui-menu-security-config.json"; + + QString jsonPath=QDir::homePath()+"/.config/ukui-menu-security-config.json"; QFile file(jsonPath); - - if (file.exists()) { + if(file.exists()) + { file.open(QIODevice::ReadOnly); - QByteArray readBy = file.readAll(); + QByteArray readBy=file.readAll(); QJsonParseError error; - QJsonDocument readDoc = QJsonDocument::fromJson(readBy, &error); - - if (!readDoc.isNull() && error.error == QJsonParseError::NoError) { - QJsonObject obj = readDoc.object().value("ukui-menu").toObject(); - - if (obj.value("mode").toString() == "whitelist") { - QJsonArray blArray = obj.value("whitelist").toArray(); - QJsonArray enArray = blArray.at(0).toObject().value("entries").toArray(); - - for (int index = 0; index < enArray.size(); index++) { - QJsonObject obj = enArray.at(index).toObject(); + QJsonDocument readDoc=QJsonDocument::fromJson(readBy,&error); + if(!readDoc.isNull() && error.error==QJsonParseError::NoError) + { + QJsonObject obj=readDoc.object().value("ukui-menu").toObject(); + if(obj.value("mode").toString()=="whitelist") + { + QJsonArray blArray=obj.value("whitelist").toArray(); + QJsonArray enArray=blArray.at(0).toObject().value("entries").toArray(); + for(int index=0;index UkuiMenuInterface::createAppInfoVector() desktopfpVector.clear(); QVector appInfoVector; QVector vector; - vector.append(QStringList() << "Android"); //0安卓 - vector.append(QStringList() << "Network"); //1网络 - vector.append(QStringList() << "Messaging"); //2社交 - vector.append(QStringList() << "Audio" << "Video"); //3影音 - vector.append(QStringList() << "Development"); //4开发 - vector.append(QStringList() << "Graphics"); //5图像 - vector.append(QStringList() << "Game"); //6游戏 - vector.append(QStringList() << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //7办公 - vector.append(QStringList() << "Education"); //8教育 - vector.append(QStringList() << "System" << "Settings" << "Security"); //9系统 - QStringList desktopfpList = getDesktopFilePath(); + vector.append(QStringList()<<"Android");//0安卓 + vector.append(QStringList()<<"Network");//1网络 + vector.append(QStringList()<<"Messaging");//2社交 + vector.append(QStringList()<<"Audio"<<"Video");//3影音 + vector.append(QStringList()<<"Development");//4开发 + vector.append(QStringList()<<"Graphics");//5图像 + vector.append(QStringList()<<"Game");//6游戏 + vector.append(QStringList()<<"Office"<<"Calculator"<<"Spreadsheet"<<"Presentation"<<"WordProcessor"<<"TextEditor");//7办公 + vector.append(QStringList()<<"Education");//8教育 + vector.append(QStringList()<<"System"<<"Settings"<<"Security");//9系统 - for (int i = 0; i < desktopfpList.count(); i++) { + QStringList desktopfpList=getDesktopFilePath(); + + for(int i=0;i UkuiMenuInterface::createAppInfoVector() //获取应用名称 QString UkuiMenuInterface::getAppName(QString desktopfp) { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Name", nullptr, nullptr); - QString namestr = QString::fromLocal8Bit(name); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + + char* name=g_key_file_get_locale_string(keyfile,"Desktop Entry","Name", nullptr, nullptr); + QString namestr=QString::fromLocal8Bit(name); + g_key_file_free(keyfile); return namestr; } @@ -331,41 +339,44 @@ QString UkuiMenuInterface::getAppName(QString desktopfp) //获取英应用英文名 QString UkuiMenuInterface::getAppEnglishName(QString desktopfp) { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); - QString namestr = QString::fromLocal8Bit(name); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + char* name=g_key_file_get_string(keyfile,"Desktop Entry","Name", nullptr); + QString namestr=QString::fromLocal8Bit(name); return namestr; } //获取应用分类 QString UkuiMenuInterface::getAppCategories(QString desktopfp) { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *category = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + char* category=g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); g_key_file_free(keyfile); return QString::fromLocal8Bit(category); } //获取应用图标 QString UkuiMenuInterface::getAppIcon(QString desktopfp) -{ - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *icon = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Icon", nullptr, nullptr); +{ + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + char* icon=g_key_file_get_locale_string(keyfile,"Desktop Entry","Icon", nullptr, nullptr); g_key_file_free(keyfile); return QString::fromLocal8Bit(icon); } @@ -373,13 +384,14 @@ QString UkuiMenuInterface::getAppIcon(QString desktopfp) //获取应用命令 QString UkuiMenuInterface::getAppExec(QString desktopfp) { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *exec = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + char* exec=g_key_file_get_locale_string(keyfile,"Desktop Entry","Exec", nullptr, nullptr); g_key_file_free(keyfile); return QString::fromLocal8Bit(exec); } @@ -387,27 +399,30 @@ QString UkuiMenuInterface::getAppExec(QString desktopfp) //获取应用注释 QString UkuiMenuInterface::getAppComment(QString desktopfp) { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *comment = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Comment", nullptr, nullptr); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + char* comment=g_key_file_get_locale_string(keyfile,"Desktop Entry","Comment", nullptr, nullptr); g_key_file_free(keyfile); return QString::fromLocal8Bit(comment); + } //获取应用类型 QString UkuiMenuInterface::getAppType(QString desktopfp) { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *type = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Type", nullptr, nullptr); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + char* type=g_key_file_get_locale_string(keyfile,"Desktop Entry","Type", nullptr, nullptr); g_key_file_free(keyfile); return QString::fromLocal8Bit(type); } @@ -415,21 +430,16 @@ QString UkuiMenuInterface::getAppType(QString desktopfp) bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2) { QLocale local; - QString language = local.languageToString(local.language()); - - if (QString::compare(language, "Chinese") == 0) { - local = QLocale(QLocale::Chinese); - } else { - local = QLocale(QLocale::English); - } - + QString language=local.languageToString(local.language()); + if(QString::compare(language,"Chinese")==0) + local=QLocale(QLocale::Chinese); + else + local=QLocale(QLocale::English); QCollator collator(local); - - if (collator.compare(arg_1.at(1), arg_2.at(1)) < 0) { + if(collator.compare(arg_1.at(1),arg_2.at(1))<0) return true; - } else { + else return false; - } } QVector UkuiMenuInterface::getAllClassification() @@ -440,26 +450,20 @@ QVector UkuiMenuInterface::getAllClassification() allAppVector.clear(); commonVector.clear(); appVector.clear(); - commonVector = getCommonUseApp(); - int index = 0; - - Q_FOREACH (QString desktopfp, desktopfpVector) { - if (!commonVector.contains(desktopfp)) { + commonVector=getCommonUseApp(); + int index=0; + Q_FOREACH(QString desktopfp, desktopfpVector) + { + if(!commonVector.contains(desktopfp)) appVector.append(appInfoVector.at(index)); - } - index++; } - - qSort(appVector.begin(), appVector.end(), cmpApp); - - Q_FOREACH (QString desktopfp, commonVector) { + qSort(appVector.begin(),appVector.end(),cmpApp); + Q_FOREACH(QString desktopfp, commonVector) allAppVector.append(desktopfp); - } - for (int index = 0; index < appVector.size(); index++) { + for(int index=0;index UkuiMenuInterface::getCommonUseApp() // { // timeOutKeys.append(dateTimeKeys.at(i)); // } + // } // setting->endGroup(); // for(int i=0;i UkuiMenuInterface::getCommonUseApp() // setting->sync(); // setting->endGroup(); // } + // setting->beginGroup("lockapplication"); // QStringList lockdesktopfnList=setting->allKeys(); // for(int i=0;i UkuiMenuInterface::getCommonUseApp() // QString tmp=lockdesktopfnList.at(j); // lockdesktopfnList.replace(j,lockdesktopfnList.at(j+1)); // lockdesktopfnList.replace(j+1,tmp); + // } // } // setting->endGroup(); @@ -519,9 +526,11 @@ QVector UkuiMenuInterface::getCommonUseApp() // QString tmp=desktopfnList.at(j); // desktopfnList.replace(j,desktopfnList.at(j+1)); // desktopfnList.replace(j+1,tmp); + // } // } // setting->endGroup(); + // QVector data; // Q_FOREACH(QString desktopfn,lockdesktopfnList) // { @@ -547,41 +556,31 @@ QVector UkuiMenuInterface::getCommonUseApp() // continue; // data.append(desktopfp); // } + QVector data; - - Q_FOREACH (QString desktopfn, getLockAppList()) { + Q_FOREACH(QString desktopfn, getLockAppList()) + { QString desktopfp; - - if (androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - + if(androidDesktopfnList.contains(desktopfn)) + desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); + else + desktopfp=QString("/usr/share/applications/"+desktopfn); QFileInfo fileInfo(desktopfp); - - if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { + if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) continue; - } - data.append(desktopfp); } - Q_FOREACH (QString desktopfn, getUnlockAllList()) { + Q_FOREACH(QString desktopfn, getUnlockAllList()) + { QString desktopfp; - - if (androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - + if(androidDesktopfnList.contains(desktopfn)) + desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); + else + desktopfp=QString("/usr/share/applications/"+desktopfn); QFileInfo fileInfo(desktopfp); - - if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { + if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) continue; - } - data.append(desktopfp); } @@ -594,272 +593,215 @@ QVector UkuiMenuInterface::getAlphabeticClassification() QStringList appnameList; appnameList.clear(); QVector appVector[27]; - int index = 0; - - while (index < appInfoVector.size()) { - QString appname = appInfoVector.at(index).at(1); - QString appnamepy = UkuiChineseLetter::getPinyins(appname); - - if (!appnamepy.isEmpty()) { - char c = appnamepy.at(0).toLatin1(); - + int index=0; + while(index otherVector; - QVector numberVector; - - for (int i = 0; i < appVector[26].count(); i++) { - QString appname = appVector[26].at(i).at(2); - QChar c = appname.at(0); - - if (c < 48 || (c > 57 && c < 65) || c > 90) { + QVector otherVector; + QVector numberVector; + for(int i=0;i57 && c<65) || c>90) otherVector.append(appVector[26].at(i)); - } else { + else numberVector.append(appVector[26].at(i)); - } } - - qSort(otherVector.begin(), otherVector.end(), cmpApp); - qSort(numberVector.begin(), numberVector.end(), cmpApp); + qSort(otherVector.begin(),otherVector.end(),cmpApp); + qSort(numberVector.begin(),numberVector.end(),cmpApp); QStringList otherfpList; otherfpList.clear(); - - for (int i = 0; i < otherVector.size(); i++) { + for(int i=0;i UkuiMenuInterface::getFunctionalClassification() { QVector appVector[11]; - int index = 0; - - while (index < appInfoVector.size()) { - int count = appInfoVector.at(index).size() - 5; - - for (int i = 0; i < count; i++) { - int category = appInfoVector.at(index).at(5 + i).toInt(); - + int index=0; + while(index data; data.clear(); - for (int i = 0; i < 11; i++) { + for(int i=0;i<11;i++) + { QStringList desktopfpList; desktopfpList.clear(); - qSort(appVector[i].begin(), appVector[i].end(), cmpApp); - - for (int j = 0; j < appVector[i].size(); j++) { + qSort(appVector[i].begin(),appVector[i].end(),cmpApp); + for(int j=0;j androidVector; androidVector.clear(); - QString path = QDir::homePath() + "/.local/share/applications/"; + QString path=QDir::homePath()+"/.local/share/applications/"; QDir dir(path); - if (!dir.exists()) { return; } - dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + dir.setFilter(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot); dir.setSorting(QDir::DirsFirst); QFileInfoList list = dir.entryInfoList(); - - if (list.size() < 1) { + if(list.size()< 1 ) { return; } + int i=0; - int i = 0; - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); - do { + do{ QFileInfo fileInfo = list.at(i); - - if (!fileInfo.isFile()) { + if(!fileInfo.isFile()) + { i++; continue; } - //过滤后缀不是.desktop的文件 - QString filePathStr = fileInfo.filePath(); - - if (!filePathStr.endsWith(".desktop")) { + QString filePathStr=fileInfo.filePath(); + if(!filePathStr.endsWith(".desktop")) + { i++; continue; } - QByteArray fpbyte = filePathStr.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); + QByteArray fpbyte=filePathStr.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); // char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); // if(ret_1!=nullptr) // { @@ -919,12 +858,13 @@ void UkuiMenuInterface::getAndroidApp() // } // else // { - filePathList.append(filePathStr); - androidDesktopfnList.append(fileInfo.fileName()); + filePathList.append(filePathStr); + androidDesktopfnList.append(fileInfo.fileName()); // } // } + i++; - } while (i < list.size()); + }while(i < list.size()); g_key_file_free(keyfile); } @@ -932,18 +872,15 @@ void UkuiMenuInterface::getAndroidApp() QString UkuiMenuInterface::getAppNameInitials(QString desktopfp) { QString firstLetters; - QString appname = getAppName(desktopfp); - QStringList appnamestr = appname.split(" "); + QString appname=getAppName(desktopfp); + QStringList appnamestr=appname.split(" "); QString letters; - - Q_FOREACH (QString name, appnamestr) { + Q_FOREACH(QString name,appnamestr) + { letters.clear(); - letters = UkuiChineseLetter::getFirstLettersAll(name); - - if (letters.isEmpty()) { - letters = UkuiChineseLetter::getFirstLetter(name); - } - + letters=UkuiChineseLetter::getFirstLettersAll(name); + if(letters.isEmpty()) + letters=UkuiChineseLetter::getFirstLetter(name); firstLetters.append(letters); } @@ -963,54 +900,53 @@ QString UkuiMenuInterface::getAppNamePinyin(QString appname) bool UkuiMenuInterface::checkKreApp(QString desktopfp) { - GError **error = nullptr; - GKeyFileFlags flags = G_KEY_FILE_NONE; - GKeyFile *keyfile = g_key_file_new(); - QByteArray fpbyte = desktopfp.toLocal8Bit(); - char *filepath = fpbyte.data(); - g_key_file_load_from_file(keyfile, filepath, flags, error); - char *value = g_key_file_get_locale_string(keyfile, "Desktop Entry", "environment", nullptr, nullptr); + GError** error=nullptr; + GKeyFileFlags flags=G_KEY_FILE_NONE; + GKeyFile* keyfile=g_key_file_new (); + + QByteArray fpbyte=desktopfp.toLocal8Bit(); + char* filepath=fpbyte.data(); + g_key_file_load_from_file(keyfile,filepath,flags,error); + + char* value=g_key_file_get_locale_string(keyfile,"Desktop Entry","environment", nullptr, nullptr); g_key_file_free(keyfile); - - if (!value) { + if(!value) return false; - } else if (QString::compare(QString::fromLocal8Bit(value), "kre-environment") == 0) { + else if(QString::compare(QString::fromLocal8Bit(value),"kre-environment")==0) return true; - } - return false; } //获取指定类型应用列表 QStringList UkuiMenuInterface::getSpecifiedCategoryAppList(QString categorystr) { - QByteArray categorybyte = categorystr.toLocal8Bit(); - char *category = categorybyte.data(); - QStringList desktopfpList = getDesktopFilePath(); + QByteArray categorybyte=categorystr.toLocal8Bit(); + char* category=categorybyte.data(); + + QStringList desktopfpList=getDesktopFilePath(); QStringList appnameList; appnameList.clear(); - - for (int index = 0; index < desktopfpList.count(); index++) { - QString appcategorystr = getAppCategories(desktopfpList.at(index)); - - if (!appcategorystr.isEmpty()) { - QByteArray appcategorybyte = appcategorystr.toLocal8Bit(); - char *appcategory = appcategorybyte.data(); - int len = static_cast(strlen(appcategory) - 6); - - for (int i = 0; i < len; i++) { - if (strncmp(appcategory + i, category, strlen(category)) == 0) { - QString appname = getAppName(desktopfpList.at(index)); - - if (QString::compare(appname, "访问提示") == 0) { - appnameList.append(appname); - } - + for(int index=0;index(strlen(appcategory)-6); + for(int i=0;iapplicationState() & Qt::ApplicationInactive) { - MainWindow *w = qobject_cast(actWin); + if(this->applicationState() & Qt::ApplicationInactive) + { + MainWindow* w=qobject_cast(actWin); w->loadMainWindow(); actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); actWin->raise(); actWin->showNormal(); actWin->activateWindow(); - } else { + + } + else { actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized); actWin->hide(); } + } } diff --git a/src/QtSingleApplication/qtsingleapplication.h b/src/QtSingleApplication/qtsingleapplication.h old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/src/QtSingleApplication/qtsingleapplication.pri old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/src/QtSingleApplication/qtsinglecoreapplication.cpp old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/src/QtSingleApplication/qtsinglecoreapplication.h old mode 100755 new mode 100644 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/src/QtSingleApplication/qtsinglecoreapplication.pri old mode 100755 new mode 100644 diff --git a/src/RightClickMenu/menubox.cpp b/src/RightClickMenu/menubox.cpp old mode 100755 new mode 100644 diff --git a/src/RightClickMenu/menubox.h b/src/RightClickMenu/menubox.h old mode 100755 new mode 100644 diff --git a/src/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp old mode 100755 new mode 100644 index 290eae6..e7da0f9 --- a/src/RightClickMenu/rightclickmenu.cpp +++ b/src/RightClickMenu/rightclickmenu.cpp @@ -47,7 +47,6 @@ RightClickMenu::RightClickMenu(QWidget *parent): m_whiteList.append("org.gnome.FileRoller.desktop"); m_whiteList.append("mate-terminal.desktop"); m_whiteList.append("hwaudioui.desktop"); - m_whiteList.append("kylin-sogouIme-configtool.desktop"); } m_ukuiMenuInterface = new UkuiMenuInterface; diff --git a/src/RightClickMenu/rightclickmenu.h b/src/RightClickMenu/rightclickmenu.h old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/file-utils.cpp b/src/SearchResultWidget/file-utils.cpp old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/file-utils.h b/src/SearchResultWidget/file-utils.h old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/fullsearchresultwidget.h b/src/SearchResultWidget/fullsearchresultwidget.h old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/pinyinWithTone.txt b/src/SearchResultWidget/pinyinWithTone.txt old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/pinyinWithoutTone.txt b/src/SearchResultWidget/pinyinWithoutTone.txt old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/searchappthread.cpp b/src/SearchResultWidget/searchappthread.cpp old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/searchappthread.h b/src/SearchResultWidget/searchappthread.h old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp old mode 100755 new mode 100644 diff --git a/src/SearchResultWidget/searchresultwidget.h b/src/SearchResultWidget/searchresultwidget.h old mode 100755 new mode 100644 diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp old mode 100755 new mode 100644 index 7cb2b3e..a14ce78 --- a/src/SideBarWidget/sidebarwidget.cpp +++ b/src/SideBarWidget/sidebarwidget.cpp @@ -291,7 +291,7 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int labelicon->setPixmap(pixmap); } else { if (!QFile::exists(btnicon)) { - btnicon = QString(":/data/img/sidebarwidget/default.svg"); + btnicon = QString("/usr/share/ukui/faces/default.png"); } labelicon->setObjectName("faceLabel"); @@ -481,7 +481,7 @@ void SideBarWidget::userAccountsChanged() QString usericon = getUserIcon(); if (!QFile::exists(usericon)) { - usericon = QString(":/data/img/sidebarwidget/default.svg"); + usericon = QString("/usr/share/ukui/faces/default.png"); } QPixmap facePixmap(usericon); diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h old mode 100755 new mode 100644 diff --git a/src/Style/style.cpp b/src/Style/style.cpp old mode 100755 new mode 100644 diff --git a/src/Style/style.h b/src/Style/style.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/classifybtnscrollarea.cpp b/src/UtilityFunction/classifybtnscrollarea.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/classifybtnscrollarea.h b/src/UtilityFunction/classifybtnscrollarea.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/convertdesktoptowinid.cpp b/src/UtilityFunction/convertdesktoptowinid.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/convertdesktoptowinid.h b/src/UtilityFunction/convertdesktoptowinid.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/fullitemdelegate.h b/src/UtilityFunction/fullitemdelegate.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/fulllistview.h b/src/UtilityFunction/fulllistview.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/functionclassifybutton.cpp b/src/UtilityFunction/functionclassifybutton.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/functionclassifybutton.h b/src/UtilityFunction/functionclassifybutton.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/itemdelegate.cpp b/src/UtilityFunction/itemdelegate.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/itemdelegate.h b/src/UtilityFunction/itemdelegate.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/src/UtilityFunction/letterclassifybutton.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/letterclassifybutton.h b/src/UtilityFunction/letterclassifybutton.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/listview.cpp b/src/UtilityFunction/listview.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/listview.h b/src/UtilityFunction/listview.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/scrollarea.cpp b/src/UtilityFunction/scrollarea.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/scrollarea.h b/src/UtilityFunction/scrollarea.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/splitbarframe.cpp b/src/UtilityFunction/splitbarframe.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/splitbarframe.h b/src/UtilityFunction/splitbarframe.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/toolbutton.cpp b/src/UtilityFunction/toolbutton.cpp old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/toolbutton.h b/src/UtilityFunction/toolbutton.h old mode 100755 new mode 100644 diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp old mode 100755 new mode 100644 index 5bb639a..d10fc82 --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -38,54 +38,55 @@ const QPixmap loadSvg(const QString &fileName, const int size) QPixmap pixmap(size, size); QSvgRenderer renderer(fileName); pixmap.fill(Qt::transparent); + QPainter painter; painter.begin(&pixmap); renderer.render(&painter); painter.end(); + return pixmap; } QPixmap drawSymbolicColoredPixmap(const QPixmap &source) { - QColor gray(128, 128, 128); - QColor standard(31, 32, 34); + QColor gray(128,128,128); + QColor standard (31,32,34); QImage img = source.toImage(); - for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); - if (color.alpha() > 0) { - if (qAbs(color.red() - gray.red()) < 20 && qAbs(color.green() - gray.green()) < 20 && qAbs(color.blue() - gray.blue()) < 20) { + if (qAbs(color.red()-gray.red())<20 && qAbs(color.green()-gray.green())<20 && qAbs(color.blue()-gray.blue())<20) { color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); - } else if (qAbs(color.red() - standard.red()) < 20 && qAbs(color.green() - standard.green()) < 20 && qAbs(color.blue() - standard.blue()) < 20) { + } + else if(qAbs(color.red()-standard.red())<20 && qAbs(color.green()-standard.green())<20 && qAbs(color.blue()-standard.blue())<20) + { color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); - } else { + } + else + { img.setPixelColor(x, y, color); } } } } - return QPixmap::fromImage(img); } QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) { QImage img = source.toImage(); - for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); - if (color.alpha() > 0) { - if (qAbs(color.red()) >= 200 && qAbs(color.green()) >= 200 && qAbs(color.blue()) >= 200) { + if (qAbs(color.red())>=200 && qAbs(color.green())>=200 && qAbs(color.blue())>=200) { color.setRed(56); color.setGreen(56); color.setBlue(56); @@ -94,7 +95,6 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) } } } - return QPixmap::fromImage(img); } @@ -107,15 +107,17 @@ QRect getScreenAvailableGeometry() DBUS_PATH, DBUS_INTERFACE, QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("GetPrimaryScreenAvailableGeometry"); + QDBusReply reply=iface.call("GetPrimaryScreenAvailableGeometry"); + if(iface.isValid() && reply.isValid()) + { + list=reply.value(); + rect = QRect(list.at(0).toInt(),list.at(1).toInt(),list.at(2).toInt(),list.at(3).toInt()); - if (iface.isValid() && reply.isValid()) { - list = reply.value(); - rect = QRect(list.at(0).toInt(), list.at(1).toInt(), list.at(2).toInt(), list.at(3).toInt()); - } else { + } + else + { rect = qApp->primaryScreen()->availableGeometry(); } - return rect; } @@ -127,73 +129,68 @@ QVariantList getScreenGeometry() DBUS_PATH, DBUS_INTERFACE, QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); - - if (iface.isValid() && reply.isValid()) { - list = reply.value(); - } else { - QRect rect = QApplication::desktop()->screenGeometry(0); + QDBusReply reply=iface.call("GetPrimaryScreenPhysicalGeometry"); + if(iface.isValid() && reply.isValid()) + { + list=reply.value(); + } + else + { + QRect rect=QApplication::desktop()->screenGeometry(0); list.append(QString::number(rect.x())); list.append(QString::number(rect.y())); list.append(QString::number(rect.width())); list.append(QString::number(rect.height())); - int position = 0; - int panelSize = 0; - - if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); - - if (gsetting->keys().contains(QString("panelposition"))) { - position = gsetting->get("panelposition").toInt(); - } else { - position = 0; - } - - if (gsetting->keys().contains(QString("panelsize"))) { - panelSize = gsetting->get("panelsize").toInt(); - } else { - panelSize = 46; - } + int position=0; + int panelSize=0; + if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); + if(gsetting->keys().contains(QString("panelposition"))) + position=gsetting->get("panelposition").toInt(); + else + position=0; + if(gsetting->keys().contains(QString("panelsize"))) + panelSize=gsetting->get("panelsize").toInt(); + else + panelSize=46; delete gsetting; - } else { - position = 0; - panelSize = 46; } - + else + { + position=0; + panelSize=46; + } list.append(QString::number(panelSize)); list.append(QString::number(position)); } - return list; } double getTransparency() { - double transparency = 0.0; - - if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) { + double transparency=0.0; + if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) + { QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); - - if (gsetting.keys().contains(QString("transparency"))) { - transparency = gsetting.get("transparency").toDouble(); - } + if(gsetting.keys().contains(QString("transparency"))) + transparency=gsetting.get("transparency").toDouble(); } - return transparency; } void debugLog(QString strMsg) { - QString path = QDir::homePath() + "/.config/ukui/ukui-menu.log"; + QString path=QDir::homePath()+"/.config/ukui/ukui-menu.log"; QFile confFile(path); - - if (confFile.open(QIODevice::Text | QIODevice::ReadWrite | QIODevice::Append)) { - QString text = QString("%1 %2") - .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")) - .arg(strMsg); + if(confFile.open(QIODevice::Text | QIODevice::ReadWrite | QIODevice::Append)) + { + QString text=QString("%1 %2") + .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")) + .arg(strMsg); QTextStream textStream(&confFile); - textStream << text << endl; + textStream< list = file.readLine().split('\x00'); - - Q_FOREACH (QByteArray array, list) { - if (array.contains("GIO_LAUNCHED_DESKTOP_FILE=")) { - ret = QString(array.split('=').at(1)); + if(file.open(QIODevice::ReadOnly)) + { + QList list=file.readLine().split('\x00'); + Q_FOREACH(QByteArray array, list) + { + if(array.contains("GIO_LAUNCHED_DESKTOP_FILE=")) + { + ret=QString(array.split('=').at(1)); break; } } - file.close(); } - return ret; + } void openDataBase(QString connectionName) @@ -228,14 +225,15 @@ void openDataBase(QString connectionName) db = QSqlDatabase::addDatabase("QSQLITE", connectionName); db.setDatabaseName(DATABASENAME); - if (false == db.open()) { + if (false == db.open()) + { qDebug() << db.lastError().text(); } } void closeDataBase(QString connectionName) { - QSqlDatabase db = QSqlDatabase::database("connectionName"); + QSqlDatabase db=QSqlDatabase::database("connectionName"); db.close(); QSqlDatabase::removeDatabase(connectionName); } @@ -247,150 +245,143 @@ void initDatabase() QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); sql.exec("select count(*) from sqlite_master where type='table' and name='appInfo'"); - - if (sql.next()) { - if (sql.value(0).toInt() == 0) { - QSettings *setting = new QSettings("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); + if(sql.next()) + { + if(sql.value(0).toInt()==0) + { + QSettings* setting=new QSettings("/var/lib/ukui-menu/ukui-menu.ini",QSettings::IniFormat); setting->beginGroup("application"); QString desktopfp; - - Q_FOREACH (QString desktopfn, setting->allKeys()) { - if (setting->value(desktopfn).toInt() == 1) { + Q_FOREACH(QString desktopfn, setting->allKeys()) + { + if(setting->value(desktopfn).toInt()==1) + { desktopfp.clear(); - - if (UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) { - desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); - } else { - desktopfp = QString("/usr/share/applications/" + desktopfn); - } - + if(UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) + desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); + else + desktopfp=QString("/usr/share/applications/"+desktopfn); QFileInfo info(desktopfp); - - if (!info.isFile() || !UkuiMenuInterface::desktopfpVector.contains(desktopfp)) { + if(!info.isFile() || !UkuiMenuInterface::desktopfpVector.contains(desktopfp)) continue; - } - desktopfnList.append(desktopfn); } } - setting->endGroup(); delete setting; } } - sql.exec("create table if not exists appInfo(desktop char primary key, times int, time int, type int, recent int)"); - - Q_FOREACH (QString desktopfn, desktopfnList) { - QDateTime dt = QDateTime::currentDateTime(); - int datetime = dt.toTime_t(); - QString cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(0) - .arg(datetime) - .arg(1) - .arg(0); + Q_FOREACH(QString desktopfn,desktopfnList) + { + QDateTime dt=QDateTime::currentDateTime(); + int datetime=dt.toTime_t(); + QString cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") + .arg(desktopfn) + .arg(0) + .arg(datetime) + .arg(1) + .arg(0); sql.exec(cmd); } } bool updateDataBaseTableTimes(QString desktopfn) { - bool ret = false; + bool ret=false; QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd; - cmd = QString("select times from appInfo where desktop=\"%1\"").arg(desktopfn); - - if (sql.exec(cmd)) { - QDateTime dt = QDateTime::currentDateTime(); - int datetime = dt.toTime_t(); - - if (sql.next()) { - int times = sql.value(0).toInt() + 1; - cmd = QString("update appInfo set times=%1, time=%2, recent=%3 where desktop=\"%4\"") - .arg(times) - .arg(datetime) - .arg(0) - .arg(desktopfn); - } else { - cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(1) - .arg(datetime) - .arg(0) - .arg(0); + cmd=QString("select times from appInfo where desktop=\"%1\"").arg(desktopfn); + if(sql.exec(cmd)) + { + QDateTime dt=QDateTime::currentDateTime(); + int datetime=dt.toTime_t(); + if(sql.next()) + { + int times=sql.value(0).toInt()+1; + cmd=QString("update appInfo set times=%1, time=%2, recent=%3 where desktop=\"%4\"") + .arg(times) + .arg(datetime) + .arg(0) + .arg(desktopfn); } - - ret = sql.exec(cmd); + else + { + cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") + .arg(desktopfn) + .arg(1) + .arg(datetime) + .arg(0) + .arg(0); + } + ret=sql.exec(cmd); } - - qDebug() << "数据库更新应用使用频率成功"; return ret; } bool updateDataBaseTableType(QString desktopfn, int type) { - bool ret = false; + bool ret=false; QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); QString cmd; - switch (type) { - case 0: { //解除锁定 - cmd = QString("delete from appInfo where desktop=\"%1\"") - .arg(desktopfn); - ret = sql.exec(cmd); - } - break; - - case 1: { //锁定 - cmd = QString("select type from appInfo where desktop=\"%1\"") - .arg(desktopfn); - - if (sql.exec(cmd)) { - if (sql.next()) { //更新记录 - cmd = QString("update appInfo set type=%1 where desktop=\"%2\"") - .arg(type) - .arg(desktopfn); - } else { //添加记录 - QDateTime dt = QDateTime::currentDateTime(); - int datetime = dt.toTime_t(); - cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(0) - .arg(datetime) - .arg(type) - .arg(0); - } - - ret = sql.exec(cmd); - } - } - break; - - default: - break; + case 0://解除锁定 + { + cmd=QString("delete from appInfo where desktop=\"%1\"") + .arg(desktopfn); + ret=sql.exec(cmd); + } + break; + case 1://锁定 + { + cmd=QString("select type from appInfo where desktop=\"%1\"") + .arg(desktopfn); + if(sql.exec(cmd)) + { + if(sql.next())//更新记录 + { + cmd=QString("update appInfo set type=%1 where desktop=\"%2\"") + .arg(type) + .arg(desktopfn); + } + else//添加记录 + { + QDateTime dt=QDateTime::currentDateTime(); + int datetime=dt.toTime_t(); + cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") + .arg(desktopfn) + .arg(0) + .arg(datetime) + .arg(type) + .arg(0); + } + ret=sql.exec(cmd); + } + } + break; + default: + break; } - return ret; } bool updateDataBaseTableRecent(QString desktopfn) { - bool ret = false; + bool ret=false; QSqlDatabase db = QSqlDatabase::database("DirectoryChangedThread"); QSqlQuery sql(db); QString cmd; - QDateTime dt = QDateTime::currentDateTime(); - int datetime = dt.toTime_t(); - cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(0) - .arg(datetime) - .arg(0) - .arg(1); - ret = sql.exec(cmd); + QDateTime dt=QDateTime::currentDateTime(); + int datetime=dt.toTime_t(); + cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") + .arg(desktopfn) + .arg(0) + .arg(datetime) + .arg(0) + .arg(1); + ret=sql.exec(cmd); return ret; } @@ -398,21 +389,20 @@ bool checkIfLocked(QString desktopfn) { QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); - QString cmd = QString("select type from appInfo where desktop=\"%1\"") - .arg(desktopfn); - - if (sql.exec(cmd)) { - if (!sql.next()) { + QString cmd=QString("select type from appInfo where desktop=\"%1\"") + .arg(desktopfn); + if(sql.exec(cmd)) + { + if(!sql.next()) return false; - } else { - if (sql.value(0).toInt() == 0) { + else + { + if(sql.value(0).toInt()==0) return false; - } else { + else return true; - } } } - return false; } @@ -420,21 +410,20 @@ bool checkIfRecent(QString desktopfn) { QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); - QString cmd = QString("select recent from appInfo where desktop=\"%1\"") - .arg(desktopfn); - - if (sql.exec(cmd)) { - if (!sql.next()) { + QString cmd=QString("select recent from appInfo where desktop=\"%1\"") + .arg(desktopfn); + if(sql.exec(cmd)) + { + if(!sql.next()) return false; - } else { - if (sql.value(0).toInt() == 0) { + else + { + if(sql.value(0).toInt()==0) return false; - } else { + else return true; - } } } - return false; } @@ -443,14 +432,12 @@ QStringList getLockAppList() QStringList list; QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); - QString cmd = QString("select desktop from appInfo where type=1"); - - if (sql.exec(cmd)) { - while (sql.next()) { + QString cmd=QString("select desktop from appInfo where type=1"); + if(sql.exec(cmd)) + { + while(sql.next()) list.append(sql.value(0).toString()); - } } - return list; } @@ -459,73 +446,72 @@ QStringList getUnlockAllList() QStringList list; QSqlDatabase db = QSqlDatabase::database("MainThread"); QSqlQuery sql(db); - QString cmd = QString("select desktop from appInfo where type=0 and times>=1 order by times desc"); - - if (sql.exec(cmd)) { - while (sql.next()) { + QString cmd=QString("select desktop from appInfo where type=0 and times>=1 order by times desc"); + if(sql.exec(cmd)) + { + while(sql.next()) list.append(sql.value(0).toString()); - } } - return list; } void cleanTimeoutApp() { QSqlDatabase db = QSqlDatabase::database("MainThread"); - QDateTime dt = QDateTime::currentDateTime(); - int datetime = dt.toTime_t() - 24 * 60 * 60 * 3; - QString cmd = QString("select desktop from appInfo where time < %1") - .arg(datetime); + QDateTime dt=QDateTime::currentDateTime(); + int datetime=dt.toTime_t()-24*60*60*3; + QString cmd=QString("select desktop from appInfo where time < %1") + .arg(datetime); QStringList list; QSqlQuery sql(db); - - if (sql.exec(cmd)) { - while (sql.next()) { - if (!checkIfLocked(sql.value(0).toString())) { + if(sql.exec(cmd)) + { + while(sql.next()) + { + if(!checkIfLocked(sql.value(0).toString())) list.append(sql.value(0).toString()); - } } } - - Q_FOREACH (QString desktopfn, list) { - cmd = QString("delete from appInfo where desktop=\"%1\"") - .arg(desktopfn); + Q_FOREACH(QString desktopfn, list) + { + cmd=QString("delete from appInfo where desktop=\"%1\"") + .arg(desktopfn); sql.exec(cmd); } } bool deleteAppRecord(QString desktopfn) { - bool ret = false; + bool ret=false; QSqlDatabase db = QSqlDatabase::database("DirectoryChangedThread"); - QString cmd = QString("delete from appInfo where desktop=\"%1\"") - .arg(desktopfn); + QString cmd=QString("delete from appInfo where desktop=\"%1\"") + .arg(desktopfn); QSqlQuery sql(db); - ret = sql.exec(cmd); + ret=sql.exec(cmd); return ret; } void execApp(QString desktopfp) { UkuiMenuInterface interface; - - if (interface.checkKreApp(desktopfp)) { + if(interface.checkKreApp(desktopfp)) + { QProcess::startDetached(interface.getAppExec(desktopfp)); - } else { + } + else + { QString appName = interface.getAppExec(desktopfp); - QStringList strList = (appName.replace("\"", "")).split(" "); - + QStringList strList = (appName.replace("\"","")).split(" "); // for(int i = 1; i < strList.size(); i++) // { - if (QString(strList.at(0)) == "kmplayer") { - QProcess::startDetached(strList.at(0)); - return; - } - + if(QString(strList.at(0)) == "kmplayer") + { + QProcess::startDetached(strList.at(0)); + return; + } // } - GDesktopAppInfo *desktopAppInfo = g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); - g_app_info_launch(G_APP_INFO(desktopAppInfo), nullptr, nullptr, nullptr); + GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); + g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); g_object_unref(desktopAppInfo); } } @@ -533,57 +519,54 @@ void execApp(QString desktopfp) bool checkOsRelease() { QFile file("/etc/os-release"); - - if (file.open(QFile::ReadOnly)) { - QByteArray line = file.readLine(); + if(file.open(QFile::ReadOnly)) + { + QByteArray line=file.readLine(); file.close(); - - if (QString(line).contains("Ubuntu")) { + if(QString(line).contains("Ubuntu")) return true; - } } - return false; } //获取用户图像 QString getUserIcon() { - qint64 uid = static_cast(getuid()); + qint64 uid=static_cast(getuid()); QDBusInterface iface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts", QDBusConnection::systemBus()); - QDBusReplyobjPath = iface.call("FindUserById", uid); + QDBusReplyobjPath=iface.call("FindUserById",uid); + QDBusInterface useriface("org.freedesktop.Accounts", objPath.value().path(), "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); - QDBusReply var = useriface.call("Get", "org.freedesktop.Accounts.User", "IconFile"); - QString iconstr = var.value().toString(); + QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","IconFile"); + QString iconstr=var.value().toString(); return iconstr; } QString getUserName() { QString name; - qint64 uid = static_cast(getuid()); + qint64 uid=static_cast(getuid()); QDBusInterface iface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts", QDBusConnection::systemBus()); - QDBusReply objPath = iface.call("FindUserById", uid); + QDBusReply objPath=iface.call("FindUserById",uid); QDBusInterface useriface("org.freedesktop.Accounts", objPath.value().path(), "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); - QDBusReply var = useriface.call("Get", "org.freedesktop.Accounts.User", "RealName"); - name = var.value().toString(); - - if (name.isEmpty()) { - var = useriface.call("Get", "org.freedesktop.Accounts.User", "UserName"); - name = var.value().toString(); + QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","RealName"); + name=var.value().toString(); + if(name.isEmpty()) + { + var=useriface.call("Get","org.freedesktop.Accounts.User","UserName"); + name=var.value().toString(); } - return name; } diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_bo.ts b/translations/ukui-menu_bo.ts old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_tr.ts b/translations/ukui-menu_tr.ts old mode 100755 new mode 100644 diff --git a/translations/ukui-menu_zh_CN.ts b/translations/ukui-menu_zh_CN.ts old mode 100755 new mode 100644 diff --git a/ukui-menu.desktop b/ukui-menu.desktop old mode 100755 new mode 100644 diff --git a/ukui-menu.ini b/ukui-menu.ini old mode 100755 new mode 100644 diff --git a/ukui-menu.pro b/ukui-menu.pro old mode 100755 new mode 100644 diff --git a/ukui-menu.pro.user b/ukui-menu.pro.user new file mode 100644 index 0000000..a5cc0fd --- /dev/null +++ b/ukui-menu.pro.user @@ -0,0 +1,314 @@ + + + + + + EnvironmentId + {b9d686e0-ada0-41c1-ad9c-96f1279f7707} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + 桌面 + 桌面 + {9d9f9a2c-403b-48c4-83ee-e52b4e889b83} + 0 + 0 + 0 + + /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug + + + true + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Release + + + true + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Qt4ProjectManager.MakeStep + + false + + + false + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro + /home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro + + false + + false + true + true + false + false + true + + /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + From 3c242b8f5a8c0659ec6d1840d293cffd3b02fa91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E7=82=9C?= Date: Fri, 20 May 2022 16:38:37 +0800 Subject: [PATCH 05/12] Import Upstream version 3.0.1.0720.1update1 --- data/img/sidebarwidget/default.svg | 1 + main.cpp | 22 +- src/CommonUseWidget/commonusewidget.cpp | 65 +- src/CommonUseWidget/commonusewidget.h | 1 - src/CommonUseWidget/fullcommonusewidget.cpp | 134 +-- src/CommonUseWidget/fullcommonusewidget.h | 2 + src/DBus/dbus.cpp | 17 - src/DBus/dbus.h | 17 - src/FunctionWidget/fullfunctionwidget.cpp | 435 ++++----- src/FunctionWidget/functionwidget.cpp | 206 ++-- src/FunctionWidget/functionwidget.h | 2 - src/Interface/ukuimenuinterface.cpp | 47 +- src/LetterWidget/fullletterwidget.cpp | 422 ++++---- src/LetterWidget/letterwidget.cpp | 179 ++-- src/LetterWidget/letterwidget.h | 1 - src/MainViewWidget/directorychangedthread.cpp | 44 +- src/MainViewWidget/mainviewwidget.cpp | 902 +++++++++-------- src/MainViewWidget/mainviewwidget.h | 23 +- src/MainWindow/mainwindow.cpp | 559 ++++------- src/MainWindow/mainwindow.h | 8 +- src/ModelView/fulllistdelegate.cpp | 109 +++ src/ModelView/fulllistdelegate.h | 19 + src/ModelView/fulllistitem.cpp | 71 ++ src/ModelView/fulllistitem.h | 20 + src/ModelView/fulllistmodel.cpp | 74 ++ src/ModelView/fulllistmodel.h | 30 + src/ModelView/fulllistview.cpp | 141 +++ src/ModelView/fulllistview.h | 37 + src/QtSingleApplication/QtLockedFile | 18 - src/QtSingleApplication/QtSingleApplication | 18 - src/RightClickMenu/menubox.cpp | 17 - src/RightClickMenu/menubox.h | 17 - src/RightClickMenu/rightclickmenu.cpp | 230 +++-- src/RightClickMenu/rightclickmenu.h | 1 - src/RightClickMenu/uninstallwhitelist.cpp | 84 ++ src/RightClickMenu/uninstallwhitelist.h | 47 + .../fullsearchresultwidget.cpp | 91 +- src/SearchResultWidget/pinyinWithTone.txt | 2 +- src/SearchResultWidget/pinyinWithoutTone.txt | 2 +- src/SearchResultWidget/searchappthread.cpp | 177 ++-- src/SearchResultWidget/searchappthread.h | 2 - src/SearchResultWidget/searchresultwidget.cpp | 46 +- src/SearchResultWidget/searchresultwidget.h | 6 +- src/SideBarWidget/sidebarwidget.cpp | 908 +++++++++--------- src/SideBarWidget/sidebarwidget.h | 56 +- src/Style/style.cpp | 103 +- src/Style/style.h | 3 +- src/UtilityFunction/convertdesktoptowinid.cpp | 176 ++-- src/UtilityFunction/convertdesktoptowinid.h | 27 +- src/UtilityFunction/fullitemdelegate.cpp | 203 ++-- src/UtilityFunction/fullitemdelegate.h | 8 +- src/UtilityFunction/fulllistview.cpp | 315 +++--- src/UtilityFunction/fulllistview.h | 24 +- src/UtilityFunction/itemdelegate.cpp | 248 +++-- src/UtilityFunction/itemdelegate.h | 6 +- src/UtilityFunction/letterclassifybutton.cpp | 1 - src/UtilityFunction/listview.cpp | 198 ++-- src/UtilityFunction/listview.h | 21 +- src/UtilityFunction/proxystyle.cpp | 17 - src/UtilityFunction/proxystyle.h | 17 - .../softwaredatabaseupdatethread.cpp | 62 ++ .../softwaredatabaseupdatethread.h | 27 + src/UtilityFunction/utility.cpp | 73 -- src/UtilityFunction/utility.h | 11 +- translations/ukui-menu_bo_CN.ts | 290 ++++++ ukui-menu.pro | 2 - ukui-menu.pro.user | 181 ++-- 67 files changed, 3913 insertions(+), 3410 deletions(-) create mode 100644 data/img/sidebarwidget/default.svg create mode 100644 src/ModelView/fulllistdelegate.cpp create mode 100644 src/ModelView/fulllistdelegate.h create mode 100644 src/ModelView/fulllistitem.cpp create mode 100644 src/ModelView/fulllistitem.h create mode 100644 src/ModelView/fulllistmodel.cpp create mode 100644 src/ModelView/fulllistmodel.h create mode 100644 src/ModelView/fulllistview.cpp create mode 100644 src/ModelView/fulllistview.h create mode 100644 src/RightClickMenu/uninstallwhitelist.cpp create mode 100644 src/RightClickMenu/uninstallwhitelist.h create mode 100644 src/UtilityFunction/softwaredatabaseupdatethread.cpp create mode 100644 src/UtilityFunction/softwaredatabaseupdatethread.h create mode 100644 translations/ukui-menu_bo_CN.ts diff --git a/data/img/sidebarwidget/default.svg b/data/img/sidebarwidget/default.svg new file mode 100644 index 0000000..7b506cb --- /dev/null +++ b/data/img/sidebarwidget/default.svg @@ -0,0 +1 @@ +avatar \ No newline at end of file diff --git a/main.cpp b/main.cpp index 05ffbaa..510c21d 100644 --- a/main.cpp +++ b/main.cpp @@ -36,36 +36,42 @@ int main(int argc, char *argv[]) { initUkuiLog4qt("ukui-menu"); qRegisterMetaType>("QVector"); + #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif + QtSingleApplication app("ukui-menu", argc, argv); app.setQuitOnLastWindowClosed(false); - if (app.isRunning()) { + + if(app.isRunning()) + { app.sendMessage("raise_window_noop"); return EXIT_SUCCESS; } // auto Style=new ProxyStyle; // app.setStyle(Style); - QTranslator translator; - if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) { + QTranslator translator; + if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) app.installTranslator(&translator); - } else { + else qDebug() << "Load translations file" << QLocale() << "failed!"; - } Zeeker::FileUtils::loadHanziTable(":/src/SearchResultWidget/pinyinWithoutTone.txt"); MainWindow w; app.setActivationWindow(&w); + // w.setProperty("useSystemStyleBlur", true); + //测试 + // if(Style::panelPosition==0) // w.setGeometry(QRect(Style::primaryScreenX+4,Style::primaryScreenY+Style::primaryScreenHeight-Style::panelSize-Style::minh-3, // Style::minw,Style::minh)); @@ -76,11 +82,13 @@ int main(int argc, char *argv[]) // else // w.setGeometry(QRect(Style::primaryScreenX+Style::primaryScreenWidth-Style::panelSize-Style::minw-4,Style::primaryScreenY+4, // Style::minw,Style::minh)); + w.show(); w.raise(); w.update(); w.activateWindow(); w.hide(); //测试 + return app.exec(); } diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp index 3c49d1c..4196876 100644 --- a/src/CommonUseWidget/commonusewidget.cpp +++ b/src/CommonUseWidget/commonusewidget.cpp @@ -27,23 +27,23 @@ CommonUseWidget::CommonUseWidget(QWidget *parent) : QWidget(parent) { initUi(); + } CommonUseWidget::~CommonUseWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } void CommonUseWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setAttribute(Qt::WA_TranslucentBackground); - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); - m_ukuiMenuInterface = new UkuiMenuInterface; + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + + m_ukuiMenuInterface=new UkuiMenuInterface; + initAppListWidget(); fillAppList(); } @@ -53,14 +53,12 @@ void CommonUseWidget::initUi() */ void CommonUseWidget::initAppListWidget() { - m_listView = new ListView(this, this->width(), this->height() - 6, 0); - m_listView->setFixedSize(this->width(), this->height() - 6); -//m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); + m_listView=new ListView(this,this->width()-6,this->height()-6,0); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); - connect(m_listView, &ListView::sendItemClickedSignal, this, &CommonUseWidget::execApplication); - connect(m_listView, &ListView::sendUpdateAppListSignal, this, &CommonUseWidget::updateListViewSlot); - connect(m_listView, &ListView::sendHideMainWindowSignal, this, &CommonUseWidget::sendHideMainWindowSignal); - connect(m_listView, &ListView::sendMainWinActiveSignal, this, &CommonUseWidget::sendMainWinActiveSignal); + connect(m_listView,&ListView::sendItemClickedSignal,this,&CommonUseWidget::execApplication); + connect(m_listView,&ListView::sendUpdateAppListSignal,this,&CommonUseWidget::updateListViewSlot); + connect(m_listView,&ListView::sendHideMainWindowSignal,this,&CommonUseWidget::sendHideMainWindowSignal); } /** @@ -69,26 +67,23 @@ void CommonUseWidget::initAppListWidget() void CommonUseWidget::fillAppList() { m_data.clear(); - - Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { - m_data.append(QStringList() << desktopfp << "1"); - } - + Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector) + m_data.append(QStringList()<addData(m_data); } void CommonUseWidget::selectFirstItem() { this->focusNextChild(); - m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + m_listView->setCurrentIndex(m_listView->model()->index(0,0)); } void CommonUseWidget::selectFirstItemTab() { this->setFocus(); - - if (m_listView->currentIndex().row() == -1) { - m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + if(m_listView->currentIndex().row() == -1) + { + m_listView->setCurrentIndex(m_listView->model()->index(0,0)); } } /** @@ -97,7 +92,7 @@ void CommonUseWidget::selectFirstItemTab() void CommonUseWidget::execApplication(QStringList arg) { Q_EMIT sendHideMainWindowSignal(); - QString desktopfp = arg.at(0); + QString desktopfp=arg.at(0); execApp(desktopfp); } @@ -113,13 +108,10 @@ void CommonUseWidget::updateListViewSlot() void CommonUseWidget::updateListView() { m_data.clear(); - - Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { - m_data.append(QStringList() << desktopfp << "1"); - } - + Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification()) + m_data.append(QStringList()<updateData(m_data); -// m_listView->setFocus(); + // m_listView->setFocus(); } void CommonUseWidget::widgetMakeZero() @@ -129,17 +121,16 @@ void CommonUseWidget::widgetMakeZero() void CommonUseWidget::moveScrollBar(int type) { - if (type == 0) { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - 100); - } else { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + 100); - } + if(type==0) + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-100); + else + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+100); } void CommonUseWidget::repaintWidget() { - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); - m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); } diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h index aeacf4b..16e571c 100644 --- a/src/CommonUseWidget/commonusewidget.h +++ b/src/CommonUseWidget/commonusewidget.h @@ -103,7 +103,6 @@ Q_SIGNALS: * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); - void sendMainWinActiveSignal(bool flag); }; #endif // COMMONUSEWIDGET_H diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp index a3afed2..035225c 100644 --- a/src/CommonUseWidget/fullcommonusewidget.cpp +++ b/src/CommonUseWidget/fullcommonusewidget.cpp @@ -30,87 +30,91 @@ FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) : FullCommonUseWidget::~FullCommonUseWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } void FullCommonUseWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setAttribute(Qt::WA_StyledBackground,true); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); this->setFocusPolicy(Qt::NoFocus); - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->setContentsMargins(0, 0, 0, 0); + QHBoxLayout* mainLayout=new QHBoxLayout; + mainLayout->setContentsMargins(0,0,0,0); this->setLayout(mainLayout); - m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); mainLayout->addItem(m_spaceItem); - m_scrollArea = new ScrollArea; - m_scrollAreaWid = new ScrollAreaWid; + m_scrollArea=new ScrollArea; + m_scrollAreaWid=new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout = new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout=new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); m_scrollAreaWidLayout->setSpacing(10); m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); mainLayout->addWidget(m_scrollArea); - m_ukuiMenuInterface = new UkuiMenuInterface; + + m_ukuiMenuInterface=new UkuiMenuInterface; + initAppListWidget(); fillAppList(); + + flag = true; + //翻页灵敏度时间调节 + time = new QTimer(this); + connect(time,&QTimer::timeout,[=](){ + if(flag == false) + { + flag = true; + time->stop(); + } + }); } void FullCommonUseWidget::initAppListWidget() { - m_listView = new FullListView(this, 0); + m_listView=new FullListView(this,0); // m_listView->setFixedSize(this->width()-Style::LeftWidWidth+3,this->height()); // QHBoxLayout *mainLayout=qobject_cast(this->layout()); // mainLayout->insertWidget(1,m_listView); m_scrollAreaWidLayout->addWidget(m_listView); - connect(m_scrollArea, &ScrollArea::requestUpdate, m_listView->viewport(), [ = ]() { - QEventLoop loop; - QTimer::singleShot(1, &loop, SLOT(quit())); - loop.exec(); - m_listView->repaint(); - }); - connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullCommonUseWidget::execApplication); - connect(m_listView, &FullListView::sendUpdateAppListSignal, this, &FullCommonUseWidget::updateListViewSlot); - connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullCommonUseWidget::sendHideMainWindowSignal); - connect(m_listView, &FullListView::sendSetslidebar, this, &FullCommonUseWidget::onSetSlider); + connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullCommonUseWidget::execApplication); + connect(m_listView,&FullListView::sendUpdateAppListSignal,this,&FullCommonUseWidget::updateListViewSlot); + connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullCommonUseWidget::sendHideMainWindowSignal); + connect(m_listView,&FullListView::sendSetslidebar,this,&FullCommonUseWidget::onSetSlider); } void FullCommonUseWidget::resizeScrollAreaControls() { - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); - QWidget *wid = widItem->widget(); - FullListView *listview = qobject_cast(wid); + QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0); + QWidget* wid=widItem->widget(); + FullListView* listview=qobject_cast(wid); listview->adjustSize(); - int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; - int rowcount = 0; + int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; + int rowcount=0; + if(listview->model()->rowCount()%dividend>0) + { + rowcount=listview->model()->rowCount()/dividend+1; + } + else + { + rowcount=listview->model()->rowCount()/dividend; - if (listview->model()->rowCount() % dividend > 0) { - rowcount = listview->model()->rowCount() / dividend + 1; - } else { - rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); + listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); m_scrollArea->widget()->adjustSize(); } void FullCommonUseWidget::fillAppList() { m_data.clear(); - - Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { + Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector) m_data.append(desktopfp); - } - m_listView->addData(m_data); resizeScrollAreaControls(); } @@ -126,28 +130,36 @@ void FullCommonUseWidget::execApplication(QString desktopfp) void FullCommonUseWidget::selectFirstItem() { - // this->focusNextChild(); + // this->focusNextChild(); qDebug() << "void FullCommonUseWidget::selectFirstItem()"; - m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + m_listView->setCurrentIndex(m_listView->model()->index(0,0)); } void FullCommonUseWidget::selectFirstItemTab() { this->setFocus(); - - if (m_listView->currentIndex().row() == -1) { - m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + if(m_listView->currentIndex().row() == -1) + { + m_listView->setCurrentIndex(m_listView->model()->index(0,0)); } } void FullCommonUseWidget::onSetSlider(int value) { - if (value == 0) { - m_scrollArea->verticalScrollBar()->setValue(0); - } else { - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); - } +// if(flag) +// { +// flag = false; +// time->start(100); + if(value == 0) + { + m_scrollArea->verticalScrollBar()->setValue(0); + } + else + { + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + } +// } } /** * 更新应用列表 @@ -160,11 +172,8 @@ void FullCommonUseWidget::updateListViewSlot() void FullCommonUseWidget::updateListView() { m_data.clear(); - - Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { + Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification()) m_data.append(desktopfp); - } - m_listView->updateData(m_data); } @@ -172,7 +181,8 @@ void FullCommonUseWidget::repaintWidget() { this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); m_scrollAreaWidLayout->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; @@ -187,11 +197,9 @@ void FullCommonUseWidget::widgetMakeZero() void FullCommonUseWidget::moveScrollBar(int type) { - int height = Style::primaryScreenHeight; - - if (type == 0) { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); - } else { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); - } + int height=Style::primaryScreenHeight; + if(type==0) + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-height*100/1080); + else + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+height*100/1080); } diff --git a/src/CommonUseWidget/fullcommonusewidget.h b/src/CommonUseWidget/fullcommonusewidget.h index 1afe6f4..ded8e50 100644 --- a/src/CommonUseWidget/fullcommonusewidget.h +++ b/src/CommonUseWidget/fullcommonusewidget.h @@ -74,6 +74,8 @@ private: ScrollArea* m_scrollArea=nullptr; ScrollAreaWid* m_scrollAreaWid=nullptr; QVBoxLayout* m_scrollAreaWidLayout=nullptr; + bool flag; + QTimer *time = nullptr; protected: /** diff --git a/src/DBus/dbus.cpp b/src/DBus/dbus.cpp index 7196fc0..f8d79a6 100644 --- a/src/DBus/dbus.cpp +++ b/src/DBus/dbus.cpp @@ -1,20 +1,3 @@ -/* - * 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 #include diff --git a/src/DBus/dbus.h b/src/DBus/dbus.h index 4a70f04..8f017fe 100644 --- a/src/DBus/dbus.h +++ b/src/DBus/dbus.h @@ -1,20 +1,3 @@ -/* - * 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 setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setAttribute(Qt::WA_TranslucentBackground); - m_applistWid = new QWidget(this); - m_iconListWid = new QWidget(this); + m_applistWid=new QWidget(this); + m_iconListWid=new QWidget(this); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); - m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height()); - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->setContentsMargins(0, 0, 0, 0); + m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); + m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height()); + + QHBoxLayout* mainLayout=new QHBoxLayout; + mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); mainLayout->addWidget(m_iconListWid); mainLayout->addWidget(m_applistWid); this->setLayout(mainLayout); - m_ukuiMenuInterface = new UkuiMenuInterface; + + m_ukuiMenuInterface=new UkuiMenuInterface; + initAppListWidget(); initIconListWidget(); + flag = true; //翻页灵敏度时间调节 time = new QTimer(this); - connect(time, &QTimer::timeout, [ = ]() { - if (flag == false) { + connect(time,&QTimer::timeout,[=](){ + if(flag == false) + { flag = true; time->stop(); } @@ -74,23 +76,24 @@ void FullFunctionWidget::initUi() */ void FullFunctionWidget::initAppListWidget() { - QHBoxLayout *layout = new QHBoxLayout(m_applistWid); - layout->setContentsMargins(0, 0, 0, 0); + QHBoxLayout* layout=new QHBoxLayout(m_applistWid); + layout->setContentsMargins(0,0,0,0); m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea; - m_scrollAreaWid = new ScrollAreaWid; + + m_scrollArea=new ScrollArea; + m_scrollAreaWid=new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout = new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout=new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); m_scrollAreaWidLayout->setSpacing(10); m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); layout->addWidget(m_scrollArea); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullFunctionWidget::valueChangedSlot); - m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, + this,&FullFunctionWidget::valueChangedSlot); + m_appListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); fillAppList(); } @@ -100,103 +103,92 @@ void FullFunctionWidget::initAppListWidget() void FullFunctionWidget::fillAppList() { m_classificationList.clear(); - QVector vector = UkuiMenuInterface::functionalVector; - QStringList androidlist = vector.at(0); - - if (!androidlist.isEmpty()) { + QVector vector=UkuiMenuInterface::functionalVector; + QStringList androidlist=vector.at(0); + if(!androidlist.isEmpty()) + { insertClassificationBtn("Mobile"); insertAppList(androidlist); } - QStringList netlist = vector.at(1); - - if (!netlist.isEmpty()) { + QStringList netlist=vector.at(1); + if(!netlist.isEmpty()) + { insertClassificationBtn("Internet"); insertAppList(netlist); } - - QStringList sociallist = vector.at(2); - - if (!sociallist.isEmpty()) { + QStringList sociallist=vector.at(2); + if(!sociallist.isEmpty()) + { insertClassificationBtn("Social"); insertAppList(sociallist); } - - QStringList avlist = vector.at(3); - - if (!avlist.isEmpty()) { + QStringList avlist=vector.at(3); + if(!avlist.isEmpty()) + { insertClassificationBtn("Video"); insertAppList(avlist); } - - QStringList developlist = vector.at(4); - - if (!developlist.isEmpty()) { + QStringList developlist=vector.at(4); + if(!developlist.isEmpty()) + { insertClassificationBtn("Development"); insertAppList(developlist); } - - QStringList graphicslist = vector.at(5); - - if (!graphicslist.isEmpty()) { + QStringList graphicslist=vector.at(5); + if(!graphicslist.isEmpty()) + { insertClassificationBtn("Image"); insertAppList(graphicslist); } - - QStringList gamelist = vector.at(6); - - if (!gamelist.isEmpty()) { + QStringList gamelist=vector.at(6); + if(!gamelist.isEmpty()) + { insertClassificationBtn("Game"); insertAppList(gamelist); } - - QStringList officelist = vector.at(7); - - if (!officelist.isEmpty()) { + QStringList officelist=vector.at(7); + if(!officelist.isEmpty()) + { insertClassificationBtn("Office"); insertAppList(officelist); } - - QStringList educationlist = vector.at(8); - - if (!educationlist.isEmpty()) { + QStringList educationlist=vector.at(8); + if(!educationlist.isEmpty()) + { insertClassificationBtn("Education"); insertAppList(educationlist); } - QStringList systemadminlist = vector.at(9); - - if (!systemadminlist.isEmpty()) { + QStringList systemadminlist=vector.at(9); + if(!systemadminlist.isEmpty()) + { insertClassificationBtn("System"); insertAppList(systemadminlist); } - - QStringList otherlist = vector.at(10); - - if (!otherlist.isEmpty()) { + QStringList otherlist=vector.at(10); + if(!otherlist.isEmpty()) + { insertClassificationBtn("Others"); insertAppList(otherlist); } - m_scrollAreaWidLayout->addItem(m_appListBottomSpacer); resizeScrollAreaControls(); } void FullFunctionWidget::insertClassificationBtn(QString category) { - SplitBarFrame *classificationbtn = new SplitBarFrame(this, category, m_scrollArea->width() - 16, 30, 2); + SplitBarFrame* classificationbtn=new SplitBarFrame(this,category,m_scrollArea->width()-12,30,2); m_scrollAreaWidLayout->addWidget(classificationbtn); m_classificationList.append(category); + } void FullFunctionWidget::insertAppList(QStringList desktopfplist) { - FullListView *listview = new FullListView(this, 2); + FullListView* listview=new FullListView(this,2); //修复异常黑框问题 - connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { - QEventLoop loop; - QTimer::singleShot(1, &loop, SLOT(quit())); - loop.exec(); + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ listview->repaint(listview->rect()); }); connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider); @@ -204,14 +196,11 @@ void FullFunctionWidget::insertAppList(QStringList desktopfplist) listview->installEventFilter(this); m_scrollAreaWidLayout->addWidget(listview); m_data.clear(); - - for (int i = 0; i < desktopfplist.count(); i++) { + for(int i=0;iaddData(m_data); - connect(listview, &FullListView::sendItemClickedSignal, this, &FullFunctionWidget::execApplication); - connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullFunctionWidget::sendHideMainWindowSignal); + connect(listview,&FullListView::sendItemClickedSignal,this,&FullFunctionWidget::execApplication); + connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullFunctionWidget::sendHideMainWindowSignal); } /** @@ -231,34 +220,29 @@ void FullFunctionWidget::updateAppListView() //刷新应用列表界面 QLayoutItem *child; m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer); - - while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { - QWidget *wid = child->widget(); - m_scrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - - fillAppList(); + while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { + QWidget* wid=child->widget(); + m_scrollAreaWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + fillAppList(); //刷新图标列表界面 - Q_FOREACH (QAbstractButton *button, m_buttonList) { + Q_FOREACH (QAbstractButton* button, m_buttonList){ m_btnGroup->removeButton(button); } - m_buttonList.clear(); m_iconListScrollAreaWidLayout->removeItem(m_topSpacerItem); m_iconListScrollAreaWidLayout->removeItem(m_bottomSpacerItem); - while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { - QWidget *wid = child->widget(); + QWidget* wid=child->widget(); m_iconListScrollAreaWidLayout->removeWidget(wid); wid->setParent(nullptr); delete wid; delete child; } - initIconListScrollArea(); } @@ -267,27 +251,29 @@ void FullFunctionWidget::updateAppListView() */ void FullFunctionWidget::resizeScrollAreaControls() { - int row = 0; - - while (row < m_scrollAreaWidLayout->count() / 2) { + int row=0; + while(rowcount()/2) + { //应用界面 - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1); - QWidget *wid = widItem->widget(); - FullListView *listview = qobject_cast(wid); + QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1); + QWidget* wid=widItem->widget(); + FullListView* listview=qobject_cast(wid); listview->adjustSize(); - int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; - int rowcount = 0; + int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; + int rowcount=0; + if(listview->model()->rowCount()%dividend>0) + { + rowcount=listview->model()->rowCount()/dividend+1; + } + else + { + rowcount=listview->model()->rowCount()/dividend; - if (listview->model()->rowCount() % dividend > 0) { - rowcount = listview->model()->rowCount() / dividend + 1; - } else { - rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); + listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); row++; } - m_scrollArea->widget()->adjustSize(); } @@ -296,25 +282,29 @@ void FullFunctionWidget::resizeScrollAreaControls() */ void FullFunctionWidget::initIconListWidget() { - m_iconListScrollArea = new ClassifyBtnScrollArea(m_iconListWid); + m_iconListScrollArea=new ClassifyBtnScrollArea(m_iconListWid); // m_iconListScrollArea->resize(Style::LeftBtnWidth, // m_iconListWid->height()); - m_iconListScrollAreaWid = new ClassifyBtnScrollAreaWid; + m_iconListScrollAreaWid=new ClassifyBtnScrollAreaWid; m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, m_iconListWid->height()); - m_iconListScrollAreaWidLayout = new QVBoxLayout; - m_iconListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_iconListScrollAreaWidLayout=new QVBoxLayout; + m_iconListScrollAreaWidLayout->setContentsMargins(0,0,0,0); m_iconListScrollAreaWidLayout->setSpacing(Style::LeftSpaceBetweenItem); m_iconListScrollAreaWid->setLayout(m_iconListScrollAreaWidLayout); m_iconListScrollArea->setWidget(m_iconListScrollAreaWid); - m_topSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_bottomSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_btnGroup = new QButtonGroup(m_iconListScrollAreaWid); + + m_topSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); + m_bottomSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); + + m_btnGroup=new QButtonGroup(m_iconListScrollAreaWid); m_animation = new QPropertyAnimation(m_iconListScrollArea, "geometry"); + m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullFunctionWidget::animationFinishSlot); connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullFunctionWidget::animationValueChangedSlot); + initIconListScrollArea(); } @@ -324,51 +314,48 @@ void FullFunctionWidget::initIconListWidget() void FullFunctionWidget::initIconListScrollArea() { m_iconListScrollAreaWidLayout->addItem(m_topSpacerItem); - - for (int i = 0; i < m_classificationList.size(); i++) { - FunctionClassifyButton *iconbtn = new FunctionClassifyButton( - Style::LeftBtnWidth, - Style::LeftBtnHeight, - Style::LeftIconSize, - m_classificationList.at(i), - true, - true); + for(int i=0;isetChecked(false); m_buttonList.append(iconbtn); m_iconListScrollAreaWidLayout->addWidget(iconbtn); } - m_iconListScrollAreaWidLayout->addItem(m_bottomSpacerItem); - int id = 0; - Q_FOREACH (QAbstractButton *btn, m_buttonList) { - m_btnGroup->addButton(btn, id++); + int id=0; + Q_FOREACH (QAbstractButton* btn, m_buttonList) { + m_btnGroup->addButton(btn,id++); } - - connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullFunctionWidget::btnGroupClickedSlot); - + connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&FullFunctionWidget::btnGroupClickedSlot); // m_iconListScrollArea->widget()->adjustSize(); - if (m_btnGroup->button(0) != nullptr) { + if(m_btnGroup->button(0)!=nullptr) m_btnGroup->button(0)->click(); - } } void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn) { - disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullFunctionWidget::valueChangedSlot); - - Q_FOREACH (QAbstractButton *button, m_buttonList) { - if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) { - m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition(); - m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y(); + disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, + this,&FullFunctionWidget::valueChangedSlot); + Q_FOREACH (QAbstractButton* button, m_buttonList) { + if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) + { + m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition(); + m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y(); m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_scrollAnimation->stop(); m_scrollAnimation->setStartValue(m_beginPos); m_scrollAnimation->setEndValue(m_endPos); m_scrollAnimation->start(); button->setChecked(true); - } else { + } + else{ button->setChecked(false); } } @@ -376,62 +363,58 @@ void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn) void FullFunctionWidget::animationFinishSlot() { - if (m_scrollArea->verticalScrollBar()->value() == m_endPos || - m_scrollArea->verticalScrollBar()->value() == m_scrollArea->verticalScrollBar()->maximum()) { + if(m_scrollArea->verticalScrollBar()->value()==m_endPos || + m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) + { m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullFunctionWidget::valueChangedSlot); + connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, + this,&FullFunctionWidget::valueChangedSlot); } } void FullFunctionWidget::animationValueChangedSlot(const QVariant &value) { Q_UNUSED(value); - - if (sender() != m_scrollAnimation) { + if (sender() != m_scrollAnimation) return; - } QPropertyAnimation *ani = qobject_cast(sender()); - if (m_endPos != ani->endValue()) { + if (m_endPos != ani->endValue()) ani->setEndValue(m_endPos); - } } void FullFunctionWidget::valueChangedSlot(int value) { - int index = 0; - - while (index <= m_classificationList.count() - 1) { - int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y(); - int max = 0; - - if (index == m_classificationList.count() - 1) { - max = m_scrollAreaWid->height(); - } else { - max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y(); - } - - if (value >= min && value < max) { - Q_FOREACH (QAbstractButton *button, m_buttonList) { - FunctionClassifyButton *fcbutton = qobject_cast(button); - - if (index == m_buttonList.indexOf(button)) { + int index=0; + while(index<=m_classificationList.count()-1) + { + int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y(); + int max=0; + if(index==m_classificationList.count()-1) + max=m_scrollAreaWid->height(); + else + max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y(); + if(value>=min && value(button); + if(index==m_buttonList.indexOf(button)) + { fcbutton->setChecked(true); - } else { + } + else{ fcbutton->setChecked(false); } } - break; - } else { - index++; } + else + index++; } } -QAbstractButton *FullFunctionWidget::getCurLetterButton(int value) +QAbstractButton* FullFunctionWidget::getCurLetterButton(int value) { return m_buttonList.at(value); } @@ -440,12 +423,12 @@ QAbstractButton *FullFunctionWidget::getCurLetterButton(int value) void FullFunctionWidget::enterAnimation() { m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0, 0, - 0, m_iconListWid->height())); + m_animation->setStartValue(QRect(0,0, + 0,m_iconListWid->height())); m_animation->setEndValue(QRect(Style::LeftMargin, - 0, - Style::LeftBtnWidth, - m_iconListWid->height())); + 0, + Style::LeftBtnWidth, + m_iconListWid->height())); m_animation->setEasingCurve(QEasingCurve::InQuart); m_animation->start(); m_iconListScrollArea->show(); @@ -459,15 +442,17 @@ void FullFunctionWidget::setFunctionBtnGeometry() Style::LeftBtnWidth, m_iconListWid->height())); m_iconListScrollArea->show(); + } void FullFunctionWidget::repaintWidget() { this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); - m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_iconListWid->setFixedSize(Style::LeftWidWidth, this->height()); + m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); + m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); + m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height()); m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, m_iconListWid->height()); updateAppListView(); @@ -475,22 +460,18 @@ void FullFunctionWidget::repaintWidget() void FullFunctionWidget::widgetMakeZero() { - if (m_btnGroup->button(0) != nullptr) { + if(m_btnGroup->button(0)!=nullptr) m_btnGroup->button(0)->click(); - } - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); } void FullFunctionWidget::moveScrollBar(int type) { - int height = Style::primaryScreenHeight; - - if (type == 0) { - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() - height * 100 / 1080); - } else { - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() + height * 100 / 1080); - } + int height=Style::primaryScreenHeight; + if(type==0) + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080); + else + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080); } void FullFunctionWidget::onSetSlider(int value) @@ -499,27 +480,29 @@ void FullFunctionWidget::onSetSlider(int value) // { // flag = false; // time->start(100); - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); // qDebug() << "FullFunctionWidget::onSetSlider" << curvalue; // } } bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) { - if (event->type() == QEvent::KeyPress) { - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); - QWidget *wid = widItem->widget(); - FullListView *m_listview = qobject_cast(wid); - QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget *widTop = widItemTop->widget(); - FullListView *m_listviewTop = qobject_cast(widTop); + if( event->type() == QEvent::KeyPress ) + { + QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); + QWidget* wid = widItem->widget(); + FullListView* m_listview = qobject_cast(wid); + + QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget* widTop = widItemTop->widget(); + FullListView* m_listviewTop = qobject_cast(widTop); + QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Tab) { - Q_EMIT setFocusToSideWin(); + if( ke->key() == Qt::Key_Tab ) + { + Q_EMIT setFocusToSideWin(); } - // if(ke->key() == Qt::Key_Up) // { // QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); @@ -548,49 +531,51 @@ bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) // } // } - if (ke->key() == Qt::Key_Up) { - if (!m_listviewTop->hasFocus()) { - QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); + if(ke->key() == Qt::Key_Up) + { + if(!m_listviewTop->hasFocus()) + { + QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size()); btnGroupClickedSlot(buttonTop); this->m_scrollArea->setFocusToPreChild(); - } else { - m_listview->setFocus(); - QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); - btnGroupClickedSlot(button); - m_index = m_buttonList.size() - 1; } - + else + { + m_listview->setFocus(); + QAbstractButton* button = getCurLetterButton(m_buttonList.size() - 1); + btnGroupClickedSlot(button); + m_index = m_buttonList.size() - 1; + } Q_EMIT selectFirstItem(); return true; } - - if (ke->key() == Qt::Key_Down) { - if (!m_listview->hasFocus()) { - QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); + if(ke->key() == Qt::Key_Down) + { + if(!m_listview->hasFocus()) + { + QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size()); btnGroupClickedSlot(button); this->m_scrollArea->setFocusToNextChild(); - } else { + } + else + { m_listviewTop->setFocus(); - QAbstractButton *buttonTop = getCurLetterButton(0); + QAbstractButton* buttonTop = getCurLetterButton(0); btnGroupClickedSlot(buttonTop); - m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0, 0)); + m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0,0)); m_index = 0; } - Q_EMIT selectFirstItem(); return true; } } - - return QWidget::eventFilter(watched, event); + return QWidget::eventFilter(watched,event); } void FullFunctionWidget::functionButtonClick() { - if (m_btnGroup->button(0) != nullptr) { + if(m_btnGroup->button(0)!=nullptr) m_btnGroup->button(0)->click(); - } - m_index = 0; } diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp index a70ec66..69dce44 100644 --- a/src/FunctionWidget/functionwidget.cpp +++ b/src/FunctionWidget/functionwidget.cpp @@ -28,10 +28,7 @@ FunctionWidget::FunctionWidget(QWidget *parent) : FunctionWidget::~FunctionWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } /** @@ -40,21 +37,24 @@ FunctionWidget::~FunctionWidget() void FunctionWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); - m_ukuiMenuInterface = new UkuiMenuInterface; + this->setAttribute(Qt::WA_StyledBackground,true); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + + m_ukuiMenuInterface=new UkuiMenuInterface; initAppListWidget(); - m_functionBtnWid = new FunctionButtonWidget(this); + + m_functionBtnWid=new FunctionButtonWidget(this); m_functionBtnWid->hide(); - connect(this, &FunctionWidget::sendClassificationbtnList, m_functionBtnWid, &FunctionButtonWidget::recvClassificationBtnList); - connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal, this, &FunctionWidget::recvFunctionBtnSignal); - m_enterAnimation = new QPropertyAnimation; + connect(this,&FunctionWidget::sendClassificationbtnList,m_functionBtnWid,&FunctionButtonWidget::recvClassificationBtnList); + connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal,this,&FunctionWidget::recvFunctionBtnSignal); + + m_enterAnimation=new QPropertyAnimation; m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation = new QPropertyAnimation; + m_leaveAnimation=new QPropertyAnimation; m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot); - connect(m_enterAnimation, &QPropertyAnimation::finished, this, &FunctionWidget::animationFinishedSLot); + connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot); + connect(m_enterAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot); } /** @@ -62,13 +62,12 @@ void FunctionWidget::initUi() */ void FunctionWidget::initAppListWidget() { - m_appListView = new ListView(this, this->width() - 6, this->height() - 6, 2); - m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView=new ListView(this,this->width()-6,this->height()-6,2); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); fillAppListView(0); - connect(m_appListView, &ListView::sendItemClickedSignal, this, &FunctionWidget::recvItemClickedSlot); - connect(m_appListView, &ListView::sendHideMainWindowSignal, this, &FunctionWidget::sendHideMainWindowSignal); - connect(m_appListView, &ListView::sendMainWinActiveSignal, this, &FunctionWidget::sendMainWinActiveSignal); + connect(m_appListView,&ListView::sendItemClickedSignal,this,&FunctionWidget::recvItemClickedSlot); + connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&FunctionWidget::sendHideMainWindowSignal); } @@ -77,118 +76,105 @@ void FunctionWidget::initAppListWidget() */ void FunctionWidget::fillAppListView(int type) { - row = 0; + row=0; m_data.clear(); m_classificationList.clear(); m_classificationBtnRowList.clear(); - QVector vector = UkuiMenuInterface::functionalVector; - QStringList androidlist = vector.at(0); - - if (!androidlist.isEmpty()) { + QVector vector=UkuiMenuInterface::functionalVector; + QStringList androidlist=vector.at(0); + if(!androidlist.isEmpty()) + { insertClassificationBtn(tr("Mobile")); insertAppList(androidlist); } - - QStringList netlist = vector.at(1); - - if (!netlist.isEmpty()) { + QStringList netlist=vector.at(1); + if(!netlist.isEmpty()) + { insertClassificationBtn(tr("Internet")); insertAppList(netlist); } - - QStringList sociallist = vector.at(2); - - if (!sociallist.isEmpty()) { + QStringList sociallist=vector.at(2); + if(!sociallist.isEmpty()) + { insertClassificationBtn(tr("Social")); insertAppList(sociallist); } - - QStringList avlist = vector.at(3); - - if (!avlist.isEmpty()) { + QStringList avlist=vector.at(3); + if(!avlist.isEmpty()) + { insertClassificationBtn(tr("Video")); insertAppList(avlist); } - - QStringList developlist = vector.at(4); - - if (!developlist.isEmpty()) { + QStringList developlist=vector.at(4); + if(!developlist.isEmpty()) + { insertClassificationBtn(tr("Development")); insertAppList(developlist); } - - QStringList graphicslist = vector.at(5); - - if (!graphicslist.isEmpty()) { + QStringList graphicslist=vector.at(5); + if(!graphicslist.isEmpty()) + { insertClassificationBtn(tr("Image")); insertAppList(graphicslist); } - - QStringList gamelist = vector.at(6); - - if (!gamelist.isEmpty()) { + QStringList gamelist=vector.at(6); + if(!gamelist.isEmpty()) + { insertClassificationBtn(tr("Game")); insertAppList(gamelist); } - - QStringList officelist = vector.at(7); - - if (!officelist.isEmpty()) { + QStringList officelist=vector.at(7); + if(!officelist.isEmpty()) + { insertClassificationBtn(tr("Office")); insertAppList(officelist); } - - QStringList educationlist = vector.at(8); - - if (!educationlist.isEmpty()) { + QStringList educationlist=vector.at(8); + if(!educationlist.isEmpty()) + { insertClassificationBtn(tr("Education")); insertAppList(educationlist); } - QStringList systemadminlist = vector.at(9); - - if (!systemadminlist.isEmpty()) { + QStringList systemadminlist=vector.at(9); + if(!systemadminlist.isEmpty()) + { insertClassificationBtn(tr("System")); insertAppList(systemadminlist); } - - QStringList otherlist = vector.at(10); - - if (!otherlist.isEmpty()) { + QStringList otherlist=vector.at(10); + if(!otherlist.isEmpty()) + { insertClassificationBtn(tr("Others")); insertAppList(otherlist); } - if (type == 0) { + if(type==0) m_appListView->addData(m_data); - } else { + else m_appListView->updateData(m_data); - } } void FunctionWidget::insertClassificationBtn(QString btnname) { m_classificationList.append(btnname); - m_data.append(QStringList() << btnname << "0"); + m_data.append(QStringList()<setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_leaveAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); // m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); - m_leaveAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); - m_enterAnimation->setStartValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); - m_enterAnimation->setEndValue(QRect((this->width() - Style::LeftBtnWidth * 2 - 5) / 2, - (this->height() - Style::LeftBtnHeight * 6 - 25) / 2, - Style::LeftBtnWidth * 2 + 5, - Style::LeftBtnHeight * 6 + 25)); + m_leaveAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); + m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); + m_enterAnimation->setEndValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2, + (this->height()-Style::LeftBtnHeight*6-25)/2, + Style::LeftBtnWidth*2+5, + Style::LeftBtnHeight*6+25)); m_leaveAnimation->setDuration(10); m_enterAnimation->setDuration(100); + //加载FunctionButtonWidget界面 Q_EMIT sendClassificationbtnList(); m_leaveAnimation->setTargetObject(m_appListView); m_enterAnimation->setTargetObject(m_functionBtnWid); m_leaveAnimation->start(); - m_widgetState = 1; + m_widgetState=1; } /** @@ -237,42 +224,44 @@ void FunctionWidget::appClassificationBtnClickedSlot() void FunctionWidget::recvFunctionBtnSignal(QString btnname) { //此处需实现将功能为btnname的应用列表移动到applistWid界面最顶端 - int index = m_classificationList.indexOf(btnname); - - if (index != -1) { - int row = m_classificationBtnRowList.at(index).toInt(); + int index=m_classificationList.indexOf(btnname); + if(index!=-1) + { + int row=m_classificationBtnRowList.at(index).toInt(); m_appListView->verticalScrollBar()->setValue(row); } - m_leaveAnimation->setStartValue(QRect((this->width() - Style::LeftBtnWidth * 2 - 5) / 2, - (this->height() - Style::LeftBtnHeight * 6 - 25) / 2, - Style::LeftBtnWidth * 2 + 5, - Style::LeftBtnHeight * 6 + 25)); - m_leaveAnimation->setEndValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); + m_leaveAnimation->setStartValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2, + (this->height()-Style::LeftBtnHeight*6-25)/2, + Style::LeftBtnWidth*2+5, + Style::LeftBtnHeight*6+25)); + m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); // m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); - m_enterAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_enterAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); + m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); m_leaveAnimation->setDuration(100); m_enterAnimation->setDuration(10); + m_leaveAnimation->setTargetObject(m_functionBtnWid); m_enterAnimation->setTargetObject(m_appListView); m_leaveAnimation->start(); - m_widgetState = 0; + m_widgetState=0; } void FunctionWidget::animationFinishedSLot() { - if (m_widgetState == 1) { + if(m_widgetState==1) + { m_appListView->hide(); m_enterAnimation->start(); - m_widgetState = -1; + m_widgetState=-1; m_functionBtnWid->show(); } - - if (m_widgetState == 0) { + if(m_widgetState==0) + { m_functionBtnWid->hide(); m_enterAnimation->start(); - m_widgetState = -1; + m_widgetState=-1; m_appListView->show(); } } @@ -280,24 +269,23 @@ void FunctionWidget::animationFinishedSLot() void FunctionWidget::widgetMakeZero() { m_functionBtnWid->hide(); - m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); m_appListView->verticalScrollBar()->setValue(0); } void FunctionWidget::moveScrollBar(int type) { - if (type == 0) { - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() - 100); - } else { - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() + 100); - } + if(type==0) + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100); + else + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100); } void FunctionWidget::repaintWidget() { - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); } diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h index beffaa3..6ecc01c 100644 --- a/src/FunctionWidget/functionwidget.h +++ b/src/FunctionWidget/functionwidget.h @@ -132,8 +132,6 @@ Q_SIGNALS: * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); - - void sendMainWinActiveSignal(bool flag); }; #endif // FUNCTIONWIDGET_H diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp index ae5e94d..f435a63 100644 --- a/src/Interface/ukuimenuinterface.cpp +++ b/src/Interface/ukuimenuinterface.cpp @@ -144,7 +144,7 @@ void UkuiMenuInterface::recursiveSearchFile(const QString& _filePath) } while(i < list.size()); } -//获取系统desktop文件路径 +//获取系统deskyop文件路径 QStringList UkuiMenuInterface::getDesktopFilePath() { filePathList.clear(); @@ -176,6 +176,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath() { getAndroidApp(); recursiveSearchFile("/usr/share/applications/"); + recursiveSearchFile(QDir::homePath()+"/.local/share/applications/"); recursiveSearchFile("/var/lib/snapd/desktop/applications/"); recursiveSearchFile("/var/lib/flatpak/exports/share/applications/"); QJsonArray blArray=obj.value("blacklist").toArray(); @@ -191,6 +192,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath() { getAndroidApp(); recursiveSearchFile("/usr/share/applications/"); + recursiveSearchFile(QDir::homePath()+"/.local/share/applications/"); recursiveSearchFile("/var/lib/snapd/desktop/applications/"); recursiveSearchFile("/var/lib/flatpak/exports/share/applications/"); } @@ -203,6 +205,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath() { getAndroidApp(); recursiveSearchFile("/usr/share/applications/"); + recursiveSearchFile(QDir::homePath()+"/.local/share/applications/"); recursiveSearchFile("/var/lib/snapd/desktop/applications/"); recursiveSearchFile("/var/lib/flatpak/exports/share/applications/"); } @@ -247,21 +250,6 @@ QStringList UkuiMenuInterface::getDesktopFilePath() filePathList.removeAll("/usr/share/applications/wps-office-uninstall.desktop"); filePathList.removeAll("/usr/share/applications/wps-office-misc.desktop"); - QStringList desktopList; - for(int i = 0; i < filePathList.count(); ++i) - { - QString filepath = filePathList.at(i); - int list_index = filepath.lastIndexOf('/'); - QString desktopName = filepath.right(filepath.length() - list_index - 1); - if(desktopList.contains(desktopName)){ - filePathList.removeAll(filepath); - i--; - } - else - { - desktopList.append(desktopName); - } - } return filePathList; } @@ -289,7 +277,6 @@ QVector UkuiMenuInterface::createAppInfoVector() QStringList appInfoList; QString desktopfp=desktopfpList.at(i); QString name=getAppName(desktopfpList.at(i)); - if(!name.isEmpty()) { QString englishName=getAppEnglishName(desktopfpList.at(i)); @@ -847,21 +834,21 @@ void UkuiMenuInterface::getAndroidApp() QByteArray fpbyte=filePathStr.toLocal8Bit(); char* filepath=fpbyte.data(); g_key_file_load_from_file(keyfile,filepath,flags,error); -// char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); -// if(ret_1!=nullptr) -// { -// QString str=QString::fromLocal8Bit(ret_1); -// if(!str.contains("Android")) -// { -// i++; -// continue; -// } -// else -// { + char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); + if(ret_1!=nullptr) + { + QString str=QString::fromLocal8Bit(ret_1); + if(!str.contains("Android")) + { + i++; + continue; + } + else + { filePathList.append(filePathStr); androidDesktopfnList.append(fileInfo.fileName()); -// } -// } + } + } i++; }while(i < list.size()); diff --git a/src/LetterWidget/fullletterwidget.cpp b/src/LetterWidget/fullletterwidget.cpp index d0aa93a..0fedf33 100644 --- a/src/LetterWidget/fullletterwidget.cpp +++ b/src/LetterWidget/fullletterwidget.cpp @@ -28,10 +28,9 @@ FullLetterWidget::FullLetterWidget(QWidget *parent) : FullLetterWidget::~FullLetterWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; + delete m_letterListBottomSpacer; + delete m_appListBottomSpacer; } /** @@ -40,28 +39,33 @@ FullLetterWidget::~FullLetterWidget() void FullLetterWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setAttribute(Qt::WA_TranslucentBackground); - m_applistWid = new QWidget(this); - m_letterListWid = new QWidget(this); + + m_applistWid=new QWidget(this); + m_letterListWid=new QWidget(this); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); - m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height()); - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->setContentsMargins(0, 0, 0, 0); + m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); + m_letterListWid->setFixedSize(Style::LeftWidWidth,this->height()); + + QHBoxLayout* mainLayout=new QHBoxLayout; + mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); mainLayout->addWidget(m_letterListWid); mainLayout->addWidget(m_applistWid); this->setLayout(mainLayout); - m_ukuiMenuInterface = new UkuiMenuInterface; + m_ukuiMenuInterface=new UkuiMenuInterface; + initAppListWidget(); initLetterListWidget(); + flag = true; //翻页灵敏度时间调节 time = new QTimer(this); - connect(time, &QTimer::timeout, [ = ]() { - if (flag == false) { + connect(time,&QTimer::timeout,[=](){ + if(flag == false) + { flag = true; time->stop(); } @@ -73,22 +77,24 @@ void FullLetterWidget::initUi() */ void FullLetterWidget::initAppListWidget() { - QHBoxLayout *layout = new QHBoxLayout(m_applistWid); - layout->setContentsMargins(0, 0, 0, 0); + QHBoxLayout* layout=new QHBoxLayout(m_applistWid); + layout->setContentsMargins(0,0,0,0); m_applistWid->setLayout(layout); - m_scrollArea = new ScrollArea; - m_scrollAreaWid = new ScrollAreaWid; + + m_scrollArea=new ScrollArea; + m_scrollAreaWid=new ScrollAreaWid; m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout = new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout=new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); m_scrollAreaWidLayout->setSpacing(10); m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); layout->addWidget(m_scrollArea); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullLetterWidget::valueChangedSlot); - m_appListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, + this,&FullLetterWidget::valueChangedSlot); + m_appListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); + fillAppList(); } @@ -105,52 +111,47 @@ void FullLetterWidget::setFocusToThis() void FullLetterWidget::fillAppList() { m_letterList.clear(); - QVector vector = UkuiMenuInterface::alphabeticVector; - - for (int i = 0; i < vector.size(); i++) { - QStringList appList = vector.at(i); - - if (!appList.isEmpty()) { + QVector vector=UkuiMenuInterface::alphabeticVector; + for(int i=0;i(i + 65))); - } else if (i == 26) { - letterstr = "&"; - } else { - letterstr = "#"; - } - + if(i<26) + letterstr=QString(QChar(static_cast(i+65))); + else if(i==26) + letterstr="&"; + else + letterstr="#"; m_letterList.append(letterstr);//存储分类字符 //插入字母分类按钮 - SplitBarFrame *letterbtn = new SplitBarFrame(this, letterstr, m_scrollArea->width() - 16, 30, 1); + SplitBarFrame* letterbtn=new SplitBarFrame(this,letterstr,m_scrollArea->width()-12,30,1); m_scrollAreaWidLayout->addWidget(letterbtn); + //插入应用列表 - FullListView *listview = new FullListView(this, 1); - connect(listview, &FullListView::sendSetslidebar, this, &FullLetterWidget::onSetSlider); + FullListView* listview=new FullListView(this,1); + connect(listview, &FullListView::sendSetslidebar,this,&FullLetterWidget::onSetSlider); connect(this, &FullLetterWidget::selectFirstItem, listview, &FullListView::selectFirstItem); listview->installEventFilter(this); //修复异常黑框问题 - connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { - QEventLoop loop; - QTimer::singleShot(1, &loop, SLOT(quit())); - loop.exec(); + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ listview->repaint(listview->rect()); }); + m_scrollAreaWidLayout->addWidget(listview); m_data.clear(); - - for (int i = 0; i < appList.count(); i++) { + for(int i=0;iaddData(m_data); - connect(listview, &FullListView::sendItemClickedSignal, this, &FullLetterWidget::execApplication); - connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullLetterWidget::sendHideMainWindowSignal); + + connect(listview,&FullListView::sendItemClickedSignal,this,&FullLetterWidget::execApplication); + connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullLetterWidget::sendHideMainWindowSignal); } } - m_scrollAreaWidLayout->addItem(m_appListBottomSpacer); + resizeScrollAreaControls(); } @@ -171,27 +172,23 @@ void FullLetterWidget::updateAppListView() //刷新应用列表界面 QLayoutItem *child; m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer); - - while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { - QWidget *wid = child->widget(); - m_scrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - - fillAppList(); + while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { + QWidget* wid=child->widget(); + m_scrollAreaWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + fillAppList(); //刷新字母列表界面 - Q_FOREACH (QAbstractButton *button, m_buttonList) { + Q_FOREACH (QAbstractButton* button, m_buttonList) { m_btnGroup->removeButton(button); } - m_buttonList.clear(); m_letterListScrollAreaWidLayout->removeItem(m_letterListBottomSpacer); - while ((child = m_letterListScrollAreaWidLayout->takeAt(0)) != 0) { - QWidget *wid = child->widget(); + QWidget* wid=child->widget(); m_letterListScrollAreaWidLayout->removeWidget(wid); wid->setParent(nullptr); delete wid; @@ -207,27 +204,30 @@ void FullLetterWidget::updateAppListView() */ void FullLetterWidget::resizeScrollAreaControls() { - int row = 0; - - while (row < m_scrollAreaWidLayout->count() / 2) { + int row=0; + while(rowcount()/2) + { //应用界面 - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1); - QWidget *wid = widItem->widget(); - FullListView *listview = qobject_cast(wid); + QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1); + QWidget* wid=widItem->widget(); + FullListView* listview=qobject_cast(wid); listview->adjustSize(); - int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; - int rowcount = 0; + int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; + + int rowcount=0; + if(listview->model()->rowCount()%dividend>0) + { + rowcount=listview->model()->rowCount()/dividend+1; + } + else + { + rowcount=listview->model()->rowCount()/dividend; - if (listview->model()->rowCount() % dividend > 0) { - rowcount = listview->model()->rowCount() / dividend + 1; - } else { - rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); + listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); row++; } - m_scrollArea->widget()->adjustSize(); } @@ -236,21 +236,24 @@ void FullLetterWidget::resizeScrollAreaControls() */ void FullLetterWidget::initLetterListWidget() { - m_letterListScrollArea = new ClassifyBtnScrollArea(m_letterListWid); - m_letterListScrollAreaWid = new ClassifyBtnScrollAreaWid; - m_letterListScrollAreaWidLayout = new QVBoxLayout; - m_letterListScrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_letterListScrollArea=new ClassifyBtnScrollArea(m_letterListWid); + m_letterListScrollAreaWid=new ClassifyBtnScrollAreaWid; + m_letterListScrollAreaWidLayout=new QVBoxLayout; + m_letterListScrollAreaWidLayout->setContentsMargins(0,0,0,0); m_letterListScrollAreaWidLayout->setSpacing(0); m_letterListScrollAreaWid->setLayout(m_letterListScrollAreaWidLayout); m_letterListScrollArea->setWidget(m_letterListScrollAreaWid); m_letterListScrollArea->setWidgetResizable(true); - m_letterListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_btnGroup = new QButtonGroup(m_letterListScrollAreaWid); + + m_letterListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); + m_btnGroup=new QButtonGroup(m_letterListScrollAreaWid); m_animation = new QPropertyAnimation(m_letterListScrollArea, "geometry"); + m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullLetterWidget::animationFinishSlot); connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullLetterWidget::animationValueChangedSlot); + initLetterListScrollArea(); } @@ -259,60 +262,56 @@ void FullLetterWidget::initLetterListWidget() */ void FullLetterWidget::initLetterListScrollArea() { - if (m_letterList.contains("&")) { - m_letterList.replace(m_letterList.indexOf("&"), "&&"); - } - - for (int i = 0; i < m_letterList.size(); i++) { - LetterClassifyButton *letterbtn = new LetterClassifyButton(m_letterListScrollAreaWid, - true, - m_letterList.at(i)); - letterbtn->setFixedSize(Style::LeftLetterBtnHeight, Style::LeftLetterBtnHeight); + if(m_letterList.contains("&")) + m_letterList.replace(m_letterList.indexOf("&"),"&&"); + for(int i=0;isetFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); m_buttonList.append(letterbtn); m_letterListScrollAreaWidLayout->addWidget(letterbtn); - m_letterListScrollAreaWidLayout->setAlignment(letterbtn, Qt::AlignHCenter); - connect(letterbtn, &LetterClassifyButton::buttonClicked, m_btnGroup, static_cast(&QButtonGroup::buttonClicked)); + m_letterListScrollAreaWidLayout->setAlignment(letterbtn,Qt::AlignHCenter); + connect(letterbtn,&LetterClassifyButton::buttonClicked,m_btnGroup, static_cast(&QButtonGroup::buttonClicked)); } - m_letterListScrollAreaWidLayout->addItem(m_letterListBottomSpacer); - int id = 0; - Q_FOREACH (QAbstractButton *btn, m_buttonList) { - m_btnGroup->addButton(btn, id++); + int id=0; + Q_FOREACH (QAbstractButton* btn, m_buttonList) { + m_btnGroup->addButton(btn,id++); } - connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullLetterWidget::btnGroupClickedSlot); + connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&FullLetterWidget::btnGroupClickedSlot); m_letterListScrollArea->widget()->adjustSize(); - - if (m_btnGroup->button(0) != nullptr) { + if(m_btnGroup->button(0)!=nullptr) m_btnGroup->button(0)->click(); - } } void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn) { - disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullLetterWidget::valueChangedSlot); - - Q_FOREACH (QAbstractButton *button, m_buttonList) { - LetterClassifyButton *letterbtn = qobject_cast(button); - - if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) { + disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, + this,&FullLetterWidget::valueChangedSlot); + Q_FOREACH (QAbstractButton* button, m_buttonList) { + LetterClassifyButton* letterbtn=qobject_cast(button); + if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) + { letterbtn->setChecked(true); //此处需实现将被选定的字母包含的应用列表移动到applistWid界面最顶端 - QString letterstr = letterbtn->text(); - int num = m_letterList.indexOf(letterstr); - - if (num != -1) { - m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition(); - m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y(); + QString letterstr=letterbtn->text(); + int num=m_letterList.indexOf(letterstr); + if(num!=-1) + { + m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition(); + m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y(); m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_scrollAnimation->stop(); m_scrollAnimation->setStartValue(m_beginPos); m_scrollAnimation->setEndValue(m_endPos); m_scrollAnimation->start(); } - } else { + } + else{ letterbtn->setChecked(false); } } @@ -320,58 +319,56 @@ void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn) void FullLetterWidget::animationFinishSlot() { - if (m_scrollArea->verticalScrollBar()->value() == m_endPos || - m_scrollArea->verticalScrollBar()->value() == m_scrollArea->verticalScrollBar()->maximum()) { + if(m_scrollArea->verticalScrollBar()->value()==m_endPos || + m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) + { m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, - this, &FullLetterWidget::valueChangedSlot); + connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, + this,&FullLetterWidget::valueChangedSlot); } } void FullLetterWidget::animationValueChangedSlot(const QVariant &value) { Q_UNUSED(value); - - if (sender() != m_scrollAnimation) { + if (sender() != m_scrollAnimation) return; - } QPropertyAnimation *ani = qobject_cast(sender()); - if (m_endPos != ani->endValue()) { + if (m_endPos != ani->endValue()) ani->setEndValue(m_endPos); - } } void FullLetterWidget::valueChangedSlot(int value) { - int index = 0; + int index=0; + while(index<=m_letterList.count()-1) + { + int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y(); + int max=0; + if(index==m_letterList.count()-1) + max=m_scrollAreaWid->height(); + else + max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y(); - while (index <= m_letterList.count() - 1) { - int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y(); - int max = 0; - - if (index == m_letterList.count() - 1) { - max = m_scrollAreaWid->height(); - } else { - max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y(); - } - - if (value >= min && value < max) { - Q_FOREACH (QAbstractButton *button, m_buttonList) { - LetterClassifyButton *letterbtn = qobject_cast(button); - - if (index == m_buttonList.indexOf(button)) { + if(value>=min && value (button); + if(index==m_buttonList.indexOf(button)) + { letterbtn->setChecked(true); - } else { + } + else + { letterbtn->setChecked(false); } } - break; - } else { - index++; } + else + index++; } // //向下滚动 @@ -380,23 +377,26 @@ void FullLetterWidget::valueChangedSlot(int value) // int val=m_letterListScrollArea->verticalScrollBar()->sliderPosition()+m_buttonList.at(index)->height(); // m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); // } + // //向上滚动 // if((m_buttonList.at(index)->pos().y()+m_letterListScrollArea->widget()->pos().y()) <= 0) // { + // int val=m_letterListScrollArea->verticalScrollBar()->value()-m_buttonList.at(index)->height(); // m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); // } + } void FullLetterWidget::enterAnimation() { m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0, (m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2, - 0, (m_letterList.size() + 1)*Style::LeftLetterBtnHeight)); + m_animation->setStartValue(QRect(0,(m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, + 0,(m_letterList.size()+1)*Style::LeftLetterBtnHeight)); m_animation->setEndValue(QRect(Style::LeftMargin, - (m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2, - Style::LeftLetterBtnHeight * 2, - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight)); + (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, + Style::LeftLetterBtnHeight*2, + (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); m_animation->setEasingCurve(QEasingCurve::InQuart); m_animation->start(); m_letterListScrollArea->show(); @@ -405,9 +405,9 @@ void FullLetterWidget::enterAnimation() void FullLetterWidget::setLetterBtnGeometry() { m_letterListScrollArea->setGeometry(QRect(Style::LeftMargin, - (m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2, - Style::LeftLetterBtnHeight * 2, - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight)); + (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, + Style::LeftLetterBtnHeight*2, + (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); m_letterListScrollArea->show(); } @@ -415,37 +415,35 @@ void FullLetterWidget::repaintWidget() { this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth, this->height()); - m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); - m_letterListWid->setFixedSize(Style::LeftWidWidth, this->height()); + m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); + m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); + m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); + m_letterListWid->setFixedSize(Style::LeftWidWidth,this->height()); updateAppListView(); } void FullLetterWidget::widgetMakeZero() { - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QString letterstr = button->text().at(0); - int num = m_letterList.indexOf(letterstr); - - if (num != -1) { + Q_FOREACH (QAbstractButton* button, m_buttonList) { + QString letterstr=button->text().at(0); + int num=m_letterList.indexOf(letterstr); + if(num!=-1) + { m_btnGroup->button(num)->click(); m_letterListScrollArea->verticalScrollBar()->setSliderPosition(0); break; } } - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); } void FullLetterWidget::moveScrollBar(int type) { - int height = Style::primaryScreenHeight; - - if (type == 0) { - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() - height * 100 / 1080); - } else { - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() + height * 100 / 1080); - } + int height=Style::primaryScreenHeight; + if(type==0) + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080); + else + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080); } void FullLetterWidget::onSetSlider(int value) @@ -454,75 +452,79 @@ void FullLetterWidget::onSetSlider(int value) // { // flag = false; // time->start(100); - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); // } } -QAbstractButton *FullLetterWidget::getCurLetterButton(int value) +QAbstractButton* FullLetterWidget::getCurLetterButton(int value) { return m_buttonList.at(value); } bool FullLetterWidget::eventFilter(QObject *watched, QEvent *event) { - if (event->type() == QEvent::KeyPress) { - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); - QWidget *wid = widItem->widget(); - FullListView *m_listview = qobject_cast(wid); - QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget *widTop = widItemTop->widget(); - FullListView *m_listviewTop = qobject_cast(widTop); + if( event->type() == QEvent::KeyPress ) + { + QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); + QWidget* wid = widItem->widget(); + FullListView* m_listview = qobject_cast(wid); + + QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget* widTop = widItemTop->widget(); + FullListView* m_listviewTop = qobject_cast(widTop); + QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Tab) { - // m_letterListScrollAreaWid->setFocus(); - // m_letterListScrollArea->setFocus(); - // return true; - Q_EMIT setFocusToSideWin(); + if( ke->key() == Qt::Key_Tab ) + { + // m_letterListScrollAreaWid->setFocus(); + // m_letterListScrollArea->setFocus(); + // return true; + Q_EMIT setFocusToSideWin(); } - - if (ke->key() == Qt::Key_Up) { - if (!m_listviewTop->hasFocus()) { - QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); + if(ke->key() == Qt::Key_Up) + { + if(!m_listviewTop->hasFocus()) + { + QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size()); btnGroupClickedSlot(buttonTop); this->m_scrollArea->setFocusToPreChild(); - } else { - m_listview->setFocus(); - QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); - btnGroupClickedSlot(button); - m_index = m_buttonList.size() - 1; } - + else + { + m_listview->setFocus(); + QAbstractButton* button = getCurLetterButton(m_buttonList.size() - 1); + btnGroupClickedSlot(button); + m_index = m_buttonList.size() - 1; + } Q_EMIT selectFirstItem(); return true; } - - if (ke->key() == Qt::Key_Down) { - if (!m_listview->hasFocus()) { - QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); + if(ke->key() == Qt::Key_Down) + { + if(!m_listview->hasFocus()) + { + QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size()); btnGroupClickedSlot(button); this->m_scrollArea->setFocusToNextChild(); - } else { + } + else + { m_listviewTop->setFocus(); - QAbstractButton *buttonTop = getCurLetterButton(0); + QAbstractButton* buttonTop = getCurLetterButton(0); btnGroupClickedSlot(buttonTop); m_index = 0; } - Q_EMIT selectFirstItem(); return true; } } - - return QWidget::eventFilter(watched, event); + return QWidget::eventFilter(watched,event); } void FullLetterWidget::letterButtonClick() { - if (m_btnGroup->button(0) != nullptr) { + if(m_btnGroup->button(0)!=nullptr) m_btnGroup->button(0)->click(); - } - m_index = 0; } diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp index f029f1f..22670c0 100644 --- a/src/LetterWidget/letterwidget.cpp +++ b/src/LetterWidget/letterwidget.cpp @@ -38,10 +38,7 @@ LetterWidget::LetterWidget(QWidget *parent) : LetterWidget::~LetterWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } /** @@ -50,21 +47,24 @@ LetterWidget::~LetterWidget() void LetterWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); - m_ukuiMenuInterface = new UkuiMenuInterface; + this->setAttribute(Qt::WA_StyledBackground,true); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + + m_ukuiMenuInterface=new UkuiMenuInterface; initAppListWidget(); - m_letterBtnWid = new LetterButtonWidget(this); + + m_letterBtnWid=new LetterButtonWidget(this); m_letterBtnWid->hide(); - connect(this, &LetterWidget::sendLetterBtnList, m_letterBtnWid, &LetterButtonWidget::recvLetterBtnList); - connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal, this, &LetterWidget::recvLetterBtnSlot); - m_enterAnimation = new QPropertyAnimation; + connect(this,&LetterWidget::sendLetterBtnList,m_letterBtnWid,&LetterButtonWidget::recvLetterBtnList); + connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal,this,&LetterWidget::recvLetterBtnSlot); + + m_enterAnimation=new QPropertyAnimation; m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation = new QPropertyAnimation; + m_leaveAnimation=new QPropertyAnimation; m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &LetterWidget::animationFinishedSLot); - connect(m_enterAnimation, &QPropertyAnimation::finished, this, &LetterWidget::animationFinishedSLot); + connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot); + connect(m_enterAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot); } /** @@ -72,13 +72,12 @@ void LetterWidget::initUi() */ void LetterWidget::initAppListWidget() { - m_appListView = new ListView(this, this->width() - 6, this->height() - 6, 1); - m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView=new ListView(this,this->width()-6,this->height()-6,1); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); fillAppListView(); - connect(m_appListView, &ListView::sendItemClickedSignal, this, &LetterWidget::recvItemClickedSlot); - connect(m_appListView, &ListView::sendHideMainWindowSignal, this, &LetterWidget::sendHideMainWindowSignal); - connect(m_appListView, &ListView::sendMainWinActiveSignal, this, &LetterWidget::sendMainWinActiveSignal); + connect(m_appListView,&ListView::sendItemClickedSignal,this,&LetterWidget::recvItemClickedSlot); + connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&LetterWidget::sendHideMainWindowSignal); } @@ -88,32 +87,27 @@ void LetterWidget::initAppListWidget() void LetterWidget::fillAppListView() { m_data.clear(); - int row = 0; - QVector vector = UkuiMenuInterface::alphabeticVector; - - for (int i = 0; i < vector.size(); i++) { - QStringList appList = vector.at(i); - - if (!appList.isEmpty()) { + int row=0; + QVector vector=UkuiMenuInterface::alphabeticVector; + for(int i=0;i(i + 65))); - } else if (i == 26) { - letterstr = "&"; - } else { - letterstr = "#"; - } - + if(i<26) + letterstr=QString(QChar(static_cast(i+65))); + else if(i==26) + letterstr="&"; + else + letterstr="#"; m_letterList.append(letterstr);//存储分类字符 m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 - m_data.append(QStringList() << letterstr << "0"); + m_data.append(QStringList()< vector = UkuiMenuInterface::alphabeticVector; - - for (int i = 0; i < vector.size(); i++) { - QStringList appList = vector.at(i); - - if (!appList.isEmpty()) { + QVector vector=UkuiMenuInterface::alphabeticVector; + for(int i=0;i(i + 65))); - } else if (i == 26) { - letterstr = "&"; - } else { - letterstr = "#"; - } - + if(i<26) + letterstr=QString(QChar(static_cast(i+65))); + else if(i==26) + letterstr="&"; + else + letterstr="#"; m_letterList.append(letterstr);//存储分类字符 m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 - m_data.append(QStringList() << letterstr << "0"); + m_data.append(QStringList()<updateData(m_data); } @@ -183,11 +170,12 @@ void LetterWidget::updateAppListView() */ void LetterWidget::appClassificationBtnClickedSlot() { - m_leaveAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); - m_leaveAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_leaveAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); + m_leaveAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); // m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setStartValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); - m_enterAnimation->setEndValue(QRect((this->width() - 235) / 2, (this->height() - 366) / 2, 235, 366)); + m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); + m_enterAnimation->setEndValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); + //加载LetterBUttonWidget界面 m_enterAnimation->setDuration(100); m_leaveAnimation->setDuration(10); @@ -195,7 +183,7 @@ void LetterWidget::appClassificationBtnClickedSlot() m_leaveAnimation->setTargetObject(m_appListView); m_enterAnimation->setTargetObject(m_letterBtnWid); m_leaveAnimation->start(); - m_widgetState = 1; + m_widgetState=1; } /** @@ -204,38 +192,40 @@ void LetterWidget::appClassificationBtnClickedSlot() void LetterWidget::recvLetterBtnSlot(QString btnname) { //此处需实现将字母为btnname的应用列表移动到applistWid界面最顶端 - int num = m_letterList.indexOf(QString(QChar(btnname.at(0)))); - - if (num != -1) { - int row = m_letterBtnRowList.at(num).toInt(); + int num=m_letterList.indexOf(QString(QChar(btnname.at(0)))); + if(num!=-1) + { + int row=m_letterBtnRowList.at(num).toInt(); m_appListView->verticalScrollBar()->setValue(row); } - m_leaveAnimation->setStartValue(QRect((this->width() - 235) / 2, (this->height() - 366) / 2, 235, 366)); - m_leaveAnimation->setEndValue(QRect(-40, -40, this->width() + 80, this->height() + 80)); + m_leaveAnimation->setStartValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); + m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); // m_enterAnimation->setStartValue(QRect(16,10,this->width()-20,this->height()-20)); - m_enterAnimation->setStartValue(QRect(6, 0, this->width() - 6, this->height() - 6)); - m_enterAnimation->setEndValue(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_enterAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); + m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); + m_enterAnimation->setDuration(10); m_leaveAnimation->setDuration(100); m_leaveAnimation->setTargetObject(m_letterBtnWid); m_enterAnimation->setTargetObject(m_appListView); m_leaveAnimation->start(); - m_widgetState = 0; + m_widgetState=0; } void LetterWidget::animationFinishedSLot() { - if (m_widgetState == 1) { + if(m_widgetState==1) + { m_enterAnimation->start(); - m_widgetState = -1; + m_widgetState=-1; m_appListView->hide(); m_letterBtnWid->show(); } - - if (m_widgetState == 0) { + if(m_widgetState==0) + { m_enterAnimation->start(); - m_widgetState = -1; + m_widgetState=-1; m_letterBtnWid->hide(); m_appListView->show(); } @@ -244,24 +234,23 @@ void LetterWidget::animationFinishedSLot() void LetterWidget::widgetMakeZero() { m_letterBtnWid->hide(); - m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); m_appListView->verticalScrollBar()->setValue(0); } void LetterWidget::moveScrollBar(int type) { - if (type == 0) { - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() - 100); - } else { - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition() + 100); - } + if(type==0) + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100); + else + m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100); } void LetterWidget::repaintWidget() { - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_appListView->show(); } diff --git a/src/LetterWidget/letterwidget.h b/src/LetterWidget/letterwidget.h index 215dbdd..4fbe4ba 100644 --- a/src/LetterWidget/letterwidget.h +++ b/src/LetterWidget/letterwidget.h @@ -122,7 +122,6 @@ Q_SIGNALS: * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); - void sendMainWinActiveSignal(bool flag); }; #endif // LETTERWIDGET_H diff --git a/src/MainViewWidget/directorychangedthread.cpp b/src/MainViewWidget/directorychangedthread.cpp index 6ff4c21..1e6d156 100644 --- a/src/MainViewWidget/directorychangedthread.cpp +++ b/src/MainViewWidget/directorychangedthread.cpp @@ -23,40 +23,44 @@ DirectoryChangedThread::DirectoryChangedThread() { - m_ukuiMenuInterface = new UkuiMenuInterface; + m_ukuiMenuInterface=new UkuiMenuInterface; } DirectoryChangedThread::~DirectoryChangedThread() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } void DirectoryChangedThread::run() { closeDataBase("DirectoryChangedThread"); openDataBase("DirectoryChangedThread"); - QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath(); - - if (desktopfpList.size() >= UkuiMenuInterface::desktopfpVector.size()) { //有新的应用安装 - for (int i = 0; i < desktopfpList.count(); i++) { - if (!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i))) { + QStringList desktopfpList=m_ukuiMenuInterface->getDesktopFilePath(); + if(desktopfpList.size() >= UkuiMenuInterface::desktopfpVector.size())//有新的应用安装 + { + for(int i=0;icreateAppInfoVector(); - UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT requestUpdateSignal(); } diff --git a/src/MainViewWidget/mainviewwidget.cpp b/src/MainViewWidget/mainviewwidget.cpp index e3ef9a0..64f1b5c 100644 --- a/src/MainViewWidget/mainviewwidget.cpp +++ b/src/MainViewWidget/mainviewwidget.cpp @@ -34,52 +34,58 @@ MainViewWidget::MainViewWidget(QWidget *parent) : MainViewWidget::~MainViewWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; + delete m_fileWatcher; + delete m_directoryChangedThread; + delete m_animation; + delete m_searchAppThread; + } void MainViewWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); + this->setAttribute(Qt::WA_StyledBackground,true); this->setAttribute(Qt::WA_TranslucentBackground); - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->setContentsMargins(0, 0, 0, 0); + QVBoxLayout* mainLayout=new QVBoxLayout; + mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); - m_topWidget = new QWidget; - m_contentWid = new QWidget; + m_topWidget=new QWidget; + m_contentWid=new QWidget; + mainLayout->addWidget(m_topWidget); mainLayout->addWidget(m_contentWid); this->setLayout(mainLayout); + this->setFocusPolicy(Qt::NoFocus); - m_commonUseWid = new CommonUseWidget(m_contentWid); - m_fullCommonUseWid = new FullCommonUseWidget(m_contentWid); - m_letterWid = new LetterWidget(m_contentWid); - m_functionWid = new FunctionWidget(m_contentWid); - m_fullLetterWid = new FullLetterWidget(m_contentWid); - m_fullFunctionWid = new FullFunctionWidget(m_contentWid); - m_fullSearchResultWid = new FullSearchResultWidget(m_contentWid); - m_searchResultWid = new SearchResultWidget(m_contentWid); + + m_commonUseWid=new CommonUseWidget(m_contentWid); + m_fullCommonUseWid=new FullCommonUseWidget(m_contentWid); + m_letterWid=new LetterWidget(m_contentWid); + m_functionWid=new FunctionWidget(m_contentWid); + m_fullLetterWid=new FullLetterWidget(m_contentWid); + m_fullFunctionWid=new FullFunctionWidget(m_contentWid); + m_fullSearchResultWid=new FullSearchResultWidget(m_contentWid); + m_searchResultWid=new SearchResultWidget(m_contentWid); hideWidget(); - m_ukuiMenuInterface = new UkuiMenuInterface; + + m_ukuiMenuInterface=new UkuiMenuInterface; + //监控.desktop文件目录 - m_fileWatcher = new QFileSystemWatcher(this); - m_fileWatcher->addPaths(QStringList() << QString("/usr/share/applications") - << QString(QDir::homePath() + "/.local/share/applications/") - << QString("/var/lib/snapd/desktop/applications/") - << QString("/var/lib/flatpak/exports/share/applications/")); - connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &MainViewWidget::directoryChangedSlot); - m_directoryChangedThread = new DirectoryChangedThread; - m_directoryChangedThread->setParent(this); - connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &MainViewWidget::requestUpdateSlot); - connect(this, &MainViewWidget::directoryChangedSignal, m_letterWid, &LetterWidget::updateAppListView); - connect(this, &MainViewWidget::directoryChangedSignal, m_fullLetterWid, &FullLetterWidget::updateAppListView); - connect(this, &MainViewWidget::directoryChangedSignal, m_functionWid, &FunctionWidget::updateAppListView); - connect(this, &MainViewWidget::directoryChangedSignal, m_fullFunctionWid, &FullFunctionWidget::updateAppListView); - connect(this, &MainViewWidget::directoryChangedSignal, m_commonUseWid, &CommonUseWidget::updateListViewSlot); - connect(this, &MainViewWidget::directoryChangedSignal, m_fullCommonUseWid, &FullCommonUseWidget::updateListViewSlot); + m_fileWatcher=new QFileSystemWatcher; + m_fileWatcher->addPaths(QStringList()<setFixedSize(Style::defaultMainViewWidWidth, Style::minh); - m_topWidget->setFixedSize(this->width(), Style::defaultTopWidHeight); - m_topLayout->setContentsMargins(0, 0, 0, 0); - m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter); - m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth, Style::defaultQueryLineEditHeight); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); + m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight); + m_topLayout->setContentsMargins(0,0,0,0); + m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); + m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, - m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, + m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); m_queryWid->show(); //内容区 - m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - m_commonUseWid->setGeometry(0, 0, Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); + m_commonUseWid->setGeometry(0,0,Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); m_commonUseWid->show(); - m_widgetState = 1; - m_saveCurrentWidState = 1; - //监控应用进程开启 - connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [ = ](WId id) { - ConvertDesktopToWinId reply; - QString desktopfp = reply.tranIdToDesktop(id); + m_widgetState=1; + m_saveCurrentWidState=1; - if (!desktopfp.isEmpty()) { - ViewOpenedSlot(desktopfp); - } + //监控应用进程开启 + connect(KWindowSystem::self(),&KWindowSystem::windowAdded,[=](WId id) + { + KWindowInfo info(id,NET::WMPid); + int pid=info.pid(); + QString desktopfp=getEnvOverriddenDesktopFile(pid); + if(!desktopfp.isEmpty()) + ViewOpenedSlot(desktopfp); + else + { + //获取软件名(2种方式) + //法1 + QStringList nameList; + KWindowInfo info(id,NET::WMName); + nameList.append(info.name()); + //法2 + QString path=QString("/proc/%1/status").arg(pid); + QFile file(path); + if(file.open(QIODevice::ReadOnly)) + { + char buf[1024]; + qint64 len=file.readLine(buf,sizeof(buf)); + if(len!=-1) + { + QString name=QString::fromLocal8Bit(buf).remove("Name:").remove("\t").remove("\n"); + nameList.append(name); + } + } + + QVector appInfoVector=UkuiMenuInterface::appInfoVector; + Q_FOREACH(QStringList list , appInfoVector) + { + if(list.at(1).contains(nameList.at(0),Qt::CaseInsensitive) || + list.at(2).contains(nameList.at(0),Qt::CaseInsensitive) || + list.at(5).contains(nameList.at(0),Qt::CaseInsensitive) || + nameList.at(0).contains(list.at(1),Qt::CaseInsensitive) || + nameList.at(0).contains(list.at(2),Qt::CaseInsensitive)) + { + ViewOpenedSlot(list.at(0)); + break; + } + else if(nameList.size()==2 && + ( + list.at(1).contains(nameList.at(1),Qt::CaseInsensitive) || + list.at(2).contains(nameList.at(1),Qt::CaseInsensitive) || + list.at(5).contains(nameList.at(1),Qt::CaseInsensitive) || + nameList.at(0).contains(list.at(1),Qt::CaseInsensitive) || + nameList.at(0).contains(list.at(2),Qt::CaseInsensitive)) + ) + { + ViewOpenedSlot(list.at(0)); + break; + } + } + } }); //监控图标主题 - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - m_gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); - connect(m_gsetting, &QGSettings::changed, this, &MainViewWidget::iconThemeChangeSlot); + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + m_gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(m_gsetting,&QGSettings::changed,this,&MainViewWidget::iconThemeChangeSlot); } } @@ -144,23 +198,23 @@ void MainViewWidget::initUi() */ void MainViewWidget::addTopControl() { - m_topLayout = new QHBoxLayout; + m_topLayout=new QHBoxLayout; m_topLayout->setSpacing(0); - m_queryLineEdit = new MyLineEdit; + m_queryLineEdit=new QLineEdit; m_topLayout->addWidget(m_queryLineEdit); m_topWidget->setLayout(m_topLayout); char style[200]; QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); else - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); - + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); m_queryLineEdit->setStyleSheet(style); + initQueryLineEdit(); + } //void MainViewWidget::focusInEvent(QFocusEvent *event) @@ -178,155 +232,150 @@ void MainViewWidget::addTopControl() */ void MainViewWidget::initQueryLineEdit() { - m_queryWid = new QWidget; + m_queryWid=new QWidget; m_queryWid->setParent(m_queryLineEdit); m_queryWid->setFocusPolicy(Qt::NoFocus); - QHBoxLayout *queryWidLayout = new QHBoxLayout; - queryWidLayout->setContentsMargins(0, 0, 0, 0); + QHBoxLayout* queryWidLayout=new QHBoxLayout; + queryWidLayout->setContentsMargins(0,0,0,0); queryWidLayout->setSpacing(5); m_queryWid->setLayout(queryWidLayout); - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16); + QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 - pixmap = drawSymbolicBlackColoredPixmap(pixmap); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - } - + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon = new QLabel; + m_queryIcon=new QLabel; m_queryIcon->setFixedSize(pixmap.size()); m_queryIcon->setPixmap(pixmap); - m_queryText = new QLabel; + m_queryText=new QLabel; m_queryText->setText(tr("Search")); m_queryText->adjustSize(); queryWidLayout->addWidget(m_queryIcon); queryWidLayout->addWidget(m_queryText); - queryWidLayout->setAlignment(m_queryIcon, Qt::AlignVCenter); - queryWidLayout->setAlignment(m_queryText, Qt::AlignVCenter); + queryWidLayout->setAlignment(m_queryIcon,Qt::AlignVCenter); + queryWidLayout->setAlignment(m_queryText,Qt::AlignVCenter); m_queryLineEdit->setFocusPolicy(Qt::ClickFocus); m_queryLineEdit->installEventFilter(this); m_queryLineEdit->setContextMenuPolicy(Qt::NoContextMenu); - m_animation = new QPropertyAnimation(m_queryWid, "geometry", m_queryWid); + + m_animation= new QPropertyAnimation(m_queryWid,"geometry"); m_animation->setDuration(100); - connect(m_animation, &QPropertyAnimation::finished, this, &MainViewWidget::animationFinishedSlot); - m_searchAppThread = new SearchAppThread; - m_searchAppThread->setParent(this); - connect(this, &MainViewWidget::sendSearchKeyword, - m_searchAppThread, &SearchAppThread::recvSearchKeyword); - connect(m_searchAppThread, &SearchAppThread::sendSearchResult, - this, &MainViewWidget::recvSearchResult); - connect(m_queryLineEdit, &MyLineEdit::textChanged, this, &MainViewWidget::searchAppSlot); + connect(m_animation,&QPropertyAnimation::finished,this,&MainViewWidget::animationFinishedSlot); + + m_searchAppThread=new SearchAppThread; + connect(this,&MainViewWidget::sendSearchKeyword, + m_searchAppThread,&SearchAppThread::recvSearchKeyword); + connect(m_searchAppThread,&SearchAppThread::sendSearchResult, + this,&MainViewWidget::recvSearchResult); + connect(m_queryLineEdit, &QLineEdit::textChanged, this, &MainViewWidget::searchAppSlot); } bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) { - if (watched == m_queryLineEdit) { - if ((m_queryIcon->x() == 0) && (event->type() == QEvent::KeyPress || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::InputMethod)) { - if (m_queryLineEdit->text().isEmpty() || (m_queryWid->layout()->count() != 2)) { - QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn)); - return false; - } - } - + if(watched==m_queryLineEdit) + { char style[200]; - - if (event->type() == QEvent::FocusIn && m_queryLineEdit->hasFocus()) { - if (!m_isFullScreen) { + if(event->type()==QEvent::FocusIn) + { + if(!m_isFullScreen) + { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault, QueryLineEditClickedDefaultBackground); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault,QueryLineEditClickedDefaultBackground); else - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditClickedBackground); - } else - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditClickedBackground); - - m_queryLineEdit->setStyleSheet(style); - - if (!m_queryLineEdit->text().isEmpty() && (m_queryLineEdit->text().size() >= 1)) { - if (m_searchKeyWords.isEmpty()) { - searchAppSlot(m_queryLineEdit->text()); - } - } else { - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); - m_animation->stop(); - m_animation->setStartValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, - m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); - m_animation->setEndValue(QRect(0, 0, - m_queryIcon->width() + 5, Style::QueryLineEditHeight)); - m_animation->setEasingCurve(QEasingCurve::OutQuad); - m_animation->start(); - m_queryLineEdit->setTextMargins(-5, 0, 0, 0); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditClickedBackground); } - - m_isSearching = true; - } else if (event->type() == QEvent::FocusOut) { + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditClickedBackground); + m_queryLineEdit->setStyleSheet(style); + if(!m_queryLineEdit->text().isEmpty()) + { + if(m_searchKeyWords.isEmpty()) + searchAppSlot(m_queryLineEdit->text()); + } + else + { + m_queryWid->layout()->removeWidget(m_queryText); + m_queryText->setParent(nullptr); + m_animation->stop(); + m_animation->setStartValue(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, + m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); + m_animation->setEndValue(QRect(0,0, + m_queryIcon->width()+5,Style::QueryLineEditHeight)); + m_animation->setEasingCurve(QEasingCurve::OutQuad); + m_animation->start(); + m_queryLineEdit->setTextMargins(-5,0,0,0); + } + m_isSearching=true; + } + else if(event->type()==QEvent::FocusOut) + { m_searchKeyWords.clear(); - - if (m_queryLineEdit->text().isEmpty()) { - if (m_isSearching || m_queryLineEdit->hasFocus()) { - if (!m_isFullScreen) { + if(m_queryLineEdit->text().isEmpty()) + { + if(m_isSearching) + { + if(!m_isFullScreen) + { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); else - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); - } else - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); - + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + } + else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); m_queryLineEdit->setStyleSheet(style); m_animation->stop(); m_queryText->adjustSize(); - m_animation->setStartValue(QRect(0, 0, - m_queryIcon->width() + 5, Style::QueryLineEditHeight)); - m_animation->setEndValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, - m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_animation->setStartValue(QRect(0,0, + m_queryIcon->width()+5,Style::QueryLineEditHeight)); + m_animation->setEndValue(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, + m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); m_animation->setEasingCurve(QEasingCurve::InQuad); m_animation->start(); } - } else { - if (!m_isFullScreen) { + } + else + { + if(!m_isFullScreen) + { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedDefaultBackground, QueryLineEditDefaultBackground); + if(gsetting.get("style-name").toString()=="ukui-light") + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", + QueryLineEditClickedDefaultBackground,QueryLineEditDefaultBackground); else - sprintf(style, "MyLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); - } else + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + } + else sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); - + QueryLineEditClickedBorder,QueryLineEditBackground); m_queryLineEdit->setStyleSheet(style); } - - m_isSearching = false; + m_isSearching=false; } } - return QWidget::eventFilter(watched, event); // 最后将事件交给上层对话框 + return QWidget::eventFilter(watched,event); // 最后将事件交给上层对话框 } void MainViewWidget::setLineEditFocus(QString arg) { - if (!m_queryLineEdit->hasFocus()) { - m_searchKeyWords = arg; + if(!m_queryLineEdit->hasFocus()) + { + m_searchKeyWords=arg; m_queryLineEdit->setFocus(); - - if (!m_queryLineEdit->text().isEmpty()) { + if(!m_queryLineEdit->text().isEmpty()) m_queryLineEdit->setText(arg); - } } } @@ -335,68 +384,48 @@ void MainViewWidget::setLineEditFocus(QString arg) */ void MainViewWidget::searchAppSlot(QString arg) { - if (!arg.isEmpty()) { //切换至搜索模块 - if (m_widgetState != 0) { - m_widgetState = 0; - - if (!m_isFullScreen) { + if(!arg.isEmpty())//切换至搜索模块 + { + if(m_widgetState!=0) + { + m_widgetState=0; + if(!m_isFullScreen) loadSearchResultWidget(); - } else { + else loadFullSearchResultWidget(); - } } - - // 如果搜索时依然还有搜索框和搜索的文字描述两个组件,则进行处理;置为搜索状态 - if (m_queryWid->layout()->count() == 2) { - QApplication::postEvent(m_queryLineEdit, new QEvent(QEvent::FocusIn)); - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); - m_animation->stop(); - m_animation->setStartValue(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, - m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); - m_animation->setEndValue(QRect(0, 0, - m_queryIcon->width() + 5, Style::QueryLineEditHeight)); - m_animation->setEasingCurve(QEasingCurve::OutQuad); - m_animation->start(); - m_queryLineEdit->setTextMargins(-5, 0, 0, 0); - } - - qDebug() << QTime::currentTime() << "m_queryWid(x, y) = (" << m_queryWid->x() << "," << m_queryWid->y() << ")"; Q_EMIT sendSearchKeyword(arg); m_searchAppThread->start(); - } else { //搜索模块显示所有的软件 - if (m_isFullScreen) { + } + else{//搜索模块显示所有的软件 + if(m_isFullScreen) + { switch (m_saveCurrentWidState) { - case 1: - loadFullCommonUseWidget(); - break; - - case 2: - loadFullLetterWidget(); - break; - - case 3: - loadFullFunctionWidget(); - - default: - break; + case 1: + loadFullCommonUseWidget(); + break; + case 2: + loadFullLetterWidget(); + break; + case 3: + loadFullFunctionWidget(); + default: + break; } - } else { + } + else { switch (m_saveCurrentWidState) { - case 1: - loadCommonUseWidget(); - break; - - case 2: - loadLetterWidget(); - break; - - case 3: - loadFunctionWidget(); - break; - - default: - break; + case 1: + loadCommonUseWidget(); + break; + case 2: + loadLetterWidget(); + break; + case 3: + loadFunctionWidget(); + break; + default: + break; } } } @@ -412,32 +441,37 @@ void MainViewWidget::recvSearchResult(QVector arg) void MainViewWidget::animationFinishedSlot() { - if (m_isSearching) { //进入搜索状态 + if(m_isSearching)//进入搜索状态 + { // m_queryWid->layout()->removeWidget(m_queryText); // m_queryText->setParent(nullptr); - m_queryLineEdit->setTextMargins(20, 0, 0, 0); - - if (!m_searchKeyWords.isEmpty()) { + m_queryLineEdit->setTextMargins(20,0,0,0); + if(!m_searchKeyWords.isEmpty()) + { m_queryLineEdit->setText(m_searchKeyWords); m_searchKeyWords.clear(); } - } else { //退出搜索状态 + } + else//退出搜索状态 + { m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); QPalette pe = m_queryText->palette(); - - if (!m_isFullScreen) { + if(!m_isFullScreen) + { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 - pe.setColor(QPalette::Text, QColor(Qt::black)); - } else { - pe.setColor(QPalette::Text, QColor(Qt::white)); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + { + pe.setColor(QPalette::Text,QColor(Qt::black)); + } + else + { + pe.setColor(QPalette::Text,QColor(Qt::white)); } - } else { - pe.setColor(QPalette::Text, QColor(Qt::white)); } + else + pe.setColor(QPalette::Text,QColor(Qt::white)); m_queryText->setPalette(pe); } @@ -448,62 +482,62 @@ void MainViewWidget::animationFinishedSlot() */ void MainViewWidget::loadMinMainView() { - this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); //搜索区 - m_topWidget->setFixedSize(this->width(), Style::defaultTopWidHeight); - m_topLayout->setContentsMargins(0, 0, 0, 0); - m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter); - m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth, Style::defaultQueryLineEditHeight); - - if (m_queryLineEdit->text().isEmpty()) { - if (m_queryWid->layout()->count() == 1) { + m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight); + m_topLayout->setContentsMargins(0,0,0,0); + m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); + m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); + if(m_queryLineEdit->text().isEmpty()) + { + if(m_queryWid->layout()->count()==1) + { m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); } - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, - m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, + m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); m_queryWid->show(); } char style[200]; QPalette pe = m_queryText->palette(); - const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); + QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") { - pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑 - pe.setColor(QPalette::Text, QColor(Qt::black)); + if(gsetting.get("style-name").toString()=="ukui-light") + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pe.setColor(QPalette::Text,QColor(Qt::black)); sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - pe.setColor(QPalette::Text, QColor(Qt::white)); - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); + QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pe.setColor(QPalette::Text,QColor(Qt::white)); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); } - m_queryLineEdit->setStyleSheet(style); pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon->setPixmap(pixmap); m_queryText->setPalette(pe); + //内容区 - m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - - if (m_widgetState == 0) { + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); + if(m_widgetState==0) + { loadSearchResultWidget(); - } else if (m_widgetState == 1) { - loadCommonUseWidget(); - } else if (m_widgetState == 2) { - loadLetterWidget(); - } else if (m_widgetState == 3) { - loadFunctionWidget(); } - - m_isFullScreen = false; + else if(m_widgetState==1) + loadCommonUseWidget(); + else if(m_widgetState==2) + loadLetterWidget(); + else if(m_widgetState==3) + loadFunctionWidget(); + m_isFullScreen=false; } /** @@ -514,134 +548,140 @@ void MainViewWidget::loadMaxMainView() this->setFixedSize(Style::MainViewWidWidth, Style::heightavailable); //搜索区 - m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight); - m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight); - m_topLayout->setContentsMargins((m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2 + Style::LeftWidWidth, - 0, - (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2, - 0); + m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight); + m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight); - if (m_queryLineEdit->text().isEmpty()) { - if (m_queryWid->layout()->count() == 1) { + m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, + 0, + (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, + 0); + + if(m_queryLineEdit->text().isEmpty()) + { + if(m_queryWid->layout()->count()==1) + { m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); } - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, - m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, + m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); m_queryWid->show(); } char style[200]; sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); + QueryLineEditClickedBorder,QueryLineEditBackground); m_queryLineEdit->setStyleSheet(style); - const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + + QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 QPalette pe = m_queryText->palette(); - pe.setColor(QPalette::Text, QColor(Qt::white)); + pe.setColor(QPalette::Text,QColor(Qt::white)); m_queryText->setPalette(pe); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon->setPixmap(pixmap); + //内容区 - m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - - if (m_widgetState == 0) { + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); + if(m_widgetState==0) + { loadFullSearchResultWidget(); - } else if (m_widgetState == 1) { - loadFullCommonUseWidget(); - } else if (m_widgetState == 2) { - loadFullLetterWidget(); - } else if (m_widgetState == 3) { - loadFullFunctionWidget(); } - - m_isFullScreen = true; + else if(m_widgetState==1) + loadFullCommonUseWidget(); + else if(m_widgetState==2) + loadFullLetterWidget(); + else if(m_widgetState==3) + loadFullFunctionWidget(); + m_isFullScreen=true; } void MainViewWidget::resizeControl() { - if (m_isFullScreen) { - if (m_widgetState == 2) { + if(m_isFullScreen) + { + if(m_widgetState==2) m_fullLetterWid->setLetterBtnGeometry(); - } - - if (m_widgetState == 3) { + if(m_widgetState==3) m_fullFunctionWid->setFunctionBtnGeometry(); - } this->setFixedSize(Style::MainViewWidWidth, Style::heightavailable); - m_topWidget->setFixedSize(this->width(), Style::TopWidgetHeight); - m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth, Style::QueryLineEditHeight); - m_topLayout->setContentsMargins((m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2 + Style::LeftWidWidth, - 0, - (m_topWidget->width() - Style::LeftWidWidth - m_queryLineEdit->width()) / 2, - 0); - m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); - } else { - this->setFixedSize(Style::defaultMainViewWidWidth, Style::minh); - m_topWidget->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultTopWidHeight); - m_topLayout->setContentsMargins(0, 0, 0, 0); - m_topLayout->setAlignment(m_queryLineEdit, Qt::AlignCenter); - m_contentWid->setFixedSize(this->width(), this->height() - m_topWidget->height()); + m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight); + m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight); + + m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, + 0, + (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, + 0); + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); } + else + { + this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); + m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight); + m_topLayout->setContentsMargins(0,0,0,0); + m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); + m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); + } + } void MainViewWidget::resetQueryLine() { - if (!m_queryLineEdit->text().isEmpty()) { + if(!m_queryLineEdit->text().isEmpty()) + { + m_queryLineEdit->clearFocus(); m_queryLineEdit->clear(); m_isSearching = false; - if (m_queryWid->layout()->count() == 1) { + if(m_queryWid->layout()->count()==1) + { m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon, Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText, Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); + m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); } - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width() - (m_queryIcon->width() + m_queryText->width() + 10)) / 2, 0, - m_queryIcon->width() + m_queryText->width() + 10, Style::QueryLineEditHeight)); + m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, + m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); char style[200]; - const auto ratio = devicePixelRatioF(); QPalette pe = m_queryText->palette(); - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/search.svg"), 16 * ratio); + QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); + if(!m_isFullScreen) + { - if (!m_isFullScreen) { QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (gsetting.get("style-name").toString() == "ukui-light") { - pixmap = drawSymbolicBlackColoredPixmap(pixmap); //反黑 - pe.setColor(QPalette::Text, QColor(Qt::black)); + if(gsetting.get("style-name").toString()=="ukui-light") + { + pixmap=drawSymbolicBlackColoredPixmap(pixmap);//反黑 + pe.setColor(QPalette::Text,QColor(Qt::black)); sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - pe.setColor(QPalette::Text, QColor(Qt::white)); - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); + QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); + } + else + { + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pe.setColor(QPalette::Text,QColor(Qt::white)); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); } - } else { - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder, QueryLineEditBackground); - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - pe.setColor(QPalette::Text, QColor(Qt::white)); } - + else + { + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", + QueryLineEditClickedBorder,QueryLineEditBackground); + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 + pe.setColor(QPalette::Text,QColor(Qt::white)); + } m_queryLineEdit->setStyleSheet(style); pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); m_queryIcon->setPixmap(pixmap); m_queryText->setPalette(pe); } - m_queryLineEdit->setFocus(); - QTimer::singleShot(1, this, [ = ]() { - m_queryLineEdit->simulateFocusOutEvent(nullptr); - }); } /** @@ -655,12 +695,12 @@ void MainViewWidget::loadCommonUseWidget() m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); hideWidget(); - m_commonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_commonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_commonUseWid->show(); m_commonUseWid->updateListView(); this->layout()->update(); - m_widgetState = 1; - m_saveCurrentWidState = 1; + m_widgetState=1; + m_saveCurrentWidState=1; resetQueryLine(); } @@ -675,10 +715,10 @@ void MainViewWidget::loadLetterWidget() m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); hideWidget(); - m_letterWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_letterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_letterWid->show(); - m_widgetState = 2; - m_saveCurrentWidState = 2; + m_widgetState=2; + m_saveCurrentWidState=2; resetQueryLine(); } @@ -693,10 +733,10 @@ void MainViewWidget::loadFunctionWidget() m_fullLetterWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); hideWidget(); - m_functionWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_functionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_functionWid->show(); - m_widgetState = 3; - m_saveCurrentWidState = 3; + m_widgetState=3; + m_saveCurrentWidState=3; resetQueryLine(); } @@ -711,11 +751,11 @@ void MainViewWidget::loadFullCommonUseWidget() m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); hideWidget(); - m_fullCommonUseWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_fullCommonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_fullCommonUseWid->show(); m_fullCommonUseWid->updateListView(); - m_widgetState = 1; - m_saveCurrentWidState = 1; + m_widgetState=1; + m_saveCurrentWidState=1; resetQueryLine(); } @@ -730,12 +770,12 @@ void MainViewWidget::loadFullLetterWidget() m_functionWid->widgetMakeZero(); m_fullFunctionWid->widgetMakeZero(); hideWidget(); - m_fullLetterWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_fullLetterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_fullLetterWid->show(); // if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2)) m_fullLetterWid->enterAnimation(); - m_widgetState = 2; - m_saveCurrentWidState = 2; + m_widgetState=2; + m_saveCurrentWidState=2; resetQueryLine(); } @@ -750,26 +790,26 @@ void MainViewWidget::loadFullFunctionWidget() m_fullLetterWid->widgetMakeZero(); m_functionWid->widgetMakeZero(); hideWidget(); - m_fullFunctionWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_fullFunctionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_fullFunctionWid->show(); // if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3)) m_fullFunctionWid->enterAnimation(); - m_widgetState = 3; - m_saveCurrentWidState = 3; + m_widgetState=3; + m_saveCurrentWidState=3; resetQueryLine(); } void MainViewWidget::loadSearchResultWidget() { hideWidget(); - m_searchResultWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_searchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_searchResultWid->show(); } void MainViewWidget::loadFullSearchResultWidget() { hideWidget(); - m_fullSearchResultWid->setGeometry(0, 0, this->width(), this->height() - m_topWidget->height()); + m_fullSearchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); m_fullSearchResultWid->show(); } @@ -800,15 +840,17 @@ void MainViewWidget::changeFocuDown() */ void MainViewWidget::ViewOpenedSlot(QString desktopfp) { - QVector desktopfpVec = UkuiMenuInterface::desktopfpVector; - - if (desktopfpVec.contains(desktopfp)) { + qDebug()<<"open software:"< desktopfpVec=UkuiMenuInterface::desktopfpVector; + if(desktopfpVec.contains(desktopfp)) + { QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); + QString desktopfn=fileInfo.fileName(); + QString dateTimeKey; dateTimeKey.clear(); - - if (!desktopfn.isEmpty()) { + if(!desktopfn.isEmpty()) + { updateDataBaseTableTimes(desktopfn); } } @@ -833,9 +875,8 @@ void MainViewWidget::requestUpdateSlot() void MainViewWidget::iconThemeChangeSlot(QString key) { - if (key == "iconThemeName" || key == "icon-theme-name") { + if(key=="iconThemeName" || key=="icon-theme-name") Q_EMIT directoryChangedSignal(); - } } void MainViewWidget::reloadUkuiMenu() @@ -845,7 +886,7 @@ void MainViewWidget::reloadUkuiMenu() void MainViewWidget::repaintWidget() { - this->setMinimumSize(Style::minw, Style::minh); + this->setMinimumSize(Style::minw,Style::minh); m_commonUseWid->repaintWidget(); m_fullCommonUseWid->repaintWidget(); m_letterWid->repaintWidget(); @@ -856,10 +897,18 @@ void MainViewWidget::repaintWidget() m_fullSearchResultWid->repaintWidget(); } +void MainViewWidget::repaintFullWidget() +{ + m_fullCommonUseWid->repaintWidget(); + m_fullLetterWid->repaintWidget(); + m_fullFunctionWid->repaintWidget(); + m_fullSearchResultWid->repaintWidget(); +} + void MainViewWidget::widgetMakeZero() { - m_isSearching = false; - m_widgetState = m_saveCurrentWidState; + m_isSearching=false; + m_widgetState=m_saveCurrentWidState; m_commonUseWid->widgetMakeZero(); m_fullCommonUseWid->widgetMakeZero(); m_letterWid->widgetMakeZero(); @@ -870,65 +919,64 @@ void MainViewWidget::widgetMakeZero() m_queryLineEdit->clear(); m_queryLineEdit->clearFocus(); m_queryLineEdit->blockSignals(false); - m_queryLineEdit->setTextMargins(0, 0, 0, 0); + m_queryLineEdit->setTextMargins(0,0,0,0); } void MainViewWidget::moveScrollBar(int type) { - if (m_widgetState == 0) { - if (m_isFullScreen) { + if(m_widgetState==0) + { + if(m_isFullScreen) m_fullSearchResultWid->moveScrollBar(type); - } else { + else m_searchResultWid->moveScrollBar(type); - } } - - if (m_widgetState == 1) { - if (m_isFullScreen) { + if(m_widgetState==1) + { + if(m_isFullScreen) m_fullCommonUseWid->moveScrollBar(type); - } else { + else m_commonUseWid->moveScrollBar(type); - } } - - if (m_widgetState == 2) { - if (m_isFullScreen) { + if(m_widgetState==2) + { + if(m_isFullScreen) m_fullLetterWid->moveScrollBar(type); - } else { + else m_letterWid->moveScrollBar(type); - } } - - if (m_widgetState == 3) { - if (m_isFullScreen) { + if(m_widgetState==3) + { + if(m_isFullScreen) m_fullFunctionWid->moveScrollBar(type); - } else { + else m_functionWid->moveScrollBar(type); - } } } void MainViewWidget::keyPressEvent(QKeyEvent *e) { - if (e->type() == QEvent::KeyPress) { - if (e->key() == Qt::Key_Escape) { - Q_EMIT setMainWinHideSignal(); - } - - switch (e->key()) { + if(e->type()==QEvent::KeyPress) + { + switch(e->key()) + { case Qt::Key_Enter: case Qt::Key_Return: - case Qt::Key_Down: { - if (m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty()) { - if (m_isFullScreen) { + case Qt::Key_Down: + { + if(m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty()) + { + if(m_isFullScreen) + { m_fullSearchResultWid->setViewFocus(); - } else { + } + else + { m_searchResultWid->setViewFocus(); } } } - break; - + break; default: break; } diff --git a/src/MainViewWidget/mainviewwidget.h b/src/MainViewWidget/mainviewwidget.h index 67332c8..fe0af1c 100644 --- a/src/MainViewWidget/mainviewwidget.h +++ b/src/MainViewWidget/mainviewwidget.h @@ -40,23 +40,9 @@ #include "src/SearchResultWidget/fullsearchresultwidget.h" #include "src/SearchResultWidget/searchresultwidget.h" #include "src/SearchResultWidget/searchappthread.h" -#include "src/UtilityFunction/convertdesktoptowinid.h" #include "directorychangedthread.h" #include "src/Style/style.h" -class MyLineEdit : public QLineEdit{ - Q_OBJECT - -public: - explicit MyLineEdit(QLineEdit *parent = nullptr){unsetCursor();} - ~MyLineEdit(){} - - void simulateFocusOutEvent(QKeyEvent *e){ - QApplication::postEvent(this, new QEvent(QEvent::FocusOut)); - this->focusOutEvent(new QFocusEvent(QEvent::FocusOut)); - } -}; - class MainViewWidget : public QWidget { Q_OBJECT @@ -88,6 +74,7 @@ public: /** * @brief changeFocuUp */ + void repaintFullWidget(); void changeFocuUp(); /** @@ -105,8 +92,6 @@ public: void resetQueryLine(); - MyLineEdit* getQueryLineEditer() {return m_queryLineEdit;} - private: UkuiMenuInterface *m_ukuiMenuInterface=nullptr; QWidget *m_topWidget=nullptr; @@ -114,7 +99,7 @@ private: QWidget *m_contentWid=nullptr; - MyLineEdit *m_queryLineEdit=nullptr; + QLineEdit *m_queryLineEdit=nullptr; QWidget *m_queryWid=nullptr; QLabel *m_queryIcon=nullptr; QLabel *m_queryText=nullptr; @@ -251,8 +236,6 @@ Q_SIGNALS: */ void sendHideMainWindowSignal(); - void sendMainWinActiveSignal(bool flag); - void setFocusToSideWin(); void selectFirstItem(); @@ -260,8 +243,6 @@ Q_SIGNALS: void selectFirstItemTab(); void setSlideBar(int value); - - void setMainWinHideSignal(); }; #endif // MAINVIEWWIDGET_H diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp index 69fc880..935fb7f 100644 --- a/src/MainWindow/mainwindow.cpp +++ b/src/MainWindow/mainwindow.cpp @@ -29,69 +29,63 @@ #include #include #include "src/Style/style.h" -#include "src/UtilityFunction/utility.h" #include -#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - getCurrentCPU(); openDataBase("MainThread"); - m_ukuiMenuInterface = new UkuiMenuInterface; - UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + m_ukuiMenuInterface=new UkuiMenuInterface; + UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); initDatabase(); - UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); - UkuiMenuInterface::allAppVector = m_ukuiMenuInterface->getAllClassification(); + UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::allAppVector=m_ukuiMenuInterface->getAllClassification(); + Style::initWidStyle(); initUi(); - m_dbus = new DBus; + + + m_dbus=new DBus; new MenuAdaptor(m_dbus); - QDBusConnection con = QDBusConnection::sessionBus(); - - if (!con.registerService("org.ukui.menu") || - !con.registerObject("/org/ukui/menu", m_dbus)) { - qDebug() << "error:" << con.lastError().message(); + QDBusConnection con=QDBusConnection::sessionBus(); + if(!con.registerService("org.ukui.menu") || + !con.registerObject("/org/ukui/menu",m_dbus)) + { + qDebug()<<"error:"<createAppInfoVector(); - UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT m_mainViewWid->reloadUkuiMenu(); }); - connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { - if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) + + connect(m_dbus,&DBus::winKeyResponseSignal,this,[=]{ + if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) { QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); - -// if(gsetting.keys().contains("win-key-release")) -// if(gsetting.get("win-key-release").toBool()) -// return; - if (gsetting.keys().contains("winKeyRelease")) - if (gsetting.get("winKeyRelease").toBool()) { + if(gsetting.keys().contains("win-key-release")) + if(gsetting.get("win-key-release").toBool()) return; - } } - if (QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) + if(QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) { QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit()); - - if (gsetting.keys().contains("isrunning")) - if (gsetting.get("isrunning").toBool()) { + if(gsetting.keys().contains("isrunning")) + if(gsetting.get("isrunning").toBool()) return; - } } - if (this->isVisible()) + if(this->isVisible()) { this->hide(); - } else - { + } + else{ this->loadMainWindow(); this->show(); this->raise(); @@ -104,11 +98,7 @@ MainWindow::MainWindow(QWidget *parent) : MainWindow::~MainWindow() { closeDataBase("MainThread"); - - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } void MainWindow::initUi() @@ -117,115 +107,101 @@ void MainWindow::initUi() this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAutoFillBackground(false); this->setFocusPolicy(Qt::NoFocus); - this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - this->setMinimumSize(Style::minw, Style::minh); - this->setContentsMargins(0, 0, 0, 0); -// this->setFocus(); - m_frame = new QFrame; - m_mainViewWid = new MainViewWidget; - m_sideBarWid = new SideBarWidget; -// m_frame->installEventFilter(this); -// m_mainViewWid->installEventFilter(this); -// m_sideBarWid->installEventFilter(this); -// setTabOrder(m_mainViewWid , m_sideBarWid); -// setTabOrder(m_sideBarWid , m_mainViewWid); + + this->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + this->setMinimumSize(Style::minw,Style::minh); + this->setContentsMargins(0,0,0,0); + m_frame=new QFrame; + m_mainViewWid=new MainViewWidget; + m_sideBarWid=new SideBarWidget; + this->setCentralWidget(m_frame); - QHBoxLayout *mainlayout = new QHBoxLayout; - mainlayout->setContentsMargins(0, 0, 0, 0); + QHBoxLayout *mainlayout=new QHBoxLayout; + mainlayout->setContentsMargins(0,0,0,0); mainlayout->setSpacing(0); m_frame->setLayout(mainlayout); + mainlayout->addWidget(m_mainViewWid); - m_line = new QFrame; + m_line=new QFrame; m_line->installEventFilter(this); m_line->setFrameShape(QFrame::VLine); - m_line->setFixedSize(1, this->height() - 1); + m_line->setFixedSize(1,this->height()-1); m_line->setEnabled(false); mainlayout->addWidget(m_line); mainlayout->addWidget(m_sideBarWid); m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); + + m_animation = new QPropertyAnimation(this, "geometry"); - connect(m_animation, &QPropertyAnimation::finished, this, &MainWindow::animationValueFinishedSlot); + connect(m_animation,&QPropertyAnimation::finished,this,&MainWindow::animationValueFinishedSlot); + connect(m_sideBarWid, &SideBarWidget::setFocusToMainWin, m_mainViewWid, &MainViewWidget::selectFirstItemTab); connect(m_sideBarWid, &SideBarWidget::sendCommonUseBtnSignal, m_mainViewWid, &MainViewWidget::loadCommonUseWidget); - connect(m_sideBarWid, &SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget); + connect(m_sideBarWid,&SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget); connect(m_sideBarWid, &SideBarWidget::sendFunctionBtnSignal, m_mainViewWid, &MainViewWidget::loadFunctionWidget); - connect(m_sideBarWid, &SideBarWidget::sendFullScreenCommonUseBtnSignal, - m_mainViewWid, &MainViewWidget::loadFullCommonUseWidget); - connect(m_sideBarWid, &SideBarWidget::sendFullScreenLetterBtnSignal, - m_mainViewWid, &MainViewWidget::loadFullLetterWidget); - connect(m_sideBarWid, &SideBarWidget::sendFullScreenFunctionBtnSignal, - m_mainViewWid, &MainViewWidget::loadFullFunctionWidget); - connect(m_sideBarWid, &SideBarWidget::setSlideBar, m_mainViewWid, &MainViewWidget::setSlideBar); - connect(m_sideBarWid, &SideBarWidget::sendFullScreenBtnSignal, this, &MainWindow::showFullScreenWidget); - connect(m_sideBarWid, &SideBarWidget::sendDefaultBtnSignal, this, &MainWindow::showDefaultWidget); - connect(m_sideBarWid, &SideBarWidget::sendShowMainWindowSignal, this, &MainWindow::activeWindowSolt); - connect(m_mainViewWid, &MainViewWidget::sendHideMainWindowSignal, this, &MainWindow::recvHideMainWindowSlot); - connect(m_sideBarWid, &SideBarWidget::sendHideMainWindowSignal, this, &MainWindow::recvHideMainWindowSlot); - connect(m_mainViewWid, &MainViewWidget::setFocusToSideWin, m_sideBarWid, &SideBarWidget::setFocusToThis); - connect(this, &MainWindow::setFocusSignal, m_mainViewWid, &MainViewWidget::selectFirstItem); - connect(m_mainViewWid, &MainViewWidget::sendMainWinActiveSignal, this, &MainWindow::activeWindowSolt); - connect(m_mainViewWid, &MainViewWidget::setMainWinHideSignal, this, &MainWindow::mainWinHideSlot); + connect(m_sideBarWid,&SideBarWidget::sendFullScreenCommonUseBtnSignal, + m_mainViewWid,&MainViewWidget::loadFullCommonUseWidget); + connect(m_sideBarWid,&SideBarWidget::sendFullScreenLetterBtnSignal, + m_mainViewWid,&MainViewWidget::loadFullLetterWidget); + connect(m_sideBarWid,&SideBarWidget::sendFullScreenFunctionBtnSignal, + m_mainViewWid,&MainViewWidget::loadFullFunctionWidget); + + connect(m_sideBarWid, &SideBarWidget::setSlideBar, m_mainViewWid, &MainViewWidget::setSlideBar); + + connect(m_sideBarWid,&SideBarWidget::sendFullScreenBtnSignal,this,&MainWindow::showFullScreenWidget); + connect(m_sideBarWid,&SideBarWidget::sendDefaultBtnSignal,this,&MainWindow::showDefaultWidget); + connect(m_sideBarWid, &SideBarWidget::sendShowMainWindowSignal, this, &MainWindow::activeWindowSolt); + connect(m_mainViewWid,&MainViewWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); + connect(m_sideBarWid,&SideBarWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); + + connect(m_mainViewWid,&MainViewWidget::setFocusToSideWin,m_sideBarWid,&SideBarWidget::setFocusToThis); + connect(this, &MainWindow::setFocusSignal, m_mainViewWid, &MainViewWidget::selectFirstItem); connect(QApplication::desktop(),&QDesktopWidget::resized,this, [=]{ - repaintWidget(); + primaryScreenChangeSlot(); }); connect(QApplication::desktop(),&QDesktopWidget::primaryScreenChanged,this,[=]{ - repaintWidget(); + primaryScreenChangeSlot(); }); + connect(QApplication::desktop(),&QDesktopWidget::screenCountChanged,this,[=]{ - repaintWidget(); + primaryScreenChangeSlot(); }); - QDBusConnection::sessionBus().connect(DBUS_NAME, DBUS_PATH, DBUS_INTERFACE, QString("PanelGeometryRefresh"), this, SLOT(primaryScreenChangeSlot())); + + QDBusConnection::sessionBus().connect(DBUS_NAME,DBUS_PATH,DBUS_INTERFACE,QString("PanelGeometryRefresh"),this,SLOT(primaryScreenChangeSlot())); //监听屏幕缩放 - if (QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) { - QGSettings *m_gsetting = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); - connect(m_gsetting, &QGSettings::changed, this, [ = ](const QString & key) { - if (key == "scalingFactor") { + if(QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) + { + QGSettings* m_gsetting=new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); + connect(m_gsetting,&QGSettings::changed,this,[=](const QString &key) + { + if(key=="scalingFactor") repaintWidget(); - } }); } if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); - connect(gsetting, &QGSettings::changed, + QGSettings *psetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit(), QByteArray(), this); + connect(psetting, &QGSettings::changed, this, &MainWindow::panelChangedSlot); } } -void MainWindow::getCurrentCPU() -{ - QProcess *processCpuInfo = new QProcess(this); - processCpuInfo->start(QString("cat /proc/cpuinfo")); - connect(processCpuInfo, static_cast(&QProcess::finished), this, [ = ]() { - processCpuInfo->deleteLater(); - }); - processCpuInfo->waitForFinished(); - QString ctrCpuInfo = processCpuInfo->readAll(); - - if (ctrCpuInfo.contains("HUAWEI") || ctrCpuInfo.contains("Kirin")) { - isHuaWeiPC = true; - } - - if (ctrCpuInfo.contains("PANGU")) { - isPANGU = true; - } -} - - void MainWindow::paintEvent(QPaintEvent *event) { - double transparency = getTransparency(); + double transparency=getTransparency(); + QRect rect = this->rect(); QPainterPath path; + QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; painter.setPen(Qt::transparent); - - if (!m_isFullScreen) { - qreal radius = 6; + if(!m_isFullScreen) + { + qreal radius=6; path.moveTo(rect.topRight() - QPointF(radius, 0)); path.lineTo(rect.topLeft() + QPointF(radius, 0)); path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); @@ -235,13 +211,17 @@ void MainWindow::paintEvent(QPaintEvent *event) path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + painter.setBrush(this->palette().base()); painter.setPen(Qt::transparent); painter.setOpacity(transparency); painter.drawPath(path); + // setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - } else { //全屏固定背景色(黑底白字) + } + else//全屏固定背景色(黑底白字) + { // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); @@ -272,16 +252,16 @@ void MainWindow::paintEvent(QPaintEvent *event) // } // else // { - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); // } + QPainterPath path; path.addRect(this->rect()); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); } - QMainWindow::paintEvent(event); } @@ -290,31 +270,24 @@ void MainWindow::paintEvent(QPaintEvent *event) */ void MainWindow::showFullScreenWidget() { - QRect availableGeometry = getScreenAvailableGeometry(); m_isFullScreen = true; this->setContentsMargins(0, 0, 0, 0); int position = Style::panelPosition; - int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; -// int width = Style::primaryScreenWidth; -// int height = Style::primaryScreenHeight; + int width = Style::widthavailable; + int height = Style::heightavailable; QRect startRect; QRect endRect; - if (position == 0) { - startRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); - endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); - } else if (position == 1) { - startRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); - endRect.setRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height()); - } else if (position == 2) { - startRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); - endRect.setRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height()); + if (position == BOTTOM) { + startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); + } else if (position == RIGHT) { + startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); } else { - startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); - endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); + startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); } + endRect.setRect(x, y, width, height); this->centralWidget()->layout()->removeWidget(m_mainViewWid); m_mainViewWid->setParent(nullptr); @@ -323,32 +296,17 @@ void MainWindow::showFullScreenWidget() this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); - if (isPANGU || isHuaWeiPC) { - is_repaint = false; - this->hide(); - QEventLoop loop; - QTimer::singleShot(150, &loop, SLOT(quit())); - loop.exec(); - m_animation->setDuration(1);//动画总时间 - m_animation->setStartValue(startRect); - m_animation->setEndValue(endRect); - m_animation->setEasingCurve(QEasingCurve::Linear); - m_animation->start(); - this->show(); - this->activateWindow(); - is_repaint = true; - } else { - m_animation->setDuration(100);//动画总时间 - m_animation->setStartValue(startRect); - m_animation->setEndValue(endRect); - m_animation->setEasingCurve(QEasingCurve::Linear); - m_animation->start(); - } + m_animation->setDuration(100);//动画总时间 + m_animation->setStartValue(startRect); + m_animation->setEndValue(endRect); + m_animation->setEasingCurve(QEasingCurve::Linear); + m_animation->start(); } void MainWindow::mouseReleaseEvent(QMouseEvent *event) { - if (m_isFullScreen && event->button() == Qt::LeftButton) { + if(m_isFullScreen && event->button()==Qt::LeftButton) + { this->hide(); } } @@ -358,30 +316,23 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event) */ void MainWindow::showDefaultWidget() { - QRect availableGeometry = getScreenAvailableGeometry(); m_isFullScreen = false; this->setContentsMargins(0, 0, 0, 0); int position = Style::panelPosition; - int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::primaryScreenWidth; - int height = Style::primaryScreenHeight; + int width = Style::widthavailable; + int height = Style::heightavailable; QRect startRect; QRect endRect; - if (position == 0) { - endRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); - startRect.setRect(x, y, width, height - panelSize); - } else if (position == 1) { - endRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); - startRect.setRect(x, y + panelSize, width, height - panelSize); - } else if (position == 2) { - endRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); - startRect.setRect(x + panelSize, y, width - panelSize, height); + startRect.setRect(x, y, width, height); + if (position == BOTTOM) { + endRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); + } else if (position == RIGHT) { + endRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); } else { - endRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); - startRect.setRect(x, y, width - panelSize, height); + endRect.setRect(x + 4, y + 4, Style::minw, Style::minh); } this->centralWidget()->layout()->removeWidget(m_mainViewWid); @@ -389,21 +340,17 @@ void MainWindow::showDefaultWidget() this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); - if (isPANGU || isHuaWeiPC) { - this->setGeometry(endRect); - animationValueFinishedSlot(); - } else { - m_animation->setDuration(100);//动画总时间 - m_animation->setStartValue(startRect); - m_animation->setEndValue(endRect); - m_animation->setEasingCurve(QEasingCurve::Linear); - m_animation->start(); - } + m_animation->setDuration(100);//动画总时间 + m_animation->setStartValue(startRect); + m_animation->setEndValue(endRect); + m_animation->setEasingCurve(QEasingCurve::Linear); + m_animation->start(); } void MainWindow::animationValueChangedSlot(const QVariant &value) { - if (m_isFullScreen) { + if(m_isFullScreen) + { QPainterPath path; path.addRect(this->rect()); // setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); @@ -413,91 +360,71 @@ void MainWindow::animationValueChangedSlot(const QVariant &value) void MainWindow::animationValueFinishedSlot() { - if (m_isFullScreen) { + if(m_isFullScreen) + { this->centralWidget()->layout()->addWidget(m_mainViewWid); this->centralWidget()->layout()->addWidget(m_sideBarWid); m_sideBarWid->loadMaxSidebar(); m_mainViewWid->loadMaxMainView(); m_sideBarWid->enterAnimation(); - } else { + } + else + { this->centralWidget()->layout()->addWidget(m_mainViewWid); this->centralWidget()->layout()->addWidget(m_line); this->centralWidget()->layout()->addWidget(m_sideBarWid); m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); } - - m_mainViewWid->getQueryLineEditer()->setFocus(); - - if (m_mainViewWid->getQueryLineEditer()->text().isEmpty()) { - qDebug() << "there is no letter in search lineEditer"; - QTimer::singleShot(1, this, [ = ]() { - m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); - }); - } } void MainWindow::activeWindowSolt(bool flag) { // qDebug() << "void MainWindow::activeWindowSolt(bool flag)"; - if (isPANGU || isHuaWeiPC) { - QTimer::singleShot(50, this, SLOT(mainWinShowSlot())); - } + QTimer::singleShot(30,this, SLOT(mainWinShowSlot())); } void MainWindow::mainWinShowSlot() { - this->activateWindow(); - - if (!this->geometry().contains(QCursor::pos())) { - this->hide(); - } - - qDebug() << "void MainWindow::activeWindowSolt()"; + this->activateWindow(); + qDebug() << "void MainWindow::activeWindowSolt()"; } /** * 鼠标点击窗口外部事件 */ -bool MainWindow::event(QEvent *event) +bool MainWindow::event ( QEvent * event ) { - if (event->type() == QEvent::ActivationChange && is_repaint) - // if(QEvent::WindowDeactivate == event->type() && m_canHide)//窗口停用 - { - qDebug() << " * 鼠标点击窗口外部事件"; - - if (QApplication::activeWindow() != this) { + if (event->type() == QEvent::ActivationChange) + // if(QEvent::WindowDeactivate == event->type() && m_canHide)//窗口停用 + { + qDebug() << " * 鼠标点击窗口外部事件"; + if(QApplication::activeWindow() != this) + { this->hide(); m_mainViewWid->widgetMakeZero(); } - } - - if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = (QKeyEvent *) event; + } + if (event->type() == QEvent::KeyPress) + { + QKeyEvent *keyEvent = (QKeyEvent *) event; // if (keyEvent->key() == Qt::Key_Tab) // { // m_mainViewWid->setFocus(); // Q_EMIT setFocusSignal(); // return true; // } - if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || - keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || - keyEvent->key() == Qt::Key_Tab) { - m_mainViewWid->setFocus(); - Q_EMIT setFocusSignal(); - // return true; - } - } - - if (event->type() == QEvent::FocusIn) { - m_mainViewWid->getQueryLineEditer()->setFocus(); - QTimer::singleShot(1, this, [ = ]() { - m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); - }); - } - - return QWidget::event(event); + if(keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || + keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || + keyEvent->key() == Qt::Key_Tab) + { + m_mainViewWid->setFocus(); + Q_EMIT setFocusSignal(); + // return true; + } + } + return QWidget::event(event); } /** @@ -513,13 +440,12 @@ void MainWindow::recvHideMainWindowSlot() void MainWindow::loadMainWindow() { cleanTimeoutApp(); - QRect availableGeometry = getScreenAvailableGeometry(); + int position = Style::panelPosition; - int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::primaryScreenWidth; - int height = Style::primaryScreenHeight; + int width = Style::widthavailable; + int height = Style::heightavailable; this->setFocus(); if (m_isFullScreen) { @@ -527,19 +453,14 @@ void MainWindow::loadMainWindow() QRect startRect; QRect endRect; - if (position == 0) { - startRect.setRect(x + 4, y + availableGeometry.height() - Style::minh - 3, Style::minw, Style::minh); - endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); - } else if (position == 1) { - startRect.setRect(x + 4, y + panelSize + 4, Style::minw, Style::minh); - endRect.setRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height()); - } else if (position == 2) { - startRect.setRect(x + panelSize + 4, y + 4, Style::minw, Style::minh); - endRect.setRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height()); + if (position == BOTTOM) { + startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); + } else if (position == RIGHT) { + startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); } else { - startRect.setRect(x + availableGeometry.width() - Style::minw - 4, y + 4, Style::minw, Style::minh); - endRect.setRect(x, y, availableGeometry.width(), availableGeometry.height()); + startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); } + endRect.setRect(x, y, width, height); this->centralWidget()->layout()->removeWidget(m_mainViewWid); m_mainViewWid->setParent(nullptr); @@ -547,156 +468,92 @@ void MainWindow::loadMainWindow() m_line->setParent(nullptr); this->centralWidget()->layout()->removeWidget(m_sideBarWid); m_sideBarWid->setParent(nullptr); -// m_sideBarWid->clearFocus(); -// m_mainViewWid->clearFocus(); m_animation->setDuration(1);//动画总时间 m_animation->setStartValue(startRect); m_animation->setEndValue(endRect); m_animation->setEasingCurve(QEasingCurve::Linear); m_animation->start(); } else { -// QGSettings* setting1 = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); -// QString value1 = setting1->get("scaling-factor").toString(); -// double scaling = value1.toDouble(); - qDebug() << "availableGeometry.height();" << availableGeometry.height(); - - if (position == 0) - this->setGeometry(QRect(x + 4, y + availableGeometry.height() - Style::minh - 3, - Style::minw, Style::minh)); - else if (position == 1) { - this->setGeometry(QRect(x + 4, y + panelSize + 4, Style::minw, Style::minh)); - } else if (position == 2) { - this->setGeometry(QRect(x + panelSize + 4, y + 4, Style::minw, Style::minh)); - } else - this->setGeometry(QRect(x + availableGeometry.width() - Style::minw - 4, y + 4, - Style::minw, Style::minh)); - + if (position == BOTTOM) { + this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); + } else if (position == RIGHT) { + this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); + } m_sideBarWid->loadMinSidebar(); m_mainViewWid->loadMinMainView(); - m_mainViewWid->getQueryLineEditer()->setFocus(); - QTimer::singleShot(1, this, [ = ]() { - m_mainViewWid->getQueryLineEditer()->simulateFocusOutEvent(nullptr); - }); } } void MainWindow::panelChangedSlot(QString key) { Q_UNUSED(key); + Style::initWidStyle(); + m_mainViewWid->repaintFullWidget(); repaintWidget(); } void MainWindow::primaryScreenChangeSlot() { - repaintWidget(); + Style::initWidStyle(); + m_mainViewWid->repaintFullWidget(); + resizeWidget(); } void MainWindow::repaintWidget() { Style::initWidStyle(); - QRect availableGeometry = getScreenAvailableGeometry();/*qApp->primaryScreen()->availableGeometry();*/ this->setMinimumSize(Style::minw, Style::minh); m_line->setFixedSize(1, this->height() - 1); + m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); m_mainViewWid->repaintWidget(); resizeWidget(); } void MainWindow::resizeWidget() { - QRect availableGeometry = getScreenAvailableGeometry(); - if (QApplication::activeWindow() == this) { int position = Style::panelPosition; - int panelSize = Style::panelSize; int x = Style::primaryScreenX; int y = Style::primaryScreenY; - int width = Style::primaryScreenWidth; - int height = Style::primaryScreenHeight; + int width = Style::widthavailable; + int height = Style::heightavailable; if (m_isFullScreen) { - if (position == 0) { - this->setGeometry(QRect(x, y, availableGeometry.width(), availableGeometry.height())); - } else if (position == 1) { - this->setGeometry(QRect(x, y + panelSize, availableGeometry.width(), availableGeometry.height())); - } else if (position == 2) { - this->setGeometry(QRect(x + panelSize, y, availableGeometry.width(), availableGeometry.height())); - } else { - this->setGeometry(QRect(x, y, availableGeometry.width(), availableGeometry.height())); - } - + this->setGeometry(x, y, width, height); m_sideBarWid->loadMaxSidebar(); m_sideBarWid->setSideBarBtnGeometry(); - m_mainViewWid->resizeControl(); } else { - if (position == 0) - this->setGeometry(QRect(x + 4, y + availableGeometry.height() - Style::minh - 3, - Style::minw, Style::minh)); - else if (position == 1) { - this->setGeometry(QRect(x + 4, y + panelSize + 4, Style::minw, Style::minh)); - } else if (position == 2) { - this->setGeometry(QRect(x + panelSize + 4, y + 4, Style::minw, Style::minh)); - } else - this->setGeometry(QRect(x + availableGeometry.width() - Style::minw - 4, y + 4, - Style::minw, Style::minh)); - + if (position == BOTTOM) { + this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); + } else if (position == RIGHT) { + this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); + } m_sideBarWid->loadMinSidebar(); - m_mainViewWid->resizeControl(); + } + m_mainViewWid->resizeControl(); + } +} + +void MainWindow::keyPressEvent(QKeyEvent *e) +{ + if(e->type() == QEvent::KeyPress) + { + if((e->key() >= 0x30 && e->key() <= 0x39) || (e->key() >= 0x41 && e->key() <= 0x5a)) + { + m_mainViewWid->setLineEditFocus(e->text()); + } + if(e->key() == Qt::Key_Backspace) + { + m_mainViewWid->setLineEditFocus(""); + } + if(e->key() == Qt::Key_Escape) + { + this->hide(); + m_mainViewWid->widgetMakeZero(); } } } -//void MainWindow::setFrameStyle() -//{ -// int position=0; -// int panelSize=0; -// if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) -// { -// QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); -// if(gsetting->keys().contains(QString("panelposition"))) -// position=gsetting->get("panelposition").toInt(); -// else -// position=0; -// if(gsetting->keys().contains(QString("panelsize"))) -// panelSize=gsetting->get("panelsize").toInt(); -// else -// panelSize=46; -// } -// else -// { -// position=0; -// panelSize=46; -// } - -// QRectF rect; -// rect.setX(this->rect().x()+1); -// rect.setY(this->rect().y()+1); -// rect.setWidth(this->rect().width()-2); -// rect.setHeight(this->rect().height()-2); -// qreal radius = 0; -// QPainterPath path; -// if(!m_isFullScreen) -// { -// radius=12; -// } -// else -// { -// radius=0; -// } - -// path.moveTo(rect.topRight() - QPointF(radius, 0)); -// path.lineTo(rect.topLeft() + QPointF(radius, 0)); -// path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); -// path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); -// path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); -// path.lineTo(rect.bottomRight() - QPointF(radius, 0)); -// path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); -// path.lineTo(rect.topRight() + QPointF(0, radius)); -// path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - -// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); -//} - -void MainWindow::mainWinHideSlot() -{ - this->hide(); - m_mainViewWid->widgetMakeZero(); -} diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h index c848ce0..8dd145f 100644 --- a/src/MainWindow/mainwindow.h +++ b/src/MainWindow/mainwindow.h @@ -56,7 +56,6 @@ public: * @brief Load the main window */ void loadMainWindow(); - void getCurrentCPU(); private: @@ -70,7 +69,6 @@ private: QPropertyAnimation *m_animation=nullptr; bool m_winFlag = false; - bool is_repaint = true; DBus *m_dbus=nullptr; protected: @@ -83,7 +81,10 @@ protected: /** * @brief The query box responds to keyboard events */ - + void keyPressEvent(QKeyEvent* e); + /** + * @brief Repaint window + */ void repaintWidget(); void resizeWidget(); @@ -109,7 +110,6 @@ public Q_SLOTS: void primaryScreenChangeSlot(); void activeWindowSolt(bool flag); void mainWinShowSlot(); - void mainWinHideSlot(); public: Q_SIGNALS: diff --git a/src/ModelView/fulllistdelegate.cpp b/src/ModelView/fulllistdelegate.cpp new file mode 100644 index 0000000..f7abd3f --- /dev/null +++ b/src/ModelView/fulllistdelegate.cpp @@ -0,0 +1,109 @@ +#include "fulllistdelegate.h" +#include "src/Style/style.h" +#include "src/UtilityFunction/utility.h" +#include +#include + +FullListDelegate::FullListDelegate(QObject *parent, int page): QStyledItemDelegate(parent) +{ + m_page = page; +} + +void FullListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QRectF rect; + rect.setX(option.rect.x()); + rect.setY(option.rect.y()); + rect.setWidth(option.rect.width()); + rect.setHeight(option.rect.height()); + //QPainterPath画圆角矩形 + const qreal radius = 4; + QPainterPath path; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + painter->setRenderHint(QPainter::Antialiasing); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + painter->save(); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(Qt::white); + painter->setOpacity(0.15); + painter->drawPath(path); + painter->restore(); + } + //绘制应用图标 + painter->save(); + painter->setOpacity(1); + QIcon icon = index.data(Qt::DecorationRole).value(); + QRect iconRect; + iconRect = QRect(rect.x() + Style::AppLeftSpace, + rect.y() + Style::AppTopSpace, + Style::AppListIconSize, + Style::AppListIconSize); + icon.paint(painter, iconRect); + + //绘制是否存在固定标志 + QString desktopfp = index.data(Qt::AccessibleDescriptionRole).value(); + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + bool isLocked = false; + if (m_page == COMMON_PAGE) { + if (checkIfLocked(desktopfn)) { + isLocked = true; + QIcon icon(QString(":/data/img/mainviewwidget/lock-fs.svg")); + icon.paint(painter, QRect(iconRect.topRight().x() - 14, iconRect.topRight().y() - 2, 16, 16)); + } + } + + //绘制应用名 + QString appName = index.data(Qt::DisplayRole).value(); + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appName, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic); + QRect textRect; + textRect = QRect(rect.x() + 5, + iconRect.bottom() + Style::AppSpaceBetweenIconText, + rect.width() - 10, + rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); + + //添加最近安装蓝色标签 + bool isRecentapp = false; + if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { + isRecentapp = true; + appnameElidedText = fm.elidedText(appName, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(QColor("#4d94ff")); + int x = 0; + if (rect.width() < (10 + fm.boundingRect(appName).width())) { + x = rect.x() + 9; + } else { + x = rect.x() + (rect.width() - fm.boundingRect(appName).width()) / 2 - 8; + } + painter->drawEllipse(QPoint(x, textRect.y() + (fm.boundingRect(appName).height() - 8) / 2 + 4), + 4, 4); + } + painter->restore(); + painter->save(); + painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText); + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = fm.boundingRect(appName).width() + 10; + if (len > rect.width()) { + QToolTip::showText(QCursor::pos(), appName); + } else { + QToolTip::hideText(); + } + } +} + +QSize FullListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QSize(Style::AppListItemSizeWidth, Style::AppListItemSizeWidth); +} diff --git a/src/ModelView/fulllistdelegate.h b/src/ModelView/fulllistdelegate.h new file mode 100644 index 0000000..afbd1a6 --- /dev/null +++ b/src/ModelView/fulllistdelegate.h @@ -0,0 +1,19 @@ +#ifndef FULLLISTDELEGATE_H +#define FULLLISTDELEGATE_H + +#include +#include +#include "src/Interface/ukuimenuinterface.h" + +class FullListDelegate: public QStyledItemDelegate +{ + Q_OBJECT +public: + FullListDelegate(QObject *parent, int page); + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; +private: + int m_page; +}; + +#endif // FULLLISTDELEGATE_H diff --git a/src/ModelView/fulllistitem.cpp b/src/ModelView/fulllistitem.cpp new file mode 100644 index 0000000..f4c1e46 --- /dev/null +++ b/src/ModelView/fulllistitem.cpp @@ -0,0 +1,71 @@ +#include "fulllistitem.h" +#include +#include +#include +#include + +FullListItem::FullListItem(QWidget *parent) : QWidget(parent) +{ + +} + +void FullListItem::setAppList(QStringList list) +{ + m_appList.clear(); + m_appList = list; +} + +QIcon FullListItem::getAppIcon(QString list) +{ + XdgDesktopFile desktopfile; + desktopfile.load(list); + QString iconName = desktopfile.iconName(); + QIcon icon = XdgIcon::fromTheme(iconName); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("xpm"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("xpm")); + } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconName).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconName).arg("png")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + return icon; +} + +QString FullListItem::getAppName(QString list) +{ + XdgDesktopFile desktopfile; + desktopfile.load(list); + QString name = desktopfile.localizedValue("Name").toString(); + return name; +} diff --git a/src/ModelView/fulllistitem.h b/src/ModelView/fulllistitem.h new file mode 100644 index 0000000..39b5b23 --- /dev/null +++ b/src/ModelView/fulllistitem.h @@ -0,0 +1,20 @@ +#ifndef FULLLISTITEM_H +#define FULLLISTITEM_H + +#include +#include + +class FullListItem: public QWidget +{ + friend class FullListModel; + Q_OBJECT +public: + explicit FullListItem(QWidget *parent = nullptr); + void setAppList(QStringList list); + QIcon getAppIcon(QString list); + QString getAppName(QString list); +private: + QStringList m_appList; +}; + +#endif // FULLLISTITEM_H diff --git a/src/ModelView/fulllistmodel.cpp b/src/ModelView/fulllistmodel.cpp new file mode 100644 index 0000000..3f9192e --- /dev/null +++ b/src/ModelView/fulllistmodel.cpp @@ -0,0 +1,74 @@ +#include "fulllistmodel.h" +#include "src/UtilityFunction/utility.h" +#include +#include + +FullListModel::FullListModel(QObject *parent) : QAbstractItemModel(parent) +{ + m_item = new FullListItem; +} + +QModelIndex FullListModel::index(int row, int column, const QModelIndex &parent) const +{ + return createIndex(row, column, m_item); +} + +QModelIndex FullListModel::parent(const QModelIndex &child) const +{ + return QModelIndex(); +} + +int FullListModel::rowCount(const QModelIndex &parent) const +{ + return m_item->m_appList.count(); +} + +int FullListModel::columnCount(const QModelIndex &parent) const +{ + return 1; +} + +QVariant FullListModel::data(const QModelIndex &index, int role) const +{ + if (m_item->m_appList.size() <= (index.row())) { + return QVariant(); + } + switch (role) { + case Qt::DecorationRole: { + return m_item->getAppIcon(m_item->m_appList.at(index.row())); + } + case Qt::DisplayRole: { + return m_item->getAppName(m_item->m_appList.at(index.row())); + } + case Qt::AccessibleDescriptionRole:{ + return m_item->m_appList.at(index.row()); + } + default: + break; + } + return QVariant(); +} + +void FullListModel::setAppList(QStringList list) +{ + m_item->setAppList(list); +} + +void FullListModel::execAppDesktop(QModelIndex index) +{ + execApp(m_item->m_appList.at(index.row())); +} + +int FullListModel::showRightClickMenu(const QPoint &pos, QModelIndex index) +{ + RightClickMenu menu; + return menu.showAppBtnMenu(pos, m_item->m_appList.at(index.row())); +} + +void FullListModel::startChangeModel(QStringList list) +{ + beginResetModel(); + m_item->m_appList.clear(); + m_item->m_appList = list; + endResetModel(); +} diff --git a/src/ModelView/fulllistmodel.h b/src/ModelView/fulllistmodel.h new file mode 100644 index 0000000..0f6e893 --- /dev/null +++ b/src/ModelView/fulllistmodel.h @@ -0,0 +1,30 @@ +#ifndef FULLLISTMODEL_H +#define FULLLISTMODEL_H + +#include +#include +#include "fulllistitem.h" +#include "src/RightClickMenu/rightclickmenu.h" + +class FullListModel: public QAbstractItemModel +{ + Q_OBJECT +public: + explicit FullListModel(QObject *parent = nullptr); + QModelIndex index(int row, int column, const QModelIndex &parent) const; + QModelIndex parent(const QModelIndex &child) const; + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + + void setAppList(QStringList list); + void execAppDesktop(QModelIndex index); + void startChangeModel(QStringList list); + int showRightClickMenu(const QPoint &pos, QModelIndex index); +private: + FullListItem * m_item = nullptr; +Q_SIGNALS: + void sendItemClickedSignal(QString desktopfp); +}; + +#endif // FULLLISTMODEL_H diff --git a/src/ModelView/fulllistview.cpp b/src/ModelView/fulllistview.cpp new file mode 100644 index 0000000..cb2b349 --- /dev/null +++ b/src/ModelView/fulllistview.cpp @@ -0,0 +1,141 @@ +#include "fulllistview.h" +#include "src/Style/style.h" +#include +#include + +FullListView::FullListView(QWidget *parent, int page) : QListView(parent) +{ + m_page = page; + initWidget(); +} + +void FullListView::initWidget() +{ + m_model = new FullListModel(this); + this->setModel(m_model); + + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setViewMode(QListView::IconMode); + this->setResizeMode(QListView::Adjust); + this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth)); + this->setFrameShape(QFrame::NoFrame);//移除边框,若不添加会存在晃动 + this->setContextMenuPolicy(Qt::CustomContextMenu); + + m_delegate = new FullListDelegate(this, m_page); + this->setItemDelegate(m_delegate); + + connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); + connect(this, &FullListView::clicked, this, &FullListView::onClicked); + +} + +void FullListView::setAppList(QStringList appList) +{ + m_model->setAppList(appList); +} + +void FullListView::startChangeModel(QStringList appList) +{ + m_model->startChangeModel(appList); +} + +void FullListView::selectFirstItem() +{ + if (this->currentIndex().row() == -1) { + this->setCurrentIndex(this->model()->index(0, 0)); + } +} + +void FullListView::onClicked(QModelIndex index) +{ + Q_EMIT sendHideMainWindowSignal(); + m_model->execAppDesktop(index); +} + +void FullListView::rightClickedSlot(const QPoint &pos) +{ + Q_UNUSED(pos) + if (!(this->selectionModel()->selectedIndexes().isEmpty())) { + QModelIndex index = this->currentIndex(); + int ret = m_model->showRightClickMenu(this->mapToGlobal(pos), index); + + switch (ret) { + case 1: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 2: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + + default: + break; + } + } +} + +void FullListView::keyPressEvent(QKeyEvent *e) +{ + QRect center = visualRect(currentIndex()); + + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + break; + } + + case Qt::Key_Left: { + if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { + Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Right: { + if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { + Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Up: { + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Down: { + return QListView::keyPressEvent(e); + break; + } + + default: + return QListView::keyPressEvent(e); + break; + } + } +} + +void FullListView::mouseReleaseEvent(QMouseEvent *event) +{ + if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { + Q_EMIT sendHideMainWindowSignal(); + } else { + return QListView::mouseReleaseEvent(event); + } +} diff --git a/src/ModelView/fulllistview.h b/src/ModelView/fulllistview.h new file mode 100644 index 0000000..c019522 --- /dev/null +++ b/src/ModelView/fulllistview.h @@ -0,0 +1,37 @@ +#ifndef FULLLISTVIEW_H +#define FULLLISTVIEW_H + +#include +#include +#include "fulllistdelegate.h" +#include "src/UtilityFunction/utility.h" +#include "src/RightClickMenu/rightclickmenu.h" +#include "fulllistmodel.h" + +class FullListView : public QListView +{ + Q_OBJECT +public: + FullListView(QWidget *parent = nullptr, int page = 0); + void setAppList(QStringList appList); + void startChangeModel(QStringList appList); +protected: + void initWidget(); + void keyPressEvent(QKeyEvent *e); + void mouseReleaseEvent(QMouseEvent *event); +private: + FullListDelegate* m_delegate = nullptr; + FullListModel* m_model = nullptr; + int m_page; + +public Q_SLOTS: + void selectFirstItem(); + void onClicked(QModelIndex index);//点击item + void rightClickedSlot(const QPoint &pos); +Q_SIGNALS: + void sendSetslidebar(int value); + void sendHideMainWindowSignal(); + void sendUpdateAppListSignal(); +}; + +#endif // FULLLISTVIEW_H diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile index f22ce73..16b48ba 100644 --- a/src/QtSingleApplication/QtLockedFile +++ b/src/QtSingleApplication/QtLockedFile @@ -1,19 +1 @@ -/* - * 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 #include diff --git a/src/RightClickMenu/menubox.h b/src/RightClickMenu/menubox.h index caa87ba..627ed8f 100644 --- a/src/RightClickMenu/menubox.h +++ b/src/RightClickMenu/menubox.h @@ -1,20 +1,3 @@ -/* - * 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 diff --git a/src/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp index e7da0f9..5cda046 100644 --- a/src/RightClickMenu/rightclickmenu.cpp +++ b/src/RightClickMenu/rightclickmenu.cpp @@ -23,7 +23,8 @@ RightClickMenu::RightClickMenu(QWidget *parent): QWidget(parent) { - m_cmdProc = new QProcess; + m_cmdProc=new QProcess; + m_whiteList.append("kylin-screenshot.desktop"); m_whiteList.append("ukui-notebook.desktop"); m_whiteList.append("ukui-clock.desktop"); @@ -43,69 +44,59 @@ RightClickMenu::RightClickMenu(QWidget *parent): m_whiteList.append("peony.desktop"); m_whiteList.append("engrampa.desktop"); - if (isPANGU || isHuaWeiPC) { - m_whiteList.append("org.gnome.FileRoller.desktop"); - m_whiteList.append("mate-terminal.desktop"); - m_whiteList.append("hwaudioui.desktop"); - } + m_ukuiMenuInterface=new UkuiMenuInterface; - m_ukuiMenuInterface = new UkuiMenuInterface; } RightClickMenu::~RightClickMenu() { delete m_cmdProc; - - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } QPixmap RightClickMenu::getIconPixmap(QString iconstr, int type) { - const auto ratio = devicePixelRatioF(); + const auto ratio=devicePixelRatioF(); QPixmap pixmap; - if (type == 0) { - pixmap = loadSvg(iconstr, 16 * ratio); + if(type==0) + { + pixmap=loadSvg(iconstr,16*ratio); pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - } else { - QIcon icon = QIcon::fromTheme(iconstr); - QPixmap pixmap_1 = icon.pixmap(QSize(16 * ratio, 16 * ratio)); - pixmap = drawSymbolicColoredPixmap(pixmap_1); } - + else + { + QIcon icon=QIcon::fromTheme(iconstr); + QPixmap pixmap_1=icon.pixmap(QSize(16*ratio,16*ratio)); + pixmap=drawSymbolicColoredPixmap(pixmap_1); + } return pixmap; } void RightClickMenu::fixToAllActionTriggerSlot() { - m_actionNumber = 1; + m_actionNumber=1; QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); - updateDataBaseTableType(desktopfn, 1); + QString desktopfn=fileInfo.fileName(); + updateDataBaseTableType(desktopfn,1); } void RightClickMenu::unfixedFromAllActionTriggerSlot() { - m_actionNumber = 2; + m_actionNumber=2; QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); - updateDataBaseTableType(desktopfn, 0); + QString desktopfn=fileInfo.fileName(); + updateDataBaseTableType(desktopfn,0); } void RightClickMenu::fixToTaskbarActionTriggerSlot() { -// QDBusInterface iface("com.ukui.panel.desktop", -// "/", -// "com.ukui.panel.desktop", -// QDBusConnection::sessionBus()); -// QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); - QDBusMessage message = QDBusMessage::createSignal("/taskbar/quicklaunch", "org.ukui.panel.taskbar", "AddToTaskbar"); - message << m_desktopfp; - QDBusConnection::sessionBus().send(message); - m_actionNumber = 3; + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); + m_actionNumber=3; } void RightClickMenu::unfixedFromTaskbarActionTriggerSlot() @@ -114,150 +105,146 @@ void RightClickMenu::unfixedFromTaskbarActionTriggerSlot() "/", "com.ukui.panel.desktop", QDBusConnection::sessionBus()); - QDBusReply ret = iface.call("RemoveFromTaskbar", m_desktopfp); - m_actionNumber = 4; + QDBusReply ret=iface.call("RemoveFromTaskbar",m_desktopfp); + m_actionNumber=4; } void RightClickMenu::addToDesktopActionTriggerSlot() { - QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QString path=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QFileInfo fileInfo(m_desktopfp); - QString desktopfn = fileInfo.fileName(); + QString desktopfn=fileInfo.fileName(); QFile file(m_desktopfp); - QString newname = QString(path + "/" + desktopfn); - bool ret = file.copy(QString(path + "/" + desktopfn)); - - if (ret) { + QString newname=QString(path+"/"+desktopfn); + bool ret=file.copy(QString(path+"/"+desktopfn)); + if(ret) + { char command[200]; - sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data()); + sprintf(command,"chmod a+x %s",newname.toLocal8Bit().data()); QProcess::startDetached(QString::fromLocal8Bit(command)); } - - m_actionNumber = 5; + m_actionNumber=5; } void RightClickMenu::uninstallActionTriggerSlot() { -// if(!checkOsRelease()) -// { - QString cmd = QString("kylin-uninstaller %1") - .arg(m_desktopfp.toLocal8Bit().data()); - bool ret = QProcess::startDetached(cmd); - qDebug() << "卸载:" << cmd << ret; - qDebug() << "kylin-uninstaller"; -// } -// else -// { -// QString cmd=QString("dpkg -S "+m_desktopfp); -// m_cmdProc->start("sh",QStringList()<<"-c"<waitForFinished(); -// QString output=m_cmdProc->readAllStandardOutput().trimmed(); -// QString packageName=output.split(":").at(0); -// cmd.clear(); -// cmd=QString("kylin-installer -remove %1") -// .arg(packageName.toLocal8Bit().data()); -// bool ret=QProcess::startDetached(cmd); -// qDebug()<<"卸载:"<start("sh",QStringList()<<"-c"<waitForFinished(); + QString output=m_cmdProc->readAllStandardOutput().trimmed(); + QString packageName=output.split(":").at(0); + cmd.clear(); + cmd=QString("kylin-installer -remove %1") + .arg(packageName.toLocal8Bit().data()); + bool ret=QProcess::startDetached(cmd); + qDebug()<<"卸载:"<m_desktopfp.clear(); - this->m_desktopfp = desktopfp; + this->m_desktopfp=desktopfp; + MenuBox m_showAppMenu; connect(&m_showAppMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); m_showAppMenu.setWindowFlag(Qt::Popup); + //添加菜单项,指定图标、名称、响应函数 QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - - if (!checkIfLocked(desktopfn)) - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to all"), - this, SLOT(fixToAllActionTriggerSlot())); + QString desktopfn=fileInfo.fileName(); + if(!checkIfLocked(desktopfn)) + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg",0)),tr("Pin to all"), + this,SLOT(fixToAllActionTriggerSlot())); else - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from all"), - this, SLOT(unfixedFromAllActionTriggerSlot())); - + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from all"), + this,SLOT(unfixedFromAllActionTriggerSlot())); QDBusInterface iface("com.ukui.panel.desktop", "/", "com.ukui.panel.desktop", QDBusConnection::sessionBus()); - QDBusReply ret = iface.call("CheckIfExist", desktopfp); - if (!ret) - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to taskbar"), - this, SLOT(fixToTaskbarActionTriggerSlot())); + QDBusReply ret=iface.call("CheckIfExist",desktopfp); + if(!ret) + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg",0)),tr("Pin to taskbar"), + this,SLOT(fixToTaskbarActionTriggerSlot())); else - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from taskbar"), - this, SLOT(unfixedFromTaskbarActionTriggerSlot())); + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from taskbar"), + this,SLOT(unfixedFromTaskbarActionTriggerSlot())); m_showAppMenu.addAction(tr("Add to desktop shortcuts"), - this, SLOT(addToDesktopActionTriggerSlot())); + this,SLOT(addToDesktopActionTriggerSlot())); //检查桌面快捷方式是否存在 - QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - QString path = QString(desktopPath + "/" + QFileInfo(m_desktopfp).fileName()); - - if (QFile(path).exists()) { - m_showAppMenu.actions().at(2)->setEnabled(false); //存在时禁用 - } - + QString desktopPath=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QString path=QString(desktopPath+"/"+QFileInfo(m_desktopfp).fileName()); + if(QFile(path).exists()) + m_showAppMenu.actions().at(2)->setEnabled(false);//存在时禁用 m_showAppMenu.addSeparator(); - - if (!m_whiteList.contains(desktopfn)) - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg", 0)), tr("Uninstall"), - this, SLOT(uninstallActionTriggerSlot())); + if(!m_whiteList.contains(desktopfn)) + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg",0)),tr("Uninstall"), + this,SLOT(uninstallActionTriggerSlot())); m_showAppMenu.setAttribute(Qt::WA_TranslucentBackground); m_showAppMenu.setAttribute(Qt::WA_DeleteOnClose); @@ -268,18 +255,19 @@ int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) int RightClickMenu::showShutdownMenu(const QPoint &pos) { - m_actionNumber = 0; + m_actionNumber=0; MenuBox m_showShutMenu; connect(&m_showShutMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); m_showShutMenu.setWindowFlag(Qt::Popup); - m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic", 1)), tr("Sleep"), - this, SLOT(hibernateActionTriggerSlot())); //休眠睡眠相同 - m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic", 1)), tr("Log Out"), - this, SLOT(logoutActionTriggerSlot())); - m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic", 1)), tr("Restart"), - this, SLOT(rebootActionTriggerSlot())); - m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic", 1)), tr("Power Off"), - this, SLOT(shutdownActionTriggerSlot())); + + m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Sleep"), + this,SLOT(hibernateActionTriggerSlot()));//休眠睡眠相同 + m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic",1)),tr("Log Out"), + this,SLOT(logoutActionTriggerSlot())); + m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic",1)),tr("Restart"), + this,SLOT(rebootActionTriggerSlot())); + m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic",1)),tr("Power Off"), + this,SLOT(shutdownActionTriggerSlot())); m_showShutMenu.setAttribute(Qt::WA_TranslucentBackground); m_showShutMenu.setAttribute(Qt::WA_DeleteOnClose); m_showShutMenu.raise(); @@ -290,9 +278,9 @@ int RightClickMenu::showShutdownMenu(const QPoint &pos) int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) { - m_actionNumber = 0; + m_actionNumber=0; this->m_desktopfp.clear(); - this->m_desktopfp = desktopfp; + this->m_desktopfp=desktopfp; MenuBox m_showOtherMenu; connect(&m_showOtherMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); m_showOtherMenu.setWindowFlag(Qt::Popup); @@ -300,6 +288,7 @@ int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) // "/", // "com.ukui.panel.desktop", // QDBusConnection::sessionBus()); + // QDBusReply ret=iface.call("CheckIfExist",this->m_desktopfp); // if(!ret) // menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"), @@ -307,11 +296,12 @@ int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) // else // menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"), // this,SLOT(unfixedFromTaskbarActionTriggerSlot())); - m_showOtherMenu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg", 0)), tr("Personalize this list"), - this, SLOT(otherListActionTriggerSlot())); + m_showOtherMenu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg",0)),tr("Personalize this list"), + this,SLOT(otherListActionTriggerSlot())); m_showOtherMenu.setAttribute(Qt::WA_TranslucentBackground); m_showOtherMenu.setAttribute(Qt::WA_DeleteOnClose); m_showOtherMenu.exec(pos); qDebug() << "RightClickMenu::showOtherMenu(QString desktopfp)"; + return m_actionNumber; } diff --git a/src/RightClickMenu/rightclickmenu.h b/src/RightClickMenu/rightclickmenu.h index 5760972..5714262 100644 --- a/src/RightClickMenu/rightclickmenu.h +++ b/src/RightClickMenu/rightclickmenu.h @@ -37,7 +37,6 @@ #include "src/Interface/ukuimenuinterface.h" #include "src/Style/style.h" #include "menubox.h" -#include class RightClickMenu : public QWidget { diff --git a/src/RightClickMenu/uninstallwhitelist.cpp b/src/RightClickMenu/uninstallwhitelist.cpp new file mode 100644 index 0000000..51e5cbe --- /dev/null +++ b/src/RightClickMenu/uninstallwhitelist.cpp @@ -0,0 +1,84 @@ +/* + * 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 + +UninstallWhitelist *UninstallWhitelist::instance = nullptr; + +UninstallWhitelist::UninstallWhitelist() +{ + m_whiteList.append("kylin-screenshot.desktop"); + m_whiteList.append("ukui-notebook.desktop"); + m_whiteList.append("ukui-clock.desktop"); + m_whiteList.append("kylin-calculator.desktop"); + m_whiteList.append("kylin-recorder.desktop"); + m_whiteList.append("kylin-software-center.desktop"); + m_whiteList.append("kylin-camera.desktop"); + m_whiteList.append("biometric-manager.desktop"); + m_whiteList.append("yhkylin-backup-tools.desktop"); + m_whiteList.append("box-manager.desktop"); + m_whiteList.append("ukui-system-monitor.desktop"); + m_whiteList.append("ksc-defender.desktop"); + m_whiteList.append("logview.desktop"); + m_whiteList.append("kylin-service-support.desktop"); + m_whiteList.append("kylin-user-guide.desktop"); + m_whiteList.append("ukui-control-center.desktop"); + m_whiteList.append("peony.desktop"); + m_whiteList.append("engrampa.desktop"); + + if (isHuaWei9006C || isHuaWeiPC) { + m_whiteList.append("org.gnome.FileRoller.desktop"); + m_whiteList.append("mate-terminal.desktop"); + m_whiteList.append("hwaudioui.desktop"); + } +} + +UninstallWhitelist *UninstallWhitelist::getInstance() +{ + if (instance == nullptr) { + instance = new UninstallWhitelist(); + } + + return instance; +} + +QStringList UninstallWhitelist::getPkgNameWhiteList() +{ + QStringList pkgNameList; + + Q_FOREACH (QString desktop, m_whiteList) { + QProcess *processPkgName = new QProcess(); + processPkgName->start(QString("dpkg -S /usr/share/applications/%1").arg(desktop)); + connect(processPkgName, static_cast(&QProcess::finished), this, [ = ]() { + processPkgName->deleteLater(); + }); + processPkgName->waitForFinished(); + QString pkgName = processPkgName->readAll(); + pkgName = pkgName.left(pkgName.indexOf(":")); + pkgNameList.append(pkgName); + } + + return pkgNameList; +} + +QStringList UninstallWhitelist::getWhiteList() +{ + return m_whiteList; +} diff --git a/src/RightClickMenu/uninstallwhitelist.h b/src/RightClickMenu/uninstallwhitelist.h new file mode 100644 index 0000000..a478292 --- /dev/null +++ b/src/RightClickMenu/uninstallwhitelist.h @@ -0,0 +1,47 @@ +/* + * 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 + +class UninstallWhitelist : public QObject +{ + Q_OBJECT + +public: + static UninstallWhitelist *getInstance(); + /** + * @brief 获取不可卸载包名列表 + * @return + */ + QStringList getPkgNameWhiteList(); + /** + * @brief 获取不可卸载desktop列表 + * @return + */ + QStringList getWhiteList(); +private: + UninstallWhitelist(); +private: + static UninstallWhitelist *instance; + + QStringList m_whiteList; +}; + +#endif // UNINSTALLWHITELIST_H diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp index 49ee973..52c16f9 100644 --- a/src/SearchResultWidget/fullsearchresultwidget.cpp +++ b/src/SearchResultWidget/fullsearchresultwidget.cpp @@ -30,43 +30,44 @@ FullSearchResultWidget::FullSearchResultWidget(QWidget *parent) : FullSearchResultWidget::~FullSearchResultWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } void FullSearchResultWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setAttribute(Qt::WA_StyledBackground,true); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->setContentsMargins(0, 0, 0, 0); - m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + + QHBoxLayout* mainLayout=new QHBoxLayout; + mainLayout->setContentsMargins(0,0,0,0); + m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); mainLayout->addItem(m_spaceItem); - m_listView = new FullListView(this, 3); + m_listView=new FullListView(this,3); this->setLayout(mainLayout); - m_scrollArea = new ScrollArea; - m_scrollAreaWid = new ScrollAreaWid; + + m_scrollArea=new ScrollArea; + m_scrollAreaWid=new ScrollAreaWid; m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); + m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); m_scrollArea->setWidget(m_scrollAreaWid); m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout = new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout=new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); m_scrollAreaWidLayout->setSpacing(10); m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); mainLayout->addWidget(m_scrollArea); m_scrollAreaWidLayout->addWidget(m_listView); - m_scrollAreaWidLayout->addItem(new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding)); + m_scrollAreaWidLayout->addItem(new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding)); + m_data.clear(); m_listView->addData(m_data); - m_ukuiMenuInterface = new UkuiMenuInterface; - connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); - connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal); + m_ukuiMenuInterface=new UkuiMenuInterface; + + connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication); + connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullSearchResultWidget::sendHideMainWindowSignal); } /** @@ -81,31 +82,31 @@ void FullSearchResultWidget::execApplication(QString desktopfp) void FullSearchResultWidget::updateAppListView(QVector arg) { m_data.clear(); - - Q_FOREACH (QStringList appinfo, arg) { + Q_FOREACH(QStringList appinfo,arg) m_data.append(appinfo.at(0)); - } - m_listView->updateData(m_data); resizeScrollAreaControls(); } void FullSearchResultWidget::resizeScrollAreaControls() { - QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); - QWidget *wid = widItem->widget(); - FullListView *listview = qobject_cast(wid); + QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0); + QWidget* wid=widItem->widget(); + FullListView* listview=qobject_cast(wid); listview->adjustSize(); - int dividend = (m_scrollArea->width() - Style::SliderSize) / Style::AppListGridSizeWidth; - int rowcount = 0; + int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; + int rowcount=0; + if(listview->model()->rowCount()%dividend>0) + { + rowcount=listview->model()->rowCount()/dividend+1; + } + else + { + rowcount=listview->model()->rowCount()/dividend; - if (listview->model()->rowCount() % dividend > 0) { - rowcount = listview->model()->rowCount() / dividend + 1; - } else { - rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_scrollArea->width() - Style::SliderSize + 1, listview->gridSize().height()*rowcount); + listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); m_scrollArea->widget()->adjustSize(); } @@ -113,29 +114,27 @@ void FullSearchResultWidget::repaintWidget() { this->setFixedSize(Style::MainViewWidWidth, Style::AppListWidHeight); - m_scrollArea->setFixedSize(Style::AppListWidWidth, this->height()); -// this->layout()->setContentsMargins(Style::LeftWidWidth,0,0,0); + m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); m_scrollAreaWidLayout->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; - m_listView = new FullListView(this, 3); - m_scrollAreaWidLayout->insertWidget(0, m_listView); + m_listView=new FullListView(this,3); + m_scrollAreaWidLayout->insertWidget(0,m_listView); + m_data.clear(); m_listView->addData(m_data); resizeScrollAreaControls(); - connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); - connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal); + connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication); + connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullSearchResultWidget::sendHideMainWindowSignal); } void FullSearchResultWidget::moveScrollBar(int type) { - int height = Style::primaryScreenHeight; - - if (type == 0) { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); - } else { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); - } + int height=Style::primaryScreenHeight; + if(type==0) + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-height*100/1080); + else + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+height*100/1080); } void FullSearchResultWidget::setViewFocus() diff --git a/src/SearchResultWidget/pinyinWithTone.txt b/src/SearchResultWidget/pinyinWithTone.txt index ef4f6e3..41eaeec 100644 --- a/src/SearchResultWidget/pinyinWithTone.txt +++ b/src/SearchResultWidget/pinyinWithTone.txt @@ -6669,7 +6669,7 @@ gāng 冈 rǎn,nán,dān 冉 cè 冊 jiōng,jiǒng 冋 -cè 册 +cè,zhà 册 zài 再 guǎ 冎 jiǒng,jiōng 冏 diff --git a/src/SearchResultWidget/pinyinWithoutTone.txt b/src/SearchResultWidget/pinyinWithoutTone.txt index 7267609..07421f0 100644 --- a/src/SearchResultWidget/pinyinWithoutTone.txt +++ b/src/SearchResultWidget/pinyinWithoutTone.txt @@ -6669,7 +6669,7 @@ gang 冈 dan,nan,ran 冉 ce 冊 jiong 冋 -ce 册 +zha,ce 册 zai 再 gua 冎 jiong 冏 diff --git a/src/SearchResultWidget/searchappthread.cpp b/src/SearchResultWidget/searchappthread.cpp index a332168..d53a5e4 100644 --- a/src/SearchResultWidget/searchappthread.cpp +++ b/src/SearchResultWidget/searchappthread.cpp @@ -22,127 +22,108 @@ SearchAppThread::SearchAppThread() { - m_ukuiMenuInterface = new UkuiMenuInterface; + m_ukuiMenuInterface=new UkuiMenuInterface; } SearchAppThread::~SearchAppThread() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } void SearchAppThread::run() { m_appInfoVector.clear(); - m_appInfoVector = UkuiMenuInterface::appInfoVector; + m_appInfoVector=UkuiMenuInterface::appInfoVector; m_searchResultVector.clear(); - m_searchFirstVector.clear(); - m_searchRestVector.clear(); - - if (!this->m_keyWord.isEmpty()) { - QString str = m_ukuiMenuInterface->getAppNamePinyin(m_keyWord); - int index = 0; -// if(str.size()==1) -// { -// int num=static_cast(str.toLocal8Bit().at(0)); -// QStringList searchDesktopList; -// searchDesktopList.clear(); -// if(num>=65 && num<=90) -// { -// for(int i=0;igetAppNamePinyin(m_appInfoVector.at(index).at(1)); -//// QString appEnglishName=m_appInfoVector.at(index).at(2); -// QString appNameFl=m_appInfoVector.at(index).at(3); - -// if(appNameFl==str)//匹配首字母 -// { -// m_searchResultVector.append(m_appInfoVector.at(index)); -// } -// index++; -// } -// } -//// else if(num<48 || (num>57 && num<65) || num>90) -//// for(int i=0;igetAppName(searchDesktopList.at(i))); -// } -// } -// else - //{ - while (index < m_appInfoVector.size()) { - // QString appNamePy=m_ukuiMenuInterface->getAppNamePinyin(m_appInfoVector.at(index).at(1)); - QStringList appNameLs; - QStringList appNameFls; - QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords(m_appInfoVector.at(index).at(1)); - - // QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords("奇安信可信"); - for (int i = 0; i < appNamePyLst.size() / 2; i++) { - appNameLs.append(appNamePyLst.at(i * 2)); - appNameFls.append(appNamePyLst.at(i * 2 + 1)); + if(!this->m_keyWord.isEmpty()) + { + QString str=m_ukuiMenuInterface->getAppNamePinyin(m_keyWord); + int index=0; + if(str.size()==1) + { + int num=static_cast(str.toLocal8Bit().at(0)); + QStringList searchDesktopList; + searchDesktopList.clear(); + if(num>=65 && num<=90) + { + for(int i=0;igetAppNamePinyin(m_appInfoVector.at(index).at(1)); +// QString appEnglishName=m_appInfoVector.at(index).at(2); + QString appNameFl=m_appInfoVector.at(index).at(3); - QString appName = m_appInfoVector.at(index).at(1); - QString appEnglishName = m_appInfoVector.at(index).at(2); - //QString appNameFls=m_appInfoVector.at(index).at(4); - - if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { //中文正则表达式 - if (appName.toUpper().contains(m_keyWord.toUpper())) { - m_searchResultVector.append(m_appInfoVector.at(index)); + if(appNameFl==str)//匹配首字母 + { + m_searchResultVector.append(m_appInfoVector.at(index)); + } + index++; } - } else { - for (int var = 0; var < appNameLs.size(); ++var) { - if (appNameLs[var].left(str.length()).contains(str, Qt::CaseInsensitive) || - appNameFls[var].left(str.length()).contains(str, Qt::CaseInsensitive)) { - m_searchFirstVector.append(m_appInfoVector.at(index)); - break; - } else if (appNameLs[var].contains(str, Qt::CaseInsensitive) || - appNameFls[var].contains(str, Qt::CaseInsensitive) || - appEnglishName.contains(str, Qt::CaseInsensitive)) { - m_searchRestVector.append(m_appInfoVector.at(index)); - break; + } +// else if(num<48 || (num>57 && num<65) || num>90) +// for(int i=0;igetAppName(searchDesktopList.at(i))); + } + } + else + { + while(indexgetAppNamePinyin(m_appInfoVector.at(index).at(1)); + QStringList appNameLs; + QStringList appNameFls; + QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords(m_appInfoVector.at(index).at(1)); + // QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords("奇安信可信"); + for(int i = 0; i < appNamePyLst.size()/2; i++) + { + appNameLs.append(appNamePyLst.at(i * 2)); + appNameFls.append(appNamePyLst.at(i * 2 + 1)); + } + + QString appName = m_appInfoVector.at(index).at(1); + QString appEnglishName=m_appInfoVector.at(index).at(2); + //QString appNameFls=m_appInfoVector.at(index).at(4); + + if(m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+")))//中文正则表达式 + { + if(appName.toUpper().contains(m_keyWord.toUpper())) + m_searchResultVector.append(m_appInfoVector.at(index)); + } + else + { + for (int var = 0; var < appNameLs.size(); ++var) + { + if(appNameLs[var].contains(str,Qt::CaseInsensitive) || + appNameFls[var].contains(str,Qt::CaseInsensitive) || + appEnglishName.contains(str,Qt::CaseInsensitive)) + { + m_searchResultVector.append(m_appInfoVector.at(index)); + break; + } } } + index++; } - - index++; - //} } } - qSort(m_searchFirstVector.begin(), m_searchFirstVector.end(), UkuiMenuInterface::cmpApp); - qSort(m_searchRestVector.begin(), m_searchRestVector.end(), UkuiMenuInterface::cmpApp); - - if (m_searchResultVector.size() != 0) { - qSort(m_searchResultVector.begin(), m_searchResultVector.end(), UkuiMenuInterface::cmpApp); - } - - for (int i = 0; i < m_searchFirstVector.size(); i++) { - m_searchResultVector.append(m_searchFirstVector.at(i)); - } - - for (int i = 0; i < m_searchRestVector.size(); i++) { - m_searchResultVector.append(m_searchRestVector.at(i)); - } - + qSort(m_searchResultVector.begin(),m_searchResultVector.end(),UkuiMenuInterface::cmpApp); Q_EMIT sendSearchResult(m_searchResultVector); } void SearchAppThread::recvSearchKeyword(QString arg) { this->m_keyWord.clear(); - this->m_keyWord = arg; + this->m_keyWord=arg; } diff --git a/src/SearchResultWidget/searchappthread.h b/src/SearchResultWidget/searchappthread.h index 9447d73..12cd9ee 100644 --- a/src/SearchResultWidget/searchappthread.h +++ b/src/SearchResultWidget/searchappthread.h @@ -33,8 +33,6 @@ public: private: QString m_keyWord; QVector m_searchResultVector; - QVector m_searchFirstVector; - QVector m_searchRestVector; UkuiMenuInterface* m_ukuiMenuInterface=nullptr; QVector m_appInfoVector; diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp index 691eff5..10c8853 100644 --- a/src/SearchResultWidget/searchresultwidget.cpp +++ b/src/SearchResultWidget/searchresultwidget.cpp @@ -30,28 +30,26 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) : SearchResultWidget::~SearchResultWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; } void SearchResultWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); - this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); + this->setAttribute(Qt::WA_StyledBackground,true); + this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); this->setFocusPolicy(Qt::StrongFocus); - m_listView = new ListView(this, this->width() - 6, this->height() - 6, 3); - m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + m_listView=new ListView(this,this->width()-6,this->height()-6,3); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); + m_data.clear(); m_listView->addData(m_data); - m_ukuiMenuInterface = new UkuiMenuInterface; - connect(m_listView, &ListView::sendItemClickedSignal, this, &SearchResultWidget::execApplication); - connect(m_listView, &ListView::sendHideMainWindowSignal, this, &SearchResultWidget::sendHideMainWindowSignal); - connect(m_listView, &ListView::sendMainWinActiveSignal, this, &SearchResultWidget::sendMainWinActiveSignal); + m_ukuiMenuInterface=new UkuiMenuInterface; + + connect(m_listView,&ListView::sendItemClickedSignal,this,&SearchResultWidget::execApplication); + connect(m_listView,&ListView::sendHideMainWindowSignal,this,&SearchResultWidget::sendHideMainWindowSignal); } /** @@ -60,34 +58,30 @@ void SearchResultWidget::initUi() void SearchResultWidget::execApplication(QStringList arg) { Q_EMIT sendHideMainWindowSignal(); - QString desktopfp = arg.at(0); + QString desktopfp=arg.at(0); execApp(desktopfp); } void SearchResultWidget::updateAppListView(QVector arg) { m_data.clear(); - - Q_FOREACH (QStringList appinfo, arg) { - m_data.append(QStringList() << appinfo.at(0) << "1"); - } - + Q_FOREACH(QStringList appinfo,arg) + m_data.append(QStringList()<updateData(m_data); } void SearchResultWidget::moveScrollBar(int type) { - if (type == 0) { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - 100); - } else { - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + 100); - } + if(type==0) + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-100); + else + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+100); } void SearchResultWidget::repaintWidget() { - this->setFixedSize(Style::defaultMainViewWidWidth, Style::defaultContentWidHeight); - m_listView->setGeometry(QRect(6, 0, this->width() - 6, this->height() - 6)); + this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); + m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); m_listView->show(); } diff --git a/src/SearchResultWidget/searchresultwidget.h b/src/SearchResultWidget/searchresultwidget.h index ce3b5ec..2897b23 100644 --- a/src/SearchResultWidget/searchresultwidget.h +++ b/src/SearchResultWidget/searchresultwidget.h @@ -59,8 +59,8 @@ public: void setViewFocus(); private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - ListView *m_listView = nullptr; + UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + ListView* m_listView=nullptr; QVector m_data; protected: @@ -81,8 +81,6 @@ Q_SIGNALS: * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); - - void sendMainWinActiveSignal(bool flag); }; #endif // SEARCHRESULTWIDGET_H diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp index a14ce78..9177982 100644 --- a/src/SideBarWidget/sidebarwidget.cpp +++ b/src/SideBarWidget/sidebarwidget.cpp @@ -35,10 +35,9 @@ SideBarWidget::SideBarWidget(QWidget *parent) : SideBarWidget::~SideBarWidget() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete m_ukuiMenuInterface; +// delete m_shutDownMenu; +// delete m_otherMenu; } /** @@ -47,8 +46,9 @@ SideBarWidget::~SideBarWidget() void SideBarWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground, true); + this->setAttribute(Qt::WA_StyledBackground,true); this->setFocusPolicy(Qt::NoFocus); + addSidebarBtn(); loadMinSidebar(); m_minMaxBtn->installEventFilter(this); @@ -61,36 +61,39 @@ void SideBarWidget::initUi() m_controlBtn->installEventFilter(this); m_trashBtn->installEventFilter(this); m_shutDownBtn->installEventFilter(this); - m_ukuiMenuInterface = new UkuiMenuInterface; -// m_shutDownMenu=new RightClickMenu; -// m_otherMenu=new RightClickMenu; + m_ukuiMenuInterface=new UkuiMenuInterface; + // m_shutDownMenu=new RightClickMenu; + // m_otherMenu=new RightClickMenu; } -bool SideBarWidget::eventFilter(QObject *target, QEvent *event) +bool SideBarWidget::eventFilter(QObject * target , QEvent * event ) { - if (event->type() == QEvent::KeyPress) { + + if( event->type() == QEvent::KeyPress ) + { QKeyEvent *ke = (QKeyEvent *)event; - - if (ke->key() == Qt::Key_Tab) { + if( ke->key() == Qt::Key_Tab ) + { Q_EMIT setFocusToMainWin(); - // return true; + // return true; } - - if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Left) { - if (m_minMaxBtn->hasFocus()) { + if(ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Left) + { + if(m_minMaxBtn->hasFocus()) + { m_shutDownBtn->setFocus(); return true; } } - - if (ke->key() == Qt::Key_Down || ke->key() == Qt::Key_Right) { - if (m_shutDownBtn->hasFocus()) { - this->setFocus(); + if(ke->key() == Qt::Key_Down || ke->key() == Qt::Key_Right) + { + if(m_shutDownBtn->hasFocus()) + { + this->setFocus(); } } } - - return QWidget::eventFilter(target, event); + return QWidget::eventFilter(target , event); } @@ -100,21 +103,21 @@ bool SideBarWidget::eventFilter(QObject *target, QEvent *event) */ void SideBarWidget::addSidebarBtn() { - m_mainWidget = new QWidget; + m_mainWidget=new QWidget; m_mainWidget->setParent(this); - m_mainWidgetLayout = new QVBoxLayout; - m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6); + m_mainWidgetLayout=new QVBoxLayout; + m_mainWidgetLayout->setContentsMargins(0,0,0,6); m_mainWidgetLayout->setSpacing(10); m_mainWidget->setLayout(m_mainWidgetLayout); - // m_mainWidget->setFocusPolicy(Qt::StrongFocus); + // m_mainWidget->setFocusPolicy(Qt::StrongFocus); // m_mainWidget->setAutoFillBackground(true); // QPalette palette; // palette.setBrush(QPalette::Background,Qt::red); // m_mainWidget->setPalette(palette); //放大缩小按钮界面 - m_minMaxWidget = new QWidget; - m_minMaxLayout = new QHBoxLayout; - m_minMaxBtn = new QPushButton; + m_minMaxWidget=new QWidget; + m_minMaxLayout=new QHBoxLayout; + m_minMaxBtn=new QPushButton; m_minMaxBtn->setFlat(true); m_minMaxBtn->setProperty("useButtonPalette", true); // m_minMaxBtn->setProperty("doNotAnimate",true); @@ -122,6 +125,7 @@ void SideBarWidget::addSidebarBtn() // m_minMaxBtn->setFlat(true); // m_minMaxBtn->setProperty("doNotAnimate",true); // m_minMaxBtn->setShortcut(QKeySequence::InsertParagraphSeparator); + // m_minMaxBtn->setShortcut(Qt::Key_Enter); // m_minMaxBtn->setShortcut(Qt::Key_Return); // QShortcut *key_1 = new QShortcut(QKeySequence(Qt::Key_Enter),this); @@ -132,101 +136,97 @@ void SideBarWidget::addSidebarBtn() m_minMaxWidget->setLayout(m_minMaxLayout); // m_minMaxWidget->setAttribute(Qt::WA_StyledBackground,true); // m_minMaxWidget->hasFocus(); + //分类按钮 m_buttonList.clear(); - m_allBtn = new QPushButton; - initBtn(m_allBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"), tr("All"), 0); - m_letterBtn = new QPushButton; - initBtn(m_letterBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"), tr("Letter"), 1); - m_functionBtn = new QPushButton; - initBtn(m_functionBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"), tr("Function"), 2); - int id = 0; - - Q_FOREACH (QAbstractButton *btn, m_buttonList) { - // m_btnGroup->addButton(btn,id++); + m_allBtn=new QPushButton; + initBtn(m_allBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"),tr("All"),0); + m_letterBtn=new QPushButton; + initBtn(m_letterBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"),tr("Letter"),1); + m_functionBtn=new QPushButton; + initBtn(m_functionBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"),tr("Function"),2); + int id=0; + Q_FOREACH (QAbstractButton* btn, m_buttonList) { + // m_btnGroup->addButton(btn,id++); btn->setCheckable(true); } - QString usericon = getUserIcon(); - QString username = getUserName(); - m_userIconBtn = new QPushButton; - initBtn(m_userIconBtn, usericon, username, 3); - m_personalBtn = new QPushButton; - initBtn(m_personalBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"), tr("Personal"), 4); - m_trashBtn = new QPushButton; - initBtn(m_trashBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"), tr("Trash"), 5); - m_computerBtn = new QPushButton; - initBtn(m_computerBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"), tr("Computer"), 6); - m_controlBtn = new QPushButton; - initBtn(m_controlBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/control.svg"), tr("Settings"), 7); - m_shutDownBtn = new QPushButton; - initBtn(m_shutDownBtn, QString::fromLocal8Bit(":/data/img/sidebarwidget/shutdown.svg"), tr("Power"), 8); + QString usericon=getUserIcon(); + QString username=getUserName(); + m_userIconBtn=new QPushButton; + initBtn(m_userIconBtn,usericon,username,3); + m_personalBtn=new QPushButton; + initBtn(m_personalBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"),tr("Personal"),4); + m_trashBtn=new QPushButton; + initBtn(m_trashBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"),tr("Trash"),5); + m_computerBtn=new QPushButton; + initBtn(m_computerBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"),tr("Computer"),6); + m_controlBtn=new QPushButton; + initBtn(m_controlBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/control.svg"),tr("Settings"),7); + m_shutDownBtn=new QPushButton; + initBtn(m_shutDownBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/shutdown.svg"),tr("Power"),8); connect(m_allBtn, &QPushButton::clicked, this, &SideBarWidget::btnAllClickedSlot); - connect(m_letterBtn, &QPushButton::clicked, this, &SideBarWidget::btnLetterClickedSlot); + connect(m_letterBtn ,&QPushButton::clicked, this, &SideBarWidget::btnLetterClickedSlot); connect(m_functionBtn, &QPushButton::clicked, this, &SideBarWidget::btnFuncClickedSlot); - connect(m_computerBtn, &QPushButton::clicked, this, &SideBarWidget::computerBtnClickedSlot); - connect(m_personalBtn, &QPushButton::clicked, this, &SideBarWidget::personalBtnClickedSlot); - connect(m_controlBtn, &QPushButton::clicked, this, &SideBarWidget::controlBtnClickedSlot); - connect(m_trashBtn, &QPushButton::clicked, this, &SideBarWidget::trashBtnClickedSlot); - connect(m_shutDownBtn, &QPushButton::clicked, this, &SideBarWidget::shutdownBtnClickedSlot); - connect(m_userIconBtn, &QPushButton::clicked, this, &SideBarWidget::userIconBtnClickedSlot); -// Q_FOREACH (QAbstractButton *button, m_buttonList) { -// QPushButton *btn = qobject_cast(button); -// if (m_buttonList.indexOf(button) > 3 && m_buttonList.indexOf(button) < m_buttonList.count() - 1) { -// button->setCheckable(false); -// addRightClickMenu(btn); -// } -// } + connect(m_computerBtn,&QPushButton::clicked,this,&SideBarWidget::computerBtnClickedSlot); + connect(m_personalBtn,&QPushButton::clicked,this,&SideBarWidget::personalBtnClickedSlot); + connect(m_controlBtn,&QPushButton::clicked,this,&SideBarWidget::controlBtnClickedSlot); + connect(m_trashBtn,&QPushButton::clicked,this,&SideBarWidget::trashBtnClickedSlot); + connect(m_shutDownBtn,&QPushButton::clicked,this,&SideBarWidget::shutdownBtnClickedSlot); + connect(m_userIconBtn,&QPushButton::clicked,this,&SideBarWidget::userIconBtnClickedSlot); + + Q_FOREACH(QAbstractButton* button,m_buttonList) + { + QPushButton* btn=qobject_cast(button); + if(m_buttonList.indexOf(button)>3 && m_buttonList.indexOf(button)setCheckable(false); + addRightClickMenu(btn); + } + } m_shutDownBtn->setContextMenuPolicy(Qt::CustomContextMenu); - connect(m_shutDownBtn, &QPushButton::customContextMenuRequested, this, + connect(m_shutDownBtn,&QPushButton::customContextMenuRequested,this, &SideBarWidget::shutdownBtnRightClickSlot); + //监控用户账户信息更改 - qint64 uid = static_cast(getuid()); + qint64 uid=static_cast(getuid()); QDBusInterface iface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts", QDBusConnection::systemBus()); - QDBusReplyobjPath = iface.call("FindUserById", uid); + QDBusReplyobjPath=iface.call("FindUserById",uid); QDBusConnection::systemBus().connect("org.freedesktop.Accounts", - objPath.value().path(), - "org.freedesktop.Accounts.User", - QString("Changed"), this, SLOT(userAccountsChanged())); + objPath.value().path(), + "org.freedesktop.Accounts.User", + QString("Changed"),this,SLOT(userAccountsChanged())); + m_mainWidgetLayout->addWidget(m_minMaxWidget); m_mainWidgetLayout->addWidget(m_buttonList.at(0)); m_mainWidgetLayout->addWidget(m_buttonList.at(1)); m_mainWidgetLayout->addWidget(m_buttonList.at(2)); - m_verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_verticalSpacer = new QSpacerItem(20,40, QSizePolicy::Fixed, QSizePolicy::Expanding); m_mainWidgetLayout->addItem(m_verticalSpacer); m_mainWidgetLayout->addWidget(m_buttonList.at(3)); - - if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) { - m_gsetting = new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit()); - - if (m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) { + if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) + { + m_gsetting=new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit()); + if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(4)); - } - - if (m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) { + if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(5)); - } - - if (m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) { + if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(6)); - } - - if (m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) { + if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(7)); - } - - connect(m_gsetting, &QGSettings::changed, - this, &SideBarWidget::resetSidebarBtnSlot); + connect(m_gsetting,&QGSettings::changed, + this,&SideBarWidget::resetSidebarBtnSlot); } - m_mainWidgetLayout->addWidget(m_buttonList.at(8)); - if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); - connect(gsetting, &QGSettings::changed, this, &SideBarWidget::themeModeChangeSlot); + if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting,&QGSettings::changed,this,&SideBarWidget::themeModeChangeSlot); } m_animation = new QPropertyAnimation(m_mainWidget, "geometry"); @@ -235,32 +235,24 @@ void SideBarWidget::addSidebarBtn() void SideBarWidget::resetSidebarBtnSlot() { QLayoutItem *child; - while ((child = m_mainWidgetLayout->takeAt(6)) != 0) { - QWidget *wid = child->widget(); + QWidget* wid=child->widget(); m_mainWidgetLayout->removeWidget(wid); wid->setParent(nullptr); delete child; } - if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) { - if (m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) { + if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) + { + if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(4)); - } - - if (m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) { + if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(5)); - } - - if (m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) { + if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(6)); - } - - if (m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) { + if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) m_mainWidgetLayout->addWidget(m_buttonList.at(7)); - } } - m_mainWidgetLayout->addWidget(m_buttonList.at(8)); } @@ -270,37 +262,34 @@ void SideBarWidget::resetSidebarBtnSlot() void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int num) { btn->setFlat(true); - btn->setProperty("useButtonPalette", true); - QHBoxLayout *btnLayout = new QHBoxLayout; - QLabel *labelicon = new QLabel; + btn->setProperty("useButtonPalette",true); + QHBoxLayout* btnLayout=new QHBoxLayout; + QLabel* labelicon=new QLabel; labelicon->setAlignment(Qt::AlignCenter); - const auto ratio = devicePixelRatioF(); + const auto ratio=devicePixelRatioF(); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - - if (num != 3) { - QPixmap pixmap = loadSvg(btnicon, Style::SideBarIconSize * ratio); - - if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 - pixmap = drawSymbolicBlackColoredPixmap(pixmap); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - } - + if(num!=3) + { + QPixmap pixmap=loadSvg(btnicon,Style::SideBarIconSize*ratio); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - labelicon->setFixedSize(Style::SideBarIconSize, Style::SideBarIconSize); + labelicon->setFixedSize(Style::SideBarIconSize,Style::SideBarIconSize); labelicon->setPixmap(pixmap); - } else { - if (!QFile::exists(btnicon)) { - btnicon = QString("/usr/share/ukui/faces/default.png"); - } - + } + else { + if(!QFile::exists(btnicon)) + btnicon=QString("/usr/share/ukui/faces/default.png"); labelicon->setObjectName("faceLabel"); labelicon->setFocusPolicy(Qt::NoFocus); labelicon->setAlignment(Qt::AlignCenter); - labelicon->setFixedSize(Style::SideBarIconSize + 4, Style::SideBarIconSize + 4); + labelicon->setFixedSize(Style::SideBarIconSize+4,Style::SideBarIconSize+4); + QPixmap facePixmap(btnicon); - facePixmap = facePixmap.scaled((Style::SideBarIconSize + 4) * ratio, (Style::SideBarIconSize + 4) * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); - facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize + 4) * ratio / 2); + facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); + facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2); facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); labelicon->setPixmap(facePixmap); } @@ -308,19 +297,20 @@ void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int btnLayout->setSpacing(0); btnLayout->addWidget(labelicon); // btnLayout->addStretch(); - QLabel *textLabel = new QLabel; - if (num == 3) { + QLabel* textLabel=new QLabel; + if(num==3) textLabel->setObjectName("nameLabel"); - } - textLabel->setText(text); btnLayout->addWidget(textLabel); btnLayout->addStretch(); + btn->setLayout(btnLayout); btn->setFocusPolicy(Qt::StrongFocus); + m_buttonList.append(btn); m_textList.append(text); + m_labelList.append(textLabel); } @@ -331,14 +321,14 @@ QPixmap SideBarWidget::PixmapToRound(const QPixmap &src, int radius) } QPixmap pixmapa(src); - QPixmap pixmap(radius * 2, radius * 2); + QPixmap pixmap(radius*2,radius*2); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); QPainterPath path; - path.addEllipse(0, 0, radius * 2, radius * 2); + path.addEllipse(0, 0, radius*2, radius*2); painter.setClipPath(path); - painter.drawPixmap(0, 0, radius * 2, radius * 2, pixmapa); + painter.drawPixmap(0, 0, radius*2, radius*2, pixmapa); return pixmap; } @@ -348,96 +338,84 @@ QPixmap SideBarWidget::PixmapToRound(const QPixmap &src, int radius) */ void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos) { + RightClickMenu m_otherMenu(this); - int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos)); + connect(&m_otherMenu, &RightClickMenu::sendMainWinActiveSignal, this, &SideBarWidget::sendShowMainWindowSignal); Q_EMIT sendShowMainWindowSignal(false); + int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos)); qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; - - if (ret >= 10 && ret <= 17) { + if(ret>=10 && ret<=17) + { Q_EMIT sendHideMainWindowSignal(); - switch (ret) { - case 10: - QProcess::startDetached(QString("ukui-screensaver-command -l")); - break; - - case 11: - QProcess::startDetached(QString("ukui-session-tools --switchuser")); - break; - - case 12: - QProcess::startDetached(QString("ukui-session-tools --logout")); - break; - - case 13: - QProcess::startDetached(QString("ukui-session-tools --reboot")); - break; - - case 14: - QProcess::startDetached(QString("ukui-session-tools --shutdown")); - break; - - case 16: - QProcess::startDetached(QString("ukui-session-tools --suspend")); - break; - - case 17: - QProcess::startDetached(QString("ukui-session-tools --sleep")); - break; - - default: - break; + case 10: + QProcess::startDetached(QString("ukui-screensaver-command -l")); + break; + case 11: + QProcess::startDetached(QString("ukui-session-tools --switchuser")); + break; + case 12: + QProcess::startDetached(QString("ukui-session-tools --logout")); + break; + case 13: + QProcess::startDetached(QString("ukui-session-tools --reboot")); + break; + case 14: + QProcess::startDetached(QString("ukui-session-tools --shutdown")); + break; + case 16: + QProcess::startDetached(QString("ukui-session-tools --suspend")); + break; + case 17: + QProcess::startDetached(QString("ukui-session-tools --sleep")); + break; + default: + break; } - } + } qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 结束"; } -//void SideBarWidget::addRightClickMenu(QPushButton *btn) -//{ -// btn->setContextMenuPolicy(Qt::CustomContextMenu); -// connect(btn, &QPushButton::customContextMenuRequested, this, &SideBarWidget::otherBtnRightClickSlot); -//} +void SideBarWidget::addRightClickMenu(QPushButton *btn) +{ + btn->setContextMenuPolicy(Qt::CustomContextMenu); + connect(btn,&QPushButton::customContextMenuRequested,this,&SideBarWidget::otherBtnRightClickSlot); +} -//void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) -//{ -// qDebug() << "SideBarWidget::otherBtnRightClickSlot() 开始"; -// QPushButton *btn = dynamic_cast(QObject::sender()); -// int index = m_buttonList.indexOf(btn); -// QString desktopfp; - -// switch (index) { -// case 4: -// desktopfp = QString("/usr/share/applications/peony-home.desktop"); -// break; - -// case 5: -// desktopfp = QString("/usr/share/applications/peony-trash.desktop"); -// break; - -// case 6: -// desktopfp = QString("/usr/share/applications/peony-computer.desktop"); -// break; - -// case 7: -// desktopfp = QString("/usr/share/applications/ukui-control-center.desktop"); -// break; - -// default: -// break; -// } - -// RightClickMenu m_otherMenu; -// int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); -// Q_EMIT sendShowMainWindowSignal(false); - -// if (ret == 15) { -// Q_EMIT sendHideMainWindowSignal(); -// QProcess::startDetached(QString("ukui-control-center -d")); -// } - -// qDebug() << "SideBarWidget::otherBtnRightClickSlot() 结束"; -//} +void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) +{ + qDebug() << "SideBarWidget::otherBtnRightClickSlot() 开始"; + QPushButton* btn=dynamic_cast(QObject::sender()); + int index=m_buttonList.indexOf(btn); + QString desktopfp; + switch (index) { + case 4: + desktopfp=QString("/usr/share/applications/peony-home.desktop"); + break; + case 5: + desktopfp=QString("/usr/share/applications/peony-trash.desktop"); + break; + case 6: + desktopfp=QString("/usr/share/applications/peony-computer.desktop"); + break; + case 7: + desktopfp=QString("/usr/share/applications/ukui-control-center.desktop"); + break; + default: + break; + } + RightClickMenu m_otherMenu; + connect(&m_otherMenu, &RightClickMenu::sendMainWinActiveSignal, this, &SideBarWidget::sendShowMainWindowSignal); + int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); + Q_EMIT sendShowMainWindowSignal(false); + if(ret==15) + { + Q_EMIT sendHideMainWindowSignal(); + QProcess::startDetached(QString("ukui-control-center -d")); + } + qDebug() << "SideBarWidget::otherBtnRightClickSlot() 结束"; +} void SideBarWidget::computerBtnClickedSlot() { @@ -455,6 +433,7 @@ void SideBarWidget::controlBtnClickedSlot() { Q_EMIT sendHideMainWindowSignal(); execApp("/usr/share/applications/ukui-control-center.desktop"); + } void SideBarWidget::trashBtnClickedSlot() @@ -472,28 +451,26 @@ void SideBarWidget::shutdownBtnClickedSlot() void SideBarWidget::userIconBtnClickedSlot() { Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-control-center -m Userinfo")); + QProcess::startDetached(QString("ukui-control-center -u")); } void SideBarWidget::userAccountsChanged() { - const auto ratio = devicePixelRatioF(); - QString usericon = getUserIcon(); - - if (!QFile::exists(usericon)) { - usericon = QString("/usr/share/ukui/faces/default.png"); - } - + const auto ratio=devicePixelRatioF(); + QString usericon=getUserIcon(); + if(!QFile::exists(usericon)) + usericon=QString("/usr/share/ukui/faces/default.png"); QPixmap facePixmap(usericon); - facePixmap = facePixmap.scaled((Style::SideBarIconSize + 2) * ratio, (Style::SideBarIconSize + 2) * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); - facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize + 2) * ratio / 2); - QLabel *labelicon = m_userIconBtn->findChild("faceLabel"); + facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); + facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2); + + QLabel* labelicon=m_userIconBtn->findChild("faceLabel"); facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); labelicon->setPixmap(facePixmap); - QLabel *labelname = m_userIconBtn->findChild("nameLabel"); - QString userName = fontMetrics().elidedText(getUserName(), Qt::ElideRight, labelname->width() - 10, Qt::TextShowMnemonic); + QLabel* labelname=m_userIconBtn->findChild("nameLabel"); + QString userName = fontMetrics().elidedText(getUserName(),Qt::ElideRight,labelname->width()-10,Qt::TextShowMnemonic); labelname->setText(userName);//更新用户名 - m_textList.replace(3, getUserName()); //更新用户名 + m_textList.replace(3,getUserName());//更新用户名 } /** @@ -501,25 +478,30 @@ void SideBarWidget::userAccountsChanged() */ void SideBarWidget::loadMinSidebar() { - m_isFullScreen = false; + m_isFullScreen=false; setMaxBtn(); - m_animation->stop(); - this->setFixedSize(Style::defaultSideBarWidWidth, Style::minh); - m_mainWidget->setGeometry(QRect(0, 0, this->width(), this->height())); - m_mainWidget->show(); - m_minMaxWidget->setFixedSize(37, 70); - m_minMaxLayout->setContentsMargins(0, 0, 0, 0); - m_mainWidgetLayout->setContentsMargins(8, 0, 10, 6); - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QPushButton *btn = qobject_cast(button); + m_animation->stop(); + this->setFixedSize(Style::defaultSideBarWidWidth,Style::minh); + m_mainWidget->setGeometry(QRect(0,0,this->width(),this->height())); + m_mainWidget->show(); + m_minMaxWidget->setFixedSize(37,70); + m_minMaxLayout->setContentsMargins(0,0,0,0); + + m_mainWidgetLayout->setContentsMargins(8,0,10,6); + + Q_FOREACH(QAbstractButton* button,m_buttonList) + { + QPushButton* btn=qobject_cast(button); setMinSidebarBtn(btn); btn->setToolTip(m_textList.at(m_buttonList.indexOf(button))); } + changeIconColor(false); - disconnect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendDefaultBtnSignal); - connect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendFullScreenBtnSignal); + + disconnect(m_minMaxBtn,&QToolButton::clicked,this, &SideBarWidget::sendDefaultBtnSignal); + connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); } /** @@ -527,38 +509,36 @@ void SideBarWidget::loadMinSidebar() */ void SideBarWidget::setMaxBtn() { - const auto ratio = devicePixelRatioF(); + const auto ratio=devicePixelRatioF(); QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - QPixmap pixmap = loadSvg(QString(":/data/img/sidebarwidget/max.svg"), 14 * ratio); - - if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 - pixmap = drawSymbolicBlackColoredPixmap(pixmap); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - } - + QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/max.svg"),14*ratio); + if(gsetting.get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_minMaxBtn->setFixedSize(37, 37); + + m_minMaxBtn->setFixedSize(37,37); m_minMaxBtn->setIcon(QIcon(pixmap)); m_minMaxBtn->setToolTip(tr("Max")); + // m_minMaxBtn->setFocus(); } /** * 设置默认侧边栏按钮 */ -void SideBarWidget::setMinSidebarBtn(QPushButton *btn) +void SideBarWidget::setMinSidebarBtn(QPushButton* btn) { - btn->setFixedSize(37, 37); - - if (m_buttonList.indexOf(btn) == 3) { - btn->layout()->setContentsMargins(7, 0, 17, 0); - } else { - btn->layout()->setContentsMargins(9, 0, 17, 0); - } - + btn->setFixedSize(37,37); + if(m_buttonList.indexOf(btn)==3) + btn->layout()->setContentsMargins(7,0,17,0); + else + btn->layout()->setContentsMargins(9,0,17,0); btn->layout()->setSpacing(0); + m_labelList.at(m_buttonList.indexOf(btn))->setVisible(false); + //移除按钮文本 // QLayoutItem *child; // if((child = btn->layout()->takeAt(1)) != nullptr) { @@ -578,26 +558,32 @@ void SideBarWidget::setMinSidebarBtn(QPushButton *btn) */ void SideBarWidget::loadMaxSidebar() { - m_isFullScreen = true; + m_isFullScreen=true; setMinBtn(); - this->setFixedSize(Style::SideBarWidWidth, Style::heightavailable); - m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth, Style::MinMaxWidHeight); - m_minMaxLayout->setContentsMargins(m_minMaxWidget->width() - m_minMaxBtn->width(), 0, 0, 0); - m_mainWidgetLayout->setContentsMargins(0, 0, 0, 6); - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QPushButton *btn = qobject_cast(button); + this->setFixedSize(Style::SideBarWidWidth,Style::heightavailable); + + m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth,Style::MinMaxWidHeight); + m_minMaxLayout->setContentsMargins(m_minMaxWidget->width()-m_minMaxBtn->width(),0,0,0); + + m_mainWidgetLayout->setContentsMargins(0,0,0,6); + + Q_FOREACH(QAbstractButton* button,m_buttonList) + { + QPushButton* btn=qobject_cast(button); setMaxSidebarBtn(btn); } - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QPushButton *btn = qobject_cast(button); - btn->setFixedSize(m_btnWidth, Style::SideBarBtnHeight); + Q_FOREACH(QAbstractButton* button,m_buttonList) + { + QPushButton* btn=qobject_cast(button); + btn->setFixedSize(m_btnWidth,Style::SideBarBtnHeight); } changeIconColor(true); - disconnect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendFullScreenBtnSignal); - connect(m_minMaxBtn, &QToolButton::clicked, this, &SideBarWidget::sendDefaultBtnSignal); + + disconnect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); + connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendDefaultBtnSignal); } /** @@ -605,13 +591,15 @@ void SideBarWidget::loadMaxSidebar() */ void SideBarWidget::setMinBtn() { - const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(QString(":/data/img/sidebarwidget/min.svg"), 14 * ratio); - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + const auto ratio=devicePixelRatioF(); + QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/min.svg"),14*ratio); + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth, Style::MinMaxBtnWidth); + + m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth,Style::MinMaxBtnWidth); m_minMaxBtn->setIcon(QIcon(pixmap)); m_minMaxBtn->setToolTip(""); + // m_minMaxBtn->setFocus(); } @@ -620,18 +608,20 @@ void SideBarWidget::setMinBtn() */ void SideBarWidget::setMaxSidebarBtn(QPushButton *btn) { - QHBoxLayout *layout = qobject_cast(btn->layout()); - - if (m_buttonList.indexOf(btn) == 3) { - layout->setContentsMargins(13, 0, 0, 0); + QHBoxLayout* layout=qobject_cast(btn->layout()); + if(m_buttonList.indexOf(btn)==3) + { + layout->setContentsMargins(13,0,0,0); layout->setSpacing(8); - } else { - layout->setContentsMargins(15, 0, 0, 0); + } + else + { + layout->setContentsMargins(15,0,0,0); layout->setSpacing(10); } - QLabel *labeltext = m_labelList.at(m_buttonList.indexOf(btn)); - labeltext->setVisible(true); + QLabel* labeltext=m_labelList.at(m_buttonList.indexOf(btn)); + labeltext->setVisible(true); //修复修改字体大小时获取文本Label大小无效 //移除按钮文本 @@ -648,30 +638,30 @@ void SideBarWidget::setMaxSidebarBtn(QPushButton *btn) // } //添加文本 // QLabel* labeltext=new QLabel; - if (m_buttonList.indexOf(btn) <= 2) { + if(m_buttonList.indexOf(btn)<=2) + { labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); labeltext->setText(m_textList.at(m_buttonList.indexOf(btn))); labeltext->adjustSize(); - m_btnWidth = 44 + labeltext->width() + 10; + m_btnWidth=44+labeltext->width()+10; btn->setToolTip(""); - } else { - QFont ft; - QFontMetrics fm(ft); - QString text = fm.elidedText(m_textList.at(m_buttonList.indexOf(btn)), Qt::ElideRight, m_btnWidth - 44); - labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - labeltext->setText(text); - labeltext->setFixedSize(m_btnWidth - 44, Style::SideBarBtnHeight); - labeltext->adjustSize(); - - if (fm.boundingRect(m_textList.at(m_buttonList.indexOf(btn))).width() > labeltext->width()) { - btn->setToolTip(m_textList.at(m_buttonList.indexOf(btn))); - } else { - btn->setToolTip(""); - } } - + else + { + QFont ft; + QFontMetrics fm(ft); + QString text = fm.elidedText(m_textList.at(m_buttonList.indexOf(btn)), Qt::ElideRight, m_btnWidth-44); + labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + labeltext->setText(text); + labeltext->setFixedSize(m_btnWidth-44,Style::SideBarBtnHeight); + labeltext->adjustSize(); + if(fm.boundingRect(m_textList.at(m_buttonList.indexOf(btn))).width()>labeltext->width()) + btn->setToolTip(m_textList.at(m_buttonList.indexOf(btn))); + else + btn->setToolTip(""); + } QPalette pe = labeltext->palette(); - pe.setColor(QPalette::ButtonText, QColor(Qt::white)); + pe.setColor(QPalette::ButtonText,QColor(Qt::white)); labeltext->setPalette(pe); // btn->layout()->addWidget(labeltext); } @@ -681,11 +671,13 @@ void SideBarWidget::btnAllClickedSlot() m_allBtn->setChecked(true); m_letterBtn->setChecked(false); m_functionBtn->setChecked(false); - - if (m_isFullScreen) { + if(m_isFullScreen) + { Q_EMIT sendFullScreenCommonUseBtnSignal(); Q_EMIT setSlideBar(0); - } else { + } + else + { Q_EMIT sendCommonUseBtnSignal(); } } @@ -695,10 +687,12 @@ void SideBarWidget::btnLetterClickedSlot() m_allBtn->setChecked(false); m_letterBtn->setChecked(true); m_functionBtn->setChecked(false); - - if (m_isFullScreen) { + if(m_isFullScreen) + { Q_EMIT sendFullScreenLetterBtnSignal(); - } else { + } + else + { Q_EMIT sendLetterBtnSignal(); } } @@ -709,75 +703,66 @@ void SideBarWidget::btnFuncClickedSlot() m_letterBtn->setChecked(false); m_functionBtn->setChecked(true); - if (m_isFullScreen) { + if(m_isFullScreen) + { Q_EMIT sendFullScreenFunctionBtnSignal(); - } else { + } + else + { Q_EMIT sendFunctionBtnSignal(); } } void SideBarWidget::themeModeChangeSlot(QString styleName) { - if (styleName == "styleName") { - QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); - - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QPushButton *btn = qobject_cast(button); - QLayoutItem *item = btn->layout()->itemAt(0); - QLabel *label = qobject_cast(item->widget()); + if(styleName=="styleName") + { + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + Q_FOREACH(QAbstractButton *button,m_buttonList) + { + QPushButton *btn=qobject_cast(button); + QLayoutItem *item=btn->layout()->itemAt(0); + QLabel *label=qobject_cast(item->widget()); QString iconStr; - switch (m_buttonList.indexOf(button)) { - case 0: - iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); - break; - - case 1: - iconStr = QString(":/data/img/sidebarwidget/letter.svg"); - break; - - case 2: - iconStr = QString(":/data/img/sidebarwidget/function.svg"); - break; - - case 3: - userAccountsChanged(); - break; - - case 4: - iconStr = QString(":/data/img/sidebarwidget/personal.svg"); - break; - - case 5: - iconStr = QString(":/data/img/sidebarwidget/trash.svg"); - break; - - case 6: - iconStr = QString(":/data/img/sidebarwidget/computer.svg"); - break; - - case 7: - iconStr = QString(":/data/img/sidebarwidget/setting.svg"); - break; - - case 8: - iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); - break; - - default: - break; + case 0: + iconStr=QString(":/data/img/sidebarwidget/commonuse.svg"); + break; + case 1: + iconStr=QString(":/data/img/sidebarwidget/letter.svg"); + break; + case 2: + iconStr=QString(":/data/img/sidebarwidget/function.svg"); + break; + case 3: + userAccountsChanged(); + break; + case 4: + iconStr=QString(":/data/img/sidebarwidget/personal.svg"); + break; + case 5: + iconStr=QString(":/data/img/sidebarwidget/trash.svg"); + break; + case 6: + iconStr=QString(":/data/img/sidebarwidget/computer.svg"); + break; + case 7: + iconStr=QString(":/data/img/sidebarwidget/setting.svg"); + break; + case 8: + iconStr=QString(":/data/img/sidebarwidget/shutdown.svg"); + break; + default: + break; } - - if (m_buttonList.indexOf(button) != 3) { - const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(iconStr, 19 * ratio); - - if (gsetting->get("style-name").toString() == "ukui-light") { //反黑 - pixmap = drawSymbolicBlackColoredPixmap(pixmap); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - } - + if(m_buttonList.indexOf(button)!=3) + { + const auto ratio=devicePixelRatioF(); + QPixmap pixmap=loadSvg(iconStr,19*ratio); + if(gsetting->get("style-name").toString()=="ukui-light")//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); label->setPixmap(pixmap); } @@ -787,65 +772,52 @@ void SideBarWidget::themeModeChangeSlot(QString styleName) void SideBarWidget::changeIconColor(bool isFullScreen) { - QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); - - Q_FOREACH (QAbstractButton *button, m_buttonList) { - QPushButton *btn = qobject_cast(button); - QLayoutItem *item = btn->layout()->itemAt(0); - QLabel *label = qobject_cast(item->widget()); + QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); + Q_FOREACH(QAbstractButton *button,m_buttonList) + { + QPushButton *btn=qobject_cast(button); + QLayoutItem *item=btn->layout()->itemAt(0); + QLabel *label=qobject_cast(item->widget()); QString iconStr; - switch (m_buttonList.indexOf(button)) { - case 0: - iconStr = QString(":/data/img/sidebarwidget/commonuse.svg"); - break; - - case 1: - iconStr = QString(":/data/img/sidebarwidget/letter.svg"); - break; - - case 2: - iconStr = QString(":/data/img/sidebarwidget/function.svg"); - break; - - case 3: - userAccountsChanged(); - break; - - case 4: - iconStr = QString(":/data/img/sidebarwidget/personal.svg"); - break; - - case 5: - iconStr = QString(":/data/img/sidebarwidget/trash.svg"); - break; - - case 6: - iconStr = QString(":/data/img/sidebarwidget/computer.svg"); - break; - - case 7: - iconStr = QString(":/data/img/sidebarwidget/setting.svg"); - break; - - case 8: - iconStr = QString(":/data/img/sidebarwidget/shutdown.svg"); - break; - - default: - break; + case 0: + iconStr=QString(":/data/img/sidebarwidget/commonuse.svg"); + break; + case 1: + iconStr=QString(":/data/img/sidebarwidget/letter.svg"); + break; + case 2: + iconStr=QString(":/data/img/sidebarwidget/function.svg"); + break; + case 3: + userAccountsChanged(); + break; + case 4: + iconStr=QString(":/data/img/sidebarwidget/personal.svg"); + break; + case 5: + iconStr=QString(":/data/img/sidebarwidget/trash.svg"); + break; + case 6: + iconStr=QString(":/data/img/sidebarwidget/computer.svg"); + break; + case 7: + iconStr=QString(":/data/img/sidebarwidget/setting.svg"); + break; + case 8: + iconStr=QString(":/data/img/sidebarwidget/shutdown.svg"); + break; + default: + break; } - - if (m_buttonList.indexOf(button) != 3) { - const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(iconStr, 18 * ratio); - - if (gsetting->get("style-name").toString() == "ukui-light" && !isFullScreen) { //反黑 - pixmap = drawSymbolicBlackColoredPixmap(pixmap); - } else { - pixmap = drawSymbolicColoredPixmap(pixmap); //反白 - } - + if(m_buttonList.indexOf(button)!=3) + { + const auto ratio=devicePixelRatioF(); + QPixmap pixmap=loadSvg(iconStr,19*ratio); + if(gsetting->get("style-name").toString()=="ukui-light" && !isFullScreen)//反黑 + pixmap=drawSymbolicBlackColoredPixmap(pixmap); + else + pixmap=drawSymbolicColoredPixmap(pixmap);//反白 pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); label->setPixmap(pixmap); } @@ -856,10 +828,10 @@ void SideBarWidget::enterAnimation() { m_animation->stop(); m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(this->width(), 0, - 0, this->height())); - m_animation->setEndValue(QRect(this->width() - m_btnWidth - Style::SideBarMargin, 0, - m_btnWidth, this->height())); + m_animation->setStartValue(QRect(this->width(),0, + 0,this->height())); + m_animation->setEndValue(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0, + m_btnWidth,this->height())); m_animation->setEasingCurve(QEasingCurve::InQuart); m_animation->start(); m_mainWidget->show(); @@ -867,8 +839,8 @@ void SideBarWidget::enterAnimation() void SideBarWidget::setSideBarBtnGeometry() { - m_mainWidget->setGeometry(QRect(this->width() - m_btnWidth - Style::SideBarMargin, 0, - m_btnWidth, this->height())); + m_mainWidget->setGeometry(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0, + m_btnWidth,this->height())); m_mainWidget->show(); } @@ -889,30 +861,39 @@ void SideBarWidget::setSideBarBtnGeometry() // } //} -void SideBarWidget::keyPressEvent(QKeyEvent *e) +void SideBarWidget::keyPressEvent(QKeyEvent* e) { - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - if (m_allBtn->hasFocus()) { - m_allBtn->click(); - } else if (m_letterBtn->hasFocus()) { - m_letterBtn->click(); - } else if (m_functionBtn->hasFocus()) { - m_functionBtn->click(); - } else { - QWidget *current_focus_widget; - current_focus_widget = QWidget::focusWidget(); - QPushButton *le = qobject_cast(current_focus_widget); - le->clicked(); - } + if(e->type()==QEvent::KeyPress) + { + switch(e->key()) + { + case Qt::Key_Enter: + case Qt::Key_Return: + { + if(m_allBtn->hasFocus()) + { + m_allBtn->click(); } + else if(m_letterBtn->hasFocus()) + { + m_letterBtn->click(); + } + else if(m_functionBtn->hasFocus()) + { + m_functionBtn->click(); + } + else + { + QWidget *current_focus_widget; + current_focus_widget = QWidget::focusWidget(); + QPushButton *le= qobject_cast(current_focus_widget); + le->clicked(); + } + } break; - - case Qt::Key_Down: - qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Down"; - // focusNextChild(); + case Qt::Key_Down: + qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Down"; + // focusNextChild(); // if(m_buttonList.at(2)->hasFocus()) // { // m_buttonList.at(3)->setFocus(); @@ -921,20 +902,19 @@ void SideBarWidget::keyPressEvent(QKeyEvent *e) // { // m_minMaxBtn->setFocus(); // } - break; - case Qt::Key_Up: - qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Up"; - // /* focusPreviousChild(); + break; + case Qt::Key_Up: + qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Up"; + // /* focusPreviousChild(); // if(m_buttonList.at(0)->hasFocus()) // { // m_minMaxBtn->setFocus(); // } - break; - - default: - return QWidget::keyPressEvent(e); - break; + break; + default: + return QWidget::keyPressEvent(e); + break; } } } diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h index 6e800d1..2dffe52 100644 --- a/src/SideBarWidget/sidebarwidget.h +++ b/src/SideBarWidget/sidebarwidget.h @@ -61,34 +61,34 @@ public: void setSideBarBtnGeometry(); private: - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + UkuiMenuInterface *m_ukuiMenuInterface=nullptr; - QWidget *m_mainWidget = nullptr; - QVBoxLayout *m_mainWidgetLayout = nullptr; + QWidget *m_mainWidget=nullptr; + QVBoxLayout *m_mainWidgetLayout=nullptr; - QWidget *m_minMaxWidget = nullptr; - QHBoxLayout *m_minMaxLayout = nullptr; - QPushButton *m_minMaxBtn = nullptr; + QWidget *m_minMaxWidget=nullptr; + QHBoxLayout *m_minMaxLayout=nullptr; + QPushButton *m_minMaxBtn=nullptr; - QList m_buttonList; - QList m_labelList; + QList m_buttonList; + QList m_labelList; QStringList m_textList; - QPushButton *m_allBtn = nullptr; - QPushButton *m_letterBtn = nullptr; - QPushButton *m_functionBtn = nullptr; + QPushButton *m_allBtn=nullptr; + QPushButton *m_letterBtn=nullptr; + QPushButton *m_functionBtn=nullptr; - QPushButton *m_userIconBtn = nullptr; - QPushButton *m_computerBtn = nullptr; - QPushButton *m_personalBtn = nullptr; - QPushButton *m_controlBtn = nullptr; - QPushButton *m_trashBtn = nullptr; - QPushButton *m_shutDownBtn = nullptr; - QSpacerItem *m_verticalSpacer = nullptr; - bool m_isFullScreen = false; - QGSettings *m_gsetting = nullptr; - // RightClickMenu *m_shutDownMenu=nullptr; - // RightClickMenu *m_otherMenu=nullptr; - QPropertyAnimation *m_animation = nullptr; + QPushButton *m_userIconBtn=nullptr; + QPushButton *m_computerBtn=nullptr; + QPushButton *m_personalBtn=nullptr; + QPushButton *m_controlBtn=nullptr; + QPushButton *m_trashBtn=nullptr; + QPushButton *m_shutDownBtn=nullptr; + QSpacerItem *m_verticalSpacer=nullptr; + bool m_isFullScreen=false; + QGSettings *m_gsetting=nullptr; + // RightClickMenu *m_shutDownMenu=nullptr; + // RightClickMenu *m_otherMenu=nullptr; + QPropertyAnimation* m_animation=nullptr; int m_btnWidth, m_btnheight; @@ -109,7 +109,7 @@ protected: * @param text: Button text * @param num: Button Number */ - void initBtn(QPushButton *btn, QString btnicon, QString text, int num); + void initBtn(QPushButton *btn, QString btnicon,QString text,int num); /** * @brief Set the default sidebar button * @param btn: QPushButton @@ -124,7 +124,7 @@ protected: * @brief Add right-click menu * @param btn: QPushButton */ -// void addRightClickMenu(QPushButton* btn); + void addRightClickMenu(QPushButton* btn); /** * @brief Set the minimize button */ @@ -136,9 +136,9 @@ protected: QPixmap PixmapToRound(const QPixmap &src, int radius); void changeIconColor(bool isFullScreen); // void mousePressEvent(QMouseEvent* event); - void keyPressEvent(QKeyEvent *e); + void keyPressEvent(QKeyEvent* e); - bool eventFilter(QObject *target, QEvent *event); + bool eventFilter(QObject * target , QEvent * event ); private Q_SLOTS: /** @@ -160,7 +160,7 @@ private Q_SLOTS: /** * @brief Load other application right-click menu */ -// void otherBtnRightClickSlot(const QPoint &pos); + void otherBtnRightClickSlot(const QPoint &pos); /** * @brief Respond to computer btn */ diff --git a/src/Style/style.cpp b/src/Style/style.cpp index 71719e8..31dd831 100644 --- a/src/Style/style.cpp +++ b/src/Style/style.cpp @@ -41,7 +41,6 @@ int Style::defaultQueryLineEditHeight=0; int Style::defaultQueryLineEditIconSize=0; int Style::defaultContentWidHeight=0; int Style::defaultSideBarWidWidth=0; -int Style::defaultIconSize=32; /** * 全屏窗口 */ @@ -101,39 +100,28 @@ int Style::SideBarSpaceBetweenItem=0; void Style::initWidStyle() { + getScreenAvailableGeometry(); - QVariantList list=getScreenGeometry(); - if(list.count()>=6) - { - primaryScreenX=list.at(0).toInt(); - primaryScreenY=list.at(1).toInt(); - primaryScreenWidth=list.at(2).toInt(); - primaryScreenHeight=list.at(3).toInt(); - panelSize=list.at(4).toInt(); - panelPosition=list.at(5).toInt(); + int fontSize = 10; + if (QGSettings::isSchemaInstalled(QString("org.mate.interface").toLocal8Bit())) { + QGSettings *setting = new QGSettings(QString("org.mate.interface").toLocal8Bit()); + if (setting->keys().contains(QString("font-name"))) { + QString value = setting->get("font-name").toString(); + QStringList valstr = value.split(" "); + fontSize = valstr.at(valstr.count() - 1).toInt(); + } } - - QGSettings* setting=new QGSettings(QString("org.mate.interface").toLocal8Bit()); - QString value=setting->get("font-name").toString(); - QStringList valstr=value.split(" "); - int fontSize=valstr.at(valstr.count()-1).toInt(); - - if(panelPosition==0 || panelPosition==1) - { - widthavailable=primaryScreenWidth; - heightavailable=primaryScreenHeight-panelSize; - } - if(panelPosition==2 || panelPosition==3) - { - widthavailable=primaryScreenWidth-panelSize; - heightavailable=primaryScreenHeight; - } - int len=0; + int len = 0; QString locale = QLocale::system().name(); - if (locale == "zh_CN") - len=0; - else - len=10; + + if (locale == "zh_CN") { + len = 0; + } else { + len = 10; + } + + primaryScreenWidth = qApp->primaryScreen()->geometry().width(); + primaryScreenHeight = qApp->primaryScreen()->geometry().height(); if(primaryScreenWidth==800 && primaryScreenHeight==600) { @@ -175,7 +163,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=14; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=15; @@ -221,7 +209,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=14; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=15; @@ -267,7 +255,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=11; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=10; @@ -313,7 +301,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=11; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=10; @@ -359,7 +347,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=11; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=10; @@ -405,7 +393,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=11; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=10; @@ -451,7 +439,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=11; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=10; @@ -497,7 +485,7 @@ void Style::initWidStyle() RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; LeftFontSize=fontSize; LeftLetterFontSize=11; - LeftIconSize=17; + LeftIconSize=19; LeftSpaceIconLeft=15; LeftSpaceIconText=14; LeftSpaceBetweenItem=10; @@ -528,3 +516,40 @@ void Style::initWidStyle() SideBarSpaceBetweenItem=16; } } + +//不通过任务栏获取屏幕可用区域数据 +void Style::getScreenAvailableGeometry() +{ + QRect rect; + rect = qApp->primaryScreen()->geometry(); + + QDBusInterface iface(DBUS_NAME, + DBUS_PATH, + DBUS_INTERFACE, + QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); + if (reply.isValid()) { + panelSize = reply.value().at(4).toInt(); + panelPosition = reply.value().at(5).toInt(); + } + + QList posIndex; + switch (panelPosition) { + case BOTTOM: + posIndex = {0, 0, 0, -1}; + break; + case TOP: + posIndex = {0, 1, 0, -1}; + break; + case LEFT: + posIndex = {1, 0, -1, 0}; + break; + case RIGHT: + posIndex = {0, 0, -1, 0}; + } + + primaryScreenX = rect.x() + posIndex[0] * panelSize; + primaryScreenY = rect.y() + posIndex[1] * panelSize; + widthavailable = rect.width() + posIndex[2] * panelSize; + heightavailable = rect.height() + posIndex[3] * panelSize; +} diff --git a/src/Style/style.h b/src/Style/style.h index 548a846..93bcfee 100644 --- a/src/Style/style.h +++ b/src/Style/style.h @@ -100,7 +100,6 @@ public: static int minh; static int defaultMainViewWidWidth; static int defaultTopWidHeight; - static int defaultIconSize; static int defaultQueryLineEditWidth; static int defaultQueryLineEditHeight; static int defaultQueryLineEditIconSize; @@ -165,6 +164,8 @@ public: static int SideBarSpaceIconText; //按钮图标与文字内边距 static int SideBarSpaceBetweenItem; //item间距 +private: + static void getScreenAvailableGeometry(); //获取屏幕可用区域 }; #endif // STYLE_H diff --git a/src/UtilityFunction/convertdesktoptowinid.cpp b/src/UtilityFunction/convertdesktoptowinid.cpp index 672f8d1..bf1d89e 100644 --- a/src/UtilityFunction/convertdesktoptowinid.cpp +++ b/src/UtilityFunction/convertdesktoptowinid.cpp @@ -32,35 +32,32 @@ QString ConvertDesktopToWinId::tranIdToDesktop(WId id) { KWindowInfo info(id, 0, NET::WM2AllProperties); QString desktopName = confirmDesktopFile(info); - qDebug() << "desktopName is :" << desktopName; + myDebug() << "desktopName is :" << desktopName; return desktopName; } QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info) { - m_desktopfilePath = ""; - - m_dir = new QDir(DEKSTOP_FILE_PATH); - m_list = m_dir->entryInfoList(); + QString desktopFilePath = nullptr; + QDir dir = QDir(DESKTOP_FILE_PATH); + QFileInfoList list = dir.entryInfoList(); //跳过 ./ 和 ../ 目录 - m_list.removeAll(QFile(USR_SHARE_APP_CURRENT)); - m_list.removeAll(QFile(USR_SHARE_APP_UPER)); + list.removeAll(QFile(USR_SHARE_APP_CURRENT)); + list.removeAll(QFile(USR_SHARE_APP_UPER)); //第一种方法:获取点击应用时大部分desktop文件名 - searchFromEnviron(info); + desktopFilePath = searchFromEnviron(info, list); //第二种方法:比较名字一致性 - if (m_desktopfilePath.isEmpty()) { + if (desktopFilePath.isEmpty()) { m_classClass = info.windowClassClass().toLower(); m_className = info.windowClassName(); //匹配安卓兼容 if (m_className == "kylin-kmre-window") { - searchAndroidApp(info); - return m_desktopfilePath; + return searchAndroidApp(info); } - QFile file(QString("/proc/%1/status").arg(info.pid())); if (file.open(QIODevice::ReadOnly)) { char buf[1024]; @@ -69,11 +66,11 @@ QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info) m_statusName = QString::fromLocal8Bit(buf).remove("Name:").remove("\t").remove("\n"); } } - compareClassName(); + desktopFilePath = compareClassName(list); } //第三种方法:比较cmd命令行操作一致性 - if (m_desktopfilePath.isEmpty()) { + if (desktopFilePath.isEmpty()) { QFile file(QString("/proc/%1/cmdline").arg(info.pid())); if (file.open(QIODevice::ReadOnly)) { char buf[1024]; @@ -82,30 +79,30 @@ QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info) m_cmdLine = QString::fromLocal8Bit(buf).remove("\n"); } } - compareCmdExec(); + desktopFilePath = compareCmdExec(list); } //第四种方法:匹配部分字段 - if (m_desktopfilePath.isEmpty()) { - compareLastStrategy(); + if (desktopFilePath.isEmpty()) { + desktopFilePath = compareLastStrategy(list); } - return m_desktopfilePath; + return desktopFilePath; } -void ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info) +QString ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info) { - m_androidDir = new QDir(QString(QDir::homePath() + ANDROID_FILE_PATH)); - m_androidList = m_androidDir->entryInfoList(); - m_androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT); - m_androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER); + QDir androidDir = QString(QDir::homePath() + ANDROID_FILE_PATH); + QFileInfoList androidList = androidDir.entryInfoList(); + androidList.removeAll(QDir::homePath() + ANDROID_APP_CURRENT); + androidList.removeAll(QDir::homePath() + ANDROID_APP_UPER); QFile file(QString("/proc/%1/cmdline").arg(info.pid())); file.open(QIODevice::ReadOnly); QByteArray cmd = file.readAll(); file.close(); QList cmdList = cmd.split('\0'); - for (int i = 0; i < m_androidList.size(); i++) { - QFileInfo fileInfo = m_androidList.at(i); + for (int i = 0; i < androidList.size(); i++) { + QFileInfo fileInfo = androidList.at(i); QString desktopName = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; @@ -113,59 +110,65 @@ void ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info) desktopName = desktopName.mid(desktopName.lastIndexOf("/") + 1); desktopName = desktopName.left(desktopName.lastIndexOf(".")); if(desktopName == cmdList.at(10)){ - m_desktopfilePath = fileInfo.filePath(); + return fileInfo.filePath(); } } + return nullptr; } -void ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info) +QString ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info, QFileInfoList list) { QFile file("/proc/" + QString::number(info.pid()) + "/environ"); file.open(QIODevice::ReadOnly); QByteArray BA = file.readAll(); file.close(); QList list_BA = BA.split('\0'); + + QString desktopFilePath = nullptr; for (int i = 0; i < list_BA.length(); i++) { if (list_BA.at(i).startsWith("GIO_LAUNCHED_DESKTOP_FILE=")) { - m_desktopfilePath = list_BA.at(i); - m_desktopfilePath = m_desktopfilePath.mid(m_desktopfilePath.indexOf("=") + 1); + desktopFilePath = list_BA.at(i); + desktopFilePath = desktopFilePath.mid(desktopFilePath.indexOf("=") + 1); //desktop文件地址需要重写 - m_desktopfilePath = m_desktopfilePath.mid(m_desktopfilePath.lastIndexOf("/") + 1); + desktopFilePath = desktopFilePath.mid(desktopFilePath.lastIndexOf("/") + 1); + break; } } //desktop文件地址重写 - if (!m_desktopfilePath.isEmpty()) { - for (int i = 0; i < m_list.size(); i++) { - QFileInfo fileInfo = m_list.at(i);; - if (fileInfo.filePath() == DEKSTOP_FILE_PATH + m_desktopfilePath) { - m_desktopfilePath = fileInfo.filePath(); + if (!desktopFilePath.isEmpty()) { + for (int i = 0; i < list.size(); i++) { + QFileInfo fileInfo = list.at(i); + if (fileInfo.filePath() == DESKTOP_FILE_PATH + desktopFilePath) { + desktopFilePath = fileInfo.filePath(); + return desktopFilePath; } } } - + return desktopFilePath; } -void ConvertDesktopToWinId::compareClassName() +QString ConvertDesktopToWinId::compareClassName(QFileInfoList list) { - for (int i = 0; i < m_list.size(); i++) { - QFileInfo fileInfo = m_list.at(i);; - QString path_desktop_name = fileInfo.filePath(); + for (int i = 0; i < list.size(); i++) { + QFileInfo fileInfo = list.at(i);; + QString pathDesktopName = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } - 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) { - m_desktopfilePath = fileInfo.filePath(); + pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1); + pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf(".")); + if (pathDesktopName == m_classClass || pathDesktopName == m_className || pathDesktopName == m_statusName) { + return fileInfo.filePath(); } } + return nullptr; } -void ConvertDesktopToWinId::compareCmdExec() +QString ConvertDesktopToWinId::compareCmdExec(QFileInfoList list) { - for (int i = 0; i < m_list.size(); i++) { + for (int i = 0; i < list.size(); i++) { QString cmd; - QFileInfo fileInfo = m_list.at(i); + QFileInfo fileInfo = list.at(i); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } @@ -177,38 +180,38 @@ void ConvertDesktopToWinId::compareCmdExec() } if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) { - m_desktopfilePath = fileInfo.filePath(); + return fileInfo.filePath(); } //仅仅是为了适配微信 - if (m_desktopfilePath.isEmpty()) { - desktopFileExeName = "/usr/lib/" + desktopFileExeName; - if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) { - m_desktopfilePath = fileInfo.filePath(); - } + desktopFileExeName = "/usr/lib/" + desktopFileExeName; + if (desktopFileExeName == m_cmdLine || desktopFileExeName.startsWith(m_cmdLine) || m_cmdLine.startsWith(desktopFileExeName)) { + return fileInfo.filePath(); } } + return nullptr; } //最后的匹配策略汇总 -void ConvertDesktopToWinId::compareLastStrategy() +QString ConvertDesktopToWinId::compareLastStrategy(QFileInfoList list) { - compareCmdName(); + QString desktopFilePath = compareCmdName(list); - if (m_desktopfilePath.isEmpty()) { - compareDesktopClass(); + if (desktopFilePath.isEmpty()) { + desktopFilePath = compareDesktopClass(list); } - if (m_desktopfilePath.isEmpty()) { - containsName(); + if (desktopFilePath.isEmpty()) { + desktopFilePath = containsName(list); } + return desktopFilePath; } -void ConvertDesktopToWinId::compareCmdName() +QString ConvertDesktopToWinId::compareCmdName(QFileInfoList list) { - for (int i = 0; i < m_list.size(); i++) { + for (int i = 0; i < list.size(); i++) { QString cmd; - QFileInfo fileInfo = m_list.at(i); + QFileInfo fileInfo = list.at(i); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } @@ -220,37 +223,39 @@ void ConvertDesktopToWinId::compareCmdName() } if (desktopFileExeName.startsWith(m_className) || desktopFileExeName.endsWith(m_className)) { - m_desktopfilePath = fileInfo.filePath(); + return fileInfo.filePath(); } } + return nullptr; } -void ConvertDesktopToWinId::compareDesktopClass() +QString ConvertDesktopToWinId::compareDesktopClass(QFileInfoList list) { - for (int i = 0; i < m_list.size(); i++) { - QFileInfo fileInfo = m_list.at(i); - QString path_desktop_name = fileInfo.filePath(); + for (int i = 0; i < list.size(); i++) { + QFileInfo fileInfo = list.at(i); + QString pathDesktopName = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; } - path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1); - path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf(".")); + pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1); + pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf(".")); - if (path_desktop_name.startsWith(m_className) || path_desktop_name.endsWith(m_className)) { - m_desktopfilePath = fileInfo.filePath(); + if (pathDesktopName.startsWith(m_className) || pathDesktopName.endsWith(m_className)) { + return fileInfo.filePath(); } - else if (m_className.startsWith(path_desktop_name) || m_className.endsWith(path_desktop_name)) { - m_desktopfilePath = fileInfo.filePath(); + else if (m_className.startsWith(pathDesktopName) || m_className.endsWith(pathDesktopName)) { + return fileInfo.filePath(); } } + return nullptr; } -void ConvertDesktopToWinId::containsName() +QString ConvertDesktopToWinId::containsName(QFileInfoList list) { - for (int i = 0; i < m_list.size(); i++) { + for (int i = 0; i < list.size(); i++) { QString cmd; - QFileInfo fileInfo = m_list.at(i); - QString path_desktop_name = fileInfo.filePath(); + QFileInfo fileInfo = list.at(i); + QString pathDesktopName = fileInfo.filePath(); if (!fileInfo.filePath().endsWith(".desktop")) { continue; @@ -259,13 +264,14 @@ void ConvertDesktopToWinId::containsName() cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data()); QString desktopFileExeName = getDesktopFileName(cmd).remove("\n"); - path_desktop_name = path_desktop_name.mid(path_desktop_name.lastIndexOf("/") + 1); - path_desktop_name = path_desktop_name.left(path_desktop_name.lastIndexOf(".")); + pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1); + pathDesktopName = pathDesktopName.left(pathDesktopName.lastIndexOf(".")); - if (path_desktop_name.contains(m_className) || desktopFileExeName.contains(m_className)) { - m_desktopfilePath = fileInfo.filePath(); + if (pathDesktopName.contains(m_className) || desktopFileExeName.contains(m_className)) { + return fileInfo.filePath(); } } + return nullptr; } //执行头文件中宏定义写好的终端指令获取对应的Exec字段 @@ -284,12 +290,4 @@ QString ConvertDesktopToWinId::getDesktopFileName(QString cmd) ConvertDesktopToWinId::~ConvertDesktopToWinId() { - if (m_dir != nullptr) { - delete m_dir; - m_dir = nullptr; - } - if (m_androidDir) { - delete m_androidDir; - m_androidDir = nullptr; - } } diff --git a/src/UtilityFunction/convertdesktoptowinid.h b/src/UtilityFunction/convertdesktoptowinid.h index 09d99f4..109c14a 100644 --- a/src/UtilityFunction/convertdesktoptowinid.h +++ b/src/UtilityFunction/convertdesktoptowinid.h @@ -23,7 +23,7 @@ #include #include -#define DEKSTOP_FILE_PATH "/usr/share/applications/" +#define DESKTOP_FILE_PATH "/usr/share/applications/" #define USR_SHARE_APP_CURRENT "/usr/share/applications/." #define USR_SHARE_APP_UPER "/usr/share/applications/.." #define PEONY_TRASH "/usr/share/applications/peony-trash.desktop" @@ -36,10 +36,11 @@ #define ANDROID_APP_CURRENT "/.local/share/applications/." #define ANDROID_APP_UPER "/.local/share/applications/.." + /** * @brief The ConvertDesktopToWinId class * 需要实现的功能,desktop文件与windowId的转换 - * 传入WindowId 转化为desktop文件路径 + * 传入desktop文件的路径,转化为(int)WindowId */ class ConvertDesktopToWinId: public QObject @@ -52,26 +53,20 @@ public: QString tranIdToDesktop(WId id); private: - QString m_desktopfilePath = nullptr; QString m_classClass = nullptr; QString m_className = nullptr; QString m_statusName = nullptr; QString m_cmdLine = nullptr; - QDir *m_dir = nullptr; - QDir *m_androidDir = nullptr; - QFileInfoList m_list; - QFileInfoList m_androidList; - QString confirmDesktopFile(KWindowInfo info); - void searchFromEnviron(KWindowInfo info); - void searchAndroidApp(KWindowInfo info); - void compareClassName(); - void compareCmdExec(); - void compareLastStrategy(); - void compareCmdName(); - void compareDesktopClass(); - void containsName(); + QString searchFromEnviron(KWindowInfo info, QFileInfoList list); + QString searchAndroidApp(KWindowInfo info); + QString compareClassName(QFileInfoList list); + QString compareCmdExec(QFileInfoList list); + QString compareLastStrategy(QFileInfoList list); + QString compareCmdName(QFileInfoList list); + QString compareDesktopClass(QFileInfoList list); + QString containsName(QFileInfoList list); QString getDesktopFileName(QString cmd); }; diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp index c471d7c..2c0c45f 100644 --- a/src/UtilityFunction/fullitemdelegate.cpp +++ b/src/UtilityFunction/fullitemdelegate.cpp @@ -23,27 +23,27 @@ FullItemDelegate::FullItemDelegate(QObject *parent, int module): QStyledItemDelegate(parent) { - this->module = module; - m_ukuiMenuInterface = new UkuiMenuInterface; + this->module=module; + pUkuiMenuInterface=new UkuiMenuInterface; } FullItemDelegate::~FullItemDelegate() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete pUkuiMenuInterface; } void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (index.isValid()) { + + if(index.isValid()) + { QStyleOptionViewItem viewOption(option);//用来在视图中画一个item QRectF rect; rect.setX(option.rect.x()); rect.setY(option.rect.y()); rect.setWidth(option.rect.width()); rect.setHeight(option.rect.height()); + //QPainterPath画圆角矩形 const qreal radius = 4; QPainterPath path; @@ -56,9 +56,10 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter->setRenderHint(QPainter::Antialiasing); - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + painter->setRenderHint(QPainter::Antialiasing); + if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) + { // QColor color = option.palette.text().color(); // color.setAlphaF(0.15); painter->save(); @@ -71,136 +72,130 @@ void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti painter->save(); painter->setOpacity(1); - QString desktopfp = index.data(Qt::DisplayRole).value(); - QString iconstr = m_ukuiMenuInterface->getAppIcon(desktopfp); + QString desktopfp=index.data(Qt::DisplayRole).value(); + QString iconstr=pUkuiMenuInterface->getAppIcon(desktopfp); QIcon icon; QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { + if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) + icon=QIcon(iconstr); + else + { iconstr.remove(".png"); iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull() || icon.actualSize(QSize(Style::AppListIconSize, - Style::AppListIconSize)).width() < Style::AppListIconSize) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); - } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } + icon=QIcon::fromTheme(iconstr); + if(icon.isNull()) + { + if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + else + icon=QIcon::fromTheme(QString("application-x-desktop")); } } - QString appname = m_ukuiMenuInterface->getAppName(desktopfp); + QString appname=pUkuiMenuInterface->getAppName(desktopfp); + QRect iconRect; QRect textRect; - iconRect = QRect(rect.x() + Style::AppLeftSpace, - rect.y() + Style::AppTopSpace, - Style::AppListIconSize, - Style::AppListIconSize); - icon.paint(painter, iconRect); + iconRect=QRect(rect.x()+Style::AppLeftSpace , + rect.y()+Style::AppTopSpace, + Style::AppListIconSize, + Style::AppListIconSize); + icon.paint(painter,iconRect); painter->restore(); - painter->save(); - bool is_locked = false; - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); + painter->save(); + bool is_locked=false; + QFileInfo fileInfo(desktopfp); + QString desktopfn=fileInfo.fileName(); //添加固定图标 - if (module == 0) { - if (checkIfLocked(desktopfn)) { - is_locked = true; + if(module==0) + { + if(checkIfLocked(desktopfn)) + { + is_locked=true; QIcon icon(QString(":/data/img/mainviewwidget/lock-fs.svg")); - icon.paint(painter, QRect(iconRect.topRight().x() - 14, iconRect.topRight().y() - 2, 16, 16)); + icon.paint(painter,QRect(iconRect.topRight().x()-14,iconRect.topRight().y()-2,16,16)); } } - painter->restore(); - textRect = QRect(rect.x() + 5, - iconRect.bottom() + Style::AppSpaceBetweenIconText, - rect.width() - 10, - rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); + + textRect=QRect(rect.x()+5, + iconRect.bottom()+Style::AppSpaceBetweenIconText, + rect.width()-10, + rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText); + painter->save(); //添加最近安装蓝色标签 - bool is_recentapp = false; - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic); + bool is_recentapp=false; + QFontMetrics fm=painter->fontMetrics(); + QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-10,Qt::TextShowMnemonic); + if(checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) + { + is_recentapp=true; + appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-23,Qt::TextShowMnemonic); + textRect=QRect(rect.x()+18, + iconRect.bottom()+Style::AppSpaceBetweenIconText, + rect.width()-23, + rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText); - if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { - is_recentapp = true; - appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic); - textRect = QRect(rect.x() + 18, - iconRect.bottom() + Style::AppSpaceBetweenIconText, - rect.width() - 23, - rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); painter->setPen(QPen(Qt::NoPen)); painter->setBrush(QColor("#4d94ff")); - int x = 0; - - if (rect.width() < (23 + fm.boundingRect(appname).width())) { - x = rect.x() + 9; - } else { - x = rect.x() + (rect.width() - 13 - fm.boundingRect(appname).width()) / 2 + 4; - } + int x=0; + if(rect.width()<(23+fm.boundingRect(appname).width())) + x=rect.x()+9; + else + x=rect.x()+(rect.width()-13-fm.boundingRect(appname).width())/2+4; painter->drawEllipse(QPoint(x, - textRect.y() + (fm.boundingRect(appname).height() - 8) / 2 + 4), + textRect.y()+(fm.boundingRect(appname).height()-8)/2+4), 4, 4); - } + } painter->restore(); + painter->save(); // painter->setPen(QPen(option.palette.text().color())); painter->setPen(QPen(Qt::white)); painter->setBrush(Qt::NoBrush); - painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText); + painter->drawText(textRect,Qt::AlignHCenter |Qt::AlignTop,appnameElidedText); // painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); painter->restore(); - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = 0; - - if (!is_locked && is_recentapp) { - len = fm.boundingRect(appname).width() + 23; - } else { - len = fm.boundingRect(appname).width() + 10; + if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) + { + int len=0; + if(!is_locked && is_recentapp) + len=fm.boundingRect(appname).width()+23; + else + len=fm.boundingRect(appname).width()+10; + if(len>rect.width()) + { + QToolTip::showText(QCursor::pos(),appname); } - - if (len > rect.width()) { - QToolTip::showText(QCursor::pos(), appname); - } else { + else { QToolTip::hideText(); } } diff --git a/src/UtilityFunction/fullitemdelegate.h b/src/UtilityFunction/fullitemdelegate.h index c845642..0e24425 100644 --- a/src/UtilityFunction/fullitemdelegate.h +++ b/src/UtilityFunction/fullitemdelegate.h @@ -27,20 +27,20 @@ #include #include #include "src/Interface/ukuimenuinterface.h" - +#include "src/Style/style.h" class FullItemDelegate : public QStyledItemDelegate { Q_OBJECT public: - FullItemDelegate(QObject *parent, int module); + FullItemDelegate(QObject* parent,int module); ~FullItemDelegate(); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; private: - int module = 0; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + int module=0; + UkuiMenuInterface* pUkuiMenuInterface=nullptr; protected: // bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index); diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp index 9bc0aa3..b2eb8a6 100644 --- a/src/UtilityFunction/fulllistview.cpp +++ b/src/UtilityFunction/fulllistview.cpp @@ -26,27 +26,22 @@ FullListView::FullListView(QWidget *parent, int module): QListView(parent) { - this->module = module; + this->module=module; initWidget(); // inCurView = false; - m_ukuiMenuInterface = new UkuiMenuInterface; + pUkuiMenuInterface=new UkuiMenuInterface; // menu=new RightClickMenu; } FullListView::~FullListView() { // delete menu; - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete pUkuiMenuInterface; } void FullListView::initWidget() { viewport()->setAttribute(Qt::WA_TranslucentBackground); - viewport()->setStyleSheet("background:transparent");//在paint中绘制,滚动页面会导致透明效果绘制不及时出现黑影,将paintEvent替换为样式表 - this->setAutoFillBackground(false); this->setSelectionMode(QAbstractItemView::SingleSelection); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // if(module==1 || module==2)s @@ -56,38 +51,44 @@ void FullListView::initWidget() this->setResizeMode(QListView::Adjust); this->setTextElideMode(Qt::ElideRight); this->setMouseTracking(true); - // this->setFocusPolicy(Qt::StrongFocus); + // this->setFocusPolicy(Qt::StrongFocus); this->setMovement(QListView::Static); this->setEditTriggers(QAbstractItemView::NoEditTriggers); - this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth)); + this->setGridSize(QSize(Style::AppListGridSizeWidth,Style::AppListGridSizeWidth)); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame);//移除边框 this->setStyleSheet(QString::fromUtf8("QStandardItemModel#listmodel{border:3px solid #FFFFFF; }QWidget#widget:focus{ border:5px solid #A5A6A1; } ")); - connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); - connect(this, &FullListView::clicked, this, &FullListView::onClicked); - flag = true; - //翻页灵敏度时间调节 - time = new QTimer(this); - connect(time, &QTimer::timeout, [ = ]() { - if (flag == false) { - flag = true; - time->stop(); - } - }); + connect(this,&FullListView::customContextMenuRequested,this,&FullListView::rightClickedSlot); + + connect(this,&FullListView::clicked,this,&FullListView::onClicked); + +// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) +// { +// gsetting = new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); +// if(gsetting->keys().contains(QString("transparency"))) +// transparency = gsetting->get("transparency").toDouble(); +// connect(gsetting,&QGSettings::changed,[this] (const QString &key) +// { +// if (key == "transparency") +// { +// transparency = gsetting->get("transparency").toDouble(); +// } +// }); +// } } void FullListView::addData(QStringList data) { - listmodel = new QStandardItemModel(this); + listmodel=new QStandardItemModel(this); this->setModel(listmodel); - Q_FOREACH (QString desktopfp, data) { - QStandardItem *item = new QStandardItem; - item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + Q_FOREACH(QString desktopfp,data) + { + QStandardItem* item=new QStandardItem; + item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); listmodel->appendRow(item); } - - m_delegate = new FullItemDelegate(this, module); + m_delegate= new FullItemDelegate(this,module); this->setItemDelegate(m_delegate); } @@ -106,71 +107,66 @@ void FullListView::focusOutEvent(QFocusEvent *event) void FullListView::updateData(QStringList data) { listmodel->clear(); - - Q_FOREACH (QString desktopfp, data) { - QStandardItem *item = new QStandardItem; - item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + Q_FOREACH(QString desktopfp,data) + { + QStandardItem* item=new QStandardItem; + item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); listmodel->appendRow(item); } } void FullListView::onClicked(QModelIndex index) { - QVariant var = listmodel->data(index, Qt::DisplayRole); + QVariant var = listmodel->data(index, Qt::DisplayRole); + if(var.isValid()) + { + QString desktopfp=var.value(); + Q_EMIT sendItemClickedSignal(desktopfp); - if (var.isValid()) { - QString desktopfp = var.value(); - Q_EMIT sendItemClickedSignal(desktopfp); - } + } } void FullListView::rightClickedSlot(const QPoint &pos) { Q_UNUSED(pos) - - if (!(this->selectionModel()->selectedIndexes().isEmpty())) { - QModelIndex index = this->currentIndex(); - QVariant var = listmodel->data(index, Qt::DisplayRole); - QString desktopfp = var.value(); + if(!(this->selectionModel()->selectedIndexes().isEmpty())) + { + QModelIndex index=this->currentIndex(); + QVariant var=listmodel->data(index, Qt::DisplayRole); + QString desktopfp=var.value(); RightClickMenu menu; - int ret = menu.showAppBtnMenu(this->mapToGlobal(pos), desktopfp); - - if (module > 0) { + int ret=menu.showAppBtnMenu(this->mapToGlobal(pos), desktopfp); + if(module>0) + { switch (ret) { - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - - default: - break; - } - } else { - switch (ret) { - case 1: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 2: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - - default: - break; + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + default: + break; + } + } + else{ + switch (ret) { + case 1: + Q_EMIT sendUpdateAppListSignal(); + break; + case 2: + Q_EMIT sendUpdateAppListSignal(); + break; + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + default: + break; } } - //this->selectionModel()->clear(); } } @@ -187,24 +183,25 @@ void FullListView::leaveEvent(QEvent *e) Q_UNUSED(e); this->verticalScrollBar()->setVisible(false); // QWidget *current_focus_widget; - // current_focus_widget = QApplication::focusWidget(); + // current_focus_widget = QApplication::focusWidget(); // current_focus_widget = QWidget::focusWidget(); // QPushButton *le= qobject_cast(current_focus_widget); + } void FullListView::selectFirstItem() { qDebug() << "void FullListView::selectFirstItem()"; - - if (this->currentIndex().row() == -1) { - this->setCurrentIndex(this->model()->index(0, 0)); + if(this->currentIndex().row() == -1) + { + this->setCurrentIndex(this->model()->index(0,0)); } } -//void FullListView::paintEvent(QPaintEvent *e) -//{ -// double transparency=getTransparency(); -// QPainter painter(this->viewport()); +void FullListView::paintEvent(QPaintEvent *e) +{ + double transparency=getTransparency(); + QPainter painter(this->viewport()); // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) // { @@ -236,93 +233,91 @@ void FullListView::selectFirstItem() // } // else // { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); // } -// QListView::paintEvent(e); -//} + QListView::paintEvent(e); +} -void FullListView::keyPressEvent(QKeyEvent *e) +void FullListView::keyPressEvent(QKeyEvent* e) { - if (flag) { //避免长按按键界面滚动过快 - flag = false; - time->start(100); - QRect center = visualRect(currentIndex()); - - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - break; - } - - case Qt::Key_Left: { - this->clearFocus(); - - if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { - Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); - } - - this->setFocus(); - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Right: { - this->clearFocus(); - - if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { - Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); - } - - this->setFocus(); - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Up: { - if (module == 0) { - if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) { - this->clearFocus(); - Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); - this->setFocus(); - } - } - - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Down: { - if (module == 0) { - if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { - this->clearFocus(); - Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); - this->setFocus(); - } - } - - return QListView::keyPressEvent(e); - break; - } - - default: - return QListView::keyPressEvent(e); - break; + QRect center = visualRect(currentIndex()); + if(e->type() == QEvent::KeyPress) + { + switch(e->key()) + { + case Qt::Key_Enter: + case Qt::Key_Return: + { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + break; + } + case Qt::Key_Left: + { + this->clearFocus(); + if(mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) + { + Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); } + this->setFocus(); + return QListView::keyPressEvent(e); + break; + } + case Qt::Key_Right: + { + + this->clearFocus(); + if(mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) + { + Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); + } + this->setFocus(); + return QListView::keyPressEvent(e); + break; + } + case Qt::Key_Up: + { + if(module == 0) + { + if(mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) + { + Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); + } + } + return QListView::keyPressEvent(e); + break; + } + case Qt::Key_Down: + { + if(module == 0) + { + if(mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) + { + Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); + } + } + return QListView::keyPressEvent(e); + break; + } + + default: + return QListView::keyPressEvent(e); + break; } } } void FullListView::mousePressEvent(QMouseEvent *event) { - if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { + if(!(this->indexAt(event->pos()).isValid()) && event->button()==Qt::LeftButton) + { Q_EMIT sendHideMainWindowSignal(); - } else { + } + else + { return QListView::mousePressEvent(event); } } diff --git a/src/UtilityFunction/fulllistview.h b/src/UtilityFunction/fulllistview.h index c5c87d5..1cff017 100644 --- a/src/UtilityFunction/fulllistview.h +++ b/src/UtilityFunction/fulllistview.h @@ -33,7 +33,7 @@ class FullListView : public QListView { Q_OBJECT public: - FullListView(QWidget *parent, int module); + FullListView(QWidget *parent,int module); ~FullListView(); void addData(QStringList data);//字母排序模块添加数据 @@ -41,25 +41,23 @@ public: protected: void initWidget(); - void keyPressEvent(QKeyEvent *e); - void enterEvent(QEvent *e) Q_DECL_OVERRIDE; - void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; -// void paintEvent(QPaintEvent *e) override; + void keyPressEvent(QKeyEvent* e); + void enterEvent(QEvent* e) Q_DECL_OVERRIDE; + void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent *e) override; void focusInEvent(QFocusEvent *event); void focusOutEvent(QFocusEvent *event); void mousePressEvent(QMouseEvent *event); private: - FullItemDelegate *m_delegate = nullptr; - QStandardItemModel *listmodel = nullptr; - int module = 0; + FullItemDelegate* m_delegate=nullptr; + QStandardItemModel* listmodel=nullptr; + int module=0; double transparency; - RightClickMenu *menu = nullptr; //右键菜单 + RightClickMenu* menu=nullptr;//右键菜单 QStringList data; - QGSettings *gsetting; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; - bool flag; - QTimer *time = nullptr; + QGSettings* gsetting; + UkuiMenuInterface* pUkuiMenuInterface=nullptr; // bool inCurView; diff --git a/src/UtilityFunction/itemdelegate.cpp b/src/UtilityFunction/itemdelegate.cpp index bd525e5..c031c4a 100644 --- a/src/UtilityFunction/itemdelegate.cpp +++ b/src/UtilityFunction/itemdelegate.cpp @@ -22,30 +22,30 @@ #include #include "src/UtilityFunction/utility.h" -ItemDelegate::ItemDelegate(QObject *parent, int module): +ItemDelegate::ItemDelegate(QObject* parent, int module): QStyledItemDelegate(parent) { - this->module = module; - m_ukuiMenuInterface = new UkuiMenuInterface; + this->module=module; + pUkuiMenuInterface=new UkuiMenuInterface; + } ItemDelegate::~ItemDelegate() { - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete pUkuiMenuInterface; } void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (index.isValid()) { + if(index.isValid()) + { // QStyleOptionViewItem viewOption(option);//用来在视图中画一个item QRectF rect; rect.setX(option.rect.x()); rect.setY(option.rect.y()); rect.setWidth(option.rect.width()); - rect.setHeight(option.rect.height() - 2); + rect.setHeight(option.rect.height()-2); + //QPainterPath画圆角矩形 const qreal radius = 4; QPainterPath path; @@ -58,10 +58,11 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); path.lineTo(rect.topRight() + QPointF(0, radius)); path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - QStringList strlist = index.model()->data(index, Qt::DisplayRole).toStringList(); - painter->setRenderHint(QPainter::Antialiasing); - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); + painter->setRenderHint(QPainter::Antialiasing); + if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) + { QColor color = option.palette.text().color(); color.setAlphaF(0.15); painter->save(); @@ -70,185 +71,168 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->drawPath(path); painter->restore(); } - painter->setOpacity(1); - if (module > 0) { - if (strlist.at(1).toInt() == 1) { - QRect iconRect = QRect(rect.x() + 11, rect.y() + (rect.height() - 32) / 2, Style::defaultIconSize, Style::defaultIconSize); - QString iconstr = m_ukuiMenuInterface->getAppIcon(strlist.at(0)); + if(module>0) + { + if(strlist.at(1).toInt()==1) + { + QRect iconRect=QRect(rect.x()+11,rect.y()+(rect.height()-32)/2,32,32); + QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0)); QIcon icon; QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { + if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) + icon=QIcon(iconstr); + else + { iconstr.remove(".png"); iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull() || icon.actualSize(QSize(Style::defaultIconSize, Style::defaultIconSize)).width() < Style::defaultIconSize) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); - } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } + icon=QIcon::fromTheme(iconstr); + if(icon.isNull()) + { + if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + else + icon=QIcon::fromTheme(QString("application-x-desktop")); } } - painter->save(); - icon.paint(painter, iconRect, Qt::AlignCenter); - QString appname = m_ukuiMenuInterface->getAppName(strlist.at(0)); - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); - painter->drawText(QRect(iconRect.right() + 15, rect.y(), - rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); + icon.paint(painter,iconRect,Qt::AlignLeft); + QString appname=pUkuiMenuInterface->getAppName(strlist.at(0)); + QFontMetrics fm=painter->fontMetrics(); + QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-62,Qt::TextShowMnemonic); + painter->drawText(QRect(iconRect.right()+15,rect.y(), + rect.width()-62,rect.height()),Qt::AlignVCenter,appnameElidedText); painter->restore(); painter->save(); QFileInfo fileInfo(strlist.at(0)); - QString desktopfn = fileInfo.fileName(); - - if (checkIfRecent(desktopfn)) { + QString desktopfn=fileInfo.fileName(); + if(checkIfRecent(desktopfn)) + { painter->setPen(QPen(Qt::NoPen)); painter->setBrush(QColor("#4d94ff")); - painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); + painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4); } - painter->restore(); - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = fm.boundingRect(appname).width(); - - if (len > rect.width() - 62) { - QToolTip::showText(QCursor::pos(), appname); - } else { + if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) + { + int len=fm.boundingRect(appname).width(); + if(len>rect.width()-62) + { + QToolTip::showText(QCursor::pos(),appname); + } + else { QToolTip::hideText(); } } - } else { + } + else + { //绘制分割线 painter->save(); // QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); - QRect textRect = QRect(rect.x() + 11, rect.y(), rect.width(), rect.height()); - painter->drawText(textRect, Qt::AlignVCenter, strlist.at(0)); + QRect textRect=QRect(rect.x()+11,rect.y(),rect.width(),rect.height()); + painter->drawText(textRect,Qt::AlignVCenter,strlist.at(0)); painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(QPen(QColor(option.palette.text().color()), 1)); + painter->setPen(QPen(QColor(option.palette.text().color()),1)); painter->setOpacity(0.1); - painter->drawLine(QPoint(5, rect.bottom()), QPoint(rect.right(), rect.bottom())); + painter->drawLine(QPoint(5,rect.bottom()),QPoint(rect.right(),rect.bottom())); painter->restore(); } - } else { - QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); - QString iconstr = m_ukuiMenuInterface->getAppIcon(strlist.at(0)); + + } + else + { + QRect iconRect=QRect(rect.left()+11,rect.y()+(rect.height()-32)/2,32,32); + QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0)); QIcon icon; QFileInfo iconFileInfo(iconstr); - - if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { - icon = QIcon(iconstr); - } else { + if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) + icon=QIcon(iconstr); + else + { iconstr.remove(".png"); iconstr.remove(".svg"); - icon = QIcon::fromTheme(iconstr); - - if (icon.isNull() || icon.actualSize(QSize(32, 32)).width() < 32) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } + icon=QIcon::fromTheme(iconstr); + if(icon.isNull()) + { + if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) + icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + else + icon=QIcon::fromTheme(QString("application-x-desktop")); } } - - icon.paint(painter, iconRect, Qt::AlignCenter); - QString appname = m_ukuiMenuInterface->getAppName(strlist.at(0)); + icon.paint(painter,iconRect,Qt::AlignLeft); + QString appname=pUkuiMenuInterface->getAppName(strlist.at(0)); QFileInfo fileInfo(strlist.at(0)); - QString desktopfn = fileInfo.fileName(); - - if (checkIfLocked(desktopfn)) { + QString desktopfn=fileInfo.fileName(); + if(checkIfLocked(desktopfn)) + { QIcon icon(QString(":/data/img/mainviewwidget/lock.svg")); - icon.paint(painter, QRect(rect.topRight().x() - 30, rect.y() + (rect.height() - 16) / 2, 16, 16)); + icon.paint(painter,QRect(rect.topRight().x()-22,rect.y()+(rect.height()-16)/2,16,16)); } - painter->setOpacity(1); painter->save(); - - if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { + if(checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) + { painter->setPen(QPen(Qt::NoPen)); painter->setBrush(QColor("#4d94ff")); - painter->drawEllipse(QPoint(rect.topRight().x() - 30, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); + painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4); } - painter->restore(); painter->save(); painter->setPen(QPen(option.palette.text().color())); painter->setBrush(Qt::NoBrush); painter->setOpacity(1); - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); - painter->drawText(QRect(iconRect.right() + 15, rect.y(), - rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); + QFontMetrics fm=painter->fontMetrics(); + QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-62,Qt::TextShowMnemonic); + painter->drawText(QRect(iconRect.right()+15,rect.y(), + rect.width()-62,rect.height()),Qt::AlignVCenter,appnameElidedText); painter->restore(); - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = fm.boundingRect(appname).width(); - - if (len > rect.width() - 62) { - QToolTip::showText(QCursor::pos(), appname); - } else { + if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) + { + int len=fm.boundingRect(appname).width(); + if(len>rect.width()-62) + { + QToolTip::showText(QCursor::pos(),appname); + } + else { QToolTip::hideText(); } } } } + } QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { // QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); // if(strlist.at(1).toInt()==1) - return QSize(298, 44); + return QSize(310,44); // else // return QSize(310,48); + } diff --git a/src/UtilityFunction/itemdelegate.h b/src/UtilityFunction/itemdelegate.h index 8906406..7c00340 100644 --- a/src/UtilityFunction/itemdelegate.h +++ b/src/UtilityFunction/itemdelegate.h @@ -32,14 +32,14 @@ public: /** * @param module为0时为常用模块,1为字母模块、2为功能模块、3为搜索模块 */ - ItemDelegate(QObject *parent, int module); + ItemDelegate(QObject* parent,int module); ~ItemDelegate(); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; private: - int module = 0; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + int module=0; + UkuiMenuInterface* pUkuiMenuInterface=nullptr; }; diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/src/UtilityFunction/letterclassifybutton.cpp index 403281a..62c4ab4 100644 --- a/src/UtilityFunction/letterclassifybutton.cpp +++ b/src/UtilityFunction/letterclassifybutton.cpp @@ -36,7 +36,6 @@ LetterClassifyButton::LetterClassifyButton(QWidget *parent, this->setText(letter); this->setFocusPolicy(Qt::NoFocus); this->setCheckable(true); - this->setStyleSheet("padding: 0px;"); connect(this,&LetterClassifyButton::toggled,this,&LetterClassifyButton::reactToToggle); } diff --git a/src/UtilityFunction/listview.cpp b/src/UtilityFunction/listview.cpp index f554276..4fc0850 100644 --- a/src/UtilityFunction/listview.cpp +++ b/src/UtilityFunction/listview.cpp @@ -24,21 +24,18 @@ ListView::ListView(QWidget *parent, int width, int height, int module): QListView(parent) { - this->w = width; - this->h = height; - this->module = module; + this->w=width; + this->h=height; + this->module=module; initWidget(); - m_ukuiMenuInterface = new UkuiMenuInterface; - menu = new RightClickMenu; + + pUkuiMenuInterface=new UkuiMenuInterface; + menu=new RightClickMenu; } ListView::~ListView() { delete menu; - - if (m_ukuiMenuInterface != nullptr) { - delete m_ukuiMenuInterface; - m_ukuiMenuInterface = nullptr; - } + delete pUkuiMenuInterface; } void ListView::initWidget() @@ -62,100 +59,94 @@ void ListView::initWidget() this->setMouseTracking(true); this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame); - this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + this->verticalScrollBar()->setProperty("drawScrollBarGroove",false); this->setFocus(); - connect(this, &ListView::customContextMenuRequested, this, &ListView::rightClickedSlot); - connect(this, &ListView::clicked, this, &ListView::onClicked); + connect(this,&ListView::customContextMenuRequested,this,&ListView::rightClickedSlot); + connect(this,&ListView::clicked,this,&ListView::onClicked); } void ListView::addData(QVector data) { - listmodel = new QStandardItemModel(this); + listmodel=new QStandardItemModel(this); this->setModel(listmodel); - - Q_FOREACH (QStringList desktopfp, data) { - QStandardItem *item = new QStandardItem; - item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + Q_FOREACH(QStringList desktopfp,data) + { + QStandardItem* item=new QStandardItem; + item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); listmodel->appendRow(item); } - - m_delegate = new ItemDelegate(this, module); + m_delegate= new ItemDelegate(this,module); this->setItemDelegate(m_delegate); } void ListView::updateData(QVector data) { listmodel->clear(); - - Q_FOREACH (QStringList desktopfp, data) { - QStandardItem *item = new QStandardItem; - item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + Q_FOREACH(QStringList desktopfp,data) + { + QStandardItem* item=new QStandardItem; + item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); listmodel->appendRow(item); } - // Q_EMIT dataChanged(createIndex(0,0), createIndex(listmodel->rowCount()-1,0)); } void ListView::onClicked(QModelIndex index) { - QVariant var = listmodel->data(index, Qt::DisplayRole); - - if (var.isValid()) { - Q_EMIT sendItemClickedSignal(var.value()); - } + QVariant var = listmodel->data(index, Qt::DisplayRole); + if(var.isValid()) + { + Q_EMIT sendItemClickedSignal(var.value()); + } } void ListView::rightClickedSlot(const QPoint &pos) { - if (!this->selectionModel()->selectedIndexes().isEmpty()) { - QModelIndex index = this->currentIndex(); + if(!this->selectionModel()->selectedIndexes().isEmpty()) + { + QModelIndex index=this->currentIndex(); // QRect center = visualRect(index); - QVariant var = listmodel->data(index, Qt::DisplayRole); - QStringList strlist = var.value(); - - if (strlist.at(1).toInt() == 1) { + QVariant var=listmodel->data(index, Qt::DisplayRole); + QStringList strlist=var.value(); + if(strlist.at(1).toInt()==1) + { int ret = menu->showAppBtnMenu(this->mapToGlobal(pos), strlist.at(0)); - Q_EMIT sendMainWinActiveSignal(false); - - if (module > 0) { - if (strlist.at(1).toInt() == 1) { + if(module>0) + { + if(strlist.at(1).toInt()==1) + { switch (ret) { - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - - default: - break; - } - } - } else { - switch (ret) { - case 1: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 2: - Q_EMIT sendUpdateAppListSignal(); - break; - case 6: Q_EMIT sendHideMainWindowSignal(); break; - case 7: Q_EMIT sendHideMainWindowSignal(); break; - default: break; + } + } + } + else{ + switch (ret) { + case 1: + Q_EMIT sendUpdateAppListSignal(); + break; + case 2: + Q_EMIT sendUpdateAppListSignal(); + break; + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + default: + break; } } - // this->selectionModel()->clear(); + // this->selectionModel()->clear(); } } } @@ -185,18 +176,19 @@ void ListView::leaveEvent(QEvent *e) void ListView::paintEvent(QPaintEvent *e) { - double transparency = getTransparency(); + double transparency=getTransparency(); QPainter painter(this->viewport()); painter.setOpacity(transparency); painter.setPen(Qt::NoPen); painter.setBrush(this->palette().base()); painter.fillRect(this->rect(), this->palette().base()); + //滚动条 - QPalette p = this->verticalScrollBar()->palette(); + QPalette p=this->verticalScrollBar()->palette(); QColor color(255, 255, 255); // QColor color=p.color(QPalette::Active,QPalette::Button); color.setAlphaF(0.25); - p.setColor(QPalette::Active, QPalette::Button, color); + p.setColor(QPalette::Active,QPalette::Button,color); this->verticalScrollBar()->setPalette(p); QListView::paintEvent(e); } @@ -207,14 +199,14 @@ void ListView::dragLeaveEvent(QDragLeaveEvent *e) QStringList m_desktopfp = pressApp.value(); QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); QFileInfo fileInfo(m_desktopfp.at(0)); - QString desktopfn = fileInfo.fileName(); + QString desktopfn=fileInfo.fileName(); QFile file(m_desktopfp.at(0)); - QString newname = QString(path + "/" + desktopfn); - bool ret = file.copy(QString(path + "/" + desktopfn)); - - if (ret) { + QString newname=QString(path+"/"+desktopfn); + bool ret=file.copy(QString(path+"/"+desktopfn)); + if(ret) + { char command[200]; - sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data()); + sprintf(command,"chmod a+x %s",newname.toLocal8Bit().data()); QProcess::startDetached(QString::fromLocal8Bit(command)); } } @@ -225,40 +217,42 @@ void ListView::mousePressEvent(QMouseEvent *event) return QListView::mousePressEvent(event); } -void ListView::keyPressEvent(QKeyEvent *e) +void ListView::keyPressEvent(QKeyEvent* e) { - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - } + if(e->type()==QEvent::KeyPress) + { + switch(e->key()) + { + case Qt::Key_Enter: + case Qt::Key_Return: + { + QModelIndex index=this->currentIndex(); + Q_EMIT clicked(index); + } break; - - case Qt::Key_Down: { - if (currentIndex().row() == this->model()->rowCount() - 1) { - setCurrentIndex(this->model()->index(0, 0)); - break; - } - - return QListView::keyPressEvent(e); + case Qt::Key_Down: + { + if(currentIndex().row() == this->model()->rowCount() - 1) + { + setCurrentIndex(this->model()->index(0,0)); break; } - - case Qt::Key_Up: { - if (currentIndex().row() == 0) { - setCurrentIndex(this->model()->index(this->model()->rowCount() - 1, 0)); - break; - } - - return QListView::keyPressEvent(e); + return QListView::keyPressEvent(e); + break; + } + case Qt::Key_Up: + { + if(currentIndex().row() == 0) + { + setCurrentIndex(this->model()->index(this->model()->rowCount()-1,0)); break; } - - default: - return QListView::keyPressEvent(e); - break; + return QListView::keyPressEvent(e); + break; + } + default: + return QListView::keyPressEvent(e); + break; } } } diff --git a/src/UtilityFunction/listview.h b/src/UtilityFunction/listview.h index b20f468..b63147e 100644 --- a/src/UtilityFunction/listview.h +++ b/src/UtilityFunction/listview.h @@ -43,25 +43,25 @@ public: protected: void initWidget(); - void enterEvent(QEvent *e) Q_DECL_OVERRIDE; - void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; + void enterEvent(QEvent* e) Q_DECL_OVERRIDE; + void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *e) override; - void keyPressEvent(QKeyEvent *e); + void keyPressEvent(QKeyEvent* e); void dropEvent(QDropEvent *event); void mousePressEvent(QMouseEvent *event); void dragLeaveEvent(QDragLeaveEvent *e); void dragMoveEvent(QDragMoveEvent *event); private: - QStandardItemModel *listmodel = nullptr; - int w = 0; - int h = 0; - int module = 0; - UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QStandardItemModel* listmodel=nullptr; + int w=0; + int h=0; + int module=0; + UkuiMenuInterface* pUkuiMenuInterface=nullptr; - RightClickMenu *menu = nullptr; //右键菜单 + RightClickMenu* menu=nullptr;//右键菜单 QVector data; - ItemDelegate *m_delegate = nullptr; + ItemDelegate* m_delegate=nullptr; int m_preRowCount; QPoint startPos; // QMimeData *mimeData = nullptr; @@ -75,7 +75,6 @@ Q_SIGNALS: void sendItemClickedSignal(QStringList arg);//发送item点击信号 void sendHideMainWindowSignal(); void sendUpdateAppListSignal(); - void sendMainWinActiveSignal(bool flag); }; #endif // LISTVIEW_H diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp index 0ffa9ef..1ccd581 100644 --- a/src/UtilityFunction/proxystyle.cpp +++ b/src/UtilityFunction/proxystyle.cpp @@ -1,20 +1,3 @@ -/* - * 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 #include diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h index 93403a0..397e74a 100644 --- a/src/UtilityFunction/proxystyle.h +++ b/src/UtilityFunction/proxystyle.h @@ -1,20 +1,3 @@ -/* - * 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 diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.cpp b/src/UtilityFunction/softwaredatabaseupdatethread.cpp new file mode 100644 index 0000000..68429d2 --- /dev/null +++ b/src/UtilityFunction/softwaredatabaseupdatethread.cpp @@ -0,0 +1,62 @@ +#include "softwaredatabaseupdatethread.h" +#include +#include +#include +#include +#include +#include +#include "src/UtilityFunction/utility.h" + +#define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" + +SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread(QObject *parent): + QThread(parent) +{ +} + +SoftwareDatabaseUpdateThread::~SoftwareDatabaseUpdateThread() +{ +} + +void SoftwareDatabaseUpdateThread::run() +{ + QSqlDatabase db; + db = QSqlDatabase::addDatabase("QSQLITE", "SoftwareThreadDatabase"); + db.setDatabaseName(DATABASENAME); + + if (false == db.open()) { + qDebug() << db.lastError().text(); + } + + QSqlQuery sql(db); + QJsonDocument jsonDocument = QJsonDocument::fromJson(m_category.toLocal8Bit().data()); + QJsonObject jsonObject = jsonDocument.object(); + QJsonArray jsonArray = jsonObject[jsonObject.keys()[0]].toArray(); + + int number = 0; + db.transaction(); + + Q_FOREACH(QJsonValue jsonValue, jsonArray){ + QJsonObject arrObject = jsonValue.toObject(); + QString execline = QString("replace into appCategory values(\"%0\", \"%1\", \"%2\")") + .arg(arrObject[arrObject.keys()[0]].toString()) + .arg(arrObject[arrObject.keys()[1]].toString()) + .arg(arrObject[arrObject.keys()[2]].toString()); + sql.exec(execline); + + ++number; + if (number % 5000 == 0) { + db.commit(); + db.transaction(); + } + } + db.commit(); + + myDebug() << "数据库已经更新"; + Q_EMIT updateDatabaseSignal(); +} + +void SoftwareDatabaseUpdateThread::getDatabaseList(QString category) +{ + this->m_category = category; +} diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.h b/src/UtilityFunction/softwaredatabaseupdatethread.h new file mode 100644 index 0000000..44b460d --- /dev/null +++ b/src/UtilityFunction/softwaredatabaseupdatethread.h @@ -0,0 +1,27 @@ +#ifndef SOFTWAREDATABASEUPDATETHREAD_H +#define SOFTWAREDATABASEUPDATETHREAD_H + +#include +#include +#include +#include +#include +#include +#include + +class SoftwareDatabaseUpdateThread: public QThread +{ + Q_OBJECT +public: + SoftwareDatabaseUpdateThread(QObject *parent = nullptr); + ~SoftwareDatabaseUpdateThread(); + void run(); + void getDatabaseList(QString category); +Q_SIGNALS: + void updateDatabaseSignal(); + +private: + QString m_category; +}; + +#endif // SOFTWAREDATABASEUPDATETHREAD_H diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp index d10fc82..d01f6af 100644 --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -30,9 +30,6 @@ #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" -bool isHuaWeiPC = false; -bool isPANGU = false; - const QPixmap loadSvg(const QString &fileName, const int size) { QPixmap pixmap(size, size); @@ -98,76 +95,6 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) return QPixmap::fromImage(img); } -QRect getScreenAvailableGeometry() -{ - QRect rect; - QVariantList list; - list.clear(); - QDBusInterface iface(DBUS_NAME, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::sessionBus()); - QDBusReply reply=iface.call("GetPrimaryScreenAvailableGeometry"); - if(iface.isValid() && reply.isValid()) - { - list=reply.value(); - rect = QRect(list.at(0).toInt(),list.at(1).toInt(),list.at(2).toInt(),list.at(3).toInt()); - - } - else - { - rect = qApp->primaryScreen()->availableGeometry(); - } - return rect; -} - -QVariantList getScreenGeometry() -{ - QVariantList list; - list.clear(); - QDBusInterface iface(DBUS_NAME, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::sessionBus()); - QDBusReply reply=iface.call("GetPrimaryScreenPhysicalGeometry"); - if(iface.isValid() && reply.isValid()) - { - list=reply.value(); - } - else - { - QRect rect=QApplication::desktop()->screenGeometry(0); - list.append(QString::number(rect.x())); - list.append(QString::number(rect.y())); - list.append(QString::number(rect.width())); - list.append(QString::number(rect.height())); - - int position=0; - int panelSize=0; - if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); - if(gsetting->keys().contains(QString("panelposition"))) - position=gsetting->get("panelposition").toInt(); - else - position=0; - if(gsetting->keys().contains(QString("panelsize"))) - panelSize=gsetting->get("panelsize").toInt(); - else - panelSize=46; - delete gsetting; - } - else - { - position=0; - panelSize=46; - } - list.append(QString::number(panelSize)); - list.append(QString::number(position)); - } - return list; -} - double getTransparency() { double transparency=0.0; diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h index 33fcc5a..db30fee 100644 --- a/src/UtilityFunction/utility.h +++ b/src/UtilityFunction/utility.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "src/Interface/ukuimenuinterface.h" @@ -31,8 +30,12 @@ #define DBUS_PATH "/panel/position" #define DBUS_INTERFACE "org.ukui.panel" -extern bool isHuaWeiPC; -extern bool isPANGU; +enum PanelPositon{ + BOTTOM = 0, + TOP = 1, + LEFT = 2, + RIGHT = 3 +}; const QPixmap loadSvg(const QString &fileName, const int size); @@ -45,8 +48,6 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source); //调试日志 void debugLog(QString strMsg); -QVariantList getScreenGeometry(); -QRect getScreenAvailableGeometry(); double getTransparency(); QString getEnvOverriddenDesktopFile(int pid); //数据库操作 diff --git a/translations/ukui-menu_bo_CN.ts b/translations/ukui-menu_bo_CN.ts new file mode 100644 index 0000000..091d0ea --- /dev/null +++ b/translations/ukui-menu_bo_CN.ts @@ -0,0 +1,290 @@ + + + + + FunctionClassifyButton + + Mobile + གནས་སྤོར། + + + Internet + སྦྲེལ་རེས་དྲ་རྒྱ། + + + Social + འབྲེལ་འདྲིས། + + + Video + བརྙན་ཟློས། + + + Development + གསར་སྤེལ། + + + Image + པར་རིས།། + + + Game + རོལ་རྩེད། + + + Office + གཞུང་ལས།དྲ་རྒྱ། + + + Education + སློབ་གསོ། + + + System + རྒྱུད་ཁོངས། + + + Others + གཞན་དག + + + + MainViewWidget + + + Search + འཚོལ་བ། + + + + QObject + + + + Office + གཞུང་ལས།དྲ་རྒྱ། + + + + + Development + གསར་སྤེལ། + + + + + Image + པར་རིས།། + + + + + Video + བརྙན་ཟློས། + + + + + Internet + སྦྲེལ་རེས་དྲ་རྒྱ། + + + + + Game + རོལ་རྩེད། + + + + + Education + སློབ་གསོ། + + + + + Social + འབྲེལ་འདྲིས། + + + + + System + རྒྱུད་ཁོངས། + + + + + Safe + + + + + + Others + གཞན་དག + + + + RightClickMenu + + + Pin to all + “ མཉེན་ཆས་ཆ་ཚང་། ” དུ་འཇོག་པ། + + + + Unpin from all + “ མཉེན་ཆས་ཆ་ཚང་། ” ལས་ལེན་པ། + + + + Pin to taskbar + འགན་བྱང་དུ་འཇོག་པ། + + + + Unpin from taskbar + འགན་བྱང་ནས་ལེན་པ། + + + + Add to desktop shortcuts + ཅོག་ངོས་སུ་མྱུར་འཐེབ་སྣོན་པ། + + + + Uninstall + ལྷུ་གཏོར + + + + Sleep + མལ་གསོ། + + + + Log Out + རྩིས་ཐེམ་ནས་བསུབ་པ། + + + + Restart + བསྐྱར་སློང་། + + + + Power Off + འཁོར་ཁ་རྒྱག་པ། + + + + Personalize this list + མགོ་རྩོམ་གདམ་བྱང་གི་རིམ་བྱང་སྒྲིག་འགོད་བྱེད་པ། + + + + SideBarWidget + + + All + མཉེན་ཆས་ཚང་མ། + + + + Letter + འཕྲིན་ཡིག + + + + Function + བྱེད་ནུས། + + + + Trash + སྙིགས་སྒམ། + + + + Computer + རྩིས་ཆས། + + + + Max + ཆེས་ཆེ་བ། + + + + Min + + + + + Personal + མི་སྒེར། + + + + Settings + སྒྲིག་འགོད། + + + + Power + ཁ་རྒྱག་པ། + + + + SplitBarFrame + + Mobile + གནས་སྤོར། + + + Internet + སྦྲེལ་རེས་དྲ་རྒྱ། + + + Social + འབྲེལ་འདྲིས། + + + Video + བརྙན་ཟློས། + + + Development + གསར་སྤེལ། + + + Image + པར་རིས།། + + + Game + རོལ་རྩེད། + + + Office + གཞུང་ལས།དྲ་རྒྱ། + + + Education + སློབ་གསོ། + + + System + རྒྱུད་ཁོངས། + + + Safe + सुरक्षा + + + Others + གཞན་དག + + + diff --git a/ukui-menu.pro b/ukui-menu.pro index a5b48e5..a6658eb 100644 --- a/ukui-menu.pro +++ b/ukui-menu.pro @@ -65,7 +65,6 @@ SOURCES += \ src/SideBarWidget/sidebarwidget.cpp \ src/Style/style.cpp \ src/UtilityFunction/classifybtnscrollarea.cpp \ - src/UtilityFunction/convertdesktoptowinid.cpp \ src/UtilityFunction/fullitemdelegate.cpp \ src/UtilityFunction/fulllistview.cpp \ src/UtilityFunction/functionclassifybutton.cpp \ @@ -104,7 +103,6 @@ HEADERS += \ src/SideBarWidget/sidebarwidget.h \ src/Style/style.h \ src/UtilityFunction/classifybtnscrollarea.h \ - src/UtilityFunction/convertdesktoptowinid.h \ src/UtilityFunction/fullitemdelegate.h \ src/UtilityFunction/fulllistview.h \ src/UtilityFunction/functionclassifybutton.h \ diff --git a/ukui-menu.pro.user b/ukui-menu.pro.user index a5cc0fd..48d277d 100644 --- a/ukui-menu.pro.user +++ b/ukui-menu.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -8,7 +8,7 @@ ProjectExplorer.Project.ActiveTarget - 0 + 0 ProjectExplorer.Project.EditorSettings @@ -28,7 +28,7 @@ QmlJSGlobal - 2 + 2 UTF-8 false 4 @@ -37,6 +37,7 @@ true true 1 + false true false 0 @@ -45,48 +46,58 @@ 0 8 true + false 1 true true true + *.md, *.MD, Makefile false + true ProjectExplorer.Project.PluginSettings - + + + true + false + true + true + true + true + + + 0 + true + ProjectExplorer.Project.Target.0 + Desktop 桌面 桌面 {9d9f9a2c-403b-48c4-83ee-e52b4e889b83} - 0 - 0 - 0 + 0 + 0 + 0 - /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug + 0 + /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug + /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug true QtProjectManager.QMakeBuildStep - true - false - false - false + true Qt4ProjectManager.MakeStep - - false - - - false - 2 + 2 Build Build ProjectExplorer.BuildSteps.Build @@ -95,46 +106,37 @@ true Qt4ProjectManager.MakeStep - - true clean - - false - 1 + 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false + + false Debug Qt4ProjectManager.Qt4BuildConfiguration 2 - /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Release + /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release + /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release true QtProjectManager.QMakeBuildStep - false - false - false - true + true Qt4ProjectManager.MakeStep - - false - - - false - 2 + 2 Build Build ProjectExplorer.BuildSteps.Build @@ -143,46 +145,38 @@ true Qt4ProjectManager.MakeStep - - true clean - - false - 1 + 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false + + false Release Qt4ProjectManager.Qt4BuildConfiguration 0 - /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Profile + 0 + /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile + /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile true QtProjectManager.QMakeBuildStep - true - false - true - true + true Qt4ProjectManager.MakeStep - - false - - - false - 2 + 2 Build Build ProjectExplorer.BuildSteps.Build @@ -191,117 +185,58 @@ true Qt4ProjectManager.MakeStep - - true clean - - false - 1 + 1 Clean Clean ProjectExplorer.BuildSteps.Clean 2 false + + false Profile Qt4ProjectManager.Qt4BuildConfiguration 0 + 0 - 3 + 3 - 0 + 0 Deploy Deploy ProjectExplorer.BuildSteps.Deploy 1 + + false ProjectExplorer.DefaultDeployConfiguration - 1 - + 1 - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F true - 4096 - false - false - 1000 - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - + 2 - Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro - /home/ztz/ukui-menu9X0/ukui-menu/ukui-menu.pro - - false - + Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro + /home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro false true true - false false true - - /home/ztz/ukui-menu9X0/build-ukui-menu-unknown-Debug - 1 + 1 ProjectExplorer.Project.TargetCount - 1 + 1 ProjectExplorer.Project.Updater.FileVersion From 73496bc8e9aca88ddb01ec48045e2173bbc103cd Mon Sep 17 00:00:00 2001 From: lixueman Date: Thu, 11 Aug 2022 17:15:46 +0800 Subject: [PATCH 06/12] init --- COPYING | 0 NEWS | 0 README.md | 51 +- data/img/mainviewwidget/.DS_Store | Bin 0 -> 6148 bytes data/img/mainviewwidget/DM-all-2x.png | Bin 0 -> 633 bytes data/img/mainviewwidget/DM-all.png | Bin 0 -> 361 bytes data/img/mainviewwidget/DM-all.svg | 6 + data/img/mainviewwidget/DM-arrow-2x.png | Bin 0 -> 360 bytes data/img/mainviewwidget/DM-arrow.png | Bin 0 -> 230 bytes data/img/mainviewwidget/DM-arrow.svg | 4 + data/img/mainviewwidget/DM-close-2x.png | Bin 0 -> 460 bytes data/img/mainviewwidget/DM-close.png | Bin 0 -> 323 bytes data/img/mainviewwidget/DM-close.svg | 13 + data/img/mainviewwidget/DM-function-2x.png | Bin 0 -> 427 bytes data/img/mainviewwidget/DM-function.png | Bin 0 -> 292 bytes data/img/mainviewwidget/DM-function.svg | 13 + data/img/mainviewwidget/DM-icon-check.png | Bin 0 -> 285 bytes data/img/mainviewwidget/DM-icon-check.svg | 6 + data/img/mainviewwidget/DM-icon-check@2x.png | Bin 0 -> 486 bytes data/img/mainviewwidget/DM-icon-option.svg | 4 + data/img/mainviewwidget/DM-icon-search.png | Bin 0 -> 432 bytes data/img/mainviewwidget/DM-icon-search.svg | 10 + data/img/mainviewwidget/DM-icon-search@2x.png | Bin 0 -> 762 bytes data/img/mainviewwidget/DM-icon-返回.png | Bin 0 -> 373 bytes data/img/mainviewwidget/DM-icon-返回.svg | 6 + data/img/mainviewwidget/DM-icon-返回@2x.png | Bin 0 -> 627 bytes data/img/mainviewwidget/DM-icon-选项.png | Bin 0 -> 180 bytes data/img/mainviewwidget/DM-icon-选项@2x.png | Bin 0 -> 214 bytes data/img/mainviewwidget/DM-letter-2x.png | Bin 0 -> 669 bytes data/img/mainviewwidget/DM-letter.png | Bin 0 -> 392 bytes data/img/mainviewwidget/DM-letter.svg | 7 + data/img/mainviewwidget/DM-max-2x.png | Bin 0 -> 559 bytes data/img/mainviewwidget/DM-max.png | Bin 0 -> 378 bytes data/img/mainviewwidget/DM-max.svg | 8 + .../mainviewwidget/Development-Checked.svg | 0 .../mainviewwidget/Development-Disabled.svg | 0 .../mainviewwidget/Development-Enabled.svg | 0 .../img/mainviewwidget/Development-Normal.svg | 0 data/img/mainviewwidget/Education-Checked.svg | 0 .../img/mainviewwidget/Education-Disabled.svg | 0 data/img/mainviewwidget/Education-Enabled.svg | 0 data/img/mainviewwidget/Education-Normal.svg | 0 data/img/mainviewwidget/Game-Checked.svg | 0 data/img/mainviewwidget/Game-Disabled.svg | 0 data/img/mainviewwidget/Game-Enabled.svg | 0 data/img/mainviewwidget/Game-Normal.svg | 0 data/img/mainviewwidget/Image-Checked.svg | 0 data/img/mainviewwidget/Image-Disabled.svg | 0 data/img/mainviewwidget/Image-Enabled.svg | 0 data/img/mainviewwidget/Image-Normal.svg | 0 data/img/mainviewwidget/Internet-Checked.svg | 0 data/img/mainviewwidget/Internet-Disabled.svg | 0 data/img/mainviewwidget/Internet-Enabled.svg | 0 data/img/mainviewwidget/Internet-Normal.svg | 0 data/img/mainviewwidget/Mobile-Checked.svg | 0 data/img/mainviewwidget/Mobile-Disabled.svg | 0 data/img/mainviewwidget/Mobile-Enabled.svg | 0 data/img/mainviewwidget/Mobile-Normal.svg | 0 data/img/mainviewwidget/Office-Checked.svg | 0 data/img/mainviewwidget/Office-Disabled.svg | 0 data/img/mainviewwidget/Office-Enabled.svg | 0 data/img/mainviewwidget/Office-Normal.svg | 0 data/img/mainviewwidget/Others-Checked.svg | 0 data/img/mainviewwidget/Others-Disabled.svg | 0 data/img/mainviewwidget/Others-Enabled.svg | 0 data/img/mainviewwidget/Others-Normal.svg | 0 data/img/mainviewwidget/Social-Checked.svg | 0 data/img/mainviewwidget/Social-Disabled.svg | 0 data/img/mainviewwidget/Social-Enabled.svg | 0 data/img/mainviewwidget/Social-Normal.svg | 0 data/img/mainviewwidget/System-Checked.svg | 0 data/img/mainviewwidget/System-Disabled.svg | 0 data/img/mainviewwidget/System-Enabled.svg | 0 data/img/mainviewwidget/System-Normal.svg | 0 data/img/mainviewwidget/Video-Checked.svg | 0 data/img/mainviewwidget/Video-Disabled.svg | 0 data/img/mainviewwidget/Video-Enabled.svg | 0 data/img/mainviewwidget/Video-Normal.svg | 0 data/img/mainviewwidget/all-2x.png | Bin 0 -> 536 bytes data/img/mainviewwidget/all.png | Bin 0 -> 327 bytes data/img/mainviewwidget/all.svg | 4 + data/img/mainviewwidget/attributeaction.svg | 0 data/img/mainviewwidget/close-2x.png | Bin 0 -> 491 bytes data/img/mainviewwidget/close.png | Bin 0 -> 345 bytes data/img/mainviewwidget/close.svg | 13 + data/img/mainviewwidget/downarrow-pressed.svg | 0 data/img/mainviewwidget/downarrow.svg | 0 data/img/mainviewwidget/drop-down-2x.png | Bin 0 -> 371 bytes data/img/mainviewwidget/drop-down.png | Bin 0 -> 226 bytes data/img/mainviewwidget/drop-down.svg | 4 + data/img/mainviewwidget/fixed.svg | 0 data/img/mainviewwidget/full-all-2x.png | Bin 0 -> 899 bytes data/img/mainviewwidget/full-close-2x.png | Bin 0 -> 477 bytes data/img/mainviewwidget/full-close.png | Bin 0 -> 304 bytes data/img/mainviewwidget/full-close.svg | 4 + data/img/mainviewwidget/full-drop-down-2x.png | Bin 0 -> 393 bytes data/img/mainviewwidget/full-drop-down.png | Bin 0 -> 260 bytes data/img/mainviewwidget/full-drop-down.svg | 4 + data/img/mainviewwidget/full-function-2x.png | Bin 0 -> 550 bytes data/img/mainviewwidget/full-function.png | Bin 0 -> 380 bytes data/img/mainviewwidget/full-function.svg | 11 + data/img/mainviewwidget/full-letter-2x.png | Bin 0 -> 867 bytes data/img/mainviewwidget/full-letter.png | Bin 0 -> 472 bytes data/img/mainviewwidget/full-letter.svg | 7 + data/img/mainviewwidget/full-min-2x.png | Bin 0 -> 566 bytes data/img/mainviewwidget/full-min.png | Bin 0 -> 382 bytes data/img/mainviewwidget/full-min.svg | 10 + data/img/mainviewwidget/full-search-2x.png | Bin 0 -> 695 bytes data/img/mainviewwidget/full-search.png | Bin 0 -> 379 bytes data/img/mainviewwidget/full-search.svg | 7 + data/img/mainviewwidget/fullicon-all.png | Bin 0 -> 482 bytes data/img/mainviewwidget/fullicon-all.svg | 4 + data/img/mainviewwidget/function-2x.png | Bin 0 -> 467 bytes data/img/mainviewwidget/function.png | Bin 0 -> 312 bytes data/img/mainviewwidget/function.svg | 11 + data/img/mainviewwidget/icon- search-2x.png | Bin 0 -> 838 bytes data/img/mainviewwidget/icon- search.png | Bin 0 -> 430 bytes data/img/mainviewwidget/icon- search.svg | 10 + data/img/mainviewwidget/icon- 返回.png | Bin 0 -> 377 bytes data/img/mainviewwidget/icon- 返回.svg | 4 + data/img/mainviewwidget/icon- 返回@2x.png | Bin 0 -> 660 bytes data/img/mainviewwidget/icon- 选项.png | Bin 0 -> 176 bytes data/img/mainviewwidget/icon- 选项.svg | 4 + data/img/mainviewwidget/icon- 选项@2x.png | Bin 0 -> 206 bytes data/img/mainviewwidget/icon-check.png | Bin 0 -> 330 bytes data/img/mainviewwidget/icon-check.svg | 4 + data/img/mainviewwidget/icon-check@2x.png | Bin 0 -> 541 bytes data/img/mainviewwidget/leftarrow-hover.svg | 0 data/img/mainviewwidget/leftarrow.svg | 0 data/img/mainviewwidget/letter-2x.png | Bin 0 -> 688 bytes data/img/mainviewwidget/letter.png | Bin 0 -> 421 bytes data/img/mainviewwidget/letter.svg | 7 + data/img/mainviewwidget/lock-fs.svg | 0 data/img/mainviewwidget/lock.svg | 0 data/img/mainviewwidget/max-2x.png | Bin 0 -> 559 bytes data/img/mainviewwidget/max.png | Bin 0 -> 390 bytes data/img/mainviewwidget/max.svg | 8 + data/img/mainviewwidget/power-2x.png | Bin 0 -> 1264 bytes data/img/mainviewwidget/power.png | Bin 0 -> 632 bytes data/img/mainviewwidget/power.svg | 5 + data/img/mainviewwidget/recent-disabled.svg | 0 data/img/mainviewwidget/recent-enabled.svg | 0 data/img/mainviewwidget/recent-gray.svg | 0 data/img/mainviewwidget/recent.svg | 0 data/img/mainviewwidget/rightarrow-hover.svg | 0 data/img/mainviewwidget/rightarrow.svg | 0 data/img/mainviewwidget/search.svg | 0 data/img/mainviewwidget/select.svg | 4 + data/img/mainviewwidget/selected.svg | 4 + data/img/mainviewwidget/ukui-search-blue.svg | 16 + data/img/mainviewwidget/ukui-search.svg | 16 + data/img/mainviewwidget/unfixed.svg | 0 data/img/mainviewwidget/uninstall.svg | 0 data/img/mainviewwidget/uparrow-pressed.svg | 0 data/img/mainviewwidget/uparrow.svg | 0 data/img/sidebarwidget/commonuse.svg | 0 data/img/sidebarwidget/computer.svg | 0 data/img/sidebarwidget/control.svg | 0 data/img/sidebarwidget/default.svg | 1 - data/img/sidebarwidget/fixed.svg | 0 data/img/sidebarwidget/fullusericon.png | Bin data/img/sidebarwidget/function.svg | 0 data/img/sidebarwidget/letter.svg | 0 data/img/sidebarwidget/lock.svg | 0 data/img/sidebarwidget/max.svg | 0 data/img/sidebarwidget/min.svg | 0 data/img/sidebarwidget/personal.svg | 0 data/img/sidebarwidget/rightarrow.svg | 0 data/img/sidebarwidget/setting.svg | 0 data/img/sidebarwidget/shutdown.svg | 0 data/img/sidebarwidget/trash.svg | 0 data/img/sidebarwidget/unfixed.svg | 0 data/img/sidebarwidget/usericon-darkcolor.svg | 0 .../img/sidebarwidget/usericon-lightcolor.svg | 0 debian/changelog | 67 + debian/control | 44 + debian/copyright | 29 + debian/rules | 7 + debian/source/format | 1 + debian/watch | 2 + main.cpp | 124 +- man/ukui-menu.1 | 0 res.qrc | 184 +- src/{ => BackProcess}/DBus/dbus-adaptor.cpp | 6 + src/{ => BackProcess}/DBus/dbus-adaptor.h | 24 +- src/{ => BackProcess}/DBus/dbus.cpp | 9 +- src/{ => BackProcess}/DBus/dbus.h | 3 +- src/{ => BackProcess}/DBus/org.ukui.menu.xml | 0 .../FileWatcher/convert_winid_to_desktop.cpp} | 36 +- .../FileWatcher/convert_winid_to_desktop.h} | 10 +- .../FileWatcher/desktop_watcher.cpp | 38 + src/BackProcess/FileWatcher/desktop_watcher.h | 32 + .../FileWatcher/directory_changed_thread.cpp} | 46 +- .../FileWatcher/directory_changed_thread.h} | 4 +- .../software_database_update_thread.cpp} | 36 +- .../software_database_update_thread.h} | 42 +- .../tablet_directorychanged_thread.cpp | 157 + .../tablet_directorychanged_thread.h | 53 + .../Interface/currenttime_interface.cpp | 90 + .../Interface/currenttime_interface.h | 35 + .../Interface/ukui_chineseletter.cpp | 6252 +++++++++++++++++ .../Interface/ukui_chineseletter.h} | 2 +- .../Interface/ukuimenuinterface.cpp | 1656 +++++ .../Interface/ukuimenuinterface.h | 37 +- .../Search}/file-utils.cpp | 170 +- .../Search}/file-utils.h | 10 +- .../Search}/pinyinWithTone.txt | 0 .../Search}/pinyinWithoutTone.txt | 0 src/BackProcess/Search/searchappthread.cpp | 107 + .../Search}/searchappthread.h | 7 +- .../XEventMonitor/xeventmonitor.cpp | 238 + src/BackProcess/XEventMonitor/xeventmonitor.h | 75 + src/BackProcess/backprocess.pri | 49 + src/BackProcess/tablet/getmodeldata.cpp | 202 + src/BackProcess/tablet/getmodeldata.h | 102 + src/BackProcess/tablet/pagemanager.cpp | 99 + src/BackProcess/tablet/pagemanager.h | 20 + src/CommonUseWidget/commonusewidget.cpp | 136 - src/CommonUseWidget/commonusewidget.h | 108 - src/CommonUseWidget/fullcommonusewidget.cpp | 205 - src/FunctionWidget/fullfunctionwidget.cpp | 587 -- src/FunctionWidget/functionbuttonwidget.cpp | 117 - src/FunctionWidget/functionwidget.cpp | 295 - src/FunctionWidget/functionwidget.h | 137 - src/Interface/ukuichineseletter.cpp | 5827 --------------- src/Interface/ukuimenuinterface.cpp | 939 --- src/LetterWidget/fullletterwidget.cpp | 530 -- src/LetterWidget/letterwidget.cpp | 260 - src/LetterWidget/letterwidget.h | 127 - src/MainViewWidget/mainviewwidget.cpp | 992 --- src/MainViewWidget/mainviewwidget.h | 248 - src/MainWindow/mainwindow.cpp | 559 -- src/MainWindow/mainwindow.h | 119 - src/ModelView/fulllistdelegate.cpp | 109 - src/ModelView/fulllistdelegate.h | 19 - src/ModelView/fulllistitem.cpp | 71 - src/ModelView/fulllistitem.h | 20 - src/ModelView/fulllistmodel.cpp | 74 - src/ModelView/fulllistmodel.h | 30 - src/ModelView/fulllistview.cpp | 141 - src/ModelView/fulllistview.h | 37 - src/QtSingleApplication/QtLockedFile | 0 src/QtSingleApplication/QtSingleApplication | 0 src/QtSingleApplication/qtlocalpeer.cpp | 88 +- src/QtSingleApplication/qtlocalpeer.h | 8 +- src/QtSingleApplication/qtlockedfile.cpp | 1 + src/QtSingleApplication/qtlockedfile.h | 29 +- src/QtSingleApplication/qtlockedfile_unix.cpp | 45 +- src/QtSingleApplication/qtlockedfile_win.cpp | 112 +- .../qtsingleapplication.cpp | 53 +- src/QtSingleApplication/qtsingleapplication.h | 41 +- .../qtsingleapplication.pri | 0 .../qtsinglecoreapplication.cpp | 4 +- .../qtsinglecoreapplication.h | 3 +- .../qtsinglecoreapplication.pri | 0 src/RightClickMenu/menubox.cpp | 36 - src/RightClickMenu/rightclickmenu.cpp | 307 - src/RightClickMenu/uninstallwhitelist.cpp | 84 - .../fullsearchresultwidget.cpp | 143 - src/SearchResultWidget/searchappthread.cpp | 129 - src/SearchResultWidget/searchresultwidget.cpp | 91 - src/SearchResultWidget/searchresultwidget.h | 86 - src/SideBarWidget/sidebarwidget.cpp | 925 --- src/SideBarWidget/sidebarwidget.h | 247 - src/Style/style.cpp | 555 -- .../Button/function_classify_button.cpp | 289 + .../Button/function_classify_button.h} | 47 +- .../Button/letter_classify_button.cpp | 225 + .../Button/letter_classify_button.h} | 25 +- src/UserInterface/Button/tool_button.cpp | 205 + .../Button/tool_button.h} | 16 +- src/UserInterface/ListView/fulllistview.cpp | 134 + src/UserInterface/ListView/fulllistview.h | 56 + src/UserInterface/ListView/klistview.cpp | 116 + src/UserInterface/ListView/klistview.h | 42 + src/UserInterface/ListView/listview.cpp | 190 + .../ListView}/listview.h | 47 +- src/UserInterface/ListView/rightlistview.cpp | 156 + src/UserInterface/ListView/rightlistview.h | 53 + src/UserInterface/ListView/tabletlistview.cpp | 809 +++ src/UserInterface/ListView/tabletlistview.h | 145 + .../Other/classify_btn_scrollarea.cpp} | 83 +- .../Other/classify_btn_scrollarea.h} | 7 +- src/UserInterface/Other/lettertooltip.cpp | 54 + src/UserInterface/Other/lettertooltip.h | 24 + src/UserInterface/Other/rotationlabel.cpp | 38 + src/UserInterface/Other/rotationlabel.h | 21 + .../Other}/scrollarea.cpp | 107 +- .../Other}/scrollarea.h | 10 +- src/UserInterface/RightClickMenu/menubox.cpp | 27 + .../RightClickMenu/menubox.h | 6 +- .../RightClickMenu/rightclickmenu.cpp | 354 + .../RightClickMenu/rightclickmenu.h | 16 +- .../RightClickMenu/tabletrightclickmenu.cpp | 314 + .../RightClickMenu/tabletrightclickmenu.h | 153 + .../ViewItem/full_item_delegate.cpp | 221 + .../ViewItem/full_item_delegate.h} | 18 +- src/UserInterface/ViewItem/itemdelegate.cpp | 352 + .../ViewItem}/itemdelegate.h | 14 +- src/UserInterface/ViewItem/kitemdelegate.cpp | 6 + src/UserInterface/ViewItem/kitemdelegate.h | 16 + .../ViewItem/recent_item_delegate.cpp | 229 + .../ViewItem/recent_item_delegate.h | 24 + .../ViewItem/right_item_delegate.cpp | 195 + .../ViewItem/right_item_delegate.h | 25 + .../ViewItem/tablet_full_itemdelegate.cpp | 214 + .../ViewItem/tablet_full_itemdelegate.h | 55 + src/UserInterface/Widget/animationpage.cpp | 26 + src/UserInterface/Widget/animationpage.h | 14 + .../Widget/full_commonuse_widget.cpp | 309 + .../Widget/full_commonuse_widget.h} | 42 +- .../Widget/full_function_widget.cpp | 589 ++ .../Widget/full_function_widget.h} | 78 +- .../Widget/full_letter_widget.cpp | 606 ++ .../Widget/full_letter_widget.h} | 73 +- .../Widget/full_searchresult_widget.cpp | 274 + .../Widget/full_searchresult_widget.h} | 50 +- src/UserInterface/Widget/function_Widget.cpp | 275 + src/UserInterface/Widget/function_Widget.h | 84 + .../Widget/function_button_widget.cpp | 125 + .../Widget/function_button_widget.h} | 9 +- .../Widget/letter_button_widget.cpp} | 82 +- .../Widget/letter_button_widget.h} | 5 +- src/UserInterface/Widget/main_view_widget.cpp | 78 + src/UserInterface/Widget/main_view_widget.h | 70 + src/UserInterface/Widget/plugin_widget.cpp | 21 + src/UserInterface/Widget/plugin_widget.h | 28 + src/UserInterface/Widget/splitbar_frame.cpp | 78 + .../Widget/splitbar_frame.h} | 32 +- src/UserInterface/Widget/tabview_widget.cpp | 36 + src/UserInterface/Widget/tabview_widget.h | 25 + src/UserInterface/full_mainwindow.cpp | 584 ++ src/UserInterface/full_mainwindow.h | 102 + src/UserInterface/mainwindow.cpp | 1423 ++++ src/UserInterface/mainwindow.h | 251 + src/UserInterface/tabletwindow.cpp | 1079 +++ src/UserInterface/tabletwindow.h | 246 + src/UserInterface/userinterface.pri | 84 + src/UtilityFunction/AbstractInterface.h | 13 + src/UtilityFunction/KySmallPluginInterface.h | 31 + src/UtilityFunction/Style/style.cpp | 255 + src/{ => UtilityFunction}/Style/style.h | 120 +- src/UtilityFunction/abstractInterface.h | 20 + src/UtilityFunction/fullitemdelegate.cpp | 208 - src/UtilityFunction/fulllistview.cpp | 323 - src/UtilityFunction/fulllistview.h | 76 - .../functionclassifybutton.cpp | 301 - src/UtilityFunction/itemdelegate.cpp | 238 - src/UtilityFunction/letterclassifybutton.cpp | 159 - src/UtilityFunction/listview.cpp | 258 - src/UtilityFunction/proxystyle.cpp | 49 - src/UtilityFunction/proxystyle.h | 28 - .../softwaredatabaseupdatethread.h | 27 - src/UtilityFunction/splitbarframe.cpp | 112 - src/UtilityFunction/thumbnail.cpp | 244 + src/UtilityFunction/thumbnail.h | 34 + src/UtilityFunction/toolbutton.cpp | 182 - src/UtilityFunction/utility.cpp | 741 +- src/UtilityFunction/utility.h | 34 +- src/UtilityFunction/utilityfunction.pri | 16 + translations/ukui-menu_bo.ts | 292 - translations/ukui-menu_bo_CN.ts | 378 +- translations/ukui-menu_tr.ts | 432 +- translations/ukui-menu_zh_CN.ts | 433 +- ukui-menu.desktop | 0 ukui-menu.ini | 0 ukui-menu.pro | 98 +- ukui-menu.pro.user | 249 - 368 files changed, 23866 insertions(+), 18470 deletions(-) mode change 100644 => 100755 COPYING mode change 100644 => 100755 NEWS mode change 100644 => 100755 README.md create mode 100755 data/img/mainviewwidget/.DS_Store create mode 100755 data/img/mainviewwidget/DM-all-2x.png create mode 100755 data/img/mainviewwidget/DM-all.png create mode 100755 data/img/mainviewwidget/DM-all.svg create mode 100755 data/img/mainviewwidget/DM-arrow-2x.png create mode 100755 data/img/mainviewwidget/DM-arrow.png create mode 100755 data/img/mainviewwidget/DM-arrow.svg create mode 100755 data/img/mainviewwidget/DM-close-2x.png create mode 100755 data/img/mainviewwidget/DM-close.png create mode 100755 data/img/mainviewwidget/DM-close.svg create mode 100755 data/img/mainviewwidget/DM-function-2x.png create mode 100755 data/img/mainviewwidget/DM-function.png create mode 100755 data/img/mainviewwidget/DM-function.svg create mode 100755 data/img/mainviewwidget/DM-icon-check.png create mode 100755 data/img/mainviewwidget/DM-icon-check.svg create mode 100755 data/img/mainviewwidget/DM-icon-check@2x.png create mode 100755 data/img/mainviewwidget/DM-icon-option.svg create mode 100755 data/img/mainviewwidget/DM-icon-search.png create mode 100755 data/img/mainviewwidget/DM-icon-search.svg create mode 100755 data/img/mainviewwidget/DM-icon-search@2x.png create mode 100755 data/img/mainviewwidget/DM-icon-返回.png create mode 100755 data/img/mainviewwidget/DM-icon-返回.svg create mode 100755 data/img/mainviewwidget/DM-icon-返回@2x.png create mode 100755 data/img/mainviewwidget/DM-icon-选项.png create mode 100755 data/img/mainviewwidget/DM-icon-选项@2x.png create mode 100755 data/img/mainviewwidget/DM-letter-2x.png create mode 100755 data/img/mainviewwidget/DM-letter.png create mode 100755 data/img/mainviewwidget/DM-letter.svg create mode 100755 data/img/mainviewwidget/DM-max-2x.png create mode 100755 data/img/mainviewwidget/DM-max.png create mode 100755 data/img/mainviewwidget/DM-max.svg mode change 100644 => 100755 data/img/mainviewwidget/Development-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Development-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Development-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Development-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Education-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Game-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Image-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Internet-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Mobile-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Office-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Others-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Social-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/System-Normal.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Checked.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/Video-Normal.svg create mode 100755 data/img/mainviewwidget/all-2x.png create mode 100755 data/img/mainviewwidget/all.png create mode 100755 data/img/mainviewwidget/all.svg mode change 100644 => 100755 data/img/mainviewwidget/attributeaction.svg create mode 100755 data/img/mainviewwidget/close-2x.png create mode 100755 data/img/mainviewwidget/close.png create mode 100755 data/img/mainviewwidget/close.svg mode change 100644 => 100755 data/img/mainviewwidget/downarrow-pressed.svg mode change 100644 => 100755 data/img/mainviewwidget/downarrow.svg create mode 100755 data/img/mainviewwidget/drop-down-2x.png create mode 100755 data/img/mainviewwidget/drop-down.png create mode 100755 data/img/mainviewwidget/drop-down.svg mode change 100644 => 100755 data/img/mainviewwidget/fixed.svg create mode 100755 data/img/mainviewwidget/full-all-2x.png create mode 100755 data/img/mainviewwidget/full-close-2x.png create mode 100755 data/img/mainviewwidget/full-close.png create mode 100755 data/img/mainviewwidget/full-close.svg create mode 100755 data/img/mainviewwidget/full-drop-down-2x.png create mode 100755 data/img/mainviewwidget/full-drop-down.png create mode 100755 data/img/mainviewwidget/full-drop-down.svg create mode 100755 data/img/mainviewwidget/full-function-2x.png create mode 100755 data/img/mainviewwidget/full-function.png create mode 100755 data/img/mainviewwidget/full-function.svg create mode 100755 data/img/mainviewwidget/full-letter-2x.png create mode 100755 data/img/mainviewwidget/full-letter.png create mode 100755 data/img/mainviewwidget/full-letter.svg create mode 100755 data/img/mainviewwidget/full-min-2x.png create mode 100755 data/img/mainviewwidget/full-min.png create mode 100755 data/img/mainviewwidget/full-min.svg create mode 100755 data/img/mainviewwidget/full-search-2x.png create mode 100755 data/img/mainviewwidget/full-search.png create mode 100755 data/img/mainviewwidget/full-search.svg create mode 100755 data/img/mainviewwidget/fullicon-all.png create mode 100755 data/img/mainviewwidget/fullicon-all.svg create mode 100755 data/img/mainviewwidget/function-2x.png create mode 100755 data/img/mainviewwidget/function.png create mode 100755 data/img/mainviewwidget/function.svg create mode 100755 data/img/mainviewwidget/icon- search-2x.png create mode 100755 data/img/mainviewwidget/icon- search.png create mode 100755 data/img/mainviewwidget/icon- search.svg create mode 100755 data/img/mainviewwidget/icon- 返回.png create mode 100755 data/img/mainviewwidget/icon- 返回.svg create mode 100755 data/img/mainviewwidget/icon- 返回@2x.png create mode 100755 data/img/mainviewwidget/icon- 选项.png create mode 100755 data/img/mainviewwidget/icon- 选项.svg create mode 100755 data/img/mainviewwidget/icon- 选项@2x.png create mode 100755 data/img/mainviewwidget/icon-check.png create mode 100755 data/img/mainviewwidget/icon-check.svg create mode 100755 data/img/mainviewwidget/icon-check@2x.png mode change 100644 => 100755 data/img/mainviewwidget/leftarrow-hover.svg mode change 100644 => 100755 data/img/mainviewwidget/leftarrow.svg create mode 100755 data/img/mainviewwidget/letter-2x.png create mode 100755 data/img/mainviewwidget/letter.png create mode 100755 data/img/mainviewwidget/letter.svg mode change 100644 => 100755 data/img/mainviewwidget/lock-fs.svg mode change 100644 => 100755 data/img/mainviewwidget/lock.svg create mode 100755 data/img/mainviewwidget/max-2x.png create mode 100755 data/img/mainviewwidget/max.png create mode 100755 data/img/mainviewwidget/max.svg create mode 100755 data/img/mainviewwidget/power-2x.png create mode 100755 data/img/mainviewwidget/power.png create mode 100755 data/img/mainviewwidget/power.svg mode change 100644 => 100755 data/img/mainviewwidget/recent-disabled.svg mode change 100644 => 100755 data/img/mainviewwidget/recent-enabled.svg mode change 100644 => 100755 data/img/mainviewwidget/recent-gray.svg mode change 100644 => 100755 data/img/mainviewwidget/recent.svg mode change 100644 => 100755 data/img/mainviewwidget/rightarrow-hover.svg mode change 100644 => 100755 data/img/mainviewwidget/rightarrow.svg mode change 100644 => 100755 data/img/mainviewwidget/search.svg create mode 100755 data/img/mainviewwidget/select.svg create mode 100755 data/img/mainviewwidget/selected.svg create mode 100755 data/img/mainviewwidget/ukui-search-blue.svg create mode 100755 data/img/mainviewwidget/ukui-search.svg mode change 100644 => 100755 data/img/mainviewwidget/unfixed.svg mode change 100644 => 100755 data/img/mainviewwidget/uninstall.svg mode change 100644 => 100755 data/img/mainviewwidget/uparrow-pressed.svg mode change 100644 => 100755 data/img/mainviewwidget/uparrow.svg mode change 100644 => 100755 data/img/sidebarwidget/commonuse.svg mode change 100644 => 100755 data/img/sidebarwidget/computer.svg mode change 100644 => 100755 data/img/sidebarwidget/control.svg delete mode 100644 data/img/sidebarwidget/default.svg mode change 100644 => 100755 data/img/sidebarwidget/fixed.svg mode change 100644 => 100755 data/img/sidebarwidget/fullusericon.png mode change 100644 => 100755 data/img/sidebarwidget/function.svg mode change 100644 => 100755 data/img/sidebarwidget/letter.svg mode change 100644 => 100755 data/img/sidebarwidget/lock.svg mode change 100644 => 100755 data/img/sidebarwidget/max.svg mode change 100644 => 100755 data/img/sidebarwidget/min.svg mode change 100644 => 100755 data/img/sidebarwidget/personal.svg mode change 100644 => 100755 data/img/sidebarwidget/rightarrow.svg mode change 100644 => 100755 data/img/sidebarwidget/setting.svg mode change 100644 => 100755 data/img/sidebarwidget/shutdown.svg mode change 100644 => 100755 data/img/sidebarwidget/trash.svg mode change 100644 => 100755 data/img/sidebarwidget/unfixed.svg mode change 100644 => 100755 data/img/sidebarwidget/usericon-darkcolor.svg mode change 100644 => 100755 data/img/sidebarwidget/usericon-lightcolor.svg create mode 100755 debian/changelog create mode 100755 debian/control create mode 100755 debian/copyright create mode 100755 debian/rules create mode 100755 debian/source/format create mode 100755 debian/watch mode change 100644 => 100755 main.cpp mode change 100644 => 100755 man/ukui-menu.1 mode change 100644 => 100755 res.qrc rename src/{ => BackProcess}/DBus/dbus-adaptor.cpp (89%) mode change 100644 => 100755 rename src/{ => BackProcess}/DBus/dbus-adaptor.h (62%) mode change 100644 => 100755 rename src/{ => BackProcess}/DBus/dbus.cpp (65%) mode change 100644 => 100755 rename src/{ => BackProcess}/DBus/dbus.h (81%) mode change 100644 => 100755 rename src/{ => BackProcess}/DBus/org.ukui.menu.xml (100%) mode change 100644 => 100755 rename src/{UtilityFunction/convertdesktoptowinid.cpp => BackProcess/FileWatcher/convert_winid_to_desktop.cpp} (90%) mode change 100644 => 100755 rename src/{UtilityFunction/convertdesktoptowinid.h => BackProcess/FileWatcher/convert_winid_to_desktop.h} (91%) mode change 100644 => 100755 create mode 100755 src/BackProcess/FileWatcher/desktop_watcher.cpp create mode 100755 src/BackProcess/FileWatcher/desktop_watcher.h rename src/{MainViewWidget/directorychangedthread.cpp => BackProcess/FileWatcher/directory_changed_thread.cpp} (55%) mode change 100644 => 100755 rename src/{MainViewWidget/directorychangedthread.h => BackProcess/FileWatcher/directory_changed_thread.h} (92%) mode change 100644 => 100755 rename src/{UtilityFunction/softwaredatabaseupdatethread.cpp => BackProcess/FileWatcher/software_database_update_thread.cpp} (62%) mode change 100644 => 100755 rename src/{RightClickMenu/uninstallwhitelist.h => BackProcess/FileWatcher/software_database_update_thread.h} (60%) mode change 100644 => 100755 create mode 100755 src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp create mode 100755 src/BackProcess/FileWatcher/tablet_directorychanged_thread.h create mode 100755 src/BackProcess/Interface/currenttime_interface.cpp create mode 100755 src/BackProcess/Interface/currenttime_interface.h create mode 100755 src/BackProcess/Interface/ukui_chineseletter.cpp rename src/{Interface/ukuichineseletter.h => BackProcess/Interface/ukui_chineseletter.h} (96%) mode change 100644 => 100755 create mode 100755 src/BackProcess/Interface/ukuimenuinterface.cpp rename src/{ => BackProcess}/Interface/ukuimenuinterface.h (71%) mode change 100644 => 100755 rename src/{SearchResultWidget => BackProcess/Search}/file-utils.cpp (68%) mode change 100644 => 100755 rename src/{SearchResultWidget => BackProcess/Search}/file-utils.h (90%) mode change 100644 => 100755 rename src/{SearchResultWidget => BackProcess/Search}/pinyinWithTone.txt (100%) mode change 100644 => 100755 rename src/{SearchResultWidget => BackProcess/Search}/pinyinWithoutTone.txt (100%) mode change 100644 => 100755 create mode 100755 src/BackProcess/Search/searchappthread.cpp rename src/{SearchResultWidget => BackProcess/Search}/searchappthread.h (88%) mode change 100644 => 100755 create mode 100755 src/BackProcess/XEventMonitor/xeventmonitor.cpp create mode 100755 src/BackProcess/XEventMonitor/xeventmonitor.h create mode 100755 src/BackProcess/backprocess.pri create mode 100755 src/BackProcess/tablet/getmodeldata.cpp create mode 100755 src/BackProcess/tablet/getmodeldata.h create mode 100755 src/BackProcess/tablet/pagemanager.cpp create mode 100755 src/BackProcess/tablet/pagemanager.h delete mode 100644 src/CommonUseWidget/commonusewidget.cpp delete mode 100644 src/CommonUseWidget/commonusewidget.h delete mode 100644 src/CommonUseWidget/fullcommonusewidget.cpp delete mode 100644 src/FunctionWidget/fullfunctionwidget.cpp delete mode 100644 src/FunctionWidget/functionbuttonwidget.cpp delete mode 100644 src/FunctionWidget/functionwidget.cpp delete mode 100644 src/FunctionWidget/functionwidget.h delete mode 100644 src/Interface/ukuichineseletter.cpp delete mode 100644 src/Interface/ukuimenuinterface.cpp delete mode 100644 src/LetterWidget/fullletterwidget.cpp delete mode 100644 src/LetterWidget/letterwidget.cpp delete mode 100644 src/LetterWidget/letterwidget.h delete mode 100644 src/MainViewWidget/mainviewwidget.cpp delete mode 100644 src/MainViewWidget/mainviewwidget.h delete mode 100644 src/MainWindow/mainwindow.cpp delete mode 100644 src/MainWindow/mainwindow.h delete mode 100644 src/ModelView/fulllistdelegate.cpp delete mode 100644 src/ModelView/fulllistdelegate.h delete mode 100644 src/ModelView/fulllistitem.cpp delete mode 100644 src/ModelView/fulllistitem.h delete mode 100644 src/ModelView/fulllistmodel.cpp delete mode 100644 src/ModelView/fulllistmodel.h delete mode 100644 src/ModelView/fulllistview.cpp delete mode 100644 src/ModelView/fulllistview.h mode change 100644 => 100755 src/QtSingleApplication/QtLockedFile mode change 100644 => 100755 src/QtSingleApplication/QtSingleApplication mode change 100644 => 100755 src/QtSingleApplication/qtlocalpeer.cpp mode change 100644 => 100755 src/QtSingleApplication/qtlocalpeer.h mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile.cpp mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile.h mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile_unix.cpp mode change 100644 => 100755 src/QtSingleApplication/qtlockedfile_win.cpp mode change 100644 => 100755 src/QtSingleApplication/qtsingleapplication.cpp mode change 100644 => 100755 src/QtSingleApplication/qtsingleapplication.h mode change 100644 => 100755 src/QtSingleApplication/qtsingleapplication.pri mode change 100644 => 100755 src/QtSingleApplication/qtsinglecoreapplication.cpp mode change 100644 => 100755 src/QtSingleApplication/qtsinglecoreapplication.h mode change 100644 => 100755 src/QtSingleApplication/qtsinglecoreapplication.pri delete mode 100644 src/RightClickMenu/menubox.cpp delete mode 100644 src/RightClickMenu/rightclickmenu.cpp delete mode 100644 src/RightClickMenu/uninstallwhitelist.cpp delete mode 100644 src/SearchResultWidget/fullsearchresultwidget.cpp delete mode 100644 src/SearchResultWidget/searchappthread.cpp delete mode 100644 src/SearchResultWidget/searchresultwidget.cpp delete mode 100644 src/SearchResultWidget/searchresultwidget.h delete mode 100644 src/SideBarWidget/sidebarwidget.cpp delete mode 100644 src/SideBarWidget/sidebarwidget.h delete mode 100644 src/Style/style.cpp create mode 100755 src/UserInterface/Button/function_classify_button.cpp rename src/{UtilityFunction/functionclassifybutton.h => UserInterface/Button/function_classify_button.h} (64%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Button/letter_classify_button.cpp rename src/{UtilityFunction/letterclassifybutton.h => UserInterface/Button/letter_classify_button.h} (73%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Button/tool_button.cpp rename src/{UtilityFunction/toolbutton.h => UserInterface/Button/tool_button.h} (86%) mode change 100644 => 100755 create mode 100755 src/UserInterface/ListView/fulllistview.cpp create mode 100755 src/UserInterface/ListView/fulllistview.h create mode 100755 src/UserInterface/ListView/klistview.cpp create mode 100755 src/UserInterface/ListView/klistview.h create mode 100755 src/UserInterface/ListView/listview.cpp rename src/{UtilityFunction => UserInterface/ListView}/listview.h (52%) mode change 100644 => 100755 create mode 100755 src/UserInterface/ListView/rightlistview.cpp create mode 100755 src/UserInterface/ListView/rightlistview.h create mode 100755 src/UserInterface/ListView/tabletlistview.cpp create mode 100755 src/UserInterface/ListView/tabletlistview.h rename src/{UtilityFunction/classifybtnscrollarea.cpp => UserInterface/Other/classify_btn_scrollarea.cpp} (53%) mode change 100644 => 100755 rename src/{UtilityFunction/classifybtnscrollarea.h => UserInterface/Other/classify_btn_scrollarea.h} (85%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Other/lettertooltip.cpp create mode 100755 src/UserInterface/Other/lettertooltip.h create mode 100644 src/UserInterface/Other/rotationlabel.cpp create mode 100644 src/UserInterface/Other/rotationlabel.h rename src/{UtilityFunction => UserInterface/Other}/scrollarea.cpp (50%) mode change 100644 => 100755 rename src/{UtilityFunction => UserInterface/Other}/scrollarea.h (84%) mode change 100644 => 100755 create mode 100755 src/UserInterface/RightClickMenu/menubox.cpp rename src/{ => UserInterface}/RightClickMenu/menubox.h (71%) mode change 100644 => 100755 create mode 100755 src/UserInterface/RightClickMenu/rightclickmenu.cpp rename src/{ => UserInterface}/RightClickMenu/rightclickmenu.h (88%) mode change 100644 => 100755 create mode 100755 src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp create mode 100755 src/UserInterface/RightClickMenu/tabletrightclickmenu.h create mode 100755 src/UserInterface/ViewItem/full_item_delegate.cpp rename src/{UtilityFunction/fullitemdelegate.h => UserInterface/ViewItem/full_item_delegate.h} (73%) mode change 100644 => 100755 create mode 100755 src/UserInterface/ViewItem/itemdelegate.cpp rename src/{UtilityFunction => UserInterface/ViewItem}/itemdelegate.h (83%) mode change 100644 => 100755 create mode 100755 src/UserInterface/ViewItem/kitemdelegate.cpp create mode 100755 src/UserInterface/ViewItem/kitemdelegate.h create mode 100755 src/UserInterface/ViewItem/recent_item_delegate.cpp create mode 100755 src/UserInterface/ViewItem/recent_item_delegate.h create mode 100755 src/UserInterface/ViewItem/right_item_delegate.cpp create mode 100755 src/UserInterface/ViewItem/right_item_delegate.h create mode 100755 src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp create mode 100755 src/UserInterface/ViewItem/tablet_full_itemdelegate.h create mode 100755 src/UserInterface/Widget/animationpage.cpp create mode 100755 src/UserInterface/Widget/animationpage.h create mode 100755 src/UserInterface/Widget/full_commonuse_widget.cpp rename src/{CommonUseWidget/fullcommonusewidget.h => UserInterface/Widget/full_commonuse_widget.h} (71%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Widget/full_function_widget.cpp rename src/{FunctionWidget/fullfunctionwidget.h => UserInterface/Widget/full_function_widget.h} (69%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Widget/full_letter_widget.cpp rename src/{LetterWidget/fullletterwidget.h => UserInterface/Widget/full_letter_widget.h} (69%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Widget/full_searchresult_widget.cpp rename src/{SearchResultWidget/fullsearchresultwidget.h => UserInterface/Widget/full_searchresult_widget.h} (66%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Widget/function_Widget.cpp create mode 100755 src/UserInterface/Widget/function_Widget.h create mode 100755 src/UserInterface/Widget/function_button_widget.cpp rename src/{FunctionWidget/functionbuttonwidget.h => UserInterface/Widget/function_button_widget.h} (89%) mode change 100644 => 100755 rename src/{LetterWidget/letterbuttonwidget.cpp => UserInterface/Widget/letter_button_widget.cpp} (52%) mode change 100644 => 100755 rename src/{LetterWidget/letterbuttonwidget.h => UserInterface/Widget/letter_button_widget.h} (93%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Widget/main_view_widget.cpp create mode 100755 src/UserInterface/Widget/main_view_widget.h create mode 100755 src/UserInterface/Widget/plugin_widget.cpp create mode 100755 src/UserInterface/Widget/plugin_widget.h create mode 100755 src/UserInterface/Widget/splitbar_frame.cpp rename src/{UtilityFunction/splitbarframe.h => UserInterface/Widget/splitbar_frame.h} (67%) mode change 100644 => 100755 create mode 100755 src/UserInterface/Widget/tabview_widget.cpp create mode 100755 src/UserInterface/Widget/tabview_widget.h create mode 100755 src/UserInterface/full_mainwindow.cpp create mode 100755 src/UserInterface/full_mainwindow.h create mode 100755 src/UserInterface/mainwindow.cpp create mode 100755 src/UserInterface/mainwindow.h create mode 100755 src/UserInterface/tabletwindow.cpp create mode 100755 src/UserInterface/tabletwindow.h create mode 100755 src/UserInterface/userinterface.pri create mode 100755 src/UtilityFunction/AbstractInterface.h create mode 100755 src/UtilityFunction/KySmallPluginInterface.h create mode 100755 src/UtilityFunction/Style/style.cpp rename src/{ => UtilityFunction}/Style/style.h (64%) mode change 100644 => 100755 create mode 100755 src/UtilityFunction/abstractInterface.h delete mode 100644 src/UtilityFunction/fullitemdelegate.cpp delete mode 100644 src/UtilityFunction/fulllistview.cpp delete mode 100644 src/UtilityFunction/fulllistview.h delete mode 100644 src/UtilityFunction/functionclassifybutton.cpp delete mode 100644 src/UtilityFunction/itemdelegate.cpp delete mode 100644 src/UtilityFunction/letterclassifybutton.cpp delete mode 100644 src/UtilityFunction/listview.cpp delete mode 100644 src/UtilityFunction/proxystyle.cpp delete mode 100644 src/UtilityFunction/proxystyle.h delete mode 100644 src/UtilityFunction/softwaredatabaseupdatethread.h delete mode 100644 src/UtilityFunction/splitbarframe.cpp create mode 100755 src/UtilityFunction/thumbnail.cpp create mode 100755 src/UtilityFunction/thumbnail.h delete mode 100644 src/UtilityFunction/toolbutton.cpp mode change 100644 => 100755 src/UtilityFunction/utility.cpp mode change 100644 => 100755 src/UtilityFunction/utility.h create mode 100755 src/UtilityFunction/utilityfunction.pri delete mode 100644 translations/ukui-menu_bo.ts mode change 100644 => 100755 translations/ukui-menu_tr.ts mode change 100644 => 100755 translations/ukui-menu_zh_CN.ts mode change 100644 => 100755 ukui-menu.desktop mode change 100644 => 100755 ukui-menu.ini mode change 100644 => 100755 ukui-menu.pro delete mode 100644 ukui-menu.pro.user diff --git a/COPYING b/COPYING old mode 100644 new mode 100755 diff --git a/NEWS b/NEWS old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index e1d44df..ff12dc9 --- a/README.md +++ b/README.md @@ -2,7 +2,34 @@ ![build](https://github.com/ukui/ukui-menu/workflows/Check%20build/badge.svg?branch=master) -An advanced menu for UKUI, providing common and all software mixed sort module, alphabet classification module, functional classification module and search module. +An advanced menu for UKUI, providing common and all software mixed sort module, alphabet classification module, functional classification module and search module. Provides favorites and recent file functions, You can fix it to your favorites area by right-clicking the application. Provides two display modes: default window and full-screen window. + +# The project structure + +## data/img + +Provide icon files for the projec. + +## src/BackProcess + +Background data processing function realization, Includes DBUS, path listening, data acquisition, and search functions. + +## src/QtSingleApplication + +Singleton pattern processing. + +## src/UserInterface + +The UI implementation. + +## src/UtilityFunction + +Implementation of common functions, including database operations. + +## translations + +Translation files + # How to report bugs Bugs should be reported to the UKUI bug tracking system: @@ -15,6 +42,7 @@ Please read the HACKING file for information on where to send changes or bugfixes for this package. # How to build + ## Preparation You can build pre-depends with such command: @@ -33,3 +61,24 @@ Note: build-depends references the paragraph in debian/control. > sudo make install Note: If you want to run ukui-menu, You just need to execute the ukui-menu command at the terminal. + +# DBUS interface + +BUS Name:org.ukui.menu + +path:/org/ukui/menu + +Interface:org.ukui.menu + +Method name: + +GetMenuStatus () <---> Get ukui-menu display hidden status + +WinKeyResponse () <---> ukui-menu display hidden state change interface + +GetSecurityConfigPath () <---> Get security control profile path + +# Configuration file + +.config/ukui/Ukuimenu.db + diff --git a/data/img/mainviewwidget/.DS_Store b/data/img/mainviewwidget/.DS_Store new file mode 100755 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0g0%imoB-!uha1yBay{C&~NCfBG(6_mV350Iqhu*b2`g8wj?iGgR%#E8aGe> z7op`A$7s>A=UBMrKbCErVt6u8Z%ED5QwcbA!%)2X z`MFH?<^1Qk=BSqDGI)Q!^VN0-+v4KJZS7LVQygx0vp+87ypzj1>A}LkcNZS}a!cTC z$fC8!QX}U%WiuKtxsvpCyX(iO|wdlJ#DNb*Ce2<7z zMQ35^dZs&;r%qPe6&?(FE|?G=ee1xt$94)X(qPaWK*KxymWQT^(ASS)O6Z zZ9*BDXKyF&VtKcX=}+=)xh$Xcyce6|GmdJ?Dc@_lHGek4;qQ-f^hLKky;<;!caCQA z?%kh+7!nvCbZzF|X7xw)N#|9~!`qJDIr8w4qkYZYAIn95FdmJ(aN>5y%{`zb;OXk; Jvd$@?2>|3A|GWSI literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-all.png b/data/img/mainviewwidget/DM-all.png new file mode 100755 index 0000000000000000000000000000000000000000..b05d7fa12f2216b254defd31629a0407729de68a GIT binary patch literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1gh1Cceo z%o`e0neI5;IUp#pFz*pZ&jU6iCh0Al+y)E*?@eukJ^xJPuRZzt?$=YvTJ249XS&exP zcj`w@Tk7Pta_hPWtW}?F + + + + + diff --git a/data/img/mainviewwidget/DM-arrow-2x.png b/data/img/mainviewwidget/DM-arrow-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..7cd5c3520da8dbb74887fe8a25651c5c56f0b786 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1uz}^K@|xiQs%2yqousfk3aI zko1L%7afnXg%~*Q(mBC0vtg2+Y^;~s0-By!V~fB%jpqvAX8d^cv`}q9^WE$tX79XTmTD!uNKZ6*JVpJ4;PdG}_x@B~ zZdu$cdLroJk$JZl>@ literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-arrow.png b/data/img/mainviewwidget/DM-arrow.png new file mode 100755 index 0000000000000000000000000000000000000000..3b4fe22971642754637c3109f80466dc94fc457b GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1&f!t(F` z|M^@;k_?_V-f)=1^jP__&j}foZ-xriJgWp#0yG5V-6yphOFq;wVGG!-9N;0TRWp6! z#6tU7LI%@WXDfK{EMd&xu + + + diff --git a/data/img/mainviewwidget/DM-close-2x.png b/data/img/mainviewwidget/DM-close-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..5dbfa4e02a5994cf04ff6fe2cd09763d090194ab GIT binary patch literal 460 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yB4$z7VnJ6*0V zeew(5$QuuC$~Jym>2R<;Tcxh;d}7}G_-=+f8Lb;SjO)Y>FeQqHGiNB+JW^xeJfxk+ z=HW0WV2SvRh_^`xFWSqklIocI;aHB}!;+q~ehb;9b_Q&5zYcDEG}G=}&d0xJRN{9r zEXzN)CA{LZ`LtuV4bL(Z9(1hX?ciIzI(b%>f*8N7-YU-0<1Aa&2^J=M%`xNCZ_#45 z{HWi=uf)AT^t)3BLs%idi_ih>yw(YQ4}Y{Dx&3fi+SbQ{Pv^X2o}cF`cB80X>VL;a gVTVFJ$rGs$n0+o9a7{UT!Wk5*p00i_>zopr06H0^c>n+a literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-close.png b/data/img/mainviewwidget/DM-close.png new file mode 100755 index 0000000000000000000000000000000000000000..af003706014c62554e7bd97ae20d5f531dedd074 GIT binary patch literal 323 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1N<#6s|H&_!M*MIP42 z4C@ZC?dnvXBfX<>^&O7w2YVOzIm~=u#&F+wl7qAG{`H>xUcckk^Ut|G{iuZckDIf& zb_RRBy!ebix8X1Mz8(*bZ}-+)K3`x^>tPTRCDi2lq_gzh>bakPHGJgXlTh8tZ9P5c zo?;7UVY)L@Scp)AIro`e%Jyv=Kex%a?v*t4>;AF!@tLpNFaB*hyl{haP}9}~8TNae uzs+}uMX6M^>{gY?YshceZWMlL?i%^K#T7Q2;v2VvJmcx==d#Wzp$Pzfi*A4b literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-close.svg b/data/img/mainviewwidget/DM-close.svg new file mode 100755 index 0000000..8992eda --- /dev/null +++ b/data/img/mainviewwidget/DM-close.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/data/img/mainviewwidget/DM-function-2x.png b/data/img/mainviewwidget/DM-function-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..aefcb56934b25e5746414adc5cf6dc769900497b GIT binary patch literal 427 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9k(bL5-B!cs8*jwI13IeQ; z8Tt~`H%Q;`Ti};uzQJ$7>=n`v*zy9x3Yco9J2?L^P&9qX-`^rr@Lu+~wyHYI_WE## zWh@eHiTX=z4uvmXA2j2TX=;yUc<556xG4>H|A;Zw8@dbS&NyNuxMQ(tgS>$)$9fhw zg+SNWAIwvVd3TuBglp_-etS{+%SPQ}6J;58Y(1>Ez4F9QGj|@|dVh%{_a=Oep3+bp zwP?2ArhATyeoygDxYWm*;@2SRv6q=O+@t5cqu@#A^Zz*2v>WR8eB_%Vo3+;Wl;v)w zISkqdxKcznO!awnT{q5o%`A@i#MJ{`}l5ed2mU=feg08#Zm)<>~Eh?>4di!-IogcbC8arNDh}fBk<3Bl#n2D;Zb1 zil;Mh{c{&TlE&b{yD3Vo#CORjO|yp93B5b^FkW`Qz~JiY%044W!gj}@hDQ!AW)Ik^ zoSJ@0&TLz?lTo-?{poW5`KSK<`&%s@(3B9AmYiHXebS^V7UPtJOa=}C>l^+#4|zeZ N^>p=fS?83{1OQJFT|oc< literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-function.svg b/data/img/mainviewwidget/DM-function.svg new file mode 100755 index 0000000..3e1c659 --- /dev/null +++ b/data/img/mainviewwidget/DM-function.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/data/img/mainviewwidget/DM-icon-check.png b/data/img/mainviewwidget/DM-icon-check.png new file mode 100755 index 0000000000000000000000000000000000000000..69c4da6b0fbbcbafb2763bee0adeb9e15bec80cc GIT binary patch literal 285 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1x^Xr>mdKI;Vst E0A?#taR2}S literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-icon-check.svg b/data/img/mainviewwidget/DM-icon-check.svg new file mode 100755 index 0000000..bca4fc6 --- /dev/null +++ b/data/img/mainviewwidget/DM-icon-check.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/data/img/mainviewwidget/DM-icon-check@2x.png b/data/img/mainviewwidget/DM-icon-check@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..b4a1b706f47970c6596f22f2cecfcbda20dfc192 GIT binary patch literal 486 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9E#?!?yB!ctp2{-}G>-P3Vb?3P`F|E8Lo$#zMtJ4 z$sT@ZB5VH{?r+PaUU4-Xmfyr&F9zWH5tnj zW6t<%E->bMaY}yMZ`mTo^_m+}m8Znc-L06>J6Y#IxwP8q#&c6HA1-~q^qNuE-urCp zj8AF@H1OP*UO#JH`T?2wPCraPwC!D+bD4?dQniKjX+J~zChhBPtQr@*|7qE8xqo1) z`cF0|flqo3cW=r4>sq*f(Z;>aXR7#n{JLaVW+(!KtEPj(+tbz0 JWt~$(69C4Xz2g7? literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-icon-option.svg b/data/img/mainviewwidget/DM-icon-option.svg new file mode 100755 index 0000000..a1e8d2b --- /dev/null +++ b/data/img/mainviewwidget/DM-icon-option.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/img/mainviewwidget/DM-icon-search.png b/data/img/mainviewwidget/DM-icon-search.png new file mode 100755 index 0000000000000000000000000000000000000000..c446f1cc3924bc8a99a0a7b69664b284e61f75a6 GIT binary patch literal 432 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1C)mLwAw^ADaSqbZ1b|+ ztM9E2*)Q(<`@Mh`v*)CW%6a|=OSS(kc)cq>^4hk!_38qy7t153F|jr#O1O)qM1JEu zqucc;<@UEVx`*(FDf@hCftaw4t{VT&wjPv>s!b>?}NdYdVvX^O}F&C(lnh7suCewaC)&Fev0aUHx3vIVCg! E0F!i{G5`Po literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-icon-search.svg b/data/img/mainviewwidget/DM-icon-search.svg new file mode 100755 index 0000000..3b4b9c6 --- /dev/null +++ b/data/img/mainviewwidget/DM-icon-search.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/data/img/mainviewwidget/DM-icon-search@2x.png b/data/img/mainviewwidget/DM-icon-search@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..d7a01d6082f4c60e4cd4a85432ca68a0838a2007 GIT binary patch literal 762 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yAbz|+MsB!ctpw6ha$IS90} z9=)5AAjoLJEW?=6(2+2g@fJ_b=d;(+7MyM1nbylNk+FLDf%}uIH6o=HRo3cn+nx1d zX5jwo>#M&w3;fw$zn8h$jQ7U-?+*(sVq)~BtL`vNPWvJI&q9Ld(&wLlY-aix-Oev5 z=iG2aTFAY(hebif@x)_WCn?qmHJlImD?$q!I@0H8-J5m%>D(Eog?C?ID^n@!?f7#2 z(*NpUhLg(P>yE4sa1qd|T-!La(2&tQbV8?xNq(x=ywsbn&6Rh!d^Q-c{@KL${w>3U z30!duy(=F~T=m$hDf;(^n%3uy60*nDD>fDV*{~<^wZ!@->tiQ(v%e89?C2IW)(R6$ zxVm1)XqCdP{3kLcNviLR_9!(p{Mi$*?s;W6+m_gF=a{zDceuAQF?{ih6L`JjosfW3 zLA1gP>$5v8+W1o!d9ic+%5d~6mAst#c1K!jfvbb%1ON5fOgj?!rfpfYt$oIv({d;8 zXJ|3)m=$^C&Yxezbm=z+TB9V-iu+VQPt2$texIQXostV zwTU~-YUC2?xX5F~ahPGj*-Z+Z3V$W$pH(nbXt>IKK!clo*8xe5df^wXFMseH%3?T? zG9kR7t%Y&s{RTsWxl0^aBpH}4%s9bhWZBrZHYgy#f^C|ElEEPc&pyVK*SELl&u)D9 vkws(PhYt^(Cu~2#yr5v=35HK=RGq{b1hyp2U2U;)8OZydu6{1-oD!M + + + + + diff --git a/data/img/mainviewwidget/DM-icon-返回@2x.png b/data/img/mainviewwidget/DM-icon-返回@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..9830a10d9b08e2b9d45859b2692f126ff1630d38 GIT binary patch literal 627 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yBarKgKyNCfBGFx`A6M}fWi ztt>hZjaM$^T(wOqwtAb?W&6fs^N!71I!%gYS{n<81)oYAL+#}sy6;=aVKQM^B*jih548=rsv$;aTulf>k=@0Mgj!STYRf;;sQdefcN78_@$ zCRoj##_&e{Afp&V%?jpOTSU_v4#Zx6`(VpXmxcvFDW|MwM^*#ncNreC2n2#=XiF`3EKzrPaF`p*F3p&)rZUdpvd=h^>bP0l+XkK DY#sqd literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-icon-选项.png b/data/img/mainviewwidget/DM-icon-选项.png new file mode 100755 index 0000000000000000000000000000000000000000..9447a802c9ef91b7dc1295ff879eac02617fa939 GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1}%WVj-BEAdzu^qv$|0 yJO97Qj|Es+SvS-bec@BLUEJu=dP9cSg^i8j)kz+f^U;hJAl;s>elF{r5}E+n)Ff;G literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-icon-选项@2x.png b/data/img/mainviewwidget/DM-icon-选项@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..c8cd4e1c8f167603daaf6b7ef76ea733eaa58712 GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1u!Qc)B=-L~tf2NU$o~vPdK{ zet2-O`M-ggZ3ZhV>xR2NUpC}i>ANT(!P|II;D9*OVpYX`7bK@jgSZlsiUv_aeLWR& fU!P`hJm6+zus^`VwNhk_8OVH3S3j3^P6g0%imoB-!uha1y9Q*we)^B!cs8=xN_01_Gsv z?nJ)R&Q+3%u=3#aX17yRex-c39-`$V6QO#Q>AEfa1Fsg|3uKGMNS@MRE#U#6n+Cscm^Ovmh*J0L`uyFq5&D8v-Z{gX` ze_~j_Pi&TC_#2~Q-|)$H?~D_SC&f}ed#?J$;?Hn!(yO^lCMRaxn7in+Q1dhf(RH19 zA%9v=iD$9hIF_my7BbtHFEv5?z$(drm6Pp^^>&?_%^0%7;p==BMz(+_=XKeC?=VfY zZ{K_M^2=EQY!C)=EBL%29W_tx%iNb9TDrYyr{Uv#d+Z_skWYxRK}Eq?%1S(fZT9t(Nrg zTke+I`Rz>~sIA*Gsqm*dJCJe6zjrVT0%8FKn^@3|VLVb{CF2@Lh0Q+14o5`~1pk zFP<-2_-*l}V23wxM~b35R&%QU-Lx?$BKWqz<6D!CsXDM8E3Th)@(VxD^S=qn4q@># zg(_a8t~qkaDNXXgnYGXNwIu~Gq~AG|aq8ypgGU(DeXMRjKUeE)=lizUeui2A*A_2l u-f)i|BaJDu3^Wcr`ZGOZnu&U_4D)>ljfZ!BzPZo`N+zDJelF{r5}E*$IuZx~ literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-letter.png b/data/img/mainviewwidget/DM-letter.png new file mode 100755 index 0000000000000000000000000000000000000000..97722c960978e8bffabeb968eef81e2318a0ebfd GIT binary patch literal 392 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_18e0omVjG4Ei z-7f$8)sk4T=vCCF|DI8eQ8m%oomH_c|}+-a1D9*z4*gD>b@g znB7(}o{H~yToD?2_29O*>Y|B{_Q?fIdn&d5{ZFREM?a$9t>vAh5;@^u;T&UW$<4=X zzJ{@JyyvLv+BMnHD*1s(wGOkEIj@;@*kH16&%~pxO-o~DNEOjG50H@XSA&CN5c88=jSK?&bNp^ P3JMWVS3j3^P6 + + + + + + diff --git a/data/img/mainviewwidget/DM-max-2x.png b/data/img/mainviewwidget/DM-max-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..db956e42c8e930947c7fac65e928b88aeeac9486 GIT binary patch literal 559 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9^si%u$NCfBG@Y99O1_G?d z*!!MwEH9Z*lCZRSNz;zzDFVxzO9aXjE-{uo5UOG9vrx~Qu${&5&yq-EuN?~{byRHM z+P(Kbv`H*)o9ExmS#~$K)t;YFSs45M^yfXV+ZfXvH|g9C5B=KN-m2gANbp$Od# zJ6O|}Do%}Y`KbNW=2BMocaFci-~XQ2^KRw6!a3b*rW}~hS^PQjf`+}XX2S({*-o4D z+cmRSw zDs12NVVP(1x7BXViTb@93CkUH1*|wft#)gFxbCXnf^Mer=FFH}#&hAlAwDUEGYx`R dm!5I`Ex+%2b4@5mWiu$^JYD@<);T3K0RSVF*PQ?W literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-max.png b/data/img/mainviewwidget/DM-max.png new file mode 100755 index 0000000000000000000000000000000000000000..14aa676c9cb67d0dcae89bf72f1649c44ff3ba98 GIT binary patch literal 378 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1*uK`*qZ2fk7w8!@NPhVLzg}SX{D~7UPGnW< z=ob?a`NJ^9o+0@2pP$8S3ltOdgncH&%qnAJVAgx^^78WMjbCa7q|dhUH~i_9k&zKE zU{eYZ_LyiR(EO*`F)Heoz!5k0BUOycU40g4Fx}cF=dyTa9K)8MN&#;a4R%Rgcp?y! zFvWs__XqzX!9_2})MH@yl%4q9@&A@SP#Ac+`njxgN@xNAi}rte literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/DM-max.svg b/data/img/mainviewwidget/DM-max.svg new file mode 100755 index 0000000..3b820ce --- /dev/null +++ b/data/img/mainviewwidget/DM-max.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/data/img/mainviewwidget/Development-Checked.svg b/data/img/mainviewwidget/Development-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Disabled.svg b/data/img/mainviewwidget/Development-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Enabled.svg b/data/img/mainviewwidget/Development-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Development-Normal.svg b/data/img/mainviewwidget/Development-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Checked.svg b/data/img/mainviewwidget/Education-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Disabled.svg b/data/img/mainviewwidget/Education-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Enabled.svg b/data/img/mainviewwidget/Education-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Education-Normal.svg b/data/img/mainviewwidget/Education-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Checked.svg b/data/img/mainviewwidget/Game-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Disabled.svg b/data/img/mainviewwidget/Game-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Enabled.svg b/data/img/mainviewwidget/Game-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Game-Normal.svg b/data/img/mainviewwidget/Game-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Checked.svg b/data/img/mainviewwidget/Image-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Disabled.svg b/data/img/mainviewwidget/Image-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Enabled.svg b/data/img/mainviewwidget/Image-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Image-Normal.svg b/data/img/mainviewwidget/Image-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Checked.svg b/data/img/mainviewwidget/Internet-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Disabled.svg b/data/img/mainviewwidget/Internet-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Enabled.svg b/data/img/mainviewwidget/Internet-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Internet-Normal.svg b/data/img/mainviewwidget/Internet-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Checked.svg b/data/img/mainviewwidget/Mobile-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Disabled.svg b/data/img/mainviewwidget/Mobile-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Enabled.svg b/data/img/mainviewwidget/Mobile-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Mobile-Normal.svg b/data/img/mainviewwidget/Mobile-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Checked.svg b/data/img/mainviewwidget/Office-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Disabled.svg b/data/img/mainviewwidget/Office-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Enabled.svg b/data/img/mainviewwidget/Office-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Office-Normal.svg b/data/img/mainviewwidget/Office-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Checked.svg b/data/img/mainviewwidget/Others-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Disabled.svg b/data/img/mainviewwidget/Others-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Enabled.svg b/data/img/mainviewwidget/Others-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Others-Normal.svg b/data/img/mainviewwidget/Others-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Checked.svg b/data/img/mainviewwidget/Social-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Disabled.svg b/data/img/mainviewwidget/Social-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Enabled.svg b/data/img/mainviewwidget/Social-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Social-Normal.svg b/data/img/mainviewwidget/Social-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Checked.svg b/data/img/mainviewwidget/System-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Disabled.svg b/data/img/mainviewwidget/System-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Enabled.svg b/data/img/mainviewwidget/System-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/System-Normal.svg b/data/img/mainviewwidget/System-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Checked.svg b/data/img/mainviewwidget/Video-Checked.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Disabled.svg b/data/img/mainviewwidget/Video-Disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Enabled.svg b/data/img/mainviewwidget/Video-Enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/Video-Normal.svg b/data/img/mainviewwidget/Video-Normal.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/all-2x.png b/data/img/mainviewwidget/all-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..15a02b1be7d9c696e1d7e6c315c9be9b428f14d4 GIT binary patch literal 536 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yAv&(p;*B!ctp)VqO)4Fp0BxRA+-^~2i--a18-gpcu8emM8$MO|37>!vxY zW*NLa@R9F~X6}RX#`j;COjww%dKH^}c{=xj*2%ib(;N?p-Z{8`g{IB}o_l4!FOQU( zmp%O(Anf{sNj^dFm+0w5i&jbfy42d&B^}XZv(&p_Zc2MfIfr|9%=tS^Zq=_QT-?&o zeYdgd#hZT@%Wd;z7V~HIf4KZI(zAA9YucJy7flzZRVY<#USh&FYnPFcw&5jnm!?T! zww31+ncjP6G$k||?+cooC~tc5B6C&KHu3k)?>WBtGOhh1GiP=AUgprb|1V5)GimcM zSTa4mfpd@Yjk2!LMLv^RU)pZ5SDyKrHTtlO60hzjJ@pN{T)e%FlAU9BT?i~>_MWi3 zgtJI~QS2fq^+MZXZi(j;)pz)C@3_~kJ6teT@jJ& zb3D(UtKInK)jXfV zd=q$Q@t$H!ZRtC}Q6lV?z+#r+me8CAq;gNH%X<7Z;kP(>!*0?88O1lT>f#Aaedp9) z#MLo~XI^5m(a@_|p|rzPId@<4`G!!lLbH$h;qnjGPnhuN-K0BazaIa&xDwrY3s% wYW>1r4E8SfKBrzhz*%vs|G{>X&TRgm`0_@n6^@4Y&VoGT>FVdQ&MBb@08?gdSO5S3 literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/all.svg b/data/img/mainviewwidget/all.svg new file mode 100755 index 0000000..43587e7 --- /dev/null +++ b/data/img/mainviewwidget/all.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/img/mainviewwidget/attributeaction.svg b/data/img/mainviewwidget/attributeaction.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/close-2x.png b/data/img/mainviewwidget/close-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..100fd90805d5671da91966e5bc45a2aff548cb16 GIT binary patch literal 491 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9E(bL5-B!ctpG~c`y1D@7} zqB<948hKwAwR}^vJ@mz+xXJR+7mn1kZTA%J_Bu5E%1jYaoOC0sTvdqc=f?Z(g=wywKIns3IU%DC)p-NNXM2jphX^zZdxISGpa{$^JW6`00UbC;WZl zHg_C0i(tR;F|L2H#re-OuY26NC>VR(M*pQR!;j}2)+`=>*dJ~e(Y~>oaT}+5eB9*u zeF{FJ!Bd%|3)dCY`31Nf5fv5`U~W0`kmW3wB9lj_y+DqDC&S7eqDou~M7KMzFs^wN z)$zda33un#LklB%AOG-jkd-@W+w}0d+|0dvJ^J+z4{OxUkQJQZ`at}op8FoDbAsxi OK=*X@b6Mw<&;$UpP`xw& literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/close.png b/data/img/mainviewwidget/close.png new file mode 100755 index 0000000000000000000000000000000000000000..ce9b7d3bb5d2db1288025d2900a4a07276c8f689 GIT binary patch literal 345 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1koR6`oQerJQP^)F^%_KHq?#VabZOh_YBBn)VSN|$o zySm3v`uUyC@8LEJD<%ZRWveih$Ci6*=31tmoh)$3JG+*h)28T)@r*<5-}kxe&OXEV z{RV@|ms^U*ejGV{WqxDhN}&Y@J>0xjC!Fy$b$FXxG1E*UQ@Eq*-_-PVUI+5kCe?aJ zY!Fpibl{-C8daUNMAm~Me`Ez8$$J(y1- + + + + + + + + + + + + diff --git a/data/img/mainviewwidget/downarrow-pressed.svg b/data/img/mainviewwidget/downarrow-pressed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/downarrow.svg b/data/img/mainviewwidget/downarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/drop-down-2x.png b/data/img/mainviewwidget/drop-down-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..a33369be2cde947857f66f720fdc8e7497de90f9 GIT binary patch literal 371 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1uzp^mK6yiQs%Yc_H5+1A#Vf zi6<;fjWZk+CUVFzoK*Jtkiqdpj`sdIJh&1f@N8G&qr=}P*akN6ary3K3YqLY zWhqap9!b`Id&f&cfB; zH`$>`u7g+TFvA%MC4okH2Q8M4_Y8*o0_qGO + + + diff --git a/data/img/mainviewwidget/fixed.svg b/data/img/mainviewwidget/fixed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/full-all-2x.png b/data/img/mainviewwidget/full-all-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..0b9e8625a3def0d9cd627af2d001ba813d08eb2d GIT binary patch literal 899 zcmV-}1AP36P)Px#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91FrWhf z1ONa40RR91FaQ7m0Qmn-HUIzu`AI}URA>e5Sut)@F%ZonTHpk^K%hnnlj{NM6q$kDtdg{@(HT#>SxG zfyeEEnK%9Ue7*_!7nE(37oJW*b_@CWY&JXc+JXBK@?DfyUVB0I6LR8y1}^y}$|fMj zUqGwH@Fh?@Tw$>HRtVg0c&0N_a!IPFD|MDIovbWlE8ekb)}5l|X{dnp(e zC$v6sI_uJD@qB$_--zdH-ROE|NUW1;GrWlA}}J*>4C9?Ivv>E zeMDe|3z>XPPF@5w(b|&SrrHQe+Eib0_9yuP zFoL-dQ}kXs0_Il>l0`riuC3AAC}w##*DJR7qJXb%ZB)7O|uYFnY^ znrDblt?^b@mIKcQ#MP|Vs(3sn&(uDgEj)!Gdq@wgT0$RSSj!UPJhqS7n#XqYBQ9b4@%A;l)tQ7e~N89hK)s|nWqIW~XoIYH{ zN%EuyDZ>-2Y_B* zwP2|(9hqHEWlKo1Ki-Xg0%imoB-!uha1y9E*we)^B!cs8=-#!>1_H-6 zI9MGKaooW0GHBTuvps_Mr1HC_3!V@OSmwk0#7CRtz!5!R#YYdm89gu()LLh>A(g4{3%l>1`PQfTc=+FQ89019qAjPw zx8@du!y%VXugb2@Ze~AR#WP>?_5KpAw0n_u#b?UH!X3uCrCbot zICnH$MCRe*b+3iB7N#<=Md<21JI-~4t7Z=qzjK#(K*X+XaiC!KboFyt=akR{0D8Q$ AGXMYp literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-close.png b/data/img/mainviewwidget/full-close.png new file mode 100755 index 0000000000000000000000000000000000000000..e0aa44f3568ab150ac580e2f5698a5392e1727d9 GIT binary patch literal 304 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1qN2(gOLGE! z3#&FXM^Aapbm#BAsNJmvM<+N{8CaNf2J2UyjN?s6`gSEnmdzoJ~`?AW(%0VxE&WXCU ZcNvfPMOrP;n(q#Bxu>h2%Q~loCIE&3VYUDO literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-close.svg b/data/img/mainviewwidget/full-close.svg new file mode 100755 index 0000000..397d1b9 --- /dev/null +++ b/data/img/mainviewwidget/full-close.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/img/mainviewwidget/full-drop-down-2x.png b/data/img/mainviewwidget/full-drop-down-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..61353ab82e25f96b97377804c395ee30092b026d GIT binary patch literal 393 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1u!U_jGX#iQs%Y#gOli0gtP+ z%8i*fEScC779MYF?d()8U{w>7I8}eaW1`0$6YYPKG&k*kJO94Jb;~=9^{7M^&nYv=jPLIr}4XKqk;6`5w-92qI{o*{=f<)vd|uV8uY&z-`@ zK25%7ZyPy->BS1ci@WChoXoV$B|v;f!AtAoWuKpzG-@#l@TzN=>n`6I#qgww!%Oh0 zdOz=GmJ2BzGxpA@+{`NCVxpTbHlgFeda*fc=ii$CX#Tqf>j!*0m@C=u&5B6+$Fn?N P926v;u6{1-oD!M}%WVj-BEAi;WtxAFh~ z|J6(zS@nV)ixf;xeDXOVqwrf?Ks(WxMQa&LDD(BUyaS30&QzB;PcUhI;*j;ALGWCY zQA1Z`qmQ_P7|WyTfW!%B70y;mNJ`c_A3Y$_#;6cz;_ToQVcM*+L5g9LgAvP-qZ=eu dEVx#PFfkO)Gu*Ixs+cIqHJ+}1F6*2UngE$tL(TvI literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-drop-down.svg b/data/img/mainviewwidget/full-drop-down.svg new file mode 100755 index 0000000..5252b3c --- /dev/null +++ b/data/img/mainviewwidget/full-drop-down.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/img/mainviewwidget/full-function-2x.png b/data/img/mainviewwidget/full-function-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..816f16cac3c5d9e8633e7a8370de892354dbf5aa GIT binary patch literal 550 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>f0%imoB>CgNpBYf`98VX=kPOzhk#BPk83?GZ zU_Rh-!S4XuNw+lzRC;eNm_5O7!airq*E<>(CG5CyHPYx??Txzc^XdgEw|<(Y$Xt8> z`U~A(thF!QB%;1lP0~`yZA;;a+$OfdY|{iUDUNL$zF(UD&?Y4GtK}iq54={}`Ghy+ zuaecRdT?M@{yYAlw4LlaEuGQEw-_cK2<&MOJjBC(ZT}VqE2(O)Cg#JP;T)Xe7VCSQ z7rl6X#8O%Gz|R}6x}R$*e^be6nHbexyWJ%6^7#w%cIoZ;aaWn4{83LwsF=c|r#^cd zmToO#jcIgY`@^LwG-J;lQIBN?h0Tvde|V@Q6z%+zY(Ddki_=Fgk@y3**I!t@kNrj2 zL#uDUrird^5MQ9Wbz3ZB_OY*(>l)II+$v*TBYFM#PNrFc*|$YEq{YmC&XwV|=577b z1M5wzi_b~RSyXr)(GvafP-BwxymS*emT5pY6bNy;iv+G-<$9ycE27|0;GC*QKhH)> z2r)BR^QBqM`#5)RdQK4Ir-?r4d}$U!W|dRlIkyOXSt5Di>1~}eu2P8#I%jLQyo;UI ZXutVs>iMZZ)qa5D%hT1*Wt~$(695tF-5US^ literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-function.png b/data/img/mainviewwidget/full-function.png new file mode 100755 index 0000000000000000000000000000000000000000..8e6f47f7558e4ba17ded1381cbad8110236a5459 GIT binary patch literal 380 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp21zqcxI}CFf_A3kYFNxrI(EM@I{J8h)zHblLGkqo<6dKB6 z6wqX;qU@O7nI<#O>vhL}ny*lizCTn++~)m_34c50hvjYRW7aReyK0K`BvBcl + + + + + + + + + + diff --git a/data/img/mainviewwidget/full-letter-2x.png b/data/img/mainviewwidget/full-letter-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..a5212da75c3cbe7d1462a9fabb1dd2c354599c2b GIT binary patch literal 867 zcmV-p1DyPcP)Px#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91FrWhf z1ONa40RR91FaQ7m0Qmn-HUIzu*-1n}RA>e5SV2w$F$|=LD@7cU$_si2@dK_1sXyQy zyr)QrYkyF|1Kfd_?OG&8EjLh zHXjTI^Y6!B@)r)=qd$j!Ukmnb4Z|V&$HMk;kO`5`V-*Jg?J5B;B}=H~iQH=dksblU zg976OwXjg;I*Ds!Kt_57RMff2IhGZTt{Fh|hd@IGdk|1vhVeFxZx~OJh4=7YJa}i| z9EceFf~YglCm$P{Bc1JR$bh8I38RF3f?kDE-7)}x^iPYala7cy`}EAm#+6dt8~{LB zpi_Cy!}An6+@vncHa8;rBXLCNs1TK|HH*&L0^^HU24qBMh&UJR3PzC0V0l zWQXWa=v<_Hf%}04I%h(U))4I$HIEGZpiT`DvOqUd&dzpFDx#RAPR$AEyHaXV1^}js zIyE0$DYeJ}Ae4o;Mx7e^t)Wyzzm+;QCrZ}FHcK)fqo1VCcr$+AIHe+jX6j_n@ksT9 z&eYqPQoClrOr0@se%~miB63;O$)MvAc8V!AI|Gz@0MTxpF~+v{VoJ?+0ElGqny6Fr z!h=$?J}D9X_=Eid;9fLw`A?Ekd`IdUqqMtX747gCIwkzy+qEr(L!MG=NYCd$L zRFebPQ5J6zb!zB6C^cyt(eHfgOd4zucG=640U7z2I$)S7>xEpotgs?r4lCl tkHPSKOcBtG_azTm827c`|2}^%0-sXOXEGJ%?eG8q002ovPDHLkV1iDjdRqVh literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-letter.png b/data/img/mainviewwidget/full-letter.png new file mode 100755 index 0000000000000000000000000000000000000000..00aff387d209b74ae5e002eb8444e6459ccf4c24 GIT binary patch literal 472 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp21z-m>k1@RxHJZzbKnc}UAdG16E# zh)3hP`Mf(lN#8>!oQ}IYhwax4>-7Pa8@_)!YS9{M?PifDY#p2L+t0B+;!k1jLzYAX2l_n*Af;`Yx??z85^>Rqe<_7)Vvp00i_>zopr0H092cmMzZ literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-letter.svg b/data/img/mainviewwidget/full-letter.svg new file mode 100755 index 0000000..ee2cc83 --- /dev/null +++ b/data/img/mainviewwidget/full-letter.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/data/img/mainviewwidget/full-min-2x.png b/data/img/mainviewwidget/full-min-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..46b8a3c7ced5a8deb6b592c268ceb3e4bf560d97 GIT binary patch literal 566 zcmeAS@N?(olHy`uVBq!ia0vp^h9Jzr1|*B;ILZJi#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)><0%imoB zHn2)CNHp+DED*lHxr>3hq;ZpjT7&Ja|Cbme7Vrq%dp&h`&62`Dep-1G-<9mWGEHai zbB&@)CZZnKOSxZ2{aV#BSwuNonq|NBuRF`9%=7wte~OgF`Te1Pu1{;3_H>seigEBLJ_wsz z5ViYo6aNMG7h=CUgKvx1={rw2Aalz2^Sb4G>OP)0Fo%=H%6&mH`#)8QL{lT-%PJEX zwqIZ`d9!BE@gHZ3vLo%)clXZh6rY|#BI<1^*qQ*-MX9}aIjQ*6Mv s=gPd*Jg?5=OzkxP@$__}S%1BreRoW)WnHt+BvAZ$y85}Sb4q9e0704OxBvhE literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-min.png b/data/img/mainviewwidget/full-min.png new file mode 100755 index 0000000000000000000000000000000000000000..1016551363088b860c747c16ea4b085b996dbf70 GIT binary patch literal 382 zcmeAS@N?(olHy`uVBq!ia0vp^k|4~%1|*NXY)uAIjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp&1t_V#~YuWWe2dF4Zl z%ru*$igpc$4k%1yOA1zawzSi@fz6-w(d>X4DUWP{Y{9^vEEx+-E;xv*IR9*T!=hpr zrxrMk!IvSjiEl&a!qtqQJGVZu3iz6CBK&Q^$HF4X!cz-88Jf@VXo#>JQIMaLl#(*1 zXIV3qPQ5wbn1jVuM7ZmT6s}TLVPxpKf BeJ}t3 literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-min.svg b/data/img/mainviewwidget/full-min.svg new file mode 100755 index 0000000..5bc8fb4 --- /dev/null +++ b/data/img/mainviewwidget/full-min.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/data/img/mainviewwidget/full-search-2x.png b/data/img/mainviewwidget/full-search-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..5419253cf31b1045d2ce47dc9a87e5fd3ebd3938 GIT binary patch literal 695 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9Q*VDx@B!ctl^oNDB9Rykf zwH7pAaD1V#gejOw_K2(t5Z_QeB07VwN1H=-2H%wTmb;fb3t3H=_`f3k-kp2*-tFG5 z&E^^T?PjiVIm7O|>r}q8g($G!I&F2KSj{H6~8W& zbKu?c+s7`W;T+q8Z=aI{4PJaoPZoL^woydUl68W>_TM3AFIrCh_|*3Ig|~s9TpDIc zdF;rU$-%XUIdRT+SF5dZ4Qwz(twW*3-h}y!n{I%uQz^#*~^w{k&`0)AUkyiGC zP={;k-kwzz-l@K7=Y1O18=uSF)Z#L~DXS*ugH?UN9P>2o)AyR4Y3m?V5s zzkqq4^ppQ=^^LRbK1-FzZ3z9^tv)fhgq=;KO^JKh8Kxi zy!TEX*vI@!_Tr|#9;v5WA4HcdxFdh@->!8o4Hs3`RX^q|6TZ0V)GT4m`6gfZXSbh{ THy25t2}(eou6{1-oD!M<;uamE literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-search.png b/data/img/mainviewwidget/full-search.png new file mode 100755 index 0000000000000000000000000000000000000000..3603ba3b4fb6075e2658277cb0786f7f974dec7f GIT binary patch literal 379 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1SN*wd?##Q^3ZDOBFPl7l!1T^R zb)DnBDzSxZJPR0RvL!sPe);^U>Wtpw*#>-%QWvnNzIi!C=0(f;!)6NdJqKofOKK4l zY20yPg0`dR4USvCK9@){FyXXf^@v~5-SGa)do_&3YVy#I?9uT=O93ItDAKbLh*2~7a1 C0gRRa literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/full-search.svg b/data/img/mainviewwidget/full-search.svg new file mode 100755 index 0000000..89c630a --- /dev/null +++ b/data/img/mainviewwidget/full-search.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/data/img/mainviewwidget/fullicon-all.png b/data/img/mainviewwidget/fullicon-all.png new file mode 100755 index 0000000000000000000000000000000000000000..8f6176b36f7182edf35264bd770d143610a05802 GIT binary patch literal 482 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp21d7Sye^s-uh|B?GY10@qQR;eEU zwmJFt{~MA#|9G#K+OqC%wy*x-*xp)yRrqkZ`Gb{7+L{dI7q&lePxSL!u>OE~+g>NV zgFXFQ7!1~}dSz7{;qLqN45xElnY-<;RQLY@efuXpXL8RsixXVF)cHq2xFCyJ*NmHy zeca+(+RpuaW-+ZpdF93>PtHww)L|IDD2+cOa{2W8>&_K--~6}9qHKQYt3}^Cswcno zS6H)MmvzRUz?fpD-LoP+9{HA)W*;z4dA@tc15>|)zWJQ2KjbyV80?Jfw_D^IZT$8& zjM*-E%>)bAUmc&+SML6vz-e4ROQo|3kZ zXW5Kq`;^~I2xD;a)voD5UW>AVjLYfo1{mvv4F FO#lSNy{7;G literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/fullicon-all.svg b/data/img/mainviewwidget/fullicon-all.svg new file mode 100755 index 0000000..a991c98 --- /dev/null +++ b/data/img/mainviewwidget/fullicon-all.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/img/mainviewwidget/function-2x.png b/data/img/mainviewwidget/function-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..ad6c487cfcabd254a1a5fa9291e898824d79d347 GIT binary patch literal 467 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yB4)6>NMWo4a8j8)rVtCh5HU`)V0uc{}7KC4b7h=*RDqIV`MDC=tNGWM;OF(_x?e zg*$8tZyAmh9AHUzlyq?YrtoZi{C=*2$i8*#^8XnH8f=(C7x%9dJIrXns?cj-w$$W| z@{LQve(V8Rnj3$)%Nj^ANjzoP*vY<(FHG*hj~y>Ir=L%nD)m8Qfdvc4)E0w$=I)Au zlbnwazhLBV3}o+VJCMQgfQK=_n{8US=F-s6P+o^L25B|9oyh?tV zV63oa%>?%b-icK!fhx>kUdPxxc6O_qVnU8$P%ucz7^9WocaZ+#%dqOI~D^ m!<>$LN@`c<1b#hi%))SDUUuj2V6#k6;Cj0HxvX-hco9|L?8;|8M8rz180hyY{SF^{Q0io1<7yPtTwJGwd53v#wmZ zvhMJanF%~@Zf?D|x98_Kek{BgU|JAFN6I z$3=X^4Fn!GdT$hGo6cx{L0IU_`4c7{yc(v5jyzyovSy7Ax6i5F4xC(Soz43`K0h!2 iz54q*+e3=}>4^+?cnlc!Dl44=`M}fF&t;ucLK6TwHfX*8 literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/function.svg b/data/img/mainviewwidget/function.svg new file mode 100755 index 0000000..da7fb57 --- /dev/null +++ b/data/img/mainviewwidget/function.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/data/img/mainviewwidget/icon- search-2x.png b/data/img/mainviewwidget/icon- search-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..8f286b4dd7a3e5406b09a175d17ce6e9a1f3b25b GIT binary patch literal 838 zcmV-M1G)T(P)Px#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91AfN*P z1ONa40RR91AOHXW0FO>U$p8QXyh%hsR9Fe^R=aNEKorG1q*R0eeOU2m<1%H^r3>lO z1&Zyr-X`!B+igg>RZN$X{DJ8rkWlggNKOrcJ;$1BS>rL-Ube~Zl}7XMJ?EaeGvk?D z?!W!(8L-kMpaCnDO4q=2Q7V>Y*~D+RTNjmw;;dGy@f!^7M3zW^3Ve@%y(FvpT$w*wJ0(G~T!2bTU(4aq#5uvwWQaRpiwNKy4yBLELvF$VkhX!HKO%;lruTvIGQ!2-V%_=xH)^$-#fya` zX|2_2{RHL;9s(L7AS+)c95YDE1pc(3-)OZx(Z5OZ QUjP6A07*qoM6N<$g5$wyj{pDw literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/icon- search.png b/data/img/mainviewwidget/icon- search.png new file mode 100755 index 0000000000000000000000000000000000000000..c2da345bcc9d7e006f2a61ea7a0a811d7307744b GIT binary patch literal 430 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1V#g?ndZe{;qxi9r>?5rzh2TGMA3U6)OYv_AfSTEM@)J*5Z{g-aIW=OETeXcl( zA9(GmIPNF|1}e^nLO=p_m`r?h8Gz3YojBqC;hY^ + + + + + + + + + diff --git a/data/img/mainviewwidget/icon- 返回.png b/data/img/mainviewwidget/icon- 返回.png new file mode 100755 index 0000000000000000000000000000000000000000..94dc40f362f5d5450008f68bf4e8fe71bf205565 GIT binary patch literal 377 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1kixs4K0^3a+!3 zMNi&f!hdG(wO^6fw{kTl^zPo4IcxIDndSePN-R>nJZ8NA1_}aCS3j3^P6 + + + diff --git a/data/img/mainviewwidget/icon- 返回@2x.png b/data/img/mainviewwidget/icon- 返回@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..f3ffab08cb4bc042fb61c668a2ba7ca52a689cc7 GIT binary patch literal 660 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1yA5%hSa%B!cs8*lxc=0TRo^ zg^u<0?JADGyKC3fwTwcir9ZH}l71l^AgqvgYFY3{PK^yatad$2V`AL5|KW_qnsdB4 zJ10)w^8DBT`}IHnU4B+{{M&uygg4dpXf7Y^@4XaPQRb}dRQ)YRg%5HP+`RClceWf!jnOO29j+y_+ z+A5{+f1S_2lUlh#Y>p3f#Jb&I6nF}nHr)SSwO3)L$G$B*3I!8%nx2QYEoS!HbV}2M zxqY5===qrsy#yU*hCVE9|6a2*X4|j7btgnteY?aaU~x)^so}80rl!eqD@FdWx$m=A zj6VIyve-$2@&0%Jz%XSFm3hJza^epRgC{K&cRR32r@v8H;FJ7Y?m1sLc@Ol8J-Q>o zpDnlUZpW%d-ISNDY!`an%%u<6J!puz!>s&>ZTm9QEh$SLS^S&jx19fJ(M*fSlX!w2 zKKR&u^bz~FEk6}f85o0R`=~if7`mD0F~l7RV%!_9HC0C9<0P4&8qU=UzW0~uIKK(q z@mDb@bn;&gLrX>W8;<*yYuz~1?J-q6O7KCiqialZ-O;sY4f0BN-&N1ceI3xroEdeg zqOsU+htr%&-^mZJ8%aByV)(+QWY;|5`HXov3^5@mcCT>SVzGho$Hk=|ndJ4ojz5&{ mka!TjwzlGl@}u~k15(B62j{(Cykr$9b$Gh^xvX + + + diff --git a/data/img/mainviewwidget/icon- 选项@2x.png b/data/img/mainviewwidget/icon- 选项@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..b6b765d8c5a69e59bde1dd9b02bb4b721c5a05e1 GIT binary patch literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1uzlc)B=-L~y>nvXG0xfP>Xx z`~Uyx?A~gNj~a8fwW~`k+{QhJX~NR^8TH@hdQ5U`U}*F^p#G-h42QrC#RtOgc5K$= aEMej=WMt-wl8mecnd|B5=d#Wzp$PyCFfkth literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/icon-check.png b/data/img/mainviewwidget/icon-check.png new file mode 100755 index 0000000000000000000000000000000000000000..29e9a1762af5371ea17392d43c562038e520dc05 GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1hJkrq7(ZT9a`t$$)|M47`c`mg-Vw#}j=H~YA{r&yw zc{esZWcFa>a5(zdaaQ=6h=~khEkZgcWYpA_aXPp@x3sWeX?WDf$jHbvXU?3@jc*uo zW;s^PbY$U)*;n(kwXcuwf?yA)!>q=sQ@1i}JZCu4>M&b7;njpp5&Z)y4UMG?C$_PF zY&276GSz3;xRG&9Bgd5~3`gWSGmoV`@DO2UFywIW$_~G_9^@xaS3j3^P6 + + + diff --git a/data/img/mainviewwidget/icon-check@2x.png b/data/img/mainviewwidget/icon-check@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..5c1a31e5b84e0084ef8040a3d17d4865dc9e28c0 GIT binary patch literal 541 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9^vZsqYgr|wJg&xi*euk+siW7U3fV~_~Z%B%c~i7d3^l0gze=o z<#ToW~3do`!iVrIQc z^~~p$4|lzjHgIgVcCP9AYC3VTg;nwF=MH-qe$F}Woc2=i1Iyd}QU<=mCN zh8^EEUJ3ngH$B>Z>j6^-!}Rx83+Hg&;XJWCP$ZX6HSG5kCNIXN4B-#ByZx8{n|kbI Q9w?eTUHx3vIVCg!0H4p@%m4rY literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/leftarrow-hover.svg b/data/img/mainviewwidget/leftarrow-hover.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/leftarrow.svg b/data/img/mainviewwidget/leftarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/letter-2x.png b/data/img/mainviewwidget/letter-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..edb749320937df9af3e699b38646c753c5f4dd9e GIT binary patch literal 688 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9Q&C|s(B!cs8sG}c~p-5_h z!kd-?21B-M6-<^*_Y%U?j5Xt?wX;=Y}%8w@yEKh`DfFP%S)^}=X!2Rqtn8I(+@l+*%Sm#vpQv` z9L)CW>n|0KCg%zBC-HpJesVIwV8xFK!msBtPH>-4N;Cg$ zOF8s%X^nE}y4Bb94{**_x*Km%8L1jr-+iJh%k0!X$%r{}7n6KlR!)}SO$mQGhcP5h za_RSz0=p&!dkcT#(kj~Iy?u4zIR}Zhi3RUpyo!BcbwnfLVN%>2^9kplr)DJ=?|8bN z@!C%#t6YaKf0YIJb8X{qv>mwG(x1BCd-7#AhF*^O=bz`U+qN)4N!ssLkp99wF)K=c z*(BEmZ|D)&CieF7%Pp2ty;W0un-g9q^s8IGn!jV3=$=%asb1FuV)Is-+XWjRU}NUr zc2E1vcHaEY$2rYv=6|h?Xid#Op6X?=TYKqZ2l-z{ZD)^GahBHJ7xUS=b07b)_=dUC zzxR2iO#b=1pyTM~+$#AT$%0H9v$|VJj1x8^P+(n(z8^S;@P*-QWW zw_5ABw_bg+%P?<bBg&nT_({r!Fq|ZX6p9 ON;#gcelF{r5}E*2CnQM# literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/letter.png b/data/img/mainviewwidget/letter.png new file mode 100755 index 0000000000000000000000000000000000000000..393bf639d2d61554b748e46b5a24194a980dcdd7 GIT binary patch literal 421 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGo_1sV`aHE&T4Tu}J6i^ktb=*Gnyv-)vj=y8Q0`D~I;I|IIv8 zbzbgcEe5u2N1H3>?GI!~ywq_#YlZZYM2UT~mYrm*%e=+Q^JPxz&E`}7Og86>b8hc* zIIuTM$%f~!`|WLOR%tojd7^({OR~Tu6W?N^6{2#XO19^Z_@^=StG(N$rx>_?#X|R| u^-N6)HyR7Hx*i3au87D|e;K;e{>c5wX3=r?bcBRJ!R6`d=d#Wzp$P!&Kb;-` literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/letter.svg b/data/img/mainviewwidget/letter.svg new file mode 100755 index 0000000..368f9fe --- /dev/null +++ b/data/img/mainviewwidget/letter.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/data/img/mainviewwidget/lock-fs.svg b/data/img/mainviewwidget/lock-fs.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/lock.svg b/data/img/mainviewwidget/lock.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/max-2x.png b/data/img/mainviewwidget/max-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..7a8d03f3c86c3815ce25e29c2cb86707e7115138 GIT binary patch literal 559 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}7O4@QX}-P; zT0k}j17mw80}DtA5K93u0|V0nCb)>g0%imoB-!uha1y9^si%u$NCfBG@YA_11_H5* zIh|yV5swRcr z*H|>pB=3LK>7lb!k|Rs}#FJf*`C0GA=p58OR>jVh?D+1;rc8Y$1$#A(&F7~qEuOqt zXR+{mkBJVy)pSl?FKalrtb^g+srL*@C!V-edkSrqc>CmFLn$B6v;UEIIdTLeY?)RG z6j~+wzYm-;FLM5itMO-#%=o%kknu{3MA(W<{eP=3GU>1#5qhxJyW6tc$(6S2CW}kQ50E#$IS3j3^P6Hd4B-jP<`)Dd9Mv!ImawV^m|x)iz$J5vZ62rRUpY_COpVMZs`~Gj*WUk~Ju}%c zQG#vV>t(;LF3Y^%ZgJW5QdX@KYUz^C|1dQi;Bw&j==#B% z(Is$6NPGXS`KPiNlDQ@B$l1=5NM`J^4hwZ{mRa$>`r+??!kbL;7#Wzhn~N|m*tG8T zoRYa~q8vnzxy+H{+;rD7>jnD_`2udc=I5N+H<=tJ&Dp>4&DN|$&Lq(1Q1`6TF%$j6@M)Hp{g)lSlR)9& M>FVdQ&MBb@0Orq!&j0`b literal 0 HcmV?d00001 diff --git a/data/img/mainviewwidget/max.svg b/data/img/mainviewwidget/max.svg new file mode 100755 index 0000000..f6f73fd --- /dev/null +++ b/data/img/mainviewwidget/max.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/data/img/mainviewwidget/power-2x.png b/data/img/mainviewwidget/power-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..926bc5904d7b35718fcb865fe5c5eb8c19d19b00 GIT binary patch literal 1264 zcmVPx#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91FrWhf z1ONa40RR91FaQ7m0Qmn-HUIzwW=TXrRA>e5SzB_{MilMangGKO-T_(yJHQ*T5r3&< zT#Q!$JHR`@SpiPrO689M7Jykn$O_`@!2B=K>*mf6 z_NMYWzLfFvtfa@c{+NBNn;Z7G4xulTz2Yk4_X3augq41QvX9Hb%E2+86uWJ4TN%I| zsz|?HZi@z+SP}O7wnTOFfB`H!Za7Fxn5SZU>&r$1&g1n_sCqX3b9U}`c5fLB!HQSv zmu*a}HL&;qnb-{Q`-^`7FW#l6>q^)CQLYuQX1^4HDBWS zWdBHx0}uY6DwDZ-+}F2idc>{w*L?8`yy^S5m9(6NGS8FJ!%OzlXK0i5M62uj3bAN#$F z*`~hWm|ufjc%peC~-FsoZOCvk`KK+C)oiAP}fkxf674 zuSsRzL>3ufR^GN*DcZ_zk`&6c>-LA*FcujYRr)KHNmLXh?FHQD8916TUUPFR+Cn;+Q0 znrk1Uu%{$dA9oSAVkWnyr(M4MQ|ah+}%*L#boB+?w-DVX4_3=Cj$U8do=4~5pk~x zywf;#JiM?CF&|>K3L$q92=0vJPRgBf`!}fr3z%KSgR}D!aD|#593v#4oF>R@Kp-Te8^ a?!bQlOtb!R0^v9S0000t=`Lp*q|hThFRWFWAQ zdrPaiS%z7IUlHAb@p<_Qk9x?0Rrc)6svD1TYHQ1nMty1E||i<6wzRsN5O z_4dy{^E3S4n|P0vg@2y6`Il!6QlV+53*+WZ7UxJUu$(Q$ShdrV=S+S-X}w5>^SO@YuZGaDlVhx8=Doy_S)r&Lk}e#A{)E!MUA-`$#>JC@`dtjaIQ zS!9|Nc8Z~4Syfj?$Xs1tnPg+--qb!eg{5Knyd`@D-!(p1Y*jCrwkp*pgRi*qmhZc{ zrU4H>I*05$|6^hJk=`vS_oNt_w3%I&ZvEn(%l>}PE`OF&cf?QgZVi%pwxU$SG~&VW zg?@XO&iQ>=@%$>+i>$7vZBa%N(h4sx<&;G8l7kd^eNURnV3S!&t-)$P-^5WF~qOe&det%Bq_lsJcmpUA?cA`Rp(zb8mjZM{QvyIw5)HISM1aBu*tK$Bl(Q` zKg?tkba-_--@AGKB(?P1O;d}{xd-}r7db1RoBwTp + + + + diff --git a/data/img/mainviewwidget/recent-disabled.svg b/data/img/mainviewwidget/recent-disabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-enabled.svg b/data/img/mainviewwidget/recent-enabled.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent-gray.svg b/data/img/mainviewwidget/recent-gray.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/recent.svg b/data/img/mainviewwidget/recent.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/rightarrow-hover.svg b/data/img/mainviewwidget/rightarrow-hover.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/rightarrow.svg b/data/img/mainviewwidget/rightarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/search.svg b/data/img/mainviewwidget/search.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/select.svg b/data/img/mainviewwidget/select.svg new file mode 100755 index 0000000..bddfc1a --- /dev/null +++ b/data/img/mainviewwidget/select.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/img/mainviewwidget/selected.svg b/data/img/mainviewwidget/selected.svg new file mode 100755 index 0000000..c610131 --- /dev/null +++ b/data/img/mainviewwidget/selected.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/img/mainviewwidget/ukui-search-blue.svg b/data/img/mainviewwidget/ukui-search-blue.svg new file mode 100755 index 0000000..4665b8a --- /dev/null +++ b/data/img/mainviewwidget/ukui-search-blue.svg @@ -0,0 +1,16 @@ + + + ukui-global search-search-blue + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/img/mainviewwidget/ukui-search.svg b/data/img/mainviewwidget/ukui-search.svg new file mode 100755 index 0000000..e931c1d --- /dev/null +++ b/data/img/mainviewwidget/ukui-search.svg @@ -0,0 +1,16 @@ + + + ukui-global search-search + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/img/mainviewwidget/unfixed.svg b/data/img/mainviewwidget/unfixed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uninstall.svg b/data/img/mainviewwidget/uninstall.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uparrow-pressed.svg b/data/img/mainviewwidget/uparrow-pressed.svg old mode 100644 new mode 100755 diff --git a/data/img/mainviewwidget/uparrow.svg b/data/img/mainviewwidget/uparrow.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/commonuse.svg b/data/img/sidebarwidget/commonuse.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/computer.svg b/data/img/sidebarwidget/computer.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/control.svg b/data/img/sidebarwidget/control.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/default.svg b/data/img/sidebarwidget/default.svg deleted file mode 100644 index 7b506cb..0000000 --- a/data/img/sidebarwidget/default.svg +++ /dev/null @@ -1 +0,0 @@ -avatar \ No newline at end of file diff --git a/data/img/sidebarwidget/fixed.svg b/data/img/sidebarwidget/fixed.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/fullusericon.png b/data/img/sidebarwidget/fullusericon.png old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/function.svg b/data/img/sidebarwidget/function.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/letter.svg b/data/img/sidebarwidget/letter.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/lock.svg b/data/img/sidebarwidget/lock.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/max.svg b/data/img/sidebarwidget/max.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/min.svg b/data/img/sidebarwidget/min.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/personal.svg b/data/img/sidebarwidget/personal.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/rightarrow.svg b/data/img/sidebarwidget/rightarrow.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/setting.svg b/data/img/sidebarwidget/setting.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/shutdown.svg b/data/img/sidebarwidget/shutdown.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/trash.svg b/data/img/sidebarwidget/trash.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/unfixed.svg b/data/img/sidebarwidget/unfixed.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/usericon-darkcolor.svg b/data/img/sidebarwidget/usericon-darkcolor.svg old mode 100644 new mode 100755 diff --git a/data/img/sidebarwidget/usericon-lightcolor.svg b/data/img/sidebarwidget/usericon-lightcolor.svg old mode 100644 new mode 100755 diff --git a/debian/changelog b/debian/changelog new file mode 100755 index 0000000..c28265f --- /dev/null +++ b/debian/changelog @@ -0,0 +1,67 @@ +ukui-menu (3.1.1-ok4~0727) yangtze; urgency=medium + + * 增加开始菜单藏文翻译 + * 调整点击应用时窗口隐藏时机 + * 修改分类下拉选择框宽度 + + -- lixueman Wed, 27 Jul 2022 20:32:11 +0800 + +ukui-menu (3.1.1-ok4~0725) yangtze; urgency=medium + + * 解决平板模式下win键可以打开开始菜单问题 + + -- lixueman Mon, 25 Jul 2022 09:15:22 +0800 + +ukui-menu (3.1.1-ok4~0721.1) yangtze; urgency=medium + + * 解决了强调色修改后,搜索框未及时刷新问题 + + -- lixueman Thu, 21 Jul 2022 15:34:09 +0800 + +ukui-menu (3.1.1-ok4~0721) yangtze; urgency=medium + + * close-cd #130526 修改搜索框和收藏最近按钮高亮色 + * close-cd #130514 全屏菜单的滑块透明度修改 + * close-cd #130485 修改字母集导航页禁用按钮样式 + * close-cd #130477 修改功能集导航页禁用按钮样式 + + -- kylin Thu, 21 Jul 2022 13:51:42 +0800 + +ukui-menu (3.1.1-ok4~0718) yangtze; urgency=medium + + * close-cd #127740 修复wayland下默认全屏切换动画位置异常,不显示动画 + * close-cd #129213 解决开始菜单点击屏幕键盘后延迟退出问题 + * close-cd #128764 增加搜索按下键切换焦点至搜索结果页;全屏增加字符输入直接切换搜索框 + * close-cd #128492,解决字母和功能分类固定到所有软件未置顶问题 + + -- lixueman Mon, 18 Jul 2022 15:09:23 +0800 + +ukui-menu (3.1.1-ok4~0712) yangtze; urgency=medium + + * close-cd #128498 + 修复【wayland】【开始菜单】多次点击tab键和回车键后,开始菜单点不开问题 + + -- lixueman Tue, 12 Jul 2022 16:11:49 +0800 + +ukui-menu (3.1.1-ok4~0708) yangtze; urgency=medium + + * 调整全屏窗口初始化代码结构 + * 增加全屏开始菜单分类选择下拉按钮动画效果 + * 增加全屏开始菜单点击空白区域退出功能 + * 固定全屏电源右键菜单位置 + + -- lixueman Fri, 08 Jul 2022 11:25:23 +0800 + +ukui-menu (3.1.1-ok4~0623) yangtze; urgency=medium + + * 调整QGuiApplication::platformName()调用时机 + * 增加全屏窗口显示时位置设定 + * 合入app-manager接口 + + -- lixueman Wed, 22 Jun 2022 11:22:58 +0800 + +ukui-menu (3.1.1-ok1) yangtze; urgency=medium + + * 版本号规范化 + + -- Xie Wei Fri, 06 May 2022 17:54:45 +0800: diff --git a/debian/control b/debian/control new file mode 100755 index 0000000..b845cb7 --- /dev/null +++ b/debian/control @@ -0,0 +1,44 @@ +Source: ukui-menu +Section: x11 +Priority: optional +Maintainer: Kylin Team +Uploaders: Aron Xu , + handsome_feng +Build-Depends: debhelper-compat (=12), + qtbase5-dev, + libqt5svg5-dev, + libqt5x11extras5-dev, + libglib2.0-dev (>= 2.36), + libgsettings-qt-dev, + qttools5-dev-tools, + libbamf3-dev, + libkf5windowsystem-dev, + libuchardet-dev, + libukui-log4qt-dev, + libxtst-dev, + libx11-dev, + libukui-common0, + libukui-common-dev, + libpeony-dev, + libkysdk-waylandhelper-dev +Standards-Version: 4.5.0 +Rules-Requires-Root: no +Homepage: https://github.com/ukui/ukui-menu +Vcs-Git: https://github.com/ukui/ukui-menu +Vcs-Browser: https://github.com/ukui/ukui-menu + +Package: ukui-menu +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends}, + accountsservice, + libgsettings-qt1, + libqt5x11extras5, + bamfdaemon, + libkysdk-waylandhelper +Suggests:kylin-status-manager +Description: Advanced ukui menu + UKUI menu provides start menu development library and advanced + graphical user interface. + . + The package contains executable file. diff --git a/debian/copyright b/debian/copyright new file mode 100755 index 0000000..3a0edea --- /dev/null +++ b/debian/copyright @@ -0,0 +1,29 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: ukui-menu +Upstream-Contact: liuhao +Source: https://github.com/ukui/ukui-menu + +Files: * +Copyright: 2019 Tianjin KYLIN Information Technology Co., Ltd. +License: GPL-3.0+ + +Files: debian/* +Copyright: 2019 liuhao +License: GPL-3.0+ + +License: GPL-3.0+ + 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 of the License, or + (at your option) any later version. + . + This package 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 . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..95cf77f --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +export QT_SELECT := qt5 + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100755 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/watch b/debian/watch new file mode 100755 index 0000000..e685515 --- /dev/null +++ b/debian/watch @@ -0,0 +1,2 @@ +version=4 +https://github.com/ukui/ukui-menu/releases .*/ukui-menu_(\d\S+)\.orig\.tar\.gz diff --git a/main.cpp b/main.cpp old mode 100644 new mode 100755 index 510c21d..4d4c558 --- a/main.cpp +++ b/main.cpp @@ -16,7 +16,8 @@ * */ -#include "src/MainWindow/mainwindow.h" +#include "mainwindow.h" +#include "tabletwindow.h" #include #include #include @@ -25,70 +26,113 @@ #include #include #include -#include "src/UtilityFunction/proxystyle.h" -#include -#include "src/UtilityFunction/utility.h" -#include "src/SearchResultWidget/file-utils.h" +#include "utility.h" +#include "file-utils.h" +#include +#include +#include "ukuistylehelper/ukuistylehelper.h" +#include "windowmanager/windowmanager.h" + +#define UKUI_SERVICE "org.gnome.SessionManager" +#define UKUI_PATH "/org/gnome/SessionManager" +#define UKUI_INTERFACE "org.gnome.SessionManager" #include int main(int argc, char *argv[]) { initUkuiLog4qt("ukui-menu"); - qRegisterMetaType>("QVector"); + g_projectCodeName = KDKGetPrjCodeName().c_str(); + g_subProjectCodeName = KDKGetOSRelease("SUB_PROJECT_CODENAME").c_str(); + qRegisterMetaType>("QVector"); #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif - QtSingleApplication app("ukui-menu", argc, argv); app.setQuitOnLastWindowClosed(false); + g_platform = QGuiApplication::platformName(); - - if(app.isRunning()) - { + if (app.isRunning()) { app.sendMessage("raise_window_noop"); return EXIT_SUCCESS; } -// auto Style=new ProxyStyle; -// app.setStyle(Style); - QTranslator translator; - if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) + + if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) { app.installTranslator(&translator); - else - qDebug() << "Load translations file" << QLocale() << "failed!"; + } else { + myDebug() << "Load translations file" << QLocale() << "failed!"; + } - Zeeker::FileUtils::loadHanziTable(":/src/SearchResultWidget/pinyinWithoutTone.txt"); - MainWindow w; - app.setActivationWindow(&w); + if (!g_projectCodeName.contains("V10SP1-edu")) { + FileUtils::loadHanziTable(":/src/BackProcess/Search/pinyinWithoutTone.txt"); + MainWindow w; + app.setActivationWindow(&w); -// w.setProperty("useSystemStyleBlur", true); + w.show(); + w.raise(); - //测试 + if (Style::m_panelPosition == 0) { + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(w.windowHandle(),QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + + Style::m_availableScreenHeight - Style::minh - 3, Style::minw, Style::minh)); + } else { + w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + Style::m_availableScreenHeight - Style::minh - 3, + Style::minw, Style::minh)); + } + } else if (Style::m_panelPosition == 1) { + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(w.windowHandle(),QRect(Style::m_primaryScreenX + 4, + Style::m_primaryScreenY + 4, Style::minw, Style::minh)); + } else { + w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::minw, Style::minh)); + } -// if(Style::panelPosition==0) -// w.setGeometry(QRect(Style::primaryScreenX+4,Style::primaryScreenY+Style::primaryScreenHeight-Style::panelSize-Style::minh-3, -// Style::minw,Style::minh)); -// else if(Style::panelPosition==1) -// w.setGeometry(QRect(Style::primaryScreenX+4,Style::primaryScreenY+Style::panelSize+4,Style::minw,Style::minh)); -// else if(Style::panelPosition==2) -// w.setGeometry(QRect(Style::primaryScreenX+Style::panelSize+4,Style::primaryScreenY+4,Style::minw,Style::minh)); -// else -// w.setGeometry(QRect(Style::primaryScreenX+Style::primaryScreenWidth-Style::panelSize-Style::minw-4,Style::primaryScreenY+4, -// Style::minw,Style::minh)); + } else if (Style::m_panelPosition == 2) { - w.show(); - w.raise(); - w.update(); - w.activateWindow(); - w.hide(); - //测试 - return app.exec(); + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(w.windowHandle(), QRect(Style::m_primaryScreenX + 4, + Style::m_primaryScreenY + 4, Style::minw, Style::minh)); + } else { + w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::minw, Style::minh)); + } + } else { + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(w.windowHandle(), QRect(Style::m_primaryScreenX + Style::m_availableScreenWidth - + Style::minw - 4, Style::m_primaryScreenY + 4, Style::minw, Style::minh)); + } else { + w.setGeometry(QRect(Style::m_primaryScreenX + Style::m_availableScreenWidth - Style::minw - 4, Style::m_primaryScreenY + 4, + Style::minw, Style::minh)); + } + } + + w.update(); + w.activateWindow(); + w.hide(); + return app.exec(); + } else { + TabletWindow w; + app.setActivationWindow(&w); + centerToScreen(&w); + w.setAttribute(Qt::WA_TranslucentBackground, true); + w.setAttribute(Qt::WA_X11NetWmWindowTypeDesktop, false); + w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); + w.raise(); + w.activateWindow(); + //拉起后通知session + QDBusInterface interface(UKUI_SERVICE, + UKUI_PATH, + UKUI_INTERFACE, + QDBusConnection::sessionBus()); + interface.call("startupfinished", "ukui-menu", "finish"); + return app.exec(); + } } + diff --git a/man/ukui-menu.1 b/man/ukui-menu.1 old mode 100644 new mode 100755 diff --git a/res.qrc b/res.qrc old mode 100644 new mode 100755 index fc6c8ee..47d0ea3 --- a/res.qrc +++ b/res.qrc @@ -1,13 +1,128 @@ + data/img/mainviewwidget/all-2x.png + data/img/mainviewwidget/all.png + data/img/mainviewwidget/all.svg data/img/mainviewwidget/attributeaction.svg + data/img/mainviewwidget/close-2x.png + data/img/mainviewwidget/close.png + data/img/mainviewwidget/close.svg + data/img/mainviewwidget/Development-Checked.svg + data/img/mainviewwidget/Development-Disabled.svg + data/img/mainviewwidget/Development-Enabled.svg + data/img/mainviewwidget/Development-Normal.svg + data/img/mainviewwidget/DM-all-2x.png + data/img/mainviewwidget/DM-all.png + data/img/mainviewwidget/DM-all.svg + data/img/mainviewwidget/DM-close-2x.png + data/img/mainviewwidget/DM-close.png + data/img/mainviewwidget/DM-close.svg + data/img/mainviewwidget/DM-function-2x.png + data/img/mainviewwidget/DM-function.png + data/img/mainviewwidget/DM-function.svg + data/img/mainviewwidget/DM-arrow.png + data/img/mainviewwidget/DM-arrow.svg + data/img/mainviewwidget/DM-arrow-2x.png + data/img/mainviewwidget/DM-icon-返回.png + data/img/mainviewwidget/DM-icon-返回.svg + data/img/mainviewwidget/DM-icon-返回@2x.png + data/img/mainviewwidget/DM-icon-选项.png + data/img/mainviewwidget/DM-icon-选项@2x.png + data/img/mainviewwidget/DM-icon-check.png + data/img/mainviewwidget/DM-icon-check.svg + data/img/mainviewwidget/DM-icon-check@2x.png + data/img/mainviewwidget/DM-icon-search.png + data/img/mainviewwidget/DM-icon-search.svg + data/img/mainviewwidget/DM-icon-search@2x.png + data/img/mainviewwidget/DM-letter-2x.png + data/img/mainviewwidget/DM-letter.png + data/img/mainviewwidget/DM-letter.svg + data/img/mainviewwidget/DM-max-2x.png + data/img/mainviewwidget/DM-max.png + data/img/mainviewwidget/DM-max.svg data/img/mainviewwidget/downarrow-pressed.svg data/img/mainviewwidget/downarrow.svg + data/img/mainviewwidget/drop-down-2x.png + data/img/mainviewwidget/drop-down.png + data/img/mainviewwidget/drop-down.svg + data/img/mainviewwidget/Education-Checked.svg + data/img/mainviewwidget/Education-Disabled.svg + data/img/mainviewwidget/Education-Enabled.svg + data/img/mainviewwidget/Education-Normal.svg data/img/mainviewwidget/fixed.svg + data/img/mainviewwidget/full-all-2x.png + data/img/mainviewwidget/full-close-2x.png + data/img/mainviewwidget/full-close.png + data/img/mainviewwidget/full-close.svg + data/img/mainviewwidget/full-drop-down-2x.png + data/img/mainviewwidget/full-drop-down.png + data/img/mainviewwidget/full-drop-down.svg + data/img/mainviewwidget/full-function-2x.png + data/img/mainviewwidget/full-function.png + data/img/mainviewwidget/full-function.svg + data/img/mainviewwidget/full-letter-2x.png + data/img/mainviewwidget/full-letter.png + data/img/mainviewwidget/full-letter.svg + data/img/mainviewwidget/full-min-2x.png + data/img/mainviewwidget/full-min.png + data/img/mainviewwidget/full-min.svg + data/img/mainviewwidget/full-search-2x.png + data/img/mainviewwidget/full-search.png + data/img/mainviewwidget/full-search.svg + data/img/mainviewwidget/fullicon-all.png + data/img/mainviewwidget/fullicon-all.svg + data/img/mainviewwidget/function-2x.png + data/img/mainviewwidget/function.png + data/img/mainviewwidget/function.svg + data/img/mainviewwidget/Game-Checked.svg + data/img/mainviewwidget/Game-Disabled.svg + data/img/mainviewwidget/Game-Enabled.svg + data/img/mainviewwidget/Game-Normal.svg + data/img/mainviewwidget/icon- 返回.png + data/img/mainviewwidget/icon- 返回.svg + data/img/mainviewwidget/icon- 返回@2x.png + data/img/mainviewwidget/icon- 选项.png + data/img/mainviewwidget/icon- 选项.svg + data/img/mainviewwidget/icon- 选项@2x.png + data/img/mainviewwidget/icon- search-2x.png + data/img/mainviewwidget/icon- search.png + data/img/mainviewwidget/icon- search.svg + data/img/mainviewwidget/icon-check.png + data/img/mainviewwidget/icon-check.svg + data/img/mainviewwidget/icon-check@2x.png + data/img/mainviewwidget/Image-Checked.svg + data/img/mainviewwidget/Image-Disabled.svg + data/img/mainviewwidget/Image-Enabled.svg + data/img/mainviewwidget/Image-Normal.svg + data/img/mainviewwidget/Internet-Checked.svg + data/img/mainviewwidget/Internet-Disabled.svg + data/img/mainviewwidget/Internet-Enabled.svg + data/img/mainviewwidget/Internet-Normal.svg data/img/mainviewwidget/leftarrow-hover.svg data/img/mainviewwidget/leftarrow.svg + data/img/mainviewwidget/letter-2x.png + data/img/mainviewwidget/letter.png + data/img/mainviewwidget/letter.svg data/img/mainviewwidget/lock-fs.svg data/img/mainviewwidget/lock.svg + data/img/mainviewwidget/max-2x.png + data/img/mainviewwidget/max.png + data/img/mainviewwidget/max.svg + data/img/mainviewwidget/Mobile-Checked.svg + data/img/mainviewwidget/Mobile-Disabled.svg + data/img/mainviewwidget/Mobile-Enabled.svg + data/img/mainviewwidget/Mobile-Normal.svg + data/img/mainviewwidget/Office-Checked.svg + data/img/mainviewwidget/Office-Disabled.svg + data/img/mainviewwidget/Office-Enabled.svg + data/img/mainviewwidget/Office-Normal.svg + data/img/mainviewwidget/Others-Checked.svg + data/img/mainviewwidget/Others-Disabled.svg + data/img/mainviewwidget/Others-Enabled.svg + data/img/mainviewwidget/Others-Normal.svg + data/img/mainviewwidget/power-2x.png + data/img/mainviewwidget/power.png + data/img/mainviewwidget/power.svg data/img/mainviewwidget/recent-disabled.svg data/img/mainviewwidget/recent-enabled.svg data/img/mainviewwidget/recent-gray.svg @@ -15,10 +130,26 @@ data/img/mainviewwidget/rightarrow-hover.svg data/img/mainviewwidget/rightarrow.svg data/img/mainviewwidget/search.svg + data/img/mainviewwidget/select.svg + data/img/mainviewwidget/selected.svg + data/img/mainviewwidget/Social-Checked.svg + data/img/mainviewwidget/Social-Disabled.svg + data/img/mainviewwidget/Social-Enabled.svg + data/img/mainviewwidget/Social-Normal.svg + data/img/mainviewwidget/System-Checked.svg + data/img/mainviewwidget/System-Disabled.svg + data/img/mainviewwidget/System-Enabled.svg + data/img/mainviewwidget/System-Normal.svg + data/img/mainviewwidget/ukui-search-blue.svg + data/img/mainviewwidget/ukui-search.svg data/img/mainviewwidget/unfixed.svg data/img/mainviewwidget/uninstall.svg data/img/mainviewwidget/uparrow-pressed.svg data/img/mainviewwidget/uparrow.svg + data/img/mainviewwidget/Video-Checked.svg + data/img/mainviewwidget/Video-Disabled.svg + data/img/mainviewwidget/Video-Enabled.svg + data/img/mainviewwidget/Video-Normal.svg data/img/sidebarwidget/commonuse.svg data/img/sidebarwidget/computer.svg data/img/sidebarwidget/control.svg @@ -29,59 +160,16 @@ data/img/sidebarwidget/lock.svg data/img/sidebarwidget/max.svg data/img/sidebarwidget/min.svg + data/img/sidebarwidget/personal.svg data/img/sidebarwidget/rightarrow.svg data/img/sidebarwidget/setting.svg data/img/sidebarwidget/shutdown.svg + data/img/sidebarwidget/trash.svg data/img/sidebarwidget/unfixed.svg data/img/sidebarwidget/usericon-darkcolor.svg data/img/sidebarwidget/usericon-lightcolor.svg - data/img/sidebarwidget/personal.svg - data/img/sidebarwidget/trash.svg - data/img/mainviewwidget/Development-Checked.svg - data/img/mainviewwidget/Development-Disabled.svg - data/img/mainviewwidget/Development-Enabled.svg - data/img/mainviewwidget/Development-Normal.svg - data/img/mainviewwidget/Education-Checked.svg - data/img/mainviewwidget/Education-Disabled.svg - data/img/mainviewwidget/Education-Enabled.svg - data/img/mainviewwidget/Education-Normal.svg - data/img/mainviewwidget/Game-Checked.svg - data/img/mainviewwidget/Game-Disabled.svg - data/img/mainviewwidget/Game-Enabled.svg - data/img/mainviewwidget/Game-Normal.svg - data/img/mainviewwidget/Image-Checked.svg - data/img/mainviewwidget/Image-Disabled.svg - data/img/mainviewwidget/Image-Enabled.svg - data/img/mainviewwidget/Image-Normal.svg - data/img/mainviewwidget/Internet-Checked.svg - data/img/mainviewwidget/Internet-Disabled.svg - data/img/mainviewwidget/Internet-Enabled.svg - data/img/mainviewwidget/Internet-Normal.svg - data/img/mainviewwidget/Office-Checked.svg - data/img/mainviewwidget/Office-Disabled.svg - data/img/mainviewwidget/Office-Enabled.svg - data/img/mainviewwidget/Office-Normal.svg - data/img/mainviewwidget/Others-Checked.svg - data/img/mainviewwidget/Others-Disabled.svg - data/img/mainviewwidget/Others-Enabled.svg - data/img/mainviewwidget/Others-Normal.svg - data/img/mainviewwidget/Social-Checked.svg - data/img/mainviewwidget/Social-Disabled.svg - data/img/mainviewwidget/Social-Enabled.svg - data/img/mainviewwidget/Social-Normal.svg - data/img/mainviewwidget/System-Checked.svg - data/img/mainviewwidget/System-Disabled.svg - data/img/mainviewwidget/System-Enabled.svg - data/img/mainviewwidget/System-Normal.svg - data/img/mainviewwidget/Video-Checked.svg - data/img/mainviewwidget/Video-Disabled.svg - data/img/mainviewwidget/Video-Enabled.svg - data/img/mainviewwidget/Video-Normal.svg - data/img/mainviewwidget/Mobile-Checked.svg - data/img/mainviewwidget/Mobile-Disabled.svg - data/img/mainviewwidget/Mobile-Enabled.svg - data/img/mainviewwidget/Mobile-Normal.svg - src/SearchResultWidget/pinyinWithTone.txt - src/SearchResultWidget/pinyinWithoutTone.txt + src/BackProcess/Search/pinyinWithoutTone.txt + src/BackProcess/Search/pinyinWithTone.txt + data/img/mainviewwidget/DM-icon-option.svg diff --git a/src/DBus/dbus-adaptor.cpp b/src/BackProcess/DBus/dbus-adaptor.cpp old mode 100644 new mode 100755 similarity index 89% rename from src/DBus/dbus-adaptor.cpp rename to src/BackProcess/DBus/dbus-adaptor.cpp index 46418e7..9df5c62 --- a/src/DBus/dbus-adaptor.cpp +++ b/src/BackProcess/DBus/dbus-adaptor.cpp @@ -53,3 +53,9 @@ void MenuAdaptor::WinKeyResponse() QMetaObject::invokeMethod(parent(), "WinKeyResponse"); } +bool MenuAdaptor::GetMenuStatus() +{ + bool status; + QMetaObject::invokeMethod(parent(), "GetMenuStatus", Q_RETURN_ARG(bool, status)); + return status; +} diff --git a/src/DBus/dbus-adaptor.h b/src/BackProcess/DBus/dbus-adaptor.h old mode 100644 new mode 100755 similarity index 62% rename from src/DBus/dbus-adaptor.h rename to src/BackProcess/DBus/dbus-adaptor.h index 0d51f6d..cc29f87 --- a/src/DBus/dbus-adaptor.h +++ b/src/BackProcess/DBus/dbus-adaptor.h @@ -9,8 +9,8 @@ * before re-generating it. */ -#ifndef DBUS-ADAPTOR_H -#define DBUS-ADAPTOR_H +#ifndef DBUS_ADAPTOR_H +#define DBUS_ADAPTOR_H #include #include @@ -32,14 +32,17 @@ class MenuAdaptor: public QDBusAbstractAdaptor Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") Q_CLASSINFO("D-Bus Introspection", "" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" - "") + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "") public: MenuAdaptor(QObject *parent); virtual ~MenuAdaptor(); @@ -49,6 +52,7 @@ public Q_SLOTS: // METHODS QString GetSecurityConfigPath(); void ReloadSecurityConfig(); void WinKeyResponse(); + bool GetMenuStatus(); Q_SIGNALS: // SIGNALS }; diff --git a/src/DBus/dbus.cpp b/src/BackProcess/DBus/dbus.cpp old mode 100644 new mode 100755 similarity index 65% rename from src/DBus/dbus.cpp rename to src/BackProcess/DBus/dbus.cpp index f8d79a6..42f7109 --- a/src/DBus/dbus.cpp +++ b/src/BackProcess/DBus/dbus.cpp @@ -1,10 +1,10 @@ #include "dbus.h" #include #include +#include "utility.h" DBus::DBus(QObject *parent) : QObject(parent) { - } void DBus::ReloadSecurityConfig() @@ -14,7 +14,7 @@ void DBus::ReloadSecurityConfig() QString DBus::GetSecurityConfigPath() { - QString path=QDir::homePath()+"/.config/ukui-menu-security-config.json"; + QString path = QDir::homePath() + "/.config/ukui-menu-security-config.json"; return path; } @@ -22,3 +22,8 @@ void DBus::WinKeyResponse() { Q_EMIT winKeyResponseSignal(); } + +bool DBus::GetMenuStatus() +{ + return g_menuStatus; +} diff --git a/src/DBus/dbus.h b/src/BackProcess/DBus/dbus.h old mode 100644 new mode 100755 similarity index 81% rename from src/DBus/dbus.h rename to src/BackProcess/DBus/dbus.h index 8f017fe..44f3be4 --- a/src/DBus/dbus.h +++ b/src/BackProcess/DBus/dbus.h @@ -6,7 +6,7 @@ class DBus : public QObject { Q_OBJECT - Q_CLASSINFO("D-Bus Interface","org.ukui.menu") + Q_CLASSINFO("D-Bus Interface", "org.ukui.menu") public: explicit DBus(QObject *parent = 0); @@ -18,6 +18,7 @@ public Q_SLOTS: QString GetSecurityConfigPath(); void ReloadSecurityConfig(); void WinKeyResponse(); + bool GetMenuStatus(); }; #endif // DBUS_H diff --git a/src/DBus/org.ukui.menu.xml b/src/BackProcess/DBus/org.ukui.menu.xml old mode 100644 new mode 100755 similarity index 100% rename from src/DBus/org.ukui.menu.xml rename to src/BackProcess/DBus/org.ukui.menu.xml diff --git a/src/UtilityFunction/convertdesktoptowinid.cpp b/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp old mode 100644 new mode 100755 similarity index 90% rename from src/UtilityFunction/convertdesktoptowinid.cpp rename to src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp index bf1d89e..cf17b36 --- a/src/UtilityFunction/convertdesktoptowinid.cpp +++ b/src/BackProcess/FileWatcher/convert_winid_to_desktop.cpp @@ -16,27 +16,27 @@ * */ -#include "convertdesktoptowinid.h" -#include "src/UtilityFunction/utility.h" +#include "convert_winid_to_desktop.h" +#include "utility.h" #include #include #include #include -ConvertDesktopToWinId::ConvertDesktopToWinId() +ConvertWinidToDesktop::ConvertWinidToDesktop(QObject *parent) : QObject(parent) { - } -QString ConvertDesktopToWinId::tranIdToDesktop(WId id) +QString ConvertWinidToDesktop::tranIdToDesktop(WId id) { KWindowInfo info(id, 0, NET::WM2AllProperties); + myDebug() << "the pid is :" << info.pid(); QString desktopName = confirmDesktopFile(info); myDebug() << "desktopName is :" << desktopName; return desktopName; } -QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info) +QString ConvertWinidToDesktop::confirmDesktopFile(KWindowInfo info) { QString desktopFilePath = nullptr; QDir dir = QDir(DESKTOP_FILE_PATH); @@ -89,7 +89,7 @@ QString ConvertDesktopToWinId::confirmDesktopFile(KWindowInfo info) return desktopFilePath; } -QString ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info) +QString ConvertWinidToDesktop::searchAndroidApp(KWindowInfo info) { QDir androidDir = QString(QDir::homePath() + ANDROID_FILE_PATH); QFileInfoList androidList = androidDir.entryInfoList(); @@ -116,7 +116,7 @@ QString ConvertDesktopToWinId::searchAndroidApp(KWindowInfo info) return nullptr; } -QString ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info, QFileInfoList list) +QString ConvertWinidToDesktop::searchFromEnviron(KWindowInfo info, QFileInfoList list) { QFile file("/proc/" + QString::number(info.pid()) + "/environ"); file.open(QIODevice::ReadOnly); @@ -147,7 +147,7 @@ QString ConvertDesktopToWinId::searchFromEnviron(KWindowInfo info, QFileInfoList return desktopFilePath; } -QString ConvertDesktopToWinId::compareClassName(QFileInfoList list) +QString ConvertWinidToDesktop::compareClassName(QFileInfoList list) { for (int i = 0; i < list.size(); i++) { QFileInfo fileInfo = list.at(i);; @@ -164,7 +164,7 @@ QString ConvertDesktopToWinId::compareClassName(QFileInfoList list) return nullptr; } -QString ConvertDesktopToWinId::compareCmdExec(QFileInfoList list) +QString ConvertWinidToDesktop::compareCmdExec(QFileInfoList list) { for (int i = 0; i < list.size(); i++) { QString cmd; @@ -193,7 +193,7 @@ QString ConvertDesktopToWinId::compareCmdExec(QFileInfoList list) } //最后的匹配策略汇总 -QString ConvertDesktopToWinId::compareLastStrategy(QFileInfoList list) +QString ConvertWinidToDesktop::compareLastStrategy(QFileInfoList list) { QString desktopFilePath = compareCmdName(list); @@ -207,7 +207,7 @@ QString ConvertDesktopToWinId::compareLastStrategy(QFileInfoList list) return desktopFilePath; } -QString ConvertDesktopToWinId::compareCmdName(QFileInfoList list) +QString ConvertWinidToDesktop::compareCmdName(QFileInfoList list) { for (int i = 0; i < list.size(); i++) { QString cmd; @@ -229,7 +229,7 @@ QString ConvertDesktopToWinId::compareCmdName(QFileInfoList list) return nullptr; } -QString ConvertDesktopToWinId::compareDesktopClass(QFileInfoList list) +QString ConvertWinidToDesktop::compareDesktopClass(QFileInfoList list) { for (int i = 0; i < list.size(); i++) { QFileInfo fileInfo = list.at(i); @@ -250,7 +250,7 @@ QString ConvertDesktopToWinId::compareDesktopClass(QFileInfoList list) return nullptr; } -QString ConvertDesktopToWinId::containsName(QFileInfoList list) +QString ConvertWinidToDesktop::containsName(QFileInfoList list) { for (int i = 0; i < list.size(); i++) { QString cmd; @@ -275,19 +275,19 @@ QString ConvertDesktopToWinId::containsName(QFileInfoList list) } //执行头文件中宏定义写好的终端指令获取对应的Exec字段 -QString ConvertDesktopToWinId::getDesktopFileName(QString cmd) +QString ConvertWinidToDesktop::getDesktopFileName(QString cmd) { char name[200]; FILE *fp1 = NULL; - if ((fp1 = popen(cmd.toStdString().data(), "r")) == NULL) + if ((fp1 = popen(cmd.toStdString().data(), "r")) == NULL) { return QString(); + } memset(name, 0, sizeof(name)); fgets(name, sizeof(name), fp1); pclose(fp1); return QString(name); } - -ConvertDesktopToWinId::~ConvertDesktopToWinId() +ConvertWinidToDesktop::~ConvertWinidToDesktop() { } diff --git a/src/UtilityFunction/convertdesktoptowinid.h b/src/BackProcess/FileWatcher/convert_winid_to_desktop.h old mode 100644 new mode 100755 similarity index 91% rename from src/UtilityFunction/convertdesktoptowinid.h rename to src/BackProcess/FileWatcher/convert_winid_to_desktop.h index 109c14a..ba6a77f --- a/src/UtilityFunction/convertdesktoptowinid.h +++ b/src/BackProcess/FileWatcher/convert_winid_to_desktop.h @@ -38,17 +38,17 @@ /** - * @brief The ConvertDesktopToWinId class + * @brief The ConvertWinidToDesktop class * 需要实现的功能,desktop文件与windowId的转换 - * 传入desktop文件的路径,转化为(int)WindowId + * 传入(int)WindowId,转化为desktop文件的路径 */ -class ConvertDesktopToWinId: public QObject +class ConvertWinidToDesktop : public QObject { Q_OBJECT public: - ConvertDesktopToWinId(); - ~ConvertDesktopToWinId(); + explicit ConvertWinidToDesktop(QObject *parent = nullptr); + ~ConvertWinidToDesktop(); QString tranIdToDesktop(WId id); diff --git a/src/BackProcess/FileWatcher/desktop_watcher.cpp b/src/BackProcess/FileWatcher/desktop_watcher.cpp new file mode 100755 index 0000000..e3c6141 --- /dev/null +++ b/src/BackProcess/FileWatcher/desktop_watcher.cpp @@ -0,0 +1,38 @@ +#include "desktop_watcher.h" +#include +#include + +DesktopWatcher::DesktopWatcher() +{ + //监控.desktop文件目录 + m_fileWatcher = new QFileSystemWatcher; + m_fileWatcher->addPaths(QStringList() << QString("/usr/share/applications") + << QString(QDir::homePath() + "/.local/share/applications/") + << QString("/var/lib/snapd/desktop/applications/") + << QString("/var/lib/flatpak/exports/share/applications/")); + connect(m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &DesktopWatcher::directoryChangedSlot); + // m_recentFile = new QFileSystemWatcher; + // m_recentFile->addPath(QString(QDir::homePath()+"/.local/share/recently-used.xbel")); + // connect(m_recentFile,&QFileSystemWatcher::fileChanged,this,[=](){ + // m_recentFile->addPath(QDir::homePath()+"/.local/share/recently-used.xbel"); + // Q_EMIT updateRecentList();}); + m_directoryChangedThread = new DirectoryChangedThread; + connect(m_directoryChangedThread, &DirectoryChangedThread::requestUpdateSignal, this, &DesktopWatcher::requestUpdateSlot); +} + +/** + * desktop文件目录改变信号槽 + */ +void DesktopWatcher::directoryChangedSlot(const QString &path) +{ + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); + m_directoryChangedThread->start(); +} + +void DesktopWatcher::requestUpdateSlot() +{ + m_directoryChangedThread->quit(); + Q_EMIT directoryChangedSignal(); +} diff --git a/src/BackProcess/FileWatcher/desktop_watcher.h b/src/BackProcess/FileWatcher/desktop_watcher.h new file mode 100755 index 0000000..874a98d --- /dev/null +++ b/src/BackProcess/FileWatcher/desktop_watcher.h @@ -0,0 +1,32 @@ +#ifndef DESKTOPWATCHER_H +#define DESKTOPWATCHER_H +#include +#include "directory_changed_thread.h" + + +class DesktopWatcher : public QObject +{ + Q_OBJECT +public: + DesktopWatcher(); + +public: +Q_SIGNALS: + /** + * @brief Desktop file directory change signal + */ + void directoryChangedSignal(); + void updateRecentList(); + +public Q_SLOTS: + + void directoryChangedSlot(const QString &path); + void requestUpdateSlot(); + +private: + QFileSystemWatcher *m_fileWatcher = nullptr; //Monitor desktop folder status +// QFileSystemWatcher *m_recentFile=nullptr; + DirectoryChangedThread *m_directoryChangedThread = nullptr; +}; + +#endif // DESKTOPWATCHER_H diff --git a/src/MainViewWidget/directorychangedthread.cpp b/src/BackProcess/FileWatcher/directory_changed_thread.cpp old mode 100644 new mode 100755 similarity index 55% rename from src/MainViewWidget/directorychangedthread.cpp rename to src/BackProcess/FileWatcher/directory_changed_thread.cpp index 1e6d156..3ef8938 --- a/src/MainViewWidget/directorychangedthread.cpp +++ b/src/BackProcess/FileWatcher/directory_changed_thread.cpp @@ -16,14 +16,14 @@ * */ -#include "directorychangedthread.h" +#include "directory_changed_thread.h" #include #include -#include "src/UtilityFunction/utility.h" +#include "utility.h" DirectoryChangedThread::DirectoryChangedThread() { - m_ukuiMenuInterface=new UkuiMenuInterface; + m_ukuiMenuInterface = new UkuiMenuInterface; } DirectoryChangedThread::~DirectoryChangedThread() @@ -35,41 +35,35 @@ void DirectoryChangedThread::run() { closeDataBase("DirectoryChangedThread"); openDataBase("DirectoryChangedThread"); - QStringList desktopfpList=m_ukuiMenuInterface->getDesktopFilePath(); - if(desktopfpList.size() >= UkuiMenuInterface::desktopfpVector.size())//有新的应用安装 - { - for(int i=0;igetDesktopFilePath(); + + if (desktopfpList.size() > UkuiMenuInterface::desktopfpVector.size()) { //有新的应用安装 + for (int i = 0; i < desktopfpList.count(); i++) { + if (!UkuiMenuInterface::desktopfpVector.contains(desktopfpList.at(i))) { QFileInfo fileInfo(desktopfpList.at(i)); - QString desktopfn=fileInfo.fileName(); + QString desktopfn = fileInfo.fileName(); updateDataBaseTableRecent(desktopfn); - //break; + break; } - } - } - else//软件卸载 - { - for(int i=0;icreateAppInfoVector(); - UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); Q_EMIT requestUpdateSignal(); } diff --git a/src/MainViewWidget/directorychangedthread.h b/src/BackProcess/FileWatcher/directory_changed_thread.h old mode 100644 new mode 100755 similarity index 92% rename from src/MainViewWidget/directorychangedthread.h rename to src/BackProcess/FileWatcher/directory_changed_thread.h index 63f9ef4..da6130c --- a/src/MainViewWidget/directorychangedthread.h +++ b/src/BackProcess/FileWatcher/directory_changed_thread.h @@ -21,7 +21,7 @@ #include #include #include -#include "src/Interface/ukuimenuinterface.h" +#include "ukuimenuinterface.h" class DirectoryChangedThread: public QThread { @@ -32,7 +32,7 @@ public: void run(); private: - UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; Q_SIGNALS: /** diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.cpp b/src/BackProcess/FileWatcher/software_database_update_thread.cpp old mode 100644 new mode 100755 similarity index 62% rename from src/UtilityFunction/softwaredatabaseupdatethread.cpp rename to src/BackProcess/FileWatcher/software_database_update_thread.cpp index 68429d2..b8c98f4 --- a/src/UtilityFunction/softwaredatabaseupdatethread.cpp +++ b/src/BackProcess/FileWatcher/software_database_update_thread.cpp @@ -1,4 +1,22 @@ -#include "softwaredatabaseupdatethread.h" +/* + * 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 #include #include @@ -9,13 +27,14 @@ #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" -SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread(QObject *parent): - QThread(parent) +SoftwareDatabaseUpdateThread::SoftwareDatabaseUpdateThread() { + } SoftwareDatabaseUpdateThread::~SoftwareDatabaseUpdateThread() { + } void SoftwareDatabaseUpdateThread::run() @@ -23,12 +42,12 @@ void SoftwareDatabaseUpdateThread::run() QSqlDatabase db; db = QSqlDatabase::addDatabase("QSQLITE", "SoftwareThreadDatabase"); db.setDatabaseName(DATABASENAME); - - if (false == db.open()) { - qDebug() << db.lastError().text(); + if (false == db.open()){ + myDebug() << db.lastError().text(); } QSqlQuery sql(db); + QJsonDocument jsonDocument = QJsonDocument::fromJson(m_category.toLocal8Bit().data()); QJsonObject jsonObject = jsonDocument.object(); QJsonArray jsonArray = jsonObject[jsonObject.keys()[0]].toArray(); @@ -48,12 +67,13 @@ void SoftwareDatabaseUpdateThread::run() if (number % 5000 == 0) { db.commit(); db.transaction(); - } + } } db.commit(); - + myDebug() << "数据库已经更新"; Q_EMIT updateDatabaseSignal(); + } void SoftwareDatabaseUpdateThread::getDatabaseList(QString category) diff --git a/src/RightClickMenu/uninstallwhitelist.h b/src/BackProcess/FileWatcher/software_database_update_thread.h old mode 100644 new mode 100755 similarity index 60% rename from src/RightClickMenu/uninstallwhitelist.h rename to src/BackProcess/FileWatcher/software_database_update_thread.h index a478292..51d7d8d --- a/src/RightClickMenu/uninstallwhitelist.h +++ b/src/BackProcess/FileWatcher/software_database_update_thread.h @@ -16,32 +16,30 @@ * */ -#ifndef UNINSTALLWHITELIST_H -#define UNINSTALLWHITELIST_H -#include +#ifndef SOFTWAREDATABASEUPDATETHREAD_H +#define SOFTWAREDATABASEUPDATETHREAD_H -class UninstallWhitelist : public QObject +#include +#include +#include +#include +#include +#include +#include + +class SoftwareDatabaseUpdateThread:public QThread { Q_OBJECT - public: - static UninstallWhitelist *getInstance(); - /** - * @brief 获取不可卸载包名列表 - * @return - */ - QStringList getPkgNameWhiteList(); - /** - * @brief 获取不可卸载desktop列表 - * @return - */ - QStringList getWhiteList(); -private: - UninstallWhitelist(); -private: - static UninstallWhitelist *instance; + SoftwareDatabaseUpdateThread(); + ~SoftwareDatabaseUpdateThread(); + void run(); + void getDatabaseList(QString category); +Q_SIGNALS: + void updateDatabaseSignal(); - QStringList m_whiteList; +private: + QString m_category; }; -#endif // UNINSTALLWHITELIST_H +#endif // SOFTWAREDATABASEUPDATETHREAD_H diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp new file mode 100755 index 0000000..0cbbf6b --- /dev/null +++ b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.cpp @@ -0,0 +1,157 @@ +/* + * 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 +#include +#include +#include "tabletlistview.h" +#include +#include + +TabletDirectoryChangedThread::TabletDirectoryChangedThread() +{ + m_ukuiMenuInterface = new UkuiMenuInterface; + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + setting = new QSettings(path, QSettings::IniFormat); +} + +TabletDirectoryChangedThread::~TabletDirectoryChangedThread() +{ + if (m_ukuiMenuInterface) { + delete m_ukuiMenuInterface; + } + + if (setting) { + delete setting; + } + + m_ukuiMenuInterface = nullptr; + setting = nullptr; +} + + +void TabletDirectoryChangedThread::run() +{ + QStringList desktopfpList = m_ukuiMenuInterface->getDesktopFilePath(); + myDebug() << "应用列表desktopfpList" << desktopfpList.size() << desktopfpList; + myDebug() << "应用列表desktopfpVector" << UkuiMenuInterface::desktopfpVector.size() << UkuiMenuInterface::desktopfpVector; + QString m_desktopfp; + + for (int i = 0; i < desktopfpList.count(); i++) { + myDebug() << desktopfpList.at(i) << "是否存在于已安装应用列表中" << + UkuiMenuInterface::desktopfpVector.contains(QString(desktopfpList.at(i))); + + if (!UkuiMenuInterface::desktopfpVector.contains(QString(desktopfpList.at(i)))) { + m_desktopfp = desktopfpList.at(i); + myDebug() << "安装应用" << m_desktopfp; + //获取当前时间戳 + QDateTime dt = QDateTime::currentDateTime(); + int datetime = dt.toTime_t(); + QString str = desktopfpList.at(i).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + QString desktopfn = str; + setting->beginGroup("recentapp"); + setting->setValue(desktopfn, datetime); + setting->sync(); + setting->endGroup(); + //wgx + setting->beginGroup("application"); + QStringList applist = setting->allKeys(); + int appnum = setting->allKeys().count(); + int maxindex = 0; + int minindex = 0; + + for (int i = 0; i < appnum; i++) { + if (setting->value(applist.at(i)).toInt() > maxindex) { + maxindex = setting->value(applist.at(i)).toInt(); + } + + if(setting->value(applist.at(i)).toInt() <= minindex) { + minindex = setting->value(applist.at(i)).toInt(); + } + } + + if (desktopfn.contains("small-plugin-manage")){ + setting->setValue(desktopfn,minindex-1); + } else { + setting->setValue(desktopfn,maxindex+1); + } + + setting->sync(); + setting->endGroup(); + // + QString iconstr = m_ukuiMenuInterface->getAppIcon(desktopfpList.at(i)); + syslog(LOG_LOCAL0 | LOG_DEBUG, "%s", iconstr.toLocal8Bit().data()); + syslog(LOG_LOCAL0 | LOG_DEBUG, "软件安装desktop文件名:%s", desktopfn.toLocal8Bit().data()); + + Q_FOREACH (QString path, QIcon::themeSearchPaths()) { + syslog(LOG_LOCAL0 | LOG_DEBUG, "%s", path.toLocal8Bit().data()); + } + } + } + + for (int i = 0; i < UkuiMenuInterface::desktopfpVector.count(); i++) { + if (!desktopfpList.contains(UkuiMenuInterface::desktopfpVector.at(i))) { + QString desktopfp = UkuiMenuInterface::desktopfpVector.at(i); + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + myDebug() << "卸载" << desktopfn; + setting->beginGroup("lockapplication"); + setting->remove(desktopfn); + setting->sync(); + setting->endGroup(); + setting->beginGroup("application"); + + if (!setting->contains(desktopfn)) { + setting->sync(); + setting->endGroup(); + continue; + } + + int val = setting->value(desktopfn).toInt(); + myDebug() << "卸载val" << val; + setting->remove(desktopfn); + QStringList desktopfnList = setting->allKeys(); + + for (int i = 0; i < desktopfnList.count(); i++) { + if (setting->value(desktopfnList.at(i)).toInt() > val) { + setting->setValue(desktopfnList.at(i), setting->value(desktopfnList.at(i)).toInt() - 1); + } + } + + setting->sync(); + setting->endGroup(); + setting->beginGroup("recentapp"); + setting->remove(desktopfn); + setting->sync(); + setting->endGroup(); + syslog(LOG_LOCAL0 | LOG_DEBUG, "软件卸载desktop文件名:%s", desktopfn.toLocal8Bit().data()); + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + iface.call("RemoveFromTaskbar", desktopfp); + } + } + + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + Q_EMIT requestUpdateSignal(m_desktopfp); +} diff --git a/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h new file mode 100755 index 0000000..279dec1 --- /dev/null +++ b/src/BackProcess/FileWatcher/tablet_directorychanged_thread.h @@ -0,0 +1,53 @@ +/* + * 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 +#include +#include +#include "ukuimenuinterface.h" +#include +#include + +class TabletDirectoryChangedThread: public QThread +{ + Q_OBJECT +public: + TabletDirectoryChangedThread(); + ~TabletDirectoryChangedThread(); + void run(); + +private: + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QSettings *setting = nullptr; + TabletListView *m_listView = nullptr; + QStandardItemModel *listmodel = nullptr; + + int index = 0; + +Q_SIGNALS: + /** + * @brief Request update signal + */ + void requestUpdateSignal(QString desktopfp); + void deleteAppSignal(); + +}; + +#endif // DIRECTORYCHANGEDTHREAD_H diff --git a/src/BackProcess/Interface/currenttime_interface.cpp b/src/BackProcess/Interface/currenttime_interface.cpp new file mode 100755 index 0000000..4608040 --- /dev/null +++ b/src/BackProcess/Interface/currenttime_interface.cpp @@ -0,0 +1,90 @@ +#include "currenttime_interface.h" +#include +#define TIME_FORMAT "org.ukui.control-center.panel.plugins" +#define TIME_FORMAT_KEY "hoursystem" +#include +#include + +CurrentTimeInterface::CurrentTimeInterface() +{ + //获得语言环境 + dateTime = new QDateTime; + myTimer = new QTimer(); + myTimer->start(1000); + + if (QGSettings::isSchemaInstalled(TIME_FORMAT)) { + timeSetting = new QGSettings(TIME_FORMAT); + + if (timeSetting->keys().contains(TIME_FORMAT_KEY) && timeSetting->keys().contains("date")) { + timeFormat = timeSetting->get(TIME_FORMAT_KEY).toString(); + timeSlash = timeSetting->get("date").toString(); + getDateTime(timeFormat); + connect(timeSetting, &QGSettings::changed, this, [ = ](const QString & key) { + if (key == "hoursystem") { + timeFormat = timeSetting->get(TIME_FORMAT_KEY).toString(); + getDateTime(timeFormat); + } else if (key == "date") { + timeSlash = timeSetting->get("date").toString(); + + if (timeSlash == "en") { + currentDate = currentDate.replace("/", "-"); + } else { + currentDate = currentDate.replace("-", "/"); + } + } + }); + } + } + + connect(myTimer, &QTimer::timeout, [this]() { + getDateTime(timeFormat); + }); +} + +CurrentTimeInterface::~CurrentTimeInterface() +{ + if (myTimer) { + delete myTimer; + } + + if (timeSetting) { + delete timeSetting; + } + + if (dateTime) { + delete dateTime; + } + + myTimer = nullptr; + timeSetting = nullptr; + dateTime = nullptr; +} + +void CurrentTimeInterface::getDateTime(QString timeFormat) +{ + if (timeFormat == "12") { + twelveHourTime(); + } else if (timeFormat == "24") { + twentyFourHourTime(); + } + + if (timeSlash == "cn") { + currentDate = currentDate.replace("-", "/"); + } +} + +//12制小时时间 +void CurrentTimeInterface::twelveHourTime() +{ + currentTime = dateTime->currentDateTime().time().toString("hh:mm AP").split(" ").first(); + currentDate = dateTime->currentDateTime().date().toString("ddd MM-dd"); + currentWeek = dateTime->currentDateTime().time().toString("AP"); +} + +//24小时制时间 +void CurrentTimeInterface::twentyFourHourTime() +{ + currentTime = dateTime->currentDateTime().time().toString("hh:mm"); + currentDate = dateTime->currentDateTime().date().toString("MM-dd"); + currentWeek = dateTime->currentDateTime().date().toString("ddd"); +} diff --git a/src/BackProcess/Interface/currenttime_interface.h b/src/BackProcess/Interface/currenttime_interface.h new file mode 100755 index 0000000..cf08151 --- /dev/null +++ b/src/BackProcess/Interface/currenttime_interface.h @@ -0,0 +1,35 @@ +#ifndef CURRENTTIMEINTERFACE_H +#define CURRENTTIMEINTERFACE_H +#include +#include +#include +#include +#include +#include + +class CurrentTimeInterface : QObject +{ + +public: + CurrentTimeInterface(); + ~CurrentTimeInterface(); + + QString currentTime; + QString currentWeek; + QString currentDate; + +protected: + void twelveHourTime(); + void twentyFourHourTime(); + void getDateTime(QString timeFormat); + +private: + QDateTime *dateTime; + QTimer *myTimer; + QGSettings *timeSetting = nullptr; + QString timeFormat; + QString timeSlash; + +}; + +#endif // CURRENTTIMEINTERFACE_H diff --git a/src/BackProcess/Interface/ukui_chineseletter.cpp b/src/BackProcess/Interface/ukui_chineseletter.cpp new file mode 100755 index 0000000..ff73a2d --- /dev/null +++ b/src/BackProcess/Interface/ukui_chineseletter.cpp @@ -0,0 +1,6252 @@ +/* + * 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 +#include + +UkuiChineseLetter::UkuiChineseLetter() +{ +} + +bool UkuiChineseLetter::In(wchar_t start, wchar_t end, wchar_t code) +{ + if (code >= start && code <= end) { + return true; + } + + return false; +} + +char UkuiChineseLetter::Convert(int n)//此方法有缺陷,只能识别一级字库中的汉字 +{ + /* + * GB2312码范围 (B0A1-F7FE) + * HiByte (B0-F7) LoByte (A1-FE) + * + * GBK编码范围 (8140-FEFE) + * 包含三大部分 + * 1.汉字区 + * a. GB2312汉字区。即GBK/2 + * b. GB13000.1扩充汉字区。包括GBK/3(CJK汉字)和GBK/4(CJK汉字和增补汉字) + * 2.图形符号区 + * a. GB2312非汉字区。即GBK/1 A1A1-A9FE。还有10个小写罗马数字和GB12345增补符号 + * b. GB13000.1扩充非汉字区。即GBK/5 A840-A9A0非汉字符号、结构符... + * 3.用户自定义区 + * + */ + if (In(0xB0A1, 0xB0C4, n)) { + return 'A'; + } + + if (In(0XB0C5, 0XB2C0, n)) { + return 'B'; + } + + if (In(0xB2C1, 0xB4ED, n)) { + return 'C'; + } + + if (In(0xB4EE, 0xB6E9, n)) { + return 'D'; + } + + if (In(0xB6EA, 0xB7A1, n)) { + return 'E'; + } + + if (In(0xB7A2, 0xB8c0, n)) { + return 'F'; + } + + if (In(0xB8C1, 0xB9FD, n)) { + return 'G'; + } + + if (In(0xB9FE, 0xBBF6, n)) { + return 'H'; + } + + if (In(0xBBF7, 0xBFA5, n)) { + return 'J'; + } + + if (In(0xBFA6, 0xC0AB, n)) { + return 'K'; + } + + if (In(0xC0AC, 0xC2E7, n)) { + return 'L'; + } + + if (In(0xC2E8, 0xC4C2, n)) { + return 'M'; + } + + if (In(0xC4C3, 0xC5B5, n)) { + return 'N'; + } + + if (In(0xC5B6, 0xC5BD, n)) { + return 'O'; + } + + if (In(0xC5BE, 0xC6D9, n)) { + return 'P'; + } + + if (In(0xC6DA, 0xC8BA, n)) { + return 'Q'; + } + + if (In(0xC8BB, 0xC8F5, n)) { + return 'R'; + } + + if (In(0xC8F6, 0xCBF0, n)) { + return 'S'; + } + + if (In(0xCBFA, 0xCDD9, n)) { + return 'T'; + } + + if (In(0xCDDA, 0xCEF3, n)) { + return 'W'; + } + + if (In(0xCEF4, 0xD1B8, n)) { + return 'X'; + } + + if (In(0xD1B9, 0xD4D0, n)) { + return 'Y'; + } + + if (In(0xD4D1, 0xD7F9, n)) { + return 'Z'; + } + + if (In(0x00, 0x7f, n)) { + return n; + } + + return '\0'; +} + +QString UkuiChineseLetter::getFirstLetter(const QString &src) +{ + // wchar_t wchr = 0; + // QString firstLetter; + // if(src.size() > 0) + // { + // QString str = src.at(0); + // QTextCodec* pCodec = QTextCodec::codecForName("gb2312"); + // if(!pCodec) return QChar(' '); + // QByteArray arr = pCodec->fromUnicode(str); + // if(arr.size() == 1) + // { + // wchr = arr.at(0) & 0xff; + // } + // else if(arr.size() == 2) + // { + // wchr = (arr.at(0) & 0xff) << 8; + // wchr |= (arr.at(1) & 0xff); + // } + // else + // { + //// qDebug() << "unknown word"; + // } + // char c = Convert(wchr); + // if(c != 0) + // { + // firstLetter.append(c); + // } + // } + QString appnamePy = getPinyins(src); + + if (!appnamePy.isEmpty()) { + return QString(appnamePy.at(0)); + } else { + return QString(); + } +} + +QString UkuiChineseLetter::getFirstLetters(const QString &src) +{ + QString firstLetters; + + for (int i = 0; i < src.length(); i++) { + QString str = src.at(i); + QTextCodec *pCodec = QTextCodec::codecForName("gb2312"); + + if (!pCodec) { + return QChar(' '); + } + + QByteArray arr = pCodec->fromUnicode(str); + wchar_t wchr = 0; + + if (arr.size() == 1) { + wchr = arr.at(0) & 0xff; + } else if (arr.size() == 2) { + wchr = (arr.at(0) & 0xff) << 8; + wchr |= (arr.at(1) & 0xff); + } else { + //qDebug() << "unknown word"; + } + + char c = Convert(wchr); + + if (c != 0) { + firstLetters.append(c); + } + } + + return firstLetters; +} + +QString UkuiChineseLetter::getFirstLettersAll(const QString &src) +{ + QString pinyins; + + for (int i = 0; i < src.length(); i++) { + QString str = src.at(i); + QTextCodec *pCodec = QTextCodec::codecForName("gb2312"); + + if (!pCodec) { + return QChar(' '); + } + + QByteArray arr = pCodec->fromUnicode(str); + unsigned char high = 0; + unsigned char low = 0; + int code = 0; + + if (arr.size() == 1) { + high = 0; + low = arr.at(0) & 0xff; + } else if (arr.size() == 2) { + high = arr.at(0) & 0xff; + low = arr.at(1) & 0xff; + } + + if (high < 0xa1 || low < 0xa1) { + continue; + } else { + code = (high - 0xa0) * 100 + low - 0xa0; + } + + pinyins += getPinyin(code).at(0); + } + + return pinyins; +} + + +QString UkuiChineseLetter::getPinyins(const QString &text) +{ + QString pinyins; + + for (int i = 0; i < text.length(); i++) { + QChar c = text.at(i); + + if ((c >= 0 && c <= 127)) { + pinyins += c.toUpper(); + continue; + } + + QString str = text.at(i); + QTextCodec *pCodec = QTextCodec::codecForName("gb2312"); + + if (!pCodec) { + return QChar(' '); + } + + QByteArray arr = pCodec->fromUnicode(str); + unsigned char high = 0; + unsigned char low = 0; + int code = 0; + + if (arr.size() == 1) { + high = 0; + low = arr.at(0) & 0xff; + } else if (arr.size() == 2) { + high = arr.at(0) & 0xff; + low = arr.at(1) & 0xff; + } + + if (high < 0xa1 || low < 0xa1) { + continue; + } else { + code = (high - 0xa0) * 100 + low - 0xa0; + } + + pinyins += getPinyin(code); + } + + return pinyins; +} + + +QString UkuiChineseLetter::getPinyin(int code)//此方法可以获取所有汉字的拼音 +{ + QString pinyin; + + switch (code) { + case 6325: + case 6436: + case 7571: + case 7925: + pinyin = "A"; + break; + + case 6263: + case 6440: + case 7040: + case 7208: + case 7451: + case 7733: + case 7945: + case 8616: + pinyin = "AI"; + break; + + case 5847: + case 5991: + case 6278: + case 6577: + case 6654: + case 7281: + case 7907: + case 8038: + case 8786: + pinyin = "AN"; + break; + pinyin = "ANG"; + break; + + case 5974: + case 6254: + case 6427: + case 6514: + case 6658: + case 6959: + case 7033: + case 7081: + case 7365: + case 8190: + case 8292: + case 8643: + case 8701: + case 8773: + pinyin = "AO"; + break; + + case 6056: + case 6135: + case 6517: + case 7857: + case 8446: + case 8649: + case 8741: + pinyin = "BA"; + break; + + case 6267: + case 6334: + case 7494: + pinyin = "BAI"; + break; + + case 5870: + case 5964: + case 7851: + case 8103: + case 8113: + case 8418: + pinyin = "BAN"; + break; + + case 6182: + case 6826: + pinyin = "BANG"; + break; + + case 6165: + case 7063: + case 7650: + case 8017: + case 8157: + case 8532: + case 8621: + pinyin = "BAO"; + break; + + case 5635: + case 5873: + case 5893: + case 5993: + case 6141: + case 6703: + case 7753: + case 8039: + case 8156: + case 8645: + case 8725: + pinyin = "BEI"; + break; + + case 5946: + case 5948: + case 7458: + case 7928: + pinyin = "BEN"; + break; + + case 6452: + case 7420: + pinyin = "BENG"; + break; + + case 5616: + case 5734: + case 6074: + case 6109: + case 6221: + case 6333: + case 6357: + case 6589: + case 6656: + case 6725: + case 6868: + case 6908: + case 6986: + case 6994: + case 7030: + case 7052: + case 7221: + case 7815: + case 7873: + case 7985: + case 8152: + case 8357: + case 8375: + case 8387: + case 8416: + case 8437: + case 8547: + case 8734: + pinyin = "BI"; + break; + + case 5650: + case 5945: + case 6048: + case 6677: + case 6774: + case 7134: + case 7614: + case 7652: + case 7730: + case 7760: + case 8125: + case 8159: + case 8289: + case 8354: + case 8693: + pinyin = "BIAN"; + break; + + case 7027: + case 7084: + case 7609: + case 7613: + case 7958: + case 7980: + case 8106: + case 8149: + case 8707: + case 8752: + pinyin = "BIAO"; + break; + + case 8531: + pinyin = "BIE"; + break; + + case 5747: + case 6557: + case 7145: + case 7167: + case 7336: + case 7375: + case 7587: + case 7957: + case 8738: + case 8762: + pinyin = "BIN"; + break; + + case 5787: + case 5891: + case 6280: + pinyin = "BING"; + break; + + case 5781: + case 6403: + case 6636: + case 7362: + case 7502: + case 7771: + case 7864: + case 8030: + case 8404: + case 8543: + case 8559: + pinyin = "BO"; + break; + + case 6318: + case 6945: + case 7419: + case 7446: + case 7848: + case 7863: + case 8519: + pinyin = "BU"; + break; + + case 6474: + case 7769: + pinyin = "CA"; + break; + pinyin = "CAI"; + break; + + case 6978: + case 7078: + case 7218: + case 8451: + case 8785: + pinyin = "CAN"; + break; + + case 5687: + pinyin = "CANG"; + break; + + case 6448: + case 6878: + case 8309: + case 8429: + pinyin = "CAO"; + break; + + case 6692: + pinyin = "CE"; + break; + + case 6515: + case 6825: + pinyin = "CEN"; + break; + + case 6465: + pinyin = "CENG"; + break; + + case 6639: + case 6766: + case 7017: + case 7230: + case 7311: + case 7322: + case 7363: + case 7942: + case 7979: + case 8135: + pinyin = "CHA"; + break; + + case 5713: + case 7846: + case 8091: + case 8218: + pinyin = "CHAI"; + break; + + case 5770: + case 5838: + case 6159: + case 6667: + case 6893: + case 6904: + case 6981: + case 7031: + case 7086: + case 7472: + case 7688: + case 7966: + case 8324: + case 8580: + pinyin = "CHAN"; + break; + + case 5686: + case 5943: + case 6041: + case 6137: + case 6660: + case 6568: + case 6749: + case 7029: + case 7047: + case 7438: + case 7509: + case 8680: + pinyin = "CHANG"; + break; + + case 6687: + case 7443: + case 8173: + pinyin = "CHAO"; + break; + + case 5969: + case 7726: + pinyin = "CHE"; + break; + + case 5840: + case 5863: + case 6251: + case 6433: + case 6923: + case 7201: + case 7320: + case 7755: + case 8619: + pinyin = "CHEN"; + break; + + case 5609: + case 5984: + case 7239: + case 7263: + case 7583: + case 7810: + case 7881: + case 7905: + case 8146: + case 8241: + case 8508: + pinyin = "CHENG"; + break; + + case 5749: + case 6015: + case 6061: + case 6319: + case 6374: + case 6420: + case 6445: + case 6633: + case 7042: + case 7523: + case 7787: + case 8023: + case 8101: + case 8161: + case 8231: + case 8304: + case 8355: + case 8388: + case 8489: + case 8556: + case 8746: + pinyin = "CHI"; + break; + + case 6091: + case 6671: + case 6731: + case 8409: + case 8430: + pinyin = "CHONG"; + break; + + case 5717: + case 6492: + case 6716: + case 8112: + case 8637: + pinyin = "CHOU"; + break; + + case 5601: + case 5927: + case 6680: + case 6732: + case 7109: + case 7238: + case 7290: + case 7343: + case 8150: + case 8260: + case 8573: + case 8777: + pinyin = "CHU"; + break; + + case 6285: + case 6408: + case 7590: + case 8563: + pinyin = "CHUAI"; + break; + + case 6622: + case 6955: + case 7516: + case 7843: + case 8413: + pinyin = "CHUAN"; + break; + + case 6675: + pinyin = "CHUANG"; + break; + + case 5879: + case 7302: + case 7319: + pinyin = "CHUI"; + break; + + case 6127: + case 8040: + case 8277: + pinyin = "CHUN"; + break; + + case 7401: + case 8554: + case 8626: + pinyin = "CHUO"; + break; + pinyin = "CI"; + break; + + case 6075: + case 6358: + case 7684: + case 8043: + case 8457: + pinyin = "4337 伺"; + break; + + case 6042: + case 6840: + case 7085: + case 7193: + case 7214: + case 7240: + pinyin = "CONG"; + break; + + case 7308: + case 7403: + case 7577: + pinyin = "COU"; + break; + + case 6180: + case 6562: + case 6607: + case 7367: + case 8501: + case 8530: + case 8577: + pinyin = "CU"; + break; + + case 5764: + case 6305: + case 7664: + case 7973: + pinyin = "CUAN"; + break; + + case 6718: + case 6145: + case 6393: + case 7213: + case 7333: + case 7505: + case 8631: + pinyin = "CUI"; + break; + + case 6666: + case 8169: + pinyin = "CUN"; + break; + + case 5640: + case 6547: + case 7566: + case 7917: + case 7983: + case 8078: + case 8526: + case 8567: + pinyin = "CUO"; + break; + + case 6239: + case 6353: + case 6410: + case 6682: + case 7007: + case 8155: + case 8346: + case 8716: + case 8718: + pinyin = "DA"; + break; + + case 6004: + case 6316: + case 6523: + case 6942: + case 7110: + case 7173: + case 8776: + pinyin = "DAI"; + break; + + case 5757: + case 6144: + case 6402: + case 7373: + case 7470: + case 7781: + case 8067: + case 8087: + case 8185: + case 8376: + pinyin = "DAN"; + break; + + case 5852: + case 5942: + case 6148: + case 6920: + case 7724: + case 7885: + case 8141: + pinyin = "DANG"; + break; + + case 6322: + case 6665: + case 7514: + case 8478: + pinyin = "DAO"; + break; + + case 7929: + pinyin = "DE"; + break; + + case 6466: + case 6556: + case 7413: + case 7767: + case 7975: + case 8403: + pinyin = "DENG"; + break; + + case 5621: + case 5765: + case 5814: + case 5848: + case 5901: + case 5970: + case 6122: + case 6454: + case 7023: + case 7116: + case 7260: + case 7306: + case 7475: + case 7738: + case 7758: + case 7791: + case 7965: + case 8438: + case 8730: + pinyin = "DI"; + break; + + case 6439: + pinyin = "DIA"; + break; + + case 5871: + case 5967: + case 6559: + case 7172: + case 7868: + case 8116: + case 8118: + case 8401: + case 8558: + pinyin = "DIAN"; + break; + + case 7886: + case 8585: + case 8684: + pinyin = "DIAO"; + break; + + case 5976: + case 6006: + case 6273: + case 6409: + case 7526: + case 8012: + case 8183: + case 8562: + case 8688: + pinyin = "DIE"; + break; + + case 5674: + case 6404: + case 7164: + case 7575: + case 7754: + case 7814: + case 8059: + case 8184: + case 8490: + pinyin = "DING"; + break; + + case 7891: + pinyin = "DIU"; + break; + + case 5977: + case 6343: + case 6520: + case 6528: + case 7517: + case 7543: + case 7556: + case 7747: + case 8020: + pinyin = "DONG"; + break; + + case 6190: + case 8128: + case 8229: + case 8391: + pinyin = "DOU"; + break; + + case 6022: + case 6429: + case 6834: + case 7292: + case 7525: + case 8328: + case 8338: + case 8739: + case 8782: + pinyin = "DU"; + break; + + case 7318: + case 7649: + case 8393: + pinyin = "DUAN"; + break; + + case 7701: + case 7713: + case 7752: + pinyin = "DUI"; + break; + + case 6771: + case 7632: + case 7727: + case 7766: + case 7779: + case 7970: + case 8527: + pinyin = "DUN"; + break; + + case 6345: + case 6365: + case 6785: + case 7122: + case 7876: + case 8154: + case 8566: + pinyin = "DUO"; + break; + + case 5612: + case 5832: + case 5844: + case 5949: + case 6035: + case 6113: + case 6164: + case 6332: + case 6721: + case 6977: + case 7025: + case 7378: + case 7581: + case 7916: + case 7941: + case 8042: + case 8206: + case 8689: + pinyin = "E"; + break; + + case 6176: + case 6284: + pinyin = "EN"; + break; + + case 5706: + case 6939: + case 7177: + case 7879: + case 8025: + case 8660: + pinyin = "ER"; + break; + + case 5950: + case 7732: + pinyin = "FA"; + break; + + case 6212: + case 6232: + case 6506: + case 7283: + case 7660: + case 7818: + case 8576: + pinyin = "FAN"; + break; + + case 5890: + case 7242: + case 7853: + case 8419: + case 8648: + pinyin = "FANG"; + break; + + case 6032: + case 6584: + case 6713: + case 6839: + case 6990: + case 7119: + case 7328: + case 7572: + case 7619: + case 7673: + case 7948: + case 8082: + case 8267: + case 8385: + case 8468: + case 8613: + case 8678: + pinyin = "FEI"; + break; + + case 5739: + case 6915: + case 7291: + case 8687: + case 8787: + pinyin = "FEN"; + break; + + case 5726: + case 5926: + case 6155: + case 6384: + case 6767: + case 7731: + pinyin = "FENG"; + break; + pinyin = "FO"; + break; + + case 8330: + pinyin = "FOU"; + break; + + case 5775: + case 5776: + case 5914: + case 6029: + case 6062: + case 6119: + case 6142: + case 6252: + case 6327: + case 6505: + case 6686: + case 6870: + case 6985: + case 7058: + case 7066: + case 7106: + case 7108: + case 7285: + case 7471: + case 7680: + case 7741: + case 7774: + case 7775: + case 7823: + case 7991: + case 8005: + case 8222: + case 8261: + case 8280: + case 8283: + case 8479: + case 8535: + case 8538: + case 8654: + case 8691: + pinyin = "FU"; + break; + + case 6246: + case 7056: + case 7057: + case 7424: + case 7837: + pinyin = " GA"; + break; + + case 5604: + case 5875: + case 5982: + case 7414: + case 7464: + pinyin = "GAI"; + break; + + case 5965: + case 6053: + case 6247: + case 6306: + case 6779: + case 6838: + case 6887: + case 7104: + case 7347: + case 7426: + case 7723: + case 8065: + case 8491: + pinyin = "GAN"; + break; + + case 7716: + case 7824: + case 8364: + pinyin = "GANG"; + break; + + case 5626: + case 5830: + case 5912: + case 6227: + case 7141: + case 7332: + case 7334: + case 7429: + case 7915: + pinyin = "GAO"; + break; + + case 5610: + case 5678: + case 5933: + case 5957: + case 6010: + case 6435: + case 7092: + case 7501: + case 7585: + case 7749: + case 7951: + case 8143: + case 8220: + case 8420: + case 8732: + pinyin = "GE"; + break; + pinyin = "GEI"; + break; + + case 5608: + case 6102: + case 6371: + case 8462: + pinyin = "GEN"; + break; + + case 6376: + case 6657: + case 7114: + case 8665: + pinyin = "GENG"; + break; + + case 7178: + case 7537: + case 8228: + case 8601: + pinyin = "GONG"; + break; + + case 5694: + case 5824: + case 6524: + case 6960: + case 7037: + case 7135: + case 7259: + case 7477: + case 7616: + case 8349: + case 8384: + case 8724: + pinyin = "GOU"; + break; + + case 5637: + case 5812: + case 6152: + case 6536: + case 6773: + case 7284: + case 7379: + case 7484: + case 7486: + case 7591: + case 7617: + case 7813: + case 7825: + case 7860: + case 7932: + case 8019: + case 8083: + case 8233: + case 8494: + case 8593: + case 8681: + case 8729: + pinyin = "GU"; + break; + + case 5652: + case 5820: + case 6341: + case 7273: + case 7550: + case 8027: + pinyin = "GUA"; + break; + pinyin = "GUAI"; + break; + + case 5736: + case 6124: + case 6272: + case 6842: + case 7834: + case 8057: + case 8170: + case 8704: + pinyin = "GUAN"; + break; + + case 6359: + case 6578: + case 7270: + case 7555: + pinyin = "GUANG"; + break; + + case 5648: + case 5659: + case 6649: + case 7003: + case 7277: + case 7433: + case 7448: + case 8007: + case 8394: + case 8657: + case 8712: + pinyin = "GUI"; + break; + + case 5782: + case 7121: + case 7762: + case 8671: + pinyin = "GUN"; + break; + + case 5769: + case 6266: + case 6335: + case 6494: + case 6538: + case 6603: + case 7304: + case 7529: + case 8188: + case 8268: + case 8269: + pinyin = "GUO"; + break; + + case 7894: + pinyin = "HA"; + break; + + case 6443: + case 7560: + case 8516: + pinyin = "HAI"; + break; + + case 5885: + case 6153: + case 6294: + case 6759: + case 6911: + case 7447: + case 7642: + case 8192: + case 8205: + case 8232: + case 8793: + pinyin = "HAN"; + break; + + case 6776: + case 7112: + case 8194: + pinyin = "HANG"; + break; + + case 6179: + case 6222: + case 6438: + case 6467: + case 6909: + case 6916: + case 7427: + case 8009: + case 8211: + case 8226: + pinyin = "HAO"; + break; + + case 5813: + case 5932: + case 5954: + case 6432: + case 6756: + case 7434: + case 7833: + case 8202: + case 8234: + case 8471: + pinyin = "HE"; + break; + pinyin = "HEI"; + break; + pinyin = "HEN"; + break; + + case 6231: + case 7181: + case 7276: + pinyin = "HENG"; + break; + + case 5768: + case 5774: + case 5807: + case 6106: + case 6214: + case 6216: + case 6740: + case 6792: + pinyin = "HONG"; + break; + + case 6009: + case 6565: + case 6943: + case 8090: + case 8383: + case 8455: + case 8655: + case 8731: + pinyin = "HOU"; + break; + + case 5792: + case 6392: + case 6481: + case 6518: + case 6609: + case 6679: + case 6717: + case 6816: + case 6879: + case 7190: + case 7346: + case 7385: + case 7618: + case 7635: + case 7646: + case 7670: + case 7672: + case 7679: + case 8013: + case 8032: + case 8041: + case 8055: + case 8343: + case 8513: + case 8590: + pinyin = "HU"; + break; + + case 7072: + case 7275: + case 7725: + case 7892: + pinyin = "HUA"; + break; + + case 8555: + pinyin = "HUAI"; + break; + + case 5928: + case 6140: + case 6307: + case 6487: + case 6621: + case 6801: + case 6829: + case 6881: + case 6930: + case 6953: + case 7157: + case 7944: + case 8673: + case 8763: + pinyin = "HUAN"; + break; + + case 5882: + case 6569: + case 6850: + case 6874: + case 6956: + case 7211: + case 7533: + case 8105: + case 8308: + case 8382: + case 8692: + pinyin = "HUANG"; + break; + + case 5822: + case 6078: + case 6086: + case 6205: + case 6352: + case 6360: + case 6425: + case 6736: + case 6807: + case 6811: + case 6971: + case 7132: + case 7185: + case 7445: + case 7703: + case 8219: + case 8319: + case 8766: + pinyin = "HUI"; + break; + + case 5827: + case 6638: + case 6752: + case 6867: + pinyin = "HUN"; + break; + + case 5669: + case 6229: + case 6311: + case 6475: + case 6623: + case 7856: + case 7933: + case 7976: + case 8175: + case 8322: + pinyin = "HUO"; + break; + + case 5629: + case 5632: + case 5662: + case 5705: + case 5742: + case 5952: + case 6024: + case 6033: + case 6193: + case 6210: + case 6265: + case 6320: + case 6350: + case 6383: + case 6507: + case 6553: + case 6809: + case 6976: + case 7087: + case 7160: + case 7165: + case 7314: + case 7374: + case 7410: + case 7411: + case 7469: + case 7473: + case 7487: + case 7620: + case 7722: + case 7831: + case 7990: + case 8002: + case 8104: + case 8217: + case 8337: + case 8339: + case 8463: + case 8550: + case 8611: + case 8661: + case 8674: + case 8757: + case 8768: + pinyin = "JI"; + break; + + case 5704: + case 5903: + case 6171: + case 6521: + case 6804: + case 6940: + case 7176: + case 7409: + case 7546: + case 7702: + case 7882: + case 7956: + case 8072: + case 8142: + case 8244: + case 8353: + case 8434: + case 8542: + pinyin = "JIA"; + break; + + case 5752: + case 5841: + case 5857: + case 6149: + case 6183: + case 6286: + case 6853: + case 6931: + case 6932: + case 7144: + case 7237: + case 7305: + case 7407: + case 7415: + case 7480: + case 7489: + case 7506: + case 7576: + case 7790: + case 7921: + case 8047: + case 8148: + case 8340: + case 8469: + case 8534: + case 8561: + case 8668: + case 8721: + pinyin = "JIAN"; + break; + + case 6092: + case 6814: + case 7113: + case 7154: + case 7481: + case 7768: + case 8180: + case 8461: + case 8488: + pinyin = "JIANG"; + break; + + case 5714: + case 5753: + case 6020: + case 6090: + case 6256: + case 6461: + case 6572: + case 7015: + case 7524: + case 8008: + case 8052: + case 8252: + case 8520: + case 8551: + case 8662: + pinyin = "JIAO"; + break; + + case 5806: + case 5821: + case 6255: + case 6414: + case 7028: + case 7061: + case 7278: + case 7757: + case 8060: + case 8201: + case 8227: + case 8441: + case 8658: + case 8726: + pinyin = "JIE"; + break; + + case 5865: + case 6103: + case 6132: + case 6468: + case 6643: + case 6659: + case 7138: + case 7210: + case 7340: + case 7465: + case 7478: + case 8138: + pinyin = "JIN"; + break; + + case 5751: + case 5869: + case 6128: + case 6616: + case 6729: + case 6794: + case 6941: + case 6982: + case 7026: + case 7534: + case 7554: + case 7570: + case 7626: + pinyin = "JIANG"; + break; + + case 6936: + case 7671: + pinyin = "JIONG"; + break; + + case 5754: + case 6417: + case 6746: + case 7249: + case 7274: + case 8015: + case 8053: + case 8481: + case 8761: + pinyin = "JIU"; + break; + + case 5738: + case 5810: + case 6036: + case 6058: + case 6076: + case 6268: + case 6965: + case 6980: + case 7202: + case 7307: + case 7316: + case 7323: + case 7357: + case 7381: + case 7488: + case 7611: + case 7850: + case 7924: + case 8022: + case 8132: + case 8153: + case 8482: + case 8522: + case 8565: + case 8620: + case 8634: + case 8722: + pinyin = "JU"; + break; + + case 5918: + case 6590: + case 6824: + case 7280: + case 7835: + case 7935: + case 7952: + case 8633: + pinyin = "JUAN"; + break; + + case 5642: + case 5667: + case 5860: + case 5939: + case 6207: + case 6421: + case 6457: + case 6469: + case 6540: + case 6617: + case 7062: + case 7169: + case 7286: + case 7351: + case 7663: + case 7967: + case 8574: + case 8591: + pinyin = "JUE"; + break; + + case 6260: + case 8168: + case 8362: + case 8769: + pinyin = "JUN"; + break; + + case 5671: + case 6339: + case 7544: + pinyin = "KA"; + break; + + case 5660: + case 5978: + case 6160: + case 6673: + case 6693: + case 7888: + case 7920: + case 7939: + pinyin = "KAI"; + break; + + case 5709: + case 6108: + case 7412: + case 7772: + case 7811: + pinyin = "KAN"; + break; + + case 5688: + case 6742: + case 7854: + pinyin = "KANG"; + break; + + case 6974: + case 7264: + case 7491: + case 7877: + pinyin = "KAO"; + break; + + case 6430: + case 6519: + case 6701: + case 6859: + case 7076: + case 7128: + case 7170: + case 7380: + case 7520: + case 7807: + case 7861: + case 7930: + case 7993: + case 8066: + case 8129: + case 8204: + case 8282: + case 8733: + pinyin = "KE"; + break; + + case 8144: + pinyin = "KEN"; + break; + + case 7912: + pinyin = "KENG"; + break; + + case 5737: + case 6539: + case 8377: + pinyin = "KONG"; + break; + + case 6050: + case 6202: + case 6321: + case 7778: + case 8356: + pinyin = "KOU"; + break; + + case 5658: + case 6005: + case 6423: + case 7111: + case 8728: + pinyin = "KU"; + break; + + case 5708: + pinyin = "KUA"; + break; + + case 5665: + case 5906: + case 6364: + case 6586: + case 7558: + pinyin = "KUAI"; + break; + + case 8737: + pinyin = "KUAN"; + break; + + case 5818: + case 5831: + case 5887: + case 5959: + case 6237: + case 6349: + case 7094: + case 7460: + pinyin = "KUANG"; + break; + + case 5624: + case 5649: + case 5771: + case 6162: + case 6281: + case 6413: + case 6416: + case 6720: + case 6951: + case 7450: + case 7805: + case 8606: + case 8743: + pinyin = "KUI"; + break; + + case 6204: + case 6245: + case 6458: + case 6618: + case 6928: + case 7152: + case 7841: + case 8051: + pinyin = "LIAO"; + break; + + case 5793: + case 5988: + case 6270: + case 6354: + case 6803: + case 8483: + case 8581: + case 8764: + pinyin = "LIE"; + break; + + case 6194: + case 6388: + case 6555: + case 6662: + case 6733: + case 6964: + case 7361: + case 7405: + case 7602: + case 7812: + case 8452: + case 8579: + case 8775: + pinyin = "LIN"; + break; + + case 5925: + case 6063: + case 6342: + case 6482: + case 6786: + case 7117: + case 7258: + case 7289: + case 7418: + case 8186: + case 8240: + case 8465: + case 8676: + pinyin = "LING"; + break; + + case 6815: + case 6962: + case 7082: + case 7124: + case 7628: + case 7654: + case 7919: + case 7954: + case 8050: + case 8644: + pinyin = "LIU"; + break; + + case 5966: + case 6055: + case 6781: + case 7171: + case 7248: + case 7542: + case 7735: + case 8110: + pinyin = "LONG"; + break; + + case 5745: + case 6168: + case 6422: + case 6548: + case 7946: + case 8092: + case 8179: + case 8287: + case 8735: + pinyin = "LOU"; + break; + + case 6744: + case 7321: + case 7586: + case 7918: + case 7989: + case 8158: + pinyin = "Lü"; + break; + + case 5968: + case 6303: + case 6464: + case 6782: + case 6843: + case 6885: + case 6954: + case 7220: + case 7251: + case 7354: + case 7391: + case 7404: + case 7510: + case 7545: + case 7969: + case 8021: + case 8056: + case 8392: + case 8421: + case 8652: + pinyin = "LU"; + break; + + case 5785: + case 7014: + case 7279: + case 8029: + case 8639: + pinyin = "LUAN"; + break; + pinyin = "LǖE"; + break; + pinyin = "LUN"; + break; + + case 5732: + case 5789: + case 6093: + case 6259: + case 6291: + case 6604: + case 6788: + case 6880: + case 7183: + case 7301: + case 7565: + case 7961: + case 8107: + case 8635: + pinyin = "LUO"; + break; + + case 6328: + pinyin = "M"; + break; + + case 6373: + case 6579: + case 7054: + case 7231: + case 8301: + pinyin = "MA"; + break; + + case 5929: + case 6104: + case 8618: + pinyin = "MAI"; + break; + + case 6012: + case 6503: + case 7147: + case 7655: + case 7960: + case 8209: + case 8293: + case 8709: + case 8720: + pinyin = "MAN"; + break; + + case 5888: + case 6861: + case 7743: + case 8294: + pinyin = "MANG"; + break; + + case 5783: + case 6066: + case 6525: + case 6787: + case 7203: + case 7436: + case 7483: + case 7503: + case 7624: + case 7714: + case 7806: + case 8317: + case 8754: + pinyin = "MAO"; + break; + + case 6114: + case 6550: + case 6613: + case 6828: + case 6856: + case 7325: + case 7949: + case 8044: + case 8139: + case 8740: + pinyin = "MEI"; + break; + + case 6249: + case 7643: + case 7715: + case 7845: + pinyin = "MEN"; + break; + + case 5934: + case 6189: + case 6211: + case 6734: + case 7592: + case 7770: + case 8221: + case 8276: + case 8323: + case 8427: + case 8431: + pinyin = "MENG"; + break; + + case 5634: + case 5855: + case 6234: + case 6368: + case 6455: + case 6608: + case 6772: + case 6921: + case 6984: + case 7563: + case 7682: + case 8445: + case 8767: + case 8771: + pinyin = "MI"; + break; + + case 6770: + case 6837: + case 6847: + case 7579: + case 7777: + pinyin = "MIAN"; + break; + + case 6387: + case 6967: + case 7131: + case 7149: + case 7234: + case 7721: + case 7780: + case 8037: + pinyin = "MIAO"; + break; + + case 5631: + case 6367: + case 8326: + case 8390: + pinyin = "MIE"; + break; + + case 6069: + case 6526: + case 6741: + case 6793: + case 7137: + case 7168: + case 7175: + case 7710: + case 8710: + case 8628: + pinyin = "MIN"; + break; + + case 5804: + case 6088: + case 6873: + case 7452: + case 7808: + case 8504: + pinyin = "MING"; + break; + pinyin = "MIU"; + break; + + case 5851: + case 6052: + case 6175: + case 6641: + case 7038: + case 7366: + case 7950: + case 7987: + case 8102: + case 8182: + case 8586: + case 8588: + case 8765: + pinyin = "MO"; + break; + + case 5716: + case 6372: + case 7788: + case 8254: + case 8290: + case 8642: + pinyin = "MOU"; + break; + + case 5679: + case 5973: + case 6057: + case 6769: + case 7504: + case 7866: + pinyin = "MU"; + break; + + case 6437: + pinyin = "N"; + break; + + case 6264: + case 7539: + case 7953: + case 8136: + pinyin = "NA"; + break; + + case 5630: + case 6021: + case 6133: + case 7245: + pinyin = "NAI"; + break; + + case 6411: + case 6478: + case 6479: + case 7310: + case 7578: + case 8279: + case 8486: + pinyin = "NAN"; + break; + + case 6313: + case 6476: + case 6646: + case 7457: + pinyin = "NANG"; + break; + + case 5611: + case 5981: + case 6346: + case 6614: + case 7207: + case 7748: + case 7883: + case 8245: + pinyin = "NAO"; + break; + + case 5811: + pinyin = "NE"; + break; + pinyin = "NEI"; + break; + + case 7705: + pinyin = "NEN"; + break; + pinyin = "NENG"; + break; + + case 5703: + case 5972: + case 6605: + case 6685: + case 7439: + case 7627: + case 7711: + case 7794: + case 7874: + case 8682: + pinyin = "NI"; + break; + + case 5605: + case 5994: + case 7393: + case 8004: + case 8651: + case 8683: + pinyin = "NIAN"; + break; + pinyin = "NIANG"; + break; + + case 6064: + case 7053: + case 7569: + case 8433: + pinyin = "NIAO"; + break; + + case 5877: + case 6233: + case 6431: + case 8208: + case 8411: + case 8570: + pinyin = "NIE"; + break; + pinyin = "NIN"; + break; + + case 5690: + case 6344: + case 6924: + case 8187: + pinyin = "NING"; + break; + + case 6580: + case 6678: + case 7004: + pinyin = "NIU"; + break; + + case 5715: + case 6370: + pinyin = "NONG"; + break; + + case 8181: + pinyin = "NOU"; + break; + + case 6983: + case 7032: + case 7059: + case 7069: + pinyin = "NU"; + break; + + case 7704: + case 7847: + case 8412: + pinyin = "Nǖ"; + break; + pinyin = "NUAN"; + break; + pinyin = "NUE"; + break; + + case 5748: + case 6289: + case 6386: + case 7927: + pinyin = "NUO"; + break; + + case 6424: + case 6462: + pinyin = "O"; + break; + + case 5809: + case 6670: + case 7417: + case 8178: + pinyin = "OU"; + break; + + case 6166: + case 7243: + case 8365: + pinyin = "PA"; + break; + + case 5729: + case 6169: + case 6363: + pinyin = "PAI"; + break; + + case 6761: + case 6790: + case 8140: + case 8165: + case 8320: + case 8571: + pinyin = "PAN"; + break; + + case 6561: + case 6872: + case 6944: + case 8306: + pinyin = "PANG"; + break; + + case 6243: + case 6583: + case 6650: + case 7567: + case 8069: + pinyin = "PAO"; + break; + + case 6446: + case 6490: + case 7623: + case 7934: + case 8512: + case 8612: + pinyin = "PEI"; + break; + + case 6852: + pinyin = "PEN"; + break; + + case 6001: + case 6456: + case 6681: + case 8318: + pinyin = "PENG"; + break; + + case 5607: + case 5682: + case 5880: + case 5892: + case 5915: + case 5960: + case 6017: + case 6037: + case 6308: + case 6472: + case 6647: + case 6836: + case 7039: + case 7102: + case 7233: + case 7422: + case 7802: + case 7828: + case 7875: + case 8117: + case 8166: + case 8223: + case 8271: + case 8589: + pinyin = "PI"; + break; + + case 5850: + case 7073: + case 7490: + case 7561: + case 8470: + case 8568: + pinyin = "PIAN"; + break; + + case 5666: + case 6449: + case 7046: + case 7146: + case 7372: + case 7809: + case 8310: + pinyin = "PIAO"; + break; + + case 6054: + case 7513: + pinyin = "PIE"; + break; + + case 7041: + case 6253: + case 7016: + case 7315: + case 7482: + case 8213: + pinyin = "PIN"; + break; + + case 5723: + case 7019: + case 7250: + case 8650: + pinyin = "PING"; + break; + + case 5647: + case 5922: + case 7174: + case 7839: + case 7862: + case 8011: + case 8345: + pinyin = "PO"; + break; + + case 5786: + case 6269: + pinyin = "POU"; + break; + + case 5773: + case 6459: + case 6863: + case 6907: + case 7217: + case 7511: + case 7968: + case 7972: + case 8575: + pinyin = "PU"; + break; + + case 5633: + case 5725: + case 5963: + case 6027: + case 6046: + case 6089: + case 6129: + case 6134: + case 6161: + case 6213: + case 6366: + case 6450: + case 6508: + case 6510: + case 6764: + case 6831: + case 7075: + case 7118: + case 7187: + case 7189: + case 7229: + case 7271: + case 7342: + case 7440: + case 7605: + case 7687: + case 7712: + case 7751: + case 8193: + case 8251: + case 8264: + case 8475: + case 8476: + case 8572: + case 8702: + case 8772: + pinyin = "QI"; + break; + + case 6154: + case 8736: + pinyin = "QIA"; + break; + + case 5727: + case 5761: + case 5868: + case 6023: + case 6045: + case 6071: + case 6271: + case 6509: + case 6705: + case 6727: + case 6925: + case 6926: + case 6929: + case 7155: + case 7293: + case 7541: + case 7709: + case 7852: + case 8215: + case 8373: + pinyin = "QIAN"; + break; + + case 6762: + case 7045: + case 7341: + case 7408: + case 7633: + case 7926: + case 7947: + case 7974: + case 8163: + case 8262: + case 8439: + case 8536: + pinyin = "QIANG"; + break; + + case 5668: + case 5829: + case 5859: + case 6081: + case 6529: + case 6724: + case 6730: + case 7352: + case 7745: + case 8546: + case 8719: + pinyin = "QIAO"; + break; + + case 5907: + case 6711: + case 7010: + case 7492: + case 7938: + case 8370: + pinyin = "QIE"; + break; + + case 6043: + case 6276: + case 6336: + case 6426: + case 6463: + case 6858: + case 7353: + case 7923: + case 8291: + case 8432: + pinyin = "QIN"; + break; + + case 6060: + case 6485: + case 7349: + case 7764: + case 8263: + case 8332: + case 8368: + case 8605: + case 8675: + case 8784: + pinyin = "QING"; + break; + + case 5886: + case 6068: + case 8123: + case 8243: + case 8344: + case 8528: + case 8638: + pinyin = "QIONG"; + break; + + case 5720: + case 5947: + case 6576: + case 6848: + case 6947: + case 6957: + case 7317: + case 7468: + case 8216: + case 8239: + case 8288: + case 8435: + case 8460: + case 8690: + case 8792: + pinyin = "QIU"; + break; + + case 5816: + case 5930: + case 6201: + case 6230: + case 6511: + case 6573: + case 6754: + case 7219: + case 7479: + case 7512: + case 7552: + case 7678: + case 7765: + case 8119: + case 8248: + case 8329: + case 8480: + case 8636: + case 8781: + pinyin = "QU"; + break; + + case 5825: + case 6085: + case 6710: + case 7125: + case 7390: + case 7816: + case 7893: + case 8273: + case 8360: + case 8760: + pinyin = "QUAN"; + break; + + case 6755: + case 6758: + case 7708: + pinyin = "QUE"; + break; + + case 6950: + pinyin = "QUN"; + break; + + case 6059: + case 8237: + case 8755: + pinyin = "RAN"; + break; + + case 7692: + case 8006: + pinyin = "RANG"; + break; + + case 6073: + case 7012: + case 7267: + pinyin = "RAO"; + break; + pinyin = "RE"; + break; + + case 5680: + case 6083: + case 6156: + case 6631: + case 7377: + case 7994: + case 8137: + pinyin = "REN"; + break; + pinyin = "RENG"; + break; + pinyin = "RI"; + break; + + case 6541: + case 6585: + case 7337: + case 7532: + case 8278: + pinyin = "RONG"; + break; + + case 8459: + case 8569: + case 8723: + pinyin = "ROU"; + break; + + case 6174: + case 6224: + case 6473: + case 6818: + case 6865: + case 6906: + case 7140: + case 7908: + case 8164: + case 8212: + pinyin = "RU"; + break; + + case 7535: + pinyin = "RUAN"; + break; + + case 6039: + case 6208: + case 7236: + case 7803: + case 8224: + pinyin = "RUI"; + break; + pinyin = "RUN"; + break; + + case 5728: + case 8372: + pinyin = "RUO"; + break; + + case 5606: + case 5677: + case 7493: + case 7559: + case 7610: + pinyin = "SA"; + break; + + case 6471: + pinyin = "SAI"; + break; + + case 6644: + case 7507: + case 8454: + pinyin = "SAN"; + break; + + case 6290: + case 7763: + case 8210: + pinyin = "SANG"; + break; + + case 6003: + case 7150: + case 7156: + case 7593: + case 8094: + case 8694: + pinyin = "SAO"; + break; + pinyin = "SE"; + break; + pinyin = "SEN"; + break; + pinyin = "SENG"; + break; + + case 6394: + case 7606: + case 7901: + case 8080: + case 8436: + case 8614: + case 8672: + pinyin = "SHA"; + break; + + case 8507: + pinyin = "SHAI"; + break; + + case 5663: + case 5808: + case 5923: + case 5979: + case 6047: + case 6890: + case 7009: + case 7051: + case 7083: + case 7594: + case 7844: + case 8062: + case 8321: + case 8414: + case 8539: + case 8713: + pinyin = "SHAN"; + break; + + case 5980: + case 7120: + case 7368: + case 7656: + case 8592: + pinyin = "SHANG"; + break; + + case 5931: + case 6070: + case 6891: + case 7228: + case 8366: + case 8425: + pinyin = "SHAO"; + break; + + case 5639: + case 5760: + case 6606: + case 6860: + case 7608: + case 7820: + case 8774: + pinyin = "SHE"; + break; + + case 5837: + case 6123: + case 6351: + case 6841: + case 7309: + case 7547: + case 7982: + case 8255: + pinyin = "SHEN"; + break; + + case 6551: + case 7441: + case 7782: + case 8347: + pinyin = "SHENG"; + break; + + case 5854: + case 5985: + case 6110: + case 6173: + case 6317: + case 7388: + case 7459: + case 7634: + case 7870: + case 8307: + case 8334: + case 8363: + case 8525: + case 8669: + case 8685: + pinyin = "SHI"; + break; + + case 6587: + case 7123: + case 8428: + pinyin = "SHOU"; + break; + + case 5731: + case 5951: + case 6136: + case 6283: + case 6780: + case 6888: + case 7013: + case 7508: + case 7582: + case 7988: + pinyin = "SHU"; + break; + + case 6407: + pinyin = "SHUA"; + break; + + case 8316: + pinyin = "SHUAI"; + break; + + case 6737: + case 6844: + pinyin = "SHUAN"; + break; + + case 7055: + pinyin = "SHUANG"; + break; + pinyin = "SHUI"; + break; + pinyin = "SHUN"; + break; + + case 6184: + case 6287: + case 6989: + case 7335: + case 7869: + pinyin = "SHUO"; + break; + + case 5643: + case 5778: + case 5944: + case 6348: + case 6765: + case 6784: + case 6889: + case 7006: + case 7065: + case 7133: + case 7675: + case 7940: + case 8024: + case 8174: + case 8247: + case 8351: + pinyin = "SI"; + break; + + case 5801: + case 6131: + case 6534: + case 6552: + case 6676: + case 6704: + case 6833: + case 8121: + pinyin = "SONG"; + break; + + case 5937: + case 6220: + case 6418: + case 6453: + case 6640: + case 6849: + case 7612: + case 7804: + case 7943: + case 8284: + pinyin = "SOU"; + break; + + case 5777: + case 5853: + case 6188: + case 6428: + case 6726: + case 6819: + case 8389: + case 8602: + case 8653: + pinyin = "SU"; + break; + + case 6601: + pinyin = "SUAN"; + break; + + case 5839: + case 6120: + case 6901: + case 6968: + case 7661: + case 7785: + case 7801: + pinyin = "SUI"; + break; + + case 6105: + case 6588: + case 6624: + case 7330: + case 8632: + pinyin = "SUN"; + break; + + case 6379: + case 6434: + case 6442: + case 7022: + case 7288: + case 7792: + case 8440: + pinyin = "SUO"; + break; + + case 6743: + case 6866: + case 6961: + case 7329: + case 7719: + case 7872: + case 8533: + case 8703: + pinyin = "TA"; + break; + + case 5902: + case 6223: + case 6330: + case 7070: + case 7536: + case 7638: + case 7849: + case 8544: + case 8656: + pinyin = "TAI"; + break; + + case 5916: + case 6903: + case 7428: + case 7694: + case 7867: + case 7936: + case 8191: + pinyin = "TAN"; + break; + + case 5746: + case 6491: + case 6871: + case 7209: + case 7344: + case 7906: + case 7959: + case 8177: + case 8305: + case 8311: + case 8442: + case 8517: + pinyin = "TANG"; + break; + + case 5627: + case 6391: + case 6812: + case 7226: + case 7666: + pinyin = "TAO"; + break; + pinyin = "1845 餐"; + break; + + case 6315: + case 7693: + case 7911: + pinyin = "TE"; + break; + + case 7588: + pinyin = "TENG"; + break; + + case 5735: + case 6709: + case 6949: + case 7130: + case 8035: + case 8151: + case 8514: + pinyin = "TI"; + break; + + case 6261: + case 6735: + case 6757: + case 7369: + case 7817: + pinyin = "TIAN"; + break; + + case 5712: + case 7686: + case 8127: + case 8272: + case 8352: + case 8448: + case 8622: + case 8670: + case 8756: + pinyin = "TIAO"; + break; + + case 6138: + case 8749: + pinyin = "TIE"; + break; + + case 6080: + case 6167: + case 7035: + case 7272: + case 7890: + case 8249: + case 8610: + pinyin = "TING"; + break; + + case 5701: + case 5758: + case 6077: + case 6444: + case 6690: + case 6892: + case 7737: + pinyin = "TONG"; + break; + + case 7855: + case 7822: + case 8727: + pinyin = "TOU"; + break; + + case 6002: + case 6117: + case 6143: + case 7842: + case 8509: + pinyin = "TU"; + break; + + case 6250: + case 6972: + pinyin = "TUAN"; + break; + + case 7653: + pinyin = "TUI"; + break; + + case 5759: + case 6629: + case 7453: + case 7564: + pinyin = "TUN"; + break; + + case 5617: + case 5702: + case 5971: + case 6653: + case 6791: + case 7256: + case 7262: + case 7350: + case 7740: + case 8374: + case 8502: + case 8541: + case 8630: + pinyin = "TUO"; + break; + + case 5684: + case 7020: + case 7580: + pinyin = "WA"; + break; + pinyin = "WAI"; + break; + + case 5664: + case 6025: + case 6150: + case 7093: + case 7126: + case 7194: + case 7568: + case 7821: + case 8274: + pinyin = "WAN"; + break; + + case 5672: + case 6244: + case 6715: + case 7394: + case 8745: + pinyin = "WANG"; + break; + + case 5743: + case 5835: + case 5881: + case 5883: + case 6158: + case 6217: + case 6488: + case 6501: + case 6543: + case 6545: + case 6611: + case 6612: + case 6739: + case 6777: + case 6802: + case 6822: + case 6952: + case 7024: + case 7166: + case 7224: + case 7406: + case 7631: + case 7648: + case 8084: + case 8426: + case 8659: + pinyin = "WEI"; + break; + + case 5656: + case 6751: + case 6775: + case 7223: + case 8609: + pinyin = "WEN"; + break; + + case 6178: + case 6219: + pinyin = "WENG"; + break; + + case 5733: + case 6111: + case 6502: + case 6855: + case 7531: + case 7750: + case 8627: + pinyin = "WO"; + break; + + case 5603: + case 5685: + case 5867: + case 5889: + case 5956: + case 6044: + case 6377: + case 6648: + case 6668: + case 6672: + case 6820: + case 6927: + case 6935: + case 6992: + case 7036: + case 7080: + case 7227: + case 7485: + case 7641: + case 8036: + case 8045: + case 8077: + case 8258: + case 8640: + case 8789: + pinyin = "WU"; + break; + + case 5750: + case 5766: + case 5884: + case 5913: + case 6130: + case 6163: + case 6191: + case 6241: + case 6381: + case 6567: + case 6630: + case 6750: + case 6827: + case 6832: + case 6979: + case 7050: + case 7184: + case 7356: + case 7456: + case 7474: + case 7604: + case 7668: + case 7689: + case 7691: + case 8010: + case 8122: + case 8265: + case 8303: + case 8312: + case 8410: + case 8424: + case 8443: + case 8449: + case 8466: + case 8521: + case 8791: + pinyin = "XI"; + break; + + case 6340: + case 6582: + case 6958: + case 7206: + case 7252: + case 7744: + case 8093: + case 8333: + case 8779: + pinyin = "XIA"; + break; + + case 5794: + case 5823: + case 6040: + case 6118: + case 6226: + case 6513: + case 6593: + case 6963: + case 7021: + case 7515: + case 7662: + case 7676: + case 8034: + case 8079: + case 8225: + case 8358: + case 8444: + case 8503: + case 8548: + case 8549: + case 8617: + pinyin = "XIAN"; + break; + + case 6028: + case 6157: + case 6635: + case 6652: + case 7088: + case 7129: + case 8313: + case 8663: + case 8747: + pinyin = "XIANG"; + break; + + case 6356: + case 6537: + case 6876: + case 6948: + case 7071: + case 7115: + case 7241: + case 7253: + case 8257: + case 8367: + case 8379: + case 8744: + pinyin = "XIAO"; + break; + + case 5741: + case 5784: + case 5936: + case 5938: + case 6215: + case 6302: + case 6619: + case 6661: + case 6845: + case 6912: + case 6966: + case 7105: + case 7151: + case 7331: + case 7339: + case 8583: + pinyin = "XIE"; + break; + + case 5622: + case 6016: + case 7431: + case 7607: + case 8646: + pinyin = "XIN"; + break; + + case 5874: + case 6084: + case 6309: + case 6712: + case 7742: + pinyin = "XING"; + break; + + case 6026: + pinyin = "XIONG"; + break; + + case 6361: + case 6522: + case 6642: + case 6651: + case 6869: + case 8028: + case 8587: + case 8759: + pinyin = "XIU"; + break; + + case 5828: + case 5935: + case 5955: + case 6203: + case 6810: + case 6851: + case 7179: + case 7282: + case 7667: + case 7776: + case 8167: + case 8458: + case 8515: + pinyin = "XU"; + break; + + case 5756: + case 5846: + case 6170: + case 6279: + case 6789: + case 6854: + case 6886: + case 7215: + case 7324: + case 7449: + case 7637: + case 7651: + case 7759: + case 7871: + case 7964: + case 8071: + pinyin = "XUAN"; + break; + + case 5842: + case 7720: + case 8529: + case 8708: + pinyin = "XUE"; + break; + + case 5767: + case 5908: + case 5987: + case 6087: + case 6101: + case 6206: + case 6225: + case 6530: + case 6563: + case 6620: + case 6694: + case 6813: + case 6817: + case 7454: + case 8131: + case 8524: + case 8664: + pinyin = "XUN"; + break; + + case 5683: + case 5975: + case 6275: + case 6512: + case 6934: + case 7011: + case 7180: + case 7266: + case 7518: + case 7728: + case 7793: + case 8073: + pinyin = "YA"; + break; + + case 5641: + case 5645: + case 5718: + case 5740: + case 5780: + case 5861: + case 5917: + case 5919: + case 6030: + case 6146: + case 6535: + case 6691: + case 6738: + case 6753: + case 6846: + case 6857: + case 6991: + case 7044: + case 7192: + case 7360: + case 7444: + case 7557: + case 7645: + case 7827: + case 8359: + case 8506: + case 8742: + case 8748: + case 8790: + pinyin = "YAN"; + break; + + case 6564: + case 6683: + case 7630: + case 7640: + case 7706: + case 8253: + case 8717: + pinyin = "YANG"; + break; + + case 5618: + case 5619: + case 6326: + case 6542: + case 6570: + case 7159: + case 7182: + case 7235: + case 7387: + case 7455: + case 7540: + case 7902: + case 8046: + case 8126: + case 8477: + case 8705: + pinyin = "YAO"; + break; + + case 5644: + case 5843: + case 5894: + case 6262: + case 7442: + case 7639: + case 7884: + pinyin = "YE"; + break; + + case 5655: + case 5657: + case 5670: + case 5693: + case 5711: + case 5817: + case 5961: + case 5992: + case 6018: + case 6051: + case 6072: + case 6218: + case 6236: + case 6240: + case 6258: + case 6314: + case 6329: + case 6355: + case 6362: + case 6441: + case 6470: + case 6527: + case 6558: + case 6602: + case 6634: + case 6688: + case 6689: + case 6708: + case 6884: + case 6938: + case 7068: + case 7143: + case 7376: + case 7383: + case 7461: + case 7629: + case 7658: + case 7784: + case 7838: + case 7955: + case 7978: + case 8074: + case 8089: + case 8115: + case 8120: + case 8270: + case 8415: + case 8464: + case 8472: + case 8493: + case 8780: + pinyin = "YI"; + break; + + case 5623: + case 5920: + case 5983: + case 6007: + case 6065: + case 6337: + case 6419: + case 6594: + case 6625: + case 6806: + case 7519: + case 7887: + case 8111: + case 8230: + case 8615: + case 8624: + pinyin = "YIN"; + break; + + case 5788: + case 5911: + case 6067: + case 6094: + case 6126: + case 6151: + case 6186: + case 6292: + case 6451: + case 6663: + case 6862: + case 6875: + case 6913: + case 7188: + case 7212: + case 7326: + case 7584: + case 8048: + case 8108: + case 8203: + case 8331: + pinyin = "YING"; + break; + + case 6401: + pinyin = "YO"; + break; + + case 5724: + case 5953: + case 6013: + case 6415: + case 6728: + case 7163: + case 7962: + case 8014: + case 8711: + case 8751: + pinyin = "YONG"; + break; + + case 5653: + case 5692: + case 5707: + case 6112: + case 6115: + case 6121: + case 6347: + case 6483: + case 6922: + case 7254: + case 7364: + case 7527: + case 7880: + case 8064: + case 8236: + case 8242: + case 8286: + case 8647: + case 8778: + case 8788: + pinyin = "YOU"; + break; + + case 5614: + case 5625: + case 5681: + case 5722: + case 5836: + case 5845: + case 6139: + case 6187: + case 6277: + case 6484: + case 6486: + case 6546: + case 6592: + case 6632: + case 6637: + case 6655: + case 6748: + case 6987: + case 6993: + case 7005: + case 7090: + case 7204: + case 7437: + case 7476: + case 7573: + case 7603: + case 7622: + case 7647: + case 7659: + case 7718: + case 7858: + case 8033: + case 8054: + case 8085: + case 8086: + case 8130: + case 8133: + case 8266: + case 8285: + case 8336: + case 8407: + case 8408: + case 8607: + case 8625: + pinyin = "YU"; + break; + + case 5989: + case 6011: + case 6282: + case 6768: + case 7034: + case 7205: + case 7358: + case 7528: + case 7783: + case 8016: + case 8302: + case 8378: + case 8629: + pinyin = "YUAN"; + break; + + case 5763: + case 6914: + case 7348: + case 7530: + case 7865: + pinyin = "YUE"; + break; + + case 5909: + case 6031: + case 6581: + case 6702: + case 6719: + case 7101: + case 7225: + case 7370: + case 7432: + case 7521: + case 7657: + pinyin = "YUN"; + break; + + case 6257: + case 6338: + pinyin = "ZA"; + break; + + case 6544: + case 7162: + pinyin = "ZAI"; + break; + + case 7222: + case 7435: + case 8402: + case 8456: + case 8485: + case 8641: + pinyin = "ZAN"; + break; + + case 6242: + case 7064: + case 7416: + pinyin = "ZANG"; + break; + + case 6380: + pinyin = "ZAO"; + break; + + case 5638: + case 8369: + case 5651: + case 6385: + case 6493: + case 6937: + case 7430: + case 8348: + case 8423: + pinyin = "ZE"; + break; + pinyin = "ZEI"; + break; + + case 5858: + pinyin = "ZEN"; + break; + + case 7153: + case 7421: + case 7832: + case 7913: + pinyin = "ZENG"; + break; + + case 6610: + case 6274: + case 6324: + case 6369: + case 6378: + case 7736: + case 8068: + case 8238: + case 8794: + pinyin = "ZHA"; + break; + + case 7746: + case 8109: + pinyin = "ZHAI"; + break; + + case 5862: + case 6288: + case 7625: + pinyin = "ZHAN"; + break; + + case 5675: + case 5921: + case 6504: + case 6554: + case 6615: + case 7049: + case 7216: + case 8315: + pinyin = "ZHANG"; + break; + + case 5815: + case 7294: + case 7840: + case 8341: + pinyin = "ZHAO"; + break; + + case 5856: + case 6301: + case 7247: + case 7392: + case 7761: + case 8049: + case 8162: + case 8256: + case 8487: + pinyin = "ZHE"; + break; + + case 5958: + case 6172: + case 6805: + case 7139: + case 7269: + case 7327: + case 7384: + case 7466: + case 7551: + case 7562: + case 7685: + case 7819: + case 8001: + case 8018: + case 8380: + pinyin = "ZHEN"; + break; + + case 5826: + case 6531: + case 6571: + case 7859: + case 7903: + case 8361: + pinyin = "ZHENG"; + break; + + case 5620: + case 5876: + case 5904: + case 5990: + case 6038: + case 6293: + case 6489: + case 6669: + case 6973: + case 6975: + case 7079: + case 7246: + case 7255: + case 7257: + case 7268: + case 7382: + case 7389: + case 7462: + case 7553: + case 7589: + case 7677: + case 7683: + case 7773: + case 7984: + case 8026: + case 8075: + case 8246: + case 8474: + case 8505: + case 8537: + case 8557: + case 8560: + case 8584: + case 8603: + pinyin = "ZHI"; + break; + + case 5803: + case 7981: + case 8314: + case 8417: + case 8564: + pinyin = "ZHONG"; + break; + + case 6107: + case 6390: + case 7008: + case 7091: + case 7107: + case 7548: + case 7756: + case 8406: + case 8492: + pinyin = "ZHOU"; + break; + + case 5689: + case 5710: + case 5905: + case 6049: + case 6079: + case 6808: + case 6830: + case 6883: + case 7244: + case 7338: + case 7345: + case 7636: + case 7889: + case 8070: + case 8081: + case 8335: + case 8371: + case 8422: + case 8467: + case 8578: + case 8770: + pinyin = "ZHU"; + break; + pinyin = "ZHUA"; + break; + pinyin = "ZHUAI"; + break; + + case 6389: + case 6645: + case 8207: + pinyin = "ZHUAN"; + break; + + case 5755: + pinyin = "ZHUANG"; + break; + + case 6723: + case 7077: + case 7136: + pinyin = "ZHUI"; + break; + + case 7538: + case 8124: + pinyin = "ZHUN"; + break; + + case 5730: + case 5834: + case 6310: + case 6823: + case 6835: + case 6910: + case 7644: + case 7690: + case 7729: + case 7977: + pinyin = "ZHUO"; + break; + + case 5849: + case 6549: + case 7002: + case 7060: + case 7127: + case 7287: + case 7402: + case 7463: + case 7707: + case 7786: + case 7937: + case 7986: + case 8172: + case 8342: + case 8450: + case 8484: + case 8594: + case 8604: + case 8623: + case 8686: + case 8758: + pinyin = "ZI"; + break; + + case 5744: + case 7574: + case 8453: + pinyin = "ZONG"; + break; + + case 5833: + case 5878: + case 5924: + case 7067: + case 8677: + pinyin = "ZOU"; + break; + + case 5762: + case 6147: + case 7963: + pinyin = "ZU"; + break; + + case 6312: + case 7158: + case 8582: + pinyin = "ZUAN"; + break; + + case 6209: + pinyin = "ZUI"; + break; + + case 6304: + case 7355: + case 8714: + pinyin = "ZUN"; + break; + + case 5872: + case 6382: + case 6460: + case 6684: + case 7549: + case 7681: + pinyin = "ZUO"; + break; + + default: + if (code >= 1601 && code <= 1602) { + pinyin = "A"; + break; + } + + if (code >= 1603 && code <= 1615) { + pinyin = "AI"; + break; + } + + if (code >= 1616 && code <= 1624) { + pinyin = "AN"; + break; + } + + if (code >= 1625 && code <= 1627) { + pinyin = "ANG"; + break; + } + + if (code >= 1628 && code <= 1636) { + pinyin = "AO"; + break; + } + + if (code >= 1637 && code <= 1654) { + pinyin = "BA"; + break; + } + + if (code >= 1655 && code <= 1662) { + pinyin = "BAI"; + break; + } + + if (code >= 1663 && code <= 1677) { + pinyin = "BAN"; + break; + } + + if (code >= 1678 && code <= 1689) { + pinyin = "BANG"; + break; + } + + if (code >= 1690 && code <= 1712) { + pinyin = "BAO"; + break; + } + + if (code >= 1713 && code <= 1727) { + pinyin = "BEI"; + break; + } + + if (code >= 1728 && code <= 1731) { + pinyin = "BEN"; + break; + } + + if (code >= 1732 && code <= 1737) { + pinyin = "BENG"; + break; + } + + if (code > 1738 && code <= 1761) { + pinyin = "BI"; + break; + } + + if (code >= 1762 && code <= 1773) { + pinyin = "BIAN"; + break; + } + + if (code >= 1774 && code <= 1777) { + pinyin = "BIAO"; + break; + } + + if (code >= 1778 && code <= 1781) { + pinyin = "BIE"; + break; + } + + if (code >= 1782 && code <= 1787) { + pinyin = "BIN"; + break; + } + + if (code >= 1788 && code <= 1794) { + pinyin = "BING"; + break; + } + + if (code >= 1801 && code <= 1802) { + pinyin = "BING"; + break; + } + + if (code >= 1803 && code <= 1821) { + pinyin = "BO"; + break; + } + + if (code >= 1822 && code <= 1832) { + pinyin = "BU"; + break; + } + + if (code == 1833) { + pinyin = "CA"; + break; + } + + if (code >= 1834 && code <= 1844) { + pinyin = "CAI"; + break; + } + + if (code >= 1845 && code <= 1851) { + pinyin = "CAN"; + break; + } + + if (code >= 1852 && code <= 1856) { + pinyin = "CANG"; + break; + } + + if (code >= 1857 && code <= 1861) { + pinyin = "CAO"; + break; + } + + if (code >= 1862 && code <= 1866) { + pinyin = "CE"; + break; + } + + if (code >= 1867 && code <= 1868) { + pinyin = "CENG"; + break; + } + + if (code >= 1869 && code <= 1879) { + pinyin = "CHA"; + break; + } + + if (code >= 1880 && code <= 1882) { + pinyin = "CHAI"; + break; + } + + if (code >= 1883 && code <= 1892) { + pinyin = "CHAN"; + break; + } + + if (code >= 1893 && code <= 1911) { + pinyin = "CHANG"; + break; + } + + if (code >= 1912 && code <= 1920) { + pinyin = "CHAO"; + break; + } + + if (code >= 1921 && code <= 1926) { + pinyin = "CHE"; + break; + } + + if (code >= 1927 && code <= 1936) { + pinyin = "CHEN"; + break; + } + + if (code >= 1937 && code <= 1951) { + pinyin = "CHENG"; + break; + } + + if (code >= 1952 && code <= 1967) { + pinyin = "CHI"; + break; + } + + if (code >= 1968 && code <= 1972) { + pinyin = "CHONG"; + break; + } + + if (code >= 1973 && code <= 1984) { + pinyin = "CHOU"; + break; + } + + if (code >= 1985 && code <= 2006) { + pinyin = "CHU"; + break; + } + + if (code == 2007) { + pinyin = "CHUAI"; + break; + } + + if (code >= 2008 && code <= 2014) { + pinyin = "CHUAN"; + break; + } + + if (code >= 2015 && code <= 2020) { + pinyin = "CHUANG"; + break; + } + + if (code >= 2021 && code <= 2025) { + pinyin = "CHUI"; + break; + } + + if (code >= 2026 && code <= 2032) { + pinyin = "CHUN"; + break; + } + + if (code >= 2033 && code <= 2034) { + pinyin = "CHUO"; + break; + } + + if (code >= 2035 && code <= 2046) { + pinyin = "CI"; + break; + } + + if (code >= 2047 && code <= 2052) { + pinyin = "CONG"; + break; + } + + if (code >= 2054 && code <= 2057) { + pinyin = "CU"; + break; + } + + if (code >= 2058 && code <= 2060) { + pinyin = "CUAN"; + break; + } + + if (code >= 2061 && code <= 2068) { + pinyin = "CUI"; + break; + } + + if (code >= 2069 && code <= 2071) { + pinyin = "CUN"; + break; + } + + if (code >= 2072 && code <= 2077) { + pinyin = "CUO"; + break; + } + + if (code >= 2078 && code <= 2083) { + pinyin = "DA"; + break; + } + + if (code >= 2084 && code <= 2094) { + pinyin = "DAI"; + break; + } + + if (code >= 2102 && code <= 2116) { + pinyin = "DAN"; + break; + } + + if (code >= 2117 && code <= 2121) { + pinyin = "DANG"; + break; + } + + if (code >= 2122 && code <= 2133) { + pinyin = "DAO"; + break; + } + + if (code >= 2134 && code <= 2136) { + pinyin = "DE"; + break; + } + + if (code >= 2137 && code <= 2143) { + pinyin = "DENG"; + break; + } + + if (code >= 2144 && code <= 2162) { + pinyin = "DI"; + break; + } + + if (code >= 2163 && code <= 2178) { + pinyin = "DIAN"; + break; + } + + if (code >= 2179 && code <= 2187) { + pinyin = "DIAO"; + break; + } + + if (code >= 2188 && code <= 2194) { + pinyin = "DIE"; + break; + } + + if (code >= 2201 && code <= 2209) { + pinyin = "DING"; + break; + } + + if (code == 2210) { + pinyin = "DIU"; + break; + } + + if (code >= 2211 && code <= 2220) { + pinyin = "DONG"; + break; + } + + if (code >= 2221 && code <= 2227) { + pinyin = "DOU"; + break; + } + + if (code >= 2228 && code <= 2242) { + pinyin = "DU"; + break; + } + + if (code >= 2243 && code <= 2248) { + pinyin = "DUAN"; + break; + } + + if (code >= 2249 && code <= 2252) { + pinyin = "DUI"; + break; + } + + if (code >= 2253 && code <= 2261) { + pinyin = "DUN"; + break; + } + + if (code >= 2262 && code <= 2273) { + pinyin = "DUO"; + break; + } + + if (code >= 2274 && code <= 2286) { + pinyin = "E"; + break; + } + + if (code == 2287) { + pinyin = "EN"; + break; + } + + if (code >= 2288 && code <= 2231) { + pinyin = "ER"; + break; + } + + if (code >= 2302 && code <= 2309) { + pinyin = "FA"; + break; + } + + if (code >= 2310 && code <= 2326) { + pinyin = "FAN"; + break; + } + + if (code >= 2327 && code <= 2337) { + pinyin = "FANG"; + break; + } + + if (code >= 2338 && code <= 2349) { + pinyin = "FEI"; + break; + } + + if (code >= 2350 && code <= 2364) { + pinyin = "FEN"; + break; + } + + if (code >= 2365 && code <= 2379) { + pinyin = "FENG"; + break; + } + + if (code == 2380) { + pinyin = "FO"; + break; + } + + if (code == 2381) { + pinyin = "FOU"; + break; + } + + if (code >= 2382 && code <= 2432) { + pinyin = "FU"; + break; + } + + if (code >= 2435 && code <= 2440) { + pinyin = "GAI"; + break; + } + + if (code >= 2441 && code <= 2451) { + pinyin = "GAN"; + break; + } + + if (code >= 2452 && code <= 2460) { + pinyin = "GANG"; + break; + } + + if (code >= 2461 && code <= 2470) { + pinyin = "GAO"; + break; + } + + if (code >= 2471 && code <= 2487) { + pinyin = "GE"; + break; + } + + if (code == 2488) { + pinyin = "GEI"; + break; + } + + if (code >= 2489 && code <= 2490) { + pinyin = "GEN"; + break; + } + + if (code >= 2491 && code <= 2503) { + pinyin = "GENG"; + break; + } + + if (code >= 2504 && code <= 2518) { + pinyin = "GONG"; + break; + } + + if (code >= 2519 && code <= 2527) { + pinyin = "GOU"; + break; + } + + if (code >= 2528 && code <= 2545) { + pinyin = "GU"; + break; + } + + if (code >= 2546 && code <= 2551) { + pinyin = "GUA"; + break; + } + + if (code >= 2552 && code <= 2554) { + pinyin = "GUAI"; + break; + } + + if (code >= 2555 && code <= 2565) { + pinyin = "GUAN"; + break; + } + + if (code >= 2566 && code <= 2568) { + pinyin = "GUANG"; + break; + } + + if (code >= 2569 && code <= 2584) { + pinyin = "GUI"; + break; + } + + if (code >= 2585 && code <= 2587) { + pinyin = "GUN"; + break; + } + + if (code >= 2588 && code <= 2593) { + pinyin = "GUO"; + break; + } + + if (code == 2594) { + pinyin = "HA"; + break; + } + + if (code >= 2601 && code <= 2607) { + pinyin = "HAI"; + break; + } + + if (code >= 2608 && code <= 2626) { + pinyin = "HAN"; + break; + } + + if (code >= 2627 && code <= 2629) { + pinyin = "HANG"; + break; + } + + if (code >= 2630 && code <= 2638) { + pinyin = "HAO"; + break; + } + + if (code >= 2639 && code <= 2656) { + pinyin = "HE"; + break; + } + + if (code >= 2657 && code <= 2658) { + pinyin = "HEI"; + break; + } + + if (code >= 2659 && code <= 2662) { + pinyin = "HEN"; + break; + } + + if (code >= 2663 && code <= 2667) { + pinyin = "HENG"; + break; + } + + if (code >= 2668 && code <= 2676) { + pinyin = "HONG"; + break; + } + + if (code >= 2677 && code <= 2683) { + pinyin = "HOU"; + break; + } + + if (code >= 2684 && code <= 2707) { + pinyin = "HU"; + break; + } + + if (code >= 2708 && code <= 2716) { + pinyin = "HUA"; + break; + } + + if (code >= 2717 && code <= 2721) { + pinyin = "HUAI"; + break; + } + + if (code >= 2722 && code <= 2735) { + pinyin = "HUAN"; + break; + } + + if (code >= 2736 && code <= 2749) { + pinyin = "HUANG"; + break; + } + + if (code >= 2750 && code <= 2770) { + pinyin = "HUI"; + break; + } + + if (code >= 2771 && code <= 2776) { + pinyin = "HUN"; + break; + } + + if (code >= 2777 && code <= 2786) { + pinyin = "HUO"; + break; + } + + if (code >= 2787 && code <= 2845) { + pinyin = "JI"; + break; + } + + if (code >= 2846 && code <= 2862) { + pinyin = "JIA"; + break; + } + + if (code >= 2863 && code <= 2908) { + pinyin = "JIAN"; + break; + } + + if (code >= 2909 && code <= 2921) { + pinyin = "JIANG"; + break; + } + + if (code >= 2922 && code <= 2949) { + pinyin = "JIAO"; + break; + } + + if (code >= 2950 && code <= 2976) { + pinyin = "JIE"; + break; + } + + if (code >= 2977 && code <= 3002) { + pinyin = "JIN"; + break; + } + + if (code >= 3003 && code <= 3027) { + pinyin = "JING"; + break; + } + + if (code >= 3028 && code <= 3029) { + pinyin = "JIONG"; + break; + } + + if (code >= 3030 && code <= 3046) { + pinyin = "JIU"; + break; + } + + if (code >= 3047 && code <= 3071) { + pinyin = "JU"; + break; + } + + if (code >= 3072 && code <= 3078) { + pinyin = "JUAN"; + break; + } + + if (code >= 3079 && code <= 3088) { + pinyin = "JUE"; + break; + } + + if (code >= 3089 && code <= 3105) { + pinyin = "JUN"; + break; + } + + if (code >= 3106 && code <= 3109) { + pinyin = "KA"; + break; + } + + if (code >= 3110 && code <= 3114) { + pinyin = "KAI"; + break; + } + + if (code >= 3115 && code <= 3120) { + pinyin = "KAN"; + break; + } + + if (code >= 3121 && code <= 3127) { + pinyin = "KANG"; + break; + } + + if (code >= 3128 && code <= 3131) { + pinyin = "KAO"; + break; + } + + if (code >= 3132 && code <= 3146) { + pinyin = "KE"; + break; + } + + if (code >= 3147 && code <= 3150) { + pinyin = "KEN"; + break; + } + + if (code >= 3151 && code <= 3152) { + pinyin = "KENG"; + break; + } + + if (code >= 3153 && code <= 3156) { + pinyin = "KONG"; + break; + } + + if (code >= 3157 && code <= 3160) { + pinyin = "KOU"; + break; + } + + if (code >= 3161 && code <= 3167) { + pinyin = "KU"; + break; + } + + if (code >= 3168 && code <= 3172) { + pinyin = "KUA"; + break; + } + + if (code >= 3173 && code <= 3176) { + pinyin = "KUAI"; + break; + } + + if (code >= 3177 && code <= 3178) { + pinyin = "KUAN"; + break; + } + + if (code >= 3179 && code <= 3186) { + pinyin = "KUANG"; + break; + } + + if (code >= 3187 && code <= 3203) { + pinyin = "KUI"; + break; + } + + if (code >= 3204 && code <= 3207) { + pinyin = "KUN"; + break; + } + + if (code >= 3208 && code <= 3211) { + pinyin = "KUO"; + break; + } + + if (code >= 3212 && code <= 3218) { + pinyin = "LA"; + break; + } + + if (code >= 3219 && code <= 3221) { + pinyin = "LAI"; + break; + } + + if (code >= 3222 && code <= 3236) { + pinyin = "LAN"; + break; + } + + if (code >= 3237 && code <= 3243) { + pinyin = "LANG"; + break; + } + + if (code >= 3244 && code <= 3252) { + pinyin = "LAO"; + break; + } + + if (code >= 3253 && code <= 3254) { + pinyin = "LE"; + break; + } + + if (code >= 3255 && code <= 3265) { + pinyin = "LEI"; + break; + } + + if (code >= 3266 && code <= 3268) { + pinyin = "LENG"; + break; + } + + if (code >= 3269 && code <= 3308) { + pinyin = "LI"; + } + + if (code == 3309) { + pinyin = "LIA"; + break; + } + + if (code >= 3310 && code <= 3323) { + pinyin = "LIAN"; + break; + } + + if (code >= 3324 && code <= 3334) { + pinyin = "LIANG"; + break; + } + + if (code >= 3335 && code <= 3347) { + pinyin = "LIAO"; + break; + } + + if (code >= 3348 && code <= 3352) { + pinyin = "LIE"; + break; + } + + if (code >= 3353 && code <= 3363) { + pinyin = "LIN"; + break; + } + + if (code >= 3364 && code <= 3378) { + pinyin = "LING"; + break; + } + + if (code >= 3379 && code <= 3389) { + pinyin = "LIU"; + break; + } + + if (code >= 3390 && code <= 3404) { + pinyin = "LONG"; + break; + } + + if (code >= 3405 && code <= 3410) { + pinyin = "LOU"; + break; + } + + if (code >= 3411 && code <= 3444) { + pinyin = "LU"; + break; + } + + if (code >= 3445 && code <= 3450) { + pinyin = "LUAN"; + break; + } + + if (code >= 3451 && code <= 3452) { + pinyin = "LUE"; + break; + } + + if (code >= 3453 && code <= 3459) { + pinyin = "LUN"; + break; + } + + if (code >= 3460 && code <= 3471) { + pinyin = "LUO"; + break; + } + + if (code >= 3472 && code <= 3480) { + pinyin = "MA"; + break; + } + + if (code >= 3481 && code <= 3486) { + pinyin = "MAI"; + break; + } + + if (code >= 3487 && code <= 3501) { + pinyin = "MAN"; + break; + } + + if (code >= 3502 && code <= 3507) { + pinyin = "MANG"; + break; + } + + if (code >= 3508 && code <= 3519) { + pinyin = "MAO"; + break; + } + + if (code == 3520) { + pinyin = "ME"; + break; + } + + if (code >= 3521 && code <= 3536) { + pinyin = "MEI"; + break; + } + + if (code >= 3537 && code <= 3539) { + pinyin = "MEN"; + break; + } + + if (code >= 3540 && code <= 3547) { + pinyin = "MENG"; + break; + } + + if (code >= 3548 && code <= 3561) { + pinyin = "MI"; + } + + if (code >= 3562 && code <= 3570) { + pinyin = "MIAN"; + break; + } + + if (code >= 3571 && code <= 3578) { + pinyin = "MIAO"; + break; + } + + if (code >= 3579 && code <= 3580) { + pinyin = "MIE"; + break; + } + + if (code >= 3581 && code <= 3586) { + pinyin = "MIN"; + break; + } + + if (code >= 3587 && code <= 3592) { + pinyin = "MING"; + break; + } + + if (code == 3593) { + pinyin = "MIU"; + break; + } + + if (code >= 3594 && code <= 3616) { + pinyin = "MO"; + break; + } + + if (code >= 3617 && code <= 3619) { + pinyin = "MOU"; + break; + } + + if (code >= 3620 && code <= 3634) { + pinyin = "MU"; + break; + } + + if (code >= 3635 && code <= 3641) { + pinyin = "NA"; + break; + } + + if (code >= 3642 && code <= 3646) { + pinyin = "NAI"; + break; + } + + if (code >= 3647 && code <= 3649) { + pinyin = "NAN"; + break; + } + + if (code == 3650) { + pinyin = "NANG"; + break; + } + + if (code >= 3651 && code <= 3655) { + pinyin = "NAO"; + break; + } + + if (code == 3656) { + pinyin = "NE"; + break; + } + + if (code >= 3657 && code <= 3658) { + pinyin = "NEI"; + break; + } + + if (code == 3659) { + pinyin = "NEN"; + break; + } + + if (code == 3660) { + pinyin = "NENG"; + break; + } + + if (code >= 3661 && code <= 3671) { + pinyin = "NI"; + break; + } + + if (code >= 3672 && code <= 3678) { + pinyin = "NIAN"; + break; + } + + if (code >= 3679 && code <= 3680) { + pinyin = "NIANG"; + break; + } + + if (code >= 3681 && code <= 3682) { + pinyin = "NIAO"; + break; + } + + if (code >= 3683 && code <= 3689) { + pinyin = "NIE"; + break; + } + + if (code == 3690) { + pinyin = "NIN"; + break; + } + + if (code >= 3691 && code <= 3702) { + pinyin = "NING"; + break; + } + + if (code >= 3703 && code <= 3706) { + pinyin = "NIU"; + break; + } + + if (code >= 3707 && code <= 3710) { + pinyin = "NONG"; + break; + } + + if (code >= 3711 && code <= 3714) { + pinyin = "NU"; + break; + } + + if (code == 3715) { + pinyin = "NUAN"; + break; + } + + if (code >= 3716 && code <= 3717) { + pinyin = "NUE"; + break; + } + + if (code >= 3718 && code <= 3721) { + pinyin = "NUO"; + break; + } + + if (code == 3722) { + pinyin = "O"; + break; + } + + if (code >= 3723 && code <= 3729) { + pinyin = "OU"; + break; + } + + if (code >= 3730 && code <= 3735) { + pinyin = "PA"; + break; + } + + if (code >= 3736 && code <= 3741) { + pinyin = "PAI"; + break; + } + + if (code >= 3742 && code <= 3749) { + pinyin = "PAN"; + break; + } + + if (code >= 3750 && code <= 3754) { + pinyin = "PANG"; + break; + } + + if (code >= 3755 && code <= 3761) { + pinyin = "PAO"; + break; + } + + if (code >= 3762 && code <= 3770) { + pinyin = "PEI"; + break; + } + + if (code >= 3771 && code <= 3772) { + pinyin = "PEN"; + break; + } + + if (code >= 3773 && code <= 3786) { + pinyin = "PENG"; + break; + } + + if (code >= 3787 && code <= 3809) { + pinyin = "PI"; + break; + } + + if (code >= 3810 && code <= 3813) { + pinyin = "PIAN"; + break; + } + + if (code >= 3814 && code <= 3817) { + pinyin = "PIAO"; + break; + } + + if (code >= 3818 && code <= 3819) { + pinyin = "PIE"; + break; + } + + if (code >= 3820 && code <= 3824) { + pinyin = "PIN"; + break; + } + + if (code >= 3825 && code <= 3833) { + pinyin = "PING"; + break; + } + + if (code >= 3834 && code <= 3841) { + pinyin = "PO"; + break; + } + + if (code == 3842) { + pinyin = "POU"; + break; + } + + if (code >= 3843 && code <= 3857) { + pinyin = "PU"; + break; + } + + if (code >= 3858 && code <= 3893) { + pinyin = "QI"; + break; + } + + if (code == 3894 || (code >= 3901 && code <= 3902)) { + pinyin = "QIA"; + break; + } + + if (code >= 3903 && code <= 3924) { + pinyin = "QIAN"; + break; + } + + if (code >= 3925 && code <= 3932) { + pinyin = "QIANG"; + break; + } + + if (code >= 3933 && code <= 3947) { + pinyin = "QIAO"; + break; + } + + if (code >= 3948 && code <= 3952) { + pinyin = "QIE"; + break; + } + + if (code >= 3953 && code <= 3963) { + pinyin = "QIN"; + break; + } + + if (code >= 3964 && code <= 3976) { + pinyin = "QING"; + break; + } + + if (code >= 3977 && code <= 3978) { + pinyin = "QIONG"; + break; + } + + if (code >= 3979 && code <= 3986) { + pinyin = "QIU"; + break; + } + + if (code >= 3987 && code <= 4005) { + pinyin = "QU"; + break; + } + + if (code >= 4006 && code <= 4016) { + pinyin = "QUAN"; + break; + } + + if (code >= 4017 && code <= 4024) { + pinyin = "QUE"; + break; + } + + if (code >= 4025 && code <= 4026) { + pinyin = "QUN"; + break; + } + + if (code >= 4027 && code <= 4030) { + pinyin = "RAN"; + break; + } + + if (code >= 4031 && code <= 4035) { + pinyin = "RANG"; + } + + if (code >= 4036 && code <= 4038) { + pinyin = "RAO"; + break; + } + + if (code >= 4039 && code <= 4040) { + pinyin = "RE"; + break; + } + + if (code >= 4041 && code <= 4050) { + pinyin = "REN"; + break; + } + + if (code >= 4051 && code <= 4052) { + pinyin = "RENG"; + break; + } + + if (code == 4053) { + pinyin = "RI"; + break; + } + + if (code >= 4054 && code <= 4063) { + pinyin = "RONG"; + break; + } + + if (code >= 4064 && code <= 4066) { + pinyin = "ROU"; + break; + } + + if (code >= 4067 && code <= 4076) { + pinyin = "RU"; + break; + } + + if (code >= 4077 && code <= 4078) { + pinyin = "RUAN"; + break; + } + + if (code >= 4079 && code <= 4081) { + pinyin = "RUI"; + break; + } + + if (code >= 4082 && code <= 4083) { + pinyin = "RUN"; + break; + } + + if (code >= 4084 && code <= 4085) { + pinyin = "RUO"; + break; + } + + if (code >= 4086 && code <= 4088) { + pinyin = "SA"; + break; + } + + if (code >= 4089 && code <= 4092) { + pinyin = "SAI"; + break; + } + + if (code >= 4093 && code <= 4094) { + pinyin = "SAN"; + break; + } + + if (code >= 4101 && code <= 4102) { + pinyin = "SAN"; + break; + } + + if (code >= 4103 && code <= 4105) { + pinyin = "SANG"; + break; + } + + if (code >= 4106 && code <= 4109) { + pinyin = "SAO"; + break; + } + + if (code >= 4110 && code <= 4112) { + pinyin = "SE"; + break; + } + + if (code == 4113) { + pinyin = "SEN"; + } + + if (code == 4114) { + pinyin = "SENG"; + break; + } + + if (code >= 4115 && code <= 4123) { + pinyin = "SHA"; + break; + } + + if (code >= 4124 && code <= 4125) { + pinyin = "SHAI"; + break; + } + + if (code >= 4126 && code <= 4141) { + pinyin = "SHAN"; + break; + } + + if (code >= 4142 && code <= 4149) { + pinyin = "SHANG"; + break; + } + + if (code >= 4150 && code <= 4160) { + pinyin = "SHAO"; + break; + } + + if (code >= 4161 && code <= 4172) { + pinyin = "SHE"; + break; + } + + if (code >= 4173 && code <= 4188) { + pinyin = "SHEN"; + break; + } + + if (code >= 4189 && code <= 4205) { + pinyin = "SHENG"; + break; + } + + if (code >= 4206 && code <= 4252) { + pinyin = "SHI"; + break; + } + + if (code >= 4253 && code <= 4262) { + pinyin = "SHOU"; + break; + } + + if (code >= 4263 && code <= 4301) { + pinyin = "SHU"; + break; + } + + if (code >= 4302 && code <= 4303) { + pinyin = "SHUA"; + break; + } + + if (code >= 4304 && code <= 4307) { + pinyin = "SHUAI"; + break; + } + + if (code >= 4308 && code <= 4309) { + pinyin = "SHUAN"; + break; + } + + if (code >= 4310 && code <= 4312) { + pinyin = "SHUANG"; + break; + } + + if (code >= 4313 && code <= 4316) { + pinyin = "SHUI"; + break; + } + + if (code >= 4317 && code <= 4320) { + pinyin = "SHUN"; + break; + } + + if (code >= 4321 && code <= 4324) { + pinyin = "SHUO"; + break; + } + + if (code >= 4325 && code <= 4340) { + pinyin = "SI"; + break; + } + + if (code >= 4341 && code <= 4348) { + pinyin = "SONG"; + break; + } + + if (code >= 4349 && code <= 4352) { + pinyin = "SOU"; + break; + } + + if (code >= 4353 && code <= 4364) { + pinyin = "SU"; + break; + } + + if (code >= 4365 && code <= 4367) { + pinyin = "SUAN"; + break; + } + + if (code >= 4368 && code <= 4378) { + pinyin = "SUI"; + break; + } + + if (code >= 4379 && code <= 4381) { + pinyin = "SUN"; + break; + } + + if (code >= 4382 && code <= 4389) { + pinyin = "SUO"; + break; + } + + if (code >= 4390 && code <= 4404) { + pinyin = "TA"; + break; + } + + if (code >= 4405 && code <= 4413) { + pinyin = "TAI"; + break; + } + + if (code >= 4414 && code <= 4431) { + pinyin = "TAN"; + break; + } + + if (code >= 4432 && code <= 4444) { + pinyin = "TANG"; + break; + } + + if (code >= 4445 && code <= 4455) { + pinyin = "TAO"; + break; + } + + if (code == 4456) { + pinyin = "TE"; + break; + } + + if (code >= 4457 && code <= 4460) { + pinyin = "TENG"; + break; + } + + if (code >= 4461 && code <= 4475) { + pinyin = "TI"; + break; + } + + if (code >= 4476 && code <= 4483) { + pinyin = "TIAN"; + break; + } + + if (code >= 4484 && code <= 4488) { + pinyin = "TIAO"; + break; + } + + if (code >= 4489 && code <= 4491) { + pinyin = "TIE"; + break; + } + + if (code >= 4492 && code <= 4507) { + pinyin = "TING"; + break; + } + + if (code >= 4508 && code <= 4520) { + pinyin = "TONG"; + break; + } + + if (code >= 4521 && code <= 4524) { + pinyin = "TOU"; + break; + } + + if (code >= 4525 && code <= 4535) { + pinyin = "TU"; + break; + } + + if (code >= 4536 && code <= 4537) { + pinyin = "TUAN"; + break; + } + + if (code >= 4538 && code <= 4543) { + pinyin = "TUI"; + break; + } + + if (code >= 4544 && code <= 4546) { + pinyin = "TUN"; + break; + } + + if (code >= 4547 && code <= 4557) { + pinyin = "TUO"; + break; + } + + if (code >= 4558 && code <= 4564) { + pinyin = "WA"; + break; + } + + if (code >= 4565 && code <= 4566) { + pinyin = "WAI"; + break; + } + + if (code >= 4567 && code <= 4583) { + pinyin = "WAN"; + break; + } + + if (code >= 4584 && code <= 4593) { + pinyin = "WANG"; + break; + } + + if (code >= 4594 && code <= 4632) { + pinyin = "WEI"; + break; + } + + if (code >= 4633 && code <= 4642) { + pinyin = "WEN"; + break; + } + + if (code >= 4643 && code <= 4645) { + pinyin = "WENG"; + break; + } + + if (code >= 4646 && code <= 4654) { + pinyin = "WO"; + break; + } + + if (code >= 4655 && code <= 4683) { + pinyin = "WU"; + break; + } + + if (code >= 4684 && code <= 4724) { + pinyin = "XI"; + break; + } + + if (code >= 4725 && code <= 4737) { + pinyin = "XIA"; + break; + } + + if (code >= 4738 && code <= 4763) { + pinyin = "XIAN"; + break; + } + + if (code >= 4764 && code <= 4783) { + pinyin = "XIANG"; + break; + } + + if (code >= 4784 && code <= 4807) { + pinyin = "XIAO"; + break; + } + + if (code >= 4809 && code <= 4828) { + pinyin = "XIE"; + break; + } + + if (code >= 4829 && code <= 4838) { + pinyin = "XIN"; + break; + } + + if (code >= 4839 && code <= 4853) { + pinyin = "XING"; + break; + } + + if (code >= 4854 && code <= 4860) { + pinyin = "XIONG"; + break; + } + + if (code >= 4861 && code <= 4869) { + pinyin = "XIU"; + break; + } + + if (code >= 4870 && code <= 4888) { + pinyin = "XU"; + break; + } + + if (code >= 4889 && code <= 4904) { + pinyin = "XUAN"; + break; + } + + if (code >= 4905 && code <= 4910) { + pinyin = "XUE"; + break; + } + + if (code >= 4911 && code <= 4924) { + pinyin = "XUN"; + break; + } + + if (code >= 4925 && code <= 4940) { + pinyin = "YA"; + break; + } + + if (code >= 4941 && code <= 4973) { + pinyin = "YAN"; + break; + } + + if (code >= 4974 && code <= 4990) { + pinyin = "YANG"; + break; + } + + if (code >= 4991 && code <= 5011) { + pinyin = "YAO"; + break; + } + + if (code >= 5012 && code <= 5026) { + pinyin = "YE"; + break; + } + + if (code >= 5027 && code <= 5079) { + pinyin = "YI"; + break; + } + + if (code >= 5080 && code <= 5101) { + pinyin = "YIN"; + break; + } + + if (code >= 5102 && code <= 5119) { + pinyin = "YING"; + break; + } + + if (code == 5120) { + pinyin = "YO"; + break; + } + + if (code >= 5121 && code <= 5135) { + pinyin = "YONG"; + break; + } + + if (code >= 5136 && code <= 5155) { + pinyin = "YOU"; + break; + } + + if (code >= 5156 && code <= 5206) { + pinyin = "YU"; + break; + } + + if (code >= 5207 && code <= 5226) { + pinyin = "YUAN"; + break; + } + + if (code >= 5227 && code <= 5236) { + pinyin = "YUE"; + break; + } + + if (code >= 5237 && code <= 5248) { + pinyin = "YUN"; + break; + } + + if (code >= 5249 && code <= 5251) { + pinyin = "ZA"; + break; + } + + if (code >= 5252 && code <= 5258) { + pinyin = "ZAI"; + break; + } + + if (code >= 5259 && code <= 5262) { + pinyin = "ZAN"; + break; + } + + if (code >= 5263 && code <= 5265) { + pinyin = "ZANG"; + break; + } + + if (code >= 5266 && code <= 5279) { + pinyin = "ZAO"; + break; + } + + if (code >= 5280 && code <= 5283) { + pinyin = "ZE"; + break; + } + + if (code == 5284) { + pinyin = "ZEI"; + break; + } + + if (code == 5285) { + pinyin = "ZEN"; + break; + } + + if (code >= 5286 && code <= 5289) { + pinyin = "ZENG"; + break; + } + + if (code >= 5290 && code <= 5309) { + pinyin = "ZHA"; + break; + } + + if (code >= 5310 && code <= 5315) { + pinyin = "ZHAI"; + break; + } + + if (code >= 5316 && code <= 5332) { + pinyin = "ZHAN"; + break; + } + + if (code >= 5333 && code <= 5347) { + pinyin = "ZHANG"; + break; + } + + if (code >= 5348 && code <= 5357) { + pinyin = "ZHAO"; + break; + } + + if (code >= 5358 && code <= 5367) { + pinyin = "ZHE"; + break; + } + + if (code >= 5368 && code <= 5383) { + pinyin = "ZHEN"; + break; + } + + if (code >= 5384 && code <= 5404) { + pinyin = "ZHENG"; + break; + } + + if (code >= 5405 && code <= 5447) { + pinyin = "ZHI"; + break; + } + + if (code >= 5448 && code <= 5458) { + pinyin = "ZHONG"; + break; + } + + if (code >= 5459 && code <= 5472) { + pinyin = "ZHOU"; + break; + } + + if (code >= 5473 && code <= 5504) { + pinyin = "ZHU"; + break; + } + + if (code >= 5505 && code <= 5506) { + pinyin = "ZHUA"; + break; + } + + if (code == 5507) { + pinyin = "ZHUAI"; + break; + } + + if (code >= 5508 && code <= 5513) { + pinyin = "ZHUAN"; + break; + } + + if (code >= 5514 && code <= 5520) { + pinyin = "ZHUANG"; + break; + } + + if (code >= 5521 && code <= 5526) { + pinyin = "ZHUI"; + break; + } + + if (code >= 5527 && code <= 5528) { + pinyin = "ZHUN"; + break; + } + + if (code >= 5529 && code <= 5539) { + pinyin = "ZHUO"; + break; + } + + if (code >= 5540 && code <= 5554) { + pinyin = "ZI"; + break; + } + + if (code >= 5555 && code <= 5561) { + pinyin = "ZONG"; + break; + } + + if (code >= 5562 && code <= 5565) { + pinyin = "ZOU"; + break; + } + + if (code >= 5566 && code <= 5573) { + pinyin = "ZU"; + break; + } + + if (code >= 5574 && code <= 5575) { + pinyin = "ZUAN"; + break; + } + + if (code >= 5576 && code <= 5579) { + pinyin = "ZUI"; + break; + } + + if (code >= 5580 && code <= 5581) { + pinyin = "ZUN"; + break; + } + + if (code >= 5582 && code <= 5589) { + pinyin = "ZUO"; + break; + } + } + + if (pinyin.isEmpty()) { + pinyin = " "; + } + + return pinyin; +} + diff --git a/src/Interface/ukuichineseletter.h b/src/BackProcess/Interface/ukui_chineseletter.h old mode 100644 new mode 100755 similarity index 96% rename from src/Interface/ukuichineseletter.h rename to src/BackProcess/Interface/ukui_chineseletter.h index 749025c..c1da729 --- a/src/Interface/ukuichineseletter.h +++ b/src/BackProcess/Interface/ukui_chineseletter.h @@ -41,7 +41,7 @@ public: static QString getPinyin(int code); // 获取所有汉字的汉语拼音 - static QString getPinyins(const QString& text); + static QString getPinyins(const QString &text); }; #endif // UKUICHINESELETTER_H diff --git a/src/BackProcess/Interface/ukuimenuinterface.cpp b/src/BackProcess/Interface/ukuimenuinterface.cpp new file mode 100755 index 0000000..ed6718b --- /dev/null +++ b/src/BackProcess/Interface/ukuimenuinterface.cpp @@ -0,0 +1,1656 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include "ukui_chineseletter.h" + +UkuiMenuInterface::UkuiMenuInterface() +{ + if (!g_projectCodeName.contains("V10SP1-edu")) { + } else { + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + setting = new QSettings(path, QSettings::IniFormat); + QString syspath = QDir::homePath() + "/.config/ukui/menusysapplist.ini"; + syssetting = new QSettings(syspath, QSettings::IniFormat); + } +} + +QVector UkuiMenuInterface::appInfoVector = QVector(); +QVector UkuiMenuInterface::desktopfpVector = QVector(); +QVector UkuiMenuInterface::collectAppVector = QVector(); +QVector UkuiMenuInterface::alphabeticVector = QVector(); +QVector UkuiMenuInterface::functionalVector = QVector(); +QVector UkuiMenuInterface::allAppVector = QVector(); +QStringList UkuiMenuInterface::androidDesktopfnList = QStringList(); +QVector UkuiMenuInterface::tencentInitVector = QVector(); +QVector UkuiMenuInterface::customizedVector = QVector(); +QVector UkuiMenuInterface::thirdPartyVector = QVector(); +QVector UkuiMenuInterface::applicationVector = QVector(); + +UkuiMenuInterface::~UkuiMenuInterface() +{ + if (!g_projectCodeName.contains("V10SP1-edu")) { + } else { + if (setting) { + delete setting; + } + + if (syssetting) { + delete syssetting; + } + + setting = nullptr; + syssetting = nullptr; + } +} + +QStringList UkuiMenuInterface::getFunctionClassName() +{ + QStringList functionList; + functionList.append(QObject::tr("Office")); + functionList.append(QObject::tr("Development")); + functionList.append(QObject::tr("Image")); + functionList.append(QObject::tr("Video")); + functionList.append(QObject::tr("Internet")); + functionList.append(QObject::tr("Game")); + functionList.append(QObject::tr("Education")); + functionList.append(QObject::tr("Social")); + functionList.append(QObject::tr("System")); + functionList.append(QObject::tr("Safe")); + functionList.append(QObject::tr("Others")); + return functionList; +} +//文件递归查询 +void UkuiMenuInterface::recursiveSearchFile(const QString &_filePath) +{ + if (!g_projectCodeName.contains("V10SP1-edu")) { + QDir dir(_filePath); + + if (!dir.exists()) { + return; + } + + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + dir.setSorting(QDir::DirsFirst); + QFileInfoList list = dir.entryInfoList(); + + if (list.size() < 1) { + return; + } + + int i = 0; + + //递归算法的核心部分 + do { + QFileInfo fileInfo = list.at(i); + //如果是文件夹,递归 + bool isDir = fileInfo.isDir(); + + if (isDir) { + recursiveSearchFile(fileInfo.filePath()); + } else { + //过滤后缀不是.desktop的文件 + QString filePathStr = fileInfo.filePath(); + + if (!filePathStr.endsWith(".desktop")) { + i++; + continue; + } + + QByteArray fpbyte = filePathStr.toLocal8Bit(); + char *filepath = fpbyte.data(); + + if (0 != access(filepath, R_OK)) { //判断文件是否可读 + i++; + continue; + } + + keyfile = g_key_file_new(); + + if (!g_key_file_load_from_file(keyfile, filepath, flags, error)) { + return; + } + + char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); + + if (ret_1 != nullptr) { + QString str = QString::fromLocal8Bit(ret_1); + + if (str.contains("true")) { + g_key_file_free(keyfile); + i++; + continue; + } + } + + char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); + + if (ret_2 != nullptr) { + QString str = QString::fromLocal8Bit(ret_2); + + if (str.contains("UKUI")) { + g_key_file_free(keyfile); + i++; + continue; + } + } + + //过滤LXQt、KDE + char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); + + if (ret != nullptr) { + QString str = QString::fromLocal8Bit(ret); + + if (str.contains("LXQt") || str.contains("KDE")) { + g_key_file_free(keyfile); + i++; + continue; + } + } + + g_key_file_free(keyfile); + m_filePathList.append(filePathStr); + } + + i++; + } while (i < list.size()); + } else { + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QDir dir(_filePath); + + if (!dir.exists()) { + return; + } + + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + dir.setSorting(QDir::DirsFirst); + QFileInfoList list = dir.entryInfoList(); + list.removeAll(QFileInfo("/usr/share/applications/screensavers")); + + if (list.size() < 1) { + return; + } + + int i = 0; + + //递归算法的核心部分 + do { + QFileInfo fileInfo = list.at(i); + //如果是文件夹,递归 + bool isDir = fileInfo.isDir(); + + if (isDir) { + recursiveSearchFile(fileInfo.filePath()); + } else { + //过滤后缀不是.desktop的文件 + QString filePathStr = fileInfo.filePath(); + + if (!filePathStr.endsWith(".desktop")) { + i++; + continue; + } + + QByteArray fpbyte = filePathStr.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NoDisplay", nullptr, nullptr); + + if (ret_1 != nullptr) { + QString str = QString::fromLocal8Bit(ret_1); + + if (str.contains("true")) { + i++; + continue; + } + } + + char *ret_2 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "NotShowIn", nullptr, nullptr); + + if (ret_2 != nullptr) { + QString str = QString::fromLocal8Bit(ret_2); + + if (str.contains("UKUI")) { + i++; + continue; + } + } + + //过滤LXQt、KDE + char *ret = g_key_file_get_locale_string(keyfile, "Desktop Entry", "OnlyShowIn", nullptr, nullptr); + + if (ret != nullptr) { + QString str = QString::fromLocal8Bit(ret); + + if (str.contains("LXQt") || str.contains("KDE")) { + i++; + continue; + } + } + + //过滤中英文名为空的情况 + QLocale cn; + QString language = cn.languageToString(cn.language()); + + if (QString::compare(language, "Chinese") == 0) { + char *nameCh = g_key_file_get_string(keyfile, "Desktop Entry", "Name[zh_CN]", nullptr); + char *nameEn = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); + + if (QString::fromLocal8Bit(nameCh).isEmpty() && QString::fromLocal8Bit(nameEn).isEmpty()) { + i++; + continue; + } + } else { + char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); + + if (QString::fromLocal8Bit(name).isEmpty()) { + i++; + continue; + } + } + + m_filePathList.append(filePathStr); + } + + i++; + } while (i < list.size()); + + g_key_file_free(keyfile); + } +} + +//获取系统desktop文件路径 +QStringList UkuiMenuInterface::getDesktopFilePath() +{ + if (!g_projectCodeName.contains("V10SP1-edu")) { + m_filePathList.clear(); + QString jsonPath = QDir::homePath() + "/.config/ukui-menu-security-config.json"; + QFile file(jsonPath); + + if (file.exists()) { + file.open(QIODevice::ReadOnly); + QByteArray readBy = file.readAll(); + QJsonParseError error; + QJsonDocument readDoc = QJsonDocument::fromJson(readBy, &error); + + if (!readDoc.isNull() && error.error == QJsonParseError::NoError) { + QJsonObject obj = readDoc.object().value("ukui-menu").toObject(); + + if (obj.value("mode").toString() == "whitelist") { + QJsonArray blArray = obj.value("whitelist").toArray(); + QJsonArray enArray = blArray.at(0).toObject().value("entries").toArray(); + + for (int index = 0; index < enArray.size(); index++) { + QJsonObject obj = enArray.at(index).toObject(); + m_filePathList.append(obj.value("path").toString()); + // qDebug()< reply = desktopfpListiface.call("GetDesktopAppList",username); + //1、获取系统应用列表 + //filePathList; + QStringList ifFileDesktopList; + /*新的应用列表*/ + myDebug() << "sysapplistnum初始化默认应用列表" << m_filePathList.count(); + + for (int i = 0; i < m_filePathList.count(); i++) { //过滤 得到真实存在的应用 + QString tmp = m_filePathList.at(i); + QFileInfo fileInfo(tmp); + + if (!fileInfo.isFile()) { //判断是否存在 + //qDebug()<beginGroup("ukui-menu-sysapplist"); + int sysapplistnum = syssetting->allKeys().count(); + syssetting->sync(); + syssetting->endGroup(); + //qDebug()<<"sysapplistnum初始化默认应用列表3"<beginGroup("ukui-menu-sysapplist"); + myDebug() << "isnottencent" << str; + syssetting->setValue(str, 0); + syssetting->sync(); + syssetting->endGroup(); + } + }/*else{ + + //用户隔离/etc/skel/桌面 + QString tmp=QString("%1%2").arg("/usr/share/applications/").arg(str); + QString appid=getTencentAppid(tmp); + qDebug()<<"appid"< UkuiMenuInterface::createAppInfoVector() +{ + desktopfpVector.clear(); + QVector appInfoVector; + QVector vector; + vector.append(QStringList() << "office" << "Office" << "Calculator" << "Spreadsheet" << "Presentation" << "WordProcessor" << "TextEditor"); //0办公 + vector.append(QStringList() << "develop" << "Development"); //1开发 + vector.append(QStringList() << "graphic" << "Graphics"); //2图像 + vector.append(QStringList() << "video" << "Audio" << "Video"); //3影音 + vector.append(QStringList() << "network" << "Network"); //4网络 + vector.append(QStringList() << "game" << "Game"); //5游戏 + vector.append(QStringList() << "education" << "Education"); //6教育 + vector.append(QStringList() << "social" << "Messaging"); //7社交 + vector.append(QStringList() << "system" << "System" << "Settings" << "Security"); //8系统 + vector.append(QStringList() << "safe"); //9安全 + vector.append(QStringList() << "others"); //10其他 + QStringList desktopfpList = getDesktopFilePath(); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlQuery sql(db); + + for (int i = 0; i < desktopfpList.count(); i++) { + QStringList appInfoList; + QString desktopfp = desktopfpList.at(i); + QString name = getAppName(desktopfpList.at(i)); + + if (!name.isEmpty()) { + QString englishName = getAppEnglishName(desktopfpList.at(i)); + QString letter = getAppNameInitial(desktopfpList.at(i)); + QString letters = getAppNameInitials(desktopfpList.at(i)); + desktopfpVector.append(desktopfp); + appInfoList << desktopfp << name << englishName << letter << letters; + + if (!g_projectCodeName.contains("V10SP1-edu")) { + QString desktopfpExecName = getAppExec(desktopfpList.at(i)); + desktopfpExecName = desktopfpExecName.mid(desktopfpExecName.lastIndexOf("/") + 1); + desktopfpExecName = desktopfpExecName.left(desktopfpExecName.lastIndexOf(" ")); + sql.exec(QString("select name_zh from appCategory where app_name=\"%1\" ").arg(desktopfpExecName)); + + if (sql.next()) { + for (int j = 0; j < vector.size(); j++) { + if (vector.at(j).contains(sql.value(0).toString())) { + appInfoList.append(QString::number(j)); + } + } + + appInfoVector.append(appInfoList); + continue; + } + } + + bool is_owned = false; + + for (int j = 0; j < vector.size(); j++) { + if (matchingAppCategories(desktopfpList.at(i), vector.at(j))) { //有对应分类 + is_owned = true; + appInfoList.append(QString::number(j)); + } + } + + if (!is_owned) { //该应用无对应分类 + appInfoList.append(QString::number(10)); + } + + appInfoVector.append(appInfoList); + } + } + + return appInfoVector; +} +//获取tencent应用名 +QString UkuiMenuInterface::getTencentAppid(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *Appid = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Appid", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(Appid); +} +//获取应用名称 +QString UkuiMenuInterface::getAppName(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Name", nullptr, nullptr); + QString namestr = QString::fromLocal8Bit(name); + g_key_file_free(keyfile); + return namestr; +} +//获取英应用英文名 +QString UkuiMenuInterface::getAppEnglishName(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *name = g_key_file_get_string(keyfile, "Desktop Entry", "Name", nullptr); + QString namestr = QString::fromLocal8Bit(name); + return namestr; +} +//获取应用分类 +QString UkuiMenuInterface::getAppCategories(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *category = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(category); +} +//获取应用图标 +QString UkuiMenuInterface::getAppIcon(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *icon = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Icon", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(icon); +} +//获取应用命令 +QString UkuiMenuInterface::getAppExec(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *exec = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(exec); +} +//获取应用注释 +QString UkuiMenuInterface::getAppComment(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *comment = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Comment", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(comment); +} +//获取应用类型 +QString UkuiMenuInterface::getAppType(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *type = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Type", nullptr, nullptr); + g_key_file_free(keyfile); + return QString::fromLocal8Bit(type); +} +bool UkuiMenuInterface::cmpApp(QStringList &arg_1, QStringList &arg_2) +{ + QLocale local; + QString language = local.languageToString(local.language()); + + if (QString::compare(language, "Chinese") == 0) { + local = QLocale(QLocale::Chinese); + } else { + local = QLocale(QLocale::English); + } + + QCollator collator(local); + + if (collator.compare(arg_1.at(1), arg_2.at(1)) < 0) { + return true; + } else { + return false; + } +} +bool UkuiMenuInterface::initAppIni() +{ + if (false) { + QVector appInitVector; + QVector tencentInitVectorList; + QVector customizedVectorList; + QVector thirdPartyVectorList; + QString tencent_math = "/usr/share/applications/tencent-math-precise-practice.desktop"; + QString tencent_chinese = "/usr/share/applications/tencent-chinese-precise-practice.desktop"; + QString tencent_english = "/usr/share/applications/tencent-english-precise-practice.desktop"; + QVector precise_practiceVector; + QStringList math; + QStringList english; + QStringList chainese; + setting->beginGroup("application"); + QStringList desktopfnList = setting->allKeys(); + setting->endGroup(); + + if (desktopfnList.count() == 0) { + for (int i = 0; i < appInfoVector.count(); i++) { + //qDebug()<<"appInfoVector"<beginGroup("tencent"); + + for (int i = 0; i < tencentInitVectorList.count(); i++) { + QString str = tencentInitVectorList.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + //qDebug()<setValue(str, i); + } + + setting->sync(); + setting->endGroup(); + // int a=tencentInitVectorList.count(); + setting->beginGroup("customized"); + + for (int i = 0; i < customizedVectorList.count(); i++) { + QString str = customizedVectorList.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + setting->setValue(str, i); + } + + setting->sync(); + setting->endGroup(); + // int b=customizedVector.count(); + setting->beginGroup("thirdParty"); + + for (int i = 0; i < thirdPartyVectorList.count(); i++) { + QString str = thirdPartyVectorList.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + setting->setValue(str, i); + } + + setting->sync(); + setting->endGroup(); + // int c=thirdPartyVectorList.count(); + setting->beginGroup("application"); + + for (int i = 0; i < appInitVector.count(); i++) { //赋值 + QString str = appInitVector.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + setting->setValue(str, i); + } + + setting->sync(); + setting->endGroup(); + return 1; + } + + return 0; + } else { + QVector appInitVector; + QVector tencentInitVector; + QVector customizedVector; + QVector thirdPartyVector; + QVector preorderAppVector; + QString tencent_math = "/usr/share/applications/tencent-math-precise-practice.desktop"; + QString tencent_chinese = "/usr/share/applications/tencent-chinese-precise-practice.desktop"; + QString tencent_english = "/usr/share/applications/tencent-english-precise-practice.desktop"; + QString smallPluginManage = "/usr/share/applications/small-plugin-manage.desktop"; + QVector precise_practiceVector; + QStringList math; + QStringList english; + QStringList chainese; + setting->beginGroup("application"); + QStringList desktopfnList = setting->allKeys(); + setting->endGroup(); + + if (desktopfnList.count() == 0) { + for (int i = 0; i < desktopfpVector.count(); i++) { + //qDebug()<<"appInfoVector"<beginGroup("application"); + + for (int i = 0; i < preorderAppVector.count(); i++) { + QString str = preorderAppVector.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + //qDebug()<setValue(str, i); + } + + int firstVectorCount = preorderAppVector.count(); + + for (int i = 0; i < tencentInitVector.count(); i++) { + QString str = tencentInitVector.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + //qDebug()<setValue(str, i + firstVectorCount); + } + + int a = tencentInitVector.count(); + + for (int i = 0; i < customizedVector.count(); i++) { + QString str = customizedVector.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + setting->setValue(str, i + a); + } + + int b = customizedVector.count(); + + for (int i = 0; i < thirdPartyVector.count(); i++) { + QString str = thirdPartyVector.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + setting->setValue(str, i + a + b); + } + + int c = thirdPartyVector.count(); + + for (int i = 0; i < appInitVector.count(); i++) { //赋值 + QString str = appInitVector.at(i).at(0).section(' ', 0, 0); + QStringList list = str.split('/'); + str = list[list.size() - 1]; + setting->setValue(str, i + a + b + c); + } + + int d = appInitVector.count(); + setting->setValue("kylin-user-guide.desktop", a + b + c + d); + setting->sync(); + setting->endGroup(); + return 1; + } + + return 0; + } +} +QVector UkuiMenuInterface::getAllClassification() +{ + QVector allAppVector; + QVector commonVector; + QVector appVector; + allAppVector.clear(); + commonVector.clear(); + appVector.clear(); + commonVector = getCommonUseApp(); + int index = 0; + + Q_FOREACH (QString desktopfp, desktopfpVector) { + if (!commonVector.contains(desktopfp)) { + appVector.append(appInfoVector.at(index)); + } + + index++; + } + + qSort(appVector.begin(), appVector.end(), cmpApp); + + Q_FOREACH (QString desktopfp, commonVector) { + allAppVector.append(desktopfp); + } + + for (int index = 0; index < appVector.size(); index++) { + allAppVector.append(appVector.at(index).at(0)); + } + + return allAppVector; +} +QVector UkuiMenuInterface::getCommonUseApp() +{ + // QDateTime dt=QDateTime::currentDateTime(); + // int currentDateTime=dt.toTime_t(); + // int nDaySec=24*60*60; + // setting->beginGroup("datetime"); + // QStringList dateTimeKeys=setting->allKeys(); + // QStringList timeOutKeys; + // timeOutKeys.clear(); + // for(int i=0;ivalue(dateTimeKeys.at(i)).toInt())/nDaySec >= 4) + // { + // timeOutKeys.append(dateTimeKeys.at(i)); + // } + // } + // setting->endGroup(); + // for(int i=0;ibeginGroup("application"); + // setting->remove(timeOutKeys.at(i)); + // setting->sync(); + // setting->endGroup(); + // setting->beginGroup("datetime"); + // setting->remove(timeOutKeys.at(i)); + // setting->sync(); + // setting->endGroup(); + // } + // setting->beginGroup("lockapplication"); + // QStringList lockdesktopfnList=setting->allKeys(); + // for(int i=0;ivalue(lockdesktopfnList.at(j)).toInt(); + // int value_2=setting->value(lockdesktopfnList.at(j+1)).toInt(); + // if(value_1 > value_2) + // { + // QString tmp=lockdesktopfnList.at(j); + // lockdesktopfnList.replace(j,lockdesktopfnList.at(j+1)); + // lockdesktopfnList.replace(j+1,tmp); + // } + // } + // setting->endGroup(); + // setting->beginGroup("application"); + // QStringList desktopfnList=setting->allKeys(); + // for(int i=0;ivalue(desktopfnList.at(j)).toInt(); + // int value_2=setting->value(desktopfnList.at(j+1)).toInt(); + // if(value_1 < value_2) + // { + // QString tmp=desktopfnList.at(j); + // desktopfnList.replace(j,desktopfnList.at(j+1)); + // desktopfnList.replace(j+1,tmp); + // } + // } + // setting->endGroup(); + // QVector data; + // Q_FOREACH(QString desktopfn,lockdesktopfnList) + // { + // QString desktopfp; + // if(androidDesktopfnList.contains(desktopfn)) + // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); + // else + // desktopfp=QString("/usr/share/applications/"+desktopfn); + // QFileInfo fileInfo(desktopfp); + // if(!fileInfo.isFile()|| !desktopfpVector.contains(desktopfp)) + // continue; + // data.append(desktopfp); + // } + // Q_FOREACH(QString desktopfn,desktopfnList) + // { + // QString desktopfp; + // if(androidDesktopfnList.contains(desktopfn)) + // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); + // else + // desktopfp=QString("/usr/share/applications/"+desktopfn); + // QFileInfo fileInfo(desktopfp); + // if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) + // continue; + // data.append(desktopfp); + // } + if (!g_projectCodeName.contains("V10SP1-edu")) { + QVector data; + + Q_FOREACH (QString desktopfn, getLockAppList()) { + QString desktopfp; + + if (androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + QFileInfo fileInfo(desktopfp); + + if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { + continue; + } + + data.append(desktopfp); + } + + Q_FOREACH (QString desktopfn, getUnlockAllList()) { + QString desktopfp; + + if (androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + QFileInfo fileInfo(desktopfp); + + if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { + continue; + } + + data.append(desktopfp); + } + + return data; + } +} + +QVector UkuiMenuInterface::sortDesktopList(QString group) +{ + setting->beginGroup(group); + QStringList desktopfnList = setting->allKeys(); + + for (int i = 0; i < desktopfnList.count() - 1; i++) + for (int j = 0; j < desktopfnList.count() - 1 - i; j++) { //冒泡排序常用的应用从大到小排列desktopfnList + int value_1 = setting->value(desktopfnList.at(j)).toInt(); + int value_2 = setting->value(desktopfnList.at(j + 1)).toInt(); + + if (value_1 > value_2) { + QString tmp = desktopfnList.at(j); + desktopfnList.replace(j, desktopfnList.at(j + 1)); + desktopfnList.replace(j + 1, tmp); + } + } + + setting->sync(); + setting->endGroup(); + QVector data; + + Q_FOREACH (QString desktopfn, desktopfnList) { + QString desktopfp; + + if (androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + data.append(desktopfp); + } + + return data; +} +QVector UkuiMenuInterface::getCollectApp() +{ + QVector data; + + Q_FOREACH (QString desktopfn, getCollectAppList()) { + QString desktopfp; + + if (androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + + QFileInfo fileInfo(desktopfp); + + if (!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) { + continue; + } + + data.append(desktopfp); + } + + return data; +} +QVector UkuiMenuInterface::getLockApp() +{ + setting->beginGroup("lockapplication"); + QStringList lockdesktopfnList = setting->allKeys(); + + for (int i = 0; i < lockdesktopfnList.count() - 1; i++) //冒泡排序锁住的应用从小到大排列lockdesktopfnList + for (int j = 0; j < lockdesktopfnList.count() - 1 - i; j++) { + int value_1 = setting->value(lockdesktopfnList.at(j)).toInt(); + int value_2 = setting->value(lockdesktopfnList.at(j + 1)).toInt(); + + if (value_1 > value_2) { + QString tmp = lockdesktopfnList.at(j); + lockdesktopfnList.replace(j, lockdesktopfnList.at(j + 1)); + lockdesktopfnList.replace(j + 1, tmp); + } + } + + setting->endGroup(); + QVector data; + + Q_FOREACH (QString desktopfn, lockdesktopfnList) { + QString desktopfp; + // if(androidDesktopfnList.contains(desktopfn))//如果锁的应用在安卓列表 + // desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); + // else + desktopfp = QString("/usr/share/applications/" + desktopfn); + // QFileInfo fileInfo(desktopfp); + // if(!fileInfo.isFile())//判断是否存在 + // continue; + data.append(desktopfp);//加入data + } + + return data; +} +QVector UkuiMenuInterface::getAlphabeticClassification() +{ + QVector data; + QStringList appnameList; + appnameList.clear(); + QVector appVector[27]; + int index = 0; + + while (index < appInfoVector.size()) { + QString appname = appInfoVector.at(index).at(1); + QString appnamepy = UkuiChineseLetter::getPinyins(appname); + + if (!appnamepy.isEmpty()) { + char c = appnamepy.at(0).toLatin1(); + + switch (c) { + case 'A': + appVector[0].append(appInfoVector.at(index)); + break; + + case 'B': + appVector[1].append(appInfoVector.at(index)); + break; + + case 'C': + appVector[2].append(appInfoVector.at(index)); + break; + + case 'D': + appVector[3].append(appInfoVector.at(index)); + break; + + case 'E': + appVector[4].append(appInfoVector.at(index)); + break; + + case 'F': + appVector[5].append(appInfoVector.at(index)); + break; + + case 'G': + appVector[6].append(appInfoVector.at(index)); + break; + + case 'H': + appVector[7].append(appInfoVector.at(index)); + break; + + case 'I': + appVector[8].append(appInfoVector.at(index)); + break; + + case 'J': + appVector[9].append(appInfoVector.at(index)); + break; + + case 'K': + appVector[10].append(appInfoVector.at(index)); + break; + + case 'L': + appVector[11].append(appInfoVector.at(index)); + break; + + case 'M': + appVector[12].append(appInfoVector.at(index)); + break; + + case 'N': + appVector[13].append(appInfoVector.at(index)); + break; + + case 'O': + appVector[14].append(appInfoVector.at(index)); + break; + + case 'P': + appVector[15].append(appInfoVector.at(index)); + break; + + case 'Q': + appVector[16].append(appInfoVector.at(index)); + break; + + case 'R': + appVector[17].append(appInfoVector.at(index)); + break; + + case 'S': + appVector[18].append(appInfoVector.at(index)); + break; + + case 'T': + appVector[19].append(appInfoVector.at(index)); + break; + + case 'U': + appVector[20].append(appInfoVector.at(index)); + break; + + case 'V': + appVector[21].append(appInfoVector.at(index)); + break; + + case 'W': + appVector[22].append(appInfoVector.at(index)); + break; + + case 'X': + appVector[23].append(appInfoVector.at(index)); + break; + + case 'Y': + appVector[24].append(appInfoVector.at(index)); + break; + + case 'Z': + appVector[25].append(appInfoVector.at(index)); + break; + + default: + appVector[26].append(appInfoVector.at(index)); + break; + } + } + + index++; + } + + for (int i = 0; i < 26; i++) { + QStringList desktopfpList; + desktopfpList.clear(); + qSort(appVector[i].begin(), appVector[i].end(), cmpApp); + + for (int j = 0; j < appVector[i].size(); j++) { + desktopfpList.append(appVector[i].at(j).at(0)); + } + + data.append(desktopfpList); + } + + QVector otherVector; + QVector numberVector; + + for (int i = 0; i < appVector[26].count(); i++) { + QString appname = appVector[26].at(i).at(2); + QChar c = appname.at(0); + + if (c < 48 || (c > 57 && c < 65) || c > 90) { + otherVector.append(appVector[26].at(i)); + } else { + numberVector.append(appVector[26].at(i)); + } + } + + qSort(otherVector.begin(), otherVector.end(), cmpApp); + qSort(numberVector.begin(), numberVector.end(), cmpApp); + QStringList otherfpList; + otherfpList.clear(); + + for (int i = 0; i < otherVector.size(); i++) { + otherfpList.append(otherVector.at(i).at(0)); + } + + QStringList numberfpList; + numberfpList.clear(); + + for (int i = 0; i < numberVector.size(); i++) { + numberfpList.append(numberVector.at(i).at(0)); + } + + data.append(otherfpList); + data.append(numberfpList); + return data; +} +QVector UkuiMenuInterface::getFunctionalClassification() +{ + QVector appVector[11]; + int index = 0; + + while (index < appInfoVector.size()) { + int count = appInfoVector.at(index).size() - 5; + + for (int i = 0; i < count; i++) { + int category = appInfoVector.at(index).at(5 + i).toInt(); + + switch (category) { + case 0: + appVector[0].append(appInfoVector.at(index)); + break; + + case 1: + appVector[1].append(appInfoVector.at(index)); + break; + + case 2: + appVector[2].append(appInfoVector.at(index)); + break; + + case 3: + appVector[3].append(appInfoVector.at(index)); + break; + + case 4: + appVector[4].append(appInfoVector.at(index)); + break; + + case 5: + appVector[5].append(appInfoVector.at(index)); + break; + + case 6: + appVector[6].append(appInfoVector.at(index)); + break; + + case 7: + appVector[7].append(appInfoVector.at(index)); + break; + + case 8: + appVector[8].append(appInfoVector.at(index)); + break; + + case 9: + appVector[9].append(appInfoVector.at(index)); + break; + + case 10: + appVector[10].append(appInfoVector.at(index)); + break; + + default: + break; + } + } + + index++; + } + + QVector data; + data.clear(); + + for (int i = 0; i < 11; i++) { + QStringList desktopfpList; + desktopfpList.clear(); + qSort(appVector[i].begin(), appVector[i].end(), cmpApp); + + for (int j = 0; j < appVector[i].size(); j++) { + desktopfpList.append(appVector[i].at(j).at(0)); + } + + data.append(desktopfpList); + } + + return data; +} +bool UkuiMenuInterface::matchingAppCategories(QString desktopfp, QStringList categorylist) +{ + QString category = getAppCategories(desktopfp); + int index; + + for (index = 0; index < categorylist.count(); index++) { + if (category.contains(categorylist.at(index), Qt::CaseInsensitive)) { + return true; + } + } + + if (index == categorylist.count()) { + return false; + } + + return false; +} +void UkuiMenuInterface::getAndroidApp() +{ + androidDesktopfnList.clear(); + QVector androidVector; + androidVector.clear(); + QString path = QDir::homePath() + "/.local/share/applications/"; + QDir dir(path); + + if (!dir.exists()) { + return; + } + + dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); + dir.setSorting(QDir::DirsFirst); + QFileInfoList list = dir.entryInfoList(); + + if (list.size() < 1) { + return; + } + + int i = 0; + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + + do { + QFileInfo fileInfo = list.at(i); + + if (!fileInfo.isFile()) { + i++; + continue; + } + + //过滤后缀不是.desktop的文件 + QString filePathStr = fileInfo.filePath(); + + if (!filePathStr.endsWith(".desktop")) { + i++; + continue; + } + + QByteArray fpbyte = filePathStr.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *ret_1 = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Categories", nullptr, nullptr); + + if (ret_1 != nullptr) { + // QString str=QString::fromLocal8Bit(ret_1); + // if(!str.contains("Android")) + // { + // i++; + // continue; + // } + // else + // { + m_filePathList.append(filePathStr); + androidDesktopfnList.append(fileInfo.fileName()); + // } + } + + i++; + } while (i < list.size()); + + g_key_file_free(keyfile); +} +QString UkuiMenuInterface::getAppNameInitials(QString desktopfp) +{ + QString firstLetters; + QString appname = getAppName(desktopfp); + QStringList appnamestr = appname.split(" "); + QString letters; + + Q_FOREACH (QString name, appnamestr) { + letters.clear(); + letters = UkuiChineseLetter::getFirstLettersAll(name); + + if (letters.isEmpty()) { + letters = UkuiChineseLetter::getFirstLetter(name); + } + + firstLetters.append(letters); + } + + return firstLetters; +} +QString UkuiMenuInterface::getAppNameInitial(QString desktopfp) +{ + return UkuiChineseLetter::getFirstLetter(getAppName(desktopfp)); +} +//获取应用拼音 +QString UkuiMenuInterface::getAppNamePinyin(QString appname) +{ + return UkuiChineseLetter::getPinyins(appname); +} +bool UkuiMenuInterface::checkKreApp(QString desktopfp) +{ + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *value = g_key_file_get_locale_string(keyfile, "Desktop Entry", "environment", nullptr, nullptr); + g_key_file_free(keyfile); + + if (!value) { + return false; + } else if (QString::compare(QString::fromLocal8Bit(value), "kre-environment") == 0) { + return true; + } + + return false; +} +//获取指定类型应用列表 +QStringList UkuiMenuInterface::getSpecifiedCategoryAppList(QString categorystr) +{ + QByteArray categorybyte = categorystr.toLocal8Bit(); + char *category = categorybyte.data(); + QStringList desktopfpList = getDesktopFilePath(); + QStringList appnameList; + appnameList.clear(); + + for (int index = 0; index < desktopfpList.count(); index++) { + QString appcategorystr = getAppCategories(desktopfpList.at(index)); + + if (!appcategorystr.isEmpty()) { + QByteArray appcategorybyte = appcategorystr.toLocal8Bit(); + char *appcategory = appcategorybyte.data(); + int len = static_cast(strlen(appcategory) - 6); + + for (int i = 0; i < len; i++) { + if (strncmp(appcategory + i, category, strlen(category)) == 0) { + QString appname = getAppName(desktopfpList.at(index)); + + if (QString::compare(appname, "访问提示") == 0) { + appnameList.append(appname); + } + + break; + } + } + } + } + + return appnameList; +} diff --git a/src/Interface/ukuimenuinterface.h b/src/BackProcess/Interface/ukuimenuinterface.h old mode 100644 new mode 100755 similarity index 71% rename from src/Interface/ukuimenuinterface.h rename to src/BackProcess/Interface/ukuimenuinterface.h index c241c27..1c8ca58 --- a/src/Interface/ukuimenuinterface.h +++ b/src/BackProcess/Interface/ukuimenuinterface.h @@ -27,18 +27,19 @@ #include #include #include +#include "utility.h" class UkuiMenuInterface { private: - QStringList filePathList; + QStringList m_filePathList; - GError** error=nullptr; - GKeyFileFlags flags=G_KEY_FILE_NONE; - GKeyFile* keyfile=nullptr; + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = nullptr; protected: - void recursiveSearchFile(const QString& _filePath);//遍历/usr/share/applications/文件夹 + void recursiveSearchFile(const QString &_filePath);//遍历/usr/share/applications/文件夹 QStringList getSpecifiedCategoryAppList(QString categorystr);//获取指定类型应用列表 public: @@ -50,8 +51,14 @@ public: static QVector alphabeticVector; static QVector functionalVector; static QVector allAppVector; + static QVector collectAppVector; static QStringList androidDesktopfnList; + static QVector tencentInitVector; + static QVector customizedVector; + static QVector thirdPartyVector; + static QVector applicationVector; + /** * 获取系统应用名称 * @param desktopfp 为应用.desktop文件所在路径 @@ -64,19 +71,31 @@ public: QString getAppExec(QString desktopfp);//获取应用命令 QString getAppType(QString desktopfp);//获取应用类型 QString getAppComment(QString desktopfp);//获取应用注释 - QStringList getDesktopFilePath();//获取系统deskyop文件路径 - + QStringList getDesktopFilePath();//获取系统desktop文件路径 + QStringList getFunctionClassName();//获取功能类别名称 + QVector getCollectApp();//获取收藏应用 QVector getAlphabeticClassification();//字母分类模块 QVector getFunctionalClassification();//功能分类模块 QVector getCommonUseApp();//获取常用App QVector getAllClassification();//所有软件模块 void getAndroidApp();//获取安卓应用 - static bool cmpApp(QStringList &arg_1,QStringList &arg_2); - bool matchingAppCategories(QString desktopfp,QStringList categorylist);//匹配应用Categories + static bool cmpApp(QStringList &arg_1, QStringList &arg_2); + bool matchingAppCategories(QString desktopfp, QStringList categorylist); //匹配应用Categories QString getAppNameInitials(QString desktopfp);//获取应用名所有首字母 QString getAppNameInitial(QString desktopfp);//获取应用名所有首字母 QString getAppNamePinyin(QString appname);//获取应用名拼音 bool checkKreApp(QString desktopfp); + + QStringList getInstalledAppList(); + QString getTencentAppid(QString desktopfp); + bool initAppIni(); + QVector getAllApp(); + QVector getLockApp(); + QVector sortDesktopList(QString group); + + /**/ + QSettings *setting = nullptr; + QSettings *syssetting = nullptr; }; #endif // UKUIMENUINTERFACE_H diff --git a/src/SearchResultWidget/file-utils.cpp b/src/BackProcess/Search/file-utils.cpp old mode 100644 new mode 100755 similarity index 68% rename from src/SearchResultWidget/file-utils.cpp rename to src/BackProcess/Search/file-utils.cpp index 06f1bf9..81130d7 --- a/src/SearchResultWidget/file-utils.cpp +++ b/src/BackProcess/Search/file-utils.cpp @@ -22,39 +22,42 @@ #include "file-utils.h" #include -using namespace Zeeker; QMap FileUtils::map_chinese2pinyin = QMap(); -FileUtils::FileUtils() { +FileUtils::FileUtils() +{ } -void FileUtils::loadHanziTable(const QString &fileName) { +void FileUtils::loadHanziTable(const QString &fileName) +{ QFile file(fileName); - if(!file.open(QFile::ReadOnly | QFile::Text)) { + + if (!file.open(QFile::ReadOnly | QFile::Text)) { qDebug("File: '%s' open failed!", file.fileName().toStdString().c_str()); return; } /* 读取汉字对照表文件并转换为QMap存储 */ - while(!file.atEnd()) { + while (!file.atEnd()) { QString content = QString::fromUtf8(file.readLine()); FileUtils::map_chinese2pinyin[content.split(" ").last().trimmed()] = content.split(" ").first().split(","); } file.close(); - return; } //DFS多音字太多直接GG -void stitchMultiToneWordsDFS(const QString& hanzi, const QString& resultAllPinYin, const QString& resultFirst, QStringList& resultList) { - if(hanzi.size() == 0) { +void stitchMultiToneWordsDFS(const QString &hanzi, const QString &resultAllPinYin, const QString &resultFirst, QStringList &resultList) +{ + if (hanzi.size() == 0) { resultList.append(resultAllPinYin); resultList.append(resultFirst); return; } - if(FileUtils::map_chinese2pinyin.contains(hanzi.at(0))) { - for(auto i : FileUtils::map_chinese2pinyin[hanzi.at(0)]) { + + if (FileUtils::map_chinese2pinyin.contains(hanzi.at(0))) { + for (auto i : FileUtils::map_chinese2pinyin[hanzi.at(0)]) { stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), resultAllPinYin + i, resultFirst + i.at(0), resultList); } } else { @@ -63,98 +66,119 @@ void stitchMultiToneWordsDFS(const QString& hanzi, const QString& resultAllPinYi } //BFS+Stack多音字太多会爆栈 -void stitchMultiToneWordsBFSStack(const QString& hanzi, QStringList& resultList) { +void stitchMultiToneWordsBFSStack(const QString &hanzi, QStringList &resultList) +{ QString tempHanzi, resultAllPinYin, resultFirst; QQueue tempQueue; tempHanzi = hanzi; int tempQueueSize = 0; - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(i); } } else { tempQueue.enqueue(tempHanzi.at(0)); } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - while(tempHanzi.size() != 0) { + + while (tempHanzi.size() != 0) { tempQueueSize = tempQueue.size(); - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(int j = 0; j < tempQueueSize; ++j) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (int j = 0; j < tempQueueSize; ++j) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(tempQueue.head() + i); } + tempQueue.dequeue(); } } else { - for(int j = 0; j < tempQueueSize; ++j) { + for (int j = 0; j < tempQueueSize; ++j) { tempQueue.enqueue(tempQueue.head() + tempHanzi.at(0)); tempQueue.dequeue(); } } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - while(!tempQueue.empty()) { + + while (!tempQueue.empty()) { resultList.append(tempQueue.dequeue()); } } //BFS+Heap,多音字太多会耗尽内存 -void stitchMultiToneWordsBFSHeap(const QString& hanzi, QStringList& resultList) { +void stitchMultiToneWordsBFSHeap(const QString &hanzi, QStringList &resultList) +{ QString tempHanzi, resultAllPinYin, resultFirst; - QQueue* tempQueue = new QQueue; + QQueue *tempQueue = new QQueue; tempHanzi = hanzi; int tempQueueSize = 0; - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(i); } } else { tempQueue->enqueue(tempHanzi.at(0)); } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - while(tempHanzi.size() != 0) { + + while (tempHanzi.size() != 0) { tempQueueSize = tempQueue->size(); - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(int j = 0; j < tempQueueSize; ++j) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (int j = 0; j < tempQueueSize; ++j) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(tempQueue->head() + i); } + tempQueue->dequeue(); } } else { - for(int j = 0; j < tempQueueSize; ++j) { + for (int j = 0; j < tempQueueSize; ++j) { tempQueue->enqueue(tempQueue->head() + tempHanzi.at(0)); tempQueue->dequeue(); } } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - while(!tempQueue->empty()) { + + while (!tempQueue->empty()) { resultList.append(tempQueue->dequeue()); } + delete tempQueue; tempQueue = nullptr; } //BFS+Heap+超过3个多音字只建一个索引,比较折中的方案 -void stitchMultiToneWordsBFSHeapLess3(const QString& hanzi, QStringList& resultList) { +void stitchMultiToneWordsBFSHeapLess3(const QString &hanzi, QStringList &resultList) +{ QString tempHanzi, resultAllPinYin, resultFirst; - QQueue* tempQueue = new QQueue; - QQueue* tempQueueFirst = new QQueue; + QQueue *tempQueue = new QQueue; + QQueue *tempQueueFirst = new QQueue; tempHanzi = hanzi; int tempQueueSize = 0; int multiToneWordNum = 0; - for(auto i : hanzi) { - if(FileUtils::map_chinese2pinyin.contains(i)) { - if(FileUtils::map_chinese2pinyin[i].size() > 1) { + + for (auto i : hanzi) { + if (FileUtils::map_chinese2pinyin.contains(i)) { + if (FileUtils::map_chinese2pinyin[i].size() > 1) { ++multiToneWordNum; } } } - if(multiToneWordNum > 3) { + + if (multiToneWordNum > 3) { QString oneResult, oneResultFirst; - for(auto i : hanzi) { - if(FileUtils::map_chinese2pinyin.contains(i)) { + + for (auto i : hanzi) { + if (FileUtils::map_chinese2pinyin.contains(i)) { oneResult += FileUtils::map_chinese2pinyin[i].first(); oneResultFirst += FileUtils::map_chinese2pinyin[i].first().at(0); } else { @@ -162,13 +186,14 @@ void stitchMultiToneWordsBFSHeapLess3(const QString& hanzi, QStringList& resultL oneResultFirst += i; } } + resultList.append(oneResult); resultList.append(oneResultFirst); return; } - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(i); tempQueueFirst->enqueue(i.at(0)); } @@ -176,32 +201,39 @@ void stitchMultiToneWordsBFSHeapLess3(const QString& hanzi, QStringList& resultL tempQueue->enqueue(tempHanzi.at(0)); tempQueueFirst->enqueue(tempHanzi.at(0)); } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - while(tempHanzi.size() != 0) { + + while (tempHanzi.size() != 0) { tempQueueSize = tempQueue->size(); - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(int j = 0; j < tempQueueSize; ++j) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (int j = 0; j < tempQueueSize; ++j) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue->enqueue(tempQueue->head() + i); tempQueueFirst->enqueue(tempQueueFirst->head() + i.at(0)); } + tempQueue->dequeue(); tempQueueFirst->dequeue(); } } else { - for(int j = 0; j < tempQueueSize; ++j) { + for (int j = 0; j < tempQueueSize; ++j) { tempQueue->enqueue(tempQueue->head() + tempHanzi.at(0)); tempQueueFirst->enqueue(tempQueueFirst->head() + tempHanzi.at(0)); tempQueue->dequeue(); tempQueueFirst->dequeue(); } } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - while(!tempQueue->empty()) { + + while (!tempQueue->empty()) { resultList.append(tempQueue->dequeue()); resultList.append(tempQueueFirst->dequeue()); } + delete tempQueue; delete tempQueueFirst; tempQueue = nullptr; @@ -210,24 +242,28 @@ void stitchMultiToneWordsBFSHeapLess3(const QString& hanzi, QStringList& resultL } //BFS+Stack+超过3个多音字只建一个索引,比较折中的方案 -void stitchMultiToneWordsBFSStackLess3(const QString& hanzi, QStringList& resultList) { +void stitchMultiToneWordsBFSStackLess3(const QString &hanzi, QStringList &resultList) +{ QString tempHanzi, resultAllPinYin, resultFirst; QQueue tempQueue; QQueue tempQueueFirst; tempHanzi = hanzi; int tempQueueSize = 0; int multiToneWordNum = 0; - for(auto i : hanzi) { - if(FileUtils::map_chinese2pinyin.contains(i)) { - if(FileUtils::map_chinese2pinyin[i].size() > 1) { + + for (auto i : hanzi) { + if (FileUtils::map_chinese2pinyin.contains(i)) { + if (FileUtils::map_chinese2pinyin[i].size() > 1) { ++multiToneWordNum; } } } - if(multiToneWordNum > 3) { + + if (multiToneWordNum > 3) { QString oneResult, oneResultFirst; - for(auto i : hanzi) { - if(FileUtils::map_chinese2pinyin.contains(i)) { + + for (auto i : hanzi) { + if (FileUtils::map_chinese2pinyin.contains(i)) { oneResult += FileUtils::map_chinese2pinyin[i].first(); oneResultFirst += FileUtils::map_chinese2pinyin[i].first().at(0); } else { @@ -235,13 +271,14 @@ void stitchMultiToneWordsBFSStackLess3(const QString& hanzi, QStringList& result oneResultFirst += i; } } + resultList.append(oneResult); resultList.append(oneResultFirst); return; } - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(i); tempQueueFirst.enqueue(i.at(0)); } @@ -249,32 +286,39 @@ void stitchMultiToneWordsBFSStackLess3(const QString& hanzi, QStringList& result tempQueue.enqueue(tempHanzi.at(0)); tempQueueFirst.enqueue(tempHanzi.at(0)); } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); - while(tempHanzi.size() != 0) { + + while (tempHanzi.size() != 0) { tempQueueSize = tempQueue.size(); - if(FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { - for(int j = 0; j < tempQueueSize; ++j) { - for(auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { + + if (FileUtils::map_chinese2pinyin.contains(tempHanzi.at(0))) { + for (int j = 0; j < tempQueueSize; ++j) { + for (auto i : FileUtils::map_chinese2pinyin[tempHanzi.at(0)]) { tempQueue.enqueue(tempQueue.head() + i); tempQueueFirst.enqueue(tempQueueFirst.head() + i.at(0)); } + tempQueue.dequeue(); tempQueueFirst.dequeue(); } } else { - for(int j = 0; j < tempQueueSize; ++j) { + for (int j = 0; j < tempQueueSize; ++j) { tempQueue.enqueue(tempQueue.head() + tempHanzi.at(0)); tempQueueFirst.enqueue(tempQueueFirst.head() + tempHanzi.at(0)); tempQueue.dequeue(); tempQueueFirst.dequeue(); } } + tempHanzi = tempHanzi.right(tempHanzi.size() - 1); } - while(!tempQueue.empty()) { + + while (!tempQueue.empty()) { resultList.append(tempQueue.dequeue()); resultList.append(tempQueueFirst.dequeue()); } + // delete tempQueue; // delete tempQueueFirst; // tempQueue = nullptr; @@ -282,12 +326,12 @@ void stitchMultiToneWordsBFSStackLess3(const QString& hanzi, QStringList& result return; } -QStringList FileUtils::findMultiToneWords(const QString& hanzi) { +QStringList FileUtils::findMultiToneWords(const QString &hanzi) +{ // QStringList* output = new QStringList(); QStringList output; QString tempAllPinYin, tempFirst; QStringList stringList = hanzi.split(""); - // stitchMultiToneWordsDFS(hanzi, tempAllPinYin, tempFirst, output); stitchMultiToneWordsBFSStackLess3(hanzi, output); // qDebug() << output; diff --git a/src/SearchResultWidget/file-utils.h b/src/BackProcess/Search/file-utils.h old mode 100644 new mode 100755 similarity index 90% rename from src/SearchResultWidget/file-utils.h rename to src/BackProcess/Search/file-utils.h index 097055c..1621f00 --- a/src/SearchResultWidget/file-utils.h +++ b/src/BackProcess/Search/file-utils.h @@ -40,19 +40,17 @@ #define MAX_CONTENT_LENGTH 20480000 -namespace Zeeker { -class FileUtils { +class FileUtils +{ public: //chinese character to pinyin static QMap map_chinese2pinyin; - static QStringList findMultiToneWords(const QString&); - static void loadHanziTable(const QString&); + static QStringList findMultiToneWords(const QString &); + static void loadHanziTable(const QString &); private: FileUtils(); }; -} - #endif // FILEUTILS_H diff --git a/src/SearchResultWidget/pinyinWithTone.txt b/src/BackProcess/Search/pinyinWithTone.txt old mode 100644 new mode 100755 similarity index 100% rename from src/SearchResultWidget/pinyinWithTone.txt rename to src/BackProcess/Search/pinyinWithTone.txt diff --git a/src/SearchResultWidget/pinyinWithoutTone.txt b/src/BackProcess/Search/pinyinWithoutTone.txt old mode 100644 new mode 100755 similarity index 100% rename from src/SearchResultWidget/pinyinWithoutTone.txt rename to src/BackProcess/Search/pinyinWithoutTone.txt diff --git a/src/BackProcess/Search/searchappthread.cpp b/src/BackProcess/Search/searchappthread.cpp new file mode 100755 index 0000000..128aeed --- /dev/null +++ b/src/BackProcess/Search/searchappthread.cpp @@ -0,0 +1,107 @@ +/* + * 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 +#include "file-utils.h" + +SearchAppThread::SearchAppThread() +{ + m_ukuiMenuInterface = new UkuiMenuInterface; +} + +SearchAppThread::~SearchAppThread() +{ + delete m_ukuiMenuInterface; +} + +void SearchAppThread::run() +{ + m_appInfoVector.clear(); + m_appInfoVector = UkuiMenuInterface::appInfoVector; + m_searchResultVector.clear(); + m_searchFirstVector.clear(); + m_searchRestVector.clear(); + + if (!this->m_keyWord.isEmpty()) { + QString str = m_ukuiMenuInterface->getAppNamePinyin(m_keyWord); + int index = 0; + + while (index < m_appInfoVector.size()) { + QString appName = m_appInfoVector.at(index).at(1); + QString appEnglishName = m_appInfoVector.at(index).at(2); + QStringList appNameLs; //中文音标全拼列表 + QStringList appNameFls; //中文拼音首字母简拼列表 + QStringList appNamePyLst = FileUtils::findMultiToneWords(appName); //获取中文拼音列表 + + for (int i = 0; i < appNamePyLst.size() / 2; i++) { + appNameLs.append(appNamePyLst.at(i * 2)); + appNameFls.append(appNamePyLst.at(i * 2 + 1)); + } + + if (m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+"))) { //中文正则表达式 + if (appName.toUpper().contains(m_keyWord.toUpper())) { + m_searchResultVector.append(m_appInfoVector.at(index)); + } + } else { + for (int var = 0; var < appNameLs.size(); ++var) { + if (appNameLs[var].left(str.length()).contains(str, Qt::CaseInsensitive) || + appNameFls[var].left(str.length()).contains(str, Qt::CaseInsensitive)) { + //按照顺序从首字母开始严格匹配查找 + m_searchFirstVector.append(m_appInfoVector.at(index)); + break; + } else if (appNameLs[var].contains(str, Qt::CaseInsensitive) || + appNameFls[var].contains(str, Qt::CaseInsensitive) || + appEnglishName.contains(str, Qt::CaseInsensitive)) { + //只要应用名存在包含输入信息就匹配 + m_searchRestVector.append(m_appInfoVector.at(index)); + break; + } + } + } + + index++; + } + } + + qSort(m_searchFirstVector.begin(), m_searchFirstVector.end(), UkuiMenuInterface::cmpApp); + qSort(m_searchRestVector.begin(), m_searchRestVector.end(), UkuiMenuInterface::cmpApp); + + //对中文搜索结果进行排序 + if (m_searchResultVector.size() != 0) { + qSort(m_searchResultVector.begin(), m_searchResultVector.end(), UkuiMenuInterface::cmpApp); + } + + //优先将严格匹配结果加入列表 + for (int i = 0; i < m_searchFirstVector.size(); i++) { + m_searchResultVector.append(m_searchFirstVector.at(i)); + } + + //将模糊匹配结果加入列表 + for (int i = 0; i < m_searchRestVector.size(); i++) { + m_searchResultVector.append(m_searchRestVector.at(i)); + } + + Q_EMIT sendSearchResult(m_searchResultVector); +} + +void SearchAppThread::recvSearchKeyword(QString arg) +{ + this->m_keyWord.clear(); + this->m_keyWord = arg; +} diff --git a/src/SearchResultWidget/searchappthread.h b/src/BackProcess/Search/searchappthread.h old mode 100644 new mode 100755 similarity index 88% rename from src/SearchResultWidget/searchappthread.h rename to src/BackProcess/Search/searchappthread.h index 12cd9ee..972ba2b --- a/src/SearchResultWidget/searchappthread.h +++ b/src/BackProcess/Search/searchappthread.h @@ -19,7 +19,7 @@ #ifndef SEARCHAPPTHREAD_H #define SEARCHAPPTHREAD_H #include -#include "src/Interface/ukuimenuinterface.h" +#include "ukuimenuinterface.h" #include class SearchAppThread : public QThread @@ -29,12 +29,13 @@ public: SearchAppThread(); ~SearchAppThread(); void run(); - private: QString m_keyWord; QVector m_searchResultVector; + QVector m_searchFirstVector; + QVector m_searchRestVector; - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; QVector m_appInfoVector; public Q_SLOTS: diff --git a/src/BackProcess/XEventMonitor/xeventmonitor.cpp b/src/BackProcess/XEventMonitor/xeventmonitor.cpp new file mode 100755 index 0000000..f593faf --- /dev/null +++ b/src/BackProcess/XEventMonitor/xeventmonitor.cpp @@ -0,0 +1,238 @@ +/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- + * -*- coding: utf-8 -*- + * + * Copyright (C) 2011 ~ 2017 Deepin, Inc. + * 2011 ~ 2017 Wang Yong + * Copyright (C) 2018 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 of the License, or + * 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 . + */ + +#include "xeventmonitor.h" +#include +#include +#include +#include +#include +#include +#include +#include + +// Virtual button codes that are not defined by X11. +#define Button1 1 +#define Button2 2 +#define Button3 3 +#define WheelUp 4 +#define WheelDown 5 +#define WheelLeft 6 +#define WheelRight 7 +#define XButton1 8 +#define XButton2 9 + +XEventMonitor *XEventMonitor::instance_ = new XEventMonitor(); + +QVector ModifiersVec{ + XK_Control_L, + XK_Control_R, + XK_Shift_L, + XK_Shift_R, + XK_Super_L, + XK_Super_R, + XK_Alt_L, + XK_Alt_R +}; + +class XEventMonitorPrivate +{ +public: + XEventMonitorPrivate(XEventMonitor *parent); + virtual ~XEventMonitorPrivate(); + void run(); + +protected: + XEventMonitor *q_ptr; + QSet modifiers; + +// bool filterWheelEvent(int detail); + static void callback(XPointer trash, XRecordInterceptData *data); + void handleRecordEvent(XRecordInterceptData *); + void emitKeySignal(const char *member, xEvent *event); + void updateModifier(xEvent *event, bool isAdd); + +private: + Q_DECLARE_PUBLIC(XEventMonitor) +}; + +XEventMonitorPrivate::XEventMonitorPrivate(XEventMonitor *parent) + : q_ptr(parent) +{ +} + +XEventMonitorPrivate::~XEventMonitorPrivate() +{ +} + +void XEventMonitorPrivate::emitKeySignal(const char *member, xEvent *event) +{ + Display *display = XOpenDisplay(NULL); + int keyCode = event->u.u.detail; + KeySym keySym = XkbKeycodeToKeysym(display, event->u.u.detail, 0, 0); + QString keyStrSplice; + + for (auto modifier : modifiers) { + keyStrSplice += QString(XKeysymToString(modifier)) + "+"; + } + + //按键是修饰键 + if (ModifiersVec.contains(keySym) && !modifiers.isEmpty()) { + keyStrSplice.remove(keyStrSplice.length() - 1, 1); + } else { + keyStrSplice += XKeysymToString(keySym); + } + + QMetaObject::invokeMethod(q_ptr, member, + Qt::AutoConnection, + Q_ARG(int, keyCode)); + QMetaObject::invokeMethod(q_ptr, member, + Qt::AutoConnection, + Q_ARG(QString, keyStrSplice)); + XCloseDisplay(display); +} + +void XEventMonitorPrivate::run() +{ + Display *display = XOpenDisplay(0); + + if (display == 0) { + fprintf(stderr, "unable to open display\n"); + XCloseDisplay(display); + return; + } + + // Receive from ALL clients, including future clients. + XRecordClientSpec clients = XRecordAllClients; + XRecordRange *range = XRecordAllocRange(); + + if (range == 0) { + fprintf(stderr, "unable to allocate XRecordRange\n"); + XCloseDisplay(display); + return; + } + + // Receive KeyPress, KeyRelease, events. + memset(range, 0, sizeof(XRecordRange)); + range->device_events.first = KeyPress; + range->device_events.last = KeyRelease; + // And create the XRECORD context. + XRecordContext context = XRecordCreateContext(display, 0, &clients, 1, &range, 1); + + if (context == 0) { + fprintf(stderr, "XRecordCreateContext failed\n"); + XCloseDisplay(display); + return; + } + + XFree(range); + XSync(display, True); + Display *display_datalink = XOpenDisplay(0); + + if (display_datalink == 0) { + fprintf(stderr, "unable to open second display\n"); + XCloseDisplay(display_datalink); + XCloseDisplay(display); + return; + } + + if (!XRecordEnableContext(display_datalink, context, callback, (XPointer) this)) { + fprintf(stderr, "XRecordEnableContext() failed\n"); + XCloseDisplay(display_datalink); + XCloseDisplay(display); + return; + } + + XCloseDisplay(display_datalink); + XCloseDisplay(display); +} + +void XEventMonitorPrivate::callback(XPointer ptr, XRecordInterceptData *data) +{ + ((XEventMonitorPrivate *) ptr)->handleRecordEvent(data); +} + +void XEventMonitorPrivate::handleRecordEvent(XRecordInterceptData *data) +{ + if (data->category == XRecordFromServer) { + xEvent *event = (xEvent *)data->data; + + switch (event->u.u.type) { + case KeyPress: + updateModifier(event, true); + emitKeySignal("keyPress", event); + break; + + case KeyRelease: + updateModifier(event, false); + emitKeySignal("keyRelease", event); + break; + + default: + break; + } + } + + fflush(stdout); + XRecordFreeData(data); +} + +//bool XEventMonitorPrivate::filterWheelEvent(int detail) +//{ +// return detail != WheelUp && detail != WheelDown && detail != WheelLeft && detail != WheelRight; +//} + +void XEventMonitorPrivate::updateModifier(xEvent *event, bool isAdd) +{ + Display *display = XOpenDisplay(NULL); + KeySym keySym = XkbKeycodeToKeysym(display, event->u.u.detail, 0, 0); + + if (ModifiersVec.contains(keySym)) { + if (isAdd) { + modifiers.insert(keySym); + } else { + modifiers.remove(keySym); + } + } + + XCloseDisplay(display); +} + +XEventMonitor::XEventMonitor(QObject *parent) + : QThread(parent), + d_ptr(new XEventMonitorPrivate(this)) +{ + Q_D(XEventMonitor); +} + +XEventMonitor::~XEventMonitor() +{ + requestInterruption(); + quit(); + wait(); +} + +void XEventMonitor::run() +{ + if (!isInterruptionRequested()) { + d_ptr->run(); + } +} diff --git a/src/BackProcess/XEventMonitor/xeventmonitor.h b/src/BackProcess/XEventMonitor/xeventmonitor.h new file mode 100755 index 0000000..8f646ca --- /dev/null +++ b/src/BackProcess/XEventMonitor/xeventmonitor.h @@ -0,0 +1,75 @@ +/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- + * -*- coding: utf-8 -*- + * + * Copyright (C) 2018 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 of the License, or + * 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 . + */ + +#ifndef XEVENTMONITOR_H +#define XEVENTMONITOR_H + +#include +#include +#include +#include +#include +#include +#undef min + +class XEventMonitorPrivate; +class XEventMonitor : public QThread +{ + Q_OBJECT + +public: + static XEventMonitor *instance() + { + return instance_; + } + +private: + XEventMonitor(QObject *parent = 0); + ~XEventMonitor(); + +Q_SIGNALS: + + /// + /// \brief keyPress + /// \param 按键键码,不包含修饰键 + /// + void keyPress(int keyCode); + void keyRelease(int keyCode); + + /// + /// \brief keyPress + /// \param 按键名称,如果是组合键,则包含修饰键的名称,如Ctrl_L+r + /// + void keyPress(const QString &key); + void keyRelease(const QString &key); + + +protected: + void run(); + +private: + Q_DECLARE_PRIVATE(XEventMonitor) + XEventMonitorPrivate *d_ptr; + + static XEventMonitor *instance_; +}; + + +#endif diff --git a/src/BackProcess/backprocess.pri b/src/BackProcess/backprocess.pri new file mode 100755 index 0000000..060c9d4 --- /dev/null +++ b/src/BackProcess/backprocess.pri @@ -0,0 +1,49 @@ +DISTFILES += \ + $$PWD/FileWatcher/filewatcher.pri + +INCLUDEPATH += \ + $$PWD/DBus \ + $$PWD/FileWatcher \ + $$PWD/Interface \ + $$PWD/Search \ + $$PWD/tablet \ + $$PWD/XEventMonitor \ + $$PWD/BuriedPoint + +HEADERS += \ + $$PWD/DBus/dbus-adaptor.h \ + $$PWD/DBus/dbus.h \ + $$PWD/FileWatcher/convert_winid_to_desktop.h \ + $$PWD/FileWatcher/desktop_watcher.h \ + $$PWD/FileWatcher/directory_changed_thread.h \ + $$PWD/FileWatcher/software_database_update_thread.h \ + $$PWD/FileWatcher/tablet_directorychanged_thread.h \ + $$PWD/Interface/currenttime_interface.h \ + $$PWD/Interface/ukui_chineseletter.h \ + $$PWD/Interface/ukuimenuinterface.h \ + $$PWD/Search/file-utils.h \ + $$PWD/Search/searchappthread.h \ + $$PWD/XEventMonitor/xeventmonitor.h \ + $$PWD/tablet/getmodeldata.h \ + $$PWD/tablet/pagemanager.h + +SOURCES += \ + $$PWD/DBus/dbus-adaptor.cpp \ + $$PWD/DBus/dbus.cpp \ + $$PWD/FileWatcher/convert_winid_to_desktop.cpp \ + $$PWD/FileWatcher/desktop_watcher.cpp \ + $$PWD/FileWatcher/directory_changed_thread.cpp \ + $$PWD/FileWatcher/software_database_update_thread.cpp \ + $$PWD/FileWatcher/tablet_directorychanged_thread.cpp \ + $$PWD/Interface/currenttime_interface.cpp \ + $$PWD/Interface/ukui_chineseletter.cpp \ + $$PWD/Interface/ukuimenuinterface.cpp \ + $$PWD/Search/file-utils.cpp \ + $$PWD/Search/searchappthread.cpp \ + $$PWD/XEventMonitor/xeventmonitor.cpp \ + $$PWD/tablet/getmodeldata.cpp \ + $$PWD/tablet/pagemanager.cpp + + +INCLUDEPATH += $$PWD/../ +DEPENDPATH += $$PWD/../ diff --git a/src/BackProcess/tablet/getmodeldata.cpp b/src/BackProcess/tablet/getmodeldata.cpp new file mode 100755 index 0000000..11d0693 --- /dev/null +++ b/src/BackProcess/tablet/getmodeldata.cpp @@ -0,0 +1,202 @@ +#include "getmodeldata.h" +#include +#include +#include "utility.h" + +GetModelData::GetModelData() +{ + m_ukuiMenuInterface = new UkuiMenuInterface; + loadDesktopVercor(); +} + +void GetModelData::loadDesktopVercor() +{ + UkuiMenuInterface::appInfoVector.clear(); + UkuiMenuInterface::alphabeticVector.clear(); + UkuiMenuInterface::functionalVector.clear(); + UkuiMenuInterface::allAppVector.clear(); + UkuiMenuInterface::collectAppVector.clear(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + UkuiMenuInterface::alphabeticVector = m_ukuiMenuInterface->getAlphabeticClassification(); + UkuiMenuInterface::functionalVector = m_ukuiMenuInterface->getFunctionalClassification(); + UkuiMenuInterface::allAppVector = m_ukuiMenuInterface->getAllClassification(); + UkuiMenuInterface::collectAppVector = m_ukuiMenuInterface->getCollectApp(); +} + +QVector GetModelData::getMinAllData() +{ + m_minAllData.clear(); + + Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { + m_minAllData.append(QStringList() << desktopfp << "1"); + } + + return m_minAllData; +} + +QStringList GetModelData::getPreCollectionApp() +{ + //收藏区预置应用:设置、天气、软件商店、截图、文件管理器 + QStringList preAppList = QStringList(); + QStringList preAppListExist = QStringList(); + preAppList << QString("/usr/share/applications/ukui-control-center.desktop") + <= arg_2.at(4)) { + return true; + } else { + return false; + } +} + + +QVector GetModelData::getRecentData() +{ + QVector recentDataVector = QVector(); + enumerator = new Peony::FileEnumerator(this); + enumerator->setEnumerateDirectory("recent:///"); + enumerator->enumerateSync(); + QString uri; + + for (auto fileInfo : enumerator->getChildren()) { + QStringList recentData; + Peony::FileInfoJob infoJob(fileInfo); + infoJob.querySync(); + QString targetUri = fileInfo.get()->targetUri(); + QString displayName = fileInfo.get()->displayName(); + QString symlinkTarget = fileInfo.get()->symlinkTarget(); + QString iconName = fileInfo.get()->iconName(); + QString accessDate = fileInfo.get()->modifiedDate(); + recentData << targetUri << displayName << symlinkTarget << iconName << accessDate; + + if (!displayName.endsWith(".desktop")) { + recentDataVector.append(recentData); + } + } + + qSort(recentDataVector.begin(), recentDataVector.end(), cmpApp); + return recentDataVector; +} + +QStringList GetModelData::getFuncClassificationList() +{ + return m_classificationList; +} + +QStringList GetModelData::getLetterClassificationList() +{ + return m_letterList; +} + +QStringList GetModelData::getFuncClassificationBtnRowList() +{ + return m_classificationBtnRowList; +} + +QStringList GetModelData::getLetterClassificationBtnRowList() +{ + return m_letterBtnRowList; +} + +QVector GetModelData::getMinLetterData() +{ + m_minLetterData.clear(); + m_letterList.clear(); + m_letterBtnRowList.clear(); + int row = 0; + QVector vector = UkuiMenuInterface::alphabeticVector; + + for (int i = 0; i < vector.size(); i++) { + QStringList appList = vector.at(i); + + if (!appList.isEmpty()) { + QString letterstr; + + if (i < 26) { + letterstr = QString(QChar(static_cast(i + 65))); + } else if (i == 26) { + letterstr = "&"; + } else { + letterstr = "#"; + } + + m_letterList.append(letterstr);//存储分类字符 + m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 + m_minLetterData.append(QStringList() << letterstr << "0"); + + for (int i = 0; i < appList.count(); i++) { + m_minLetterData.append(QStringList() << appList.at(i) << "1"); + } + + row += (appList.count() + 1); + } + } + + return m_minLetterData; +} + +QVector GetModelData::getMinFuncData() +{ + m_funcRow = 0; + m_minFuncData.clear(); + m_classificationList.clear(); + m_classificationBtnRowList.clear(); + QVector vector = UkuiMenuInterface::functionalVector; + QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + + for (int i = 0; i < vector.size(); i++) { + if (!(vector.at(i).isEmpty())) { + QString functionName = functionList.at(i); + insertClassificationBtn(functionName); + insertAppList(vector.at(i)); + } + } + + return m_minFuncData; +} + + + +void GetModelData::insertClassificationBtn(QString btnname) +{ + m_classificationList.append(btnname); + m_minFuncData.append(QStringList() << btnname << "0"); + m_classificationBtnRowList.append(QString::number(m_funcRow)); +} + +void GetModelData::insertAppList(QStringList appnamelist) +{ + m_funcRow += (appnamelist.count() + 1); + + for (int i = 0; i < appnamelist.count(); i++) { + m_minFuncData.append(QStringList() << appnamelist.at(i) << "1"); + } +} + diff --git a/src/BackProcess/tablet/getmodeldata.h b/src/BackProcess/tablet/getmodeldata.h new file mode 100755 index 0000000..6e0d3dc --- /dev/null +++ b/src/BackProcess/tablet/getmodeldata.h @@ -0,0 +1,102 @@ +#ifndef GETMODELDATA_H +#define GETMODELDATA_H +#include "ukuimenuinterface.h" +#include +#include +#include + +class GetModelData : public QObject +{ + Q_OBJECT + +public: + GetModelData(); + +public: + /** + * @brief 获取默认窗口全部分类数据 + * @return + */ + QVector getMinAllData(); + /** + * @brief 获取默认窗口字母分类数据 + * @return + */ + QVector getMinLetterData(); + /** + * @brief 获取默认窗口功能分类数据 + * @return + */ + QVector getMinFuncData(); + /** + * @brief 获取收藏列表数据 + * @return + */ + QStringList getcollectData(); + /** + * @brief 获取功能分类类别列表 + * @return + */ + QStringList getFuncClassificationList(); + /** + * @brief 获取字母分类类别列表 + * @return + */ + QStringList getLetterClassificationList(); + /** + * @brief 获取对应类别所在行数 + * @return + */ + QStringList getFuncClassificationBtnRowList(); + QStringList getLetterClassificationBtnRowList(); + /** + * @brief 获取最近页面所展示应用列表 + * @return + */ + QVector getRecentData(); + + /** + * @brief 重新加载各个部分数据,用于初始化和整体更新 + */ + void loadDesktopVercor(); + /** + * @brief 获取预装应用 + * @return + */ + QStringList getPreCollectionApp(); + +protected: + /** + * @brief 插入分类按键 + * @param btnname + */ + void insertClassificationBtn(QString btnname); + /** + * @brief 插入应用列表 + * @param appnamelist + */ + void insertAppList(QStringList appnamelist); + /** + * @brief 修改时间比较 + * @param arg_1 + * @param arg_2 + * @return + */ + static bool cmpApp(QStringList &arg_1, QStringList &arg_2); + +private: + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QVector m_minAllData; + QStringList m_collectData; + QVector m_minLetterData; + QStringList m_letterList; + QStringList m_letterBtnRowList; + QVector m_minFuncData; + QStringList m_classificationList; + QStringList m_classificationBtnRowList; + int m_funcRow; + Peony::FileEnumerator *enumerator = nullptr; + QList> m_childrens; +}; + +#endif // GETMODELDATA_H diff --git a/src/BackProcess/tablet/pagemanager.cpp b/src/BackProcess/tablet/pagemanager.cpp new file mode 100755 index 0000000..86b2af1 --- /dev/null +++ b/src/BackProcess/tablet/pagemanager.cpp @@ -0,0 +1,99 @@ +#include "pagemanager.h" +#include "ukuimenuinterface.h" +#include "style.h" +PageManager::PageManager() +{ + //获取数据 + m_ukuiMenuInterface = new UkuiMenuInterface(); + UkuiMenuInterface::appInfoVector = m_ukuiMenuInterface->createAppInfoVector(); + m_ukuiMenuInterface->initAppIni(); +} + +int PageManager::getPageNum(const int &appNum) +{ + int pageNum = 0; + + if (appNum / (Style::appColumnFirst * Style::appLineFirst) == 0) { + pageNum = 1; + } else { + int appNumOtherPage = appNum - (Style::appColumnFirst * Style::appLineFirst); + + if (appNumOtherPage % (Style::appColumn * Style::appLine) == 0) { + pageNum = appNumOtherPage / (Style::appColumn * Style::appLine) + 1; + } else { + pageNum = appNumOtherPage / (Style::appColumn * Style::appLine) + 2; + } + } + + return pageNum; +} + +QVector PageManager::sortAppInPage(const QVector &appVector) +{ + QVector m_data; + QVector pageData; + QStringList onePageData; + + Q_FOREACH (QString desktopfp, appVector) { + m_data.append(desktopfp); + } + + int pageSize = getPageNum(m_data.size()); + onePageData.clear(); + + for (int j = 0; j < Style::appColumnFirst * Style::appLineFirst; j++) { + if (m_data.size() > 0) { + onePageData.append(m_data.at(0)); + m_data.pop_front(); + } else { + break; + } + } + + pageData.append(onePageData); + + for (int i = 0; i < pageSize - 1; i++) { + onePageData.clear(); + + for (int j = 0; j < Style::appColumn * Style::appLine; j++) { + if (m_data.size() > 0) { + onePageData.append(m_data.at(0)); + m_data.pop_front(); + } else { + break; + } + } + + pageData.append(onePageData); + } + + return pageData; +} + +QVector PageManager::getAppPageVector() +{ + UkuiMenuInterface::tencentInitVector = m_ukuiMenuInterface->sortDesktopList("tencent"); + UkuiMenuInterface::customizedVector = m_ukuiMenuInterface->sortDesktopList("customized"); + UkuiMenuInterface::thirdPartyVector = m_ukuiMenuInterface->sortDesktopList("thirdParty"); + UkuiMenuInterface::applicationVector = m_ukuiMenuInterface->sortDesktopList("application"); + QVector appPagelist; + QVector allAppList = UkuiMenuInterface::tencentInitVector + UkuiMenuInterface::customizedVector + UkuiMenuInterface::thirdPartyVector + UkuiMenuInterface::applicationVector; + + Q_FOREACH (QStringList desktopfp, sortAppInPage(/*UkuiMenuInterface::tencentInitVector*/allAppList)) { + appPagelist.append(desktopfp); + } + +// Q_FOREACH(QStringList desktopfp,sortAppInPage(UkuiMenuInterface::customizedVector)) +// { +// appPagelist.append(desktopfp); +// } +// Q_FOREACH(QStringList desktopfp,sortAppInPage(UkuiMenuInterface::thirdPartyVector)) +// { +// appPagelist.append(desktopfp); +// } +// Q_FOREACH(QStringList desktopfp,sortAppInPage(UkuiMenuInterface::applicationVector)) +// { +// appPagelist.append(desktopfp); +// } + return appPagelist; +} diff --git a/src/BackProcess/tablet/pagemanager.h b/src/BackProcess/tablet/pagemanager.h new file mode 100755 index 0000000..8c3f2ca --- /dev/null +++ b/src/BackProcess/tablet/pagemanager.h @@ -0,0 +1,20 @@ +#ifndef PAGEMANAGER_H +#define PAGEMANAGER_H + +#include +#include "ukuimenuinterface.h" + +class PageManager : public QObject +{ + Q_OBJECT +public: + PageManager(); + + int getPageNum(const int &appNum); + QVector sortAppInPage(const QVector &appVector); + QVector getAppPageVector(); +private: + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; +}; + +#endif // PAGEMANAGER_H diff --git a/src/CommonUseWidget/commonusewidget.cpp b/src/CommonUseWidget/commonusewidget.cpp deleted file mode 100644 index 4196876..0000000 --- a/src/CommonUseWidget/commonusewidget.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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 -#include -#include -#include - -CommonUseWidget::CommonUseWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); - -} - -CommonUseWidget::~CommonUseWidget() -{ - delete m_ukuiMenuInterface; -} - -void CommonUseWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setAttribute(Qt::WA_TranslucentBackground); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - - m_ukuiMenuInterface=new UkuiMenuInterface; - - initAppListWidget(); - fillAppList(); -} - -/** - * 初始化应用列表界面 - */ -void CommonUseWidget::initAppListWidget() -{ - m_listView=new ListView(this,this->width()-6,this->height()-6,0); - m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_listView->show(); - connect(m_listView,&ListView::sendItemClickedSignal,this,&CommonUseWidget::execApplication); - connect(m_listView,&ListView::sendUpdateAppListSignal,this,&CommonUseWidget::updateListViewSlot); - connect(m_listView,&ListView::sendHideMainWindowSignal,this,&CommonUseWidget::sendHideMainWindowSignal); -} - -/** - * 填充应用列表 - */ -void CommonUseWidget::fillAppList() -{ - m_data.clear(); - Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector) - m_data.append(QStringList()<addData(m_data); -} - -void CommonUseWidget::selectFirstItem() -{ - this->focusNextChild(); - m_listView->setCurrentIndex(m_listView->model()->index(0,0)); -} - -void CommonUseWidget::selectFirstItemTab() -{ - this->setFocus(); - if(m_listView->currentIndex().row() == -1) - { - m_listView->setCurrentIndex(m_listView->model()->index(0,0)); - } -} -/** - * 执行应用程序 - */ -void CommonUseWidget::execApplication(QStringList arg) -{ - Q_EMIT sendHideMainWindowSignal(); - QString desktopfp=arg.at(0); - execApp(desktopfp); -} - - -/** - * 更新应用列表槽函数 - */ -void CommonUseWidget::updateListViewSlot() -{ - updateListView(); -} - -void CommonUseWidget::updateListView() -{ - m_data.clear(); - Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification()) - m_data.append(QStringList()<updateData(m_data); - // m_listView->setFocus(); -} - -void CommonUseWidget::widgetMakeZero() -{ - m_listView->verticalScrollBar()->setSliderPosition(0); -} - -void CommonUseWidget::moveScrollBar(int type) -{ - if(type==0) - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-100); - else - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+100); -} - -void CommonUseWidget::repaintWidget() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_listView->show(); -} - diff --git a/src/CommonUseWidget/commonusewidget.h b/src/CommonUseWidget/commonusewidget.h deleted file mode 100644 index 16e571c..0000000 --- a/src/CommonUseWidget/commonusewidget.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -#include "src/RightClickMenu/rightclickmenu.h" -#include "src/UtilityFunction/listview.h" -#include "src/UtilityFunction/itemdelegate.h" -#include "src/UtilityFunction/utility.h" - -class CommonUseWidget : public QWidget -{ - Q_OBJECT - -public: - explicit CommonUseWidget(QWidget *parent = nullptr); - ~CommonUseWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Update application list - */ - void updateListView(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Repaint window - */ - void repaintWidget(); - -private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - ListView* m_listView=nullptr; - QVector m_data; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppList(); - -public Q_SLOTS: - /** - * @brief Open the application - * @param arg: The desktop file information that the application contains - */ - void execApplication(QStringList arg); - /** - * @brief Update the application list slot function - */ - void updateListViewSlot(); - - void selectFirstItem(); - - void selectFirstItemTab(); - -Q_SIGNALS: - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // COMMONUSEWIDGET_H diff --git a/src/CommonUseWidget/fullcommonusewidget.cpp b/src/CommonUseWidget/fullcommonusewidget.cpp deleted file mode 100644 index 035225c..0000000 --- a/src/CommonUseWidget/fullcommonusewidget.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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 -#include "src/Style/style.h" -#include "src/UtilityFunction/utility.h" -#include - -FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullCommonUseWidget::~FullCommonUseWidget() -{ - delete m_ukuiMenuInterface; -} - -void FullCommonUseWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - this->setFocusPolicy(Qt::NoFocus); - QHBoxLayout* mainLayout=new QHBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - this->setLayout(mainLayout); - m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); - mainLayout->addItem(m_spaceItem); - m_scrollArea=new ScrollArea; - m_scrollAreaWid=new ScrollAreaWid; - m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout=new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_scrollAreaWidLayout->setSpacing(10); - m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); - mainLayout->addWidget(m_scrollArea); - - m_ukuiMenuInterface=new UkuiMenuInterface; - - initAppListWidget(); - fillAppList(); - - flag = true; - //翻页灵敏度时间调节 - time = new QTimer(this); - connect(time,&QTimer::timeout,[=](){ - if(flag == false) - { - flag = true; - time->stop(); - } - }); -} - -void FullCommonUseWidget::initAppListWidget() -{ - m_listView=new FullListView(this,0); -// m_listView->setFixedSize(this->width()-Style::LeftWidWidth+3,this->height()); -// QHBoxLayout *mainLayout=qobject_cast(this->layout()); -// mainLayout->insertWidget(1,m_listView); - m_scrollAreaWidLayout->addWidget(m_listView); - connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullCommonUseWidget::execApplication); - connect(m_listView,&FullListView::sendUpdateAppListSignal,this,&FullCommonUseWidget::updateListViewSlot); - connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullCommonUseWidget::sendHideMainWindowSignal); - connect(m_listView,&FullListView::sendSetslidebar,this,&FullCommonUseWidget::onSetSlider); -} - -void FullCommonUseWidget::resizeScrollAreaControls() -{ - QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0); - QWidget* wid=widItem->widget(); - FullListView* listview=qobject_cast(wid); - listview->adjustSize(); - int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; - int rowcount=0; - if(listview->model()->rowCount()%dividend>0) - { - rowcount=listview->model()->rowCount()/dividend+1; - } - else - { - rowcount=listview->model()->rowCount()/dividend; - - } - - listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); - m_scrollArea->widget()->adjustSize(); -} - -void FullCommonUseWidget::fillAppList() -{ - m_data.clear(); - Q_FOREACH(QString desktopfp,UkuiMenuInterface::allAppVector) - m_data.append(desktopfp); - m_listView->addData(m_data); - resizeScrollAreaControls(); -} - -/** - * 执行应用程序 - */ -void FullCommonUseWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -void FullCommonUseWidget::selectFirstItem() -{ - // this->focusNextChild(); - qDebug() << "void FullCommonUseWidget::selectFirstItem()"; - m_listView->setCurrentIndex(m_listView->model()->index(0,0)); -} - -void FullCommonUseWidget::selectFirstItemTab() -{ - this->setFocus(); - if(m_listView->currentIndex().row() == -1) - { - m_listView->setCurrentIndex(m_listView->model()->index(0,0)); - } -} - -void FullCommonUseWidget::onSetSlider(int value) -{ -// if(flag) -// { -// flag = false; -// time->start(100); - if(value == 0) - { - m_scrollArea->verticalScrollBar()->setValue(0); - } - else - { - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); - } -// } -} -/** - * 更新应用列表 - */ -void FullCommonUseWidget::updateListViewSlot() -{ - updateListView(); -} - -void FullCommonUseWidget::updateListView() -{ - m_data.clear(); - Q_FOREACH(QString desktopfp,m_ukuiMenuInterface->getAllClassification()) - m_data.append(desktopfp); - m_listView->updateData(m_data); -} - -void FullCommonUseWidget::repaintWidget() -{ - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); - m_scrollAreaWidLayout->removeWidget(m_listView); - m_listView->setParent(nullptr); - delete m_listView; - initAppListWidget(); - fillAppList(); -} - -void FullCommonUseWidget::widgetMakeZero() -{ - m_listView->verticalScrollBar()->setSliderPosition(0); -} - -void FullCommonUseWidget::moveScrollBar(int type) -{ - int height=Style::primaryScreenHeight; - if(type==0) - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-height*100/1080); - else - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+height*100/1080); -} diff --git a/src/FunctionWidget/fullfunctionwidget.cpp b/src/FunctionWidget/fullfunctionwidget.cpp deleted file mode 100644 index 8e30388..0000000 --- a/src/FunctionWidget/fullfunctionwidget.cpp +++ /dev/null @@ -1,587 +0,0 @@ -/* - * 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 -#include -#include "src/Style/style.h" -#include -#include -#include - -FullFunctionWidget::FullFunctionWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullFunctionWidget::~FullFunctionWidget() -{ - delete m_ukuiMenuInterface; -} - -void FullFunctionWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setAttribute(Qt::WA_TranslucentBackground); - m_applistWid=new QWidget(this); - m_iconListWid=new QWidget(this); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height()); - - QHBoxLayout* mainLayout=new QHBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - mainLayout->setSpacing(0); - mainLayout->addWidget(m_iconListWid); - mainLayout->addWidget(m_applistWid); - this->setLayout(mainLayout); - - m_ukuiMenuInterface=new UkuiMenuInterface; - - initAppListWidget(); - initIconListWidget(); - - flag = true; - //翻页灵敏度时间调节 - time = new QTimer(this); - connect(time,&QTimer::timeout,[=](){ - if(flag == false) - { - flag = true; - time->stop(); - } - }); -} - -/** - * 初始化应用列表界面 - */ -void FullFunctionWidget::initAppListWidget() -{ - QHBoxLayout* layout=new QHBoxLayout(m_applistWid); - layout->setContentsMargins(0,0,0,0); - m_applistWid->setLayout(layout); - - m_scrollArea=new ScrollArea; - m_scrollAreaWid=new ScrollAreaWid; - m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout=new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_scrollAreaWidLayout->setSpacing(10); - m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); - layout->addWidget(m_scrollArea); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullFunctionWidget::valueChangedSlot); - m_appListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); - fillAppList(); -} - -/** - * 填充应用列表 - */ -void FullFunctionWidget::fillAppList() -{ - m_classificationList.clear(); - QVector vector=UkuiMenuInterface::functionalVector; - QStringList androidlist=vector.at(0); - if(!androidlist.isEmpty()) - { - insertClassificationBtn("Mobile"); - insertAppList(androidlist); - } - - QStringList netlist=vector.at(1); - if(!netlist.isEmpty()) - { - insertClassificationBtn("Internet"); - insertAppList(netlist); - } - QStringList sociallist=vector.at(2); - if(!sociallist.isEmpty()) - { - insertClassificationBtn("Social"); - insertAppList(sociallist); - } - QStringList avlist=vector.at(3); - if(!avlist.isEmpty()) - { - insertClassificationBtn("Video"); - insertAppList(avlist); - } - QStringList developlist=vector.at(4); - if(!developlist.isEmpty()) - { - insertClassificationBtn("Development"); - insertAppList(developlist); - } - QStringList graphicslist=vector.at(5); - if(!graphicslist.isEmpty()) - { - insertClassificationBtn("Image"); - insertAppList(graphicslist); - } - QStringList gamelist=vector.at(6); - if(!gamelist.isEmpty()) - { - insertClassificationBtn("Game"); - insertAppList(gamelist); - } - QStringList officelist=vector.at(7); - if(!officelist.isEmpty()) - { - insertClassificationBtn("Office"); - insertAppList(officelist); - } - QStringList educationlist=vector.at(8); - if(!educationlist.isEmpty()) - { - insertClassificationBtn("Education"); - insertAppList(educationlist); - } - - QStringList systemadminlist=vector.at(9); - if(!systemadminlist.isEmpty()) - { - insertClassificationBtn("System"); - insertAppList(systemadminlist); - } - QStringList otherlist=vector.at(10); - if(!otherlist.isEmpty()) - { - insertClassificationBtn("Others"); - insertAppList(otherlist); - } - m_scrollAreaWidLayout->addItem(m_appListBottomSpacer); - resizeScrollAreaControls(); -} - -void FullFunctionWidget::insertClassificationBtn(QString category) -{ - SplitBarFrame* classificationbtn=new SplitBarFrame(this,category,m_scrollArea->width()-12,30,2); - m_scrollAreaWidLayout->addWidget(classificationbtn); - m_classificationList.append(category); - -} - -void FullFunctionWidget::insertAppList(QStringList desktopfplist) -{ - FullListView* listview=new FullListView(this,2); - //修复异常黑框问题 - connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ - listview->repaint(listview->rect()); - }); - connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider); - connect(this, &FullFunctionWidget::selectFirstItem, listview, &FullListView::selectFirstItem); - listview->installEventFilter(this); - m_scrollAreaWidLayout->addWidget(listview); - m_data.clear(); - for(int i=0;iaddData(m_data); - connect(listview,&FullListView::sendItemClickedSignal,this,&FullFunctionWidget::execApplication); - connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullFunctionWidget::sendHideMainWindowSignal); -} - -/** - * 执行应用程序 - */ -void FullFunctionWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -/** - * 更新应用列表 - */ -void FullFunctionWidget::updateAppListView() -{ - //刷新应用列表界面 - QLayoutItem *child; - m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer); - while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_scrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - fillAppList(); - - //刷新图标列表界面 - Q_FOREACH (QAbstractButton* button, m_buttonList){ - m_btnGroup->removeButton(button); - } - m_buttonList.clear(); - m_iconListScrollAreaWidLayout->removeItem(m_topSpacerItem); - m_iconListScrollAreaWidLayout->removeItem(m_bottomSpacerItem); - while ((child = m_iconListScrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_iconListScrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - initIconListScrollArea(); -} - -/** - * 设置scrollarea所填充控件大小 - */ -void FullFunctionWidget::resizeScrollAreaControls() -{ - int row=0; - while(rowcount()/2) - { - //应用界面 - QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1); - QWidget* wid=widItem->widget(); - FullListView* listview=qobject_cast(wid); - listview->adjustSize(); - int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; - int rowcount=0; - if(listview->model()->rowCount()%dividend>0) - { - rowcount=listview->model()->rowCount()/dividend+1; - } - else - { - rowcount=listview->model()->rowCount()/dividend; - - } - - listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); - row++; - } - m_scrollArea->widget()->adjustSize(); -} - -/** - * 初始化图标列表界面 - */ -void FullFunctionWidget::initIconListWidget() -{ - m_iconListScrollArea=new ClassifyBtnScrollArea(m_iconListWid); -// m_iconListScrollArea->resize(Style::LeftBtnWidth, -// m_iconListWid->height()); - m_iconListScrollAreaWid=new ClassifyBtnScrollAreaWid; - m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, - m_iconListWid->height()); - m_iconListScrollAreaWidLayout=new QVBoxLayout; - m_iconListScrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_iconListScrollAreaWidLayout->setSpacing(Style::LeftSpaceBetweenItem); - m_iconListScrollAreaWid->setLayout(m_iconListScrollAreaWidLayout); - m_iconListScrollArea->setWidget(m_iconListScrollAreaWid); - - m_topSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); - m_bottomSpacerItem=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); - - m_btnGroup=new QButtonGroup(m_iconListScrollAreaWid); - m_animation = new QPropertyAnimation(m_iconListScrollArea, "geometry"); - - m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); - m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); - connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullFunctionWidget::animationFinishSlot); - connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullFunctionWidget::animationValueChangedSlot); - - initIconListScrollArea(); -} - -/** - * 初始化图标列表界面数据表格iconlisttableWid - */ -void FullFunctionWidget::initIconListScrollArea() -{ - m_iconListScrollAreaWidLayout->addItem(m_topSpacerItem); - for(int i=0;isetChecked(false); - m_buttonList.append(iconbtn); - m_iconListScrollAreaWidLayout->addWidget(iconbtn); - } - m_iconListScrollAreaWidLayout->addItem(m_bottomSpacerItem); - - int id=0; - Q_FOREACH (QAbstractButton* btn, m_buttonList) { - m_btnGroup->addButton(btn,id++); - } - connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&FullFunctionWidget::btnGroupClickedSlot); -// m_iconListScrollArea->widget()->adjustSize(); - if(m_btnGroup->button(0)!=nullptr) - m_btnGroup->button(0)->click(); -} - -void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn) -{ - disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullFunctionWidget::valueChangedSlot); - Q_FOREACH (QAbstractButton* button, m_buttonList) { - if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) - { - m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition(); - m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y(); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAnimation->stop(); - m_scrollAnimation->setStartValue(m_beginPos); - m_scrollAnimation->setEndValue(m_endPos); - m_scrollAnimation->start(); - button->setChecked(true); - } - else{ - button->setChecked(false); - } - } -} - -void FullFunctionWidget::animationFinishSlot() -{ - if(m_scrollArea->verticalScrollBar()->value()==m_endPos || - m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) - { - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullFunctionWidget::valueChangedSlot); - } -} - -void FullFunctionWidget::animationValueChangedSlot(const QVariant &value) -{ - Q_UNUSED(value); - if (sender() != m_scrollAnimation) - return; - - QPropertyAnimation *ani = qobject_cast(sender()); - - if (m_endPos != ani->endValue()) - ani->setEndValue(m_endPos); -} - -void FullFunctionWidget::valueChangedSlot(int value) -{ - int index=0; - while(index<=m_classificationList.count()-1) - { - int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y(); - int max=0; - if(index==m_classificationList.count()-1) - max=m_scrollAreaWid->height(); - else - max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y(); - if(value>=min && value(button); - if(index==m_buttonList.indexOf(button)) - { - fcbutton->setChecked(true); - } - else{ - fcbutton->setChecked(false); - } - } - break; - } - else - index++; - } -} - -QAbstractButton* FullFunctionWidget::getCurLetterButton(int value) -{ - return m_buttonList.at(value); -} - - -void FullFunctionWidget::enterAnimation() -{ - m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0,0, - 0,m_iconListWid->height())); - m_animation->setEndValue(QRect(Style::LeftMargin, - 0, - Style::LeftBtnWidth, - m_iconListWid->height())); - m_animation->setEasingCurve(QEasingCurve::InQuart); - m_animation->start(); - m_iconListScrollArea->show(); -} - -void FullFunctionWidget::setFunctionBtnGeometry() -{ -// int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; - m_iconListScrollArea->setGeometry(QRect(Style::LeftMargin, - 0, - Style::LeftBtnWidth, - m_iconListWid->height())); - m_iconListScrollArea->show(); - -} - -void FullFunctionWidget::repaintWidget() -{ - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); - m_iconListWid->setFixedSize(Style::LeftWidWidth,this->height()); - m_iconListScrollAreaWid->setFixedSize(Style::LeftBtnWidth, - m_iconListWid->height()); - updateAppListView(); -} - -void FullFunctionWidget::widgetMakeZero() -{ - if(m_btnGroup->button(0)!=nullptr) - m_btnGroup->button(0)->click(); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); -} - -void FullFunctionWidget::moveScrollBar(int type) -{ - int height=Style::primaryScreenHeight; - if(type==0) - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080); - else - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080); -} - -void FullFunctionWidget::onSetSlider(int value) -{ -// if(flag) -// { -// flag = false; -// time->start(100); - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); -// qDebug() << "FullFunctionWidget::onSetSlider" << curvalue; -// } -} - -bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) -{ - if( event->type() == QEvent::KeyPress ) - { - QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); - QWidget* wid = widItem->widget(); - FullListView* m_listview = qobject_cast(wid); - - QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget* widTop = widItemTop->widget(); - FullListView* m_listviewTop = qobject_cast(widTop); - - QKeyEvent *ke = (QKeyEvent *)event; - if( ke->key() == Qt::Key_Tab ) - { - Q_EMIT setFocusToSideWin(); - } -// if(ke->key() == Qt::Key_Up) -// { -// QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); -// QWidget* widTop = widItemTop->widget(); -// FullListView* m_listviewTop = qobject_cast(widTop); -// if(!m_listviewTop->hasFocus()) -// { -// QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size()); -// btnGroupClickedSlot(buttonTop); -// this->m_scrollArea->setFocusToPreChild(); -// return true; -// } -// } -// if(ke->key() == Qt::Key_Down) -// { -// QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); -// QWidget* wid = widItem->widget(); -// FullListView* m_listview = qobject_cast(wid); - -// if(!m_listview->hasFocus()) -// { -// QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size()); -// btnGroupClickedSlot(button); -// this->m_scrollArea->setFocusToNextChild(); -// return true; -// } -// } - - if(ke->key() == Qt::Key_Up) - { - if(!m_listviewTop->hasFocus()) - { - QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size()); - btnGroupClickedSlot(buttonTop); - this->m_scrollArea->setFocusToPreChild(); - } - else - { - m_listview->setFocus(); - QAbstractButton* button = getCurLetterButton(m_buttonList.size() - 1); - btnGroupClickedSlot(button); - m_index = m_buttonList.size() - 1; - } - Q_EMIT selectFirstItem(); - return true; - } - if(ke->key() == Qt::Key_Down) - { - if(!m_listview->hasFocus()) - { - QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size()); - btnGroupClickedSlot(button); - this->m_scrollArea->setFocusToNextChild(); - } - else - { - m_listviewTop->setFocus(); - QAbstractButton* buttonTop = getCurLetterButton(0); - btnGroupClickedSlot(buttonTop); - m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0,0)); - m_index = 0; - } - Q_EMIT selectFirstItem(); - return true; - } - } - return QWidget::eventFilter(watched,event); -} - -void FullFunctionWidget::functionButtonClick() -{ - if(m_btnGroup->button(0)!=nullptr) - m_btnGroup->button(0)->click(); - m_index = 0; -} - -void FullFunctionWidget::setFocusToThis() -{ - functionButtonClick(); - this->setFocus(); - Q_EMIT selectFirstItem(); -} diff --git a/src/FunctionWidget/functionbuttonwidget.cpp b/src/FunctionWidget/functionbuttonwidget.cpp deleted file mode 100644 index 0cde546..0000000 --- a/src/FunctionWidget/functionbuttonwidget.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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 -#include -#include - -FunctionButtonWidget::FunctionButtonWidget(QWidget *parent) : - QWidget(parent) -{ - m_categoryList.append("Mobile"); - m_categoryList.append("Internet"); - m_categoryList.append("Social"); - m_categoryList.append("Video"); - m_categoryList.append("Development"); - m_categoryList.append("Image"); - m_categoryList.append("Game"); - m_categoryList.append("Office"); - m_categoryList.append("Education"); - m_categoryList.append("System"); - m_categoryList.append("Others"); - - initUi(); -} - -FunctionButtonWidget::~FunctionButtonWidget() -{ -} - -void FunctionButtonWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->resize(Style::LeftBtnWidth*2+5,Style::LeftBtnHeight*6+25); - - QGridLayout* gridLayout=new QGridLayout; - gridLayout->setContentsMargins(0,0,0,0); - gridLayout->setSpacing(5); - this->setLayout(gridLayout); - - for(int row=0;row<6;row++) - for(int col=0;col<2;col++) - { - FunctionClassifyButton* iconbtn=new FunctionClassifyButton(Style::LeftBtnWidth, - Style::LeftBtnHeight, - Style::LeftIconSize, - m_categoryList.at(row*2+col), - false, - false); - - gridLayout->addWidget(iconbtn,row,col); - m_buttonList.append(iconbtn); - connect(iconbtn,&FunctionClassifyButton::buttonClicked,this, &FunctionButtonWidget::functionBtnClickedSlot); - if(row*2+col==10)break; - } - - if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); - connect(gsetting,&QGSettings::changed,this,[=]{ - Q_FOREACH (QAbstractButton* btn, m_buttonList) { - FunctionClassifyButton *fbtn=qobject_cast(btn); - fbtn->updateIconState(); - } - }); - } -} - -/** - * 功能分类按钮槽函数 - */ -void FunctionButtonWidget::functionBtnClickedSlot() -{ - FunctionClassifyButton* btn=dynamic_cast(sender()); - QWidget* wid=btn->layout()->itemAt(1)->widget(); - QLabel* label=qobject_cast(wid); - Q_EMIT sendFunctionBtnSignal(label->text()); -} - -/** - * 接收FunctionWidget界面分类按钮列表 - */ -void FunctionButtonWidget::recvClassificationBtnList() -{ - QGridLayout* gridLayout=qobject_cast(this->layout()); - for(int row=0;row<6;row++) - for(int col=0;col<2;col++) - { - QLayoutItem* item=gridLayout->itemAtPosition(row,col); - FunctionClassifyButton* btn=qobject_cast(item->widget()); - if(UkuiMenuInterface::functionalVector.at(row*2+col).isEmpty()) - btn->m_enabled=false; - else - btn->m_enabled=true; - btn->setEnabled(btn->m_enabled); - btn->updateBtnState(); - - if(row*2+col==10)break; - } -} diff --git a/src/FunctionWidget/functionwidget.cpp b/src/FunctionWidget/functionwidget.cpp deleted file mode 100644 index 69dce44..0000000 --- a/src/FunctionWidget/functionwidget.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - * 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 - -FunctionWidget::FunctionWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FunctionWidget::~FunctionWidget() -{ - delete m_ukuiMenuInterface; -} - -/** - * 主界面初始化 - */ -void FunctionWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - - m_ukuiMenuInterface=new UkuiMenuInterface; - initAppListWidget(); - - m_functionBtnWid=new FunctionButtonWidget(this); - m_functionBtnWid->hide(); - connect(this,&FunctionWidget::sendClassificationbtnList,m_functionBtnWid,&FunctionButtonWidget::recvClassificationBtnList); - connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal,this,&FunctionWidget::recvFunctionBtnSignal); - - m_enterAnimation=new QPropertyAnimation; - m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation=new QPropertyAnimation; - m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot); - connect(m_enterAnimation,&QPropertyAnimation::finished,this,&FunctionWidget::animationFinishedSLot); -} - -/** - * 初始化应用列表界面 - */ -void FunctionWidget::initAppListWidget() -{ - m_appListView=new ListView(this,this->width()-6,this->height()-6,2); - m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_appListView->show(); - fillAppListView(0); - connect(m_appListView,&ListView::sendItemClickedSignal,this,&FunctionWidget::recvItemClickedSlot); - connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&FunctionWidget::sendHideMainWindowSignal); -} - - -/** - * 填充应用列表 - */ -void FunctionWidget::fillAppListView(int type) -{ - row=0; - m_data.clear(); - m_classificationList.clear(); - m_classificationBtnRowList.clear(); - QVector vector=UkuiMenuInterface::functionalVector; - QStringList androidlist=vector.at(0); - if(!androidlist.isEmpty()) - { - insertClassificationBtn(tr("Mobile")); - insertAppList(androidlist); - } - QStringList netlist=vector.at(1); - if(!netlist.isEmpty()) - { - insertClassificationBtn(tr("Internet")); - insertAppList(netlist); - } - QStringList sociallist=vector.at(2); - if(!sociallist.isEmpty()) - { - insertClassificationBtn(tr("Social")); - insertAppList(sociallist); - } - QStringList avlist=vector.at(3); - if(!avlist.isEmpty()) - { - insertClassificationBtn(tr("Video")); - insertAppList(avlist); - } - QStringList developlist=vector.at(4); - if(!developlist.isEmpty()) - { - insertClassificationBtn(tr("Development")); - insertAppList(developlist); - } - QStringList graphicslist=vector.at(5); - if(!graphicslist.isEmpty()) - { - insertClassificationBtn(tr("Image")); - insertAppList(graphicslist); - } - QStringList gamelist=vector.at(6); - if(!gamelist.isEmpty()) - { - insertClassificationBtn(tr("Game")); - insertAppList(gamelist); - } - QStringList officelist=vector.at(7); - if(!officelist.isEmpty()) - { - insertClassificationBtn(tr("Office")); - insertAppList(officelist); - } - QStringList educationlist=vector.at(8); - if(!educationlist.isEmpty()) - { - insertClassificationBtn(tr("Education")); - insertAppList(educationlist); - } - - QStringList systemadminlist=vector.at(9); - if(!systemadminlist.isEmpty()) - { - insertClassificationBtn(tr("System")); - insertAppList(systemadminlist); - } - QStringList otherlist=vector.at(10); - if(!otherlist.isEmpty()) - { - insertClassificationBtn(tr("Others")); - insertAppList(otherlist); - } - - if(type==0) - m_appListView->addData(m_data); - else - m_appListView->updateData(m_data); -} - -void FunctionWidget::insertClassificationBtn(QString btnname) -{ - m_classificationList.append(btnname); - m_data.append(QStringList()<setStartValue(QRect(6,0,this->width()-6,this->height()-6)); -// m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); - m_leaveAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); - m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); - m_enterAnimation->setEndValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2, - (this->height()-Style::LeftBtnHeight*6-25)/2, - Style::LeftBtnWidth*2+5, - Style::LeftBtnHeight*6+25)); - m_leaveAnimation->setDuration(10); - m_enterAnimation->setDuration(100); - - //加载FunctionButtonWidget界面 - Q_EMIT sendClassificationbtnList(); - m_leaveAnimation->setTargetObject(m_appListView); - m_enterAnimation->setTargetObject(m_functionBtnWid); - m_leaveAnimation->start(); - m_widgetState=1; -} - -/** - * 接收FunctionButtonWidget界面按钮信号 - */ -void FunctionWidget::recvFunctionBtnSignal(QString btnname) -{ - //此处需实现将功能为btnname的应用列表移动到applistWid界面最顶端 - int index=m_classificationList.indexOf(btnname); - if(index!=-1) - { - int row=m_classificationBtnRowList.at(index).toInt(); - m_appListView->verticalScrollBar()->setValue(row); - } - - m_leaveAnimation->setStartValue(QRect((this->width()-Style::LeftBtnWidth*2-5)/2, - (this->height()-Style::LeftBtnHeight*6-25)/2, - Style::LeftBtnWidth*2+5, - Style::LeftBtnHeight*6+25)); - m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); -// m_enterAnimation->setStartValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); - m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); - m_leaveAnimation->setDuration(100); - m_enterAnimation->setDuration(10); - - m_leaveAnimation->setTargetObject(m_functionBtnWid); - m_enterAnimation->setTargetObject(m_appListView); - m_leaveAnimation->start(); - m_widgetState=0; -} - -void FunctionWidget::animationFinishedSLot() -{ - if(m_widgetState==1) - { - m_appListView->hide(); - m_enterAnimation->start(); - m_widgetState=-1; - m_functionBtnWid->show(); - } - if(m_widgetState==0) - { - m_functionBtnWid->hide(); - m_enterAnimation->start(); - m_widgetState=-1; - m_appListView->show(); - } -} - -void FunctionWidget::widgetMakeZero() -{ - m_functionBtnWid->hide(); - m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_appListView->show(); - m_appListView->verticalScrollBar()->setValue(0); -} - -void FunctionWidget::moveScrollBar(int type) -{ - if(type==0) - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100); - else - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100); -} - -void FunctionWidget::repaintWidget() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_appListView->show(); -} - -void FunctionWidget::setFocusToThis() -{ - this->setFocus(); -} diff --git a/src/FunctionWidget/functionwidget.h b/src/FunctionWidget/functionwidget.h deleted file mode 100644 index 6ecc01c..0000000 --- a/src/FunctionWidget/functionwidget.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -#include "functionbuttonwidget.h" -#include "src/RightClickMenu/rightclickmenu.h" -#include "src/UtilityFunction/listview.h" -#include "src/UtilityFunction/itemdelegate.h" - -class FunctionWidget : public QWidget -{ - Q_OBJECT - -public: - explicit FunctionWidget(QWidget *parent=nullptr); - ~FunctionWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Repaint window - */ - void repaintWidget(); - -private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - FunctionButtonWidget* m_functionBtnWid=nullptr;//Classification list interface - ListView* m_appListView=nullptr; - QVector m_data; - QStringList m_classificationList;//Store the list of category buttons - QStringList m_classificationBtnRowList;//Store the row in which the category button is located - int row=0; - /*Interface switching animation*/ - QPropertyAnimation* m_enterAnimation=nullptr; - QPropertyAnimation* m_leaveAnimation=nullptr; - int m_widgetState=-1; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppListView(int type); - /** - * @brief Insert category button - * @param category: Functional classification name - */ - void insertClassificationBtn(QString btnname); - /** - * @brief Insert application list - * @param desktopfplist: Desktop file path list - */ - void insertAppList(QStringList appnamelist); - -public Q_SLOTS: - /** - * @brief Switch to the function classification button interface - */ - void appClassificationBtnClickedSlot(); - /** - * @brief Receive function classification button interface signal - * @param Category button name - */ - void recvFunctionBtnSignal(QString btnname); - /** - * @brief Open the application - * @param arg: Desktop file path - */ - void execApplication(QString desktopfp); - /** - * @brief Update application list slot function - */ - void updateAppListView(); - /** - * @brief Respond to the list item click - * @param arg: The desktop file information that the application contains - */ - void recvItemClickedSlot(QStringList arg); - /** - * @brief Respond to animation finish - */ - void animationFinishedSLot(); - - void setFocusToThis(); - -Q_SIGNALS: - /** - * @brief Send the classification button click signal to functionbuttonwidget - */ - void sendClassificationbtnList(); - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // FUNCTIONWIDGET_H diff --git a/src/Interface/ukuichineseletter.cpp b/src/Interface/ukuichineseletter.cpp deleted file mode 100644 index f7a1afa..0000000 --- a/src/Interface/ukuichineseletter.cpp +++ /dev/null @@ -1,5827 +0,0 @@ -/* - * 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 -#include - -UkuiChineseLetter::UkuiChineseLetter() -{ - -} - -bool UkuiChineseLetter::In(wchar_t start, wchar_t end, wchar_t code) -{ - if (code >= start && code <= end) - { - return true; - } - return false; -} - -char UkuiChineseLetter::Convert(int n)//此方法有缺陷,只能识别一级字库中的汉字 -{ - /* - * GB2312码范围 (B0A1-F7FE) - * HiByte (B0-F7) LoByte (A1-FE) - * - * GBK编码范围 (8140-FEFE) - * 包含三大部分 - * 1.汉字区 - * a. GB2312汉字区。即GBK/2 - * b. GB13000.1扩充汉字区。包括GBK/3(CJK汉字)和GBK/4(CJK汉字和增补汉字) - * 2.图形符号区 - * a. GB2312非汉字区。即GBK/1 A1A1-A9FE。还有10个小写罗马数字和GB12345增补符号 - * b. GB13000.1扩充非汉字区。即GBK/5 A840-A9A0非汉字符号、结构符... - * 3.用户自定义区 - * - */ - - if (In(0xB0A1,0xB0C4,n)) return 'A'; - if (In(0XB0C5,0XB2C0,n)) return 'B'; - if (In(0xB2C1,0xB4ED,n)) return 'C'; - if (In(0xB4EE,0xB6E9,n)) return 'D'; - if (In(0xB6EA,0xB7A1,n)) return 'E'; - if (In(0xB7A2,0xB8c0,n)) return 'F'; - if (In(0xB8C1,0xB9FD,n)) return 'G'; - if (In(0xB9FE,0xBBF6,n)) return 'H'; - if (In(0xBBF7,0xBFA5,n)) return 'J'; - if (In(0xBFA6,0xC0AB,n)) return 'K'; - if (In(0xC0AC,0xC2E7,n)) return 'L'; - if (In(0xC2E8,0xC4C2,n)) return 'M'; - if (In(0xC4C3,0xC5B5,n)) return 'N'; - if (In(0xC5B6,0xC5BD,n)) return 'O'; - if (In(0xC5BE,0xC6D9,n)) return 'P'; - if (In(0xC6DA,0xC8BA,n)) return 'Q'; - if (In(0xC8BB,0xC8F5,n)) return 'R'; - if (In(0xC8F6,0xCBF0,n)) return 'S'; - if (In(0xCBFA,0xCDD9,n)) return 'T'; - if (In(0xCDDA,0xCEF3,n)) return 'W'; - if (In(0xCEF4,0xD1B8,n)) return 'X'; - if (In(0xD1B9,0xD4D0,n)) return 'Y'; - if (In(0xD4D1,0xD7F9,n)) return 'Z'; - if (In(0x00, 0x7f, n)) return n; - return '\0'; -} - -QString UkuiChineseLetter::getFirstLetter(const QString &src) -{ -// wchar_t wchr = 0; -// QString firstLetter; -// if(src.size() > 0) -// { -// QString str = src.at(0); -// QTextCodec* pCodec = QTextCodec::codecForName("gb2312"); -// if(!pCodec) return QChar(' '); -// QByteArray arr = pCodec->fromUnicode(str); - -// if(arr.size() == 1) -// { -// wchr = arr.at(0) & 0xff; -// } -// else if(arr.size() == 2) -// { -// wchr = (arr.at(0) & 0xff) << 8; -// wchr |= (arr.at(1) & 0xff); -// } -// else -// { -//// qDebug() << "unknown word"; -// } - -// char c = Convert(wchr); -// if(c != 0) -// { -// firstLetter.append(c); -// } -// } - - QString appnamePy=getPinyins(src); - if(!appnamePy.isEmpty()) - return QString(appnamePy.at(0)); - else - return QString(); -} - -QString UkuiChineseLetter::getFirstLetters(const QString &src) -{ - QString firstLetters; - for (int i=0; ifromUnicode(str); - wchar_t wchr = 0; - - if(arr.size() == 1) - { - wchr = arr.at(0) & 0xff; - } - else if(arr.size() == 2) - { - wchr = (arr.at(0) & 0xff) << 8; - wchr |= (arr.at(1) & 0xff); - } - else - { - //qDebug() << "unknown word"; - } - - char c = Convert(wchr); - if(c != 0) - { - firstLetters.append(c); - } - } - return firstLetters; -} - -QString UkuiChineseLetter::getFirstLettersAll(const QString &src) -{ - QString pinyins; - for (int i=0; ifromUnicode(str); - unsigned char high = 0; - unsigned char low = 0; - int code = 0; - - if(arr.size() == 1) - { - high = 0; - low = arr.at(0) & 0xff; - } - else if(arr.size() == 2) - { - high = arr.at(0) & 0xff; - low = arr.at(1) & 0xff; - } - - if ( high < 0xa1 || low < 0xa1) - { - continue; - } - else - { - code = (high - 0xa0) * 100 + low - 0xa0; - } - - pinyins += getPinyin(code).at(0); - } - return pinyins; -} - - -QString UkuiChineseLetter::getPinyins(const QString &text) -{ - QString pinyins; - for (int i=0; i= 0 && c <= 127)) - { - pinyins+=c.toUpper(); - continue; - } - - QString str = text.at(i); - QTextCodec* pCodec = QTextCodec::codecForName("gb2312"); - if(!pCodec) return QChar(' '); - QByteArray arr = pCodec->fromUnicode(str); - unsigned char high = 0; - unsigned char low = 0; - int code = 0; - - if(arr.size() == 1) - { - high = 0; - low = arr.at(0) & 0xff; - } - else if(arr.size() == 2) - { - high = arr.at(0) & 0xff; - low = arr.at(1) & 0xff; - } - - if ( high < 0xa1 || low < 0xa1) - { - continue; - } - else - { - code = (high - 0xa0) * 100 + low - 0xa0; - } - - pinyins += getPinyin(code); - } - return pinyins; -} - - -QString UkuiChineseLetter::getPinyin(int code)//此方法可以获取所有汉字的拼音 -{ - QString pinyin; - switch(code) - { - case 6325: - case 6436: - case 7571: - case 7925: - pinyin="A"; - break; - case 6263: - case 6440: - case 7040: - case 7208: - case 7451: - case 7733: - case 7945: - case 8616: - pinyin="AI"; - break; - case 5847: - case 5991: - case 6278: - case 6577: - case 6654: - case 7281: - case 7907: - case 8038: - case 8786: - pinyin="AN"; - break; - pinyin="ANG"; - break; - case 5974: - case 6254: - case 6427: - case 6514: - case 6658: - case 6959: - case 7033: - case 7081: - case 7365: - case 8190: - case 8292: - case 8643: - case 8701: - case 8773: - pinyin="AO"; - break; - case 6056: - case 6135: - case 6517: - case 7857: - case 8446: - case 8649: - case 8741: - pinyin="BA"; - break; - case 6267: - case 6334: - case 7494: - pinyin="BAI"; - break; - case 5870: - case 5964: - case 7851: - case 8103: - case 8113: - case 8418: - pinyin="BAN"; - break; - case 6182: - case 6826: - pinyin="BANG"; - break; - case 6165: - case 7063: - case 7650: - case 8017: - case 8157: - case 8532: - case 8621: - pinyin="BAO"; - break; - case 5635: - case 5873: - case 5893: - case 5993: - case 6141: - case 6703: - case 7753: - case 8039: - case 8156: - case 8645: - case 8725: - pinyin="BEI"; - break; - case 5946: - case 5948: - case 7458: - case 7928: - pinyin="BEN"; - break; - case 6452: - case 7420: - pinyin="BENG"; - break; - case 5616: - case 5734: - case 6074: - case 6109: - case 6221: - case 6333: - case 6357: - case 6589: - case 6656: - case 6725: - case 6868: - case 6908: - case 6986: - case 6994: - case 7030: - case 7052: - case 7221: - case 7815: - case 7873: - case 7985: - case 8152: - case 8357: - case 8375: - case 8387: - case 8416: - case 8437: - case 8547: - case 8734: - pinyin="BI"; - break; - case 5650: - case 5945: - case 6048: - case 6677: - case 6774: - case 7134: - case 7614: - case 7652: - case 7730: - case 7760: - case 8125: - case 8159: - case 8289: - case 8354: - case 8693: - pinyin="BIAN"; - break; - case 7027: - case 7084: - case 7609: - case 7613: - case 7958: - case 7980: - case 8106: - case 8149: - case 8707: - case 8752: - pinyin="BIAO"; - break; - case 8531: - pinyin="BIE"; - break; - case 5747: - case 6557: - case 7145: - case 7167: - case 7336: - case 7375: - case 7587: - case 7957: - case 8738: - case 8762: - pinyin="BIN"; - break; - case 5787: - case 5891: - case 6280: - pinyin="BING"; - break; - case 5781: - case 6403: - case 6636: - case 7362: - case 7502: - case 7771: - case 7864: - case 8030: - case 8404: - case 8543: - case 8559: - pinyin="BO"; - break; - case 6318: - case 6945: - case 7419: - case 7446: - case 7848: - case 7863: - case 8519: - pinyin="BU"; - break; - case 6474: - case 7769: - pinyin="CA"; - break; - pinyin="CAI"; - break; - case 6978: - case 7078: - case 7218: - case 8451: - case 8785: - pinyin="CAN"; - break; - case 5687: - pinyin="CANG"; - break; - case 6448: - case 6878: - case 8309: - case 8429: - pinyin="CAO"; - break; - case 6692: - pinyin="CE"; - break; - case 6515: - case 6825: - pinyin="CEN"; - break; - case 6465: - pinyin="CENG"; - break; - case 6639: - case 6766: - case 7017: - case 7230: - case 7311: - case 7322: - case 7363: - case 7942: - case 7979: - case 8135: - pinyin="CHA"; - break; - case 5713: - case 7846: - case 8091: - case 8218: - pinyin="CHAI"; - break; - case 5770: - case 5838: - case 6159: - case 6667: - case 6893: - case 6904: - case 6981: - case 7031: - case 7086: - case 7472: - case 7688: - case 7966: - case 8324: - case 8580: - pinyin="CHAN"; - break; - case 5686: - case 5943: - case 6041: - case 6137: - case 6660: - case 6568: - case 6749: - case 7029: - case 7047: - case 7438: - case 7509: - case 8680: - pinyin="CHANG"; - break; - case 6687: - case 7443: - case 8173: - pinyin="CHAO"; - break; - case 5969: - case 7726: - pinyin="CHE"; - break; - case 5840: - case 5863: - case 6251: - case 6433: - case 6923: - case 7201: - case 7320: - case 7755: - case 8619: - pinyin="CHEN"; - break; - case 5609: - case 5984: - case 7239: - case 7263: - case 7583: - case 7810: - case 7881: - case 7905: - case 8146: - case 8241: - case 8508: - pinyin="CHENG"; - break; - case 5749: - case 6015: - case 6061: - case 6319: - case 6374: - case 6420: - case 6445: - case 6633: - case 7042: - case 7523: - case 7787: - case 8023: - case 8101: - case 8161: - case 8231: - case 8304: - case 8355: - case 8388: - case 8489: - case 8556: - case 8746: - pinyin="CHI"; - break; - case 6091: - case 6671: - case 6731: - case 8409: - case 8430: - pinyin="CHONG"; - break; - case 5717: - case 6492: - case 6716: - case 8112: - case 8637: - pinyin="CHOU"; - break; - case 5601: - case 5927: - case 6680: - case 6732: - case 7109: - case 7238: - case 7290: - case 7343: - case 8150: - case 8260: - case 8573: - case 8777: - pinyin="CHU"; - break; - case 6285: - case 6408: - case 7590: - case 8563: - pinyin="CHUAI"; - break; - case 6622: - case 6955: - case 7516: - case 7843: - case 8413: - pinyin="CHUAN"; - break; - case 6675: - pinyin="CHUANG"; - break; - case 5879: - case 7302: - case 7319: - pinyin="CHUI"; - break; - case 6127: - case 8040: - case 8277: - pinyin="CHUN"; - break; - case 7401: - case 8554: - case 8626: - pinyin="CHUO"; - break; - pinyin="CI"; - break; - case 6075: - case 6358: - case 7684: - case 8043: - case 8457: - pinyin="4337 伺"; - break; - case 6042: - case 6840: - case 7085: - case 7193: - case 7214: - case 7240: - pinyin="CONG"; - break; - case 7308: - case 7403: - case 7577: - pinyin="COU"; - break; - case 6180: - case 6562: - case 6607: - case 7367: - case 8501: - case 8530: - case 8577: - pinyin="CU"; - break; - case 5764: - case 6305: - case 7664: - case 7973: - pinyin="CUAN"; - break; - case 6718: - case 6145: - case 6393: - case 7213: - case 7333: - case 7505: - case 8631: - pinyin="CUI"; - break; - case 6666: - case 8169: - pinyin="CUN"; - break; - case 5640: - case 6547: - case 7566: - case 7917: - case 7983: - case 8078: - case 8526: - case 8567: - pinyin="CUO"; - break; - case 6239: - case 6353: - case 6410: - case 6682: - case 7007: - case 8155: - case 8346: - case 8716: - case 8718: - pinyin="DA"; - break; - case 6004: - case 6316: - case 6523: - case 6942: - case 7110: - case 7173: - case 8776: - pinyin="DAI"; - break; - case 5757: - case 6144: - case 6402: - case 7373: - case 7470: - case 7781: - case 8067: - case 8087: - case 8185: - case 8376: - pinyin="DAN"; - break; - case 5852: - case 5942: - case 6148: - case 6920: - case 7724: - case 7885: - case 8141: - pinyin="DANG"; - break; - case 6322: - case 6665: - case 7514: - case 8478: - pinyin="DAO"; - break; - case 7929: - pinyin="DE"; - break; - case 6466: - case 6556: - case 7413: - case 7767: - case 7975: - case 8403: - pinyin="DENG"; - break; - case 5621: - case 5765: - case 5814: - case 5848: - case 5901: - case 5970: - case 6122: - case 6454: - case 7023: - case 7116: - case 7260: - case 7306: - case 7475: - case 7738: - case 7758: - case 7791: - case 7965: - case 8438: - case 8730: - pinyin="DI"; - break; - case 6439: - pinyin="DIA"; - break; - case 5871: - case 5967: - case 6559: - case 7172: - case 7868: - case 8116: - case 8118: - case 8401: - case 8558: - pinyin="DIAN"; - break; - case 7886: - case 8585: - case 8684: - pinyin="DIAO"; - break; - case 5976: - case 6006: - case 6273: - case 6409: - case 7526: - case 8012: - case 8183: - case 8562: - case 8688: - pinyin="DIE"; - break; - case 5674: - case 6404: - case 7164: - case 7575: - case 7754: - case 7814: - case 8059: - case 8184: - case 8490: - pinyin="DING"; - break; - case 7891: - pinyin="DIU"; - break; - case 5977: - case 6343: - case 6520: - case 6528: - case 7517: - case 7543: - case 7556: - case 7747: - case 8020: - pinyin="DONG"; - break; - case 6190: - case 8128: - case 8229: - case 8391: - pinyin="DOU"; - break; - case 6022: - case 6429: - case 6834: - case 7292: - case 7525: - case 8328: - case 8338: - case 8739: - case 8782: - pinyin="DU"; - break; - case 7318: - case 7649: - case 8393: - pinyin="DUAN"; - break; - case 7701: - case 7713: - case 7752: - pinyin="DUI"; - break; - case 6771: - case 7632: - case 7727: - case 7766: - case 7779: - case 7970: - case 8527: - pinyin="DUN"; - break; - case 6345: - case 6365: - case 6785: - case 7122: - case 7876: - case 8154: - case 8566: - pinyin="DUO"; - break; - case 5612: - case 5832: - case 5844: - case 5949: - case 6035: - case 6113: - case 6164: - case 6332: - case 6721: - case 6977: - case 7025: - case 7378: - case 7581: - case 7916: - case 7941: - case 8042: - case 8206: - case 8689: - pinyin="E"; - break; - case 6176: - case 6284: - pinyin="EN"; - break; - case 5706: - case 6939: - case 7177: - case 7879: - case 8025: - case 8660: - pinyin="ER"; - break; - case 5950: - case 7732: - pinyin="FA"; - break; - case 6212: - case 6232: - case 6506: - case 7283: - case 7660: - case 7818: - case 8576: - pinyin="FAN"; - break; - case 5890: - case 7242: - case 7853: - case 8419: - case 8648: - pinyin="FANG"; - break; - case 6032: - case 6584: - case 6713: - case 6839: - case 6990: - case 7119: - case 7328: - case 7572: - case 7619: - case 7673: - case 7948: - case 8082: - case 8267: - case 8385: - case 8468: - case 8613: - case 8678: - pinyin="FEI"; - break; - case 5739: - case 6915: - case 7291: - case 8687: - case 8787: - pinyin="FEN"; - break; - case 5726: - case 5926: - case 6155: - case 6384: - case 6767: - case 7731: - pinyin="FENG"; - break; - pinyin="FO"; - break; - case 8330: - pinyin="FOU"; - break; - case 5775: - case 5776: - case 5914: - case 6029: - case 6062: - case 6119: - case 6142: - case 6252: - case 6327: - case 6505: - case 6686: - case 6870: - case 6985: - case 7058: - case 7066: - case 7106: - case 7108: - case 7285: - case 7471: - case 7680: - case 7741: - case 7774: - case 7775: - case 7823: - case 7991: - case 8005: - case 8222: - case 8261: - case 8280: - case 8283: - case 8479: - case 8535: - case 8538: - case 8654: - case 8691: - pinyin="FU"; - break; - case 6246: - case 7056: - case 7057: - case 7424: - case 7837: - pinyin=" GA"; - break; - case 5604: - case 5875: - case 5982: - case 7414: - case 7464: - pinyin="GAI"; - break; - case 5965: - case 6053: - case 6247: - case 6306: - case 6779: - case 6838: - case 6887: - case 7104: - case 7347: - case 7426: - case 7723: - case 8065: - case 8491: - pinyin="GAN"; - break; - case 7716: - case 7824: - case 8364: - pinyin="GANG"; - break; - case 5626: - case 5830: - case 5912: - case 6227: - case 7141: - case 7332: - case 7334: - case 7429: - case 7915: - pinyin="GAO"; - break; - case 5610: - case 5678: - case 5933: - case 5957: - case 6010: - case 6435: - case 7092: - case 7501: - case 7585: - case 7749: - case 7951: - case 8143: - case 8220: - case 8420: - case 8732: - pinyin="GE"; - break; - pinyin="GEI"; - break; - case 5608: - case 6102: - case 6371: - case 8462: - pinyin="GEN"; - break; - case 6376: - case 6657: - case 7114: - case 8665: - pinyin="GENG"; - break; - case 7178: - case 7537: - case 8228: - case 8601: - pinyin="GONG"; - break; - case 5694: - case 5824: - case 6524: - case 6960: - case 7037: - case 7135: - case 7259: - case 7477: - case 7616: - case 8349: - case 8384: - case 8724: - pinyin="GOU"; - break; - case 5637: - case 5812: - case 6152: - case 6536: - case 6773: - case 7284: - case 7379: - case 7484: - case 7486: - case 7591: - case 7617: - case 7813: - case 7825: - case 7860: - case 7932: - case 8019: - case 8083: - case 8233: - case 8494: - case 8593: - case 8681: - case 8729: - pinyin="GU"; - break; - case 5652: - case 5820: - case 6341: - case 7273: - case 7550: - case 8027: - pinyin="GUA"; - break; - pinyin="GUAI"; - break; - case 5736: - case 6124: - case 6272: - case 6842: - case 7834: - case 8057: - case 8170: - case 8704: - pinyin="GUAN"; - break; - case 6359: - case 6578: - case 7270: - case 7555: - pinyin="GUANG"; - break; - case 5648: - case 5659: - case 6649: - case 7003: - case 7277: - case 7433: - case 7448: - case 8007: - case 8394: - case 8657: - case 8712: - pinyin="GUI"; - break; - case 5782: - case 7121: - case 7762: - case 8671: - pinyin="GUN"; - break; - case 5769: - case 6266: - case 6335: - case 6494: - case 6538: - case 6603: - case 7304: - case 7529: - case 8188: - case 8268: - case 8269: - pinyin="GUO"; - break; - case 7894: - pinyin="HA"; - break; - case 6443: - case 7560: - case 8516: - pinyin="HAI"; - break; - case 5885: - case 6153: - case 6294: - case 6759: - case 6911: - case 7447: - case 7642: - case 8192: - case 8205: - case 8232: - case 8793: - pinyin="HAN"; - break; - case 6776: - case 7112: - case 8194: - pinyin="HANG"; - break; - case 6179: - case 6222: - case 6438: - case 6467: - case 6909: - case 6916: - case 7427: - case 8009: - case 8211: - case 8226: - pinyin="HAO"; - break; - case 5813: - case 5932: - case 5954: - case 6432: - case 6756: - case 7434: - case 7833: - case 8202: - case 8234: - case 8471: - pinyin="HE"; - break; - pinyin="HEI"; - break; - pinyin="HEN"; - break; - case 6231: - case 7181: - case 7276: - pinyin="HENG"; - break; - case 5768: - case 5774: - case 5807: - case 6106: - case 6214: - case 6216: - case 6740: - case 6792: - pinyin="HONG"; - break; - case 6009: - case 6565: - case 6943: - case 8090: - case 8383: - case 8455: - case 8655: - case 8731: - pinyin="HOU"; - break; - case 5792: - case 6392: - case 6481: - case 6518: - case 6609: - case 6679: - case 6717: - case 6816: - case 6879: - case 7190: - case 7346: - case 7385: - case 7618: - case 7635: - case 7646: - case 7670: - case 7672: - case 7679: - case 8013: - case 8032: - case 8041: - case 8055: - case 8343: - case 8513: - case 8590: - pinyin="HU"; - break; - case 7072: - case 7275: - case 7725: - case 7892: - pinyin="HUA"; - break; - case 8555: - pinyin="HUAI"; - break; - case 5928: - case 6140: - case 6307: - case 6487: - case 6621: - case 6801: - case 6829: - case 6881: - case 6930: - case 6953: - case 7157: - case 7944: - case 8673: - case 8763: - pinyin="HUAN"; - break; - case 5882: - case 6569: - case 6850: - case 6874: - case 6956: - case 7211: - case 7533: - case 8105: - case 8308: - case 8382: - case 8692: - pinyin="HUANG"; - break; - case 5822: - case 6078: - case 6086: - case 6205: - case 6352: - case 6360: - case 6425: - case 6736: - case 6807: - case 6811: - case 6971: - case 7132: - case 7185: - case 7445: - case 7703: - case 8219: - case 8319: - case 8766: - pinyin="HUI"; - break; - case 5827: - case 6638: - case 6752: - case 6867: - pinyin="HUN"; - break; - case 5669: - case 6229: - case 6311: - case 6475: - case 6623: - case 7856: - case 7933: - case 7976: - case 8175: - case 8322: - pinyin="HUO"; - break; - case 5629: - case 5632: - case 5662: - case 5705: - case 5742: - case 5952: - case 6024: - case 6033: - case 6193: - case 6210: - case 6265: - case 6320: - case 6350: - case 6383: - case 6507: - case 6553: - case 6809: - case 6976: - case 7087: - case 7160: - case 7165: - case 7314: - case 7374: - case 7410: - case 7411: - case 7469: - case 7473: - case 7487: - case 7620: - case 7722: - case 7831: - case 7990: - case 8002: - case 8104: - case 8217: - case 8337: - case 8339: - case 8463: - case 8550: - case 8611: - case 8661: - case 8674: - case 8757: - case 8768: - pinyin="JI"; - break; - case 5704: - case 5903: - case 6171: - case 6521: - case 6804: - case 6940: - case 7176: - case 7409: - case 7546: - case 7702: - case 7882: - case 7956: - case 8072: - case 8142: - case 8244: - case 8353: - case 8434: - case 8542: - pinyin="JIA"; - break; - case 5752: - case 5841: - case 5857: - case 6149: - case 6183: - case 6286: - case 6853: - case 6931: - case 6932: - case 7144: - case 7237: - case 7305: - case 7407: - case 7415: - case 7480: - case 7489: - case 7506: - case 7576: - case 7790: - case 7921: - case 8047: - case 8148: - case 8340: - case 8469: - case 8534: - case 8561: - case 8668: - case 8721: - pinyin="JIAN"; - break; - case 6092: - case 6814: - case 7113: - case 7154: - case 7481: - case 7768: - case 8180: - case 8461: - case 8488: - pinyin="JIANG"; - break; - case 5714: - case 5753: - case 6020: - case 6090: - case 6256: - case 6461: - case 6572: - case 7015: - case 7524: - case 8008: - case 8052: - case 8252: - case 8520: - case 8551: - case 8662: - pinyin="JIAO"; - break; - case 5806: - case 5821: - case 6255: - case 6414: - case 7028: - case 7061: - case 7278: - case 7757: - case 8060: - case 8201: - case 8227: - case 8441: - case 8658: - case 8726: - pinyin="JIE"; - break; - case 5865: - case 6103: - case 6132: - case 6468: - case 6643: - case 6659: - case 7138: - case 7210: - case 7340: - case 7465: - case 7478: - case 8138: - pinyin="JIN"; - break; - case 5751: - case 5869: - case 6128: - case 6616: - case 6729: - case 6794: - case 6941: - case 6982: - case 7026: - case 7534: - case 7554: - case 7570: - case 7626: - pinyin="JIANG"; - break; - case 6936: - case 7671: - pinyin="JIONG"; - break; - case 5754: - case 6417: - case 6746: - case 7249: - case 7274: - case 8015: - case 8053: - case 8481: - case 8761: - pinyin="JIU"; - break; - case 5738: - case 5810: - case 6036: - case 6058: - case 6076: - case 6268: - case 6965: - case 6980: - case 7202: - case 7307: - case 7316: - case 7323: - case 7357: - case 7381: - case 7488: - case 7611: - case 7850: - case 7924: - case 8022: - case 8132: - case 8153: - case 8482: - case 8522: - case 8565: - case 8620: - case 8634: - case 8722: - pinyin="JU"; - break; - case 5918: - case 6590: - case 6824: - case 7280: - case 7835: - case 7935: - case 7952: - case 8633: - pinyin="JUAN"; - break; - case 5642: - case 5667: - case 5860: - case 5939: - case 6207: - case 6421: - case 6457: - case 6469: - case 6540: - case 6617: - case 7062: - case 7169: - case 7286: - case 7351: - case 7663: - case 7967: - case 8574: - case 8591: - pinyin="JUE"; - break; - case 6260: - case 8168: - case 8362: - case 8769: - pinyin="JUN"; - break; - case 5671: - case 6339: - case 7544: - pinyin="KA"; - break; - case 5660: - case 5978: - case 6160: - case 6673: - case 6693: - case 7888: - case 7920: - case 7939: - pinyin="KAI"; - break; - case 5709: - case 6108: - case 7412: - case 7772: - case 7811: - pinyin="KAN"; - break; - case 5688: - case 6742: - case 7854: - pinyin="KANG"; - break; - case 6974: - case 7264: - case 7491: - case 7877: - pinyin="KAO"; - break; - case 6430: - case 6519: - case 6701: - case 6859: - case 7076: - case 7128: - case 7170: - case 7380: - case 7520: - case 7807: - case 7861: - case 7930: - case 7993: - case 8066: - case 8129: - case 8204: - case 8282: - case 8733: - pinyin="KE"; - break; - case 8144: - pinyin="KEN"; - break; - case 7912: - pinyin="KENG"; - break; - case 5737: - case 6539: - case 8377: - pinyin="KONG"; - break; - case 6050: - case 6202: - case 6321: - case 7778: - case 8356: - pinyin="KOU"; - break; - case 5658: - case 6005: - case 6423: - case 7111: - case 8728: - pinyin="KU"; - break; - case 5708: - pinyin="KUA"; - break; - case 5665: - case 5906: - case 6364: - case 6586: - case 7558: - pinyin="KUAI"; - break; - case 8737: - pinyin="KUAN"; - break; - case 5818: - case 5831: - case 5887: - case 5959: - case 6237: - case 6349: - case 7094: - case 7460: - pinyin="KUANG"; - break; - case 5624: - case 5649: - case 5771: - case 6162: - case 6281: - case 6413: - case 6416: - case 6720: - case 6951: - case 7450: - case 7805: - case 8606: - case 8743: - pinyin="KUI"; - break; - case 6204: - case 6245: - case 6458: - case 6618: - case 6928: - case 7152: - case 7841: - case 8051: - pinyin="LIAO"; - break; - case 5793: - case 5988: - case 6270: - case 6354: - case 6803: - case 8483: - case 8581: - case 8764: - pinyin="LIE"; - break; - case 6194: - case 6388: - case 6555: - case 6662: - case 6733: - case 6964: - case 7361: - case 7405: - case 7602: - case 7812: - case 8452: - case 8579: - case 8775: - pinyin="LIN"; - break; - case 5925: - case 6063: - case 6342: - case 6482: - case 6786: - case 7117: - case 7258: - case 7289: - case 7418: - case 8186: - case 8240: - case 8465: - case 8676: - pinyin="LING"; - break; - case 6815: - case 6962: - case 7082: - case 7124: - case 7628: - case 7654: - case 7919: - case 7954: - case 8050: - case 8644: - pinyin="LIU"; - break; - case 5966: - case 6055: - case 6781: - case 7171: - case 7248: - case 7542: - case 7735: - case 8110: - pinyin="LONG"; - break; - case 5745: - case 6168: - case 6422: - case 6548: - case 7946: - case 8092: - case 8179: - case 8287: - case 8735: - pinyin="LOU"; - break; - case 6744: - case 7321: - case 7586: - case 7918: - case 7989: - case 8158: - pinyin="Lü"; - break; - case 5968: - case 6303: - case 6464: - case 6782: - case 6843: - case 6885: - case 6954: - case 7220: - case 7251: - case 7354: - case 7391: - case 7404: - case 7510: - case 7545: - case 7969: - case 8021: - case 8056: - case 8392: - case 8421: - case 8652: - pinyin="LU"; - break; - case 5785: - case 7014: - case 7279: - case 8029: - case 8639: - pinyin="LUAN"; - break; - pinyin="LǖE"; - break; - pinyin="LUN"; - break; - case 5732: - case 5789: - case 6093: - case 6259: - case 6291: - case 6604: - case 6788: - case 6880: - case 7183: - case 7301: - case 7565: - case 7961: - case 8107: - case 8635: - pinyin="LUO"; - break; - case 6328: - pinyin="M"; - break; - case 6373: - case 6579: - case 7054: - case 7231: - case 8301: - pinyin="MA"; - break; - case 5929: - case 6104: - case 8618: - pinyin="MAI"; - break; - case 6012: - case 6503: - case 7147: - case 7655: - case 7960: - case 8209: - case 8293: - case 8709: - case 8720: - pinyin="MAN"; - break; - case 5888: - case 6861: - case 7743: - case 8294: - pinyin="MANG"; - break; - case 5783: - case 6066: - case 6525: - case 6787: - case 7203: - case 7436: - case 7483: - case 7503: - case 7624: - case 7714: - case 7806: - case 8317: - case 8754: - pinyin="MAO"; - break; - case 6114: - case 6550: - case 6613: - case 6828: - case 6856: - case 7325: - case 7949: - case 8044: - case 8139: - case 8740: - pinyin="MEI"; - break; - case 6249: - case 7643: - case 7715: - case 7845: - pinyin="MEN"; - break; - case 5934: - case 6189: - case 6211: - case 6734: - case 7592: - case 7770: - case 8221: - case 8276: - case 8323: - case 8427: - case 8431: - pinyin="MENG"; - break; - case 5634: - case 5855: - case 6234: - case 6368: - case 6455: - case 6608: - case 6772: - case 6921: - case 6984: - case 7563: - case 7682: - case 8445: - case 8767: - case 8771: - pinyin="MI"; - break; - case 6770: - case 6837: - case 6847: - case 7579: - case 7777: - pinyin="MIAN"; - break; - case 6387: - case 6967: - case 7131: - case 7149: - case 7234: - case 7721: - case 7780: - case 8037: - pinyin="MIAO"; - break; - case 5631: - case 6367: - case 8326: - case 8390: - pinyin="MIE"; - break; - case 6069: - case 6526: - case 6741: - case 6793: - case 7137: - case 7168: - case 7175: - case 7710: - case 8710: - case 8628: - pinyin="MIN"; - break; - case 5804: - case 6088: - case 6873: - case 7452: - case 7808: - case 8504: - pinyin="MING"; - break; - pinyin="MIU"; - break; - case 5851: - case 6052: - case 6175: - case 6641: - case 7038: - case 7366: - case 7950: - case 7987: - case 8102: - case 8182: - case 8586: - case 8588: - case 8765: - pinyin="MO"; - break; - case 5716: - case 6372: - case 7788: - case 8254: - case 8290: - case 8642: - pinyin="MOU"; - break; - case 5679: - case 5973: - case 6057: - case 6769: - case 7504: - case 7866: - pinyin="MU"; - break; - case 6437: - pinyin="N"; - break; - case 6264: - case 7539: - case 7953: - case 8136: - pinyin="NA"; - break; - case 5630: - case 6021: - case 6133: - case 7245: - pinyin="NAI"; - break; - case 6411: - case 6478: - case 6479: - case 7310: - case 7578: - case 8279: - case 8486: - pinyin="NAN"; - break; - case 6313: - case 6476: - case 6646: - case 7457: - pinyin="NANG"; - break; - case 5611: - case 5981: - case 6346: - case 6614: - case 7207: - case 7748: - case 7883: - case 8245: - pinyin="NAO"; - break; - case 5811: - pinyin="NE"; - break; - pinyin="NEI"; - break; - case 7705: - pinyin="NEN"; - break; - pinyin="NENG"; - break; - case 5703: - case 5972: - case 6605: - case 6685: - case 7439: - case 7627: - case 7711: - case 7794: - case 7874: - case 8682: - pinyin="NI"; - break; - case 5605: - case 5994: - case 7393: - case 8004: - case 8651: - case 8683: - pinyin="NIAN"; - break; - pinyin="NIANG"; - break; - case 6064: - case 7053: - case 7569: - case 8433: - pinyin="NIAO"; - break; - case 5877: - case 6233: - case 6431: - case 8208: - case 8411: - case 8570: - pinyin="NIE"; - break; - pinyin="NIN"; - break; - case 5690: - case 6344: - case 6924: - case 8187: - pinyin="NING"; - break; - case 6580: - case 6678: - case 7004: - pinyin="NIU"; - break; - case 5715: - case 6370: - pinyin="NONG"; - break; - case 8181: - pinyin="NOU"; - break; - case 6983: - case 7032: - case 7059: - case 7069: - pinyin="NU"; - break; - case 7704: - case 7847: - case 8412: - pinyin="Nǖ"; - break; - pinyin="NUAN"; - break; - pinyin="NUE"; - break; - case 5748: - case 6289: - case 6386: - case 7927: - pinyin="NUO"; - break; - case 6424: - case 6462: - pinyin="O"; - break; - case 5809: - case 6670: - case 7417: - case 8178: - pinyin="OU"; - break; - case 6166: - case 7243: - case 8365: - pinyin="PA"; - break; - case 5729: - case 6169: - case 6363: - pinyin="PAI"; - break; - case 6761: - case 6790: - case 8140: - case 8165: - case 8320: - case 8571: - pinyin="PAN"; - break; - case 6561: - case 6872: - case 6944: - case 8306: - pinyin="PANG"; - break; - case 6243: - case 6583: - case 6650: - case 7567: - case 8069: - pinyin="PAO"; - break; - case 6446: - case 6490: - case 7623: - case 7934: - case 8512: - case 8612: - pinyin="PEI"; - break; - case 6852: - pinyin="PEN"; - break; - case 6001: - case 6456: - case 6681: - case 8318: - pinyin="PENG"; - break; - case 5607: - case 5682: - case 5880: - case 5892: - case 5915: - case 5960: - case 6017: - case 6037: - case 6308: - case 6472: - case 6647: - case 6836: - case 7039: - case 7102: - case 7233: - case 7422: - case 7802: - case 7828: - case 7875: - case 8117: - case 8166: - case 8223: - case 8271: - case 8589: - pinyin="PI"; - break; - case 5850: - case 7073: - case 7490: - case 7561: - case 8470: - case 8568: - pinyin="PIAN"; - break; - case 5666: - case 6449: - case 7046: - case 7146: - case 7372: - case 7809: - case 8310: - pinyin="PIAO"; - break; - case 6054: - case 7513: - pinyin="PIE"; - break; - case 7041: - case 6253: - case 7016: - case 7315: - case 7482: - case 8213: - pinyin="PIN"; - break; - case 5723: - case 7019: - case 7250: - case 8650: - pinyin="PING"; - break; - case 5647: - case 5922: - case 7174: - case 7839: - case 7862: - case 8011: - case 8345: - pinyin="PO"; - break; - case 5786: - case 6269: - pinyin="POU"; - break; - case 5773: - case 6459: - case 6863: - case 6907: - case 7217: - case 7511: - case 7968: - case 7972: - case 8575: - pinyin="PU"; - break; - case 5633: - case 5725: - case 5963: - case 6027: - case 6046: - case 6089: - case 6129: - case 6134: - case 6161: - case 6213: - case 6366: - case 6450: - case 6508: - case 6510: - case 6764: - case 6831: - case 7075: - case 7118: - case 7187: - case 7189: - case 7229: - case 7271: - case 7342: - case 7440: - case 7605: - case 7687: - case 7712: - case 7751: - case 8193: - case 8251: - case 8264: - case 8475: - case 8476: - case 8572: - case 8702: - case 8772: - pinyin="QI"; - break; - case 6154: - case 8736: - pinyin="QIA"; - break; - case 5727: - case 5761: - case 5868: - case 6023: - case 6045: - case 6071: - case 6271: - case 6509: - case 6705: - case 6727: - case 6925: - case 6926: - case 6929: - case 7155: - case 7293: - case 7541: - case 7709: - case 7852: - case 8215: - case 8373: - pinyin="QIAN"; - break; - case 6762: - case 7045: - case 7341: - case 7408: - case 7633: - case 7926: - case 7947: - case 7974: - case 8163: - case 8262: - case 8439: - case 8536: - pinyin="QIANG"; - break; - case 5668: - case 5829: - case 5859: - case 6081: - case 6529: - case 6724: - case 6730: - case 7352: - case 7745: - case 8546: - case 8719: - pinyin="QIAO"; - break; - case 5907: - case 6711: - case 7010: - case 7492: - case 7938: - case 8370: - pinyin="QIE"; - break; - case 6043: - case 6276: - case 6336: - case 6426: - case 6463: - case 6858: - case 7353: - case 7923: - case 8291: - case 8432: - pinyin="QIN"; - break; - case 6060: - case 6485: - case 7349: - case 7764: - case 8263: - case 8332: - case 8368: - case 8605: - case 8675: - case 8784: - pinyin="QING"; - break; - case 5886: - case 6068: - case 8123: - case 8243: - case 8344: - case 8528: - case 8638: - pinyin="QIONG"; - break; - case 5720: - case 5947: - case 6576: - case 6848: - case 6947: - case 6957: - case 7317: - case 7468: - case 8216: - case 8239: - case 8288: - case 8435: - case 8460: - case 8690: - case 8792: - pinyin="QIU"; - break; - case 5816: - case 5930: - case 6201: - case 6230: - case 6511: - case 6573: - case 6754: - case 7219: - case 7479: - case 7512: - case 7552: - case 7678: - case 7765: - case 8119: - case 8248: - case 8329: - case 8480: - case 8636: - case 8781: - pinyin="QU"; - break; - case 5825: - case 6085: - case 6710: - case 7125: - case 7390: - case 7816: - case 7893: - case 8273: - case 8360: - case 8760: - pinyin="QUAN"; - break; - case 6755: - case 6758: - case 7708: - pinyin="QUE"; - break; - case 6950: - pinyin="QUN"; - break; - case 6059: - case 8237: - case 8755: - pinyin="RAN"; - break; - case 7692: - case 8006: - pinyin="RANG"; - break; - case 6073: - case 7012: - case 7267: - pinyin="RAO"; - break; - pinyin="RE"; - break; - case 5680: - case 6083: - case 6156: - case 6631: - case 7377: - case 7994: - case 8137: - pinyin="REN"; - break; - pinyin="RENG"; - break; - pinyin="RI"; - break; - case 6541: - case 6585: - case 7337: - case 7532: - case 8278: - pinyin="RONG"; - break; - case 8459: - case 8569: - case 8723: - pinyin="ROU"; - break; - case 6174: - case 6224: - case 6473: - case 6818: - case 6865: - case 6906: - case 7140: - case 7908: - case 8164: - case 8212: - pinyin="RU"; - break; - case 7535: - pinyin="RUAN"; - break; - case 6039: - case 6208: - case 7236: - case 7803: - case 8224: - pinyin="RUI"; - break; - pinyin="RUN"; - break; - case 5728: - case 8372: - pinyin="RUO"; - break; - case 5606: - case 5677: - case 7493: - case 7559: - case 7610: - pinyin="SA"; - break; - case 6471: - pinyin="SAI"; - break; - case 6644: - case 7507: - case 8454: - pinyin="SAN"; - break; - case 6290: - case 7763: - case 8210: - pinyin="SANG"; - break; - case 6003: - case 7150: - case 7156: - case 7593: - case 8094: - case 8694: - pinyin="SAO"; - break; - pinyin="SE"; - break; - pinyin="SEN"; - break; - pinyin="SENG"; - break; - case 6394: - case 7606: - case 7901: - case 8080: - case 8436: - case 8614: - case 8672: - pinyin="SHA"; - break; - case 8507: - pinyin="SHAI"; - break; - case 5663: - case 5808: - case 5923: - case 5979: - case 6047: - case 6890: - case 7009: - case 7051: - case 7083: - case 7594: - case 7844: - case 8062: - case 8321: - case 8414: - case 8539: - case 8713: - pinyin="SHAN"; - break; - case 5980: - case 7120: - case 7368: - case 7656: - case 8592: - pinyin="SHANG"; - break; - case 5931: - case 6070: - case 6891: - case 7228: - case 8366: - case 8425: - pinyin="SHAO"; - break; - case 5639: - case 5760: - case 6606: - case 6860: - case 7608: - case 7820: - case 8774: - pinyin="SHE"; - break; - case 5837: - case 6123: - case 6351: - case 6841: - case 7309: - case 7547: - case 7982: - case 8255: - pinyin="SHEN"; - break; - case 6551: - case 7441: - case 7782: - case 8347: - pinyin="SHENG"; - break; - case 5854: - case 5985: - case 6110: - case 6173: - case 6317: - case 7388: - case 7459: - case 7634: - case 7870: - case 8307: - case 8334: - case 8363: - case 8525: - case 8669: - case 8685: - pinyin="SHI"; - break; - case 6587: - case 7123: - case 8428: - pinyin="SHOU"; - break; - case 5731: - case 5951: - case 6136: - case 6283: - case 6780: - case 6888: - case 7013: - case 7508: - case 7582: - case 7988: - pinyin="SHU"; - break; - case 6407: - pinyin="SHUA"; - break; - case 8316: - pinyin="SHUAI"; - break; - case 6737: - case 6844: - pinyin="SHUAN"; - break; - case 7055: - pinyin="SHUANG"; - break; - pinyin="SHUI"; - break; - pinyin="SHUN"; - break; - case 6184: - case 6287: - case 6989: - case 7335: - case 7869: - pinyin="SHUO"; - break; - case 5643: - case 5778: - case 5944: - case 6348: - case 6765: - case 6784: - case 6889: - case 7006: - case 7065: - case 7133: - case 7675: - case 7940: - case 8024: - case 8174: - case 8247: - case 8351: - pinyin="SI"; - break; - case 5801: - case 6131: - case 6534: - case 6552: - case 6676: - case 6704: - case 6833: - case 8121: - pinyin="SONG"; - break; - case 5937: - case 6220: - case 6418: - case 6453: - case 6640: - case 6849: - case 7612: - case 7804: - case 7943: - case 8284: - pinyin="SOU"; - break; - case 5777: - case 5853: - case 6188: - case 6428: - case 6726: - case 6819: - case 8389: - case 8602: - case 8653: - pinyin="SU"; - break; - case 6601: - pinyin="SUAN"; - break; - case 5839: - case 6120: - case 6901: - case 6968: - case 7661: - case 7785: - case 7801: - pinyin="SUI"; - break; - case 6105: - case 6588: - case 6624: - case 7330: - case 8632: - pinyin="SUN"; - break; - case 6379: - case 6434: - case 6442: - case 7022: - case 7288: - case 7792: - case 8440: - pinyin="SUO"; - break; - case 6743: - case 6866: - case 6961: - case 7329: - case 7719: - case 7872: - case 8533: - case 8703: - pinyin="TA"; - break; - case 5902: - case 6223: - case 6330: - case 7070: - case 7536: - case 7638: - case 7849: - case 8544: - case 8656: - pinyin="TAI"; - break; - case 5916: - case 6903: - case 7428: - case 7694: - case 7867: - case 7936: - case 8191: - pinyin="TAN"; - break; - case 5746: - case 6491: - case 6871: - case 7209: - case 7344: - case 7906: - case 7959: - case 8177: - case 8305: - case 8311: - case 8442: - case 8517: - pinyin="TANG"; - break; - case 5627: - case 6391: - case 6812: - case 7226: - case 7666: - pinyin="TAO"; - break; - pinyin="1845 餐"; - break; - case 6315: - case 7693: - case 7911: - pinyin="TE"; - break; - case 7588: - pinyin="TENG"; - break; - case 5735: - case 6709: - case 6949: - case 7130: - case 8035: - case 8151: - case 8514: - pinyin="TI"; - break; - case 6261: - case 6735: - case 6757: - case 7369: - case 7817: - pinyin="TIAN"; - break; - case 5712: - case 7686: - case 8127: - case 8272: - case 8352: - case 8448: - case 8622: - case 8670: - case 8756: - pinyin="TIAO"; - break; - case 6138: - case 8749: - pinyin="TIE"; - break; - case 6080: - case 6167: - case 7035: - case 7272: - case 7890: - case 8249: - case 8610: - pinyin="TING"; - break; - case 5701: - case 5758: - case 6077: - case 6444: - case 6690: - case 6892: - case 7737: - pinyin="TONG"; - break; - case 7855: - case 7822: - case 8727: - pinyin="TOU"; - break; - case 6002: - case 6117: - case 6143: - case 7842: - case 8509: - pinyin="TU"; - break; - case 6250: - case 6972: - pinyin="TUAN"; - break; - case 7653: - pinyin="TUI"; - break; - case 5759: - case 6629: - case 7453: - case 7564: - pinyin="TUN"; - break; - case 5617: - case 5702: - case 5971: - case 6653: - case 6791: - case 7256: - case 7262: - case 7350: - case 7740: - case 8374: - case 8502: - case 8541: - case 8630: - pinyin="TUO"; - break; - case 5684: - case 7020: - case 7580: - pinyin="WA"; - break; - pinyin="WAI"; - break; - case 5664: - case 6025: - case 6150: - case 7093: - case 7126: - case 7194: - case 7568: - case 7821: - case 8274: - pinyin="WAN"; - break; - case 5672: - case 6244: - case 6715: - case 7394: - case 8745: - pinyin="WANG"; - break; - case 5743: - case 5835: - case 5881: - case 5883: - case 6158: - case 6217: - case 6488: - case 6501: - case 6543: - case 6545: - case 6611: - case 6612: - case 6739: - case 6777: - case 6802: - case 6822: - case 6952: - case 7024: - case 7166: - case 7224: - case 7406: - case 7631: - case 7648: - case 8084: - case 8426: - case 8659: - pinyin="WEI"; - break; - case 5656: - case 6751: - case 6775: - case 7223: - case 8609: - pinyin="WEN"; - break; - case 6178: - case 6219: - pinyin="WENG"; - break; - case 5733: - case 6111: - case 6502: - case 6855: - case 7531: - case 7750: - case 8627: - pinyin="WO"; - break; - case 5603: - case 5685: - case 5867: - case 5889: - case 5956: - case 6044: - case 6377: - case 6648: - case 6668: - case 6672: - case 6820: - case 6927: - case 6935: - case 6992: - case 7036: - case 7080: - case 7227: - case 7485: - case 7641: - case 8036: - case 8045: - case 8077: - case 8258: - case 8640: - case 8789: - pinyin="WU"; - break; - case 5750: - case 5766: - case 5884: - case 5913: - case 6130: - case 6163: - case 6191: - case 6241: - case 6381: - case 6567: - case 6630: - case 6750: - case 6827: - case 6832: - case 6979: - case 7050: - case 7184: - case 7356: - case 7456: - case 7474: - case 7604: - case 7668: - case 7689: - case 7691: - case 8010: - case 8122: - case 8265: - case 8303: - case 8312: - case 8410: - case 8424: - case 8443: - case 8449: - case 8466: - case 8521: - case 8791: - pinyin="XI"; - break; - case 6340: - case 6582: - case 6958: - case 7206: - case 7252: - case 7744: - case 8093: - case 8333: - case 8779: - pinyin="XIA"; - break; - case 5794: - case 5823: - case 6040: - case 6118: - case 6226: - case 6513: - case 6593: - case 6963: - case 7021: - case 7515: - case 7662: - case 7676: - case 8034: - case 8079: - case 8225: - case 8358: - case 8444: - case 8503: - case 8548: - case 8549: - case 8617: - pinyin="XIAN"; - break; - case 6028: - case 6157: - case 6635: - case 6652: - case 7088: - case 7129: - case 8313: - case 8663: - case 8747: - pinyin="XIANG"; - break; - case 6356: - case 6537: - case 6876: - case 6948: - case 7071: - case 7115: - case 7241: - case 7253: - case 8257: - case 8367: - case 8379: - case 8744: - pinyin="XIAO"; - break; - case 5741: - case 5784: - case 5936: - case 5938: - case 6215: - case 6302: - case 6619: - case 6661: - case 6845: - case 6912: - case 6966: - case 7105: - case 7151: - case 7331: - case 7339: - case 8583: - pinyin="XIE"; - break; - case 5622: - case 6016: - case 7431: - case 7607: - case 8646: - pinyin="XIN"; - break; - case 5874: - case 6084: - case 6309: - case 6712: - case 7742: - pinyin="XING"; - break; - case 6026: - pinyin="XIONG"; - break; - case 6361: - case 6522: - case 6642: - case 6651: - case 6869: - case 8028: - case 8587: - case 8759: - pinyin="XIU"; - break; - case 5828: - case 5935: - case 5955: - case 6203: - case 6810: - case 6851: - case 7179: - case 7282: - case 7667: - case 7776: - case 8167: - case 8458: - case 8515: - pinyin="XU"; - break; - case 5756: - case 5846: - case 6170: - case 6279: - case 6789: - case 6854: - case 6886: - case 7215: - case 7324: - case 7449: - case 7637: - case 7651: - case 7759: - case 7871: - case 7964: - case 8071: - pinyin="XUAN"; - break; - case 5842: - case 7720: - case 8529: - case 8708: - pinyin="XUE"; - break; - case 5767: - case 5908: - case 5987: - case 6087: - case 6101: - case 6206: - case 6225: - case 6530: - case 6563: - case 6620: - case 6694: - case 6813: - case 6817: - case 7454: - case 8131: - case 8524: - case 8664: - pinyin="XUN"; - break; - case 5683: - case 5975: - case 6275: - case 6512: - case 6934: - case 7011: - case 7180: - case 7266: - case 7518: - case 7728: - case 7793: - case 8073: - pinyin="YA"; - break; - case 5641: - case 5645: - case 5718: - case 5740: - case 5780: - case 5861: - case 5917: - case 5919: - case 6030: - case 6146: - case 6535: - case 6691: - case 6738: - case 6753: - case 6846: - case 6857: - case 6991: - case 7044: - case 7192: - case 7360: - case 7444: - case 7557: - case 7645: - case 7827: - case 8359: - case 8506: - case 8742: - case 8748: - case 8790: - pinyin="YAN"; - break; - case 6564: - case 6683: - case 7630: - case 7640: - case 7706: - case 8253: - case 8717: - pinyin="YANG"; - break; - case 5618: - case 5619: - case 6326: - case 6542: - case 6570: - case 7159: - case 7182: - case 7235: - case 7387: - case 7455: - case 7540: - case 7902: - case 8046: - case 8126: - case 8477: - case 8705: - pinyin="YAO"; - break; - case 5644: - case 5843: - case 5894: - case 6262: - case 7442: - case 7639: - case 7884: - pinyin="YE"; - break; - case 5655: - case 5657: - case 5670: - case 5693: - case 5711: - case 5817: - case 5961: - case 5992: - case 6018: - case 6051: - case 6072: - case 6218: - case 6236: - case 6240: - case 6258: - case 6314: - case 6329: - case 6355: - case 6362: - case 6441: - case 6470: - case 6527: - case 6558: - case 6602: - case 6634: - case 6688: - case 6689: - case 6708: - case 6884: - case 6938: - case 7068: - case 7143: - case 7376: - case 7383: - case 7461: - case 7629: - case 7658: - case 7784: - case 7838: - case 7955: - case 7978: - case 8074: - case 8089: - case 8115: - case 8120: - case 8270: - case 8415: - case 8464: - case 8472: - case 8493: - case 8780: - pinyin="YI"; - break; - case 5623: - case 5920: - case 5983: - case 6007: - case 6065: - case 6337: - case 6419: - case 6594: - case 6625: - case 6806: - case 7519: - case 7887: - case 8111: - case 8230: - case 8615: - case 8624: - pinyin="YIN"; - break; - case 5788: - case 5911: - case 6067: - case 6094: - case 6126: - case 6151: - case 6186: - case 6292: - case 6451: - case 6663: - case 6862: - case 6875: - case 6913: - case 7188: - case 7212: - case 7326: - case 7584: - case 8048: - case 8108: - case 8203: - case 8331: - pinyin="YING"; - break; - case 6401: - pinyin="YO"; - break; - case 5724: - case 5953: - case 6013: - case 6415: - case 6728: - case 7163: - case 7962: - case 8014: - case 8711: - case 8751: - pinyin="YONG"; - break; - case 5653: - case 5692: - case 5707: - case 6112: - case 6115: - case 6121: - case 6347: - case 6483: - case 6922: - case 7254: - case 7364: - case 7527: - case 7880: - case 8064: - case 8236: - case 8242: - case 8286: - case 8647: - case 8778: - case 8788: - pinyin="YOU"; - break; - case 5614: - case 5625: - case 5681: - case 5722: - case 5836: - case 5845: - case 6139: - case 6187: - case 6277: - case 6484: - case 6486: - case 6546: - case 6592: - case 6632: - case 6637: - case 6655: - case 6748: - case 6987: - case 6993: - case 7005: - case 7090: - case 7204: - case 7437: - case 7476: - case 7573: - case 7603: - case 7622: - case 7647: - case 7659: - case 7718: - case 7858: - case 8033: - case 8054: - case 8085: - case 8086: - case 8130: - case 8133: - case 8266: - case 8285: - case 8336: - case 8407: - case 8408: - case 8607: - case 8625: - pinyin="YU"; - break; - case 5989: - case 6011: - case 6282: - case 6768: - case 7034: - case 7205: - case 7358: - case 7528: - case 7783: - case 8016: - case 8302: - case 8378: - case 8629: - pinyin="YUAN"; - break; - case 5763: - case 6914: - case 7348: - case 7530: - case 7865: - pinyin="YUE"; - break; - case 5909: - case 6031: - case 6581: - case 6702: - case 6719: - case 7101: - case 7225: - case 7370: - case 7432: - case 7521: - case 7657: - pinyin="YUN"; - break; - case 6257: - case 6338: - pinyin="ZA"; - break; - case 6544: - case 7162: - pinyin="ZAI"; - break; - case 7222: - case 7435: - case 8402: - case 8456: - case 8485: - case 8641: - pinyin="ZAN"; - break; - case 6242: - case 7064: - case 7416: - pinyin="ZANG"; - break; - case 6380: - pinyin="ZAO"; - break; - case 5638: - case 8369: - case 5651: - case 6385: - case 6493: - case 6937: - case 7430: - case 8348: - case 8423: - pinyin="ZE"; - break; - pinyin="ZEI"; - break; - case 5858: - pinyin="ZEN"; - break; - case 7153: - case 7421: - case 7832: - case 7913: - pinyin="ZENG"; - break; - case 6610: - case 6274: - case 6324: - case 6369: - case 6378: - case 7736: - case 8068: - case 8238: - case 8794: - pinyin="ZHA"; - break; - case 7746: - case 8109: - pinyin="ZHAI"; - break; - case 5862: - case 6288: - case 7625: - pinyin="ZHAN"; - break; - case 5675: - case 5921: - case 6504: - case 6554: - case 6615: - case 7049: - case 7216: - case 8315: - pinyin="ZHANG"; - break; - case 5815: - case 7294: - case 7840: - case 8341: - pinyin="ZHAO"; - break; - case 5856: - case 6301: - case 7247: - case 7392: - case 7761: - case 8049: - case 8162: - case 8256: - case 8487: - pinyin="ZHE"; - break; - case 5958: - case 6172: - case 6805: - case 7139: - case 7269: - case 7327: - case 7384: - case 7466: - case 7551: - case 7562: - case 7685: - case 7819: - case 8001: - case 8018: - case 8380: - pinyin="ZHEN"; - break; - case 5826: - case 6531: - case 6571: - case 7859: - case 7903: - case 8361: - pinyin="ZHENG"; - break; - case 5620: - case 5876: - case 5904: - case 5990: - case 6038: - case 6293: - case 6489: - case 6669: - case 6973: - case 6975: - case 7079: - case 7246: - case 7255: - case 7257: - case 7268: - case 7382: - case 7389: - case 7462: - case 7553: - case 7589: - case 7677: - case 7683: - case 7773: - case 7984: - case 8026: - case 8075: - case 8246: - case 8474: - case 8505: - case 8537: - case 8557: - case 8560: - case 8584: - case 8603: - pinyin="ZHI"; - break; - case 5803: - case 7981: - case 8314: - case 8417: - case 8564: - pinyin="ZHONG"; - break; - case 6107: - case 6390: - case 7008: - case 7091: - case 7107: - case 7548: - case 7756: - case 8406: - case 8492: - pinyin="ZHOU"; - break; - case 5689: - case 5710: - case 5905: - case 6049: - case 6079: - case 6808: - case 6830: - case 6883: - case 7244: - case 7338: - case 7345: - case 7636: - case 7889: - case 8070: - case 8081: - case 8335: - case 8371: - case 8422: - case 8467: - case 8578: - case 8770: - pinyin="ZHU"; - break; - pinyin="ZHUA"; - break; - pinyin="ZHUAI"; - break; - case 6389: - case 6645: - case 8207: - pinyin="ZHUAN"; - break; - case 5755: - pinyin="ZHUANG"; - break; - case 6723: - case 7077: - case 7136: - pinyin="ZHUI"; - break; - case 7538: - case 8124: - pinyin="ZHUN"; - break; - case 5730: - case 5834: - case 6310: - case 6823: - case 6835: - case 6910: - case 7644: - case 7690: - case 7729: - case 7977: - pinyin="ZHUO"; - break; - case 5849: - case 6549: - case 7002: - case 7060: - case 7127: - case 7287: - case 7402: - case 7463: - case 7707: - case 7786: - case 7937: - case 7986: - case 8172: - case 8342: - case 8450: - case 8484: - case 8594: - case 8604: - case 8623: - case 8686: - case 8758: - pinyin="ZI"; - break; - case 5744: - case 7574: - case 8453: - pinyin="ZONG"; - break; - case 5833: - case 5878: - case 5924: - case 7067: - case 8677: - pinyin="ZOU"; - break; - case 5762: - case 6147: - case 7963: - pinyin="ZU"; - break; - case 6312: - case 7158: - case 8582: - pinyin="ZUAN"; - break; - case 6209: - pinyin="ZUI"; - break; - case 6304: - case 7355: - case 8714: - pinyin="ZUN"; - break; - case 5872: - case 6382: - case 6460: - case 6684: - case 7549: - case 7681: - pinyin="ZUO"; - break; - default: - if(code>=1601 && code<=1602) - { - pinyin="A"; - break; - } - if(code>=1603 && code<=1615) - { - pinyin="AI"; - break; - } - if(code>=1616 && code<=1624) - { - pinyin="AN"; - break; - } - if(code>=1625 && code<=1627) - { - pinyin="ANG"; - break; - } - if(code>=1628 && code<=1636) - { - pinyin="AO"; - break; - } - if(code>=1637 && code<=1654) - { - pinyin="BA"; - break; - } - if(code>=1655 && code<=1662) - { - pinyin="BAI"; - break; - } - if(code>=1663 && code<=1677) - { - pinyin="BAN"; - break; - } - if(code>=1678 && code<=1689) - { - pinyin="BANG"; - break; - } - if(code>=1690 && code<=1712) - { - pinyin="BAO"; - break; - } - if(code>=1713 && code<=1727) - { - pinyin="BEI"; - break; - } - if(code>=1728 && code<=1731) - { - pinyin="BEN"; - break; - } - if(code>=1732 && code<=1737) - { - pinyin="BENG"; - break; - } - if(code>1738 && code<=1761) - { - pinyin="BI"; - break; - } - if(code>=1762 && code<=1773) - { - pinyin="BIAN"; - break; - } - if(code>=1774 && code<=1777) - { - pinyin="BIAO"; - break; - } - if(code>=1778 && code<=1781) - { - pinyin="BIE"; - break; - } - if(code>=1782 && code<=1787) - { - pinyin="BIN"; - break; - } - if(code>=1788 && code<=1794) - { - pinyin="BING"; - break; - } - if(code>=1801 && code<=1802) - { - pinyin="BING"; - break; - } - if(code>=1803 && code<=1821) - { - pinyin="BO"; - break; - } - if(code>=1822 && code<=1832) - { - pinyin="BU"; - break; - } - if(code==1833) - { - pinyin="CA"; - break; - } - if(code>=1834 && code<=1844) - { - pinyin="CAI"; - break; - } - if(code>=1845 && code<=1851) - { - pinyin="CAN"; - break; - } - if(code>=1852 && code<=1856) - { - pinyin="CANG"; - break; - } - if(code>=1857 && code<=1861) - { - pinyin="CAO"; - break; - } - if(code>=1862 && code<=1866) - { - pinyin="CE"; - break; - } - if(code>=1867 && code<=1868) - { - pinyin="CENG"; - break; - } - if(code>=1869 && code<=1879) - { - pinyin="CHA"; - break; - } - if(code>=1880 && code<=1882) - { - pinyin="CHAI"; - break; - } - if(code>=1883 && code<=1892) - { - pinyin="CHAN"; - break; - } - if(code>=1893 && code<=1911) - { - pinyin="CHANG"; - break; - } - if(code>=1912 && code<=1920) - { - pinyin="CHAO"; - break; - } - if(code>=1921 && code<=1926) - { - pinyin="CHE"; - break; - } - if(code>=1927 && code<=1936) - { - pinyin="CHEN"; - break; - } - if(code>=1937 && code<=1951) - { - pinyin="CHENG"; - break; - } - if(code>=1952 && code<=1967) - { - pinyin="CHI"; - break; - } - if(code>=1968 && code<=1972) - { - pinyin="CHONG"; - break; - } - if(code>=1973 && code<=1984) - { - pinyin="CHOU"; - break; - } - if(code>=1985 && code<=2006) - { - pinyin="CHU"; - break; - } - if(code==2007) - { - pinyin="CHUAI"; - break; - } - if(code>=2008 && code<=2014) - { - pinyin="CHUAN"; - break; - } - if(code>=2015 && code<=2020) - { - pinyin="CHUANG"; - break; - } - if(code>=2021 && code<=2025) - { - pinyin="CHUI"; - break; - } - if(code>=2026 && code<=2032) - { - pinyin="CHUN"; - break; - } - if(code>=2033 && code<=2034) - { - pinyin="CHUO"; - break; - } - if(code>=2035 && code<=2046) - { - pinyin="CI"; - break; - } - if(code>=2047 && code<=2052) - { - pinyin="CONG"; - break; - } - if(code>=2054 && code<=2057) - { - pinyin="CU"; - break; - } - if(code>=2058 && code<=2060) - { - pinyin="CUAN"; - break; - } - if(code>=2061 && code<=2068) - { - pinyin="CUI"; - break; - } - if(code>=2069 && code<=2071) - { - pinyin="CUN"; - break; - } - if(code>=2072 && code<=2077) - { - pinyin="CUO"; - break; - } - if(code>=2078 && code<=2083) - { - pinyin="DA"; - break; - } - if(code>=2084 && code<=2094) - { - pinyin="DAI"; - break; - } - if(code>=2102 && code<=2116) - { - pinyin="DAN"; - break; - } - if(code>=2117 && code<=2121) - { - pinyin="DANG"; - break; - } - if(code>=2122 && code<=2133) - { - pinyin="DAO"; - break; - } - if(code>=2134 && code<=2136) - { - pinyin="DE"; - break; - } - if(code>=2137 && code<=2143) - { - pinyin="DENG"; - break; - } - if(code>=2144 && code<=2162) - { - pinyin="DI"; - break; - } - if(code>=2163 && code<=2178) - { - pinyin="DIAN"; - break; - } - if(code>=2179 && code<=2187) - { - pinyin="DIAO"; - break; - } - if(code>=2188 && code<=2194) - { - pinyin="DIE"; - break; - } - if(code>=2201 && code<=2209) - { - pinyin="DING"; - break; - } - if(code==2210) - { - pinyin="DIU"; - break; - } - if(code>=2211 && code<=2220) - { - pinyin="DONG"; - break; - } - if(code>=2221 && code<=2227) - { - pinyin="DOU"; - break; - } - if(code>=2228 && code<=2242) - { - pinyin="DU"; - break; - } - if(code>=2243 && code<=2248) - { - pinyin="DUAN"; - break; - } - if(code>=2249 && code<=2252) - { - pinyin="DUI"; - break; - } - if(code>=2253 && code<=2261) - { - pinyin="DUN"; - break; - } - if(code>=2262 && code<=2273) - { - pinyin="DUO"; - break; - } - if(code>=2274 && code<=2286) - { - pinyin="E"; - break; - } - if(code==2287) - { - pinyin="EN"; - break; - } - if(code>=2288 && code<=2231) - { - pinyin="ER"; - break; - } - if(code>=2302 && code<=2309) - { - pinyin="FA"; - break; - } - if(code>=2310 && code<=2326) - { - pinyin="FAN"; - break; - } - if(code>=2327 && code<=2337) - { - pinyin="FANG"; - break; - } - if(code>=2338 && code<=2349) - { - pinyin="FEI"; - break; - } - if(code>=2350 && code<=2364) - { - pinyin="FEN"; - break; - } - if(code>=2365 && code<=2379) - { - pinyin="FENG"; - break; - } - if(code==2380) - { - pinyin="FO"; - break; - } - if(code==2381) - { - pinyin="FOU"; - break; - } - if(code>=2382 && code<=2432) - { - pinyin="FU"; - break; - } - if(code>=2435 && code<=2440) - { - pinyin="GAI"; - break; - } - if(code>=2441 && code<=2451) - { - pinyin="GAN"; - break; - } - if(code>=2452 && code<=2460) - { - pinyin="GANG"; - break; - } - if(code>=2461 && code<=2470) - { - pinyin="GAO"; - break; - } - if(code>=2471 && code<=2487) - { - pinyin="GE"; - break; - } - if(code==2488) - { - pinyin="GEI"; - break; - } - if(code>=2489 && code<=2490) - { - pinyin="GEN"; - break; - } - if(code>=2491 && code<=2503) - { - pinyin="GENG"; - break; - } - if(code>=2504 && code<=2518) - { - pinyin="GONG"; - break; - } - if(code>=2519 && code<=2527) - { - pinyin="GOU"; - break; - } - if(code>=2528 && code<=2545) - { - pinyin="GU"; - break; - } - if(code>=2546 && code<=2551) - { - pinyin="GUA"; - break; - } - if(code>=2552 && code<=2554) - { - pinyin="GUAI"; - break; - } - if(code>=2555 && code<=2565) - { - pinyin="GUAN"; - break; - } - if(code>=2566 && code<=2568) - { - pinyin="GUANG"; - break; - } - if(code>=2569 && code<=2584) - { - pinyin="GUI"; - break; - } - if(code>=2585 && code<=2587) - { - pinyin="GUN"; - break; - } - if(code>=2588 && code<=2593) - { - pinyin="GUO"; - break; - } - if(code==2594) - { - pinyin="HA"; - break; - } - if(code>=2601 && code<=2607) - { - pinyin="HAI"; - break; - } - if(code>=2608 && code<=2626) - { - pinyin="HAN"; - break; - } - if(code>=2627 && code<=2629) - { - pinyin="HANG"; - break; - } - if(code>=2630 && code<=2638) - { - pinyin="HAO"; - break; - } - if(code>=2639 && code<=2656) - { - pinyin="HE"; - break; - } - if(code>=2657 && code<=2658) - { - pinyin="HEI"; - break; - } - if(code>=2659 && code<=2662) - { - pinyin="HEN"; - break; - } - if(code>=2663 && code<=2667) - { - pinyin="HENG"; - break; - } - if(code>=2668 && code<=2676) - { - pinyin="HONG"; - break; - } - if(code>=2677 && code<=2683) - { - pinyin="HOU"; - break; - } - if(code>=2684 && code<=2707) - { - pinyin="HU"; - break; - } - if(code>=2708 && code<=2716) - { - pinyin="HUA"; - break; - } - if(code>=2717 && code<=2721) - { - pinyin="HUAI"; - break; - } - if(code>=2722 && code<=2735) - { - pinyin="HUAN"; - break; - } - if(code>=2736 && code<=2749) - { - pinyin="HUANG"; - break; - } - if(code>=2750 && code<=2770) - { - pinyin="HUI"; - break; - } - if(code>=2771 && code<=2776) - { - pinyin="HUN"; - break; - } - if(code>=2777 && code<=2786) - { - pinyin="HUO"; - break; - } - if(code>=2787 && code<=2845) - { - pinyin="JI"; - break; - } - if(code>=2846 && code<=2862) - { - pinyin="JIA"; - break; - } - if(code>=2863 && code<=2908) - { - pinyin="JIAN"; - break; - } - if(code>=2909 && code<=2921) - { - pinyin="JIANG"; - break; - } - if(code>=2922 && code<=2949) - { - pinyin="JIAO"; - break; - } - if(code>=2950 && code<=2976) - { - pinyin="JIE"; - break; - } - if(code>=2977 && code<=3002) - { - pinyin="JIN"; - break; - } - if(code>=3003 && code<=3027) - { - pinyin="JING"; - break; - } - if(code>=3028 && code<=3029) - { - pinyin="JIONG"; - break; - } - if(code>=3030 && code<=3046) - { - pinyin="JIU"; - break; - } - if(code>=3047 && code<=3071) - { - pinyin="JU"; - break; - } - if(code>=3072 && code<=3078) - { - pinyin="JUAN"; - break; - } - if(code>=3079 && code<=3088) - { - pinyin="JUE"; - break; - } - if(code>=3089 && code<=3105) - { - pinyin="JUN"; - break; - } - if(code>=3106 && code<=3109) - { - pinyin="KA"; - break; - } - if(code>=3110 && code<=3114) - { - pinyin="KAI"; - break; - } - if(code>=3115 && code<=3120) - { - pinyin="KAN"; - break; - } - if(code>=3121 && code<=3127) - { - pinyin="KANG"; - break; - } - if(code>=3128 && code<=3131) - { - pinyin="KAO"; - break; - } - if(code>=3132 && code<=3146) - { - pinyin="KE"; - break; - } - if(code>=3147 && code<=3150) - { - pinyin="KEN"; - break; - } - if(code>=3151 && code<=3152) - { - pinyin="KENG"; - break; - } - if(code>=3153 && code<=3156) - { - pinyin="KONG"; - break; - } - if(code>=3157 && code<=3160) - { - pinyin="KOU"; - break; - } - if(code>=3161 && code<=3167) - { - pinyin="KU"; - break; - } - if(code>=3168 && code<=3172) - { - pinyin="KUA"; - break; - } - if(code>=3173 && code<=3176) - { - pinyin="KUAI"; - break; - } - if(code>=3177 && code<=3178) - { - pinyin="KUAN"; - break; - } - if(code>=3179 && code<=3186) - { - pinyin="KUANG"; - break; - } - if(code>=3187 && code<=3203) - { - pinyin="KUI"; - break; - } - if(code>=3204 && code<=3207) - { - pinyin="KUN"; - break; - } - if(code>=3208 && code<=3211) - { - pinyin="KUO"; - break; - } - if(code>=3212 && code<=3218) - { - pinyin="LA"; - break; - } - if(code>=3219 && code<=3221) - { - pinyin="LAI"; - break; - } - if(code>=3222 && code<=3236) - { - pinyin="LAN"; - break; - } - if(code>=3237 && code<=3243) - { - pinyin="LANG"; - break; - } - if(code>=3244 && code<=3252) - { - pinyin="LAO"; - break; - } - if(code>=3253 && code<=3254) - { - pinyin="LE"; - break; - } - if(code>=3255 && code<=3265) - { - pinyin="LEI"; - break; - } - if(code>=3266 && code<=3268) - { - pinyin="LENG"; - break; - } - if(code>=3269 && code<=3308) - { - pinyin="LI"; - } - if(code==3309) - { - pinyin="LIA"; - break; - } - if(code>=3310 && code<=3323) - { - pinyin="LIAN"; - break; - } - if(code>=3324 && code<=3334) - { - pinyin="LIANG"; - break; - } - if(code>=3335 && code<=3347) - { - pinyin="LIAO"; - break; - } - if(code>=3348 && code<=3352) - { - pinyin="LIE"; - break; - } - if(code>=3353 && code<=3363) - { - pinyin="LIN"; - break; - } - if(code>=3364 && code<=3378) - { - pinyin="LING"; - break; - } - if(code>=3379 && code<=3389) - { - pinyin="LIU"; - break; - } - if(code>=3390 && code<=3404) - { - pinyin="LONG"; - break; - } - if(code>=3405 && code<=3410) - { - pinyin="LOU"; - break; - } - if(code>=3411 && code<=3444) - { - pinyin="LU"; - break; - } - if(code>=3445 && code<=3450) - { - pinyin="LUAN"; - break; - } - if(code>=3451 && code<=3452) - { - pinyin="LUE"; - break; - } - if(code>=3453 && code<=3459) - { - pinyin="LUN"; - break; - } - if(code>=3460 && code<=3471) - { - pinyin="LUO"; - break; - } - if(code>=3472 && code<=3480) - { - pinyin="MA"; - break; - } - if(code>=3481 && code<=3486) - { - pinyin="MAI"; - break; - } - if(code>=3487 && code<=3501) - { - pinyin="MAN"; - break; - } - if(code>=3502 && code<=3507) - { - pinyin="MANG"; - break; - } - if(code>=3508 && code<=3519) - { - pinyin="MAO"; - break; - } - if(code==3520) - { - pinyin="ME"; - break; - } - if(code>=3521 && code<=3536) - { - pinyin="MEI"; - break; - } - if(code>=3537 && code<=3539) - { - pinyin="MEN"; - break; - } - if(code>=3540 && code<=3547) - { - pinyin="MENG"; - break; - } - if(code>=3548 && code<=3561) - { - pinyin="MI"; - } - if(code>=3562 && code<=3570) - { - pinyin="MIAN"; - break; - } - if(code>=3571 && code<=3578) - { - pinyin="MIAO"; - break; - } - if(code>=3579 && code<=3580) - { - pinyin="MIE"; - break; - } - if(code>=3581 && code<=3586) - { - pinyin="MIN"; - break; - } - if(code>=3587 && code<=3592) - { - pinyin="MING"; - break; - } - if(code==3593) - { - pinyin="MIU"; - break; - } - if(code>=3594 && code<=3616) - { - pinyin="MO"; - break; - } - if(code>=3617 && code<=3619) - { - pinyin="MOU"; - break; - } - if(code>=3620 && code<=3634) - { - pinyin="MU"; - break; - } - if(code>=3635 && code<=3641) - { - pinyin="NA"; - break; - } - if(code>=3642 && code<=3646) - { - pinyin="NAI"; - break; - } - if(code>=3647 && code<=3649) - { - pinyin="NAN"; - break; - } - if(code==3650) - { - pinyin="NANG"; - break; - } - if(code>=3651 && code<=3655) - { - pinyin="NAO"; - break; - } - if(code==3656) - { - pinyin="NE"; - break; - } - if(code>=3657 && code<=3658) - { - pinyin="NEI"; - break; - } - if(code==3659) - { - pinyin="NEN"; - break; - } - if(code==3660) - { - pinyin="NENG"; - break; - } - if(code>=3661 && code<=3671) - { - pinyin="NI"; - break; - } - if(code>=3672 && code<=3678) - { - pinyin="NIAN"; - break; - } - if(code>=3679 && code<=3680) - { - pinyin="NIANG"; - break; - } - if(code>=3681 && code<=3682) - { - pinyin="NIAO"; - break; - } - if(code>=3683 && code<=3689) - { - pinyin="NIE"; - break; - } - if(code==3690) - { - pinyin="NIN"; - break; - } - if(code>=3691 && code<=3702) - { - pinyin="NING"; - break; - } - if(code>=3703 && code<=3706) - { - pinyin="NIU"; - break; - } - if(code>=3707 && code<=3710) - { - pinyin="NONG"; - break; - } - if(code>=3711 && code<=3714) - { - pinyin="NU"; - break; - } - if(code==3715) - { - pinyin="NUAN"; - break; - } - if(code>=3716 && code<=3717) - { - pinyin="NUE"; - break; - } - if(code>=3718 && code<=3721) - { - pinyin="NUO"; - break; - } - if(code==3722) - { - pinyin="O"; - break; - } - if(code>=3723 && code<=3729) - { - pinyin="OU"; - break; - } - if(code>=3730 && code<=3735) - { - pinyin="PA"; - break; - } - if(code>=3736 && code<=3741) - { - pinyin="PAI"; - break; - } - if(code>=3742 && code<=3749) - { - pinyin="PAN"; - break; - } - if(code>=3750 && code<=3754) - { - pinyin="PANG"; - break; - } - if(code>=3755 && code<=3761) - { - pinyin="PAO"; - break; - } - if(code>=3762 && code<=3770) - { - pinyin="PEI"; - break; - } - if(code>=3771 && code<=3772) - { - pinyin="PEN"; - break; - } - if(code>=3773 && code<=3786) - { - pinyin="PENG"; - break; - } - if(code>=3787 && code<=3809) - { - pinyin="PI"; - break; - } - if(code>=3810 && code<=3813) - { - pinyin="PIAN"; - break; - } - if(code>=3814 && code<=3817) - { - pinyin="PIAO"; - break; - } - if(code>=3818 && code<=3819) - { - pinyin="PIE"; - break; - } - if(code>=3820 && code<=3824) - { - pinyin="PIN"; - break; - } - if(code>=3825 && code<=3833) - { - pinyin="PING"; - break; - } - if(code>=3834 && code<=3841) - { - pinyin="PO"; - break; - } - if(code==3842) - { - pinyin="POU"; - break; - } - if(code>=3843 && code<=3857) - { - pinyin="PU"; - break; - } - if(code>=3858 && code<=3893) - { - pinyin="QI"; - break; - } - if(code==3894 || (code>=3901 && code<=3902)) - { - pinyin="QIA"; - break; - } - if(code>=3903 && code<=3924) - { - pinyin="QIAN"; - break; - } - if(code>=3925 && code<=3932) - { - pinyin="QIANG"; - break; - } - if(code>=3933 && code<=3947) - { - pinyin="QIAO"; - break; - } - if(code>=3948 && code<=3952) - { - pinyin="QIE"; - break; - } - if(code>=3953 && code<=3963) - { - pinyin="QIN"; - break; - } - if(code>=3964 && code<=3976) - { - pinyin="QING"; - break; - } - if(code>=3977 && code<=3978) - { - pinyin="QIONG"; - break; - } - if(code>=3979 && code<=3986) - { - pinyin="QIU"; - break; - } - if(code>=3987 && code<=4005) - { - pinyin="QU"; - break; - } - if(code>=4006 && code<=4016) - { - pinyin="QUAN"; - break; - } - if(code>=4017 && code<=4024) - { - pinyin="QUE"; - break; - } - if(code>=4025 && code<=4026) - { - pinyin="QUN"; - break; - } - if(code>=4027 && code<=4030) - { - pinyin="RAN"; - break; - } - if(code>=4031 && code<=4035) - { - pinyin="RANG"; - } - if(code>=4036 && code<=4038) - { - pinyin="RAO"; - break; - } - if(code>=4039 && code<=4040) - { - pinyin="RE"; - break; - } - if(code>=4041 && code<=4050) - { - pinyin="REN"; - break; - } - if(code>=4051 && code<=4052) - { - pinyin="RENG"; - break; - } - if(code==4053) - { - pinyin="RI"; - break; - } - if(code>=4054 && code<=4063) - { - pinyin="RONG"; - break; - } - if(code>=4064 && code<=4066) - { - pinyin="ROU"; - break; - } - if(code>=4067 && code<=4076) - { - pinyin="RU"; - break; - } - if(code>=4077 && code<=4078) - { - pinyin="RUAN"; - break; - } - if(code>=4079 && code<=4081) - { - pinyin="RUI"; - break; - } - if(code>=4082 && code<=4083) - { - pinyin="RUN"; - break; - } - if(code>=4084 && code<=4085) - { - pinyin="RUO"; - break; - } - if(code>=4086 && code<=4088) - { - pinyin="SA"; - break; - } - if(code>=4089 && code<=4092) - { - pinyin="SAI"; - break; - } - if(code>=4093 && code<=4094) - { - pinyin="SAN"; - break; - } - if(code>=4101 && code<=4102) - { - pinyin="SAN"; - break; - } - if(code>=4103 && code<=4105) - { - pinyin="SANG"; - break; - } - if(code>=4106 && code<=4109) - { - pinyin="SAO"; - break; - } - if(code>=4110 && code<=4112) - { - pinyin="SE"; - break; - } - if(code==4113) - { - pinyin="SEN"; - } - if(code==4114) - { - pinyin="SENG"; - break; - } - if(code>=4115 && code<=4123) - { - pinyin="SHA"; - break; - } - if(code>=4124 && code<=4125) - { - pinyin="SHAI"; - break; - } - if(code>=4126 && code<=4141) - { - pinyin="SHAN"; - break; - } - if(code>=4142 && code<=4149) - { - pinyin="SHANG"; - break; - } - if(code>=4150 && code<=4160) - { - pinyin="SHAO"; - break; - } - if(code>=4161 && code<=4172) - { - pinyin="SHE"; - break; - } - if(code>=4173 && code<=4188) - { - pinyin="SHEN"; - break; - } - if(code>=4189 && code<=4205) - { - pinyin="SHENG"; - break; - } - if(code>=4206 && code<=4252) - { - pinyin="SHI"; - break; - } - if(code>=4253 && code<=4262) - { - pinyin="SHOU"; - break; - } - if(code>=4263 && code<=4301) - { - pinyin="SHU"; - break; - } - if(code>=4302 && code<=4303) - { - pinyin="SHUA"; - break; - } - if(code>=4304 && code<=4307) - { - pinyin="SHUAI"; - break; - } - if(code>=4308 && code<=4309) - { - pinyin="SHUAN"; - break; - } - if(code>=4310 && code<=4312) - { - pinyin="SHUANG"; - break; - } - if(code>=4313 && code<=4316) - { - pinyin="SHUI"; - break; - } - if(code>=4317 && code<=4320) - { - pinyin="SHUN"; - break; - } - if(code>=4321 && code<=4324) - { - pinyin="SHUO"; - break; - } - if(code>=4325 && code<=4340) - { - pinyin="SI"; - break; - } - if(code>=4341 && code<=4348) - { - pinyin="SONG"; - break; - } - if(code>=4349 && code<=4352) - { - pinyin="SOU"; - break; - } - if(code>=4353 && code<=4364) - { - pinyin="SU"; - break; - } - if(code>=4365 && code<=4367) - { - pinyin="SUAN"; - break; - } - if(code>=4368 && code<=4378) - { - pinyin="SUI"; - break; - } - if(code>=4379 && code<=4381) - { - pinyin="SUN"; - break; - } - if(code>=4382 && code<=4389) - { - pinyin="SUO"; - break; - } - if(code>=4390 && code<=4404) - { - pinyin="TA"; - break; - } - if(code>=4405 && code<=4413) - { - pinyin="TAI"; - break; - } - if(code>=4414 && code<=4431) - { - pinyin="TAN"; - break; - } - if(code>=4432 && code<=4444) - { - pinyin="TANG"; - break; - } - if(code>=4445 && code<=4455) - { - pinyin="TAO"; - break; - } - if(code==4456) - { - pinyin="TE"; - break; - } - if(code>=4457 && code<=4460) - { - pinyin="TENG"; - break; - } - if(code>=4461 && code<=4475) - { - pinyin="TI"; - break; - } - if(code>=4476 && code<=4483) - { - pinyin="TIAN"; - break; - } - if(code>=4484 && code<=4488) - { - pinyin="TIAO"; - break; - } - if(code>=4489 && code<=4491) - { - pinyin="TIE"; - break; - } - if(code>=4492 && code<=4507) - { - pinyin="TING"; - break; - } - if(code>=4508 && code<=4520) - { - pinyin="TONG"; - break; - } - if(code>=4521 && code<=4524) - { - pinyin="TOU"; - break; - } - if(code>=4525 && code<=4535) - { - pinyin="TU"; - break; - } - if(code>=4536 && code<=4537) - { - pinyin="TUAN"; - break; - } - if(code>=4538 && code<=4543) - { - pinyin="TUI"; - break; - } - if(code>=4544 && code<=4546) - { - pinyin="TUN"; - break; - } - if(code>=4547 && code<=4557) - { - pinyin="TUO"; - break; - } - if(code>=4558 && code<=4564) - { - pinyin="WA"; - break; - } - if(code>=4565 && code<=4566) - { - pinyin="WAI"; - break; - } - if(code>=4567 && code<=4583) - { - pinyin="WAN"; - break; - } - if(code>=4584 && code<=4593) - { - pinyin="WANG"; - break; - } - if(code>=4594 && code<=4632) - { - pinyin="WEI"; - break; - } - if(code>=4633 && code<=4642) - { - pinyin="WEN"; - break; - } - if(code>=4643 && code<=4645) - { - pinyin="WENG"; - break; - } - if(code>=4646 && code<=4654) - { - pinyin="WO"; - break; - } - if(code>=4655 && code<=4683) - { - pinyin="WU"; - break; - } - if(code>=4684 && code<=4724) - { - pinyin="XI"; - break; - } - if(code>=4725 && code<=4737) - { - pinyin="XIA"; - break; - } - if(code>=4738 && code<=4763) - { - pinyin="XIAN"; - break; - } - if(code>=4764 && code<=4783) - { - pinyin="XIANG"; - break; - } - if(code>=4784 && code<=4807) - { - pinyin="XIAO"; - break; - } - if(code>=4809 && code<=4828) - { - pinyin="XIE"; - break; - } - if(code>=4829 && code<=4838) - { - pinyin="XIN"; - break; - } - if(code>=4839 && code<=4853) - { - pinyin="XING"; - break; - } - if(code>=4854 && code<=4860) - { - pinyin="XIONG"; - break; - } - if(code>=4861 && code<=4869) - { - pinyin="XIU"; - break; - } - if(code>=4870 && code<=4888) - { - pinyin="XU"; - break; - } - if(code>=4889 && code<=4904) - { - pinyin="XUAN"; - break; - } - if(code>=4905 && code<=4910) - { - pinyin="XUE"; - break; - } - if(code>=4911 && code<=4924) - { - pinyin="XUN"; - break; - } - if(code>=4925 && code<=4940) - { - pinyin="YA"; - break; - } - if(code>=4941 && code<=4973) - { - pinyin="YAN"; - break; - } - if(code>=4974 && code<=4990) - { - pinyin="YANG"; - break; - } - if(code>=4991 && code<=5011) - { - pinyin="YAO"; - break; - } - if(code>=5012 && code<=5026) - { - pinyin="YE"; - break; - } - if(code>=5027 && code<=5079) - { - pinyin="YI"; - break; - } - if(code>=5080 && code<=5101) - { - pinyin="YIN"; - break; - } - if(code>=5102 && code<=5119) - { - pinyin="YING"; - break; - } - if(code==5120) - { - pinyin="YO"; - break; - } - if(code>=5121 && code<=5135) - { - pinyin="YONG"; - break; - } - if(code>=5136 && code<=5155) - { - pinyin="YOU"; - break; - } - if(code>=5156 && code<=5206) - { - pinyin="YU"; - break; - } - if(code>=5207 && code<=5226) - { - pinyin="YUAN"; - break; - } - if(code>=5227 && code<=5236) - { - pinyin="YUE"; - break; - } - if(code>=5237 && code<=5248) - { - pinyin="YUN"; - break; - } - if(code>=5249 && code<=5251) - { - pinyin="ZA"; - break; - } - if(code>=5252 && code<=5258) - { - pinyin="ZAI"; - break; - } - if(code>=5259 && code<=5262) - { - pinyin="ZAN"; - break; - } - if(code>=5263 && code<=5265) - { - pinyin="ZANG"; - break; - } - if(code>=5266 && code<=5279) - { - pinyin="ZAO"; - break; - } - if(code>=5280 && code<=5283) - { - pinyin="ZE"; - break; - } - if(code==5284) - { - pinyin="ZEI"; - break; - } - if(code==5285) - { - pinyin="ZEN"; - break; - } - if(code>=5286 && code<=5289) - { - pinyin="ZENG"; - break; - } - if(code>=5290 && code<=5309) - { - pinyin="ZHA"; - break; - } - if(code>=5310 && code<=5315) - { - pinyin="ZHAI"; - break; - } - if(code>=5316 && code<=5332) - { - pinyin="ZHAN"; - break; - } - if(code>=5333 && code<=5347) - { - pinyin="ZHANG"; - break; - } - if(code>=5348 && code<=5357) - { - pinyin="ZHAO"; - break; - } - if(code>=5358 && code<=5367) - { - pinyin="ZHE"; - break; - } - if(code>=5368 && code<=5383) - { - pinyin="ZHEN"; - break; - } - if(code>=5384 && code<=5404) - { - pinyin="ZHENG"; - break; - } - if(code>=5405 && code<=5447) - { - pinyin="ZHI"; - break; - } - if(code>=5448 && code<=5458) - { - pinyin="ZHONG"; - break; - } - if(code>=5459 && code<=5472) - { - pinyin="ZHOU"; - break; - } - if(code>=5473 && code<=5504) - { - pinyin="ZHU"; - break; - } - if(code>=5505 && code<=5506) - { - pinyin="ZHUA"; - break; - } - if(code==5507) - { - pinyin="ZHUAI"; - break; - } - if(code>=5508 && code<=5513) - { - pinyin="ZHUAN"; - break; - } - if(code>=5514 && code<=5520) - { - pinyin="ZHUANG"; - break; - } - if(code>=5521 && code<=5526) - { - pinyin="ZHUI"; - break; - } - if(code>=5527 && code<=5528) - { - pinyin="ZHUN"; - break; - } - if(code>=5529 && code<=5539) - { - pinyin="ZHUO"; - break; - } - if(code>=5540 && code<=5554) - { - pinyin="ZI"; - break; - } - if(code>=5555 && code<=5561) - { - pinyin="ZONG"; - break; - } - if(code>=5562 && code<=5565) - { - pinyin="ZOU"; - break; - } - if(code>=5566 && code<=5573) - { - pinyin="ZU"; - break; - } - if(code>=5574 && code<=5575) - { - pinyin="ZUAN"; - break; - } - if(code>=5576 && code<=5579) - { - pinyin="ZUI"; - break; - } - if(code>=5580 && code<=5581) - { - pinyin="ZUN"; - break; - } - if(code>=5582 && code<=5589) - { - pinyin="ZUO"; - break; - } - } - if (pinyin.isEmpty()) - { - pinyin=""; - } - return pinyin; -} - diff --git a/src/Interface/ukuimenuinterface.cpp b/src/Interface/ukuimenuinterface.cpp deleted file mode 100644 index f435a63..0000000 --- a/src/Interface/ukuimenuinterface.cpp +++ /dev/null @@ -1,939 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include "ukuichineseletter.h" -#include "src/UtilityFunction/utility.h" - -UkuiMenuInterface::UkuiMenuInterface() -{ -} - -QVector UkuiMenuInterface::appInfoVector=QVector(); -QVector UkuiMenuInterface::desktopfpVector=QVector(); -QVector UkuiMenuInterface::alphabeticVector=QVector(); -QVector UkuiMenuInterface::functionalVector=QVector(); -QVector UkuiMenuInterface::allAppVector=QVector(); -QStringList UkuiMenuInterface::androidDesktopfnList=QStringList(); - -UkuiMenuInterface::~UkuiMenuInterface() -{ -} - -//文件递归查询 -void UkuiMenuInterface::recursiveSearchFile(const QString& _filePath) -{ - QDir dir(_filePath); - if (!dir.exists()) { - return; - } - - dir.setFilter(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot); - dir.setSorting(QDir::DirsFirst); - QFileInfoList list = dir.entryInfoList(); - list.removeAll(QFileInfo("/usr/share/applications/screensavers")); - if(list.size()< 1 ) { - return; - } - int i=0; - - //递归算法的核心部分 - do{ - QFileInfo fileInfo = list.at(i); - //如果是文件夹,递归 - bool isDir = fileInfo.isDir(); - if(isDir) { - recursiveSearchFile(fileInfo.filePath()); - } - else{ - //过滤后缀不是.desktop的文件 - QString filePathStr=fileInfo.filePath(); - if(!filePathStr.endsWith(".desktop")) - { - i++; - continue; - } - - QByteArray fpbyte=filePathStr.toLocal8Bit(); - char* filepath=fpbyte.data(); - if(0!=access(filepath,R_OK))//判断文件是否可读 - { - i++; - continue; - } - - keyfile=g_key_file_new(); - if(!g_key_file_load_from_file(keyfile,filepath,flags,error)) - return; - - char* ret_0 = g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); - if(ret_0 != nullptr) - { - QString str = QString::fromLocal8Bit(ret_0); - if(str.contains("Android")) - { - g_key_file_free(keyfile); - i++; - continue; - } - } - char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","NoDisplay", nullptr, nullptr); - if(ret_1!=nullptr) - { - QString str=QString::fromLocal8Bit(ret_1); - if(str.contains("true")) - { - g_key_file_free(keyfile); - i++; - continue; - } - } - char* ret_2=g_key_file_get_locale_string(keyfile,"Desktop Entry","NotShowIn", nullptr, nullptr); - if(ret_2!=nullptr) - { - QString str=QString::fromLocal8Bit(ret_2); - if(str.contains("UKUI")) - { - g_key_file_free(keyfile); - i++; - continue; - } - } - - //过滤LXQt、KDE - char* ret=g_key_file_get_locale_string(keyfile,"Desktop Entry","OnlyShowIn", nullptr, nullptr); - if(ret!=nullptr) - { - QString str=QString::fromLocal8Bit(ret); - if(str.contains("LXQt") || str.contains("KDE")) - { - g_key_file_free(keyfile); - i++; - continue; - } - } - - g_key_file_free(keyfile); - filePathList.append(filePathStr); - } - i++; - - } while(i < list.size()); -} - -//获取系统deskyop文件路径 -QStringList UkuiMenuInterface::getDesktopFilePath() -{ - filePathList.clear(); - - QString jsonPath=QDir::homePath()+"/.config/ukui-menu-security-config.json"; - QFile file(jsonPath); - if(file.exists()) - { - file.open(QIODevice::ReadOnly); - QByteArray readBy=file.readAll(); - QJsonParseError error; - QJsonDocument readDoc=QJsonDocument::fromJson(readBy,&error); - if(!readDoc.isNull() && error.error==QJsonParseError::NoError) - { - QJsonObject obj=readDoc.object().value("ukui-menu").toObject(); - if(obj.value("mode").toString()=="whitelist") - { - QJsonArray blArray=obj.value("whitelist").toArray(); - QJsonArray enArray=blArray.at(0).toObject().value("entries").toArray(); - for(int index=0;index UkuiMenuInterface::createAppInfoVector() -{ - desktopfpVector.clear(); - QVector appInfoVector; - QVector vector; - vector.append(QStringList()<<"Android");//0安卓 - vector.append(QStringList()<<"Network");//1网络 - vector.append(QStringList()<<"Messaging");//2社交 - vector.append(QStringList()<<"Audio"<<"Video");//3影音 - vector.append(QStringList()<<"Development");//4开发 - vector.append(QStringList()<<"Graphics");//5图像 - vector.append(QStringList()<<"Game");//6游戏 - vector.append(QStringList()<<"Office"<<"Calculator"<<"Spreadsheet"<<"Presentation"<<"WordProcessor"<<"TextEditor");//7办公 - vector.append(QStringList()<<"Education");//8教育 - vector.append(QStringList()<<"System"<<"Settings"<<"Security");//9系统 - - QStringList desktopfpList=getDesktopFilePath(); - - for(int i=0;i UkuiMenuInterface::getAllClassification() -{ - QVector allAppVector; - QVector commonVector; - QVector appVector; - allAppVector.clear(); - commonVector.clear(); - appVector.clear(); - commonVector=getCommonUseApp(); - int index=0; - Q_FOREACH(QString desktopfp, desktopfpVector) - { - if(!commonVector.contains(desktopfp)) - appVector.append(appInfoVector.at(index)); - index++; - } - qSort(appVector.begin(),appVector.end(),cmpApp); - Q_FOREACH(QString desktopfp, commonVector) - allAppVector.append(desktopfp); - - for(int index=0;index UkuiMenuInterface::getCommonUseApp() -{ -// QDateTime dt=QDateTime::currentDateTime(); -// int currentDateTime=dt.toTime_t(); -// int nDaySec=24*60*60; -// setting->beginGroup("datetime"); -// QStringList dateTimeKeys=setting->allKeys(); -// QStringList timeOutKeys; -// timeOutKeys.clear(); -// for(int i=0;ivalue(dateTimeKeys.at(i)).toInt())/nDaySec >= 4) -// { -// timeOutKeys.append(dateTimeKeys.at(i)); -// } - -// } -// setting->endGroup(); -// for(int i=0;ibeginGroup("application"); -// setting->remove(timeOutKeys.at(i)); -// setting->sync(); -// setting->endGroup(); -// setting->beginGroup("datetime"); -// setting->remove(timeOutKeys.at(i)); -// setting->sync(); -// setting->endGroup(); -// } - -// setting->beginGroup("lockapplication"); -// QStringList lockdesktopfnList=setting->allKeys(); -// for(int i=0;ivalue(lockdesktopfnList.at(j)).toInt(); -// int value_2=setting->value(lockdesktopfnList.at(j+1)).toInt(); -// if(value_1 > value_2) -// { -// QString tmp=lockdesktopfnList.at(j); -// lockdesktopfnList.replace(j,lockdesktopfnList.at(j+1)); -// lockdesktopfnList.replace(j+1,tmp); - -// } -// } -// setting->endGroup(); -// setting->beginGroup("application"); -// QStringList desktopfnList=setting->allKeys(); -// for(int i=0;ivalue(desktopfnList.at(j)).toInt(); -// int value_2=setting->value(desktopfnList.at(j+1)).toInt(); -// if(value_1 < value_2) -// { -// QString tmp=desktopfnList.at(j); -// desktopfnList.replace(j,desktopfnList.at(j+1)); -// desktopfnList.replace(j+1,tmp); - -// } -// } -// setting->endGroup(); - -// QVector data; -// Q_FOREACH(QString desktopfn,lockdesktopfnList) -// { -// QString desktopfp; -// if(androidDesktopfnList.contains(desktopfn)) -// desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); -// else -// desktopfp=QString("/usr/share/applications/"+desktopfn); -// QFileInfo fileInfo(desktopfp); -// if(!fileInfo.isFile()|| !desktopfpVector.contains(desktopfp)) -// continue; -// data.append(desktopfp); -// } -// Q_FOREACH(QString desktopfn,desktopfnList) -// { -// QString desktopfp; -// if(androidDesktopfnList.contains(desktopfn)) -// desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); -// else -// desktopfp=QString("/usr/share/applications/"+desktopfn); -// QFileInfo fileInfo(desktopfp); -// if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) -// continue; -// data.append(desktopfp); -// } - - QVector data; - Q_FOREACH(QString desktopfn, getLockAppList()) - { - QString desktopfp; - if(androidDesktopfnList.contains(desktopfn)) - desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); - else - desktopfp=QString("/usr/share/applications/"+desktopfn); - QFileInfo fileInfo(desktopfp); - if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) - continue; - data.append(desktopfp); - } - - Q_FOREACH(QString desktopfn, getUnlockAllList()) - { - QString desktopfp; - if(androidDesktopfnList.contains(desktopfn)) - desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); - else - desktopfp=QString("/usr/share/applications/"+desktopfn); - QFileInfo fileInfo(desktopfp); - if(!fileInfo.isFile() || !desktopfpVector.contains(desktopfp)) - continue; - data.append(desktopfp); - } - - return data; -} - -QVector UkuiMenuInterface::getAlphabeticClassification() -{ - QVector data; - QStringList appnameList; - appnameList.clear(); - QVector appVector[27]; - int index=0; - while(index otherVector; - QVector numberVector; - for(int i=0;i57 && c<65) || c>90) - otherVector.append(appVector[26].at(i)); - else - numberVector.append(appVector[26].at(i)); - } - qSort(otherVector.begin(),otherVector.end(),cmpApp); - qSort(numberVector.begin(),numberVector.end(),cmpApp); - QStringList otherfpList; - otherfpList.clear(); - for(int i=0;i UkuiMenuInterface::getFunctionalClassification() -{ - QVector appVector[11]; - int index=0; - while(index data; - data.clear(); - - for(int i=0;i<11;i++) - { - QStringList desktopfpList; - desktopfpList.clear(); - qSort(appVector[i].begin(),appVector[i].end(),cmpApp); - for(int j=0;j androidVector; - androidVector.clear(); - QString path=QDir::homePath()+"/.local/share/applications/"; - QDir dir(path); - if (!dir.exists()) { - return; - } - - dir.setFilter(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot); - dir.setSorting(QDir::DirsFirst); - QFileInfoList list = dir.entryInfoList(); - if(list.size()< 1 ) { - return; - } - int i=0; - - GError** error=nullptr; - GKeyFileFlags flags=G_KEY_FILE_NONE; - GKeyFile* keyfile=g_key_file_new (); - - do{ - QFileInfo fileInfo = list.at(i); - if(!fileInfo.isFile()) - { - i++; - continue; - } - //过滤后缀不是.desktop的文件 - QString filePathStr=fileInfo.filePath(); - if(!filePathStr.endsWith(".desktop")) - { - i++; - continue; - } - - QByteArray fpbyte=filePathStr.toLocal8Bit(); - char* filepath=fpbyte.data(); - g_key_file_load_from_file(keyfile,filepath,flags,error); - char* ret_1=g_key_file_get_locale_string(keyfile,"Desktop Entry","Categories", nullptr, nullptr); - if(ret_1!=nullptr) - { - QString str=QString::fromLocal8Bit(ret_1); - if(!str.contains("Android")) - { - i++; - continue; - } - else - { - filePathList.append(filePathStr); - androidDesktopfnList.append(fileInfo.fileName()); - } - } - - i++; - }while(i < list.size()); - - g_key_file_free(keyfile); -} - -QString UkuiMenuInterface::getAppNameInitials(QString desktopfp) -{ - QString firstLetters; - QString appname=getAppName(desktopfp); - QStringList appnamestr=appname.split(" "); - QString letters; - Q_FOREACH(QString name,appnamestr) - { - letters.clear(); - letters=UkuiChineseLetter::getFirstLettersAll(name); - if(letters.isEmpty()) - letters=UkuiChineseLetter::getFirstLetter(name); - firstLetters.append(letters); - } - - return firstLetters; -} - -QString UkuiMenuInterface::getAppNameInitial(QString desktopfp) -{ - return UkuiChineseLetter::getFirstLetter(getAppName(desktopfp)); -} - -//获取应用拼音 -QString UkuiMenuInterface::getAppNamePinyin(QString appname) -{ - return UkuiChineseLetter::getPinyins(appname); -} - -bool UkuiMenuInterface::checkKreApp(QString desktopfp) -{ - GError** error=nullptr; - GKeyFileFlags flags=G_KEY_FILE_NONE; - GKeyFile* keyfile=g_key_file_new (); - - QByteArray fpbyte=desktopfp.toLocal8Bit(); - char* filepath=fpbyte.data(); - g_key_file_load_from_file(keyfile,filepath,flags,error); - - char* value=g_key_file_get_locale_string(keyfile,"Desktop Entry","environment", nullptr, nullptr); - g_key_file_free(keyfile); - if(!value) - return false; - else if(QString::compare(QString::fromLocal8Bit(value),"kre-environment")==0) - return true; - return false; -} - -//获取指定类型应用列表 -QStringList UkuiMenuInterface::getSpecifiedCategoryAppList(QString categorystr) -{ - QByteArray categorybyte=categorystr.toLocal8Bit(); - char* category=categorybyte.data(); - - QStringList desktopfpList=getDesktopFilePath(); - QStringList appnameList; - appnameList.clear(); - for(int index=0;index(strlen(appcategory)-6); - for(int i=0;i -#include - -FullLetterWidget::FullLetterWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullLetterWidget::~FullLetterWidget() -{ - delete m_ukuiMenuInterface; - delete m_letterListBottomSpacer; - delete m_appListBottomSpacer; -} - -/** - * 主界面初始化 - */ -void FullLetterWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setAttribute(Qt::WA_TranslucentBackground); - - m_applistWid=new QWidget(this); - m_letterListWid=new QWidget(this); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_letterListWid->setFixedSize(Style::LeftWidWidth,this->height()); - - QHBoxLayout* mainLayout=new QHBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - mainLayout->setSpacing(0); - mainLayout->addWidget(m_letterListWid); - mainLayout->addWidget(m_applistWid); - this->setLayout(mainLayout); - m_ukuiMenuInterface=new UkuiMenuInterface; - - initAppListWidget(); - initLetterListWidget(); - - flag = true; - //翻页灵敏度时间调节 - time = new QTimer(this); - connect(time,&QTimer::timeout,[=](){ - if(flag == false) - { - flag = true; - time->stop(); - } - }); -} - -/** - * 初始化应用列表界面 - */ -void FullLetterWidget::initAppListWidget() -{ - QHBoxLayout* layout=new QHBoxLayout(m_applistWid); - layout->setContentsMargins(0,0,0,0); - m_applistWid->setLayout(layout); - - m_scrollArea=new ScrollArea; - m_scrollAreaWid=new ScrollAreaWid; - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout=new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_scrollAreaWidLayout->setSpacing(10); - m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); - layout->addWidget(m_scrollArea); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullLetterWidget::valueChangedSlot); - m_appListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); - - fillAppList(); -} - -void FullLetterWidget::setFocusToThis() -{ - letterButtonClick(); - this->setFocus(); - Q_EMIT selectFirstItem(); -} - -/** - * 填充应用列表 - */ -void FullLetterWidget::fillAppList() -{ - m_letterList.clear(); - QVector vector=UkuiMenuInterface::alphabeticVector; - for(int i=0;i(i+65))); - else if(i==26) - letterstr="&"; - else - letterstr="#"; - m_letterList.append(letterstr);//存储分类字符 - //插入字母分类按钮 - SplitBarFrame* letterbtn=new SplitBarFrame(this,letterstr,m_scrollArea->width()-12,30,1); - m_scrollAreaWidLayout->addWidget(letterbtn); - - //插入应用列表 - FullListView* listview=new FullListView(this,1); - connect(listview, &FullListView::sendSetslidebar,this,&FullLetterWidget::onSetSlider); - connect(this, &FullLetterWidget::selectFirstItem, listview, &FullListView::selectFirstItem); - listview->installEventFilter(this); - //修复异常黑框问题 - connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ - listview->repaint(listview->rect()); - }); - - m_scrollAreaWidLayout->addWidget(listview); - m_data.clear(); - for(int i=0;iaddData(m_data); - - connect(listview,&FullListView::sendItemClickedSignal,this,&FullLetterWidget::execApplication); - connect(listview,&FullListView::sendHideMainWindowSignal,this,&FullLetterWidget::sendHideMainWindowSignal); - } - } - m_scrollAreaWidLayout->addItem(m_appListBottomSpacer); - - resizeScrollAreaControls(); -} - -/** - * 执行应用程序 - */ -void FullLetterWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -/** - * 更新应用列表 - */ -void FullLetterWidget::updateAppListView() -{ - //刷新应用列表界面 - QLayoutItem *child; - m_scrollAreaWidLayout->removeItem(m_appListBottomSpacer); - while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_scrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - fillAppList(); - - //刷新字母列表界面 - Q_FOREACH (QAbstractButton* button, m_buttonList) { - m_btnGroup->removeButton(button); - } - m_buttonList.clear(); - m_letterListScrollAreaWidLayout->removeItem(m_letterListBottomSpacer); - while ((child = m_letterListScrollAreaWidLayout->takeAt(0)) != 0) { - QWidget* wid=child->widget(); - m_letterListScrollAreaWidLayout->removeWidget(wid); - wid->setParent(nullptr); - delete wid; - delete child; - } - - //防止按钮位置偏移 - initLetterListScrollArea(); -} - -/** - * 设置scrollarea所填充控件大小 - */ -void FullLetterWidget::resizeScrollAreaControls() -{ - int row=0; - while(rowcount()/2) - { - //应用界面 - QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(row*2+1); - QWidget* wid=widItem->widget(); - FullListView* listview=qobject_cast(wid); - listview->adjustSize(); - int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; - - int rowcount=0; - if(listview->model()->rowCount()%dividend>0) - { - rowcount=listview->model()->rowCount()/dividend+1; - } - else - { - rowcount=listview->model()->rowCount()/dividend; - - } - - listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); - row++; - } - m_scrollArea->widget()->adjustSize(); -} - -/** - * 初始化字母列表界面 - */ -void FullLetterWidget::initLetterListWidget() -{ - m_letterListScrollArea=new ClassifyBtnScrollArea(m_letterListWid); - m_letterListScrollAreaWid=new ClassifyBtnScrollAreaWid; - m_letterListScrollAreaWidLayout=new QVBoxLayout; - m_letterListScrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_letterListScrollAreaWidLayout->setSpacing(0); - m_letterListScrollAreaWid->setLayout(m_letterListScrollAreaWidLayout); - m_letterListScrollArea->setWidget(m_letterListScrollAreaWid); - m_letterListScrollArea->setWidgetResizable(true); - - m_letterListBottomSpacer=new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding); - m_btnGroup=new QButtonGroup(m_letterListScrollAreaWid); - m_animation = new QPropertyAnimation(m_letterListScrollArea, "geometry"); - - m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); - m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); - connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullLetterWidget::animationFinishSlot); - connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullLetterWidget::animationValueChangedSlot); - - initLetterListScrollArea(); -} - -/** - * 初始化字母列表 - */ -void FullLetterWidget::initLetterListScrollArea() -{ - if(m_letterList.contains("&")) - m_letterList.replace(m_letterList.indexOf("&"),"&&"); - for(int i=0;isetFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); - m_buttonList.append(letterbtn); - m_letterListScrollAreaWidLayout->addWidget(letterbtn); - m_letterListScrollAreaWidLayout->setAlignment(letterbtn,Qt::AlignHCenter); - connect(letterbtn,&LetterClassifyButton::buttonClicked,m_btnGroup, static_cast(&QButtonGroup::buttonClicked)); - } - m_letterListScrollAreaWidLayout->addItem(m_letterListBottomSpacer); - - int id=0; - Q_FOREACH (QAbstractButton* btn, m_buttonList) { - m_btnGroup->addButton(btn,id++); - } - - connect(m_btnGroup,static_cast(&QButtonGroup::buttonClicked),this,&FullLetterWidget::btnGroupClickedSlot); - m_letterListScrollArea->widget()->adjustSize(); - if(m_btnGroup->button(0)!=nullptr) - m_btnGroup->button(0)->click(); -} - -void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn) -{ - disconnect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullLetterWidget::valueChangedSlot); - Q_FOREACH (QAbstractButton* button, m_buttonList) { - LetterClassifyButton* letterbtn=qobject_cast(button); - if(m_btnGroup->id(btn)==m_buttonList.indexOf(button)) - { - letterbtn->setChecked(true); - //此处需实现将被选定的字母包含的应用列表移动到applistWid界面最顶端 - QString letterstr=letterbtn->text(); - int num=m_letterList.indexOf(letterstr); - if(num!=-1) - { - m_beginPos=m_scrollArea->verticalScrollBar()->sliderPosition(); - m_endPos=m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn)*2)->widget()->y(); - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_scrollAnimation->stop(); - m_scrollAnimation->setStartValue(m_beginPos); - m_scrollAnimation->setEndValue(m_endPos); - m_scrollAnimation->start(); - } - } - else{ - letterbtn->setChecked(false); - } - } -} - -void FullLetterWidget::animationFinishSlot() -{ - if(m_scrollArea->verticalScrollBar()->value()==m_endPos || - m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) - { - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - connect(m_scrollArea->verticalScrollBar(),&QScrollBar::valueChanged, - this,&FullLetterWidget::valueChangedSlot); - } -} - -void FullLetterWidget::animationValueChangedSlot(const QVariant &value) -{ - Q_UNUSED(value); - if (sender() != m_scrollAnimation) - return; - - QPropertyAnimation *ani = qobject_cast(sender()); - - if (m_endPos != ani->endValue()) - ani->setEndValue(m_endPos); -} - -void FullLetterWidget::valueChangedSlot(int value) -{ - int index=0; - while(index<=m_letterList.count()-1) - { - int min=m_scrollAreaWidLayout->itemAt(2*index)->widget()->y(); - int max=0; - if(index==m_letterList.count()-1) - max=m_scrollAreaWid->height(); - else - max=m_scrollAreaWidLayout->itemAt(2*(index+1))->widget()->y(); - - if(value>=min && value (button); - if(index==m_buttonList.indexOf(button)) - { - letterbtn->setChecked(true); - } - else - { - letterbtn->setChecked(false); - } - } - break; - } - else - index++; - } - -// //向下滚动 -// if((m_buttonList.at(index)->pos().y()+m_buttonList.at(index)->height()+m_letterListScrollArea->widget()->pos().y()) >= m_letterListScrollArea->height()) -// { -// int val=m_letterListScrollArea->verticalScrollBar()->sliderPosition()+m_buttonList.at(index)->height(); -// m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); -// } - -// //向上滚动 -// if((m_buttonList.at(index)->pos().y()+m_letterListScrollArea->widget()->pos().y()) <= 0) -// { - -// int val=m_letterListScrollArea->verticalScrollBar()->value()-m_buttonList.at(index)->height(); -// m_letterListScrollArea->verticalScrollBar()->setSliderPosition(val); -// } - -} - -void FullLetterWidget::enterAnimation() -{ - m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(0,(m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, - 0,(m_letterList.size()+1)*Style::LeftLetterBtnHeight)); - m_animation->setEndValue(QRect(Style::LeftMargin, - (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, - Style::LeftLetterBtnHeight*2, - (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); - m_animation->setEasingCurve(QEasingCurve::InQuart); - m_animation->start(); - m_letterListScrollArea->show(); -} - -void FullLetterWidget::setLetterBtnGeometry() -{ - m_letterListScrollArea->setGeometry(QRect(Style::LeftMargin, - (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, - Style::LeftLetterBtnHeight*2, - (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); - m_letterListScrollArea->show(); -} - -void FullLetterWidget::repaintWidget() -{ - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_applistWid->setFixedSize(Style::AppListWidWidth,this->height()); - m_scrollArea->setFixedSize(m_applistWid->width(),m_applistWid->height()); - m_scrollAreaWid->setFixedWidth(m_scrollArea->width() - Style::SliderSize); - m_letterListWid->setFixedSize(Style::LeftWidWidth,this->height()); - updateAppListView(); -} - -void FullLetterWidget::widgetMakeZero() -{ - Q_FOREACH (QAbstractButton* button, m_buttonList) { - QString letterstr=button->text().at(0); - int num=m_letterList.indexOf(letterstr); - if(num!=-1) - { - m_btnGroup->button(num)->click(); - m_letterListScrollArea->verticalScrollBar()->setSliderPosition(0); - break; - } - } - m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); -} - -void FullLetterWidget::moveScrollBar(int type) -{ - int height=Style::primaryScreenHeight; - if(type==0) - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()-height*100/1080); - else - m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition()+height*100/1080); -} - -void FullLetterWidget::onSetSlider(int value) -{ -// if(flag) -// { -// flag = false; -// time->start(100); - int curvalue = m_scrollArea->verticalScrollBar()->value(); - m_scrollArea->verticalScrollBar()->setValue(curvalue + value); -// } -} - -QAbstractButton* FullLetterWidget::getCurLetterButton(int value) -{ - return m_buttonList.at(value); -} - -bool FullLetterWidget::eventFilter(QObject *watched, QEvent *event) -{ - if( event->type() == QEvent::KeyPress ) - { - QLayoutItem* widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); - QWidget* wid = widItem->widget(); - FullListView* m_listview = qobject_cast(wid); - - QLayoutItem* widItemTop = m_scrollAreaWidLayout->itemAt(1); - QWidget* widTop = widItemTop->widget(); - FullListView* m_listviewTop = qobject_cast(widTop); - - QKeyEvent *ke = (QKeyEvent *)event; - if( ke->key() == Qt::Key_Tab ) - { - // m_letterListScrollAreaWid->setFocus(); - // m_letterListScrollArea->setFocus(); - // return true; - Q_EMIT setFocusToSideWin(); - } - if(ke->key() == Qt::Key_Up) - { - if(!m_listviewTop->hasFocus()) - { - QAbstractButton* buttonTop = getCurLetterButton(( --m_index) % m_buttonList.size()); - btnGroupClickedSlot(buttonTop); - this->m_scrollArea->setFocusToPreChild(); - } - else - { - m_listview->setFocus(); - QAbstractButton* button = getCurLetterButton(m_buttonList.size() - 1); - btnGroupClickedSlot(button); - m_index = m_buttonList.size() - 1; - } - Q_EMIT selectFirstItem(); - return true; - } - if(ke->key() == Qt::Key_Down) - { - if(!m_listview->hasFocus()) - { - QAbstractButton* button = getCurLetterButton(( ++m_index) % m_buttonList.size()); - btnGroupClickedSlot(button); - this->m_scrollArea->setFocusToNextChild(); - } - else - { - m_listviewTop->setFocus(); - QAbstractButton* buttonTop = getCurLetterButton(0); - btnGroupClickedSlot(buttonTop); - m_index = 0; - } - Q_EMIT selectFirstItem(); - return true; - } - } - return QWidget::eventFilter(watched,event); -} - -void FullLetterWidget::letterButtonClick() -{ - if(m_btnGroup->button(0)!=nullptr) - m_btnGroup->button(0)->click(); - m_index = 0; -} diff --git a/src/LetterWidget/letterwidget.cpp b/src/LetterWidget/letterwidget.cpp deleted file mode 100644 index 22670c0..0000000 --- a/src/LetterWidget/letterwidget.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/UtilityFunction/itemdelegate.h" -#include "src/UtilityFunction/utility.h" - -LetterWidget::LetterWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -LetterWidget::~LetterWidget() -{ - delete m_ukuiMenuInterface; -} - -/** - * 主界面初始化 - */ -void LetterWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - - m_ukuiMenuInterface=new UkuiMenuInterface; - initAppListWidget(); - - m_letterBtnWid=new LetterButtonWidget(this); - m_letterBtnWid->hide(); - connect(this,&LetterWidget::sendLetterBtnList,m_letterBtnWid,&LetterButtonWidget::recvLetterBtnList); - connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal,this,&LetterWidget::recvLetterBtnSlot); - - m_enterAnimation=new QPropertyAnimation; - m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - m_leaveAnimation=new QPropertyAnimation; - m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); - connect(m_leaveAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot); - connect(m_enterAnimation,&QPropertyAnimation::finished,this,&LetterWidget::animationFinishedSLot); -} - -/** - * 初始化应用列表界面 - */ -void LetterWidget::initAppListWidget() -{ - m_appListView=new ListView(this,this->width()-6,this->height()-6,1); - m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_appListView->show(); - fillAppListView(); - connect(m_appListView,&ListView::sendItemClickedSignal,this,&LetterWidget::recvItemClickedSlot); - connect(m_appListView,&ListView::sendHideMainWindowSignal,this,&LetterWidget::sendHideMainWindowSignal); -} - - -/** - * 填充应用列表 - */ -void LetterWidget::fillAppListView() -{ - m_data.clear(); - int row=0; - QVector vector=UkuiMenuInterface::alphabeticVector; - for(int i=0;i(i+65))); - else if(i==26) - letterstr="&"; - else - letterstr="#"; - m_letterList.append(letterstr);//存储分类字符 - m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 - m_data.append(QStringList()<addData(m_data); -} - -void LetterWidget::recvItemClickedSlot(QStringList arg) -{ - if(arg.at(1).toInt()==0) - appClassificationBtnClickedSlot(); - else - execApplication(arg.at(0)); -} - -/** - * 执行应用程序 - */ -void LetterWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -/** - * 更新应用列表 - */ -void LetterWidget::updateAppListView() -{ - int row=0; - m_data.clear(); - m_letterList.clear(); - m_letterBtnRowList.clear(); - QVector vector=UkuiMenuInterface::alphabeticVector; - for(int i=0;i(i+65))); - else if(i==26) - letterstr="&"; - else - letterstr="#"; - m_letterList.append(letterstr);//存储分类字符 - m_letterBtnRowList.append(QString::number(row));//存储分类字符所在行 - m_data.append(QStringList()<updateData(m_data); -} - -/** - * 应用列表字母分类按钮槽函数 - */ -void LetterWidget::appClassificationBtnClickedSlot() -{ - m_leaveAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); - m_leaveAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); -// m_leaveAnimation->setEndValue(QRect(20,20,this->width()-40,this->height()-40)); - m_enterAnimation->setStartValue(QRect(-40,-40,this->width()+80,this->height()+80)); - m_enterAnimation->setEndValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); - - //加载LetterBUttonWidget界面 - m_enterAnimation->setDuration(100); - m_leaveAnimation->setDuration(10); - Q_EMIT sendLetterBtnList(m_letterList); - m_leaveAnimation->setTargetObject(m_appListView); - m_enterAnimation->setTargetObject(m_letterBtnWid); - m_leaveAnimation->start(); - m_widgetState=1; -} - -/** - * 接收LetterButtonWidget界面按钮信号 - */ -void LetterWidget::recvLetterBtnSlot(QString btnname) -{ - //此处需实现将字母为btnname的应用列表移动到applistWid界面最顶端 - int num=m_letterList.indexOf(QString(QChar(btnname.at(0)))); - if(num!=-1) - { - int row=m_letterBtnRowList.at(num).toInt(); - m_appListView->verticalScrollBar()->setValue(row); - } - - m_leaveAnimation->setStartValue(QRect((this->width()-235)/2,(this->height()-366)/2,235,366)); - m_leaveAnimation->setEndValue(QRect(-40,-40,this->width()+80,this->height()+80)); -// m_enterAnimation->setStartValue(QRect(16,10,this->width()-20,this->height()-20)); - m_enterAnimation->setStartValue(QRect(6,0,this->width()-6,this->height()-6)); - m_enterAnimation->setEndValue(QRect(6,0,this->width()-6,this->height()-6)); - - m_enterAnimation->setDuration(10); - m_leaveAnimation->setDuration(100); - m_leaveAnimation->setTargetObject(m_letterBtnWid); - m_enterAnimation->setTargetObject(m_appListView); - m_leaveAnimation->start(); - m_widgetState=0; -} - -void LetterWidget::animationFinishedSLot() -{ - if(m_widgetState==1) - { - m_enterAnimation->start(); - m_widgetState=-1; - m_appListView->hide(); - m_letterBtnWid->show(); - } - if(m_widgetState==0) - { - m_enterAnimation->start(); - m_widgetState=-1; - m_letterBtnWid->hide(); - m_appListView->show(); - } -} - -void LetterWidget::widgetMakeZero() -{ - m_letterBtnWid->hide(); - m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_appListView->show(); - m_appListView->verticalScrollBar()->setValue(0); -} - -void LetterWidget::moveScrollBar(int type) -{ - if(type==0) - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()-100); - else - m_appListView->verticalScrollBar()->setSliderPosition(m_appListView->verticalScrollBar()->sliderPosition()+100); -} - -void LetterWidget::repaintWidget() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_appListView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_appListView->show(); -} - -void LetterWidget::setFocusToThis() -{ - this->setFocus(); -} diff --git a/src/LetterWidget/letterwidget.h b/src/LetterWidget/letterwidget.h deleted file mode 100644 index 4fbe4ba..0000000 --- a/src/LetterWidget/letterwidget.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -#include "letterbuttonwidget.h" -#include "src/UtilityFunction/listview.h" -#include "src/UtilityFunction/itemdelegate.h" - -class LetterWidget : public QWidget -{ - Q_OBJECT - -public: - explicit LetterWidget(QWidget *parent=nullptr); - ~LetterWidget(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Repaint window - */ - void repaintWidget(); - -private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - LetterButtonWidget* m_letterBtnWid=nullptr; - ListView* m_appListView=nullptr; - QVector m_data; - QStringList m_letterList; - QStringList m_letterBtnRowList; - - /*Interface switching animation*/ - QPropertyAnimation* m_enterAnimation=nullptr; - QPropertyAnimation* m_leaveAnimation=nullptr; - int m_widgetState=-1; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Initialize the application list interface - */ - void initAppListWidget(); - /** - * @brief fill application list - */ - void fillAppListView(); - -public Q_SLOTS: - /** - * @brief Switch to the alphabetic classification button interface - */ - void appClassificationBtnClickedSlot(); - /** - * @brief Receive alphabetic classification button interface signal - * @param Category button name - */ - void recvLetterBtnSlot(QString btnname); - /** - * @brief Open the application - * @param arg: Desktop file path - */ - void execApplication(QString desktopfp); - /** - * @brief Update application list slot function - */ - void updateAppListView(); - /** - * @brief Respond to the list item click - * @param arg: The desktop file information that the application contains - */ - void recvItemClickedSlot(QStringList arg); - /** - * @brief Respond to animation finish - */ - void animationFinishedSLot(); - - void setFocusToThis(); - -Q_SIGNALS: - /** - * @brief Send alphabetic classification list to the letterbuttonwidget - * @param list: Alphabetic classification list - */ - void sendLetterBtnList(QStringList list); - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // LETTERWIDGET_H diff --git a/src/MainViewWidget/mainviewwidget.cpp b/src/MainViewWidget/mainviewwidget.cpp deleted file mode 100644 index 64f1b5c..0000000 --- a/src/MainViewWidget/mainviewwidget.cpp +++ /dev/null @@ -1,992 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -MainViewWidget::MainViewWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -MainViewWidget::~MainViewWidget() -{ - delete m_ukuiMenuInterface; - delete m_fileWatcher; - delete m_directoryChangedThread; - delete m_animation; - delete m_searchAppThread; - -} - -void MainViewWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setAttribute(Qt::WA_TranslucentBackground); - QVBoxLayout* mainLayout=new QVBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - mainLayout->setSpacing(0); - m_topWidget=new QWidget; - m_contentWid=new QWidget; - - mainLayout->addWidget(m_topWidget); - mainLayout->addWidget(m_contentWid); - this->setLayout(mainLayout); - - this->setFocusPolicy(Qt::NoFocus); - - m_commonUseWid=new CommonUseWidget(m_contentWid); - m_fullCommonUseWid=new FullCommonUseWidget(m_contentWid); - m_letterWid=new LetterWidget(m_contentWid); - m_functionWid=new FunctionWidget(m_contentWid); - m_fullLetterWid=new FullLetterWidget(m_contentWid); - m_fullFunctionWid=new FullFunctionWidget(m_contentWid); - m_fullSearchResultWid=new FullSearchResultWidget(m_contentWid); - m_searchResultWid=new SearchResultWidget(m_contentWid); - hideWidget(); - - m_ukuiMenuInterface=new UkuiMenuInterface; - - //监控.desktop文件目录 - m_fileWatcher=new QFileSystemWatcher; - m_fileWatcher->addPaths(QStringList()<setFixedSize(Style::defaultMainViewWidWidth,Style::minh); - m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight); - m_topLayout->setContentsMargins(0,0,0,0); - m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); - m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, - m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); - m_queryWid->show(); - //内容区 - m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); - m_commonUseWid->setGeometry(0,0,Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_commonUseWid->show(); - m_widgetState=1; - m_saveCurrentWidState=1; - - //监控应用进程开启 - connect(KWindowSystem::self(),&KWindowSystem::windowAdded,[=](WId id) - { - KWindowInfo info(id,NET::WMPid); - int pid=info.pid(); - QString desktopfp=getEnvOverriddenDesktopFile(pid); - if(!desktopfp.isEmpty()) - ViewOpenedSlot(desktopfp); - else - { - //获取软件名(2种方式) - //法1 - QStringList nameList; - KWindowInfo info(id,NET::WMName); - nameList.append(info.name()); - //法2 - QString path=QString("/proc/%1/status").arg(pid); - QFile file(path); - if(file.open(QIODevice::ReadOnly)) - { - char buf[1024]; - qint64 len=file.readLine(buf,sizeof(buf)); - if(len!=-1) - { - QString name=QString::fromLocal8Bit(buf).remove("Name:").remove("\t").remove("\n"); - nameList.append(name); - } - } - - QVector appInfoVector=UkuiMenuInterface::appInfoVector; - Q_FOREACH(QStringList list , appInfoVector) - { - if(list.at(1).contains(nameList.at(0),Qt::CaseInsensitive) || - list.at(2).contains(nameList.at(0),Qt::CaseInsensitive) || - list.at(5).contains(nameList.at(0),Qt::CaseInsensitive) || - nameList.at(0).contains(list.at(1),Qt::CaseInsensitive) || - nameList.at(0).contains(list.at(2),Qt::CaseInsensitive)) - { - ViewOpenedSlot(list.at(0)); - break; - } - else if(nameList.size()==2 && - ( - list.at(1).contains(nameList.at(1),Qt::CaseInsensitive) || - list.at(2).contains(nameList.at(1),Qt::CaseInsensitive) || - list.at(5).contains(nameList.at(1),Qt::CaseInsensitive) || - nameList.at(0).contains(list.at(1),Qt::CaseInsensitive) || - nameList.at(0).contains(list.at(2),Qt::CaseInsensitive)) - ) - { - ViewOpenedSlot(list.at(0)); - break; - } - } - } - }); - - //监控图标主题 - if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) - { - m_gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); - connect(m_gsetting,&QGSettings::changed,this,&MainViewWidget::iconThemeChangeSlot); - } -} - -/** - * 添加顶部控件 - */ -void MainViewWidget::addTopControl() -{ - m_topLayout=new QHBoxLayout; - m_topLayout->setSpacing(0); - m_queryLineEdit=new QLineEdit; - m_topLayout->addWidget(m_queryLineEdit); - m_topWidget->setLayout(m_topLayout); - char style[200]; - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light") - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); - else - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(style); - - initQueryLineEdit(); - -} - -//void MainViewWidget::focusInEvent(QFocusEvent *event) -//{ -// Q_UNUSED(event); -// if(this->hasFocus()) -// { -// this->focusNextChild(); -// } -// return QWidget::focusInEvent(event); -//} - -/** - * 添加搜索框 - */ -void MainViewWidget::initQueryLineEdit() -{ - m_queryWid=new QWidget; - m_queryWid->setParent(m_queryLineEdit); - m_queryWid->setFocusPolicy(Qt::NoFocus); - QHBoxLayout* queryWidLayout=new QHBoxLayout; - queryWidLayout->setContentsMargins(0,0,0,0); - queryWidLayout->setSpacing(5); - m_queryWid->setLayout(queryWidLayout); - QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light")//反黑 - pixmap=drawSymbolicBlackColoredPixmap(pixmap); - else - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon=new QLabel; - m_queryIcon->setFixedSize(pixmap.size()); - m_queryIcon->setPixmap(pixmap); - m_queryText=new QLabel; - m_queryText->setText(tr("Search")); - m_queryText->adjustSize(); - queryWidLayout->addWidget(m_queryIcon); - queryWidLayout->addWidget(m_queryText); - queryWidLayout->setAlignment(m_queryIcon,Qt::AlignVCenter); - queryWidLayout->setAlignment(m_queryText,Qt::AlignVCenter); - m_queryLineEdit->setFocusPolicy(Qt::ClickFocus); - m_queryLineEdit->installEventFilter(this); - m_queryLineEdit->setContextMenuPolicy(Qt::NoContextMenu); - - m_animation= new QPropertyAnimation(m_queryWid,"geometry"); - m_animation->setDuration(100); - connect(m_animation,&QPropertyAnimation::finished,this,&MainViewWidget::animationFinishedSlot); - - m_searchAppThread=new SearchAppThread; - connect(this,&MainViewWidget::sendSearchKeyword, - m_searchAppThread,&SearchAppThread::recvSearchKeyword); - connect(m_searchAppThread,&SearchAppThread::sendSearchResult, - this,&MainViewWidget::recvSearchResult); - connect(m_queryLineEdit, &QLineEdit::textChanged, this, &MainViewWidget::searchAppSlot); -} - -bool MainViewWidget::eventFilter(QObject *watched, QEvent *event) -{ - if(watched==m_queryLineEdit) - { - char style[200]; - if(event->type()==QEvent::FocusIn) - { - if(!m_isFullScreen) - { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light") - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault,QueryLineEditClickedDefaultBackground); - else - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditClickedBackground); - } - else - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditClickedBackground); - m_queryLineEdit->setStyleSheet(style); - if(!m_queryLineEdit->text().isEmpty()) - { - if(m_searchKeyWords.isEmpty()) - searchAppSlot(m_queryLineEdit->text()); - } - else - { - m_queryWid->layout()->removeWidget(m_queryText); - m_queryText->setParent(nullptr); - m_animation->stop(); - m_animation->setStartValue(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, - m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); - m_animation->setEndValue(QRect(0,0, - m_queryIcon->width()+5,Style::QueryLineEditHeight)); - m_animation->setEasingCurve(QEasingCurve::OutQuad); - m_animation->start(); - m_queryLineEdit->setTextMargins(-5,0,0,0); - } - m_isSearching=true; - } - else if(event->type()==QEvent::FocusOut) - { - m_searchKeyWords.clear(); - if(m_queryLineEdit->text().isEmpty()) - { - if(m_isSearching) - { - if(!m_isFullScreen) - { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light") - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); - else - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - } - else - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(style); - m_animation->stop(); - m_queryText->adjustSize(); - m_animation->setStartValue(QRect(0,0, - m_queryIcon->width()+5,Style::QueryLineEditHeight)); - m_animation->setEndValue(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, - m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); - m_animation->setEasingCurve(QEasingCurve::InQuad); - m_animation->start(); - } - } - else - { - if(!m_isFullScreen) - { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light") - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedDefaultBackground,QueryLineEditDefaultBackground); - else - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - } - else - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(style); - } - m_isSearching=false; - } - } - - return QWidget::eventFilter(watched,event); // 最后将事件交给上层对话框 -} - -void MainViewWidget::setLineEditFocus(QString arg) -{ - if(!m_queryLineEdit->hasFocus()) - { - m_searchKeyWords=arg; - m_queryLineEdit->setFocus(); - if(!m_queryLineEdit->text().isEmpty()) - m_queryLineEdit->setText(arg); - } -} - -/** - * 搜索程序和文件槽函数 - */ -void MainViewWidget::searchAppSlot(QString arg) -{ - if(!arg.isEmpty())//切换至搜索模块 - { - if(m_widgetState!=0) - { - m_widgetState=0; - if(!m_isFullScreen) - loadSearchResultWidget(); - else - loadFullSearchResultWidget(); - } - Q_EMIT sendSearchKeyword(arg); - m_searchAppThread->start(); - } - else{//搜索模块显示所有的软件 - if(m_isFullScreen) - { - switch (m_saveCurrentWidState) { - case 1: - loadFullCommonUseWidget(); - break; - case 2: - loadFullLetterWidget(); - break; - case 3: - loadFullFunctionWidget(); - default: - break; - } - } - else { - switch (m_saveCurrentWidState) { - case 1: - loadCommonUseWidget(); - break; - case 2: - loadLetterWidget(); - break; - case 3: - loadFunctionWidget(); - break; - default: - break; - } - } - } -} - -void MainViewWidget::recvSearchResult(QVector arg) -{ - m_searchAppThread->quit(); -// m_searchAppThread->wait(); - m_fullSearchResultWid->updateAppListView(arg); - m_searchResultWid->updateAppListView(arg); -} - -void MainViewWidget::animationFinishedSlot() -{ - if(m_isSearching)//进入搜索状态 - { -// m_queryWid->layout()->removeWidget(m_queryText); -// m_queryText->setParent(nullptr); - m_queryLineEdit->setTextMargins(20,0,0,0); - if(!m_searchKeyWords.isEmpty()) - { - m_queryLineEdit->setText(m_searchKeyWords); - m_searchKeyWords.clear(); - } - } - else//退出搜索状态 - { - m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); - QPalette pe = m_queryText->palette(); - if(!m_isFullScreen) - { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light")//反黑 - { - pe.setColor(QPalette::Text,QColor(Qt::black)); - } - else - { - pe.setColor(QPalette::Text,QColor(Qt::white)); - } - } - else - pe.setColor(QPalette::Text,QColor(Qt::white)); - - m_queryText->setPalette(pe); - } -} - -/** - * 加载默认主视图 - */ -void MainViewWidget::loadMinMainView() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); - //搜索区 - m_topWidget->setFixedSize(this->width(),Style::defaultTopWidHeight); - m_topLayout->setContentsMargins(0,0,0,0); - m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); - m_queryLineEdit->setFixedSize(Style::defaultQueryLineEditWidth,Style::defaultQueryLineEditHeight); - if(m_queryLineEdit->text().isEmpty()) - { - if(m_queryWid->layout()->count()==1) - { - m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); - } - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, - m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); - m_queryWid->show(); - } - - char style[200]; - QPalette pe = m_queryText->palette(); - QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light") - { - pixmap=drawSymbolicBlackColoredPixmap(pixmap);//反黑 - pe.setColor(QPalette::Text,QColor(Qt::black)); - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); - } - else - { - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pe.setColor(QPalette::Text,QColor(Qt::white)); - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - } - m_queryLineEdit->setStyleSheet(style); - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon->setPixmap(pixmap); - m_queryText->setPalette(pe); - - //内容区 - m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); - if(m_widgetState==0) - { - loadSearchResultWidget(); - } - else if(m_widgetState==1) - loadCommonUseWidget(); - else if(m_widgetState==2) - loadLetterWidget(); - else if(m_widgetState==3) - loadFunctionWidget(); - m_isFullScreen=false; -} - -/** - * 加载全屏主视图 - */ -void MainViewWidget::loadMaxMainView() -{ - this->setFixedSize(Style::MainViewWidWidth, - Style::heightavailable); - //搜索区 - m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight); - m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight); - - m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, - 0, - (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, - 0); - - if(m_queryLineEdit->text().isEmpty()) - { - if(m_queryWid->layout()->count()==1) - { - m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); - } - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, - m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); - m_queryWid->show(); - } - - char style[200]; - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - m_queryLineEdit->setStyleSheet(style); - - QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - QPalette pe = m_queryText->palette(); - pe.setColor(QPalette::Text,QColor(Qt::white)); - m_queryText->setPalette(pe); - - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon->setPixmap(pixmap); - - //内容区 - m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); - if(m_widgetState==0) - { - loadFullSearchResultWidget(); - } - else if(m_widgetState==1) - loadFullCommonUseWidget(); - else if(m_widgetState==2) - loadFullLetterWidget(); - else if(m_widgetState==3) - loadFullFunctionWidget(); - m_isFullScreen=true; -} - -void MainViewWidget::resizeControl() -{ - if(m_isFullScreen) - { - if(m_widgetState==2) - m_fullLetterWid->setLetterBtnGeometry(); - if(m_widgetState==3) - m_fullFunctionWid->setFunctionBtnGeometry(); - - this->setFixedSize(Style::MainViewWidWidth, - Style::heightavailable); - m_topWidget->setFixedSize(this->width(),Style::TopWidgetHeight); - m_queryLineEdit->setFixedSize(Style::QueryLineEditWidth,Style::QueryLineEditHeight); - - m_topLayout->setContentsMargins((m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2+Style::LeftWidWidth, - 0, - (m_topWidget->width()-Style::LeftWidWidth-m_queryLineEdit->width())/2, - 0); - m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); - } - else - { - this->setFixedSize(Style::defaultMainViewWidWidth,Style::minh); - m_topWidget->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultTopWidHeight); - m_topLayout->setContentsMargins(0,0,0,0); - m_topLayout->setAlignment(m_queryLineEdit,Qt::AlignCenter); - m_contentWid->setFixedSize(this->width(),this->height()-m_topWidget->height()); - } - -} - -void MainViewWidget::resetQueryLine() -{ - if(!m_queryLineEdit->text().isEmpty()) - { - m_queryLineEdit->clearFocus(); - m_queryLineEdit->clear(); - m_isSearching = false; - - if(m_queryWid->layout()->count()==1) - { - m_queryWid->layout()->addWidget(m_queryText); - m_queryWid->layout()->setAlignment(m_queryIcon,Qt::AlignVCenter); - m_queryWid->layout()->setAlignment(m_queryText,Qt::AlignVCenter); - } - m_queryText->adjustSize(); - m_queryWid->setGeometry(QRect((m_queryLineEdit->width()-(m_queryIcon->width()+m_queryText->width()+10))/2,0, - m_queryIcon->width()+m_queryText->width()+10,Style::QueryLineEditHeight)); - char style[200]; - QPalette pe = m_queryText->palette(); - QPixmap pixmap=loadSvg(QString(":/data/img/mainviewwidget/search.svg"),16); - if(!m_isFullScreen) - { - - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light") - { - pixmap=drawSymbolicBlackColoredPixmap(pixmap);//反黑 - pe.setColor(QPalette::Text,QColor(Qt::black)); - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#000000;}", - QueryLineEditClickedBorderDefault,QueryLineEditDefaultBackground); - } - else - { - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pe.setColor(QPalette::Text,QColor(Qt::white)); - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - } - } - else - { - sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:4px;color:#ffffff;}", - QueryLineEditClickedBorder,QueryLineEditBackground); - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pe.setColor(QPalette::Text,QColor(Qt::white)); - } - m_queryLineEdit->setStyleSheet(style); - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_queryIcon->setPixmap(pixmap); - m_queryText->setPalette(pe); - } - -} - -/** - * 加载常用分类界面 - */ -void MainViewWidget::loadCommonUseWidget() -{ - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - hideWidget(); - m_commonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_commonUseWid->show(); - m_commonUseWid->updateListView(); - this->layout()->update(); - m_widgetState=1; - m_saveCurrentWidState=1; - resetQueryLine(); -} - -/** - * 加载字母分类界面 - */ -void MainViewWidget::loadLetterWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - hideWidget(); - m_letterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_letterWid->show(); - m_widgetState=2; - m_saveCurrentWidState=2; - resetQueryLine(); -} - -/** - * 加载功能分类界面 - */ -void MainViewWidget::loadFunctionWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - hideWidget(); - m_functionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_functionWid->show(); - m_widgetState=3; - m_saveCurrentWidState=3; - resetQueryLine(); -} - -/** - * 加载全屏常用分类界面 - */ -void MainViewWidget::loadFullCommonUseWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - hideWidget(); - m_fullCommonUseWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_fullCommonUseWid->show(); - m_fullCommonUseWid->updateListView(); - m_widgetState=1; - m_saveCurrentWidState=1; - resetQueryLine(); -} - -/** - * 加载全屏字母分类界面 - */ -void MainViewWidget::loadFullLetterWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - hideWidget(); - m_fullLetterWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_fullLetterWid->show(); -// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=2)) - m_fullLetterWid->enterAnimation(); - m_widgetState=2; - m_saveCurrentWidState=2; - resetQueryLine(); -} - -/** - * 加载全屏功能分类界面 - */ -void MainViewWidget::loadFullFunctionWidget() -{ - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - hideWidget(); - m_fullFunctionWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_fullFunctionWid->show(); -// if(!m_isFullScreen || (m_isFullScreen && m_saveCurrentWidState!=3)) - m_fullFunctionWid->enterAnimation(); - m_widgetState=3; - m_saveCurrentWidState=3; - resetQueryLine(); -} - -void MainViewWidget::loadSearchResultWidget() -{ - hideWidget(); - m_searchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_searchResultWid->show(); -} - -void MainViewWidget::loadFullSearchResultWidget() -{ - hideWidget(); - m_fullSearchResultWid->setGeometry(0,0,this->width(),this->height()-m_topWidget->height()); - m_fullSearchResultWid->show(); -} - -void MainViewWidget::hideWidget() -{ - m_commonUseWid->hide(); - m_fullCommonUseWid->hide(); - m_letterWid->hide(); - m_fullLetterWid->hide(); - m_functionWid->hide(); - m_fullFunctionWid->hide(); - m_searchResultWid->hide(); - m_fullSearchResultWid->hide(); -} - -void MainViewWidget::changeFocuUp() -{ - this->focusPreviousChild(); -} - -void MainViewWidget::changeFocuDown() -{ - this->focusNextChild(); -} - -/** - * 进程开启监控槽函数 - */ -void MainViewWidget::ViewOpenedSlot(QString desktopfp) -{ - qDebug()<<"open software:"< desktopfpVec=UkuiMenuInterface::desktopfpVector; - if(desktopfpVec.contains(desktopfp)) - { - QFileInfo fileInfo(desktopfp); - QString desktopfn=fileInfo.fileName(); - - QString dateTimeKey; - dateTimeKey.clear(); - if(!desktopfn.isEmpty()) - { - updateDataBaseTableTimes(desktopfn); - } - } -} - -/** - * desktop文件目录改变信号槽 - */ -void MainViewWidget::directoryChangedSlot(const QString &path) -{ - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - m_directoryChangedThread->start(); -} - -void MainViewWidget::requestUpdateSlot() -{ - m_directoryChangedThread->quit(); - Q_EMIT directoryChangedSignal(); -} - -void MainViewWidget::iconThemeChangeSlot(QString key) -{ - if(key=="iconThemeName" || key=="icon-theme-name") - Q_EMIT directoryChangedSignal(); -} - -void MainViewWidget::reloadUkuiMenu() -{ - Q_EMIT directoryChangedSignal(); -} - -void MainViewWidget::repaintWidget() -{ - this->setMinimumSize(Style::minw,Style::minh); - m_commonUseWid->repaintWidget(); - m_fullCommonUseWid->repaintWidget(); - m_letterWid->repaintWidget(); - m_fullLetterWid->repaintWidget(); - m_functionWid->repaintWidget(); - m_fullFunctionWid->repaintWidget(); - m_searchResultWid->repaintWidget(); - m_fullSearchResultWid->repaintWidget(); -} - -void MainViewWidget::repaintFullWidget() -{ - m_fullCommonUseWid->repaintWidget(); - m_fullLetterWid->repaintWidget(); - m_fullFunctionWid->repaintWidget(); - m_fullSearchResultWid->repaintWidget(); -} - -void MainViewWidget::widgetMakeZero() -{ - m_isSearching=false; - m_widgetState=m_saveCurrentWidState; - m_commonUseWid->widgetMakeZero(); - m_fullCommonUseWid->widgetMakeZero(); - m_letterWid->widgetMakeZero(); - m_fullLetterWid->widgetMakeZero(); - m_functionWid->widgetMakeZero(); - m_fullFunctionWid->widgetMakeZero(); - m_queryLineEdit->blockSignals(true); - m_queryLineEdit->clear(); - m_queryLineEdit->clearFocus(); - m_queryLineEdit->blockSignals(false); - m_queryLineEdit->setTextMargins(0,0,0,0); -} - -void MainViewWidget::moveScrollBar(int type) -{ - if(m_widgetState==0) - { - if(m_isFullScreen) - m_fullSearchResultWid->moveScrollBar(type); - else - m_searchResultWid->moveScrollBar(type); - } - if(m_widgetState==1) - { - if(m_isFullScreen) - m_fullCommonUseWid->moveScrollBar(type); - else - m_commonUseWid->moveScrollBar(type); - } - if(m_widgetState==2) - { - if(m_isFullScreen) - m_fullLetterWid->moveScrollBar(type); - else - m_letterWid->moveScrollBar(type); - } - if(m_widgetState==3) - { - if(m_isFullScreen) - m_fullFunctionWid->moveScrollBar(type); - else - m_functionWid->moveScrollBar(type); - } -} - -void MainViewWidget::keyPressEvent(QKeyEvent *e) -{ - if(e->type()==QEvent::KeyPress) - { - switch(e->key()) - { - case Qt::Key_Enter: - case Qt::Key_Return: - case Qt::Key_Down: - { - if(m_queryLineEdit->hasFocus() && !m_queryLineEdit->text().isEmpty()) - { - if(m_isFullScreen) - { - m_fullSearchResultWid->setViewFocus(); - } - else - { - m_searchResultWid->setViewFocus(); - } - } - } - break; - default: - break; - } - } -} - -void MainViewWidget::setFocusToThis() -{ - this->setFocus(); - //// this->focusProxy(); -// m_fullLetterWid->letterButtonClick(); -// m_fullFunctionWid->functionButtonClick(); -} diff --git a/src/MainViewWidget/mainviewwidget.h b/src/MainViewWidget/mainviewwidget.h deleted file mode 100644 index fe0af1c..0000000 --- a/src/MainViewWidget/mainviewwidget.h +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -#include "src/CommonUseWidget/commonusewidget.h" -#include "src/LetterWidget/letterwidget.h" -#include "src/FunctionWidget/functionwidget.h" -#include "src/CommonUseWidget/fullcommonusewidget.h" -#include "src/FunctionWidget/fullfunctionwidget.h" -#include "src/LetterWidget/fullletterwidget.h" -#include "src/SearchResultWidget/fullsearchresultwidget.h" -#include "src/SearchResultWidget/searchresultwidget.h" -#include "src/SearchResultWidget/searchappthread.h" -#include "directorychangedthread.h" -#include "src/Style/style.h" - -class MainViewWidget : public QWidget -{ - Q_OBJECT - -public: - explicit MainViewWidget(QWidget *parent = nullptr); - ~MainViewWidget(); - /** - * @brief Load the default main view - */ - void loadMinMainView(); - /** - * @brief Load the full screen main view - */ - void loadMaxMainView(); - /** - * @brief Initializes the interface state - */ - void widgetMakeZero(); - /** - * @brief Set the focus of the search box - * @param arg: Text - */ - void setLineEditFocus(QString arg); - /** - * @brief Repaint window - */ - void repaintWidget(); - /** - * @brief changeFocuUp - */ - void repaintFullWidget(); - void changeFocuUp(); - - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Resize the control - */ - void resizeControl(); - void reloadUkuiMenu(); - - void resetQueryLine(); - -private: - UkuiMenuInterface *m_ukuiMenuInterface=nullptr; - QWidget *m_topWidget=nullptr; - QHBoxLayout *m_topLayout=nullptr; - - QWidget *m_contentWid=nullptr; - - QLineEdit *m_queryLineEdit=nullptr; - QWidget *m_queryWid=nullptr; - QLabel *m_queryIcon=nullptr; - QLabel *m_queryText=nullptr; - bool m_isSearching; - QString m_searchKeyWords; - QPropertyAnimation *m_animation=nullptr; - - FullSearchResultWidget *m_fullSearchResultWid=nullptr; - SearchResultWidget *m_searchResultWid=nullptr; - SearchAppThread *m_searchAppThread=nullptr; - CommonUseWidget *m_commonUseWid=nullptr; - LetterWidget *m_letterWid=nullptr; - FunctionWidget *m_functionWid=nullptr; - FullCommonUseWidget *m_fullCommonUseWid=nullptr; - FullLetterWidget *m_fullLetterWid=nullptr; - FullFunctionWidget *m_fullFunctionWid=nullptr; - - DirectoryChangedThread *m_directoryChangedThread=nullptr; - - int m_widgetState=1;//Classification window number - int m_saveCurrentWidState=-1;//Store the current category window number - - bool m_isFullScreen=false; -// bool m_isHiden=false; - - QFileSystemWatcher *m_fileWatcher=nullptr;//Monitor desktop folder status - - QGSettings *m_gsetting=nullptr; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Add a top window control - */ - void addTopControl(); - /** - * @brief Initializes the query box - */ - void initQueryLineEdit(); -// void paintEvent(QPaintEvent* event); - void loadSearchResultWidget(); - void loadFullSearchResultWidget(); - void hideWidget(); - void keyPressEvent(QKeyEvent* e); -// void focusInEvent(QFocusEvent *event); - -public Q_SLOTS: - /** - * @brief Search box focus event filtering - */ - bool eventFilter(QObject *watched, QEvent *event); - /** - * @brief Load the common classification interface - */ - void loadCommonUseWidget(); - /** - * @brief Load the letter classification interface - */ - void loadLetterWidget(); - /** - * @brief Load function classification interface - */ - void loadFunctionWidget(); - /** - * @brief Load full screen common classification interface - */ - void loadFullCommonUseWidget(); - /** - * @brief Load the full screen letter classification interface - */ - void loadFullLetterWidget(); - /** - * @brief Load the full screen function classification interface - */ - void loadFullFunctionWidget(); - /** - * @brief Respond to search box - * @param arg: Search keywords - */ - void searchAppSlot(QString arg); - /** - * @brief Respond to search box animation finish - */ - void animationFinishedSlot(); - /** - * @brief Monitor application startup - */ - void ViewOpenedSlot(QString desktopfp); - /** - * @brief Monitor desktop file directory changes - */ - void directoryChangedSlot(const QString &path); - /** - * @brief Receive search results - * @param arg: Search results - */ - void recvSearchResult(QVector arg); - /** - * @brief Monitor icon theme changes - * @param key: Key - */ - void iconThemeChangeSlot(QString key); - /** - * @brief Request for updating the application list - */ - void requestUpdateSlot(); - - void setFocusToThis(); - - /** - * @brief changeFocuDown - */ - void changeFocuDown(); - -Q_SIGNALS: - /** - * @brief Desktop file directory change signal - */ - void directoryChangedSignal(); - /** - * @brief Send the search keyword to the SearchAppThread - * @param arg: Search keyword - */ - void sendSearchKeyword(QString arg); - /** - * @brief Send mounting and unmounting signals to DirectoryChangedThread - */ - void sendDirectoryPath(); - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); - - void setFocusToSideWin(); - - void selectFirstItem(); - - void selectFirstItemTab(); - - void setSlideBar(int value); -}; - -#endif // MAINVIEWWIDGET_H diff --git a/src/MainWindow/mainwindow.cpp b/src/MainWindow/mainwindow.cpp deleted file mode 100644 index 935fb7f..0000000 --- a/src/MainWindow/mainwindow.cpp +++ /dev/null @@ -1,559 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/Style/style.h" -#include - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent) -{ - openDataBase("MainThread"); - m_ukuiMenuInterface=new UkuiMenuInterface; - UkuiMenuInterface::appInfoVector=m_ukuiMenuInterface->createAppInfoVector(); - initDatabase(); - UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); - UkuiMenuInterface::allAppVector=m_ukuiMenuInterface->getAllClassification(); - - Style::initWidStyle(); - initUi(); - - - m_dbus=new DBus; - new MenuAdaptor(m_dbus); - QDBusConnection con=QDBusConnection::sessionBus(); - if(!con.registerService("org.ukui.menu") || - !con.registerObject("/org/ukui/menu",m_dbus)) - { - qDebug()<<"error:"<createAppInfoVector(); - UkuiMenuInterface::alphabeticVector=m_ukuiMenuInterface->getAlphabeticClassification(); - UkuiMenuInterface::functionalVector=m_ukuiMenuInterface->getFunctionalClassification(); - Q_EMIT m_mainViewWid->reloadUkuiMenu(); - }); - - connect(m_dbus,&DBus::winKeyResponseSignal,this,[=]{ - if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) - { - QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); - if(gsetting.keys().contains("win-key-release")) - if(gsetting.get("win-key-release").toBool()) - return; - } - if(QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) - { - QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit()); - if(gsetting.keys().contains("isrunning")) - if(gsetting.get("isrunning").toBool()) - return; - } - - if(this->isVisible()) - { - this->hide(); - } - else{ - this->loadMainWindow(); - this->show(); - this->raise(); - this->activateWindow(); - } - m_mainViewWid->widgetMakeZero(); - }); -} - -MainWindow::~MainWindow() -{ - closeDataBase("MainThread"); - delete m_ukuiMenuInterface; -} - -void MainWindow::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); - this->setAttribute(Qt::WA_TranslucentBackground, true); - this->setAutoFillBackground(false); - this->setFocusPolicy(Qt::NoFocus); - - this->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); - this->setMinimumSize(Style::minw,Style::minh); - this->setContentsMargins(0,0,0,0); - m_frame=new QFrame; - m_mainViewWid=new MainViewWidget; - m_sideBarWid=new SideBarWidget; - - this->setCentralWidget(m_frame); - QHBoxLayout *mainlayout=new QHBoxLayout; - mainlayout->setContentsMargins(0,0,0,0); - mainlayout->setSpacing(0); - m_frame->setLayout(mainlayout); - - mainlayout->addWidget(m_mainViewWid); - m_line=new QFrame; - m_line->installEventFilter(this); - m_line->setFrameShape(QFrame::VLine); - m_line->setFixedSize(1,this->height()-1); - m_line->setEnabled(false); - mainlayout->addWidget(m_line); - mainlayout->addWidget(m_sideBarWid); - m_sideBarWid->loadMinSidebar(); - m_mainViewWid->loadMinMainView(); - - - m_animation = new QPropertyAnimation(this, "geometry"); - connect(m_animation,&QPropertyAnimation::finished,this,&MainWindow::animationValueFinishedSlot); - - connect(m_sideBarWid, &SideBarWidget::setFocusToMainWin, m_mainViewWid, &MainViewWidget::selectFirstItemTab); - connect(m_sideBarWid, &SideBarWidget::sendCommonUseBtnSignal, m_mainViewWid, &MainViewWidget::loadCommonUseWidget); - connect(m_sideBarWid,&SideBarWidget::sendLetterBtnSignal, m_mainViewWid, &MainViewWidget::loadLetterWidget); - connect(m_sideBarWid, &SideBarWidget::sendFunctionBtnSignal, m_mainViewWid, &MainViewWidget::loadFunctionWidget); - - connect(m_sideBarWid,&SideBarWidget::sendFullScreenCommonUseBtnSignal, - m_mainViewWid,&MainViewWidget::loadFullCommonUseWidget); - connect(m_sideBarWid,&SideBarWidget::sendFullScreenLetterBtnSignal, - m_mainViewWid,&MainViewWidget::loadFullLetterWidget); - connect(m_sideBarWid,&SideBarWidget::sendFullScreenFunctionBtnSignal, - m_mainViewWid,&MainViewWidget::loadFullFunctionWidget); - - connect(m_sideBarWid, &SideBarWidget::setSlideBar, m_mainViewWid, &MainViewWidget::setSlideBar); - - connect(m_sideBarWid,&SideBarWidget::sendFullScreenBtnSignal,this,&MainWindow::showFullScreenWidget); - connect(m_sideBarWid,&SideBarWidget::sendDefaultBtnSignal,this,&MainWindow::showDefaultWidget); - connect(m_sideBarWid, &SideBarWidget::sendShowMainWindowSignal, this, &MainWindow::activeWindowSolt); - connect(m_mainViewWid,&MainViewWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); - connect(m_sideBarWid,&SideBarWidget::sendHideMainWindowSignal,this,&MainWindow::recvHideMainWindowSlot); - - connect(m_mainViewWid,&MainViewWidget::setFocusToSideWin,m_sideBarWid,&SideBarWidget::setFocusToThis); - connect(this, &MainWindow::setFocusSignal, m_mainViewWid, &MainViewWidget::selectFirstItem); - connect(QApplication::desktop(),&QDesktopWidget::resized,this, [=]{ - primaryScreenChangeSlot(); - }); - connect(QApplication::desktop(),&QDesktopWidget::primaryScreenChanged,this,[=]{ - primaryScreenChangeSlot(); - }); - - connect(QApplication::desktop(),&QDesktopWidget::screenCountChanged,this,[=]{ - primaryScreenChangeSlot(); - }); - - QDBusConnection::sessionBus().connect(DBUS_NAME,DBUS_PATH,DBUS_INTERFACE,QString("PanelGeometryRefresh"),this,SLOT(primaryScreenChangeSlot())); - - //监听屏幕缩放 - if(QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) - { - QGSettings* m_gsetting=new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); - connect(m_gsetting,&QGSettings::changed,this,[=](const QString &key) - { - if(key=="scalingFactor") - repaintWidget(); - }); - } - - if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { - QGSettings *psetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit(), QByteArray(), this); - connect(psetting, &QGSettings::changed, - this, &MainWindow::panelChangedSlot); - } -} - -void MainWindow::paintEvent(QPaintEvent *event) -{ - double transparency=getTransparency(); - - QRect rect = this->rect(); - QPainterPath path; - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(Qt::transparent); - if(!m_isFullScreen) - { - qreal radius=6; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawPath(path); - -// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - } - else//全屏固定背景色(黑底白字) - { -// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) -// { -// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); -// if(gsetting.keys().contains(QString("effect"))) -// { -// if(gsetting.get("effect").toBool()) -// { -// painter.setBrush(Qt::black); -// painter.setPen(Qt::transparent); -// painter.setOpacity(0.25); -// painter.drawRect(this->rect()); -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else -// { - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); -// } - - QPainterPath path; - path.addRect(this->rect()); - KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - } - QMainWindow::paintEvent(event); -} - -/** - * 显示全屏窗口 - */ -void MainWindow::showFullScreenWidget() -{ - m_isFullScreen = true; - this->setContentsMargins(0, 0, 0, 0); - int position = Style::panelPosition; - int x = Style::primaryScreenX; - int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; - QRect startRect; - QRect endRect; - - if (position == BOTTOM) { - startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); - } else { - startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); - } - endRect.setRect(x, y, width, height); - - this->centralWidget()->layout()->removeWidget(m_mainViewWid); - m_mainViewWid->setParent(nullptr); - this->centralWidget()->layout()->removeWidget(m_line); - m_line->setParent(nullptr); - this->centralWidget()->layout()->removeWidget(m_sideBarWid); - m_sideBarWid->setParent(nullptr); - - m_animation->setDuration(100);//动画总时间 - m_animation->setStartValue(startRect); - m_animation->setEndValue(endRect); - m_animation->setEasingCurve(QEasingCurve::Linear); - m_animation->start(); -} - -void MainWindow::mouseReleaseEvent(QMouseEvent *event) -{ - if(m_isFullScreen && event->button()==Qt::LeftButton) - { - this->hide(); - } -} - -/** - * 显示默认窗口 - */ -void MainWindow::showDefaultWidget() -{ - m_isFullScreen = false; - this->setContentsMargins(0, 0, 0, 0); - int position = Style::panelPosition; - int x = Style::primaryScreenX; - int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; - QRect startRect; - QRect endRect; - - startRect.setRect(x, y, width, height); - if (position == BOTTOM) { - endRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - endRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); - } else { - endRect.setRect(x + 4, y + 4, Style::minw, Style::minh); - } - - this->centralWidget()->layout()->removeWidget(m_mainViewWid); - m_mainViewWid->setParent(nullptr); - this->centralWidget()->layout()->removeWidget(m_sideBarWid); - m_sideBarWid->setParent(nullptr); - - m_animation->setDuration(100);//动画总时间 - m_animation->setStartValue(startRect); - m_animation->setEndValue(endRect); - m_animation->setEasingCurve(QEasingCurve::Linear); - m_animation->start(); -} - -void MainWindow::animationValueChangedSlot(const QVariant &value) -{ - if(m_isFullScreen) - { - QPainterPath path; - path.addRect(this->rect()); -// setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); - KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - } -} - -void MainWindow::animationValueFinishedSlot() -{ - if(m_isFullScreen) - { - this->centralWidget()->layout()->addWidget(m_mainViewWid); - this->centralWidget()->layout()->addWidget(m_sideBarWid); - m_sideBarWid->loadMaxSidebar(); - m_mainViewWid->loadMaxMainView(); - m_sideBarWid->enterAnimation(); - } - else - { - this->centralWidget()->layout()->addWidget(m_mainViewWid); - this->centralWidget()->layout()->addWidget(m_line); - this->centralWidget()->layout()->addWidget(m_sideBarWid); - m_sideBarWid->loadMinSidebar(); - m_mainViewWid->loadMinMainView(); - } -} - -void MainWindow::activeWindowSolt(bool flag) -{ -// qDebug() << "void MainWindow::activeWindowSolt(bool flag)"; - QTimer::singleShot(30,this, SLOT(mainWinShowSlot())); -} - -void MainWindow::mainWinShowSlot() -{ - this->activateWindow(); - qDebug() << "void MainWindow::activeWindowSolt()"; -} - -/** - * 鼠标点击窗口外部事件 - */ -bool MainWindow::event ( QEvent * event ) -{ - if (event->type() == QEvent::ActivationChange) - // if(QEvent::WindowDeactivate == event->type() && m_canHide)//窗口停用 - { - qDebug() << " * 鼠标点击窗口外部事件"; - if(QApplication::activeWindow() != this) - { - this->hide(); - m_mainViewWid->widgetMakeZero(); - } - } - - if (event->type() == QEvent::KeyPress) - { - QKeyEvent *keyEvent = (QKeyEvent *) event; -// if (keyEvent->key() == Qt::Key_Tab) -// { -// m_mainViewWid->setFocus(); -// Q_EMIT setFocusSignal(); -// return true; -// } - if(keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || - keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || - keyEvent->key() == Qt::Key_Tab) - { - m_mainViewWid->setFocus(); - Q_EMIT setFocusSignal(); - // return true; - } - } - return QWidget::event(event); -} - -/** - * 隐藏窗口 - */ -void MainWindow::recvHideMainWindowSlot() -{ - this->hide(); -// m_mainViewWid->widgetMakeZero(); -// m_sideBarWid->widgetMakeZero(); -} - -void MainWindow::loadMainWindow() -{ - cleanTimeoutApp(); - - int position = Style::panelPosition; - int x = Style::primaryScreenX; - int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; - this->setFocus(); - - if (m_isFullScreen) { - //修复界面黑框问题 - QRect startRect; - QRect endRect; - - if (position == BOTTOM) { - startRect.setRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh); - } else if (position == RIGHT) { - startRect.setRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh); - } else { - startRect.setRect(x + 4, y + 4, Style::minw, Style::minh); - } - endRect.setRect(x, y, width, height); - - this->centralWidget()->layout()->removeWidget(m_mainViewWid); - m_mainViewWid->setParent(nullptr); - this->centralWidget()->layout()->removeWidget(m_line); - m_line->setParent(nullptr); - this->centralWidget()->layout()->removeWidget(m_sideBarWid); - m_sideBarWid->setParent(nullptr); - m_animation->setDuration(1);//动画总时间 - m_animation->setStartValue(startRect); - m_animation->setEndValue(endRect); - m_animation->setEasingCurve(QEasingCurve::Linear); - m_animation->start(); - } else { - if (position == BOTTOM) { - this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); - } else if (position == RIGHT) { - this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); - } else { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } - m_sideBarWid->loadMinSidebar(); - m_mainViewWid->loadMinMainView(); - } -} - -void MainWindow::panelChangedSlot(QString key) -{ - Q_UNUSED(key); - Style::initWidStyle(); - m_mainViewWid->repaintFullWidget(); - repaintWidget(); -} - -void MainWindow::primaryScreenChangeSlot() -{ - Style::initWidStyle(); - m_mainViewWid->repaintFullWidget(); - resizeWidget(); -} - -void MainWindow::repaintWidget() -{ - Style::initWidStyle(); - this->setMinimumSize(Style::minw, Style::minh); - m_line->setFixedSize(1, this->height() - 1); - m_line->setStyleSheet("border : 1px solid rgb(255,255,255,25)"); - m_mainViewWid->repaintWidget(); - resizeWidget(); -} - -void MainWindow::resizeWidget() -{ - if (QApplication::activeWindow() == this) { - int position = Style::panelPosition; - int x = Style::primaryScreenX; - int y = Style::primaryScreenY; - int width = Style::widthavailable; - int height = Style::heightavailable; - - if (m_isFullScreen) { - this->setGeometry(x, y, width, height); - m_sideBarWid->loadMaxSidebar(); - m_sideBarWid->setSideBarBtnGeometry(); - } else { - if (position == BOTTOM) { - this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); - } else if (position == RIGHT) { - this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); - } else { - this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); - } - m_sideBarWid->loadMinSidebar(); - } - m_mainViewWid->resizeControl(); - } -} - -void MainWindow::keyPressEvent(QKeyEvent *e) -{ - if(e->type() == QEvent::KeyPress) - { - if((e->key() >= 0x30 && e->key() <= 0x39) || (e->key() >= 0x41 && e->key() <= 0x5a)) - { - m_mainViewWid->setLineEditFocus(e->text()); - } - if(e->key() == Qt::Key_Backspace) - { - m_mainViewWid->setLineEditFocus(""); - } - if(e->key() == Qt::Key_Escape) - { - this->hide(); - m_mainViewWid->widgetMakeZero(); - } - } -} diff --git a/src/MainWindow/mainwindow.h b/src/MainWindow/mainwindow.h deleted file mode 100644 index 8dd145f..0000000 --- a/src/MainWindow/mainwindow.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -#include -#include -#include -#include -#include -#include "src/Style/style.h" -#include "src/SideBarWidget/sidebarwidget.h" -#include "src/MainViewWidget/mainviewwidget.h" -#include "src/DBus/dbus.h" -#include "src/DBus/dbus-adaptor.h" -#include - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - /** - * @brief Set the QFrame style - */ -// void setFrameStyle(); - /** - * @brief Load the main window - */ - void loadMainWindow(); - -private: - - bool m_isFullScreen=false; - UkuiMenuInterface *m_ukuiMenuInterface=nullptr; - - QFrame *m_line=nullptr;//Vertical dividing line - QFrame *m_frame=nullptr; - SideBarWidget *m_sideBarWid=nullptr; - MainViewWidget *m_mainViewWid=nullptr; - - QPropertyAnimation *m_animation=nullptr; - bool m_winFlag = false; - DBus *m_dbus=nullptr; - -protected: - void initUi(); - /** - * @brief Handle events clicking on the outside of the window - */ - bool event(QEvent *event); - void paintEvent(QPaintEvent* event); - /** - * @brief The query box responds to keyboard events - */ - void keyPressEvent(QKeyEvent* e); - /** - * @brief Repaint window - */ - void repaintWidget(); - void resizeWidget(); - - void mouseReleaseEvent(QMouseEvent *event); - -public Q_SLOTS: - /** - * @brief Load the full screen window - */ - void showFullScreenWidget(); - /** - * @brief Load the default window - */ - void showDefaultWidget(); - void recvHideMainWindowSlot();//接收隐藏主窗口信号 - /** - * @brief Monitor taskbar key changes - * @param key: Key - */ - void panelChangedSlot(QString key); - void animationValueChangedSlot(const QVariant &value);//动画当前值变化监控 - void animationValueFinishedSlot(); - void primaryScreenChangeSlot(); - void activeWindowSolt(bool flag); - void mainWinShowSlot(); - -public: -Q_SIGNALS: - void setFocusSignal(); -}; - -#endif // MAINWINDOW_H diff --git a/src/ModelView/fulllistdelegate.cpp b/src/ModelView/fulllistdelegate.cpp deleted file mode 100644 index f7abd3f..0000000 --- a/src/ModelView/fulllistdelegate.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "fulllistdelegate.h" -#include "src/Style/style.h" -#include "src/UtilityFunction/utility.h" -#include -#include - -FullListDelegate::FullListDelegate(QObject *parent, int page): QStyledItemDelegate(parent) -{ - m_page = page; -} - -void FullListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QRectF rect; - rect.setX(option.rect.x()); - rect.setY(option.rect.y()); - rect.setWidth(option.rect.width()); - rect.setHeight(option.rect.height()); - //QPainterPath画圆角矩形 - const qreal radius = 4; - QPainterPath path; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter->setRenderHint(QPainter::Antialiasing); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - painter->save(); - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(Qt::white); - painter->setOpacity(0.15); - painter->drawPath(path); - painter->restore(); - } - //绘制应用图标 - painter->save(); - painter->setOpacity(1); - QIcon icon = index.data(Qt::DecorationRole).value(); - QRect iconRect; - iconRect = QRect(rect.x() + Style::AppLeftSpace, - rect.y() + Style::AppTopSpace, - Style::AppListIconSize, - Style::AppListIconSize); - icon.paint(painter, iconRect); - - //绘制是否存在固定标志 - QString desktopfp = index.data(Qt::AccessibleDescriptionRole).value(); - QFileInfo fileInfo(desktopfp); - QString desktopfn = fileInfo.fileName(); - bool isLocked = false; - if (m_page == COMMON_PAGE) { - if (checkIfLocked(desktopfn)) { - isLocked = true; - QIcon icon(QString(":/data/img/mainviewwidget/lock-fs.svg")); - icon.paint(painter, QRect(iconRect.topRight().x() - 14, iconRect.topRight().y() - 2, 16, 16)); - } - } - - //绘制应用名 - QString appName = index.data(Qt::DisplayRole).value(); - QFontMetrics fm = painter->fontMetrics(); - QString appnameElidedText = fm.elidedText(appName, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic); - QRect textRect; - textRect = QRect(rect.x() + 5, - iconRect.bottom() + Style::AppSpaceBetweenIconText, - rect.width() - 10, - rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); - - //添加最近安装蓝色标签 - bool isRecentapp = false; - if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { - isRecentapp = true; - appnameElidedText = fm.elidedText(appName, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic); - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(QColor("#4d94ff")); - int x = 0; - if (rect.width() < (10 + fm.boundingRect(appName).width())) { - x = rect.x() + 9; - } else { - x = rect.x() + (rect.width() - fm.boundingRect(appName).width()) / 2 - 8; - } - painter->drawEllipse(QPoint(x, textRect.y() + (fm.boundingRect(appName).height() - 8) / 2 + 4), - 4, 4); - } - painter->restore(); - painter->save(); - painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText); - painter->restore(); - - if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { - int len = fm.boundingRect(appName).width() + 10; - if (len > rect.width()) { - QToolTip::showText(QCursor::pos(), appName); - } else { - QToolTip::hideText(); - } - } -} - -QSize FullListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - return QSize(Style::AppListItemSizeWidth, Style::AppListItemSizeWidth); -} diff --git a/src/ModelView/fulllistdelegate.h b/src/ModelView/fulllistdelegate.h deleted file mode 100644 index afbd1a6..0000000 --- a/src/ModelView/fulllistdelegate.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef FULLLISTDELEGATE_H -#define FULLLISTDELEGATE_H - -#include -#include -#include "src/Interface/ukuimenuinterface.h" - -class FullListDelegate: public QStyledItemDelegate -{ - Q_OBJECT -public: - FullListDelegate(QObject *parent, int page); - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; -private: - int m_page; -}; - -#endif // FULLLISTDELEGATE_H diff --git a/src/ModelView/fulllistitem.cpp b/src/ModelView/fulllistitem.cpp deleted file mode 100644 index f4c1e46..0000000 --- a/src/ModelView/fulllistitem.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "fulllistitem.h" -#include -#include -#include -#include - -FullListItem::FullListItem(QWidget *parent) : QWidget(parent) -{ - -} - -void FullListItem::setAppList(QStringList list) -{ - m_appList.clear(); - m_appList = list; -} - -QIcon FullListItem::getAppIcon(QString list) -{ - XdgDesktopFile desktopfile; - desktopfile.load(list); - QString iconName = desktopfile.iconName(); - QIcon icon = XdgIcon::fromTheme(iconName); - - if (icon.isNull()) { - if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconName).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconName).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconName).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconName).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconName).arg("svg")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("png")); - } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("svg"))) { - icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconName).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("png")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("svg"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("svg")); - } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("xpm"))) { - icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconName).arg("xpm")); - } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconName).arg("png"))) { - icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconName).arg("png")); - } else { - icon = QIcon::fromTheme(QString("application-x-desktop")); - } - } - return icon; -} - -QString FullListItem::getAppName(QString list) -{ - XdgDesktopFile desktopfile; - desktopfile.load(list); - QString name = desktopfile.localizedValue("Name").toString(); - return name; -} diff --git a/src/ModelView/fulllistitem.h b/src/ModelView/fulllistitem.h deleted file mode 100644 index 39b5b23..0000000 --- a/src/ModelView/fulllistitem.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef FULLLISTITEM_H -#define FULLLISTITEM_H - -#include -#include - -class FullListItem: public QWidget -{ - friend class FullListModel; - Q_OBJECT -public: - explicit FullListItem(QWidget *parent = nullptr); - void setAppList(QStringList list); - QIcon getAppIcon(QString list); - QString getAppName(QString list); -private: - QStringList m_appList; -}; - -#endif // FULLLISTITEM_H diff --git a/src/ModelView/fulllistmodel.cpp b/src/ModelView/fulllistmodel.cpp deleted file mode 100644 index 3f9192e..0000000 --- a/src/ModelView/fulllistmodel.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "fulllistmodel.h" -#include "src/UtilityFunction/utility.h" -#include -#include - -FullListModel::FullListModel(QObject *parent) : QAbstractItemModel(parent) -{ - m_item = new FullListItem; -} - -QModelIndex FullListModel::index(int row, int column, const QModelIndex &parent) const -{ - return createIndex(row, column, m_item); -} - -QModelIndex FullListModel::parent(const QModelIndex &child) const -{ - return QModelIndex(); -} - -int FullListModel::rowCount(const QModelIndex &parent) const -{ - return m_item->m_appList.count(); -} - -int FullListModel::columnCount(const QModelIndex &parent) const -{ - return 1; -} - -QVariant FullListModel::data(const QModelIndex &index, int role) const -{ - if (m_item->m_appList.size() <= (index.row())) { - return QVariant(); - } - switch (role) { - case Qt::DecorationRole: { - return m_item->getAppIcon(m_item->m_appList.at(index.row())); - } - case Qt::DisplayRole: { - return m_item->getAppName(m_item->m_appList.at(index.row())); - } - case Qt::AccessibleDescriptionRole:{ - return m_item->m_appList.at(index.row()); - } - default: - break; - } - return QVariant(); -} - -void FullListModel::setAppList(QStringList list) -{ - m_item->setAppList(list); -} - -void FullListModel::execAppDesktop(QModelIndex index) -{ - execApp(m_item->m_appList.at(index.row())); -} - -int FullListModel::showRightClickMenu(const QPoint &pos, QModelIndex index) -{ - RightClickMenu menu; - return menu.showAppBtnMenu(pos, m_item->m_appList.at(index.row())); -} - -void FullListModel::startChangeModel(QStringList list) -{ - beginResetModel(); - m_item->m_appList.clear(); - m_item->m_appList = list; - endResetModel(); -} diff --git a/src/ModelView/fulllistmodel.h b/src/ModelView/fulllistmodel.h deleted file mode 100644 index 0f6e893..0000000 --- a/src/ModelView/fulllistmodel.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef FULLLISTMODEL_H -#define FULLLISTMODEL_H - -#include -#include -#include "fulllistitem.h" -#include "src/RightClickMenu/rightclickmenu.h" - -class FullListModel: public QAbstractItemModel -{ - Q_OBJECT -public: - explicit FullListModel(QObject *parent = nullptr); - QModelIndex index(int row, int column, const QModelIndex &parent) const; - QModelIndex parent(const QModelIndex &child) const; - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - - void setAppList(QStringList list); - void execAppDesktop(QModelIndex index); - void startChangeModel(QStringList list); - int showRightClickMenu(const QPoint &pos, QModelIndex index); -private: - FullListItem * m_item = nullptr; -Q_SIGNALS: - void sendItemClickedSignal(QString desktopfp); -}; - -#endif // FULLLISTMODEL_H diff --git a/src/ModelView/fulllistview.cpp b/src/ModelView/fulllistview.cpp deleted file mode 100644 index cb2b349..0000000 --- a/src/ModelView/fulllistview.cpp +++ /dev/null @@ -1,141 +0,0 @@ -#include "fulllistview.h" -#include "src/Style/style.h" -#include -#include - -FullListView::FullListView(QWidget *parent, int page) : QListView(parent) -{ - m_page = page; - initWidget(); -} - -void FullListView::initWidget() -{ - m_model = new FullListModel(this); - this->setModel(m_model); - - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setViewMode(QListView::IconMode); - this->setResizeMode(QListView::Adjust); - this->setGridSize(QSize(Style::AppListGridSizeWidth, Style::AppListGridSizeWidth)); - this->setFrameShape(QFrame::NoFrame);//移除边框,若不添加会存在晃动 - this->setContextMenuPolicy(Qt::CustomContextMenu); - - m_delegate = new FullListDelegate(this, m_page); - this->setItemDelegate(m_delegate); - - connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); - connect(this, &FullListView::clicked, this, &FullListView::onClicked); - -} - -void FullListView::setAppList(QStringList appList) -{ - m_model->setAppList(appList); -} - -void FullListView::startChangeModel(QStringList appList) -{ - m_model->startChangeModel(appList); -} - -void FullListView::selectFirstItem() -{ - if (this->currentIndex().row() == -1) { - this->setCurrentIndex(this->model()->index(0, 0)); - } -} - -void FullListView::onClicked(QModelIndex index) -{ - Q_EMIT sendHideMainWindowSignal(); - m_model->execAppDesktop(index); -} - -void FullListView::rightClickedSlot(const QPoint &pos) -{ - Q_UNUSED(pos) - if (!(this->selectionModel()->selectedIndexes().isEmpty())) { - QModelIndex index = this->currentIndex(); - int ret = m_model->showRightClickMenu(this->mapToGlobal(pos), index); - - switch (ret) { - case 1: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 2: - Q_EMIT sendUpdateAppListSignal(); - break; - - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - - default: - break; - } - } -} - -void FullListView::keyPressEvent(QKeyEvent *e) -{ - QRect center = visualRect(currentIndex()); - - if (e->type() == QEvent::KeyPress) { - switch (e->key()) { - case Qt::Key_Enter: - case Qt::Key_Return: { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - break; - } - - case Qt::Key_Left: { - if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) { - Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); - } - - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Right: { - if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) { - Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); - } - - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Up: { - return QListView::keyPressEvent(e); - break; - } - - case Qt::Key_Down: { - return QListView::keyPressEvent(e); - break; - } - - default: - return QListView::keyPressEvent(e); - break; - } - } -} - -void FullListView::mouseReleaseEvent(QMouseEvent *event) -{ - if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { - Q_EMIT sendHideMainWindowSignal(); - } else { - return QListView::mouseReleaseEvent(event); - } -} diff --git a/src/ModelView/fulllistview.h b/src/ModelView/fulllistview.h deleted file mode 100644 index c019522..0000000 --- a/src/ModelView/fulllistview.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef FULLLISTVIEW_H -#define FULLLISTVIEW_H - -#include -#include -#include "fulllistdelegate.h" -#include "src/UtilityFunction/utility.h" -#include "src/RightClickMenu/rightclickmenu.h" -#include "fulllistmodel.h" - -class FullListView : public QListView -{ - Q_OBJECT -public: - FullListView(QWidget *parent = nullptr, int page = 0); - void setAppList(QStringList appList); - void startChangeModel(QStringList appList); -protected: - void initWidget(); - void keyPressEvent(QKeyEvent *e); - void mouseReleaseEvent(QMouseEvent *event); -private: - FullListDelegate* m_delegate = nullptr; - FullListModel* m_model = nullptr; - int m_page; - -public Q_SLOTS: - void selectFirstItem(); - void onClicked(QModelIndex index);//点击item - void rightClickedSlot(const QPoint &pos); -Q_SIGNALS: - void sendSetslidebar(int value); - void sendHideMainWindowSignal(); - void sendUpdateAppListSignal(); -}; - -#endif // FULLLISTVIEW_H diff --git a/src/QtSingleApplication/QtLockedFile b/src/QtSingleApplication/QtLockedFile old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/QtSingleApplication b/src/QtSingleApplication/QtSingleApplication old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtlocalpeer.cpp b/src/QtSingleApplication/qtlocalpeer.cpp old mode 100644 new mode 100755 index 1824e8b..7d875d4 --- a/src/QtSingleApplication/qtlocalpeer.cpp +++ b/src/QtSingleApplication/qtlocalpeer.cpp @@ -45,32 +45,34 @@ #include #if defined(Q_OS_WIN) -#include -#include -typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); -static PProcessIdToSessionId pProcessIdToSessionId = 0; + #include + #include + typedef BOOL(WINAPI *PProcessIdToSessionId)(DWORD, DWORD *); + static PProcessIdToSessionId pProcessIdToSessionId = 0; #endif #if defined(Q_OS_UNIX) -#include -#include -#include + #include + #include + #include #endif -namespace QtLP_Private { +namespace QtLP_Private +{ #include "qtlockedfile.cpp" #if defined(Q_OS_WIN) -#include "qtlockedfile_win.cpp" + #include "qtlockedfile_win.cpp" #else -#include "qtlockedfile_unix.cpp" + #include "qtlockedfile_unix.cpp" #endif } -const char* QtLocalPeer::ack = "ack"; +const char *QtLocalPeer::ack = "ack"; -QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) +QtLocalPeer::QtLocalPeer(QObject *parent, const QString &appId) : QObject(parent), id(appId) { QString prefix = id; + if (id.isEmpty()) { id = QCoreApplication::applicationFilePath(); #if defined(Q_OS_WIN) @@ -78,30 +80,30 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) #endif prefix = id.section(QLatin1Char('/'), -1); } + prefix.remove(QRegExp("[^a-zA-Z]")); prefix.truncate(6); - QByteArray idc = id.toUtf8(); quint16 idNum = qChecksum(idc.constData(), idc.size()); socketName = QLatin1String("qtsingleapp-") + prefix + QLatin1Char('-') + QString::number(idNum, 16); - #if defined(Q_OS_WIN) + if (!pProcessIdToSessionId) { QLibrary lib("kernel32"); pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); } + if (pProcessIdToSessionId) { DWORD sessionId = 0; pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); socketName += QLatin1Char('-') + QString::number(sessionId, 16); } + #else socketName += QLatin1Char('-') + QString::number(::getuid(), 16); #endif - socketName += qgetenv("DISPLAY"); - server = new QLocalServer(this); QString lockName = QDir(QDir::tempPath()).absolutePath() + QLatin1Char('/') + socketName @@ -114,22 +116,29 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) bool QtLocalPeer::isClient() { - if (lockFile.isLocked()) + if (lockFile.isLocked()) { return false; + } - if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) + if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false)) { return true; + } bool res = server->listen(socketName); #if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) + // ### Workaround if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { - QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); + QFile::remove(QDir::cleanPath(QDir::tempPath()) + QLatin1Char('/') + socketName); res = server->listen(socketName); } + #endif - if (!res) + + if (!res) { qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); + } + QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); return false; } @@ -137,17 +146,22 @@ bool QtLocalPeer::isClient() bool QtLocalPeer::sendMessage(const QString &message, int timeout) { - if (!isClient()) + if (!isClient()) { return false; + } QLocalSocket socket; bool connOk = false; - for(int i = 0; i < 2; i++) { + + for (int i = 0; i < 2; i++) { // Try twice, in case the other instance is just starting up socket.connectToServer(socketName); - connOk = socket.waitForConnected(timeout/2); - if (connOk || i) + connOk = socket.waitForConnected(timeout / 2); + + if (connOk || i) { break; + } + int ms = 250; #if defined(Q_OS_WIN) Sleep(DWORD(ms)); @@ -156,27 +170,35 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout) nanosleep(&ts, NULL); #endif } - if (!connOk) + + if (!connOk) { return false; + } QByteArray uMsg(message.toUtf8()); QDataStream ds(&socket); ds.writeBytes(uMsg.constData(), uMsg.size()); bool res = socket.waitForBytesWritten(timeout); + if (res) { res &= socket.waitForReadyRead(timeout); // wait for ack - if (res) + + if (res) { res &= (socket.read(qstrlen(ack)) == ack); + } } + return res; } void QtLocalPeer::receiveConnection() { - QLocalSocket* socket = server->nextPendingConnection(); - if (!socket) + QLocalSocket *socket = server->nextPendingConnection(); + + if (!socket) { return; + } while (true) { if (socket->state() == QLocalSocket::UnconnectedState) { @@ -184,8 +206,11 @@ void QtLocalPeer::receiveConnection() delete socket; return; } - if (socket->bytesAvailable() >= qint64(sizeof(quint32))) + + if (socket->bytesAvailable() >= qint64(sizeof(quint32))) { break; + } + socket->waitForReadyRead(); } @@ -195,17 +220,20 @@ void QtLocalPeer::receiveConnection() ds >> remaining; uMsg.resize(remaining); int got = 0; - char* uMsgBuf = uMsg.data(); + char *uMsgBuf = uMsg.data(); + do { got = ds.readRawData(uMsgBuf, remaining); remaining -= got; uMsgBuf += got; } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); + if (got < 0) { qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); delete socket; return; } + QString message(QString::fromUtf8(uMsg)); socket->write(ack, qstrlen(ack)); socket->waitForBytesWritten(1000); diff --git a/src/QtSingleApplication/qtlocalpeer.h b/src/QtSingleApplication/qtlocalpeer.h old mode 100644 new mode 100755 index 1b533b1..4e63426 --- a/src/QtSingleApplication/qtlocalpeer.h +++ b/src/QtSingleApplication/qtlocalpeer.h @@ -56,7 +56,9 @@ public: bool isClient(); bool sendMessage(const QString &message, int timeout); QString applicationId() const - { return id; } + { + return id; + } Q_SIGNALS: void messageReceived(const QString &message); @@ -67,11 +69,11 @@ protected Q_SLOTS: protected: QString id; QString socketName; - QLocalServer* server; + QLocalServer *server; QtLP_Private::QtLockedFile lockFile; private: - static const char* ack; + static const char *ack; }; #endif // QTLOCALPEER_H diff --git a/src/QtSingleApplication/qtlockedfile.cpp b/src/QtSingleApplication/qtlockedfile.cpp old mode 100644 new mode 100755 index c142a86..2204343 --- a/src/QtSingleApplication/qtlockedfile.cpp +++ b/src/QtSingleApplication/qtlockedfile.cpp @@ -126,6 +126,7 @@ bool QtLockedFile::open(OpenMode mode) qWarning("QtLockedFile::open(): Truncate mode not allowed."); return false; } + return QFile::open(mode); } diff --git a/src/QtSingleApplication/qtlockedfile.h b/src/QtSingleApplication/qtlockedfile.h old mode 100644 new mode 100755 index 84c18e5..e73d39a --- a/src/QtSingleApplication/qtlockedfile.h +++ b/src/QtSingleApplication/qtlockedfile.h @@ -43,26 +43,27 @@ #include #ifdef Q_OS_WIN -#include + #include #endif #if defined(Q_OS_WIN) -# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) -# define QT_QTLOCKEDFILE_EXPORT -# elif defined(QT_QTLOCKEDFILE_IMPORT) -# if defined(QT_QTLOCKEDFILE_EXPORT) -# undef QT_QTLOCKEDFILE_EXPORT -# endif -# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) -# elif defined(QT_QTLOCKEDFILE_EXPORT) -# undef QT_QTLOCKEDFILE_EXPORT -# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) -# endif + #if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) + #define QT_QTLOCKEDFILE_EXPORT + #elif defined(QT_QTLOCKEDFILE_IMPORT) + #if defined(QT_QTLOCKEDFILE_EXPORT) + #undef QT_QTLOCKEDFILE_EXPORT + #endif + #define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) + #elif defined(QT_QTLOCKEDFILE_EXPORT) + #undef QT_QTLOCKEDFILE_EXPORT + #define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) + #endif #else -# define QT_QTLOCKEDFILE_EXPORT + #define QT_QTLOCKEDFILE_EXPORT #endif -namespace QtLP_Private { +namespace QtLP_Private +{ class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile { diff --git a/src/QtSingleApplication/qtlockedfile_unix.cpp b/src/QtSingleApplication/qtlockedfile_unix.cpp old mode 100644 new mode 100755 index 976c1b9..9e9a5a6 --- a/src/QtSingleApplication/qtlockedfile_unix.cpp +++ b/src/QtSingleApplication/qtlockedfile_unix.cpp @@ -51,31 +51,41 @@ bool QtLockedFile::lock(LockMode mode, bool block) qWarning("QtLockedFile::lock(): file is not opened"); return false; } - - if (mode == NoLock) - return unlock(); - - if (mode == m_lock_mode) - return true; - if (m_lock_mode != NoLock) + if (mode == NoLock) { + return unlock(); + } + + if (mode == m_lock_mode) { + return true; + } + + if (m_lock_mode != NoLock) { unlock(); + } struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; + int cmd = block ? F_SETLKW : F_SETLK; + int ret = fcntl(handle(), cmd, &fl); - + if (ret == -1) { - if (errno != EINTR && errno != EAGAIN) + if (errno != EINTR && errno != EAGAIN) { qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); + } + return false; } - m_lock_mode = mode; return true; } @@ -88,28 +98,35 @@ bool QtLockedFile::unlock() return false; } - if (!isLocked()) + if (!isLocked()) { return true; + } struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = F_UNLCK; + int ret = fcntl(handle(), F_SETLKW, &fl); - + if (ret == -1) { qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); return false; } - + m_lock_mode = NoLock; return true; } QtLockedFile::~QtLockedFile() { - if (isOpen()) + if (isOpen()) { unlock(); + } } diff --git a/src/QtSingleApplication/qtlockedfile_win.cpp b/src/QtSingleApplication/qtlockedfile_win.cpp old mode 100644 new mode 100755 index 6144ea7..38500e4 --- a/src/QtSingleApplication/qtlockedfile_win.cpp +++ b/src/QtSingleApplication/qtlockedfile_win.cpp @@ -47,7 +47,7 @@ #define MAX_READERS MAXIMUM_WAIT_OBJECTS #if QT_VERSION >= 0x050000 -#define QT_WA(unicode, ansi) unicode + #define QT_WA(unicode, ansi) unicode #endif Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) @@ -57,28 +57,36 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) mutexname = QString::fromLatin1(MUTEX_PREFIX) + fi.absoluteFilePath().toLower(); } + QString mname(mutexname); - if (idx >= 0) + + if (idx >= 0) { mname += QString::number(idx); + } Qt::HANDLE mutex; + if (doCreate) { - QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, - { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); + QT_WA({ mutex = CreateMutexW(NULL, FALSE, (TCHAR *)mname.utf16()); }, + { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); }); + if (!mutex) { qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); return 0; } - } - else { - QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, - { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); + } else { + QT_WA({ mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR *)mname.utf16()); }, + { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); }); + if (!mutex) { - if (GetLastError() != ERROR_FILE_NOT_FOUND) + if (GetLastError() != ERROR_FILE_NOT_FOUND) { qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); + } + return 0; } } + return mutex; } @@ -86,16 +94,20 @@ bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) { Q_ASSERT(mutex); DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); + switch (res) { - case WAIT_OBJECT_0: - case WAIT_ABANDONED: - return true; - break; - case WAIT_TIMEOUT: - break; - default: - qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + return true; + break; + + case WAIT_TIMEOUT: + break; + + default: + qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); } + return false; } @@ -108,61 +120,83 @@ bool QtLockedFile::lock(LockMode mode, bool block) return false; } - if (mode == NoLock) + if (mode == NoLock) { return unlock(); + } - if (mode == m_lock_mode) + if (mode == m_lock_mode) { return true; + } - if (m_lock_mode != NoLock) + if (m_lock_mode != NoLock) { unlock(); + } - if (!wmutex && !(wmutex = getMutexHandle(-1, true))) + if (!wmutex && !(wmutex = getMutexHandle(-1, true))) { return false; + } - if (!waitMutex(wmutex, block)) + if (!waitMutex(wmutex, block)) { return false; + } if (mode == ReadLock) { int idx = 0; + for (; idx < MAX_READERS; idx++) { rmutex = getMutexHandle(idx, false); - if (!rmutex || waitMutex(rmutex, false)) + + if (!rmutex || waitMutex(rmutex, false)) { break; + } + CloseHandle(rmutex); } + bool ok = true; + if (idx >= MAX_READERS) { qWarning("QtLockedFile::lock(): too many readers"); rmutex = 0; ok = false; - } - else if (!rmutex) { + } else if (!rmutex) { rmutex = getMutexHandle(idx, true); - if (!rmutex || !waitMutex(rmutex, false)) + + if (!rmutex || !waitMutex(rmutex, false)) { ok = false; + } } + if (!ok && rmutex) { CloseHandle(rmutex); rmutex = 0; } + ReleaseMutex(wmutex); - if (!ok) + + if (!ok) { return false; - } - else { + } + } else { Q_ASSERT(rmutexes.isEmpty()); + for (int i = 0; i < MAX_READERS; i++) { Qt::HANDLE mutex = getMutexHandle(i, false); - if (mutex) + + if (mutex) { rmutexes.append(mutex); + } } + if (rmutexes.size()) { DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), TRUE, block ? INFINITE : 0); + if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { - if (res != WAIT_TIMEOUT) + if (res != WAIT_TIMEOUT) { qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); + } + m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky unlock(); return false; @@ -181,19 +215,20 @@ bool QtLockedFile::unlock() return false; } - if (!isLocked()) + if (!isLocked()) { return true; + } if (m_lock_mode == ReadLock) { ReleaseMutex(rmutex); CloseHandle(rmutex); rmutex = 0; - } - else { - Q_FOREACH(Qt::HANDLE mutex, rmutexes) { + } else { + Q_FOREACH (Qt::HANDLE mutex, rmutexes) { ReleaseMutex(mutex); CloseHandle(mutex); } + rmutexes.clear(); ReleaseMutex(wmutex); } @@ -204,8 +239,11 @@ bool QtLockedFile::unlock() QtLockedFile::~QtLockedFile() { - if (isOpen()) + if (isOpen()) { unlock(); - if (wmutex) + } + + if (wmutex) { CloseHandle(wmutex); + } } diff --git a/src/QtSingleApplication/qtsingleapplication.cpp b/src/QtSingleApplication/qtsingleapplication.cpp old mode 100644 new mode 100755 index 9257ace..d957182 --- a/src/QtSingleApplication/qtsingleapplication.cpp +++ b/src/QtSingleApplication/qtsingleapplication.cpp @@ -40,13 +40,15 @@ #include "qtsingleapplication.h" +#include "src/UtilityFunction/utility.h" #include "qtlocalpeer.h" #include #include #include #include #include -#include "src/MainWindow/mainwindow.h" +#include "mainwindow.h" +#include "tabletwindow.h" /*! @@ -142,7 +144,7 @@ void QtSingleApplication::sysInit(const QString &appId) { actWin = 0; peer = new QtLocalPeer(this, appId); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); + connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &))); } @@ -196,7 +198,7 @@ QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) will be QCoreApplication::applicationFilePath(). \a dpy, \a visual, and \a cmap are passed on to the QApplication constructor. */ -QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap) +QtSingleApplication::QtSingleApplication(Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, visual, cmap) { sysInit(); @@ -222,7 +224,7 @@ QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Q argv, \a visual, and \a cmap are passed on to the QApplication constructor. */ -QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) +QtSingleApplication::QtSingleApplication(Display *dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) : QApplication(dpy, argc, argv, visual, cmap) { sysInit(appId); @@ -304,13 +306,15 @@ QString QtSingleApplication::id() const \sa activateWindow(), messageReceived() */ -void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) +void QtSingleApplication::setActivationWindow(QWidget *aw, bool activateOnMessage) { actWin = aw; - if (activateOnMessage) - connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); - else - disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); + + if (activateOnMessage) { + connect(peer, SIGNAL(messageReceived(const QString &)), this, SLOT(activateWindow())); + } else { + disconnect(peer, SIGNAL(messageReceived(const QString &)), this, SLOT(activateWindow())); + } } @@ -320,7 +324,7 @@ void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessag \sa setActivationWindow() */ -QWidget* QtSingleApplication::activationWindow() const +QWidget *QtSingleApplication::activationWindow() const { return actWin; } @@ -343,21 +347,24 @@ QWidget* QtSingleApplication::activationWindow() const void QtSingleApplication::activateWindow() { if (actWin) { - if(this->applicationState() & Qt::ApplicationInactive) - { - MainWindow* w=qobject_cast(actWin); - w->loadMainWindow(); - actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); - actWin->raise(); - actWin->showNormal(); - actWin->activateWindow(); + myDebug() << "单例触发activateWindow"; + if (!g_projectCodeName.contains("V10SP1-edu")) { + MainWindow *w = qobject_cast(actWin); + w->windowOption(); +// if (this->applicationState() & Qt::ApplicationInactive) { +// myDebug() << "单例内触发开始菜单显示"; +// actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); +// w->showWindow(); +// } else { +// myDebug() << "单例内触发开始菜单隐藏"; +// actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized); +// w->hideWindow(); +// } + } else { + TabletWindow *w = qobject_cast(actWin); + w->showPCMenu(); } - else { - actWin->setWindowState(actWin->windowState() & Qt::WindowMinimized); - actWin->hide(); - } - } } diff --git a/src/QtSingleApplication/qtsingleapplication.h b/src/QtSingleApplication/qtsingleapplication.h old mode 100644 new mode 100755 index 0b36bea..3bbc700 --- a/src/QtSingleApplication/qtsingleapplication.h +++ b/src/QtSingleApplication/qtsingleapplication.h @@ -46,19 +46,19 @@ class QtLocalPeer; #if defined(Q_OS_WIN) -# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) -# define QT_QTSINGLEAPPLICATION_EXPORT -# elif defined(QT_QTSINGLEAPPLICATION_IMPORT) -# if defined(QT_QTSINGLEAPPLICATION_EXPORT) -# undef QT_QTSINGLEAPPLICATION_EXPORT -# endif -# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) -# elif defined(QT_QTSINGLEAPPLICATION_EXPORT) -# undef QT_QTSINGLEAPPLICATION_EXPORT -# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) -# endif + #if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) + #define QT_QTSINGLEAPPLICATION_EXPORT + #elif defined(QT_QTSINGLEAPPLICATION_IMPORT) + #if defined(QT_QTSINGLEAPPLICATION_EXPORT) + #undef QT_QTSINGLEAPPLICATION_EXPORT + #endif + #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) + #elif defined(QT_QTSINGLEAPPLICATION_EXPORT) + #undef QT_QTSINGLEAPPLICATION_EXPORT + #define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) + #endif #else -# define QT_QTSINGLEAPPLICATION_EXPORT + #define QT_QTSINGLEAPPLICATION_EXPORT #endif class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication @@ -71,21 +71,24 @@ public: #if QT_VERSION < 0x050000 QtSingleApplication(int &argc, char **argv, Type type); # if defined(Q_WS_X11) - QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); - QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); - QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); + QtSingleApplication(Display *dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); + QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); + QtSingleApplication(Display *dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); # endif // Q_WS_X11 #endif // QT_VERSION < 0x050000 bool isRunning(); QString id() const; - void setActivationWindow(QWidget* aw, bool activateOnMessage = true); - QWidget* activationWindow() const; + void setActivationWindow(QWidget *aw, bool activateOnMessage = true); + QWidget *activationWindow() const; // Obsolete: void initialize(bool dummy = true) - { isRunning(); Q_UNUSED(dummy) } + { + isRunning(); + Q_UNUSED(dummy) + } public Q_SLOTS: bool sendMessage(const QString &message, int timeout = 5000); @@ -96,7 +99,7 @@ Q_SIGNALS: void messageReceived(const QString &message); protected: - // bool notify(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + // bool notify(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; private: void sysInit(const QString &appId = QString()); diff --git a/src/QtSingleApplication/qtsingleapplication.pri b/src/QtSingleApplication/qtsingleapplication.pri old mode 100644 new mode 100755 diff --git a/src/QtSingleApplication/qtsinglecoreapplication.cpp b/src/QtSingleApplication/qtsinglecoreapplication.cpp old mode 100644 new mode 100755 index 5634537..d06a75b --- a/src/QtSingleApplication/qtsinglecoreapplication.cpp +++ b/src/QtSingleApplication/qtsinglecoreapplication.cpp @@ -74,7 +74,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); + connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &))); } @@ -87,7 +87,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc : QCoreApplication(argc, argv) { peer = new QtLocalPeer(this, appId); - connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); + connect(peer, SIGNAL(messageReceived(const QString &)), SIGNAL(messageReceived(const QString &))); } diff --git a/src/QtSingleApplication/qtsinglecoreapplication.h b/src/QtSingleApplication/qtsinglecoreapplication.h old mode 100644 new mode 100755 index b87fffe..571b37d --- a/src/QtSingleApplication/qtsinglecoreapplication.h +++ b/src/QtSingleApplication/qtsinglecoreapplication.h @@ -59,13 +59,12 @@ public: public Q_SLOTS: bool sendMessage(const QString &message, int timeout = 5000); - Q_SIGNALS: void messageReceived(const QString &message); private: - QtLocalPeer* peer; + QtLocalPeer *peer; }; #endif // QTSINGLECOREAPPLICATION_H diff --git a/src/QtSingleApplication/qtsinglecoreapplication.pri b/src/QtSingleApplication/qtsinglecoreapplication.pri old mode 100644 new mode 100755 diff --git a/src/RightClickMenu/menubox.cpp b/src/RightClickMenu/menubox.cpp deleted file mode 100644 index 6333dd0..0000000 --- a/src/RightClickMenu/menubox.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "menubox.h" -#include -#include -#include -#include - -MenuBox::MenuBox(QWidget *parent): - QMenu(parent) -{ - this->activateWindow(); -} - -void MenuBox::mousePressEvent(QMouseEvent *event) -{ - this->activateWindow(); - Q_EMIT sendMainWinActiveSignal(true); - return QMenu::mousePressEvent(event); -} - -//void MenuBox::mouseReleaseEvent(QMouseEvent *event) -//{ -// Q_UNUSED(event); -// this->activateWindow(); -// Q_EMIT sendMainWinActiveSignal(true); -// if(this->geometry().contains(QCursor::pos())) -// { -// return QMenu::mousePressEvent(event); -// } -// else -// { -// this->raise(); -// this->activateWindow(); -// } - -// return QMenu::mouseReleaseEvent(event); -//} diff --git a/src/RightClickMenu/rightclickmenu.cpp b/src/RightClickMenu/rightclickmenu.cpp deleted file mode 100644 index 5cda046..0000000 --- a/src/RightClickMenu/rightclickmenu.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* - * 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 - -RightClickMenu::RightClickMenu(QWidget *parent): - QWidget(parent) -{ - m_cmdProc=new QProcess; - - m_whiteList.append("kylin-screenshot.desktop"); - m_whiteList.append("ukui-notebook.desktop"); - m_whiteList.append("ukui-clock.desktop"); - m_whiteList.append("kylin-calculator.desktop"); - m_whiteList.append("kylin-recorder.desktop"); - m_whiteList.append("kylin-software-center.desktop"); - m_whiteList.append("kylin-camera.desktop"); - m_whiteList.append("biometric-manager.desktop"); - m_whiteList.append("yhkylin-backup-tools.desktop"); - m_whiteList.append("box-manager.desktop"); - m_whiteList.append("ukui-system-monitor.desktop"); - m_whiteList.append("ksc-defender.desktop"); - m_whiteList.append("logview.desktop"); - m_whiteList.append("kylin-service-support.desktop"); - m_whiteList.append("kylin-user-guide.desktop"); - m_whiteList.append("ukui-control-center.desktop"); - m_whiteList.append("peony.desktop"); - m_whiteList.append("engrampa.desktop"); - - m_ukuiMenuInterface=new UkuiMenuInterface; - -} - -RightClickMenu::~RightClickMenu() -{ - delete m_cmdProc; - delete m_ukuiMenuInterface; -} - -QPixmap RightClickMenu::getIconPixmap(QString iconstr, int type) -{ - const auto ratio=devicePixelRatioF(); - QPixmap pixmap; - - if(type==0) - { - pixmap=loadSvg(iconstr,16*ratio); - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - } - else - { - QIcon icon=QIcon::fromTheme(iconstr); - QPixmap pixmap_1=icon.pixmap(QSize(16*ratio,16*ratio)); - pixmap=drawSymbolicColoredPixmap(pixmap_1); - } - return pixmap; -} - -void RightClickMenu::fixToAllActionTriggerSlot() -{ - m_actionNumber=1; - QFileInfo fileInfo(m_desktopfp); - QString desktopfn=fileInfo.fileName(); - updateDataBaseTableType(desktopfn,1); -} - -void RightClickMenu::unfixedFromAllActionTriggerSlot() -{ - m_actionNumber=2; - QFileInfo fileInfo(m_desktopfp); - QString desktopfn=fileInfo.fileName(); - updateDataBaseTableType(desktopfn,0); -} - -void RightClickMenu::fixToTaskbarActionTriggerSlot() -{ - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret=iface.call("AddToTaskbar",m_desktopfp); - m_actionNumber=3; -} - -void RightClickMenu::unfixedFromTaskbarActionTriggerSlot() -{ - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - QDBusReply ret=iface.call("RemoveFromTaskbar",m_desktopfp); - m_actionNumber=4; -} - -void RightClickMenu::addToDesktopActionTriggerSlot() -{ - QString path=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - QFileInfo fileInfo(m_desktopfp); - QString desktopfn=fileInfo.fileName(); - QFile file(m_desktopfp); - QString newname=QString(path+"/"+desktopfn); - bool ret=file.copy(QString(path+"/"+desktopfn)); - if(ret) - { - char command[200]; - sprintf(command,"chmod a+x %s",newname.toLocal8Bit().data()); - QProcess::startDetached(QString::fromLocal8Bit(command)); - } - m_actionNumber=5; -} - -void RightClickMenu::uninstallActionTriggerSlot() -{ - if(!checkOsRelease()) - { - QString cmd=QString("kylin-uninstaller %1") - .arg(m_desktopfp.toLocal8Bit().data()); - bool ret=QProcess::startDetached(cmd); - qDebug()<<"卸载:"<start("sh",QStringList()<<"-c"<waitForFinished(); - QString output=m_cmdProc->readAllStandardOutput().trimmed(); - QString packageName=output.split(":").at(0); - cmd.clear(); - cmd=QString("kylin-installer -remove %1") - .arg(packageName.toLocal8Bit().data()); - bool ret=QProcess::startDetached(cmd); - qDebug()<<"卸载:"<m_desktopfp.clear(); - this->m_desktopfp=desktopfp; - - MenuBox m_showAppMenu; - connect(&m_showAppMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); - m_showAppMenu.setWindowFlag(Qt::Popup); - - //添加菜单项,指定图标、名称、响应函数 - QFileInfo fileInfo(desktopfp); - QString desktopfn=fileInfo.fileName(); - if(!checkIfLocked(desktopfn)) - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg",0)),tr("Pin to all"), - this,SLOT(fixToAllActionTriggerSlot())); - else - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from all"), - this,SLOT(unfixedFromAllActionTriggerSlot())); - QDBusInterface iface("com.ukui.panel.desktop", - "/", - "com.ukui.panel.desktop", - QDBusConnection::sessionBus()); - - QDBusReply ret=iface.call("CheckIfExist",desktopfp); - if(!ret) - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg",0)),tr("Pin to taskbar"), - this,SLOT(fixToTaskbarActionTriggerSlot())); - else - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from taskbar"), - this,SLOT(unfixedFromTaskbarActionTriggerSlot())); - - m_showAppMenu.addAction(tr("Add to desktop shortcuts"), - this,SLOT(addToDesktopActionTriggerSlot())); - //检查桌面快捷方式是否存在 - QString desktopPath=QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - QString path=QString(desktopPath+"/"+QFileInfo(m_desktopfp).fileName()); - if(QFile(path).exists()) - m_showAppMenu.actions().at(2)->setEnabled(false);//存在时禁用 - m_showAppMenu.addSeparator(); - if(!m_whiteList.contains(desktopfn)) - m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg",0)),tr("Uninstall"), - this,SLOT(uninstallActionTriggerSlot())); - - m_showAppMenu.setAttribute(Qt::WA_TranslucentBackground); - m_showAppMenu.setAttribute(Qt::WA_DeleteOnClose); - m_showAppMenu.exec(pos); - qDebug() << "RightClickMenu::showAppBtnMenu(QString desktopfp)"; - return m_actionNumber; -} - -int RightClickMenu::showShutdownMenu(const QPoint &pos) -{ - m_actionNumber=0; - MenuBox m_showShutMenu; - connect(&m_showShutMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); - m_showShutMenu.setWindowFlag(Qt::Popup); - - m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Sleep"), - this,SLOT(hibernateActionTriggerSlot()));//休眠睡眠相同 - m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic",1)),tr("Log Out"), - this,SLOT(logoutActionTriggerSlot())); - m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic",1)),tr("Restart"), - this,SLOT(rebootActionTriggerSlot())); - m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic",1)),tr("Power Off"), - this,SLOT(shutdownActionTriggerSlot())); - m_showShutMenu.setAttribute(Qt::WA_TranslucentBackground); - m_showShutMenu.setAttribute(Qt::WA_DeleteOnClose); - m_showShutMenu.raise(); - m_showShutMenu.exec(pos); - qDebug() << "RightClickMenu::showShutdownMenu()"; - return m_actionNumber; -} - -int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) -{ - m_actionNumber=0; - this->m_desktopfp.clear(); - this->m_desktopfp=desktopfp; - MenuBox m_showOtherMenu; - connect(&m_showOtherMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); - m_showOtherMenu.setWindowFlag(Qt::Popup); -// QDBusInterface iface("com.ukui.panel.desktop", -// "/", -// "com.ukui.panel.desktop", -// QDBusConnection::sessionBus()); - -// QDBusReply ret=iface.call("CheckIfExist",this->m_desktopfp); -// if(!ret) -// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"), -// this,SLOT(fixToTaskbarActionTriggerSlot())); -// else -// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"), -// this,SLOT(unfixedFromTaskbarActionTriggerSlot())); - m_showOtherMenu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg",0)),tr("Personalize this list"), - this,SLOT(otherListActionTriggerSlot())); - m_showOtherMenu.setAttribute(Qt::WA_TranslucentBackground); - m_showOtherMenu.setAttribute(Qt::WA_DeleteOnClose); - m_showOtherMenu.exec(pos); - qDebug() << "RightClickMenu::showOtherMenu(QString desktopfp)"; - - return m_actionNumber; -} diff --git a/src/RightClickMenu/uninstallwhitelist.cpp b/src/RightClickMenu/uninstallwhitelist.cpp deleted file mode 100644 index 51e5cbe..0000000 --- a/src/RightClickMenu/uninstallwhitelist.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 - -UninstallWhitelist *UninstallWhitelist::instance = nullptr; - -UninstallWhitelist::UninstallWhitelist() -{ - m_whiteList.append("kylin-screenshot.desktop"); - m_whiteList.append("ukui-notebook.desktop"); - m_whiteList.append("ukui-clock.desktop"); - m_whiteList.append("kylin-calculator.desktop"); - m_whiteList.append("kylin-recorder.desktop"); - m_whiteList.append("kylin-software-center.desktop"); - m_whiteList.append("kylin-camera.desktop"); - m_whiteList.append("biometric-manager.desktop"); - m_whiteList.append("yhkylin-backup-tools.desktop"); - m_whiteList.append("box-manager.desktop"); - m_whiteList.append("ukui-system-monitor.desktop"); - m_whiteList.append("ksc-defender.desktop"); - m_whiteList.append("logview.desktop"); - m_whiteList.append("kylin-service-support.desktop"); - m_whiteList.append("kylin-user-guide.desktop"); - m_whiteList.append("ukui-control-center.desktop"); - m_whiteList.append("peony.desktop"); - m_whiteList.append("engrampa.desktop"); - - if (isHuaWei9006C || isHuaWeiPC) { - m_whiteList.append("org.gnome.FileRoller.desktop"); - m_whiteList.append("mate-terminal.desktop"); - m_whiteList.append("hwaudioui.desktop"); - } -} - -UninstallWhitelist *UninstallWhitelist::getInstance() -{ - if (instance == nullptr) { - instance = new UninstallWhitelist(); - } - - return instance; -} - -QStringList UninstallWhitelist::getPkgNameWhiteList() -{ - QStringList pkgNameList; - - Q_FOREACH (QString desktop, m_whiteList) { - QProcess *processPkgName = new QProcess(); - processPkgName->start(QString("dpkg -S /usr/share/applications/%1").arg(desktop)); - connect(processPkgName, static_cast(&QProcess::finished), this, [ = ]() { - processPkgName->deleteLater(); - }); - processPkgName->waitForFinished(); - QString pkgName = processPkgName->readAll(); - pkgName = pkgName.left(pkgName.indexOf(":")); - pkgNameList.append(pkgName); - } - - return pkgNameList; -} - -QStringList UninstallWhitelist::getWhiteList() -{ - return m_whiteList; -} diff --git a/src/SearchResultWidget/fullsearchresultwidget.cpp b/src/SearchResultWidget/fullsearchresultwidget.cpp deleted file mode 100644 index 52c16f9..0000000 --- a/src/SearchResultWidget/fullsearchresultwidget.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 -#include "src/Style/style.h" -#include "src/UtilityFunction/utility.h" -#include - -FullSearchResultWidget::FullSearchResultWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -FullSearchResultWidget::~FullSearchResultWidget() -{ - delete m_ukuiMenuInterface; -} - -void FullSearchResultWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - - QHBoxLayout* mainLayout=new QHBoxLayout; - mainLayout->setContentsMargins(0,0,0,0); - m_spaceItem=new QSpacerItem(40,20,QSizePolicy::Expanding,QSizePolicy::Fixed); - mainLayout->addItem(m_spaceItem); - m_listView=new FullListView(this,3); - this->setLayout(mainLayout); - - m_scrollArea=new ScrollArea; - m_scrollAreaWid=new ScrollAreaWid; - m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); - m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); - m_scrollArea->setWidget(m_scrollAreaWid); - m_scrollArea->setWidgetResizable(true); - m_scrollAreaWidLayout=new QVBoxLayout; - m_scrollAreaWidLayout->setContentsMargins(0,0,0,0); - m_scrollAreaWidLayout->setSpacing(10); - m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); - mainLayout->addWidget(m_scrollArea); - m_scrollAreaWidLayout->addWidget(m_listView); - m_scrollAreaWidLayout->addItem(new QSpacerItem(20,40,QSizePolicy::Fixed,QSizePolicy::Expanding)); - - m_data.clear(); - m_listView->addData(m_data); - m_ukuiMenuInterface=new UkuiMenuInterface; - - connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication); - connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullSearchResultWidget::sendHideMainWindowSignal); -} - -/** - * 执行应用程序 - */ -void FullSearchResultWidget::execApplication(QString desktopfp) -{ - Q_EMIT sendHideMainWindowSignal(); - execApp(desktopfp); -} - -void FullSearchResultWidget::updateAppListView(QVector arg) -{ - m_data.clear(); - Q_FOREACH(QStringList appinfo,arg) - m_data.append(appinfo.at(0)); - m_listView->updateData(m_data); - resizeScrollAreaControls(); -} - -void FullSearchResultWidget::resizeScrollAreaControls() -{ - QLayoutItem* widItem=m_scrollAreaWidLayout->itemAt(0); - QWidget* wid=widItem->widget(); - FullListView* listview=qobject_cast(wid); - listview->adjustSize(); - int dividend=(m_scrollArea->width()-Style::SliderSize)/Style::AppListGridSizeWidth; - int rowcount=0; - if(listview->model()->rowCount()%dividend>0) - { - rowcount=listview->model()->rowCount()/dividend+1; - } - else - { - rowcount=listview->model()->rowCount()/dividend; - - } - - listview->setFixedSize(m_scrollArea->width()-Style::SliderSize+1,listview->gridSize().height()*rowcount); - m_scrollArea->widget()->adjustSize(); -} - -void FullSearchResultWidget::repaintWidget() -{ - this->setFixedSize(Style::MainViewWidWidth, - Style::AppListWidHeight); - m_scrollArea->setFixedSize(Style::AppListWidWidth,this->height()); - m_scrollAreaWidLayout->removeWidget(m_listView); - m_listView->setParent(nullptr); - delete m_listView; - m_listView=new FullListView(this,3); - m_scrollAreaWidLayout->insertWidget(0,m_listView); - - m_data.clear(); - m_listView->addData(m_data); - resizeScrollAreaControls(); - connect(m_listView,&FullListView::sendItemClickedSignal,this,&FullSearchResultWidget::execApplication); - connect(m_listView,&FullListView::sendHideMainWindowSignal,this,&FullSearchResultWidget::sendHideMainWindowSignal); -} - -void FullSearchResultWidget::moveScrollBar(int type) -{ - int height=Style::primaryScreenHeight; - if(type==0) - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-height*100/1080); - else - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+height*100/1080); -} - -void FullSearchResultWidget::setViewFocus() -{ - m_listView->setFocus(); -} diff --git a/src/SearchResultWidget/searchappthread.cpp b/src/SearchResultWidget/searchappthread.cpp deleted file mode 100644 index d53a5e4..0000000 --- a/src/SearchResultWidget/searchappthread.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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 -#include "src/SearchResultWidget/file-utils.h" - -SearchAppThread::SearchAppThread() -{ - m_ukuiMenuInterface=new UkuiMenuInterface; -} - -SearchAppThread::~SearchAppThread() -{ - delete m_ukuiMenuInterface; -} - -void SearchAppThread::run() -{ - m_appInfoVector.clear(); - m_appInfoVector=UkuiMenuInterface::appInfoVector; - m_searchResultVector.clear(); - if(!this->m_keyWord.isEmpty()) - { - QString str=m_ukuiMenuInterface->getAppNamePinyin(m_keyWord); - int index=0; - if(str.size()==1) - { - int num=static_cast(str.toLocal8Bit().at(0)); - QStringList searchDesktopList; - searchDesktopList.clear(); - if(num>=65 && num<=90) - { - for(int i=0;igetAppNamePinyin(m_appInfoVector.at(index).at(1)); -// QString appEnglishName=m_appInfoVector.at(index).at(2); - QString appNameFl=m_appInfoVector.at(index).at(3); - - if(appNameFl==str)//匹配首字母 - { - m_searchResultVector.append(m_appInfoVector.at(index)); - } - index++; - } - } -// else if(num<48 || (num>57 && num<65) || num>90) -// for(int i=0;igetAppName(searchDesktopList.at(i))); - } - } - else - { - while(indexgetAppNamePinyin(m_appInfoVector.at(index).at(1)); - QStringList appNameLs; - QStringList appNameFls; - QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords(m_appInfoVector.at(index).at(1)); - // QStringList appNamePyLst = Zeeker::FileUtils::findMultiToneWords("奇安信可信"); - for(int i = 0; i < appNamePyLst.size()/2; i++) - { - appNameLs.append(appNamePyLst.at(i * 2)); - appNameFls.append(appNamePyLst.at(i * 2 + 1)); - } - - QString appName = m_appInfoVector.at(index).at(1); - QString appEnglishName=m_appInfoVector.at(index).at(2); - //QString appNameFls=m_appInfoVector.at(index).at(4); - - if(m_keyWord.contains(QRegExp("[\\x4e00-\\x9fa5]+")))//中文正则表达式 - { - if(appName.toUpper().contains(m_keyWord.toUpper())) - m_searchResultVector.append(m_appInfoVector.at(index)); - } - else - { - for (int var = 0; var < appNameLs.size(); ++var) - { - if(appNameLs[var].contains(str,Qt::CaseInsensitive) || - appNameFls[var].contains(str,Qt::CaseInsensitive) || - appEnglishName.contains(str,Qt::CaseInsensitive)) - { - m_searchResultVector.append(m_appInfoVector.at(index)); - break; - } - } - } - index++; - } - } - } - - qSort(m_searchResultVector.begin(),m_searchResultVector.end(),UkuiMenuInterface::cmpApp); - Q_EMIT sendSearchResult(m_searchResultVector); -} - -void SearchAppThread::recvSearchKeyword(QString arg) -{ - this->m_keyWord.clear(); - this->m_keyWord=arg; -} diff --git a/src/SearchResultWidget/searchresultwidget.cpp b/src/SearchResultWidget/searchresultwidget.cpp deleted file mode 100644 index 10c8853..0000000 --- a/src/SearchResultWidget/searchresultwidget.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 -#include -#include "src/UtilityFunction/utility.h" - -SearchResultWidget::SearchResultWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); -} - -SearchResultWidget::~SearchResultWidget() -{ - delete m_ukuiMenuInterface; -} - -void SearchResultWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - this->setFocusPolicy(Qt::StrongFocus); - m_listView=new ListView(this,this->width()-6,this->height()-6,3); - m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_listView->show(); - - m_data.clear(); - m_listView->addData(m_data); - m_ukuiMenuInterface=new UkuiMenuInterface; - - connect(m_listView,&ListView::sendItemClickedSignal,this,&SearchResultWidget::execApplication); - connect(m_listView,&ListView::sendHideMainWindowSignal,this,&SearchResultWidget::sendHideMainWindowSignal); -} - -/** - * 执行应用程序 - */ -void SearchResultWidget::execApplication(QStringList arg) -{ - Q_EMIT sendHideMainWindowSignal(); - QString desktopfp=arg.at(0); - execApp(desktopfp); -} - -void SearchResultWidget::updateAppListView(QVector arg) -{ - m_data.clear(); - Q_FOREACH(QStringList appinfo,arg) - m_data.append(QStringList()<updateData(m_data); -} - -void SearchResultWidget::moveScrollBar(int type) -{ - if(type==0) - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()-100); - else - m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition()+100); -} - -void SearchResultWidget::repaintWidget() -{ - this->setFixedSize(Style::defaultMainViewWidWidth,Style::defaultContentWidHeight); - m_listView->setGeometry(QRect(6,0,this->width()-6,this->height()-6)); - m_listView->show(); -} - -void SearchResultWidget::setViewFocus() -{ - m_listView->setFocus(); -} diff --git a/src/SearchResultWidget/searchresultwidget.h b/src/SearchResultWidget/searchresultwidget.h deleted file mode 100644 index 2897b23..0000000 --- a/src/SearchResultWidget/searchresultwidget.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -//#include "searchappthread.h" -#include "src/UtilityFunction/listview.h" -#include "src/UtilityFunction/itemdelegate.h" - -class SearchResultWidget : public QWidget -{ - Q_OBJECT - -public: - explicit SearchResultWidget(QWidget *parent = nullptr); - ~SearchResultWidget(); - /** - * @brief Update application list - */ - void updateAppListView(QVector arg); - /** - * @brief Move the scroll bar - * @param type: Scroll way,Only the following parameters can be entered: - * 0: moving up - * 1: moving down - */ - void moveScrollBar(int type); - /** - * @brief Repaint window - */ - void repaintWidget(); - - void setViewFocus(); - -private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - ListView* m_listView=nullptr; - QVector m_data; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - -private Q_SLOTS: - /** - * @brief Open the application - * @param arg: The desktop file information that the application contains - */ - void execApplication(QStringList arg); - -Q_SIGNALS: - /** - * @brief Send a hidden main window signal to the MainViewWidget - */ - void sendHideMainWindowSignal(); -}; - -#endif // SEARCHRESULTWIDGET_H diff --git a/src/SideBarWidget/sidebarwidget.cpp b/src/SideBarWidget/sidebarwidget.cpp deleted file mode 100644 index 9177982..0000000 --- a/src/SideBarWidget/sidebarwidget.cpp +++ /dev/null @@ -1,925 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "src/Style/style.h" -#include "src/UtilityFunction/utility.h" - -SideBarWidget::SideBarWidget(QWidget *parent) : - QWidget(parent) -{ - initUi(); - m_allBtn->click(); -} - -SideBarWidget::~SideBarWidget() -{ - delete m_ukuiMenuInterface; -// delete m_shutDownMenu; -// delete m_otherMenu; -} - -/** - * 侧边栏初始化 - */ -void SideBarWidget::initUi() -{ - this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); - this->setFocusPolicy(Qt::NoFocus); - - addSidebarBtn(); - loadMinSidebar(); - m_minMaxBtn->installEventFilter(this); - m_allBtn->installEventFilter(this); - m_letterBtn->installEventFilter(this); - m_functionBtn->installEventFilter(this); - m_userIconBtn->installEventFilter(this); - m_computerBtn->installEventFilter(this); - m_personalBtn->installEventFilter(this); - m_controlBtn->installEventFilter(this); - m_trashBtn->installEventFilter(this); - m_shutDownBtn->installEventFilter(this); - m_ukuiMenuInterface=new UkuiMenuInterface; - // m_shutDownMenu=new RightClickMenu; - // m_otherMenu=new RightClickMenu; -} - -bool SideBarWidget::eventFilter(QObject * target , QEvent * event ) -{ - - if( event->type() == QEvent::KeyPress ) - { - QKeyEvent *ke = (QKeyEvent *)event; - if( ke->key() == Qt::Key_Tab ) - { - Q_EMIT setFocusToMainWin(); - // return true; - } - if(ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Left) - { - if(m_minMaxBtn->hasFocus()) - { - m_shutDownBtn->setFocus(); - return true; - } - } - if(ke->key() == Qt::Key_Down || ke->key() == Qt::Key_Right) - { - if(m_shutDownBtn->hasFocus()) - { - this->setFocus(); - } - } - } - return QWidget::eventFilter(target , event); -} - - - -/** - * 侧边栏添加控件 - */ -void SideBarWidget::addSidebarBtn() -{ - m_mainWidget=new QWidget; - m_mainWidget->setParent(this); - m_mainWidgetLayout=new QVBoxLayout; - m_mainWidgetLayout->setContentsMargins(0,0,0,6); - m_mainWidgetLayout->setSpacing(10); - m_mainWidget->setLayout(m_mainWidgetLayout); - // m_mainWidget->setFocusPolicy(Qt::StrongFocus); -// m_mainWidget->setAutoFillBackground(true); -// QPalette palette; -// palette.setBrush(QPalette::Background,Qt::red); -// m_mainWidget->setPalette(palette); - //放大缩小按钮界面 - m_minMaxWidget=new QWidget; - m_minMaxLayout=new QHBoxLayout; - m_minMaxBtn=new QPushButton; - m_minMaxBtn->setFlat(true); - m_minMaxBtn->setProperty("useButtonPalette", true); -// m_minMaxBtn->setProperty("doNotAnimate",true); -// m_minMaxBtn->setProperty("useButtonPalette", true); -// m_minMaxBtn->setFlat(true); -// m_minMaxBtn->setProperty("doNotAnimate",true); -// m_minMaxBtn->setShortcut(QKeySequence::InsertParagraphSeparator); - -// m_minMaxBtn->setShortcut(Qt::Key_Enter); -// m_minMaxBtn->setShortcut(Qt::Key_Return); -// QShortcut *key_1 = new QShortcut(QKeySequence(Qt::Key_Enter),this); -// connect(key_1,&QShortcut::activated,m_minMaxBtn,&QPushButton::click); -// QShortcut *key_2 = new QShortcut(QKeySequence(Qt::Key_Return),this); -// connect(key_2,&QShortcut::activated,m_minMaxBtn,&QPushButton::click); - m_minMaxLayout->addWidget(m_minMaxBtn); - m_minMaxWidget->setLayout(m_minMaxLayout); -// m_minMaxWidget->setAttribute(Qt::WA_StyledBackground,true); -// m_minMaxWidget->hasFocus(); - - //分类按钮 - m_buttonList.clear(); - m_allBtn=new QPushButton; - initBtn(m_allBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/commonuse.svg"),tr("All"),0); - m_letterBtn=new QPushButton; - initBtn(m_letterBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/letter.svg"),tr("Letter"),1); - m_functionBtn=new QPushButton; - initBtn(m_functionBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/function.svg"),tr("Function"),2); - int id=0; - Q_FOREACH (QAbstractButton* btn, m_buttonList) { - // m_btnGroup->addButton(btn,id++); - btn->setCheckable(true); - } - - QString usericon=getUserIcon(); - QString username=getUserName(); - m_userIconBtn=new QPushButton; - initBtn(m_userIconBtn,usericon,username,3); - m_personalBtn=new QPushButton; - initBtn(m_personalBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/personal.svg"),tr("Personal"),4); - m_trashBtn=new QPushButton; - initBtn(m_trashBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/trash.svg"),tr("Trash"),5); - m_computerBtn=new QPushButton; - initBtn(m_computerBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/computer.svg"),tr("Computer"),6); - m_controlBtn=new QPushButton; - initBtn(m_controlBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/control.svg"),tr("Settings"),7); - m_shutDownBtn=new QPushButton; - initBtn(m_shutDownBtn,QString::fromLocal8Bit(":/data/img/sidebarwidget/shutdown.svg"),tr("Power"),8); - connect(m_allBtn, &QPushButton::clicked, this, &SideBarWidget::btnAllClickedSlot); - connect(m_letterBtn ,&QPushButton::clicked, this, &SideBarWidget::btnLetterClickedSlot); - connect(m_functionBtn, &QPushButton::clicked, this, &SideBarWidget::btnFuncClickedSlot); - connect(m_computerBtn,&QPushButton::clicked,this,&SideBarWidget::computerBtnClickedSlot); - connect(m_personalBtn,&QPushButton::clicked,this,&SideBarWidget::personalBtnClickedSlot); - connect(m_controlBtn,&QPushButton::clicked,this,&SideBarWidget::controlBtnClickedSlot); - connect(m_trashBtn,&QPushButton::clicked,this,&SideBarWidget::trashBtnClickedSlot); - connect(m_shutDownBtn,&QPushButton::clicked,this,&SideBarWidget::shutdownBtnClickedSlot); - connect(m_userIconBtn,&QPushButton::clicked,this,&SideBarWidget::userIconBtnClickedSlot); - - Q_FOREACH(QAbstractButton* button,m_buttonList) - { - QPushButton* btn=qobject_cast(button); - if(m_buttonList.indexOf(button)>3 && m_buttonList.indexOf(button)setCheckable(false); - addRightClickMenu(btn); - } - } - m_shutDownBtn->setContextMenuPolicy(Qt::CustomContextMenu); - connect(m_shutDownBtn,&QPushButton::customContextMenuRequested,this, - &SideBarWidget::shutdownBtnRightClickSlot); - - //监控用户账户信息更改 - qint64 uid=static_cast(getuid()); - QDBusInterface iface("org.freedesktop.Accounts", - "/org/freedesktop/Accounts", - "org.freedesktop.Accounts", - QDBusConnection::systemBus()); - QDBusReplyobjPath=iface.call("FindUserById",uid); - QDBusConnection::systemBus().connect("org.freedesktop.Accounts", - objPath.value().path(), - "org.freedesktop.Accounts.User", - QString("Changed"),this,SLOT(userAccountsChanged())); - - m_mainWidgetLayout->addWidget(m_minMaxWidget); - m_mainWidgetLayout->addWidget(m_buttonList.at(0)); - m_mainWidgetLayout->addWidget(m_buttonList.at(1)); - m_mainWidgetLayout->addWidget(m_buttonList.at(2)); - m_verticalSpacer = new QSpacerItem(20,40, QSizePolicy::Fixed, QSizePolicy::Expanding); - m_mainWidgetLayout->addItem(m_verticalSpacer); - m_mainWidgetLayout->addWidget(m_buttonList.at(3)); - if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) - { - m_gsetting=new QGSettings(QString("org.ukui.control-center.desktop").toLocal8Bit()); - if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(4)); - if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(5)); - if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(6)); - if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(7)); - connect(m_gsetting,&QGSettings::changed, - this,&SideBarWidget::resetSidebarBtnSlot); - } - m_mainWidgetLayout->addWidget(m_buttonList.at(8)); - - if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); - connect(gsetting,&QGSettings::changed,this,&SideBarWidget::themeModeChangeSlot); - } - - m_animation = new QPropertyAnimation(m_mainWidget, "geometry"); -} - -void SideBarWidget::resetSidebarBtnSlot() -{ - QLayoutItem *child; - while ((child = m_mainWidgetLayout->takeAt(6)) != 0) { - QWidget* wid=child->widget(); - m_mainWidgetLayout->removeWidget(wid); - wid->setParent(nullptr); - delete child; - } - - if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.desktop").toLocal8Bit())) - { - if(m_gsetting->keys().contains(QString("personalIconLocking")) && m_gsetting->get("personal-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(4)); - if(m_gsetting->keys().contains(QString("trashIconLocking")) && m_gsetting->get("trash-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(5)); - if(m_gsetting->keys().contains(QString("computerIconLocking")) && m_gsetting->get("computer-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(6)); - if(m_gsetting->keys().contains(QString("settingsIconLocking")) && m_gsetting->get("settings-icon-locking").toBool()) - m_mainWidgetLayout->addWidget(m_buttonList.at(7)); - } - m_mainWidgetLayout->addWidget(m_buttonList.at(8)); -} - -/** - * 设置按钮样式 - */ -void SideBarWidget::initBtn(QPushButton *btn, QString btnicon, QString text, int num) -{ - btn->setFlat(true); - btn->setProperty("useButtonPalette",true); - QHBoxLayout* btnLayout=new QHBoxLayout; - QLabel* labelicon=new QLabel; - labelicon->setAlignment(Qt::AlignCenter); - const auto ratio=devicePixelRatioF(); - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(num!=3) - { - QPixmap pixmap=loadSvg(btnicon,Style::SideBarIconSize*ratio); - if(gsetting.get("style-name").toString()=="ukui-light")//反黑 - pixmap=drawSymbolicBlackColoredPixmap(pixmap); - else - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - labelicon->setFixedSize(Style::SideBarIconSize,Style::SideBarIconSize); - labelicon->setPixmap(pixmap); - } - else { - if(!QFile::exists(btnicon)) - btnicon=QString("/usr/share/ukui/faces/default.png"); - labelicon->setObjectName("faceLabel"); - labelicon->setFocusPolicy(Qt::NoFocus); - labelicon->setAlignment(Qt::AlignCenter); - labelicon->setFixedSize(Style::SideBarIconSize+4,Style::SideBarIconSize+4); - - QPixmap facePixmap(btnicon); - facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); - facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2); - facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - labelicon->setPixmap(facePixmap); - } - - btnLayout->setSpacing(0); - btnLayout->addWidget(labelicon); -// btnLayout->addStretch(); - - QLabel* textLabel=new QLabel; - if(num==3) - textLabel->setObjectName("nameLabel"); - textLabel->setText(text); - btnLayout->addWidget(textLabel); - btnLayout->addStretch(); - - btn->setLayout(btnLayout); - btn->setFocusPolicy(Qt::StrongFocus); - - m_buttonList.append(btn); - m_textList.append(text); - - m_labelList.append(textLabel); -} - -QPixmap SideBarWidget::PixmapToRound(const QPixmap &src, int radius) -{ - if (src.isNull()) { - return QPixmap(); - } - - QPixmap pixmapa(src); - QPixmap pixmap(radius*2,radius*2); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - QPainterPath path; - path.addEllipse(0, 0, radius*2, radius*2); - painter.setClipPath(path); - painter.drawPixmap(0, 0, radius*2, radius*2, pixmapa); - return pixmap; -} - - -/** - * 加载关机按钮右键菜单 - */ -void SideBarWidget::shutdownBtnRightClickSlot(const QPoint &pos) -{ - - RightClickMenu m_otherMenu(this); - connect(&m_otherMenu, &RightClickMenu::sendMainWinActiveSignal, this, &SideBarWidget::sendShowMainWindowSignal); - Q_EMIT sendShowMainWindowSignal(false); - int ret = m_otherMenu.showShutdownMenu(m_shutDownBtn->mapToGlobal(pos)); - qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; - if(ret>=10 && ret<=17) - { - Q_EMIT sendHideMainWindowSignal(); - switch (ret) { - case 10: - QProcess::startDetached(QString("ukui-screensaver-command -l")); - break; - case 11: - QProcess::startDetached(QString("ukui-session-tools --switchuser")); - break; - case 12: - QProcess::startDetached(QString("ukui-session-tools --logout")); - break; - case 13: - QProcess::startDetached(QString("ukui-session-tools --reboot")); - break; - case 14: - QProcess::startDetached(QString("ukui-session-tools --shutdown")); - break; - case 16: - QProcess::startDetached(QString("ukui-session-tools --suspend")); - break; - case 17: - QProcess::startDetached(QString("ukui-session-tools --sleep")); - break; - default: - break; - } - - } - qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 结束"; -} - -void SideBarWidget::addRightClickMenu(QPushButton *btn) -{ - btn->setContextMenuPolicy(Qt::CustomContextMenu); - connect(btn,&QPushButton::customContextMenuRequested,this,&SideBarWidget::otherBtnRightClickSlot); -} - -void SideBarWidget::otherBtnRightClickSlot(const QPoint &pos) -{ - qDebug() << "SideBarWidget::otherBtnRightClickSlot() 开始"; - QPushButton* btn=dynamic_cast(QObject::sender()); - int index=m_buttonList.indexOf(btn); - QString desktopfp; - switch (index) { - case 4: - desktopfp=QString("/usr/share/applications/peony-home.desktop"); - break; - case 5: - desktopfp=QString("/usr/share/applications/peony-trash.desktop"); - break; - case 6: - desktopfp=QString("/usr/share/applications/peony-computer.desktop"); - break; - case 7: - desktopfp=QString("/usr/share/applications/ukui-control-center.desktop"); - break; - default: - break; - } - RightClickMenu m_otherMenu; - connect(&m_otherMenu, &RightClickMenu::sendMainWinActiveSignal, this, &SideBarWidget::sendShowMainWindowSignal); - int ret = m_otherMenu.showOtherMenu(btn->mapToGlobal(pos), desktopfp); - Q_EMIT sendShowMainWindowSignal(false); - if(ret==15) - { - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-control-center -d")); - } - qDebug() << "SideBarWidget::otherBtnRightClickSlot() 结束"; -} - -void SideBarWidget::computerBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("/usr/bin/peony computer:///")); -} - -void SideBarWidget::personalBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("/usr/bin/peony")); -} - -void SideBarWidget::controlBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - execApp("/usr/share/applications/ukui-control-center.desktop"); - -} - -void SideBarWidget::trashBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("/usr/bin/peony trash:///")); -} - -void SideBarWidget::shutdownBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-session-tools")); -} - -void SideBarWidget::userIconBtnClickedSlot() -{ - Q_EMIT sendHideMainWindowSignal(); - QProcess::startDetached(QString("ukui-control-center -u")); -} - -void SideBarWidget::userAccountsChanged() -{ - const auto ratio=devicePixelRatioF(); - QString usericon=getUserIcon(); - if(!QFile::exists(usericon)) - usericon=QString("/usr/share/ukui/faces/default.png"); - QPixmap facePixmap(usericon); - facePixmap = facePixmap.scaled((Style::SideBarIconSize+4)*ratio,(Style::SideBarIconSize+4)*ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); - facePixmap = PixmapToRound(facePixmap, (Style::SideBarIconSize+4)*ratio/2); - - QLabel* labelicon=m_userIconBtn->findChild("faceLabel"); - facePixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - labelicon->setPixmap(facePixmap); - QLabel* labelname=m_userIconBtn->findChild("nameLabel"); - QString userName = fontMetrics().elidedText(getUserName(),Qt::ElideRight,labelname->width()-10,Qt::TextShowMnemonic); - labelname->setText(userName);//更新用户名 - m_textList.replace(3,getUserName());//更新用户名 -} - -/** - * 加载默认侧边栏 - */ -void SideBarWidget::loadMinSidebar() -{ - m_isFullScreen=false; - setMaxBtn(); - - m_animation->stop(); - this->setFixedSize(Style::defaultSideBarWidWidth,Style::minh); - m_mainWidget->setGeometry(QRect(0,0,this->width(),this->height())); - m_mainWidget->show(); - m_minMaxWidget->setFixedSize(37,70); - m_minMaxLayout->setContentsMargins(0,0,0,0); - - m_mainWidgetLayout->setContentsMargins(8,0,10,6); - - Q_FOREACH(QAbstractButton* button,m_buttonList) - { - QPushButton* btn=qobject_cast(button); - setMinSidebarBtn(btn); - btn->setToolTip(m_textList.at(m_buttonList.indexOf(button))); - } - - - changeIconColor(false); - - disconnect(m_minMaxBtn,&QToolButton::clicked,this, &SideBarWidget::sendDefaultBtnSignal); - connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); -} - -/** - * 设置全屏按钮 - */ -void SideBarWidget::setMaxBtn() -{ - const auto ratio=devicePixelRatioF(); - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/max.svg"),14*ratio); - if(gsetting.get("style-name").toString()=="ukui-light")//反黑 - pixmap=drawSymbolicBlackColoredPixmap(pixmap); - else - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - - m_minMaxBtn->setFixedSize(37,37); - m_minMaxBtn->setIcon(QIcon(pixmap)); - m_minMaxBtn->setToolTip(tr("Max")); - -// m_minMaxBtn->setFocus(); -} - -/** - * 设置默认侧边栏按钮 - */ -void SideBarWidget::setMinSidebarBtn(QPushButton* btn) -{ - btn->setFixedSize(37,37); - if(m_buttonList.indexOf(btn)==3) - btn->layout()->setContentsMargins(7,0,17,0); - else - btn->layout()->setContentsMargins(9,0,17,0); - btn->layout()->setSpacing(0); - - m_labelList.at(m_buttonList.indexOf(btn))->setVisible(false); - - //移除按钮文本 -// QLayoutItem *child; -// if((child = btn->layout()->takeAt(1)) != nullptr) { -// QWidget* childwid=child->widget(); -// if(childwid!=nullptr) -// { -// btn->layout()->removeWidget(childwid); -// childwid->setParent(nullptr); -// delete childwid; -// delete child; -// } -// } -} - -/** - * 加载全屏侧边栏 - */ -void SideBarWidget::loadMaxSidebar() -{ - m_isFullScreen=true; - setMinBtn(); - - this->setFixedSize(Style::SideBarWidWidth,Style::heightavailable); - - m_minMaxWidget->setFixedSize(Style::MinMaxWidWidth,Style::MinMaxWidHeight); - m_minMaxLayout->setContentsMargins(m_minMaxWidget->width()-m_minMaxBtn->width(),0,0,0); - - m_mainWidgetLayout->setContentsMargins(0,0,0,6); - - Q_FOREACH(QAbstractButton* button,m_buttonList) - { - QPushButton* btn=qobject_cast(button); - setMaxSidebarBtn(btn); - } - - Q_FOREACH(QAbstractButton* button,m_buttonList) - { - QPushButton* btn=qobject_cast(button); - btn->setFixedSize(m_btnWidth,Style::SideBarBtnHeight); - } - - changeIconColor(true); - - disconnect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendFullScreenBtnSignal); - connect(m_minMaxBtn, &QToolButton::clicked,this,&SideBarWidget::sendDefaultBtnSignal); -} - -/** - * 设置还原按钮 - */ -void SideBarWidget::setMinBtn() -{ - const auto ratio=devicePixelRatioF(); - QPixmap pixmap=loadSvg(QString(":/data/img/sidebarwidget/min.svg"),14*ratio); - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - - m_minMaxBtn->setFixedSize(Style::MinMaxBtnWidth,Style::MinMaxBtnWidth); - m_minMaxBtn->setIcon(QIcon(pixmap)); - m_minMaxBtn->setToolTip(""); - -// m_minMaxBtn->setFocus(); -} - -/** - * 设置全屏侧边栏按钮 - */ -void SideBarWidget::setMaxSidebarBtn(QPushButton *btn) -{ - QHBoxLayout* layout=qobject_cast(btn->layout()); - if(m_buttonList.indexOf(btn)==3) - { - layout->setContentsMargins(13,0,0,0); - layout->setSpacing(8); - } - else - { - layout->setContentsMargins(15,0,0,0); - layout->setSpacing(10); - } - - QLabel* labeltext=m_labelList.at(m_buttonList.indexOf(btn)); - labeltext->setVisible(true); - - //修复修改字体大小时获取文本Label大小无效 - //移除按钮文本 -// QLayoutItem *child; -// if((child = btn->layout()->takeAt(1)) != nullptr) { -// QWidget* childwid=child->widget(); -// if(childwid!=nullptr) -// { -// btn->layout()->removeWidget(childwid); -// childwid->setParent(nullptr); -// delete childwid; -// delete child; -// } -// } - //添加文本 -// QLabel* labeltext=new QLabel; - if(m_buttonList.indexOf(btn)<=2) - { - labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - labeltext->setText(m_textList.at(m_buttonList.indexOf(btn))); - labeltext->adjustSize(); - m_btnWidth=44+labeltext->width()+10; - btn->setToolTip(""); - } - else - { - QFont ft; - QFontMetrics fm(ft); - QString text = fm.elidedText(m_textList.at(m_buttonList.indexOf(btn)), Qt::ElideRight, m_btnWidth-44); - labeltext->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - labeltext->setText(text); - labeltext->setFixedSize(m_btnWidth-44,Style::SideBarBtnHeight); - labeltext->adjustSize(); - if(fm.boundingRect(m_textList.at(m_buttonList.indexOf(btn))).width()>labeltext->width()) - btn->setToolTip(m_textList.at(m_buttonList.indexOf(btn))); - else - btn->setToolTip(""); - } - QPalette pe = labeltext->palette(); - pe.setColor(QPalette::ButtonText,QColor(Qt::white)); - labeltext->setPalette(pe); -// btn->layout()->addWidget(labeltext); -} - -void SideBarWidget::btnAllClickedSlot() -{ - m_allBtn->setChecked(true); - m_letterBtn->setChecked(false); - m_functionBtn->setChecked(false); - if(m_isFullScreen) - { - Q_EMIT sendFullScreenCommonUseBtnSignal(); - Q_EMIT setSlideBar(0); - } - else - { - Q_EMIT sendCommonUseBtnSignal(); - } -} - -void SideBarWidget::btnLetterClickedSlot() -{ - m_allBtn->setChecked(false); - m_letterBtn->setChecked(true); - m_functionBtn->setChecked(false); - if(m_isFullScreen) - { - Q_EMIT sendFullScreenLetterBtnSignal(); - } - else - { - Q_EMIT sendLetterBtnSignal(); - } -} - -void SideBarWidget::btnFuncClickedSlot() -{ - m_allBtn->setChecked(false); - m_letterBtn->setChecked(false); - m_functionBtn->setChecked(true); - - if(m_isFullScreen) - { - Q_EMIT sendFullScreenFunctionBtnSignal(); - } - else - { - Q_EMIT sendFunctionBtnSignal(); - } -} - -void SideBarWidget::themeModeChangeSlot(QString styleName) -{ - if(styleName=="styleName") - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); - Q_FOREACH(QAbstractButton *button,m_buttonList) - { - QPushButton *btn=qobject_cast(button); - QLayoutItem *item=btn->layout()->itemAt(0); - QLabel *label=qobject_cast(item->widget()); - QString iconStr; - switch (m_buttonList.indexOf(button)) { - case 0: - iconStr=QString(":/data/img/sidebarwidget/commonuse.svg"); - break; - case 1: - iconStr=QString(":/data/img/sidebarwidget/letter.svg"); - break; - case 2: - iconStr=QString(":/data/img/sidebarwidget/function.svg"); - break; - case 3: - userAccountsChanged(); - break; - case 4: - iconStr=QString(":/data/img/sidebarwidget/personal.svg"); - break; - case 5: - iconStr=QString(":/data/img/sidebarwidget/trash.svg"); - break; - case 6: - iconStr=QString(":/data/img/sidebarwidget/computer.svg"); - break; - case 7: - iconStr=QString(":/data/img/sidebarwidget/setting.svg"); - break; - case 8: - iconStr=QString(":/data/img/sidebarwidget/shutdown.svg"); - break; - default: - break; - } - if(m_buttonList.indexOf(button)!=3) - { - const auto ratio=devicePixelRatioF(); - QPixmap pixmap=loadSvg(iconStr,19*ratio); - if(gsetting->get("style-name").toString()=="ukui-light")//反黑 - pixmap=drawSymbolicBlackColoredPixmap(pixmap); - else - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - label->setPixmap(pixmap); - } - } - } -} - -void SideBarWidget::changeIconColor(bool isFullScreen) -{ - QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); - Q_FOREACH(QAbstractButton *button,m_buttonList) - { - QPushButton *btn=qobject_cast(button); - QLayoutItem *item=btn->layout()->itemAt(0); - QLabel *label=qobject_cast(item->widget()); - QString iconStr; - switch (m_buttonList.indexOf(button)) { - case 0: - iconStr=QString(":/data/img/sidebarwidget/commonuse.svg"); - break; - case 1: - iconStr=QString(":/data/img/sidebarwidget/letter.svg"); - break; - case 2: - iconStr=QString(":/data/img/sidebarwidget/function.svg"); - break; - case 3: - userAccountsChanged(); - break; - case 4: - iconStr=QString(":/data/img/sidebarwidget/personal.svg"); - break; - case 5: - iconStr=QString(":/data/img/sidebarwidget/trash.svg"); - break; - case 6: - iconStr=QString(":/data/img/sidebarwidget/computer.svg"); - break; - case 7: - iconStr=QString(":/data/img/sidebarwidget/setting.svg"); - break; - case 8: - iconStr=QString(":/data/img/sidebarwidget/shutdown.svg"); - break; - default: - break; - } - if(m_buttonList.indexOf(button)!=3) - { - const auto ratio=devicePixelRatioF(); - QPixmap pixmap=loadSvg(iconStr,19*ratio); - if(gsetting->get("style-name").toString()=="ukui-light" && !isFullScreen)//反黑 - pixmap=drawSymbolicBlackColoredPixmap(pixmap); - else - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - label->setPixmap(pixmap); - } - } -} - -void SideBarWidget::enterAnimation() -{ - m_animation->stop(); - m_animation->setDuration(200);//动画总时间 - m_animation->setStartValue(QRect(this->width(),0, - 0,this->height())); - m_animation->setEndValue(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0, - m_btnWidth,this->height())); - m_animation->setEasingCurve(QEasingCurve::InQuart); - m_animation->start(); - m_mainWidget->show(); -} - -void SideBarWidget::setSideBarBtnGeometry() -{ - m_mainWidget->setGeometry(QRect(this->width()-m_btnWidth-Style::SideBarMargin,0, - m_btnWidth,this->height())); - m_mainWidget->show(); -} - -//void SideBarWidget::mousePressEvent(QMouseEvent *event) -//{ -// if(m_isFullScreen && event->button()==Qt::LeftButton) -// { -// int x=event->x(); -// int y=event->y(); -// QRect rect_1(0,0,this->width()-Style::SideBarBtnWidth-Style::SideBarMargin,this->height()); -// QRect rect_2(this->width()-Style::SideBarBtnWidth-Style::SideBarMargin,0,Style::MinMaxWidWidth,Style::MinMaxWidHeight); -// QRect rect_3(rect_1.width()+m_functionBtn->x(),m_functionBtn->y()+m_functionBtn->height(),Style::SideBarBtnWidth,m_otherButtonList.at(0)->y()-m_functionBtn->y()-m_functionBtn->height()); -// syslog(LOG_LOCAL0 | LOG_DEBUG ,"坐标:%d:%d:%d",x,rect_1.x(),rect_3.x()); -// if((x>=rect_1.x() && x<=rect_1.x()+rect_1.width() && y>=rect_1.y() && y<=rect_1.y()+rect_1.height()) || -// (x>=rect_2.x() && x<=rect_2.x()+rect_2.width() && y>=rect_2.y() && y<=rect_2.y()+rect_2.height()) || -// (x>=rect_3.x() && x<=rect_3.x()+rect_3.width() && y>=rect_3.y() && y<=rect_3.y()+rect_3.height())) -// this->parentWidget()->parentWidget()->hide(); -// } -//} - -void SideBarWidget::keyPressEvent(QKeyEvent* e) -{ - if(e->type()==QEvent::KeyPress) - { - switch(e->key()) - { - case Qt::Key_Enter: - case Qt::Key_Return: - { - if(m_allBtn->hasFocus()) - { - m_allBtn->click(); - } - else if(m_letterBtn->hasFocus()) - { - m_letterBtn->click(); - } - else if(m_functionBtn->hasFocus()) - { - m_functionBtn->click(); - } - else - { - QWidget *current_focus_widget; - current_focus_widget = QWidget::focusWidget(); - QPushButton *le= qobject_cast(current_focus_widget); - le->clicked(); - } - } - break; - case Qt::Key_Down: - qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Down"; - // focusNextChild(); -// if(m_buttonList.at(2)->hasFocus()) -// { -// m_buttonList.at(3)->setFocus(); -// } -// if(m_shutDownBtn->hasFocus()) -// { -// m_minMaxBtn->setFocus(); -// } - - break; - case Qt::Key_Up: - qDebug() << "SideBarWidget::keyPressEvent(QKeyEvent* e) key_Up"; - // /* focusPreviousChild(); -// if(m_buttonList.at(0)->hasFocus()) -// { -// m_minMaxBtn->setFocus(); -// } - break; - default: - return QWidget::keyPressEvent(e); - break; - } - } -} - -void SideBarWidget::setFocusToThis() -{ - this->setFocus(); -} diff --git a/src/SideBarWidget/sidebarwidget.h b/src/SideBarWidget/sidebarwidget.h deleted file mode 100644 index 2dffe52..0000000 --- a/src/SideBarWidget/sidebarwidget.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include "src/Interface/ukuimenuinterface.h" -#include -#include -#include -#include -#include "src/Style/style.h" -#include "src/RightClickMenu/rightclickmenu.h" - -class SideBarWidget : public QWidget -{ - Q_OBJECT - -public: - explicit SideBarWidget(QWidget *parent = nullptr); - ~SideBarWidget(); - /** - * @brief Load the default sidebar - */ - void loadMinSidebar(); - /** - * @brief Load the full-screen sidebar - */ - void loadMaxSidebar(); - /** - * @brief Sidebar animation - */ - void enterAnimation(); - /** - * @brief Adjust the position of the sidebar buttons - */ - void setSideBarBtnGeometry(); - -private: - UkuiMenuInterface *m_ukuiMenuInterface=nullptr; - - QWidget *m_mainWidget=nullptr; - QVBoxLayout *m_mainWidgetLayout=nullptr; - - QWidget *m_minMaxWidget=nullptr; - QHBoxLayout *m_minMaxLayout=nullptr; - QPushButton *m_minMaxBtn=nullptr; - - QList m_buttonList; - QList m_labelList; - QStringList m_textList; - QPushButton *m_allBtn=nullptr; - QPushButton *m_letterBtn=nullptr; - QPushButton *m_functionBtn=nullptr; - - QPushButton *m_userIconBtn=nullptr; - QPushButton *m_computerBtn=nullptr; - QPushButton *m_personalBtn=nullptr; - QPushButton *m_controlBtn=nullptr; - QPushButton *m_trashBtn=nullptr; - QPushButton *m_shutDownBtn=nullptr; - QSpacerItem *m_verticalSpacer=nullptr; - bool m_isFullScreen=false; - QGSettings *m_gsetting=nullptr; - // RightClickMenu *m_shutDownMenu=nullptr; - // RightClickMenu *m_otherMenu=nullptr; - QPropertyAnimation* m_animation=nullptr; - - int m_btnWidth, m_btnheight; - -protected: - /** - * @brief Initializes UI - */ - void initUi(); - /** - * @brief Add a sidebar button - */ - void addSidebarBtn(); - /** - * @brief Set button style - * @param btn: QPushButton - * @param btnicon: Button icon - * @param label: QLabel - * @param text: Button text - * @param num: Button Number - */ - void initBtn(QPushButton *btn, QString btnicon,QString text,int num); - /** - * @brief Set the default sidebar button - * @param btn: QPushButton - */ - void setMinSidebarBtn(QPushButton *btn); - /** - * @brief Set the full-screen sidebar button - * @param btn: QPushButton - */ - void setMaxSidebarBtn(QPushButton *btn); - /** - * @brief Add right-click menu - * @param btn: QPushButton - */ - void addRightClickMenu(QPushButton* btn); - /** - * @brief Set the minimize button - */ - void setMinBtn(); - /** - * @brief Set the maximize button - */ - void setMaxBtn(); - QPixmap PixmapToRound(const QPixmap &src, int radius); - void changeIconColor(bool isFullScreen); -// void mousePressEvent(QMouseEvent* event); - void keyPressEvent(QKeyEvent* e); - - bool eventFilter(QObject * target , QEvent * event ); - -private Q_SLOTS: - /** - * @brief btnAllClickedSlot - */ - void btnAllClickedSlot(); - /** - * @brief btnLetterClickedSlot - */ - void btnLetterClickedSlot(); - /** - * @brief btnFuncClickedSlot - */ - void btnFuncClickedSlot(); - /** - * @brief Load power button right-click menu - */ - void shutdownBtnRightClickSlot(const QPoint &pos); - /** - * @brief Load other application right-click menu - */ - void otherBtnRightClickSlot(const QPoint &pos); - /** - * @brief Respond to computer btn - */ - void computerBtnClickedSlot(); - /** - * @brief Respond to personal btn - */ - void personalBtnClickedSlot(); - /** - * @brief Respond to control btn - */ - void controlBtnClickedSlot(); - /** - * @brief Respond to trash btn - */ - void trashBtnClickedSlot(); - /** - * @brief Respond to power btn - */ - void shutdownBtnClickedSlot(); - /** - * @brief Respond to user icon btn - */ - void userIconBtnClickedSlot(); - /** - * @brief Monitor user account changes - */ - void userAccountsChanged(); - /** - * @brief Reset the sidebar button - */ - void resetSidebarBtnSlot(); - void themeModeChangeSlot(QString styleName); - -public Q_SLOTS: - - void setFocusToThis(); - -Q_SIGNALS: - /** - * @brief Send all category button signal - */ - void sendCommonUseBtnSignal(); - /** - * @brief Send the letter classification button signal - */ - void sendLetterBtnSignal(); - /** - * @brief Send function classification button signal - */ - void sendFunctionBtnSignal(); - /** - * @brief Send all category button signal of full screen - */ - void sendFullScreenCommonUseBtnSignal(); - /** - * @brief Send the letter classification button of full screen - */ - void sendFullScreenLetterBtnSignal(); - /** - * @brief Send function classification button signal of full screen - */ - void sendFullScreenFunctionBtnSignal(); - /** - * @brief Send a full-screen button click signal - */ - void sendFullScreenBtnSignal(); - /** - * @brief Send the default button click signal - */ - void sendDefaultBtnSignal();//发送默认(还原)按钮点击信号 - /** - * @brief Send a hidden main window signal to the MainWindow - */ - void sendHideMainWindowSignal(); - - void sendShowMainWindowSignal(bool flag); - - void setFocusToMainWin(); - - void setSlideBar(int value); -}; - -#endif // SIDEBARWIDGET_H diff --git a/src/Style/style.cpp b/src/Style/style.cpp deleted file mode 100644 index 31dd831..0000000 --- a/src/Style/style.cpp +++ /dev/null @@ -1,555 +0,0 @@ -/* - * 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 - -Style::Style() -{ - -} - -int Style::primaryScreenX=0; -int Style::primaryScreenY=0; -int Style::primaryScreenWidth=0; -int Style::primaryScreenHeight=0; -int Style::panelPosition=0; -int Style::panelSize=0; -//默认窗口 -int Style::minw=0; -int Style::minh=0; -int Style::defaultMainViewWidWidth=0; -int Style::defaultTopWidHeight=0; -int Style::defaultQueryLineEditWidth=0; -int Style::defaultQueryLineEditHeight=0; -int Style::defaultQueryLineEditIconSize=0; -int Style::defaultContentWidHeight=0; -int Style::defaultSideBarWidWidth=0; -/** - * 全屏窗口 - */ -//主窗口 -int Style::widthavailable=0; -int Style::heightavailable=0; -//主视图 -int Style::MainViewWidWidth=0; -//搜索栏 -int Style::TopWidgetHeight=0; -int Style::QueryLineEditWidth=0; -int Style::QueryLineEditHeight=0; -int Style::QueryLineEditFontSize=0; -int Style::QueryLineEditIconSize=0; -//左侧栏 -int Style::LeftWidWidth=0; -int Style::LeftWidHeight=0; -int Style::LeftMargin=0; -int Style::RightMargin=0; -int Style::LeftBtnWidth=0; -int Style::LeftBtnHeight=0; -int Style::LeftLetterBtnHeight=0; -int Style::LeftFontSize=0; -int Style::LeftLetterFontSize=0; -int Style::LeftIconSize=0; -int Style::LeftSpaceIconLeft=0; -int Style::LeftSpaceIconText=0; -int Style::LeftSpaceBetweenItem=0; -//应用列表栏 -int Style::AppListWidWidth=0; -int Style::AppListWidHeight=0; -int Style::AppListFontSize=0; -int Style::AppListIconSize=0; -int Style::AppListItemSizeWidth=0; -int Style::AppListGridSizeWidth=0; -int Style::AppLeftSpace=0; -int Style::AppTopSpace=0; -int Style::AppSpaceBetweenIconText=0; -int Style::AppBottomSpace=0; -int Style::SliderSize=0; - -//侧边栏primaryScreen -int Style::SideBarWidWidth=0; -int Style::SideBarMargin=0; -int Style::MinMaxWidWidth=0; -int Style::MinMaxWidHeight=0; -int Style::MinMaxBtnWidth=0; -int Style::MinMaxIconSize=0; -int Style::SideBarBtnWidth=0; -int Style::SideBarBtnHeight=0; -int Style::SideBarFontSize=0; -int Style::SideBarIconSize=0; -int Style::SideBarSpaceIconLeft=0; -int Style::SideBarSpaceIconText=0; -int Style::SideBarSpaceBetweenItem=0; - - -void Style::initWidStyle() -{ - getScreenAvailableGeometry(); - - int fontSize = 10; - if (QGSettings::isSchemaInstalled(QString("org.mate.interface").toLocal8Bit())) { - QGSettings *setting = new QGSettings(QString("org.mate.interface").toLocal8Bit()); - if (setting->keys().contains(QString("font-name"))) { - QString value = setting->get("font-name").toString(); - QStringList valstr = value.split(" "); - fontSize = valstr.at(valstr.count() - 1).toInt(); - } - } - int len = 0; - QString locale = QLocale::system().name(); - - if (locale == "zh_CN") { - len = 0; - } else { - len = 10; - } - - primaryScreenWidth = qApp->primaryScreen()->geometry().width(); - primaryScreenHeight = qApp->primaryScreen()->geometry().height(); - - if(primaryScreenWidth==800 && primaryScreenHeight==600) - { - minw=320; - minh=500; - defaultMainViewWidWidth=264; - defaultTopWidHeight=54; - defaultQueryLineEditWidth=245; - defaultQueryLineEditHeight=30; - defaultContentWidHeight=446; - defaultSideBarWidWidth=55; - } - else - { - minw=376; - minh=590; - defaultMainViewWidWidth=320; - defaultTopWidHeight=54; - defaultQueryLineEditWidth=288; - defaultQueryLineEditHeight=30; - defaultContentWidHeight=536; - defaultSideBarWidWidth=55; - } - - if(widthavailable>=2000 && widthavailable<=4000) - { - MainViewWidWidth=widthavailable-round((widthavailable-1644)/2); - TopWidgetHeight=107; - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=16; - LeftWidWidth=round((widthavailable-1644)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=20; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=25; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=14; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=15; - AppListWidWidth=1644; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=96; - AppListItemSizeWidth=168; - AppListGridSizeWidth=204; - AppLeftSpace=36; - AppTopSpace=15; - AppSpaceBetweenIconText=20; -// AppBottomSpace=27; - SliderSize=12; - - SideBarWidWidth=round((widthavailable-1644)/2); - SideBarMargin=20; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110+2*len; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } - else if (widthavailable>=1920 && widthavailable<2000) { - MainViewWidWidth=widthavailable-round((widthavailable-1314)/2); - TopWidgetHeight=107; - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=16; - LeftWidWidth=round((widthavailable-1314)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=20; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=25; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=14; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=15; - AppListWidWidth=1314; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=86; - AppListItemSizeWidth=150; - AppListGridSizeWidth=186; - AppLeftSpace=32; - AppTopSpace=13; - AppSpaceBetweenIconText=18; -// AppBottomSpace=27; - SliderSize=12; - - SideBarWidWidth=round((widthavailable-1314)/2); - SideBarMargin=20; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110+2*len; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } - else if (widthavailable>=1600 && widthavailable<1920) { - MainViewWidWidth=widthavailable-round((widthavailable-1090)/2); - TopWidgetHeight=107; - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=14; - LeftWidWidth=round((widthavailable-1090)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=10; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=25; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=11; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=10; - AppListWidWidth=1090; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=86; - AppListItemSizeWidth=150; - AppListGridSizeWidth=180; - AppLeftSpace=32; - AppTopSpace=10; - AppSpaceBetweenIconText=14; -// AppBottomSpace=static_cast(round(27*0.84)); - SliderSize=10; - - SideBarWidWidth=round((widthavailable-1090)/2); - SideBarMargin=10; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110+2*len; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } - else if (widthavailable>=1366 && widthavailable<1600) { - MainViewWidWidth=widthavailable-round((widthavailable-850)/2); - TopWidgetHeight=round(107*0.78); - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=14; - LeftWidWidth=round((widthavailable-850)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=10; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=20; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=11; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=10; - AppListWidWidth=850; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=64; - AppListItemSizeWidth=112; - AppListGridSizeWidth=140; - AppLeftSpace=24; - AppTopSpace=10; - AppSpaceBetweenIconText=0; -// AppBottomSpace=static_cast(round(27*0.74)); - SliderSize=10; - - SideBarWidWidth=round((widthavailable-850)/2); - SideBarMargin=10; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110+2*len; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } - else if (widthavailable>=1280 && widthavailable<1366) { - MainViewWidWidth=widthavailable-round((widthavailable-718)/2); - TopWidgetHeight=round(107*0.78); - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=14; - LeftWidWidth=round((widthavailable-718)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=10; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=20; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=11; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=10; - AppListWidWidth=718; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=64; - AppListItemSizeWidth=112; - AppListGridSizeWidth=142; - AppLeftSpace=24; - AppTopSpace=10; - AppSpaceBetweenIconText=14; -// AppBottomSpace=static_cast(round(27*0.65)); - SliderSize=8; - - SideBarWidWidth=round((widthavailable-718)/2); - SideBarMargin=10; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110+2*len; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } - else if (widthavailable>=1152 && widthavailable<1280) { - MainViewWidWidth=widthavailable-round((widthavailable-718)/2); - TopWidgetHeight=round(107*0.78); - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=14; - LeftWidWidth=round((widthavailable-718)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=10; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=20; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=11; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=10; - AppListWidWidth=718; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=64; - AppListItemSizeWidth=112; - AppListGridSizeWidth=142; - AppLeftSpace=24; - AppTopSpace=10; - AppSpaceBetweenIconText=14; -// AppBottomSpace=static_cast(round(27*0.65)); - SliderSize=8; - - SideBarWidWidth=round((widthavailable-718)/2); - SideBarMargin=10; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110+2*len; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } - else if (widthavailable>800 && widthavailable<1152){ - MainViewWidWidth=widthavailable-round((widthavailable-572)/2); - TopWidgetHeight=round(107*0.78); - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=14; - LeftWidWidth=round((widthavailable-572)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=10; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=20; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=11; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=10; - AppListWidWidth=572; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=64; - AppListItemSizeWidth=112; - AppListGridSizeWidth=141; - AppLeftSpace=25; - AppTopSpace=10; - AppSpaceBetweenIconText=14; -// AppBottomSpace=static_cast(round(27*0.52)); - SliderSize=8; - - SideBarWidWidth=round((widthavailable-572)/2); - SideBarMargin=10; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110+2*len; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } - else{ - MainViewWidWidth=widthavailable-round((widthavailable-560)/2); - TopWidgetHeight=round(107*0.78); - QueryLineEditWidth=350; - QueryLineEditHeight=30; - QueryLineEditFontSize=fontSize; - QueryLineEditIconSize=14; - LeftWidWidth=round((widthavailable-560)/2); - LeftWidHeight=heightavailable-TopWidgetHeight; - LeftMargin=10; - LeftBtnWidth=100+5*len; - LeftBtnHeight=43; - LeftLetterBtnHeight=20; - RightMargin=LeftWidWidth-LeftMargin-LeftBtnWidth; - LeftFontSize=fontSize; - LeftLetterFontSize=11; - LeftIconSize=19; - LeftSpaceIconLeft=15; - LeftSpaceIconText=14; - LeftSpaceBetweenItem=10; - AppListWidWidth=560; - AppListWidHeight=heightavailable-TopWidgetHeight; - AppListFontSize=fontSize; - AppListIconSize=64; - AppListItemSizeWidth=112; - AppListGridSizeWidth=138; - AppLeftSpace=25; - AppTopSpace=10; - AppSpaceBetweenIconText=14; -// AppBottomSpace=static_cast(round(27*0.52)); - SliderSize=8; - - SideBarWidWidth=round((widthavailable-560)/2); - SideBarMargin=10; - MinMaxWidWidth=110; - MinMaxWidHeight=TopWidgetHeight; - MinMaxBtnWidth=49; - MinMaxIconSize=19; - SideBarBtnWidth=110; - SideBarBtnHeight=43; - SideBarFontSize=fontSize; - SideBarIconSize=19; - SideBarSpaceIconLeft=14; - SideBarSpaceIconText=10; - SideBarSpaceBetweenItem=16; - } -} - -//不通过任务栏获取屏幕可用区域数据 -void Style::getScreenAvailableGeometry() -{ - QRect rect; - rect = qApp->primaryScreen()->geometry(); - - QDBusInterface iface(DBUS_NAME, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); - if (reply.isValid()) { - panelSize = reply.value().at(4).toInt(); - panelPosition = reply.value().at(5).toInt(); - } - - QList posIndex; - switch (panelPosition) { - case BOTTOM: - posIndex = {0, 0, 0, -1}; - break; - case TOP: - posIndex = {0, 1, 0, -1}; - break; - case LEFT: - posIndex = {1, 0, -1, 0}; - break; - case RIGHT: - posIndex = {0, 0, -1, 0}; - } - - primaryScreenX = rect.x() + posIndex[0] * panelSize; - primaryScreenY = rect.y() + posIndex[1] * panelSize; - widthavailable = rect.width() + posIndex[2] * panelSize; - heightavailable = rect.height() + posIndex[3] * panelSize; -} diff --git a/src/UserInterface/Button/function_classify_button.cpp b/src/UserInterface/Button/function_classify_button.cpp new file mode 100755 index 0000000..ffed89c --- /dev/null +++ b/src/UserInterface/Button/function_classify_button.cpp @@ -0,0 +1,289 @@ +/* + * 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 +#include +#include +#include + +FunctionClassifyButton::FunctionClassifyButton(int width, + int height, + int iconSize, + QString category, + bool fullscreen, + bool enabled, + QWidget *parent): + QPushButton(parent), + m_width(width), + m_height(height), + m_iconSize(iconSize), + m_category(category), + m_fullscreen(fullscreen), + m_enabled(enabled) +{ + this->setFlat(true); + this->setFixedSize(m_width, m_height); + this->setFocusPolicy(Qt::NoFocus); + + if (m_fullscreen) { + updateIconState(Normal); + this->setCheckable(true); + } else { + if (m_enabled) { + updateIconState(Enabled); + } else { + updateIconState(Disabled); + } + + this->setCheckable(false); + } + + connect(this, &FunctionClassifyButton::toggled, this, &FunctionClassifyButton::reactToToggle); + connect(this, &FunctionClassifyButton::clicked, this, &FunctionClassifyButton::buttonClickedSlot); +} + +void FunctionClassifyButton::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + QStylePainter painter(this); + QStyleOptionButton option; + initStyleOption(&option); + + if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver)) { + painter.save(); + painter.setPen(Qt::NoPen); + + if (!m_fullscreen) { + QColor color; + + if (option.state & QStyle::State_Selected) { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#33FFFFFF"); + } else { + color.setNamedColor("#D1FFFFFF"); + } + } else { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#1AFFFFFF"); + } else { + color.setNamedColor("#8CFFFFFF"); + } + } + + painter.setBrush(color); + } else { + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + } + + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + + if (!(option.state & QStyle::State_Enabled)) { + painter.save(); + QColor color; + if (!m_fullscreen) { + if ( g_curStyle == "ukui-light") { + color = Qt::black; + } else { + color = Qt::white; + } + color.setAlphaF(0.2); + } + painter.setPen(color); + painter.drawText(option.rect, Qt::AlignCenter, m_category); + painter.restore(); + } + + if (option.state & QStyle::State_Enabled) { + painter.save(); + QColor color; + + if (m_fullscreen) { + color = Qt::white; + } else { + if ( g_curStyle == "ukui-light") { + color = Qt::black; + } else { + color = Qt::white; + } + } + + color.setAlphaF(0.9); + painter.setPen(color); + painter.drawText(option.rect, Qt::AlignCenter, m_category); + painter.restore(); + } + + if (m_fullscreen && (option.state & QStyle::State_On)) { + painter.save(); + painter.setPen(Qt::NoPen); + QColor color = option.palette.color(QPalette::Text); + // color.setAlphaF(0.15); + painter.setBrush(color); + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + + QStyleOptionButton subopt = option; + subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); + subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); + painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); + return; +} + +void FunctionClassifyButton::updateBtnState() +{ + if (m_enabled) { + updateIconState(Enabled); + } else { + updateIconState(Disabled); + } +} + +void FunctionClassifyButton::enterEvent(QEvent *e) +{ + Q_UNUSED(e); + + if (m_enabled) { + updateIconState(Checked); + } +} + +void FunctionClassifyButton::leaveEvent(QEvent *e) +{ + Q_UNUSED(e); + + if (m_fullscreen) { + if (!isChecked()) { + updateIconState(Normal); + } + } else { + if (m_enabled) { + updateIconState(Enabled); + } + } +} + +void FunctionClassifyButton::reactToToggle(bool checked) +{ + if (m_fullscreen) { + if (checked) { + updateIconState(Checked); + } else { + updateIconState(Normal); + } + } +} + +void FunctionClassifyButton::buttonClickedSlot() +{ + Q_EMIT buttonClicked(); +} + +void FunctionClassifyButton::updateIconState() +{ + this->setFlat(true); + QString picState; + + switch (m_state) { + case Enabled: + picState = "Enabled"; + break; + + case Disabled: + picState = "Disabled"; + break; + + case Normal: + picState = "Normal"; + break; + + case Checked: + picState = "Checked"; + break; + + default: + break; + } + +// const auto ratio = devicePixelRatioF(); +// QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize * ratio); +// QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); +// if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 +// pixmap = drawSymbolicBlackColoredPixmap(pixmap); +// } else { +// pixmap = drawSymbolicColoredPixmap(pixmap); //反白 +// } +// pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); +// m_iconLabel->setPixmap(pixmap); +} + +void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State state) +{ + if (state == m_state) { + return; + } + + m_state = state; + QString picState; + + switch (state) { + case Enabled: + picState = "Enabled"; + break; + + case Disabled: + picState = "Disabled"; + break; + + case Normal: + picState = "Normal"; + break; + + case Checked: + picState = "Checked"; + break; + + default: + break; + } + +// const auto ratio = devicePixelRatioF(); +// QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize * ratio); +// if (!m_fullscreen) { +// QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); +// if (gsetting.get("style-name").toString() == "ukui-light") { //反黑 +// pixmap = drawSymbolicBlackColoredPixmap(pixmap); +// } else { +// pixmap = drawSymbolicColoredPixmap(pixmap); //反白 +// } +// } else { +// pixmap = drawSymbolicColoredPixmap(pixmap); //反白 +// } +// pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); +// m_iconLabel->setPixmap(pixmap); +// updateTextState(state); +} + + diff --git a/src/UtilityFunction/functionclassifybutton.h b/src/UserInterface/Button/function_classify_button.h old mode 100644 new mode 100755 similarity index 64% rename from src/UtilityFunction/functionclassifybutton.h rename to src/UserInterface/Button/function_classify_button.h index 1b80037..6160fb9 --- a/src/UtilityFunction/functionclassifybutton.h +++ b/src/UserInterface/Button/function_classify_button.h @@ -27,23 +27,23 @@ #include #include #include -#include "src/Style/style.h" -#include "src/UtilityFunction/utility.h" +#include "style.h" +#include "utility.h" -class FunctionClassifyButton :public QPushButton +class FunctionClassifyButton : public QPushButton { Q_OBJECT public: /** * @param iconstr正常图片 */ - FunctionClassifyButton(int width, - int height, - int iconSize, - QString category, - bool fullscreen, - bool enabled, - QWidget *parent=nullptr); + FunctionClassifyButton(int width, + int height, + int iconSize, + QString category, + bool fullscreen, + bool enabled, + QWidget *parent = nullptr); enum State { Enabled, @@ -52,41 +52,22 @@ public: Checked, }; - enum Category{ - Mobile, - Internet, - Social, - Video, - Development, - Image, - Game, - Office, - Education, - System, - Others, - }; - Q_ENUM(Category) - int m_width; int m_height; int m_iconSize; QString m_category; bool m_fullscreen; bool m_enabled; - QLabel* m_iconLabel=nullptr; - QLabel* m_textLabel=nullptr; - State m_state=Checked; + State m_state = Checked; void updateBtnState(); void updateIconState();//根据主题修改图标 protected: - void enterEvent(QEvent* e); - void leaveEvent(QEvent* e); - void paintEvent(QPaintEvent* e); + void enterEvent(QEvent *e); + void leaveEvent(QEvent *e); + void paintEvent(QPaintEvent *e); void updateIconState(const State state); - void updateTextState(const State state); - void setLabelText(); Q_SIGNALS: void buttonClicked(); diff --git a/src/UserInterface/Button/letter_classify_button.cpp b/src/UserInterface/Button/letter_classify_button.cpp new file mode 100755 index 0000000..11073a8 --- /dev/null +++ b/src/UserInterface/Button/letter_classify_button.cpp @@ -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 +#include +#include "utility.h" + +LetterClassifyButton::LetterClassifyButton(QWidget *parent, + bool fullscreen, + QString letter): + QPushButton(parent), + m_fullscreen(fullscreen) +{ + this->setFlat(true); + m_letter = letter; +// if (m_fullscreen) { +// QFont font; +// font.setPixelSize(Style::LeftLetterFontSize); +// this->setFont(font); +// QPalette pe = this->palette(); +// pe.setColor(QPalette::ButtonText, Qt::white); +// this->setPalette(pe); +// } + +// this->setText(letter); + this->setFocusPolicy(Qt::NoFocus); + this->setCheckable(true); + this->setStyleSheet("padding: 0px;"); + connect(this, &LetterClassifyButton::toggled, this, &LetterClassifyButton::reactToToggle); +} + +void LetterClassifyButton::paintEvent(QPaintEvent *e) +{ + QStylePainter painter(this); + QStyleOptionButton option; + initStyleOption(&option); + + if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver || option.state & QStyle::State_HasFocus)) { + painter.save(); + painter.setPen(Qt::NoPen); + + if (!m_fullscreen) { + QColor color; + + if (option.state & QStyle::State_Selected) { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#33FFFFFF"); + } else { + color.setNamedColor("#D1FFFFFF"); + } + } else { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#1AFFFFFF"); + } else { + color.setNamedColor("#8CFFFFFF"); + } + } + + painter.setBrush(color); + } else { + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + } + + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + + if (!(option.state & QStyle::State_Enabled)) { + painter.save(); + QColor color; + if (!m_fullscreen) { + if ( g_curStyle == "ukui-light") { + color = Qt::black; + } else { + color = Qt::white; + } + color.setAlphaF(0.2); + } + painter.setPen(color); + painter.drawText(option.rect, Qt::AlignCenter, m_letter); + painter.restore(); + } + + if (option.state & QStyle::State_Enabled) { + painter.save(); + QColor color; + + if (m_fullscreen) { + color = Qt::white; + } else { + if ( g_curStyle == "ukui-light") { + color = Qt::black; + } else { + color = Qt::white; + } + } + + color.setAlphaF(0.9); + painter.setPen(color); + painter.drawText(option.rect, Qt::AlignCenter, m_letter); + painter.restore(); + } + + if (m_fullscreen && (option.state & QStyle::State_On)) { + painter.save(); + painter.setPen(Qt::NoPen); + // QColor color = option.palette.color(QPalette::Text); + // color.setAlphaF(0.15); + // painter.setBrush(color); + painter.setOpacity(0.15); + painter.setBrush(Qt::white); + painter.drawRoundedRect(option.rect, 4, 4); + painter.restore(); + } + + QStyleOptionButton subopt = option; + subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); + + if (m_fullscreen) { + subopt.palette.setBrush(QPalette::ButtonText, QColor(Qt::white)); + } else { + subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); + } + + painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); + return; +} + +void LetterClassifyButton::enterEvent(QEvent *e) +{ + Q_UNUSED(e); + + if (m_fullscreen) { + // QFont font; + // font.setPixelSize(Style::LeftLetterFontSize*3); + // this->setFont(font); + // this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + tooltip = new LetterToolTip(); + QPoint oPoint = this->mapToGlobal(QPoint(this->rect().x() + 35, this->rect().y() - 10)); + tooltip->setText(m_letter); + tooltip->raise(); + tooltip->move(oPoint); + tooltip->show(); + } +} + +void LetterClassifyButton::leaveEvent(QEvent *e) +{ + Q_UNUSED(e); + + if (m_fullscreen) { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight, Style::LeftLetterBtnHeight); + tooltip->close(); + delete tooltip; + tooltip = nullptr; + } +} + +void LetterClassifyButton::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + + if (m_fullscreen) { + // QFont font; + // font.setPixelSize(Style::LeftLetterFontSize*3); + // this->setFont(font); + // this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + is_pressed = true; + } +} + +void LetterClassifyButton::focusInEvent(QEvent *e) +{ + Q_UNUSED(e); + + if (m_fullscreen) { + QFont font; + font.setPixelSize(Style::LeftLetterFontSize * 3); + this->setFont(font); + this->setFixedSize(Style::LeftLetterBtnHeight * 2, Style::LeftLetterBtnHeight * 2); + } +} + +void LetterClassifyButton::mouseReleaseEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + + if (m_fullscreen) { + // QFont font; + // font.setPixelSize(Style::LeftLetterFontSize*3); + // this->setFont(font); + // this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); + } + + Q_EMIT buttonClicked(this); +} + +void LetterClassifyButton::reactToToggle(bool checked) +{ + if (checked) { + this->is_pressed = true; + } else { + this->is_pressed = false; + } +} diff --git a/src/UtilityFunction/letterclassifybutton.h b/src/UserInterface/Button/letter_classify_button.h old mode 100644 new mode 100755 similarity index 73% rename from src/UtilityFunction/letterclassifybutton.h rename to src/UserInterface/Button/letter_classify_button.h index be5f601..7235987 --- a/src/UtilityFunction/letterclassifybutton.h +++ b/src/UserInterface/Button/letter_classify_button.h @@ -21,7 +21,9 @@ #include #include #include -#include "src/Style/style.h" +#include "style.h" +#include "lettertooltip.h" +#include class LetterClassifyButton : public QPushButton { @@ -30,24 +32,25 @@ public: LetterClassifyButton(QWidget *parent, bool fullscreen, QString letter - ); - - bool is_pressed=false; + ); + bool is_pressed = false; + QString m_letter = QString(); private: - bool m_fullscreen=false; + bool m_fullscreen = false; + LetterToolTip *tooltip = nullptr; protected: - void enterEvent(QEvent* e); - void leaveEvent(QEvent* e); - void paintEvent(QPaintEvent* e); + void enterEvent(QEvent *e); + void leaveEvent(QEvent *e); + void paintEvent(QPaintEvent *e); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); - void focusInEvent(QEvent* e); - void focusOutEvent(QEvent* e); + void focusInEvent(QEvent *e); + void focusOutEvent(QEvent *e); Q_SIGNALS: - void buttonClicked(QAbstractButton* btn); + void buttonClicked(QAbstractButton *btn); private Q_SLOTS: void reactToToggle(bool checked); diff --git a/src/UserInterface/Button/tool_button.cpp b/src/UserInterface/Button/tool_button.cpp new file mode 100755 index 0000000..9e430e6 --- /dev/null +++ b/src/UserInterface/Button/tool_button.cpp @@ -0,0 +1,205 @@ +/* + * 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 + +ToolButton::ToolButton(int width, + int height, + QString iconstr, + QString piconstr, + QString hoverbg, + QString pressedbg, + int module, + QString text) +{ + this->setFixedSize(width, height); + this->iconstr = iconstr; + this->piconstr = piconstr; + this->hoverbg = hoverbg; + this->pressedbg = pressedbg; + this->module = module; + this->text = text; + this->setFocusPolicy(Qt::StrongFocus); + svgRender = new QSvgRenderer(this); + svgRender->load(iconstr); + + if (module == 1) { + pixmap = new QPixmap(14, 14); + } else if (module == 2) { + pixmap = new QPixmap(19, 19); + } else { + pixmap = new QPixmap(9, 9); + } + + pixmap->fill(Qt::transparent); + QPainter p(pixmap); + svgRender->render(&p); + this->setIcon(QIcon(*pixmap)); + + if (module == 2) { + this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + this->setText(tr(text.toLocal8Bit().data())); + // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); + } + + // else + // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); +} + +void ToolButton::enterEvent(QEvent *e) +{ + Q_UNUSED(e); + QByteArray byte = hoverbg.toLocal8Bit(); + char *hover = byte.data(); + char style[100]; + + if (module == 2) { + sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", hover); + } else { + sprintf(style, "border:0px;padding-left:0px;background-color:%s;", hover); + } + + delete svgRender; + svgRender = new QSvgRenderer(this); + svgRender->load(piconstr); + + if (module == 1) { + pixmap = new QPixmap(14, 14); + } else if (module == 2) { + pixmap = new QPixmap(19, 19); + } else { + pixmap = new QPixmap(9, 9); + } + + pixmap->fill(Qt::transparent); + QPainter p(pixmap); + svgRender->render(&p); + this->setIcon(QIcon(*pixmap)); +} + +void ToolButton::leaveEvent(QEvent *e) +{ + Q_UNUSED(e); + // if(module==2) + // { + // if(!is_pressed) + // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); + // else + // this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255);font-size:14px;"); + // } + // else + // this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); + delete svgRender; + svgRender = new QSvgRenderer(this); + + if (module == 2 && is_pressed) { + svgRender->load(piconstr); + } else { + svgRender->load(iconstr); + } + + if (module == 1) { + pixmap = new QPixmap(14, 14); + } else if (module == 2) { + pixmap = new QPixmap(19, 19); + } else { + pixmap = new QPixmap(9, 9); + } + + pixmap->fill(Qt::transparent); + QPainter p(pixmap); + svgRender->render(&p); + this->setIcon(QIcon(*pixmap)); +} + +void ToolButton::mousePressEvent(QMouseEvent *event) +{ + QByteArray byte = pressedbg.toLocal8Bit(); + char *pressed = byte.data(); + char style[100]; + + if (module == 2) { + sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", pressed); + } else { + sprintf(style, "border:0px;padding-left:0px;background-color:%s;", pressed); + } + + if (event->button() == Qt::LeftButton) { + // this->setStyleSheet(QString::fromLocal8Bit(style)); + delete svgRender; + svgRender = new QSvgRenderer(this); + svgRender->load(piconstr); + + if (module == 1) { + pixmap = new QPixmap(14, 14); + } else if (module == 2) { + pixmap = new QPixmap(19, 19); + } else { + pixmap = new QPixmap(9, 9); + } + + pixmap->fill(Qt::transparent); + QPainter p(pixmap); + svgRender->render(&p); + this->setIcon(QIcon(*pixmap)); + is_pressed = true; + } +} + +void ToolButton::mouseReleaseEvent(QMouseEvent *event) +{ + QByteArray byte = hoverbg.toLocal8Bit(); + char *hover = byte.data(); + char style[100]; + + if (module == 2) { + sprintf(style, "border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;", hover); + } else { + sprintf(style, "border:0px;padding-left:0px;background-color:%s;", hover); + } + + if (event->button() == Qt::LeftButton) { + // this->setStyleSheet(QString::fromLocal8Bit(style)); + delete svgRender; + svgRender = new QSvgRenderer(this); + svgRender->load(piconstr); + + if (module == 1) { + pixmap = new QPixmap(14, 14); + } else if (module == 2) { + pixmap = new QPixmap(19, 19); + } else { + pixmap = new QPixmap(9, 9); + } + + pixmap->fill(Qt::transparent); + QPainter p(pixmap); + svgRender->render(&p); + this->setIcon(QIcon(*pixmap)); + + if (module == 2) { + Q_EMIT buttonClicked(this); + } else { + Q_EMIT clicked(); + } + } +} + + + diff --git a/src/UtilityFunction/toolbutton.h b/src/UserInterface/Button/tool_button.h old mode 100644 new mode 100755 similarity index 86% rename from src/UtilityFunction/toolbutton.h rename to src/UserInterface/Button/tool_button.h index 8b1f07b..8634fb2 --- a/src/UtilityFunction/toolbutton.h +++ b/src/UserInterface/Button/tool_button.h @@ -47,7 +47,7 @@ public: int module, QString text); - bool is_pressed=false;//记录功能分类模块点击状态 + bool is_pressed = false; //记录功能分类模块点击状态 private: QString iconstr; @@ -55,21 +55,21 @@ private: QString hoverbg; QString pressedbg; int module; - QLabel* label; - QHBoxLayout* layout; - QPixmap* pixmap; - QSvgRenderer* svgRender; + QLabel *label; + QHBoxLayout *layout; + QPixmap *pixmap; + QSvgRenderer *svgRender; QString text; protected: - void enterEvent(QEvent* e); - void leaveEvent(QEvent* e); + void enterEvent(QEvent *e); + void leaveEvent(QEvent *e); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); Q_SIGNALS: - void buttonClicked(QAbstractButton* btn); + void buttonClicked(QAbstractButton *btn); }; #endif // TOOLBUTTON_H diff --git a/src/UserInterface/ListView/fulllistview.cpp b/src/UserInterface/ListView/fulllistview.cpp new file mode 100755 index 0000000..17124b8 --- /dev/null +++ b/src/UserInterface/ListView/fulllistview.cpp @@ -0,0 +1,134 @@ +/* + * 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 +#include +#include +#include + +FullListView::FullListView(QWidget *parent, int module): + KListView(parent) +{ + this->module = module; + initWidget(); + m_delegate = new FullItemDelegate(this, module); + this->setItemDelegate(m_delegate); + pUkuiMenuInterface = new UkuiMenuInterface; +} + +FullListView::~FullListView() +{ + delete menu; + delete gsetting; +} + +void FullListView::initWidget() +{ + viewport()->setAttribute(Qt::WA_TranslucentBackground); + this->setSelectionMode(QAbstractItemView::SingleSelection); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setViewMode(QListView::IconMode); + this->setContextMenuPolicy(Qt::CustomContextMenu); + this->setResizeMode(QListView::Adjust); + this->setTextElideMode(Qt::ElideRight); + this->setMouseTracking(true); + this->setMovement(QListView::Static); + this->setEditTriggers(QAbstractItemView::NoEditTriggers); + setItemAlignment(Qt::AlignCenter); + this->setGridSize(QSize(Style::m_applistGridSizeWidth, Style::m_applistGridSizeWidth)); + this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->setFrameShape(QFrame::NoFrame);//移除边框 + //this->setStyleSheet(QString::fromUtf8("QStandardItemModel#listmodel{border:3px solid #FFFFFF; }QWidget#widget:focus{ border:5px solid #A5A6A1; } ")); + connect(this, &FullListView::customContextMenuRequested, this, &FullListView::rightClickedSlot); + connect(this, &FullListView::clicked, this, &FullListView::onClicked); +} + +void FullListView::selectFirstItem() +{ + if (this->currentIndex().row() == -1) { + this->setCurrentIndex(this->model()->index(0, 0)); + } +} + +void FullListView::keyPressEvent(QKeyEvent *e) +{ + QRect center = visualRect(currentIndex()); + + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + break; + } + + case Qt::Key_Left: { + this->clearFocus(); + + if (mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::m_applistGridSizeWidth) { + Q_EMIT sendSetslidebar(-Style::m_applistGridSizeWidth); + } + + this->setFocus(); + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Right: { + this->clearFocus(); + + if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::m_applistGridSizeWidth)) { + Q_EMIT sendSetslidebar(Style::m_applistGridSizeWidth); + } + + this->setFocus(); + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Up: { + if (module == 0) { + if (mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::m_applistGridSizeWidth)) { + Q_EMIT sendSetslidebar(-Style::m_applistGridSizeWidth); + } + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Down: { + if (module == 0) { + if (mapToGlobal(center.bottomRight()).y() > (1080 - Style::m_applistGridSizeWidth)) { + Q_EMIT sendSetslidebar(Style::m_applistGridSizeWidth); + } + } + + return QListView::keyPressEvent(e); + break; + } + + default: + return QListView::keyPressEvent(e); + } + } +} diff --git a/src/UserInterface/ListView/fulllistview.h b/src/UserInterface/ListView/fulllistview.h new file mode 100755 index 0000000..93c06b2 --- /dev/null +++ b/src/UserInterface/ListView/fulllistview.h @@ -0,0 +1,56 @@ +/* + * 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 +#include +#include "rightclickmenu.h" +#include "ukuimenuinterface.h" +#include +#include +#include +#include +#include "full_item_delegate.h" +#include "style.h" +#include "klistview.h" + +class FullListView : public KListView +{ + Q_OBJECT +public: + explicit FullListView(QWidget *parent, int module); + ~FullListView(); + +protected: + void initWidget(); + void keyPressEvent(QKeyEvent *e); + +private: + RightClickMenu *menu = nullptr;//右键菜单 + QStringList data; + QGSettings *gsetting = nullptr; + +public Q_SLOTS: + void selectFirstItem(); + +Q_SIGNALS: + void sendSetslidebar(int value); +}; + +#endif // FULLLISTVIEW_H diff --git a/src/UserInterface/ListView/klistview.cpp b/src/UserInterface/ListView/klistview.cpp new file mode 100755 index 0000000..3954bc9 --- /dev/null +++ b/src/UserInterface/ListView/klistview.cpp @@ -0,0 +1,116 @@ +#include +#include "klistview.h" +#include "utility.h" +#include +#include "rightclickmenu.h" + +KListView::KListView(QWidget *parent): + QListView(parent) +{ +} + +KListView::~KListView() +{ + delete m_delegate; + delete listmodel; + delete pUkuiMenuInterface; +} + +void KListView::addData(QStringList data) +{ + listmodel = new QStandardItemModel(this); + this->setModel(listmodel); + + Q_FOREACH (QString desktopfp, data) { + QStandardItem *item = new QStandardItem; + item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + listmodel->appendRow(item); + } +} + +void KListView::updateData(QStringList data) +{ + listmodel->clear(); + + Q_FOREACH (QString desktopfp, data) { + QStandardItem *item = new QStandardItem; + item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + listmodel->appendRow(item); + } +} + +void KListView::onClicked(QModelIndex index) +{ + QVariant var = listmodel->data(index, Qt::DisplayRole); + + if (var.isValid()) { + QString desktopfp = var.value(); + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); + } +} + +void KListView::paintEvent(QPaintEvent *e) +{ + double transparency = getTransparency(); + QPainter painter(this->viewport()); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + QListView::paintEvent(e); +} + +void KListView::mouseMoveEvent(QMouseEvent *e) +{ + this->clearFocus(); + return QListView::mouseMoveEvent(e); +} + +void KListView::mousePressEvent(QMouseEvent *event) +{ + if (!(this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) { + Q_EMIT sendHideMainWindowSignal(); + } else { + pressApp = listmodel->data(this->indexAt(event->pos()), Qt::DisplayRole); + } + return QListView::mousePressEvent(event); +} + +void KListView::rightClickedSlot(const QPoint &pos) +{ + if (!(this->selectionModel()->selectedIndexes().isEmpty())) { + + QModelIndex index = indexAt(pos); + if(!index.isValid()) { + return; + } + + QVariant var = listmodel->data(index, Qt::DisplayRole); + QStringList strlist = var.value(); + + if (strlist.count() == 1 || ((strlist.count() == 2) && (strlist.at(1).toInt() == 1))) { + RightClickMenu menu; + int ret = menu.showAppBtnMenu(this->mapToGlobal(pos), strlist.at(0)); + + switch (ret) { + case 1: + case 2: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 6: + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + + case 18: + Q_EMIT sendCollectViewUpdate(); + break; + + default: + break; + } + } + } +} diff --git a/src/UserInterface/ListView/klistview.h b/src/UserInterface/ListView/klistview.h new file mode 100755 index 0000000..e932fd2 --- /dev/null +++ b/src/UserInterface/ListView/klistview.h @@ -0,0 +1,42 @@ +#ifndef KLISTVIEW_H +#define KLISTVIEW_H +#include +#include "kitemdelegate.h" +#include +#include +#include + +class KListView : public QListView +{ + Q_OBJECT +public: + KListView(QWidget *parent); + ~KListView(); + void initWidget(); + + KItemDelegate *m_delegate = nullptr; + QStandardItemModel *listmodel = nullptr; + int module = 0; + double transparency; + QVariant pressApp; + UkuiMenuInterface *pUkuiMenuInterface = nullptr; +protected: + void paintEvent(QPaintEvent *e); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *e); +public: + void addData(QStringList data); + void updateData(QStringList data); + +Q_SIGNALS: + void sendHideMainWindowSignal(); + void sendItemClickedSignal(QString arg);//发送item点击信号 + void sendUpdateAppListSignal(); + void sendCollectViewUpdate(); + +public Q_SLOTS: + void rightClickedSlot(const QPoint &pos); + void onClicked(QModelIndex index); +}; + +#endif // KLISTVIEW_H diff --git a/src/UserInterface/ListView/listview.cpp b/src/UserInterface/ListView/listview.cpp new file mode 100755 index 0000000..368f25a --- /dev/null +++ b/src/UserInterface/ListView/listview.cpp @@ -0,0 +1,190 @@ +/* + * 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 +#include + +ListView::ListView(QWidget *parent/*, int width, int height, int module*/): + KListView(parent) +{ + this->w = 300; + this->h = 540; + this->module = 1; + initWidget(); + listmodel = new QStandardItemModel(this); + this->setModel(listmodel); + pUkuiMenuInterface = new UkuiMenuInterface; + this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); +} + +ListView::~ListView() +{ + delete pUkuiMenuInterface; +} + +void ListView::initWidget() +{ + setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAutoFillBackground(false); + this->setSelectionMode(QAbstractItemView::SingleSelection); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setResizeMode(QListView::Adjust); + this->setTextElideMode(Qt::ElideRight); + this->setViewMode(QListView::ListMode); + this->setContextMenuPolicy(Qt::CustomContextMenu); + this->setFocusPolicy(Qt::StrongFocus); + this->setMovement(QListView::Static); + this->setEditTriggers(QAbstractItemView::NoEditTriggers); + this->setUpdatesEnabled(true); + this->setSpacing(0); + this->setContentsMargins(0, 0, 0, 0); + this->setMouseTracking(true); + this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->setFrameShape(QFrame::NoFrame); + this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + connect(this, &ListView::customContextMenuRequested, this, &ListView::rightClickedSlot); + connect(this, &ListView::clicked, this, &ListView::onClicked); +} + +void ListView::addData(QVector data, int module) +{ + this->module = module; + listmodel->clear(); + + Q_FOREACH (QStringList desktopfp, data) { + QStandardItem *item = new QStandardItem; + item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + listmodel->appendRow(item); + } + + m_delegate = new ItemDelegate(this, module); + this->setItemDelegate(m_delegate); +} + +void ListView::updateData(QVector data) +{ + listmodel->clear(); + + Q_FOREACH (QStringList desktopfp, data) { + QStandardItem *item = new QStandardItem; + item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + listmodel->appendRow(item); + } +} + +void ListView::onClicked(QModelIndex index) +{ + QVariant var = listmodel->data(index, Qt::DisplayRole); + QString desktopfp = var.value().at(0); + + if (var.isValid()) { + if ((var.value().size() == 5) && (!desktopfp.endsWith(".desktop"))) { //专用于处理最近页的uri + QUrl url(desktopfp); + QDesktopServices::openUrl(url); + return; + } + + if (var.value().at(1).toInt() == 0) { + Q_EMIT sendAppClassificationBtnClicked(); + } else { + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); + } + } +} + +void ListView::enterEvent(QEvent *e) +{ + Q_UNUSED(e); + this->selectionModel()->clear(); + this->verticalScrollBar()->setVisible(true); +} + +void ListView::leaveEvent(QEvent *e) +{ + Q_UNUSED(e); + this->verticalScrollBar()->setVisible(false); +} + +void ListView::paintEvent(QPaintEvent *e) +{ + //滚动条 + QPalette p = this->verticalScrollBar()->palette(); + QColor color; + + if (g_curStyle == "ukui-dark") { + color = QColor("#26FFFFFF"); + } else { + color = QColor("#1A000000"); + } + + p.setColor(QPalette::Active, QPalette::Button, color); + this->verticalScrollBar()->setPalette(p); + QListView::paintEvent(e); +} + +void ListView::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + } + break; + + case Qt::Key_Down: { + if (currentIndex().row() == this->model()->rowCount() - 1) { + setCurrentIndex(this->model()->index(0, 0)); + break; + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Up: { + if (currentIndex().row() == 0) { + setCurrentIndex(this->model()->index(this->model()->rowCount() - 1, 0)); + break; + } + + return QListView::keyPressEvent(e); + break; + } + + case Qt::Key_Right: { + break; + } + + case Qt::Key_Left: { + break; + } + + default: + return QListView::keyPressEvent(e); + break; + } + } +} diff --git a/src/UtilityFunction/listview.h b/src/UserInterface/ListView/listview.h old mode 100644 new mode 100755 similarity index 52% rename from src/UtilityFunction/listview.h rename to src/UserInterface/ListView/listview.h index b63147e..5b14550 --- a/src/UtilityFunction/listview.h +++ b/src/UserInterface/ListView/listview.h @@ -23,58 +23,47 @@ #include #include #include -#include "src/Style/style.h" -#include "src/RightClickMenu/rightclickmenu.h" +#include "style.h" +#include "rightclickmenu.h" #include #include #include -#include "src/Interface/ukuimenuinterface.h" +#include "ukuimenuinterface.h" #include "itemdelegate.h" +#include "klistview.h" +#include -class ListView : public QListView +class ListView : public KListView { Q_OBJECT + public: - ListView(QWidget *parent, int width, int height, int module); + ListView(QWidget *parent/*, int width, int height, int module*/); ~ListView(); - void addData(QVector data); + void addData(QVector data, int module); void updateData(QVector data); protected: void initWidget(); - void enterEvent(QEvent* e) Q_DECL_OVERRIDE; - void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; + void enterEvent(QEvent *e) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *e) override; - void keyPressEvent(QKeyEvent* e); - void dropEvent(QDropEvent *event); - void mousePressEvent(QMouseEvent *event); - void dragLeaveEvent(QDragLeaveEvent *e); - void dragMoveEvent(QDragMoveEvent *event); + void keyPressEvent(QKeyEvent *e); private: - QStandardItemModel* listmodel=nullptr; - int w=0; - int h=0; - int module=0; - UkuiMenuInterface* pUkuiMenuInterface=nullptr; - - RightClickMenu* menu=nullptr;//右键菜单 - QVector data; - ItemDelegate* m_delegate=nullptr; + int w = 0; + int h = 0; int m_preRowCount; - QPoint startPos; -// QMimeData *mimeData = nullptr; -// QDrag *drag = nullptr; private Q_SLOTS: void onClicked(QModelIndex index);//点击item - void rightClickedSlot(const QPoint &pos);//右键菜单 +// void rightClickedSlot(const QPoint &pos);//右键菜单 + Q_SIGNALS: - void sendItemClickedSignal(QStringList arg);//发送item点击信号 - void sendHideMainWindowSignal(); - void sendUpdateAppListSignal(); + void sendMainWinActiveSignal(bool flag); + void sendAppClassificationBtnClicked(); }; #endif // LISTVIEW_H diff --git a/src/UserInterface/ListView/rightlistview.cpp b/src/UserInterface/ListView/rightlistview.cpp new file mode 100755 index 0000000..7725222 --- /dev/null +++ b/src/UserInterface/ListView/rightlistview.cpp @@ -0,0 +1,156 @@ +/* + * 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 +#include +#include +#include + +RightListView::RightListView(QWidget *parent): + KListView(parent) +{ + initWidget(); + m_delegate = new RightItemDelegate(this); + this->setItemDelegate(m_delegate); + pUkuiMenuInterface = new UkuiMenuInterface; +} + +RightListView::~RightListView() +{ + delete pUkuiMenuInterface; +} + +void RightListView::initWidget() +{ + setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAttribute(Qt::WA_TranslucentBackground); + viewport()->setAutoFillBackground(false); + this->setSelectionMode(QAbstractItemView::SingleSelection); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + this->setViewMode(QListView::IconMode); + this->setContextMenuPolicy(Qt::CustomContextMenu); + this->setResizeMode(QListView::Adjust); + this->setTextElideMode(Qt::ElideRight); + this->setMouseTracking(true); + this->setMovement(QListView::Static); + this->setEditTriggers(QAbstractItemView::NoEditTriggers); + this->setGridSize(QSize(105, 105)); + this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); + this->setFrameShape(QFrame::NoFrame);//移除边框 + connect(this, &RightListView::customContextMenuRequested, this, &RightListView::rightClickedSlot); + connect(this, &RightListView::clicked, this, &RightListView::onClicked); +} + +void RightListView::dropEvent(QDropEvent *event) +{ + RightListView *source = qobject_cast(event->source()); + + if (source && source == this) { + m_dropPos = event->pos(); + + if (this->indexAt(m_dropPos).isValid()) { + QVariant var = listmodel->data(indexAt(m_dropPos), Qt::DisplayRole); + QString desktopfp = var.value(); + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + QString dragDesktopfp = pressApp.value(); + QFileInfo dragFileInfo(dragDesktopfp); + QString dragDesktopfn = dragFileInfo.fileName(); + changeCollectSort(dragDesktopfn, desktopfn); + } + } + + Q_EMIT sendCollectViewUpdate(); +} + +void RightListView::selectFirstItem() +{ + myDebug() << "选择首个元素"; + + if (this->currentIndex().row() == -1) { + this->setCurrentIndex(this->model()->index(0, 0)); + } +} + +void RightListView::paintEvent(QPaintEvent *e) +{ + //滚动条 + QPalette p = this->verticalScrollBar()->palette(); + QColor color; + + if (g_curStyle == "ukui-dark") { + color = QColor("#26FFFFFF"); + } else { + color = QColor("#1A000000"); + } + + p.setColor(QPalette::Active, QPalette::Button, color); + this->verticalScrollBar()->setPalette(p); + QListView::paintEvent(e); +} + +void RightListView::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + switch (e->key()) { + case Qt::Key_Enter: + case Qt::Key_Return: { + QModelIndex index = this->currentIndex(); + Q_EMIT clicked(index); + break; + } + + default: + return QListView::keyPressEvent(e); + break; + } + } +} + +void RightListView::onClicked(QModelIndex index) +{ + Q_EMIT sendHideMainWindowSignal(); + QVariant var = listmodel->data(index, Qt::DisplayRole); + QString desktopfp = var.value().at(0); + if (var.isValid()) { + QString desktopfp = var.value(); + execApp(desktopfp); + } +} + +void RightListView::changeStyleColor(const QColor &color) +{ + m_styleColor = color; +} + +void RightListView::enterEvent(QEvent *e) +{ + Q_UNUSED(e); + this->selectionModel()->clear(); + this->verticalScrollBar()->setVisible(true); +} + +void RightListView::leaveEvent(QEvent *e) +{ + Q_UNUSED(e); + this->verticalScrollBar()->setVisible(false); +} diff --git a/src/UserInterface/ListView/rightlistview.h b/src/UserInterface/ListView/rightlistview.h new file mode 100755 index 0000000..b09c361 --- /dev/null +++ b/src/UserInterface/ListView/rightlistview.h @@ -0,0 +1,53 @@ +#ifndef RIGHTLISTVIEW_H +#define RIGHTLISTVIEW_H +#include +#include +#include "rightclickmenu.h" +#include "ukuimenuinterface.h" +#include +#include +#include +#include +#include "right_item_delegate.h" +#include "style.h" +#include "utility.h" +#include "klistview.h" + +class RightListView : public KListView +{ + Q_OBJECT +public: + RightListView(QWidget *parent); + ~RightListView(); + + void initWidget(); +protected: + + void keyPressEvent(QKeyEvent *e); + void dropEvent(QDropEvent *event); + void enterEvent(QEvent *e); + void paintEvent(QPaintEvent *e); + void leaveEvent(QEvent *e); + +private: + RightClickMenu *menu = nullptr; //右键菜单 + QStringList data; + QGSettings *gsetting; + QPoint m_dropPos; + QColor m_styleColor; + +// bool inCurView; + +public Q_SLOTS: + +// void rightClickedSlot(const QPoint &pos);//右键菜单 + void selectFirstItem(); + void changeStyleColor(const QColor &color); + void onClicked(QModelIndex index); + +Q_SIGNALS: + + void sendSetslidebar(int value); +}; + +#endif // FULLLISTVIEW_H diff --git a/src/UserInterface/ListView/tabletlistview.cpp b/src/UserInterface/ListView/tabletlistview.cpp new file mode 100755 index 0000000..6a957f4 --- /dev/null +++ b/src/UserInterface/ListView/tabletlistview.cpp @@ -0,0 +1,809 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#define TABLED_SCHEMA "org.ukui.SettingsDaemon.plugins.tablet-mode" +#define TABLET_MODE "tablet-mode" +/*初始化*/ +TabletListView::TabletListView(QWidget *parent, int pageNum): + QListView(parent) +{ + QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(this); + shadowEffect->setOffset(0, 0); + shadowEffect->setColor(QColor(26, 26, 28, 150)); + shadowEffect->setBlurRadius(15); + this->setGraphicsEffect(shadowEffect); + this->setAcceptDrops(true); + this->m_pageNum = pageNum; + initWidget(); + pUkuiMenuInterface = new UkuiMenuInterface; + menu = new TabletRightClickMenu; + //应用列表 + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + setting = new QSettings(path, QSettings::IniFormat); + //禁用列表 + QString pathini = QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"; + disableSetting = new QSettings(pathini, QSettings::IniFormat); + //不可卸载列表 + QString syspath = QDir::homePath() + "/.config/ukui/menusysapplist.ini"; + syssetting = new QSettings(syspath, QSettings::IniFormat); + setDragEnabled(true); + //翻页灵敏度时间调节 + m_time = new QTimer(this); + connect(m_time, &QTimer::timeout, [ = ]() { + if (m_flat == false) { + m_flat = true; + m_time->stop(); + } + }); +} + +TabletListView::~TabletListView() +{ + if (pUkuiMenuInterface) { + delete pUkuiMenuInterface; + } + + if (menu) { + delete menu; + } + + if (setting) { + delete setting; + } + + if (disableSetting) { + delete disableSetting; + } + + if (tabletMode) { + delete tabletMode; + } + + if (m_animation) { + delete m_animation; + } + + if (m_time) { + delete m_time; + } + + if (listmodel) { + delete listmodel; + } + + if (m_delegate) { //can + delete m_delegate; + } + + pUkuiMenuInterface = nullptr; + menu = nullptr; + setting = nullptr; + disableSetting = nullptr; + tabletMode = nullptr; + m_animation = nullptr; + m_time = nullptr; + listmodel = nullptr; + m_delegate = nullptr; + + if (syssetting) { + delete syssetting; + } + + syssetting = nullptr; +} + +void TabletListView::initWidget() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setSelectionMode(QAbstractItemView::SingleSelection); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setAutoFillBackground(false); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setWindowFlags(Qt::FramelessWindowHint);//无边框 + viewport()->setAttribute(Qt::WA_TranslucentBackground); + this->viewport()->setUpdatesEnabled(true); + this->setViewMode(QListView::IconMode); + this->setContextMenuPolicy(Qt::CustomContextMenu); + this->setResizeMode(QListView::Adjust); + this->setTextElideMode(Qt::ElideRight); + this->setMouseTracking(true); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setFocusPolicy(Qt::NoFocus); + this->setMovement(QListView::Snap); + this->setFrameShape(QFrame::NoFrame); + this->setContentsMargins(0, 0, 0, 0); + this->setSpacing(0); + this->setEditTriggers(QAbstractItemView::NoEditTriggers); + connect(this, &TabletListView::customContextMenuRequested, this, &TabletListView::rightClickedSlot); +} +//添加数据 +void TabletListView::addData(QStringList data) +{ + listmodel = new QStandardItemModel(this); + this->setModel(listmodel); + + Q_FOREACH (QString desktopfp, data) { + QStandardItem *item = new QStandardItem; + item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + bool appDis = appDisable(desktopfp); + item->setData(QVariant::fromValue(appDis), Qt::UserRole + 2); + listmodel->appendRow(item); + } + + m_delegate = new TabletFullItemDelegate(this, m_pageNum); + this->setItemDelegate(m_delegate); +} + +void TabletListView::updateData(QStringList data) +{ + listmodel->clear(); + + Q_FOREACH (QString desktopfp, data) { + QStandardItem *p_item = new QStandardItem; + p_item->setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + bool appDis = appDisable(desktopfp); + p_item->setData(QVariant::fromValue(appDis), Qt::UserRole + 2); + listmodel->appendRow(p_item); + } + + m_delegate = new TabletFullItemDelegate(this, m_pageNum); + this->setItemDelegate(m_delegate); +} + +bool TabletListView::appDisable(QString desktopfp) //判断是否是禁用应用(这个还有问题暂时不会用) +{ + QString str; + //打开文件.desktop + GError **pp_error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *p_keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *p_filepath = fpbyte.data(); + g_key_file_load_from_file(p_keyfile, p_filepath, flags, pp_error); + char *p_name = g_key_file_get_locale_string(p_keyfile, "Desktop Entry", "Exec", nullptr, nullptr); + //取出value值 + QString execnamestr = QString::fromLocal8Bit(p_name); + //处理value值 + str = execnamestr; + // str = execnamestr.section(' ', 0, 0); + // QStringList list = str.split('/'); + // str = list[list.size()-1]; + //关闭文件 + g_key_file_free(p_keyfile); + QString desktopfp1 = str; + disableSetting->beginGroup("application"); + //判断 + bool bo = disableSetting->contains(desktopfp1.toLocal8Bit().data());// iskey + bool bo1 = disableSetting->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool();//isvalue + disableSetting->endGroup(); + + //qDebug()<setData(QVariant::fromValue(desktopfp), Qt::DisplayRole); + m_item->setData(QVariant::fromValue(0), Qt::UserRole); + listmodel->appendRow(m_item); +} + +/*点击执行*/ +void TabletListView::onClicked(QModelIndex index) +{ + QVariant var = listmodel->data(index, Qt::DisplayRole); + + if (var.isValid()) { + QString desktopfp = var.value(); + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + setting->beginGroup("groupname"); + bool iscontain = setting->contains(desktopfn); + setting->endGroup(); + + if (!appDisable(desktopfp)) { + Q_EMIT sendHideMainWindowSignal(); + } + + if (iscontain) { + // Q_EMIT sendGroupClickSignal(desktopfn); + } else { + Q_EMIT sendItemClickedSignal(desktopfp); + } + } +} + +bool TabletListView::uninstall(QString desktopfp) //判断是否可以卸载 +{ + syssetting->beginGroup("ukui-menu-sysapplist"); + QStringList sysapplist = syssetting->allKeys(); + syssetting->sync(); + syssetting->endGroup(); + QString appstr = desktopfp.section(' ', 0, 0); + QStringList strlist = appstr.split('/'); + appstr = strlist[strlist.size() - 1]; + + if (sysapplist.contains(appstr)) { + myDebug() << "默认应用"; + return 0; + } + + return 1; +} + +/*右键*/ +void TabletListView::rightClickedSlot(const QPoint &pos) +{ + Q_UNUSED(pos) + this->model()->setData(this->indexAt(right_pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); + + if (!(this->selectionModel()->selectedIndexes().isEmpty())) { + QModelIndex index = this->currentIndex(); + QVariant var = listmodel->data(index, Qt::DisplayRole); + QString desktopfp = var.value(); + bool isinstall = uninstall(desktopfp);//判断是否为安装的应用可卸载 + int ret = menu->showAppBtnMenu(desktopfp, isinstall); + + switch (ret) { + case 1: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 2: + Q_EMIT sendUpdateAppListSignal(); + break; + + case 6: + Q_EMIT sendHideMainWindowSignal(); + break; + + case 7: + Q_EMIT sendHideMainWindowSignal(); + break; + + default: + break; + } + + right_iconClick = false; + this->selectionModel()->clear(); + } +} + +void TabletListView::mousePressEvent(QMouseEvent *event) +{ + myDebug() << "鼠标点击事件触发"; + pressedpos = event->pos(); + + if (event->button() == Qt::LeftButton) { + //左键 + myDebug() << "左键点击,当前点坐标" << event->pos(); + + if (((this->indexAt(event->pos()).isValid()) && (m_pageNum == FIRSTPAGE) && (((pressedpos.x() % Style::TabletItemSizeWidthFirst) >= Style::FirstPageSpace) && + ((pressedpos.x() % Style::TabletItemSizeWidthFirst) <= (Style::FirstPageSpace + Style::AppListIconSize)) && + ((pressedpos.y() % Style::AppListItemSizeHeight) >= Style::AppTopSpace) && + ((pressedpos.y() % Style::AppListItemSizeHeight) <= (Style::AppTopSpace + Style::AppListIconSize)))) || + ((this->indexAt(event->pos()).isValid()) && (m_pageNum == OTHERPAGE) && + (pressedpos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace && + pressedpos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize && + pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && + pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) { + pressApp = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole); + iconClick = true; + startPos = event->pos(); + listmodel->setData(this->indexAt(pressedpos), 1, Qt::UserRole + 2); + repaint(); + } else { + iconClick = false; + listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); + pressedpos = event->pos(); + moveing_pressedpos = pressedpos; + press_time = event->timestamp(); + } + } else if (event->button() == Qt::RightButton) { + //右键 + myDebug() << "右键点击,当前点坐标" << event->pos(); + + if (((this->indexAt(event->pos()).isValid()) && (m_pageNum == FIRSTPAGE) && ((pressedpos.x()) % Style::TabletItemSizeWidthFirst >= Style::FirstPageSpace && + (pressedpos.x()) % Style::TabletItemSizeWidthFirst <= Style::FirstPageSpace + Style::AppListIconSize && + pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && + pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize)) || + ((this->indexAt(event->pos()).isValid()) && (m_pageNum == OTHERPAGE) && + (pressedpos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace && + pressedpos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize && + pressedpos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && + pressedpos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) { + pressApp = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole); + right_iconClick = true; + right_pressedpos = pressedpos; + listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(1), Qt::UserRole + 2); + this->selectionModel()->setCurrentIndex(this->indexAt(event->pos()), QItemSelectionModel::SelectCurrent); + } else { + right_iconClick = false; + listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); + } + } + + event->accept(); +} + +void TabletListView::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() & Qt::LeftButton & this->indexAt(event->pos()).isValid()) { + if (iconClick) { + if ((event->pos() - startPos).manhattanLength() >= QApplication::startDragDistance()) { + myDebug() << "进入拖拽事件"; + //this->setCursor(Qt::ClosedHandCursor); + QModelIndex theDragIndex = indexAt(startPos); + theDragRow = theDragIndex.row(); + //[1]把拖拽数据放在QMimeData容器中 + QString desktopfp = this->indexAt(startPos).data(Qt::DisplayRole).value(); + QByteArray itemData = desktopfp.toLocal8Bit();; + QMimeData *mimeData = new QMimeData; + ThumbNail *dragImage = new ThumbNail(this); + QDrag *drag = new QDrag(this); + mimeData->setData("INFO", itemData); + //[2]设置拖拽时的缩略图 + dragImage->setupthumbnail(desktopfp); + QPixmap pixmap = dragImage->grab(); + drag->setMimeData(mimeData); + drag->setPixmap(pixmap); + drag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2)); + m_isDraging = true; + + if (drag->exec(Qt::MoveAction) == Qt::MoveAction) { + } + + m_isDraging = false; + delete drag; //setMimeData 使得mimeData归drag所有,不需要单独进行delele处理 + delete dragImage; + drag = nullptr; + dragImage = nullptr; + } + } + } + + event->ignore(); +} +void TabletListView::dragMoveEvent(QDragMoveEvent *event) +{ + moveing_pressedpos = event->pos(); + + //拖拽特效绘制 + if (m_flat == true) { + m_flat = false; + m_time->start(500); + + if (m_pageNum == OTHERPAGE) { + if (event->pos().x() >= (Style::OtherPageViewWidth - (Style::OtherPageSpace / 2)) || event->pos().x() <= (Style::OtherPageSpace / 2)) { + if (event->pos().x() <= (Style::OtherPageSpace / 2)) { + Q_EMIT pagenumchanged(false); + } + + if (event->pos().x() >= (Style::OtherPageViewWidth - (Style::OtherPageSpace / 2))) { + Q_EMIT pagenumchanged(true); + } + } + } else { + if (event->pos().x() >= (Style::FirsPageViewWidth - (Style::FirstPageSpace / 2))) { + Q_EMIT pagenumchanged(true); + } + } + } + + event->accept(); +} + +void TabletListView::dragEnterEvent(QDragEnterEvent *event) +{ + iconClick = true; + event->accept(); +} + +void TabletListView::dropEvent(QDropEvent *event) +{ + dropPos = event->pos(); + pressDesktopfp = (QString)event->mimeData()->data("INFO"); + insertApplication(startPos, dropPos); + this->model()->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); +} +void TabletListView::mouseReleaseEvent(QMouseEvent *e) +{ + releasepos = e->pos();//释放的位置坐标 + + if (iconClick) { + if (e->button() == Qt::LeftButton) { + if (qAbs(releasepos.x() - pressedpos.x()) <= 5 && qAbs(releasepos.y() - pressedpos.y()) <= 5 + && this->indexAt(releasepos) == this->indexAt(pressedpos)) { + QEventLoop loop1; + QTimer::singleShot(200, &loop1, SLOT(quit())); + loop1.exec(); + listmodel->setData(this->indexAt(pressedpos), 0, Qt::UserRole + 2); + QEventLoop loop; + QTimer::singleShot(200, &loop, SLOT(quit())); + loop.exec(); + Q_EMIT onClicked(this->indexAt(e->pos())); + } + } + } else { + if (e->button() == Qt::LeftButton) { + int dist_y = releasepos.y() - pressedpos.y(); + int dist_x = releasepos.x() - pressedpos.x(); + + if (((pressedpos - releasepos).manhattanLength() <= QApplication::startDragDistance() || pressedpos == releasepos)) { + qDebug() << "sendHideMainWindowSignal"; + Q_EMIT sendHideMainWindowSignal(); + } else { + if (2 * qAbs(dist_x) >= qAbs(dist_y)) { + if (qAbs(dist_x) >= 80) { + if ((dist_x >= 80)) { + Q_EMIT pagenumchanged(false); + } else if ((dist_x <= -80)) { + Q_EMIT pagenumchanged(true); + } + } + } + } + } + + if (right_iconClick) { + this->selectionModel()->setCurrentIndex(this->indexAt(right_pressedpos), QItemSelectionModel::SelectCurrent); + Q_EMIT customContextMenuRequested(right_pressedpos); + } + } + + e->accept(); + listmodel->setData(this->indexAt(pressedpos), QVariant::fromValue(0), Qt::UserRole + 2); + iconClick = false;//是否点钟图标 + right_iconClick = false;//是否右键点中图标 + theDragRow = -1; + this->setCursor(Qt::ArrowCursor); +} + +//拖拽移动的时候,如果不是应用的话,就交换位置 +void TabletListView::insertApplication(QPoint pressedpos, QPoint releasepos) +{ + if (false) {//不同分类分页显示备用 + QVariant var2 = pressApp; + QString desktopfp2 = var2.value(); + QFileInfo fileInfo2(desktopfp2); + QString desktopfn2 = fileInfo2.fileName(); + + if (m_pageNum == FIRSTPAGE) { + releasepos.setX(releasepos.x() + Style::OtherPageSpace); + } else { + releasepos.setX(releasepos.x() + Style::FirstPageSpace); + } + + QVariant var3 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//释放位置右侧有应用 + QString desktopfp3 = var3.value();//释放位置的应用 + QFileInfo fileInfo3(desktopfp3); + QString desktopfn3 = fileInfo3.fileName(); + + if (m_pageNum == FIRSTPAGE) { + releasepos.setX(releasepos.x() - (Style::OtherPageSpace * 2)); + } else { + releasepos.setX(releasepos.x() - (Style::FirstPageSpace * 2)); + } + + QVariant var4 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//右侧没有左侧有 + QString desktopfp4 = var4.value();//释放位置的应用 + QFileInfo fileInfo4(desktopfp4); + QString desktopfn4 = fileInfo4.fileName(); + //qDebug()<<"4rel"<beginGroup("application"); + QStringList keyList = setting->allKeys(); + setting->sync(); + setting->endGroup(); + + if (keyList.contains(desktopfn2)) { + editString = "application"; + } + + setting->beginGroup("tencent"); + QStringList keyTecentList = setting->allKeys(); + setting->sync(); + setting->endGroup(); + + if (keyTecentList.contains(desktopfn2)) { + editString = "tencent"; + } + + setting->beginGroup("thirdParty"); + QStringList keyThirdList = setting->allKeys(); + setting->sync(); + setting->endGroup(); + + if (keyThirdList.contains(desktopfn2)) { + editString = "thirdParty"; + } + + setting->beginGroup("customized"); + QStringList customizedList = setting->allKeys(); + setting->sync(); + setting->endGroup(); + + if (customizedList.contains(desktopfn2)) { + editString = "customized"; + } + + if (var3.isValid() && desktopfp3 != desktopfp2) { + setting->beginGroup(editString); + int indexPre = setting->value(desktopfn2).toInt(); + int indexRel = setting->value(desktopfn3).toInt(); + QStringList keyList = setting->allKeys(); + + if (indexPre > indexRel) { + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() >= indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); + } + } + + setting->setValue(desktopfn2, indexRel); + } else if (indexPre < indexRel) { + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() < indexRel) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); + } + } + + setting->setValue(desktopfn2, indexRel - 1); + } + + setting->sync(); + setting->endGroup(); + } else if (var4.isValid() && desktopfp4 != desktopfp2) { + setting->beginGroup(editString); + int indexPre = setting->value(desktopfn2).toInt(); + int indexRel = setting->value(desktopfn4).toInt(); + QStringList keyList = setting->allKeys(); + + if (indexPre < indexRel) { + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() <= indexRel) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); + } + } + + setting->setValue(desktopfn2, indexRel); + } else if (indexPre > indexRel) { + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() > indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); + } + } + + setting->setValue(desktopfn2, indexRel + 1); + } + + setting->sync(); + setting->endGroup(); + } + + Q_EMIT sendUpdateAppListSignal(); + } else { + QFileInfo fileInfo2(pressDesktopfp); + QString desktopfn2 = fileInfo2.fileName(); + + if (((this->indexAt(releasepos).isValid()) && (m_pageNum == FIRSTPAGE) && ((releasepos.x()) % Style::TabletItemSizeWidthFirst >= Style::FirstPageSpace && + (releasepos.x()) % Style::TabletItemSizeWidthFirst <= Style::FirstPageSpace + Style::AppListIconSize && + releasepos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && + releasepos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize)) || + ((this->indexAt(releasepos).isValid()) && (m_pageNum == OTHERPAGE) && + (releasepos.x() % Style::TabletItemSizeWidthOther >= Style::OtherPageSpace && + releasepos.x() % Style::TabletItemSizeWidthOther <= Style::OtherPageSpace + Style::AppListIconSize && + releasepos.y() % Style::AppListItemSizeHeight >= Style::AppTopSpace && + releasepos.y() % Style::AppListItemSizeHeight <= Style::AppTopSpace + Style::AppListIconSize))) { + return; + } + + if (m_pageNum == FIRSTPAGE) { + releasepos.setX(releasepos.x() + Style::FirstPageSpace); + } else { + releasepos.setX(releasepos.x() + Style::OtherPageSpace); + } + + QVariant var3 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//释放位置右侧有应用 + QString desktopfp3 = var3.value();//释放位置的应用 + QFileInfo fileInfo3(desktopfp3); + QString desktopfn3 = fileInfo3.fileName(); + + if (m_pageNum == FIRSTPAGE) { + releasepos.setX(releasepos.x() - Style::FirstPageSpace * 2); + } else { + releasepos.setX(releasepos.x() - Style::OtherPageSpace * 2); + } + + QVariant var4 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole);//右侧没有左侧有 + QString desktopfp4 = var4.value();//释放位置的应用 + QFileInfo fileInfo4(desktopfp4); + QString desktopfn4 = fileInfo4.fileName(); + + //qDebug()<<"4rel"<beginGroup("application"); + int indexPre = setting->value(desktopfn2).toInt(); + int indexRel = setting->value(desktopfn3).toInt(); + QStringList keyList = setting->allKeys(); + + if (indexPre > indexRel) { + myDebug() << ">"; + + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() >= indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); + } + } + + setting->setValue(desktopfn2, indexRel); + } else if (indexPre < indexRel) { + qDebug() << "<"; + + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() < indexRel) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); + } + } + + setting->setValue(desktopfn2, indexRel - 1); + } + + setting->sync(); + setting->endGroup(); + } else if (var4.isValid() && desktopfp4 != pressDesktopfp) { + setting->beginGroup("application"); + int indexPre = setting->value(desktopfn2).toInt(); + int indexRel = setting->value(desktopfn4).toInt(); + QStringList keyList = setting->allKeys(); + + if (indexPre < indexRel) { + // qDebug()<<"4 <"; + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() > indexPre && setting->value(keyList.at(i)).toInt() <= indexRel) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() - 1); + } + } + + setting->setValue(desktopfn2, indexRel); + } else if (indexPre > indexRel) { + qDebug() << ">"; + + for (int i = 0; i < keyList.count(); i++) { + if (setting->value(keyList.at(i)).toInt() > indexRel && setting->value(keyList.at(i)).toInt() < indexPre) { + setting->setValue(keyList.at(i), setting->value(keyList.at(i)).toInt() + 1); + } + } + + setting->setValue(desktopfn2, indexRel + 1); + } + + setting->sync(); + setting->endGroup(); + } + + // } + Q_EMIT sendUpdateAppListSignal(); + } +} + +//拖拽移动的时候,如果是应用,就组成组合框 +void TabletListView::mergeApplication(QPoint pressedpos, QPoint releasepos) +{ + QVariant var1 = listmodel->data(this->indexAt(releasepos), Qt::DisplayRole); + QVariant var2 = listmodel->data(this->indexAt(pressedpos), Qt::DisplayRole); + + if (var1 != var2) { + QString desktopfp1 = var1.value(); //鼠标释放位置的应用 + QFileInfo fileInfo1(desktopfp1); + QString desktopfn1 = fileInfo1.fileName(); + QString desktopfp2 = var2.value(); //鼠标点击位置的应用 + QFileInfo fileInfo2(desktopfp2); + QString desktopfn2 = fileInfo2.fileName(); + setting->beginGroup("groupname"); + bool isgroup = setting->contains(desktopfn2); + setting->endGroup(); + + if (!isgroup) { + // qDebug() <<"拖拽"; + //合并 + setting->beginGroup("groupname"); + QStringList groupList = setting->allKeys(); + bool iscontain = setting->contains(desktopfn1); + setting->endGroup(); + + if (iscontain) { //组存在,把应用加入组中,同时去掉position里的键值。 + qDebug() << "组存在,找到这个组,把应用加入里边"; + setting->beginGroup(desktopfn1); + setting->setValue(desktopfn2, setting->allKeys().count()); + setting->sync(); + setting->endGroup(); + setting->beginGroup("application"); + int indexPre = setting->value(desktopfn2).toInt(); + QStringList appList = setting->allKeys(); + + for (int i = 0; i < appList.count(); i++) { + if (setting->value(appList.at(i)).toInt() >= indexPre) { + setting->setValue(appList.at(i), setting->value(appList.at(i)).toInt() - 1); + } + } + + setting->remove(desktopfn2); + setting->sync(); + setting->endGroup(); + listmodel->removeRow(this->indexAt(pressedpos).row()); + this->viewport()->update(); + } else { //如果组不存在的话 + setting->beginGroup("groupname"); + QString group = QString("group%1").arg(groupList.count() + 1); + QString groupname = QString("group%1").arg(groupList.count() + 1); + setting->setValue(group, groupname); + setting->sync(); + setting->endGroup(); + setting->beginGroup(group); + setting->setValue(desktopfn2, 0); + setting->setValue(desktopfn1, 1); + setting->sync(); + setting->endGroup(); + setting->beginGroup("application"); + int indexPre = setting->value(desktopfn2).toInt(); + int indexRel = setting->value(desktopfn1).toInt(); + setting->setValue(groupname, indexRel); + QStringList appList = setting->allKeys(); + + for (int i = 0; i < appList.count(); i++) { + if (setting->value(appList.at(i)).toInt() >= indexPre) { + setting->setValue(appList.at(i), setting->value(appList.at(i)).toInt() - 1); + } + } + + setting->remove(desktopfn1); + setting->remove(desktopfn2); + setting->sync(); + setting->endGroup(); + listmodel->removeRow(this->indexAt(pressedpos).row()); + listmodel->removeRow(this->indexAt(releasepos).row()); + listmodel->insertRow(this->indexAt(releasepos).row()); + QVariant variant = QVariant::fromValue(QString("usr/share/application/%1").arg(group)); + listmodel->setData(this->indexAt(releasepos), variant); + } + } + } +} + + + diff --git a/src/UserInterface/ListView/tabletlistview.h b/src/UserInterface/ListView/tabletlistview.h new file mode 100755 index 0000000..5980d2c --- /dev/null +++ b/src/UserInterface/ListView/tabletlistview.h @@ -0,0 +1,145 @@ +/* + * 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 +#include "ukuimenuinterface.h" +#include "rightclickmenu.h" +//#include "src/GroupListView/grouplistview.h" +//#include "src/GroupListView/grouplistwidget.h" +#include +#include +#include +#include +#include "tablet_full_itemdelegate.h" +#include "style.h" +#include "thumbnail.h" +#include +#include +#include +#include +#include +#include "full_item_delegate.h" +#include "tabletrightclickmenu.h" +#include "klistview.h" + +enum Page { + FIRSTPAGE = 0, + OTHERPAGE +}; + +class TabletListView : public QListView +{ + Q_OBJECT +public: + TabletListView(QWidget *parent, int pageNum); + ~TabletListView(); + + void addData(QStringList data);//字母排序模块添加数据 + void updateData(QStringList data); + void insertData(QString desktopfp); + bool appDisable(QString desktopfp);//判断是否是禁用的应用 + bool isDraging() + { + return m_isDraging; + } + QStandardItemModel *listmodel = nullptr; +// void paintPixmap(const QModelIndex &index,QPoint position); + +protected: + void initWidget(); + void mouseReleaseEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *event); +// void wheelEvent(QWheelEvent *e); + void mouseMoveEvent(QMouseEvent *event); + void paintGroupItem(const QModelIndex &index, QString group); + + void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event) override; +// void dragLeaveEvent(QDragLeaveEvent *event) override; + void dragMoveEvent(QDragMoveEvent *event) override; + + void insertApplication(QPoint pressedpos, QPoint releasepos); + void mergeApplication(QPoint pressedpos, QPoint releasepos); + + +private: + QVariantAnimation *m_animation = nullptr; //翻页动画 + TabletRightClickMenu *menu = nullptr; //右键菜单 + TabletFullItemDelegate *m_delegate = nullptr; + QStringList data; + UkuiMenuInterface *pUkuiMenuInterface = nullptr; + int m_pageNum = 0; + + /*鼠标事件的参数变量*/ + int dist;//翻页的鼠标移动长度 + + QPoint pressedpos; //鼠标按下的位置 + QPoint releasepos; //鼠标释放的位置 + QPoint moveing_pressedpos;// 鼠标移动的位置 + QPoint right_pressedpos;// 右键点击的位置 + + + QPoint startPos;//开始点击的位置 + QVariant pressApp;//点击位置的app想、 + QPoint dropPos;//dropPos的位置 + + //拖动 + int theDragRow = -1; + bool iconClick = false; //是否点钟图标 + bool right_iconClick = false; //是否右键点中图标 + + ulong press_time = -1; + ulong move_time = -1; + ulong release_time = -1; + + + + QSettings *setting = nullptr; //应用列表settings + QSettings *disableSetting = nullptr; //禁用的settings + QSettings *syssetting = nullptr; //不可卸载列表 + + + //鼠标滚轮灵密度限制 + QTimer *m_time = nullptr; + bool m_flat = true; + + QGSettings *tabletMode = nullptr; + + bool m_isDraging = false; + + QString pressDesktopfp; + +private Q_SLOTS: + void onClicked(QModelIndex index);//点击item + void rightClickedSlot(const QPoint &pos);//右键菜单 + bool uninstall(QString desktopfp); + +Q_SIGNALS: + void sendItemClickedSignal(QString arg);//发送item点击信号 + void sendGroupClickSignal(QString desktopfn);//发送组合框点击信号 + void sendHideMainWindowSignal();//界面隐藏信号 + void sendUpdateAppListSignal();//界面更新信号 + void pagenumchanged(bool nextPage);//页面数改变信号 + void sendPageLeft(); + void sendPageRight(); //右滑页面展开 + +}; + +#endif // FULLLISTVIEW_H diff --git a/src/UtilityFunction/classifybtnscrollarea.cpp b/src/UserInterface/Other/classify_btn_scrollarea.cpp old mode 100644 new mode 100755 similarity index 53% rename from src/UtilityFunction/classifybtnscrollarea.cpp rename to src/UserInterface/Other/classify_btn_scrollarea.cpp index ea0e400..95c2619 --- a/src/UtilityFunction/classifybtnscrollarea.cpp +++ b/src/UserInterface/Other/classify_btn_scrollarea.cpp @@ -16,57 +16,58 @@ * */ -#include "classifybtnscrollarea.h" -#include "utility.h" +#include "classify_btn_scrollarea.h" +#include "src/UtilityFunction/utility.h" #include #include #include -ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid() +ClassifyBtnScrollAreaWid::ClassifyBtnScrollAreaWid(QWidget *parent): + QWidget(parent) { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); + this->setAutoFillBackground(false); } void ClassifyBtnScrollAreaWid::paintEvent(QPaintEvent *event) { - double transparency=getTransparency(); + double transparency = getTransparency(); QPainter painter(this); - -// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) -// { -// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); -// if(gsetting.keys().contains(QString("effect"))) -// { -// if(gsetting.get("effect").toBool()) -// { -// painter.setBrush(Qt::black); -// painter.setPen(Qt::transparent); -// painter.setOpacity(0.25); -// painter.drawRect(this->rect()); -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else{ - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); -// } + // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) + // { + // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); + // if(gsetting.keys().contains(QString("effect"))) + // { + // if(gsetting.get("effect").toBool()) + // { + // painter.setBrush(Qt::black); + // painter.setPen(Qt::transparent); + // painter.setOpacity(0.25); + // painter.drawRect(this->rect()); + // } + // else + // { + // painter.setBrush(this->palette().base()); + // painter.setPen(Qt::transparent); + // painter.setOpacity(transparency); + // painter.drawRect(this->rect()); + // } + // } + // else + // { + // painter.setBrush(this->palette().base()); + // painter.setPen(Qt::transparent); + // painter.setOpacity(transparency); + // painter.drawRect(this->rect()); + // } + // } + // else{ + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + // } QWidget::paintEvent(event); } @@ -103,8 +104,8 @@ ClassifyBtnScrollArea::ClassifyBtnScrollArea(QWidget *parent): void ClassifyBtnScrollArea::initWid() { - this->verticalScrollBar()->setHidden(true); - this->horizontalScrollBar()->setHidden(true); + this->verticalScrollBar()->setHidden(false); + this->horizontalScrollBar()->setHidden(false); this->setWidgetResizable(true); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); diff --git a/src/UtilityFunction/classifybtnscrollarea.h b/src/UserInterface/Other/classify_btn_scrollarea.h old mode 100644 new mode 100755 similarity index 85% rename from src/UtilityFunction/classifybtnscrollarea.h rename to src/UserInterface/Other/classify_btn_scrollarea.h index 41b9bb2..743c8d1 --- a/src/UtilityFunction/classifybtnscrollarea.h +++ b/src/UserInterface/Other/classify_btn_scrollarea.h @@ -25,17 +25,16 @@ class ClassifyBtnScrollAreaWid: public QWidget { public: - ClassifyBtnScrollAreaWid(); + ClassifyBtnScrollAreaWid(QWidget *parent); protected: - void paintEvent(QPaintEvent* event); - // void keyPressEvent(QKeyEvent* e); + void paintEvent(QPaintEvent *event); }; class ClassifyBtnScrollArea : public QScrollArea { public: - explicit ClassifyBtnScrollArea(QWidget* parent=nullptr); + explicit ClassifyBtnScrollArea(QWidget *parent = nullptr); protected: void initWid(); diff --git a/src/UserInterface/Other/lettertooltip.cpp b/src/UserInterface/Other/lettertooltip.cpp new file mode 100755 index 0000000..176b48b --- /dev/null +++ b/src/UserInterface/Other/lettertooltip.cpp @@ -0,0 +1,54 @@ +#include "lettertooltip.h" +#include +#include +#include + +LetterToolTip::LetterToolTip(QWidget *parent): + QDialog(parent) +{ + this->setWindowFlags(/*Qt::FramelessWindowHint *//*| */Qt::X11BypassWindowManagerHint); + this->setAttribute(Qt::WA_TranslucentBackground, true); + this->setContentsMargins(0, 0, 0, 0); + this->setAutoFillBackground(false); + this->setFixedSize(83, 46); + QHBoxLayout *mainlayout = new QHBoxLayout; + this->setLayout(mainlayout); + mainlayout->setAlignment(Qt::AlignCenter); + mainlayout->addWidget(&textLabel); + // this->raise(); + // this->activateWindow(); +} + +LetterToolTip::~LetterToolTip() +{ +} + +void LetterToolTip::setText(QString str) +{ + QFont font; + QPalette pa; + pa.setColor(QPalette::WindowText, Qt::black); + font.setPixelSize(30); + font.setBold(true); + textLabel.setContentsMargins(0, 0, 0, 0); + textLabel.setAlignment(Qt::AlignCenter); + textLabel.setFont(font); + textLabel.setPalette(pa); + textLabel.setText(str); +} + +void LetterToolTip::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.setRenderHints(QPainter::Antialiasing); + painter.setPen(Qt::NoPen); + painter.setBrush(QColor("#F2FAFF")); + painter.drawRoundedRect(5, 0, width() - 5, height(), 4, 4); + QPointF points[3] = { + QPointF(0, height() / 2), + QPointF(5, height() / 2 - 5), + QPointF(5, height() / 2 + 5), + }; + painter.drawPolygon(points, 3); + QWidget::paintEvent(event); +} diff --git a/src/UserInterface/Other/lettertooltip.h b/src/UserInterface/Other/lettertooltip.h new file mode 100755 index 0000000..4f64e0a --- /dev/null +++ b/src/UserInterface/Other/lettertooltip.h @@ -0,0 +1,24 @@ +#ifndef LETTERTOOLTIP_H +#define LETTERTOOLTIP_H +#include +#include + +class LetterToolTip : public QDialog +{ + Q_OBJECT +public: + LetterToolTip(QWidget *parent = nullptr); + + ~LetterToolTip(); + + void setText(QString str); + +protected: + + void paintEvent(QPaintEvent *event); + +private: + QLabel textLabel; +}; + +#endif // LETTERTOOLTIP_H diff --git a/src/UserInterface/Other/rotationlabel.cpp b/src/UserInterface/Other/rotationlabel.cpp new file mode 100644 index 0000000..0c08e2e --- /dev/null +++ b/src/UserInterface/Other/rotationlabel.cpp @@ -0,0 +1,38 @@ +#include "rotationlabel.h" +#include +#include + +RotationLabel::RotationLabel(QWidget *parent) + : QLabel(parent) +{ + this->setFrameShape(QFrame::NoFrame); + this->setContentsMargins(0, 0, 0, 0); +} + +void RotationLabel::setRotation(int rot) +{ + m_rotation = rot; + this->update(); + qDebug() << m_rotation; +} + +int RotationLabel::rotation() +{ + return m_rotation; +} + +void RotationLabel::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.setRenderHints(QPainter::SmoothPixmapTransform, true); + painter.translate(rect().width() / 2, rect().height() / 2); + painter.rotate(m_rotation); + painter.translate(-rect().width() / 2, -rect().height() / 2); + painter.drawPixmap(rect().adjusted(0, 9, 0, -9), m_pixmap); + return QLabel::paintEvent(event); +} + +void RotationLabel::setIcon(const QPixmap &pixmap) +{ + m_pixmap = pixmap; +} diff --git a/src/UserInterface/Other/rotationlabel.h b/src/UserInterface/Other/rotationlabel.h new file mode 100644 index 0000000..f99cdbb --- /dev/null +++ b/src/UserInterface/Other/rotationlabel.h @@ -0,0 +1,21 @@ +#ifndef ROTATIONLABEL_H +#define ROTATIONLABEL_H +#include + +class RotationLabel : public QLabel +{ + Q_OBJECT + Q_PROPERTY(int rotation READ rotation WRITE setRotation) //旋转 +public: + RotationLabel(QWidget *parent = nullptr); + void setIcon(const QPixmap &pixmap); +protected: + int rotation(); + void setRotation(int rot); + void paintEvent(QPaintEvent *event); +private: + int m_rotation = 0; + QPixmap m_pixmap; +}; + +#endif // ROTATIONLABEL_H diff --git a/src/UtilityFunction/scrollarea.cpp b/src/UserInterface/Other/scrollarea.cpp old mode 100644 new mode 100755 similarity index 50% rename from src/UtilityFunction/scrollarea.cpp rename to src/UserInterface/Other/scrollarea.cpp index 3d9bee5..65c26e5 --- a/src/UtilityFunction/scrollarea.cpp +++ b/src/UserInterface/Other/scrollarea.cpp @@ -20,9 +20,10 @@ #include #include #include -#include "utility.h" +#include "src/UtilityFunction/utility.h" -ScrollAreaWid::ScrollAreaWid() +ScrollAreaWid::ScrollAreaWid(QWidget *parent): + QWidget(parent) { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); @@ -30,60 +31,62 @@ ScrollAreaWid::ScrollAreaWid() void ScrollAreaWid::paintEvent(QPaintEvent *event) { - double transparency=getTransparency(); + double transparency = getTransparency(); QPainter painter(this); - -// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) -// { -// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); -// if(gsetting.keys().contains(QString("effect"))) -// { -// if(gsetting.get("effect").toBool()) -// { -// painter.setBrush(Qt::black); -//// painter.setBrush(Qt::red); -// painter.setPen(Qt::transparent); -// painter.setOpacity(0.25); -// painter.drawRect(this->rect()); -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else -// { - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); -// } + // if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) + // { + // QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); + // if(gsetting.keys().contains(QString("effect"))) + // { + // if(gsetting.get("effect").toBool()) + // { + // painter.setBrush(Qt::black); + //// painter.setBrush(Qt::red); + // painter.setPen(Qt::transparent); + // painter.setOpacity(0.25); + // painter.drawRect(this->rect()); + // } + // else + // { + // painter.setBrush(this->palette().base()); + // painter.setPen(Qt::transparent); + // painter.setOpacity(transparency); + // painter.drawRect(this->rect()); + // } + // } + // else + // { + // painter.setBrush(this->palette().base()); + // painter.setPen(Qt::transparent); + // painter.setOpacity(transparency); + // painter.drawRect(this->rect()); + // } + // } + // else + // { + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + // } QWidget::paintEvent(event); } ScrollArea::ScrollArea() { - this->verticalScrollBar()->setVisible(false); - this->setFocusPolicy(Qt::NoFocus); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + // this->verticalScrollBar()->setVisible(false); + // this->setFocusPolicy(Qt::NoFocus); + //// this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + this->setFixedWidth(1330); + // this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); this->setFrameShape(QFrame::NoFrame); - this->verticalScrollBar()->setProperty("drawScrollBarGroove",false); - this->verticalScrollBar()->setAttribute(Qt::WA_TranslucentBackground, false); + // this->verticalScrollBar()->setProperty("drawScrollBarGroove",false); + // this->verticalScrollBar()->setAttribute(Qt::WA_TranslucentBackground, false); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->verticalScrollBar()->setVisible(false); //滚动条设置 - QPalette p=this->verticalScrollBar()->palette(); + QPalette p = this->verticalScrollBar()->palette(); QColor color(255, 255, 255); color.setAlphaF(0.25); p.setColor(QPalette::Active, QPalette::Button, color); @@ -102,7 +105,7 @@ void ScrollArea::setFocusToPreChild() void ScrollArea::enterEvent(QEvent *e) { Q_UNUSED(e); - this->verticalScrollBar()->setVisible(true); + // this->verticalScrollBar()->setVisible(true); } //void ScrollArea::keyPressEvent(QKeyEvent* e) @@ -135,10 +138,8 @@ void ScrollArea::leaveEvent(QEvent *e) void ScrollArea::scrollContentsBy(int dx, int dy) { - QScrollArea::scrollContentsBy(dx,dy); - + QScrollArea::scrollContentsBy(dx, dy); Q_EMIT requestUpdate(); - -// update(); -// viewport()->update(); + // update(); + // viewport()->update(); } diff --git a/src/UtilityFunction/scrollarea.h b/src/UserInterface/Other/scrollarea.h old mode 100644 new mode 100755 similarity index 84% rename from src/UtilityFunction/scrollarea.h rename to src/UserInterface/Other/scrollarea.h index 730ccc0..96a5f57 --- a/src/UtilityFunction/scrollarea.h +++ b/src/UserInterface/Other/scrollarea.h @@ -28,10 +28,10 @@ class ScrollAreaWid: public QWidget { public: - ScrollAreaWid(); + ScrollAreaWid(QWidget *parent); protected: - void paintEvent(QPaintEvent* event); + void paintEvent(QPaintEvent *event); }; class ScrollArea : public QScrollArea @@ -46,9 +46,9 @@ Q_SIGNALS: void requestUpdate(); protected: - void enterEvent(QEvent* e) Q_DECL_OVERRIDE; - void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; -// void keyPressEvent(QKeyEvent* e) Q_DECL_OVERRIDE; + void enterEvent(QEvent *e) Q_DECL_OVERRIDE; + void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; + // void keyPressEvent(QKeyEvent* e) Q_DECL_OVERRIDE; void scrollContentsBy(int dx, int dy) override; private: diff --git a/src/UserInterface/RightClickMenu/menubox.cpp b/src/UserInterface/RightClickMenu/menubox.cpp new file mode 100755 index 0000000..c6f9729 --- /dev/null +++ b/src/UserInterface/RightClickMenu/menubox.cpp @@ -0,0 +1,27 @@ +#include "menubox.h" +#include +#include +#include +#include + +MenuBox::MenuBox(QWidget *parent): + QMenu(parent) +{ +} + +void MenuBox::mousePressEvent(QMouseEvent *event) +{ + if (!this->actionAt(event->pos())) { + Q_EMIT sendMainWinActiveSignal(true); + } + + qDebug() << "void MenuBox::mousePressEvent(QMouseEvent *event)"; + return QMenu::mousePressEvent(event); +} + +void MenuBox::hideEvent(QHideEvent *e) +{ + Q_EMIT sendMainWinActiveSignal(true); + return QMenu::hideEvent(e); +} + diff --git a/src/RightClickMenu/menubox.h b/src/UserInterface/RightClickMenu/menubox.h old mode 100644 new mode 100755 similarity index 71% rename from src/RightClickMenu/menubox.h rename to src/UserInterface/RightClickMenu/menubox.h index 627ed8f..ea48961 --- a/src/RightClickMenu/menubox.h +++ b/src/UserInterface/RightClickMenu/menubox.h @@ -12,12 +12,8 @@ public: protected: void mousePressEvent(QMouseEvent *event); + void hideEvent(QHideEvent *e) override; -// void mouseReleaseEvent(QMouseEvent *event); - -// void focusInEvent(QFocusEvent *event); - -// void focusOutEvent(QFocusEvent *event); public: Q_SIGNALS: void sendMainWinActiveSignal(bool flag); diff --git a/src/UserInterface/RightClickMenu/rightclickmenu.cpp b/src/UserInterface/RightClickMenu/rightclickmenu.cpp new file mode 100755 index 0000000..f274607 --- /dev/null +++ b/src/UserInterface/RightClickMenu/rightclickmenu.cpp @@ -0,0 +1,354 @@ +/* + * 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 + +RightClickMenu::RightClickMenu(QWidget *parent): + QWidget(parent) +{ + m_cmdProc = new QProcess; + m_whiteList.append("kylin-screenshot.desktop"); + m_whiteList.append("ukui-notebook.desktop"); + m_whiteList.append("ukui-clock.desktop"); + m_whiteList.append("kylin-calculator.desktop"); + m_whiteList.append("kylin-recorder.desktop"); + m_whiteList.append("kylin-software-center.desktop"); + m_whiteList.append("kylin-camera.desktop"); + m_whiteList.append("biometric-manager.desktop"); + m_whiteList.append("yhkylin-backup-tools.desktop"); + m_whiteList.append("box-manager.desktop"); + m_whiteList.append("ukui-system-monitor.desktop"); + m_whiteList.append("ksc-defender.desktop"); + m_whiteList.append("logview.desktop"); + m_whiteList.append("kylin-service-support.desktop"); + m_whiteList.append("kylin-user-guide.desktop"); + m_whiteList.append("ukui-control-center.desktop"); + m_whiteList.append("peony.desktop"); + m_whiteList.append("engrampa.desktop"); + m_ukuiMenuInterface = new UkuiMenuInterface; +} + +RightClickMenu::~RightClickMenu() +{ + delete m_cmdProc; + delete m_ukuiMenuInterface; +} + +QPixmap RightClickMenu::getIconPixmap(QString iconstr, int type) +{ + const auto ratio = devicePixelRatioF(); + QPixmap pixmap; + + if (type == 0) { + pixmap = loadSvg(iconstr, 16 * ratio); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + } else { + QIcon icon = QIcon::fromTheme(iconstr); + QPixmap pixmap_1 = icon.pixmap(QSize(16 * ratio, 16 * ratio)); + pixmap = drawSymbolicColoredPixmap(pixmap_1); + } + + return pixmap; +} + +void RightClickMenu::fixToAllActionTriggerSlot() +{ + m_actionNumber = 1; + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + updateDataBaseTableType(desktopfn, 1); +} + +void RightClickMenu::unfixedFromAllActionTriggerSlot() +{ + m_actionNumber = 2; + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + updateDataBaseTableType(desktopfn, 0); +} + +void RightClickMenu::pincToCollectionActionTriggerSlot() +{ + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + QStringList appList = getCollectAppList(); + updateDataBaseCollect(desktopfn, appList.size() + 1); + m_actionNumber = 18; +} + +void RightClickMenu::removeFromCollectionActionTriggerSlot() +{ + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + updateDataBaseCollect(desktopfn, 0); + m_actionNumber = 18; +} + +void RightClickMenu::fixToTaskbarActionTriggerSlot() +{ + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("AddToTaskbar", m_desktopfp); + m_actionNumber = 3; +} + +void RightClickMenu::unfixedFromTaskbarActionTriggerSlot() +{ + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("RemoveFromTaskbar", m_desktopfp); + m_actionNumber = 4; +} + +void RightClickMenu::addToDesktopActionTriggerSlot() +{ + QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + QFile file(m_desktopfp); + QString newname = QString(path + "/" + desktopfn); + bool ret = file.copy(QString(path + "/" + desktopfn)); + + if (ret) { + char command[200]; + sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data()); + QProcess::startDetached(QString::fromLocal8Bit(command)); + } + + m_actionNumber = 5; +} + +void RightClickMenu::uninstallActionTriggerSlot() +{ + QString cmd = QString("kylin-uninstaller %1") + .arg(m_desktopfp.toLocal8Bit().data()); + bool ret = QProcess::startDetached(cmd); + myDebug() << "卸载:" << cmd << ret; + myDebug() << "kylin-uninstaller"; + m_actionNumber = 6; +} + +void RightClickMenu::attributeActionTriggerSlot() +{ + char command[100]; + sprintf(command, "ukui-menu-attr %s", m_desktopfp.toLocal8Bit().data()); + QProcess::startDetached(command); + m_actionNumber = 7; +} + +void RightClickMenu::lockScreenActionTriggerSlot() +{ + QProcess::startDetached(QString("ukui-screensaver-command -l")); +} + +void RightClickMenu::switchUserActionTriggerSlot() +{ + QProcess::startDetached(QString("ukui-session-tools --switchuser")); +} + +void RightClickMenu::logoutActionTriggerSlot() +{ + QProcess::startDetached(QString("ukui-session-tools --logout")); +} + +void RightClickMenu::rebootActionTriggerSlot() +{ + QProcess::startDetached(QString("ukui-session-tools --reboot")); +} + +void RightClickMenu::shutdownActionTriggerSlot() +{ + QProcess::startDetached(QString("ukui-session-tools --shutdown")); +} + +void RightClickMenu::otherListActionTriggerSlot() +{ + m_actionNumber = 15; +} + +void RightClickMenu::hibernateActionTriggerSlot() +{ + QProcess::startDetached(QString("ukui-session-tools --hibernate")); +} + +void RightClickMenu::sleepActionTriggerSlot() +{ + QProcess::startDetached(QString("ukui-session-tools --suspend")); +} + +int RightClickMenu::showAppBtnMenu(const QPoint &pos, QString desktopfp) +{ + m_actionNumber = 0; + this->m_desktopfp.clear(); + this->m_desktopfp = desktopfp; + MenuBox m_showAppMenu; + connect(&m_showAppMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); + // m_showAppMenu.setWindowFlag(Qt::Popup); + //添加菜单项,指定图标、名称、响应函数 + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + + if (!checkIfLocked(desktopfn)) + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to all"), + this, SLOT(fixToAllActionTriggerSlot())); + else + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from all"), + this, SLOT(unfixedFromAllActionTriggerSlot())); + + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("CheckIfExist", desktopfp); + + if (!ret) + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg", 0)), tr("Pin to taskbar"), + this, SLOT(fixToTaskbarActionTriggerSlot())); + else + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg", 0)), tr("Unpin from taskbar"), + this, SLOT(unfixedFromTaskbarActionTriggerSlot())); + + m_showAppMenu.addAction(tr("Add to desktop shortcuts"), + this, SLOT(addToDesktopActionTriggerSlot())); + + if (!checkIfCollected(desktopfn)) { + m_showAppMenu.addAction(tr("Pin to collection"), + this, SLOT(pincToCollectionActionTriggerSlot())); + } else { + m_showAppMenu.addAction(tr("Remove from collection"), + this, SLOT(removeFromCollectionActionTriggerSlot())); + } + + //检查桌面快捷方式是否存在 + QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QString path = QString(desktopPath + "/" + QFileInfo(m_desktopfp).fileName()); + + if (QFile(path).exists()) { + m_showAppMenu.actions().at(2)->setEnabled(false); //存在时禁用 + } + + m_showAppMenu.addSeparator(); + + if (!m_whiteList.contains(desktopfn)) + m_showAppMenu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/uninstall.svg", 0)), tr("Uninstall"), + this, SLOT(uninstallActionTriggerSlot())); + + m_showAppMenu.setAttribute(Qt::WA_TranslucentBackground); + m_showAppMenu.setAttribute(Qt::WA_DeleteOnClose); + m_showAppMenu.exec(pos); + qDebug() << "RightClickMenu::showAppBtnMenu(QString desktopfp)"; + return m_actionNumber; +} + +int RightClickMenu::showShutdownMenu(const QPoint &pos, const bool &isFullWind) +{ + m_actionNumber = 0; + MenuBox m_showShutMenu; + connect(&m_showShutMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); + QDBusInterface iface(DBUS_SESSION_NAME, DBUS_SESSION_PATH, + DBUS_SESSION_INTERFACE, QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("canSwitch"); + + if (reply.isValid() && reply.value() == true) { + m_showShutMenu.addAction(QIcon(getIconPixmap("stock-people-symbolic", 1)), tr("Switch user"), + this, SLOT(switchUserActionTriggerSlot())); + } + + reply = iface.call("canHibernate"); + + if (reply.isValid() && reply.value() == true) { + m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-sleep-symbolic", 1)), tr("Hibernate"), + this, SLOT(hibernateActionTriggerSlot())); + } + + reply = iface.call("canSuspend"); + + if (reply.isValid() && reply.value() == true) { + m_showShutMenu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic", 1)), tr("Sleep"), + this, SLOT(sleepActionTriggerSlot())); + } + + m_showShutMenu.addAction(QIcon(getIconPixmap("system-lock-screen-symbolic", 1)), tr("Lock Screen"), + this, SLOT(lockScreenActionTriggerSlot())); + reply = iface.call("canLogout"); + + if (reply.isValid() && reply.value() == true) { + m_showShutMenu.addAction(QIcon(getIconPixmap("system-logout-symbolic", 1)), tr("Log Out"), + this, SLOT(logoutActionTriggerSlot())); + } + + reply = iface.call("canReboot"); + + if (reply.isValid() && reply.value() == true) { + m_showShutMenu.addAction(QIcon(getIconPixmap("system-restart-symbolic", 1)), tr("Restart"), + this, SLOT(rebootActionTriggerSlot())); + } + + reply = iface.call("canPowerOff"); + + if (reply.isValid() && reply.value() == true) { + m_showShutMenu.addAction(QIcon(getIconPixmap("exit-symbolic", 1)), tr("Power Off"), + this, SLOT(shutdownActionTriggerSlot())); + } + + m_showShutMenu.setAttribute(Qt::WA_TranslucentBackground); + m_showShutMenu.setAttribute(Qt::WA_DeleteOnClose); + m_showShutMenu.raise(); + if (isFullWind) { + m_showShutMenu.exec(QPoint(pos.x() - m_showShutMenu.sizeHint().width(), pos.y() - m_showShutMenu.sizeHint().height())); + } else { + m_showShutMenu.exec(pos); + } + + myDebug() << "RightClickMenu::showShutdownMenu()"; + return m_actionNumber; +} + +int RightClickMenu::showOtherMenu(const QPoint &pos, QString desktopfp) +{ + m_actionNumber = 0; + this->m_desktopfp.clear(); + this->m_desktopfp = desktopfp; + MenuBox m_showOtherMenu; + connect(&m_showOtherMenu, &MenuBox::sendMainWinActiveSignal, this, &RightClickMenu::sendMainWinActiveSignal); + // m_showOtherMenu.setWindowFlag(Qt::Popup); + // QDBusInterface iface("com.ukui.panel.desktop", + // "/", + // "com.ukui.panel.desktop", + // QDBusConnection::sessionBus()); + // QDBusReply ret=iface.call("CheckIfExist",this->m_desktopfp); + // if(!ret) + // menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"), + // this,SLOT(fixToTaskbarActionTriggerSlot())); + // else + // menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"), + // this,SLOT(unfixedFromTaskbarActionTriggerSlot())); + m_showOtherMenu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg", 0)), tr("Personalize this list"), + this, SLOT(otherListActionTriggerSlot())); + m_showOtherMenu.setAttribute(Qt::WA_TranslucentBackground); + m_showOtherMenu.setAttribute(Qt::WA_DeleteOnClose); + m_showOtherMenu.exec(pos); + qDebug() << "RightClickMenu::showOtherMenu(QString desktopfp)"; + return m_actionNumber; +} diff --git a/src/RightClickMenu/rightclickmenu.h b/src/UserInterface/RightClickMenu/rightclickmenu.h old mode 100644 new mode 100755 similarity index 88% rename from src/RightClickMenu/rightclickmenu.h rename to src/UserInterface/RightClickMenu/rightclickmenu.h index 5714262..4075294 --- a/src/RightClickMenu/rightclickmenu.h +++ b/src/UserInterface/RightClickMenu/rightclickmenu.h @@ -34,10 +34,14 @@ #include #include #include -#include "src/Interface/ukuimenuinterface.h" -#include "src/Style/style.h" +#include "ukuimenuinterface.h" +#include "style.h" #include "menubox.h" +#define DBUS_SESSION_NAME "org.gnome.SessionManager" +#define DBUS_SESSION_PATH "/org/gnome/SessionManager" +#define DBUS_SESSION_INTERFACE "org.gnome.SessionManager" + class RightClickMenu : public QWidget { Q_OBJECT @@ -61,7 +65,7 @@ public: * @brief Displays the power right-click menu * @return return action number */ - int showShutdownMenu(const QPoint &pos); + int showShutdownMenu(const QPoint &pos, const bool &isFullWind); /** * @brief Displays other application right-click menus * @param desktopfp: Application desktop file @@ -72,8 +76,8 @@ public: private: QString m_desktopfp; int m_actionNumber; - QProcess *m_cmdProc=nullptr; - UkuiMenuInterface *m_ukuiMenuInterface=nullptr; + QProcess *m_cmdProc = nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; QStringList m_whiteList; @@ -143,6 +147,8 @@ private Q_SLOTS: * @brief Personalize this list */ void otherListActionTriggerSlot(); + void pincToCollectionActionTriggerSlot(); + void removeFromCollectionActionTriggerSlot(); public: Q_SIGNALS: diff --git a/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp b/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp new file mode 100755 index 0000000..0143c32 --- /dev/null +++ b/src/UserInterface/RightClickMenu/tabletrightclickmenu.cpp @@ -0,0 +1,314 @@ +/* + * 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 + +TabletRightClickMenu::TabletRightClickMenu(QWidget *parent): + QWidget(parent) +{ + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + m_setting = new QSettings(path, QSettings::IniFormat); + + sprintf(m_style, "QMenu{padding-left:2px;padding-top:6px;padding-right:2px;padding-bottom:6px;border:1px solid %s;border-radius:6px;background-color:%s;}\ + QMenu::item:selected{background-color:%s;border-radius:6px;}\ + QMenu::separator{height:1px;background-color:%s;margin-top:2px;margin-bottom:2px;}", + RightClickMenuBorder, RightClickMenuBackground, RightClickMenuSelected, RightClickMenuSeparator); +} + +TabletRightClickMenu::~TabletRightClickMenu() +{ + if (m_setting) { + delete m_setting; + } + + m_setting = nullptr; +} + +QPixmap TabletRightClickMenu::getIconPixmap(QString iconstr, int type) +{ + const auto ratio = devicePixelRatioF(); + QPixmap pixmap; + + if (type == 0) { + pixmap = loadSvg(iconstr, 16 * ratio); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + } else { + QIcon icon = QIcon::fromTheme(iconstr); + QPixmap pixmap_1 = icon.pixmap(QSize(16 * ratio, 16 * ratio)); + pixmap = drawSymbolicColoredPixmap(pixmap_1); + } + + return pixmap; +} + +QPixmap TabletRightClickMenu::drawSymbolicColoredPixmap(const QPixmap &source) +{ + QColor gray(128, 128, 128); + QColor standard(31, 32, 34); + QImage img = source.toImage(); + + for (int x = 0; x < img.width(); x++) { + for (int y = 0; y < img.height(); y++) { + auto color = img.pixelColor(x, y); + + if (color.alpha() > 0) { + if (qAbs(color.red() - gray.red()) < 20 && qAbs(color.green() - gray.green()) < 20 && qAbs(color.blue() - gray.blue()) < 20) { + color.setRed(255); + color.setGreen(255); + color.setBlue(255); + img.setPixelColor(x, y, color); + } else if (qAbs(color.red() - standard.red()) < 20 && qAbs(color.green() - standard.green()) < 20 && qAbs(color.blue() - standard.blue()) < 20) { + color.setRed(255); + color.setGreen(255); + color.setBlue(255); + img.setPixelColor(x, y, color); + } else { + img.setPixelColor(x, y, color); + } + } + } + } + + return QPixmap::fromImage(img); +} + +void TabletRightClickMenu::fixToAllActionTriggerSlot() +{ + m_actionNumber = 1; + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + m_setting->beginGroup("lockapplication"); + m_setting->setValue(desktopfn, m_setting->allKeys().size()); + m_setting->sync(); + m_setting->endGroup(); + // m_setting->beginGroup("application");//wgx + // m_setting->remove(desktopfn); + // m_setting->sync(); + // m_setting->endGroup(); + // m_setting->beginGroup("datetime"); + // m_setting->remove(desktopfn); + // m_setting->sync(); + // m_setting->endGroup(); + m_setting->beginGroup("recentapp"); + m_setting->remove(desktopfn); + m_setting->sync(); + m_setting->endGroup(); +} + +void TabletRightClickMenu::unfixedFromAllActionTriggerSlot() +{ + m_actionNumber = 2; + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + m_setting->beginGroup("lockapplication"); + + Q_FOREACH (QString desktop, m_setting->allKeys()) { + if (m_setting->value(desktop).toInt() > m_setting->value(desktopfn).toInt()) { + m_setting->setValue(desktop, m_setting->value(desktop).toInt() - 1); + } + } + + m_setting->remove(desktopfn); + m_setting->sync(); + m_setting->endGroup(); + // m_setting->beginGroup("application"); + // m_setting->remove(desktopfn); + // m_setting->sync(); + // m_setting->endGroup(); + // m_setting->beginGroup("datetime"); + // m_setting->remove(desktopfn); + // m_setting->sync(); + // m_setting->endGroup(); +} + +void TabletRightClickMenu::fixToTaskbarActionTriggerSlot() +{ + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("AddToTaskbar", m_desktopfp); + //qDebug()< ret = iface.call("RemoveFromTaskbar", m_desktopfp); + m_actionNumber = 4; +} + +void TabletRightClickMenu::addToDesktopActionTriggerSlot() +{ + QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + QFileInfo fileInfo(m_desktopfp); + QString desktopfn = fileInfo.fileName(); + QFile file(m_desktopfp); + QString newname = QString(path + "/" + desktopfn); + bool ret = file.copy(QString(path + "/" + desktopfn)); + + if (ret) { + char command[200]; + sprintf(command, "chmod a+x %s", newname.toLocal8Bit().data()); + QProcess::startDetached(QString::fromLocal8Bit(command)); + } + + m_actionNumber = 5; +} + +void TabletRightClickMenu::uninstallActionTriggerSlot() +{ + QString cmd = QString("kylin-uninstaller %1") + .arg(m_desktopfp.toLocal8Bit().data()); + bool ret = QProcess::startDetached(cmd); + myDebug() << "卸载:" << cmd << ret; + m_actionNumber = 6; +} + +void TabletRightClickMenu::attributeActionTriggerSlot() +{ + char command[100]; + sprintf(command, "ukui-menu-attr %s", m_desktopfp.toLocal8Bit().data()); + QProcess::startDetached(command); + m_actionNumber = 7; +} +int TabletRightClickMenu::showAppBtnMenu(QString desktopfp, bool isinstall) +{ + m_actionNumber = 0; + this->m_desktopfp.clear(); + this->m_desktopfp = desktopfp; + QMenu menu; + //添加菜单项,指定图标、名称、响应函数 + // m_setting->beginGroup("lockapplication"); + // QFileInfo fileInfo(desktopfp); + // QString desktopfn=fileInfo.fileName(); + // if(!m_setting->contains(desktopfn)) + // menu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/fixed.svg",0)),tr("Pin to all"), + // this,SLOT(fixToAllActionTriggerSlot())); + // else + // menu.addAction(QIcon(getIconPixmap(":/data/img/mainviewwidget/unfixed.svg",0)),tr("Unpin from all"), + // this,SLOT(unfixedFromAllActionTriggerSlot())); + // m_setting->endGroup(); + QDBusInterface iface("com.ukui.panel.desktop", + "/", + "com.ukui.panel.desktop", + QDBusConnection::sessionBus()); + QDBusReply ret = iface.call("CheckIfExist", desktopfp); + + if (!ret) + menu.addAction(QIcon(getIconPixmap(":/img/fixed.svg", 0)), tr("Pin to taskbar"), + this, SLOT(fixToTaskbarActionTriggerSlot())); + else + menu.addAction(QIcon(getIconPixmap(":/img/unfixed.svg", 0)), tr("Unpin from taskbar"), + this, SLOT(unfixedFromTaskbarActionTriggerSlot())); + + // menu.addAction(QIcon(getIconPixmap(":/img/fixed.svg",0)),tr("Add to desktop shortcuts"), + // this,SLOT(addToDesktopActionTriggerSlot())); + QAction *clickaction = new QAction(this); + clickaction->setText(tr("Add to desktop shortcuts")); + clickaction->setIcon(QIcon(getIconPixmap(":/img/fixed.svg", 0))); + connect(clickaction, &QAction::triggered, this, &TabletRightClickMenu::addToDesktopActionTriggerSlot); + menu.addAction(clickaction); + myDebug() << "desktopfp" << desktopfp; + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + QString desktopfp1 = QDir::homePath() + "/桌面/" + desktopfn; + QFileInfo fileInfo1(desktopfp1); + + if (fileInfo1.exists()) { + clickaction->setEnabled(false); + } else { + clickaction->setEnabled(true); + } + + menu.addSeparator(); + + if (isinstall) { + menu.addAction(QIcon(getIconPixmap(":/img/uninstall.svg", 0)), tr("Uninstall"), + this, SLOT(uninstallActionTriggerSlot())); + } + + menu.setAttribute(Qt::WA_TranslucentBackground); + menu.exec(QCursor::pos()); + return m_actionNumber; +} + +//int RightClickMenu::showShutdownMenu() +//{ +// m_actionNumber=0; +// QMenu menu; +// menu.addAction(QIcon(getIconPixmap("stock-people-symbolic",1)),tr("Switch User"), +// this,SLOT(switchUserActionTriggerSlot())); +// if(QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) +// { +// QGSettings* gsetting=new QGSettings(QString("org.ukui.session").toLocal8Bit()); +// if(gsetting->keys().contains(QString("canhibernate"))) +// { +// if(gsetting->get("canhibernate").toBool()) +// menu.addAction(QIcon(getIconPixmap("kylin-hebernate-symbolic",1)),tr("Hibernate"), +// this,SLOT(hibernateActionTriggerSlot())); +// } +// } +// menu.addAction(QIcon(getIconPixmap("kylin-sleep-symbolic",1)),tr("Sleep"), +// this,SLOT(sleepActionTriggerSlot())); +// menu.addAction(QIcon(getIconPixmap("system-lock-screen-symbolic",1)),tr("Lock Screen"), +// this,SLOT(lockScreenActionTriggerSlot())); +// menu.addAction(QIcon(getIconPixmap("system-logout-symbolic",1)),tr("Log Out"), +// this,SLOT(logoutActionTriggerSlot())); +// menu.addAction(QIcon(getIconPixmap("system-restart-symbolic",1)),tr("Restart"), +// this,SLOT(rebootActionTriggerSlot())); +// menu.addAction(QIcon(getIconPixmap("exit-symbolic",1)),tr("Power Off"), +// this,SLOT(shutdownActionTriggerSlot())); +// menu.setAttribute(Qt::WA_TranslucentBackground); +//// menu.setStyleSheet(m_style); +// menu.exec(QCursor::pos()); +// return m_actionNumber; +//} + +//int RightClickMenu::showOtherMenu(QString desktopfp) +//{ +// m_actionNumber=0; +// this->m_desktopfp.clear(); +// this->m_desktopfp=desktopfp; + +// QMenu menu; +// QDBusInterface iface("com.ukui.panel.desktop", +// "/", +// "com.ukui.panel.desktop", +// QDBusConnection::sessionBus()); + +// QDBusReply ret=iface.call("CheckIfExist",this->m_desktopfp); +// if(!ret) +// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/fixed.svg",0)),tr("Pin to taskbar"), +// this,SLOT(fixToTaskbarActionTriggerSlot())); +// else +// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/unfixed.svg",0)),tr("Unpin from taskbar"), +// this,SLOT(unfixedFromTaskbarActionTriggerSlot())); +// menu.addAction(QIcon(getIconPixmap(":/data/img/sidebarwidget/setting.svg",0)),tr("Personalize this list"), +// this,SLOT(otherListActionTriggerSlot())); +// menu.setAttribute(Qt::WA_TranslucentBackground); +//// menu.setStyleSheet(m_style); +// menu.exec(QCursor::pos()); +// return m_actionNumber; +//} diff --git a/src/UserInterface/RightClickMenu/tabletrightclickmenu.h b/src/UserInterface/RightClickMenu/tabletrightclickmenu.h new file mode 100755 index 0000000..a91451c --- /dev/null +++ b/src/UserInterface/RightClickMenu/tabletrightclickmenu.h @@ -0,0 +1,153 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include "ukuimenuinterface.h" +#include "style.h" + +class TabletRightClickMenu : public QWidget +{ + Q_OBJECT +public: + /** + * @brief Right-click menu + * @param module: Right-click menu type, Only the following parameters can be entered: + * 0: application + * 1: power + * 2: others + */ + explicit TabletRightClickMenu(QWidget *parent = nullptr); + virtual ~TabletRightClickMenu(); + /** + * @brief Displays the application right-click menu + * @param desktopfp: Application desktop file + * @return return action number + */ + int showAppBtnMenu(QString desktopfp, bool isinstall); + /** + * @brief Displays the power right-click menu + * @return return action number + */ + //int showShutdownMenu(); + /** + * @brief Displays other application right-click menus + * @param desktopfp: Application desktop file + * @return return action number + */ + //int showOtherMenu(QString desktopfp); + +private: + QString m_desktopfp; + int m_actionNumber; + QSettings *m_setting = nullptr; + + char m_style[400]; + +protected: + /** + * @brief Get icon pixmap + * @param iconstr: Icon names + * @param type: Icon type, Only the following parameters can be entered: + * 0: Resource icon + * 1: System icon + * @return + */ + QPixmap getIconPixmap(QString iconstr, int type); + /** + * @brief Process image color + * @param source: QPixmap icon + * @return return QPixmap icon + */ + QPixmap drawSymbolicColoredPixmap(const QPixmap &source); + +private Q_SLOTS: + /** + * @brief Fixed to all software + */ + void fixToAllActionTriggerSlot(); + /** + * @brief Unfix from all software + */ + void unfixedFromAllActionTriggerSlot(); + /** + * @brief Fixed to the taskbar + */ + void fixToTaskbarActionTriggerSlot(); + /** + * @brief Unfix from the taskbar + */ + void unfixedFromTaskbarActionTriggerSlot(); + /** + * @brief Add to the desktop shortcut + */ + void addToDesktopActionTriggerSlot(); + /** + * @brief Uninstall + */ + void uninstallActionTriggerSlot(); + /** + * @brief Attribute + */ + void attributeActionTriggerSlot(); + /** + * @brief Lock Screen + */ + //void lockScreenActionTriggerSlot(); + /** + * @brief Switch user + */ + //void switchUserActionTriggerSlot(); + /** + * @brief Log out + */ + //void logoutActionTriggerSlot(); + /** + * @brief Reboot + */ + //void rebootActionTriggerSlot(); + /** + * @brief Shut down + */ + //void shutdownActionTriggerSlot(); + //void hibernateActionTriggerSlot(); + //void sleepActionTriggerSlot(); + /** + * @brief Personalize this list + */ + //void otherListActionTriggerSlot(); +}; + +#endif // RIGHTCLICKMENU_H diff --git a/src/UserInterface/ViewItem/full_item_delegate.cpp b/src/UserInterface/ViewItem/full_item_delegate.cpp new file mode 100755 index 0000000..5e5c358 --- /dev/null +++ b/src/UserInterface/ViewItem/full_item_delegate.cpp @@ -0,0 +1,221 @@ +/* + * 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 + +FullItemDelegate::FullItemDelegate(QObject *parent, int module): + KItemDelegate(parent) +{ + this->module = module; + pUkuiMenuInterface = new UkuiMenuInterface; +} + +FullItemDelegate::~FullItemDelegate() +{ + delete pUkuiMenuInterface; +} + +void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + if (index.isValid()) { + QStyleOptionViewItem viewOption(option);//用来在视图中画一个item + QRectF rect; + rect.setX(option.rect.x()); + rect.setY(option.rect.y()); + rect.setWidth(option.rect.width()); + rect.setHeight(option.rect.height()); + //QPainterPath画圆角矩形 + const qreal radius = 26; + QPainterPath path; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + painter->setRenderHint(QPainter::Antialiasing); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + // QColor color = option.palette.text().color(); + // color.setAlphaF(0.15); + painter->save(); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(Qt::white); + painter->setOpacity(0.15); + painter->drawPath(path); + painter->restore(); + } + + painter->save(); + painter->setOpacity(1); + QString desktopfp = index.data(Qt::DisplayRole).value(); + QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + QString appname = pUkuiMenuInterface->getAppName(desktopfp); + QRect iconRect; + QRect textRect; + iconRect = QRect(rect.x() + (rect.width() - Style::AppListIconSize) / 2, + rect.y() + 20, + Style::AppListIconSize, + Style::AppListIconSize); + icon.paint(painter, iconRect); + painter->restore(); + painter->save(); + bool is_locked = false; + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + + //添加固定图标 + if (module == 0) { + if (checkIfLocked(desktopfn)) { + is_locked = true; + QIcon icon(QString(":/data/img/mainviewwidget/lock-fs.svg")); + icon.paint(painter, QRect(iconRect.topRight().x() - 14, iconRect.topRight().y() - 2, 16, 16)); + } + } + + painter->restore(); + textRect = QRect(rect.x() + 5, + iconRect.bottom() + Style::AppSpaceBetweenIconText, + rect.width() - 10, + rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); + painter->save(); + //添加最近安装蓝色标签 + bool is_recentapp = false; + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic); + + if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { + is_recentapp = true; + appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic); + textRect = QRect(rect.x() + 18, + iconRect.bottom() + Style::AppSpaceBetweenIconText, + rect.width() - 23, + rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(QColor("#4d94ff")); + int x = 0; + + if (rect.width() < (23 + fm.boundingRect(appname).width())) { + x = rect.x() + 9; + } else { + x = rect.x() + (rect.width() - 13 - fm.boundingRect(appname).width()) / 2 + 4; + } + + painter->drawEllipse(QPoint(x, + textRect.y() + (fm.boundingRect(appname).height() - 8) / 2 + 4), + 4, + 4); + } + + painter->restore(); + painter->save(); + + // painter->setPen(QPen(option.palette.text().color())); + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.keys().contains("styleName")) { + if (/*gsetting.get("styleName").toString() == "ukui-light"*/false) { + painter->setPen(QPen(Qt::black)); + } else { + painter->setPen(QPen(Qt::white)); + } + } + } + + painter->setBrush(Qt::NoBrush); + painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText); + // painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = 0; + + if (!is_locked && is_recentapp) { + len = fm.boundingRect(appname).width() + 23; + } else { + len = fm.boundingRect(appname).width() + 10; + } + + if (len > rect.width()) { + if (option.state & QStyle::State_MouseOver) { + QToolTip::showText(QCursor::pos(), appname); + } else { + QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); + } + } else { + QToolTip::hideText(); + } + } + } +} + +QSize FullItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QSize(Style::AppListItemSizeWidth, Style::AppListItemSizeWidth); +} diff --git a/src/UtilityFunction/fullitemdelegate.h b/src/UserInterface/ViewItem/full_item_delegate.h old mode 100644 new mode 100755 similarity index 73% rename from src/UtilityFunction/fullitemdelegate.h rename to src/UserInterface/ViewItem/full_item_delegate.h index 0e24425..601939e --- a/src/UtilityFunction/fullitemdelegate.h +++ b/src/UserInterface/ViewItem/full_item_delegate.h @@ -19,31 +19,25 @@ #ifndef FULLITEMDELEGATE_H #define FULLITEMDELEGATE_H #include -#include "src/Style/style.h" +#include "style.h" #include #include #include #include #include #include -#include "src/Interface/ukuimenuinterface.h" -#include "src/Style/style.h" +#include "ukuimenuinterface.h" +#include "style.h" +#include "kitemdelegate.h" -class FullItemDelegate : public QStyledItemDelegate +class FullItemDelegate : public KItemDelegate { Q_OBJECT public: - FullItemDelegate(QObject* parent,int module); + FullItemDelegate(QObject *parent, int module); ~FullItemDelegate(); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - int module=0; - UkuiMenuInterface* pUkuiMenuInterface=nullptr; - -protected: -// bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index); }; #endif // FULLITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/itemdelegate.cpp b/src/UserInterface/ViewItem/itemdelegate.cpp new file mode 100755 index 0000000..7effecd --- /dev/null +++ b/src/UserInterface/ViewItem/itemdelegate.cpp @@ -0,0 +1,352 @@ +/* + * 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 +#include +#include +#include "utility.h" + +ItemDelegate::ItemDelegate(QObject *parent, int module): + KItemDelegate(parent) +{ + this->module = module; + pUkuiMenuInterface = new UkuiMenuInterface; +} + +ItemDelegate::~ItemDelegate() +{ + delete pUkuiMenuInterface; +} + +void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + if (index.isValid()) { + QRectF rect; + rect.setX(option.rect.x()); + rect.setY(option.rect.y()); + rect.setWidth(option.rect.width()); + rect.setHeight(option.rect.height() - 2); + //QPainterPath画圆角矩形 + const qreal radius = 4; + QPainterPath path; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + QStringList strlist = index.model()->data(index, Qt::DisplayRole).toStringList(); + painter->setRenderHint(QPainter::Antialiasing); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + QColor color; + + if (option.state & QStyle::State_Selected) { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#33FFFFFF"); + } else { + color.setNamedColor("#D1FFFFFF"); + } + } else { + if (g_curStyle == "ukui-dark") { + color.setNamedColor("#1AFFFFFF"); + } else { + color.setNamedColor("#8CFFFFFF"); + } + } + + painter->save(); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(color); + painter->drawPath(path); + painter->restore(); + } + + painter->setOpacity(1); + + if (module > 0) { + if (strlist.at(1).toInt() == 1) { + QRect iconRect = QRect(rect.x() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); + QString iconstr = pUkuiMenuInterface->getAppIcon(strlist.at(0)); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); + } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + painter->save(); + icon.paint(painter, iconRect, Qt::AlignCenter); + QString appname = pUkuiMenuInterface->getAppName(strlist.at(0)); + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); + painter->drawText(QRect(iconRect.right() + 15, rect.y(), + rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); + painter->restore(); + painter->save(); + QFileInfo fileInfo(strlist.at(0)); + QString desktopfn = fileInfo.fileName(); + + if (checkIfRecent(desktopfn)) { + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(QColor("#4d94ff")); + painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); + } + + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = fm.boundingRect(appname).width(); + + if (len > rect.width() - 62) { + if (option.state & QStyle::State_MouseOver) { + QToolTip::showText(QCursor::pos(), appname); + } else { + QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.bottomRight().x(), rect.center().y())), appname); + } + } else { + QToolTip::hideText(); + } + } + } else { + //绘制分割线 + painter->save(); + // QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); + QRect textRect = QRect(rect.x() + 11, rect.y(), rect.width(), rect.height()); + painter->drawText(textRect, Qt::AlignVCenter, strlist.at(0)); + painter->setRenderHints(QPainter::SmoothPixmapTransform, true); + QPixmap pixmap = getCurIcon(":/data/img/mainviewwidget/DM-icon-option.svg", true).pixmap(QSize(16, 16)); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + painter->drawPixmap(rect.width() - 25, rect.y() + 15, pixmap); + if (module == 1) { + QToolTip::showText(QCursor::pos(), tr("Open the function sort menu")); + } else if (module == 2) { + QToolTip::showText(QCursor::pos(), tr("Open the alphabetical menu")); + } + } + + painter->restore(); + } + } else if (module == -1) { + QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); + QString iconstr = strlist.at(3); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); + } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + icon.paint(painter, iconRect, Qt::AlignCenter); + QString appname = strlist.at(1); + painter->setOpacity(1); + painter->save(); + painter->setPen(QPen(option.palette.text().color())); + painter->setBrush(Qt::NoBrush); + painter->setOpacity(1); + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); + painter->drawText(QRect(iconRect.right() + 15, rect.y(), + rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = fm.boundingRect(appname).width(); + + if (len > rect.width() - 64) { + if (option.state & QStyle::State_MouseOver) { + QToolTip::showText(QCursor::pos(), appname); + } else { + QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.bottomRight().x(), rect.center().y())), appname); + } + } else { + QToolTip::hideText(); + } + } + } else { + QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); + QString iconstr = pUkuiMenuInterface->getAppIcon(strlist.at(0)); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); + } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + icon.paint(painter, iconRect, Qt::AlignCenter); + QString appname = pUkuiMenuInterface->getAppName(strlist.at(0)); + QFileInfo fileInfo(strlist.at(0)); + QString desktopfn = fileInfo.fileName(); + + if (checkIfLocked(desktopfn)) { + QIcon icon = getCurIcon(":/data/img/mainviewwidget/lock.svg", true); + icon.paint(painter, QRect(rect.topRight().x() - 22, rect.y() + (rect.height() - 16) / 2, 16, 16)); + } + + painter->setOpacity(1); + painter->save(); + + if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(QColor("#4d94ff")); + painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); + } + + painter->restore(); + painter->save(); + painter->setPen(QPen(option.palette.text().color())); + painter->setBrush(Qt::NoBrush); + painter->setOpacity(1); + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); + painter->drawText(QRect(iconRect.right() + 15, rect.y(), + rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = fm.boundingRect(appname).width(); + + if (len > rect.width() - 62) { + if (option.state & QStyle::State_MouseOver) { + QToolTip::showText(QCursor::pos(), appname); + } else { + QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.bottomRight().x(), rect.center().y())), appname); + } + } else { + QToolTip::hideText(); + } + } + } + } +} + +QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + // QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); + // if(strlist.at(1).toInt()==1) + return QSize(310, 47); + // else + // return QSize(310,48); +} diff --git a/src/UtilityFunction/itemdelegate.h b/src/UserInterface/ViewItem/itemdelegate.h old mode 100644 new mode 100755 similarity index 83% rename from src/UtilityFunction/itemdelegate.h rename to src/UserInterface/ViewItem/itemdelegate.h index 7c00340..a57708e --- a/src/UtilityFunction/itemdelegate.h +++ b/src/UserInterface/ViewItem/itemdelegate.h @@ -19,28 +19,24 @@ #ifndef ITEMDELEGATE_H #define ITEMDELEGATE_H #include -#include "src/Style/style.h" +#include "style.h" #include #include #include -#include "src/Interface/ukuimenuinterface.h" +#include "ukuimenuinterface.h" +#include "kitemdelegate.h" -class ItemDelegate : public QStyledItemDelegate +class ItemDelegate : public KItemDelegate { Q_OBJECT public: /** * @param module为0时为常用模块,1为字母模块、2为功能模块、3为搜索模块 */ - ItemDelegate(QObject* parent,int module); + ItemDelegate(QObject *parent, int module); ~ItemDelegate(); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - int module=0; - UkuiMenuInterface* pUkuiMenuInterface=nullptr; - }; #endif // ITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/kitemdelegate.cpp b/src/UserInterface/ViewItem/kitemdelegate.cpp new file mode 100755 index 0000000..540536e --- /dev/null +++ b/src/UserInterface/ViewItem/kitemdelegate.cpp @@ -0,0 +1,6 @@ +#include "kitemdelegate.h" + +KItemDelegate::KItemDelegate(QObject *parent): + QStyledItemDelegate(parent) +{ +} diff --git a/src/UserInterface/ViewItem/kitemdelegate.h b/src/UserInterface/ViewItem/kitemdelegate.h new file mode 100755 index 0000000..5145b78 --- /dev/null +++ b/src/UserInterface/ViewItem/kitemdelegate.h @@ -0,0 +1,16 @@ +#ifndef KITEMDELEGATE_H +#define KITEMDELEGATE_H +#include +#include "ukuimenuinterface.h" + +class KItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + KItemDelegate(QObject *parent); + + int module = 0; + UkuiMenuInterface *pUkuiMenuInterface = nullptr; +}; + +#endif // KITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/recent_item_delegate.cpp b/src/UserInterface/ViewItem/recent_item_delegate.cpp new file mode 100755 index 0000000..db471cf --- /dev/null +++ b/src/UserInterface/ViewItem/recent_item_delegate.cpp @@ -0,0 +1,229 @@ +#include "recent_item_delegate.h" + +recentitemdelegate::recentitemdelegate(QObject *parent, int module): + KItemDelegate(parent) +{ + this->module = module; + pUkuiMenuInterface = new UkuiMenuInterface; +} + +recentitemdelegate::~recentitemdelegate() +{ + delete pUkuiMenuInterface; +} + +void recentitemdelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + if (index.isValid()) { + // QStyleOptionViewItem viewOption(option);//用来在视图中画一个item + QRectF rect; + rect.setX(option.rect.x()); + rect.setY(option.rect.y()); + rect.setWidth(option.rect.width()); + rect.setHeight(option.rect.height() - 2); + //QPainterPath画圆角矩形 + const qreal radius = 4; + QPainterPath path; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + QStringList strlist = index.model()->data(index, Qt::DisplayRole).toStringList(); + painter->setRenderHint(QPainter::Antialiasing); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + QColor color = option.palette.text().color(); + color.setAlphaF(0.15); + painter->save(); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(color); + painter->drawPath(path); + painter->restore(); + } + + painter->setOpacity(1); + + if (module > 0) { + if (strlist.at(1).toInt() == 1) { + QRect iconRect = QRect(rect.x() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); + // QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0)); + QString iconstr = "wps-office2019-etmain"; + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + painter->save(); + icon.paint(painter, iconRect, Qt::AlignLeft); + // QString appname=pUkuiMenuInterface->getAppName(strlist.at(0)); + QString appname = "这是一个测试文件.xlsx"; + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); + painter->drawText(QRect(iconRect.right() + 15, rect.y(), + rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); + painter->restore(); + painter->save(); + QFileInfo fileInfo(strlist.at(0)); + QString desktopfn = fileInfo.fileName(); + + if (checkIfRecent(desktopfn)) { + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(QColor("#4d94ff")); + painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); + } + + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = fm.boundingRect(appname).width(); + + if (len > rect.width() - 62) { + if (option.state & QStyle::State_MouseOver) { + QToolTip::showText(QCursor::pos(), appname); + } else { + QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); + } + } else { + QToolTip::hideText(); + } + } + } else { + //绘制分割线 + painter->save(); + // QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); + QRect textRect = QRect(rect.x() + 11, rect.y(), rect.width(), rect.height()); + painter->drawText(textRect, Qt::AlignVCenter, strlist.at(0)); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setPen(QPen(QColor(option.palette.text().color()), 1)); + painter->setOpacity(0.1); + painter->drawLine(QPoint(5, rect.bottom()), QPoint(rect.right(), rect.bottom())); + painter->restore(); + } + } else { + QRect iconRect = QRect(rect.left() + 11, rect.y() + (rect.height() - 32) / 2, 32, 32); + QString iconstr = pUkuiMenuInterface->getAppIcon(strlist.at(0)); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("xpm")); + } else if (QFile::exists(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/%1.%2").arg(iconstr).arg("png")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + icon.paint(painter, iconRect, Qt::AlignCenter); + QString appname = pUkuiMenuInterface->getAppName(strlist.at(0)); + QFileInfo fileInfo(strlist.at(0)); + QString desktopfn = fileInfo.fileName(); + + if (checkIfLocked(desktopfn)) { + QIcon icon(QString(":/data/img/mainviewwidget/lock.svg")); + icon.paint(painter, QRect(rect.topRight().x() - 22, rect.y() + (rect.height() - 16) / 2, 16, 16)); + } + + painter->setOpacity(1); + painter->save(); + + if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(QColor("#4d94ff")); + painter->drawEllipse(QPoint(rect.topRight().x() - 22, rect.y() + (rect.height() - 8) / 2 + 4), 4, 4); + } + + painter->restore(); + painter->save(); + painter->setPen(QPen(option.palette.text().color())); + painter->setBrush(Qt::NoBrush); + painter->setOpacity(1); + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 62, Qt::TextShowMnemonic); + painter->drawText(QRect(iconRect.right() + 15, rect.y(), + rect.width() - 62, rect.height()), Qt::AlignVCenter, appnameElidedText); + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = fm.boundingRect(appname).width(); + + if (len > rect.width() - 62) { + if (option.state & QStyle::State_MouseOver) { + QToolTip::showText(QCursor::pos(), appname); + } else { + QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); + } + } else { + QToolTip::hideText(); + } + } + } + } +} + +QSize recentitemdelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + // QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); + // if(strlist.at(1).toInt()==1) + return QSize(310, 47); + // else + // return QSize(310,48); +} diff --git a/src/UserInterface/ViewItem/recent_item_delegate.h b/src/UserInterface/ViewItem/recent_item_delegate.h new file mode 100755 index 0000000..a613d90 --- /dev/null +++ b/src/UserInterface/ViewItem/recent_item_delegate.h @@ -0,0 +1,24 @@ +#ifndef RECENTITEMDELEGATE_H +#define RECENTITEMDELEGATE_H +#include "itemdelegate.h" +#include +#include +#include +#include +#include "src/UtilityFunction/utility.h" +#include "kitemdelegate.h" + +class recentitemdelegate : public KItemDelegate +{ + Q_OBJECT +public: + /** + * @param module为0时为常用模块,1为字母模块、2为功能模块、3为搜索模块 + */ + recentitemdelegate(QObject *parent, int module); + ~recentitemdelegate(); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; +}; + +#endif // RECENTITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/right_item_delegate.cpp b/src/UserInterface/ViewItem/right_item_delegate.cpp new file mode 100755 index 0000000..b50de3d --- /dev/null +++ b/src/UserInterface/ViewItem/right_item_delegate.cpp @@ -0,0 +1,195 @@ +#include "right_item_delegate.h" +#include "utility.h" +#include + +RightItemDelegate::RightItemDelegate(QObject *parent): + KItemDelegate(parent) +{ + pUkuiMenuInterface = new UkuiMenuInterface; +} + +RightItemDelegate::~RightItemDelegate() +{ + delete pUkuiMenuInterface; +} + +void RightItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + if (index.isValid()) { + QStyleOptionViewItem viewOption(option);//用来在视图中画一个item + QRectF rect; + rect.setX(option.rect.x() + 1); + rect.setY(option.rect.y() + 1); + rect.setWidth(option.rect.width() - 2); + rect.setHeight(option.rect.height() - 2); + //QPainterPath画圆角矩形 + const qreal radius = 10; + QPainterPath path; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + painter->setRenderHint(QPainter::Antialiasing); + painter->save(); + painter->setPen(QPen(Qt::NoPen)); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + if (option.state & QStyle::State_Selected) { + if (g_curStyle == "ukui-dark") { + painter->setBrush(QColor("#7A000000")); + } else { + painter->setBrush(QColor("#BFFFFFFF")); + } + } else { + if (g_curStyle == "ukui-dark") { + painter->setBrush(QColor("#66000000")); + } else { + painter->setBrush(QColor("#99FFFFFF")); + } + } + } else { + if (g_curStyle == "ukui-dark") { + painter->setBrush(QColor("#40000000")); + } else { + painter->setBrush(QColor("#66FFFFFF")); + } + } + + painter->drawPath(path); + painter->restore(); + painter->save(); + painter->setOpacity(1); + QString desktopfp = index.data(Qt::DisplayRole).value(); + QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/128x128/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + QString appname = pUkuiMenuInterface->getAppName(desktopfp); + QRect iconRect; + QRect textRect; + iconRect = QRect(rect.x() + 28, + rect.y() + 16, + 48, + 48); + icon.paint(painter, iconRect); + painter->restore(); + painter->save(); + bool is_locked = false; + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + painter->restore(); + textRect = QRect(rect.x(), + iconRect.bottom(), + rect.width(), + rect.height() - iconRect.height()); + painter->save(); + //添加最近安装蓝色标签 + bool is_recentapp = false; + QFontMetrics fm = painter->fontMetrics(); + QString appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 10, Qt::TextShowMnemonic); + + if (checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) { + is_recentapp = true; + appnameElidedText = fm.elidedText(appname, Qt::ElideRight, rect.width() - 23, Qt::TextShowMnemonic); + textRect = QRect(rect.x() + 18, + iconRect.bottom() + Style::AppSpaceBetweenIconText, + rect.width() - 23, + rect.height() - iconRect.height() - Style::AppSpaceBetweenIconText); + painter->setPen(QPen(Qt::NoPen)); + painter->setBrush(QColor("#4d94ff")); + int x = 0; + + if (rect.width() < (23 + fm.boundingRect(appname).width())) { + x = rect.x() + 9; + } else { + x = rect.x() + (rect.width() - 13 - fm.boundingRect(appname).width()) / 2 + 4; + } + + painter->drawEllipse(QPoint(x, + textRect.y() + (fm.boundingRect(appname).height() - 8) / 2 + 4), + 4, + 4); + } + + painter->restore(); + painter->save(); + painter->setPen(QPen(option.palette.text().color())); +// painter->setPen(QPen(Qt::white)); + painter->setBrush(Qt::NoBrush); + painter->drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, appnameElidedText); + // painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); + painter->restore(); + + if ((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) { + int len = 0; + + if (!is_locked && is_recentapp) { + len = fm.boundingRect(appname).width() + 23; + } else { + len = fm.boundingRect(appname).width() + 10; + } + + if (len > rect.width()) { + if (option.state & QStyle::State_MouseOver) { + QToolTip::showText(QCursor::pos(), appname); + } else { + QToolTip::showText(option.widget->mapToGlobal(QPoint(rect.center().x(), rect.center().y() + 15)), appname); + } + } else { + QToolTip::hideText(); + } + } + } +} + +QSize RightItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QSize(104, 104); +} diff --git a/src/UserInterface/ViewItem/right_item_delegate.h b/src/UserInterface/ViewItem/right_item_delegate.h new file mode 100755 index 0000000..ee62ed6 --- /dev/null +++ b/src/UserInterface/ViewItem/right_item_delegate.h @@ -0,0 +1,25 @@ +#ifndef RIGHTITEMDELEGATE_H +#define RIGHTITEMDELEGATE_H +#include +#include "style.h" +#include +#include +#include +#include +#include +#include +#include "ukuimenuinterface.h" +#include "style.h" +#include "kitemdelegate.h" + +class RightItemDelegate : public KItemDelegate +{ + Q_OBJECT +public: + RightItemDelegate(QObject *parent); + ~RightItemDelegate(); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; +}; + +#endif // FULLITEMDELEGATE_H diff --git a/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp b/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp new file mode 100755 index 0000000..58e487a --- /dev/null +++ b/src/UserInterface/ViewItem/tablet_full_itemdelegate.cpp @@ -0,0 +1,214 @@ +/* + * 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 +#include "ukuimenuinterface.h" +#include "style.h" +#include +#include + +TabletFullItemDelegate::TabletFullItemDelegate(QObject *parent, int module): + QStyledItemDelegate(parent) +{ + this->module = module; + pUkuiMenuInterface = new UkuiMenuInterface; + //打开ini文件 + QString pathini = QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"; + settt = new QSettings(pathini, QSettings::IniFormat); + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + setting = new QSettings(path, QSettings::IniFormat); +} + +TabletFullItemDelegate::~TabletFullItemDelegate() +{ + if (pUkuiMenuInterface) { + delete pUkuiMenuInterface; + } + + if (settt) { + delete settt; + } + + if (setting) { + delete setting; + } + + pUkuiMenuInterface = nullptr; + settt = nullptr; + setting = nullptr; +} + +void TabletFullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + if (index.isValid()) { + painter->save(); + QStyleOptionViewItem viewOption(option);//用来在视图中画一个item + QRectF rect; + rect.setX(option.rect.x()); + rect.setY(option.rect.y()); + rect.setWidth(option.rect.width()); + rect.setHeight(option.rect.height()); + painter->setOpacity(1); + QString desktopfp = index.model()->data(index, Qt::DisplayRole).value(); + QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + QString appname = pUkuiMenuInterface->getAppName(desktopfp); + QRect iconRect; + QRect textRect; + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + //qDebug()<<"str-----------"<beginGroup("application"); + //判断禁用 + settt->sync(); + bool bo = settt->contains(desktopfp1.toLocal8Bit().data()); // iskey + bool bo1 = settt->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool(); //isvalue + settt->endGroup(); + + if (bo && bo1 == false) { //都存在//存在并且为false + QPixmap pixmap; + + if (bigIcon) { + pixmap = icon.pixmap((Style::AppListBigIconSize, Style::AppListBigIconSize), QIcon::Disabled, QIcon::Off); //wgx + pixmap = pixmap.scaled(Style::AppListBigIconSize, Style::AppListBigIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + } else { + pixmap = icon.pixmap((Style::AppListIconSize, Style::AppListIconSize), QIcon::Disabled, QIcon::Off); //wgx + } + + icon = QIcon(pixmap); + } else { + QPixmap mPixmap; + + if (bigIcon) { + mPixmap = icon.pixmap((Style::AppListBigIconSize, Style::AppListBigIconSize)); //wgx + mPixmap = mPixmap.scaled(Style::AppListBigIconSize, Style::AppListBigIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + } else { + mPixmap = icon.pixmap((Style::AppListIconSize, Style::AppListIconSize)); //wgx + } + + icon = QIcon(mPixmap); + } + + // qDebug()<<"iconRect"<setPen(shadow); + QRect textLineRect; + textLineRect.setLeft(textRect.left() + 1); + textLineRect.setRight(textRect.right() + 1); + textLineRect.setTop(textRect.top() + 1); + textLineRect.setBottom(textRect.bottom() + 1); + painter->drawText(textLineRect, Qt::TextWordWrap | Qt::AlignCenter, appname); + painter->setPen(QPen(Qt::white)); + painter->drawText(textRect, Qt::TextWordWrap | Qt::AlignCenter, appname); + painter->restore(); + } +} + +QSize TabletFullItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + // if(index.row()>=Style::appNum) + // { + // return QSize(0,0); + // } + return QSize(Style::TabletItemSizeWidthFirst, Style::AppListItemSizeHeight); +} + diff --git a/src/UserInterface/ViewItem/tablet_full_itemdelegate.h b/src/UserInterface/ViewItem/tablet_full_itemdelegate.h new file mode 100755 index 0000000..8407557 --- /dev/null +++ b/src/UserInterface/ViewItem/tablet_full_itemdelegate.h @@ -0,0 +1,55 @@ +/* + * 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 +#include "style.h" +#include +#include +#include +#include +#include +#include "ukuimenuinterface.h" +#include "style.h" +#include + +class TabletFullItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + TabletFullItemDelegate(QObject *parent, int module); + ~TabletFullItemDelegate(); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + +private: + int module = 0; + UkuiMenuInterface *pUkuiMenuInterface = nullptr; + QSettings *settt; + QSettings *setting = nullptr; + // int i=0; + // int j=1; + + + +protected: + // bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index); +}; + +#endif // FULLITEMDELEGATE_H diff --git a/src/UserInterface/Widget/animationpage.cpp b/src/UserInterface/Widget/animationpage.cpp new file mode 100755 index 0000000..2676f29 --- /dev/null +++ b/src/UserInterface/Widget/animationpage.cpp @@ -0,0 +1,26 @@ +#include "animationpage.h" +#include "utility.h" +#include +#include +#include + +AnimationPage::AnimationPage(QWidget *parent) + : QWidget(parent) + +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); + this->setAutoFillBackground(false); + this->setAttribute(Qt::WA_TranslucentBackground); +} +void AnimationPage::paintEvent(QPaintEvent *event) +{ + double transparency = getTransparency(); + QRect rect = this->rect(); + QPainter painter(this); + painter.setBrush(this->palette().base()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(rect); + KWindowEffects::enableBlurBehind(this->winId(), true, QRect(rect)); + return QWidget::paintEvent(event); +} diff --git a/src/UserInterface/Widget/animationpage.h b/src/UserInterface/Widget/animationpage.h new file mode 100755 index 0000000..9cefa24 --- /dev/null +++ b/src/UserInterface/Widget/animationpage.h @@ -0,0 +1,14 @@ +#ifndef ANIMATIONPAGE_H +#define ANIMATIONPAGE_H +#include + +class AnimationPage : public QWidget +{ + Q_OBJECT +public: + AnimationPage(QWidget *parent = nullptr); +protected: + void paintEvent(QPaintEvent *event); +}; + +#endif // ANIMATIONPAGE_H diff --git a/src/UserInterface/Widget/full_commonuse_widget.cpp b/src/UserInterface/Widget/full_commonuse_widget.cpp new file mode 100755 index 0000000..26d86b5 --- /dev/null +++ b/src/UserInterface/Widget/full_commonuse_widget.cpp @@ -0,0 +1,309 @@ +/* + * 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 +#include "style.h" +#include "utility.h" +#include + +FullCommonUseWidget::FullCommonUseWidget(QWidget *parent) : + QWidget(parent) +{ + Style::initWidStyle(); + initUi(); +} + +FullCommonUseWidget::~FullCommonUseWidget() +{ + delete m_ukuiMenuInterface; +} + +void FullCommonUseWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + this->setFocusPolicy(Qt::NoFocus); + QHBoxLayout *mainLayout = new QHBoxLayout(this); + mainLayout->setContentsMargins(40, 0, 40, 0); + mainLayout->setSpacing(0); + m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + mainLayout->addItem(m_spaceItem); + m_scrollArea = new ScrollArea(); + m_scrollAreaWid = new ScrollAreaWid(this); + m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); + m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setStyleSheet("QWidget{background:transparent;}"); + m_scrollArea->setWidgetResizable(true); + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollAreaWidLayout = new QVBoxLayout(m_scrollAreaWid); + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(10); + QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); + rightButtonLayout->setContentsMargins(0, 0, 0, 20); + rightButtonLayout->setSpacing(0); + QSpacerItem *m_spaceItem2 = nullptr; + m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem2); + m_verticalScrollBar = new QScrollBar(this); + m_verticalScrollBar->installEventFilter(this); + m_verticalScrollBar->setOrientation(Qt::Vertical); + mainLayout->addWidget(m_scrollArea); + QSpacerItem *m_spaceItem1 = nullptr; + m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + mainLayout->addItem(m_spaceItem1); + m_powerOffButton = new QPushButton(this); + m_powerOffButton->setFixedSize(QSize(40, 40)); + m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); + QIcon powerIcon; + powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); + m_powerOffButton->setIcon(powerIcon); + m_powerOffButton->setIconSize(QSize(28, 28)); + m_powerOffButton->setFlat(true); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius :20px; background: rgba(255, 255, 255, 0.2);}" + "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); + rightButtonLayout->addWidget(m_verticalScrollBar); + QSpacerItem *m_spaceItem3 = nullptr; + m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem3); + rightButtonLayout->addWidget(m_powerOffButton); + rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); + mainLayout->addLayout(rightButtonLayout); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + fillAppList(); + m_scrollAreaWid->adjustSize(); + flag = true; + //翻页灵敏度时间调节 + time = new QTimer(this); + connect(time, &QTimer::timeout, [ = ]() { + if (flag == false) { + flag = true; + time->stop(); + } + }); + m_scrollAreaWidHeight = m_scrollAreaWid->height(); + initVerticalScrollBar(); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullCommonUseWidget::on_setScrollBarValue); + connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullCommonUseWidget::on_setAreaScrollBarValue); + connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullCommonUseWidget::on_powerOffButton_customContextMenuRequested); + connect(m_powerOffButton, &QPushButton::clicked, this, &FullCommonUseWidget::on_powerOffButton_clicked); +} + +void FullCommonUseWidget::initVerticalScrollBar() +{ + m_verticalScrollBar->setFixedHeight(200); + int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; + + if (scrollBarSize >= 200) { + m_verticalScrollBar->hide(); + } else { + m_verticalScrollBar->show(); + } + + m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); " + "margin: 0px,0px,0px,0px; border-radius: %3px;}" + "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);" + "border-radius: %3px; min-height: %1;}" + "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" + "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); +} + +void FullCommonUseWidget::on_powerOffButton_clicked() +{ + QProcess::startDetached(QString("ukui-session-tools")); +} + +void FullCommonUseWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) +{ + Q_UNUSED(pos); + RightClickMenu m_otherMenu(this); + m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(QPoint(0, 45)), true); + myDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; +} + +void FullCommonUseWidget::initAppListWidget() +{ + m_listView = new FullListView(this, 0); + m_listView->installEventFilter(this); + m_scrollAreaWidLayout->addWidget(m_listView); + m_listView->setFixedWidth(m_scrollArea->width()); + connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullCommonUseWidget::execApplication); + connect(m_listView, &FullListView::sendUpdateAppListSignal, this, &FullCommonUseWidget::updateListViewSlot); + connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullCommonUseWidget::sendHideMainWindowSignal); + connect(m_listView, &FullListView::sendSetslidebar, this, &FullCommonUseWidget::onSetSlider); +} + +void FullCommonUseWidget::resizeScrollAreaControls() +{ + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); + QWidget *wid = widItem->widget(); + FullListView *listview = qobject_cast(wid); + listview->adjustSize(); + int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; + int rowcount = 0; + + if (listview->model()->rowCount() % dividend > 0) { + rowcount = listview->model()->rowCount() / dividend + 1; + } else { + rowcount = listview->model()->rowCount() / dividend; + } + + listview->setFixedSize(m_listView->width(), listview->gridSize().height() * rowcount); + m_scrollArea->widget()->setFixedSize(listview->size()); +} + +void FullCommonUseWidget::fillAppList() +{ + m_data.clear(); + + Q_FOREACH (QString desktopfp, UkuiMenuInterface::allAppVector) { + m_data.append(desktopfp); + } + + m_listView->addData(m_data); + resizeScrollAreaControls(); +} + +/** + * 执行应用程序 + */ +void FullCommonUseWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +void FullCommonUseWidget::selectFirstItem() +{ + m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); +} + +void FullCommonUseWidget::on_setScrollBarValue(int value) +{ + m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); + m_verticalScrollBar->setValue(value); +} + +bool FullCommonUseWidget::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_listView) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + Q_EMIT setFocusToSideWin(); + return true; + } + } + } + + if (watched == m_verticalScrollBar) { + if (event->type() == QEvent::Enter) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78)); + } + + if (event->type() == QEvent::Leave) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); + } + + if(event->type() == QEvent::MouseButtonPress) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9)); + } + } + + return QWidget::eventFilter(watched, event); +} + +void FullCommonUseWidget::onSetSlider(int value) +{ + if (value == 0) { + m_scrollArea->verticalScrollBar()->setValue(0); + } else { + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + } +} + +void FullCommonUseWidget::selectFirstItemTab() +{ + m_listView->setFocus(); + m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + onSetSlider(0); +} + +void FullCommonUseWidget::on_setAreaScrollBarValue(int value) +{ + m_scrollArea->verticalScrollBar()->setValue(value); +} +/** + * 更新应用列表 + */ +void FullCommonUseWidget::updateListViewSlot() +{ + updateListView(); + Q_EMIT sendUpdateOtherView(); +} + +void FullCommonUseWidget::updateListView() +{ + m_data.clear(); + + Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { + m_data.append(desktopfp); + } + + m_listView->updateData(m_data); + m_data.clear(); + resizeScrollAreaControls(); + m_scrollAreaWidHeight = m_scrollAreaWid->height(); + initVerticalScrollBar(); +} + +void FullCommonUseWidget::repaintWidget() +{ + m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + m_scrollAreaWidLayout->removeWidget(m_listView); + m_listView->setParent(nullptr); + delete m_listView; + initAppListWidget(); + fillAppList(); + m_scrollAreaWidHeight = m_scrollAreaWid->height(); + initVerticalScrollBar(); + on_setAreaScrollBarValue(0); +} + +void FullCommonUseWidget::widgetMakeZero() +{ + m_listView->verticalScrollBar()->setSliderPosition(0); +} + +void FullCommonUseWidget::moveScrollBar(int type) +{ + int height = Style::m_availableScreenHeight; + + if (type == 0) { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); + } else { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); + } +} diff --git a/src/CommonUseWidget/fullcommonusewidget.h b/src/UserInterface/Widget/full_commonuse_widget.h old mode 100644 new mode 100755 similarity index 71% rename from src/CommonUseWidget/fullcommonusewidget.h rename to src/UserInterface/Widget/full_commonuse_widget.h index ded8e50..9f60538 --- a/src/CommonUseWidget/fullcommonusewidget.h +++ b/src/UserInterface/Widget/full_commonuse_widget.h @@ -32,11 +32,12 @@ #include #include #include -#include "src/Interface/ukuimenuinterface.h" -#include "src/RightClickMenu/rightclickmenu.h" -#include "src/UtilityFunction/fulllistview.h" -#include "src/Style/style.h" -#include "src/UtilityFunction/scrollarea.h" +#include "ukuimenuinterface.h" +#include "rightclickmenu.h" +#include "fulllistview.h" +#include "style.h" +#include "scrollarea.h" +#include "getmodeldata.h" class FullCommonUseWidget : public QWidget { @@ -65,17 +66,22 @@ public: */ void moveScrollBar(int type); - FullListView* m_listView=nullptr; + FullListView *m_listView = nullptr; private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; QStringList m_data; - QSpacerItem *m_spaceItem=nullptr; - ScrollArea* m_scrollArea=nullptr; - ScrollAreaWid* m_scrollAreaWid=nullptr; - QVBoxLayout* m_scrollAreaWidLayout=nullptr; + QSpacerItem *m_spaceItem = nullptr; + ScrollArea *m_scrollArea = nullptr; + ScrollAreaWid *m_scrollAreaWid = nullptr; + QVBoxLayout *m_scrollAreaWidLayout = nullptr; bool flag; QTimer *time = nullptr; + GetModelData *modaldata = nullptr; + QScrollBar *m_verticalScrollBar = nullptr; + int m_scrollAreaWidHeight = 0; + QString m_scrollBarStyle; + QPushButton *m_powerOffButton = nullptr; protected: /** @@ -91,6 +97,9 @@ protected: */ void fillAppList(); void resizeScrollAreaControls(); + void initVerticalScrollBar(); + + bool eventFilter(QObject *watched, QEvent *event); public Q_SLOTS: /** @@ -103,17 +112,28 @@ public Q_SLOTS: */ void updateListViewSlot(); + void on_setScrollBarValue(int value); + void onSetSlider(int value); void selectFirstItem(); void selectFirstItemTab(); + void on_setAreaScrollBarValue(int value); + + void on_powerOffButton_clicked(); + + void on_powerOffButton_customContextMenuRequested(const QPoint &pos); + Q_SIGNALS: /** * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); + void changeScrollValue(int value, int maximumValue); + void setFocusToSideWin(); + void sendUpdateOtherView(); }; #endif // FULLCOMMONUSEWIDGET_H diff --git a/src/UserInterface/Widget/full_function_widget.cpp b/src/UserInterface/Widget/full_function_widget.cpp new file mode 100755 index 0000000..7cc8464 --- /dev/null +++ b/src/UserInterface/Widget/full_function_widget.cpp @@ -0,0 +1,589 @@ +/* + * 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 +#include +#include "style.h" +#include +#include +#include + +FullFunctionWidget::FullFunctionWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +FullFunctionWidget::~FullFunctionWidget() +{ + delete m_ukuiMenuInterface; +} + +void FullFunctionWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setFocusPolicy(Qt::NoFocus); + m_applistWid = new QWidget(this); + m_iconListWid = new QWidget(this); + m_iconListWid->setAttribute(Qt::WA_TranslucentBackground); + m_iconListWid->setAutoFillBackground(false); + m_applistWid->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + m_iconListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); + m_verticalScrollBar = new QScrollBar(m_scrollArea); + m_verticalScrollBar->installEventFilter(this); + m_verticalScrollBar->setOrientation(Qt::Vertical); + QHBoxLayout *mainLayout = new QHBoxLayout(this); + mainLayout->setContentsMargins(0, 0, 40, 0); + mainLayout->setSpacing(0); + mainLayout->addWidget(m_iconListWid); + mainLayout->addWidget(m_applistWid); + QSpacerItem *m_spaceItem1 = nullptr; + m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + mainLayout->addItem(m_spaceItem1); + QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); + rightButtonLayout->setContentsMargins(0, 0, 0, 20); + rightButtonLayout->setSpacing(0); + m_powerOffButton = new QPushButton(this); + m_powerOffButton->setFixedSize(QSize(40, 40)); + m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); + QIcon powerIcon; + powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); + m_powerOffButton->setIcon(powerIcon); + m_powerOffButton->setIconSize(QSize(28, 28)); + m_powerOffButton->setFlat(true); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius:20px; background: rgba(255, 255, 255, 0.2);}" + "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); + QSpacerItem *m_spaceItem2 = nullptr; + m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem2); + rightButtonLayout->addWidget(m_verticalScrollBar); + QSpacerItem *m_spaceItem3 = nullptr; + m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem3); + rightButtonLayout->addWidget(m_powerOffButton); + rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); + mainLayout->addLayout(rightButtonLayout); + // mainLayout->addWidget(verticalScrollBar); + // this->setLayout(mainLayout); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + initIconListWidget(); + flag = true; + //翻页灵敏度时间调节 + time = new QTimer(this); + connect(time, &QTimer::timeout, [ = ]() { + if (flag == false) { + flag = true; + time->stop(); + } + }); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullFunctionWidget::on_setScrollBarValue); + connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullFunctionWidget::on_setAreaScrollBarValue); + connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullFunctionWidget::on_powerOffButton_customContextMenuRequested); + connect(m_powerOffButton, &QPushButton::clicked, this, &FullFunctionWidget::on_powerOffButton_clicked); +} + +/** + * 初始化应用列表界面 + */ +void FullFunctionWidget::initAppListWidget() +{ + QHBoxLayout *layout = new QHBoxLayout(m_applistWid); + layout->setContentsMargins(0, 0, 0, 0); + m_applistWid->setLayout(layout); + m_scrollArea = new ScrollArea; + m_scrollArea->setStyleSheet("background:transparent"); + m_scrollAreaWid = new ScrollAreaWid(this); + m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); + m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setWidgetResizable(true); + m_scrollAreaWidLayout = new QVBoxLayout(m_scrollAreaWid); + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(10); + layout->addWidget(m_scrollArea); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullFunctionWidget::valueChangedSlot); + fillAppList(); + m_scrollAreaWidHeight = m_scrollAreaWid->height(); + initVerticalScrollBar(); +} + +void FullFunctionWidget::initVerticalScrollBar() +{ + m_verticalScrollBar->setFixedHeight(200); + int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; + + if (scrollBarSize >= 200) { + m_verticalScrollBar->hide(); + } else { + m_verticalScrollBar->show(); + } + + m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); " + "margin: 0px,0px,0px,0px; border-radius: %3px;}" + "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);" + "border-radius: %3px; min-height: %1;}" + "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" + "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); +} + +void FullFunctionWidget::on_powerOffButton_clicked() +{ + QProcess::startDetached(QString("ukui-session-tools")); +} + +void FullFunctionWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) +{ + Q_UNUSED(pos); + RightClickMenu m_otherMenu(this); + m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(QPoint(0, 45)), true); + myDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; +} + + +/** + * 填充应用列表 + */ +void FullFunctionWidget::fillAppList() +{ + m_classificationList.clear(); + QVector vector = UkuiMenuInterface::functionalVector; + QStringList functionList = m_ukuiMenuInterface->getFunctionClassName(); + + for (int i = 0; i < vector.size(); i++) { + if (!(vector.at(i).isEmpty())) { + insertClassificationBtn(functionList.at(i)); + insertAppList(vector.at(i)); + } + } + + resizeScrollAreaControls(); +} + +void FullFunctionWidget::insertClassificationBtn(QString category) +{ + SplitBarFrame *classificationbtn = new SplitBarFrame(this, category, m_scrollArea->width() - 12, 30, 2); + classificationbtn->setAttribute(Qt::WA_TranslucentBackground); + classificationbtn->setAutoFillBackground(false); + m_scrollAreaWidLayout->addWidget(classificationbtn); + m_classificationList.append(category); +} + +void FullFunctionWidget::insertAppList(QStringList desktopfplist) +{ + FullListView *listview = new FullListView(this, 2); + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { + listview->repaint(listview->rect()); + }); + connect(listview, &FullListView::sendSetslidebar, this, &FullFunctionWidget::onSetSlider); + connect(this, &FullFunctionWidget::selectFirstItem, listview, &FullListView::selectFirstItem); + listview->installEventFilter(this); + m_scrollAreaWidLayout->addWidget(listview); + m_data.clear(); + + for (int i = 0; i < desktopfplist.count(); i++) { + m_data.append(desktopfplist.at(i)); + } + + listview->addData(m_data); + connect(listview, &FullListView::sendItemClickedSignal, this, &FullFunctionWidget::execApplication); + connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullFunctionWidget::sendHideMainWindowSignal); + connect(listview, &FullListView::sendUpdateAppListSignal, this, &FullFunctionWidget::sendUpdateCommonView); +} + +/** + * 执行应用程序 + */ +void FullFunctionWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +void FullFunctionWidget::on_setAreaScrollBarValue(int value) +{ + // m_scrollArea->verticalScrollBar()->setMaximum(maxmumValue); + m_scrollArea->verticalScrollBar()->setValue(value); +} + +/** + * 更新应用列表 + */ +void FullFunctionWidget::updateAppListView() +{ + disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullFunctionWidget::valueChangedSlot); + //刷新应用列表界面 + QLayoutItem *child; + + while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { + QWidget *wid = child->widget(); + m_scrollAreaWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + + fillAppList(); + + //刷新图标列表界面 + Q_FOREACH (QAbstractButton *button, m_buttonList) { + m_btnGroup->removeButton(button); + } + + m_buttonList.clear(); + m_iconListWidLayout->removeItem(m_topSpacerItem); + m_iconListWidLayout->removeItem(m_bottomSpacerItem); + + while ((child = m_iconListWidLayout->takeAt(0)) != 0) { + QWidget *wid = child->widget(); + m_iconListWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + + initIconListScrollArea(); + m_scrollAreaWidHeight = m_scrollAreaWid->height(); + initVerticalScrollBar(); +} + +/** + * 设置scrollarea所填充控件大小 + */ +void FullFunctionWidget::resizeScrollAreaControls() +{ + int row = 0; + int areaHeight = 0; + + while (row < m_scrollAreaWidLayout->count() / 2) { + //应用界面 + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1); + QWidget *wid = widItem->widget(); + FullListView *listview = qobject_cast(wid); + listview->adjustSize(); + int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; + int rowcount = 0; + + if (listview->model()->rowCount() % dividend > 0) { + rowcount = listview->model()->rowCount() / dividend + 1; + } else { + rowcount = listview->model()->rowCount() / dividend; + } + + listview->setFixedSize(m_scrollArea->width(), listview->gridSize().height()*rowcount); + areaHeight += listview->height() + 50; + row++; + } + + m_scrollArea->widget()->setFixedSize(m_scrollArea->width(), areaHeight - 10); +} + +/** + * 初始化图标列表界面 + */ +void FullFunctionWidget::initIconListWidget() +{ + m_iconListWidLayout = new QVBoxLayout(m_iconListWid); + m_iconListWidLayout->setSpacing(Style::LeftSpaceBetweenItem); + m_iconListWidLayout->setContentsMargins(45, 0, 0, 0); + m_topSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_bottomSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_btnGroup = new QButtonGroup(m_iconListWid); + m_animation = new QPropertyAnimation(m_iconListWid, "geometry"); + m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); + m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); + connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullFunctionWidget::animationFinishSlot); + connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullFunctionWidget::animationValueChangedSlot); + initIconListScrollArea(); +} + +void FullFunctionWidget::on_setScrollBarValue(int value) +{ + m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); + m_verticalScrollBar->setValue(value); +} + +/** + * 初始化图标列表界面数据表格iconlisttableWid + */ +void FullFunctionWidget::initIconListScrollArea() +{ + m_iconListWidLayout->addItem(m_topSpacerItem); + + for (int i = 0; i < m_classificationList.size(); i++) { + FunctionClassifyButton *iconbtn = new FunctionClassifyButton( + Style::LeftBtnWidth, + Style::LeftBtnHeight, + Style::LeftIconSize, + m_classificationList.at(i), + true, + true); + iconbtn->setChecked(false); + m_buttonList.append(iconbtn); + m_iconListWidLayout->addWidget(iconbtn); + m_iconListWidLayout->setAlignment(iconbtn, Qt::AlignLeft); + } + + m_iconListWidLayout->addItem(m_bottomSpacerItem); + int id = 0; + + Q_FOREACH (QAbstractButton *btn, m_buttonList) { + m_btnGroup->addButton(btn, id++); + } + + connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullFunctionWidget::btnGroupClickedSlot); + + // m_iconListScrollArea->widget()->adjustSize(); + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } +} + +void FullFunctionWidget::btnGroupClickedSlot(QAbstractButton *btn) +{ + disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullFunctionWidget::valueChangedSlot); + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) { + m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition(); + m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y(); + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollAnimation->stop(); + m_scrollAnimation->setStartValue(m_beginPos); + m_scrollAnimation->setEndValue(m_endPos); + m_scrollAnimation->start(); + button->setChecked(true); + } else { + button->setChecked(false); + } + } +} + +void FullFunctionWidget::animationFinishSlot() +{ + // if(m_scrollArea->verticalScrollBar()->value()==m_endPos || + // m_scrollArea->verticalScrollBar()->value()==m_scrollArea->verticalScrollBar()->maximum()) + // { + // m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullFunctionWidget::valueChangedSlot); + // } +} + +void FullFunctionWidget::animationValueChangedSlot(const QVariant &value) +{ + Q_UNUSED(value); + + if (sender() != m_scrollAnimation) { + return; + } + + QPropertyAnimation *ani = qobject_cast(sender()); + + if (m_endPos != ani->endValue()) { + ani->setEndValue(m_endPos); + } +} + +void FullFunctionWidget::valueChangedSlot(int value) +{ + int index = 0; + + while (index <= m_classificationList.count() - 1) { + int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y(); + int max = 0; + + if (index == m_classificationList.count() - 1) { + max = m_scrollAreaWid->height(); + } else { + max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y(); + } + + if (value >= min && value < max) { + Q_FOREACH (QAbstractButton *button, m_buttonList) { + FunctionClassifyButton *fcbutton = qobject_cast(button); + + if (index == m_buttonList.indexOf(button)) { + fcbutton->setChecked(true); + } else { + fcbutton->setChecked(false); + } + } + + break; + } else { + index++; + } + } +} + +QAbstractButton *FullFunctionWidget::getCurLetterButton(int value) +{ + return m_buttonList.at(value); +} + + +void FullFunctionWidget::enterAnimation() +{ + m_animation->setDuration(200);//动画总时间 + m_animation->setStartValue(QRect(0, 0, + 0, m_iconListWid->height())); + m_animation->setEndValue(QRect(Style::LeftMargin, + 0, + Style::LeftBtnWidth, + m_iconListWid->height())); + m_animation->setEasingCurve(QEasingCurve::InQuart); + m_animation->start(); + m_iconListScrollAreaWid->show(); +} + +void FullFunctionWidget::setFunctionBtnGeometry() +{ + // int height=m_classificationList.size()*Style::LeftBtnHeight+(m_classificationList.size()-1)*Style::LeftSpaceBetweenItem; + m_iconListScrollAreaWid->setGeometry(QRect(Style::LeftMargin, + 0, + Style::LeftBtnWidth, + m_iconListWid->height())); + m_iconListScrollAreaWid->show(); +} + +void FullFunctionWidget::repaintWidget() +{ + m_applistWid->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + m_iconListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); + m_scrollArea->setFixedSize(m_applistWid->width(), m_applistWid->height()); + updateAppListView(); +} + +void FullFunctionWidget::widgetMakeZero() +{ + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } + + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); +} + +void FullFunctionWidget::onSetSlider(int value) +{ + // if(flag) + // { + // flag = false; + // time->start(100); + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + // qDebug() << "FullFunctionWidget::onSetSlider" << curvalue; + // } +} + +bool FullFunctionWidget::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_verticalScrollBar) { + if (watched == m_verticalScrollBar) { + if (event->type() == QEvent::Enter) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78)); + } + + if (event->type() == QEvent::Leave) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); + } + + if(event->type() == QEvent::MouseButtonPress) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9)); + } + } + } else { + if (event->type() == QEvent::KeyPress) { + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); + QWidget *wid = widItem->widget(); + FullListView *m_listview = qobject_cast(wid); + QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget *widTop = widItemTop->widget(); + FullListView *m_listviewTop = qobject_cast(widTop); + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + Q_EMIT setFocusToSideWin(); + return true; + } + + if (ke->key() == Qt::Key_Up) { + if (!m_listviewTop->hasFocus()) { + QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); + btnGroupClickedSlot(buttonTop); + this->m_scrollArea->setFocusToPreChild(); + } else { + m_listview->setFocus(); + QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); + btnGroupClickedSlot(button); + m_index = m_buttonList.size() - 1; + } + + Q_EMIT selectFirstItem(); + return true; + } + + if (ke->key() == Qt::Key_Down) { + if (!m_listview->hasFocus()) { + QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); + btnGroupClickedSlot(button); + this->m_scrollArea->setFocusToNextChild(); + } else { + m_listviewTop->setFocus(); + QAbstractButton *buttonTop = getCurLetterButton(0); + btnGroupClickedSlot(buttonTop); + m_listviewTop->setCurrentIndex(m_listviewTop->model()->index(0, 0)); + m_index = 0; + } + + Q_EMIT selectFirstItem(); + return true; + } + } + } + + return QWidget::eventFilter(watched, event); +} + +void FullFunctionWidget::functionButtonClick() +{ + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } + + m_index = 0; +} + +void FullFunctionWidget::setFocusToThis() +{ + QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget *widTop = widItemTop->widget(); + FullListView *m_listviewTop = qobject_cast(widTop); + functionButtonClick(); + m_listviewTop->setFocus(); + Q_EMIT selectFirstItem(); +} diff --git a/src/FunctionWidget/fullfunctionwidget.h b/src/UserInterface/Widget/full_function_widget.h old mode 100644 new mode 100755 similarity index 69% rename from src/FunctionWidget/fullfunctionwidget.h rename to src/UserInterface/Widget/full_function_widget.h index 81551b7..931104c --- a/src/FunctionWidget/fullfunctionwidget.h +++ b/src/UserInterface/Widget/full_function_widget.h @@ -33,14 +33,14 @@ #include #include #include -#include "src/Interface/ukuimenuinterface.h" -#include "src/UtilityFunction/scrollarea.h" -#include "src/UtilityFunction/splitbarframe.h" -#include "src/UtilityFunction/fulllistview.h" -#include "src/UtilityFunction/classifybtnscrollarea.h" -#include "src/UtilityFunction/toolbutton.h" -#include "src/UtilityFunction/functionclassifybutton.h" -#include "src/Style/style.h" +#include "ukuimenuinterface.h" +#include "scrollarea.h" +#include "splitbar_frame.h" +#include "fulllistview.h" +#include "classify_btn_scrollarea.h" +#include "tool_button.h" +#include "function_classify_button.h" +#include "style.h" #include class FullFunctionWidget : public QWidget @@ -48,7 +48,7 @@ class FullFunctionWidget : public QWidget Q_OBJECT public: - explicit FullFunctionWidget(QWidget *parent=nullptr); + explicit FullFunctionWidget(QWidget *parent = nullptr); ~FullFunctionWidget(); /** * @brief Initializes the interface state @@ -68,44 +68,43 @@ public: * 0: moving up * 1: moving down */ - void moveScrollBar(int type); - /** - * @brief Adjust function classification button position - */ void setFunctionBtnGeometry(); void functionButtonClick(); - QAbstractButton* getCurLetterButton(int value); + QAbstractButton *getCurLetterButton(int value); private: /*Application list interface*/ - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - QWidget* m_applistWid=nullptr; - ScrollArea* m_scrollArea=nullptr; - ScrollAreaWid* m_scrollAreaWid=nullptr; - QVBoxLayout* m_scrollAreaWidLayout=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QWidget *m_applistWid = nullptr; + ScrollArea *m_scrollArea = nullptr; + ScrollAreaWid *m_scrollAreaWid = nullptr; + QVBoxLayout *m_scrollAreaWidLayout = nullptr; QStringList m_classificationList;//Store the list of category buttons QStringList m_data; + QString m_scrollBarStyle; QTimer *time = nullptr; bool flag; /*Function classification list interface*/ - QWidget* m_iconListWid=nullptr; - ClassifyBtnScrollArea* m_iconListScrollArea=nullptr; - ClassifyBtnScrollAreaWid* m_iconListScrollAreaWid=nullptr; - QVBoxLayout* m_iconListScrollAreaWidLayout=nullptr; - QList m_buttonList; - QButtonGroup* m_btnGroup=nullptr; - QSpacerItem* m_topSpacerItem=nullptr; - QSpacerItem* m_bottomSpacerItem=nullptr; - QSpacerItem* m_appListBottomSpacer=nullptr; + QWidget *m_iconListWid = nullptr; + ClassifyBtnScrollArea *m_iconListScrollArea = nullptr; + ClassifyBtnScrollAreaWid *m_iconListScrollAreaWid = nullptr; + QVBoxLayout *m_iconListWidLayout = nullptr; + QList m_buttonList; + QButtonGroup *m_btnGroup = nullptr; + QSpacerItem *m_topSpacerItem = nullptr; + QSpacerItem *m_bottomSpacerItem = nullptr; /*Animation*/ - QPropertyAnimation* m_animation=nullptr;//Function category button animation - QPropertyAnimation* m_scrollAnimation=nullptr;//Application list animation - int m_beginPos= 0;//Application list scrollbar starting value - int m_endPos= 0;//Application list scrollbar end value + QPropertyAnimation *m_animation = nullptr; //Function category button animation + QPropertyAnimation *m_scrollAnimation = nullptr; //Application list animation + int m_beginPos = 0; //Application list scrollbar starting value + int m_endPos = 0; //Application list scrollbar end value int m_index = 0; + QScrollBar *m_verticalScrollBar = nullptr; + int m_scrollAreaWidHeight = 0; + QPushButton *m_powerOffButton = nullptr; protected: /** @@ -139,7 +138,7 @@ protected: * @brief Set the control size in qscrollarea */ void resizeScrollAreaControls(); - + void initVerticalScrollBar(); bool eventFilter(QObject *watched, QEvent *event); public Q_SLOTS: @@ -176,6 +175,14 @@ public Q_SLOTS: void setFocusToThis(); + void on_setScrollBarValue(int value); + + void on_setAreaScrollBarValue(int value); + + void on_powerOffButton_clicked(); + + void on_powerOffButton_customContextMenuRequested(const QPoint &pos); + Q_SIGNALS: /** * @brief Send a hidden main window signal to the MainViewWidget @@ -185,6 +192,11 @@ Q_SIGNALS: void setFocusToSideWin(); void selectFirstItem(); + + void changeScrollValue(int value, int maximumValue); + + void sendUpdateCommonView(); + }; #endif // FULLFUNCTIONWIDGET_H diff --git a/src/UserInterface/Widget/full_letter_widget.cpp b/src/UserInterface/Widget/full_letter_widget.cpp new file mode 100755 index 0000000..1ebc2c5 --- /dev/null +++ b/src/UserInterface/Widget/full_letter_widget.cpp @@ -0,0 +1,606 @@ +/* + * 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 +#include + +FullLetterWidget::FullLetterWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +FullLetterWidget::~FullLetterWidget() +{ + delete m_ukuiMenuInterface; + delete m_letterListBottomSpacer; +} + +/** + * 主界面初始化 + */ +void FullLetterWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setAttribute(Qt::WA_TranslucentBackground); + m_letterListWid = new QWidget(this); + m_letterListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); + m_verticalScrollBar = new QScrollBar(m_scrollArea); + m_verticalScrollBar->installEventFilter(this); + m_verticalScrollBar->setOrientation(Qt::Vertical); + m_mainLayout = new QHBoxLayout; + m_mainLayout->setContentsMargins(0, 0, 40, 0); + m_mainLayout->setSpacing(0); + m_mainLayout->addWidget(m_letterListWid); + this->setLayout(m_mainLayout); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + initLetterListWidget(); + flag = true; + //翻页灵敏度时间调节 + time = new QTimer(this); + connect(time, &QTimer::timeout, [ = ]() { + if (flag == false) { + flag = true; + time->stop(); + } + }); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullLetterWidget::on_setScrollBarValue); + connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullLetterWidget::on_setAreaScrollBarValue); + connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullLetterWidget::on_powerOffButton_customContextMenuRequested); + connect(m_powerOffButton, &QPushButton::clicked, this, &FullLetterWidget::on_powerOffButton_clicked); +} + +/** + * 初始化应用列表界面 + */ +void FullLetterWidget::initAppListWidget() +{ + // QHBoxLayout* layout=new QHBoxLayout(m_applistWid); + // layout->setContentsMargins(0,0,0,0); + // m_applistWid->setLayout(layout); + m_scrollArea = new ScrollArea(); + m_scrollArea->setStyleSheet("background:transparent"); + m_scrollAreaWid = new ScrollAreaWid(this); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + m_scrollArea->setWidgetResizable(true); + // m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollAreaWidLayout = new QVBoxLayout; + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(10); + m_scrollAreaWid->setLayout(m_scrollAreaWidLayout); + m_mainLayout->addWidget(m_scrollArea); + QSpacerItem *m_spaceItem1 = nullptr; + m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_mainLayout->addItem(m_spaceItem1); + QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); + rightButtonLayout->setContentsMargins(0, 0, 0, 20); + rightButtonLayout->setSpacing(0); + QSpacerItem *m_spaceItem2 = nullptr; + m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem2); + m_powerOffButton = new QPushButton(this); + m_powerOffButton->setFixedSize(QSize(40, 40)); + m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); + QIcon powerIcon; + powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); + m_powerOffButton->setIcon(powerIcon); + m_powerOffButton->setIconSize(QSize(28, 28)); + m_powerOffButton->setFlat(true); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius:20px; background: rgba(255, 255, 255, 0.2);}" + "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); + rightButtonLayout->addWidget(m_verticalScrollBar); + QSpacerItem *m_spaceItem3 = nullptr; + m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem3); + rightButtonLayout->addWidget(m_powerOffButton); + rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); + m_mainLayout->addLayout(rightButtonLayout); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullLetterWidget::valueChangedSlot); + fillAppList(); + m_scrollAreaWidHeight = m_scrollAreaWid->height(); + initVerticalScrollBar(); +} + +void FullLetterWidget::initVerticalScrollBar() +{ + m_verticalScrollBar->setFixedHeight(200); + int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; + + if (scrollBarSize >= 200) { + m_verticalScrollBar->hide(); + } else { + m_verticalScrollBar->show(); + } + + m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); " + "margin: 0px,0px,0px,0px; border-radius: %3px;}" + "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);" + "border-radius: %3px; min-height: %1;}" + "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" + "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); +} + +void FullLetterWidget::on_powerOffButton_clicked() +{ + QProcess::startDetached(QString("ukui-session-tools")); +} + +void FullLetterWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) +{ + Q_UNUSED(pos); + RightClickMenu m_otherMenu(this); + m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(QPoint(0, 45)), true); + qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; +} + +void FullLetterWidget::setFocusToThis() +{ + QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget *widTop = widItemTop->widget(); + FullListView *m_listviewTop = qobject_cast(widTop); + letterButtonClick(); + m_listviewTop->setFocus(); + Q_EMIT selectFirstItem(); +} + +/** + * 填充应用列表 + */ +void FullLetterWidget::fillAppList() +{ + m_letterList.clear(); + QVector vector = UkuiMenuInterface::alphabeticVector; + + for (int i = 0; i < vector.size(); i++) { + QStringList appList = vector.at(i); + + if (!appList.isEmpty()) { + QString letterstr; + + if (i < 26) { + letterstr = QString(QChar(static_cast(i + 65))); + } else if (i == 26) { + letterstr = "&"; + } else { + letterstr = "#"; + } + + m_letterList.append(letterstr);//存储分类字符 + //插入字母分类按钮 + SplitBarFrame *letterbtn = new SplitBarFrame(this, letterstr, m_scrollArea->width() - 12, 30, 1); + m_scrollAreaWidLayout->addWidget(letterbtn); + //插入应用列表 + FullListView *listview = new FullListView(this, 1); + connect(listview, &FullListView::sendSetslidebar, this, &FullLetterWidget::onSetSlider); + connect(this, &FullLetterWidget::selectFirstItem, listview, &FullListView::selectFirstItem); + listview->installEventFilter(this); + //修复异常黑框问题 + connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [ = ]() { + listview->repaint(listview->rect()); + }); + m_scrollAreaWidLayout->addWidget(listview); + m_data.clear(); + + for (int i = 0; i < appList.count(); i++) { + m_data.append(appList.at(i)); + } + + listview->addData(m_data); + connect(listview, &FullListView::sendItemClickedSignal, this, &FullLetterWidget::execApplication); + connect(listview, &FullListView::sendHideMainWindowSignal, this, &FullLetterWidget::sendHideMainWindowSignal); + connect(listview, &FullListView::sendUpdateAppListSignal, this, &FullLetterWidget::sendUpdateCommonView); + } + } + + resizeScrollAreaControls(); +} + +/** + * 执行应用程序 + */ +void FullLetterWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +void FullLetterWidget::on_setAreaScrollBarValue(int value) +{ + // m_scrollArea->verticalScrollBar()->setMaximum(maxmumValue); + m_scrollArea->verticalScrollBar()->setValue(value); +} + +/** + * 更新应用列表 + */ +void FullLetterWidget::updateAppListView() +{ + disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullLetterWidget::valueChangedSlot); + //刷新应用列表界面 + QLayoutItem *child; + + while ((child = m_scrollAreaWidLayout->takeAt(0)) != 0) { + QWidget *wid = child->widget(); + m_scrollAreaWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + + fillAppList(); + + //刷新字母列表界面 + Q_FOREACH (QAbstractButton *button, m_buttonList) { + m_btnGroup->removeButton(button); + } + + m_buttonList.clear(); + m_letterListWidLayout->removeItem(m_topSpacerItem); + m_letterListWidLayout->removeItem(m_letterListBottomSpacer); + + while ((child = m_letterListWidLayout->takeAt(0)) != 0) { + QWidget *wid = child->widget(); + m_letterListWidLayout->removeWidget(wid); + wid->setParent(nullptr); + delete wid; + delete child; + } + + //防止按钮位置偏移 + initLetterListScrollArea(); + m_scrollAreaWidHeight = m_scrollAreaWid->height(); + initVerticalScrollBar(); +} + +void FullLetterWidget::on_setScrollBarValue(int value) +{ + m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); + m_verticalScrollBar->setValue(value); +} + +/** + * 设置scrollarea所填充控件大小 + */ +void FullLetterWidget::resizeScrollAreaControls() +{ + int row = 0; + int areaHeight = 0; + + while (row < m_scrollAreaWidLayout->count() / 2) { + //应用界面 + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(row * 2 + 1); + QWidget *wid = widItem->widget(); + FullListView *listview = qobject_cast(wid); + listview->adjustSize(); + int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; + int rowcount = 0; + + if (listview->model()->rowCount() % dividend > 0) { + rowcount = listview->model()->rowCount() / dividend + 1; + } else { + rowcount = listview->model()->rowCount() / dividend; + } + + listview->setFixedSize(m_scrollArea->width(), listview->gridSize().height()*rowcount); + areaHeight += listview->height() + 50; + row++; + } + + m_scrollArea->widget()->setFixedSize(m_scrollArea->width(), areaHeight - 10); +} + +/** + * 初始化字母列表界面 + */ +void FullLetterWidget::initLetterListWidget() +{ + m_letterListWidLayout = new QVBoxLayout(m_letterListWid); + m_letterListWidLayout->setContentsMargins(45, 0, 0, 0); + m_letterListWidLayout->setSpacing(0); + m_topSpacerItem = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_letterListBottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_btnGroup = new QButtonGroup(m_letterListWid); + m_animation = new QPropertyAnimation(m_letterListWid, "geometry"); + m_scrollAnimation = new QPropertyAnimation(m_scrollArea->verticalScrollBar(), "value"); + m_scrollAnimation->setEasingCurve(QEasingCurve::OutQuad); + connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &FullLetterWidget::animationFinishSlot); + connect(m_scrollAnimation, &QPropertyAnimation::valueChanged, this, &FullLetterWidget::animationValueChangedSlot); + initLetterListScrollArea(); +} + +/** + * 初始化字母列表 + */ +void FullLetterWidget::initLetterListScrollArea() +{ + m_letterListWidLayout->addItem(m_topSpacerItem); + + if (m_letterList.contains("&")) { + m_letterList.replace(m_letterList.indexOf("&"), "&&"); + } + + for (int i = 0; i < m_letterList.size(); i++) { + LetterClassifyButton *letterbtn = new LetterClassifyButton(m_letterListWid, + true, + m_letterList.at(i)); + letterbtn->setFixedSize(Style::LeftLetterBtnHeight, Style::LeftLetterBtnHeight); + m_buttonList.append(letterbtn); + m_letterListWidLayout->addWidget(letterbtn); + m_letterListWidLayout->setAlignment(letterbtn, Qt::AlignLeft); + connect(letterbtn, &LetterClassifyButton::buttonClicked, m_btnGroup, static_cast(&QButtonGroup::buttonClicked)); + } + + m_letterListWidLayout->addItem(m_letterListBottomSpacer); + int id = 0; + + Q_FOREACH (QAbstractButton *btn, m_buttonList) { + m_btnGroup->addButton(btn, id++); + } + + connect(m_btnGroup, static_cast(&QButtonGroup::buttonClicked), this, &FullLetterWidget::btnGroupClickedSlot); + + // m_letterListWid->widget()->adjustSize(); + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } +} + +void FullLetterWidget::btnGroupClickedSlot(QAbstractButton *btn) +{ + disconnect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullLetterWidget::valueChangedSlot); + + Q_FOREACH (QAbstractButton *button, m_buttonList) { + LetterClassifyButton *letterbtn = qobject_cast(button); + + if (m_btnGroup->id(btn) == m_buttonList.indexOf(button)) { + letterbtn->setChecked(true); + //此处需实现将被选定的字母包含的应用列表移动到applistWid界面最顶端 + QString letterstr = letterbtn->m_letter; + int num = m_letterList.indexOf(letterstr); + + if (num != -1) { + m_beginPos = m_scrollArea->verticalScrollBar()->sliderPosition(); + m_endPos = m_scrollAreaWidLayout->itemAt(m_btnGroup->id(btn) * 2)->widget()->y(); + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollAnimation->stop(); + m_scrollAnimation->setStartValue(m_beginPos); + m_scrollAnimation->setEndValue(m_endPos); + m_scrollAnimation->start(); + } + } else { + letterbtn->setChecked(false); + } + } +} + +void FullLetterWidget::animationFinishSlot() +{ + if (m_scrollArea->verticalScrollBar()->value() == m_endPos || + m_scrollArea->verticalScrollBar()->value() == m_scrollArea->verticalScrollBar()->maximum()) { + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, + this, &FullLetterWidget::valueChangedSlot); + } +} + +void FullLetterWidget::animationValueChangedSlot(const QVariant &value) +{ + Q_UNUSED(value); + + if (sender() != m_scrollAnimation) { + return; + } + + QPropertyAnimation *ani = qobject_cast(sender()); + + if (m_endPos != ani->endValue()) { + ani->setEndValue(m_endPos); + } +} + +void FullLetterWidget::valueChangedSlot(int value) +{ + int index = 0; + + while (index <= m_letterList.count() - 1) { + int min = m_scrollAreaWidLayout->itemAt(2 * index)->widget()->y(); + int max = 0; + + if (index == m_letterList.count() - 1) { + max = m_scrollAreaWid->height(); + } else { + max = m_scrollAreaWidLayout->itemAt(2 * (index + 1))->widget()->y(); + } + + if (value >= min && value < max) { + Q_FOREACH (QAbstractButton *button, m_buttonList) { + LetterClassifyButton *letterbtn = qobject_cast(button); + + if (index == m_buttonList.indexOf(button)) { + letterbtn->setChecked(true); + } else { + letterbtn->setChecked(false); + } + } + + break; + } else { + index++; + } + } +} + +void FullLetterWidget::enterAnimation() +{ + m_animation->setDuration(200);//动画总时间 + m_animation->setStartValue(QRect(0, (m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2, + 0, (m_letterList.size() + 1)*Style::LeftLetterBtnHeight)); + m_animation->setEndValue(QRect(Style::LeftMargin, + (m_letterListWid->height() - (m_letterList.size() + 1)*Style::LeftLetterBtnHeight) / 2, + Style::LeftLetterBtnHeight * 2, + (m_letterList.size() + 1)*Style::LeftLetterBtnHeight)); + m_animation->setEasingCurve(QEasingCurve::InQuart); + m_animation->start(); + // m_letterListScrollArea->show(); +} + +void FullLetterWidget::setLetterBtnGeometry() +{ + // m_letterListScrollArea->setGeometry(QRect(Style::LeftMargin, + // (m_letterListWid->height()-(m_letterList.size()+1)*Style::LeftLetterBtnHeight)/2, + // Style::LeftLetterBtnHeight*2, + // (m_letterList.size()+1)*Style::LeftLetterBtnHeight)); + // m_letterListScrollArea->show(); +} + +void FullLetterWidget::repaintWidget() +{ + m_letterListWid->setFixedSize(Style::m_leftWidWidth, Style::m_applistWidHeight); + m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + updateAppListView(); +} + +void FullLetterWidget::widgetMakeZero() +{ + Q_FOREACH (QAbstractButton *button, m_buttonList) { + QString letterstr = button->text().at(0); + int num = m_letterList.indexOf(letterstr); + + if (num != -1) { + m_btnGroup->button(num)->click(); + // m_letterListScrollArea->verticalScrollBar()->setSliderPosition(0); + break; + } + } + + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); +} + +void FullLetterWidget::moveScrollBar(int type) +{ + int height = Style::m_availableScreenHeight; + + if (type == 0) { + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() - height * 100 / 1080); + } else { + m_scrollArea->verticalScrollBar()->setSliderPosition(m_scrollArea->verticalScrollBar()->sliderPosition() + height * 100 / 1080); + } +} + +void FullLetterWidget::onSetSlider(int value) +{ + // if(flag) + // { + // flag = false; + // time->start(100); + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + // } +} + +QAbstractButton *FullLetterWidget::getCurLetterButton(int value) +{ + return m_buttonList.at(value); +} + +bool FullLetterWidget::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_verticalScrollBar) { + if (event->type() == QEvent::Enter) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78)); + } + + if (event->type() == QEvent::Leave) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); + } + + if(event->type() == QEvent::MouseButtonPress) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9)); + } + } else { + if (event->type() == QEvent::KeyPress) { + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(2 * m_buttonList.size() - 1); + QWidget *wid = widItem->widget(); + FullListView *m_listview = qobject_cast(wid); + QLayoutItem *widItemTop = m_scrollAreaWidLayout->itemAt(1); + QWidget *widTop = widItemTop->widget(); + FullListView *m_listviewTop = qobject_cast(widTop); + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + // m_letterListScrollAreaWid->setFocus(); + // m_letterListScrollArea->setFocus(); + // return true; + Q_EMIT setFocusToSideWin(); + return true; + } + + if (ke->key() == Qt::Key_Up) { + if (!m_listviewTop->hasFocus()) { + QAbstractButton *buttonTop = getCurLetterButton((--m_index) % m_buttonList.size()); + btnGroupClickedSlot(buttonTop); + this->m_scrollArea->setFocusToPreChild(); + } else { + m_listview->setFocus(); + QAbstractButton *button = getCurLetterButton(m_buttonList.size() - 1); + btnGroupClickedSlot(button); + m_index = m_buttonList.size() - 1; + } + + Q_EMIT selectFirstItem(); + return true; + } + + if (ke->key() == Qt::Key_Down) { + if (!m_listview->hasFocus()) { + QAbstractButton *button = getCurLetterButton((++m_index) % m_buttonList.size()); + btnGroupClickedSlot(button); + this->m_scrollArea->setFocusToNextChild(); + } else { + m_listviewTop->setFocus(); + QAbstractButton *buttonTop = getCurLetterButton(0); + btnGroupClickedSlot(buttonTop); + m_index = 0; + } + + Q_EMIT selectFirstItem(); + return true; + } + } + } + + return QWidget::eventFilter(watched, event); +} + +void FullLetterWidget::letterButtonClick() +{ + if (m_btnGroup->button(0) != nullptr) { + m_btnGroup->button(0)->click(); + } + + m_index = 0; +} diff --git a/src/LetterWidget/fullletterwidget.h b/src/UserInterface/Widget/full_letter_widget.h old mode 100644 new mode 100755 similarity index 69% rename from src/LetterWidget/fullletterwidget.h rename to src/UserInterface/Widget/full_letter_widget.h index 4b7e2e6..662408b --- a/src/LetterWidget/fullletterwidget.h +++ b/src/UserInterface/Widget/full_letter_widget.h @@ -30,31 +30,30 @@ #include #include #include -#include "src/Interface/ukuimenuinterface.h" +#include "ukuimenuinterface.h" #include #include #include #include #include -#include "src/Interface/ukuimenuinterface.h" #include #include #include #include -#include "src/UtilityFunction/letterclassifybutton.h" -#include "src/UtilityFunction/scrollarea.h" -#include "src/UtilityFunction/splitbarframe.h" -#include "src/UtilityFunction/fulllistview.h" -#include "src/UtilityFunction/classifybtnscrollarea.h" -#include "src/UtilityFunction/toolbutton.h" -#include "src/Style/style.h" +#include "letter_classify_button.h" +#include "scrollarea.h" +#include "splitbar_frame.h" +#include "fulllistview.h" +#include "classify_btn_scrollarea.h" +#include "tool_button.h" +#include "style.h" class FullLetterWidget : public QWidget { Q_OBJECT public: - explicit FullLetterWidget(QWidget *parent=nullptr); + explicit FullLetterWidget(QWidget *parent = nullptr); ~FullLetterWidget(); /** * @brief Initializes the interface state @@ -82,42 +81,45 @@ public: void letterButtonClick(); - QAbstractButton* getCurLetterButton(int value); + QAbstractButton *getCurLetterButton(int value); private: /*Application list interface*/ - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - QWidget* m_applistWid=nullptr; - ScrollArea* m_scrollArea=nullptr; - ScrollAreaWid* m_scrollAreaWid=nullptr; - QVBoxLayout* m_scrollAreaWidLayout=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QWidget *m_applistWid = nullptr; + ScrollArea *m_scrollArea = nullptr; + ScrollAreaWid *m_scrollAreaWid = nullptr; + QVBoxLayout *m_scrollAreaWidLayout = nullptr; QStringList m_letterList;//Store the list of letter buttons QStringList m_data; bool flag; QTimer *time = nullptr; int m_index = 0; /*Alphabetic classification list interface*/ - QWidget* m_letterListWid=nullptr; - ClassifyBtnScrollArea* m_letterListScrollArea=nullptr; - ClassifyBtnScrollAreaWid* m_letterListScrollAreaWid=nullptr; - QVBoxLayout* m_letterListScrollAreaWidLayout=nullptr; - QList m_buttonList; - QButtonGroup* m_btnGroup=nullptr; - QSpacerItem* m_letterListBottomSpacer=nullptr; - QSpacerItem* m_appListBottomSpacer=nullptr; + QWidget *m_letterListWid = nullptr; + QVBoxLayout *m_letterListWidLayout = nullptr; + QList m_buttonList; + QButtonGroup *m_btnGroup = nullptr; + QSpacerItem *m_letterListBottomSpacer = nullptr; + QSpacerItem *m_topSpacerItem = nullptr; /*Animation*/ - QPropertyAnimation* m_animation=nullptr;//Letter category button animation - int m_beginPos=0;//Application list scrollbar starting value - int m_endPos=0;//Application list scrollbar end value - QPropertyAnimation* m_scrollAnimation=nullptr;//Application list animation + QPropertyAnimation *m_animation = nullptr; //Letter category button animation + int m_beginPos = 0; //Application list scrollbar starting value + int m_endPos = 0; //Application list scrollbar end value + QPropertyAnimation *m_scrollAnimation = nullptr; //Application list animation + QScrollBar *m_verticalScrollBar = nullptr; + int m_scrollAreaWidHeight = 0; + QString m_scrollBarStyle; + QHBoxLayout *m_mainLayout = nullptr; + QPushButton *m_powerOffButton = nullptr; protected: /** * @brief Initializes UI */ void initUi(); -// void paintEvent(QPaintEvent *event); + // void paintEvent(QPaintEvent *event); /** * @brief fill application list */ @@ -135,6 +137,7 @@ protected: * @brief Set the control size in qscrollarea */ void resizeScrollAreaControls(); + void initVerticalScrollBar(); bool eventFilter(QObject *watched, QEvent *event); @@ -171,6 +174,15 @@ public Q_SLOTS: void onSetSlider(int); void setFocusToThis(); + + void on_setScrollBarValue(int value); + + void on_setAreaScrollBarValue(int value); + + void on_powerOffButton_clicked(); + + void on_powerOffButton_customContextMenuRequested(const QPoint &pos); + public: Q_SIGNALS: /** @@ -184,6 +196,9 @@ Q_SIGNALS: void selectFirstItem(); + void changeScrollValue(int value, int maximumValue); + + void sendUpdateCommonView(); }; #endif // FULLLETTERWIDGET_H diff --git a/src/UserInterface/Widget/full_searchresult_widget.cpp b/src/UserInterface/Widget/full_searchresult_widget.cpp new file mode 100755 index 0000000..efdee49 --- /dev/null +++ b/src/UserInterface/Widget/full_searchresult_widget.cpp @@ -0,0 +1,274 @@ +/* + * 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 +#include "style.h" +#include "utility.h" +#include + +FullSearchResultWidget::FullSearchResultWidget(QWidget *parent) : + QWidget(parent) +{ + initUi(); +} + +FullSearchResultWidget::~FullSearchResultWidget() +{ + delete m_ukuiMenuInterface; +} + +void FullSearchResultWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setFocusPolicy(Qt::NoFocus); + QHBoxLayout *mainLayout = new QHBoxLayout(this); + mainLayout->setContentsMargins(40, 0, 40, 0); + mainLayout->setSpacing(0); + m_spaceItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Fixed); + mainLayout->addItem(m_spaceItem); + m_scrollArea = new ScrollArea; + m_scrollArea->setStyleSheet("background:transparent"); + m_scrollAreaWid = new ScrollAreaWid(this); + m_scrollAreaWid->setAttribute(Qt::WA_TranslucentBackground); + m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setWidgetResizable(true); + m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollAreaWidLayout = new QVBoxLayout(m_scrollAreaWid); + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(10); + QVBoxLayout *rightButtonLayout = new QVBoxLayout(this); + rightButtonLayout->setContentsMargins(0, 0, 0, 20); + rightButtonLayout->setSpacing(0); + QSpacerItem *m_spaceItem2 = nullptr; + m_spaceItem2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem2); + m_verticalScrollBar = new QScrollBar(m_scrollArea); + m_verticalScrollBar->installEventFilter(this); + m_verticalScrollBar->setOrientation(Qt::Vertical); + mainLayout->addWidget(m_scrollArea); + QSpacerItem *m_spaceItem1 = nullptr; + m_spaceItem1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + mainLayout->addItem(m_spaceItem1); + m_powerOffButton = new QPushButton(this); + m_powerOffButton->setFixedSize(QSize(40, 40)); + m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); + QIcon powerIcon; + powerIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/power.svg"), QSize(), QIcon::Normal, QIcon::Off); + m_powerOffButton->setIcon(powerIcon); + m_powerOffButton->setIconSize(QSize(28, 28)); + m_powerOffButton->setFlat(true); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius:20px; background: rgba(255, 255, 255, 0.2);}" + "QPushButton:pressed {border-radius:20px; background: rgba(255, 255, 255, 0.3);}"); + rightButtonLayout->addWidget(m_verticalScrollBar); + QSpacerItem *m_spaceItem3 = nullptr; + m_spaceItem3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + rightButtonLayout->addItem(m_spaceItem3); + rightButtonLayout->addWidget(m_powerOffButton); + rightButtonLayout->setAlignment(m_verticalScrollBar, Qt::AlignHCenter); + mainLayout->addLayout(rightButtonLayout); + m_ukuiMenuInterface = new UkuiMenuInterface; + initAppListWidget(); + fillAppList(); + m_scrollAreaWid->adjustSize(); + m_scrollAreaWidHeight = m_scrollAreaWid->height() + 1; + initVerticalScrollBar(); + connect(m_scrollArea->verticalScrollBar(), &QScrollBar::valueChanged, this, &FullSearchResultWidget::on_setScrollBarValue); + connect(m_verticalScrollBar, &QScrollBar::valueChanged, this, &FullSearchResultWidget::on_setAreaScrollBarValue); + connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &FullSearchResultWidget::on_powerOffButton_customContextMenuRequested); + connect(m_powerOffButton, &QPushButton::clicked, this, &FullSearchResultWidget::on_powerOffButton_clicked); +} + +void FullSearchResultWidget::initVerticalScrollBar() +{ + m_verticalScrollBar->setFixedHeight(200); + int scrollBarSize = 200 * Style::m_applistWidHeight / m_scrollAreaWidHeight + 1; + + if (scrollBarSize >= 200) { + m_verticalScrollBar->hide(); + } else { + m_verticalScrollBar->show(); + } + + m_scrollBarStyle = QString("QScrollBar:vertical{width: %2px; background: rgba(12, 12, 12, %4); " + "margin: 0px,0px,0px,0px; border-radius: %3px;}" + "QScrollBar::handle:vertical{width: %2px; background: rgba(255, 255, 255, %5);" + "border-radius: %3px; min-height: %1;}" + "QScrollBar::add-line:vertical{ height: 0px; width: 0px; subcontrol-position: bottom;}" + "QScrollBar::sub-line:vertical{ height: 0px; width: 0px; subcontrol-position:top;}").arg(scrollBarSize); + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); +} + +void FullSearchResultWidget::on_powerOffButton_clicked() +{ + QProcess::startDetached(QString("ukui-session-tools")); +} + +void FullSearchResultWidget::on_powerOffButton_customContextMenuRequested(const QPoint &pos) +{ + Q_UNUSED(pos); + RightClickMenu m_otherMenu(this); + m_otherMenu.showShutdownMenu(m_powerOffButton->mapToGlobal(QPoint(0, 45)), true); + myDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; +} + +void FullSearchResultWidget::initAppListWidget() +{ + m_listView = new FullListView(this, 0); + m_listView->installEventFilter(this); + m_scrollAreaWidLayout->addWidget(m_listView); + m_listView->setFixedWidth(m_scrollArea->width()); + connect(m_listView, &FullListView::sendItemClickedSignal, this, &FullSearchResultWidget::execApplication); + connect(m_listView, &FullListView::sendHideMainWindowSignal, this, &FullSearchResultWidget::sendHideMainWindowSignal); + connect(m_listView, &FullListView::sendSetslidebar, this, &FullSearchResultWidget::onSetSlider); +} + +void FullSearchResultWidget::fillAppList() +{ + m_data.clear(); + m_listView->addData(m_data); + resizeScrollAreaControls(); +} +/** + * 执行应用程序 + */ +void FullSearchResultWidget::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + execApp(desktopfp); +} + +void FullSearchResultWidget::updateAppListView(QVector arg) +{ + m_data.clear(); + + Q_FOREACH (QStringList appinfo, arg) { + m_data.append(appinfo.at(0)); + } + + m_listView->updateData(m_data); + resizeScrollAreaControls(); + m_scrollAreaWidHeight = m_scrollAreaWid->height() + 1; + initVerticalScrollBar(); +} + +void FullSearchResultWidget::resizeScrollAreaControls() +{ + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(0); + QWidget *wid = widItem->widget(); + FullListView *listview = qobject_cast(wid); + listview->adjustSize(); + int dividend = m_scrollArea->width() / Style::m_applistGridSizeWidth; + int rowcount = 0; + + if (listview->model()->rowCount() % dividend > 0) { + rowcount = listview->model()->rowCount() / dividend + 1; + } else { + rowcount = listview->model()->rowCount() / dividend; + } + + listview->setFixedSize(m_scrollArea->width(), listview->gridSize().height() * rowcount); + m_scrollArea->widget()->setFixedSize(listview->size()); +} + +bool FullSearchResultWidget::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_listView) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + Q_EMIT setFocusToSideWin(); + return true; + } + } + } + + if (watched == m_verticalScrollBar) { + if (event->type() == QEvent::Enter) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.78)); + } + + if (event->type() == QEvent::Leave) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(4).arg(2).arg(0.25).arg(0.6)); + } + + if(event->type() == QEvent::MouseButtonPress) { + m_verticalScrollBar->setStyleSheet(m_scrollBarStyle.arg(8).arg(4).arg(0.25).arg(0.9)); + } + } + + return QWidget::eventFilter(watched, event); +} + +void FullSearchResultWidget::selectFirstItemTab() +{ + m_listView->setFocus(); + m_listView->setCurrentIndex(m_listView->model()->index(0, 0)); + m_scrollArea->verticalScrollBar()->setValue(0); +} + +void FullSearchResultWidget::repaintWidget() +{ + m_scrollArea->setFixedSize(Style::m_applistWidWidth, Style::m_applistWidHeight); + resizeScrollAreaControls(); + m_scrollAreaWidHeight = m_scrollAreaWid->height() + 1; + initVerticalScrollBar(); +} + +void FullSearchResultWidget::moveScrollBar(int type) +{ + int height = Style::m_availableScreenHeight; + + if (type == 0) { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() - height * 100 / 1080); + } else { + m_listView->verticalScrollBar()->setSliderPosition(m_listView->verticalScrollBar()->sliderPosition() + height * 100 / 1080); + } +} + +void FullSearchResultWidget::onSetSlider(int value) +{ + myDebug() << value; + + if (value == 0) { + m_scrollArea->verticalScrollBar()->setValue(0); + } else { + int curvalue = m_scrollArea->verticalScrollBar()->value(); + m_scrollArea->verticalScrollBar()->setValue(curvalue + value); + } +} + +void FullSearchResultWidget::setViewFocus() +{ + m_listView->setFocus(); +} + +void FullSearchResultWidget::on_setScrollBarValue(int value) +{ + m_verticalScrollBar->setMaximum(m_scrollAreaWidHeight - Style::m_applistWidHeight); + m_verticalScrollBar->setValue(value); +} + +void FullSearchResultWidget::on_setAreaScrollBarValue(int value) +{ + m_scrollArea->verticalScrollBar()->setValue(value); +} diff --git a/src/SearchResultWidget/fullsearchresultwidget.h b/src/UserInterface/Widget/full_searchresult_widget.h old mode 100644 new mode 100755 similarity index 66% rename from src/SearchResultWidget/fullsearchresultwidget.h rename to src/UserInterface/Widget/full_searchresult_widget.h index f132160..43c1955 --- a/src/SearchResultWidget/fullsearchresultwidget.h +++ b/src/UserInterface/Widget/full_searchresult_widget.h @@ -20,6 +20,7 @@ #define FULLSEARCHRESULTWIDGET_H #include +#include #include #include #include @@ -27,10 +28,10 @@ #include #include #include -#include "src/Interface/ukuimenuinterface.h" -#include "src/UtilityFunction/fulllistview.h" -#include "src/Style/style.h" -#include "src/UtilityFunction/scrollarea.h" +#include "ukuimenuinterface.h" +#include "fulllistview.h" +#include "style.h" +#include "scrollarea.h" class FullSearchResultWidget : public QWidget { @@ -58,34 +59,61 @@ public: void setViewFocus(); private: - UkuiMenuInterface* m_ukuiMenuInterface=nullptr; - FullListView* m_listView=nullptr; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + FullListView *m_listView = nullptr; QStringList m_data; - QSpacerItem *m_spaceItem=nullptr; + QSpacerItem *m_spaceItem = nullptr; - ScrollArea* m_scrollArea=nullptr; - ScrollAreaWid* m_scrollAreaWid=nullptr; - QVBoxLayout* m_scrollAreaWidLayout=nullptr; + ScrollArea *m_scrollArea = nullptr; + ScrollAreaWid *m_scrollAreaWid = nullptr; + QVBoxLayout *m_scrollAreaWidLayout = nullptr; + + QScrollBar *m_verticalScrollBar = nullptr; + int m_scrollAreaWidHeight = 0; + QString m_scrollBarStyle; + QPushButton *m_powerOffButton = nullptr; protected: /** * @brief Initializes UI */ void initUi(); + + void initAppListWidget(); + + void fillAppList(); + void resizeScrollAreaControls(); -private Q_SLOTS: + void initVerticalScrollBar(); + + bool eventFilter(QObject *watched, QEvent *event); + +public Q_SLOTS: /** * @brief Open the application * @param arg: Desktop file path */ void execApplication(QString desktopfp); + void selectFirstItemTab(); + + void on_setScrollBarValue(int value); + + void onSetSlider(int value); + + void on_setAreaScrollBarValue(int value); + + void on_powerOffButton_clicked(); + + void on_powerOffButton_customContextMenuRequested(const QPoint &pos); + Q_SIGNALS: /** * @brief Send a hidden main window signal to the MainViewWidget */ void sendHideMainWindowSignal(); + void setFocusToSideWin(); }; #endif // FULLSEARCHRESULTWIDGET_H diff --git a/src/UserInterface/Widget/function_Widget.cpp b/src/UserInterface/Widget/function_Widget.cpp new file mode 100755 index 0000000..5cf1f5e --- /dev/null +++ b/src/UserInterface/Widget/function_Widget.cpp @@ -0,0 +1,275 @@ +#include "function_Widget.h" +#include "style.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "currenttime_interface.h" +#include "style.h" +#include "utility.h" +#include +#define TIME_FORMAT "org.ukui.control-center.panel.plugins" +#define TIME_FORMAT_KEY "hoursystem" +#include +#include + +FunctionWidget::FunctionWidget(QWidget *parent): QWidget(parent) +{ + // if(QGSettings::isSchemaInstalled("org.ukui.style")){ + // themeSetting=new QGSettings("org.ukui.style"); + // themeName=themeSetting->get("style-name").toString(); + // } + // connect(themeSetting,&QGSettings::changed,this,[=](){ + // changeSearchBoxBackground(); + // }); + usrInterface = new QDBusInterface("com.kylin.statusmanager.interface", + "/", + "com.kylin.statusmanager.interface", + QDBusConnection::sessionBus()); + QDBusConnection::sessionBus().connect("com.kylin.statusmanager.interface", + "/", + "com.kylin.statusmanager.interface", + "stylename_change_signal", + this, + SLOT(changeSearchBoxBackground(QString)) + ); + initUi(); + myTimer = new QTimer(); + myTimer->start(10000); + connect(myTimer, &QTimer::timeout, [this]() { + timeLabel->setText(Time->currentTime); + weekLabel->setText(Time->currentWeek); + dateLabel->setText(Time->currentDate); + }); + + if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) { + timeSetting = new QGSettings(TIME_FORMAT); + connect(timeSetting, &QGSettings::changed, this, [ = ](const QString & key) { + timeLabel->setText(Time->currentTime); + weekLabel->setText(Time->currentWeek); + dateLabel->setText(Time->currentDate); + }); + } +} + +FunctionWidget::~FunctionWidget() +{ + if (themeSetting) { + delete themeSetting; + } + + if (myTimer) { + delete myTimer; + } + + if (upWidget) { + delete upWidget; + } + + if (upLayout) { + delete upLayout; + } + + if (leftUpWidget) { + delete leftUpWidget; + } + + if (leftUpLayout) { + delete leftUpLayout; + } + + if (upLeftWidget) { + delete upLeftWidget; + } + + if (upLeftLayout) { + delete upLeftLayout; + } + + if (upRightWidget) { + delete upRightWidget; + } + + if (upRightLayout) { + delete upRightLayout; + } + + if (downWidget) { + delete downWidget; + } + + if (downLayout) { + delete downLayout; + } + + if (timeLabel) { + delete timeLabel; + } + + if (weekLabel) { + delete weekLabel; + } + + if (dateLabel) { + delete dateLabel; + } + + if (searchEditBtn) { + delete searchEditBtn; + } + + if (focusPlug) { + delete focusPlug; + } + + if (effect) { + delete effect; + } + + themeSetting = nullptr; + myTimer = nullptr; + upWidget = nullptr; + upLayout = nullptr; + leftUpWidget = nullptr; + leftUpLayout = nullptr; + upRightWidget = nullptr; + downWidget = nullptr; + downLayout = nullptr; + timeLabel = nullptr; + weekLabel = nullptr; + dateLabel = nullptr; + searchEditBtn = nullptr; + focusPlug = nullptr; + effect = nullptr; +} + +void FunctionWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setStyleSheet("border:0px solid #ff0000;background:transparent;"); + this->setFocusPolicy(Qt::NoFocus); + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->setSpacing(10); + mainLayout->setContentsMargins(5, 0, 0, 0); + this->setLayout(mainLayout); + //时间 + upWidget = new QWidget(); + upWidget->setFixedSize(400, 96); + upLayout = new QVBoxLayout(); + upWidget->setLayout(upLayout); + upLayout->setContentsMargins(0, 0, 0, 32); + upLayout->setSpacing(0); + //上 + leftUpWidget = new QWidget(); + leftUpWidget->setFixedSize(400, 96); + leftUpLayout = new QHBoxLayout(); + leftUpWidget->setLayout(leftUpLayout); + leftUpLayout->setContentsMargins(0, 0, 0, 0); + leftUpLayout->setSpacing(0); + //左上左 + upLeftWidget = new QWidget; + upLeftWidget->setFixedSize(263, 96); + upLeftLayout = new QHBoxLayout(); + upLeftWidget->setLayout(upLeftLayout); + upLeftLayout->setContentsMargins(0, 0, 0, 0); + // upLeftWidget->setStyleSheet("border-width:1px;border-style:solid;border-color:red"); + //左上右 + upRightWidget = new QWidget; + upRightWidget->setFixedSize(170, 96); + upRightLayout = new QVBoxLayout(); + upRightWidget->setLayout(upRightLayout); + upRightLayout->setContentsMargins(0, 0, 0, 0); + upRightLayout->setSpacing(0); + // upRightWidget->setStyleSheet("border-width:1px;border-style:solid;border-color:red"); + //左侧控件 + timeLabel = new QLabel(); + weekLabel = new QLabel(); + dateLabel = new QLabel(); + //搜索 + searchEditBtn = new QPushButton(); + searchEditBtn->setFocusPolicy(Qt::NoFocus); + searchEditBtn->setFixedSize(400, 80); + searchEditBtn->setIcon(QIcon(":/data/img/mainviewwidget/ukui-search-blue.svg")); + searchEditBtn->setIconSize(QPixmap(":/data/img/mainviewwidget/ukui-search-blue.svg").size()); + searchEditBtn->setText(tr("Search")); + QDBusReply styleName = usrInterface->call(QString("get_current_stylename")); + changeSearchBoxBackground(styleName); + connect(searchEditBtn, &QPushButton::clicked, this, &FunctionWidget::obtainSearchResult); + upLayout->addWidget(leftUpWidget); + mainLayout->addStretch(); + + if (g_subProjectCodeName.contains("mavis")) { + upWidget->setFixedSize(0, 0); + } else { + mainLayout->addWidget(upWidget); + } + + mainLayout->addWidget(searchEditBtn); + focusPlug = new pluginwidget(this); + mainLayout->addWidget(focusPlug); + focusPlug->setFixedSize(400, 638); + mainLayout->addStretch(); + leftUpLayout->addWidget(upLeftWidget); + leftUpLayout->addWidget(upRightWidget); + Time = new CurrentTimeInterface; + timeLabel->setText(Time->currentTime); + weekLabel->setText(Time->currentWeek); + dateLabel->setText(Time->currentDate); + upLeftLayout->addWidget(timeLabel); + upRightLayout->addWidget(weekLabel); + upRightLayout->addWidget(dateLabel); + upRightLayout->setContentsMargins(0, 0, 0, 0); + upRightLayout->setSpacing(0); + weekLabel->setContentsMargins(10, 8, 0, 0); + dateLabel->setContentsMargins(10, 6, 0, 0); + timeLabel->setStyleSheet("border:0px;background:transparent;font-size:96px;color:white;"); + dateLabel->setStyleSheet("border:0px;background:transparent;font-size:32px;color:white;"); + weekLabel->setStyleSheet("border:0px;background:transparent;font-size:38px;color:white;"); + effect = new QGraphicsDropShadowEffect(this); + effect->setXOffset(0); + effect->setYOffset(0); + effect->setBlurRadius(8); + effect->setColor(QColor(38, 38, 38, 100)); + upWidget->setGraphicsEffect(effect); +} + +void FunctionWidget::setDownOpacityEffect(const qreal &num) +{ + opacity = num; + QDBusReply styleName = usrInterface->call(QString("get_current_stylename")); + changeSearchBoxBackground(styleName); +} + +void FunctionWidget::obtainSearchResult() +{ + QDBusInterface iface("com.ukui.search.service", + "/", + "org.ukui.search.service", + QDBusConnection::sessionBus()); + + if (iface.isValid()) { + iface.call("showWindow"); + } +} + +//搜索框适配主题 +void FunctionWidget::changeSearchBoxBackground(QString styleName) +{ + QString styleSheetDark = QString("border-radius:40px;background:rgba(44,50,57,%1);color:white;font-size:24px;text-align:left;padding-left:24px;").arg(opacity); + QString styleSheetLight = QString("border-radius:40px;background:rgba(255,255,255,%1);" + "color:rgba(58,67,78,0.25);font-size:24px;text-align:left;padding-left:24px;").arg(opacity); + + // themeName=themeSetting->get("style-name").toString(); + if (styleName == "ukui-dark") { + searchEditBtn->setStyleSheet(styleSheetDark); + } else { + searchEditBtn->setStyleSheet(styleSheetLight); + } +} + + diff --git a/src/UserInterface/Widget/function_Widget.h b/src/UserInterface/Widget/function_Widget.h new file mode 100755 index 0000000..3681c78 --- /dev/null +++ b/src/UserInterface/Widget/function_Widget.h @@ -0,0 +1,84 @@ +#ifndef FUNCTIONWIDGET_H +#define FUNCTIONWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "AbstractInterface.h" +#include +#include "plugin_widget.h" +#include "currenttime_interface.h" + +class FunctionWidget : public QWidget +{ + Q_OBJECT +public: + FunctionWidget(QWidget *parent); + ~FunctionWidget(); + //QWidget* focusPlug=nullptr; + pluginwidget *focusPlug = nullptr; + void setDownOpacityEffect(const qreal &num); + +protected: + void initUi(); + +private: + CurrentTimeInterface *Time = nullptr; + QGSettings *themeSetting = nullptr; + QGSettings *timeSetting = nullptr; + QString themeName; + QObject *plugin = nullptr; + QGraphicsDropShadowEffect *effect; + QPalette palette; + QTimer *myTimer = nullptr; + + //上方(时间+搜索) + QWidget *upWidget = nullptr; + QWidget *leftUpWidget = nullptr; + QWidget *upLeftWidget = nullptr; + QWidget *downWidget = nullptr; + + + QVBoxLayout *upLayout; + QHBoxLayout *leftUpLayout; + QVBoxLayout *downLayout; + QVBoxLayout *focusModeLayout; + + QHBoxLayout *upLeftLayout; + QVBoxLayout *upRightLayout; + + QLabel *timeLabel; + QLabel *weekLabel; + QLabel *dateLabel; + QPushButton *searchEditBtn; + + QDBusInterface *usrInterface = nullptr; + + //右侧 + QWidget *upRightWidget = nullptr; + + qreal opacity; //透明系数 + +private Q_SLOTS: + + void obtainSearchResult(); + +public Q_SLOTS: + + void changeSearchBoxBackground(QString styleName); +public: +Q_SIGNALS: + void hideTabletWindow(); + + + +}; + +#endif // TIMEWIDGET_H diff --git a/src/UserInterface/Widget/function_button_widget.cpp b/src/UserInterface/Widget/function_button_widget.cpp new file mode 100755 index 0000000..dbb116c --- /dev/null +++ b/src/UserInterface/Widget/function_button_widget.cpp @@ -0,0 +1,125 @@ +/* + * 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 +#include +#include + +FunctionButtonWidget::FunctionButtonWidget(QWidget *parent) : + QWidget(parent) +{ + m_categoryList.clear(); + m_categoryList.append(QObject::tr("Office")); + m_categoryList.append(QObject::tr("Development")); + m_categoryList.append(QObject::tr("Image")); + m_categoryList.append(QObject::tr("Video")); + m_categoryList.append(QObject::tr("Internet")); + m_categoryList.append(QObject::tr("Game")); + m_categoryList.append(QObject::tr("Education")); + m_categoryList.append(QObject::tr("Social")); + m_categoryList.append(QObject::tr("System")); + m_categoryList.append(QObject::tr("Safe")); + m_categoryList.append(QObject::tr("Others")); + initUi(); +} + +FunctionButtonWidget::~FunctionButtonWidget() +{ +} + +void FunctionButtonWidget::initUi() +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + QGridLayout *gridLayout = new QGridLayout; + gridLayout->setContentsMargins(40, 80, 40, 80); + gridLayout->setSpacing(5); + this->setLayout(gridLayout); + + for (int row = 0; row < 6; row++) + for (int col = 0; col < 2; col++) { + FunctionClassifyButton *iconbtn = new FunctionClassifyButton(Style::LeftBtnWidth, + Style::LeftBtnHeight, + Style::LeftIconSize, + m_categoryList.at(row * 2 + col), + false, + false); + gridLayout->addWidget(iconbtn, row, col); + m_buttonList.append(iconbtn); + connect(iconbtn, &FunctionClassifyButton::buttonClicked, this, &FunctionButtonWidget::functionBtnClickedSlot); + + if (row * 2 + col == 10) { + break; + } + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings *gsetting = new QGSettings(QString("org.ukui.style").toLocal8Bit()); + connect(gsetting, &QGSettings::changed, this, [ = ] { + Q_FOREACH (QAbstractButton *btn, m_buttonList) + { + FunctionClassifyButton *fbtn = qobject_cast(btn); + fbtn->updateBtnState(); + } + }); + } +} + +/** + * 功能分类按钮槽函数 + */ +void FunctionButtonWidget::functionBtnClickedSlot() +{ + FunctionClassifyButton *btn = dynamic_cast(sender()); + Q_EMIT sendFunctionBtnSignal(btn->m_category); +} + +void FunctionButtonWidget::hideEvent(QHideEvent *event) +{ + Q_EMIT sendResetFunctionPage(); + return QWidget::hideEvent(event); +} + +/** + * 接收FunctionWidget界面分类按钮列表 + */ +void FunctionButtonWidget::recvClassificationBtnList() +{ + QGridLayout *gridLayout = qobject_cast(this->layout()); + + for (int row = 0; row < 6; row++) + for (int col = 0; col < 2; col++) { + QLayoutItem *item = gridLayout->itemAtPosition(row, col); + FunctionClassifyButton *btn = qobject_cast(item->widget()); + + if (UkuiMenuInterface::functionalVector.at(row * 2 + col).isEmpty()) { + btn->m_enabled = false; + } else { + btn->m_enabled = true; + } + + btn->setEnabled(btn->m_enabled); + btn->updateBtnState(); + + if (row * 2 + col == 10) { + break; + } + } +} diff --git a/src/FunctionWidget/functionbuttonwidget.h b/src/UserInterface/Widget/function_button_widget.h old mode 100644 new mode 100755 similarity index 89% rename from src/FunctionWidget/functionbuttonwidget.h rename to src/UserInterface/Widget/function_button_widget.h index e2cc5d1..3faed62 --- a/src/FunctionWidget/functionbuttonwidget.h +++ b/src/UserInterface/Widget/function_button_widget.h @@ -26,8 +26,8 @@ #include #include #include -#include "src/UtilityFunction/functionclassifybutton.h" -#include "src/Interface/ukuimenuinterface.h" +#include "function_classify_button.h" +#include "ukuimenuinterface.h" class FunctionButtonWidget : public QWidget { @@ -39,7 +39,7 @@ public: private: QStringList m_categoryList; - QList m_buttonList; + QList m_buttonList; protected: /** @@ -47,12 +47,15 @@ protected: */ void initUi(); + void hideEvent(QHideEvent *event); + Q_SIGNALS: /** * @brief Send button click signal to functionwidget interface * @param btnname: Category button name */ void sendFunctionBtnSignal(QString btnname); + void sendResetFunctionPage(); public Q_SLOTS: /** diff --git a/src/LetterWidget/letterbuttonwidget.cpp b/src/UserInterface/Widget/letter_button_widget.cpp old mode 100644 new mode 100755 similarity index 52% rename from src/LetterWidget/letterbuttonwidget.cpp rename to src/UserInterface/Widget/letter_button_widget.cpp index bcf298f..f110340 --- a/src/LetterWidget/letterbuttonwidget.cpp +++ b/src/UserInterface/Widget/letter_button_widget.cpp @@ -16,9 +16,8 @@ * */ -#include "letterbuttonwidget.h" -#include "src/Style/style.h" -#include "letterwidget.h" +#include "letter_button_widget.h" +#include "style.h" #include LetterButtonWidget::LetterButtonWidget(QWidget *parent) : @@ -34,52 +33,52 @@ LetterButtonWidget::~LetterButtonWidget() void LetterButtonWidget::initUi() { this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setAttribute(Qt::WA_StyledBackground,true); + this->setAttribute(Qt::WA_StyledBackground, true); this->setFocusPolicy(Qt::NoFocus); - this->resize(235,366); - - QGridLayout* gridLayout=new QGridLayout; - gridLayout->setContentsMargins(0,0,0,0); + QGridLayout *gridLayout = new QGridLayout; + gridLayout->setContentsMargins(35, 80, 35, 80); gridLayout->setSpacing(5); this->setLayout(gridLayout); - QStringList letterlist; letterlist.clear(); - for(int i=0;i<26;i++) - { - char letter=static_cast(65+i); + + for (int i = 0; i < 26; i++) { + char letter = static_cast(65 + i); letterlist.append(QString(QChar(letter))); } - letterlist.append("&&"); + + letterlist.append("&"); letterlist.append("#"); - for(int row=0;row<7;row++) - { - for(int col=0;col<4;col++) - { - if(row*4+colsetFlat(true); btn->setCheckable(false); - btn->setFixedSize(55,48); - gridLayout->addWidget(btn,row,col); - connect(btn,&LetterClassifyButton::buttonClicked,this, &LetterButtonWidget::letterBtnClickedSlot); - } - else { + btn->setFixedSize(38, 38); + gridLayout->addWidget(btn, row, col); + connect(btn, &LetterClassifyButton::buttonClicked, this, &LetterButtonWidget::letterBtnClickedSlot); + } else { break; } } } } +void LetterButtonWidget::hideEvent(QHideEvent *event) +{ + Q_EMIT sendResetLetterPage(); + return QWidget::hideEvent(event); +} + /** * 字母分类按钮槽函数 */ void LetterButtonWidget::letterBtnClickedSlot() { - LetterClassifyButton* btn=dynamic_cast(QObject::sender()); - QString btnname=btn->text(); + LetterClassifyButton *btn = dynamic_cast(QObject::sender()); + QString btnname = btn->m_letter; Q_EMIT sendLetterBtnSignal(btnname); } @@ -88,20 +87,23 @@ void LetterButtonWidget::letterBtnClickedSlot() */ void LetterButtonWidget::recvLetterBtnList(QStringList list) { - QGridLayout* gridLayout=qobject_cast(this->layout()); - for(int row=0;row<7;row++) - { - for(int col=0;col<4;col++) - { - QLayoutItem* item=gridLayout->itemAt(row*4+col); - LetterClassifyButton* btn=static_cast(item->widget()); - QString letterstr=btn->text(); - if(list.indexOf(letterstr.at(0))==-1) - btn->setEnabled(false); - else - btn->setEnabled(true); + QGridLayout *gridLayout = qobject_cast(this->layout()); - if(row*4+col==27) break; + for (int row = 0; row < 7; row++) { + for (int col = 0; col < 4; col++) { + QLayoutItem *item = gridLayout->itemAt(row * 4 + col); + LetterClassifyButton *btn = static_cast(item->widget()); + QString letterstr = btn->m_letter; + + if (list.indexOf(letterstr.at(0)) == -1) { + btn->setEnabled(false); + } else { + btn->setEnabled(true); + } + + if (row * 4 + col == 27) { + break; + } } } } diff --git a/src/LetterWidget/letterbuttonwidget.h b/src/UserInterface/Widget/letter_button_widget.h old mode 100644 new mode 100755 similarity index 93% rename from src/LetterWidget/letterbuttonwidget.h rename to src/UserInterface/Widget/letter_button_widget.h index 7c03a67..bf50598 --- a/src/LetterWidget/letterbuttonwidget.h +++ b/src/UserInterface/Widget/letter_button_widget.h @@ -26,7 +26,7 @@ #include #include #include -#include "src/UtilityFunction/letterclassifybutton.h" +#include "letter_classify_button.h" class LetterButtonWidget : public QWidget { @@ -42,12 +42,15 @@ protected: */ void initUi(); + void hideEvent(QHideEvent *event); + Q_SIGNALS: /** * @brief Send button click signal to letterwidget interface * @param btnname: Category button name */ void sendLetterBtnSignal(QString btnname); + void sendResetLetterPage(); public Q_SLOTS: /** diff --git a/src/UserInterface/Widget/main_view_widget.cpp b/src/UserInterface/Widget/main_view_widget.cpp new file mode 100755 index 0000000..8a883d8 --- /dev/null +++ b/src/UserInterface/Widget/main_view_widget.cpp @@ -0,0 +1,78 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +MainViewWidget::MainViewWidget(QWidget *parent) : + QWidget(parent) +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setAutoFillBackground(false); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setFocusPolicy(Qt::StrongFocus); +} + +MainViewWidget::~MainViewWidget() +{ +} + +void MainViewWidget::styleChangeSlot(const QString &style) +{ + m_curStyle = style; + + if (style == "ukui-dark") { + m_backColor.setNamedColor("#800D0D0D"); + } else { + m_backColor.setNamedColor("#94FFFFFF"); + } +} + +void MainViewWidget::paintEvent(QPaintEvent *event) +{ +// double transparency = getTransparency(); + QRect rect = this->rect(); + QPainterPath path; + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(Qt::transparent); + qreal radius = 10; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + painter.setPen(Qt::transparent); + painter.setOpacity(0.58); + painter.fillPath(path, m_backColor); + QWidget::paintEvent(event); +} diff --git a/src/UserInterface/Widget/main_view_widget.h b/src/UserInterface/Widget/main_view_widget.h new file mode 100755 index 0000000..ebebf5a --- /dev/null +++ b/src/UserInterface/Widget/main_view_widget.h @@ -0,0 +1,70 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ukuimenuinterface.h" +#include "searchappthread.h" +#include "directory_changed_thread.h" +#include "convert_winid_to_desktop.h" +#include "style.h" +#include "src/UtilityFunction/utility.h" +#include +#include + +class MainViewWidget : public QWidget +{ + Q_OBJECT + +public: + explicit MainViewWidget(QWidget *parent = nullptr); + ~MainViewWidget(); + +protected: + + void initUi(); + + void paintEvent(QPaintEvent *event); + +public Q_SLOTS: + void styleChangeSlot(const QString &style); + +Q_SIGNALS: + + void directoryChangedSignal(); + + void sendDirectoryPath(); +private: + QString m_curStyle; + QColor m_backColor; +}; + +#endif // MAINVIEWWIDGET_H diff --git a/src/UserInterface/Widget/plugin_widget.cpp b/src/UserInterface/Widget/plugin_widget.cpp new file mode 100755 index 0000000..2881e05 --- /dev/null +++ b/src/UserInterface/Widget/plugin_widget.cpp @@ -0,0 +1,21 @@ +#include "plugin_widget.h" +#include "KySmallPluginInterface.h" +#include +pluginwidget::pluginwidget(QWidget *parent) : QWidget(parent) +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); + this->setAttribute(Qt::WA_StyledBackground, true); + this->setFocusPolicy(Qt::NoFocus); + init(); +} +void pluginwidget::init() +{ + QPluginLoader loader("/opt/small-plugin/bin/libsmall-plugin-manage.so"); + QObject *plugin = loader.instance(); + + if (plugin) { + KySmallPluginInterface *app = qobject_cast(plugin); + QWidget *widget = app->createWidget(this); + widget->setFixedSize(400, 638); + } +} diff --git a/src/UserInterface/Widget/plugin_widget.h b/src/UserInterface/Widget/plugin_widget.h new file mode 100755 index 0000000..af41deb --- /dev/null +++ b/src/UserInterface/Widget/plugin_widget.h @@ -0,0 +1,28 @@ +#ifndef PLUGINWIDGET_H +#define PLUGINWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +class pluginwidget : public QWidget +{ + Q_OBJECT +public: + explicit pluginwidget(QWidget *parent = nullptr); + void init(); +}; + +#endif // PLUGINWIDGET_H diff --git a/src/UserInterface/Widget/splitbar_frame.cpp b/src/UserInterface/Widget/splitbar_frame.cpp new file mode 100755 index 0000000..00b9d4a --- /dev/null +++ b/src/UserInterface/Widget/splitbar_frame.cpp @@ -0,0 +1,78 @@ +/* + * 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 setFixedSize(m_width, m_height); + // this->setStyleSheet("background:transparent"); + //按钮透明 + this->setFocusPolicy(Qt::NoFocus); + this->setAttribute(Qt::WA_TranslucentBackground); + QHBoxLayout *layout = new QHBoxLayout; + layout->setContentsMargins(15, 0, 0, 0); + layout->setSpacing(6); + m_textLabel->setAutoFillBackground(false); + m_textLabel->setAlignment(Qt::AlignCenter); + m_textLabel->setText(m_category); + m_textLabel->adjustSize(); + QPalette pe = m_textLabel->palette(); + pe.setColor(QPalette::WindowText, /*pe.color(QPalette::Text)*/Qt::white); + m_textLabel->setPalette(pe); + m_line->setFrameShape(QFrame::HLine); + m_line->setFixedHeight(1); + m_line->setFixedSize(m_width - m_textLabel->width() - 15, 1); + m_line->setEnabled(false); + QPalette linePe = m_line->palette(); + QColor color = /*linePe.color(QPalette::Text)*/Qt::white; + color.setAlphaF(0.10); + linePe.setColor(QPalette::WindowText, color); + m_line->setPalette(linePe); + this->setLayout(layout); + layout->addWidget(m_textLabel); + layout->addWidget(m_line); +} + +void SplitBarFrame::paintEvent(QPaintEvent *event) +{ + double transparency = getTransparency(); + QPainter painter(this); + painter.setBrush(Qt::transparent); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + QWidget::paintEvent(event); +} + diff --git a/src/UtilityFunction/splitbarframe.h b/src/UserInterface/Widget/splitbar_frame.h old mode 100644 new mode 100755 similarity index 67% rename from src/UtilityFunction/splitbarframe.h rename to src/UserInterface/Widget/splitbar_frame.h index ee33748..cafd1e0 --- a/src/UtilityFunction/splitbarframe.h +++ b/src/UserInterface/Widget/splitbar_frame.h @@ -23,13 +23,12 @@ #include #include #include -#include "src/Style/style.h" -#include "src/Interface/ukuimenuinterface.h" -#include "src/Style/style.h" -#include "src/RightClickMenu/rightclickmenu.h" +#include "style.h" +#include "ukuimenuinterface.h" +#include "rightclickmenu.h" #include "utility.h" -class SplitBarFrame : public QFrame //全屏分隔栏 +class SplitBarFrame : public QWidget //全屏分隔栏 { Q_OBJECT public: @@ -37,35 +36,20 @@ public: * @param classify为0时为分类按钮、1为应用按钮 * @param module为0时为常用模块,1为字母模块、2为功能模块 */ - SplitBarFrame(QWidget *parent,QString category,int width,int height,int module); + SplitBarFrame(QWidget *parent, QString category, int width, int height, int module); ~SplitBarFrame(); - enum Category{ - Mobile, - Internet, - Social, - Video, - Development, - Image, - Game, - Office, - Education, - System, - Others, - }; - Q_ENUM(Category) - private: QString m_category; int m_width; int m_height; int m_module; - QLabel* m_textLabel=nullptr; - QFrame* m_line=nullptr; + QLabel *m_textLabel = nullptr; + QFrame *m_line = nullptr; protected: void initAppBtn(); - void setLabelText(); + void paintEvent(QPaintEvent *event); }; #endif // PUSHBUTTON_H diff --git a/src/UserInterface/Widget/tabview_widget.cpp b/src/UserInterface/Widget/tabview_widget.cpp new file mode 100755 index 0000000..c07987b --- /dev/null +++ b/src/UserInterface/Widget/tabview_widget.cpp @@ -0,0 +1,36 @@ +#include "tabview_widget.h" +#include + +TabViewWidget::TabViewWidget() +{ + setStyleSheet("background:transparent"); + collectionTab = new QWidget(); + recentTab = new QWidget(); + collectionTab->setObjectName(QString::fromUtf8("collectionTab")); + recentTab->setObjectName(QString::fromUtf8("recentTab")); + this->addTab(collectionTab, QString()); + this->addTab(recentTab, QString()); + this->tabBar()->hide(); + this->setCurrentIndex(0); + initAppListWidget(); + updateListView(); +} + +void TabViewWidget::initAppListWidget() +{ + m_collectListView = new RightListView(collectionTab); + m_collectListView->setFixedSize(352, 428); + m_collectListView->show(); +} + +void TabViewWidget::updateListView() +{ + m_data.clear(); + + Q_FOREACH (QString desktopfp, m_ukuiMenuInterface->getAllClassification()) { + m_data.append(desktopfp); + } + + m_collectListView->addData(m_data); +} + diff --git a/src/UserInterface/Widget/tabview_widget.h b/src/UserInterface/Widget/tabview_widget.h new file mode 100755 index 0000000..ca9e999 --- /dev/null +++ b/src/UserInterface/Widget/tabview_widget.h @@ -0,0 +1,25 @@ +#ifndef TABVIEWWIDGET_H +#define TABVIEWWIDGET_H +#include +#include "rightlistview.h" + +class TabViewWidget: public QTabWidget +{ +public: + TabViewWidget(); + +protected: + + void initAppListWidget(); + void updateListView(); + +private: + + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QWidget *collectionTab = nullptr; + QWidget *recentTab = nullptr; + RightListView *m_collectListView = nullptr; + QStringList m_data; +}; + +#endif // TABVIEWWIDGET_H diff --git a/src/UserInterface/full_mainwindow.cpp b/src/UserInterface/full_mainwindow.cpp new file mode 100755 index 0000000..dfd692f --- /dev/null +++ b/src/UserInterface/full_mainwindow.cpp @@ -0,0 +1,584 @@ +#include "full_mainwindow.h" +#include +#include +#include +#include "utility.h" +#include + +FullMainWindow::FullMainWindow(QWidget *parent) : + QMainWindow(parent) +{ + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); + this->setAttribute(Qt::WA_TranslucentBackground, true); + this->setAutoFillBackground(false); + Style::initWidStyle(); + this->setFixedSize(Style::m_availableScreenWidth, Style::m_availableScreenHeight); + initLayout(); + initSearchUI(); + initButtonUI(); + initAppListUI(); + initMenu(); + initTabOrder(); + changeStyle(); + initConnect(); +} + +FullMainWindow::~FullMainWindow() +{ +} + +void FullMainWindow::initLayout() +{ + centralwidget = new QWidget(this); + verticalLayout = new QVBoxLayout(centralwidget); + verticalLayout->setSpacing(0); + verticalLayout->setContentsMargins(0, 48, 0, 0); + topHorizontalLayout = new QHBoxLayout(); + topHorizontalLayout->setSpacing(8); + topHorizontalLayout->setContentsMargins(155, 0, 35, 0); + horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + bottomHorizonLayout = new QHBoxLayout(); + bottomHorizonLayout->setSpacing(0); + bottomHorizonLayout->setContentsMargins(0, 0, 0, 0); +} + +void FullMainWindow::initButtonUI() +{ + m_buttonStyle = QString("%1{border-radius:24px; background: rgba(255, 255, 255, 0.1);}" + "%1:hover {border-radius:24px; background: rgba(255, 255, 255, 0.2);}" + "%1:pressed {border-radius:24px; background: rgba(255, 255, 255, 0.3);}"); + m_lineEdit->setFocusPolicy(Qt::StrongFocus); + horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_fullSelectToolButton = new QPushButton(centralwidget); +// fullSelectToolButton->setStyleSheet(m_buttonStyle.arg("QToolButton")); + m_fullSelectToolButton->setObjectName(QString::fromUtf8("fullSelectToolButton")); + m_fullSelectToolButton->setMinimumSize(QSize(48, 48)); + m_fullSelectToolButton->installEventFilter(this); + m_fullSelectToolButton->setFocus(); + QIcon selectIcon; + selectIcon.addFile(QString::fromUtf8(":/data/img/mainviewwidget/full-function.svg"), QSize(), QIcon::Normal, QIcon::Off); + m_fullSelectToolButton->setIcon(selectIcon); + + m_fullSelectMenuButton = new RotationLabel(this); + m_fullSelectMenuButton->installEventFilter(this); + m_fullSelectMenuButton->setStyleSheet("background: transparent;"); + m_fullSelectMenuButton->setFixedSize(QSize(16, 34)); + m_fullSelectMenuButton->setAcceptDrops(true); + m_fullSelectMenuButton->setFocusPolicy(Qt::StrongFocus); + m_fullSelectMenuButton->setIcon(QPixmap(":/data/img/mainviewwidget/DM-arrow-2x.png")); + QPalette palete; + palete.setColor(QPalette::NoRole, Qt::white); + m_fullSelectMenuButton->setPalette(palete); + m_minPushButton = new QPushButton(centralwidget); + m_minPushButton->setObjectName(QString::fromUtf8("minPushButton")); + m_minPushButton->setFixedSize(QSize(48, 48)); + m_minPushButton->setFlat(true); + m_minPushButton->installEventFilter(this); +} + +void FullMainWindow::initSearchUI() +{ + m_searchAppThread = new SearchAppThread; + m_lineEdit = new QLineEdit(centralwidget); + m_lineEdit->setFixedSize(QSize(372, 36)); + m_lineEdit->setLayoutDirection(Qt::LeftToRight); + m_lineEdit->installEventFilter(this); + m_lineEdit->setFrame(false); + m_queryWid = new QWidget; + m_queryWid->setParent(m_lineEdit); + m_queryWid->setFocusPolicy(Qt::NoFocus); + m_queryWid->setFixedSize(372, 36); + QHBoxLayout *queryWidLayout = new QHBoxLayout; + queryWidLayout->setContentsMargins(0, 0, 0, 0); + queryWidLayout->setSpacing(5); + m_queryWid->setLayout(queryWidLayout); + char style[200]; + QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/full-search.svg"), 16); + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings *gsetting = new QGSettings("org.ukui.style", QByteArray(), this); + + if (gsetting->keys().contains("styleName")) { + if (/*gsetting->get("styleName").toString() == "ukui-light"*/false) { + pixmap = drawSymbolicBlackColoredPixmap(pixmap); + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:17px;color:#000000;}", + QueryLineEditClickedBorderDefault, QueryLineEditDefaultBackground); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap); //反白 + sprintf(style, "QLineEdit{border:1px solid %s;background-color:%s;border-radius:17px;color:#ffffff;}", + QueryLineEditClickedBorderDefault, QueryLineEditBackground); + } + } + + connect(gsetting, &QGSettings::changed, [ = ](QString key) { + if ("systemFont" == key || "systemFontSize" == key) { + m_queryWid->layout()->removeWidget(m_queryText); + m_queryText->setParent(nullptr); + resetEditline(); + m_fullCommonPage->repaintWidget(); + m_fullFunctionPage->repaintWidget(); + m_fullLetterPage->repaintWidget(); + } + + if (key.contains(QString("styleName"))) { + changeStyle(); + } + + if (key.contains(QString("theme-color"))) { + QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16); + QString color = highLightColor.mid(2, 6); + QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color); + m_lineEdit->setStyleSheet(searchStyle); + } + }); + } + + m_lineEdit->setStyleSheet(style); + pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); + m_queryIcon = new QLabel; + m_queryIcon->setFixedSize(pixmap.size()); + m_queryIcon->setPixmap(pixmap); + m_queryText = new QLabel; + QPalette pa; + pa.setColor(QPalette::Text, Qt::white); + m_queryText->setPalette(pa); + m_queryText->setText(tr("Search")); + m_queryText->adjustSize(); + queryWidLayout->addWidget(m_queryIcon); + queryWidLayout->addWidget(m_queryText); + queryWidLayout->setAlignment(Qt::AlignCenter); +} + +void FullMainWindow::initAppListUI() +{ + m_fullStackedWidget = new QStackedWidget(centralwidget); + m_fullCommonPage = new FullCommonUseWidget(m_fullStackedWidget); + m_fullStackedWidget->addWidget(m_fullCommonPage); + m_fullLetterPage = new FullLetterWidget(m_fullStackedWidget); + m_fullStackedWidget->addWidget(m_fullLetterPage); + m_fullFunctionPage = new FullFunctionWidget(m_fullStackedWidget); + m_fullStackedWidget->addWidget(m_fullFunctionPage); + m_fullResultPage = new FullSearchResultWidget(m_fullStackedWidget); + m_fullStackedWidget->addWidget(m_fullResultPage); + bottomHorizonLayout->addWidget(m_fullStackedWidget); + // bottomHorizonLayout->addWidget(verticalScrollBar); + topHorizontalLayout->addItem(horizontalSpacer); + topHorizontalLayout->addWidget(m_lineEdit); + topHorizontalLayout->addItem(horizontalSpacer_2); + topHorizontalLayout->addWidget(m_fullSelectToolButton); + topHorizontalLayout->addWidget(m_fullSelectMenuButton); + topHorizontalLayout->addWidget(m_minPushButton); + verticalLayout->addLayout(topHorizontalLayout); + verticalLayout->addLayout(bottomHorizonLayout); + this->setCentralWidget(centralwidget); + m_fullStackedWidget->setCurrentIndex(0); +} + +void FullMainWindow::initMenu() +{ + m_dropDownMenu = new MenuBox(this); + m_allAction = new QAction(m_dropDownMenu); + m_letterAction = new QAction(m_dropDownMenu); + m_funcAction = new QAction(m_dropDownMenu); + m_allAction->setText(tr("All")); + m_allAction->setCheckable(true); + m_letterAction->setText(tr("Letter")); + m_letterAction->setCheckable(true); + m_funcAction->setText(tr("Function")); + m_funcAction->setCheckable(true); + m_dropDownMenu->addAction(m_allAction); + m_dropDownMenu->addAction(m_letterAction); + m_dropDownMenu->addAction(m_funcAction); + m_allAction->setChecked(true); +} + +void FullMainWindow::initTabOrder() +{ + setTabOrder(m_lineEdit, m_fullSelectToolButton); + setTabOrder(m_fullSelectToolButton, m_fullSelectMenuButton); + setTabOrder(m_fullSelectMenuButton, m_minPushButton); +} + +void FullMainWindow::initConnect() +{ + connect(m_lineEdit, &QLineEdit::textChanged, this, &FullMainWindow::searchAppSlot); + connect(this, &FullMainWindow::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword); + connect(m_searchAppThread, &SearchAppThread::sendSearchResult, this, &FullMainWindow::recvSearchResult); + connect(m_minPushButton, &QPushButton::clicked, this, &FullMainWindow::on_minPushButton_clicked); + connect(m_fullSelectToolButton, &QToolButton::clicked, this, &FullMainWindow::on_fullSelectToolButton_clicked); + connect(m_fullFunctionPage, &FullFunctionWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); + connect(m_fullLetterPage, &FullLetterWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); + connect(m_fullCommonPage, &FullCommonUseWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); + connect(m_fullResultPage, &FullSearchResultWidget::setFocusToSideWin, this, &FullMainWindow::setFocusToButton); + connect(this, &FullMainWindow::sendSetFocusToCom, m_fullCommonPage, &FullCommonUseWidget::selectFirstItemTab); + connect(this, &FullMainWindow::sendSetFocusToLet, m_fullLetterPage, &FullLetterWidget::setFocusToThis); + connect(this, &FullMainWindow::sendSetFocusToFun, m_fullFunctionPage, &FullFunctionWidget::setFocusToThis); + connect(this, &FullMainWindow::sendSetFocusToResult, m_fullResultPage, &FullSearchResultWidget::selectFirstItemTab); +// connect(m_fullSelectMenuButton, &QToolButton::clicked, this, &FullMainWindow::on_fullSelectMenuButton_clicked); + connect(m_fullCommonPage, &FullCommonUseWidget::sendUpdateOtherView, this, &FullMainWindow::sendUpdateOtherView); + connect(m_fullFunctionPage, &FullFunctionWidget::sendUpdateCommonView, m_fullCommonPage, &FullCommonUseWidget::updateListViewSlot); + connect(m_fullLetterPage, &FullLetterWidget::sendUpdateCommonView, m_fullCommonPage, &FullCommonUseWidget::updateListViewSlot); + connect(m_fullCommonPage, &FullCommonUseWidget::sendHideMainWindowSignal, this, &FullMainWindow::fullWindowHide); + connect(m_fullFunctionPage, &FullFunctionWidget::sendHideMainWindowSignal, this, &FullMainWindow::fullWindowHide); + connect(m_fullLetterPage, &FullLetterWidget::sendHideMainWindowSignal, this, &FullMainWindow::fullWindowHide); + connect(m_fullResultPage, &FullSearchResultWidget::sendHideMainWindowSignal, this, &FullMainWindow::fullWindowHide); + connect(m_dropDownMenu, &MenuBox::triggered, this, &FullMainWindow::on_fullSelectMenuButton_triggered); + connect(m_dropDownMenu, &MenuBox::sendMainWinActiveSignal, [ = ]() { + selectIconAnimation(false); + }); +} + +void FullMainWindow::updateView() +{ + m_fullCommonPage->updateListView(); + m_fullFunctionPage->updateAppListView(); + m_fullLetterPage->updateAppListView(); +} + +void FullMainWindow::changeStyle() +{ + QPalette linePe; + QString buttonColorDefault; + QString buttonColorHover; + QString buttonColorPress; + QColor buttonColor; + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.keys().contains(QString("styleName"))) { + if (/*gsetting.get("style-name").toString() == "ukui-light"*/false) { + buttonColorDefault = "rgba(16, 23, 29, 0.06)"; + buttonColorHover = "rgba(16, 23, 29, 0.12)"; + buttonColorPress = "rgba(16, 23, 29, 0.17)"; + } else { + buttonColor = linePe.color(QPalette::Light); + QRgb rgbDefault = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 25); + buttonColorDefault = "#" + QString::number(rgbDefault, 16); + QRgb rgbHover = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 50); + buttonColorHover = "#" + QString::number(rgbHover, 16); + QRgb rgbPress = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 75); + buttonColorPress = "#" + QString::number(rgbPress, 16); + } + } + } + + m_buttonStyle = QString("%1{border-radius:24px; background:" + buttonColorDefault + ";}" + "%1:hover {border-radius:24px; background:" + buttonColorHover + ";}" + "%1:pressed {border-radius:24px; background:" + buttonColorPress + ";}"); + m_fullSelectToolButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); + m_fullSelectMenuButton->setIcon(QPixmap(":/data/img/mainviewwidget/DM-arrow-2x.png")); + m_minPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/full-min.svg", false)); + m_minPushButton->setProperty("useIconHighlightEffect", 0x0); +} + +void FullMainWindow::on_minPushButton_clicked() +{ + Q_EMIT showNormalWindow(); +} + +void FullMainWindow::paintEvent(QPaintEvent *event) +{ + double transparency = getTransparency(); + QPainterPath path; + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(Qt::transparent); + painter.setBrush(this->palette().dark()); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawRect(this->rect()); + path.addRect(this->rect()); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); + QMainWindow::paintEvent(event); +} + +bool FullMainWindow::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_lineEdit) { + m_isSearching = true; + QString style; + + if (event->type() == QEvent::FocusIn) { + QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16); + QString color = highLightColor.mid(2, 6); + style = QString("QLineEdit{border:2px solid #%1;background-color:%2;border-radius:17px;color:#ffffff;}") + .arg(color).arg(QueryLineEditClickedBackground); + m_lineEdit->setStyleSheet(style); + myDebug() <text().isEmpty()) { + qDebug() << "bool FullMainWindow::eventFilter(QObject *watched, QEvent *event)" << m_queryWid->layout()->count(); + + if (m_queryWid->layout()->count() == 2) { + m_queryWid->layout()->removeWidget(m_queryText); + m_queryText->setParent(nullptr); + } + + m_queryWid->setGeometry(6, 2, m_queryIcon->width() + 5, Style::QueryLineEditHeight); + m_queryWid->layout()->setAlignment(Qt::AlignVCenter); + m_lineEdit->setTextMargins(26, 0, 0, 0); + } + } else if (event->type() == QEvent::FocusOut && m_lineEdit->text().isEmpty()) { + style = QString("QLineEdit{border:1px solid %1;background-color:%2;border-radius:17px;color:#ffffff;}") + .arg(QueryLineEditClickedBorderDefault).arg(QueryLineEditClickedBackground); + m_lineEdit->setStyleSheet(style); + resetEditline(); + } + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Down) { + Q_EMIT sendSetFocusToResult(); + } + } + } + + if (watched == m_minPushButton) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Tab) { + if (m_fullStackedWidget->currentIndex() == 0) { + Q_EMIT sendSetFocusToCom(); + } else if (m_fullStackedWidget->currentIndex() == 1) { + Q_EMIT sendSetFocusToLet(); + } else if (m_fullStackedWidget->currentIndex() == 2) { + Q_EMIT sendSetFocusToFun(); + } else { + Q_EMIT sendSetFocusToResult(); + } + + return true; + } + } + } + + if (watched == m_minPushButton || watched == m_fullSelectToolButton || watched == m_fullSelectMenuButton) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + + if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down || + ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { + return true; + } + } + } + + if (watched == m_fullSelectMenuButton) { + if (event->type() == QEvent::MouseButtonPress) { + selectIconAnimation(true); + return true; + } + } + + return QWidget::eventFilter(watched, event); +} + +void FullMainWindow::iconAnimationFinished() +{ + m_dropDownMenu->raise(); + m_dropDownMenu->exec(m_fullSelectMenuButton->mapToGlobal(QPoint(m_fullSelectMenuButton->width() + - m_dropDownMenu->sizeHint().width(), 45))); +} + +void FullMainWindow::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + if ((e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) || (e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z)) { + qDebug() << "void MainWindow::keyPressEvent(QKeyEvent *e)" << e->text(); + m_lineEdit->setFocus(); + m_lineEdit->setText(e->text()); + } + + if (e->key() == Qt::Key_Backspace) { + if (!m_lineEdit->text().isEmpty()) { + m_lineEdit->setText(""); + } + } + } +} + +void FullMainWindow::selectIconAnimation(const bool &flag) +{ + iconAnimation = new QPropertyAnimation(m_fullSelectMenuButton, "rotation", this); + + if (flag) { + connect(iconAnimation, &QPropertyAnimation::finished, this, &FullMainWindow::iconAnimationFinished); + + if (m_fullSelectMenuButton->property("rotation") == 0) { + iconAnimation->setStartValue(0); + iconAnimation->setEndValue(-180); + } + } else { + if (m_fullSelectMenuButton->property("rotation") == -180) { + iconAnimation->setStartValue(-180); + iconAnimation->setEndValue(0); + } + } + + iconAnimation->setEasingCurve(QEasingCurve::Linear); + iconAnimation->setDuration(300); + iconAnimation->start(QPropertyAnimation::DeleteWhenStopped); +} + +void FullMainWindow::fullWindowHide() +{ + this->hide(); +} + +void FullMainWindow::resetEditline() +{ + m_lineEdit->clear(); + m_lineEdit->clearFocus(); + m_fullSelectToolButton->setFocus(); + if (m_queryWid->layout()->children().isEmpty()) { + m_queryWid->layout()->addWidget(m_queryIcon); + m_queryWid->layout()->addWidget(m_queryText); + } + m_queryIcon->adjustSize(); + m_queryText->adjustSize(); + m_queryWid->layout()->setAlignment(Qt::AlignCenter); + m_queryWid->setFixedSize(372, 36); +} + +bool FullMainWindow::event(QEvent *event) +{ + if (event->type() == QEvent::ActivationChange) { + qDebug() << " * 鼠标点击窗口外部事件"; + + if (QApplication::activeWindow() != this) { + this->hide(); + } /*else { + + fullLetterPage->repaintWidget(); + fullFunctionPage->repaintWidget(); + }*/ + } + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = (QKeyEvent *) event; + + if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { + if (m_fullSelectToolButton->hasFocus()) { + m_fullSelectToolButton->click(); + } else if (m_fullSelectMenuButton->hasFocus()) { + QApplication::postEvent(m_fullSelectMenuButton, new QEvent(QEvent::MouseButtonPress)); + } + + if (m_lineEdit->hasFocus()) { + m_fullResultPage->setFocus(); + } else { + QWidget *current_focus_widget; + current_focus_widget = QWidget::focusWidget(); + QPushButton *le = qobject_cast(current_focus_widget); + + if (le != nullptr) { + le->clicked(); + } + } + } + + if (keyEvent->key() == Qt::Key_Escape) { + m_lineEdit->clear(); + this->hide(); + } + } + + return QWidget::event(event); +} + +void FullMainWindow::setFocusToButton() +{ + qDebug() << "设置lineEdit焦点"; + m_lineEdit->setFocus(); +} + +void FullMainWindow::searchAppSlot(QString arg) +{ + if (!arg.isEmpty()) { //切换至搜索模块 + Q_EMIT sendSearchKeyword(arg); + m_searchAppThread->start(); + m_fullStackedWidget->setCurrentIndex(3); + } else { + m_fullStackedWidget->setCurrentIndex(m_state); + m_fullFunctionPage->repaintWidget(); + m_fullLetterPage->repaintWidget(); + } +} + +void FullMainWindow::mousePressEvent(QMouseEvent *event) +{ + resetEditline(); + if (event->button() == Qt::LeftButton) { + this->hide(); + } + return QMainWindow::mousePressEvent(event); +} + +void FullMainWindow::recvSearchResult(QVector arg) +{ + m_searchAppThread->quit(); + m_fullResultPage->updateAppListView(arg); +} + +void FullMainWindow::on_fullSelectToolButton_clicked() +{ + resetEditline(); + m_fullSelectToolButton->setFocus(); + selectIconAnimation(false); + + if (m_fullStackedWidget->currentIndex() == 0) { + on_fullSelectMenuButton_triggered(m_letterAction); + } else if (m_fullStackedWidget->currentIndex() == 1) { + on_fullSelectMenuButton_triggered(m_funcAction); + } else if (m_fullStackedWidget->currentIndex() == 2) { + on_fullSelectMenuButton_triggered(m_allAction); + } +} + +void FullMainWindow::on_fullSelectMenuButton_clicked() +{ + resetEditline(); +} + +void FullMainWindow::on_fullSelectMenuButton_triggered(QAction *arg1) +{ + selectIconAnimation(false); + + if (arg1 == m_allAction) { + m_fullStackedWidget->setCurrentIndex(0); + m_fullCommonPage->repaintWidget(); + //fullCommonPage->updateListView(); + m_state = 0; + m_fullSelectToolButton->setIcon(QIcon(":/data/img/mainviewwidget/full-all-2x.png")); + m_allAction->setChecked(true); + m_letterAction->setChecked(false); + m_funcAction->setChecked(false); + } else if (arg1 == m_letterAction) { + m_fullStackedWidget->setCurrentIndex(1); + m_fullLetterPage->repaintWidget(); + m_state = 1; + m_fullSelectToolButton->setIcon(QIcon(":/data/img/mainviewwidget/full-letter.svg")); + m_allAction->setChecked(false); + m_letterAction->setChecked(true); + m_funcAction->setChecked(false); + } else if (arg1 == m_funcAction) { + m_fullStackedWidget->setCurrentIndex(2); + m_fullFunctionPage->repaintWidget(); + m_state = 2; + m_fullSelectToolButton->setIcon(QIcon(":/data/img/mainviewwidget/full-function.svg")); + m_allAction->setChecked(false); + m_letterAction->setChecked(false); + m_funcAction->setChecked(true); + } +} + +void FullMainWindow::repaintWidget() +{ + m_fullCommonPage->repaintWidget(); + m_fullFunctionPage->repaintWidget(); + m_fullLetterPage->repaintWidget(); + m_fullResultPage->repaintWidget(); +} diff --git a/src/UserInterface/full_mainwindow.h b/src/UserInterface/full_mainwindow.h new file mode 100755 index 0000000..9592169 --- /dev/null +++ b/src/UserInterface/full_mainwindow.h @@ -0,0 +1,102 @@ +#ifndef FULLMAINWINDOW_H +#define FULLMAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include "full_commonuse_widget.h" +#include "full_function_widget.h" +#include "full_letter_widget.h" +#include "searchappthread.h" +#include "full_searchresult_widget.h" +#include "rotationlabel.h" + +class FullMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit FullMainWindow(QWidget *parent = nullptr); + ~FullMainWindow(); +public: + void updateView(); + void resetEditline(); + void repaintWidget(); + +Q_SIGNALS: + + void showNormalWindow(); + void sendSearchKeyword(QString arg); + void sendSetFocusToCom(); + void sendSetFocusToFun(); + void sendSetFocusToLet(); + void sendSetFocusToResult(); + void sendUpdateOtherView(); + +private Q_SLOTS: + + void on_minPushButton_clicked(); + void on_fullSelectToolButton_clicked(); + void on_fullSelectMenuButton_triggered(QAction *arg1); + void searchAppSlot(QString arg); + void recvSearchResult(QVector arg); + void setFocusToButton(); + void on_fullSelectMenuButton_clicked(); + void fullWindowHide(); + + +protected: + void paintEvent(QPaintEvent *event); + bool event(QEvent *event); + bool eventFilter(QObject *watched, QEvent *event); + void mousePressEvent(QMouseEvent *event); + void changeStyle(); + void initConnect(); + void initTabOrder(); + void initMenu(); + void initAppListUI(); + void initSearchUI(); + void initButtonUI(); + void initLayout(); + void selectIconAnimation(const bool &flag); + void iconAnimationFinished(); + void keyPressEvent(QKeyEvent *e); + +private: + QAction *m_allAction = nullptr; + QAction *m_letterAction = nullptr; + QAction *m_funcAction = nullptr; + QMenu *m_menu = nullptr; + + QWidget *centralwidget; + QVBoxLayout *verticalLayout; + QHBoxLayout *topHorizontalLayout; + QHBoxLayout *bottomHorizonLayout; + QSpacerItem *horizontalSpacer; + QLineEdit *m_lineEdit; + QSpacerItem *horizontalSpacer_2; + QPushButton *m_fullSelectToolButton; + RotationLabel *m_fullSelectMenuButton; + QPushButton *m_minPushButton; + QStackedWidget *m_fullStackedWidget; + + FullCommonUseWidget *m_fullCommonPage; + FullLetterWidget *m_fullLetterPage; + FullFunctionWidget *m_fullFunctionPage; + FullSearchResultWidget *m_fullResultPage; + + SearchAppThread *m_searchAppThread = nullptr; + int m_state = 0; + QWidget *m_queryWid = nullptr; + QLabel *m_queryIcon = nullptr; + QLabel *m_queryText = nullptr; + bool m_isSearching = false; + QString m_buttonStyle; + QPropertyAnimation *iconAnimation = nullptr; + MenuBox *m_dropDownMenu = nullptr; +}; + +#endif // FULLMAINWINDOW_H diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp new file mode 100755 index 0000000..8427b34 --- /dev/null +++ b/src/UserInterface/mainwindow.cpp @@ -0,0 +1,1423 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "style.h" +#include +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent) +{ + Style::initWidStyle(); + openDataBase("MainThreadDataBase"); + initDatabase(); + this->resize(Style::minw, Style::minh); + this->setAutoFillBackground(false); + m_centralwidget = new QWidget(this); + m_centerLayout = new QHBoxLayout(m_centralwidget); + m_centerLayout->setSpacing(0); + m_centerLayout->setContentsMargins(0, 0, 0, 0); + //左侧 + m_viewWidget = new MainViewWidget(m_centralwidget); + m_mainLeftVerticalLayout = new QVBoxLayout(m_viewWidget); + m_mainLeftVerticalLayout->setSpacing(9); + m_mainLeftVerticalLayout->setContentsMargins(8, 15, 4, 0); + + initSearchUi(); + initLeftWidget(); + initRightWidgetButton(); + initCollectWidget(); + initRecentWidget(); + initTabOrder(); + + m_softwareDbThread = new SoftwareDatabaseUpdateThread; + m_animationPage = new AnimationPage(); + m_maxAnimation = new QPropertyAnimation(m_animationPage, "geometry", this); + m_minAnimation = new QPropertyAnimation(m_animationPage, "geometry", this); + m_searchAppThread = new SearchAppThread; + m_functionBtnWid = new FunctionButtonWidget(m_minFuncPage); + m_functionBtnWid->hide(); + m_letterBtnWid = new LetterButtonWidget(m_minLetterPage); + m_letterBtnWid->hide(); + m_enterAnimation = new QPropertyAnimation; + m_enterAnimation->setPropertyName(QString("geometry").toLocal8Bit()); + m_leaveAnimation = new QPropertyAnimation; + m_leaveAnimation->setPropertyName(QString("geometry").toLocal8Bit()); + + //获取软件商店类别信号 + QDBusConnection::sessionBus().connect("com.kylin.softwarecenter.getsearchresults", + "/com/kylin/softwarecenter/getsearchresults", + "com.kylin.getsearchresults", + "get_app_category_list_signal", + this, + SLOT(updateAppCategorySlot(QString)) + ); + setTabletModeFlag(); + initUi(); + registDbusServer(); + initSignalConnect(); + initGsettings(); +} + +MainWindow::~MainWindow() +{ + closeDataBase("MainThread"); + + if (m_animationPage != nullptr) { + delete m_animationPage; + m_animationPage = nullptr; + } +} + +void MainWindow::setTabletModeFlag() +{ + QDBusConnection::sessionBus().connect("com.kylin.statusmanager.interface", + "/", + "com.kylin.statusmanager.interface", + "mode_change_signal", + this, + SLOT(tabletModeChangeSlot(bool))); + m_usrInterface = new QDBusInterface("com.kylin.statusmanager.interface", + "/", + "com.kylin.statusmanager.interface", + QDBusConnection::sessionBus(), this); + QDBusReply res = m_usrInterface->call("get_current_tabletmode"); + if (res.isValid()) { + m_isTabletMode = res; + } +} + +void MainWindow::tabletModeChangeSlot(bool flag) +{ + m_isTabletMode = flag; +} + +void MainWindow::registDbusServer() +{ + m_dbus = new DBus; + new MenuAdaptor(m_dbus); + m_fullWindow = new FullMainWindow; + QDBusConnection con = QDBusConnection::sessionBus(); + + if (!con.registerService("org.ukui.menu") || + !con.registerObject("/org/ukui/menu", m_dbus)) { + qDebug() << "error:" << con.lastError().message(); + } + + connect(m_dbus, &DBus::sendReloadSignal, this, [ = ] { + updateView(); + }); + connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { + + if (m_isTabletMode) { + return; + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); + + if (gsetting.keys().contains("winKeyRelease")) + if (gsetting.get("winKeyRelease").toBool()) { + return; + } + } + if (QGSettings::isSchemaInstalled(QString("org.ukui.screenshot").toLocal8Bit())) + { + QGSettings gsetting(QString("org.ukui.screenshot").toLocal8Bit()); + + if (gsetting.keys().contains("isrunning")) + if (gsetting.get("isrunning").toBool()) { + return; + } + } + + if (this->isVisible()) + { + this->hide(); + m_topStackedWidget->setCurrentIndex(0); + m_lineEdit->clear(); + this->clearFocus(); + m_isFullScreen = false; + } else if (m_fullWindow->isVisible()) + { + m_fullWindow->hide(); + m_fullWindow->clearFocus(); + m_fullWindow->resetEditline(); + m_isFullScreen = true; + } else + { + if (!m_isFullScreen) { + this->show(); + setMinWindowPos(); + this->raise(); + this->activateWindow(); + on_collectPushButton_clicked(); + m_viewWidget->setFocus(); + } else { + m_fullWindow->show(); + setMaxWindowPos(); + m_fullWindow->raise(); + m_fullWindow->activateWindow(); + } + } + }); + + repaintWidget(); +} + +void MainWindow::initSignalConnect() +{ + connect(this, &MainWindow::sendClassificationbtnList, m_functionBtnWid, &FunctionButtonWidget::recvClassificationBtnList); + connect(this, &MainWindow::sendLetterClassificationList, m_letterBtnWid, &LetterButtonWidget::recvLetterBtnList); + // connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal,this,&FunctionWidget::recvFunctionBtnSignal); + connect(m_minFuncListView, &ListView::sendAppClassificationBtnClicked, this, &MainWindow::appClassificationBtnClickedSlot); + connect(m_minLetterListView, &ListView::sendAppClassificationBtnClicked, this, &MainWindow::appClassificationBtnClickedSlot); + connect(m_leaveAnimation, &QPropertyAnimation::finished, this, &MainWindow::animationFinishedSLot); + connect(m_enterAnimation, &QPropertyAnimation::finished, this, &MainWindow::animationFinishedSLot); + connect(m_functionBtnWid, &FunctionButtonWidget::sendFunctionBtnSignal, this, &MainWindow::recvFunctionBtnSignal); + connect(m_letterBtnWid, &LetterButtonWidget::sendLetterBtnSignal, this, &MainWindow::recvFunctionBtnSignal); + connect(m_functionBtnWid, &FunctionButtonWidget::sendResetFunctionPage, this, &MainWindow::resetFunctionPage); + connect(m_letterBtnWid, &LetterButtonWidget::sendResetLetterPage, this, &MainWindow::resetLetterPage); + connect(m_maxAnimation, &QPropertyAnimation::finished, this, &MainWindow::maxAnimationFinished); + connect(m_minAnimation, &QPropertyAnimation::finished, this, &MainWindow::minAnimationFinished); + connect(m_lineEdit, &QLineEdit::textChanged, this, &MainWindow::searchAppSlot); + connect(this, &MainWindow::sendSearchKeyword, m_searchAppThread, &SearchAppThread::recvSearchKeyword); + connect(m_searchAppThread, &SearchAppThread::sendSearchResult, this, &MainWindow::recvSearchResult); + connect(m_fullWindow, &FullMainWindow::showNormalWindow, this, &MainWindow::showNormalWindowSlot); + connect(m_fullWindow, &FullMainWindow::sendUpdateOtherView, this, &MainWindow::updateMinAllView); + connect(m_minSelectButton, &QToolButton::clicked, this, &MainWindow::on_minSelectButton_clicked); + connect(m_dropDownMenu, &MenuBox::triggered, this, &MainWindow::on_selectMenuButton_triggered); + connect(m_dropDownMenu, &MenuBox::sendMainWinActiveSignal, [ = ]() { + selectIconAnimation(false); + }); + connect(m_powerOffButton, &QPushButton::customContextMenuRequested, this, &MainWindow::on_powerOffButton_customContextMenuRequested); + connect(m_powerOffButton, &QPushButton::clicked, this, &MainWindow::on_powerOffButton_clicked); + connect(m_cancelSearchPushButton, &QPushButton::clicked, this, &MainWindow::on_cancelSearchPushButton_clicked); + connect(m_searchPushButton, &QPushButton::clicked, this, &MainWindow::on_searchPushButton_clicked); + connect(m_minMaxChangeButton, &QPushButton::clicked, this, &MainWindow::on_minMaxChangeButton_clicked); + connect(m_minAllListView, &ListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); + connect(m_minFuncListView, &ListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); + connect(m_minLetterListView, &ListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); + connect(m_collectListView, &RightListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); +// QDBusConnection::sessionBus().connect(DBUS_NAME, DBUS_PATH, DBUS_INTERFACE, QString("PanelGeometryRefresh"), this, SLOT(primaryScreenChangeSlot())); + connect(QApplication::desktop(), &QDesktopWidget::resized, this, &MainWindow::primaryScreenChangeSlot); + connect(QApplication::desktop(), &QDesktopWidget::primaryScreenChanged, this, &MainWindow::primaryScreenChangeSlot); + connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged, this, &MainWindow::primaryScreenChangeSlot); + + //监控应用进程开启 + connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [ = ](WId id) { + ConvertWinidToDesktop reply; + QString desktopfp = reply.tranIdToDesktop(id); + + if (!desktopfp.isEmpty()) { + ViewOpenedSlot(desktopfp); + } + }); +} + +void MainWindow::initGsettings() +{ + //监听屏幕缩放 + if (QGSettings::isSchemaInstalled(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit())) { + QGSettings *m_gsetting = new QGSettings(QString("org.ukui.SettingsDaemon.plugins.xsettings").toLocal8Bit()); + connect(m_gsetting, &QGSettings::changed, this, [ = ](const QString & key) { + if (key == "scalingFactor") { + repaintWidget(); + } + }); + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { + QGSettings *gsetting = new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit()); + connect(gsetting, &QGSettings::changed, + this, &MainWindow::repaintWidget); + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings *gsetting = new QGSettings("org.ukui.style", QByteArray(), this); + connect(gsetting, &QGSettings::changed, [ = ](QString key) { + if ("systemFont" == key || "systemFontSize" == key) { + m_leftTopSearchHorizontalLayout->removeWidget(m_lineEdit); + m_leftTopSearchHorizontalLayout->removeWidget(m_cancelSearchPushButton); + m_lineEdit->setParent(nullptr); + m_leftTopSearchHorizontalLayout->addWidget(m_lineEdit); + m_leftTopSearchHorizontalLayout->addWidget(m_cancelSearchPushButton); + m_lineEdit->setPlaceholderText("搜索应用"); + m_fullWindow->updateView(); + } + + if (key.contains(QString("styleName"))) { + changeStyle(); + } + + if (key.contains(QString("theme-color"))) { + QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16); + QString color = highLightColor.mid(2, 6); + QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color); + m_lineEdit->setStyleSheet(searchStyle); + } + }); + } +} + +void MainWindow::initSearchUi() +{ + //搜索框部分 + m_topStackedWidget = new QStackedWidget(m_viewWidget); + m_topStackedWidget->setFixedHeight(34); + //搜索框收起页 + m_minMenuPage = new QWidget(); + m_minMenuPage->setMinimumSize(QSize(0, 34)); + m_letfTopSelectHorizontalLayout = new QHBoxLayout(m_minMenuPage); + m_letfTopSelectHorizontalLayout->setSpacing(2); + m_letfTopSelectHorizontalLayout->setContentsMargins(8, 0, 4, 0); + m_minSelectTextLabel = new QLabel(m_minMenuPage); + m_horizontalSpacer = new QSpacerItem(58, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_searchPushButton = new QPushButton(m_minMenuPage); +// m_searchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); + m_searchPushButton->setFixedSize(QSize(26, 26)); + m_searchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/search.svg", true)); + m_searchPushButton->installEventFilter(this); + m_searchPushButton->setToolTip(tr("Search")); + m_minSelectButton = new QPushButton(m_minMenuPage); + m_minSelectButton->setFixedSize(QSize(26, 26)); + m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-all.svg", true)); + m_minSelectButton->setToolTip(tr("All")); + m_minSelectButton->installEventFilter(this); + m_selectMenuButton = new RotationLabel(m_minMenuPage); + m_selectMenuButton->installEventFilter(this); + m_selectMenuButton->setStyleSheet("background: transparent;"); + m_selectMenuButton->setFixedSize(QSize(8, 26)); + m_selectMenuButton->setAcceptDrops(true); + m_selectMenuButton->setFocusPolicy(Qt::StrongFocus); + m_selectMenuButton->setIcon(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true) + .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); + //搜索框展开页 + m_minSearchPage = new QWidget(); + m_leftTopSearchHorizontalLayout = new QHBoxLayout(m_minSearchPage); + m_leftTopSearchHorizontalLayout->setContentsMargins(8, 0, 8, 0); + m_lineEdit = new QLineEdit(m_minSearchPage); + m_lineEdit->setMinimumSize(QSize(30, 26)); + QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16); + QString color = highLightColor.mid(2, 6); + QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color); + m_lineEdit->setStyleSheet(searchStyle); + m_lineEdit->setFrame(false); + m_lineEdit->setPlaceholderText(tr("Search")); + m_lineEdit->installEventFilter(this); + m_cancelSearchPushButton = new QPushButton(m_minSearchPage); + m_cancelSearchPushButton->setFixedSize(QSize(26, 26)); +// m_cancelSearchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); + m_cancelSearchPushButton->installEventFilter(this); + m_cancelSearchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-close-2x.png", true)); + m_topStackedWidget->addWidget(m_minMenuPage); + m_topStackedWidget->addWidget(m_minSearchPage); +} + +void MainWindow::initLeftWidget() +{ + //左侧列表区 + m_leftStackedWidget = new QStackedWidget(m_viewWidget); + m_leftStackedWidget->setFixedSize(QSize(300, Style::leftPageHeight)); + m_minAllPage = new QWidget(); + m_minAllPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minAllListView = new ListView(m_minAllPage); + m_minAllListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minAllListView->setFrameShape(QFrame::NoFrame); + m_leftStackedWidget->addWidget(m_minAllPage); + m_minAllListView->installEventFilter(this); + m_minLetterPage = new QWidget(); + m_minLetterPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minLetterListView = new ListView(m_minLetterPage); + m_minLetterListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minLetterListView->setFrameShape(QFrame::NoFrame); + m_leftStackedWidget->addWidget(m_minLetterPage); + m_minLetterListView->installEventFilter(this); + m_minFuncPage = new QWidget(); + m_minFuncPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minFuncListView = new ListView(m_minFuncPage); + m_minFuncListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minFuncListView->setFrameShape(QFrame::NoFrame); + m_leftStackedWidget->addWidget(m_minFuncPage); + m_minFuncListView->installEventFilter(this); + m_minSearchResultPage = new QWidget(); + m_minSearchResultPage->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minSearchResultListView = new ListView(m_minSearchResultPage); + m_minSearchResultListView->setFixedSize(QSize(Style::leftPageWidth, Style::leftPageHeight)); + m_minSearchResultListView->installEventFilter(this); + m_leftStackedWidget->addWidget(m_minSearchResultPage); +} + +void MainWindow::initRightWidgetButton() +{ + //右侧窗口 + m_mainRightVerticalLayout = new QVBoxLayout(); + m_mainRightVerticalLayout->setSpacing(0); + m_mainRightVerticalLayout->setContentsMargins(8, 6, 8, 8); + m_mainRightVerticalLayout_1 = new QVBoxLayout(); + m_rightTopHorizontalLayout = new QHBoxLayout(); + m_rightTopHorizontalLayout->setSpacing(30); + m_rightTopHorizontalLayout->setContentsMargins(8, 0, 10, 0); + //收藏按键 + m_collectPushButton = new QLabel(m_centralwidget); + m_collectPushButton->setFocusPolicy(Qt::StrongFocus); + m_collectPushButton->setFixedHeight(34); +// m_collectPushButton->setFlat(true); + m_collectPushButton->installEventFilter(this); + //最近按键 + m_recentPushButton = new QLabel(m_centralwidget); + m_recentPushButton->setFixedHeight(34); + m_recentPushButton->setFocusPolicy(Qt::StrongFocus); +// m_recentPushButton->setFlat(true); + m_recentPushButton->installEventFilter(this); + m_horizontalSpacer_3 = new QSpacerItem(332, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + //放大缩小按键 + m_minMaxChangeButton = new QPushButton(m_centralwidget); + m_minMaxChangeButton->setFixedSize(QSize(24, 24)); + m_minMaxChangeButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-max.svg", true)); + m_minMaxChangeButton->setFlat(true); + m_rightTopHorizontalLayout->addWidget(m_collectPushButton); + m_rightTopHorizontalLayout->addWidget(m_recentPushButton); + m_rightTopHorizontalLayout->addItem(m_horizontalSpacer_3); + m_rightTopHorizontalLayout->addWidget(m_minMaxChangeButton); + m_verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); +} + +void MainWindow::initCollectWidget() +{ + //右侧列表区 + m_rightStackedWidget = new QStackedWidget(m_centralwidget); + m_rightStackedWidget->setFixedSize(QSize(352, 490)); + m_rightStackedWidget->setFocusPolicy(Qt::StrongFocus); + m_collectPage = new QWidget(); + m_collectPage->setFixedSize(QSize(332, 480)); + m_rightCollectLayout = new QVBoxLayout(m_collectPage); + m_rightCollectLayout->setContentsMargins(0, 18, 0, 0); + //收藏视图 + m_collectListView = new RightListView(m_collectPage); + m_collectListView->setFixedSize(QSize(332, 420)); + m_collectListView->setAcceptDrops(true); + m_collectListView->setAutoFillBackground(false); + m_collectListView->setProperty("showDropIndicator", QVariant(true)); + m_collectListView->setDragEnabled(true); + m_collectListView->setDragDropMode(QAbstractItemView::InternalMove); + m_collectListView->setDefaultDropAction(Qt::MoveAction); + m_collectListView->setMovement(QListView::Snap); + m_collectListView->setProperty("isWrapping", QVariant(true)); + m_collectListView->setWordWrap(true); + m_collectListView->setSelectionRectVisible(true); + m_collectListView->installEventFilter(this); + m_recentPage = new QWidget(); + m_recentPage->setFixedSize(QSize(352, 490)); + m_rightRecentLayout = new QVBoxLayout(m_recentPage); + m_rightRecentLayout->setContentsMargins(0, 20, 0, 0); +} + +void MainWindow::initRecentWidget() +{ + //最近视图 + m_recentListView = new ListView(m_recentPage); + m_recentListView->installEventFilter(this); + m_recentListView->setFixedSize(QSize(Style::rightViewWidth, Style::rightViewHeight)); + m_recentTextlabel = new QLabel(m_recentPage); + m_recentTextlabel->setFixedSize(QSize(Style::rightViewWidth, Style::rightViewHeight)); + m_recentTextlabel->setAlignment(Qt::AlignCenter); + m_recentTextlabel->setText(QApplication::translate("MainWindow", "No recent files")); + + m_rightStackedWidget->addWidget(m_collectPage); + m_rightStackedWidget->addWidget(m_recentPage); + m_verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + m_rightBottomHorizontalLayout = new QHBoxLayout(); + m_rightBottomHorizontalLayout->setSizeConstraint(QLayout::SetDefaultConstraint); + m_rightBottomHorizontalLayout->setContentsMargins(0, 0, 8, 0); + m_horizontalSpacer_2 = new QSpacerItem(332, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + m_horizontalSpacer_4 = new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Minimum); + m_powerOffButton = new QPushButton(m_centralwidget); + m_powerOffButton->setFixedSize(QSize(32, 32)); + m_powerOffButton->setContextMenuPolicy(Qt::CustomContextMenu); + m_powerOffButton->setIcon(QIcon(":/data/img/mainviewwidget/power.svg")); + m_powerOffButton->setIconSize(QSize(24, 24)); + m_powerOffButton->setFlat(true); + m_powerOffButton->installEventFilter(this); + m_letfTopSelectHorizontalLayout->addWidget(m_minSelectTextLabel); + m_letfTopSelectHorizontalLayout->addItem(m_horizontalSpacer); + m_letfTopSelectHorizontalLayout->addWidget(m_searchPushButton); + m_letfTopSelectHorizontalLayout->addItem(m_horizontalSpacer_4); + m_letfTopSelectHorizontalLayout->addWidget(m_minSelectButton); + m_letfTopSelectHorizontalLayout->addWidget(m_selectMenuButton); + m_leftTopSearchHorizontalLayout->addWidget(m_lineEdit); + m_leftTopSearchHorizontalLayout->addWidget(m_cancelSearchPushButton); + m_mainLeftVerticalLayout->addWidget(m_topStackedWidget); + m_mainLeftVerticalLayout->addWidget(m_leftStackedWidget); + m_mainLeftVerticalLayout->addStretch(); + m_mainRightVerticalLayout_1->addLayout(m_rightTopHorizontalLayout); + m_rightCollectLayout->addWidget(m_collectListView); + m_rightCollectLayout->addItem(m_verticalSpacer_2); + m_rightRecentLayout->addWidget(m_recentListView); + m_rightRecentLayout->addWidget(m_recentTextlabel); + m_mainRightVerticalLayout_1->addWidget(m_rightStackedWidget); + m_rightBottomHorizontalLayout->addItem(m_horizontalSpacer_2); + m_rightBottomHorizontalLayout->addWidget(m_powerOffButton); + m_mainRightVerticalLayout->addLayout(m_mainRightVerticalLayout_1); + m_mainRightVerticalLayout->addLayout(m_rightBottomHorizontalLayout); + m_centerLayout->addWidget(m_viewWidget); + m_centerLayout->addLayout(m_mainRightVerticalLayout); + this->setCentralWidget(m_centralwidget); + m_minSelectTextLabel->setText(QApplication::translate("MainWindow", "All", nullptr)); + m_searchPushButton->setText(QString()); + m_minSelectButton->setText(QString()); + m_selectMenuButton->setText(QString()); + m_cancelSearchPushButton->setText(QString()); + QFont collectFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize() + 2); + m_collectPushButton->setFont(collectFont); + m_collectPushButton->setText(QApplication::translate("MainWindow", "collection", nullptr)); + m_recentPushButton->setText(QApplication::translate("MainWindow", "recent", nullptr)); + m_minMaxChangeButton->setToolTip(QApplication::translate("MainWindow", "Max", nullptr)); + m_minMaxChangeButton->setText(QString()); + m_powerOffButton->setToolTip(QApplication::translate("MainWindow", "PowerOff", nullptr)); + m_powerOffButton->setText(QString()); + m_topStackedWidget->setCurrentIndex(0); + m_leftStackedWidget->setCurrentIndex(0); + m_minMaxChangeButton->setDefault(false); + m_rightStackedWidget->setCurrentIndex(0); +} + +void MainWindow::initTabOrder() +{ + setTabOrder(m_searchPushButton, m_minSelectButton); + setTabOrder(m_minSelectButton, m_selectMenuButton); + setTabOrder(m_selectMenuButton, m_collectPushButton); + setTabOrder(m_collectPushButton, m_recentPushButton); + setTabOrder(m_recentPushButton, m_minMaxChangeButton); + setTabOrder(m_minMaxChangeButton, m_powerOffButton); +} + +void MainWindow::windowOption() +{ + if (this->isVisible() || m_fullWindow->isVisible()) { + hideWindow(); + } else { + showWindow(); + } +} + +void MainWindow::initUi() +{ + qDebug() << "init UI"; + this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint); + this->setAttribute(Qt::WA_TranslucentBackground, true); + this->setAutoFillBackground(false); + this->setFocusPolicy(Qt::NoFocus); + m_modaldata = new GetModelData; + m_minAllListView->addData(m_modaldata->getMinAllData(), 0); + m_minFuncListView->addData(m_modaldata->getMinFuncData(), 1); + m_minLetterListView->addData(m_modaldata->getMinLetterData(), 2); + + if (dataBaseIsEmpty()) { + m_collectListView->addData(m_modaldata->getPreCollectionApp()); + } else { + m_collectListView->addData(m_modaldata->getcollectData()); + } + + QVector recentFile = m_modaldata->getRecentData(); + m_recentListView->addData(recentFile , -1); + + if (recentFile.isEmpty()) { + m_recentListView->hide(); + } else { + m_recentTextlabel->hide(); + } + + m_dropDownMenu = new MenuBox(this); + m_allAction = new QAction(m_dropDownMenu); + m_letterAction = new QAction(m_dropDownMenu); + m_funcAction = new QAction(m_dropDownMenu); + m_allAction->setText(tr("All")); + m_allAction->setCheckable(true); + m_letterAction->setText(tr("Letter")); + m_letterAction->setCheckable(true); + m_funcAction->setText(tr("Function")); + m_funcAction->setCheckable(true); + m_dropDownMenu->addAction(m_allAction); + m_dropDownMenu->addAction(m_letterAction); + m_dropDownMenu->addAction(m_funcAction); + m_allAction->setChecked(true); + QString textColorHightLight = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16).mid(2, 6); + m_collectPushButton->setStyleSheet(QString("color: #%1;").arg(textColorHightLight)); + QString textColorDefault = QString::number(this->palette().color(QPalette::Text).rgba(), 16).mid(2, 6); + m_recentPushButton->setStyleSheet(QString("color: #%1;").arg(textColorDefault)); + QAction *action = new QAction(); + action->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-icon-search.svg", true)); + m_lineEdit->addAction(action, QLineEdit::LeadingPosition); + m_desktopWatcher = new DesktopWatcher(); + connect(m_minAllListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); + connect(m_minFuncListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); + connect(m_minLetterListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); + connect(m_minSearchResultListView, &ListView::sendUpdateAppListSignal, this, &MainWindow::updateView); + connect(m_collectListView, &RightListView::sendUpdateAppListSignal, this, &MainWindow::updateView); + connect(m_minAllListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); + connect(m_minFuncListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); + connect(m_minSearchResultListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); + connect(m_minLetterListView, &ListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); + connect(m_collectListView, &RightListView::sendCollectViewUpdate, this, &MainWindow::updateCollectView); + connect(m_desktopWatcher, &DesktopWatcher::directoryChangedSignal, this, &MainWindow::updateView); + connect(m_desktopWatcher, &DesktopWatcher::updateRecentList, this, &MainWindow::updateRecentView); + connect(this, &MainWindow::sendStyleChangeSignal, m_viewWidget, &MainViewWidget::styleChangeSlot); + connect(m_minAllListView, &ListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); + connect(m_minFuncListView, &ListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); + connect(m_minLetterListView, &ListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); + connect(m_minSearchResultListView, &ListView::sendHideMainWindowSignal, this, &MainWindow::hideWindow); + changeStyle(); +} + +void MainWindow::changeStyle() +{ + QPalette linePe; + QString buttonColorDefault; + QString buttonColorHover; + QString buttonColorPress; + QColor buttonColor; + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.keys().contains(QString("styleName"))) { + if (gsetting.get("style-name").toString() == "ukui-light" + || gsetting.get("style-name").toString() == "ukui-default") { + g_curStyle = "ukui-light"; + buttonColorDefault = "rgba(16, 23, 29, 0.06)"; + buttonColorHover = "rgba(16, 23, 29, 0.12)"; + buttonColorPress = "rgba(16, 23, 29, 0.17)"; + m_windowColor.setNamedColor("#C7E9EEF2"); + Q_EMIT sendStyleChangeSignal("ukui-light"); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius:16px; background: rgba(255, 255, 255, 0.4);}" + "QPushButton:pressed {border-radius:16px; background: rgba(255, 255, 255, 0.65);}"); + } else { + g_curStyle = "ukui-dark"; + buttonColor = linePe.color(QPalette::Light); + QRgb rgbDefault = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 25); + buttonColorDefault = "#" + QString::number(rgbDefault, 16); + QRgb rgbHover = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 50); + buttonColorHover = "#" + QString::number(rgbHover, 16); + QRgb rgbPress = qRgba(buttonColor.red(), buttonColor.green(), buttonColor.blue(), 75); + buttonColorPress = "#" + QString::number(rgbPress, 16); + m_windowColor.setNamedColor("#FF383838"); + Q_EMIT sendStyleChangeSignal("ukui-dark"); + m_powerOffButton->setStyleSheet("QPushButton {padding: 0px;}" + "QPushButton:hover {border-radius:16px; background: rgba(255, 255, 255, 0.12);}" + "QPushButton:pressed {border-radius:16px; background: rgba(255, 255, 255, 0.25);}"); + } + } + } + + m_buttonStyle = QString("%1{border-radius:13px; background:" + buttonColorDefault + ";}" + "%1:hover {border-radius:13px; background:" + buttonColorHover + ";}" + "%1:pressed {border-radius:13px; background:" + buttonColorPress + ";}"); + m_searchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); + m_minSelectButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); + m_cancelSearchPushButton->setStyleSheet(m_buttonStyle.arg("QPushButton")); + m_searchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/full-search.svg", true)); + QAction *lineAction = m_lineEdit->actions().at(0); + + if (lineAction != nullptr) { + m_lineEdit->removeAction(lineAction); + delete lineAction; + lineAction = nullptr; + } + + QAction *action = new QAction(); + action->setIcon(getCurIcon(":/data/img/mainviewwidget/full-search.svg", true)); + m_lineEdit->addAction(action, QLineEdit::LeadingPosition); + m_cancelSearchPushButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-close-2x.png", true)); + + if (m_leftStackedWidget->currentIndex() == 0) { + on_selectMenuButton_triggered(m_allAction); + } else if (m_leftStackedWidget->currentIndex() == 1) { + on_selectMenuButton_triggered(m_letterAction); + } else if (m_leftStackedWidget->currentIndex() == 2) { + on_selectMenuButton_triggered(m_funcAction); + } +} + +void MainWindow::paintEvent(QPaintEvent *event) +{ + double transparency = getTransparency(); + QColor curColor = m_windowColor; + if ( transparency == 1) { + curColor.setAlpha(255); + } + QRect rect = this->rect(); + QPainterPath path; + // rect.setTopLeft(QPoint(rect.x()+320,rect.y())); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(Qt::transparent); + qreal radius = 10; + path.moveTo(rect.topRight() - QPointF(radius, 0)); + path.lineTo(rect.topLeft() + QPointF(radius, 0)); + path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); + path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); + path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); + path.lineTo(rect.bottomRight() - QPointF(radius, 0)); + path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); + path.lineTo(rect.topRight() + QPointF(0, radius)); + path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + painter.setBrush(curColor); + painter.setPen(Qt::transparent); + painter.setOpacity(transparency); + painter.drawPath(path); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); + QMainWindow::paintEvent(event); +} +/** + * 鼠标点击窗口外部事件 + */ +bool MainWindow::event(QEvent *event) +{ + if (QEvent::WindowDeactivate == event->type()) { //窗口停用 + if (QApplication::activeWindow() != this) { + qDebug() << " * 鼠标点击窗口外部事件"; + this->setWindowState(this->windowState() & Qt::WindowMinimized); + this->hide(); + m_topStackedWidget->setCurrentIndex(0); + m_lineEdit->clear(); + } + } + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = (QKeyEvent *) event; + + if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || + keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right || + keyEvent->key() == Qt::Key_Tab) { + if (!m_collectListView->hasFocus()) { + m_viewWidget->setFocus(); + + if (m_state == 0) { + m_minAllListView->setFocus(); + m_minAllListView->setCurrentIndex(m_minAllListView->model()->index(0, 0)); + } else if (m_state == 1) { + m_minLetterListView->setFocus(); + m_minLetterListView->setCurrentIndex(m_minLetterListView->model()->index(0, 0)); + } else { + m_minFuncListView->setFocus(); + m_minFuncListView->setCurrentIndex(m_minFuncListView->model()->index(0, 0)); + } + } + + return true; + } + + if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { + if (m_minSelectButton->hasFocus()) { + m_minSelectButton->click(); + } else if (m_selectMenuButton->hasFocus()) { + QApplication::postEvent(m_selectMenuButton, new QEvent(QEvent::MouseButtonPress)); + } + + if (m_lineEdit->hasFocus()) { + m_minSearchResultListView->setFocus(); + } else { + QWidget *current_focus_widget; + current_focus_widget = QWidget::focusWidget(); + QPushButton *le = qobject_cast(current_focus_widget); + + if (le != nullptr) { + le->clicked(); + } + } + } + } + + return QWidget::event(event); +} +void MainWindow::minAnimationFinished() +{ + this->show(); + setMinWindowPos(); + this->raise(); + this->activateWindow(); + m_viewWidget->setFocus(); +// m_collectPushButton->clicked(true); + on_collectPushButton_clicked(); + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); + m_animationPage->hide(); +} + +void MainWindow::iconAnimationFinished() +{ + m_dropDownMenu->raise(); + m_dropDownMenu->exec(m_selectMenuButton->mapToGlobal(QPoint(m_selectMenuButton->width() + - m_dropDownMenu->sizeHint().width() + 5, 29))); +} + +void MainWindow::maxAnimationFinished() +{ + m_fullWindow->raise(); + m_fullWindow->showNormal(); + setMaxWindowPos(); + m_fullWindow->activateWindow(); + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); + m_animationPage->hide(); +} +void MainWindow::resetLetterPage() +{ + m_minLetterListView->show(); + m_letterBtnWid->hide(); +} +void MainWindow::resetFunctionPage() +{ + m_minFuncListView->show(); + m_functionBtnWid->hide(); +} +/** + * 接收FunctionButtonWidget界面按钮信号 + */ +void MainWindow::recvFunctionBtnSignal(QString btnName) +{ + //此处需实现将功能为btnname的应用列表移动到applistWid界面最顶端 + if (m_state == 1) { + int index = m_modaldata->getLetterClassificationList().indexOf(btnName); + + if (index != -1) { + int row = m_modaldata->getLetterClassificationBtnRowList().at(index).toInt(); + m_minLetterListView->verticalScrollBar()->setValue(row); + m_leaveAnimation->setTargetObject(m_letterBtnWid); + m_enterAnimation->setTargetObject(m_minLetterListView); + } + } else { + int index = m_modaldata->getFuncClassificationList().indexOf(btnName); + + if (index != -1) { + int row = m_modaldata->getFuncClassificationBtnRowList().at(index).toInt(); + m_minFuncListView->verticalScrollBar()->setValue(row); + m_leaveAnimation->setTargetObject(m_functionBtnWid); + m_enterAnimation->setTargetObject(m_minFuncListView); + } + } + + m_leaveAnimation->setStartValue(QRect(0, 0, m_minFuncPage->width(), m_minFuncPage->height())); + m_leaveAnimation->setEndValue(QRect(0, 0, 0, 0)); + m_enterAnimation->setStartValue(QRect(0, 0, 0, 0)); + m_enterAnimation->setEndValue(QRect(0, 0, m_minFuncPage->width(), m_minFuncPage->height())); + m_leaveAnimation->setDuration(10); + m_enterAnimation->setDuration(100); + m_leaveAnimation->start(); + m_widgetState = 0; +} +void MainWindow::primaryScreenChangeSlot() +{ + repaintWidget(); +} +void MainWindow::appClassificationBtnClickedSlot() +{ + m_leaveAnimation->setStartValue(QRect(0, 0, Style::leftPageWidth, Style::leftPageHeight)); + m_leaveAnimation->setEndValue(QRect(0, 0, 0, 0)); + m_enterAnimation->setStartValue(QRect(-40, -40, Style::leftPageWidth + 80, Style::leftPageHeight + 80)); + m_enterAnimation->setEndValue(QRect(10, 0, Style::leftPageWidth - 20, Style::leftPageHeight - 60)); + m_leaveAnimation->setDuration(10); + m_enterAnimation->setDuration(100); + + if (m_state == 1) { + Q_EMIT sendLetterClassificationList(m_modaldata->getLetterClassificationList()); + m_leaveAnimation->setTargetObject(m_minLetterListView); + m_enterAnimation->setTargetObject(m_letterBtnWid); + } else if (m_state == 2) { + //加载FunctionButtonWidget界面 + Q_EMIT sendClassificationbtnList(); + m_leaveAnimation->setTargetObject(m_minFuncListView); + m_enterAnimation->setTargetObject(m_functionBtnWid); + } + + m_leaveAnimation->start(); + m_widgetState = 1; +} +void MainWindow::animationFinishedSLot() +{ + if (m_widgetState == 1) { + if (m_state == 1) { + m_minLetterListView->hide(); + m_letterBtnWid->show(); + } else { + m_minFuncListView->hide(); + m_functionBtnWid->show(); + } + + m_enterAnimation->start(); + m_widgetState = -1; + } + + if (m_widgetState == 0) { + if (m_state == 1) { + m_letterBtnWid->hide(); + m_minLetterListView->show(); + } else { + m_functionBtnWid->hide(); + m_minFuncListView->show(); + } + + m_enterAnimation->start(); + m_widgetState = -1; + } +} +void MainWindow::on_minSelectButton_clicked() +{ +// selectIconAnimation(true); + selectIconAnimation(false); + + if (m_leftStackedWidget->currentIndex() == 0) { + on_selectMenuButton_triggered(m_letterAction); + } else if (m_leftStackedWidget->currentIndex() == 1) { + on_selectMenuButton_triggered(m_funcAction); + } else if (m_leftStackedWidget->currentIndex() == 2) { + on_selectMenuButton_triggered(m_allAction); + } +} + +void MainWindow::selectIconAnimation(const bool &flag) +{ + iconAnimation = new QPropertyAnimation(m_selectMenuButton, "rotation", this); + + if (flag) { + connect(iconAnimation, &QPropertyAnimation::finished, this, &MainWindow::iconAnimationFinished); + + if (m_selectMenuButton->property("rotation") == 0) { + iconAnimation->setStartValue(0); + iconAnimation->setEndValue(-180); + } + } else { + if (m_selectMenuButton->property("rotation") == -180) { + iconAnimation->setStartValue(-180); + iconAnimation->setEndValue(0); + } + } + + iconAnimation->setEasingCurve(QEasingCurve::Linear); + iconAnimation->setDuration(300); + iconAnimation->start(QPropertyAnimation::DeleteWhenStopped); +} + +bool MainWindow::eventFilter(QObject *target, QEvent *event) +{ + if (event->type() == QEvent::MouseButtonPress) { + if (target == m_recentPushButton) { + on_recentPushButton_clicked(); + return false; + } + + if (target == m_collectPushButton) { + on_collectPushButton_clicked(); + return false; + } + + if (target == m_selectMenuButton) { + m_selectMenuButton->setIcon(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true) + .pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); + selectIconAnimation(true); + } + } + + if (target == m_lineEdit) { + if (event->type() == QEvent::FocusIn) { + QString highLightColor = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16); + QString color = highLightColor.mid(2, 6); + QString searchStyle = QString("border-radius: 13px; border:1px solid #%1; background: transparent;").arg(color); + m_lineEdit->setStyleSheet(searchStyle); + } + } + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = (QKeyEvent *)event; + + if (target == m_powerOffButton) { + if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Right) { + if (m_topStackedWidget->currentIndex() == 0) { + m_topStackedWidget->setFocus(); + } else { + m_lineEdit->setFocus(); + return true; + } + } + + if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { + return true; + } + } + + if (target == m_collectPushButton) { + if (ke->key() == Qt::Key_Down) { + if (m_rightStackedWidget->currentIndex() == 0) { + m_collectListView->setFocus(); + return true; + } else { + return true; + } + } + + if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { + return true; + } + } + + if (target == m_collectListView) { + if (ke->key() == Qt::Key_Tab) { + m_collectPushButton->setFocus(); + return true; + } + } + + if (target == m_recentListView) { + if (ke->key() == Qt::Key_Tab) { + m_recentPushButton->setFocus(); + return true; + } + + if (ke->key() == Qt::Key_Left || ke->key() == Qt::Key_Right) { + return true; + } + } + + if (target == m_minAllListView || target == m_minLetterListView || target == m_minFuncListView) { + if (ke->key() == Qt::Key_Tab) { + m_searchPushButton->setFocus(); + } + } + + if (target == m_cancelSearchPushButton) { + if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Right) { + m_collectPushButton->setFocus(); + return true; + } + + if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) { + return true; + } + } + + if (target == m_minSearchResultListView) { + if (ke->key() == Qt::Key_Tab) { + m_lineEdit->setFocus(); + return true; + } + } + + if (target == m_lineEdit) { + if (ke->key() == Qt::Key_Down) { + m_minSearchResultListView->setFocus(); + return true; + } + } + + if (target == m_minSelectButton) { + if (ke->key() == Qt::Key_Down) { + if (m_state == 0) { + m_minAllListView->setFocus(); + m_minAllListView->setCurrentIndex(m_minAllListView->model()->index(0, 0)); + } else if (m_state == 1) { + m_minLetterListView->setFocus(); + m_minLetterListView->setCurrentIndex(m_minLetterListView->model()->index(0, 0)); + } else { + m_minFuncListView->setFocus(); + m_minFuncListView->setCurrentIndex(m_minFuncListView->model()->index(0, 0)); + } + + return true; + } + + if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { + return true; + } + } + + if (target == m_recentPushButton) { + if (ke->key() == Qt::Key_Down) { + if (m_rightStackedWidget->currentIndex() == 1) { + m_recentListView->setFocus(); + return true; + } else { + return true; + } + } + + if (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Right || ke->key() == Qt::Key_Left) { + return true; + } + } + } + + return QWidget::eventFilter(target, event); +} +void MainWindow::keyPressEvent(QKeyEvent *e) +{ + if (e->type() == QEvent::KeyPress) { + if ((e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9) || (e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z)) { + qDebug() << "void MainWindow::keyPressEvent(QKeyEvent *e)" << e->text(); + m_topStackedWidget->setCurrentIndex(1); + m_lineEdit->setFocus(); + m_lineEdit->setText(e->text()); + } + + if (e->key() == Qt::Key_Backspace) { + if (!m_lineEdit->text().isEmpty()) { + m_lineEdit->setText(""); + } else { + m_topStackedWidget->setCurrentIndex(0); + } + } + + if (e->key() == Qt::Key_Escape) { + this->hide(); + } + } +} +/** + * 进程开启监控槽函数 + */ +void MainWindow::ViewOpenedSlot(QString desktopfp) +{ + myDebug() << "open software:" << desktopfp; + QVector desktopfpVec = UkuiMenuInterface::desktopfpVector; + + if (desktopfpVec.contains(desktopfp)) { + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + QString dateTimeKey; + dateTimeKey.clear(); + + if (!desktopfn.isEmpty()) { + updateDataBaseTableTimes(desktopfn); + updateView(); + } + } +} +void MainWindow::recvSearchResult(QVector arg) +{ + m_searchAppThread->quit(); + QVector m_data; + m_data.clear(); + m_minSearchResultListView->verticalScrollBar()->setSliderPosition(0); + m_minSearchResultListView->addData(m_data, 3); + + Q_FOREACH (QStringList appinfo, arg) { + m_data.append(QStringList() << appinfo.at(0) << "1"); + } + + m_minSearchResultListView->updateData(m_data); +} +void MainWindow::searchAppSlot(QString arg) +{ + if (!arg.isEmpty()) { //切换至搜索模块 + m_leftStackedWidget->setCurrentIndex(3); + Q_EMIT sendSearchKeyword(arg); + m_searchAppThread->start(); + } else { + m_leftStackedWidget->setCurrentIndex(m_state); + } +} +void MainWindow::on_selectMenuButton_triggered(QAction *arg1) +{ + m_selectMenuButton->setIcon(getCurIcon(":/data/img/mainviewwidget/downarrow.svg", true).pixmap(QSize(Style::miniIconSize, Style::miniIconSize))); + selectIconAnimation(false); + + if (arg1 == m_allAction) { + m_leftStackedWidget->setCurrentIndex(0); + m_state = 0; + m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-all.svg", true)); + m_minSelectButton->setToolTip(tr("All")); + m_minSelectTextLabel->setText(tr("All")); + m_allAction->setChecked(true); + m_letterAction->setChecked(false); + m_funcAction->setChecked(false); + } else if (arg1 == m_letterAction) { + m_leftStackedWidget->setCurrentIndex(1); + m_state = 1; + m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-letter.svg", true)); + m_minSelectButton->setToolTip(tr("Letter")); + m_minSelectTextLabel->setText(tr("Letter")); + m_allAction->setChecked(false); + m_letterAction->setChecked(true); + m_funcAction->setChecked(false); + } else if (arg1 == m_funcAction) { + m_leftStackedWidget->setCurrentIndex(2); + m_state = 2; + m_minSelectButton->setIcon(getCurIcon(":/data/img/mainviewwidget/DM-function.svg", true)); + m_minSelectButton->setToolTip(tr("Function")); + m_minSelectTextLabel->setText(tr("Function")); + m_allAction->setChecked(false); + m_letterAction->setChecked(false); + m_funcAction->setChecked(true); + } +} +void MainWindow::updateCollectView() +{ + m_modaldata->loadDesktopVercor(); + m_collectListView->updateData(m_modaldata->getcollectData()); +} +void MainWindow::updateMinAllView() +{ + m_modaldata->loadDesktopVercor(); + m_minAllListView->updateData(m_modaldata->getMinAllData()); +} +void MainWindow::updateRecentView() +{ + m_modaldata->loadDesktopVercor(); + QVector recentFile = m_modaldata->getRecentData(); + if (recentFile.isEmpty()) { + m_recentListView->hide(); + m_recentTextlabel->show(); + } else { + m_recentTextlabel->hide(); + m_recentListView->show(); + m_recentListView->updateData(recentFile); + } +} +void MainWindow::updateView() +{ + m_modaldata->loadDesktopVercor(); + m_minAllListView->updateData(m_modaldata->getMinAllData()); + m_collectListView->updateData(m_modaldata->getcollectData()); + m_minFuncListView->updateData(m_modaldata->getMinFuncData()); + m_minLetterListView->updateData(m_modaldata->getMinLetterData()); + m_fullWindow->updateView(); +} +void MainWindow::updateAppCategorySlot(QString category) +{ + m_softwareDbThread->getDatabaseList(category); + m_softwareDbThread->start(); + connect(m_softwareDbThread, &SoftwareDatabaseUpdateThread::updateDatabaseSignal, this, &MainWindow::databaseThreadCloseSlot); +} +void MainWindow::databaseThreadCloseSlot() +{ + m_softwareDbThread->quit(); + updateView(); +} + +void MainWindow::on_collectPushButton_clicked() +{ + m_rightStackedWidget->setCurrentIndex(0); + + QString textColorHightLight = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16).mid(2, 6); + m_collectPushButton->setStyleSheet(QString("color:#%1;").arg(textColorHightLight)); + QFont collectFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize() + 2); + m_collectPushButton->setFont(collectFont); + QString textColorDefault = QString::number(this->palette().color(QPalette::Text).rgba(), 16).mid(2, 6); + m_recentPushButton->setStyleSheet(QString("color:#%1;").arg(textColorDefault)); + QFont recentFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize()); + m_recentPushButton->setFont(recentFont); +} + +void MainWindow::on_recentPushButton_clicked() +{ + m_rightStackedWidget->setCurrentIndex(1); + QString textColorDefault = QString::number(this->palette().color(QPalette::Text).rgba(), 16).mid(2, 6); + m_collectPushButton->setStyleSheet(QString("color:#%1").arg(textColorDefault)); + QFont collectFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize()); + m_collectPushButton->setFont(collectFont); + QString textColorHightLight = QString::number(this->palette().color(QPalette::Highlight).rgba(), 16).mid(2, 6); + m_recentPushButton->setStyleSheet(QString("color:#%1").arg(textColorHightLight)); + + QFont recentFont(QGuiApplication::font().family(), QGuiApplication::font().pointSize() + 2); + m_recentPushButton->setFont(recentFont); + updateRecentView(); +} +void MainWindow::on_cancelSearchPushButton_clicked() +{ + m_topStackedWidget->setCurrentIndex(0); + m_lineEdit->clear(); +} +void MainWindow::on_searchPushButton_clicked() +{ + m_topStackedWidget->setCurrentIndex(1); + m_lineEdit->setFocus(); +} +void MainWindow::on_minMaxChangeButton_clicked() +{ + m_canHide = true; + m_isFullScreen = true; + + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + m_maxAnimation->setDuration(1); + } else { + m_animationPage->show(); + m_animationPage->setGeometry(this->x(), this->y(), Style::minw, Style::minh); + m_animationPage->raise(); + m_animationPage->repaint(); + m_maxAnimation->setDuration(260); + } + + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); + m_maxAnimation->setEasingCurve(QEasingCurve::OutExpo); +// m_maxAnimation->setStartValue(QRect(Style::m_primaryScreenX, Style::m_primaryScreenY + Style::m_availableScreenHeight - Style::minh, Style::minw, Style::minh)); + m_maxAnimation->setStartValue(QRect(this->x(), this->y(), Style::minw, Style::minh)); + m_maxAnimation->setEndValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight)); + + m_maxAnimation->start(); + this->hide(); +} +void MainWindow::showWindow() +{ + Style::initWidStyle(); + myDebug() << "调用开始菜单显示"; + if (m_isFullScreen) { + m_fullWindow->show(); + setMaxWindowPos(); + m_fullWindow->raise(); + m_fullWindow->activateWindow(); + } else { + this->show(); + setMinWindowPos(); + this->raise(); + this->activateWindow(); + on_collectPushButton_clicked(); + m_viewWidget->setFocus(); + } +} + +void MainWindow::hideWindow() +{ + myDebug() << "调用开始菜单隐藏"; + if (m_fullWindow->isVisible()) { + m_fullWindow->hide(); + m_fullWindow->resetEditline(); + this->clearFocus(); + m_isFullScreen = true; + } else { + this->hide(); + m_topStackedWidget->setCurrentIndex(0); + m_lineEdit->clear(); + this->clearFocus(); + m_isFullScreen = false; + } +} + +void MainWindow::setMinWindowPos() +{ + int position = Style::m_panelPosition; + int x = Style::m_primaryScreenX; + int y = Style::m_primaryScreenY; + int width = Style::m_availableScreenWidth; + int height = Style::m_availableScreenHeight; + + if (position == 0) { + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(this->windowHandle(), QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + 4, y + height - Style::minh - 3, Style::minw, Style::minh)); + } + } else if (position == 1) { + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(this->windowHandle(), QRect(x + 4, y + 4, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); + } + } else if (position == 2) { + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(this->windowHandle(), QRect(x + 4, y + 4, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + 4, y + 4, Style::minw, Style::minh)); + } + } else { + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(this->windowHandle(), QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); + } else { + this->setGeometry(QRect(x + width - Style::minw - 4, y + 4, Style::minw, Style::minh)); + } + } +} + +void MainWindow::setMaxWindowPos() +{ + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(m_fullWindow->windowHandle(), QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight)); + } +} + +void MainWindow::repaintWidget() +{ + Style::initWidStyle(); + this->setMinimumSize(Style::minw, Style::minh); + int x = Style::m_primaryScreenX; + int y = Style::m_primaryScreenY; + int width = Style::m_availableScreenWidth; + int height = Style::m_availableScreenHeight; + setMinWindowPos(); + m_fullWindow->move(x, y); + m_fullWindow->setFixedSize(width, height); + m_fullWindow->repaintWidget(); +} + +void MainWindow::showNormalWindowSlot() +{ + myDebug() << "Style::m_availableScreenWidth" << Style::m_availableScreenWidth << "Style::m_availableScreenHeight" << Style::m_availableScreenHeight; + + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + m_minAnimation->setDuration(1); + } else { + m_animationPage->show(); + m_animationPage->setGeometry(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight); + m_animationPage->raise(); + m_animationPage->repaint(); + m_minAnimation->setDuration(260); + } + + myDebug() << m_animationPage->rect(); + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); + m_isFullScreen = false; + m_minAnimation->setEasingCurve(QEasingCurve::OutExpo); + m_minAnimation->setStartValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight)); + m_minAnimation->setEndValue(QRect(this->x(), this->y(), Style::minw, Style::minh)); + + m_minAnimation->start(); + m_fullWindow->hide(); +} +void MainWindow::on_powerOffButton_clicked() +{ + QProcess::startDetached(QString("ukui-session-tools")); +} +void MainWindow::on_powerOffButton_customContextMenuRequested(const QPoint &pos) +{ + Q_UNUSED(pos); + RightClickMenu m_otherMenu(this); + m_otherMenu.showShutdownMenu(this->mapToGlobal(m_centralwidget->rect().bottomRight()), false); + qDebug() << "SideBarWidget::shutdownBtnRightClickSlot() 开始"; +} diff --git a/src/UserInterface/mainwindow.h b/src/UserInterface/mainwindow.h new file mode 100755 index 0000000..1b5363d --- /dev/null +++ b/src/UserInterface/mainwindow.h @@ -0,0 +1,251 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "ukuimenuinterface.h" +#include +#include +#include +#include +#include +#include +#include "convert_winid_to_desktop.h" +#include "style.h" +#include "main_view_widget.h" +#include "tabview_widget.h" +#include "dbus.h" +#include "dbus-adaptor.h" +#include "software_database_update_thread.h" +#include +#include +#include +#include +#include "listview.h" +#include "getmodeldata.h" +#include "full_mainwindow.h" +#include "desktop_watcher.h" +#include "function_button_widget.h" +#include "letter_button_widget.h" +#include "animationpage.h" +#include "rotationlabel.h" +#include "ukuistylehelper/ukuistylehelper.h" +#include "windowmanager/windowmanager.h" + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + void windowOption(); + +protected: + void initSearchUi(); + void initLeftWidget(); + void initRightWidgetButton(); + void initCollectWidget(); + void initRecentWidget(); + void initTabOrder(); + void initGsettings(); + void initSignalConnect(); + void registDbusServer(); + void setTabletModeFlag(); + void initUi(); + void showWindow(); + void hideWindow(); + /** + * @brief 处理外部点击事件和主窗口键盘控制 + * @param event + * @return + */ + bool event(QEvent *event); + /** + * @brief 主窗口圆角绘制 + * @param event + */ + void paintEvent(QPaintEvent *event); + + /** + * @brief 键盘字符输入处理 + * @param e + */ + void keyPressEvent(QKeyEvent *e); + + /** + * @brief searchAppSlot + * @param arg + */ + void searchAppSlot(QString arg); + + void recvSearchResult(QVector arg); + + void ViewOpenedSlot(QString desktopfp); + + bool eventFilter(QObject *target, QEvent *event); + + // void mouseReleaseEvent(QMouseEvent *event); + + void selectIconAnimation(const bool &flag); + + void setMinWindowPos(); + + void setMaxWindowPos(); +public: +Q_SIGNALS: + void sendSearchKeyword(QString arg); + void sendClassificationbtnList(); + void sendLetterClassificationList(QStringList list); + void sendSetFullWindowItemHide(bool flag); + void sendStyleChangeSignal(QString style); + +public Q_SLOTS: + void updateCollectView(); + void on_minSelectButton_clicked(); + void updateMinAllView(); + void updateView(); + void recvFunctionBtnSignal(QString btnname); + void primaryScreenChangeSlot(); + void repaintWidget(); + void updateRecentView(); + void updateAppCategorySlot(QString category); + void databaseThreadCloseSlot(); + void resetLetterPage(); + void resetFunctionPage(); + void minAnimationFinished(); + void maxAnimationFinished(); + void iconAnimationFinished(); + void changeStyle(); + void tabletModeChangeSlot(bool flag); +private Q_SLOTS: + void on_selectMenuButton_triggered(QAction *arg1); + + void on_collectPushButton_clicked(); + + void on_recentPushButton_clicked(); + + void on_cancelSearchPushButton_clicked(); + + void on_searchPushButton_clicked(); + + void on_minMaxChangeButton_clicked(); + + void on_powerOffButton_clicked(); + + void on_powerOffButton_customContextMenuRequested(const QPoint &pos); + + void appClassificationBtnClickedSlot(); + + void animationFinishedSLot(); + + void showNormalWindowSlot(); + +private: + + QWidget *m_centralwidget = nullptr; + QHBoxLayout *m_centerLayout = nullptr; + MainViewWidget *m_viewWidget = nullptr; + QGridLayout *m_gridLayout = nullptr; + QVBoxLayout *m_mainLeftVerticalLayout = nullptr; + QStackedWidget *m_topStackedWidget = nullptr; + QWidget *m_minMenuPage = nullptr; + QHBoxLayout *m_letfTopSelectHorizontalLayout = nullptr; + QLabel *m_minSelectTextLabel = nullptr; + QSpacerItem *m_horizontalSpacer = nullptr; + QPushButton *m_searchPushButton = nullptr; + QPushButton *m_minSelectButton = nullptr; + RotationLabel *m_selectMenuButton = nullptr; + QWidget *m_minSearchPage = nullptr; + QHBoxLayout *m_leftTopSearchHorizontalLayout = nullptr; + QLineEdit *m_lineEdit = nullptr; + QPushButton *m_cancelSearchPushButton = nullptr; + QStackedWidget *m_leftStackedWidget = nullptr; + QWidget *m_minAllPage = nullptr; + ListView *m_minAllListView = nullptr; + QWidget *m_minLetterPage = nullptr; + ListView *m_minLetterListView = nullptr; + QWidget *m_minFuncPage = nullptr; + ListView *m_minFuncListView = nullptr; + QWidget *m_minSearchResultPage = nullptr; + ListView *m_minSearchResultListView = nullptr; + QVBoxLayout *m_mainRightVerticalLayout = nullptr; + QVBoxLayout *m_mainRightVerticalLayout_1 = nullptr; + QHBoxLayout *m_rightTopHorizontalLayout = nullptr; + QVBoxLayout *m_rightCollectLayout = nullptr; + QVBoxLayout *m_rightRecentLayout = nullptr; + QLabel *m_collectPushButton = nullptr; + QLabel *m_recentPushButton = nullptr; + QSpacerItem *m_horizontalSpacer_3 = nullptr; + QPushButton *m_minMaxChangeButton = nullptr; + QSpacerItem *m_verticalSpacer = nullptr; + QStackedWidget *m_rightStackedWidget = nullptr; + QWidget *m_collectPage = nullptr; + RightListView *m_collectListView = nullptr; + QWidget *m_recentPage = nullptr; + ListView *m_recentListView = nullptr; + QLabel *m_recentTextlabel = nullptr; + QSpacerItem *m_verticalSpacer_2 = nullptr; + QHBoxLayout *m_rightBottomHorizontalLayout = nullptr; + QSpacerItem *m_horizontalSpacer_2 = nullptr; + QSpacerItem *m_horizontalSpacer_4 = nullptr; + QPushButton *m_powerOffButton = nullptr; + AnimationPage *m_animationPage = nullptr; + MenuBox *m_dropDownMenu = nullptr; + + bool m_canHide = true; + bool m_isFullScreen = false; + QString m_buttonStyle; + UkuiMenuInterface *m_ukuiMenuInterface = nullptr; + QPropertyAnimation *m_animation = nullptr; + bool m_winFlag = false; + DBus *m_dbus = nullptr; + GetModelData *m_modaldata = nullptr; + QAction *m_allAction = nullptr; + QAction *m_letterAction = nullptr; + QAction *m_funcAction = nullptr; + SearchAppThread *m_searchAppThread = nullptr; + int m_state = 0; + FullMainWindow *m_fullWindow = nullptr; + DesktopWatcher *m_desktopWatcher = nullptr; + QPropertyAnimation *m_enterAnimation = nullptr; + QPropertyAnimation *m_leaveAnimation = nullptr; + QPropertyAnimation *m_minAnimation = nullptr; + QPropertyAnimation *m_maxAnimation = nullptr; + QPropertyAnimation *iconAnimation = nullptr; + int m_widgetState = -1; + FunctionButtonWidget *m_functionBtnWid = nullptr; + LetterButtonWidget *m_letterBtnWid = nullptr; + SoftwareDatabaseUpdateThread *m_softwareDbThread = nullptr; + QColor m_windowColor; + bool m_isTabletMode = false; + QDBusInterface *m_usrInterface = nullptr; +}; + +#endif // MAINWINDOW_H diff --git a/src/UserInterface/tabletwindow.cpp b/src/UserInterface/tabletwindow.cpp new file mode 100755 index 0000000..378ad1f --- /dev/null +++ b/src/UserInterface/tabletwindow.cpp @@ -0,0 +1,1079 @@ +/* + * 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 +#include +#include "style.h" +#include +#include +#include +#include "tabletlistview.h" +#include "xeventmonitor.h" +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +extern void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); +QT_END_NAMESPACE + +TabletWindow::TabletWindow(QWidget *parent) : + QWidget(parent), + m_scrollArea(new QScrollArea(this)), + m_scrollAreaWid(new ScrollAreaWid(this)), + m_backPixmap(new QPixmap), + m_leftWidget(new FunctionWidget(this)), + m_firstPageWidget(new QWidget(this)), + m_pagemanager(new PageManager()), + m_buttonBoxLayout(new QHBoxLayout), + m_buttonGroup(new QButtonGroup), + m_buttonWidget(new QWidget(this)), + m_appFileWatcher(new QFileSystemWatcher), + m_appListFileWatcher(new QFileSystemWatcher), + m_configFileWatcher(new QFileSystemWatcher), + m_directoryChangedThread(new TabletDirectoryChangedThread) + +{ + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + m_setting = new QSettings(path, QSettings::IniFormat); + setProperty("useStyleWindowManager", false); + initSize(); + initUi(); +} + +TabletWindow::~TabletWindow() +{ +} + +QVector TabletWindow::m_keyVector = QVector(); +QVector TabletWindow::m_keyValueVector = QVector(); + +void TabletWindow::initSize() +{ + Style::initWidStyle(); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setFixedSize(Style::ScreenWidth, Style::ScreenHeight); + m_leftWidget->setFixedSize(Style::m_leftWidWidth, Style::CenterWindHeight); + m_leftWidget->layout()->setContentsMargins(Style::TimeWidgetLeft, Style::TimeWidgetTop, 0, 0); + m_scrollAreaWid->setFixedHeight(Style::CenterWindHeight); + m_scrollArea->setFixedSize(Style::ScreenWidth, Style::CenterWindHeight); + m_buttonWidget->setFixedSize(Style::OtherPageViewWidth, 30); +} + +void TabletWindow::initUi() +{ + this->setAttribute(Qt::WA_TranslucentBackground, true); + this->setAutoFillBackground(false); + this->setFocusPolicy(Qt::NoFocus); + m_animationPage.setParent(this); + m_firstPageWidget->installEventFilter(this); + m_buttonBoxLayout->setAlignment(Qt::AlignHCenter); + m_buttonBoxLayout->setSpacing(0); + m_buttonWidget->setLayout(m_buttonBoxLayout); + m_buttonBoxLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAnimation = new QPropertyAnimation(&m_animationPage, "pos"); + connect(m_scrollAnimation, &QPropertyAnimation::finished, this, &TabletWindow::animationFinishSlot); + m_scrollAnimation->setEasingCurve(QEasingCurve::OutExpo); + setOpacityEffect(0.7); + fileWatcher(); + initAppListWidget(); + setBackground(); + initStatusManager(); + initTransparency(); + registDbusService(); + ways(); + buttonWidgetShow(); + connect(m_leftWidget, &FunctionWidget::hideTabletWindow, this, &TabletWindow::recvHideMainWindowSlot); + + if (checkapplist()) { + directoryChangedSlot();//更新应用列表 + } + + initXEventMonitor(); +} + +void TabletWindow::initXEventMonitor() +{ + //pc下鼠标功能 + XEventMonitor::instance()->start(); + connect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), + this, SLOT(xkbEventsRelease(QString))); + connect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), + this, SLOT(xkbEventsPress(QString))); +} + +void TabletWindow::fileWatcher() +{ + m_configFileWatcher->addPath(QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"); + connect(m_configFileWatcher, &QFileSystemWatcher::fileChanged, this, [ = ]() { + m_configFileWatcher->addPath(QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"); + this->repaint(); + }); + m_appFileWatcher->addPaths(QStringList() << QString("/usr/share/applications") + << QString(QDir::homePath() + "/.local/share/applications/")); + connect(m_appFileWatcher, &QFileSystemWatcher::directoryChanged, this, &TabletWindow::directoryChangedSlot); + m_appListFileWatcher->addPath(QDir::homePath() + "/.config/ukui/desktop_applist"); + connect(m_appListFileWatcher, &QFileSystemWatcher::fileChanged, this, &TabletWindow::directoryChangedSlot); + connect(m_directoryChangedThread, &TabletDirectoryChangedThread::requestUpdateSignal, this, &TabletWindow::requestUpdateSlot); + connect(m_directoryChangedThread, &TabletDirectoryChangedThread::deleteAppSignal, this, &TabletWindow::requestDeleteAppSlot); +} + +void TabletWindow::initTransparency() +{ + //特效模式,此处Gsetting不明确,需进一步确认 + if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) { + m_bgEffect = new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); + + if (m_bgEffect->keys().contains("transparency")) { + setOpacityEffect(m_bgEffect->get("transparency").toReal()); + connect(m_bgEffect, &QGSettings::changed, [this](const QString & key) { + if (key == "effect") { + if (m_bgEffect->get("effect").toBool()) { + setOpacityEffect(m_bgEffect->get("transparency").toReal()); + } else { + setOpacityEffect(m_bgEffect->get("transparency").toReal()); + } + } + }); + } + } +} + +void TabletWindow::initStatusManager() +{ + m_usrInterface = new QDBusInterface("com.kylin.statusmanager.interface", + "/", + "com.kylin.statusmanager.interface", + QDBusConnection::sessionBus()); + QDBusConnection::sessionBus().connect("com.kylin.statusmanager.interface", + "/", + "com.kylin.statusmanager.interface", + "mode_change_signal", + this, + SLOT(modelChanged(bool)) + ); +} + +void TabletWindow::setBackground() +{ + if (QGSettings::isSchemaInstalled(QString("org.mate.background").toLocal8Bit())) { + m_bgSetting = new QGSettings(QString("org.mate.background").toLocal8Bit()); + + if (m_bgSetting->keys().contains("pictureFilename")) { + m_bgPath = m_bgSetting->get("pictureFilename").toString(); + } + + if (m_bgSetting->keys().contains("pictureOptions")) { + m_bgOption = m_bgSetting->get("pictureOptions").toString(); + } + + connect(m_bgSetting, &QGSettings::changed, this, [ = ](const QString & key) { + if (key == "pictureFilename") { + //在每个屏幕上绘制背景 + if (m_bgSetting->keys().contains("pictureFilename") && + m_bgSetting->keys().contains("pictureOptions")) { + m_bgPath = m_bgSetting->get("pictureFilename").toString(); + m_bgOption = m_bgSetting->get("pictureOptions").toString(); + } + + ways();//壁纸显示方式 + } + + if (key == "pictureOptions") { + //在每个屏幕上绘制背景 + if (m_bgSetting->keys().contains("pictureOptions")) { + m_bgOption = m_bgSetting->get("pictureOptions").toString(); + } + + ways(); + } + }); + } +} + +void TabletWindow::registDbusService() +{ +// m_dbus = new DBus; +// new MenuAdaptor(m_dbus); +// QDBusConnection con = QDBusConnection::sessionBus(); +// if (!con.registerService("org.ukui.menu") || +// !con.registerObject("/org/ukui/menu", m_dbus)) { +// qDebug() << "error:" << con.lastError().message(); +// } +// connect(m_dbus, &DBus::winKeyResponseSignal, this, [ = ] { +// if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) +// { +// QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); +// if (gsetting.keys().contains("winKeyRelease")) { +// if (gsetting.get(QString("winKeyRelease")).toBool()) { +// return; +// } +// } +// } +// if (QApplication::activeWindow() == this) +// { +// myDebug() << "win键触发窗口隐藏事件"; +// this->hide(); +// } else +// { +// myDebug() << "win键触发窗口显示事件"; +// this->showPCMenu(); +// } +// }); +} + +bool TabletWindow::checkapplist() +{ + qDebug() << "MainWindow checkapplist"; + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + QSettings *setting = new QSettings(path, QSettings::IniFormat); + setting->beginGroup("application"); + QStringList keyList = setting->allKeys(); + setting->sync(); + setting->endGroup(); + delete setting; +// if(keyList.count() == UkuiMenuInterface::desktopfpVector.count()) +// { +// return false; +// }else + { + UkuiMenuInterface::desktopfpVector.clear(); + + for (int i = 0; i < keyList.count(); i++) { + QString tmp; + + if (UkuiMenuInterface::androidDesktopfnList.contains(keyList.at(i))) { + tmp = QString(QDir::homePath() + "/.local/share/applications/" + keyList.at(i)); + } else { + tmp = QString("%1%2").arg("/usr/share/applications/").arg(keyList.at(i)); + } + + UkuiMenuInterface::desktopfpVector.append(tmp); + } + + return true; + } +} + +bool TabletWindow::eventFilter(QObject *target, QEvent *event) +{ + if (target == m_scrollArea->viewport()) { + if (event->type() == QEvent::Wheel) { + event->ignore(); + return true; + } + } + + if (target == m_firstPageWidget || target == m_buttonWidget) { + if (event->type() == QEvent::MouseMove) { + return true; + } + } + + if (target == m_firstPageWidget) { + if (event->type() == QEvent::MouseButtonRelease) {//因触控拖拽会触发press事件,所以改为release时隐藏 + recvHideMainWindowSlot(); + } + } + + return false; +} + + +void TabletWindow::wheelEvent(QWheelEvent *e) +{ + if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { + if (qAbs(e->angleDelta().y()) >= qAbs(e->angleDelta().x())) { + if ((e->angleDelta().y() >= 120)) { + on_pageNumberChanged(false); + } else if ((e->angleDelta().y() <= -120)) { + on_pageNumberChanged(true); + } + } else if (qAbs(e->angleDelta().y()) < qAbs(e->angleDelta().x())) { + if ((e->angleDelta().x() >= 120)) { + on_pageNumberChanged(false); + } else if ((e->angleDelta().x() <= -120)) { + on_pageNumberChanged(true); + } + } + } + + e->ignore(); +} + +/** + * 初始化应用列表界面 + */ +void TabletWindow::initAppListWidget() +{ + m_layout = new QVBoxLayout(this); + m_layout->setContentsMargins(0, 0, 0, 0); + this->setLayout(m_layout); + m_firstPageLayout = new QHBoxLayout(); +// m_scrollAreaWid->setStyleSheet("border:0px; background:transparent;"); + m_scrollArea->setWidget(m_scrollAreaWid); + m_scrollArea->setWidgetResizable(true); + m_scrollArea->setStyleSheet("border:0px; background:transparent;"); + m_scrollArea->setProperty("notUseSlideGesture", true); + m_scrollArea->setFocusPolicy(Qt::NoFocus); + m_scrollArea->viewport()->installEventFilter(this); + m_scrollAreaWidLayout = new QHBoxLayout(m_scrollAreaWid); + m_scrollAreaWidLayout->setContentsMargins(0, 0, 0, 0); + m_scrollAreaWidLayout->setSpacing(0); + m_layout->addWidget(m_scrollArea); + m_layout->addWidget(m_buttonWidget); + m_buttonWidget->installEventFilter(this); + fillAppList(); +} + +void TabletWindow::modelChanged(bool value) +{ + if (value) { + ways(); + recvHideMainWindowSlot(); + } + + QEventLoop loop; + QTimer::singleShot(500, &loop, SLOT(quit())); + loop.exec(); + QDBusReply res = m_usrInterface->call("get_current_tabletmode"); + + if (!res) { + initSize(); + reloadWidget(); + } + +// reloadAppList(); + myDebug() << "平板模式切换"; +} + +//打开PC模式下的开始菜单 +void TabletWindow::showPCMenu() +{ +// this->setAttribute(Qt::WA_TranslucentBackground,true); +// this->setAttribute(Qt::WA_X11NetWmWindowTypeDesktop,false); +// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + this->show(); + this->raise(); + this->activateWindow(); + g_menuStatus = true; + menuStatusChange(); + myDebug() << "showMenu显示开始菜单"; +} + +//改变搜索框及工具栏透明度 +void TabletWindow::setOpacityEffect(const qreal &num) +{ + m_leftWidget->setDownOpacityEffect(num); //全局搜索框透明度 +} + +void TabletWindow::reloadAppList() +{ +// qDebug() << "void TabletWindow::reloadAppList()"; + QVector vector; + m_data.clear(); + m_keyVector.clear(); + m_keyValueVector.clear(); + vector = m_pagemanager->getAppPageVector(); + + if (!vector.at(0).isEmpty()) { + QLayoutItem *widItem = m_firstPageLayout->itemAt(1); + QWidget *wid = widItem->widget(); + TabletListView *m_listview = qobject_cast(wid); + m_listview->updateData(vector.at(0)); + } + + for (int i = 1; i < vector.size(); i++) { + if (!vector.at(i).isEmpty()) { + QLayoutItem *widItem = m_scrollAreaWidLayout->itemAt(i); + QWidget *wid = widItem->widget(); + TabletListView *m_listview = qobject_cast(wid); + m_listview->updateData(vector.at(i)); + } + } +} + +void TabletWindow::reloadWidget() +{ + QLayoutItem *child; + + if (m_firstPageLayout->count() == 2) { + QLayoutItem *widItem = m_firstPageLayout->itemAt(1); + QWidget *wid = widItem->widget(); + TabletListView *m_listview = qobject_cast(wid); + delete m_listview; + m_firstPageLayout->removeWidget(m_leftWidget); + } + + while ((child = m_scrollAreaWidLayout->takeAt(1)) != 0) { + if (child->widget() != 0) { + delete child->widget(); + } + + delete child; + } + + m_isFirstPage = true; + fillAppList(); + buttonWidgetShow(); +} +/** + * 填充应用列表 + */ +void TabletWindow::fillAppList() +{ + QVector vector; + m_data.clear(); + m_keyVector.clear(); + m_keyValueVector.clear(); + vector = m_pagemanager->getAppPageVector(); + + for (int i = 0; i < vector.size(); i++) { + QStringList applist = vector.at(i); + + if (!applist.isEmpty()) { +// if (!m_isFirstPage) { +// insertAppList(QStringList()); +// } + insertAppList(applist); + } + } +} +bool TabletWindow::cmpApp(QString &arg_1, QString &arg_2) +{ + if (m_keyValueVector.at(m_keyVector.indexOf(arg_1)) < m_keyValueVector.at(m_keyVector.indexOf(arg_2))) { + return true; + } else { + return false; + } +} + +void TabletWindow::directoryChangedSlot() +{ + myDebug() << "监测到desktop文件变化"; + m_appFileWatcher->addPaths(QStringList() << QString("/usr/share/applications") + << QString(QDir::homePath() + "/.local/share/applications/")); + QEventLoop loop; + QTimer::singleShot(100, &loop, SLOT(quit())); + loop.exec(); + m_directoryChangedThread->start(); +} +void TabletWindow::requestUpdateSlot(QString desktopfp) +{ + m_directoryChangedThread->quit(); + reloadWidget(); + connect(m_appListFileWatcher, &QFileSystemWatcher::fileChanged, this, &TabletWindow::directoryChangedSlot); +} + +void TabletWindow::requestDeleteAppSlot() +{ + m_directoryChangedThread->quit(); + reloadWidget(); + connect(m_appListFileWatcher, &QFileSystemWatcher::fileChanged, this, &TabletWindow::directoryChangedSlot); +} + +void TabletWindow::on_pageNumberChanged(bool nextPage) +{ +// qDebug() << "void TabletWindow::on_pageNumberChanged(bool nextPage)"; +// if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { + int preNum = m_curPageNum; + + if (nextPage) { + m_curPageNum++; + + if (m_curPageNum > (m_scrollAreaWidLayout->count() - 1)) { + m_curPageNum = (m_scrollAreaWidLayout->count() - 1); + return; + } + } else { + m_curPageNum--; + + if (m_curPageNum < 0) { + m_curPageNum = 0; + return; + } + } + + m_scrollArea->horizontalScrollBar()->setMaximum(m_scrollAreaWidLayout->count() * 1920); + btnGroupClickedSlot(preNum, m_curPageNum); + pageNumberChanged(m_curPageNum + 1); +// } +} + +bool TabletWindow::event(QEvent *event) +{ + if (event->type() == QEvent::ActivationChange) + //if(QEvent::WindowDeactivate == event->type())//窗口停用 + { + if (QApplication::activeWindow() != this) { + myDebug() << " * 鼠标点击窗口外部事件"; + this->hide(); + g_menuStatus = false; + menuStatusChange(); + } + } + + if (event->type() == QEvent::MouseMove) { + qDebug() << "bool TabletWindow::event ( QEvent * event ) 鼠标移动"; + //return true; + event->ignore(); + } + + if (event->type() == QEvent::MouseButtonPress) { + if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { + this->hide(); + g_menuStatus = false; + myDebug() << "鼠标点击事件触发隐藏"; + } + } + + return QWidget::event(event); +} + +void TabletWindow::insertAppList(QStringList desktopfplist) +{ + TabletListView *listview = nullptr; + + if (m_isFirstPage) { + listview = new TabletListView(this, 0); + m_firstPageLayout->setSpacing(0); + m_firstPageLayout->setContentsMargins(0, 0, 0, 0); + m_firstPageWidget->setLayout(m_firstPageLayout); + m_firstPageLayout->addWidget(m_leftWidget); + listview->setFixedSize(Style::FirsPageViewWidth, Style::CenterWindHeight); + m_firstPageLayout->addWidget(listview); + m_scrollAreaWidLayout->addWidget(m_firstPageWidget); + listview->setGridSize(QSize(Style::TabletItemSizeWidthFirst, Style::AppListItemSizeHeight)); + m_isFirstPage = false; + } else { + listview = new TabletListView(this, 1); + listview->setFixedSize(Style::OtherPageViewWidth, Style::CenterWindHeight); + listview->setGridSize(QSize(Style::TabletItemSizeWidthOther, Style::AppListItemSizeHeight)); + m_scrollAreaWidLayout->addWidget(listview); + } + +// //修复异常黑框问题 +// connect(m_scrollArea, &ScrollArea::requestUpdate, listview->viewport(), [=](){ +// listview->repaint(listview->rect()); +// }); + connect(listview, &TabletListView::pagenumchanged, this, &TabletWindow::on_pageNumberChanged); + listview->setProperty("notUseSlideGesture", true); + m_data.clear(); + + for (int i = 0; i < desktopfplist.count(); i++) { + m_data.append(desktopfplist.at(i)); + } + + listview->addData(m_data); + connect(listview, &TabletListView::sendItemClickedSignal, this, &TabletWindow::execApplication); + connect(listview, &TabletListView::sendHideMainWindowSignal, this, &TabletWindow::recvHideMainWindowSlot); + connect(listview, &TabletListView::sendUpdateAppListSignal, this, &TabletWindow::reloadAppList); +} + +//void TabletWindow::recvStartMenuSlot() +//{ +// QDBusReply res = usrInterface->call("get_current_tabletmode"); + +// if (this->isVisible()) { +// if (!res) { //平板模式 下禁止wi隐藏菜单 +// this->hide(); +// } +// } else { +// if (!res) { //平板模式 下禁止win隐藏菜单 +// this->showPCMenu(); +// } +// } +//} + +/** + * 执行应用程序 + */ +void TabletWindow::execApplication(QString desktopfp) +{ + Q_EMIT sendHideMainWindowSignal(); + QDBusInterface iface("com.kylin.AppManager", + "/com/kylin/AppManager", + "com.kylin.AppManager", + QDBusConnection::sessionBus()); + + if (!g_subProjectCodeName.contains("mavis") + || (g_subProjectCodeName.contains("mavis") && !QDBusReply(iface.call("LaunchApp", desktopfp)))) { +// execApp(desktopfp); + QString str; + //打开文件.desktop + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); + //取出value值 + QString execnamestr = QString::fromLocal8Bit(name); + str = execnamestr; + //qDebug()<<"2 exec"<beginGroup("application"); + QString desktopfp1 = str; + //判断 + bool bo = m_disableAppSet->contains(desktopfp1.toLocal8Bit().data()); // iskey + bool bo1 = m_disableAppSet->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool(); //isvalue + m_disableAppSet->endGroup(); + + if (bo && bo1 == false) { //都存在//存在并且为false,从filepathlist中去掉 + //qDebug()<<"bool"<toImage(); + //qt_blurImage(&painter,srcImg,2,true,false);//top 27000//150 + QGraphicsBlurEffect *blur = new QGraphicsBlurEffect; + blur->setBlurRadius(70); + QImage result = applyEffectToImage(srcImg, blur, 70); + qt_blurImage(&painter, result, 1, false, false); //top 27000//150 + painter.end(); + return pixmap; +} + +void TabletWindow::pageNumberChanged(int pageNum) +{ + if (m_pagemanager->getAppPageVector().size() != 1) { + for (int page = 1; page <= m_pagemanager->getAppPageVector().size(); page++) { + if (pageNum == page) { + m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/selected.svg);}" + "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/selected.svg);}" + "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/selected.svg);}"); + } else { + m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/select.svg);}" + "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/select.svg);}" + "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/select.svg);}"); + } + } + } +} + +void TabletWindow::ways() +{ + m_pixmap = QPixmap(m_bgPath); + + if (m_bgOption == "zoom" || m_bgOption == "" || m_bgOption == NULL) { + m_bgOption = "scaled"; + } + + if (m_bgOption == "centered") { //居中 + m_backPixmap->load(m_bgPath); + } else if (m_bgOption == "stretched") { //拉伸 + m_pixmap = m_pixmap.scaled(this->size()); + m_backPixmap = &m_pixmap; + } else if (m_bgOption == "scaled") { //填充 + m_backPixmap->load(m_bgPath); + } else if (m_bgOption == "wallpaper") { //平铺 + m_backPixmap->load(m_bgPath); + } else { + m_pixmap = m_pixmap.scaled(this->size()); + m_backPixmap = &m_pixmap; + } + + m_backPixmap = blurPixmap(m_backPixmap); +} + +/** + * @brief FullBackgroundWidget::getPaddingPixmap + * @param pixmap 需要填充的图像 + * @param width 容器宽度 + * @param height 容器高度 + * @return + */ +QPixmap TabletWindow::getPaddingPixmap(QPixmap pixmap, int width, int height) +{ + if (pixmap.isNull() || pixmap.width() == 0 || pixmap.height() == 0) { + return QPixmap(); + } + + bool useHeight; + float scaled = 0.0; + QPixmap scaledPixmap; + QPixmap paddingPixmap; + qint64 rw = qint64(height) * qint64(pixmap.width()) / qint64(pixmap.height()); + useHeight = (rw >= width); + + if (useHeight) { + scaled = float(height) / float(pixmap.height()); + scaledPixmap = pixmap.scaled(pixmap.width() * scaled, height); + paddingPixmap = scaledPixmap.copy((pixmap.width() * scaled - width) / 2, 0, width, height); + } else { + scaled = float(width) / float(pixmap.width()); + scaledPixmap = pixmap.scaled(width, pixmap.height() * scaled); + paddingPixmap = scaledPixmap.copy(0, (pixmap.height() * scaled - height) / 2, width, height); + } + + return paddingPixmap; +} + +void TabletWindow::backgroundPic() //const QString &bgPath,QRect rect +{ +// qDebug()<<"5、绘制背景"; + QPainter painter(this); + + if (/*hideBackground*/false) { + QColor cor; + cor = "#252729"; + painter.setBrush(cor); + painter.drawRect(this->rect()); + } else if (m_bgOption == "zoom" || m_bgOption == "" || m_bgOption == NULL) { + m_bgOption = "scaled"; + } else if (m_bgOption == "centered") { + QColor cor; + cor = "#000000"; + painter.setBrush(cor); + painter.drawRect(this->rect()); + painter.drawPixmap(this->width() / 2 - m_backPixmap->width() / 2, + this->height() / 2 - m_backPixmap->height() / 2, + *m_backPixmap); + } else if (m_bgOption == "stretched") { + //qDebug() << "---------" << "stretched" << "----------"; + painter.drawPixmap(this->rect(), *m_backPixmap); + } else if (m_bgOption == "scaled") { + painter.setPen(QColor(0, 0, 0, 64));//蒙层效果 + painter.setBrush(QColor(0, 0, 0, 64)); + painter.drawPixmap(this->geometry(), getPaddingPixmap(*m_backPixmap, this->size().width(), this->size().height())); + painter.drawRect(this->geometry()); + } else if (m_bgOption == "wallpaper") { + //qDebug() << "---------" << "wallpaper" << "----------"; + int drawedWidth = 0; + int drawedHeight = 0; + + while (1) { + drawedWidth = 0; + + while (1) { + painter.drawPixmap(drawedWidth, drawedHeight, *m_backPixmap); + drawedWidth += m_backPixmap->width(); + + if (drawedWidth >= this->width()) { + break; + } + } + + drawedHeight += m_backPixmap->height(); + + if (drawedHeight >= this->height()) { + break; + } + } + } else { + painter.drawPixmap(this->rect(), *m_backPixmap); + } +} + +void TabletWindow::recvHideMainWindowSlot() +{ +// this->setAttribute(Qt::WA_TranslucentBackground,true); +// this->setAttribute(Qt::WA_X11NetWmWindowTypeDesktop,false); +// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + this->hide(); + g_menuStatus = false; + myDebug() << "信号触发隐藏窗口"; +} + +void TabletWindow::btnGroupClickedSlot(int prePageNum, int pageNum) +{ + qDebug() << "void TabletWindow::btnGroupClickedSlot(int pageNum)"; + int durationTime = 200; + + if (prePageNum == pageNum) { + durationTime = 1; + } + + if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { + QPixmap p = m_scrollAreaWid->grab(m_scrollAreaWid->rect()); + m_animationPage.setFixedSize(m_scrollAreaWid->size()); + m_animationPage.setPixmap(p); + m_beginPos = m_scrollArea->horizontalScrollBar()->sliderPosition(); + m_endPos = m_scrollAreaWidLayout->itemAt(pageNum)->widget()->x(); + m_scrollArea->horizontalScrollBar()->setValue(m_endPos); + m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_scrollAnimation->setDuration(durationTime); + m_scrollAnimation->setStartValue(QPoint(-m_beginPos, m_scrollArea->y())); + m_scrollAnimation->setEndValue(QPoint(-m_endPos, m_scrollArea->y())); + m_scrollAnimation->start(); + m_animationPage.show(); + m_animationPage.raise(); + m_scrollAreaWid->hide(); + } +} + +void TabletWindow::buttonWidgetShow() +{ + //qDebug()<<"4、buttonWidgetShow"; + delete m_buttonBoxLayout; + m_buttonBoxLayout = new QHBoxLayout; + m_buttonWidget->setLayout(m_buttonBoxLayout); + m_buttonBoxLayout->setAlignment(Qt::AlignHCenter); + m_buttonBoxLayout->setSpacing(16); + m_buttonBoxLayout->setContentsMargins(0, 0, 0, 0); + + for (auto button : m_buttonGroup->buttons()) { + m_buttonGroup->removeButton(button); + button->deleteLater(); + } + + QDBusReply var = m_usrInterface->call("get_current_tabletmode"); + +// res = var; + for (int page = 1; page <= m_pagemanager->getAppPageVector().size(); page++) { + m_pageButton = new QPushButton; + m_pageButton->setFocusPolicy(Qt::NoFocus); + m_pageButton->setFixedSize(24, 24); + m_pageButton->setStyleSheet("QPushButton{border-image: url(:/data/img/mainviewwidget/select.svg);}" + "QPushButton:hover{border-image: url(:/img/mainviewwidget/select.svg);}" + "QPushButton:pressed{border-image:url(:/img/mainviewwidget/select.svg);}"); + + if (page == 1) { + m_pageButton->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/selected.svg);}" + "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/selected.svg);}" + "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/selected.svg);}"); + } + + m_buttonBoxLayout->addWidget(m_pageButton); + m_buttonGroup->addButton(m_pageButton, page); + } + + btnGroupClickedSlot(0, 0); + m_curPageNum = 0; + connect(m_buttonGroup, QOverload::of(&QButtonGroup::buttonClicked), this, &TabletWindow::buttonClicked); +} + +void TabletWindow::buttonClicked(QAbstractButton *button) +{ + if (!(m_scrollAnimation->state() == QPropertyAnimation::Running)) { + int idd = m_buttonGroup->id(button); + int preNum = m_curPageNum; + Style::nowpagenum = idd; + +// QDBusReply res = usrInterface->call("get_current_tabletmode"); + for (int page = 1; page <= m_pagemanager->getAppPageVector().size(); page++) { + if (idd == page) { + m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/selected.svg);}" + "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/selected.svg);}" + "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/selected.svg);}"); + } else { + m_buttonGroup->button(page)->setStyleSheet("QPushButton{border-image:url(:/data/img/mainviewwidget/select.svg);}" + "QPushButton:hover{border-image: url(:/data/img/mainviewwidget/select.svg);}" + "QPushButton:pressed{border-image: url(:/data/img/mainviewwidget/select.svg);}"); + } + } + + m_curPageNum = idd - 1; + btnGroupClickedSlot(preNum, m_curPageNum); + } +} + +void TabletWindow::animationFinishSlot() +{ + m_scrollAreaWid->show(); + m_scrollAreaWid->raise(); + m_animationPage.hide(); +// if(m_scrollArea->horizontalScrollBar()->value()==m_endPos || +// m_scrollArea->horizontalScrollBar()->value()==m_scrollArea->horizontalScrollBar()->maximum()) +// { +// m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); +// } +} + +void TabletWindow::animationValueChangedSlot(const QVariant &value) +{ + Q_UNUSED(value); + + if (sender() != m_scrollAnimation) { + return; + } + + QPropertyAnimation *ani = qobject_cast(sender()); + + if (m_endPos != ani->endValue()) { + ani->setEndValue(m_endPos); + } +} + +void TabletWindow::xkbEventsPress(const QString &keycode) +{ + myDebug() << keycode; + QString KeyName; + + if (keycode.length() >= 8) { + KeyName = keycode.left(8); + } + + if (KeyName.compare("Super_L+") == 0) {//组合按键 + m_winFlag = true; + } + + if (keycode == "Super_L") {//win键 + m_winFlag = false; + } +} + +void TabletWindow::xkbEventsRelease(const QString &keycode) +{ + myDebug() << "触发按键释放" << keycode; + QString KeyName; + + if (keycode.length() >= 8) { + KeyName = keycode.left(8); + } + + if (KeyName.compare("Super_L+") == 0 || //组合释放 + (m_winFlag && keycode == "Super_L")) { //组合按下单独释放 + return; + } + + QDBusReply res = m_usrInterface->call("get_current_tabletmode"); + + if (m_usrInterface && res) { + qWarning() << QTime::currentTime() + << " Now is tablet mode, and it is forbidden to hide or show the menu after 'win'.'Esc'"; + return; + } + + /**以下代码是非平板模式需要处理的键盘按键**/ + if ((keycode == "Super_L") || (keycode == "Super_R")) { + qDebug() << "(ActiveWindow, SelfWindow):(" << QApplication::activeWindow() << ", " << this << ")"; + + if (QApplication::activeWindow() == this) { +// if (m_CommonUseWidget->m_listView->isDraging()) { +// qWarning() << "Icon is been draging"; +// } + qDebug() << "win键触发窗口隐藏事件"; + this->hide(); + g_menuStatus = false; + } else { + qDebug() << "win键触发窗口显示事件"; + this->showPCMenu(); + g_menuStatus = true; + } + } + + if (keycode == "Escape") { + this->hide(); + } +} + +void TabletWindow::winKeyReleaseSlot(const QString &key) +{ + if (key == "winKeyRelease" || key == "win-key-release") { + if (QGSettings::isSchemaInstalled(QString("org.ukui.session").toLocal8Bit())) { + QGSettings gsetting(QString("org.ukui.session").toLocal8Bit()); + + if (gsetting.keys().contains("winKeyRelease")) { + if (gsetting.get(QString("winKeyRelease")).toBool()) { + disconnect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), + this, SLOT(xkbEventsRelease(QString))); + disconnect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), + this, SLOT(xkbEventsPress(QString))); + } else { + connect(XEventMonitor::instance(), SIGNAL(keyRelease(QString)), + this, SLOT(xkbEventsRelease(QString))); + connect(XEventMonitor::instance(), SIGNAL(keyPress(QString)), + this, SLOT(xkbEventsPress(QString))); + } + } + } + } +} + +void TabletWindow::menuStatusChange() +{ + QDBusMessage message = QDBusMessage::createSignal("/com/ukui/menu", "com.ukui.menu", "statusChangeSignal"); + //给信号赋值 + message << g_menuStatus; + //发射 + QDBusConnection::sessionBus().send(message); +} diff --git a/src/UserInterface/tabletwindow.h b/src/UserInterface/tabletwindow.h new file mode 100755 index 0000000..7b6a03d --- /dev/null +++ b/src/UserInterface/tabletwindow.h @@ -0,0 +1,246 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ukuimenuinterface.h" +#include "scrollarea.h" +#include "splitbar_frame.h" +#include "fulllistview.h" +#include "classify_btn_scrollarea.h" +#include "tool_button.h" +#include "function_classify_button.h" +#include "style.h" +#include +#include "function_Widget.h" +#include "tabletlistview.h" +#include "pagemanager.h" +#include "tablet_directorychanged_thread.h" + +class TabletWindow : public QWidget +{ + Q_OBJECT + +public: + explicit TabletWindow(QWidget *parent = nullptr); + + ~TabletWindow(); + + void repaintWidget(); + + void showPCMenu(); //打开pc的开始菜单 + + static bool cmpApp(QString &arg_1, QString &arg_2); + + void setOpacityEffect(const qreal &num); + +private: + /*Application list interface*/ + QScrollArea *m_scrollArea = nullptr; + ScrollAreaWid *m_scrollAreaWid = nullptr; + QHBoxLayout *m_scrollAreaWidLayout = nullptr; + QStringList m_data; + /*Function classification list interface*/ + QWidget *m_iconListWid = nullptr; + ClassifyBtnScrollArea *m_iconListScrollArea = nullptr; + ClassifyBtnScrollAreaWid *m_iconListScrollAreaWid = nullptr; + QVBoxLayout *m_iconListWidLayout = nullptr; + QList m_buttonList; + QButtonGroup *m_btnGroup = nullptr; + QSpacerItem *m_topSpacerItem = nullptr; + QSpacerItem *m_bottomSpacerItem = nullptr; + + /*Animation*/ + QPropertyAnimation *m_scrollAnimation = nullptr;//Application list animation + int m_beginPos = 0;//Application list scrollbar starting value + int m_endPos = 0;//Application list scrollbar end value + int m_index = 0; + int m_scrollAreaWidHeight = 0; + + int m_width; + int m_height; + + QString m_bgPath; + QString m_bgOption; + QPixmap m_pixmap; + + QPixmap *m_backPixmap = nullptr; + QGSettings *m_bgSetting = nullptr; + QGSettings *m_bgEffect = nullptr; + + QDBusInterface *m_usrInterface = nullptr; + bool m_winFlag = false; + int m_curPageNum = 0; + QVBoxLayout *m_layout = nullptr; + FunctionWidget *m_leftWidget = nullptr; + bool m_isFirstPage = true; + QWidget *m_firstPageWidget = nullptr; + static QVector m_keyVector; + static QVector m_keyValueVector; + QSettings *m_setting = nullptr; + PageManager *m_pagemanager = nullptr; + TabletListView *m_listView = nullptr; + QHBoxLayout *m_firstPageLayout = nullptr; + QHBoxLayout *m_buttonBoxLayout = nullptr; + QButtonGroup *m_buttonGroup = nullptr; + QWidget *m_buttonWidget = nullptr; + QPushButton *m_pageButton = nullptr; + + QFileSystemWatcher *m_appFileWatcher = nullptr; + QFileSystemWatcher *m_appListFileWatcher = nullptr; + QFileSystemWatcher *m_configFileWatcher = nullptr; + TabletDirectoryChangedThread *m_directoryChangedThread = nullptr; + QSettings *m_disableAppSet = nullptr; + + QLabel m_animationPage; +// DBus *m_dbus = nullptr; + +protected: + /** + * @brief Initializes UI + */ + void initUi(); + /** + * @brief initSize + */ + void initSize(); + + void fileWatcher(); + + void setBackground(); + + void registDbusService(); + + void initTransparency(); + + void initStatusManager(); + + void initXEventMonitor(); + /** + * @brief Initialize the application list interface + */ + void initAppListWidget(); + /** + * @brief fill application list + */ + void fillAppList(); + /** + * @brief Insert application list + * @param desktopfplist: Desktop file path list + */ + void insertAppList(QStringList desktopfplist); + + void paintEvent(QPaintEvent *event); + + void backgroundPic(); + + QPixmap *blurPixmap(QPixmap *pixmap); + + void ways(); + + QPixmap getPaddingPixmap(QPixmap pixmap, int width, int height); + + QImage applyEffectToImage(QImage src, QGraphicsEffect *effect, int extent = 0); + + void buttonWidgetShow(); + + bool event(QEvent *event); + + void wheelEvent(QWheelEvent *e); + + bool eventFilter(QObject *target, QEvent *event); + + bool checkapplist(); + + void menuStatusChange(); + +public Q_SLOTS: + /** + * @brief Open the application + * @param arg: Desktop file path + */ + void execApplication(QString desktopfp); + /** + * @brief Respond to button click + * @param btn: QButtonGroup button + */ + void btnGroupClickedSlot(int prePageNum, int pageNum); + + void reloadAppList(); + + /** + * @brief Respond to application list animation finish + */ + void animationFinishSlot(); + /** + * @brief Respond to application list animation current value change + * @param value: animation current value + */ + void animationValueChangedSlot(const QVariant &value); + + void recvHideMainWindowSlot(); + +// void recvStartMenuSlot(); + + void modelChanged(bool value); + + void xkbEventsPress(const QString &keycode); + void xkbEventsRelease(const QString &keycode); + void winKeyReleaseSlot(const QString &key); + void on_pageNumberChanged(bool nextPage); + void buttonClicked(QAbstractButton *m_pageButton); + void pageNumberChanged(int pageNum); + void requestDeleteAppSlot(); + void requestUpdateSlot(QString desktopfp); + void directoryChangedSlot(); + void reloadWidget(); +Q_SIGNALS: + /** + * @brief Send a hidden main window signal to the MainViewWidget + */ + void sendHideMainWindowSignal(); + + void setFocusToSideWin(); + + void selectFirstItem(); + + void changeScrollValue(int value, int maximumValue); + + void pagenumchanged(int pageNum); //翻页信号 + + void sendDirectoryPath(QString arg); + + void UpdateSignal(); +}; + +#endif // FULLFUNCTIONWIDGET_H diff --git a/src/UserInterface/userinterface.pri b/src/UserInterface/userinterface.pri new file mode 100755 index 0000000..56b58f8 --- /dev/null +++ b/src/UserInterface/userinterface.pri @@ -0,0 +1,84 @@ +INCLUDEPATH += \ + $$PWD \ + $$PWD/Button \ + $$PWD/ListView \ + $$PWD/Other \ + $$PWD/RightClickMenu \ + $$PWD/ViewItem \ + $$PWD/Widget + +HEADERS += \ + $$PWD/Button/function_classify_button.h \ + $$PWD/Button/letter_classify_button.h \ + $$PWD/Button/tool_button.h \ + $$PWD/ListView/fulllistview.h \ + $$PWD/ListView/klistview.h \ + $$PWD/ListView/listview.h \ + $$PWD/ListView/rightlistview.h \ + $$PWD/ListView/tabletlistview.h \ + $$PWD/Other/classify_btn_scrollarea.h \ + $$PWD/Other/lettertooltip.h \ + $$PWD/Other/rotationlabel.h \ + $$PWD/Other/scrollarea.h \ + $$PWD/RightClickMenu/menubox.h \ + $$PWD/RightClickMenu/rightclickmenu.h \ + $$PWD/RightClickMenu/tabletrightclickmenu.h \ + $$PWD/ViewItem/full_item_delegate.h \ + $$PWD/ViewItem/itemdelegate.h \ + $$PWD/ViewItem/kitemdelegate.h \ + $$PWD/ViewItem/recent_item_delegate.h \ + $$PWD/ViewItem/right_item_delegate.h \ + $$PWD/ViewItem/tablet_full_itemdelegate.h \ + $$PWD/Widget/animationpage.h \ + $$PWD/Widget/full_commonuse_widget.h \ + $$PWD/Widget/full_function_widget.h \ + $$PWD/Widget/full_letter_widget.h \ + $$PWD/Widget/full_searchresult_widget.h \ + $$PWD/Widget/function_Widget.h \ + $$PWD/Widget/function_button_widget.h \ + $$PWD/Widget/letter_button_widget.h \ + $$PWD/Widget/main_view_widget.h \ + $$PWD/Widget/plugin_widget.h \ + $$PWD/Widget/splitbar_frame.h \ + $$PWD/Widget/tabview_widget.h \ + $$PWD/full_mainwindow.h \ + $$PWD/mainwindow.h \ + $$PWD/tabletwindow.h + +SOURCES += \ + $$PWD/Button/function_classify_button.cpp \ + $$PWD/Button/letter_classify_button.cpp \ + $$PWD/Button/tool_button.cpp \ + $$PWD/ListView/fulllistview.cpp \ + $$PWD/ListView/klistview.cpp \ + $$PWD/ListView/listview.cpp \ + $$PWD/ListView/rightlistview.cpp \ + $$PWD/ListView/tabletlistview.cpp \ + $$PWD/Other/classify_btn_scrollarea.cpp \ + $$PWD/Other/lettertooltip.cpp \ + $$PWD/Other/rotationlabel.cpp \ + $$PWD/Other/scrollarea.cpp \ + $$PWD/RightClickMenu/menubox.cpp \ + $$PWD/RightClickMenu/rightclickmenu.cpp \ + $$PWD/RightClickMenu/tabletrightclickmenu.cpp \ + $$PWD/ViewItem/full_item_delegate.cpp \ + $$PWD/ViewItem/itemdelegate.cpp \ + $$PWD/ViewItem/kitemdelegate.cpp \ + $$PWD/ViewItem/recent_item_delegate.cpp \ + $$PWD/ViewItem/right_item_delegate.cpp \ + $$PWD/ViewItem/tablet_full_itemdelegate.cpp \ + $$PWD/Widget/animationpage.cpp \ + $$PWD/Widget/full_commonuse_widget.cpp \ + $$PWD/Widget/full_function_widget.cpp \ + $$PWD/Widget/full_letter_widget.cpp \ + $$PWD/Widget/full_searchresult_widget.cpp \ + $$PWD/Widget/function_Widget.cpp \ + $$PWD/Widget/function_button_widget.cpp \ + $$PWD/Widget/letter_button_widget.cpp \ + $$PWD/Widget/main_view_widget.cpp \ + $$PWD/Widget/plugin_widget.cpp \ + $$PWD/Widget/splitbar_frame.cpp \ + $$PWD/Widget/tabview_widget.cpp \ + $$PWD/full_mainwindow.cpp \ + $$PWD/mainwindow.cpp \ + $$PWD/tabletwindow.cpp diff --git a/src/UtilityFunction/AbstractInterface.h b/src/UtilityFunction/AbstractInterface.h new file mode 100755 index 0000000..90ed8ff --- /dev/null +++ b/src/UtilityFunction/AbstractInterface.h @@ -0,0 +1,13 @@ +#ifndef ABSTRACTINTERFACE_H +#define ABSTRACTINTERFACE_H +#include +class QWidget; +class AbstractInterface +{ +public: + virtual ~AbstractInterface() {} + virtual QWidget *createPluginWidget(QWidget *parent, bool type) = 0; +}; +#define AbstractInterface_iid "Welcome to use focusmode" +Q_DECLARE_INTERFACE(AbstractInterface, AbstractInterface_iid) +#endif // ABSTRACTINTERFACE_H diff --git a/src/UtilityFunction/KySmallPluginInterface.h b/src/UtilityFunction/KySmallPluginInterface.h new file mode 100755 index 0000000..cf9ad21 --- /dev/null +++ b/src/UtilityFunction/KySmallPluginInterface.h @@ -0,0 +1,31 @@ +#ifndef KYSMALLPLUGININTERFACE_H +#define KYSMALLPLUGININTERFACE_H + +#include +#include +#include +#include + +class QWidget; +class KySmallPluginInterface +{ + +public: + virtual ~KySmallPluginInterface() {} + virtual const QString name() const = 0; + virtual const QString nameCN() const = 0; + virtual const QString description() const = 0; + virtual int sortNum() const = 0; + virtual QWidget *createWidget(QWidget *parent) = 0; +}; +QT_BEGIN_NAMESPACE +/* + * 声明接口,Q_DECLARE_INTERFACE 宏告诉Qt 这个纯虚类是一个插件接口类 + * Q_DECLARE_INTERFACE(接口类名, 接口标识符) + * 如果我们稍后更改接口,则必须使用不同的字符串来标识新接口;否则,应用程序可能会崩溃。因此,在字符串中包含一个版本号是一个好主意 +*/ +#define SP_PLUGIN_IID "org.Kylin.SmallPlugin.widgetInterface/1.0" +Q_DECLARE_INTERFACE(KySmallPluginInterface, SP_PLUGIN_IID) +QT_END_NAMESPACE + +#endif // KYSMALLPLUGININTERFACE_H diff --git a/src/UtilityFunction/Style/style.cpp b/src/UtilityFunction/Style/style.cpp new file mode 100755 index 0000000..53378bd --- /dev/null +++ b/src/UtilityFunction/Style/style.cpp @@ -0,0 +1,255 @@ +/* + * 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 +#include "src/UtilityFunction/utility.h" +#include "src/UtilityFunction/utility.h" +#include + +Style::Style() +{ +} + +int Style::m_primaryScreenX = 0; +int Style::m_primaryScreenY = 0; +int Style::m_panelPosition = 0; +//默认窗口 +int Style::minw = 0; +int Style::minh = 0; +int Style::leftPageWidth = 0; +int Style::leftPageHeight = 0; +int Style::defaultQueryLineEditIconSize = 0; +/** + * 全屏窗口 + */ +//主窗口 +int Style::m_availableScreenWidth = 0; +int Style::m_availableScreenHeight = 0; +//搜索栏 +int Style::QueryLineEditHeight = 0; +//左侧栏 +int Style::m_leftWidWidth = 0; +int Style::LeftMargin = 0; +int Style::LeftBtnWidth = 0; +int Style::LeftBtnHeight = 0; +int Style::LeftLetterBtnHeight = 0; +int Style::LeftLetterFontSize = 0; +int Style::LeftIconSize = 0; +int Style::LeftSpaceIconText = 0; +int Style::LeftSpaceBetweenItem = 0; +//应用列表栏 +int Style::m_applistWidWidth = 0; +int Style::m_applistWidHeight = 0; +int Style::AppListIconSize = 0; +int Style::AppListBigIconSize = 0; +int Style::AppListItemSizeWidth = 0; +int Style::TabletItemSizeWidthOther = 0; +int Style::TabletItemSizeWidthFirst = 0; +int Style::FirsPageViewWidth = 0; +int Style::OtherPageViewWidth = 0; +int Style::m_applistGridSizeWidth = 0; +int Style::AppLeftSpace = 0; +int Style::AppTopSpace = 0; +int Style::AppSpaceBetweenIconText = 0; +int Style::FirstPageSpace = 0; +int Style::OtherPageSpace = 0; + +//侧边栏primaryScreen +int Style::SideBarWidWidth = 0; + +int Style::appLine = 0; +int Style::appColumn = 0; +int Style::appLineFirst = 0; +int Style::appColumnFirst = 0; +int Style::appPage = 1; +int Style::appNum = 0; +int Style::nowpagenum = 1; +int Style::appRows = 0; +bool Style::ScreenRotation = false; +int Style::AppListItemSizeHeight = 270; +int Style::AppListViewTopMargin = 0; +int Style::ScreenWidth = 0; +int Style::ScreenHeight = 0; +int Style::AppListViewLeftMargin = 52; +int Style::AppListViewBottomMargin = 20; +int Style::AppListViewRightMargin = 0; +int Style::TimeWidgetTop = 81; +int Style::TimeWidgetLeft = 112; +int Style::CenterWindHeight = 0; + +int Style::GroupAppColumn = 1; +int Style::GroupAppRow = 1; + +int Style::ButtonWidgetWidth = 56; + +int Style::ToolWidgetLeft = 24; +bool Style::IsWideScreen = false; + +int Style::DropMenuWidth = 0; +int Style::DropMenuHeight = 0; +int Style::miniIconSize = 0; + +int Style::rightViewWidth = 0; +int Style::rightViewHeight = 0; + +void Style::initWidStyle() +{ + if (!g_projectCodeName.contains("V10SP1-edu")) { + QVariantList list = getScreenGeometryList(); + m_primaryScreenX = list.at(0).toInt(); + m_primaryScreenY = list.at(1).toInt(); + m_availableScreenWidth = list.at(2).toInt(); + m_availableScreenHeight = list.at(3).toInt(); + m_panelPosition = list.at(5).toInt(); + int len = 0; + QString locale = QLocale::system().name(); + + if (locale == "zh_CN") { + len = 0; + } else { + len = 10; + } + + if (m_availableScreenWidth == 800 && m_availableScreenHeight == 600) { + minw = 320; + minh = 500; + leftPageWidth = 300; + leftPageHeight = 517; + } else { + minw = 652; + minh = 590; + leftPageWidth = 300; + leftPageHeight = 517; + } + + if (m_availableScreenWidth >= 2000 && m_availableScreenWidth <= 4000) { + LeftMargin = 20; + LeftLetterFontSize = 14; + LeftSpaceBetweenItem = 15; + AppListIconSize = 96; + AppListItemSizeWidth = 168; + m_applistGridSizeWidth = 240; + AppSpaceBetweenIconText = 20; + } else if (m_availableScreenWidth >= 1920 && m_availableScreenWidth < 2000) { + LeftMargin = 20; + LeftLetterFontSize = 14; + LeftSpaceBetweenItem = 15; + AppListIconSize = 86; + AppListItemSizeWidth = 168; + m_applistGridSizeWidth = 220; + AppSpaceBetweenIconText = 18; + } else if (m_availableScreenWidth >= 1600 && m_availableScreenWidth < 1920) { + LeftMargin = 10; + LeftLetterFontSize = 11; + LeftSpaceBetweenItem = 10; + AppListIconSize = 86; + AppListItemSizeWidth = 150; + m_applistGridSizeWidth = 180; + AppSpaceBetweenIconText = 14; + } else if (m_availableScreenWidth >= 1366 && m_availableScreenWidth < 1600) { + LeftMargin = 10; + LeftLetterFontSize = 11; + LeftSpaceBetweenItem = 10; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + m_applistGridSizeWidth = 140; + AppSpaceBetweenIconText = 0; + } else if (m_availableScreenWidth >= 1280 && m_availableScreenWidth < 1366) { + LeftMargin = 10; + LeftLetterFontSize = 11; + LeftSpaceBetweenItem = 10; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + m_applistGridSizeWidth = 142; + AppSpaceBetweenIconText = 14; + } else if (m_availableScreenWidth >= 1152 && m_availableScreenWidth < 1280) { + LeftMargin = 10; + LeftLetterFontSize = 11; + LeftSpaceBetweenItem = 10; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + m_applistGridSizeWidth = 142; + AppSpaceBetweenIconText = 14; + } else if (m_availableScreenWidth > 800 && m_availableScreenWidth < 1152) { + LeftMargin = 10; + LeftLetterFontSize = 11; + LeftSpaceBetweenItem = 10; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + m_applistGridSizeWidth = 141; + AppSpaceBetweenIconText = 14; + } else { + LeftMargin = 10; + LeftLetterFontSize = 11; + LeftSpaceBetweenItem = 10; + AppListIconSize = 64; + AppListItemSizeWidth = 112; + m_applistGridSizeWidth = 138; + AppSpaceBetweenIconText = 14; + } + + LeftBtnWidth = 68 + 5 * len; + LeftBtnHeight = 34; + QueryLineEditHeight = 30; + LeftLetterBtnHeight = 25; + LeftIconSize = 19; + DropMenuWidth = 170; + DropMenuHeight = 112; + miniIconSize = 8; + rightViewWidth = 324; + rightViewHeight = 470; + LeftSpaceIconText = 14; + m_applistWidWidth = m_availableScreenWidth / 1.25; + m_applistWidWidth = m_applistWidWidth - (m_applistWidWidth % m_applistGridSizeWidth) + 1; + m_applistWidHeight = m_availableScreenHeight - 120; + m_applistWidHeight = m_applistWidHeight - (m_applistWidHeight % m_applistGridSizeWidth) + 1; + m_leftWidWidth = (m_availableScreenWidth - m_applistWidWidth) / 2 + 1; + } else { + ScreenWidth = QApplication::primaryScreen()->geometry().width(); + ScreenHeight = QApplication::primaryScreen()->geometry().height(); + myDebug() << "Winches" << qApp->desktop()->widthMM(); + myDebug() << "Hinches" << qApp->desktop()->heightMM(); + myDebug() << "ScreenWidth" << ScreenWidth; + myDebug() << "ScreenHeight" << ScreenHeight; + appColumn = 6; + appLine = 4; + appLineFirst = 4; + AppListViewTopMargin = 70; + AppListViewLeftMargin = 52; + AppListViewBottomMargin = AppListViewTopMargin - 30; + AppListViewRightMargin = 0; + m_leftWidWidth = ScreenWidth * 0.3; + FirsPageViewWidth = ScreenWidth - m_leftWidWidth - 5; + appColumnFirst = FirsPageViewWidth / 220; + OtherPageViewWidth = ScreenWidth; + TabletItemSizeWidthFirst = FirsPageViewWidth / appColumnFirst; + TabletItemSizeWidthOther = (ScreenWidth - 5) / appColumn; + CenterWindHeight = ScreenHeight - AppListViewBottomMargin - AppListViewTopMargin; + AppListItemSizeHeight = CenterWindHeight / appLine; + AppListIconSize = 96; + AppListBigIconSize = 108; + AppTopSpace = (AppListItemSizeHeight - AppListIconSize) / 2; + AppLeftSpace = (TabletItemSizeWidthFirst - AppListIconSize) / 2; + TimeWidgetTop = (CenterWindHeight - 870) / 2; + TimeWidgetLeft = (m_leftWidWidth - 400) / 2; + FirstPageSpace = AppLeftSpace; + OtherPageSpace = (TabletItemSizeWidthOther - AppListIconSize) / 2; + } +} diff --git a/src/Style/style.h b/src/UtilityFunction/Style/style.h old mode 100644 new mode 100755 similarity index 64% rename from src/Style/style.h rename to src/UtilityFunction/Style/style.h index 93bcfee..a74e0da --- a/src/Style/style.h +++ b/src/UtilityFunction/Style/style.h @@ -31,7 +31,6 @@ //颜色 #define BORDERCOLOR "rgba(37,41,43)" //边框 #define SHADOWCOLOR "#80000000" //阴影 - #define UserIconBackground "#ffffff" #define UserIconOpacity 0.20 #define RightClickMenuBackground "rgba(12, 12, 13, 0.7)"//右键菜单背景 @@ -52,7 +51,7 @@ #define QueryLineEditClickedDefaultBackground "rgba(0, 0, 0,0.04)" //搜索框默认态背景选中 #define QueryLineEditClickedBackground "rgba(255, 255, 255,0.06)" //搜索框背景选中 #define QueryLineEditClickedBorderDefault "rgba(0, 0, 0,0.1)" //搜索框默认态背景选中边框 -#define QueryLineEditClickedBorder "rgba(255, 255, 255,0.15)" //搜索框背景选中边框 +#define QueryLineEditClickedBorder "rgba(5, 151, 255, 1)" //搜索框背景选中边框 #define AppBtnHover "#ffffff" //按钮悬浮 /** @@ -61,22 +60,15 @@ ////左侧栏 //#define LeftWidSize leftsize //大小 //#define LeftMarginLeftSize Leftmarginleftsize //内左侧边距 -//#define LeftFontSize leftfontsize //字体大小 -//#define LeftIconSize lefticonsize //图标大小 -//#define LeftSpaceIconLeft leftspaceiconleft //按钮内左侧边距 //#define LeftSpaceIconText leftspaceicontext //按钮图标与文字内边距 //#define LeftSpaceBetweenItem leftspacebetweenitem //item间距 ////应用列表栏 -//#define AppListWidSize applistwidsize //大小 -//#define AppListFontSize applistfontsize //字体大小 //#define AppListIconSize applisticonsize //图标大小 //#define AppListSpaceBetweenItem applistspacebetweenitem //item间距 -//#define SliderSize slidersize //滑块大小 ////右侧栏 //#define RightWidSize rightsize //大小 -//#define RightMarginLeftSize rightmarginleftsize //内右侧边距 //#define RightFontSize rightfontsize //字体大小 //#define RightIconSize righticonsize //图标大小 //#define RightSpaceIconLeft rightspaceiconleft //按钮内左侧边距 @@ -89,83 +81,103 @@ public: Style(); static void initWidStyle(); - static int primaryScreenX; - static int primaryScreenY; - static int primaryScreenWidth; - static int primaryScreenHeight; - static int panelPosition; - static int panelSize; + static int m_primaryScreenX; + static int m_primaryScreenY; + static int m_panelPosition; //默认窗口 static int minw; static int minh; - static int defaultMainViewWidWidth; - static int defaultTopWidHeight; - static int defaultQueryLineEditWidth; - static int defaultQueryLineEditHeight; + static int leftPageWidth; + static int leftPageHeight; static int defaultQueryLineEditIconSize; - static int defaultContentWidHeight; - static int defaultSideBarWidWidth; /** * 全屏 */ //主窗口 - static int widthavailable; - static int heightavailable; - //主视图 - static int MainViewWidWidth;//宽度 + static int m_availableScreenWidth; + static int m_availableScreenHeight; //搜索栏 - static int TopWidgetHeight;//高度 - static int QueryLineEditWidth;//搜索框宽度 static int QueryLineEditHeight;//搜索框高度 - static int QueryLineEditIconSize;//搜索框图标 - static int QueryLineEditFontSize;//搜索框字体大小 //左侧栏 - static int LeftWidWidth; //宽度 - static int LeftWidHeight; //高度 + static int m_leftWidWidth; //宽度 static int LeftMargin; //内左侧边距 - static int RightMargin;//内右侧边距 static int LeftBtnWidth;//按钮宽度 static int LeftBtnHeight;//按钮高度 static int LeftLetterBtnHeight;//按钮高度 - static int LeftFontSize; //字体大小 static int LeftLetterFontSize; //字体大小 static int LeftIconSize; //图标大小 - static int LeftSpaceIconLeft; //按钮内左侧边距 static int LeftSpaceIconText; //按钮图标与文字内边距 static int LeftSpaceBetweenItem; //item间距 //应用列表栏 - static int AppListWidWidth; //宽度 - static int AppListWidHeight; //高度 - static int AppListFontSize; //字体大小 + static int m_applistWidWidth; //宽度 + static int m_applistWidHeight; //高度 static int AppListIconSize; //图标大小 + static int AppListBigIconSize; static int AppListItemSizeWidth; //item大小 - static int AppListGridSizeWidth; //网格大小 + static int TabletItemSizeWidthFirst; + static int TabletItemSizeWidthOther; + static int FirsPageViewWidth; + static int OtherPageViewWidth; + static int m_applistGridSizeWidth; //网格大小 static int AppLeftSpace;//左侧边距 static int AppTopSpace;//上侧边距 static int AppSpaceBetweenIconText;//图标与文字边距 - static int AppBottomSpace;//下侧边距 - static int SliderSize; //滑块大小 + static int FirstPageSpace; + static int OtherPageSpace; /** * 侧边栏 */ static int SideBarWidWidth; //宽度 - static int SideBarMargin; //内右侧边距 - static int MinMaxWidWidth; //放大缩小界面宽度 - static int MinMaxWidHeight; //放大缩小界面高度 - static int MinMaxBtnWidth; //放大缩小按钮宽度 - static int MinMaxIconSize; //放大缩小按钮大小 - static int SideBarBtnWidth;//按钮宽度 - static int SideBarBtnHeight;//按钮高度 - static int SideBarFontSize; //字体大小 - static int SideBarIconSize; //图标大小 - static int SideBarSpaceIconLeft; //按钮内左侧边距 - static int SideBarSpaceIconText; //按钮图标与文字内边距 - static int SideBarSpaceBetweenItem; //item间距 -private: - static void getScreenAvailableGeometry(); //获取屏幕可用区域 + static int appLine; + static int appColumn; + static int appLineFirst; + static int appColumnFirst; + static int appNum; + static int appPage; + static int nowpagenum; + static int appRows; //app的总行数 + static bool ScreenRotation; + + static int AppListItemSizeHeight; + +// static int ScreenWidth; +// static int ScreenHeight; + + + static int LeftWidgetWidth; + + static int ScreenWidth; + static int ScreenHeight; + static int AppListViewTopMargin; + static int AppListViewLeftMargin; + static int AppListViewBottomMargin; + static int AppListViewRightMargin; + static int CenterWindHeight; + + static int GroupAppRow; + static int GroupAppColumn; + + static int TimeWidgetTop; + static int TimeWidgetLeft; + + static int ButtonWidgetWidth; + + //扩展的开始菜单应用列表 + static int ToolWidgetLeft; + static int WideAppListItemSizeWidth; + static int WideAppListItemSizeHeight; + static int WideAppViewLeftMargin; + static bool IsWideScreen; + static int DropMenuWidth; + static int DropMenuHeight; + static int miniIconSize; + + static int rightViewWidth; + static int rightViewHeight; + }; #endif // STYLE_H diff --git a/src/UtilityFunction/abstractInterface.h b/src/UtilityFunction/abstractInterface.h new file mode 100755 index 0000000..f484d73 --- /dev/null +++ b/src/UtilityFunction/abstractInterface.h @@ -0,0 +1,20 @@ +#ifndef OOBE_PLUGIN_INFACE_H +#define OOBE_PLUGIN_INFACE_H + +#include +#include +#include +#include + +class QWidget; +class kyMenuPluginInterface +{ + +public: + virtual ~kyMenuPluginInterface() {} + virtual const QString name() = 0; + virtual const QString description() = 0; + virtual QWidget *createWidget(QWidget *parent) = 0; +}; +Q_DECLARE_INTERFACE(kyMenuPluginInterface, "org.kyMenuPlugin.AbstractInterface") +#endif \ No newline at end of file diff --git a/src/UtilityFunction/fullitemdelegate.cpp b/src/UtilityFunction/fullitemdelegate.cpp deleted file mode 100644 index 2c0c45f..0000000 --- a/src/UtilityFunction/fullitemdelegate.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * 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 - -FullItemDelegate::FullItemDelegate(QObject *parent, int module): - QStyledItemDelegate(parent) -{ - this->module=module; - pUkuiMenuInterface=new UkuiMenuInterface; -} - -FullItemDelegate::~FullItemDelegate() -{ - delete pUkuiMenuInterface; -} - -void FullItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - - if(index.isValid()) - { - QStyleOptionViewItem viewOption(option);//用来在视图中画一个item - QRectF rect; - rect.setX(option.rect.x()); - rect.setY(option.rect.y()); - rect.setWidth(option.rect.width()); - rect.setHeight(option.rect.height()); - - //QPainterPath画圆角矩形 - const qreal radius = 4; - QPainterPath path; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - - painter->setRenderHint(QPainter::Antialiasing); - if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) - { -// QColor color = option.palette.text().color(); -// color.setAlphaF(0.15); - painter->save(); - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(Qt::white); - painter->setOpacity(0.15); - painter->drawPath(path); - painter->restore(); - } - - painter->save(); - painter->setOpacity(1); - QString desktopfp=index.data(Qt::DisplayRole).value(); - QString iconstr=pUkuiMenuInterface->getAppIcon(desktopfp); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) - icon=QIcon(iconstr); - else - { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon=QIcon::fromTheme(iconstr); - if(icon.isNull()) - { - if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - else - icon=QIcon::fromTheme(QString("application-x-desktop")); - } - } - - QString appname=pUkuiMenuInterface->getAppName(desktopfp); - - QRect iconRect; - QRect textRect; - iconRect=QRect(rect.x()+Style::AppLeftSpace , - rect.y()+Style::AppTopSpace, - Style::AppListIconSize, - Style::AppListIconSize); - icon.paint(painter,iconRect); - painter->restore(); - - painter->save(); - bool is_locked=false; - QFileInfo fileInfo(desktopfp); - QString desktopfn=fileInfo.fileName(); - //添加固定图标 - if(module==0) - { - if(checkIfLocked(desktopfn)) - { - is_locked=true; - QIcon icon(QString(":/data/img/mainviewwidget/lock-fs.svg")); - icon.paint(painter,QRect(iconRect.topRight().x()-14,iconRect.topRight().y()-2,16,16)); - } - } - painter->restore(); - - textRect=QRect(rect.x()+5, - iconRect.bottom()+Style::AppSpaceBetweenIconText, - rect.width()-10, - rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText); - - painter->save(); - //添加最近安装蓝色标签 - bool is_recentapp=false; - QFontMetrics fm=painter->fontMetrics(); - QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-10,Qt::TextShowMnemonic); - if(checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) - { - is_recentapp=true; - appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-23,Qt::TextShowMnemonic); - textRect=QRect(rect.x()+18, - iconRect.bottom()+Style::AppSpaceBetweenIconText, - rect.width()-23, - rect.height()-iconRect.height()-Style::AppSpaceBetweenIconText); - - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(QColor("#4d94ff")); - int x=0; - if(rect.width()<(23+fm.boundingRect(appname).width())) - x=rect.x()+9; - else - x=rect.x()+(rect.width()-13-fm.boundingRect(appname).width())/2+4; - - painter->drawEllipse(QPoint(x, - textRect.y()+(fm.boundingRect(appname).height()-8)/2+4), - 4, - 4); - - } - painter->restore(); - - painter->save(); -// painter->setPen(QPen(option.palette.text().color())); - painter->setPen(QPen(Qt::white)); - painter->setBrush(Qt::NoBrush); - painter->drawText(textRect,Qt::AlignHCenter |Qt::AlignTop,appnameElidedText); -// painter->drawText(textRect,Qt::TextWordWrap |Qt::AlignHCenter,appname); - painter->restore(); - - if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) - { - int len=0; - if(!is_locked && is_recentapp) - len=fm.boundingRect(appname).width()+23; - else - len=fm.boundingRect(appname).width()+10; - if(len>rect.width()) - { - QToolTip::showText(QCursor::pos(),appname); - } - else { - QToolTip::hideText(); - } - } - } -} - -QSize FullItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - return QSize(Style::AppListItemSizeWidth, Style::AppListItemSizeWidth); -} diff --git a/src/UtilityFunction/fulllistview.cpp b/src/UtilityFunction/fulllistview.cpp deleted file mode 100644 index b2eb8a6..0000000 --- a/src/UtilityFunction/fulllistview.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - * 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 -#include -#include -#include - -FullListView::FullListView(QWidget *parent, int module): - QListView(parent) -{ - this->module=module; - initWidget(); -// inCurView = false; - pUkuiMenuInterface=new UkuiMenuInterface; -// menu=new RightClickMenu; -} - -FullListView::~FullListView() -{ -// delete menu; - delete pUkuiMenuInterface; -} - -void FullListView::initWidget() -{ - viewport()->setAttribute(Qt::WA_TranslucentBackground); - this->setSelectionMode(QAbstractItemView::SingleSelection); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -// if(module==1 || module==2)s - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setViewMode(QListView::IconMode); - this->setContextMenuPolicy(Qt::CustomContextMenu); - this->setResizeMode(QListView::Adjust); - this->setTextElideMode(Qt::ElideRight); - this->setMouseTracking(true); - // this->setFocusPolicy(Qt::StrongFocus); - this->setMovement(QListView::Static); - this->setEditTriggers(QAbstractItemView::NoEditTriggers); - this->setGridSize(QSize(Style::AppListGridSizeWidth,Style::AppListGridSizeWidth)); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - this->setFrameShape(QFrame::NoFrame);//移除边框 - this->setStyleSheet(QString::fromUtf8("QStandardItemModel#listmodel{border:3px solid #FFFFFF; }QWidget#widget:focus{ border:5px solid #A5A6A1; } ")); - connect(this,&FullListView::customContextMenuRequested,this,&FullListView::rightClickedSlot); - - connect(this,&FullListView::clicked,this,&FullListView::onClicked); - -// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) -// { -// gsetting = new QGSettings(QString("org.ukui.control-center.personalise").toLocal8Bit()); -// if(gsetting->keys().contains(QString("transparency"))) -// transparency = gsetting->get("transparency").toDouble(); -// connect(gsetting,&QGSettings::changed,[this] (const QString &key) -// { -// if (key == "transparency") -// { -// transparency = gsetting->get("transparency").toDouble(); -// } -// }); -// } -} - -void FullListView::addData(QStringList data) -{ - listmodel=new QStandardItemModel(this); - this->setModel(listmodel); - - Q_FOREACH(QString desktopfp,data) - { - QStandardItem* item=new QStandardItem; - item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); - listmodel->appendRow(item); - } - m_delegate= new FullItemDelegate(this,module); - this->setItemDelegate(m_delegate); -} - -void FullListView::focusInEvent(QFocusEvent *event) -{ - //inCurView = true; - return QListView::focusInEvent(event); -} - -void FullListView::focusOutEvent(QFocusEvent *event) -{ - //inCurView = false; - return QListView::focusOutEvent(event); -} - -void FullListView::updateData(QStringList data) -{ - listmodel->clear(); - Q_FOREACH(QString desktopfp,data) - { - QStandardItem* item=new QStandardItem; - item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); - listmodel->appendRow(item); - } -} - -void FullListView::onClicked(QModelIndex index) -{ - QVariant var = listmodel->data(index, Qt::DisplayRole); - if(var.isValid()) - { - QString desktopfp=var.value(); - Q_EMIT sendItemClickedSignal(desktopfp); - - } -} - -void FullListView::rightClickedSlot(const QPoint &pos) -{ - Q_UNUSED(pos) - if(!(this->selectionModel()->selectedIndexes().isEmpty())) - { - QModelIndex index=this->currentIndex(); - QVariant var=listmodel->data(index, Qt::DisplayRole); - QString desktopfp=var.value(); - RightClickMenu menu; - int ret=menu.showAppBtnMenu(this->mapToGlobal(pos), desktopfp); - if(module>0) - { - switch (ret) { - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - default: - break; - } - } - else{ - switch (ret) { - case 1: - Q_EMIT sendUpdateAppListSignal(); - break; - case 2: - Q_EMIT sendUpdateAppListSignal(); - break; - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - default: - break; - } - } - //this->selectionModel()->clear(); - } -} - -void FullListView::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - this->selectionModel()->clear(); - this->verticalScrollBar()->setVisible(true); -} - -void FullListView::leaveEvent(QEvent *e) -{ - Q_UNUSED(e); - this->verticalScrollBar()->setVisible(false); -// QWidget *current_focus_widget; - // current_focus_widget = QApplication::focusWidget(); -// current_focus_widget = QWidget::focusWidget(); -// QPushButton *le= qobject_cast(current_focus_widget); - -} - -void FullListView::selectFirstItem() -{ - qDebug() << "void FullListView::selectFirstItem()"; - if(this->currentIndex().row() == -1) - { - this->setCurrentIndex(this->model()->index(0,0)); - } -} - -void FullListView::paintEvent(QPaintEvent *e) -{ - double transparency=getTransparency(); - QPainter painter(this->viewport()); - -// if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) -// { -// QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); -// if(gsetting.keys().contains(QString("effect"))) -// { -// if(gsetting.get("effect").toBool()) -// { -// painter.setBrush(Qt::black); -// painter.setPen(Qt::transparent); -// painter.setOpacity(0.25); -// painter.drawRect(this->rect()); -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else -// { -// painter.setBrush(this->palette().base()); -// painter.setPen(Qt::transparent); -// painter.setOpacity(transparency); -// painter.drawRect(this->rect()); -// } -// } -// else -// { - painter.setBrush(this->palette().base()); - painter.setPen(Qt::transparent); - painter.setOpacity(transparency); - painter.drawRect(this->rect()); -// } - QListView::paintEvent(e); -} - -void FullListView::keyPressEvent(QKeyEvent* e) -{ - QRect center = visualRect(currentIndex()); - if(e->type() == QEvent::KeyPress) - { - switch(e->key()) - { - case Qt::Key_Enter: - case Qt::Key_Return: - { - QModelIndex index = this->currentIndex(); - Q_EMIT clicked(index); - break; - } - case Qt::Key_Left: - { - this->clearFocus(); - if(mapToGlobal(center.topRight()).y() < Style::QueryLineEditHeight + Style::AppListGridSizeWidth) - { - Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); - } - this->setFocus(); - return QListView::keyPressEvent(e); - break; - } - case Qt::Key_Right: - { - - this->clearFocus(); - if(mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) - { - Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); - } - this->setFocus(); - return QListView::keyPressEvent(e); - break; - } - case Qt::Key_Up: - { - if(module == 0) - { - if(mapToGlobal(center.topRight()).y() < (Style::QueryLineEditHeight + Style::AppListGridSizeWidth)) - { - Q_EMIT sendSetslidebar(-Style::AppListGridSizeWidth); - } - } - return QListView::keyPressEvent(e); - break; - } - case Qt::Key_Down: - { - if(module == 0) - { - if(mapToGlobal(center.bottomRight()).y() > (1080 - Style::AppListGridSizeWidth)) - { - Q_EMIT sendSetslidebar(Style::AppListGridSizeWidth); - } - } - return QListView::keyPressEvent(e); - break; - } - - default: - return QListView::keyPressEvent(e); - break; - } - } -} - -void FullListView::mousePressEvent(QMouseEvent *event) -{ - if(!(this->indexAt(event->pos()).isValid()) && event->button()==Qt::LeftButton) - { - Q_EMIT sendHideMainWindowSignal(); - } - else - { - return QListView::mousePressEvent(event); - } -} diff --git a/src/UtilityFunction/fulllistview.h b/src/UtilityFunction/fulllistview.h deleted file mode 100644 index 1cff017..0000000 --- a/src/UtilityFunction/fulllistview.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 -#include -#include "src/RightClickMenu/rightclickmenu.h" -#include "src/Interface/ukuimenuinterface.h" -#include -#include -#include -#include -#include "fullitemdelegate.h" -#include "src/Style/style.h" - -class FullListView : public QListView -{ - Q_OBJECT -public: - FullListView(QWidget *parent,int module); - ~FullListView(); - - void addData(QStringList data);//字母排序模块添加数据 - void updateData(QStringList data); - -protected: - void initWidget(); - void keyPressEvent(QKeyEvent* e); - void enterEvent(QEvent* e) Q_DECL_OVERRIDE; - void leaveEvent(QEvent* e) Q_DECL_OVERRIDE; - void paintEvent(QPaintEvent *e) override; - void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); - void mousePressEvent(QMouseEvent *event); - -private: - FullItemDelegate* m_delegate=nullptr; - QStandardItemModel* listmodel=nullptr; - int module=0; - double transparency; - RightClickMenu* menu=nullptr;//右键菜单 - QStringList data; - QGSettings* gsetting; - UkuiMenuInterface* pUkuiMenuInterface=nullptr; - -// bool inCurView; - -public Q_SLOTS: - void onClicked(QModelIndex index);//点击item - void rightClickedSlot(const QPoint &pos);//右键菜单 - void selectFirstItem(); - -Q_SIGNALS: - void sendItemClickedSignal(QString arg);//发送item点击信号 - void sendHideMainWindowSignal(); - void sendUpdateAppListSignal(); - void sendSetslidebar(int value); -}; - -#endif // FULLLISTVIEW_H diff --git a/src/UtilityFunction/functionclassifybutton.cpp b/src/UtilityFunction/functionclassifybutton.cpp deleted file mode 100644 index 21ee26a..0000000 --- a/src/UtilityFunction/functionclassifybutton.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/* - * 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 -#include -#include -#include - -FunctionClassifyButton::FunctionClassifyButton(int width, - int height, - int iconSize, - QString category, - bool fullscreen, - bool enabled, - QWidget *parent): - QPushButton (parent), - m_width(width), - m_height(height), - m_iconSize(iconSize), - m_category(category), - m_fullscreen(fullscreen), - m_enabled(enabled), - m_iconLabel(new QLabel), - m_textLabel(new QLabel) -{ - this->setFlat(true); - this->setFixedSize(m_width,m_height); - this->setFocusPolicy(Qt::NoFocus); - m_iconLabel->setFixedSize(m_iconSize,m_iconSize); - m_textLabel->adjustSize(); - if(m_fullscreen) - { - QPalette pe = m_textLabel->palette(); - pe.setColor(QPalette::ButtonText,QColor(Qt::white)); - m_textLabel->setPalette(pe); - } - setLabelText(); - if(m_fullscreen) - { - updateIconState(Normal); - this->setCheckable(true); - } - else - { - if(m_enabled) - updateIconState(Enabled); - else - updateIconState(Disabled); - this->setCheckable(false); - } - - QHBoxLayout* mainlayout=new QHBoxLayout; - mainlayout->setContentsMargins(Style::LeftSpaceIconLeft,0,0,0); - mainlayout->setSpacing(Style::LeftSpaceIconText); - this->setLayout(mainlayout); - mainlayout->addWidget(m_iconLabel); - mainlayout->addWidget(m_textLabel); - connect(this,&FunctionClassifyButton::toggled,this,&FunctionClassifyButton::reactToToggle); - connect(this,&FunctionClassifyButton::clicked,this,&FunctionClassifyButton::buttonClickedSlot); -} - -void FunctionClassifyButton::paintEvent(QPaintEvent* e) -{ - Q_UNUSED(e); - QStylePainter painter(this); - QStyleOptionButton option; - initStyleOption(&option); - if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver)) { - painter.save(); - painter.setPen(Qt::NoPen); - if(!m_fullscreen) - { - QColor color = option.palette.color(QPalette::Text); - color.setAlphaF(0.15); - painter.setBrush(color); - } - else - { - painter.setOpacity(0.15); - painter.setBrush(Qt::white); - } - painter.drawRoundedRect(option.rect, 4, 4); - painter.restore(); - } - if(m_fullscreen && (option.state & QStyle::State_On)) - { - painter.save(); - painter.setPen(Qt::NoPen); -// QColor color = option.palette.color(QPalette::Text); -// color.setAlphaF(0.15); -// painter.setBrush(color); - painter.setOpacity(0.15); - painter.setBrush(Qt::white); - painter.drawRoundedRect(option.rect, 4, 4); - painter.restore(); - } - - QStyleOptionButton subopt = option; - subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); - subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); - painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); - return; -} - -void FunctionClassifyButton::updateBtnState() -{ - if(m_enabled) - updateIconState(Enabled); - else - updateIconState(Disabled); -} - -void FunctionClassifyButton::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - if(m_enabled) - { - updateIconState(Checked); - } -} - -void FunctionClassifyButton::leaveEvent(QEvent *e) -{ - Q_UNUSED(e); - if(m_fullscreen) - { - if(!isChecked()) - updateIconState(Normal); - } - else - { - if(m_enabled) - updateIconState(Enabled); - } -} - -void FunctionClassifyButton::reactToToggle(bool checked) -{ - if(m_fullscreen) - { - if(checked) - updateIconState(Checked); - else - updateIconState(Normal); - } -} - -void FunctionClassifyButton::buttonClickedSlot() -{ - Q_EMIT buttonClicked(); -} - -void FunctionClassifyButton::updateIconState() -{ - this->setFlat(true); - QString picState; - switch (m_state) - { - case Enabled: picState="Enabled"; break; - case Disabled: picState="Disabled"; break; - case Normal: picState="Normal"; break; - case Checked: picState="Checked"; break; - default: break; - } - - const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light")//反黑 - { - pixmap=drawSymbolicBlackColoredPixmap(pixmap); - } - else - { - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - } - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_iconLabel->setPixmap(pixmap); -} - -void FunctionClassifyButton::updateIconState(const FunctionClassifyButton::State state) -{ - if (state == m_state) - return; - m_state = state; - - QString picState; - switch (state) - { - case Enabled: picState="Enabled"; break; - case Disabled: picState="Disabled"; break; - case Normal: picState="Normal"; break; - case Checked: picState="Checked"; break; - default: break; - } - - const auto ratio = devicePixelRatioF(); - QPixmap pixmap = loadSvg(QString(":/data/img/mainviewwidget/%1-%2.svg").arg(m_category).arg(picState), m_iconSize*ratio); - if(!m_fullscreen) - { - QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); - if(gsetting.get("style-name").toString()=="ukui-light")//反黑 - { - pixmap=drawSymbolicBlackColoredPixmap(pixmap); - } - else - { - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - } - } - else - pixmap=drawSymbolicColoredPixmap(pixmap);//反白 - pixmap.setDevicePixelRatio(qApp->devicePixelRatio()); - m_iconLabel->setPixmap(pixmap); - updateTextState(state); -} - -void FunctionClassifyButton::updateTextState(const FunctionClassifyButton::State state) -{ -// QPalette p= m_textLabel->palette(); - switch (state) - { - case Enabled: -// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); -// m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255);"); - break; - case Disabled: -// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.25)); -// m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 25%);"); - break; - case Normal: -// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1, 0.50)); -// m_textLabel->setStyleSheet("background:transparent; color:rgba(255, 255, 255, 50%);"); - break; - case Checked: -// p.setColor(QPalette::WindowText,QColor::fromRgbF(1, 1, 1)); -// m_textLabel->setStyleSheet("background:transparent;color:rgba(255, 255, 255);"); - break; - default: - break; - } -// p.setColor(QPalette::Window,Qt::transparent); -// m_textLabel->setPalette(p); -} - -void FunctionClassifyButton::setLabelText() -{ - QMetaEnum metaEnum=QMetaEnum::fromType(); - switch (metaEnum.keyToValue(m_category.toLocal8Bit().data())) { - case Mobile: - m_textLabel->setText(tr("Mobile")); - break; - case Internet: - m_textLabel->setText(tr("Internet")); - break; - case Social: - m_textLabel->setText(tr("Social")); - break; - case Video: - m_textLabel->setText(tr("Video")); - break; - case Development: - m_textLabel->setText(tr("Development")); - break; - case Image: - m_textLabel->setText(tr("Image")); - break; - case Game: - m_textLabel->setText(tr("Game")); - break; - case Office: - m_textLabel->setText(tr("Office")); - break; - case Education: - m_textLabel->setText(tr("Education")); - break; - case System: - m_textLabel->setText(tr("System")); - break; - default: - m_textLabel->setText(tr("Others")); - break; - } -} diff --git a/src/UtilityFunction/itemdelegate.cpp b/src/UtilityFunction/itemdelegate.cpp deleted file mode 100644 index c031c4a..0000000 --- a/src/UtilityFunction/itemdelegate.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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 -#include -#include -#include "src/UtilityFunction/utility.h" - -ItemDelegate::ItemDelegate(QObject* parent, int module): - QStyledItemDelegate(parent) -{ - this->module=module; - pUkuiMenuInterface=new UkuiMenuInterface; - -} - -ItemDelegate::~ItemDelegate() -{ - delete pUkuiMenuInterface; -} - -void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - if(index.isValid()) - { -// QStyleOptionViewItem viewOption(option);//用来在视图中画一个item - QRectF rect; - rect.setX(option.rect.x()); - rect.setY(option.rect.y()); - rect.setWidth(option.rect.width()); - rect.setHeight(option.rect.height()-2); - - //QPainterPath画圆角矩形 - const qreal radius = 4; - QPainterPath path; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - - QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); - painter->setRenderHint(QPainter::Antialiasing); - if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) - { - QColor color = option.palette.text().color(); - color.setAlphaF(0.15); - painter->save(); - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(color); - painter->drawPath(path); - painter->restore(); - } - painter->setOpacity(1); - - if(module>0) - { - if(strlist.at(1).toInt()==1) - { - QRect iconRect=QRect(rect.x()+11,rect.y()+(rect.height()-32)/2,32,32); - QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0)); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) - icon=QIcon(iconstr); - else - { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon=QIcon::fromTheme(iconstr); - if(icon.isNull()) - { - if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - else - icon=QIcon::fromTheme(QString("application-x-desktop")); - } - } - painter->save(); - icon.paint(painter,iconRect,Qt::AlignLeft); - QString appname=pUkuiMenuInterface->getAppName(strlist.at(0)); - QFontMetrics fm=painter->fontMetrics(); - QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-62,Qt::TextShowMnemonic); - painter->drawText(QRect(iconRect.right()+15,rect.y(), - rect.width()-62,rect.height()),Qt::AlignVCenter,appnameElidedText); - painter->restore(); - painter->save(); - QFileInfo fileInfo(strlist.at(0)); - QString desktopfn=fileInfo.fileName(); - if(checkIfRecent(desktopfn)) - { - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(QColor("#4d94ff")); - painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4); - } - painter->restore(); - - if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) - { - int len=fm.boundingRect(appname).width(); - if(len>rect.width()-62) - { - QToolTip::showText(QCursor::pos(),appname); - } - else { - QToolTip::hideText(); - } - } - } - else - { - //绘制分割线 - painter->save(); -// QRect textRect=QRect(rect.x()+11,rect.y()+12,rect.width(),rect.height()); - QRect textRect=QRect(rect.x()+11,rect.y(),rect.width(),rect.height()); - painter->drawText(textRect,Qt::AlignVCenter,strlist.at(0)); - painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(QPen(QColor(option.palette.text().color()),1)); - painter->setOpacity(0.1); - painter->drawLine(QPoint(5,rect.bottom()),QPoint(rect.right(),rect.bottom())); - painter->restore(); - } - - } - else - { - QRect iconRect=QRect(rect.left()+11,rect.y()+(rect.height()-32)/2,32,32); - QString iconstr=pUkuiMenuInterface->getAppIcon(strlist.at(0)); - QIcon icon; - QFileInfo iconFileInfo(iconstr); - if(iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) - icon=QIcon(iconstr); - else - { - iconstr.remove(".png"); - iconstr.remove(".svg"); - icon=QIcon::fromTheme(iconstr); - if(icon.isNull()) - { - if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); - else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png"))) - icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("png")); - else if(QFile::exists(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg"))) - icon=QIcon(QString("/usr/share/pixmaps/%1.%2").arg(iconstr).arg("svg")); - else - icon=QIcon::fromTheme(QString("application-x-desktop")); - } - } - icon.paint(painter,iconRect,Qt::AlignLeft); - QString appname=pUkuiMenuInterface->getAppName(strlist.at(0)); - QFileInfo fileInfo(strlist.at(0)); - QString desktopfn=fileInfo.fileName(); - if(checkIfLocked(desktopfn)) - { - QIcon icon(QString(":/data/img/mainviewwidget/lock.svg")); - icon.paint(painter,QRect(rect.topRight().x()-22,rect.y()+(rect.height()-16)/2,16,16)); - } - painter->setOpacity(1); - painter->save(); - if(checkIfRecent(desktopfn) && !checkIfLocked(desktopfn)) - { - painter->setPen(QPen(Qt::NoPen)); - painter->setBrush(QColor("#4d94ff")); - painter->drawEllipse(QPoint(rect.topRight().x()-22,rect.y()+(rect.height()-8)/2+4),4,4); - } - painter->restore(); - painter->save(); - painter->setPen(QPen(option.palette.text().color())); - painter->setBrush(Qt::NoBrush); - painter->setOpacity(1); - QFontMetrics fm=painter->fontMetrics(); - QString appnameElidedText=fm.elidedText(appname,Qt::ElideRight,rect.width()-62,Qt::TextShowMnemonic); - painter->drawText(QRect(iconRect.right()+15,rect.y(), - rect.width()-62,rect.height()),Qt::AlignVCenter,appnameElidedText); - painter->restore(); - - if((option.state & QStyle::State_MouseOver) || (option.state & QStyle::State_HasFocus)) - { - int len=fm.boundingRect(appname).width(); - if(len>rect.width()-62) - { - QToolTip::showText(QCursor::pos(),appname); - } - else { - QToolTip::hideText(); - } - } - } - } - -} - -QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ -// QStringList strlist=index.model()->data(index,Qt::DisplayRole).toStringList(); -// if(strlist.at(1).toInt()==1) - return QSize(310,44); -// else -// return QSize(310,48); - -} diff --git a/src/UtilityFunction/letterclassifybutton.cpp b/src/UtilityFunction/letterclassifybutton.cpp deleted file mode 100644 index 62c4ab4..0000000 --- a/src/UtilityFunction/letterclassifybutton.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 -#include - -LetterClassifyButton::LetterClassifyButton(QWidget *parent, - bool fullscreen, - QString letter): - QPushButton(parent), - m_fullscreen(fullscreen) -{ - this->setFlat(true); - if(m_fullscreen) - { - QFont font; - font.setPixelSize(Style::LeftLetterFontSize); - this->setFont(font); - } - this->setText(letter); - this->setFocusPolicy(Qt::NoFocus); - this->setCheckable(true); - connect(this,&LetterClassifyButton::toggled,this,&LetterClassifyButton::reactToToggle); -} - -void LetterClassifyButton::paintEvent(QPaintEvent* e) -{ - QStylePainter painter(this); - QStyleOptionButton option; - initStyleOption(&option); - if ((option.state & QStyle::State_Enabled) && (option.state & QStyle::State_MouseOver || option.state & QStyle::State_HasFocus)) { - painter.save(); - painter.setPen(Qt::NoPen); - if(!m_fullscreen) - { - QColor color = option.palette.color(QPalette::Text); - color.setAlphaF(0.15); - painter.setBrush(color); - } - else - { - painter.setOpacity(0.15); - painter.setBrush(Qt::white); - } - painter.drawRoundedRect(option.rect, 4, 4); - painter.restore(); - } - if(m_fullscreen && (option.state & QStyle::State_On)) - { - painter.save(); - painter.setPen(Qt::NoPen); -// QColor color = option.palette.color(QPalette::Text); -// color.setAlphaF(0.15); -// painter.setBrush(color); - painter.setOpacity(0.15); - painter.setBrush(Qt::white); - painter.drawRoundedRect(option.rect, 4, 4); - painter.restore(); - } - - QStyleOptionButton subopt = option; - subopt.rect = painter.style()->subElementRect(QStyle::SE_PushButtonContents, &option, this); - if(m_fullscreen) - subopt.palette.setBrush(QPalette::ButtonText, QColor(Qt::white)); - else - subopt.palette.setBrush(QPalette::HighlightedText, subopt.palette.text()); - painter.style()->drawControl(QStyle::CE_PushButtonLabel, &subopt, &painter, this); - return; -} - -void LetterClassifyButton::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - if(m_fullscreen) - { - QFont font; - font.setPixelSize(Style::LeftLetterFontSize*3); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - } -} - -void LetterClassifyButton::leaveEvent(QEvent *e) -{ - Q_UNUSED(e); - if(m_fullscreen) - { - QFont font; - font.setPixelSize(Style::LeftLetterFontSize); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight,Style::LeftLetterBtnHeight); - } -} - -void LetterClassifyButton::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - if(m_fullscreen) - { - QFont font; - font.setPixelSize(Style::LeftLetterFontSize*3); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - is_pressed=true; - } -} - -void LetterClassifyButton::focusInEvent(QEvent* e) -{ - Q_UNUSED(e); - if(m_fullscreen) - { - QFont font; - font.setPixelSize(Style::LeftLetterFontSize*3); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - } -} - -void LetterClassifyButton::mouseReleaseEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - if(m_fullscreen) - { - QFont font; - font.setPixelSize(Style::LeftLetterFontSize*3); - this->setFont(font); - this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - } - Q_EMIT buttonClicked(this); -} - -void LetterClassifyButton::reactToToggle(bool checked) -{ - if(checked) - { - this->is_pressed=true; - } - else - { - this->is_pressed=false; - } -} diff --git a/src/UtilityFunction/listview.cpp b/src/UtilityFunction/listview.cpp deleted file mode 100644 index 4fc0850..0000000 --- a/src/UtilityFunction/listview.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* - * 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 -#include - -ListView::ListView(QWidget *parent, int width, int height, int module): - QListView(parent) -{ - this->w=width; - this->h=height; - this->module=module; - initWidget(); - - pUkuiMenuInterface=new UkuiMenuInterface; - menu=new RightClickMenu; -} -ListView::~ListView() -{ - delete menu; - delete pUkuiMenuInterface; -} - -void ListView::initWidget() -{ - setAttribute(Qt::WA_TranslucentBackground); - viewport()->setAttribute(Qt::WA_TranslucentBackground); - this->setSelectionMode(QAbstractItemView::SingleSelection); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setResizeMode(QListView::Adjust); - this->setTextElideMode(Qt::ElideRight); - this->setViewMode(QListView::ListMode); - this->setContextMenuPolicy(Qt::CustomContextMenu); - this->setFocusPolicy(Qt::StrongFocus); - this->setMovement(QListView::Free); - this->setDragEnabled(QListView::Free); - this->setEditTriggers(QAbstractItemView::NoEditTriggers); - this->setUpdatesEnabled(true); - this->setSpacing(0); - this->setContentsMargins(0, 0, 0, 0); - this->setMouseTracking(true); - this->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); - this->setFrameShape(QFrame::NoFrame); - this->verticalScrollBar()->setProperty("drawScrollBarGroove",false); - this->setFocus(); - connect(this,&ListView::customContextMenuRequested,this,&ListView::rightClickedSlot); - connect(this,&ListView::clicked,this,&ListView::onClicked); -} - -void ListView::addData(QVector data) -{ - listmodel=new QStandardItemModel(this); - this->setModel(listmodel); - Q_FOREACH(QStringList desktopfp,data) - { - QStandardItem* item=new QStandardItem; - item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); - listmodel->appendRow(item); - } - m_delegate= new ItemDelegate(this,module); - this->setItemDelegate(m_delegate); -} - -void ListView::updateData(QVector data) -{ - listmodel->clear(); - Q_FOREACH(QStringList desktopfp,data) - { - QStandardItem* item=new QStandardItem; - item->setData(QVariant::fromValue(desktopfp),Qt::DisplayRole); - listmodel->appendRow(item); - } -// Q_EMIT dataChanged(createIndex(0,0), createIndex(listmodel->rowCount()-1,0)); -} - -void ListView::onClicked(QModelIndex index) -{ - QVariant var = listmodel->data(index, Qt::DisplayRole); - if(var.isValid()) - { - Q_EMIT sendItemClickedSignal(var.value()); - } -} - -void ListView::rightClickedSlot(const QPoint &pos) -{ - if(!this->selectionModel()->selectedIndexes().isEmpty()) - { - QModelIndex index=this->currentIndex(); -// QRect center = visualRect(index); - QVariant var=listmodel->data(index, Qt::DisplayRole); - QStringList strlist=var.value(); - if(strlist.at(1).toInt()==1) - { - int ret = menu->showAppBtnMenu(this->mapToGlobal(pos), strlist.at(0)); - if(module>0) - { - if(strlist.at(1).toInt()==1) - { - switch (ret) { - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - default: - break; - } - } - } - else{ - switch (ret) { - case 1: - Q_EMIT sendUpdateAppListSignal(); - break; - case 2: - Q_EMIT sendUpdateAppListSignal(); - break; - case 6: - Q_EMIT sendHideMainWindowSignal(); - break; - case 7: - Q_EMIT sendHideMainWindowSignal(); - break; - default: - break; - } - } - - // this->selectionModel()->clear(); - } - } -} - -void ListView::dragMoveEvent(QDragMoveEvent *e) -{ - Q_UNUSED(e); -} - -void ListView::dropEvent(QDropEvent *e) -{ - Q_UNUSED(e); -} - -void ListView::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - this->selectionModel()->clear(); - this->verticalScrollBar()->setVisible(true); -} - -void ListView::leaveEvent(QEvent *e) -{ - Q_UNUSED(e); - this->verticalScrollBar()->setVisible(false); -} - -void ListView::paintEvent(QPaintEvent *e) -{ - double transparency=getTransparency(); - QPainter painter(this->viewport()); - painter.setOpacity(transparency); - painter.setPen(Qt::NoPen); - painter.setBrush(this->palette().base()); - painter.fillRect(this->rect(), this->palette().base()); - - //滚动条 - QPalette p=this->verticalScrollBar()->palette(); - QColor color(255, 255, 255); -// QColor color=p.color(QPalette::Active,QPalette::Button); - color.setAlphaF(0.25); - p.setColor(QPalette::Active,QPalette::Button,color); - this->verticalScrollBar()->setPalette(p); - QListView::paintEvent(e); -} - -void ListView::dragLeaveEvent(QDragLeaveEvent *e) -{ - QVariant pressApp = listmodel->data(this->indexAt(startPos), Qt::DisplayRole); - QStringList m_desktopfp = pressApp.value(); - QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - QFileInfo fileInfo(m_desktopfp.at(0)); - QString desktopfn=fileInfo.fileName(); - QFile file(m_desktopfp.at(0)); - QString newname=QString(path+"/"+desktopfn); - bool ret=file.copy(QString(path+"/"+desktopfn)); - if(ret) - { - char command[200]; - sprintf(command,"chmod a+x %s",newname.toLocal8Bit().data()); - QProcess::startDetached(QString::fromLocal8Bit(command)); - } -} - -void ListView::mousePressEvent(QMouseEvent *event) -{ - startPos = event->pos(); - return QListView::mousePressEvent(event); -} - -void ListView::keyPressEvent(QKeyEvent* e) -{ - if(e->type()==QEvent::KeyPress) - { - switch(e->key()) - { - case Qt::Key_Enter: - case Qt::Key_Return: - { - QModelIndex index=this->currentIndex(); - Q_EMIT clicked(index); - } - break; - case Qt::Key_Down: - { - if(currentIndex().row() == this->model()->rowCount() - 1) - { - setCurrentIndex(this->model()->index(0,0)); - break; - } - return QListView::keyPressEvent(e); - break; - } - case Qt::Key_Up: - { - if(currentIndex().row() == 0) - { - setCurrentIndex(this->model()->index(this->model()->rowCount()-1,0)); - break; - } - return QListView::keyPressEvent(e); - break; - } - default: - return QListView::keyPressEvent(e); - break; - } - } -} diff --git a/src/UtilityFunction/proxystyle.cpp b/src/UtilityFunction/proxystyle.cpp deleted file mode 100644 index 1ccd581..0000000 --- a/src/UtilityFunction/proxystyle.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "proxystyle.h" -#include -#include - -ProxyStyle::ProxyStyle() -{ - if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); - connect(gsetting,&QGSettings::changed,this,[=]{ - for(auto widget: QApplication::allWidgets()) - { - widget->update(); - } - }); - } -} - -QPalette ProxyStyle::standardPalette() const -{ - auto m_palette=QProxyStyle::standardPalette(); - QColor m_highlightbg; - if(QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) - { - QGSettings* gsetting=new QGSettings(QString("org.ukui.style").toLocal8Bit()); - if(gsetting->keys().contains(QString("styleName"))) - { - if(gsetting->get("style-name").toString()=="ukui-light") - { - m_highlightbg=QColor(0, 0, 0); - m_highlightbg.setAlphaF(0.15); - } - else - { - m_highlightbg=QColor(255,255,255); - m_highlightbg.setAlphaF(0.14); - } - } - m_palette.setBrush(QPalette::Highlight,m_highlightbg); - return m_palette; - } - return m_palette; -} - -void ProxyStyle::polish(QPalette &pal) -{ - pal=standardPalette(); -// QProxyStyle::polish(pal); -} diff --git a/src/UtilityFunction/proxystyle.h b/src/UtilityFunction/proxystyle.h deleted file mode 100644 index 397e74a..0000000 --- a/src/UtilityFunction/proxystyle.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef INTERNALSTYLE_H -#define INTERNALSTYLE_H -#include -#include -#include -#include -#include -#include - -class ProxyStyle : public QProxyStyle -{ - Q_OBJECT -public: - ProxyStyle(); - -// void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; -// void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const; -// void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const; - void polish(QPalette &pal); -// void polish(QWidget *widget); - QPalette standardPalette() const; - -private: - double transparency; - -}; - -#endif // INTERNALSTYLE_H diff --git a/src/UtilityFunction/softwaredatabaseupdatethread.h b/src/UtilityFunction/softwaredatabaseupdatethread.h deleted file mode 100644 index 44b460d..0000000 --- a/src/UtilityFunction/softwaredatabaseupdatethread.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SOFTWAREDATABASEUPDATETHREAD_H -#define SOFTWAREDATABASEUPDATETHREAD_H - -#include -#include -#include -#include -#include -#include -#include - -class SoftwareDatabaseUpdateThread: public QThread -{ - Q_OBJECT -public: - SoftwareDatabaseUpdateThread(QObject *parent = nullptr); - ~SoftwareDatabaseUpdateThread(); - void run(); - void getDatabaseList(QString category); -Q_SIGNALS: - void updateDatabaseSignal(); - -private: - QString m_category; -}; - -#endif // SOFTWAREDATABASEUPDATETHREAD_H diff --git a/src/UtilityFunction/splitbarframe.cpp b/src/UtilityFunction/splitbarframe.cpp deleted file mode 100644 index 6a9b517..0000000 --- a/src/UtilityFunction/splitbarframe.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 setFixedSize(m_width,m_height); -// this->setStyleSheet("background:transparent"); - //按钮透明 - this->setFocusPolicy(Qt::NoFocus); - this->setAttribute(Qt::WA_TranslucentBackground); - QHBoxLayout* layout=new QHBoxLayout; - layout->setContentsMargins(15,0,0,0); - layout->setSpacing(6); - - m_textLabel->setAutoFillBackground(false); - m_textLabel->setAlignment(Qt::AlignCenter); - if(m_module==1) - m_textLabel->setText(m_category); - else - setLabelText(); - m_textLabel->adjustSize(); - QPalette pe=m_textLabel->palette(); - pe.setColor(QPalette::WindowText,Qt::white); - m_textLabel->setPalette(pe); - m_line->setFrameShape(QFrame::HLine); - m_line->setFixedHeight(1); - m_line->setFixedSize(m_width-m_textLabel->width()-15,1); - m_line->setEnabled(false); - QPalette linePe=m_line->palette(); - QColor color(255,255,255); - color.setAlphaF(0.10); - linePe.setColor(QPalette::WindowText,color); - m_line->setPalette(linePe); - - this->setLayout(layout); - layout->addWidget(m_textLabel); - layout->addWidget(m_line); -} - -void SplitBarFrame::setLabelText() -{ - QMetaEnum metaEnum=QMetaEnum::fromType(); - switch (metaEnum.keyToValue(m_category.toLocal8Bit().data())) - { - case Mobile: - m_textLabel->setText(tr("Mobile")); - break; - case Internet: - m_textLabel->setText(tr("Internet")); - break; - case Social: - m_textLabel->setText(tr("Social")); - break; - case Video: - m_textLabel->setText(tr("Video")); - break; - case Development: - m_textLabel->setText(tr("Development")); - break; - case Image: - m_textLabel->setText(tr("Image")); - break; - case Game: - m_textLabel->setText(tr("Game")); - break; - case Office: - m_textLabel->setText(tr("Office")); - break; - case Education: - m_textLabel->setText(tr("Education")); - break; - case System: - m_textLabel->setText(tr("System")); - break; - default: - m_textLabel->setText(tr("Others")); - break; - } -} diff --git a/src/UtilityFunction/thumbnail.cpp b/src/UtilityFunction/thumbnail.cpp new file mode 100755 index 0000000..55a1f79 --- /dev/null +++ b/src/UtilityFunction/thumbnail.cpp @@ -0,0 +1,244 @@ +#include "thumbnail.h" +#include +#include "style.h" +#include +#include +#include +#include + +ThumbNail::ThumbNail(QWidget *parent): + QWidget(parent) +{ + pUkuiMenuInterface = new UkuiMenuInterface; + initUi(); + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.ini"; + setting = new QSettings(path, QSettings::IniFormat); + QString pathini = QDir::homePath() + "/.cache/ukui-menu/ukui-menu.ini"; + disableSetting = new QSettings(pathini, QSettings::IniFormat); +} + +void ThumbNail::initUi() +{ + setWindowFlags(Qt::FramelessWindowHint); + setAttribute(Qt::WA_TranslucentBackground); + this->setStyleSheet("border:0px;background:transparent;"); + this->setFixedSize(Style::AppListIconSize, Style::AppListIconSize); + iconLabel = new QLabel(this); + iconLabel->setStyleSheet("border:0px;background-color:transparent;"); + iconLabel->setFocusPolicy(Qt::NoFocus); + iconLabel->setFixedSize(Style::AppListIconSize, Style::AppListIconSize); + layout = new QVBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->addWidget(iconLabel); +} + +ThumbNail::~ThumbNail() +{ + if (pUkuiMenuInterface) { + delete pUkuiMenuInterface; + } + + if (setting) { + delete setting; + } + + if (disableSetting) { + delete disableSetting; + } + + if (iconLabel) { + delete iconLabel; + } + + if (m_icon) { + delete m_icon; + } + + pUkuiMenuInterface = nullptr; + setting = nullptr; + disableSetting = nullptr; + iconLabel = nullptr; + + if (layout) { + delete layout; + } +} + +void ThumbNail::setupthumbnail(QString desktopfp) +{ + QString fn = desktopfp.split('/').last(); + setting->beginGroup("groupname"); + QStringList keyList = setting->allKeys(); + bool isgroup = setting->contains(fn); + + if (!isgroup) { + QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); + QString appname = pUkuiMenuInterface->getAppName(desktopfp); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + // QPixmap pixmap = icon.pixmap((Style::AppListIconSize,Style::AppListIconSize),QIcon::Selected,QIcon::Off); + QPixmap pixmap ; + + if (appDisable(desktopfp) == 1) { + pixmap = icon.pixmap((Style::AppListIconSize, Style::AppListIconSize), QIcon::Disabled, QIcon::Off); + //qDebug()<<"appDisable(desktopfp)"<setPixmap(pixmap); + } else { + int k = 0; + iconLabel->setStyleSheet("border:0px;background: rgba(0, 0, 0, 0.25);border-radius: 16px;"); + QGridLayout *iconLayout = new QGridLayout(); + iconLayout->setContentsMargins(0, 0, 0, 0); + iconLayout->setSpacing(0); + iconLabel->setLayout(iconLayout); + + for (int i = 0; i < 3; i++) { + for (int j = 1; j < 4; j++) { + if (k < keyList.size()) { + QString fp; + + if (UkuiMenuInterface::androidDesktopfnList.contains(keyList.at(k))) { + fp = QString(QDir::homePath() + "/.local/share/applications/" + keyList.at(i)); + } else { + fp = "/usr/share/applications/" + keyList.at(k); + } + + m_icon = new QLabel; + m_icon->setFixedSize(28, 28); + QPixmap pixmap = getIcon(fp, 28, 28); + // QPixmap pixmap = icon.pixmap((28,28),QIcon::Selected,QIcon::Off); + m_icon->setPixmap(pixmap); + iconLayout->addWidget(m_icon, i, j - 1); + k = k + 1; + } else { + break; + } + } + } + } +} + +QPixmap ThumbNail::getIcon(QString desktopfp, int width, int height) +{ + QString iconstr = pUkuiMenuInterface->getAppIcon(desktopfp); + QIcon icon; + QFileInfo iconFileInfo(iconstr); + + if (iconFileInfo.isFile() && (iconstr.endsWith(".png") || iconstr.endsWith(".svg"))) { + icon = QIcon(iconstr); + } else { + iconstr.remove(".png"); + iconstr.remove(".svg"); + icon = QIcon::fromTheme(iconstr); + + if (icon.isNull()) { + if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/scalable/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/96x96/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/64x64/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/48x48/apps/%1.%2").arg(iconstr).arg("svg")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("png")); + } else if (QFile::exists(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg"))) { + icon = QIcon(QString("/usr/share/icons/hicolor/32x32/apps/%1.%2").arg(iconstr).arg("svg")); + } else { + icon = QIcon::fromTheme(QString("application-x-desktop")); + } + } + } + + if (appDisable(desktopfp) == 1) { + //return icon.pixmap((width,height),QIcon::Selected,QIcon::Off); + return icon.pixmap((width, height), QIcon::Disabled, QIcon::Off); + } + + return icon.pixmap((width, height), QIcon::Selected, QIcon::Off); +} + +bool ThumbNail::appDisable(QString desktopfp)//判断是否是禁用应用(这个还有问题暂时不会用) +{ + QString str; + //打开文件.desktop + GError **error = nullptr; + GKeyFileFlags flags = G_KEY_FILE_NONE; + GKeyFile *keyfile = g_key_file_new(); + QByteArray fpbyte = desktopfp.toLocal8Bit(); + char *filepath = fpbyte.data(); + g_key_file_load_from_file(keyfile, filepath, flags, error); + char *name = g_key_file_get_locale_string(keyfile, "Desktop Entry", "Exec", nullptr, nullptr); + //取出value值 + QString execnamestr = QString::fromLocal8Bit(name); + //处理value值 + str = execnamestr; + // str = execnamestr.section(' ', 0, 0); + // QStringList list = str.split('/'); + // str = list[list.size()-1]; + //关闭文件 + g_key_file_free(keyfile); + QString desktopfp1 =/*"application/"+*/str; + //QString group=desktopfp.split('/').last(); + disableSetting->beginGroup("application"); + //判断 + bool bo = disableSetting->contains(desktopfp1.toLocal8Bit().data()); // iskey + bool bo1 = disableSetting->QSettings::value(desktopfp1.toLocal8Bit().data()).toBool(); //isvalue + disableSetting->endGroup(); + + //qDebug()< +#include +#include +#include "ukuimenuinterface.h" +#define TEXT_LENGTH 100 //文字长度 + +class ThumbNail : public QWidget +{ + Q_OBJECT +public: + ThumbNail(QWidget *parent = nullptr); + ~ThumbNail(); + void setupthumbnail(QString desktopfp); + QPixmap getIcon(QString desktopfp, int width, int height); + bool appDisable(QString desktopfp); + +private: + QLabel *iconLabel = nullptr; + QVBoxLayout *layout = nullptr; + QLabel *m_icon = nullptr; + QLabel *textLabel = nullptr; + UkuiMenuInterface *pUkuiMenuInterface = nullptr; + QString appIcon = nullptr; + QSettings *setting = nullptr; + QSettings *disableSetting = nullptr; + +private: + void initUi(); +}; + +#endif // THUMBNAIL_H diff --git a/src/UtilityFunction/toolbutton.cpp b/src/UtilityFunction/toolbutton.cpp deleted file mode 100644 index a0824ab..0000000 --- a/src/UtilityFunction/toolbutton.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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 - -ToolButton::ToolButton(int width, - int height, - QString iconstr, - QString piconstr, - QString hoverbg, - QString pressedbg, - int module, - QString text) -{ - this->setFixedSize(width,height); - this->iconstr=iconstr; - this->piconstr=piconstr; - this->hoverbg=hoverbg; - this->pressedbg=pressedbg; - this->module=module; - this->text=text; - - this->setFocusPolicy(Qt::StrongFocus); - svgRender=new QSvgRenderer(this); - svgRender->load(iconstr); - if(module==1) - pixmap=new QPixmap(14,14); - else if(module==2) - pixmap=new QPixmap(19,19); - else - pixmap=new QPixmap(9,9); - pixmap->fill(Qt::transparent); - QPainter p(pixmap); - svgRender->render(&p); - this->setIcon(QIcon(*pixmap)); - - if(module==2) - { - this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - this->setText(tr(text.toLocal8Bit().data())); -// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); - } -// else -// this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); -} - -void ToolButton::enterEvent(QEvent *e) -{ - Q_UNUSED(e); - QByteArray byte=hoverbg.toLocal8Bit(); - char* hover=byte.data(); - char style[100]; - if(module==2) - sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",hover); - else - sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); -// this->setStyleSheet(QString::fromLocal8Bit(style)); - delete svgRender; - svgRender=new QSvgRenderer(this); - svgRender->load(piconstr); - if(module==1) - pixmap=new QPixmap(14,14); - else if(module==2) - pixmap=new QPixmap(19,19); - else - pixmap=new QPixmap(9,9); - pixmap->fill(Qt::transparent); - QPainter p(pixmap); - svgRender->render(&p); - this->setIcon(QIcon(*pixmap)); -} - -void ToolButton::leaveEvent(QEvent *e) -{ - Q_UNUSED(e); -// if(module==2) -// { -// if(!is_pressed) -// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255, 50%);font-size:14px;"); -// else -// this->setStyleSheet("border:0px;padding-left:16px;background:transparent;color:rgba(255, 255, 255);font-size:14px;"); -// } -// else -// this->setStyleSheet("border:0px;padding-left:0px;background:transparent;"); - delete svgRender; - svgRender=new QSvgRenderer(this); - if(module==2 && is_pressed) - svgRender->load(piconstr); - else - svgRender->load(iconstr); - if(module==1) - pixmap=new QPixmap(14,14); - else if(module==2) - pixmap=new QPixmap(19,19); - else - pixmap=new QPixmap(9,9); - pixmap->fill(Qt::transparent); - QPainter p(pixmap); - svgRender->render(&p); - this->setIcon(QIcon(*pixmap)); -} - -void ToolButton::mousePressEvent(QMouseEvent *event) -{ - QByteArray byte=pressedbg.toLocal8Bit(); - char* pressed=byte.data(); - char style[100]; - if(module==2) - sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",pressed); - else - sprintf(style,"border:0px;padding-left:0px;background-color:%s;",pressed); - if(event->button()==Qt::LeftButton) - { -// this->setStyleSheet(QString::fromLocal8Bit(style)); - delete svgRender; - svgRender=new QSvgRenderer(this); - svgRender->load(piconstr); - if(module==1) - pixmap=new QPixmap(14,14); - else if(module==2) - pixmap=new QPixmap(19,19); - else - pixmap=new QPixmap(9,9); - pixmap->fill(Qt::transparent); - QPainter p(pixmap); - svgRender->render(&p); - this->setIcon(QIcon(*pixmap)); - - is_pressed=true; - } -} - -void ToolButton::mouseReleaseEvent(QMouseEvent *event) -{ - QByteArray byte=hoverbg.toLocal8Bit(); - char* hover=byte.data(); - char style[100]; - if(module==2) - sprintf(style,"border:0px;padding-left:16px;background-color:%s;color:#ffffff;font-size:14px;",hover); - else - sprintf(style,"border:0px;padding-left:0px;background-color:%s;",hover); - if(event->button()==Qt::LeftButton) - { -// this->setStyleSheet(QString::fromLocal8Bit(style)); - delete svgRender; - svgRender=new QSvgRenderer(this); - svgRender->load(piconstr); - if(module==1) - pixmap=new QPixmap(14,14); - else if(module==2) - pixmap=new QPixmap(19,19); - else - pixmap=new QPixmap(9,9); - pixmap->fill(Qt::transparent); - QPainter p(pixmap); - svgRender->render(&p); - this->setIcon(QIcon(*pixmap)); - if(module==2) - Q_EMIT buttonClicked(this); - else - Q_EMIT clicked(); - } -} - - - diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp old mode 100644 new mode 100755 index d01f6af..40c6f08 --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -27,63 +27,69 @@ #include #include #include +#include +#include "ukuimenuinterface.h" #define DATABASENAME QDir::homePath()+"/.config/ukui/"+"UkuiMenu.db" +QString g_projectCodeName = "V10SP1"; +QString g_subProjectCodeName = ""; +QString g_platform = ""; +bool g_menuStatus = false; +QString g_curStyle = ""; const QPixmap loadSvg(const QString &fileName, const int size) { QPixmap pixmap(size, size); QSvgRenderer renderer(fileName); pixmap.fill(Qt::transparent); - QPainter painter; painter.begin(&pixmap); renderer.render(&painter); painter.end(); - return pixmap; } QPixmap drawSymbolicColoredPixmap(const QPixmap &source) { - QColor gray(128,128,128); - QColor standard (31,32,34); + QColor gray(128, 128, 128); + QColor standard(31, 32, 34); QImage img = source.toImage(); + for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); + if (color.alpha() > 0) { - if (qAbs(color.red()-gray.red())<20 && qAbs(color.green()-gray.green())<20 && qAbs(color.blue()-gray.blue())<20) { + if (qAbs(color.red() - gray.red()) < 20 && qAbs(color.green() - gray.green()) < 20 && qAbs(color.blue() - gray.blue()) < 20) { color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); - } - else if(qAbs(color.red()-standard.red())<20 && qAbs(color.green()-standard.green())<20 && qAbs(color.blue()-standard.blue())<20) - { + } else if (qAbs(color.red() - standard.red()) < 20 && qAbs(color.green() - standard.green()) < 20 && qAbs(color.blue() - standard.blue()) < 20) { color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); - } - else - { + } else { img.setPixelColor(x, y, color); } } } } + return QPixmap::fromImage(img); } QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) { QImage img = source.toImage(); + for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); + if (color.alpha() > 0) { - if (qAbs(color.red())>=200 && qAbs(color.green())>=200 && qAbs(color.blue())>=200) { + if (qAbs(color.red()) >= 200 && qAbs(color.green()) >= 200 && qAbs(color.blue()) >= 200) { color.setRed(56); color.setGreen(56); color.setBlue(56); @@ -92,32 +98,126 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source) } } } + return QPixmap::fromImage(img); } +QIcon getCurIcon(const QString &iconPath, bool autoSet) +{ + QPixmap pixmap; + + if (iconPath.endsWith("png")) { + pixmap = QPixmap(iconPath); + } else { + pixmap = loadSvg(iconPath, 16); + } + + if (!autoSet) { + return drawSymbolicColoredPixmap(pixmap); + } + + if (QGSettings::isSchemaInstalled(QString("org.ukui.style").toLocal8Bit())) { + QGSettings gsetting(QString("org.ukui.style").toLocal8Bit()); + + if (gsetting.keys().contains(QString("styleName"))) { + if (gsetting.get("style-name").toString() == "ukui-light" + || gsetting.get("style-name").toString() == "ukui-default") { + pixmap = drawSymbolicBlackColoredPixmap(pixmap); + } else { + pixmap = drawSymbolicColoredPixmap(pixmap); + } + } + } + + return QIcon(pixmap); +} + +//不通过任务栏获取屏幕可用区域数据 +QVariantList getScreenGeometryList() +{ + QRect rect; + rect = qApp->primaryScreen()->geometry(); + int panelSize = 0; + int position = 0; + QVariantList list; + list.clear(); + QDBusInterface iface(DBUS_NAME, + DBUS_PATH, + DBUS_INTERFACE, + QDBusConnection::sessionBus()); + QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); + + if (reply.isValid()) { + panelSize = reply.value().at(4).toInt(); + position = reply.value().at(5).toInt(); + } + + QList posIndex; + + switch (position) { + case BOTTOM: + posIndex = {0, 0, 0, -1}; + break; + case TOP: + posIndex = {0, 1, 0, -1}; + break; + case LEFT: + posIndex = {1, 0, -1, 0}; + break; + case RIGHT: + posIndex = {0, 0, -1, 0}; + } + + list.append(rect.x() + posIndex[0] * panelSize); + list.append(rect.y() + posIndex[1] * panelSize); + list.append(rect.width() + posIndex[2] * panelSize); + list.append(rect.height() + posIndex[3] * panelSize); + list.append(panelSize); + list.append(position); + return list; +} + double getTransparency() { - double transparency=0.0; - if(QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) - { + double transparency = 0.0; + + if (QGSettings::isSchemaInstalled(QString("org.ukui.control-center.personalise").toLocal8Bit())) { QGSettings gsetting(QString("org.ukui.control-center.personalise").toLocal8Bit()); - if(gsetting.keys().contains(QString("transparency"))) - transparency=gsetting.get("transparency").toDouble(); + + if (gsetting.keys().contains(QString("transparency"))) { + transparency = gsetting.get("transparency").toDouble(); + } } + return transparency; } +void centerToScreen(QWidget *widget) +{ + if (!widget) { + return; + } + + QDesktopWidget *deskTopWidget = QApplication::desktop(); + QRect deskRect = deskTopWidget->screenGeometry(deskTopWidget->screenNumber(QCursor::pos())); + int deskWidth = deskRect.width(); + int deskHeight = deskRect.height(); + int x = QApplication::primaryScreen()->geometry().width(); + int y = QApplication::primaryScreen()->geometry().height(); + widget->move(deskWidth / 2 - x / 2 + deskRect.left(), deskHeight / 2 - y / 2 + deskRect.top()); +} + void debugLog(QString strMsg) { - QString path=QDir::homePath()+"/.config/ukui/ukui-menu.log"; + QString path = QDir::homePath() + "/.config/ukui/ukui-menu.log"; QFile confFile(path); - if(confFile.open(QIODevice::Text | QIODevice::ReadWrite | QIODevice::Append)) - { - QString text=QString("%1 %2") - .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")) - .arg(strMsg); + + if (confFile.open(QIODevice::Text | QIODevice::ReadWrite | QIODevice::Append)) { + QString text = QString("%1 %2") + .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")) + .arg(strMsg); QTextStream textStream(&confFile); - textStream< list=file.readLine().split('\x00'); - Q_FOREACH(QByteArray array, list) - { - if(array.contains("GIO_LAUNCHED_DESKTOP_FILE=")) - { - ret=QString(array.split('=').at(1)); + + if (file.open(QIODevice::ReadOnly)) { + QList list = file.readLine().split('\x00'); + + Q_FOREACH (QByteArray array, list) { + if (array.contains("GIO_LAUNCHED_DESKTOP_FILE=")) { + ret = QString(array.split('=').at(1)); break; } } + file.close(); } - return ret; + return ret; } void openDataBase(QString connectionName) @@ -152,15 +252,14 @@ void openDataBase(QString connectionName) db = QSqlDatabase::addDatabase("QSQLITE", connectionName); db.setDatabaseName(DATABASENAME); - if (false == db.open()) - { + if (false == db.open()) { qDebug() << db.lastError().text(); } } void closeDataBase(QString connectionName) { - QSqlDatabase db=QSqlDatabase::database("connectionName"); + QSqlDatabase db = QSqlDatabase::database(connectionName); db.close(); QSqlDatabase::removeDatabase(connectionName); } @@ -169,331 +268,537 @@ void initDatabase() { QStringList desktopfnList; desktopfnList.clear(); - QSqlDatabase db = QSqlDatabase::database("MainThread"); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); QSqlQuery sql(db); sql.exec("select count(*) from sqlite_master where type='table' and name='appInfo'"); - if(sql.next()) - { - if(sql.value(0).toInt()==0) - { - QSettings* setting=new QSettings("/var/lib/ukui-menu/ukui-menu.ini",QSettings::IniFormat); + + if (sql.next()) { + if (sql.value(0).toInt() == 0) { + QSettings *setting = new QSettings("/var/lib/ukui-menu/ukui-menu.ini", QSettings::IniFormat); setting->beginGroup("application"); QString desktopfp; - Q_FOREACH(QString desktopfn, setting->allKeys()) - { - if(setting->value(desktopfn).toInt()==1) - { + + Q_FOREACH (QString desktopfn, setting->allKeys()) { + if (setting->value(desktopfn).toInt() == 1) { desktopfp.clear(); - if(UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) - desktopfp=QString(QDir::homePath()+"/.local/share/applications/"+desktopfn); - else - desktopfp=QString("/usr/share/applications/"+desktopfn); + + if (UkuiMenuInterface::androidDesktopfnList.contains(desktopfn)) { + desktopfp = QString(QDir::homePath() + "/.local/share/applications/" + desktopfn); + } else { + desktopfp = QString("/usr/share/applications/" + desktopfn); + } + QFileInfo info(desktopfp); - if(!info.isFile() || !UkuiMenuInterface::desktopfpVector.contains(desktopfp)) + + if (!info.isFile() || !UkuiMenuInterface::desktopfpVector.contains(desktopfp)) { continue; + } + desktopfnList.append(desktopfn); } } + setting->endGroup(); delete setting; } } - sql.exec("create table if not exists appInfo(desktop char primary key, times int, time int, type int, recent int)"); - Q_FOREACH(QString desktopfn,desktopfnList) - { - QDateTime dt=QDateTime::currentDateTime(); - int datetime=dt.toTime_t(); - QString cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(0) - .arg(datetime) - .arg(1) - .arg(0); - sql.exec(cmd); + + bool b = sql.exec("create table if not exists appInfo(desktop char primary key, times int, time int, type int, recent int, num int, collect int)"); + + Q_FOREACH (QString desktopfn, desktopfnList) { + myDebug() << "void initDatabase()" << desktopfn; + QDateTime dt = QDateTime::currentDateTime(); + int datetime = dt.toTime_t(); + QString cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") + .arg(desktopfn) + .arg(0) + .arg(datetime) + .arg(1) + .arg(0) + .arg(0) + .arg(0); + bool a = sql.exec(cmd); + myDebug() << "数据库执行是否成功" << a; } + + sql.exec("create table appCategory(app_name char primary key, name_en char, name_zh char)"); + sql.exec("insert into appCategory values('indicator-china-weather', '其他', 'others')"); + sql.exec("insert into appCategory values('peony', '其他', 'others')"); + sql.exec("insert into appCategory values('kylin-usb-creator', '其他', 'others')"); + sql.exec("insert into appCategory values('kylin-burner', '其他', 'others')"); + sql.exec("insert into appCategory values('sc-reader', '办公', 'office')"); + sql.exec("insert into appCategory values('kylin-scanner', '办公', 'office')"); + sql.exec("insert into appCategory values('onboard', '系统', 'system')"); + sql.exec("insert into appCategory values('evolution', '系统', 'system')"); + sql.exec("insert into appCategory values('kylin-screenshot', '系统', 'system')"); + sql.exec("insert into appCategory values('kylin-ipmsg', '网络', 'network')"); + sql.exec("insert into appCategory values('ksc-defender', '安全', 'safe')"); + sql.exec("insert into appCategory values('yhkylin-backup-tools', '安全', 'safe')"); + sql.exec("insert into appCategory values('box-manager', '安全', 'safe')"); + sql.exec("insert into appCategory values('ukui-system-monitor', '安全', 'safe')"); } bool updateDataBaseTableTimes(QString desktopfn) { - bool ret=false; - QSqlDatabase db = QSqlDatabase::database("MainThread"); + bool ret = false; + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); QSqlQuery sql(db); QString cmd; - cmd=QString("select times from appInfo where desktop=\"%1\"").arg(desktopfn); - if(sql.exec(cmd)) - { - QDateTime dt=QDateTime::currentDateTime(); - int datetime=dt.toTime_t(); - if(sql.next()) - { - int times=sql.value(0).toInt()+1; - cmd=QString("update appInfo set times=%1, time=%2, recent=%3 where desktop=\"%4\"") - .arg(times) - .arg(datetime) - .arg(0) - .arg(desktopfn); + cmd = QString("select times from appInfo where desktop=\"%1\"").arg(desktopfn); + + if (sql.exec(cmd)) { + QDateTime dt = QDateTime::currentDateTime(); + int datetime = dt.toTime_t(); + + if (sql.next()) { + int times = sql.value(0).toInt() + 1; + cmd = QString("update appInfo set times=%1, time=%2, recent=%3 where desktop=\"%4\"") + .arg(times) + .arg(datetime) + .arg(0) + .arg(desktopfn); + } else { + cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") + .arg(desktopfn) + .arg(1) + .arg(datetime) + .arg(0) + .arg(0) + .arg(0) + .arg(0); } - else - { - cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(1) - .arg(datetime) - .arg(0) - .arg(0); - } - ret=sql.exec(cmd); + + ret = sql.exec(cmd); } + return ret; } +bool dataBaseIsEmpty() +{ + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlQuery sql(db); + QString cmd; + cmd = QString("select * from appInfo"); + if (sql.exec(cmd)) { + if (!sql.next()) { + return true; + } else { + if (sql.value(0).toString() == "") { + return true; + } else { + return false; + } + } + return false; + } + return false; +} + +bool updateDataBaseCollect(QString desktopfn, int type) +{ + bool ret = false; + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlQuery sql(db); + QString cmd; + + switch (type) { + case 0: { //取消收藏 + cmd = QString("update appInfo set collect=%1 where desktop=\"%2\"") + .arg(type) + .arg(desktopfn); + ret = sql.exec(cmd); + } + break; + + default: { //收藏 + cmd = QString("select type from appInfo where desktop=\"%1\"") + .arg(desktopfn); + + if (sql.exec(cmd)) { + if (sql.next()) { //更新记录 + cmd = QString("update appInfo set collect=%1 where desktop=\"%2\"") + .arg(type) + .arg(desktopfn); + } else { //添加记录 + QDateTime dt = QDateTime::currentDateTime(); + int datetime = dt.toTime_t(); + cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") + .arg(desktopfn) + .arg(0) + .arg(datetime) + .arg(0) + .arg(0) + .arg(0) + .arg(type); + } + + ret = sql.exec(cmd); + } + } + break; + } + + return ret; +} + +QStringList getCollectAppList() +{ + QStringList list; + int count = 0; + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlQuery sql(db); + QSqlQuery sqlque(db); + QString cmd = QString("select desktop from appInfo where collect!=0 order by collect"); + + if (sql.exec(cmd)) { + while (sql.next()) { + list.append(sql.value(0).toString()); + sqlque.exec(QString("update appInfo set collect=%1 where desktop=\"%2\"") + .arg(++count) + .arg(sql.value(0).toString())); + } + } + + collectCount = list.size() + 1; + return list; +} + +int getCollectAppCount(QString desktopfn) +{ + int appCount = 0; + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlQuery sql(db); + QString cmd = QString("select collect from appInfo where desktop=\"%1\"") + .arg(desktopfn); + + if (sql.exec(cmd)) { + if (sql.next()) { + appCount = sql.value(0).toInt(); + } + } + + return appCount; +} + +void changeCollectSort(QString dragDesktopfn, QString dropDesktopfn) +{ + int endNum = getCollectAppCount(dropDesktopfn); + int startNum = getCollectAppCount(dragDesktopfn); + QStringList applist = getCollectAppList(); + + if (startNum < endNum) { + updateDataBaseCollect(dragDesktopfn, endNum + 1); + + for (int i = endNum; i < applist.count(); i++) { + updateDataBaseCollect(applist.at(i), i + 2); + } + } else { + updateDataBaseCollect(dragDesktopfn, endNum); + + for (int i = endNum - 1; i < applist.count(); i++) { + if (dragDesktopfn != applist.at(i)) { + updateDataBaseCollect(applist.at(i), i + 2); + } + } + } +} + +bool checkIfCollected(QString desktopfn) +{ + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QSqlQuery sql(db); + QString cmd = QString("select collect from appInfo where desktop=\"%1\"") + .arg(desktopfn); + + if (sql.exec(cmd)) { + if (!sql.next()) { + return false; + } else { + if (sql.value(0).toInt() == 0) { + return false; + } else { + return true; + } + } + } + + return false; +} + bool updateDataBaseTableType(QString desktopfn, int type) { - bool ret=false; - QSqlDatabase db = QSqlDatabase::database("MainThread"); + bool ret = false; + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); QSqlQuery sql(db); QString cmd; + switch (type) { - case 0://解除锁定 - { - cmd=QString("delete from appInfo where desktop=\"%1\"") - .arg(desktopfn); - ret=sql.exec(cmd); - } - break; - case 1://锁定 - { - cmd=QString("select type from appInfo where desktop=\"%1\"") - .arg(desktopfn); - if(sql.exec(cmd)) - { - if(sql.next())//更新记录 - { - cmd=QString("update appInfo set type=%1 where desktop=\"%2\"") - .arg(type) - .arg(desktopfn); - } - else//添加记录 - { - QDateTime dt=QDateTime::currentDateTime(); - int datetime=dt.toTime_t(); - cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(0) - .arg(datetime) - .arg(type) - .arg(0); - } - ret=sql.exec(cmd); + case 0: { //解除锁定 + cmd = QString("update appInfo set times=%1,type=%2 where desktop=\"%3\"") + .arg(0) + .arg(type) + .arg(desktopfn); + ret = sql.exec(cmd); } - } break; - default: + + case 1: { //锁定 + cmd = QString("select type from appInfo where desktop=\"%1\"") + .arg(desktopfn); + + if (sql.exec(cmd)) { + if (sql.next()) { //更新记录 + cmd = QString("update appInfo set type=%1 where desktop=\"%2\"") + .arg(type) + .arg(desktopfn); + } else { //添加记录 + QDateTime dt = QDateTime::currentDateTime(); + int datetime = dt.toTime_t(); + cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5,%6)") + .arg(desktopfn) + .arg(0) + .arg(datetime) + .arg(type) + .arg(0) + .arg(0) + .arg(0); + } + + ret = sql.exec(cmd); + } + } break; + + default: + break; } + return ret; } bool updateDataBaseTableRecent(QString desktopfn) { - bool ret=false; + bool ret = false; QSqlDatabase db = QSqlDatabase::database("DirectoryChangedThread"); QSqlQuery sql(db); QString cmd; - QDateTime dt=QDateTime::currentDateTime(); - int datetime=dt.toTime_t(); - cmd=QString("insert into appInfo values(\"%0\",%1,%2,%3,%4)") - .arg(desktopfn) - .arg(0) - .arg(datetime) - .arg(0) - .arg(1); - ret=sql.exec(cmd); + QDateTime dt = QDateTime::currentDateTime(); + int datetime = dt.toTime_t(); + cmd = QString("insert into appInfo values(\"%0\",%1,%2,%3,%4,%5)") + .arg(desktopfn) + .arg(0) + .arg(datetime) + .arg(0) + .arg(1) + .arg(0); + ret = sql.exec(cmd); return ret; } bool checkIfLocked(QString desktopfn) { - QSqlDatabase db = QSqlDatabase::database("MainThread"); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); QSqlQuery sql(db); - QString cmd=QString("select type from appInfo where desktop=\"%1\"") - .arg(desktopfn); - if(sql.exec(cmd)) - { - if(!sql.next()) + QString cmd = QString("select type from appInfo where desktop=\"%1\"") + .arg(desktopfn); + + if (sql.exec(cmd)) { + if (!sql.next()) { return false; - else - { - if(sql.value(0).toInt()==0) + } else { + if (sql.value(0).toInt() == 0) { return false; - else + } else { return true; + } } } + return false; } bool checkIfRecent(QString desktopfn) { - QSqlDatabase db = QSqlDatabase::database("MainThread"); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); QSqlQuery sql(db); - QString cmd=QString("select recent from appInfo where desktop=\"%1\"") - .arg(desktopfn); - if(sql.exec(cmd)) - { - if(!sql.next()) + QString cmd = QString("select recent from appInfo where desktop=\"%1\"") + .arg(desktopfn); + + if (sql.exec(cmd)) { + if (!sql.next()) { return false; - else - { - if(sql.value(0).toInt()==0) + } else { + if (sql.value(0).toInt() == 0) { return false; - else + } else { return true; + } } } + return false; } QStringList getLockAppList() { QStringList list; - QSqlDatabase db = QSqlDatabase::database("MainThread"); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); QSqlQuery sql(db); - QString cmd=QString("select desktop from appInfo where type=1"); - if(sql.exec(cmd)) - { - while(sql.next()) + QString cmd = QString("select desktop from appInfo where type=1"); + + if (sql.exec(cmd)) { + while (sql.next()) { list.append(sql.value(0).toString()); + } } + return list; } QStringList getUnlockAllList() { QStringList list; - QSqlDatabase db = QSqlDatabase::database("MainThread"); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); QSqlQuery sql(db); - QString cmd=QString("select desktop from appInfo where type=0 and times>=1 order by times desc"); - if(sql.exec(cmd)) - { - while(sql.next()) + QString cmd = QString("select desktop from appInfo where type=0 and times>=1 order by times desc"); + + if (sql.exec(cmd)) { + while (sql.next()) { list.append(sql.value(0).toString()); + } } + return list; } void cleanTimeoutApp() { - QSqlDatabase db = QSqlDatabase::database("MainThread"); - QDateTime dt=QDateTime::currentDateTime(); - int datetime=dt.toTime_t()-24*60*60*3; - QString cmd=QString("select desktop from appInfo where time < %1") - .arg(datetime); + QSqlDatabase db = QSqlDatabase::database("MainThreadDataBase"); + QDateTime dt = QDateTime::currentDateTime(); + int datetime = dt.toTime_t() - 24 * 60 * 60 * 3; + QString cmd = QString("select desktop from appInfo where time < %1") + .arg(datetime); QStringList list; QSqlQuery sql(db); - if(sql.exec(cmd)) - { - while(sql.next()) - { - if(!checkIfLocked(sql.value(0).toString())) + + if (sql.exec(cmd)) { + while (sql.next()) { + if (!checkIfLocked(sql.value(0).toString())) { list.append(sql.value(0).toString()); + } } } - Q_FOREACH(QString desktopfn, list) - { - cmd=QString("delete from appInfo where desktop=\"%1\"") - .arg(desktopfn); + + Q_FOREACH (QString desktopfn, list) { + cmd = QString("delete from appInfo where desktop=\"%1\"") + .arg(desktopfn); sql.exec(cmd); } } bool deleteAppRecord(QString desktopfn) { - bool ret=false; + bool ret = false; QSqlDatabase db = QSqlDatabase::database("DirectoryChangedThread"); - QString cmd=QString("delete from appInfo where desktop=\"%1\"") - .arg(desktopfn); + QString cmd = QString("delete from appInfo where desktop=\"%1\"") + .arg(desktopfn); QSqlQuery sql(db); - ret=sql.exec(cmd); + ret = sql.exec(cmd); return ret; } void execApp(QString desktopfp) { - UkuiMenuInterface interface; - if(interface.checkKreApp(desktopfp)) - { - QProcess::startDetached(interface.getAppExec(desktopfp)); - } - else - { - QString appName = interface.getAppExec(desktopfp); - QStringList strList = (appName.replace("\"","")).split(" "); -// for(int i = 1; i < strList.size(); i++) -// { - if(QString(strList.at(0)) == "kmplayer") - { + + QDBusInterface iface("com.kylin.AppManager", + "/com/kylin/AppManager", + "com.kylin.AppManager", + QDBusConnection::sessionBus()); + QDBusReply res = iface.call("LaunchApp", desktopfp); + + if (!res.isValid() || !res) { + + UkuiMenuInterface interface; + + if (interface.checkKreApp(desktopfp)) { + QProcess::startDetached(interface.getAppExec(desktopfp)); + } else { + QString appName = interface.getAppExec(desktopfp); + QStringList strList = (appName.replace("\"", "")).split(" "); + + if (QString(strList.at(0)) == "kmplayer") { QProcess::startDetached(strList.at(0)); return; } -// } - GDesktopAppInfo * desktopAppInfo=g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); - g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr); - g_object_unref(desktopAppInfo); + + GDesktopAppInfo *desktopAppInfo = g_desktop_app_info_new_from_filename(desktopfp.toLocal8Bit().data()); + g_app_info_launch(G_APP_INFO(desktopAppInfo), nullptr, nullptr, nullptr); + g_object_unref(desktopAppInfo); + } + } + + QFileInfo fileInfo(desktopfp); + QString desktopfn = fileInfo.fileName(); + + if (desktopfn.startsWith("app.web.")) { + updateDataBaseTableTimes(desktopfn); } } bool checkOsRelease() { QFile file("/etc/os-release"); - if(file.open(QFile::ReadOnly)) - { - QByteArray line=file.readLine(); + + if (file.open(QFile::ReadOnly)) { + QByteArray line = file.readLine(); file.close(); - if(QString(line).contains("Ubuntu")) + + if (QString(line).contains("Ubuntu")) { return true; + } } + return false; } //获取用户图像 QString getUserIcon() { - qint64 uid=static_cast(getuid()); + qint64 uid = static_cast(getuid()); QDBusInterface iface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts", QDBusConnection::systemBus()); - QDBusReplyobjPath=iface.call("FindUserById",uid); - + QDBusReplyobjPath = iface.call("FindUserById", uid); QDBusInterface useriface("org.freedesktop.Accounts", objPath.value().path(), "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); - QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","IconFile"); - QString iconstr=var.value().toString(); + QDBusReply var = useriface.call("Get", "org.freedesktop.Accounts.User", "IconFile"); + QString iconstr = var.value().toString(); return iconstr; } QString getUserName() { QString name; - qint64 uid=static_cast(getuid()); + qint64 uid = static_cast(getuid()); QDBusInterface iface("org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts", QDBusConnection::systemBus()); - QDBusReply objPath=iface.call("FindUserById",uid); + QDBusReply objPath = iface.call("FindUserById", uid); QDBusInterface useriface("org.freedesktop.Accounts", objPath.value().path(), "org.freedesktop.DBus.Properties", QDBusConnection::systemBus()); - QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","RealName"); - name=var.value().toString(); - if(name.isEmpty()) - { - var=useriface.call("Get","org.freedesktop.Accounts.User","UserName"); - name=var.value().toString(); - } + // QDBusReply var=useriface.call("Get","org.freedesktop.Accounts.User","RealName"); + // name=var.value().toString(); + // if(name.isEmpty()) + // { + QDBusReply var = useriface.call("Get", "org.freedesktop.Accounts.User", "UserName"); + name = var.value().toString(); + // } return name; } diff --git a/src/UtilityFunction/utility.h b/src/UtilityFunction/utility.h old mode 100644 new mode 100755 index db30fee..4491673 --- a/src/UtilityFunction/utility.h +++ b/src/UtilityFunction/utility.h @@ -23,19 +23,16 @@ #include #include #include +#include #include -#include "src/Interface/ukuimenuinterface.h" #define DBUS_NAME "org.ukui.panel" #define DBUS_PATH "/panel/position" #define DBUS_INTERFACE "org.ukui.panel" -enum PanelPositon{ - BOTTOM = 0, - TOP = 1, - LEFT = 2, - RIGHT = 3 -}; +#define myDebug() qDebug() << QString("%1 %2 行 %3").arg(__FILE__).arg(__FUNCTION__).arg(__LINE__) + +static int collectCount = 0; const QPixmap loadSvg(const QString &fileName, const int size); @@ -47,7 +44,7 @@ QPixmap drawSymbolicBlackColoredPixmap(const QPixmap &source); //调试日志 void debugLog(QString strMsg); - +QVariantList getScreenGeometryList(); double getTransparency(); QString getEnvOverriddenDesktopFile(int pid); //数据库操作 @@ -59,6 +56,11 @@ bool updateDataBaseTableType(QString desktopfn, int type);//更新是否锁定 bool updateDataBaseTableRecent(QString desktopfn);//更新最近添加 bool checkIfLocked(QString desktopfn);//检查是否被锁定 bool checkIfRecent(QString desktopfn);//检查是否最近安装 +bool checkIfCollected(QString desktopfn); +QStringList getCollectAppList(); +void changeCollectSort(QString dragDesktopfn, QString dropDesktopfn); +bool dataBaseIsEmpty();//判断数据库是否为空 +bool updateDataBaseCollect(QString desktopfn, int type); QStringList getLockAppList();//获取被锁定应用 QStringList getUnlockAllList();//获取未被锁定应用 void cleanTimeoutApp();//清理超时应用 @@ -68,10 +70,26 @@ bool deleteAppRecord(QString desktopfn);//删除应用记录 void execApp(QString desktopfp); bool checkOsRelease();//区分社区办与商业版 +void centerToScreen(QWidget *widget); +QIcon getCurIcon(const QString &iconPath, bool autoSet); + //获取用户图像 QString getUserIcon(); //获取用户姓名 QString getUserName(); +enum PanelPositon { + BOTTOM = 0, + TOP = 1, + LEFT = 2, + RIGHT = 3 +}; + +extern QString g_projectCodeName; +extern QString g_subProjectCodeName; +extern QString g_platform; +extern bool g_menuStatus; +extern QString g_curStyle; + #endif // UTILITY_H diff --git a/src/UtilityFunction/utilityfunction.pri b/src/UtilityFunction/utilityfunction.pri new file mode 100755 index 0000000..3cc89d4 --- /dev/null +++ b/src/UtilityFunction/utilityfunction.pri @@ -0,0 +1,16 @@ +INCLUDEPATH += \ + $$PWD \ + $$PWD/Style + +HEADERS += \ + $$PWD/AbstractInterface.h \ + $$PWD/KySmallPluginInterface.h \ + $$PWD/Style/style.h \ + $$PWD/abstractInterface.h \ + $$PWD/thumbnail.h \ + $$PWD/utility.h + +SOURCES += \ + $$PWD/Style/style.cpp \ + $$PWD/thumbnail.cpp \ + $$PWD/utility.cpp diff --git a/translations/ukui-menu_bo.ts b/translations/ukui-menu_bo.ts deleted file mode 100644 index 52e731e..0000000 --- a/translations/ukui-menu_bo.ts +++ /dev/null @@ -1,292 +0,0 @@ - - - - - FunctionClassifyButton - - - Mobile - - - - - Internet - - - - - Social - - - - - Video - - - - - Development - - - - - Image - - - - - Game - - - - - Office - - - - - Education - - - - - System - - - - - Others - - - - - FunctionWidget - - - Mobile - - - - - Internet - - - - - Social - - - - - Video - - - - - Development - - - - - Image - - - - - Game - - - - - Office - - - - - Education - - - - - System - - - - - Others - - - - - MainViewWidget - - - Search - - - - - RightClickMenu - - - Pin to all - - - - - Unpin from all - - - - - Pin to taskbar - - - - - Unpin from taskbar - - - - - Add to desktop shortcuts - - - - - Uninstall - - - - - Sleep - - - - - Log Out - - - - - Restart - - - - - Power Off - - - - - Personalize this list - - - - - SideBarWidget - - - All - - - - - Letter - - - - - Function - - - - - Trash - - - - - Computer - - - - - Max - - - - - Personal - - - - - Settings - - - - - Power - - - - - SplitBarFrame - - - Mobile - - - - - Internet - - - - - Social - - - - - Video - - - - - Development - - - - - Image - - - - - Game - - - - - Office - - - - - Education - - - - - System - - - - - Others - - - - diff --git a/translations/ukui-menu_bo_CN.ts b/translations/ukui-menu_bo_CN.ts index 091d0ea..d92f153 100644 --- a/translations/ukui-menu_bo_CN.ts +++ b/translations/ukui-menu_bo_CN.ts @@ -1,290 +1,292 @@ - + - FunctionClassifyButton + FullMainWindow - Mobile - གནས་སྤོར། + + Search + འཚོལ་ཞིབ། - Internet - སྦྲེལ་རེས་དྲ་རྒྱ། + + All + ཚང་མ། - Social - འབྲེལ་འདྲིས། + + Letter + འཕྲིན་ཡིག - Video - བརྙན་ཟློས། - - - Development - གསར་སྤེལ། - - - Image - པར་རིས།། - - - Game - རོལ་རྩེད། - - - Office - གཞུང་ལས།དྲ་རྒྱ། - - - Education - སློབ་གསོ། - - - System - རྒྱུད་ཁོངས། - - - Others - གཞན་དག + + Function + བྱེད་ནུས། - MainViewWidget + FunctionWidget - + Search - འཚོལ་བ། + འཚོལ་ཞིབ། + + + + ItemDelegate + + Open feature sort list + 打开功能排序菜单 + + + Open alphabetical list + 打开字母排序菜单 + + + + Open the function sort menu + བྱེད་ལས་རིགས་ཀྱི་ཟས་ཐོའི་ཁ་ཕྱེ་བ། + + + + Open the alphabetical menu + དབྱངས་གསལ་ཡི་གེའི་ཟས་ཐོའི་ཁ་ཕྱེ་བ། + + + + MainWindow + + + + Search + འཚོལ་ཞིབ། + + + + No recent files + ཉེ་དུས་ཀྱི་ཡིག་ཆ་མེད། + + + + + + + + All + ཚང་མ། + + + + collection + བསྡུ་ཉར། + + + + recent + ཉེ་ཆར། + + + + Max + མའེ་ཁེ་སི། + + + + PowerOff + སྒུལ་ཤུགས་ཀྱི་ནུས་པ། + + + Search application + 搜索应用 + + + + + + Letter + འཕྲིན་ཡིག + + + + + + Function + བྱེད་ནུས། QObject - - + + Office - གཞུང་ལས།དྲ་རྒྱ། + གཞུང་ལས་ཁང་། - - + + Development - གསར་སྤེལ། + འཕེལ་རྒྱས་ - - + + Image - པར་རིས།། + པར་རིས། - - + + Video - བརྙན་ཟློས། + བརྙན་ཕབ། - - + + Internet - སྦྲེལ་རེས་དྲ་རྒྱ། + དྲ་སྦྲེལ། - - + + Game རོལ་རྩེད། - - + + Education སློབ་གསོ། - - + + Social - འབྲེལ་འདྲིས། + སྤྱི་ཚོགས། - - + + System - རྒྱུད་ཁོངས། + ལམ་ལུགས། - - + + Safe - + བདེ་འཇགས། - - + + Others - གཞན་དག + དེ་མིན་ད་དུང་ RightClickMenu - + Pin to all - “ མཉེན་ཆས་ཆ་ཚང་། ” དུ་འཇོག་པ། + མི་ཚང་མར་ཁབ་རྒྱག་པ། - + Unpin from all - “ མཉེན་ཆས་ཆ་ཚང་། ” ལས་ལེན་པ། + མི་ཚང་མའི་ཁྲོད་ནས་བཀག་འགོག་བྱེད་ - + Pin to taskbar - འགན་བྱང་དུ་འཇོག་པ། + ལས་འགན་སྒྲུབ་པར་ཁབ་རྒྱག་པ། - + Unpin from taskbar - འགན་བྱང་ནས་ལེན་པ། + ལས་འགན་སྒྲུབ་ས་ནས་ཁ་པར་གཏོང་བ། - + Add to desktop shortcuts - ཅོག་ངོས་སུ་མྱུར་འཐེབ་སྣོན་པ། + ཅོག་ཙེའི་སྟེང་གི་མགྱོགས་ལམ་ཁ་སྣོན་བྱས་ཡོད། - + + Pin to collection + འཚོལ་སྡུད་བྱེད་པའི་ཁབ་སྐུད། + + + + Remove from collection + བསྡུ་ཉར་དངོས་རྫས་ཁྲོད་ནས་ཕྱིར་ + + + Uninstall - ལྷུ་གཏོར + སྒྲིག་སྦྱོར་བྱས་མེད་པ། - + + Switch user + གློག་སྒོ་འབྱེད་པའི་སྤྱོད་མཁན + + + + Hibernate + ཧིན་རྡུ་ཉི་ཞི་ཡ། + + + Sleep - མལ་གསོ། + གཉིད་ཁུག་པ། - + + Lock Screen + སྒོ་ལྕགས་ཀྱི་བརྙན་ཤེལ། + + + Log Out - རྩིས་ཐེམ་ནས་བསུབ་པ། + ཕྱིར་འཐེན་བྱ་དགོས། - + Restart - བསྐྱར་སློང་། + ཡང་བསྐྱར་འགོ་འཛུགས་ - + Power Off - འཁོར་ཁ་རྒྱག་པ། + གློག་ཆད་པ། - + Personalize this list - མགོ་རྩོམ་གདམ་བྱང་གི་རིམ་བྱང་སྒྲིག་འགོད་བྱེད་པ། + མིང་ཐོ་འདི་རང་གཤིས་ཅན་དུ་བསྒྱུར - SideBarWidget + TabletRightClickMenu - - All - མཉེན་ཆས་ཚང་མ། + + Pin to taskbar + ལས་འགན་སྒྲུབ་པར་ཁབ་རྒྱག་པ། - - Letter - འཕྲིན་ཡིག + + Unpin from taskbar + ལས་འགན་སྒྲུབ་ས་ནས་ཁ་པར་གཏོང་བ། - - Function - བྱེད་ནུས། + + Add to desktop shortcuts + ཅོག་ཙེའི་སྟེང་གི་མགྱོགས་ལམ་ཁ་སྣོན་བྱས་ཡོད། - - Trash - སྙིགས་སྒམ། - - - - Computer - རྩིས་ཆས། - - - - Max - ཆེས་ཆེ་བ། - - - - Min - - - - - Personal - མི་སྒེར། - - - - Settings - སྒྲིག་འགོད། - - - - Power - ཁ་རྒྱག་པ། - - - - SplitBarFrame - - Mobile - གནས་སྤོར། - - - Internet - སྦྲེལ་རེས་དྲ་རྒྱ། - - - Social - འབྲེལ་འདྲིས། - - - Video - བརྙན་ཟློས། - - - Development - གསར་སྤེལ། - - - Image - པར་རིས།། - - - Game - རོལ་རྩེད། - - - Office - གཞུང་ལས།དྲ་རྒྱ། - - - Education - སློབ་གསོ། - - - System - རྒྱུད་ཁོངས། - - - Safe - सुरक्षा - - - Others - གཞན་དག + + Uninstall + སྒྲིག་སྦྱོར་བྱས་མེད་པ། diff --git a/translations/ukui-menu_tr.ts b/translations/ukui-menu_tr.ts old mode 100644 new mode 100755 index 691fbea..756c8b1 --- a/translations/ukui-menu_tr.ts +++ b/translations/ukui-menu_tr.ts @@ -1,128 +1,262 @@ + + FullMainWindow + + + Search + Ara + + + + All + Tümü + + + + Letter + Alfabetik + + + + Function + Kategori + + FunctionClassifyButton - Mobile - Mobil + Mobil - Internet - İnternet + İnternet - Social - Sosyal + Sosyal - Video - Video + Video - Development - Programlama + Programlama - Image - Grafik + Grafik - Game - Oyunlar + Oyunlar - Office - Ofis Uygulamaları + Ofis Uygulamaları - Education - Eğitim + Eğitim - System - Sistem + Sistem - Others - Diğer + Diğer FunctionWidget - Mobile - Mobil + Mobil - Internet - İnternet + İnternet - Social - Sosyal + Sosyal - Video - Video + Video - Development - Programlama + Programlama - Image - Grafik + Grafik - Game - Oyunlar + Oyunlar - Office - Ofis Uygulamaları + Ofis Uygulamaları - Education - Eğitim + Eğitim - System - Sistem + Sistem - Others - Diğer + Diğer + + + + Search + Ara + + + + GetModelData + + Mobile + Mobil + + + Internet + İnternet + + + Social + Sosyal + + + Video + Video + + + Development + Programlama + + + Image + Grafik + + + Game + Oyunlar + + + Office + Ofis Uygulamaları + + + Education + Eğitim + + + System + Sistem + + + Others + Diğer + + + + ItemDelegate + + + Open the function sort menu + + + + + Open the alphabetical menu + MainViewWidget - + All + Tümü + + + Letter + Alfabetik + + + Function + Kategori + + Search - Ara + Ara + + + + MainWindow + + + collection + + + + + + + + + All + Tümü + + + + + Search + Ara + + + + No recent files + + + + + recent + + + + + Max + + + + + PowerOff + + + + + + + Letter + Alfabetik + + + + + + Function + Kategori @@ -172,72 +306,158 @@ Diğer + + QObject + + + + Office + Ofis Uygulamaları + + + + + Development + Programlama + + + + + Image + Grafik + + + + + Video + Video + + + + + Internet + İnternet + + + + + Game + Oyunlar + + + + + Education + Eğitim + + + + + Social + Sosyal + + + + + System + Sistem + + + + + Safe + + + + + + Others + Diğer + + RightClickMenu - + Pin to all Tümünü sabitle - + Unpin from all Tüm sabitlemeleri kaldır - + Pin to taskbar Görev çubuğuna sabitle - + Unpin from taskbar Görev çubuğundan sabitlemeyi kaldır - + Add to desktop shortcuts Masaüstü kısayollarına ekle - + + Pin to collection + + + + + Remove from collection + + + + Uninstall Kaldır - Hibernate - Beklemeye Al + + Switch user + - + + Hibernate + Beklemeye Al + + + Sleep Uyku Modu + Lock Screen - Ekranı Kilitle + Ekranı Kilitle Switch User Kullanıcı Değiştir - + Log Out Çıkış - + Restart Yeniden Başlat - + Power Off Kapat - + Personalize this list Bu listeyi özelleştirin @@ -245,111 +465,117 @@ SideBarWidget - All - Tümü + Tümü - Letter - Alfabetik + Alfabetik - Function - Kategori + Kategori - Trash - Çöp + Çöp - Computer - Bilgisayar + Bilgisayar - - Max - - - - Personal - Kişisel + Kişisel - Settings - Ayarlar + Ayarlar Recycle Bin Çöp - Power - Kapat + Kapat SplitBarFrame - Mobile - Mobil + Mobil - Internet - İnternet + İnternet - Social - Sosyal + Sosyal - Video - Video + Video - Development - Programlama + Programlama - Image - Grafik + Grafik - Game - Oyunlar + Oyunlar - Office - Ofis Uygulamaları + Ofis Uygulamaları - Education - Eğitim + Eğitim - System - Sistem + Sistem - Others - Diğer + Diğer + + + + TabletRightClickMenu + + + Pin to taskbar + Görev çubuğuna sabitle + + + + Unpin from taskbar + Görev çubuğundan sabitlemeyi kaldır + + + + Add to desktop shortcuts + Masaüstü kısayollarına ekle + + + + Uninstall + Kaldır + + + + TimeWidget + + Search + Ara diff --git a/translations/ukui-menu_zh_CN.ts b/translations/ukui-menu_zh_CN.ts old mode 100644 new mode 100755 index f4c522a..4d04dbf --- a/translations/ukui-menu_zh_CN.ts +++ b/translations/ukui-menu_zh_CN.ts @@ -2,354 +2,291 @@ - FunctionClassifyButton + FullMainWindow - - Mobile - 移动 + + Search + 搜索应用 - - Internet - 网络 + + All + 全部 - - Social - 社交 + + Letter + 字母排序 - - Video - 影音 - - - - Development - 开发 - - - - Image - 图像 - - - - Game - 游戏 - - - - Office - 办公 - - - - Education - 教育 - - - - System - 系统 - - - - Others - 其它 + + Function + 功能分类 FunctionWidget - - Mobile - 移动 + + Search + 全局搜索 + + + + ItemDelegate + + Open feature sort list + 打开功能排序菜单 - - Internet - 网络 + Open alphabetical list + 打开字母排序菜单 - - Social - 社交 + + Open the function sort menu + 打开功能排序菜单 - - Video - 影音 + + Open the alphabetical menu + 打开字母排序菜单 + + + + MainWindow + + + + Search + 搜索应用 - - Development - 开发 + + No recent files + 暂无最近文件 - - Image - 图像 + + + + + + All + 全部 - - Game - 游戏 + + collection + 收藏 - + + recent + 最近 + + + + Max + 放大 + + + + PowerOff + 电源 + + + Search application + 搜索应用 + + + + + + Letter + 字母排序 + + + + + + Function + 功能分类 + + + + QObject + + + Office 办公 - + + + Development + 开发 + + + + + Image + 图像 + + + + + Video + 影音 + + + + + Internet + 网络 + + + + + Game + 游戏 + + + + Education 教育 - + + + Social + 社交 + + + + System 系统 - + + + Safe + 安全 + + + + Others - 其它 - - - - MainViewWidget - - - Search - 搜索 - - - - PushButton - - Mobile - 移动 - - - Internet - 网络 - - - Social - 社交 - - - Video - 影音 - - - Development - 开发 - - - Image - 图像 - - - Game - 游戏 - - - Office - 办公 - - - Education - 教育 - - - System - 系统 - - - Others - 其它 + 其他 RightClickMenu - + Pin to all 固定到“所有软件” - + Unpin from all 从“所有软件”取消固定 - + Pin to taskbar 固定到任务栏 - + Unpin from taskbar 从任务栏取消固定 - + Add to desktop shortcuts 添加到桌面快捷方式 - + + Pin to collection + 固定到收藏 + + + + Remove from collection + 从收藏移除 + + + Uninstall 卸载 - Hibernate - 休眠 + + Switch user + 切换用户 - + + Hibernate + 休眠 + + + Sleep 睡眠 + Lock Screen - 锁屏 + 锁屏 - Switch User - 切换用户 - - - + Log Out 注销 - + Restart 重启 - + Power Off 关机 - + Personalize this list - 设置开始菜单显示列表 + - SideBarWidget + TabletRightClickMenu - - All - 所有软件 + + Pin to taskbar + 固定到任务栏 - - Letter - 字母排序 + + Unpin from taskbar + 从任务栏取消固定 - - Function - 功能分类 + + Add to desktop shortcuts + 固定到桌面快捷方式 - - Trash - 回收站 - - - - Computer - 计算机 - - - - Max - 放大 - - - - Personal - 个人 - - - - Settings - 设置 - - - Recycle Bin - 回收站 - - - - Power - 电源 - - - - SplitBarFrame - - - Mobile - 移动 - - - - Internet - 网络 - - - - Social - 社交 - - - - Video - 影音 - - - - Development - 开发 - - - - Image - 图像 - - - - Game - 游戏 - - - - Office - 办公 - - - - Education - 教育 - - - - System - 系统 - - - - Others - 其它 + + Uninstall + 卸载 diff --git a/ukui-menu.desktop b/ukui-menu.desktop old mode 100644 new mode 100755 diff --git a/ukui-menu.ini b/ukui-menu.ini old mode 100644 new mode 100755 diff --git a/ukui-menu.pro b/ukui-menu.pro old mode 100644 new mode 100755 index a6658eb..1ca9797 --- a/ukui-menu.pro +++ b/ukui-menu.pro @@ -7,7 +7,11 @@ QT += core gui svg dbus x11extras KWindowSystem sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -include(src/QtSingleApplication/qtsingleapplication.pri) + +include(./src/BackProcess/backprocess.pri) +include(./src/QtSingleApplication/qtsingleapplication.pri) +include(./src/UserInterface/userinterface.pri) +include(./src/UtilityFunction/utilityfunction.pri) QMAKE_CXXFLAGS += -g TARGET = ukui-menu @@ -16,7 +20,7 @@ TEMPLATE = app target.path = /usr/bin TRANSLATIONS+=\ - translations/ukui-menu_bo.ts \ + translations/ukui-menu_bo_CN.ts \ translations/ukui-menu_zh_CN.ts \ translations/ukui-menu_tr.ts @@ -44,92 +48,22 @@ INSTALLS += qm_files # So we can access it from main.cpp DEFINES += QM_FILES_INSTALL_PATH='\\"$${QM_FILES_INSTALL_PATH}\\"' -SOURCES += \ - src/CommonUseWidget/commonusewidget.cpp \ - src/CommonUseWidget/fullcommonusewidget.cpp \ - src/FunctionWidget/fullfunctionwidget.cpp \ - src/FunctionWidget/functionbuttonwidget.cpp \ - src/FunctionWidget/functionwidget.cpp \ - src/LetterWidget/fullletterwidget.cpp \ - src/LetterWidget/letterbuttonwidget.cpp \ - src/LetterWidget/letterwidget.cpp \ - src/MainViewWidget/directorychangedthread.cpp \ - src/MainViewWidget/mainviewwidget.cpp \ - src/MainWindow/mainwindow.cpp \ - src/RightClickMenu/menubox.cpp \ - src/RightClickMenu/rightclickmenu.cpp \ - src/SearchResultWidget/file-utils.cpp \ - src/SearchResultWidget/fullsearchresultwidget.cpp \ - src/SearchResultWidget/searchappthread.cpp \ - src/SearchResultWidget/searchresultwidget.cpp \ - src/SideBarWidget/sidebarwidget.cpp \ - src/Style/style.cpp \ - src/UtilityFunction/classifybtnscrollarea.cpp \ - src/UtilityFunction/fullitemdelegate.cpp \ - src/UtilityFunction/fulllistview.cpp \ - src/UtilityFunction/functionclassifybutton.cpp \ - src/UtilityFunction/itemdelegate.cpp \ - src/UtilityFunction/letterclassifybutton.cpp \ - src/UtilityFunction/listview.cpp \ - src/UtilityFunction/proxystyle.cpp \ - src/UtilityFunction/scrollarea.cpp \ - src/UtilityFunction/splitbarframe.cpp \ - src/UtilityFunction/toolbutton.cpp \ - src/Interface/ukuichineseletter.cpp \ - src/Interface/ukuimenuinterface.cpp \ - main.cpp \ - src/UtilityFunction/utility.cpp \ - src/DBus/dbus.cpp \ - src/DBus/dbus-adaptor.cpp - -HEADERS += \ - src/CommonUseWidget/commonusewidget.h \ - src/CommonUseWidget/fullcommonusewidget.h \ - src/FunctionWidget/fullfunctionwidget.h \ - src/FunctionWidget/functionbuttonwidget.h \ - src/FunctionWidget/functionwidget.h \ - src/LetterWidget/fullletterwidget.h \ - src/LetterWidget/letterbuttonwidget.h \ - src/LetterWidget/letterwidget.h \ - src/MainViewWidget/directorychangedthread.h \ - src/MainViewWidget/mainviewwidget.h \ - src/MainWindow/mainwindow.h \ - src/RightClickMenu/menubox.h \ - src/RightClickMenu/rightclickmenu.h \ - src/SearchResultWidget/file-utils.h \ - src/SearchResultWidget/fullsearchresultwidget.h \ - src/SearchResultWidget/searchappthread.h \ - src/SearchResultWidget/searchresultwidget.h \ - src/SideBarWidget/sidebarwidget.h \ - src/Style/style.h \ - src/UtilityFunction/classifybtnscrollarea.h \ - src/UtilityFunction/fullitemdelegate.h \ - src/UtilityFunction/fulllistview.h \ - src/UtilityFunction/functionclassifybutton.h \ - src/UtilityFunction/itemdelegate.h \ - src/UtilityFunction/letterclassifybutton.h \ - src/UtilityFunction/listview.h \ - src/UtilityFunction/proxystyle.h \ - src/UtilityFunction/scrollarea.h \ - src/UtilityFunction/splitbarframe.h \ - src/UtilityFunction/toolbutton.h \ - src/Interface/ukuichineseletter.h \ - src/Interface/ukuimenuinterface.h \ - src/UtilityFunction/utility.h \ - src/DBus/dbus.h \ - src/DBus/dbus-adaptor.h - -RESOURCES += \ - res.qrc - -PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt +PKGCONFIG+=glib-2.0 gio-unix-2.0 gsettings-qt libbamf3 x11 xtst kysdk-waylandhelper CONFIG += no_keywords link_pkgconfig -LIBS+=-pthread -luchardet -lukui-log4qt +LIBS+=-pthread -luchardet -lukui-log4qt -lukui-com4c -lukui-com4cxx -lpeony desktop_file.files = ukui-menu.desktop desktop_file.path = /etc/xdg/autostart INSTALLS += \ target desktop_file + +FORMS += + +SOURCES += \ + main.cpp \ + +RESOURCES += \ + res.qrc diff --git a/ukui-menu.pro.user b/ukui-menu.pro.user deleted file mode 100644 index 48d277d..0000000 --- a/ukui-menu.pro.user +++ /dev/null @@ -1,249 +0,0 @@ - - - - - - EnvironmentId - {b9d686e0-ada0-41c1-ad9c-96f1279f7707} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - false - true - false - 0 - true - true - 0 - 8 - true - false - 1 - true - true - true - *.md, *.MD, Makefile - false - true - - - - ProjectExplorer.Project.PluginSettings - - - true - false - true - true - true - true - - - 0 - true - - - - ProjectExplorer.Project.Target.0 - - Desktop - 桌面 - 桌面 - {9d9f9a2c-403b-48c4-83ee-e52b4e889b83} - 0 - 0 - 0 - - 0 - /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug - /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Debug - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release - /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Release - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - - - 0 - /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile - /home/ztz/ukui-menu3.0-0720/build-ukui-menu-unknown-Profile - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - true - - 2 - - Qt4ProjectManager.Qt4RunConfiguration:/home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro - /home/ztz/ukui-menu3.0-0720/ukui-menu/ukui-menu.pro - false - true - true - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - From ce2f022961020bf65d0c794a5ef25c28d2e5d886 Mon Sep 17 00:00:00 2001 From: lixueman Date: Fri, 12 Aug 2022 08:25:58 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E7=A7=BB=E9=99=A4debian=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 67 -------------------------------------------- debian/control | 44 ----------------------------- debian/copyright | 29 ------------------- debian/rules | 7 ----- debian/source/format | 1 - debian/watch | 2 -- 6 files changed, 150 deletions(-) delete mode 100755 debian/changelog delete mode 100755 debian/control delete mode 100755 debian/copyright delete mode 100755 debian/rules delete mode 100755 debian/source/format delete mode 100755 debian/watch diff --git a/debian/changelog b/debian/changelog deleted file mode 100755 index c28265f..0000000 --- a/debian/changelog +++ /dev/null @@ -1,67 +0,0 @@ -ukui-menu (3.1.1-ok4~0727) yangtze; urgency=medium - - * 增加开始菜单藏文翻译 - * 调整点击应用时窗口隐藏时机 - * 修改分类下拉选择框宽度 - - -- lixueman Wed, 27 Jul 2022 20:32:11 +0800 - -ukui-menu (3.1.1-ok4~0725) yangtze; urgency=medium - - * 解决平板模式下win键可以打开开始菜单问题 - - -- lixueman Mon, 25 Jul 2022 09:15:22 +0800 - -ukui-menu (3.1.1-ok4~0721.1) yangtze; urgency=medium - - * 解决了强调色修改后,搜索框未及时刷新问题 - - -- lixueman Thu, 21 Jul 2022 15:34:09 +0800 - -ukui-menu (3.1.1-ok4~0721) yangtze; urgency=medium - - * close-cd #130526 修改搜索框和收藏最近按钮高亮色 - * close-cd #130514 全屏菜单的滑块透明度修改 - * close-cd #130485 修改字母集导航页禁用按钮样式 - * close-cd #130477 修改功能集导航页禁用按钮样式 - - -- kylin Thu, 21 Jul 2022 13:51:42 +0800 - -ukui-menu (3.1.1-ok4~0718) yangtze; urgency=medium - - * close-cd #127740 修复wayland下默认全屏切换动画位置异常,不显示动画 - * close-cd #129213 解决开始菜单点击屏幕键盘后延迟退出问题 - * close-cd #128764 增加搜索按下键切换焦点至搜索结果页;全屏增加字符输入直接切换搜索框 - * close-cd #128492,解决字母和功能分类固定到所有软件未置顶问题 - - -- lixueman Mon, 18 Jul 2022 15:09:23 +0800 - -ukui-menu (3.1.1-ok4~0712) yangtze; urgency=medium - - * close-cd #128498 - 修复【wayland】【开始菜单】多次点击tab键和回车键后,开始菜单点不开问题 - - -- lixueman Tue, 12 Jul 2022 16:11:49 +0800 - -ukui-menu (3.1.1-ok4~0708) yangtze; urgency=medium - - * 调整全屏窗口初始化代码结构 - * 增加全屏开始菜单分类选择下拉按钮动画效果 - * 增加全屏开始菜单点击空白区域退出功能 - * 固定全屏电源右键菜单位置 - - -- lixueman Fri, 08 Jul 2022 11:25:23 +0800 - -ukui-menu (3.1.1-ok4~0623) yangtze; urgency=medium - - * 调整QGuiApplication::platformName()调用时机 - * 增加全屏窗口显示时位置设定 - * 合入app-manager接口 - - -- lixueman Wed, 22 Jun 2022 11:22:58 +0800 - -ukui-menu (3.1.1-ok1) yangtze; urgency=medium - - * 版本号规范化 - - -- Xie Wei Fri, 06 May 2022 17:54:45 +0800: diff --git a/debian/control b/debian/control deleted file mode 100755 index b845cb7..0000000 --- a/debian/control +++ /dev/null @@ -1,44 +0,0 @@ -Source: ukui-menu -Section: x11 -Priority: optional -Maintainer: Kylin Team -Uploaders: Aron Xu , - handsome_feng -Build-Depends: debhelper-compat (=12), - qtbase5-dev, - libqt5svg5-dev, - libqt5x11extras5-dev, - libglib2.0-dev (>= 2.36), - libgsettings-qt-dev, - qttools5-dev-tools, - libbamf3-dev, - libkf5windowsystem-dev, - libuchardet-dev, - libukui-log4qt-dev, - libxtst-dev, - libx11-dev, - libukui-common0, - libukui-common-dev, - libpeony-dev, - libkysdk-waylandhelper-dev -Standards-Version: 4.5.0 -Rules-Requires-Root: no -Homepage: https://github.com/ukui/ukui-menu -Vcs-Git: https://github.com/ukui/ukui-menu -Vcs-Browser: https://github.com/ukui/ukui-menu - -Package: ukui-menu -Architecture: any -Depends: ${shlibs:Depends}, - ${misc:Depends}, - accountsservice, - libgsettings-qt1, - libqt5x11extras5, - bamfdaemon, - libkysdk-waylandhelper -Suggests:kylin-status-manager -Description: Advanced ukui menu - UKUI menu provides start menu development library and advanced - graphical user interface. - . - The package contains executable file. diff --git a/debian/copyright b/debian/copyright deleted file mode 100755 index 3a0edea..0000000 --- a/debian/copyright +++ /dev/null @@ -1,29 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: ukui-menu -Upstream-Contact: liuhao -Source: https://github.com/ukui/ukui-menu - -Files: * -Copyright: 2019 Tianjin KYLIN Information Technology Co., Ltd. -License: GPL-3.0+ - -Files: debian/* -Copyright: 2019 liuhao -License: GPL-3.0+ - -License: GPL-3.0+ - 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 of the License, or - (at your option) any later version. - . - This package 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 . - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 95cf77f..0000000 --- a/debian/rules +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/make -f - -export DEB_BUILD_MAINT_OPTIONS = hardening=+all -export QT_SELECT := qt5 - -%: - dh $@ diff --git a/debian/source/format b/debian/source/format deleted file mode 100755 index 89ae9db..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/debian/watch b/debian/watch deleted file mode 100755 index e685515..0000000 --- a/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=4 -https://github.com/ukui/ukui-menu/releases .*/ukui-menu_(\d\S+)\.orig\.tar\.gz From f052864023ee966081f4a33fabaa22ee121d93fd Mon Sep 17 00:00:00 2001 From: lixueman Date: Fri, 21 Oct 2022 15:46:18 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E7=A7=BB=E9=99=A4debian=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 115 ------------------------------------------- debian/control | 44 ----------------- debian/copyright | 29 ----------- debian/rules | 7 --- debian/source/format | 1 - debian/watch | 2 - 6 files changed, 198 deletions(-) delete mode 100755 debian/changelog delete mode 100755 debian/control delete mode 100755 debian/copyright delete mode 100755 debian/rules delete mode 100755 debian/source/format delete mode 100755 debian/watch diff --git a/debian/changelog b/debian/changelog deleted file mode 100755 index f06dc59..0000000 --- a/debian/changelog +++ /dev/null @@ -1,115 +0,0 @@ -ukui-menu (3.1.1-ok4~1020) yangtze; urgency=medium - - * close-cd #129225【开始菜单】【PC】在列表顶部或底部继续触摸拖动概率性出现图标缺失情况,再次滑动显示正常(1/10) - - -- lixueman Thu, 20 Oct 2022 09:11:06 +0800 - -ukui-menu (3.1.1-ok4~1012) yangtze; urgency=medium - - * close-cd #116176 【设计】【开始菜单】【浅色模式】底板缺少描边及阴影 - - -- lixueman Wed, 12 Oct 2022 11:14:50 +0800 - -ukui-menu (3.1.1-ok4~0920) yangtze; urgency=medium - - * 任务:开始菜单工具提示内容优化(收藏&最近 区域),增加路径提示 - - -- lixueman Tue, 20 Sep 2022 09:04:27 +0800 - -ukui-menu (3.1.1-ok4~0913) yangtze; urgency=medium - - * close-cd #125158 【开始菜单】切换全屏时动画显示不太流畅 - * close-cd #133399 【开始菜单】【PC】只有一个用户,开始菜单右键电源按钮存在切换用户选项 - * 添加版权信息 - * 修改规范性问题 - - -- lixueman Tue, 13 Sep 2022 08:40:10 +0800 - -ukui-menu (3.1.1-ok4~0907) yangtze; urgency=medium - - * close-cd #125158 【开始菜单】切换全屏时动画显示不太流畅 - * close-cd #133399 【开始菜单】【PC】只有一个用户,开始菜单右键电源按钮存在切换用户选项 - * 添加版权信息 - - -- lixueman Wed, 07 Sep 2022 14:12:53 +0800 - -ukui-menu (3.1.1-ok4~0831) yangtze; urgency=medium - - * close-cd # 131373 【wayland】【软件更新器】点击打开软件更新器后,开始菜单过6s左右才退出; - - -- lixueman Wed, 31 Aug 2022 00:52:08 +0800 - -ukui-menu (3.1.1-ok4~0818) yangtze; urgency=medium - - * close-cd #125159 修改全屏下固定到收藏不生效问题 - * close-cd #130911 【开始菜单】【PC】最大化后无法上下滑动翻页 - - -- lixueman Thu, 18 Aug 2022 11:19:35 +0800 - -ukui-menu (3.1.1-ok4~0727) yangtze; urgency=medium - - * 增加开始菜单藏文翻译 - * 调整点击应用时窗口隐藏时机 - * 修改分类下拉选择框宽度 - - -- lixueman Wed, 27 Jul 2022 20:32:11 +0800 - -ukui-menu (3.1.1-ok4~0725) yangtze; urgency=medium - - * 解决平板模式下win键可以打开开始菜单问题 - - -- lixueman Mon, 25 Jul 2022 09:15:22 +0800 - -ukui-menu (3.1.1-ok4~0721.1) yangtze; urgency=medium - - * 解决了强调色修改后,搜索框未及时刷新问题 - - -- lixueman Thu, 21 Jul 2022 15:34:09 +0800 - -ukui-menu (3.1.1-ok4~0721) yangtze; urgency=medium - - * close-cd #130526 修改搜索框和收藏最近按钮高亮色 - * close-cd #130514 全屏菜单的滑块透明度修改 - * close-cd #130485 修改字母集导航页禁用按钮样式 - * close-cd #130477 修改功能集导航页禁用按钮样式 - - -- kylin Thu, 21 Jul 2022 13:51:42 +0800 - -ukui-menu (3.1.1-ok4~0718) yangtze; urgency=medium - - * close-cd #127740 修复wayland下默认全屏切换动画位置异常,不显示动画 - * close-cd #129213 解决开始菜单点击屏幕键盘后延迟退出问题 - * close-cd #128764 增加搜索按下键切换焦点至搜索结果页;全屏增加字符输入直接切换搜索框 - * close-cd #128492,解决字母和功能分类固定到所有软件未置顶问题 - - -- lixueman Mon, 18 Jul 2022 15:09:23 +0800 - -ukui-menu (3.1.1-ok4~0712) yangtze; urgency=medium - - * close-cd #128498 - 修复【wayland】【开始菜单】多次点击tab键和回车键后,开始菜单点不开问题 - - -- lixueman Tue, 12 Jul 2022 16:11:49 +0800 - -ukui-menu (3.1.1-ok4~0708) yangtze; urgency=medium - - * 调整全屏窗口初始化代码结构 - * 增加全屏开始菜单分类选择下拉按钮动画效果 - * 增加全屏开始菜单点击空白区域退出功能 - * 固定全屏电源右键菜单位置 - - -- lixueman Fri, 08 Jul 2022 11:25:23 +0800 - -ukui-menu (3.1.1-ok4~0623) yangtze; urgency=medium - - * 调整QGuiApplication::platformName()调用时机 - * 增加全屏窗口显示时位置设定 - * 合入app-manager接口 - - -- lixueman Wed, 22 Jun 2022 11:22:58 +0800 - -ukui-menu (3.1.1-ok1) yangtze; urgency=medium - - * 版本号规范化 - - -- Xie Wei Fri, 06 May 2022 17:54:45 +0800: diff --git a/debian/control b/debian/control deleted file mode 100755 index b845cb7..0000000 --- a/debian/control +++ /dev/null @@ -1,44 +0,0 @@ -Source: ukui-menu -Section: x11 -Priority: optional -Maintainer: Kylin Team -Uploaders: Aron Xu , - handsome_feng -Build-Depends: debhelper-compat (=12), - qtbase5-dev, - libqt5svg5-dev, - libqt5x11extras5-dev, - libglib2.0-dev (>= 2.36), - libgsettings-qt-dev, - qttools5-dev-tools, - libbamf3-dev, - libkf5windowsystem-dev, - libuchardet-dev, - libukui-log4qt-dev, - libxtst-dev, - libx11-dev, - libukui-common0, - libukui-common-dev, - libpeony-dev, - libkysdk-waylandhelper-dev -Standards-Version: 4.5.0 -Rules-Requires-Root: no -Homepage: https://github.com/ukui/ukui-menu -Vcs-Git: https://github.com/ukui/ukui-menu -Vcs-Browser: https://github.com/ukui/ukui-menu - -Package: ukui-menu -Architecture: any -Depends: ${shlibs:Depends}, - ${misc:Depends}, - accountsservice, - libgsettings-qt1, - libqt5x11extras5, - bamfdaemon, - libkysdk-waylandhelper -Suggests:kylin-status-manager -Description: Advanced ukui menu - UKUI menu provides start menu development library and advanced - graphical user interface. - . - The package contains executable file. diff --git a/debian/copyright b/debian/copyright deleted file mode 100755 index 3a0edea..0000000 --- a/debian/copyright +++ /dev/null @@ -1,29 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: ukui-menu -Upstream-Contact: liuhao -Source: https://github.com/ukui/ukui-menu - -Files: * -Copyright: 2019 Tianjin KYLIN Information Technology Co., Ltd. -License: GPL-3.0+ - -Files: debian/* -Copyright: 2019 liuhao -License: GPL-3.0+ - -License: GPL-3.0+ - 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 of the License, or - (at your option) any later version. - . - This package 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 . - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 95cf77f..0000000 --- a/debian/rules +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/make -f - -export DEB_BUILD_MAINT_OPTIONS = hardening=+all -export QT_SELECT := qt5 - -%: - dh $@ diff --git a/debian/source/format b/debian/source/format deleted file mode 100755 index 89ae9db..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/debian/watch b/debian/watch deleted file mode 100755 index e685515..0000000 --- a/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=4 -https://github.com/ukui/ukui-menu/releases .*/ukui-menu_(\d\S+)\.orig\.tar\.gz From 28ee855a99bd367c16a17e4aa91869b60c64d15e Mon Sep 17 00:00:00 2001 From: lixueman Date: Fri, 21 Oct 2022 17:36:45 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E6=81=A2=E5=A4=8Ddebian=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 115 +++++++++++++++++++++++++++++++++++++++++++ debian/control | 44 +++++++++++++++++ debian/copyright | 29 +++++++++++ debian/rules | 7 +++ debian/source/format | 1 + debian/watch | 2 + 6 files changed, 198 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/rules create mode 100644 debian/source/format create mode 100644 debian/watch diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..f06dc59 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,115 @@ +ukui-menu (3.1.1-ok4~1020) yangtze; urgency=medium + + * close-cd #129225【开始菜单】【PC】在列表顶部或底部继续触摸拖动概率性出现图标缺失情况,再次滑动显示正常(1/10) + + -- lixueman Thu, 20 Oct 2022 09:11:06 +0800 + +ukui-menu (3.1.1-ok4~1012) yangtze; urgency=medium + + * close-cd #116176 【设计】【开始菜单】【浅色模式】底板缺少描边及阴影 + + -- lixueman Wed, 12 Oct 2022 11:14:50 +0800 + +ukui-menu (3.1.1-ok4~0920) yangtze; urgency=medium + + * 任务:开始菜单工具提示内容优化(收藏&最近 区域),增加路径提示 + + -- lixueman Tue, 20 Sep 2022 09:04:27 +0800 + +ukui-menu (3.1.1-ok4~0913) yangtze; urgency=medium + + * close-cd #125158 【开始菜单】切换全屏时动画显示不太流畅 + * close-cd #133399 【开始菜单】【PC】只有一个用户,开始菜单右键电源按钮存在切换用户选项 + * 添加版权信息 + * 修改规范性问题 + + -- lixueman Tue, 13 Sep 2022 08:40:10 +0800 + +ukui-menu (3.1.1-ok4~0907) yangtze; urgency=medium + + * close-cd #125158 【开始菜单】切换全屏时动画显示不太流畅 + * close-cd #133399 【开始菜单】【PC】只有一个用户,开始菜单右键电源按钮存在切换用户选项 + * 添加版权信息 + + -- lixueman Wed, 07 Sep 2022 14:12:53 +0800 + +ukui-menu (3.1.1-ok4~0831) yangtze; urgency=medium + + * close-cd # 131373 【wayland】【软件更新器】点击打开软件更新器后,开始菜单过6s左右才退出; + + -- lixueman Wed, 31 Aug 2022 00:52:08 +0800 + +ukui-menu (3.1.1-ok4~0818) yangtze; urgency=medium + + * close-cd #125159 修改全屏下固定到收藏不生效问题 + * close-cd #130911 【开始菜单】【PC】最大化后无法上下滑动翻页 + + -- lixueman Thu, 18 Aug 2022 11:19:35 +0800 + +ukui-menu (3.1.1-ok4~0727) yangtze; urgency=medium + + * 增加开始菜单藏文翻译 + * 调整点击应用时窗口隐藏时机 + * 修改分类下拉选择框宽度 + + -- lixueman Wed, 27 Jul 2022 20:32:11 +0800 + +ukui-menu (3.1.1-ok4~0725) yangtze; urgency=medium + + * 解决平板模式下win键可以打开开始菜单问题 + + -- lixueman Mon, 25 Jul 2022 09:15:22 +0800 + +ukui-menu (3.1.1-ok4~0721.1) yangtze; urgency=medium + + * 解决了强调色修改后,搜索框未及时刷新问题 + + -- lixueman Thu, 21 Jul 2022 15:34:09 +0800 + +ukui-menu (3.1.1-ok4~0721) yangtze; urgency=medium + + * close-cd #130526 修改搜索框和收藏最近按钮高亮色 + * close-cd #130514 全屏菜单的滑块透明度修改 + * close-cd #130485 修改字母集导航页禁用按钮样式 + * close-cd #130477 修改功能集导航页禁用按钮样式 + + -- kylin Thu, 21 Jul 2022 13:51:42 +0800 + +ukui-menu (3.1.1-ok4~0718) yangtze; urgency=medium + + * close-cd #127740 修复wayland下默认全屏切换动画位置异常,不显示动画 + * close-cd #129213 解决开始菜单点击屏幕键盘后延迟退出问题 + * close-cd #128764 增加搜索按下键切换焦点至搜索结果页;全屏增加字符输入直接切换搜索框 + * close-cd #128492,解决字母和功能分类固定到所有软件未置顶问题 + + -- lixueman Mon, 18 Jul 2022 15:09:23 +0800 + +ukui-menu (3.1.1-ok4~0712) yangtze; urgency=medium + + * close-cd #128498 + 修复【wayland】【开始菜单】多次点击tab键和回车键后,开始菜单点不开问题 + + -- lixueman Tue, 12 Jul 2022 16:11:49 +0800 + +ukui-menu (3.1.1-ok4~0708) yangtze; urgency=medium + + * 调整全屏窗口初始化代码结构 + * 增加全屏开始菜单分类选择下拉按钮动画效果 + * 增加全屏开始菜单点击空白区域退出功能 + * 固定全屏电源右键菜单位置 + + -- lixueman Fri, 08 Jul 2022 11:25:23 +0800 + +ukui-menu (3.1.1-ok4~0623) yangtze; urgency=medium + + * 调整QGuiApplication::platformName()调用时机 + * 增加全屏窗口显示时位置设定 + * 合入app-manager接口 + + -- lixueman Wed, 22 Jun 2022 11:22:58 +0800 + +ukui-menu (3.1.1-ok1) yangtze; urgency=medium + + * 版本号规范化 + + -- Xie Wei Fri, 06 May 2022 17:54:45 +0800: diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b845cb7 --- /dev/null +++ b/debian/control @@ -0,0 +1,44 @@ +Source: ukui-menu +Section: x11 +Priority: optional +Maintainer: Kylin Team +Uploaders: Aron Xu , + handsome_feng +Build-Depends: debhelper-compat (=12), + qtbase5-dev, + libqt5svg5-dev, + libqt5x11extras5-dev, + libglib2.0-dev (>= 2.36), + libgsettings-qt-dev, + qttools5-dev-tools, + libbamf3-dev, + libkf5windowsystem-dev, + libuchardet-dev, + libukui-log4qt-dev, + libxtst-dev, + libx11-dev, + libukui-common0, + libukui-common-dev, + libpeony-dev, + libkysdk-waylandhelper-dev +Standards-Version: 4.5.0 +Rules-Requires-Root: no +Homepage: https://github.com/ukui/ukui-menu +Vcs-Git: https://github.com/ukui/ukui-menu +Vcs-Browser: https://github.com/ukui/ukui-menu + +Package: ukui-menu +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends}, + accountsservice, + libgsettings-qt1, + libqt5x11extras5, + bamfdaemon, + libkysdk-waylandhelper +Suggests:kylin-status-manager +Description: Advanced ukui menu + UKUI menu provides start menu development library and advanced + graphical user interface. + . + The package contains executable file. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..3a0edea --- /dev/null +++ b/debian/copyright @@ -0,0 +1,29 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: ukui-menu +Upstream-Contact: liuhao +Source: https://github.com/ukui/ukui-menu + +Files: * +Copyright: 2019 Tianjin KYLIN Information Technology Co., Ltd. +License: GPL-3.0+ + +Files: debian/* +Copyright: 2019 liuhao +License: GPL-3.0+ + +License: GPL-3.0+ + 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 of the License, or + (at your option) any later version. + . + This package 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 . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/rules b/debian/rules new file mode 100644 index 0000000..95cf77f --- /dev/null +++ b/debian/rules @@ -0,0 +1,7 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +export QT_SELECT := qt5 + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..e685515 --- /dev/null +++ b/debian/watch @@ -0,0 +1,2 @@ +version=4 +https://github.com/ukui/ukui-menu/releases .*/ukui-menu_(\d\S+)\.orig\.tar\.gz From ed36dd3868639ebcafdf166419624fa0bf1c1abf Mon Sep 17 00:00:00 2001 From: lixueman Date: Mon, 24 Oct 2022 16:17:03 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=A0=8F=E9=AB=98=E5=BA=A6=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?;=E4=BF=AE=E6=94=B9=E5=85=A8=E5=B1=8F=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=AE=9A=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Widget/full_commonuse_widget.cpp | 4 +++- src/UserInterface/mainwindow.cpp | 8 ++++++- src/UtilityFunction/utility.cpp | 23 ++++++++++--------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/UserInterface/Widget/full_commonuse_widget.cpp b/src/UserInterface/Widget/full_commonuse_widget.cpp index 6adab1a..adbce44 100755 --- a/src/UserInterface/Widget/full_commonuse_widget.cpp +++ b/src/UserInterface/Widget/full_commonuse_widget.cpp @@ -170,7 +170,7 @@ void FullCommonUseWidget::resizeScrollAreaControls() rowcount = listview->model()->rowCount() / dividend; } - listview->setFixedSize(m_listView->width(), listview->gridSize().height() * rowcount); + listview->setFixedSize(Style::m_applistAreaWidth, listview->gridSize().height() * rowcount); m_scrollArea->widget()->setFixedSize(listview->size()); } @@ -275,11 +275,13 @@ void FullCommonUseWidget::updateListView() void FullCommonUseWidget::repaintWidget() { m_scrollArea->setFixedSize(Style::m_applistAreaWidth, Style::m_applistWidHeight); + m_scrollArea->setWidgetResizable(true); m_scrollAreaWidLayout->removeWidget(m_listView); m_listView->setParent(nullptr); delete m_listView; initAppListWidget(); fillAppList(); + m_scrollAreaWid->adjustSize(); m_scrollAreaWidHeight = m_scrollAreaWid->height(); initVerticalScrollBar(); on_setAreaScrollBarValue(0); diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp index 0c07b15..42a5e78 100755 --- a/src/UserInterface/mainwindow.cpp +++ b/src/UserInterface/mainwindow.cpp @@ -1382,8 +1382,14 @@ void MainWindow::repaintWidget() int y = Style::m_primaryScreenY; int width = Style::m_availableScreenWidth; int height = Style::m_availableScreenHeight; + setMinWindowPos(); - m_fullWindow->move(x, y); + + if (g_platform.startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) { + kdk::WindowManager::setGeometry(m_fullWindow->windowHandle(), QRect(x, y, width, height)); + } else { + m_fullWindow->move(x, y); + } m_fullWindow->setFixedSize(width, height); m_fullWindow->repaintWidget(); } diff --git a/src/UtilityFunction/utility.cpp b/src/UtilityFunction/utility.cpp index c7b63e7..1873136 100755 --- a/src/UtilityFunction/utility.cpp +++ b/src/UtilityFunction/utility.cpp @@ -138,23 +138,24 @@ QVariantList getScreenGeometryList() QRect rect; rect = qApp->primaryScreen()->geometry(); int panelSize = 0; - int position = 0; + int panelPosition = 0; QVariantList list; list.clear(); - QDBusInterface iface(DBUS_NAME, - DBUS_PATH, - DBUS_INTERFACE, - QDBusConnection::sessionBus()); - QDBusReply reply = iface.call("GetPrimaryScreenPhysicalGeometry"); - if (reply.isValid()) { - panelSize = reply.value().at(4).toInt(); - position = reply.value().at(5).toInt(); + if (QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit())) { + QGSettings gsetting(QString("org.ukui.panel.settings").toLocal8Bit()); + if (gsetting.keys().contains("panelposition")) { + panelPosition = gsetting.get("panelposition").toInt(); + } + + if (gsetting.keys().contains("panelsize")) { + panelSize = gsetting.get("panelsize").toInt(); + } } QList posIndex; - switch (position) { + switch (panelPosition) { case BOTTOM: posIndex = {0, 0, 0, -1}; break; @@ -173,7 +174,7 @@ QVariantList getScreenGeometryList() list.append(rect.width() + posIndex[2] * panelSize); list.append(rect.height() + posIndex[3] * panelSize); list.append(panelSize); - list.append(position); + list.append(panelPosition); return list; } From 86afee1420981f23421e29b6825c6f4b3f5cf0fa Mon Sep 17 00:00:00 2001 From: lixueman Date: Mon, 24 Oct 2022 17:03:20 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E6=94=BE=E5=BC=80=E5=AF=B9=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=99=A8=E7=9A=84=E5=B1=8F=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BackProcess/Interface/ukuimenuinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BackProcess/Interface/ukuimenuinterface.cpp b/src/BackProcess/Interface/ukuimenuinterface.cpp index 7879cc0..d7438fb 100755 --- a/src/BackProcess/Interface/ukuimenuinterface.cpp +++ b/src/BackProcess/Interface/ukuimenuinterface.cpp @@ -375,7 +375,7 @@ QStringList UkuiMenuInterface::getDesktopFilePath() m_filePathList.removeAll("/usr/share/applications/kylin-io-monitor.desktop"); m_filePathList.removeAll("/usr/share/applications/wps-office-uninstall.desktop"); m_filePathList.removeAll("/usr/share/applications/wps-office-misc.desktop"); - m_filePathList.removeAll("/usr/share/applications/kylin-installer.desktop"); +// m_filePathList.removeAll("/usr/share/applications/kylin-installer.desktop"); QStringList desktopList; for (int i = 0; i < m_filePathList.count(); ++i) { From d3e98857c9a9653c8da33f6576025092509cf3ec Mon Sep 17 00:00:00 2001 From: lixueman Date: Mon, 24 Oct 2022 17:21:45 +0800 Subject: [PATCH 12/12] update changelog --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index f06dc59..428f626 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +ukui-menu (3.1.1-ok4~1024) yangtze; urgency=medium + + * close-cd #I5SPVS 移动面板后使用win键打开菜单栏位置不对 + * close-cd #I5RF2N 开始菜单展开后没有置顶,也没有全屏 + * close-cd #I5R2AO 开始菜单放大后应用图标缺失、电源按钮被任务栏挡住,且有小概率未正确全屏 + + -- lixueman Mon, 24 Oct 2022 17:10:56 +0800 + ukui-menu (3.1.1-ok4~1020) yangtze; urgency=medium * close-cd #129225【开始菜单】【PC】在列表顶部或底部继续触摸拖动概率性出现图标缺失情况,再次滑动显示正常(1/10)