Subversion Repositories Scribus

Rev

Rev 16192 | Rev 16215 | Go to most recent revision | 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
*/
2834 cbradney 7
/***************************************************************************
8
        copyright            : (C) 2005 by Craig Bradney
9
        email                : cbradney@zip.com.au
10
***************************************************************************/
11
 
12
/***************************************************************************
13
*                                                                         *
14
*   This program is free software; you can redistribute it and/or modify  *
15
*   it under the terms of the GNU General Public License as published by  *
16
*   the Free Software Foundation; either version 2 of the License, or     *
17
*   (at your option) any later version.                                   *
18
*                                                                         *
19
***************************************************************************/
2835 cbradney 20
 
10531 avox 21
#include <QColor>
22
#include <QDebug>
8528 cbradney 23
#include <QDesktopWidget>
10223 cbradney 24
#include <QDir>
25
#include <QDomDocument>
26
#include <QFile>
13951 fschmid 27
#include <QTransform>
10531 avox 28
#include <QList>
10223 cbradney 29
#include <QString>
11506 mrdocs 30
#include <QStringList>
10223 cbradney 31
#include <QStyleFactory>
2835 cbradney 32
 
2834 cbradney 33
#include "prefsmanager.h"
5243 cbradney 34
 
35
#include "actionmanager.h"
4606 cbradney 36
#include "colorsetmanager.h"
4538 cbradney 37
#include "commonstrings.h"
2859 cbradney 38
#include "filewatcher.h"
11506 mrdocs 39
#include "latexhelpers.h"
13650 cbradney 40
#include "ui/missing.h"
15834 fschmid 41
//#include "ui/tabkeyboardshortcutswidget.h"
42
#include "ui/prefs_keyboardshortcuts.h"
2865 cbradney 43
#include "pagesize.h"
4122 cbradney 44
#include "pagestructs.h"
2835 cbradney 45
#include "pdfoptions.h"
46
#include "prefsfile.h"
13460 jghali 47
#include "scclocale.h"
14150 fschmid 48
#include "sccolorengine.h"
2835 cbradney 49
#include "scfonts.h"
13576 cbradney 50
#include "ui/scmessagebox.h"
2835 cbradney 51
#include "scpaths.h"
5781 cbradney 52
#include "scribuscore.h"
2835 cbradney 53
#include "scribusstructs.h"
5243 cbradney 54
#include "scribuscore.h"
10976 cbradney 55
#include "ui/modetoolbar.h"
15665 fschmid 56
#include "util_color.h"
11605 jghali 57
#include "util_file.h"
10212 cbradney 58
#include "util_ghostscript.h"
10976 cbradney 59
 
2859 cbradney 60
extern bool emergencyActivated;
2835 cbradney 61
 
2834 cbradney 62
PrefsManager* PrefsManager::_instance = 0;
63
 
10427 cbradney 64
PrefsManager::PrefsManager(QObject *parent)
13482 cbradney 65
 : QObject(parent),
66
 firstTimeIgnoreOldPrefs(false)
2834 cbradney 67
{
68
}
69
 
70
PrefsManager::~PrefsManager()
71
{
13955 cbradney 72
        appPrefs.fontPrefs.AvailFonts.clear();
2856 cbradney 73
        delete prefsFile;
2834 cbradney 74
}
75
 
76
PrefsManager* PrefsManager::instance()
77
{
14043 jghali 78
        if (_instance == 0)
79
                _instance = new PrefsManager();
2834 cbradney 80
 
14043 jghali 81
        return _instance;
2834 cbradney 82
}
83
 
84
void PrefsManager::deleteInstance()
85
{
14043 jghali 86
        if (_instance)
87
                delete _instance;
88
        _instance = 0;
2834 cbradney 89
}
90
 
91
 
92
ApplicationPrefs* PrefsManager::applicationPrefs()
93
{
94
        return &appPrefs;
95
}
2835 cbradney 96
 
14046 cbradney 97
void PrefsManager::setNewPrefs(ApplicationPrefs& newPrefs)
98
{
99
        appPrefs=newPrefs;
100
}
101
 
2856 cbradney 102
PrefsFile* PrefsManager::applicationPrefsFile()
103
{
104
        return prefsFile;
105
}
106
 
10509 cbradney 107
bool PrefsManager::importingFrom12x()
2856 cbradney 108
{
109
        return importingFrom12;
110
}
111
 
112
 
113
void PrefsManager::setup()
114
{
115
        setupPreferencesLocation();
116
 
5200 cbradney 117
        importingFrom12=copyOldPreferences();
13608 jghali 118
        prefsFile = new PrefsFile( prefsLocation + "/prefs150.xml" );
2856 cbradney 119
        if (importingFrom12)
120
                convert12Preferences();
121
        //<<CB TODO Reset keyboard shortcuts of all 1.3 users as too many
122
        //     have conflicts if they dont nuke their settings.
123
        // - Remove for 1.3.0 release: importingFrom12=true;
124
        //>>CB
125
}
126
 
2835 cbradney 127
void PrefsManager::initDefaults()
128
{
129
        /** Default font and size **/
13955 cbradney 130
        SCFontsIterator it(appPrefs.fontPrefs.AvailFonts);
4221 fschmid 131
        bool goodFont = false;
13955 cbradney 132
        for ( SCFontsIterator itf(appPrefs.fontPrefs.AvailFonts); itf.hasNext(); itf.next())
4221 fschmid 133
        {
134
                if ((itf.currentKey() == "Arial Regular") || (itf.currentKey() == "Times New Roman Regular"))
135
                {
13996 cbradney 136
                        appPrefs.itemToolPrefs.textFont = itf.currentKey();
4221 fschmid 137
                        goodFont = true;
138
                        break;
139
                }
140
        }
141
        if (!goodFont)
13996 cbradney 142
                appPrefs.itemToolPrefs.textFont = it.currentKey();
143
        appPrefs.itemToolPrefs.textSize = 120;
2835 cbradney 144
 
145
        /** Default colours **/
16016 fschmid 146
        appPrefs.defaultPatterns.clear();
14150 fschmid 147
        appPrefs.defaultGradients.clear();
13967 cbradney 148
        appPrefs.colorPrefs.DColors.clear();
14043 jghali 149
 
4606 cbradney 150
        ColorSetManager csm;
151
        csm.initialiseDefaultPrefs(appPrefs);
2835 cbradney 152
 
13876 cbradney 153
        appPrefs.uiPrefs.wheelJump = 40;
3641 fschmid 154
        /** Set Default window position and size to sane default values which should work on every screen */
13955 cbradney 155
//      appPrefs.uiPrefs.mainWinSettings.xPosition = 0;
156
//      appPrefs.uiPrefs.mainWinSettings.yPosition = 0;
157
        appPrefs.uiPrefs.mainWinSettings.width = 640;
158
        appPrefs.uiPrefs.mainWinSettings.height = 480;
13050 cbradney 159
        QDesktopWidget *d = QApplication::desktop();
13955 cbradney 160
        appPrefs.uiPrefs.mainWinSettings.xPosition=(d->availableGeometry().width()-appPrefs.uiPrefs.mainWinSettings.width)/2;
161
        appPrefs.uiPrefs.mainWinSettings.yPosition=(d->availableGeometry().height()-appPrefs.uiPrefs.mainWinSettings.height)/2;
162
        appPrefs.uiPrefs.mainWinSettings.maximized = false;
163
        appPrefs.uiPrefs.mainWinState = QByteArray();
13889 cbradney 164
        appPrefs.guidesPrefs.marginsShown = true;
165
        appPrefs.guidesPrefs.framesShown = true;
166
        appPrefs.guidesPrefs.layerMarkersShown = false;
167
        appPrefs.guidesPrefs.gridShown = false;
168
        appPrefs.guidesPrefs.guidesShown = true;
169
        appPrefs.guidesPrefs.colBordersShown = true;
170
        appPrefs.guidesPrefs.baselineGridShown = false;
171
        appPrefs.guidesPrefs.showPic = true;
172
        appPrefs.guidesPrefs.showControls = false;
173
        appPrefs.guidesPrefs.linkShown = false;
174
        appPrefs.guidesPrefs.rulersShown = true;
175
        appPrefs.guidesPrefs.showBleed = true;
176
        appPrefs.guidesPrefs.rulerMode = true;
177
        appPrefs.guidesPrefs.grabRadius = 4;
178
        appPrefs.guidesPrefs.guideRad = 10;
179
        appPrefs.guidesPrefs.minorGridSpacing = 20;
180
        appPrefs.guidesPrefs.majorGridSpacing = 100;
181
        appPrefs.guidesPrefs.minorGridColor = QColor(Qt::green);
182
        appPrefs.guidesPrefs.majorGridColor = QColor(Qt::green);
183
        appPrefs.guidesPrefs.marginColor = QColor(Qt::blue);
184
        appPrefs.guidesPrefs.guideColor = QColor(Qt::darkBlue);
185
        appPrefs.guidesPrefs.baselineGridColor = QColor(Qt::lightGray);
13953 cbradney 186
        appPrefs.typoPrefs.valueSuperScript = 33;
187
        appPrefs.typoPrefs.scalingSuperScript = 66;
188
        appPrefs.typoPrefs.valueSubScript = 33;
189
        appPrefs.typoPrefs.scalingSubScript = 66;
190
        appPrefs.typoPrefs.valueSmallCaps = 75;
191
        appPrefs.typoPrefs.autoLineSpacing = 20;
192
        appPrefs.typoPrefs.valueUnderlinePos = -1;
193
        appPrefs.typoPrefs.valueUnderlineWidth = -1;
194
        appPrefs.typoPrefs.valueStrikeThruPos = -1;
195
        appPrefs.typoPrefs.valueStrikeThruWidth = -1;
13889 cbradney 196
        appPrefs.guidesPrefs.valueBaselineGrid = 14.4;
197
        appPrefs.guidesPrefs.offsetBaselineGrid = 0.0;
13876 cbradney 198
        appPrefs.uiPrefs.style = "";
13955 cbradney 199
        appPrefs.uiPrefs.grayscaleIcons = false; // can be a little slower on startup.. but its a nice effect to play with
200
        appPrefs.displayPrefs.showToolTips = true;
201
        appPrefs.displayPrefs.showMouseCoordinates = true;
13876 cbradney 202
        appPrefs.uiPrefs.mouseMoveTimeout = 150;
13955 cbradney 203
        appPrefs.uiPrefs.stickyTools = false;
2835 cbradney 204
        //FIXME
205
        //Black here causes issues when a colour set is loaded without "Black" in it.
206
        //"Black" is created with wrong values. Eg SVG colour set
14014 cbradney 207
        appPrefs.itemToolPrefs.shapeLineColor = "Black";
15187 cbradney 208
        appPrefs.itemToolPrefs.shapeFillColor = CommonStrings::None;
14014 cbradney 209
        appPrefs.itemToolPrefs.shapeLineColorShade = 100;
210
        appPrefs.itemToolPrefs.shapeFillColorShade = 100;
211
        appPrefs.itemToolPrefs.shapeLineStyle = Qt::SolidLine;
15187 cbradney 212
        appPrefs.itemToolPrefs.shapeLineWidth = 1;
13996 cbradney 213
        appPrefs.itemToolPrefs.lineColor = "Black";
214
        appPrefs.itemToolPrefs.textColor = "Black";
215
        appPrefs.itemToolPrefs.textStrokeColor = "Black";
14014 cbradney 216
        appPrefs.itemToolPrefs.textFillColor = CommonStrings::None;
13996 cbradney 217
        appPrefs.itemToolPrefs.textLineColor = CommonStrings::None;
14014 cbradney 218
        appPrefs.itemToolPrefs.textFillColorShade = 100;
219
        appPrefs.itemToolPrefs.textLineColorShade = 100;
13996 cbradney 220
        appPrefs.itemToolPrefs.textShade = 100;
221
        appPrefs.itemToolPrefs.textStrokeShade = 100;
222
        appPrefs.itemToolPrefs.textTabFillChar = "";
223
        appPrefs.itemToolPrefs.textTabWidth = 36.0;
15847 fschmid 224
        // defaults for calligraphic pen
225
        appPrefs.itemToolPrefs.calligrapicPenFillColor = "Black";
226
        appPrefs.itemToolPrefs.calligrapicPenLineColor = "Black";
227
        appPrefs.itemToolPrefs.calligrapicPenFillColorShade = 100;
228
        appPrefs.itemToolPrefs.calligrapicPenLineColorShade = 100;
229
        appPrefs.itemToolPrefs.calligrapicPenLineWidth = 1.0;
230
        appPrefs.itemToolPrefs.calligrapicPenAngle = 0.0;
231
        appPrefs.itemToolPrefs.calligrapicPenWidth = 10.0;
232
        appPrefs.itemToolPrefs.calligrapicPenStyle = Qt::SolidLine;
233
 
13953 cbradney 234
        appPrefs.opToolPrefs.dispX = 10.0;
235
        appPrefs.opToolPrefs.dispY = 10.0;
236
        appPrefs.opToolPrefs.constrain = 15.0;
13974 cbradney 237
        appPrefs.displayPrefs.paperColor = QColor(Qt::white);
15139 cbradney 238
        appPrefs.displayPrefs.scratchColor = qApp->palette().color(QPalette::Active, QPalette::Window);
13955 cbradney 239
        appPrefs.displayPrefs.showPageShadow = true;
14811 cbradney 240
        appPrefs.displayPrefs.showVerifierWarningsOnCanvas = true;
13974 cbradney 241
        appPrefs.displayPrefs.frameColor = QColor(Qt::red);
242
        appPrefs.displayPrefs.frameNormColor = QColor(Qt::black);
243
        appPrefs.displayPrefs.frameGroupColor = QColor(Qt::darkCyan);
244
        appPrefs.displayPrefs.frameLockColor = QColor(Qt::darkRed);
245
        appPrefs.displayPrefs.frameLinkColor = QColor(Qt::red);
246
        appPrefs.displayPrefs.frameAnnotationColor = QColor(Qt::blue);
247
        appPrefs.displayPrefs.pageBorderColor = QColor(Qt::red);
248
        appPrefs.displayPrefs.controlCharColor = QColor(Qt::darkRed);
13996 cbradney 249
        appPrefs.itemToolPrefs.textColumns = 1;
250
        appPrefs.itemToolPrefs.textColumnGap = 0.0;
14014 cbradney 251
        appPrefs.itemToolPrefs.lineColorShade = 100;
13996 cbradney 252
        appPrefs.itemToolPrefs.lineStyle = Qt::SolidLine;
253
        appPrefs.itemToolPrefs.lineWidth = 1;
254
        appPrefs.itemToolPrefs.lineStartArrow = 0;
255
        appPrefs.itemToolPrefs.lineEndArrow = 0;
14730 fschmid 256
        appPrefs.opToolPrefs.magMin = 1;
13953 cbradney 257
        appPrefs.opToolPrefs.magMax = 3200;
258
        appPrefs.opToolPrefs.magStep = 200;
13996 cbradney 259
        appPrefs.itemToolPrefs.imageFillColor = CommonStrings::None;
14014 cbradney 260
        appPrefs.itemToolPrefs.imageFillColorShade = 100;
13996 cbradney 261
        appPrefs.itemToolPrefs.imageScaleX = 1;
262
        appPrefs.itemToolPrefs.imageScaleY = 1;
13889 cbradney 263
        appPrefs.guidesPrefs.guidePlacement = true;
13876 cbradney 264
        appPrefs.docSetupPrefs.docUnitIndex = 0;
13996 cbradney 265
        appPrefs.itemToolPrefs.polyCorners = 4;
14022 cbradney 266
        appPrefs.itemToolPrefs.polyFactor = 0.5;
13996 cbradney 267
        appPrefs.itemToolPrefs.polyUseFactor = false;
14027 fschmid 268
        appPrefs.itemToolPrefs.polyFactorGuiVal = 0;
13996 cbradney 269
        appPrefs.itemToolPrefs.polyRotation = 0.0;
16191 fschmid 270
        appPrefs.itemToolPrefs.polyInnerRot = 0.0;
13953 cbradney 271
        appPrefs.itemToolPrefs.polyCurvature = 0.0;
16192 fschmid 272
        appPrefs.itemToolPrefs.polyOuterCurvature = 0.0;
4649 fschmid 273
//      appPrefs.PSize = 40;
13955 cbradney 274
        appPrefs.printerPrefs.ClipMargin = false;
13967 cbradney 275
        appPrefs.printerPrefs.GCRMode = false;
13955 cbradney 276
        appPrefs.uiPrefs.RecentDocs.clear();
277
        appPrefs.scrapbookPrefs.RecentScrapbooks.clear();
13876 cbradney 278
        appPrefs.uiPrefs.recentDocCount = 5;
13955 cbradney 279
        appPrefs.scrapbookPrefs.doCopyToScrapbook = true;
280
        appPrefs.scrapbookPrefs.persistentScrapbook = false;
14715 fschmid 281
        appPrefs.scrapbookPrefs.writePreviews = true;
13955 cbradney 282
        appPrefs.scrapbookPrefs.numScrapbookCopies = 10;
283
        appPrefs.displayPrefs.marginColored = false;
13876 cbradney 284
        appPrefs.docSetupPrefs.pageSize = "A4";
285
        appPrefs.docSetupPrefs.pageOrientation = 0;
2865 cbradney 286
        PageSize a4("A4");
13876 cbradney 287
        appPrefs.docSetupPrefs.pageWidth = a4.width();
288
        appPrefs.docSetupPrefs.pageHeight = a4.height();
289
        appPrefs.docSetupPrefs.margins.Top = 40;
290
        appPrefs.docSetupPrefs.margins.Bottom = 40;
291
        appPrefs.docSetupPrefs.margins.Left = 40;
292
        appPrefs.docSetupPrefs.margins.Right = 40;
293
        appPrefs.docSetupPrefs.marginPreset = 0;
294
        appPrefs.docSetupPrefs.bleeds.Top = 0;
295
        appPrefs.docSetupPrefs.bleeds.Left = 0;
296
        appPrefs.docSetupPrefs.bleeds.Right = 0;
297
        appPrefs.docSetupPrefs.bleeds.Bottom = 0;
13996 cbradney 298
        appPrefs.itemToolPrefs.imageScaleType = true;
299
        appPrefs.itemToolPrefs.imageAspectRatio = true;
300
        appPrefs.itemToolPrefs.imageLowResType = 1;
301
        appPrefs.itemToolPrefs.imageUseEmbeddedPath = false;
13955 cbradney 302
        appPrefs.hyphPrefs.MinWordLen = 3;
303
        appPrefs.hyphPrefs.HyCount = 2;
304
        appPrefs.hyphPrefs.Language = "";
305
        appPrefs.hyphPrefs.specialWords.clear();
306
        appPrefs.hyphPrefs.ignoredWords.clear();
307
        appPrefs.hyphPrefs.Automatic = true;
308
        appPrefs.hyphPrefs.AutoCheck = false;
13967 cbradney 309
        appPrefs.docSetupPrefs.AutoSave = true;
310
        appPrefs.docSetupPrefs.AutoSaveTime = 600000;
14764 cbradney 311
        appPrefs.docSetupPrefs.saveCompressed = false;
12109 fschmid 312
        int dpi = qApp->desktop()->logicalDpiX();
313
        if ((dpi < 60) || (dpi > 200))
314
                dpi = 72;
13974 cbradney 315
        appPrefs.displayPrefs.displayScale = dpi / 72.0;
12109 fschmid 316
 
13876 cbradney 317
        appPrefs.pathPrefs.documents = ScPaths::getUserDocumentDir();
318
        appPrefs.pathPrefs.colorProfiles = "";
319
        appPrefs.pathPrefs.scripts = "";
320
        appPrefs.pathPrefs.documentTemplates = "";
13967 cbradney 321
        appPrefs.printPreviewPrefs.PrPr_Mode = false;
322
        //appPrefs.Gcr_Mode = true;
323
        appPrefs.printPreviewPrefs.PrPr_AntiAliasing = false;
324
        appPrefs.printPreviewPrefs.PrPr_Transparency = false;
325
        appPrefs.printPreviewPrefs.PrPr_C = true;
326
        appPrefs.printPreviewPrefs.PrPr_M = true;
327
        appPrefs.printPreviewPrefs.PrPr_Y = true;
328
        appPrefs.printPreviewPrefs.PrPr_K = true;
329
        appPrefs.printPreviewPrefs.PrPr_InkCoverage = false;
330
        appPrefs.printPreviewPrefs.PrPr_InkThreshold = 250;
13955 cbradney 331
        appPrefs.extToolPrefs.imageEditorExecutable = "gimp";
332
        appPrefs.extToolPrefs.extBrowserExecutable = "";
13957 herm 333
        appPrefs.extToolPrefs.uniconvExecutable = "uniconv";
13955 cbradney 334
        appPrefs.extToolPrefs.latexConfigs = LatexConfigCache::defaultConfigs();
15439 craig 335
        appPrefs.extToolPrefs.latexCommands = LatexConfigCache::defaultCommands();
13955 cbradney 336
        appPrefs.extToolPrefs.latexEditorExecutable = "";
337
        appPrefs.extToolPrefs.latexResolution = 72;
338
        appPrefs.extToolPrefs.latexForceDpi = true;
339
        appPrefs.extToolPrefs.latexStartWithEmptyFrames = false;
340
        appPrefs.extToolPrefs.gs_AntiAliasGraphics = true;
341
        appPrefs.extToolPrefs.gs_AntiAliasText = true;
342
        appPrefs.extToolPrefs.gs_exe = getGSDefaultExeName();
343
        appPrefs.extToolPrefs.gs_Resolution = 72;
14823 cbradney 344
        appPrefs.storyEditorPrefs.guiFontColorBackground = QColor(Qt::white);
345
        appPrefs.storyEditorPrefs.smartTextSelection=false;
13967 cbradney 346
        appPrefs.colorPrefs.DCMSset.DefaultMonitorProfile = "";
347
        appPrefs.colorPrefs.DCMSset.DefaultPrinterProfile = "";
348
        appPrefs.colorPrefs.DCMSset.DefaultImageRGBProfile = "";
349
        appPrefs.colorPrefs.DCMSset.DefaultSolidColorRGBProfile = "";
350
        appPrefs.colorPrefs.DCMSset.DefaultSolidColorCMYKProfile = "";
351
        appPrefs.colorPrefs.DCMSset.CMSinUse = false;
352
        appPrefs.colorPrefs.DCMSset.SoftProofOn = false;
353
        appPrefs.colorPrefs.DCMSset.SoftProofFullOn = false;
354
        appPrefs.colorPrefs.DCMSset.GamutCheck = false;
355
        appPrefs.colorPrefs.DCMSset.BlackPoint = true;
14170 jghali 356
        appPrefs.colorPrefs.DCMSset.DefaultIntentColors = Intent_Relative_Colorimetric;
357
        appPrefs.colorPrefs.DCMSset.DefaultIntentImages = Intent_Perceptual;
13967 cbradney 358
        appPrefs.fontPrefs.GFontSub.clear();
13955 cbradney 359
        appPrefs.displayPrefs.scratch.Left = 100;
360
        appPrefs.displayPrefs.scratch.Right = 100;
361
        appPrefs.displayPrefs.scratch.Top = 20;
362
        appPrefs.displayPrefs.scratch.Bottom = 20;
13974 cbradney 363
        appPrefs.displayPrefs.pageGapHorizontal = 0.0;
364
        appPrefs.displayPrefs.pageGapVertical = 40.0;
3016 fschmid 365
        struct PageSet pageS;
4538 cbradney 366
        pageS.Name = CommonStrings::pageSet1;
3016 fschmid 367
        pageS.FirstPage = 0;
368
        pageS.Rows = 1;
369
        pageS.Columns = 1;
3026 fschmid 370
        pageS.pageNames.clear();
3016 fschmid 371
        appPrefs.pageSets.append(pageS);
4538 cbradney 372
        pageS.Name = CommonStrings::pageSet2;
3016 fschmid 373
        pageS.FirstPage = 1;
374
        pageS.Columns = 2;
3026 fschmid 375
        pageS.pageNames.clear();
4538 cbradney 376
        pageS.pageNames.append(CommonStrings::pageLocLeft);
377
        pageS.pageNames.append(CommonStrings::pageLocRight);
3016 fschmid 378
        appPrefs.pageSets.append(pageS);
4538 cbradney 379
        pageS.Name = CommonStrings::pageSet3;
3016 fschmid 380
        pageS.FirstPage = 0;
381
        pageS.Columns = 3;
3026 fschmid 382
        pageS.pageNames.clear();
4538 cbradney 383
        pageS.pageNames.append(CommonStrings::pageLocLeft);
384
        pageS.pageNames.append(CommonStrings::pageLocMiddle);
385
        pageS.pageNames.append(CommonStrings::pageLocRight);
3016 fschmid 386
        appPrefs.pageSets.append(pageS);
4538 cbradney 387
        pageS.Name = CommonStrings::pageSet4;
3016 fschmid 388
        pageS.FirstPage = 0;
389
        pageS.Columns = 4;
3026 fschmid 390
        pageS.pageNames.clear();
4538 cbradney 391
        pageS.pageNames.append(CommonStrings::pageLocLeft);
392
        pageS.pageNames.append(CommonStrings::pageLocMiddleLeft);
393
        pageS.pageNames.append(CommonStrings::pageLocMiddleRight);
394
        pageS.pageNames.append(CommonStrings::pageLocRight);
3016 fschmid 395
        appPrefs.pageSets.append(pageS);
13876 cbradney 396
        appPrefs.docSetupPrefs.pagePositioning = singlePage;
13955 cbradney 397
        appPrefs.fontPrefs.askBeforeSubstitute = true;
398
        appPrefs.miscPrefs.haveStylePreview = true;
2835 cbradney 399
        // lorem ipsum defaults
13955 cbradney 400
        appPrefs.miscPrefs.useStandardLI = false;
401
        appPrefs.miscPrefs.paragraphsLI = 10;
13876 cbradney 402
        appPrefs.uiPrefs.showStartupDialog = true;
14203 cbradney 403
        appPrefs.uiPrefs.showSplashOnStartup = true;
13876 cbradney 404
        appPrefs.uiPrefs.useSmallWidgets = false;
14224 fschmid 405
        appPrefs.uiPrefs.useTabs = false;
14849 cbradney 406
        initDefaultCheckerPrefs(&appPrefs.verifierPrefs.checkerPrefsList);
407
        appPrefs.verifierPrefs.curCheckProfile = CommonStrings::PostScript;
408
        appPrefs.verifierPrefs.showPagesWithoutErrors=false;
14850 cbradney 409
        appPrefs.verifierPrefs.showNonPrintingLayerErrors=false;
13955 cbradney 410
        appPrefs.pdfPrefs.Thumbnails = false;
411
        appPrefs.pdfPrefs.Articles = false;
412
        appPrefs.pdfPrefs.useLayers = false;
413
        appPrefs.pdfPrefs.Compress = true;
414
        appPrefs.pdfPrefs.CompressMethod = PDFOptions::Compression_Auto;
415
        appPrefs.pdfPrefs.Quality = 0;
416
        appPrefs.pdfPrefs.RecalcPic = false;
417
        appPrefs.pdfPrefs.embedPDF  = false;
418
        appPrefs.pdfPrefs.Bookmarks = false;
419
        appPrefs.pdfPrefs.PicRes = 300;
420
        appPrefs.pdfPrefs.Version = PDFOptions::PDFVersion_14;
421
        appPrefs.pdfPrefs.Resolution = 300;
422
        appPrefs.pdfPrefs.Binding = 0;
423
        appPrefs.pdfPrefs.EmbedList.clear();
424
        appPrefs.pdfPrefs.SubsetList.clear();
425
        appPrefs.pdfPrefs.MirrorH = false;
426
        appPrefs.pdfPrefs.MirrorV = false;
427
        appPrefs.pdfPrefs.doClip = false;
428
        appPrefs.pdfPrefs.RotateDeg = 0;
429
        appPrefs.pdfPrefs.PresentMode = false;
430
        appPrefs.pdfPrefs.fileName = "";
431
        appPrefs.pdfPrefs.PresentVals.clear();
432
        appPrefs.pdfPrefs.isGrayscale = false;
433
        appPrefs.pdfPrefs.UseRGB = true;
434
        appPrefs.pdfPrefs.UseProfiles = false;
435
        appPrefs.pdfPrefs.UseProfiles2 = false;
436
        appPrefs.pdfPrefs.SolidProf = "";
437
        appPrefs.pdfPrefs.SComp = 3;
438
        appPrefs.pdfPrefs.ImageProf = "";
439
        appPrefs.pdfPrefs.PrintProf = "";
440
        appPrefs.pdfPrefs.Info = "";
441
        appPrefs.pdfPrefs.Intent = 0;
442
        appPrefs.pdfPrefs.Intent2 = 0;
443
        appPrefs.pdfPrefs.bleeds.Top = 0;
444
        appPrefs.pdfPrefs.bleeds.Left = 0;
445
        appPrefs.pdfPrefs.bleeds.Right = 0;
446
        appPrefs.pdfPrefs.bleeds.Bottom = 0;
447
        appPrefs.pdfPrefs.useDocBleeds = true;
448
        appPrefs.pdfPrefs.cropMarks = false;
449
        appPrefs.pdfPrefs.bleedMarks = false;
450
        appPrefs.pdfPrefs.registrationMarks = false;
451
        appPrefs.pdfPrefs.colorMarks = false;
452
        appPrefs.pdfPrefs.docInfoMarks = false;
453
        appPrefs.pdfPrefs.markOffset = 0;
454
        appPrefs.pdfPrefs.EmbeddedI = false;
455
        appPrefs.pdfPrefs.Encrypt = false;
456
        appPrefs.pdfPrefs.PassOwner = "";
457
        appPrefs.pdfPrefs.PassUser = "";
458
        appPrefs.pdfPrefs.Permissions = -4;
459
        appPrefs.pdfPrefs.UseLPI = false;
460
        appPrefs.pdfPrefs.LPISettings.clear();
461
        appPrefs.pdfPrefs.UseSpotColors = true;
462
        appPrefs.pdfPrefs.doMultiFile = false;
463
        appPrefs.pdfPrefs.displayBookmarks = false;
464
        appPrefs.pdfPrefs.displayFullscreen = false;
465
        appPrefs.pdfPrefs.displayLayers = false;
466
        appPrefs.pdfPrefs.displayThumbs = false;
467
        appPrefs.pdfPrefs.hideMenuBar = false;
468
        appPrefs.pdfPrefs.hideToolBar = false;
469
        appPrefs.pdfPrefs.fitWindow = false;
16204 fschmid 470
        appPrefs.pdfPrefs.openAfterExport = false;
13955 cbradney 471
        appPrefs.pdfPrefs.PageLayout = PDFOptions::SinglePage;
472
        appPrefs.pdfPrefs.openAction = "";
14539 jghali 473
        appPrefs.imageCachePrefs.cacheEnabled = false;
474
        appPrefs.imageCachePrefs.maxCacheSizeMiB = 1000;
475
        appPrefs.imageCachePrefs.maxCacheEntries = 1000;
476
        appPrefs.imageCachePrefs.compressionLevel = 1;
15105 cbradney 477
        appPrefs.activePageSizes.clear();
478
        appPrefs.activePageSizes << "A4" << "Letter";
2835 cbradney 479
 
480
        //Attribute setup
13955 cbradney 481
        appPrefs.itemAttrPrefs.defaultItemAttributes.clear();
482
        appPrefs.tocPrefs.defaultToCSetups.clear();
14043 jghali 483
 
5243 cbradney 484
        initDefaultActionKeys();
2835 cbradney 485
}
486
 
5243 cbradney 487
void PrefsManager::initDefaultActionKeys()
488
{
489
        ActionManager::createDefaultShortcuts();
5257 cbradney 490
        QMap<QString, QKeySequence > *map=ActionManager::defaultShortcuts();
5243 cbradney 491
        for( QMap<QString, QKeySequence >::ConstIterator it = map->begin(); it!=map->end(); ++it )
492
        {
13955 cbradney 493
                appPrefs.keyShortcutPrefs.KeyActions[it.key()].actionName = it.key();
494
                appPrefs.keyShortcutPrefs.KeyActions[it.key()].keySequence = it.value();
5243 cbradney 495
        }
496
}
497
 
10977 cbradney 498
void PrefsManager::applyLoadedShortCuts()
499
{
13955 cbradney 500
        for (QMap<QString,Keys>::Iterator it = appPrefs.keyShortcutPrefs.KeyActions.begin(); it != appPrefs.keyShortcutPrefs.KeyActions.end(); ++it )
10977 cbradney 501
        {
502
                if (!it.value().actionName.isEmpty())
503
                {
504
                        if (ScCore->primaryMainWindow()->scrActions[it.value().actionName])
505
                                ScCore->primaryMainWindow()->scrActions[it.value().actionName]->setShortcut(it.value().keySequence);
506
                }
507
        }
508
}
509
 
2835 cbradney 510
void PrefsManager::initDefaultGUIFont(const QFont& guiFont)
511
{
13876 cbradney 512
        appPrefs.uiPrefs.applicationFontSize = guiFont.pointSize();
13996 cbradney 513
        appPrefs.storyEditorPrefs.guiFont = guiFont.toString();
13876 cbradney 514
        appPrefs.uiPrefs.paletteFontSize = appPrefs.uiPrefs.applicationFontSize;
2835 cbradney 515
}
516
 
517
void PrefsManager::initArrowStyles()
518
{
519
        struct ArrowDesc arrow;
520
        FPointArray points;
13951 fschmid 521
        QTransform arrowScaling;
2835 cbradney 522
        arrowScaling.scale(0.5, 0.5);
13951 fschmid 523
        QTransform arrowRotate;
11176 fschmid 524
        arrowRotate.rotate(180);
2835 cbradney 525
        arrow.name = "Arrow1L";
526
        arrow.userArrow = false;
527
        points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
528
        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
529
        points.addQuadPoint(12, 0, 12, 0, 12, 0, 12, 0);
530
        points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
531
        points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
532
        arrow.points = points.copy();
533
        appPrefs.arrowStyles.append(arrow);
534
        arrow.name = "Arrow1M";
535
        points.map(arrowScaling);
536
        arrow.points = points.copy();
537
        appPrefs.arrowStyles.append(arrow);
538
        arrow.name = "Arrow1S";
539
        points.map(arrowScaling);
540
        arrow.points = points.copy();
541
        appPrefs.arrowStyles.append(arrow);
542
        arrow.name = "SquareL";
543
        points.resize(0);
544
        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
545
        points.addQuadPoint(5, -5, 5, -5, 5, -5, 5, -5);
546
        points.addQuadPoint(5, 5, 5, 5, 5, 5, 5, 5);
547
        points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
548
        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
549
        arrow.points = points.copy();
550
        appPrefs.arrowStyles.append(arrow);
551
        arrow.name = "SquareM";
552
        points.map(arrowScaling);
553
        arrow.points = points.copy();
554
        appPrefs.arrowStyles.append(arrow);
555
        arrow.name = "SquareS";
556
        points.map(arrowScaling);
557
        arrow.points = points.copy();
558
        appPrefs.arrowStyles.append(arrow);
559
        arrow.name = "TriangleInL";
560
        points.resize(0);
561
        points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
562
        points.addQuadPoint(-2.88, 5, -2.88, 5, -2.88, 5, -2.88, 5);
563
        points.addQuadPoint(-2.88, -5, -2.88, -5, -2.88, -5, -2.88, -5);
564
        points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
565
        arrow.points = points.copy();
566
        appPrefs.arrowStyles.append(arrow);
567
        arrow.name = "TriangleInM";
568
        points.map(arrowScaling);
569
        arrow.points = points.copy();
570
        appPrefs.arrowStyles.append(arrow);
571
        arrow.name = "TriangleInS";
572
        points.map(arrowScaling);
573
        arrow.points = points.copy();
574
        appPrefs.arrowStyles.append(arrow);
575
        arrow.name = "TriangleOutL";
576
        points.resize(0);
577
        points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
578
        points.addQuadPoint(2.88, 5, 2.88, 5, 2.88, 5, 2.88, 5);
579
        points.addQuadPoint(2.88, -5, 2.88, -5, 2.88, -5, 2.88, -5);
580
        points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
581
        arrow.points = points.copy();
582
        appPrefs.arrowStyles.append(arrow);
583
        arrow.name = "TriangleOutM";
584
        points.map(arrowScaling);
585
        arrow.points = points.copy();
586
        appPrefs.arrowStyles.append(arrow);
587
        arrow.name = "TriangleOutS";
588
        points.map(arrowScaling);
589
        arrow.points = points.copy();
590
        appPrefs.arrowStyles.append(arrow);
11176 fschmid 591
        arrow.name = "DiamondL";
592
        points.resize(0);
593
        points.parseSVG("M 0, -7.0710768 L -7.0710894, 0 L 0, 7.0710589 L 7.0710462, 0 L 0,-7.0710768 z");
594
        arrow.points = points.copy();
595
        appPrefs.arrowStyles.append(arrow);
596
        arrow.name = "DiamondM";
597
        points.map(arrowScaling);
598
        arrow.points = points.copy();
599
        appPrefs.arrowStyles.append(arrow);
600
        arrow.name = "DiamondS";
601
        points.map(arrowScaling);
602
        arrow.points = points.copy();
603
        appPrefs.arrowStyles.append(arrow);
604
        points.resize(0);
605
        arrow.name = "DotL";
606
        points.parseSVG("M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z");
607
        points.translate(7.4, 1.0);
608
        arrow.points = points.copy();
609
        appPrefs.arrowStyles.append(arrow);
610
        arrow.name = "DotM";
611
        points.map(arrowScaling);
612
        arrow.points = points.copy();
613
        appPrefs.arrowStyles.append(arrow);
614
        arrow.name = "DotS";
615
        points.map(arrowScaling);
616
        arrow.points = points.copy();
617
        appPrefs.arrowStyles.append(arrow);
618
        points.resize(0);
619
        arrow.name = "SemiCircleInL";
620
        points.parseSVG("M -0.37450702,-0.045692580 C -0.37450702,2.7143074 1.8654930,4.9543074 4.6254930,4.9543074 L 4.6254930,-5.0456926 C 1.8654930,-5.0456926 -0.37450702,-2.8056926 -0.37450702,-0.045692580 z");
621
        arrow.points = points.copy();
622
        appPrefs.arrowStyles.append(arrow);
623
        arrow.name = "SemiCircleInM";
624
        points.map(arrowScaling);
625
        arrow.points = points.copy();
626
        appPrefs.arrowStyles.append(arrow);
627
        arrow.name = "SemiCircleInS";
628
        points.map(arrowScaling);
629
        arrow.points = points.copy();
630
        appPrefs.arrowStyles.append(arrow);
631
        points.resize(0);
632
        arrow.name = "SemiCircleOutL";
633
        points.parseSVG("M -2.5,-0.80913858 C -2.5,1.9508614 -4.7400000,4.1908614 -7.5,4.1908614 L -7.5,-5.8091386 C -4.7400000,-5.8091386 -2.5,-3.5691386 -2.5,-0.80913858 z");
634
        points.translate(7.125493, 0.763446);
635
        arrow.points = points.copy();
636
        appPrefs.arrowStyles.append(arrow);
637
        arrow.name = "SemiCircleOutM";
638
        points.map(arrowScaling);
639
        arrow.points = points.copy();
640
        appPrefs.arrowStyles.append(arrow);
641
        arrow.name = "SemiCircleOutS";
642
        points.map(arrowScaling);
643
        arrow.points = points.copy();
644
        appPrefs.arrowStyles.append(arrow);
645
        points.resize(0);
646
        arrow.name = "Arrow2L";
647
        points.parseSVG("M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z");
12116 fschmid 648
        points.translate(-6.0, -0.016013256);
11176 fschmid 649
        points.map(arrowRotate);
650
        arrow.points = points.copy();
651
        appPrefs.arrowStyles.append(arrow);
652
        arrow.name = "Arrow2M";
653
        points.map(arrowScaling);
654
        arrow.points = points.copy();
655
        appPrefs.arrowStyles.append(arrow);
656
        arrow.name = "Arrow2S";
657
        points.map(arrowScaling);
658
        arrow.points = points.copy();
659
        appPrefs.arrowStyles.append(arrow);
660
        points.resize(0);
661
        arrow.name = "ScissorsL";
662
        points.parseSVG("M 9.0898857,-3.6061018 C 8.1198849,-4.7769976 6.3697607,-4.7358294 5.0623558,-4.2327734 L -3.1500488,-1.1548705 C -5.5383421,-2.4615840 -7.8983361,-2.0874077 -7.8983361,-2.7236578 C -7.8983361,-3.2209742 -7.4416699,-3.1119800 -7.5100293,-4.4068519 C -7.5756648,-5.6501286 -8.8736064,-6.5699315 -10.100428,-6.4884954 C -11.327699,-6.4958500 -12.599867,-5.5553341 -12.610769,-4.2584343 C -12.702194,-2.9520479 -11.603560,-1.7387447 -10.304005,-1.6532027 C -8.7816644,-1.4265411 -6.0857470,-2.3487593 -4.8210600,-0.082342643 C -5.7633447,1.6559151 -7.4350844,1.6607341 -8.9465707,1.5737277 C -10.201445,1.5014928 -11.708664,1.8611256 -12.307219,3.0945882 C -12.885586,4.2766744 -12.318421,5.9591904 -10.990470,6.3210002 C -9.6502788,6.8128279 -7.8098011,6.1912892 -7.4910978,4.6502760 C -7.2454393,3.4624530 -8.0864637,2.9043186 -7.7636052,2.4731223 C -7.5199917,2.1477623 -5.9728246,2.3362771 -3.2164999,1.0982979 L 5.6763468,4.2330688 C 6.8000164,4.5467672 8.1730685,4.5362646 9.1684433,3.4313614 L -0.051640930,-0.053722219 L 9.0898857,-3.6061018 z M -9.2179159,-5.5066058 C -7.9233569,-4.7838060 -8.0290767,-2.8230356 -9.3743431,-2.4433169 C -10.590861,-2.0196559 -12.145370,-3.2022863 -11.757521,-4.5207817 C -11.530373,-5.6026336 -10.104134,-6.0014137 -9.2179159,-5.5066058 z M -9.1616516,2.5107591 C -7.8108215,3.0096239 -8.0402087,5.2951947 -9.4138723,5.6023681 C -10.324932,5.9187072 -11.627422,5.4635705 -11.719569,4.3902287 C -11.897178,3.0851737 -10.363484,1.9060805 -9.1616516,2.5107591 z");
663
        points.map(arrowRotate);
664
        arrow.points = points.copy();
665
        appPrefs.arrowStyles.append(arrow);
666
        arrow.name = "ScissorsM";
667
        points.map(arrowScaling);
668
        arrow.points = points.copy();
669
        appPrefs.arrowStyles.append(arrow);
670
        arrow.name = "ScissorsS";
671
        points.map(arrowScaling);
672
        arrow.points = points.copy();
673
        appPrefs.arrowStyles.append(arrow);
674
        points.resize(0);
675
        arrow.name = "ClubL";
676
        points.parseSVG("M -1.5971367,-7.0977635 C -3.4863874,-7.0977635 -5.0235187,-5.5606321 -5.0235187,-3.6713813 C -5.0235187,-3.0147015 -4.7851656,-2.4444556 -4.4641095,-1.9232271 C -4.5028609,-1.8911157 -4.5437814,-1.8647646 -4.5806531,-1.8299921 C -5.2030765,-2.6849849 -6.1700514,-3.2751330 -7.3077730,-3.2751330 C -9.1970245,-3.2751331 -10.734155,-1.7380016 -10.734155,0.15124914 C -10.734155,2.0404999 -9.1970245,3.5776313 -7.3077730,3.5776313 C -6.3143268,3.5776313 -5.4391540,3.1355702 -4.8137404,2.4588126 C -4.9384274,2.8137041 -5.0235187,3.1803000 -5.0235187,3.5776313 C -5.0235187,5.4668819 -3.4863874,7.0040135 -1.5971367,7.0040135 C 0.29211394,7.0040135 1.8292454,5.4668819 1.8292454,3.5776313 C 1.8292454,2.7842354 1.5136868,2.0838028 1.0600576,1.5031550 C 2.4152718,1.7663868 3.7718375,2.2973711 4.7661444,3.8340272 C 4.0279463,3.0958289 3.5540908,1.7534117 3.5540908,-0.058529361 L 2.9247554,-0.10514681 L 3.5074733,-0.12845553 C 3.5074733,-1.9403966 3.9580199,-3.2828138 4.6962183,-4.0210121 C 3.7371277,-2.5387813 2.4390549,-1.9946496 1.1299838,-1.7134486 C 1.5341802,-2.2753578 1.8292454,-2.9268556 1.8292454,-3.6713813 C 1.8292454,-5.5606319 0.29211394,-7.0977635 -1.5971367,-7.0977635 z");
677
        points.map(arrowRotate);
678
        arrow.points = points.copy();
679
        appPrefs.arrowStyles.append(arrow);
680
        arrow.name = "ClubM";
681
        points.map(arrowScaling);
682
        arrow.points = points.copy();
683
        appPrefs.arrowStyles.append(arrow);
684
        arrow.name = "ClubS";
685
        points.map(arrowScaling);
686
        arrow.points = points.copy();
687
        appPrefs.arrowStyles.append(arrow);
12515 fschmid 688
        arrow.name = "LineL";
689
        points.resize(0);
690
        points.parseSVG("M 0, -5 L 1, -5 L 1, 5 L 0, 5 z");
691
        arrow.points = points.copy();
692
        appPrefs.arrowStyles.append(arrow);
693
        arrow.name = "LineM";
694
        points.map(arrowScaling);
695
        arrow.points = points.copy();
696
        appPrefs.arrowStyles.append(arrow);
697
        arrow.name = "LineS";
698
        points.map(arrowScaling);
699
        arrow.points = points.copy();
700
        appPrefs.arrowStyles.append(arrow);
701
        points.resize(0);
2835 cbradney 702
}
703
 
704
QString PrefsManager::setupPreferencesLocation()
705
{
5917 jghali 706
        QString Pff = QDir::convertSeparators(ScPaths::getApplicationDataDir());
2835 cbradney 707
        QFileInfo Pffi = QFileInfo(Pff);
708
        QString PrefsPfad;
13171 cbradney 709
        //If we are using the ScPaths default prefs location
2835 cbradney 710
        if (Pffi.exists())
711
        {
712
                if (Pffi.isDir())
713
                        PrefsPfad = Pff;
714
                else
10398 cbradney 715
                        PrefsPfad = QDir::homePath();
2835 cbradney 716
        }
13171 cbradney 717
        else // Move to using the ScPaths default prefs location/scribus.* from ~/.scribus.*
2835 cbradney 718
        {
719
                QDir prefsDirectory = QDir();
720
                prefsDirectory.mkdir(Pff);
721
                PrefsPfad = Pff;
10398 cbradney 722
                QString oldPR = QDir::convertSeparators(QDir::homePath()+"/.scribus.rc");
2835 cbradney 723
                QFileInfo oldPi = QFileInfo(oldPR);
724
                if (oldPi.exists())
725
                        moveFile(oldPR, Pff+"/scribus.rc");
10398 cbradney 726
                QString oldPR2 = QDir::convertSeparators(QDir::homePath()+"/.scribusfont.rc");
2835 cbradney 727
                QFileInfo oldPi2 = QFileInfo(oldPR2);
728
                if (oldPi2.exists())
729
                        moveFile(oldPR2, Pff+"/scribusfont.rc");
10398 cbradney 730
                QString oldPR3 = QDir::convertSeparators(QDir::homePath()+"/.scribusscrap.scs");
2835 cbradney 731
                QFileInfo oldPi3 = QFileInfo(oldPR3);
732
                if (oldPi3.exists())
733
                        moveFile(oldPR3, Pff+"/scrap.scs");
734
        }
13608 jghali 735
        QString scP = QDir::convertSeparators(ScPaths::getPluginDataDir());
736
        QFileInfo scPi = QFileInfo(scP);
737
        if (!scPi.exists())
738
        {
739
                QDir pluginDataDirectory = QDir();
740
                pluginDataDirectory.mkdir(scP);
741
        }
4611 fschmid 742
        QString scB = QDir::convertSeparators(Pff+"/scrapbook");
743
        QFileInfo scBi = QFileInfo(scB);
744
        if (!scBi.exists())
745
        {
746
                QDir scrapDirectory = QDir();
747
                scrapDirectory.mkdir(scB);
748
                QDir scrapMainDirectory = QDir();
749
                scrapDirectory.mkdir(QDir::convertSeparators(scB+"/main"));
750
        }
5760 fschmid 751
        QFileInfo scTmp = QFileInfo(QDir::convertSeparators(scB+"/tmp"));
752
        if (!scTmp.exists())
753
        {
754
                QDir scrapDirectoryT = QDir();
755
                scrapDirectoryT.mkdir(QDir::convertSeparators(scB+"/tmp"));
756
        }
2835 cbradney 757
        prefsLocation=PrefsPfad;
15681 fschmid 758
        QFileInfo scSwatch = QFileInfo(ScPaths::getApplicationDataDir()+"swatches");
759
        if (!scSwatch.exists())
760
        {
761
                QDir swatchDir = QDir();
762
                swatchDir.mkpath(ScPaths::getApplicationDataDir()+"swatches");
763
                swatchDir.mkpath(ScPaths::getApplicationDataDir()+"swatches/locked");
764
 
765
        }
2835 cbradney 766
        return PrefsPfad;
767
}
768
 
769
const QString PrefsManager::preferencesLocation()
770
{
771
        return prefsLocation;
772
}
773
 
5200 cbradney 774
bool PrefsManager::copyOldPreferences()
2835 cbradney 775
{
776
        //Now make copies for 1.3 use and leave the old ones alone for <1.3.0 usage
13608 jghali 777
        QString prefs135[4], prefs140[4], prefs150[4];
3152 craig 778
 
8673 cbradney 779
        prefs135[0]=QDir::convertSeparators(prefsLocation+"/scribus135.rc");
780
        prefs135[1]=QDir::convertSeparators(prefsLocation+"/scrap135.scs");
781
        prefs135[2]=QDir::convertSeparators(prefsLocation+"/prefs135.xml");
782
        prefs135[3]=QDir::convertSeparators(prefsLocation+"/scripter135.rc");
13608 jghali 783
        prefs140[0]=QDir::convertSeparators(prefsLocation+"/scribus140.rc");
784
        prefs140[1]=QDir::convertSeparators(prefsLocation+"/scrap140.scs");
785
        prefs140[2]=QDir::convertSeparators(prefsLocation+"/prefs140.xml");
786
        prefs140[3]=QDir::convertSeparators(prefsLocation+"/scripter140.rc");
787
        prefs150[0]=QDir::convertSeparators(prefsLocation+"/scribus150.rc");
788
        prefs150[1]=QDir::convertSeparators(prefsLocation+"/scrap150.scs");
789
        prefs150[2]=QDir::convertSeparators(prefsLocation+"/prefs150.xml");
790
        prefs150[3]=QDir::convertSeparators(prefsLocation+"/scripter150.rc");
2835 cbradney 791
 
13608 jghali 792
        bool existsPrefs135[4], existsPrefs140[4], existsPrefs150[4];
3156 craig 793
        for (uint i=0;i<4;++i)
2835 cbradney 794
        {
8673 cbradney 795
                existsPrefs135[i]=QFile::exists(prefs135[i]);
13608 jghali 796
                existsPrefs140[i]=QFile::exists(prefs140[i]);
797
                existsPrefs150[i]=QFile::exists(prefs150[i]);
2835 cbradney 798
        }
799
 
800
        bool retVal=false;
13608 jghali 801
        if (existsPrefs150[0] && existsPrefs150[2])
5200 cbradney 802
                return retVal;
8673 cbradney 803
        //Only check for these three as they will be autocreated if they dont exist.
13608 jghali 804
        if( (existsPrefs135[0] && !existsPrefs140[0]) || (existsPrefs135[2] && !existsPrefs140[2]) )
2835 cbradney 805
        {
13608 jghali 806
                // Now always return false
807
                // retVal=true; // converting from 1.2 prefs
5243 cbradney 808
                if (ScCore->usingGUI())
2835 cbradney 809
                {
5656 cbradney 810
                        bool splashShown=ScCore->splashShowing();
811
                        if (splashShown)
812
                                ScCore->showSplash(false);
5781 cbradney 813
                        if ( (ScMessageBox::question( ScCore->primaryMainWindow(), tr("Migrate Old Scribus Settings?"),
13608 jghali 814
                                tr("Scribus has detected existing Scribus 1.3.5 preferences files.\n"
2835 cbradney 815
                                                "Do you want to migrate them to the new Scribus version?"),
816
                                QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::NoButton))==QMessageBox::Yes )
817
                        {
818
                                for (uint i=0;i<4;++i)
819
                                {
13608 jghali 820
                                        if (existsPrefs135[i] && !existsPrefs150[i])
821
                                                copyFile(prefs135[i], prefs150[i]);
2835 cbradney 822
                                }
823
                        }
5656 cbradney 824
                        if (splashShown)
825
                                ScCore->showSplash(true);
2835 cbradney 826
                }
827
        }
13608 jghali 828
        else if(existsPrefs140[0])
8673 cbradney 829
        {
830
                for (uint i=0;i<4;++i)
831
                {
13608 jghali 832
                        if (existsPrefs140[i] && !existsPrefs150[i])
833
                                copyFile(prefs140[i], prefs150[i]);
8673 cbradney 834
                }
835
        }
13608 jghali 836
        else if(existsPrefs135[0])
5200 cbradney 837
        {
838
                for (uint i=0;i<4;++i)
839
                {
13608 jghali 840
                        if (existsPrefs135[i] && !existsPrefs150[i])
841
                                copyFile(prefs135[i], prefs150[i]);
5200 cbradney 842
                }
843
        }
2835 cbradney 844
        return retVal;
845
}
846
 
2856 cbradney 847
void PrefsManager::convert12Preferences()
2835 cbradney 848
{
849
        // Import 1.2 font search path prefs
850
        QFile fontPrefsFile12(QDir::convertSeparators(prefsLocation+"/scribusfont.rc"));
8501 cbradney 851
        if (fontPrefsFile12.open(QIODevice::ReadOnly))
2835 cbradney 852
        {
2856 cbradney 853
                PrefsContext *pc = prefsFile->getContext("Fonts");
2835 cbradney 854
                PrefsTable *fontPrefs = pc->getTable("ExtraFontDirs");
10004 fschmid 855
                QTextStream tsx(&fontPrefsFile12);
856
                QString extraPath = tsx.readAll();
2835 cbradney 857
                fontPrefsFile12.close();
10603 fschmid 858
                QStringList extraFonts = extraPath.split("\n", QString::SkipEmptyParts);
8528 cbradney 859
                for (int i = 0; i < extraFonts.count(); ++i)
2835 cbradney 860
                        fontPrefs->set(i, 0, extraFonts[i]);
861
        }
862
}
2859 cbradney 863
 
3873 subik 864
void PrefsManager::ReadPrefs(const QString & fname)
2859 cbradney 865
{
3873 subik 866
        QString realFile;
867
        if (fname.isNull())
13608 jghali 868
                realFile = prefsLocation + "/scribus150.rc";
3873 subik 869
        else
870
                realFile = fname;
871
 
872
        if (QFile::exists(realFile))
873
        {
874
                if (!ReadPref(realFile))
3171 craig 875
                {
876
                        alertLoadPrefsFailed();
877
                        return;
878
                }
3873 subik 879
        }
5243 cbradney 880
}
3873 subik 881
 
5243 cbradney 882
void PrefsManager::setupMainWindow(ScribusMainWindow* mw)
883
{
13955 cbradney 884
        mw->setDefaultPrinter(appPrefs.printerPrefs.PrinterName, appPrefs.printerPrefs.PrinterFile, appPrefs.printerPrefs.PrinterCommand);
2859 cbradney 885
 
13955 cbradney 886
        uint max = qMin(appPrefs.uiPrefs.recentDocCount, appPrefs.uiPrefs.RecentDocs.count());
2859 cbradney 887
        for (uint m = 0; m < max; ++m)
888
        {
13955 cbradney 889
                QFileInfo fd(appPrefs.uiPrefs.RecentDocs[m]);
2859 cbradney 890
                if (fd.exists())
891
                {
13955 cbradney 892
                        mw->RecentDocs.append(appPrefs.uiPrefs.RecentDocs[m]);
893
                        ScCore->fileWatcher->addFile(appPrefs.uiPrefs.RecentDocs[m]);
2859 cbradney 894
                }
895
        }
5243 cbradney 896
        mw->rebuildRecentFileMenu();
13955 cbradney 897
        mw->move(appPrefs.uiPrefs.mainWinSettings.xPosition, appPrefs.uiPrefs.mainWinSettings.yPosition);
898
        mw->resize(appPrefs.uiPrefs.mainWinSettings.width, appPrefs.uiPrefs.mainWinSettings.height);
899
        if (appPrefs.uiPrefs.mainWinSettings.maximized)
10550 avox 900
                mw->setWindowState((ScCore->primaryMainWindow()->windowState() & ~Qt::WindowMinimized) | Qt::WindowMaximized);
13482 cbradney 901
        //For 1.3.5, we dump prefs first time around.
902
        if (!firstTimeIgnoreOldPrefs)
903
                ReadPrefsXML();
14849 cbradney 904
        if (appPrefs.verifierPrefs.checkerPrefsList.count() == 0)
2859 cbradney 905
        {
14849 cbradney 906
                initDefaultCheckerPrefs(&appPrefs.verifierPrefs.checkerPrefsList);
907
                appPrefs.verifierPrefs.curCheckProfile = CommonStrings::PostScript;
2859 cbradney 908
        }
13955 cbradney 909
        if (!appPrefs.uiPrefs.mainWinState.isEmpty())
10256 fschmid 910
        {
13955 cbradney 911
                mw->restoreState(appPrefs.uiPrefs.mainWinState);
10256 fschmid 912
        }
2859 cbradney 913
}
914
 
915
void PrefsManager::ReadPrefsXML()
916
{
10256 fschmid 917
        if (prefsFile)
918
        {
919
                PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
920
                if (userprefsContext)
921
                {
13876 cbradney 922
                        appPrefs.uiPrefs.language = userprefsContext->get("gui_language","");
13955 cbradney 923
                        appPrefs.uiPrefs.mainWinState = QByteArray::fromBase64(userprefsContext->get("mainwinstate","").toAscii());
14043 jghali 924
                        //continue here...
925
                        //Prefs."blah blah" =...
10256 fschmid 926
                }
12104 jghali 927
                if (prefsFile->hasContext("print_options"))
928
                {
929
                        // Reset copies number to 1 when user start new session
930
                        PrefsContext* printOptionsContext = prefsFile->getContext("print_options");
931
                        if (printOptionsContext)
932
                                printOptionsContext->set("Copies", 1);
933
                }
10256 fschmid 934
        }
2859 cbradney 935
}
936
 
937
 
3873 subik 938
void PrefsManager::SavePrefs(const QString & fname)
2859 cbradney 939
{
940
        // If closing because of a crash don't save prefs as we can
941
        // accidentally nuke the settings if the crash is before prefs are loaded
3170 craig 942
        // The caller is responsible for ensuring we aren't called under those
943
        // conditions.
944
        Q_ASSERT(!emergencyActivated);
13955 cbradney 945
        appPrefs.uiPrefs.mainWinSettings.xPosition = abs(ScCore->primaryMainWindow()->pos().x());
946
        appPrefs.uiPrefs.mainWinSettings.yPosition = abs(ScCore->primaryMainWindow()->pos().y());
947
        appPrefs.uiPrefs.mainWinSettings.width = ScCore->primaryMainWindow()->size().width();
948
        appPrefs.uiPrefs.mainWinSettings.height = ScCore->primaryMainWindow()->size().height();
949
        appPrefs.uiPrefs.mainWinSettings.maximized = ScCore->primaryMainWindow()->isMaximized();
950
        appPrefs.uiPrefs.mainWinState = ScCore->primaryMainWindow()->saveState();
951
        appPrefs.uiPrefs.RecentDocs.clear();
13876 cbradney 952
        uint max = qMin(appPrefs.uiPrefs.recentDocCount, ScCore->primaryMainWindow()->RecentDocs.count());
2859 cbradney 953
        for (uint m = 0; m < max; ++m)
954
        {
13955 cbradney 955
                appPrefs.uiPrefs.RecentDocs.append(ScCore->primaryMainWindow()->RecentDocs[m]);
2859 cbradney 956
        }
13955 cbradney 957
        ScCore->primaryMainWindow()->getDefaultPrinter(appPrefs.printerPrefs.PrinterName, appPrefs.printerPrefs.PrinterFile, appPrefs.printerPrefs.PrinterCommand);
3170 craig 958
        SavePrefsXML();
3873 subik 959
        QString realFile;
960
        if (fname.isNull())
13608 jghali 961
                realFile = prefsLocation+"/scribus150.rc";
3873 subik 962
        else
963
                realFile = fname;
964
        if (!WritePref(realFile))
3170 craig 965
                alertSavePrefsFailed();
5257 cbradney 966
        emit prefsChanged();
2859 cbradney 967
}
968
 
969
void PrefsManager::SavePrefsXML()
970
{
10256 fschmid 971
        if (prefsFile)
972
        {
973
                PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
974
                if (userprefsContext)
975
                {
13876 cbradney 976
                        userprefsContext->set("gui_language", appPrefs.uiPrefs.language);
13955 cbradney 977
                        userprefsContext->set("mainwinstate", QString::fromAscii(appPrefs.uiPrefs.mainWinState.toBase64()));
14043 jghali 978
                        //continue here...
979
                        //Prefs."blah blah" =...
10256 fschmid 980
                }
981
                prefsFile->write();
982
        }
2859 cbradney 983
}
2862 cbradney 984
 
985
void PrefsManager::setGhostscriptExecutable(const QString& executableName)
986
{
13955 cbradney 987
        appPrefs.extToolPrefs.gs_exe=executableName;
2862 cbradney 988
}
989
 
990
void PrefsManager::setImageEditorExecutable(const QString& executableName)
991
{
13955 cbradney 992
        appPrefs.extToolPrefs.imageEditorExecutable=executableName;
2862 cbradney 993
}
994
 
5418 cbradney 995
void PrefsManager::setExtBrowserExecutable(const QString& executableName)
2862 cbradney 996
{
13955 cbradney 997
        appPrefs.extToolPrefs.extBrowserExecutable=executableName;
2862 cbradney 998
}
999
 
13957 herm 1000
void PrefsManager::setUniconvExecutable(const QString& executableName)
1001
{
1002
        appPrefs.extToolPrefs.uniconvExecutable=executableName;
1003
}
1004
 
11506 mrdocs 1005
void PrefsManager::setLatexConfigs(const QStringList& configs)
10228 avox 1006
{
13955 cbradney 1007
        appPrefs.extToolPrefs.latexConfigs=configs;
10228 avox 1008
}
1009
 
15411 craig 1010
void PrefsManager::setLatexCommands(const QMap<QString, QString>& commands)
1011
{
1012
        appPrefs.extToolPrefs.latexCommands=commands;
1013
}
1014
 
15434 craig 1015
bool PrefsManager::renderFrameConfigured()
1016
{
1017
        if (appPrefs.extToolPrefs.latexConfigs.isEmpty())
1018
                return false;
1019
        if (appPrefs.extToolPrefs.latexCommands.isEmpty())
1020
                return false;
1021
        bool foundAny=false;
1022
        foreach (QString cmd, appPrefs.extToolPrefs.latexCommands)
15439 craig 1023
        {
15434 craig 1024
                if (fileInPath(cmd))
1025
                        foundAny=true;
15439 craig 1026
        }
15434 craig 1027
        return foundAny;
1028
}
15411 craig 1029
 
15434 craig 1030
 
10228 avox 1031
void PrefsManager::setLatexEditorExecutable(const QString& executableName)
1032
{
13955 cbradney 1033
        appPrefs.extToolPrefs.latexEditorExecutable=executableName;
10228 avox 1034
}
1035
 
2871 cbradney 1036
const QString PrefsManager::documentDir()
1037
{
13876 cbradney 1038
        return appPrefs.pathPrefs.documents;
2871 cbradney 1039
}
1040
 
3931 subik 1041
void PrefsManager::setDocumentDir(const QString& dirname)
1042
{
13876 cbradney 1043
        appPrefs.pathPrefs.documents = dirname;
3931 subik 1044
}
1045
 
13870 cbradney 1046
int PrefsManager::mouseWheelJump() const
2871 cbradney 1047
{
13876 cbradney 1048
        return appPrefs.uiPrefs.wheelJump;
2871 cbradney 1049
}
1050
 
2870 cbradney 1051
//Changed to return false when we have no fonts
6700 cbradney 1052
bool PrefsManager::GetAllFonts(bool showFontInfo)
2870 cbradney 1053
{
13955 cbradney 1054
        appPrefs.fontPrefs.AvailFonts.GetFonts(prefsLocation, showFontInfo);
1055
        return !appPrefs.fontPrefs.AvailFonts.isEmpty();
2870 cbradney 1056
}
2871 cbradney 1057
 
1058
void PrefsManager::setShowStartupDialog(const bool showDialog)
1059
{
13876 cbradney 1060
        appPrefs.uiPrefs.showStartupDialog=showDialog;
2871 cbradney 1061
}
1062
 
1063
const ColorList& PrefsManager::colorSet()
1064
{
13967 cbradney 1065
        return appPrefs.colorPrefs.DColors;
2871 cbradney 1066
}
1067
 
1068
ColorList* PrefsManager::colorSetPtr()
1069
{
13967 cbradney 1070
        return &appPrefs.colorPrefs.DColors;
2871 cbradney 1071
}
1072
 
1073
const QString& PrefsManager::colorSetName()
1074
{
13967 cbradney 1075
        return appPrefs.colorPrefs.DColorSet;
2871 cbradney 1076
}
1077
 
7718 jghali 1078
bool PrefsManager::isToolColor(const QString& name)
1079
{
13953 cbradney 1080
        return isToolColor(appPrefs.itemToolPrefs, name);
7718 jghali 1081
}
1082
 
13953 cbradney 1083
bool PrefsManager::isToolColor(const struct ItemToolPrefs& settings, const QString& name)
7718 jghali 1084
{
15847 fschmid 1085
        if (settings.calligrapicPenLineColor == name)
1086
                return true;
1087
        if (settings.calligrapicPenFillColor == name)
1088
                return true;
13996 cbradney 1089
        if (settings.textColor == name)
7718 jghali 1090
                return true;
13996 cbradney 1091
        if (settings.textStrokeColor == name)
7718 jghali 1092
                return true;
14014 cbradney 1093
        if (settings.textFillColor == name)
7718 jghali 1094
                return true;
13996 cbradney 1095
        if (settings.textLineColor == name)
7718 jghali 1096
                return true;
14014 cbradney 1097
        if (settings.shapeLineColor == name)
7718 jghali 1098
                return true;
14014 cbradney 1099
        if (settings.shapeFillColor == name)
7718 jghali 1100
                return true;
13996 cbradney 1101
        if (settings.lineColor == name)
7718 jghali 1102
                return true;
13996 cbradney 1103
        if (settings.imageFillColor == name)
7718 jghali 1104
                return true;
1105
        return false;
1106
}
1107
 
1108
QStringList PrefsManager::toolColorNames()
1109
{
13953 cbradney 1110
        return toolColorNames(appPrefs.itemToolPrefs);
7718 jghali 1111
}
1112
 
13953 cbradney 1113
QStringList PrefsManager::toolColorNames(const struct ItemToolPrefs& settings)
7718 jghali 1114
{
1115
        QStringList names;
13996 cbradney 1116
        names.append(settings.textColor);
1117
        if (!names.contains(settings.textStrokeColor))
1118
                names.append(settings.textStrokeColor);
14014 cbradney 1119
        if (!names.contains(settings.textFillColor))
1120
                names.append(settings.textFillColor);
13996 cbradney 1121
        if (!names.contains(settings.textLineColor))
1122
                names.append(settings.textLineColor);
14014 cbradney 1123
        if (!names.contains(settings.shapeLineColor))
1124
                names.append(settings.shapeLineColor);
1125
        if (!names.contains(settings.shapeFillColor))
1126
                names.append(settings.shapeFillColor);
13996 cbradney 1127
        if (!names.contains(settings.lineColor))
1128
                names.append(settings.lineColor);
1129
        if (!names.contains(settings.imageFillColor))
1130
                names.append(settings.imageFillColor);
15847 fschmid 1131
        if (!names.contains(settings.calligrapicPenFillColor))
1132
                names.append(settings.calligrapicPenFillColor);
1133
        if (!names.contains(settings.calligrapicPenLineColor))
1134
                names.append(settings.calligrapicPenLineColor);
7718 jghali 1135
        return names;
1136
}
1137
 
1138
void PrefsManager::replaceToolColors(const QMap<QString, QString> replaceMap)
1139
{
13953 cbradney 1140
        replaceToolColors(appPrefs.itemToolPrefs, replaceMap);
7718 jghali 1141
}
1142
 
13953 cbradney 1143
void PrefsManager::replaceToolColors(struct ItemToolPrefs& settings, const QMap<QString, QString> replaceMap)
7718 jghali 1144
{
13996 cbradney 1145
        if (replaceMap.contains(settings.textColor))
1146
                settings.textColor = replaceMap[settings.textColor];
1147
        if (replaceMap.contains(settings.textStrokeColor))
1148
                settings.textStrokeColor = replaceMap[settings.textStrokeColor];
14014 cbradney 1149
        if (replaceMap.contains(settings.textFillColor))
1150
                settings.textFillColor = replaceMap[settings.textFillColor];
13996 cbradney 1151
        if (replaceMap.contains(settings.textLineColor))
1152
                settings.textLineColor = replaceMap[settings.textLineColor];
14014 cbradney 1153
        if (replaceMap.contains(settings.shapeLineColor))
1154
                settings.shapeLineColor = replaceMap[settings.shapeLineColor];
1155
        if (replaceMap.contains(settings.shapeFillColor))
1156
                settings.shapeFillColor = replaceMap[settings.shapeFillColor];
13996 cbradney 1157
        if (replaceMap.contains(settings.lineColor))
1158
                settings.lineColor = replaceMap[settings.lineColor];
1159
        if (replaceMap.contains(settings.imageFillColor))
1160
                settings.imageFillColor = replaceMap[settings.imageFillColor];
15847 fschmid 1161
        if (replaceMap.contains(settings.calligrapicPenFillColor))
1162
                settings.calligrapicPenFillColor = replaceMap[settings.calligrapicPenFillColor];
1163
        if (replaceMap.contains(settings.calligrapicPenLineColor))
1164
                settings.calligrapicPenLineColor = replaceMap[settings.calligrapicPenLineColor];
7718 jghali 1165
}
1166
 
2871 cbradney 1167
void PrefsManager::setColorSet(const ColorList& colorSet)
1168
{
7718 jghali 1169
        // Color set may have changed and tools color not be present in the new color set
1170
        ColorList tmpSet = colorSet;
13996 cbradney 1171
        QString penText = appPrefs.itemToolPrefs.textColor;
7718 jghali 1172
        if (!tmpSet.contains(penText) && penText != CommonStrings::None)
13967 cbradney 1173
                tmpSet[penText] = appPrefs.colorPrefs.DColors[penText];
13996 cbradney 1174
        QString strokeText = appPrefs.itemToolPrefs.textStrokeColor;
7718 jghali 1175
        if (!tmpSet.contains(strokeText) && strokeText != CommonStrings::None)
13967 cbradney 1176
                tmpSet[strokeText] = appPrefs.colorPrefs.DColors[strokeText];
14014 cbradney 1177
        QString textFillColor = appPrefs.itemToolPrefs.textFillColor;
1178
        if (!tmpSet.contains(textFillColor) && textFillColor != CommonStrings::None)
1179
                tmpSet[textFillColor] = appPrefs.colorPrefs.DColors[textFillColor];
13996 cbradney 1180
        QString textLineColor = appPrefs.itemToolPrefs.textLineColor;
7718 jghali 1181
        if (!tmpSet.contains(textLineColor) && textLineColor != CommonStrings::None)
13967 cbradney 1182
                tmpSet[textLineColor] = appPrefs.colorPrefs.DColors[textLineColor];
14014 cbradney 1183
        QString pen = appPrefs.itemToolPrefs.shapeLineColor;
7718 jghali 1184
        if (!tmpSet.contains(pen) && pen != CommonStrings::None)
13967 cbradney 1185
                tmpSet[pen] = appPrefs.colorPrefs.DColors[pen];
14014 cbradney 1186
        QString brush = appPrefs.itemToolPrefs.shapeFillColor;
7718 jghali 1187
        if (!tmpSet.contains(brush) && brush != CommonStrings::None)
13967 cbradney 1188
                tmpSet[brush] = appPrefs.colorPrefs.DColors[brush];
13996 cbradney 1189
        QString penLine = appPrefs.itemToolPrefs.lineColor;
7718 jghali 1190
        if (!tmpSet.contains(penLine) && penLine != CommonStrings::None)
13967 cbradney 1191
                tmpSet[penLine] = appPrefs.colorPrefs.DColors[penLine];
13996 cbradney 1192
        QString brushPict = appPrefs.itemToolPrefs.imageFillColor;
7718 jghali 1193
        if (!tmpSet.contains(brushPict) && brushPict != CommonStrings::None)
13967 cbradney 1194
                tmpSet[brushPict] = appPrefs.colorPrefs.DColors[brushPict];
15847 fschmid 1195
        QString brushCpen = appPrefs.itemToolPrefs.calligrapicPenFillColor;
1196
        if (!tmpSet.contains(brushCpen) && brushCpen != CommonStrings::None)
1197
                tmpSet[brushCpen] = appPrefs.colorPrefs.DColors[brushCpen];
1198
        QString brushCpen2 = appPrefs.itemToolPrefs.calligrapicPenLineColor;
1199
        if (!tmpSet.contains(brushCpen2) && brushCpen2 != CommonStrings::None)
1200
                tmpSet[brushCpen2] = appPrefs.colorPrefs.DColors[brushCpen2];
13967 cbradney 1201
        appPrefs.colorPrefs.DColors = tmpSet;
2871 cbradney 1202
}
1203
 
1204
void PrefsManager::setColorSetName(const QString& colorSetName)
1205
{
13967 cbradney 1206
        appPrefs.colorPrefs.DColorSet=colorSetName;
2871 cbradney 1207
}
2873 cbradney 1208
 
1209
 
3932 avox 1210
void PrefsManager::setKeyEntry(const QString& actName, const QString& cleanMenuText, const QKeySequence& keyseq, const int& rowNumber)
2873 cbradney 1211
{
1212
        Keys ke;
2877 cbradney 1213
        if (!actName.isEmpty())
2873 cbradney 1214
        {
5781 cbradney 1215
                if (ScCore->primaryMainWindow()->scrActions[actName])
2873 cbradney 1216
                {
1217
                        ke.actionName=actName;
1218
                        ke.keySequence = keyseq;
1219
                        ke.cleanMenuText=cleanMenuText;
1220
                        ke.tableRow=rowNumber;
13955 cbradney 1221
                        appPrefs.keyShortcutPrefs.KeyActions.insert(actName, ke);
2873 cbradney 1222
                }
1223
                else
10553 fschmid 1224
                        qDebug("%s", QString("Action Name: %1 does not exist").arg(actName).toAscii().constData());
2873 cbradney 1225
        }
1226
}
1227
 
10509 cbradney 1228
double PrefsManager::displayScale() const
2873 cbradney 1229
{
13974 cbradney 1230
        return appPrefs.displayPrefs.displayScale;
2873 cbradney 1231
}
1232
 
13870 cbradney 1233
const QString& PrefsManager::uiLanguage() const
2873 cbradney 1234
{
13876 cbradney 1235
        return appPrefs.uiPrefs.language;
2873 cbradney 1236
}
1237
 
10390 cbradney 1238
const QString& PrefsManager::guiStyle() const
2873 cbradney 1239
{
13876 cbradney 1240
        return appPrefs.uiPrefs.style;
2873 cbradney 1241
}
1242
 
11115 subik 1243
const QString& PrefsManager::guiSystemStyle() const
1244
{
13870 cbradney 1245
        return appPrefs.ui_SystemTheme;
11115 subik 1246
}
1247
 
10390 cbradney 1248
const int& PrefsManager::guiFontSize() const
2873 cbradney 1249
{
13876 cbradney 1250
        return appPrefs.uiPrefs.applicationFontSize;
2873 cbradney 1251
}
2889 cbradney 1252
 
10390 cbradney 1253
const int& PrefsManager::paletteFontSize() const
3940 tsoots 1254
{
13876 cbradney 1255
        return appPrefs.uiPrefs.paletteFontSize;
3940 tsoots 1256
}
1257
 
12476 cbradney 1258
bool PrefsManager::showPageShadow() const
1259
{
13955 cbradney 1260
        return appPrefs.displayPrefs.showPageShadow;
12476 cbradney 1261
}
1262
 
3170 craig 1263
bool PrefsManager::WritePref(QString ho)
2889 cbradney 1264
{
1265
        QDomDocument docu("scribusrc");
1266
        QString st="<SCRIBUSRC></SCRIBUSRC>";
1267
        docu.setContent(st);
1268
        QDomElement elem=docu.documentElement();
15124 cbradney 1269
        elem.setAttribute("VERSION","1.5.0");
1270
 
1271
 
1272
        QDomElement dcUI=docu.createElement("UI");
1273
        dcUI.setAttribute("PagePaletteShowThumbs", static_cast<int>(appPrefs.uiPrefs.SepalT));
1274
        dcUI.setAttribute("PagePaletteShowNames", static_cast<int>(appPrefs.uiPrefs.SepalN));
1275
        dcUI.setAttribute("ShowStartupDialog", static_cast<int>(appPrefs.uiPrefs.showStartupDialog));
1276
        dcUI.setAttribute("ShowSplashOnStartup", static_cast<int>(appPrefs.uiPrefs.showSplashOnStartup));
1277
        dcUI.setAttribute("UseSmallWidgets", static_cast<int>(appPrefs.uiPrefs.useSmallWidgets));
1278
        dcUI.setAttribute("UseDocumentTabs", static_cast<int>(appPrefs.uiPrefs.useTabs));
1279
        dcUI.setAttribute("StickyTools", static_cast<int>(appPrefs.uiPrefs.stickyTools));
1280
        dcUI.setAttribute("Theme", appPrefs.uiPrefs.style);
1281
        dcUI.setAttribute("ScrollWheelJump", appPrefs.uiPrefs.wheelJump);
1282
        dcUI.setAttribute("MouseMoveTimeout", appPrefs.uiPrefs.mouseMoveTimeout);
1283
        dcUI.setAttribute("ApplicationFontSize", appPrefs.uiPrefs.applicationFontSize);
1284
        dcUI.setAttribute("PaletteFontSize", appPrefs.uiPrefs.paletteFontSize);
1285
        dcUI.setAttribute("RecentDocumentCount", appPrefs.uiPrefs.recentDocCount);
15461 craig 1286
        dcUI.setAttribute("UseGrayscaleIcons", appPrefs.uiPrefs.grayscaleIcons);
15124 cbradney 1287
        elem.appendChild(dcUI);
1288
 
1289
        QDomElement deDocumentSetup=docu.createElement("DocumentSetup");
1290
        deDocumentSetup.setAttribute("UnitIndex",appPrefs.docSetupPrefs.docUnitIndex);
1291
        deDocumentSetup.setAttribute("PageSize",appPrefs.docSetupPrefs.pageSize);
1292
        deDocumentSetup.setAttribute("PageOrientation",appPrefs.docSetupPrefs.pageOrientation);
1293
        deDocumentSetup.setAttribute("PageWidth",ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageWidth));
1294
        deDocumentSetup.setAttribute("PageHeight",ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageHeight));
1295
        deDocumentSetup.setAttribute("MarginTop",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.Top));
1296
        deDocumentSetup.setAttribute("MarginBottom",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.Bottom));
1297
        deDocumentSetup.setAttribute("MarginLeft",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.Left));
1298
        deDocumentSetup.setAttribute("MarginRight",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.Right));
1299
        deDocumentSetup.setAttribute("MarginPreset",appPrefs.docSetupPrefs.marginPreset);
1300
        deDocumentSetup.setAttribute("PagePositioning", appPrefs.docSetupPrefs.pagePositioning);
1301
        deDocumentSetup.setAttribute("AutoSave", static_cast<int>(appPrefs.docSetupPrefs.AutoSave));
1302
        deDocumentSetup.setAttribute("AutoSaveTime", appPrefs.docSetupPrefs.AutoSaveTime);
1303
        deDocumentSetup.setAttribute("SaveCompressed", static_cast<int>(appPrefs.docSetupPrefs.saveCompressed));
1304
        deDocumentSetup.setAttribute("BleedTop", ScCLocale::toQStringC(appPrefs.docSetupPrefs.bleeds.Top));
1305
        deDocumentSetup.setAttribute("BleedLeft", ScCLocale::toQStringC(appPrefs.docSetupPrefs.bleeds.Left));
1306
        deDocumentSetup.setAttribute("BleedRight", ScCLocale::toQStringC(appPrefs.docSetupPrefs.bleeds.Right));
1307
        deDocumentSetup.setAttribute("BleedBottom", ScCLocale::toQStringC(appPrefs.docSetupPrefs.bleeds.Bottom));
1308
        elem.appendChild(deDocumentSetup);
1309
 
1310
        QDomElement dePaths=docu.createElement("Paths");
1311
        dePaths.setAttribute("Documents", appPrefs.pathPrefs.documents);
1312
        dePaths.setAttribute("Profiles", appPrefs.pathPrefs.colorProfiles);
1313
        dePaths.setAttribute("Scripts", appPrefs.pathPrefs.scripts);
1314
        dePaths.setAttribute("Templates", appPrefs.pathPrefs.documentTemplates);
1315
        elem.appendChild(dePaths);
1316
 
1317
        QDomElement deGuides=docu.createElement("Guides");
1318
        deGuides.setAttribute("GrabRadius",appPrefs.guidesPrefs.grabRadius);
1319
        deGuides.setAttribute("ShowGuides", static_cast<int>(appPrefs.guidesPrefs.guidesShown));
1320
        deGuides.setAttribute("ShowColumnBorders", static_cast<int>(appPrefs.guidesPrefs.colBordersShown));
1321
        deGuides.setAttribute("ShowFrames", static_cast<int>(appPrefs.guidesPrefs.framesShown));
1322
        deGuides.setAttribute("ShowLayerMarkers", static_cast<int>(appPrefs.guidesPrefs.layerMarkersShown));
1323
        deGuides.setAttribute("ShowMargins", static_cast<int>(appPrefs.guidesPrefs.marginsShown));
1324
        deGuides.setAttribute("ShowBaselineGrid", static_cast<int>(appPrefs.guidesPrefs.baselineGridShown));
1325
        deGuides.setAttribute("ShowLinks", static_cast<int>(appPrefs.guidesPrefs.linkShown));
1326
        deGuides.setAttribute("ShowImages", static_cast<int>(appPrefs.guidesPrefs.showPic));
1327
        deGuides.setAttribute("ShowControls", static_cast<int>(appPrefs.guidesPrefs.showControls));
1328
        deGuides.setAttribute("ShowRulers", static_cast<int>(appPrefs.guidesPrefs.rulersShown));
1329
        deGuides.setAttribute("ShowBleed", static_cast<int>(appPrefs.guidesPrefs.showBleed));
1330
        deGuides.setAttribute("RulerMode", static_cast<int>(appPrefs.guidesPrefs.rulerMode));
1331
        deGuides.setAttribute("MinorGridSpacing",ScCLocale::toQStringC(appPrefs.guidesPrefs.minorGridSpacing));
1332
        deGuides.setAttribute("MajorGridSpacing",ScCLocale::toQStringC(appPrefs.guidesPrefs.majorGridSpacing));
1333
        deGuides.setAttribute("MinorGridColor",appPrefs.guidesPrefs.minorGridColor.name());
1334
        deGuides.setAttribute("MajorGridColor",appPrefs.guidesPrefs.majorGridColor.name());
1335
        deGuides.setAttribute("GuidesColor", appPrefs.guidesPrefs.guideColor.name());
1336
        deGuides.setAttribute("MarginColor",appPrefs.guidesPrefs.marginColor.name());
1337
        deGuides.setAttribute("BaselineGridColor", appPrefs.guidesPrefs.baselineGridColor.name());
1338
        deGuides.setAttribute("ObjectToGuideSnapRadius", ScCLocale::toQStringC(appPrefs.guidesPrefs.guideRad));
1339
        deGuides.setAttribute("GuidePlacement", static_cast<int>(appPrefs.guidesPrefs.guidePlacement));
1340
        deGuides.setAttribute("ShowGrid", static_cast<int>(appPrefs.guidesPrefs.gridShown));
1341
        deGuides.setAttribute("BaselineGridDistance", ScCLocale::toQStringC(appPrefs.guidesPrefs.valueBaselineGrid));
1342
        deGuides.setAttribute("BaselineGridOffset", ScCLocale::toQStringC(appPrefs.guidesPrefs.offsetBaselineGrid));
1343
        elem.appendChild(deGuides);
1344
 
1345
        QDomElement deMiscellaneous=docu.createElement("Miscellaneous");
1346
        deMiscellaneous.setAttribute("ShowStylePreview", static_cast<int>(appPrefs.miscPrefs.haveStylePreview));
1347
        deMiscellaneous.setAttribute("LoremIpsumUseStandard", static_cast<int>(appPrefs.miscPrefs.useStandardLI));
1348
        deMiscellaneous.setAttribute("LoremIpsumParagraphs", appPrefs.miscPrefs.paragraphsLI);
1349
        elem.appendChild(deMiscellaneous);
1350
 
1351
 
1352
 
14823 cbradney 1353
        QDomElement deSE=docu.createElement("StoryEditor");
1354
        deSE.setAttribute("Font",appPrefs.storyEditorPrefs.guiFont);
1355
        deSE.setAttribute("FontColorBackground",appPrefs.storyEditorPrefs.guiFontColorBackground.name());
1356
        deSE.setAttribute("SmartTextSelection",static_cast<int>(appPrefs.storyEditorPrefs.smartTextSelection));
1357
        elem.appendChild(deSE);
14811 cbradney 1358
 
15124 cbradney 1359
        QDomElement deDisplay=docu.createElement("Display");
1360
        deDisplay.setAttribute("ScratchBottom", appPrefs.displayPrefs.scratch.Bottom);
1361
        deDisplay.setAttribute("ScratchLeft", appPrefs.displayPrefs.scratch.Left);
1362
        deDisplay.setAttribute("ScratchRight", appPrefs.displayPrefs.scratch.Right);
1363
        deDisplay.setAttribute("ScratchTop", appPrefs.displayPrefs.scratch.Top);
1364
        deDisplay.setAttribute("PageGapHorizontal", ScCLocale::toQStringC(appPrefs.displayPrefs.pageGapHorizontal));
1365
        deDisplay.setAttribute("PageGapVertical", ScCLocale::toQStringC(appPrefs.displayPrefs.pageGapVertical));
1366
        deDisplay.setAttribute("ShowPageShadow",static_cast<int>(appPrefs.displayPrefs.showPageShadow));
1367
        deDisplay.setAttribute("PageColor",appPrefs.displayPrefs.paperColor.name());
15139 cbradney 1368
        deDisplay.setAttribute("ScratchColor",appPrefs.displayPrefs.scratchColor.name());
15124 cbradney 1369
        deDisplay.setAttribute("FrameSelectedColor",appPrefs.displayPrefs.frameColor.name());
1370
        deDisplay.setAttribute("FrameNormColor",appPrefs.displayPrefs.frameNormColor.name());
1371
        deDisplay.setAttribute("FrameGroupColor",appPrefs.displayPrefs.frameGroupColor.name());
1372
        deDisplay.setAttribute("FrameLockColor",appPrefs.displayPrefs.frameLockColor.name());
1373
        deDisplay.setAttribute("FrameLinkColor",appPrefs.displayPrefs.frameLinkColor.name());
1374
        deDisplay.setAttribute("FrameAnnotationColor",appPrefs.displayPrefs.frameAnnotationColor.name());
1375
        deDisplay.setAttribute("PageBorderColor",appPrefs.displayPrefs.pageBorderColor.name());
1376
        deDisplay.setAttribute("ControlCharColor",appPrefs.displayPrefs.controlCharColor.name());
1377
        deDisplay.setAttribute("ShowMarginsFilled", static_cast<int>(appPrefs.displayPrefs.marginColored));
15179 jghali 1378
        deDisplay.setAttribute("DisplayScale", ScCLocale::toQStringC(appPrefs.displayPrefs.displayScale, 8));
15124 cbradney 1379
        deDisplay.setAttribute("ShowVerifierWarningsOnCanvas",static_cast<int>(appPrefs.displayPrefs.showVerifierWarningsOnCanvas));
1380
        deDisplay.setAttribute("ToolTips", static_cast<int>(appPrefs.displayPrefs.showToolTips));
1381
        deDisplay.setAttribute("ShowMouseCoordinates", static_cast<int>(appPrefs.displayPrefs.showMouseCoordinates));
1382
        elem.appendChild(deDisplay);
1383
 
1384
        // Font information must be written before Fonts element so that face "usable"
14312 jghali 1385
        // member is set properly before one try to set default font. Allows to check
1386
        // that default font is indeed usable, problems expected otherwise
1387
        for ( SCFontsIterator itf(appPrefs.fontPrefs.AvailFonts); itf.hasNext(); itf.next())
1388
        {
1389
                if (!itf.currentKey().isEmpty())
1390
                {
15124 cbradney 1391
                        QDomElement fn=docu.createElement("Font");
1392
                        fn.setAttribute("Name",itf.currentKey());
1393
                        fn.setAttribute("Embed",static_cast<int>(itf.current().embedPs()));
1394
                        fn.setAttribute("Use", static_cast<int>(itf.current().usable()));
1395
                        fn.setAttribute("Subset", static_cast<int>(itf.current().subset()));
14312 jghali 1396
                        elem.appendChild(fn);
1397
                }
1398
        }
1399
        QMap<QString,QString>::Iterator itfsu;
1400
        for (itfsu = appPrefs.fontPrefs.GFontSub.begin(); itfsu != appPrefs.fontPrefs.GFontSub.end(); ++itfsu)
1401
        {
1402
                QDomElement fosu = docu.createElement("Substitute");
1403
                fosu.setAttribute("Name",itfsu.key());
1404
                fosu.setAttribute("Replace",itfsu.value());
1405
                elem.appendChild(fosu);
1406
        }
15124 cbradney 1407
 
1408
        QDomElement dcFonts=docu.createElement("Fonts");
1409
        dcFonts.setAttribute("AutomaticSubstitution", static_cast<int>(appPrefs.fontPrefs.askBeforeSubstitute));
1410
        elem.appendChild(dcFonts);
1411
 
1412
        QDomElement dcTypography=docu.createElement("Typography");
1413
        dcTypography.setAttribute("SubScriptDistance",appPrefs.typoPrefs.valueSubScript);
1414
        dcTypography.setAttribute("SubScriptScaling",appPrefs.typoPrefs.scalingSubScript);
1415
        dcTypography.setAttribute("SuperScriptDistance",appPrefs.typoPrefs.valueSuperScript);
1416
        dcTypography.setAttribute("SuperScriptScaling",appPrefs.typoPrefs.scalingSuperScript);
1417
        dcTypography.setAttribute("SmallCapsScaling",appPrefs.typoPrefs.valueSmallCaps);
1418
        dcTypography.setAttribute("AutomaticLineSpacing", appPrefs.typoPrefs.autoLineSpacing);
13953 cbradney 1419
        if (appPrefs.typoPrefs.valueUnderlinePos == -1)
15124 cbradney 1420
                dcTypography.setAttribute("UnderlineDistance", appPrefs.typoPrefs.valueUnderlinePos);
2889 cbradney 1421
        else
15124 cbradney 1422
                dcTypography.setAttribute("UnderlineDistance", appPrefs.typoPrefs.valueUnderlinePos / 10.0);
13953 cbradney 1423
        if (appPrefs.typoPrefs.valueUnderlineWidth == -1)
15124 cbradney 1424
                dcTypography.setAttribute("UnderlineWidth", appPrefs.typoPrefs.valueUnderlineWidth);
2889 cbradney 1425
        else
15124 cbradney 1426
                dcTypography.setAttribute("UnderlineWidth", appPrefs.typoPrefs.valueUnderlineWidth / 10.0);
13953 cbradney 1427
        if (appPrefs.typoPrefs.valueStrikeThruPos == -1)
15124 cbradney 1428
                dcTypography.setAttribute("StrikeThruDistance", appPrefs.typoPrefs.valueStrikeThruPos);
2889 cbradney 1429
        else
15124 cbradney 1430
                dcTypography.setAttribute("StrikeThruDistance", appPrefs.typoPrefs.valueStrikeThruPos / 10.0);
13953 cbradney 1431
        if (appPrefs.typoPrefs.valueStrikeThruWidth == -1)
15124 cbradney 1432
                dcTypography.setAttribute("StrikeThruWidth", appPrefs.typoPrefs.valueStrikeThruWidth);
2889 cbradney 1433
        else
15124 cbradney 1434
                dcTypography.setAttribute("StrikeThruWidth", appPrefs.typoPrefs.valueStrikeThruWidth / 10.0);
1435
        elem.appendChild(dcTypography);
1436
 
1437
        QDomElement dcItemTools=docu.createElement("ItemTools");
1438
        dcItemTools.setAttribute("ShapeLineColor",appPrefs.itemToolPrefs.shapeLineColor);
1439
        dcItemTools.setAttribute("ShapeFillColor",appPrefs.itemToolPrefs.shapeFillColor);
1440
        dcItemTools.setAttribute("LineColor",appPrefs.itemToolPrefs.lineColor);
1441
        dcItemTools.setAttribute("TextColor",appPrefs.itemToolPrefs.textColor);
1442
        dcItemTools.setAttribute("TextStrokeColor",appPrefs.itemToolPrefs.textStrokeColor);
1443
        dcItemTools.setAttribute("TextBackgroundColor", appPrefs.itemToolPrefs.textFillColor);
1444
        dcItemTools.setAttribute("TextLineColor", appPrefs.itemToolPrefs.textLineColor);
1445
        dcItemTools.setAttribute("TextBackgroundColorShade", appPrefs.itemToolPrefs.textFillColorShade);
1446
        dcItemTools.setAttribute("TextLineColorShade", appPrefs.itemToolPrefs.textLineColorShade);
1447
        dcItemTools.setAttribute("TextColorShade", appPrefs.itemToolPrefs.textShade);
1448
        dcItemTools.setAttribute("TextStrokeColorShade", appPrefs.itemToolPrefs.textStrokeShade);
1449
        dcItemTools.setAttribute("TextColumnCount",appPrefs.itemToolPrefs.textColumns);
1450
        dcItemTools.setAttribute("TextColumnGap",ScCLocale::toQStringC(appPrefs.itemToolPrefs.textColumnGap));
1451
        dcItemTools.setAttribute("TextTabWidth",ScCLocale::toQStringC(appPrefs.itemToolPrefs.textTabWidth));
15138 cbradney 1452
        dcItemTools.setAttribute("TextDistanceTop",ScCLocale::toQStringC(appPrefs.itemToolPrefs.textDistances.Top));
1453
        dcItemTools.setAttribute("TextDistanceBottom",ScCLocale::toQStringC(appPrefs.itemToolPrefs.textDistances.Bottom));
1454
        dcItemTools.setAttribute("TextDistanceLeft",ScCLocale::toQStringC(appPrefs.itemToolPrefs.textDistances.Left));
1455
        dcItemTools.setAttribute("TextDistanceRight",ScCLocale::toQStringC(appPrefs.itemToolPrefs.textDistances.Right));
15124 cbradney 1456
        dcItemTools.setAttribute("TabFillCharacter",appPrefs.itemToolPrefs.textTabFillChar);
1457
        dcItemTools.setAttribute("ShapeLineStyle",appPrefs.itemToolPrefs.shapeLineStyle);
1458
        dcItemTools.setAttribute("LineStyle",appPrefs.itemToolPrefs.lineStyle);
1459
        dcItemTools.setAttribute("ShapeLineWidth",ScCLocale::toQStringC(appPrefs.itemToolPrefs.shapeLineWidth));
1460
        dcItemTools.setAttribute("LineWidth",ScCLocale::toQStringC(appPrefs.itemToolPrefs.lineWidth));
1461
        dcItemTools.setAttribute("ShapeLineColorShade",appPrefs.itemToolPrefs.shapeLineColorShade);
1462
        dcItemTools.setAttribute("LineColorShade",appPrefs.itemToolPrefs.lineColorShade);
1463
        dcItemTools.setAttribute("ShapeFillColorShade",appPrefs.itemToolPrefs.shapeFillColorShade);
1464
        dcItemTools.setAttribute("ImageFillColor",appPrefs.itemToolPrefs.imageFillColor);
1465
        dcItemTools.setAttribute("ImageFillColorShade",appPrefs.itemToolPrefs.imageFillColorShade);
1466
        dcItemTools.setAttribute("ImageScaleX",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleX));
1467
        dcItemTools.setAttribute("ImageScaleY",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleY));
1468
        dcItemTools.setAttribute("PolygonCorners", appPrefs.itemToolPrefs.polyCorners);
1469
        dcItemTools.setAttribute("PolygonFactor", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyFactor));
1470
        dcItemTools.setAttribute("PolygonRotation", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyRotation));
16191 fschmid 1471
        dcItemTools.setAttribute("PolygonInnerRotation", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyInnerRot));
15124 cbradney 1472
        dcItemTools.setAttribute("PolygonFactorGUI", appPrefs.itemToolPrefs.polyFactorGuiVal);
1473
        dcItemTools.setAttribute("PolygonCurvature", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyCurvature));
16192 fschmid 1474
        dcItemTools.setAttribute("PolygonOuterCurvature", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyOuterCurvature));
15124 cbradney 1475
        dcItemTools.setAttribute("PolygonUseFactor", static_cast<int>(appPrefs.itemToolPrefs.polyUseFactor));
1476
        dcItemTools.setAttribute("ImageScaleType", static_cast<int>(appPrefs.itemToolPrefs.imageScaleType));
1477
        dcItemTools.setAttribute("ImageAspectRatio", static_cast<int>(appPrefs.itemToolPrefs.imageAspectRatio));
1478
        dcItemTools.setAttribute("ImageUseEmbeddedPath", static_cast<int>(appPrefs.itemToolPrefs.imageUseEmbeddedPath));
1479
        dcItemTools.setAttribute("ImageLowResType", appPrefs.itemToolPrefs.imageLowResType);
1480
        dcItemTools.setAttribute("LineStartArrow", appPrefs.itemToolPrefs.lineStartArrow);
1481
        dcItemTools.setAttribute("LineEndArrow", appPrefs.itemToolPrefs.lineEndArrow);
1482
        dcItemTools.setAttribute("FontFace",appPrefs.itemToolPrefs.textFont);
1483
        dcItemTools.setAttribute("FontSize",appPrefs.itemToolPrefs.textSize / 10.0);
15847 fschmid 1484
        dcItemTools.setAttribute("calligrapicPenFillColor", appPrefs.itemToolPrefs.calligrapicPenFillColor);
1485
        dcItemTools.setAttribute("calligrapicPenLineColor", appPrefs.itemToolPrefs.calligrapicPenLineColor);
1486
        dcItemTools.setAttribute("calligrapicPenFillColorShade", appPrefs.itemToolPrefs.calligrapicPenFillColorShade);
1487
        dcItemTools.setAttribute("calligrapicPenLineColorShade", appPrefs.itemToolPrefs.calligrapicPenLineColorShade);
1488
        dcItemTools.setAttribute("calligrapicPenLineWidth", appPrefs.itemToolPrefs.calligrapicPenLineWidth);
1489
        dcItemTools.setAttribute("calligrapicPenAngle", appPrefs.itemToolPrefs.calligrapicPenAngle);
1490
        dcItemTools.setAttribute("calligrapicPenWidth", appPrefs.itemToolPrefs.calligrapicPenWidth);
1491
        dcItemTools.setAttribute("calligrapicPenStyle",appPrefs.itemToolPrefs.calligrapicPenStyle);
15124 cbradney 1492
        elem.appendChild(dcItemTools);
1493
 
1494
        QDomElement dcOperatorTools=docu.createElement("OperatorTools");
1495
        dcOperatorTools.setAttribute("MinimumMagnification",appPrefs.opToolPrefs.magMin);
1496
        dcOperatorTools.setAttribute("MaximumMagnification",appPrefs.opToolPrefs.magMax);
1497
        dcOperatorTools.setAttribute("MagnificationStep",appPrefs.opToolPrefs.magStep);
1498
        dcOperatorTools.setAttribute("DisplayOffsetX", ScCLocale::toQStringC(appPrefs.opToolPrefs.dispX));
1499
        dcOperatorTools.setAttribute("DisplayOffsetY", ScCLocale::toQStringC(appPrefs.opToolPrefs.dispY));
1500
        dcOperatorTools.setAttribute("RotationConstrainAngle", ScCLocale::toQStringC(appPrefs.opToolPrefs.constrain));
1501
        elem.appendChild(dcOperatorTools);
1502
 
1503
        QDomElement dcMainWindow=docu.createElement("MainWindow");
1504
        dcMainWindow.setAttribute("XPosition",appPrefs.uiPrefs.mainWinSettings.xPosition);
1505
        dcMainWindow.setAttribute("YPosition",appPrefs.uiPrefs.mainWinSettings.yPosition);
1506
        dcMainWindow.setAttribute("Width",appPrefs.uiPrefs.mainWinSettings.width);
1507
        dcMainWindow.setAttribute("Height",appPrefs.uiPrefs.mainWinSettings.height);
1508
        dcMainWindow.setAttribute("Maximized",static_cast<int>(appPrefs.uiPrefs.mainWinSettings.maximized));
1509
        elem.appendChild(dcMainWindow);
1510
 
1511
        QDomElement dcScrapbook=docu.createElement("ScrapBook");
1512
        dcScrapbook.setAttribute("CopyToScrapbook",static_cast<int>(appPrefs.scrapbookPrefs.doCopyToScrapbook));
1513
        dcScrapbook.setAttribute("PersistentScrapbook",static_cast<int>(appPrefs.scrapbookPrefs.persistentScrapbook));
1514
        dcScrapbook.setAttribute("WritePreviews",static_cast<int>(appPrefs.scrapbookPrefs.writePreviews));
1515
        dcScrapbook.setAttribute("ScrapbookCopies",appPrefs.scrapbookPrefs.numScrapbookCopies);
1516
        for (int i=0; i<appPrefs.scrapbookPrefs.RecentScrapbooks.count(); ++i)
4735 fschmid 1517
        {
15124 cbradney 1518
                QDomElement rde=docu.createElement("Recent");
1519
                rde.setAttribute("Name",appPrefs.scrapbookPrefs.RecentScrapbooks[i]);
1520
                dcScrapbook.appendChild(rde);
4735 fschmid 1521
        }
15124 cbradney 1522
        elem.appendChild(dcScrapbook);
1523
 
1524
 
3016 fschmid 1525
        QDomElement pageSetAttr = docu.createElement("PageSets");
9803 fschmid 1526
        QList<PageSet>::Iterator itpgset;
3016 fschmid 1527
        for(itpgset = appPrefs.pageSets.begin(); itpgset != appPrefs.pageSets.end(); ++itpgset )
1528
        {
1529
                QDomElement pgst = docu.createElement("Set");
1530
                pgst.setAttribute("Name", (*itpgset).Name);
1531
                pgst.setAttribute("FirstPage", (*itpgset).FirstPage);
1532
                pgst.setAttribute("Rows", (*itpgset).Rows);
1533
                pgst.setAttribute("Columns", (*itpgset).Columns);
11349 fschmid 1534
//              pgst.setAttribute("GapHorizontal", (*itpgset).GapHorizontal);
1535
//              pgst.setAttribute("GapVertical", (*itpgset).GapVertical);
1536
//              pgst.setAttribute("GapBelow", (*itpgset).GapBelow);
3026 fschmid 1537
                QStringList pNames = (*itpgset).pageNames;
1538
                QStringList::Iterator itpgsetN;
1539
                for(itpgsetN = pNames.begin(); itpgsetN != pNames.end(); ++itpgsetN )
1540
                {
1541
                        QDomElement pgstN = docu.createElement("PageNames");
1542
                        pgstN.setAttribute("Name", (*itpgsetN));
1543
                        pgst.appendChild(pgstN);
1544
                }
3016 fschmid 1545
                pageSetAttr.appendChild(pgst);
1546
        }
1547
        elem.appendChild(pageSetAttr);
15124 cbradney 1548
 
1549
        QDomElement dcPreflightVerifier=docu.createElement("PreflightVerifier");
1550
        dcPreflightVerifier.setAttribute("CurrentProfile", appPrefs.verifierPrefs.curCheckProfile);
1551
        dcPreflightVerifier.setAttribute("ShowPagesWithoutErrors", appPrefs.verifierPrefs.showPagesWithoutErrors);
1552
        dcPreflightVerifier.setAttribute("ShowNonPrintingLayerErrors", appPrefs.verifierPrefs.showNonPrintingLayerErrors);
1553
        elem.appendChild(dcPreflightVerifier);
1554
 
3033 cbradney 1555
        CheckerPrefsList::Iterator itcp;
14849 cbradney 1556
        CheckerPrefsList::Iterator itcpend=appPrefs.verifierPrefs.checkerPrefsList.end();
1557
        for (itcp = appPrefs.verifierPrefs.checkerPrefsList.begin(); itcp != itcpend; ++itcp)
2889 cbradney 1558
        {
15124 cbradney 1559
                QDomElement dcVerifierProfile=docu.createElement("VerifierProfile");
1560
                dcVerifierProfile.setAttribute("Name",itcp.key());
1561
                dcVerifierProfile.setAttribute("IgnoreErrors", static_cast<int>(itcp.value().ignoreErrors));
1562
                dcVerifierProfile.setAttribute("AutoCheck", static_cast<int>(itcp.value().autoCheck));
1563
                dcVerifierProfile.setAttribute("CheckGlyphs", static_cast<int>(itcp.value().checkGlyphs));
1564
                dcVerifierProfile.setAttribute("CheckOrphans", static_cast<int>(itcp.value().checkOrphans));
1565
                dcVerifierProfile.setAttribute("CheckOverflow", static_cast<int>(itcp.value().checkOverflow));
1566
                dcVerifierProfile.setAttribute("CheckPictures", static_cast<int>(itcp.value().checkPictures));
1567
                dcVerifierProfile.setAttribute("CheckResolution", static_cast<int>(itcp.value().checkResolution));
1568
                dcVerifierProfile.setAttribute("CheckTransparency", static_cast<int>(itcp.value().checkTransparency));
1569
                dcVerifierProfile.setAttribute("CheckAnnotations", static_cast<int>(itcp.value().checkAnnotations));
1570
                dcVerifierProfile.setAttribute("CheckRasterPDF", static_cast<int>(itcp.value().checkRasterPDF));
1571
                dcVerifierProfile.setAttribute("CheckForGIF", static_cast<int>(itcp.value().checkForGIF));
1572
                dcVerifierProfile.setAttribute("IgnoreOffLayers", static_cast<int>(itcp.value().ignoreOffLayers));
1573
                dcVerifierProfile.setAttribute("CheckOffConflictLayers", static_cast<int>(itcp.value().checkOffConflictLayers));
1574
                dcVerifierProfile.setAttribute("MinimumResolution",ScCLocale::toQStringC(itcp.value().minResolution));
1575
                dcVerifierProfile.setAttribute("MaximumResolution",ScCLocale::toQStringC(itcp.value().maxResolution));
1576
                dcVerifierProfile.setAttribute("CheckNotCMYKOrSpot", static_cast<int>(itcp.value().checkNotCMYKOrSpot));
1577
                dcVerifierProfile.setAttribute("CheckDeviceColorsAndOutputIntend", static_cast<int>(itcp.value().checkDeviceColorsAndOutputIntend));
1578
                dcVerifierProfile.setAttribute("CheckFontNotEmbedded", static_cast<int>(itcp.value().checkFontNotEmbedded));
1579
                dcVerifierProfile.setAttribute("CheckFontIsOpenType", static_cast<int>(itcp.value().checkFontIsOpenType));
1580
                elem.appendChild(dcVerifierProfile);
2889 cbradney 1581
        }
15124 cbradney 1582
        QDomElement dcColorManagement=docu.createElement("ColorManagement");
1583
        dcColorManagement.setAttribute("SoftProofOn", static_cast<int>(appPrefs.colorPrefs.DCMSset.SoftProofOn));
1584
        dcColorManagement.setAttribute("SoftProofFullOn", static_cast<int>(appPrefs.colorPrefs.DCMSset.SoftProofFullOn));
1585
        dcColorManagement.setAttribute("ColorManagementActive", static_cast<int>(appPrefs.colorPrefs.DCMSset.CMSinUse));
1586
        dcColorManagement.setAttribute("GamutCheck", static_cast<int>(appPrefs.colorPrefs.DCMSset.GamutCheck));
1587
        dcColorManagement.setAttribute("BlackPoint", static_cast<int>(appPrefs.colorPrefs.DCMSset.BlackPoint));
1588
        dcColorManagement.setAttribute("DefaultMonitorProfile",appPrefs.colorPrefs.DCMSset.DefaultMonitorProfile);
1589
        dcColorManagement.setAttribute("DefaultPrinterProfile",appPrefs.colorPrefs.DCMSset.DefaultPrinterProfile);
1590
        dcColorManagement.setAttribute("DefaultImageRGBProfile",appPrefs.colorPrefs.DCMSset.DefaultImageRGBProfile);
1591
        dcColorManagement.setAttribute("DefaultImageCMYKProfile",appPrefs.colorPrefs.DCMSset.DefaultImageCMYKProfile);
1592
        dcColorManagement.setAttribute("DefaultSolidColorRGBProfile",appPrefs.colorPrefs.DCMSset.DefaultSolidColorRGBProfile);
1593
        dcColorManagement.setAttribute("DefaultSolorColorCMYKProfile",appPrefs.colorPrefs.DCMSset.DefaultSolidColorCMYKProfile);
1594
        dcColorManagement.setAttribute("DefaultIntentColors",appPrefs.colorPrefs.DCMSset.DefaultIntentColors);
1595
        dcColorManagement.setAttribute("DefaultIntentImages",appPrefs.colorPrefs.DCMSset.DefaultIntentImages);
1596
        elem.appendChild(dcColorManagement);
1597
 
1598
        QDomElement dcPrinter=docu.createElement("Printer");
1599
        dcPrinter.setAttribute("Name",appPrefs.printerPrefs.PrinterName);
1600
        dcPrinter.setAttribute("File",appPrefs.printerPrefs.PrinterFile);
1601
        dcPrinter.setAttribute("Command",appPrefs.printerPrefs.PrinterCommand);
1602
        dcPrinter.setAttribute("ClipToMargins", static_cast<int>(appPrefs.printerPrefs.ClipMargin));
1603
        dcPrinter.setAttribute("GCRMode", static_cast<int>(appPrefs.printerPrefs.GCRMode));
1604
        elem.appendChild(dcPrinter);
1605
 
1606
        QDomElement dc8Pr=docu.createElement("PrintPreview");
13967 cbradney 1607
        dc8Pr.setAttribute("Mode", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_Mode));
1608
        //dc8Pr.setAttribute("GcrMode", static_cast<int>(appPrefs.Gcr_Mode));
1609
        dc8Pr.setAttribute("AntiAliasing", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_AntiAliasing));
1610
        dc8Pr.setAttribute("Transparency", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_Transparency));
1611
        dc8Pr.setAttribute("Cyan", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_C));
1612
        dc8Pr.setAttribute("Magenta", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_M));
1613
        dc8Pr.setAttribute("Yellow", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_Y));
1614
        dc8Pr.setAttribute("Black", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_K));
1615
        dc8Pr.setAttribute("InkCoverage", static_cast<int>(appPrefs.printPreviewPrefs.PrPr_InkCoverage));
1616
        dc8Pr.setAttribute("InkThreshold", appPrefs.printPreviewPrefs.PrPr_InkThreshold);
2889 cbradney 1617
        elem.appendChild(dc8Pr);
15130 cbradney 1618
        QDomElement dcExternalTools = docu.createElement("ExternalTools");
1619
        dcExternalTools.setAttribute("ImageEditor", imageEditorExecutable());
1620
        dcExternalTools.setAttribute("Ghostscript", ghostscriptExecutable());
1621
        dcExternalTools.setAttribute("WebBrowser", extBrowserExecutable());
1622
        dcExternalTools.setAttribute("GhostscriptAntiAliasGraphics", static_cast<int>(appPrefs.extToolPrefs.gs_AntiAliasGraphics));
1623
        dcExternalTools.setAttribute("GhostscriptAntiAliasText", static_cast<int>(appPrefs.extToolPrefs.gs_AntiAliasText));
1624
        dcExternalTools.setAttribute("Resolution", appPrefs.extToolPrefs.gs_Resolution);
1625
        dcExternalTools.setAttribute("Uniconvertor", uniconvExecutable());
1626
        dcExternalTools.setAttribute("PDFViewer", appPrefs.extToolPrefs.pdfViewerExecutable);
1627
        dcExternalTools.setAttribute("LatexEditor", latexEditorExecutable());
1628
        dcExternalTools.setAttribute("LatexResolution", latexResolution());
1629
        dcExternalTools.setAttribute("LatexForceDpi", static_cast<int>(appPrefs.extToolPrefs.latexForceDpi));
1630
        dcExternalTools.setAttribute("LatexStartWithEmptyFrames", static_cast<int>(appPrefs.extToolPrefs.latexStartWithEmptyFrames));
11506 mrdocs 1631
        QStringList configs = latexConfigs();
1632
        foreach (QString config, configs) {
1633
                QDomElement domConfig = docu.createElement("LatexConfig");
1634
                domConfig.setAttribute("file", config);
13955 cbradney 1635
                domConfig.setAttribute("command", appPrefs.extToolPrefs.latexCommands[config]);
15130 cbradney 1636
                dcExternalTools.appendChild(domConfig);
11506 mrdocs 1637
        }
15130 cbradney 1638
        elem.appendChild(dcExternalTools);
15124 cbradney 1639
        QDomElement rde=docu.createElement("Hyphenator");
1640
        rde.setAttribute("Language", appPrefs.hyphPrefs.Language);
1641
        rde.setAttribute("WordLength", appPrefs.hyphPrefs.MinWordLen);
1642
        rde.setAttribute("HyphenCount", appPrefs.hyphPrefs.HyCount);
1643
        rde.setAttribute("Automatic", static_cast<int>(appPrefs.hyphPrefs.Automatic));
1644
        rde.setAttribute("AutomaticCheck", static_cast<int>(appPrefs.hyphPrefs.AutoCheck));
13955 cbradney 1645
        for (QHash<QString, QString>::Iterator hyit = appPrefs.hyphPrefs.specialWords.begin(); hyit != appPrefs.hyphPrefs.specialWords.end(); ++hyit)
10170 fschmid 1646
        {
15124 cbradney 1647
                QDomElement hyelm = docu.createElement("Exception");
1648
                hyelm.setAttribute("Word", hyit.key());
1649
                hyelm.setAttribute("Hyphenated", hyit.value());
10170 fschmid 1650
                rde.appendChild(hyelm);
1651
        }
13955 cbradney 1652
        for (QSet<QString>::Iterator hyit2 = appPrefs.hyphPrefs.ignoredWords.begin(); hyit2 != appPrefs.hyphPrefs.ignoredWords.end(); ++hyit2)
10170 fschmid 1653
        {
15124 cbradney 1654
                QDomElement hyelm2 = docu.createElement("Ignore");
1655
                hyelm2.setAttribute("Word", (*hyit2));
10170 fschmid 1656
                rde.appendChild(hyelm2);
1657
        }
2889 cbradney 1658
        elem.appendChild(rde);
13955 cbradney 1659
        for (int rd=0; rd<appPrefs.uiPrefs.RecentDocs.count(); ++rd)
2889 cbradney 1660
        {
15124 cbradney 1661
                QDomElement rde=docu.createElement("Recent");
1662
                rde.setAttribute("Name",appPrefs.uiPrefs.RecentDocs[rd]);
2889 cbradney 1663
                elem.appendChild(rde);
1664
        }
13955 cbradney 1665
        for (QMap<QString,Keys>::Iterator ksc=appPrefs.keyShortcutPrefs.KeyActions.begin(); ksc!=appPrefs.keyShortcutPrefs.KeyActions.end(); ++ksc)
2889 cbradney 1666
        {
10398 cbradney 1667
                if (ksc.value().actionName.isEmpty())
5354 cbradney 1668
                        continue;
15124 cbradney 1669
                QDomElement kscc=docu.createElement("Shortcut");
1670
                kscc.setAttribute("Action",ksc.value().actionName);
15834 fschmid 1671
                kscc.setAttribute("KeySequence",Prefs_KeyboardShortcuts::getKeyText(ksc.value().keySequence));
2889 cbradney 1672
                elem.appendChild(kscc);
1673
        }
15124 cbradney 1674
        QDomElement cosd=docu.createElement("DefaultColorSet");
15216 cbradney 1675
        cosd.setAttribute("Name",appPrefs.colorPrefs.DColorSet);
2889 cbradney 1676
        elem.appendChild(cosd);
15124 cbradney 1677
 
2889 cbradney 1678
        QDomElement pdf = docu.createElement("PDF");
13955 cbradney 1679
        pdf.setAttribute("Thumbnails", static_cast<int>(appPrefs.pdfPrefs.Thumbnails));
1680
        pdf.setAttribute("Articles", static_cast<int>(appPrefs.pdfPrefs.Articles));
1681
        pdf.setAttribute("Bookmarks", static_cast<int>(appPrefs.pdfPrefs.Bookmarks));
1682
        pdf.setAttribute("Compress", static_cast<int>(appPrefs.pdfPrefs.Compress));
15124 cbradney 1683
        pdf.setAttribute("CompressionMethod", appPrefs.pdfPrefs.CompressMethod);
13955 cbradney 1684
        pdf.setAttribute("Quality", appPrefs.pdfPrefs.Quality);
1685
        pdf.setAttribute("EmbedPDF", static_cast<int>(appPrefs.pdfPrefs.embedPDF));
15124 cbradney 1686
        pdf.setAttribute("MirrorPagesHorizontal", static_cast<int>(appPrefs.pdfPrefs.MirrorH));
1687
        pdf.setAttribute("MirrorPagesVertical", static_cast<int>(appPrefs.pdfPrefs.MirrorV));
1688
        pdf.setAttribute("DoClip", static_cast<int>(appPrefs.pdfPrefs.doClip));
13955 cbradney 1689
        pdf.setAttribute("RotateDeg", static_cast<int>(appPrefs.pdfPrefs.RotateDeg));
1690
        pdf.setAttribute("PresentMode", static_cast<int>(appPrefs.pdfPrefs.PresentMode));
1691
        pdf.setAttribute("RecalcPic", static_cast<int>(appPrefs.pdfPrefs.RecalcPic));
1692
        pdf.setAttribute("Grayscale", static_cast<int>(appPrefs.pdfPrefs.isGrayscale));
1693
        pdf.setAttribute("RGBMode", static_cast<int>(appPrefs.pdfPrefs.UseRGB));
1694
        pdf.setAttribute("UseProfiles", static_cast<int>(appPrefs.pdfPrefs.UseProfiles));
1695
        pdf.setAttribute("UseProfiles2", static_cast<int>(appPrefs.pdfPrefs.UseProfiles2));
1696
        pdf.setAttribute("Binding", appPrefs.pdfPrefs.Binding);
1697
        pdf.setAttribute("PicRes", appPrefs.pdfPrefs.PicRes);
1698
        pdf.setAttribute("Resolution", appPrefs.pdfPrefs.Resolution);
1699
        pdf.setAttribute("Version", appPrefs.pdfPrefs.Version);
1700
        pdf.setAttribute("Intent", appPrefs.pdfPrefs.Intent);
1701
        pdf.setAttribute("Intent2", appPrefs.pdfPrefs.Intent2);
15124 cbradney 1702
        pdf.setAttribute("SolidProfile", appPrefs.pdfPrefs.SolidProf);
1703
        pdf.setAttribute("ImageProfile", appPrefs.pdfPrefs.ImageProf);
1704
        pdf.setAttribute("PrintProfile", appPrefs.pdfPrefs.PrintProf);
13955 cbradney 1705
        pdf.setAttribute("InfoString", appPrefs.pdfPrefs.Info);
15124 cbradney 1706
        pdf.setAttribute("BleedTop", ScCLocale::toQStringC(appPrefs.pdfPrefs.bleeds.Top));
1707
        pdf.setAttribute("BleedLeft", ScCLocale::toQStringC(appPrefs.pdfPrefs.bleeds.Left));
1708
        pdf.setAttribute("BleedRight", ScCLocale::toQStringC(appPrefs.pdfPrefs.bleeds.Right));
1709
        pdf.setAttribute("BleedBottom", ScCLocale::toQStringC(appPrefs.pdfPrefs.bleeds.Bottom));
1710
        pdf.setAttribute("UseDocBleeds", static_cast<int>(appPrefs.pdfPrefs.useDocBleeds));
1711
        pdf.setAttribute("CropMarks", static_cast<int>(appPrefs.pdfPrefs.cropMarks));
1712
        pdf.setAttribute("BleedMarks", static_cast<int>(appPrefs.pdfPrefs.bleedMarks));
1713
        pdf.setAttribute("RegistrationMarks", static_cast<int>(appPrefs.pdfPrefs.registrationMarks));
1714
        pdf.setAttribute("ColorMarks", static_cast<int>(appPrefs.pdfPrefs.colorMarks));
1715
        pdf.setAttribute("DocInfoMarks", static_cast<int>(appPrefs.pdfPrefs.docInfoMarks));
1716
        pdf.setAttribute("MarkOffset", appPrefs.pdfPrefs.markOffset);
13955 cbradney 1717
        pdf.setAttribute("ImagePr", static_cast<int>(appPrefs.pdfPrefs.EmbeddedI));
1718
        pdf.setAttribute("PassOwner", appPrefs.pdfPrefs.PassOwner);
1719
        pdf.setAttribute("PassUser", appPrefs.pdfPrefs.PassUser);
1720
        pdf.setAttribute("Permissions", appPrefs.pdfPrefs.Permissions);
1721
        pdf.setAttribute("Encrypt", static_cast<int>(appPrefs.pdfPrefs.Encrypt));
1722
        pdf.setAttribute("UseLayers", static_cast<int>(appPrefs.pdfPrefs.useLayers));
1723
        pdf.setAttribute("UseLpi", static_cast<int>(appPrefs.pdfPrefs.UseLPI));
1724
        pdf.setAttribute("UseSpotColors", static_cast<int>(appPrefs.pdfPrefs.UseSpotColors));
15124 cbradney 1725
        pdf.setAttribute("DoMultiFile", static_cast<int>(appPrefs.pdfPrefs.doMultiFile));
1726
        pdf.setAttribute("DisplayBookmarks", static_cast<int>(appPrefs.pdfPrefs.displayBookmarks));
1727
        pdf.setAttribute("DisplayFullscreen", static_cast<int>(appPrefs.pdfPrefs.displayFullscreen));
1728
        pdf.setAttribute("DisplayLayers", static_cast<int>(appPrefs.pdfPrefs.displayLayers));
1729
        pdf.setAttribute("DisplayThumbs", static_cast<int>(appPrefs.pdfPrefs.displayThumbs));
16204 fschmid 1730
        pdf.setAttribute("hideMenuBar", static_cast<int>(appPrefs.pdfPrefs.hideMenuBar));
1731
        pdf.setAttribute("hideToolBar", static_cast<int>(appPrefs.pdfPrefs.hideToolBar));
1732
        pdf.setAttribute("fitWindow", static_cast<int>(appPrefs.pdfPrefs.fitWindow));
1733
        pdf.setAttribute("openAfterExport", static_cast<int>(appPrefs.pdfPrefs.openAfterExport));
13955 cbradney 1734
        pdf.setAttribute("PageLayout", appPrefs.pdfPrefs.PageLayout);
15124 cbradney 1735
        pdf.setAttribute("OpenAction", appPrefs.pdfPrefs.openAction);
2889 cbradney 1736
        QMap<QString,LPIData>::Iterator itlp;
13955 cbradney 1737
        for (itlp = appPrefs.pdfPrefs.LPISettings.begin(); itlp != appPrefs.pdfPrefs.LPISettings.end(); ++itlp)
2889 cbradney 1738
        {
1739
                QDomElement pdf4 = docu.createElement("LPI");
1740
                pdf4.setAttribute("Color", itlp.key());
10398 cbradney 1741
                pdf4.setAttribute("Frequency", itlp.value().Frequency);
1742
                pdf4.setAttribute("Angle", itlp.value().Angle);
1743
                pdf4.setAttribute("SpotFunction", itlp.value().SpotFunc);
2889 cbradney 1744
                pdf.appendChild(pdf4);
1745
        }
1746
        elem.appendChild(pdf);
1747
        QDomElement docItemAttrs = docu.createElement("DefaultItemAttributes");
13955 cbradney 1748
        for(ObjAttrVector::Iterator objAttrIt = appPrefs.itemAttrPrefs.defaultItemAttributes.begin() ; objAttrIt != appPrefs.itemAttrPrefs.defaultItemAttributes.end(); ++objAttrIt )
2889 cbradney 1749
        {
1750
                QDomElement itemAttr = docu.createElement("ItemAttribute");
1751
                itemAttr.setAttribute("Name", (*objAttrIt).name);
1752
                itemAttr.setAttribute("Type", (*objAttrIt).type);
1753
                itemAttr.setAttribute("Value", (*objAttrIt).value);
1754
                itemAttr.setAttribute("Parameter", (*objAttrIt).parameter);
1755
                itemAttr.setAttribute("Relationship", (*objAttrIt).relationship);
1756
                itemAttr.setAttribute("RelationshipTo", (*objAttrIt).relationshipto);
1757
                itemAttr.setAttribute("AutoAddTo", (*objAttrIt).autoaddto);
1758
                docItemAttrs.appendChild(itemAttr);
1759
        }
1760
        elem.appendChild(docItemAttrs);
1761
        QDomElement tocElem = docu.createElement("TablesOfContents");
13955 cbradney 1762
        for(ToCSetupVector::Iterator tocSetupIt = appPrefs.tocPrefs.defaultToCSetups.begin() ; tocSetupIt != appPrefs.tocPrefs.defaultToCSetups.end(); ++tocSetupIt )
2889 cbradney 1763
        {
1764
                QDomElement tocsetup = docu.createElement("TableOfContents");
1765
                tocsetup.setAttribute("Name", (*tocSetupIt).name);
1766
                tocsetup.setAttribute("ItemAttributeName", (*tocSetupIt).itemAttrName);
1767
                tocsetup.setAttribute("FrameName", (*tocSetupIt).frameName);
1768
                tocsetup.setAttribute("ListNonPrinting", (*tocSetupIt).listNonPrintingFrames);
1769
                tocsetup.setAttribute("Style", (*tocSetupIt).textStyle);
1770
                tocsetup.setAttribute("NumberPlacement", (*tocSetupIt).pageLocation);
1771
                tocElem.appendChild(tocsetup);
1772
        }
1773
        elem.appendChild(tocElem);
15124 cbradney 1774
 
14539 jghali 1775
        // image cache
1776
        QDomElement icElem = docu.createElement("ImageCache");
15124 cbradney 1777
        icElem.setAttribute("Enabled", appPrefs.imageCachePrefs.cacheEnabled);
1778
        icElem.setAttribute("MaximumCacheSizeMiB", appPrefs.imageCachePrefs.maxCacheSizeMiB);
1779
        icElem.setAttribute("MaximumCacheEntries", appPrefs.imageCachePrefs.maxCacheEntries);
1780
        icElem.setAttribute("CompressionLevel", appPrefs.imageCachePrefs.compressionLevel);
14539 jghali 1781
        elem.appendChild(icElem);
15105 cbradney 1782
        // active page sizes
1783
        QDomElement apsElem = docu.createElement("ActivePageSizes");
15124 cbradney 1784
        apsElem.setAttribute("Names", appPrefs.activePageSizes.join(","));
15105 cbradney 1785
        elem.appendChild(apsElem);
1786
 
2889 cbradney 1787
        // write file
3170 craig 1788
        bool result = false;
2889 cbradney 1789
        QFile f(ho);
8501 cbradney 1790
        if(!f.open(QIODevice::WriteOnly))
3170 craig 1791
        {
1792
                m_lastError = tr("Could not open preferences file \"%1\" for writing: %2")
10553 fschmid 1793
                        .arg(ho).arg(qApp->translate("QFile",f.errorString().toLatin1().constData()));
3170 craig 1794
        }
1795
        else
1796
        {
10004 fschmid 1797
                QTextStream s(&f);
1798
                s.setCodec("UTF-8");
3170 craig 1799
                s<<docu.toString();
8528 cbradney 1800
                if (f.error()==QFile::NoError)
3170 craig 1801
                        result = true;
1802
                else
1803
                        m_lastError = tr("Writing to preferences file \"%1\" failed: "
14043 jghali 1804
                                                         "QIODevice status code %2")
10553 fschmid 1805
                                .arg(ho).arg(f.errorString());
3170 craig 1806
        }
1807
        if (f.isOpen())
1808
                f.close();
1809
        return result;
2889 cbradney 1810
}
1811
 
1812
bool PrefsManager::ReadPref(QString ho)
1813
{
1814
        QDomDocument docu("scridoc");
1815
        QFile f(ho);
8501 cbradney 1816
        if(!f.open(QIODevice::ReadOnly))
3171 craig 1817
        {
1818
                m_lastError = tr("Failed to open prefs file \"%1\": %2")
10553 fschmid 1819
                        .arg(ho).arg( qApp->translate("QFile",f.errorString().toLatin1().constData()) );
2889 cbradney 1820
                return false;
3171 craig 1821
        }
10004 fschmid 1822
        QTextStream ts(&f);
1823
        ts.setCodec("UTF-8");
2889 cbradney 1824
        QString errorMsg;
1825
        int errorLine = 0, errorColumn = 0;
10004 fschmid 1826
        if( !docu.setContent(ts.readAll(), &errorMsg, &errorLine, &errorColumn) )
2889 cbradney 1827
        {
3171 craig 1828
                m_lastError = tr("Failed to read prefs XML from \"%1\": %2 at line %3, col %4")
1829
                        .arg(ho).arg(errorMsg).arg(errorLine).arg(errorColumn);
2889 cbradney 1830
                f.close();
1831
                return false;
1832
        }
1833
        f.close();
1834
        QDomElement elem=docu.documentElement();
1835
        if (elem.tagName() != "SCRIBUSRC")
1836
                return false;
15125 cbradney 1837
        //Ignore scribus*.rc files prior to 1.5.0 due to changes
1838
        bool prefs150FileFound=false;
13474 cbradney 1839
        if (elem.hasAttribute("VERSION"))
1840
        {
15125 cbradney 1841
                if (elem.attribute("VERSION") == "1.5.0")
1842
                        prefs150FileFound=true;
13474 cbradney 1843
        }
15125 cbradney 1844
        firstTimeIgnoreOldPrefs=!prefs150FileFound;
1845
        if (!prefs150FileFound)
13474 cbradney 1846
                return false;
13967 cbradney 1847
        appPrefs.colorPrefs.DColors.clear();
13955 cbradney 1848
        appPrefs.extToolPrefs.latexCommands.clear();
15665 fschmid 1849
        ColorSetManager csm;
1850
        csm.initialiseDefaultPrefs(appPrefs);
1851
        csm.findPaletteLocations();
1852
        csm.findPalettes();
15681 fschmid 1853
        csm.findUserPalettes();
2889 cbradney 1854
        ScColor lf = ScColor();
1855
        QDomNode DOC=elem.firstChild();
3183 fschmid 1856
        if (!DOC.namedItem("CheckProfile").isNull())
14849 cbradney 1857
                appPrefs.verifierPrefs.checkerPrefsList.clear();
2889 cbradney 1858
        while(!DOC.isNull())
1859
        {
1860
                QDomElement dc=DOC.toElement();
15124 cbradney 1861
 
1862
                if (dc.tagName()=="UI")
2889 cbradney 1863
                {
15124 cbradney 1864
                        appPrefs.uiPrefs.style = dc.attribute("Theme","Default");
1865
                        appPrefs.uiPrefs.wheelJump = dc.attribute("ScrollWheelJump").toInt();
1866
                        appPrefs.uiPrefs.mouseMoveTimeout = dc.attribute("MouseMoveTimeout", "150").toInt();
1867
                        appPrefs.uiPrefs.applicationFontSize = dc.attribute("ApplicationFontSize", "12").toInt();
1868
                        appPrefs.uiPrefs.paletteFontSize = dc.attribute("PaletteFontSize", "10").toInt();
1869
                        appPrefs.uiPrefs.recentDocCount = dc.attribute("RecentDocumentCount","5").toUInt();
1870
                        appPrefs.uiPrefs.showStartupDialog = static_cast<bool>(dc.attribute("ShowStartupDialog", "1").toInt());
14203 cbradney 1871
                        appPrefs.uiPrefs.showSplashOnStartup = static_cast<bool>(dc.attribute("UI_SHOWSPLASHSCREEN", "1").toInt());
15124 cbradney 1872
                        appPrefs.uiPrefs.useSmallWidgets = dc.attribute("UseSmallWidgets").toInt();
1873
                        appPrefs.uiPrefs.useTabs = static_cast<bool>(dc.attribute("UseDocumentTabs", "0").toInt());
1874
                        appPrefs.uiPrefs.stickyTools = static_cast<bool>(dc.attribute("StickyTools", "0").toInt());
1875
                        appPrefs.uiPrefs.SepalT = static_cast<bool>(dc.attribute("PagePaletteShowThumbs").toInt());
1876
                        appPrefs.uiPrefs.SepalN = static_cast<bool>(dc.attribute("PagePaletteShowNames").toInt());
15461 craig 1877
                        appPrefs.uiPrefs.grayscaleIcons = static_cast<bool>(dc.attribute("UseGrayscaleIcons",0).toInt());
15124 cbradney 1878
                }
13876 cbradney 1879
 
15124 cbradney 1880
                if (dc.tagName()=="DocumentSetup")
1881
                {
1882
                        appPrefs.docSetupPrefs.docUnitIndex = dc.attribute("UnitIndex", "0").toInt();
1883
                        appPrefs.docSetupPrefs.pageSize = dc.attribute("PageSize","A4");
1884
                        appPrefs.docSetupPrefs.pageOrientation = dc.attribute("PageOrientation", "0").toInt();
1885
                        appPrefs.docSetupPrefs.pageWidth   = ScCLocale::toDoubleC(dc.attribute("PageWidth"), 595.0);
1886
                        appPrefs.docSetupPrefs.pageHeight  = ScCLocale::toDoubleC(dc.attribute("PageHeight"), 842.0);
1887
                        appPrefs.docSetupPrefs.margins.Top = ScCLocale::toDoubleC(dc.attribute("MarginTop"), 9.0);
1888
                        appPrefs.docSetupPrefs.margins.Bottom = ScCLocale::toDoubleC(dc.attribute("MarginBottom"), 40.0);
1889
                        appPrefs.docSetupPrefs.margins.Left   = ScCLocale::toDoubleC(dc.attribute("MarginLeft"), 9.0);
1890
                        appPrefs.docSetupPrefs.margins.Right  = ScCLocale::toDoubleC(dc.attribute("MarginRight"), 9.0);
1891
                        appPrefs.docSetupPrefs.marginPreset   = dc.attribute("MarginPreset", "0").toInt();
1892
                        appPrefs.docSetupPrefs.pagePositioning    = dc.attribute("PagePositioning", "0").toInt();
1893
                        appPrefs.docSetupPrefs.AutoSave      = static_cast<bool>(dc.attribute("AutoSave", "0").toInt());
1894
                        appPrefs.docSetupPrefs.AutoSaveTime  = dc.attribute("AutoSaveTime", "600000").toInt();
1895
                        appPrefs.docSetupPrefs.saveCompressed = static_cast<bool>(dc.attribute("SaveCompressed", "0").toInt());
1896
                        appPrefs.docSetupPrefs.bleeds.Top    = ScCLocale::toDoubleC(dc.attribute("BleedTop"), 0.0);
1897
                        appPrefs.docSetupPrefs.bleeds.Left   = ScCLocale::toDoubleC(dc.attribute("BleedLeft"), 0.0);
1898
                        appPrefs.docSetupPrefs.bleeds.Right  = ScCLocale::toDoubleC(dc.attribute("BleedRight"), 0.0);
1899
                        appPrefs.docSetupPrefs.bleeds.Bottom = ScCLocale::toDoubleC(dc.attribute("BleedBottom"), 0.0);
1900
 
1901
                }
1902
 
1903
                if (dc.tagName()=="Miscellaneous")
1904
                {
1905
                        appPrefs.miscPrefs.haveStylePreview = static_cast<bool>(dc.attribute("ShowStylePreview", "1").toInt());
1906
                        appPrefs.miscPrefs.useStandardLI = static_cast<bool>(dc.attribute("LoremIpsumUseStandard", "0").toInt());
1907
                        appPrefs.miscPrefs.paragraphsLI = dc.attribute("LoremIpsumParagraphs", "10").toInt();
1908
                }
1909
 
1910
 
1911
                if (dc.tagName()=="Display")
1912
                {
13955 cbradney 1913
                        appPrefs.displayPrefs.scratch.Bottom = ScCLocale::toDoubleC(dc.attribute("ScratchBottom"), 20.0);
1914
                        appPrefs.displayPrefs.scratch.Left   = ScCLocale::toDoubleC(dc.attribute("ScratchLeft"), 100.0);
1915
                        appPrefs.displayPrefs.scratch.Right  = ScCLocale::toDoubleC(dc.attribute("ScratchRight"), 100.0);
1916
                        appPrefs.displayPrefs.scratch.Top    = ScCLocale::toDoubleC(dc.attribute("ScratchTop"), 20.0);
15124 cbradney 1917
                        appPrefs.displayPrefs.pageGapHorizontal  = ScCLocale::toDoubleC(dc.attribute("PageGapHorizontal"), 0.0);
1918
                        appPrefs.displayPrefs.pageGapVertical    = ScCLocale::toDoubleC(dc.attribute("PageGapVertical"), 40.0);
1919
                        appPrefs.displayPrefs.showPageShadow = static_cast<bool>(dc.attribute("ShowPageShadow", "1").toInt());
1920
                        appPrefs.displayPrefs.paperColor = QColor(dc.attribute("PageColor"));
15139 cbradney 1921
                        if (dc.hasAttribute("ScratchColor"))
1922
                                appPrefs.displayPrefs.scratchColor = QColor(dc.attribute("ScratchColor"));
1923
                        else
1924
                                appPrefs.displayPrefs.scratchColor = qApp->palette().color(QPalette::Active, QPalette::Window);
15124 cbradney 1925
                        appPrefs.displayPrefs.frameColor = QColor(dc.attribute("FrameSelectedColor","#ff0000"));
1926
                        appPrefs.displayPrefs.frameNormColor = QColor(dc.attribute("FrameNormColor","#000000"));
1927
                        appPrefs.displayPrefs.frameGroupColor = QColor(dc.attribute("FrameGroupColor","#008080"));
1928
                        appPrefs.displayPrefs.frameLockColor = QColor(dc.attribute("FrameLockColor","#800000"));
1929
                        appPrefs.displayPrefs.frameLinkColor = QColor(dc.attribute("FrameLinkColor","#ff0000"));
1930
                        appPrefs.displayPrefs.frameAnnotationColor = QColor(dc.attribute("FrameAnnotationColor","#0000ff"));
1931
                        appPrefs.displayPrefs.pageBorderColor = QColor(dc.attribute("PageBorderColor","#ff0000"));
1932
                        appPrefs.displayPrefs.controlCharColor = QColor(dc.attribute("ControlCharColor","#800000"));
1933
                        appPrefs.displayPrefs.marginColored = static_cast<bool>(dc.attribute("ShowMarginsFilled", "0").toInt());
15179 jghali 1934
                        appPrefs.displayPrefs.displayScale = qRound(ScCLocale::toDoubleC(dc.attribute("DisplayScale"), appPrefs.displayPrefs.displayScale)*72)/72.0;
15124 cbradney 1935
                        appPrefs.displayPrefs.showVerifierWarningsOnCanvas = static_cast<bool>(dc.attribute("ShowVerifierWarningsOnCanvas", "1").toInt());
13955 cbradney 1936
                        appPrefs.displayPrefs.showToolTips = static_cast<bool>