Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
14798 cbradney 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 "collectforoutput_ui.h"
9
 
10
#include "commonstrings.h"
11
#include "undomanager.h"
12
#include "filewatcher.h"
13
#include "prefscontext.h"
14
#include "scribuscore.h"
15
#include "scraction.h"
16
#include "scribusapp.h"
17
 
18
CollectForOutput_UI::CollectForOutput_UI(QWidget* parent, ScribusDoc* doc, QString outputDirectory, bool withFonts, bool withProfiles, bool compressDoc) :
19
        CollectForOutput(doc, outputDirectory, withFonts, withProfiles, compressDoc)
20
{
21
        uiCollect=true;
22
        connect(this, SIGNAL(fontsCollected(int)), this, SLOT(collectedFonts(int)));
23
        connect(this, SIGNAL(itemsCollected(int)), this, SLOT(collectedItems(int)));
24
        connect(this, SIGNAL(patternsCollected(int)), this, SLOT(collectedPatterns(int)));
25
        connect(this, SIGNAL(profilesCollected(int)), this, SLOT(collectedProfiles(int)));
26
}
27
 
28
QString CollectForOutput_UI::collect(QString &newFileName)
29
{
30
        if (!newDirDialog())
31
                return "Collect cancelled or unable to create collect destination directory";
32
 
33
        progressDialog=new MultiProgressDialog("Collect for Output", "Cancel");
34
        QStringList barNames, barTexts;
35
        QList<bool> barsNumeric;
36
        barNames << "items";
37
        barTexts << tr("Collecting Items:");
38
        barsNumeric << true;
39
        barNames << "patterns";
40
        barTexts << tr("Collecting Patterns:");
41
        barsNumeric << true;
42
 
43
        if (m_withFonts)
44
        {
45
                barNames << "fonts";
46
                barTexts << tr("Collecting Fonts:");
47
                barsNumeric << true;
48
        }
49
        if (m_withProfiles)
50
        {
51
                barNames << "profiles";
52
                barTexts << tr("Collecting Profiles:");
53
                barsNumeric << true;
54
        }
55
 
56
        progressDialog->addExtraProgressBars(barNames, barTexts, barsNumeric);
57
        progressDialog->setOverallTotalSteps(profileCount+itemCount+fontCount+patternCount);
58
        progressDialog->setTotalSteps("items", itemCount);
59
        progressDialog->setTotalSteps("patterns", patternCount);
60
        progressDialog->setProgress("items", 0);
61
        progressDialog->setProgress("patterns", 0);
62
        if (m_withFonts)
63
        {
64
                progressDialog->setTotalSteps("fonts", fontCount);
65
                progressDialog->setProgress("fonts", 0);
66
        }
67
        if (m_withProfiles)
68
        {
69
                progressDialog->setTotalSteps("profiles", profileCount);
70
                progressDialog->setProgress("profiles", 0);
71
        }
72
        progressDialog->setOverallProgress(0);
73
 
74
 
75
 
76
        ScCore->fileWatcher->forceScan();
77
        ScCore->fileWatcher->stop();
78
 
79
 
80
        progressDialog->show();
81
//      connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelRequested()));
82
        ScQApp->processEvents();
83
 
84
        dirs->set("collect", m_outputDirectory.left(m_outputDirectory.lastIndexOf("/",-2)));
85
        ScCore->primaryMainWindow()->setStatusBarInfoText( tr("Collecting..."));
86
 
87
        if (!collectItems())
88
        {
89
                QString errorMsg( tr("Cannot collect all files for output for file:\n%1").arg(newName) );
90
                QMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning,
91
                                                         "<qt>" + errorMsg + "</qt>",
92
                                                         CommonStrings::tr_OK);
93
                return errorMsg;
94
        }
95
        progressDialog->setOverallProgress(itemCount+patternCount);
96
 
97
        if (m_withFonts)
98
        {
99
                collectFonts();
100
                progressDialog->setProgress("fonts", fontCount);
101
                progressDialog->setOverallProgress(itemCount+patternCount+fontCount);
102
        }
103
        if (m_withProfiles)
104
        {
105
                collectProfiles();
106
                progressDialog->setProgress("profiles", profileCount);
107
                progressDialog->setOverallProgress(itemCount+patternCount+fontCount+profileCount);
108
        }
109
        /* collect document must go last because of image paths changes in collectItems() */
110
        if (!collectDocument())
111
        {
112
                QString errorMsg( tr("Cannot collect the file: \n%1").arg(newName) );
113
                QMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, "<qt>" + errorMsg + "</qt>", CommonStrings::tr_OK);
114
                return errorMsg;
115
        }
116
 
117
        QDir::setCurrent(m_outputDirectory);
118
        ScCore->primaryMainWindow()->updateActiveWindowCaption(newName);
119
        UndoManager::instance()->renameStack(newName);
120
        ScCore->primaryMainWindow()->scrActions["fileRevert"]->setEnabled(false);
121
        ScCore->primaryMainWindow()->updateRecent(newName);
122
        ScCore->primaryMainWindow()->setStatusBarInfoText("");
123
        ScCore->primaryMainWindow()->mainWindowProgressBar->reset();
124
        ScCore->fileWatcher->start();
125
        collectedFiles.clear();
126
        newFileName=newName;
127
        progressDialog->close();
128
        delete progressDialog;
129
        return QString::null;
130
}
131
 
132
void CollectForOutput_UI::collectedFonts(int c)
133
{
134
        progressDialog->setProgress("fonts", c);
135
        ScQApp->processEvents();
136
}
137
 
138
void CollectForOutput_UI::collectedItems(int c)
139
{
140
        progressDialog->setProgress("items", c);
141
        ScQApp->processEvents();
142
}
143
 
144
void CollectForOutput_UI::collectedPatterns(int c)
145
{
146
        progressDialog->setProgress("patterns", c);
147
        ScQApp->processEvents();
148
}
149
 
150
void CollectForOutput_UI::collectedProfiles(int c)
151
{
152
        progressDialog->setProgress("profiles", c);
153
        ScQApp->processEvents();
154
}