Skip to content

Commit

Permalink
Make "Auto-Follow Focus" configurable in the preferences (fixes #412)
Browse files Browse the repository at this point in the history
  • Loading branch information
stloeffler committed Dec 29, 2019
1 parent 281f5e8 commit b0d43ef
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/DefaultPrefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const int kDefault_TabWidth = 32;
const int kDefault_HideConsole = 1;
const bool kDefault_HighlightCurrentLine = true;
const bool kDefault_AutocompleteEnabled = true;
const bool kDefault_AutoFollowFocusEnabled = false;
const bool kDefault_AllowScriptFileReading = false;
const bool kDefault_AllowScriptFileWriting = false;
const bool kDefault_EnableScriptingPlugins = false;
Expand Down
4 changes: 4 additions & 0 deletions src/PrefsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ void PrefsDialog::restoreDefaults()
encoding->setCurrentIndex(encoding->findText(QString::fromLatin1("UTF-8")));
highlightCurrentLine->setChecked(kDefault_HighlightCurrentLine);
autocompleteEnabled->setChecked(kDefault_AutocompleteEnabled);
autoFollowFocusEnabled->setChecked(kDefault_AutoFollowFocusEnabled);
break;

case 2:
Expand Down Expand Up @@ -578,6 +579,7 @@ QDialog::DialogCode PrefsDialog::doPrefsDialog(QWidget *parent)
dlg.encoding->setCurrentIndex(nameList.indexOf(QString::fromUtf8(TWApp::instance()->getDefaultCodec()->name().constData())));
dlg.highlightCurrentLine->setChecked(settings.value(QString::fromLatin1("highlightCurrentLine"), kDefault_HighlightCurrentLine).toBool());
dlg.autocompleteEnabled->setChecked(settings.value(QString::fromLatin1("autocompleteEnabled"), kDefault_AutocompleteEnabled).toBool());
dlg.autoFollowFocusEnabled->setChecked(settings.value(QStringLiteral("autoFollowFocusEnabled"), kDefault_AutoFollowFocusEnabled).toBool());

QString defDict = settings.value(QString::fromLatin1("language"), QString::fromLatin1("None")).toString();
int i = dlg.language->findData(defDict);
Expand Down Expand Up @@ -747,6 +749,8 @@ QDialog::DialogCode PrefsDialog::doPrefsDialog(QWidget *parent)
settings.setValue(QString::fromLatin1("autocompleteEnabled"), autocompleteEnabled);
CompletingEdit::setAutocompleteEnabled(autocompleteEnabled);

settings.setValue(QStringLiteral("autoFollowFocusEnabled"), dlg.autoFollowFocusEnabled->isChecked());

// Since the tab width can't be set by any other means, forcibly update
// all windows now
foreach (QWidget* widget, TWApp::instance()->allWidgets()) {
Expand Down
7 changes: 7 additions & 0 deletions src/PrefsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="autoFollowFocusEnabled">
<property name="text">
<string>Enable auto-follow focus</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
2 changes: 2 additions & 0 deletions src/TeXDocumentWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ void TeXDocumentWindow::init()
b = settings.value(QString::fromLatin1("lineNumbers"), false).toBool();
actionLine_Numbers->setChecked(b);
setLineNumbers(b);

actionAuto_Follow_Focus->setChecked(settings.value(QStringLiteral("autoFollowFocusEnabled"), kDefault_AutoFollowFocusEnabled).toBool());

QStringList options = TeXHighlighter::syntaxOptions();

Expand Down

0 comments on commit b0d43ef

Please sign in to comment.