diff -Nru dtkwidget-5.4.36/debian/changelog dtkwidget-5.5.17.1/debian/changelog --- dtkwidget-5.4.36/debian/changelog 2021-09-17 15:48:26.000000000 +0000 +++ dtkwidget-5.5.17.1/debian/changelog 2021-09-18 09:49:15.000000000 +0000 @@ -1,3 +1,9 @@ +dtkwidget (5.5.17.1-1) impish; urgency=medium + + * New upstream release. + + -- Arun Kumar Pariyar Sat, 18 Sep 2021 15:34:15 +0545 + dtkwidget (5.4.36-1) impish; urgency=medium * New upstream release. diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_button_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_button_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_button_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_button_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - icon_button/normal - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Dial_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Dial_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Dial_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Dial_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - - - icon_Dial/normal - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Dialog_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Dialog_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Dialog_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Dialog_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - - - icon_Dialog/normal - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_edit_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_edit_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_edit_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_edit_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - icon_edit/normal - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Layout_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Layout_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Layout_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Layout_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - - - icon_Layout/normal - - - - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_LCDNumber_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_LCDNumber_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_LCDNumber_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_LCDNumber_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ - - - icon_LCDNumber/normal - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_ListView_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_ListView_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_ListView_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_ListView_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - - - icon_ListView/normal - - - - - - - - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_menu_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_menu_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_menu_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_menu_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ - - - icon_menu/normal - - - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_ProgressBar_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_ProgressBar_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_ProgressBar_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_ProgressBar_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - icon_ProgressBar/normal - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_RubberBand_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_RubberBand_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_RubberBand_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_RubberBand_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - - - icon_RubberBand/normal - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_ScrollBar_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_ScrollBar_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_ScrollBar_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_ScrollBar_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - icon_ScrollBar/normal - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_slider_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_slider_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_slider_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_slider_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ - - - icon_slider/normal - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Spinner_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Spinner_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Spinner_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Spinner_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - - - icon_Spinner/normal - - - - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Tooltip_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Tooltip_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Tooltip_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Tooltip_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - - - icon_Tooltip/normal - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Widget_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Widget_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Widget_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Widget_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - - - icon_Widget/normal - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Window_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Window_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/actions/icon_Window_16px.svg 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/actions/icon_Window_16px.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - - - icon_Window/normal - - - - - - - - - \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_button_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_button_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_button_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_button_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,7 @@ + + + icon_button/normal + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Dial_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Dial_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Dial_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Dial_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,9 @@ + + + icon_Dial/normal + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Dialog_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Dialog_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Dialog_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Dialog_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,9 @@ + + + icon_Dialog/normal + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_edit_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_edit_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_edit_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_edit_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,7 @@ + + + icon_edit/normal + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Layout_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Layout_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Layout_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Layout_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,14 @@ + + + icon_Layout/normal + + + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_LCDNumber_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_LCDNumber_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_LCDNumber_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_LCDNumber_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,26 @@ + + + icon_LCDNumber/normal + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_ListView_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_ListView_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_ListView_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_ListView_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,18 @@ + + + icon_ListView/normal + + + + + + + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_menu_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_menu_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_menu_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_menu_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,13 @@ + + + icon_menu/normal + + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_ProgressBar_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_ProgressBar_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_ProgressBar_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_ProgressBar_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,7 @@ + + + icon_ProgressBar/normal + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_RubberBand_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_RubberBand_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_RubberBand_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_RubberBand_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,11 @@ + + + icon_RubberBand/normal + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_ScrollBar_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_ScrollBar_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_ScrollBar_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_ScrollBar_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,7 @@ + + + icon_ScrollBar/normal + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_slider_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_slider_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_slider_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_slider_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,7 @@ + + + icon_slider/normal + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Spinner_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Spinner_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Spinner_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Spinner_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,14 @@ + + + icon_Spinner/normal + + + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Tooltip_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Tooltip_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Tooltip_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Tooltip_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,11 @@ + + + icon_Tooltip/normal + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Widget_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Widget_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Widget_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Widget_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,9 @@ + + + icon_Widget/normal + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Window_16px.svg dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Window_16px.svg --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/texts/icon_Window_16px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/texts/icon_Window_16px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,12 @@ + + + icon_Window/normal + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/theme-icons.qrc dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/theme-icons.qrc --- dtkwidget-5.4.36/examples/dwidget-examples/collections/icons/theme-icons.qrc 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/icons/theme-icons.qrc 2021-06-30 10:52:09.000000000 +0000 @@ -1,20 +1,20 @@ - actions/icon_button_16px.svg - actions/icon_Dial_16px.svg - actions/icon_Dialog_16px.svg - actions/icon_edit_16px.svg - actions/icon_Layout_16px.svg - actions/icon_LCDNumber_16px.svg - actions/icon_ListView_16px.svg - actions/icon_menu_16px.svg - actions/icon_ProgressBar_16px.svg - actions/icon_RubberBand_16px.svg - actions/icon_ScrollBar_16px.svg - actions/icon_slider_16px.svg - actions/icon_Spinner_16px.svg - actions/icon_Tooltip_16px.svg - actions/icon_Widget_16px.svg - actions/icon_Window_16px.svg + texts/icon_button_16px.svg + texts/icon_Dial_16px.svg + texts/icon_Dialog_16px.svg + texts/icon_edit_16px.svg + texts/icon_Layout_16px.svg + texts/icon_LCDNumber_16px.svg + texts/icon_ListView_16px.svg + texts/icon_menu_16px.svg + texts/icon_ProgressBar_16px.svg + texts/icon_RubberBand_16px.svg + texts/icon_ScrollBar_16px.svg + texts/icon_slider_16px.svg + texts/icon_Spinner_16px.svg + texts/icon_Tooltip_16px.svg + texts/icon_Widget_16px.svg + texts/icon_Window_16px.svg diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/main.cpp dtkwidget-5.5.17.1/examples/dwidget-examples/collections/main.cpp --- dtkwidget-5.4.36/examples/dwidget-examples/collections/main.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/main.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -46,6 +46,7 @@ if (!DGuiApplicationHelper::setSingleInstance("deepin-tool-kit-examples")) { qDebug() << "another instance is running!!"; + return 0; } a->setApplicationName("dtk-example"); @@ -55,7 +56,6 @@ MainWindow w; w.show(); - w.titlebar()->setDisableFlags(Qt::WindowMinimizeButtonHint); Dtk::Widget::moveToCenter(&w); diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/mainwindow.cpp dtkwidget-5.5.17.1/examples/dwidget-examples/collections/mainwindow.cpp --- dtkwidget-5.4.36/examples/dwidget-examples/collections/mainwindow.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/mainwindow.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -118,6 +118,9 @@ }); connect(titlebar->menu(), &QMenu::triggered, this, &MainWindow::menuItemInvoked); + titlebar->setDisableFlags(Qt::WindowMinimizeButtonHint + | Qt::WindowMaximizeButtonHint + | Qt::WindowSystemMenuHint); titlebar->setAutoHideOnFullscreen(true); } diff -Nru dtkwidget-5.4.36/examples/dwidget-examples/collections/windowexample.cpp dtkwidget-5.5.17.1/examples/dwidget-examples/collections/windowexample.cpp --- dtkwidget-5.4.36/examples/dwidget-examples/collections/windowexample.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/examples/dwidget-examples/collections/windowexample.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ { DTitlebar::paintEvent(e); QPainter p(this); - const DPalette &dp = DApplicationHelper::instance()->palette(this); + const DPalette &dp = DPaletteHelper::instance()->palette(this); p.save(); p.setPen(QPen(dp.frameBorder(), 2)); @@ -81,7 +81,7 @@ { DMainWindow::paintEvent(e); QPainter p(this); - const DPalette &dp = DApplicationHelper::instance()->palette(this); + const DPalette &dp = DPaletteHelper::instance()->palette(this); p.save(); p.setPen(QPen(dp.frameBorder(), 2)); @@ -117,7 +117,7 @@ void paintEvent(QPaintEvent *e) override { QPainter p(this); - const DPalette &dp = DApplicationHelper::instance()->palette(this); + const DPalette &dp = DPaletteHelper::instance()->palette(this); p.setPen(QPen(dp.frameBorder(), 2)); DDrawUtils::drawRoundedRect(&p, rect().adjusted(0 , 0, -1 , -1), 16, 16, @@ -282,63 +282,6 @@ return 572; } -// 构造指定类型的Tabbar -template -T* generateTabBar(const QTabBar::Shape shape, QWidget* parent = nullptr) -{ - auto tabbar = new T(parent); - - tabbar->addTab(""); - tabbar->setTabIcon(0, QIcon(":/images/logo_icon.svg")); - tabbar->addTab("标签二"); - tabbar->addTab("标签三"); - tabbar->addTab("标签四"); - tabbar->addTab("标签五"); - tabbar->addTab("标签六"); - tabbar->addTab("标签七"); - - tabbar->setShape(shape); - tabbar->setTabsClosable(true); - - return tabbar; -} - -// 测试DTabBar::setShape接口 -inline static QWidget* createTabBarSetShape(const QList& shapes, QWidget* parent) -{ - auto view = new QWidget(parent); - - auto layout = new QHBoxLayout(view); - layout->setSpacing(40); - - for (auto shape : shapes) { - auto *tabbar1 = generateTabBar(shape); - tabbar1->setEnabledEmbedStyle(false); - layout->addWidget(tabbar1, 0); - { - auto border = new QFrame(); - border->setFrameShape(QFrame::VLine); - border->setFrameShadow(QFrame::Sunken); - layout->addWidget(border); - } - auto *tabbar2 = generateTabBar(shape); - tabbar2->setEnabledEmbedStyle(true); - layout->addWidget(tabbar2, 0); - { - auto border = new QFrame(); - border->setFrameShape(QFrame::VLine); - border->setFrameShadow(QFrame::Sunken); - layout->addWidget(border); - } - - QObject::connect(tabbar1, &DTabBar::tabAddRequested, [tabbar1, tabbar2](){ - tabbar1->addTab(QString("Add Tab %1").arg(tabbar1->count())); - tabbar2->addTab(QString("Add Tab %1").arg(tabbar2->count())); - }); - } - return view; -} - DTabBarExample::DTabBarExample(QWidget *parent) : ExampleWindowInterface(parent) { @@ -376,10 +319,6 @@ layout->addWidget(tabbar1, 0, Qt::AlignCenter); layout->addSpacing(40); layout->addWidget(window, 0, Qt::AlignCenter); - layout->addSpacing(40); - layout->addWidget(createTabBarSetShape({QTabBar::RoundedWest, QTabBar::RoundedEast}, this), 0, Qt::AlignCenter); - layout->addSpacing(40); - layout->addWidget(createTabBarSetShape({QTabBar::TriangularWest, QTabBar::TriangularEast}, this), 0, Qt::AlignCenter); layout->addSpacing(70); layout->addWidget(label1, 0, Qt::AlignCenter); layout->addWidget(label2, 0, Qt::AlignCenter); @@ -409,7 +348,7 @@ int DTabBarExample::getFixedHeight() const { - return 1880; + return 1080; } DSizegripExample::DSizegripExample(QWidget *parent) diff -Nru dtkwidget-5.4.36/rpm/dtkwidget.spec dtkwidget-5.5.17.1/rpm/dtkwidget.spec --- dtkwidget-5.4.36/rpm/dtkwidget.spec 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/rpm/dtkwidget.spec 2021-06-30 10:52:09.000000000 +0000 @@ -1,5 +1,5 @@ Name: dtkwidget -Version: 5.4.3 +Version: 5.4.3+rpm Release: 1%{?dist} Summary: Deepin tool kit widget modules License: LGPLv3+ diff -Nru dtkwidget-5.4.36/src/src.pro dtkwidget-5.5.17.1/src/src.pro --- dtkwidget-5.4.36/src/src.pro 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/src.pro 2021-06-30 10:52:09.000000000 +0000 @@ -19,7 +19,7 @@ linux* { QT += x11extras dbus #LIBS += -lcups - ###(zccrs): use load(dtk_qmake), dtkcore > 2.0.9 + ###(zccrs): use load(dtk_qmake), dtkcore5.5 > 2.0.9 ARCH = $$QMAKE_HOST.arch isEqual(ARCH, sw_64) | isEqual(ARCH, mips64) | isEqual(ARCH, mips32) { DEFINES += FORCE_RASTER_WIDGETS @@ -78,3 +78,7 @@ load(dtk_cmake) load(dtk_module) + +load(dtk_multiversion) +dtkBuildMultiVersion(5.5) +load(dtk_install_multiversion) diff -Nru dtkwidget-5.4.36/src/widgets/assets/icons/dark/icons/titlebar_more_50px.svg dtkwidget-5.5.17.1/src/widgets/assets/icons/dark/icons/titlebar_more_50px.svg --- dtkwidget-5.4.36/src/widgets/assets/icons/dark/icons/titlebar_more_50px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/assets/icons/dark/icons/titlebar_more_50px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,12 @@ + + + more_dark + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/src/widgets/assets/icons/dtk-icon-theme.qrc dtkwidget-5.5.17.1/src/widgets/assets/icons/dtk-icon-theme.qrc --- dtkwidget-5.4.36/src/widgets/assets/icons/dtk-icon-theme.qrc 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/assets/icons/dtk-icon-theme.qrc 2021-06-30 10:52:09.000000000 +0000 @@ -36,5 +36,7 @@ light/icons/print_previewscale_18px.svg dark/icons/dorpper_normal_32px.svg light/icons/dorpper_normal_32px.svg + dark/icons/titlebar_more_50px.svg + light/icons/titlebar_more_50px.svg diff -Nru dtkwidget-5.4.36/src/widgets/assets/icons/light/icons/titlebar_more_50px.svg dtkwidget-5.5.17.1/src/widgets/assets/icons/light/icons/titlebar_more_50px.svg --- dtkwidget-5.4.36/src/widgets/assets/icons/light/icons/titlebar_more_50px.svg 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/assets/icons/light/icons/titlebar_more_50px.svg 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,20 @@ + + + menu_normal + + + + + + + + + + + + + + + + + \ No newline at end of file diff -Nru dtkwidget-5.4.36/src/widgets/dabstractdialog.cpp dtkwidget-5.5.17.1/src/widgets/dabstractdialog.cpp --- dtkwidget-5.4.36/src/widgets/dabstractdialog.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dabstractdialog.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -34,6 +34,9 @@ #include "dapplication.h" #include "dblureffectwidget.h" +#include +#include + DWIDGET_BEGIN_NAMESPACE DAbstractDialogPrivate::DAbstractDialogPrivate(DAbstractDialog *qq): @@ -59,6 +62,12 @@ bgBlurWidget->setFull(true); bgBlurWidget->setMaskColor(DBlurEffectWidget::AutoColor); bgBlurWidget->setMaskAlpha(204); // 80% + + if (!DWindowManagerHelper::instance()->hasBlurWindow() + && DGuiApplicationHelper::instance()->isTabletEnvironment()) { + blurIfPossible = false; + } + bgBlurWidget->setBlurEnabled(blurIfPossible); q->setAttribute(Qt::WA_TranslucentBackground, blurIfPossible); } else { diff -Nru dtkwidget-5.4.36/src/widgets/dapplication.cpp dtkwidget-5.5.17.1/src/widgets/dapplication.cpp --- dtkwidget-5.4.36/src/widgets/dapplication.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dapplication.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -149,7 +150,12 @@ q, cancelNotification); #endif - QApplication::setStyle("chameleon"); + // If not in dde and not use deepin platform theme, force set style to chameleon. + if (!DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::Attribute::IsDeepinPlatformTheme) && + !DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::Attribute::IsDeepinEnvironment)) { + DApplication::setStyle("chameleon"); + q->setPalette(DGuiApplicationHelper::instance()->applicationPalette()); + } } DApplicationPrivate::~DApplicationPrivate() @@ -377,6 +383,120 @@ } } +void DApplicationPrivate::doAcclimatizeVirtualKeyboard(QWidget *window, QWidget *widget, bool allowResizeContentsMargins) +{ + // 如果新激活的输入窗口跟已经在处理中的窗口不一致,则恢复旧窗口的状态 + if (activeInputWindow && activeInputWindow != window) { + activeInputWindow->setContentsMargins(activeInputWindowContentsMargins); + activeInputWindow = nullptr; + } + + auto platform_context = QGuiApplicationPrivate::platformIntegration()->inputContext(); + auto input_method = QGuiApplication::inputMethod(); + // 先检查输入面板的状态 + if (!platform_context->inputMethodAccepted() || !input_method->isVisible()) { + if (activeInputWindow) { + activeInputWindow->setContentsMargins(activeInputWindowContentsMargins); + activeInputWindow = nullptr; + } + + return; + } + + // 如果输入控件的主窗口处于未激活状态则忽略 + if (!window->isActiveWindow()) + return; + + // 虚拟键盘相对于当前窗口的geometry + const QRectF &kRect = input_method->keyboardRectangle().translated(-window->mapToGlobal(QPoint(0, 0))); + if (kRect.isEmpty() || !kRect.isValid()) + return; + + // 记录待处理窗口的数据 + if (!activeInputWindow) { + activeInputWindow = window; + activeInputWindowContentsMargins = window->contentsMargins(); + lastContentsMargins = qMakePair(0, 0); + } + + // 可以被压缩的高度 + int resizeableHeight = lastContentsMargins.first; + // 将要平移的距离 + int panValue = 0; + + const QRectF &cRect = input_method->cursorRectangle(); + const QRectF &iRect = input_method->inputItemClipRectangle(); + const QRectF &wRect = window->rect().marginsRemoved(activeInputWindowContentsMargins); + + if (allowResizeContentsMargins) { + // 判断输入控件是否处于一个可滚动区域中 + QWidget *scrollWidget = widget; + while (scrollWidget && !qobject_cast(scrollWidget)) { + scrollWidget = scrollWidget->parentWidget(); + } + + if (QAbstractScrollArea *scrollArea = qobject_cast(scrollWidget)) { + resizeableHeight = scrollArea->maximumViewportSize().height() + // 至少要保证可滚动区域的最小高度,以及光标的可显示区域 + - qMax(scrollArea->minimumHeight(), qRound(cRect.height())); + resizeableHeight = qMax(0, resizeableHeight); + } + } + + // 优先保证输入框下面的内容都能正常显示 + int shadowHeight = wRect.bottom() - kRect.top(); + if (shadowHeight > cRect.y()) { + // 如果窗口底部的内容必须要被遮挡,则优先保证能完整显示整个输入区域,且最低限度是要显示输入光标 + shadowHeight = qMin(cRect.y(), iRect.bottom() - kRect.top()); + } + // 如果输入区域没有被盖住则忽略 + if (shadowHeight <= 0) + return; + + // 更新需要平移的区域 + int resizeHeight = qMin(resizeableHeight, shadowHeight); + panValue = shadowHeight - resizeHeight; + + if (lastContentsMargins.first == resizeableHeight + && lastContentsMargins.second == panValue) { + return; + } + + // 记录本次的计算结果 + lastContentsMargins.first = resizeableHeight; + lastContentsMargins.second = panValue; + + // 更新窗口内容显示区域以确保虚拟键盘能正常显示 + window->setContentsMargins(0, -panValue, 0, resizeHeight + panValue); +} + +void DApplicationPrivate::acclimatizeVirtualKeyboardForFocusWidget(bool allowResizeContentsMargins) +{ + auto focus = QApplication::focusWidget(); + if (!focus) + return; + + for (auto window : acclimatizeVirtualKeyboardWindows) { + if (window->isAncestorOf(focus) + || (window->property("_dtk_NoTopLevelEnabled").toBool() // 非顶级窗口恢复虚拟键盘挤占空间 + && !qApp->inputMethod()->isVisible())) { + return doAcclimatizeVirtualKeyboard(window ,focus, allowResizeContentsMargins); + } + } +} + +void DApplicationPrivate::_q_panWindowContentsForVirtualKeyboard() +{ + acclimatizeVirtualKeyboardForFocusWidget(false); +} + +void DApplicationPrivate::_q_resizeWindowContentsForVirtualKeyboard() +{ + // TODO(zccrs): 暂时不支持压缩窗口高度适应虚拟键盘的模式 + // 需要做到ScrollArea中的输入控件能在改变窗口高度之后还处于可见状态 + acclimatizeVirtualKeyboardForFocusWidget(false); +} + bool DApplicationPrivate::isUserManualExists() { #ifdef Q_OS_LINUX @@ -1180,6 +1300,125 @@ } /** + * \~chinese @brief DApplication::acclimatizeVirtualKeyboard + * + * \~chinese 为窗口的可输入控件添加自动适应虚拟键盘输入法的功能。开启此功能后,当 + * \~chinese 监听到 \a QInputMethod::keyboardRectangleChanged 后,会判断当 + * \~chinese 前的可输入(不仅仅是处于焦点状态)控件是否为此 \a window 的子控件, + * \~chinese 如果是,则将通过 \a QWidget::setContentsMargins 更新 \a window + * \~chinese 的布局区域,以此确保可输入控件处于可见区域。如果可输入控件处于一个 + * \~chinese \a QAbstractScrollArea 中,将会压缩 \a window 的布局空间,促使 + * \~chinese 可滚动区域缩小,再使用 \a QAbstraceScrollArea::scrollContentsBy + * \~chinese 将可输入控件滚动到合适的区域,否则将直接把 \a 的内容向上移动为虚拟键盘 + * \~chinese 腾出空间。 + * \~chinese \note 在使用之前要确保窗口的 \a Qt::WA_LayoutOnEntireRect + * \~chinese \a 和 Qt::WA_ContentsMarginsRespectsSafeArea 都为 false + * \~chinese \param window 需是一个顶层窗口 + * \~chinese \sa QWidget::isTopLevel + * \~chinese \sa QWidget::setContentsMargins + * \~chinese \sa QInputMethod::cursorRectangle + * \~chinese \sa QInputMethod::inputItemClipRectangle + * \~chinese \sa QInputMethod::keyboardRectangle + * \~chinese \sa QAbstractScrollArea + */ +void DApplication::acclimatizeVirtualKeyboard(QWidget *window) +{ + Q_ASSERT(!window->property("_dtk_NoTopLevelEnabled").toBool() ? window->isTopLevel() : true + && !window->testAttribute(Qt::WA_LayoutOnEntireRect) + && !window->testAttribute(Qt::WA_ContentsMarginsRespectsSafeArea)); + + D_D(DApplication); + if (d->acclimatizeVirtualKeyboardWindows.contains(window)) + return; + + if (d->acclimatizeVirtualKeyboardWindows.isEmpty()) { + connect(this, SIGNAL(focusChanged(QWidget *, QWidget *)), + this, SLOT(_q_resizeWindowContentsForVirtualKeyboard()), + Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); + connect(inputMethod(), SIGNAL(keyboardRectangleChanged()), + this, SLOT(_q_resizeWindowContentsForVirtualKeyboard()), + Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); + connect(inputMethod(), SIGNAL(visibleChanged()), + this, SLOT(_q_resizeWindowContentsForVirtualKeyboard()), + Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); + connect(inputMethod(), SIGNAL(cursorRectangleChanged()), + this, SLOT(_q_panWindowContentsForVirtualKeyboard()), + Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); + connect(inputMethod(), SIGNAL(inputItemClipRectangleChanged()), + this, SLOT(_q_panWindowContentsForVirtualKeyboard()), + Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection)); + } + + d->acclimatizeVirtualKeyboardWindows << window; + + connect(window, &QWidget::destroyed, this, [this, window] { + this->ignoreVirtualKeyboard(window); + }); + + if (window->isAncestorOf(focusWidget())) { + d->doAcclimatizeVirtualKeyboard(window, focusWidget(), true); + } +} + +/** + * \~chinese @brief DApplication::ignoreVirtualKeyboard + * \~chinese 恢复到默认状态,将不会为虚拟键盘的环境做任何自适应操作 + * \~chinese \note 此操作不会恢复对 \a QWidget::contentsMargins 的修改 + * \~chinese \param window 需是一个调用过 \a acclimatizeVirtualKeyboard 的窗口 + */ +void DApplication::ignoreVirtualKeyboard(QWidget *window) +{ + D_D(DApplication); + + if (!d->acclimatizeVirtualKeyboardWindows.removeOne(window)) + return; + + if (d->acclimatizeVirtualKeyboardWindows.isEmpty()) { + disconnect(this, SIGNAL(focusChanged(QWidget *, QWidget *)), + this, SLOT(_q_resizeWindowContentsForVirtualKeyboard())); + disconnect(inputMethod(), SIGNAL(keyboardRectangleChanged()), + this, SLOT(_q_resizeWindowContentsForVirtualKeyboard())); + disconnect(inputMethod(), SIGNAL(visibleChanged()), + this, SLOT(_q_resizeWindowContentsForVirtualKeyboard())); + disconnect(inputMethod(), SIGNAL(cursorRectangleChanged()), + this, SLOT(_q_panWindowContentsForVirtualKeyboard())); + disconnect(inputMethod(), SIGNAL(inputItemClipRectangleChanged()), + this, SLOT(_q_panWindowContentsForVirtualKeyboard())); + } +} + +/** + * \~chinese @brief DApplication::isAcclimatizedVirtualKeyboard + * \~chinese 如果 \a window 会自适应虚拟键盘返回 true,否则返回 false + * \~chinese \param window + */ +bool DApplication::isAcclimatizedVirtualKeyboard(QWidget *window) const +{ + D_DC(DApplication); + return d->acclimatizeVirtualKeyboardWindows.contains(window); +} + +/*! + \fn DApplication::customHandler(DAppHandler *handler) + \brief 设置 app 的处理程序,如果要设置,必须对 help、about、quit 都进行处理。handler 需要继承实现。 +*/ +void DApplication::setCustomHandler(DAppHandler *handler) +{ + D_D(DApplication); + d->appHandler = handler; +} + +/*! + \fn DApplication::customHandler() + \brief 获取设置的 app 定制化处理程序 +*/ +DAppHandler *DApplication::customHandler() +{ + D_D(DApplication); + return d->appHandler; +} + +/** * \~english @brief DApplication::handleHelpAction * * \~english Triggered when user clicked the help menu item of this window's titlebar, @@ -1191,6 +1430,12 @@ */ void DApplication::handleHelpAction() { + D_D(DApplication); + if (customHandler()) { + d->appHandler->handleHelpAction(); + return; + } + #ifdef Q_OS_LINUX QString appid = applicationName(); @@ -1224,6 +1469,10 @@ void DApplication::handleAboutAction() { D_D(DApplication); + if (customHandler()) { + d->appHandler->handleAboutAction(); + return; + } if (d->aboutDialog) { d->aboutDialog->show(); @@ -1271,6 +1520,12 @@ */ void DApplication::handleQuitAction() { + D_D(DApplication); + if (customHandler()) { + d->appHandler->handleQuitAction(); + return; + } + quit(); } diff -Nru dtkwidget-5.4.36/src/widgets/dapplication.h dtkwidget-5.5.17.1/src/widgets/dapplication.h --- dtkwidget-5.4.36/src/widgets/dapplication.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dapplication.h 2021-06-30 10:52:09.000000000 +0000 @@ -33,6 +33,7 @@ class DApplication; class DApplicationPrivate; class DAboutDialog; +class DAppHandler; #if defined(qApp) #undef qApp @@ -123,6 +124,11 @@ bool autoActivateWindows() const; void setAutoActivateWindows(bool autoActivateWindows); + // 使窗口内的输入框自动适应虚拟键盘 + void acclimatizeVirtualKeyboard(QWidget *window); + void ignoreVirtualKeyboard(QWidget *window); + bool isAcclimatizedVirtualKeyboard(QWidget *window) const; + #ifdef VERSION static inline QString buildVersion(const QString &fallbackVersion) { @@ -147,6 +153,10 @@ //###(zccrs): Emit form the Qt platform theme plugin(from the package: dde-qt5integration) void screenDevicePixelRatioChanged(QScreen *screen); +public: + void setCustomHandler(DAppHandler *handler); + DAppHandler *customHandler(); + protected: virtual void handleHelpAction(); virtual void handleAboutAction(); @@ -160,6 +170,17 @@ friend class DMainWindowPrivate; D_PRIVATE_SLOT(void _q_onNewInstanceStarted()) + D_PRIVATE_SLOT(void _q_panWindowContentsForVirtualKeyboard()) + D_PRIVATE_SLOT(void _q_resizeWindowContentsForVirtualKeyboard()) +}; + +class LIBDTKWIDGETSHARED_EXPORT DAppHandler { +public: + inline virtual ~DAppHandler() = default; + + virtual void handleHelpAction() = 0; + virtual void handleAboutAction() = 0; + virtual void handleQuitAction() = 0; }; class DtkBuildVersion { diff -Nru dtkwidget-5.4.36/src/widgets/dapplicationhelper.cpp dtkwidget-5.5.17.1/src/widgets/dapplicationhelper.cpp --- dtkwidget-5.4.36/src/widgets/dapplicationhelper.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dapplicationhelper.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -19,9 +19,9 @@ * along with this program. If not, see . */ #include "dapplicationhelper.h" -#include "dstyleoption.h" +#include "dpalettehelper.h" -#include +#include DWIDGET_BEGIN_NAMESPACE @@ -36,13 +36,15 @@ __attribute__((constructor)) // 在库被加载时就执行此函数 static void init_createHelper () { - DApplicationHelper::registerInstanceCreator(_DApplicationHelper::createHelper); + if (!QApplication::instance() || qobject_cast(QApplication::instance())) { + DApplicationHelper::registerInstanceCreator(_DApplicationHelper::createHelper); + } } class DApplicationHelperPrivate { public: - QHash paletteCache; + DPaletteHelper *paletteHelper = DPaletteHelper::instance(); }; static DApplicationHelperPrivate *d = nullptr; @@ -68,46 +70,7 @@ */ DPalette DApplicationHelper::palette(const QWidget *widget, const QPalette &base) const { - DPalette palette; - - if (!widget) { - return applicationPalette(); - } - - do { - // 先从缓存中取数据 - if (d->paletteCache.contains(widget)) { - palette = d->paletteCache.value(widget); - break; - } - - if (QWidget *parent = widget->parentWidget()) { - palette = this->palette(parent, base); - } else { - palette = applicationPalette(); - } - - // 判断widget对象有没有被设置过palette - if (widget->testAttribute(Qt::WA_SetPalette)) { - // 存在自定义palette时应该根据其自定义的palette获取对应色调的DPalette - const QPalette &wp = widget->palette(); - - // 判断控件自己的palette色调是否和要继承调色板色调一致 - if (toColorType(palette) != toColorType(wp)) { - // 不一致时则fallback到标准的palette - palette = standardPalette(toColorType(wp)); - } - } - - // 缓存数据 - d->paletteCache.insert(widget, palette); - // 关注控件palette改变的事件 - const_cast(widget)->installEventFilter(const_cast(this)); - } while (false); - - palette.QPalette::operator =(base.resolve() ? base : widget->palette()); - - return palette; + return d->paletteHelper->palette(widget, base); } /*! @@ -117,11 +80,7 @@ */ void DApplicationHelper::setPalette(QWidget *widget, const DPalette &palette) { - d->paletteCache.insert(widget, palette); - widget->installEventFilter(const_cast(this)); - // 记录此控件被设置过palette - widget->setProperty("_d_set_palette", true); - widget->setPalette(palette); + d->paletteHelper->setPalette(widget, palette); } /*! @@ -130,10 +89,7 @@ */ void DApplicationHelper::resetPalette(QWidget *widget) { - // 清理数据 - d->paletteCache.remove(widget); - widget->setProperty("_d_set_palette", QVariant()); - widget->setAttribute(Qt::WA_SetPalette, false); + d->paletteHelper->resetPalette(widget); } DApplicationHelper::DApplicationHelper() @@ -152,31 +108,13 @@ bool DApplicationHelper::eventFilter(QObject *watched, QEvent *event) { - if (Q_UNLIKELY(event->type() == QEvent::PaletteChange)) { - if (QWidget *widget = qobject_cast(watched)) { - if (!widget->property("_d_set_palette").toBool()) { - // 清理缓存 - d->paletteCache.remove(widget); - } - } - } else if (Q_UNLIKELY(event->type() == QEvent::Destroy)) { - if (QWidget *widget = qobject_cast(watched)) { - if (d->paletteCache.contains(widget)) { - // 清理缓存 - d->paletteCache.remove(widget); - } - } - } + Q_ASSERT_X(false, Q_FUNC_INFO, "This function should not be called."); return DGuiApplicationHelper::eventFilter(watched, event); } bool DApplicationHelper::event(QEvent *event) { - if (event->type() == QEvent::ApplicationFontChange) { - DFontSizeManager::instance()->setFontGenericPixelSize(DFontSizeManager::fontPixelSize(qGuiApp->font())); - } - return DGuiApplicationHelper::event(event); } diff -Nru dtkwidget-5.4.36/src/widgets/dapplicationhelper.h dtkwidget-5.5.17.1/src/widgets/dapplicationhelper.h --- dtkwidget-5.4.36/src/widgets/dapplicationhelper.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dapplicationhelper.h 2021-06-30 10:52:09.000000000 +0000 @@ -28,7 +28,7 @@ DGUI_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE -class DApplicationHelper : public DGuiApplicationHelper +class D_DECL_DEPRECATED_X("Use DPaletteHelper") DApplicationHelper : public DGuiApplicationHelper { Q_OBJECT diff -Nru dtkwidget-5.4.36/src/widgets/darrowrectangle.cpp dtkwidget-5.5.17.1/src/widgets/darrowrectangle.cpp --- dtkwidget-5.4.36/src/widgets/darrowrectangle.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/darrowrectangle.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -1243,6 +1243,11 @@ q->setAttribute(Qt::WA_TranslucentBackground); } + if (!DWindowManagerHelper::instance()->hasBlurWindow() + && DGuiApplicationHelper::instance()->isTabletEnvironment()) { + q->setAttribute(Qt::WA_TranslucentBackground, false); + } + if (DApplication::isDXcbPlatform() && (DArrowRectangle::FloatWindow == floatMode)) { m_handle = new DPlatformWindowHandle(q, q); m_handle->setTranslucentBackground(true); diff -Nru dtkwidget-5.4.36/src/widgets/dbackgroundgroup.cpp dtkwidget-5.5.17.1/src/widgets/dbackgroundgroup.cpp --- dtkwidget-5.4.36/src/widgets/dbackgroundgroup.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dbackgroundgroup.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -74,7 +74,7 @@ QMargins itemMargins; int itemSpacing = -1; bool useWidgetBackground = true; - + QPalette::ColorRole role = QPalette::Base; D_DECLARE_PUBLIC(DBackgroundGroup) }; @@ -154,6 +154,18 @@ setItemMargins(layout->contentsMargins()); } +void DBackgroundGroup::setBackgroundRole(QPalette::ColorRole role) +{ + D_D(DBackgroundGroup); + d->role = role; +} + +QPalette::ColorRole DBackgroundGroup::backgroundRole() const +{ + D_DC(DBackgroundGroup); + return d->role; +} + /*! * \~chinese \brief DBackgroundGroup::setItemMargins设置控件在布局内的边距 * \~chinese \param itemMargins控件在布局内的边距 diff -Nru dtkwidget-5.4.36/src/widgets/dbackgroundgroup.h dtkwidget-5.5.17.1/src/widgets/dbackgroundgroup.h --- dtkwidget-5.4.36/src/widgets/dbackgroundgroup.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dbackgroundgroup.h 2021-06-30 10:52:09.000000000 +0000 @@ -25,6 +25,9 @@ void setLayout(QLayout *layout); + void setBackgroundRole(QPalette::ColorRole role); + QPalette::ColorRole backgroundRole() const; + public Q_SLOTS: void setItemMargins(QMargins itemMargins); void setItemSpacing(int spacing); diff -Nru dtkwidget-5.4.36/src/widgets/dcommandlinkbutton.cpp dtkwidget-5.5.17.1/src/widgets/dcommandlinkbutton.cpp --- dtkwidget-5.4.36/src/widgets/dcommandlinkbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dcommandlinkbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -1,5 +1,5 @@ #include "dcommandlinkbutton.h" -#include "dapplicationhelper.h" +#include "dpalettehelper.h" #include #include @@ -53,7 +53,7 @@ if (isDown()) option->state |= QStyle::State_Sunken; - DPalette pa = DApplicationHelper::instance()->palette(this); + DPalette pa = DPaletteHelper::instance()->palette(this); option->palette.setBrush(DPalette::ButtonText, pa.highlight()); option->text = this->text(); } diff -Nru dtkwidget-5.4.36/src/widgets/ddialog.cpp dtkwidget-5.5.17.1/src/widgets/ddialog.cpp --- dtkwidget-5.4.36/src/widgets/ddialog.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/ddialog.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -29,6 +29,7 @@ #include #include #include +#include #include "private/ddialog_p.h" @@ -41,33 +42,6 @@ #include "dwarningbutton.h" #include "dsuggestbutton.h" -// 字符串为2个字符的非拉丁字符串,中间加上空格 -static bool buttonTextOrigin2Echo(QString &text) -{ - if (text.count() == 2 && text.indexOf(QChar::Nbsp) == -1) { - for (const QChar &ch : text) { - switch (ch.script()) { - case QChar::Script_Han: - case QChar::Script_Katakana: - case QChar::Script_Hiragana: - case QChar::Script_Hangul: - text.insert(1, QChar::Nbsp); - return true; - default: - break; - } - } - } - return false; -} - -static QString buttonTextOrigin2Echo(const QString &text) -{ - QString tmp = text; - buttonTextOrigin2Echo(tmp); - return tmp; -} - DWIDGET_BEGIN_NAMESPACE DDialogPrivate::DDialogPrivate(DDialog *qq) @@ -137,6 +111,17 @@ contentLayout->setSpacing(0); contentLayout->addLayout(textLayout); + contentWidget = new QWidget; + contentWidget->setLayout(contentLayout); + DApplication *dapp = qobject_cast(qApp); + + if (dapp) { + contentWidget->setAttribute(Qt::WA_LayoutOnEntireRect, false); + contentWidget->setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false); + contentWidget->setProperty("_dtk_NoTopLevelEnabled", true); + qApp->acclimatizeVirtualKeyboard(contentWidget); + } + titleBar = new DTitlebar(); titleBar->setAccessibleName("DDialogTitleBar"); titleBar->setIcon(icon); //设置标题icon @@ -151,7 +136,7 @@ // MainLayout--TopLayout mainLayout->addWidget(titleBar, 0, Qt::AlignTop); - mainLayout->addLayout(contentLayout); + mainLayout->addWidget(contentWidget); mainLayout->setContentsMargins(QMargins(0, 0, 0, 0)); // MainLayout--ButtonLayout @@ -631,10 +616,23 @@ setDefaultButton(button); } - // TODO 添加text显示规则处理 - auto text = button->text(); - if (buttonTextOrigin2Echo(text)) - button->setText(text); + const QString &text = button->text(); + + if (text.count() == 2) { + for (const QChar &ch : text) { + switch (ch.script()) { + case QChar::Script_Han: + case QChar::Script_Katakana: + case QChar::Script_Hiragana: + case QChar::Script_Hangul: + break; + default: + return; + } + } + + button->setText(QString().append(text.at(0)).append(QChar::Nbsp).append(text.at(1))); + } } /*! @@ -908,8 +906,7 @@ { QAbstractButton *button = getButton(index); - // TODO 添加text显示规则处理 - button->setText(buttonTextOrigin2Echo(text)); + button->setText(text); } /*! @@ -1048,29 +1045,19 @@ /*! * \~chinese \brief 以模态框形式显示当前对话框 * - * \~chinese 以 \l{QDialog#Modal Dialogs}{模态框} 形式显示当前对话框,将会阻塞直到用户关闭对话框。 - * - * \~chinese onButtonClickedClose()为 true 时返回当前点击按钮的Index,否则返回 \DialogCode 结果。 + * \~chinese 以 \l{QDialog#Modal Dialogs}{模态框} 形式显示当前对话框,将会阻塞直到用户关闭对话框,并返回 \DialogCode 结果。 * + * \sa open(), show(), result(), setWindowModality() */ int DDialog::exec() { D_D(DDialog); d->clickedButtonIndex = -1; - int clickedIndex = d->clickedButtonIndex; - - if (d->onButtonClickedClose) { - // 如果设置了WA_DeleteOnClose属性,那么在exec()中将直接delete this - // d->clickedButtonIndex中记录的数据失效,这里通过信号槽更新正确的数据 - connect(this, &DDialog::buttonClicked, this, [ &clickedIndex ] (int index, const QString &) { - clickedIndex = index; - }); - } int code = DAbstractDialog::exec(); - return clickedIndex >= 0 ? clickedIndex : code; + return d->clickedButtonIndex >= 0 ? d->clickedButtonIndex : code; } void DDialog::setCloseButtonVisible(bool closeButtonVisible) diff -Nru dtkwidget-5.4.36/src/widgets/dfloatingmessage.h dtkwidget-5.5.17.1/src/widgets/dfloatingmessage.h --- dtkwidget-5.4.36/src/widgets/dfloatingmessage.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dfloatingmessage.h 2021-06-30 10:52:09.000000000 +0000 @@ -50,7 +50,7 @@ void setWidget(QWidget *w); void setDuration(int msec); - QSize sizeHint() const; + virtual QSize sizeHint() const override; Q_SIGNALS: void closeButtonClicked(); diff -Nru dtkwidget-5.4.36/src/widgets/dfloatingwidget.h dtkwidget-5.5.17.1/src/widgets/dfloatingwidget.h --- dtkwidget-5.4.36/src/widgets/dfloatingwidget.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dfloatingwidget.h 2021-06-30 10:52:09.000000000 +0000 @@ -41,7 +41,7 @@ public: explicit DFloatingWidget(QWidget *parent = nullptr); - QSize sizeHint() const override; + virtual QSize sizeHint() const override; void setWidget(QWidget *widget); void setFramRadius(int radius); diff -Nru dtkwidget-5.4.36/src/widgets/dframe.cpp dtkwidget-5.5.17.1/src/widgets/dframe.cpp --- dtkwidget-5.4.36/src/widgets/dframe.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dframe.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -19,7 +19,7 @@ * along with this program. If not, see . */ #include "dframe.h" -#include "dapplicationhelper.h" +#include "dpalettehelper.h" #include "private/dframe_p.h" #include @@ -98,7 +98,7 @@ opt.features |= QStyleOptionFrame::Rounded; } - const DPalette &dp = DApplicationHelper::instance()->palette(this); + const DPalette &dp = DPaletteHelper::instance()->palette(this); if (d->backType != DPalette::NoType) { p.setBackground(dp.brush(d->backType)); diff -Nru dtkwidget-5.4.36/src/widgets/diconbutton.cpp dtkwidget-5.5.17.1/src/widgets/diconbutton.cpp --- dtkwidget-5.4.36/src/widgets/diconbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/diconbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -257,6 +257,15 @@ } } +/*! + * \~chinese \brief DIconButton::setNewNotification 设置是否显示小红点 + * \~chinese \param set_new true有红点 false无红点 + */ +void DIconButton::setNewNotification(const bool set_new) +{ + this->setProperty("_d_dtk_newNotification", set_new); +} + void DIconButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) diff -Nru dtkwidget-5.4.36/src/widgets/diconbutton.h dtkwidget-5.5.17.1/src/widgets/diconbutton.h --- dtkwidget-5.4.36/src/widgets/diconbutton.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/diconbutton.h 2021-06-30 10:52:09.000000000 +0000 @@ -56,6 +56,7 @@ void setEnabledCircle(bool status); bool enabledCircle() const; + void setNewNotification(const bool set_new); public Q_SLOTS: void setFlat(bool flat); diff -Nru dtkwidget-5.4.36/src/widgets/dkeysequenceedit.cpp dtkwidget-5.5.17.1/src/widgets/dkeysequenceedit.cpp --- dtkwidget-5.4.36/src/widgets/dkeysequenceedit.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dkeysequenceedit.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -42,7 +42,7 @@ opt.features |= QStyleOptionFrame::Rounded; - const DPalette &dp = DApplicationHelper::instance()->palette(this); + const DPalette &dp = DPaletteHelper::instance()->palette(this); if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { p.setBackground(QColor(255, 255, 255)); diff -Nru dtkwidget-5.4.36/src/widgets/dlabel.cpp dtkwidget-5.5.17.1/src/widgets/dlabel.cpp --- dtkwidget-5.4.36/src/widgets/dlabel.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dlabel.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -21,7 +21,7 @@ #include "dlabel.h" #include "private/dlabel_p.h" -#include +#include #include @@ -127,7 +127,7 @@ D_DC(DLabel); QLabel::initPainter(painter); if (d->color != DPalette::NoType) { - QBrush color = DApplicationHelper::instance()->palette(this).brush(d->color); + QBrush color = DPaletteHelper::instance()->palette(this).brush(d->color); painter->setPen(QPen(color.color())); } } @@ -179,7 +179,7 @@ context.palette = opt.palette; if (d_func()->color != DPalette::NoType) { - context.palette.setBrush(QPalette::Text, DApplicationHelper::instance()->palette(this).brush(d_func()->color)); + context.palette.setBrush(QPalette::Text, DPaletteHelper::instance()->palette(this).brush(d_func()->color)); } else if (foregroundRole() != QPalette::Text && isEnabled()) { context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole())); } @@ -202,7 +202,7 @@ QPalette palette = opt.palette; if (d_func()->color != DPalette::NoType) { - palette.setBrush(foregroundRole(), DApplicationHelper::instance()->palette(this).brush(d_func()->color)); + palette.setBrush(foregroundRole(), DPaletteHelper::instance()->palette(this).brush(d_func()->color)); } QString text = d->text; diff -Nru dtkwidget-5.4.36/src/widgets/dmainwindow.cpp dtkwidget-5.5.17.1/src/widgets/dmainwindow.cpp --- dtkwidget-5.4.36/src/widgets/dmainwindow.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dmainwindow.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -68,9 +68,12 @@ // 默认开启标题栏阴影 q->setTitlebarShadowEnabled(true); - const DApplication *dapp = qobject_cast(qApp); + DApplication *dapp = qobject_cast(qApp); if (dapp) { q->setWindowTitle(dapp->productName()); + q->setAttribute(Qt::WA_LayoutOnEntireRect, false); + q->setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false); + dapp->acclimatizeVirtualKeyboard(q); } else { q->setWindowTitle(qApp->applicationDisplayName()); } @@ -123,7 +126,7 @@ if (!titleShadow) return; - QRect rect(0, titlebar->rect().bottom() + 1, q->width(), titleShadow->sizeHint().height()); + QRect rect(0, titlebar->geometry().bottom() + 1, q->width(), titleShadow->sizeHint().height()); titleShadow->setGeometry(rect); // 全凭时会隐藏窗口标题栏,因此不应该显示标题栏的阴影 titleShadow->setVisible(!q->isFullScreen()); @@ -151,6 +154,11 @@ , DObject(*new DMainWindowPrivate(this)) { d_func()->init(); + + //平板模式下DMainWindow屏蔽掉最大,最小,以及关闭按钮 + if (DGuiApplicationHelper::isTabletEnvironment()) { + setWindowFlags(windowFlags() & ~(Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)); + } } /*! diff -Nru dtkwidget-5.4.36/src/widgets/dmessagemanager.cpp dtkwidget-5.5.17.1/src/widgets/dmessagemanager.cpp --- dtkwidget-5.4.36/src/widgets/dmessagemanager.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dmessagemanager.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -1,11 +1,62 @@ #include "dmessagemanager.h" -#include +#include +#include #include #define D_MESSAGE_MANAGER_CONTENT "_d_message_manager_content" Q_DECLARE_METATYPE(QMargins) +// 仅仅为了接口兼容, 符号不会减少, 如果使用了这个接口,实际调用走的有namespace的 +class Q_DECL_EXPORT DMessageManager: public QObject +{ + Q_OBJECT +private: + DMessageManager(); + +public: + static DMessageManager *instance(); + + void sendMessage(QWidget *par, DTK_WIDGET_NAMESPACE::DFloatingMessage *floMsg); + void sendMessage(QWidget *par, const QIcon &icon, const QString &message); + bool setContentMargens(QWidget *par, const QMargins &margins); + +protected: + bool eventFilter(QObject *watched, QEvent *event) override; +}; + +DMessageManager::DMessageManager() +{ +} + +DMessageManager *DMessageManager::instance() +{ + return reinterpret_cast(DTK_WIDGET_NAMESPACE::DMessageManager::instance()); +} + +void DMessageManager::sendMessage(QWidget *par, DTK_WIDGET_NAMESPACE::DFloatingMessage *floMsg) +{ + DTK_WIDGET_NAMESPACE::DMessageManager::instance()->sendMessage(par, floMsg); +} + +void DMessageManager::sendMessage(QWidget *par, const QIcon &icon, const QString &message) +{ + DTK_WIDGET_NAMESPACE::DMessageManager::instance()->sendMessage(par, icon, message); +} + +bool DMessageManager::setContentMargens(QWidget *par, const QMargins &margins) +{ + return DTK_WIDGET_NAMESPACE::DMessageManager::instance()->setContentMargens(par, margins); +} + +bool DMessageManager::eventFilter(QObject *watched, QEvent *event) +{ + Q_UNUSED(watched); + Q_UNUSED(event); + return false; +} + +DWIDGET_BEGIN_NAMESPACE DMessageManager::DMessageManager() //私有静态构造函数 { } @@ -142,3 +193,7 @@ return QObject::eventFilter(watched, event); } + +DWIDGET_END_NAMESPACE + +#include "dmessagemanager.moc" diff -Nru dtkwidget-5.4.36/src/widgets/dmessagemanager.h dtkwidget-5.5.17.1/src/widgets/dmessagemanager.h --- dtkwidget-5.4.36/src/widgets/dmessagemanager.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dmessagemanager.h 2021-06-30 10:52:09.000000000 +0000 @@ -3,12 +3,10 @@ #include #include -#include - -#include "dfloatingmessage.h" - -DWIDGET_USE_NAMESPACE +#include +DWIDGET_BEGIN_NAMESPACE +class DFloatingMessage; class DMessageManager: public QObject { Q_OBJECT @@ -27,4 +25,6 @@ bool eventFilter(QObject *watched, QEvent *event) override; }; +DWIDGET_END_NAMESPACE + #endif // DMESSAGEMANAGER_H diff -Nru dtkwidget-5.4.36/src/widgets/dmpriscontrol.cpp dtkwidget-5.5.17.1/src/widgets/dmpriscontrol.cpp --- dtkwidget-5.4.36/src/widgets/dmpriscontrol.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dmpriscontrol.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -301,6 +301,14 @@ { D_Q(DMPRISControl); + DBusMPRIS *newMpris = new DBusMPRIS(path, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), q); + + // 此属性判断是否支持使用MPRIS控制 真表示能控制 假则忽略这个dbus接口 + if (!newMpris->canShowInUI()) { + newMpris->deleteLater(); + return; + } + const bool hasOld = m_mprisInter; m_lastPath = path; @@ -311,7 +319,7 @@ if (m_mprisInter) m_mprisInter->deleteLater(); - m_mprisInter = new DBusMPRIS(path, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), q); + m_mprisInter = newMpris; m_controlWidget->setVisible(m_mprisInter->canControl()); diff -Nru dtkwidget-5.4.36/src/widgets/DPaletteHelper dtkwidget-5.5.17.1/src/widgets/DPaletteHelper --- dtkwidget-5.4.36/src/widgets/DPaletteHelper 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/DPaletteHelper 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1 @@ +#include "dpalettehelper.h" diff -Nru dtkwidget-5.4.36/src/widgets/dpalettehelper.cpp dtkwidget-5.5.17.1/src/widgets/dpalettehelper.cpp --- dtkwidget-5.4.36/src/widgets/dpalettehelper.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dpalettehelper.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2020 ~ 2020 Deepin Technology Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include "dpalettehelper.h" +#include "dstyleoption.h" +#include "private/dpalettehelper_p.h" + +DWIDGET_BEGIN_NAMESPACE + +static DPaletteHelper *g_instance = nullptr; + +DPaletteHelperPrivate::DPaletteHelperPrivate(DPaletteHelper *qq) + : DTK_CORE_NAMESPACE::DObjectPrivate(qq) +{ +} + +DPaletteHelper::DPaletteHelper(QObject *parent) + : QObject(parent) + , DTK_CORE_NAMESPACE::DObject(*new DPaletteHelperPrivate(this)) +{ + connect(qGuiApp, &QGuiApplication::fontChanged, this, [](const QFont &font) { + DFontSizeManager::instance()->setFontGenericPixelSize(static_cast(DFontSizeManager::fontPixelSize(font))); + }); +} + +DPaletteHelper::~DPaletteHelper() +{ + if (g_instance) { + g_instance->deleteLater(); + g_instance = nullptr; + } +} + +DPaletteHelper *DPaletteHelper::instance() +{ + if (!g_instance) { + g_instance = new DPaletteHelper; + } + + return g_instance; +} + +/*! + * \~chinese \brief DPaletteHelper::palette返回调色板 + * \~chinese \param widget控件 + * \~chinese \param base调色板 + * \~chinese \return 调色板 + */ +DPalette DPaletteHelper::palette(const QWidget *widget, const QPalette &base) const +{ + D_DC(DPaletteHelper); + + DPalette palette; + + if (!widget) { + return DGuiApplicationHelper::instance()->applicationPalette(); + } + + do { + // 先从缓存中取数据 + if (d->paletteCache.contains(widget)) { + palette = d->paletteCache.value(widget); + break; + } + + if (QWidget *parent = widget->parentWidget()) { + palette = this->palette(parent, base); + } else { + palette = DGuiApplicationHelper::instance()->applicationPalette(); + } + + // 判断widget对象有没有被设置过palette + if (widget->testAttribute(Qt::WA_SetPalette)) { + // 存在自定义palette时应该根据其自定义的palette获取对应色调的DPalette + const QPalette &wp = widget->palette(); + + // 判断控件自己的palette色调是否和要继承调色板色调一致 + if (DGuiApplicationHelper::instance()->toColorType(palette) != DGuiApplicationHelper::instance()->toColorType(wp)) { + // 不一致时则fallback到标准的palette + palette = DGuiApplicationHelper::instance()->standardPalette(DGuiApplicationHelper::instance()->toColorType(wp)); + } + } + + // 缓存数据 + const_cast(d)->paletteCache.insert(widget, palette); + // 关注控件palette改变的事件 + const_cast(widget)->installEventFilter(const_cast(this)); + } while (false); + + palette.QPalette::operator=(base.resolve() ? base : widget->palette()); + + return palette; +} + +/*! + * \~chinese \brief DPaletteHelper::setPalette将调色板设置到控件 + * \~chinese \param widget控件 + * \~chinese \param palette调色板 + */ +void DPaletteHelper::setPalette(QWidget *widget, const DPalette &palette) +{ + D_D(DPaletteHelper); + + d->paletteCache.insert(widget, palette); + widget->installEventFilter(const_cast(this)); + // 记录此控件被设置过palette + widget->setProperty("_d_set_palette", true); + widget->setPalette(palette); +} + +/*! + * \~chinese \brief DPaletteHelper::resetPalette重置控件的调色板属性 + * \~chinese \param widget控件 + */ +void DPaletteHelper::resetPalette(QWidget *widget) +{ + D_D(DPaletteHelper); + + // 清理数据 + d->paletteCache.remove(widget); + widget->setProperty("_d_set_palette", QVariant()); + widget->setAttribute(Qt::WA_SetPalette, false); +} + +bool DPaletteHelper::eventFilter(QObject *watched, QEvent *event) +{ + D_D(DPaletteHelper); + + if (Q_UNLIKELY(event->type() == QEvent::PaletteChange)) { + if (QWidget *widget = qobject_cast(watched)) { + if (!widget->property("_d_set_palette").toBool()) { + // 清理缓存 + d->paletteCache.remove(widget); + } + } + } else if (Q_UNLIKELY(event->type() == QEvent::Destroy)) { + if (QWidget *widget = qobject_cast(watched)) { + if (d->paletteCache.contains(widget)) { + // 清理缓存 + d->paletteCache.remove(widget); + } + } + } + + return QObject::eventFilter(watched, event); +} + +DWIDGET_END_NAMESPACE diff -Nru dtkwidget-5.4.36/src/widgets/dpalettehelper.h dtkwidget-5.5.17.1/src/widgets/dpalettehelper.h --- dtkwidget-5.4.36/src/widgets/dpalettehelper.h 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dpalettehelper.h 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2020 ~ 2020 Deepin Technology Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef DPALETTEHELPER_H +#define DPALETTEHELPER_H + +#include +#include +#include + +DGUI_USE_NAMESPACE +DWIDGET_BEGIN_NAMESPACE + +class DPaletteHelperPrivate; +class DPaletteHelper : public QObject + , public DCORE_NAMESPACE::DObject +{ + Q_OBJECT + +public: + static DPaletteHelper *instance(); + + DPalette palette(const QWidget *widget, const QPalette &base = QPalette()) const; + void setPalette(QWidget *widget, const DPalette &palette); + void resetPalette(QWidget *widget); + +private: + DPaletteHelper(QObject *parent = nullptr); + ~DPaletteHelper() override; + + bool eventFilter(QObject *watched, QEvent *event) override; + + D_DECLARE_PRIVATE(DPaletteHelper) +}; + +DWIDGET_END_NAMESPACE + +#endif // DPALETTEHELPER_H diff -Nru dtkwidget-5.4.36/src/widgets/dplatformwindowhandle.cpp dtkwidget-5.5.17.1/src/widgets/dplatformwindowhandle.cpp --- dtkwidget-5.4.36/src/widgets/dplatformwindowhandle.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dplatformwindowhandle.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -188,4 +188,46 @@ return widget->windowHandle() && DPlatformHandle::setWindowBlurAreaByWM(widget->windowHandle(), paths); } +/*! + * \~chinese \brief DPlatformWindowHandle::setWindowWallpaperParaByWM + * \~chinese 这只是一个重载函数,如果 widget 的 QWidget::windowHandle 为 nullptr 则返回 false, + * \~chinese 否则返回 setWindowWallpaperParaByWM(wiget->windowHandle(), area) 的值。示例: + * \~chinese \code + * DMainWindow w;.000000 + * QRect area; + * DPlatformWindowHandle::WallpaperScaleMode sMode + * DPlatformWindowHandle::WallpaperFillMode fMode + * + * area.x = 50; + * area.y = 50; + * area.width = 200; + * area.height = 200; + * area.xRadius = 10; + * area.yRaduis = 10; + * + * sMode = WallpaperScaleFlag::FollowWindow; + * fMode = WallpaperFillFlag::PreserveAspectCrop; + * + * DPlatformWindowHandle::setWindowWallpaperParaByWM(&w, area, sMode, fMode); + * + * w.resize(300, 300); + * w.setAttribute(Qt::WA_TranslucentBackground); + * w.show(); + * + * \endcode + * \~chinese \param widget + * \~chinese \param area + * \~chinese \param sMode + * \~chinese \param fMode + * \~chinese \return + * \~chinese \note 需要对 \a widget 添加 Qt::WA_TranslucentBackground 使其背景透明 + * \~chinese \sa QWidget::setAttribute + */ +bool DPlatformWindowHandle::setWindowWallpaperParaByWM(QWidget *widget, const QRect &area, WallpaperScaleMode sMode, WallpaperFillMode fMode) +{ + Q_ASSERT(widget); + + return DPlatformHandle::setWindowWallpaperParaByWM(ensureWindowHandle(widget), area, sMode, fMode); +} + DWIDGET_END_NAMESPACE diff -Nru dtkwidget-5.4.36/src/widgets/dplatformwindowhandle.h dtkwidget-5.5.17.1/src/widgets/dplatformwindowhandle.h --- dtkwidget-5.4.36/src/widgets/dplatformwindowhandle.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dplatformwindowhandle.h 2021-06-30 10:52:09.000000000 +0000 @@ -19,6 +19,7 @@ #define DPLATFORMWINDOWHANDLE_H #include +#include #include QT_BEGIN_NAMESPACE @@ -40,9 +41,10 @@ static bool setWindowBlurAreaByWM(QWidget *widget, const QVector &area); static bool setWindowBlurAreaByWM(QWidget *widget, const QList &paths); - + static bool setWindowWallpaperParaByWM(QWidget *widget, const QRect &area, WallpaperScaleMode sMode, WallpaperFillMode fMode); using DPlatformHandle::setWindowBlurAreaByWM; + using DPlatformHandle::setWindowWallpaperParaByWM; }; DWIDGET_END_NAMESPACE diff -Nru dtkwidget-5.4.36/src/widgets/dprintpreviewdialog.cpp dtkwidget-5.5.17.1/src/widgets/dprintpreviewdialog.cpp --- dtkwidget-5.4.36/src/widgets/dprintpreviewdialog.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dprintpreviewdialog.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -12,7 +12,7 @@ #include "dspinbox.h" #include "dbackgroundgroup.h" #include "dfiledialog.h" -#include "dapplicationhelper.h" +#include "dpalettehelper.h" #include "dstyleoption.h" #include "dapplication.h" #include "dfilechooseredit.h" @@ -120,9 +120,9 @@ mainWidget->setAutoFillBackground(true); - DPalette pa = DApplicationHelper::instance()->palette(titleWidget); + DPalette pa = DPaletteHelper::instance()->palette(titleWidget); pa.setBrush(DPalette::Background, pa.base()); - DApplicationHelper::instance()->setPalette(titleWidget, pa); + DPaletteHelper::instance()->setPalette(titleWidget, pa); titleWidget->setAutoFillBackground(true); QHBoxLayout *mainlayout = new QHBoxLayout(); @@ -201,9 +201,9 @@ QRegExpValidator *val = new QRegExpValidator(reg, jumpPageEdit); jumpPageEdit->lineEdit()->setValidator(val); - DPalette m_pa = DApplicationHelper::instance()->palette(pview); + DPalette m_pa = DPaletteHelper::instance()->palette(pview); m_pa.setBrush(DPalette::Base, m_pa.itemBackground()); - DApplicationHelper::instance()->setPalette(pview, m_pa); + DPaletteHelper::instance()->setPalette(pview, m_pa); } void DPrintPreviewDialogPrivate::initright(QVBoxLayout *layout) @@ -382,9 +382,9 @@ DBackgroundGroup *back = new DBackgroundGroup(orientationlayout); back->setObjectName("OrientationBackgroundGroup"); back->setItemSpacing(2); - DPalette pa = DApplicationHelper::instance()->palette(back); + DPalette pa = DPaletteHelper::instance()->palette(back); pa.setBrush(DPalette::Base, pa.itemBackground()); - DApplicationHelper::instance()->setPalette(back, pa); + DPaletteHelper::instance()->setPalette(back, pa); layout->addWidget(back); } @@ -467,7 +467,7 @@ marginslayout->addLayout(marginscombolayout); marginslayout->addLayout(marginsspinlayout); - QRegExp reg("^([5-5][0-4]|[1-4][0-9]|[0-9])?(\\.[0-9][0-9])|55(\\.[8-8][0-8])|55(\\.[0-7][0-9])"); + QRegExp reg("^([5-5][0-4]|[1-4][0-9]|[0-9])(\\.[0-9][0-9])|55(\\.[8-8][0-8])|55(\\.[0-7][0-9])"); QRegExpValidator *val = new QRegExpValidator(reg, marginsframe); QList list = marginsframe->findChildren(); for (int i = 0; i < list.size(); i++) { @@ -529,9 +529,9 @@ DBackgroundGroup *back = new DBackgroundGroup(scalingcontentlayout); back->setObjectName("ScalingContentBackgroundGroup"); back->setItemSpacing(1); - DPalette pa = DApplicationHelper::instance()->palette(back); + DPalette pa = DPaletteHelper::instance()->palette(back); pa.setBrush(DPalette::Base, pa.itemBackground()); - DApplicationHelper::instance()->setPalette(back, pa); + DPaletteHelper::instance()->setPalette(back, pa); scalinglayout->addLayout(scalingtitlelayout); scalinglayout->addWidget(back); @@ -674,9 +674,9 @@ DBackgroundGroup *backorder = new DBackgroundGroup(ordercontentlayout); backorder->setItemSpacing(1); - pa = DApplicationHelper::instance()->palette(backorder); + pa = DPaletteHelper::instance()->palette(backorder); pa.setBrush(DPalette::Base, pa.itemBackground()); - DApplicationHelper::instance()->setPalette(backorder, pa); + DPaletteHelper::instance()->setPalette(backorder, pa); orderlayout->addLayout(ordertitlelayout); orderlayout->addWidget(backorder); @@ -863,9 +863,9 @@ vContentLayout->addWidget(sizeframe); vContentLayout->addWidget(opaframe); - DPalette pa = DApplicationHelper::instance()->palette(back); + DPalette pa = DPaletteHelper::instance()->palette(back); pa.setBrush(DPalette::Base, pa.itemBackground()); - DApplicationHelper::instance()->setPalette(back, pa); + DPaletteHelper::instance()->setPalette(back, pa); watermarksettingwdg->setLayout(vContentLayout); } @@ -1066,7 +1066,7 @@ pview->setCurrentPage(jumpPageEdit->value()); setTurnPageBtnStatus(); }); - QObject::connect(paperSizeCombo, static_cast(&QComboBox::currentIndexChanged), q, [this](int index) { + QObject::connect(paperSizeCombo, static_cast(&QComboBox::currentIndexChanged), q, [this](int) { QPrinterInfo prInfo(*printer); if (paperSizeCombo->count() == 0) { printer->setPageSize(QPrinter::A4); @@ -1140,12 +1140,12 @@ QObject::connect(marginLeftSpin, SIGNAL(valueChanged(double)), q, SLOT(_q_marginspinChanged(double))); QObject::connect(marginBottomSpin, SIGNAL(valueChanged(double)), q, SLOT(_q_marginspinChanged(double))); QObject::connect(duplexCheckBox, SIGNAL(stateChanged(int)), q, SLOT(_q_checkStateChanged(int))); - QObject::connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, pview, &DPrintPreviewWidget::themeTypeChanged); + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, pview, &DPrintPreviewWidget::themeTypeChanged); QObject::connect(marginTopSpin, SIGNAL(editingFinished()), q, SLOT(_q_marginEditFinished())); QObject::connect(marginRightSpin, SIGNAL(editingFinished()), q, SLOT(_q_marginEditFinished())); QObject::connect(marginLeftSpin, SIGNAL(editingFinished()), q, SLOT(_q_marginEditFinished())); QObject::connect(marginBottomSpin, SIGNAL(editingFinished()), q, SLOT(_q_marginEditFinished())); - QObject::connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, q, [this](DGuiApplicationHelper::ColorType themeType) { this->themeTypeChange(themeType); }); + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, q, [this](DGuiApplicationHelper::ColorType themeType) { this->themeTypeChange(themeType); }); QObject::connect(marginTopSpin->lineEdit(), SIGNAL(textEdited(const QString &)), q, SLOT(_q_spinboxValueEmptyChecked(const QString &))); QObject::connect(marginRightSpin->lineEdit(), SIGNAL(textEdited(const QString &)), q, SLOT(_q_spinboxValueEmptyChecked(const QString &))); QObject::connect(marginLeftSpin->lineEdit(), SIGNAL(textEdited(const QString &)), q, SLOT(_q_spinboxValueEmptyChecked(const QString &))); @@ -1159,9 +1159,9 @@ void DPrintPreviewDialogPrivate::setfrmaeback(DFrame *frame) { frame->setLineWidth(0); - DPalette pa = DApplicationHelper::instance()->palette(frame); + DPalette pa = DPaletteHelper::instance()->palette(frame); pa.setBrush(DPalette::Base, pa.itemBackground()); - DApplicationHelper::instance()->setPalette(frame, pa); + DPaletteHelper::instance()->setPalette(frame, pa); } void DPrintPreviewDialogPrivate::showadvancesetting() @@ -1358,9 +1358,9 @@ { Q_Q(DPrintPreviewDialog); DWidget *titleWidget = q->findChild("titlewidget"); - DPalette m_pa = DApplicationHelper::instance()->palette(titleWidget); + DPalette m_pa = DPaletteHelper::instance()->palette(titleWidget); m_pa.setBrush(DPalette::Background, m_pa.base()); - DApplicationHelper::instance()->setPalette(titleWidget, m_pa); + DPaletteHelper::instance()->setPalette(titleWidget, m_pa); titleWidget->setAutoFillBackground(true); QList m_frameList = q->findChildren(); @@ -1374,10 +1374,10 @@ } pa.setBrush(DPalette::FrameBorder, pa.base()); for (int i = 1; i < m_frameList.size(); i++) { - DApplicationHelper::instance()->setPalette(m_frameList.at(i), pa); + DPaletteHelper::instance()->setPalette(m_frameList.at(i), pa); } - for (int i = 1; i < m_back.size(); i++) { - DApplicationHelper::instance()->setPalette(m_back.at(i), pa); + for (int i = 0; i < m_back.size(); i++) { + DPaletteHelper::instance()->setPalette(m_back.at(i), pa); } } @@ -1481,8 +1481,6 @@ */ void DPrintPreviewDialogPrivate::watermarkTypeChoosed(int index) { - D_Q(DPrintPreviewDialog); - if (index == 0) { pview->refreshBegin(); waterTextCombo->setEnabled(true); @@ -1502,7 +1500,8 @@ fontCombo->addItem(font); } - if (!q->property("_d_print_waterIsInit").toBool()) { + static bool watermarkIsInited = false; + if (!watermarkIsInited) { // 初始化才使用系统默认字体 下次切换时保留上一次字体 //通过字体信息,当中文字体的情况下将英文转换为中文 QFont font; @@ -1514,7 +1513,7 @@ fontCombo->setCurrentText(itemName); } } - q->setProperty("_d_print_waterIsInit", true); + watermarkIsInited = true; } pview->setWaterMarkType(Type_Text); pview->refreshEnd(); @@ -2004,7 +2003,7 @@ if (isClicked) { wmSpacer->changeSize(WIDTH_NORMAL, SPACER_HEIGHT_HIDE); watermarksettingwdg->show(); - waterTypeGroup->button(typeChoice)->setChecked(true); + waterTypeGroup->button(0)->setChecked(true); watermarkTypeChoosed(typeChoice); if (typeChoice == Type_Image - 1 && !picPathEdit->text().isEmpty()) customPictureWatermarkChoosed(picPathEdit->text()); diff -Nru dtkwidget-5.4.36/src/widgets/dprintpreviewwidget.h dtkwidget-5.5.17.1/src/widgets/dprintpreviewwidget.h --- dtkwidget-5.4.36/src/widgets/dprintpreviewwidget.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dprintpreviewwidget.h 2021-06-30 10:52:09.000000000 +0000 @@ -23,7 +23,7 @@ #define DPRINTPREVIEWWIDGET_H #include -#include +#include #include #include @@ -35,6 +35,8 @@ #include #undef private +DGUI_USE_NAMESPACE + DWIDGET_BEGIN_NAMESPACE class DPrintPreviewWidgetPrivate; diff -Nru dtkwidget-5.4.36/src/widgets/dsearchedit.cpp dtkwidget-5.5.17.1/src/widgets/dsearchedit.cpp --- dtkwidget-5.4.36/src/widgets/dsearchedit.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dsearchedit.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -22,6 +22,7 @@ #include "diconbutton.h" #include +#include #undef ENABLE_AI #ifdef ENABLE_AI @@ -189,6 +190,11 @@ d->init(); setSpeechToTextEnabled(false); + + //平板模式下屏蔽搜索框右键菜单 + if (DGuiApplicationHelper::isTabletEnvironment()) { + d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu); + } } DSearchEdit::~DSearchEdit() diff -Nru dtkwidget-5.4.36/src/widgets/dsettingsdialog.cpp dtkwidget-5.5.17.1/src/widgets/dsettingsdialog.cpp --- dtkwidget-5.4.36/src/widgets/dsettingsdialog.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dsettingsdialog.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -119,6 +119,13 @@ d->leftFrame->blockSignals(false); }); + DApplication *dapp = qobject_cast(qApp); + + if (dapp) { + d->content->setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea, false); + d->content->setProperty("_dtk_NoTopLevelEnabled", true); + qApp->acclimatizeVirtualKeyboard(d->content); + } // 修复 wayland 下使用 setwindowicon 程序出现死循环 if (DApplication::isDXcbPlatform()) { connect(this, &DSettingsDialog::windowIconChanged, d->frameBar, &DTitlebar::setIcon); diff -Nru dtkwidget-5.4.36/src/widgets/dshortcutedit.h dtkwidget-5.5.17.1/src/widgets/dshortcutedit.h --- dtkwidget-5.4.36/src/widgets/dshortcutedit.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dshortcutedit.h 2021-06-30 10:52:09.000000000 +0000 @@ -30,7 +30,7 @@ DWIDGET_BEGIN_NAMESPACE class DShortcutEditLabel; -class D_DECL_DEPRECATED_X("Remove useless old widget") LIBDTKWIDGETSHARED_EXPORT DShortcutEdit : public QFrame +class D_DECL_DEPRECATED_X("Use DKeySequenceEdit instead.") LIBDTKWIDGETSHARED_EXPORT DShortcutEdit : public QFrame { Q_OBJECT diff -Nru dtkwidget-5.4.36/src/widgets/dslider.cpp dtkwidget-5.5.17.1/src/widgets/dslider.cpp --- dtkwidget-5.4.36/src/widgets/dslider.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dslider.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -28,7 +28,7 @@ #include #include -#include +#include #include DWIDGET_BEGIN_NAMESPACE @@ -719,7 +719,7 @@ { Q_UNUSED(event) QPainter pa(this); - auto dpa = DApplicationHelper::instance()->palette(this); + auto dpa = DPaletteHelper::instance()->palette(this); QPen penLine = QPen(dpa.color(DPalette::ObviousBackground), 1); QPen penNumber = QPen(dpa.textTips(), 1); diff -Nru dtkwidget-5.4.36/src/widgets/dstyle.cpp dtkwidget-5.5.17.1/src/widgets/dstyle.cpp --- dtkwidget-5.4.36/src/widgets/dstyle.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dstyle.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -1228,6 +1228,19 @@ dstyle.drawPrimitive(PE_IconButtonIcon, &new_opt, p, w); } + // 有新信息时添加小红点 + if (w && w->property("_d_dtk_newNotification").toBool()){ + DPalette pa = DGuiApplicationHelper::instance()->standardPalette(DGuiApplicationHelper::LightType); + // 按图标大小50x50时,小红点大小6x6,距离右边和上面8个像素的比例绘制 + const int redPointRadius = 3; + int redPointPadding = (8 * w->size().width() / 50) + redPointRadius; + p->setPen(pa.color(DPalette::TextWarning)); + p->setBrush(pa.color(DPalette::TextWarning)); + p->setRenderHint(QPainter::Antialiasing); + p->drawEllipse(QPointF(w->size().width()-redPointPadding, redPointPadding), + redPointRadius, redPointRadius); + } + if (btn->state & State_HasFocus) { if (btn->features & DStyleOptionButton::FloatingButton) { int border_width = dstyle.pixelMetric(PM_FocusBorderWidth, opt, w); @@ -1339,7 +1352,7 @@ DStyleHelper dstyle(style); const QColor &background = dstyle.getColor(opt, checked ? QPalette::Highlight : QPalette::Button); p->setBrush(background); - p->setPen(QPen(background, 1)); + p->setPen(Qt::NoPen); int radius = dstyle.pixelMetric(PM_FrameRadius, opt, w); int margins = dstyle.pixelMetric(PM_FrameMargins, opt, w); DStyleOptionButtonBoxButton::ButtonPosition pos = btn->position; @@ -1661,7 +1674,7 @@ Q_UNUSED(widget) #define CASE_ICON(Value) \ -case SP_##Value: { \ +case static_cast(SP_##Value): { \ DStyledIconEngine *icon_engine = new DStyledIconEngine(DDrawUtils::draw##Value, QStringLiteral(#Value)); \ return QIcon(icon_engine);} @@ -1726,6 +1739,8 @@ return QIcon::fromTheme("password_hide"); case SP_IndicatorSearch: return QIcon::fromTheme("search_indicator"); + case SP_TitleMoreButton: + return QIcon::fromTheme("titlebar_more"); default: break; } @@ -1776,7 +1791,7 @@ case SH_ToolTipLabel_Opacity: return 255; case SH_RequestSoftwareInputPanel: - return RSIP_OnMouseClickAndAlreadyFocused; + return RSIP_OnMouseClick; case SH_ItemView_ScrollMode: return QAbstractItemView::ScrollPerPixel; case SH_Widget_Animation_Duration: @@ -1865,15 +1880,6 @@ if (option->state.testFlag(DStyle::State_Sunken)) { state = DStyle::SS_PressState; } else if (option->state.testFlag(DStyle::State_MouseOver)) { - // 设置setAttribute(Qt::WA_Hover, false)后 - // 按钮按下时依旧会存在State_MouseOver状态 - // 错误的获取了SS_HoverState后的调色板 - QWidget *widget = qobject_cast(option->styleObject); - if (option->state & State_MouseOver && widget - && !widget->testAttribute(Qt::WA_Hover)) { - return DStyle::SS_NormalState; - } - state = DStyle::SS_HoverState; } @@ -2066,7 +2072,7 @@ */ QIcon DStyle::standardIcon(QStyle::StandardPixmap st, const QStyleOption *opt, const QWidget *widget) const { - switch (st) { + switch (static_cast(st)) { CASE_ICON(TitleBarMenuButton) CASE_ICON(TitleBarMinButton) CASE_ICON(TitleBarMaxButton) @@ -2075,7 +2081,6 @@ CASE_ICON(TitleQuitFullButton) case SP_LineEditClearButton: return QIcon::fromTheme("button_edit-clear"); - break; default: break; } @@ -2763,17 +2768,16 @@ */ void DStyledIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) { + Q_UNUSED(mode) Q_UNUSED(state) if (m_painterRole != QPalette::NoRole) { - QPalette::ColorGroup cg = (mode == QIcon::Disabled) ? QPalette::Disabled : QPalette::Current; - if (m_widget) { - painter->setPen(m_widget->palette().brush(cg, m_painterRole).color()); - painter->setBrush(m_widget->palette().brush(cg, m_painterRole)); + painter->setPen(m_widget->palette().brush(m_painterRole).color()); + painter->setBrush(m_widget->palette().brush(m_painterRole)); } else { - painter->setPen(qApp->palette().brush(cg, m_painterRole).color()); - painter->setBrush(qApp->palette().brush(cg, m_painterRole)); + painter->setPen(qApp->palette().brush(m_painterRole).color()); + painter->setBrush(qApp->palette().brush(m_painterRole)); } } diff -Nru dtkwidget-5.4.36/src/widgets/dstyleditemdelegate.cpp dtkwidget-5.5.17.1/src/widgets/dstyleditemdelegate.cpp --- dtkwidget-5.4.36/src/widgets/dstyleditemdelegate.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dstyleditemdelegate.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -21,7 +21,7 @@ #include "dstyleditemdelegate.h" #include "dobject_p.h" #include "dstyleoption.h" -#include "dapplicationhelper.h" +#include "dpalettehelper.h" #include "dstyle.h" #include "dlistview.h" @@ -263,7 +263,7 @@ pa->setPen(option.palette.color(cg, QPalette::HighlightedText)); } else { if (action->textColorType() > 0) { - pa->setPen(QPen(DApplicationHelper::instance()->palette(option.widget).brush(cg, action->textColorType()), 1)); + pa->setPen(QPen(DPaletteHelper::instance()->palette(option.widget).brush(cg, action->textColorType()), 1)); } else { QPalette::ColorRole role = action->textColorRole() > 0 ? action->textColorRole() : QPalette::Text; pa->setPen(QPen(option.palette.brush(cg, role), 1)); @@ -827,7 +827,7 @@ if (opt.state & QStyle::State_Selected) { painter->setPen(opt.palette.color(cg, QPalette::HighlightedText)); } else if (action->textColorType() >= 0) { - painter->setPen(DApplicationHelper::instance()->palette(widget).color(cg, action->textColorType())); + painter->setPen(DPaletteHelper::instance()->palette(widget).color(cg, action->textColorType())); } else if (action->textColorRole() >= 0) { painter->setPen(opt.palette.color(cg, action->textColorRole())); } else { @@ -1101,7 +1101,7 @@ DPalette::ColorType type = getViewItemColorType(index, Dtk::ViewItemForegroundRole); if (type != DPalette::NoType) { - option->palette.setBrush(QPalette::Text, DApplicationHelper::instance()->palette(option->widget).brush(type)); + option->palette.setBrush(QPalette::Text, DPaletteHelper::instance()->palette(option->widget).brush(type)); } else { QPalette::ColorRole role = getViewItemColorRole(index, Dtk::ViewItemForegroundRole); @@ -1113,7 +1113,7 @@ type = getViewItemColorType(index, Dtk::ViewItemBackgroundRole); if (type != DPalette::NoType) { - option->backgroundBrush = DApplicationHelper::instance()->palette(option->widget).brush(type); + option->backgroundBrush = DPaletteHelper::instance()->palette(option->widget).brush(type); } else { QPalette::ColorRole role = getViewItemColorRole(index, Dtk::ViewItemBackgroundRole); diff -Nru dtkwidget-5.4.36/src/widgets/dstyle.h dtkwidget-5.5.17.1/src/widgets/dstyle.h --- dtkwidget-5.4.36/src/widgets/dstyle.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dstyle.h 2021-06-30 10:52:09.000000000 +0000 @@ -215,6 +215,7 @@ SP_DeleteButton, //删除按钮 SP_AddButton, //新增按钮 SP_TitleQuitFullButton, //标题栏(「」) + SP_TitleMoreButton, //标题栏 "更多" 按钮 SP_CustomBase = QStyle::SP_CustomBase + 0xf00000 }; diff -Nru dtkwidget-5.4.36/src/widgets/dstyleoption.cpp dtkwidget-5.5.17.1/src/widgets/dstyleoption.cpp --- dtkwidget-5.4.36/src/widgets/dstyleoption.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dstyleoption.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -27,7 +27,7 @@ #include "dlineedit.h" #include "private/dlineedit_p.h" -#include "dapplicationhelper.h" +#include "dpalettehelper.h" #include #include @@ -136,7 +136,7 @@ void DStyleOption::init(const QWidget *widget) { - dpalette = DApplicationHelper::instance()->palette(widget); + dpalette = DPaletteHelper::instance()->palette(widget); } /*! diff -Nru dtkwidget-5.4.36/src/widgets/dtabbar.cpp dtkwidget-5.5.17.1/src/widgets/dtabbar.cpp --- dtkwidget-5.4.36/src/widgets/dtabbar.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtabbar.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -31,7 +31,6 @@ #include #include #include -#include #include #define private public @@ -55,48 +54,6 @@ || shape == QTabBar::TriangularEast; } -// QBoxLayout::Direction与QTabBar::Shape之间的映射 -inline static QBoxLayout::Direction shapeToDirection (const QTabBar::Shape shape) -{ - if (verticalTabs(shape)) { - return QBoxLayout::TopToBottom; - } else { - return QBoxLayout::LeftToRight; - } -} - -// 判断是否为横向布局 -static inline bool horz(QBoxLayout::Direction dir) -{ - return dir == QBoxLayout::RightToLeft || dir == QBoxLayout::LeftToRight; -} - -// TODO 提取到DStyle -static inline QColor getColor(const QStyleOption *option, DPalette::ColorType type, const QWidget *w) -{ - if (auto s = qobject_cast(w->style())) { - const DPalette &pa = DApplicationHelper::instance()->palette(w, option->palette); - return s->generatedBrush(option, pa.brush(type), pa.currentColorGroup(), type).color(); - } - return QColor(); -} - -// 获得边框线颜色,与chameleonstyle保持一致,TODO 提取到DStyle -static inline QColor getTabbarBorderColor(const QStyleOption *opt, const QWidget *w) -{ - if (DGuiApplicationHelper::instance()->paletteType() == DGuiApplicationHelper::LightType - || (DGuiApplicationHelper::instance()->paletteType() == DGuiApplicationHelper::UnknownType - && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)) { - return getColor(opt, DPalette::FrameBorder, w); - } else if (DGuiApplicationHelper::instance()->paletteType() == DGuiApplicationHelper::DarkType - || (DGuiApplicationHelper::instance()->paletteType() == DGuiApplicationHelper::UnknownType - && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType)){ - return QColor(0, 0, 0, static_cast(0.05 * 255)); - } else { - return getColor(opt, DPalette::FrameBorder, w); - } -} - class DMovableTabWidget : public QWidget { public: @@ -182,24 +139,21 @@ d->rightB->setFixedSize(0, 0); d->rightB->installEventFilter(this); - qq->installEventFilter(this); - connect(leftScrollButton, &DIconButton::clicked, d->leftB, &QToolButton::click); connect(rightScrollButton, &DIconButton::clicked, d->rightB, &QToolButton::click); - layout = new QBoxLayout(shapeToDirection(d->shape), qq); + layout = new QHBoxLayout(qq); layout->setMargin(0); layout->setSpacing(0); - layout->setContentsMargins(0, 0, 0, 0); - - leftBtnL = new QSpacerItem(0, 0); + stretch = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); leftBtnR = new QSpacerItem(0, 0); + leftBtnL = new QSpacerItem(0, 0); rightBtnL = new QSpacerItem(0, 0); - addBtnL = new QSpacerItem(0, 0); - addBtnR = new QSpacerItem(0, 0); - stretch = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + addBtnL = new QSpacerItem(DStyle::pixelMetric(style(), DStyle::PM_ContentsSpacing), 0); + addBtnR = new QSpacerItem(DStyle::pixelMetric(style(), DStyle::PM_ContentsSpacing), 0); layout->addSpacerItem(leftBtnL); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(leftScrollButton); layout->addSpacerItem(leftBtnR); @@ -208,15 +162,13 @@ layout->addWidget(rightScrollButton); layout->addSpacerItem(addBtnL); - layout->addWidget(addButton); + layout->addWidget(addButton, Qt::AlignCenter); layout->addSpacerItem(addBtnR); layout->addSpacerItem(stretch); d->expanding = false; qq->setTabLabelAlignment(Qt::AlignCenter); - updateTabAlignment(); - qq->setFocusProxy(this); connect(this, &DTabBarPrivate::currentChanged, this, &DTabBarPrivate::onCurrentChanged); @@ -226,43 +178,6 @@ connect(this, &DTabBarPrivate::tabBarDoubleClicked, qq, &DTabBar::tabBarDoubleClicked); } - // 刷新占位符弹簧的方向及大小,(当前布局方向、是否为直角风格、滑块是否显示、添加按钮是否显示) - void refreshSpacers(bool visible = true) - { - D_Q(DTabBar); - const int TabSpacing = DStyle::pixelMetric(style(), DStyle::PM_ContentsSpacing, nullptr) / 2; - bool isRectType = q->property("_d_dtk_tabbartab_type").toBool(); - int ll = 0; - int lr = 0; - int rl = 0; - int al = 0; - if (visible) { - ll = isRectType ? 6 : TabSpacing; - lr = isRectType ? 6 : TabSpacing; - rl = isRectType ? 6 : TabSpacing; - if (visibleAddButton) { - al = isRectType ? 12 : TabSpacing * 2; - } - } else { - if (visibleAddButton) { - al = isRectType ? 6 : TabSpacing; - } - } - - // 根据布局方向设置不同弹簧策略 - if (horz(shapeToDirection(shape()))) { - leftBtnL->changeSize(ll, 0); - leftBtnR->changeSize(lr, 0); - rightBtnL->changeSize(rl, 0); - addBtnL->changeSize(al, 0); - } else { - leftBtnL->changeSize(0, ll); - leftBtnR->changeSize(0, lr); - rightBtnL->changeSize(0, rl); - addBtnL->changeSize(0, al); - } - } - ~DTabBarPrivate() override { if (stretchIsRemove && stretch) { @@ -270,18 +185,6 @@ } } - // 更新布局内的控件的对齐方式 - void updateTabAlignment() - { - Qt::Alignment tabAlignment = Qt::AlignCenter; - - for (int i = 0; i < layout->count(); i++) { - QLayoutItem *item = layout->itemAt(i); - item->setAlignment(tabAlignment); - } - layout->invalidate(); - } - void moveTabOffset(int index, int offset) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); @@ -293,38 +196,6 @@ update(); } - // 直角Tabbar,绘制边框延长线。 - /* - ---- ---- - xxxxxx - ---- ---- - */ - void drawDTabbarExtendLine() - { - D_Q(DTabBar); - - if (!q->property("_d_dtk_tabbartab_type").toBool()) { - return; - } - - QStyleOptionTabBarBase optTabBase; - QTabBarPrivate::initStyleBaseOption(&optTabBase, this, q->size()); - - QStylePainter p(q); - QStyleOption* opt = &optTabBase; - p.setPen(getTabbarBorderColor(opt, this)); - - const QRect dtabbarRect = q->rect(); - const QRect qtabbarRect = this->rect(); - - // 不用区分是否竖直,线坐标一致, - p.drawLine(dtabbarRect.topLeft(), mapTo(q, qtabbarRect.topLeft())); - p.drawLine(dtabbarRect.bottomLeft(), mapTo(q, qtabbarRect.bottomLeft())); - - p.drawLine(mapTo(q, qtabbarRect.topRight()), dtabbarRect.topRight()); - p.drawLine(mapTo(q, qtabbarRect.bottomRight()), dtabbarRect.bottomRight()); - } - struct TabBarAnimation : public QVariantAnimation { TabBarAnimation(QTabBarPrivate::Tab *t, QTabBarPrivate *_priv, @@ -424,7 +295,7 @@ DIconButton *leftScrollButton; DIconButton *rightScrollButton; - QBoxLayout *layout; + QHBoxLayout *layout; QSpacerItem *stretch; QSpacerItem *leftBtnL; QSpacerItem *leftBtnR; @@ -488,10 +359,7 @@ int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); QRect grabRect = tabRect(d->pressedIndex); - if (verticalTabs(shape())) - grabRect.adjust(0, -taboverlap, 0, taboverlap); - else - grabRect.adjust(-taboverlap, 0, taboverlap, 0); + grabRect.adjust(-taboverlap, 0, taboverlap, 0); QPixmap grabImage(grabRect.size() * devicePixelRatioF()); grabImage.setDevicePixelRatio(devicePixelRatioF()); @@ -501,15 +369,10 @@ QStyleOptionTab tab; initStyleOption(&tab, d->pressedIndex); - tab.position = QStyleOptionTab::OnlyOneTab; - if (verticalTabs(shape())) - tab.rect.moveTopLeft(QPoint(0, taboverlap)); - else - tab.rect.moveTopLeft(QPoint(taboverlap, 0)); + tab.rect.moveTopLeft(QPoint(taboverlap, 0)); // 强制让文本居中 tab.rightButtonSize = QSize(); q_func()->paintTab(&p, d->pressedIndex, tab); - p.end(); reinterpret_cast(d->movingTab)->setPixmap(grabImage); d->movingTab->setGeometry(grabRect); @@ -1075,17 +938,30 @@ bool DTabBarPrivate::eventFilter(QObject *watched, QEvent *event) { - QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); D_Q(DTabBar); + QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); + bool enabled = q->property("_d_dtk_tabbartab_type").toBool(); if (watched == d->leftB) { switch (event->type()) { case QEvent::Show: - refreshSpacers(); + if (enabled) { + leftBtnL->changeSize(10, 0); + leftBtnR->changeSize(10, 0); + rightBtnL->changeSize(10, 0); + if (!q->visibleAddButton()) + addBtnL->changeSize(10, 0); + } leftScrollButton->show(); break; case QEvent::Hide: - refreshSpacers(false); + if (enabled) { + leftBtnR->changeSize(0, 0); + leftBtnL->changeSize(0, 0); + rightBtnL->changeSize(0, 0); + if (!q->visibleAddButton()) + addBtnL->changeSize(0, 0); + } leftScrollButton->hide(); break; case QEvent::EnabledChange: @@ -1119,8 +995,6 @@ default: break; } - } else if(watched == q) { - drawDTabbarExtendLine(); } return QTabBar::eventFilter(watched, event); @@ -1168,15 +1042,13 @@ QStylePainter p(this); int selected = -1; - int cutLeft = -1; - int cutRight = -1; +// int cut = -1; +// bool rtl = optTabBase.direction == Qt::RightToLeft; bool vertical = verticalTabs(d->shape); - QStyleOptionTab cutTabLeft; - QStyleOptionTab cutTabRight; +// QStyleOptionTab cutTab; selected = d->currentIndex; if (d->dragInProgress) selected = d->pressedIndex; - const QRect scrollRect = d->normalizedScrollRect(); for (int i = 0; i < d->tabList.count(); ++i) optTabBase.tabBarRect |= tabRect(i); @@ -1201,20 +1073,13 @@ if (!(tab.state & QStyle::State_Enabled)) { tab.palette.setCurrentColorGroup(QPalette::Disabled); } - // If this tab is partially obscured, make a note of it so that we can pass the information // along when we draw the tear. - QRect tabRect = d->tabList[i].rect; - int tabStart = vertical ? tabRect.top() : tabRect.left(); - int tabEnd = vertical ? tabRect.bottom() : tabRect.right(); - if (tabStart < scrollRect.left() + d->scrollOffset) { - cutLeft = i; - cutTabLeft = tab; - } else if (tabEnd > scrollRect.right() + d->scrollOffset) { - cutRight = i; - cutTabRight = tab; - } - +// if (((!vertical && (!rtl && tab.rect.left() < 0)) || (rtl && tab.rect.right() > width())) +// || (vertical && tab.rect.top() < 0)) { +// cut = i; +// cutTab = tab; +// } // Don't bother drawing a tab if the entire tab is outside of the visible tab bar. if ((!vertical && (tab.rect.right() < 0 || tab.rect.left() > width())) || (vertical && (tab.rect.bottom() < 0 || tab.rect.top() > height()))) @@ -1225,7 +1090,6 @@ continue; q->paintTab(&p, i, tab); -// p.drawControl(QStyle::CE_TabBarTab, tab); // Qt源码写法 if (i == flashTabIndex) { p.setOpacity(opacityOnFlash); @@ -1249,7 +1113,6 @@ } if (!d->dragInProgress) { q->paintTab(&p, selected, tab); -// p.drawControl(QStyle::CE_TabBarTab, tab); // Qt源码写法 if (selected == flashTabIndex) { p.setOpacity(opacityOnFlash); @@ -1258,25 +1121,16 @@ } } else { int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); - if (verticalTabs(d->shape)) - d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); - else - d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); + d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); } } // Only draw the tear indicator if necessary. Most of the time we don't need too. - if (d->leftB->isVisible() && cutLeft >= 0) { - cutTabLeft.rect = rect(); - cutTabLeft.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &cutTabLeft, this); - p.drawPrimitive(QStyle::PE_IndicatorTabTearLeft, cutTabLeft); - } - - if (d->rightB->isVisible() && cutRight >= 0) { - cutTabRight.rect = rect(); - cutTabRight.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &cutTabRight, this); - p.drawPrimitive(QStyle::PE_IndicatorTabTearRight, cutTabRight); - } +// if (d->leftB->isVisible() && cut >= 0) { +// cutTab.rect = rect(); +// cutTab.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicator, &cutTab, this); +// p.drawPrimitive(QStyle::PE_IndicatorTabTear, cutTab); +// } } void DTabBarPrivate::mouseMoveEvent(QMouseEvent *event) @@ -1600,18 +1454,34 @@ d->setShape(shape); if (old_vertical != new_vertical) { - // 设置对应shape上的策略 + if (QBoxLayout *layout = qobject_cast(this->layout())) { + if (new_vertical) + layout->setDirection(QBoxLayout::TopToBottom); + else + layout->setDirection(QBoxLayout::LeftToRight); + } + if (new_vertical) { d->leftScrollButton->setIcon(getArrowIcon(style(), Qt::UpArrow)); d->rightScrollButton->setIcon(getArrowIcon(style(), Qt::DownArrow)); - d->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + d->leftScrollButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + d->rightScrollButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + d->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + d->addButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + d->addButton->setFixedHeight(48); + d->addButton->setMinimumWidth(0); + d->addButton->setMaximumWidth(9999); } else { d->leftScrollButton->setIcon(getArrowIcon(style(), Qt::LeftArrow)); d->rightScrollButton->setIcon(getArrowIcon(style(), Qt::RightArrow)); - d->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); + d->leftScrollButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + d->rightScrollButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + d->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); + d->addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + d->addButton->setFixedWidth(48); + d->addButton->setMinimumHeight(0); + d->addButton->setMaximumHeight(9999); } - // 重新设置Direction - d->layout->setDirection(shapeToDirection(shape)); } } @@ -1884,7 +1754,8 @@ bool DTabBar::expanding() const { - return d_func()->expanding(); + QTabBarPrivate *dd = reinterpret_cast(qGetPtrHelper(d_func()->d_ptr)); + return dd->expanding; } void DTabBar::setExpanding(bool enabled) @@ -1895,7 +1766,7 @@ return; QTabBarPrivate *dd = reinterpret_cast(qGetPtrHelper(d->d_ptr)); dd->expanding = enabled; - auto auto_layout = d->layout; + QHBoxLayout *auto_layout = d->layout; if (enabled) { auto_layout->removeItem(d->stretch); @@ -1992,21 +1863,21 @@ { D_D(DTabBar); + int radius; setProperty("_d_dtk_tabbartab_type", enable); - d->refreshSpacers(); - int radius; - QSize size; if (enable) { radius = DStyle::pixelMetric(style(), DStyle::PM_FloatingWidgetRadius); - size = QSize(24, 24); + d->addButton->setMaximumSize(QSize(24, 24)); + d->rightScrollButton->setMaximumSize(QSize(24, 24)); + d->leftScrollButton->setMaximumSize(QSize(24, 24)); } else { radius = DStyle::pixelMetric(style(), DStyle::PM_FrameRadius); - size = d->addButton->sizeHint(); + QSize size = d->addButton->sizeHint(); + d->addButton->setMaximumSize(size); + d->rightScrollButton->setMaximumSize(size); + d->leftScrollButton->setMaximumSize(size); } - d->addButton->setMaximumSize(size); - d->rightScrollButton->setMaximumSize(size); - d->leftScrollButton->setMaximumSize(size); DStyle::setFrameRadius(d->rightScrollButton, radius); DStyle::setFrameRadius(d->leftScrollButton, radius); @@ -2039,7 +1910,14 @@ d->visibleAddButton = visibleAddButton; d->addButton->setVisible(visibleAddButton); - d->refreshSpacers(); + + if (visibleAddButton) { + d->addBtnL->changeSize(10, 0); + d->addBtnR->changeSize(10, 0); + } else { + d->addBtnL->changeSize(0, 0); + d->addBtnR->changeSize(0, 0); + } } /*! @@ -2311,7 +2189,7 @@ bool is_vertical = verticalTabs(dd->shape); if (is_vertical) { - size.setWidth(qMax(size.width(), dd->leftB->width())); + size.setWidth(qMax(size.width(), d->width())); } else { size.setHeight(qMax(size.height(), dd->leftB->height())); } diff -Nru dtkwidget-5.4.36/src/widgets/DTabletWindowOptionButton dtkwidget-5.5.17.1/src/widgets/DTabletWindowOptionButton --- dtkwidget-5.4.36/src/widgets/DTabletWindowOptionButton 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/DTabletWindowOptionButton 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1 @@ +#include "dtabletwindowoptionbutton.h" diff -Nru dtkwidget-5.4.36/src/widgets/dtabletwindowoptionbutton.cpp dtkwidget-5.5.17.1/src/widgets/dtabletwindowoptionbutton.cpp --- dtkwidget-5.4.36/src/widgets/dtabletwindowoptionbutton.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtabletwindowoptionbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2020 ~ 2021 Deepin Technology Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include "dtabletwindowoptionbutton.h" +#include "dstyleoption.h" + +DWIDGET_BEGIN_NAMESPACE + +/*! + * \~english \class DTabletWindowOptionButton + * \~english \brief The DTabletWindowOptionButton class is used as the unified tablet window option button. + * + * \~english It's actually a special DImageButton which has the appearance of option button. + * + * \~chinese \class DTabletWindowOptionButton + * \~chinese \brief DTabletWindowOptionButton 类是 DTK 平板窗口统一的菜单按钮控件。 + * \~chinese 点击按钮后,默认会显示程序主菜单,包含“关于”、“帮助”等项。 + */ + +/*! + * \~chinese \brief DTabletWindowOptionButton::DTabletWindowOptionButton 是 DTabletWindowOptionButton 的构造 + * \~chinese 函数,返回 DTabletWindowOptionButton 对象,普通程序一般无需使用。 + * \~chinese \param parent 为创建对象的父控件。 + */ +DTabletWindowOptionButton::DTabletWindowOptionButton(QWidget *parent) + : DIconButton(DStyle::SP_TitleMoreButton, parent) +{ + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); + setFlat(true); +} + +QSize DTabletWindowOptionButton::sizeHint() const +{ + return iconSize(); +} + +void DTabletWindowOptionButton::initStyleOption(DStyleOptionButton *option) const +{ + DIconButton::initStyleOption(option); + + option->features |= QStyleOptionButton::ButtonFeature(DStyleOptionButton::TitleBarButton); +} + +DWIDGET_END_NAMESPACE diff -Nru dtkwidget-5.4.36/src/widgets/dtabletwindowoptionbutton.h dtkwidget-5.5.17.1/src/widgets/dtabletwindowoptionbutton.h --- dtkwidget-5.4.36/src/widgets/dtabletwindowoptionbutton.h 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtabletwindowoptionbutton.h 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 ~ 2021 Deepin Technology Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef DTABLETWINDOWOPTIONBUTTON_H +#define DTABLETWINDOWOPTIONBUTTON_H + +#include + +DWIDGET_BEGIN_NAMESPACE + +class LIBDTKWIDGETSHARED_EXPORT DTabletWindowOptionButton : public DIconButton +{ + Q_OBJECT +public: + DTabletWindowOptionButton(QWidget *parent = 0); + + QSize sizeHint() const override; + +protected: + void initStyleOption(DStyleOptionButton *option) const override; +}; + +DWIDGET_END_NAMESPACE + +#endif // DTABLETWINDOWOPTIONBUTTON_H diff -Nru dtkwidget-5.4.36/src/widgets/dtextedit.cpp dtkwidget-5.5.17.1/src/widgets/dtextedit.cpp --- dtkwidget-5.4.36/src/widgets/dtextedit.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtextedit.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -12,6 +12,8 @@ #include #include +#include + #include #include @@ -104,6 +106,17 @@ query->setValue(property, rc); query->accept(); return true; + } else if (property == Qt::ImAnchorRectangle) { + QTextEditPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); + QRect anchorRect = d->control->inputMethodQuery(Qt::ImAnchorRectangle, true).toRect(); + + DStyleHelper dstyle(style()); + int frame_radius = dstyle.pixelMetric(DStyle::PM_FrameRadius, nullptr, this); + + anchorRect.adjust(frame_radius, 0, frame_radius, 0); + query->setValue(Qt::ImAnchorRectangle, anchorRect); + query->accept(); + return true; } } } diff -Nru dtkwidget-5.4.36/src/widgets/dtitlebar.cpp dtkwidget-5.5.17.1/src/widgets/dtitlebar.cpp --- dtkwidget-5.4.36/src/widgets/dtitlebar.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtitlebar.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -32,6 +32,7 @@ #include "dwindowmaxbutton.h" #include "dwindowminbutton.h" #include "dwindowoptionbutton.h" +#include "dtabletwindowoptionbutton.h" #include "dwindowquitfullbutton.h" #include "dplatformwindowhandle.h" #include "daboutdialog.h" @@ -98,7 +99,7 @@ DWindowMinButton *minButton; DWindowMaxButton *maxButton; DWindowCloseButton *closeButton; - DWindowOptionButton *optionButton; + DIconButton *optionButton; DWindowQuitFullButton *quitFullButton; DLabel *titleLabel; QWidget *customWidget = nullptr; @@ -132,7 +133,9 @@ Q_DECLARE_PUBLIC(DTitlebar) }; -DTitlebarPrivate::DTitlebarPrivate(DTitlebar *qq): DObjectPrivate(qq) +DTitlebarPrivate::DTitlebarPrivate(DTitlebar *qq) + : DObjectPrivate(qq) + , quitFullButton(nullptr) { } @@ -152,8 +155,13 @@ minButton = new DWindowMinButton; maxButton = new DWindowMaxButton; closeButton = new DWindowCloseButton; - optionButton = new DWindowOptionButton; - quitFullButton = new DWindowQuitFullButton; + + if (DGuiApplicationHelper::isTabletEnvironment()) { + optionButton = new DTabletWindowOptionButton; + } else { + optionButton = new DWindowOptionButton; + } + separatorTop = new DHorizontalLine(q); separator = new DHorizontalLine(q); titleLabel = centerArea; @@ -163,7 +171,6 @@ maxButton->installEventFilter(q); closeButton->installEventFilter(q); optionButton->installEventFilter(q); - quitFullButton->installEventFilter(q); optionButton->setObjectName("DTitlebarDWindowOptionButton"); optionButton->setIconSize(QSize(DefaultTitlebarHeight, DefaultTitlebarHeight)); @@ -177,10 +184,7 @@ closeButton->setObjectName("DTitlebarDWindowCloseButton"); closeButton->setAccessibleName("DTitlebarDWindowCloseButton"); closeButton->setIconSize(QSize(DefaultTitlebarHeight, DefaultTitlebarHeight)); - quitFullButton->setObjectName("DTitlebarDWindowQuitFullscreenButton"); - quitFullButton->setAccessibleName("DTitlebarDWindowQuitFullscreenButton"); - quitFullButton->setIconSize(QSize(DefaultTitlebarHeight, DefaultTitlebarHeight)); - quitFullButton->hide(); + iconLabel->setIconSize(QSize(DefaultIconWidth, DefaultIconHeight)); iconLabel->setWindowFlags(Qt::WindowTransparentForInput); @@ -213,7 +217,15 @@ buttonLayout->addWidget(optionButton); buttonLayout->addWidget(minButton); buttonLayout->addWidget(maxButton); - buttonLayout->addWidget(quitFullButton); + if (!DGuiApplicationHelper::isTabletEnvironment()) { + quitFullButton = new DWindowQuitFullButton; + quitFullButton->installEventFilter(q); + quitFullButton->setObjectName("DTitlebarDWindowQuitFullscreenButton"); + quitFullButton->setAccessibleName("DTitlebarDWindowQuitFullscreenButton"); + quitFullButton->setIconSize(QSize(DefaultTitlebarHeight, DefaultTitlebarHeight)); + quitFullButton->hide(); + buttonLayout->addWidget(quitFullButton); + } buttonLayout->addWidget(closeButton); rightArea->setWindowFlag(Qt::WindowTransparentForInput); @@ -245,15 +257,17 @@ q->setFixedHeight(DefaultTitlebarHeight); q->setMinimumHeight(DefaultTitlebarHeight); - q->connect(quitFullButton, &DWindowQuitFullButton::clicked, q, [ = ]() { - bool isFullscreen = targetWindow()->windowState().testFlag(Qt::WindowFullScreen); - if (isFullscreen) { - targetWindow()->showNormal(); - } else { - targetWindow()->showFullScreen(); - } - }); - q->connect(optionButton, &DWindowOptionButton::clicked, q, &DTitlebar::optionClicked); + if (!DGuiApplicationHelper::isTabletEnvironment()) { + q->connect(quitFullButton, &DWindowQuitFullButton::clicked, q, [ = ]() { + bool isFullscreen = targetWindow()->windowState().testFlag(Qt::WindowFullScreen); + if (isFullscreen) { + targetWindow()->showNormal(); + } else { + targetWindow()->showFullScreen(); + } + }); + } + q->connect(optionButton, &DIconButton::clicked, q, &DTitlebar::optionClicked); q->connect(DWindowManagerHelper::instance(), SIGNAL(windowMotifWMHintsChanged(quint32)), q, SLOT(_q_onTopWindowMotifHintsChanged(quint32))); q->connect(DGuiApplicationHelper::instance()->systemTheme(), &DPlatformTheme::iconThemeNameChanged, q, [ = ]() { @@ -315,12 +329,14 @@ bool isFullscreen = targetWindow()->windowState().testFlag(Qt::WindowFullScreen); auto mainWindow = qobject_cast(targetWindow()); if (!isFullscreen) { - quitFullButton->hide(); + if (!DGuiApplicationHelper::isTabletEnvironment()) + quitFullButton->hide(); mainWindow->setMenuWidget(q); showOnFullscreen(); } else { // must set to empty - quitFullButton->show(); + if (!DGuiApplicationHelper::isTabletEnvironment()) + quitFullButton->show(); if (mainWindow->menuWidget()) { mainWindow->menuWidget()->setParent(nullptr); mainWindow->setMenuWidget(Q_NULLPTR); @@ -360,7 +376,6 @@ bool showMin = (type.testFlag(Qt::WindowMinimizeButtonHint) || forceShow) && !forceHide; minButton->setVisible(showMin); - bool allowResize = true; if (q->window() && q->window()->windowHandle()) { @@ -371,23 +386,22 @@ bool showMax = (type.testFlag(Qt::WindowMaximizeButtonHint) || forceShow) && !forceHide && allowResize; bool showClose = type.testFlag(Qt::WindowCloseButtonHint) && useDXcb; bool showQuit = isFullscreen && useDXcb && fullScreenButtonVisible; -// qDebug() << "max:" -// << "allowResize" << allowResize -// << "useDXcb" << useDXcb -// << "forceHide" << forceHide -// << "type.testFlag(Qt::WindowMaximizeButtonHint)" << type.testFlag(Qt::WindowMaximizeButtonHint); maxButton->setVisible(showMax); closeButton->setVisible(showClose); - quitFullButton->setVisible(showQuit); + + if (!DGuiApplicationHelper::isTabletEnvironment()) + quitFullButton->setVisible(showQuit); + // qDebug() << "max:" + // << "allowResize" << allowResize + // << "useDXcb" << useDXcb + // << "forceHide" << forceHide + // << "type.testFlag(Qt::WindowMaximizeButtonHint)" << type.testFlag(Qt::WindowMaximizeButtonHint); } void DTitlebarPrivate::updateButtonsFunc() { // TASK-18145 (bug-17474) do not setMotifFunctions on wayland if (!targetWindowHandle || !qgetenv("WAYLAND_DISPLAY").isEmpty()) { - if (!targetWindowHandle) { - qWarning() << "Warning: setdisableflags cannot be called when window construction is incomplete!"; - } return; } @@ -521,7 +535,7 @@ D_Q(DTitlebar); // add switch theme sub menu - if (!switchThemeMenu) { + if (!switchThemeMenu && DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::Attribute::IsDeepinPlatformTheme)) { bool disableDtkSwitchThemeMenu = qEnvironmentVariableIsSet("KLU_DISABLE_MENU_THEME"); if (!disableDtkSwitchThemeMenu) { switchThemeMenu = new QMenu(qApp->translate("TitleBarMenu", "Theme"), menu); @@ -546,7 +560,8 @@ themeSeparator = menu->addSeparator(); switchThemeMenu->menuAction()->setVisible(canSwitchTheme); - themeSeparator->setVisible(canSwitchTheme); + + themeSeparator->setVisible(DGuiApplicationHelper::isTabletEnvironment() ? false : canSwitchTheme); } } @@ -569,7 +584,9 @@ if (!quitAction) { quitAction = new QAction(qApp->translate("TitleBarMenu", "Exit"), menu); QObject::connect(quitAction, SIGNAL(triggered(bool)), q, SLOT(_q_quitActionTriggered())); - menu->addAction(quitAction); + if (!DGuiApplicationHelper::isTabletEnvironment()) { + menu->addAction(quitAction); + } } } diff -Nru dtkwidget-5.4.36/src/widgets/dtitlebar.h dtkwidget-5.5.17.1/src/widgets/dtitlebar.h --- dtkwidget-5.4.36/src/widgets/dtitlebar.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtitlebar.h 2021-06-30 10:52:09.000000000 +0000 @@ -54,7 +54,7 @@ bool autoHideOnFullscreen() const; void setAutoHideOnFullscreen(bool autohide); - void setVisible(bool visible) Q_DECL_OVERRIDE; + virtual void setVisible(bool visible) Q_DECL_OVERRIDE; void setEmbedMode(bool embed); bool menuIsVisible() const; @@ -73,8 +73,8 @@ void setDisableFlags(Qt::WindowFlags flags); Qt::WindowFlags disableFlags() const; - QSize sizeHint() const; - QSize minimumSizeHint() const; + virtual QSize sizeHint() const override; + virtual QSize minimumSizeHint() const override; bool blurBackground() const; void setFullScreenButtonVisible(bool enabled); diff -Nru dtkwidget-5.4.36/src/widgets/dtoolbutton.cpp dtkwidget-5.5.17.1/src/widgets/dtoolbutton.cpp --- dtkwidget-5.4.36/src/widgets/dtoolbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtoolbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -52,14 +52,28 @@ QSize DToolButton::sizeHint() const { - QSize size = QToolButton::sizeHint(); - //计算图标文字同时存在时的宽度 - if (!icon().isNull() && !text().isEmpty()) { - QFontMetrics fm = fontMetrics(); - int textWidth = fm.size(Qt::TextShowMnemonic, text()).width(); - size.setWidth(size.width() + textWidth); - } - return size; + return QToolButton::sizeHint(); +} + +/*! + * \~chinese \brief DToolButton::setAlignment 设置DToolButton的对齐方式 + * \~chinese \param flag Qt::AlignCenter居中对齐 Qt::AlignLeft左对齐 Qt::AlignRight右对齐 + */ +void DToolButton::setAlignment(Qt::Alignment flag) +{ + this->setProperty("_d_dtk_toolButtonAlign", QVariant(flag)); +} + +/*! + * \~chinese \brief DToolButton::alignment 返回DToolButton当前的对齐方式 + * \~chinese \return 如果setAlignment设置成功则返回当前对齐方式,否则返回Qt::AlignLeft + */ +Qt::Alignment DToolButton::alignment() const +{ + if(this->property("_d_dtk_toolButtonAlign").isValid()) + return static_cast(this->property("_d_dtk_toolButtonAlign").toInt()); + else + return Qt::AlignLeft; } DWIDGET_END_NAMESPACE diff -Nru dtkwidget-5.4.36/src/widgets/dtoolbutton.h dtkwidget-5.5.17.1/src/widgets/dtoolbutton.h --- dtkwidget-5.4.36/src/widgets/dtoolbutton.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dtoolbutton.h 2021-06-30 10:52:09.000000000 +0000 @@ -31,6 +31,8 @@ Q_OBJECT public: DToolButton(QWidget *parent = nullptr); + void setAlignment(Qt::Alignment flag); + Qt::Alignment alignment() const; protected: void paintEvent(QPaintEvent *event) override; diff -Nru dtkwidget-5.4.36/src/widgets/dwarningbutton.cpp dtkwidget-5.5.17.1/src/widgets/dwarningbutton.cpp --- dtkwidget-5.4.36/src/widgets/dwarningbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/dwarningbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -1,5 +1,5 @@ #include "dwarningbutton.h" -#include "dapplicationhelper.h" +#include "dpalettehelper.h" #include "dstyleoption.h" #include @@ -29,7 +29,7 @@ void DWarningButton::initStyleOption(QStyleOptionButton *option) const { DPushButton::initStyleOption(option); - DPalette pa = DApplicationHelper::instance()->palette(this); + DPalette pa = DPaletteHelper::instance()->palette(this); option->palette.setBrush(QPalette::ButtonText, pa.textWarning()); option->features |= QStyleOptionButton::ButtonFeature(DStyleOptionButton::WarningButton); } diff -Nru dtkwidget-5.4.36/src/widgets/private/dapplication_p.h dtkwidget-5.5.17.1/src/widgets/private/dapplication_p.h --- dtkwidget-5.4.36/src/widgets/private/dapplication_p.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/private/dapplication_p.h 2021-06-30 10:52:09.000000000 +0000 @@ -24,6 +24,7 @@ #include "dpathbuf.h" #include +#include class QLocalServer; class QTranslator; @@ -53,6 +54,12 @@ bool loadTranslator(QList translateDirs, const QString &name, QList localeFallback); void _q_onNewInstanceStarted(); + // 为控件适应当前虚拟键盘的位置 + void doAcclimatizeVirtualKeyboard(QWidget *window, QWidget *widget, bool allowResizeContentsMargins); + void acclimatizeVirtualKeyboardForFocusWidget(bool allowResizeContentsMargins); + void _q_panWindowContentsForVirtualKeyboard(); + void _q_resizeWindowContentsForVirtualKeyboard(); + static bool isUserManualExists(); public: // int m_pidLockFD = 0; @@ -74,7 +81,15 @@ bool visibleMenuIcon = false; bool autoActivateWindows = false; + DAppHandler *appHandler = Q_NULLPTR; DAboutDialog *aboutDialog = Q_NULLPTR; + + // 需要自适应虚拟键盘环境的窗口 + QPointer activeInputWindow; + // 上一次为适配虚拟键盘所设置的值 + QPair lastContentsMargins; + QMargins activeInputWindowContentsMargins; + QList acclimatizeVirtualKeyboardWindows; }; DWIDGET_END_NAMESPACE diff -Nru dtkwidget-5.4.36/src/widgets/private/ddialog_p.h dtkwidget-5.5.17.1/src/widgets/private/ddialog_p.h --- dtkwidget-5.4.36/src/widgets/private/ddialog_p.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/private/ddialog_p.h 2021-06-30 10:52:09.000000000 +0000 @@ -55,6 +55,7 @@ DTitlebar *titleBar = nullptr; QHBoxLayout *iconLayout; QVBoxLayout *contentLayout; + QWidget *contentWidget = nullptr; QHBoxLayout *buttonLayout; const QScreen *targetScreen = nullptr; QSpacerItem *spacer = nullptr; diff -Nru dtkwidget-5.4.36/src/widgets/private/dpalettehelper_p.h dtkwidget-5.5.17.1/src/widgets/private/dpalettehelper_p.h --- dtkwidget-5.4.36/src/widgets/private/dpalettehelper_p.h 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/private/dpalettehelper_p.h 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,22 @@ +#ifndef DPALETTEHELPER_P_H +#define DPALETTEHELPER_P_H + +#include "dpalettehelper.h" + +#include + +DWIDGET_BEGIN_NAMESPACE + +class DPaletteHelperPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate +{ +public: + DPaletteHelperPrivate(DPaletteHelper *qq); + + QHash paletteCache; + + D_DECLARE_PUBLIC(DPaletteHelper) +}; + +DWIDGET_END_NAMESPACE + +#endif // DPALETTEHELPER_P_H diff -Nru dtkwidget-5.4.36/src/widgets/private/mpris/dbusmpris.h dtkwidget-5.5.17.1/src/widgets/private/mpris/dbusmpris.h --- dtkwidget-5.4.36/src/widgets/private/mpris/dbusmpris.h 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/private/mpris/dbusmpris.h 2021-06-30 10:52:09.000000000 +0000 @@ -67,6 +67,14 @@ inline bool canControl() const { return qvariant_cast< bool >(property("CanControl")); } + Q_PROPERTY(bool CanShowInUI READ canShowInUI NOTIFY CanShowInUIChanged) + inline bool canShowInUI() const + { + QVariant showInUI = property("CanShowInUI"); + // 属性有效且为假表示不能控制 无效或为真表示可以控制 + return showInUI.isValid() ? showInUI.toBool() : true; + } + Q_PROPERTY(bool CanGoNext READ canGoNext NOTIFY CanGoNextChanged) inline bool canGoNext() const { return qvariant_cast< bool >(property("CanGoNext")); } @@ -193,6 +201,7 @@ void Seeked(qlonglong Position); // begin property changed signals void CanControlChanged(bool value); +void CanShowInUIChanged(bool value); void CanGoNextChanged(bool value); void CanGoPreviousChanged(bool value); void CanPauseChanged(bool value); diff -Nru dtkwidget-5.4.36/src/widgets/private/private.pri dtkwidget-5.5.17.1/src/widgets/private/private.pri --- dtkwidget-5.4.36/src/widgets/private/private.pri 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/private/private.pri 2021-06-30 10:52:09.000000000 +0000 @@ -53,7 +53,8 @@ $$PWD/dalertcontrol_p.h \ $$PWD/dsearchcombobox_p.h \ $$PWD/dprintpreviewdialog_p.h \ - $$PWD/dprintpreviewwidget_p.h + $$PWD/dprintpreviewwidget_p.h \ + $$PWD/dpalettehelper_p.h SOURCES += \ $$PWD/dthemehelper.cpp diff -Nru dtkwidget-5.4.36/src/widgets/private/settings/navigation.cpp dtkwidget-5.5.17.1/src/widgets/private/settings/navigation.cpp --- dtkwidget-5.4.36/src/widgets/private/settings/navigation.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/private/settings/navigation.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include "navigationdelegate.h" @@ -91,9 +91,9 @@ d->navbar->setContentsMargins(0, 0, 0, 0); d->navbar->setAutoFillBackground(true); d->navbar->setViewportMargins(10, 0, 10, 0); - DPalette pa = DApplicationHelper::instance()->palette(d->navbar); + DPalette pa = DPaletteHelper::instance()->palette(d->navbar); pa.setBrush(DPalette::ItemBackground, Qt::transparent); - DApplicationHelper::instance()->setPalette(d->navbar, pa); + DPaletteHelper::instance()->setPalette(d->navbar, pa); d->navbar->setSelectionMode(QListView::SingleSelection); d->navbar->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); diff -Nru dtkwidget-5.4.36/src/widgets/widgets.pri dtkwidget-5.5.17.1/src/widgets/widgets.pri --- dtkwidget-5.4.36/src/widgets/widgets.pri 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/src/widgets/widgets.pri 2021-06-30 10:52:09.000000000 +0000 @@ -50,6 +50,7 @@ $$PWD/dwindowminbutton.h \ $$PWD/dwindowclosebutton.h \ $$PWD/dwindowoptionbutton.h \ + $$PWD/dtabletwindowoptionbutton.h \ $$PWD/dwindowquitfullbutton.h \ $$PWD/dshortcutedit.h \ $$PWD/dsimplelistview.h \ @@ -114,7 +115,8 @@ $$PWD/dtoolbutton.h \ $$PWD/dsearchcombobox.h \ $$PWD/dprintpreviewwidget.h \ - $$PWD/dprintpickcolorwidget.h + $$PWD/dprintpickcolorwidget.h \ + $$PWD/dpalettehelper.h SOURCES += $$PWD/dslider.cpp \ $$PWD/dbackgroundgroup.cpp \ @@ -136,6 +138,7 @@ $$PWD/dwindowminbutton.cpp \ $$PWD/dwindowclosebutton.cpp \ $$PWD/dwindowoptionbutton.cpp \ + $$PWD/dtabletwindowoptionbutton.cpp \ $$PWD/dwindowquitfullbutton.cpp \ $$PWD/dshortcutedit.cpp \ $$PWD/dsimplelistview.cpp \ @@ -199,7 +202,8 @@ $$PWD/dtoolbutton.cpp \ $$PWD/dsearchcombobox.cpp \ $$PWD/dprintpreviewwidget.cpp \ - $$PWD/dprintpickcolorwidget.cpp + $$PWD/dprintpickcolorwidget.cpp \ + $$PWD/dpalettehelper.cpp RESOURCES += \ $$PWD/icons.qrc \ @@ -341,6 +345,7 @@ $$PWD/DWindowMaxButton \ $$PWD/DWindowMinButton \ $$PWD/DWindowOptionButton \ + $$PWD/DTabletWindowOptionButton \ $$PWD/DWindowQuitFullButton \ $$PWD/DApplicationHelper \ $$PWD/DFloatingWidget \ @@ -362,4 +367,5 @@ $$PWD/DAlertControl \ $$PWD/DSearchComboBox \ $$PWD/DPrintPreviewDialog \ - $$PWD/DFileChooserEdit + $$PWD/DFileChooserEdit \ + $$PWD/DPaletteHelper diff -Nru dtkwidget-5.4.36/tests/main.cpp dtkwidget-5.5.17.1/tests/main.cpp --- dtkwidget-5.4.36/tests/main.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/main.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -21,11 +21,6 @@ #include #include - -#ifdef QT_DEBUG -#include -#endif - int main(int argc, char *argv[]) { // gerrit编译时没有显示器,需要指定环境变量 @@ -33,11 +28,5 @@ QApplication app(argc, argv); ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - -#ifdef QT_DEBUG - __sanitizer_set_report_path("asan.log"); -#endif - - return ret; + return RUN_ALL_TESTS(); } diff -Nru dtkwidget-5.4.36/tests/src/src.pri dtkwidget-5.5.17.1/tests/src/src.pri --- dtkwidget-5.4.36/tests/src/src.pri 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/src.pri 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1 @@ +include($$PWD/widgets/widgets.pri) diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dalertcontrol.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dalertcontrol.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dalertcontrol.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dalertcontrol.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,74 @@ +#include +#include "dalertcontrol.h" +#include "private/dalertcontrol_p.h" +#include "DLineEdit" +#include "DWidget" +#include + +DWIDGET_USE_NAMESPACE + +class ut_DAlertcontrol : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + + DWidget *widget = nullptr; + DLineEdit *lineEdit = nullptr; + DAlertControl *control = nullptr; +}; + +void ut_DAlertcontrol::SetUp() +{ + widget = new DWidget(nullptr); + lineEdit = new DLineEdit(widget); + control = new DAlertControl(lineEdit, widget); + + widget->resize(320, 280); + lineEdit->resize(180, 80); + lineEdit->move(40, 10); +} + +void ut_DAlertcontrol::TearDown() +{ + control->deleteLater(); + lineEdit->deleteLater(); + widget->deleteLater(); +} + +TEST_F(ut_DAlertcontrol, showALertMessage) +{ + // 测试 LineEdit 的文字内容是否设置成功 + QString testStr = QStringLiteral("xxxxxxxxxxxxxxxxxxxxxxxxxx"); + + lineEdit->setText(testStr); + ASSERT_EQ(lineEdit->text(), testStr); + + // 测试 showAlertMessage 是否生效 + control->showAlertMessage(testStr); + ASSERT_EQ(control->d_func()->tooltip->text(), testStr); + + control->hideAlertMessage(); + ASSERT_EQ(control->d_func()->frame->isVisible(), false); + + // 测试LineEdit里面设置的警告色是否正常,setAlert 是否生效 + control->setAlert(false); + ASSERT_EQ(control->isAlert(), false); + + control->setAlertColor(Qt::red); + control->setAlert(true); + ASSERT_EQ(control->isAlert(), true); + ASSERT_EQ(QColor(Qt::red) == control->alertColor(), true); + + // 默认左对齐,测试右对齐 + control->setMessageAlignment(Qt::AlignRight); + ASSERT_EQ(control->messageAlignment(), Qt::AlignRight); + + // 测试输入文本后通过信号槽获取内容 + QObject::connect(lineEdit, &DLineEdit::textChanged, widget, [&](const QString &text){ + control->showAlertMessage(lineEdit->text()); + ASSERT_EQ(text, testStr); + }); + + emit lineEdit->textChanged(testStr); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_danchor.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_danchor.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_danchor.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_danchor.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "danchors.h" +#include + +DWIDGET_USE_NAMESPACE + +class ut_DAnchors : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + QWidget *widget = nullptr; +}; + +void ut_DAnchors::SetUp() +{ + widget = new QWidget; + widget->resize(300, 200); +} + +void ut_DAnchors::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DAnchors, testDAnchors) +{ + // 锚定布局也是布局管理的一种 + QLabel *lb1 = new QLabel("anchor1", widget); + QLabel *lb2 = new QLabel("anchor2", widget); + + DAnchors anchor1(lb1); + DAnchors anchor2(lb2); + + int margin = 15; + anchor2.setLeftMargin(margin); + ASSERT_TRUE(anchor2.leftMargin() == margin); + anchor2.setTop(anchor1.bottom()); + anchor2.setLeft(anchor1.right()); + + anchor1.moveCenter(QPoint(widget->width() / 2, widget->height() / 2)); + ASSERT_TRUE(anchor1->pos().x() < anchor2->pos().x()); + ASSERT_TRUE(anchor1->pos().y() > anchor2->pos().y()); + + anchor1.moveHorizontalCenter(widget->width()/2); + anchor1.moveVerticalCenter(widget->height()/2); + ASSERT_TRUE(anchor1->pos().x() < anchor2->pos().x()); + ASSERT_TRUE(anchor1->pos().y() > anchor2->pos().y()); + + // 测试offset改变的信号槽的有效性 + bool result = anchor2.setAnchor(Qt::AnchorRight, widget, Qt::AnchorRight); + ASSERT_TRUE(result); + + int offset = 10; + int signalTest = 0; + DAnchorsBase *anchorBase = anchor2.getAnchorBaseByWidget(widget); + ASSERT_TRUE(anchorBase != nullptr); + + anchorBase && QObject::connect(anchorBase, &DAnchorsBase::horizontalCenterOffsetChanged, widget, [&](int offsetIn){ + ASSERT_TRUE(offsetIn == offset); + signalTest++; + }); + + anchorBase && QObject::connect(anchorBase, &DAnchorsBase::verticalCenterOffsetChanged, widget, [&](int offsetIn){ + ASSERT_TRUE(offsetIn == offset); + signalTest++; + }); + result = anchor2.setAnchor(Qt::AnchorBottom, widget, Qt::AnchorBottom); + ASSERT_TRUE(result); + + emit anchorBase->horizontalCenterOffsetChanged(offset); + emit anchorBase->verticalCenterOffsetChanged(offset); + ASSERT_TRUE(signalTest == 2); + + anchor2.setHorizontalCenterOffset(offset); + anchor2.setVerticalCenterOffset(offset); + + // 测试设置的偏移量是否正确: + ASSERT_EQ(anchor2.horizontalCenterOffset(), offset); + ASSERT_EQ(anchor2.verticalCenterOffset(), offset); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dblureffectwidget.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dblureffectwidget.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dblureffectwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dblureffectwidget.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include +#include +#include + +#include "dblureffectwidget.h" +#include "private/dblureffectwidget_p.h" + +DWIDGET_USE_NAMESPACE + +class ut_DBlurEffectWidget : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DBlurEffectWidget *widget = nullptr; +}; + +void ut_DBlurEffectWidget::SetUp() +{ + widget = new DBlurEffectWidget; +} + +void ut_DBlurEffectWidget::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DBlurEffectWidget, testBlurEffectWidgetFrontEnd) +{ + // 测试信号槽的有效性 + QObject::connect(widget, &DBlurEffectWidget::modeChanged, widget, [this](DBlurEffectWidget::BlurMode mode){ + ASSERT_TRUE(widget->mode() == DBlurEffectWidget::BlurMode::GaussianBlur); + }); + + QObject::connect(widget, &DBlurEffectWidget::fullChanged, widget, [this](bool isFull){ + ASSERT_TRUE(widget->isFull() == isFull); + }); + widget->setFull(true); + + // 测试 set mode 以及 mode change 的有效性 + widget->setMode(DBlurEffectWidget::BlurMode::GaussianBlur); + ASSERT_TRUE(widget->mode() == DBlurEffectWidget::BlurMode::GaussianBlur); + + widget->setRadius(5); + ASSERT_TRUE(widget->radius() == 5); + + // 测试 setMaskPath + QPainter painter; + painter.setPen(Qt::yellow); //设置画笔颜色 + QPainterPath path; + path.moveTo(widget->width()/2, widget->height()/2); + path.arcTo(widget->width()/2 - 100, widget->height()/2 - 100, 200, 200, 30, 120); + painter.drawPath(path); + + widget->setMaskPath(path); + ASSERT_TRUE(widget->d_func()->maskPath == path); + + widget->setBlendMode(DBlurEffectWidget::InWindowBlend); + ASSERT_TRUE(widget->blendMode() == DBlurEffectWidget::InWindowBlend); + + widget->setMaskAlpha(155); + ASSERT_TRUE(widget->maskAlpha() == 155); +} + +TEST_F(ut_DBlurEffectWidget, testBlurEffectWidgetBackEnd) +{ + DBlurEffectWidget::MaskColorType type = DBlurEffectWidget::LightColor; + widget->setMaskColor(type); + ASSERT_TRUE(widget->d_func()->maskColorType == type); + + widget->setBlurEnabled(true); + ASSERT_TRUE(widget->blurEnabled() == true); + + QImage img(QIcon::fromTheme("icon_Window").pixmap(QSize(10,10)).toImage()); + widget->setSourceImage(img); + ASSERT_TRUE(widget->d_func()->sourceImage == img); + + int blurRectXRadius = 8; + widget->setBlurRectXRadius(blurRectXRadius); + ASSERT_EQ(widget->d_func()->blurRectXRadius, blurRectXRadius); + + int blurRectYRadius = 8; + widget->setBlurRectYRadius(blurRectYRadius); + ASSERT_EQ(widget->d_func()->blurRectYRadius, blurRectYRadius); + + const QFont font("Arial"); + widget->setFont(font); + qDebug() << widget->font().family(); + ASSERT_TRUE(widget->font().family() == font.family()); +} + diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dboxwidget.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dboxwidget.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dboxwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dboxwidget.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dboxwidget.h" + +DWIDGET_USE_NAMESPACE + +class ut_DBoxWidget : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + QWidget *widget = nullptr; +}; + +void ut_DBoxWidget::SetUp() +{ + widget = new QWidget; +} + +void ut_DBoxWidget::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DBoxWidget, createMimeDataFromSelection) +{ + + widget->resize(200, 200); + + QBoxLayout::Direction direction = QBoxLayout::LeftToRight; + DBoxWidget box(direction, widget); + + // 测试方向设置是否正确 + ASSERT_EQ(box.direction() == direction, true); + for (direction = QBoxLayout::LeftToRight; direction < QBoxLayout::Up;) { + box.setDirection(direction); + ASSERT_EQ(box.direction() == direction, true); + + int direct = direction; + direction = (QBoxLayout::Direction)(direct + 1); + } + + // 测试设置大小是否正确 + QSize size(200, 200); + box.setFixedSize(size); + + ASSERT_TRUE(box.size() == size); + + // 测试设置方向的信号是否正确 + QObject::connect(&box, &DBoxWidget::directionChanged, widget, [this, &box](QBoxLayout::Direction direction){ + ASSERT_TRUE(box.direction() == direction); + }); + + box.setDirection(QBoxLayout::LeftToRight); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dcrumbedit.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dcrumbedit.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dcrumbedit.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dcrumbedit.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,94 @@ +#include +#include +#include +#include + +#include "dcrumbedit.h" +#include + +DWIDGET_USE_NAMESPACE + +class ut_DCrumbedit : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + + DCrumbEdit *edit; +}; + +void ut_DCrumbedit::SetUp() +{ + edit = new DCrumbEdit; +} + +void ut_DCrumbedit::TearDown() +{ + delete edit; +} + +TEST_F(ut_DCrumbedit, createMimeDataFromSelection) +{ + edit->appendCrumb("人物"); + edit->appendCrumb("儿童"); + edit->appendCrumb("照片"); + + QTextCursor cursor = edit->textCursor(); + cursor.setPosition(0); + cursor.insertText("测试1"); + cursor.movePosition(QTextCursor::Right); + cursor.insertText("测试2"); + cursor.movePosition(QTextCursor::Right); + cursor.insertText("测试3"); + cursor.movePosition(QTextCursor::End); + cursor.insertText("测试代码调试添加GTest"); + + // 重置光标到最前面 + cursor.setPosition(0); + // 此时 测试1 人物 测试2 儿童 测试3 照片 测试代码调试添加GTest + edit->setTextCursor(cursor); + + ASSERT_EQ(edit->textCursor().position(), 0); + + // 模拟鼠标中选中操作 选中字符为: 测试1 + QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); + QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); + QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); + // 此时位置: 测试1 | 人物 测试2 儿童 测试3 照片 测试代码调试添加GTest + ASSERT_TRUE(edit->textCursor().hasSelection()); + ASSERT_FALSE(edit->textCursor().selectedText().isEmpty()); + edit->copy(); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "测试1"); + ASSERT_EQ(qApp->clipboard()->text(), "测试1"); + + // 模拟鼠标中选中操作 选中字符为: 测试1 人物 + QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); + // 此时位置 测试1 人物 | 测试2 儿童 测试3 照片 测试代码调试添加GTest + ASSERT_TRUE(edit->textCursor().hasSelection()); + ASSERT_FALSE(edit->textCursor().selectedText().isEmpty()); + edit->copy(); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "测试1 人物"); + ASSERT_EQ(qApp->clipboard()->text(), "测试1 人物"); + + edit->moveCursor(QTextCursor::Start); + edit->moveCursor(QTextCursor::Right); + edit->moveCursor(QTextCursor::Right); + edit->moveCursor(QTextCursor::Right); + + // 选中字符为: 人物 测试 + QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); + QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); + QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); + // 此时位置 测试1 人物 测试|2 儿童 测试3 照片 测试代码调试添加GTest + edit->copy(); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "人物 测试"); + ASSERT_EQ(qApp->clipboard()->text(), "人物 测试"); + + edit->moveCursor(QTextCursor::Start); + + // 选中所有字符 + QTest::keyClick(edit, Qt::Key_End, Qt::ShiftModifier); + edit->copy(); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "测试1 人物 测试2 儿童 测试3 照片 测试代码调试添加GTest"); + ASSERT_EQ(qApp->clipboard()->text(), "测试1 人物 测试2 儿童 测试3 照片 测试代码调试添加GTest"); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dfloatingmessage.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dfloatingmessage.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dfloatingmessage.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dfloatingmessage.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dfloatingmessage.h" +#include "dlabel.h" +#include "qlabel.h" +#include "qtimer.h" +#include "private/dfloatingmessage_p.h" + +DWIDGET_USE_NAMESPACE + +// for test setMessage +class MessageLabel : public QLabel +{ +public: + QSize sizeHint() const override + { + return fontMetrics().size(Qt::TextSingleLine, text()); + } +}; + +class ut_DFloatingMessage : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DFloatingMessage *message = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DFloatingMessage::SetUp() +{ + widget = new QWidget; + widget->resize(300, 200); + message = new DFloatingMessage(DFloatingMessage::TransientType, widget); +} + +void ut_DFloatingMessage::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DFloatingMessage, testDFloatingMessageFrontEnd) +{ + // 测试消息是否设置成功 + QString msg("Hello DTK~"); + message->setMessage(msg); + ASSERT_TRUE(message->d_func()->labMessage->text() == msg); + + // 测试 Icon 是否正确设置 + QIcon icon(QIcon::fromTheme("preferences-system")); + message->setIcon(icon); + QIcon tmp(message->d_func()->iconButton->icon()); + ASSERT_TRUE(message->d_func()->iconButton->icon().data_ptr() == tmp.data_ptr()); + + // 测试 widget 是否设置成功 + QWidget w; + message->setWidget(&w); + ASSERT_TRUE(message->d_func()->content == &w); +} + +TEST_F(ut_DFloatingMessage, testDFloatingMessageBackEnd) +{ + // 测试设置的持续时间 + int duration = 3 * 1000; + message->setDuration(duration); + ASSERT_TRUE(message->d_func()->timer->interval() == duration); + + // 测试边距设置 + QMargins contentsMargins(1, 2, 3, 4); + message->setContentsMargins(contentsMargins); + ASSERT_TRUE(message->contentsMargins() == contentsMargins); + + // 测试自动填充背景 + message->setAutoFillBackground(true); + ASSERT_TRUE(message->autoFillBackground()); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_diconbutton.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_diconbutton.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_diconbutton.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_diconbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "diconbutton.h" +#include "private/diconbutton_p.h" + +DWIDGET_USE_NAMESPACE + +class ut_IConButton : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DIconButton *button = nullptr; + QWidget *widget = nullptr; +}; + +void ut_IConButton::SetUp() +{ + widget = new QWidget; + button = new DIconButton(widget); + widget->resize(300, 200); +} + +void ut_IConButton::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_IConButton, testIConButton) +{ + QIcon icon(QIcon::fromTheme("preferences-system")); + button->setIcon(icon); + + button->setFlat(true); + ASSERT_TRUE(button->isFlat()); + + QString btStr("aaaaaaaa"); + button->setText(btStr); + ASSERT_TRUE(button->text() == btStr); + + button->setEnabledCircle(true); + ASSERT_TRUE(button->enabledCircle()); + + button->setNewNotification(true); + ASSERT_TRUE(button->property("_d_dtk_newNotification").toBool()); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dkeysequenceedit.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dkeysequenceedit.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dkeysequenceedit.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dkeysequenceedit.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include +#include +#include "dkeysequenceedit.h" + +DWIDGET_USE_NAMESPACE + +class ut_DKeySequenceEdit : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DKeySequenceEdit *sequence = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DKeySequenceEdit::SetUp() +{ + widget = new QWidget; + sequence = new DKeySequenceEdit(widget); + widget->resize(300, 200); +} + +void ut_DKeySequenceEdit::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DKeySequenceEdit, testDKeySequenceEdit) +{ + // 测试默认快捷键 + const QKeySequence seq(Qt::CTRL, Qt::SHIFT); + sequence->setKeySequence(seq); + ASSERT_TRUE(seq == sequence->keySequence()); + + // 测试清空功能 + sequence->clear(); + ASSERT_TRUE(sequence->keySequence() == QKeySequence()); + + // 测试 resize 功能 + QSize newSize(sequence->size() * 2); + sequence->resize(newSize); + ASSERT_TRUE(newSize == sequence->size()); + + sequence->setKeySequence(seq); + + // 测试对齐方式,只支持左对齐和右对齐 + sequence->ShortcutDirection(Qt::AlignRight); + ASSERT_TRUE(sequence->alignment().testFlag(Qt::AlignLeft)); + + sequence->ShortcutDirection(Qt::AlignLeft); + ASSERT_TRUE(sequence->alignment().testFlag(Qt::AlignRight)); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dmainwindow.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dmainwindow.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dmainwindow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dmainwindow.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include "dthememanager.h" +#include "dmainwindow.h" +#include "private/dmainwindow_p.h" + +DWIDGET_USE_NAMESPACE + +class ut_DMainWindow : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DMainWindow *window = nullptr; +}; + +void ut_DMainWindow::SetUp() +{ + window = new DMainWindow; + window->resize(300, 200); +} + +void ut_DMainWindow::TearDown() +{ + window->deleteLater(); +} + +TEST_F(ut_DMainWindow, testDMainWindowFrontEnd) +{ + + // 测试边框 + QRect rect1(0, 0, 300, 200); + QRegion r1(rect1); + window->setFrameMask(r1); + + // 测试 titlebar 阴影效果 + bool isTitlebarShadowEnabled = true; + window->setTitlebarShadowEnabled(isTitlebarShadowEnabled); + ASSERT_TRUE(window->d_func()->titleShadow != nullptr); + + if (qgetenv("QT_QPA_PLATFORM") == QByteArray("offscreen")) + return; + + window->setBorderColor(QColor(Qt::red)); + ASSERT_EQ(window->borderColor(), QColor(Qt::red)); + + // 测试裁剪路径 + QPainterPath clipPath; + clipPath.addRoundedRect(QRect(QPoint(0, 0), QSize(300, 200)), 0, 4); + window->setClipPath(clipPath); + ASSERT_TRUE(window->clipPath() == clipPath); + + // 测试窗口圆角 + window->setWindowRadius(150); + ASSERT_TRUE(window->windowRadius() == 150); + + // 测试窗口边框宽度 + window->setBorderWidth(20); + ASSERT_TRUE(window->borderWidth() == 20); + + // 测试窗口阴影偏移 + QPoint p(10, 10); + window->setShadowOffset(p); + ASSERT_TRUE(window->shadowOffset() == p); +} + +TEST_F(ut_DMainWindow, testDMainWindowBackEnd) +{ + if (qgetenv("QT_QPA_PLATFORM") == QByteArray("offscreen")) + return; + + // 测试模糊窗口 + bool isEnableBlurWindow = true; + window->setEnableBlurWindow(isEnableBlurWindow); + ASSERT_TRUE(window->enableBlurWindow()); + + // 测试鼠标移动功能 + bool isEnableSystemMove = true; + window->setEnableSystemMove(isEnableSystemMove); + ASSERT_TRUE(window->enableSystemMove()); + + // 测试窗口缩放 + bool isEnableSystemResize = true; + window->setEnableSystemResize(isEnableSystemResize); + ASSERT_TRUE(window->enableSystemResize()); + + // 测试半透明的背景 + bool isTranslucentBackground = true; + window->setTranslucentBackground(isTranslucentBackground); + ASSERT_TRUE(window->translucentBackground()); + + // 测试裁剪路径的输入 mask + bool isAutoInputMaskByClipPath = true; + window->setAutoInputMaskByClipPath(isAutoInputMaskByClipPath); + ASSERT_TRUE(window->autoInputMaskByClipPath()); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dprogressbar.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dprogressbar.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dprogressbar.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dprogressbar.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dprogressbar.h" + +DWIDGET_USE_NAMESPACE + +class ut_DProgressBar: public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DProgressBar *bar = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DProgressBar::SetUp() +{ + widget = new QWidget; + bar = new DProgressBar(widget); + widget->resize(300, 100); +} + +void ut_DProgressBar::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DProgressBar, testDProgressBar) +{ + // 测试数值的设置是否正确 + for (int i = 0; i < 101; ++i) { + bar->setValue(i); + ASSERT_TRUE(bar->value() == i); + } + + // 测试字体的设置是否正确 + QFont arial("Arial"); + bar->setFont(arial); + ASSERT_TRUE(bar->font().family() == arial.family()); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dsimplelistview.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dsimplelistview.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dsimplelistview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dsimplelistview.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dsimplelistview.h" +#include "dsimplelistitem.h" +#include "dlabel.h" + +DWIDGET_USE_NAMESPACE + +// std::atomic g_isSelectTest(false); +enum selectType { + selectAll, selectPrev, selectLast, selectFirst, selectSingle +}; + +class LIBDTKWIDGETSHARED_EXPORT TestListItem : public DSimpleListItem { +public: + bool isSelectTest = false; + selectType type = selectSingle; + int idx = 0; + + TestListItem() {} + virtual ~TestListItem() {} + + bool sameAs(DSimpleListItem *item) override { + return type == static_cast(item)->type; + } + + void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover) override { + QPen pen; + pen.setColor(QColor(Qt::green)); + pen.setWidth(50); + painter->setPen(pen); + painter->setBrush(QBrush(Qt::green)); + painter->drawRoundRect(rect); + if (isSelectTest) { + SelectedTest(isSelect); + } + } + + void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover) override { + QPen pen; + pen.setColor(QColor(Qt::red)); + pen.setWidth(5); + painter->setPen(pen); + painter->setBrush(QBrush(Qt::red)); + painter->drawRoundedRect(rect, 0, 0); + if (isSelectTest) { + SelectedTest(isSelect); + } + } + + void SelectedTest(bool isSelect) { + switch (type) { + case selectAll: { + ASSERT_TRUE(isSelect); + } + break; + case selectPrev: { + if (idx == 2) { + ASSERT_TRUE(isSelect); + } else { + ASSERT_FALSE(isSelect); + } + } + break; + case selectLast: { + if (idx == 3) { + ASSERT_TRUE(isSelect); + } else { + ASSERT_FALSE(isSelect); + } + } + break; + case selectFirst: { + if (idx == 0) { + ASSERT_TRUE(isSelect); + } else { + ASSERT_FALSE(isSelect); + } + } + break; + case selectSingle: { + static int count = 0; + if (isSelect) { + count++; + } + ASSERT_TRUE(count < 2); + } + break; + default: + ASSERT_TRUE(false); + } + } +}; + +class ut_DSimpleListView : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DSimpleListView *listView = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DSimpleListView::SetUp() +{ + widget = new QWidget; + listView = new DSimpleListView(widget); + QSize szie(300, 200); + widget->resize(szie); + listView->resize(szie); +} + +void ut_DSimpleListView::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DSimpleListView, testDSimpleListViewSelectFirst) +{ + if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { + return; + } + int idx = 0; + TestListItem item[4]; + QList itemList; + for (TestListItem &i : item) { + itemList << &i; + i.isSelectTest = true; + i.type = selectFirst; + i.idx = idx++; + } + + listView->addItems(itemList); + listView->selectFirstItem(); + widget->show(); +} + +TEST_F(ut_DSimpleListView, testDSimpleListViewSelectLast) +{ + if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { + return; + } + int idx = 0; + TestListItem item[4]; + QList itemList; + for (TestListItem &i : item) { + itemList << &i; + i.isSelectTest = true; + i.type = selectLast; + i.idx = idx++; + } + + listView->addItems(itemList); + listView->selectLastItem(); + widget->show(); +} + +TEST_F(ut_DSimpleListView, testDSimpleListViewSelectAll) +{ + if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { + return; + } + int idx = 0; + TestListItem item[4]; + QList itemList; + + for (TestListItem &i : item) { + itemList << &i; + i.isSelectTest = true; + i.type = selectAll; + i.idx = idx++; + } + + listView->addItems(itemList); + listView->selectAllItems(); + widget->show(); +} + +TEST_F(ut_DSimpleListView, testDSimpleListViewSelectPrev) +{ + if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { + return; + } + int idx = 0; + TestListItem item[4]; + QList itemList; + + for (TestListItem &i : item) { + itemList << &i; + i.isSelectTest = true; + i.type = selectPrev; + i.idx = idx++; + } + + listView->addItems(itemList); + listView->selectLastItem(); + listView->selectPrevItem(); + widget->show(); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dswitchbutton.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dswitchbutton.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dswitchbutton.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dswitchbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dswitchbutton.h" + +DWIDGET_USE_NAMESPACE + +class ut_DSwitchButton : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DSwitchButton *button = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DSwitchButton::SetUp() +{ + widget = new QWidget; + button = new DSwitchButton(widget); + widget->resize(300, 200); +} + +void ut_DSwitchButton::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DSwitchButton, testDSwitchButtonClicked) +{ + // 测试 sizeHint + ASSERT_TRUE(button->sizeHint().width() > 0); + ASSERT_TRUE(button->sizeHint().height() > 0); + + // 测试按钮按下 + int count = 0; + QObject::connect(button, &DSwitchButton::clicked, button, [&count](bool isClicked){ + if (count) + ASSERT_TRUE(isClicked == false); + else + ASSERT_TRUE(isClicked == true); + ++count; + }); + emit button->clicked(true); + emit button->clicked(false); + + QObject::disconnect(button, &DSwitchButton::clicked, button, nullptr); + + ASSERT_TRUE(count == 2); +} + +TEST_F(ut_DSwitchButton, testDSwitchButtonToggled) +{ + // 测试按钮翻转 + int count = 0; + QObject::connect(button, &DSwitchButton::toggled, button, [&count](bool isClicked){ + if (count) + ASSERT_TRUE(isClicked == false); + else + ASSERT_TRUE(isClicked == true); + ++count; + }); + + emit button->toggled(true); + emit button->toggled(false); + + QObject::disconnect(button, &DSwitchButton::toggled, button, nullptr); + + ASSERT_TRUE(count == 2); +} + +TEST_F(ut_DSwitchButton, testDSwitchButtonCheckedChanged) +{ + // 测试按钮翻转 + int count = 0; + QObject::connect(button, &DSwitchButton::checkedChanged, button, [&count](bool isChecked){ + if (count) + ASSERT_TRUE(isChecked == false); + else + ASSERT_TRUE(isChecked == true); + ++count; + }); + + emit button->setChecked(true); + emit button->setChecked(false); + + QObject::disconnect(button, &DSwitchButton::toggled, button, nullptr); + + ASSERT_TRUE(count == 2); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dtoolbutton.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dtoolbutton.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dtoolbutton.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dtoolbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dtoolbutton.h" + +DWIDGET_USE_NAMESPACE + +class ut_DToolButton : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DToolButton *button = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DToolButton::SetUp() +{ + widget = new QWidget; + button = new DToolButton(widget); + widget->resize(300, 200); +} + +void ut_DToolButton::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DToolButton, testDToolButton) +{ + QIcon icon(QIcon::fromTheme("preferences-system")); + button->setIcon(icon); + + QString btStr("aaaaaaaa"); + button->setText(btStr); + ASSERT_TRUE(button->text() == btStr); + + Qt::Alignment align[] = { + Qt::AlignLeft, + Qt::AlignRight, + Qt::AlignHCenter, + Qt::AlignJustify, + Qt::AlignAbsolute, + Qt::AlignTop, + Qt::AlignBottom, + Qt::AlignVCenter, + Qt::AlignBaseline, + Qt::AlignCenter, + }; + + for (Qt::Alignment al : align) { + button->setAlignment(al); + ASSERT_TRUE(button->alignment() == al); + } +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dwarningbutton.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dwarningbutton.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dwarningbutton.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dwarningbutton.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dwarningbutton.h" + +DWIDGET_USE_NAMESPACE + +class ut_DWarningButton : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DWarningButton *button = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DWarningButton::SetUp() +{ + widget = new QWidget; + button = new DWarningButton(widget); + widget->resize(300, 200); +} + +void ut_DWarningButton::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DWarningButton, testDWarningButton) +{ + // 测试 Icon 是否正确设置 + QIcon icon(QIcon::fromTheme("preferences-system")); + button->setIcon(icon); + QIcon tmp(button->icon()); + ASSERT_TRUE(button->icon().data_ptr() == tmp.data_ptr()); + + // 测试文本是否设置正确 + QString btStr("aaaaaaaa"); + button->setText(btStr); + ASSERT_TRUE(button->text() == btStr); + + // 测试 flat 是否设置成功 + button->setFlat(true); + ASSERT_TRUE(button->isFlat()); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/ut_dwaterprogress.cpp dtkwidget-5.5.17.1/tests/src/widgets/ut_dwaterprogress.cpp --- dtkwidget-5.4.36/tests/src/widgets/ut_dwaterprogress.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/ut_dwaterprogress.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. + * + * Author: Wang Peng + * + * Maintainer: Wang Peng + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser 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 Lesser General Public License + * along with this program. If not, see . + */ + +#include +#include +#include + +#include "dwaterprogress.h" + +DWIDGET_USE_NAMESPACE + +class ut_DWaterProgress : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + DWaterProgress *progress = nullptr; + QWidget *widget = nullptr; +}; + +void ut_DWaterProgress::SetUp() +{ + widget = new QWidget; + progress = new DWaterProgress(widget); + widget->resize(300, 200); +} + +void ut_DWaterProgress::TearDown() +{ + widget->deleteLater(); +} + +TEST_F(ut_DWaterProgress, testDwaterProress) +{ + QObject::connect(progress, &DWaterProgress::valueChanged, widget, [this](){ + ASSERT_TRUE(progress->value() > -1 && progress->value() < 101); + }); + + progress->start(); + for (int var = 0; var < 101; ++var) { + progress->setValue(var); + ASSERT_TRUE(progress->value() == var); + } + progress->stop(); +} diff -Nru dtkwidget-5.4.36/tests/src/widgets/widgets.pri dtkwidget-5.5.17.1/tests/src/widgets/widgets.pri --- dtkwidget-5.4.36/tests/src/widgets/widgets.pri 1970-01-01 00:00:00.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/src/widgets/widgets.pri 2021-06-30 10:52:09.000000000 +0000 @@ -0,0 +1,20 @@ +INCLUDEPATH += $$PWD/../../../src/ +INCLUDEPATH += $$PWD/../../../src/widgets/ +INCLUDEPATH += $$OUT_PWD/../src/ + +SOURCES += \ + $$PWD/ut_dalertcontrol.cpp \ + $$PWD/ut_dcrumbedit.cpp \ + $$PWD/ut_dboxwidget.cpp \ + $$PWD/ut_dblureffectwidget.cpp \ + $$PWD/ut_diconbutton.cpp \ + $$PWD/ut_dtoolbutton.cpp \ + $$PWD/ut_dprogressbar.cpp \ + $$PWD/ut_dwaterprogress.cpp \ + $$PWD/ut_danchor.cpp \ + $$PWD/ut_dmainwindow.cpp \ + $$PWD/ut_dfloatingmessage.cpp \ + $$PWD/ut_dswitchbutton.cpp \ + $$PWD/ut_dwarningbutton.cpp \ + $$PWD/ut_dsimplelistview.cpp \ + $$PWD/ut_dkeysequenceedit.cpp diff -Nru dtkwidget-5.4.36/tests/testcases/printpreview/ut_dprintpreviewdialog.cpp dtkwidget-5.5.17.1/tests/testcases/printpreview/ut_dprintpreviewdialog.cpp --- dtkwidget-5.4.36/tests/testcases/printpreview/ut_dprintpreviewdialog.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/printpreview/ut_dprintpreviewdialog.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -29,7 +29,8 @@ #include #include #include -#include +#include +#include "dprintpreviewwidget.h" #include "dprintpreviewdialog.h" #include "dprintpreviewdialog_p.h" @@ -216,79 +217,79 @@ { DFrame *printerFrame = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(printerFrame); - DPalette pa = DApplicationHelper::instance()->palette(printerFrame); + DPalette pa = DPaletteHelper::instance()->palette(printerFrame); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *copycountFrame = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(copycountFrame); - pa = DApplicationHelper::instance()->palette(copycountFrame); + pa = DPaletteHelper::instance()->palette(copycountFrame); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *pageFrame = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(pageFrame); - pa = DApplicationHelper::instance()->palette(pageFrame); + pa = DPaletteHelper::instance()->palette(pageFrame); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *colorframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(colorframe); - pa = DApplicationHelper::instance()->palette(colorframe); + pa = DPaletteHelper::instance()->palette(colorframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *marginsframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(marginsframe); - pa = DApplicationHelper::instance()->palette(marginsframe); + pa = DPaletteHelper::instance()->palette(marginsframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *paperframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(paperframe); - pa = DApplicationHelper::instance()->palette(paperframe); + pa = DPaletteHelper::instance()->palette(paperframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *duplexframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(duplexframe); - pa = DApplicationHelper::instance()->palette(duplexframe); + pa = DPaletteHelper::instance()->palette(duplexframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *sidebysideframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(sidebysideframe); - pa = DApplicationHelper::instance()->palette(sidebysideframe); + pa = DPaletteHelper::instance()->palette(sidebysideframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *watermarkframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(watermarkframe); - pa = DApplicationHelper::instance()->palette(watermarkframe); + pa = DPaletteHelper::instance()->palette(watermarkframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *posframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(posframe); - pa = DApplicationHelper::instance()->palette(posframe); + pa = DPaletteHelper::instance()->palette(posframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *inclinatframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(inclinatframe); - pa = DApplicationHelper::instance()->palette(inclinatframe); + pa = DPaletteHelper::instance()->palette(inclinatframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *sizeframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(sizeframe); - pa = DApplicationHelper::instance()->palette(sizeframe); + pa = DPaletteHelper::instance()->palette(sizeframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); DFrame *opaframe = new DFrame(test_dialog_d->basicsettingwdg); test_dialog_d->setfrmaeback(opaframe); - pa = DApplicationHelper::instance()->palette(opaframe); + pa = DPaletteHelper::instance()->palette(opaframe); ASSERT_EQ(pa.base().color(), pa.itemBackground().color()); } @@ -1641,9 +1642,9 @@ // TODO: duplexCheckBox } -TEST_F(ut_DPrintPreviewDialog, testDApplicationHelper_instance) +TEST_F(ut_DPrintPreviewDialog, themeTypeChanged) { - DApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::LightType); + DGuiApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::LightType); - DApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::DarkType); + DGuiApplicationHelper::instance()->themeTypeChanged(DGuiApplicationHelper::DarkType); } diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dalertcontrol.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dalertcontrol.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dalertcontrol.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dalertcontrol.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include "dalertcontrol.h" -#include "private/dalertcontrol_p.h" -#include "DLineEdit" -#include "DWidget" -#include - -DWIDGET_USE_NAMESPACE - -class ut_DAlertcontrol : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - - DWidget *widget = nullptr; - DLineEdit *lineEdit = nullptr; - DAlertControl *control = nullptr; -}; - -void ut_DAlertcontrol::SetUp() -{ - widget = new DWidget(nullptr); - lineEdit = new DLineEdit(widget); - control = new DAlertControl(lineEdit, widget); - - widget->resize(320, 280); - lineEdit->resize(180, 80); - lineEdit->move(40, 10); -} - -void ut_DAlertcontrol::TearDown() -{ - control->deleteLater(); - lineEdit->deleteLater(); - widget->deleteLater(); -} - -TEST_F(ut_DAlertcontrol, showALertMessage) -{ - // 测试 LineEdit 的文字内容是否设置成功 - QString testStr = QStringLiteral("xxxxxxxxxxxxxxxxxxxxxxxxxx"); - - lineEdit->setText(testStr); - ASSERT_EQ(lineEdit->text(), testStr); - - // 测试 showAlertMessage 是否生效 - control->showAlertMessage(testStr); - ASSERT_EQ(control->d_func()->tooltip->text(), testStr); - - control->hideAlertMessage(); - ASSERT_EQ(control->d_func()->frame->isVisible(), false); - - // 测试LineEdit里面设置的警告色是否正常,setAlert 是否生效 - control->setAlert(false); - ASSERT_EQ(control->isAlert(), false); - - control->setAlertColor(Qt::red); - control->setAlert(true); - ASSERT_EQ(control->isAlert(), true); - ASSERT_EQ(QColor(Qt::red) == control->alertColor(), true); - - // 默认左对齐,测试右对齐 - control->setMessageAlignment(Qt::AlignRight); - ASSERT_EQ(control->messageAlignment(), Qt::AlignRight); - - // 测试输入文本后通过信号槽获取内容 - QObject::connect(lineEdit, &DLineEdit::textChanged, widget, [&](const QString &text){ - control->showAlertMessage(lineEdit->text()); - ASSERT_EQ(text, testStr); - }); - - emit lineEdit->textChanged(testStr); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_danchor.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_danchor.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_danchor.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_danchor.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "danchors.h" -#include - -DWIDGET_USE_NAMESPACE - -class ut_DAnchors : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - QWidget *widget = nullptr; -}; - -void ut_DAnchors::SetUp() -{ - widget = new QWidget; - widget->resize(300, 200); -} - -void ut_DAnchors::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DAnchors, testDAnchors) -{ - // 锚定布局也是布局管理的一种 - QLabel *lb1 = new QLabel("anchor1", widget); - QLabel *lb2 = new QLabel("anchor2", widget); - - DAnchors anchor1(lb1); - DAnchors anchor2(lb2); - - int margin = 15; - anchor2.setLeftMargin(margin); - ASSERT_TRUE(anchor2.leftMargin() == margin); - anchor2.setTop(anchor1.bottom()); - anchor2.setLeft(anchor1.right()); - - anchor1.moveCenter(QPoint(widget->width() / 2, widget->height() / 2)); - ASSERT_TRUE(anchor1->pos().x() < anchor2->pos().x()); - ASSERT_TRUE(anchor1->pos().y() > anchor2->pos().y()); - - anchor1.moveHorizontalCenter(widget->width()/2); - anchor1.moveVerticalCenter(widget->height()/2); - ASSERT_TRUE(anchor1->pos().x() < anchor2->pos().x()); - ASSERT_TRUE(anchor1->pos().y() > anchor2->pos().y()); - - // 测试offset改变的信号槽的有效性 - bool result = anchor2.setAnchor(Qt::AnchorRight, widget, Qt::AnchorRight); - ASSERT_TRUE(result); - - int offset = 10; - int signalTest = 0; - DAnchorsBase *anchorBase = anchor2.getAnchorBaseByWidget(widget); - ASSERT_TRUE(anchorBase != nullptr); - - anchorBase && QObject::connect(anchorBase, &DAnchorsBase::horizontalCenterOffsetChanged, widget, [&](int offsetIn){ - ASSERT_TRUE(offsetIn == offset); - signalTest++; - }); - - anchorBase && QObject::connect(anchorBase, &DAnchorsBase::verticalCenterOffsetChanged, widget, [&](int offsetIn){ - ASSERT_TRUE(offsetIn == offset); - signalTest++; - }); - result = anchor2.setAnchor(Qt::AnchorBottom, widget, Qt::AnchorBottom); - ASSERT_TRUE(result); - - emit anchorBase->horizontalCenterOffsetChanged(offset); - emit anchorBase->verticalCenterOffsetChanged(offset); - ASSERT_TRUE(signalTest == 2); - - anchor2.setHorizontalCenterOffset(offset); - anchor2.setVerticalCenterOffset(offset); - - // 测试设置的偏移量是否正确: - ASSERT_EQ(anchor2.horizontalCenterOffset(), offset); - ASSERT_EQ(anchor2.verticalCenterOffset(), offset); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dblureffectwidget.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dblureffectwidget.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dblureffectwidget.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dblureffectwidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include -#include -#include - -#include "dblureffectwidget.h" -#include "private/dblureffectwidget_p.h" - -DWIDGET_USE_NAMESPACE - -class ut_DBlurEffectWidget : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DBlurEffectWidget *widget = nullptr; -}; - -void ut_DBlurEffectWidget::SetUp() -{ - widget = new DBlurEffectWidget; -} - -void ut_DBlurEffectWidget::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DBlurEffectWidget, testBlurEffectWidgetFrontEnd) -{ - // 测试信号槽的有效性 - QObject::connect(widget, &DBlurEffectWidget::modeChanged, widget, [this](DBlurEffectWidget::BlurMode mode){ - ASSERT_TRUE(widget->mode() == DBlurEffectWidget::BlurMode::GaussianBlur); - }); - - QObject::connect(widget, &DBlurEffectWidget::fullChanged, widget, [this](bool isFull){ - ASSERT_TRUE(widget->isFull() == isFull); - }); - widget->setFull(true); - - // 测试 set mode 以及 mode change 的有效性 - widget->setMode(DBlurEffectWidget::BlurMode::GaussianBlur); - ASSERT_TRUE(widget->mode() == DBlurEffectWidget::BlurMode::GaussianBlur); - - widget->setRadius(5); - ASSERT_TRUE(widget->radius() == 5); - - // 测试 setMaskPath - QPainter painter; - painter.setPen(Qt::yellow); //设置画笔颜色 - QPainterPath path; - path.moveTo(widget->width()/2, widget->height()/2); - path.arcTo(widget->width()/2 - 100, widget->height()/2 - 100, 200, 200, 30, 120); - painter.drawPath(path); - - widget->setMaskPath(path); - ASSERT_TRUE(widget->d_func()->maskPath == path); - - widget->setBlendMode(DBlurEffectWidget::InWindowBlend); - ASSERT_TRUE(widget->blendMode() == DBlurEffectWidget::InWindowBlend); - - widget->setMaskAlpha(155); - ASSERT_TRUE(widget->maskAlpha() == 155); -} - -TEST_F(ut_DBlurEffectWidget, testBlurEffectWidgetBackEnd) -{ - DBlurEffectWidget::MaskColorType type = DBlurEffectWidget::LightColor; - widget->setMaskColor(type); - ASSERT_TRUE(widget->d_func()->maskColorType == type); - - widget->setBlurEnabled(true); - ASSERT_TRUE(widget->blurEnabled() == true); - - QImage img(QIcon::fromTheme("icon_Window").pixmap(QSize(10,10)).toImage()); - widget->setSourceImage(img); - ASSERT_TRUE(widget->d_func()->sourceImage == img); - - int blurRectXRadius = 8; - widget->setBlurRectXRadius(blurRectXRadius); - ASSERT_EQ(widget->d_func()->blurRectXRadius, blurRectXRadius); - - int blurRectYRadius = 8; - widget->setBlurRectYRadius(blurRectYRadius); - ASSERT_EQ(widget->d_func()->blurRectYRadius, blurRectYRadius); - - const QFont font("Arial"); - widget->setFont(font); - qDebug() << widget->font().family(); - ASSERT_TRUE(widget->font().family() == font.family()); -} - diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dboxwidget.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dboxwidget.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dboxwidget.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dboxwidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dboxwidget.h" - -DWIDGET_USE_NAMESPACE - -class ut_DBoxWidget : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - QWidget *widget = nullptr; -}; - -void ut_DBoxWidget::SetUp() -{ - widget = new QWidget; -} - -void ut_DBoxWidget::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DBoxWidget, createMimeDataFromSelection) -{ - - widget->resize(200, 200); - - QBoxLayout::Direction direction = QBoxLayout::LeftToRight; - DBoxWidget box(direction, widget); - - // 测试方向设置是否正确 - ASSERT_EQ(box.direction() == direction, true); - for (direction = QBoxLayout::LeftToRight; direction < QBoxLayout::Up;) { - box.setDirection(direction); - ASSERT_EQ(box.direction() == direction, true); - - int direct = direction; - direction = (QBoxLayout::Direction)(direct + 1); - } - - // 测试设置大小是否正确 - QSize size(200, 200); - box.setFixedSize(size); - - ASSERT_TRUE(box.size() == size); - - // 测试设置方向的信号是否正确 - QObject::connect(&box, &DBoxWidget::directionChanged, widget, [this, &box](QBoxLayout::Direction direction){ - ASSERT_TRUE(box.direction() == direction); - }); - - box.setDirection(QBoxLayout::LeftToRight); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dcrumbedit.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dcrumbedit.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dcrumbedit.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dcrumbedit.cpp 2021-06-30 10:52:09.000000000 +0000 @@ -78,10 +78,8 @@ ASSERT_TRUE(edit->textCursor().hasSelection()); ASSERT_FALSE(edit->textCursor().selectedText().isEmpty()); edit->copy(); - QMimeData *data = edit->createMimeDataFromSelection(); - ASSERT_EQ(data->text(), "测试1"); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "测试1"); ASSERT_EQ(qApp->clipboard()->text(), "测试1"); - delete data; // 模拟鼠标中选中操作 选中字符为: 测试1 人物 QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); @@ -89,10 +87,8 @@ ASSERT_TRUE(edit->textCursor().hasSelection()); ASSERT_FALSE(edit->textCursor().selectedText().isEmpty()); edit->copy(); - data = edit->createMimeDataFromSelection(); - ASSERT_EQ(data->text(), "测试1 人物"); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "测试1 人物"); ASSERT_EQ(qApp->clipboard()->text(), "测试1 人物"); - delete data; edit->moveCursor(QTextCursor::Start); edit->moveCursor(QTextCursor::Right); @@ -105,18 +101,14 @@ QTest::keyClick(edit, Qt::Key_Right, Qt::ShiftModifier); // 此时位置 测试1 人物 测试|2 儿童 测试3 照片 测试代码调试添加GTest edit->copy(); - data = edit->createMimeDataFromSelection(); - ASSERT_EQ(data->text(), "人物 测试"); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "人物 测试"); ASSERT_EQ(qApp->clipboard()->text(), "人物 测试"); - delete data; edit->moveCursor(QTextCursor::Start); // 选中所有字符 QTest::keyClick(edit, Qt::Key_End, Qt::ShiftModifier); edit->copy(); - data = edit->createMimeDataFromSelection(); - ASSERT_EQ(data->text(), "测试1 人物 测试2 儿童 测试3 照片 测试代码调试添加GTest"); + ASSERT_EQ(edit->createMimeDataFromSelection()->text(), "测试1 人物 测试2 儿童 测试3 照片 测试代码调试添加GTest"); ASSERT_EQ(qApp->clipboard()->text(), "测试1 人物 测试2 儿童 测试3 照片 测试代码调试添加GTest"); - delete data; } diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dfloatingmessage.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dfloatingmessage.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dfloatingmessage.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dfloatingmessage.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dfloatingmessage.h" -#include "dlabel.h" -#include "qlabel.h" -#include "qtimer.h" -#include "private/dfloatingmessage_p.h" - -DWIDGET_USE_NAMESPACE - -// for test setMessage -class MessageLabel : public QLabel -{ -public: - QSize sizeHint() const override - { - return fontMetrics().size(Qt::TextSingleLine, text()); - } -}; - -class ut_DFloatingMessage : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DFloatingMessage *message = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DFloatingMessage::SetUp() -{ - widget = new QWidget; - widget->resize(300, 200); - message = new DFloatingMessage(DFloatingMessage::TransientType, widget); -} - -void ut_DFloatingMessage::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DFloatingMessage, testDFloatingMessageFrontEnd) -{ - // 测试消息是否设置成功 - QString msg("Hello DTK~"); - message->setMessage(msg); - ASSERT_TRUE(message->d_func()->labMessage->text() == msg); - - // 测试 Icon 是否正确设置 - QIcon icon(QIcon::fromTheme("preferences-system")); - message->setIcon(icon); - QIcon tmp(message->d_func()->iconButton->icon()); - ASSERT_TRUE(message->d_func()->iconButton->icon().data_ptr() == tmp.data_ptr()); - - // 测试 widget 是否设置成功 - QWidget w; - message->setWidget(&w); - ASSERT_TRUE(message->d_func()->content == &w); -} - -TEST_F(ut_DFloatingMessage, testDFloatingMessageBackEnd) -{ - // 测试设置的持续时间 - int duration = 3 * 1000; - message->setDuration(duration); - ASSERT_TRUE(message->d_func()->timer->interval() == duration); - - // 测试边距设置 - QMargins contentsMargins(1, 2, 3, 4); - message->setContentsMargins(contentsMargins); - ASSERT_TRUE(message->contentsMargins() == contentsMargins); - - // 测试自动填充背景 - message->setAutoFillBackground(true); - ASSERT_TRUE(message->autoFillBackground()); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_diconbutton.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_diconbutton.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_diconbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_diconbutton.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "diconbutton.h" -#include "private/diconbutton_p.h" - -DWIDGET_USE_NAMESPACE - -class ut_IConButton : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DIconButton *button = nullptr; - QWidget *widget = nullptr; -}; - -void ut_IConButton::SetUp() -{ - widget = new QWidget; - button = new DIconButton(widget); - widget->resize(300, 200); -} - -void ut_IConButton::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_IConButton, testIConButton) -{ - QIcon icon(QIcon::fromTheme("preferences-system")); - button->setIcon(icon); - - button->setFlat(true); - ASSERT_TRUE(button->isFlat()); - - - button->setEnabledCircle(true); - ASSERT_TRUE(button->enabledCircle()); - - button->setFlat(true); - ASSERT_TRUE(button->isFlat()); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dkeysequenceedit.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dkeysequenceedit.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dkeysequenceedit.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dkeysequenceedit.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include -#include -#include "dkeysequenceedit.h" - -DWIDGET_USE_NAMESPACE - -class ut_DKeySequenceEdit : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DKeySequenceEdit *sequence = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DKeySequenceEdit::SetUp() -{ - widget = new QWidget; - sequence = new DKeySequenceEdit(widget); - widget->resize(300, 200); -} - -void ut_DKeySequenceEdit::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DKeySequenceEdit, testDKeySequenceEdit) -{ - // 测试默认快捷键 - const QKeySequence seq(Qt::CTRL, Qt::SHIFT); - sequence->setKeySequence(seq); - ASSERT_TRUE(seq == sequence->keySequence()); - - // 测试清空功能 - sequence->clear(); - ASSERT_TRUE(sequence->keySequence() == QKeySequence()); - - // 测试 resize 功能 - QSize newSize(sequence->size() * 2); - sequence->resize(newSize); - ASSERT_TRUE(newSize == sequence->size()); - - sequence->setKeySequence(seq); - - // 测试对齐方式,只支持左对齐和右对齐 - sequence->ShortcutDirection(Qt::AlignRight); - ASSERT_TRUE(sequence->alignment().testFlag(Qt::AlignLeft)); - - sequence->ShortcutDirection(Qt::AlignLeft); - ASSERT_TRUE(sequence->alignment().testFlag(Qt::AlignRight)); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dmainwindow.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dmainwindow.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dmainwindow.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dmainwindow.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -#include "dthememanager.h" -#include "dmainwindow.h" -#include "private/dmainwindow_p.h" - -DWIDGET_USE_NAMESPACE - -class ut_DMainWindow : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DMainWindow *window = nullptr; -}; - -void ut_DMainWindow::SetUp() -{ - window = new DMainWindow; - window->resize(300, 200); -} - -void ut_DMainWindow::TearDown() -{ - window->deleteLater(); -} - -TEST_F(ut_DMainWindow, testDMainWindowFrontEnd) -{ - - // 测试边框 - QRect rect1(0, 0, 300, 200); - QRegion r1(rect1); - window->setFrameMask(r1); - - // 测试 titlebar 阴影效果 - bool isTitlebarShadowEnabled = true; - window->setTitlebarShadowEnabled(isTitlebarShadowEnabled); - ASSERT_TRUE(window->d_func()->titleShadow != nullptr); - - if (qgetenv("QT_QPA_PLATFORM") == QByteArray("offscreen")) - return; - - window->setBorderColor(QColor(Qt::red)); - ASSERT_EQ(window->borderColor(), QColor(Qt::red)); - - // 测试裁剪路径 - QPainterPath clipPath; - clipPath.addRoundedRect(QRect(QPoint(0, 0), QSize(300, 200)), 0, 4); - window->setClipPath(clipPath); - ASSERT_TRUE(window->clipPath() == clipPath); - - // 测试窗口圆角 - window->setWindowRadius(150); - ASSERT_TRUE(window->windowRadius() == 150); - - // 测试窗口边框宽度 - window->setBorderWidth(20); - ASSERT_TRUE(window->borderWidth() == 20); - - // 测试窗口阴影偏移 - QPoint p(10, 10); - window->setShadowOffset(p); - ASSERT_TRUE(window->shadowOffset() == p); -} - -TEST_F(ut_DMainWindow, testDMainWindowBackEnd) -{ - if (qgetenv("QT_QPA_PLATFORM") == QByteArray("offscreen")) - return; - - // 测试模糊窗口 - bool isEnableBlurWindow = true; - window->setEnableBlurWindow(isEnableBlurWindow); - ASSERT_TRUE(window->enableBlurWindow()); - - // 测试鼠标移动功能 - bool isEnableSystemMove = true; - window->setEnableSystemMove(isEnableSystemMove); - ASSERT_TRUE(window->enableSystemMove()); - - // 测试窗口缩放 - bool isEnableSystemResize = true; - window->setEnableSystemResize(isEnableSystemResize); - ASSERT_TRUE(window->enableSystemResize()); - - // 测试半透明的背景 - bool isTranslucentBackground = true; - window->setTranslucentBackground(isTranslucentBackground); - ASSERT_TRUE(window->translucentBackground()); - - // 测试裁剪路径的输入 mask - bool isAutoInputMaskByClipPath = true; - window->setAutoInputMaskByClipPath(isAutoInputMaskByClipPath); - ASSERT_TRUE(window->autoInputMaskByClipPath()); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dprogressbar.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dprogressbar.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dprogressbar.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dprogressbar.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dprogressbar.h" - -DWIDGET_USE_NAMESPACE - -class ut_DProgressBar: public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DProgressBar *bar = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DProgressBar::SetUp() -{ - widget = new QWidget; - bar = new DProgressBar(widget); - widget->resize(300, 100); -} - -void ut_DProgressBar::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DProgressBar, testDProgressBar) -{ - // 测试数值的设置是否正确 - for (int i = 0; i < 101; ++i) { - bar->setValue(i); - ASSERT_TRUE(bar->value() == i); - } - - // 测试字体的设置是否正确 - QFont arial("Arial"); - bar->setFont(arial); - ASSERT_TRUE(bar->font().family() == arial.family()); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dsimplelistview.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dsimplelistview.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dsimplelistview.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dsimplelistview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dsimplelistview.h" -#include "dsimplelistitem.h" -#include "dlabel.h" - -DWIDGET_USE_NAMESPACE - -// std::atomic g_isSelectTest(false); -enum selectType { - selectAll, selectPrev, selectLast, selectFirst, selectSingle -}; - -class LIBDTKWIDGETSHARED_EXPORT TestListItem : public DSimpleListItem { -public: - bool isSelectTest = false; - selectType type = selectSingle; - int idx = 0; - - TestListItem() {} - virtual ~TestListItem() {} - - bool sameAs(DSimpleListItem *item) override { - return type == static_cast(item)->type; - } - - void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover) override { - QPen pen; - pen.setColor(QColor(Qt::green)); - pen.setWidth(50); - painter->setPen(pen); - painter->setBrush(QBrush(Qt::green)); - painter->drawRoundRect(rect); - if (isSelectTest) { - SelectedTest(isSelect); - } - } - - void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover) override { - QPen pen; - pen.setColor(QColor(Qt::red)); - pen.setWidth(5); - painter->setPen(pen); - painter->setBrush(QBrush(Qt::red)); - painter->drawRoundedRect(rect, 0, 0); - if (isSelectTest) { - SelectedTest(isSelect); - } - } - - void SelectedTest(bool isSelect) { - switch (type) { - case selectAll: { - ASSERT_TRUE(isSelect); - } - break; - case selectPrev: { - if (idx == 2) { - ASSERT_TRUE(isSelect); - } else { - ASSERT_FALSE(isSelect); - } - } - break; - case selectLast: { - if (idx == 3) { - ASSERT_TRUE(isSelect); - } else { - ASSERT_FALSE(isSelect); - } - } - break; - case selectFirst: { - if (idx == 0) { - ASSERT_TRUE(isSelect); - } else { - ASSERT_FALSE(isSelect); - } - } - break; - case selectSingle: { - static int count = 0; - if (isSelect) { - count++; - } - ASSERT_TRUE(count < 2); - } - break; - default: - ASSERT_TRUE(false); - } - } -}; - -class ut_DSimpleListView : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DSimpleListView *listView = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DSimpleListView::SetUp() -{ - widget = new QWidget; - listView = new DSimpleListView(widget); - QSize szie(300, 200); - widget->resize(szie); - listView->resize(szie); -} - -void ut_DSimpleListView::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DSimpleListView, testDSimpleListViewSelectFirst) -{ - if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { - return; - } - int idx = 0; - TestListItem item[4]; - QList itemList; - for (TestListItem &i : item) { - itemList << &i; - i.isSelectTest = true; - i.type = selectFirst; - i.idx = idx++; - } - - listView->addItems(itemList); - listView->selectFirstItem(); - widget->show(); -} - -TEST_F(ut_DSimpleListView, testDSimpleListViewSelectLast) -{ - if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { - return; - } - int idx = 0; - TestListItem item[4]; - QList itemList; - for (TestListItem &i : item) { - itemList << &i; - i.isSelectTest = true; - i.type = selectLast; - i.idx = idx++; - } - - listView->addItems(itemList); - listView->selectLastItem(); - widget->show(); -} - -TEST_F(ut_DSimpleListView, testDSimpleListViewSelectAll) -{ - if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { - return; - } - int idx = 0; - TestListItem item[4]; - QList itemList; - - for (TestListItem &i : item) { - itemList << &i; - i.isSelectTest = true; - i.type = selectAll; - i.idx = idx++; - } - - listView->addItems(itemList); - listView->selectAllItems(); - widget->show(); -} - -TEST_F(ut_DSimpleListView, testDSimpleListViewSelectPrev) -{ - if (!qgetenv("QT_QPA_PLATFORM").isEmpty()) { - return; - } - int idx = 0; - TestListItem item[4]; - QList itemList; - - for (TestListItem &i : item) { - itemList << &i; - i.isSelectTest = true; - i.type = selectPrev; - i.idx = idx++; - } - - listView->addItems(itemList); - listView->selectLastItem(); - listView->selectPrevItem(); - widget->show(); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dswitchbutton.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dswitchbutton.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dswitchbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dswitchbutton.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dswitchbutton.h" - -DWIDGET_USE_NAMESPACE - -class ut_DSwitchButton : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DSwitchButton *button = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DSwitchButton::SetUp() -{ - widget = new QWidget; - button = new DSwitchButton(widget); - widget->resize(300, 200); -} - -void ut_DSwitchButton::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DSwitchButton, testDSwitchButtonClicked) -{ - // 测试 sizeHint - ASSERT_TRUE(button->sizeHint().width() > 0); - ASSERT_TRUE(button->sizeHint().height() > 0); - - // 测试按钮按下 - int count = 0; - QObject::connect(button, &DSwitchButton::clicked, button, [&count](bool isClicked){ - if (count) - ASSERT_TRUE(isClicked == false); - else - ASSERT_TRUE(isClicked == true); - ++count; - }); - emit button->clicked(true); - emit button->clicked(false); - - QObject::disconnect(button, &DSwitchButton::clicked, button, nullptr); - - ASSERT_TRUE(count == 2); -} - -TEST_F(ut_DSwitchButton, testDSwitchButtonToggled) -{ - // 测试按钮翻转 - int count = 0; - QObject::connect(button, &DSwitchButton::toggled, button, [&count](bool isClicked){ - if (count) - ASSERT_TRUE(isClicked == false); - else - ASSERT_TRUE(isClicked == true); - ++count; - }); - - emit button->toggled(true); - emit button->toggled(false); - - QObject::disconnect(button, &DSwitchButton::toggled, button, nullptr); - - ASSERT_TRUE(count == 2); -} - -TEST_F(ut_DSwitchButton, testDSwitchButtonCheckedChanged) -{ - // 测试按钮翻转 - int count = 0; - QObject::connect(button, &DSwitchButton::checkedChanged, button, [&count](bool isChecked){ - if (count) - ASSERT_TRUE(isChecked == false); - else - ASSERT_TRUE(isChecked == true); - ++count; - }); - - emit button->setChecked(true); - emit button->setChecked(false); - - QObject::disconnect(button, &DSwitchButton::toggled, button, nullptr); - - ASSERT_TRUE(count == 2); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dtoolbutton.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dtoolbutton.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dtoolbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dtoolbutton.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dtoolbutton.h" - -DWIDGET_USE_NAMESPACE - -class ut_DToolButton : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DToolButton *button = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DToolButton::SetUp() -{ - widget = new QWidget; - button = new DToolButton(widget); - widget->resize(300, 200); -} - -void ut_DToolButton::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DToolButton, testDToolButton) -{ - QIcon icon(QIcon::fromTheme("preferences-system")); - button->setIcon(icon); - - QString btStr("aaaaaaaa"); - button->setText(btStr); - ASSERT_TRUE(button->text() == btStr); - -#if DTK_VERSION > DTK_VERSION_CHECK(5, 5, 0, 0) - Qt::Alignment align[] = { - Qt::AlignLeft, - Qt::AlignRight, - Qt::AlignHCenter, - Qt::AlignJustify, - Qt::AlignAbsolute, - Qt::AlignTop, - Qt::AlignBottom, - Qt::AlignVCenter, - Qt::AlignBaseline, - Qt::AlignCenter, - }; - - for (Qt::Alignment al : align) { - button->setAlignment(al); - ASSERT_TRUE(button->alignment() == al); - } -#endif -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dwarningbutton.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dwarningbutton.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dwarningbutton.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dwarningbutton.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dwarningbutton.h" - -DWIDGET_USE_NAMESPACE - -class ut_DWarningButton : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DWarningButton *button = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DWarningButton::SetUp() -{ - widget = new QWidget; - button = new DWarningButton(widget); - widget->resize(300, 200); -} - -void ut_DWarningButton::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DWarningButton, testDWarningButton) -{ - // 测试 Icon 是否正确设置 - QIcon icon(QIcon::fromTheme("preferences-system")); - button->setIcon(icon); - QIcon tmp(button->icon()); - ASSERT_TRUE(button->icon().data_ptr() == tmp.data_ptr()); - - // 测试文本是否设置正确 - QString btStr("aaaaaaaa"); - button->setText(btStr); - ASSERT_TRUE(button->text() == btStr); - - // 测试 flat 是否设置成功 - button->setFlat(true); - ASSERT_TRUE(button->isFlat()); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/ut_dwaterprogress.cpp dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dwaterprogress.cpp --- dtkwidget-5.4.36/tests/testcases/widgets/ut_dwaterprogress.cpp 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/ut_dwaterprogress.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2021 ~ 2021 Deepin Technology Co., Ltd. - * - * Author: Wang Peng - * - * Maintainer: Wang Peng - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "dwaterprogress.h" - -DWIDGET_USE_NAMESPACE - -class ut_DWaterProgress : public testing::Test -{ -protected: - void SetUp() override; - void TearDown() override; - DWaterProgress *progress = nullptr; - QWidget *widget = nullptr; -}; - -void ut_DWaterProgress::SetUp() -{ - widget = new QWidget; - progress = new DWaterProgress(widget); - widget->resize(300, 200); -} - -void ut_DWaterProgress::TearDown() -{ - widget->deleteLater(); -} - -TEST_F(ut_DWaterProgress, testDwaterProress) -{ - QObject::connect(progress, &DWaterProgress::valueChanged, widget, [this](){ - ASSERT_TRUE(progress->value() > -1 && progress->value() < 101); - }); - - progress->start(); - for (int var = 0; var < 101; ++var) { - progress->setValue(var); - ASSERT_TRUE(progress->value() == var); - } - progress->stop(); -} diff -Nru dtkwidget-5.4.36/tests/testcases/widgets/widgets.pri dtkwidget-5.5.17.1/tests/testcases/widgets/widgets.pri --- dtkwidget-5.4.36/tests/testcases/widgets/widgets.pri 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/testcases/widgets/widgets.pri 2021-06-30 10:52:09.000000000 +0000 @@ -3,18 +3,5 @@ INCLUDEPATH += $$OUT_PWD/../src/ SOURCES += \ - $$PWD/ut_dalertcontrol.cpp \ - $$PWD/ut_dcrumbedit.cpp \ - $$PWD/ut_dboxwidget.cpp \ - # $$PWD/ut_dblureffectwidget.cpp \ - $$PWD/ut_diconbutton.cpp \ - $$PWD/ut_dtoolbutton.cpp \ - $$PWD/ut_dprogressbar.cpp \ - $$PWD/ut_dwaterprogress.cpp \ - $$PWD/ut_danchor.cpp \ - $$PWD/ut_dmainwindow.cpp \ - $$PWD/ut_dfloatingmessage.cpp \ - $$PWD/ut_dswitchbutton.cpp \ - $$PWD/ut_dwarningbutton.cpp \ - $$PWD/ut_dsimplelistview.cpp \ - $$PWD/ut_dkeysequenceedit.cpp + $$PWD/ut_dcrumbedit.cpp + diff -Nru dtkwidget-5.4.36/tests/test-recoverage.sh dtkwidget-5.5.17.1/tests/test-recoverage.sh --- dtkwidget-5.4.36/tests/test-recoverage.sh 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/test-recoverage.sh 2021-06-30 10:52:09.000000000 +0000 @@ -4,32 +4,17 @@ REPORT_DIR=report cd ../ -#rm -rf $BUILD_DIR -#mkdir $BUILD_DIR -#cd $BUILD_DIR -#qmake .. CONFIG+=debug -#make -j$(nproc) -#cd ../tests/ - -rm -rf $BUILD_DIR -mkdir $BUILD_DIR -cd $BUILD_DIR - -qmake .. CONFIG+=debug && make qmake_all -#make -j$(nproc) -cd ../tests/ - rm -rf $BUILD_DIR mkdir $BUILD_DIR cd $BUILD_DIR -qmake ../ CONFIG+=debug -export ASAN_OPTIONS=halt_on_error=0 -TESTARGS="--gtest_output=xml:dde_test_report_dtkwidget.xml" make check -j$(nproc) +qmake .. +make -j16 +cd tests/ +make check lcov -d ./ -c -o coverage_all.info lcov --extract coverage_all.info $EXTRACT_ARGS --output-file coverage.info lcov --remove coverage_all.info "*/tests/*" "*/usr/include*" "*build/src*" --output-file coverage.info genhtml -o ../../tests/$REPORT_DIR coverage.info -cd .. -test -e ./build/asan.log* && mv ./build/asan.log* ./build/asan_dtkwidget.log || touch ./build/asan.log +rm -rf ../../$BUILD_DIR diff -Nru dtkwidget-5.4.36/tests/tests.pro dtkwidget-5.5.17.1/tests/tests.pro --- dtkwidget-5.4.36/tests/tests.pro 2021-07-26 03:47:34.000000000 +0000 +++ dtkwidget-5.5.17.1/tests/tests.pro 2021-06-30 10:52:09.000000000 +0000 @@ -7,18 +7,11 @@ QT += widgets dtkcore dtkgui testlib unix:QMAKE_RPATHDIR += $$OUT_PWD/../src -unix:LIBS += -L$$OUT_PWD/../src -ldtkwidget -lgtest -lglib-2.0 +unix:LIBS += -L$$OUT_PWD/../src -ldtkwidget -lgtest QMAKE_CXXFLAGS += -fno-access-control QMAKE_LFLAGS += -fno-access-control -CONFIG(debug, debug|release) { -LIBS += -lgtest -lgmock -QMAKE_CXXFLAGS += -g -Wall -fprofile-arcs -ftest-coverage -fsanitize=address -fsanitize-recover=address -O2 -QMAKE_LFLAGS += -g -Wall -fprofile-arcs -ftest-coverage -fsanitize=address -fsanitize-recover=address -O2 -QMAKE_CXX += -g -fprofile-arcs -ftest-coverage -fsanitize=address -fsanitize-recover=address -O2 -} - # 指定moc文件生成目录和src一样 MOC_DIR=$$OUT_PWD/../src