Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support setUseTabs config #642

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ CMakeLists.txt.user*
/build
/icon/*.png
/icon/ImageMagick
src/build/**
1 change: 1 addition & 0 deletions src/NotepadNext/ApplicationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CREATE_SETTING(Gui, ShowToolBar, showToolBar, bool, true)
CREATE_SETTING(Gui, ShowTabBar, showTabBar, bool, true)
CREATE_SETTING(Gui, ShowStatusBar, showStatusBar, bool, true)
CREATE_SETTING(Gui, CenterSearchDialog, centerSearchDialog, bool, true)
CREATE_SETTING(Gui, UseTabs, useTabs, bool, true)

CREATE_SETTING(Gui, TabsClosable, tabsClosable, bool, true)
CREATE_SETTING(Gui, ExitOnLastTabClosed, exitOnLastTabClosed, bool, false)
Expand Down
1 change: 1 addition & 0 deletions src/NotepadNext/ApplicationSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class ApplicationSettings : public QSettings
DEFINE_SETTING(ShowTabBar, showTabBar, bool)
DEFINE_SETTING(ShowStatusBar, showStatusBar, bool)
DEFINE_SETTING(CenterSearchDialog, centerSearchDialog, bool)
DEFINE_SETTING(UseTabs, useTabs, bool)

DEFINE_SETTING(TabsClosable, tabsClosable, bool)
DEFINE_SETTING(ExitOnLastTabClosed, exitOnLastTabClosed, bool)
Expand Down
6 changes: 6 additions & 0 deletions src/NotepadNext/EditorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ EditorManager::EditorManager(ApplicationSettings *settings, QObject *parent)
}
});

connect(settings, &ApplicationSettings::useTabsChanged, this, [=](bool b) {
for (auto &editor : getEditors()) {
editor->setUseTabs((b ? true : false));
}
});

connect(settings, &ApplicationSettings::showWhitespaceChanged, this, [=](bool b) {
// TODO: could make SCWS_VISIBLEALWAYS configurable via settings. Probably not worth
Expand Down Expand Up @@ -199,6 +204,7 @@ void EditorManager::setupEditor(ScintillaNext *editor)
editor->setTabDrawMode(SCTD_STRIKEOUT);
editor->setTabWidth(4);
editor->setBackSpaceUnIndents(true);
editor->setUseTabs(settings->useTabs() ? true : false);

editor->setCaretLineVisible(true);
editor->setCaretLineVisibleAlways(true);
Expand Down
7 changes: 4 additions & 3 deletions src/NotepadNext/NotepadNextApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ bool NotepadNextApplication::init()
.addFunction("showToolBar", &ApplicationSettings::setShowToolBar)
.addFunction("showTabBar", &ApplicationSettings::setShowTabBar)
.addFunction("showStatusBar", &ApplicationSettings::setShowStatusBar)
.addFunction("getUseTabs", &ApplicationSettings::useTabs)
.endClass()
.endNamespace();
luabridge::setGlobal(luaState->L, settings, "settings");
Expand Down Expand Up @@ -315,9 +316,9 @@ void NotepadNextApplication::setEditorLanguage(ScintillaNext *editor, const QStr
getLuaState()->execute(R"(
local L = languages[languageName]

if not skip_tabs then
editor.UseTabs = (L.tabSettings or "tabs") == "tabs"
end
--if not skip_tabs then
-- editor.UseTabs = (L.tabSettings or "tabs") == "tabs"
--end
if not skip_tabwidth then
editor.TabWidth = L.tabSize or 4
end
Expand Down
1 change: 1 addition & 0 deletions src/NotepadNext/dialogs/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ PreferencesDialog::PreferencesDialog(ApplicationSettings *settings, QWidget *par
MapSettingToCheckBox(ui->checkBoxToolBar, &ApplicationSettings::showToolBar, &ApplicationSettings::setShowToolBar, &ApplicationSettings::showToolBarChanged);
MapSettingToCheckBox(ui->checkBoxStatusBar, &ApplicationSettings::showStatusBar, &ApplicationSettings::setShowStatusBar, &ApplicationSettings::showStatusBarChanged);
MapSettingToCheckBox(ui->checkBoxRecenterSearchDialog, &ApplicationSettings::centerSearchDialog, &ApplicationSettings::setCenterSearchDialog, &ApplicationSettings::centerSearchDialogChanged);
MapSettingToCheckBox(ui->checkBoxSetUseTabs, &ApplicationSettings::useTabs, &ApplicationSettings::setUseTabs, &ApplicationSettings::useTabsChanged);

MapSettingToGroupBox(ui->gbxRestorePreviousSession, &ApplicationSettings::restorePreviousSession, &ApplicationSettings::setRestorePreviousSession, &ApplicationSettings::restorePreviousSessionChanged);
connect(ui->gbxRestorePreviousSession, &QGroupBox::toggled, this, [=](bool checked) {
Expand Down
7 changes: 7 additions & 0 deletions src/NotepadNext/dialogs/PreferencesDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSetUseTabs">
<property name="text">
<string>Set use tabs</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbxRestorePreviousSession">
<property name="title">
Expand Down