Skip to content

Commit

Permalink
Merge pull request #10121 from brave/download-item-text-overlap-1.30.x
Browse files Browse the repository at this point in the history
Uplift 1.30.x - fixed download item filename overlap
  • Loading branch information
kjozwiak authored Sep 17, 2021
2 parents 23a00f5 + e03e0bb commit f60fa98
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
23 changes: 18 additions & 5 deletions browser/ui/views/download/brave_download_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/auto_reset.h"
#include "brave/app/vector_icons/vector_icons.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/download/download_item_mode.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
Expand Down Expand Up @@ -99,7 +100,6 @@ void BraveDownloadItemView::OnPaint(gfx::Canvas* canvas) {
DownloadItemView::OnPaint(canvas);
if (is_origin_url_visible_)
DrawOriginURL(canvas);
file_name_label_->SetVisible(!is_origin_url_visible_);
}

// download::DownloadItem::Observer overrides.
Expand Down Expand Up @@ -236,18 +236,31 @@ void BraveDownloadItemView::SetMode(download::DownloadItemMode mode) {
}
}

void BraveDownloadItemView::UpdateLabels() {
DownloadItemView::UpdateLabels();
// Update visibility to avoid artifacts to be shown from upstream
file_name_label_->SetVisible(
!is_origin_url_visible_ &&
(GetMode() == download::DownloadItemMode::kNormal));
}

void BraveDownloadItemView::SetOriginUrlVisible(bool visible) {
is_origin_url_visible_ = visible;
UpdateLabels();
}

void BraveDownloadItemView::OnMouseEntered(const ui::MouseEvent& event) {
is_origin_url_visible_ = true;
SetOriginUrlVisible(true);
}

void BraveDownloadItemView::OnMouseExited(const ui::MouseEvent& event) {
is_origin_url_visible_ = false;
SetOriginUrlVisible(false);
}

void BraveDownloadItemView::OnViewFocused(View* observed_view) {
is_origin_url_visible_ = true;
SetOriginUrlVisible(true);
}

void BraveDownloadItemView::OnViewBlurred(View* observed_view) {
is_origin_url_visible_ = false;
SetOriginUrlVisible(false);
}
3 changes: 3 additions & 0 deletions browser/ui/views/download/brave_download_item_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ class BraveDownloadItemView : public DownloadItemView {

// Overrides the accessible name construction to reflect the origin URL.
void SetMode(download::DownloadItemMode mode) override;
void UpdateLabels() override;
void OnMouseEntered(const ui::MouseEvent& event) override;
void OnMouseExited(const ui::MouseEvent& event) override;
void OnViewFocused(View* observed_view) override;
void OnViewBlurred(View* observed_view) override;

void SetOriginUrlVisible(bool visible);

// Brave download item model.
BraveDownloadItemModel brave_model_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@
protected: \
bool IsShowingWarningDialog() const;

#define UpdateLabels virtual UpdateLabels
#define SetMode virtual SetMode
#include "../../../../../../../chrome/browser/ui/views/download/download_item_view.h"
#undef SetMode
#undef UpdateLabels
#undef BRAVE_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_

#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_

0 comments on commit f60fa98

Please sign in to comment.