Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
4430 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
*/
1235 fschmid 7
#include "tabcheckdoc.h"
8
 
9838 fschmid 9
#include <QGridLayout>
10
#include <QVBoxLayout>
11
#include <QHBoxLayout>
12
#include <QSpacerItem>
13
#include <QCheckBox>
14
#include <QGroupBox>
15
#include <QLabel>
16
#include <QComboBox>
17
#include <QPushButton>
18
#include <QSpinBox>
19
 
2834 cbradney 20
#include "prefsstructs.h"
10648 fschmid 21
#include "util.h"
2834 cbradney 22
 
10585 fschmid 23
TabCheckDoc::TabCheckDoc( QWidget* parent, CheckerPrefsList prefsData, QString prefProfile ) : QWidget( parent )
1235 fschmid 24
{
9838 fschmid 25
        TabCheckDocLayout = new QVBoxLayout(this);
26
        TabCheckDocLayout->setMargin(0);
27
        TabCheckDocLayout->setSpacing(5);
1235 fschmid 28
        TabCheckDocLayout->setAlignment( Qt::AlignTop );
9838 fschmid 29
        curCheckProfile = new QComboBox(this);
1284 fschmid 30
        curCheckProfile->setEditable(true);
31
        curCheckProfile->setDuplicatesEnabled(false);
5711 subik 32
 
1261 fschmid 33
        TabCheckDocLayout->addWidget( curCheckProfile );
10585 fschmid 34
        ignoreErrors = new QCheckBox( this );
1266 cbradney 35
        ignoreErrors->setText( tr( "Ignore all errors" ) );
1235 fschmid 36
        TabCheckDocLayout->addWidget( ignoreErrors );
10585 fschmid 37
        automaticCheck = new QCheckBox( this );
1266 cbradney 38
        automaticCheck->setText( tr( "Automatic check before printing or exporting" ) );
1235 fschmid 39
        TabCheckDocLayout->addWidget( automaticCheck );
10585 fschmid 40
        missingGlyphs = new QCheckBox( this );
1266 cbradney 41
        missingGlyphs->setText( tr( "Check for missing glyphs" ) );
1235 fschmid 42
        TabCheckDocLayout->addWidget( missingGlyphs );
10585 fschmid 43
        checkOrphans = new QCheckBox( this );
7400 cbradney 44
        checkOrphans->setText( tr( "Check for items not on a page" ) );
1235 fschmid 45
        TabCheckDocLayout->addWidget( checkOrphans );
10585 fschmid 46
        textOverflow = new QCheckBox( this );
1266 cbradney 47
        textOverflow->setText( tr( "Check for overflow in text frames" ) );
1235 fschmid 48
        TabCheckDocLayout->addWidget( textOverflow );
10585 fschmid 49
        tranparentObjects = new QCheckBox( this );
7400 cbradney 50
        tranparentObjects->setText( tr( "Check for used transparencies" ) );
1235 fschmid 51
        TabCheckDocLayout->addWidget( tranparentObjects );
10585 fschmid 52
        missingPictures = new QCheckBox( this );
1266 cbradney 53
        missingPictures->setText( tr( "Check for missing images" ) );
1235 fschmid 54
        TabCheckDocLayout->addWidget( missingPictures );
10585 fschmid 55
        pictResolution = new QGroupBox( this );
1266 cbradney 56
        pictResolution->setTitle( tr( "Check image resolution" ) );
1235 fschmid 57
        pictResolution->setCheckable( true );
9838 fschmid 58
        pictResolutionLayout = new QGridLayout(pictResolution);
59
        pictResolutionLayout->setMargin(10);
60
        pictResolutionLayout->setSpacing(5);
1235 fschmid 61
        pictResolutionLayout->setAlignment( Qt::AlignTop );
10585 fschmid 62
        textLabel1 = new QLabel( pictResolution );
1266 cbradney 63
        textLabel1->setText( tr( "Lowest allowed resolution" ) );
5239 fschmid 64
        pictResolutionLayout->addWidget( textLabel1, 0, 0 );
10585 fschmid 65
        resolutionValue = new QSpinBox( pictResolution );
10493 fschmid 66
        resolutionValue->setMaximum( 4800 );
67
        resolutionValue->setMinimum( 10 );
1235 fschmid 68
        resolutionValue->setSuffix( tr( " dpi" ) );
7400 cbradney 69
        pictResolutionLayout->addWidget( resolutionValue, 0, 1 );
10585 fschmid 70
        textLabel1m = new QLabel( pictResolution );
5239 fschmid 71
        textLabel1m->setText( tr( "Highest allowed resolution" ) );
7400 cbradney 72
        pictResolutionLayout->addWidget( textLabel1m, 0, 2 );
10585 fschmid 73
        resolutionValueM = new QSpinBox( pictResolution );
10493 fschmid 74
        resolutionValueM->setMaximum( 4800 );
75
        resolutionValueM->setMinimum( 10 );
5239 fschmid 76
        resolutionValueM->setSuffix( tr( " dpi" ) );
7400 cbradney 77
        pictResolutionLayout->addWidget( resolutionValueM, 0, 3 );
1235 fschmid 78
        TabCheckDocLayout->addWidget( pictResolution );
10585 fschmid 79
        rasterPDF = new QCheckBox( this );
1926 cbradney 80
        rasterPDF->setText( tr( "Check for placed PDF Files" ) );
1284 fschmid 81
        TabCheckDocLayout->addWidget( rasterPDF );
10585 fschmid 82
        checkForGIF = new QCheckBox(this);
6260 fschmid 83
        checkForGIF->setText( tr("Check for GIF images"));
5270 subik 84
        TabCheckDocLayout->addWidget(checkForGIF);
10585 fschmid 85
        useAnnotations = new QCheckBox( this );
1284 fschmid 86
        useAnnotations->setText( tr( "Check for PDF Annotations and Fields" ) );
87
        TabCheckDocLayout->addWidget( useAnnotations );
10585 fschmid 88
        ignoreOffLayers = new QCheckBox( this );
6619 fschmid 89
        ignoreOffLayers->setText( tr( "Ignore non-printable Layers" ) );
90
        TabCheckDocLayout->addWidget( ignoreOffLayers );
14543 cbradney 91
        checkOffConflictLayers = new QCheckBox( this );
92
        checkOffConflictLayers->setText( tr( "Check for Visible/Printable Mismatch in Layers" ) );
93
        TabCheckDocLayout->addWidget( checkOffConflictLayers );
9838 fschmid 94
        layout1 = new QHBoxLayout;
95
        layout1->setMargin(0);
96
        layout1->setSpacing(5);
97
        QSpacerItem* spacer = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
1284 fschmid 98
        layout1->addItem( spacer );
10585 fschmid 99
        addProfile = new QPushButton( tr( "Add Profile" ), this );
1284 fschmid 100
        layout1->addWidget( addProfile );
10585 fschmid 101
        removeProfile = new QPushButton( tr( "Remove Profile" ), this );
1284 fschmid 102
        layout1->addWidget( removeProfile );
9838 fschmid 103
        QSpacerItem* spacer2 = new QSpacerItem( 2, 2, QSizePolicy::Expanding, QSizePolicy::Minimum );
1284 fschmid 104
        layout1->addItem( spacer2 );
105
        TabCheckDocLayout->addLayout( layout1 );
5711 subik 106
 
5763 subik 107
        // switched off as it's called in main prefs classes - PV
108
        //restoreDefaults(&prefsData, prefProfile);
5711 subik 109
 
1261 fschmid 110
        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
10904 jghali 111
        connect(curCheckProfile, SIGNAL(editTextChanged(const QString&)), this, SLOT(setProfile(const QString&)));
2526 cbradney 112
 
1261 fschmid 113
        connect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
114
        connect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
115
        connect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
116
        connect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
2526 cbradney 117
        connect(textOverflow, SIGNAL(clicked()), this, SLOT(putProfile()));
118
        connect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
1261 fschmid 119
        connect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
120
        connect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
2526 cbradney 121
        connect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
1284 fschmid 122
        connect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
5270 subik 123
        connect(checkForGIF, SIGNAL(clicked()), this, SLOT(putProfile()));
1261 fschmid 124
        connect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
5239 fschmid 125
        connect(resolutionValueM, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
6619 fschmid 126
        connect(ignoreOffLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
14543 cbradney 127
        connect(checkOffConflictLayers, SIGNAL(clicked()), this, SLOT(putProfile()));  
1284 fschmid 128
        connect(removeProfile, SIGNAL(clicked()), this, SLOT(delProf()));
129
        connect(addProfile, SIGNAL(clicked()), this, SLOT(addProf()));
1235 fschmid 130
}
1261 fschmid 131
 
5553 subik 132
void TabCheckDoc::restoreDefaults(CheckerPrefsList *prefsData, QString prefProfile)
1828 fschmid 133
{
5553 subik 134
        checkerProfile = *prefsData;
135
        curCheckProfile->clear();
136
        CheckerPrefsList::Iterator it;
5711 subik 137
        curCheckProfile->clear();
5553 subik 138
        for (it = checkerProfile.begin(); it != checkerProfile.end(); ++it)
9838 fschmid 139
                curCheckProfile->addItem(it.key());
10648 fschmid 140
        setCurrentComboItem(curCheckProfile, prefProfile);
5553 subik 141
        ignoreErrors->setChecked(checkerProfile[prefProfile].ignoreErrors);
142
        automaticCheck->setChecked(checkerProfile[prefProfile].autoCheck);
143
        missingGlyphs->setChecked(checkerProfile[prefProfile].checkGlyphs);
144
        checkOrphans->setChecked(checkerProfile[prefProfile].checkOrphans);
145
        textOverflow->setChecked(checkerProfile[prefProfile].checkOverflow);
146
        tranparentObjects->setChecked(checkerProfile[prefProfile].checkTransparency);
147
        missingPictures->setChecked(checkerProfile[prefProfile].checkPictures);
148
        pictResolution->setChecked(checkerProfile[prefProfile].checkResolution);
149
        useAnnotations->setChecked(checkerProfile[prefProfile].checkAnnotations);
150
        rasterPDF->setChecked(checkerProfile[prefProfile].checkRasterPDF);
151
        checkForGIF->setChecked(checkerProfile[prefProfile].checkForGIF);
6619 fschmid 152
        ignoreOffLayers->setChecked(checkerProfile[prefProfile].ignoreOffLayers);
14543 cbradney 153
        checkOffConflictLayers->setChecked(checkerProfile[prefProfile].checkOffConflictLayers);
5553 subik 154
        resolutionValue->setValue( qRound(checkerProfile[prefProfile].minResolution) );
155
        resolutionValueM->setValue( qRound(checkerProfile[prefProfile].maxResolution) );
156
        currentProfile = prefProfile;
157
        if (checkerProfile.count() == 1)
158
                removeProfile->setEnabled(false);
159
        addProfile->setEnabled(false);
160
        tempNewProfileName="";
1828 fschmid 161
}
162
 
1261 fschmid 163
void TabCheckDoc::putProfile()
164
{
1284 fschmid 165
        if (checkerProfile.contains(currentProfile))
166
        {
167
                checkerProfile[currentProfile].ignoreErrors = ignoreErrors->isChecked();
168
                checkerProfile[currentProfile].autoCheck = automaticCheck->isChecked();
169
                checkerProfile[currentProfile].checkGlyphs = missingGlyphs->isChecked();
170
                checkerProfile[currentProfile].checkOrphans = checkOrphans->isChecked();
171
                checkerProfile[currentProfile].checkOverflow = textOverflow->isChecked();
172
                checkerProfile[currentProfile].checkPictures = missingPictures->isChecked();
173
                checkerProfile[currentProfile].checkResolution = pictResolution->isChecked();
174
                checkerProfile[currentProfile].checkTransparency = tranparentObjects->isChecked();
175
                checkerProfile[currentProfile].minResolution = resolutionValue->value();
5239 fschmid 176
                checkerProfile[currentProfile].maxResolution = resolutionValueM->value();
1284 fschmid 177
                checkerProfile[currentProfile].checkAnnotations = useAnnotations->isChecked();
178
                checkerProfile[currentProfile].checkRasterPDF = rasterPDF->isChecked();
5270 subik 179
                checkerProfile[currentProfile].checkForGIF = checkForGIF->isChecked();
6619 fschmid 180
                checkerProfile[currentProfile].ignoreOffLayers = ignoreOffLayers->isChecked();
14543 cbradney 181
                checkerProfile[currentProfile].checkOffConflictLayers = checkOffConflictLayers->isChecked();
1284 fschmid 182
        }
1261 fschmid 183
}
184
 
185
void TabCheckDoc::setProfile(const QString& name)
186
{
1284 fschmid 187
        if (checkerProfile.contains(name))
188
        {
189
                putProfile();
190
                updateProfile(name);
4776 cbradney 191
                tempNewProfileName="";
1284 fschmid 192
                addProfile->setEnabled(false);
193
        }
194
        else
4776 cbradney 195
        {
196
                tempNewProfileName=name;
1284 fschmid 197
                addProfile->setEnabled(true);
4776 cbradney 198
        }
1284 fschmid 199
}
200
 
201
void TabCheckDoc::updateProfile(const QString& name)
202
{
1261 fschmid 203
        disconnect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
204
        disconnect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
205
        disconnect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
206
        disconnect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
207
        disconnect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
208
        disconnect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
209
        disconnect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
210
        disconnect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
5239 fschmid 211
        disconnect(resolutionValueM, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
1284 fschmid 212
        disconnect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
5270 subik 213
        disconnect(checkForGIF, SIGNAL(clicked()), this, SLOT(putProfile()));
1284 fschmid 214
        disconnect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
6619 fschmid 215
        disconnect(ignoreOffLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
14543 cbradney 216
        disconnect(checkOffConflictLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
1261 fschmid 217
        ignoreErrors->setChecked(checkerProfile[name].ignoreErrors);
218
        automaticCheck->setChecked(checkerProfile[name].autoCheck);
219
        missingGlyphs->setChecked(checkerProfile[name].checkGlyphs);
220
        checkOrphans->setChecked(checkerProfile[name].checkOrphans);
221
        textOverflow->setChecked(checkerProfile[name].checkOverflow);
222
        tranparentObjects->setChecked(checkerProfile[name].checkTransparency);
223
        missingPictures->setChecked(checkerProfile[name].checkPictures);
224
        pictResolution->setChecked(checkerProfile[name].checkResolution);
225
        resolutionValue->setValue( qRound(checkerProfile[name].minResolution) );
5239 fschmid 226
        resolutionValueM->setValue( qRound(checkerProfile[name].maxResolution) );
1284 fschmid 227
        useAnnotations->setChecked(checkerProfile[name].checkAnnotations);
228
        rasterPDF->setChecked(checkerProfile[name].checkRasterPDF);
5270 subik 229
        checkForGIF->setChecked(checkerProfile[name].checkForGIF);
6619 fschmid 230
        ignoreOffLayers->setChecked(checkerProfile[name].ignoreOffLayers);
14543 cbradney 231
        checkOffConflictLayers->setChecked(checkerProfile[name].checkOffConflictLayers);
1261 fschmid 232
        currentProfile = name;
233
        connect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
234
        connect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
235
        connect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
236
        connect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
237
        connect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
238
        connect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
239
        connect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
240
        connect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
5239 fschmid 241
        connect(resolutionValueM, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
1284 fschmid 242
        connect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
5270 subik 243
        connect(checkForGIF, SIGNAL(clicked()), this, SLOT(putProfile()));
1284 fschmid 244
        connect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
6619 fschmid 245
        connect(ignoreOffLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
14543 cbradney 246
        connect(checkOffConflictLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
1261 fschmid 247
}
1284 fschmid 248
 
249
void TabCheckDoc::addProf()
250
{
251
        struct checkerPrefs checkerSettings;
252
        checkerSettings.ignoreErrors = ignoreErrors->isChecked();
253
        checkerSettings.autoCheck = automaticCheck->isChecked();
254
        checkerSettings.checkGlyphs = missingGlyphs->isChecked();
255
        checkerSettings.checkOrphans = checkOrphans->isChecked();
256
        checkerSettings.checkOverflow = textOverflow->isChecked();
257
        checkerSettings.checkPictures = missingPictures->isChecked();
258
        checkerSettings.checkResolution = pictResolution->isChecked();
259
        checkerSettings.checkTransparency =  tranparentObjects->isChecked();
260
        checkerSettings.minResolution = resolutionValue->value();
5239 fschmid 261
        checkerSettings.maxResolution = resolutionValueM->value();
1284 fschmid 262
        checkerSettings.checkAnnotations = useAnnotations->isChecked();
263
        checkerSettings.checkRasterPDF = rasterPDF->isChecked();
5270 subik 264
        checkerSettings.checkForGIF = checkForGIF->isChecked();
6619 fschmid 265
        checkerSettings.ignoreOffLayers = ignoreOffLayers->isChecked();
14543 cbradney 266
        checkerSettings.checkOffConflictLayers = checkOffConflictLayers->isChecked();
4776 cbradney 267
        checkerProfile.insert(tempNewProfileName, checkerSettings);
268
        currentProfile = tempNewProfileName;
1284 fschmid 269
        if (checkerProfile.count() > 1)
270
                removeProfile->setEnabled(true);
271
        addProfile->setEnabled(false);
4776 cbradney 272
        curCheckProfile->clear();
273
 
274
        disconnect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
15409 craig 275
        disconnect(curCheckProfile, SIGNAL(editTextChanged(const QString&)), this, SLOT(setProfile(const QString&)));  
4776 cbradney 276
        CheckerPrefsList::Iterator it;
277
        int j,i=0;
278
        for (it = checkerProfile.begin(), j=0; it != checkerProfile.end(); ++it, ++j)
279
        {
9838 fschmid 280
                curCheckProfile->addItem(it.key());
4776 cbradney 281
                if (it.key()==currentProfile)
282
                        i=j;
283
        }
10585 fschmid 284
        curCheckProfile->setCurrentIndex(i);
4776 cbradney 285
        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
15409 craig 286
        connect(curCheckProfile, SIGNAL(editTextChanged(const QString&)), this, SLOT(setProfile(const QString&)));
4776 cbradney 287
        tempNewProfileName="";
1284 fschmid 288
}
289
 
290
void TabCheckDoc::delProf()
291
{
292
        disconnect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
15409 craig 293
        disconnect(curCheckProfile, SIGNAL(editTextChanged(const QString&)), this, SLOT(setProfile(const QString&)));
1284 fschmid 294
        checkerProfile.remove(currentProfile);
295
        updateProfile(checkerProfile.begin().key());
296
        curCheckProfile->clear();
3033 cbradney 297
        CheckerPrefsList::Iterator it;
298
        CheckerPrefsList::Iterator itend=checkerProfile.end();
299
        for (it = checkerProfile.begin(); it != itend; ++it)
9838 fschmid 300
                curCheckProfile->addItem(it.key());
10648 fschmid 301
        setCurrentComboItem(curCheckProfile, currentProfile);
1284 fschmid 302
        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
15409 craig 303
        connect(curCheckProfile, SIGNAL(editTextChanged(const QString&)), this, SLOT(setProfile(const QString&)));
1284 fschmid 304
        if (checkerProfile.count() == 1)
305
                removeProfile->setEnabled(false);
306
}