示例#1
0
PushButton::PushButton(QGraphicsWidget *parent)
    : QGraphicsProxyWidget(parent),
      d(new PushButtonPrivate(this))
{
    d->background = new FrameSvg(this);
    d->background->setImagePath("widgets/button");
    d->background->setCacheAllRenderedFrames(true);

    d->background->setElementPrefix("normal");

    d->hoverAnimation = Animator::create(Animator::PixmapTransitionAnimation);
    d->hoverAnimation->setTargetWidget(this);

    KPushButton *native = new KPushButton;
    connect(native, SIGNAL(pressed()), this, SIGNAL(pressed()));
    connect(native, SIGNAL(pressed()), this, SLOT(pressedChanged()));
    connect(native, SIGNAL(released()), this, SIGNAL(released()));
    connect(native, SIGNAL(released()), this, SLOT(pressedChanged()));
    connect(native, SIGNAL(clicked()), this, SIGNAL(clicked()));
    connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
    setWidget(native);
    native->setAttribute(Qt::WA_NoSystemBackground);
    native->setWindowIcon(QIcon());

    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    d->focusIndicator = new FocusIndicator(this, d->background);

    d->syncBorders();
    setAcceptHoverEvents(true);

    connect(d->background, SIGNAL(repaintNeeded()), SLOT(syncBorders()));
    d->initTheming();
    d->syncFrame();
}
示例#2
0
文件: frame.cpp 项目: vasi/kdelibs
Frame::Frame(QGraphicsWidget *parent)
    : QGraphicsWidget(parent),
      d(new FramePrivate(this))
{
    d->svg = new Plasma::FrameSvg(this);
    d->svg->setImagePath("widgets/frame");
    d->svg->setElementPrefix("plain");
    d->syncBorders();

    connect(d->svg, SIGNAL(repaintNeeded()), SLOT(syncBorders()));
    d->initTheming();
}