26 #include <QKeySequence> 27 #include <QLatin1Char> 32 #include <KLocalizedString> 47 #define INS(n,v) m_standard_keys.insert(_(n), v) 73 INS(
"UnknownKey", QKeySequence::UnknownKey);
74 INS(
"HelpContents", QKeySequence::HelpContents);
75 INS(
"WhatsThis", QKeySequence::WhatsThis);
76 INS(
"Open", QKeySequence::Open);
77 INS(
"Close", QKeySequence::Close);
78 INS(
"Save", QKeySequence::Save);
79 INS(
"New", QKeySequence::New);
80 INS(
"Delete", QKeySequence::Delete);
81 INS(
"Cut", QKeySequence::Cut);
82 INS(
"Copy", QKeySequence::Copy);
83 INS(
"Paste", QKeySequence::Paste);
84 INS(
"Undo", QKeySequence::Undo);
85 INS(
"Redo", QKeySequence::Redo);
86 INS(
"Back", QKeySequence::Back);
87 INS(
"Forward", QKeySequence::Forward);
88 INS(
"Refresh", QKeySequence::Refresh);
89 INS(
"ZoomIn", QKeySequence::ZoomIn);
90 INS(
"ZoomOut", QKeySequence::ZoomOut);
91 INS(
"Print", QKeySequence::Print);
92 INS(
"AddTab", QKeySequence::AddTab);
93 INS(
"NextChild", QKeySequence::NextChild);
94 INS(
"PreviousChild", QKeySequence::PreviousChild);
95 INS(
"Find", QKeySequence::Find);
96 INS(
"FindNext", QKeySequence::FindNext);
97 INS(
"FindPrevious", QKeySequence::FindPrevious);
98 INS(
"Replace", QKeySequence::Replace);
99 INS(
"SelectAll", QKeySequence::SelectAll);
100 INS(
"Bold", QKeySequence::Bold);
101 INS(
"Italic", QKeySequence::Italic);
102 INS(
"Underline", QKeySequence::Underline);
103 INS(
"MoveToNextChar", QKeySequence::MoveToNextChar);
104 INS(
"MoveToPreviousChar", QKeySequence::MoveToPreviousChar);
105 INS(
"MoveToNextWord", QKeySequence::MoveToNextWord);
106 INS(
"MoveToPreviousWord", QKeySequence::MoveToPreviousWord);
107 INS(
"MoveToNextLine", QKeySequence::MoveToNextLine);
108 INS(
"MoveToPreviousLine", QKeySequence::MoveToPreviousLine);
109 INS(
"MoveToNextPage", QKeySequence::MoveToNextPage);
110 INS(
"MoveToPreviousPage", QKeySequence::MoveToPreviousPage);
111 INS(
"MoveToStartOfLine", QKeySequence::MoveToStartOfLine);
112 INS(
"MoveToEndOfLine", QKeySequence::MoveToEndOfLine);
113 INS(
"MoveToStartOfBlock", QKeySequence::MoveToStartOfBlock);
114 INS(
"MoveToEndOfBlock", QKeySequence::MoveToEndOfBlock);
115 INS(
"MoveToStartOfDocument", QKeySequence::MoveToStartOfDocument);
116 INS(
"MoveToEndOfDocument", QKeySequence::MoveToEndOfDocument);
117 INS(
"SelectNextChar", QKeySequence::SelectNextChar);
118 INS(
"SelectPreviousChar", QKeySequence::SelectPreviousChar);
119 INS(
"SelectNextWord", QKeySequence::SelectNextWord);
120 INS(
"SelectPreviousWord", QKeySequence::SelectPreviousWord);
121 INS(
"SelectNextLine", QKeySequence::SelectNextLine);
122 INS(
"SelectPreviousLine", QKeySequence::SelectPreviousLine);
123 INS(
"SelectNextPage", QKeySequence::SelectNextPage);
124 INS(
"SelectPreviousPage", QKeySequence::SelectPreviousPage);
125 INS(
"SelectStartOfLine", QKeySequence::SelectStartOfLine);
126 INS(
"SelectEndOfLine", QKeySequence::SelectEndOfLine);
127 INS(
"SelectStartOfBlock", QKeySequence::SelectStartOfBlock);
128 INS(
"SelectEndOfBlock", QKeySequence::SelectEndOfBlock);
129 INS(
"SelectStartOfDocument", QKeySequence::SelectStartOfDocument);
130 INS(
"SelectEndOfDocument", QKeySequence::SelectEndOfDocument);
131 INS(
"DeleteStartOfWord", QKeySequence::DeleteStartOfWord);
132 INS(
"DeleteEndOfWord", QKeySequence::DeleteEndOfWord);
133 INS(
"DeleteEndOfLine", QKeySequence::DeleteEndOfLine);
141 Q_ASSERT(command.length());
146 QKeySequence shortcut;
158 qWarning(
"no position field !");
164 if (param.length()) {
166 QRegExp rx(
_(
"::(\\w+)"), Qt::CaseInsensitive);
168 while ((p = rx.indexIn(param, 0)) >= 0) {
169 QString stdname = rx.cap(1);
173 QString expanded = sequence.toString();
174 param = param.replace(p, stdname.length() + 2, expanded);
177 qWarning(
"MenuManager::executeCommand: pos=%d, stdname='%s' " 178 "-> UNKNOWN ???", p,
DBG(stdname));
184 shortcut = QKeySequence::fromString(i18n(param.toLatin1()));
189 if (param.length())
id = param;
194 if (!shortcut.isEmpty()) {
195 static QMap<QString, QString> used_shortcuts;
197 QString sc = shortcut.toString();
198 QString m = pos.left(pos.indexOf(
_(
"/#")));
200 if (used_shortcuts.contains(sc) && (used_shortcuts[sc] != m)) {
201 qWarning(
"MenuManager: insertNode('%s')",
DBG(m));
202 qWarning(
" shortcut %s already in use for '%s'",
203 DBG(sc),
DBG(used_shortcuts[sc]));
205 used_shortcuts[sc] = m;
221 if (node) node->
clear();
226 const QString &entry,
227 const QString ¶m)
229 Q_ASSERT(entry.length());
230 if (!entry.length())
return;
237 if (cmd.contains(
_(
"%1"))) {
238 QString p = (param.length()) ? param : entry;
243 qWarning(
"MenuManager: could not find numbered Menu '%s'",
DBG(uid));
253 if (!group.length()) {
254 qWarning(
"MenuManager::selectItem('','%s'): no group!?",
DBG(uid));
258 if (group[0] != QLatin1Char(
'@')) {
259 qWarning(
"MenuManager::selectItem('%s','%s'): " 260 "invalid group name, does not start with '@'!",
266 if (!groups.contains(group)) {
267 qWarning(
"MenuManager::selectItem(): group '%s' not found!",
273 Q_ASSERT(group_node);
303 qWarning(
"MenuManager::setItemVisible('%s', '%d'): uid not found!",
322 if (groups.contains(uid)) {
332 qWarning(
"MenuManager::setItemEnabled('%s', '%d'): uid not found!",
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
const QString & firstParam()
static QString escape(const QString &text)
const QString & nextParam()