コード例 #1
0
ファイル: titlebar.cpp プロジェクト: CheeryLee/QShaderEditor
/*!
    \fn TitleBar::draw_close_btn()
 */
void TitleBar::draw_close_btn()
{
    //draw close button
	int ih1 = 13;
	int iw1 = 30;
        QPainter painter;
        QPen pen;
	QLinearGradient gradient1(0, ih1, 0, 0);
	gradient1.setColorAt(0, QColor::fromRgb(131, 3, 3));
	rightPm = QPixmap(iw1, ih1);
	painter.begin(&rightPm);
	
	if(bpress)
	{
		gradient1.setColorAt(1, QColor::fromRgb(237, 26, 86));
		painter.fillRect(0, 0, iw1, ih1, QBrush(gradient1));
		//draw frame close button
		painter.setPen(QColor(0,0,0));
		painter.drawLine(0,0,iw1,0);
		painter.drawLine(0,ih1,0,0);
                painter.drawLine(0, ih1-1, iw1,ih1-1);
                pen.setColor(QColor(83,31,31));

	}
	else
	{
		
	    gradient1.setColorAt(1, QColor::fromRgb(243, 115, 115));
	    painter.fillRect(0, 0, iw1, ih1, QBrush(gradient1));
		//draw frame close button
	    painter.setPen(QColor(66,67,70));
	    painter.drawLine(0,0,iw1,0);
		painter.setPen(QColor(71,71,74));
	    painter.drawLine(0,ih1,0,0);
		painter.setPen(QColor(88,88,90));
            painter.drawLine(0, ih1-1, iw1,ih1-1);
            pen.setColor(QColor(255,255,255));
	}
		
	//draw line close button
	painter.setPen(pen);
	QVector<QLine> lines;
	lines << QLine(iw1-16,ih1-10,iw1-11,ih1-5) << QLine(iw1-11,ih1-10,iw1-16,ih1-5);
	painter.drawLines(lines);
		
	update();
	painter.end();
}
コード例 #2
0
ファイル: paintwidget.cpp プロジェクト: Hasimir/PySide
void PaintWidget::paintEvent(QPaintEvent *event)
{
    QLinearGradient gradient1(rect().topLeft(), rect().bottomRight());
    gradient1.setColorAt(0, QColor("#ffffcc"));
    gradient1.setColorAt(1, QColor("#ccccff"));

    QRectF ellipseRect(width()*0.25, height()*0.25, width()*0.5, height()*0.5);
    QLinearGradient gradient2(ellipseRect.topLeft(), ellipseRect.bottomRight());
    gradient2.setColorAt(0, QColor("#ccccff"));
    gradient2.setColorAt(1, QColor("#ffffcc"));

    QPainter painter;
    painter.begin(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.fillRect(rect(), QBrush(gradient1));
    painter.setBrush(QBrush(gradient2));
    painter.drawEllipse(ellipseRect);
    painter.end();
}
コード例 #3
0
SocioTwitterwidget::SocioTwitterwidget(const QRectF &rect, QWidget *widget):
    DesktopWidget(rect, widget)
{


    if (SocioTwitterwidget->objectName().isEmpty())
        SocioTwitterwidget->setObjectName(QString::fromUtf8("SocioTwitterClass"));
    SocioTwitterwidget->resize(272, 415);
    QSizePolicy sizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(SocioTwitterClass->sizePolicy().hasHeightForWidth());
    SocioTwitterwidget->setSizePolicy(sizePolicy);
    SocioTwitterwidget->setCursor(QCursor(Qt::ArrowCursor));
    SocioTwitterwidget->setAcceptDrops(true);
    SocioTwitterwidget->setWindowTitle(QString::fromUtf8("SocioTwitter"));
    SocioTwitterwidget->setAutoFillBackground(false);
    SocioTwitterwidget->setStyleSheet(QString::fromUtf8("QWidget{   \n"
                                      "background:transparent;\n"
                                      "transparent-color:black;\n"
                                      "background-color:qlineargradient(spread:pad, x1:0.604, y1:0.409, x2:0.193, y2:0.938, stop:0.233503 rgba(1, 0, 		0,255))\n"
                                      "\n"
                                      "\n"
                                      "  }"));

    lineEdit = new QLineEdit(SocioTwitterwidget);
    lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
    lineEdit->setGeometry(QRect(0, 370, 271, 41));
    QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Fixed);
    sizePolicy1.setHorizontalStretch(0);
    sizePolicy1.setVerticalStretch(0);
    sizePolicy1.setHeightForWidth(lineEdit->sizePolicy().hasHeightForWidth());

    lineEdit->setSizePolicy(sizePolicy1);
    lineEdit->setFocusPolicy(Qt::StrongFocus);
    lineEdit->setStyleSheet(QString::fromUtf8("QLineEdit {     \n"
                            " border: 1px solid gray;     \n"
                            " border-radius: 5px;     \n"
                            " padding: 0 8px;     \n"
                            " background: beige;     \n"
                            " selection-background-color: darkgray;\n"
                            "  }"));

    scrollArea = new QScrollArea(SocioTwitterwidget);
    scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
    scrollArea->setGeometry(QRect(0, 40, 271, 331));

    QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);

    sizePolicy2.setHorizontalStretch(10);
    sizePolicy2.setVerticalStretch(0);
    sizePolicy2.setHeightForWidth(scrollArea->sizePolicy().hasHeightForWidth());

    scrollArea->setSizePolicy(sizePolicy2);
    scrollArea->setAcceptDrops(true);
    scrollArea->setAutoFillBackground(true);
    scrollArea->setFrameShape(QFrame::NoFrame);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setWidgetResizable(true);
    scrollArea->setAlignment(Qt::AlignHCenter | Qt::AlignTop);

    scrollAreaWidgetContents = new QWidget();
    scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
    scrollAreaWidgetContents->setGeometry(QRect(0, 0, 267, 327));

    graphicsView = new QGraphicsView(scrollAreaWidgetContents);
    graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
    graphicsView->setGeometry(QRect(10, 20, 61, 51));
    graphicsView->setFrameShadow(QFrame::Raised);
    graphicsView->setLineWidth(1);
    graphicsView->setMidLineWidth(0);
    graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    graphicsView_2 = new QGraphicsView(scrollAreaWidgetContents);
    graphicsView_2->setObjectName(QString::fromUtf8("graphicsView_2"));
    graphicsView_2->setGeometry(QRect(10, 80, 61, 51));
    graphicsView_2->setFrameShape(QFrame::StyledPanel);

    graphicsView_3 = new QGraphicsView(scrollAreaWidgetContents);
    graphicsView_3->setObjectName(QString::fromUtf8("graphicsView_3"));
    graphicsView_3->setGeometry(QRect(10, 140, 61, 51));
    graphicsView_3->setFrameShape(QFrame::NoFrame);

    graphicsView_4 = new QGraphicsView(scrollAreaWidgetContents);
    graphicsView_4->setObjectName(QString::fromUtf8("graphicsView_4"));
    graphicsView_4->setGeometry(QRect(10, 200, 61, 51));
    graphicsView_4->setFrameShape(QFrame::StyledPanel);

    graphicsView_5 = new QGraphicsView(scrollAreaWidgetContents);
    graphicsView_5->setObjectName(QString::fromUtf8("graphicsView_5"));
    graphicsView_5->setGeometry(QRect(10, 260, 61, 51));
    graphicsView_5->setFrameShape(QFrame::NoFrame);

    textBrowser = new QTextBrowser(scrollAreaWidgetContents);
    textBrowser->setObjectName(QString::fromUtf8("textBrowser"));
    textBrowser->setGeometry(QRect(80, 20, 181, 51));
    textBrowser->setFrameShape(QFrame::Box);

    textBrowser_2 = new QTextBrowser(scrollAreaWidgetContents);
    textBrowser_2->setObjectName(QString::fromUtf8("textBrowser_2"));
    textBrowser_2->setGeometry(QRect(80, 80, 181, 51));
    textBrowser_2->setFrameShape(QFrame::NoFrame);

    textBrowser_3 = new QTextBrowser(scrollAreaWidgetContents);
    textBrowser_3->setObjectName(QString::fromUtf8("textBrowser_3"));
    textBrowser_3->setGeometry(QRect(80, 140, 181, 51));
    textBrowser_3->setFrameShape(QFrame::NoFrame);

    textBrowser_4 = new QTextBrowser(scrollAreaWidgetContents);
    textBrowser_4->setObjectName(QString::fromUtf8("textBrowser_4"));
    textBrowser_4->setGeometry(QRect(80, 200, 181, 51));
    textBrowser_4->setFrameShape(QFrame::NoFrame);

    textBrowser_5 = new QTextBrowser(scrollAreaWidgetContents);
    textBrowser_5->setObjectName(QString::fromUtf8("textBrowser_5"));
    textBrowser_5->setGeometry(QRect(80, 260, 181, 51));
    textBrowser_5->setFrameShape(QFrame::NoFrame);

    scrollArea->setWidget(scrollAreaWidgetContents);

    pushButton = new QPushButton(SocioTwitterClass);
    pushButton->setObjectName(QString::fromUtf8("pushButton"));
    pushButton->setGeometry(QRect(10, 10, 71, 41));

    QFont font;
    font.setBold(true);
    font.setWeight(75);

    pushButton->setFont(font);
    pushButton->setCursor(QCursor(Qt::PointingHandCursor));
    pushButton->setMouseTracking(false);
    pushButton->setFocusPolicy(Qt::StrongFocus);

    OPtions = new QPushButton(SocioTwitterClass);
    OPtions->setObjectName(QString::fromUtf8("OPtions"));
    OPtions->setEnabled(true);
    OPtions->setGeometry(QRect(80, 10, 71, 41));

    QPalette palette;
    QLinearGradient gradient(0.604, 0.409, 0.193, 0.938);

    gradient.setSpread(QGradient::PadSpread);
    gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
    gradient.setColorAt(0.233503, QColor(1, 0, 0, 255));
    QBrush brush(gradient);

    palette.setBrush(QPalette::Active, QPalette::Button, brush);
    QBrush brush1(QColor(169, 169, 169, 255));
    brush1.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Active, QPalette::Highlight, brush1);
    QLinearGradient gradient1(0.604, 0.409, 0.193, 0.938);
    gradient1.setSpread(QGradient::PadSpread);
    gradient1.setCoordinateMode(QGradient::ObjectBoundingMode);
    gradient1.setColorAt(0.233503, QColor(1, 0, 0, 255));

    QBrush brush2(gradient1);
    palette.setBrush(QPalette::Inactive, QPalette::Button, brush2);
    palette.setBrush(QPalette::Inactive, QPalette::Highlight, brush1);
    QLinearGradient gradient2(0.604, 0.409, 0.193, 0.938);

    gradient2.setSpread(QGradient::PadSpread);
    gradient2.setCoordinateMode(QGradient::ObjectBoundingMode);
    gradient2.setColorAt(0.233503, QColor(1, 0, 0, 255));

    QBrush brush3(gradient2);
    palette.setBrush(QPalette::Disabled, QPalette::Button, brush3);
    palette.setBrush(QPalette::Disabled, QPalette::Highlight, brush1);
    OPtions->setPalette(palette);

    QFont font1;
    font1.setFamily(QString::fromUtf8("Sans Serif"));
    font1.setPointSize(10);
    font1.setBold(true);
    font1.setWeight(75);

    OPtions->setFont(font1);
    OPtions->setCursor(QCursor(Qt::PointingHandCursor));
    OPtions->setAutoDefault(false);
    OPtions->setDefault(false);
    OPtions->setFlat(false);

    retranslateUi(SocioTwitterClass);

    QMetaObject::connectSlotsByName(SocioTwitterClass);
}
コード例 #4
0
void UBGraphicsTriangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{

    painter->setPen(Qt::NoPen);

    QPolygonF polygon;

    QLinearGradient gradient1(QPointF(A1.x(), 0), QPointF(A2.x(), 0));
    gradient1.setColorAt(0, edgeFillColor());
    gradient1.setColorAt(1, middleFillColor());
    painter->setBrush(gradient1);
    polygon << A1 << A2 << B2 << B1;
    painter->drawPolygon(polygon);
    polygon.clear();

    QLinearGradient gradient2(QPointF(0, B1.y()), QPointF(0, B2.y()));
    gradient2.setColorAt(0, edgeFillColor());
    gradient2.setColorAt(1, middleFillColor());
    painter->setBrush(gradient2);
    polygon << B1 << B2 << C2 << C1;
    painter->drawPolygon(polygon);
    polygon.clear();

    QLinearGradient gradient3(CC, C2);
    gradient3.setColorAt(0, edgeFillColor());
    gradient3.setColorAt(1, middleFillColor());
    painter->setBrush(gradient3);
    polygon << C1 << C2 << A2 << A1;
    painter->drawPolygon(polygon);
    polygon.clear();


    painter->setBrush(Qt::NoBrush);
    painter->setPen(drawColor());

    polygon << A1 << B1 << C1;
    painter->drawPolygon(polygon);
    polygon.clear();

    polygon << A2 << B2 << C2;
    painter->drawPolygon(polygon);

    paintGraduations(painter);

    mAntiScaleRatio = 1 / (UBApplication::boardController->systemScaleFactor() * UBApplication::boardController->currentZoom());
    QTransform antiScaleTransform;
    antiScaleTransform.scale(mAntiScaleRatio, mAntiScaleRatio);

    mCloseSvgItem->setTransform(antiScaleTransform);
    mHFlipSvgItem->setTransform(antiScaleTransform);
    mVFlipSvgItem->setTransform(antiScaleTransform);
    mRotateSvgItem->setTransform(antiScaleTransform);

    mCloseSvgItem->setPos(closeButtonRect().topLeft());
    mHFlipSvgItem->setPos(hFlipRect().topLeft());
    mVFlipSvgItem->setPos(vFlipRect().topLeft());
    mRotateSvgItem->setPos(rotateRect().topLeft());

    if (mShowButtons || mResizing1 || mResizing2)
    {
        painter->setBrush(QColor(0, 0, 0));
        if (mShowButtons || mResizing1)
            painter->drawPolygon(resize1Polygon());
        if (mShowButtons || mResizing2)
            painter->drawPolygon(resize2Polygon());
    }
}
コード例 #5
0
ファイル: overviewwidget.cpp プロジェクト: bsmr-opengl/voreen
OverviewWidget::OverviewWidget(QWidget* parent, NetworkEvaluator* networkEval)
    : QWidget(parent)
    , duration_(1200)
    , zoom_(1)
    , viewportWidth_(500)
    , scrollBarPosition_(0)
    , canvasRenderer_(0)
    , networkEvaluator_(networkEval)
    , currentFrame_(0)
    , fps_(30)
    , autoPreview_(false)
{
    canvasRenderer_ = 0;
    previews_.clear();
    QHBoxLayout* mainLayout = new QHBoxLayout(this);

    mainLayout->setMargin(1);
    mainLayout->setSpacing(1);
    setFixedHeight(110);

    overviewScene_ = new QGraphicsScene(this);

    overviewView_ = new OverviewView(overviewScene_, this);

    highlightBar_ = new QGraphicsRectItem();
    overviewView_->setBar(highlightBar_);
    highlightBar_->setZValue(2);
    highlightBar_->setPen(QPen(Qt::DotLine));
    QLinearGradient gradient1(0,0,0, 40 );
    gradient1.setSpread(QGradient::ReflectSpread);
    gradient1.setColorAt(0.0, QColor(20, 100 ,100, 30));
    gradient1.setColorAt(1.0, QColor(80, 100 ,100, 30));
    QBrush brush(gradient1);
    highlightBar_->setBrush(gradient1);
    overviewScene_->addItem(highlightBar_);
    highlight_ = new QGraphicsRectItem();
    highlight_->setPen(QPen(Qt::DotLine));
    QLinearGradient gradient(0,0,0, 40 );
    gradient.setSpread(QGradient::ReflectSpread);
    gradient.setColorAt(0.0, QColor(120, 100 ,100, 30));
    gradient.setColorAt(1.0, QColor(100, 100 ,100, 30));
    highlight_->setBrush(gradient);
    overviewScene_->addItem(highlight_);

    overviewView_->setStyleSheet("background:transparent");
    connect(overviewView_, SIGNAL(currentFrameChanged(int)), this, SIGNAL(currentFrameChanged(int)));
    connect(overviewView_, SIGNAL(contextMenuRequest(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
    connect(overviewView_, SIGNAL(barMovement(int)), this, SIGNAL(barMovement(int)));
    connect(this, SIGNAL(offsetCorrection(int)), overviewView_, SLOT(offsetCorrection(int)));

    overviewView_->setGeometry(QRect(0, 0, duration_, 50));
    overviewView_->setSceneRect(QRect(0, 0, duration_, 50));
    overviewView_->setCurrentFrame(0);

    mainLayout->addWidget(overviewView_);
    QLabel* nameLabel = new QLabel(this);
    nameLabel->lower();
    nameLabel->move(8, 45);
    nameLabel->setText(QString::fromStdString("Overview"));

    if (canvasRenderer_) {
        const std::vector<Port*> port = canvasRenderer_->getInports();
        if (port.size() == 1) {
            if(dynamic_cast<RenderPort*>(port.at(0)) != 0)
                renderPort_ = dynamic_cast<RenderPort*>(port.at(0));
        }
    }
    setStandardRenderport();
}