Ejemplo n.º 1
0
/*==================================================================*/
void ModifyStation::initModifyStation(int no)
{
	setModal(true);
	setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint 
		| Qt::WindowMinimizeButtonHint
		| Qt::WindowMaximizeButtonHint);

	//setAttribute(Qt::WA_DeleteOnClose);

	this->setAutoFillBackground(true);
	QPalette palette;
	palette.setColor(QPalette::Background, QColor(35,202,255));
	this->setPalette(palette);

	QPainterPath path;
	QRectF rect = QRectF(this->rect());
	path.addRoundRect(rect,10,10);
	QPolygon polygon= path.toFillPolygon().toPolygon();
	QRegion region(polygon);
	setMask(region);

	//当点击确定时,执行的槽函数为ok
	connect(ui.okButton, SIGNAL(clicked()), this, SLOT(ok()));

	//记录当前焦点所在采集站的编号
	index = no;

	//读取已有的配置或增加新配置
	readIni(no);
}
Ejemplo n.º 2
0
  void TOPPASOutputFileListVertex::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/)
  {
    QPen pen(pen_color_, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
    if (isSelected())
    {
      pen.setWidth(2);
      painter->setBrush(brush_color_.darker(130));
      pen.setColor(Qt::darkBlue);
    }
    else
    {
      painter->setBrush(brush_color_);
    }
    painter->setPen(pen);

    QPainterPath path;
    path.addRoundRect(-70.0, -40.0, 140.0, 80.0, 20, 20);
    painter->drawPath(path);

    pen.setColor(pen_color_);
    painter->setPen(pen);
    QString text =  QString::number(files_written_) + "/"
                   + QString::number(files_total_) + " output file" + (files_total_ == 1 ? "" : "s");
    QRectF text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
    painter->drawText(-(int)(text_boundings.width() / 2.0), (int)(text_boundings.height() / 4.0), text);

    // display file type(s)
    Map<QString, Size> suffices;
    foreach(QString fn, getFileNames())
    {
      QStringList l = QFileInfo(fn).completeSuffix().split('.');
      QString suf = ((l.size() > 1 && l[l.size() - 2].size() <= 4) ? l[l.size() - 2] + "." : QString()) + l.back(); // take up to two dots as suffix (the first only if its <=4 chars, e.g. we want ".prot.xml" or ".tar.gz", but not "stupid.filename.with.longdots.mzML")
      ++suffices[suf];
    }
Ejemplo n.º 3
0
void MenuListWidget::paintEvent(QPaintEvent *event) {
    Q_UNUSED(event);
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing, true);//启用反走样以得到平滑的边缘
    painter.setPen(QColor("#FDFDFD"));
    painter.setBrush(QColor("#FDFDFD"));

    painter.save();

    QRect bgRect = rect();
    bgRect.setWidth(rect().width());
    bgRect.setHeight(rect().height());
    painter.drawRect(bgRect);

    painter.restore();

    QPainterPath path;
    path.addRoundRect(0, 8, 185, 8+_displayCount*52, 10);
    path.moveTo(172, 0);
    path.lineTo(172-5, 8);
    path.lineTo(172+5, 8);

//    painter.setPen(QColor("#0f9d58"));
//    painter.setBrush(QColor("#0f9d58"));
    painter.setPen(Qt::transparent);
    painter.setBrush(Qt::transparent);
    painter.drawPath(path);
    painter.fillPath(path, QColor(255,255,255,128));
}
Ejemplo n.º 4
0
QPainterPath Paths::node()
{
    QRectF m_rect;
    m_rect.setWidth(150);
    m_rect.setHeight(100);

    QPainterPath shape;
    shape.addRoundRect(m_rect, 25);

    const int conWidth = 10;
    const int xOffset  = 7;

    QRectF rect(xOffset,
                conWidth + 20,
                conWidth, conWidth);
    shape.addEllipse(rect);
    //shape.addRect(rect);

    rect = QRectF(m_rect.right() - conWidth - xOffset,
                  conWidth + 20,
                  conWidth, conWidth);
    shape.addEllipse(rect);
    //shape.addRect(rect);
    return shape;
}
Ejemplo n.º 5
0
void Cover::setCoverPixmap(const QPixmap &pixmap)
{
    Q_D(Cover);
    int radius = d->m_radius;
    QSize sz = size();
    QPainter::CompositionMode mode = QPainter::CompositionMode_SourceIn;

    QPixmap destinationImage(sz);
    destinationImage.fill(Qt::transparent);
    QPainterPath path;
    path.addRoundRect(QRectF(0, 0, sz.width(), sz.height()), radius);
    QPainter bkPainter(&destinationImage);
    bkPainter.setRenderHint(QPainter::Antialiasing);
    bkPainter.setPen(QPen(Qt::white, 1));
    bkPainter.fillPath(path, QBrush(Qt::red));

    QPixmap backgroundImage = pixmap.scaled(sz, Qt::KeepAspectRatioByExpanding);

    QImage resultImage = QImage(sz, QImage::Format_ARGB32_Premultiplied);
    QPainter painter(&resultImage);
    painter.setCompositionMode(QPainter::CompositionMode_Source);
    painter.fillRect(resultImage.rect(), Qt::transparent);
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawImage(0, 0, destinationImage.toImage());
    painter.setCompositionMode(mode);
    painter.drawImage(0, 0, backgroundImage.toImage());
    painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
    painter.end();

    d->m_Background = QPixmap::fromImage(resultImage);
}
Ejemplo n.º 6
0
QPainterPath SchedulePoint::shape() const
{
    // provide shape of each point
    QRectF rect = outlineRect();
    QPainterPath path;
    path.addRoundRect(rect,roundness(rect.width()), roundness(rect.height()));
    return path;
}
Ejemplo n.º 7
0
QPainterPath QNodeItem::shape() const
{
   QRectF rect = outlineRect();

   QPainterPath path;
   path.addRoundRect(rect, roundness(rect.width()),
		     roundness(rect.height()));
   return path;
}
Ejemplo n.º 8
0
void KoContextBarButton::paintEvent(QPaintEvent*)
{
    QStylePainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    QStyleOptionToolButton opt;
    initStyleOption(&opt);

    const QColor bgColor = palette().color(QPalette::Highlight);
    QColor color = bgColor.dark(CONTEXTBAR_BACKGROUND_DARKNESS);
    QColor borderColor = bgColor.light(CONTEXTBAR_BORDER_LIGHTNESS);

    if (opt.state & QStyle::State_MouseOver && opt.state & QStyle::State_Enabled) {
            color = color.light(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
            borderColor = borderColor.lighter(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
    }

    const QRectF rectF = QRectF(opt.rect).adjusted(0.5, 0.5, -0.5, -0.5);
    QPainterPath path;
    path.addRoundRect(rectF, CONTEXTBAR_RADIUS, CONTEXTBAR_RADIUS);

    if (m_fadingValue < 255) {
        color.setAlpha(m_fadingValue);
    }

    // Background
    painter.fillPath(path, color);

    if (opt.state & QStyle::State_Raised && opt.state & QStyle::State_Enabled) {
        // Bottom shadow
        QLinearGradient gradient(rectF.bottomLeft(), rectF.bottomLeft() - QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.bottomLeft() + QPoint(3, 0));
        painter.fillPath(path, gradient);
    }
    else {
        // Top shadow
        QLinearGradient gradient(rectF.topLeft(), rectF.topLeft() + QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.topLeft() + QPoint(5, 0));
        painter.fillPath(path, gradient);
    }

    // Border
    painter.setPen(QPen(borderColor, 0));
    painter.drawPath(path);

    // Content
    painter.drawControl(QStyle::CE_ToolButtonLabel, opt);
}
Ejemplo n.º 9
0
void SelectLocation::paintEvent(QPaintEvent *paintevent)
{
	QPainter painter;
	QPainterPath roundedrect;
	roundedrect.addRoundRect(this->rect(),20);
	
	painter.setOpacity(0.8);
	painter.fillPath(roundedrect,QColor(Qt::black));
	painter.setOpacity(1);
	
}
Ejemplo n.º 10
0
QPainterPath EvButton::backgroundPath() const
{
    QPainterPath path;
    if(m_rounded){
        path.addRoundRect(rect(),roundness());
    }
    else{
        path.addRect(rect());
    }

    return path;
}
QPainterPath
dmz::QtCanvasObjectText::shape () const {

   QPainterPath path;

   if (_text.length ()) {

      QRectF rect (_outline_rect ());
      path.addRoundRect (rect, _roundness (rect.width ()), _roundness (rect.height ()));
   }

   return path;
}
Ejemplo n.º 12
0
  void TOPPASMergerVertex::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
  {
    __DEBUG_BEGIN_METHOD__

    QPen pen(pen_color_, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
    if (isSelected())
    {
      pen.setWidth(2);
      painter->setBrush(brush_color_.darker(130));
      pen.setColor(Qt::darkBlue);
    }
    else
    {
      painter->setBrush(brush_color_);
    }
    painter->setPen(pen);

    QPainterPath path;
    path.addRoundRect(-40.0, -40.0, 80.0, 80.0, 20, 20);
    painter->drawPath(path);

    pen.setColor(pen_color_);
    painter->setPen(pen);

    QString text = round_based_mode_ ? "Merge" : "Collect";
    QRectF text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
    painter->drawText(-(int)(text_boundings.width() / 2.0), (int)(text_boundings.height() / 4.0), text);

    if (round_total_ != -1) // draw round number
    {
      text = QString::number(round_counter_) + " / " + QString::number(round_total_);
      text_boundings = painter->boundingRect(QRectF(0, 0, 0, 0), Qt::AlignCenter, text);
      painter->drawText(-(int)(text_boundings.width() / 2.0), 31, text);
    }

    //topo sort number
    qreal x_pos = -36.0;
    qreal y_pos = -23.0;
    painter->drawText(x_pos, y_pos, QString::number(topo_nr_));


    // recycling status
    if (this->allow_output_recycling_)
    {
      painter->setPen(Qt::green);
      QSvgRenderer * svg_renderer = new QSvgRenderer(QString(":/Recycling_symbol.svg"), 0);
      svg_renderer->render(painter, QRectF(-7, -32, 14, 14));
    }

    __DEBUG_END_METHOD__
  }
Ejemplo n.º 13
0
void ClassicBackgroundRender::drawBackroundFrame(QPainter *painter,
                                                 const QRectF &rect) {
  painter->fillRect(rect, QColor(0, 0, 0));
  painter->save();
  float xoffset = (rect.width() - mBackgroundImage.width()) / 2;
  float yoffset = (rect.height() - mBackgroundImage.height()) / 2;
  QRectF imageRect(xoffset, yoffset, mBackgroundImage.width(),
                   mBackgroundImage.height());
  QPainterPath path;
  path.addRoundRect(imageRect, 8.0, 8.0);
  painter->setClipPath(path);
  painter->drawImage(imageRect, mBackgroundImage);
  painter->restore();
}
Ejemplo n.º 14
0
QPainterPath EvButton::textPath() const
{
    QPainterPath path;
    path.setFillRule( Qt::WindingFill);

    QRect rect = textRect();
    if(m_rounded){
        float roundness = this->roundness();
        path.addRoundRect( rect, roundness );
        path.addRect( QRect(rect.x(),0, roundness,roundness ) );
        path.addRect( QRect( rect.x(),rect.y() , roundness,roundness ) );
    }
    else{
        path.addRect(rect);
    }
    return path.simplified();
}
Ejemplo n.º 15
0
// Прорисовка обводки виджета
void ToolTip::paintEvent(QPaintEvent *event)
{
    int roundness(3);
    QPainter painter(this);
    painter.save();

    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::red);

    QPainterPath roundedRect;
    roundedRect.addRoundRect(1, 1, this->rect().width() - 2, this->rect().height() - 2, roundness, roundness);
    painter.setClipPath(roundedRect);

    QRegion maskregion = painter.clipRegion();
    setMask(maskregion);
    painter.setBrush(Qt::NoBrush);
    painter.setPen(QPen(QColor(128, 128, 128), 3, Qt::SolidLine));
    painter.drawRoundedRect(1, 1, this->rect().width() - 2, this->rect().height() - 2, roundness + 2, roundness + 2);
    // restore painter
    painter.restore();

    QWidget::paintEvent(event);
}
Ejemplo n.º 16
0
void SaagharItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
						 const QModelIndex &index) const
{
//	if (parent()->objectName()=="searchTable")
//	{
//		qDebug() << keywordList;
//	}
	const bool flagRightToLeft = true;
	int textHMargin = 0;
	if (tableStyle)
	{
		textHMargin = tableStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, &option) +1 ;
	}

	QBrush itemBrush = painter->brush();
	
	itemBrush.setColor(SaagharWidget::matchedTextColor);
	itemBrush.setStyle(Qt::SolidPattern);

	QString text="";
	QString cleanedText = "";
	int lastX,x;
	const QFontMetrics fontMetric(option.fontMetrics);
	const QString tatweel = QString(0x0640);

	int iconWidth = 0;

	if (index.data().isValid())
	{
		text = index.data().toString();

		if (index.data(Qt::DecorationRole).isValid())
		{
			QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
			iconWidth = icon.pixmap(100, 100).width()+5;
		}

		cleanedText = QGanjoorDbBrowser::cleanString(text);
//		if (text.contains( QString::fromLocal8Bit(
//							  "پسر چون ز مادر بران گونه زاد"
////			                      "پرپر شد ..."
//					/*"وَز ســوری و نــعــمـان وزد، هـر دم شـمـیـم عـنـبـریـن"*/)))
//		{
//			qDebug() << "textt="<<text;
//			qDebug() << "clean="<<cleanedText;
//		}
		text = QGanjoorDbBrowser::cleanString(text/*, false*/);
	}
	//qDebug() << "text="<<text<<"cleanedText="<<cleanedText;
	Qt::Alignment itemAlignment = 0;
	QVariant alignValue = index.data(Qt::TextAlignmentRole);
	
	if (alignValue.isValid() && !alignValue.isNull())
		itemAlignment = Qt::Alignment(alignValue.toInt());

	int keywordsCount = keywordList.size();
	for (int i=0; i<keywordsCount; ++i)
	{
		lastX = x = option.rect.x()+textHMargin;
		//QString keyword = keywordList.isEmpty() ? "" : keywordList.at(0);
		QString keyword = keywordList.at(i);

		keyword.replace(QChar(0x200C), "", Qt::CaseInsensitive);//replace ZWNJ by ""
		//qDebug() << "keyword1="<<keyword;
		keyword = keyword.split("", QString::SkipEmptyParts).join(tatweel+"*");
		//qDebug() << "keyword2="<<keyword;
		keyword.replace("@"+tatweel+"*", "\\S*", Qt::CaseInsensitive);//replace wildcard by word chars
		//qDebug() << "keyword3="<<keyword;
		QRegExp maybeTatweel(keyword, Qt::CaseInsensitive);
		maybeTatweel.indexIn(text);
		//qDebug() << text<<"count=" << maybeTatweel.captureCount()<<maybeTatweel.capturedTexts();
		//qDebug() << "Match: "<<maybeTatweel.cap(0);
		keyword = maybeTatweel.cap(0);
	if (!(keyword.isEmpty() || text.indexOf(keyword) == -1 ) )
	{
		QString txt = text;
		while (txt.size() > 0)
		{
			int index = txt.indexOf(keyword);
			QString thisPart;
			if (index == -1)
			{
				thisPart = txt;
				txt = QString();
			}
			else
			{
				if (index == 0)
				{
					thisPart = txt.mid(0, keyword.size());
					if (txt == keyword)
						txt = QString();
					else
						txt = txt.mid(keyword.size(), txt.size() - keyword.size());
				}
				else
				{
					thisPart = txt.mid(0, index);
					txt = txt.mid(index);
				}
			}
				
			QSize sz = fontMetric.boundingRect(thisPart).size();
			if (index == 0)
			{
				if (flagRightToLeft)
				{
					switch (itemAlignment^Qt::AlignVCenter)
					{
						case Qt::AlignRight:
							lastX = option.rect.left()+textHMargin+fontMetric.boundingRect(text).width()-(lastX-option.rect.x()+sz.width()-textHMargin);
							break;

						case Qt::AlignHCenter:
							lastX = option.rect.left()+textHMargin+fontMetric.boundingRect(text).width()-(lastX-option.rect.x()+sz.width()-textHMargin)+((option.rect.width()-fontMetric.boundingRect(text).width()-textHMargin)/2);
							break;

						case Qt::AlignLeft:
						default:
							lastX = option.rect.right()+textHMargin-1 - (lastX-option.rect.x()+sz.width());
							break;
					}
				}

				QRectF rectf(lastX , option.rect.y()+((option.rect.height()-qMin(option.rect.height(), fontMetric.height()))/2), sz.width(), fontMetric.height() );
				qreal oldOpacity = painter->opacity();
				painter->setOpacity(0.65);
				rectf.adjust(-iconWidth, 0, -iconWidth, 0);
				QPainterPath roundedRect;
				roundedRect.addRoundRect(rectf, 50, 50);
				QPen defaultPen(painter->pen());
				painter->setPen(SaagharWidget::matchedTextColor.darker(150));
				painter->drawPath(roundedRect);
				painter->fillPath( roundedRect, itemBrush );
				painter->setOpacity(oldOpacity);
				painter->setPen(defaultPen);
				//painter->fillRect( rectf, itemBrush );
			}
			x += option.fontMetrics.width(thisPart);
			lastX = x;
		}
	}
	else if (!(keyword.isEmpty() || cleanedText.indexOf(keyword) == -1 ) )
	{
		qreal oldOpacity = painter->opacity();
		painter->setOpacity(0.35);
		painter->fillRect( option.rect, itemBrush );
		painter->setOpacity(oldOpacity);
		//painter->fillRect( rectf, itemBrush );
	}
	}
	QStyledItemDelegate::paint(painter, option, index);
}
Ejemplo n.º 17
0
QPainterPath PianoKey::defaultKeyShape(uchar _id){//y=0 set on upside of keyboard
    TYPE type = TYPE(0);
    if(_id==0) //leftmost key
        type = WHITE_LEFT;
    else if(_id==87) //rightmost key
        type = WHITE_WHOLE;
    else
        switch(_id % 12){
        case 1: case 4: case 6: case 9: case 11:
            type = BLACK; break;
        case 3: case 8: //C, F
            type = WHITE_LEFT; break;
        case 0: case 5: case 10: //A, D, G
            type = WHITE_NORMAL; break;
        case 2:case 7:  //B, E
            type = WHITE_RIGHT; break;
        default: break;
        }
    QPainterPath temp;
    QPolygonF polygon;
    switch(type){
    case BLACK:
/*        polygon<<blackBound.topLeft
               <<blackBound.topRight
               <<QPointF(halfwidth,blackheight)
               <<QPointF(-halfwidth,blackheight)
               <<QPointF(-halfwidth, 0); */// for fine looking
        temp.addRoundRect(blackBound, 70);//roundness 70
        return temp;
               break;
    case WHITE_LEFT:
        polygon<<whiteBound.topLeft()
               <<QPointF(halfspacing-halfwidth, 0)
               <<QPointF(halfspacing-halfwidth, blackheight)
               <<QPointF(halfspacing, blackheight)
               <<whiteBound.bottomRight()
               <<whiteBound.bottomLeft()
               <<whiteBound.topLeft();
               break;
    case WHITE_NORMAL:
        polygon<<QPointF(halfwidth-halfspacing, 0)
               <<QPointF(halfspacing-halfwidth, 0)
               <<QPointF(halfspacing-halfwidth, blackheight)
               <<QPointF(halfspacing, blackheight)
               <<whiteBound.bottomRight()
               <<whiteBound.bottomLeft()
               <<QPointF(-halfspacing, blackheight)
               <<QPointF(halfwidth-halfspacing, blackheight)
               <<QPointF(halfwidth-halfspacing, 0);
               break;
    case WHITE_RIGHT:
        polygon<<QPointF(halfwidth-halfspacing, 0)
               <<whiteBound.topRight()
               <<whiteBound.bottomRight()
               <<whiteBound.bottomLeft()
               <<QPointF(-halfspacing, blackheight)
               <<QPointF(halfwidth-halfspacing, blackheight)
               <<QPointF(halfwidth-halfspacing, 0);
               break;
    case WHITE_WHOLE:
/*        polygon<<whiteBound.topLeft
               <<whiteBound.topRight
               <<QPointF(halfspacing,whiteheight)
               <<QPointF(-halfspacing,whiteheight)
               <<QPointF(-halfspacing, 0);*///for fine looking
        temp.addRect(whiteBound);
        return temp;
               break;


    default: break;
    }

    temp.addPolygon(polygon);
    return temp;

}
Ejemplo n.º 18
0
Component::Component(QString name, QStringList inputs, QStringList outputs,
		QMenu *contextMenu, QGraphicsItem *parent, QGraphicsScene *scene) :
	QGraphicsPolygonItem(parent, scene), mySlots(inputs), mySignals(outputs),
			myName(name), myContextMenu(contextMenu) {
	minDeviceWidth = 100;
	maxDeviceWidth = 200;
	minDeviceHeight = 100;
	maxDeviceHeight = 600;
	deviceEdgeThickness = 2;
	bewelOfDeviceEdges = 15;
	spaceBetweenPins = 20;
	numberOfSlots = mySlots.size();
	numberOfSignals = mySignals.size();


	QGraphicsTextItem *nameTag = pTailorTextItem(myName, maxDeviceWidth - 20,
			maxDeviceHeight - 40, this);

	widthOfName = nameTag->boundingRect().width();
	heightOfName = nameTag->boundingRect().height();
	nameTag->setPos(-widthOfName / 2, -heightOfName / 2);

	if (widthOfName + 20 < minDeviceWidth)
		myWidth = minDeviceWidth;
	else if (widthOfName + 20 > maxDeviceWidth)
		myWidth = maxDeviceWidth;
	else
		myWidth = widthOfName + 20;
	//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
	Pin *tempPin;

//Búa til Signöl
	Pin::PinType myPinType = Pin::Signal;

	for (int i = 0; i < numberOfSignals; i++) {
		tempPin = new Pin(
				myWidth / 2 - 6 , spaceBetweenPins*i - (numberOfSignals-1)*spaceBetweenPins/2 - 6,
				12, 12, myPinType, this);

		mySignalPins << tempPin;
	}
	tempPin = 0;

//Búa til Slotts
	myPinType = Pin::Slot;

	for (int i = 0; i < numberOfSlots; i++) {
		tempPin = new Pin(
				- myWidth / 2 - 6 , spaceBetweenPins*i - (numberOfSlots-1)*spaceBetweenPins/2 - 6,
				12, 12, myPinType, this);

		mySlotPins << tempPin;
	}
	tempPin = 0;

//	QGraphicsEllipseItem *testEllipse = new QGraphicsEllipseItem(10,10,10,10,this);
//	testEllipse->setBrush(Qt::white);
//	testEllipse->setPen(pen);

// reikna hversu hár kassinn má vera


	//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	int childItemsHeight = qMax(heightOfName, qMax(numberOfSignals*spaceBetweenPins,numberOfSlots*spaceBetweenPins));

	if (childItemsHeight + 40 < minDeviceHeight)
			myHeight = minDeviceHeight;
	else if (childItemsHeight + 40 > maxDeviceHeight)
		myHeight = maxDeviceHeight;
	else
		myHeight = childItemsHeight + 40;

	myTopLeft = QPointF(-(myWidth / 2), -myHeight / 2);
	myBottomRight = QPointF(myWidth / 2, myHeight / 2);

	QPainterPath path;
	path.addRoundRect(QRectF(myTopLeft, myBottomRight), 100, bewelOfDeviceEdges
			* 100 / myHeight);

	myPolygon = path.toFillPolygon();
	setPen(QPen(Qt::black, deviceEdgeThickness));
	setBrush(QColor(200, 200, 200, 255));
	setPolygon(myPolygon);

	setFlag(QGraphicsItem::ItemIsMovable, true);
	setFlag(QGraphicsItem::ItemIsSelectable, true);
	//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
	//	QList<QGraphicsItem *> allTheItems;
	//	allTheItems << nameTag << testPin ;
	//	QGraphicsItemGroup *group = scene->createItemGroup(allTheItems);
	//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

}
PixmapListDialog::PixmapListDialog( QWidget *parent ) :
	Plasma::Dialog( parent )
{
	current_image = -1;
	movie_buffer = NULL;

	left_icon_hover = false;
	right_icon_hover = false;

	setResizeHandleCorners( Plasma::Dialog::NoCorner );

	QVBoxLayout *layout = new QVBoxLayout( this );

	const int icon_size = 36;
	const int label_size = 40;

	left_icon = new QLabel;
	left_icon->setAutoFillBackground ( true );
	left_icon->setAlignment( Qt::AlignVCenter | Qt::AlignHCenter );
	left_icon_pixmap = KIconLoader::global()->loadIcon( "go-previous", KIconLoader::NoGroup,
		icon_size, KIconLoader::DefaultState, QStringList(), 0L, false );
	left_icon->setPixmap( left_icon_pixmap );
	left_icon->setFixedHeight( label_size );
	left_icon->setFixedWidth( label_size );
	left_icon->setAttribute( Qt::WA_Hover );
	left_icon->installEventFilter( this );

	title = new QLabel;
	QPalette palette = title->palette();
	palette.setColor( QPalette::WindowText, Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) );
	palette.setColor( QPalette::Text, Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) );
	palette.setColor( QPalette::BrightText, Plasma::Theme::defaultTheme()->color( Plasma::Theme::TextColor ) );

	title->setPalette( palette );
	title->setAutoFillBackground ( true );
	title->setAlignment( Qt::AlignVCenter | Qt::AlignHCenter );
	title->setFixedHeight( label_size );

	right_icon = new QLabel;
	right_icon->setAutoFillBackground ( true );
	right_icon->setAlignment( Qt::AlignVCenter | Qt::AlignHCenter );
	right_icon_pixmap = KIconLoader::global()->loadIcon( "go-next", KIconLoader::NoGroup,
		icon_size, KIconLoader::DefaultState, QStringList(), 0L, false );
	right_icon->setPixmap( right_icon_pixmap );
	right_icon->setFixedHeight( label_size );
	right_icon->setFixedWidth( label_size );
	right_icon->setAttribute( Qt::WA_Hover );
	right_icon->installEventFilter( this );

	QHBoxLayout *icon_layout = new QHBoxLayout;
	icon_layout->addWidget( left_icon );
	icon_layout->addWidget( title );
	icon_layout->addWidget( right_icon );

	layout->addLayout( icon_layout );

	background_label = new QLabel;
	background_label->setAutoFillBackground ( true );
	background_label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
	background_label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );

	label = new QLabel( background_label );
	label->setAutoFillBackground ( true );
	label->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
	label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
	label->resize( background_label->size() );

	label->installEventFilter( this );

	layout->addWidget( background_label );

	setMinimumSize( 50, 50 );

	QPainterPath path;
	path.addRoundRect( QRectF( 0, 0, label_size - 2, label_size - 2 ), 15 );
	QLinearGradient gradient( 0.5, 0, 0.5, 1 );
	gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
	if ( qGray( Plasma::Theme::BackgroundColor ) < 140 )
	{
		gradient.setColorAt( 0, QColor( 240, 240, 240, 255 ) );
		gradient.setColorAt( 1, QColor( 140, 140, 140, 255 ) );
	}
	else
	{
		gradient.setColorAt( 0, QColor( 140, 140, 140, 255 ) );
		gradient.setColorAt( 1, QColor( 40, 40, 40, 255 ) );
	}

	left_icon_pixmap_lighter = QPixmap( label_size, label_size );
	left_icon_pixmap_lighter.fill( Qt::transparent );
	QPainter painter_left( &left_icon_pixmap_lighter );
	painter_left.setBrush( gradient );
	painter_left.translate( 1, 1 );
	painter_left.drawPath( path );
	painter_left.translate( -1, -1 );
	painter_left.drawPixmap( QRect( (int)(0.5*(label_size-icon_size)), (int)(0.5*(label_size-icon_size)),
		left_icon_pixmap.width(), left_icon_pixmap.height() ), left_icon_pixmap );

	right_icon_pixmap_lighter = QPixmap( label_size, label_size );
	right_icon_pixmap_lighter.fill( Qt::transparent );
	QPainter painter_right( &right_icon_pixmap_lighter );
	painter_right.setBrush( gradient );
	painter_left.translate( 0.5, 0.5 );
	painter_right.drawPath( path );
	painter_left.translate( -0.5, -0.5 );
	painter_right.drawPixmap( QRect( (int)(0.5*(label_size-icon_size)), (int)(0.5*(label_size-icon_size)),
		right_icon_pixmap.width(), right_icon_pixmap.height() ), right_icon_pixmap );

	connect( this, SIGNAL( dialogResized() ), this, SLOT( resized() ) );
}
Ejemplo n.º 20
0
 QPainterPath TOPPASMergerVertex::shape() const
 {
   QPainterPath shape;
   shape.addRoundRect(-41.0, -41.0, 82.0, 82.0, 20, 20);
   return shape;
 }