void
FormText::setCfg( const Cfg::Text & c )
{
	setPlainText( QString() );

	QFont f = font();
	QTextCharFormat fmt = textCursor().charFormat();
	QTextBlockFormat b = textCursor().blockFormat();

	foreach( const Cfg::TextStyle & s, c.text() )
	{
		if( s.style().contains( Cfg::c_normalStyle ) )
		{
			f.setWeight( QFont::Normal );
			f.setItalic( false );
			f.setUnderline( false );

			fmt.setFontWeight( QFont::Normal );
			fmt.setFontItalic( false );
			fmt.setFontUnderline( false );
		}
		else
		{
			if( s.style().contains( Cfg::c_boldStyle ) )
			{
				f.setWeight( QFont::Bold );
				fmt.setFontWeight( QFont::Bold );
			}
			else
			{
				f.setWeight( QFont::Normal );
				fmt.setFontWeight( QFont::Normal );
			}

			if( s.style().contains( Cfg::c_italicStyle ) )
			{
				f.setItalic( true );
				fmt.setFontItalic( true );
			}
			else
			{
				f.setItalic( false );
				fmt.setFontItalic( false );
			}

			if( s.style().contains( Cfg::c_underlineStyle ) )
			{
				f.setUnderline( true );
				fmt.setFontUnderline( true );
			}
			else
			{
				f.setUnderline( false );
				fmt.setFontUnderline( false );
			}
		}

		Cfg::initBlockFormat( b, s );

		f.setPointSize( s.fontSize() );

		fmt.setFontPointSize( s.fontSize() );

		setFont( f );

		QTextCursor cursor = textCursor();
		cursor.movePosition( QTextCursor::End );
		cursor.setCharFormat( fmt );
		cursor.setBlockFormat( b );
		cursor.insertText( s.text() );
		setTextCursor( cursor );
	}

	document()->clearUndoRedoStacks();

	setObjectId( c.objectId() );

	setTextWidth( c.textWidth() );

	setPos( QPointF( c.pos().x(), c.pos().y() ) );

	setLink( c.link() );

	QRectF r = boundingRect();
	r.moveTo( pos() );

	d->m_proxy->setRect( r );
}
SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
    QSplashScreen(pixmap, f)
{
    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;

    // define text to place
    QString titleText       = QString(QApplication::applicationName()).replace(QString("-testnet"), QString(""), Qt::CaseSensitive); // cut of testnet, place it as single object further down
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QChar(0xA9)+QString(" 2013-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Primecoin developers"));
    QString copyrightBitcoin= QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin developers"));
    QString copyrightPPCoin= QChar(0xA9)+QString(" 2011-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The PPCoin developers"));
    QString testnetAddText  = QString(tr("[testnet]")); // define text to place as single text object

    QString font            = "Arial";

    // load the bitmap for writing some text over it
    QPixmap newPixmap;
    if(GetBoolArg("-testnet")) {
        newPixmap     = QPixmap(":/images/splash_primecoin");
    }
    else {
        newPixmap     = QPixmap(":/images/splash_primecoin");
    }

    QPainter pixPaint(&newPixmap);
    pixPaint.setPen(QColor(100,100,100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is to long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace+(int)(10*fontFactor+2),copyrightBitcoin);
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace+(int)(10*fontFactor+2)*2,copyrightPPCoin);

    // draw testnet string if -testnet is on
    if(QApplication::applicationName().contains(QString("-testnet"))) {
        // draw copyright stuff
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int testnetAddTextWidth  = fm.width(testnetAddText);
        pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
    }

    pixPaint.end();

    this->setPixmap(newPixmap);
}
QFont KResourceMan::readFontEntry( const QString& rKey,
							  const QFont* pDefault ) const
{
  QFont aRetFont;

  QString aValue = readEntry( rKey );
  if( !aValue.isNull() )
	{
	  // find first part (font family)
	  int nIndex = aValue.find( ',' );
	  if( nIndex == -1 )
		return aRetFont;
	  aRetFont.setFamily( aValue.left( nIndex ) );
	
	  // find second part (point size)
	  int nOldIndex = nIndex;
	  nIndex = aValue.find( ',', nOldIndex+1 );
	  if( nIndex == -1 )
		return aRetFont;
	  aRetFont.setPointSize( aValue.mid( nOldIndex+1,
										 nIndex-nOldIndex-1 ).toInt() );

	  // find third part (style hint)
	  nOldIndex = nIndex;
	  nIndex = aValue.find( ',', nOldIndex+1 );
	  if( nIndex == -1 )
		return aRetFont;
	  aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1,
													nIndex-nOldIndex-1 ).toUInt() );

	  // find fourth part (char set)
	  nOldIndex = nIndex;
	  nIndex = aValue.find( ',', nOldIndex+1 );
	  if( nIndex == -1 )
		return aRetFont;
	  aRetFont.setCharSet( (QFont::CharSet)aValue.mid( nOldIndex+1,
									   nIndex-nOldIndex-1 ).toUInt() );

	  // find fifth part (weight)
	  nOldIndex = nIndex;
	  nIndex = aValue.find( ',', nOldIndex+1 );
	  if( nIndex == -1 )
		return aRetFont;
	  aRetFont.setWeight( aValue.mid( nOldIndex+1,
									  nIndex-nOldIndex-1 ).toUInt() );

	  // find sixth part (font bits)
	  uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt();
	  if( nFontBits & 0x01 )
		aRetFont.setItalic( true );
	  if( nFontBits & 0x02 )
		aRetFont.setUnderline( true );
	  if( nFontBits & 0x04 )
		aRetFont.setStrikeOut( true );
	  if( nFontBits & 0x08 )
		aRetFont.setFixedPitch( true );
	  if( nFontBits & 0x20 )
		aRetFont.setRawMode( true );
	}
  else if( pDefault )
	aRetFont = *pDefault;

  return aRetFont;
}
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle* networkStyle) : QWidget(0, f), curAlignment(0)
{
    // set reference point, paddings
    int paddingLeft = 14;
    int paddingTop = 470;
    int titleVersionVSpace = 17;
    int titleCopyrightVSpace = 32;

    float fontFactor = 1.0;

    // define text to place
    QString titleText = tr("PIVX Core");
    QString versionText = QString(tr("Version %1")).arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightTextBtc = QChar(0xA9) + QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
    QString copyrightTextDash = QChar(0xA9) + QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Dash Core developers"));
    QString copyrightTextPIVX = QChar(0xA9) + QString(" 2015-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The PIVX Core developers"));
    QString titleAddText = networkStyle->getTitleAddText();

    QString font = QApplication::font().toString();

    // load the bitmap for writing some text over it
    pixmap = networkStyle->getSplashImage();

    QPainter pixPaint(&pixmap);
    pixPaint.setPen(QColor(100, 100, 100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 28 * fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth = fm.width(titleText);
    if (titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 28 * fontFactor));
    fm = pixPaint.fontMetrics();
    //titleTextWidth = fm.width(titleText);
    pixPaint.drawText(paddingLeft, paddingTop, titleText);

    pixPaint.setFont(QFont(font, 15 * fontFactor));
    pixPaint.drawText(paddingLeft, paddingTop + titleVersionVSpace, versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10 * fontFactor));
    pixPaint.drawText(paddingLeft, paddingTop + titleCopyrightVSpace, copyrightTextBtc);
    pixPaint.drawText(paddingLeft, paddingTop + titleCopyrightVSpace + 12, copyrightTextDash);
    pixPaint.drawText(paddingLeft, paddingTop + titleCopyrightVSpace + 24, copyrightTextPIVX);

    // draw additional text if special network
    if (!titleAddText.isEmpty()) {
        QFont boldFont = QFont(font, 10 * fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int titleAddTextWidth = fm.width(titleAddText);
        pixPaint.drawText(pixmap.width() - titleAddTextWidth - 10, pixmap.height() - 25, titleAddText);
    }

    pixPaint.end();

    // Set window title
    setWindowTitle(titleText + " " + titleAddText);

    // Resize window and move to center of desktop, disallow resizing
    QRect r(QPoint(), pixmap.size());
    resize(r.size());
    setFixedSize(r.size());
    move(QApplication::desktop()->screenGeometry().center() - r.center());

    subscribeToCoreSignals();
}
Exemple #5
0
SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
    QSplashScreen(pixmap, f)
{
    setAutoFillBackground(true);

    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;

    // define text to place
    QString titleText       = tr("Dogecoin Core");
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers\n")) + QChar(0xA9)+QString(" 2013-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Dogecoin Core developers"));
    QString testnetAddText  = QString(tr("[testnet]")); // define text to place as single text object

    QString font            = "Comic Sans MS";

    // load the bitmap for writing some text over it
    QPixmap newPixmap;
    if(isTestNet) {
        newPixmap     = QPixmap(":/images/splash_testnet");
    }
    else {
        newPixmap     = QPixmap(":/images/splash");
    }

    QPainter pixPaint(&newPixmap);
    pixPaint.setPen(QColor(100,100,100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is to long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    QRect copyrightRect = QRect(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,fm.width(copyrightText),fm.height()*2);
    pixPaint.drawText(copyrightRect,Qt::TextWordWrap,copyrightText);

    // draw testnet string if testnet is on
    if(isTestNet) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int testnetAddTextWidth  = fm.width(testnetAddText);
        pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
    }

    pixPaint.end();

    this->setPixmap(newPixmap);

    subscribeToCoreSignals();
}
Exemple #6
0
// Convert simple DOM types
QVariant domPropertyToVariant(const DomProperty *p)
{
    // requires non-const virtual nameToIcon, etc.
    switch(p->kind()) {
    case DomProperty::Bool:
        return QVariant(p->elementBool() == QFormBuilderStrings::instance().trueValue);

    case DomProperty::Cstring:
        return QVariant(p->elementCstring().toUtf8());

    case DomProperty::Point: {
        const DomPoint *point = p->elementPoint();
        return QVariant(QPoint(point->elementX(), point->elementY()));
    }

    case DomProperty::PointF: {
        const DomPointF *pointf = p->elementPointF();
        return QVariant(QPointF(pointf->elementX(), pointf->elementY()));
    }

    case DomProperty::Size: {
        const DomSize *size = p->elementSize();
        return QVariant(QSize(size->elementWidth(), size->elementHeight()));
    }

    case DomProperty::SizeF: {
        const DomSizeF *sizef = p->elementSizeF();
        return QVariant(QSizeF(sizef->elementWidth(), sizef->elementHeight()));
    }

    case DomProperty::Rect: {
        const DomRect *rc = p->elementRect();
        const QRect g(rc->elementX(), rc->elementY(), rc->elementWidth(), rc->elementHeight());
        return QVariant(g);
    }

    case DomProperty::RectF: {
        const DomRectF *rcf = p->elementRectF();
        const QRectF g(rcf->elementX(), rcf->elementY(), rcf->elementWidth(), rcf->elementHeight());
        return QVariant(g);
    }

    case DomProperty::String:
        return QVariant(p->elementString()->text());

    case DomProperty::Number:
        return QVariant(p->elementNumber());

    case DomProperty::UInt:
        return QVariant(p->elementUInt());

    case DomProperty::LongLong:
        return QVariant(p->elementLongLong());

    case DomProperty::ULongLong:
        return QVariant(p->elementULongLong());

    case DomProperty::Double:
        return QVariant(p->elementDouble());

    case DomProperty::Char: {
        const DomChar *character = p->elementChar();
        const QChar c(character->elementUnicode());
        return QVariant::fromValue(c);
    }

    case DomProperty::Color: {
        const DomColor *color = p->elementColor();
        QColor c(color->elementRed(), color->elementGreen(), color->elementBlue());
        if (color->hasAttributeAlpha())
            c.setAlpha(color->attributeAlpha());
        return QVariant::fromValue(c);
    }

    case DomProperty::Font: {
        const DomFont *font = p->elementFont();

        QFont f;
        if (font->hasElementFamily() && !font->elementFamily().isEmpty())
            f.setFamily(font->elementFamily());
        if (font->hasElementPointSize() && font->elementPointSize() > 0)
            f.setPointSize(font->elementPointSize());
        if (font->hasElementWeight() && font->elementWeight() > 0)
            f.setWeight(font->elementWeight());
        if (font->hasElementItalic())
            f.setItalic(font->elementItalic());
        if (font->hasElementBold())
            f.setBold(font->elementBold());
        if (font->hasElementUnderline())
            f.setUnderline(font->elementUnderline());
        if (font->hasElementStrikeOut())
            f.setStrikeOut(font->elementStrikeOut());
        if (font->hasElementKerning())
            f.setKerning(font->elementKerning());
        if (font->hasElementAntialiasing())
            f.setStyleStrategy(font->elementAntialiasing() ? QFont::PreferDefault : QFont::NoAntialias);
        if (font->hasElementStyleStrategy()) {
            f.setStyleStrategy(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::StyleStrategy>("styleStrategy", font->elementStyleStrategy().toLatin1()));
        }
        return QVariant::fromValue(f);
    }

    case DomProperty::Date: {
        const DomDate *date = p->elementDate();
        return QVariant(QDate(date->elementYear(), date->elementMonth(), date->elementDay()));
    }

    case DomProperty::Time: {
        const DomTime *t = p->elementTime();
        return QVariant(QTime(t->elementHour(), t->elementMinute(), t->elementSecond()));
    }

    case DomProperty::DateTime: {
        const DomDateTime *dateTime = p->elementDateTime();
        const QDate d(dateTime->elementYear(), dateTime->elementMonth(), dateTime->elementDay());
        const QTime tm(dateTime->elementHour(), dateTime->elementMinute(), dateTime->elementSecond());
        return QVariant(QDateTime(d, tm));
    }

    case DomProperty::Url: {
        const DomUrl *url = p->elementUrl();
        return QVariant(QUrl(url->elementString()->text()));
    }

#ifndef QT_NO_CURSOR
    case DomProperty::Cursor:
        return QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(p->elementCursor())));

    case DomProperty::CursorShape:
        return QVariant::fromValue(QCursor(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::CursorShape>("cursorShape", p->elementCursorShape().toLatin1())));
#endif

    case DomProperty::Locale: {
        const DomLocale *locale = p->elementLocale();
        return QVariant::fromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1()),
                    enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Country>("country", locale->attributeCountry().toLatin1())));
    }
    case DomProperty::SizePolicy: {
        const DomSizePolicy *sizep = p->elementSizePolicy();

        QSizePolicy sizePolicy;
        sizePolicy.setHorizontalStretch(sizep->elementHorStretch());
        sizePolicy.setVerticalStretch(sizep->elementVerStretch());

        const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");

        if (sizep->hasElementHSizeType()) {
            sizePolicy.setHorizontalPolicy((QSizePolicy::Policy) sizep->elementHSizeType());
        } else if (sizep->hasAttributeHSizeType()) {
            const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeHSizeType().toLatin1());
            sizePolicy.setHorizontalPolicy(sp);
        }

        if (sizep->hasElementVSizeType()) {
            sizePolicy.setVerticalPolicy((QSizePolicy::Policy) sizep->elementVSizeType());
        } else if (sizep->hasAttributeVSizeType()) {
            const  QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeVSizeType().toLatin1());
            sizePolicy.setVerticalPolicy(sp);
        }

        return QVariant::fromValue(sizePolicy);
    }

    case DomProperty::StringList:
        return QVariant(p->elementStringList()->elementString());

    default:
        uiLibWarning(QCoreApplication::translate("QFormBuilder", "Reading properties of the type %1 is not supported yet.").arg(p->kind()));
        break;
    }

    return QVariant();
}
CreateEntityDialog::CreateEntityDialog(const IdmContainer &container, const QString &name, QWidget *parent) :
    QDialog(parent),
    m_label(this),
    m_lineEdit(name, this),
    m_label2(this),
    m_lineEdit2(this),
    m_label3(this),
    m_comboBox(this),
    m_view(this),
    m_addEntity(tr("Add"), this),
    m_removeEntity(tr("Remove"), this),
    m_gridLayout(this),
    m_buttonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this),
    m_model(this),
    m_delegate(container)
{
    setWindowTitle(tr("Create a new entity"));
    setListEnabled(false);

    QFont font;
    font.setBold(true);
    font.setWeight(75);
    m_label.setFont(font);
    m_label.setText(tr("Name"));
    m_label2.setFont(font);
    m_label2.setText(tr("Short format"));
    m_label3.setFont(font);
    m_label3.setText(tr("Type"));

    m_gridLayout.setMargin(3);
    m_gridLayout.setSpacing(1);
    m_gridLayout.addWidget(&m_label,       0, 0, 1, 1);
    m_gridLayout.addWidget(&m_lineEdit,    0, 1, 1, 1);
    m_gridLayout.addWidget(&m_label3,      1, 0, 1, 1);
    m_gridLayout.addWidget(&m_comboBox,    1, 1, 1, 1);
    m_gridLayout.addWidget(&m_label2,      2, 0, 1, 1);
    m_gridLayout.addWidget(&m_lineEdit2,   2, 1, 1, 1);
    m_gridLayout.addLayout(&m_gridLayout2, 3, 0, 1, 2);
    m_gridLayout.addWidget(&m_buttonBox,   4, 0, 1, 2);

    m_horizontalLayout.setMargin(3);
    m_horizontalLayout.setSpacing(1);
    m_horizontalLayout.addWidget(&m_addEntity);
    m_horizontalLayout.addWidget(&m_removeEntity);

    m_gridLayout2.setMargin(3);
    m_gridLayout2.setSpacing(1);
    m_gridLayout2.addLayout(&m_horizontalLayout, 0, 0, 1, 1);
    m_gridLayout2.addWidget(&m_view, 1, 0, 1, 1);

    connect(&m_addEntity, SIGNAL(clicked()), this, SLOT(add()));
    connect(&m_removeEntity, SIGNAL(clicked()), this, SLOT(remove()));

    m_view.setHeaderHidden(true);
    m_view.setModel(&m_model);
    m_view.setItemDelegate(&m_delegate);

    connect(&m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(&m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    m_lineEdit.selectAll();

    for (EntityTypes::const_iterator it = container.entityTypes().constBegin(), end = container.entityTypes().constEnd(); it != end; ++it)
        m_comboBox.addItem(it->label, it.key());

    m_comboBox.setCurrentIndex(0);
    connect(&m_comboBox, SIGNAL(activated(int)), this, SLOT(activated(int)));
}
Exemple #8
0
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
    QWidget(0, f), curAlignment(0)
{

    // transparent background
    setAttribute(Qt::WA_TranslucentBackground);
    setStyleSheet("background:transparent;");

    // no window decorations
    setWindowFlags(Qt::FramelessWindowHint);

    // set reference point, paddings
    int paddingLeft             = 14;
    int paddingTop              = 470;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 32;

    float fontFactor            = 1.0;

    // define text to place
    QString titleText       = tr("Dash Core");
    QString versionText     = QString(tr("Version %1")).arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightTextBtc   = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
    QString copyrightTextDash   = QChar(0xA9)+QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Dash Core developers"));
    QString titleAddText    = networkStyle->getTitleAddText();
    // networkstyle.cpp can't (yet) read themes, so we do it here to get the correct Splash-screen
    QString splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash";
    if(GetBoolArg("-regtest", false))
        splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet";
    if(GetBoolArg("-testnet", false))
        splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet";

    QString font = QApplication::font().toString();

    // load the bitmap for writing some text over it
    pixmap = QPixmap(splashScreenPath);

    QPainter pixPaint(&pixmap);
    pixPaint.setPen(QColor(100,100,100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 28*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 28*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(paddingLeft,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));
    pixPaint.drawText(paddingLeft,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace,copyrightTextBtc);
    pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace+12,copyrightTextDash);

    // draw additional text if special network
    if(!titleAddText.isEmpty()) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int titleAddTextWidth  = fm.width(titleAddText);
        pixPaint.drawText(pixmap.width()-titleAddTextWidth-10,pixmap.height()-25,titleAddText);
    }

    pixPaint.end();

    // Resize window and move to center of desktop, disallow resizing
    QRect r(QPoint(), pixmap.size());
    resize(r.size());
    setFixedSize(r.size());
    move(QApplication::desktop()->screenGeometry().center() - r.center());

    subscribeToCoreSignals();
}
/*!

*/
void QLineNumberPanel::paint(QPainter *p, QEditor *e)
{
	/*
		possible Unicode caracter for wrapping arrow :
			0x21B3
			0x2937
	*/
	
	QFont f(font());
	f.setWeight(QFont::Bold);
	const QFontMetrics sfm(f);
	
	#ifndef WIN32
	static const QChar wrappingArrow(0x2937);
	const QFontMetrics specialSfm(sfm);
	#else
	static const QChar wrappingArrow('Ä');
	QFont specialFont(font());
	specialFont.setRawName("Wingdings");
	const QFontMetrics specialSfm(specialFont);
	#endif
	
	const int max = e->document()->lines();
	const int panelWidth = sfm.width(QString::number(max)) + 5;
	setFixedWidth(panelWidth);
	
	const QFontMetrics fm( e->document()->font() );
	
	int n, posY,
		as = fm.ascent(),
		ls = fm.lineSpacing(),
		pageBottom = e->viewport()->height(),
		contentsY = e->verticalOffset();
	
	QString txt;
	QDocument *d = e->document();
	const int cursorLine = e->cursor().lineNumber();
	
	n = d->lineNumber(contentsY);
	posY = as + 2 + d->y(n) - contentsY;
	
	//qDebug("first = %i; last = %i", first, last);
	//qDebug("beg pos : %i", posY);
	
	for ( ; ; ++n )
	{
		//qDebug("n = %i; pos = %i", n, posY);
		QDocumentLine line = d->line(n);
		
		if ( line.isNull() || ((posY - as) > pageBottom) )
			break;
		
		if ( line.isHidden() )
			continue;
		
		bool draw = true;
		
		if ( !m_verbose )
		{
			draw = !((n + 1) % 10) || !n || !line.marks().empty();
		}
		
		txt = QString::number(n + 1);
		
		if ( n == cursorLine )
		{
			draw = true;
			
			p->save();
			QFont f = p->font();
			f.setWeight(QFont::Bold);

			p->setFont(f);
		}
		
		if ( draw ) 
		{
			p->drawText(width() - 2 - sfm.width(txt),
						posY,
						txt);
			#ifdef WIN32
            	if (line.lineSpan()>1) {
                	p->save();
                	specialFont.setBold(n == cursorLine); //todo: only get bold on the current wrapped line
                	p->setFont(specialFont);
            	}
			#endif
		
			for ( int i = 1; i < line.lineSpan(); ++i )
				p->drawText(width() - 2 - specialSfm.width(wrappingArrow), posY + i * ls, wrappingArrow);

            #ifdef WIN32
                if (line.lineSpan()>1) 
                    p->restore();
            #endif
		} else {
			int yOff = posY - (as + 1) + ls / 2;
			
			if ( (n + 1) % 5 )
				p->drawPoint(width() - 5, yOff);
			else
				p->drawLine(width() - 7, yOff, width() - 2, yOff);
		}
				
		if ( n == cursorLine )
		{
			p->restore();
		}
		
		posY += ls * line.lineSpan();
	}
	
	//p->setPen(Qt::DotLine);
	//p->drawLine(width()-1, 0, width()-1, pageBottom);
	
	//setFixedWidth(sfm.width(txt) + 5);
}
void
PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    TrackModelItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
    Q_ASSERT( item );

    QStyleOptionViewItemV4 opt = option;
    prepareStyleOption( &opt, index, item );
    opt.text.clear();

    qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );

    if ( m_view->header()->visualIndex( index.column() ) > 0 )
        return;

    QPixmap pixmap, avatar;
    QString artist, track, upperText, lowerText;
    unsigned int duration = 0;

    if ( item->query()->results().count() )
    {
        artist = item->query()->results().first()->artist()->name();
        track = item->query()->results().first()->track();
        duration = item->query()->results().first()->duration();
    }
    else
    {
        artist = item->query()->artist();
        track = item->query()->track();
    }

    painter->save();
    {
        QRect r = opt.rect.adjusted( 3, 6, 0, -6 );

        // Paint Now Playing Speaker Icon
        if ( item->isPlaying() )
        {
            QPixmap nowPlayingIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker );
            QRect npr = r.adjusted( 3, r.height() / 2 - nowPlayingIcon.height() / 2, 18 - r.width(), -r.height() / 2 + nowPlayingIcon.height() / 2 );
            nowPlayingIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() );
            painter->drawPixmap( npr, nowPlayingIcon );
            r.adjust( 22, 0, 0, 0 );
        }

        QFont figureFont = opt.font;
        figureFont.setPixelSize( 18 );
        figureFont.setWeight( 99 );

        QFont boldFont = opt.font;
        boldFont.setPixelSize( 15 );
        boldFont.setWeight( 99 );

        QFont smallBoldFont = opt.font;
        smallBoldFont.setPixelSize( 12 );
        smallBoldFont.setWeight( 80 );

        QFont durationFont = opt.font;
        durationFont.setPixelSize( 12 );
        durationFont.setWeight( 80 );

        if ( index.row() == 0 )
        {
            figureFont.setPixelSize( 36 );
            boldFont.setPixelSize( 26 );
            smallBoldFont.setPixelSize( 22 );
        }
        else if ( index.row() == 1 )
        {
            figureFont.setPixelSize( 30 );
            boldFont.setPixelSize( 22 );
            smallBoldFont.setPixelSize( 18 );
        }
        else if ( index.row() == 2 )
        {
            figureFont.setPixelSize( 24 );
            boldFont.setPixelSize( 18 );
            smallBoldFont.setPixelSize( 14 );
        }
        else if ( index.row() >= 10 )
        {
            boldFont.setPixelSize( 12 );
            smallBoldFont.setPixelSize( 11 );
        }

        QRect figureRect = r.adjusted( 0, 0, -option.rect.width() + 60 - 6 + r.left(), 0 );
        painter->setFont( figureFont );
        painter->setPen( option.palette.text().color().lighter( 450 ) );
        painter->drawText( figureRect, QString::number( index.row() + 1 ), m_centerOption );
        painter->setPen( opt.palette.text().color() );

        QRect pixmapRect = r.adjusted( figureRect.width() + 6, 0, -option.rect.width() + figureRect.width() + option.rect.height() - 6 + r.left(), 0 );
        pixmap = item->query()->cover( pixmapRect.size(), false );
        if ( !pixmap )
        {
            pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::ScaledCover, pixmapRect.size() );
        }
        painter->drawPixmap( pixmapRect, pixmap );
        
        r.adjust( pixmapRect.width() + figureRect.width() + 18, 1, -28, 0 );
        QRect leftRect = r.adjusted( 0, 0, -48, 0 );
        QRect rightRect = r.adjusted( r.width() - 40, 0, 0, 0 );

        painter->setFont( boldFont );
        QString text = painter->fontMetrics().elidedText( artist, Qt::ElideRight, leftRect.width() );
        painter->drawText( leftRect, text, m_topOption );

        painter->setFont( smallBoldFont );
        text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
        painter->drawText( index.row() >= 10 ? leftRect : leftRect.adjusted( 0, painter->fontMetrics().height() + 6, 0, 0 ), text, index.row() >= 10 ? m_bottomOption : m_topOption );

        if ( duration > 0 )
        {
            painter->setFont( durationFont );
            text = painter->fontMetrics().elidedText( TomahawkUtils::timeToString( duration ), Qt::ElideRight, rightRect.width() );
            painter->drawText( rightRect, text, m_centerRightOption );
        }
    }
    painter->restore();
}
    FenetrePrincipale::FenetrePrincipale(QWidget *parent) :
        QMainWindow(parent)
    {

        if (this->objectName().isEmpty())
            this->setObjectName(QString::fromUtf8("MainWindow"));
        this->resize(1024, 768);
        actionNouvelle_Partie = new QAction(this);
        actionNouvelle_Partie->setObjectName(QString::fromUtf8("actionNouvelle_Partie"));
        actionSauvegarder_la_Partie = new QAction(this);
        actionSauvegarder_la_Partie->setObjectName(QString::fromUtf8("actionSauvegarder_la_Partie"));
        actionCharger_une_Partie = new QAction(this);
        actionCharger_une_Partie->setObjectName(QString::fromUtf8("actionCharger_une_Partie"));
        actionA_Propos = new QAction(this);
        actionA_Propos->setObjectName(QString::fromUtf8("actionA_Propos"));
        centralWidget = new QWidget(this);
        centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
        labelDescriptionVague = new QLabel(centralWidget);
        labelDescriptionVague->setObjectName(QString::fromUtf8("labelDescriptionVague"));
        labelDescriptionVague->setGeometry(QRect(20, 700, 672, 20));
        groupBoxInformationsJeu = new QGroupBox(centralWidget);
        groupBoxInformationsJeu->setObjectName(QString::fromUtf8("groupBoxInformationsJeu"));
        groupBoxInformationsJeu->setGeometry(QRect(710, 10, 300, 161));
        groupBoxInformationsJeu->setAutoFillBackground(false);
        lcdNumberCredits = new QLCDNumber(groupBoxInformationsJeu);
        lcdNumberCredits->setObjectName(QString::fromUtf8("lcdNumberCredits"));
        lcdNumberCredits->setGeometry(QRect(20, 52, 121, 41));
        lcdNumberVies = new QLCDNumber(groupBoxInformationsJeu);
        lcdNumberVies->setObjectName(QString::fromUtf8("lcdNumberVies"));
        lcdNumberVies->setGeometry(QRect(160, 50, 121, 41));
        labelCredits = new QLabel(groupBoxInformationsJeu);
        labelCredits->setObjectName(QString::fromUtf8("labelCredits"));
        labelCredits->setGeometry(QRect(20, 30, 111, 21));
        QFont font;
        font.setPointSize(13);
        font.setBold(true);
        font.setWeight(75);
        labelCredits->setFont(font);
        labelCredits->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
        labelVies = new QLabel(groupBoxInformationsJeu);
        labelVies->setObjectName(QString::fromUtf8("labelVies"));
        labelVies->setGeometry(QRect(160, 30, 111, 21));
        labelVies->setFont(font);
        labelVies->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);

        boutonLancerVague = new QPushButton(groupBoxInformationsJeu);
        boutonLancerVague->setObjectName(QString::fromUtf8("boutonLancerVague"));
        boutonLancerVague->setGeometry(QRect(20, 110, 121, 31));
        boutonLancerVague->setDisabled(true);

        boutonPause = new QPushButton(groupBoxInformationsJeu);
        boutonPause->setObjectName(QString::fromUtf8("boutonPause"));
        boutonPause->setGeometry(QRect(160, 110, 121, 31));
        boutonPause->setDisabled(true);

        groupBoxCreationDefense = new QGroupBox(centralWidget);
        groupBoxCreationDefense->setObjectName(QString::fromUtf8("groupBoxCreationDefense"));
        groupBoxCreationDefense->setGeometry(QRect(710, 190, 300, 160));
        boutonCreerPistoleteau = new QPushButton(groupBoxCreationDefense);
        boutonCreerPistoleteau->setObjectName(QString::fromUtf8("boutonCreerPistoleteau"));
        boutonCreerPistoleteau->setGeometry(QRect(20, 30, 121, 31));
        boutonCreerPistoleteau->setDisabled(true);
        boutonCreerLancepierre = new QPushButton(groupBoxCreationDefense);
        boutonCreerLancepierre->setObjectName(QString::fromUtf8("boutonCreerLancepierre"));
        boutonCreerLancepierre->setGeometry(QRect(160, 30, 121, 31));
        boutonCreerLancepierre->setDisabled(true);
        boutonCreerPaintball = new QPushButton(groupBoxCreationDefense);
        boutonCreerPaintball->setObjectName(QString::fromUtf8("boutonCreerPaintball"));
        boutonCreerPaintball->setGeometry(QRect(20, 70, 121, 31));
        boutonCreerPaintball->setDisabled(true);
        boutonCreerPetanque = new QPushButton(groupBoxCreationDefense);
        boutonCreerPetanque->setObjectName(QString::fromUtf8("boutonCreerPetanque"));
        boutonCreerPetanque->setGeometry(QRect(160, 70, 121, 31));
        boutonCreerPetanque->setDisabled(true);
        boutonCreerMusicien = new QPushButton(groupBoxCreationDefense);
        boutonCreerMusicien->setObjectName(QString::fromUtf8("boutonCreerMusicien"));
        boutonCreerMusicien->setGeometry(QRect(20, 110, 121, 31));
        boutonCreerMusicien->setDisabled(true);
        groupBoxInformations = new QGroupBox(centralWidget);
        groupBoxInformations->setObjectName(QString::fromUtf8("groupBoxInformations"));
        groupBoxInformations->setEnabled(true);
        groupBoxInformations->setGeometry(QRect(710, 370, 300, 201));
        groupBoxInformations->setMinimumSize(QSize(299, 200));
        groupBoxInformations->hide();
        labelDefenseurType = new QLabel(groupBoxInformations);
        labelDefenseurType->setObjectName(QString::fromUtf8("labelDefenseurType"));
        labelDefenseurType->setGeometry(QRect(20, 20, 80, 16));
        QFont font1;
        font1.setPointSize(10);
        font1.setBold(true);
        font1.setWeight(75);
        labelDefenseurType->setFont(font1);
        labelDefenseurCibles = new QLabel(groupBoxInformations);
        labelDefenseurCibles->setObjectName(QString::fromUtf8("labelDefenseurCibles"));
        labelDefenseurCibles->setGeometry(QRect(20, 40, 80, 16));
        labelDefenseurCibles->setFont(font1);
        labelDefenseurPortee = new QLabel(groupBoxInformations);
        labelDefenseurPortee->setObjectName(QString::fromUtf8("labelDefenseurPortee"));
        labelDefenseurPortee->setGeometry(QRect(20, 60, 80, 16));
        labelDefenseurPortee->setFont(font1);
        labelDefenseurCadence = new QLabel(groupBoxInformations);
        labelDefenseurCadence->setObjectName(QString::fromUtf8("labelDefenseurCadence"));
        labelDefenseurCadence->setGeometry(QRect(20, 80, 80, 16));
        labelDefenseurCadence->setFont(font1);
        labelDefenseurFrappe = new QLabel(groupBoxInformations);
        labelDefenseurFrappe->setObjectName(QString::fromUtf8("labelDefenseurFrappe"));
        labelDefenseurFrappe->setGeometry(QRect(20, 100, 80, 16));
        labelDefenseurFrappe->setFont(font1);
        labelDefenseurNiveau = new QLabel(groupBoxInformations);
        labelDefenseurNiveau->setObjectName(QString::fromUtf8("labelDefenseurNiveau"));
        labelDefenseurNiveau->setGeometry(QRect(20, 120, 80, 16));
        labelDefenseurNiveau->setFont(font1);
        boutonSupprimerDefense = new QPushButton(groupBoxInformations);
        boutonSupprimerDefense->setObjectName(QString::fromUtf8("boutonSupprimerDefense"));
        boutonSupprimerDefense->setGeometry(QRect(160, 150, 121, 31));
        QFont font2;
        font2.setPointSize(10);
        font2.setBold(false);
        font2.setItalic(true);
        font2.setWeight(50);
        boutonSupprimerDefense->setFont(font2);
        boutonAmeliorerDefense = new QPushButton(groupBoxInformations);
        boutonAmeliorerDefense->setObjectName(QString::fromUtf8("boutonAmeliorerDefense"));
        boutonAmeliorerDefense->setGeometry(QRect(20, 150, 121, 31));
        boutonAmeliorerDefense->setFont(font1);
        labelDefenseurType_info = new QLabel(groupBoxInformations);
        labelDefenseurType_info->setObjectName(QString::fromUtf8("labelDefenseurType_info"));
        labelDefenseurType_info->setGeometry(QRect(130, 20, 160, 16));
        labelDefenseurType_info->setFont(font1);
        labelDefenseurCibles_info = new QLabel(groupBoxInformations);
        labelDefenseurCibles_info->setObjectName(QString::fromUtf8("labelDefenseurCibles_info"));
        labelDefenseurCibles_info->setGeometry(QRect(130, 40, 160, 16));
        labelDefenseurCibles_info->setFont(font1);
        labelDefenseurPortee_info = new QLabel(groupBoxInformations);
        labelDefenseurPortee_info->setObjectName(QString::fromUtf8("labelDefenseurPortee_info"));
        labelDefenseurPortee_info->setGeometry(QRect(130, 60, 160, 16));
        labelDefenseurPortee_info->setFont(font1);
        labelDefenseurCadence_info = new QLabel(groupBoxInformations);
        labelDefenseurCadence_info->setObjectName(QString::fromUtf8("labelDefenseurCadence_info"));
        labelDefenseurCadence_info->setGeometry(QRect(130, 80, 160, 16));
        labelDefenseurCadence_info->setFont(font1);
        labelDefenseurFrappe_info = new QLabel(groupBoxInformations);
        labelDefenseurFrappe_info->setObjectName(QString::fromUtf8("labelDefenseurFrappe_info"));
        labelDefenseurFrappe_info->setGeometry(QRect(130, 100, 160, 16));
        labelDefenseurFrappe_info->setFont(font1);
        labelDefenseurNiveau_info = new QLabel(groupBoxInformations);
        labelDefenseurNiveau_info->setObjectName(QString::fromUtf8("labelDefenseurNiveau_info"));
        labelDefenseurNiveau_info->setGeometry(QRect(130, 120, 160, 16));
        labelDefenseurNiveau_info->setFont(font1);


        widgetCarte = new QWidget(centralWidget);
        widgetCarte->setPalette(QColor("white"));
        widgetCarte->setAutoFillBackground(true);
        widgetCarte->setGeometry(QRect(10, 10, 691, 691));
        widgetCarte->setObjectName(QString::fromUtf8("widgetCarte"));

        carteGraphicsScene = new MyQGraphicsScene;
        carteGraphicsScene->setSceneRect(10, 10, Constantes::largeurGraphicsScene, Constantes::hauteurGraphicsScene);
        carteGraphicsView = new QGraphicsView(carteGraphicsScene, widgetCarte);
        carteGraphicsView->setBackgroundBrush(QPixmap(QString(":/images/herbe.jpg")));

        this->setCentralWidget(centralWidget);
        statusBar = new QStatusBar(this);
        statusBar->setObjectName(QString::fromUtf8("statusBar"));
        this->setStatusBar(statusBar);
        menuBar = new QMenuBar(this);
        menuBar->setObjectName(QString::fromUtf8("menuBar"));
        menuBar->setGeometry(QRect(0, 0, 1024, 21));
        menuTowerDefense = new QMenu(menuBar);
        menuTowerDefense->setObjectName(QString::fromUtf8("menuTowerDefense"));
        menuAide = new QMenu(menuBar);
        menuAide->setObjectName(QString::fromUtf8("menuAide"));
        this->setMenuBar(menuBar);

        menuBar->addAction(menuTowerDefense->menuAction());
        menuBar->addAction(menuAide->menuAction());
        menuTowerDefense->addAction(actionNouvelle_Partie);
        menuTowerDefense->addAction(actionSauvegarder_la_Partie);
        menuTowerDefense->addAction(actionCharger_une_Partie);
        menuAide->addAction(actionA_Propos);


        this->setWindowTitle(QApplication::translate("MainWindow", "Tower Defense - LO21", 0, QApplication::UnicodeUTF8));
        actionNouvelle_Partie->setText(QApplication::translate("MainWindow", "Nouvelle Partie", 0, QApplication::UnicodeUTF8));
        actionNouvelle_Partie->setShortcut(QApplication::translate("MainWindow", "Ctrl+N", 0, QApplication::UnicodeUTF8));
        actionSauvegarder_la_Partie->setText(QApplication::translate("MainWindow", "Sauvegarder la Partie", 0, QApplication::UnicodeUTF8));
        actionSauvegarder_la_Partie->setShortcut(QApplication::translate("MainWindow", "Ctrl+S", 0, QApplication::UnicodeUTF8));
        actionCharger_une_Partie->setText(QApplication::translate("MainWindow", "Charger une Partie", 0, QApplication::UnicodeUTF8));
        actionCharger_une_Partie->setShortcut(QApplication::translate("MainWindow", "Ctrl+L", 0, QApplication::UnicodeUTF8));
        actionA_Propos->setText(QApplication::translate("MainWindow", "A Propos", 0, QApplication::UnicodeUTF8));
        actionA_Propos->setShortcut(QApplication::translate("MainWindow", "F1", 0, QApplication::UnicodeUTF8));
        labelDescriptionVague->setText(QApplication::translate("MainWindow", "Aucune vague en cours...", 0, QApplication::UnicodeUTF8));
        groupBoxInformationsJeu->setTitle(QApplication::translate("MainWindow", "Informations de la partie", 0, QApplication::UnicodeUTF8));
        labelCredits->setText(QApplication::translate("MainWindow", "Cr\303\251dits", 0, QApplication::UnicodeUTF8));
        labelVies->setText(QApplication::translate("MainWindow", "Vies", 0, QApplication::UnicodeUTF8));
        boutonLancerVague->setText(QApplication::translate("MainWindow", "Lancer la Vague", 0, QApplication::UnicodeUTF8));
        boutonPause->setText(QApplication::translate("MainWindow", "Pause", 0, QApplication::UnicodeUTF8));
        groupBoxCreationDefense->setTitle(QApplication::translate("MainWindow", "Cr\303\251er une d\303\251fense", 0, QApplication::UnicodeUTF8));
        boutonCreerPistoleteau->setText(QApplication::translate("MainWindow", "Pistolet \303\240 Eau", 0, QApplication::UnicodeUTF8));
        boutonCreerLancepierre->setText(QApplication::translate("MainWindow", "Lance-Pierre", 0, QApplication::UnicodeUTF8));
        boutonCreerPaintball->setText(QApplication::translate("MainWindow", "Paint-Ball", 0, QApplication::UnicodeUTF8));
        boutonCreerPetanque->setText(QApplication::translate("MainWindow", "P\303\251tanque", 0, QApplication::UnicodeUTF8));
        boutonCreerMusicien->setText(QApplication::translate("MainWindow", "Musicien", 0, QApplication::UnicodeUTF8));
        groupBoxInformations->setTitle(QApplication::translate("MainWindow", "D\303\251tails", 0, QApplication::UnicodeUTF8));
        labelDefenseurType->setText(QApplication::translate("MainWindow", "Type :", 0, QApplication::UnicodeUTF8));
        labelDefenseurCibles->setText(QApplication::translate("MainWindow", "Cibles :", 0, QApplication::UnicodeUTF8));
        labelDefenseurPortee->setText(QApplication::translate("MainWindow", "Port\303\251e :", 0, QApplication::UnicodeUTF8));
        labelDefenseurCadence->setText(QApplication::translate("MainWindow", "Cadence :", 0, QApplication::UnicodeUTF8));
        labelDefenseurFrappe->setText(QApplication::translate("MainWindow", "Frappe :", 0, QApplication::UnicodeUTF8));
        labelDefenseurNiveau->setText(QApplication::translate("MainWindow", "Niveau :", 0, QApplication::UnicodeUTF8));
        boutonSupprimerDefense->setText(QApplication::translate("MainWindow", "Supprimer", 0, QApplication::UnicodeUTF8));
        boutonAmeliorerDefense->setText(QApplication::translate("MainWindow", "Am\303\251liorer", 0, QApplication::UnicodeUTF8));
        labelDefenseurType_info->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
        labelDefenseurCibles_info->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
        labelDefenseurPortee_info->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
        labelDefenseurCadence_info->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
        labelDefenseurFrappe_info->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
        labelDefenseurNiveau_info->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
        menuTowerDefense->setTitle(QApplication::translate("MainWindow", "Menu", 0, QApplication::UnicodeUTF8));
        menuAide->setTitle(QApplication::translate("MainWindow", "Aide", 0, QApplication::UnicodeUTF8));


        timer = new QTimer();


        // Connexion des signaux et des slots
        QObject::connect(timer, SIGNAL(timeout()), carteGraphicsScene, SLOT(advance()));
        QObject::connect(boutonLancerVague, SIGNAL(clicked()), this, SLOT(lancerVague()));
        QObject::connect(boutonPause, SIGNAL(clicked()), this, SLOT(slotPause()));
        QObject::connect(boutonCreerPaintball, SIGNAL(clicked()), this, SLOT(activerInsertion()));
        QObject::connect(boutonCreerLancepierre, SIGNAL(clicked()), this, SLOT(activerInsertion()));
        QObject::connect(boutonCreerPetanque, SIGNAL(clicked()), this, SLOT(activerInsertion()));
        QObject::connect(boutonCreerPistoleteau, SIGNAL(clicked()), this, SLOT(activerInsertion()));
        QObject::connect(boutonCreerMusicien, SIGNAL(clicked()), this, SLOT(activerInsertion()));
        QObject::connect(boutonAmeliorerDefense, SIGNAL(clicked()), carteGraphicsScene, SLOT(ameliorerDefenseur()));
        QObject::connect(boutonSupprimerDefense, SIGNAL(clicked()), carteGraphicsScene, SLOT(supprimerDefenseur()));

        QObject::connect(carteGraphicsScene, SIGNAL(mauvaisEndroitClique()), this, SLOT(mauvaisEndroitClique()));

        // Connexion entre les factories et la partie graphique
        // Mise à jour des informations courantes du jeu
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(creditChanged()), this, SLOT(creditChanged()));
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(creditChanged()), carteGraphicsScene, SLOT(creditChanged()));
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(viesChanged()), this, SLOT(viesChanged()));
        QObject::connect(carteGraphicsScene, SIGNAL(signalAfficherInfosDefenseur(Defenseur*)), this, SLOT(afficherInfosDefenseur(Defenseur*)));


        // Gestion de l'affichage des ennemis
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalAjouterEnnemi(Ennemi*)), this, SLOT(ajouterEnnemi(Ennemi*)));
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalEnnemiMort(Ennemi*)), this, SLOT(supprimerEnnemi(Ennemi*)));
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalEnnemiBut(Ennemi*)), this, SLOT(supprimerEnnemi(Ennemi*)));

        // Gestion de l'affichage des defenseurs
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalAjouterDefenseur(Defenseur*)), this, SLOT(ajouterDefenseur(Defenseur*)));
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalSupprimerDefenseur(Defenseur*)), this, SLOT(supprimerDefenseur(Defenseur*)));

        // Gestion de l'affichage des projectiles
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalAjouterProjectile(Projectile*)), this, SLOT(ajouterProjectile(Projectile*)));
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalSupprimerProjectile(Projectile*)), this, SLOT(supprimerProjectile(Projectile*)));

        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalPlusDeVies()), this, SLOT(plusDeVies()));
        QObject::connect(JoueurSingleton::getInstance(), SIGNAL(signalVagueTerminee()), this, SLOT(vagueTerminee()));

        QObject::connect(actionNouvelle_Partie, SIGNAL(triggered()), this, SLOT(lancerNouvellePartie()));





    }
SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
    QSplashScreen(pixmap, f)
{
    setAutoFillBackground(true);

    // set reference point, paddings
    int paddingLeft             = 14;
    int paddingTop              = 26;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 32;

    float fontFactor            = 1.0;

    // define text to place
    QString titleText       = tr("Flaxscript Core");
    QString versionText     = QString(tr("Version %1")).arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightTextBtc   = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
    QString copyrightTextDrk   = QChar(0xA9)+QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Dash Core developers"));
    QString copyrightTextChc   = QChar(0xA9)+QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Flaxscript Core developers"));
    QString testnetAddText  = QString(tr("[testnet]")); // define text to place as single text object

    QString font            = "Arial";

    // load the bitmap for writing some text over it
    QPixmap newPixmap;
    if(isTestNet) {
        newPixmap     = QPixmap(":/images/splash_testnet");
    }
    else {
        newPixmap     = QPixmap(":/images/splash");
    }

    QPainter pixPaint(&newPixmap);
    pixPaint.setPen(QColor(100,100,100));

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 28*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 28*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(paddingLeft,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));
    pixPaint.drawText(paddingLeft,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace,copyrightTextBtc);
    pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace+12,copyrightTextDrk);
    pixPaint.drawText(paddingLeft,paddingTop+titleCopyrightVSpace+24,copyrightTextChc);

    // draw testnet string if testnet is on
    if(isTestNet) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int testnetAddTextWidth  = fm.width(testnetAddText);
        pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,newPixmap.height()-25,testnetAddText);
    }

    pixPaint.end();

    this->setPixmap(newPixmap);

    subscribeToCoreSignals();
}
inline void PlacemarkPainter::drawLabelPixmap( VisiblePlacemark *mark )
{

    QPainter labelPainter;
    QPixmap labelPixmap;

    const GeoDataPlacemark *placemark = mark->placemark();
    Q_ASSERT(placemark);
    const GeoDataStyle* style = placemark->style();

    QString labelName = placemark->name();
    QRect  labelRect  = mark->labelRect().toRect();
    if ( !labelRect.isValid() ) {
        mark->setLabelPixmap( QPixmap() );
        return;
    }
    
    QFont  labelFont  = style->labelStyle().font();
    QColor labelColor = style->labelStyle().color();

    // FIXME: To be removed after MapTheme / KML refactoring
    if ( ( labelColor == Qt::black || labelColor == QColor( "#404040" ) )
	 && m_defaultLabelColor != Qt::black )
        labelColor = m_defaultLabelColor;

    LabelStyle labelStyle = Normal;
    if ( mark->selected() ) {
        labelStyle = Selected;
    } else if ( style->labelStyle().glow() ) {
        labelFont.setWeight(75);
        labelStyle = Glow;
    }


    // Due to some XOrg bug this requires a workaround via
    // QImage in some cases (at least with Qt 4.2).
    if ( !m_useXWorkaround ) {
        labelPixmap = QPixmap( labelRect.size() );
        labelPixmap.fill( Qt::transparent );

        labelPainter.begin( &labelPixmap );

        drawLabelText( labelPainter, labelName, labelFont, labelStyle, labelColor );

        labelPainter.end();
    } else {

        QImage image( labelRect.size(),
                      QImage::Format_ARGB32_Premultiplied );
        image.fill( 0 );

        labelPainter.begin( &image );

        drawLabelText( labelPainter, labelName, labelFont, labelStyle, labelColor );

        labelPainter.end();

        labelPixmap = QPixmap::fromImage( image );
    }

    mark->setLabelPixmap( labelPixmap );
}
Exemple #14
0
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
    QWidget(0, f), curAlignment(0)
{
    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;
    float devicePixelRatio      = 1.0;
#if QT_VERSION > 0x050100
    devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio();
#endif

    // define text to place
    QString titleText       = tr("dkcoin Core");
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QChar(0xA9)+QString(" 2015-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
    QString titleAddText    = networkStyle->getTitleAddText();

    QString font            = QApplication::font().toString();

    // create a bitmap according to device pixelratio
    QSize splashSize(480*devicePixelRatio,320*devicePixelRatio);
    pixmap = QPixmap(splashSize);

#if QT_VERSION > 0x050100
    // change to HiDPI if it makes sense
    pixmap.setDevicePixelRatio(devicePixelRatio);
#endif

    QPainter pixPaint(&pixmap);
    pixPaint.setPen(QColor(100,100,100));

    // draw a slighly radial gradient
    QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio);
    gradient.setColorAt(0, Qt::white);
    gradient.setColorAt(1, QColor(247,247,247));
    QRect rGradient(QPoint(0,0), splashSize);
    pixPaint.fillRect(rGradient, gradient);

    // draw the bitcoin icon, expected size of PNG: 1024x1024
    QRect rectIcon(QPoint(-150,-122), QSize(430,430));

    const QSize requiredSize(1024,1024);
    QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize));

    pixPaint.drawPixmap(rectIcon, icon);

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth  = fm.width(titleText);
    if(titleTextWidth > 160) {
        // strange font rendering, Arial probably not found
        fontFactor = 0.75;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is to long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    pixPaint.setFont(QFont(font, 10*fontFactor));
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);

    // draw additional text if special network
    if(!titleAddText.isEmpty()) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int titleAddTextWidth  = fm.width(titleAddText);
        pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText);
    }

    pixPaint.end();

    // Set window title
    setWindowTitle(titleText + " " + titleAddText);

    // Resize window and move to center of desktop, disallow resizing
    QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio));
    resize(r.size());
    setFixedSize(r.size());
    move(QApplication::desktop()->screenGeometry().center() - r.center());

    subscribeToCoreSignals();
}
void PQApplication::setFontWeight(int weight) {
    QFont font = QApplication::font();
    font.setWeight(weight);
    QApplication::setFont(font);
}
Exemple #16
0
static void generate_qpath( mlt_properties producer_properties )
{
	QPainterPath* qPath = static_cast<QPainterPath*>( mlt_properties_get_data( producer_properties, "_qpath", NULL ) );
	int outline = mlt_properties_get_int( producer_properties, "outline" );
	char* align = mlt_properties_get( producer_properties, "align" );
	char* style = mlt_properties_get( producer_properties, "style" );
	char* text = mlt_properties_get( producer_properties, "text" );
	char* encoding = mlt_properties_get( producer_properties, "encoding" );
	int pad = mlt_properties_get_int( producer_properties, "pad" );
	int offset = pad + ( outline / 2 );
	int width = 0;
	int height = 0;

	// Make the path empty
	*qPath = QPainterPath();

	// Get the strings to display
	QTextCodec *codec = QTextCodec::codecForName( encoding );
	QTextDecoder *decoder = codec->makeDecoder();
	QString s = decoder->toUnicode( text );
	delete decoder;
	QStringList lines = s.split( "\n" );

	// Configure the font
	QFont font;
	font.setPixelSize( mlt_properties_get_int( producer_properties, "size" ) );
	font.setFamily( mlt_properties_get( producer_properties, "family" ) );
	font.setWeight( ( mlt_properties_get_int( producer_properties, "weight" ) / 10 ) -1 );
	switch( style[0] )
	{
	case 'i':
	case 'I':
		font.setStyle( QFont::StyleItalic );
		break;
	}
	QFontMetrics fm( font );

	// Determine the text rectangle size
	height = fm.lineSpacing() * lines.size();
	for( int i = 0; i < lines.size(); ++i )
	{
		int line_width = fm.width( lines.at(i) );
		if( line_width > width ) width = line_width;
	}

	// Lay out the text in the path
	int x = 0;
	int y = fm.ascent() + 1 + offset;
	for( int i = 0; i < lines.size(); ++i )
	{
		QString line = lines.at(i);
		x = offset;
		switch( align[0] )
		{
			default:
			case 'l':
			case 'L':
				break;
			case 'c':
			case 'C':
				x += ( width - fm.width( line ) ) / 2;
				break;
			case 'r':
			case 'R':
				x += width - fm.width( line );
				break;
		}
		qPath->addText( x, y, font, line );
		y += fm.lineSpacing();
	}

	// Account for outline and pad
	width += offset * 2;
	height += offset * 2;
	// Sanity check
	if( width == 0 ) width = 1;
	if( height == 0 ) height = 1;
	mlt_properties_set_int( producer_properties, "meta.media.width", width );
	mlt_properties_set_int( producer_properties, "meta.media.height", height );
}
void RssListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyledItemDelegate::paint(painter,option,index);

    painter->save();

    QFont font = QApplication::font();
    QFont SubFont = QApplication::font();
    QFont dateFont = QApplication::font();

    //font.setPixelSize(font.weight()+);
    font.setBold(true);
    SubFont.setWeight(SubFont.weight()-2);
    QFontMetrics fm(font);
    QFontMetrics dfm(dateFont);

    QIcon icon = qvariant_cast<QIcon>(index.data(IconRole));
    QString headerText = qvariant_cast<QString>(index.data(HeaderTextRole));
    QString subText = qvariant_cast<QString>(index.data(DescriptionRole));
    QString dateText = qvariant_cast<QString>(index.data(DateRole));

    QSize iconsize = icon.actualSize(option.decorationSize);

    QRect headerRect = option.rect;
    QRect subheaderRect = option.rect;
    QRect iconRect = subheaderRect;
    QRect dateRect = subheaderRect;

    iconRect.setRight(iconsize.width()+30);
    iconRect.setTop(iconRect.top()+5);
    headerRect.setLeft(iconRect.right());
    headerRect.setTop(headerRect.top()+5);
    headerRect.setBottom(headerRect.top()+fm.height());

    int dateWidth = 0;
    if(!dateText.isEmpty()) {
        dateWidth = dfm.width(dateText) + 5;
        dateRect.setLeft(iconRect.right());
        dateRect.setTop(headerRect.bottom()+17);
    }


    subheaderRect.setLeft(iconRect.right() + dateWidth);
    subheaderRect.setTop(headerRect.bottom()+17);


    //painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height()));
    painter->drawPixmap(QPoint(iconRect.left()+iconsize.width()/2+2,iconRect.top()+iconsize.height()/2+3),icon.pixmap(iconsize.width(),iconsize.height()));

    painter->setFont(font);
    painter->drawText(headerRect,headerText);


    painter->setFont(SubFont);
    painter->drawText(subheaderRect.left(),subheaderRect.top(),subText);

    if(dateWidth) {
        painter->setFont(dateFont);
        painter->drawText(dateRect.left(), dateRect.top(), dateText);
    }

    painter->restore();

}
Exemple #18
0
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  QRect screenGeometry = QApplication::desktop()->screenGeometry();
  int ret = -1;
  char *buf;
  int window_x, window_y; // posX, posY
  int window_w, window_h; // width, height
  const char *window_font; // font family
  int window_fs, window_fw; // font size, weight
  int window_is; // icon size
  bool fs;

  // Processing command line arguments
  buf = getCmd(argv, argv + argc, "--help");
  if (buf)
  {
    cout << "Application selector usage:\n"
            "    app-selector [OPTION]... < [ITEM FILE]\n"
            "\nwhere options include:\n"
            "    --fullscreen                 use the entire screen.\n"
            "    --geometry WxH               size of window.\n"
            "    --font fontname              font family name.\n"
            "    --font-size size             font point size.\n"
            "    --font-weight weight         font weight.\n"
            "    --icon-size size             icon size.\n"
            "\nStructure of JSON file :\n"
            "[\n  {\n"
            "    \"name\": <string>, /* Friendly name of application       */\n"
            "    \"exec\": <string>, /* Command line or any data as output */\n"
            "    \"icon\": <string>  /* Icon path                          */\n"
            "  }, ...\n"
            "]\n";
    return 0;
  }
  buf = getCmdOption(argv, argv + argc, "--fullscreen");
  if (buf)
    fs = true;
  else
    fs = false;
  buf = getCmdOption(argv, argv + argc, "--geometry");
  if (!buf || sscanf(buf, "%ix%i", &window_w, &window_h) != 2)
  {
    window_x = 0;
    window_y = 0;
    window_w = screenGeometry.width();
    window_h = screenGeometry.height();
  }
  else
  {
      window_x = (screenGeometry.width() - window_w) / 2;
      window_y = (screenGeometry.height() - window_h) / 2;
  }
  buf = getCmdOption(argv, argv + argc, "--font");
  if (!buf)
    window_font = WINDOW_DFLT_FONT_FAMILY;
  else
    window_font = buf;
  buf = getCmdOption(argv, argv + argc, "--font-size");
  if (!buf || sscanf(buf, "%i", &window_fs) != 1)
  {
    window_fs = WINDOW_DFLT_FONT_POINT_SIZE;
  }
  buf = getCmdOption(argv, argv + argc, "--font-weight");
  if (!buf || sscanf(buf, "%i", &window_fw) != 1)
  {
    window_fw = WINDOW_DFLT_FONT_WEIGHT;
  }
  buf = getCmdOption(argv, argv + argc, "--icon-size");
  if (!buf || sscanf(buf, "%i", &window_is) != 1)
  {
    window_is = WINDOW_DFLT_ICON_SIZE;
  }

  vitem v;
  readJsonFromStream(&cin, v);

  MainWindow window;

  // Setup our window size and position
  window.resize(window_w, window_h);
  window.move(window_x, window_y);

  // Setup our font face, size and weight
  QFont font;
  font.setFamily(QString::fromUtf8(window_font));
  font.setPointSize(window_fs);
  font.setBold(false);
  font.setWeight(window_fw);
  window.setFont(font);

  // Setup our icon size
  window.setIconSize(QSize(window_is, window_is));

  for (vitem::iterator it = v.begin(); it != v.end(); ++it)
    window.AddItem(*it);

  if (fs)
    window.showFullScreen();
  else
    window.show();
  window.activateWindow();

  ret = a.exec();

  if (ret == 0)
  {
    int selection = window.GetSelected();
    if (selection >= 0)
    {
      Item item = v.at(selection);
      cout << item.execCmd.toStdString();
      cout << "\n";
    }
  }

  return ret;
}
Exemple #19
0
QFont KConfigBase::readFontEntry(const char *pKey, const QFont *pDefault) const
{
    QFont aRetFont;

    QString aValue = readEntry(pKey);
    if(!aValue.isNull())
    {
        if(aValue.contains(',') > 5)
        {
            // KDE3 and upwards entry
            if(!aRetFont.fromString(aValue) && pDefault)
                aRetFont = *pDefault;
        }
        else
        {
            // backward compatibility with older font formats
            // ### remove KDE 3.1 ?
            // find first part (font family)
            int nIndex = aValue.find(',');
            if(nIndex == -1)
            {
                if(pDefault)
                    aRetFont = *pDefault;
                return aRetFont;
            }
            aRetFont.setFamily(aValue.left(nIndex));

            // find second part (point size)
            int nOldIndex = nIndex;
            nIndex = aValue.find(',', nOldIndex + 1);
            if(nIndex == -1)
            {
                if(pDefault)
                    aRetFont = *pDefault;
                return aRetFont;
            }

            aRetFont.setPointSize(aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toInt());

            // find third part (style hint)
            nOldIndex = nIndex;
            nIndex = aValue.find(',', nOldIndex + 1);

            if(nIndex == -1)
            {
                if(pDefault)
                    aRetFont = *pDefault;
                return aRetFont;
            }

            aRetFont.setStyleHint((QFont::StyleHint)aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toUInt());

            // find fourth part (char set)
            nOldIndex = nIndex;
            nIndex = aValue.find(',', nOldIndex + 1);

            if(nIndex == -1)
            {
                if(pDefault)
                    aRetFont = *pDefault;
                return aRetFont;
            }

            QString chStr = aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1);
            // find fifth part (weight)
            nOldIndex = nIndex;
            nIndex = aValue.find(',', nOldIndex + 1);

            if(nIndex == -1)
            {
                if(pDefault)
                    aRetFont = *pDefault;
                return aRetFont;
            }

            aRetFont.setWeight(aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toUInt());

            // find sixth part (font bits)
            uint nFontBits = aValue.right(aValue.length() - nIndex - 1).toUInt();

            aRetFont.setItalic(nFontBits & 0x01);
            aRetFont.setUnderline(nFontBits & 0x02);
            aRetFont.setStrikeOut(nFontBits & 0x04);
            aRetFont.setFixedPitch(nFontBits & 0x08);
            aRetFont.setRawMode(nFontBits & 0x20);
        }
    }
    else
    {
        if(pDefault)
            aRetFont = *pDefault;
    }

    return aRetFont;
}
void
GcWindow::paintEvent(QPaintEvent * /*event*/)
{
    static QPixmap closeImage = QPixmap(":images/toolbar/popbutton.png");
    static QPixmap aluBar = QPixmap(":images/aluBar.png");
    static QPixmap aluBarDark = QPixmap(":images/aluBarDark.png");
    static QPixmap aluLight = QPixmap(":images/aluLight.jpg");
    static QPixmap carbon = QPixmap(":images/carbon.jpg");
    static QPalette defaultPalette;


    // setup a painter and the area to paint
    QPainter painter(this);
    // background light gray for now?
    QRect all(0,0,width(),height());
    painter.fillRect(all, property("color").value<QColor>());

    if (contentsMargins().top() > 0) {

        // fill in the title bar
        QRect bar(0,0,width(),contentsMargins().top());
        if (contentsMargins().top() < 25) {
        QColor bg;
        if (property("active").toBool() == true) {
            bg = GColor(CTILEBARSELECT);
            painter.drawPixmap(bar, aluBar);
        } else {
            bg = GColor(CTILEBAR);
            painter.drawPixmap(bar, aluBarDark);
        }
        } else {
            painter.setPen(Qt::darkGray);
            painter.drawRect(QRect(0,0,width()-1,height()-1));
        }

        // heading
        QFont font;
        font.setPointSize((contentsMargins().top()/2)+2);
        font.setWeight(QFont::Bold);
        painter.setFont(font);
        QString subtitle = property("subtitle").toString();
        QString title = property("title").toString();
        QString heading = subtitle != "" ? subtitle : title;

        // embossed...
        QRect shad = bar;
        shad.setY(bar.y()+2);
        //shad.setX(bar.x()+2);
        painter.setPen(QColor(255,255,255,180));
        painter.drawText(shad, heading, Qt::AlignVCenter | Qt::AlignCenter);

        painter.setPen(QColor(0,0,0,200));
        painter.drawText(bar, heading, Qt::AlignVCenter | Qt::AlignCenter);

        // border
        painter.setBrush(Qt::NoBrush);
        if (underMouse()) {

            QPixmap sized = closeImage.scaled(QSize(contentsMargins().top()-6,
                                                    contentsMargins().top()-6));
            //painter.drawPixmap(width()-3-sized.width(), 3, sized.width(), sized.height(), sized);

        } else {
            painter.setPen(Qt::darkGray);
            //painter.drawRect(QRect(0,0,width()-1,height()-1)); //XXX pointless
        }
    } else {
        // is this a layout manager?
        // background light gray for now?
        QRect all(0,0,width(),height());
        if (property("isManager").toBool() == true) {
            //painter.drawTiledPixmap(all, carbon);
            painter.fillRect(all, QColor("#B3B4BA"));
        } else {
            //painter.drawTiledPixmap(all, aluLight);
        }
    }
}
Exemple #21
0
// Quartz Paint magic goes here.
void QuartzClient::paintEvent( QPaintEvent* )
{
	// Never paint if the pixmaps have not been created
	if (!quartz_initialized)
		return;

	const bool maxFull = (maximizeMode()==MaximizeFull) && !options()->moveResizeMaximizedWindows();

	QColorGroup g;
    QPainter p(widget());

    // Obtain widget bounds.
    QRect r(widget()->rect());
    int x = r.x();
    int y = r.y();
    int x2 = r.width() - 1;
    int y2 = r.height() - 1;
    int w  = r.width();
    int h  = r.height();

    // Draw part of the frame that is the title color

	if( coloredFrame )
    	g = options()->colorGroup(ColorTitleBar, isActive());
	else
		g = options()->colorGroup(ColorFrame, isActive());

    // Draw outer highlights and lowlights
    p.setPen( g.light().light(120) );
    p.drawLine( x, y, x2-1, y );
    p.drawLine( x, y+1, x, y2-1 );
    p.setPen( g.dark().light(120) );
    p.drawLine( x2, y, x2, y2 );
    p.drawLine( x, y2, x2, y2 );

    // Fill out the border edges
	QColor frameColor;
	if ( coloredFrame)
		frameColor = g.background().light(130);
	else
		frameColor = g.background();
	if (borderSize > 2) {
		p.fillRect(x+1, y+1, w-2, borderSize-2, frameColor); // top
		if (!maxFull) {
			p.fillRect(x+1, y+h-(borderSize-1), w-2, borderSize-2, frameColor); // bottom
			p.fillRect(x+1, y+borderSize-1, borderSize-1, h-2*(borderSize-1), frameColor); // left
			p.fillRect(x+w-(borderSize), y+borderSize-1, borderSize-1, h-2*(borderSize-1), frameColor); // right
		}
	}

    // Draw a frame around the wrapped widget.
    p.setPen( g.background() );
	if (maxFull) {
		p.drawLine(x+1, y+titleHeight+(borderSize-1), w-2, y+titleHeight+(borderSize-1));
	} else {
		p.drawRect( x+(borderSize-1), y+titleHeight+(borderSize-1), w-2*(borderSize-1), h-titleHeight-2*(borderSize-1) );
	}

	// Drawing this extra line removes non-drawn areas when shaded
	p.drawLine( x+borderSize, y2-borderSize, x2-borderSize, y2-borderSize);

    // Highlight top corner
    p.setPen( g.light().light(160) );
    p.drawPoint( x, y );
    p.setPen( g.light().light(140) );
    p.drawPoint( x+1, y );
    p.drawPoint( x, y+1 );

    // Draw the title bar.
    // ===================
    int r_x, r_y, r_x2, r_y2;
    widget()->rect().coords(&r_x, &r_y, &r_x2, &r_y2);
    const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
    const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
    const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
    const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
    const int ttlHeight = layoutMetric(LM_TitleHeight);
    const int titleEdgeBottomBottom = r_y+titleEdgeTop+ttlHeight+titleEdgeBottom-1;
    r = QRect(r_x+titleEdgeLeft+buttonsLeftWidth(), r_y+titleEdgeTop,
              r_x2-titleEdgeRight-buttonsRightWidth()-(r_x+titleEdgeLeft+buttonsLeftWidth()),
              titleEdgeBottomBottom-(r_y+titleEdgeTop) );

    // Obtain titlebar blend colours
    QColor c1 = options()->color(ColorTitleBar, isActive() ).light(130);
    QColor c2 = options()->color(ColorTitleBlend, isActive() );

    // Create a disposable pixmap buffer for the titlebar
    KPixmap* titleBuffer = new KPixmap;
    titleBuffer->resize( maxFull?w-2:(w-2*(borderSize-1)), titleHeight );

    QPainter p2( titleBuffer, this );

	// subtract titleBlocks pixmap width and some
	int rightoffset = r.x()+r.width()-titleBlocks->width()-borderSize;

    p2.fillRect( 0, 0, w, r.height(), c1 );
    p2.fillRect( rightoffset, 0, maxFull?w-rightoffset:w-rightoffset-2*(borderSize-1), r.height(), c2 );

    // 8 bit displays will be a bit dithered, but they still look ok.
    if ( isActive() )
		p2.drawPixmap( rightoffset, 0, *titleBlocks );
	else
		p2.drawPixmap( rightoffset, 0, *ititleBlocks );

	// Draw the title text on the pixmap, and with a smaller font
	// for toolwindows than the default.
	QFont fnt;
	if ( largeButtons ) {
		fnt = options()->font(true, false); // font not small
	} else {
		fnt = options()->font(true, true); // font small
		fnt.setWeight( QFont::Normal ); // and disable bold
	}
    p2.setFont( fnt );

    p2.setPen( options()->color(ColorFont, isActive() ));
    p2.drawText(r.x()+4-borderSize, 0, r.width()-3, r.height(),
                AlignLeft | AlignVCenter, caption() );
    p2.end();

    p.drawPixmap( maxFull?1:borderSize-1, borderSize-1, *titleBuffer );

    delete titleBuffer;
}
Exemple #22
0
void ZDvidSynapse::display(ZPainter &painter, int slice, EDisplayStyle option,
                           neutube::EAxis sliceAxis) const
{
  bool visible = true;
  int z = painter.getZ(slice);

  if (slice < 0) {
    visible = isProjectionVisible();
  } else {
    visible = isSliceVisible(z, sliceAxis);
  }

  double radius = getRadius(z, sliceAxis);

  ZIntPoint center = m_position;
  center.shiftSliceAxis(sliceAxis);

  bool isFocused = (z == center.getZ());


  if (visible) {
    QPen pen;

    QColor color = getColor();

    double alpha = 1.0;
    if (option == SKELETON) {
      alpha = 0.1;
    }

    if (!isFocused) {
      alpha *= radius / m_radius;
      alpha *= alpha * 0.5;
      alpha += 0.1;  
    }
    color.setAlphaF(alpha * color.alphaF());

    pen.setColor(color);

    painter.setPen(pen);

    painter.setBrush(Qt::NoBrush);
    if (isFocused) {
      int x = center.getX();
      int y = center.getY();
      painter.drawLine(QPointF(x - 1, y), QPointF(x + 1, y));
      painter.drawLine(QPointF(x, y - 1), QPointF(x, y + 1));

      if (getStatus() == STATUS_DUPLICATED) {
        painter.drawEllipse(
              QPointF(center.getX(), center.getY()), 1, 1);
      }
    }
    if (radius > 0.0) {
      double oldWidth = pen.widthF();
      QColor oldColor = pen.color();
      if (getKind() == EKind::KIND_POST_SYN) {
        if (option != SKELETON) {
          pen.setWidthF(oldWidth + 1.0);
        }
        if (isSelected()) {
          pen.setColor(QColor(255, 0, 255, oldColor.alpha()));
        }
      } else {
        if (isSelected()) {
          pen.setWidthF(pen.widthF() + 1.0);
        }
      }

      painter.setPen(pen);
      painter.drawEllipse(QPointF(center.getX(), center.getY()),
                          radius, radius);
      pen.setWidthF(oldWidth);
      pen.setColor(oldColor);
    }
//    QString decorationText;

    if (isVerified()) {
      //        decorationText = "U";
      color.setRgb(0, 0, 0);

      if (isSelected()) {
        if (getKind() == EKind::KIND_PRE_SYN) {
          color.setRgb(0, 255, 0);
          size_t index = 0;
          for (std::vector<bool>::const_iterator iter = m_isPartnerVerified.begin();
               iter != m_isPartnerVerified.end(); ++iter, ++index) {
            bool verified = *iter;
            if (m_partnerKind[index] == EKind::KIND_POST_SYN) {
              if (!verified) {
                color.setRgb(0, 0, 0);
                break;
              }
            }
          }
        }
      }

      color.setAlphaF(alpha);
      pen.setColor(color);
      pen.setWidthF(pen.widthF() + 0.5);
      painter.setPen(pen);
      double margin = 0.5;
      painter.drawLine(QPointF(center.getX(), center.getY() + radius - margin),
                       QPointF(center.getX() + radius - margin, center.getY()));
      painter.drawLine(QPointF(center.getX(), center.getY() + radius - margin),
                       QPointF(center.getX() - radius + margin, center.getY()));
    }


    double conf  = getConfidence();
    if (conf < 1.0) {
//      double lineWidth = radius * conf * 0.5 + 1.0;
      double lineWidth = radius * 0.5;
      double red = 1.0 - conf;
      double green = conf;
      QColor color;
      color.setRedF(red);
      if (getKind() == ZDvidAnnotation::EKind::KIND_POST_SYN) {
        color.setBlueF(green);
      } else {
        color.setGreenF(green);
      }
      color.setAlphaF(alpha);
      painter.setPen(color);
      double x = center.getX();
      double y = center.getY();
      /*
      painter.drawLine(QPointF(x - lineWidth, y),
                       QPointF(x + lineWidth, y));
                       */
      int startAngle = 0;
      int spanAngle = iround((1.0 - conf) * 180) * 16;
      painter.drawArc(QRectF(QPointF(x - lineWidth, y - lineWidth),
                             QPointF(x + lineWidth, y + lineWidth)),
                      startAngle, spanAngle);
//      painter.drawEllipse(QPointF(x, y), lineWidth, lineWidth);

//      decorationText += QString(".%1").arg(iround(conf * 10.0));
    }

#if 0
    int height = iround(getRadius() * 1.5);
    int width = decorationText.size() * height;

    if (decorationText !=   m_textDecoration.text()) {
      m_textDecoration.setText(decorationText);
      m_textDecoration.setTextWidth(width);
    }

    if (!decorationText.isEmpty()) {
      QFont font;
      font.setPixelSize(height);
      font.setWeight(QFont::Light);
      font.setStyleStrategy(QFont::PreferMatch);
      painter.setFont(font);

      QColor oldColor = painter.getPen().color();
      QColor color = QColor(0, 0, 0);
      color.setAlphaF(alpha);
      QPen pen = painter.getPen();
      pen.setColor(color);
      painter.setPen(pen);
      painter.drawStaticText(center.getX() - height / 2, center.getY(),
                             m_textDecoration);
//      painter.drawText(center.getX() - height / 2, center.getY(), width, height,
//                       Qt::AlignLeft, decorationText);
      painter.setPen(oldColor);
    }
#endif
  }


  QPen pen;
  pen.setCosmetic(m_usingCosmeticPen);

  bool drawingBoundBox = false;
  bool drawingArrow = false;
  if (isSelected()) {
    if (visible) {
      drawingBoundBox = true;
    } else {
      drawingArrow = true;
    }

    QColor color;
    color.setRgb(255, 255, 0, 255);
    pen.setColor(color);
    pen.setCosmetic(true);
  } else if (hasVisualEffect(neutube::display::Sphere::VE_BOUND_BOX)) {
    drawingBoundBox = true;
    pen.setStyle(Qt::SolidLine);
    pen.setCosmetic(m_usingCosmeticPen);
  }

  if (drawingBoundBox) {
    QRectF rect;
    double halfSize = m_radius;
    if (m_usingCosmeticPen) {
      halfSize += 0.5;
    }
    rect.setLeft(center.getX() - halfSize);
    rect.setTop(center.getY() - halfSize);
    rect.setWidth(halfSize * 2);
    rect.setHeight(halfSize * 2);

    painter.setBrush(Qt::NoBrush);
    pen.setWidthF(pen.widthF() * 0.5);
    if (visible) {
      pen.setStyle(Qt::SolidLine);
    } else {
      pen.setStyle(Qt::DotLine);
    }
    painter.setPen(pen);
    painter.drawRect(rect);
  }

  if (drawingArrow) {
    painter.setPen(pen);
    QRectF rect(center.getX() - m_radius, center.getY() - m_radius,
                m_radius + m_radius, m_radius + m_radius);

//    pen.setStyle(Qt::SolidLine);
//    pen.setColor(GetArrowColor(isVerified()));
//    painter.setPen(pen);
    QPointF ptArray[4];
    //      double s = 5.0;
    if (z > center.getZ()) {
      ZFlyEmMisc::MakeTriangle(rect, ptArray, neutube::ECardinalDirection::NORTH);
      /*
        pt[0] = QPointF(rect.center().x() - rect.width() / s,
                        rect.top() + rect.height() / s);
        pt[1] = QPointF(rect.center().x(),
                        rect.top() - rect.height() / s);
        pt[2] = QPointF(rect.center().x() + rect.width() / s,
                        rect.top() + rect.height() / s);
*/
    } else {
      ZFlyEmMisc::MakeTriangle(rect, ptArray, neutube::ECardinalDirection::SOUTH);
      /*
        pt[0] = QPointF(rect.center().x() - rect.width() / s,
                        rect.bottom() - rect.height() / s);
        pt[1] = QPointF(rect.center().x(),
                        rect.bottom() + rect.height() / s);
        pt[2] = QPointF(rect.center().x() + rect.width() / s,
                        rect.bottom() - rect.height() / s);
                        */
    }
    painter.drawPolyline(ptArray, 4);
//      painter.drawLine(pt[0], pt[1]);
//      painter.drawLine(pt[1], pt[2]);
//      painter.drawLine(pt[0], pt[2]);
  }

  if (isSelected()) {
    pen.setStyle(Qt::SolidLine);

    size_t index = 0;
    if (m_isPartnerVerified.size() == m_partnerHint.size()) {
      for (std::vector<ZIntPoint>::const_iterator iter = m_partnerHint.begin();
           iter != m_partnerHint.end(); ++iter, ++index) {
        pen.setColor(GetArrowColor(m_isPartnerVerified[index]));
        painter.setPen(pen);

        const ZIntPoint &partner = *iter;
        double len = 0.0;
        if (partner.getZ() < z && getPosition().getZ() < z) {
          len = -1.0;
        } else if (partner.getZ() > z && getPosition().getZ() > z) {
          len = 1.0;
        }

        if (len != 0.0) {
          QPointF pt[3];
          pt[0].setX(partner.getX() - len);
          pt[0].setY(partner.getY() - len);

          pt[1].setX(partner.getX() + len);
          pt[1].setY(partner.getY() - len);

          pt[2].setX(partner.getX());
          pt[2].setY(partner.getY() + len);


          painter.drawLine(pt[0], pt[1]);
          painter.drawLine(pt[1], pt[2]);
          painter.drawLine(pt[0], pt[2]);
        }

        if (m_partnerKind[index] == EKind::KIND_POST_SYN) {
          ZDvidSynapse partnerSynapse;
          partnerSynapse.setKind(EKind::KIND_POST_SYN);
          partnerSynapse.setStatus(m_partnerStatus[index]);
          partnerSynapse.setPosition(partner);
          partnerSynapse.setDefaultColor();
          partnerSynapse.setDefaultRadius();
          painter.save();
          partnerSynapse.display(painter, slice, ZStackObject::NORMAL, sliceAxis);
          painter.restore();
        }
      }
    }

    index = 0;
    for (std::vector<ZIntPoint>::const_iterator iter = m_partnerHint.begin();
         iter != m_partnerHint.end(); ++iter, ++index) {
      ZLineSegmentObject line;
      line.setStartPoint(getPosition());
      line.setEndPoint(*iter);
      if (getKind() == EKind::KIND_PRE_SYN && m_partnerKind[index] == EKind::KIND_PRE_SYN) {
        line.setColor(QColor(0, 255, 255));
        line.setFocusColor(QColor(0, 255, 255));
      } else if (m_partnerKind[index] == EKind::KIND_UNKNOWN) {
        line.setColor(QColor(164, 0, 0));
        line.setFocusColor(QColor(255, 0, 0));
      } else {
        line.setColor(QColor(255, 255, 0));
        line.setFocusColor(QColor(255, 0, 255));
      }

      line.setVisualEffect(neutube::display::Line::VE_LINE_PROJ);
      line.display(painter, slice, option, sliceAxis);

      /*
      ZIntPoint pos = *iter;
      painter.drawLine(getPosition().getX(), getPosition().getY(),
                       pos.getX(), pos.getY());
                       */
    }
  }
}
void
PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
    Q_ASSERT( item );

    QStyleOptionViewItemV4 opt = option;
    prepareStyleOption( &opt, index, item );
    opt.text.clear();

    qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );

    if ( m_view->header()->visualIndex( index.column() ) > 0 )
        return;

    const query_ptr q = item->query()->displayQuery();
    unsigned int duration = q->duration();
    QString artist = q->artist();
    QString track = q->track();
    QPixmap avatar;
    QString upperText, lowerText;

    painter->save();
    {
        QRect r = opt.rect.adjusted( 3, 6, 0, -6 );

        // Paint Now Playing Speaker Icon
        if ( item->isPlaying() )
        {
            QPixmap nowPlayingIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker );
            QRect npr = r.adjusted( 3, r.height() / 2 - nowPlayingIcon.height() / 2, 18 - r.width(), -r.height() / 2 + nowPlayingIcon.height() / 2 );
            nowPlayingIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() );
            painter->drawPixmap( npr, nowPlayingIcon );
            r.adjust( 22, 0, 0, 0 );
        }

        QFont figureFont = opt.font;
        figureFont.setPixelSize( 18 );
        figureFont.setWeight( 99 );

        QFont boldFont = opt.font;
        boldFont.setPixelSize( 15 );
        boldFont.setWeight( 99 );

        QFont smallBoldFont = opt.font;
        smallBoldFont.setPixelSize( 12 );
        smallBoldFont.setWeight( 60 );

        QFont durationFont = opt.font;
        durationFont.setPixelSize( 12 );
        durationFont.setWeight( 80 );

        if ( index.row() == 0 )
        {
            figureFont.setPixelSize( 36 );
            boldFont.setPixelSize( 26 );
            smallBoldFont.setPixelSize( 22 );
        }
        else if ( index.row() == 1 )
        {
            figureFont.setPixelSize( 30 );
            boldFont.setPixelSize( 22 );
            smallBoldFont.setPixelSize( 18 );
        }
        else if ( index.row() == 2 )
        {
            figureFont.setPixelSize( 24 );
            boldFont.setPixelSize( 18 );
            smallBoldFont.setPixelSize( 14 );
        }
        else if ( index.row() >= 10 )
        {
            boldFont.setPixelSize( 12 );
            smallBoldFont.setPixelSize( 11 );
        }

        QRect figureRect = r.adjusted( 0, 0, -option.rect.width() + 60 - 6 + r.left(), 0 );
        painter->setFont( figureFont );
        painter->setPen( option.palette.text().color().lighter( 450 ) );
        painter->drawText( figureRect, QString::number( index.row() + 1 ), m_centerOption );
        painter->setPen( opt.palette.text().color() );

        QRect pixmapRect = r.adjusted( figureRect.width() + 6, 0, -option.rect.width() + figureRect.width() + option.rect.height() - 6 + r.left(), 0 );

        if ( !m_pixmaps.contains( index ) )
        {
            m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), pixmapRect.size(), TomahawkUtils::ScaledCover, false ) ) );
            _detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<PlaylistChartItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) );
            closure->setAutoDelete( false );
        }

        const QPixmap pixmap = m_pixmaps[ index ]->currentPixmap();
        painter->drawPixmap( pixmapRect, pixmap );

        r.adjust( pixmapRect.width() + figureRect.width() + 18, 1, -28, 0 );
        QRect leftRect = r.adjusted( 0, 0, -48, 0 );
        QRect rightRect = r.adjusted( r.width() - 40, 0, 0, 0 );

        painter->setFont( boldFont );
        QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() );
        painter->drawText( leftRect, text, m_topOption );

        painter->setFont( smallBoldFont );
        text = painter->fontMetrics().elidedText( artist, Qt::ElideRight, leftRect.width() );
        painter->drawText( index.row() >= 10 ? leftRect : leftRect.adjusted( 0, painter->fontMetrics().height() + 6, 0, 0 ), text, index.row() >= 10 ? m_bottomOption : m_topOption );

        if ( duration > 0 )
        {
            painter->setFont( durationFont );
            text = painter->fontMetrics().elidedText( TomahawkUtils::timeToString( duration ), Qt::ElideRight, rightRect.width() );
            painter->drawText( rightRect, text, m_centerRightOption );
        }
    }
SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle) :
    QWidget(0, f), curAlignment(0), m_node(node)
{
    // set reference point, paddings
    int paddingRight            = 50;
    int paddingTop              = 50;
    int titleVersionVSpace      = 17;
    int titleCopyrightVSpace    = 40;

    float fontFactor            = 1.0;
    float devicePixelRatio      = 1.0;
#if QT_VERSION > 0x050100
    devicePixelRatio = static_cast<QGuiApplication*>(QCoreApplication::instance())->devicePixelRatio();
#endif

    // define text to place
    QString titleText       = tr(PACKAGE_NAME);
    QString versionText     = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
    QString copyrightText   = QString::fromUtf8(CopyrightHolders(strprintf("\xc2\xA9 %u-%u ", 2009, COPYRIGHT_YEAR)).c_str());
    QString titleAddText    = networkStyle->getTitleAddText();

    QString font            = QApplication::font().toString();

    // create a bitmap according to device pixelratio
    QSize splashSize(480*devicePixelRatio,320*devicePixelRatio);
    pixmap = QPixmap(splashSize);

#if QT_VERSION > 0x050100
    // change to HiDPI if it makes sense
    pixmap.setDevicePixelRatio(devicePixelRatio);
#endif

    QPainter pixPaint(&pixmap);
    pixPaint.setPen(QColor(100,100,100));

    // draw a slightly radial gradient
    QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio);
    gradient.setColorAt(0, Qt::white);
    gradient.setColorAt(1, QColor(247,247,247));
    QRect rGradient(QPoint(0,0), splashSize);
    pixPaint.fillRect(rGradient, gradient);

    // draw the machinecoin icon, expected size of PNG: 1024x1024
    QRect rectIcon(QPoint(-150,-122), QSize(430,430));

    const QSize requiredSize(1024,1024);
    QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize));

    pixPaint.drawPixmap(rectIcon, icon);

    // check font size and drawing with
    pixPaint.setFont(QFont(font, 33*fontFactor));
    QFontMetrics fm = pixPaint.fontMetrics();
    int titleTextWidth = fm.width(titleText);
    if (titleTextWidth > 176) {
        fontFactor = fontFactor * 176 / titleTextWidth;
    }

    pixPaint.setFont(QFont(font, 33*fontFactor));
    fm = pixPaint.fontMetrics();
    titleTextWidth  = fm.width(titleText);
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText);

    pixPaint.setFont(QFont(font, 15*fontFactor));

    // if the version string is too long, reduce size
    fm = pixPaint.fontMetrics();
    int versionTextWidth  = fm.width(versionText);
    if(versionTextWidth > titleTextWidth+paddingRight-10) {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        titleVersionVSpace -= 5;
    }
    pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);

    // draw copyright stuff
    {
        pixPaint.setFont(QFont(font, 10*fontFactor));
        const int x = pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight;
        const int y = paddingTop+titleCopyrightVSpace;
        QRect copyrightRect(x, y, pixmap.width() - x - paddingRight, pixmap.height() - y);
        pixPaint.drawText(copyrightRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, copyrightText);
    }

    // draw additional text if special network
    if(!titleAddText.isEmpty()) {
        QFont boldFont = QFont(font, 10*fontFactor);
        boldFont.setWeight(QFont::Bold);
        pixPaint.setFont(boldFont);
        fm = pixPaint.fontMetrics();
        int titleAddTextWidth  = fm.width(titleAddText);
        pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText);
    }

    pixPaint.end();

    // Set window title
    setWindowTitle(titleText + " " + titleAddText);

    // Resize window and move to center of desktop, disallow resizing
    QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio));
    resize(r.size());
    setFixedSize(r.size());
    move(QApplication::desktop()->screenGeometry().center() - r.center());

    subscribeToCoreSignals();
    installEventFilter(this);
}
Exemple #25
0
void Font::Create(const FontParameters &fp)
{
    Release();

    QFont *f = new QFont();

    QFont::StyleStrategy strategy;

    switch (fp.extraFontFlag & SC_EFF_QUALITY_MASK)
    {
    case SC_EFF_QUALITY_NON_ANTIALIASED:
        strategy = QFont::NoAntialias;
        break;

    case SC_EFF_QUALITY_ANTIALIASED:
        strategy = QFont::PreferAntialias;
        break;

    default:
        strategy = QFont::PreferDefault;
    }

#if defined(Q_OS_MAC)
#if QT_VERSION >= 0x040700
    strategy = static_cast<QFont::StyleStrategy>(strategy | QFont::ForceIntegerMetrics);
#else
#warning "Correct handling of QFont metrics requires Qt v4.7.0 or later"
#endif
#endif

    f->setStyleStrategy(strategy);

    // If name of the font begins with a '-', assume, that it is an XLFD.
    if (fp.faceName[0] == '-')
    {
        f->setRawName(fp.faceName);
    }
    else
    {
        f->setFamily(fp.faceName);
        f->setPointSizeF(fp.size);

        // See if the Qt weight has been passed via the back door.   Otherwise
        // map Scintilla weights to Qt weights ensuring that the SC_WEIGHT_*
        // values get mapped to the correct QFont::Weight values.
        int qt_weight;

        if (fp.weight < 0)
            qt_weight = -fp.weight;
        else if (fp.weight <= 200)
            qt_weight = QFont::Light;
        else if (fp.weight <= QsciScintillaBase::SC_WEIGHT_NORMAL)
            qt_weight = QFont::Normal;
        else if (fp.weight <= 600)
            qt_weight = QFont::DemiBold;
        else if (fp.weight <= 850)
            qt_weight = QFont::Bold;
        else
            qt_weight = QFont::Black;

        f->setWeight(qt_weight);

        f->setItalic(fp.italic);
    }

    fid = f;
}
bool PreferencesDialog::Save()
{
    bool recalc_events = false;
    bool needs_restart = false;

    if (ui->ahiGraphZeroReset->isChecked() != profile->cpap->AHIReset()) { recalc_events = true; }

    if (ui->useSquareWavePlots->isChecked() != profile->appearance->squareWavePlots()) {
        needs_restart = true;
    }

    if ((profile->session->daySplitTime() != ui->timeEdit->time()) ||
            (profile->session->combineCloseSessions() != ui->combineSlider->value()) ||
            (profile->session->ignoreShortSessions() != ui->IgnoreSlider->value())) {
        needs_restart = true;
    }

    if (profile->session->lockSummarySessions() != ui->LockSummarySessionSplitting->isChecked()) {
        needs_restart = true;
    }

    if (profile->cpap->userEventPieChart() != ui->showUserFlagsInPie->isChecked()) {
        // lazy.. fix me
        needs_restart = true;
    }

    int rdi_set = profile->general->calculateRDI() ? 1 : 0;
    if (rdi_set != ui->eventIndexCombo->currentIndex()) {
        //recalc_events=true;
        needs_restart = true;
    }

    if ((profile->general->prefCalcMiddle() != ui->prefCalcMiddle->currentIndex())
            || (profile->general->prefCalcMax() != ui->prefCalcMax->currentIndex())
            || (profile->general->prefCalcPercentile() != ui->prefCalcPercentile->value())) {
        needs_restart = true;
    }

    if (profile->cpap->leakRedline() != ui->leakRedlineSpinbox->value()) {
        recalc_events = true;
    }


    if (profile->cpap->userEventFlagging() &&
            (profile->cpap->userEventDuration() != ui->apneaDuration->value() ||
             profile->cpap->userEventDuration2() != ui->apneaDuration2->value() ||
             profile->cpap->userEventDuplicates() != ui->userEventDuplicates->isChecked() ||
             profile->cpap->userFlowRestriction2() != ui->apneaFlowRestriction2->value() ||
             profile->cpap->userFlowRestriction() != ui->apneaFlowRestriction->value())) {
        recalc_events = true;
    }

    // Restart if turning user event flagging on/off
    if (profile->cpap->userEventFlagging() != ui->customEventGroupbox->isChecked()) {
        // if (profile->cpap->userEventFlagging()) {
        // Don't bother recalculating, just switch off
        needs_restart = true;
        //} else
        recalc_events = true;
    }

    if (profile->session->compressSessionData() != ui->compressSessionData->isChecked()) {
        recalc_events = true;
    }

    if (recalc_events) {
        if (p_profile->countDays(MT_CPAP, p_profile->FirstDay(), p_profile->LastDay()) > 0) {
            if (QMessageBox::question(this, tr("Data Reindex Required"),
                                      tr("A data reindexing proceedure is required to apply these changes. This operation may take a couple of minutes to complete.\n\nAre you sure you want to make these changes?"),
                                      QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
                return false;
            }
        } else { recalc_events = false; }
    } else if (needs_restart) {
        if (QMessageBox::question(this, tr("Restart Required"),
                                  tr("One or more of the changes you have made will require this application to be restarted,\nin order for these changes to come into effect.\n\nWould you like do this now?"),
                                  QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
            return false;
        }
    }

    schema::channel[OXI_SPO2].setLowerThreshold(ui->oxiDesaturationThreshold->value());
    schema::channel[OXI_Pulse].setLowerThreshold(ui->flagPulseBelow->value());
    schema::channel[OXI_Pulse].setUpperThreshold(ui->flagPulseAbove->value());


    profile->cpap->setUserEventPieChart(ui->showUserFlagsInPie->isChecked());
    profile->session->setLockSummarySessions(ui->LockSummarySessionSplitting->isChecked());

    profile->appearance->setAllowYAxisScaling(ui->allowYAxisScaling->isChecked());
    profile->appearance->setGraphTooltips(ui->graphTooltips->isChecked());

    profile->appearance->setAntiAliasing(ui->useAntiAliasing->isChecked());
    profile->appearance->setUsePixmapCaching(ui->usePixmapCaching->isChecked());
    profile->appearance->setSquareWavePlots(ui->useSquareWavePlots->isChecked());
    profile->appearance->setGraphSnapshots(ui->enableGraphSnapshots->isChecked());
    profile->appearance->setLineThickness(float(ui->lineThicknessSlider->value()) / 2.0);

    profile->general->setSkipEmptyDays(ui->skipEmptyDays->isChecked());

    profile->general->setTooltipTimeout(ui->tooltipTimeoutSlider->value() * 50);
    profile->general->setScrollDampening(ui->scrollDampeningSlider->value() * 10);

    profile->general->setShowUnknownFlags(ui->showUnknownFlags->isChecked());
    profile->session->setMultithreading(ui->enableMultithreading->isChecked());
    profile->session->setCacheSessions(ui->cacheSessionData->isChecked());
    profile->session->setPreloadSummaries(ui->preloadSummaries->isChecked());
    profile->appearance->setAnimations(ui->animationsAndTransitionsCheckbox->isChecked());

    profile->cpap->setShowLeakRedline(ui->showLeakRedline->isChecked());
    profile->cpap->setLeakRedline(ui->leakRedlineSpinbox->value());

    profile->cpap->setShowComplianceInfo(ui->complianceCheckBox->isChecked());
    profile->cpap->setComplianceHours(ui->complianceHours->value());

    if (ui->graphHeight->value() != profile->appearance->graphHeight()) {
        profile->appearance->setGraphHeight(ui->graphHeight->value());
        mainwin->getDaily()->ResetGraphLayout();
        mainwin->getOverview()->ResetGraphLayout();
    }

    profile->general->setPrefCalcMiddle(ui->prefCalcMiddle->currentIndex());
    profile->general->setPrefCalcMax(ui->prefCalcMax->currentIndex());
    profile->general->setPrefCalcPercentile(ui->prefCalcPercentile->value());

    profile->general->setCalculateRDI((ui->eventIndexCombo->currentIndex() == 1));
    profile->session->setBackupCardData(ui->createSDBackups->isChecked());
    profile->session->setCompressBackupData(ui->compressSDBackups->isChecked());
    profile->session->setCompressSessionData(ui->compressSessionData->isChecked());

    profile->session->setCombineCloseSessions(ui->combineSlider->value());
    profile->session->setIgnoreShortSessions(ui->IgnoreSlider->value());
    profile->session->setDaySplitTime(ui->timeEdit->time());
    profile->session->setIgnoreOlderSessions(ui->ignoreOlderSessionsCheck->isChecked());
    profile->session->setIgnoreOlderSessionsDate(ui->ignoreOlderSessionsDate->date());

    int s = ui->clockDriftHours->value() * 3600 + ui->clockDriftMinutes->value() * 60 + ui->clockDriftSeconds->value();
    profile->cpap->setClockDrift(s);

    profile->appearance->setOverlayType((OverlayDisplayType)ui->overlayFlagsCombo->currentIndex());
    profile->appearance->setOverviewLinechartMode((OverviewLinechartModes)ui->overviewLinecharts->currentIndex());

    profile->oxi->setSpO2DropPercentage(ui->spo2Drop->value());
    profile->oxi->setSpO2DropDuration(ui->spo2DropTime->value());
    profile->oxi->setPulseChangeBPM(ui->pulseChange->value());
    profile->oxi->setPulseChangeDuration(ui->pulseChangeTime->value());
    profile->oxi->setOxiDiscardThreshold(ui->oxiDiscardThreshold->value());

    profile->cpap->setAHIWindow(ui->ahiGraphWindowSize->value());
    profile->cpap->setAHIReset(ui->ahiGraphZeroReset->isChecked());

    profile->cpap->setAutoImport(ui->automaticImport->isChecked());

    profile->cpap->setUserEventFlagging(ui->customEventGroupbox->isChecked());

    profile->cpap->setResyncFromUserFlagging(ui->resyncMachineDetectedEvents->isChecked());
    profile->cpap->setUserEventDuration(ui->apneaDuration->value());
    profile->cpap->setUserFlowRestriction(ui->apneaFlowRestriction->value());
    profile->cpap->setUserEventDuration2(ui->apneaDuration2->value());
    profile->cpap->setUserFlowRestriction2(ui->apneaFlowRestriction2->value());

    profile->cpap->setUserEventDuplicates(ui->userEventDuplicates->isChecked());



    if ((ui->calculateUnintentionalLeaks->isChecked() != profile->cpap->calculateUnintentionalLeaks())
      || (fabs((ui->maskLeaks4Slider->value()/10.0)-profile->cpap->custom4cmH2OLeaks())>.1)
      || (fabs((ui->maskLeaks20Slider->value()/10.0)-profile->cpap->custom20cmH2OLeaks())>.1)) {
           recalc_events = true;
    }

    profile->cpap->setCalculateUnintentionalLeaks(ui->calculateUnintentionalLeaks->isChecked());
    profile->cpap->setCustom4cmH2OLeaks(double(ui->maskLeaks4Slider->value()) / 10.0f);
    profile->cpap->setCustom20cmH2OLeaks(double(ui->maskLeaks20Slider->value()) / 10.0f);

    PREF[STR_GEN_SkipLogin] = ui->skipLoginScreen->isChecked();

    PREF[STR_GEN_UpdatesAutoCheck] = ui->automaticallyCheckUpdates->isChecked();
    PREF[STR_GEN_UpdateCheckFrequency] = ui->updateCheckEvery->value();
    PREF[STR_PREF_AllowEarlyUpdates] = ui->allowEarlyUpdates->isChecked();
    PREF[STR_PREF_AllowEventRenaming] = ui->allowEventRenaming->isChecked();


    PREF["Fonts_Application_Name"] = ui->applicationFont->currentText();
    PREF["Fonts_Application_Size"] = ui->applicationFontSize->value();
    PREF["Fonts_Application_Bold"] = ui->applicationFontBold->isChecked();
    PREF["Fonts_Application_Italic"] = ui->applicationFontItalic->isChecked();


    PREF["Fonts_Graph_Name"] = ui->graphFont->currentText();
    PREF["Fonts_Graph_Size"] = ui->graphFontSize->value();
    PREF["Fonts_Graph_Bold"] = ui->graphFontBold->isChecked();
    PREF["Fonts_Graph_Italic"] = ui->graphFontItalic->isChecked();

    PREF["Fonts_Title_Name"] = ui->titleFont->currentText();
    PREF["Fonts_Title_Size"] = ui->titleFontSize->value();
    PREF["Fonts_Title_Bold"] = ui->titleFontBold->isChecked();
    PREF["Fonts_Title_Italic"] = ui->titleFontItalic->isChecked();

    PREF["Fonts_Big_Name"] = ui->bigFont->currentText();
    PREF["Fonts_Big_Size"] = ui->bigFontSize->value();
    PREF["Fonts_Big_Bold"] = ui->bigFontBold->isChecked();
    PREF["Fonts_Big_Italic"] = ui->bigFontItalic->isChecked();

    QFont font = ui->applicationFont->currentFont();
    font.setPointSize(ui->applicationFontSize->value());
    font.setWeight(ui->applicationFontBold->isChecked() ? QFont::Bold : QFont::Normal);
    font.setItalic(ui->applicationFontItalic->isChecked());
    QApplication::setFont(font);
    mainwin->menuBar()->setFont(font);

    *defaultfont = ui->graphFont->currentFont();
    defaultfont->setPointSize(ui->graphFontSize->value());
    defaultfont->setWeight(ui->graphFontBold->isChecked() ? QFont::Bold : QFont::Normal);
    defaultfont->setItalic(ui->graphFontItalic->isChecked());

    *mediumfont = ui->titleFont->currentFont();
    mediumfont->setPointSize(ui->titleFontSize->value());
    mediumfont->setWeight(ui->titleFontBold->isChecked() ? QFont::Bold : QFont::Normal);
    mediumfont->setItalic(ui->titleFontItalic->isChecked());

    *bigfont = ui->bigFont->currentFont();
    bigfont->setPointSize(ui->bigFontSize->value());
    bigfont->setWeight(ui->bigFontBold->isChecked() ? QFont::Bold : QFont::Normal);
    bigfont->setItalic(ui->bigFontItalic->isChecked());


    saveChanInfo();
    saveWaveInfo();
    //qDebug() << "TODO: Save channels.xml to update channel data";

    PREF.Save();
    p_profile->Save();

    if (recalc_events) {
        // send a signal instead?
        mainwin->reprocessEvents(needs_restart);
    } else if (needs_restart) {
        p_profile->removeLock();
        mainwin->RestartApplication();
    } else {
        mainwin->getDaily()->LoadDate(mainwin->getDaily()->getDate());
        // Save early.. just in case..
        mainwin->getDaily()->graphView()->SaveSettings("Daily");
        mainwin->getOverview()->graphView()->SaveSettings("Overview");
    }

    return true;
}
//---------------------------------------------------------------------------
//  makePixmap
//
//! Create a pixmap representation of the rack.
//
//! @return the pixmap
//---------------------------------------------------------------------------
QPixmap
CrosswordGameRackWidget::makePixmap() const
{
    QPixmap pixmap (getRackSize());
    QPainter painter (&pixmap);

    // FIXME: most of this is duplicated between BoardWidget and here
    QColor backgroundColor = BACKGROUND_COLOR;
    QPalette backgroundPalette;
    backgroundPalette.setColor(QPalette::Light,
                               backgroundColor.light(SQUARE_SHADE_VALUE));
    backgroundPalette.setColor(QPalette::Mid, backgroundColor);
    backgroundPalette.setColor(QPalette::Dark,
                               backgroundColor.dark(SQUARE_SHADE_VALUE));

    for (int i = 0; i < NUM_TILES; ++i) {
        QRect rect (i * COLUMN_WIDTH, 0, COLUMN_WIDTH, ROW_HEIGHT);
        painter.setPen(backgroundColor);
        painter.setBrush(backgroundColor);
        painter.drawRect(rect);

        qDrawShadePanel(&painter, rect, backgroundPalette, false,
                        SQUARE_SHADE_PANEL_WIDTH);


        if (i >= letters.length())
            continue;

        QRect tileRect(i * COLUMN_WIDTH + TILE_MARGIN, TILE_MARGIN,
                       COLUMN_WIDTH - 2 * TILE_MARGIN -
                       SQUARE_SHADE_PANEL_WIDTH,
                       ROW_HEIGHT - 2 * TILE_MARGIN -
                       SQUARE_SHADE_PANEL_WIDTH);

        QColor color = TILE_COLOR;
        QPalette palette;
        palette.setColor(QPalette::Light,
                         color.light(TILE_SHADE_VALUE));
        palette.setColor(QPalette::Mid, color);
        palette.setColor(QPalette::Dark,
                         color.dark(TILE_SHADE_VALUE));

        painter.setPen(QColor("black"));
        painter.setBrush(color);
        painter.drawRect(tileRect);
        qDrawShadePanel(&painter, tileRect, palette, false,
                        TILE_SHADE_PANEL_WIDTH);

        QFont tileFont = font();
        tileFont.setPixelSize(LETTER_HEIGHT);
        tileFont.setWeight(QFont::Black);
        painter.setFont(tileFont);

        switch (playerNum) {
            case 1:  color = PLAYER1_LETTER_COLOR; break;
            case 2:  color = PLAYER2_LETTER_COLOR; break;
            default: color = DEFAULT_LETTER_COLOR; break;
        }
        painter.setPen(QPen(color));

        QChar letter = letters[i];
        if (letter == '?') {
            QPen pen (color);
            pen.setWidth(1);
            painter.setPen(pen);
            painter.setBrush(Qt::NoBrush);
            QRect blankRect(rect.x() + BLANK_SQUARE_MARGIN,
                            rect.y() + BLANK_SQUARE_MARGIN,
                            rect.width() - 2 * BLANK_SQUARE_MARGIN -
                            SQUARE_SHADE_PANEL_WIDTH - 1,
                            rect.height() - 2 * BLANK_SQUARE_MARGIN -
                            SQUARE_SHADE_PANEL_WIDTH - 1);
            painter.drawRect(blankRect);
        }

        else {
            painter.drawText(rect, Qt::AlignCenter, letter);
        }
    }

    return pixmap;
}
Exemple #28
0
void WaveformRenderMark::generateMarkImage(WaveformMark& mark) {
    // Load the pixmap from file -- takes precedence over text.
    if (mark.m_pixmapPath != "") {
        QString path =  mark.m_pixmapPath;
        QImage image = QImage(path);
        // If loading the image didn't fail, then we're done. Otherwise fall
        // through and render a label.
        if (!image.isNull()) {
            mark.m_image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
            WImageStore::correctImageColors(&mark.m_image);
            return;
        }
    }

    QPainter painter;

    int labelRectWidth = 0;
    int labelRectHeight = 0;

    // If no text is provided, leave m_markImage as a null image
    if (!mark.m_text.isNull()) {
        //QFont font("Bitstream Vera Sans");
        //QFont font("Helvetica");
        QFont font; // Uses the application default
        font.setPointSize(10);
        font.setStretch(100);

        QFontMetrics metrics(font);

        //fixed margin ...
        QRect wordRect = metrics.tightBoundingRect(mark.m_text);
        const int marginX = 1;
        const int marginY = 1;
        wordRect.moveTop(marginX + 1);
        wordRect.moveLeft(marginY + 1);
        wordRect.setWidth(wordRect.width() + (wordRect.width())%2);
        //even wordrect to have an even Image >> draw the line in the middle !

        labelRectWidth = wordRect.width() + 2*marginX + 4;
        labelRectHeight = wordRect.height() + 2*marginY + 4 ;

        QRectF labelRect(0, 0,
                (float)labelRectWidth, (float)labelRectHeight);

        mark.m_image = QImage(labelRectWidth+1,
                m_waveformRenderer->getHeight(),
                QImage::Format_ARGB32_Premultiplied);

        if (mark.m_align == Qt::AlignBottom) {
            labelRect.moveBottom(mark.m_image.height()-1);
        }

        // Fill with transparent pixels
        mark.m_image.fill(QColor(0,0,0,0).rgba());

        painter.begin(&mark.m_image);
        painter.setRenderHint(QPainter::TextAntialiasing);

        painter.setWorldMatrixEnabled(false);

        //draw the label rect
        QColor rectColor = mark.m_color;
        rectColor.setAlpha(150);
        painter.setPen(mark.m_color);
        painter.setBrush(QBrush(rectColor));
        painter.drawRoundedRect(labelRect, 2.0, 2.0);
        //painter.drawRect(labelRect);

        //draw text
        painter.setBrush(QBrush(QColor(0,0,0,0)));
        font.setWeight(75);
        painter.setFont(font);
        painter.setPen(mark.m_textColor);
        painter.drawText(labelRect, Qt::AlignCenter, mark.m_text);

        //draw line
        QColor lineColor = mark.m_color;
        lineColor.setAlpha(200);
        painter.setPen(lineColor);

        float middle = mark.m_image.width() / 2.0;
        //Default line align top
        float lineTop = labelRectHeight + 1;
        float lineBottom = mark.m_image.height();

        if (mark.m_align == Qt::AlignBottom) {
            lineTop = 0.0;
            lineBottom = mark.m_image.height() - labelRectHeight - 1;
        }

        painter.drawLine(middle, lineTop, middle, lineBottom);

        //other lines to increase contrast
        painter.setPen(QColor(0,0,0,120));
        painter.drawLine(middle - 1, lineTop, middle - 1, lineBottom);
        painter.drawLine(middle + 1, lineTop, middle + 1, lineBottom);

    }
    else //no text draw triangle
    {
        float triangleSize = 9.0;
        mark.m_image = QImage(labelRectWidth+1,
                m_waveformRenderer->getHeight(),
                QImage::Format_ARGB32_Premultiplied);
        mark.m_image.fill(QColor(0,0,0,0).rgba());

        painter.begin(&mark.m_image);
        painter.setRenderHint(QPainter::TextAntialiasing);

        painter.setWorldMatrixEnabled(false);

        QColor triangleColor = mark.m_color;
        triangleColor.setAlpha(140);
        painter.setPen(QColor(0,0,0,0));
        painter.setBrush(QBrush(triangleColor));

        //vRince: again don't ask about the +-0.1 0.5 ...
        // just to make it nice in Qt ...

        QPolygonF triangle;
        triangle.append(QPointF(0.5,0));
        triangle.append(QPointF(triangleSize+0.5,0));
        triangle.append(QPointF(triangleSize*0.5 + 0.1, triangleSize*0.5));

        painter.drawPolygon(triangle);

        triangle.clear();
        triangle.append(QPointF(0.0,mark.m_image.height()));
        triangle.append(QPointF(triangleSize+0.5,mark.m_image.height()));
        triangle.append(QPointF(triangleSize*0.5 + 0.1, mark.m_image.height() - triangleSize*0.5 - 2.1));

        painter.drawPolygon(triangle);

        //TODO vRince duplicated code make a method
        //draw line
        QColor lineColor = mark.m_color;
        lineColor.setAlpha(140);
        painter.setPen(lineColor);
        float middle = mark.m_image.width() / 2.0;

        float lineTop = triangleSize * 0.5 + 1;
        float lineBottom = mark.m_image.height() - triangleSize * 0.5 - 1;

        painter.drawLine(middle, lineTop, middle, lineBottom);

        //other lines to increase contrast
        painter.setPen(QColor(0,0,0,100));
        painter.drawLine(middle - 1, lineTop, middle - 1, lineBottom);
        painter.drawLine(middle + 1, lineTop, middle + 1, lineBottom);
    }
}
Exemple #29
0
void QFontProto::setWeight(int weight)
{
  QFont *item = qscriptvalue_cast<QFont*>(thisObject());
  if (item)
    item->setWeight(weight);
}
Exemple #30
0
void Editor::setupUi(QMainWindow *Editor)
{
  if (Editor->objectName().isEmpty())
    Editor->setObjectName(QStringLiteral("Editor"));
  Editor->setWindowModality(Qt::NonModal);
  Editor->setEnabled(true);
  Editor->resize(1680, 840);
  QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
  sizePolicy.setHorizontalStretch(0);
  sizePolicy.setVerticalStretch(0);
  sizePolicy.setHeightForWidth(Editor->sizePolicy().hasHeightForWidth());
  Editor->setSizePolicy(sizePolicy);
  Editor->setFocusPolicy(Qt::ClickFocus);
  Editor->setAutoFillBackground(false);
  Editor->setAnimated(true);
  actionLoad = new QAction(Editor);
  actionLoad->setObjectName(QStringLiteral("actionLoad"));
  actionSave = new QAction(Editor);
  actionSave->setObjectName(QStringLiteral("actionSave"));
  centralWidget = new QWidget(Editor);
  centralWidget->setObjectName(QStringLiteral("centralWidget"));
  tabWidget = new QTabWidget(centralWidget);
  tabWidget->setObjectName(QStringLiteral("tabWidget"));
  tabWidget->setGeometry(QRect(0, 50, 1671, 761));
  tabWidget->setLayoutDirection(Qt::LeftToRight);
  tabWidget->setTabShape(QTabWidget::Rounded);
  tabWidget->setTabsClosable(false);
  tabWidget->setMovable(true);
  tab = new QWidget();
  tab->setObjectName(QStringLiteral("tab"));
  gb_obj = new QGroupBox(tab);
  gb_obj->setObjectName(QStringLiteral("gb_obj"));
  gb_obj->setGeometry(QRect(20, 10, 251, 261));
  lbl_object_txt = new QLabel(gb_obj);
  lbl_object_txt->setObjectName(QStringLiteral("lbl_object_txt"));
  lbl_object_txt->setGeometry(QRect(40, 20, 101, 16));
  QFont font;
  font.setBold(true);
  font.setWeight(75);
  lbl_object_txt->setFont(font);
  label = new QLabel(gb_obj);
  label->setObjectName(QStringLiteral("label"));
  label->setGeometry(QRect(20, 40, 61, 16));
  QFont font1;
  font1.setUnderline(true);
  label->setFont(font1);
  le_obj_pos_x = new QLineEdit(gb_obj);
  le_obj_pos_x->setObjectName(QStringLiteral("le_obj_pos_x"));
  le_obj_pos_x->setGeometry(QRect(20, 60, 71, 21));
  label_2 = new QLabel(gb_obj);
  label_2->setObjectName(QStringLiteral("label_2"));
  label_2->setGeometry(QRect(10, 60, 20, 21));
  le_obj_pos_y = new QLineEdit(gb_obj);
  le_obj_pos_y->setObjectName(QStringLiteral("le_obj_pos_y"));
  le_obj_pos_y->setGeometry(QRect(20, 90, 71, 21));
  label_3 = new QLabel(gb_obj);
  label_3->setObjectName(QStringLiteral("label_3"));
  label_3->setGeometry(QRect(10, 90, 20, 21));
  le_obj_pos_z = new QLineEdit(gb_obj);
  le_obj_pos_z->setObjectName(QStringLiteral("le_obj_pos_z"));
  le_obj_pos_z->setGeometry(QRect(20, 120, 71, 21));
  label_4 = new QLabel(gb_obj);
  label_4->setObjectName(QStringLiteral("label_4"));
  label_4->setGeometry(QRect(10, 120, 20, 21));
  le_obj_rot_x = new QLineEdit(gb_obj);
  le_obj_rot_x->setObjectName(QStringLiteral("le_obj_rot_x"));
  le_obj_rot_x->setGeometry(QRect(20, 170, 71, 21));
  label_5 = new QLabel(gb_obj);
  label_5->setObjectName(QStringLiteral("label_5"));
  label_5->setGeometry(QRect(10, 170, 20, 21));
  le_obj_rot_z = new QLineEdit(gb_obj);
  le_obj_rot_z->setObjectName(QStringLiteral("le_obj_rot_z"));
  le_obj_rot_z->setGeometry(QRect(20, 230, 71, 21));
  le_obj_rot_y = new QLineEdit(gb_obj);
  le_obj_rot_y->setObjectName(QStringLiteral("le_obj_rot_y"));
  le_obj_rot_y->setGeometry(QRect(20, 200, 71, 21));
  label_6 = new QLabel(gb_obj);
  label_6->setObjectName(QStringLiteral("label_6"));
  label_6->setGeometry(QRect(10, 230, 20, 21));
  label_7 = new QLabel(gb_obj);
  label_7->setObjectName(QStringLiteral("label_7"));
  label_7->setGeometry(QRect(10, 200, 20, 21));
  label_8 = new QLabel(gb_obj);
  label_8->setObjectName(QStringLiteral("label_8"));
  label_8->setGeometry(QRect(20, 150, 61, 16));
  label_8->setFont(font1);
  rb_obj_apply_physic = new QRadioButton(gb_obj);
  rb_obj_apply_physic->setObjectName(QStringLiteral("rb_obj_apply_physic"));
  rb_obj_apply_physic->setGeometry(QRect(130, 170, 91, 17));
  rb_obj_physic_static = new QRadioButton(gb_obj);
  rb_obj_physic_static->setObjectName(QStringLiteral("rb_obj_physic_static"));
  rb_obj_physic_static->setGeometry(QRect(160, 190, 61, 17));
  rb_obj_fixed = new QRadioButton(gb_obj);
  rb_obj_fixed->setObjectName(QStringLiteral("rb_obj_fixed"));
  rb_obj_fixed->setGeometry(QRect(130, 150, 82, 17));
  rb_obj_visible = new QRadioButton(gb_obj);
  rb_obj_visible->setObjectName(QStringLiteral("rb_obj_visible"));
  rb_obj_visible->setGeometry(QRect(130, 210, 82, 17));
  rb_object_shadow_only = new QRadioButton(gb_obj);
  rb_object_shadow_only->setObjectName(QStringLiteral("rb_object_shadow_only"));
  rb_object_shadow_only->setGeometry(QRect(130, 230, 82, 17));
  pb_object_remove = new QPushButton(gb_obj);
  pb_object_remove->setObjectName(QStringLiteral("pb_object_remove"));
  pb_object_remove->setGeometry(QRect(130, 110, 75, 23));
  groupBox = new QGroupBox(tab);
  groupBox->setObjectName(QStringLiteral("groupBox"));
  groupBox->setGeometry(QRect(290, 10, 361, 741));
  lv_objects_chooser = new QListView(groupBox);
  lv_objects_chooser->setObjectName(QStringLiteral("lv_objects_chooser"));
  lv_objects_chooser->setGeometry(QRect(20, 220, 321, 471));
  pb_objects_add = new QPushButton(groupBox);
  pb_objects_add->setObjectName(QStringLiteral("pb_objects_add"));
  pb_objects_add->setGeometry(QRect(200, 30, 91, 23));
  f_objects_selected = new QFrame(groupBox);
  f_objects_selected->setObjectName(QStringLiteral("f_objects_selected"));
  f_objects_selected->setGeometry(QRect(20, 70, 151, 141));
  f_objects_selected->setAutoFillBackground(true);
  f_objects_selected->setFrameShape(QFrame::StyledPanel);
  f_objects_selected->setFrameShadow(QFrame::Raised);
  lbl_objectdb_txt = new QLabel(groupBox);
  lbl_objectdb_txt->setObjectName(QStringLiteral("lbl_objectdb_txt"));
  lbl_objectdb_txt->setGeometry(QRect(30, 40, 101, 16));
  lbl_objectdb_txt->setFont(font);
  tb_ojectdb_description = new QTextBrowser(groupBox);
  tb_ojectdb_description->setObjectName(QStringLiteral("tb_ojectdb_description"));
  tb_ojectdb_description->setGeometry(QRect(180, 70, 161, 141));
  groupBox_2 = new QGroupBox(tab);
  groupBox_2->setObjectName(QStringLiteral("groupBox_2"));
  groupBox_2->setGeometry(QRect(10, 280, 261, 471));
  lw_objects_active = new QListWidget(groupBox_2);
  lw_objects_active->setObjectName(QStringLiteral("lw_objects_active"));
  lw_objects_active->setGeometry(QRect(10, 20, 241, 401));
  tabWidget->addTab(tab, QString());
  tab_2 = new QWidget();
  tab_2->setObjectName(QStringLiteral("tab_2"));
  gb_light = new QGroupBox(tab_2);
  gb_light->setObjectName(QStringLiteral("gb_light"));
  gb_light->setGeometry(QRect(10, 10, 221, 261));
  lbl_light_txt = new QLabel(gb_light);
  lbl_light_txt->setObjectName(QStringLiteral("lbl_light_txt"));
  lbl_light_txt->setGeometry(QRect(10, 20, 101, 16));
  lbl_light_txt->setFont(font);
  label_9 = new QLabel(gb_light);
  label_9->setObjectName(QStringLiteral("label_9"));
  label_9->setGeometry(QRect(20, 40, 61, 16));
  label_9->setFont(font1);
  le_light_pos_x = new QLineEdit(gb_light);
  le_light_pos_x->setObjectName(QStringLiteral("le_light_pos_x"));
  le_light_pos_x->setGeometry(QRect(20, 60, 71, 21));
  label_10 = new QLabel(gb_light);
  label_10->setObjectName(QStringLiteral("label_10"));
  label_10->setGeometry(QRect(10, 60, 20, 21));
  le_light_pos_y = new QLineEdit(gb_light);
  le_light_pos_y->setObjectName(QStringLiteral("le_light_pos_y"));
  le_light_pos_y->setGeometry(QRect(20, 90, 71, 21));
  label_11 = new QLabel(gb_light);
  label_11->setObjectName(QStringLiteral("label_11"));
  label_11->setGeometry(QRect(10, 90, 20, 21));
  le_light_pos_z = new QLineEdit(gb_light);
  le_light_pos_z->setObjectName(QStringLiteral("le_light_pos_z"));
  le_light_pos_z->setGeometry(QRect(20, 120, 71, 21));
  label_12 = new QLabel(gb_light);
  label_12->setObjectName(QStringLiteral("label_12"));
  label_12->setGeometry(QRect(10, 120, 20, 21));
  le_light_rot_x = new QLineEdit(gb_light);
  le_light_rot_x->setObjectName(QStringLiteral("le_light_rot_x"));
  le_light_rot_x->setGeometry(QRect(20, 170, 71, 21));
  label_13 = new QLabel(gb_light);
  label_13->setObjectName(QStringLiteral("label_13"));
  label_13->setGeometry(QRect(10, 170, 20, 21));
  le_light_rot_z = new QLineEdit(gb_light);
  le_light_rot_z->setObjectName(QStringLiteral("le_light_rot_z"));
  le_light_rot_z->setGeometry(QRect(20, 230, 71, 21));
  le_light_rot_y = new QLineEdit(gb_light);
  le_light_rot_y->setObjectName(QStringLiteral("le_light_rot_y"));
  le_light_rot_y->setGeometry(QRect(20, 200, 71, 21));
  label_14 = new QLabel(gb_light);
  label_14->setObjectName(QStringLiteral("label_14"));
  label_14->setGeometry(QRect(10, 230, 20, 21));
  label_15 = new QLabel(gb_light);
  label_15->setObjectName(QStringLiteral("label_15"));
  label_15->setGeometry(QRect(10, 200, 20, 21));
  label_16 = new QLabel(gb_light);
  label_16->setObjectName(QStringLiteral("label_16"));
  label_16->setGeometry(QRect(20, 150, 61, 16));
  label_16->setFont(font1);
  sb_light_r = new QSpinBox(gb_light);
  sb_light_r->setObjectName(QStringLiteral("sb_light_r"));
  sb_light_r->setGeometry(QRect(140, 60, 41, 22));
  sb_light_g = new QSpinBox(gb_light);
  sb_light_g->setObjectName(QStringLiteral("sb_light_g"));
  sb_light_g->setGeometry(QRect(140, 90, 41, 22));
  sb_light_b = new QSpinBox(gb_light);
  sb_light_b->setObjectName(QStringLiteral("sb_light_b"));
  sb_light_b->setGeometry(QRect(140, 120, 41, 22));
  label_17 = new QLabel(gb_light);
  label_17->setObjectName(QStringLiteral("label_17"));
  label_17->setGeometry(QRect(120, 60, 20, 21));
  label_18 = new QLabel(gb_light);
  label_18->setObjectName(QStringLiteral("label_18"));
  label_18->setGeometry(QRect(120, 90, 20, 21));
  label_19 = new QLabel(gb_light);
  label_19->setObjectName(QStringLiteral("label_19"));
  label_19->setGeometry(QRect(120, 120, 20, 21));
  doubleSpinBox = new QDoubleSpinBox(gb_light);
  doubleSpinBox->setObjectName(QStringLiteral("doubleSpinBox"));
  doubleSpinBox->setGeometry(QRect(140, 170, 51, 22));
  label_20 = new QLabel(gb_light);
  label_20->setObjectName(QStringLiteral("label_20"));
  label_20->setGeometry(QRect(110, 150, 61, 16));
  label_20->setFont(font1);
  label_21 = new QLabel(gb_light);
  label_21->setObjectName(QStringLiteral("label_21"));
  label_21->setGeometry(QRect(110, 40, 61, 16));
  label_21->setFont(font1);
  lw_lights_active = new QListWidget(tab_2);
  lw_lights_active->setObjectName(QStringLiteral("lw_lights_active"));
  lw_lights_active->setGeometry(QRect(10, 280, 221, 231));
  groupBox_3 = new QGroupBox(tab_2);
  groupBox_3->setObjectName(QStringLiteral("groupBox_3"));
  groupBox_3->setGeometry(QRect(240, 10, 201, 101));
  cb_lights_type = new QComboBox(groupBox_3);
  cb_lights_type->setObjectName(QStringLiteral("cb_lights_type"));
  cb_lights_type->setGeometry(QRect(10, 30, 81, 22));
  pb_lights_add = new QPushButton(groupBox_3);
  pb_lights_add->setObjectName(QStringLiteral("pb_lights_add"));
  pb_lights_add->setGeometry(QRect(110, 30, 81, 23));
  rb_lights_cast_shadow = new QRadioButton(groupBox_3);
  rb_lights_cast_shadow->setObjectName(QStringLiteral("rb_lights_cast_shadow"));
  rb_lights_cast_shadow->setGeometry(QRect(10, 70, 82, 17));
  tabWidget->addTab(tab_2, QString());
  pb_scene_play = new QPushButton(centralWidget);
  pb_scene_play->setObjectName(QStringLiteral("pb_scene_play"));
  pb_scene_play->setGeometry(QRect(20, 10, 31, 23));
  pb_scene_pause = new QPushButton(centralWidget);
  pb_scene_pause->setObjectName(QStringLiteral("pb_scene_pause"));
  pb_scene_pause->setGeometry(QRect(70, 10, 31, 23));
  Editor->setCentralWidget(centralWidget);
  menuBar = new QMenuBar(Editor);
  menuBar->setObjectName(QStringLiteral("menuBar"));
  menuBar->setGeometry(QRect(0, 0, 1680, 21));
  menuSceneEditor = new QMenu(menuBar);
  menuSceneEditor->setObjectName(QStringLiteral("menuSceneEditor"));
  Editor->setMenuBar(menuBar);
  mainToolBar = new QToolBar(Editor);
  mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
  Editor->addToolBar(Qt::TopToolBarArea, mainToolBar);
  statusBar = new QStatusBar(Editor);
  statusBar->setObjectName(QStringLiteral("statusBar"));
  Editor->setStatusBar(statusBar);

  menuBar->addAction(menuSceneEditor->menuAction());
  menuSceneEditor->addAction(actionLoad);
  menuSceneEditor->addAction(actionSave);

  retranslateUi(Editor);

  tabWidget->setCurrentIndex(0);


  QObject::connect(pb_scene_pause, SIGNAL(clicked()), this, SLOT(on_pb_scene_pause_clicked()));
 // QMetaObject::connectSlotsByName(Editor);
} // setupUi