TDE graphics utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kpmainwindow_tools.cpp 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. Copyright (c) 2003,2004,2005 Clarence Dang <dang@kde.org>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  13. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #include <kpmainwindow.h>
  24. #include <tdeapplication.h>
  25. #include <tdeconfig.h>
  26. #include <kdebug.h>
  27. #include <tdelocale.h>
  28. #include <kpcolortoolbar.h>
  29. #include <kpcommandhistory.h>
  30. #include <kpdocument.h>
  31. #include <kpselectiontransparency.h>
  32. #include <kpsinglekeytriggersaction.h>
  33. #include <kptool.h>
  34. #include <kptoolaction.h>
  35. #include <kptoolairspray.h>
  36. #include <kptoolbrush.h>
  37. #include <kptoolcolorpicker.h>
  38. #include <kptoolcolorwasher.h>
  39. #include <kptoolcurve.h>
  40. #include <kptoolellipticalselection.h>
  41. #include <kptoolellipse.h>
  42. #include <kptooleraser.h>
  43. #include <kptoolfloodfill.h>
  44. #include <kptoolfreeformselection.h>
  45. #include <kptoolline.h>
  46. #include <kptoolpen.h>
  47. #include <kptoolpolygon.h>
  48. #include <kptoolpolyline.h>
  49. #include <kptoolrectangle.h>
  50. #include <kptoolrectselection.h>
  51. #include <kptoolresizescale.h>
  52. #include <kptoolroundedrectangle.h>
  53. #include <kptooltext.h>
  54. #include <kptooltoolbar.h>
  55. #include <kptoolwidgetopaqueortransparent.h>
  56. #include <kpviewscrollablecontainer.h>
  57. #include <kpzoomedview.h>
  58. // private
  59. void kpMainWindow::setupToolActions ()
  60. {
  61. m_tools.setAutoDelete (true);
  62. m_tools.append (m_toolFreeFormSelection = new kpToolFreeFormSelection (this));
  63. m_tools.append (m_toolRectSelection = new kpToolRectSelection (this));
  64. m_tools.append (m_toolEllipticalSelection = new kpToolEllipticalSelection (this));
  65. m_tools.append (m_toolText = new kpToolText (this));
  66. m_tools.append (m_toolLine = new kpToolLine (this));
  67. m_tools.append (m_toolPen = new kpToolPen (this));
  68. m_tools.append (m_toolEraser = new kpToolEraser (this));
  69. m_tools.append (m_toolBrush = new kpToolBrush (this));
  70. m_tools.append (m_toolFloodFill = new kpToolFloodFill (this));
  71. m_tools.append (m_toolColorPicker = new kpToolColorPicker (this));
  72. m_tools.append (m_toolColorWasher = new kpToolColorWasher (this));
  73. m_tools.append (m_toolAirSpray = new kpToolAirSpray (this));
  74. m_tools.append (m_toolRoundedRectangle = new kpToolRoundedRectangle (this));
  75. m_tools.append (m_toolRectangle = new kpToolRectangle (this));
  76. m_tools.append (m_toolPolygon = new kpToolPolygon (this));
  77. m_tools.append (m_toolEllipse = new kpToolEllipse (this));
  78. m_tools.append (m_toolPolyline = new kpToolPolyline (this));
  79. m_tools.append (m_toolCurve = new kpToolCurve (this));
  80. TDEActionCollection *ac = actionCollection ();
  81. m_actionPrevToolOptionGroup1 = new kpSingleKeyTriggersAction (
  82. i18n ("Previous Tool Option (Group #1)"),
  83. kpTool::shortcutForKey (TQt::Key_1),
  84. TQT_TQOBJECT(this), TQT_SLOT (slotActionPrevToolOptionGroup1 ()),
  85. ac, "prev_tool_option_group_1");
  86. m_actionNextToolOptionGroup1 = new kpSingleKeyTriggersAction (
  87. i18n ("Next Tool Option (Group #1)"),
  88. kpTool::shortcutForKey (TQt::Key_2),
  89. TQT_TQOBJECT(this), TQT_SLOT (slotActionNextToolOptionGroup1 ()),
  90. ac, "next_tool_option_group_1");
  91. m_actionPrevToolOptionGroup2 = new kpSingleKeyTriggersAction (
  92. i18n ("Previous Tool Option (Group #2)"),
  93. kpTool::shortcutForKey (TQt::Key_3),
  94. TQT_TQOBJECT(this), TQT_SLOT (slotActionPrevToolOptionGroup2 ()),
  95. ac, "prev_tool_option_group_2");
  96. m_actionNextToolOptionGroup2 = new kpSingleKeyTriggersAction (
  97. i18n ("Next Tool Option (Group #2)"),
  98. kpTool::shortcutForKey (TQt::Key_4),
  99. TQT_TQOBJECT(this), TQT_SLOT (slotActionNextToolOptionGroup2 ()),
  100. ac, "next_tool_option_group_2");
  101. }
  102. // private
  103. void kpMainWindow::createToolBox ()
  104. {
  105. m_toolToolBar = new kpToolToolBar (i18n ("Tool Box"), this, 2/*columns/rows*/, "Tool Box");
  106. connect (m_toolToolBar, TQT_SIGNAL (sigToolSelected (kpTool *)),
  107. this, TQT_SLOT (slotToolSelected (kpTool *)));
  108. connect (m_toolToolBar, TQT_SIGNAL (toolWidgetOptionSelected ()),
  109. this, TQT_SLOT (updateToolOptionPrevNextActionsEnabled ()));
  110. for (TQPtrList <kpTool>::const_iterator it = m_tools.begin ();
  111. it != m_tools.end ();
  112. it++)
  113. {
  114. m_toolToolBar->registerTool (*it);
  115. }
  116. // (from config file)
  117. readLastTool ();
  118. enableToolsDocumentActions (false);
  119. }
  120. // private
  121. void kpMainWindow::enableToolsDocumentActions (bool enable)
  122. {
  123. #if DEBUG_KP_MAIN_WINDOW
  124. kdDebug () << "kpMainWindow::enableToolsDocumentsAction(" << enable << ")" << endl;
  125. #endif
  126. m_toolActionsEnabled = enable;
  127. if (enable && !m_toolToolBar->isEnabled ())
  128. {
  129. kpTool *previousTool = m_toolToolBar->previousTool ();
  130. // select tool for enabled Tool Box
  131. if (previousTool)
  132. m_toolToolBar->selectPreviousTool ();
  133. else
  134. {
  135. if (m_lastToolNumber >= 0 && m_lastToolNumber < (int) m_tools.count ())
  136. m_toolToolBar->selectTool (m_tools.at (m_lastToolNumber));
  137. else
  138. m_toolToolBar->selectTool (m_toolPen);
  139. }
  140. }
  141. else if (!enable && m_toolToolBar->isEnabled ())
  142. {
  143. // don't have a disabled Tool Box with an enabled Tool
  144. m_toolToolBar->selectTool (0);
  145. }
  146. m_toolToolBar->setEnabled (enable);
  147. for (TQPtrList <kpTool>::const_iterator it = m_tools.begin ();
  148. it != m_tools.end ();
  149. it++)
  150. {
  151. kpToolAction *action = (*it)->action ();
  152. if (action)
  153. {
  154. #if DEBUG_KP_MAIN_WINDOW
  155. kdDebug () << "\tchanging enabled state of " << (*it)->name () << endl;
  156. #endif
  157. if (!enable && action->isChecked ())
  158. action->setChecked (false);
  159. action->setEnabled (enable);
  160. }
  161. else
  162. {
  163. #if DEBUG_KP_MAIN_WINDOW
  164. kdDebug () << "\tno action for " << (*it)->name () << endl;
  165. #endif
  166. }
  167. }
  168. updateToolOptionPrevNextActionsEnabled ();
  169. }
  170. // private slot
  171. void kpMainWindow::updateToolOptionPrevNextActionsEnabled ()
  172. {
  173. #if DEBUG_KP_MAIN_WINDOW
  174. kdDebug () << "kpMainWindow::updateToolOptionPrevNextActionsEnabled()"
  175. << " numShownToolWidgets="
  176. << m_toolToolBar->numShownToolWidgets ()
  177. << endl;
  178. #endif
  179. const bool enable = m_toolActionsEnabled;
  180. m_actionPrevToolOptionGroup1->setEnabled (enable &&
  181. m_toolToolBar->shownToolWidget (0) &&
  182. m_toolToolBar->shownToolWidget (0)->hasPreviousOption ());
  183. m_actionNextToolOptionGroup1->setEnabled (enable &&
  184. m_toolToolBar->shownToolWidget (0) &&
  185. m_toolToolBar->shownToolWidget (0)->hasNextOption ());
  186. m_actionPrevToolOptionGroup2->setEnabled (enable &&
  187. m_toolToolBar->shownToolWidget (1) &&
  188. m_toolToolBar->shownToolWidget (1)->hasPreviousOption ());
  189. m_actionNextToolOptionGroup2->setEnabled (enable &&
  190. m_toolToolBar->shownToolWidget (1) &&
  191. m_toolToolBar->shownToolWidget (1)->hasNextOption ());
  192. }
  193. // public
  194. kpTool *kpMainWindow::tool () const
  195. {
  196. return m_toolToolBar ? m_toolToolBar->tool () : 0;
  197. }
  198. // public
  199. bool kpMainWindow::toolHasBegunShape () const
  200. {
  201. kpTool *currentTool = tool ();
  202. return (currentTool && currentTool->hasBegunShape ());
  203. }
  204. // public
  205. bool kpMainWindow::toolIsASelectionTool (bool includingTextTool) const
  206. {
  207. kpTool *currentTool = tool ();
  208. return ((currentTool == m_toolFreeFormSelection) ||
  209. (currentTool == m_toolRectSelection) ||
  210. (currentTool == m_toolEllipticalSelection) ||
  211. (currentTool == m_toolText && includingTextTool));
  212. }
  213. // public
  214. bool kpMainWindow::toolIsTextTool () const
  215. {
  216. return (tool () == m_toolText);
  217. }
  218. // public
  219. kpSelectionTransparency kpMainWindow::selectionTransparency () const
  220. {
  221. kpToolWidgetOpaqueOrTransparent *oot = m_toolToolBar->toolWidgetOpaqueOrTransparent ();
  222. if (!oot)
  223. {
  224. kdError () << "kpMainWindow::selectionTransparency() without opaqueOrTransparent widget" << endl;
  225. return kpSelectionTransparency ();
  226. }
  227. return kpSelectionTransparency (oot->isOpaque (), backgroundColor (), m_colorToolBar->colorSimilarity ());
  228. }
  229. // public
  230. void kpMainWindow::setSelectionTransparency (const kpSelectionTransparency &transparency, bool forceColorChange)
  231. {
  232. #if DEBUG_KP_MAIN_WINDOW && 1
  233. kdDebug () << "kpMainWindow::setSelectionTransparency() isOpaque=" << transparency.isOpaque ()
  234. << " color=" << (transparency.transparentColor ().isValid () ? (int *) transparency.transparentColor ().toTQRgb () : 0)
  235. << " forceColorChange=" << forceColorChange
  236. << endl;
  237. #endif
  238. kpToolWidgetOpaqueOrTransparent *oot = m_toolToolBar->toolWidgetOpaqueOrTransparent ();
  239. if (!oot)
  240. {
  241. kdError () << "kpMainWindow::setSelectionTransparency() without opaqueOrTransparent widget" << endl;
  242. return;
  243. }
  244. m_settingSelectionTransparency++;
  245. oot->setOpaque (transparency.isOpaque ());
  246. if (transparency.isTransparent () || forceColorChange)
  247. {
  248. m_colorToolBar->setColor (1, transparency.transparentColor ());
  249. m_colorToolBar->setColorSimilarity (transparency.colorSimilarity ());
  250. }
  251. m_settingSelectionTransparency--;
  252. }
  253. // public
  254. int kpMainWindow::settingSelectionTransparency () const
  255. {
  256. return m_settingSelectionTransparency;
  257. }
  258. // private slot
  259. void kpMainWindow::slotToolSelected (kpTool *tool)
  260. {
  261. #if DEBUG_KP_MAIN_WINDOW
  262. kdDebug () << "kpMainWindow::slotToolSelected (" << tool << ")" << endl;
  263. #endif
  264. kpTool *previousTool = m_toolToolBar ? m_toolToolBar->previousTool () : 0;
  265. if (previousTool)
  266. {
  267. disconnect (previousTool, TQT_SIGNAL (movedAndAboutToDraw (const TQPoint &, const TQPoint &, int, bool *)),
  268. this, TQT_SLOT (slotDragScroll (const TQPoint &, const TQPoint &, int, bool *)));
  269. disconnect (previousTool, TQT_SIGNAL (endedDraw (const TQPoint &)),
  270. this, TQT_SLOT (slotEndDragScroll ()));
  271. disconnect (previousTool, TQT_SIGNAL (cancelledShape (const TQPoint &)),
  272. this, TQT_SLOT (slotEndDragScroll ()));
  273. disconnect (previousTool, TQT_SIGNAL (userMessageChanged (const TQString &)),
  274. this, TQT_SLOT (recalculateStatusBarMessage ()));
  275. disconnect (previousTool, TQT_SIGNAL (userShapePointsChanged (const TQPoint &, const TQPoint &)),
  276. this, TQT_SLOT (recalculateStatusBarShape ()));
  277. disconnect (previousTool, TQT_SIGNAL (userShapeSizeChanged (const TQSize &)),
  278. this, TQT_SLOT (recalculateStatusBarShape ()));
  279. disconnect (m_colorToolBar, TQT_SIGNAL (colorsSwapped (const kpColor &, const kpColor &)),
  280. previousTool, TQT_SLOT (slotColorsSwappedInternal (const kpColor &, const kpColor &)));
  281. disconnect (m_colorToolBar, TQT_SIGNAL (foregroundColorChanged (const kpColor &)),
  282. previousTool, TQT_SLOT (slotForegroundColorChangedInternal (const kpColor &)));
  283. disconnect (m_colorToolBar, TQT_SIGNAL (backgroundColorChanged (const kpColor &)),
  284. previousTool, TQT_SLOT (slotBackgroundColorChangedInternal (const kpColor &)));
  285. disconnect (m_colorToolBar, TQT_SIGNAL (colorSimilarityChanged (double, int)),
  286. previousTool, TQT_SLOT (slotColorSimilarityChangedInternal (double, int)));
  287. }
  288. if (tool)
  289. {
  290. connect (tool, TQT_SIGNAL (movedAndAboutToDraw (const TQPoint &, const TQPoint &, int, bool *)),
  291. this, TQT_SLOT (slotDragScroll (const TQPoint &, const TQPoint &, int, bool *)));
  292. connect (tool, TQT_SIGNAL (endedDraw (const TQPoint &)),
  293. this, TQT_SLOT (slotEndDragScroll ()));
  294. connect (tool, TQT_SIGNAL (cancelledShape (const TQPoint &)),
  295. this, TQT_SLOT (slotEndDragScroll ()));
  296. connect (tool, TQT_SIGNAL (userMessageChanged (const TQString &)),
  297. this, TQT_SLOT (recalculateStatusBarMessage ()));
  298. connect (tool, TQT_SIGNAL (userShapePointsChanged (const TQPoint &, const TQPoint &)),
  299. this, TQT_SLOT (recalculateStatusBarShape ()));
  300. connect (tool, TQT_SIGNAL (userShapeSizeChanged (const TQSize &)),
  301. this, TQT_SLOT (recalculateStatusBarShape ()));
  302. recalculateStatusBar ();
  303. connect (m_colorToolBar, TQT_SIGNAL (colorsSwapped (const kpColor &, const kpColor &)),
  304. tool, TQT_SLOT (slotColorsSwappedInternal (const kpColor &, const kpColor &)));
  305. connect (m_colorToolBar, TQT_SIGNAL (foregroundColorChanged (const kpColor &)),
  306. tool, TQT_SLOT (slotForegroundColorChangedInternal (const kpColor &)));
  307. connect (m_colorToolBar, TQT_SIGNAL (backgroundColorChanged (const kpColor &)),
  308. tool, TQT_SLOT (slotBackgroundColorChangedInternal (const kpColor &)));
  309. connect (m_colorToolBar, TQT_SIGNAL (colorSimilarityChanged (double, int)),
  310. tool, TQT_SLOT (slotColorSimilarityChangedInternal (double, int)));
  311. saveLastTool ();
  312. }
  313. updateToolOptionPrevNextActionsEnabled ();
  314. }
  315. // private
  316. void kpMainWindow::readLastTool ()
  317. {
  318. TDEConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupTools);
  319. TDEConfigBase *cfg = cfgGroupSaver.config ();
  320. m_lastToolNumber = cfg->readNumEntry (kpSettingLastTool, -1);
  321. }
  322. // private
  323. int kpMainWindow::toolNumber () const
  324. {
  325. int number = 0;
  326. for (TQPtrList <kpTool>::const_iterator it = m_tools.begin ();
  327. it != m_tools.end ();
  328. it++)
  329. {
  330. if (*it == tool ())
  331. return number;
  332. number++;
  333. }
  334. return -1;
  335. }
  336. // private
  337. void kpMainWindow::saveLastTool ()
  338. {
  339. int number = toolNumber ();
  340. if (number < 0 || number >= (int) m_tools.count ())
  341. return;
  342. TDEConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupTools);
  343. TDEConfigBase *cfg = cfgGroupSaver.config ();
  344. cfg->writeEntry (kpSettingLastTool, number);
  345. cfg->sync ();
  346. }
  347. // private
  348. bool kpMainWindow::maybeDragScrollingMainView () const
  349. {
  350. return (tool () && m_mainView &&
  351. tool ()->viewUnderStartPoint () == m_mainView);
  352. }
  353. // private slot
  354. bool kpMainWindow::slotDragScroll (const TQPoint &docPoint,
  355. const TQPoint &docLastPoint,
  356. int zoomLevel,
  357. bool *scrolled)
  358. {
  359. #if DEBUG_KP_MAIN_WINDOW
  360. kdDebug () << "kpMainWindow::slotDragScroll() maybeDragScrolling="
  361. << maybeDragScrollingMainView ()
  362. << endl;
  363. #endif
  364. if (maybeDragScrollingMainView ())
  365. {
  366. return m_scrollView->beginDragScroll (docPoint, docLastPoint, zoomLevel, scrolled);
  367. }
  368. else
  369. {
  370. return false;
  371. }
  372. }
  373. // private slot
  374. bool kpMainWindow::slotEndDragScroll ()
  375. {
  376. // (harmless if haven't started drag scroll)
  377. return m_scrollView->endDragScroll ();
  378. }
  379. // private slot
  380. void kpMainWindow::slotBeganDocResize ()
  381. {
  382. if (toolHasBegunShape ())
  383. tool ()->endShapeInternal ();
  384. recalculateStatusBarShape ();
  385. }
  386. // private slot
  387. void kpMainWindow::slotContinuedDocResize (const TQSize &)
  388. {
  389. recalculateStatusBarShape ();
  390. }
  391. // private slot
  392. void kpMainWindow::slotCancelledDocResize ()
  393. {
  394. recalculateStatusBar ();
  395. }
  396. // private slot
  397. void kpMainWindow::slotEndedDocResize (const TQSize &size)
  398. {
  399. #define DOC_RESIZE_COMPLETED() \
  400. { \
  401. m_docResizeToBeCompleted = false; \
  402. recalculateStatusBar (); \
  403. }
  404. // Prevent statusbar updates
  405. m_docResizeToBeCompleted = true;
  406. m_docResizeWidth = (size.width () > 0 ? size.width () : 1),
  407. m_docResizeHeight = (size.height () > 0 ? size.height () : 1);
  408. if (m_docResizeWidth == m_document->width () &&
  409. m_docResizeHeight == m_document->height ())
  410. {
  411. DOC_RESIZE_COMPLETED ();
  412. return;
  413. }
  414. // Blank status to avoid confusion if dialog comes up
  415. setStatusBarMessage ();
  416. setStatusBarShapePoints ();
  417. setStatusBarShapeSize ();
  418. if (kpTool::warnIfBigImageSize (m_document->width (),
  419. m_document->height (),
  420. m_docResizeWidth, m_docResizeHeight,
  421. i18n ("<qt><p>Resizing the image to"
  422. " %1x%2 may take a substantial amount of memory."
  423. " This can reduce system"
  424. " responsiveness and cause other application resource"
  425. " problems.</p>"
  426. "<p>Are you sure want to resize the"
  427. " image?</p></qt>")
  428. .arg (m_docResizeWidth)
  429. .arg (m_docResizeHeight),
  430. i18n ("Resize Image?"),
  431. i18n ("R&esize Image"),
  432. this))
  433. {
  434. m_commandHistory->addCommand (
  435. new kpToolResizeScaleCommand (
  436. false/*doc, not sel*/,
  437. m_docResizeWidth, m_docResizeHeight,
  438. kpToolResizeScaleCommand::Resize,
  439. this));
  440. saveDefaultDocSize (TQSize (m_docResizeWidth, m_docResizeHeight));
  441. }
  442. DOC_RESIZE_COMPLETED ();
  443. #undef DOC_RESIZE_COMPLETED
  444. }
  445. // private slot
  446. void kpMainWindow::slotDocResizeMessageChanged (const TQString &string)
  447. {
  448. #if DEBUG_KP_MAIN_WINDOW
  449. kdDebug () << "kpMainWindow::slotDocResizeMessageChanged(" << string
  450. << ") docResizeToBeCompleted=" << m_docResizeToBeCompleted
  451. << endl;
  452. #else
  453. (void) string;
  454. #endif
  455. if (m_docResizeToBeCompleted)
  456. return;
  457. recalculateStatusBarMessage ();
  458. }
  459. // private slot
  460. void kpMainWindow::slotActionPrevToolOptionGroup1 ()
  461. {
  462. if (!m_toolToolBar->shownToolWidget (0))
  463. return;
  464. m_toolToolBar->shownToolWidget (0)->selectPreviousOption ();
  465. updateToolOptionPrevNextActionsEnabled ();
  466. }
  467. // private slot
  468. void kpMainWindow::slotActionNextToolOptionGroup1 ()
  469. {
  470. if (!m_toolToolBar->shownToolWidget (0))
  471. return;
  472. m_toolToolBar->shownToolWidget (0)->selectNextOption ();
  473. updateToolOptionPrevNextActionsEnabled ();
  474. }
  475. // private slot
  476. void kpMainWindow::slotActionPrevToolOptionGroup2 ()
  477. {
  478. if (!m_toolToolBar->shownToolWidget (1))
  479. return;
  480. m_toolToolBar->shownToolWidget (1)->selectPreviousOption ();
  481. updateToolOptionPrevNextActionsEnabled ();
  482. }
  483. // private slot
  484. void kpMainWindow::slotActionNextToolOptionGroup2 ()
  485. {
  486. if (!m_toolToolBar->shownToolWidget (1))
  487. return;
  488. m_toolToolBar->shownToolWidget (1)->selectNextOption ();
  489. updateToolOptionPrevNextActionsEnabled ();
  490. }
  491. // public slots
  492. #define SLOT_TOOL(toolName) \
  493. void kpMainWindow::slotTool##toolName () \
  494. { \
  495. if (!m_toolToolBar) \
  496. return; \
  497. \
  498. if (tool () == m_tool##toolName) \
  499. return; \
  500. \
  501. m_toolToolBar->selectTool (m_tool##toolName); \
  502. }
  503. SLOT_TOOL (AirSpray)
  504. SLOT_TOOL (Brush)
  505. SLOT_TOOL (ColorPicker)
  506. SLOT_TOOL (ColorWasher)
  507. SLOT_TOOL (Curve)
  508. SLOT_TOOL (Ellipse)
  509. SLOT_TOOL (EllipticalSelection)
  510. SLOT_TOOL (Eraser)
  511. SLOT_TOOL (FloodFill)
  512. SLOT_TOOL (FreeFormSelection)
  513. SLOT_TOOL (Line)
  514. SLOT_TOOL (Pen)
  515. SLOT_TOOL (Polygon)
  516. SLOT_TOOL (Polyline)
  517. SLOT_TOOL (Rectangle)
  518. SLOT_TOOL (RectSelection)
  519. SLOT_TOOL (RoundedRectangle)
  520. SLOT_TOOL (Text)