Save the toolbar states
| 928 | // Save the toolbar states |
| 929 | // |
| 930 | void ToolManager::WriteConfig() |
| 931 | { |
| 932 | if( !gPrefs ) |
| 933 | { |
| 934 | return; |
| 935 | } |
| 936 | |
| 937 | auto toolbarsGroup = gPrefs->BeginGroup("/GUI/ToolBars"); |
| 938 | |
| 939 | // Save state of each bar |
| 940 | ForEach([this](ToolBar *bar){ |
| 941 | // Change to the bar subkey |
| 942 | auto sectionGroup = gPrefs->BeginGroup(bar->GetSection().GET()); |
| 943 | |
| 944 | // Search both docks for toolbar order |
| 945 | bool to = mTopDock->GetConfiguration().Contains( bar ); |
| 946 | bool bo = mBotDock->GetConfiguration().Contains( bar ); |
| 947 | |
| 948 | // Save |
| 949 | // Note that DockV2 was introduced in 2.2.2 to fix bug #1554. Dock is retained so that |
| 950 | // the toolbar layout is not changed when opening a version before 2.2.2, and in particular |
| 951 | // its value is compatible with versions 2.1.3 to 2.2.1 which have this bug. |
| 952 | ToolDock* dock = bar->GetDock(); // dock for both shown and hidden toolbars |
| 953 | gPrefs->Write( wxT("DockV2"), static_cast<int>(dock == mTopDock ? TopDockID : dock == mBotDock ? BotDockID : NoDockID )); |
| 954 | |
| 955 | gPrefs->Write( wxT("Dock"), static_cast<int>( to ? TopDockID : bo ? BotDockID : NoDockID)); |
| 956 | |
| 957 | dock = to ? mTopDock : bo ? mBotDock : nullptr; // dock for shown toolbars |
| 958 | ToolBarConfiguration::Write |
| 959 | (dock ? &dock->GetConfiguration() : nullptr, bar); |
| 960 | |
| 961 | wxPoint pos( -1, -1 ); |
| 962 | wxSize sz = bar->GetSize(); |
| 963 | if( !bar->IsDocked() && bar->IsPositioned() ) |
| 964 | { |
| 965 | pos = bar->GetParent()->GetPosition(); |
| 966 | sz = bar->GetParent()->GetSize(); |
| 967 | } |
| 968 | gPrefs->Write( wxT("X"), pos.x ); |
| 969 | gPrefs->Write( wxT("Y"), pos.y ); |
| 970 | gPrefs->Write( wxT("W"), sz.x ); |
| 971 | gPrefs->Write( wxT("H"), sz.y ); |
| 972 | }); |
| 973 | gPrefs->Flush(); |
| 974 | } |
| 975 | |
| 976 | // |
| 977 | // Return a pointer to the specified toolbar or nullptr |
nothing calls this directly
no test coverage detected