19 #include "ui_toolboxwidget.h"
23 #include <QToolButton>
24 #include <QGridLayout>
25 #include <QKeySequence>
26 #include <QResizeEvent>
28 #include "flowlayout.h"
29 #include "spinslider.h"
31 #include "toolmanager.h"
32 #include "pencilsettings.h"
37 strCommandName =
QString(
"shortcuts/") + strCommandName;
42 ToolBoxWidget::ToolBoxWidget(
QWidget* parent) :
49 ToolBoxWidget::~ToolBoxWidget()
56 void ToolBoxWidget::initUI()
61 "QToolButton { border: 0px; }"
62 "QToolButton:pressed { border: 1px solid #ADADAD; border-radius: 2px; background-color: #D5D5D5; }"
63 "QToolButton:checked { border: 1px solid #ADADAD; border-radius: 2px; background-color: #D5D5D5; }";
64 ui->pencilButton->setStyleSheet(sStyle);
65 ui->selectButton->setStyleSheet(sStyle);
66 ui->moveButton->setStyleSheet(sStyle);
67 ui->handButton->setStyleSheet(sStyle);
68 ui->penButton->setStyleSheet(sStyle);
69 ui->eraserButton->setStyleSheet(sStyle);
70 ui->polylineButton->setStyleSheet(sStyle);
71 ui->bucketButton->setStyleSheet(sStyle);
72 ui->brushButton->setStyleSheet(sStyle);
73 ui->eyedropperButton->setStyleSheet(sStyle);
74 ui->clearButton->setStyleSheet(sStyle);
75 ui->smudgeButton->setStyleSheet(sStyle);
78 ui->pencilButton->setToolTip(
tr(
"Pencil Tool (%1): Sketch with pencil" )
79 .arg( GetToolTips( CMD_TOOL_PENCIL ) ) );
80 ui->selectButton->setToolTip(
tr(
"Select Tool (%1): Select an object" )
81 .arg( GetToolTips( CMD_TOOL_SELECT ) ) );
82 ui->moveButton->setToolTip(
tr(
"Move Tool (%1): Move an object" )
83 .arg( GetToolTips( CMD_TOOL_MOVE ) ) );
84 ui->handButton->setToolTip(
tr(
"Hand Tool (%1): Move the canvas" )
85 .arg( GetToolTips( CMD_TOOL_HAND ) ) );
86 ui->penButton->setToolTip(
tr(
"Pen Tool (%1): Sketch with pen" )
87 .arg( GetToolTips( CMD_TOOL_PEN ) ) );
88 ui->eraserButton->setToolTip(
tr(
"Eraser Tool (%1): Erase" )
89 .arg( GetToolTips( CMD_TOOL_ERASER ) ) );
90 ui->polylineButton->setToolTip(
tr(
"Polyline Tool (%1): Create line/curves" )
91 .arg( GetToolTips( CMD_TOOL_POLYLINE ) ) );
92 ui->bucketButton->setToolTip(
tr(
"Paint Bucket Tool (%1): Fill selected area with a color" )
93 .arg( GetToolTips( CMD_TOOL_BUCKET ) ) );
94 ui->brushButton->setToolTip(
tr(
"Brush Tool (%1): Paint smooth stroke with a brush" )
95 .arg( GetToolTips( CMD_TOOL_BRUSH ) ) );
96 ui->eyedropperButton->setToolTip(
tr(
"Eyedropper Tool (%1): "
97 "Set color from the stage<br>[ALT] for instant access" )
98 .arg( GetToolTips( CMD_TOOL_EYEDROPPER ) ) );
99 ui->clearButton->setToolTip(
tr(
"Clear Frame (%1): Erases content of selected frame" )
100 .arg( GetToolTips( CMD_CLEAR_FRAME ) ) );
101 ui->smudgeButton->setToolTip(
tr(
"Smudge Tool (%1):<br>Edit polyline/curves<br>"
102 "Liquify bitmap pixels<br> (%1)+[Alt]: Smooth" )
103 .arg( GetToolTips( CMD_TOOL_SMUDGE ) ) );
105 ui->pencilButton->setWhatsThis(
tr(
"Pencil Tool (%1)" )
106 .arg( GetToolTips( CMD_TOOL_PENCIL ) ) );
107 ui->selectButton->setWhatsThis(
tr(
"Select Tool (%1)" )
108 .arg( GetToolTips( CMD_TOOL_SELECT ) ) );
109 ui->moveButton->setWhatsThis(
tr(
"Move Tool (%1)" )
110 .arg( GetToolTips( CMD_TOOL_MOVE ) ) );
111 ui->handButton->setWhatsThis(
tr(
"Hand Tool (%1)" )
112 .arg( GetToolTips( CMD_TOOL_HAND ) ) );
113 ui->penButton->setWhatsThis(
tr(
"Pen Tool (%1)" )
114 .arg( GetToolTips( CMD_TOOL_PEN ) ) );
115 ui->eraserButton->setWhatsThis(
tr(
"Eraser Tool (%1)" )
116 .arg( GetToolTips( CMD_TOOL_ERASER ) ) );
117 ui->polylineButton->setWhatsThis(
tr(
"Polyline Tool (%1)" )
118 .arg( GetToolTips( CMD_TOOL_POLYLINE ) ) );
119 ui->bucketButton->setWhatsThis(
tr(
"Paint Bucket Tool (%1)" )
120 .arg( GetToolTips( CMD_TOOL_BUCKET ) ) );
121 ui->brushButton->setWhatsThis(
tr(
"Brush Tool (%1)" )
122 .arg( GetToolTips( CMD_TOOL_BRUSH ) ) );
123 ui->eyedropperButton->setWhatsThis(
tr(
"Eyedropper Tool (%1)" )
124 .arg( GetToolTips( CMD_TOOL_EYEDROPPER ) ) );
125 ui->clearButton->setWhatsThis(
tr(
"Clear Tool (%1)" )
126 .arg( GetToolTips( CMD_CLEAR_FRAME ) ) );
127 ui->smudgeButton->setWhatsThis(
tr(
"Smudge Tool (%1)" )
128 .arg( GetToolTips( CMD_TOOL_SMUDGE ) ) );
152 flowlayout->
addWidget(ui->polylineButton);
154 flowlayout->
addWidget(ui->eyedropperButton);
158 delete ui->scrollAreaWidgetContents_2->layout();
159 ui->scrollAreaWidgetContents_2->setLayout(flowlayout);
165 void ToolBoxWidget::updateUI()
169 void ToolBoxWidget::pencilOn()
171 if (!leavingTool(ui->pencilButton)) {
return; }
173 editor()->tools()->setCurrentTool(PENCIL);
176 ui->pencilButton->setChecked(
true);
179 void ToolBoxWidget::eraserOn()
181 if (!leavingTool(ui->eraserButton)) {
return; }
183 editor()->tools()->setCurrentTool(ERASER);
186 ui->eraserButton->setChecked(
true);
189 void ToolBoxWidget::selectOn()
191 if (!leavingTool(ui->selectButton)) {
return; }
193 editor()->tools()->setCurrentTool(SELECT);
196 ui->selectButton->setChecked(
true);
199 void ToolBoxWidget::moveOn()
201 if (!leavingTool(ui->moveButton)) {
return; }
203 editor()->tools()->setCurrentTool(MOVE);
206 ui->moveButton->setChecked(
true);
209 void ToolBoxWidget::penOn()
211 if (!leavingTool(ui->penButton)) {
return; }
213 editor()->tools()->setCurrentTool(PEN);
216 ui->penButton->setChecked(
true);
219 void ToolBoxWidget::handOn()
221 if (!leavingTool(ui->handButton)) {
return; }
223 editor()->tools()->setCurrentTool( HAND );
226 ui->handButton->setChecked(
true);
229 void ToolBoxWidget::polylineOn()
231 if (!leavingTool(ui->polylineButton)) {
return; }
233 editor()->tools()->setCurrentTool(POLYLINE);
236 ui->polylineButton->setChecked(
true);
239 void ToolBoxWidget::bucketOn()
241 if (!leavingTool(ui->bucketButton)) {
return; }
243 editor()->tools()->setCurrentTool(BUCKET);
246 ui->bucketButton->setChecked(
true);
249 void ToolBoxWidget::eyedropperOn()
251 if (!leavingTool(ui->eyedropperButton)) {
return; }
252 editor()->tools()->setCurrentTool(EYEDROPPER);
255 ui->eyedropperButton->setChecked(
true);
258 void ToolBoxWidget::brushOn()
260 if (!leavingTool(ui->brushButton)) {
return; }
262 editor()->tools()->setCurrentTool( BRUSH );
265 ui->brushButton->setChecked(
true);
268 void ToolBoxWidget::smudgeOn()
270 if (!leavingTool(ui->smudgeButton)) {
return; }
271 editor()->tools()->setCurrentTool(SMUDGE);
274 ui->smudgeButton->setChecked(
true);
277 int ToolBoxWidget::getMinHeightForWidth(
int width)
279 return ui->toolGroup->layout()->heightForWidth(width);
282 void ToolBoxWidget::deselectAllTools()
284 ui->pencilButton->setChecked(
false);
285 ui->eraserButton->setChecked(
false);
286 ui->selectButton->setChecked(
false);
287 ui->moveButton->setChecked(
false);
288 ui->handButton->setChecked(
false);
289 ui->penButton->setChecked(
false);
290 ui->polylineButton->setChecked(
false);
291 ui->bucketButton->setChecked(
false);
292 ui->eyedropperButton->setChecked(
false);
293 ui->brushButton->setChecked(
false);
294 ui->smudgeButton->setChecked(
false);
297 bool ToolBoxWidget::leavingTool(
QToolButton* toolButton)
299 if (!editor()->tools()->leavingThisTool())
QString tr(const char *sourceText, const char *disambiguation, int n)
char * toString(const T &value)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
void keySequence(QWindow *window, const QKeySequence &keySequence)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)