/** * Called when context menu on the contact list has been clicked. * Calls methods to respond to clicked action. * @brief MainWindow::contactsMenuClicked */ void MainWindow::contactsMenuClicked(QAction *action) { QString sel(ui->lstContacts->selectedItems().at(0)->data(Qt::DisplayRole).toString()); if(action->text().compare(STR_ADD_TO_CONVO) == 0) //Add contact to conversation { contextAddToConvo(sel); } if(action->text().compare(STR_REMOVE) == 0) //Remove contact from list { ui->lstContacts->takeItem(ui->lstContacts->currentRow()); controller->removeExtContact(sel); } if(action->text().compare(STR_BLOCK_UNBLK) == 0) //Block contact { // Indicate a blocked contact with grey text and strikethrough. QFont f = ui->lstContacts->selectedItems().at(0)->font(); if(f.strikeOut()) { ui->lstContacts->selectedItems().at(0)->setTextColor(Qt::black); controller->unblockContact(sel); } else { ui->lstContacts->selectedItems().at(0)->setTextColor(Qt::gray); controller->blockContact(sel); } f.setStrikeOut(!f.strikeOut()); ui->lstContacts->selectedItems().at(0)->setFont(f); } }
void FontEditor::update() { if (m_object) { QVariant valueFont = m_object ? m_object->property(m_fontPropertyName.toLatin1()) : QVariant(); setFont((valueFont.isValid() && valueFont.canConvert<QFont>()) ? valueFont.value<QFont>() : QFont()); int indexFont = m_object->metaObject()->indexOfProperty(m_fontPropertyName.toLatin1()); if (m_object->metaObject()->property(indexFont).hasNotifySignal()) { QMetaMethod signal = m_object->metaObject()->property(indexFont).notifySignal(); QMetaMethod slot = this->metaObject()->method(this->metaObject()->indexOfSlot("fontFromObjectProperty()")); connect(m_object, signal, this, slot, Qt::UniqueConnection); } QVariant currentColorVar = m_object->property(m_colorPropertyName.toLatin1()); ui->fontColor->setEnabled(currentColorVar.canConvert<QColor>()); } else if (m_objectList.count()) { QString family; qreal size = -1; bool bold = false; bool italic = false; bool strikeout = false; bool underline = false; bool fontFound = false; bool colorFound = false; foreach(QObject * object, m_objectList) { QVariant fontValue = object->property(m_fontPropertyName.toLatin1()); QVariant colorValue = object->property(m_colorPropertyName.toLatin1()); if (fontValue.isValid() && fontValue.canConvert<QFont>()) { QFont f = fontValue.value<QFont>(); if (!fontFound) { family = f.family(); size = f.pointSizeF(); bold = f.bold(); italic = f.italic(); strikeout = f.strikeOut(); underline = f.underline(); fontFound = true; } else { if (f.family() != family) family = QString(); if (f.pointSizeF() != size) size = -1; if (f.bold() != bold) bold = false; if (f.italic() != italic) italic = false; if (f.strikeOut() != strikeout) strikeout = false; if (f.underline() != underline) underline = false; } } if (!colorFound && colorValue.isValid() && colorValue.canConvert<QColor>()) { colorFound = true; } }
void KNFontDialog::setInitialFont(const QFont &font) { //Save the initial font as the result font. m_resultFont=font; //Set the font to previewer. m_previewer->setFont(font); //Sync the font size. syncFontSize(font.pointSizeF()); //Sync the font family. //Clear the filter of proxy model first. m_fontFamilyFilter->setFilterFixedString(""); //Find and select the font family. m_fontComboBox->setCurrentFont(font); QModelIndex fontProxyIndex= m_fontFamilyFilter->mapFromSource( m_fontComboBox->model()->index(m_fontComboBox->currentIndex(), 0)); m_fontFamilyList->setCurrentIndex(fontProxyIndex); m_fontFamilyList->scrollTo(fontProxyIndex); //Sync the font style. m_fontStyles[Bold]->setChecked(font.bold()); m_fontStyles[Italic]->setChecked(font.italic()); m_fontStyles[Underline]->setChecked(font.underline()); m_fontStyles[StrikeOut]->setChecked(font.strikeOut()); m_fontStyles[Kerning]->setChecked(font.kerning()); }
QFont stripStyleName(QFont &f, QFontDatabase &db) { const QString &styleName = f.styleName(); if (styleName.isEmpty()) { return f; } else { QFont g = (db.styleString(f) != styleName) ? db.font(f.family(), styleName, f.pointSize()) : QFont(f.family(), f.pointSize(), f.weight()); if (auto s = f.pixelSize() > 0) { g.setPixelSize(s); } g.setStyleHint(f.styleHint(), f.styleStrategy()); g.setStyle(f.style()); if (f.underline()) { g.setUnderline(true); } if (f.strikeOut()) { g.setStrikeOut(true); } if (f.fixedPitch()) { g.setFixedPitch(true); } return g; } }
void QgsFieldConditionalFormatWidget::setFormattingFromStyle( QgsConditionalStyle style ) { btnBackgroundColor->setColor( style.backgroundColor() ); btnTextColor->setColor( style.textColor() ); if ( !style.icon().isNull() ) { checkIcon->setChecked( true ); QIcon icon( style.icon() ); btnChangeIcon->setIcon( icon ); } else { checkIcon->setChecked( false ); btnChangeIcon->setIcon( QIcon() ); } if ( style.symbol() ) { mSymbol = style.symbol()->clone(); } else { mSymbol = 0; } QFont font = style.font(); mFontBoldBtn->setChecked( font.bold() ); mFontItalicBtn->setChecked( font.italic() ); mFontStrikethroughBtn->setChecked( font.strikeOut() ); mFontUnderlineBtn->setChecked( font.underline() ); mFontFamilyCmbBx->setFont( font ); }
bool QFontProto::strikeOut() const { QFont *item = qscriptvalue_cast<QFont*>(thisObject()); if (item) return item->strikeOut(); return false; }
void tst_QFont::resolve() { QFont font; font.setPointSize(font.pointSize() * 2); font.setItalic(false); font.setWeight(QFont::Normal); font.setUnderline(false); font.setStrikeOut(false); font.setOverline(false); font.setStretch(QFont::Unstretched); QFont font1; font1.setWeight(QFont::Bold); QFont font2 = font1.resolve(font); QVERIFY(font2.weight() == font1.weight()); QVERIFY(font2.pointSize() == font.pointSize()); QVERIFY(font2.italic() == font.italic()); QVERIFY(font2.underline() == font.underline()); QVERIFY(font2.overline() == font.overline()); QVERIFY(font2.strikeOut() == font.strikeOut()); QVERIFY(font2.stretch() == font.stretch()); QFont font3; font3.setStretch(QFont::UltraCondensed); QFont font4 = font3.resolve(font1).resolve(font); QVERIFY(font4.stretch() == font3.stretch()); QVERIFY(font4.weight() == font.weight()); QVERIFY(font4.pointSize() == font.pointSize()); QVERIFY(font4.italic() == font.italic()); QVERIFY(font4.underline() == font.underline()); QVERIFY(font4.overline() == font.overline()); QVERIFY(font4.strikeOut() == font.strikeOut()); QFont f1,f2,f3; f2.setPointSize(45); f3.setPointSize(55); QFont f4 = f1.resolve(f2); QCOMPARE(f4.pointSize(), 45); f4 = f4.resolve(f3); QCOMPARE(f4.pointSize(), 55); }
WFont transform(const QFont& font) { WFont f(font.family().toStdString(), font.pointSize(), font.weight(), font.italic()); f.setUnderline(font.underline()); f.setStrikeOut(font.strikeOut()); f.setKerning(font.kerning()); return f; }
/*! * Set the format properties from the given \a font. */ void Format::setFont(const QFont &font) { setFontName(font.family()); setFontSize(font.pointSize()); setFontBold(font.bold()); setFontItalic(font.italic()); setFontUnderline(font.underline() ? FontUnderlineSingle : FontUnderlineNone); setFontStrikeOut(font.strikeOut()); }
void EmfPaintEngine::drawTextItem ( const QPointF & p, const QTextItem & textItem ) { setClipping(); SetBkMode( metaDC, TRANSPARENT ); QFont f = textItem.font(); QFontMetrics fm(f); HFONT wfont = CreateFontA(fm.height() - 1, fm.averageCharWidth(), 0, 0, 10*f.weight(), f.italic(), f.underline (), f.strikeOut(), DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, f.family().toAscii().data()); SelectObject( metaDC, wfont); QColor colour = painter()->pen().color(); SetTextColor( metaDC, RGB(colour.red(), colour.green(), colour.blue())); QString text = textItem.text(); int size = text.size(); QMatrix m = painter()->worldMatrix(); XFORM xf; xf.eM11 = m.m11(); xf.eM12 = m.m12(); xf.eM21 = m.m21(); xf.eM22 = m.m22(); xf.eDx = m.dx(); xf.eDy = m.dy(); SetWorldTransform(metaDC, &xf); #ifdef Q_WS_WIN wchar_t *wtext = (wchar_t *)malloc(size*sizeof(wchar_t)); if (!wtext){ qWarning("EmfEngine: Not enough memory in drawTextItem()."); return; } size = text.toWCharArray(wtext); TextOutW(metaDC, qRound(p.x()), qRound(p.y() - 0.85*fm.height()), wtext, size); free(wtext); #else TextOutA(metaDC, qRound(p.x()), qRound(p.y() - 0.85*fm.height()), text.toLocal8Bit().data(), size); #endif xf.eM11 = 1.0; xf.eM12 = 0.0; xf.eM21 = 0.0; xf.eM22 = 1.0; xf.eDx = 0.0; xf.eDy = 0.0; SetWorldTransform(metaDC, &xf); resetClipping(); DeleteObject(wfont); }
QString Setting::fontToString(QFont f) { #ifdef Q_WS_X11_xxx return f.rawName(); #else return f.family() + "-" + QString::number(f.pointSize()) + "-" + QString::number(f.weight()) + "-" + QString::number(f.italic()) + "-" + QString::number(f.underline()) + "-" + QString::number(f.strikeOut()); #endif }
void QFontDialog::setFont( const QFont &f ) { d->family = f.family(); d->style = d->fdb.styleString( f ); d->size = f.pointSize(); if ( d->size == -1 ) { QFontInfo fi( f ); d->size = fi.pointSize(); } d->strikeout->setChecked( f.strikeOut() ); d->underline->setChecked( f.underline() ); updateFamilies(); }
void ConvertDialogTest::convert_addText_fontPx() { EffectsScrollArea *effectsScrollArea = convertDialog->effectsScrollArea; QGroupBox *textGroupBox = effectsScrollArea->textGroupBox; textGroupBox->setChecked(true); QLineEdit *textLineEdit = effectsScrollArea->textLineEdit; QString testText = "Test Text"; textLineEdit->setText(testText); QComboBox *fontSizeComboBox = effectsScrollArea->textFontSizeComboBox; int px = 1; fontSizeComboBox->setCurrentIndex(px); QFont font = effectsScrollArea->textFontComboBox->currentFont(); int fontSize = 20; font.setPixelSize(fontSize); font.setBold(true); font.setItalic(true); font.setUnderline(true); font.setStrikeOut(true); effectsScrollArea->textFontSizeSpinBox->setValue(fontSize); effectsScrollArea->textBoldPushButton->setChecked(font.bold()); effectsScrollArea->textItalicPushButton->setChecked(font.italic()); effectsScrollArea->textUnderlinePushButton->setChecked(font.underline()); effectsScrollArea->textStrikeOutPushButton->setChecked(font.strikeOut()); QColor color = Qt::green; effectsScrollArea->textColorFrame->setColor(color); effectsScrollArea->textOpacitySpinBox->setValue(0.5); effectsScrollArea->textPositionComboBox->setCurrentIndex(TopRightCorner); QPoint position = QPoint(4, 3); effectsScrollArea->textXSpinBox->setValue(position.x()); effectsScrollArea->textYSpinBox->setValue(position.y()); convertDialog->convert(); SharedInformation *sharedInfo = convertDialog->sharedInfo; EffectsConfiguration conf = sharedInfo->effectsConfiguration(); QCOMPARE(conf.getTextString(), testText); QCOMPARE(conf.getTextFont(), font); QCOMPARE(conf.getTextColor(), color); QCOMPARE(conf.getTextOpacity(), 0.5); QCOMPARE(conf.getTextPosModifier(), TopRightCorner); QCOMPARE(conf.getTextPos(), position); QCOMPARE(conf.getTextUnitPair(), PosUnitPair(Pixel, Pixel)); QCOMPARE(conf.getTextFrame(), false); QCOMPARE(conf.getTextRotation(), 0); }
QString SongSettingWidget::getFontText(QFont font) { QString f = font.toString().split(",").at(0); QString st(QString("%1: %2").arg(f).arg(font.pointSize())); if(font.bold()) st += ", " + tr("Bold"); if(font.italic()) st += ", " + tr("Italic"); if(font.strikeOut()) st += ", " + tr("StrikeOut"); if(font.underline()) st += ", " + tr("Underline"); return st; }
void QSGTextNode::addTextLayout(const QPointF &position, QTextLayout *textLayout, const QColor &color, QSGText::TextStyle style, const QColor &styleColor) { QList<QGlyphRun> glyphsList(textLayout->glyphRuns()); QSGGlyphNode *prevNode = 0; QFont font = textLayout->font(); qreal underlinePosition, ascent, lineThickness; int decorations = NoDecoration; decorations |= (font.underline() ? Underline : 0); decorations |= (font.overline() ? Overline : 0); decorations |= (font.strikeOut() ? StrikeOut : 0); underlinePosition = ascent = lineThickness = 0; for (int i=0; i<glyphsList.size(); ++i) { QGlyphRun glyphs = glyphsList.at(i); QRawFont rawfont = glyphs.rawFont(); prevNode = addGlyphs(position + QPointF(0, rawfont.ascent()), glyphs, color, style, styleColor); if (decorations) { qreal rawAscent = rawfont.ascent(); if (decorations & Underline) { ascent = qMax(ascent, rawAscent); qreal pos = rawfont.underlinePosition(); if (pos > underlinePosition) { underlinePosition = pos; // take line thickness from the rawfont with maximum underline // position in this case lineThickness = rawfont.lineThickness(); } } else { // otherwise it's strike out or overline, we take line thickness // from the rawfont with maximum ascent if (rawAscent > ascent) { ascent = rawAscent; lineThickness = rawfont.lineThickness(); } } } } if (decorations) { addTextDecorations(Decoration(decorations), position + QPointF(0, ascent), color, textLayout->boundingRect().width(), lineThickness, underlinePosition, ascent); } }
void obs_data_set_qfont(obs_data_t* data, const char* name, QFont font){ obs_data_t *fontObj = obs_data_create(); obs_data_set_string(fontObj, "face", (font.family()).toUtf8().data()); obs_data_set_string(fontObj, "style", (font.styleName()).toUtf8().data()); obs_data_set_int(fontObj, "size", font.pointSize()); int flags = font.bold() ? OBS_FONT_BOLD : 0; flags |= font.italic() ? OBS_FONT_ITALIC : 0; flags |= font.underline() ? OBS_FONT_UNDERLINE : 0; flags |= font.strikeOut() ? OBS_FONT_STRIKEOUT : 0; obs_data_set_int(fontObj, "flags", flags); obs_data_set_obj(data, "font", fontObj); obs_data_release(fontObj); return; }
QString FontEdit::font2str(const QFont &f, bool use_tr) { QString fontName = f.family(); fontName += ", "; if (f.pointSize() > 0){ fontName += QString::number(f.pointSize()); fontName += " pt."; }else{ fontName += QString::number(f.pixelSize()); fontName += " pix."; } switch (f.weight()){ case QFont::Light: fontName += ", "; fontName += s_tr(I18N_NOOP("light"), use_tr); break; case QFont::DemiBold: fontName += ", "; fontName += s_tr(I18N_NOOP("demibold"), use_tr); break; case QFont::Bold: fontName += ", "; fontName += s_tr(I18N_NOOP("bold"), use_tr); break; case QFont::Black: fontName += ", "; fontName += s_tr(I18N_NOOP("black"), use_tr); break; default: break; } if (f.italic()){ fontName += ", "; fontName += s_tr(I18N_NOOP("italic"), use_tr); } if (f.strikeOut()){ fontName += ", "; fontName += s_tr(I18N_NOOP("strikeout"), use_tr); } if (f.underline()){ fontName += ", "; fontName += s_tr(I18N_NOOP("underline"), use_tr); } return fontName; }
/*! \since 4.5 Sets the font highlighted in the QFontDialog to the given \a font. \sa selectedFont() */ void QFontDialog::setCurrentFont(const QFont &font) { Q_D(QFontDialog); d->family = font.family(); d->style = d->fdb.styleString(font); d->size = font.pointSize(); if (d->size == -1) { QFontInfo fi(font); d->size = fi.pointSize(); } d->strikeout->setChecked(font.strikeOut()); d->underline->setChecked(font.underline()); d->updateFamilies(); if (d->canBeNativeDialog()) { if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) helper->setCurrentFont(font); } }
QString QTextFormat::getKey( const QFont &fn, const QColor &col, bool misspelled, const QString &lhref, const QString &lnm, VerticalAlignment a ) { QString k; QTextOStream ts( &k ); ts << fn.pointSize() << "/" << fn.weight() << "/" << (int)fn.underline() << "/" << (int)fn.strikeOut() << "/" << (int)fn.italic() << "/" << (uint)col.rgb() << "/" << fn.family() << "/" << (int)misspelled << "/" << lhref << "/" << lnm << "/" << (int)a; return k; }
QDomElement Calligra::Sheets::NativeFormat::createElement(const QString & tagName, const QFont & font, QDomDocument & doc) { QDomElement e(doc.createElement(tagName)); e.setAttribute("family", font.family()); e.setAttribute("size", font.pointSize()); e.setAttribute("weight", font.weight()); if (font.bold()) e.setAttribute("bold", "yes"); if (font.italic()) e.setAttribute("italic", "yes"); if (font.underline()) e.setAttribute("underline", "yes"); if (font.strikeOut()) e.setAttribute("strikeout", "yes"); //e.setAttribute( "charset", KGlobal::charsets()->name( font ) ); return e; }
/*! \since 4.5 Sets the font highlighted in the QFontDialog to the given \a font. \sa selectedFont() */ void QFontDialog::setCurrentFont(const QFont &font) { Q_D(QFontDialog); d->family = font.family(); d->style = d->fdb.styleString(font); d->size = font.pointSize(); if (d->size == -1) { QFontInfo fi(font); d->size = fi.pointSize(); } d->strikeout->setChecked(font.strikeOut()); d->underline->setChecked(font.underline()); d->updateFamilies(); #ifdef Q_WS_MAC if (d->delegate) QFontDialogPrivate::setFont(d->delegate, font); #endif }
void DFont :: FromODataLayout (ODataLayout *pODataLayout ) { QFont *qfont = NULL; QColor *qcolor = NULL; BEGINSEQ if ( !pODataLayout ) LEAVESEQ if ( qfont = pODataLayout->get_font() ) { strcpy(family_name,QS2SZ(qfont->family())); weight = (ADK_FontWeight)qfont->weight(); italic = qfont->italic(); underline = qfont->underline(); strike_out = qfont->strikeOut(); fixed_pitch = qfont->fixedPitch(); style_hint = (ADK_FontStyle)qfont->styleHint(); style_strategy = (ADK_FontStyleStrategy)qfont->styleStrategy(); stretch = qfont->stretch(); } prefer_quality = NO; if ( style_strategy && QFont::PreferQuality ) { prefer_quality = YES; style_strategy = (ADK_FontStyleStrategy)(style_strategy - QFont::PreferQuality); } if ( qcolor = pODataLayout->get_text_color() ) text_color = QCOLOR2DCOLOR(*qcolor); if ( qcolor = pODataLayout->get_bg_color() ) bg_color = QCOLOR2DCOLOR(*qcolor); use_pixel = NO; if ( (size = qfont->pointSize()) == -1 ) // pixel size used { use_pixel = YES; size = qfont->pixelSize(); } ENDSEQ }
static QString describeFont(const QFont &f) { QString res = "'" + f.family() + "' "; if(f.pointSize() > 0) res += QString::number(f.pointSize()) + "pt"; else res += QString::number(f.pixelSize()) + "px"; if(f.bold()) res += " bold"; if(f.italic()) res += " italic"; if(f.underline()) res += " underline"; if(f.overline()) res += " overline"; if(f.strikeOut()) res += " strikeout"; return res; }
void BiLiTextSourcePropertyDlg::mSltFontComboxChanged(const QString &text) { QFont font = qobject_cast<QFontComboBox *>(sender())->currentFont(); obs_data_t *fontObj = obs_data_create(); obs_data_set_string(fontObj, "face", (font.family()).toUtf8().data()); obs_data_set_string(fontObj, "style", (font.styleName()).toUtf8().data()); obs_data_set_int(fontObj, "size", font.pointSize()); int flags = font.bold() ? OBS_FONT_BOLD : 0; flags |= font.italic() ? OBS_FONT_ITALIC : 0; flags |= font.underline() ? OBS_FONT_UNDERLINE : 0; flags |= font.strikeOut() ? OBS_FONT_STRIKEOUT : 0; obs_data_set_int(fontObj, "flags", flags); obs_data_t *settingFont = obs_source_get_settings(mSrc); obs_data_set_obj(settingFont, "font", fontObj); obs_data_release(fontObj); obs_data_release(settingFont); }
void toString(const QFont & font, QString & szBuffer) { QString szFamily(font.family()); szBuffer.sprintf("%s,%d,%d,%d", szFamily.toUtf8().data(), font.pointSize(), font.styleHint(), font.weight()); QString szOptions; if(font.bold()) szOptions.append('b'); if(font.italic()) szOptions.append('i'); if(font.underline()) szOptions.append('u'); if(font.strikeOut()) szOptions.append('s'); if(font.fixedPitch()) szOptions.append('f'); if(!szOptions.isEmpty()) { szBuffer.append(','); szBuffer.append(szOptions); } }
QString LegendWidget::saveToString() { QString s = "<Legend>\n"; s += FrameWidget::saveToString(); s += "<Text>\n" + d_text->text() + "\n</Text>\n"; QFont f = d_text->font(); s += "<Font>" + f.family() + "\t"; s += QString::number(f.pointSize())+"\t"; s += QString::number(f.weight())+"\t"; s += QString::number(f.italic())+"\t"; s += QString::number(f.underline())+"\t"; s += QString::number(f.strikeOut())+"</Font>\n"; s += "<TextColor>" + d_text->color().name()+"</TextColor>\n"; QColor bc = backgroundColor(); s += "<Background>" + bc.name() + "</Background>\n"; s += "<Alpha>" + QString::number(bc.alpha()) + "</Alpha>\n"; s += "<Angle>" + QString::number(d_angle) + "</Angle>\n"; s += "<AutoUpdate>" + QString::number(d_auto_update) + "</AutoUpdate>\n"; return s + "</Legend>\n"; }
void StyleSheetEditorDialog::slotAddFont() { bool ok; QFont font = QFontDialog::getFont(&ok, this); if (ok) { QString fontStr; if (font.weight() != QFont::Normal) { fontStr += QString::number(font.weight()); fontStr += QLatin1Char(' '); } switch (font.style()) { case QFont::StyleItalic: fontStr += QLatin1String("italic "); break; case QFont::StyleOblique: fontStr += QLatin1String("oblique "); break; default: break; } fontStr += QString::number(font.pointSize()); fontStr += QLatin1String("pt \""); fontStr += font.family(); fontStr += QLatin1Char('"'); insertCssProperty(QLatin1String("font"), fontStr); QString decoration; if (font.underline()) decoration += QLatin1String("underline"); if (font.strikeOut()) { if (!decoration.isEmpty()) decoration += QLatin1Char(' '); decoration += QLatin1String("line-through"); } insertCssProperty(QLatin1String("text-decoration"), decoration); } }
void QJsonPaintEngine::updateFont(const QFont &font) { Q_D(QJsonPaintEngine); #ifdef QT_PICTURE_DEBUG qDebug() << " -> updateFont(): pt sz:" << font.pointSize(); #endif QStringList decorators; if (font.italic()) decorators << "itallic"; if (font.strikeOut()) decorators << "strikeout"; if (font.underline()) decorators << "underline"; switch (font.weight()) { case QFont::Light: decorators << "lighter"; break; case QFont::DemiBold: decorators << "bolder"; break; case QFont::Bold: decorators << "bold"; break; case QFont::Black: decorators << "bold"; break; case QFont::Normal: break; default: break; } QString units; float size; if (font.pixelSize() != -1) { units="px"; size = font.pixelSize(); } else { units="pt"; size = font.pointSize(); } d->s << QString("\t{\"f\": { \"d\": \"%1\", \"s\": %2, \"u\": \"%4\", \"f\": \"%3\"}},\r\n") .arg(decorators.join(" ")) .arg(size) .arg(font.family()) .arg(units); }
bool WidgetInfo::FontChanged(const char *setting) { obs_data_t *font_obj = obs_data_get_obj(view->settings, setting); bool success; uint32_t flags; QFont font; if (!font_obj) { font = QFontDialog::getFont(&success, view); } else { MakeQFont(font_obj, font); font = QFontDialog::getFont(&success, font, view); obs_data_release(font_obj); } if (!success) return false; font_obj = obs_data_create(); obs_data_set_string(font_obj, "face", QT_TO_UTF8(font.family())); obs_data_set_string(font_obj, "style", QT_TO_UTF8(font.styleName())); obs_data_set_int(font_obj, "size", font.pointSize()); flags = font.bold() ? OBS_FONT_BOLD : 0; flags |= font.italic() ? OBS_FONT_ITALIC : 0; flags |= font.underline() ? OBS_FONT_UNDERLINE : 0; flags |= font.strikeOut() ? OBS_FONT_STRIKEOUT : 0; obs_data_set_int(font_obj, "flags", flags); QLabel *label = static_cast<QLabel*>(widget); label->setFont(font); label->setText(QString("%1 %2").arg(font.family(), font.styleName())); obs_data_set_obj(view->settings, setting, font_obj); obs_data_release(font_obj); return true; }
/*! * \class TextCursorChangeFontFace * \author Anders Fernström * \date 2005-11-03 * \date 2006-01-13 (update) * * \brief Command for changing font face * * 2005-11-07 AF, Added function (case 4) in switch to change * strikckout settings * 2005-11-15 AF, added trick to get correct style on links * 2006-01-13 AF, remove trick to get correct style on links because * it made undo/redo work incorrectly */ void TextCursorChangeFontFace::execute() { QTextEdit *editor = document()->getCursor()->currentCell()->textEdit(); QFont font; if( editor ) { switch( face_ ) { case 0: // Plain editor->setFontWeight( QFont::Normal ); editor->setFontItalic( false ); editor->setFontUnderline( false ); font = editor->currentFont(); font.setStrikeOut( false ); editor->setCurrentFont( font ); break; case 1: // Bold if( editor->fontWeight() != QFont::Normal ) editor->setFontWeight( QFont::Normal ); else editor->setFontWeight( QFont::Bold ); break; case 2: // Italic if( editor->fontItalic() ) editor->setFontItalic( false ); else editor->setFontItalic( true ); break; case 3: // Underline if( editor->fontUnderline() ) editor->setFontUnderline( false ); else editor->setFontUnderline( true ); break; case 4: // Strickout font = editor->currentFont(); if( font.strikeOut() ) font.setStrikeOut( false ); else font.setStrikeOut( true ); editor->setCurrentFont( font ); break; } // ugly trick to make the sure that the links haven't change // color /* if( !editor->toPlainText().isEmpty() ) { int start = editor->textCursor().selectionStart(); int end = editor->textCursor().selectionEnd(); editor->setHtml( editor->toHtml() ); QTextCursor cursor( editor->textCursor() ); cursor.setPosition( start ); cursor.setPosition( end, QTextCursor::KeepAnchor ); editor->setTextCursor( cursor ); }*/ } }