X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Frefinesearchbutton.cpp;h=1091e56d9edeed41a7e1b6c74094202252ab869d;hb=HEAD;hp=4917a96ae7b59505e58195142eb30b27920b58b8;hpb=42994a9540d8eeee1eebf4513a92f942f7040f10;p=minitube diff --git a/src/refinesearchbutton.cpp b/src/refinesearchbutton.cpp index 4917a96..1091e56 100644 --- a/src/refinesearchbutton.cpp +++ b/src/refinesearchbutton.cpp @@ -1,39 +1,50 @@ -#include "refinesearchbutton.h" +/* $BEGIN_LICENSE + +This file is part of Minitube. +Copyright 2009, Flavio Tordini + +Minitube is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Minitube is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. -static const int refineButtonSize = 48; +You should have received a copy of the GNU General Public License +along with Minitube. If not, see . -RefineSearchButton::RefineSearchButton(QWidget *parent) : - QPushButton(parent) { +$END_LICENSE */ +#include "refinesearchbutton.h" +#include "iconutils.h" + +RefineSearchButton::RefineSearchButton(QWidget *parent) : QPushButton(parent) { hovered = false; + const int refineButtonSize = 48; setMinimumSize(refineButtonSize, refineButtonSize); setMaximumSize(refineButtonSize, refineButtonSize); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setStyleSheet( - "background: red url(:/images/refine-search.png) no-repeat center;" - "border: 0;" - ); } -void RefineSearchButton::paintBackground() const { - -} +void RefineSearchButton::paintEvent(QPaintEvent *) { + QColor backgroundColor = palette().windowText().color(); + backgroundColor.setAlpha(hovered ? 192 : 170); -void RefineSearchButton::paintEvent(QPaintEvent *event) { - // QPushButton::paintEvent(event); QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing, true); - painter.setBrush(QColor(0,0,0, hovered ? 192 : 170)); - QPen pen(Qt::white); - pen.setWidth(2); - painter.setPen(pen); - painter.drawEllipse(QPoint(width(), height()), width()-2, height()-2); - - QPixmap icon = QPixmap(":/images/refine-search.png"); - painter.drawPixmap(width() - icon.width() - 6, height() - icon.height() - 6, - icon.width(), icon.height(), - icon); + painter.setPen(Qt::NoPen); + painter.setBrush(backgroundColor); + painter.drawEllipse(QPoint(width(), height()), width() - 2, height() - 2); + + QPixmap pixmap = + IconUtils::iconPixmap("refine-search", 24, backgroundColor, devicePixelRatioF()); + int pw = pixmap.width() / pixmap.devicePixelRatio(); + int ph = pixmap.height() / pixmap.devicePixelRatio(); + painter.drawPixmap(width() - pw - 6, height() - ph - 6, pw, ph, pixmap); } void RefineSearchButton::enterEvent(QEvent *) {