Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/spellcheckerconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const char SETTINGS_OUTPUT_PANE_COL_WORD[] = "ColWord";
const char SETTINGS_OUTPUT_PANE_COL_LITERAL[] = "ColLiteral";
const char SETTINGS_OUTPUT_PANE_COL_LINE[] = "ColLine";
const char SETTINGS_OUTPUT_PANE_COL_COLUMN[] = "ColColumn";
const char SETTINGS_ERRORS_COLOR[] = "ErrorsColor";

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

Expand Down
6 changes: 3 additions & 3 deletions src/spellcheckercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ void SpellCheckerCore::addMisspelledWords( const QString& fileName, const WordLi
* and color stays the same, we just want to underline the mistake. */
QTextCharFormat format = cursor.charFormat();
format.setFontUnderline( true );
static const QColor underLineColor = QColor( Qt::red );
format.setUnderlineColor( underLineColor );
format.setUnderlineColor( d->settings.errorsColor );
format.setUnderlineStyle( QTextCharFormat::WaveUnderline );
format.setToolTip( word.suggestions.isEmpty()
? QStringLiteral( "Incorrect spelling" )
Expand Down Expand Up @@ -439,8 +438,9 @@ void SpellCheckerCore::futureFinished()
, Qt::QueuedConnection
, Q_ARG( QString, fileName )
, Q_ARG( SpellChecker::WordList, wordsToSpellCheck ) );
} else {
locker.unlock();
}
locker.unlock();
watcher->deleteLater();
/* Add the list of misspelled words to the mistakes model */
addMisspelledWords( fileName, checkedWords );
Expand Down
5 changes: 4 additions & 1 deletion src/spellcheckercoreoptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private slots:
void toolButtonRemoveProjectClicked();
void listWidgetItemChanged( QListWidgetItem* item );

private:
private:
void updateWithSettings( const SpellCheckerCoreSettings* const settings );

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

const QMap<QString, ISpellChecker*> availableSpellCheckers = SpellCheckerCore::instance()->addedSpellCheckers();
// todo: change QMap to std::map and use std::views::keys
Expand Down Expand Up @@ -129,6 +130,7 @@ SpellCheckerCoreSettings SpellCheckerCoreOptionsWidget::settings()
settings.checkExternalFiles = ui.checkBoxCheckExternal->isChecked();
settings.projectsToIgnore = m_projectsToIgnore;
settings.replaceAllFromRightClick = ui.checkBoxReplaceAllRightClick->isChecked();
settings.errorsColor = ui.buttonErrorsColor->color();
return settings;
}
// --------------------------------------------------
Expand Down Expand Up @@ -180,6 +182,7 @@ void SpellCheckerCoreOptionsWidget::updateWithSettings( const SpellCheckerCoreSe
ui.listWidget->clear();
ui.listWidget->addItems( m_projectsToIgnore );
ui.checkBoxReplaceAllRightClick->setChecked( settings->replaceAllFromRightClick );
ui.buttonErrorsColor->setColor( settings->errorsColor );
}
// --------------------------------------------------

Expand Down
96 changes: 74 additions & 22 deletions src/spellcheckercoreoptionswidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
Expand All @@ -24,23 +24,23 @@
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxSpellChecker"/>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="0">
<layout class="QVBoxLayout" name="spellCheckerOptionsWidgetLayout"/>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Project Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxOnlyCheckCurrent">
<property name="toolTip">
<string>Parsing the whole project can sometimes take a lot of time, especially for large projects. This setting will restrict the number of files parsed to only the current editor when a project is opened or a setting is changed.</string>
</property>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxReplaceAllRightClick">
<property name="text">
<string>Only check current editor</string>
<string>Replace all occurrence of selected word from suggestion on Right Click menu </string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxCheckExternal">
<property name="toolTip">
<string>Enable or disable if the SpellChecker should attempt to parse files external to the current active project as they are opened/edited.</string>
Expand All @@ -50,16 +50,32 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxOnlyCheckCurrent">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Parsing the whole project can sometimes take a lot of time, especially for large projects. This setting will restrict the number of files parsed to only the current editor when a project is opened or a setting is changed.</string>
</property>
<property name="text">
<string>Only check current editor</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Projects to ignore</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QListWidget" name="listWidget"/>
<widget class="QWidget" name="widget_2" native="true"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
Expand All @@ -77,7 +93,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -104,20 +120,53 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxReplaceAllRightClick">
<property name="text">
<string>Replace all occurrence of selected word from suggestion on Right Click menu </string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="labelErrorsColor">
<property name="text">
<string>Errors color:</string>
</property>
</widget>
</item>
<item>
<widget class="Utils::QtColorButton" name="buttonErrorsColor">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0">
<widget class="QWidget" name="widgetErrorOutput" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
Expand Down Expand Up @@ -148,7 +197,6 @@
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
Expand Down Expand Up @@ -181,11 +229,15 @@
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QVBoxLayout" name="spellCheckerOptionsWidgetLayout"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::QtColorButton</class>
<extends>QToolButton</extends>
<header location="global">utils/qtcolorbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
4 changes: 4 additions & 0 deletions src/spellcheckercoresettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void SpellCheckerCoreSettings::saveToSettings( Utils::QtcSettings* settings ) co
settings->setValue( Constants::SETTING_CHECK_EXTERNAL, checkExternalFiles );
settings->setValue( Constants::PROJECTS_TO_IGNORE, projectsToIgnore );
settings->setValue( Constants::REPLACE_ALL_FROM_RIGHT_CLICK, replaceAllFromRightClick );
settings->setValue( Constants::SETTINGS_ERRORS_COLOR, errorsColor );
settings->endGroup(); /* CORE_SETTINGS_GROUP */
settings->sync();
}
Expand All @@ -68,6 +69,7 @@ void SpellCheckerCoreSettings::loadFromSettings( Utils::QtcSettings* settings )
checkExternalFiles = settings->value( Constants::SETTING_CHECK_EXTERNAL, checkExternalFiles ).toBool();
projectsToIgnore = settings->value( Constants::PROJECTS_TO_IGNORE, projectsToIgnore ).toStringList();
replaceAllFromRightClick = settings->value( Constants::REPLACE_ALL_FROM_RIGHT_CLICK, replaceAllFromRightClick ).toBool();
errorsColor = settings->value( Constants::SETTINGS_ERRORS_COLOR, errorsColor ).value<QColor>();
settings->endGroup(); /* CORE_SETTINGS_GROUP */
}
// --------------------------------------------------
Expand All @@ -81,6 +83,7 @@ SpellCheckerCoreSettings& SpellCheckerCoreSettings::operator=( const SpellChecke
this->checkExternalFiles = other.checkExternalFiles;
this->projectsToIgnore = other.projectsToIgnore;
this->replaceAllFromRightClick = other.replaceAllFromRightClick;
this->errorsColor = other.errorsColor;
emit settingsChanged();
}
return *this;
Expand All @@ -95,6 +98,7 @@ bool SpellCheckerCoreSettings::operator==( const SpellCheckerCoreSettings& other
different = different | ( checkExternalFiles != other.checkExternalFiles );
different = different | ( projectsToIgnore != other.projectsToIgnore );
different = different | ( replaceAllFromRightClick != other.replaceAllFromRightClick );
different |= errorsColor != other.errorsColor;
return ( different == false );
}
// --------------------------------------------------
2 changes: 2 additions & 0 deletions src/spellcheckercoresettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <utils/qtcsettings.h>

#include <QColor>
#include <QObject>

namespace SpellChecker {
Expand All @@ -43,6 +44,7 @@ class SpellCheckerCoreSettings
bool operator==( const SpellCheckerCoreSettings& other ) const;

QString activeSpellChecker;
QColor errorsColor{ Qt::red };
bool onlyParseCurrentFile;
bool checkExternalFiles;
QStringList projectsToIgnore;
Expand Down