From 5adddb9880ae0d5997f5d1ce5530ff9c7f54021a Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 22 Mar 2018 20:04:40 +0100 Subject: [PATCH] BookmarksToolbar: Fix setting minimum height of toolbar --- src/lib/bookmarks/bookmarkstoolbar.cpp | 15 +++++++-------- src/lib/bookmarks/bookmarkstoolbar.h | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/lib/bookmarks/bookmarkstoolbar.cpp b/src/lib/bookmarks/bookmarkstoolbar.cpp index 81e5e120a..d8fc05779 100644 --- a/src/lib/bookmarks/bookmarkstoolbar.cpp +++ b/src/lib/bookmarks/bookmarkstoolbar.cpp @@ -45,9 +45,6 @@ BookmarksToolbar::BookmarksToolbar(BrowserWindow* window, QWidget* parent) m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this)); setLayout(m_layout); - // Set some sane value - setMinimumHeight(20); - m_updateTimer = new QTimer(this); m_updateTimer->setInterval(300); m_updateTimer->setSingleShot(true); @@ -213,11 +210,6 @@ void BookmarksToolbar::addItem(BookmarkItem* item) button->setShowOnlyIcon(m_bookmarks->showOnlyIconsInToolbar()); button->setShowOnlyText(m_bookmarks->showOnlyTextInToolbar()); m_layout->addWidget(button); - - if (!m_fixedMinHeight) { - m_fixedMinHeight = true; - setMinimumHeight(minimumSizeHint().height()); - } } BookmarksToolbarButton* BookmarksToolbar::buttonAt(const QPoint &pos) @@ -225,6 +217,13 @@ BookmarksToolbarButton* BookmarksToolbar::buttonAt(const QPoint &pos) return qobject_cast(QApplication::widgetAt(mapToGlobal(pos))); } +QSize BookmarksToolbar::minimumSizeHint() const +{ + QSize size = QWidget::minimumSizeHint(); + size.setHeight(qMax(20, size.height())); + return size; +} + void BookmarksToolbar::dropEvent(QDropEvent* e) { const QMimeData* mime = e->mimeData(); diff --git a/src/lib/bookmarks/bookmarkstoolbar.h b/src/lib/bookmarks/bookmarkstoolbar.h index 0381946b3..bb979c4dc 100644 --- a/src/lib/bookmarks/bookmarkstoolbar.h +++ b/src/lib/bookmarks/bookmarkstoolbar.h @@ -55,6 +55,8 @@ private: void addItem(BookmarkItem* item); BookmarksToolbarButton* buttonAt(const QPoint &pos); + QSize minimumSizeHint() const override; + void dropEvent(QDropEvent* e); void dragEnterEvent(QDragEnterEvent* e); @@ -65,8 +67,6 @@ private: QTimer* m_updateTimer; QAction* m_actShowOnlyIcons = nullptr; QAction* m_actShowOnlyText = nullptr; - - bool m_fixedMinHeight = false; }; #endif // BOOKMARKSTOOLBAR_H