• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
parleyactions.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 Copyright 2009 Frederik Gladhorn <gladhorn@kde.org>
3 ***************************************************************************/
4 
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
13 
14 #include "parleyactions.h"
15 
16 #include "prefs.h"
17 
18 #include <KStandardAction>
19 #include <KLocalizedString>
20 #include <KActionCollection>
21 #include <knewstuff3/knewstuffaction.h>
22 #include <KToggleAction>
23 
24 namespace ParleyActions {
25  namespace Private {
26  KAction* createCustomAction(const QObject* recvr, const char* slot, QObject* parent,
27  const QString& name,
28  const QString& text,
29  const QString& helpText,
30  const QString& iconName = QString(),
31  bool toggle = false)
32  {
33  // Create KAction or KToggleAction
34  KAction* pAction;
35  if (toggle) {
36  pAction = new KToggleAction(parent);
37  } else {
38  pAction = new KAction(parent);
39  }
40  // Set ObjectName, Text and HelpText
41  pAction->setObjectName(name);
42  pAction->setText(text);
43  pAction->setHelpText(helpText);
44 
45  // Icon
46  if (!iconName.isEmpty()) {
47  pAction->setIcon(KIcon(iconName));
48  }
49 
50  // Connect the action
51  pAction->connect(pAction, SIGNAL(triggered(bool)), recvr, slot);
52 
53  // If parent is a KActionCollection, add the new action to it
54  KActionCollection *collection = qobject_cast<KActionCollection *>(parent);
55  if (pAction && collection)
56  collection->addAction(pAction->objectName(), pAction);
57  return pAction;
58  }
59  }
60 }
61 
62 KAction* ParleyActions::create(ParleyAction id, const QObject* recvr, const char* slot, QObject* parent)
63 {
64  KAction* pAction = 0;
65 
66  switch (id) {
67  case FileNew:
68  pAction = KStandardAction::openNew(recvr, slot, parent);
69  pAction->setHelpText(i18n("Creates a new vocabulary collection"));
70  break;
71  case FileOpen:
72  pAction = KStandardAction::open(recvr, slot, parent);
73  pAction->setHelpText(i18n("Opens an existing vocabulary collection"));
74  break;
75  case FileOpenDownloaded:
76  pAction = Private::createCustomAction(recvr, slot, parent,
77  "file_open_downloaded", i18n("Open &Downloaded Vocabularies..."),
78  i18n("Open downloaded vocabulary collections"), "get-hot-new-stuff");
79  break;
80  case FileSave:
81  pAction = KStandardAction::save(recvr, slot, parent);
82  pAction->setHelpText(i18n("Save the active vocabulary collection"));
83  break;
84  case FileSaveAs:
85  pAction = KStandardAction::saveAs(recvr, slot, parent);
86  pAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
87  pAction->setHelpText(i18n("Save the active vocabulary collection with a different name"));
88  break;
89  case FileExport:
90  pAction = Private::createCustomAction(recvr, slot, parent,
91  "file_export", i18n("&Export..."),
92  i18n("Export to HTML or CSV"), "document-export");
93  break;
94  case FileProperties:
95  pAction = Private::createCustomAction(recvr, slot, parent,
96  "file_properties", i18n("&Properties..."),
97  i18n("Edit document properties"), "document-properties");
98  break;
99  case FileClose:
100  pAction = Private::createCustomAction(recvr, slot, parent,
101  "file_close", i18n("&Start Page"),
102  i18n("Close the current vocabulary collection and show the start page"), "go-home");
103  break;
104  case FileQuit:
105  pAction = KStandardAction::quit(recvr, slot, parent);
106  pAction->setHelpText(i18n("Quit Parley"));
107  break;
108  case Preferences:
109  pAction = KStandardAction::preferences(recvr, slot, parent);
110  pAction->setHelpText(i18n("Show the configuration dialog"));
111  break;
112  case LanguagesProperties:
113  pAction = Private::createCustomAction(recvr, slot, parent,
114  "edit_languages", i18n("&Languages..."),
115  i18n("Edit which languages are in the collection and their grammar properties."), "set-language");
116  break;
117  case RemoveGrades:
118  pAction = Private::createCustomAction(recvr, slot, parent,
119  "vocab_remove_grades", i18n("Remove Grades"),
120  i18n("Remove all grades from the current document"), "edit-clear");
121  break;
122  case CheckSpelling:
123  pAction = KStandardAction::spelling(recvr, slot, parent);
124  break;
125  case ToggleShowSublessons:
126  pAction = Private::createCustomAction(recvr, slot, parent,
127  "lesson_showsublessonentries", i18n("Show Entries from Child Lessons"),
128  i18n("Enable to also see the entries of child lessons in each lesson."),
129  QString(), true);
130  pAction->setChecked(Prefs::showSublessonentries());
131  break;
132  case AutomaticTranslation:
133  pAction = Private::createCustomAction(recvr, slot, parent,
134  "lesson_automatictranslation", i18n("Automatic Translation"),
135  i18n("Enable automatic translation of the lesson entries."),
136  QString(), true);
137  pAction->setChecked(Prefs::automaticTranslation());
138  break;
139  case StartPractice:
140  pAction = Private::createCustomAction(recvr, slot, parent,
141  "practice_start", i18n("Start Practice..."),
142  i18n("Start practicing"), "practice-start");
143  break;
144  case ConfigurePractice:
145  pAction = Private::createCustomAction(recvr, slot, parent,
146  "practice_configure", i18n("Configure Practice..."),
147  i18n("Change practice settings"), "practice-setup");
148  break;
149  case EnterEditMode:
150  pAction = Private::createCustomAction(recvr, slot, parent,
151  "document_edit", i18n("Editor"),
152  i18n("Switch to vocabulary editor"), "document-edit");
153  break;
154  case ToggleSearchBar:
155  pAction = Private::createCustomAction(recvr, slot, parent,
156  "config_show_search", i18n("Show Se&arch"),
157  i18n("Toggle display of the search bar"),
158  QString(), true);
159  pAction->setChecked(Prefs::showSearch());
160  break;
161  case SearchVocabulary:
162  pAction = KStandardAction::find(recvr, slot, parent);
163  break;
164  case ShowScriptManager:
165  pAction = Private::createCustomAction(recvr, slot, parent,
166  "show_script_manager", i18n("&Script Manager"),
167  i18n("Enable and disable scripts"), "set-language");
168  break;
169  }
170 
171  Q_ASSERT(pAction);
172  return pAction;
173 }
174 
175 
176 KRecentFilesAction* ParleyActions::createRecentFilesAction(const QObject* recvr, const char* slot, QObject* parent)
177 {
178  return KStandardAction::openRecent(recvr, slot, parent);
179 }
180 
181 KAction* ParleyActions::createDownloadAction(const QObject* recvr, const char* slot, KActionCollection* collection)
182 {
183  KAction *pAction = KNS3::standardAction(i18n("Download New Vocabularies..."), recvr, slot, collection, "file_ghns");
184  pAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
185  pAction->setHelpText(i18n("Downloads new vocabulary collections"));
186  return pAction;
187 }
188 
189 KAction* ParleyActions::createUploadAction(const QObject* recvr, const char* slot, KActionCollection* collection)
190 {
191  KAction *pAction = KNS3::standardActionUpload(i18n("&Upload Vocabulary Document..."), recvr, slot, collection, "file_upload");
192  pAction->setHelpText(i18n("Share the current vocabulary collection with other users"));
193  return pAction;
194 }
ParleyActions::create
KAction * create(ParleyAction id, const QObject *recvr, const char *slot, QObject *parent)
Definition: parleyactions.cpp:62
ParleyActions::FileNew
Definition: parleyactions.h:24
ParleyActions::AutomaticTranslation
Definition: parleyactions.h:35
prefs.h
QObject
ParleyActions::SearchVocabulary
Definition: parleyactions.h:38
ParleyActions::FileOpen
Definition: parleyactions.h:25
Prefs::showSearch
static bool showSearch()
Get Toggle display of the search bar.
Definition: prefs.h:768
parleyactions.h
ParleyActions::FileProperties
Definition: parleyactions.h:28
ParleyActions::FileExport
Definition: parleyactions.h:27
ParleyActions::ToggleSearchBar
Definition: parleyactions.h:38
ParleyActions::ParleyAction
ParleyAction
Definition: parleyactions.h:23
ParleyActions::ConfigurePractice
Definition: parleyactions.h:36
ParleyActions::ShowScriptManager
Definition: parleyactions.h:39
ParleyActions::CheckSpelling
Definition: parleyactions.h:33
ParleyActions::ToggleShowSublessons
Definition: parleyactions.h:34
ParleyActions::FileClose
Definition: parleyactions.h:29
ParleyActions::FileSave
Definition: parleyactions.h:26
ParleyActions::RemoveGrades
Definition: parleyactions.h:32
ParleyActions::StartPractice
Definition: parleyactions.h:36
ParleyActions::Private::createCustomAction
KAction * createCustomAction(const QObject *recvr, const char *slot, QObject *parent, const QString &name, const QString &text, const QString &helpText, const QString &iconName=QString(), bool toggle=false)
Definition: parleyactions.cpp:26
ParleyActions::createDownloadAction
KAction * createDownloadAction(const QObject *recvr, const char *slot, KActionCollection *collection)
Definition: parleyactions.cpp:181
ParleyActions::createRecentFilesAction
KRecentFilesAction * createRecentFilesAction(const QObject *recvr, const char *slot, QObject *parent)
Definition: parleyactions.cpp:176
Prefs::showSublessonentries
static bool showSublessonentries()
Get When enabled a lesson also shows entries from its sublessons.
Definition: prefs.h:787
ParleyActions::LanguagesProperties
Definition: parleyactions.h:31
ParleyActions::Preferences
Definition: parleyactions.h:30
ParleyActions::EnterEditMode
Definition: parleyactions.h:37
ParleyActions::FileSaveAs
Definition: parleyactions.h:26
ParleyActions::FileQuit
Definition: parleyactions.h:29
Prefs::automaticTranslation
static bool automaticTranslation()
Get Enable automatic translation of the lesson entries.
Definition: prefs.h:236
ParleyActions::FileOpenDownloaded
Definition: parleyactions.h:25
ParleyActions::createUploadAction
KAction * createUploadAction(const QObject *recvr, const char *slot, KActionCollection *collection)
Definition: parleyactions.cpp:189
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal