Changeset View
Changeset View
Standalone View
Standalone View
src/views/dolphinviewactionhandler.cpp
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 53 | { | |||
---|---|---|---|---|---|
62 | connect(view, &DolphinView::modeChanged, | 62 | connect(view, &DolphinView::modeChanged, | ||
63 | this, &DolphinViewActionHandler::updateViewActions); | 63 | this, &DolphinViewActionHandler::updateViewActions); | ||
64 | connect(view, &DolphinView::previewsShownChanged, | 64 | connect(view, &DolphinView::previewsShownChanged, | ||
65 | this, &DolphinViewActionHandler::slotPreviewsShownChanged); | 65 | this, &DolphinViewActionHandler::slotPreviewsShownChanged); | ||
66 | connect(view, &DolphinView::sortOrderChanged, | 66 | connect(view, &DolphinView::sortOrderChanged, | ||
67 | this, &DolphinViewActionHandler::slotSortOrderChanged); | 67 | this, &DolphinViewActionHandler::slotSortOrderChanged); | ||
68 | connect(view, &DolphinView::sortFoldersFirstChanged, | 68 | connect(view, &DolphinView::sortFoldersFirstChanged, | ||
69 | this, &DolphinViewActionHandler::slotSortFoldersFirstChanged); | 69 | this, &DolphinViewActionHandler::slotSortFoldersFirstChanged); | ||
70 | connect(view, &DolphinView::sortHiddenLastChanged, | ||||
71 | this, &DolphinViewActionHandler::slotSortHiddenLastChanged); | ||||
70 | connect(view, &DolphinView::visibleRolesChanged, | 72 | connect(view, &DolphinView::visibleRolesChanged, | ||
71 | this, &DolphinViewActionHandler::slotVisibleRolesChanged); | 73 | this, &DolphinViewActionHandler::slotVisibleRolesChanged); | ||
72 | connect(view, &DolphinView::groupedSortingChanged, | 74 | connect(view, &DolphinView::groupedSortingChanged, | ||
73 | this, &DolphinViewActionHandler::slotGroupedSortingChanged); | 75 | this, &DolphinViewActionHandler::slotGroupedSortingChanged); | ||
74 | connect(view, &DolphinView::hiddenFilesShownChanged, | 76 | connect(view, &DolphinView::hiddenFilesShownChanged, | ||
75 | this, &DolphinViewActionHandler::slotHiddenFilesShownChanged); | 77 | this, &DolphinViewActionHandler::slotHiddenFilesShownChanged); | ||
76 | connect(view, &DolphinView::sortRoleChanged, | 78 | connect(view, &DolphinView::sortRoleChanged, | ||
77 | this, &DolphinViewActionHandler::slotSortRoleChanged); | 79 | this, &DolphinViewActionHandler::slotSortRoleChanged); | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 216 | showPreview->setWhatsThis(xi18nc("@info:whatsthis", "When this is " | |||
217 | "down versions of the images.")); | 219 | "down versions of the images.")); | ||
218 | showPreview->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | 220 | showPreview->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | ||
219 | connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview); | 221 | connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview); | ||
220 | 222 | | |||
221 | KToggleAction* sortFoldersFirst = m_actionCollection->add<KToggleAction>(QStringLiteral("folders_first")); | 223 | KToggleAction* sortFoldersFirst = m_actionCollection->add<KToggleAction>(QStringLiteral("folders_first")); | ||
222 | sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First")); | 224 | sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First")); | ||
223 | connect(sortFoldersFirst, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortFoldersFirst); | 225 | connect(sortFoldersFirst, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortFoldersFirst); | ||
224 | 226 | | |||
227 | KToggleAction* sortHiddenLast = m_actionCollection->add<KToggleAction>(QStringLiteral("hidden_last")); | ||||
228 | sortHiddenLast->setText(i18nc("@action:inmenu Sort", "Hidden Last")); | ||||
229 | connect(sortHiddenLast, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortHiddenLast); | ||||
230 | | ||||
225 | // View -> Sort By | 231 | // View -> Sort By | ||
226 | QActionGroup* sortByActionGroup = createFileItemRolesActionGroup(QStringLiteral("sort_by_")); | 232 | QActionGroup* sortByActionGroup = createFileItemRolesActionGroup(QStringLiteral("sort_by_")); | ||
227 | 233 | | |||
228 | KActionMenu* sortByActionMenu = m_actionCollection->add<KActionMenu>(QStringLiteral("sort")); | 234 | KActionMenu* sortByActionMenu = m_actionCollection->add<KActionMenu>(QStringLiteral("sort")); | ||
229 | sortByActionMenu->setIcon(QIcon::fromTheme(QStringLiteral("view-sort"))); | 235 | sortByActionMenu->setIcon(QIcon::fromTheme(QStringLiteral("view-sort"))); | ||
230 | sortByActionMenu->setText(i18nc("@action:inmenu View", "Sort By")); | 236 | sortByActionMenu->setText(i18nc("@action:inmenu View", "Sort By")); | ||
231 | sortByActionMenu->setDelayed(false); | 237 | sortByActionMenu->setDelayed(false); | ||
232 | 238 | | |||
Show All 17 Lines | |||||
250 | connect(descendingAction, &QAction::triggered, this, [this] { | 256 | connect(descendingAction, &QAction::triggered, this, [this] { | ||
251 | m_currentView->setSortOrder(Qt::DescendingOrder); | 257 | m_currentView->setSortOrder(Qt::DescendingOrder); | ||
252 | }); | 258 | }); | ||
253 | 259 | | |||
254 | sortByActionMenu->addAction(ascendingAction); | 260 | sortByActionMenu->addAction(ascendingAction); | ||
255 | sortByActionMenu->addAction(descendingAction); | 261 | sortByActionMenu->addAction(descendingAction); | ||
256 | sortByActionMenu->addSeparator(); | 262 | sortByActionMenu->addSeparator(); | ||
257 | sortByActionMenu->addAction(sortFoldersFirst); | 263 | sortByActionMenu->addAction(sortFoldersFirst); | ||
264 | sortByActionMenu->addAction(sortHiddenLast); | ||||
258 | 265 | | |||
259 | // View -> Additional Information | 266 | // View -> Additional Information | ||
260 | QActionGroup* visibleRolesGroup = createFileItemRolesActionGroup(QStringLiteral("show_")); | 267 | QActionGroup* visibleRolesGroup = createFileItemRolesActionGroup(QStringLiteral("show_")); | ||
261 | 268 | | |||
262 | KActionMenu* visibleRolesMenu = m_actionCollection->add<KActionMenu>(QStringLiteral("additional_info")); | 269 | KActionMenu* visibleRolesMenu = m_actionCollection->add<KActionMenu>(QStringLiteral("additional_info")); | ||
263 | visibleRolesMenu->setText(i18nc("@action:inmenu View", "Show Additional Information")); | 270 | visibleRolesMenu->setText(i18nc("@action:inmenu View", "Show Additional Information")); | ||
264 | visibleRolesMenu->setIcon(QIcon::fromTheme(QStringLiteral("documentinfo"))); | 271 | visibleRolesMenu->setIcon(QIcon::fromTheme(QStringLiteral("documentinfo"))); | ||
265 | visibleRolesMenu->setDelayed(false); | 272 | visibleRolesMenu->setDelayed(false); | ||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 446 | if (viewModeAction) { | |||
443 | viewModeMenu->setIcon(viewModeAction->icon()); | 450 | viewModeMenu->setIcon(viewModeAction->icon()); | ||
444 | } | 451 | } | ||
445 | 452 | | |||
446 | QAction* showPreviewAction = m_actionCollection->action(QStringLiteral("show_preview")); | 453 | QAction* showPreviewAction = m_actionCollection->action(QStringLiteral("show_preview")); | ||
447 | showPreviewAction->setChecked(m_currentView->previewsShown()); | 454 | showPreviewAction->setChecked(m_currentView->previewsShown()); | ||
448 | 455 | | |||
449 | slotSortOrderChanged(m_currentView->sortOrder()); | 456 | slotSortOrderChanged(m_currentView->sortOrder()); | ||
450 | slotSortFoldersFirstChanged(m_currentView->sortFoldersFirst()); | 457 | slotSortFoldersFirstChanged(m_currentView->sortFoldersFirst()); | ||
458 | slotSortHiddenLastChanged(m_currentView->sortHiddenLast()); | ||||
451 | slotVisibleRolesChanged(m_currentView->visibleRoles(), QList<QByteArray>()); | 459 | slotVisibleRolesChanged(m_currentView->visibleRoles(), QList<QByteArray>()); | ||
452 | slotGroupedSortingChanged(m_currentView->groupedSorting()); | 460 | slotGroupedSortingChanged(m_currentView->groupedSorting()); | ||
453 | slotSortRoleChanged(m_currentView->sortRole()); | 461 | slotSortRoleChanged(m_currentView->sortRole()); | ||
454 | slotZoomLevelChanged(m_currentView->zoomLevel(), -1); | 462 | slotZoomLevelChanged(m_currentView->zoomLevel(), -1); | ||
455 | 463 | | |||
456 | // Updates the "show_hidden_files" action state and icon | 464 | // Updates the "show_hidden_files" action state and icon | ||
457 | slotHiddenFilesShownChanged(m_currentView->hiddenFilesShown()); | 465 | slotHiddenFilesShownChanged(m_currentView->hiddenFilesShown()); | ||
458 | } | 466 | } | ||
Show All 19 Lines | |||||
478 | } | 486 | } | ||
479 | 487 | | |||
480 | void DolphinViewActionHandler::toggleSortFoldersFirst() | 488 | void DolphinViewActionHandler::toggleSortFoldersFirst() | ||
481 | { | 489 | { | ||
482 | const bool sortFirst = m_currentView->sortFoldersFirst(); | 490 | const bool sortFirst = m_currentView->sortFoldersFirst(); | ||
483 | m_currentView->setSortFoldersFirst(!sortFirst); | 491 | m_currentView->setSortFoldersFirst(!sortFirst); | ||
484 | } | 492 | } | ||
485 | 493 | | |||
494 | void DolphinViewActionHandler::toggleSortHiddenLast() | ||||
495 | { | ||||
496 | const bool sortHiddenLast = m_currentView->sortHiddenLast(); | ||||
497 | m_currentView->setSortHiddenLast(!sortHiddenLast); | ||||
498 | } | ||||
499 | | ||||
486 | void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order) | 500 | void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order) | ||
487 | { | 501 | { | ||
488 | QAction* descending = m_actionCollection->action(QStringLiteral("descending")); | 502 | QAction* descending = m_actionCollection->action(QStringLiteral("descending")); | ||
489 | QAction* ascending = m_actionCollection->action(QStringLiteral("ascending")); | 503 | QAction* ascending = m_actionCollection->action(QStringLiteral("ascending")); | ||
490 | const bool sortDescending = (order == Qt::DescendingOrder); | 504 | const bool sortDescending = (order == Qt::DescendingOrder); | ||
491 | descending->setChecked(sortDescending); | 505 | descending->setChecked(sortDescending); | ||
492 | ascending->setChecked(!sortDescending); | 506 | ascending->setChecked(!sortDescending); | ||
493 | } | 507 | } | ||
494 | 508 | | |||
495 | void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst) | 509 | void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst) | ||
496 | { | 510 | { | ||
497 | m_actionCollection->action(QStringLiteral("folders_first"))->setChecked(foldersFirst); | 511 | m_actionCollection->action(QStringLiteral("folders_first"))->setChecked(foldersFirst); | ||
498 | } | 512 | } | ||
499 | 513 | | |||
514 | void DolphinViewActionHandler::slotSortHiddenLastChanged(bool hiddenLast) | ||||
515 | { | ||||
516 | m_actionCollection->action(QStringLiteral("hidden_last"))->setChecked(hiddenLast); | ||||
517 | } | ||||
518 | | ||||
500 | void DolphinViewActionHandler::toggleVisibleRole(QAction* action) | 519 | void DolphinViewActionHandler::toggleVisibleRole(QAction* action) | ||
501 | { | 520 | { | ||
502 | emit actionBeingHandled(); | 521 | emit actionBeingHandled(); | ||
503 | 522 | | |||
504 | const QByteArray toggledRole = action->data().toByteArray(); | 523 | const QByteArray toggledRole = action->data().toByteArray(); | ||
505 | 524 | | |||
506 | QList<QByteArray> roles = m_currentView->visibleRoles(); | 525 | QList<QByteArray> roles = m_currentView->visibleRoles(); | ||
507 | 526 | | |||
▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines |