QRectF UBGraphicsCompass::closeButtonRect() const
{
    QPixmap closePixmap(":/images/closeTool.svg");

    QSizeF closeRectSize(
        closePixmap.width() * mAntiScaleRatio,
        closePixmap.height() * mAntiScaleRatio);

    QPointF closeRectTopLeft(
        sNeedleLength + sNeedleBaseLength + 4,
        (rect().height() - closeRectSize.height()) / 2);

    QRectF closeRect(closeRectTopLeft, closeRectSize);
    closeRect.translate(rect().topLeft());

    return closeRect;
}
QRectF UBGraphicsRuler::closeButtonRect() const
{
    QPixmap closePixmap(":/images/closeTool.svg");

    QSizeF closeRectSize(
        closePixmap.width() * mAntiScaleRatio,
        closePixmap.height() * mAntiScaleRatio);

    QPointF closeRectCenter(
        rect().left() + sLeftEdgeMargin + sPixelsPerMillimeter * 5,
        rect().center().y());

    QPointF closeRectTopLeft(
        closeRectCenter.x() - closeRectSize.width() / 2,
        closeRectCenter.y() - closeRectSize.height() / 2);

    return QRectF(closeRectTopLeft, closeRectSize);
}
Exemple #3
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	QWidget win;

	QVBoxLayout* mainLayout = new QVBoxLayout(&win);

	// button
	QPushButton* closeButton = new QPushButton("Close", &win);

	QPixmap closePixmap(":/icon-close.png");
	QIcon closeIcon(closePixmap);
	closeButton->setIcon(closeIcon);
	closeButton->setIconSize(QSize(64, 64));
	mainLayout->addWidget(closeButton, 1, Qt::AlignCenter);

	QObject::connect(closeButton, SIGNAL(clicked()), &win, SLOT(close()));

	win.resize(200, 100);
	win.show();

	return a.exec();
}
const QPixmap* QWSDefaultDecoration::pixmapFor(const QWidget* w, QWSDecoration::Region type, bool on, int& xoff, int& /*yoff*/)
{
#ifndef QT_NO_IMAGEIO_XPM

    static const char** staticMenuPixmapXPM=0;
    static const char** staticClosePixmapXPM=0;
    static const char** staticMinimizePixmapXPM=0;
    static const char** staticMaximizePixmapXPM=0;
    static const char** staticNormalizePixmapXPM=0;

    const char** xpm;

    // Why don't we just use/extend the enum type...

    if ( staticMenuPixmapXPM != (xpm=menuPixmap()) ) {
	staticMenuPixmapXPM = xpm;
	staticMenuPixmap = new QPixmap(xpm);
    }
    if ( staticClosePixmapXPM != (xpm=closePixmap()) ) {
	staticClosePixmapXPM = xpm;
	staticClosePixmap = new QPixmap(xpm);
    }
    if ( staticMinimizePixmapXPM != (xpm=minimizePixmap()) ) {
	staticMinimizePixmapXPM = xpm;
	staticMinimizePixmap = new QPixmap(xpm);
    }
    if ( staticMaximizePixmapXPM != (xpm=maximizePixmap()) ) {
	staticMaximizePixmapXPM = xpm;
	staticMaximizePixmap = new QPixmap(xpm);
    }
    if ( staticNormalizePixmapXPM != (xpm=normalizePixmap()) ) {
	staticNormalizePixmapXPM = xpm;
	staticNormalizePixmap = new QPixmap(xpm);
    }

    const QPixmap *pm = 0;

    switch (type) {
	case Menu:
	    pm = w->icon();
	    if ( !pm ) {
		xoff = 1;
		pm = staticMenuPixmap;
	    }
	    break;
	case Close:
	    pm = staticClosePixmap;
	    break;
	case Maximize:
	    if (on)
		pm = staticNormalizePixmap;
	    else
		pm = staticMaximizePixmap;
	    break;
	case Minimize:
	    pm = staticMinimizePixmap;
	    break;
	default:
	    break;
    }
    return pm;
#else
    return 0;
#endif
}