File indexing completed on 2024-05-19 16:09:35
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2010 Gopalakrishna Bhat A <gopalakbhat@gmail.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "KPrPresentationToolAdaptor.h" 0021 0022 #include "KPrPresentationStrategyBase.h" 0023 #include "KPrPresentationTool.h" 0024 #include "KPrPresentationDrawWidget.h" 0025 #include "KPrPresentationDrawStrategy.h" 0026 #include "KPrPresentationHighlightWidget.h" 0027 #include "KPrPresentationHighlightStrategy.h" 0028 #include "KPrPresentationBlackWidget.h" 0029 #include "KPrPresentationBlackStrategy.h" 0030 #include "KPrViewModePresentation.h" 0031 0032 #include <QMouseEvent> 0033 0034 KPrPresentationToolAdaptor::KPrPresentationToolAdaptor(KPrPresentationTool* tool) 0035 : QDBusAbstractAdaptor(tool) 0036 , m_tool(tool) 0037 , m_viewModePresentation(tool->viewModePresentation()) 0038 { 0039 0040 } 0041 0042 KPrPresentationToolAdaptor::~KPrPresentationToolAdaptor() 0043 { 0044 0045 } 0046 0047 void KPrPresentationToolAdaptor::blankPresentation() 0048 { 0049 if (m_viewModePresentation.isActivated() && ! dynamic_cast<KPrPresentationBlackStrategy *>(m_tool->strategy())) { 0050 m_tool->blackPresentation(); 0051 } 0052 } 0053 0054 void KPrPresentationToolAdaptor::highlightPresentation(int pointx, int pointy) 0055 { 0056 if (m_viewModePresentation.isActivated()) { 0057 if (! dynamic_cast<KPrPresentationHighlightStrategy *>(m_tool->strategy())) { 0058 m_tool->highlightPresentation(); 0059 } 0060 0061 QPoint point(pointx,pointy); 0062 QMouseEvent event(QEvent::MouseMove, point, Qt::NoButton, Qt::LeftButton, Qt::NoModifier); 0063 0064 m_tool->strategy()->widget()->receiveMouseMoveEvent(&event); 0065 } 0066 } 0067 0068 void KPrPresentationToolAdaptor::startDrawPresentation(int pointx, int pointy, int penSize, const QString &color) 0069 { 0070 if (m_viewModePresentation.isActivated()) { 0071 if (! dynamic_cast< KPrPresentationDrawStrategy* >(m_tool->strategy())) { 0072 m_tool->drawOnPresentation(); 0073 KPrPresentationDrawWidget *widget = static_cast< KPrPresentationDrawWidget *>(m_tool->strategy()->widget()); 0074 widget->updateSize(penSize); 0075 widget->updateColor(color); 0076 } 0077 0078 QPoint point(pointx,pointy); 0079 QMouseEvent event(QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); 0080 0081 m_tool->strategy()->widget()->receiveMousePressEvent(&event); 0082 } 0083 } 0084 0085 void KPrPresentationToolAdaptor::drawOnPresentation(int pointx,int pointy) 0086 { 0087 if (m_viewModePresentation.isActivated() && dynamic_cast<KPrPresentationDrawStrategy*>(m_tool->strategy()) ) { 0088 QPoint point(pointx,pointy); 0089 QMouseEvent event(QEvent::MouseMove, point, Qt::NoButton, Qt::LeftButton, Qt::NoModifier); 0090 0091 m_tool->strategy()->widget()->receiveMouseMoveEvent(&event); 0092 } 0093 } 0094 0095 void KPrPresentationToolAdaptor::stopDrawPresentation() { 0096 if (m_viewModePresentation.isActivated()) { 0097 QPoint point(0,0); 0098 QMouseEvent event(QEvent::MouseButtonRelease, point, Qt::NoButton, Qt::LeftButton, Qt::NoModifier); 0099 0100 m_tool->strategy()->widget()->receiveMouseReleaseEvent(&event); 0101 } 0102 } 0103 0104 void KPrPresentationToolAdaptor::normalPresentation() 0105 { 0106 m_tool->normalPresentation(); 0107 }