X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/78cffd2979a6ed87e044fcb024cf4fdfc5c7cb3d..a2c9c05de2dfabbb2bb614390c8e03023dad2bd1:/src/selectionmode/bottombarcontentscontainer.cpp diff --git a/src/selectionmode/bottombarcontentscontainer.cpp b/src/selectionmode/bottombarcontentscontainer.cpp index 2c924415a..1634cf4c9 100644 --- a/src/selectionmode/bottombarcontentscontainer.cpp +++ b/src/selectionmode/bottombarcontentscontainer.cpp @@ -157,8 +157,8 @@ void BottomBarContentsContainer::addCopyContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to copy files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort Copying"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Copying"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *copyButton = new QPushButton(this); @@ -176,7 +176,7 @@ void BottomBarContentsContainer::addCopyContents() resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because // it instantly deletes the button and then the other slots won't be called. } - Q_EMIT leaveSelectionModeRequested(); + Q_EMIT selectionModeLeavingRequested(); }); updateMainActionButton(KFileItemList()); m_layout->addWidget(copyButton); @@ -190,8 +190,8 @@ void BottomBarContentsContainer::addCopyLocationContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to copy the location of files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort Copying"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Copying"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *copyLocationButton = new QPushButton(this); @@ -209,8 +209,8 @@ void BottomBarContentsContainer::addCopyToOtherViewContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to copy the location of files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort Copying"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Copying"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *copyToOtherViewButton = new QPushButton(this); @@ -227,8 +227,8 @@ void BottomBarContentsContainer::addCutContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to cut files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort Cutting"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Cutting"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *cutButton = new QPushButton(this); @@ -246,7 +246,7 @@ void BottomBarContentsContainer::addCutContents() resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because // it instantly deletes the button and then the other slots won't be called. } - Q_EMIT leaveSelectionModeRequested(); + Q_EMIT selectionModeLeavingRequested(); }); updateMainActionButton(KFileItemList()); m_layout->addWidget(cutButton); @@ -260,8 +260,8 @@ void BottomBarContentsContainer::addDeleteContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to delete files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *deleteButton = new QPushButton(this); @@ -278,8 +278,8 @@ void BottomBarContentsContainer::addDuplicateContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to duplicate files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort Duplicating"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Duplicating"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *duplicateButton = new QPushButton(this); @@ -291,15 +291,10 @@ void BottomBarContentsContainer::addDuplicateContents() void BottomBarContentsContainer::addGeneralContents() { if (!m_overflowButton) { - m_overflowButton = new QToolButton{this}; - // i18n: This button appears in a bar if there isn't enough horizontal space to fit all the other buttons. - // The small icon-only button opens a menu that contains the actions that didn't fit on the bar. - // Since this is an icon-only button this text will only appear as a tooltip and as accessibility text. - m_overflowButton->setToolTip(i18nc("@action", "More")); - m_overflowButton->setAccessibleName(m_overflowButton->toolTip()); - m_overflowButton->setIcon(QIcon::fromTheme(QStringLiteral("view-more-horizontal-symbolic"))); + // i18n: This button appears in a bar if there isn't enough horizontal space to fit all the other buttons so please keep it short. + // The small button opens a menu that contains the actions that didn't fit on the bar. + m_overflowButton = new QPushButton{QIcon::fromTheme(QStringLiteral("view-more-symbolic")), i18nc("@action keep short", "More"), this}; m_overflowButton->setMenu(new QMenu{m_overflowButton}); - m_overflowButton->setPopupMode(QToolButton::ToolButtonPopupMode::InstantPopup); m_overflowButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding); // Makes sure it has the same height as the labeled buttons. m_layout->addWidget(m_overflowButton); } else { @@ -348,8 +343,8 @@ void BottomBarContentsContainer::addMoveToOtherViewContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to copy the location of files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort Moving"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Moving"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *moveToOtherViewButton = new QPushButton(this); @@ -366,8 +361,8 @@ void BottomBarContentsContainer::addMoveToTrashContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process of moving files to the trash by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Abort"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *moveToTrashButton = new QPushButton(this); @@ -393,7 +388,7 @@ void BottomBarContentsContainer::addPasteContents() * So we first have to claim that we have different contents before requesting to leave selection mode. */ auto actuallyLeaveSelectionMode = [this]() { m_contents = BottomBar::Contents::CopyLocationContents; - Q_EMIT leaveSelectionModeRequested(); + Q_EMIT barVisibilityChangeRequested(false); }; auto *pasteButton = new QPushButton(this); @@ -427,8 +422,8 @@ void BottomBarContentsContainer::addRenameContents() m_layout->addWidget(m_explanatoryLabel); // i18n: Aborts the current step-by-step process to delete files by leaving the selection mode. - auto *cancelButton = new QPushButton(i18nc("@action:button", "Stop Renaming"), this); - connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::leaveSelectionModeRequested); + auto *cancelButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18nc("@action:button", "Cancel Renaming"), this); + connect(cancelButton, &QAbstractButton::clicked, this, &BottomBarContentsContainer::selectionModeLeavingRequested); m_layout->addWidget(cancelButton); auto *renameButton = new QPushButton(this); @@ -503,6 +498,21 @@ std::vector BottomBarContentsContainer::contextActionsFor(const KFile } } } + + auto separator = new QAction(m_internalContextMenu.get()); + separator->setSeparator(true); + contextActions.emplace_back(separator); + + // Add "Invert Selection" and "Select All" at the very end for better usability while in selection mode. + // Design-wise this decision is slightly questionable because the other actions in the bar apply to the selected items while + // the "select" actions apply to the view instead but we decided that there are more benefits than drawbacks to this. + auto invertSelectionAction = m_actionCollection->action(QStringLiteral("invert_selection")); + Q_ASSERT(invertSelectionAction && !internalContextMenuActions.contains(invertSelectionAction)); + contextActions.emplace_back(invertSelectionAction); + auto selectAllAction = m_actionCollection->action(KStandardAction::name(KStandardAction::SelectAll)); + Q_ASSERT(selectAllAction && !internalContextMenuActions.contains(selectAllAction)); + contextActions.emplace_back(selectAllAction); + return contextActions; }