Commit e373613d authored by Aurélien Gâteau's avatar Aurélien Gâteau
Browse files

Configurable mouse wheel behavior.

One can choose between scrolling and browsing now.
BUG:156088

svn path=/trunk/KDE/kdegraphics/gwenview/; revision=775426
parent 7f5472f2
......@@ -35,6 +35,7 @@ namespace Gwenview {
struct ConfigDialogPrivate : public Ui_ConfigDialog {
InvisibleButtonGroup* mAlphaBackgroundModeGroup;
InvisibleButtonGroup* mWheelBehaviorGroup;
};
......@@ -51,6 +52,11 @@ ConfigDialog::ConfigDialog(QWidget* parent)
d->mAlphaBackgroundModeGroup->addButton(d->checkBoardRadioButton, int(ImageView::AlphaBackgroundCheckBoard));
d->mAlphaBackgroundModeGroup->addButton(d->solidColorRadioButton, int(ImageView::AlphaBackgroundSolid));
d->mWheelBehaviorGroup = new InvisibleButtonGroup(widget);
d->mWheelBehaviorGroup->setObjectName("kcfg_MouseWheelBehavior");
d->mWheelBehaviorGroup->addButton(d->mouseWheelScrollRadioButton, int(ImageView::MouseWheelScroll));
d->mWheelBehaviorGroup->addButton(d->mouseWheelBrowseRadioButton, int(ImageView::MouseWheelBrowse));
addPage(widget, "");
setHelp(QString(), "gwenview");
}
......
......@@ -5,11 +5,11 @@
<rect>
<x>0</x>
<y>0</y>
<width>407</width>
<height>416</height>
<width>427</width>
<height>478</height>
</rect>
</property>
<layout class="QGridLayout" >
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="label_3" >
<property name="text" >
......@@ -47,7 +47,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
......@@ -65,7 +65,7 @@ p, li { white-space: pre-wrap; }
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
......@@ -76,10 +76,21 @@ p, li { white-space: pre-wrap; }
<item row="3" column="0" colspan="2" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Transparent Image Background&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-weight:600;">Image View&lt;/span>&lt;/p>&lt;/body>&lt;/html></string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>Transparent background:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
......@@ -88,16 +99,7 @@ p, li { white-space: pre-wrap; }
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
......@@ -115,7 +117,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
......@@ -130,16 +132,7 @@ p, li { white-space: pre-wrap; }
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<property name="margin" >
<number>0</number>
</property>
<item>
......@@ -164,7 +157,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
......@@ -175,6 +168,67 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>Mouse wheel behavior:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QRadioButton" name="mouseWheelScrollRadioButton" >
<property name="text" >
<string>Scroll</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="7" column="1" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QRadioButton" name="mouseWheelBrowseRadioButton" >
<property name="text" >
<string>Browse</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="8" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
......@@ -182,7 +236,7 @@ p, li { white-space: pre-wrap; }
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
......@@ -190,7 +244,7 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="7" column="0" colspan="2" >
<item row="9" column="0" colspan="2" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
......@@ -200,7 +254,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="8" column="0" >
<item row="10" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Image Information:</string>
......@@ -213,10 +267,10 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="8" column="1" >
<item row="10" column="1" >
<widget class="QLineEdit" name="kcfg_FullScreenInfo" />
</item>
<item row="9" column="1" >
<item row="11" column="1" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Filename: %f
......@@ -227,12 +281,12 @@ Focal Length: %l</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2" >
<item row="12" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>399</width>
<height>16</height>
......
......@@ -33,6 +33,14 @@
<entry name="AlphaBackgroundColor" type="Color">
<default>#ffffff</default>
</entry>
<entry name="MouseWheelBehavior" type="Enum">
<choices name="Gwenview::ImageView::MouseWheelBehavior">
<choice name="ImageView::MouseWheelScroll"/>
<choice name="ImageView::MouseWheelBrowse"/>
</choices>
<default>ImageView::MouseWheelScroll</default>
</entry>
</group>
<group name="ThumbnailView">
......
......@@ -44,6 +44,7 @@ struct ImageViewPrivate {
QWidget* mViewport;
ImageView::AlphaBackgroundMode mAlphaBackgroundMode;
QColor mAlphaBackgroundColor;
ImageView::MouseWheelBehavior mMouseWheelBehavior;
const QImage* mImage;
qreal mZoom;
bool mZoomToFit;
......@@ -155,6 +156,7 @@ ImageView::ImageView(QWidget* parent)
{
d->mAlphaBackgroundMode = AlphaBackgroundCheckBoard;
d->mAlphaBackgroundColor = Qt::black;
d->mMouseWheelBehavior = MouseWheelScroll;
d->mImage = &d->mEmptyImage;
d->mView = this;
......@@ -191,6 +193,16 @@ void ImageView::setAlphaBackgroundColor(const QColor& color) {
}
void ImageView::setMouseWheelBehavior(ImageView::MouseWheelBehavior behavior) {
d->mMouseWheelBehavior = behavior;
}
ImageView::MouseWheelBehavior ImageView::mouseWheelBehavior() const {
return d->mMouseWheelBehavior;
}
void ImageView::setImage(const QImage* image) {
if (image) {
d->mImage = image;
......
......@@ -39,6 +39,11 @@ public:
AlphaBackgroundSolid
};
enum MouseWheelBehavior {
MouseWheelScroll,
MouseWheelBrowse
};
ImageView(QWidget* parent);
~ImageView();
......@@ -49,6 +54,10 @@ public:
void setAlphaBackgroundColor(const QColor& color);
void setMouseWheelBehavior(MouseWheelBehavior);
MouseWheelBehavior mouseWheelBehavior() const;
/**
* Set the image to display in this view. Note that we pass a pointer, not
* a reference, to make it more explicit that we do not keep a copy of the
......
......@@ -99,8 +99,7 @@ void ScrollTool::mouseReleaseEvent(QMouseEvent* /*event*/) {
void ScrollTool::wheelEvent(QWheelEvent* event) {
if (false/*imageView()->scrollOnWheelEvent()*/) {
// Scroll
if (imageView()->mouseWheelBehavior() == ImageView::MouseWheelScroll) {
// Forward events to the scrollbars, like
// QAbstractScrollArea::wheelEvent() do.
if (event->orientation() == Qt::Horizontal) {
......
......@@ -216,6 +216,7 @@ ImageView* GVPart::imageView() const {
void GVPart::loadConfig() {
mView->setAlphaBackgroundMode(GwenviewConfig::alphaBackgroundMode());
mView->setAlphaBackgroundColor(GwenviewConfig::alphaBackgroundColor());
mView->setMouseWheelBehavior(GwenviewConfig::mouseWheelBehavior());
}
......
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