Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
1235 fschmid 1
#include "tabcheckdoc.h"
2
#include "tabcheckdoc.moc"
3
#include <qvariant.h>
4
#include <qcheckbox.h>
5
#include <qgroupbox.h>
6
#include <qlabel.h>
7
#include <qspinbox.h>
8
#include <qlayout.h>
9
#include <qtooltip.h>
10
#include <qwhatsthis.h>
1261 fschmid 11
#include <qcombobox.h>
1284 fschmid 12
#include <qpushbutton.h>
1235 fschmid 13
 
1261 fschmid 14
TabCheckDoc::TabCheckDoc( QWidget* parent, QMap<QString, checkerPrefs> prefsData, QString prefProfile ) : QWidget( parent, "tabcheckDoc", 0 )
1235 fschmid 15
{
1261 fschmid 16
        checkerProfile = prefsData;
1878 cbradney 17
        TabCheckDocLayout = new QVBoxLayout( this, 0, 5, "TabCheckDocLayout");
1235 fschmid 18
        TabCheckDocLayout->setAlignment( Qt::AlignTop );
1261 fschmid 19
        curCheckProfile = new QComboBox( true, this, "Profiles" );
1284 fschmid 20
        curCheckProfile->setEditable(true);
21
        curCheckProfile->setDuplicatesEnabled(false);
1261 fschmid 22
        QMap<QString, checkerPrefs>::Iterator it;
23
        for (it = checkerProfile.begin(); it != checkerProfile.end(); ++it)
24
        {
25
                curCheckProfile->insertItem(it.key());
26
        }
27
        curCheckProfile->setCurrentText(prefProfile);
28
        TabCheckDocLayout->addWidget( curCheckProfile );
1235 fschmid 29
        ignoreErrors = new QCheckBox( this, "ignoreErrors" );
1266 cbradney 30
        ignoreErrors->setText( tr( "Ignore all errors" ) );
1235 fschmid 31
        TabCheckDocLayout->addWidget( ignoreErrors );
32
        automaticCheck = new QCheckBox( this, "automaticCheck" );
1266 cbradney 33
        automaticCheck->setText( tr( "Automatic check before printing or exporting" ) );
1235 fschmid 34
        TabCheckDocLayout->addWidget( automaticCheck );
35
        missingGlyphs = new QCheckBox( this, "missingGlyphs" );
1266 cbradney 36
        missingGlyphs->setText( tr( "Check for missing glyphs" ) );
1235 fschmid 37
        TabCheckDocLayout->addWidget( missingGlyphs );
38
        checkOrphans = new QCheckBox( this, "checkOrphans" );
1266 cbradney 39
        checkOrphans->setText( tr( "Check for objects not on a page" ) );
1235 fschmid 40
        TabCheckDocLayout->addWidget( checkOrphans );
41
        textOverflow = new QCheckBox( this, "textOverflow" );
1266 cbradney 42
        textOverflow->setText( tr( "Check for overflow in text frames" ) );
1235 fschmid 43
        TabCheckDocLayout->addWidget( textOverflow );
44
        tranparentObjects = new QCheckBox( this, "tranparentObjects" );
1266 cbradney 45
        tranparentObjects->setText( tr( "Check for transparencies used" ) );
1235 fschmid 46
        TabCheckDocLayout->addWidget( tranparentObjects );
47
        missingPictures = new QCheckBox( this, "missingPictures" );
1266 cbradney 48
        missingPictures->setText( tr( "Check for missing images" ) );
1235 fschmid 49
        TabCheckDocLayout->addWidget( missingPictures );
50
        pictResolution = new QGroupBox( this, "pictResolution" );
1266 cbradney 51
        pictResolution->setTitle( tr( "Check image resolution" ) );
1235 fschmid 52
        pictResolution->setCheckable( true );
53
        pictResolution->setColumnLayout(0, Qt::Vertical );
54
        pictResolution->layout()->setSpacing( 5 );
55
        pictResolution->layout()->setMargin( 10 );
56
        pictResolutionLayout = new QHBoxLayout( pictResolution->layout() );
57
        pictResolutionLayout->setAlignment( Qt::AlignTop );
58
        textLabel1 = new QLabel( pictResolution, "textLabel1" );
1266 cbradney 59
        textLabel1->setText( tr( "Lowest allowed resolution" ) );
1235 fschmid 60
        pictResolutionLayout->addWidget( textLabel1 );
61
        resolutionValue = new QSpinBox( pictResolution, "resolutionValue" );
62
        resolutionValue->setMaxValue( 3600 );
63
        resolutionValue->setMinValue( 10 );
64
        resolutionValue->setSuffix( tr( " dpi" ) );
65
        pictResolutionLayout->addWidget( resolutionValue );
66
        TabCheckDocLayout->addWidget( pictResolution );
1284 fschmid 67
        rasterPDF = new QCheckBox( this, "rasterPDF" );
68
        rasterPDF->setText( tr( "Check for placed PDF-Files" ) );
69
        TabCheckDocLayout->addWidget( rasterPDF );
70
        useAnnotations = new QCheckBox( this, "useAnnotations" );
71
        useAnnotations->setText( tr( "Check for PDF Annotations and Fields" ) );
72
        TabCheckDocLayout->addWidget( useAnnotations );
73
        layout1 = new QHBoxLayout( 0, 0, 5, "layout1");
74
        QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
75
        layout1->addItem( spacer );
76
        addProfile = new QPushButton( tr( "Add Profile" ), this, "addProfile" );
77
        layout1->addWidget( addProfile );
78
        removeProfile = new QPushButton( tr( "Remove Profile" ), this, "removeProfile" );
79
        layout1->addWidget( removeProfile );
80
        QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
81
        layout1->addItem( spacer2 );
82
        TabCheckDocLayout->addLayout( layout1 );
1261 fschmid 83
        ignoreErrors->setChecked(checkerProfile[prefProfile].ignoreErrors);
84
        automaticCheck->setChecked(checkerProfile[prefProfile].autoCheck);
85
        missingGlyphs->setChecked(checkerProfile[prefProfile].checkGlyphs);
86
        checkOrphans->setChecked(checkerProfile[prefProfile].checkOrphans);
87
        textOverflow->setChecked(checkerProfile[prefProfile].checkOverflow);
88
        tranparentObjects->setChecked(checkerProfile[prefProfile].checkTransparency);
89
        missingPictures->setChecked(checkerProfile[prefProfile].checkPictures);
90
        pictResolution->setChecked(checkerProfile[prefProfile].checkResolution);
1284 fschmid 91
        useAnnotations->setChecked(checkerProfile[prefProfile].checkAnnotations);
92
        rasterPDF->setChecked(checkerProfile[prefProfile].checkRasterPDF);
1261 fschmid 93
        resolutionValue->setValue( qRound(checkerProfile[prefProfile].minResolution) );
94
        currentProfile = prefProfile;
1284 fschmid 95
        if (checkerProfile.count() == 1)
96
                removeProfile->setEnabled(false);
97
        addProfile->setEnabled(false);
1261 fschmid 98
        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
1284 fschmid 99
        connect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));
1261 fschmid 100
        connect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
101
        connect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
102
        connect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
103
        connect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
104
        connect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
105
        connect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
106
        connect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
1284 fschmid 107
        connect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
108
        connect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
1261 fschmid 109
        connect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
1284 fschmid 110
        connect(removeProfile, SIGNAL(clicked()), this, SLOT(delProf()));
111
        connect(addProfile, SIGNAL(clicked()), this, SLOT(addProf()));
1235 fschmid 112
        clearWState( WState_Polished );
113
}
1261 fschmid 114
 
1828 fschmid 115
void TabCheckDoc::restoreDefaults()
116
{
117
}
118
 
1261 fschmid 119
void TabCheckDoc::putProfile()
120
{
1284 fschmid 121
        if (checkerProfile.contains(currentProfile))
122
        {
123
                checkerProfile[currentProfile].ignoreErrors = ignoreErrors->isChecked();
124
                checkerProfile[currentProfile].autoCheck = automaticCheck->isChecked();
125
                checkerProfile[currentProfile].checkGlyphs = missingGlyphs->isChecked();
126
                checkerProfile[currentProfile].checkOrphans = checkOrphans->isChecked();
127
                checkerProfile[currentProfile].checkOverflow = textOverflow->isChecked();
128
                checkerProfile[currentProfile].checkPictures = missingPictures->isChecked();
129
                checkerProfile[currentProfile].checkResolution = pictResolution->isChecked();
130
                checkerProfile[currentProfile].checkTransparency = tranparentObjects->isChecked();
131
                checkerProfile[currentProfile].minResolution = resolutionValue->value();
132
                checkerProfile[currentProfile].checkAnnotations = useAnnotations->isChecked();
133
                checkerProfile[currentProfile].checkRasterPDF = rasterPDF->isChecked();
134
        }
1261 fschmid 135
}
136
 
137
void TabCheckDoc::setProfile(const QString& name)
138
{
1284 fschmid 139
        if (checkerProfile.contains(name))
140
        {
141
                putProfile();
142
                updateProfile(name);
143
                addProfile->setEnabled(false);
144
        }
145
        else
146
                addProfile->setEnabled(true);
147
}
148
 
149
void TabCheckDoc::updateProfile(const QString& name)
150
{
1261 fschmid 151
        disconnect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
152
        disconnect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
153
        disconnect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
154
        disconnect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
155
        disconnect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
156
        disconnect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
157
        disconnect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
158
        disconnect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
1284 fschmid 159
        disconnect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
160
        disconnect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
1261 fschmid 161
        ignoreErrors->setChecked(checkerProfile[name].ignoreErrors);
162
        automaticCheck->setChecked(checkerProfile[name].autoCheck);
163
        missingGlyphs->setChecked(checkerProfile[name].checkGlyphs);
164
        checkOrphans->setChecked(checkerProfile[name].checkOrphans);
165
        textOverflow->setChecked(checkerProfile[name].checkOverflow);
166
        tranparentObjects->setChecked(checkerProfile[name].checkTransparency);
167
        missingPictures->setChecked(checkerProfile[name].checkPictures);
168
        pictResolution->setChecked(checkerProfile[name].checkResolution);
169
        resolutionValue->setValue( qRound(checkerProfile[name].minResolution) );
1284 fschmid 170
        useAnnotations->setChecked(checkerProfile[name].checkAnnotations);
171
        rasterPDF->setChecked(checkerProfile[name].checkRasterPDF);
1261 fschmid 172
        currentProfile = name;
173
        connect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
174
        connect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
175
        connect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
176
        connect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
177
        connect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
178
        connect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
179
        connect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
180
        connect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
1284 fschmid 181
        connect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
182
        connect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
1261 fschmid 183
}
1284 fschmid 184
 
185
void TabCheckDoc::addProf()
186
{
187
        struct checkerPrefs checkerSettings;
188
        checkerSettings.ignoreErrors = ignoreErrors->isChecked();
189
        checkerSettings.autoCheck = automaticCheck->isChecked();
190
        checkerSettings.checkGlyphs = missingGlyphs->isChecked();
191
        checkerSettings.checkOrphans = checkOrphans->isChecked();
192
        checkerSettings.checkOverflow = textOverflow->isChecked();
193
        checkerSettings.checkPictures = missingPictures->isChecked();
194
        checkerSettings.checkResolution = pictResolution->isChecked();
195
        checkerSettings.checkTransparency =  tranparentObjects->isChecked();
196
        checkerSettings.minResolution = resolutionValue->value();
197
        checkerSettings.checkAnnotations = useAnnotations->isChecked();
198
        checkerSettings.checkRasterPDF = rasterPDF->isChecked();
199
        checkerProfile.insert(curCheckProfile->currentText(), checkerSettings);
200
        currentProfile = curCheckProfile->currentText();
201
        if (checkerProfile.count() > 1)
202
                removeProfile->setEnabled(true);
203
        addProfile->setEnabled(false);
204
}
205
 
206
void TabCheckDoc::delProf()
207
{
208
        disconnect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
209
        disconnect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));
210
        checkerProfile.remove(currentProfile);
211
        updateProfile(checkerProfile.begin().key());
212
        QMap<QString, checkerPrefs>::Iterator it;
213
        curCheckProfile->clear();
214
        for (it = checkerProfile.begin(); it != checkerProfile.end(); ++it)
215
        {
216
                curCheckProfile->insertItem(it.key());
217
        }
218
        curCheckProfile->setCurrentText(currentProfile);
219
        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
220
        connect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));
221
        if (checkerProfile.count() == 1)
222
                removeProfile->setEnabled(false);
223
}