Commit 7165ea7a authored by Nate Graham's avatar Nate Graham
Browse files

Add Reset Zoom Level action inside View menu

Summary:
FEATURE: 409591
FIXED-IN: 19.12.0

Test Plan: {F7096397}

Reviewers: elvisangelaccio, shubham, #dolphin

Reviewed By: elvisangelaccio, #dolphin

Subscribers: broulik, cfeck, kfm-devel, kde-doc-english

Tags: #dolphin, #documentation

Differential Revision: https://phabricator.kde.org/D22444
parent 4c995268
......@@ -1758,6 +1758,17 @@ Selects all unselected items and deselects all selected items in the current fol
<listitem><para><action>Decreases the size of icons in the view.</action></para></listitem>
</varlistentry>
<varlistentry>
<term><menuchoice>
<shortcut>
<keycombo action="simul">&Ctrl;<keycap>0</keycap></keycombo>
</shortcut>
<guimenu>View</guimenu>
<guimenuitem>Zoom Reset</guimenuitem>
</menuchoice></term>
<listitem><para><action>Resets the size of icons in the view to default.</action></para></listitem>
</varlistentry>
<varlistentry>
<term><menuchoice>
<guimenu>View</guimenu>
......
......@@ -1016,6 +1016,7 @@ void DolphinMainWindow::updateControlMenu()
// Add "View" actions
if (!GeneralSettings::showZoomSlider()) {
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomIn)), menu);
addActionToMenu(ac->action(QStringLiteral("view_zoom_reset")), menu);
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::ZoomOut)), menu);
menu->addSeparator();
}
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="dolphin" version="25">
<kpartgui name="dolphin" version="26">
<MenuBar>
<Menu name="file">
<Action name="new_menu" />
......@@ -23,6 +23,10 @@
<Action name="invert_selection" />
</Menu>
<Menu name="view">
<Action name="view_zoom_in"/>
<Action name="view_zoom_reset"/>
<Action name="view_zoom_out"/>
<Separator/>
<Action name="sort" />
<Action name="view_mode" />
<Action name="additional_info" />
......@@ -116,6 +120,7 @@
<Action priority="0" name="compact"/>
<Action priority="0" name="details"/>
<Action priority="0" name="view_zoom_in"/>
<Action priority="0" name="view_zoom_reset"/>
<Action priority="0" name="view_zoom_out"/>
<Action priority="0" name="edit_cut"/>
<Action priority="0" name="edit_copy"/>
......
......@@ -66,6 +66,7 @@
#include <QPixmapCache>
#include <QPointer>
#include <QScrollBar>
#include <QSize>
#include <QTimer>
#include <QVBoxLayout>
......@@ -1338,6 +1339,20 @@ QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
return QUrl();
}
void DolphinView::resetZoomLevel()
{
ViewModeSettings::ViewMode mode;
switch (m_mode) {
case IconsView: mode = ViewModeSettings::IconsMode; break;
case CompactView: mode = ViewModeSettings::CompactMode; break;
case DetailsView: mode = ViewModeSettings::DetailsMode; break;
}
const ViewModeSettings settings(mode);
const QSize iconSize = QSize(settings.iconSize(), settings.iconSize());
setZoomLevel(ZoomLevelInfo::zoomLevelForIconSize(iconSize));
}
void DolphinView::observeCreatedItem(const QUrl& url)
{
if (m_active) {
......
......@@ -196,6 +196,11 @@ public:
void setZoomLevel(int level);
int zoomLevel() const;
/**
* Resets the view's icon size to the default value
*/
void resetZoomLevel();
void setSortRole(const QByteArray& role);
QByteArray sortRole() const;
......
......@@ -188,6 +188,14 @@ void DolphinViewActionHandler::createActions()
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);
......@@ -391,7 +399,7 @@ void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown)
{
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 +462,12 @@ void DolphinViewActionHandler::zoomOut()
updateViewActions();
}
void DolphinViewActionHandler::zoomReset()
{
m_currentView->resetZoomLevel();
updateViewActions();
}
void DolphinViewActionHandler::toggleSortFoldersFirst()
{
const bool sortFirst = m_currentView->sortFoldersFirst();
......
......@@ -131,6 +131,9 @@ private Q_SLOTS:
/** 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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment