Subversion Repositories Scribus

Rev

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

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