| 1003 | |
| 1004 | |
| 1005 | bool CtrlrPanel::canClose(const bool closePanel) |
| 1006 | { |
| 1007 | bool result = true; |
| 1008 | // Check for modified Lua Code |
| 1009 | CtrlrPanelWindowManager &manager = getWindowManager(); |
| 1010 | if (manager.isCreated(CtrlrPanelWindowManager::LuaMethodEditor)) |
| 1011 | { |
| 1012 | CtrlrChildWindowContent *content = manager.getContent(CtrlrPanelWindowManager::LuaMethodEditor); |
| 1013 | if (content != nullptr) |
| 1014 | { // Move the editor to front |
| 1015 | content->toFront(true); |
| 1016 | if (!content->canCloseWindow()) |
| 1017 | { |
| 1018 | result = false; |
| 1019 | } |
| 1020 | } |
| 1021 | } |
| 1022 | // Check for panel modifications |
| 1023 | if(closePanel && (hasChangedSinceSavePoint() || isPanelDirty())) |
| 1024 | { |
| 1025 | int ret = AlertWindow::showYesNoCancelBox(AlertWindow::QuestionIcon, "Save panel (" + getName() + ")", "There are unsaved changes in this panel. Do you want to save them berfore closing ?", "Save", "Discard", "Cancel"); |
| 1026 | if (ret == 0) |
| 1027 | { // Cancel |
| 1028 | result = false; |
| 1029 | } |
| 1030 | else if (ret == 1) |
| 1031 | { // Save |
| 1032 | savePanel(); |
| 1033 | result = true; |
| 1034 | } |
| 1035 | else |
| 1036 | { // Discard |
| 1037 | result = true; |
| 1038 | } |
| 1039 | } |
| 1040 | return result; |
| 1041 | } |
no test coverage detected