From 0f80232fff079a0f91765b32a539fe370d3ca84f Mon Sep 17 00:00:00 2001 From: keshavbhatt Date: Fri, 9 Apr 2021 10:25:02 +0530 Subject: spellcheck impl --- src/settingswidget.cpp | 76 +++++++++++++++++++++++ src/settingswidget.h | 9 +++ src/settingswidget.ui | 161 ++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 212 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/settingswidget.cpp b/src/settingswidget.cpp index 4a735b8..fe91502 100644 --- a/src/settingswidget.cpp +++ b/src/settingswidget.cpp @@ -2,6 +2,7 @@ #include "ui_settingswidget.h" #include +#include "mainwindow.h" extern QString defaultUserAgentStr; @@ -22,6 +23,7 @@ SettingsWidget::SettingsWidget(QWidget *parent, QString engineCachePath, QString ui->autoPlayMediaCheckBox->setChecked(settings.value("autoPlayMedia",false).toBool()); ui->themeComboBox->setCurrentText(utils::toCamelCase(settings.value("windowTheme","light").toString())); ui->userAgentLineEdit->setText(settings.value("useragent",defaultUserAgentStr).toString()); + ui->enableSpellCheck->setChecked(settings.value("sc_enabled",true).toBool()); this->setCurrentPasswordText("Current Password: " +QByteArray::fromBase64(settings.value("asdfg").toString().toUtf8())+""); @@ -36,10 +38,53 @@ SettingsWidget::~SettingsWidget() delete ui; } +void SettingsWidget::loadDictionaries(QStringList dictionaries) +{ + // set up supported spellcheck dictionaries + QStringList ui_dictionary_names; + foreach(QString dictionary_name, dictionaries) { + ui_dictionary_names.append(dictionary_name); + } + ui_dictionary_names.sort(); + //add to ui + ui->dictComboBox->blockSignals(true); + foreach(QString dict_name, ui_dictionary_names) { + ui->dictComboBox->addItem(dict_name); + } + ui->dictComboBox->blockSignals(false); + + // load settings for spellcheck dictionary + QString dictionary_name = settings.value("sc_dict","en-US").toString(); + int pos = ui->dictComboBox->findText(dictionary_name); + if (pos == -1) { + pos = ui->dictComboBox->findText("en-US"); + if (pos == -1) { + pos = 0; + } + } + ui->dictComboBox->setCurrentIndex(pos); +} + void SettingsWidget::refresh() { ui->cacheSize->setText(utils::refreshCacheSize(cachePath())); ui->cookieSize->setText(utils::refreshCacheSize(persistentStoragePath())); + + //update dict settings at runtime + // load settings for spellcheck dictionary + QString dictionary_name = settings.value("sc_dict","en-US").toString(); + int pos = ui->dictComboBox->findText(dictionary_name); + if (pos == -1) { + pos = ui->dictComboBox->findText("en-US"); + if (pos == -1) { + pos = 0; + } + } + ui->dictComboBox->setCurrentIndex(pos); + + //enable disable spell check + ui->enableSpellCheck->setChecked(settings.value("sc_enabled",true).toBool()); + } void SettingsWidget::updateDefaultUAButton(const QString engineUA) @@ -212,3 +257,34 @@ void SettingsWidget::on_applock_checkbox_toggled(bool checked) emit init_lock(); } } + +void SettingsWidget::on_dictComboBox_currentIndexChanged(const QString &arg1) +{ + settings.setValue("sc_dict",arg1); + emit dictChanged(arg1); +} + +void SettingsWidget::on_enableSpellCheck_toggled(bool checked) +{ + settings.setValue("sc_enabled",checked); + emit spellCheckChanged(checked); +} + +void SettingsWidget::on_showShortcutsButton_clicked() +{ + QWidget *sheet = new QWidget(this); + sheet->setWindowTitle(QApplication::applicationName()+" | Global shortcuts"); + sheet->setWindowFlag(Qt::Sheet); + + QVBoxLayout *layout = new QVBoxLayout(sheet); + sheet->setLayout(layout); + auto *w = qobject_cast(parent()); + if(w != 0){ + foreach (QAction *action, w->actions()) { + QLabel *label = new QLabel(action->text()+" | "+action->shortcut().toString(),sheet); + layout->addWidget(label); + } + } + sheet->setAttribute(Qt::WA_DeleteOnClose); + sheet->show(); +} diff --git a/src/settingswidget.h b/src/settingswidget.h index 640f294..e126930 100644 --- a/src/settingswidget.h +++ b/src/settingswidget.h @@ -22,6 +22,8 @@ signals: void autoPlayMediaToggled(const bool checked); void userAgentChanged(QString userAgentStr); void init_lock(); + void dictChanged(QString dict); + void spellCheckChanged(bool checked); public: explicit SettingsWidget(QWidget *parent = nullptr,QString engineCachePath = "", QString enginePersistentStoragePath = ""); @@ -32,6 +34,7 @@ public slots: void updateDefaultUAButton(const QString engineUA); void appLockSetChecked(bool checked); void setCurrentPasswordText(QString str); + void loadDictionaries(QStringList dictionaries); private slots: QString cachePath(); QString persistentStoragePath(); @@ -61,6 +64,12 @@ private slots: void on_applock_checkbox_toggled(bool checked); + void on_dictComboBox_currentIndexChanged(const QString &arg1); + + void on_enableSpellCheck_toggled(bool checked); + + void on_showShortcutsButton_clicked(); + private: Ui::SettingsWidget *ui; QString engineCachePath,enginePersistentStoragePath; diff --git a/src/settingswidget.ui b/src/settingswidget.ui index 1e8b647..aec1dfe 100644 --- a/src/settingswidget.ui +++ b/src/settingswidget.ui @@ -104,64 +104,78 @@ background:transparent; General settings - - - - + + + + - Disable Notifications PopUp + Enable Spell Checker - - - - Mute Audio + + + + + 1 + 0 + - - - - - - Disable Auto Playback of Media + + + 1 + 16777215 + + + + background-color: rgba(63, 129, 216, 48); + + + QFrame::Raised + + + Qt::Vertical - - + + - Disable loading videos + SpellChecker Language + + + - - + + - + - Theme + Close button action - + - Dark + Minimize to tray - Light + Quit Application - + @@ -197,32 +211,64 @@ background:transparent; - - + + - + - Default close button action + Theme - + - Minimize to tray + Dark - Quit Application + Light - + + + + + + Disable Notifications PopUp + + + + + + + Mute Audio from Page + + + + + + + Disable Auto Playback of Media + + + + + + + Disable loading videos + + + + + + 0 @@ -246,6 +292,53 @@ background:transparent; + + + + + 0 + 1 + + + + + 16777215 + 1 + + + + background-color: rgba(63, 129, 216, 48); + + + QFrame::Raised + + + Qt::Horizontal + + + + + + + + + Global App shortcuts + + + + + + + Show + + + + :/icons/eye-line.png:/icons/eye-line.png + + + + + -- cgit v1.2.3