2008-04-14 15:05:49 +02: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.
|
2008-05-24 03:48:36 +02:00
|
|
|
|
2008-04-14 15:05:49 +02:00
|
|
|
* 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-04-25 05:23:31 +02:00
|
|
|
#include "animator.h"
|
2008-04-14 15:05:49 +02:00
|
|
|
|
2008-05-24 03:48:36 +02:00
|
|
|
class QAction;
|
|
|
|
|
2008-04-14 15:05:49 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-05-24 03:48:36 +02:00
|
|
|
//class Widget;
|
|
|
|
//class EmptyGraphicsItem;
|
2008-07-01 20:56:43 +02:00
|
|
|
class ToolBoxPrivate;
|
2008-04-14 15:05:49 +02:00
|
|
|
|
2008-05-24 14:25:56 +02:00
|
|
|
class ToolBox : public QObject, public QGraphicsItem
|
2008-04-14 15:05:49 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2008-08-28 17:59:03 +02:00
|
|
|
/**
|
|
|
|
* These flags represents what borders should be drawn
|
|
|
|
*/
|
2008-10-12 01:28:20 +02:00
|
|
|
enum Corner {
|
|
|
|
Top = 0,
|
|
|
|
TopRight,
|
|
|
|
TopLeft,
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
Bottom,
|
|
|
|
BottomRight,
|
|
|
|
BottomLeft
|
|
|
|
};
|
2008-08-28 17:59:03 +02:00
|
|
|
|
2008-05-24 14:25:56 +02:00
|
|
|
explicit ToolBox(QGraphicsItem *parent = 0);
|
|
|
|
~ToolBox();
|
2008-04-14 15:05:49 +02:00
|
|
|
|
2008-05-24 03:48:36 +02:00
|
|
|
/**
|
|
|
|
* 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);
|
2008-04-14 15:05:49 +02:00
|
|
|
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-08-28 17:59:03 +02:00
|
|
|
void setCorner(Corner corner);
|
|
|
|
Corner corner() const;
|
2008-04-14 15:05:49 +02:00
|
|
|
|
2008-05-24 14:25:56 +02:00
|
|
|
virtual void showToolBox() = 0;
|
|
|
|
virtual void hideToolBox() = 0;
|
2008-05-24 03:48:36 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
|
|
|
* re-show the toolbox, in case any tools have changed
|
|
|
|
*/
|
2008-05-24 14:25:56 +02:00
|
|
|
void updateToolBox();
|
2008-04-26 19:31:49 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void toggled();
|
|
|
|
|
2008-04-14 15:05:49 +02:00
|
|
|
protected:
|
2008-08-28 17:59:03 +02:00
|
|
|
QPoint toolPosition(int toolHeight);
|
2008-04-26 19:31:49 +02:00
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
2008-04-14 15:05:49 +02:00
|
|
|
|
|
|
|
private:
|
2008-07-01 20:56:43 +02:00
|
|
|
ToolBoxPrivate *d;
|
2008-04-14 15:05:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
#endif // multiple inclusion guard
|
|
|
|
|