summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuon Imberger <[email protected]>2018-02-14 18:20:17 +0100
committerHenrik Fehlauer <[email protected]>2018-02-14 18:24:34 +0100
commit4a87ed952ec209d4407fad664a76a2e1afd59b95 (patch)
tree98b899d8c5d7b28ac02c0f740fd9dcc483ad7606
parent140393d089726b58ac7f854c83e0697b8b471f05 (diff)
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
-rw-r--r--app/browsemainpage.cpp30
-rw-r--r--app/configdialog.cpp7
-rw-r--r--app/configdialog.h1
-rw-r--r--app/generalconfigpage.ui76
-rw-r--r--app/viewmainpage.cpp2
-rw-r--r--importer/thumbnailpage.cpp13
-rw-r--r--lib/gwenviewconfig.kcfg10
-rw-r--r--lib/thumbnailactions.h48
-rw-r--r--lib/thumbnailview/thumbnailbarview.cpp3
9 files changed, 166 insertions, 24 deletions
diff --git a/app/browsemainpage.cpp b/app/browsemainpage.cpp
index 3eea328..63bdd8a 100644
--- a/app/browsemainpage.cpp
+++ b/app/browsemainpage.cpp
@@ -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);
diff --git a/app/configdialog.cpp b/app/configdialog.cpp
index 7cdbfab..24f0131 100644
--- a/app/configdialog.cpp
+++ b/app/configdialog.cpp
@@ -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()));
diff --git a/app/configdialog.h b/app/configdialog.h
index 4bca637..637201e 100644
--- a/app/configdialog.h
+++ b/app/configdialog.h
@@ -48,6 +48,7 @@ private:
InvisibleButtonGroup* mAlphaBackgroundModeGroup;
InvisibleButtonGroup* mWheelBehaviorGroup;
InvisibleButtonGroup* mAnimationMethodGroup;
+ InvisibleButtonGroup* mThumbnailActionsGroup;
InvisibleButtonGroup* mZoomModeGroup;
InvisibleButtonGroup* mThumbnailBarOrientationGroup;
InvisibleButtonGroup* mRenderingIntentGroup;
diff --git a/app/generalconfigpage.ui b/app/generalconfigpage.ui
index 12d7830..041f9d3 100644
--- a/app/generalconfigpage.ui
+++ b/app/generalconfigpage.ui
@@ -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/>
diff --git a/app/viewmainpage.cpp b/app/viewmainpage.cpp
index aeb12dd..399a50b 100644
--- a/app/viewmainpage.cpp
+++ b/app/viewmainpage.cpp
@@ -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;"
diff --git a/importer/thumbnailpage.cpp b/importer/thumbnailpage.cpp
index 031d3d1..6ebdcef 100644
--- a/importer/thumbnailpage.cpp
+++ b/importer/thumbnailpage.cpp
@@ -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
diff --git a/lib/gwenviewconfig.kcfg b/lib/gwenviewconfig.kcfg
index 1e8866d..0f46f54 100644
--- a/lib/gwenviewconfig.kcfg
+++ b/lib/gwenviewconfig.kcfg
@@ -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">
diff --git a/lib/thumbnailactions.h b/lib/thumbnailactions.h
new file mode 100644
index 0000000..c67246e
--- /dev/null
+++ b/lib/thumbnailactions.h
@@ -0,0 +1,48 @@
+// vim: set tabstop=4 shiftwidth=4 expandtab:
+/*
+Gwenview: an image viewer
+Copyright 2018 Huon Imberger <[email protected]>
+
+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 */
diff --git a/lib/thumbnailview/thumbnailbarview.cpp b/lib/thumbnailview/thumbnailbarview.cpp
index a53bcb4..260c1bd 100644
--- a/lib/thumbnailview/thumbnailbarview.cpp
+++ b/lib/thumbnailview/thumbnailbarview.cpp
@@ -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);