Desktop manager form.

git-svn-id: trunk@49455 -
This commit is contained in:
juha 2015-06-28 11:45:43 +00:00
parent 80cf99ea16
commit c53fe9aebc
3 changed files with 155 additions and 0 deletions

2
.gitattributes vendored
View File

@ -5589,6 +5589,8 @@ ide/customformeditor.pp svneol=native#text/pascal
ide/debugmanager.pas svneol=native#text/pascal
ide/definesgui.lfm svneol=native#text/plain
ide/definesgui.pas svneol=native#text/pascal
ide/desktopmanager.lfm svneol=native#text/plain
ide/desktopmanager.pas svneol=native#text/pascal
ide/dialogprocs.pas svneol=native#text/pascal
ide/diffdialog.lfm svneol=native#text/plain
ide/diffdialog.pas svneol=native#text/pascal

53
ide/desktopmanager.lfm Normal file
View File

@ -0,0 +1,53 @@
object DesktopForm: TDesktopForm
Left = 463
Height = 159
Top = 670
Width = 394
Caption = 'DesktopForm'
ClientHeight = 159
ClientWidth = 394
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.5'
object DesktopComboBox: TComboBox
Left = 6
Height = 23
Top = 12
Width = 212
ItemHeight = 17
OnSelect = DesktopComboBoxSelect
TabOrder = 0
Text = 'DesktopComboBox'
end
object SaveBitBtn: TBitBtn
AnchorSideLeft.Control = DesktopComboBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DesktopComboBox
AnchorSideTop.Side = asrCenter
Left = 229
Height = 29
Top = 9
Width = 133
AutoSize = True
BorderSpacing.Left = 11
Caption = 'Save current desktop'
OnClick = SaveBitBtnClick
TabOrder = 1
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 37
Top = 116
Width = 382
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 2
ShowButtons = [pbOK, pbCancel]
end
end

100
ide/desktopmanager.pas Normal file
View File

@ -0,0 +1,100 @@
unit DesktopManager;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ButtonPanel,
LazarusIDEStrConsts, LCLProc, EnvironmentOpts;
type
{ TDesktopForm }
TDesktopForm = class(TForm)
ButtonPanel1: TButtonPanel;
DesktopComboBox: TComboBox;
SaveBitBtn: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure DesktopComboBoxSelect(Sender: TObject);
procedure SaveBitBtnClick(Sender: TObject);
private
public
end;
function ShowDesktopManagerDlg: TModalResult;
//var DesktopForm: TDesktopForm;
implementation
function ShowDesktopManagerDlg: TModalResult;
var
theForm: TDesktopForm;
begin
Result:=mrCancel;
theForm:=TDesktopForm.Create(Nil);
try
Result:=theForm.ShowModal;
if Result=mrYes then begin
debugln(['ShowDesktopManagerDlg: Selecting ', theForm.DesktopComboBox.Text]);
EnvironmentOptions.Desktops.Select(theForm.DesktopComboBox.Text);
end;
finally
theForm.Free;
end;
end;
{$R *.lfm}
{ TDesktopForm }
procedure TDesktopForm.FormCreate(Sender: TObject);
var
i, ActiveInd: Integer;
begin
// Saved desktops
ActiveInd := 0;
with EnvironmentOptions do
for i:=0 to Desktops.Count-1 do
begin
if Desktops[i] = Desktop then
ActiveInd := i;
DesktopComboBox.Items.Add(Desktops[i].Name);
end;
DesktopComboBox.ItemIndex := ActiveInd;
// Save button
SaveBitBtn.Caption := dlgSaveCurrentDesktop;
SaveBitBtn.LoadGlyphFromResourceName(HInstance, 'laz_save');
end;
procedure TDesktopForm.DesktopComboBoxSelect(Sender: TObject);
begin
debugln(['TDesktopForm.DesktopComboBoxSelect: ', DesktopComboBox.Text]);
end;
procedure TDesktopForm.SaveBitBtnClick(Sender: TObject);
var
dsk: TDesktopOpt;
begin
with EnvironmentOptions do
begin
dsk := Desktops.Find(DesktopComboBox.Text);
if not Assigned(dsk) then
begin
debugln(['TDesktopForm.SaveBitBtnClick: Adding ', DesktopComboBox.Text]);
dsk := TDesktopOpt.Create(DesktopComboBox.Text);
Desktops.Add(dsk);
end;
debugln(['TDesktopForm.SaveBitBtnClick: Assign from ', Desktop.Name, ' to ', dsk.Name]);
dsk.Assign(Desktop);
Desktops.Select(DesktopComboBox.Text);
end;
end;
end.