void SimpleRichTextEdit::clearUndoRedoHistory() { if(isUndoRedoEnabled()) { setUndoRedoEnabled(false); // clears the undo/redo history setUndoRedoEnabled(true); } }
void TerminalEdit::append(const QString &text, QTextCharFormat *fmt) { setUndoRedoEnabled(false); QTextCursor cur = this->textCursor(); cur.movePosition(QTextCursor::End); if (fmt) { cur.setCharFormat(*fmt); } cur.insertText(text); this->setTextCursor(cur); setUndoRedoEnabled(true); m_endPostion = cur.position(); }
QwtRichTextDocument( const QString &text, int flags, const QFont &font ) { setUndoRedoEnabled( false ); setDefaultFont( font ); setHtml( text ); // make sure we have a document layout ( void )documentLayout(); QTextOption option = defaultTextOption(); if ( flags & Qt::TextWordWrap ) option.setWrapMode( QTextOption::WordWrap ); else option.setWrapMode( QTextOption::NoWrap ); option.setAlignment( ( Qt::Alignment ) flags ); setDefaultTextOption( option ); QTextFrame *root = rootFrame(); QTextFrameFormat fm = root->frameFormat(); fm.setBorder( 0 ); fm.setMargin( 0 ); fm.setPadding( 0 ); fm.setBottomMargin( 0 ); fm.setLeftMargin( 0 ); root->setFrameFormat( fm ); adjustSize(); }
ChatBrowser::ChatBrowser(QWidget *parent) : QTextBrowser(parent),m_bgColor(MAX_COLOR_CHANNEL,MAX_COLOR_CHANNEL,MAX_COLOR_CHANNEL),m_parent(parent) { //setOpenLinks(true); m_bgColorAct= new QAction(tr("Background Color"),this); //toolBar->addWidget(m_bgColorSelector); m_bgColorAct->setToolTip(tr("Background Color")); connect(m_bgColorAct,SIGNAL(triggered()),this, SLOT(backGroundChanged())); m_detachedDialog = new QAction(tr("Detach the view"),this); m_detachedDialog->setCheckable(true); m_wordWarp = new QAction(tr("Word Wrap"),this); m_wordWarp->setCheckable(true); m_wordWarp->setChecked(true); connect(m_detachedDialog,SIGNAL(triggered()),this, SLOT(detachedView())); //connect(m_anyWhereWarp,SIGNAL(triggered()),this, SLOT(setWrapAnyWhere())); connect(m_wordWarp,SIGNAL(triggered()),this, SLOT(setWordWrap())); setContextMenuPolicy(Qt::CustomContextMenu); connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showContextMenu(QPoint))); setAcceptRichText(false); //setContextMenuPolicy(Qt::NoContextMenu); setOpenLinks(true); setReadOnly(true); setUndoRedoEnabled(false); setWordWrapMode(QTextOption::WordWrap); document()->setDefaultStyleSheet(QString(".dice {color:%1;font-weight: bold;}").arg(PreferencesManager::getInstance()->value("DiceHighlightColor",QColor(Qt::red)).value<QColor>().name())); }
XERCES_CPP_NAMESPACE_USE ScriptingWidget::ScriptingWidget(const QString& strPlugInName, QWidget* parent) : QTextEdit(parent), mDropOccurring(false), mDisplayedOnce(false), mPrompt(strPlugInName + "> "), mCommandIndex(0), mMaxParagraphs(512), mInterpreterName(strPlugInName), mInterpreter(), mCommandStartPos(0), mExecutingCommand(false), mInteractive(false), mpPims(Service<PlugInManagerServices>().get(), SIGNAL_NAME(PlugInManagerServices, PlugInDestroyed), Slot(this, &ScriptingWidget::plugInDestroyed)) { // Initialization setFrameStyle(QFrame::NoFrame); setMinimumWidth(150); setUndoRedoEnabled(false); setFocus(); mpClearAction = new QAction("Clear", this); VERIFYNR(connect(mpClearAction, SIGNAL(triggered(bool)), this, SLOT(clearOutput()))); mpGlobalOutputAction = new QAction("Global Output Shown", this); mpGlobalOutputAction->setCheckable(true); VERIFYNR(connect(mpGlobalOutputAction, SIGNAL(triggered(bool)), this, SLOT(globalOutputChanged(bool)))); }
ItemText::ItemText(const QString &text, bool isRichText, QWidget *parent) : QTextEdit(parent) , ItemWidget(this) , m_textDocument() , m_searchTextDocument() , m_textFormat(isRichText ? Qt::RichText : Qt::PlainText) { init(m_textDocument, font()); init(m_searchTextDocument, font()); setUndoRedoEnabled(false); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFrameStyle(QFrame::NoFrame); // Selecting text copies it to clipboard. connect( this, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()) ); setReadOnly(true); if (isRichText) m_textDocument.setHtml( text.left(defaultMaxBytes) ); else m_textDocument.setPlainText( text.left(defaultMaxBytes) ); setDocument(&m_textDocument); updateSize(); }
HelpWidget::HelpBrowser::HelpBrowser(HelpWidget* parent, QHelpEngineCore* helpEngine) : QTextBrowser(parent), helpwidget_(parent), helpEngine_(helpEngine) { setReadOnly(true); setUndoRedoEnabled(false); setContextMenuPolicy(Qt::NoContextMenu); setAcceptRichText(false); }
VBoxDbgConsoleOutput::VBoxDbgConsoleOutput(QWidget *pParent/* = NULL*/, const char *pszName/* = NULL*/) : QTextEdit(pParent), m_uCurLine(0), m_uCurPos(0), m_hGUIThread(RTThreadNativeSelf()) { setReadOnly(true); setUndoRedoEnabled(false); setOverwriteMode(false); setPlainText(""); setTextInteractionFlags(Qt::TextBrowserInteraction); setAutoFormatting(QTextEdit::AutoAll); setTabChangesFocus(true); setAcceptRichText(false); /* * Font. * Create actions for font menu items. */ m_pCourierFontAction = new QAction(tr("Courier"), this); m_pCourierFontAction->setCheckable(true); m_pCourierFontAction->setShortcut(Qt::ControlModifier + Qt::Key_D); connect(m_pCourierFontAction, SIGNAL(triggered()), this, SLOT(setFontCourier())); m_pMonospaceFontAction = new QAction(tr("Monospace"), this); m_pMonospaceFontAction->setCheckable(true); m_pMonospaceFontAction->setShortcut(Qt::ControlModifier + Qt::Key_M); connect(m_pMonospaceFontAction, SIGNAL(triggered()), this, SLOT(setFontMonospace())); /* Create action group for grouping of exclusive font menu items. */ QActionGroup *pActionFontGroup = new QActionGroup(this); pActionFontGroup->addAction(m_pCourierFontAction); pActionFontGroup->addAction(m_pMonospaceFontAction); pActionFontGroup->setExclusive(true); /* * Color scheme. * Create actions for color-scheme menu items. */ m_pGreenOnBlackAction = new QAction(tr("Green On Black"), this); m_pGreenOnBlackAction->setCheckable(true); m_pGreenOnBlackAction->setShortcut(Qt::ControlModifier + Qt::Key_1); connect(m_pGreenOnBlackAction, SIGNAL(triggered()), this, SLOT(setColorGreenOnBlack())); m_pBlackOnWhiteAction = new QAction(tr("Black On White"), this); m_pBlackOnWhiteAction->setCheckable(true); m_pBlackOnWhiteAction->setShortcut(Qt::ControlModifier + Qt::Key_2); connect(m_pBlackOnWhiteAction, SIGNAL(triggered()), this, SLOT(setColorBlackOnWhite())); /* Create action group for grouping of exclusive color-scheme menu items. */ QActionGroup *pActionColorGroup = new QActionGroup(this); pActionColorGroup->addAction(m_pGreenOnBlackAction); pActionColorGroup->addAction(m_pBlackOnWhiteAction); pActionColorGroup->setExclusive(true); /* * Set the defaults (which syncs with the menu item checked state). */ setFontCourier(); setColorGreenOnBlack(); NOREF(pszName); }
//---------------------------------------------------------------------------- // ChatView //---------------------------------------------------------------------------- ChatView::ChatView(QWidget *parent) : PsiTextView(parent) , dialog_(0) { setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); setReadOnly(true); setUndoRedoEnabled(false); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); #ifndef Q_WS_X11 // linux has this feature built-in connect(this, SIGNAL(selectionChanged()), SLOT(autoCopy())); connect(this, SIGNAL(cursorPositionChanged()), SLOT(autoCopy())); #endif // FIXME #ifdef YAPSI CombinedSyntaxHighlighter* hl = new CombinedSyntaxHighlighter(this); new QuotationHighlighter(hl, this); new WikiHighlighter(hl, this); #ifdef YAPSI_DEV new CppHighlighter(hl, this); #endif #endif }
ProtocolView::ProtocolView(const QCString& appId, QWidget *parent, const char *name) : QTextEdit(parent, name) , job(0) , m_isUpdateJob(false) { setReadOnly(true); setUndoRedoEnabled(false); setTabChangesFocus(true); setTextFormat(Qt::LogText); KConfig *config = CervisiaPart::config(); config->setGroup("LookAndFeel"); setFont(config->readFontEntry("ProtocolFont")); config->setGroup("Colors"); QColor defaultColor = QColor(255, 130, 130); conflictColor=config->readColorEntry("Conflict",&defaultColor); defaultColor=QColor(130, 130, 255); localChangeColor=config->readColorEntry("LocalChange",&defaultColor); defaultColor=QColor(70, 210, 70); remoteChangeColor=config->readColorEntry("RemoteChange",&defaultColor); // create a DCOP stub for the non-concurrent cvs job job = new CvsJob_stub(appId, "NonConcurrentJob"); // establish connections to the signals of the cvs job connectDCOPSignal(job->app(), job->obj(), "jobExited(bool, int)", "slotJobExited(bool, int)", true); connectDCOPSignal(job->app(), job->obj(), "receivedStdout(QString)", "slotReceivedOutput(QString)", true); connectDCOPSignal(job->app(), job->obj(), "receivedStderr(QString)", "slotReceivedOutput(QString)", true); }
//Reset the console void pConsole::reset() { clear(); setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard | Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextEditable ); setUndoRedoEnabled( false ); setTabStopWidth( 30 ); QFont font = QFont( "Bitstream Vera Sans Mono", 11 ); font.setBold( true ); setFont( font ); QPalette pal = viewport()->palette(); pal.setColor( viewport()->backgroundRole(), QColor( Qt::black ) ); pal.setColor( viewport()->foregroundRole(), QColor( Qt::white ) ); viewport()->setPalette( pal ); mColors[ ctCommand ] = Qt::white; mColors[ ctError ] = Qt::red; mColors[ ctOutput ] = Qt::blue; mColors[ ctCompletion ] = Qt::green; mRecordedScript.clear(); mTypedCommand.clear(); setHistory( QStringList() ); setPromptVisible( true ); setPrompt( "@:/> " ); }
int QTextDocument::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 14) qt_static_metacall(this, _c, _id, _a); _id -= 14; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled(); break; case 1: *reinterpret_cast< bool*>(_v) = isModified(); break; case 2: *reinterpret_cast< QSizeF*>(_v) = pageSize(); break; case 3: *reinterpret_cast< QFont*>(_v) = defaultFont(); break; case 4: *reinterpret_cast< bool*>(_v) = useDesignMetrics(); break; case 5: *reinterpret_cast< QSizeF*>(_v) = size(); break; case 6: *reinterpret_cast< qreal*>(_v) = textWidth(); break; case 7: *reinterpret_cast< int*>(_v) = blockCount(); break; case 8: *reinterpret_cast< qreal*>(_v) = indentWidth(); break; case 9: *reinterpret_cast< QString*>(_v) = defaultStyleSheet(); break; case 10: *reinterpret_cast< int*>(_v) = maximumBlockCount(); break; case 11: *reinterpret_cast< qreal*>(_v) = documentMargin(); break; } _id -= 12; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setUndoRedoEnabled(*reinterpret_cast< bool*>(_v)); break; case 1: setModified(*reinterpret_cast< bool*>(_v)); break; case 2: setPageSize(*reinterpret_cast< QSizeF*>(_v)); break; case 3: setDefaultFont(*reinterpret_cast< QFont*>(_v)); break; case 4: setUseDesignMetrics(*reinterpret_cast< bool*>(_v)); break; case 6: setTextWidth(*reinterpret_cast< qreal*>(_v)); break; case 8: setIndentWidth(*reinterpret_cast< qreal*>(_v)); break; case 9: setDefaultStyleSheet(*reinterpret_cast< QString*>(_v)); break; case 10: setMaximumBlockCount(*reinterpret_cast< int*>(_v)); break; case 11: setDocumentMargin(*reinterpret_cast< qreal*>(_v)); break; } _id -= 12; } else if (_c == QMetaObject::ResetProperty) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 12; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 12; } #endif // QT_NO_PROPERTIES return _id; }
ClientTextEdit::ClientTextEdit(QWidget* parent) : QTextEdit(parent) { setReadOnly(true); setOverwriteMode(true); setUndoRedoEnabled(false); setDocumentTitle("mClient"); setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); setTabChangesFocus(false); //_doc->setMaximumBlockCount(Config().scrollbackSize); // max number of lines? document()->setUndoRedoEnabled(false); QTextFrame* frame = document()->rootFrame(); _cursor = frame->firstCursorPosition(); // Default Colors _foregroundColor = Qt::lightGray; _backgroundColor = Qt::black; _blackColor = Qt::darkGray; _redColor = Qt::darkRed; _greenColor = Qt::darkGreen; _yellowColor = Qt::darkYellow; _blueColor = Qt::darkBlue; _magentaColor = Qt::darkMagenta; _cyanColor = Qt::darkCyan; _grayColor = Qt::lightGray; _darkGrayColor = Qt::gray; _brightRedColor = Qt::red; _brightGreenColor = Qt::green; _brightYellowColor = Qt::yellow; _brightBlueColor = Qt::blue; _brightMagentaColor = Qt::magenta; _brightCyanColor = Qt::cyan; _whiteColor = Qt::white; // Default Fonts _serverOutputFont = QFont("Monospace", 10); _inputLineFont = QFont("Monospace", 10); //QApplication::font(); _serverOutputFont.setStyleHint(QFont::TypeWriter, QFont::PreferAntialias); QTextFrameFormat frameFormat = frame->frameFormat(); frameFormat.setBackground(_backgroundColor); frameFormat.setForeground(_foregroundColor); frame->setFrameFormat(frameFormat); _format = _cursor.charFormat(); setDefaultFormat(_format); _defaultFormat = _format; _cursor.setCharFormat(_format); QFontMetrics fm(_serverOutputFont); setTabStopWidth(fm.width(" ") * 8); // A tab is 8 spaces wide QScrollBar* scrollbar = verticalScrollBar(); scrollbar->setSingleStep(fm.leading()+fm.height()); connect(scrollbar, SIGNAL(sliderReleased()), this, SLOT(scrollBarReleased())); previous = 0; }
void TerminalEdit::append(const QString &text, QTextCharFormat *fmt) { QString str = text; if (m_bFilterTermColor) { static QRegExp rx("\033\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]"); str.remove(rx); } setUndoRedoEnabled(false); QTextCursor cur = this->textCursor(); cur.movePosition(QTextCursor::End); if (fmt) { cur.setCharFormat(*fmt); } cur.insertText(str); this->setTextCursor(cur); setUndoRedoEnabled(true); m_endPostion = this->textCursor().position(); }
CustomTextDocument::CustomTextDocument(QObject *parent) : QTextDocument(parent) { static QString css = Style::getStylesheet(":ui/chatArea/innerStyle.css"); setDefaultStyleSheet(css); setUndoRedoEnabled(false); setUseDesignMetrics(false); }
OutputWindow::OutputWindow(Context context, QWidget *parent) : QPlainTextEdit(parent) , d(new Internal::OutputWindowPrivate(document())) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //setCenterOnScroll(false); setFrameShape(QFrame::NoFrame); setMouseTracking(true); setUndoRedoEnabled(false); d->outputWindowContext = new IContext; d->outputWindowContext->setContext(context); d->outputWindowContext->setWidget(this); ICore::addContextObject(d->outputWindowContext); // QAction *undoAction = new QAction(this); // QAction *redoAction = new QAction(this); // QAction *cutAction = new QAction(this); // QAction *copyAction = new QAction(this); // QAction *pasteAction = new QAction(this); // QAction *selectAllAction = new QAction(this); // ActionManager::registerAction(undoAction, Constants::UNDO, context); // ActionManager::registerAction(redoAction, Constants::REDO, context); // ActionManager::registerAction(cutAction, Constants::CUT, context); // ActionManager::registerAction(copyAction, Constants::COPY, context); // ActionManager::registerAction(pasteAction, Constants::PASTE, context); // ActionManager::registerAction(selectAllAction, Constants::SELECTALL, context); // connect(undoAction, &QAction::triggered, this, &QPlainTextEdit::undo); // connect(redoAction, &QAction::triggered, this, &QPlainTextEdit::redo); // connect(cutAction, &QAction::triggered, this, &QPlainTextEdit::cut); // connect(copyAction, &QAction::triggered, this, &QPlainTextEdit::copy); // connect(pasteAction, &QAction::triggered, this, &QPlainTextEdit::paste); // connect(selectAllAction, &QAction::triggered, this, &QPlainTextEdit::selectAll); // connect(this, &QPlainTextEdit::undoAvailable, undoAction, &QAction::setEnabled); // connect(this, &QPlainTextEdit::redoAvailable, redoAction, &QAction::setEnabled); // connect(this, &QPlainTextEdit::copyAvailable, cutAction, &QAction::setEnabled); // OutputWindow never read-only // connect(this, &QPlainTextEdit::copyAvailable, copyAction, &QAction::setEnabled); // undoAction->setEnabled(false); // redoAction->setEnabled(false); // cutAction->setEnabled(false); // copyAction->setEnabled(false); m_scrollTimer.setInterval(10); m_scrollTimer.setSingleShot(true); connect(&m_scrollTimer, &QTimer::timeout, this, &OutputWindow::scrollToBottom); m_lastMessage.start(); d->m_originalFontSize = font().pointSizeF(); }
Console::Console(QWidget *parent) : QPlainTextEdit(parent) { setWindowTitle("Console"); resize(800, 600); setUndoRedoEnabled(false); appendPlainText(QString("")); QFont courier("Courier"); setFont(courier); }
CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode, QWidget* parent) : QPlainTextEdit (parent), mDocument (document), mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive), mChangeLocked (0) { // setAcceptRichText (false); setLineWrapMode (QPlainTextEdit::NoWrap); setTabStopWidth (4); setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead mAllowedTypes <<CSMWorld::UniversalId::Type_Journal <<CSMWorld::UniversalId::Type_Global <<CSMWorld::UniversalId::Type_Topic <<CSMWorld::UniversalId::Type_Sound <<CSMWorld::UniversalId::Type_Spell <<CSMWorld::UniversalId::Type_Cell <<CSMWorld::UniversalId::Type_Referenceable <<CSMWorld::UniversalId::Type_Activator <<CSMWorld::UniversalId::Type_Potion <<CSMWorld::UniversalId::Type_Apparatus <<CSMWorld::UniversalId::Type_Armor <<CSMWorld::UniversalId::Type_Book <<CSMWorld::UniversalId::Type_Clothing <<CSMWorld::UniversalId::Type_Container <<CSMWorld::UniversalId::Type_Creature <<CSMWorld::UniversalId::Type_Door <<CSMWorld::UniversalId::Type_Ingredient <<CSMWorld::UniversalId::Type_CreatureLevelledList <<CSMWorld::UniversalId::Type_ItemLevelledList <<CSMWorld::UniversalId::Type_Light <<CSMWorld::UniversalId::Type_Lockpick <<CSMWorld::UniversalId::Type_Miscellaneous <<CSMWorld::UniversalId::Type_Npc <<CSMWorld::UniversalId::Type_Probe <<CSMWorld::UniversalId::Type_Repair <<CSMWorld::UniversalId::Type_Static <<CSMWorld::UniversalId::Type_Weapon <<CSMWorld::UniversalId::Type_Script <<CSMWorld::UniversalId::Type_Region; mHighlighter = new ScriptHighlighter (document.getData(), mode, ScriptEdit::document()); connect (&document.getData(), SIGNAL (idListChanged()), this, SLOT (idListChanged())); connect (&mUpdateTimer, SIGNAL (timeout()), this, SLOT (updateHighlighting())); mUpdateTimer.setSingleShot (true); }
QSerialTerminal::QSerialTerminal(QWidget *parent) : QPlainTextEdit(parent) { serial = NULL; setUndoRedoEnabled(false); setMouseTracking(true); cursor = textCursor(); TotalRx = 0; TotalTx = 0; runningAverageDivisor = 1; editorCharacterCount = 0; rxTime.start(); transmitThread = new TransmitThread(); }
ColumnIndicatorTextEdit::ColumnIndicatorTextEdit(QWidget *parent) : QTextEdit(parent) { QFont font; font.setFamily(QLatin1String("Courier New")); setFont(font); setReadOnly(true); setUndoRedoEnabled(false); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sizePolicy.setVerticalStretch(3); setSizePolicy(sizePolicy); int cmx = 0, cmy = 0, cmw = 0, cmh = 0; getContentsMargins(&cmx, &cmy, &cmw, &cmh); m_columnIndicator = QFontMetrics(font).width(QLatin1Char('W')) * 100 + cmx + 1; m_columnIndicatorFont.setFamily(QLatin1String("Times")); m_columnIndicatorFont.setPointSizeF(7.0); }
ConsoleOutput::ConsoleOutput(QWidget *parent, bool enabled) :QTextEdit(parent) ,m_enabled(false) ,m_timerId(0) ,m_mode(CompileMode) ,m_nextMode(CompileMode) ,m_parseColors(true) ,m_parseVar(0) ,m_stdout_tie_stream(&m_stdout_tie_stream_buf) { setReadOnly(true); setFont(QFont("Monospace")); QPalette pal=palette(); pal.setColor(QPalette::Text,Qt::lightGray); pal.setColor(QPalette::Base,Qt::black); setPalette(pal); enable(enabled); resetTimes(); setUndoRedoEnabled(false); setTextInteractionFlags(Qt::TextBrowserInteraction); QAction* hideAction = new QAction("hide", this); addAction(hideAction); connect(hideAction, SIGNAL(triggered()), this, SLOT(hide())); QAction* clearAction = new QAction("clear", this); addAction(clearAction); connect(clearAction, SIGNAL(triggered()), this, SLOT(clear())); QAction* biggerAction = new QAction("bigger", this); addAction(biggerAction); biggerAction->setShortcut(Qt::CTRL + Qt::Key_Plus); connect(biggerAction, SIGNAL(triggered()), this, SLOT(bigger())); QAction* smallerAction = new QAction("smaller", this); addAction(smallerAction); smallerAction->setShortcut(Qt::CTRL + Qt::Key_Minus); connect(smallerAction, SIGNAL(triggered()), this, SLOT(smaller())); setContextMenuPolicy(Qt::ActionsContextMenu); s_instance = this; std::cout.tie(&m_stdout_tie_stream); // std::cout.setf(std::ios::unitbuf); }
OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) : QPlainTextEdit(parent), m_defaultFormat(currentCharFormat()), m_errorFormat(m_defaultFormat), m_warningFormat(m_defaultFormat), m_commandFormat(m_defaultFormat), m_messageFormat(m_defaultFormat) { setReadOnly(true); setUndoRedoEnabled(false); setFrameStyle(QFrame::NoFrame); m_errorFormat.setForeground(Qt::red); m_warningFormat.setForeground(Qt::darkYellow); m_commandFormat.setFontWeight(QFont::Bold); m_messageFormat.setForeground(Qt::blue); m_formatter = new Utils::OutputFormatter; m_formatter->setPlainTextEdit(this); }
TranslationUnitTextEdit::TranslationUnitTextEdit(Catalog* catalog, DocPosition::Part part, QWidget* parent) : KTextEdit(parent) , m_currentUnicodeNumber(0) , m_langUsesSpaces(true) , m_catalog(catalog) , m_part(part) , m_highlighter(new SyntaxHighlighter(this)) , m_completionBox(0) { setReadOnly(part==DocPosition::Source); setUndoRedoEnabled(false); setAcceptRichText(false); if (part==DocPosition::Target) { connect (document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(contentsChanged(int,int,int))); connect (this,SIGNAL(cursorPositionChanged()), this, SLOT(emitCursorPositionChanged())); }
ItemText::ItemText(const QString &text, bool isRichText, int maxLines, int maximumHeight, QWidget *parent) : QTextBrowser(parent) , ItemWidget(this) , m_textDocument() , m_maximumHeight(maximumHeight) { m_textDocument.setDefaultFont(font()); setReadOnly(true); setUndoRedoEnabled(false); setOpenExternalLinks(true); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFrameStyle(QFrame::NoFrame); setContextMenuPolicy(Qt::NoContextMenu); viewport()->installEventFilter(this); if (isRichText) m_textDocument.setHtml( text.left(defaultMaxBytes) ); else m_textDocument.setPlainText( text.left(defaultMaxBytes) ); m_textDocument.setDocumentMargin(0); setProperty("CopyQ_no_style", isRichText); if (maxLines > 0) { QTextBlock block = m_textDocument.findBlockByLineNumber(maxLines); if (block.isValid()) { QTextCursor tc(&m_textDocument); tc.setPosition(block.position() - 1); tc.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); tc.removeSelectedText(); tc.insertHtml( " " "<span style='background:rgba(0,0,0,30);border-radius:4px'>" " … " "</span>"); } } setDocument(&m_textDocument); }
//------------------------------------------------------------------------------------------------- QCommandPrompt::QCommandPrompt(QWidget *parent) :QPlainTextEdit(parent) ,m_sPrompt("Lua") ,m_sPromptChar(">") ,m_vHistory() ,m_vLineQueue() ,m_pTimerQueue(new QTimer(this)) ,m_font() ,m_mtxLineQueue() ,m_colDefault(Qt::darkBlue) ,m_nHistPos(0) ,m_nMaxLines(200) ,m_nMaxHist(5) ,m_nPromptPos() ,m_nTimerInterval(50) ,m_nBlockSize(200) ,m_bIsMuted(false) { setAcceptDrops(true); // drops will be accepted (filenames and commands) setUndoRedoEnabled(false); // undo is not necessary in a console setTabChangesFocus(false); // tab will be needed for auto completion setLineWrapMode(QPlainTextEdit::NoWrap); m_pTimerQueue->setSingleShot(false); m_pTimerQueue->start(m_nTimerInterval); connect(m_pTimerQueue, SIGNAL(timeout()), this, SLOT(writeQueue())); /* QStringList vWordList; vWordList.push_back("abcd"); vWordList.push_back("efgh"); vWordList.push_back("aaaaaa"); m_pCompleter = new QCompleter(vWordList); m_pCompleter->setCaseSensitivity(Qt::CaseSensitive); //Make caseInsensitive selection m_pCompleter->setCompletionMode(QCompleter::InlineCompletion); //Used to enable in line searching this->setCompleter(m_pCompleter); */ document()->setMaximumBlockCount(m_nMaxLines); }
Console::Console(QWidget *parent) : QPlainTextEdit(parent) , m_commandLineReady(false) , m_historyPos(-1) , m_completer(0) { QFont f; #ifdef Q_OS_LINUX f.setFamily("Monospace"); f.setPointSize(12); #elif defined(Q_OS_MAC) f.setFamily("Menlo"); f.setPointSize(12); #else f.setFamily("Consolas"); f.setPointSize(12); #endif setFont(f); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setUndoRedoEnabled(false); //setLineWrapMode(QPlainTextEdit::NoWrap); //setWordWrapMode(QTextOption::NoWrap); setBackgroundVisible(false); setFrameStyle(QFrame::NoFrame); setTabStopWidth(40); setAcceptDrops(false); setPrefix("Nexpo> "); setPrefixColor(QColor(30, 128, 50)); f.setBold(true); setPrefixFont(f); m_errorColor = QColor(200, 0, 0); // Restore saved history from last session QSettings settings; m_history = settings.value("consoleCommandHistory").toStringList(); prepareCommandLine(); }
ChatOutput::ChatOutput(QWidget *parent) : QTextBrowser(parent), autolinkRegexp(AUTOLINK_REGEXP) { setReadOnly(true); setOpenLinks(false); setUndoRedoEnabled(false); normalFormat.setFontWeight(QFont::Normal); boldFormat.setFontWeight(QFont::Bold); linkFormat.setAnchor(true); linkFormat.setAnchorHref(""); linkFormat.setFontWeight(QFont::Bold); linkFormat.setForeground(palette().link()); linkFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); cursor = textCursor(); Q_ASSERT(autolinkRegexp.isValid()); }
TextDocument::TextDocument(IrcBuffer* buffer) : QTextDocument(buffer) { qRegisterMetaType<TextDocument*>(); d.uc = 0; d.dirty = -1; d.rebuild = -1; d.lowlight = -1; d.clone = false; d.buffer = buffer; d.visible = false; d.formatter = new MessageFormatter(this); d.formatter->setBuffer(buffer); setUndoRedoEnabled(false); setMaximumBlockCount(1000); connect(buffer->connection(), SIGNAL(disconnected()), this, SLOT(lowlight())); connect(buffer, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(receiveMessage(IrcMessage*))); }
WChatLog::WChatLog(QWidget * pwParent, ITreeItemChatLogEvents * pContactOrGroup) : WTextBrowser(pwParent) { Assert(pContactOrGroup != NULL); m_pContactOrGroup = pContactOrGroup; m_fDisplayAllMessages = FALSE; m_tsMidnightNext = d_ts_zNA; setMinimumSize(10, 50); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setTextInteractionFlags((textInteractionFlags() & ~Qt::TextEditable) | Qt::LinksAccessibleByMouse); setUndoRedoEnabled(false); // setMaximumBlockCount setCursorWidth(0); //document()->setDefaultStyleSheet("p {text-indent:-10px; margin-left:10px; margin-top:5; margin-bottom:0; white-space:pre-wrap;}"); document()->setDefaultStyleSheet( "a."d_szClassForChatLog_ButtonHtml " { color: black; background-color: silver; text-decoration: none; font-weight: bold } " "a."d_szClassForChatLog_HyperlinkDisabled " { color: gray; text-decoration: none; } " "a.ha { color: navy; text-decoration: none; } " // Active Hyperlink (displayed in the normal blue color) ".d { color: green } " //"a.hb { padding: 6px; margin-left:10px; background-color: silver; border-style: outset; border-width: 2px; border-radius: 10px; border-color: black; } " //"a.hb:hover { background-color: rgb(224, 0, 0); border-style: inset; }"); ); /* QTextCursor oTextCursor = textCursor(); //oTextCursor.select(QTextCursor::Document); //oTextCursor.setBlockFormat(QTextBlockFormat()); oTextCursor.insertBlock(); m_oTextBlockComposing = oTextCursor.block(); CArrayPtrEvents arraypEvents; pContactOrGroup->Vault_GetEventsForChatLog(OUT &arraypEvents); ChatLog_EventsDisplay(IN arraypEvents); */ ChatLog_EventsRepopulate(); setOpenLinks(false); // Prevent the chat history to automatically open the hyperlinks connect(this, SIGNAL(highlighted(QUrl)), this, SLOT(SL_HyperlinkMouseHovering(QUrl))); connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(SL_HyperlinkClicked(QUrl))); }
//---------------------------------------------------------------------------- // ChatView //---------------------------------------------------------------------------- ChatView::ChatView(QWidget *parent) : PsiTextView(parent) , isMuc_(false) , oldTrackBarPosition(0) , dialog_(0) { setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); setReadOnly(true); setUndoRedoEnabled(false); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setLooks(this); #ifndef HAVE_X11 // linux has this feature built-in connect(this, SIGNAL(selectionChanged()), SLOT(autoCopy())); connect(this, SIGNAL(cursorPositionChanged()), SLOT(autoCopy())); #endif useMessageIcons_ = PsiOptions::instance()->getOption("options.ui.chat.use-message-icons").toBool(); if (useMessageIcons_) { int logIconsSize = fontInfo().pixelSize()*0.93; if (PsiOptions::instance()->getOption("options.ui.chat.scaled-message-icons").toBool()) { logIconReceive = IconsetFactory::iconPixmap("psi/notification_chat_receive").scaledToHeight(logIconsSize, Qt::SmoothTransformation); logIconSend = IconsetFactory::iconPixmap("psi/notification_chat_send").scaledToHeight(logIconsSize, Qt::SmoothTransformation); logIconDelivered = IconsetFactory::iconPixmap("psi/notification_chat_delivery_ok").scaledToHeight(logIconsSize, Qt::SmoothTransformation); logIconTime = IconsetFactory::iconPixmap("psi/notification_chat_time").scaledToHeight(logIconsSize, Qt::SmoothTransformation); logIconInfo = IconsetFactory::iconPixmap("psi/notification_chat_info").scaledToHeight(logIconsSize, Qt::SmoothTransformation); } else { logIconReceive = IconsetFactory::iconPixmap("psi/notification_chat_receive"); logIconSend = IconsetFactory::iconPixmap("psi/notification_chat_send"); logIconDelivered = IconsetFactory::iconPixmap("psi/notification_chat_delivery_ok"); logIconTime = IconsetFactory::iconPixmap("psi/notification_chat_time"); logIconInfo = IconsetFactory::iconPixmap("psi/notification_chat_info"); } addLogIconsResources(); } }