Rev 17550 | Rev 18586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
17502 | craig | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | #include "hunspellplugin.h" |
||
8 | #include "hunspellpluginimpl.h" |
||
9 | #include "scribuscore.h" |
||
10 | #include "ui/storyeditor.h" |
||
11 | |||
12 | // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods |
||
13 | // do. That documentatation is not duplicated here. |
||
14 | // Please don't implement the functionality of your plugin here; do that |
||
15 | // in mypluginimpl.h and mypluginimpl.cpp . |
||
16 | |||
17 | HunspellPlugin::HunspellPlugin() : ScActionPlugin() |
||
18 | { |
||
19 | // Set action info in languageChange, so we only have to do |
||
20 | // it in one place. |
||
21 | languageChange(); |
||
22 | } |
||
23 | |||
24 | HunspellPlugin::~HunspellPlugin() {}; |
||
25 | |||
26 | void HunspellPlugin::languageChange() |
||
27 | { |
||
28 | // Note that we leave the unused members unset. They'll be initialised |
||
29 | // with their default ctors during construction. |
||
30 | // Action name |
||
31 | m_actionInfo.name = "HunspellPlugin"; |
||
32 | // Action text for menu, including &accel |
||
33 | m_actionInfo.text = tr("Check Spelling..."); |
||
34 | // Menu |
||
18070 | fschmid | 35 | m_actionInfo.menu = "Extras"; |
17502 | craig | 36 | // Story Editor Menu |
37 | m_actionInfo.seMenu = "Edit"; |
||
38 | // If needed, what item to add the menu item after |
||
39 | //m_actionInfo.menuAfterName = "ColorWheel" |
||
40 | // If needed, the keyboard shortcut for the plugin |
||
41 | m_actionInfo.keySequence = "SHIFT+F7"; |
||
42 | // Should the menu item be enabled when the app starts |
||
43 | // (even without a document open) ? |
||
44 | m_actionInfo.enabledOnStartup = false; |
||
45 | m_actionInfo.enabledForStoryEditor = true; |
||
46 | m_actionInfo.notSuitableFor.append(PageItem::Line); |
||
47 | m_actionInfo.notSuitableFor.append(PageItem::Polygon); |
||
48 | m_actionInfo.notSuitableFor.append(PageItem::ImageFrame); |
||
49 | m_actionInfo.notSuitableFor.append(PageItem::PathText); |
||
50 | m_actionInfo.notSuitableFor.append(PageItem::LatexFrame); |
||
18070 | fschmid | 51 | m_actionInfo.notSuitableFor.append(PageItem::Symbol); |
52 | m_actionInfo.notSuitableFor.append(PageItem::RegularPolygon); |
||
53 | m_actionInfo.notSuitableFor.append(PageItem::Arc); |
||
54 | m_actionInfo.notSuitableFor.append(PageItem::Spiral); |
||
17502 | craig | 55 | m_actionInfo.needsNumObjects = 1; |
56 | } |
||
57 | |||
58 | const QString HunspellPlugin::fullTrName() const |
||
59 | { |
||
60 | return QObject::tr("Hunspell Plugin"); |
||
61 | } |
||
62 | |||
63 | const ScActionPlugin::AboutData* HunspellPlugin::getAboutData() const |
||
64 | { |
||
65 | AboutData* about = new AboutData; |
||
66 | Q_CHECK_PTR(about); |
||
67 | return about; |
||
68 | } |
||
69 | |||
70 | void HunspellPlugin::deleteAboutData(const AboutData* about) const |
||
71 | { |
||
72 | Q_ASSERT(about); |
||
73 | delete about; |
||
74 | } |
||
75 | |||
76 | bool HunspellPlugin::run(ScribusDoc* doc, QString target) |
||
77 | { |
||
78 | HunspellPluginImpl *hunspellPluginImpl = new HunspellPluginImpl(); |
||
79 | Q_CHECK_PTR(hunspellPluginImpl); |
||
80 | bool result = hunspellPluginImpl->run(target, doc); |
||
81 | delete hunspellPluginImpl; |
||
82 | return result; |
||
83 | } |
||
84 | |||
85 | bool HunspellPlugin::run(QWidget *parent, ScribusDoc *doc, QString target) |
||
86 | { |
||
87 | HunspellPluginImpl *hunspellPluginImpl = new HunspellPluginImpl(); |
||
88 | Q_CHECK_PTR(hunspellPluginImpl); |
||
89 | if (parent) |
||
90 | hunspellPluginImpl->setRunningForSE(true, dynamic_cast<StoryEditor*>(parent)); |
||
91 | bool result = hunspellPluginImpl->run(target, doc); |
||
92 | delete hunspellPluginImpl; |
||
93 | return result; |
||
94 | } |
||
95 | |||
96 | // Low level plugin API |
||
97 | int hunspellplugin_getPluginAPIVersion() |
||
98 | { |
||
99 | return PLUGIN_API_VERSION; |
||
100 | } |
||
101 | |||
102 | ScPlugin* hunspellplugin_getPlugin() |
||
103 | { |
||
104 | HunspellPlugin* plug = new HunspellPlugin(); |
||
105 | Q_CHECK_PTR(plug); |
||
106 | return plug; |
||
107 | } |
||
108 | |||
109 | void hunspellplugin_freePlugin(ScPlugin* plugin) |
||
110 | { |
||
111 | HunspellPlugin* plug = dynamic_cast<HunspellPlugin*>(plugin); |
||
112 | Q_ASSERT(plug); |
||
113 | delete plug; |
||
114 | } |