コード例 #1
0
ファイル: ScrollbarThemeQt.cpp プロジェクト: 13W/phantomjs
bool ScrollbarThemeQt::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
{
    // Middle click centers slider thumb (if supported).
    return style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
}
コード例 #2
0
void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
{
    ASSERT(value);
    CSSPrimitiveValue* primitiveValue = 0;
    if (value->isPrimitiveValue())
        primitiveValue = static_cast<CSSPrimitiveValue*>(value);

    SVGRenderStyle* svgstyle = m_style->accessSVGStyle();
    unsigned short valueType = value->cssValueType();
    
    bool isInherit = m_parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT;
    bool isInitial = valueType == CSSPrimitiveValue::CSS_INITIAL || (!m_parentNode && valueType == CSSPrimitiveValue::CSS_INHERIT);

    // What follows is a list that maps the CSS properties into their
    // corresponding front-end RenderStyle values. Shorthands(e.g. border,
    // background) occur in this list as well and are only hit when mapping
    // "inherit" or "initial" into front-end values.
    switch (id)
    {
        // ident only properties
        case CSSPropertyAlignmentBaseline:
        {
            HANDLE_INHERIT_AND_INITIAL(alignmentBaseline, AlignmentBaseline)
            if (!primitiveValue)
                break;
            
            svgstyle->setAlignmentBaseline(*primitiveValue);
            break;
        }
        case CSSPropertyBaselineShift:
        {
            HANDLE_INHERIT_AND_INITIAL(baselineShift, BaselineShift);
            if (!primitiveValue)
                break;

            if (primitiveValue->getIdent()) {
                switch (primitiveValue->getIdent()) {
                case CSSValueBaseline:
                    svgstyle->setBaselineShift(BS_BASELINE);
                    break;
                case CSSValueSub:
                    svgstyle->setBaselineShift(BS_SUB);
                    break;
                case CSSValueSuper:
                    svgstyle->setBaselineShift(BS_SUPER);
                    break;
                default:
                    break;
                }
            } else {
                svgstyle->setBaselineShift(BS_LENGTH);
                svgstyle->setBaselineShiftValue(primitiveValue);
            }

            break;
        }
        case CSSPropertyKerning:
        {
            HANDLE_INHERIT_AND_INITIAL(kerning, Kerning);
            svgstyle->setKerning(primitiveValue);
            break;
        }
        case CSSPropertyPointerEvents:
        {
            HANDLE_INHERIT_AND_INITIAL(pointerEvents, PointerEvents)
            if (!primitiveValue)
                break;
            
            svgstyle->setPointerEvents(*primitiveValue);
            break;
        }
        case CSSPropertyDominantBaseline:
        {
            HANDLE_INHERIT_AND_INITIAL(dominantBaseline, DominantBaseline)
            if (primitiveValue)
                svgstyle->setDominantBaseline(*primitiveValue);
            break;
        }
        case CSSPropertyColorInterpolation:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolation, ColorInterpolation)
            if (primitiveValue)
                svgstyle->setColorInterpolation(*primitiveValue);
            break;
        }
        case CSSPropertyColorInterpolationFilters:
        {
            HANDLE_INHERIT_AND_INITIAL(colorInterpolationFilters, ColorInterpolationFilters)
            if (primitiveValue)
                svgstyle->setColorInterpolationFilters(*primitiveValue);
            break;
        }
        case CSSPropertyColorRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(colorRendering, ColorRendering)
            if (primitiveValue)
                svgstyle->setColorRendering(*primitiveValue);
            break;
        }
        case CSSPropertyClipRule:
        {
            HANDLE_INHERIT_AND_INITIAL(clipRule, ClipRule)
            if (primitiveValue)
                svgstyle->setClipRule(*primitiveValue);
            break;
        }
        case CSSPropertyFillRule:
        {
            HANDLE_INHERIT_AND_INITIAL(fillRule, FillRule)
            if (primitiveValue)
                svgstyle->setFillRule(*primitiveValue);
            break;
        }
        case CSSPropertyStrokeLinejoin:
        {
            HANDLE_INHERIT_AND_INITIAL(joinStyle, JoinStyle)
            if (primitiveValue)
                svgstyle->setJoinStyle(*primitiveValue);
            break;
        }
        case CSSPropertyImageRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(imageRendering, ImageRendering)
            if (primitiveValue)
                svgstyle->setImageRendering(*primitiveValue);
            break;
        }
        case CSSPropertyShapeRendering:
        {
            HANDLE_INHERIT_AND_INITIAL(shapeRendering, ShapeRendering)
            if (primitiveValue)
                svgstyle->setShapeRendering(*primitiveValue);
            break;
        }
        // end of ident only properties
        case CSSPropertyFill:
        {
            HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint)
            if (value->isSVGPaint())
                svgstyle->setFillPaint(static_cast<SVGPaint*>(value));
            break;
        }
        case CSSPropertyStroke:
        {
            HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint)
            if (value->isSVGPaint())
                svgstyle->setStrokePaint(static_cast<SVGPaint*>(value));
            
            break;
        }
        case CSSPropertyStrokeWidth:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeWidth, StrokeWidth)
            if (primitiveValue)
                svgstyle->setStrokeWidth(primitiveValue);
            break;
        }
        case CSSPropertyStrokeDasharray:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashArray, StrokeDashArray)
            if (value->isValueList())
                svgstyle->setStrokeDashArray(static_cast<CSSValueList*>(value));
            break;
        }
        case CSSPropertyStrokeDashoffset:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeDashOffset, StrokeDashOffset)
            if (primitiveValue)
                svgstyle->setStrokeDashOffset(primitiveValue);
            break;
        }
        case CSSPropertyFillOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(fillOpacity, FillOpacity)
            if (!primitiveValue)
                return;
        
            float f = 0.0f;    
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setFillOpacity(f);
            break;
        }
        case CSSPropertyStrokeOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeOpacity, StrokeOpacity)
            if (!primitiveValue)
                return;
        
            float f = 0.0f;    
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStrokeOpacity(f);
            break;
        }
        case CSSPropertyStopOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(stopOpacity, StopOpacity)
            if (!primitiveValue)
                return;
        
            float f = 0.0f;    
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStopOpacity(f);
            break;
        }
        case CSSPropertyMarkerStart:
        {
            HANDLE_INHERIT_AND_INITIAL(markerStartResource, MarkerStartResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setMarkerStartResource(SVGURIReference::getTarget(s));
            break;
        }
        case CSSPropertyMarkerMid:
        {
            HANDLE_INHERIT_AND_INITIAL(markerMidResource, MarkerMidResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setMarkerMidResource(SVGURIReference::getTarget(s));
            break;
        }
        case CSSPropertyMarkerEnd:
        {
            HANDLE_INHERIT_AND_INITIAL(markerEndResource, MarkerEndResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setMarkerEndResource(SVGURIReference::getTarget(s));
            break;
        }
        case CSSPropertyStrokeLinecap:
        {
            HANDLE_INHERIT_AND_INITIAL(capStyle, CapStyle)
            if (primitiveValue)
                svgstyle->setCapStyle(*primitiveValue);
            break;
        }
        case CSSPropertyStrokeMiterlimit:
        {
            HANDLE_INHERIT_AND_INITIAL(strokeMiterLimit, StrokeMiterLimit)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setStrokeMiterLimit(f);
            break;
        }
        case CSSPropertyFilter:
        {
            HANDLE_INHERIT_AND_INITIAL(filterResource, FilterResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setFilterResource(SVGURIReference::getTarget(s));
            break;
        }
        case CSSPropertyMask:
        {
            HANDLE_INHERIT_AND_INITIAL(maskerResource, MaskerResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;
            
            svgstyle->setMaskerResource(SVGURIReference::getTarget(s));
            break;
        }
        case CSSPropertyClipPath:
        {
            HANDLE_INHERIT_AND_INITIAL(clipperResource, ClipperResource)
            if (!primitiveValue)
                return;

            String s;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_URI)
                s = primitiveValue->getStringValue();
            else
                return;

            svgstyle->setClipperResource(SVGURIReference::getTarget(s));
            break;
        }
        case CSSPropertyTextAnchor:
        {
            HANDLE_INHERIT_AND_INITIAL(textAnchor, TextAnchor)
            if (primitiveValue)
                svgstyle->setTextAnchor(*primitiveValue);
            break;
        }
        case CSSPropertyWritingMode:
        {
            HANDLE_INHERIT_AND_INITIAL(writingMode, WritingMode)
            if (primitiveValue)
                svgstyle->setWritingMode(*primitiveValue);
            break;
        }
        case CSSPropertyStopColor:
        {
            HANDLE_INHERIT_AND_INITIAL(stopColor, StopColor);
            if (value->isSVGColor())
                svgstyle->setStopColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color()));
            break;
        }
       case CSSPropertyLightingColor:
        {
            HANDLE_INHERIT_AND_INITIAL(lightingColor, LightingColor);
            if (value->isSVGColor())
                svgstyle->setLightingColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color()));
            break;
        }
        case CSSPropertyFloodOpacity:
        {
            HANDLE_INHERIT_AND_INITIAL(floodOpacity, FloodOpacity)
            if (!primitiveValue)
                return;

            float f = 0.0f;
            int type = primitiveValue->primitiveType();
            if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
                f = primitiveValue->getFloatValue() / 100.0f;
            else if (type == CSSPrimitiveValue::CSS_NUMBER)
                f = primitiveValue->getFloatValue();
            else
                return;

            svgstyle->setFloodOpacity(f);
            break;
        }
        case CSSPropertyFloodColor:
        {
            HANDLE_INHERIT_AND_INITIAL(floodColor, FloodColor);
            if (value->isSVGColor())
                svgstyle->setFloodColor(colorFromSVGColorCSSValue(static_cast<SVGColor*>(value), m_style->color()));
            break;
        }
        case CSSPropertyGlyphOrientationHorizontal:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationHorizontal, GlyphOrientationHorizontal)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationHorizontal((EGlyphOrientation) orientation);
            }

            break;
        }
        case CSSPropertyGlyphOrientationVertical:
        {
            HANDLE_INHERIT_AND_INITIAL(glyphOrientationVertical, GlyphOrientationVertical)
            if (!primitiveValue)
                return;

            if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_DEG) {
                int orientation = angleToGlyphOrientation(primitiveValue->getFloatValue());
                ASSERT(orientation != -1);

                svgstyle->setGlyphOrientationVertical((EGlyphOrientation) orientation);
            } else if (primitiveValue->getIdent() == CSSValueAuto)
                svgstyle->setGlyphOrientationVertical(GO_AUTO);

            break;
        }
        case CSSPropertyEnableBackground:
            // Silently ignoring this property for now
            // http://bugs.webkit.org/show_bug.cgi?id=6022
            break;
        case CSSPropertyWebkitSvgShadow: {
            if (isInherit)
                return svgstyle->setShadow(m_parentStyle->svgStyle()->shadow() ? new ShadowData(*m_parentStyle->svgStyle()->shadow()) : 0);
            if (isInitial || primitiveValue) // initial | none
                return svgstyle->setShadow(0);

            if (!value->isValueList())
                return;

            CSSValueList *list = static_cast<CSSValueList*>(value);
            ASSERT(list->length() == 1);
            ShadowValue* item = static_cast<ShadowValue*>(list->itemWithoutBoundsCheck(0));
            int x = item->x->computeLengthInt(style(), m_rootElementStyle);
            int y = item->y->computeLengthInt(style(), m_rootElementStyle);
            int blur = item->blur ? item->blur->computeLengthInt(style(), m_rootElementStyle) : 0;
            Color color;
            if (item->color)
                color = getColorFromPrimitiveValue(item->color.get());

            // -webkit-svg-shadow does should not have a spread or style
            ASSERT(!item->spread);
            ASSERT(!item->style);
                
            ShadowData* shadowData = new ShadowData(x, y, blur, 0, Normal, color.isValid() ? color : Color::transparent);
            svgstyle->setShadow(shadowData);
            return;
        }
        default:
            // If you crash here, it's because you added a css property and are not handling it
            // in either this switch statement or the one in CSSStyleSelector::applyProperty
            ASSERT_WITH_MESSAGE(0, "unimplemented propertyID: %d", id);
            return;
    }
}
コード例 #3
0
ファイル: RenderTextControl.cpp プロジェクト: Moondee/Artemis
float RenderTextControl::scaleEmToUnits(int x) const
{
    // This matches the unitsPerEm value for MS Shell Dlg and Courier New from the "head" font table.
    float unitsPerEm = 2048.0f;
    return roundf(style()->font().size() * x / unitsPerEm);
}
コード例 #4
0
ファイル: browserbar.cpp プロジェクト: gms8994/amarok-1.4
 virtual void styleChange( QStyle& )
 {
     setFixedWidth( style().pixelMetric( QStyle::PM_SplitterWidth, this ) );
 }
コード例 #5
0
/*!
  Draw the border of the plot canvas

  \param painter Painter
  \sa setBorderRadius()
*/
void QwtPlotCanvas::drawBorder( QPainter *painter )
{
    if ( d_data->borderRadius > 0 )
    {
        if ( frameWidth() > 0 )
        {
            QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ), 
                d_data->borderRadius, d_data->borderRadius,
                palette(), frameWidth(), frameStyle() );
        }
    }
    else
    {
#if QT_VERSION >= 0x040500
#if !defined(_MSC_VER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
        QStyleOptionFrameV3 opt;
#if !defined(_MSC_VER)
#pragma GCC diagnostic pop
#endif
        opt.init(this);

        int frameShape  = frameStyle() & QFrame::Shape_Mask;
        int frameShadow = frameStyle() & QFrame::Shadow_Mask;

        opt.frameShape = QFrame::Shape( int( opt.frameShape ) | frameShape );
#if 0
        opt.rect = frameRect();
#endif

        switch (frameShape) 
        {
            case QFrame::Box:
            case QFrame::HLine:
            case QFrame::VLine:
            case QFrame::StyledPanel:
            case QFrame::Panel:
            {
                opt.lineWidth = lineWidth();
                opt.midLineWidth = midLineWidth();
                break; 
            }
            default: 
            {
                opt.lineWidth = frameWidth();
                break;
            }
        }
    
        if ( frameShadow == Sunken )
            opt.state |= QStyle::State_Sunken;
        else if ( frameShadow == Raised )
            opt.state |= QStyle::State_Raised;

        style()->drawControl(QStyle::CE_ShapedFrame, &opt, painter, this);
#else
        drawFrame( painter );
#endif
    }
}
コード例 #6
0
ファイル: controlslider.cpp プロジェクト: ABuus/partyplayer
QRect ControlSlider::handleRect()
{
	int sliderPos = style()->sliderPositionFromValue(minimum(),maximum(),value(),width()-12);
	return QRect(sliderPos,0,12,12);
}
コード例 #7
0
PlayerControls::PlayerControls(QWidget *parent)
    : QWidget(parent)
    , playerState(QMediaPlayer::StoppedState)
    , playerMuted(false)
    , playButton(0)
    , stopButton(0)
    , nextButton(0)
    , previousButton(0)
    , muteButton(0)
    , volumeSlider(0)
    , rateBox(0)
{
    playButton = new QToolButton(this);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));

    connect(playButton, SIGNAL(clicked()), this, SLOT(playClicked()));

    stopButton = new QToolButton(this);
    stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
    stopButton->setEnabled(false);

    connect(stopButton, SIGNAL(clicked()), this, SIGNAL(stop()));

    nextButton = new QToolButton(this);
    nextButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipForward));

    connect(nextButton, SIGNAL(clicked()), this, SIGNAL(next()));

    previousButton = new QToolButton(this);
    previousButton->setIcon(style()->standardIcon(QStyle::SP_MediaSkipBackward));

    connect(previousButton, SIGNAL(clicked()), this, SIGNAL(previous()));

    muteButton = new QToolButton(this);
    muteButton->setIcon(style()->standardIcon(QStyle::SP_MediaVolume));

    connect(muteButton, SIGNAL(clicked()), this, SLOT(muteClicked()));

    volumeSlider = new QSlider(Qt::Horizontal, this);
    volumeSlider->setRange(0, 100);

    connect(volumeSlider, SIGNAL(sliderMoved(int)), this, SIGNAL(changeVolume(int)));

    rateBox = new QComboBox(this);
    rateBox->addItem("0.5x", QVariant(0.5));
    rateBox->addItem("1.0x", QVariant(1.0));
    rateBox->addItem("2.0x", QVariant(2.0));
    rateBox->setCurrentIndex(1);

    connect(rateBox, SIGNAL(activated(int)), SLOT(updateRate()));

    QBoxLayout *layout = new QHBoxLayout;
    layout->setMargin(0);
    layout->addWidget(stopButton);
    layout->addWidget(previousButton);
    layout->addWidget(playButton);
    layout->addWidget(nextButton);
    layout->addWidget(muteButton);
    layout->addWidget(volumeSlider);
    layout->addWidget(rateBox);
    setLayout(layout);
}
コード例 #8
0
ファイル: kmultitabbar.cpp プロジェクト: fluxer/kdelibs
void KMultiTabBarTab::paintEvent(QPaintEvent*) {
	QPainter painter(this);

	QStyleOptionToolButton opt;
	initStyleOption(&opt);

	// Paint bevel..
	if (underMouse() || isChecked()) {
		opt.text.clear();
		opt.icon = QIcon();
		style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &painter, this);
	}

	int hMargin, vMargin;
	computeMargins(&hMargin, &vMargin);

	// We first figure out how much room we have for the text, based on
	// icon size and margin, try to fit in by eliding, and perhaps
	// give up on drawing the text entirely if we're too short on room
	QPixmap icon = iconPixmap();
	int textRoom = 0;
	int iconRoom = 0;

	QString t;
	if (shouldDrawText()) {
		if (isVertical()) {
			iconRoom = icon.height() + 2*vMargin;
			textRoom = height() - iconRoom - vMargin;
		} else {
			iconRoom = icon.width() + 2*hMargin;
			textRoom = width() - iconRoom - hMargin;
		}

		t = painter.fontMetrics().elidedText(text(), Qt::ElideRight, textRoom);

		// See whether anything is left. Qt will return either
		// ... or the ellipsis unicode character, 0x2026
		if (t == QLatin1String("...") || t == QChar(0x2026))
			t.clear();
	}

	// Label time.... Simple case: no text, so just plop down the icon right in the center
	// We only do this when the button never draws the text, to avoid jumps in icon position
	// when resizing
 	if (!shouldDrawText()) {
 		style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter | Qt::AlignVCenter, icon);
 		return;
 	}

	// Now where the icon/text goes depends on text direction and tab position
	QRect iconArea;
	QRect labelArea;

	bool bottomIcon = false;
	bool rtl = layoutDirection() == Qt::RightToLeft;
	if (isVertical()) {
		if (m_position == KMultiTabBar::Left && !rtl)
			bottomIcon = true;
		if (m_position == KMultiTabBar::Right && rtl)
			bottomIcon = true;
	}
	//alignFlags = Qt::AlignLeading | Qt::AlignVCenter;

	if (isVertical()) {
		if (bottomIcon) {
			labelArea = QRect(0, vMargin, width(), textRoom);
			iconArea  = QRect(0, vMargin + textRoom, width(), iconRoom);
		} else {
			labelArea = QRect(0, iconRoom, width(), textRoom);
			iconArea  = QRect(0, 0, width(), iconRoom);
		}
	} else {
		// Pretty simple --- depends only on RTL/LTR
		if (rtl) {
			labelArea = QRect(hMargin, 0, textRoom, height());
			iconArea  = QRect(hMargin + textRoom, 0, iconRoom, height());
		} else {
			labelArea = QRect(iconRoom, 0, textRoom, height());
			iconArea  = QRect(0, 0, iconRoom, height());
		}
	}

	style()->drawItemPixmap(&painter, iconArea, Qt::AlignCenter | Qt::AlignVCenter, icon);

	if (t.isEmpty())
		return;

	QRect labelPaintArea = labelArea;

	if (isVertical()) {
		// If we're vertical, we paint to a simple 0,0 origin rect,
		// and get the transformations to get us in the right place
		labelPaintArea = QRect(0, 0, labelArea.height(), labelArea.width());

		QTransform tr;

		if (bottomIcon) {
			tr.translate(labelArea.x(), labelPaintArea.width() + labelArea.y());
			tr.rotate(-90);
		} else {
			tr.translate(labelPaintArea.height() + labelArea.x(), labelArea.y());
			tr.rotate(90);
		}
		painter.setTransform(tr);
	}

	style()->drawItemText(&painter, labelPaintArea, Qt::AlignLeading | Qt::AlignVCenter,
	                      palette(), true, t, QPalette::ButtonText);
}
コード例 #9
0
ファイル: llimpanel.cpp プロジェクト: mightymarc/SWAMPWATER
void LLFloaterIMPanel::addHistoryLine(const std::string &utf8msg, LLColor4 incolor, bool log_to_file, const LLUUID& source, const std::string& name)
{
	static const LLCachedControl<bool> mKeywordsChangeColor(gSavedPerAccountSettings, "KeywordsChangeColor", false);
	static const LLCachedControl<LLColor4> mKeywordsColor(gSavedPerAccountSettings, "KeywordsColor", LLColor4(1.f, 1.f, 1.f, 1.f));

	if (gAgentID != source)
	{
		if (mKeywordsChangeColor)
		{
			if (AscentKeyword::hasKeyword(utf8msg, 2))
			{
				incolor = mKeywordsColor;
			}
		}

		if (mDing && (!hasFocus() || !gFocusMgr.getAppHasFocus()))
		{
			static const LLCachedControl<std::string> ding("LiruNewMessageSound");
			static const LLCachedControl<std::string> dong("LiruNewMessageSoundForSystemMessages");
			LLUI::sAudioCallback(LLUUID(source.notNull() ? ding : dong));
		}
	}

	const LLColor4& color = incolor;
	// start tab flashing when receiving im for background session from user
	if (source.notNull())
	{
		LLMultiFloater* hostp = getHost();
		if( !isInVisibleChain() 
			&& hostp 
			&& source != gAgentID)
		{
			hostp->setFloaterFlashing(this, TRUE);
		}
	}

	// Now we're adding the actual line of text, so erase the 
	// "Foo is typing..." text segment, and the optional timestamp
	// if it was present. JC
	removeTypingIndicator(NULL);

	// Actually add the line
	bool prepend_newline = true;
	if (gSavedSettings.getBOOL("IMShowTimestamps"))
	{
		mHistoryEditor->appendTime(prepend_newline);
		prepend_newline = false;
	}

	std::string show_name = name;
	bool is_irc = false;
	// 'name' is a sender name that we want to hotlink so that clicking on it opens a profile.
	if (!name.empty()) // If name exists, then add it to the front of the message.
	{
		// Don't hotlink any messages from the system (e.g. "Second Life:"), so just add those in plain text.
		if (name == SYSTEM_FROM)
		{
			mHistoryEditor->appendColoredText(name,false,prepend_newline,color);
		}
		else
		{
			// IRC style text starts with a colon here; empty names and system messages aren't irc style.
			static const LLCachedControl<bool> italicize("LiruItalicizeActions");
			is_irc = italicize && utf8msg[0] != ':';
			if (source.notNull())
				LLAvatarNameCache::getPNSName(source, show_name);
			// Convert the name to a hotlink and add to message.
			LLStyleSP source_style = LLStyleMap::instance().lookupAgent(source);
			source_style->mItalic = is_irc;
			mHistoryEditor->appendStyledText(show_name,false,prepend_newline,source_style);
		}
		prepend_newline = false;
	}

	// Append the chat message in style
	{
		LLStyleSP style(new LLStyle);
		style->setColor(color);
		style->mItalic = is_irc;
		style->mBold = gSavedSettings.getBOOL("SingularityBoldGroupModerator") && isModerator(source);
		mHistoryEditor->appendStyledText(utf8msg, false, prepend_newline, style);
	}

	if (log_to_file
		&& gSavedPerAccountSettings.getBOOL("LogInstantMessages") ) 
	{
		std::string histstr;
		if (gSavedPerAccountSettings.getBOOL("IMLogTimestamp"))
			histstr = LLLogChat::timestamp(gSavedPerAccountSettings.getBOOL("LogTimestampDate")) + show_name + utf8msg;
		else
			histstr = show_name + utf8msg;

		// [Ansariel: Display name support]
		// Floater title contains display name -> bad idea to use that as filename
		// mLogLabel, however, is the old legacy name
		//LLLogChat::saveHistory(getTitle(),histstr);
		LLLogChat::saveHistory(mLogLabel, histstr);
		// [/Ansariel: Display name support]
	}

	if (source.notNull())
	{
		if (!isInVisibleChain() || (!hasFocus() && getParent() == gFloaterView))
		{
			mNumUnreadMessages++;
		}

		mSpeakers->speakerChatted(source);
		mSpeakers->setSpeakerTyping(source, FALSE);
	}
}
コード例 #10
0
ファイル: css_parser_font.cpp プロジェクト: Cassie90/ClanLib
void CSSParserFont::parse(const std::string &propname, const std::vector<CSSToken> &tokens, std::vector<std::unique_ptr<CSSPropertyValue> > &inout_values)
{
	std::unique_ptr<CSSValueFontStyle> style(new CSSValueFontStyle());
	std::unique_ptr<CSSValueFontVariant> variant(new CSSValueFontVariant());
	std::unique_ptr<CSSValueFontWeight> weight(new CSSValueFontWeight());
	std::unique_ptr<CSSValueFontSize> size(new CSSValueFontSize());
	std::unique_ptr<CSSValueLineHeight> line_height(new CSSValueLineHeight());
	std::unique_ptr<CSSValueFontFamily> family(new CSSValueFontFamily());
	style->type = CSSValueFontStyle::type_normal;
	variant->type = CSSValueFontVariant::type_normal;
	weight->type = CSSValueFontWeight::type_normal;
	size->type = CSSValueFontSize::type_medium;
	line_height->type = CSSValueLineHeight::type_normal;
	family->type = CSSValueFontFamily::type_names;
	family->names.push_back(CSSValueFontFamilyName());

	bool font_style_set = false;
	bool font_variant_set = false;
	bool font_weight_set = false;
	int normal_count = 0;
	size_t pos = 0;
	CSSToken token;
	while (pos < tokens.size())
	{
		token = next_token(pos, tokens);
		if (token.type == CSSToken::type_ident)
		{
			if (tokens.size() == 1 &&
				(equals(token.value, "caption") ||
				equals(token.value, "icon") ||
				equals(token.value, "menu") ||
				equals(token.value, "message-box") ||
				equals(token.value, "small-caption") ||
				equals(token.value, "status-bar")))
			{
				inout_values.push_back(std::move(style));
				inout_values.push_back(std::move(variant));
				inout_values.push_back(std::move(weight));
				inout_values.push_back(std::move(size));
				inout_values.push_back(std::move(line_height));
				inout_values.push_back(std::move(family));
				return;
			}
			else if (equals(token.value, "inherit") && tokens.size() == 1)
			{
				style->type = CSSValueFontStyle::type_inherit;
				variant->type = CSSValueFontVariant::type_inherit;
				weight->type = CSSValueFontWeight::type_inherit;
				size->type = CSSValueFontSize::type_inherit;
				line_height->type = CSSValueLineHeight::type_inherit;
				family->type = CSSValueFontFamily::type_inherit;
				
				inout_values.push_back(std::move(style));
				inout_values.push_back(std::move(variant));
				inout_values.push_back(std::move(weight));
				inout_values.push_back(std::move(size));
				inout_values.push_back(std::move(line_height));
				inout_values.push_back(std::move(family));
				return;
			}
			else if (equals(token.value, "normal")) // font-style or font-weight or font-variant
			{
				int allowed = 3;
				if (font_style_set)
					allowed--;
				if (font_weight_set)
					allowed--;
				if (font_variant_set)
					allowed--;
				if (normal_count < allowed)
					normal_count++;
			}
			else if (equals(token.value, "italic") && !font_style_set) // font-style
			{
				font_style_set = true;
				style->type = CSSValueFontStyle::type_italic;
			}
			else if (equals(token.value, "oblique") && !font_style_set) // font-style
			{
				font_style_set = true;
				style->type = CSSValueFontStyle::type_oblique;
			}
			else if (equals(token.value, "small-caps") && !font_variant_set) // font-variant
			{
				font_style_set = true;
				variant->type = CSSValueFontVariant::type_small_caps;
			}
			else if (equals(token.value, "bold") && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_bold;
			}
			else if (equals(token.value, "bolder") && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_bolder;
			}
			else if (equals(token.value, "lighter") && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_lighter;
			}
			else if (token.value == "100" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_100;
			}
			else if (token.value == "200" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_200;
			}
			else if (token.value == "300" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_300;
			}
			else if (token.value == "400" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_400;
			}
			else if (token.value == "500" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_500;
			}
			else if (token.value == "600" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_600;
			}
			else if (token.value == "700" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_700;
			}
			else if (token.value == "800" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_800;
			}
			else if (token.value == "900" && !font_weight_set) // font-weight
			{
				font_weight_set = true;
				weight->type = CSSValueFontWeight::type_900;
			}
			else
			{
				break;
			}
		}
		else
		{
			break;
		}
	}

	if (pos == tokens.size())
	{
		debug_parse_error(propname, tokens);
		return;
	}

	if (token.type == CSSToken::type_ident)
	{
		if (equals(token.value, "xx-small"))
			size->type = CSSValueFontSize::type_xx_small;
		else if (equals(token.value, "x-small"))
			size->type = CSSValueFontSize::type_x_small;
		else if (equals(token.value, "small"))
			size->type = CSSValueFontSize::type_small;
		else if (equals(token.value, "medium"))
			size->type = CSSValueFontSize::type_medium;
		else if (equals(token.value, "large"))
			size->type = CSSValueFontSize::type_large;
		else if (equals(token.value, "x-large"))
			size->type = CSSValueFontSize::type_x_large;
		else if (equals(token.value, "xx-large"))
			size->type = CSSValueFontSize::type_xx_large;
		else if (equals(token.value, "smaller"))
			size->type = CSSValueFontSize::type_smaller;
		else if (equals(token.value, "larger"))
			size->type = CSSValueFontSize::type_larger;
		else if (equals(token.value, "inherit"))
			size->type = CSSValueFontSize::type_inherit;
		else
		{
			debug_parse_error(propname, tokens);
			return;
		}
	}
	else if (is_length(token))
	{
		CSSLength length;
		if (parse_length(token, length))
		{
			size->type = CSSValueFontSize::type_length;
			size->length = length;
		}
		else
		{
			debug_parse_error(propname, tokens);
			return;
		}
	}
	else if (token.type == CSSToken::type_percentage)
	{
		size->type = CSSValueFontSize::type_percentage;
		size->percentage = StringHelp::text_to_float(token.value);
	}
	else
	{
		debug_parse_error(propname, tokens);
		return;
	}

	token = next_token(pos, tokens);
	if (token.type == CSSToken::type_delim && token.value == "/")
	{
		token = next_token(pos, tokens);

		if (token.type == CSSToken::type_ident)
		{
			if (equals(token.value, "normal"))
				line_height->type = CSSValueLineHeight::type_normal;
			else if (equals(token.value, "inherit"))
				line_height->type = CSSValueLineHeight::type_inherit;
			else
			{
				debug_parse_error(propname, tokens);
				return;
			}
		}
		else if (token.type == CSSToken::type_number)
		{
			line_height->type = CSSValueLineHeight::type_number;
			line_height->number = StringHelp::text_to_float(token.value);
		}
		else if (is_length(token))
		{
			CSSLength length;
			if (parse_length(token, length))
			{
				line_height->type = CSSValueLineHeight::type_length;
				line_height->length = length;
			}
			else
			{
				debug_parse_error(propname, tokens);
				return;
			}
		}
		else if (token.type == CSSToken::type_percentage)
		{
			line_height->type = CSSValueLineHeight::type_percentage;
			line_height->percentage = StringHelp::text_to_float(token.value);
		}
		else
		{
			debug_parse_error(propname, tokens);
			return;
		}

		token = next_token(pos, tokens);
	}

	family->names.clear();
	while (true)
	{
		if (token.type == CSSToken::type_ident)
		{
			CSSValueFontFamilyName name;
			if (equals(token.value, "serif"))
			{
				name.type = CSSValueFontFamilyName::type_serif;
			}
			else if (equals(token.value, "sans-serif"))
			{
				name.type = CSSValueFontFamilyName::type_sans_serif;
			}
			else if (equals(token.value, "cursive"))
			{
				name.type = CSSValueFontFamilyName::type_cursive;
			}
			else if (equals(token.value, "fantasy"))
			{
				name.type = CSSValueFontFamilyName::type_fantasy;
			}
			else if (equals(token.value, "monospace"))
			{
				name.type = CSSValueFontFamilyName::type_monospace;
			}
			else if (equals(token.value, "default"))
			{
				// reserved for future use
				return;
			}
			else if (equals(token.value, "initial"))
			{
				// reserved for future use
				return;
			}
			else
			{
				name.type = CSSValueFontFamilyName::type_family_name;
			}

			if (name.type == CSSValueFontFamilyName::type_family_name)
			{
				name.name = token.value;
				while (pos != tokens.size())
				{
					token = tokens[pos++];
					if (token.type == CSSToken::type_whitespace)
					{
						name.name += " ";
					}
					else if (token.type == CSSToken::type_ident)
					{
						name.name += token.value;
					}
					else if (token.type == CSSToken::type_delim && token.value == ",")
					{
						break;
					}
				}
				family->names.push_back(name);
				if (pos == tokens.size())
					break;
				token = next_token(pos, tokens);
			}
			else
			{
				family->names.push_back(name);

				if (pos == tokens.size())
					break;
				token = next_token(pos, tokens);
				if (token.type != CSSToken::type_delim || token.value != ",")
				{
					debug_parse_error(propname, tokens);
					return;
				}
				token = next_token(pos, tokens);
			}
		}
		else if (token.type == CSSToken::type_string)
		{
			CSSValueFontFamilyName name;
			name.type = CSSValueFontFamilyName::type_family_name;
			name.name = token.value;
			family->names.push_back(name);

			if (pos == tokens.size())
				break;
			token = next_token(pos, tokens);
			if (token.type != CSSToken::type_delim || token.value != ",")
			{
				debug_parse_error(propname, tokens);
				return;
			}
			token = next_token(pos, tokens);
		}
		else
		{
			debug_parse_error(propname, tokens);
			return;
		}
	}

	inout_values.push_back(std::move(style));
	inout_values.push_back(std::move(variant));
	inout_values.push_back(std::move(weight));
	inout_values.push_back(std::move(size));
	inout_values.push_back(std::move(line_height));
	inout_values.push_back(std::move(family));
}
コード例 #11
0
ファイル: kmultitabbar.cpp プロジェクト: fluxer/kdelibs
QPixmap KMultiTabBarTab::iconPixmap() const
{
	int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
	return icon().pixmap(iconSize);
}
コード例 #12
0
void RenderSVGInlineText::updateScaledFont()
{
    computeNewScaledFontForStyle(*this, style(), m_scalingFactor, m_scaledFont);
}
コード例 #13
0
ファイル: ScrollbarThemeQt.cpp プロジェクト: 13W/phantomjs
int ScrollbarThemeQt::trackLength(Scrollbar* scrollbar)
{
    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
    return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height();
}
コード例 #14
0
ファイル: ScrollbarThemeQt.cpp プロジェクト: 13W/phantomjs
int ScrollbarThemeQt::trackPosition(Scrollbar* scrollbar)
{
    QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
    IntRect track = style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
    return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y();
}
コード例 #15
0
ファイル: qtoolbutton.cpp プロジェクト: venkatarajasekhar/Qt
/*!
    Initialize \a option with the values from this QToolButton. This method
    is useful for subclasses when they need a QStyleOptionToolButton, but don't want
    to fill in all the information themselves.

    \sa QStyleOption::initFrom()
*/
void QToolButton::initStyleOption(QStyleOptionToolButton *option) const
{
    if (!option)
        return;

    Q_D(const QToolButton);
    option->initFrom(this);
    bool forceNoText = false;
    option->iconSize = iconSize(); //default value

#ifndef QT_NO_TOOLBAR
    if (parentWidget()) {
        if (QToolBar *toolBar = qobject_cast<QToolBar *>(parentWidget())) {
            option->iconSize = toolBar->iconSize();
        }
    }
#endif // QT_NO_TOOLBAR

    if (!forceNoText)
        option->text = d->text;
    option->icon = d->icon;
    option->arrowType = d->arrowType;
    if (d->down)
        option->state |= QStyle::State_Sunken;
    if (d->checked)
        option->state |= QStyle::State_On;
    if (d->autoRaise)
        option->state |= QStyle::State_AutoRaise;
    if (!d->checked && !d->down)
        option->state |= QStyle::State_Raised;

    option->subControls = QStyle::SC_ToolButton;
    option->activeSubControls = QStyle::SC_None;

    option->features = QStyleOptionToolButton::None;
    if (d->popupMode == QToolButton::MenuButtonPopup) {
        option->subControls |= QStyle::SC_ToolButtonMenu;
        option->features |= QStyleOptionToolButton::MenuButtonPopup;
    }
    if (option->state & QStyle::State_MouseOver) {
        option->activeSubControls = d->hoverControl;
    }
    if (d->menuButtonDown) {
        option->state |= QStyle::State_Sunken;
        option->activeSubControls |= QStyle::SC_ToolButtonMenu;
    }
    if (d->down) {
        option->state |= QStyle::State_Sunken;
        option->activeSubControls |= QStyle::SC_ToolButton;
    }


    if (d->arrowType != Qt::NoArrow)
        option->features |= QStyleOptionToolButton::Arrow;
    if (d->popupMode == QToolButton::DelayedPopup)
        option->features |= QStyleOptionToolButton::PopupDelay;
#ifndef QT_NO_MENU
    if (d->hasMenu())
        option->features |= QStyleOptionToolButton::HasMenu;
#endif
    if (d->toolButtonStyle == Qt::ToolButtonFollowStyle) {
        option->toolButtonStyle = Qt::ToolButtonStyle(style()->styleHint(QStyle::SH_ToolButtonStyle, option, this));
    } else
        option->toolButtonStyle = d->toolButtonStyle;

    if (option->toolButtonStyle == Qt::ToolButtonTextBesideIcon) {
        // If the action is not prioritized, remove the text label to save space
        if (d->defaultAction && d->defaultAction->priority() < QAction::NormalPriority)
            option->toolButtonStyle = Qt::ToolButtonIconOnly;
    }

    if (d->icon.isNull() && d->arrowType == Qt::NoArrow && !forceNoText) {
        if (!d->text.isEmpty())
            option->toolButtonStyle = Qt::ToolButtonTextOnly;
        else if (option->toolButtonStyle != Qt::ToolButtonTextOnly)
            option->toolButtonStyle = Qt::ToolButtonIconOnly;
    }

    option->pos = pos();
    option->font = font();
}
コード例 #16
0
void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
{
    if (!shouldPaint(paintInfo, tx, ty))
        return;
    
    tx += x();
    ty += y();
    
    if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)) 
        paintBoxDecorations(paintInfo, tx, ty);
    
    if (paintInfo.phase == PaintPhaseMask) {
        paintMask(paintInfo, tx, ty);
        return;
    }

    if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
        paintOutline(paintInfo.context, tx, ty, width(), height());
    
    if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)
        return;
    
    if (!shouldPaintWithinRoot(paintInfo))
        return;
    
    bool drawSelectionTint = selectionState() != SelectionNone && !document()->printing();
    if (paintInfo.phase == PaintPhaseSelection) {
        if (selectionState() == SelectionNone)
            return;
        drawSelectionTint = false;
    }

    bool completelyClippedOut = false;
    if (style()->hasBorderRadius()) {
        IntRect borderRect = IntRect(tx, ty, width(), height());

        if (borderRect.isEmpty())
            completelyClippedOut = true;
        else {
            // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
            paintInfo.context->save();
            
            IntSize topLeft, topRight, bottomLeft, bottomRight;
            style()->getBorderRadiiForRect(borderRect, topLeft, topRight, bottomLeft, bottomRight);

            paintInfo.context->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight);
        }
    }

    if (!completelyClippedOut) {
        paintReplaced(paintInfo, tx, ty);

        if (style()->hasBorderRadius())
            paintInfo.context->restore();
    }
        
    // The selection tint never gets clipped by border-radius rounding, since we want it to run right up to the edges of
    // surrounding content.
    if (drawSelectionTint) {
        IntRect selectionPaintingRect = localSelectionRect();
        selectionPaintingRect.move(tx, ty);
        paintInfo.context->fillRect(selectionPaintingRect, selectionBackgroundColor(), style()->colorSpace());
    }
}
コード例 #17
0
void RenderTextTrackCue::layout()
{
    StackStats::LayoutCheckPoint layoutCheckPoint;
    RenderBlock::layout();

    LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
    
    if (m_cue->cueType()== TextTrackCue::WebVTT) {
        if (m_cue->snapToLines())
            repositionCueSnapToLinesSet();
        else
            repositionCueSnapToLinesNotSet();
    } else
        repositionGenericCue();

    statePusher.pop();
}
コード例 #18
0
ファイル: mainwindow.cpp プロジェクト: aruggles/BaroboLabHack
MainWindow::MainWindow(const QUrl& url) : m_dongle(new mobot_t)
{
    progress = 0;

    QFile file;
    file.setFileName(":/jquery.min.js");
    file.open(QIODevice::ReadOnly);
    jQuery = file.readAll();
    jQuery.append("\nvar qt = { 'jQuery': jQuery.noConflict(true) };");
    file.close();
//! [1]

    QNetworkProxyFactory::setUseSystemConfiguration(true);

    m_interface = new JsInterface(this);
//! [2]
    view = new QWebView(this);
    view->load(url);
    connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
    connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
    connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
    connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
    connect(view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
            this, SLOT(populateJavaScriptWindowObject()));

    locationEdit = new QLineEdit(this);
    locationEdit->setSizePolicy(QSizePolicy::Expanding, locationEdit->sizePolicy().verticalPolicy());
    connect(locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));

    QToolBar *toolBar = addToolBar(tr("Navigation"));
    toolBar->addAction(view->pageAction(QWebPage::Back));
    toolBar->addAction(view->pageAction(QWebPage::Forward));
    toolBar->addAction(view->pageAction(QWebPage::Reload));
    toolBar->addAction(view->pageAction(QWebPage::Stop));
    toolBar->addWidget(locationEdit);
//! [2]

    QMenu *viewMenu = menuBar()->addMenu(tr("&View"));
    QAction* viewSourceAction = new QAction("Page Source", this);
    connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource()));
    viewMenu->addAction(viewSourceAction);

//! [3]
    QMenu *effectMenu = menuBar()->addMenu(tr("&Effect"));
    effectMenu->addAction("Highlight all links", this, SLOT(highlightAllLinks()));

    rotateAction = new QAction(this);
    rotateAction->setIcon(style()->standardIcon(QStyle::SP_FileDialogDetailedView));
    rotateAction->setCheckable(true);
    rotateAction->setText(tr("Turn images upside down"));
    connect(rotateAction, SIGNAL(toggled(bool)), this, SLOT(rotateImages(bool)));
    effectMenu->addAction(rotateAction);

    QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools"));
    toolsMenu->addAction(tr("Remove GIF images"), this, SLOT(removeGifImages()));
    toolsMenu->addAction(tr("Remove all inline frames"), this, SLOT(removeInlineFrames()));
    toolsMenu->addAction(tr("Remove all object elements"), this, SLOT(removeObjectElements()));
    toolsMenu->addAction(tr("Remove all embedded elements"), this, SLOT(removeEmbeddedElements()));

    setCentralWidget(view);
    setUnifiedTitleAndToolBarOnMac(true);

    baroboInit();
    
    qDebug() << "App path : " << qApp->applicationDirPath();
}
コード例 #19
0
void QFrame::drawFrame(QPainter *p)
{
    QPoint      p1, p2;
    QRect       r     = frameRect();
    int         type  = fstyle & MShape;
    int         cstyle = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen(black);   // ####
    p->drawRect(r);   //### a bit too simple
#else
    const QColorGroup & g = colorGroup();

#ifndef QT_NO_STYLE
    QStyleOption opt(lineWidth(), midLineWidth());

    QStyle::SFlags flags = QStyle::Style_Default;
    if (isEnabled())
        flags |= QStyle::Style_Enabled;
    if (cstyle == Sunken)
        flags |= QStyle::Style_Sunken;
    else if (cstyle == Raised)
        flags |= QStyle::Style_Raised;
    if (hasFocus())
        flags |= QStyle::Style_HasFocus;
    if (hasMouse())
        flags |= QStyle::Style_MouseOver;
#endif // QT_NO_STYLE

    switch (type) {

    case Box:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            qDrawShadeRect(p, r, g, cstyle == Sunken, lwidth,
                           midLineWidth());
        break;

    case LineEditPanel:
        style().drawPrimitive(QStyle::PE_PanelLineEdit, p, r, g, flags, opt);
        break;

    case GroupBoxPanel:
        style().drawPrimitive(QStyle::PE_PanelGroupBox, p, r, g, flags, opt);
        break;

    case TabWidgetPanel:
        style().drawPrimitive(QStyle::PE_PanelTabWidget, p, r, g, flags, opt);
        break;

    case MenuBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelMenuBar, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case ToolBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelDockWindow, p, rect(), g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case StyledPanel:
#ifndef QT_NO_STYLE
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            style().drawPrimitive(QStyle::PE_Panel, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case PopupPanel:
#ifndef QT_NO_STYLE
        {
            int vextra = style().pixelMetric(QStyle::PM_PopupMenuFrameVerticalExtra, this),
                         hextra = style().pixelMetric(QStyle::PM_PopupMenuFrameHorizontalExtra, this);
            if (vextra > 0 || hextra > 0) {
                QRect fr = frameRect();
                int   fw = frameWidth();
                if (vextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.bottom() - fw - vextra, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                }
                if (hextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.right() - fw - hextra, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                }
            }

            if (cstyle == Plain)
                qDrawPlainRect(p, r, g.foreground(), lwidth);
            else
                style().drawPrimitive(QStyle::PE_PanelPopup, p, r, g, flags, opt);
            break;
        }
#endif // fall through to Panel if QT_NO_STYLE

    case Panel:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            qDrawShadePanel(p, r, g, cstyle == Sunken, lwidth);
        break;

    case WinPanel:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), wpwidth);
        else
            qDrawWinPanel(p, r, g, cstyle == Sunken);
        break;
    case HLine:
    case VLine:
        if (type == HLine) {
            p1 = QPoint(r.x(), r.height() / 2);
            p2 = QPoint(r.x() + r.width(), p1.y());
        } else {
            p1 = QPoint(r.x() + r.width() / 2, 0);
            p2 = QPoint(p1.x(), r.height());
        }
        if (cstyle == Plain) {
            QPen oldPen = p->pen();
            p->setPen(QPen(g.foreground(), lwidth));
            p->drawLine(p1, p2);
            p->setPen(oldPen);
        } else
            qDrawShadeLine(p, p1, p2, g, cstyle == Sunken,
                           lwidth, midLineWidth());
        break;
    }
コード例 #20
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tRepowerMotoringWidgetSimrad::PaintBars( QPainter& painter, QVector< float >& values, bool isLeft )
{
    if ( m_pEngineRPMGauge )
    {
        painter.save();

        QRect gaugeRect = m_pEngineRPMGauge->geometry();

        const int barWidth( qRound( gaugeRect.height() * 0.05 ) );
        const int offsetValue (  qRound( barWidth +  ( barWidth * 0.5 ) ) );
        const int cStep( offsetValue / 4 ) ;
        int totalOffset( int( offsetValue / 1.5 ) );
        int count( 0 );

        foreach( float value, values )
        {
            QRect middleRect( gaugeRect );
            tDigitalData data( DATA_TYPE_ENGINE_TEMP );

            middleRect.adjust( -totalOffset, -totalOffset, totalOffset, totalOffset );

            if ( true == isLeft )
            {
                data = tDigitalData( DATA_TYPE_ENGINE_TRIM );
            }

            qreal span( ( 45 - ( count * cStep ) ) );
            count ++;
            int spanForArc( int( span * 16 ) );

            qreal leftStartAngle( 180 * 16 );
            qreal rightStartAngle( 360 * 16 );
            
            // Red bit
            tNOSStyle* pStyle = qobject_cast< tNOSStyle* >( style() );
            Assert( pStyle );
            QColor redColour( Qt::red );
            if ( pStyle )
            {
                redColour = pStyle->GetColor( tNOSStyle::eNCR_Destructive );
            }
            painter.setPen( QPen( redColour, barWidth ) );
            if ( true == isLeft )
            {
                painter.drawArc( middleRect, int( leftStartAngle - ( spanForArc / 2 ) ), spanForArc );
            }
            else
            {
                painter.drawArc( middleRect, int( rightStartAngle - ( spanForArc / 2 ) ), spanForArc );
            }

            // Black bit
            span -= cRedLineWidth;
            int blackSpan( int( span * 16 ) );
            painter.setPen( QPen( palette().color( QPalette::Active, QPalette::Background ), barWidth ) );
            if ( true == isLeft )
            {
                painter.translate( QPoint( cRedLineWidth, 0 ) );
                painter.drawArc( middleRect, int( leftStartAngle - ( blackSpan / 2 ) ), blackSpan );
            }
            else
            {
                painter.translate( QPoint( -cRedLineWidth, 0 ) );
                painter.drawArc( middleRect, int( rightStartAngle- ( blackSpan / 2 ) ), blackSpan );
            }

            // Grey bit.
            span -= ( cBlackLineWidth / 3 );
            int greyBarWidth( barWidth - ( cBlackLineWidth * 3 ) );
            int greySpan( int( span * 16 ) );
            QColor greyColour( palette().color( QPalette::Disabled, QPalette::Text ) );
            greyColour.setAlpha( 100 );
            painter.setPen( QPen( greyColour, greyBarWidth ) );
            if ( true == isLeft )
            {
                painter.translate( QPoint( cBlackLineWidth / 3, 0 ) );
                painter.drawArc( middleRect, int( leftStartAngle - ( greySpan / 2 ) ), greySpan );
                painter.translate( QPoint( -cBlackLineWidth / 3, 0 ) );
            }
            else
            {
                painter.translate( QPoint( -cBlackLineWidth / 3, 0 ) );
                painter.drawArc( middleRect, int( rightStartAngle - ( greySpan / 2 ) ), greySpan );
                painter.translate( QPoint( cBlackLineWidth / 3, 0 ) );
            }

            // White bit
            if ( value > 0 )
            {
                painter.setPen( QPen( palette().color( QPalette::Active, QPalette::Text ), greyBarWidth ) );
                float fillPercentage( qBound( 0.0f, ( 1 / data.Max() ) * value, 1.0f ) );
                int fillSpan( int( span * fillPercentage * 16 ) );

                // Adjust the value to take into account the line thickness.
                if ( fillSpan > greyBarWidth )
                {
                    fillSpan -= int( greyBarWidth );
                }

                if ( true == isLeft )
                {
                    painter.drawArc( middleRect, int( ( leftStartAngle - ( greySpan / 2) ) ) + ( greySpan - fillSpan ), fillSpan );
                }
                else
                {
                    painter.drawArc( middleRect, int( rightStartAngle - ( greySpan / 2 ) ), fillSpan );
                }
            }

            // Black lines
            qreal greyAreaHalfWidth( ( ( barWidth - cRedLineWidth - cBlackLineWidth ) / 2 ) );
            qreal quarterRotation( span / 4 );
            painter.setPen( QPen( Qt::black, cBlackLineWidth ) );
            
            painter.save();
            QPointF centrePoint( 0, middleRect.width() / 2 );
            painter.translate( middleRect.center() );
            painter.rotate( quarterRotation );
            if ( true == isLeft )
            {
                painter.drawLine( QPointF( - ( middleRect.width() / 2 ) - greyAreaHalfWidth, 0 ), QPointF( - ( middleRect.width() / 2 ) + greyAreaHalfWidth, 0 ) );
            }
            else
            {
                painter.drawLine( QPointF( ( middleRect.width() / 2 ) - greyAreaHalfWidth, 0 ), QPointF( ( middleRect.width() / 2 ) + greyAreaHalfWidth, 0 ) );
            }
            painter.translate( QPoint( 0, 0 ) );
            painter.restore();

            painter.save();
            
            if ( true == isLeft )
            {
                painter.drawLine( QPointF( middleRect.left() + greyAreaHalfWidth, middleRect.center().y() ), QPointF( middleRect.left() - greyAreaHalfWidth, middleRect.center().y() ) );
            }
            else
            {
                painter.drawLine( QPointF( middleRect.right() + greyAreaHalfWidth, middleRect.center().y() ), QPointF( middleRect.right() - greyAreaHalfWidth, middleRect.center().y() ) );
            }
            painter.restore();

            painter.save();
            centrePoint = QPointF( 0, middleRect.width() / 2 );
            painter.translate( middleRect.center() );
            painter.rotate( - ( quarterRotation ) );
            if ( true == isLeft )
            {
                painter.drawLine( QPointF( - ( middleRect.width() / 2 ) - greyAreaHalfWidth, 0 ), QPointF( - ( middleRect.width() / 2 ) + greyAreaHalfWidth, 0 ) );
            }
            else
            {
                painter.drawLine( QPointF( ( middleRect.width() / 2 ) - greyAreaHalfWidth, 0 ), QPointF( ( middleRect.width() / 2 ) + greyAreaHalfWidth, 0 ) );
            }
            painter.translate( QPoint( 0, 0 ) );
            painter.restore();

            totalOffset += offsetValue;
        }

        painter.restore();
    }
コード例 #21
0
ファイル: browserbar.cpp プロジェクト: gms8994/amarok-1.4
 Splitter( BrowserBar *w ) : QWidget( w, "divider" )
 {
     setCursor( QCursor(SplitHCursor) );
     styleChange( style() );
 }
コード例 #22
0
ファイル: qtoolbar.cpp プロジェクト: ballock/qtbase
/*! \reimp */
bool QToolBar::event(QEvent *event)
{
    Q_D(QToolBar);

    switch (event->type()) {
    case QEvent::Timer:
        if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) {
            QWidget *w = QApplication::activePopupWidget();
            if (!waitForPopup(this, w)) {
                d->waitForPopupTimer.stop();
                if (!this->underMouse())
                    d->layout->setExpanded(false);
            }
        }
        break;
    case QEvent::Hide:
        if (!isHidden())
            break;
    // fallthrough intended
    case QEvent::Show:
        d->toggleViewAction->setChecked(event->type() == QEvent::Show);
        emit visibilityChanged(event->type() == QEvent::Show);
#if defined(Q_WS_MAC)
        if (toolbarInUnifiedToolBar(this)) {
            // I can static_cast because I did the qobject_cast in the if above, therefore
            // we must have a QMainWindowLayout here.
            QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(parentWidget()));
            mwLayout->fixSizeInUnifiedToolbar(this);
            mwLayout->syncUnifiedToolbarVisibility();
        }
#endif // Q_WS_MAC
        break;
    case QEvent::ParentChange:
        d->layout->checkUsePopupMenu();
#if defined(Q_WS_MAC)
        if (parentWidget() && parentWidget()->isWindow())
            qt_mac_updateToolBarButtonHint(parentWidget());
#endif
        break;

    case QEvent::MouseButtonPress: {
        if (d->mousePressEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    }
    case QEvent::MouseButtonRelease:
        if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
    case QEvent::HoverEnter:
    case QEvent::HoverLeave:
        // there's nothing special to do here and we don't want to update the whole widget
        return true;
    case QEvent::HoverMove: {
#ifndef QT_NO_CURSOR
        QHoverEvent *e = static_cast<QHoverEvent*>(event);
        QStyleOptionToolBar opt;
        initStyleOption(&opt);
        if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos()))
            setCursor(Qt::SizeAllCursor);
        else
            unsetCursor();
#endif
        break;
    }
    case QEvent::MouseMove:
        if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
            return true;
        break;
#ifdef Q_OS_WINCE
    case QEvent::ContextMenu:
    {
        QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
        QWidget* child = childAt(contextMenuEvent->pos());
        QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
        if (button)
            button->setDown(false);
    }
    break;
#endif
    case QEvent::Leave:
        if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN
            // This is a workaround for loosing the mouse on Vista.
            QPoint pos = QCursor::pos();
            QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
                             QApplication::mouseButtons(), QApplication::keyboardModifiers());
            d->mouseMoveEvent(&fake);
#endif
        } else {
            if (!d->layout->expanded)
                break;

            QWidget *w = QApplication::activePopupWidget();
            if (waitForPopup(this, w)) {
                d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this);
                break;
            }

            d->waitForPopupTimer.stop();
            d->layout->setExpanded(false);
            break;
        }
    default:
        break;
    }
    return QWidget::event(event);
}
コード例 #23
0
void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) 
{
    bool hackStyledBackground = false;

    if ( withBackground && testAttribute( Qt::WA_StyledBackground ) 
        && testPaintAttribute( HackStyledBackground ) )
    {
        // Antialiasing rounded borders is done by
        // inserting pixels with colors between the 
        // border color and the color on the canvas,
        // When the border is painted before the plot items
        // these colors are interpolated for the canvas
        // and the plot items need to be clipped excluding
        // the anialiased pixels. In situations, where
        // the plot items fill the area at the rounded
        // borders this is noticeable.
        // The only way to avoid these annoying "artefacts"
        // is to paint the border on top of the plot items.

        if ( d_data->styleSheet.hasBorder &&
            !d_data->styleSheet.borderPath.isEmpty() )
        {
            // We have a border with at least one rounded corner
            hackStyledBackground = true;
        }
    }

    if ( withBackground )
    {
        painter->save();

        if ( testAttribute( Qt::WA_StyledBackground ) )
        {
            if ( hackStyledBackground )
            {
                // paint background without border

                painter->setPen( Qt::NoPen );
                painter->setBrush( d_data->styleSheet.background.brush ); 
                painter->setBrushOrigin( d_data->styleSheet.background.origin );
                painter->setClipPath( d_data->styleSheet.borderPath );
                painter->drawRect( contentsRect() );
            }
            else
            {
                qwtDrawStyledBackground( this, painter );
            }
        }
        else if ( autoFillBackground() )
        {
            painter->setPen( Qt::NoPen );
            painter->setBrush( palette().brush( backgroundRole() ) );

            if ( d_data->borderRadius > 0.0 && ( rect() == frameRect() ) )
            {
                if ( frameWidth() > 0 )
                {
                    painter->setClipPath( borderPath( rect() ) );
                    painter->drawRect( rect() );
                }
                else
                {
                    painter->setRenderHint( QPainter::Antialiasing, true );
                    painter->drawPath( borderPath( rect() ) );
                }
            }
            else
            {
                painter->drawRect( rect() );
            }
        }

        painter->restore();
    }

    painter->save();

    if ( !d_data->styleSheet.borderPath.isEmpty() )
    {
        painter->setClipPath( 
            d_data->styleSheet.borderPath, Qt::IntersectClip );
    }
    else
    {
        if ( d_data->borderRadius > 0.0 )
            painter->setClipPath( borderPath( frameRect() ), Qt::IntersectClip );
        else
            painter->setClipRect( contentsRect(), Qt::IntersectClip );
    }

    plot()->drawCanvas( painter );

    painter->restore();

    if ( withBackground && hackStyledBackground )
    {
        // Now paint the border on top
        QStyleOptionFrame opt;
        opt.initFrom(this);
        style()->drawPrimitive( QStyle::PE_Frame, &opt, painter, this);
    }
}
コード例 #24
0
ファイル: Pen.cpp プロジェクト: AndresPozo/PCL
Pen::style Pen::Style() const
{
   return style( (*API->Pen->GetPenStyle)( handle ) );
}
コード例 #25
0
void KMenuBar::drawContents(QPainter *p)
{
    // Closes the BR77113
    // We need to overload this method to paint only the menu items
    // This way when the KMenuBar is embedded in the menu applet it
    // integrates correctly.
    //
    // Background mode and origin are set so late because of styles
    // using the polish() method to modify these settings.
    //
    // Of course this hack can safely be removed when real transparency
    // will be available

    if(!d->topLevel)
    {
        QMenuBar::drawContents(p);
    }
    else
    {
        bool up_enabled = isUpdatesEnabled();
        BackgroundMode bg_mode = backgroundMode();
        BackgroundOrigin bg_origin = backgroundOrigin();

        setUpdatesEnabled(false);
        setBackgroundMode(X11ParentRelative);
        setBackgroundOrigin(WindowOrigin);

        p->eraseRect(rect());
        erase();

        QColorGroup g = colorGroup();
        bool e;

        for(int i = 0; i < (int)count(); i++)
        {
            QMenuItem *mi = findItem(idAt(i));

            if(!mi->text().isNull() || mi->pixmap())
            {
                QRect r = itemRect(i);
                if(r.isEmpty() || !mi->isVisible())
                    continue;

                e = mi->isEnabledAndVisible();
                if(e)
                    g = isEnabled() ? (isActiveWindow() ? palette().active() : palette().inactive()) : palette().disabled();
                else
                    g = palette().disabled();

                bool item_active = (actItem == i);

                p->setClipRect(r);

                if(item_active)
                {
                    QStyle::SFlags flags = QStyle::Style_Default;
                    if(isEnabled() && e)
                        flags |= QStyle::Style_Enabled;
                    if(item_active)
                        flags |= QStyle::Style_Active;
                    if(item_active && actItemDown)
                        flags |= QStyle::Style_Down;
                    flags |= QStyle::Style_HasFocus;

                    style().drawControl(QStyle::CE_MenuBarItem, p, this, r, g, flags, QStyleOption(mi));
                }
                else
                {
                    style().drawItem(p, r, AlignCenter | AlignVCenter | ShowPrefix, g, e, mi->pixmap(), mi->text());
                }
            }
        }

        setBackgroundOrigin(bg_origin);
        setBackgroundMode(bg_mode);
        setUpdatesEnabled(up_enabled);
    }
}
コード例 #26
0
ファイル: app.cpp プロジェクト: ertos12/bomi
App::App(int &argc, char **argv)
: QApplication(argc, argv), d(new Data(this)) {
    if (QFile::exists(applicationDirPath() % "/bomi.ini"_a)) {
        QSettings set(applicationDirPath() % "/bomi.ini"_a, QSettings::IniFormat);
        d->useLocalConfig = set.value(u"app/use-local-config"_q, false).toBool();
        Global::useLocalConfig = set.value(u"global/use-local-config"_q, false).toBool();
        if (d->useLocalConfig != Global::useLocalConfig) {
            const auto from = _WritablePath(Location::Config, false);
            Global::useLocalConfig = d->useLocalConfig;
            const auto to = _WritablePath(Location::Config, false);
            d->copyConfig(from, to);
            set.setValue(u"global/use-local-config"_q, Global::useLocalConfig);
        }
    }

#ifdef Q_OS_LINUX
    setlocale(LC_NUMERIC,"C");
#endif

    OS::initialize();

    _New(d->parser);
    d->parser->addOption(LineCmd::Open, u"open"_q,
                         u"Open given %1 for file path or URL."_q, u"mrl"_q);
    d->parser->addOption(LineCmd::SetSubtitle, u"set-subtitle"_q,
                         u"Set subtitle file to display."_q, u"file"_q);
//    d->parser->addOption(LineCmd::AddSubtitle, u"add-subtitle"_q,
//                         u"Add subtitle file to display."_q, u"file"_q);
    d->parser->addOption(LineCmd::Wake, u"wake"_q,
                         u"Bring the application window in front."_q);
    d->parser->addOption(LineCmd::Action, u"action"_q,
                         u"Exectute %1 action or open %1 menu."_q, u"id"_q);
    d->parser->addOption(LineCmd::LogLevel, u"log-level"_q,
                         u"Maximum verbosity for log. %1 should be one of nexts:\n    "_q
                         % Log::levelNames().join(u", "_q), u"lv"_q);
    d->parser->addOption(LineCmd::Debug, u"debug"_q,
                         u"Turn on options for debugging."_q);
    d->parser->addOption(LineCmd::DumpApiTree, u"dump-api-tree"_q,
                         u"Dump API structure tree to stdout."_q);
    d->parser->addOption(LineCmd::DumpActionList, u"dump-action-list"_q,
                         u"Dump executable action list to stdout."_q);
#ifdef Q_OS_WIN
    d->parser->addOption(LineCmd::WinAssoc, u"win-assoc"_q,
                         u"Associate given comma-separated extension list."_q, u"ext"_q);
    d->parser->addOption(LineCmd::WinUnassoc, u"win-unassoc"_q,
                         u"Unassociate all extensions."_q);
    d->parser->addOption(LineCmd::WinAssocDefault, u"win-assoc-default"_q,
                         u"Associate default extensions."_q);
#endif
    d->parser->parse(arguments());
    d->gldebug = d->parser->isSet(LineCmd::Debug);
    const auto lvStdOut = d->parser->stdoutLogLevel();

    d->import();

    d->storage.setObject(this, u"application"_q);
    d->storage.add("locale", &d->locale);
    d->storage.json("log-option", &d->logOption);
    d->storage.add("style-name", &d->styleName);
    d->storage.add("unique", &d->unique);
    d->storage.add("open-folders", open_folders, set_open_folders);
    d->storage.add("font");
    d->storage.add("fixedFont");
    d->storage.restore();

    setLocale(d->locale);

    auto logOption = d->logOption;
    if (logOption.level(LogOutput::StdOut) < lvStdOut)
        logOption.setLevel(LogOutput::StdOut, lvStdOut);
    Log::setOption(logOption);

    setQuitOnLastWindowClosed(false);
#ifndef Q_OS_MAC
    setWindowIcon(defaultIcon());
#endif

    d->styleNames = [this] () {
        auto names = QStyleFactory::keys();
        const auto defaultName = style()->objectName();
        for (auto it = ++names.begin(); it != names.end(); ++it) {
            if (defaultName.compare(*it, Qt::CaseInsensitive) == 0) {
                const auto name = *it;
                names.erase(it);
                names.prepend(name);
                break;
            }
        }
        return names;
    }();
    auto makeStyle = [&]() {
        auto name = d->styleName;
        if (style()->objectName().compare(name, Qt::CaseInsensitive) == 0)
            return;
        if (!d->styleNames.contains(name, Qt::CaseInsensitive))
            return;
        setStyle(QStyleFactory::create(name));
    };
    makeStyle();
    connect(&d->connection, &LocalConnection::messageReceived,
            this, &App::handleMessage);
}
コード例 #27
0
ファイル: qgsdatetimeedit.cpp プロジェクト: ACorradini/QGIS
int QgsDateTimeEdit::frameWidth() const
{
  return style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
}
コード例 #28
0
ファイル: qcheckbox.cpp プロジェクト: NikhilNJ/screenplay-dx
/*!
    \reimp
*/
bool QCheckBox::hitButton(const QPoint &pos) const
{
    QStyleOptionButton opt;
    initStyleOption(&opt);
    return style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, this).contains(pos);
}
コード例 #29
0
ファイル: qgsdoublespinbox.cpp プロジェクト: LingboTang/QGIS
int QgsDoubleSpinBox::frameWidth() const
{
  return style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
}
コード例 #30
0
/*!
  \brief Draw the identifier representing the curve on the legend

  \param painter Üainter
  \param rect Bounding rectangle for the identifier

  \sa setLegendAttribute
*/
void QwtPlotCurve::drawLegendIdentifier(
    QPainter *painter, const QRectF &rect ) const
{
    if ( rect.isEmpty() )
        return;

    const int dim = qMin( rect.width(), rect.height() );

    QSize size( dim, dim );

    QRectF r( 0, 0, size.width(), size.height() );
    r.moveCenter( rect.center() );

    if ( d_data->legendAttributes == 0 )
    {
        QBrush brush = d_data->brush;
        if ( brush.style() == Qt::NoBrush )
        {
            if ( style() != QwtPlotCurve::NoCurve )
                brush = QBrush( pen().color() );
            else if ( d_data->symbol &&
                ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
            {
                brush = QBrush( d_data->symbol->pen().color() );
            }
        }
        if ( brush.style() != Qt::NoBrush )
            painter->fillRect( r, brush );
    }
    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
    {
        if ( d_data->brush.style() != Qt::NoBrush )
            painter->fillRect( r, d_data->brush );
    }
    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
    {
        if ( pen() != Qt::NoPen )
        {
            painter->setPen( pen() );
            QwtPainter::drawLine( painter, rect.left(), rect.center().y(),
                                  rect.right() - 1.0, rect.center().y() );
        }
    }
    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
    {
        if ( d_data->symbol &&
            ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
        {
            QSize symbolSize = d_data->symbol->boundingSize();
            symbolSize -= QSize( 2, 2 );

            // scale the symbol size down if it doesn't fit into rect.

            double xRatio = 1.0;
            if ( rect.width() < symbolSize.width() )
                xRatio = rect.width() / symbolSize.width();
            double yRatio = 1.0;
            if ( rect.height() < symbolSize.height() )
                yRatio = rect.height() / symbolSize.height();

            const double ratio = qMin( xRatio, yRatio );

            painter->save();
            painter->scale( ratio, ratio );

            d_data->symbol->drawSymbol( painter, rect.center() / ratio );

            painter->restore();
        }
    }
}