From f44ff6d5854e22526f9a895fa1a02bc61e7e17aa Mon Sep 17 00:00:00 2001 From: Stefan Comanescu Date: Sat, 30 Nov 2019 17:35:03 +0200 Subject: [PATCH] Disable folder selection when selecting bookmark as home page --- src/ui/Menu.cpp | 15 ++++++++++----- .../preferences/PreferencesGeneralPageWidget.cpp | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ui/Menu.cpp b/src/ui/Menu.cpp index 9c71aef7bb..44d31e0131 100644 --- a/src/ui/Menu.cpp +++ b/src/ui/Menu.cpp @@ -692,11 +692,16 @@ void Menu::populateBookmarkSelectorMenu() } const BookmarksModel::Bookmark *folderBookmark(BookmarksManager::getModel()->getBookmark(m_menuOptions.value(QLatin1String("bookmark")).toULongLong())); - Action *addFolderAction(new Action(-1, {}, {{QLatin1String("icon"), QLatin1String("document-open-folder")}, {QLatin1String("text"), QT_TRANSLATE_NOOP("actions", "This Folder")}}, ActionExecutor::Object(), this)); - addFolderAction->setData(folderBookmark->getIdentifier()); - addAction(addFolderAction); - addSeparator(); + const bool supportsFolderSelection = m_menuOptions.value(QLatin1String("supportsFolderSelection"), true).toBool(); + if (supportsFolderSelection) + { + Action *addFolderAction(new Action(-1, {}, {{QLatin1String("icon"), QLatin1String("document-open-folder")}, {QLatin1String("text"), QT_TRANSLATE_NOOP("actions", "This Folder")}}, ActionExecutor::Object(), this)); + addFolderAction->setData(folderBookmark->getIdentifier()); + + addAction(addFolderAction); + addSeparator(); + } for (int i = 0; i < folderBookmark->rowCount(); ++i) { @@ -718,7 +723,7 @@ void Menu::populateBookmarkSelectorMenu() if (type != BookmarksModel::UrlBookmark) { Menu *menu(new Menu(BookmarkSelectorMenu, this)); - menu->setMenuOptions({{QLatin1String("bookmark"), bookmark->getIdentifier()}}); + menu->setMenuOptions({{QLatin1String("bookmark"), bookmark->getIdentifier()}, {QLatin1String("supportsFolderSelection"), supportsFolderSelection}}); action->setMenu(menu); } diff --git a/src/ui/preferences/PreferencesGeneralPageWidget.cpp b/src/ui/preferences/PreferencesGeneralPageWidget.cpp index 1d73b3e4bf..ebee124a89 100644 --- a/src/ui/preferences/PreferencesGeneralPageWidget.cpp +++ b/src/ui/preferences/PreferencesGeneralPageWidget.cpp @@ -54,6 +54,7 @@ PreferencesGeneralPageWidget::PreferencesGeneralPageWidget(QWidget *parent) : QW m_ui->homePageLineEditWidget->setText(SettingsManager::getOption(SettingsManager::Browser_HomePageOption).toString()); Menu *bookmarksMenu(new Menu(Menu::BookmarkSelectorMenu, m_ui->useBookmarkAsHomePageButton)); + bookmarksMenu->setMenuOptions({{QLatin1String("supportsFolderSelection"), false}}); m_ui->useBookmarkAsHomePageButton->setMenu(bookmarksMenu); m_ui->useBookmarkAsHomePageButton->setEnabled(BookmarksManager::getModel()->getRootItem()->rowCount() > 0);