Subversion Repositories Scribus

Rev

Rev 22635 | Rev 23054 | 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
 
22639 craig 15
Barcode::Barcode()
4460 subik 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");
22439 craig 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. https://bwipp.terryburton.co.uk";
20308 craig 53
 
54
        // Extract the version information from BWIPP
21990 craig 55
        QFile f( ScPaths::instance().shareDir() + QString("/plugins/barcode.ps") );
56
        if(f.open(QIODevice::ReadOnly))
57
        {
58
                QTextStream ts(&f);
59
                QString bwipp = ts.read(150);
60
                f.close();
61
                QRegExp rx("\\n% Barcode Writer in Pure PostScript - Version ([\\d-]+)\\n");
62
                rx.indexIn(bwipp);
63
                about->version = "Backend: "+rx.cap(1);
64
        }
65
        else
66
                about->version = "Unable to open backend file";
4460 subik 67
        // about->releaseDate
22439 craig 68
        about->copyright = QString::fromUtf8("Backend: Copyright (c) 2004-2018 Terry Burton - tez@terryburton.co.uk\nFrontend: Copyright (c) 2005 Petr Van\xc4\x9bk - petr@scribus.info");
4460 subik 69
        about->license = "Backend: MIT/X-Consortium, Frontend: GPL";
70
        return about;
71
}
72
 
73
void Barcode::deleteAboutData(const AboutData* about) const
74
{
75
        Q_ASSERT(about);
76
        delete about;
77
}
78
 
22635 craig 79
bool Barcode::run(ScribusDoc* doc, const QString& /*target*/ )
4460 subik 80
{
19179 craig 81
        if (!doc || !ScCore->haveGS())
12565 cbradney 82
                return false;
4460 subik 83
        BarcodeGenerator *bg = new BarcodeGenerator();
84
        Q_CHECK_PTR(bg);
85
        bg->exec();
86
        delete bg;
87
        return true;
88
}
89
 
90
int barcodegenerator_getPluginAPIVersion()
91
{
92
        return PLUGIN_API_VERSION;
93
}
94
 
95
ScPlugin* barcodegenerator_getPlugin()
96
{
97
        Barcode* plug = new Barcode();
98
        Q_CHECK_PTR(plug);
99
        return plug;
100
}
101
 
102
void barcodegenerator_freePlugin(ScPlugin* plugin)
103
{
104
        Barcode* plug = dynamic_cast<Barcode*>(plugin);
105
        Q_ASSERT(plug);
106
        delete plug;
107
}