You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6KB

  1. #include "options.h"
  2. options::options( wxWindow* parent )
  3. :
  4. dialog_Options( parent )
  5. {
  6. configuration = new config(this);
  7. dirpicker_dbpath->SetPath(configuration->GetDbpath());
  8. checkbox_proxy->SetValue(configuration->IsUseproxy());
  9. textctrl_url->SetValue(configuration->GetProxyurl());
  10. spinctrl_port->SetValue(configuration->GetProxyport());
  11. updatefields();
  12. }
  13. options::~options()
  14. {
  15. delete configuration;
  16. }
  17. void options::OnCancel( wxCloseEvent& event )
  18. {
  19. dirpicker_dbpath->SetPath(configuration->GetDbpath());
  20. checkbox_proxy->SetValue(configuration->IsUseproxy());
  21. textctrl_url->SetValue(configuration->GetProxyurl());
  22. spinctrl_port->SetValue(configuration->GetProxyport());
  23. this->Hide();
  24. updatefields();
  25. }
  26. void options::OnCancel( wxCommandEvent& event )
  27. {
  28. dirpicker_dbpath->SetPath(configuration->GetDbpath());
  29. checkbox_proxy->SetValue(configuration->IsUseproxy());
  30. textctrl_url->SetValue(configuration->GetProxyurl());
  31. spinctrl_port->SetValue(configuration->GetProxyport());
  32. this->Hide();
  33. updatefields();
  34. }
  35. void options::OnOk( wxCommandEvent& event )
  36. {
  37. configuration->SetDbpath(dirpicker_dbpath->GetPath());
  38. configuration->SetUseproxy(checkbox_proxy->GetValue());
  39. configuration->SetProxyurl(textctrl_url->GetValue());
  40. configuration->SetProxyport(spinctrl_port->GetValue());
  41. configuration->save();
  42. this->Hide();
  43. }
  44. void options::OnToggleProxy( wxCommandEvent& event )
  45. {
  46. updatefields();
  47. }
  48. void options::updatefields()
  49. {
  50. if (!checkbox_proxy->GetValue())
  51. {
  52. textctrl_url->Disable();
  53. spinctrl_port->Disable();
  54. }
  55. else
  56. {
  57. textctrl_url->Enable();
  58. spinctrl_port->Enable();
  59. }
  60. }