Subversion Repositories Scribus

Rev

Rev 23705 | 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
 
23054 craig 20
Barcode::~Barcode() = default;
4460 subik 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
        }
23474 jghali 33
        m_actionInfo.iconPath1 = "16/insert-barcode.png";
34
        m_actionInfo.iconPath2 = "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
 
23705 craig 40
QString Barcode::fullTrName() const
4460 subik 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") );
23755 jghali 56
        if (f.open(QIODevice::ReadOnly))
21990 craig 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");
23755 jghali 62
                if (rx.indexIn(bwipp) >= 0)
63
                        about->version = "Backend: " + rx.cap(1);
64
                else
65
                        about->version = "Backend: Unknown";
21990 craig 66
        }
67
        else
68
                about->version = "Unable to open backend file";
4460 subik 69
        // about->releaseDate
22439 craig 70
        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 71
        about->license = "Backend: MIT/X-Consortium, Frontend: GPL";
72
        return about;
73
}
74
 
75
void Barcode::deleteAboutData(const AboutData* about) const
76
{
77
        Q_ASSERT(about);
78
        delete about;
79
}
80
 
22635 craig 81
bool Barcode::run(ScribusDoc* doc, const QString& /*target*/ )
4460 subik 82
{
19179 craig 83
        if (!doc || !ScCore->haveGS())
12565 cbradney 84
                return false;
4460 subik 85
        BarcodeGenerator *bg = new BarcodeGenerator();
86
        Q_CHECK_PTR(bg);
87
        bg->exec();
88
        delete bg;
89
        return true;
90
}
91
 
92
int barcodegenerator_getPluginAPIVersion()
93
{
94
        return PLUGIN_API_VERSION;
95
}
96
 
97
ScPlugin* barcodegenerator_getPlugin()
98
{
99
        Barcode* plug = new Barcode();
100
        Q_CHECK_PTR(plug);
101
        return plug;
102
}
103
 
104
void barcodegenerator_freePlugin(ScPlugin* plugin)
105
{
106
        Barcode* plug = dynamic_cast<Barcode*>(plugin);
107
        Q_ASSERT(plug);
108
        delete plug;
109
}