Changeset 9 for trunk


Ignore:
Timestamp:
Apr 1, 2016, 8:25:11 AM (9 years ago)
Author:
chronos
Message:
  • Added: Project save action in menu activated if project was modified.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFormMain.lfm

    r8 r9  
    285285      OnExecute = AFileOpenExecute
    286286    end
     287    object AFileSave: TAction
     288      Caption = 'Save'
     289      OnExecute = AFileSaveExecute
     290    end
    287291  end
    288292  object OpenDialog1: TOpenDialog
     
    302306        Action = AFileOpen
    303307      end
     308      object MenuItem9: TMenuItem
     309        Action = AFileSave
     310      end
    304311      object MenuItem3: TMenuItem
    305312        Action = AFileSaveAs
  • trunk/UFormMain.pas

    r8 r9  
    1515  TFormMain = class(TForm)
    1616    ABrowseDisk: TAction;
     17    AFileSave: TAction;
    1718    AFileOpen: TAction;
    1819    AFileSaveAs: TAction;
     
    5960    MenuItem7: TMenuItem;
    6061    MenuItem8: TMenuItem;
     62    MenuItem9: TMenuItem;
    6163    OpenDialog1: TOpenDialog;
    6264    SaveDialog1: TSaveDialog;
     
    6769    procedure AFileOpenExecute(Sender: TObject);
    6870    procedure AFileSaveAsExecute(Sender: TObject);
     71    procedure AFileSaveExecute(Sender: TObject);
    6972    procedure AScanOptionsExecute(Sender: TObject);
    7073    procedure AScanStartExecute(Sender: TObject);
     
    106109  UFormProject;
    107110
     111resourcestring
     112  SProjectModified = '(modified)';
     113
    108114{ TFormMain }
    109115
     
    112118  LoadConfig;
    113119  if FileExists(LastProjectFileName) then
    114     ProjectOpen(LastProjectFileName);
    115   Redraw;
    116   UpdateInterface;
     120    ProjectOpen(LastProjectFileName)
     121  else begin
     122    Redraw;
     123    UpdateInterface;
     124  end;
    117125end;
    118126
     
    148156  DriveScan.WritePattern := StrToInt(EditPattern.Text);
    149157  DriveScan.Start;
     158  Project.Modified := True;
    150159  UpdateInterface;
    151160end;
     
    189198    Project.SaveToFile(SaveDialog1.FileName);
    190199  end;
     200end;
     201
     202procedure TFormMain.AFileSaveExecute(Sender: TObject);
     203begin
     204  if not FileExists(Project.FileName) then
     205    AFileSaveAs.Execute
     206    else Project.SaveToFile(Project.FileName);
    191207end;
    192208
     
    255271
    256272procedure TFormMain.UpdateInterface;
     273var
     274  Title: string;
    257275begin
    258276  if Assigned(DriveScan) then begin
     
    260278    AScanStop.Enabled := DriveScan.Terminated = False;
    261279  end;
     280  AFileSave.Enabled := Assigned(Project) and Project.Modified;
     281  AFileSaveAs.Enabled := Assigned(Project);
     282
     283  Title := '';
     284  if Assigned(Project) then
     285    Title := Title + Project.FileName + ' - ';
     286  Title := Title + Application.Title;
     287  if Assigned(Project) and Project.Modified then
     288    Title := Title + ' ' + SProjectModified;
     289  Caption := Title;
    262290end;
    263291
     
    283311  Project.LoadFromFile(FileName);
    284312  LastProjectFileName := FileName;
     313  UpdateInterface;
     314  Redraw;
    285315end;
    286316
  • trunk/UProject.pas

    r7 r9  
    7171    Doc.Free;
    7272  end;
     73  Modified := False;
    7374end;
    7475
     
    7980  NewNode: TDOMNode;
    8081begin
     82  Modified := False;
    8183  Self.FileName := FileName;
    8284  ReadXMLFile(Doc, FileName);
Note: See TracChangeset for help on using the changeset viewer.