mirror of https://github.com/buggins/dlangide.git
edit/preferences dialog, part 1
This commit is contained in:
parent
7d143000bc
commit
1dfe3d581d
|
@ -13,6 +13,7 @@ import dlangui.widgets.combobox;
|
|||
import dlangui.widgets.popup;
|
||||
import dlangui.dialogs.dialog;
|
||||
import dlangui.dialogs.filedlg;
|
||||
import dlangui.dialogs.settingsdialog;
|
||||
import dlangui.core.stdaction;
|
||||
import dlangui.core.files;
|
||||
|
||||
|
@ -489,6 +490,8 @@ class IDEFrame : AppFrame {
|
|||
/// override to handle specific actions state (e.g. change enabled state for supported actions)
|
||||
override bool handleActionStateRequest(const Action a) {
|
||||
switch (a.id) {
|
||||
case IDEActions.EditPreferences:
|
||||
return true;
|
||||
case IDEActions.FileExit:
|
||||
case IDEActions.FileOpen:
|
||||
case IDEActions.WindowCloseAllDocuments:
|
||||
|
@ -619,6 +622,9 @@ class IDEFrame : AppFrame {
|
|||
auto results = _editorTool.getCompletions(currentEditor, currentEditor.getCaretPosition);
|
||||
currentEditor.showCompletionPopup(results);
|
||||
return true;
|
||||
case IDEActions.EditPreferences:
|
||||
showPreferences();
|
||||
return true;
|
||||
default:
|
||||
return super.handleAction(a);
|
||||
}
|
||||
|
@ -626,6 +632,18 @@ class IDEFrame : AppFrame {
|
|||
return false;
|
||||
}
|
||||
|
||||
void showPreferences() {
|
||||
Setting s = _settings.copySettings();
|
||||
SettingsDialog dlg = new SettingsDialog(UIString("DlangIDE settings"d), window, s, createSettingsPages());
|
||||
dlg.onDialogResult = delegate(Dialog dlg, const Action result) {
|
||||
if (result.id == ACTION_APPLY.id) {
|
||||
_settings.applySettings(s);
|
||||
_settings.save();
|
||||
}
|
||||
};
|
||||
dlg.show();
|
||||
}
|
||||
|
||||
private bool loadProject(Project project) {
|
||||
if (!project.load()) {
|
||||
_logPanel.logLine("Cannot read project " ~ project.filename);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
module dlangide.ui.settings;
|
||||
|
||||
import dlangui.core.settings;
|
||||
import dlangui.core.i18n;
|
||||
import dlangui.dialogs.settingsdialog;
|
||||
|
||||
|
||||
const AVAILABLE_THEMES = ["theme_default", "theme_dark"];
|
||||
|
@ -103,3 +105,18 @@ class IDESettings : SettingsFile {
|
|||
/// set smart indents enabled flag
|
||||
@property IDESettings smartIndentsAfterPaste(bool enabled) { editorSettings.setBoolean("smartIndentsAfterPaste", enabled); return this; }
|
||||
}
|
||||
|
||||
/// create DlangIDE settings pages tree
|
||||
SettingsPage createSettingsPages() {
|
||||
SettingsPage res = new SettingsPage("", UIString(""d));
|
||||
SettingsPage ed = res.addChild("editors", UIString("Editors"d));
|
||||
SettingsPage texted = ed.addChild("editors/textEditor", UIString("Text Editors"d));
|
||||
texted.addCheckbox("editors/textEditor/useSpacesForTabs", UIString("Use spaces for tabs"d));
|
||||
texted.addCheckbox("editors/textEditor/smartIndents", UIString("Smart indents"d));
|
||||
texted.addCheckbox("editors/textEditor/smartIndentsAfterPaste", UIString("Smart indent after paste"d));
|
||||
//ed.setIntegerDef("tabSize", 4);
|
||||
SettingsPage ui = res.addChild("interface", UIString("Interface"d));
|
||||
//ui.setStringDef("theme", "theme_default");
|
||||
//ui.setStringDef("language", "en");
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue