Warning, file /office/calligra/libs/widgets/KoModeBox_p.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
0003  * Copyright (c) 2005-2008 Thomas Zander <zander@kde.org>
0004  * Copyright (c) 2009 Peter Simonsson <peter.simonsson@gmail.com>
0005  * Copyright (c) 2010 Cyrille Berger <cberger@cberger.net>
0006  * Copyright (c) 2011 C. Boemann <cbo@boemann.dk>
0007  *
0008  * This library is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Library General Public
0010  * License as published by the Free Software Foundation; either
0011  * version 2 of the License, or (at your option) any later version.
0012  *
0013  * This library is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * Library General Public License for more details.
0017  *
0018  * You should have received a copy of the GNU Library General Public License
0019  * along with this library; see the file COPYING.LIB.  If not, write to
0020  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021  * Boston, MA 02110-1301, USA.
0022  */
0023 #ifndef KO_MODEBOX_H
0024 #define KO_MODEBOX_H
0025 
0026 #include <KoCanvasObserverBase.h>
0027 
0028 #include <QPointer>
0029 #include <QList>
0030 #include <QMap>
0031 #include <QHash>
0032 #include <QDockWidget>
0033 #include <QScrollArea>
0034 
0035 #include <KoToolManager.h>
0036 
0037 class KoCanvasControllerWidget;
0038 class KoCanvasController;
0039 class KoCanvasBase;
0040 class KoShapeLayer;
0041 
0042 class ScrollArea : public QScrollArea
0043 {
0044     Q_OBJECT
0045 protected:
0046     void showEvent(QShowEvent *) override;
0047 };
0048 
0049 /**
0050  * KoModeBox is housed in a dock widget that presents tools as headings in a QToolBox
0051  * according to type and priority.
0052  *
0053  * The ModeBox is a container for tool buttons which are themselves
0054  * divided into sections.
0055  *
0056  * @see KoToolManager
0057  */
0058 class KoModeBox : public QWidget {
0059     Q_OBJECT
0060 public:
0061     /// constructor
0062     explicit KoModeBox(KoCanvasControllerWidget *canvas, const QString &applicationName);
0063     ~KoModeBox() override;
0064 
0065     /**
0066      * Should been called when the docker position has changed.
0067      * Organise widgets and icons and orientation of the tabs.
0068      *
0069      * @param area the new location area
0070      */
0071     void locationChanged(Qt::DockWidgetArea area);
0072 public Q_SLOTS:
0073     /**
0074      * Using the buttongroup id passed in addButton() you can set the new active tool.
0075      * If the id does not resolve to a visible heading, this call is ignored.
0076      * @param canvas the currently active canvas.
0077      * @param id an id to identify the tool/heading to activate.
0078      */
0079     void setActiveTool(KoCanvasController *canvas, int id);
0080 
0081     /**
0082      * Show only the dynamic buttons that have a code from parameter codes.
0083      * The modebox allows buttons to be optionally registered with a visibilityCode. This code
0084      * can be passed here and all buttons that have that code are shown. All buttons that
0085      * have another visibility code registered are hidden.
0086      * @param codes a list of all the codes to show.
0087      */
0088     void updateShownTools(const QList<QString> &codes);
0089 
0090     void setOptionWidgets(const QList<QPointer<QWidget> > &optionWidgetList);
0091 
0092     /// set the canvas this docker should listen to for changes.
0093     void setCanvas(KoCanvasBase *canvas);
0094     void unsetCanvas();
0095 
0096 private Q_SLOTS:
0097     void setCurrentLayer(const KoCanvasController *canvas, const KoShapeLayer* newLayer);
0098 
0099     /// add a tool post-initialization. The tool will also be activated.
0100     void toolAdded(KoToolAction *toolAction, KoCanvasController *canvas);
0101 
0102     /// slot for when a new item have been selected in the QToolBox
0103     void toolSelected(int index);
0104 
0105     /// slot for context menu of the tabbar
0106     void slotContextMenuRequested(const QPoint &pos);
0107 
0108     /// switch icon mode
0109     void switchIconMode(int);
0110 
0111     /// switch tabs side
0112     void switchTabsSide(int);
0113 
0114     /**
0115      * Add a tool to the modebox.
0116      * The tools should all be added before the first showing since adding will not really add
0117      * them to the UI until setup() is called.
0118      *
0119      * @param toolAction the action of the tool
0120      * @see setup()
0121      */
0122     void addToolAction(KoToolAction *toolAction);
0123 
0124 public:
0125     static QString applicationName;
0126 
0127 private:
0128     enum IconMode {
0129         IconAndText,
0130         IconOnly
0131     };
0132 
0133     enum VerticalTabsSide {
0134         TopSide,
0135         BottomSide
0136     };
0137 
0138     enum HorizontalTabsSide {
0139         LeftSide,
0140         RightSide
0141     };
0142 
0143     QIcon createTextIcon(KoToolAction *toolAction) const;
0144     QIcon createSimpleIcon(KoToolAction *toolAction) const;
0145     void addItem(KoToolAction *toolAction);
0146     void setIconSize() const;
0147 
0148 private:
0149     class Private;
0150     Private * const d;
0151 };
0152 
0153 #endif // _KO_TOOLBOX_H_