source: trunk/qt/IconToolButton.cc @ 14547

Last change on this file since 14547 was 14547, checked in by mikedld, 6 years ago

Some look-and-feel improvements for Mac and GTK+ styles (Qt client)

  • Property svn:keywords set to Date Rev Author Id
File size: 1.0 KB
Line 
1/*
2 * This file Copyright (C) 2009-2015 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: IconToolButton.cc 14547 2015-06-28 14:18:06Z mikedld $
8 */
9
10#include <QStyle>
11#include <QStyleOption>
12#include <QStyleOptionToolButton>
13#include <QStylePainter>
14
15#include "IconToolButton.h"
16
17IconToolButton::IconToolButton (QWidget * parent):
18  QToolButton (parent)
19{
20}
21
22QSize
23IconToolButton::sizeHint () const
24{
25  QStyleOptionToolButton option;
26  initStyleOption (&option);
27  option.features = QStyleOptionToolButton::None;
28  option.toolButtonStyle = Qt::ToolButtonIconOnly;
29  const QSize size = style ()->sizeFromContents (QStyle::CT_ToolButton, &option, iconSize (), this);
30
31  return size.expandedTo (iconSize () + QSize (8, 8));
32}
33
34void IconToolButton::paintEvent (QPaintEvent * /*event*/)
35{
36  QStylePainter painter(this);
37  QStyleOptionToolButton option;
38  initStyleOption (&option);
39  option.features = QStyleOptionToolButton::None;
40  option.toolButtonStyle = Qt::ToolButtonIconOnly;
41  painter.drawComplexControl(QStyle::CC_ToolButton, option);
42}
Note: See TracBrowser for help on using the repository browser.