Skip to content

Commit 4c5c159

Browse files
committed
Force GRASS shell font by setStyleSheet, hopefully fixes #7340; added black on white scheme
1 parent 15e3fc3 commit 4c5c159

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

src/plugins/grass/qgsgrassshell.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ QgsGrassShell::QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent, const ch
5959
#endif
6060

6161
mTerminal->setSize( 80, 25 );
62-
mTerminal->setColorScheme( COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW );
62+
mTerminal->setColorScheme( COLOR_SCHEME_BLACK_ON_WHITE );
6363
mTerminal->startShellProgram();
6464
mTerminal->setFocus( Qt::MouseFocusReason );
6565
}

src/plugins/grass/qtermwidget/ColorTables.h

+15
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,20 @@ static const ColorEntry blackonlightyellow_color_table[TABLE_COLORS] =
6464
ColorEntry( QColor( 84, 255, 255 ), 0, 0 ), ColorEntry( QColor( 255, 255, 255 ), 0, 0 )
6565
};
6666

67+
// copy of blackonlightyellow_color_table with background set to white
68+
static const ColorEntry blackonwhite_color_table[TABLE_COLORS] =
69+
{
70+
ColorEntry( QColor( 0, 0, 0 ), 0, 0 ), ColorEntry( QColor( 255, 255, 255 ), 1, 0 ),
71+
ColorEntry( QColor( 0, 0, 0 ), 0, 0 ), ColorEntry( QColor( 178, 24, 24 ), 0, 0 ),
72+
ColorEntry( QColor( 24, 178, 24 ), 0, 0 ), ColorEntry( QColor( 178, 104, 24 ), 0, 0 ),
73+
ColorEntry( QColor( 24, 24, 178 ), 0, 0 ), ColorEntry( QColor( 178, 24, 178 ), 0, 0 ),
74+
ColorEntry( QColor( 24, 178, 178 ), 0, 0 ), ColorEntry( QColor( 178, 178, 178 ), 0, 0 ),
75+
ColorEntry( QColor( 0, 0, 0 ), 0, 1 ), ColorEntry( QColor( 255, 255, 221 ), 1, 0 ),
76+
ColorEntry( QColor( 104, 104, 104 ), 0, 0 ), ColorEntry( QColor( 255, 84, 84 ), 0, 0 ),
77+
ColorEntry( QColor( 84, 255, 84 ), 0, 0 ), ColorEntry( QColor( 255, 255, 84 ), 0, 0 ),
78+
ColorEntry( QColor( 84, 84, 255 ), 0, 0 ), ColorEntry( QColor( 255, 84, 255 ), 0, 0 ),
79+
ColorEntry( QColor( 84, 255, 255 ), 0, 0 ), ColorEntry( QColor( 255, 255, 255 ), 0, 0 )
80+
};
81+
6782
#endif
6883

src/plugins/grass/qtermwidget/TerminalDisplay.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,13 @@ void TerminalDisplay::paintEvent( QPaintEvent* pe )
10821082
QPainter paint( this );
10831083
//qDebug("%s %d paintEvent %d %d", __FILE__, __LINE__, paint.window().top(), paint.window().right());
10841084

1085+
const QColor background = _colorTable[DEFAULT_BACK_COLOR].color;
10851086
foreach ( QRect rect, ( pe->region() & contentsRect() ).rects() )
10861087
{
1087-
drawBackground( paint, rect, palette().background().color(), true /* use opacity setting */ );
1088+
// setStyleSheet() changes background color -> use default
1089+
//drawBackground( paint, rect, palette().background().color(), true /* use opacity setting */ );
1090+
drawBackground( paint, rect, background, true );
1091+
10881092
drawContents( paint, rect );
10891093
}
10901094
// drawBackground(paint,contentsRect(),palette().background().color(), true /* use opacity setting */);

src/plugins/grass/qtermwidget/qtermwidget.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ void QTermWidget::init()
114114
{
115115
m_impl->m_terminalDisplay->setSize( 80, 40 );
116116

117+
// QWidget::setFont() does not guarantee to really change the font (see doc)
118+
// setStyleSheet() however should force the font change, it has however some
119+
// some side efects like changing background color
120+
if ( m_impl->m_terminalDisplay )
121+
{
122+
m_impl->m_terminalDisplay->setStyleSheet( "font-size: 10pt; font-family: Monospace;" );
123+
}
124+
117125
QFont font = QApplication::font();
118126
font.setFamily( "Monospace" );
119127
font.setPointSize( 10 );
@@ -181,6 +189,9 @@ void QTermWidget::setColorScheme( int scheme )
181189
case COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW:
182190
m_impl->m_terminalDisplay->setColorTable( blackonlightyellow_color_table );
183191
break;
192+
case COLOR_SCHEME_BLACK_ON_WHITE:
193+
m_impl->m_terminalDisplay->setColorTable( blackonwhite_color_table );
194+
break;
184195
default: //do nothing
185196
break;
186197
};

src/plugins/grass/qtermwidget/qtermwidget.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ struct TermWidgetImpl;
2727

2828
enum COLOR_SCHEME { COLOR_SCHEME_WHITE_ON_BLACK = 1,
2929
COLOR_SCHEME_GREEN_ON_BLACK,
30-
COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW
30+
COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW,
31+
COLOR_SCHEME_BLACK_ON_WHITE
3132
};
3233

3334
class QTermWidget : public QWidget
@@ -138,7 +139,7 @@ class QTermWidget : public QWidget
138139
#ifdef __cplusplus
139140
extern "C"
140141
#endif
141-
void *createTermWidget( int startnow, void *parent );
142+
void *createTermWidget( int startnow, void *parent );
142143

143144
#endif
144145

0 commit comments

Comments
 (0)