Sonnet

nsspellcheckerclient.mm
1 /*
2  * nsspellcheckerclient.mm
3  *
4  * SPDX-FileCopyrightText: 2015 Nick Shaforostoff <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-or-later
7  */
8 #include "nsspellcheckerclient.h"
9 #include "nsspellcheckerdict.h"
10 
11 #import <AppKit/AppKit.h>
12 
13 using namespace Sonnet;
14 
15 NSSpellCheckerClient::NSSpellCheckerClient(QObject *parent)
16  : Client(parent)
17 {
18 }
19 
20 NSSpellCheckerClient::~NSSpellCheckerClient()
21 {
22 }
23 
24 int NSSpellCheckerClient::reliability() const
25 {
26  return qEnvironmentVariableIsSet("SONNET_PREFER_NSSPELLCHECKER") ? 9999 : 30;
27 }
28 
29 SpellerPlugin *NSSpellCheckerClient::createSpeller(const QString &language)
30 {
31  return new NSSpellCheckerDict(language);
32 }
33 
34 QStringList NSSpellCheckerClient::languages() const
35 {
36  QStringList lst;
37  NSArray* availableLanguages = [[NSSpellChecker sharedSpellChecker]
38  availableLanguages];
39  for (NSString* lang_code in availableLanguages) {
40  lst.append(QString::fromNSString(lang_code));
41  }
42  return lst;
43 }
44 
void append(const T &value)
QString fromNSString(const NSString *string)
The sonnet namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:14:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.