diff options
author | Tobias Markmann <tm@ayena.de> | 2016-11-10 11:22:12 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2016-11-10 12:37:15 (GMT) |
commit | 94ec9c25311f8d54519f045205d58526d885412a (patch) | |
tree | 423bf068441e7314e8736622f53dc2ce42f2244c /Swift/QtUI/QtTextEdit.cpp | |
parent | d2ba1ab8a36333523bf794c23226bd044e1717c2 (diff) | |
download | swift-94ec9c25311f8d54519f045205d58526d885412a.zip swift-94ec9c25311f8d54519f045205d58526d885412a.tar.bz2 |
Move Qt specific setting constants to QtUISettingConstants.h
Test-Information:
Builds on macOS 10.12.1, ./scons test=all passes, Swift
successfully logins and remembered Trellis configuration.
Change-Id: Id94d6af1448d44d7d46ba2b8606f3e5ebe98be7a
Diffstat (limited to 'Swift/QtUI/QtTextEdit.cpp')
-rw-r--r-- | Swift/QtUI/QtTextEdit.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp index d9ee2f4..e9708bf 100644 --- a/Swift/QtUI/QtTextEdit.cpp +++ b/Swift/QtUI/QtTextEdit.cpp @@ -1,57 +1,56 @@ /* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtTextEdit.h> #include <boost/algorithm/string.hpp> #include <boost/bind.hpp> #include <boost/tuple/tuple.hpp> #include <QApplication> #include <QKeyEvent> #include <QKeySequence> #include <QMenu> #include <QTextDocument> #include <Swiften/Base/Log.h> -#include <Swift/Controllers/SettingConstants.h> - #include <SwifTools/SpellChecker.h> #include <SwifTools/SpellCheckerFactory.h> #include <Swift/QtUI/QtSpellCheckerWindow.h> #include <Swift/QtUI/QtSwiftUtil.h> +#include <Swift/QtUI/QtUISettingConstants.h> #include <Swift/QtUI/QtUtilities.h> namespace Swift { QtTextEdit::QtTextEdit(SettingsProvider* settings, QWidget* parent) : QTextEdit(parent), checker_(nullptr), highlighter_(nullptr) { connect(this, SIGNAL(textChanged()), this, SLOT(handleTextChanged())); settings_ = settings; #ifdef HAVE_SPELLCHECKER setUpSpellChecker(); #endif handleTextChanged(); QTextOption textOption = document()->defaultTextOption(); textOption.setWrapMode(QTextOption::WordWrap); document()->setDefaultTextOption(textOption); } QtTextEdit::~QtTextEdit() { delete checker_; } void QtTextEdit::keyPressEvent(QKeyEvent* event) { int key = event->key(); Qt::KeyboardModifiers modifiers = event->modifiers(); if ((key == Qt::Key_Enter || key == Qt::Key_Return) && (modifiers == Qt::NoModifier || modifiers == Qt::KeypadModifier)) { emit returnPressed(); } else if (((key == Qt::Key_PageUp || key == Qt::Key_PageDown) && modifiers == Qt::ShiftModifier) || (key == Qt::Key_C && modifiers == Qt::ControlModifier && textCursor().selectedText().isEmpty()) || (key == Qt::Key_W && modifiers == Qt::ControlModifier) @@ -188,81 +187,81 @@ void QtTextEdit::addSuggestions(QMenu* menu, QContextMenuEvent* event) // suggestions are necessary return; } cursor.setPosition(boost::get<0>(wordPosition), QTextCursor::MoveAnchor); cursor.setPosition(boost::get<1>(wordPosition), QTextCursor::KeepAnchor); std::vector<std::string> wordList; checker_->getSuggestions(Q2PSTRING(cursor.selectedText()), wordList); if (wordList.size() == 0) { QAction* noSuggestions = new QAction(tr("No Suggestions"), menu); noSuggestions->setDisabled(true); menu->insertAction(insertPoint, noSuggestions); } else { for (auto& word : wordList) { QAction* wordAction = new QAction(word.c_str(), menu); menu->insertAction(insertPoint, wordAction); replaceWordActions_.push_back(wordAction); } } menu->insertAction(insertPoint, menu->addSeparator()); } } #ifdef HAVE_SPELLCHECKER void QtTextEdit::setUpSpellChecker() { delete highlighter_; highlighter_ = nullptr; delete checker_; checker_ = nullptr; - if (settings_->getSetting(SettingConstants::SPELL_CHECKER)) { + if (settings_->getSetting(QtUISettingConstants::SPELL_CHECKER)) { checker_ = SpellCheckerFactory().createSpellChecker(); if (checker_) { if (!checker_->isAutomaticallyDetectingLanguage()) { - checker_->setActiveLanguage(settings_->getSetting(SettingConstants::SPELL_CHECKER_LANGUAGE)); + checker_->setActiveLanguage(settings_->getSetting(QtUISettingConstants::SPELL_CHECKER_LANGUAGE)); } highlighter_ = new QtSpellCheckHighlighter(document(), checker_); } else { // Spellchecking is not working, as we did not get a valid checker from the factory. Disable spellchecking. SWIFT_LOG(warning) << "Spellchecking is currently misconfigured in Swift (e.g. missing dictionary or broken dictionary file). Disable spellchecking." << std::endl; - settings_->storeSetting(SettingConstants::SPELL_CHECKER, false); + settings_->storeSetting(QtUISettingConstants::SPELL_CHECKER, false); } } } #endif void QtTextEdit::spellCheckerSettingsWindow() { if (!spellCheckerWindow_) { spellCheckerWindow_ = new QtSpellCheckerWindow(settings_); settings_->onSettingChanged.connect(boost::bind(&QtTextEdit::handleSettingChanged, this, _1)); spellCheckerWindow_->show(); } else { spellCheckerWindow_->show(); spellCheckerWindow_->raise(); spellCheckerWindow_->activateWindow(); } if (checker_) { spellCheckerWindow_->setAutomaticallyIdentifiesLanguage(checker_->isAutomaticallyDetectingLanguage()); if (!checker_->isAutomaticallyDetectingLanguage()) { spellCheckerWindow_->setSupportedLanguages(checker_->supportedLanguages()); spellCheckerWindow_->setActiveLanguage(checker_->activeLanguage()); } } } void QtTextEdit::handleSettingChanged(const std::string& settings) { - if (settings == SettingConstants::SPELL_CHECKER.getKey() || - settings == SettingConstants::SPELL_CHECKER_LANGUAGE.getKey()) { + if (settings == QtUISettingConstants::SPELL_CHECKER.getKey() || + settings == QtUISettingConstants::SPELL_CHECKER_LANGUAGE.getKey()) { #ifdef HAVE_SPELLCHECKER setUpSpellChecker(); if (highlighter_) { highlighter_->rehighlight(); } #endif } } } |