31 #include <QtCore/QDate>
32 #include <QtCore/QFile>
33 #include <QtCore/QCoreApplication>
34 #include <QtCore/QTextStream>
35 #include <QtCore/QStringList>
39 if ( key ==
"Alt" || key ==
"Ctrl" || key ==
"Enter" || key ==
"Esc" ||
40 key ==
"Shift" || key ==
"Tab" ) {
41 return QString(
'&' + key +
';');
43 if ( key ==
"Left" || key ==
"Right" || key ==
"Up" || key ==
"Down" ) {
44 return QString(
"<keysym>" + key +
" Arrow</keysym>");
46 if ( key ==
"Backspace" || key ==
"Menu" ) {
47 return QString(
"<keysym>" + key +
"</keysym>");
49 if ( key ==
"Plus" ) {
50 return QString(
"<keycap>+</keycap>");
52 if ( key ==
"Minus" ) {
53 return QString(
"<keycap>-</keycap>");
55 return QString(
"<keycap>" + key +
"</keycap>");
60 QString markup =
"<!ENTITY KeyCombo_";
73 markup +=
"OpenRecent";
109 markup +=
"SelectAll";
112 markup +=
"Deselect";
115 markup +=
"DeleteWordBack";
118 markup +=
"DeleteWordForward";
124 markup +=
"FindNext";
127 markup +=
"FindPrev";
148 markup +=
"GotoLine";
151 markup +=
"AddBookmark";
172 markup +=
"ShowMenubar";
178 markup +=
"WhatsThis";
181 markup +=
"TextCompletion";
184 markup +=
"PrevCompletion";
187 markup +=
"NextCompletion";
190 markup +=
"SubstringCompletion";
193 markup +=
"RotateUp";
196 markup +=
"RotateDown";
205 markup +=
"FullScreen";
208 markup +=
"BackwardWord";
211 markup +=
"ForwardWord";
214 markup +=
"BeginningOfLine";
217 markup +=
"EndOfLine";
220 markup +=
"PastSelection";
226 markup +=
"PrintPreview";
235 markup +=
"ActualSize";
238 markup +=
"FitToPage";
241 markup +=
"FitToWidth";
244 markup +=
"FitToHeight";
253 markup +=
"GotoPage";
256 markup +=
"DocumentBack";
259 markup +=
"DocumentForward";
262 markup +=
"EditBookmarks";
265 markup +=
"Spelling";
268 markup +=
"ShowToolbar";
271 markup +=
"ShowStatusbar";
274 markup +=
"SaveOptions";
277 markup +=
"KeyBindings";
280 markup +=
"Preferences";
283 markup +=
"ConfigureToolbars";
286 markup +=
"ConfigureNotifications";
289 markup +=
"TipofDay";
292 markup +=
"ReportBug";
295 markup +=
"SwitchApplicationLanguage";
298 markup +=
"AboutApp";
301 markup +=
"AboutKDE";
310 QString firstSequence = internalStr.left( internalStr.indexOf(
';' ) );
311 const QStringList keys = firstSequence.split(
'+',QString::SkipEmptyParts );
312 if ( keys.empty() ) {
316 if ( keys.count() == 1 ) {
317 if ( keys.first().startsWith( QLatin1String(
"XF86") ) ) {
322 markup +=
"<keycombo action=\"Simul\">";
323 foreach(
const QString &key, keys ) {
324 if ( key.startsWith( QLatin1String(
"XF86") ) ) {
329 markup +=
"</keycombo>";
335 int main(
int argc,
char **argv )
338 cmdLineOptions.
add(
"o");
339 cmdLineOptions.
add(
"output <file>",
ki18n(
"Output file"),
"kde-standard-accels.entities");
341 KAboutData aboutData(
"genshortcutents", 0,
ki18n(
"genshortcutents"),
"1.0",
342 ki18n(
"Generates DocBook entities for key shortcuts of standard actions" ));
353 QFile outputFile( outputFileName );
354 if ( !outputFile.open( QIODevice::WriteOnly ) ) {
355 qDebug(
"Failed to open %s for writing.", qPrintable( outputFileName ) );
359 QTextStream stream( &outputFile );
360 stream <<
"<!-- Generated by "
362 << aboutData.
version() +
" on "
363 << QDateTime::currentDateTime().toString() +
".\n";
364 stream <<
" Do not bother to fiddle with this, your modifications will be\n"
365 <<
" overwritten as soon as the file is regenerated. -->\n";
369 stream << entityForAccel( static_cast<KStandardShortcut::StandardShortcut>(i) ) <<
"\n";
static void addCmdLineOptions(const KCmdLineOptions &options, const KLocalizedString &name=KLocalizedString(), const QByteArray &id=QByteArray(), const QByteArray &afterId=QByteArray())
KCmdLineOptions & add(const QByteArray &name, const KLocalizedString &description=KLocalizedString(), const QByteArray &defaultValue=QByteArray())
KLocalizedString ki18n(const char *msg)
static KCmdLineArgs * parsedArgs(const QByteArray &id=QByteArray())
const KShortcut & shortcut(StandardShortcut id)
int main(int argc, char **argv)
QString programName() const
static QString entityForAccel(KStandardShortcut::StandardShortcut accel)
static QString keyAsMarkup(const QString &key)
static void init(int argc, char **argv, const QByteArray &appname, const QByteArray &catalog, const KLocalizedString &programName, const QByteArray &version, const KLocalizedString &description=KLocalizedString(), StdCmdLineArgs stdargs=StdCmdLineArgs(CmdLineArgQt|CmdLineArgKDE))
QString getOption(const QByteArray &option) const