00001 /* This file is part of the KDE project 00002 * Copyright (C) 2006 Thomas Zander <zander@kde.org> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "KoToolManager_p.h" 00021 00022 #include <KoShapeManager.h> 00023 #include <KoSelection.h> 00024 #include <KoToolFactory.h> 00025 #include <QToolButton> 00026 #include <kicon.h> 00027 00028 #include <stdlib.h> // for random() 00029 00030 // ************ ToolHelper ********** 00031 ToolHelper::ToolHelper(KoToolFactory *tool) { 00032 m_toolFactory = tool; 00033 m_uniqueId = (int) random(); 00034 } 00035 00036 QAbstractButton* ToolHelper::createButton() { 00037 QToolButton *but = new QToolButton(); 00038 but->setIcon(KIcon( m_toolFactory->icon() ).pixmap(22)); 00039 but->setToolTip(m_toolFactory->toolTip()); 00040 connect(but, SIGNAL(clicked()), this, SLOT(buttonPressed())); 00041 return but; 00042 } 00043 00044 void ToolHelper::buttonPressed() { 00045 emit toolActivated(this); 00046 } 00047 00048 const QString &ToolHelper::id() const { 00049 return m_toolFactory->toolId(); 00050 } 00051 00052 const QString &ToolHelper::activationShapeId() const { 00053 return m_toolFactory->activationShapeId(); 00054 } 00055 00056 const QString& ToolHelper::name() const { 00057 return m_toolFactory->name(); 00058 } 00059 00060 KoTool *ToolHelper::createTool(KoCanvasBase *canvas) const { 00061 return m_toolFactory->createTool(canvas); 00062 } 00063 00064 const QString &ToolHelper::toolType() const { 00065 return m_toolFactory->toolType(); 00066 } 00067 00068 int ToolHelper::priority() const { 00069 return m_toolFactory->priority(); 00070 } 00071 00072 00073 // ************ Connector ********** 00074 Connector::Connector(KoShapeManager *parent) 00075 : QObject(parent), 00076 m_shapeManager(parent) 00077 { 00078 connect(m_shapeManager, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); 00079 } 00080 00081 void Connector::selectionChanged() { 00082 emit selectionChanged(m_shapeManager->selection()->selectedShapes().toList()); 00083 } 00084 00085 #include "KoToolManager_p.moc"