-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
386 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
object SimbaBackupsForm: TSimbaBackupsForm | ||
Left = 1333 | ||
Height = 450 | ||
Top = 543 | ||
Width = 739 | ||
Caption = 'SimbaBackupsForm' | ||
ClientHeight = 450 | ||
ClientWidth = 739 | ||
DesignTimePPI = 120 | ||
OnCreate = FormCreate | ||
OnShow = FormShow | ||
Position = poMainFormCenter | ||
ShowInTaskBar = stAlways | ||
LCLVersion = '2.2.4.0' | ||
object LeftPanel: TPanel | ||
Left = 0 | ||
Height = 450 | ||
Top = 0 | ||
Width = 213 | ||
Align = alLeft | ||
BevelOuter = bvNone | ||
TabOrder = 0 | ||
end | ||
object Splitter: TSplitter | ||
Left = 213 | ||
Height = 450 | ||
Top = 0 | ||
Width = 6 | ||
OnPaint = SplitterPaint | ||
end | ||
object RightPanel: TPanel | ||
Left = 219 | ||
Height = 450 | ||
Top = 0 | ||
Width = 520 | ||
Align = alClient | ||
BevelOuter = bvNone | ||
Caption = '(no file selected)' | ||
TabOrder = 2 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
{ | ||
Author: Raymond van Venetië and Merlijn Wajer | ||
Project: Simba (https://github.com/MerlijnWajer/Simba) | ||
License: GNU General Public License (https://www.gnu.org/licenses/gpl-3.0) | ||
} | ||
unit simba.backupsform; | ||
|
||
{$i simba.inc} | ||
|
||
interface | ||
|
||
uses | ||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, Zipper, | ||
simba.editor, simba.component_treeview, simba.component_buttonpanel; | ||
|
||
type | ||
TSimbaBackupsForm = class(TForm) | ||
LeftPanel: TPanel; | ||
RightPanel: TPanel; | ||
Splitter: TSplitter; | ||
ButtonPanel: TSimbaButtonPanel; | ||
|
||
procedure FormCreate(Sender: TObject); | ||
procedure FormShow(Sender: TObject); | ||
procedure SplitterPaint(Sender: TObject); | ||
procedure DoSplitterEnterExit(Sender: TObject); | ||
procedure DoTreeViewSelectionChanged(Sender: TObject); | ||
procedure DoButtonOkClick(Sender: TObject); | ||
procedure DoCreateStream(Sender : TObject; var AStream: TStream; AItem: TFullZipFileEntry); | ||
procedure DoDoneStream(Sender : TObject; var AStream : TStream; AItem : TFullZipFileEntry); | ||
procedure AddBackups; | ||
private | ||
TreeView: TSimbaTreeView; | ||
Editor: TSimbaEditor; | ||
CurrentNode: TTreeNode; | ||
end; | ||
|
||
var | ||
SimbaBackupsForm: TSimbaBackupsForm; | ||
|
||
implementation | ||
|
||
{$R *.lfm} | ||
|
||
uses | ||
AnchorDocking, | ||
simba.env, simba.files, simba.theme, simba.main, simba.scripttabsform; | ||
|
||
type | ||
TBackupNode = class(TTreeNode) | ||
public | ||
Contents: String; | ||
end; | ||
|
||
procedure TSimbaBackupsForm.FormShow(Sender: TObject); | ||
begin | ||
Splitter.Width := DockMaster.SplitterWidth; | ||
TreeView.Clear(); | ||
AddBackups(); | ||
end; | ||
|
||
procedure TSimbaBackupsForm.SplitterPaint(Sender: TObject); | ||
begin | ||
with TSplitter(Sender) do | ||
begin | ||
Canvas.Brush.Color := SimbaTheme.ColorFrame; | ||
Canvas.FillRect(ClientRect); | ||
|
||
if MouseInClient then | ||
begin | ||
Canvas.Brush.Color := SimbaTheme.ColorActive; | ||
Canvas.FillRect(3, 3, Width-3, Height-3); | ||
end; | ||
end; | ||
end; | ||
|
||
procedure TSimbaBackupsForm.DoSplitterEnterExit(Sender: TObject); | ||
begin | ||
TSplitter(Sender).Invalidate(); | ||
end; | ||
|
||
procedure TSimbaBackupsForm.DoTreeViewSelectionChanged(Sender: TObject); | ||
var | ||
Node: TBackupNode; | ||
begin | ||
Node := TBackupNode(TreeView.Selected); | ||
if (Node is TBackupNode) then | ||
begin | ||
Editor.Text := Node.Contents; | ||
Editor.Visible := True; | ||
end else | ||
Editor.Visible := False; | ||
end; | ||
|
||
procedure TSimbaBackupsForm.DoButtonOkClick(Sender: TObject); | ||
begin | ||
if Editor.Visible then | ||
begin | ||
SimbaScriptTabsForm.AddTab().Editor.Text := Editor.Text; | ||
if (Sender is TTreeView) then | ||
Close(); | ||
end; | ||
end; | ||
|
||
procedure TSimbaBackupsForm.DoCreateStream(Sender: TObject; var AStream: TStream; AItem: TFullZipFileEntry); | ||
begin | ||
AStream := TStringStream.Create(); | ||
end; | ||
|
||
procedure TSimbaBackupsForm.DoDoneStream(Sender: TObject; var AStream: TStream; AItem: TFullZipFileEntry); | ||
begin | ||
with TreeView.AddNode(CurrentNode, FormatDateTime('c', AItem.DateTime), IMAGE_FILE) as TBackupNode do | ||
Contents := TStringStream(AStream).DataString; | ||
|
||
AStream.Free(); | ||
end; | ||
|
||
procedure TSimbaBackupsForm.AddBackups; | ||
var | ||
FileName: String; | ||
UnZipper: TUnZipper; | ||
begin | ||
for FileName in TSimbaDir.DirSearch(SimbaEnv.BackupsPath, '*.zip') do | ||
begin | ||
CurrentNode := TreeView.AddNode(TSimbaPath.PathExtractNameWithoutExt(FileName), IMAGE_DIRECTORY); | ||
|
||
UnZipper := TUnZipper.Create(); | ||
try | ||
UnZipper.FileName := FileName; | ||
UnZipper.Examine(); | ||
UnZipper.OnCreateStream := @DoCreateStream; | ||
UnZipper.OnDoneStream := @DoDoneStream; | ||
UnZipper.UnZipAllFiles(); | ||
except | ||
end; | ||
UnZipper.Free(); | ||
end; | ||
end; | ||
|
||
procedure TSimbaBackupsForm.FormCreate(Sender: TObject); | ||
begin | ||
Width := Scale96ToScreen(800); | ||
Height := Scale96ToScreen(600); | ||
|
||
Editor := TSimbaEditor.Create(Self); | ||
Editor.Parent := RightPanel; | ||
Editor.Align := alClient; | ||
Editor.Visible := False; | ||
|
||
TreeView := TSimbaTreeView.Create(Self, TBackupNode); | ||
TreeView.Parent := LeftPanel; | ||
TreeView.Align := alClient; | ||
TreeView.OnSelectionChange := @DoTreeViewSelectionChanged; | ||
TreeView.OnDoubleClick := @DoButtonOkClick; | ||
|
||
RightPanel.Color := SimbaTheme.ColorBackground; | ||
RightPanel.Font.Color := SimbaTheme.ColorFont; | ||
|
||
ButtonPanel := TSimbaButtonPanel.Create(Self); | ||
ButtonPanel.Parent := Self; | ||
ButtonPanel.ButtonOk.OnClick := @DoButtonOkClick; | ||
|
||
Splitter.OnEnter := @DoSplitterEnterExit; | ||
Splitter.OnExit := @DoSplitterEnterExit; | ||
end; | ||
|
||
end. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.