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.
|
|
|
|
*/
|
|
|
|
|
2009-12-27 23:16:11 +01:00
|
|
|
#ifndef PLASMA_INTERNALTOOLBOX_P_H
|
|
|
|
#define PLASMA_INTERNALTOOLBOX_P_H
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-10-07 19:08:44 +02:00
|
|
|
#include <QGraphicsWidget>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2008-11-14 08:28:02 +01:00
|
|
|
#include "containment.h"
|
2009-10-20 16:14:53 +02:00
|
|
|
#include "abstracttoolbox.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
|
|
|
|
{
|
|
|
|
|
2010-01-04 07:41:43 +01:00
|
|
|
class IconWidget;
|
2009-10-20 16:14:53 +02:00
|
|
|
class InternalToolBoxPrivate;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2009-10-20 16:14:53 +02:00
|
|
|
class InternalToolBox : public AbstractToolBox
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2009-09-20 14:53:16 +02:00
|
|
|
Q_INTERFACES(QGraphicsItem)
|
2008-11-04 00:08:39 +01:00
|
|
|
public:
|
|
|
|
enum Corner {
|
|
|
|
Top = 0,
|
|
|
|
TopRight,
|
|
|
|
TopLeft,
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
Bottom,
|
|
|
|
BottomRight,
|
|
|
|
BottomLeft
|
|
|
|
};
|
|
|
|
|
2009-10-20 16:14:53 +02:00
|
|
|
explicit InternalToolBox(Containment *parent);
|
|
|
|
~InternalToolBox();
|
2008-11-04 00:08:39 +01: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);
|
|
|
|
int size() const;
|
|
|
|
void setSize(const int newSize);
|
|
|
|
QSize iconSize() const;
|
|
|
|
void setIconSize(const QSize newSize);
|
2009-10-20 16:14:53 +02:00
|
|
|
bool isShowing() const;
|
2008-11-04 00:08:39 +01:00
|
|
|
void setShowing(const bool show);
|
2009-10-20 16:14:53 +02:00
|
|
|
|
2010-01-04 07:41:43 +01:00
|
|
|
virtual QGraphicsWidget *toolParent();
|
|
|
|
|
2009-10-20 16:14:53 +02:00
|
|
|
virtual void setCorner(const Corner corner);
|
|
|
|
virtual Corner corner() const;
|
2008-11-04 00:08:39 +01:00
|
|
|
|
2008-11-10 04:53:35 +01:00
|
|
|
bool isMovable() const;
|
|
|
|
void setIsMovable(bool movable);
|
|
|
|
|
2008-11-14 08:28:02 +01:00
|
|
|
void save(KConfigGroup &cg) const;
|
2010-01-27 00:35:32 +01:00
|
|
|
void restore(const KConfigGroup &containmentGroup = KConfigGroup());
|
2008-11-14 08:28:02 +01:00
|
|
|
void reposition();
|
|
|
|
|
2009-07-28 05:19:33 +02:00
|
|
|
virtual QSize fullWidth() const;
|
|
|
|
virtual QSize fullHeight() const;
|
|
|
|
virtual QSize cornerSize() const;
|
|
|
|
|
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
|
|
|
|
*/
|
2010-01-26 07:06:43 +01:00
|
|
|
virtual void updateToolBox();
|
2009-01-28 14:38:57 +01:00
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
protected:
|
2009-10-07 19:08:44 +02:00
|
|
|
Containment *containment();
|
2008-11-04 00:08:39 +01:00
|
|
|
QPoint toolPosition(int toolHeight);
|
2010-01-04 07:41:43 +01:00
|
|
|
QMap<AbstractToolBox::ToolType, IconWidget *> tools() const;
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
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:
|
2009-10-20 16:14:53 +02:00
|
|
|
InternalToolBoxPrivate *d;
|
2008-11-04 00:08:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
2009-12-27 23:16:11 +01:00
|
|
|
|
|
|
|
#endif // PLASMA_INTERNALTOOLBOX_P_H
|
2008-11-04 00:08:39 +01:00
|
|
|
|