Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
/*
* SPDX-FileCopyrightText: 2005 Boudewijn Rempt <[email protected]>
* SPDX-FileCopyrightText: 2005-2008 Thomas Zander <[email protected]>
* SPDX-FileCopyrightText: 2009 Peter Simonsson <[email protected]>
* SPDX-FileCopyrightText: 2010 Cyrille Berger <[email protected]>
* SPDX-FileCopyrightText: 2022 Alvin Wong <[email protected]>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef _KO_TOOLBOX_H_
#define _KO_TOOLBOX_H_
#include <KoCanvasObserverBase.h>
#include <QWidget>
#include <QList>
#include <KoToolManager.h>
class KisViewManager;
class KoCanvasController;
class KoShapeLayer;
class KoToolBoxLayout;
/**
* KoToolBox is a dock widget that can order tools according to type and
* priority.
*
* The ToolBox is a container for tool buttons which are themselves
* divided into sections.
*
* Adding buttons using addButton() will allow you to show those buttons. You should connect
* the button to your handling method yourself.
*
* The unique property of this toolbox is that it can be shown horizontal as well as vertical,
* rotating in a smart way to show the buttons optimally.
* @see KoToolManager
*/
class KoToolBox : public QWidget {
Q_OBJECT
public:
/// constructor
explicit KoToolBox();
~KoToolBox() override;
void applyIconSize();
void setViewManager(KisViewManager *viewManager);
public Q_SLOTS:
/**
* Set the new active button based on the currently active tool.
* @param canvas the currently active canvas.
*/
void setActiveTool(KoCanvasController *canvas);
/**
* Show only the dynamic buttons that have a code from parameter codes.
* The toolbox allows buttons to be optionally registered with a visibilityCode. This code
* can be passed here and all buttons that have that code are shown. All buttons that
* have another visibility code registered are hidden.
* @param codes a list of all the codes to show.
*/
void setButtonsVisible(const QList<QString> &codes);
/// Set the orientation of the layout to @p orientation
void setOrientation(Qt::Orientation orientation);
void setCompact(bool);
bool isCompact();
void setFloating(bool v);
KoToolBoxLayout *toolBoxLayout() const;
private:
/**
* Add a button to the toolbox.
* The buttons should all be added before the first showing since adding will not really add
* them to the UI until setup() is called.
*
* @param toolAction the action of the tool
* @see setup()
*/
void addButton(KoToolAction *toolAction);
/// Resets visibility of all buttons
void resetButtonVisibility();
/// Disables all buttons who's names are in the provided list
void disableButtonsByName(QList<QString> names);
private Q_SLOTS:
void setCurrentLayer(const KoCanvasController *canvas, const KoShapeLayer* newLayer);
/// add a tool post-initialization. The tool will also be activated.
void toolAdded(KoToolAction *toolAction, KoCanvasController *canvas);
/// set the icon size for all the buttons
void slotContextIconSize();
protected:
void paintEvent(QPaintEvent *event) override;
void changeEvent(QEvent *event) override;
private:
void setupIconSizeMenu(QMenu *menu);
friend class KoToolBoxDocker;
private:
class Private;
Private * const d;
};
#endif // _KO_TOOLBOX_H_