2014-12-18 01:30:50 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2009-2015 Mnemosyne LLC
|
2014-12-18 01:30:50 +00:00
|
|
|
*
|
2014-12-21 23:49:39 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-12-18 01:30:50 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2017-04-19 12:04:45 +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
|
|
|
}
|