mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[spellcheck] Added dialog with spell check settings.
This commit is contained in:
parent
c3a0e1f13a
commit
0a7773bec1
@ -30,7 +30,7 @@ SpellCheck::SpellCheck()
|
|||||||
|
|
||||||
bool SpellCheck::isContinousSpellCheckingEnabled() const
|
bool SpellCheck::isContinousSpellCheckingEnabled() const
|
||||||
{
|
{
|
||||||
return m_speller->isEnabled();
|
return mApp->speller()->isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpellCheck::toggleContinousSpellChecking()
|
void SpellCheck::toggleContinousSpellChecking()
|
||||||
|
136
src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp
Normal file
136
src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.cpp
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "spellcheckdialog.h"
|
||||||
|
#include "ui_spellcheckdialog.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "speller.h"
|
||||||
|
#include "mainapplication.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
SpellCheckDialog::SpellCheckDialog(QWidget* parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, ui(new Ui::SpellCheckDialog)
|
||||||
|
, m_listChanged(false)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->dictPath->setText(mApp->speller()->dictionaryPath());
|
||||||
|
|
||||||
|
QFile file(mApp->currentProfilePath() + "userdictionary.txt");
|
||||||
|
if (!file.open(QFile::ReadOnly)) {
|
||||||
|
qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QString word;
|
||||||
|
QTextStream stream(&file);
|
||||||
|
|
||||||
|
while (!stream.atEnd()) {
|
||||||
|
stream >> word;
|
||||||
|
word = word.trimmed();
|
||||||
|
|
||||||
|
if (!word.isEmpty()) {
|
||||||
|
ui->userDictList->insertItem(0, word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(ui->changeDictPath, SIGNAL(clicked()), this, SLOT(changeDictionaryPath()));
|
||||||
|
connect(ui->add, SIGNAL(clicked()), this, SLOT(addUserWord()));
|
||||||
|
connect(ui->remove, SIGNAL(clicked()), this, SLOT(removeUserWord()));
|
||||||
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
|
||||||
|
|
||||||
|
ui->userDictList->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellCheckDialog::changeDictionaryPath()
|
||||||
|
{
|
||||||
|
const QString &path = QFileDialog::getExistingDirectory(this, tr("Choose dictionary path..."),
|
||||||
|
ui->dictPath->text());
|
||||||
|
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
ui->dictPath->setText(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellCheckDialog::addUserWord()
|
||||||
|
{
|
||||||
|
const QString &word = QInputDialog::getText(0, tr("Add new word..."), tr("Add new word:"));
|
||||||
|
|
||||||
|
if (!word.isEmpty()) {
|
||||||
|
ui->userDictList->addItem(word);
|
||||||
|
ui->userDictList->setCurrentRow(ui->userDictList->count() - 1);
|
||||||
|
|
||||||
|
m_listChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellCheckDialog::removeUserWord()
|
||||||
|
{
|
||||||
|
QListWidgetItem* item = ui->userDictList->currentItem();
|
||||||
|
|
||||||
|
if (!item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_listChanged = true;
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpellCheckDialog::saveSettings()
|
||||||
|
{
|
||||||
|
// Save only when changed
|
||||||
|
|
||||||
|
if (ui->dictPath->text() != mApp->speller()->dictionaryPath()) {
|
||||||
|
Settings settings;
|
||||||
|
settings.beginGroup("SpellCheck");
|
||||||
|
settings.setValue("dictionaryPath", ui->dictPath->text());
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_listChanged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(mApp->currentProfilePath() + "userdictionary.txt");
|
||||||
|
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
|
||||||
|
qWarning() << "SpellCheckDialog: Cannot open file" << file.fileName() << "for reading!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream stream(&file);
|
||||||
|
int count = ui->userDictList->count();
|
||||||
|
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
const QString &word = ui->userDictList->item(i)->text();
|
||||||
|
stream << word << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
SpellCheckDialog::~SpellCheckDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
49
src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.h
Normal file
49
src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef SPELLCHECKDIALOG_H
|
||||||
|
#define SPELLCHECKDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class SpellCheckDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SpellCheckDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SpellCheckDialog(QWidget* parent = 0);
|
||||||
|
~SpellCheckDialog();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void changeDictionaryPath();
|
||||||
|
void addUserWord();
|
||||||
|
void removeUserWord();
|
||||||
|
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SpellCheckDialog* ui;
|
||||||
|
|
||||||
|
bool m_listChanged;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SPELLCHECKDIALOG_H
|
161
src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.ui
Normal file
161
src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.ui
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SpellCheckDialog</class>
|
||||||
|
<widget class="QDialog" name="SpellCheckDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>441</width>
|
||||||
|
<height>305</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>SpellCheck</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-weight:600;">Dictionary path</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="dictPath">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="changeDictPath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Change...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string><b>User dictionary</b></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="userDictList"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="add">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="remove">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="textLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Using Hunspell library</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>SpellCheckDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>SpellCheckDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -61,7 +61,10 @@ void Speller::loadSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
m_userDictionary.setFileName(mApp->currentProfilePath() + "userdictionary.txt");
|
m_userDictionary.setFileName(mApp->currentProfilePath() + "userdictionary.txt");
|
||||||
|
|
||||||
|
if (m_enabled) {
|
||||||
initialize();
|
initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Speller::initialize()
|
void Speller::initialize()
|
||||||
@ -112,9 +115,11 @@ Speller::Language Speller::language() const
|
|||||||
return m_language;
|
return m_language;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Speller::Language> Speller::availableLanguages() const
|
QList<Speller::Language> Speller::availableLanguages()
|
||||||
{
|
{
|
||||||
QList<Language> languages;
|
if (!m_availableLanguages.isEmpty()) {
|
||||||
|
return m_availableLanguages;
|
||||||
|
}
|
||||||
|
|
||||||
QDirIterator it(m_dictionaryPath, QStringList("*.dic"), QDir::Files);
|
QDirIterator it(m_dictionaryPath, QStringList("*.dic"), QDir::Files);
|
||||||
|
|
||||||
@ -129,12 +134,12 @@ QList<Speller::Language> Speller::availableLanguages() const
|
|||||||
lang.code = it.fileInfo().baseName();
|
lang.code = it.fileInfo().baseName();
|
||||||
lang.name = nameForLanguage(lang.code);
|
lang.name = nameForLanguage(lang.code);
|
||||||
|
|
||||||
if (!languages.contains(lang)) {
|
if (!m_availableLanguages.contains(lang)) {
|
||||||
languages.append(lang);
|
m_availableLanguages.append(lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return languages;
|
return m_availableLanguages;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Speller::dictionaryPath() const
|
QString Speller::dictionaryPath() const
|
||||||
@ -142,20 +147,12 @@ QString Speller::dictionaryPath() const
|
|||||||
return m_dictionaryPath;
|
return m_dictionaryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Speller::showSettings(QWidget* parent)
|
|
||||||
{
|
|
||||||
SpellCheckDialog dialog(parent);
|
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
|
||||||
loadSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Speller::populateContextMenu(QMenu* menu, const QWebHitTestResult &hitTest)
|
void Speller::populateContextMenu(QMenu* menu, const QWebHitTestResult &hitTest)
|
||||||
{
|
{
|
||||||
m_element = hitTest.element();
|
m_element = hitTest.element();
|
||||||
|
|
||||||
if (m_element.isNull()) {
|
if (!m_enabled || m_element.isNull() ||
|
||||||
|
m_element.attribute(QLatin1String("type")) == QLatin1String("password")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,8 +202,8 @@ void Speller::addToDictionary()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_userDictionary.write(word.toUtf8());
|
QTextStream stream(&m_userDictionary);
|
||||||
m_userDictionary.write("\n");
|
stream << word << endl;
|
||||||
m_userDictionary.close();
|
m_userDictionary.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,6 +231,33 @@ void Speller::replaceWord()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Speller::showSettings()
|
||||||
|
{
|
||||||
|
SpellCheckDialog dialog;
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Speller::changeLanguage()
|
||||||
|
{
|
||||||
|
QAction* act = qobject_cast<QAction*>(sender());
|
||||||
|
|
||||||
|
if (!act) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Language lang = act->data().value<Language>();
|
||||||
|
|
||||||
|
Settings settings;
|
||||||
|
settings.beginGroup("SpellCheck");
|
||||||
|
settings.setValue("language", lang.code);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
void Speller::putWord(const QString &word)
|
void Speller::putWord(const QString &word)
|
||||||
{
|
{
|
||||||
if (!m_hunspell || !m_textCodec) {
|
if (!m_hunspell || !m_textCodec) {
|
||||||
@ -290,6 +314,43 @@ bool Speller::isValidWord(const QString &str)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Speller::populateLanguagesMenu()
|
||||||
|
{
|
||||||
|
QMenu* menu = qobject_cast<QMenu*>(sender());
|
||||||
|
|
||||||
|
if (!menu || !menu->isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<Language> langs = availableLanguages();
|
||||||
|
foreach(const Language & lang, langs) {
|
||||||
|
QAction* act = menu->addAction(lang.name, this, SLOT(changeLanguage()));
|
||||||
|
act->setCheckable(true);
|
||||||
|
act->setChecked(m_language == lang);
|
||||||
|
act->setData(QVariant::fromValue(lang));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu->isEmpty()) {
|
||||||
|
QAction* act = menu->addAction(tr("Empty"));
|
||||||
|
act->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
menu->addAction(tr("Settings"), this, SLOT(showSettings()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Speller::toggleEnableSpellChecking()
|
||||||
|
{
|
||||||
|
m_enabled = !m_enabled;
|
||||||
|
|
||||||
|
Settings settings;
|
||||||
|
settings.beginGroup("SpellCheck");
|
||||||
|
settings.setValue("enabled", m_enabled);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
bool Speller::dictionaryExists(const QString &path) const
|
bool Speller::dictionaryExists(const QString &path) const
|
||||||
{
|
{
|
||||||
return QFile(path + ".dic").exists() &&
|
return QFile(path + ".dic").exists() &&
|
||||||
|
@ -52,10 +52,9 @@ public:
|
|||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
Language language() const;
|
Language language() const;
|
||||||
QList<Language> availableLanguages() const;
|
QList<Language> availableLanguages();
|
||||||
|
|
||||||
QString dictionaryPath() const;
|
QString dictionaryPath() const;
|
||||||
void showSettings(QWidget* parent);
|
|
||||||
void populateContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
void populateContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
||||||
|
|
||||||
bool isMisspelled(const QString &string);
|
bool isMisspelled(const QString &string);
|
||||||
@ -63,10 +62,17 @@ public:
|
|||||||
|
|
||||||
static bool isValidWord(const QString &str);
|
static bool isValidWord(const QString &str);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void populateLanguagesMenu();
|
||||||
|
void toggleEnableSpellChecking();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addToDictionary();
|
void addToDictionary();
|
||||||
void replaceWord();
|
void replaceWord();
|
||||||
|
|
||||||
|
void showSettings();
|
||||||
|
void changeLanguage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialize();
|
void initialize();
|
||||||
void putWord(const QString &word);
|
void putWord(const QString &word);
|
||||||
@ -81,6 +87,7 @@ private:
|
|||||||
|
|
||||||
QFile m_userDictionary;
|
QFile m_userDictionary;
|
||||||
Language m_language;
|
Language m_language;
|
||||||
|
QList<Language> m_availableLanguages;
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
|
|
||||||
// Replacing word
|
// Replacing word
|
||||||
@ -89,4 +96,6 @@ private:
|
|||||||
int m_endPos;
|
int m_endPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Speller::Language)
|
||||||
|
|
||||||
#endif // SPELLER_H
|
#endif // SPELLER_H
|
||||||
|
@ -814,6 +814,8 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
|
|||||||
if (hitTest.element().tagName().toLower() == QLatin1String("input")) {
|
if (hitTest.element().tagName().toLower() == QLatin1String("input")) {
|
||||||
checkForForm(menu, hitTest.element());
|
checkForForm(menu, hitTest.element());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createSpellCheckContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!selectedText().isEmpty()) {
|
if (!selectedText().isEmpty()) {
|
||||||
@ -1030,6 +1032,22 @@ void WebView::createMediaContextMenu(QMenu* menu, const QWebHitTestResult &hitTe
|
|||||||
menu->addAction(QIcon::fromTheme("document-save"), tr("Save Media To &Disk"), this, SLOT(downloadUrlToDisk()))->setData(videoUrl);
|
menu->addAction(QIcon::fromTheme("document-save"), tr("Save Media To &Disk"), this, SLOT(downloadUrlToDisk()))->setData(videoUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebView::createSpellCheckContextMenu(QMenu* menu)
|
||||||
|
{
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
QAction* act = menu->addAction(tr("Check &Spelling"), mApp->speller(), SLOT(toggleEnableSpellChecking()));
|
||||||
|
act->setCheckable(true);
|
||||||
|
act->setChecked(mApp->speller()->isEnabled());
|
||||||
|
|
||||||
|
if (mApp->speller()->isEnabled()) {
|
||||||
|
QMenu* men = menu->addMenu(tr("Languages"));
|
||||||
|
connect(men, SIGNAL(aboutToShow()), mApp->speller(), SLOT(populateLanguagesMenu()));
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::pauseMedia()
|
void WebView::pauseMedia()
|
||||||
{
|
{
|
||||||
bool paused = m_clickedElement.evaluateJavaScript("this.paused").toBool();
|
bool paused = m_clickedElement.evaluateJavaScript("this.paused").toBool();
|
||||||
|
@ -142,6 +142,7 @@ protected:
|
|||||||
void createImageContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
void createImageContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
||||||
void createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
void createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
||||||
void createMediaContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
void createMediaContextMenu(QMenu* menu, const QWebHitTestResult &hitTest);
|
||||||
|
void createSpellCheckContextMenu(QMenu* menu);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void pauseMedia();
|
void pauseMedia();
|
||||||
|
@ -4241,6 +4241,68 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>SpellCheckDialog</name>
|
||||||
|
<message>
|
||||||
|
<source>SpellCheck</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><html><head/><body><p><span style=" font-weight:600;">Dictionary path</span></p></body></html></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Change...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source><b>User dictionary</b></source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Add</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Remove</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Using Hunspell library</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Choose dictionary path...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Add new word...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Add new word:</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>Speller</name>
|
||||||
|
<message>
|
||||||
|
<source>No suggestions</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Add to dictionary</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Empty</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Settings</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SqueezeLabelV2</name>
|
<name>SqueezeLabelV2</name>
|
||||||
<message>
|
<message>
|
||||||
@ -4817,6 +4879,14 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla
|
|||||||
<source>Create Search Engine</source>
|
<source>Create Search Engine</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Check &Spelling</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Languages</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>jsAlert</name>
|
<name>jsAlert</name>
|
||||||
|
Loading…
Reference in New Issue
Block a user