Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
4460 subik 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
#include "barcode.h"
9
#include "barcodegenerator.h"
19179 craig 10
#include "scribuscore.h"
11027 fschmid 11
#include "scribusstructs.h"
20185 craig 12
#include "iconmanager.h"
20308 craig 13
#include "scpaths.h"
4460 subik 14
 
15
Barcode::Barcode() : ScActionPlugin()
16
{
17
        languageChange();
18
}
19
 
20
Barcode::~Barcode() {};
21
 
22
void Barcode::languageChange()
23
{
18571 craig 24
        m_actionInfo.name = "BarcodeGenerator";
19118 craig 25
        m_actionInfo.text = tr("Barcode");
19445 jghali 26
        m_actionInfo.helpText = tr("Insert a barcode");
19179 craig 27
        if (ScCore->haveGS())
28
        {
29
                m_actionInfo.menu = "Insert";
30
                m_actionInfo.menuAfterName = "toolsInsertRenderFrame";
31
                m_actionInfo.toolbar = "Tools";
32
        }
20185 craig 33
        m_actionInfo.icon1 = IconManager::instance()->loadPixmap("16/insert-barcode.png");
34
        m_actionInfo.icon2 = IconManager::instance()->loadPixmap("22/insert-barcode.png");
12566 cbradney 35
        m_actionInfo.enabledOnStartup = false;
19066 craig 36
//      m_actionInfo.forAppMode.append(modeNormal);
10956 fschmid 37
        m_actionInfo.needsNumObjects = -1;
4460 subik 38
}
39
 
40
const QString Barcode::fullTrName() const
41
{
42
        return QObject::tr("Barcode Generator");
43
}
44
 
45
const ScActionPlugin::AboutData* Barcode::getAboutData() const
46
{
47
        AboutData* about = new AboutData;
48
        Q_CHECK_PTR(about);
20308 craig 49
 
4460 subik 50
        about->authors = QString::fromUtf8("Terry Burton - <tez@terryburton.co.uk>, Petr Van\xc4\x9bk <petr@scribus.info>");
20308 craig 51
        about->shortDescription = tr("Scribus frontend for Barcode Writer in Pure PostScript");
52
        about->description = "Barcode Writer in Pure Postscript generates all barcode formats entirely within PostScript hence this plugin requires Ghostscript to be installed on your system. http://bwipp.terryburton.co.uk";
53
 
54
        // Extract the version information from BWIPP
55
        QFile f( ScPaths::instance().shareDir() + QString("/plugins/barcode.ps") );
56
        f.open(QIODevice::ReadOnly);
57
        QTextStream ts(&f);
58
        QString bwipp = ts.read(150);
59
        f.close();
60
        QRegExp rx("\\n% Barcode Writer in Pure PostScript - Version ([\\d-]+)\\n");
61
        rx.indexIn(bwipp);
62
        about->version = "Backend: "+rx.cap(1);
63
 
4460 subik 64
        // about->releaseDate
20308 craig 65
        about->copyright = QString::fromUtf8("Backend: Copyright (c) 2004-2015 Terry Burton - tez@terryburton.co.uk\nFrontend: Copyright (c) 2005 Petr Van\xc4\x9bk - petr@scribus.info");
4460 subik 66
        about->license = "Backend: MIT/X-Consortium, Frontend: GPL";
67
        return about;
68
}
69
 
70
void Barcode::deleteAboutData(const AboutData* about) const
71
{
72
        Q_ASSERT(about);
73
        delete about;
74
}
75
 
12565 cbradney 76
bool Barcode::run(ScribusDoc* doc, QString /*target*/ )
4460 subik 77
{
19179 craig 78
        if (!doc || !ScCore->haveGS())
12565 cbradney 79
                return false;
4460 subik 80
        BarcodeGenerator *bg = new BarcodeGenerator();
81
        Q_CHECK_PTR(bg);
82
        bg->exec();
83
        delete bg;
84
        return true;
85
}
86
 
87
int barcodegenerator_getPluginAPIVersion()
88
{
89
        return PLUGIN_API_VERSION;
90
}
91
 
92
ScPlugin* barcodegenerator_getPlugin()
93
{
94
        Barcode* plug = new Barcode();
95
        Q_CHECK_PTR(plug);
96
        return plug;
97
}
98
 
99
void barcodegenerator_freePlugin(ScPlugin* plugin)
100
{
101
        Barcode* plug = dynamic_cast<Barcode*>(plugin);
102
        Q_ASSERT(plug);
103
        delete plug;
104
}