Mercurial > hg > octave-avbm
diff libgui/src/settings-dialog.cc @ 16622:818eef7b2618
allow terminal colors to be set from preferences dialog
* QTerminalInterface.h (QTerminalInterface::setBackgroundColor,
QTerminalInterface::setForeroundColor,
QTerminalInterface::setSelectionColor,
QTerminalInterface::setCursorColor): New functions.
* QUnixTerminalImpl.h, QUnixTerminalImpl.cpp
QUnixTerminalImpl::setBackgroundColor,
QUnixTerminalImpl::setForeroundColor,
QUnixTerminalImpl::setSelectionColor,
QUnixTerminalImpl::setCursorColor): New functions.
* QWinTerminalImpl.h, QWinTerminalImpl.cpp
(QConsolePrivate::setCursorColor): New argument, useForegroundColor.
(QConsolePrivate::m_selectionColor, QConsolePrivate::m_cursorColor):
New member variablebs.
(QConsolePrivate::selectionColor, QConsolePrivate::cursorColor,
QConsolePrivate::setSelectionColor, QConsolePrivate::setCursorColor):
Use member variables instead of Windows console color map.
(QConsolePrivate::cursorColor): Return foreground color if stored
color is invalid.
(QConsolePrivate::setCursorColor): Store invalid color if
useForegroundcolor.
(QConsolePrivate::QConsolePrivate): Set default selection and cursor
colors.
* QTerminal.cc (QTerminal::notice_settings): Handle terminal color
settings.
* resource-manager.h, resource-manager.cc
(resource_manager::terminal_color_names,
resource_manager::terminal_default_colors,
resource_manager::terminal_color_chars): New functions.
* settings-dialog.h, settings-dialog.cc
(settings_dialog::read_terminal_colors): New function.
(settings_dialog::settings_dialog): Call read_terminal_colors. Read
valud for using foreground color for cursor color.
(settings_dialog::write_terminal_colors): New function.
(settings_dialog::write_changed_settings): Call
write_terminal_colors. Handle setting for using foreground color for
cursor color.
* settings-dialog.ui: Add color selection to terminal settings
dialog.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 May 2013 06:00:44 -0400 (2013-05-06) |
parents | a1f613e5066d |
children | 9c0487bb205b |
line wrap: on
line diff
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -97,6 +97,7 @@ ui->useProxyServer->setChecked (settings->value ("useProxyServer",false).toBool ()); ui->proxyHostName->setText (settings->value ("proxyHostName").toString ()); ui->terminal_cursorBlinking->setChecked (settings->value ("terminal/cursorBlinking",true).toBool ()); + ui->terminal_cursorUseForegroundColor->setChecked (settings->value ("terminal/cursorUseForegroundColor",true).toBool ()); QString cursorType = settings->value ("terminal/cursorType","ibeam").toString (); @@ -129,6 +130,9 @@ // qorkspace colors read_workspace_colors (settings); + // terminal colors + read_terminal_colors (settings); + #ifdef HAVE_QSCINTILLA // editor styles: create lexer, read settings, and create dialog elements QsciLexer *lexer; @@ -285,6 +289,43 @@ ui->workspace_colors_box->setLayout (style_grid); } +void +settings_dialog::read_terminal_colors (QSettings *settings) +{ + + QList<QColor> default_colors = resource_manager::terminal_default_colors (); + QStringList class_names = resource_manager::terminal_color_names (); + QString class_chars = resource_manager::terminal_color_chars (); + int nr_of_classes = class_chars.length (); + + QGridLayout *style_grid = new QGridLayout (); + QLabel *description[nr_of_classes]; + color_picker *color[nr_of_classes]; + + int column = 0; + int row = 0; + for (int i = 0; i < nr_of_classes; i++) + { + description[i] = new QLabel (class_names.at (i)); + description[i]->setAlignment (Qt::AlignRight); + QVariant default_var = default_colors.at (i); + QColor setting_color = settings->value ("terminal/color_"+class_chars.mid (i,1), + default_var).value<QColor> (); + color[i] = new color_picker (setting_color); + color[i]->setObjectName ("terminal_color_"+class_chars.mid (i,1)); + color[i]->setMinimumSize (30,10); + style_grid->addWidget (description[i], row,2*column); + style_grid->addWidget (color[i], row,2*column+1); + if (++column == 2) + { + row++; + column = 0; + } + } + + // place grid with elements into the tab + ui->terminal_colors_box->setLayout (style_grid); +} void settings_dialog::write_changed_settings () @@ -330,6 +371,7 @@ settings->setValue ("proxyUserName", ui->proxyUserName->text ()); settings->setValue ("proxyPassword", ui->proxyPassword->text ()); settings->setValue ("terminal/cursorBlinking", ui->terminal_cursorBlinking->isChecked ()); + settings->setValue ("terminal/cursorUseForegroundColor", ui->terminal_cursorUseForegroundColor->isChecked ()); // the cursor QString cursorType; @@ -366,6 +408,8 @@ #endif write_workspace_colors (settings); + + write_terminal_colors (settings); } #ifdef HAVE_QSCINTILLA @@ -444,3 +488,20 @@ } settings->sync (); } + +void +settings_dialog::write_terminal_colors (QSettings *settings) +{ + QString class_chars = resource_manager::terminal_color_chars (); + color_picker *color; + + for (int i = 0; i < class_chars.length (); i++) + { + color = ui->terminal_colors_box->findChild <color_picker *>( + "terminal_color_"+class_chars.mid (i,1)); + if (color) + settings->setValue ("terminal/color_"+class_chars.mid (i,1), + color->color ()); + } + settings->sync (); +}