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

parley

  • sources
  • kde-4.14
  • 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 {
26 namespace Private
27 {
28 KAction* createCustomAction(const QObject* recvr, const char* slot, QObject* parent,
29  const QString& name,
30  const QString& text,
31  const QString& helpText,
32  const QString& iconName = QString(),
33  bool toggle = false)
34 {
35  // Create KAction or KToggleAction
36  KAction* pAction;
37  if (toggle) {
38  pAction = new KToggleAction(parent);
39  } else {
40  pAction = new KAction(parent);
41  }
42  // Set ObjectName, Text and HelpText
43  pAction->setObjectName(name);
44  pAction->setText(text);
45  pAction->setHelpText(helpText);
46 
47  // Icon
48  if (!iconName.isEmpty()) {
49  pAction->setIcon(KIcon(iconName));
50  }
51 
52  // Connect the action
53  pAction->connect(pAction, SIGNAL(triggered(bool)), recvr, slot);
54 
55  // If parent is a KActionCollection, add the new action to it
56  KActionCollection *collection = qobject_cast<KActionCollection *>(parent);
57  if (pAction && collection)
58  collection->addAction(pAction->objectName(), pAction);
59  return pAction;
60 }
61 }
62 }
63 
64 KAction* ParleyActions::create(ParleyAction id, const QObject* recvr, const char* slot, QObject* parent)
65 {
66  KAction* pAction = 0;
67 
68  switch (id) {
69  case FileNew:
70  pAction = KStandardAction::openNew(recvr, slot, parent);
71  pAction->setHelpText(i18n("Creates a new vocabulary collection"));
72  break;
73  case FileOpen:
74  pAction = KStandardAction::open(recvr, slot, parent);
75  pAction->setHelpText(i18n("Opens an existing vocabulary collection"));
76  break;
77  case FileOpenDownloaded:
78  pAction = Private::createCustomAction(recvr, slot, parent,
79  "file_open_downloaded", i18n("Open &Downloaded Vocabularies..."),
80  i18n("Open downloaded vocabulary collections"), "get-hot-new-stuff");
81  break;
82  case FileSave:
83  pAction = KStandardAction::save(recvr, slot, parent);
84  pAction->setHelpText(i18n("Save the active vocabulary collection"));
85  break;
86  case FileSaveAs:
87  pAction = KStandardAction::saveAs(recvr, slot, parent);
88  pAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
89  pAction->setHelpText(i18n("Save the active vocabulary collection with a different name"));
90  break;
91  case FileExport:
92  pAction = Private::createCustomAction(recvr, slot, parent,
93  "file_export", i18n("&Export..."),
94  i18n("Export to HTML or CSV"), "document-export");
95  break;
96  case FileProperties:
97  pAction = Private::createCustomAction(recvr, slot, parent,
98  "file_properties", i18n("&Properties..."),
99  i18n("Edit document properties"), "document-properties");
100  break;
101  case FileClose:
102  pAction = Private::createCustomAction(recvr, slot, parent,
103  "file_close", i18n("Dashboard"),
104  i18n("Close the current vocabulary collection and show the dashboard"), "go-home");
105  break;
106  case FileQuit:
107  pAction = KStandardAction::quit(recvr, slot, parent);
108  pAction->setHelpText(i18n("Quit Parley"));
109  break;
110  case Preferences:
111  pAction = KStandardAction::preferences(recvr, slot, parent);
112  pAction->setHelpText(i18n("Show the configuration dialog"));
113  break;
114  case LanguagesProperties:
115  pAction = Private::createCustomAction(recvr, slot, parent,
116  "edit_languages", i18n("&Languages..."),
117  i18n("Edit which languages are in the collection and their grammar properties."), "set-language");
118  break;
119  case RemoveGrades:
120  pAction = Private::createCustomAction(recvr, slot, parent,
121  "vocab_remove_grades", i18n("Remove Confidence Levels"),
122  i18n("Remove all confidence levels from the current document"), "edit-clear");
123  break;
124  case CheckSpelling:
125  pAction = KStandardAction::spelling(recvr, slot, parent);
126  break;
127  case ToggleShowSublessons:
128  pAction = Private::createCustomAction(recvr, slot, parent,
129  "lesson_showsublessonentries", i18n("Show Entries from Child Units"),
130  i18n("Enable to also see the entries of child units in each unit."),
131  QString(), true);
132  pAction->setChecked(Prefs::showSublessonentries());
133  break;
134  case AutomaticTranslation:
135  pAction = Private::createCustomAction(recvr, slot, parent,
136  "lesson_automatictranslation", i18n("Automatic Translation"),
137  i18n("Enable automatic translation of the unit entries."),
138  QString(), true);
139  pAction->setChecked(Prefs::automaticTranslation());
140  break;
141  case StartPractice:
142  pAction = Private::createCustomAction(recvr, slot, parent,
143  "practice_start", i18n("Start Practice..."),
144  i18n("Start practicing"), "practice-start");
145  break;
146  case ConfigurePractice:
147  pAction = Private::createCustomAction(recvr, slot, parent,
148  "practice_configure", i18n("Configure Practice..."),
149  i18n("Change practice settings"), "practice-setup");
150  break;
151  case ExportPracticeResults:
152  pAction = Private::createCustomAction(recvr, slot, parent,
153  "practice_export", i18n("Export results..."),
154  i18n("Write a file with the results of the practice"), "document-export");
155  break;
156  case EnterEditMode:
157  pAction = Private::createCustomAction(recvr, slot, parent,
158  "document_edit", i18n("Editor"),
159  i18n("Switch to vocabulary editor"), "document-edit");
160  break;
161  case ToggleSearchBar:
162  pAction = Private::createCustomAction(recvr, slot, parent,
163  "config_show_search", i18n("Show Se&arch"),
164  i18n("Toggle display of the search bar"),
165  QString(), true);
166  pAction->setChecked(Prefs::showSearch());
167  break;
168  case SearchVocabulary:
169  pAction = KStandardAction::find(recvr, slot, parent);
170  break;
171  case ShowScriptManager:
172  pAction = Private::createCustomAction(recvr, slot, parent,
173  "show_script_manager", i18n("&Script Manager"),
174  i18n("Enable and disable scripts"), "set-language");
175  break;
176  }
177 
178  Q_ASSERT(pAction);
179  return pAction;
180 }
181 
182 
183 KRecentFilesAction* ParleyActions::createRecentFilesAction(const QObject* recvr, const char* slot, QObject* parent)
184 {
185  return KStandardAction::openRecent(recvr, slot, parent);
186 }
187 
188 KAction* ParleyActions::createDownloadAction(const QObject* recvr, const char* slot, KActionCollection* collection)
189 {
190  KAction *pAction = KNS3::standardAction(i18n("Download New Vocabularies..."), recvr, slot, collection, "file_ghns");
191  pAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
192  pAction->setHelpText(i18n("Downloads new vocabulary collections"));
193  return pAction;
194 }
195 
196 KAction* ParleyActions::createUploadAction(const QObject* recvr, const char* slot, KActionCollection* collection)
197 {
198  KAction *pAction = KNS3::standardActionUpload(i18n("&Upload Vocabulary Document..."), recvr, slot, collection, "file_upload");
199  pAction->setHelpText(i18n("Share the current vocabulary collection with other users"));
200  return pAction;
201 }
ParleyActions::create
KAction * create(ParleyAction id, const QObject *recvr, const char *slot, QObject *parent)
Definition: parleyactions.cpp:64
ParleyActions::FileNew
Definition: parleyactions.h:25
ParleyActions::AutomaticTranslation
Definition: parleyactions.h:36
prefs.h
ParleyActions::SearchVocabulary
Definition: parleyactions.h:39
ParleyActions::FileOpen
Definition: parleyactions.h:26
Prefs::showSearch
static bool showSearch()
Get Toggle display of the search bar.
Definition: prefs.h:830
parleyactions.h
ParleyActions::FileProperties
Definition: parleyactions.h:29
ParleyActions::FileExport
Definition: parleyactions.h:28
ParleyActions::ToggleSearchBar
Definition: parleyactions.h:39
ParleyActions::ParleyAction
ParleyAction
Definition: parleyactions.h:24
QObject
ParleyActions::ConfigurePractice
Definition: parleyactions.h:37
ParleyActions::ShowScriptManager
Definition: parleyactions.h:40
ParleyActions::ExportPracticeResults
Definition: parleyactions.h:37
ParleyActions::CheckSpelling
Definition: parleyactions.h:34
ParleyActions::ToggleShowSublessons
Definition: parleyactions.h:35
ParleyActions::FileClose
Definition: parleyactions.h:30
QString
ParleyActions::FileSave
Definition: parleyactions.h:27
ParleyActions::RemoveGrades
Definition: parleyactions.h:33
ParleyActions::StartPractice
Definition: parleyactions.h:37
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:28
ParleyActions::createDownloadAction
KAction * createDownloadAction(const QObject *recvr, const char *slot, KActionCollection *collection)
Definition: parleyactions.cpp:188
ParleyActions::createRecentFilesAction
KRecentFilesAction * createRecentFilesAction(const QObject *recvr, const char *slot, QObject *parent)
Definition: parleyactions.cpp:183
Prefs::showSublessonentries
static bool showSublessonentries()
Get When enabled a unit also shows entries from its subunits.
Definition: prefs.h:849
ParleyActions::LanguagesProperties
Definition: parleyactions.h:32
ParleyActions::Preferences
Definition: parleyactions.h:31
ParleyActions::EnterEditMode
Definition: parleyactions.h:38
ParleyActions::FileSaveAs
Definition: parleyactions.h:27
QKeySequence
ParleyActions::FileQuit
Definition: parleyactions.h:30
Prefs::automaticTranslation
static bool automaticTranslation()
Get Enable automatic translation of the unit entries.
Definition: prefs.h:241
ParleyActions::FileOpenDownloaded
Definition: parleyactions.h:26
ParleyActions::createUploadAction
KAction * createUploadAction(const QObject *recvr, const char *slot, KActionCollection *collection)
Definition: parleyactions.cpp:196
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 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
  • 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