This repository was archived by the owner on Dec 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.cpp
More file actions
86 lines (72 loc) · 2.6 KB
/
settings.cpp
File metadata and controls
86 lines (72 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include "settings.h"
#include "message.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
namespace Ioutils = System::Ioutils;
//---------------------------------------------------------------------------
__fastcall TSettingsForm::TSettingsForm(TComponent* Owner)
: TForm(Owner)
{
DefaultProfileEdit->OnChangeTracking = this->OnChangedTracking;
PluginsPathEdit->OnChangeTracking = this->OnChangedTracking;
ProfilesPathEdit->OnChangeTracking = this->OnChangedTracking;
}
//---------------------------------------------------------------------------
void __fastcall TSettingsForm::OkButtonClick(TObject *Sender)
{
OkButton->ModalResult = mrNone;
struct TCheckItem
{
TEdit* Edit;
bool IsFile;
};
TCheckItem checks[] = {
{ DefaultProfileEdit, true },
{ PluginsPathEdit, false },
{ ProfilesPathEdit, false }
};
for (auto &check : checks)
{
bool exists = check.IsFile ? TFile::Exists(check.Edit->Text) : TDirectory::Exists(check.Edit->Text);
if (!exists)
{
ErrorMessage(L"'%s' could not be found", check.Edit->Text);
return;
}
}
OkButton->ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TSettingsForm::CancelButtonClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TSettingsForm::EllipsesEditButton2Click(TObject *Sender)
{
UnicodeString dir = L"";
if( Dialogs::SelectDirectory("Select 'plugins' Directory", PluginsPathEdit->Text, dir ) ) PluginsPathEdit->Text = dir;
}
//---------------------------------------------------------------------------
void __fastcall TSettingsForm::OnChangedTracking( TObject *Sender )
{
OkButton->Enabled =
!DefaultProfileEdit->Text.IsEmpty() &&
!PluginsPathEdit->Text.IsEmpty() &&
!ProfilesPathEdit->Text.IsEmpty();
}
void __fastcall TSettingsForm::EllipsesEditButton1Click(TObject *Sender)
{
if( OpenDialog->Execute() ) DefaultProfileEdit->Text = OpenDialog->FileName;
}
//---------------------------------------------------------------------------
void __fastcall TSettingsForm::EllipsesEditButton3Click(TObject *Sender)
{
UnicodeString dir = L"";
if( Dialogs::SelectDirectory("Select Profiles Directory", ProfilesPathEdit->Text, dir ) ) ProfilesPathEdit->Text = dir;
}
//---------------------------------------------------------------------------