TDE System Settings – easy to use control center
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.

159 lines
4.5KB

  1. /**
  2. * Copyright (C) 2005 Benjamin C Meyer (ben+tdecmodulemenu at meyerhome dot net)
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public License
  15. * along with this library; see the file COPYING.LIB. If not, write to
  16. * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef KCMMODULEMENU_H
  20. #define KCMMODULEMENU_H
  21. #include <tdecmoduleinfo.h>
  22. class TDECModuleMenuPrivate;
  23. /**
  24. * List of all KCM modules inside a FreeDesktop.org menu
  25. * The menu spec is located at: http://www.freedesktop.org/Standards/menu-spec
  26. *
  27. * For a menu to show up in TDE three files need to be installed in the system.
  28. *
  29. * example-merge.menu
  30. * example.directory
  31. * example.menu
  32. *
  33. * example-merge.menu should be installed in xdg/menus/applications-merged/
  34. * so that ksyscoco will find it.
  35. *
  36. * \code
  37. * <!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
  38. * "http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd">
  39. *
  40. * <Menu>
  41. * <!-- The following menus are hidden by default -->
  42. * <Menu>
  43. * <Name>Example Menu</Name>
  44. * <Directory>example.directory</Directory>
  45. * <MergeFile>../example.menu</MergeFile>
  46. * </Menu>
  47. * </Menu>
  48. * \endcode
  49. *
  50. * example.directory should be installed in share/desktop-directories/ where files
  51. * such as tde-system.directory reside. It is important that it have X-TDE-BaseGroup
  52. * as this value is the class constructor argument.
  53. *
  54. * \code
  55. * [Desktop Entry]
  56. * Encoding=UTF-8
  57. * Name=Example Menu
  58. * NoDisplay=true
  59. * Icon=package_settings
  60. * X-TDE-BaseGroup=examplemenu
  61. * \endcode
  62. *
  63. * example.menu should be installed in xdg/menus/ so that ksyscoco will find
  64. * it. See the above url for example menus. After changing the menu you need
  65. * to run "tdebuildsycoca" to regenerate the cache as ksyscoco will cache the
  66. * menu and is a file that doesn't change on users.
  67. */
  68. /**
  69. * A menu consists of menu items. An item is either another menu or a module.
  70. */
  71. class MenuItem {
  72. public:
  73. MenuItem( bool isMenu=false ){ menu = isMenu; };
  74. bool menu;
  75. TQString subMenu;
  76. TQString caption;
  77. TDECModuleInfo item;
  78. };
  79. class TDECModuleMenu : public TQValueList<TDECModuleInfo>
  80. {
  81. public:
  82. TQString caption;
  83. /**
  84. * @param the X-TDE-BaseGroup item from the directory file
  85. * that should be loaded.
  86. *
  87. * Example:
  88. * In example.directory
  89. * X-TDE-BaseGroup=examplemenu
  90. * so menuName should be "systemsettings"
  91. */
  92. TDECModuleMenu( const TQString &menuName );
  93. /**
  94. * Deconstructor
  95. */
  96. virtual ~TDECModuleMenu();
  97. /**
  98. * Returns item of a menu path. An empty string is the top level.
  99. * Item order is maintained from the menu file.
  100. * @param path to return submenus from.
  101. * @return all items in menuPath.
  102. */
  103. TQValueList<MenuItem> menuList( const TQString &menuPath=TQString() );
  104. /**
  105. * Returns the modules in a menu path. An empty string is the top level.
  106. * @param menu to return modules from.
  107. * @returns only the top level modules of menuPath
  108. */
  109. TQValueList<TDECModuleInfo> modules( const TQString &menuPath=TQString() );
  110. /**
  111. * Returns the sub menus of a menu path. An empty string is the top level.
  112. * @param path to return submenus from.
  113. * @return only the submenus of menuPath.
  114. */
  115. TQStringList submenus( const TQString &menuPath=TQString() );
  116. protected:
  117. /**
  118. * Reads all the desktop files from the pathName and saves/loads
  119. * all of the kcm's into the list.
  120. * This is the <Name> from the merge.menu file
  121. * @param pathName the base path name of the menu.
  122. */
  123. virtual void readMenu( const TQString &pathName );
  124. /**
  125. * Function that determines if the entry from readMenu
  126. * should be added to the list or not. It checks
  127. * to see if it is an authorized kcm module that has a library.
  128. *
  129. * Overload to filter out kcm modules
  130. *
  131. * @entry to test
  132. * @return true if it should be included
  133. */
  134. virtual bool addEntry( KSycocaEntry *entry );
  135. private:
  136. TDECModuleMenuPrivate *d;
  137. TQString deriveCaptionFromPath( const TQString &menuPath );
  138. };
  139. #endif // KCMMODULEMENU_H