Subversion Repositories Scribus

Rev

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