Skip to content

Commit 8d59166

Browse files
author
Eugene Shalygin
committed
Add option to set error color
1 parent 3a22422 commit 8d59166

File tree

6 files changed

+256
-195
lines changed

6 files changed

+256
-195
lines changed

src/spellcheckerconstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const char SETTINGS_OUTPUT_PANE_COL_WORD[] = "ColWord";
5555
const char SETTINGS_OUTPUT_PANE_COL_LITERAL[] = "ColLiteral";
5656
const char SETTINGS_OUTPUT_PANE_COL_LINE[] = "ColLine";
5757
const char SETTINGS_OUTPUT_PANE_COL_COLUMN[] = "ColColumn";
58+
const char SETTINGS_UNDERLINE_COLOR[] = "UnderlineColor";
5859

5960
const char OUTPUT_PANE_TITLE[] = QT_TRANSLATE_NOOP( "SpellChecker::Internal::OutputPane", "Spelling Mistakes" );
6061

src/spellcheckercore.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,7 @@ void SpellCheckerCore::addMisspelledWords( const QString& fileName, const WordLi
244244
* and color stays the same, we just want to underline the mistake. */
245245
QTextCharFormat format = cursor.charFormat();
246246
format.setFontUnderline( true );
247-
static const QColor underLineColor = QColor( Qt::red );
248-
format.setUnderlineColor( underLineColor );
247+
format.setUnderlineColor( d->settings.underlineColor );
249248
format.setUnderlineStyle( QTextCharFormat::WaveUnderline );
250249
format.setToolTip( word.suggestions.isEmpty()
251250
? QStringLiteral( "Incorrect spelling" )

src/spellcheckercoreoptionswidget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private slots:
6060
void toolButtonRemoveProjectClicked();
6161
void listWidgetItemChanged( QListWidgetItem* item );
6262

63-
private:
63+
private:
6464
void updateWithSettings( const SpellCheckerCoreSettings* const settings );
6565

6666
Ui::SpellCheckerCoreOptionsWidget ui;
@@ -96,6 +96,7 @@ SpellCheckerCoreOptionsWidget::SpellCheckerCoreOptionsWidget( SpellCheckerCoreSe
9696
* is for the toolbar since nowhere else is a normal one needed. */
9797
ui.toolButtonRemoveProject->setIcon( Utils::Icon( { { ":/utils/images/minus.png"
9898
, Utils::Theme::PaletteText } }, Utils::Icon::Tint ).icon() );
99+
ui.buttonUnderlineColor->setAlphaAllowed( false );
99100

100101
const QMap<QString, ISpellChecker*> availableSpellCheckers = SpellCheckerCore::instance()->addedSpellCheckers();
101102
// todo: change QMap to std::map and use std::views::keys
@@ -129,6 +130,7 @@ SpellCheckerCoreSettings SpellCheckerCoreOptionsWidget::settings()
129130
settings.checkExternalFiles = ui.checkBoxCheckExternal->isChecked();
130131
settings.projectsToIgnore = m_projectsToIgnore;
131132
settings.replaceAllFromRightClick = ui.checkBoxReplaceAllRightClick->isChecked();
133+
settings.underlineColor = ui.buttonUnderlineColor->color();
132134
return settings;
133135
}
134136
// --------------------------------------------------
@@ -180,6 +182,7 @@ void SpellCheckerCoreOptionsWidget::updateWithSettings( const SpellCheckerCoreSe
180182
ui.listWidget->clear();
181183
ui.listWidget->addItems( m_projectsToIgnore );
182184
ui.checkBoxReplaceAllRightClick->setChecked( settings->replaceAllFromRightClick );
185+
ui.buttonUnderlineColor->setColor( settings->underlineColor );
183186
}
184187
// --------------------------------------------------
185188

0 commit comments

Comments
 (0)