#include "qsptextbox.h" #include #include #include #include #include #include #include "comtools.h" QspTextBox::QspTextBox(QWidget *parent) : QTextBrowser(parent) { //SetBorders(5); setFocusPolicy(Qt::NoFocus); setFrameStyle(QFrame::NoFrame); setFrameShadow(QFrame::Plain); setContentsMargins(0,0,0,0); m_isUseHtml = false; showPlainText = false; disableVideo = false; //m_linkColor = palette().color(QPalette::Link); //m_fontColor = palette().color(QPalette::Text); //m_backColor = QColor(224, 224, 224); m_font = font(); setOpenLinks(false); #ifndef _WEBBOX_COMMON connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(resizeAnimations()) ); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(resizeAnimations()) ); #endif // m_font = *wxNORMAL_FONT; // m_outFormat = wxString::Format( // wxT("") // wxT("%%s"), // wxFontMapper::GetEncodingName(wxLocale::GetSystemEncoding()).wx_str() // ); } QspTextBox::~QspTextBox() { #ifndef _WEBBOX_COMMON clearManualResources(); #endif } void QspTextBox::SetIsHtml(bool isHtml) { if (m_isUseHtml != isHtml) { m_isUseHtml = isHtml; RefreshUI(); } } void QspTextBox::RefreshUI(bool isScroll) { QString color(QSPTools::GetHexColor(GetForegroundColor())); //QString str(QByteArray::fromPercentEncoding(m_text.replace("%", "%25").toUtf8())); //QString text(QSPTools::HtmlizeWhitespaces(m_isUseHtml ? str : QSPTools::ProceedAsPlain(str))); QString str = m_text; QString text; if(m_isUseHtml) { if(str.endsWith("\r")) str.chop(1); if(str.endsWith("\n")) str.chop(1); str = str.replace("\r", "").replace("\n", "
").replace("