File indexing completed on 2024-12-22 04:13:04

0001 /*
0002  * SPDX-FileCopyrightText: 2005 Boudewijn Rempt <boud@valdyas.org>
0003  * SPDX-FileCopyrightText: 2005-2008 Thomas Zander <zander@kde.org>
0004  * SPDX-FileCopyrightText: 2009 Peter Simonsson <peter.simonsson@gmail.com>
0005  * SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net>
0006  * SPDX-FileCopyrightText: 2022 Alvin Wong <alvin@alvinhc.com>
0007  *
0008  * SPDX-License-Identifier: LGPL-2.0-or-later
0009  */
0010 #ifndef _KO_TOOLBOX_DOCKER_H_
0011 #define _KO_TOOLBOX_DOCKER_H_
0012 
0013 #include <kis_mainwindow_observer.h>
0014 
0015 #include <QDockWidget>
0016 
0017 class KoCanvasBase;
0018 class KoToolBox;
0019 class KoToolBoxScrollArea;
0020 
0021 class QMenu;
0022 
0023 class KoToolBoxDocker : public QDockWidget, public KisMainwindowObserver
0024 {
0025     Q_OBJECT
0026 public:
0027     explicit KoToolBoxDocker(KoToolBox *toolBox);
0028 
0029     /// reimplemented from KoCanvasObserverBase
0030     void setCanvas(KoCanvasBase *canvas) override;
0031     void unsetCanvas() override;
0032     QString observerName() override { return "KoToolBoxDocker"; }
0033     /// reimplemented from KisMainwindowObserver
0034     void setViewManager(KisViewManager *viewManager) override;
0035 
0036 protected:
0037     void resizeEvent(QResizeEvent *event) override;
0038     void contextMenuEvent(QContextMenuEvent *event) override;
0039 
0040 protected Q_SLOTS:
0041     void updateToolBoxOrientation(Qt::DockWidgetArea area);
0042     void updateFloating(bool);
0043 
0044 private:
0045     void setToolBoxOrientation(Qt::Orientation orientation);
0046     void updateLayoutDir();
0047     void changeLayoutDir(Qt::LayoutDirection);
0048 
0049 private:
0050     KoToolBox *m_toolBox;
0051     KoToolBoxScrollArea *m_scrollArea;
0052     QMenu *m_contextMenu {nullptr};
0053     Qt::DockWidgetArea m_dockArea {Qt::NoDockWidgetArea};
0054     Qt::LayoutDirection m_layoutDir;
0055 };
0056 
0057 #endif // _KO_TOOLBOX_DOCKER_H_