improve performance of console, shader view

This commit is contained in:
Garux 2023-05-18 19:09:19 +06:00
parent 8c92cb69ed
commit 2b3a34b299
3 changed files with 30 additions and 30 deletions

View File

@ -35,7 +35,7 @@
#include "gtkmisc.h"
#include "mainframe.h"
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QContextMenuEvent>
// 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 );
}
{

View File

@ -38,7 +38,7 @@
#include <QSplitter>
#include <QTreeWidget>
#include <QHeaderView>
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
@ -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 );
}

View File

@ -56,7 +56,6 @@
#include "gtkutil/guisettings.h"
#include <QPlainTextEdit>
#include <QComboBox>
#include <QTextEdit>
#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" );