2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2008 by Marco Martin <notmart@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_TOOLBOX_P_H
|
|
|
|
#define PLASMA_TOOLBOX_P_H
|
|
|
|
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
#include <QObject>
|
|
|
|
|
2008-11-14 08:28:02 +01:00
|
|
|
#include "containment.h"
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
class QAction;
|
|
|
|
|
2008-11-14 08:28:02 +01:00
|
|
|
class KConfigGroup;
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
//class Widget;
|
|
|
|
//class EmptyGraphicsItem;
|
|
|
|
class ToolBoxPrivate;
|
|
|
|
|
|
|
|
class ToolBox : public QObject, public QGraphicsItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* These flags represents what borders should be drawn
|
|
|
|
*/
|
|
|
|
enum Corner {
|
|
|
|
Top = 0,
|
|
|
|
TopRight,
|
|
|
|
TopLeft,
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
Bottom,
|
|
|
|
BottomRight,
|
|
|
|
BottomLeft
|
|
|
|
};
|
|
|
|
|
2008-11-14 08:28:02 +01:00
|
|
|
explicit ToolBox(Containment *parent);
|
2008-11-04 00:08:39 +01:00
|
|
|
~ToolBox();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* create a toolbox tool from the given action
|
|
|
|
* @p action the action to associate hte tool with
|
|
|
|
*/
|
|
|
|
void addTool(QAction *action);
|
|
|
|
/**
|
|
|
|
* remove the tool associated with this action
|
|
|
|
*/
|
|
|
|
void removeTool(QAction *action);
|
|
|
|
int size() const;
|
|
|
|
void setSize(const int newSize);
|
|
|
|
QSize iconSize() const;
|
|
|
|
void setIconSize(const QSize newSize);
|
|
|
|
bool showing() const;
|
|
|
|
void setShowing(const bool show);
|
2008-11-24 18:39:03 +01:00
|
|
|
void setCorner(const Corner corner);
|
2008-11-04 00:08:39 +01:00
|
|
|
Corner corner() const;
|
|
|
|
|
2008-11-10 04:53:35 +01:00
|
|
|
bool isMovable() const;
|
|
|
|
void setIsMovable(bool movable);
|
|
|
|
|
2008-11-28 18:32:21 +01:00
|
|
|
bool isToolbar() const;
|
|
|
|
void setIsToolbar(bool toolbar);
|
|
|
|
|
|
|
|
QTransform viewTransform() const;
|
2009-07-16 15:09:19 +02:00
|
|
|
void setViewTransform(const QTransform &transform);
|
2008-11-28 18:32:21 +01:00
|
|
|
|
2008-11-14 08:28:02 +01:00
|
|
|
void save(KConfigGroup &cg) const;
|
2009-06-11 22:04:10 +02:00
|
|
|
void load(const KConfigGroup &containmentGroup = KConfigGroup());
|
2008-11-14 08:28:02 +01:00
|
|
|
void reposition();
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
virtual void showToolBox() = 0;
|
|
|
|
virtual void hideToolBox() = 0;
|
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* re-show the toolbox, in case any tools have changed
|
|
|
|
*/
|
|
|
|
void updateToolBox();
|
2009-01-28 14:38:57 +01:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
void toggled();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QPoint toolPosition(int toolHeight);
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
2008-11-10 04:53:35 +01:00
|
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
2008-11-04 00:08:39 +01:00
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
2009-01-28 14:38:57 +01:00
|
|
|
protected Q_SLOTS:
|
|
|
|
virtual void toolTriggered(bool);
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
private:
|
|
|
|
ToolBoxPrivate *d;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
#endif // multiple inclusion guard
|
|
|
|
|