mirror of https://github.com/buggins/dlangide.git
apply settings:
This commit is contained in:
parent
cd647f222c
commit
90337397b4
|
@ -113,6 +113,7 @@ class IDEFrame : AppFrame {
|
||||||
_settings.updateDefaults();
|
_settings.updateDefaults();
|
||||||
_settings.save();
|
_settings.save();
|
||||||
super.init();
|
super.init();
|
||||||
|
applySettings(_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// move focus to editor in currently selected tab
|
/// move focus to editor in currently selected tab
|
||||||
|
@ -182,7 +183,7 @@ class IDEFrame : AppFrame {
|
||||||
TabItem tab = _tabs.tab(filename);
|
TabItem tab = _tabs.tab(filename);
|
||||||
tab.objectParam = file;
|
tab.objectParam = file;
|
||||||
editor.onModifiedStateChangeListener = &onModifiedStateChange;
|
editor.onModifiedStateChangeListener = &onModifiedStateChange;
|
||||||
editor.settings(settings).applySettings();
|
applySettings(editor, settings);
|
||||||
_tabs.selectTab(index, true);
|
_tabs.selectTab(index, true);
|
||||||
} else {
|
} else {
|
||||||
destroy(editor);
|
destroy(editor);
|
||||||
|
@ -641,12 +642,32 @@ class IDEFrame : AppFrame {
|
||||||
if (result.id == ACTION_APPLY.id) {
|
if (result.id == ACTION_APPLY.id) {
|
||||||
//Log.d("settings after edit:\n", s.toJSON(true));
|
//Log.d("settings after edit:\n", s.toJSON(true));
|
||||||
_settings.applySettings(s);
|
_settings.applySettings(s);
|
||||||
|
applySettings(_settings);
|
||||||
_settings.save();
|
_settings.save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
dlg.show();
|
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) {
|
private bool loadProject(Project project) {
|
||||||
if (!project.load()) {
|
if (!project.load()) {
|
||||||
_logPanel.logLine("Cannot read project " ~ project.filename);
|
_logPanel.logLine("Cannot read project " ~ project.filename);
|
||||||
|
|
|
@ -2,6 +2,7 @@ module dlangide.ui.settings;
|
||||||
|
|
||||||
import dlangui.core.settings;
|
import dlangui.core.settings;
|
||||||
import dlangui.core.i18n;
|
import dlangui.core.i18n;
|
||||||
|
import dlangui.graphics.fonts;
|
||||||
import dlangui.widgets.lists;
|
import dlangui.widgets.lists;
|
||||||
import dlangui.dialogs.settingsdialog;
|
import dlangui.dialogs.settingsdialog;
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ class IDESettings : SettingsFile {
|
||||||
ui.setStringDef("theme", "theme_default");
|
ui.setStringDef("theme", "theme_default");
|
||||||
ui.setStringDef("language", "en");
|
ui.setStringDef("language", "en");
|
||||||
ui.setIntegerDef("hintingMode", 1);
|
ui.setIntegerDef("hintingMode", 1);
|
||||||
|
ui.setIntegerDef("minAntialiasedFontSize", 0);
|
||||||
ui.setFloatingDef("fontGamma", 0.8);
|
ui.setFloatingDef("fontGamma", 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +109,28 @@ class IDESettings : SettingsFile {
|
||||||
@property bool smartIndentsAfterPaste() { return editorSettings.getBoolean("smartIndentsAfterPaste", true); }
|
@property bool smartIndentsAfterPaste() { return editorSettings.getBoolean("smartIndentsAfterPaste", true); }
|
||||||
/// set smart indents enabled flag
|
/// set smart indents enabled flag
|
||||||
@property IDESettings smartIndentsAfterPaste(bool enabled) { editorSettings.setBoolean("smartIndentsAfterPaste", enabled); return this; }
|
@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
|
/// 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.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),
|
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)]);
|
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),
|
ui.addFloatComboBox("interface/fontGamma", UIString("Font gamma"d),
|
||||||
[
|
[
|
||||||
StringListValue(500, "0.5 "d),
|
StringListValue(500, "0.5 "d),
|
||||||
|
|
Loading…
Reference in New Issue