Commit 50bfd9fe authored by Oliver Sander's avatar Oliver Sander

Presentation: optionally go to prev. page when touching left half of the page

This patch makes switching presentation slides using touch screen taps
more flexible.  It introduces a new configuration option
'Touch navigation' with three possible values:
* 'Tap left/right side to go back/forward':
   Tapping on the left(right) half of the screen
  makes the presentation go to the previous(next) slide.
* 'Tap anywhere to go forward':
  Tapping on the screen makes the presentation go to the
  next slide, no matter where the screen is being tapped
* 'Disabled':
  Screen tapping doesn't do anything.

Previously, only 'Tap anywhere...' was implemented.

This patch does not change the behavior of mouse clicks.

Differential Revision: https://phabricator.kde.org/D18118
parent c3db2972
......@@ -87,6 +87,39 @@
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QLabel">
<property name="text">
<string>Touch navigation:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="kcfg_SlidesTapNavigation">
<item>
<property name="text">
<string>Tap left/right side to go back/forward</string>
</property>
</item>
<item>
<property name="text">
<string>Tap anywhere to go forward</string>
</property>
</item>
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......
......@@ -92,5 +92,13 @@
<entry key="SlidesLoop" type="Bool" >
<default>false</default>
</entry>
<entry key="SlidesTapNavigation" type="Enum" >
<default>Forward</default>
<choices>
<choice name="ForwardBackward" />
<choice name="Forward" />
<choice name="Disabled" />
</choices>
</entry>
</group>
</kcfg>
......@@ -153,6 +153,7 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
m_ac( collection ), m_screenSelect( nullptr ), m_isSetup( false ), m_blockNotifications( false ), m_inBlackScreenMode( false ),
m_showSummaryView( Okular::Settings::slidesShowSummary() ),
m_advanceSlides( Okular::SettingsCore::slidesAdvance() ),
m_goToPreviousPageOnRelease( false ),
m_goToNextPageOnRelease( false )
{
Q_UNUSED( parent )
......@@ -707,7 +708,39 @@ void PresentationWidget::mousePressEvent( QMouseEvent * e )
return;
}
m_goToNextPageOnRelease = true;
// Actual mouse press events always lead to the next page page
if ( e->source() == Qt::MouseEventNotSynthesized )
{
m_goToNextPageOnRelease = true;
}
// Touch events may lead to the previous or next page
else if ( Okular::Settings::slidesTapNavigation() != Okular::Settings::EnumSlidesTapNavigation::Disabled )
{
switch ( Okular::Settings::slidesTapNavigation() )
{
case Okular::Settings::EnumSlidesTapNavigation::ForwardBackward:
{
if ( e->x() < ( geometry().width()/2 ) )
{
m_goToPreviousPageOnRelease = true;
}
else
{
m_goToNextPageOnRelease = true;
}
break;
}
case Okular::Settings::EnumSlidesTapNavigation::Forward:
{
m_goToNextPageOnRelease = true;
break;
}
case Okular::Settings::EnumSlidesTapNavigation::Disabled:
{
// Do Nothing
}
}
}
}
// pressing the "move forward" mouse button: unlike the left button this
// always means "show next page", so we unconditionally delegate to that
......@@ -737,6 +770,11 @@ void PresentationWidget::mouseReleaseEvent( QMouseEvent * e )
m_pressedLink = nullptr;
}
if ( m_goToPreviousPageOnRelease ) {
slotPrevPage();
m_goToPreviousPageOnRelease = false;
}
if ( m_goToNextPageOnRelease ) {
slotNextPage();
m_goToNextPageOnRelease = false;
......
......@@ -146,6 +146,7 @@ class PresentationWidget : public QWidget, public Okular::DocumentObserver
bool m_inBlackScreenMode;
bool m_showSummaryView;
bool m_advanceSlides;
bool m_goToPreviousPageOnRelease;
bool m_goToNextPageOnRelease;
private Q_SLOTS:
......
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