Changeset View
Standalone View
src/views/dolphinviewactionhandler.cpp
Show First 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 90 | { | |||
---|---|---|---|---|---|
183 | viewModeActions->setToolBarMode(KSelectAction::MenuMode); | 183 | viewModeActions->setToolBarMode(KSelectAction::MenuMode); | ||
184 | connect(viewModeActions, QOverload<QAction*>::of(&KSelectAction::triggered), this, &DolphinViewActionHandler::slotViewModeActionTriggered); | 184 | connect(viewModeActions, QOverload<QAction*>::of(&KSelectAction::triggered), this, &DolphinViewActionHandler::slotViewModeActionTriggered); | ||
185 | 185 | | |||
186 | QAction* zoomInAction = KStandardAction::zoomIn(this, | 186 | QAction* zoomInAction = KStandardAction::zoomIn(this, | ||
187 | &DolphinViewActionHandler::zoomIn, | 187 | &DolphinViewActionHandler::zoomIn, | ||
188 | m_actionCollection); | 188 | m_actionCollection); | ||
189 | zoomInAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This increases the icon size.")); | 189 | zoomInAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This increases the icon size.")); | ||
190 | 190 | | |||
191 | QAction* zoomResetAction = m_actionCollection->addAction(QStringLiteral("view_zoom_reset")); | ||||
elvisangelaccio: Please remove the spaces before/after `QStringLiteral` | |||||
192 | zoomResetAction->setText(i18nc("@action:inmenu View", "Reset Zoom Level")); | ||||
Sorry, I steered you wrong. The text needs to Use Title Case: "Reset zoom level" ngraham: Sorry, I steered you wrong. The text needs to Use Title Case:
"Reset zoom level" | |||||
193 | zoomResetAction->setToolTip(i18n("Zoom To Default")); | ||||
194 | zoomResetAction->setWhatsThis(i18nc("@info:whatsthis zoom reset", "This resets the icon size to default.")); | ||||
195 | zoomResetAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom-original"))); | ||||
196 | m_actionCollection->setDefaultShortcuts(zoomResetAction, {Qt::CTRL + Qt::Key_0}); | ||||
197 | connect(zoomResetAction, &QAction::triggered, this, &DolphinViewActionHandler::zoomReset); | ||||
198 | | ||||
191 | QAction* zoomOutAction = KStandardAction::zoomOut(this, | 199 | QAction* zoomOutAction = KStandardAction::zoomOut(this, | ||
192 | &DolphinViewActionHandler::zoomOut, | 200 | &DolphinViewActionHandler::zoomOut, | ||
193 | m_actionCollection); | 201 | m_actionCollection); | ||
194 | zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom out", "This reduces the icon size.")); | 202 | zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom out", "This reduces the icon size.")); | ||
195 | 203 | | |||
Unrelated change, should go to its own commit. (feel free to push it without review...) elvisangelaccio: Unrelated change, should go to its own commit. (feel free to push it without review...) | |||||
196 | KToggleAction* showPreview = m_actionCollection->add<KToggleAction>(QStringLiteral("show_preview")); | 204 | KToggleAction* showPreview = m_actionCollection->add<KToggleAction>(QStringLiteral("show_preview")); | ||
197 | showPreview->setText(i18nc("@action:intoolbar", "Preview")); | 205 | showPreview->setText(i18nc("@action:intoolbar", "Preview")); | ||
ngraham: Name should be "Reset zoom level" or "Zoom to default size" | |||||
198 | showPreview->setToolTip(i18nc("@info", "Show preview of files and folders")); | 206 | showPreview->setToolTip(i18nc("@info", "Show preview of files and folders")); | ||
199 | showPreview->setWhatsThis(xi18nc("@info:whatsthis", "When this is " | 207 | showPreview->setWhatsThis(xi18nc("@info:whatsthis", "When this is " | ||
200 | "enabled, the icons are based on the actual file or folder " | 208 | "enabled, the icons are based on the actual file or folder " | ||
201 | "contents.<nl/>For example the icons of images become scaled " | 209 | "contents.<nl/>For example the icons of images become scaled " | ||
202 | "down versions of the images.")); | 210 | "down versions of the images.")); | ||
203 | showPreview->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | 211 | showPreview->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | ||
204 | connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview); | 212 | connect(showPreview, &KToggleAction::triggered, this, &DolphinViewActionHandler::togglePreview); | ||
205 | 213 | | |||
▲ Show 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | 393 | { | |||
386 | emit actionBeingHandled(); | 394 | emit actionBeingHandled(); | ||
387 | m_currentView->setPreviewsShown(show); | 395 | m_currentView->setPreviewsShown(show); | ||
388 | } | 396 | } | ||
389 | 397 | | |||
390 | void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown) | 398 | void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown) | ||
391 | { | 399 | { | ||
392 | Q_UNUSED(shown); | 400 | Q_UNUSED(shown); | ||
393 | // It is not enough to update the 'Show Preview' action, also | 401 | // It is not enough to update the 'Show Preview' action, also | ||
394 | // the 'Zoom In' and 'Zoom Out' actions must be adapted. | 402 | // the 'Zoom In', 'Zoom Out' and 'Zoom Reset' actions must be adapted. | ||
395 | updateViewActions(); | 403 | updateViewActions(); | ||
396 | } | 404 | } | ||
397 | 405 | | |||
398 | QString DolphinViewActionHandler::currentViewModeActionName() const | 406 | QString DolphinViewActionHandler::currentViewModeActionName() const | ||
399 | { | 407 | { | ||
400 | switch (m_currentView->mode()) { | 408 | switch (m_currentView->mode()) { | ||
401 | case DolphinView::IconsView: | 409 | case DolphinView::IconsView: | ||
402 | return QStringLiteral("icons"); | 410 | return QStringLiteral("icons"); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
449 | 457 | | |||
450 | void DolphinViewActionHandler::zoomOut() | 458 | void DolphinViewActionHandler::zoomOut() | ||
451 | { | 459 | { | ||
452 | const int level = m_currentView->zoomLevel(); | 460 | const int level = m_currentView->zoomLevel(); | ||
453 | m_currentView->setZoomLevel(level - 1); | 461 | m_currentView->setZoomLevel(level - 1); | ||
454 | updateViewActions(); | 462 | updateViewActions(); | ||
455 | } | 463 | } | ||
456 | 464 | | |||
465 | void DolphinViewActionHandler::zoomReset() | ||||
466 | { | ||||
467 | m_currentView->resetZoomLevel(); | ||||
That seems like a fairly arbitrary value to reset it to. You should read the default size and zoom to that instead. After all, that's what the WhatsThis text you wrote says it will do. :) ngraham: That seems like a fairly arbitrary value to reset it to. You should read the default size and… | |||||
There is nothing like "default". zoomlevelinfo.cpp also have only min and max values for levels. I have choosen 5px as it looks perfect. shubham: There is nothing like "default". zoomlevelinfo.cpp also have only min and max values for levels. | |||||
468 | updateViewActions(); | ||||
469 | } | ||||
470 | | ||||
457 | void DolphinViewActionHandler::toggleSortFoldersFirst() | 471 | void DolphinViewActionHandler::toggleSortFoldersFirst() | ||
458 | { | 472 | { | ||
459 | const bool sortFirst = m_currentView->sortFoldersFirst(); | 473 | const bool sortFirst = m_currentView->sortFoldersFirst(); | ||
460 | m_currentView->setSortFoldersFirst(!sortFirst); | 474 | m_currentView->setSortFoldersFirst(!sortFirst); | ||
461 | } | 475 | } | ||
462 | 476 | | |||
463 | void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order) | 477 | void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order) | ||
464 | { | 478 | { | ||
465 | QAction* descending = m_actionCollection->action(QStringLiteral("descending")); | 479 | QAction* descending = m_actionCollection->action(QStringLiteral("descending")); | ||
466 | QAction* ascending = m_actionCollection->action(QStringLiteral("ascending")); | 480 | QAction* ascending = m_actionCollection->action(QStringLiteral("ascending")); | ||
467 | const bool sortDescending = (order == Qt::DescendingOrder); | 481 | const bool sortDescending = (order == Qt::DescendingOrder); | ||
468 | descending->setChecked(sortDescending); | 482 | descending->setChecked(sortDescending); | ||
469 | ascending->setChecked(!sortDescending); | 483 | ascending->setChecked(!sortDescending); | ||
This is troubling me for some time now. It gives undefined reference linker error. I have already included the corresponding header file. shubham: This is troubling me for some time now. It gives undefined reference linker error. I have… | |||||
470 | } | 484 | } | ||
471 | 485 | | |||
Sorry but I don't like this solution (i.e. creating a settings tab widget inside the action handler). Please try the following instead:
elvisangelaccio: Sorry but I don't like this solution (i.e. creating a settings tab widget inside the action… | |||||
472 | void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst) | 486 | void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst) | ||
473 | { | 487 | { | ||
474 | m_actionCollection->action(QStringLiteral("folders_first"))->setChecked(foldersFirst); | 488 | m_actionCollection->action(QStringLiteral("folders_first"))->setChecked(foldersFirst); | ||
475 | } | 489 | } | ||
476 | 490 | | |||
477 | void DolphinViewActionHandler::toggleVisibleRole(QAction* action) | 491 | void DolphinViewActionHandler::toggleVisibleRole(QAction* action) | ||
478 | { | 492 | { | ||
479 | emit actionBeingHandled(); | 493 | emit actionBeingHandled(); | ||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |
Please remove the spaces before/after QStringLiteral