unit_createhd.pas 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. unit unit_createhd;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, Forms, Controls, Graphics, LCLIntf, Dialogs, StdCtrls,
  6. Buttons, EditBtn, ComCtrls, Spin;
  7. type
  8. { TfrmCreateHD }
  9. TfrmCreateHD = class(TForm)
  10. btnRef1: TBitBtn;
  11. btnOK: TBitBtn;
  12. btnCancel: TBitBtn;
  13. cmbHDImageType: TComboBox;
  14. edtHDFile: TFileNameEdit;
  15. GroupBox1: TGroupBox;
  16. Label1: TLabel;
  17. Label2: TLabel;
  18. Label3: TLabel;
  19. Label4: TLabel;
  20. Label5: TLabel;
  21. spnHDSize: TSpinEdit;
  22. trkHDSize: TTrackBar;
  23. procedure btnCancelClick(Sender: TObject);
  24. procedure btnOKClick(Sender: TObject);
  25. procedure btnRef1Click(Sender: TObject);
  26. procedure FormCreate(Sender: TObject);
  27. procedure spnHDSizeChange(Sender: TObject);
  28. procedure trkHDSizeChange(Sender: TObject);
  29. private
  30. public
  31. end;
  32. var
  33. frmCreateHD: TfrmCreateHD;
  34. implementation
  35. uses
  36. Unit1;
  37. {$R *.lfm}
  38. { TfrmCreateHD }
  39. procedure TfrmCreateHD.FormCreate(Sender: TObject);
  40. begin
  41. end;
  42. procedure TfrmCreateHD.btnOKClick(Sender: TObject);
  43. var
  44. ret:string;
  45. begin
  46. ret:=Form1.GetCommandOutput('qemu-img create -q -f '+cmbHDImageType.Text+' '+edtHDFile.Text+' '+inttostr(trkHDSize.Position)+'G' );
  47. if ret <> '' then
  48. ShowMessage('QEMU image creation error: '+ret)
  49. else
  50. ModalResult:=mrOK;
  51. end;
  52. procedure TfrmCreateHD.btnRef1Click(Sender: TObject);
  53. begin
  54. OpenURL('https://en.wikibooks.org/wiki/QEMU/Images#Image_types');
  55. end;
  56. procedure TfrmCreateHD.btnCancelClick(Sender: TObject);
  57. begin
  58. ModalResult:=mrCancel;
  59. end;
  60. procedure TfrmCreateHD.spnHDSizeChange(Sender: TObject);
  61. begin
  62. if spnHDSize.Focused then
  63. trkHDSize.Position := spnHDSize.Value;
  64. end;
  65. procedure TfrmCreateHD.trkHDSizeChange(Sender: TObject);
  66. begin
  67. if trkHDSize.Focused then
  68. spnHDSize.Value := trkHDSize.Position;
  69. end;
  70. end.