Skip to content
Permalink
Browse files

Move tree background color setting from File menu to the Advanced tab…

… of the session manager. Closes #360
  • Loading branch information...
ansgarbecker committed Mar 30, 2019
1 parent 1f30684 commit 07afefc7261c49c4a582535face6da25c39d876f
Showing with 44 additions and 86 deletions.
  1. +38 −18 source/connections.dfm
  2. +6 −0 source/connections.pas
  3. +0 −13 source/main.dfm
  4. +0 −55 source/main.pas
@@ -3,7 +3,7 @@ object connform: Tconnform
Top = 129
BorderIcons = [biSystemMenu, biHelp]
Caption = 'Session manager'
ClientHeight = 364
ClientHeight = 448
ClientWidth = 649
Color = clBtnFace
Constraints.MinHeight = 360
@@ -18,15 +18,15 @@ object connform: Tconnform
OnShow = FormShow
DesignSize = (
649
364)
448)
PixelsPerInch = 96
TextHeight = 13
object splitterMain: TSplitter
AlignWithMargins = True
Left = 208
Top = 8
Width = 8
Height = 316
Height = 400
Cursor = crSizeWE
Margins.Left = 0
Margins.Top = 8
@@ -37,7 +37,7 @@ object connform: Tconnform
end
object btnSave: TButton
Left = 64
Top = 331
Top = 415
Width = 50
Height = 25
Anchors = [akLeft, akBottom]
@@ -47,7 +47,7 @@ object connform: Tconnform
end
object btnOpen: TButton
Left = 389
Top = 331
Top = 415
Width = 80
Height = 25
Anchors = [akRight, akBottom]
@@ -59,7 +59,7 @@ object connform: Tconnform
end
object btnCancel: TButton
Left = 475
Top = 331
Top = 415
Width = 80
Height = 25
Anchors = [akRight, akBottom]
@@ -73,7 +73,7 @@ object connform: Tconnform
Left = 8
Top = 8
Width = 200
Height = 316
Height = 400
Margins.Left = 8
Margins.Top = 8
Margins.Right = 0
@@ -146,7 +146,7 @@ object connform: Tconnform
end
object btnNew: TButton
Left = 8
Top = 331
Top = 415
Width = 50
Height = 25
Anchors = [akLeft, akBottom]
@@ -158,7 +158,7 @@ object connform: Tconnform
end
object btnDelete: TButton
Left = 120
Top = 331
Top = 415
Width = 50
Height = 25
Anchors = [akLeft, akBottom]
@@ -171,7 +171,7 @@ object connform: Tconnform
Left = 216
Top = 8
Width = 425
Height = 316
Height = 400
Margins.Left = 0
Margins.Top = 8
Margins.Right = 8
@@ -216,15 +216,15 @@ object connform: Tconnform
Left = 0
Top = 0
Width = 417
Height = 287
Height = 371
Align = alClient
BevelOuter = bvNone
Caption = 'pnlDpiHelperSettings'
ShowCaption = False
TabOrder = 0
DesignSize = (
417
287)
371)
object lblPort: TLabel
Left = 3
Top = 168
@@ -379,7 +379,7 @@ object connform: Tconnform
Left = 120
Top = 238
Width = 294
Height = 35
Height = 119
Anchors = [akLeft, akTop, akRight, akBottom]
ScrollBars = ssVertical
TabOrder = 10
@@ -408,15 +408,15 @@ object connform: Tconnform
Left = 0
Top = 0
Width = 417
Height = 287
Height = 371
Align = alClient
BevelOuter = bvNone
Caption = 'pnlDpiHelperSshTunnel'
ShowCaption = False
TabOrder = 0
DesignSize = (
417
287)
371)
object lblSSHLocalPort: TLabel
Left = 3
Top = 190
@@ -597,15 +597,15 @@ object connform: Tconnform
Left = 0
Top = 0
Width = 417
Height = 287
Height = 371
Align = alClient
BevelOuter = bvNone
Caption = 'pnlDpiHelperAdvanced'
ShowCaption = False
TabOrder = 0
DesignSize = (
417
287)
371)
object lblSSLPrivateKey: TLabel
Left = 3
Top = 39
@@ -659,6 +659,13 @@ object connform: Tconnform
Height = 13
Caption = 'Ping every X seconds:'
end
object lblBackgroundColor: TLabel
Left = 3
Top = 304
Width = 86
Height = 13
Caption = 'Background color:'
end
object editSSLPrivateKey: TButtonedEdit
Left = 120
Top = 36
@@ -802,6 +809,19 @@ object connform: Tconnform
Max = 86400
TabOrder = 11
end
object ColorBoxBackgroundColor: TColorBox
Left = 120
Top = 301
Width = 294
Height = 22
NoneColorColor = clNone
Selected = clNone
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, cbIncludeDefault, cbCustomColor, cbPrettyNames, cbCustomColors]
Anchors = [akLeft, akTop, akRight]
DropDownCount = 16
TabOrder = 12
OnChange = Modification
end
end
end
object tabStatistics: TTabSheet
@@ -867,7 +887,7 @@ object connform: Tconnform
end
object btnMore: TButton
Left = 561
Top = 331
Top = 415
Width = 80
Height = 25
Anchors = [akRight, akBottom]
@@ -118,6 +118,8 @@ Tconnform = class(TFormWithSizeGrip)
pnlDpiHelperSshTunnel: TPanel;
pnlDpiHelperAdvanced: TPanel;
TimerButtonAnimation: TTimer;
lblBackgroundColor: TLabel;
ColorBoxBackgroundColor: TColorBox;
procedure FormCreate(Sender: TObject);
procedure btnOpenClick(Sender: TObject);
procedure FormShow(Sender: TObject);
@@ -382,6 +384,7 @@ procedure Tconnform.btnSaveClick(Sender: TObject);
Sess.KeepAlive := updownKeepAlive.Position;
Sess.LocalTimeZone := chkLocalTimeZone.Checked;
Sess.FullTableStatus := chkFullTableStatus.Checked;
Sess.SessionColor := ColorBoxBackgroundColor.Selected;
Sess.AllDatabasesStr := editDatabases.Text;
Sess.Comment := memoComment.Text;
Sess.StartupScriptFilename := editStartupScript.Text;
@@ -595,6 +598,7 @@ function Tconnform.CurrentParams: TConnectionParameters;
Result.KeepAlive := updownKeepAlive.Position;
Result.LocalTimeZone := chkLocalTimeZone.Checked;
Result.FullTableStatus := chkFullTableStatus.Checked;
Result.SessionColor := ColorBoxBackgroundColor.Selected;
end;
end;

@@ -837,6 +841,7 @@ procedure Tconnform.ListSessionsFocusChanged(Sender: TBaseVirtualTree;
updownKeepAlive.Position := Sess.KeepAlive;
chkLocalTimeZone.Checked := Sess.LocalTimeZone;
chkFullTableStatus.Checked := Sess.FullTableStatus;
ColorBoxBackgroundColor.Selected := Sess.SessionColor;
editDatabases.Text := Sess.AllDatabasesStr;
memoComment.Text := Sess.Comment;
editStartupScript.Text := Sess.StartupScriptFilename;
@@ -1099,6 +1104,7 @@ procedure Tconnform.Modification(Sender: TObject);
or (Sess.KeepAlive <> updownKeepAlive.Position)
or (Sess.LocalTimeZone <> chkLocalTimeZone.Checked)
or (Sess.FullTableStatus <> chkFullTableStatus.Checked)
or (Sess.SessionColor <> ColorBoxBackgroundColor.Selected)
or (Sess.NetType <> TNetType(comboNetType.ItemIndex))
or (Sess.StartupScriptFilename <> editStartupScript.Text)
or (Sess.AllDatabasesStr <> editDatabases.Text)
@@ -1730,9 +1730,6 @@ object MainForm: TMainForm
object N1: TMenuItem
Caption = '-'
end
object actSelectTreeBackground1: TMenuItem
Action = actSelectTreeBackground
end
object ExportSettings1: TMenuItem
Action = actExportSettings
end
@@ -2455,13 +2452,6 @@ object MainForm: TMainForm
ImageIndex = 26
OnExecute = actRemoveFilterExecute
end
object actSelectTreeBackground: TAction
Category = 'File'
Caption = 'Select session background color ...'
Hint = 'Lets you chose a per session color value for the database tree'
ImageIndex = 115
OnExecute = actSelectTreeBackgroundExecute
end
object actPreviousTab: TPreviousTab
Category = 'Tools'
TabControl = PageControlMain
@@ -2889,9 +2879,6 @@ object MainForm: TMainForm
Caption = 'Doubleclick inserts node text'
OnClick = menuDoubleClickInsertsNodeTextClick
end
object menuSelectBGColor: TMenuItem
Action = actSelectTreeBackground
end
object actFavoriteObjectsOnly1: TMenuItem
Action = actFavoriteObjectsOnly
AutoCheck = True
@@ -238,7 +238,6 @@ TMainForm = class(TForm)
Cut1: TMenuItem;
actExportSettings: TAction;
actImportSettings: TAction;
actSelectTreeBackground: TAction;
actPreferences: TAction;
actFlushHosts: TAction;
actFlushLogs: TAction;
@@ -429,7 +428,6 @@ TMainForm = class(TForm)
Cancelediting1: TMenuItem;
DataPost1: TMenuItem;
menuShowSizeColumn: TMenuItem;
menuSelectBGColor: TMenuItem;
actPreviousTab: TPreviousTab;
actNextTab: TNextTab;
Nexttab1: TMenuItem;
@@ -691,7 +689,6 @@ TMainForm = class(TForm)
procedure actSQLhelpExecute(Sender: TObject);
procedure actUpdateCheckExecute(Sender: TObject);
procedure actWebbrowse(Sender: TObject);
procedure actSelectTreeBackgroundExecute(Sender: TObject);
procedure popupQueryPopup(Sender: TObject);
procedure btnDataClick(Sender: TObject);
procedure ListTablesChange(Sender: TBaseVirtualTree; Node: PVirtualNode);
@@ -4701,58 +4698,6 @@ procedure TMainForm.actDataCancelChangesExecute(Sender: TObject);
end;


procedure TMainForm.actSelectTreeBackgroundExecute(Sender: TObject);
var
cs: TColorSelect;
SessionPaths: TStringList;
i: Integer;
Col: TColor;
ColString: String;
CharPostfix: Char;

function ValueExists(Value: String): Boolean;
var
j: Integer;
begin
// Value exists in string list?
Result := False;
for j:=0 to cs.Dialog.CustomColors.Count-1 do begin
if cs.Dialog.CustomColors.ValueFromIndex[j] = Value then begin
Result := True;
break;
end;
end;
end;

begin
// Select database tree background color
cs := TColorSelect.Create(Self);
cs.Dialog.Color := ActiveConnection.Parameters.SessionColor;
// Add custom colors from all sessions
SessionPaths := TStringList.Create;
AppSettings.GetSessionPaths('', SessionPaths);
CharPostfix := 'A';
for i:=0 to SessionPaths.Count-1 do begin
AppSettings.SessionPath := SessionPaths[i];
Col := AppSettings.ReadInt(asTreeBackground);
if Col <> clNone then begin
ColString := IntToHex(ColorToRgb(Col), 6);
if not ValueExists(ColString) then begin
cs.Dialog.CustomColors.Add('Color'+CharPostfix+'='+ColString);
if cs.Dialog.CustomColors.Count >= MaxCustomColors then
break;
CharPostfix := Chr(Ord(CharPostfix)+1);
end;
end;
end;
if cs.Execute then begin
ActiveConnection.Parameters.SessionColor := cs.Dialog.Color;
AppSettings.SessionPath := ActiveConnection.Parameters.SessionPath;
AppSettings.WriteInt(asTreeBackground, cs.Dialog.Color);
end;
end;


{**
Add a SQL-command or comment to SynMemoSQLLog
}

0 comments on commit 07afefc

Please sign in to comment.
You can’t perform that action at this time.