Rev 135 | Rev 221 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4 | paul | 1 | /*************************************************************************** |
2 | scribuswin.cpp - description |
||
3 | ------------------- |
||
4 | begin : Mit Nov 6 2002 |
||
5 | copyright : (C) 2002 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
81 | Franz | 17 | #include <qfileinfo.h> |
18 | #include <qdir.h> |
||
4 | paul | 19 | #include "scribuswin.h" |
20 | #include "scribuswin.moc" |
||
81 | Franz | 21 | #include "scribusXml.h" |
135 | Franz | 22 | #include "scribus.h" |
204 | Franz | 23 | |
4 | paul | 24 | extern QPixmap loadIcon(QString nam); |
135 | Franz | 25 | extern ScribusApp* ScApp; |
204 | Franz | 26 | extern int moveFile(QString source, QString target); |
4 | paul | 27 | |
28 | ScribusWin::ScribusWin(QWidget* parent, ScribusDoc* ddoc) |
||
204 | Franz | 29 | : QMainWindow(parent, "", WDestructiveClose) |
4 | paul | 30 | { |
204 | Franz | 31 | setIcon(loadIcon("AppIcon.png")); |
4 | paul | 32 | doc = ddoc; |
33 | muster = NULL; |
||
34 | NrItems = 0; |
||
35 | First = 1; |
||
36 | Last = 0; |
||
37 | } |
||
38 | |||
39 | void ScribusWin::setView(ScribusView* dview) |
||
40 | { |
||
41 | view = dview; |
||
42 | } |
||
43 | |||
81 | Franz | 44 | void ScribusWin::slotAutoSave() |
45 | { |
||
204 | Franz | 46 | if ((doc->hasName) && (doc->isModified()) && (!doc->TemplateMode)) |
47 | { |
||
48 | moveFile(doc->DocName, doc->DocName+".bak"); |
||
81 | Franz | 49 | QString fn = doc->DocName; |
204 | Franz | 50 | QFileInfo fi(fn); |
51 | QDir::setCurrent(fi.dirPath(true)); |
||
52 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
81 | Franz | 53 | if (ss->WriteDoc(fn, doc, view, 0)) |
204 | Franz | 54 | { |
81 | Franz | 55 | doc->setUnModified(); |
56 | setCaption(doc->DocName); |
||
57 | qApp->processEvents(); |
||
58 | emit AutoSaved(); |
||
204 | Franz | 59 | } |
60 | delete ss; |
||
61 | } |
||
81 | Franz | 62 | } |
63 | |||
4 | paul | 64 | void ScribusWin::closeEvent(QCloseEvent *ce) |
65 | { |
||
66 | if (doc->isModified()) |
||
204 | Franz | 67 | { |
135 | Franz | 68 | QString CloseTxt; |
69 | if (ScApp->singleClose) |
||
204 | Franz | 70 | CloseTxt = tr("Leave Anyway"); |
135 | Franz | 71 | else |
72 | CloseTxt = tr("Close Anyway"); |
||
204 | Franz | 73 | int exit=QMessageBox::information(this, |
74 | tr("Warning"), |
||
75 | tr("Document:")+" "+doc->DocName+"\n"+ tr("has been changed since the last save."), |
||
76 | tr("Save Now"), |
||
77 | tr("Cancel"), |
||
78 | CloseTxt, |
||
79 | 0, 1); |
||
80 | switch (exit) |
||
81 | { |
||
82 | case 0: |
||
83 | emit SaveAndClose(); |
||
84 | ce->accept(); |
||
85 | break; |
||
86 | case 1: |
||
87 | break; |
||
88 | case 2: |
||
89 | emit Schliessen(); |
||
90 | ce->accept(); |
||
91 | break; |
||
4 | paul | 92 | } |
204 | Franz | 93 | } |
4 | paul | 94 | else |
204 | Franz | 95 | { |
4 | paul | 96 | emit Schliessen(); |
97 | ce->accept(); |
||
204 | Franz | 98 | } |
4 | paul | 99 | } |
100 | |||
101 | void ScribusWin::CloseCMSProfiles() |
||
102 | { |
||
103 | #ifdef HAVE_CMS |
||
104 | cmsCloseProfile(doc->DocInputProf); |
||
105 | cmsCloseProfile(doc->DocOutputProf); |
||
106 | cmsCloseProfile(doc->DocPrinterProf); |
||
107 | cmsDeleteTransform(stdTrans); |
||
108 | cmsDeleteTransform(stdProof); |
||
109 | cmsDeleteTransform(stdTransImg); |
||
110 | cmsDeleteTransform(stdProofImg); |
||
111 | #endif |
||
112 | } |
||
113 | |||
114 | void ScribusWin::OpenCMSProfiles(ProfilesL InPo, ProfilesL MoPo, ProfilesL PrPo) |
||
115 | { |
||
116 | #ifdef HAVE_CMS |
||
117 | doc->DocInputProf = cmsOpenProfileFromFile(InPo[doc->CMSSettings.DefaultInputProfile2], "r"); |
||
116 | Franz | 118 | doc->DocOutputProf = cmsOpenProfileFromFile(MoPo[doc->CMSSettings.DefaultMonitorProfile], "r"); |
119 | doc->DocPrinterProf = cmsOpenProfileFromFile(PrPo[doc->CMSSettings.DefaultPrinterProfile], "r"); |
||
120 | if ((doc->DocInputProf == NULL) || (doc->DocOutputProf == NULL) || (doc->DocPrinterProf == NULL)) |
||
204 | Franz | 121 | { |
116 | Franz | 122 | doc->CMSSettings.CMSinUse = false; |
123 | return; |
||
204 | Franz | 124 | } |
4 | paul | 125 | int dcmsFlags = 0; |
68 | Franz | 126 | int dcmsFlags2 = cmsFLAGS_NOTPRECALC; |
4 | paul | 127 | if (Gamut) |
128 | dcmsFlags |= cmsFLAGS_GAMUTCHECK; |
||
129 | else |
||
130 | dcmsFlags |= cmsFLAGS_SOFTPROOFING; |
||
68 | Franz | 131 | #ifdef cmsFLAGS_BLACKPOINTCOMPENSATION |
117 | Franz | 132 | if (doc->CMSSettings.BlackPoint) |
204 | Franz | 133 | { |
117 | Franz | 134 | dcmsFlags2 |= cmsFLAGS_BLACKPOINTCOMPENSATION; |
135 | dcmsFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION; |
||
204 | Franz | 136 | } |
68 | Franz | 137 | #endif |
4 | paul | 138 | stdProof = cmsCreateProofingTransform(doc->DocInputProf, TYPE_RGB_16, |
204 | Franz | 139 | doc->DocOutputProf, TYPE_RGB_16, |
140 | doc->DocPrinterProf, |
||
141 | IntentPrinter, |
||
142 | IntentMonitor, dcmsFlags); |
||
4 | paul | 143 | stdTrans = cmsCreateTransform(doc->DocInputProf, TYPE_RGB_16, |
204 | Franz | 144 | doc->DocOutputProf, TYPE_RGB_16, |
145 | IntentMonitor, |
||
146 | dcmsFlags2); |
||
4 | paul | 147 | stdProofImg = cmsCreateProofingTransform(doc->DocInputProf, TYPE_RGBA_8, |
204 | Franz | 148 | doc->DocOutputProf, TYPE_RGBA_8, |
149 | doc->DocPrinterProf, |
||
150 | IntentPrinter, |
||
151 | IntentMonitor, dcmsFlags); |
||
4 | paul | 152 | stdTransImg = cmsCreateTransform(doc->DocInputProf, TYPE_RGBA_8, |
204 | Franz | 153 | doc->DocOutputProf, TYPE_RGBA_8, |
154 | IntentMonitor, |
||
155 | dcmsFlags2); |
||
4 | paul | 156 | #endif |
157 | } |