void IntervalSummaryWindow::intervalSelected() { // if no ride available don't bother if (mainWindow->currentRideItem() == NULL || mainWindow->currentRide() == NULL) return; QString html; if (mainWindow->allIntervalItems() != NULL) { for (int i=0; i<mainWindow->allIntervalItems()->childCount(); i++) { IntervalItem *current = dynamic_cast<IntervalItem*>(mainWindow->allIntervalItems()->child(i)); if (current != NULL) { if (current->isSelected()) { calcInterval(current, html); } } } } if (html.length() == 0) html = "<i>" + tr("select an interval for summary info") + "</i>"; setHtml(html); return; }
void HexEditor::update() { string output; char temp[256]; unsigned offset = hexOffset; for(unsigned y = 0; y < 16; y++) { if(offset >= hexSize) break; sprintf(temp, "%.6x", offset & 0xffffff); output << "<font color='#606060'>" << temp << "</font> "; for(unsigned x = 0; x < 16; x++) { if(offset >= hexSize) break; sprintf(temp, "%.2x", reader(offset++)); output << "<font color='" << ((x & 1) ? "#000080" : "#0000ff") << "'>" << temp << "</font>"; if(x != 15) output << " "; } if(y != 15) output << "<br>"; } setHtml(utf8() << output); }
void HelpViewer::setSource(const QUrl &url) { bool help = url.toString() == QLatin1String("help"); if (url.isValid() && !help) { if (launchedWithExternalApp(url)) return; QUrl u = helpEngine->findFile(url); if (u.isValid()) { QTextBrowser::setSource(u); return; } } if (help) { QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com." "assistantinternal-1.0.0/assistant/assistant.html"))); } else { QTextBrowser::setSource(url); setHtml(PageNotFoundMessage.arg(url.toString())); emit sourceChanged(url); } }
CUBWAY_NS_BEGIN View::View(QWidget *parent) : QWebView(parent) { this->doWebSettings(); setWindowTitle("Cubway"); // setWindowFlags(Qt::WindowStaysOnBottomHint | Qt::FramelessWindowHint); if(QApplication::arguments().length() <= 1){ setHtml("<!DOCTYPE html><html><head></head><body></body></html>"); show(); }else{ this->appFile.reset(new QFile(QApplication::arguments()[1])); QFileInfo file_info(*this->appFile); this->appDirPath = file_info.absoluteDir().path(); QDir::setCurrent(this->appDirPath); load(QUrl::fromLocalFile(file_info.absoluteFilePath())); } connect(page()->mainFrame(), SIGNAL(loadFinished(bool)), this, SLOT(HandleMetaData()) ); Mainview = this; }
TITANIUM_FUNCTION(WebView, setHtml) { std::unordered_map<std::string, std::string> options; if (arguments.size() < 1) { return get_context().CreateUndefined(); } const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsObject()); const auto html = static_cast<std::string>(_0); if (arguments.size() >= 2) { const auto _1 = arguments.at(1); TITANIUM_ASSERT(_1.IsObject()); const auto js_options = static_cast<JSObject>(_1); // extract JSObject into C++ unordered_map for (const auto& property_name : static_cast<std::vector<JSString>>(js_options.GetPropertyNames())) { options.emplace(property_name, static_cast<std::string>(js_options.GetProperty(property_name))); } } setHtml(html, options); return get_context().CreateUndefined(); }
void KinotifyWidget::SetData () { QString data = Theme_; data.replace ("{title}", Title_); data.replace ("{body}", Body_); if (OverridePixmap_.isNull ()) data.replace ("{imagepath}", MakeImage (ImagePath_)); else data.replace ("{imagepath}", MakeImage (OverridePixmap_)); setHtml (data); if (!ActionsNames_.isEmpty ()) { QWebElement button = page ()->mainFrame ()->documentElement ().findFirst ("form"); if (!button.isNull ()) { QStringList reversed = ActionsNames_; std::reverse (reversed.begin (), reversed.end ()); Q_FOREACH (const QString& name, reversed) button.appendInside (QString ("<input type=\"button\" id=\"%1\" value=\"%2\"" " onclick=\"Action.sendActionOnClick(id)\" />") .arg (ActionsNames_.indexOf (name)) .arg (name)); }
void CustomWebView::NavigateHome () { QFile file (":/resources/html/home.html"); file.open (QIODevice::ReadOnly); QString data = file.readAll (); data.replace ("{pagetitle}", tr ("Welcome to LeechCraft!")); data.replace ("{title}", tr ("Welcome to LeechCraft!")); data.replace ("{body}", tr ("Welcome to LeechCraft, the integrated internet-client.<br />" "More info is available on the <a href='http://leechcraft.org'>" "project's site</a>.")); QBuffer iconBuffer; iconBuffer.open (QIODevice::ReadWrite); QPixmap pixmap (":/resources/images/poshuku.svg"); pixmap.save (&iconBuffer, "PNG"); data.replace ("{img}", QByteArray ("data:image/png;base64,") + iconBuffer.buffer ().toBase64 ()); setHtml (data); }
bool Text::readProperties(const QDomElement& e) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "style") { int st; bool ok; int i = val.toInt(&ok); if (ok) { // obsolete old text styles switch (i) { case 1: i = TEXT_STYLE_UNSTYLED; break; case 2: i = TEXT_STYLE_TITLE; break; case 3: i = TEXT_STYLE_SUBTITLE; break; case 4: i = TEXT_STYLE_COMPOSER; break; case 5: i = TEXT_STYLE_POET; break; case 6: i = TEXT_STYLE_LYRIC1; break; case 7: i = TEXT_STYLE_LYRIC2; break; case 8: i = TEXT_STYLE_FINGERING; break; case 9: i = TEXT_STYLE_INSTRUMENT_LONG; break; case 10: i = TEXT_STYLE_INSTRUMENT_SHORT; break; case 11: i = TEXT_STYLE_INSTRUMENT_EXCERPT; break; case 12: i = TEXT_STYLE_DYNAMICS; break; case 13: i = TEXT_STYLE_TECHNIK; break; case 14: i = TEXT_STYLE_TEMPO; break; case 15: i = TEXT_STYLE_METRONOME; break; case 16: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_COPYRIGHT case 17: i = TEXT_STYLE_MEASURE_NUMBER; break; case 18: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_ODD case 19: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_EVEN case 20: i = TEXT_STYLE_TRANSLATOR; break; case 21: i = TEXT_STYLE_TUPLET; break; case 22: i = TEXT_STYLE_SYSTEM; break; case 23: i = TEXT_STYLE_STAFF; break; case 24: i = TEXT_STYLE_HARMONY; break; case 25: i = TEXT_STYLE_REHEARSAL_MARK; break; case 26: i = TEXT_STYLE_REPEAT; break; case 27: i = TEXT_STYLE_VOLTA; break; case 28: i = TEXT_STYLE_FRAME; break; case 29: i = TEXT_STYLE_TEXTLINE; break; case 30: i = TEXT_STYLE_GLISSANDO; break; case 31: i = TEXT_STYLE_STRING_NUMBER; break; case 32: i = TEXT_STYLE_OTTAVA; break; case 33: i = TEXT_STYLE_BENCH; break; case 34: i = TEXT_STYLE_HEADER; break; case 35: i = TEXT_STYLE_FOOTER; break; case 0: default: qDebug("Text:readProperties: style %d<%s> invalid", i, qPrintable(val)); i = TEXT_STYLE_UNSTYLED; break; } st = i; } else st = score()->style()->textStyleType(val); if (st == TEXT_STYLE_UNSTYLED) setUnstyled(); else if (st == TEXT_STYLE_UNKNOWN) _styleIndex = st; else setTextStyleType(st); } else if (tag == "styleName") // obsolete, unstyled text ; // _styleName = val; else if (tag == "data") // obsolete _doc->setHtml(val); else if (tag == "html") { QString s = Xml::htmlToString(e); setHtml(s); } else if (tag == "text") setText(val); else if (tag == "html-data") { QString s = Xml::htmlToString(e.firstChildElement()); setHtml(s); } else if (tag == "subtype") // obsolete ; else if (_textStyle.readProperties(e)) ; // setUnstyled(); else if (!Element::readProperties(e)) return false; return true; }
int CzUIWebView::LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node) { if (parent->getClassTypeHash() != CzHashes::Scene_Hash && parent->getClassTypeHash() != CzHashes::Actor_Hash) { CzDebug::Log(CZ_DEBUG_CHANNEL_ERROR, "WebView - Needs to be declared inside a scene or an actor - ", DebugInfo.c_str()); return 0; } // Load main actor attributes int ret = CzUIBase::LoadFromXoml(parent, false, node); if (ret <= 0) return ret; // Process WebView specific attributes bool modal = false; bool transparent = false; const char* java_script = NULL; for (CzXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++) { unsigned int name_hash = (*it)->getName().getHash(); if (name_hash == CzHashes::URI_Hash) URI = (*it)->getValue(); else if (name_hash == CzHashes::Modal_Hash) modal = (*it)->getValueAsBool(); else if (name_hash == CzHashes::JavaScript_Hash) java_script = (*it)->getValue().c_str(); else if (name_hash == CzHashes::Transparent_Hash) transparent = (*it)->getValueAsBool(); else if (name_hash == CzHashes::Html_Hash) setHtml((*it)->getValue().c_str()); else if (name_hash == CzHashes::OnError_Hash) EventsManager->addEvent("OnError", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnPageLoaded_Hash) EventsManager->addEvent("OnPageLoaded", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnPageLoading_Hash) EventsManager->addEvent("OnPageLoading", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnPageError_Hash) EventsManager->addEvent("OnPageError", (*it)->getValue().c_str(), true); else if (name_hash == CzHashes::OnJavascript_Hash) EventsManager->addEvent("OnJavascript", (*it)->getValue().c_str(), true); } if (!PLATFORM_UI->isWebViewAvailable()) { ProcessEventActions(CZ_HASH("OnError")); CzDebug::Log(CZ_DEBUG_CHANNEL_ERROR, "WebView - Not supported on this platform - ", DebugInfo.c_str()); return -1; } InitView(modal, transparent, java_script); // Process inner tags if (load_children) { if (!CZ_XOML->Process(this, node)) return 0; } return 1; }
void PmrWindowWidget::initialize(const PMRSupport::PmrExposures &pExposures, const QString &pErrorMessage, const QString &pFilter, const bool &pInternetConnectionAvailable) { // Initialise / keep track of some properties mExposureNames.clear(); mExposureDisplayed.clear(); mExposureUrlId.clear(); mErrorMessage = pErrorMessage; mInternetConnectionAvailable = pInternetConnectionAvailable; // Initialise our list of exposures QString exposures = QString(); QRegularExpression filterRegEx = QRegularExpression(pFilter, QRegularExpression::CaseInsensitiveOption); mNumberOfFilteredExposures = 0; for (int i = 0, iMax = pExposures.count(); i < iMax; ++i) { QString exposureUrl = pExposures[i]->url(); QString exposureName = pExposures[i]->name(); bool exposureDisplayed = exposureName.contains(filterRegEx); exposures += "<tr id=\"exposure_"+QString::number(i)+"\" style=\"display: "+(exposureDisplayed?"table-row":"none")+";\">\n" " <td class=\"exposure\">\n" " <table class=\"fullWidth\">\n" " <tbody>\n" " <tr>\n" " <td class=\"fullWidth\">\n" " <ul>\n" " <li class=\"exposure\">\n" " <a href=\""+exposureUrl+"\">"+exposureName+"</a>\n" " </li>\n" " </ul>\n" " </td>\n" " <td class=\"button\">\n" " <a class=\"noHover\" href=\"cloneWorkspace|"+exposureUrl+"\"><img class=\"button clone\"/></a>\n" " </td>\n" " <td class=\"button\">\n" " <a class=\"noHover\" href=\"showExposureFiles|"+exposureUrl+"\"><img id=\"exposureFilesButton_"+QString::number(i)+"\" class=\"button open\"/></a>\n" " </td>\n" " </tr>\n" " </tbody>\n" " </table>\n" " <ul id=\"exposureFiles_"+QString::number(i)+"\" style=\"display: none;\">\n" " </ul>\n" " </td>\n" "</tr>\n"; mExposureNames << exposureName; mExposureDisplayed << exposureDisplayed; mExposureUrlId.insert(exposureUrl, i); mNumberOfFilteredExposures += exposureDisplayed; } setHtml(mTemplate.arg(message(), exposures)); mInitialized = true; }
void AdiumThemeView::initialise(const AdiumThemeHeaderInfo &chatInfo) { QString headerHtml; QString templateHtml = m_chatStyle->getTemplateHtml(); QString footerHtml = replaceHeaderKeywords(m_chatStyle->getFooterHtml(), chatInfo); QString extraStyleHtml = m_chatStyle->messageViewVersion() < 3 ? QLatin1String("") : QLatin1String("@import url( \"main.css\" );"); m_lastContent = AdiumThemeContentInfo(); if (templateHtml.isEmpty()) { // if templateHtml is empty, we failed to load the fallback template file KMessageBox::error(this, i18n("Missing required file Template.html - check your installation.")); } if (m_displayHeader) { if (chatInfo.isGroupChat()) { // In group chats header should be replaced by topic headerHtml = replaceHeaderKeywords(m_chatStyle->getTopicHtml(), chatInfo); } else { headerHtml = replaceHeaderKeywords(m_chatStyle->getHeaderHtml(), chatInfo); } } //otherwise leave as blank. // set fontFamily and fontSize if (m_useCustomFont) { // use user specified fontFamily and Size settings()->setFontFamily(QWebSettings::StandardFont, m_fontFamily); settings()->setFontSize(QWebSettings::DefaultFontSize, m_fontSize); // since some themes are pretty odd and hardcode fonts to the css we need to override that // with some extra css. this may not work for all themes! extraStyleHtml.append ( QString(QLatin1String("\n* {font-family:\"%1\" !important;font-size:%2pt !important};")) .arg( m_fontFamily ) .arg( m_fontSize ) ); } else { // FIXME: we should inform the user if the chatStyle want's to use a fontFamily which is not present on the system QFontDatabase fontDB = QFontDatabase(); kDebug() << "Theme font installed: " << m_chatStyle->defaultFontFamily() << fontDB.families().contains(m_chatStyle->defaultFontFamily()); // use theme fontFamily/Size, if not existent, it falls back to systems default font settings()->setFontFamily(QWebSettings::StandardFont, m_chatStyle->defaultFontFamily()); settings()->setFontSize(QWebSettings::DefaultFontSize, m_chatStyle->defaultFontSize()); } //The templateHtml is in a horrific NSString format. //Want to use this rather than roll our own, as that way we can get templates from themes too //"%@" is each argument. // all other %'s are escaped. // first is baseref // second is extra style code (This is sometimes missing !!!!) // third is variant CSS // 4th is header // 5th is footer templateHtml.replace(QLatin1String("%%"), QLatin1String("%")); int numberOfPlaceholders = templateHtml.count(QLatin1String("%@")); int index = 0; index = templateHtml.indexOf(QLatin1String("%@"), index); templateHtml.replace(index, 2, QString(QLatin1String("file:///")).append(m_chatStyle->getStyleBaseHref())); if (numberOfPlaceholders == 5) { index = templateHtml.indexOf(QLatin1String("%@"), index); templateHtml.replace(index, 2, extraStyleHtml); } index = templateHtml.indexOf(QLatin1String("%@"), index); templateHtml.replace(index, 2, m_variantPath); index = templateHtml.indexOf(QLatin1String("%@"), index); templateHtml.replace(index, 2, headerHtml); index = templateHtml.indexOf(QLatin1String("%@"), index); templateHtml.replace(index, 2, footerHtml); setHtml(templateHtml); //hidden HTML debugging mode. Should have no visible way to turn it on. if (m_webInspector) { QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); } }
void body_view::redisplay() { m_loaded=false; setHtml(m_html_text, QUrl("/")); }
void TextBrowser::refreshHtml() { setHtml(toHtml()); }
void QalculateSyntaxHelpObject::fetchInformation() { std::string cmd = command().remove(QLatin1String("help")).simplified().toLatin1().data(); qDebug() << "HELP CALLED FOR:" << QLatin1String(cmd.c_str()); if (cmd == "plot") { setPlotInformation(); return; } if (cmd == "saveVariables") { setSaveVariablesInformation(); return; } if (cmd == "loadVariables") { setLoadVariablesInformation(); return; } ExpressionItem *item = CALCULATOR->getActiveExpressionItem(cmd); if (!item) { m_answer = i18n("No function, variable or unit with specified name exist."); return; } switch(item->type()) { case TYPE_FUNCTION: MathFunction *f = (MathFunction*) item; QString title = i18n("Function: %1", QLatin1String(item->title().c_str())); const ExpressionName *ename = &f->preferredName(false); int iargs = f->maxargs(); if(iargs < 0) { iargs = f->minargs() + 1; } QString str,str2,syntax; str += QLatin1String(ename->name.c_str()); str += QLatin1String("("); if(iargs != 0) { Argument *arg; Argument default_arg; for(int i2 = 1; i2 <= iargs; i2++) { if(i2 > f->minargs()) { str += QLatin1String("["); } if(i2 > 1) { str += QLatin1String(CALCULATOR->getComma().c_str()); str += QLatin1String(" "); } arg = f->getArgumentDefinition(i2); if(arg && !arg->name().empty()) { str2 = QLatin1String(arg->name().c_str()); } else { str2 = QLatin1String("argument"); str2 += QLatin1String(" "); str2 += QString::number(i2); } str += str2; if(i2 > f->minargs()) { str += QLatin1String("]"); } } if(f->maxargs() < 0) { str += QLatin1String(CALCULATOR->getComma().c_str()); str += QLatin1String(" ..."); } } str += QLatin1String(")"); syntax = QString::fromLatin1("<p>%1</p>").arg(str); QString arguments = QLatin1String(""); if(iargs != 0) { Argument *arg; Argument default_arg; for(int i2 = 1; i2 <= iargs; i2++) { arg = f->getArgumentDefinition(i2); if(arg && !arg->name().empty()) { str = QLatin1String(arg->name().c_str()); } else { str = QString::number(i2); } str += QLatin1String(": "); if(arg) { str2 = QLatin1String(arg->printlong().c_str()); } else { str2 = QLatin1String(default_arg.printlong().c_str()); } if(i2 > f->minargs()) { str2 += QLatin1String(" ("); //optional argument, in description str2 += QLatin1String("optional"); if(!f->getDefaultValue(i2).empty()) { str2 += QLatin1String(", "); //argument default, in description str2 += QLatin1String("default: "); str2 += QLatin1String(f->getDefaultValue(i2).c_str()); } str2 += QLatin1String(")"); } str += str2; arguments += QString::fromLatin1("<p>%1</p>").arg(str); } } QString desc = QString::fromLatin1("<p>%1</p>").arg(QLatin1String(item->description().c_str())); m_answer = title + desc + syntax + arguments; setHtml(QLatin1String("<p style='white-space:pre'>") + syntax + QLatin1String("</p>")); emit done(); } }
bool Text::readProperties(const QDomElement& e) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "style") { int st; bool ok; int i = val.toInt(&ok); if (ok) { // obsolete old text styles switch (i) { case 1: i = TEXT_STYLE_UNSTYLED; break; case 2: i = TEXT_STYLE_TITLE; break; case 3: i = TEXT_STYLE_SUBTITLE; break; case 4: i = TEXT_STYLE_COMPOSER; break; case 5: i = TEXT_STYLE_POET; break; case 6: i = TEXT_STYLE_LYRIC1; break; case 7: i = TEXT_STYLE_LYRIC2; break; case 8: i = TEXT_STYLE_FINGERING; break; case 9: i = TEXT_STYLE_INSTRUMENT_LONG; break; case 10: i = TEXT_STYLE_INSTRUMENT_SHORT; break; case 11: i = TEXT_STYLE_INSTRUMENT_EXCERPT; break; case 12: i = TEXT_STYLE_DYNAMICS; break; case 13: i = TEXT_STYLE_TECHNIK; break; case 14: i = TEXT_STYLE_TEMPO; break; case 15: i = TEXT_STYLE_METRONOME; break; case 16: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_COPYRIGHT case 17: i = TEXT_STYLE_MEASURE_NUMBER; break; case 18: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_ODD case 19: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_EVEN case 20: i = TEXT_STYLE_TRANSLATOR; break; case 21: i = TEXT_STYLE_TUPLET; break; case 22: i = TEXT_STYLE_SYSTEM; break; case 23: i = TEXT_STYLE_STAFF; break; case 24: i = TEXT_STYLE_HARMONY; break; case 25: i = TEXT_STYLE_REHEARSAL_MARK; break; case 26: i = TEXT_STYLE_REPEAT; break; case 27: i = TEXT_STYLE_VOLTA; break; case 28: i = TEXT_STYLE_FRAME; break; case 29: i = TEXT_STYLE_TEXTLINE; break; case 30: i = TEXT_STYLE_GLISSANDO; break; case 31: i = TEXT_STYLE_STRING_NUMBER; break; case 32: i = TEXT_STYLE_OTTAVA; break; case 33: i = TEXT_STYLE_BENCH; break; case 34: i = TEXT_STYLE_HEADER; break; case 35: i = TEXT_STYLE_FOOTER; break; case 0: default: qDebug("Text:readProperties: style %d<%s> invalid", i, qPrintable(val)); i = TEXT_STYLE_UNSTYLED; break; } st = i; } else st = score()->style()->textStyleType(val); if (st == TEXT_STYLE_UNSTYLED) setUnstyled(); else if (st == TEXT_STYLE_UNKNOWN) _styleIndex = st; else setTextStyleType(st); } else if (tag == "styleName") // obsolete, unstyled text ; // _styleName = val; else if (tag == "data") // obsolete _doc->setHtml(val); else if (tag == "html") { QString s = Xml::htmlToString(e); setHtml(s); } else if (tag == "text") setText(val); else if (tag == "html-data") { QString s = Xml::htmlToString(e.firstChildElement()); if (score()->mscVersion() <= 114) { s.replace("MScore1", "FreeSerifMscore"); s.replace(QChar(0xe10e), QChar(0x266e)); //natural s.replace(QChar(0xe10c), QChar(0x266f)); // sharp s.replace(QChar(0xe10d), QChar(0x266d)); // flat s.replace(QChar(0xe104), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5e))), // note2_Sym s.replace(QChar(0xe105), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5f))); // note4_Sym //test s.replace(QChar(0xe105), QString("XXX")); s.replace(QChar(0xe106), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd60))); // note8_Sym s.replace(QChar(0xe107), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd61))); // note16_Sym s.replace(QChar(0xe108), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd62))); // note32_Sym s.replace(QChar(0xe109), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd63))); // note64_Sym s.replace(QChar(0xe10a), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dot s.replace(QChar(0xe10b), QString("%1%2%3%4").arg(QChar(0xd834)).arg(QChar(0xdd6d)).arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dotdot s.replace(QChar(0xe167), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0b))); // coda s.replace(QChar(0xe168), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // varcoda s.replace(QChar(0xe169), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // segno if (_doc == 0) createDoc(); _doc->setHtml(s); if (isSimpleText()) { QString s = _doc->toPlainText(); delete _doc; _doc = 0; setText(s); } else { setUnstyled(); setHtml(s); } } else { setHtml(s); } } else if (tag == "subtype") // obsolete ; else if (tag == "frameWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setFrameWidth(Spatium(val.toDouble() / spMM)); } else if (tag == "paddingWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setPaddingWidth(Spatium(val.toDouble() / spMM)); } else if (_textStyle.readProperties(e)) ; else if (!Element::readProperties(e)) return false; return true; }
/** * @brief DiagramTextItem::setHtmlText * @param txt */ void DiagramTextItem::setHtmlText(const QString &txt) { setHtml( txt ); }
void TextContent::setPlainText(const QString & plainText) { m_text->setPlainText(plainText); setHtml(m_text->toHtml()); }
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), d(new Data) { d->ui.setupUi(this); auto link = [] (const char *url) -> QString { return "<a href=\""_a % _L(url) % "\">"_a % _L(url) % "</a>"_a; }; d->ui.app_name->setText(cApp.displayName()); #define UI_LABEL_ARG(label, arg) d->ui.label->setText(d->ui.label->text().arg) UI_LABEL_ARG(version, arg(_L(cApp.version()))); UI_LABEL_ARG(qt_info, arg(_L(qVersion()), _L(QT_VERSION_STR))); UI_LABEL_ARG(copyright, arg(QDate::currentDate().year()).arg(tr("Lee, Byoung-young"))); UI_LABEL_ARG(contacts, arg(link("http://bomi-player.github.io") % "<br>"_a). arg(link("http://twitter.com/bomi_player") % "<br>"_a). arg(link("https://github.com/xylosper/bomi/issues") % "<br>"_a). arg("<a href=\"mailto:[email protected]\">[email protected]</a><br>"_a)); UI_LABEL_ARG(ivan, arg(_L("https://plus.google.com/u/1/117118228830713086299/posts"))); #undef UI_LABEL_ARG d->ui.license->setText( u"This program is free software; " "you can redistribute it and/or modify it under the terms of " "the GNU General Public License " "as published by ""the Free Software Foundation; " "either version 2 of the License, " "or (at your option) any later version.<br><br>" "This program is distributed in the hope that it will be useful, " "but WITHOUT ANY WARRANTY; without even the implied warranty of " "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " "See the GNU General Public License for more details.<br><br>" "You should have received a copy of " "the GNU General Public License along with this program; " "if not, see <a href=\"http://www.gnu.org/licenses\">" "http://www.gnu.org/licenses</a>."_q ); auto show = [this] () { QDialog dlg(this); auto text = new QTextBrowser(&dlg); auto close = new QPushButton(tr("Close"), &dlg); auto vbox = new QVBoxLayout(&dlg); vbox->addWidget(text); auto hbox = new QHBoxLayout; hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding)); hbox->addWidget(close); hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding)); vbox->addLayout(hbox); connect(close, &QPushButton::clicked, &dlg, &QDialog::accept); const QString fileName(u":/gpl.html"_q); QFile file(fileName); file.open(QFile::ReadOnly | QFile::Text); text->setHtml(QString::fromLatin1(file.readAll())); dlg.resize(500, 400); dlg.exec(); }; connect(d->ui.view_gpl, &QPushButton::clicked, this, show); adjustSize(); }
void BrowerEditAreaWidget::setText(const QString &html) { setHtml(html); }
void body_view::clear() { setHtml("<html><body></body></html>"); }
void qevercloud::EvernoteOAuthWebView::clearHtml() { setHtml(""); }
void ScTextBrowser::clear() { setHtml(QString::fromAscii("<html></html>")); }
void QtChatHistoryWidget::clear() { setHtml("", QUrl(_theme->getThemePath())); }
void MeasureWidget::objectSelectionChanged() { QString headline; // inline HTML QString body; // HTML blocks QString extra_text; // inline HTML auto& selected_objects = map->selectedObjects(); if (selected_objects.empty()) { extra_text = tr("No object selected."); } else if (selected_objects.size() > 1) { extra_text = tr("%1 objects selected.").arg(locale().toString(map->getNumSelectedObjects())); } else { const Object* object = *begin(selected_objects); const Symbol* symbol = object->getSymbol(); headline = symbol->getNumberAsString() + QLatin1Char(' ') + symbol->getName(); if (object->getType() != Object::Path) { extra_text = tr("The selected object is not a path."); } else { body = QLatin1String{ "<table>" }; static const QString table_row{ QLatin1String{ "<tr><td>%1</td><td align=\"center\">%2 %3</td><td align=\"center\">(%4 %5)</td></tr>" } }; double paper_to_real = 0.001 * map->getScaleDenominator(); object->update(); const PathPartVector& parts = static_cast<const PathObject*>(object)->parts(); Q_ASSERT(!parts.empty()); auto paper_length = parts.front().length(); auto real_length = paper_length * paper_to_real; auto paper_length_text = locale().toString(paper_length, 'f', 2); auto real_length_text = locale().toString(real_length, 'f', 0); if (symbol->getContainedTypes() & Symbol::Area) { body.append(table_row.arg(tr("Boundary length:"), paper_length_text, tr("mm", "millimeters"), real_length_text, tr("m", "meters"))); auto paper_area = parts.front().calculateArea(); if (parts.size() > 1) { paper_area *= 2; for (const auto& part : parts) paper_area -= part.calculateArea(); } double real_area = paper_area * paper_to_real * paper_to_real; auto paper_area_text = locale().toString(paper_area, 'f', 2); auto real_area_text = locale().toString(real_area, 'f', 0); body.append(table_row.arg(tr("Area:"), paper_area_text, trUtf8("mm²", "square millimeters"), real_area_text , trUtf8("m²", "square meters"))); auto minimum_area = 0.0; auto minimum_area_text = QString{ }; if (symbol->getType() == Symbol::Area) { minimum_area = 0.001 * static_cast<const AreaSymbol*>(symbol)->getMinimumArea(); minimum_area_text = locale().toString(minimum_area, 'f', 2); } if (paper_area < minimum_area && paper_area_text != minimum_area_text) { extra_text = QLatin1String("<b>") + tr("This object is too small.") + QLatin1String("</b><br/>") + tr("The minimimum area is %1 %2.").arg(minimum_area_text, trUtf8("mm²")) + QLatin1String("<br/>"); } extra_text.append(tr("Note: Boundary length and area are correct only if there are no self-intersections and holes are used as such.")); } else { body.append(table_row.arg(tr("Length:"), paper_length_text, tr("mm", "millimeters"), real_length_text, tr("m", "meters"))); auto minimum_length = 0.0; auto minimum_length_text = QString{ }; if (symbol->getType() == Symbol::Line) { minimum_length = 0.001 * static_cast<const LineSymbol*>(symbol)->getMinimumLength(); minimum_length_text = locale().toString(minimum_length, 'f', 2); } if (paper_length < minimum_length && paper_length_text != minimum_length_text) { extra_text = QLatin1String("<b>") + tr("This line is too short.") + QLatin1String("</b><br/>") + tr("The minimum length is %1 %2.").arg(minimum_length_text, tr("mm")); } } body.append(QLatin1String("</table>")); } } if (!extra_text.isEmpty()) body.append(QLatin1String("<p>") + extra_text + QLatin1String("</p>")); setHtml(QLatin1String("<p><b>") + headline + QLatin1String("</b></p>") + body); }
void Text::setText(const QTextDocumentFragment& f) { setHtml(f.toHtml()); }
void TextInformationItem::setMessage(const QString& text) { setHtml(text); setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width()/2 , parentItem()->boundingRect().center().y()); }
TtipChart::TtipChart(TquestionPoint *point) : TgraphicsTextTip(), m_point(point) { if (point->question()->melody()) return; TnotePixmap::setDefaultClef(defaultClef); QString txt; if (point->nr()) txt = QString("<big><b>%1.</b></big>").arg(point->nr()); txt += "<br>" + TquestionAsWdg::questionTxt() + ": <b>" + TquestionAsWdg::qaTypeText(point->question()->questionAs) + "</b><br>" + TquestionAsWdg::answerTxt() + ": <b>" + TquestionAsWdg::qaTypeText(point->question()->answerAs) + "</b><br>"; QString qS = "", aS = ""; switch (point->question()->questionAs) { case TQAtype::e_asNote : { int qStrNr = 0; if (point->question()->answerAs == TQAtype::e_asFretPos) { qStrNr = point->question()->qa.pos.str(); if (qStrNr < 1 || qStrNr > 6) qStrNr = 0; // to avoid any stupidity } qS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key, 4.0, qStrNr); if (point->question()->answerAs == TQAtype::e_asNote) { qS = wrapPixToHtml(point->question()->qa.note, true, TkeySignature(0)); // no key in question aS = wrapPixToHtml(point->question()->qa_2.note, true, point->question()->key); } break; } case TQAtype::e_asName: qS = "<span style=\"font-size: xx-large;\">" + point->question()->qa.note.toRichText(point->question()->styleOfQuestion()) + "</span>"; if (point->question()->answerAs == TQAtype::e_asName) aS = "<span style=\"font-size: xx-large;\">" + point->question()->qa_2.note.toRichText(point->question()->styleOfAnswer()) + "</span>"; break; case TQAtype::e_asFretPos: qS = point->question()->qa.pos.toHtml(); break; case TQAtype::e_asSound: qS = TnooFont::span("n", 45); if (point->question()->answerAs == TQAtype::e_asSound) aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); break; } if (aS == "") { switch (point->question()->answerAs) { case TQAtype::e_asNote : aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); break; case TQAtype::e_asName: aS = "<span style=\"font-size: xx-large;\">" + point->question()->qa.note.toRichText(point->question()->styleOfAnswer()) + "</span>"; break; case TQAtype::e_asFretPos: if (point->question()->questionAs == TQAtype::e_asFretPos) aS = point->question()->qa_2.pos.toHtml(); else aS = point->question()->qa.pos.toHtml(); break; case TQAtype::e_asSound: if (point->question()->questionAs == TQAtype::e_asNote) aS = TnooFont::span("n",45); else aS = wrapPixToHtml(point->question()->qa.note, true, point->question()->key); break; } } txt += "<table valign=\"middle\" align=\"center\"><tr><td> " + qS + " </td><td>" + TnooFont::span("?", 45, "color: red") + " </td><td> " + aS + " </td></tr></table>"; txt += wasAnswerOKtext(point->question(), point->color()); if (point->question()->melody() && !point->question()->isWrong()) txt += TexTrans::effectTxt() + QString(": <b>%1%</b><br>").arg(point->question()->effectiveness(), 0, 'f', 1, '0'); txt += TexTrans::reactTimeTxt() + QString("<big><b> %1</b></big>").arg(Texam::formatReactTime(point->question()->time, true)); setBgColor(point->color()); setHtml(txt); }
int RichTextRenderer::fitToSize(const QSize& size, int minimumFontSize, int maximumFontSize) { int width = size.width(); int height = size.height(); const QString sizeKey = QString("%1:%2:%3:%4").arg(html()).arg(width).arg(height).arg(minimumFontSize); // for centering qreal boxHeight = -1; double ptSize = -1; if(static_autoTextSizeCache.contains(sizeKey)) { ptSize = *(static_autoTextSizeCache[sizeKey]); //qDebug()<<"RichTextRenderer::fitToSize(): size search: CACHE HIT: loaded size:"<<ptSize; // We go thru the much-more-verbose method of creating // the document and setting the html, width, merge cursor, // etc, just so we can get the document height after // setting the font size inorder to use it to center the textbox. // If we didnt nead the height, we could just use autoText->setFontSize() QTextDocument doc; doc.setTextWidth(width); if (Qt::mightBeRichText(html())) doc.setHtml(html()); else doc.setPlainText(html()); QTextCursor cursor(&doc); cursor.select(QTextCursor::Document); QTextCharFormat format; format.setFontPointSize(ptSize); cursor.mergeCharFormat(format); boxHeight = doc.documentLayout()->documentSize().height(); setHtml(doc.toHtml()); } else { double ptSize = minimumFontSize > 0 ? minimumFontSize : findFontSize(); double sizeInc = 1; // how big of a jump to add to the ptSize each iteration int count = 0; // current loop iteration int maxCount = 100; // max iterations of the search loop bool done = false; double lastGoodSize = ptSize; QString lastGoodHtml = html(); QTextDocument doc; qreal heightTmp; doc.setTextWidth(width); if (Qt::mightBeRichText(html())) doc.setHtml(html()); else doc.setPlainText(html()); QTextCursor cursor(&doc); cursor.select(QTextCursor::Document); QTextCharFormat format; while(!done && count++ < maxCount) { format.setFontPointSize(ptSize); cursor.mergeCharFormat(format); heightTmp = doc.documentLayout()->documentSize().height(); if(heightTmp < height && ptSize < maximumFontSize) { lastGoodSize = ptSize; //lastGoodHtml = html(); boxHeight = heightTmp; sizeInc *= 1.1; // qDebug()<<"size search: "<<ptSize<<"pt was good, trying higher, inc:"<<sizeInc<<"pt"; ptSize += sizeInc; } else { // qDebug()<<"fitToSize: size search: last good ptsize:"<<lastGoodSize<<", stopping search"; done = true; } } if(boxHeight < 0 && minimumFontSize <= 0) // didnt find a size { ptSize = 100; count = 0; done = false; sizeInc = 1; //qDebug()<<"RichTextRenderer::fitToSize(): size search: going UP failed, now I'll try to go DOWN"; while(!done && count++ < maxCount) { format.setFontPointSize(ptSize); cursor.mergeCharFormat(format); heightTmp = doc.documentLayout()->documentSize().height(); if(heightTmp < height) { lastGoodSize = ptSize; //lastGoodHtml = html(); boxHeight = heightTmp; sizeInc *= 1.1; //qDebug()<<"size search: "<<ptSize<<"pt was good, trying higher, inc:"<<sizeInc<<"pt"; ptSize -= sizeInc; } else { //qDebug()<<"SongSlideGroup::textToSlides(): size search: last good ptsize:"<<lastGoodSize<<", stopping search"; done = true; } } } format.setFontPointSize(lastGoodSize); cursor.mergeCharFormat(format); setHtml(doc.toHtml()); //qDebug()<<"RichTextRenderer::fitToSize(): size search: caching ptsize:"<<lastGoodSize<<", count: "<<count<<"( minimum size was:"<<minimumFontSize<<")"; boxHeight = heightTmp; //static_autoTextSizeCache[sizeKey] = lastGoodSize; // We are using a QCache instead of a plain QMap, so that requires a pointer value // Using QCache because the key for the cache could potentially become quite large if there are large amounts of HTML // and I dont want to just keep accumlating html in the cache infinitely static_autoTextSizeCache.insert(sizeKey, new double(lastGoodSize),1); } return (int)boxHeight; }
K3ActiveLabel::K3ActiveLabel(const QString &text, QWidget * parent) : KTextBrowser(parent),d(new K3ActiveLabelPrivate(this)) { setHtml(text); }
void TextBoxContent::syncFromModelItem(AbstractVisualItem *model) { DEBUG_TSTART(); m_dontSyncToModel = true; if(!modelItem()) { setModelItem(model); // Start out the last remembered model rev at the rev of the model // so we dont force a redraw of the cache just because we're a fresh // object. if(QPixmapCache::find(cacheKey())) m_lastModelRev = modelItem()->revision(); } static int x = 0; x++; //qDebug() << x<<": TextBoxContent::syncFromModelItem() mark"; QFont font; TextItem * textModel = dynamic_cast<TextItem*>(model); font.setFamily(textModel->fontFamily()); font.setPointSize((int)textModel->fontSize()); m_text->setDefaultFont(font); if (!Qt::mightBeRichText(textModel->text())) { qDebug() << "TextBoxContent:: converting plain text from model item to html"; m_text->setPlainText(textModel->text()); textModel->setText(m_text->toHtml()); } //qDebug() << "TextBoxContent:: Original HTML:"<<textModel->text(); setHtml(textModel->text()); //qDebug() << "TextBoxContent:: New HTML:"<<m_text->toHtml(); AbstractContent::syncFromModelItem(model); if(modelItem()->revision() != m_lastModelRev) { //qDebug()<<"modelItem():"<<modelItem()->itemName()<<": last revision:"<<m_lastModelRev<<", this revision:"<<m_lastModelRev<<", cache dirty!"; m_lastModelRev = modelItem()->revision(); // DONT dirty cache here since we changed the cacheKey algorithm - cache key is now based on visual description, not on item identity //dirtyCache(); } if( model->zoomEffectEnabled() && model->zoomSpeed() > 0 && sceneContextHint() == MyGraphicsScene::Live) { m_zoomEnabled = true; m_zoomAnimationTimer->start(1000 / 20); // / model->zoomSpeed()); QSize size = contentsRect().size(); double width = size.width(); double height = size.height(); double aspectRatio = height == 0 ? 1 : width/height; // if(!m_zoomInit) // { //qDebug() << "aspectRatio: "<<aspectRatio; QPointF delta; m_zoomStartSize.setX(width); m_zoomStartSize.setY(height); m_zoomEndSize.setX(width * model->zoomFactor()); m_zoomEndSize.setY(height * model->zoomFactor()); bool zoomIn = true; if(model->zoomDirection() == AbstractVisualItem::ZoomIn) zoomIn = true; else if(model->zoomDirection() == AbstractVisualItem::ZoomOut) zoomIn = false; else if(model->zoomDirection() == AbstractVisualItem::ZoomRandom) zoomIn = qrand() < RAND_MAX/2; m_zoomCurSize = zoomIn ? m_zoomStartSize : m_zoomEndSize; m_zoomDir = zoomIn ? 1 : -1; delta.setX(m_zoomEndSize.x() - m_zoomCurSize.x()); delta.setY(m_zoomEndSize.y() - m_zoomCurSize.y()); //step.setX(delta.x()/ZOOM_STEPS); //step.setY(delta.y()/ZOOM_STEPS); // m_zoomInit = true; // } // allow it to go below 1.0 for step size by using 75.0 when the max of the zoomSpeed slider in config is 100 m_zoomStep.setX(8.0 / (100.01 - ((double)model->zoomSpeed())) * aspectRatio); m_zoomStep.setY(8.0 / (100.01 - ((double)model->zoomSpeed()))); if(model->zoomAnchorPoint() == AbstractVisualItem::ZoomAnchorRandom) { // pick a third intersection double x = qrand() < RAND_MAX/2 ? .33 : .66; double y = qrand() < RAND_MAX/2 ? .33 : .66; // apply a fudge factor // x += 0.15 - ((double)qrand()) / ((double)RAND_MAX) * 0.075; // y += 0.15 - ((double)qrand()) / ((double)RAND_MAX) * 0.075; m_zoomDestPoint = QPointF(x,y); //qDebug() << "ZoomRandom: "<<x<<","<<y; //qDebug() << model->itemName() << "Random zoom anchor: "<<m_zoomDestPoint; } else { double x = .0, y = .0; switch(model->zoomAnchorPoint()) { case AbstractVisualItem::ZoomTopLeft: x = .33; y = .33; break; case AbstractVisualItem::ZoomTopMid: x = .50; y = .25; break; case AbstractVisualItem::ZoomTopRight: x = .66; y = .33; break; case AbstractVisualItem::ZoomRightMid: x = .75; y = .50; break; case AbstractVisualItem::ZoomBottomRight: x = .66; y = .66; break; case AbstractVisualItem::ZoomBottomMid: x = .50; y = .75; break; case AbstractVisualItem::ZoomBottomLeft: x = .33; y = .66; break; case AbstractVisualItem::ZoomLeftMid: x = .25; y = .50; break; case AbstractVisualItem::ZoomCenter: default: x = .50; y = .50; break; }; m_zoomDestPoint = QPointF(x,y); } } else { m_zoomEnabled = false; if(m_zoomAnimationTimer->isActive()) m_zoomAnimationTimer->stop(); } m_dontSyncToModel = false; }