use kDebug
[kdegraphics.git] / kolourpaint / tools / kpTool_UserNotifications.cpp
blob86247d4cba528ed87e8f7fa3619d471cb46817f2
2 /*
3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
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 // Tools' statusbar updates.
33 #define DEBUG_KP_TOOL 0
36 // LOREFACTOR: reduce number of includes
37 #include <kpTool.h>
38 #include <kpToolPrivate.h>
40 #include <limits.h>
42 #include <qapplication.h>
43 #include <qclipboard.h>
44 #include <qcursor.h>
45 #include <qevent.h>
46 #include <qlayout.h>
47 #include <qpainter.h>
48 #include <qpixmap.h>
50 #include <kapplication.h>
51 #include <kdebug.h>
52 #include <kiconloader.h>
53 #include <klocale.h>
54 #include <kmessagebox.h>
56 #include <kpBug.h>
57 #include <kpColor.h>
58 #include <kpColorToolBar.h>
59 #include <kpDefs.h>
60 #include <kpPixmapFX.h>
61 #include <kpToolAction.h>
62 #include <kpToolToolBar.h>
63 #include <kpView.h>
64 #include <kpViewManager.h>
65 #include <kactioncollection.h>
68 // public static
69 QString kpTool::cancelUserMessage (int mouseButton)
71 if (mouseButton == 0)
72 return i18n ("Right click to cancel.");
73 else
74 return i18n ("Left click to cancel.");
77 // public
78 QString kpTool::cancelUserMessage () const
80 return cancelUserMessage (d->mouseButton);
84 // public
85 QString kpTool::userMessage () const
87 return d->userMessage;
90 // public
91 void kpTool::setUserMessage (const QString &userMessage)
93 d->userMessage = userMessage;
95 if (d->userMessage.isEmpty ())
96 d->userMessage = text ();
97 else
98 d->userMessage.prepend (i18n ("%1: ", text ()));
100 emit userMessageChanged (d->userMessage);
104 // public
105 QPoint kpTool::userShapeStartPoint () const
107 return d->userShapeStartPoint;
110 // public
111 QPoint kpTool::userShapeEndPoint () const
113 return d->userShapeEndPoint;
116 // public
117 void kpTool::setUserShapePoints (const QPoint &startPoint,
118 const QPoint &endPoint,
119 bool setSize)
121 d->userShapeStartPoint = startPoint;
122 d->userShapeEndPoint = endPoint;
123 emit userShapePointsChanged (d->userShapeStartPoint, d->userShapeEndPoint);
125 if (setSize)
127 if (startPoint != KP_INVALID_POINT &&
128 endPoint != KP_INVALID_POINT)
130 setUserShapeSize (calculateLength (startPoint.x (), endPoint.x ()),
131 calculateLength (startPoint.y (), endPoint.y ()));
133 else
135 setUserShapeSize ();
140 // public
141 QSize kpTool::userShapeSize () const
143 return d->userShapeSize;
146 // public
147 int kpTool::userShapeWidth () const
149 return d->userShapeSize.width ();
152 // public
153 int kpTool::userShapeHeight () const
155 return d->userShapeSize.height ();
158 // public
159 void kpTool::setUserShapeSize (const QSize &size)
161 d->userShapeSize = size;
163 emit userShapeSizeChanged (d->userShapeSize);
164 emit userShapeSizeChanged (d->userShapeSize.width (),
165 d->userShapeSize.height ());
168 // public
169 void kpTool::setUserShapeSize (int width, int height)
171 setUserShapeSize (QSize (width, height));