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