tdegraphics
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.

kpsinglekeytriggersaction.cpp 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. #define DEBUG_KP_SINGLE_KEY_TRIGGERS_ACTION 0
  24. //
  25. // kpSingleKeyTriggersActionInterface
  26. //
  27. #include <kpsinglekeytriggersaction.h>
  28. #include <kdebug.h>
  29. #include <kptool.h>
  30. kpSingleKeyTriggersActionInterface::kpSingleKeyTriggersActionInterface ()
  31. {
  32. m_singleKeyTriggersEnabled = true;
  33. }
  34. kpSingleKeyTriggersActionInterface::~kpSingleKeyTriggersActionInterface ()
  35. {
  36. }
  37. // public
  38. bool kpSingleKeyTriggersActionInterface::singleKeyTriggersEnabled () const
  39. {
  40. return m_singleKeyTriggersEnabled;
  41. }
  42. // public
  43. void kpSingleKeyTriggersActionInterface::enableSingleKeyTriggers (bool enable)
  44. {
  45. #if DEBUG_KP_SINGLE_KEY_TRIGGERS_ACTION
  46. kdDebug () << "kpSingleKeyTriggersActionInterface(" << /*virtual*/actionName ()
  47. << ")::enableSingleKeyTriggers(" << enable << ")"
  48. << endl;
  49. #endif
  50. if (enable == m_singleKeyTriggersEnabled)
  51. {
  52. #if DEBUG_KP_SINGLE_KEY_TRIGGERS_ACTION
  53. kdDebug () << "\tnop" << endl;
  54. #endif
  55. return;
  56. }
  57. m_singleKeyTriggersEnabled = enable;
  58. if (enable)
  59. {
  60. #if DEBUG_KP_SINGLE_KEY_TRIGGERS_ACTION
  61. kdDebug () << "\tre-enabling to " << m_fullShortcut.toString () << endl;
  62. #endif
  63. /*pure virtual*/actionSetShortcut (m_fullShortcut);
  64. }
  65. else // disable single key triggers
  66. {
  67. m_fullShortcut = /*pure virtual*/actionShortcut ();
  68. TDEShortcut newShortcut;
  69. if (kpTool::containsSingleKeyTrigger (m_fullShortcut, &newShortcut))
  70. {
  71. #if DEBUG_KP_SINGLE_KEY_TRIGGERS_ACTION
  72. kdDebug () << "\tchange shortcuts: old="
  73. << m_fullShortcut.toString ()
  74. << " new="
  75. << newShortcut.toString ()
  76. << endl;
  77. #endif
  78. /*pure virtual*/actionSetShortcut (newShortcut);
  79. }
  80. else
  81. {
  82. #if DEBUG_KP_SINGLE_KEY_TRIGGERS_ACTION
  83. kdDebug () << "\tshortcut is untouched "
  84. << m_fullShortcut.toString ()
  85. << endl;
  86. #endif
  87. }
  88. }
  89. }
  90. //
  91. // kpSingleKeyTriggersAction
  92. //
  93. kpSingleKeyTriggersAction::kpSingleKeyTriggersAction (const TQString &text,
  94. const TDEShortcut &shortcut,
  95. const TQObject *receiver, const char *slot,
  96. TDEActionCollection *parent, const char *name)
  97. : TDEAction (text, shortcut, receiver, slot, parent, name)
  98. {
  99. }
  100. kpSingleKeyTriggersAction::~kpSingleKeyTriggersAction ()
  101. {
  102. }
  103. //
  104. // kpSingleKeyTriggersAction implements kpSingleKeyTriggersActionInterface
  105. //
  106. // public virtual [base kpSingleKeyTriggersActionInterface]
  107. const char *kpSingleKeyTriggersAction::actionName () const
  108. {
  109. return name ();
  110. }
  111. // public virtual [base kpSingleKeyTriggersActionInterface]
  112. TDEShortcut kpSingleKeyTriggersAction::actionShortcut () const
  113. {
  114. return shortcut ();
  115. }
  116. // public virtual [base kpSingleKeyTriggersActionInterface]
  117. void kpSingleKeyTriggersAction::actionSetShortcut (const TDEShortcut &shortcut)
  118. {
  119. setShortcut (shortcut);
  120. }
  121. #include <kpsinglekeytriggersaction.moc>