Add option to clone favorite tools

If cloning is enabled, favorite tools will appear in the favorites panel
and in the original location.
This commit is contained in:
Lawrence Lee
2021-12-09 21:27:39 -08:00
parent acda4da226
commit f8a1deb371
11 changed files with 69 additions and 27 deletions

View File

@@ -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

View File

@@ -2487,10 +2487,10 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition)
}
void EditorPanel::updateToolPanelToolLocations(
const std::vector<Glib::ustring> &favorites)
const std::vector<Glib::ustring> &favorites, bool cloneFavoriteTools)
{
if (tpc) {
tpc->updateToolLocations(favorites);
tpc->updateToolLocations(favorites, cloneFavoriteTools);
}
}

View File

@@ -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<Glib::ustring> &favorites);
void updateToolPanelToolLocations(
const std::vector<Glib::ustring> &favorites, bool cloneFavoriteTools);
void defaultMonitorProfileChanged (const Glib::ustring &profile_name, bool auto_monitor_profile);

View File

@@ -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<Glib::ustring> 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);

View File

@@ -428,6 +428,7 @@ public:
bool fastexport_use_fast_pipeline;
std::vector<Glib::ustring> favorites;
bool cloneFavoriteTools;
// Dialog settings
Glib::ustring lastIccDir;
Glib::ustring lastDarkframeDir;

View File

@@ -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);
}
}

View File

@@ -1111,10 +1111,10 @@ void RTWindow::updateHistogramPosition (int oldPosition, int newPosition)
}
void RTWindow::updateToolPanelToolLocations(
const std::vector<Glib::ustring> &favorites)
const std::vector<Glib::ustring> &favorites, bool cloneFavoriteTools)
{
if (epanel) {
epanel->updateToolPanelToolLocations(favorites);
epanel->updateToolPanelToolLocations(favorites, cloneFavoriteTools);
}
}

View File

@@ -124,7 +124,8 @@ public:
void updateFBQueryTB (bool singleRow);
void updateFBToolBarVisibility (bool showFilmStripToolBar);
void updateShowtooltipVisibility (bool showtooltip);
void updateToolPanelToolLocations(const std::vector<Glib::ustring> &favorites);
void updateToolPanelToolLocations(
const std::vector<Glib::ustring> &favorites, bool cloneFavoriteTools);
bool getIsFullscreen()
{
return is_fullscreen;

View File

@@ -423,6 +423,9 @@ struct ToolLocationPreference::Impl {
Options &options;
// General options.
Gtk::CheckButton *cloneFavoriteToolsToggleWidget;
// Tool list.
ToolListColumns toolListColumns;
Glib::RefPtr<Gtk::TreeStore> toolListModelPtr;
@@ -506,6 +509,10 @@ std::unordered_map<std::string, Tool>
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<Tool> 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<Tool> 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()

View File

@@ -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<Glib::ustring> &favoritesNames)
const std::vector<Glib::ustring> &favoritesNames,
bool cloneFavoriteTools)
{
std::unordered_set<Tool, ScopedEnumHash> favorites_set;
std::vector<std::reference_wrapper<const ToolTree>> 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<Glib::ustring> &favorites)
Gtk::Widget *page,
const std::vector<Glib::ustring> &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 <typename T>
@@ -766,18 +770,21 @@ ToolPanelCoordinator::updateToolPanel(
Gtk::Box *panelBox,
const std::vector<T> &children,
int level,
std::unordered_set<Tool, ScopedEnumHash> favorites)
std::unordered_set<Tool, ScopedEnumHash> favorites,
bool cloneFavoriteTools)
{
const bool is_favorite_panel = panelBox == favoritePanel;
const bool skip_favorites = !cloneFavoriteTools && !is_favorite_panel;
const std::vector<Gtk::Widget *> 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<Glib::ustring> &favorites)
void ToolPanelCoordinator::updateToolLocations(
const std::vector<Glib::ustring> &favorites, bool cloneFavoriteTools)
{
const int fav_page_num = toolPanelNotebook->page_num(*favoritePanelSW);
@@ -1644,7 +1653,7 @@ void ToolPanelCoordinator::updateToolLocations(const std::vector<Glib::ustring>
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);
}

View File

@@ -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<Glib::ustring> &favorites);
Gtk::Widget *page,
const std::vector<Glib::ustring> &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<Glib::ustring> &favorites);
void updateToolLocations(
const std::vector<Glib::ustring> &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<Glib::ustring> &favorites);
void updateFavoritesPanel(
const std::vector<Glib::ustring> &favorites, bool cloneFavoriteTools);
template <typename T>
typename std::enable_if<std::is_convertible<T, const ToolTree>::value, void>::type
updateToolPanel(
Gtk::Box *panelBox,
const std::vector<T> &children,
int level,
std::unordered_set<Tool, ScopedEnumHash> favorites);
std::unordered_set<Tool, ScopedEnumHash> favorites,
bool cloneFavoriteTools);
private:
IdleRegister idle_register;