Subversion Repositories Scribus

Rev

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