3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <kpMainWindow.h>
30 #include <kpMainWindowPrivate.h>
32 #include <QActionGroup>
35 #include <kapplication.h>
36 #include <kactioncollection.h>
38 #include <kconfiggroup.h>
43 #include <kpColorToolBar.h>
44 #include <kpCommandHistory.h>
45 #include <kpDocument.h>
46 #include <kpImageSelectionTransparency.h>
48 #include <kpToolAction.h>
49 #include <kpToolBrush.h>
50 #include <kpToolColorEraser.h>
51 #include <kpToolColorPicker.h>
52 #include <kpToolCurve.h>
53 #include <kpToolEllipticalSelection.h>
54 #include <kpToolEllipse.h>
55 #include <kpToolEraser.h>
56 #include <kpToolFloodFill.h>
57 #include <kpToolFreeFormSelection.h>
58 #include <kpToolLine.h>
59 #include <kpToolPen.h>
60 #include <kpToolPolygon.h>
61 #include <kpToolPolyline.h>
62 #include <kpToolRectangle.h>
63 #include <kpToolRectSelection.h>
64 #include <kpToolRoundedRectangle.h>
65 #include <kpToolSelectionEnvironment.h>
66 #include <kpToolSpraycan.h>
67 #include <kpToolText.h>
68 #include <kpToolToolBar.h>
69 #include <kpToolWidgetOpaqueOrTransparent.h>
70 #include <kpToolZoom.h>
71 #include <kpTransformResizeScaleCommand.h>
72 #include <kpViewScrollableContainer.h>
73 #include <kpZoomedView.h>
77 kpToolSelectionEnvironment
*kpMainWindow::toolSelectionEnvironment ()
79 if (!d
->toolSelectionEnvironment
)
80 d
->toolSelectionEnvironment
= new kpToolSelectionEnvironment (this);
82 return d
->toolSelectionEnvironment
;
86 kpToolEnvironment
*kpMainWindow::toolEnvironment ()
88 // It's fine to return a more complex environment than required.
89 return toolSelectionEnvironment ();
94 void kpMainWindow::setupToolActions ()
96 kpToolSelectionEnvironment
*toolSelEnv
= toolSelectionEnvironment ();
97 kpToolEnvironment
*toolEnv
= toolEnvironment ();
99 d
->tools
.append (d
->toolFreeFormSelection
= new kpToolFreeFormSelection (toolSelEnv
, this));
100 d
->tools
.append (d
->toolRectSelection
= new kpToolRectSelection (toolSelEnv
, this));
102 d
->tools
.append (d
->toolEllipticalSelection
= new kpToolEllipticalSelection (toolSelEnv
, this));
103 d
->tools
.append (d
->toolText
= new kpToolText (toolSelEnv
, this));
105 d
->tools
.append (d
->toolLine
= new kpToolLine (toolEnv
, this));
106 d
->tools
.append (d
->toolPen
= new kpToolPen (toolEnv
, this));
108 d
->tools
.append (d
->toolEraser
= new kpToolEraser (toolEnv
, this));
109 d
->tools
.append (d
->toolBrush
= new kpToolBrush (toolEnv
, this));
111 d
->tools
.append (d
->toolFloodFill
= new kpToolFloodFill (toolEnv
, this));
112 d
->tools
.append (d
->toolColorPicker
= new kpToolColorPicker (toolEnv
, this));
114 d
->tools
.append (d
->toolColorEraser
= new kpToolColorEraser (toolEnv
, this));
115 d
->tools
.append (d
->toolSpraycan
= new kpToolSpraycan (toolEnv
, this));
117 d
->tools
.append (d
->toolRoundedRectangle
= new kpToolRoundedRectangle (toolEnv
, this));
118 d
->tools
.append (d
->toolRectangle
= new kpToolRectangle (toolEnv
, this));
120 d
->tools
.append (d
->toolPolygon
= new kpToolPolygon (toolEnv
, this));
121 d
->tools
.append (d
->toolEllipse
= new kpToolEllipse (toolEnv
, this));
123 d
->tools
.append (d
->toolPolyline
= new kpToolPolyline (toolEnv
, this));
124 d
->tools
.append (d
->toolCurve
= new kpToolCurve (toolEnv
, this));
126 d
->tools
.append (d
->toolZoom
= new kpToolZoom (toolEnv
, this));
129 KActionCollection
*ac
= actionCollection ();
131 d
->actionPrevToolOptionGroup1
= ac
->addAction ("prev_tool_option_group_1");
132 d
->actionPrevToolOptionGroup1
->setText (i18n ("Previous Tool Option (Group #1)"));
133 d
->actionPrevToolOptionGroup1
->setShortcuts (kpTool::shortcutForKey (Qt::Key_1
));
134 connect (d
->actionPrevToolOptionGroup1
, SIGNAL (triggered (bool)),
135 SLOT (slotActionPrevToolOptionGroup1 ()));
137 d
->actionNextToolOptionGroup1
= ac
->addAction ("next_tool_option_group_1");
138 d
->actionNextToolOptionGroup1
->setText (i18n ("Next Tool Option (Group #1)"));
139 d
->actionNextToolOptionGroup1
->setShortcuts (kpTool::shortcutForKey (Qt::Key_2
));
140 connect (d
->actionNextToolOptionGroup1
, SIGNAL (triggered (bool)),
141 SLOT (slotActionNextToolOptionGroup1 ()));
143 d
->actionPrevToolOptionGroup2
= ac
->addAction ("prev_tool_option_group_2");
144 d
->actionPrevToolOptionGroup2
->setText (i18n ("Previous Tool Option (Group #2)"));
145 d
->actionPrevToolOptionGroup2
->setShortcuts (kpTool::shortcutForKey (Qt::Key_3
));
146 connect (d
->actionPrevToolOptionGroup2
, SIGNAL (triggered (bool)),
147 SLOT (slotActionPrevToolOptionGroup2 ()));
149 d
->actionNextToolOptionGroup2
= ac
->addAction ("next_tool_option_group_2");
150 d
->actionNextToolOptionGroup2
->setText (i18n ("Next Tool Option (Group #2)"));
151 d
->actionNextToolOptionGroup2
->setShortcuts (kpTool::shortcutForKey (Qt::Key_4
));
152 connect (d
->actionNextToolOptionGroup2
, SIGNAL (triggered (bool)),
153 SLOT (slotActionNextToolOptionGroup2 ()));
157 // Implemented in this file (kpMainWindow_Tools.cpp), not
158 // kpImageWindow_Image.cpp since they're really setting tool options.
161 d
->actionDrawOpaque
= ac
->add
<KToggleAction
> ("image_draw_opaque");
162 d
->actionDrawOpaque
->setText (i18n ("&Draw Opaque"));
163 connect (d
->actionDrawOpaque
, SIGNAL (triggered (bool)),
164 SLOT (slotActionDrawOpaqueToggled ()));
166 d
->actionDrawColorSimilarity
= ac
->addAction ("image_draw_color_similarity");
167 d
->actionDrawColorSimilarity
->setText (i18n ("Draw With Color Similarity..."));
168 connect (d
->actionDrawColorSimilarity
, SIGNAL (triggered (bool)),
169 SLOT (slotActionDrawColorSimilarity ()));
173 void kpMainWindow::createToolBox ()
175 d
->toolToolBar
= new kpToolToolBar (i18n ("Tool Box"), 2/*columns/rows*/, this);
177 // (needed for QMainWindow::saveState())
178 d
->toolToolBar
->setObjectName ("Tool Box");
180 connect (d
->toolToolBar
, SIGNAL (sigToolSelected (kpTool
*)),
181 this, SLOT (slotToolSelected (kpTool
*)));
182 connect (d
->toolToolBar
, SIGNAL (toolWidgetOptionSelected ()),
183 this, SLOT (updateToolOptionPrevNextActionsEnabled ()));
185 connect (d
->toolToolBar
->toolWidgetOpaqueOrTransparent (),
186 SIGNAL (isOpaqueChanged (bool)),
187 SLOT (updateActionDrawOpaqueChecked ()));
188 updateActionDrawOpaqueChecked ();
190 for (QList
<kpTool
*>::const_iterator it
= d
->tools
.begin ();
191 it
!= d
->tools
.end ();
194 d
->toolToolBar
->registerTool (*it
);
198 // (from config file)
202 enableToolsDocumentActions (false);
206 void kpMainWindow::enableToolsDocumentActions (bool enable
)
208 #if DEBUG_KP_MAIN_WINDOW
209 kDebug () << "kpMainWindow::enableToolsDocumentsAction(" << enable
<< ")";
212 d
->toolActionsEnabled
= enable
;
215 if (enable
&& !d
->toolToolBar
->isEnabled ())
217 kpTool
*previousTool
= d
->toolToolBar
->previousTool ();
219 // select tool for enabled Tool Box
222 d
->toolToolBar
->selectPreviousTool ();
225 if (d
->lastToolNumber
>= 0 && d
->lastToolNumber
< (int) d
->tools
.count ())
226 d
->toolToolBar
->selectTool (d
->tools
.at (d
->lastToolNumber
));
228 d
->toolToolBar
->selectTool (d
->toolPen
);
231 else if (!enable
&& d
->toolToolBar
->isEnabled ())
233 // don't have a disabled Tool Box with an enabled Tool
234 d
->toolToolBar
->selectTool (0);
238 d
->toolToolBar
->setEnabled (enable
);
241 for (QList
<kpTool
*>::const_iterator it
= d
->tools
.begin ();
242 it
!= d
->tools
.end ();
245 kpToolAction
*action
= (*it
)->action ();
248 #if DEBUG_KP_MAIN_WINDOW
249 kDebug () << "\tchanging enabled state of " << (*it
)->objectName ();
252 if (!enable
&& action
->isChecked ())
253 action
->setChecked (false);
255 action
->setEnabled (enable
);
259 #if DEBUG_KP_MAIN_WINDOW
260 kDebug () << "\tno action for " << (*it
)->objectName ();
266 updateToolOptionPrevNextActionsEnabled ();
267 updateActionDrawOpaqueEnabled ();
271 void kpMainWindow::updateToolOptionPrevNextActionsEnabled ()
273 #if DEBUG_KP_MAIN_WINDOW
274 kDebug () << "kpMainWindow::updateToolOptionPrevNextActionsEnabled()"
275 << " numShownToolWidgets="
276 << d
->toolToolBar
->numShownToolWidgets ()
280 const bool enable
= d
->toolActionsEnabled
;
283 d
->actionPrevToolOptionGroup1
->setEnabled (enable
&&
284 d
->toolToolBar
->shownToolWidget (0) &&
285 d
->toolToolBar
->shownToolWidget (0)->hasPreviousOption ());
286 d
->actionNextToolOptionGroup1
->setEnabled (enable
&&
287 d
->toolToolBar
->shownToolWidget (0) &&
288 d
->toolToolBar
->shownToolWidget (0)->hasNextOption ());
290 d
->actionPrevToolOptionGroup2
->setEnabled (enable
&&
291 d
->toolToolBar
->shownToolWidget (1) &&
292 d
->toolToolBar
->shownToolWidget (1)->hasPreviousOption ());
293 d
->actionNextToolOptionGroup2
->setEnabled (enable
&&
294 d
->toolToolBar
->shownToolWidget (1) &&
295 d
->toolToolBar
->shownToolWidget (1)->hasNextOption ());
300 void kpMainWindow::updateActionDrawOpaqueChecked ()
302 #if DEBUG_KP_MAIN_WINDOW
303 kDebug () << "kpMainWindow::updateActionDrawOpaqueChecked()";
306 const bool drawOpaque
=
307 (d
->toolToolBar
->toolWidgetOpaqueOrTransparent ()->selectedRow () == 0);
308 #if DEBUG_KP_MAIN_WINDOW
309 kDebug () << "\tdrawOpaque=" << drawOpaque
;
312 d
->actionDrawOpaque
->setChecked (drawOpaque
);
316 void kpMainWindow::updateActionDrawOpaqueEnabled ()
318 #if DEBUG_KP_MAIN_WINDOW
319 kDebug () << "kpMainWindow::updateActionDrawOpaqueEnabled()";
322 const bool enable
= d
->toolActionsEnabled
;
324 #if DEBUG_KP_MAIN_WINDOW
325 kDebug () << "\tenable=" << enable
326 << " tool=" << (tool () ? tool ()->objectName () : 0)
327 << " (is selection=" << toolIsASelectionTool () << ")"
331 d
->actionDrawOpaque
->setEnabled (enable
&& toolIsASelectionTool ());
336 QActionGroup
*kpMainWindow::toolsActionGroup ()
338 if (!d
->toolsActionGroup
)
339 d
->toolsActionGroup
= new QActionGroup (this);
341 return d
->toolsActionGroup
;
346 kpTool
*kpMainWindow::tool () const
348 return d
->toolToolBar
? d
->toolToolBar
->tool () : 0;
352 bool kpMainWindow::toolHasBegunShape () const
354 kpTool
*currentTool
= tool ();
355 return (currentTool
&& currentTool
->hasBegunShape ());
359 bool kpMainWindow::toolIsASelectionTool (bool includingTextTool
) const
361 kpTool
*currentTool
= tool ();
363 return ((currentTool
== d
->toolFreeFormSelection
) ||
364 (currentTool
== d
->toolRectSelection
) ||
365 (currentTool
== d
->toolEllipticalSelection
) ||
366 (currentTool
== d
->toolText
&& includingTextTool
));
370 bool kpMainWindow::toolIsTextTool () const
372 return (tool () == d
->toolText
);
377 void kpMainWindow::toolEndShape ()
379 if (toolHasBegunShape ())
380 tool ()->endShapeInternal ();
385 kpImageSelectionTransparency
kpMainWindow::imageSelectionTransparency () const
387 kpToolWidgetOpaqueOrTransparent
*oot
= d
->toolToolBar
->toolWidgetOpaqueOrTransparent ();
390 return kpImageSelectionTransparency (oot
->isOpaque (), backgroundColor (), d
->colorToolBar
->colorSimilarity ());
394 void kpMainWindow::setImageSelectionTransparency (const kpImageSelectionTransparency
&transparency
, bool forceColorChange
)
396 #if DEBUG_KP_MAIN_WINDOW && 1
397 kDebug () << "kpMainWindow::setImageSelectionTransparency() isOpaque=" << transparency
.isOpaque ()
398 << " color=" << (transparency
.transparentColor ().isValid () ? (int *) transparency
.transparentColor ().toQRgb () : 0)
399 << " forceColorChange=" << forceColorChange
403 kpToolWidgetOpaqueOrTransparent
*oot
= d
->toolToolBar
->toolWidgetOpaqueOrTransparent ();
406 d
->settingImageSelectionTransparency
++;
408 oot
->setOpaque (transparency
.isOpaque ());
409 if (transparency
.isTransparent () || forceColorChange
)
411 d
->colorToolBar
->setColor (1, transparency
.transparentColor ());
412 d
->colorToolBar
->setColorSimilarity (transparency
.colorSimilarity ());
415 d
->settingImageSelectionTransparency
--;
419 int kpMainWindow::settingImageSelectionTransparency () const
421 return d
->settingImageSelectionTransparency
;
426 void kpMainWindow::slotToolSelected (kpTool
*tool
)
428 #if DEBUG_KP_MAIN_WINDOW
429 kDebug () << "kpMainWindow::slotToolSelected (" << tool
<< ")";
432 kpTool
*previousTool
= d
->toolToolBar
? d
->toolToolBar
->previousTool () : 0;
436 disconnect (previousTool
, SIGNAL (movedAndAboutToDraw (const QPoint
&, const QPoint
&, int, bool *)),
437 this, SLOT (slotDragScroll (const QPoint
&, const QPoint
&, int, bool *)));
438 disconnect (previousTool
, SIGNAL (endedDraw (const QPoint
&)),
439 this, SLOT (slotEndDragScroll ()));
440 disconnect (previousTool
, SIGNAL (cancelledShape (const QPoint
&)),
441 this, SLOT (slotEndDragScroll ()));
443 disconnect (previousTool
, SIGNAL (userMessageChanged (const QString
&)),
444 this, SLOT (recalculateStatusBarMessage ()));
445 disconnect (previousTool
, SIGNAL (userShapePointsChanged (const QPoint
&, const QPoint
&)),
446 this, SLOT (recalculateStatusBarShape ()));
447 disconnect (previousTool
, SIGNAL (userShapeSizeChanged (const QSize
&)),
448 this, SLOT (recalculateStatusBarShape ()));
450 disconnect (d
->colorToolBar
, SIGNAL (colorsSwapped (const kpColor
&, const kpColor
&)),
451 previousTool
, SLOT (slotColorsSwappedInternal (const kpColor
&, const kpColor
&)));
452 disconnect (d
->colorToolBar
, SIGNAL (foregroundColorChanged (const kpColor
&)),
453 previousTool
, SLOT (slotForegroundColorChangedInternal (const kpColor
&)));
454 disconnect (d
->colorToolBar
, SIGNAL (backgroundColorChanged (const kpColor
&)),
455 previousTool
, SLOT (slotBackgroundColorChangedInternal (const kpColor
&)));
456 disconnect (d
->colorToolBar
, SIGNAL (colorSimilarityChanged (double, int)),
457 previousTool
, SLOT (slotColorSimilarityChangedInternal (double, int)));
462 connect (tool
, SIGNAL (movedAndAboutToDraw (const QPoint
&, const QPoint
&, int, bool *)),
463 this, SLOT (slotDragScroll (const QPoint
&, const QPoint
&, int, bool *)));
464 connect (tool
, SIGNAL (endedDraw (const QPoint
&)),
465 this, SLOT (slotEndDragScroll ()));
466 connect (tool
, SIGNAL (cancelledShape (const QPoint
&)),
467 this, SLOT (slotEndDragScroll ()));
469 connect (tool
, SIGNAL (userMessageChanged (const QString
&)),
470 this, SLOT (recalculateStatusBarMessage ()));
471 connect (tool
, SIGNAL (userShapePointsChanged (const QPoint
&, const QPoint
&)),
472 this, SLOT (recalculateStatusBarShape ()));
473 connect (tool
, SIGNAL (userShapeSizeChanged (const QSize
&)),
474 this, SLOT (recalculateStatusBarShape ()));
475 recalculateStatusBar ();
477 connect (d
->colorToolBar
, SIGNAL (colorsSwapped (const kpColor
&, const kpColor
&)),
478 tool
, SLOT (slotColorsSwappedInternal (const kpColor
&, const kpColor
&)));
479 connect (d
->colorToolBar
, SIGNAL (foregroundColorChanged (const kpColor
&)),
480 tool
, SLOT (slotForegroundColorChangedInternal (const kpColor
&)));
481 connect (d
->colorToolBar
, SIGNAL (backgroundColorChanged (const kpColor
&)),
482 tool
, SLOT (slotBackgroundColorChangedInternal (const kpColor
&)));
483 connect (d
->colorToolBar
, SIGNAL (colorSimilarityChanged (double, int)),
484 tool
, SLOT (slotColorSimilarityChangedInternal (double, int)));
490 updateToolOptionPrevNextActionsEnabled ();
491 updateActionDrawOpaqueEnabled ();
496 void kpMainWindow::readLastTool ()
498 KConfigGroup
cfg (KGlobal::config (), kpSettingsGroupTools
);
500 d
->lastToolNumber
= cfg
.readEntry (kpSettingLastTool
, -1);
505 int kpMainWindow::toolNumber () const
508 for (QList
<kpTool
*>::const_iterator it
= d
->tools
.begin ();
509 it
!= d
->tools
.end ();
522 void kpMainWindow::saveLastTool ()
524 int number
= toolNumber ();
525 if (number
< 0 || number
>= (int) d
->tools
.count ())
529 KConfigGroup
cfg (KGlobal::config (), kpSettingsGroupTools
);
531 cfg
.writeEntry (kpSettingLastTool
, number
);
537 bool kpMainWindow::maybeDragScrollingMainView () const
539 return (tool () && d
->mainView
&&
540 tool ()->viewUnderStartPoint () == d
->mainView
);
544 bool kpMainWindow::slotDragScroll (const QPoint
&docPoint
,
545 const QPoint
&docLastPoint
,
549 #if DEBUG_KP_MAIN_WINDOW
550 kDebug () << "kpMainWindow::slotDragScroll() maybeDragScrolling="
551 << maybeDragScrollingMainView ()
555 if (maybeDragScrollingMainView ())
557 return d
->scrollView
->beginDragScroll (docPoint
, docLastPoint
, zoomLevel
, scrolled
);
566 bool kpMainWindow::slotEndDragScroll ()
568 // (harmless if haven't started drag scroll)
569 return d
->scrollView
->endDragScroll ();
574 void kpMainWindow::slotBeganDocResize ()
578 recalculateStatusBarShape ();
582 void kpMainWindow::slotContinuedDocResize (const QSize
&)
584 recalculateStatusBarShape ();
588 void kpMainWindow::slotCancelledDocResize ()
590 recalculateStatusBar ();
594 void kpMainWindow::slotEndedDocResize (const QSize
&size
)
596 #define DOC_RESIZE_COMPLETED() \
598 d->docResizeToBeCompleted = false; \
599 recalculateStatusBar (); \
602 // Prevent statusbar updates
603 d
->docResizeToBeCompleted
= true;
605 d
->docResizeWidth
= (size
.width () > 0 ? size
.width () : 1),
606 d
->docResizeHeight
= (size
.height () > 0 ? size
.height () : 1);
608 if (d
->docResizeWidth
== d
->document
->width () &&
609 d
->docResizeHeight
== d
->document
->height ())
611 DOC_RESIZE_COMPLETED ();
616 // Blank status to avoid confusion if dialog comes up
617 setStatusBarMessage ();
618 setStatusBarShapePoints ();
619 setStatusBarShapeSize ();
622 if (kpTool::warnIfBigImageSize (d
->document
->width (),
623 d
->document
->height (),
624 d
->docResizeWidth
, d
->docResizeHeight
,
625 i18n ("<qt><p>Resizing the image to"
626 " %1x%2 may take a substantial amount of memory."
627 " This can reduce system"
628 " responsiveness and cause other application resource"
631 "<p>Are you sure want to resize the"
635 i18n ("Resize Image?"),
636 i18n ("R&esize Image"),
639 d
->commandHistory
->addCommand (
640 new kpTransformResizeScaleCommand (
641 false/*doc, not sel*/,
642 d
->docResizeWidth
, d
->docResizeHeight
,
643 kpTransformResizeScaleCommand::Resize
,
644 commandEnvironment ()));
646 saveDefaultDocSize (QSize (d
->docResizeWidth
, d
->docResizeHeight
));
650 DOC_RESIZE_COMPLETED ();
652 #undef DOC_RESIZE_COMPLETED
656 void kpMainWindow::slotDocResizeMessageChanged (const QString
&string
)
658 #if DEBUG_KP_MAIN_WINDOW
659 kDebug () << "kpMainWindow::slotDocResizeMessageChanged(" << string
660 << ") docResizeToBeCompleted=" << d
->docResizeToBeCompleted
666 if (d
->docResizeToBeCompleted
)
669 recalculateStatusBarMessage ();
674 void kpMainWindow::slotActionPrevToolOptionGroup1 ()
676 if (!d
->toolToolBar
->shownToolWidget (0))
679 // We don't call toolEndShape() here because we want #23 in the file BUGS
682 d
->toolToolBar
->shownToolWidget (0)->selectPreviousOption ();
683 updateToolOptionPrevNextActionsEnabled ();
687 void kpMainWindow::slotActionNextToolOptionGroup1 ()
689 if (!d
->toolToolBar
->shownToolWidget (0))
692 // We don't call toolEndShape() here because we want #23 in the file BUGS
695 d
->toolToolBar
->shownToolWidget (0)->selectNextOption ();
696 updateToolOptionPrevNextActionsEnabled ();
701 void kpMainWindow::slotActionPrevToolOptionGroup2 ()
703 if (!d
->toolToolBar
->shownToolWidget (1))
706 // We don't call toolEndShape() here because we want #23 in the file BUGS
709 d
->toolToolBar
->shownToolWidget (1)->selectPreviousOption ();
710 updateToolOptionPrevNextActionsEnabled ();
714 void kpMainWindow::slotActionNextToolOptionGroup2 ()
716 if (!d
->toolToolBar
->shownToolWidget (1))
719 // We don't call toolEndShape() here because we want #23 in the file BUGS
722 d
->toolToolBar
->shownToolWidget (1)->selectNextOption ();
723 updateToolOptionPrevNextActionsEnabled ();
728 void kpMainWindow::slotActionDrawOpaqueToggled ()
730 #if DEBUG_KP_MAIN_WINDOW
731 kDebug () << "kpMainWindow::slotActionDrawOpaqueToggled()";
735 // TODO: How does this differ to setImageSelectionTransparency()?
737 // ("kpToolWidgetBase::" is to access one overload shadowed by the override
738 // of the other overload)
739 d
->toolToolBar
->toolWidgetOpaqueOrTransparent ()->kpToolWidgetBase::setSelected (
740 (d
->actionDrawOpaque
->isChecked () ?
741 0/*row 0 = opaque*/ :
742 1/*row 1 = transparent*/),
747 void kpMainWindow::slotActionDrawColorSimilarity ()
749 #if DEBUG_KP_MAIN_WINDOW
750 kDebug () << "kpMainWindow::slotActionDrawColorSimilarity()";
754 d
->colorToolBar
->openColorSimilarityDialog ();
760 // LOTODO: Who actually calls these?
761 #define SLOT_TOOL(toolName) \
762 void kpMainWindow::slotTool##toolName () \
764 if (!d->toolToolBar) \
767 if (tool () == d->tool##toolName) \
770 d->toolToolBar->selectTool (d->tool##toolName); \
775 SLOT_TOOL (ColorEraser
)
776 SLOT_TOOL (ColorPicker
)
779 SLOT_TOOL (EllipticalSelection
)
781 SLOT_TOOL (FloodFill
)
782 SLOT_TOOL (FreeFormSelection
)
787 SLOT_TOOL (Rectangle
)
788 SLOT_TOOL (RectSelection
)
789 SLOT_TOOL (RoundedRectangle
)