Truly independent web browser
UI/Qt: Add a feedback button to the toolbar
Andreas Klingf10301cfa32c
diff --git a/Libraries/LibCore/BrowserVersion.h.in b/Libraries/LibCore/BrowserVersion.h.inindex 8c768f8f846..872844b86ba 100644--- a/Libraries/LibCore/BrowserVersion.h.in+++ b/Libraries/LibCore/BrowserVersion.h.in@@ -10,3 +10,4 @@#define BROWSER_BUILD_CONFIGURATION "@CMAKE_BUILD_TYPE@"#define BROWSER_RELEASE_STAGE "@browser_release_stage@"#define BROWSER_PRODUCT_NAME "@browser_product_name@"+#define BROWSER_IS_FINAL_RELEASE @browser_is_final_release@diff --git a/Libraries/LibCore/CMakeLists.txt b/Libraries/LibCore/CMakeLists.txtindex f4cb48ff809..e5cfab1e9ce 100644--- a/Libraries/LibCore/CMakeLists.txt+++ b/Libraries/LibCore/CMakeLists.txt@@ -116,8 +116,12 @@ ladybird_lib(LibCore core EXPLICIT_SYMBOL_EXPORT)target_link_libraries(LibCore PRIVATE Threads::Threads LibUnicode LibTextCodec mimalloc)# Development builds are in no stage of development, and leave it out of their product name.+set(browser_is_final_release 0)if (NOT LADYBIRD_VERSION STREQUAL "")set(browser_release_stage "${LADYBIRD_RELEASE_STAGE}")+ if (browser_release_stage STREQUAL "")+ set(browser_is_final_release 1)+ endif()endif()string(JOIN " " browser_product_name "Ladybird" ${browser_release_stage})configure_file(BrowserVersion.h.in BrowserVersion.h @ONLY)diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cppindex f405d12a44e..631d8a233cc 100644--- a/UI/Qt/Application.cpp+++ b/UI/Qt/Application.cpp@@ -1182,6 +1182,14 @@ void Application::display_crash_report_notification(ByteString const& report_namm_crash_report_notifier.offer(report_name);}+void Application::update_feedback_buttons()+{+ for (auto* widget : QApplication::topLevelWidgets()) {+ if (auto* window = as_if<BrowserWindow>(widget))+ window->toolbar().update_feedback_button();+ }+}+void Application::review_crash_report(ByteString const& report_name){if (!m_active_window)diff --git a/UI/Qt/Application.h b/UI/Qt/Application.hindex 2529f66ec4a..65c31d40187 100644--- a/UI/Qt/Application.h+++ b/UI/Qt/Application.h@@ -81,6 +81,7 @@ public:bool confirm_stop_active_downloads(QWidget* parent = nullptr);CrashReportNotifier& crash_report_notifier() { return m_crash_report_notifier; }+ void update_feedback_buttons();void review_crash_report(ByteString const& report_name);BrowserWindow& active_window() const { return *m_active_window; }diff --git a/UI/Qt/CMakeLists.txt b/UI/Qt/CMakeLists.txtindex 59140801126..c48de9c9154 100644--- a/UI/Qt/CMakeLists.txt+++ b/UI/Qt/CMakeLists.txt@@ -26,6 +26,7 @@ add_library(ladybird_impl STATICDevToolsBanner.cppEventLoopImplementationQt.cppEventLoopImplementationQtEventTarget.cpp+ FeedbackPopover.cppFindInPageWidget.cppHiddenPageSizing.cppIcon.cppdiff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cppindex 827ee74a2fa..1a983df7cce 100644--- a/UI/Qt/ChromeStyle.cpp+++ b/UI/Qt/ChromeStyle.cpp@@ -1713,6 +1713,50 @@ QToolButton#LadybirdPopoverIconButton {{style_sheet_color(panel.separator), style_sheet_color(panel.link), style_sheet_color(panel.warning), style_sheet_color(panel.control), style_sheet_color(panel.pressed));}+QString feedback_popover_style_sheet(QPalette const&)+{+ auto const& panel = Theme::panel();+ return qformatted(R"(+QFrame#LadybirdFeedbackPopover {{+ color: {0};+ background: {1};+ border: 1px solid {2};+ border-radius: 12px;+}}++QFrame#LadybirdFeedbackPopover QLabel {{+ color: {0};+ background: transparent;+}}++QFrame#LadybirdFeedbackPopover QLabel#LadybirdFeedbackDetail {{+ color: {3};+ font-size: 12px;+}}++QFrame#LadybirdPopoverSeparator {{+ background: {4};+ border: 0;+}}++QPushButton#LadybirdPopoverRow {{+ background: transparent;+ border: 0;+ border-radius: 6px;+}}++QPushButton#LadybirdPopoverRow:hover {{+ background: {5};+}}++QPushButton#LadybirdPopoverRow:pressed {{+ background: {6};+}}+)",+ style_sheet_color(panel.text), style_sheet_color(panel.surface), style_sheet_color(over(panel.edge, panel.surface)), style_sheet_color(panel.muted),+ style_sheet_color(panel.separator), style_sheet_color(panel.control), style_sheet_color(panel.pressed));+}+QString all_tabs_popover_style_sheet(QPalette const&){auto const& panel = Theme::panel();diff --git a/UI/Qt/ChromeStyle.h b/UI/Qt/ChromeStyle.hindex 68d37dfa579..bf77495ac29 100644--- a/UI/Qt/ChromeStyle.h+++ b/UI/Qt/ChromeStyle.h@@ -98,6 +98,7 @@ QString autocomplete_popup_style_sheet(QPalette const&);QString downloads_popover_style_sheet(QPalette const&);QString message_popover_style_sheet(QPalette const&);QString site_settings_popover_style_sheet(QPalette const&);+QString feedback_popover_style_sheet(QPalette const&);QString permission_prompt_style_sheet(QPalette const&);QString all_tabs_popover_style_sheet(QPalette const&);QString bookmark_popover_style_sheet(QPalette const&);diff --git a/UI/Qt/CrashReportNotifier.cpp b/UI/Qt/CrashReportNotifier.cppindex 4f0b0f874f1..63e6f4237ad 100644--- a/UI/Qt/CrashReportNotifier.cpp+++ b/UI/Qt/CrashReportNotifier.cpp@@ -23,6 +23,7 @@ static constexpr int CRASH_REPORT_POPOVER_WIDTH = 340;void CrashReportNotifier::offer(ByteString report_name){m_pending_report_name = move(report_name);+ Application::the().update_feedback_buttons();if (!exchange(m_is_listening_for_activation, true)) {QObject::connect(qApp, &QGuiApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) {@@ -77,12 +78,16 @@ void CrashReportNotifier::show_pending()// The review marks the report as seen once it opens it. The popover is the report's one automatic prompt, so// however else it is left, the report is not offered again. Leaving it also declines the reports still waiting,// except when a newer report takes its place, which is about to be offered itself.- m_popover->on_accept = [report_name] { Application::the().review_crash_report(report_name); };+ m_popover->on_accept = [report_name] {+ Application::the().review_crash_report(report_name);+ Application::the().update_feedback_buttons();+ };m_popover->on_dismiss = [this, report_name] {auto& store = WebView::CrashReportStore::the();auto result = m_is_replacing_popover ? store.mark_seen(report_name) : store.mark_all_seen();if (result.is_error())warnln("Could not mark crash reports as seen: {}", result.error());+ Application::the().update_feedback_buttons();};// The menu button's palette is transparent, so the popover takes its colors from the window instead.diff --git a/UI/Qt/FeedbackPopover.cpp b/UI/Qt/FeedbackPopover.cppnew file mode 100644index 00000000000..f6d1d0b804d--- /dev/null+++ b/UI/Qt/FeedbackPopover.cpp@@ -0,0 +1,174 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <UI/Qt/ChromeStyle.h>+#include <UI/Qt/FeedbackPopover.h>+#include <UI/Qt/Icon.h>+#include <UI/Qt/Theme.h>++#include <QFrame>+#include <QHBoxLayout>+#include <QLabel>+#include <QPainter>+#include <QPixmap>+#include <QPushButton>+#include <QVBoxLayout>++namespace Ladybird {++static constexpr int POPOVER_WIDTH = 300;+static constexpr int ROW_HEIGHT = 32;+static constexpr int ROW_WITH_DETAIL_HEIGHT = 46;+static constexpr int CRASH_REPORTS_DOT_SIZE = 7;+static constexpr int EXTERNAL_LINK_ICON_SIZE = 14;+static constexpr int CHEVRON_ICON_SIZE = 12;++static QLabel* create_row_label(QString const& text, QWidget& row)+{+ auto* label = new QLabel(text, &row);+ label->setAttribute(Qt::WA_TransparentForMouseEvents);+ label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);+ return label;+}++static QLabel* create_detail_label(QString const& text, QWidget& row)+{+ auto* label = create_row_label(text, row);+ label->setObjectName("LadybirdFeedbackDetail");+ return label;+}++static QLabel* create_row_icon(QWidget& row, int size)+{+ auto* icon = new QLabel(&row);+ icon->setFixedSize(size, size);+ icon->setAttribute(Qt::WA_TransparentForMouseEvents);+ return icon;+}++static QPushButton* create_row(QWidget& parent, QString const& accessible_name, int height)+{+ auto* row = new QPushButton(&parent);+ row->setObjectName("LadybirdPopoverRow");+ row->setAccessibleName(accessible_name);+ row->setFixedHeight(height);+ row->setAttribute(Qt::WA_LayoutUsesWidgetRect);+ auto* layout = new QHBoxLayout(row);+ layout->setContentsMargins(10, 0, 10, 0);+ layout->setSpacing(10);+ return row;+}++static QVBoxLayout* create_row_text(QPushButton& row, QString const& title)+{+ auto* text = new QVBoxLayout;+ text->setContentsMargins(0, 0, 0, 0);+ text->setSpacing(2);+ text->setAlignment(Qt::AlignVCenter);+ text->addWidget(create_row_label(title, row));+ static_cast<QHBoxLayout*>(row.layout())->addLayout(text, 1);+ return text;+}++FeedbackPopover::FeedbackPopover(QWidget* parent)+ : Popover(parent)+{+ setAccessibleName("Send feedback");+ card().setObjectName("LadybirdFeedbackPopover");+ card().setFixedWidth(POPOVER_WIDTH);++ auto* layout = new QVBoxLayout(&card());+ layout->setContentsMargins(6, 6, 6, 6);+ layout->setSpacing(0);++ m_report_site_row = create_row(card(), "Report a problem with this site", ROW_WITH_DETAIL_HEIGHT);+ auto* report_site_text = create_row_text(*m_report_site_row, "Report a problem with this site");+ m_host_label = create_detail_label({}, *m_report_site_row);+ report_site_text->addWidget(m_host_label);+ QObject::connect(m_report_site_row, &QPushButton::clicked, this, [this] {+ close();+ if (on_report_site)+ on_report_site();+ });+ layout->addWidget(m_report_site_row);++ auto* report_bug_row = create_row(card(), "Report a bug on GitHub", ROW_WITH_DETAIL_HEIGHT);+ auto* report_bug_text = create_row_text(*report_bug_row, "Report a bug");+ report_bug_text->addWidget(create_detail_label("On GitHub", *report_bug_row));+ m_external_link_icon = create_row_icon(*report_bug_row, EXTERNAL_LINK_ICON_SIZE);+ report_bug_row->layout()->addWidget(m_external_link_icon);+ QObject::connect(report_bug_row, &QPushButton::clicked, this, [this] {+ close();+ if (on_report_bug)+ on_report_bug();+ });+ layout->addWidget(report_bug_row);++ m_crash_reports_section = new QWidget(&card());+ auto* section_layout = new QVBoxLayout(m_crash_reports_section);+ section_layout->setContentsMargins(0, 5, 0, 0);+ section_layout->setSpacing(5);++ auto* separator = new QFrame(m_crash_reports_section);+ separator->setObjectName("LadybirdPopoverSeparator");+ separator->setFixedHeight(1);+ auto* separator_row = new QHBoxLayout;+ separator_row->setContentsMargins(10, 0, 10, 0);+ separator_row->addWidget(separator);+ section_layout->addLayout(separator_row);++ auto* crash_reports_row = create_row(*m_crash_reports_section, "Crash reports", ROW_HEIGHT);+ m_crash_reports_dot = create_row_icon(*crash_reports_row, CRASH_REPORTS_DOT_SIZE);+ crash_reports_row->layout()->addWidget(m_crash_reports_dot);+ create_row_text(*crash_reports_row, "Crash reports");+ m_crash_reports_count = create_detail_label({}, *crash_reports_row);+ crash_reports_row->layout()->addWidget(m_crash_reports_count);+ m_crash_reports_chevron = create_row_icon(*crash_reports_row, CHEVRON_ICON_SIZE);+ crash_reports_row->layout()->addWidget(m_crash_reports_chevron);+ QObject::connect(crash_reports_row, &QPushButton::clicked, this, [this] {+ close();+ if (on_review_crash_reports)+ on_review_crash_reports();+ });+ section_layout->addWidget(crash_reports_row);+ layout->addWidget(m_crash_reports_section);+}++void FeedbackPopover::update_chrome_style(QPalette const& palette)+{+ setPalette(palette);+ setStyleSheet(ChromeStyle::feedback_popover_style_sheet(palette));++ auto const& panel = Theme::panel();+ auto device_pixel_ratio = devicePixelRatioF();+ m_external_link_icon->setPixmap(create_chrome_icon(ChromeIcon::ExternalLink, panel.muted).pixmap(QSize(EXTERNAL_LINK_ICON_SIZE, EXTERNAL_LINK_ICON_SIZE), device_pixel_ratio));+ m_crash_reports_chevron->setPixmap(create_chrome_icon(ChromeIcon::Forward, panel.muted).pixmap(QSize(CHEVRON_ICON_SIZE, CHEVRON_ICON_SIZE), device_pixel_ratio));++ QPixmap dot(QSize(CRASH_REPORTS_DOT_SIZE, CRASH_REPORTS_DOT_SIZE) * device_pixel_ratio);+ dot.setDevicePixelRatio(device_pixel_ratio);+ dot.fill(Qt::transparent);+ QPainter painter(&dot);+ painter.setRenderHint(QPainter::Antialiasing, true);+ painter.setPen(Qt::NoPen);+ painter.setBrush(panel.text);+ painter.drawEllipse(QRectF(0, 0, CRASH_REPORTS_DOT_SIZE, CRASH_REPORTS_DOT_SIZE));+ painter.end();+ m_crash_reports_dot->setPixmap(dot);+}++void FeedbackPopover::set_reportable_host(QString const& host)+{+ m_host_label->setText(host);+ m_report_site_row->setVisible(!host.isEmpty());+}++void FeedbackPopover::set_crash_report_count(size_t count)+{+ m_crash_reports_count->setText(QString("%1 to review").arg(count));+ m_crash_reports_section->setVisible(count > 0);+}++}diff --git a/UI/Qt/FeedbackPopover.h b/UI/Qt/FeedbackPopover.hnew file mode 100644index 00000000000..8d616881f01--- /dev/null+++ b/UI/Qt/FeedbackPopover.h@@ -0,0 +1,49 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <AK/Function.h>+#include <AK/kmalloc.h>+#include <LibCore/BrowserVersion.h>+#include <UI/Qt/Popover.h>++class QFrame;+class QLabel;+class QPushButton;++namespace Ladybird {++// Builds that are still being tested ask for feedback from the toolbar. A final release does not.+static constexpr bool has_feedback_button = !BROWSER_IS_FINAL_RELEASE;++class FeedbackPopover final : public Popover {+public:+ AK_ALLOC_WITH_KMALLOC;++ explicit FeedbackPopover(QWidget* parent);++ void update_chrome_style(QPalette const&);++ // Without a host, the page is not a website that can be reported, and the panel does not offer to.+ void set_reportable_host(QString const& host);+ void set_crash_report_count(size_t);++ Function<void()> on_report_site;+ Function<void()> on_report_bug;+ Function<void()> on_review_crash_reports;++private:+ QPushButton* m_report_site_row { nullptr };+ QLabel* m_host_label { nullptr };+ QLabel* m_external_link_icon { nullptr };+ QWidget* m_crash_reports_section { nullptr };+ QLabel* m_crash_reports_dot { nullptr };+ QLabel* m_crash_reports_count { nullptr };+ QLabel* m_crash_reports_chevron { nullptr };+};++}diff --git a/UI/Qt/Icon.cpp b/UI/Qt/Icon.cppindex 135123e02a5..d6a7dfaa064 100644--- a/UI/Qt/Icon.cpp+++ b/UI/Qt/Icon.cpp@@ -304,6 +304,8 @@ static constexpr auto DOCUMENT_ICON_PATH = "M3.5 1.5h5l4 4v9h-9zM8.5 1.5v4h4"sv;static constexpr auto COMPOSITOR_ICON_PATH = "M5.5 6.5h9v7h-9zM5.5 9.5h-4v-7h9v4"sv;static constexpr auto IMAGE_ICON_PATH = "M2.5 2.5h11a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1zM1.5 11.5l3.5-3.5 5.5 5.5M9.5 9.5l2-2 3 3M10.5 5.5v.01"sv;static constexpr auto FOLDER_ICON_PATH = "M2.5 2.5h3l2 2h6a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1z"sv;+static constexpr auto FEEDBACK_ICON_PATH = "M3.5 1.5h8a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-4l-3 3v-3h-1a2 2 0 0 1-2-2v-6a2 2 0 0 1 2-2zM7.5 3.5v3M7.5 8.5v.01"sv;+static constexpr auto EXTERNAL_LINK_ICON_PATH = "M6.5 2.5h-3a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1v-3M9.5 1.5h4v4M13.5 1.5l-6 6"sv;// The window controls of Windows and Linux are drawn on a 10 px box in the middle of the icon.static constexpr auto WINDOW_MINIMIZE_ICON_PATH = "M3.5 8.5h9"sv;@@ -383,6 +385,10 @@ static StringView chrome_icon_path(ChromeIcon icon)return WARNING_ICON_PATH;case ChromeIcon::Pause:return PAUSE_ICON_PATH;+ case ChromeIcon::Feedback:+ return FEEDBACK_ICON_PATH;+ case ChromeIcon::ExternalLink:+ return EXTERNAL_LINK_ICON_PATH;case ChromeIcon::ZoomOut:return ZOOM_OUT_ICON_PATH;case ChromeIcon::Sidebar:diff --git a/UI/Qt/Icon.h b/UI/Qt/Icon.hindex e08ca05aba2..1aa09cf244b 100644--- a/UI/Qt/Icon.h+++ b/UI/Qt/Icon.h@@ -54,6 +54,8 @@ enum class ChromeIcon {Image,Warning,Pause,+ Feedback,+ ExternalLink,ZoomOut,Sidebar,SidebarRight,diff --git a/UI/Qt/WindowToolbar.cpp b/UI/Qt/WindowToolbar.cppindex d57975bd89c..e6aae48b31c 100644--- a/UI/Qt/WindowToolbar.cpp+++ b/UI/Qt/WindowToolbar.cpp@@ -8,13 +8,16 @@*/#include <AK/kmalloc.h>+#include <LibURL/Parser.h>#include <LibWebView/Application.h>+#include <LibWebView/CrashReportStore.h>#include <LibWebView/DownloadPresentation.h>#include <LibWebView/TabPerformanceMonitor.h>#include <UI/Qt/Application.h>#include <UI/Qt/BrowserWindow.h>#include <UI/Qt/ChromeLayout.h>#include <UI/Qt/ChromeStyle.h>+#include <UI/Qt/FeedbackPopover.h>#include <UI/Qt/Icon.h>#include <UI/Qt/LadybirdButton.h>#include <UI/Qt/Menu.h>@@ -511,6 +514,77 @@ private:QVariantAnimation m_ring_fade;};+// The feedback button ends the toolbar of builds that are still being tested, and opens the ways to send feedback. A+// dot marks it while crash reports wait to be reviewed.+class FeedbackButton final : public ToolbarButton {+public:+ AK_ALLOC_WITH_KMALLOC;++ explicit FeedbackButton(QWidget* parent)+ : ToolbarButton(parent)+ {+ setObjectName("LadybirdFeedbackButton");+ setToolTip("Send feedback");+ setAccessibleName("Send feedback");+ // NB: The button stays checked while the popover is open.+ setCheckable(true);+ setAutoRaise(true);+ setFocusPolicy(Qt::NoFocus);+ setIconSize({ TOOLBAR_ICON_SIZE, TOOLBAR_ICON_SIZE });+ setFixedSize(TOOLBAR_BUTTON_SIZE);+ setAttribute(Qt::WA_LayoutUsesWidgetRect);++ m_dot_animation.setDuration(Motion::BASE);+ m_dot_animation.setEasingCurve(Motion::enter_easing());+ m_dot_animation.setStartValue(0.0);+ m_dot_animation.setEndValue(1.0);+ QObject::connect(&m_dot_animation, &QVariantAnimation::valueChanged, this, [this](QVariant const& value) {+ m_dot_scale = value.toDouble();+ update();+ });+ }++ void set_crash_reports_waiting(bool crash_reports_waiting)+ {+ if (m_crash_reports_waiting == crash_reports_waiting)+ return;+ m_crash_reports_waiting = crash_reports_waiting;+ setAccessibleName(crash_reports_waiting ? "Send feedback, crash reports waiting" : "Send feedback");++ // A dot that is already there when a window opens was not just earned, so it does not animate.+ m_dot_animation.stop();+ m_dot_scale = 1;+ if (crash_reports_waiting && isVisible() && !SystemAppearance::prefers_reduced_motion()) {+ m_dot_scale = 0;+ m_dot_animation.start();+ }+ update();+ }++private:+ virtual void paintEvent(QPaintEvent* event) override+ {+ ToolbarButton::paintEvent(event);+ if (!m_crash_reports_waiting)+ return;++ QPainter painter(this);+ painter.setRenderHint(QPainter::Antialiasing, true);+ auto palette = Theme::chrome_palette(*this);+ QPointF dot_center { width() - 9.5, 7.5 };+ painter.setPen(Qt::NoPen);+ painter.setBrush(Theme::chrome(palette).toolbar);+ painter.drawEllipse(dot_center, 5.5 * m_dot_scale, 5.5 * m_dot_scale);+ // NB: In the icon's color, the dot would fuse with the glyph it sits on.+ painter.setBrush(ChromeStyle::is_dark(palette) ? QColor(0xF2, 0xA3, 0x3A) : QColor(0xD9, 0x80, 0x0F));+ painter.drawEllipse(dot_center, 3.5 * m_dot_scale, 3.5 * m_dot_scale);+ }++ bool m_crash_reports_waiting { false };+ QVariantAnimation m_dot_animation;+ qreal m_dot_scale { 1 };+};+template<typename ButtonType = ToolbarButton>static ButtonType* create_toolbar_button(QWidget& parent, QAction& action){@@ -546,6 +620,7 @@ static constexpr int toolbar_right_margin(bool has_custom_window_controls){return has_custom_window_controls ? 0 : TOOLBAR_HORIZONTAL_MARGIN - TOOLBAR_LOCATION_FOCUS_RING_ROOM;}+static constexpr auto REPORT_BUG_URL = "https://github.com/LadybirdBrowser/ladybird/issues/new?template=bug_report.yml"sv;static constexpr int DOWNLOADS_POPOVER_WIDTH = 380;static constexpr int DOWNLOADS_POPOVER_MAX_HEIGHT = 360;class ElidedLabel final : public QLabel {@@ -975,6 +1050,15 @@ WindowToolbar::WindowToolbar(WebView::IsPrivate is_private, QWidget* parent)show_downloads_popover();});+ if constexpr (has_feedback_button) {+ m_feedback_button = new FeedbackButton(m_toolbar);+ QObject::connect(m_feedback_button, &QToolButton::clicked, this, [this] {+ // NB: The button only stays checked while the popover is open, which showing it sees to.+ m_feedback_button->setChecked(m_feedback_popover && m_feedback_popover->isVisible());+ show_feedback_popover();+ });+ }+m_navigate_back_action.action().setEnabled(false);m_navigate_forward_action.action().setEnabled(false);m_reload_action = create_application_action(*this, application.reload_action());@@ -1072,6 +1156,8 @@ WindowToolbar::WindowToolbar(WebView::IsPrivate is_private, QWidget* parent)toolbar_layout->addWidget(navigation_button_cluster, 0, Qt::AlignVCenter);toolbar_layout->addWidget(location_edit_container, 1);toolbar_layout->addWidget(m_downloads_button, 0, Qt::AlignVCenter);+ if (m_feedback_button)+ toolbar_layout->addWidget(m_feedback_button, 0, Qt::AlignVCenter);toolbar_layout->addWidget(m_performance_monitor, 0, Qt::AlignVCenter);if constexpr (!use_native_macos_window_controls()) {@@ -1084,6 +1170,7 @@ WindowToolbar::WindowToolbar(WebView::IsPrivate is_private, QWidget* parent)recreate_icons();update_chrome_style();set_window_controls_visible(false);+ update_feedback_button();}WindowToolbar::~WindowToolbar() = default;@@ -1307,6 +1394,8 @@ void WindowToolbar::update_chrome_style()setStyleSheet(ChromeStyle::toolbar_container_style_sheet(Theme::chrome_palette(*this)));if (m_downloads_popover)m_downloads_popover->update_chrome_style(palette());+ if (m_feedback_popover)+ m_feedback_popover->update_chrome_style(palette());m_is_updating_chrome_style = false;}@@ -1318,6 +1407,8 @@ void WindowToolbar::recreate_icons()m_reload_action->setIcon(create_chrome_icon(ChromeIcon::Reload, Theme::chrome_palette(*this), activity, TOOLBAR_ICON_SIZE));m_stop_action->setIcon(create_chrome_icon(ChromeIcon::Stop, Theme::chrome_palette(*this), activity, TOOLBAR_ICON_SIZE));m_downloads_button->setIcon(create_chrome_icon(ChromeIcon::Download, Theme::chrome_palette(*this), activity, TOOLBAR_ICON_SIZE));+ if (m_feedback_button)+ m_feedback_button->setIcon(create_chrome_icon(ChromeIcon::Feedback, Theme::chrome_palette(*this), activity, TOOLBAR_ICON_SIZE));update_window_control_icons();}@@ -1357,6 +1448,54 @@ void WindowToolbar::update_downloads_popover()position_downloads_popover();}+void WindowToolbar::update_feedback_button()+{+ if (m_feedback_button)+ m_feedback_button->set_crash_reports_waiting(WebView::CrashReportStore::the().has_pending_reports());+}++void WindowToolbar::show_feedback_popover()+{+ if (!m_feedback_popover) {+ m_feedback_popover = new FeedbackPopover(this);+ m_feedback_popover->on_visibility_change = [this](bool visible) {+ m_feedback_button->setChecked(visible);+ };+ m_feedback_popover->on_report_site = [this] {+ if (m_tab)+ m_tab->view().report_website_issue();+ };+ m_feedback_popover->on_report_bug = [this] {+ browser_window().new_tab_from_url(URL::Parser::basic_parse(REPORT_BUG_URL).release_value(), Web::HTML::ActivateTab::Yes, BrowserWindow::TabLocation::after_current_tab());+ };+ m_feedback_popover->on_review_crash_reports = [] {+ auto names = WebView::CrashReportStore::the().pending_report_names();+ if (!names.is_error() && !names.value().is_empty())+ Application::the().review_crash_report(names.value().first());+ Application::the().update_feedback_buttons();+ };+ }++ QString reportable_host;+ if (m_tab && m_tab->view().can_report_website_issue()) {+ if (m_tab->url().host().has_value())+ reportable_host = qstring_from_ak_string(m_tab->url().serialized_host());+ }+ auto names = WebView::CrashReportStore::the().pending_report_names();+ auto crash_report_count = names.is_error() ? 0 : names.value().size();+ m_feedback_button->set_crash_reports_waiting(crash_report_count > 0);++ m_feedback_popover->update_chrome_style(palette());+ m_feedback_popover->set_reportable_host(reportable_host);+ m_feedback_popover->set_crash_report_count(crash_report_count);+ m_feedback_popover->card().layout()->activate();+ m_feedback_popover->adjustSize();+ move_popover_below(*m_feedback_popover, *m_feedback_button, PopoverAlignment::Trailing);+ m_feedback_popover->show();+ move_popover_below(*m_feedback_popover, *m_feedback_button, PopoverAlignment::Trailing);+ m_feedback_popover->raise();+}+// The downloads hang from the downloads button. Without any, the downloads page opens instead.void WindowToolbar::show_downloads_popover(){diff --git a/UI/Qt/WindowToolbar.h b/UI/Qt/WindowToolbar.hindex d3c968b4cbc..068297d912a 100644--- a/UI/Qt/WindowToolbar.h+++ b/UI/Qt/WindowToolbar.h@@ -24,6 +24,8 @@ namespace Ladybird {class BrowserWindow;class DownloadsButton;class DownloadsPopover;+class FeedbackButton;+class FeedbackPopover;class LocationEdit;class PerformanceMonitorWidget;class ReloadButton;@@ -60,6 +62,7 @@ public:void show_downloads_popover();void update_downloads_button();+ void update_feedback_button();private:virtual bool event(QEvent*) override;@@ -79,6 +82,7 @@ private:void update_chrome_style();void update_downloads_popover();void position_downloads_popover();+ void show_feedback_popover();WebView::IsPrivate m_is_private { WebView::IsPrivate::No };QPointer<Tab> m_tab;@@ -109,6 +113,9 @@ private:QPointer<DownloadsPopover> m_downloads_popover;size_t m_completed_download_count { 0 };+ FeedbackButton* m_feedback_button { nullptr };+ QPointer<FeedbackPopover> m_feedback_popover;+bool m_is_updating_chrome_style { false };};