diff --git a/doc/index.docbook b/doc/index.docbook --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1758,6 +1758,17 @@ Decreases the size of icons in the view. + + + +&Ctrl;0 + +View +Zoom Reset + +Resets the size of icons in the view to default. + + View diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -89,7 +89,9 @@ kitemviews/private/kitemlistviewlayouter.cpp kitemviews/private/kpixmapmodifier.cpp settings/applyviewpropsjob.cpp + settings/viewmodes/dolphinfontrequester.cpp settings/viewmodes/viewmodesettings.cpp + settings/viewmodes/viewsettingstab.cpp settings/viewpropertiesdialog.cpp settings/viewpropsprogressinfo.cpp views/dolphinfileitemlistwidget.cpp diff --git a/src/dolphinpart.rc b/src/dolphinpart.rc --- a/src/dolphinpart.rc +++ b/src/dolphinpart.rc @@ -1,5 +1,5 @@ - + &Edit @@ -21,6 +21,7 @@ &View + diff --git a/src/dolphinui.rc b/src/dolphinui.rc --- a/src/dolphinui.rc +++ b/src/dolphinui.rc @@ -1,5 +1,5 @@ - + @@ -21,6 +21,7 @@ + @@ -113,6 +114,7 @@ + diff --git a/src/settings/viewmodes/viewsettingstab.h b/src/settings/viewmodes/viewsettingstab.h --- a/src/settings/viewmodes/viewsettingstab.h +++ b/src/settings/viewmodes/viewsettingstab.h @@ -49,6 +49,7 @@ void applySettings(); void restoreDefaultSettings(); + int sliderValue() const; signals: void changed(); diff --git a/src/settings/viewmodes/viewsettingstab.cpp b/src/settings/viewmodes/viewsettingstab.cpp --- a/src/settings/viewmodes/viewsettingstab.cpp +++ b/src/settings/viewmodes/viewsettingstab.cpp @@ -189,6 +189,11 @@ settings->useDefaults(false); } +int ViewSettingsTab::sliderValue() const +{ + return m_defaultSizeSlider->value(); +} + void ViewSettingsTab::loadSettings() { switch (m_mode) { diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h --- a/src/views/dolphinviewactionhandler.h +++ b/src/views/dolphinviewactionhandler.h @@ -131,6 +131,9 @@ /** Decreases the size of the current set view mode. */ void zoomOut(); + + /** Resets the size of the current set view mode to default. */ + void zoomReset(); /** Switches between a separate sorting and a mixed sorting of files and folders. */ void toggleSortFoldersFirst(); diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -23,6 +23,7 @@ #include "dolphindebug.h" #include "kitemviews/kfileitemmodel.h" #include "settings/viewpropertiesdialog.h" +#include "settings/viewmodes/viewsettingstab.h" #include "views/zoomlevelinfo.h" #ifdef HAVE_BALOO @@ -188,11 +189,19 @@ m_actionCollection); zoomInAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This increases the icon size.")); + QAction* zoomResetAction = m_actionCollection->addAction( QStringLiteral("view_zoom_reset") ); + zoomResetAction->setText(i18nc("@action:inmenu View", "Reset Zoom Level")); + zoomResetAction->setToolTip(i18n("Zoom To Default")); + zoomResetAction->setWhatsThis(i18nc("@info:whatsthis zoom reset", "This resets the icon size to default.")); + zoomResetAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom-original"))); + m_actionCollection->setDefaultShortcuts(zoomResetAction, {Qt::CTRL + Qt::Key_0}); + connect(zoomResetAction, &QAction::triggered, this, &DolphinViewActionHandler::zoomReset); + QAction* zoomOutAction = KStandardAction::zoomOut(this, &DolphinViewActionHandler::zoomOut, m_actionCollection); - zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom in", "This reduces the icon size.")); - + zoomOutAction->setWhatsThis(i18nc("@info:whatsthis zoom out", "This reduces the icon size.")); + KToggleAction* showPreview = m_actionCollection->add(QStringLiteral("show_preview")); showPreview->setText(i18nc("@action:intoolbar", "Preview")); showPreview->setToolTip(i18nc("@info", "Show preview of files and folders")); @@ -391,7 +400,7 @@ { Q_UNUSED(shown); // It is not enough to update the 'Show Preview' action, also - // the 'Zoom In' and 'Zoom Out' actions must be adapted. + // the 'Zoom In', 'Zoom Out' and 'Zoom Reset' actions must be adapted. updateViewActions(); } @@ -454,6 +463,29 @@ updateViewActions(); } +void DolphinViewActionHandler::zoomReset() +{ + ViewSettingsTab::Mode settingsMode; + switch (m_currentView->mode()) { + case DolphinView::IconsView: + settingsMode = ViewSettingsTab::IconsMode; + break; + case DolphinView::DetailsView: + settingsMode = ViewSettingsTab::DetailsMode; + break; + case DolphinView::CompactView: + settingsMode = ViewSettingsTab::CompactMode; + break; + default: + Q_ASSERT(false); + break; + } + + const ViewSettingsTab settings(settingsMode); + m_currentView->setZoomLevel(settings.sliderValue()); + updateViewActions(); +} + void DolphinViewActionHandler::toggleSortFoldersFirst() { const bool sortFirst = m_currentView->sortFoldersFirst();