Debian Codegraph @

components/extension/accuraterip/configdialog.cpp

raw symbols SCIP
1 /* fre:ac - free audio converter
2 * Copyright (C) 2001-2021 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #include "configdialog.h"
14
15 BoCA::AccurateRipConfigDialog::AccurateRipConfigDialog()
16 {
17 AS::Registry &boca = AS::Registry::Get();
18
19 component = boca.CreateComponentByID("accuraterip-verify");
20
21 if (component != NIL)
22 {
23 Config *config = Config::Get();
24 I18n *i18n = I18n::Get();
25
26 i18n->SetContext("Configuration");
27
28 layer = component->GetConfigurationLayer();
29
30 mainWnd = new Window(component->GetName(), Point(config->GetIntValue("Settings", "WindowPosX", 100), config->GetIntValue("Settings", "WindowPosY", 100)) + Point(60, 60), layer->GetSize() + Size(8, 73));
31 mainWnd->SetRightToLeft(i18n->IsActiveLanguageRightToLeft());
32
33 mainWnd_titlebar = new Titlebar(TB_CLOSEBUTTON);
34 divbar = new Divider(39, OR_HORZ | OR_BOTTOM);
35
36 btn_cancel = new Button(i18n->TranslateString("Cancel"), Point(175, 29), Size());
37 btn_cancel->onAction.Connect(&AccurateRipConfigDialog::Cancel, this);
38 btn_cancel->SetOrientation(OR_LOWERRIGHT);
39
40 btn_ok = new Button(i18n->TranslateString("OK"), btn_cancel->GetPosition() - Point(88, 0), Size());
41 btn_ok->onAction.Connect(&AccurateRipConfigDialog::OK, this);
42 btn_ok->SetOrientation(OR_LOWERRIGHT);
43
44 Add(mainWnd);
45
46 mainWnd->Add(mainWnd_titlebar);
47 mainWnd->Add(divbar);
48 mainWnd->Add(btn_ok);
49 mainWnd->Add(btn_cancel);
50
51 mainWnd->GetMainLayer()->Add(layer);
52
53 String resourcesPath = Application::GetApplicationDirectory();
54
55 #ifndef __WIN32__
56 if (Directory(S::System::System::GetResourcesDirectory().Append("freac")).Exists()) resourcesPath = S::System::System::GetResourcesDirectory().Append("freac").Append(Directory::GetDirectoryDelimiter());
57 #endif
58
59 mainWnd->SetFlags(mainWnd->GetFlags() | WF_NOTASKBUTTON | WF_MODAL);
60 mainWnd->SetIcon(ImageLoader::Load(String(resourcesPath).Append("icons/freac.png")));
61 }
62 else
63 {
64 layer = NIL;
65
66 mainWnd = NIL;
67 mainWnd_titlebar = NIL;
68
69 btn_cancel = NIL;
70 btn_ok = NIL;
71
72 divbar = NIL;
73 }
74 }
75
76 BoCA::AccurateRipConfigDialog::~AccurateRipConfigDialog()
77 {
78 if (component == NIL) return;
79
80 AS::Registry &boca = AS::Registry::Get();
81
82 DeleteObject(mainWnd_titlebar);
83 DeleteObject(mainWnd);
84 DeleteObject(btn_ok);
85 DeleteObject(btn_cancel);
86 DeleteObject(divbar);
87
88 boca.DeleteComponent(component);
89 }
90
91 const Error &BoCA::AccurateRipConfigDialog::ShowDialog()
92 {
93 if (layer != NIL) mainWnd->WaitUntilClosed();
94 else error = Error();
95
96 return error;
97 }
98
99 Void BoCA::AccurateRipConfigDialog::OK()
100 {
101 if (layer->SaveSettings() == Error()) return;
102
103 mainWnd->Close();
104
105 Settings::onChangeComponentSettings.Emit(component->GetID());
106 }
107
108 Void BoCA::AccurateRipConfigDialog::Cancel()
109 {
110 mainWnd->Close();
111 }