diff --git a/rtdata/languages/default b/rtdata/languages/default index 525fa2d09..bd65781a8 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1901,6 +1901,7 @@ PREFERENCES_THUMBNAIL_INSPECTOR_MODE;Image to show PREFERENCES_THUMBNAIL_INSPECTOR_RAW;Neutral raw rendering PREFERENCES_THUMBNAIL_INSPECTOR_RAW_IF_NO_JPEG_FULLSIZE;Embedded JPEG if fullsize, neutral raw otherwise PREFERENCES_TOOLPANEL_AVAILABLETOOLS;Available Tools +PREFERENCES_TOOLPANEL_CLONE_FAVORITES;Keep favorite tools in original locations PREFERENCES_TOOLPANEL_FAVORITE;Favorite PREFERENCES_TOOLPANEL_FAVORITESPANEL;Favorites Panel PREFERENCES_TOOLPANEL_TOOL;Tool diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 888fc9518..64fa50a6a 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -2487,10 +2487,10 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition) } void EditorPanel::updateToolPanelToolLocations( - const std::vector &favorites) + const std::vector &favorites, bool cloneFavoriteTools) { if (tpc) { - tpc->updateToolLocations(favorites); + tpc->updateToolLocations(favorites, cloneFavoriteTools); } } diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index 0ffe44ace..bb0ecbc89 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -185,7 +185,8 @@ public: void updateProfiles (const Glib::ustring &printerProfile, rtengine::RenderingIntent printerIntent, bool printerBPC); void updateTPVScrollbar (bool hide); void updateHistogramPosition (int oldPosition, int newPosition); - void updateToolPanelToolLocations(const std::vector &favorites); + void updateToolPanelToolLocations( + const std::vector &favorites, bool cloneFavoriteTools); void defaultMonitorProfileChanged (const Glib::ustring &profile_name, bool auto_monitor_profile); diff --git a/rtgui/options.cc b/rtgui/options.cc index 70b0fa010..b5463949a 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -424,6 +424,7 @@ void Options::setDefaults() //crvOpen.clear (); parseExtensions.clear(); favorites.clear(); + cloneFavoriteTools = true; parseExtensionsEnabled.clear(); parsedExtensions.clear(); parsedExtensionsSet.clear(); @@ -1220,6 +1221,10 @@ void Options::readFromFile(Glib::ustring fname) favorites = keyFile.get_string_list("GUI", "Favorites"); } + if (keyFile.has_key("GUI", "FavoritesCloneTools")) { + cloneFavoriteTools = keyFile.get_boolean("GUI", "FavoritesCloneTools"); + } + if (keyFile.has_key("GUI", "WindowWidth")) { windowWidth = keyFile.get_integer("GUI", "WindowWidth"); } @@ -2261,6 +2266,7 @@ void Options::saveToFile(Glib::ustring fname) Glib::ArrayHandle ahfavorites = favorites; keyFile.set_string_list("GUI", "Favorites", ahfavorites); + keyFile.set_boolean("GUI", "FavoritesCloneTools", cloneFavoriteTools); keyFile.set_integer("GUI", "WindowWidth", windowWidth); keyFile.set_integer("GUI", "WindowHeight", windowHeight); keyFile.set_integer("GUI", "WindowX", windowX); diff --git a/rtgui/options.h b/rtgui/options.h index bc5e41c91..6f21d1d76 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -428,6 +428,7 @@ public: bool fastexport_use_fast_pipeline; std::vector favorites; + bool cloneFavoriteTools; // Dialog settings Glib::ustring lastIccDir; Glib::ustring lastDarkframeDir; diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index e67d16015..493f84f5a 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -2572,8 +2572,10 @@ void Preferences::workflowUpdate() parent->updateProfiles (moptions.rtSettings.printerProfile, rtengine::RenderingIntent(moptions.rtSettings.printerIntent), moptions.rtSettings.printerBPC); } - if (moptions.favorites != options.favorites) { - parent->updateToolPanelToolLocations(moptions.favorites); + if (moptions.cloneFavoriteTools != options.cloneFavoriteTools || + moptions.favorites != options.favorites) { + parent->updateToolPanelToolLocations( + moptions.favorites, moptions.cloneFavoriteTools); } } diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 15715a2fd..f3eb658e5 100755 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -1111,10 +1111,10 @@ void RTWindow::updateHistogramPosition (int oldPosition, int newPosition) } void RTWindow::updateToolPanelToolLocations( - const std::vector &favorites) + const std::vector &favorites, bool cloneFavoriteTools) { if (epanel) { - epanel->updateToolPanelToolLocations(favorites); + epanel->updateToolPanelToolLocations(favorites, cloneFavoriteTools); } } diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index d35755185..0ef5abb1f 100755 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -124,7 +124,8 @@ public: void updateFBQueryTB (bool singleRow); void updateFBToolBarVisibility (bool showFilmStripToolBar); void updateShowtooltipVisibility (bool showtooltip); - void updateToolPanelToolLocations(const std::vector &favorites); + void updateToolPanelToolLocations( + const std::vector &favorites, bool cloneFavoriteTools); bool getIsFullscreen() { return is_fullscreen; diff --git a/rtgui/toollocationpref.cc b/rtgui/toollocationpref.cc index 561be4601..849ff29b6 100644 --- a/rtgui/toollocationpref.cc +++ b/rtgui/toollocationpref.cc @@ -423,6 +423,9 @@ struct ToolLocationPreference::Impl { Options &options; + // General options. + Gtk::CheckButton *cloneFavoriteToolsToggleWidget; + // Tool list. ToolListColumns toolListColumns; Glib::RefPtr toolListModelPtr; @@ -506,6 +509,10 @@ std::unordered_map ToolLocationPreference::Impl::Impl(Options &options) : options(options), + // General options. + cloneFavoriteToolsToggleWidget(Gtk::manage( + new Gtk::CheckButton(M("PREFERENCES_TOOLPANEL_CLONE_FAVORITES")))), + // Tool list. toolListModelPtr(Gtk::TreeStore::create(toolListColumns)), toolListViewColumnFavorite( @@ -523,6 +530,9 @@ ToolLocationPreference::Impl::Impl(Options &options) : { const std::vector favorites = toolNamesToTools(options.favorites); + // General options. + cloneFavoriteToolsToggleWidget->set_active(options.cloneFavoriteTools); + // Tool list. toolListViewPtr->append_column(toolListViewColumnToolName); toolListViewColumnToolName.pack_start(toolListCellRendererToolName); @@ -686,6 +696,8 @@ std::vector ToolLocationPreference::Impl::toolNamesToTools( void ToolLocationPreference::Impl::updateOptions() { + options.cloneFavoriteTools = cloneFavoriteToolsToggleWidget->get_active(); + const auto favorites_rows = favoritesModelPtr->children(); options.favorites.resize(favorites_rows.size()); for (unsigned i = 0; i < favorites_rows.size(); i++) { @@ -729,6 +741,10 @@ ToolLocationPreference::ToolLocationPreference(Options &options) : favorites_list_scrolled_window->add(*impl->favoritesViewPtr); setExpandAlignProperties( favorites_frame, false, true, Gtk::ALIGN_START, Gtk::ALIGN_FILL); + + // General options. + layout_grid->attach_next_to( + *impl->cloneFavoriteToolsToggleWidget, Gtk::PositionType::POS_BOTTOM, 2, 1); } void ToolLocationPreference::updateOptions() diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 985fb5461..4991e68d8 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -481,7 +481,7 @@ ToolPanelCoordinator::ToolPanelCoordinator (bool batch) : ipc (nullptr), favorit toolPanelNotebook->set_scrollable(); toolPanelNotebook->show_all(); - updateToolLocations(options.favorites); + updateToolLocations(options.favorites, options.cloneFavoriteTools); notebookconn = toolPanelNotebook->signal_switch_page().connect( sigc::mem_fun(*this, &ToolPanelCoordinator::notebookPageChanged)); @@ -681,7 +681,7 @@ bool ToolPanelCoordinator::isFavoritable(Tool tool) void ToolPanelCoordinator::notebookPageChanged(Gtk::Widget* page, guint page_num) { - updatePanelTools(page, options.favorites); + updatePanelTools(page, options.favorites, options.cloneFavoriteTools); // Locallab spot curves are set visible if at least one photo has been loaded (to avoid // segfault) and locallab panel is active @@ -701,7 +701,8 @@ void ToolPanelCoordinator::notebookPageChanged(Gtk::Widget* page, guint page_num } void ToolPanelCoordinator::updateFavoritesPanel( - const std::vector &favoritesNames) + const std::vector &favoritesNames, + bool cloneFavoriteTools) { std::unordered_set favorites_set; std::vector> favorites_tool_tree; @@ -713,14 +714,17 @@ void ToolPanelCoordinator::updateFavoritesPanel( std::ref(*(toolToDefaultToolTreeMap.at(tool)))); } - updateToolPanel(favoritePanel, favorites_tool_tree, 1, favorites_set); + updateToolPanel( + favoritePanel, favorites_tool_tree, 1, favorites_set, cloneFavoriteTools); } void ToolPanelCoordinator::updatePanelTools( - Gtk::Widget *page, const std::vector &favorites) + Gtk::Widget *page, + const std::vector &favorites, + bool cloneFavoriteTools) { if (page == favoritePanelSW.get()) { - updateFavoritesPanel(favorites); + updateFavoritesPanel(favorites, cloneFavoriteTools); return; } @@ -757,7 +761,7 @@ void ToolPanelCoordinator::updatePanelTools( favoriteTools.insert(getToolFromName(tool_name.raw())); } - updateToolPanel(panel, *default_panel_tools, 1, favoriteTools); + updateToolPanel(panel, *default_panel_tools, 1, favoriteTools, cloneFavoriteTools); } template @@ -766,18 +770,21 @@ ToolPanelCoordinator::updateToolPanel( Gtk::Box *panelBox, const std::vector &children, int level, - std::unordered_set favorites) + std::unordered_set favorites, + bool cloneFavoriteTools) { const bool is_favorite_panel = panelBox == favoritePanel; + const bool skip_favorites = !cloneFavoriteTools && !is_favorite_panel; const std::vector old_tool_panels = panelBox->get_children(); auto old_widgets_iter = old_tool_panels.begin(); auto new_tool_trees_iter = children.begin(); // Indicates if this tool should not be added. Favorite tools are skipped - // unless the parent panel box is the favorites panel. + // if they are sub-tools within the favorites panel, or if tool cloning is + // off and they are not within the favorites panel. const auto should_skip_tool = - [is_favorite_panel, &favorites](const ToolTree &tool_tree) { - return !is_favorite_panel && favorites.count(tool_tree.id); + [skip_favorites, &favorites](const ToolTree &tool_tree) { + return skip_favorites && favorites.count(tool_tree.id); }; // Keep tools that are already correct. @@ -824,7 +831,8 @@ ToolPanelCoordinator::updateToolPanel( tool_panel->getSubToolsContainer(), tool_tree.children, level + 1, - favorites); + favorites, + cloneFavoriteTools && !is_favorite_panel); } } @@ -1623,7 +1631,8 @@ void ToolPanelCoordinator::foldAllButOne(Gtk::Box* parent, FoldableToolPanel* op } } -void ToolPanelCoordinator::updateToolLocations(const std::vector &favorites) +void ToolPanelCoordinator::updateToolLocations( + const std::vector &favorites, bool cloneFavoriteTools) { const int fav_page_num = toolPanelNotebook->page_num(*favoritePanelSW); @@ -1644,7 +1653,7 @@ void ToolPanelCoordinator::updateToolLocations(const std::vector int cur_page_num = toolPanelNotebook->get_current_page(); Gtk::Widget *const cur_page = toolPanelNotebook->get_nth_page(cur_page_num); - updatePanelTools(cur_page, favorites); + updatePanelTools(cur_page, favorites, cloneFavoriteTools); } bool ToolPanelCoordinator::handleShortcutKey(GdkEventKey* event) @@ -1791,7 +1800,7 @@ void ToolPanelCoordinator::toolSelected(ToolMode tool) break; } - updateToolLocations(options.favorites); + updateToolLocations(options.favorites, options.cloneFavoriteTools); notebookconn.block(false); } diff --git a/rtgui/toolpanelcoord.h b/rtgui/toolpanelcoord.h index 3182d3e16..8c0f6beaf 100644 --- a/rtgui/toolpanelcoord.h +++ b/rtgui/toolpanelcoord.h @@ -219,7 +219,9 @@ protected: void addfavoritePanel (Gtk::Box* where, FoldableToolPanel* panel, int level = 1); void notebookPageChanged(Gtk::Widget* page, guint page_num); void updatePanelTools( - Gtk::Widget *page, const std::vector &favorites); + Gtk::Widget *page, + const std::vector &favorites, + bool cloneFavoriteTools); private: EditDataProvider *editDataProvider; @@ -345,7 +347,8 @@ public: const LUTu& histLRETI ); void foldAllButOne(Gtk::Box* parent, FoldableToolPanel* openedSection); - void updateToolLocations(const std::vector &favorites); + void updateToolLocations( + const std::vector &favorites, bool cloneFavoriteTools); // multiple listeners can be added that are notified on changes (typical: profile panel and the history) void addPParamsChangeListener(PParamsChangeListener* pp) @@ -461,14 +464,16 @@ protected: FoldableToolPanel *getFoldableToolPanel(Tool tool) const; FoldableToolPanel *getFoldableToolPanel(const ToolTree &tool) const; - void updateFavoritesPanel(const std::vector &favorites); + void updateFavoritesPanel( + const std::vector &favorites, bool cloneFavoriteTools); template typename std::enable_if::value, void>::type updateToolPanel( Gtk::Box *panelBox, const std::vector &children, int level, - std::unordered_set favorites); + std::unordered_set favorites, + bool cloneFavoriteTools); private: IdleRegister idle_register;