2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2009-2022 Mnemosyne LLC.
|
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2014-12-18 01:30:50 +00:00
|
|
|
|
2015-06-28 14:18:06 +00:00
|
|
|
#include <QStyle>
|
2014-12-18 01:30:50 +00:00
|
|
|
#include <QStyleOption>
|
|
|
|
#include <QStyleOptionToolButton>
|
|
|
|
#include <QStylePainter>
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "IconToolButton.h"
|
2014-12-18 01:30:50 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
IconToolButton::IconToolButton(QWidget* parent)
|
|
|
|
: QToolButton(parent)
|
2014-12-18 01:30:50 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
QSize IconToolButton::sizeHint() const
|
2015-06-28 14:18:06 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
QStyleOptionToolButton option;
|
|
|
|
initStyleOption(&option);
|
|
|
|
option.features = QStyleOptionToolButton::None;
|
|
|
|
option.toolButtonStyle = Qt::ToolButtonIconOnly;
|
2017-04-20 16:02:19 +00:00
|
|
|
QSize const size = style()->sizeFromContents(QStyle::CT_ToolButton, &option, iconSize(), this);
|
2015-06-28 14:18:06 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
return size.expandedTo(iconSize() + QSize(8, 8));
|
2015-06-28 14:18:06 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void IconToolButton::paintEvent(QPaintEvent* /*event*/)
|
2014-12-18 01:30:50 +00:00
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
QStylePainter painter(this);
|
|
|
|
QStyleOptionToolButton option;
|
|
|
|
initStyleOption(&option);
|
|
|
|
option.features = QStyleOptionToolButton::None;
|
|
|
|
option.toolButtonStyle = Qt::ToolButtonIconOnly;
|
|
|
|
painter.drawComplexControl(QStyle::CC_ToolButton, option);
|
2014-12-18 01:30:50 +00:00
|
|
|
}
|