<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2023 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2023-2024 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
<item>
<widget class="QRadioButton" name="currentFolderIconRadioButton">
<property name="text">
- <string>Default folder icon</string>
+ <string>Current folder icon</string>
</property>
<property name="checked">
</widget>
</item>
- <!-- Second row, current website favorite icon. -->
+ <!-- Second row, current folder icon. -->
+ <item>
+ <widget class="QRadioButton" name="defaultFolderIconRadioButton">
+ <property name="text">
+ <string>Default folder icon</string>
+ </property>
+
+ <property name="icon">
+ <iconset theme="folder"/>
+ </property>
+
+ <property name="iconSize">
+ <size>
+ <height>32</height>
+ <width>32</width>
+ </size>
+ </property>
+ </widget>
+ </item>
+
+ <!-- Third row, current website favorite icon. -->
<item>
<widget class="QRadioButton" name="currentWebsiteFavoriteIconRadioButton">
<property name="text">
</widget>
</item>
- <!-- Third row, custom folder icon. -->
+ <!-- Fourth row, custom folder icon. -->
<item>
<widget class="QRadioButton" name="customFolderIconRadioButton">
<property name="text">
// Add a separator to the bookmarks menu.
bookmarksMenuPointer->addSeparator();
- // Initialize the current bookmarks lists.
- finalBookmarkFolderMenuActionList = QList<QPair<QMenu *, QAction *> *>();
+ // Initialize the bookmark action lists.
+ bookmarkFolderFinalActionList = QList<QPair<QMenu *, QAction *> *>();
bookmarksMenuActionList = QList<QPair<QMenu *, QAction *> *>();
bookmarksMenuSubmenuList = QList<QPair<QMenu *, QMenu *> *>();
bookmarksToolBarActionList = QList<QAction*>();
- bookmarksToolBarSubfolderActionList = QList<QPair<QMenu *, QAction * > *>();
+ bookmarksToolBarSubfolderActionList = QList<QPair<QMenu *, QAction *> *>();
// Set the bookmarks toolbar context menu policy.
bookmarksToolBarPointer->setContextMenuPolicy(Qt::CustomContextMenu);
}
}
-void BrowserWindow::addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double folderId)
+// If actions are part of a context menu they do not need to be added to the list as they will be deleted automatically when the context menu closes.
+void BrowserWindow::addBookmarkFolderFinalActions(QMenu *menuPointer, const double folderId, const bool addToList)
{
// Get the database ID.
int folderDatabaseId = BookmarksDatabase::getFolderDatabaseId(folderId);
}
);
- // Add the action to the beginning of the final bookmark folder menu action list.
- finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, editFolderActionPointer));
+ // Add the action to the beginning of the bookmark folder final action list if requsted.
+ if (addToList)
+ bookmarkFolderFinalActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, editFolderActionPointer));
}
// Add the delete folder action to the menu.
actionCollectionPointer->setDefaultShortcut(addFolderActionPointer, metaFKeySequence);
}
- // Add the actions to the beginning of the final bookmark folder menu action list.
- finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, addBookmarkActionPointer));
- finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, addFolderActionPointer));
- finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, openFolderInNewTabsActionPointer));
- finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, openFolderInBackgroundTabsActionPointer));
- finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, openFolderInNewWindowActionPointer));
- finalBookmarkFolderMenuActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, deleteFolderActionPointer));
+ // Add the actions to the beginning of the bookmark folder final action list if requested.
+ if (addToList) {
+ bookmarkFolderFinalActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, addBookmarkActionPointer));
+ bookmarkFolderFinalActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, addFolderActionPointer));
+ bookmarkFolderFinalActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, openFolderInNewTabsActionPointer));
+ bookmarkFolderFinalActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, openFolderInBackgroundTabsActionPointer));
+ bookmarkFolderFinalActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, openFolderInNewWindowActionPointer));
+ bookmarkFolderFinalActionList.prepend(new QPair<QMenu *, QAction *>(menuPointer, deleteFolderActionPointer));
+ }
}
void BrowserWindow::addOrEditDomainSettings()
void BrowserWindow::populateBookmarksInThisWindow()
{
// Remove all the final bookmark folder menu actions.
- for (QPair<QMenu *, QAction *> *finalBookmarkFolderMenuActionPair : finalBookmarkFolderMenuActionList)
+ for (QPair<QMenu *, QAction *> *bookmarkFolderFinalActionPairPointer : bookmarkFolderFinalActionList)
{
// Remove the action.
- finalBookmarkFolderMenuActionPair->first->removeAction(finalBookmarkFolderMenuActionPair->second);
+ bookmarkFolderFinalActionPairPointer->first->removeAction(bookmarkFolderFinalActionPairPointer->second);
}
// Remove all the current menu bookmarks.
bookmarksToolBarPointer->removeAction(bookmarkAction);
}
- // Clear the current bookmark lists.
+ // Clear the action lists.
+ bookmarkFolderFinalActionList.clear();
bookmarksMenuActionList.clear();
bookmarksMenuSubmenuList.clear();
- bookmarksToolBarActionList.clear();
bookmarksToolBarSubfolderActionList.clear();
+ bookmarksToolBarActionList.clear();
// Populate the bookmarks subfolders, beginning with the root folder (`0`);
populateBookmarksMenuSubfolders(0, bookmarksMenuPointer);
}
}
- // Add the extra items at the bottom of the menu.
- addFinalBookmarkFolderMenuActions(menuPointer, folderId);
+ // Add the extra items at the bottom of the menu. `true` adds them to the list of actions to be deleted on repopulate.
+ addBookmarkFolderFinalActions(menuPointer, folderId, true);
}
void BrowserWindow::populateBookmarksToolBar()
// Add the extra items to the toolbar folder menus. The first item in the pair is the menu pointer. The second is the folder ID.
for (QPair<QMenu *, const double> *menuAndFolderIdPairPointer : bookmarksToolBarMenuList)
{
- // Populate the final bookmarks menu entries.
- addFinalBookmarkFolderMenuActions(menuAndFolderIdPairPointer->first, menuAndFolderIdPairPointer->second);
+ // Populate the final bookmarks menu entries. `true` adds them to the list of actions to be deleted on repopulate.
+ addBookmarkFolderFinalActions(menuAndFolderIdPairPointer->first, menuAndFolderIdPairPointer->second, true);
}
}
// Create the menu according to the type.
if (BookmarksDatabase::isFolder(databaseId)) // A folder was clicked.
{
- // Populate the final bookmarks menu entries.
- addFinalBookmarkFolderMenuActions(bookmarkContextMenuPointer, BookmarksDatabase::getFolderId(databaseId));
+ // Populate the final bookmarks menu entries. `false` does not add the actions to the delete list, as they will be automatically deleted when the menu closes.
+ addBookmarkFolderFinalActions(bookmarkContextMenuPointer, BookmarksDatabase::getFolderId(databaseId), false);
}
else // A bookmark was clicked.
{
// The private variables.
KActionCollection *actionCollectionPointer;
QAction *bookmarkedActionPointer;
+ QList<QPair<QMenu *, QAction *> *> bookmarkFolderFinalActionList;
QList<QPair<QMenu *, QAction *> *> bookmarksMenuActionList;
QMenu *bookmarksMenuPointer;
QList<QPair<QMenu *, QMenu *> *> bookmarksMenuSubmenuList;
double defaultZoomFactorDouble;
QAction *developerToolsActionPointer;
QAction *domStorageActionPointer;
- QList<QPair<QMenu *, QAction *> *> finalBookmarkFolderMenuActionList;
QAction *findCaseSensitiveActionPointer;
QAction *findNextActionPointer;
QAction *findPreviousActionPointer;
QPushButton *zoomPlusButtonPointer;
// The private functions.
- void addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double folderId);
+ void addBookmarkFolderFinalActions(QMenu *menuPointer, const double folderId, const bool addToList);
int calculateSettingsInt(const bool settingCurrentlyEnabled, const bool settingEnabledByDefault) const;
void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
void populateBookmarksToolBar();