1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-14 02:52:12 +01:00

BookmarksToolbar: Fix setting minimum height of toolbar

This commit is contained in:
David Rosca 2018-03-22 20:04:40 +01:00
parent fbb48f28fd
commit 5adddb9880
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
2 changed files with 9 additions and 10 deletions

View File

@ -45,9 +45,6 @@ BookmarksToolbar::BookmarksToolbar(BrowserWindow* window, QWidget* parent)
m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this)); m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this));
setLayout(m_layout); setLayout(m_layout);
// Set some sane value
setMinimumHeight(20);
m_updateTimer = new QTimer(this); m_updateTimer = new QTimer(this);
m_updateTimer->setInterval(300); m_updateTimer->setInterval(300);
m_updateTimer->setSingleShot(true); m_updateTimer->setSingleShot(true);
@ -213,11 +210,6 @@ void BookmarksToolbar::addItem(BookmarkItem* item)
button->setShowOnlyIcon(m_bookmarks->showOnlyIconsInToolbar()); button->setShowOnlyIcon(m_bookmarks->showOnlyIconsInToolbar());
button->setShowOnlyText(m_bookmarks->showOnlyTextInToolbar()); button->setShowOnlyText(m_bookmarks->showOnlyTextInToolbar());
m_layout->addWidget(button); m_layout->addWidget(button);
if (!m_fixedMinHeight) {
m_fixedMinHeight = true;
setMinimumHeight(minimumSizeHint().height());
}
} }
BookmarksToolbarButton* BookmarksToolbar::buttonAt(const QPoint &pos) BookmarksToolbarButton* BookmarksToolbar::buttonAt(const QPoint &pos)
@ -225,6 +217,13 @@ BookmarksToolbarButton* BookmarksToolbar::buttonAt(const QPoint &pos)
return qobject_cast<BookmarksToolbarButton*>(QApplication::widgetAt(mapToGlobal(pos))); return qobject_cast<BookmarksToolbarButton*>(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) void BookmarksToolbar::dropEvent(QDropEvent* e)
{ {
const QMimeData* mime = e->mimeData(); const QMimeData* mime = e->mimeData();

View File

@ -55,6 +55,8 @@ private:
void addItem(BookmarkItem* item); void addItem(BookmarkItem* item);
BookmarksToolbarButton* buttonAt(const QPoint &pos); BookmarksToolbarButton* buttonAt(const QPoint &pos);
QSize minimumSizeHint() const override;
void dropEvent(QDropEvent* e); void dropEvent(QDropEvent* e);
void dragEnterEvent(QDragEnterEvent* e); void dragEnterEvent(QDragEnterEvent* e);
@ -65,8 +67,6 @@ private:
QTimer* m_updateTimer; QTimer* m_updateTimer;
QAction* m_actShowOnlyIcons = nullptr; QAction* m_actShowOnlyIcons = nullptr;
QAction* m_actShowOnlyText = nullptr; QAction* m_actShowOnlyText = nullptr;
bool m_fixedMinHeight = false;
}; };
#endif // BOOKMARKSTOOLBAR_H #endif // BOOKMARKSTOOLBAR_H