Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
toolbox.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#include "toolbox.h"
19
20#include <cmath>
21
22#include <QToolButton>
23#include <QGridLayout>
24#include <QKeySequence>
25#include <QResizeEvent>
26#include <QDebug>
27#include <QScrollBar>
28#include <QBoxLayout>
29
30#include "basetool.h"
31#include "flowlayout.h"
32#include "spinslider.h"
33#include "editor.h"
34#include "toolmanager.h"
35#include "layermanager.h"
36#include "pencilsettings.h"
37
38ToolBoxDockWidget::ToolBoxDockWidget(QWidget* parent) :
39 BaseDockWidget(parent)
40{
41 mWidget = new ToolBoxWidget(this);
42
43 setWindowTitle(tr("Tools", "Window title of Tools"));
44}
45
46ToolBoxDockWidget::~ToolBoxDockWidget()
47{
48 QSettings settings(PENCIL2D, PENCIL2D);
49 settings.setValue("ToolBoxGeom", this->saveGeometry());
50}
51
52void ToolBoxDockWidget::initUI()
53{
54 mWidget->setEditor(editor());
55 mWidget->initUI();
56
57 setWidget(mWidget);
58 setContentsMargins(0,0,0,0);
59
60 connect(editor()->layers(), &LayerManager::currentLayerChanged, this, &ToolBoxDockWidget::onLayerDidChange);
61
62 QSettings settings(PENCIL2D, PENCIL2D);
63 restoreGeometry(settings.value("ToolBoxGeom").toByteArray());
64
65 // Important to set the proper minimumSize;
66 setMinimumSize(mWidget->minimumSize());
67}
68
69void ToolBoxDockWidget::setActiveTool(ToolType type)
70{
71 mWidget->setActiveTool(type);
72}
73
74void ToolBoxDockWidget::updateUI()
75{
76 mWidget->updateUI();
77}
78
79void ToolBoxDockWidget::onLayerDidChange(int)
80{
81 BaseTool* currentTool = editor()->tools()->currentTool();
82 if (currentTool->type() == MOVE || currentTool->type() == CAMERA)
83 {
84 mWidget->moveOn();
85 }
86}
BaseDockWidget
Definition: basedockwidget.h:27
BaseTool
Definition: basetool.h:47
ToolBoxWidget
Definition: toolboxwidget.h:36
QDockWidget::setWidget
void setWidget(QWidget *widget)
QObject::connect
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QSettings
QWidget
QWidget::setMinimumSize
void setMinimumSize(const QSize &)
QWidget::restoreGeometry
bool restoreGeometry(const QByteArray &geometry)
QWidget::saveGeometry
QByteArray saveGeometry() const const
QWidget::setContentsMargins
void setContentsMargins(int left, int top, int right, int bottom)
Generated on Tue Jan 6 2026 11:38:51 for Pencil2D by doxygen 1.9.6 based on revision f91a96748ec6712509b9b0ff47979db9c34d556f