17#include "tooloptionwidget.h"
18#include "ui_tooloptions.h"
23#include "cameraoptionswidget.h"
24#include "bucketoptionswidget.h"
25#include "strokeoptionswidget.h"
26#include "transformoptionswidget.h"
27#include "spinslider.h"
31#include "layermanager.h"
32#include "stroketool.h"
33#include "toolmanager.h"
34#include "basewidget.h"
39 setWindowTitle(tr(
"Options",
"Window title of tool option panel like pen width, feather etc.."));
42 setWidget(innerWidget);
43 ui =
new Ui::ToolOptions;
44 ui->setupUi(innerWidget);
47ToolOptionWidget::~ToolOptionWidget()
52void ToolOptionWidget::initUI()
62 ui->scrollAreaWidgetContents->layout()->addWidget(mBucketOptionsWidget);
63 ui->scrollAreaWidgetContents->layout()->addWidget(mCameraOptionsWidget);
64 ui->scrollAreaWidgetContents->layout()->addWidget(mStrokeOptionsWidget);
65 ui->scrollAreaWidgetContents->layout()->addWidget(mTransformOptionsWidget);
68 makeConnectionToEditor(editor());
72void ToolOptionWidget::updateUI()
74 BaseTool* currentTool = editor()->tools()->currentTool();
75 Q_ASSERT(currentTool);
77 updateUIForTool(currentTool);
80void ToolOptionWidget::makeConnectionToEditor(
Editor* editor)
82 connect(editor->tools(), &ToolManager::toolChanged,
this, &ToolOptionWidget::onToolChanged);
83 connect(editor->tools(), &ToolManager::toolsReset,
this, &ToolOptionWidget::onToolsReset);
84 connect(editor->layers(), &LayerManager::currentLayerChanged,
this, &ToolOptionWidget::onLayerChanged);
87void ToolOptionWidget::setWidgetVisibility(
BaseWidget* widget,
bool isVisible)
96void ToolOptionWidget::updateUIForTool(
BaseTool* tool)
98 setWidgetVisibility(mBucketOptionsWidget, tool->type() == BUCKET);
99 setWidgetVisibility(mCameraOptionsWidget, tool->type() == CAMERA);
100 setWidgetVisibility(mStrokeOptionsWidget, editor()->tools()->isStrokeTool(tool));
101 setWidgetVisibility(mTransformOptionsWidget, editor()->tools()->isTransformTool(tool));
104void ToolOptionWidget::onLayerChanged(
int layerIndex)
107 Layer* layer = layerManager->getLayer(layerIndex);
108 if (layer->type() != layerManager->currentLayer()->type()) {
112 updateUIForTool(editor()->tools()->currentTool());
115void ToolOptionWidget::onToolChanged(ToolType toolType)
117 BaseTool* tool = editor()->tools()->getTool(toolType);
118 updateUIForTool(tool);
121void ToolOptionWidget::onToolsReset()
123 updateUIForTool(editor()->tools()->currentTool());
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)