File indexing completed on 2024-05-12 16:36:46

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007-2009 Thorsten Zachmann <zachmann@kde.org>
0003  * Copyright (C) 2008 Jim Courtiau <jeremy.courtiau@gmail.com>
0004  * Copyright (C) 2009 Alexia Allanic <alexia_allanic@yahoo.fr>
0005  * Copyright (C) 2009 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com>
0006  * Copyright (C) 2009 Jérémy Lugagne <jejewindsurf@hotmail.com>
0007  * Copyright (C) 2009 Johann Hingue <yoan1703@hotmail.fr>
0008  *
0009  * This library is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU Library General Public
0011  * License as published by the Free Software Foundation; either
0012  * version 2 of the License, or (at your option) any later version.
0013  *
0014  * This library is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017  * Library General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU Library General Public License
0020  * along with this library; see the file COPYING.LIB.  If not, write to
0021  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0022  * Boston, MA 02110-1301, USA.
0023  */
0024 #ifndef KPRPRESENTATIONTOOL_H
0025 #define KPRPRESENTATIONTOOL_H
0026 
0027 #include <KoToolBase.h>
0028 
0029 #include <QSet>
0030 
0031 class QFrame;
0032 class KoEventAction;
0033 class KPrViewModePresentation;
0034 class KPrPresentationToolWidget;
0035 class KPrPresentationStrategyBase;
0036 
0037 #ifndef QT_NO_DBUS
0038 class KPrPresentationToolAdaptor;
0039 #endif
0040 
0041 /// The tool used for presentations
0042 class KPrPresentationTool : public KoToolBase
0043 {
0044     Q_OBJECT
0045 public:
0046     explicit KPrPresentationTool( KPrViewModePresentation &viewMode );
0047     ~KPrPresentationTool() override;
0048 
0049     bool wantsAutoScroll() const override;
0050 
0051     void paint( QPainter &painter, const KoViewConverter &converter ) override;
0052 
0053     void mousePressEvent( KoPointerEvent *event ) override;
0054     void mouseDoubleClickEvent( KoPointerEvent *event ) override;
0055     void mouseMoveEvent( KoPointerEvent *event ) override;
0056     void mouseReleaseEvent( KoPointerEvent *event ) override;
0057     void keyPressEvent( QKeyEvent *event ) override;
0058     void keyReleaseEvent( QKeyEvent *event ) override;
0059     void wheelEvent( KoPointerEvent * event ) override;
0060 
0061     KPrPresentationStrategyBase *strategy();
0062     KPrViewModePresentation & viewModePresentation();
0063 
0064 public Q_SLOTS:
0065     void activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes) override;
0066     void deactivate() override;
0067     void highlightPresentation();
0068     void drawOnPresentation();
0069     void blackPresentation();
0070     void normalPresentation();
0071 
0072 private:
0073     void finishEventActions();
0074     void switchStrategy( KPrPresentationStrategyBase * strategy );
0075     bool eventFilter( QObject * obj, QEvent * event ) override;
0076 
0077     /**
0078      * Returns true if shape is a TextShape and event->point is over hyperlink
0079      * @param event the mouse event
0080      * @param shape the shape fhich is searched for hyperlink
0081      * @param hyperLink the string which is filled with hyperlink url
0082      */
0083     bool checkHyperlink(KoPointerEvent *event, KoShape * shape, QString & hyperLink);
0084 
0085     /**
0086      * Runs url string defined inside hyperlink
0087      * @param hyperLink the hyperlink string
0088      */
0089     void runHyperlink(const QString &hyperLink);
0090 
0091     KPrViewModePresentation & m_viewMode;
0092     QSet<KoEventAction *> m_eventActions;
0093 
0094     KPrPresentationToolWidget * m_presentationToolWidget;
0095     QFrame * m_frame;
0096     KPrPresentationStrategyBase * m_strategy;
0097 
0098 #ifndef QT_NO_DBUS
0099     KPrPresentationToolAdaptor *m_bus;
0100 #endif
0101 
0102     friend class KPrPresentationStrategyBase;
0103 };
0104 
0105 #endif /* KPRPRESENTATIONTOOL_H */