Introduce GUI font preferences setting, so the user can customize the font of all dialogs and forms. Does not work with menus, however. See http://www.heidisql.com/forum.php?t=19666

This commit is contained in:
Ansgar Becker
2015-11-03 06:28:37 +00:00
parent e19d803e64
commit 269ee242d9
9 changed files with 154 additions and 39 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2015-09-26 14:16+0200\n"
"PO-Revision-Date: 2015-11-03 07:26+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
"language/en/)\n"
@ -5960,3 +5960,9 @@ msgstr "Send a donation"
msgid "Donate to the %s project"
msgstr "Donate to the %s project"
msgid "GUI font (requires restart):"
msgstr "GUI font (requires restart):"
msgid "Default system font"
msgstr "Default system font"

View File

@ -87,12 +87,8 @@ object connform: Tconnform
Constraints.MinWidth = 200
DragMode = dmAutomatic
Header.AutoSizeIndex = -1
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.Options = [hoAutoResize, hoColumnResize, hoDblClickResize, hoDrag, hoHotTrack, hoShowSortGlyphs, hoVisible]
Header.ParentFont = True
Header.PopupMenu = MainForm.popupListHeader
Header.SortColumn = 0
HintMode = hmTooltip

View File

@ -159,7 +159,7 @@ type
asConnectCount, asRefusedCount, asSessionCreated, asDoUsageStatistics,
asLastUsageStatisticCall, asDisplayBars, asBarColor, asMySQLBinaries, asCustomSnippetsDirectory,
asPromptSaveFileOnTabClose, asWarnUnsafeUpdates,
asCompletionProposal, asTabsToSpaces, asFilterPanel, asAllowMultipleInstances, asFindDialogSearchHistory,
asCompletionProposal, asTabsToSpaces, asFilterPanel, asAllowMultipleInstances, asFindDialogSearchHistory, asGUIFontName, asGUIFontSize,
asFindDialogReplaceHistory, asMaxQueryResults, asLogErrors,
asLogUserSQL, asLogSQL, asLogInfos, asLogDebug, asFieldColorNumeric,
asFieldColorReal, asFieldColorText, asFieldColorBinary, asFieldColorDatetime, asFieldColorSpatial,
@ -1668,18 +1668,26 @@ end;
procedure InheritFont(AFont: TFont);
var
LogFont: TLogFont;
GUIFontName: String;
begin
// Apply system font for a given font. See issue #3204.
// Code taken from http://www.gerixsoft.com/blog/delphi/system-font
if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(TLogFont), @LogFont, 0) then begin
AFont.Height := LogFont.lfHeight;
AFont.Orientation := LogFont.lfOrientation;
AFont.Charset := TFontCharset(LogFont.lfCharSet);
AFont.Name := PChar(@LogFont.lfFaceName);
case LogFont.lfPitchAndFamily and $F of
VARIABLE_PITCH: AFont.Pitch := fpVariable;
FIXED_PITCH: AFont.Pitch := fpFixed;
else AFont.Pitch := fpDefault;
GUIFontName := AppSettings.ReadString(asGUIFontName);
if not GUIFontName.IsEmpty then begin
// Apply user specified font
AFont.Name := GUIFontName;
AFont.Size := AppSettings.ReadInt(asGUIFontSize);
end else begin
// Apply system font. See issue #3204.
// Code taken from http://www.gerixsoft.com/blog/delphi/system-font
if SystemParametersInfo(SPI_GETICONTITLELOGFONT, SizeOf(TLogFont), @LogFont, 0) then begin
AFont.Height := LogFont.lfHeight;
AFont.Orientation := LogFont.lfOrientation;
AFont.Charset := TFontCharset(LogFont.lfCharSet);
AFont.Name := PChar(@LogFont.lfFaceName);
case LogFont.lfPitchAndFamily and $F of
VARIABLE_PITCH: AFont.Pitch := fpVariable;
FIXED_PITCH: AFont.Pitch := fpFixed;
else AFont.Pitch := fpDefault;
end;
end;
end;
end;
@ -3301,6 +3309,8 @@ begin
InitSetting(asAllowMultipleInstances, 'AllowMultipleInstances', 0, True);
InitSetting(asFindDialogSearchHistory, 'FindDialogSearchHistory', 0, False, '');
InitSetting(asFindDialogReplaceHistory, 'FindDialogReplaceHistory', 0, False, '');
InitSetting(asGUIFontName, 'GUIFontName', 0, False, '');
InitSetting(asGUIFontSize, 'GUIFontSize', 8);
InitSetting(asMaxQueryResults, 'MaxQueryResults', 10);
InitSetting(asLogErrors, 'LogErrors', 0, True);
InitSetting(asLogUserSQL, 'LogUserSQL', 0, True);

View File

@ -102,13 +102,9 @@ object frmInsertFiles: TfrmInsertFiles
Anchors = [akLeft, akTop, akRight]
EditDelay = 0
Header.AutoSizeIndex = 2
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.Images = MainForm.ImageListMain
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible]
Header.ParentFont = True
Header.PopupMenu = MainForm.popupListHeader
TabOrder = 2
TreeOptions.MiscOptions = [toAcceptOLEDrop, toEditable, toFullRepaintOnResize, toGridExtensions, toInitOnSave, toToggleOnDblClick, toWheelPanning, toEditOnClick]
@ -180,12 +176,8 @@ object frmInsertFiles: TfrmInsertFiles
Height = 128
Anchors = [akLeft, akTop, akRight, akBottom]
Header.AutoSizeIndex = 0
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoHotTrack, hoShowImages, hoShowSortGlyphs, hoVisible]
Header.ParentFont = True
Header.PopupMenu = MainForm.popupListHeader
Header.SortColumn = 0
TabOrder = 0

View File

@ -287,11 +287,13 @@ object MainForm: TMainForm
Images = ImageListMain
LeftButton.ImageIndex = 5
LeftButton.Visible = True
RightButton.ImageIndex = 26
TabOrder = 0
TextHint = 'Database filter'
OnChange = editDatabaseTableFilterChange
OnExit = editDatabaseTableFilterExit
OnLeftButtonClick = editDatabaseTableFilterLeftButtonClick
OnRightButtonClick = editDatabaseTableFilterRightButtonClick
end
object editTableFilter: TButtonedEdit
Left = 50
@ -302,11 +304,13 @@ object MainForm: TMainForm
Images = ImageListMain
LeftButton.ImageIndex = 14
LeftButton.Visible = True
RightButton.ImageIndex = 26
TabOrder = 1
TextHint = 'Table filter'
OnChange = editDatabaseTableFilterChange
OnExit = editDatabaseTableFilterExit
OnLeftButtonClick = editDatabaseTableFilterLeftButtonClick
OnRightButtonClick = editDatabaseTableFilterRightButtonClick
end
object btnTreeFavorites: TToolButton
Left = 100
@ -332,15 +336,8 @@ object MainForm: TMainForm
BevelOuter = bvNone
TabOrder = 0
Visible = False
object lblFilterVT: TLabel
Left = 36
Top = 6
Width = 28
Height = 13
Caption = 'Filter:'
end
object lblFilterVTInfo: TLabel
Left = 239
Left = 333
Top = 6
Width = 66
Height = 13
@ -356,7 +353,7 @@ object MainForm: TMainForm
OnClick = actFilterPanelExecute
end
object editFilterVT: TButtonedEdit
Left = 70
Left = 164
Top = 3
Width = 154
Height = 21
@ -368,6 +365,26 @@ object MainForm: TMainForm
OnChange = editFilterVTChange
OnRightButtonClick = editFilterVTRightButtonClick
end
object radioFilterVT: TRadioButton
Left = 27
Top = 2
Width = 55
Height = 17
Caption = 'Filter:'
Checked = True
TabOrder = 1
TabStop = True
OnClick = editFilterVTChange
end
object radioHighlightVT: TRadioButton
Left = 88
Top = 2
Width = 70
Height = 17
Caption = 'Highlight:'
TabOrder = 2
OnClick = editFilterVTChange
end
end
object PageControlMain: TPageControl
Left = 0
@ -2781,6 +2798,12 @@ object MainForm: TMainForm
OnExecute = actSaveSynMemoToTextfileExecute
OnUpdate = ValidateControls
end
object actRenameQueryTab: TAction
Category = 'File'
Caption = 'Rename query tab'
ImageIndex = 58
ShortCut = 16497
end
end
object menuConnections: TPopupMenu
AutoHotkeys = maManual
@ -2795,7 +2818,7 @@ object MainForm: TMainForm
Left = 504
Top = 104
Bitmap = {
494C0101BD005001F80310001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600
494C0101BD005001FC0310001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000000003000001002000000000000000
0300000000000000000000000000000000000000000000000000000000000000
00000000000000000004000000080000000C0000000C00000008000000030000
@ -9894,6 +9917,9 @@ object MainForm: TMainForm
ImageIndex = 133
OnClick = menuCloseQueryTab
end
object Renamequerytab1: TMenuItem
Action = actRenameQueryTab
end
end
object TimerFilterVT: TTimer
Enabled = False

View File

@ -1608,6 +1608,7 @@ begin
QueryTab.spltHelpers := spltQueryHelpers;
QueryTab.spltQuery := spltQuery;
QueryTab.tabsetQuery := tabsetQuery;
InheritFont(QueryTab.tabsetQuery.Font);
QueryTab.ResultTabs := TResultTabs.Create(True);
QueryTabs := TObjectList<TQueryTab>.Create(True);
@ -9776,6 +9777,7 @@ begin
QueryTab.tabsetQuery := TTabSet.Create(QueryTab.TabSheet);
QueryTab.tabsetQuery.Parent := QueryTab.TabSheet;
QueryTab.tabsetQuery.Align := tabsetQuery.Align;
InheritFont(QueryTab.tabsetQuery.Font);
QueryTab.tabsetQuery.Images := tabsetQuery.Images;
QueryTab.tabsetQuery.Style := tabsetQuery.Style;
QueryTab.tabsetQuery.TabHeight := tabsetQuery.TabHeight;

View File

@ -56,6 +56,21 @@ object optionsform: Toptionsform
Height = 13
Caption = 'Custom snippets directory:'
end
object lblGUIFont: TLabel
Left = 8
Top = 300
Width = 131
Height = 13
Caption = 'GUI font (requires restart):'
end
object lblGUIFontSize: TLabel
Left = 578
Top = 300
Width = 10
Height = 13
Anchors = [akTop, akRight]
Caption = 'pt'
end
object chkAutoReconnect: TCheckBox
Left = 8
Top = 31
@ -212,6 +227,38 @@ object optionsform: Toptionsform
OnDblClick = editCustomSnippetsDirectoryRightButtonClick
OnRightButtonClick = editCustomSnippetsDirectoryRightButtonClick
end
object comboGUIFont: TComboBox
Left = 272
Top = 297
Width = 218
Height = 21
Style = csDropDownList
Anchors = [akLeft, akTop, akRight]
TabOrder = 13
OnChange = comboGUIFontChange
end
object editGUIFontSize: TEdit
Left = 496
Top = 297
Width = 57
Height = 21
Anchors = [akTop, akRight]
TabOrder = 14
Text = '8'
OnChange = Modified
end
object updownGUIFontSize: TUpDown
Left = 553
Top = 297
Width = 16
Height = 21
Anchors = [akTop, akRight]
Associate = editGUIFontSize
Min = 4
Position = 8
TabOrder = 15
OnChanging = anyUpDownLimitChanging
end
end
object tabLogging: TTabSheet
Caption = 'Logging'

View File

@ -130,6 +130,11 @@ type
chkHintsOnResultTabs: TCheckBox;
lblLineBreakStyle: TLabel;
comboLineBreakStyle: TComboBox;
lblGUIFont: TLabel;
comboGUIFont: TComboBox;
editGUIFontSize: TEdit;
updownGUIFontSize: TUpDown;
lblGUIFontSize: TLabel;
procedure FormShow(Sender: TObject);
procedure Modified(Sender: TObject);
procedure Apply(Sender: TObject);
@ -167,6 +172,7 @@ type
procedure editMySQLBinariesRightButtonClick(Sender: TObject);
procedure editGridRowCountExit(Sender: TObject);
procedure editCustomSnippetsDirectoryRightButtonClick(Sender: TObject);
procedure comboGUIFontChange(Sender: TObject);
private
{ Private declarations }
FWasModified: Boolean;
@ -276,6 +282,12 @@ begin
AppSettings.WriteString(asAppLanguage, LangCode);
end else
AppSettings.WriteString(asAppLanguage, '');
if comboGUIFont.ItemIndex = 0 then
AppSettings.WriteString(asGUIFontName, '')
else
AppSettings.WriteString(asGUIFontName, comboGUIFont.Text);
AppSettings.WriteInt(asGUIFontSize, updownGUIFontSize.Position);
AppSettings.WriteInt(asMaxQueryResults, updownMaxQueryResults.Position);
// Save color settings
AppSettings.WriteInt(asFieldColorNumeric, FGridTextColors[dtcInteger]);
@ -403,6 +415,9 @@ begin
comboAppLanguage.Items.Add(FLanguages.ValueFromIndex[i]);
end;
comboGUIFont.Items.Assign(Screen.Fonts);
comboGUIFont.Items.Insert(0, '<'+_('Default system font')+'>');
// Data
// Populate datatype categories pulldown
for dtc:=Low(TDBDatatypeCategoryIndex) to High(TDBDatatypeCategoryIndex) do
@ -440,7 +455,7 @@ end;
procedure Toptionsform.FormShow(Sender: TObject);
var
LangCode: String;
LangCode, GUIFont: String;
begin
screen.Cursor := crHourGlass;
@ -459,6 +474,13 @@ begin
editCustomSnippetsDirectory.Text := AppSettings.ReadString(asCustomSnippetsDirectory);
LangCode := AppSettings.ReadString(asAppLanguage);
comboAppLanguage.ItemIndex := comboAppLanguage.Items.IndexOf(FLanguages.Values[LangCode]);
GUIFont := AppSettings.ReadString(asGUIFontName);
if GUIFont.IsEmpty then
comboGUIFont.ItemIndex := 0
else
comboGUIFont.ItemIndex := comboGUIFont.Items.IndexOf(GUIFont);
updownGUIFontSize.Position := AppSettings.ReadInt(asGUIFontSize);
comboGUIFont.OnChange(comboGUIFont);
chkAskFileSave.Checked := AppSettings.ReadBool(asPromptSaveFileOnTabClose);
// Logging
@ -659,6 +681,19 @@ begin
end;
procedure Toptionsform.comboGUIFontChange(Sender: TObject);
var
UseCustomFont: Boolean;
begin
// System font selected
UseCustomFont := comboGUIFont.ItemIndex > 0;
editGUIFontSize.Enabled := UseCustomFont;
updownGUIFontSize.Enabled := UseCustomFont;
lblGUIFontSize.Enabled := UseCustomFont;
Modified(Sender);
end;
procedure Toptionsform.colorBoxGridTextColorsSelect(Sender: TObject);
begin
// Color selected

View File

@ -60,6 +60,7 @@ uses helpers, main;
procedure TfrmSearchReplace.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
InheritFont(Font);
comboSearch.Items.Text := AppSettings.ReadString(asFindDialogSearchHistory);
comboReplace.Items.Text := AppSettings.ReadString(asFindDialogReplaceHistory);
comboSearch.Text := '';