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_settings.cpp 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 <tdeactionclasses.h>
  25. #include <tdeapplication.h>
  26. #include <tdeconfig.h>
  27. #include <kdebug.h>
  28. #include <kedittoolbar.h>
  29. #include <kkeydialog.h>
  30. #include <tdelocale.h>
  31. #include <tdemessagebox.h>
  32. #include <kstdaction.h>
  33. #include <kpdefs.h>
  34. #include <kpdocument.h>
  35. #include <kptool.h>
  36. #include <kptooltoolbar.h>
  37. // private
  38. void kpMainWindow::setupSettingsMenuActions ()
  39. {
  40. TDEActionCollection *ac = actionCollection ();
  41. // Settings/Toolbars |> %s
  42. setStandardToolBarMenuEnabled (true);
  43. // Settings/Show Statusbar
  44. createStandardStatusBarAction ();
  45. m_actionFullScreen = KStdAction::fullScreen (TQT_TQOBJECT(this), TQT_SLOT (slotFullScreen ()), ac,
  46. this/*window*/);
  47. m_actionShowPath = new TDEToggleAction (i18n ("Show &Path"), 0,
  48. TQT_TQOBJECT(this), TQT_SLOT (slotShowPathToggled ()), ac, "settings_show_path");
  49. m_actionShowPath->setCheckedState (i18n ("Hide &Path"));
  50. slotEnableSettingsShowPath ();
  51. m_actionKeyBindings = KStdAction::keyBindings (TQT_TQOBJECT(this), TQT_SLOT (slotKeyBindings ()), ac);
  52. m_actionConfigureToolbars = KStdAction::configureToolbars (TQT_TQOBJECT(this), TQT_SLOT (slotConfigureToolBars ()), ac);
  53. // m_actionConfigure = KStdAction::preferences (TQT_TQOBJECT(this), TQT_SLOT (slotConfigure ()), ac);
  54. enableSettingsMenuDocumentActions (false);
  55. }
  56. // private
  57. void kpMainWindow::enableSettingsMenuDocumentActions (bool /*enable*/)
  58. {
  59. }
  60. // private slot
  61. void kpMainWindow::slotFullScreen ()
  62. {
  63. if (m_actionFullScreen->isChecked ())
  64. showFullScreen ();
  65. else
  66. showNormal ();
  67. }
  68. // private slot
  69. void kpMainWindow::slotEnableSettingsShowPath ()
  70. {
  71. #if DEBUG_KP_MAIN_WINDOW
  72. kdDebug () << "kpMainWindow::slotEnableSettingsShowPath()" << endl;
  73. #endif
  74. const bool enable = (m_document && !m_document->url ().isEmpty ());
  75. m_actionShowPath->setEnabled (enable);
  76. m_actionShowPath->setChecked (enable && m_configShowPath);
  77. }
  78. // private slot
  79. void kpMainWindow::slotShowPathToggled ()
  80. {
  81. #if DEBUG_KP_MAIN_WINDOW
  82. kdDebug () << "kpMainWindow::slotShowPathToggled()" << endl;
  83. #endif
  84. m_configShowPath = m_actionShowPath->isChecked ();
  85. slotUpdateCaption ();
  86. TDEConfigGroupSaver cfgGroupSaver (kapp->config (), kpSettingsGroupGeneral);
  87. TDEConfigBase *cfg = cfgGroupSaver.config ();
  88. cfg->writeEntry (kpSettingShowPath, m_configShowPath);
  89. cfg->sync ();
  90. }
  91. // private slot
  92. void kpMainWindow::slotKeyBindings ()
  93. {
  94. #if DEBUG_KP_MAIN_WINDOW
  95. kdDebug () << "kpMainWindow::slotKeyBindings()" << endl;
  96. #endif
  97. if (toolHasBegunShape ())
  98. tool ()->endShapeInternal ();
  99. bool singleKeyTriggersDisabled = !actionsSingleKeyTriggersEnabled ();
  100. if (singleKeyTriggersDisabled)
  101. enableActionsSingleKeyTriggers (true);
  102. if (KKeyDialog::configure (actionCollection (), this))
  103. {
  104. #if DEBUG_KP_MAIN_WINDOW
  105. kdDebug () << "\tdialog accepted" << endl;
  106. #endif
  107. // TODO: PROPAGATE: thru mainWindow's and interprocess
  108. if (singleKeyTriggersDisabled)
  109. enableActionsSingleKeyTriggers (false);
  110. }
  111. }
  112. // private slot
  113. void kpMainWindow::slotConfigureToolBars ()
  114. {
  115. #if DEBUG_KP_MAIN_WINDOW
  116. kdDebug () << "kpMainWindow::slotConfigureToolBars()" << endl;
  117. #endif
  118. if (toolHasBegunShape ())
  119. tool ()->endShapeInternal ();
  120. //saveMainWindowSettings (kapp->config (), autoSaveGroup ());
  121. KEditToolbar dialog (actionCollection (),
  122. TQString()/*default ui.rc file*/,
  123. true/*global resource*/,
  124. this/*parent*/);
  125. // Clicking on OK after Apply brings up the dialog (below) again.
  126. // Bug with KEditToolBar.
  127. dialog.showButtonApply (false);
  128. connect (&dialog, TQT_SIGNAL (newToolbarConfig ()),
  129. this, TQT_SLOT (slotNewToolBarConfig ()));
  130. dialog.exec ();
  131. }
  132. // private slot
  133. void kpMainWindow::slotNewToolBarConfig ()
  134. {
  135. #if DEBUG_KP_MAIN_WINDOW
  136. kdDebug () << "kpMainWindow::slotNewToolBarConfig()" << endl;
  137. #endif
  138. // Wouldn't it be nice if createGUI () didn't nuke all the TDEToolBar's?
  139. // (including my non-XMLGUI ones whose states take a _lot_ of effort to
  140. // restore).
  141. // TODO: this message is probably unacceptable - so restore the state of
  142. // my toolbars instead.
  143. KMessageBox::information (this,
  144. i18n ("You have to restart KolourPaint for these changes to take effect."),
  145. i18n ("Toolbar Settings Changed"),
  146. TQString::fromLatin1 ("ToolBarSettingsChanged"));
  147. //createGUI();
  148. //applyMainWindowSettings (kapp->config (), autoSaveGroup ());
  149. }
  150. // private slot
  151. void kpMainWindow::slotConfigure ()
  152. {
  153. // TODO
  154. }