Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
2834 cbradney 7
/***************************************************************************
8
        copyright            : (C) 2005 by Craig Bradney
9
        email                : cbradney@zip.com.au
10
***************************************************************************/
11
 
12
/***************************************************************************
13
*                                                                         *
14
*   This program is free software; you can redistribute it and/or modify  *
15
*   it under the terms of the GNU General Public License as published by  *
16
*   the Free Software Foundation; either version 2 of the License, or     *
17
*   (at your option) any later version.                                   *
18
*                                                                         *
19
***************************************************************************/
2835 cbradney 20
 
10531 avox 21
#include <QColor>
22
#include <QDebug>
8528 cbradney 23
#include <QDesktopWidget>
10223 cbradney 24
#include <QDir>
25
#include <QDomDocument>
26
#include <QFile>
16477 craig 27
#include <QList>
10531 avox 28
#include <QMatrix>
10223 cbradney 29
#include <QString>
11506 mrdocs 30
#include <QStringList>
10223 cbradney 31
#include <QStyleFactory>
2835 cbradney 32
 
2834 cbradney 33
#include "prefsmanager.h"
5243 cbradney 34
 
35
#include "actionmanager.h"
15911 jghali 36
#include "colormgmt/sccolormgmtstructs.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"
2889 cbradney 41
#include "missing.h"
5354 cbradney 42
#include "tabkeyboardshortcutswidget.h"
2865 cbradney 43
#include "pagesize.h"
4122 cbradney 44
#include "pagestructs.h"
2835 cbradney 45
#include "pdfoptions.h"
46
#include "prefsfile.h"
13460 jghali 47
#include "scclocale.h"
2835 cbradney 48
#include "scfonts.h"
3953 cbradney 49
#include "scmessagebox.h"
2835 cbradney 50
#include "scpaths.h"
5781 cbradney 51
#include "scribuscore.h"
2835 cbradney 52
#include "scribusstructs.h"
10976 cbradney 53
#include "ui/modetoolbar.h"
11605 jghali 54
#include "util_file.h"
10212 cbradney 55
#include "util_ghostscript.h"
10976 cbradney 56
 
2859 cbradney 57
extern bool emergencyActivated;
2835 cbradney 58
 
2834 cbradney 59
PrefsManager* PrefsManager::_instance = 0;
60
 
10427 cbradney 61
PrefsManager::PrefsManager(QObject *parent)
13482 cbradney 62
 : QObject(parent),
63
 firstTimeIgnoreOldPrefs(false)
2834 cbradney 64
{
65
}
66
 
67
PrefsManager::~PrefsManager()
68
{
10237 jghali 69
        appPrefs.AvailFonts.clear();
2856 cbradney 70
        delete prefsFile;
2834 cbradney 71
}
72
 
73
PrefsManager* PrefsManager::instance()
74
{
75
    if (_instance == 0)
76
        _instance = new PrefsManager();
77
 
78
    return _instance;
79
}
80
 
81
void PrefsManager::deleteInstance()
82
{
83
    if (_instance)
84
        delete _instance;
85
    _instance = 0;
86
}
87
 
88
 
89
ApplicationPrefs* PrefsManager::applicationPrefs()
90
{
91
        return &appPrefs;
92
}
2835 cbradney 93
 
2856 cbradney 94
PrefsFile* PrefsManager::applicationPrefsFile()
95
{
96
        return prefsFile;
97
}
98
 
10509 cbradney 99
bool PrefsManager::importingFrom12x()
2856 cbradney 100
{
101
        return importingFrom12;
102
}
103
 
104
 
105
void PrefsManager::setup()
106
{
107
        setupPreferencesLocation();
108
 
5200 cbradney 109
        importingFrom12=copyOldPreferences();
16451 craig 110
        prefsFile = new PrefsFile( prefsLocation + "/prefs140.xml" );
2856 cbradney 111
        if (importingFrom12)
112
                convert12Preferences();
113
        //<<CB TODO Reset keyboard shortcuts of all 1.3 users as too many
114
        //     have conflicts if they dont nuke their settings.
115
        // - Remove for 1.3.0 release: importingFrom12=true;
116
        //>>CB
117
}
118
 
2835 cbradney 119
void PrefsManager::initDefaults()
120
{
121
        /** Default font and size **/
122
        SCFontsIterator it(appPrefs.AvailFonts);
4221 fschmid 123
        bool goodFont = false;
5980 avox 124
        for ( SCFontsIterator itf(appPrefs.AvailFonts); itf.hasNext(); itf.next())
4221 fschmid 125
        {
126
                if ((itf.currentKey() == "Arial Regular") || (itf.currentKey() == "Times New Roman Regular"))
127
                {
128
                        appPrefs.toolSettings.defFont = itf.currentKey();
129
                        goodFont = true;
130
                        break;
131
                }
132
        }
133
        if (!goodFont)
134
                appPrefs.toolSettings.defFont = it.currentKey();
2835 cbradney 135
        appPrefs.toolSettings.defSize = 120;
136
 
137
        /** Default colours **/
138
        appPrefs.DColors.clear();
4606 cbradney 139
 
140
        ColorSetManager csm;
141
        csm.initialiseDefaultPrefs(appPrefs);
142
        csm.findPaletteLocations();
143
        csm.findPalettes();
144
        /*
17179 craig 145
        QString pfadC = ScPaths::instance().shareDir()+"swatches/";
4606 cbradney 146
        QString pfadC2 = pfadC + "Scribus_X11.txt";
2835 cbradney 147
        QFile fiC(pfadC2);
148
        if (!fiC.exists())
149
        {
2886 fschmid 150
                appPrefs.DColors.insert("White", ScColor(0, 0, 0, 0));
151
                appPrefs.DColors.insert("Black", ScColor(0, 0, 0, 255));
152
                appPrefs.DColors.insert("Blue", ScColor(255, 255, 0, 0));
153
                appPrefs.DColors.insert("Cyan", ScColor(255, 0, 0, 0));
154
                appPrefs.DColors.insert("Green", ScColor(255, 0, 255, 0));
155
                appPrefs.DColors.insert("Red", ScColor(0, 255, 255, 0));
156
                appPrefs.DColors.insert("Yellow", ScColor(0, 0, 255, 0));
157
                appPrefs.DColors.insert("Magenta", ScColor(0, 255, 0, 0));
2835 cbradney 158
                appPrefs.DColorSet = "Scribus-Small";
159
        }
160
        else
161
        {
162
                if (fiC.open(IO_ReadOnly))
163
                {
164
                        QString ColorEn, Cname;
165
                        int Rval, Gval, Bval;
166
                        QTextStream tsC(&fiC);
167
                        ColorEn = tsC.readLine();
168
                        while (!tsC.atEnd())
169
                        {
170
                                ColorEn = tsC.readLine();
171
                                QTextStream CoE(&ColorEn, IO_ReadOnly);
172
                                CoE >> Rval;
173
                                CoE >> Gval;
174
                                CoE >> Bval;
175
                                CoE >> Cname;
2886 fschmid 176
                                ScColor tmp;
2835 cbradney 177
                                tmp.setColorRGB(Rval, Gval, Bval);
178
                                appPrefs.DColors.insert(Cname, tmp);
179
                        }
180
                        fiC.close();
181
                }
182
                appPrefs.DColorSet = "X11 RGB-Set";
183
        }
4606 cbradney 184
        */
2835 cbradney 185
 
186
        appPrefs.Wheelval = 40;
3641 fschmid 187
        /** Set Default window position and size to sane default values which should work on every screen */
13050 cbradney 188
//      appPrefs.mainWinSettings.xPosition = 0;
189
//      appPrefs.mainWinSettings.yPosition = 0;
3641 fschmid 190
        appPrefs.mainWinSettings.width = 640;
191
        appPrefs.mainWinSettings.height = 480;
13050 cbradney 192
        QDesktopWidget *d = QApplication::desktop();
193
        appPrefs.mainWinSettings.xPosition=(d->availableGeometry().width()-appPrefs.mainWinSettings.width)/2;
194
        appPrefs.mainWinSettings.yPosition=(d->availableGeometry().height()-appPrefs.mainWinSettings.height)/2;
4892 cbradney 195
        appPrefs.mainWinSettings.maximized = false;
10531 avox 196
        appPrefs.mainWinState = QByteArray();
2835 cbradney 197
        appPrefs.guidesSettings.marginsShown = true;
198
        appPrefs.guidesSettings.framesShown = true;
5584 fschmid 199
        appPrefs.guidesSettings.layerMarkersShown = false;
2835 cbradney 200
        appPrefs.guidesSettings.gridShown = false;
9941 mrdocs 201
        appPrefs.guidesSettings.guidesShown = true;
11830 fschmid 202
        appPrefs.guidesSettings.colBordersShown = true;
2835 cbradney 203
        appPrefs.guidesSettings.baseShown = false;
204
        appPrefs.guidesSettings.showPic = true;
205
        appPrefs.guidesSettings.showControls = false;
206
        appPrefs.guidesSettings.linkShown = false;
4651 cbradney 207
        appPrefs.guidesSettings.rulersShown = true;
7051 fschmid 208
        appPrefs.guidesSettings.showBleed = true;
2863 fschmid 209
        appPrefs.guidesSettings.rulerMode = true;
2835 cbradney 210
        appPrefs.guidesSettings.grabRad = 4;
211
        appPrefs.guidesSettings.guideRad = 10;
212
        appPrefs.guidesSettings.minorGrid = 20;
213
        appPrefs.guidesSettings.majorGrid = 100;
8528 cbradney 214
        appPrefs.guidesSettings.minorColor = QColor(Qt::green);
215
        appPrefs.guidesSettings.majorColor = QColor(Qt::green);
216
        appPrefs.guidesSettings.margColor = QColor(Qt::blue);
217
        appPrefs.guidesSettings.guideColor = QColor(Qt::darkBlue);
218
        appPrefs.guidesSettings.baseColor = QColor(Qt::lightGray);
2889 cbradney 219
        appPrefs.typographicSettings.valueSuperScript = 33;
9941 mrdocs 220
        appPrefs.typographicSettings.scalingSuperScript = 66;
2889 cbradney 221
        appPrefs.typographicSettings.valueSubScript = 33;
9941 mrdocs 222
        appPrefs.typographicSettings.scalingSubScript = 66;
2889 cbradney 223
        appPrefs.typographicSettings.valueSmallCaps = 75;
224
        appPrefs.typographicSettings.autoLineSpacing = 20;
225
        appPrefs.typographicSettings.valueUnderlinePos = -1;
226
        appPrefs.typographicSettings.valueUnderlineWidth = -1;
227
        appPrefs.typographicSettings.valueStrikeThruPos = -1;
228
        appPrefs.typographicSettings.valueStrikeThruWidth = -1;
229
        appPrefs.typographicSettings.valueBaseGrid = 14.4;
230
        appPrefs.typographicSettings.offsetBaseGrid = 0.0;
11115 subik 231
        appPrefs.GUI = "";
10200 cbradney 232
        appPrefs.grayscaleIcons = false; // can be a little slower on startup.. but its a nice effect to play with
4039 fschmid 233
        appPrefs.showToolTips = true;
12754 fschmid 234
        appPrefs.showMouseCoordinates = true;
5912 fschmid 235
        appPrefs.moveTimeout = 150;
7350 fschmid 236
        appPrefs.stickyTools = false;
2835 cbradney 237
        //FIXME
238
        //Black here causes issues when a colour set is loaded without "Black" in it.
239
        //"Black" is created with wrong values. Eg SVG colour set
240
        appPrefs.toolSettings.dPen = "Black";
15186 cbradney 241
        appPrefs.toolSettings.dBrush = CommonStrings::None;
2835 cbradney 242
        appPrefs.toolSettings.dShade = 100;
243
        appPrefs.toolSettings.dShade2 = 100;
8522 cbradney 244
        appPrefs.toolSettings.dLineArt = Qt::SolidLine;
15186 cbradney 245
        appPrefs.toolSettings.dWidth = 1;
2835 cbradney 246
        appPrefs.toolSettings.dPenLine = "Black";
247
        appPrefs.toolSettings.dPenText = "Black";
248
        appPrefs.toolSettings.dStrokeText = "Black";
4546 subik 249
        appPrefs.toolSettings.dTextBackGround = CommonStrings::None;
250
        appPrefs.toolSettings.dTextLineColor = CommonStrings::None;
3093 fschmid 251
        appPrefs.toolSettings.dTextBackGroundShade = 100;
252
        appPrefs.toolSettings.dTextLineShade = 100;
253
        appPrefs.toolSettings.dTextPenShade = 100;
254
        appPrefs.toolSettings.dTextStrokeShade = 100;
2835 cbradney 255
        appPrefs.toolSettings.tabFillChar = "";
256
        appPrefs.toolSettings.dTabWidth = 36.0;
6606 fschmid 257
        appPrefs.toolSettings.dispX = 10.0;
258
        appPrefs.toolSettings.dispY = 10.0;
6618 fschmid 259
        appPrefs.toolSettings.constrain = 15.0;
8528 cbradney 260
        appPrefs.DpapColor = QColor(Qt::white);
12476 cbradney 261
        appPrefs.showPageShadow = true;
8528 cbradney 262
        appPrefs.DFrameColor = QColor(Qt::red);
263
        appPrefs.DFrameNormColor = QColor(Qt::black);
264
        appPrefs.DFrameGroupColor = QColor(Qt::darkCyan);
265
        appPrefs.DFrameLockColor = QColor(Qt::darkRed);
266
        appPrefs.DFrameLinkColor = QColor(Qt::red);
267
        appPrefs.DFrameAnnotationColor = QColor(Qt::blue);
268
        appPrefs.DPageBorderColor = QColor(Qt::red);
269
        appPrefs.DControlCharColor = QColor(Qt::darkRed);
2835 cbradney 270
        appPrefs.toolSettings.dCols = 1;
271
        appPrefs.toolSettings.dGap = 0.0;
272
        appPrefs.toolSettings.dShadeLine = 100;
8522 cbradney 273
        appPrefs.toolSettings.dLstyleLine = Qt::SolidLine;
2835 cbradney 274
        appPrefs.toolSettings.dWidthLine = 1;
275
        appPrefs.toolSettings.dStartArrow = 0;
276
        appPrefs.toolSettings.dEndArrow = 0;
277
        appPrefs.toolSettings.magMin = 10;
278
        appPrefs.toolSettings.magMax = 3200;
4285 cbradney 279
        appPrefs.toolSettings.magStep = 200;
5510 cbradney 280
        appPrefs.toolSettings.dBrushPict = CommonStrings::None;
2835 cbradney 281
        appPrefs.toolSettings.shadePict = 100;
282
        appPrefs.toolSettings.scaleX = 1;
283
        appPrefs.toolSettings.scaleY = 1;
284
        appPrefs.guidesSettings.before = true;
285
        appPrefs.docUnitIndex = 0;
286
        appPrefs.toolSettings.polyC = 4;
287
        appPrefs.toolSettings.polyF = 0.5;
288
        appPrefs.toolSettings.polyS = false;
289
        appPrefs.toolSettings.polyFd = 0;
12885 fschmid 290
        appPrefs.toolSettings.polyR = 0.0;
291
        appPrefs.toolSettings.polyCurvature = 0.0;
4649 fschmid 292
//      appPrefs.PSize = 40;
4450 cbradney 293
        appPrefs.ClipMargin = false;
2835 cbradney 294
        appPrefs.GCRMode = false;
295
        appPrefs.RecentDocs.clear();
4735 fschmid 296
        appPrefs.RecentScrapbooks.clear();
2835 cbradney 297
        appPrefs.RecentDCount = 5;
5787 fschmid 298
        appPrefs.doCopyToScrapbook = true;
299
        appPrefs.persistentScrapbook = false;
300
        appPrefs.numScrapbookCopies = 10;
2835 cbradney 301
        appPrefs.marginColored = false;
302
        appPrefs.pageSize = "A4";
303
        appPrefs.pageOrientation = 0;
2865 cbradney 304
        PageSize a4("A4");
5785 cbradney 305
        appPrefs.PageWidth = a4.width();
306
        appPrefs.PageHeight = a4.height();
7225 cbradney 307
        appPrefs.margins.Top = 40;
308
        appPrefs.margins.Bottom = 40;
309
        appPrefs.margins.Left = 40;
310
        appPrefs.margins.Right = 40;
12334 fschmid 311
        appPrefs.marginPreset = 0;
7225 cbradney 312
        appPrefs.bleeds.Top = 0;
313
        appPrefs.bleeds.Left = 0;
314
        appPrefs.bleeds.Right = 0;
315
        appPrefs.bleeds.Bottom = 0;
2835 cbradney 316
        appPrefs.toolSettings.scaleType = true;
317
        appPrefs.toolSettings.aspectRatio = true;
318
        appPrefs.toolSettings.lowResType = 1;
319
        appPrefs.toolSettings.useEmbeddedPath = false;
320
        appPrefs.MinWordLen = 3;
321
        appPrefs.HyCount = 2;
322
        appPrefs.Language = "";
10170 fschmid 323
        appPrefs.specialWords.clear();
324
        appPrefs.ignoredWords.clear();
2835 cbradney 325
        appPrefs.Automatic = true;
326
        appPrefs.AutoCheck = false;
7864 fschmid 327
        appPrefs.AutoSave = true;
2835 cbradney 328
        appPrefs.AutoSaveTime = 600000;
12109 fschmid 329
 
330
        int dpi = qApp->desktop()->logicalDpiX();
331
        if ((dpi < 60) || (dpi > 200))
332
                dpi = 72;
333
        appPrefs.DisScale = dpi / 72.0;
334
 
335
//      appPrefs.DisScale = 1.0;
5917 jghali 336
        appPrefs.DocDir = ScPaths::getUserDocumentDir();
2835 cbradney 337
        appPrefs.ProfileDir = "";
338
        appPrefs.ScriptDir = "";
339
        appPrefs.documentTemplatesDir = "";
340
        appPrefs.CustomColorSets.clear();
341
        appPrefs.PrPr_Mode = false;
342
        appPrefs.Gcr_Mode = true;
6008 jghali 343
        appPrefs.PrPr_AntiAliasing = false;
2835 cbradney 344
        appPrefs.PrPr_Transparency = false;
345
        appPrefs.PrPr_C = true;
346
        appPrefs.PrPr_M = true;
347
        appPrefs.PrPr_Y = true;
348
        appPrefs.PrPr_K = true;
13153 fschmid 349
        appPrefs.PrPr_InkCoverage = false;
350
        appPrefs.PrPr_InkThreshold = 250;
2835 cbradney 351
        appPrefs.imageEditorExecutable = "gimp";
5418 cbradney 352
        appPrefs.extBrowserExecutable = "";
11506 mrdocs 353
        appPrefs.latexConfigs = LatexConfigCache::defaultConfigs();
12977 herm 354
        appPrefs.latexCommands.clear();
10228 avox 355
        appPrefs.latexEditorExecutable = "";
356
        appPrefs.latexResolution = 72;
11506 mrdocs 357
        appPrefs.latexForceDpi = true;
10618 cbradney 358
        appPrefs.latexStartWithEmptyFrames = false;
2835 cbradney 359
        appPrefs.gs_AntiAliasGraphics = true;
360
        appPrefs.gs_AntiAliasText = true;
2910 fschmid 361
        appPrefs.gs_exe = getGSDefaultExeName();
2835 cbradney 362
        appPrefs.gs_Resolution = 72;
8528 cbradney 363
        appPrefs.STEcolor = QColor(Qt::white);
2835 cbradney 364
        appPrefs.DCMSset.DefaultMonitorProfile = "";
365
        appPrefs.DCMSset.DefaultPrinterProfile = "";
2984 fschmid 366
        appPrefs.DCMSset.DefaultImageRGBProfile = "";
5345 mrdocs 367
        appPrefs.DCMSset.DefaultSolidColorRGBProfile = "";
368
        appPrefs.DCMSset.DefaultSolidColorCMYKProfile = "";
2835 cbradney 369
        appPrefs.DCMSset.CMSinUse = false;
370
        appPrefs.DCMSset.SoftProofOn = false;
5345 mrdocs 371
        appPrefs.DCMSset.SoftProofFullOn = false;
2835 cbradney 372
        appPrefs.DCMSset.GamutCheck = false;
373
        appPrefs.DCMSset.BlackPoint = true;
15706 jghali 374
        appPrefs.DCMSset.DefaultIntentColors = Intent_Relative_Colorimetric;
375
        appPrefs.DCMSset.DefaultIntentImages = Intent_Perceptual;
2835 cbradney 376
        appPrefs.GFontSub.clear();
8012 cbradney 377
        appPrefs.scratch.Left = 100;
378
        appPrefs.scratch.Right = 100;
379
        appPrefs.scratch.Top = 20;
380
        appPrefs.scratch.Bottom = 20;
11349 fschmid 381
        appPrefs.GapHorizontal = 0.0;
382
        appPrefs.GapVertical = 40.0;
3016 fschmid 383
        struct PageSet pageS;
4538 cbradney 384
        pageS.Name = CommonStrings::pageSet1;
3016 fschmid 385
        pageS.FirstPage = 0;
386
        pageS.Rows = 1;
387
        pageS.Columns = 1;
11349 fschmid 388
//      pageS.GapHorizontal = 0.0;
389
//      pageS.GapVertical = 0.0;
390
//      pageS.GapBelow = 40.0;
3026 fschmid 391
        pageS.pageNames.clear();
3016 fschmid 392
        appPrefs.pageSets.append(pageS);
4538 cbradney 393
        pageS.Name = CommonStrings::pageSet2;
3016 fschmid 394
        pageS.FirstPage = 1;
395
        pageS.Columns = 2;
3026 fschmid 396
        pageS.pageNames.clear();
4538 cbradney 397
        pageS.pageNames.append(CommonStrings::pageLocLeft);
398
        pageS.pageNames.append(CommonStrings::pageLocRight);
3016 fschmid 399
        appPrefs.pageSets.append(pageS);
4538 cbradney 400
        pageS.Name = CommonStrings::pageSet3;
3016 fschmid 401
        pageS.FirstPage = 0;
402
        pageS.Columns = 3;
3026 fschmid 403
        pageS.pageNames.clear();
4538 cbradney 404
        pageS.pageNames.append(CommonStrings::pageLocLeft);
405
        pageS.pageNames.append(CommonStrings::pageLocMiddle);
406
        pageS.pageNames.append(CommonStrings::pageLocRight);
3016 fschmid 407
        appPrefs.pageSets.append(pageS);
4538 cbradney 408
        pageS.Name = CommonStrings::pageSet4;
3016 fschmid 409
        pageS.FirstPage = 0;
410
        pageS.Columns = 4;
3026 fschmid 411
        pageS.pageNames.clear();
4538 cbradney 412
        pageS.pageNames.append(CommonStrings::pageLocLeft);
413
        pageS.pageNames.append(CommonStrings::pageLocMiddleLeft);
414
        pageS.pageNames.append(CommonStrings::pageLocMiddleRight);
415
        pageS.pageNames.append(CommonStrings::pageLocRight);
3016 fschmid 416
        appPrefs.pageSets.append(pageS);
417
        appPrefs.FacingPages = singlePage;
2835 cbradney 418
        appPrefs.askBeforeSubstituite = true;
419
        appPrefs.haveStylePreview = true;
420
        // lorem ipsum defaults
421
        appPrefs.useStandardLI = false;
422
        appPrefs.paragraphsLI = 10;
423
        appPrefs.showStartupDialog = true;
10225 subik 424
        appPrefs.useSmallWidgets = false;
3873 subik 425
        initDefaultCheckerPrefs(&appPrefs.checkerProfiles);
10096 jghali 426
        appPrefs.curCheckProfile = CommonStrings::PostScript;
2835 cbradney 427
        appPrefs.PDF_Options.Thumbnails = false;
428
        appPrefs.PDF_Options.Articles = false;
429
        appPrefs.PDF_Options.useLayers = false;
430
        appPrefs.PDF_Options.Compress = true;
11446 jghali 431
        appPrefs.PDF_Options.CompressMethod = PDFOptions::Compression_Auto;
2835 cbradney 432
        appPrefs.PDF_Options.Quality = 0;
433
        appPrefs.PDF_Options.RecalcPic = false;
13823 jghali 434
        appPrefs.PDF_Options.embedPDF  = false;
2835 cbradney 435
        appPrefs.PDF_Options.Bookmarks = false;
436
        appPrefs.PDF_Options.PicRes = 300;
437
        appPrefs.PDF_Options.Version = PDFOptions::PDFVersion_14;
438
        appPrefs.PDF_Options.Resolution = 300;
439
        appPrefs.PDF_Options.Binding = 0;
440
        appPrefs.PDF_Options.EmbedList.clear();
441
        appPrefs.PDF_Options.SubsetList.clear();
442
        appPrefs.PDF_Options.MirrorH = false;
443
        appPrefs.PDF_Options.MirrorV = false;
4649 fschmid 444
        appPrefs.PDF_Options.doClip = false;
2835 cbradney 445
        appPrefs.PDF_Options.RotateDeg = 0;
446
        appPrefs.PDF_Options.PresentMode = false;
11948 jghali 447
        appPrefs.PDF_Options.fileName = "";
2835 cbradney 448
        appPrefs.PDF_Options.PresentVals.clear();
449
        appPrefs.PDF_Options.isGrayscale = false;
450
        appPrefs.PDF_Options.UseRGB = true;
451
        appPrefs.PDF_Options.UseProfiles = false;
452
        appPrefs.PDF_Options.UseProfiles2 = false;
453
        appPrefs.PDF_Options.SolidProf = "";
454
        appPrefs.PDF_Options.SComp = 3;
455
        appPrefs.PDF_Options.ImageProf = "";
456
        appPrefs.PDF_Options.PrintProf = "";
457
        appPrefs.PDF_Options.Info = "";
458
        appPrefs.PDF_Options.Intent = 0;
459
        appPrefs.PDF_Options.Intent2 = 0;
7225 cbradney 460
        appPrefs.PDF_Options.bleeds.Top = 0;
461
        appPrefs.PDF_Options.bleeds.Left = 0;
462
        appPrefs.PDF_Options.bleeds.Right = 0;
463
        appPrefs.PDF_Options.bleeds.Bottom = 0;
10285 jghali 464
        appPrefs.PDF_Options.useDocBleeds = true;
6921 fschmid 465
        appPrefs.PDF_Options.cropMarks = false;
466
        appPrefs.PDF_Options.bleedMarks = false;
467
        appPrefs.PDF_Options.registrationMarks = false;
468
        appPrefs.PDF_Options.colorMarks = false;
469
        appPrefs.PDF_Options.docInfoMarks = false;
470
        appPrefs.PDF_Options.markOffset = 0;
2835 cbradney 471
        appPrefs.PDF_Options.EmbeddedI = false;
472
        appPrefs.PDF_Options.Encrypt = false;
473
        appPrefs.PDF_Options.PassOwner = "";
474
        appPrefs.PDF_Options.PassUser = "";
475
        appPrefs.PDF_Options.Permissions = -4;
476
        appPrefs.PDF_Options.UseLPI = false;
477
        appPrefs.PDF_Options.LPISettings.clear();
3079 fschmid 478
        appPrefs.PDF_Options.UseSpotColors = true;
479
        appPrefs.PDF_Options.doMultiFile = false;
4197 fschmid 480
        appPrefs.PDF_Options.displayBookmarks = false;
481
        appPrefs.PDF_Options.displayFullscreen = false;
482
        appPrefs.PDF_Options.displayLayers = false;
483
        appPrefs.PDF_Options.displayThumbs = false;
4201 fschmid 484
        appPrefs.PDF_Options.hideMenuBar = false;
485
        appPrefs.PDF_Options.hideToolBar = false;
486
        appPrefs.PDF_Options.fitWindow = false;
4197 fschmid 487
        appPrefs.PDF_Options.PageLayout = PDFOptions::SinglePage;
488
        appPrefs.PDF_Options.openAction = "";
2835 cbradney 489
 
490
        //Attribute setup
491
        appPrefs.defaultItemAttributes.clear();
492
        appPrefs.defaultToCSetups.clear();
5243 cbradney 493
 
494
        initDefaultActionKeys();
2835 cbradney 495
}
496
 
5243 cbradney 497
void PrefsManager::initDefaultActionKeys()
498
{
499
        ActionManager::createDefaultShortcuts();
5257 cbradney 500
        QMap<QString, QKeySequence > *map=ActionManager::defaultShortcuts();
5243 cbradney 501
        for( QMap<QString, QKeySequence >::ConstIterator it = map->begin(); it!=map->end(); ++it )
502
        {
503
                appPrefs.KeyActions[it.key()].actionName = it.key();
10516 cbradney 504
                appPrefs.KeyActions[it.key()].keySequence = it.value();
5243 cbradney 505
        }
506
}
507
 
10977 cbradney 508
void PrefsManager::applyLoadedShortCuts()
509
{
510
        for (QMap<QString,Keys>::Iterator it = appPrefs.KeyActions.begin(); it != appPrefs.KeyActions.end(); ++it )
511
        {
512
                if (!it.value().actionName.isEmpty())
513
                {
514
                        if (ScCore->primaryMainWindow()->scrActions[it.value().actionName])
515
                                ScCore->primaryMainWindow()->scrActions[it.value().actionName]->setShortcut(it.value().keySequence);
516
                }
517
        }
518
}
519
 
2835 cbradney 520
void PrefsManager::initDefaultGUIFont(const QFont& guiFont)
521
{
3873 subik 522
        appPrefs.AppFontSize = guiFont.pointSize();
523
        appPrefs.STEfont = guiFont.toString();
3940 tsoots 524
        appPrefs.PaletteFontSize = appPrefs.AppFontSize;
2835 cbradney 525
}
526
 
527
void PrefsManager::initArrowStyles()
528
{
529
        struct ArrowDesc arrow;
530
        FPointArray points;
8501 cbradney 531
        QMatrix arrowScaling;
2835 cbradney 532
        arrowScaling.scale(0.5, 0.5);
11176 fschmid 533
        QMatrix arrowRotate;
534
        arrowRotate.rotate(180);
2835 cbradney 535
        arrow.name = "Arrow1L";
536
        arrow.userArrow = false;
537
        points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
538
        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
539
        points.addQuadPoint(12, 0, 12, 0, 12, 0, 12, 0);
540
        points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
541
        points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
542
        arrow.points = points.copy();
543
        appPrefs.arrowStyles.append(arrow);
544
        arrow.name = "Arrow1M";
545
        points.map(arrowScaling);
546
        arrow.points = points.copy();
547
        appPrefs.arrowStyles.append(arrow);
548
        arrow.name = "Arrow1S";
549
        points.map(arrowScaling);
550
        arrow.points = points.copy();
551
        appPrefs.arrowStyles.append(arrow);
552
        arrow.name = "SquareL";
553
        points.resize(0);
554
        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
555
        points.addQuadPoint(5, -5, 5, -5, 5, -5, 5, -5);
556
        points.addQuadPoint(5, 5, 5, 5, 5, 5, 5, 5);
557
        points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
558
        points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
559
        arrow.points = points.copy();
560
        appPrefs.arrowStyles.append(arrow);
561
        arrow.name = "SquareM";
562
        points.map(arrowScaling);
563
        arrow.points = points.copy();
564
        appPrefs.arrowStyles.append(arrow);
565
        arrow.name = "SquareS";
566
        points.map(arrowScaling);
567
        arrow.points = points.copy();
568
        appPrefs.arrowStyles.append(arrow);
569
        arrow.name = "TriangleInL";
570
        points.resize(0);
571
        points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
572
        points.addQuadPoint(-2.88, 5, -2.88, 5, -2.88, 5, -2.88, 5);
573
        points.addQuadPoint(-2.88, -5, -2.88, -5, -2.88, -5, -2.88, -5);
574
        points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
575
        arrow.points = points.copy();
576
        appPrefs.arrowStyles.append(arrow);
577
        arrow.name = "TriangleInM";
578
        points.map(arrowScaling);
579
        arrow.points = points.copy();
580
        appPrefs.arrowStyles.append(arrow);
581
        arrow.name = "TriangleInS";
582
        points.map(arrowScaling);
583
        arrow.points = points.copy();
584
        appPrefs.arrowStyles.append(arrow);
585
        arrow.name = "TriangleOutL";
586
        points.resize(0);
587
        points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
588
        points.addQuadPoint(2.88, 5, 2.88, 5, 2.88, 5, 2.88, 5);
589
        points.addQuadPoint(2.88, -5, 2.88, -5, 2.88, -5, 2.88, -5);
590
        points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
591
        arrow.points = points.copy();
592
        appPrefs.arrowStyles.append(arrow);
593
        arrow.name = "TriangleOutM";
594
        points.map(arrowScaling);
595
        arrow.points = points.copy();
596
        appPrefs.arrowStyles.append(arrow);
597
        arrow.name = "TriangleOutS";
598
        points.map(arrowScaling);
599
        arrow.points = points.copy();
600
        appPrefs.arrowStyles.append(arrow);
11176 fschmid 601
        arrow.name = "DiamondL";
602
        points.resize(0);
603
        points.parseSVG("M 0, -7.0710768 L -7.0710894, 0 L 0, 7.0710589 L 7.0710462, 0 L 0,-7.0710768 z");
604
        arrow.points = points.copy();
605
        appPrefs.arrowStyles.append(arrow);
606
        arrow.name = "DiamondM";
607
        points.map(arrowScaling);
608
        arrow.points = points.copy();
609
        appPrefs.arrowStyles.append(arrow);
610
        arrow.name = "DiamondS";
611
        points.map(arrowScaling);
612
        arrow.points = points.copy();
613
        appPrefs.arrowStyles.append(arrow);
614
        points.resize(0);
615
        arrow.name = "DotL";
616
        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");
617
        points.translate(7.4, 1.0);
618
        arrow.points = points.copy();
619
        appPrefs.arrowStyles.append(arrow);
620
        arrow.name = "DotM";
621
        points.map(arrowScaling);
622
        arrow.points = points.copy();
623
        appPrefs.arrowStyles.append(arrow);
624
        arrow.name = "DotS";
625
        points.map(arrowScaling);
626
        arrow.points = points.copy();
627
        appPrefs.arrowStyles.append(arrow);
628
        points.resize(0);
629
        arrow.name = "SemiCircleInL";
630
        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");
631
        arrow.points = points.copy();
632
        appPrefs.arrowStyles.append(arrow);
633
        arrow.name = "SemiCircleInM";
634
        points.map(arrowScaling);
635
        arrow.points = points.copy();
636
        appPrefs.arrowStyles.append(arrow);
637
        arrow.name = "SemiCircleInS";
638
        points.map(arrowScaling);
639
        arrow.points = points.copy();
640
        appPrefs.arrowStyles.append(arrow);
641
        points.resize(0);
642
        arrow.name = "SemiCircleOutL";
643
        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");
644
        points.translate(7.125493, 0.763446);
645
        arrow.points = points.copy();
646
        appPrefs.arrowStyles.append(arrow);
647
        arrow.name = "SemiCircleOutM";
648
        points.map(arrowScaling);
649
        arrow.points = points.copy();
650
        appPrefs.arrowStyles.append(arrow);
651
        arrow.name = "SemiCircleOutS";
652
        points.map(arrowScaling);
653
        arrow.points = points.copy();
654
        appPrefs.arrowStyles.append(arrow);
655
        points.resize(0);
656
        arrow.name = "Arrow2L";
657
        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 658
        points.translate(-6.0, -0.016013256);
11176 fschmid 659
        points.map(arrowRotate);
660
        arrow.points = points.copy();
661
        appPrefs.arrowStyles.append(arrow);
662
        arrow.name = "Arrow2M";
663
        points.map(arrowScaling);
664
        arrow.points = points.copy();
665
        appPrefs.arrowStyles.append(arrow);
666
        arrow.name = "Arrow2S";
667
        points.map(arrowScaling);
668
        arrow.points = points.copy();
669
        appPrefs.arrowStyles.append(arrow);
670
        points.resize(0);
671
        arrow.name = "ScissorsL";
672
        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");
673
        points.map(arrowRotate);
674
        arrow.points = points.copy();
675
        appPrefs.arrowStyles.append(arrow);
676
        arrow.name = "ScissorsM";
677
        points.map(arrowScaling);
678
        arrow.points = points.copy();
679
        appPrefs.arrowStyles.append(arrow);
680
        arrow.name = "ScissorsS";
681
        points.map(arrowScaling);
682
        arrow.points = points.copy();
683
        appPrefs.arrowStyles.append(arrow);
684
        points.resize(0);
685
        arrow.name = "ClubL";
686
        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");
687
        points.map(arrowRotate);
688
        arrow.points = points.copy();
689
        appPrefs.arrowStyles.append(arrow);
690
        arrow.name = "ClubM";
691
        points.map(arrowScaling);
692
        arrow.points = points.copy();
693
        appPrefs.arrowStyles.append(arrow);
694
        arrow.name = "ClubS";
695
        points.map(arrowScaling);
696
        arrow.points = points.copy();
697
        appPrefs.arrowStyles.append(arrow);
12515 fschmid 698
        arrow.name = "LineL";
699
        points.resize(0);
700
        points.parseSVG("M 0, -5 L 1, -5 L 1, 5 L 0, 5 z");
701
        arrow.points = points.copy();
702
        appPrefs.arrowStyles.append(arrow);
703
        arrow.name = "LineM";
704
        points.map(arrowScaling);
705
        arrow.points = points.copy();
706
        appPrefs.arrowStyles.append(arrow);
707
        arrow.name = "LineS";
708
        points.map(arrowScaling);
709
        arrow.points = points.copy();
710
        appPrefs.arrowStyles.append(arrow);
711
        points.resize(0);
2835 cbradney 712
}
713
 
714
QString PrefsManager::setupPreferencesLocation()
715
{
16576 craig 716
        QString appDataDir(QDir::toNativeSeparators(ScPaths::getApplicationDataDir()));
16451 craig 717
        QFileInfo fiAppDataDir = QFileInfo(appDataDir);
718
        QString prefsLoc;
13171 cbradney 719
        //If we are using the ScPaths default prefs location
16451 craig 720
        if (fiAppDataDir.exists())
2835 cbradney 721
        {
16451 craig 722
                if (fiAppDataDir.isDir())
723
                        prefsLoc = appDataDir;
2835 cbradney 724
                else
16451 craig 725
                        prefsLoc = QDir::homePath();
2835 cbradney 726
        }
13171 cbradney 727
        else // Move to using the ScPaths default prefs location/scribus.* from ~/.scribus.*
2835 cbradney 728
        {
729
                QDir prefsDirectory = QDir();
16451 craig 730
                prefsDirectory.mkdir(appDataDir);
731
                prefsLoc = appDataDir;
16576 craig 732
                QString oldPR = QDir::toNativeSeparators(QDir::homePath()+"/.scribus.rc");
2835 cbradney 733
                QFileInfo oldPi = QFileInfo(oldPR);
734
                if (oldPi.exists())
16451 craig 735
                        moveFile(oldPR, appDataDir+"scribus.rc");
16576 craig 736
                QString oldPR2 = QDir::toNativeSeparators(QDir::homePath()+"/.scribusfont.rc");
2835 cbradney 737
                QFileInfo oldPi2 = QFileInfo(oldPR2);
738
                if (oldPi2.exists())
16451 craig 739
                        moveFile(oldPR2, appDataDir+"scribusfont.rc");
16576 craig 740
                QString oldPR3 = QDir::toNativeSeparators(QDir::homePath()+"/.scribusscrap.scs");
2835 cbradney 741
                QFileInfo oldPi3 = QFileInfo(oldPR3);
742
                if (oldPi3.exists())
16451 craig 743
                        moveFile(oldPR3, appDataDir+"scrap.scs");
2835 cbradney 744
        }
16576 craig 745
        QString scB = QDir::toNativeSeparators(appDataDir+"scrapbook");
4611 fschmid 746
        QFileInfo scBi = QFileInfo(scB);
747
        if (!scBi.exists())
748
        {
749
                QDir scrapDirectory = QDir();
750
                scrapDirectory.mkdir(scB);
751
                QDir scrapMainDirectory = QDir();
16576 craig 752
                scrapDirectory.mkdir(QDir::toNativeSeparators(scB+"/main"));
4611 fschmid 753
        }
16576 craig 754
        QFileInfo scTmp = QFileInfo(QDir::toNativeSeparators(scB+"/tmp"));
5760 fschmid 755
        if (!scTmp.exists())
756
        {
757
                QDir scrapDirectoryT = QDir();
16576 craig 758
                scrapDirectoryT.mkdir(QDir::toNativeSeparators(scB+"/tmp"));
5760 fschmid 759
        }
17077 jghali 760
        QFileInfo scSwatch = QFileInfo(ScPaths::getApplicationDataDir()+"swatches");
761
        if (!scSwatch.exists())
762
        {
763
                QDir swatchDir = QDir();
764
                swatchDir.mkpath(ScPaths::getApplicationDataDir()+"swatches");
765
                swatchDir.mkpath(ScPaths::getApplicationDataDir()+"swatches/locked");
766
        }
767
        prefsLocation = prefsLoc;
16451 craig 768
        return prefsLoc;
2835 cbradney 769
}
770
 
771
const QString PrefsManager::preferencesLocation()
772
{
773
        return prefsLocation;
774
}
775
 
5200 cbradney 776
bool PrefsManager::copyOldPreferences()
2835 cbradney 777
{
16451 craig 778
        //Now make copies for 1.4.0 use and leave the old ones alone for <1.3.0 usage
779
        QString prefs12[4], prefs130[4], prefs134[4], prefs135[4], prefs140[4];
3152 craig 780
 
781
        // Special case for scribus.rc - if found, use scribus123.rc,
782
        // otherwise fall back to the possibly mis-encoded scribus.rc .
16576 craig 783
        prefs12[0]=QDir::toNativeSeparators(prefsLocation+"scribus123.rc");
5200 cbradney 784
        if (!QFile::exists(prefs12[0]))
16451 craig 785
                prefs12[0] = prefsLocation+"scribus.rc";
16576 craig 786
        prefs12[1]=QDir::toNativeSeparators(prefsLocation+"scrap.scs");
787
        prefs12[2]=QDir::toNativeSeparators(prefsLocation+"prefs.xml");
788
        prefs12[3]=QDir::toNativeSeparators(prefsLocation+"scripter.rc");
789
        prefs130[0]=QDir::toNativeSeparators(prefsLocation+"scribus13.rc");
790
        prefs130[1]=QDir::toNativeSeparators(prefsLocation+"scrap13.scs");
791
        prefs130[2]=QDir::toNativeSeparators(prefsLocation+"prefs13.xml");
792
        prefs130[3]=QDir::toNativeSeparators(prefsLocation+"scripter13.rc");
793
        prefs134[0]=QDir::toNativeSeparators(prefsLocation+"scribus134.rc");
794
        prefs134[1]=QDir::toNativeSeparators(prefsLocation+"scrap134.scs");
795
        prefs134[2]=QDir::toNativeSeparators(prefsLocation+"prefs134.xml");
796
        prefs134[3]=QDir::toNativeSeparators(prefsLocation+"scripter134.rc");
797
        prefs135[0]=QDir::toNativeSeparators(prefsLocation+"scribus135.rc");
798
        prefs135[1]=QDir::toNativeSeparators(prefsLocation+"scrap135.scs");
799
        prefs135[2]=QDir::toNativeSeparators(prefsLocation+"prefs135.xml");
800
        prefs135[3]=QDir::toNativeSeparators(prefsLocation+"scripter135.rc");
801
        prefs140[0]=QDir::toNativeSeparators(prefsLocation+"scribus140.rc");
802
        prefs140[1]=QDir::toNativeSeparators(prefsLocation+"scrap140.scs");
803
        prefs140[2]=QDir::toNativeSeparators(prefsLocation+"prefs140.xml");
804
        prefs140[3]=QDir::toNativeSeparators(prefsLocation+"scripter140.rc");
3152 craig 805
 
16451 craig 806
        bool existsPrefs12[4], existsPrefs130[4], existsPrefs134[4], existsPrefs135[4], existsPrefs140[4];
3156 craig 807
        for (uint i=0;i<4;++i)
2835 cbradney 808
        {
5200 cbradney 809
                existsPrefs12[i]=QFile::exists(prefs12[i]);
810
                existsPrefs130[i]=QFile::exists(prefs130[i]);
811
                existsPrefs134[i]=QFile::exists(prefs134[i]);
8673 cbradney 812
                existsPrefs135[i]=QFile::exists(prefs135[i]);
16451 craig 813
                existsPrefs140[i]=QFile::exists(prefs140[i]);
2835 cbradney 814
        }
815
 
816
        bool retVal=false;
16451 craig 817
        if (existsPrefs140[0] && existsPrefs140[2])
5200 cbradney 818
                return retVal;
16451 craig 819
 
8673 cbradney 820
        //Only check for these three as they will be autocreated if they dont exist.
16451 craig 821
        if( (existsPrefs12[0] && !existsPrefs130[0] && !existsPrefs134[0] && !existsPrefs135[0]) || (existsPrefs12[2] && !existsPrefs130[2] && !existsPrefs134[2] && !existsPrefs135[2]) )
2835 cbradney 822
        {
823
                retVal=true; // converting from 1.2 prefs
5243 cbradney 824
                if (ScCore->usingGUI())
2835 cbradney 825
                {
5656 cbradney 826
                        bool splashShown=ScCore->splashShowing();
827
                        if (splashShown)
828
                                ScCore->showSplash(false);
5781 cbradney 829
                        if ( (ScMessageBox::question( ScCore->primaryMainWindow(), tr("Migrate Old Scribus Settings?"),
2835 cbradney 830
                                tr("Scribus has detected existing Scribus 1.2 preferences files.\n"
831
                                                "Do you want to migrate them to the new Scribus version?"),
832
                                QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::NoButton))==QMessageBox::Yes )
833
                        {
834
                                for (uint i=0;i<4;++i)
835
                                {
16451 craig 836
                                        if (existsPrefs12[i] && !existsPrefs140[i])
837
                                                copyFile(prefs12[i], prefs140[i]);
2835 cbradney 838
                                }
839
                        }
5656 cbradney 840
                        if (splashShown)
841
                                ScCore->showSplash(true);
2835 cbradney 842
                }
843
        }
5200 cbradney 844
        else
16451 craig 845
        if(existsPrefs135[0])
846
        {
847
                for (uint i=0;i<4;++i)
848
                {
849
                        if (existsPrefs135[i] && !existsPrefs140[i])
850
                                copyFile(prefs135[i], prefs140[i]);
851
                }
852
        }
853
        else
8673 cbradney 854
        if(existsPrefs134[0])
855
        {
856
                for (uint i=0;i<4;++i)
857
                {
16451 craig 858
                        if (existsPrefs134[i] && !existsPrefs140[i])
859
                                copyFile(prefs134[i], prefs140[i]);
8673 cbradney 860
                }
861
        }
862
        else
5200 cbradney 863
        if(existsPrefs130[0])
864
        {
865
                for (uint i=0;i<4;++i)
866
                {
16451 craig 867
                        if (existsPrefs130[i] && !existsPrefs140[i])
868
                                copyFile(prefs130[i], prefs140[i]);
5200 cbradney 869
                }
870
        }
2835 cbradney 871
        return retVal;
872
}
873
 
2856 cbradney 874
void PrefsManager::convert12Preferences()
2835 cbradney 875
{
876
        // Import 1.2 font search path prefs
16576 craig 877
        QFile fontPrefsFile12(QDir::toNativeSeparators(prefsLocation+"/scribusfont.rc"));
8501 cbradney 878
        if (fontPrefsFile12.open(QIODevice::ReadOnly))
2835 cbradney 879
        {
2856 cbradney 880
                PrefsContext *pc = prefsFile->getContext("Fonts");
2835 cbradney 881
                PrefsTable *fontPrefs = pc->getTable("ExtraFontDirs");
10004 fschmid 882
                QTextStream tsx(&fontPrefsFile12);
883
                QString extraPath = tsx.readAll();
2835 cbradney 884
                fontPrefsFile12.close();
10603 fschmid 885
                QStringList extraFonts = extraPath.split("\n", QString::SkipEmptyParts);
8528 cbradney 886
                for (int i = 0; i < extraFonts.count(); ++i)
2835 cbradney 887
                        fontPrefs->set(i, 0, extraFonts[i]);
888
        }
889
}
2859 cbradney 890
 
3873 subik 891
void PrefsManager::ReadPrefs(const QString & fname)
2859 cbradney 892
{
3873 subik 893
        QString realFile;
894
        if (fname.isNull())
16451 craig 895
                realFile = prefsLocation + "/scribus140.rc";
3873 subik 896
        else
897
                realFile = fname;
898
 
899
        if (QFile::exists(realFile))
900
        {
901
                if (!ReadPref(realFile))
3171 craig 902
                {
903
                        alertLoadPrefsFailed();
904
                        return;
905
                }
3873 subik 906
        }
5243 cbradney 907
}
3873 subik 908
 
5243 cbradney 909
void PrefsManager::setupMainWindow(ScribusMainWindow* mw)
910
{
911
        mw->setDefaultPrinter(appPrefs.PrinterName, appPrefs.PrinterFile, appPrefs.PrinterCommand);
2859 cbradney 912
 
8562 jghali 913
        uint max = qMin(appPrefs.RecentDCount, appPrefs.RecentDocs.count());
2859 cbradney 914
        for (uint m = 0; m < max; ++m)
915
        {
916
                QFileInfo fd(appPrefs.RecentDocs[m]);
917
                if (fd.exists())
918
                {
5243 cbradney 919
                        mw->RecentDocs.append(appPrefs.RecentDocs[m]);
16668 craig 920
                        //#9845: ScCore->fileWatcher->addFile(appPrefs.RecentDocs[m]);
2859 cbradney 921
                }
922
        }
5243 cbradney 923
        mw->rebuildRecentFileMenu();
924
        mw->move(appPrefs.mainWinSettings.xPosition, appPrefs.mainWinSettings.yPosition);
925
        mw->resize(appPrefs.mainWinSettings.width, appPrefs.mainWinSettings.height);
4892 cbradney 926
        if (appPrefs.mainWinSettings.maximized)
10550 avox 927
                mw->setWindowState((ScCore->primaryMainWindow()->windowState() & ~Qt::WindowMinimized) | Qt::WindowMaximized);
13482 cbradney 928
        //For 1.3.5, we dump prefs first time around.
929
        if (!firstTimeIgnoreOldPrefs)
930
                ReadPrefsXML();
2859 cbradney 931
        if (appPrefs.checkerProfiles.count() == 0)
932
        {
3873 subik 933
                initDefaultCheckerPrefs(&appPrefs.checkerProfiles);
10096 jghali 934
                appPrefs.curCheckProfile = CommonStrings::PostScript;
2859 cbradney 935
        }
10256 fschmid 936
        if (!appPrefs.mainWinState.isEmpty())
937
        {
10531 avox 938
                mw->restoreState(appPrefs.mainWinState);
10256 fschmid 939
        }
2859 cbradney 940
}
941
 
942
void PrefsManager::ReadPrefsXML()
943
{
10256 fschmid 944
        if (prefsFile)
945
        {
946
                PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
947
                if (userprefsContext)
948
                {
949
                        appPrefs.guiLanguage = userprefsContext->get("gui_language","");
10531 avox 950
                        appPrefs.mainWinState = QByteArray::fromBase64(userprefsContext->get("mainwinstate","").toAscii());
2859 cbradney 951
            //continue here...
952
            //Prefs."blah blah" =...
10256 fschmid 953
                }
12104 jghali 954
                if (prefsFile->hasContext("print_options"))
955
                {
956
                        // Reset copies number to 1 when user start new session
957
                        PrefsContext* printOptionsContext = prefsFile->getContext("print_options");
958
                        if (printOptionsContext)
959
                                printOptionsContext->set("Copies", 1);
960
                }
10256 fschmid 961
        }
2859 cbradney 962
}
963
 
964
 
3873 subik 965
void PrefsManager::SavePrefs(const QString & fname)
2859 cbradney 966
{
967
        // If closing because of a crash don't save prefs as we can
968
        // accidentally nuke the settings if the crash is before prefs are loaded
3170 craig 969
        // The caller is responsible for ensuring we aren't called under those
970
        // conditions.
971
        Q_ASSERT(!emergencyActivated);
5781 cbradney 972
        appPrefs.mainWinSettings.xPosition = abs(ScCore->primaryMainWindow()->pos().x());
973
        appPrefs.mainWinSettings.yPosition = abs(ScCore->primaryMainWindow()->pos().y());
974
        appPrefs.mainWinSettings.width = ScCore->primaryMainWindow()->size().width();
975
        appPrefs.mainWinSettings.height = ScCore->primaryMainWindow()->size().height();
976
        appPrefs.mainWinSettings.maximized = ScCore->primaryMainWindow()->isMaximized();
10531 avox 977
        appPrefs.mainWinState = ScCore->primaryMainWindow()->saveState();
2859 cbradney 978
        appPrefs.RecentDocs.clear();
8562 jghali 979
        uint max = qMin(appPrefs.RecentDCount, ScCore->primaryMainWindow()->RecentDocs.count());
2859 cbradney 980
        for (uint m = 0; m < max; ++m)
981
        {
5781 cbradney 982
                appPrefs.RecentDocs.append(ScCore->primaryMainWindow()->RecentDocs[m]);
2859 cbradney 983
        }
11031 jghali 984
        ScCore->primaryMainWindow()->getDefaultPrinter(appPrefs.PrinterName, appPrefs.PrinterFile, appPrefs.PrinterCommand);
3170 craig 985
        SavePrefsXML();
3873 subik 986
        QString realFile;
987
        if (fname.isNull())
16451 craig 988
                realFile = prefsLocation+"/scribus140.rc";
3873 subik 989
        else
990
                realFile = fname;
991
        if (!WritePref(realFile))
3170 craig 992
                alertSavePrefsFailed();
5257 cbradney 993
        emit prefsChanged();
2859 cbradney 994
}
995
 
996
void PrefsManager::SavePrefsXML()
997
{
10256 fschmid 998
        if (prefsFile)
999
        {
1000
                PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
1001
                if (userprefsContext)
1002
                {
10531 avox 1003
                        userprefsContext->set("gui_language", appPrefs.guiLanguage);
1004
                        userprefsContext->set("mainwinstate", QString::fromAscii(appPrefs.mainWinState.toBase64()));
2859 cbradney 1005
            //continue here...
1006
            //Prefs."blah blah" =...
10256 fschmid 1007
                }
1008
                prefsFile->write();
1009
        }
2859 cbradney 1010
}
2862 cbradney 1011
 
1012
void PrefsManager::setGhostscriptExecutable(const QString& executableName)
1013
{
1014
        appPrefs.gs_exe=executableName;
1015
}
1016
 
1017
void PrefsManager::setImageEditorExecutable(const QString& executableName)
1018
{
1019
        appPrefs.imageEditorExecutable=executableName;
1020
}
1021
 
5418 cbradney 1022
void PrefsManager::setExtBrowserExecutable(const QString& executableName)
2862 cbradney 1023
{
5418 cbradney 1024
        appPrefs.extBrowserExecutable=executableName;
2862 cbradney 1025
}
1026
 
11506 mrdocs 1027
void PrefsManager::setLatexConfigs(const QStringList& configs)
10228 avox 1028
{
11506 mrdocs 1029
        appPrefs.latexConfigs=configs;
10228 avox 1030
}
1031
 
1032
void PrefsManager::setLatexEditorExecutable(const QString& executableName)
1033
{
1034
        appPrefs.latexEditorExecutable=executableName;
1035
}
1036
 
2871 cbradney 1037
const QString PrefsManager::documentDir()
1038
{
1039
        return appPrefs.DocDir;
1040
}
1041
 
3931 subik 1042
void PrefsManager::setDocumentDir(const QString& dirname)
1043
{
1044
        appPrefs.DocDir = dirname;
1045
}
1046
 
10509 cbradney 1047
int PrefsManager::mouseWheelValue() const
2871 cbradney 1048
{
1049
        return appPrefs.Wheelval;
1050
}
1051
 
2870 cbradney 1052
//Changed to return false when we have no fonts
6700 cbradney 1053
bool PrefsManager::GetAllFonts(bool showFontInfo)
2870 cbradney 1054
{
1055
        appPrefs.AvailFonts.GetFonts(prefsLocation, showFontInfo);
6700 cbradney 1056
        return !appPrefs.AvailFonts.isEmpty();
2870 cbradney 1057
}
2871 cbradney 1058
 
1059
void PrefsManager::setShowStartupDialog(const bool showDialog)
1060
{
1061
        appPrefs.showStartupDialog=showDialog;
1062
}
1063
 
1064
const ColorList& PrefsManager::colorSet()
1065
{
1066
        return appPrefs.DColors;
1067
}
1068
 
1069
ColorList* PrefsManager::colorSetPtr()
1070
{
1071
        return &appPrefs.DColors;
1072
}
1073
 
1074
const QString& PrefsManager::colorSetName()
1075
{
1076
        return appPrefs.DColorSet;
1077
}
1078
 
7718 jghali 1079
bool PrefsManager::isToolColor(const QString& name)
1080
{
1081
        return isToolColor(appPrefs.toolSettings, name);
1082
}
1083
 
1084
bool PrefsManager::isToolColor(const struct toolPrefs& settings, const QString& name)
1085
{
1086
        if (settings.dPenText == name)
1087
                return true;
1088
        if (settings.dStrokeText == name)
1089
                return true;
1090
        if (settings.dTextBackGround == name)
1091
                return true;
1092
        if (settings.dTextLineColor == name)
1093
                return true;
1094
        if (settings.dPen == name)
1095
                return true;
1096
        if (settings.dBrush == name)
1097
                return true;
1098
        if (settings.dPenLine == name)
1099
                return true;
1100
        if (settings.dBrushPict == name)
1101
                return true;
1102
        return false;
1103
}
1104
 
1105
QStringList PrefsManager::toolColorNames()
1106
{
1107
        return toolColorNames(appPrefs.toolSettings);
1108
}
1109
 
1110
QStringList PrefsManager::toolColorNames(const struct toolPrefs& settings)
1111
{
1112
        QStringList names;
1113
        names.append(settings.dPenText);
1114
        if (!names.contains(settings.dStrokeText))
1115
                names.append(settings.dStrokeText);
1116
        if (!names.contains(settings.dTextBackGround))
1117
                names.append(settings.dTextBackGround);
1118
        if (!names.contains(settings.dTextLineColor))
1119
                names.append(settings.dTextLineColor);
1120
        if (!names.contains(settings.dPen))
1121
                names.append(settings.dPen);
1122
        if (!names.contains(settings.dBrush))
1123
                names.append(settings.dBrush);
1124
        if (!names.contains(settings.dPenLine))
1125
                names.append(settings.dPenLine);
1126
        if (!names.contains(settings.dBrushPict))
1127
                names.append(settings.dBrushPict);
1128
        return names;
1129
}
1130
 
1131
void PrefsManager::replaceToolColors(const QMap<QString, QString> replaceMap)
1132
{
1133
        replaceToolColors(appPrefs.toolSettings, replaceMap);
1134
}
1135
 
1136
void PrefsManager::replaceToolColors(struct toolPrefs& settings, const QMap<QString, QString> replaceMap)
1137
{
1138
        if (replaceMap.contains(settings.dPenText))
1139
                settings.dPenText = replaceMap[settings.dPenText];
1140
        if (replaceMap.contains(settings.dStrokeText))
1141
                settings.dStrokeText = replaceMap[settings.dStrokeText];
1142
        if (replaceMap.contains(settings.dTextBackGround))
1143
                settings.dTextBackGround = replaceMap[settings.dTextBackGround];
1144
        if (replaceMap.contains(settings.dTextLineColor))
1145
                settings.dTextLineColor = replaceMap[settings.dTextLineColor];
1146
        if (replaceMap.contains(settings.dPen))
1147
                settings.dPen = replaceMap[settings.dPen];
1148
        if (replaceMap.contains(settings.dBrush))
1149
                settings.dBrush = replaceMap[settings.dBrush];
1150
        if (replaceMap.contains(settings.dPenLine))
1151
                settings.dPenLine = replaceMap[settings.dPenLine];
1152
        if (replaceMap.contains(settings.dBrushPict))
1153
                settings.dBrushPict = replaceMap[settings.dBrushPict];
1154
}
1155
 
2871 cbradney 1156
void PrefsManager::setColorSet(const ColorList& colorSet)
1157
{
7718 jghali 1158
        // Color set may have changed and tools color not be present in the new color set
1159
        ColorList tmpSet = colorSet;
1160
        QString penText = appPrefs.toolSettings.dPenText;
1161
        if (!tmpSet.contains(penText) && penText != CommonStrings::None)
1162
                tmpSet[penText] = appPrefs.DColors[penText];
1163
        QString strokeText = appPrefs.toolSettings.dStrokeText;
1164
        if (!tmpSet.contains(strokeText) && strokeText != CommonStrings::None)
1165
                tmpSet[strokeText] = appPrefs.DColors[strokeText];
1166
        QString textBackGround = appPrefs.toolSettings.dTextBackGround;
1167
        if (!tmpSet.contains(textBackGround) && textBackGround != CommonStrings::None)
1168
                tmpSet[textBackGround] = appPrefs.DColors[textBackGround];
1169
        QString textLineColor = appPrefs.toolSettings.dTextLineColor;
1170
        if (!tmpSet.contains(textLineColor) && textLineColor != CommonStrings::None)
1171
                tmpSet[textLineColor] = appPrefs.DColors[textLineColor];
1172
        QString pen = appPrefs.toolSettings.dPen;
1173
        if (!tmpSet.contains(pen) && pen != CommonStrings::None)
1174
                tmpSet[pen] = appPrefs.DColors[pen];
1175
        QString brush = appPrefs.toolSettings.dBrush;
1176
        if (!tmpSet.contains(brush) && brush != CommonStrings::None)
1177
                tmpSet[brush] = appPrefs.DColors[brush];
1178
        QString penLine = appPrefs.toolSettings.dPenLine;
1179
        if (!tmpSet.contains(penLine) && penLine != CommonStrings::None)
1180
                tmpSet[penLine] = appPrefs.DColors[penLine];
1181
        QString brushPict = appPrefs.toolSettings.dBrushPict;
1182
        if (!tmpSet.contains(brushPict) && brushPict != CommonStrings::None)
1183
                tmpSet[brushPict] = appPrefs.DColors[brushPict];
1184
        appPrefs.DColors = tmpSet;
2871 cbradney 1185
}
1186
 
1187
void PrefsManager::setColorSetName(const QString& colorSetName)
1188
{
1189
        appPrefs.DColorSet=colorSetName;
1190
}
2873 cbradney 1191
 
1192
 
3932 avox 1193
void PrefsManager::setKeyEntry(const QString& actName, const QString& cleanMenuText, const QKeySequence& keyseq, const int& rowNumber)
2873 cbradney 1194
{
1195
        Keys ke;
2877 cbradney 1196
        if (!actName.isEmpty())
2873 cbradney 1197
        {
5781 cbradney 1198
                if (ScCore->primaryMainWindow()->scrActions[actName])
2873 cbradney 1199
                {
1200
                        ke.actionName=actName;
1201
                        ke.keySequence = keyseq;
1202
                        ke.cleanMenuText=cleanMenuText;
1203
                        ke.tableRow=rowNumber;
1204
                        appPrefs.KeyActions.insert(actName, ke);
1205
                }
1206
                else
10553 fschmid 1207
                        qDebug("%s", QString("Action Name: %1 does not exist").arg(actName).toAscii().constData());
2873 cbradney 1208
        }
1209
}
1210
 
10509 cbradney 1211
double PrefsManager::displayScale() const
2873 cbradney 1212
{
1213
        return appPrefs.DisScale;
1214
}
1215
 
10390 cbradney 1216
const QString& PrefsManager::guiLanguage() const
2873 cbradney 1217
{
1218
        return appPrefs.guiLanguage;
1219
}
1220
 
10390 cbradney 1221
const QString& PrefsManager::guiStyle() const
2873 cbradney 1222
{
1223
        return appPrefs.GUI;
1224
}
1225
 
11115 subik 1226
const QString& PrefsManager::guiSystemStyle() const
1227
{
1228
        return appPrefs.GUIsystem;
1229
}
1230
 
10390 cbradney 1231
const int& PrefsManager::guiFontSize() const
2873 cbradney 1232
{
1233
        return appPrefs.AppFontSize;
1234
}
2889 cbradney 1235
 
10390 cbradney 1236
const int& PrefsManager::paletteFontSize() const
3940 tsoots 1237
{
1238
        return appPrefs.PaletteFontSize;
1239
}
1240
 
12476 cbradney 1241
bool PrefsManager::showPageShadow() const
1242
{
1243
        return appPrefs.showPageShadow;
1244
}
1245
 
16451 craig 1246
bool PrefsManager::WritePref(QString filename)
2889 cbradney 1247
{
1248
        QDomDocument docu("scribusrc");
1249
        QString st="<SCRIBUSRC></SCRIBUSRC>";
1250
        docu.setContent(st);
1251
        QDomElement elem=docu.documentElement();
16451 craig 1252
        elem.setAttribute("VERSION","1.4.0");
2889 cbradney 1253
        QDomElement dc=docu.createElement("GUI");
1254
        dc.setAttribute("STILT",appPrefs.GUI);
1255
        dc.setAttribute("RAD",appPrefs.Wheelval);
5912 fschmid 1256
        dc.setAttribute("MOVT", appPrefs.moveTimeout);
2889 cbradney 1257
        dc.setAttribute("APF",appPrefs.AppFontSize);
3940 tsoots 1258
        dc.setAttribute("PFS",appPrefs.PaletteFontSize);
2889 cbradney 1259
        dc.setAttribute("GRAB",appPrefs.guidesSettings.grabRad);
1260
        dc.setAttribute("UNIT",appPrefs.docUnitIndex);
1261
        dc.setAttribute("RCD", appPrefs.RecentDCount);
1262
        dc.setAttribute("DOC", appPrefs.DocDir);
1263
        dc.setAttribute("PROFILES", appPrefs.ProfileDir);
1264
        dc.setAttribute("SCRIPTS", appPrefs.ScriptDir);
1265
        dc.setAttribute("TEMPLATES", appPrefs.documentTemplatesDir);
1266
        dc.setAttribute("SHOWGUIDES", static_cast<int>(appPrefs.guidesSettings.guidesShown));
5384 cbradney 1267
        dc.setAttribute("showcolborders", static_cast<int>(appPrefs.guidesSettings.colBordersShown));
2889 cbradney 1268
        dc.setAttribute("FRV", static_cast<int>(appPrefs.guidesSettings.framesShown));
5584 fschmid 1269
        dc.setAttribute("SHOWLAYERM", static_cast<int>(appPrefs.guidesSettings.layerMarkersShown));
2889 cbradney 1270
        dc.setAttribute("SHOWMARGIN", static_cast<int>(appPrefs.guidesSettings.marginsShown));
1271
        dc.setAttribute("SHOWBASE", static_cast<int>(appPrefs.guidesSettings.baseShown));
1272
        dc.setAttribute("SHOWLINK", static_cast<int>(appPrefs.guidesSettings.linkShown));
1273
        dc.setAttribute("SHOWPICT", static_cast<int>(appPrefs.guidesSettings.showPic));
1274
        dc.setAttribute("SHOWControl", static_cast<int>(appPrefs.guidesSettings.showControls));
4651 cbradney 1275
        dc.setAttribute("rulersShown", static_cast<int>(appPrefs.guidesSettings.rulersShown));
7051 fschmid 1276
        dc.setAttribute("showBleed", static_cast<int>(appPrefs.guidesSettings.showBleed));
2889 cbradney 1277
        dc.setAttribute("rulerMode", static_cast<int>(appPrefs.guidesSettings.rulerMode));
8012 cbradney 1278
        dc.setAttribute("ScratchBottom", appPrefs.scratch.Bottom);
1279
        dc.setAttribute("ScratchLeft", appPrefs.scratch.Left);
1280
        dc.setAttribute("ScratchRight", appPrefs.scratch.Right);
1281
        dc.setAttribute("ScratchTop", appPrefs.scratch.Top);
13470 cbradney 1282
        dc.setAttribute("GapHorizontal", ScCLocale::toQStringC(appPrefs.GapHorizontal));
1283
        dc.setAttribute("GapVertical", ScCLocale::toQStringC(appPrefs.GapVertical));
2889 cbradney 1284
        dc.setAttribute("STECOLOR", appPrefs.STEcolor.name());
1285
        dc.setAttribute("STEFONT", appPrefs.STEfont);
1286
        dc.setAttribute("STYLEPREVIEW", static_cast<int>(appPrefs.haveStylePreview));
1287
        dc.setAttribute("StartUp", static_cast<int>(appPrefs.showStartupDialog));
10225 subik 1288
        dc.setAttribute("UseSmallWidgets", static_cast<int>(appPrefs.useSmallWidgets));
4039 fschmid 1289
        dc.setAttribute("ToolTips", static_cast<int>(appPrefs.showToolTips));
12754 fschmid 1290
        dc.setAttribute("showMouseCoordinates", static_cast<int>(appPrefs.showMouseCoordinates));
7350 fschmid 1291
        dc.setAttribute("stickyTools", static_cast<int>(appPrefs.stickyTools));
2889 cbradney 1292
        elem.appendChild(dc);
1293
        QDomElement dc1=docu.createElement("GRID");
13470 cbradney 1294
        dc1.setAttribute("MINOR",ScCLocale::toQStringC(appPrefs.guidesSettings.minorGrid));
1295
        dc1.setAttribute("MAJOR",ScCLocale::toQStringC(appPrefs.guidesSettings.majorGrid));
2889 cbradney 1296
        dc1.setAttribute("MINORC",appPrefs.guidesSettings.minorColor.name());
1297
        dc1.setAttribute("MAJORC",appPrefs.guidesSettings.majorColor.name());
1298
        dc1.setAttribute("GuideC", appPrefs.guidesSettings.guideColor.name());
1299
        dc1.setAttribute("BaseC", appPrefs.guidesSettings.baseColor.name());
13470 cbradney 1300
        dc1.setAttribute("GuideZ", ScCLocale::toQStringC(appPrefs.guidesSettings.guideRad));
2889 cbradney 1301
        dc1.setAttribute("BACKG", static_cast<int>(appPrefs.guidesSettings.before));
1302
        dc1.setAttribute("SHOW", static_cast<int>(appPrefs.guidesSettings.gridShown));
1303
        elem.appendChild(dc1);
1304
        QDomElement dc1a=docu.createElement("PAGE");
12476 cbradney 1305
        dc1a.setAttribute("ShowPageShadow",static_cast<int>(appPrefs.showPageShadow));
2889 cbradney 1306
        dc1a.setAttribute("PAGEC",appPrefs.DpapColor.name());
6316 fschmid 1307
        dc1a.setAttribute("SELEC",appPrefs.DFrameColor.name());
6326 fschmid 1308
        dc1a.setAttribute("DFrameNormColor",appPrefs.DFrameNormColor.name());
1309
        dc1a.setAttribute("DFrameGroupColor",appPrefs.DFrameGroupColor.name());
1310
        dc1a.setAttribute("DFrameLockColor",appPrefs.DFrameLockColor.name());
1311
        dc1a.setAttribute("DFrameLinkColor",appPrefs.DFrameLinkColor.name());
1312
        dc1a.setAttribute("DFrameAnnotationColor",appPrefs.DFrameAnnotationColor.name());
1313
        dc1a.setAttribute("DPageBorderColor",appPrefs.DPageBorderColor.name());
1314
        dc1a.setAttribute("DControlCharColor",appPrefs.DControlCharColor.name());
2889 cbradney 1315
        dc1a.setAttribute("MARGC",appPrefs.guidesSettings.margColor.name());
1316
        dc1a.setAttribute("RANDF", static_cast<int>(appPrefs.marginColored));
15181 jghali 1317
        dc1a.setAttribute("DScale", ScCLocale::toQStringC(appPrefs.DisScale, 6));
2889 cbradney 1318
        elem.appendChild(dc1a);
14311 jghali 1319
        // Font information must be written before FONTS element so that face "usable"
1320
        // member is set properly before one try to set default font. Allows to check
1321
        // that default font is indeed usable, problems expected otherwise
1322
        for ( SCFontsIterator itf(appPrefs.AvailFonts); itf.hasNext(); itf.next())
1323
        {
1324
                if (!itf.currentKey().isEmpty())
1325
                {
1326
                        QDomElement fn=docu.createElement("FONT");
1327
                        fn.setAttribute("NAME",itf.currentKey());
1328
                        fn.setAttribute("EMBED",static_cast<int>(itf.current().embedPs()));
1329
                        fn.setAttribute("USE", static_cast<int>(itf.current().usable()));
1330
                        fn.setAttribute("SUBSET", static_cast<int>(itf.current().subset()));
1331
                        elem.appendChild(fn);
1332
                }
1333
        }
1334
        QMap<QString,QString>::Iterator itfsu;
1335
        for (itfsu = appPrefs.GFontSub.begin(); itfsu != appPrefs.GFontSub.end(); ++itfsu)
1336
        {
1337
                QDomElement fosu = docu.createElement("Substitute");
1338
                fosu.setAttribute("Name",itfsu.key());
1339
                fosu.setAttribute("Replace",itfsu.value());
1340
                elem.appendChild(fosu);
1341
        }
2889 cbradney 1342
        QDomElement dc2=docu.createElement("FONTS");
1343
        dc2.setAttribute("FACE",appPrefs.toolSettings.defFont);
1344
        dc2.setAttribute("SIZE",appPrefs.toolSettings.defSize / 10.0);
1345
        dc2.setAttribute("AutomaticSubst", static_cast<int>(appPrefs.askBeforeSubstituite));
1346
        elem.appendChild(dc2);
1347
        QDomElement dc3=docu.createElement("TYPO");
1348
        dc3.setAttribute("TIEF",appPrefs.typographicSettings.valueSubScript);
1349
        dc3.setAttribute("TIEFSC",appPrefs.typographicSettings.scalingSubScript);
1350
        dc3.setAttribute("HOCH",appPrefs.typographicSettings.valueSuperScript);
1351
        dc3.setAttribute("HOCHSC",appPrefs.typographicSettings.scalingSuperScript);
1352
        dc3.setAttribute("SMCAPS",appPrefs.typographicSettings.valueSmallCaps);
1353
        dc3.setAttribute("AUTOL", appPrefs.typographicSettings.autoLineSpacing);
13470 cbradney 1354
        dc3.setAttribute("BASE", ScCLocale::toQStringC(appPrefs.typographicSettings.valueBaseGrid));
1355
        dc3.setAttribute("BASEO", ScCLocale::toQStringC(appPrefs.typographicSettings.offsetBaseGrid));
2889 cbradney 1356
        if (appPrefs.typographicSettings.valueUnderlinePos == -1)
1357
                dc3.setAttribute("UnderlinePos", appPrefs.typographicSettings.valueUnderlinePos);
1358
        else
1359
                dc3.setAttribute("UnderlinePos", appPrefs.typographicSettings.valueUnderlinePos / 10.0);
1360
        if (appPrefs.typographicSettings.valueUnderlineWidth == -1)
1361
                dc3.setAttribute("UnderlineWidth", appPrefs.typographicSettings.valueUnderlineWidth);
1362
        else
1363
                dc3.setAttribute("UnderlineWidth", appPrefs.typographicSettings.valueUnderlineWidth / 10.0);
1364
        if (appPrefs.typographicSettings.valueStrikeThruPos == -1)
1365
                dc3.setAttribute("StrikeThruPos", appPrefs.typographicSettings.valueStrikeThruPos);
1366
        else
1367
                dc3.setAttribute("StrikeThruPos", appPrefs.typographicSettings.valueStrikeThruPos / 10.0);
1368
        if (appPrefs.typographicSettings.valueStrikeThruWidth == -1)
1369
                dc3.setAttribute("StrikeThruWidth", appPrefs.typographicSettings.valueStrikeThruWidth);
1370
        else
1371
                dc3.setAttribute("StrikeThruWidth", appPrefs.typographicSettings.valueStrikeThruWidth / 10.0);
1372
        elem.appendChild(dc3);
1373
        QDomElement dc9=docu.createElement("TOOLS");
1374
        dc9.setAttribute("PEN",appPrefs.toolSettings.dPen);
1375
        dc9.setAttribute("BRUSH",appPrefs.toolSettings.dBrush);
1376
        dc9.setAttribute("PENLINE",appPrefs.toolSettings.dPenLine);
1377
        dc9.setAttribute("PENTEXT",appPrefs.toolSettings.dPenText);
1378
        dc9.setAttribute("StrokeText",appPrefs.toolSettings.dStrokeText);
3093 fschmid 1379
        dc9.setAttribute("TextBackGround", appPrefs.toolSettings.dTextBackGround);
1380
        dc9.setAttribute("TextLineColor", appPrefs.toolSettings.dTextLineColor);
1381
        dc9.setAttribute("TextBackGroundShade", appPrefs.toolSettings.dTextBackGroundShade);
1382
        dc9.setAttribute("TextLineShade", appPrefs.toolSettings.dTextLineShade);
1383
        dc9.setAttribute("TextPenShade", appPrefs.toolSettings.dTextPenShade);
1384
        dc9.setAttribute("TextStrokeShade", appPrefs.toolSettings.dTextStrokeShade);
2889 cbradney 1385
        dc9.setAttribute("TEXTCOL",appPrefs.toolSettings.dCols);
13470 cbradney 1386
        dc9.setAttribute("TEXTGAP",ScCLocale::toQStringC(appPrefs.toolSettings.dGap));
1387
        dc9.setAttribute("TabWidth",ScCLocale::toQStringC(appPrefs.toolSettings.dTabWidth));
2889 cbradney 1388
        dc9.setAttribute("TabFill",appPrefs.toolSettings.tabFillChar);
1389
        dc9.setAttribute("STIL",appPrefs.toolSettings.dLineArt);
1390
        dc9.setAttribute("STILLINE",appPrefs.toolSettings.dLstyleLine);
13470 cbradney 1391
        dc9.setAttribute("WIDTH",ScCLocale::toQStringC(appPrefs.toolSettings.dWidth));
1392
        dc9.setAttribute("WIDTHLINE",ScCLocale::toQStringC(appPrefs.toolSettings.dWidthLine));
2889 cbradney 1393
        dc9.setAttribute("PENSHADE",appPrefs.toolSettings.dShade2);
1394
        dc9.setAttribute("LINESHADE",appPrefs.toolSettings.dShadeLine);
1395
        dc9.setAttribute("BRUSHSHADE",appPrefs.toolSettings.dShade);
1396
        dc9.setAttribute("MAGMIN",appPrefs.toolSettings.magMin);
1397
        dc9.setAttribute("MAGMAX",appPrefs.toolSettings.magMax);
1398
        dc9.setAttribute("MAGSTEP",appPrefs.toolSettings.magStep);
1399
        dc9.setAttribute("CPICT",appPrefs.toolSettings.dBrushPict);
1400
        dc9.setAttribute("PICTSHADE",appPrefs.toolSettings.shadePict);
13470 cbradney 1401
        dc9.setAttribute("PICTSCX",ScCLocale::toQStringC(appPrefs.toolSettings.scaleX));
1402
        dc9.setAttribute("PICTSCY",ScCLocale::toQStringC(appPrefs.toolSettings.scaleY));
2889 cbradney 1403
        dc9.setAttribute("POLYC", appPrefs.toolSettings.polyC);
13470 cbradney 1404
        dc9.setAttribute("POLYF", ScCLocale::toQStringC(appPrefs.toolSettings.polyF));
1405
        dc9.setAttribute("POLYR", ScCLocale::toQStringC(appPrefs.toolSettings.polyR));
2889 cbradney 1406
        dc9.setAttribute("POLYFD", appPrefs.toolSettings.polyFd);
13470 cbradney 1407
        dc9.setAttribute("POLYCUR", ScCLocale::toQStringC(appPrefs.toolSettings.polyCurvature));
2889 cbradney 1408
        dc9.setAttribute("POLYS", static_cast<int>(appPrefs.toolSettings.polyS));
1409
        dc9.setAttribute("PSCALE", static_cast<int>(appPrefs.toolSettings.scaleType));
1410
        dc9.setAttribute("PASPECT", static_cast<int>(appPrefs.toolSettings.aspectRatio));
1411
        dc9.setAttribute("EmbeddedPath", static_cast<int>(appPrefs.toolSettings.useEmbeddedPath));
1412
        dc9.setAttribute("HalfRes", appPrefs.toolSettings.lowResType);
1413
        dc9.setAttribute("StartArrow", appPrefs.toolSettings.dStartArrow);
1414
        dc9.setAttribute("EndArrow", appPrefs.toolSettings.dEndArrow);
13470 cbradney 1415
        dc9.setAttribute("dispX", ScCLocale::toQStringC(appPrefs.toolSettings.dispX));
1416
        dc9.setAttribute("dispY", ScCLocale::toQStringC(appPrefs.toolSettings.dispY));
1417
        dc9.setAttribute("constrain", ScCLocale::toQStringC(appPrefs.toolSettings.constrain));
2889 cbradney 1418
        elem.appendChild(dc9);
1419
        QDomElement dc4=docu.createElement("MAINWINDOW");
1420
        dc4.setAttribute("XPOS",appPrefs.mainWinSettings.xPosition);
1421
        dc4.setAttribute("YPOS",appPrefs.mainWinSettings.yPosition);
1422
        dc4.setAttribute("WIDTH",appPrefs.mainWinSettings.width);
1423
        dc4.setAttribute("HEIGHT",appPrefs.mainWinSettings.height);
4892 cbradney 1424
        dc4.setAttribute("MAXIMIZED",static_cast<int>(appPrefs.mainWinSettings.maximized));
2889 cbradney 1425
        elem.appendChild(dc4);
4735 fschmid 1426
        QDomElement dc73=docu.createElement("SCRAPBOOK");
5787 fschmid 1427
        dc73.setAttribute("CopyToScrapbook",static_cast<int>(appPrefs.doCopyToScrapbook));
1428
        dc73.setAttribute("persistentScrapbook",static_cast<int>(appPrefs.persistentScrapbook));
1429
        dc73.setAttribute("numScrapbookCopies",appPrefs.numScrapbookCopies);
8528 cbradney 1430
        for (int rd=0; rd<appPrefs.RecentScrapbooks.count(); ++rd)
4735 fschmid 1431
        {
1432
                QDomElement rde=docu.createElement("RECENT");
1433
                rde.setAttribute("NAME",appPrefs.RecentScrapbooks[rd]);
1434
                dc73.appendChild(rde);
1435
        }
1436
        elem.appendChild(dc73);
2889 cbradney 1437
        QDomElement dc75=docu.createElement("PAGEPALETTE");
1438
        dc75.setAttribute("THUMBS", static_cast<int>(appPrefs.SepalT));
1439
        dc75.setAttribute("NAMES", static_cast<int>(appPrefs.SepalN));
1440
        elem.appendChild(dc75);
1441
        QDomElement dc76=docu.createElement("DOKUMENT");
1442
        dc76.setAttribute("PAGESIZE",appPrefs.pageSize);
1443
        dc76.setAttribute("AUSRICHTUNG",appPrefs.pageOrientation);
13470 cbradney 1444
        dc76.setAttribute("BREITE",ScCLocale::toQStringC(appPrefs.PageWidth));
1445
        dc76.setAttribute("HOEHE",ScCLocale::toQStringC(appPrefs.PageHeight));
1446
        dc76.setAttribute("RANDO",ScCLocale::toQStringC(appPrefs.margins.Top));
1447
        dc76.setAttribute("RANDU",ScCLocale::toQStringC(appPrefs.margins.Bottom));
1448
        dc76.setAttribute("RANDL",ScCLocale::toQStringC(appPrefs.margins.Left));
1449
        dc76.setAttribute("RANDR",ScCLocale::toQStringC(appPrefs.margins.Right));
12334 fschmid 1450
        dc76.setAttribute("PRESET",appPrefs.marginPreset);
2894 fschmid 1451
        dc76.setAttribute("DOPPEL", appPrefs.FacingPages);
2889 cbradney 1452
        dc76.setAttribute("AutoSave", static_cast<int>(appPrefs.AutoSave));
1453
        dc76.setAttribute("AutoSaveTime", appPrefs.AutoSaveTime);
13470 cbradney 1454
        dc76.setAttribute("BleedTop", ScCLocale::toQStringC(appPrefs.bleeds.Top));
1455
        dc76.setAttribute("BleedLeft", ScCLocale::toQStringC(appPrefs.bleeds.Left));
1456
        dc76.setAttribute("BleedRight", ScCLocale::toQStringC(appPrefs.bleeds.Right));
1457
        dc76.setAttribute("BleedBottom", ScCLocale::toQStringC(appPrefs.bleeds.Bottom));
2889 cbradney 1458
        elem.appendChild(dc76);
3016 fschmid 1459
        QDomElement pageSetAttr = docu.createElement("PageSets");
9803 fschmid 1460
        QList<PageSet>::Iterator itpgset;
3016 fschmid 1461
        for(itpgset = appPrefs.pageSets.begin(); itpgset != appPrefs.pageSets.end(); ++itpgset )
1462
        {
1463
                QDomElement pgst = docu.createElement("Set");
1464
                pgst.setAttribute("Name", (*itpgset).Name);
1465
                pgst.setAttribute("FirstPage", (*itpgset).FirstPage);
1466
                pgst.setAttribute("Rows", (*itpgset).Rows);
1467
                pgst.setAttribute("Columns", (*itpgset).Columns);
11349 fschmid 1468
//              pgst.setAttribute("GapHorizontal", (*itpgset).GapHorizontal);
1469
//              pgst.setAttribute("GapVertical", (*itpgset).GapVertical);
1470
//              pgst.setAttribute("GapBelow", (*itpgset).GapBelow);
3026 fschmid 1471
                QStringList pNames = (*itpgset).pageNames;
1472
                QStringList::Iterator itpgsetN;
1473
                for(itpgsetN = pNames.begin(); itpgsetN != pNames.end(); ++itpgsetN )
1474
                {
1475
                        QDomElement pgstN = docu.createElement("PageNames");
1476
                        pgstN.setAttribute("Name", (*itpgsetN));
1477
                        pgst.appendChild(pgstN);
1478
                }
3016 fschmid 1479
                pageSetAttr.appendChild(pgst);
1480
        }
1481
        elem.appendChild(pageSetAttr);
3183 fschmid 1482
        QDomElement dc79ac=docu.createElement("Checker");
1483
        dc79ac.setAttribute("currentProfile", appPrefs.curCheckProfile);
1484
        elem.appendChild(dc79ac);
3033 cbradney 1485
        CheckerPrefsList::Iterator itcp;
1486
        CheckerPrefsList::Iterator itcpend=appPrefs.checkerProfiles.end();
1487
        for (itcp = appPrefs.checkerProfiles.begin(); itcp != itcpend; ++itcp)
2889 cbradney 1488
        {
1489
                QDomElement dc79a=docu.createElement("CheckProfile");
1490
                dc79a.setAttribute("Name",itcp.key());
10398 cbradney 1491
                dc79a.setAttribute("ignoreErrors", static_cast<int>(itcp.value().ignoreErrors));
1492
                dc79a.setAttribute("autoCheck", static_cast<int>(itcp.value().autoCheck));
1493
                dc79a.setAttribute("checkGlyphs", static_cast<int>(itcp.value().checkGlyphs));
1494
                dc79a.setAttribute("checkOrphans", static_cast<int>(itcp.value().checkOrphans));
1495
                dc79a.setAttribute("checkOverflow", static_cast<int>(itcp.value().checkOverflow));
1496
                dc79a.setAttribute("checkPictures", static_cast<int>(itcp.value().checkPictures));
1497
                dc79a.setAttribute("checkResolution", static_cast<int>(itcp.value().checkResolution));
1498
                dc79a.setAttribute("checkTransparency", static_cast<int>(itcp.value().checkTransparency));
1499
                dc79a.setAttribute("checkAnnotations", static_cast<int>(itcp.value().checkAnnotations));
1500
                dc79a.setAttribute("checkRasterPDF", static_cast<int>(itcp.value().checkRasterPDF));
1501
                dc79a.setAttribute("checkForGIF", static_cast<int>(itcp.value().checkForGIF));
1502
                dc79a.setAttribute("ignoreOffLayers", static_cast<int>(itcp.value().ignoreOffLayers));
14543 cbradney 1503
                dc79a.setAttribute("checkOffConflictLayers", static_cast<int>(itcp.value().checkOffConflictLayers));
13470 cbradney 1504
                dc79a.setAttribute("minResolution",ScCLocale::toQStringC(itcp.value().minResolution));
1505
                dc79a.setAttribute("maxResolution",ScCLocale::toQStringC(itcp.value().maxResolution));
2889 cbradney 1506
                elem.appendChild(dc79a);
1507
        }
1508
        QDomElement dc81=docu.createElement("CMS");
1509
        dc81.setAttribute("DPSo", static_cast<int>(appPrefs.DCMSset.SoftProofOn));
5345 mrdocs 1510
        dc81.setAttribute("DPSFo", static_cast<int>(appPrefs.DCMSset.SoftProofFullOn));
2889 cbradney 1511
        dc81.setAttribute("DPuse", static_cast<int>(appPrefs.DCMSset.CMSinUse));
1512
        dc81.setAttribute("DPgam", static_cast<int>(appPrefs.DCMSset.GamutCheck));
1513
        dc81.setAttribute("DPbla", static_cast<int>(appPrefs.DCMSset.BlackPoint));
1514
        dc81.setAttribute("DPMo",appPrefs.DCMSset.DefaultMonitorProfile);
1515
        dc81.setAttribute("DPPr",appPrefs.DCMSset.DefaultPrinterProfile);
2984 fschmid 1516
        dc81.setAttribute("DPIn",appPrefs.DCMSset.DefaultImageRGBProfile);
1517
        dc81.setAttribute("DPInCMYK",appPrefs.DCMSset.DefaultImageCMYKProfile);
5345 mrdocs 1518
        dc81.setAttribute("DPIn2",appPrefs.DCMSset.DefaultSolidColorRGBProfile);
1519
        dc81.setAttribute("DPIn3",appPrefs.DCMSset.DefaultSolidColorCMYKProfile);
1520
        //dc81.setAttribute("DIPr",appPrefs.DCMSset.DefaultIntentPrinter);
1521
        //dc81.setAttribute("DIMo",appPrefs.DCMSset.DefaultIntentMonitor);
1522
        dc81.setAttribute("DISc",appPrefs.DCMSset.DefaultIntentColors);
1523
        dc81.setAttribute("DIIm",appPrefs.DCMSset.DefaultIntentImages);
2889 cbradney 1524
        elem.appendChild(dc81);
1525
        QDomElement dc82=docu.createElement("PRINTER");
1526
        dc82.setAttribute("NAME",appPrefs.PrinterName);
1527
        dc82.setAttribute("FILE",appPrefs.PrinterFile);
1528
        dc82.setAttribute("COMMAND",appPrefs.PrinterCommand);
1529
        dc82.setAttribute("CLIPMARGIN", static_cast<int>(appPrefs.ClipMargin));
1530
        dc82.setAttribute("GMODE", static_cast<int>(appPrefs.GCRMode));
1531
        elem.appendChild(dc82);
1532
        QDomElement dc8Pr=docu.createElement("PRINTPREVIEW");
1533
        dc8Pr.setAttribute("Mode", static_cast<int>(appPrefs.PrPr_Mode));
1534
        dc8Pr.setAttribute("GcrMode", static_cast<int>(appPrefs.Gcr_Mode));
6008 jghali 1535
        dc8Pr.setAttribute("AntiAliasing", static_cast<int>(appPrefs.PrPr_AntiAliasing));
2889 cbradney 1536
        dc8Pr.setAttribute("Transparency", static_cast<int>(appPrefs.PrPr_Transparency));
1537
        dc8Pr.setAttribute("Cyan", static_cast<int>(appPrefs.PrPr_C));
1538
        dc8Pr.setAttribute("Magenta", static_cast<int>(appPrefs.PrPr_M));
1539
        dc8Pr.setAttribute("Yellow", static_cast<int>(appPrefs.PrPr_Y));
1540
        dc8Pr.setAttribute("Black", static_cast<int>(appPrefs.PrPr_K));
13153 fschmid 1541
        dc8Pr.setAttribute("InkCoverage", static_cast<int>(appPrefs.PrPr_InkCoverage));
1542
        dc8Pr.setAttribute("InkThreshold", appPrefs.PrPr_InkThreshold);
2889 cbradney 1543
        elem.appendChild(dc8Pr);
1544
        QDomElement dc8Ex = docu.createElement("EXTERNAL");
1545
        dc8Ex.setAttribute("GIMP", imageEditorExecutable());
1546
        dc8Ex.setAttribute("GS", ghostscriptExecutable());
5418 cbradney 1547
        dc8Ex.setAttribute("WebBrowser", extBrowserExecutable());
2889 cbradney 1548
        dc8Ex.setAttribute("AlphaGraphics", static_cast<int>(appPrefs.gs_AntiAliasGraphics));
1549
        dc8Ex.setAttribute("AlphaText", static_cast<int>(appPrefs.gs_AntiAliasText));
1550
        dc8Ex.setAttribute("Resolution", appPrefs.gs_Resolution);
10228 avox 1551
        dc8Ex.setAttribute("LatexEditor", latexEditorExecutable());
1552
        dc8Ex.setAttribute("LatexResolution", latexResolution());
1553
        dc8Ex.setAttribute("LatexForceDpi", static_cast<int>(appPrefs.latexForceDpi));
10618 cbradney 1554
        dc8Ex.setAttribute("LatexStartWithEmptyFrames", static_cast<int>(appPrefs.latexStartWithEmptyFrames));
11506 mrdocs 1555
        QStringList configs = latexConfigs();
1556
        foreach (QString config, configs) {
1557
                QDomElement domConfig = docu.createElement("LatexConfig");
1558
                domConfig.setAttribute("file", config);
12977 herm 1559
                domConfig.setAttribute("command", appPrefs.latexCommands[config]);
11506 mrdocs 1560
                dc8Ex.appendChild(domConfig);
1561
        }
2889 cbradney 1562
        elem.appendChild(dc8Ex);
1563
        QDomElement rde=docu.createElement("HYPHEN");
1564
        rde.setAttribute("LANG", appPrefs.Language);
1565
        rde.setAttribute("WORDLEN", appPrefs.MinWordLen);
1566
        rde.setAttribute("HYCOUNT", appPrefs.HyCount);
1567
        rde.setAttribute("MODE", static_cast<int>(appPrefs.Automatic));
1568
        rde.setAttribute("INMODE", static_cast<int>(appPrefs.AutoCheck));
10170 fschmid 1569
        for (QHash<QString, QString>::Iterator hyit = appPrefs.specialWords.begin(); hyit != appPrefs.specialWords.end(); ++hyit)
1570
        {
1571
                QDomElement hyelm = docu.createElement("EXCEPTION");
1572
                hyelm.setAttribute("WORD", hyit.key());
1573
                hyelm.setAttribute("HYPHENATED", hyit.value());
1574
                rde.appendChild(hyelm);
1575
        }
1576
        for (QSet<QString>::Iterator hyit2 = appPrefs.ignoredWords.begin(); hyit2 != appPrefs.ignoredWords.end(); ++hyit2)
1577
        {
1578
                QDomElement hyelm2 = docu.createElement("IGNORE");
1579
                hyelm2.setAttribute("WORD", (*hyit2));
1580
                rde.appendChild(hyelm2);
1581
        }
2889 cbradney 1582
        elem.appendChild(rde);
1583
        ColorList::Iterator itc;
1584
        for (itc = appPrefs.DColors.begin(); itc != appPrefs.DColors.end(); ++itc)
1585
        {
1586
                QDomElement co=docu.createElement("COLOR");
1587
                co.setAttribute("NAME",itc.key());
10398 cbradney 1588
                if (itc.value().getColorModel() == colorModelRGB)
1589
                        co.setAttribute("RGB", itc.value().nameRGB());
4535 fschmid 1590
                else
10398 cbradney 1591
                        co.setAttribute("CMYK", itc.value().nameCMYK());
1592
                co.setAttribute("Spot", static_cast<int>(itc.value().isSpotColor()));
1593
                co.setAttribute("Register", static_cast<int>(itc.value().isRegistrationColor()));
2889 cbradney 1594
                elem.appendChild(co);
1595
        }
8528 cbradney 1596
        for (int rd=0; rd<appPrefs.RecentDocs.count(); ++rd)
2889 cbradney 1597
        {
1598
                QDomElement rde=docu.createElement("RECENT");
4321 cbradney 1599
                rde.setAttribute("NAME",appPrefs.RecentDocs[rd]);
2889 cbradney 1600
                elem.appendChild(rde);
1601
        }
1602
        for (QMap<QString,Keys>::Iterator ksc=appPrefs.KeyActions.begin(); ksc!=appPrefs.KeyActions.end(); ++ksc)
1603
        {
10398 cbradney 1604
                if (ksc.value().actionName.isEmpty())
5354 cbradney 1605
                        continue;
2889 cbradney 1606
                QDomElement kscc=docu.createElement("SHORTCUT");
10398 cbradney 1607
                kscc.setAttribute("ACTION",ksc.value().actionName);
1608
                kscc.setAttribute("SEQUENCE",TabKeyboardShortcutsWidget::getKeyText(ksc.value().keySequence));
2889 cbradney 1609
                elem.appendChild(kscc);
1610
        }
8528 cbradney 1611
        for (int ccs=0; ccs<appPrefs.CustomColorSets.count(); ++ccs)
2889 cbradney 1612
        {
1613
                QDomElement cos=docu.createElement("COLORSET");
1614
                cos.setAttribute("NAME",appPrefs.CustomColorSets[ccs]);
1615
                elem.appendChild(cos);
1616
        }
1617
        QDomElement cosd=docu.createElement("DCOLORSET");
1618
        cosd.setAttribute("NAME",appPrefs.DColorSet);
1619
        elem.appendChild(cosd);
1620
        QDomElement pdf = docu.createElement("PDF");
1621
        pdf.setAttribute("Thumbnails", static_cast<int>(appPrefs.PDF_Options.Thumbnails));
1622
        pdf.setAttribute("Articles", static_cast<int>(appPrefs.PDF_Options.Articles));
1623
        pdf.setAttribute("Bookmarks", static_cast<int>(appPrefs.PDF_Options.Bookmarks));
1624
        pdf.setAttribute("Compress", static_cast<int>(appPrefs.PDF_Options.Compress));
1625
        pdf.setAttribute("CMethod", appPrefs.PDF_Options.CompressMethod);
1626
        pdf.setAttribute("Quality", appPrefs.PDF_Options.Quality);
13823 jghali 1627
        pdf.setAttribute("EmbedPDF", static_cast<int>(appPrefs.PDF_Options.embedPDF));
2889 cbradney 1628
        pdf.setAttribute("MirrorH", static_cast<int>(appPrefs.PDF_Options.MirrorH));
1629
        pdf.setAttribute("MirrorV", static_cast<int>(appPrefs.PDF_Options.MirrorV));
4649 fschmid 1630
        pdf.setAttribute("Clip", static_cast<int>(appPrefs.PDF_Options.doClip));
2889 cbradney 1631
        pdf.setAttribute("RotateDeg", static_cast<int>(appPrefs.PDF_Options.RotateDeg));
1632
        pdf.setAttribute("PresentMode", static_cast<int>(appPrefs.PDF_Options.PresentMode));
1633
        pdf.setAttribute("RecalcPic", static_cast<int>(appPrefs.PDF_Options.RecalcPic));
1634
        pdf.setAttribute("Grayscale", static_cast<int>(appPrefs.PDF_Options.isGrayscale));
1635
        pdf.setAttribute("RGBMode", static_cast<int>(appPrefs.PDF_Options.UseRGB));
1636
        pdf.setAttribute("UseProfiles", static_cast<int>(appPrefs.PDF_Options.UseProfiles));
1637
        pdf.setAttribute("UseProfiles2", static_cast<int>(appPrefs.PDF_Options.UseProfiles2));
1638
        pdf.setAttribute("Binding", appPrefs.PDF_Options.Binding);
1639
        pdf.setAttribute("PicRes", appPrefs.PDF_Options.PicRes);
1640
        pdf.setAttribute("Resolution", appPrefs.PDF_Options.Resolution);
1641
        pdf.setAttribute("Version", appPrefs.PDF_Options.Version);
1642
        pdf.setAttribute("Intent", appPrefs.PDF_Options.Intent);
1643
        pdf.setAttribute("Intent2", appPrefs.PDF_Options.Intent2);
1644
        pdf.setAttribute("SolidP", appPrefs.PDF_Options.SolidProf);
1645
        pdf.setAttribute("ImageP", appPrefs.PDF_Options.ImageProf);
1646
        pdf.setAttribute("PrintP", appPrefs.PDF_Options.PrintProf);
1647
        pdf.setAttribute("InfoString", appPrefs.PDF_Options.Info);
13470 cbradney 1648
        pdf.setAttribute("BTop", ScCLocale::toQStringC(appPrefs.PDF_Options.bleeds.Top));
1649
        pdf.setAttribute("BLeft", ScCLocale::toQStringC(appPrefs.PDF_Options.bleeds.Left));
1650
        pdf.setAttribute("BRight", ScCLocale::toQStringC(appPrefs.PDF_Options.bleeds.Right));
1651
        pdf.setAttribute("BBottom", ScCLocale::toQStringC(appPrefs.PDF_Options.bleeds.Bottom));
7076 fschmid 1652
        pdf.setAttribute("useDocBleeds", static_cast<int>(appPrefs.PDF_Options.useDocBleeds));
6921 fschmid 1653
        pdf.setAttribute("cropMarks", static_cast<int>(appPrefs.PDF_Options.cropMarks));
1654
        pdf.setAttribute("bleedMarks", static_cast<int>(appPrefs.PDF_Options.bleedMarks));
1655
        pdf.setAttribute("registrationMarks", static_cast<int>(appPrefs.PDF_Options.registrationMarks));
1656
        pdf.setAttribute("colorMarks", static_cast<int>(appPrefs.PDF_Options.colorMarks));
1657
        pdf.setAttribute("docInfoMarks", static_cast<int>(appPrefs.PDF_Options.docInfoMarks));
1658
        pdf.setAttribute("markOffset", appPrefs.PDF_Options.markOffset);
2889 cbradney 1659
        pdf.setAttribute("ImagePr", static_cast<int>(appPrefs.PDF_Options.EmbeddedI));
1660
        pdf.setAttribute("PassOwner", appPrefs.PDF_Options.PassOwner);
1661
        pdf.setAttribute("PassUser", appPrefs.PDF_Options.PassUser);
1662
        pdf.setAttribute("Permissions", appPrefs.PDF_Options.Permissions);
1663
        pdf.setAttribute("Encrypt", static_cast<int>(appPrefs.PDF_Options.Encrypt));
1664
        pdf.setAttribute("UseLayers", static_cast<int>(appPrefs.PDF_Options.useLayers));
1665
        pdf.setAttribute("UseLpi", static_cast<int>(appPrefs.PDF_Options.UseLPI));
3079 fschmid 1666
        pdf.setAttribute("UseSpotColors", static_cast<int>(appPrefs.PDF_Options.UseSpotColors));
1667
        pdf.setAttribute("doMultiFile", static_cast<int>(appPrefs.PDF_Options.doMultiFile));
4197 fschmid 1668
        pdf.setAttribute("displayBookmarks", static_cast<int>(appPrefs.PDF_Options.displayBookmarks));
1669
        pdf.setAttribute("displayFullscreen", static_cast<int>(appPrefs.PDF_Options.displayFullscreen));
1670
        pdf.setAttribute("displayLayers", static_cast<int>(appPrefs.PDF_Options.displayLayers));
1671
        pdf.setAttribute("displayThumbs", static_cast<int>(appPrefs.PDF_Options.displayThumbs));
1672
        pdf.setAttribute("PageLayout", appPrefs.PDF_Options.PageLayout);
1673
        pdf.setAttribute("openAction", appPrefs.PDF_Options.openAction);
2889 cbradney 1674
        QMap<QString,LPIData>::Iterator itlp;
1675
        for (itlp = appPrefs.PDF_Options.LPISettings.begin(); itlp != appPrefs.PDF_Options.LPISettings.end(); ++itlp)
1676
        {
1677
                QDomElement pdf4 = docu.createElement("LPI");
1678
                pdf4.setAttribute("Color", itlp.key());
10398 cbradney 1679
                pdf4.setAttribute("Frequency", itlp.value().Frequency);
1680
                pdf4.setAttribute("Angle", itlp.value().Angle);
1681
                pdf4.setAttribute("SpotFunction", itlp.value().SpotFunc);
2889 cbradney 1682
                pdf.appendChild(pdf4);
1683
        }
1684
        elem.appendChild(pdf);
1685
        QDomElement docItemAttrs = docu.createElement("DefaultItemAttributes");
1686
        for(ObjAttrVector::Iterator objAttrIt = appPrefs.defaultItemAttributes.begin() ; objAttrIt != appPrefs.defaultItemAttributes.end(); ++objAttrIt )
1687
        {
1688
                QDomElement itemAttr = docu.createElement("ItemAttribute");
1689
                itemAttr.setAttribute("Name", (*objAttrIt).name);
1690
                itemAttr.setAttribute("Type", (*objAttrIt).type);
1691
                itemAttr.setAttribute("Value", (*objAttrIt).value);
1692
                itemAttr.setAttribute("Parameter", (*objAttrIt).parameter);
1693
                itemAttr.setAttribute("Relationship", (*objAttrIt).relationship);
1694
                itemAttr.setAttribute("RelationshipTo", (*objAttrIt).relationshipto);
1695
                itemAttr.setAttribute("AutoAddTo", (*objAttrIt).autoaddto);
1696
                docItemAttrs.appendChild(itemAttr);
1697
        }
1698
        elem.appendChild(docItemAttrs);
1699
        QDomElement tocElem = docu.createElement("TablesOfContents");
1700
        for(ToCSetupVector::Iterator tocSetupIt = appPrefs.defaultToCSetups.begin() ; tocSetupIt != appPrefs.defaultToCSetups.end(); ++tocSetupIt )
1701
        {
1702
                QDomElement tocsetup = docu.createElement("TableOfContents");
1703
                tocsetup.setAttribute("Name", (*tocSetupIt).name);
1704
                tocsetup.setAttribute("ItemAttributeName", (*tocSetupIt).itemAttrName);
1705
                tocsetup.setAttribute("FrameName", (*tocSetupIt).frameName);
1706
                tocsetup.setAttribute("ListNonPrinting", (*tocSetupIt).listNonPrintingFrames);
1707
                tocsetup.setAttribute("Style", (*tocSetupIt).textStyle);
1708
                tocsetup.setAttribute("NumberPlacement", (*tocSetupIt).pageLocation);
1709
                tocElem.appendChild(tocsetup);
1710
        }
1711
        elem.appendChild(tocElem);
1712
        // lorem ipsum
1713
        QDomElement liElem = docu.createElement("LoremIpsum");
1714
        liElem.setAttribute("useStandardLI", static_cast<int>(appPrefs.useStandardLI));
1715
        liElem.setAttribute("paragraphsLI", appPrefs.paragraphsLI);
1716
        elem.appendChild(liElem);
1717
        // write file
3170 craig 1718
        bool result = false;
16451 craig 1719
        QFile f(filename);
8501 cbradney 1720
        if(!f.open(QIODevice::WriteOnly))
3170 craig 1721
        {
1722
                m_lastError = tr("Could not open preferences file \"%1\" for writing: %2")
16453 craig 1723
                        .arg(filename).arg(qApp->translate("QFile",f.errorString().toLatin1().constData()));
3170 craig 1724
        }
1725
        else
1726
        {
10004 fschmid 1727
                QTextStream s(&f);
1728
                s.setCodec("UTF-8");
3170 craig 1729
                s<<docu.toString();
8528 cbradney 1730
                if (f.error()==QFile::NoError)
3170 craig 1731
                        result = true;
1732
                else
1733
                        m_lastError = tr("Writing to preferences file \"%1\" failed: "
16453 craig 1734
                                             "QIODevice status code %2").arg(filename).arg(f.errorString());
3170 craig 1735
        }
1736
        if (f.isOpen())
1737
                f.close();
1738
        return result;
2889 cbradney 1739
}
1740
 
1741
bool PrefsManager::ReadPref(QString ho)
1742
{
1743
        QDomDocument docu("scridoc");
1744
        QFile f(ho);
8501 cbradney 1745
        if(!f.open(QIODevice::ReadOnly))
3171 craig 1746
        {
1747
                m_lastError = tr("Failed to open prefs file \"%1\": %2")
10553 fschmid 1748
                        .arg(ho).arg( qApp->translate("QFile",f.errorString().toLatin1().constData()) );
2889 cbradney 1749
                return false;
3171 craig 1750
        }
10004 fschmid 1751
        QTextStream ts(&f);
1752
        ts.setCodec("UTF-8");
2889 cbradney 1753
        QString errorMsg;
1754
        int errorLine = 0, errorColumn = 0;
10004 fschmid 1755
        if( !docu.setContent(ts.readAll(), &errorMsg, &errorLine, &errorColumn) )
2889 cbradney 1756
        {
3171 craig 1757
                m_lastError = tr("Failed to read prefs XML from \"%1\": %2 at line %3, col %4")
1758
                        .arg(ho).arg(errorMsg).arg(errorLine).arg(errorColumn);
2889 cbradney 1759
                f.close();
1760
                return false;
1761
        }
1762
        f.close();
1763
        QDomElement elem=docu.documentElement();
1764
        if (elem.tagName() != "SCRIBUSRC")
1765
                return false;
13474 cbradney 1766
        //Ignore scribus*.rc files prior to 1.3.5 due to changes
16451 craig 1767
        bool prefs135140FileFound=false;
13474 cbradney 1768
        if (elem.hasAttribute("VERSION"))
1769
        {
16451 craig 1770
                if (elem.attribute("VERSION") == "1.3.5" || elem.attribute("VERSION") == "1.4.0")
1771
                        prefs135140FileFound=true;
13474 cbradney 1772
        }
16451 craig 1773
        firstTimeIgnoreOldPrefs=!prefs135140FileFound;
1774
        if (!prefs135140FileFound)
13474 cbradney 1775
                return false;
2889 cbradney 1776
        appPrefs.DColors.clear();
12977 herm 1777
        appPrefs.latexCommands.clear();
2889 cbradney 1778
        ScColor lf = ScColor();
1779
        QDomNode DOC=elem.firstChild();
3183 fschmid 1780
        if (!DOC.namedItem("CheckProfile").isNull())
1781
                appPrefs.checkerProfiles.clear();
2889 cbradney 1782
        while(!DOC.isNull())
1783
        {
1784
                QDomElement dc=DOC.toElement();
1785
                if (dc.tagName()=="GUI")
1786
                {
1787
                        appPrefs.GUI = dc.attribute("STILT","Default");
4026 craig 1788
                        appPrefs.Wheelval = dc.attribute("RAD").toInt();
5912 fschmid 1789
                        appPrefs.moveTimeout = dc.attribute("MOVT", "150").toInt();
4026 craig 1790
                        appPrefs.guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt();
1791
                        appPrefs.docUnitIndex = dc.attribute("UNIT", "0").toInt();
1792
                        appPrefs.AppFontSize = dc.attribute("APF", "12").toInt();
1793
                        appPrefs.PaletteFontSize = dc.attribute("PFS", "10").toInt();
2889 cbradney 1794
                        appPrefs.RecentDCount = dc.attribute("RCD","5").toUInt();
1795
                        appPrefs.DocDir = dc.attribute("DOC","");
1796
                        appPrefs.ProfileDir = dc.attribute("PROFILES","");
1797
                        appPrefs.ScriptDir = dc.attribute("SCRIPTS","");
1798
                        appPrefs.documentTemplatesDir = dc.attribute("TEMPLATES","");
4026 craig 1799
                        appPrefs.guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt());
5384 cbradney 1800
                        appPrefs.guidesSettings.colBordersShown = static_cast<bool>(dc.attribute("showcolborders", "0").toInt());
4026 craig 1801
                        appPrefs.guidesSettings.framesShown = static_cast<bool>(dc.attribute("FRV", "1").toInt());
5584 fschmid 1802
                        appPrefs.guidesSettings.layerMarkersShown = static_cast<bool>(dc.attribute("SHOWLAYERM", "0").toInt());
4026 craig 1803
                        appPrefs.guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt());
1804
                        appPrefs.guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "1").toInt());
1805
                        appPrefs.guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt());
1806
                        appPrefs.guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt());
1807
                        appPrefs.guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt());
4651 cbradney 1808
                        appPrefs.guidesSettings.rulersShown = static_cast<bool>(dc.attribute("rulersShown", "1").toInt());
7051 fschmid 1809
                        appPrefs.guidesSettings.showBleed = static_cast<bool>(dc.attribute("showBleed", "1").toInt());
4026 craig 1810
                        appPrefs.guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt());
1811
                        appPrefs.haveStylePreview = static_cast<bool>(dc.attribute("STYLEPREVIEW", "1").toInt());
1812
                        appPrefs.showStartupDialog = static_cast<bool>(dc.attribute("StartUp", "1").toInt());
10225 subik 1813
                        appPrefs.useSmallWidgets = static_cast<bool>(dc.attribute("UseSmallWidgets", "0").toInt());
13460 jghali 1814
                        appPrefs.scratch.Bottom = ScCLocale::toDoubleC(dc.attribute("ScratchBottom"), 20.0);
1815
                        appPrefs.scratch.Left   = ScCLocale::toDoubleC(dc.attribute("ScratchLeft"), 100.0);
1816
                        appPrefs.scratch.Right  = ScCLocale::toDoubleC(dc.attribute("ScratchRight"), 100.0);
1817
                        appPrefs.scratch.Top    = ScCLocale::toDoubleC(dc.attribute("ScratchTop"), 20.0);
1818
                        appPrefs.GapHorizontal  = ScCLocale::toDoubleC(dc.attribute("GapHorizontal"), 0.0);
1819
                        appPrefs.GapVertical    = ScCLocale::toDoubleC(dc.attribute("GapVertical"), 40.0);
2889 cbradney 1820
                        if (dc.hasAttribute("STECOLOR"))
1821
                                appPrefs.STEcolor = QColor(dc.attribute("STECOLOR"));
1822
                        if (dc.hasAttribute("STEFONT"))
1823
                                appPrefs.STEfont = dc.attribute("STEFONT");
4039 fschmid 1824
                        appPrefs.showToolTips = static_cast<bool>(dc.attribute("ToolTips", "1").toInt());
12754 fschmid 1825
                        appPrefs.showMouseCoordinates = static_cast<bool>(dc.attribute("showMouseCoordinates", "1").toInt());
7350 fschmid 1826
                        appPrefs.stickyTools = static_cast<bool>(dc.attribute("stickyTools", "0").toInt());
2889 cbradney 1827
                }
1828
                if (dc.tagName()=="GRID")
1829
                {
13460 jghali 1830
                        appPrefs.guidesSettings.minorGrid  = ScCLocale::toDoubleC(dc.attribute("MINOR"), 20.0);
1831
                        appPrefs.guidesSettings.majorGrid  = ScCLocale::toDoubleC(dc.attribute("MAJOR"), 100.0);
2889 cbradney 1832
                        appPrefs.guidesSettings.minorColor = QColor(dc.attribute("MINORC"));
1833
                        appPrefs.guidesSettings.majorColor = QColor(dc.attribute("MAJORC"));
4026 craig 1834
                        appPrefs.guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt());
1835
                        appPrefs.guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOW", "0").toInt());
2889 cbradney 1836
                        if (dc.hasAttribute("GuideC"))
1837
                                appPrefs.guidesSettings.guideColor = QColor(dc.attribute("GuideC"));
1838
                        if (dc.hasAttribute("GuideZ"))
13460 jghali 1839
                                appPrefs.guidesSettings.guideRad = ScCLocale::toDoubleC(dc.attribute("GuideZ"), 10.0);
2889 cbradney 1840
                        if (dc.hasAttribute("BaseC"))
1841
                                appPrefs.guidesSettings.baseColor = QColor(dc.attribute("BaseC"));
1842
                }
1843
                if (dc.tagName()=="PAGE")
1844
                {
12476 cbradney 1845
                        appPrefs.showPageShadow = static_cast<bool>(dc.attribute("ShowPageShadow", "1").toInt());
2889 cbradney 1846
                        appPrefs.DpapColor = QColor(dc.attribute("PAGEC"));
6316 fschmid 1847
                        appPrefs.DFrameColor = QColor(dc.attribute("SELEC","#ff0000"));
6326 fschmid 1848
                        appPrefs.DFrameNormColor = QColor(dc.attribute("DFrameNormColor","#000000"));
1849
                        appPrefs.DFrameGroupColor = QColor(dc.attribute("DFrameGroupColor","#008080"));
1850
                        appPrefs.DFrameLockColor = QColor(dc.attribute("DFrameLockColor","#800000"));
1851
                        appPrefs.DFrameLinkColor = QColor(dc.attribute("DFrameLinkColor","#ff0000"));
1852
                        appPrefs.DFrameAnnotationColor = QColor(dc.attribute("DFrameAnnotationColor","#0000ff"));
1853
                        appPrefs.DPageBorderColor = QColor(dc.attribute("DPageBorderColor","#ff0000"));
1854
                        appPrefs.DControlCharColor = QColor(dc.attribute("DControlCharColor","#800000"));
2889 cbradney 1855
                        appPrefs.guidesSettings.margColor = QColor(dc.attribute("MARGC","#0000ff"));
4026 craig 1856
                        appPrefs.marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt());
15181 jghali 1857
                        appPrefs.DisScale = qRound(ScCLocale::toDoubleC(dc.attribute("DScale"), appPrefs.DisScale)*72)/72.0;
2889 cbradney 1858
                }
1859
                if (dc.tagName()=="TYPO")
1860
                {
4026 craig 1861
                        appPrefs.typographicSettings.valueSuperScript = dc.attribute("HOCH").toInt();
1862
                        appPrefs.typographicSettings.scalingSuperScript = dc.attribute("HOCHSC").toInt();
1863
                        appPrefs.typographicSettings.valueSubScript = dc.attribute("TIEF").toInt();
1864
                        appPrefs.typographicSettings.scalingSubScript = dc.attribute("TIEFSC").toInt();
13460 jghali 1865
                        appPrefs.typographicSettings.valueSmallCaps  = dc.attribute("SMCAPS").toInt();
1866
                        appPrefs.typographicSettings.valueBaseGrid   = ScCLocale::toDoubleC(dc.attribute("BASE"), 12.0);
1867
                        appPrefs.typographicSettings.offsetBaseGrid  = ScCLocale::toDoubleC(dc.attribute("BASEO"), 0.0);
4026 craig 1868
                        appPrefs.typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
13460 jghali 1869
                        double ulp = ScCLocale::toDoubleC(dc.attribute("UnderlinePos"), -1.0);
2889 cbradney 1870
                        if (ulp != -1)
1871
                                appPrefs.typographicSettings.valueUnderlinePos = qRound(ulp * 10);
1872
                        else
1873
                                appPrefs.typographicSettings.valueUnderlinePos = -1;
13460 jghali 1874
                        double ulw = ScCLocale::toDoubleC(dc.attribute("UnderlineWidth"), -1.0);
2889 cbradney 1875
                        if (ulw != -1)
1876
                                appPrefs.typographicSettings.valueUnderlineWidth = qRound(ulw * 10);
1877
                        else
1878
                                appPrefs.typographicSettings.valueUnderlineWidth = -1;
13460 jghali 1879
                        double stp = ScCLocale::toDoubleC(dc.attribute("StrikeThruPos"), -1.0);
2889 cbradney 1880
                        if (stp != -1)
1881
                                appPrefs.typographicSettings.valueStrikeThruPos = qRound(ulp * 10);
1882
                        else
1883
                                appPrefs.typographicSettings.valueStrikeThruPos = -1;
13460 jghali 1884
                        double stw = ScCLocale::toDoubleC(dc.attribute("StrikeThruWidth"), -1.0);
2889 cbradney 1885
                        if (stw != -1)
1886
                                appPrefs.typographicSettings.valueStrikeThruWidth = qRound(stw * 10);
1887
                        else
1888
                                appPrefs.typographicSettings.valueStrikeThruWidth = -1;
1889
                }
1890
                if (dc.tagName()=="TOOLS")
1891
                {
1892
                        appPrefs.toolSettings.dPen = dc.attribute("PEN");
15186 cbradney 1893
                        appPrefs.toolSettings.dBrush = dc.attribute("BRUSH", CommonStrings::None);
2889 cbradney 1894
                        appPrefs.toolSettings.dPenLine = dc.attribute("PENLINE");
1895
                        appPrefs.toolSettings.dPenText = dc.attribute("PENTEXT");
1896
                        appPrefs.toolSettings.dStrokeText = dc.attribute("StrokeText", appPrefs.toolSettings.dPenText);
4546 subik 1897
                        appPrefs.toolSettings.dTextBackGround = dc.attribute("TextBackGround", CommonStrings::None);
1898
                        appPrefs.toolSettings.dTextLineColor = dc.attribute("TextLineColor", CommonStrings::None);
4026 craig 1899
                        appPrefs.toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt();
1900
                        appPrefs.toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt();
1901
                        appPrefs.toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt();
1902
                        appPrefs.toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt();
1903
                        appPrefs.toolSettings.dCols = dc.attribute("TEXTCOL", "1").toInt();
13460 jghali 1904
                        appPrefs.toolSettings.dGap  = ScCLocale::toDoubleC(dc.attribute("TEXTGAP"), 0.0);
2889 cbradney 1905
                        appPrefs.toolSettings.tabFillChar = dc.attribute("TabFill", "");
13460 jghali 1906
                        appPrefs.toolSettings.dTabWidth   = ScCLocale::toDoubleC(dc.attribute("TabWidth"), 36.0);
4026 craig 1907
                        appPrefs.toolSettings.dLineArt = dc.attribute("STIL").toInt();
1908
                        appPrefs.toolSettings.dLstyleLine = dc.attribute("STILLINE").toInt();
15186 cbradney 1909
                        appPrefs.toolSettings.dWidth     = ScCLocale::toDoubleC(dc.attribute("WIDTH"), 1.0);
13460 jghali 1910
                        appPrefs.toolSettings.dWidthLine = ScCLocale::toDoubleC(dc.attribute("WIDTHLINE"), 1.0);
4026 craig 1911
                        appPrefs.toolSettings.dShade2 = dc.attribute("PENSHADE").toInt();
1912
                        appPrefs.toolSettings.dShadeLine = dc.attribute("LINESHADE").toInt();
13460 jghali 1913
                        appPrefs.toolSettings.dShade  = dc.attribute("BRUSHSHADE").toInt();
1914
                        appPrefs.toolSettings.magMin  = dc.attribute("MAGMIN", "10").toInt();
1915
                        appPrefs.toolSettings.magMax  = dc.attribute("MAGMAX", "3200").toInt();
4285 cbradney 1916
                        appPrefs.toolSettings.magStep = dc.attribute("MAGSTEP", "200").toInt();
4295 cbradney 1917
                        //CB Reset prefs zoom step value to 200% instead of old values.
14499 jghali 1918
                        if (appPrefs.toolSettings.magStep <= 100)
1919
                                appPrefs.toolSettings.magStep = 200;
5510 cbradney 1920
                        appPrefs.toolSettings.dBrushPict = dc.attribute("CPICT", CommonStrings::None);
4026 craig 1921
                        appPrefs.toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt();
13460 jghali 1922
                        appPrefs.toolSettings.scaleX = ScCLocale::toDoubleC(dc.attribute("PICTSCX"), 1.0);
1923
                        appPrefs.toolSettings.scaleY = ScCLocale::toDoubleC(dc.attribute("PICTSCY"), 1.0);
4026 craig 1924
                        appPrefs.toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt());
1925
                        appPrefs.toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt());
1926
                        appPrefs.toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt());
1927
                        appPrefs.toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt();
1928
                        appPrefs.toolSettings.polyC = dc.attribute("POLYC", "4").toInt();
13460 jghali 1929
                        appPrefs.toolSettings.polyF <