1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-23 07:48:50 -05:00
This commit is contained in:
Merlijn Wajer 2010-07-06 11:31:50 +02:00
commit cb5d6c3843
4 changed files with 11 additions and 353 deletions

View File

@ -3,11 +3,11 @@
Simba settings
==============
The Simba settings form can be used to tweak various Simba settings. Varying
from how often Simba will check for an update to wether or not you want the tray
icon to show at all times.
The Simba settings form can be used to modify the settings. These options vary
from how often Simba will check for an update to whether the tray icon is
displayed at all times.
Settings can be changed by going to the menubar titled *Tools* and the
Settings can be changed by going to the menu *Tools* menu and the
selecting the *Settings* option.
If you at any time have serious problems with Simba not behaving it as you
@ -16,6 +16,7 @@ closing Simba and deleting ``settings.xml``. Simba will create one with
default settings if it does not exist.
=======
General Settings
----------------
@ -26,7 +27,7 @@ Recent files history
``MaxRecentFiles``
Stores the amount of recent files to remember. *10* is default.
Stores the amount of recent files to remember. The default is *10*.
Extensions
@ -129,7 +130,8 @@ Automatically pop up Code Hints
``ShowAutomatically``
If set to *True*, code hints will be shown when appropriate.
On *False* code hints will never be shown automatically.
On *False* code hints will never be shown automatically, but can still be
accessed by pressing *Ctrl+Space*.
Code Hints
@ -160,7 +162,7 @@ It true is set to *True*, the function list will be visible on startup. *False*
requires you to enable it yourself.
Colour Picker
Color Picker
-------------
``Settings/ColourPicker``
@ -184,9 +186,9 @@ Script opening mode
``OpenScriptInNewTab``
Simba can load Scripts in two diffferent ways. It can open every script in a new
Simba can load Scripts in two different ways. It can open every script in a new
tab, or it can override the currently active tab. Setting this to *True* opens
scripts in new tabs; this is also the default.
scripts in new tabs, this is the default.
Behaviour when closing tabs
~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,74 +0,0 @@
object SettingsForm: TSettingsForm
Left = 563
Height = 558
Top = 173
Width = 360
Caption = 'Simba Settings'
ClientHeight = 558
ClientWidth = 360
OnCreate = FormCreate
OnDestroy = FormDestroy
OnMouseUp = MouseUp
LCLVersion = '0.9.29'
object SettingsTreeView: TTreeView
Left = 16
Height = 473
Top = 16
Width = 324
Anchors = [akTop, akLeft, akRight, akBottom]
DefaultItemHeight = 15
ReadOnly = True
ScrollBars = ssAutoBoth
TabOrder = 0
OnDblClick = SettingsTreeViewDblClick
OnKeyPress = OnKeyPress
OnMouseUp = MouseUp
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end
object SettingsFormButtonOK: TButton
Left = 265
Height = 25
Top = 511
Width = 75
Anchors = [akRight, akBottom]
Caption = 'OK'
OnClick = SettingsFormButtonOKClick
TabOrder = 1
end
object SettingsFormButtonCancel: TButton
Left = 16
Height = 25
Top = 511
Width = 75
Anchors = [akLeft, akBottom]
Caption = 'Cancel'
OnClick = SettingsFormButtonCancelClick
TabOrder = 2
end
object DeleteButton: TButton
Left = 120
Height = 25
Top = 511
Width = 120
Anchors = [akBottom]
Caption = 'Delete Selected'
OnClick = DeleteSelected
TabOrder = 3
end
object SettingsPopup: TPopupMenu
left = 40
top = 32
object PopupRename: TMenuItem
Caption = 'Rename'
OnClick = PopupRenameClick
end
object PopupDelete: TMenuItem
Caption = 'Delete'
OnClick = PopupDeleteClick
end
object PopupCreate: TMenuItem
Caption = 'Create subkey'
OnClick = PopupCreateKey
end
end
end

View File

@ -1,26 +0,0 @@
LazarusResources.Add('TSettingsForm','FORMDATA',[
'TPF0'#13'TSettingsForm'#12'SettingsForm'#4'Left'#3'3'#2#6'Height'#3'.'#2#3'T'
+'op'#3#173#0#5'Width'#3'h'#1#7'Caption'#6#14'Simba Settings'#12'ClientHeight'
+#3'.'#2#11'ClientWidth'#3'h'#1#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11
+'FormDestroy'#9'OnMouseUp'#7#7'MouseUp'#10'LCLVersion'#6#6'0.9.29'#0#9'TTree'
+'View'#16'SettingsTreeView'#4'Left'#2#16#6'Height'#3#217#1#3'Top'#2#16#5'Wid'
+'th'#3'D'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#17'Def'
+'aultItemHeight'#2#15#8'ReadOnly'#9#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrd'
+'er'#2#0#10'OnDblClick'#7#24'SettingsTreeViewDblClick'#10'OnKeyPress'#7#10'O'
+'nKeyPress'#9'OnMouseUp'#7#7'MouseUp'#7'Options'#11#17'tvoAutoItemHeight'#16
+'tvoHideSelection'#21'tvoKeepCollapsedNodes'#11'tvoReadOnly'#14'tvoShowButto'
+'ns'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0#0#7'TButton'#20'Se'
+'ttingsFormButtonOK'#4'Left'#3#9#1#6'Height'#2#25#3'Top'#3#255#1#5'Width'#2
+'K'#7'Anchors'#11#7'akRight'#8'akBottom'#0#7'Caption'#6#2'OK'#7'OnClick'#7#25
+'SettingsFormButtonOKClick'#8'TabOrder'#2#1#0#0#7'TButton'#24'SettingsFormBu'
+'ttonCancel'#4'Left'#2#16#6'Height'#2#25#3'Top'#3#255#1#5'Width'#2'K'#7'Anch'
+'ors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#6'Cancel'#7'OnClick'#7#29'Sett'
+'ingsFormButtonCancelClick'#8'TabOrder'#2#2#0#0#7'TButton'#12'DeleteButton'#4
+'Left'#2'x'#6'Height'#2#25#3'Top'#3#255#1#5'Width'#2'x'#7'Anchors'#11#8'akBo'
+'ttom'#0#7'Caption'#6#15'Delete Selected'#7'OnClick'#7#14'DeleteSelected'#8
+'TabOrder'#2#3#0#0#10'TPopupMenu'#13'SettingsPopup'#4'left'#2'('#3'top'#2' '
+#0#9'TMenuItem'#11'PopupRename'#7'Caption'#6#6'Rename'#7'OnClick'#7#16'Popup'
+'RenameClick'#0#0#9'TMenuItem'#11'PopupDelete'#7'Caption'#6#6'Delete'#7'OnCl'
+'ick'#7#16'PopupDeleteClick'#0#0#9'TMenuItem'#11'PopupCreate'#7'Caption'#6#13
+'Create subkey'#7'OnClick'#7#14'PopupCreateKey'#0#0#0#0
]);

View File

@ -1,244 +0,0 @@
unit Simbasettings;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls,MufasaBase, Graphics, Dialogs,
ComCtrls, StdCtrls, Menus, settings;
type
{ TSettingsForm }
TSettingsForm = class(TForm)
DeleteButton: TButton;
PopupCreate: TMenuItem;
PopupRename: TMenuItem;
PopupDelete: TMenuItem;
SettingsPopup: TPopupMenu;
SettingsFormButtonCancel: TButton;
SettingsFormButtonOK: TButton;
SettingsTreeView: TTreeView;
Settings: TMMLSettings;
procedure DeleteSelected(Sender: TObject);
procedure MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure OnKeyPress(Sender: TObject; var Key: char);
procedure PopupCreateKey(Sender: TObject);
procedure PopupDeleteClick(Sender: TObject);
procedure PopupRenameClick(Sender: TObject);
procedure SettingsFormButtonCancelClick(Sender: TObject);
procedure SettingsFormButtonOKClick(Sender: TObject);
procedure DeleteANode(N: TTreeNode);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure SettingsTreeViewDblClick(Sender: TObject);
{ private declarations }
public
procedure SaveCurrent;
procedure Reload;
{ public declarations }
end;
var
SettingsForm: TSettingsForm;
SimbaSettingsFile : string;
implementation
uses LCLtype;
{ TSettingsForm }
procedure TSettingsForm.FormCreate(Sender: TObject);
var
FirstNode : TTreeNode;
begin
Settings := TMMLSettings.Create(SettingsTreeView.Items);
if not FileExists(SimbaSettingsFile) then
begin
SettingsTreeView.Items.Clear;
Settings.SaveToXML(SimbaSettingsFile);
end;
SettingsTreeView.Items.Clear;
Settings.LoadFromXML(SimbaSettingsFile);
FirstNode := SettingsTreeView.Items.GetFirstNode;
if FirstNode <> nil then
if FirstNode.Text = 'Settings' then
FirstNode.Expand(false);
end;
procedure TSettingsForm.SettingsFormButtonOKClick(Sender: TObject);
begin
Self.Settings.SaveToXML(SimbaSettingsFile);
Self.ModalResult:=mrOK;
end;
procedure TSettingsForm.SettingsFormButtonCancelClick(Sender: TObject);
begin
if not FileExists(SimbaSettingsFile) then
begin
Self.SettingsTreeView.Items.Clear;
Self.Settings.SaveToXML(SimbaSettingsFile);
Self.SettingsTreeView.Items.Clear;
Self.Settings.LoadFromXML(SimbaSettingsFile);
end;
Self.ModalResult:=mrOK;
end;
procedure TSettingsForm.MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
N: TTreeNode;
begin
if Button = mbRight then
begin
N := SettingsTreeView.GetNodeAt(X, Y);
if N = nil then
exit;
SettingsTreeView.Selected := N;
SettingsPopup.PopUp();
end;
end;
procedure TSettingsForm.OnKeyPress(Sender: TObject; var Key: char);
var
N: TTreeNode;
begin
if (Ord(Key) = VK_DELETE) or (Ord(Key) = VK_BACK) then
begin
N := SettingsTreeView.Selected;
if N = nil then
exit;
DeleteANode(N);
end;
end;
procedure TSettingsForm.PopupCreateKey(Sender: TObject);
var
KeyName, P: String;
N, NN: TTreeNode;
begin
N := SettingsTreeView.Selected;
if N = nil then
exit;
if N.Data <> nil then
exit;
if N.GetFirstChild <> nil then
if N.GetFirstChild.Data <> nil then
exit;
KeyName := InputBox('Create new Key', 'Please enter the key name', '');
if KeyName = '' then
exit;
P := Settings.GetNodePath(N);
if Settings.CreateKey(P + '/' + KeyName) then
mDebugLn('Added key ' + KeyName);
end;
procedure TSettingsForm.FormDestroy(Sender: TObject);
begin
Settings.Free;
end;
procedure TSettingsForm.PopupDeleteClick(Sender: TObject);
begin
DeleteSelected(Sender);
end;
procedure TSettingsForm.PopupRenameClick(Sender: TObject);
var
N: TTreeNode;
MBox, Path: String;
begin
N := SettingsTreeView.Selected;
if N = nil then
exit;
Path := Settings.GetNodePath(N);
MBox := InputBox('Rename', 'Please fill in the new name', '');
if MBox = '' then
exit;
if Settings.RenameKey(Path, MBox) then
N.Text := MBox;
end;
procedure TSettingsForm.DeleteSelected(Sender: TObject);
var
N: TTreeNode;
begin
N := SettingsTreeView.Selected;
if N = nil then
exit;
DeleteANode(N);
end;
procedure TSettingsForm.DeleteANode(N: TTreeNode);
var
Path: String;
begin
if N = nil then
exit;
if MessageDlg('Delete a setting', 'Are you sure you want to delete this setting?', mtWarning, [mbYes, mbNo], 0) = mrNo then
exit;
Path := Settings.GetNodePath(N);
Settings.DeleteKey(Path);
N.DeleteChildren;
N.Delete;
end;
procedure TSettingsForm.SettingsTreeViewDblClick(Sender: TObject);
var
p, pp: TPoint;
N: TTreeNode;
Path, NewVal: String;
begin
p := Mouse.CursorPos;
pp := TTreeView(Sender).ScreenToClient(p);
N := SettingsTreeView.GetNodeAt(pp.x, pp.y);
if N <> nil then
if assigned(N.Data) then
begin
Path := Settings.GetNodePath(N.Parent);
NewVal := InputBox('Change Setting', 'Change value for ' + TSettingData(N.Data).Val,
Settings.GetKeyValue(Path));
mDebugLn('NewVal: ' + NewVal);
Settings.SetKeyValue(Path, NewVal);
N.Text := NewVal;
end;
end;
procedure TSettingsForm.SaveCurrent;
begin
Settings.SaveToXML(SimbaSettingsFile);
end;
procedure TSettingsForm.Reload;
begin
if not FileExists(SimbaSettingsFile) then
begin
SettingsTreeView.Items.Clear;
Settings.SaveToXML(SimbaSettingsFile);
end;
SettingsTreeView.Items.Clear;
Settings.LoadFromXML(SimbaSettingsFile);
end;
initialization
{$R *.lfm}
end.