| 1657 | } |
| 1658 | |
| 1659 | bool AppFrame::actionOnMenuLoadSave(wxCommandEvent& event) { |
| 1660 | |
| 1661 | if (event.GetId() == wxID_SAVE) { |
| 1662 | |
| 1663 | if (!currentSessionFile.empty()) { |
| 1664 | saveSession(currentSessionFile); |
| 1665 | } |
| 1666 | else { |
| 1667 | wxFileDialog saveFileDialog(this, _("Save XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); |
| 1668 | if (saveFileDialog.ShowModal() == wxID_CANCEL) { |
| 1669 | return true; |
| 1670 | } |
| 1671 | saveSession(saveFileDialog.GetPath().ToStdString()); |
| 1672 | } |
| 1673 | |
| 1674 | return true; |
| 1675 | } |
| 1676 | else if (event.GetId() == wxID_OPEN) { |
| 1677 | wxFileDialog openFileDialog(this, _("Open XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_OPEN | wxFD_FILE_MUST_EXIST); |
| 1678 | if (openFileDialog.ShowModal() == wxID_CANCEL) { |
| 1679 | return true; |
| 1680 | } |
| 1681 | loadSession(openFileDialog.GetPath().ToStdString()); |
| 1682 | |
| 1683 | return true; |
| 1684 | } |
| 1685 | else if (event.GetId() == wxID_SAVEAS) { |
| 1686 | wxFileDialog saveFileDialog(this, _("Save XML Session file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); |
| 1687 | if (saveFileDialog.ShowModal() == wxID_CANCEL) { |
| 1688 | return true; |
| 1689 | } |
| 1690 | saveSession(saveFileDialog.GetPath().ToStdString()); |
| 1691 | |
| 1692 | return true; |
| 1693 | } |
| 1694 | |
| 1695 | //save mecanic for bookmark files |
| 1696 | else if (event.GetId() == wxID_SAVE_BOOKMARKS) { |
| 1697 | |
| 1698 | if (!currentBookmarkFile.empty()) { |
| 1699 | wxGetApp().getBookmarkMgr().saveToFile(currentBookmarkFile, false, true); |
| 1700 | } |
| 1701 | else { |
| 1702 | wxFileDialog saveFileDialog(this, _("Save XML Bookmark file"), "", "", "XML files (*.xml)|*.xml", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); |
| 1703 | if (saveFileDialog.ShowModal() == wxID_CANCEL) { |
| 1704 | return true; |
| 1705 | } |
| 1706 | |
| 1707 | // Make sure the file name actually ends in .xml |
| 1708 | std::string fileName = saveFileDialog.GetPath().ToStdString(); |
| 1709 | std::string lcFileName = fileName; |
| 1710 | |
| 1711 | std::transform(lcFileName.begin(), lcFileName.end(), lcFileName.begin(), ::tolower); |
| 1712 | |
| 1713 | if (lcFileName.find_last_of(".xml") != lcFileName.length() - 1) { |
| 1714 | fileName.append(".xml"); |
| 1715 | } |
| 1716 |
nothing calls this directly
no test coverage detected