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 /***************************************************************************
8 shapeplugin.cpp - description
9 -------------------
10 begin : Fri Apr 3 08:00:00 CEST 2015
11 copyright : (C) 2015 by Franz Schmid
12 email : Franz.Schmid@altmuehlnet.de
13 ***************************************************************************/
14
15 /***************************************************************************
16 * *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
21 * *
22 ***************************************************************************/
23
24 #include <QApplication>
25 #include <QWidget>
26 #include <QString>
27
28 #include "scribuscore.h"
29 #include "scribusapp.h"
30 #include "shapeplugin.h"
31 #include "scraction.h"
32 #include "ui/scmwmenumanager.h"
33
34
shapeplugin_getPluginAPIVersion()35 int shapeplugin_getPluginAPIVersion()
36 {
37 return PLUGIN_API_VERSION;
38 }
39
shapeplugin_getPlugin()40 ScPlugin* shapeplugin_getPlugin()
41 {
42 ShapePlugin* plug = new ShapePlugin();
43 Q_CHECK_PTR(plug);
44 return plug;
45 }
46
shapeplugin_freePlugin(ScPlugin * plugin)47 void shapeplugin_freePlugin(ScPlugin* plugin)
48 {
49 ShapePlugin* plug = qobject_cast<ShapePlugin*>(plugin);
50 Q_ASSERT(plug);
51 delete plug;
52 }
53
ShapePlugin()54 ShapePlugin::ShapePlugin()
55 {
56 sc_palette = nullptr;
57 }
58
~ShapePlugin()59 ShapePlugin::~ShapePlugin() {};
60
languageChange()61 void ShapePlugin::languageChange()
62 {
63 if (sc_palette)
64 sc_palette->languageChange();
65 }
66
addToMainWindowMenu(ScribusMainWindow * mw)67 void ShapePlugin::addToMainWindowMenu(ScribusMainWindow* mw)
68 {
69 if (!sc_palette)
70 return;
71
72 sc_palette->setMainWindow(mw);
73 languageChange();
74 m_actions.insert("shapeShowPalette", new ScrAction(QObject::tr("Custom Shapes"), QKeySequence(), this));
75 m_actions["shapeShowPalette"]->setToggleAction(true);
76 m_actions["shapeShowPalette"]->setChecked(false);
77 connect(m_actions["shapeShowPalette"], SIGNAL(toggled(bool)), sc_palette, SLOT(setPaletteShown(bool)));
78 connect(sc_palette, SIGNAL(paletteShown(bool)), m_actions["shapeShowPalette"], SLOT(setChecked(bool)));
79 mw->scrMenuMgr->addMenuItemStringAfter("shapeShowPalette", "toolsInline", "Windows");
80 mw->scrMenuMgr->addMenuItemStringsToMenuBar("Windows", m_actions);
81 }
82
fullTrName() const83 QString ShapePlugin::fullTrName() const
84 {
85 return QObject::tr("Custom Shapes");
86 }
87
getAboutData() const88 const ScActionPlugin::AboutData* ShapePlugin::getAboutData() const
89 {
90 AboutData* about = new AboutData;
91 Q_CHECK_PTR(about);
92 about->authors = QString::fromUtf8("Franz Schmid <franz@scribus.info>, ");
93 about->shortDescription = tr("Palette for Photoshop Custom Shapes.");
94 return about;
95 }
96
deleteAboutData(const AboutData * about) const97 void ShapePlugin::deleteAboutData(const AboutData* about) const
98 {
99 Q_ASSERT(about);
100 delete about;
101 }
102
initPlugin()103 bool ShapePlugin::initPlugin()
104 {
105 sc_palette = new ShapePalette(ScCore->primaryMainWindow());
106 sc_palette->startup();
107 sc_palette->readFromPrefs();
108 return true;
109 }
110
cleanupPlugin()111 bool ShapePlugin::cleanupPlugin()
112 {
113 if (sc_palette)
114 {
115 sc_palette->writeToPrefs();
116 delete sc_palette;
117 sc_palette = nullptr;
118 }
119 return true;
120 }
121