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 "flowlayout.h"
31#include "spinslider.h"
32#include "editor.h"
33#include "toolmanager.h"
34#include "layermanager.h"
35#include "pencilsettings.h"
36
37ToolBoxDockWidget::ToolBoxDockWidget(QWidget* parent) :
38 BaseDockWidget(parent)
39{
40 mWidget = new ToolBoxWidget(this);
41
42 setWindowTitle(tr("Tools", "Window title of Tools"));
43}
44
45ToolBoxDockWidget::~ToolBoxDockWidget()
46{
47 QSettings settings(PENCIL2D, PENCIL2D);
48 settings.setValue("ToolBoxGeom", this->saveGeometry());
49}
50
51void ToolBoxDockWidget::initUI()
52{
53 mWidget->setEditor(editor());
54 mWidget->initUI();
55
56 setWidget(mWidget);
57 setContentsMargins(0,0,0,0);
58
59 connect(editor()->layers(), &LayerManager::currentLayerChanged, this, &ToolBoxDockWidget::onLayerDidChange);
60
61 QSettings settings(PENCIL2D, PENCIL2D);
62 restoreGeometry(settings.value("ToolBoxGeom").toByteArray());
63
64 // Important to set the proper minimumSize;
65 setMinimumSize(mWidget->minimumSize());
66}
67
68void ToolBoxDockWidget::setActiveTool(ToolType type)
69{
70 mWidget->setActiveTool(type);
71}
72
73void ToolBoxDockWidget::updateUI()
74{
75 mWidget->updateUI();
76}
77
78void ToolBoxDockWidget::onLayerDidChange(int)
79{
80 BaseTool* currentTool = editor()->tools()->currentTool();
81 if (currentTool->type() == MOVE || currentTool->type() == CAMERA)
82 {
83 mWidget->moveOn();
84 }
85}
BaseDockWidget
Definition: basedockwidget.h:27
BaseTool
Definition: basetool.h:70
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 Thu Jun 5 2025 14:06:43 for Pencil2D by doxygen 1.9.6 based on revision 4c63407997b2c03e5048716586dec6fbbb755173