MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / savePanel

Method savePanel

Source/Core/CtrlrPanel/CtrlrPanelFileOperations.cpp:132–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132Result CtrlrPanel::savePanel()
133{
134 _DBG("CtrlrPanel::savePanel");
135
136 bool panelWasDirty = isPanelDirty();
137 setPanelDirty(false);
138 Result res = Result::ok();
139 const String filePath = getProperty(Ids::panelFilePath);
140 File panelFile(filePath);
141
142 if (panelFile.existsAsFile() && panelFile.hasWriteAccess())
143 {
144 if (panelFile.hasFileExtension("panel"))
145 res = savePanelXml(panelFile, this, false);
146 if (panelFile.hasFileExtension("panelz"))
147 res = savePanelXml (panelFile, this, true);
148 if (panelFile.hasFileExtension("bpanel"))
149 res = savePanelBin (panelFile, this, false);
150 if (panelFile.hasFileExtension("bpanelz"))
151 res = savePanelBin(panelFile, this, true);
152
153 if (getEditor())
154 {
155 if (res.failed())
156 {
157 notify ("Panel save: ["+res.getErrorMessage()+"]", nullptr, NotifyFailure);
158 }
159 else
160 {
161 notify ("Panel saved: ["+panelFile.getFullPathName()+"]", nullptr, NotifySuccess);
162 }
163 }
164 }
165 else
166 {
167 File ret = askForPanelFileToSave (this, File(owner.getProperty(Ids::panelLastSaveDir)).getChildFile(getVersionString()));
168 if (ret != File())
169 {
170 res = savePanelXml(ret, this);
171 setProperty (Ids::panelFilePath, ret.getFullPathName());
172 setProperty (Ids::panelLastSaveDir, ret.getParentDirectory().getFullPathName());
173 }
174 else
175 {
176 res = Result::fail ("Selected file is invalid");
177 }
178
179 if (getEditor())
180 {
181 if (res.failed())
182 {
183 notify ("Panel save: ["+res.getErrorMessage()+"]", nullptr, NotifyFailure);
184 }
185 else
186 {
187 notify ("Panel saved: ["+panelFile.getFullPathName()+"]", nullptr, NotifySuccess);
188 }
189 }

Callers 1

performMethod · 0.80

Calls 13

FileClass · 0.85
getVersionStringFunction · 0.85
setPropertyFunction · 0.85
wasOkMethod · 0.80
getUndoManagerFunction · 0.50
existsAsFileMethod · 0.45
hasWriteAccessMethod · 0.45
hasFileExtensionMethod · 0.45
failedMethod · 0.45
getChildFileMethod · 0.45
getPropertyMethod · 0.45
getParentDirectoryMethod · 0.45

Tested by

no test coverage detected