Subversion Repositories Scribus

Rev

Rev 959 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
464 subik 1
/*! This is the Scribus Short Words plugin interface implementation.
2
 
3
This code is based on the Scribus-Vlna plug in rewritten for
4
international use.
5
 
6
2004 Petr Vanek <petr@yarpen.cz>
7
 
8
This program is free software - see LICENSE file in the distribution
9
or documentation
10
*/
11
 
12
#include "shortwords.h"
13
#include "version.h"
14
#include "vlnadialog.h"
15
 
16
#include <scribus.h>
17
#include <qmessagebox.h>
18
#include <qtextcodec.h>
19
#include <qcursor.h>
20
#include <qprogressdialog.h>
21
#include <qfile.h>
22
#include <qdir.h>
23
 
24
ShortWords* shortWords;
25
extern ScribusApp *ScApp;
26
 
27
QString Name()
28
{
29
        return shortWords->tr("Short &Words...");
30
}
31
 
32
 
33
int Type()
34
{
35
        return 1;
36
}
37
 
904 subik 38
int ID()
39
{
40
        return 11;
41
}
42
 
464 subik 43
void Run(QWidget *d, ScribusApp *plug)
44
{
936 subik 45
        // translator
464 subik 46
        QTranslator *trans = new QTranslator(0);
936 subik 47
        trans->load(QString("libscribusshortwords.") + plug->GuiLanguage + QString(".qm"),
48
                                QDir::convertSeparators(PLUGINDIR));
464 subik 49
        qApp->installTranslator(trans);
50
        // run plug
51
        ShortWords *sw = new ShortWords();
959 subik 52
        /*delete sw;
53
        delete trans;*/
464 subik 54
}
55
 
56
ShortWords::ShortWords()
57
{
58
        shortWords = this;
59
        originalPage = ScApp->doc->ActPage->PageNr;
60
        cfg = new Config();
61
        VlnaDialog *dlg = new VlnaDialog(ScApp, "dlg", TRUE, 0);
62
 
63
        cfg->userConfig ? dlg->userCheckBox->setChecked(TRUE) : dlg->userCheckBox->setChecked(FALSE);
64
        dlg->selectAction(cfg->action);
65
        if (dlg->exec() == QDialog::Accepted) {
936 subik 66
                parse = new Parse();
464 subik 67
                QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
68
                ScApp->FMess->setText(shortWords->tr("Short Words processing. Wait please..."));
69
                dlg->userCheckBox->isChecked() ? cfg->userConfig = 1 : cfg->userConfig = 0;
70
                cfg->action = dlg->actionSelected;
71
                switch (dlg->actionSelected) {
72
                        case 0:
73
                                parse->parseSelection();
74
                                break;
75
                        case 1:
76
                                parse->parsePage(ScApp->doc->ActPage);
77
                                break;
78
                        case 2:
79
                                parse->parseAll();
80
                                break;
81
                } // switch
82
                // enable "Save" icon
83
                if (parse->modify > 0)
84
                        ScApp->slotDocCh(TRUE);
85
                // redraw document
86
                ScApp->view->DrawNew();
87
                QApplication::restoreOverrideCursor();
88
                ScApp->FMess->setText(shortWords->tr("Short Words processing. Done."));
89
                ScApp->FProg->reset();
90
                // set page where user calls vlna
91
                ScApp->view->GotoPage(originalPage);
92
        } // action
93
        delete dlg;
1181 subik 94
        cfg->saveConfig();
464 subik 95
} // constructor
96
 
97
ShortWords::~ShortWords()
98
{
99
        delete cfg;
100
        delete parse;
101
}