Commit 98000ff9 authored by Tobias Koenig's avatar Tobias Koenig

Add some nice features for presentation mode:

  - cursor modes: visible, hidden, hidden with delay
  - automatic advance
  - loop on last page
  - default transition

I know it's quite late in the release cycle, but the code is stable and kpdf rocks!

svn path=/trunk/kdegraphics/kpdf/; revision=375353
parent abdc236d
......@@ -91,6 +91,10 @@ More items (first items will enter 'In progress list' first):
-> move some document related features from part to the document (see find, goto dialog, ...)
Done (newest features come first):
-> ADD: presentation: cursor modes: hidden, visible, hidden with delay (Tobias)
-> ADD: presentation: default transition which is used when no transition is defined in document (Tobias)
-> ADD: presentation: support for automatic advance and loop on last page (Tobias)
-> ADD: presentation: add additional presentation page to settings dialog (Tobias)
-> CHG: presentation: the round wheel indicator can be clicked to change page
-> FIX: layout margins on pageView
-> ADD: restore the last active page when a file is opened again
......
......@@ -3,6 +3,7 @@ INCLUDES = -I$(srcdir)/.. -I$(top_builddir)/kpdf $(all_includes)
METASOURCES = AUTO
libkpdfconf_la_SOURCES = dlggeneral.ui dlgperformance.ui dlgaccessibility.ui \
dlgpresentation.ui \
preferencesdialog.cpp settings.kcfgc
noinst_LTLIBRARIES = libkpdfconf.la
......
......@@ -8,10 +8,13 @@
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>255</height>
<width>289</width>
<height>169</height>
</rect>
</property>
<property name="caption">
<string>DlgGeneral</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
......@@ -147,96 +150,6 @@
</widget>
</hbox>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox1</cstring>
</property>
<property name="title">
<string>Presentation</string>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout12</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_SlidesShowProgress</cstring>
</property>
<property name="text">
<string>Show &amp;progress indicator</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_SlidesShowGrayBack</cstring>
</property>
<property name="text">
<string>Show light &amp;gray background</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_SlidesShowSummary</cstring>
</property>
<property name="text">
<string>Show s&amp;ummary page</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout3</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>pixmapLabel1</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap>"kpresenter_kpr", 32</pixmap>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacerV2</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Minimum</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</hbox>
</widget>
<spacer>
<property name="name">
<cstring>spacer3</cstring>
......
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>DlgPresentation</class>
<widget class="QWidget">
<property name="name">
<cstring>DlgPresentation</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>348</width>
<height>298</height>
</rect>
</property>
<property name="caption">
<string>DlgPresentation</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox1</cstring>
</property>
<property name="title">
<string>Navigation</string>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout1</cstring>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QSpinBox" row="0" column="1">
<property name="name">
<cstring>kcfg_SlidesAdvanceTime</cstring>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string> sec.</string>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
<widget class="QCheckBox" row="0" column="0">
<property name="name">
<cstring>kcfg_SlidesAdvance</cstring>
</property>
<property name="text">
<string>Advance Every</string>
</property>
</widget>
<widget class="QCheckBox" row="2" column="0">
<property name="name">
<cstring>kcfg_SlidesLoop</cstring>
</property>
<property name="text">
<string>Loop After Last Page</string>
</property>
</widget>
</grid>
</widget>
</hbox>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox2</cstring>
</property>
<property name="title">
<string>Appearance</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QComboBox" row="1" column="1">
<item>
<property name="text">
<string>Replace</string>
</property>
</item>
<item>
<property name="text">
<string>Split</string>
</property>
</item>
<item>
<property name="text">
<string>Blinds</string>
</property>
</item>
<item>
<property name="text">
<string>Box</string>
</property>
</item>
<item>
<property name="text">
<string>Wipe</string>
</property>
</item>
<item>
<property name="text">
<string>Dissolve</string>
</property>
</item>
<item>
<property name="text">
<string>Glitter</string>
</property>
</item>
<item>
<property name="text">
<string>Fly</string>
</property>
</item>
<item>
<property name="text">
<string>Push</string>
</property>
</item>
<item>
<property name="text">
<string>Cover</string>
</property>
</item>
<item>
<property name="text">
<string>Uncover</string>
</property>
</item>
<item>
<property name="text">
<string>Fade</string>
</property>
</item>
<property name="name">
<cstring>kcfg_SlidesTransition</cstring>
</property>
</widget>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Default Transition:</string>
</property>
</widget>
<widget class="QLabel" row="2" column="0">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>Mouse Cursor:</string>
</property>
</widget>
<widget class="QComboBox" row="2" column="1">
<item>
<property name="text">
<string>Hidden After Delay</string>
</property>
</item>
<item>
<property name="text">
<string>Always Visible</string>
</property>
</item>
<item>
<property name="text">
<string>Always Hidden</string>
</property>
</item>
<property name="name">
<cstring>kcfg_SlidesCursor</cstring>
</property>
</widget>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel3</cstring>
</property>
<property name="text">
<string>Background Color:</string>
</property>
</widget>
<widget class="KColorButton" row="0" column="1">
<property name="name">
<cstring>kcfg_SlidesBackgroundColor</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="QCheckBox" row="4" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>kcfg_SlidesShowSummary</cstring>
</property>
<property name="text">
<string>Show s&amp;ummary page</string>
</property>
<property name="accel">
<string>Alt+U</string>
</property>
</widget>
<widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>kcfg_SlidesShowProgress</cstring>
</property>
<property name="text">
<string>Show &amp;progress indicator</string>
</property>
<property name="accel">
<string>Alt+P</string>
</property>
</widget>
</grid>
</widget>
</vbox>
</widget>
<customwidgets>
</customwidgets>
<connections>
<connection>
<sender>kcfg_SlidesAdvance</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_SlidesAdvanceTime</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
<includehint>kcolorbutton.h</includehint>
</includehints>
</UI>
......@@ -90,10 +90,46 @@
</entry>
</group>
<group name="Presentation" >
<entry key="SlidesShowProgress" type="Bool" >
<default>true</default>
<entry key="SlidesAdvance" type="Bool" >
<default>false</default>
</entry>
<entry key="SlidesAdvanceTime" type="UInt" >
<default>5</default>
<min>1</min>
<max>3600</max>
</entry>
<entry key="SlidesLoop" type="Bool" >
<default>false</default>
</entry>
<entry key="SlidesBackgroundColor" type="Color" >
<default code="true" >Qt::black</default>
</entry>
<entry key="SlidesShowGrayBack" type="Bool" >
<entry key="SlidesTransition" type="Enum" >
<default>Replace</default>
<choices>
<choice name="Replace" />
<choice name="Split" />
<choice name="Blinds" />
<choice name="Box" />
<choice name="Wipe" />
<choice name="Dissolve" />
<choice name="Glitter" />
<choice name="Fly" />
<choice name="Push" />
<choice name="Cover" />
<choice name="Uncover" />
<choice name="Fade" />
</choices>
</entry>
<entry key="SlidesCursor" type="Enum" >
<default>HiddenDelay</default>
<choices>
<choice name="HiddenDelay" />
<choice name="Visible" />
<choice name="Hidden" />
</choices>
</entry>
<entry key="SlidesShowProgress" type="Bool" >
<default>true</default>
</entry>
<entry key="SlidesShowSummary" type="Bool" >
......
......@@ -13,6 +13,7 @@
#include "dlggeneral.h"
#include "dlgperformance.h"
#include "dlgaccessibility.h"
#include "dlgpresentation.h"
// reimplementing this
#include "preferencesdialog.h"
......@@ -23,8 +24,11 @@ PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skelet
m_general = new DlgGeneral(0);
m_performance = new DlgPerformance(0);
m_accessibility = new DlgAccessibility(0);
m_presentation = new DlgPresentation(0);
addPage( m_general, i18n("General"), "kpdf", i18n("General Options") );
addPage( m_accessibility, i18n("Accessibility"), "access", i18n("Reading Aids") );
addPage( m_performance, i18n("Performance"), "launch", i18n("Performance Tuning") );
addPage( m_presentation, i18n("Presentation"), "kpresenter_kpr",
i18n("Options For Presentation Mode") );
}
......@@ -19,6 +19,7 @@ class KConfigSkeleton;
class DlgGeneral;
class DlgPerformance;
class DlgAccessibility;
class DlgPresentation;
class PreferencesDialog : public KConfigDialog
{
......@@ -37,6 +38,7 @@ class PreferencesDialog : public KConfigDialog
DlgGeneral * m_general;
DlgPerformance * m_performance;
DlgAccessibility * m_accessibility;
DlgPresentation * m_presentation;
};
#endif
......@@ -12,8 +12,8 @@
/** class KPDFPageTransition **/
KPDFPageTransition::KPDFPageTransition()
: m_type( Replace ),
KPDFPageTransition::KPDFPageTransition( Type type )
: m_type( type ),
m_duration( 1 ),
m_alignment( Horizontal ),
m_direction( Inward ),
......
......@@ -16,9 +16,6 @@
class KPDFPageTransition
{
public:
KPDFPageTransition();
~KPDFPageTransition();
enum Type {
Replace,
Split,
......@@ -44,6 +41,9 @@ class KPDFPageTransition
Outward
};
KPDFPageTransition( Type type = Replace );
~KPDFPageTransition();
// Get type of the transition.
inline Type type() const { return m_type; }
......
......@@ -77,6 +77,8 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
connect( m_transitionTimer, SIGNAL( timeout() ), this, SLOT( slotTransitionStep() ) );
m_overlayHideTimer = new QTimer( this );
connect( m_overlayHideTimer, SIGNAL( timeout() ), this, SLOT( slotHideOverlay() ) );
m_advanceTimer = new QTimer( this );
connect( m_advanceTimer, SIGNAL( timeout() ), this, SLOT( slotNextPage() ) );
// register this observer in document
m_document->addObserver( this );
......@@ -88,8 +90,15 @@ PresentationWidget::PresentationWidget( KPDFDocument * doc )
else
slotNextPage();
KCursor::setAutoHideCursor( this, true );
KCursor::setHideCursorDelay( 3000 );
if ( Settings::slidesCursor() == Settings::EnumSlidesCursor::HiddenDelay )
{
KCursor::setAutoHideCursor( this, true );
KCursor::setHideCursorDelay( 3000 );
}
else if ( Settings::slidesCursor() == Settings::EnumSlidesCursor::Hidden )
{
setCursor( KCursor::blankCursor() );
}
}
PresentationWidget::~PresentationWidget()
......@@ -338,8 +347,10 @@ void PresentationWidget::generatePage()
m_frames[ m_frameIndex ]->page->getTransition() : 0;
if ( transition )
initTransition( transition );
else
update();
else {
KPDFPageTransition trans = defaultTransition();
initTransition( &trans );
}
}
void PresentationWidget::generateIntroPage( QPainter & p )
......@@ -418,32 +429,7 @@ void PresentationWidget::generateContentsPage( int pageNum, QPainter & p )
for ( uint i = 0; i < rects.count(); i++ )
{
const QRect & r = rects[i];
if ( Settings::slidesShowGrayBack() )
{
// use a vertical gray gradient background
int baseTint = Qt::gray.red(),
blendLevel = 9 * m_height / 10,
blendLeft = r.left(),
blendWidth = r.width();
float blendDiv = (m_height * m_height) / 100; // use 100 to fade to pure white
QColor baseColor( baseTint, baseTint, baseTint );
for ( int i = r.top(); i <= r.bottom(); i++ )
{
if ( i <= blendLevel )
p.fillRect( blendLeft, i, blendWidth, 1, baseColor );
else
{
int k = i - blendLevel;
k = baseTint + (int)( (255-baseTint) * (k * k) / blendDiv );
p.fillRect( blendLeft, i, blendWidth, 1, QColor( baseTint, baseTint, k ) );
}
}
}
else
{
// use the black color that 'crops' images on beamers
p.fillRect( r, Qt::black );
}
p.fillRect( r, Settings::slidesBackgroundColor() );
}
}
......@@ -525,6 +511,13 @@ void PresentationWidget::generateOverlay()
void PresentationWidget::slotNextPage()
{
if ( m_advanceTimer->isActive() )
m_advanceTimer->stop();
// loop when configured
if ( m_frameIndex == (int)m_frames.count() - 1 && Settings::slidesLoop() )
m_frameIndex = -1;
if ( m_frameIndex < (int)m_frames.count() - 1 )
{
// go to next page
......@@ -536,7 +529,11 @@ void PresentationWidget::slotNextPage()
update();
}
// we need the setFocus() call here to let KCursor::autoHide() work correctly
setFocus();
if ( Settings::slidesAdvance() )
m_advanceTimer->start( Settings::slidesAdvanceTime() * 1000 );
}
void PresentationWidget::slotPrevPage()
......@@ -573,6 +570,49 @@ void PresentationWidget::slotTransitionStep()
m_transitionTimer->start( m_transitionDelay, true );
}
const KPDFPageTransition PresentationWidget::defaultTransition() const
{
switch ( Settings::slidesTransition() )
{
case Settings::EnumSlidesTransition::Split:
return KPDFPageTransition( KPDFPageTransition::Split );
break;
case Settings::EnumSlidesTransition::Blinds:
return KPDFPageTransition( KPDFPageTransition::Blinds );
break;
case Settings::EnumSlidesTransition::Box:
return KPDFPageTransition( KPDFPageTransition::Box );
break;
case Settings::EnumSlidesTransition::Wipe:
return KPDFPageTransition( KPDFPageTransition::Wipe );
break;
case Settings::EnumSlidesTransition::Dissolve:
return KPDFPageTransition( KPDFPageTransition::Dissolve );
break;
case Settings::EnumSlidesTransition::Glitter:
return KPDFPageTransition( KPDFPageTransition::Glitter );
break;
case Settings::EnumSlidesTransition::Fly:
return KPDFPageTransition( KPDFPageTransition::Fly );
break;
case Settings::EnumSlidesTransition::Push:
return KPDFPageTransition( KPDFPageTransition::Push );
break;
case Settings::EnumSlidesTransition::Cover:
return KPDFPageTransition( KPDFPageTransition::Cover );