| 130 | } |
| 131 | |
| 132 | Result 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 | } |
no test coverage detected