apply settings:

This commit is contained in:
Vadim Lopatin 2015-03-04 18:23:29 +03:00
parent cd647f222c
commit 90337397b4
2 changed files with 56 additions and 1 deletions

View File

@ -113,6 +113,7 @@ class IDEFrame : AppFrame {
_settings.updateDefaults();
_settings.save();
super.init();
applySettings(_settings);
}
/// move focus to editor in currently selected tab
@ -182,7 +183,7 @@ class IDEFrame : AppFrame {
TabItem tab = _tabs.tab(filename);
tab.objectParam = file;
editor.onModifiedStateChangeListener = &onModifiedStateChange;
editor.settings(settings).applySettings();
applySettings(editor, settings);
_tabs.selectTab(index, true);
} else {
destroy(editor);
@ -641,12 +642,32 @@ class IDEFrame : AppFrame {
if (result.id == ACTION_APPLY.id) {
//Log.d("settings after edit:\n", s.toJSON(true));
_settings.applySettings(s);
applySettings(_settings);
_settings.save();
}
};
dlg.show();
}
void applySettings(IDESettings settings) {
for (int i = _tabs.tabCount - 1; i >= 0; i--) {
DSourceEdit ed = cast(DSourceEdit)_tabs.tabBody(i);
if (ed) {
applySettings(ed, settings);
}
}
FontManager.fontGamma = settings.fontGamma;
FontManager.hintingMode = settings.hintingMode;
FontManager.minAnitialiasedFontSize = settings.minAntialiasedFontSize;
Platform.instance.uiLanguage = settings.uiLanguage;
Platform.instance.uiTheme = settings.uiTheme;
requestLayout();
}
void applySettings(DSourceEdit editor, IDESettings settings) {
editor.settings(settings).applySettings();
}
private bool loadProject(Project project) {
if (!project.load()) {
_logPanel.logLine("Cannot read project " ~ project.filename);

View File

@ -2,6 +2,7 @@ module dlangide.ui.settings;
import dlangui.core.settings;
import dlangui.core.i18n;
import dlangui.graphics.fonts;
import dlangui.widgets.lists;
import dlangui.dialogs.settingsdialog;
@ -25,6 +26,7 @@ class IDESettings : SettingsFile {
ui.setStringDef("theme", "theme_default");
ui.setStringDef("language", "en");
ui.setIntegerDef("hintingMode", 1);
ui.setIntegerDef("minAntialiasedFontSize", 0);
ui.setFloatingDef("fontGamma", 0.8);
}
@ -107,6 +109,28 @@ class IDESettings : SettingsFile {
@property bool smartIndentsAfterPaste() { return editorSettings.getBoolean("smartIndentsAfterPaste", true); }
/// set smart indents enabled flag
@property IDESettings smartIndentsAfterPaste(bool enabled) { editorSettings.setBoolean("smartIndentsAfterPaste", enabled); return this; }
@property double fontGamma() {
double gamma = uiSettings.getFloating("fontGamma", 1.0);
if (gamma >= 0.5 && gamma <= 2.0)
return gamma;
return 1.0;
}
@property HintingMode hintingMode() {
long mode = uiSettings.getInteger("hintingMode", HintingMode.Normal);
if (mode >= HintingMode.Normal && mode <= HintingMode.Light)
return cast(HintingMode)mode;
return HintingMode.Normal;
}
@property int minAntialiasedFontSize() {
long sz = uiSettings.getInteger("minAntialiasedFontSize", 0);
if (sz >= 0)
return cast(int)sz;
return 0;
}
}
/// create DlangIDE settings pages tree
@ -123,6 +147,16 @@ SettingsPage createSettingsPages() {
ui.addStringComboBox("interface/language", UIString("Language"d), [StringListValue("en", "English"d), StringListValue("ru", "Russian"d)]);
ui.addIntComboBox("interface/hintingMode", UIString("Font hinting mode"d), [StringListValue(0, "Normal"d), StringListValue(1, "Force Auto Hint"d),
StringListValue(2, "Disabled"d), StringListValue(3, "Light"d)]);
ui.addIntComboBox("interface/minAntialiasedFontSize", UIString("Minimum font size for antialiasing"d),
[StringListValue(0, "Always ON"d),
StringListValue(12, "12"d),
StringListValue(14, "14"d),
StringListValue(16, "16"d),
StringListValue(20, "20"d),
StringListValue(24, "24"d),
StringListValue(32, "32"d),
StringListValue(48, "48"d),
StringListValue(255, "Always OFF"d)]);
ui.addFloatComboBox("interface/fontGamma", UIString("Font gamma"d),
[
StringListValue(500, "0.5 "d),