diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 0b1ebe7656..62e347032b 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1687,8 +1687,13 @@ void DolphinMainWindow::setupActions() m_helpMenu = new KHelpMenu(nullptr); m_helpMenu->menu()->installEventFilter(this); // remove duplicate shortcuts - m_helpMenu->action(KHelpMenu::menuHelpContents)->setShortcut(QKeySequence()); - m_helpMenu->action(KHelpMenu::menuWhatsThis)->setShortcut(QKeySequence()); + auto removeHelpActionShortcut = [this](KHelpMenu::MenuId menuId) { + if (auto *action = m_helpMenu->action(menuId)) { + action->setShortcut(QKeySequence()); + } + }; + removeHelpActionShortcut(KHelpMenu::menuHelpContents); + removeHelpActionShortcut(KHelpMenu::menuWhatsThis); // not in menu actions QList nextTabKeys = KStandardShortcut::tabNext(); @@ -2284,6 +2289,18 @@ void DolphinMainWindow::setupWhatsThis() // StandardAction separately because both are used in different locations. // m_helpMenu is only used for createControlButton() button. + auto setStandardActionWhatsThis = [this](KStandardAction::StandardAction actionId, + const QString &whatsThis) { + if (auto *action = actionCollection()->action(KStandardAction::name(actionId))) { + action->setWhatsThis(whatsThis); + } + }; + auto setHelpActionWhatsThis = [this](KHelpMenu::MenuId menuId, const QString &whatsThis) { + if (auto *action = m_helpMenu->action(menuId)) { + action->setWhatsThis(whatsThis); + } + }; + // Links do not work within the Menubar so texts without links are provided there. // i18n: If the external link isn't available in your language you should @@ -2294,13 +2311,12 @@ void DolphinMainWindow::setupWhatsThis() const QString whatsThisHelpContents = xi18nc("@info:whatsthis handbook", "This opens the Handbook for this application. It provides " "explanations for every part of Dolphin."); - actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents)) - ->setWhatsThis(whatsThisHelpContents + setStandardActionWhatsThis(KStandardAction::HelpContents, whatsThisHelpContents + xi18nc("@info:whatsthis second half of handbook hb text without link", "If you want more elaborate introductions to the " "different features of Dolphin " "go to the KDE UserBase Wiki.")); - m_helpMenu->action(KHelpMenu::menuHelpContents)->setWhatsThis(whatsThisHelpContents + setHelpActionWhatsThis(KHelpMenu::menuHelpContents, whatsThisHelpContents + xi18nc("@info:whatsthis second half of handbook text with link", "If you want more elaborate introductions to the " "different features of Dolphin " @@ -2312,8 +2328,7 @@ void DolphinMainWindow::setupWhatsThis() "using right now! Click it, then click any component of this " "application to ask \"What's this?\" about it. The mouse cursor " "will change appearance if no help is available for a spot."); - actionCollection()->action(KStandardAction::name(KStandardAction::WhatsThis)) - ->setWhatsThis(whatsThisWhatsThis + setStandardActionWhatsThis(KStandardAction::WhatsThis, whatsThisWhatsThis + xi18nc("@info:whatsthis second half of whatsthis button text without link", "There are two other ways to get help for this application: The " "Dolphin Handbook in the Help" @@ -2321,7 +2336,7 @@ void DolphinMainWindow::setupWhatsThis() "article about File Management online." "The \"What's this?\" help is " "missing in most other windows so don't get too used to this.")); - m_helpMenu->action(KHelpMenu::menuWhatsThis)->setWhatsThis(whatsThisWhatsThis + setHelpActionWhatsThis(KHelpMenu::menuWhatsThis, whatsThisWhatsThis + xi18nc("@info:whatsthis second half of whatsthis button text with link", "There are two other ways to get help: " "The Dolphin Handbook and " @@ -2332,9 +2347,8 @@ void DolphinMainWindow::setupWhatsThis() const QString whatsThisReportBug = xi18nc("@info:whatsthis","This opens a " "window that will guide you through reporting errors or flaws " "in this application or in other KDE software."); - actionCollection()->action(KStandardAction::name(KStandardAction::ReportBug)) - ->setWhatsThis(whatsThisReportBug); - m_helpMenu->action(KHelpMenu::menuReportBug)->setWhatsThis(whatsThisReportBug + setStandardActionWhatsThis(KStandardAction::ReportBug, whatsThisReportBug); + setHelpActionWhatsThis(KHelpMenu::menuReportBug, whatsThisReportBug + xi18nc("@info:whatsthis second half of reportbug text with link", "High-quality bug reports are much appreciated. To learn " "how to make your bug report as effective as possible " @@ -2351,33 +2365,30 @@ void DolphinMainWindow::setupWhatsThis() "require money like servers, contributor meetings, etc." "KDE e.V. is the non-profit " "organization behind the KDE community."); - actionCollection()->action(KStandardAction::name(KStandardAction::Donate)) - ->setWhatsThis(whatsThisDonate); - m_helpMenu->action(KHelpMenu::menuDonate)->setWhatsThis(whatsThisDonate); + setStandardActionWhatsThis(KStandardAction::Donate, whatsThisDonate); + setHelpActionWhatsThis(KHelpMenu::menuDonate, whatsThisDonate); const QString whatsThisSwitchLanguage = xi18nc("@info:whatsthis", "With this you can change the language this application uses." "You can even set secondary languages which will be used " "if texts are not available in your preferred language."); - actionCollection()->action(KStandardAction::name(KStandardAction::SwitchApplicationLanguage)) - ->setWhatsThis(whatsThisSwitchLanguage); - m_helpMenu->action(KHelpMenu::menuSwitchLanguage)->setWhatsThis(whatsThisSwitchLanguage); + setStandardActionWhatsThis(KStandardAction::SwitchApplicationLanguage, + whatsThisSwitchLanguage); + setHelpActionWhatsThis(KHelpMenu::menuSwitchLanguage, whatsThisSwitchLanguage); const QString whatsThisAboutApp = xi18nc("@info:whatsthis","This opens a " "window that informs you about the version, license, " "used libraries and maintainers of this application."); - actionCollection()->action(KStandardAction::name(KStandardAction::AboutApp)) - ->setWhatsThis(whatsThisAboutApp); - m_helpMenu->action(KHelpMenu::menuAboutApp)->setWhatsThis(whatsThisAboutApp); + setStandardActionWhatsThis(KStandardAction::AboutApp, whatsThisAboutApp); + setHelpActionWhatsThis(KHelpMenu::menuAboutApp, whatsThisAboutApp); const QString whatsThisAboutKDE = xi18nc("@info:whatsthis","This opens a " "window with information about KDE. " "The KDE community are the people behind this free software." "If you like using this application but don't know " "about KDE or want to see a cute dragon have a look!"); - actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE)) - ->setWhatsThis(whatsThisAboutKDE); - m_helpMenu->action(KHelpMenu::menuAboutKDE)->setWhatsThis(whatsThisAboutKDE); + setStandardActionWhatsThis(KStandardAction::AboutKDE, whatsThisAboutKDE); + setHelpActionWhatsThis(KHelpMenu::menuAboutKDE, whatsThisAboutKDE); } bool DolphinMainWindow::addHamburgerMenuToToolbar()