void Text::setText(const Common::String &text) { if (_text != text) { _text = text; updateFormat(); forceRefresh(); } }
void Text::setAutoWrapThreshold(uint32 autoWrapThreshold) { if (autoWrapThreshold != _autoWrapThreshold) { _autoWrapThreshold = autoWrapThreshold; updateFormat(); forceRefresh(); } }
void Text::setAutoWrap(bool autoWrap) { if (autoWrap != _autoWrap) { _autoWrap = autoWrap; updateFormat(); forceRefresh(); } }
void ClientTextEdit::displayText(const QString& str) { // ANSI codes are formatted as the following: // escape + [ + n1 (+ n2) + m QRegExp ansiRx("\\0033\\[((?:\\d+;)*\\d+)m"); QRegExp subBlockRx("\\0010"); QStringList blocks = str.split(ansiRx); QStringList ansi, subAnsi, subBlock; int i = 0, j, k; ansi << ""; while ((i = ansiRx.indexIn(str, i)) != -1) { ansi << ansiRx.cap(1); i += ansiRx.matchedLength(); } for (i = 0; i < blocks.count(); i++) { // split several semicoloned ansi codes into individual codes subAnsi = ansi[i].split(";"); QStringListIterator ansiIterator(subAnsi); while (ansiIterator.hasNext() && i != 0) updateFormat(_format, ansiIterator.next().toInt()); // split the text into sub-blocks blocks[i].replace((char)20, " "); // replace hex-spaces with normal spaces if ((k = blocks[i].indexOf(subBlockRx)) != -1) { j = 0; do { //qDebug("j%d k%d %s", j, k, blocks[i].toAscii().data()); if (blocks[i].length() > 2) { // this is for the "You begin to search.." etc lines _cursor.insertText(blocks[i].mid(j, k), _format); moveCursor(-1); } else { // HACK because the twiddler has a backspace following the twiddler character moveCursor(-1); _cursor.insertText(blocks[i].mid(j, k), _format); } j = k + 1; } while ((k = blocks[i].indexOf(subBlockRx, j)) != -1); _cursor.insertText(blocks[i].mid(j), _format); } else _cursor.insertText(blocks[i], _format); /* for (j = 0; (j = subBlockRx.indexIn(blocks[i], j)) != -1; j += subBlockRx.matchedLength()) { qDebug("%s", subBlock.join(",").toAscii().data()); if (subBlockRx.cap(1).contains(QRegExp("\\0010"))) { _cursor.insertText(blockIterator.next(), _format); moveCursor(-1); } else { _cursor.insertText(blockIterator.next(), _format); } } */ } setTextCursor(_cursor); ensureCursorVisible(); }
bool Text::setFont(const Common::String &font) { // Load font #ifdef PRECACHE_RESOURCES if (getResourceManager()->precacheResource(font)) { _font = font; updateFormat(); forceRefresh(); return true; } else { error("Could not precache font \"%s\". Font probably does not exist.", font.c_str()); return false; } #else getResourceManager()->requestResource(font); _font = font; updateFormat(); forceRefresh(); return true; #endif }
bool Text::setFont(const Common::String &font) { // Font precachen. if (getResourceManager()->precacheResource(font)) { _font = font; updateFormat(); forceRefresh(); return true; } else { BS_LOG_ERRORLN("Could not precache font \"%s\". Font probably does not exist.", font.c_str()); return false; } }
void MScoreTextToMXML::writeTextFragments(const QList<TextFragment>& fr, Xml& xml) { //qDebug("MScoreTextToMXML::writeTextFragments defFmt %s", qPrintable(charFormat2QString(oldFormat))); //dumpText(fr); bool firstTime = true; // write additional attributes only the first time characters are written for (const TextFragment& f : fr) { newFormat = f.format; if (f.format.type() == CharFormatType::SYMBOL) { // for symbols, only an explicit font change is required // fragment text is already SMuFL-compliant newFormat.setFontFamily(musicalTextFont); } QString formatAttr = updateFormat(); xml.tag(tagname + (firstTime ? attribs : "") + formatAttr, f.text); firstTime = false; } }
void MScoreTextToMXML::write(Xml& xml) { //qDebug("MScoreTextToMXML::write()"); QXmlStreamReader r(text); bool firstTime = true; // write additional attributes only the first time characters are written while (!r.atEnd()) { // do processing r.readNext(); if(r.isCharacters()) { //qDebug("old %s", qPrintable(charFormat2QString(oldFormat))); //qDebug("new %s", qPrintable(charFormat2QString(newFormat))); QString formatAttr = updateFormat(); //qDebug("old %s", qPrintable(charFormat2QString(oldFormat))); //qDebug("new %s", qPrintable(charFormat2QString(newFormat))); //qDebug("Characters '%s'", qPrintable(r.text().toString())); xml.tag(tagname + (firstTime ? attribs : "") + formatAttr, r.text().toString()); firstTime = false; } else if(r.isEndElement()) { //qDebug("EndElem '%s'", qPrintable(r.name().toString())); handleEndElement(r); } else if(r.isStartElement()) { /* qDebug("StartElem '%s'", qPrintable(r.name().toString())); if (r.name() == "font") qDebug(" face='%s' size='%s'", qPrintable(r.attributes().value("face").toString()), qPrintable(r.attributes().value("size").toString())); */ handleStartElement(r); } } if (r.hasError()) { // do error handling qDebug("Error %s", qPrintable(r.errorString())); } }
void LxQtWorldClock::settingsChanged() { QSettings *_settings = settings(); FormatType oldFormatType = mFormatType; QString oldCustomFormat = mCustomFormat; mTimeZones.clear(); int size = _settings->beginReadArray(QLatin1String("timeZones")); for (int i = 0; i < size; ++i) { _settings->setArrayIndex(i); mTimeZones.append(_settings->value(QLatin1String("timeZone"), QString()).toString()); } _settings->endArray(); if (mTimeZones.isEmpty()) mTimeZones.append(QString::fromLatin1(QTimeZone::systemTimeZoneId())); mDefaultTimeZone = _settings->value(QLatin1String("defaultTimeZone"), QString()).toString(); if (mDefaultTimeZone.isEmpty()) mDefaultTimeZone = mTimeZones[0]; mActiveTimeZone = mDefaultTimeZone; mCustomFormat = _settings->value(QLatin1String("customFormat"), tr("'<b>'HH:mm:ss'</b><br/><font size=\"-2\">'ddd, d MMM yyyy'<br/>'TT'</font>'")).toString(); QString formatType = _settings->value(QLatin1String("formatType"), QString()).toString(); if (formatType == QLatin1String("custom")) mFormatType = FORMAT_CUSTOM; else if (formatType == QLatin1String("full")) mFormatType = FORMAT_LONG; else if (formatType == QLatin1String("long")) mFormatType = FORMAT_LONG; else if (formatType == QLatin1String("medium")) mFormatType = FORMAT_SHORT; else if (formatType == QLatin1String("short-timeonly")) mFormatType = FORMAT_SHORT_TIMEONLY; else if (formatType == QLatin1String("long-timeonly")) mFormatType = FORMAT_LONG_TIMEONLY; else mFormatType = FORMAT_SHORT; if ((oldFormatType != mFormatType) || (oldCustomFormat != mCustomFormat)) updateFormat(); bool autoRotate = settings()->value(QLatin1String("autoRotate"), true).toBool(); if (autoRotate != mAutoRotate) { mAutoRotate = autoRotate; realign(); } if (mPopup) { updatePopupContent(); mPopup->adjustSize(); mPopup->setGeometry(calculatePopupWindowPos(mPopup->size())); } timeout(); }
void MSNumericArrayView::format(const MSFormat& format_) { _format=format_; updateFormat(); }