Subversion Repositories Scribus

Rev

Rev 10928 | Rev 10956 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10928 fschmid 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
*   Copyright (C) 2007 by Franz Schmid                                     *
9
*   franz.schmid@altmuehlnet.de                                            *
10
*                                                                          *
11
*   This program is free software; you can redistribute it and/or modify   *
12
*   it under the terms of the GNU General Public License as published by   *
13
*   the Free Software Foundation; either version 2 of the License, or      *
14
*   (at your option) any later version.                                    *
15
*                                                                          *
16
*   This program is distributed in the hope that it will be useful,        *
17
*   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
18
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
19
*   GNU General Public License for more details.                           *
20
*                                                                          *
21
*   You should have received a copy of the GNU General Public License      *
22
*   along with this program; if not, write to the                          *
23
*   Free Software Foundation, Inc.,                                        *
24
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
25
****************************************************************************/
26
 
27
#include "lenseffects.h"
28
#include "lensdialog.h"
29
#include "scribuscore.h"
30
 
31
int lenseffects_getPluginAPIVersion()
32
{
33
        return PLUGIN_API_VERSION;
34
}
35
 
36
ScPlugin* lenseffects_getPlugin()
37
{
38
        LensEffectsPlugin* plug = new LensEffectsPlugin();
39
        Q_CHECK_PTR(plug);
40
        return plug;
41
}
42
 
43
void lenseffects_freePlugin(ScPlugin* plugin)
44
{
45
        LensEffectsPlugin* plug = dynamic_cast<LensEffectsPlugin*>(plugin);
46
        Q_ASSERT(plug);
47
        delete plug;
48
}
49
 
50
LensEffectsPlugin::LensEffectsPlugin() : ScActionPlugin()
51
{
52
        // Set action info in languageChange, so we only have to do
53
        // it in one place.
54
        languageChange();
55
}
56
 
57
LensEffectsPlugin::~LensEffectsPlugin() {};
58
 
59
void LensEffectsPlugin::languageChange()
60
{
61
        // Note that we leave the unused members unset. They'll be initialised
62
        // with their default ctors during construction.
63
        // Action name
64
        m_actionInfo.name = "LensEffects";
65
        // Action text for menu, including accel
66
        m_actionInfo.text = tr("Lens Effects...");
67
        // Menu
68
        m_actionInfo.menu = "Item";
69
        m_actionInfo.enabledOnStartup = true;
70
}
71
 
72
const QString LensEffectsPlugin::fullTrName() const
73
{
74
        return QObject::tr("Lens Effects");
75
}
76
 
77
const ScActionPlugin::AboutData* LensEffectsPlugin::getAboutData() const
78
{
79
        AboutData* about = new AboutData;
80
        Q_CHECK_PTR(about);
81
        about->authors = QString::fromUtf8("Franz Schmid <Franz.Schmid@altmuehlnet.de>");
82
        about->shortDescription = tr("Lens Effects");
83
        about->description = tr("Apply fancy lens effects");
84
        // about->version
85
        // about->releaseDate
86
        // about->copyright
87
        about->license = "GPL";
88
        return about;
89
}
90
 
91
void LensEffectsPlugin::deleteAboutData(const AboutData* about) const
92
{
93
        Q_ASSERT(about);
94
        delete about;
95
}
96
 
97
bool LensEffectsPlugin::run(ScribusDoc* doc, QString)
98
{
99
        ScribusDoc* currDoc = doc;
100
        if (currDoc == 0)
101
                currDoc = ScCore->primaryMainWindow()->doc;
102
        if (currDoc->m_Selection->count() > 0)
103
        {
104
                LensDialog *dia = new LensDialog(currDoc->scMW(), currDoc);
105
                if (dia->exec())
106
                {
107
                        for (int a = 0; a < dia->origPathItem.count(); a++)
108
                        {
109
                                QPainterPath path = dia->origPathItem[a]->path();
110
                                FPointArray points;
111
                                points.fromQPainterPath(path);
112
                                PageItem *currItem = currDoc->m_Selection->itemAt(a);
113
                                currItem->PoLine = points;
114
                                currDoc->AdjustItemSize(currItem);
115
                        }
10936 fschmid 116
                        currDoc->changed();
10928 fschmid 117
                }
118
                delete dia;
119
        }
120
        return true;
121
}