10#include "ui_configui.h"
20class Sonnet::ConfigViewPrivate
23 explicit ConfigViewPrivate(ConfigView *v);
28 void slotUpdateButton(
const QString &text);
29 void slotSelectionChanged();
30 void slotIgnoreWordAdded();
31 void slotIgnoreWordRemoved();
34ConfigViewPrivate::ConfigViewPrivate(ConfigView *v)
39void ConfigViewPrivate::slotUpdateButton(
const QString &text)
41 ui.addButton->setEnabled(!text.
isEmpty());
44void ConfigViewPrivate::slotSelectionChanged()
46 ui.removeButton->setEnabled(!ui.ignoreListWidget->selectedItems().isEmpty());
49void ConfigViewPrivate::slotIgnoreWordAdded()
51 QString newWord = ui.newIgnoreEdit->text();
52 ui.newIgnoreEdit->clear();
56 ignoreList.
append(newWord);
58 ui.ignoreListWidget->clear();
59 ui.ignoreListWidget->addItems(ignoreList);
61 Q_EMIT q->configChanged();
64void ConfigViewPrivate::slotIgnoreWordRemoved()
71 ui.ignoreListWidget->clear();
72 ui.ignoreListWidget->addItems(ignoreList);
74 Q_EMIT q->configChanged();
77ConfigView::ConfigView(
QWidget *parent)
79 , d(new ConfigViewPrivate(this))
82 layout->setContentsMargins(0, 0, 0, 0);
83 layout->setObjectName(QStringLiteral(
"SonnetConfigUILayout"));
85 d->ui.setupUi(d->wdg);
86 d->ui.languageList->setProperty(
"_breeze_force_frame",
true);
88 for (
int i = 0; i < d->ui.m_langCombo->count(); i++) {
89 const QString tag = d->ui.m_langCombo->itemData(i).toString();
93 auto *item =
new QListWidgetItem(d->ui.m_langCombo->itemText(i), d->ui.languageList);
97 d->ui.kcfg_backgroundCheckerEnabled->hide();
100 d->slotIgnoreWordAdded();
103 d->slotIgnoreWordRemoved();
106 layout->addWidget(d->wdg);
108 d->slotUpdateButton(text);
111 d->slotSelectionChanged();
113 d->ui.addButton->setEnabled(
false);
114 d->ui.removeButton->setEnabled(
false);
126ConfigView::~ConfigView() =
default;
128void ConfigView::setNoBackendFoundVisible(
bool show)
130 d->ui.nobackendfound->setVisible(
show);
133bool ConfigView::noBackendFoundVisible()
const
135 return d->ui.nobackendfound->isVisible();
138void ConfigView::setBackgroundCheckingButtonShown(
bool b)
140 d->ui.kcfg_backgroundCheckerEnabled->setVisible(b);
143bool ConfigView::backgroundCheckingButtonShown()
const
145 return !d->ui.kcfg_backgroundCheckerEnabled->isHidden();
148void ConfigView::setLanguage(
const QString &language)
150 d->ui.m_langCombo->setCurrentByDictionary(language);
153QString ConfigView::language()
const
155 if (d->ui.m_langCombo->count()) {
156 return d->ui.m_langCombo->currentDictionary();
162void ConfigView::setPreferredLanguages(
const QStringList &preferredLanguages)
164 for (
int i = 0; i < d->ui.languageList->count(); ++i) {
167 if (preferredLanguages.
contains(tag)) {
179 for (
int i = 0; i < d->ui.languageList->count(); i++) {
180 if (d->ui.languageList->item(i)->checkState() ==
Qt::Unchecked) {
183 preferredLanguages << d->ui.languageList->item(i)->data(
Qt::UserRole).toString();
185 return preferredLanguages;
188void ConfigView::setIgnoreList(
const QStringList &ignoreList)
190 d->ignoreList = ignoreList;
191 d->ignoreList.sort();
192 d->ui.ignoreListWidget->clear();
193 d->ui.ignoreListWidget->addItems(d->ignoreList);
199 return d->ignoreList;
202#include "moc_configview.cpp"
void dictionaryChanged(const QString &dictionary)
Emitted whenever the current dictionary changes.
void textChanged(const QString &text)
void append(QList< T > &&value)
qsizetype removeAll(const AT &t)
bool isEmpty() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QString toString() const const