diff options
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 7 | ||||
-rw-r--r-- | Swift/QtUI/QtTextEdit.cpp | 29 | ||||
-rw-r--r-- | Swift/QtUI/QtTextEdit.h | 6 |
3 files changed, 24 insertions, 18 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 0da4563..bda6b3e 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -311,7 +311,7 @@ void QtChatWindow::beginCorrection() { cursor.endEditBlock(); isCorrection_ = true; correctingLabel_->show(); - input_->setStyleSheet(alertStyleSheet_); + input_->setCorrectionHighlight(true); labelsWidget_->setEnabled(false); } @@ -325,7 +325,7 @@ void QtChatWindow::cancelCorrection() { cursor.removeSelectedText(); isCorrection_ = false; correctingLabel_->hide(); - input_->setStyleSheet(qApp->styleSheet()); + input_->setCorrectionHighlight(false); labelsWidget_->setEnabled(true); } @@ -844,10 +844,7 @@ std::string QtChatWindow::getID() const { } void QtChatWindow::setEmphasiseFocus(bool emphasise) { - input_->setAttribute(Qt::WA_MacShowFocusRect, emphasise); -#ifdef SWIFTEN_PLATFORM_WINDOWS input_->setEmphasiseFocus(emphasise); -#endif } void QtChatWindow::showRoomConfigurationForm(Form::ref form) { diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp index 60dac9b..d9ee2f4 100644 --- a/Swift/QtUI/QtTextEdit.cpp +++ b/Swift/QtUI/QtTextEdit.cpp @@ -82,34 +82,41 @@ void QtTextEdit::keyPressEvent(QKeyEvent* event) { void QtTextEdit::setEmphasiseFocus(bool emphasise) { emphasiseFocus_ = emphasise; - updateEmphasisedFocus(); + updateStyleSheet(); } -void QtTextEdit::updateEmphasisedFocus() { +void QtTextEdit::setCorrectionHighlight(bool correctionHighlight) { + correctionHighlight_ = correctionHighlight; + updateStyleSheet(); +} + +void QtTextEdit::updateStyleSheet() { + QString newStyleSheet; + + if (correctionHighlight_) { + newStyleSheet += "background: rgb(255, 255, 153); color: black;"; + } + if (emphasiseFocus_) { if (hasFocus()) { - setStyleSheet("border: 2px solid palette(highlight);"); - } - else { - setStyleSheet(""); + newStyleSheet += "border: 2px solid palette(highlight);"; } } - else { - setStyleSheet(""); - } + + setStyleSheet(newStyleSheet); handleTextChanged(); } void QtTextEdit::focusInEvent(QFocusEvent* event) { receivedFocus(); QTextEdit::focusInEvent(event); - updateEmphasisedFocus(); + updateStyleSheet(); } void QtTextEdit::focusOutEvent(QFocusEvent* event) { lostFocus(); QTextEdit::focusOutEvent(event); - updateEmphasisedFocus(); + updateStyleSheet(); } void QtTextEdit::handleTextChanged() { diff --git a/Swift/QtUI/QtTextEdit.h b/Swift/QtUI/QtTextEdit.h index 921c4b9..228aa9e 100644 --- a/Swift/QtUI/QtTextEdit.h +++ b/Swift/QtUI/QtTextEdit.h @@ -9,7 +9,6 @@ #include <QPointer> #include <QTextEdit> -#include <Swift/Controllers/SettingConstants.h> #include <Swift/Controllers/Settings/SettingsProvider.h> #include <SwifTools/SpellParser.h> @@ -26,7 +25,9 @@ namespace Swift { QtTextEdit(SettingsProvider* settings, QWidget* parent = nullptr); virtual ~QtTextEdit(); virtual QSize sizeHint() const; + void setEmphasiseFocus(bool emphasise); + void setCorrectionHighlight(bool coorectionHighlight); signals: void wordCorrected(QString& word); @@ -53,7 +54,7 @@ namespace Swift { void setUpSpellChecker(); void spellCheckerSettingsWindow(); PositionPair getWordFromCursor(int cursorPosition); - void updateEmphasisedFocus(); + void updateStyleSheet(); private: SpellChecker* checker_; @@ -62,5 +63,6 @@ namespace Swift { SettingsProvider* settings_; QPointer<QtSpellCheckerWindow> spellCheckerWindow_; bool emphasiseFocus_ = false; + bool correctionHighlight_ = false; }; } |