mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 09:02:43 +00:00 
			
		
		
		
	Userland: Port GUI::Application::show_tooltip() to String
This most importantly gets rid of a chain of "String to DeprecatedString to String" transformations when setting a tooltip from GUI::Widget's set_tooltip function.
This commit is contained in:
		
							parent
							
								
									16defb4806
								
							
						
					
					
						commit
						a3ddba4191
					
				
					 7 changed files with 12 additions and 12 deletions
				
			
		|  | @ -187,7 +187,7 @@ void MapWidget::mousemove_event(GUI::MouseEvent& event) | |||
|             marker_image->height() | ||||
|         }; | ||||
|         if (marker_rect.contains(event.x(), event.y())) { | ||||
|             GUI::Application::the()->show_tooltip(marker.tooltip.value().to_deprecated_string(), this); | ||||
|             GUI::Application::the()->show_tooltip(marker.tooltip.value(), this); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -74,7 +74,7 @@ void GuideTool::on_mousedown(Layer*, MouseEvent& event) | |||
| 
 | ||||
|     if (m_selected_guide) { | ||||
|         m_guide_origin = m_selected_guide->offset(); | ||||
|         GUI::Application::the()->show_tooltip_immediately(DeprecatedString::formatted("{}", m_guide_origin), GUI::Application::the()->tooltip_source_widget()); | ||||
|         GUI::Application::the()->show_tooltip_immediately(MUST(String::number(m_guide_origin)), GUI::Application::the()->tooltip_source_widget()); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -120,7 +120,7 @@ void GuideTool::on_mousemove(Layer*, MouseEvent& event) | |||
| 
 | ||||
|     m_selected_guide->set_offset(new_offset); | ||||
| 
 | ||||
|     GUI::Application::the()->show_tooltip_immediately(DeprecatedString::formatted("{}", new_offset), GUI::Application::the()->tooltip_source_widget()); | ||||
|     GUI::Application::the()->show_tooltip_immediately(MUST(String::number(new_offset)), GUI::Application::the()->tooltip_source_widget()); | ||||
| 
 | ||||
|     editor()->update(); | ||||
| } | ||||
|  |  | |||
|  | @ -130,7 +130,7 @@ void TimelineTrack::mousemove_event(GUI::MouseEvent& event) | |||
|         Gfx::IntRect hoverable_rect { x - hoverable_padding, frame_thickness(), hoverable_padding * 2, height() - frame_thickness() * 2 }; | ||||
|         if (hoverable_rect.contains_horizontally(event.x())) { | ||||
|             auto const& data = signpost.data.template get<Profile::Event::SignpostData>(); | ||||
|             GUI::Application::the()->show_tooltip_immediately(DeprecatedString::formatted("{}, {}", data.string, data.arg), this); | ||||
|             GUI::Application::the()->show_tooltip_immediately(MUST(String::formatted("{}, {}", data.string, data.arg)), this); | ||||
|             hovering_a_signpost = true; | ||||
|             return IterationDecision::Break; | ||||
|         } | ||||
|  |  | |||
|  | @ -25,9 +25,9 @@ class Application::TooltipWindow final : public Window { | |||
|     C_OBJECT(TooltipWindow); | ||||
| 
 | ||||
| public: | ||||
|     void set_tooltip(DeprecatedString const& tooltip) | ||||
|     void set_tooltip(String tooltip) | ||||
|     { | ||||
|         m_label->set_text(String::from_deprecated_string(tooltip).release_value_but_fixme_should_propagate_errors()); | ||||
|         m_label->set_text(move(tooltip)); | ||||
|         int tooltip_width = m_label->effective_min_size().width().as_int() + 10; | ||||
|         int line_count = m_label->text().count("\n"sv); | ||||
|         int font_size = m_label->font().pixel_size_rounded_up(); | ||||
|  | @ -152,7 +152,7 @@ Action* Application::action_for_shortcut(Shortcut const& shortcut) const | |||
|     return (*it).value; | ||||
| } | ||||
| 
 | ||||
| void Application::show_tooltip(DeprecatedString tooltip, Widget const* tooltip_source_widget) | ||||
| void Application::show_tooltip(String tooltip, Widget const* tooltip_source_widget) | ||||
| { | ||||
|     if (!Desktop::the().system_effects().tooltips()) | ||||
|         return; | ||||
|  | @ -173,7 +173,7 @@ void Application::show_tooltip(DeprecatedString tooltip, Widget const* tooltip_s | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void Application::show_tooltip_immediately(DeprecatedString tooltip, Widget const* tooltip_source_widget) | ||||
| void Application::show_tooltip_immediately(String tooltip, Widget const* tooltip_source_widget) | ||||
| { | ||||
|     if (!Desktop::the().system_effects().tooltips()) | ||||
|         return; | ||||
|  |  | |||
|  | @ -41,8 +41,8 @@ public: | |||
|     void register_global_shortcut_action(Badge<Action>, Action&); | ||||
|     void unregister_global_shortcut_action(Badge<Action>, Action&); | ||||
| 
 | ||||
|     void show_tooltip(DeprecatedString, Widget const* tooltip_source_widget); | ||||
|     void show_tooltip_immediately(DeprecatedString, Widget const* tooltip_source_widget); | ||||
|     void show_tooltip(String, Widget const* tooltip_source_widget); | ||||
|     void show_tooltip_immediately(String, Widget const* tooltip_source_widget); | ||||
|     void hide_tooltip(); | ||||
|     Widget const* tooltip_source_widget() { return m_tooltip_source_widget; } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1122,7 +1122,7 @@ void Widget::set_tooltip(String tooltip) | |||
| void Widget::show_or_hide_tooltip() | ||||
| { | ||||
|     if (has_tooltip()) | ||||
|         Application::the()->show_tooltip(m_tooltip.to_deprecated_string(), this); | ||||
|         Application::the()->show_tooltip(m_tooltip, this); | ||||
|     else | ||||
|         Application::the()->hide_tooltip(); | ||||
| } | ||||
|  |  | |||
|  | @ -65,7 +65,7 @@ OutOfProcessWebView::OutOfProcessWebView() | |||
|     }; | ||||
| 
 | ||||
|     on_enter_tooltip_area = [](auto, auto tooltip) { | ||||
|         GUI::Application::the()->show_tooltip(tooltip, nullptr); | ||||
|         GUI::Application::the()->show_tooltip(MUST(String::from_deprecated_string(tooltip)), nullptr); | ||||
|     }; | ||||
| 
 | ||||
|     on_leave_tooltip_area = []() { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Karol Kosek
						Karol Kosek