+ // --------------------- //
+ // START double click view background
+
+ // list of actions allowed to be triggered by double click
+ // actions were selected based on their usefulness of being triggered with the mouse
+ QStringList allowedActions{"new_tab",
+ "file_new",
+ "show_places_panel",
+ "show_information_panel",
+ "show_folders_panel",
+ "show_terminal_panel",
+ "open_terminal",
+ "go_up",
+ "go_back",
+ "go_home",
+ "view_redisplay",
+ "split_view",
+ "edit_select_all",
+ "toggle_selection_mode",
+ "create_dir",
+ "show_preview",
+ "show_hidden_files",
+ "show_in_groups",
+ "view_properties"};
+
+ // create actions combo-box and add actions
+ m_doubleClickViewComboBox = new QComboBox();
+ m_doubleClickViewComboBox->setAccessibleDescription(i18nc("Accessible description for combobox with actions of double click view background setting",
+ "Action to trigger when double clicking view background"));
+ // i18n: Completes the sentence "Double-click triggers [Nothing]".
+ m_doubleClickViewComboBox->addItem(QIcon::fromTheme("empty"), i18nc("@item:inlistbox", "Nothing"), QStringLiteral("none"));
+ m_doubleClickViewComboBox->addItem(QIcon::fromTheme("list-add"), i18nc("@item:inlistbox", "Custom Command"), customCommand);
+ m_doubleClickViewComboBox->insertSeparator(2);
+
+ DolphinMainWindow *mainWindow = static_cast<DolphinMainWindow *>(QApplication::activeWindow());
+ if (mainWindow != nullptr) {
+ KActionCollection *actions = mainWindow->actionCollection();
+ // get the allowed actions from actionCollection and add them to the combobox
+ for (const QString &actionName : allowedActions) {
+ QAction *action = actions->action(actionName);
+ if (action == nullptr) {
+ qCWarning(DolphinDebug) << QStringLiteral("Double click view: action `%1` was not found").arg(actionName);
+ continue;
+ }
+
+ QString actionText = action->text();
+ // remove ampersand used to define the action's shortcut
+ actionText.remove(QLatin1Char('&'));
+ m_doubleClickViewComboBox->addItem(action->icon(), actionText, action->objectName());
+ }
+ }
+ // i18n: This sentence is incomplete because the user can choose an action that is triggered in a combobox that will appear directly after "triggers".
+ // (While using a left-to-right language it will be to the right of "triggers", in a right-to-left layout it will be to the left.)
+ // So please try to keep this translation in a way that it is a complete sentence when reading the content of the combobox as part of the sentence.
+ // There can be many possible actions in the combobox. The default is "Nothing". Other actions are "New Tab", "Create Folder", "Show Hidden Files", …
+ QLabel *doubleClickViewLabel{new QLabel(i18nc("@info", "Double-click triggers"))};
+ QHBoxLayout *doubleClickViewHLayout{new QHBoxLayout()};
+ QWidget *doubleClickViewWidget{new QWidget()};
+ doubleClickViewWidget->setLayout(doubleClickViewHLayout);
+ doubleClickViewHLayout->addWidget(doubleClickViewLabel);
+ doubleClickViewHLayout->setContentsMargins(0, 0, 0, 0);
+ doubleClickViewHLayout->addWidget(m_doubleClickViewComboBox);
+ topLayout->addRow(i18nc("@title:group", "Background: "), doubleClickViewWidget);
+
+ m_doubleClickViewCustomAction = new QLineEdit();
+ m_doubleClickViewCustomAction->setAccessibleDescription(
+ i18nc("Accessible description for custom command text field of double click view background setting",
+ "Enter custom command to trigger when double clicking view background"));
+ m_doubleClickViewCustomAction->setPlaceholderText(i18nc("@info:placeholder for terminal command", "Command…"));
+ topLayout->addRow(QString(), m_doubleClickViewCustomAction);
+
+ m_doubleClickViewCustomActionInfo = new QLabel(i18nc("@label",
+ "Use {path} to get the path of the current folder. "
+ "Example: dolphin {path}"));
+ m_doubleClickViewCustomActionInfo->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
+ m_doubleClickViewCustomActionInfo->setWordWrap(true);
+ m_doubleClickViewCustomActionInfo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ m_doubleClickViewCustomActionInfo->hide();
+ m_doubleClickViewCustomActionInfo->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard
+ | Qt::LinksAccessibleByKeyboard); // for accessibility
+ topLayout->addRow(QString(), m_doubleClickViewCustomActionInfo);
+ // END double click view background
+ // --------------------- //
+