1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

[BookmarksToolbar] Don't hardcode height of buttons

Also don't "hide" (=resize only to layout spacing * 2) toolbar
when there is no bookmark in it.
This commit is contained in:
nowrep 2014-02-12 11:42:01 +01:00
parent 9eb36830b2
commit 801284eda0
3 changed files with 14 additions and 8 deletions

View File

@ -35,14 +35,17 @@ BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
, m_clickedBookmark(0)
{
setObjectName("bookmarksbar");
setContextMenuPolicy(Qt::CustomContextMenu);
setAcceptDrops(true);
setContextMenuPolicy(Qt::CustomContextMenu);
m_layout = new QHBoxLayout(this);
m_layout->setMargin(1);
m_layout->setSpacing(0);
setLayout(m_layout);
// Set some sane value, will be updated to correct value on first added button
setMinimumHeight(25);
m_updateTimer = new QTimer(this);
m_updateTimer->setInterval(300);
m_updateTimer->setSingleShot(true);
@ -162,6 +165,8 @@ void BookmarksToolbar::addItem(BookmarkItem* item)
button->setMainWindow(m_window);
button->setShowOnlyIcon(m_bookmarks->showOnlyIconsInToolbar());
m_layout->addWidget(button);
setFixedHeight(m_layout->spacing() * 2 + button->preferredHeight());
}
BookmarksToolbarButton* BookmarksToolbar::buttonAt(const QPoint &pos)

View File

@ -78,9 +78,7 @@ QSize BookmarksToolbarButton::sizeHint() const
}
}
QSize s = QPushButton::sizeHint();
s.setWidth(qMin(width, MAX_WIDTH));
return s;
return QSize(qMin(width, MAX_WIDTH), preferredHeight());
}
QSize BookmarksToolbarButton::minimumSizeHint() const
@ -94,9 +92,12 @@ QSize BookmarksToolbarButton::minimumSizeHint() const
width += PADDING + 8;
}
QSize s = QPushButton::minimumSizeHint();
s.setWidth(width);
return s;
return QSize(width, preferredHeight());
}
int BookmarksToolbarButton::preferredHeight() const
{
return fontMetrics().height() + PADDING * 2;
}
void BookmarksToolbarButton::createMenu()
@ -196,7 +197,6 @@ void BookmarksToolbarButton::init()
setFocusPolicy(Qt::NoFocus);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
setIconSize(QSize(16, 16));
setMaximumHeight(24);
setToolTip(createTooltip());
if (m_bookmark->isFolder()) {

View File

@ -41,6 +41,7 @@ public:
QSize sizeHint() const;
QSize minimumSizeHint() const;
int preferredHeight() const;
private slots:
void createMenu();