Menu

#537 activate 'Save everything' btn when no project opened

Undefined
fixed
UI (54)
Feature_Request
2017-10-19
2017-08-02
Jannick
No

CB with no project opened: menu item File > 'Save everything' shoud be active if this remains the only option to the user to save config changes made when no project is opened.

Alternatively, a differenct menu item could be created to save config changes.

Related

Tickets: #531

Discussion

  • ollydbg

    ollydbg - 2017-08-03

    This is done by the following code snippet:

        EVT_UPDATE_UI(idFileSaveAll,                MainFrame::OnProjectMenuUpdateUI)
    

    Then this is updated here:

    void MainFrame::OnProjectMenuUpdateUI(wxUpdateUIEvent& event)
    {
        if (Manager::IsAppShuttingDown())
        {
            event.Skip();
            return;
        }
    
        cbProject* prj = Manager::Get()->GetProjectManager() ? Manager::Get()->GetProjectManager()->GetActiveProject() : nullptr;
        wxMenuBar* mbar = GetMenuBar();
    
        bool canCloseProject = (ProjectManager::CanShutdown() && EditorManager::CanShutdown());
    
        mbar->Enable(idFileCloseProject,           prj && canCloseProject);
        mbar->Enable(idFileCloseAllProjects,       prj && canCloseProject);
        mbar->Enable(idFileSaveProject,            prj && prj->GetModified() && canCloseProject);
        mbar->Enable(idFileSaveProjectAs,          prj && canCloseProject);
        mbar->Enable(idFileSaveProjectAllProjects, prj && canCloseProject);
        mbar->Enable(idFileSaveProjectTemplate,    prj && canCloseProject);
    
        event.Skip();
    }
    

    The logic is not correct, since user may need to save configure file.

    The related ticket is here: [tickets:#531] [default.conf] config changes lost after crash

     

    Related

    Tickets: #531

  • ollydbg

    ollydbg - 2017-09-09

    I looked it again today, it looks like my previous comment is not correct, we have to do this in this code snippet:

    void MainFrame::OnFileMenuUpdateUI(wxUpdateUIEvent& event)
    {
        if (Manager::IsAppShuttingDown())
        {
            event.Skip();
            return;
        }
    
        EditorBase*  ed   = Manager::Get()->GetEditorManager() ? Manager::Get()->GetEditorManager()->GetActiveEditor() : nullptr;
        cbProject*   prj  = Manager::Get()->GetProjectManager() ? Manager::Get()->GetProjectManager()->GetActiveProject() : nullptr;
        EditorBase*  sh   = Manager::Get()->GetEditorManager()->GetEditor(g_StartHereTitle);
        cbWorkspace* wksp = Manager::Get()->GetProjectManager()->GetWorkspace();
        wxMenuBar*   mbar = GetMenuBar();
    
        bool canCloseProject = (ProjectManager::CanShutdown() && EditorManager::CanShutdown())
                                && prj && !prj->GetCurrentlyCompilingTarget();
        bool canClose        = ed && !(sh && Manager::Get()->GetEditorManager()->GetEditorsCount() == 1);
        bool canSaveFiles    = ed && !(sh && Manager::Get()->GetEditorManager()->GetEditorsCount() == 1);
        bool canSaveAll      =     (prj && prj->GetModified())
                                || (wksp && !wksp->IsDefault() && wksp->GetModified())
                                || canSaveFiles;
    
        mbar->Enable(idFileCloseProject,                  canCloseProject);
        mbar->Enable(idFileOpenRecentFileClearHistory,    !m_filesHistory.Empty());
        mbar->Enable(idFileOpenRecentProjectClearHistory, !m_projectsHistory.Empty());
        mbar->Enable(idFileClose,                         canClose);
        mbar->Enable(idFileCloseAll,                      canClose);
        mbar->Enable(idFileSave,                          ed && ed->GetModified());
        mbar->Enable(idFileSaveAs,                        canSaveFiles);
        mbar->Enable(idFileSaveAllFiles,                  canSaveFiles);
        mbar->Enable(idFileSaveProject,                   prj && prj->GetModified() && canCloseProject);
        mbar->Enable(idFileSaveProjectAs,                 prj && canCloseProject);
        mbar->Enable(idFileOpenDefWorkspace,              canCloseProject);
        mbar->Enable(idFileSaveWorkspace,                 Manager::Get()->GetProjectManager() && canCloseProject);
        mbar->Enable(idFileSaveWorkspaceAs,               Manager::Get()->GetProjectManager() && canCloseProject);
        mbar->Enable(idFileCloseWorkspace,                Manager::Get()->GetProjectManager() && canCloseProject);
        mbar->Enable(idFileSaveAll,                       canSaveAll);
        mbar->Enable(idFilePrint,                         Manager::Get()->GetEditorManager() && Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor());
    
        if (m_pToolbar)
        {
            m_pToolbar->EnableTool(idFileSave,         ed && ed->GetModified());
            m_pToolbar->EnableTool(idFileSaveAllFiles, canSaveFiles);
            m_pToolbar->EnableTool(idFileSaveAll,      canSaveAll);
            m_pToolbar->EnableTool(idFilePrint,        Manager::Get()->GetEditorManager() && Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor());
        }
    
        event.Skip();
    }
    

    The menu item and toolbar item has the same id named "idFileSaveAll", so we can let it be true.

    Current way, it was:

        bool canSaveAll      =     (prj && prj->GetModified())
                                || (wksp && !wksp->IsDefault() && wksp->GetModified())
                                || canSaveFiles;
    

    So, this value could be always true?

    Otherwise, we have to add a new menu item which like "idFileSaveConfigure".

     
  • Teodor Petrov

    Teodor Petrov - 2017-10-19
    • status: open --> fixed
    • assigned_to: Teodor Petrov
     
  • Teodor Petrov

    Teodor Petrov - 2017-10-19

    Fixed in rev11203.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.