Commit 4a87ed95 authored by Huon Imberger's avatar Huon Imberger Committed by Henrik Fehlauer

Add options to disable some/all buttons when hovering over thumbnails

Summary:
Adds three options:

  1) Show all (previous behaviour, now default)
  2) Show only selection buttons (hide fullscreen and rotate buttons in Browse View)
  3) Hide all buttons

This option affects Browse View, Image View Thumbnail Bar, and the Importer tool `gwenview_importer`.

FEATURE: 164847

Reviewers: rkflx, ngraham

Reviewed By: rkflx, ngraham

Subscribers: ngraham

Differential Revision: https://phabricator.kde.org/D10421
parent 140393d0
......@@ -215,6 +215,28 @@ struct BrowseMainPagePrivate : public Ui_BrowseMainPage
pal.setColor(QPalette::Window, pal.color(QPalette::Window).dark(110));
mUrlNavigatorContainer->setPalette(pal);
}
void updateContextBarActions()
{
PreviewItemDelegate::ContextBarActions actions;
switch (GwenviewConfig::thumbnailActions())
{
case ThumbnailActions::None:
actions = PreviewItemDelegate::NoAction;
break;
case ThumbnailActions::ShowSelectionButtonOnly:
actions = PreviewItemDelegate::SelectionAction;
break;
case ThumbnailActions::AllButtons:
default:
actions = PreviewItemDelegate::SelectionAction | PreviewItemDelegate::RotateAction;
if (!q->window()->isFullScreen()) {
actions |= PreviewItemDelegate::FullScreenAction;
}
break;
}
mDelegate->setContextBarActions(actions);
}
};
BrowseMainPage::BrowseMainPage(QWidget* parent, KActionCollection* actionCollection, GvCore* gvCore)
......@@ -263,6 +285,8 @@ void BrowseMainPage::loadConfig()
break;
}
}
d->updateContextBarActions();
}
void BrowseMainPage::saveConfig() const
......@@ -374,11 +398,7 @@ void BrowseMainPage::setFullScreenMode(bool fullScreen)
d->mUrlNavigatorContainer->setContentsMargins(
fullScreen ? 6 : 0,
0, 0, 0);
PreviewItemDelegate::ContextBarActions actions = PreviewItemDelegate::SelectionAction | PreviewItemDelegate::RotateAction;
if (!fullScreen) {
actions |= PreviewItemDelegate::FullScreenAction;
}
d->mDelegate->setContextBarActions(actions);
d->updateContextBarActions();
d->mFullScreenToolBar->setVisible(fullScreen);
d->mFullScreenToolBar2->setVisible(fullScreen);
......
......@@ -52,6 +52,13 @@ ConfigDialog::ConfigDialog(QWidget* parent)
// General
widget = setupPage(mGeneralConfigPage);
mThumbnailActionsGroup = new InvisibleButtonGroup(widget);
mThumbnailActionsGroup->setObjectName(QLatin1String("kcfg_ThumbnailActions"));
mThumbnailActionsGroup->addButton(mGeneralConfigPage.allButtonsThumbnailActionsRadioButton, int(ThumbnailActions::AllButtons));
mThumbnailActionsGroup->addButton(mGeneralConfigPage.selectionOnlyThumbnailActionsRadioButton, int(ThumbnailActions::ShowSelectionButtonOnly));
mThumbnailActionsGroup->addButton(mGeneralConfigPage.noneThumbnailActionsRadioButton, int(ThumbnailActions::None));
pageItem = addPage(widget, i18n("General"));
pageItem->setIcon(QIcon::fromTheme("gwenview"));
connect(mGeneralConfigPage.kcfg_ViewBackgroundValue, SIGNAL(valueChanged(int)), SLOT(updateViewBackgroundFrame()));
......
......@@ -48,6 +48,7 @@ private:
InvisibleButtonGroup* mAlphaBackgroundModeGroup;
InvisibleButtonGroup* mWheelBehaviorGroup;
InvisibleButtonGroup* mAnimationMethodGroup;
InvisibleButtonGroup* mThumbnailActionsGroup;
InvisibleButtonGroup* mZoomModeGroup;
InvisibleButtonGroup* mThumbnailBarOrientationGroup;
InvisibleButtonGroup* mRenderingIntentGroup;
......
......@@ -11,6 +11,36 @@
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Videos:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="kcfg_ListVideos">
<property name="text">
<string>Show videos</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
......@@ -76,22 +106,8 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Videos:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="kcfg_ListVideos">
<property name="text">
<string>Show videos</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
......@@ -106,6 +122,34 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Thumbnail actions:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="allButtonsThumbnailActionsRadioButton">
<property name="text">
<string>All buttons</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QRadioButton" name="selectionOnlyThumbnailActionsRadioButton">
<property name="text">
<string>Show selection button onl&amp;y</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QRadioButton" name="noneThumbnailActionsRadioButton">
<property name="text">
<string>None</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -189,7 +189,7 @@ struct ViewMainPagePrivate
QColor borderSelColor = PaintUtils::adjustedHsv(bgSelColor, 0, 0, -qMin(60, bgSelColor.value()));
QString itemCss =
"QListView::item {"
"QListView::item:!hover {"
" background-color: %1;"
" border-left: 1px solid %2;"
" border-right: 1px solid %3;"
......
......@@ -162,7 +162,18 @@ struct ThumbnailPagePrivate : public Ui_ThumbnailPage
PreviewItemDelegate* delegate = new PreviewItemDelegate(mThumbnailView);
delegate->setThumbnailDetails(PreviewItemDelegate::FileNameDetail);
delegate->setContextBarActions(PreviewItemDelegate::SelectionAction);
PreviewItemDelegate::ContextBarActions actions;
switch (GwenviewConfig::thumbnailActions())
{
case ThumbnailActions::None:
actions = PreviewItemDelegate::NoAction;
break;
case ThumbnailActions::ShowSelectionButtonOnly:
case ThumbnailActions::AllButtons:
actions = PreviewItemDelegate::SelectionAction;
break;
}
delegate->setContextBarActions(actions);
mThumbnailView->setItemDelegate(delegate);
// Colors
......
......@@ -7,6 +7,7 @@
<kcfgfile name="gwenviewrc"/>
<include>lib/sorting.h</include>
<include>lib/zoommode.h</include>
<include>lib/thumbnailactions.h</include>
<include>lib/mousewheelbehavior.h</include>
<include>lib/documentview/documentview.h</include>
<include>lib/documentview/rasterimageview.h</include>
......@@ -82,6 +83,15 @@
<entry name="SideBarPage" type="String">
<default>information</default>
</entry>
<entry name="ThumbnailActions" type="Enum">
<choices name="Gwenview::ThumbnailActions::Enum">
<choice name="ThumbnailActions::AllButtons"/>
<choice name="ThumbnailActions::ShowSelectionButtonOnly"/>
<choice name="ThumbnailActions::None"/>
</choices>
<default>ThumbnailActions::AllButtons</default>
</entry>
</group>
<group name="FullScreen">
......
// vim: set tabstop=4 shiftwidth=4 expandtab:
/*
Gwenview: an image viewer
Copyright 2018 Huon Imberger <huon@plonq.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA.
*/
#ifndef THUMBNAILACTIONS_H
#define THUMBNAILACTIONS_H
// Qt
// KDE
// Local
namespace Gwenview
{
namespace ThumbnailActions
{
/**
* This enum represents the different thumbnail actions display modes.
*/
enum Enum {
AllButtons,
ShowSelectionButtonOnly,
None
};
} // namespace ThumbnailActions
} // namespace Gwenview
#endif /* THUMBNAILACTIONS_H */
......@@ -44,6 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include "lib/hud/hudtheme.h"
#include "lib/paintutils.h"
#include "lib/thumbnailview/abstractthumbnailviewhelper.h"
#include "gwenviewconfig.h"
namespace Gwenview
{
......@@ -126,7 +127,7 @@ struct ThumbnailBarItemDelegatePrivate
{
mIndexUnderCursor = index;
if (mIndexUnderCursor.isValid()) {
if (mIndexUnderCursor.isValid() && GwenviewConfig::thumbnailActions() != ThumbnailActions::None) {
updateToggleSelectionButton();
const QRect rect = mView->visualRect(mIndexUnderCursor);
......
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