1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 18:18:10 +00:00
transmission/qt/triconpushbutton.cc
Jordan Lee 4b9626bb83 Licensing changes:
1. add the option the code to be used under GPLv2 or GPLv3; previously only GPLv2 was allowed

2. add the "proxy option" as described in GPLv3 so we can add future licenses without having to bulk-edit everything again :)

3. remove the awkward "exception for MIT code in Mac client" clause; it was unnecessary and confusing.
2014-01-19 01:09:44 +00:00

61 lines
1.6 KiB
C++

/*
* This file Copyright (C) 2009-2014 Mnemosyne LLC
*
* It may be used under the GNU Public License v2 or v3 licenses,
* or any future license endorsed by Mnemosyne LLC.
*
* $Id$
*/
#include <iostream>
#include <QIcon>
#include <QStyleOption>
#include <QStyleOptionButton>
#include <QStylePainter>
#include "hig.h"
#include "triconpushbutton.h"
TrIconPushButton :: TrIconPushButton (QWidget * parent):
QPushButton (parent)
{
}
TrIconPushButton :: TrIconPushButton (const QIcon& icon, QWidget * parent):
QPushButton (parent)
{
setIcon (icon);
}
QSize
TrIconPushButton :: sizeHint () const
{
QSize s = iconSize ();
s.rwidth() += HIG::PAD_SMALL*2;
return s;
}
void
TrIconPushButton :: paintEvent (QPaintEvent *)
{
QStylePainter p (this);
QStyleOptionButton opt;
initStyleOption (&opt);
QIcon::Mode mode = opt.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled;
if ((mode == QIcon::Normal) && (opt.state & QStyle::State_HasFocus))
mode = QIcon::Active;
QPixmap pixmap = opt.icon.pixmap (opt.iconSize, QIcon::Active, QIcon::On);
QRect iconRect (opt.rect.x() + HIG::PAD_SMALL,
opt.rect.y() + (opt.rect.height() - pixmap.height())/2,
pixmap.width(),
pixmap.height());
if (opt.state & (QStyle::State_On | QStyle::State_Sunken))
iconRect.translate (style()->pixelMetric (QStyle::PM_ButtonShiftHorizontal, &opt, this),
style()->pixelMetric (QStyle::PM_ButtonShiftVertical, &opt, this));
p.drawPixmap(iconRect, pixmap);
if (opt.state & QStyle::State_HasFocus)
p.drawPrimitive (QStyle::PE_FrameFocusRect, opt);
}