From ab76dcd0879e684b34c3de243e44e3751b68356f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 8 Nov 2019 13:04:53 +0300 Subject: [PATCH 01/28] Initial cmake build scripts. --- CMakeLists.txt | 184 ++++++++++++++++++++++++++++++++++++ cmake/generate_styles.cmake | 94 ++++++++++++++++++ 2 files changed, 278 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/generate_styles.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..61793b7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,184 @@ +add_library(lib_ui OBJECT) +init_target(lib_ui) + +include(cmake/generate_styles.cmake) + +get_filename_component(src_loc . REALPATH) + +set(style_files + ui/basic.style + ui/layers/layers.style + ui/widgets/widgets.style +) + +generate_palette(lib_ui ui/colors.palette) +generate_styles(lib_ui ${src_loc} "${style_files}" ui/colors.palette) +generate_emoji(lib_ui emoji_suggestions/emoji_autocomplete.json) + +set(lib_ui_sources +PRIVATE + ${style_files} + ui/colors.palette + emoji_suggestions/emoji_autocomplete.json + + ui/effects/animation_value.cpp + ui/effects/animation_value.h + ui/effects/animations.cpp + ui/effects/animations.h + ui/effects/cross_animation.cpp + ui/effects/cross_animation.h + ui/effects/fade_animation.cpp + ui/effects/fade_animation.h + ui/effects/numbers_animation.cpp + ui/effects/numbers_animation.h + ui/effects/panel_animation.cpp + ui/effects/panel_animation.h + ui/effects/radial_animation.cpp + ui/effects/radial_animation.h + ui/effects/ripple_animation.cpp + ui/effects/ripple_animation.h + ui/effects/slide_animation.cpp + ui/effects/slide_animation.h + ui/image/image_prepare.cpp + ui/image/image_prepare.h + ui/layers/box_content.cpp + ui/layers/box_content.h + ui/layers/box_layer_widget.cpp + ui/layers/box_layer_widget.h + ui/layers/generic_box.cpp + ui/layers/generic_box.h + ui/layers/layer_manager.cpp + ui/layers/layer_manager.h + ui/layers/layer_widget.cpp + ui/layers/layer_widget.h + ui/platform/linux/ui_window_linux.cpp + ui/platform/linux/ui_window_linux.h + ui/platform/linux/ui_utility_linux.cpp + ui/platform/linux/ui_utility_linux.h + ui/platform/mac/ui_window_mac.h + ui/platform/mac/ui_window_mac.mm + ui/platform/mac/ui_window_title_mac.h + ui/platform/mac/ui_window_title_mac.mm + ui/platform/mac/ui_utility_mac.h + ui/platform/mac/ui_utility_mac.mm + ui/platform/win/ui_window_shadow_win.cpp + ui/platform/win/ui_window_shadow_win.h + ui/platform/win/ui_window_title_win.cpp + ui/platform/win/ui_window_title_win.h + ui/platform/win/ui_window_win.cpp + ui/platform/win/ui_window_win.h + ui/platform/win/ui_utility_win.cpp + ui/platform/win/ui_utility_win.h + ui/platform/ui_platform_window.h + ui/platform/ui_platform_utility.h + ui/style/style_core.cpp + ui/style/style_core.h + ui/style/style_core_color.cpp + ui/style/style_core_color.h + ui/style/style_core_direction.cpp + ui/style/style_core_direction.h + ui/style/style_core_font.cpp + ui/style/style_core_font.h + ui/style/style_core_icon.cpp + ui/style/style_core_icon.h + ui/style/style_core_scale.cpp + ui/style/style_core_scale.h + ui/style/style_core_types.cpp + ui/style/style_core_types.h + ui/text/text.cpp + ui/text/text.h + ui/text/text_block.cpp + ui/text/text_block.h + ui/text/text_entity.cpp + ui/text/text_entity.h + ui/text/text_isolated_emoji.h + ui/text/text_utilities.cpp + ui/text/text_utilities.h + ui/toast/toast.cpp + ui/toast/toast.h + ui/toast/toast_manager.cpp + ui/toast/toast_manager.h + ui/toast/toast_widget.cpp + ui/toast/toast_widget.h + ui/widgets/box_content_divider.cpp + ui/widgets/box_content_divider.h + ui/widgets/buttons.cpp + ui/widgets/buttons.h + ui/widgets/checkbox.cpp + ui/widgets/checkbox.h + ui/widgets/dropdown_menu.cpp + ui/widgets/dropdown_menu.h + ui/widgets/inner_dropdown.cpp + ui/widgets/inner_dropdown.h + ui/widgets/input_fields.cpp + ui/widgets/input_fields.h + ui/widgets/labels.cpp + ui/widgets/labels.h + ui/widgets/menu.cpp + ui/widgets/menu.h + ui/widgets/popup_menu.cpp + ui/widgets/popup_menu.h + ui/widgets/scroll_area.cpp + ui/widgets/scroll_area.h + ui/widgets/shadow.cpp + ui/widgets/shadow.h + ui/widgets/tooltip.cpp + ui/widgets/tooltip.h + ui/widgets/window.cpp + ui/widgets/window.h + ui/wrap/fade_wrap.cpp + ui/wrap/fade_wrap.h + ui/wrap/padding_wrap.cpp + ui/wrap/padding_wrap.h + ui/wrap/slide_wrap.cpp + ui/wrap/slide_wrap.h + ui/wrap/vertical_layout.cpp + ui/wrap/vertical_layout.h + ui/wrap/wrap.h + ui/abstract_button.cpp + ui/abstract_button.h + ui/basic_click_handlers.cpp + ui/basic_click_handlers.h + ui/click_handler.cpp + ui/click_handler.h + ui/delayed_activation.cpp + ui/delayed_activation.h + ui/emoji_config.cpp + ui/emoji_config.h + ui/focus_persister.h + ui/inactive_press.cpp + ui/inactive_press.h + ui/integration.cpp + ui/integration.h + ui/main_queue_processor.cpp + ui/main_queue_processor.h + ui/painter.h + ui/ph.cpp + ui/ph.h + ui/rect_part.h + ui/round_rect.cpp + ui/round_rect.h + ui/rp_widget.cpp + ui/rp_widget.h + ui/ui_log.cpp + ui/ui_log.h + ui/ui_utility.cpp + ui/ui_utility.h + emoji_suggestions/emoji_suggestions.cpp + emoji_suggestions/emoji_suggestions.h + emoji_suggestions/emoji_suggestions_helper.h +) + +force_include(lib_ui ui/ui_pch.h) +nice_target_sources(lib_ui ${src_loc} "${lib_ui_sources}") + +target_include_directories(lib_ui +PUBLIC + ${src_loc} + ${src_loc}/emoji_suggestions +) + +target_link_libraries(lib_ui +PUBLIC + lib_base +) diff --git a/cmake/generate_styles.cmake b/cmake/generate_styles.cmake new file mode 100644 index 0000000..b759319 --- /dev/null +++ b/cmake/generate_styles.cmake @@ -0,0 +1,94 @@ +function(append_generate_target target_name postfix generated_files gen_dst) + add_custom_target(${target_name}_${postfix} DEPENDS ${generated_files}) + init_target(${target_name}_${postfix} "(gen)") + add_dependencies(${target_name} ${target_name}_${postfix}) + target_sources(${target_name} PRIVATE ${generated_files}) + target_include_directories(${target_name} PUBLIC ${gen_dst}) + source_group("(gen)" FILES ${generated_files}) +endfunction() + +function(generate_palette target_name palette_file) + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${palette_file}) + set(generated_files + ${gen_dst}/styles/palette.cpp + ${gen_dst}/styles/palette.h + ) + add_custom_command( + OUTPUT + ${generated_files} + COMMAND + codegen_style + -I${gen_dst} + -o${gen_dst}/styles + -w${CMAKE_CURRENT_SOURCE_DIR} + ${gen_src} + COMMENT "Generating palette (${target_name})" + DEPENDS + codegen_style + ${gen_src} + MAIN_DEPENDENCY + ${gen_src} + ) + append_generate_target(${target_name} palette "${generated_files}" ${gen_dst}) +endfunction() + +function(generate_styles target_name src_loc style_files dependent_style_files) + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + set(full_generated_files "") + set(full_dependencies_list ${style_files}) + list(APPEND full_dependencies_list ${dependent_style_files}) + foreach (file ${style_files}) + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + get_filename_component(file_name ${file} NAME_WLE) + set(generated_files + ${gen_dst}/styles/style_${file_name}.cpp + ${gen_dst}/styles/style_${file_name}.h + ) + list(APPEND full_generated_files ${generated_files}) + add_custom_command( + OUTPUT + ${generated_files} + COMMAND + codegen_style + -I${src_loc} + -I${submodules_loc}/lib_ui + -I${submodules_loc}/Resources + -o${gen_dst}/styles + -w${CMAKE_CURRENT_SOURCE_DIR} + ${gen_src} + COMMENT "Generating style (${target_name}:${file_name})" + DEPENDS + codegen_style + ${full_dependencies_list} + MAIN_DEPENDENCY + ${gen_src} + ) + endforeach() + + append_generate_target(${target_name} styles "${full_generated_files}" ${gen_dst}) +endfunction() + +function(generate_emoji target_name suggestions_json) + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${suggestions_json}) + set(generated_files + ${gen_dst}/emoji.cpp + ${gen_dst}/emoji.h + ${gen_dst}/emoji_suggestions_data.cpp + ${gen_dst}/emoji_suggestions_data.h + ) + add_custom_command( + OUTPUT + ${generated_files} + COMMAND + codegen_emoji + -o${gen_dst} + ${gen_src} + COMMENT "Generating emoji (${target_name})" + DEPENDS + codegen_emoji + ${gen_src} + ) + append_generate_target(${target_name} emoji "${generated_files}" ${gen_dst}) +endfunction() From d32f772e5274e8490ade20e88c6bfa10b8ecfee5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 8 Nov 2019 14:08:03 +0300 Subject: [PATCH 02/28] Divide codegen cmake scripts. --- CMakeLists.txt | 2 ++ cmake/generate_emoji.cmake | 23 ++++++++++++ cmake/generate_palette.cmake | 25 +++++++++++++ cmake/generate_styles.cmake | 70 ++++-------------------------------- 4 files changed, 57 insertions(+), 63 deletions(-) create mode 100644 cmake/generate_emoji.cmake create mode 100644 cmake/generate_palette.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 61793b7..5fb7fb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,9 @@ add_library(lib_ui OBJECT) init_target(lib_ui) +include(cmake/generate_palette.cmake) include(cmake/generate_styles.cmake) +include(cmake/generate_emoji.cmake) get_filename_component(src_loc . REALPATH) diff --git a/cmake/generate_emoji.cmake b/cmake/generate_emoji.cmake new file mode 100644 index 0000000..77456d6 --- /dev/null +++ b/cmake/generate_emoji.cmake @@ -0,0 +1,23 @@ +function(generate_emoji target_name suggestions_json) + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${suggestions_json}) + set(generated_files + ${gen_dst}/emoji.cpp + ${gen_dst}/emoji.h + ${gen_dst}/emoji_suggestions_data.cpp + ${gen_dst}/emoji_suggestions_data.h + ) + add_custom_command( + OUTPUT + ${generated_files} + COMMAND + codegen_emoji + -o${gen_dst} + ${gen_src} + COMMENT "Generating emoji (${target_name})" + DEPENDS + codegen_emoji + ${gen_src} + ) + generate_target(${target_name} emoji "${generated_files}" ${gen_dst}) +endfunction() diff --git a/cmake/generate_palette.cmake b/cmake/generate_palette.cmake new file mode 100644 index 0000000..f0e349a --- /dev/null +++ b/cmake/generate_palette.cmake @@ -0,0 +1,25 @@ +function(generate_palette target_name palette_file) + set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${palette_file}) + set(generated_files + ${gen_dst}/styles/palette.cpp + ${gen_dst}/styles/palette.h + ) + add_custom_command( + OUTPUT + ${generated_files} + COMMAND + codegen_style + -I${gen_dst} + -o${gen_dst}/styles + -w${CMAKE_CURRENT_SOURCE_DIR} + ${gen_src} + COMMENT "Generating palette (${target_name})" + DEPENDS + codegen_style + ${gen_src} + MAIN_DEPENDENCY + ${gen_src} + ) + generate_target(${target_name} palette "${generated_files}" ${gen_dst}) +endfunction() diff --git a/cmake/generate_styles.cmake b/cmake/generate_styles.cmake index b759319..2bb4259 100644 --- a/cmake/generate_styles.cmake +++ b/cmake/generate_styles.cmake @@ -1,45 +1,13 @@ -function(append_generate_target target_name postfix generated_files gen_dst) - add_custom_target(${target_name}_${postfix} DEPENDS ${generated_files}) - init_target(${target_name}_${postfix} "(gen)") - add_dependencies(${target_name} ${target_name}_${postfix}) - target_sources(${target_name} PRIVATE ${generated_files}) - target_include_directories(${target_name} PUBLIC ${gen_dst}) - source_group("(gen)" FILES ${generated_files}) -endfunction() - -function(generate_palette target_name palette_file) - set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) - set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${palette_file}) - set(generated_files - ${gen_dst}/styles/palette.cpp - ${gen_dst}/styles/palette.h - ) - add_custom_command( - OUTPUT - ${generated_files} - COMMAND - codegen_style - -I${gen_dst} - -o${gen_dst}/styles - -w${CMAKE_CURRENT_SOURCE_DIR} - ${gen_src} - COMMENT "Generating palette (${target_name})" - DEPENDS - codegen_style - ${gen_src} - MAIN_DEPENDENCY - ${gen_src} - ) - append_generate_target(${target_name} palette "${generated_files}" ${gen_dst}) -endfunction() - function(generate_styles target_name src_loc style_files dependent_style_files) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) set(full_generated_files "") - set(full_dependencies_list ${style_files}) - list(APPEND full_dependencies_list ${dependent_style_files}) + set(full_dependencies_list ${dependent_style_files}) foreach (file ${style_files}) - set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${file}) + list(APPEND full_dependencies_list ${src_loc}/${file}) + endforeach() + + foreach (file ${style_files}) + set(gen_src ${src_loc}/${file}) get_filename_component(file_name ${file} NAME_WLE) set(generated_files ${gen_dst}/styles/style_${file_name}.cpp @@ -66,29 +34,5 @@ function(generate_styles target_name src_loc style_files dependent_style_files) ) endforeach() - append_generate_target(${target_name} styles "${full_generated_files}" ${gen_dst}) -endfunction() - -function(generate_emoji target_name suggestions_json) - set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) - set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${suggestions_json}) - set(generated_files - ${gen_dst}/emoji.cpp - ${gen_dst}/emoji.h - ${gen_dst}/emoji_suggestions_data.cpp - ${gen_dst}/emoji_suggestions_data.h - ) - add_custom_command( - OUTPUT - ${generated_files} - COMMAND - codegen_emoji - -o${gen_dst} - ${gen_src} - COMMENT "Generating emoji (${target_name})" - DEPENDS - codegen_emoji - ${gen_src} - ) - append_generate_target(${target_name} emoji "${generated_files}" ${gen_dst}) + generate_target(${target_name} styles "${full_generated_files}" ${gen_dst}) endfunction() From 110a17089a2b18e93edf77a0adf596df92e9def0 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 11 Nov 2019 10:54:07 +0300 Subject: [PATCH 03/28] Enable MOC and RCC compilers. --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fb7fb3..0a320e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,13 +12,23 @@ set(style_files ui/layers/layers.style ui/widgets/widgets.style ) +set(qrc_files + fonts/fonts.qrc + qt_conf/linux.qrc + qt_conf/mac.qrc + qt_conf/win.qrc +) generate_palette(lib_ui ui/colors.palette) generate_styles(lib_ui ${src_loc} "${style_files}" ui/colors.palette) generate_emoji(lib_ui emoji_suggestions/emoji_autocomplete.json) +set_target_properties(lib_ui PROPERTIES AUTOMOC ON) +set_target_properties(lib_ui PROPERTIES AUTORCC ON) + set(lib_ui_sources PRIVATE + ${qrc_files} ${style_files} ui/colors.palette emoji_suggestions/emoji_autocomplete.json @@ -170,9 +180,9 @@ PRIVATE emoji_suggestions/emoji_suggestions.h emoji_suggestions/emoji_suggestions_helper.h ) +nice_target_sources(lib_ui ${src_loc} "${lib_ui_sources}") force_include(lib_ui ui/ui_pch.h) -nice_target_sources(lib_ui ${src_loc} "${lib_ui_sources}") target_include_directories(lib_ui PUBLIC From 5851950296a2586ecc581c125e4478cf2831522a Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 Nov 2019 15:20:45 +0300 Subject: [PATCH 04/28] Allow emoji in discrete slider labels. --- ui/widgets/widgets.style | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/widgets/widgets.style b/ui/widgets/widgets.style index a463c50..04eabf0 100644 --- a/ui/widgets/widgets.style +++ b/ui/widgets/widgets.style @@ -794,7 +794,7 @@ SettingsSlider { barFg: color; barFgActive: color; labelTop: pixels; - labelFont: font; + labelStyle: TextStyle; labelFg: color; labelFgActive: color; duration: int; @@ -812,7 +812,7 @@ defaultSettingsSlider: SettingsSlider { barFg: sliderBgInactive; barFgActive: sliderBgActive; labelTop: 17px; - labelFont: normalFont; + labelStyle: defaultTextStyle; labelFg: windowActiveTextFg; labelFgActive: windowActiveTextFg; duration: 150; @@ -824,7 +824,7 @@ defaultTabsSlider: SettingsSlider(defaultSettingsSlider) { barSkip: 0px; barFg: transparent; labelTop: 19px; - labelFont: semiboldFont; + labelStyle: semiboldTextStyle; labelFg: windowSubTextFg; labelFgActive: lightButtonFg; rippleBottomSkip: 1px; From d0f25088636702a460c6dd040b929c2b0d9d2ab3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 Nov 2019 15:21:06 +0300 Subject: [PATCH 05/28] Move box setNoContentMargin() to public interface. --- ui/layers/box_content.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ui/layers/box_content.h b/ui/layers/box_content.h index 6d49519..28426d5 100644 --- a/ui/layers/box_content.h +++ b/ui/layers/box_content.h @@ -184,6 +184,14 @@ public: return _delegate; } + void setNoContentMargin(bool noContentMargin) { + if (_noContentMargin != noContentMargin) { + _noContentMargin = noContentMargin; + setAttribute(Qt::WA_OpaquePaintEvent, !_noContentMargin); + } + getDelegate()->setNoContentMargin(noContentMargin); + } + public slots: void onScrollToY(int top, int bottom = -1); @@ -196,13 +204,6 @@ protected: getDelegate()->setLayerType(layerType); } - void setNoContentMargin(bool noContentMargin) { - if (_noContentMargin != noContentMargin) { - _noContentMargin = noContentMargin; - setAttribute(Qt::WA_OpaquePaintEvent, !_noContentMargin); - } - getDelegate()->setNoContentMargin(noContentMargin); - } void setDimensions( int newWidth, int maxHeight, From b7af3b71a3f7ee93cb2ea70cdeb16a8a3ff06bce Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 18 Nov 2019 00:27:26 +0300 Subject: [PATCH 06/28] Use precompiled header from cmake 3.16. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a320e0..53fc247 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,7 @@ PRIVATE ) nice_target_sources(lib_ui ${src_loc} "${lib_ui_sources}") -force_include(lib_ui ui/ui_pch.h) +target_precompile_headers(lib_ui PRIVATE ${src_loc}/ui/ui_pch.h) target_include_directories(lib_ui PUBLIC From 8e3034213761ba98a916b16ad230560e5695c856 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 21 Nov 2019 16:55:41 +0300 Subject: [PATCH 07/28] Use namespaced library aliases. --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53fc247..4ed7b32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,11 @@ +# This file is part of Desktop App Toolkit, +# a set of libraries for developing nice desktop applications. +# +# For license and copyright information please follow this link: +# https://github.com/desktop-app/legal/blob/master/LEGAL + add_library(lib_ui OBJECT) +add_library(desktop-app::lib_ui ALIAS lib_ui) init_target(lib_ui) include(cmake/generate_palette.cmake) @@ -192,5 +199,5 @@ PUBLIC target_link_libraries(lib_ui PUBLIC - lib_base + desktop-app::lib_base ) From 6fda2709ea0f594fc869422dee77eef2fd9dc86c Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 25 Nov 2019 18:40:24 +0300 Subject: [PATCH 08/28] Initial build with Xcode. --- CMakeLists.txt | 3 +-- cmake/generate_emoji.cmake | 2 ++ cmake/generate_palette.cmake | 2 ++ cmake/generate_styles.cmake | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ed7b32..0a941e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,8 +30,7 @@ generate_palette(lib_ui ui/colors.palette) generate_styles(lib_ui ${src_loc} "${style_files}" ui/colors.palette) generate_emoji(lib_ui emoji_suggestions/emoji_autocomplete.json) -set_target_properties(lib_ui PROPERTIES AUTOMOC ON) -set_target_properties(lib_ui PROPERTIES AUTORCC ON) +set_target_properties(lib_ui PROPERTIES AUTOMOC ON AUTORCC ON) set(lib_ui_sources PRIVATE diff --git a/cmake/generate_emoji.cmake b/cmake/generate_emoji.cmake index 77456d6..50268df 100644 --- a/cmake/generate_emoji.cmake +++ b/cmake/generate_emoji.cmake @@ -1,5 +1,7 @@ function(generate_emoji target_name suggestions_json) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + file(MAKE_DIRECTORY ${gen_dst}) + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${suggestions_json}) set(generated_files ${gen_dst}/emoji.cpp diff --git a/cmake/generate_palette.cmake b/cmake/generate_palette.cmake index f0e349a..d9e8fdb 100644 --- a/cmake/generate_palette.cmake +++ b/cmake/generate_palette.cmake @@ -1,5 +1,7 @@ function(generate_palette target_name palette_file) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + file(MAKE_DIRECTORY ${gen_dst}) + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${palette_file}) set(generated_files ${gen_dst}/styles/palette.cpp diff --git a/cmake/generate_styles.cmake b/cmake/generate_styles.cmake index 2bb4259..c4767c5 100644 --- a/cmake/generate_styles.cmake +++ b/cmake/generate_styles.cmake @@ -1,5 +1,7 @@ function(generate_styles target_name src_loc style_files dependent_style_files) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) + file(MAKE_DIRECTORY ${gen_dst}) + set(full_generated_files "") set(full_dependencies_list ${dependent_style_files}) foreach (file ${style_files}) From 4b25cd30d14e94220f8fe213e85554a84fefbc1e Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 28 Nov 2019 11:41:48 +0300 Subject: [PATCH 09/28] Use BYPRODUCTS instead of OUTPUT for codegen. --- cmake/generate_emoji.cmake | 8 +++++++- cmake/generate_palette.cmake | 6 +++++- cmake/generate_styles.cmake | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cmake/generate_emoji.cmake b/cmake/generate_emoji.cmake index 50268df..0c35ec0 100644 --- a/cmake/generate_emoji.cmake +++ b/cmake/generate_emoji.cmake @@ -8,10 +8,16 @@ function(generate_emoji target_name suggestions_json) ${gen_dst}/emoji.h ${gen_dst}/emoji_suggestions_data.cpp ${gen_dst}/emoji_suggestions_data.h + ${gen_dst}/emoji.timestamp ) add_custom_command( OUTPUT - ${generated_files} + ${gen_dst}/emoji.timestamp + BYPRODUCTS + ${gen_dst}/emoji.cpp + ${gen_dst}/emoji.h + ${gen_dst}/emoji_suggestions_data.cpp + ${gen_dst}/emoji_suggestions_data.h COMMAND codegen_emoji -o${gen_dst} diff --git a/cmake/generate_palette.cmake b/cmake/generate_palette.cmake index d9e8fdb..e22dc48 100644 --- a/cmake/generate_palette.cmake +++ b/cmake/generate_palette.cmake @@ -6,10 +6,14 @@ function(generate_palette target_name palette_file) set(generated_files ${gen_dst}/styles/palette.cpp ${gen_dst}/styles/palette.h + ${gen_dst}/styles/palette.timestamp ) add_custom_command( OUTPUT - ${generated_files} + ${gen_dst}/styles/palette.timestamp + BYPRODUCTS + ${gen_dst}/styles/palette.cpp + ${gen_dst}/styles/palette.h COMMAND codegen_style -I${gen_dst} diff --git a/cmake/generate_styles.cmake b/cmake/generate_styles.cmake index c4767c5..5574655 100644 --- a/cmake/generate_styles.cmake +++ b/cmake/generate_styles.cmake @@ -14,11 +14,15 @@ function(generate_styles target_name src_loc style_files dependent_style_files) set(generated_files ${gen_dst}/styles/style_${file_name}.cpp ${gen_dst}/styles/style_${file_name}.h + ${gen_dst}/styles/style_${file_name}.timestamp ) list(APPEND full_generated_files ${generated_files}) add_custom_command( OUTPUT - ${generated_files} + ${gen_dst}/styles/style_${file_name}.timestamp + BYPRODUCTS + ${gen_dst}/styles/style_${file_name}.cpp + ${gen_dst}/styles/style_${file_name}.h COMMAND codegen_style -I${src_loc} From 1c19e874bbeddded6b729bd37aa6da1c872eb206 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 29 Nov 2019 11:29:57 +0300 Subject: [PATCH 10/28] Generate all styles in one custom action. --- cmake/generate_palette.cmake | 1 + cmake/generate_styles.cmake | 54 +++++++++++++++++------------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/cmake/generate_palette.cmake b/cmake/generate_palette.cmake index e22dc48..82e93d0 100644 --- a/cmake/generate_palette.cmake +++ b/cmake/generate_palette.cmake @@ -18,6 +18,7 @@ function(generate_palette target_name palette_file) codegen_style -I${gen_dst} -o${gen_dst}/styles + -t${gen_dst}/styles/palette -w${CMAKE_CURRENT_SOURCE_DIR} ${gen_src} COMMENT "Generating palette (${target_name})" diff --git a/cmake/generate_styles.cmake b/cmake/generate_styles.cmake index 5574655..4a17c9d 100644 --- a/cmake/generate_styles.cmake +++ b/cmake/generate_styles.cmake @@ -3,42 +3,38 @@ function(generate_styles target_name src_loc style_files dependent_style_files) file(MAKE_DIRECTORY ${gen_dst}) set(full_generated_files "") + set(full_generation_sources "") set(full_dependencies_list ${dependent_style_files}) foreach (file ${style_files}) - list(APPEND full_dependencies_list ${src_loc}/${file}) - endforeach() - - foreach (file ${style_files}) - set(gen_src ${src_loc}/${file}) + list(APPEND full_generation_sources ${src_loc}/${file}) get_filename_component(file_name ${file} NAME_WLE) - set(generated_files + list(APPEND full_generated_files ${gen_dst}/styles/style_${file_name}.cpp ${gen_dst}/styles/style_${file_name}.h - ${gen_dst}/styles/style_${file_name}.timestamp - ) - list(APPEND full_generated_files ${generated_files}) - add_custom_command( - OUTPUT - ${gen_dst}/styles/style_${file_name}.timestamp - BYPRODUCTS - ${gen_dst}/styles/style_${file_name}.cpp - ${gen_dst}/styles/style_${file_name}.h - COMMAND - codegen_style - -I${src_loc} - -I${submodules_loc}/lib_ui - -I${submodules_loc}/Resources - -o${gen_dst}/styles - -w${CMAKE_CURRENT_SOURCE_DIR} - ${gen_src} - COMMENT "Generating style (${target_name}:${file_name})" - DEPENDS - codegen_style - ${full_dependencies_list} - MAIN_DEPENDENCY - ${gen_src} ) endforeach() + list(APPEND full_dependencies_list ${full_generation_sources}) + add_custom_command( + OUTPUT + ${gen_dst}/styles/${target_name}_style.timestamp + BYPRODUCTS + ${full_generated_files} + COMMAND + codegen_style + -I${src_loc} + -I${submodules_loc}/lib_ui + -I${submodules_loc}/Resources + -o${gen_dst}/styles + -t${gen_dst}/styles/${target_name}_style + -w${CMAKE_CURRENT_SOURCE_DIR} + ${full_generation_sources} + COMMENT "Generating styles (${target_name})" + DEPENDS + codegen_style + ${full_dependencies_list} + ) + + list(APPEND full_generated_files ${gen_dst}/styles/${target_name}_style.timestamp) generate_target(${target_name} styles "${full_generated_files}" ${gen_dst}) endfunction() From fcb44b320c008b21f9e168149a3ac72f68530b4c Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 3 Dec 2019 18:26:12 +0300 Subject: [PATCH 11/28] Add generated files to dependent targets. --- CMakeLists.txt | 6 ++---- cmake/generate_emoji.cmake | 16 +++++++--------- cmake/generate_palette.cmake | 18 +++++++++--------- cmake/generate_styles.cmake | 12 ++++++------ 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a941e0..687b25f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,8 @@ generate_emoji(lib_ui emoji_suggestions/emoji_autocomplete.json) set_target_properties(lib_ui PROPERTIES AUTOMOC ON AUTORCC ON) -set(lib_ui_sources +target_precompile_headers(lib_ui PRIVATE ${src_loc}/ui/ui_pch.h) +nice_target_sources(lib_ui ${src_loc} PRIVATE ${qrc_files} ${style_files} @@ -186,9 +187,6 @@ PRIVATE emoji_suggestions/emoji_suggestions.h emoji_suggestions/emoji_suggestions_helper.h ) -nice_target_sources(lib_ui ${src_loc} "${lib_ui_sources}") - -target_precompile_headers(lib_ui PRIVATE ${src_loc}/ui/ui_pch.h) target_include_directories(lib_ui PUBLIC diff --git a/cmake/generate_emoji.cmake b/cmake/generate_emoji.cmake index 0c35ec0..a85dac8 100644 --- a/cmake/generate_emoji.cmake +++ b/cmake/generate_emoji.cmake @@ -2,22 +2,20 @@ function(generate_emoji target_name suggestions_json) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) file(MAKE_DIRECTORY ${gen_dst}) - set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${suggestions_json}) - set(generated_files + set(gen_timestamp ${gen_dst}/emoji.timestamp) + set(gen_files ${gen_dst}/emoji.cpp ${gen_dst}/emoji.h ${gen_dst}/emoji_suggestions_data.cpp ${gen_dst}/emoji_suggestions_data.h - ${gen_dst}/emoji.timestamp ) + + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${suggestions_json}) add_custom_command( OUTPUT - ${gen_dst}/emoji.timestamp + ${gen_timestamp} BYPRODUCTS - ${gen_dst}/emoji.cpp - ${gen_dst}/emoji.h - ${gen_dst}/emoji_suggestions_data.cpp - ${gen_dst}/emoji_suggestions_data.h + ${gen_files} COMMAND codegen_emoji -o${gen_dst} @@ -27,5 +25,5 @@ function(generate_emoji target_name suggestions_json) codegen_emoji ${gen_src} ) - generate_target(${target_name} emoji "${generated_files}" ${gen_dst}) + generate_target(${target_name} emoji ${gen_timestamp} "${gen_files}" ${gen_dst}) endfunction() diff --git a/cmake/generate_palette.cmake b/cmake/generate_palette.cmake index 82e93d0..e3f7043 100644 --- a/cmake/generate_palette.cmake +++ b/cmake/generate_palette.cmake @@ -2,18 +2,18 @@ function(generate_palette target_name palette_file) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) file(MAKE_DIRECTORY ${gen_dst}) - set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${palette_file}) - set(generated_files - ${gen_dst}/styles/palette.cpp - ${gen_dst}/styles/palette.h - ${gen_dst}/styles/palette.timestamp + set(gen_timestamp ${gen_dst}/styles/palette.timestamp) + set(gen_files + ${gen_dst}/styles/palette.cpp + ${gen_dst}/styles/palette.h ) + + set(gen_src ${CMAKE_CURRENT_SOURCE_DIR}/${palette_file}) add_custom_command( OUTPUT - ${gen_dst}/styles/palette.timestamp + ${gen_timestamp} BYPRODUCTS - ${gen_dst}/styles/palette.cpp - ${gen_dst}/styles/palette.h + ${gen_files} COMMAND codegen_style -I${gen_dst} @@ -28,5 +28,5 @@ function(generate_palette target_name palette_file) MAIN_DEPENDENCY ${gen_src} ) - generate_target(${target_name} palette "${generated_files}" ${gen_dst}) + generate_target(${target_name} palette ${gen_timestamp} "${gen_files}" ${gen_dst}) endfunction() diff --git a/cmake/generate_styles.cmake b/cmake/generate_styles.cmake index 4a17c9d..84617ea 100644 --- a/cmake/generate_styles.cmake +++ b/cmake/generate_styles.cmake @@ -2,13 +2,14 @@ function(generate_styles target_name src_loc style_files dependent_style_files) set(gen_dst ${CMAKE_CURRENT_BINARY_DIR}/gen) file(MAKE_DIRECTORY ${gen_dst}) - set(full_generated_files "") + set(gen_timestamp ${gen_dst}/styles/${target_name}_style.timestamp) + set(gen_files "") set(full_generation_sources "") set(full_dependencies_list ${dependent_style_files}) foreach (file ${style_files}) list(APPEND full_generation_sources ${src_loc}/${file}) get_filename_component(file_name ${file} NAME_WLE) - list(APPEND full_generated_files + list(APPEND gen_files ${gen_dst}/styles/style_${file_name}.cpp ${gen_dst}/styles/style_${file_name}.h ) @@ -17,9 +18,9 @@ function(generate_styles target_name src_loc style_files dependent_style_files) add_custom_command( OUTPUT - ${gen_dst}/styles/${target_name}_style.timestamp + ${gen_timestamp} BYPRODUCTS - ${full_generated_files} + ${gen_files} COMMAND codegen_style -I${src_loc} @@ -35,6 +36,5 @@ function(generate_styles target_name src_loc style_files dependent_style_files) ${full_dependencies_list} ) - list(APPEND full_generated_files ${gen_dst}/styles/${target_name}_style.timestamp) - generate_target(${target_name} styles "${full_generated_files}" ${gen_dst}) + generate_target(${target_name} styles ${gen_timestamp} "${gen_files}" ${gen_dst}) endfunction() From 604f62599e9ee5f4d57d778ebbe9403c2a875245 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 10 Dec 2019 10:36:25 +0300 Subject: [PATCH 12/28] Fix parsing entities from Ui::Text::String. --- ui/effects/radial_animation.h | 4 ++-- ui/text/text.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/effects/radial_animation.h b/ui/effects/radial_animation.h index 2581372..54a34de 100644 --- a/ui/effects/radial_animation.h +++ b/ui/effects/radial_animation.h @@ -72,7 +72,7 @@ public: Callback &&callback, const style::InfiniteRadialAnimation &st); - bool animating() const { + [[nodiscard]] bool animating() const { return _animation.animating(); } @@ -89,7 +89,7 @@ public: QSize size, int outerWidth); - RadialState computeState(); + [[nodiscard]] RadialState computeState(); private: const style::InfiniteRadialAnimation &_st; diff --git a/ui/text/text.cpp b/ui/text/text.cpp index 724000b..e984353 100644 --- a/ui/text/text.cpp +++ b/ui/text/text.cpp @@ -3214,6 +3214,17 @@ TextForMimeData String::toText( if (composeExpanded) { result.expanded.reserve(_text.size()); } + const auto insertEntity = [&](EntityInText &&entity) { + auto i = result.rich.entities.end(); + while (i != result.rich.entities.begin()) { + auto j = i; + if ((--j)->offset() <= entity.offset()) { + break; + } + i = j; + } + result.rich.entities.insert(i, std::move(entity)); + }; auto linkStart = 0; auto markdownTrackers = composeEntities ? std::vector{ @@ -3231,7 +3242,7 @@ TextForMimeData String::toText( for (auto &tracker : markdownTrackers) { const auto flag = tracker.flag; if ((oldFlags & flag) && !(newFlags & flag)) { - result.rich.entities.push_back({ + insertEntity({ tracker.type, tracker.start, result.rich.text.size() - tracker.start }); @@ -3264,7 +3275,7 @@ TextForMimeData String::toText( } } if (composeEntities) { - result.rich.entities.push_back({ + insertEntity({ entity.type, linkStart, full.size(), From 21b976569ae2051955c7346295c7029a75bf1bbc Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 10 Dec 2019 15:12:48 +0300 Subject: [PATCH 13/28] Draw radial animation in a static method. --- ui/effects/radial_animation.cpp | 32 +++++++++++++++++++++++++++----- ui/effects/radial_animation.h | 15 ++++++++++++--- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/ui/effects/radial_animation.cpp b/ui/effects/radial_animation.cpp index 3a3ff77..83bb308 100644 --- a/ui/effects/radial_animation.cpp +++ b/ui/effects/radial_animation.cpp @@ -144,7 +144,14 @@ void InfiniteRadialAnimation::draw( QPainter &p, QPoint position, int outerWidth) { - draw(p, position, _st.size, outerWidth); + Draw( + p, + computeState(), + position, + _st.size, + outerWidth, + _st.color, + _st.thickness); } void InfiniteRadialAnimation::draw( @@ -152,8 +159,24 @@ void InfiniteRadialAnimation::draw( QPoint position, QSize size, int outerWidth) { - const auto state = computeState(); + Draw( + p, + computeState(), + position, + size, + outerWidth, + _st.color, + _st.thickness); +} +void InfiniteRadialAnimation::Draw( + QPainter &p, + const RadialState &state, + QPoint position, + QSize size, + int outerWidth, + QPen pen, + int thickness) { auto o = p.opacity(); p.setOpacity(o * state.shown); @@ -166,10 +189,9 @@ void InfiniteRadialAnimation::draw( const auto was = p.pen(); const auto brush = p.brush(); if (anim::Disabled()) { - anim::DrawStaticLoading(p, rect, _st.thickness, _st.color); + anim::DrawStaticLoading(p, rect, thickness, pen); } else { - auto pen = _st.color->p; - pen.setWidth(_st.thickness); + pen.setWidth(thickness); pen.setCapStyle(Qt::RoundCap); p.setPen(pen); diff --git a/ui/effects/radial_animation.h b/ui/effects/radial_animation.h index 54a34de..984e49a 100644 --- a/ui/effects/radial_animation.h +++ b/ui/effects/radial_animation.h @@ -27,10 +27,10 @@ public: template RadialAnimation(Callback &&callback); - float64 opacity() const { + [[nodiscard]] float64 opacity() const { return _opacity; } - bool animating() const { + [[nodiscard]] bool animating() const { return _animation.animating(); } @@ -44,7 +44,7 @@ public: int32 thickness, style::color color) const; - RadialState computeState() const; + [[nodiscard]] RadialState computeState() const; private: crl::time _firstStart = 0; @@ -89,6 +89,15 @@ public: QSize size, int outerWidth); + static void Draw( + QPainter &p, + const RadialState &state, + QPoint position, + QSize size, + int outerWidth, + QPen pen, + int thickness); + [[nodiscard]] RadialState computeState(); private: From 65eb03a6a78ffe09cd8f644edfe14560854b89eb Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 14 Dec 2019 17:08:29 +0300 Subject: [PATCH 14/28] Don't change image pixel ratio when rounding. --- ui/image/image_prepare.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/image/image_prepare.cpp b/ui/image/image_prepare.cpp index 5a86d26..b2c2270 100644 --- a/ui/image/image_prepare.cpp +++ b/ui/image/image_prepare.cpp @@ -516,7 +516,6 @@ void prepareRound( } Assert(!image.isNull()); - image.setDevicePixelRatio(style::DevicePixelRatio()); image = std::move(image).convertToFormat( QImage::Format_ARGB32_Premultiplied); Assert(!image.isNull()); From 6b673d9154cd596b9c648b130f334c166af36875 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 27 Dec 2019 13:40:36 +0300 Subject: [PATCH 15/28] Skip internal: links in String::toText with entities. --- ui/text/text.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/text/text.cpp b/ui/text/text.cpp index e984353..e395f5e 100644 --- a/ui/text/text.cpp +++ b/ui/text/text.cpp @@ -3267,14 +3267,16 @@ TextForMimeData String::toText( if (!composeExpanded && !composeEntities) { return; } + const auto skipLink = (entity.type == EntityType::CustomUrl) + && (entity.data.startsWith(qstr("internal:"))); if (composeExpanded) { result.expanded.append(full); - if (entity.type == EntityType::CustomUrl) { + if (entity.type == EntityType::CustomUrl && !skipLink) { const auto &url = entity.data; result.expanded.append(qstr(" (")).append(url).append(')'); } } - if (composeEntities) { + if (composeEntities && !skipLink) { insertEntity({ entity.type, linkStart, From 29cb1dccc44a6d5715230ded14ab87294491b164 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 27 Dec 2019 15:43:04 +0300 Subject: [PATCH 16/28] Skip internal: links in link tooltips. --- ui/basic_click_handlers.cpp | 7 ++++++- ui/basic_click_handlers.h | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/basic_click_handlers.cpp b/ui/basic_click_handlers.cpp index 6599f8c..534ea57 100644 --- a/ui/basic_click_handlers.cpp +++ b/ui/basic_click_handlers.cpp @@ -16,12 +16,17 @@ #include #include +QString TextClickHandler::readable() const { + const auto result = url(); + return result.startsWith(qstr("internal:")) ? QString() : result; +} + UrlClickHandler::UrlClickHandler(const QString &url, bool fullDisplayed) : TextClickHandler(fullDisplayed) , _originalUrl(url) { if (isEmail()) { _readable = _originalUrl; - } else { + } else if (!_originalUrl.startsWith(qstr("internal:"))) { const auto original = QUrl(_originalUrl); const auto good = QUrl(original.isValid() ? original.toEncoded() diff --git a/ui/basic_click_handlers.h b/ui/basic_click_handlers.h index 4335cce..ffcab83 100644 --- a/ui/basic_click_handlers.h +++ b/ui/basic_click_handlers.h @@ -29,9 +29,7 @@ public: protected: virtual QString url() const = 0; - virtual QString readable() const { - return url(); - } + virtual QString readable() const; bool _fullDisplayed; From e6914d46493e7b394d52ed90f31ac6dec3711842 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 30 Dec 2019 16:40:14 +0300 Subject: [PATCH 17/28] Don't activate wrong window after popup menu. --- ui/widgets/popup_menu.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/widgets/popup_menu.cpp b/ui/widgets/popup_menu.cpp index 17ecfb4..5032008 100644 --- a/ui/widgets/popup_menu.cpp +++ b/ui/widgets/popup_menu.cpp @@ -519,7 +519,8 @@ PopupMenu::~PopupMenu() { delete submenu; } if (const auto parent = parentWidget()) { - if (QApplication::focusWidget() != nullptr) { + if (QApplication::focusWidget() != nullptr + && Ui::InFocusChain(parent)) { ActivateWindowDelayed(parent); } } From 983d6be8d4114e94b7e47a65674c11d877b68cec Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 30 Dec 2019 16:58:53 +0300 Subject: [PATCH 18/28] Added rpl::event_stream for firing applied markdown tag to spellchecker. --- ui/widgets/input_fields.cpp | 4 ++++ ui/widgets/input_fields.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ui/widgets/input_fields.cpp b/ui/widgets/input_fields.cpp index fb6b171..db17e0c 100644 --- a/ui/widgets/input_fields.cpp +++ b/ui/widgets/input_fields.cpp @@ -3152,6 +3152,10 @@ bool InputField::commitMarkdownReplacement( cursor.setCharFormat(_defaultCharFormat); _inner->setTextCursor(cursor); + + // Fire the tag to the spellchecker. + _markdownTagApplies.fire({ from, till, -1, -1, false, tag }); + return true; } diff --git a/ui/widgets/input_fields.h b/ui/widgets/input_fields.h index 4fd9dbc..2873ea7 100644 --- a/ui/widgets/input_fields.h +++ b/ui/widgets/input_fields.h @@ -330,6 +330,9 @@ public: auto documentContentsChanges() { return _documentContentsChanges.events(); } + auto markdownTagApplies() { + return _markdownTagApplies.events(); + } ~InputField(); @@ -535,6 +538,7 @@ private: bool _instantReplacesEnabled = true; rpl::event_stream _documentContentsChanges; + rpl::event_stream _markdownTagApplies; }; From da3b4704bfde6572e29966254f3f91866207c693 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Dec 2019 10:29:48 +0300 Subject: [PATCH 19/28] Fix activating window after popup menu. --- ui/widgets/popup_menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/widgets/popup_menu.cpp b/ui/widgets/popup_menu.cpp index 5032008..64ef28b 100644 --- a/ui/widgets/popup_menu.cpp +++ b/ui/widgets/popup_menu.cpp @@ -520,7 +520,7 @@ PopupMenu::~PopupMenu() { } if (const auto parent = parentWidget()) { if (QApplication::focusWidget() != nullptr - && Ui::InFocusChain(parent)) { + && Ui::InFocusChain(parent->window())) { ActivateWindowDelayed(parent); } } From f0e95ee933d1caf74b790fc85d34212dd3dd2229 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Dec 2019 13:48:16 +0300 Subject: [PATCH 20/28] Fix possible assertion violation in animations shutdown. --- ui/effects/animations.cpp | 7 +++++++ ui/effects/animations.h | 1 + 2 files changed, 8 insertions(+) diff --git a/ui/effects/animations.cpp b/ui/effects/animations.cpp index 874f07e..426a085 100644 --- a/ui/effects/animations.cpp +++ b/ui/effects/animations.cpp @@ -113,6 +113,7 @@ void Manager::stop(not_null animation) { const auto i = ranges::find(_active, value, proj); if (i != end(_active)) { *i = nullptr; + _removedWhileUpdating = true; } } else if (empty(_active)) { stopTimer(); @@ -138,6 +139,12 @@ void Manager::update() { }; _active.erase(ranges::remove_if(_active, isFinished), end(_active)); + if (_removedWhileUpdating) { + _removedWhileUpdating = false; + const auto proj = &ActiveBasicPointer::get; + _active.erase(ranges::remove(_active, nullptr, proj), end(_active)); + } + if (!empty(_starting)) { _active.insert( end(_active), diff --git a/ui/effects/animations.h b/ui/effects/animations.h index 41665c3..c7eabf6 100644 --- a/ui/effects/animations.h +++ b/ui/effects/animations.h @@ -198,6 +198,7 @@ private: crl::time _lastUpdateTime = 0; int _timerId = 0; bool _updating = false; + bool _removedWhileUpdating = false; bool _scheduled = false; bool _forceImmediateUpdate = false; std::vector _active; From 765e525458843ffb893586441b885ac5ba143e51 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 31 Dec 2019 16:48:25 +0300 Subject: [PATCH 21/28] Add Ui::AppInFocus() method. --- ui/layers/layer_widget.cpp | 12 +++++++----- ui/rp_widget.h | 4 ---- ui/ui_utility.cpp | 6 +++++- ui/ui_utility.h | 2 ++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ui/layers/layer_widget.cpp b/ui/layers/layer_widget.cpp index 6a05357..91df272 100644 --- a/ui/layers/layer_widget.cpp +++ b/ui/layers/layer_widget.cpp @@ -462,10 +462,10 @@ void LayerStackWidget::setCacheImages() { void LayerStackWidget::closeLayer(not_null layer) { const auto weak = Ui::MakeWeak(layer.get()); - if (weak->inFocusChain()) { + if (Ui::InFocusChain(layer)) { setFocus(); } - if (!weak || !weak->setClosing()) { + if (!layer->setClosing()) { // This layer is already closing. return; } else if (!weak) { @@ -734,9 +734,11 @@ void LayerStackWidget::appendBox( LayerWidget *LayerStackWidget::pushBox( object_ptr box, anim::type animated) { - auto oldLayer = currentLayer(); + const auto oldLayer = currentLayer(); if (oldLayer) { - if (oldLayer->inFocusChain()) setFocus(); + if (Ui::InFocusChain(oldLayer)) { + setFocus(); + } oldLayer->hide(); } _layers.push_back( @@ -793,7 +795,7 @@ void LayerStackWidget::clearClosingLayers() { while (!_closingLayers.empty()) { const auto index = _closingLayers.size() - 1; const auto layer = _closingLayers.back().get(); - if (layer->inFocusChain()) { + if (Ui::InFocusChain(layer)) { setFocus(); } diff --git a/ui/rp_widget.h b/ui/rp_widget.h index bfadb9f..8cffbe5 100644 --- a/ui/rp_widget.h +++ b/ui/rp_widget.h @@ -28,10 +28,6 @@ public: return QMargins(); } - bool inFocusChain() const { - return Ui::InFocusChain(this); - } - void hideChildren() { for (auto child : Base::children()) { if (child->isWidgetType()) { diff --git a/ui/ui_utility.cpp b/ui/ui_utility.cpp index e7e5e59..2b3d6e2 100644 --- a/ui/ui_utility.cpp +++ b/ui/ui_utility.cpp @@ -8,8 +8,8 @@ #include "ui/style/style_core.h" +#include #include -#include #include #include @@ -82,6 +82,10 @@ void SendPendingEventsRecursive(QWidget *target, bool parentHiddenFlag) { } // namespace +bool AppInFocus() { + return QApplication::focusWidget() != nullptr; +} + void SendPendingMoveResizeEvents(not_null target) { CreateWidgetStateRecursive(target); SendPendingEventsRecursive(target, !target->isVisible()); diff --git a/ui/ui_utility.h b/ui/ui_utility.h index 3b2f77a..4a1ce5e 100644 --- a/ui/ui_utility.h +++ b/ui/ui_utility.h @@ -98,6 +98,8 @@ inline not_null*> AttachAsChild( std::forward(value))->value(); } +[[nodiscard]] bool AppInFocus(); + [[nodiscard]] inline bool InFocusChain(not_null widget) { if (const auto top = widget->window()) { if (auto focused = top->focusWidget()) { From d30d361609d4b76d3a55b1329642caee30b82264 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 2 Jan 2020 14:25:11 +0300 Subject: [PATCH 22/28] Fix whitespace and indentation errors. --- ui/text/text.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ui/text/text.cpp b/ui/text/text.cpp index e395f5e..1a41f8c 100644 --- a/ui/text/text.cpp +++ b/ui/text/text.cpp @@ -117,19 +117,19 @@ bool ComputeCheckTilde(const style::TextStyle &st) { bool chIsBad(QChar ch) { return (ch == 0) - || (ch >= 8232 && ch < 8237) - || (ch >= 65024 && ch < 65040 && ch != 65039) - || (ch >= 127 && ch < 160 && ch != 156) + || (ch >= 8232 && ch < 8237) + || (ch >= 65024 && ch < 65040 && ch != 65039) + || (ch >= 127 && ch < 160 && ch != 156) - // qt harfbuzz crash see https://github.com/telegramdesktop/tdesktop/issues/4551 - || (Platform::IsMac() && ch == 6158) + // qt harfbuzz crash see https://github.com/telegramdesktop/tdesktop/issues/4551 + || (Platform::IsMac() && ch == 6158) - // tmp hack see https://bugreports.qt.io/browse/QTBUG-48910 + // tmp hack see https://bugreports.qt.io/browse/QTBUG-48910 || (Platform::IsMac10_11OrGreater() && !Platform::IsMac10_12OrGreater() && ch >= 0x0B00 - && ch <= 0x0B7F - && chIsDiac(ch)); + && ch <= 0x0B7F + && chIsDiac(ch)); } QString textcmdSkipBlock(ushort w, ushort h) { @@ -1518,7 +1518,7 @@ private: eShapeLine(line); int firstItem = engine.findItem(line.from), lastItem = engine.findItem(line.from + line.length - 1); - int nItems = (firstItem >= 0 && lastItem >= firstItem) ? (lastItem - firstItem + 1) : 0; + int nItems = (firstItem >= 0 && lastItem >= firstItem) ? (lastItem - firstItem + 1) : 0; if (!nItems) { return true; } @@ -1545,7 +1545,7 @@ private: } } } - QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); + QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); if (style::RightToLeft() && skipIndex == nItems - 1) { for (int32 i = nItems; i > 1;) { --i; @@ -1870,7 +1870,7 @@ private: _wLeft = _w - elideWidth - _elideRemoveFromEnd; int firstItem = engine.findItem(line.from), lastItem = engine.findItem(line.from + line.length - 1); - int nItems = (firstItem >= 0 && lastItem >= firstItem) ? (lastItem - firstItem + 1) : 0, i; + int nItems = (firstItem >= 0 && lastItem >= firstItem) ? (lastItem - firstItem + 1) : 0, i; for (i = 0; i < nItems; ++i) { QScriptItem &si(engine.layoutData->items[firstItem + i]); From 0aadf4ca7d483600122bacac1bf24bb6cfe7e448 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 2 Jan 2020 14:57:22 +0300 Subject: [PATCH 23/28] Correctly minimize window. --- ui/platform/win/ui_window_title_win.cpp | 3 ++- ui/platform/win/ui_window_win.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/platform/win/ui_window_title_win.cpp b/ui/platform/win/ui_window_title_win.cpp index 986cca5..d08e332 100644 --- a/ui/platform/win/ui_window_title_win.cpp +++ b/ui/platform/win/ui_window_title_win.cpp @@ -53,7 +53,8 @@ void TitleWidget::setResizeEnabled(bool enabled) { void TitleWidget::init() { _minimize->setClickedCallback([=] { - window()->setWindowState(Qt::WindowMinimized); + window()->setWindowState( + window()->windowState() | Qt::WindowMinimized); _minimize->clearState(); }); _minimize->setPointerCursor(false); diff --git a/ui/platform/win/ui_window_win.cpp b/ui/platform/win/ui_window_win.cpp index 58fb94a..41a2260 100644 --- a/ui/platform/win/ui_window_win.cpp +++ b/ui/platform/win/ui_window_win.cpp @@ -338,9 +338,12 @@ bool WindowHelper::handleNativeEvent( } const auto command = LOWORD(wParam); switch (command) { - case SC_CLOSE: _window->close(); return true; + case SC_CLOSE: + _window->close(); + return true; case SC_MINIMIZE: - _window->setWindowState(Qt::WindowMinimized); + _window->setWindowState( + _window->windowState() | Qt::WindowMinimized); return true; case SC_MAXIMIZE: if (!fixedSize()) { From 4ec9e32f8f5f6b8192fd60d73ae0b575e82c1c60 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 2 Jan 2020 15:21:57 +0300 Subject: [PATCH 24/28] Use fallback color for spell checker underline. --- ui/colors.palette | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/colors.palette b/ui/colors.palette index 76af17f..3796680 100644 --- a/ui/colors.palette +++ b/ui/colors.palette @@ -558,7 +558,7 @@ outdateSoonBg: #e08543; // operating system version is soon outdated bar backgro outdatedBg: #e05745; // operating system version is already outdated bar background // spellcheck -spellUnderline: #ff000088; // misspelled words +spellUnderline: #ff000088 | attentionButtonFg; // misspelled words walletTitleBg: #121213; // wallet window title background when window is inactive walletTitleBgActive: walletTitleBg; // wallet window title background when window is active From 26e6a3050c8c768da2fec03db905e413a1ebcc9e Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 7 Jan 2020 15:16:00 +0300 Subject: [PATCH 25/28] Allow non-activatable window on Windows. --- ui/platform/linux/ui_utility_linux.cpp | 3 +++ ui/platform/mac/ui_utility_mac.mm | 3 +++ ui/platform/ui_platform_utility.h | 1 + ui/platform/win/ui_utility_win.cpp | 15 +++++++++++++++ 4 files changed, 22 insertions(+) diff --git a/ui/platform/linux/ui_utility_linux.cpp b/ui/platform/linux/ui_utility_linux.cpp index 0bd8f94..e43e672 100644 --- a/ui/platform/linux/ui_utility_linux.cpp +++ b/ui/platform/linux/ui_utility_linux.cpp @@ -43,5 +43,8 @@ bool TranslucentWindowsSupported(QPoint globalPosition) { return false; } +void IgnoreAllActivation(not_null widget) { +} + } // namespace Platform } // namespace Ui diff --git a/ui/platform/mac/ui_utility_mac.mm b/ui/platform/mac/ui_utility_mac.mm index 4055c4a..a7e05db 100644 --- a/ui/platform/mac/ui_utility_mac.mm +++ b/ui/platform/mac/ui_utility_mac.mm @@ -91,5 +91,8 @@ void DrainMainQueue() { _dispatch_main_queue_callback_4CF(nullptr); } +void IgnoreAllActivation(not_null widget) { +} + } // namespace Platform } // namespace Ui diff --git a/ui/platform/ui_platform_utility.h b/ui/platform/ui_platform_utility.h index d253c91..dec7e12 100644 --- a/ui/platform/ui_platform_utility.h +++ b/ui/platform/ui_platform_utility.h @@ -25,6 +25,7 @@ void ReInitOnTopPanel(not_null panel); void UpdateOverlayed(not_null widget); void ShowOverAll(not_null widget, bool canFocus = true); void BringToBack(not_null widget); +void IgnoreAllActivation(not_null widget); [[nodiscard]] constexpr bool UseMainQueueGeneric(); void DrainMainQueue(); // Needed only if UseMainQueueGeneric() is false. diff --git a/ui/platform/win/ui_utility_win.cpp b/ui/platform/win/ui_utility_win.cpp index f6fd431..b9ddcbd 100644 --- a/ui/platform/win/ui_utility_win.cpp +++ b/ui/platform/win/ui_utility_win.cpp @@ -8,6 +8,8 @@ #include +#include "base/platform/win/base_windows_h.h" + namespace Ui { namespace Platform { @@ -27,5 +29,18 @@ void UpdateOverlayed(not_null widget) { if (!wv) widget->setAttribute(Qt::WA_WState_Visible, false); } +void IgnoreAllActivation(not_null widget) { + const auto handle = reinterpret_cast(widget->winId()); + Assert(handle != nullptr); + + ShowWindow(handle, SW_HIDE); + const auto style = GetWindowLong(handle, GWL_EXSTYLE); + SetWindowLong( + handle, + GWL_EXSTYLE, + style | WS_EX_NOACTIVATE | WS_EX_APPWINDOW); + ShowWindow(handle, SW_SHOW); +} + } // namespace Platform } // namespace Ui From 20b37f2dc1e186d697096224a2fbdb812de5a047 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 13 Jan 2020 13:04:37 +0300 Subject: [PATCH 26/28] Fix nested wrapped widgets. --- ui/wrap/wrap.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/wrap/wrap.h b/ui/wrap/wrap.h index 0d9cb08..7dbe93b 100644 --- a/ui/wrap/wrap.h +++ b/ui/wrap/wrap.h @@ -77,6 +77,8 @@ public: return RpWidget::naturalWidth(); } + using WrapParentType = RpWidget; + protected: int resizeGetHeight(int newWidth) override { if (auto weak = wrapped()) { From 777cf61626e8be9e845d73938fd9427d407971cc Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 17 Jan 2020 15:53:58 +0400 Subject: [PATCH 27/28] Don't load linux.qrc when DESKTOP_APP_USE_PACKAGED is defined --- CMakeLists.txt | 5 ++++- ui/style/style_core_font.cpp | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 687b25f..0b15166 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,11 +21,14 @@ set(style_files ) set(qrc_files fonts/fonts.qrc - qt_conf/linux.qrc qt_conf/mac.qrc qt_conf/win.qrc ) +if (NOT DESKTOP_APP_USE_PACKAGED) + set(qrc_files qt_conf/linux.qrc) +endif() + generate_palette(lib_ui ui/colors.palette) generate_styles(lib_ui ${src_loc} "${style_files}" ui/colors.palette) generate_emoji(lib_ui emoji_suggestions/emoji_autocomplete.json) diff --git a/ui/style/style_core_font.cpp b/ui/style/style_core_font.cpp index cfe2111..9f3aad8 100644 --- a/ui/style/style_core_font.cpp +++ b/ui/style/style_core_font.cpp @@ -20,9 +20,9 @@ void style_InitFontsResource() { Q_INIT_RESOURCE(win); #elif defined Q_OS_MAC // Q_OS_WIN Q_INIT_RESOURCE(mac); -#else // Q_OS_WIN || Q_OS_MAC +#elif defined Q_OS_LINUX && !defined DESKTOP_APP_USE_PACKAGED // Q_OS_WIN || Q_OS_MAC Q_INIT_RESOURCE(linux); -#endif // Q_OS_WIN || Q_OS_MAC || Q_OS_LINUX +#endif // Q_OS_WIN || Q_OS_MAC || (Q_OS_LINUX && !DESKTOP_APP_USE_PACKAGED) } namespace style { From c0b07457fa5df905f7926025302f66065dc4d52b Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 17 Jan 2020 18:13:05 +0300 Subject: [PATCH 28/28] Fix build without DESKTOP_APP_USE_PACKAGED. --- CMakeLists.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b15166..81bf4d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,15 +19,6 @@ set(style_files ui/layers/layers.style ui/widgets/widgets.style ) -set(qrc_files - fonts/fonts.qrc - qt_conf/mac.qrc - qt_conf/win.qrc -) - -if (NOT DESKTOP_APP_USE_PACKAGED) - set(qrc_files qt_conf/linux.qrc) -endif() generate_palette(lib_ui ui/colors.palette) generate_styles(lib_ui ${src_loc} "${style_files}" ui/colors.palette) @@ -38,11 +29,14 @@ set_target_properties(lib_ui PROPERTIES AUTOMOC ON AUTORCC ON) target_precompile_headers(lib_ui PRIVATE ${src_loc}/ui/ui_pch.h) nice_target_sources(lib_ui ${src_loc} PRIVATE - ${qrc_files} ${style_files} ui/colors.palette emoji_suggestions/emoji_autocomplete.json + fonts/fonts.qrc + qt_conf/mac.qrc + qt_conf/win.qrc + ui/effects/animation_value.cpp ui/effects/animation_value.h ui/effects/animations.cpp @@ -191,6 +185,10 @@ PRIVATE emoji_suggestions/emoji_suggestions_helper.h ) +if (NOT DESKTOP_APP_USE_PACKAGED) + nice_target_sources(lib_ui ${src_loc} PRIVATE qt_conf/linux.qrc) +endif() + target_include_directories(lib_ui PUBLIC ${src_loc}