diff --git a/radiant/console.cpp b/radiant/console.cpp index 7d3b6055..5a75b605 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -35,7 +35,7 @@ #include "gtkmisc.h" #include "mainframe.h" -#include +#include #include // handle to the console log file @@ -81,15 +81,15 @@ void Sys_LogFile( bool enable ){ } } -QTextEdit* g_console = 0; +QPlainTextEdit* g_console = 0; -class QTextEdit_console : public QTextEdit +class QPlainTextEdit_console : public QPlainTextEdit { protected: void contextMenuEvent( QContextMenuEvent *event ) override { QMenu *menu = createStandardContextMenu(); QAction *action = menu->addAction( "Clear" ); - connect( action, &QAction::triggered, this, &QTextEdit::clear ); + connect( action, &QAction::triggered, this, &QPlainTextEdit::clear ); menu->exec( event->globalPos() ); delete menu; } @@ -97,10 +97,9 @@ protected: QWidget* Console_constructWindow(){ - QTextEdit *text = new QTextEdit_console(); + QPlainTextEdit *text = new QPlainTextEdit_console(); text->setReadOnly( true ); text->setUndoRedoEnabled( false ); - text->setAcceptRichText( false ); text->setMinimumHeight( 10 ); text->setFocusPolicy( Qt::FocusPolicy::NoFocus ); @@ -120,9 +119,9 @@ QWidget* Console_constructWindow(){ class GtkTextBufferOutputStream : public TextOutputStream { - QTextEdit* textBuffer; + QPlainTextEdit* textBuffer; public: - GtkTextBufferOutputStream( QTextEdit* textBuffer ) : textBuffer( textBuffer ) { + GtkTextBufferOutputStream( QPlainTextEdit* textBuffer ) : textBuffer( textBuffer ) { } std::size_t #ifdef __GNUC__ @@ -152,21 +151,25 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){ if ( level != SYS_NOCON ) { if ( g_console != 0 ) { - g_console->moveCursor( QTextCursor::End ); // must go before setTextColor() + g_console->moveCursor( QTextCursor::End ); // must go before setTextColor() & insertPlainText() - switch ( level ) { - case SYS_WRN: - g_console->setTextColor( QColor( 255, 127, 0 ) ); - break; - case SYS_ERR: - g_console->setTextColor( QColor( 255, 0, 0 ) ); - break; - case SYS_STD: - case SYS_VRB: - default: - g_console->setTextColor( g_console->palette().text().color() ); - break; + QTextCharFormat format = g_console->currentCharFormat(); + switch ( level ) + { + case SYS_WRN: + format.setForeground( QColor( 255, 127, 0 ) ); + break; + case SYS_ERR: + format.setForeground( QColor( 255, 0, 0 ) ); + break; + case SYS_STD: + case SYS_VRB: + default: + format.setForeground( g_console->palette().text().color() ); + break; + } + g_console->setCurrentCharFormat( format ); } { diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 98bf07b2..a06f61f1 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -691,7 +691,7 @@ namespace bool g_entityInspector_windowConstructed = false; QTreeWidget* g_entityClassList; -QTextEdit* g_entityClassComment; +QPlainTextEdit* g_entityClassComment; QCheckBox* g_entitySpawnflagsCheck[MAX_FLAGS]; @@ -1192,10 +1192,9 @@ QWidget* EntityInspector_constructWindow( QWidget* toplevel ){ splitter->addWidget( tree ); } { - auto text = g_entityClassComment = new QTextEdit; + auto text = g_entityClassComment = new QPlainTextEdit; text->setReadOnly( true ); text->setUndoRedoEnabled( false ); - text->setAcceptRichText( false ); splitter->addWidget( text ); } diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 966b83c2..a7730092 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -56,7 +56,6 @@ #include "gtkutil/guisettings.h" #include #include -#include #include "os/path.h" #include "math/aabb.h" @@ -405,7 +404,7 @@ void DoAbout(){ class TextEditor { QWidget *m_window = 0; - QTextEdit *m_textView; // slave, text widget from the gtk editor + QPlainTextEdit *m_textView; // slave, text widget from the gtk editor QPushButton *m_button; // save button CopiedString m_filename; @@ -416,9 +415,8 @@ class TextEditor auto *vbox = new QVBoxLayout( m_window ); vbox->setContentsMargins( 0, 0, 0, 0 ); - m_textView = new QTextEdit; - m_textView->setAcceptRichText( false ); - m_textView->setLineWrapMode( QTextEdit::LineWrapMode::NoWrap ); + m_textView = new QPlainTextEdit; + m_textView->setLineWrapMode( QPlainTextEdit::LineWrapMode::NoWrap ); vbox->addWidget( m_textView ); m_button = new QPushButton( "Save" );