#include "selectionmode/actiontexthelper.h"
#include "settings/viewpropertiesdialog.h"
#include "views/zoomlevelinfo.h"
+#include "views/zoomwidgetaction.h"
#if HAVE_BALOO
#include <Baloo/IndexerConfig>
connect(view, &DolphinView::sortRoleChanged, this, &DolphinViewActionHandler::slotSortRoleChanged);
connect(view, &DolphinView::zoomLevelChanged, this, &DolphinViewActionHandler::slotZoomLevelChanged);
connect(view, &DolphinView::writeStateChanged, this, &DolphinViewActionHandler::slotWriteStateChanged);
+ slotWriteStateChanged(view->isFolderWritable());
connect(view, &DolphinView::selectionModeChangeRequested, this, [this](bool enabled) {
Q_EMIT selectionModeChangeTriggered(enabled);
});
// This action doesn't appear in the GUI, it's for the shortcut only.
// KNewFileMenu takes care of the GUI stuff.
QAction *newDirAction = m_actionCollection->addAction(QStringLiteral("create_dir"));
- newDirAction->setText(i18nc("@action", "Create Folder..."));
+ newDirAction->setText(i18nc("@action", "Create Folder…"));
m_actionCollection->setDefaultShortcuts(newDirAction, KStandardShortcut::createFolder());
newDirAction->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
newDirAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
connect(newDirAction, &QAction::triggered, this, &DolphinViewActionHandler::createDirectoryTriggered);
+ QAction *newFileAction = m_actionCollection->addAction(QStringLiteral("create_file"));
+ newFileAction->setText(i18nc("@action", "Create File…"));
+ newFileAction->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
+ newFileAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
+ connect(newFileAction, &QAction::triggered, this, &DolphinViewActionHandler::createFileTriggered);
+
// File menu
auto renameAction = KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection);
renameAction->setWhatsThis(xi18nc("@info:whatsthis",
"This renames the "
"items in your current selection.<nl/>Renaming multiple items "
- "at once amounts to their new names differing only in a number."));
+ "at once results in their new names differing only in a number."));
auto trashAction = KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection);
auto trashShortcuts = trashAction->shortcuts();
trashAction->setWhatsThis(xi18nc("@info:whatsthis",
"This moves the "
"items in your current selection to the <filename>Trash"
- "</filename>.<nl/>The trash is a temporary storage where "
- "items can be deleted from if disk space is needed."));
+ "</filename>.<nl/>The trash is a temporary storage location where "
+ "items can be deleted later if disk space is needed."));
auto deleteAction = KStandardAction::deleteFile(this, &DolphinViewActionHandler::slotDeleteItems, m_actionCollection);
auto deleteShortcuts = deleteAction->shortcuts();
}
deleteAction->setWhatsThis(xi18nc("@info:whatsthis",
"This deletes "
- "the items in your current selection completely. They can "
- "not be recovered by normal means."));
+ "the items in your current selection permanently. They "
+ "cannot be recovered by normal means."));
// This action is useful for being enabled when KStandardAction::MoveToTrash should be
// disabled and KStandardAction::DeleteFile is enabled (e.g. non-local files), so that Key_Del
compactAction->setWhatsThis(xi18nc("@info:whatsthis Compact view mode",
"<para>This switches to a compact view mode that lists the folders "
"and files in columns with the names beside the icons.</para><para>"
- "This helps to keep the overview in folders with many items.</para>"));
+ "This helps to give you an overview in folders with many items.</para>"));
detailsAction->setWhatsThis(xi18nc("@info:whatsthis Details view mode",
"<para>This switches to a list view mode that focuses on folder "
"and file details.</para><para>Click on a detail in the column "
"way around. To select which details should be displayed click "
"the header with the right mouse button.</para><para>You can "
"view the contents of a folder without leaving the current "
- "location by clicking to the left of it. This way you can view "
- "the contents of multiple folders in the same list.</para>"));
+ "location by clicking the region to the left of it. This way you can "
+ "view the contents of multiple folders in the same list.</para>"));
KSelectAction *viewModeActions = m_actionCollection->add<KSelectAction>(QStringLiteral("view_mode"));
- viewModeActions->setText(i18nc("@action:intoolbar", "View Mode"));
+ viewModeActions->setText(i18nc("@action:intoolbar", "Change View Mode"));
+ viewModeActions->setWhatsThis(xi18nc("@info:whatsthis View Mode Toolbutton", "This cycles through all view modes."));
viewModeActions->addAction(iconsAction);
viewModeActions->addAction(compactAction);
viewModeActions->addAction(detailsAction);
viewModeActions->setToolBarMode(KSelectAction::MenuMode);
- connect(viewModeActions, &KSelectAction::triggered, this, &DolphinViewActionHandler::slotViewModeActionTriggered);
+ viewModeActions->setToolButtonPopupMode(QToolButton::ToolButtonPopupMode::MenuButtonPopup);
+ connect(viewModeActions, &KSelectAction::actionTriggered, this, &DolphinViewActionHandler::slotViewModeActionTriggered);
+ connect(viewModeActions, &KSelectAction::triggered, this, [this, viewModeActions, iconsAction, compactAction, detailsAction]() {
+ // Loop through the actions when button is clicked
+ const auto currentAction = viewModeActions->currentAction();
+ if (currentAction == iconsAction) {
+ slotViewModeActionTriggered(compactAction);
+ } else if (currentAction == compactAction) {
+ slotViewModeActionTriggered(detailsAction);
+ } else if (currentAction == detailsAction) {
+ slotViewModeActionTriggered(iconsAction);
+ }
+ });
QAction *zoomInAction = KStandardAction::zoomIn(this, &DolphinViewActionHandler::zoomIn, m_actionCollection);
zoomInAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This increases the icon size."));
QAction *zoomOutAction = KStandardAction::zoomOut(this, &DolphinViewActionHandler::zoomOut, m_actionCollection);
zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom out", "This reduces the icon size."));
- KActionMenu *zoomMenu = m_actionCollection->add<KActionMenu>(QStringLiteral("zoom"));
- zoomMenu->setText(i18nc("@action:inmenu menu of zoom actions", "Zoom"));
- zoomMenu->setIcon(QIcon::fromTheme(QStringLiteral("zoom")));
- zoomMenu->setPopupMode(QToolButton::InstantPopup);
- zoomMenu->addAction(zoomInAction);
- zoomMenu->addAction(zoomResetAction);
- zoomMenu->addAction(zoomOutAction);
+ ZoomWidgetAction *zoomWidgetAction = new ZoomWidgetAction(zoomInAction, zoomResetAction, zoomOutAction, m_actionCollection);
+ m_actionCollection->addAction(QStringLiteral("zoom"), zoomWidgetAction);
KToggleAction *showPreview = m_actionCollection->add<KToggleAction>(QStringLiteral("show_preview"));
showPreview->setText(i18nc("@action:intoolbar", "Show Previews"));
"contents.<nl/>For example the icons of images become scaled "
"down versions of the images."));
showPreview->setIcon(QIcon::fromTheme(QStringLiteral("view-preview")));
+ m_actionCollection->setDefaultShortcut(showPreview, QKeySequence(Qt::Key_F12));
connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview);
KToggleAction *sortFoldersFirst = m_actionCollection->add<KToggleAction>(QStringLiteral("folders_first"));
showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
showHiddenFiles->setWhatsThis(xi18nc("@info:whatsthis",
"<para>When "
- "this is enabled <emphasis>hidden</emphasis> files and folders "
+ "this is enabled, <emphasis>hidden</emphasis> files and folders "
"are visible. They will be displayed semi-transparent.</para>"
- "<para>Hidden items only differ from other ones in that their "
- "name starts with a \".\". In general there is no need for "
- "users to access them which is why they are hidden.</para>"));
+ "<para>Hidden items only differ from normal ones in that their "
+ "name starts with a dot (\".\"). Typically, there is no need for "
+ "users to access them, which is why they are hidden.</para>"
+ "<para>Items can also be hidden if their names are listed in a text file "
+ "named \".hidden\". Files with the \"application/x-trash\" MIME type, "
+ "such as backup files, can also be hidden by enabling that setting in "
+ "Configure Dolphin > View > General.</para>"));
m_actionCollection->setDefaultShortcuts(showHiddenFiles, KStandardShortcut::showHideHiddenFiles());
connect(showHiddenFiles, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleShowHiddenFiles);
QAction *adjustViewProps = m_actionCollection->addAction(QStringLiteral("view_properties"));
- adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Display Style..."));
+ adjustViewProps->setText(i18nc("@action:inmenu View", "Adjust View Display Style…"));
adjustViewProps->setIcon(QIcon::fromTheme(QStringLiteral("view-choose")));
adjustViewProps->setWhatsThis(i18nc("@info:whatsthis",
"This opens a window "
"in which all folder view properties can be adjusted."));
connect(adjustViewProps, &QAction::triggered, this, &DolphinViewActionHandler::slotAdjustViewProperties);
+
+ // View settings: the dropdown menu contains various view-related actions
+ KActionMenu *viewSettings = m_actionCollection->add<KActionMenu>(QStringLiteral("view_settings"));
+ viewSettings->setText(i18nc("@action:intoolbar", "View Settings"));
+ viewSettings->setWhatsThis(
+ xi18nc("@info:whatsthis View Settings Toolbutton", "This cycles through all view modes. The dropdown menu contains various view-related actions."));
+ const auto actions = viewModeActions->actions();
+ for (QAction *action : actions) {
+ viewSettings->addAction(action);
+ }
+ viewSettings->addSeparator();
+ viewSettings->addAction(zoomWidgetAction);
+ viewSettings->addAction(sortByActionMenu);
+ viewSettings->addAction(visibleRolesMenu);
+ viewSettings->addAction(showPreview);
+ viewSettings->addAction(showInGroups);
+ viewSettings->addAction(showHiddenFiles);
+ viewSettings->addAction(adjustViewProps);
+ viewSettings->setPopupMode(QToolButton::ToolButtonPopupMode::MenuButtonPopup);
+ connect(viewSettings, &KActionMenu::triggered, viewModeActions, &KSelectAction::triggered);
}
QActionGroup *DolphinViewActionHandler::createFileItemRolesActionGroup(const QString &groupPrefix)
QAction *viewModeMenu = m_actionCollection->action(QStringLiteral("view_mode"));
viewModeMenu->setIcon(action->icon());
+
+ QAction *viewSettingsAction = m_actionCollection->action(QStringLiteral("view_settings"));
+ viewSettingsAction->setIcon(action->icon());
}
void DolphinViewActionHandler::slotRename()
QAction *viewModeMenu = m_actionCollection->action(QStringLiteral("view_mode"));
viewModeMenu->setIcon(viewModeAction->icon());
+
+ QAction *viewSettingsAction = m_actionCollection->action(QStringLiteral("view_settings"));
+ viewSettingsAction->setIcon(viewModeAction->icon());
}
QAction *showPreviewAction = m_actionCollection->action(QStringLiteral("show_preview"));
void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable)
{
- m_actionCollection->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable && KProtocolManager::supportsMakeDir(currentView()->url()));
+ const bool supportsMakeDir = KProtocolManager::supportsMakeDir(currentView()->url());
+ m_actionCollection->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable && supportsMakeDir);
+ m_actionCollection->action(QStringLiteral("create_file"))->setEnabled(isFolderWritable);
}
KToggleAction *DolphinViewActionHandler::iconsModeAction()
// actions and the sub-menu-actions. If an action gets checked, it must
// be assured that all other actions get unchecked, except the ascending/
// descending actions
- for (QAction *groupAction : qAsConst(m_sortByActions)) {
+ for (QAction *groupAction : std::as_const(m_sortByActions)) {
KActionMenu *actionMenu = qobject_cast<KActionMenu *>(groupAction);
if (actionMenu) {
const auto actions = actionMenu->menu()->actions();
}
}
}
+
+#include "moc_dolphinviewactionhandler.cpp"