~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/scribus.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2009-02-09 09:25:18 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090209092518-iqsxmh3pjspgrdyd
Tags: 1.3.5.dfsg~svn20090208-2
debian/control: Use "type-handling -n arm,armel,armeb any" to generate the
list of architectures to build on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 *                                                                         *
22
22
 ***************************************************************************/
23
23
 
24
 
#include <qaccel.h>
25
 
#include <qapplication.h>
26
 
#include <qeventloop.h>
27
 
#include <qcolordialog.h>
28
 
#include <qcolor.h>
29
 
#include <qiconset.h>
30
 
#include <qtextstream.h>
31
 
#include <qstylefactory.h>
32
 
#include <qregexp.h>
33
 
#include <qtextcodec.h>
34
 
#include <qcursor.h>
35
 
#include <qvbox.h>
36
 
#include <qpixmap.h>
37
 
#include <qkeysequence.h>
 
24
#include <QApplication>
 
25
#include <QByteArray>
 
26
#include <QCloseEvent>
 
27
#include <QColor>
 
28
#include <QColorDialog>
 
29
#include <QCursor>
 
30
#include <QDesktopWidget>
 
31
#include <QDragEnterEvent>
 
32
#include <QDropEvent>
 
33
#include <QEvent>
 
34
#include <QEventLoop>
 
35
#include <QFrame>
 
36
#include <QIcon>
 
37
#include <QInputDialog>
 
38
#include <QKeyEvent>
 
39
#include <QKeySequence>
 
40
#include <QLabel>
 
41
#include <QList>
 
42
#include <QLocale>
 
43
#include <QMouseEvent>
 
44
#include <QPixmap>
 
45
#include <QRegExp>
 
46
#include <QStyleFactory>
 
47
#include <QTableWidget>
 
48
#include <QTextCodec>
 
49
#include <QTranslator>
 
50
#include <QWheelEvent>
 
51
 
38
52
 
39
53
#include <cstdio>
40
54
#include <cstdlib>
56
70
#include <signal.h>
57
71
#include <string>
58
72
 
59
 
#include "sccombobox.h"
60
 
#include "scribusapp.h"
61
 
#include "scribuscore.h"
62
 
#include "scribus.h"
63
 
#include "scribus.moc"
64
 
#include "newfile.h"
65
 
#include "page.h"
66
 
#include "query.h"
67
 
#include "mdup.h"
68
 
#include "multipleduplicate.h"
69
 
#include "docinfo.h"
70
 
#include "reformdoc.h"
71
 
#include "serializer.h"
72
 
#include "aligndistribute.h"
73
 
#include "fmitem.h"
74
 
#include "fontprefs.h"
75
 
#include "prefs.h"
76
 
#include "prefscontext.h"
77
 
#include "prefstable.h"
78
 
#include "pdfopts.h"
79
 
#include "pdflib.h"
80
 
#include "inspage.h"
81
 
#include "delpages.h"
82
 
#include "movepage.h"
83
 
#include "helpbrowser.h"
84
 
#include "scribusXml.h"
 
73
 
 
74
 
 
75
 
85
76
#include "about.h"
86
77
#include "aboutplugins.h"
87
 
#include "pslib.h"
88
 
#include "druck.h"
89
 
#include "editformats.h"
90
 
#include "muster.h"
91
 
#include "newtemp.h"
 
78
#include "actionmanager.h"
 
79
#include "aligndistribute.h"
 
80
#include "annot.h"
 
81
#include "annota.h"
92
82
#include "applytemplatedialog.h"
93
 
#include "picstatus.h"
94
 
#include "customfdialog.h"
 
83
#include "arrowchooser.h"
 
84
#include "autoform.h"
 
85
#include "basepointwidget.h"
 
86
#include "bookmarkpalette.h"
 
87
#include "canvasmode.h"
 
88
#include "charselect.h"
 
89
#include "checkDocument.h"
95
90
#include "cmsprefs.h"
96
 
#include "annot.h"
97
 
#include "annota.h"
98
 
#include "javadocs.h"
 
91
#include "collect4output.h"
 
92
#include "colorcombo.h"
99
93
#include "colorm.h"
100
 
#include "mpalette.h"
 
94
#include "commonstrings.h"
 
95
#include "contextmenu.h"
101
96
#include "cpalette.h"
102
 
#include "bookpalette.h"
103
 
#include "seiten.h"
104
 
#include "layers.h"
105
 
#include "frameedit.h"
106
 
#include "splash.h"
107
 
#include "measurements.h"
108
 
#include "gtgettext.h"
 
97
#include "customfdialog.h"
 
98
#include "delpages.h"
 
99
#include "desaxe/digester.h"
 
100
#include "desaxe/saxXML.h"
 
101
#include "desaxe/simple_actions.h"
 
102
#include "docinfo.h"
 
103
#include "docitemattrprefs.h"
 
104
#include "documentchecker.h"
 
105
#include "documentinformation.h"
 
106
#include "effectsdialog.h"
109
107
#include "fileloader.h"
110
 
#include "arrowchooser.h"
111
 
#include "tabtypography.h"
112
 
#include "tabguides.h"
113
 
#include "tabtools.h"
114
 
#include "undogui.h"
115
108
#include "filewatcher.h"
116
 
#include "charselect.h"
117
 
#include "checkDocument.h"
118
 
#include "tabcheckdoc.h"
119
 
#include "tabpdfoptions.h"
120
 
#include "docitemattrprefs.h"
121
 
#include "pageitemattributes.h"
122
 
#include "pageitem_textframe.h"
123
 
#include "pageitem_imageframe.h"
124
 
#include "tocindexprefs.h"
125
 
#include "tocgenerator.h"
126
 
#include "collect4output.h"
 
109
#include "fontcombo.h"
 
110
#include "fontprefs.h"
127
111
#include "fpoint.h"
128
112
#include "fpointarray.h"
 
113
#include "gtgettext.h"
 
114
#include "guidemanager.h"
 
115
#include "helpbrowser.h"
 
116
#include "hruler.h"
 
117
#include "hyphenator.h"
129
118
#include "hysettings.h"
130
 
#include "guidemanager.h"
 
119
#include "imageinfodialog.h"
 
120
#include "insertaframe.h"
 
121
#include "inspage.h"
 
122
#include "javadocs.h"
 
123
#include "langmgr.h"
 
124
#include "layers.h"
 
125
#include "loremipsum.h"
 
126
#include "marginwidget.h"
 
127
#include "margindialog.h"
 
128
#include "masterpagepalette.h"
 
129
#include "menumanager.h"
131
130
#include "mergedoc.h"
132
 
#include "lineformats.h"
133
 
#include "story.h"
134
 
#include "autoform.h"
135
 
#include "tabmanager.h"
136
 
#include "search.h"
137
 
#include "fontcombo.h"
138
 
#include "colorcombo.h"
139
 
#include "prefsfile.h"
140
 
#include "undomanager.h"
141
 
#include "polygonwidget.h"
142
 
#include "werktoolb.h"
143
 
#include "units.h"
144
 
#include "hruler.h"
145
 
#include "vruler.h"
 
131
#include "movepage.h"
 
132
#include "multipleduplicate.h"
 
133
#include "newfile.h"
 
134
#include "newtemp.h"
 
135
#include "nodeeditpalette.h"
 
136
#include "outlinepalette.h"
 
137
#include "page.h"
 
138
#include "pageitem_imageframe.h"
 
139
#include "pageitem_latexframe.h"
 
140
#include "pageitem_textframe.h"
 
141
#include "pageitemattributes.h"
 
142
#include "pagelayout.h"
 
143
#include "pagepalette.h"
146
144
#include "pageselector.h"
147
 
#include "scraction.h"
148
 
#include "menumanager.h"
149
 
#include "undostate.h"
150
 
#include "tree.h"
151
 
#include "scrap.h"
 
145
#include "pagesize.h"
 
146
#include "patterndialog.h"
 
147
#include "pdflib.h"
 
148
#include "pdfoptions.h"
 
149
#include "pdfopts.h"
 
150
#include "picstatus.h"
152
151
#include "pluginmanager.h"
153
 
#include "scpaths.h"
154
 
#include "pdfoptions.h"
155
 
#include "actionmanager.h"
156
 
#include "documentinformation.h"
157
 
#include "effectsdialog.h"
158
 
#include "documentchecker.h"
159
 
#include "gsutil.h"
160
 
#include "pagesize.h"
161
 
#include "loremipsum.h"
162
 
#include "marginWidget.h"
163
 
#include "margindialog.h"
 
152
#include "plugins/formatidlist.h"
 
153
#include "polygonwidget.h"
 
154
#include "prefs.h"
 
155
#include "prefscontext.h"
 
156
#include "prefsfile.h"
164
157
#include "prefsmanager.h"
165
 
#include "pagelayout.h"
166
 
#include "commonstrings.h"
 
158
#include "prefstable.h"
167
159
#include "preview.h"
 
160
#include "printdialog.h"
 
161
#include "propertiespalette.h"
 
162
#include "pslib.h"
 
163
#include "query.h"
 
164
#include "reformdoc.h"
 
165
#include "replacecolors.h"
 
166
#include "resourcecollection.h"
 
167
#include "sccolorengine.h"
 
168
#include "sccombobox.h"
 
169
#include "scgtplugin.h"
 
170
#include "scmessagebox.h"
 
171
#include "scmimedata.h"
 
172
#include "scpaths.h"
 
173
#include "scprintengine_ps.h"
 
174
#include "scraction.h"
 
175
#include "scrapbookpalette.h"
 
176
#include "scribus.h"
 
177
#include "scribusXml.h"
 
178
#include "scribusapp.h"
 
179
#include "scribuscore.h"
168
180
#include "scribuswin.h"
169
 
#include "hyphenator.h"
170
 
#include "scmessagebox.h"
171
 
#include "imageinfodialog.h"
172
 
#include "resourcecollection.h"
 
181
#include "search.h"
173
182
#include "selection.h"
 
183
#include "selectobjects.h"
 
184
#include "serializer.h"
 
185
#include "smlinestyle.h"
 
186
#include "smtextstyles.h"
 
187
#include "splash.h"
 
188
#include "stencilreader.h"
 
189
#include "storyeditor.h"
174
190
#include "stylemanager.h"
175
 
#include "smlinestyle.h"
 
191
#include "tabcheckdoc.h"
 
192
#include "tabguides.h"
 
193
#include "tabmanager.h"
 
194
#include "tabpdfoptions.h"
 
195
#include "tabtools.h"
 
196
#include "tabtypography.h"
 
197
#include "text/nlsconfig.h"
 
198
#include "tocgenerator.h"
 
199
#include "tocindexprefs.h"
 
200
#include "ui/copypagetomasterpagedialog.h"
 
201
#include "ui/edittoolbar.h"
 
202
#include "ui/filetoolbar.h"
 
203
#include "ui/modetoolbar.h"
 
204
#include "ui/pdftoolbar.h"
 
205
#include "undogui.h"
 
206
#include "undomanager.h"
 
207
#include "undostate.h"
 
208
#include "units.h"
 
209
#include "urllauncher.h"
176
210
#include "util.h"
177
 
#include "text/nlsconfig.h"
 
211
#include "util_formats.h"
 
212
#include "util_ghostscript.h"
 
213
#include "util_icon.h"
 
214
#include "vruler.h"
 
215
#include "loadsaveplugin.h"
178
216
#include "plugins/formatidlist.h"
179
 
#include "scgtplugin.h"
180
 
#include "stencilreader.h"
181
 
#include "langmgr.h"
182
 
#include "smtextstyles.h"
183
 
#include "insertaframe.h"
184
 
#include "patterndialog.h"
185
 
#include "sccolorengine.h"
186
 
#include "desaxe/saxXML.h"
187
 
#include "desaxe/digester.h"
188
 
#include "desaxe/simple_actions.h"
 
217
 
189
218
 
190
219
#if defined(_WIN32)
191
 
#include "scwinprint.h"
192
220
#include "scdocoutput_ps2.h"
 
221
#include "scprintengine_gdi.h"
193
222
#endif
194
223
 
195
224
using namespace std;
199
228
 
200
229
QString DocDir;
201
230
 
202
 
//extern ScribusCore* ScCore;
 
231
 
203
232
extern ScribusQApp* ScQApp;
204
233
extern bool emergencyActivated;
205
234
 
 
235
 
206
236
ScribusMainWindow::ScribusMainWindow()
207
237
{
208
238
        actionManager=0;
209
239
        scrMenuMgr=0;
210
240
        prefsManager=0;
 
241
        formatsManager=0;
 
242
        UrlLauncher::instance();
211
243
        mainWindowStatusLabel=0;
212
244
        ExternalApp=0;
213
245
#ifdef Q_WS_MAC
214
246
        noIcon = loadIcon("noicon.xpm");
215
247
#endif
216
 
} // ScribusMainWindow::ScribusMainWindow()
 
248
}
 
249
 
 
250
/*
 
251
static QCoreApplication::EventFilter origEventFilter = 0;
 
252
 
 
253
bool reportFocusChanges(void *message, long *result)
 
254
{
 
255
        unsigned* data = static_cast<unsigned*>(message);
 
256
        if (QApplication::focusWidget())
 
257
                qDebug() << QApplication::applicationFilePath() << reinterpret_cast<void*>(QApplication::focusWidget()) << typeid(*QApplication::focusWidget()).name() << QApplication::focusWidget()->objectName() << message << data[0] << data[1] << data[2] << data[3] << data[4] << data[5] << data[6] << data[7];
 
258
        else
 
259
                qDebug() << QApplication::applicationFilePath() << "no focus" << message << data[0] << data[1] << data[2] << data[3] << data[4] << data[5] << data[6] << data[7];
 
260
        return origEventFilter && origEventFilter(message, result);
 
261
}
 
262
*/
217
263
 
218
264
/*
219
265
 * retval 0 - ok, 1 - no fonts, ...
222
268
{
223
269
        int retVal=0;
224
270
 
225
 
//      CommonStrings::languageChange();
 
271
        QByteArray stylesheet;
 
272
        if (loadRawText(ScPaths::getApplicationDataDir() + "/stylesheet.css", stylesheet))
 
273
        {
 
274
                qApp->setStyleSheet(QString(stylesheet));
 
275
        }
 
276
 
 
277
//      origEventFilter = qApp->setEventFilter(reportFocusChanges);
 
278
 
226
279
        previewDinUse = false;
227
280
        printDinUse = false;
228
 
//      guiLanguage = newGuiLanguage;
229
 
//      initSplash(showSplash);
230
 
        setUsesBigPixmaps(true);
 
281
        internalCopy = false;
231
282
        CurrStED = NULL;
232
 
        setCaption( tr("Scribus " VERSION));
233
 
        setKeyCompression(false);
234
 
        setIcon(loadIcon("AppIcon.png"));
 
283
        setWindowTitle( tr("Scribus " VERSION));
 
284
        setAttribute(Qt::WA_KeyCompression, false);
 
285
        setWindowIcon(loadIcon("AppIcon.png"));
235
286
        scrActionGroups.clear();
236
 
        scrActionGroups.setAutoDelete(true);
237
287
        scrActions.clear();
238
288
        scrRecentFileActions.clear();
239
289
        scrRecentPasteActions.clear();
241
291
        scrLayersActions.clear();
242
292
        scrMenuMgr = new MenuManager(menuBar());
243
293
        prefsManager = PrefsManager::instance();
 
294
        formatsManager = FormatsManager::instance();
244
295
        objectSpecificUndo = false;
245
296
 
246
297
        undoManager = UndoManager::instance();
255
306
 
256
307
        qApp->processEvents();
257
308
 
258
 
        BuFromApp = false;
259
 
 
260
 
        actionManager = new ActionManager(this, "actionManager");
 
309
        actionManager = new ActionManager(this);
261
310
        actionManager->init(this);
 
311
//      if (primaryMainWindow)
 
312
//              ScCore->setSplashStatus( tr("Applying User Shortcuts") );
 
313
//      prefsManager->applyLoadedShortCuts();
 
314
//      initKeyboardShortcuts();
262
315
        initMenuBar();
263
316
        initToolBars();
264
 
        buildFontMenu();
265
317
        ScCore->pluginManager->setupPluginActions(this);
266
318
        ScCore->pluginManager->languageChange();
 
319
        if (primaryMainWindow)
 
320
                ScCore->setSplashStatus( tr("Applying User Shortcuts") );
 
321
        prefsManager->applyLoadedShortCuts();
267
322
        initKeyboardShortcuts();
268
 
        if (primaryMainWindow)
269
 
                ScCore->setSplashStatus( tr("Setting up Shortcuts") );
270
 
        SetShortCut();
271
323
 
272
324
        resize(610, 600);
273
 
        QVBox* vb = new QVBox( this );
274
 
        vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
275
 
        wsp = new QWorkspace( vb );
276
 
        setCentralWidget( vb );
 
325
        wsp = new QWorkspace( this );
 
326
        setCentralWidget( wsp );
277
327
        connect(wsp, SIGNAL(windowActivated(QWidget *)), this, SLOT(newActWin(QWidget *)));
278
328
        //Connect windows cascade and tile actions to the workspace after its created. Only depends on wsp created.
279
 
        connect( scrActions["windowsCascade"], SIGNAL(activated()) , wsp, SLOT(cascade()) );
280
 
        connect( scrActions["windowsTile"], SIGNAL(activated()) , wsp, SLOT(tile()) );
 
329
        connect( scrActions["windowsCascade"], SIGNAL(triggered()) , wsp, SLOT(cascade()) );
 
330
        connect( scrActions["windowsTile"], SIGNAL(triggered()) , wsp, SLOT(tile()) );
281
331
        initPalettes();
282
332
 
283
333
        prefsManager->setupMainWindow(this);
288
338
 
289
339
        DocDir = prefsManager->documentDir();
290
340
 
291
 
 
292
341
        if (primaryMainWindow)
293
342
                ScCore->setSplashStatus( tr("Initializing Hyphenator") );
294
343
        QString preLang = prefsManager->appPrefs.Language;
295
344
        initHyphenator();
296
 
        if (Sprachen.contains(preLang))
 
345
        if (!LanguageManager::instance()->getHyphFilename( preLang, false ).isEmpty() )
297
346
                prefsManager->appPrefs.Language = preLang;
298
347
        if (primaryMainWindow)
299
348
                ScCore->setSplashStatus( tr("Reading Scrapbook") );
300
349
        initScrapbook();
301
350
 
302
 
        scrActions["helpTooltips"]->setOn(prefsManager->appPrefs.showToolTips);
303
 
        scrActions["stickyTools"]->setOn(prefsManager->appPrefs.stickyTools);
 
351
        scrActions["helpTooltips"]->setChecked(prefsManager->appPrefs.showToolTips);
 
352
        scrActions["showMouseCoordinates"]->setChecked(prefsManager->appPrefs.showMouseCoordinates);
 
353
        scrActions["stickyTools"]->setChecked(prefsManager->appPrefs.stickyTools);
304
354
        ToggleTips();
 
355
        ToggleMouseTips();
305
356
        propertiesPalette->setFontSize();
306
357
        if (scrActions["SaveAsDocumentTemplate"])
307
358
                scrActions["SaveAsDocumentTemplate"]->setEnabled(false);
308
359
 
309
360
        connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString )), this, SLOT(removeRecent(QString)));
310
361
        connect(this, SIGNAL(TextStyle(const ParagraphStyle&)), propertiesPalette, SLOT(updateStyle(const ParagraphStyle&)));
311
 
        // to go:  (av)
312
 
        connect(this, SIGNAL(TextIFont(const QString&)), this, SLOT(AdjustFontMenu(const QString&)));
313
 
        connect(this, SIGNAL(TextIFont(const QString&)), propertiesPalette, SLOT(setFontFace(const QString&)));
314
 
        connect(this, SIGNAL(TextISize(int)), this, SLOT(setFSizeMenu(int)));
315
 
        connect(this, SIGNAL(TextISize(int)), propertiesPalette, SLOT(setSize(int)));
316
 
        connect(this, SIGNAL(TextUSval(int)), propertiesPalette, SLOT(setExtra(int)));
 
362
        connect(this, SIGNAL(TextIFont(QString)), propertiesPalette, SLOT(setFontFace(QString)));
 
363
        connect(this, SIGNAL(TextISize(double)), propertiesPalette, SLOT(setSize(double)));
 
364
        connect(this, SIGNAL(TextUSval(double)), propertiesPalette, SLOT(setExtra(double)));
317
365
        connect(this, SIGNAL(TextStil(int)), propertiesPalette, SLOT(setStil(int)));
318
 
        connect(this, SIGNAL(TextScale(int)), propertiesPalette, SLOT(setTScale(int)));
319
 
        connect(this, SIGNAL(TextScaleV(int)), propertiesPalette, SLOT(setTScaleV(int)));
320
 
        connect(this, SIGNAL(TextBase(int)), propertiesPalette, SLOT(setTBase(int)));
321
 
        connect(this, SIGNAL(TextShadow(int, int )), propertiesPalette, SLOT(setShadowOffs(int, int )));
322
 
        connect(this, SIGNAL(TextOutline(int)), propertiesPalette, SLOT(setOutlineW(int)));
323
 
        connect(this, SIGNAL(TextUnderline(int, int)), propertiesPalette, SLOT(setUnderline(int, int)));
324
 
        connect(this, SIGNAL(TextStrike(int, int)), propertiesPalette, SLOT(setStrike(int, int)));
325
 
        connect(this, SIGNAL(TextFarben(QString, QString, int, int)), propertiesPalette, SLOT(setActFarben(QString, QString, int, int)));
 
366
        connect(this, SIGNAL(TextScale(double)), propertiesPalette, SLOT(setTScale(double)));
 
367
        connect(this, SIGNAL(TextScaleV(double)), propertiesPalette, SLOT(setTScaleV(double)));
 
368
        connect(this, SIGNAL(TextBase(double)), propertiesPalette, SLOT(setTBase(double)));
 
369
        connect(this, SIGNAL(TextShadow(double, double )), propertiesPalette, SLOT(setShadowOffs(double, double )));
 
370
        connect(this, SIGNAL(TextOutline(double)), propertiesPalette, SLOT(setOutlineW(double)));
 
371
        connect(this, SIGNAL(TextUnderline(double, double)), propertiesPalette, SLOT(setUnderline(double, double)));
 
372
        connect(this, SIGNAL(TextStrike(double, double)), propertiesPalette, SLOT(setStrike(double, double)));
 
373
        connect(this, SIGNAL(TextFarben(QString, QString, double, double)), propertiesPalette, SLOT(setActFarben(QString, QString, double, double)));
326
374
        connect(ClipB, SIGNAL(dataChanged()), this, SLOT(ClipChange()));
327
375
//      connect(ClipB, SIGNAL(selectionChanged()), this, SLOT(ClipChange()));
328
376
        setAcceptDrops(true);
 
377
        QCoreApplication::instance()->installEventFilter(this);
 
378
        scrActions["toolsSelect"]->setChecked(true);
 
379
 
329
380
        return retVal;
330
381
}
331
382
 
 
383
 
332
384
ScribusMainWindow::~ScribusMainWindow()
333
385
{
334
386
}
335
387
 
 
388
void ScribusMainWindow::addScToolBar(ScToolBar *tb, QString name)
 
389
{
 
390
        if (!scrToolBars.contains(name))
 
391
                scrToolBars.insert(name, tb);
 
392
        addToolBar(tb);
 
393
}
336
394
 
337
395
void ScribusMainWindow::initToolBars()
338
396
{
339
 
        fileToolBar = new ScToolBar( tr("File"), "File", this);
340
 
        scrActions["fileNew"]->addTo(fileToolBar);
341
 
        scrActions["fileOpen"]->addTo(fileToolBar);
342
 
        scrMenuMgr->addMenuToWidgetOfAction("FileOpenRecent", scrActions["fileOpen"]);
343
 
        scrActions["fileSave"]->addTo(fileToolBar);
344
 
        scrActions["fileClose"]->addTo(fileToolBar);
345
 
        scrActions["filePrint"]->addTo(fileToolBar);
346
 
        scrActions["toolsPreflightVerifier"]->addTo(fileToolBar);
347
 
        scrActions["fileExportAsPDF"]->addTo(fileToolBar);
348
 
 
349
 
        editToolBar = new ScToolBar( tr("Edit"), "Edit", this);
 
397
        fileToolBar = new FileToolBar(this);
 
398
        editToolBar = new EditToolBar(this);
350
399
        UndoWidget* uWidget = new UndoWidget(editToolBar, "uWidget");
351
400
        undoManager->registerGui(uWidget);
352
 
 
353
 
        mainToolBar = new ModeToolBar(this);
 
401
        modeToolBar = new ModeToolBar(this);
354
402
        pdfToolBar = new PDFToolBar(this);
355
403
 
356
 
        connect(mainToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarTools"], SLOT(setOn(bool)));
357
 
        connect(scrActions["toolsToolbarPDF"], SIGNAL(toggled(bool)), pdfToolBar, SLOT(setShown(bool)));
358
 
        connect(pdfToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarPDF"], SLOT(setOn(bool)));
359
 
        connect(scrActions["toolsToolbarTools"], SIGNAL(toggled(bool)), mainToolBar, SLOT(setShown(bool)) );
 
404
        addScToolBar(fileToolBar, "ToolBar-File");
 
405
        addScToolBar(editToolBar, "ToolBar-Edit");
 
406
        addScToolBar(modeToolBar, "ToolBar-Tools");
 
407
        addScToolBar(pdfToolBar, "ToolBar-PDF_Tools");
 
408
 
 
409
        connect(modeToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarTools"], SLOT(setChecked(bool)));
 
410
        connect(scrActions["toolsToolbarPDF"], SIGNAL(toggled(bool)), pdfToolBar, SLOT(setVisible(bool)));
 
411
        connect(pdfToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarPDF"], SLOT(setChecked(bool)));
 
412
        connect(scrActions["toolsToolbarTools"], SIGNAL(toggled(bool)), modeToolBar, SLOT(setVisible(bool)) );
360
413
}
361
414
 
 
415
 
362
416
void ScribusMainWindow::initDefaultValues()
363
417
{
364
418
        HaveDoc = false;
365
419
        ScriptRunning = false;
366
420
        view = NULL;
367
421
        doc = NULL;
368
 
        Buffer2 = "";
369
422
        DocNr = 1;
370
423
        PrinterUsed = false;
371
424
        PDef.Pname = "";
378
431
        guidesStatus[0] = false;
379
432
}
380
433
 
 
434
 
381
435
void ScribusMainWindow::initKeyboardShortcuts()
382
436
{
383
 
        for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrActions.begin(); it!=scrActions.end(); ++it )
 
437
        for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrActions.begin(); it!=scrActions.end(); ++it )
384
438
        {
385
 
                if ((ScrAction*)(it.data())!=NULL)
 
439
                if ((ScrAction*)(it.value())!=NULL)
386
440
                {
387
 
                        QString accelerator=it.data()->accel();
388
 
                        prefsManager->setKeyEntry(it.key(), it.data()->cleanMenuText(), accelerator,0);
 
441
                        QString accelerator=it.value()->shortcut();
 
442
                        prefsManager->setKeyEntry(it.key(), it.value()->cleanMenuText(), accelerator,0);
389
443
                }
390
444
                //else
391
 
                //      qDebug(it.key());
392
 
                //qDebug(QString("|-\n|%1||%2||%3").arg(it.key()).arg(it.data()->cleanMenuText()).arg(QString(it.data()->accel())));
 
445
                //      qDebug() << it.key();
 
446
                //qDebug() << QString("|-\n|%1||%2||%3").arg(it.key()).arg(it.value()->cleanMenuText()).arg(QString(it.data()->accel()));
393
447
        }
394
448
}
395
449
 
 
450
 
396
451
void ScribusMainWindow::initPalettes()
397
452
{
398
453
        //CB TODO hide the publicly available members of some palettes
399
454
        // these must be filtered too as they take control of the palettes events
400
 
        outlinePalette = new Tree(this);
 
455
        outlinePalette = new OutlinePalette(this);
401
456
        outlinePalette->setMainWindow(this);
402
457
        connect( scrActions["toolsOutline"], SIGNAL(toggled(bool)) , outlinePalette, SLOT(setPaletteShown(bool)) );
403
 
        connect( outlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsOutline"], SLOT(setOn(bool)));
404
 
        propertiesPalette = new Mpalette(ScCore->m_PaletteParent);
 
458
        connect( outlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsOutline"], SLOT(setChecked(bool)));
 
459
        propertiesPalette = new PropertiesPalette(this);
405
460
        propertiesPalette->setMainWindow(this);
406
461
        connect( scrActions["toolsProperties"], SIGNAL(toggled(bool)) , propertiesPalette, SLOT(setPaletteShown(bool)) );
407
 
        connect( propertiesPalette, SIGNAL(paletteShown(bool)), scrActions["toolsProperties"], SLOT(setOn(bool)));
 
462
        connect( propertiesPalette, SIGNAL(paletteShown(bool)), scrActions["toolsProperties"], SLOT(setChecked(bool)));
408
463
 
409
464
        //CB dont need this until we have a doc...
410
465
        //propertiesPalette->Cpal->SetColors(prefsManager->colorSet());
416
471
        guidePalette = new GuideManager(this);
417
472
        charPalette = new CharSelect(this);
418
473
        connect( scrActions["toolsLayers"], SIGNAL(toggled(bool)) , layerPalette, SLOT(setPaletteShown(bool)) );
419
 
        connect( layerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsLayers"], SLOT(setOn(bool)));
 
474
        connect( layerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsLayers"], SLOT(setChecked(bool)));
420
475
        layerPalette->installEventFilter(this);
421
476
        layerPalette->Table->installEventFilter(this);
422
477
        scrapbookPalette = new Biblio(this);
423
478
        connect( scrActions["toolsScrapbook"], SIGNAL(toggled(bool)) , scrapbookPalette, SLOT(setPaletteShown(bool)) );
424
 
        connect( scrapbookPalette, SIGNAL(paletteShown(bool)), scrActions["toolsScrapbook"], SLOT(setOn(bool)));
 
479
        connect( scrapbookPalette, SIGNAL(paletteShown(bool)), scrActions["toolsScrapbook"], SLOT(setChecked(bool)));
 
480
        connect( scrapbookPalette, SIGNAL(pasteToActualPage(QString)), this, SLOT(pasteFromScrapbook(QString)));
425
481
        scrapbookPalette->installEventFilter(this);
426
482
        pagePalette = new PagePalette(this);
427
483
        connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , pagePalette, SLOT(setPaletteShown(bool)) );
428
484
        connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , this, SLOT(setPagePalette(bool)) );
429
 
        connect( pagePalette, SIGNAL(paletteShown(bool)), scrActions["toolsPages"], SLOT(setOn(bool)));
 
485
        connect( pagePalette, SIGNAL(paletteShown(bool)), scrActions["toolsPages"], SLOT(setChecked(bool)));
430
486
        pagePalette->installEventFilter(this);
431
487
        bookmarkPalette = new BookPalette(this);
432
488
        connect( scrActions["toolsBookmarks"], SIGNAL(toggled(bool)) , bookmarkPalette, SLOT(setPaletteShown(bool)) );
433
 
        connect( bookmarkPalette, SIGNAL(paletteShown(bool)), scrActions["toolsBookmarks"], SLOT(setOn(bool)));
 
489
        connect( bookmarkPalette, SIGNAL(paletteShown(bool)), scrActions["toolsBookmarks"], SLOT(setChecked(bool)));
434
490
        bookmarkPalette->installEventFilter(this);
435
 
        measurementPalette = new Measurements(this);
436
 
        connect( scrActions["toolsMeasurements"], SIGNAL(toggled(bool)) , measurementPalette, SLOT(setPaletteShown(bool)) );
 
491
//      measurementPalette = new Measurements(this);
 
492
//      connect( scrActions["toolsMeasurements"], SIGNAL(toggled(bool)) , measurementPalette, SLOT(setPaletteShown(bool)) );
437
493
        connect( scrActions["toolsMeasurements"], SIGNAL(toggledData(bool, int)) , this, SLOT(setAppModeByToggle(bool, int)) );
438
 
        connect( measurementPalette, SIGNAL(paletteShown(bool)), scrActions["toolsMeasurements"], SLOT(setOn(bool)));
439
 
        measurementPalette->installEventFilter(this);
440
 
        measurementPalette->hide();
 
494
//      connect( measurementPalette, SIGNAL(paletteShown(bool)), scrActions["toolsMeasurements"], SLOT(setChecked(bool)));
 
495
//      measurementPalette->installEventFilter(this);
 
496
//      measurementPalette->hide();
441
497
        docCheckerPalette = new CheckDocument(this, false);
442
498
        connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , docCheckerPalette, SLOT(setPaletteShown(bool)) );
443
499
        connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , this, SLOT(docCheckToggle(bool)) );
444
 
        connect( docCheckerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsPreflightVerifier"], SLOT(setOn(bool)));
 
500
        connect( docCheckerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsPreflightVerifier"], SLOT(setChecked(bool)));
445
501
        connect( docCheckerPalette, SIGNAL(paletteShown(bool)), this, SLOT(docCheckToggle(bool)));
446
502
        docCheckerPalette->installEventFilter(this);
447
503
        docCheckerPalette->hide();
448
504
 
449
505
        alignDistributePalette = new AlignDistributePalette(this, "AlignDistributePalette", false);
450
506
        connect( scrActions["toolsAlignDistribute"], SIGNAL(toggled(bool)) , alignDistributePalette, SLOT(setPaletteShown(bool)) );
451
 
        connect( alignDistributePalette, SIGNAL(paletteShown(bool)), scrActions["toolsAlignDistribute"], SLOT(setOn(bool)));
 
507
        connect( alignDistributePalette, SIGNAL(paletteShown(bool)), scrActions["toolsAlignDistribute"], SLOT(setChecked(bool)));
452
508
        connect( alignDistributePalette, SIGNAL(documentChanged()), this, SLOT(slotDocCh()));
453
509
        alignDistributePalette->installEventFilter(this);
454
510
 
464
520
        SMCharacterStyle *tmpCS = new SMCharacterStyle();
465
521
        styleManager->addStyle(new SMParagraphStyle(tmpCS->tmpStyles()));
466
522
        styleManager->addStyle(tmpCS);
467
 
        connect( scrActions["editStyles"], SIGNAL(toggled(bool)) , styleManager, SLOT(setPaletteShown(bool)) );
468
 
        connect( styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setOn(bool)));
 
523
        connect( scrActions["editStyles"], SIGNAL(toggled(bool)), styleManager, SLOT(setPaletteShown(bool)) );
 
524
        connect( styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setChecked(bool)));
469
525
        styleManager->installEventFilter(this);
470
526
 
471
527
        connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(selectItemsFromOutlines(int, int)));
477
533
        connect(propertiesPalette->paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewParStyle(const QString&)));
478
534
        connect(propertiesPalette->charStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewCharStyle(const QString&)));
479
535
//      connect(propertiesPalette, SIGNAL(EditLSt()), this, SLOT(slotEditLineStyles()));
480
 
        connect(nodePalette, SIGNAL(Schliessen()), this, SLOT(NoFrameEdit()));
 
536
        connect(nodePalette, SIGNAL(Schliessen()), propertiesPalette, SLOT(endEdit2()));
 
537
        connect(nodePalette, SIGNAL(Schliessen()), this, SLOT(slotSelect()));
481
538
        connect(nodePalette, SIGNAL(DocChanged()), this, SLOT(slotDocCh()));
482
539
        connect(layerPalette, SIGNAL(LayerChanged()), this, SLOT(showLayer()));
483
540
 
486
543
        connect(bookmarkPalette->BView, SIGNAL(SelectElement(PageItem *)), this, SLOT(selectItemsFromOutlines(PageItem *)));
487
544
        // guides
488
545
        connect(scrActions["pageManageGuides"], SIGNAL(toggled(bool)), guidePalette, SLOT(setPaletteShown(bool)));
489
 
        connect(guidePalette, SIGNAL(paletteShown(bool)), scrActions["pageManageGuides"], SLOT(setOn(bool)));
 
546
        connect(guidePalette, SIGNAL(paletteShown(bool)), scrActions["pageManageGuides"], SLOT(setChecked(bool)));
490
547
        // char palette
491
548
        connect(scrActions["insertGlyph"], SIGNAL(toggled(bool)), charPalette, SLOT(setPaletteShown(bool)));
492
 
        connect(charPalette, SIGNAL(paletteShown(bool)), scrActions["insertGlyph"], SLOT(setOn(bool)));
 
549
        connect(charPalette, SIGNAL(paletteShown(bool)), scrActions["insertGlyph"], SLOT(setChecked(bool)));
493
550
}
494
551
 
 
552
 
495
553
void ScribusMainWindow::initScrapbook()
496
554
{
497
555
        QString scrapbookFileO = QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrap13.scs");
516
574
        connect(scrapbookPalette, SIGNAL(updateRecentMenue()), this, SLOT(rebuildRecentPasteMenu()));
517
575
}
518
576
 
 
577
 
519
578
bool ScribusMainWindow::warningVersion(QWidget *parent)
520
579
{
521
580
        bool retval = false;
522
581
        int t = ScMessageBox::warning(parent, QObject::tr("Scribus Development Version"), "<qt>" +
523
582
                                                                 QObject::tr("You are running a development version of Scribus 1.3.x. The document you are working with was created in Scribus 1.2.x.  Saving the current file under 1.3.x renders it unable to be edited in Scribus 1.2.x versions. To preserve the ability to edit in 1.2.x, save this file under a different name and further edit the newly named file and the original will be untouched. Are you sure you wish to proceed with this operation?") + "</qt>",
524
 
                                                                 CommonStrings::tr_OK, CommonStrings::tr_Cancel, "", 1, 0);
525
 
        if (t == 0)
 
583
                                                                 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
 
584
        if (t == QMessageBox::Ok)
526
585
                retval = true;
527
586
        return retval;
528
587
}
529
588
 
 
589
 
530
590
void ScribusMainWindow::initMenuBar()
531
591
{
532
592
        RecentDocs.clear();
533
 
 
534
 
        scrMenuMgr->createMenu("File", tr("&File"));
 
593
        scrMenuMgr->createMenu("File", ActionManager::defaultMenuNameEntryTranslated("File"));
535
594
        scrMenuMgr->addMenuItem(scrActions["fileNew"], "File");
536
595
        scrMenuMgr->addMenuItem(scrActions["fileOpen"], "File");
537
596
        recentFileMenuName="FileOpenRecent";
538
 
        scrMenuMgr->createMenu(recentFileMenuName, QIconSet(noIcon), tr("Open &Recent"), "File");
 
597
        scrMenuMgr->createMenu(recentFileMenuName, tr("Open &Recent"), "File");
539
598
        scrMenuMgr->addMenuSeparator("File");
540
599
        scrMenuMgr->addMenuItem(scrActions["fileClose"], "File");
541
600
        scrMenuMgr->addMenuItem(scrActions["fileSave"], "File");
543
602
        scrMenuMgr->addMenuItem(scrActions["fileRevert"], "File");
544
603
        scrMenuMgr->addMenuItem(scrActions["fileCollect"], "File");
545
604
        scrMenuMgr->addMenuSeparator("File");
546
 
        scrMenuMgr->createMenu("FileImport", QIconSet(noIcon), tr("&Import"), "File");
 
605
        scrMenuMgr->createMenu("FileImport", tr("&Import"), "File");
547
606
        scrMenuMgr->addMenuItem(scrActions["fileImportText"], "FileImport");
548
607
//      scrMenuMgr->addMenuItem(scrActions["fileImportText2"], "FileImport");
549
608
        scrMenuMgr->addMenuItem(scrActions["fileImportAppendText"], "FileImport");
550
609
        scrMenuMgr->addMenuItem(scrActions["fileImportImage"], "FileImport");
551
 
        scrMenuMgr->createMenu("FileExport", QIconSet(noIcon), tr("&Export"), "File");
 
610
        scrMenuMgr->addMenuItem(scrActions["fileImportVector"], "FileImport");
 
611
 
 
612
        scrMenuMgr->createMenu("FileExport", tr("&Export"), "File");
552
613
        scrMenuMgr->addMenuItem(scrActions["fileExportText"], "FileExport");
553
614
        scrMenuMgr->addMenuItem(scrActions["fileExportAsEPS"], "FileExport");
554
615
        scrMenuMgr->addMenuItem(scrActions["fileExportAsPDF"], "FileExport");
580
641
        scrActions["filePrint"]->setEnabled(false);
581
642
        scrActions["PrintPreview"]->setEnabled(false);
582
643
 
583
 
        scrMenuMgr->createMenu("Edit", tr("&Edit"));
 
644
        scrMenuMgr->createMenu("Edit", ActionManager::defaultMenuNameEntryTranslated("Edit"));
584
645
        scrMenuMgr->addMenuItem(scrActions["editUndoAction"], "Edit");
585
646
        scrMenuMgr->addMenuItem(scrActions["editRedoAction"], "Edit");
586
647
        scrMenuMgr->addMenuItem(scrActions["editActionMode"], "Edit");
589
650
        scrMenuMgr->addMenuItem(scrActions["editCopy"], "Edit");
590
651
        scrMenuMgr->addMenuItem(scrActions["editPaste"], "Edit");
591
652
        recentPasteMenuName="EditPasteRecent";
592
 
        scrMenuMgr->createMenu(recentPasteMenuName, QIconSet(noIcon), tr("Paste Recent"), "Edit");
593
 
        scrMenuMgr->createMenu("EditContents", QPixmap(noIcon), tr("Contents"), "Edit");
 
653
        scrMenuMgr->createMenu(recentPasteMenuName, tr("Paste Recent"), "Edit");
 
654
        scrMenuMgr->createMenu("EditContents", tr("Contents"), "Edit");
594
655
        scrMenuMgr->addMenuItem(scrActions["editCopyContents"], "EditContents");
595
656
        scrMenuMgr->addMenuItem(scrActions["editPasteContents"], "EditContents");
596
657
        scrMenuMgr->addMenuItem(scrActions["editPasteContentsAbs"], "EditContents");
597
658
        scrMenuMgr->addMenuItem(scrActions["editClearContents"], "EditContents");
598
659
        scrMenuMgr->addMenuSeparator("Edit");
599
660
        scrMenuMgr->addMenuItem(scrActions["editSelectAll"], "Edit");
 
661
        scrMenuMgr->addMenuItem(scrActions["editSelectAllOnLayer"], "Edit");
600
662
        scrMenuMgr->addMenuItem(scrActions["editDeselectAll"], "Edit");
601
663
        scrMenuMgr->addMenuSeparator("Edit");
602
664
        scrMenuMgr->addMenuItem(scrActions["editSearchReplace"], "Edit");
603
665
        scrMenuMgr->addMenuItem(scrActions["toolsEditWithStoryEditor"], "Edit");
604
666
        scrMenuMgr->addMenuItem(scrActions["editEditWithImageEditor"], "Edit");
 
667
        scrMenuMgr->addMenuItem(scrActions["editEditRenderSource"], "Edit");
605
668
        scrMenuMgr->addMenuSeparator("Edit");
606
669
        scrMenuMgr->addMenuItem(scrActions["editColors"], "Edit");
 
670
        scrMenuMgr->addMenuItem(scrActions["editReplaceColors"], "Edit");
607
671
        scrMenuMgr->addMenuItem(scrActions["editPatterns"], "Edit");
608
672
        scrMenuMgr->addMenuItem(scrActions["editStyles"], "Edit");
609
673
        scrMenuMgr->addMenuItem(scrActions["editMasterPages"], "Edit");
621
685
        scrActions["editPasteContentsAbs"]->setEnabled(false);
622
686
        scrActions["editClearContents"]->setEnabled(false);
623
687
        scrActions["editSelectAll"]->setEnabled(false);
 
688
        scrActions["editSelectAllOnLayer"]->setEnabled(false);
624
689
        scrActions["editDeselectAll"]->setEnabled(false);
625
690
        scrActions["editSearchReplace"]->setEnabled(false);
 
691
        scrActions["editReplaceColors"]->setEnabled(false);
626
692
        scrActions["editPatterns"]->setEnabled(false);
627
693
        scrActions["editStyles"]->setEnabled(false);
628
694
        scrActions["editMasterPages"]->setEnabled(false);
629
695
        scrActions["editJavascripts"]->setEnabled(false);
630
696
        scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
631
697
        scrActions["editEditWithImageEditor"]->setEnabled(false);
632
 
 
633
 
        //Style Menu
634
 
        scrMenuMgr->createMenu("Style", tr("St&yle"));
635
 
        //Color menu
636
 
        // CB TODO
637
 
        scrMenuMgr->createMenu("Color", tr("&Color"));
638
 
        ColorMenC = new ColorCombo(false);
639
 
        ColorMenC->setEditable(false);
640
 
        scrMenuMgr->addMenuItem(ColorMenC, "Color");
641
 
 
642
 
        //Text size menu
643
 
        scrMenuMgr->createMenu("FontSize", tr("&Size"));
644
 
        scrActionGroups["fontSize"]->addTo(scrMenuMgr->getLocalPopupMenu("FontSize"));
645
 
 
646
 
        //Shade menu
647
 
        scrMenuMgr->createMenu("Shade", tr("&Shade"));
648
 
        scrActionGroups["shade"]->addTo(scrMenuMgr->getLocalPopupMenu("Shade"));
649
 
 
650
 
        //Font menu
651
 
        scrMenuMgr->createMenu("Font", tr("&Font"));
652
 
        FontMenu = scrMenuMgr->getLocalPopupMenu("Font");
653
 
 
654
 
        //Type style menu
655
 
        scrMenuMgr->createMenu("TypeEffects", tr("&Effects"));
656
 
        scrActionGroups["typeEffects"]->addTo(scrMenuMgr->getLocalPopupMenu("TypeEffects"));
 
698
        scrActions["editEditRenderSource"]->setEnabled(false);
657
699
 
658
700
        //Item Menu
659
 
        scrMenuMgr->createMenu("Item", tr("&Item"));
 
701
        scrMenuMgr->createMenu("Item", ActionManager::defaultMenuNameEntryTranslated("Item"));
660
702
        scrMenuMgr->addMenuItem(scrActions["itemDuplicate"], "Item");
661
703
        scrMenuMgr->addMenuItem(scrActions["itemMulDuplicate"], "Item");
662
704
        scrMenuMgr->addMenuItem(scrActions["itemDelete"], "Item");
679
721
        scrMenuMgr->addMenuItem(scrActions["itemSendToPattern"], "Item");
680
722
        scrMenuMgr->addMenuSeparator("Item");
681
723
        scrMenuMgr->addMenuItem(scrActions["itemAdjustFrameToImage"], "Item");
 
724
        scrMenuMgr->addMenuItem(scrActions["itemAdjustImageToFrame"], "Item");
682
725
        scrMenuMgr->addMenuItem(scrActions["itemExtendedImageProperties"], "Item");
683
726
        scrMenuMgr->addMenuItem(scrActions["itemUpdateImage"], "Item");
684
727
        scrMenuMgr->createMenu("ItemPreviewSettings", tr("Preview Settings"), "Item");
695
738
        scrMenuMgr->addMenuItem(scrActions["itemPDFIsBookmark"], "ItemPDFOptions");
696
739
        scrMenuMgr->addMenuItem(scrActions["itemPDFAnnotationProps"], "ItemPDFOptions");
697
740
        scrMenuMgr->addMenuItem(scrActions["itemPDFFieldProps"], "ItemPDFOptions");
698
 
        scrMenuMgr->createMenu("ItemShapes", tr("&Shape"), "Item");
699
 
        // CB TODO
700
 
        //Shape menu
701
 
        SCustom = new Autoforms(0);
702
 
        scrMenuMgr->addMenuItem(SCustom, "ItemShapes");
703
 
        connect(SCustom, SIGNAL(FormSel(int, int, double *)), this, SLOT(MakeFrame(int, int, double *)));
704
 
        scrMenuMgr->addMenuItem(scrActions["itemShapeEdit"], "ItemShapes");
705
 
        scrMenuMgr->createMenu("ItemConvertTo", QPixmap(noIcon), tr("C&onvert To"), "Item");
706
 
        //scrMenuMgr->createMenu("ItemConvertTo", tr("C&onvert To"));
707
 
        //scrMenuMgr->addMenuToMenu("ItemConvertTo", "Item");
 
741
        //scrMenuMgr->createMenu("ItemShapes", tr("&Shape"), "Item");
 
742
        scrMenuMgr->createMenu("ItemConvertTo", tr("C&onvert To"), "Item");
708
743
        scrMenuMgr->addMenuItem(scrActions["itemConvertToBezierCurve"], "ItemConvertTo");
709
744
        scrMenuMgr->addMenuItem(scrActions["itemConvertToImageFrame"], "ItemConvertTo");
710
745
        scrMenuMgr->addMenuItem(scrActions["itemConvertToOutlines"], "ItemConvertTo");
713
748
 
714
749
        scrMenuMgr->addMenuItem(scrActions["itemAttachTextToPath"], "Item");
715
750
        scrMenuMgr->addMenuItem(scrActions["itemDetachTextFromPath"], "Item");
 
751
//      scrMenuMgr->createMenu("ItemPathOps", tr("Path Tools"), "Item");
716
752
        scrMenuMgr->addMenuItem(scrActions["itemCombinePolygons"], "Item");
717
753
        scrMenuMgr->addMenuItem(scrActions["itemSplitPolygons"], "Item");
718
 
        scrMenuMgr->setMenuEnabled("ItemShapes", false);
 
754
        //scrMenuMgr->setMenuEnabled("ItemShapes", false);
719
755
        scrActions["itemGroup"]->setEnabled(false);
720
756
        scrActions["itemUngroup"]->setEnabled(false);
721
757
        scrActions["itemAttachTextToPath"]->setEnabled(false);
734
770
        scrActions["itemConvertToTextFrame"]->setEnabled(false);
735
771
 
736
772
        //Insert menu
737
 
        scrMenuMgr->createMenu("Insert", tr("I&nsert"));
 
773
        scrMenuMgr->createMenu("Insert", ActionManager::defaultMenuNameEntryTranslated("Insert"));
738
774
        scrMenuMgr->addMenuItem(scrActions["insertFrame"], "Insert");
739
775
        scrMenuMgr->addMenuSeparator("Insert");
740
776
        scrMenuMgr->addMenuItem(scrActions["toolsInsertTextFrame"], "Insert");
741
777
        scrMenuMgr->addMenuItem(scrActions["toolsInsertImageFrame"], "Insert");
 
778
        scrMenuMgr->addMenuItem(scrActions["toolsInsertRenderFrame"], "Insert");
742
779
        scrMenuMgr->addMenuItem(scrActions["toolsInsertTableFrame"], "Insert");
743
780
        scrMenuMgr->addMenuItem(scrActions["toolsInsertShape"], "Insert");
744
781
        scrMenuMgr->addMenuItem(scrActions["toolsInsertPolygon"], "Insert");
750
787
        scrMenuMgr->addMenuSeparator("Insert");
751
788
        scrMenuMgr->addMenuItem(scrActions["insertGlyph"], "Insert");
752
789
 
753
 
        scrMenuMgr->createMenu("InsertChar", QPixmap(noIcon), tr("&Character"), "Insert");
754
 
        //scrMenuMgr->addMenuToMenu("InsertChar", "Insert");
 
790
        scrMenuMgr->createMenu("InsertChar", tr("&Character"), "Insert");
755
791
        scrMenuMgr->addMenuItem(scrActions["unicodePageNumber"], "InsertChar");
 
792
        scrMenuMgr->addMenuItem(scrActions["unicodePageCount"], "InsertChar");
756
793
        scrMenuMgr->addMenuItem(scrActions["unicodeSmartHyphen"], "InsertChar");
757
794
        scrMenuMgr->addMenuItem(scrActions["unicodeNonBreakingHyphen"], "InsertChar");
758
795
        scrMenuMgr->addMenuSeparator("InsertChar");
768
805
        scrMenuMgr->addMenuItem(scrActions["unicodeDashFigure"], "InsertChar");
769
806
        scrMenuMgr->addMenuItem(scrActions["unicodeDashQuotation"], "InsertChar");
770
807
 
771
 
        scrMenuMgr->createMenu("InsertQuote", QPixmap(noIcon), tr("&Quote"), "Insert");
772
 
        //scrMenuMgr->addMenuToMenu("InsertQuote", "Insert");
 
808
        scrMenuMgr->createMenu("InsertQuote", tr("&Quote"), "Insert");
773
809
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteApostrophe"], "InsertQuote");
774
810
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteStraight"], "InsertQuote");
775
811
        scrMenuMgr->addMenuSeparator("InsertQuote");
794
830
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKDoubleLeft"], "InsertQuote");
795
831
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKDoubleRight"], "InsertQuote");
796
832
 
797
 
        scrMenuMgr->createMenu("InsertSpace", QPixmap(noIcon), tr("S&paces && Breaks"), "Insert");
 
833
        scrMenuMgr->createMenu("InsertSpace", tr("S&paces && Breaks"), "Insert");
798
834
        scrMenuMgr->addMenuItem(scrActions["unicodeNonBreakingSpace"], "InsertSpace");
799
835
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceEN"], "InsertSpace");
800
836
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceEM"], "InsertSpace");
808
844
        scrMenuMgr->addMenuItem(scrActions["unicodeColumnBreak"], "InsertSpace");
809
845
        scrMenuMgr->addMenuItem(scrActions["unicodeZerowidthSpace"], "InsertSpace");
810
846
 
811
 
        scrMenuMgr->createMenu("InsertLigature", QPixmap(noIcon), tr("Liga&ture"), "Insert");
 
847
        scrMenuMgr->createMenu("InsertLigature", tr("Liga&ture"), "Insert");
812
848
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ff"], "InsertLigature");
813
849
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_fi"], "InsertLigature");
814
850
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_fl"], "InsertLigature");
822
858
        scrActions["insertFrame"]->setEnabled(false);
823
859
 
824
860
        //Page menu
825
 
        scrMenuMgr->createMenu("Page", tr("&Page"));
 
861
        scrMenuMgr->createMenu("Page", ActionManager::defaultMenuNameEntryTranslated("Page"));
826
862
        scrMenuMgr->addMenuItem(scrActions["pageInsert"], "Page");
827
863
        scrMenuMgr->addMenuItem(scrActions["pageImport"], "Page");
828
864
        scrMenuMgr->addMenuItem(scrActions["pageDelete"], "Page");
839
875
        scrActions["pageMove"]->setEnabled(false);
840
876
 
841
877
        //View menu
842
 
        scrMenuMgr->createMenu("View", tr("&View"));
 
878
        scrMenuMgr->createMenu("View", ActionManager::defaultMenuNameEntryTranslated("View"));
843
879
        scrMenuMgr->addMenuItem(scrActions["viewFitInWindow"], "View");
844
880
        scrMenuMgr->addMenuItem(scrActions["viewFitWidth"], "View");
845
881
        scrMenuMgr->addMenuItem(scrActions["viewFit50"], "View");
846
882
        scrMenuMgr->addMenuItem(scrActions["viewFit75"], "View");
847
883
        scrMenuMgr->addMenuItem(scrActions["viewFit100"], "View");
848
884
        scrMenuMgr->addMenuItem(scrActions["viewFit200"], "View");
 
885
        scrMenuMgr->addMenuItem(scrActions["viewFit400"], "View");
849
886
        scrMenuMgr->addMenuSeparator("View");
850
887
        scrMenuMgr->addMenuItem(scrActions["viewFitPreview"], "View");
851
888
        scrMenuMgr->addMenuSeparator("View");
862
899
        scrMenuMgr->addMenuItem(scrActions["viewShowTextControls"], "View");
863
900
        scrMenuMgr->addMenuItem(scrActions["viewShowRulers"], "View");
864
901
        scrMenuMgr->addMenuItem(scrActions["viewRulerMode"], "View");
 
902
        scrMenuMgr->addMenuItem(scrActions["showMouseCoordinates"], "View");
865
903
 
866
904
        scrActions["viewShowRulers"]->setEnabled(false);
867
905
 
887
925
        //scrActions["toolsPreflightVerifier"]->setEnabled(false);*/
888
926
 
889
927
        //Extra menu
890
 
        scrMenuMgr->createMenu("Extras", tr("E&xtras"));
891
 
        scrMenuMgr->addMenuItem(scrActions["extrasManagePictures"], "Extras");
 
928
        scrMenuMgr->createMenu("Extras", ActionManager::defaultMenuNameEntryTranslated("Extras"));
 
929
        scrMenuMgr->addMenuItem(scrActions["extrasManageImages"], "Extras");
892
930
        scrMenuMgr->addMenuItem(scrActions["extrasHyphenateText"], "Extras");
893
931
        scrMenuMgr->addMenuItem(scrActions["extrasDeHyphenateText"], "Extras");
894
932
        scrMenuMgr->addMenuItem(scrActions["extrasGenerateTableOfContents"], "Extras");
896
934
        scrMenuMgr->setMenuEnabled("Extras", false);
897
935
        scrActions["extrasHyphenateText"]->setEnabled(false);
898
936
        scrActions["extrasDeHyphenateText"]->setEnabled(false);
 
937
        connect(scrMenuMgr->getLocalPopupMenu("Extras"), SIGNAL(aboutToShow()), this, SLOT(extrasMenuAboutToShow()));
899
938
 
900
939
        //Window menu
901
 
         scrMenuMgr->createMenu("Windows", tr("&Windows"), QString::null, true);
902
 
        connect(FontMenu, SIGNAL(aboutToShow()), this, SLOT(fontMenuAboutToShow()));
 
940
         scrMenuMgr->createMenu("Windows", ActionManager::defaultMenuNameEntryTranslated("Windows"), QString::null, true);
903
941
        connect(scrMenuMgr->getLocalPopupMenu("Windows"), SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
904
942
        addDefaultWindowMenuItems();
905
943
 
906
944
        //Help menu
907
 
        scrMenuMgr->createMenu("Help", tr("&Help"));
 
945
        scrMenuMgr->createMenu("Help", ActionManager::defaultMenuNameEntryTranslated("Help"));
908
946
        scrMenuMgr->addMenuItem(scrActions["helpManual"], "Help");
 
947
        scrMenuMgr->addMenuItem(scrActions["helpManual2"], "Help");
909
948
        scrMenuMgr->addMenuSeparator("Help");
910
949
        scrMenuMgr->addMenuItem(scrActions["helpTooltips"], "Help");
911
950
        scrMenuMgr->addMenuSeparator("Help");
 
951
        scrMenuMgr->addMenuItem(scrActions["helpOnlineWWW"], "Help");
 
952
        scrMenuMgr->addMenuItem(scrActions["helpOnlineDocs"], "Help");
 
953
        scrMenuMgr->addMenuItem(scrActions["helpOnlineWiki"], "Help");
 
954
        scrMenuMgr->createMenu("HelpOnlineTutorials", tr("Online &Tutorials"), "Help");
 
955
        scrMenuMgr->addMenuItem(scrActions["helpOnlineTutorial1"], "HelpOnlineTutorials");
 
956
        scrMenuMgr->addMenuSeparator("Help");
 
957
        scrMenuMgr->addMenuItem(scrActions["helpCheckUpdates"], "Help");
 
958
        scrMenuMgr->addMenuSeparator("Help");
912
959
        scrMenuMgr->addMenuItem(scrActions["helpAboutScribus"], "Help");
913
960
        scrMenuMgr->addMenuItem(scrActions["helpAboutPlugins"], "Help");
914
961
        scrMenuMgr->addMenuItem(scrActions["helpAboutQt"], "Help");
915
 
        
 
962
 
916
963
        scrMenuMgr->addMenuToMenuBar("File");
917
964
        scrMenuMgr->addMenuToMenuBar("Edit");
918
 
        scrMenuMgr->addMenuToMenuBar("Style");
919
 
        scrMenuMgr->setMenuEnabled("Style", false);
920
965
        scrMenuMgr->addMenuToMenuBar("Item");
921
966
        scrMenuMgr->setMenuEnabled("Item", false);
922
967
        scrMenuMgr->addMenuToMenuBar("Insert");
930
975
        scrMenuMgr->setMenuEnabled("Extras", false);
931
976
        scrMenuMgr->addMenuToMenuBar("Windows");
932
977
        //scrMenuMgr->setMenuEnabled("Windows", false);
933
 
        menuBar()->insertSeparator();
 
978
        menuBar()->addSeparator();
934
979
        scrMenuMgr->addMenuToMenuBar("Help");
935
 
 
936
 
        //Alignment menu
937
 
        scrMenuMgr->createMenu("Alignment", tr("&Alignment"));
938
 
        scrMenuMgr->addMenuItem(scrActions["alignLeft"], "Alignment");
939
 
        scrMenuMgr->addMenuItem(scrActions["alignCenter"], "Alignment");
940
 
        scrMenuMgr->addMenuItem(scrActions["alignRight"], "Alignment");
941
 
        scrMenuMgr->addMenuItem(scrActions["alignBlock"], "Alignment");
942
 
        scrMenuMgr->addMenuItem(scrActions["alignForced"], "Alignment");
943
 
 
944
 
        connect(ColorMenC, SIGNAL(activated(int)), this, SLOT(setItemFarbe(int)));
945
 
        connect(FontMenu, SIGNAL(activated(int)), this, SLOT(setItemFont(int)));
946
980
}
947
981
 
 
982
 
948
983
void ScribusMainWindow::addDefaultWindowMenuItems()
949
984
{
950
985
        scrMenuMgr->clearMenu("Windows");
970
1005
 
971
1006
void ScribusMainWindow::initStatusBar()
972
1007
{
973
 
        mainWindowStatusLabel = new QLabel( "           ", statusBar(), "ft");
974
 
        mainWindowProgressBar = new QProgressBar(statusBar(), "p");
975
 
        mainWindowProgressBar->setCenterIndicator(true);
 
1008
        mainWindowStatusLabel = new QLabel( "           ", statusBar());
 
1009
        mainWindowProgressBar = new QProgressBar(statusBar());
 
1010
        mainWindowProgressBar->setAlignment(Qt::AlignHCenter);
976
1011
        mainWindowProgressBar->setFixedWidth( 100 );
977
1012
        mainWindowProgressBar->reset();
978
 
        mainWindowXPosLabel = new QLabel( "X-Pos:", statusBar(), "xt");
979
 
        mainWindowYPosLabel = new QLabel( "Y-Pos:", statusBar(), "yt");
980
 
        mainWindowXPosDataLabel = new QLabel( "        ", statusBar(), "dt");
981
 
        mainWindowYPosDataLabel = new QLabel( "        ", statusBar(), "ydt");
 
1013
        mainWindowXPosLabel = new QLabel( tr("X-Pos:"), statusBar());
 
1014
        mainWindowYPosLabel = new QLabel( tr("Y-Pos:"), statusBar());
 
1015
        mainWindowXPosDataLabel = new QLabel( "        ", statusBar());
 
1016
        mainWindowYPosDataLabel = new QLabel( "        ", statusBar());
982
1017
 
983
 
        statusBar()->addWidget(mainWindowStatusLabel, 6, true);
984
 
        statusBar()->addWidget(mainWindowProgressBar, 0, true);
985
 
        statusBar()->addWidget(mainWindowXPosLabel, 0, true);
986
 
        statusBar()->addWidget(mainWindowXPosDataLabel, 1, true);
987
 
        statusBar()->addWidget(mainWindowYPosLabel, 0, true);
988
 
        statusBar()->addWidget(mainWindowYPosDataLabel, 1, true);
 
1018
        statusBar()->addPermanentWidget(mainWindowStatusLabel, 6);
 
1019
        statusBar()->addPermanentWidget(mainWindowProgressBar, 0);
 
1020
        statusBar()->addPermanentWidget(mainWindowXPosLabel, 0);
 
1021
        statusBar()->addPermanentWidget(mainWindowXPosDataLabel, 1);
 
1022
        statusBar()->addPermanentWidget(mainWindowYPosLabel, 0);
 
1023
        statusBar()->addPermanentWidget(mainWindowYPosDataLabel, 1);
989
1024
}
990
1025
 
 
1026
 
991
1027
void ScribusMainWindow::setStatusBarMousePosition(double xp, double yp)
992
1028
{
993
1029
        double xn = xp;
999
1035
        }
1000
1036
        xn -= doc->rulerXoffset;
1001
1037
        yn -= doc->rulerYoffset;
1002
 
        QString suffix=unitGetSuffixFromIndex(doc->unitIndex());
1003
 
        int multiplier=unitGetDecimalsFromIndex(doc->unitIndex());
1004
 
        double divisor=static_cast<double>(multiplier);
1005
 
        int precision=unitGetPrecisionFromIndex(doc->unitIndex());
1006
 
        QString tmp;
1007
 
        mainWindowXPosDataLabel->setText(tmp.setNum(qRound(xn*doc->unitRatio() * multiplier) / divisor, 'f', precision) + suffix);
1008
 
        mainWindowYPosDataLabel->setText(tmp.setNum(qRound(yn*doc->unitRatio() * multiplier) / divisor, 'f', precision) + suffix);
 
1038
        mainWindowXPosDataLabel->setText(value2String(xn, doc->unitIndex(), true, true));
 
1039
        mainWindowYPosDataLabel->setText(value2String(yn, doc->unitIndex(), true, true));
1009
1040
}
1010
1041
 
 
1042
 
1011
1043
void ScribusMainWindow::setStatusBarInfoText(QString newText)
1012
1044
{
1013
1045
        if (mainWindowStatusLabel)
1014
1046
                mainWindowStatusLabel->setText(newText);
1015
1047
}
1016
1048
 
1017
 
//CB-->Doc
 
1049
 
 
1050
//AV to be replaced with Selection::update and listener in PropertiesPalette
1018
1051
void ScribusMainWindow::setTBvals(PageItem *currItem)
1019
1052
{
1020
1053
        if (currItem->itemText.length() != 0)
1021
1054
        {
1022
 
//              int ChPos = QMIN(currItem->CPos, static_cast<int>(currItem->itemText.length()-1));
1023
 
                const ParagraphStyle& currPStyle(currItem->currentStyle());
 
1055
//              int ChPos = qMin(currItem->CPos, static_cast<int>(currItem->itemText.length()-1));
 
1056
                const ParagraphStyle& currPStyle( (doc->appMode == modeEdit) ? currItem->currentStyle() : currItem->itemText.defaultStyle());
1024
1057
                setAbsValue(currPStyle.alignment());
1025
1058
                propertiesPalette->setParStyle(currPStyle.parent());
1026
1059
                propertiesPalette->setCharStyle(currItem->currentCharStyle().parent());
1046
1079
        }
1047
1080
}
1048
1081
 
1049
 
void ScribusMainWindow::wheelEvent(QWheelEvent *w)
1050
 
{
1051
 
        if (HaveDoc)
1052
 
        {
1053
 
                int wheelVal=prefsManager->mouseWheelValue();
1054
 
                if ((w->orientation() != Qt::Vertical) || ( w->state() & ShiftButton ))
1055
 
                {
1056
 
                        if (w->delta() < 0)
1057
 
                                view->scrollBy(wheelVal, 0);
1058
 
                        else
1059
 
                                view->scrollBy(-wheelVal, 0);
1060
 
                }
1061
 
                else
1062
 
                {
1063
 
                        if (w->delta() < 0)
1064
 
                                view->scrollBy(0, wheelVal);
1065
 
                        else
1066
 
                                view->scrollBy(0, -wheelVal);
1067
 
                }
1068
 
                w->accept();
1069
 
        }
1070
 
}
1071
 
 
1072
1082
//Special keys assigned to actions are stolen by the action and not passed to
1073
1083
//keyPressEvent so process them here.
1074
1084
void ScribusMainWindow::specialActionKeyEvent(const QString& actionName, int unicodevalue)
1090
1100
                                                currItem->itemText.insertChars(currItem->CPos, QString(QChar(unicodevalue)), true);
1091
1101
                                                currItem->CPos += 1;
1092
1102
//                                              currItem->Tinput = true;
1093
 
                                                view->RefreshItem(currItem);
 
1103
                                                currItem->update();
1094
1104
                                        }
1095
1105
                                        else if (actionName=="unicodeSmartHyphen") //ignore the char as we use an attribute if the text item, for now.
1096
1106
                                        {
1099
1109
                                                if (currItem->CPos-1>0)
1100
1110
                                                {
1101
1111
#if 0
1102
 
                                                        StyleFlag fl = currItem->itemText.item(QMAX(currItem->CPos-1,0))->effects();
 
1112
                                                        StyleFlag fl = currItem->itemText.item(qMax(currItem->CPos-1,0))->effects();
1103
1113
                                                        fl |= ScStyle_HyphenationPossible;
1104
 
                                                        currItem->itemText.item(QMAX(currItem->CPos-1,0))->setEffects(fl);
 
1114
                                                        currItem->itemText.item(qMax(currItem->CPos-1,0))->setEffects(fl);
1105
1115
#else
1106
1116
                                                        currItem->itemText.insertChars(currItem->CPos, QString(SpecialChars::SHYPHEN), true);
1107
1117
                                                        currItem->CPos += 1;
1108
1118
#endif
1109
1119
//                                                      currItem->Tinput = true;
1110
 
                                                        view->RefreshItem(currItem);
 
1120
                                                        currItem->update();
1111
1121
                                                }
1112
1122
                                        }
1113
1123
                                }
1119
1129
bool ScribusMainWindow::eventFilter( QObject* /*o*/, QEvent *e )
1120
1130
{
1121
1131
        bool retVal;
1122
 
        if ( e->type() == QEvent::KeyPress ) {
 
1132
        if (e->type() == QEvent::ToolTip)
 
1133
        {
 
1134
                return (!prefsManager->appPrefs.showToolTips);
 
1135
        }
 
1136
        if ( e->type() == QEvent::KeyPress )
 
1137
        {
1123
1138
                QKeyEvent *k = (QKeyEvent *)e;
1124
1139
                int keyMod=0;
1125
 
                if (k->state() & ShiftButton)
1126
 
                        keyMod |= SHIFT;
1127
 
                if (k->state() & ControlButton)
1128
 
                        keyMod |= CTRL;
1129
 
                if (k->state() & AltButton)
1130
 
                        keyMod |= ALT;
 
1140
                if (k->modifiers() & Qt::ShiftModifier)
 
1141
                        keyMod |= Qt::SHIFT;
 
1142
                if (k->modifiers() & Qt::ControlModifier)
 
1143
                        keyMod |= Qt::CTRL;
 
1144
                if (k->modifiers() & Qt::AltModifier)
 
1145
                        keyMod |= Qt::ALT;
1131
1146
 
1132
1147
                QKeySequence currKeySeq = QKeySequence(k->key() | keyMod);
1133
1148
                if (QString(currKeySeq).isNull())
1134
1149
                        return false;
1135
1150
                retVal=true;
1136
1151
                //Palette actions
1137
 
                if (currKeySeq == scrActions["specialToggleAllPalettes"]->accel())
1138
 
                        scrActions["specialToggleAllPalettes"]->activate();
1139
 
                else
1140
 
                if (currKeySeq == scrActions["toolsProperties"]->accel())
1141
 
                        scrActions["toolsProperties"]->toggle();
1142
 
                else
1143
 
                if (currKeySeq == scrActions["toolsOutline"]->accel())
1144
 
                        scrActions["toolsOutline"]->toggle();
1145
 
                else
1146
 
                if (currKeySeq == scrActions["toolsScrapbook"]->accel())
1147
 
                        scrActions["toolsScrapbook"]->toggle();
1148
 
                else
1149
 
                if (currKeySeq == scrActions["toolsLayers"]->accel())
1150
 
                        scrActions["toolsLayers"]->toggle();
1151
 
                else
1152
 
                if (currKeySeq == scrActions["toolsPages"]->accel())
1153
 
                        scrActions["toolsPages"]->toggle();
1154
 
                else
1155
 
                if (currKeySeq == scrActions["toolsBookmarks"]->accel())
1156
 
                        scrActions["toolsBookmarks"]->toggle();
1157
 
                else
1158
 
                if (currKeySeq == scrActions["toolsActionHistory"]->accel())
1159
 
                        scrActions["toolsActionHistory"]->toggle();
1160
 
                else
1161
 
                if (currKeySeq == scrActions["toolsPreflightVerifier"]->accel())
1162
 
                        scrActions["toolsPreflightVerifier"]->toggle();
1163
 
                else
1164
 
                if (currKeySeq == scrActions["toolsAlignDistribute"]->accel())
1165
 
                        scrActions["toolsAlignDistribute"]->toggle();
1166
 
                else
 
1152
                if (currKeySeq == scrActions["specialToggleAllPalettes"]->shortcut())
 
1153
                        scrActions["specialToggleAllPalettes"]->activate(QAction::Trigger);
 
1154
                else
 
1155
// CB These were moved to ActionManager via the setShortcutContext(Qt::ApplicationShortcut) calls, leaving for notes for now
 
1156
//              if (currKeySeq == scrActions["toolsProperties"]->accel())
 
1157
//                      scrActions["toolsProperties"]->toggle();
 
1158
//              else
 
1159
//              if (currKeySeq == scrActions["toolsOutline"]->accel())
 
1160
//                      scrActions["toolsOutline"]->toggle();
 
1161
//              else
 
1162
//              if (currKeySeq == scrActions["toolsScrapbook"]->accel())
 
1163
//                      scrActions["toolsScrapbook"]->toggle();
 
1164
//              else
 
1165
//              if (currKeySeq == scrActions["toolsLayers"]->accel())
 
1166
//                      scrActions["toolsLayers"]->toggle();
 
1167
//              else
 
1168
//              if (currKeySeq == scrActions["toolsPages"]->accel())
 
1169
//                      scrActions["toolsPages"]->toggle();
 
1170
//              else
 
1171
//              if (currKeySeq == scrActions["toolsBookmarks"]->accel())
 
1172
//                      scrActions["toolsBookmarks"]->toggle();
 
1173
//              else
 
1174
//              if (currKeySeq == scrActions["toolsActionHistory"]->accel())
 
1175
//                      scrActions["toolsActionHistory"]->toggle();
 
1176
//              else
 
1177
//              if (currKeySeq == scrActions["toolsPreflightVerifier"]->accel())
 
1178
//                      scrActions["toolsPreflightVerifier"]->toggle();
 
1179
//              else
 
1180
//              if (currKeySeq == scrActions["toolsAlignDistribute"]->accel())
 
1181
//                      scrActions["toolsAlignDistribute"]->toggle();
 
1182
//              else
1167
1183
                //Edit actions
1168
 
                if (currKeySeq == scrActions["editStyles"]->accel())
 
1184
                if (currKeySeq == scrActions["editStyles"]->shortcut())
1169
1185
                        scrActions["editStyles"]->toggle();
1170
1186
                else
1171
 
                if (currKeySeq == scrActions["editUndoAction"]->accel() && scrActions["editUndoAction"]->isEnabled())
1172
 
                        scrActions["editUndoAction"]->activate();
 
1187
                if (currKeySeq == scrActions["editUndoAction"]->shortcut() && scrActions["editUndoAction"]->isEnabled())
 
1188
                        scrActions["editUndoAction"]->activate(QAction::Trigger);
1173
1189
                else
1174
 
                if (currKeySeq == scrActions["editRedoAction"]->accel() && scrActions["editRedoAction"]->isEnabled())
1175
 
                        scrActions["editRedoAction"]->activate();
 
1190
                if (currKeySeq == scrActions["editRedoAction"]->shortcut() && scrActions["editRedoAction"]->isEnabled())
 
1191
                        scrActions["editRedoAction"]->activate(QAction::Trigger);
1176
1192
                else
1177
1193
                //Other actions
1178
 
                if (currKeySeq == scrActions["fileQuit"]->accel())
1179
 
                        scrActions["fileQuit"]->activate();
 
1194
                if (currKeySeq == scrActions["fileQuit"]->shortcut())
 
1195
                        scrActions["fileQuit"]->activate(QAction::Trigger);
1180
1196
                else
1181
1197
                //Zoom actions
1182
 
                if (currKeySeq == scrActions["toolsZoomIn"]->accel())
1183
 
                        scrActions["toolsZoomIn"]->activate();
 
1198
                if (currKeySeq == scrActions["toolsZoomIn"]->shortcut())
 
1199
                        scrActions["toolsZoomIn"]->activate(QAction::Trigger);
1184
1200
                else
1185
 
                if (currKeySeq == scrActions["toolsZoomOut"]->accel())
1186
 
                        scrActions["toolsZoomOut"]->activate();
 
1201
                if (currKeySeq == scrActions["toolsZoomOut"]->shortcut())
 
1202
                        scrActions["toolsZoomOut"]->activate(QAction::Trigger);
1187
1203
                else
1188
1204
                        retVal=false;
1189
1205
        }
1193
1209
        return retVal;
1194
1210
}
1195
1211
 
 
1212
 
 
1213
//AV -> CanvasMode
1196
1214
void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
1197
1215
{
1198
1216
        QWidgetList windows;
1199
1217
        QWidget* w = NULL;
1200
1218
        int kk = k->key();
1201
1219
        QString uc = k->text();
1202
 
        QString cr, Tcha, Twort;
 
1220
//      QString cr, Tcha, Twort;
1203
1221
        if (HaveDoc)
1204
1222
        {
1205
 
                if ((doc->appMode == modeMagnifier) && (kk == Key_Shift))
 
1223
                if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift))
1206
1224
                {
1207
 
                        qApp->setOverrideCursor(QCursor(loadIcon("LupeZm.xpm")), true);
 
1225
                        qApp->changeOverrideCursor(QCursor(loadIcon("LupeZm.xpm")));
1208
1226
                        return;
1209
1227
                }
1210
1228
        }
1211
1229
        if (keyrep)
1212
1230
                return;
1213
1231
        keyrep = true;
1214
 
        int KeyMod;
1215
 
        switch (k->state())
1216
 
        {
1217
 
        case ShiftButton:
1218
 
                KeyMod = SHIFT;
1219
 
                break;
1220
 
        case AltButton:
1221
 
                KeyMod = ALT;
1222
 
                break;
1223
 
        case ControlButton:
1224
 
                KeyMod = CTRL;
1225
 
                break;
1226
 
        default:
1227
 
                KeyMod = 0;
1228
 
                break;
1229
 
        }
 
1232
        int keyMod=0;
 
1233
        if (k->modifiers() & Qt::ShiftModifier)
 
1234
                keyMod |= Qt::SHIFT;
 
1235
        if (k->modifiers() & Qt::ControlModifier)
 
1236
                keyMod |= Qt::CTRL;
 
1237
        if (k->modifiers() & Qt::AltModifier)
 
1238
                keyMod |= Qt::ALT;
1230
1239
        //User presses escape and we have a doc open, and we have an item selected
1231
 
        if ((kk == Key_Escape) && (HaveDoc))
 
1240
        if ((kk == Qt::Key_Escape) && (HaveDoc))
1232
1241
        {
1233
1242
                keyrep = false;
1234
1243
                PageItem *currItem;
1238
1247
                        switch (doc->appMode)
1239
1248
                        {
1240
1249
                                case modeNormal:
 
1250
                                case modeEditClip:
1241
1251
                                        currItem->Sizing = false;
1242
1252
                                        if (doc->SubMode != -1)
1243
1253
                                        {
1244
1254
                                                view->Deselect(false);
1245
 
                                                doc->Items->remove(currItem->ItemNr);
 
1255
                                                doc->Items->removeAt(currItem->ItemNr);
1246
1256
                                        }
1247
1257
                                        else
1248
1258
                                                view->Deselect(false);
 
1259
                                        view->cancelGroupTransaction();
1249
1260
                                        break;
1250
1261
                                case modeEdit:
 
1262
                                        view->cancelGroupTransaction();
1251
1263
                                        break;
1252
1264
                                case modeLinkFrames:
1253
1265
                                case modeUnlinkFrames:
1255
1267
                                case modeEditGradientVectors:
1256
1268
                                case modeCopyProperties:
1257
1269
                                        view->Deselect(false);
 
1270
                                case modeEyeDropper:
 
1271
                                case modeImportObject:
1258
1272
                                case modePanning:
 
1273
                                        view->requestMode(modeNormal);
1259
1274
                                        break;
1260
1275
                                case modeDrawBezierLine:
1261
 
                                        currItem->PoLine.resize(currItem->PoLine.size()-2);
 
1276
                                        currItem->PoLine.resize(qMax(0, static_cast<int>(currItem->PoLine.size())-2));
1262
1277
                                        if (currItem->PoLine.size() < 4)
1263
1278
                                        {
1264
1279
                                                view->Deselect(false);
1265
 
                                                doc->Items->remove(currItem->ItemNr);
 
1280
                                                doc->Items->removeAt(currItem->ItemNr);
1266
1281
                                        }
1267
1282
                                        else
1268
1283
                                        {
1269
1284
                                                doc->SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem->ItemNr, false, false);
1270
 
                                                currItem->setPolyClip(qRound(QMAX(currItem->lineWidth() / 2.0, 1)));
 
1285
                                                currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1.0)));
1271
1286
                                                doc->AdjustItemSize(currItem);
1272
1287
                                                currItem->ContourLine = currItem->PoLine.copy();
1273
1288
                                                currItem->ClipEdited = true;
1277
1292
                                        view->FirstPoly = true;
1278
1293
                                        break;
1279
1294
                                default:
1280
 
                                        view->Deselect(false);
1281
 
                                        doc->Items->remove(currItem->ItemNr);
 
1295
                                        if (currItem->Sizing)
 
1296
                                        {
 
1297
                                                view->Deselect(false);
 
1298
                                                doc->Items->removeAt(currItem->ItemNr);
 
1299
                                        }
1282
1300
                                        break;
1283
1301
                        }
1284
1302
                }
1285
 
                view->m_MouseButtonPressed = false;
1286
1303
                doc->DragP = false;
1287
1304
                doc->leaveDrag = false;
1288
 
                view->operItemMoving = false;
1289
 
                view->operItemResizing = false;
1290
 
                view->inItemCreation = false;
1291
 
                view->MidButt = false;
 
1305
                view->stopAllDrags();
1292
1306
                doc->SubMode = -1;
1293
1307
                doc->ElemToLink = NULL;
1294
 
                NoFrameEdit();
1295
1308
                slotSelect();
 
1309
                if (doc->m_Selection->count() == 0)
 
1310
                        HaveNewSel(-1);
 
1311
                prefsManager->appPrefs.stickyTools = false;
 
1312
                scrActions["stickyTools"]->setChecked(prefsManager->appPrefs.stickyTools);
1296
1313
                return;
1297
1314
        }
1298
 
        ButtonState buttonState = k->state();
 
1315
        Qt::KeyboardModifiers buttonModifiers = k->modifiers();
1299
1316
        /**If we have a doc and we are not changing the page or zoom level in the status bar */
1300
1317
        if ((HaveDoc) && (!view->zoomSpinBox->hasFocus()) && (!view->pageSelector->hasFocus()))
1301
1318
        {
 
1319
                //Show our context menu
 
1320
                QKeySequence currKeySeq = QKeySequence(kk | keyMod);
 
1321
                if (currKeySeq.matches(scrActions["viewShowContextMenu"]->shortcut()) == QKeySequence::ExactMatch)
 
1322
                {
 
1323
                        ContextMenu* cmen=NULL;
 
1324
                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 
1325
                        if (doc->m_Selection->count() == 0)
 
1326
                        {
 
1327
                                //CB We should be able to get this calculated by the canvas.... it is already in m_canvas->globalToCanvas(m->globalPos());
 
1328
                                QPoint p(QCursor::pos() - mapToGlobal(QPoint(0,0)));
 
1329
                                FPoint fp(p.x() / view->scale() + doc->minCanvasCoordinate.x(),
 
1330
                                p.y() / view->scale() + doc->minCanvasCoordinate.y());
 
1331
                                cmen = new ContextMenu(this, doc, fp.x(), fp.y());
 
1332
                        }
 
1333
                        else
 
1334
                                cmen = new ContextMenu(*(doc->m_Selection), this, doc);
 
1335
                        if (cmen)
 
1336
                        {
 
1337
                                setUndoMode(true);
 
1338
                                cmen->exec(QCursor::pos());
 
1339
                                setUndoMode(false);
 
1340
                        }
 
1341
                        delete cmen;
 
1342
                }
 
1343
 
 
1344
 
1302
1345
                /**
1303
1346
                 * With no item selected we can:
1304
1347
                 * - With space, get into panning mode (modePanning)
1311
1354
                {
1312
1355
                        int pg;
1313
1356
                        int wheelVal = prefsManager->mouseWheelValue();
1314
 
                        if ((buttonState & ShiftButton) && !(buttonState & ControlButton) && !(buttonState & AltButton))
1315
 
                                wheelVal = QMAX(qRound(wheelVal / 10.0), 1);
 
1357
                        if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
 
1358
                                wheelVal = qMax(qRound(wheelVal / 10.0), 1);
1316
1359
                        switch (kk)
1317
1360
                        {
1318
 
                        case Key_Space:
 
1361
                        case Qt::Key_Space:
1319
1362
                                keyrep = false;
1320
1363
                                if (doc->appMode == modePanning)
1321
 
                                        setAppMode(modeNormal);
 
1364
                                        view->requestMode(modeNormal);
1322
1365
                                else
1323
 
                                        setAppMode(modePanning);
 
1366
                                        view->requestMode(modePanning);
1324
1367
                                return;
1325
1368
                                break;
1326
 
                        case Key_Prior:
 
1369
                        case Qt::Key_PageUp:
1327
1370
                                if (doc->masterPageMode())
1328
1371
                                        view->scrollBy(0, -prefsManager->mouseWheelValue());
1329
1372
                                else
1330
1373
                                {
1331
1374
                                        pg = doc->currentPageNumber();
1332
 
                                        if ((buttonState & ShiftButton) && !(buttonState & ControlButton) && !(buttonState & AltButton))
 
1375
                                        if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1333
1376
                                                pg--;
1334
1377
                                        else
1335
1378
                                                pg -= doc->pageSets[doc->currentPageLayout].Columns;
1339
1382
                                keyrep = false;
1340
1383
                                return;
1341
1384
                                break;
1342
 
                        case Key_Next:
 
1385
                        case Qt::Key_PageDown:
1343
1386
                                if (doc->masterPageMode())
1344
1387
                                        view->scrollBy(0, prefsManager->mouseWheelValue());
1345
1388
                                else
1346
1389
                                {
1347
1390
                                        pg = doc->currentPageNumber();
1348
 
                                        if ((buttonState & ShiftButton) && !(buttonState & ControlButton) && !(buttonState & AltButton))
 
1391
                                        if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1349
1392
                                                pg++;
1350
1393
                                        else
1351
1394
                                                pg += doc->pageSets[doc->currentPageLayout].Columns;
1355
1398
                                keyrep = false;
1356
1399
                                return;
1357
1400
                                break;
1358
 
                        case Key_Left:
 
1401
                        case Qt::Key_Left:
1359
1402
                                view->scrollBy(-wheelVal, 0);
1360
1403
                                keyrep = false;
1361
1404
                                return;
1362
1405
                                break;
1363
 
                        case Key_Right:
 
1406
                        case Qt::Key_Right:
1364
1407
                                view->scrollBy(wheelVal, 0);
1365
1408
                                keyrep = false;
1366
1409
                                return;
1367
1410
                                break;
1368
 
                        case Key_Up:
 
1411
                        case Qt::Key_Up:
1369
1412
                                view->scrollBy(0, -wheelVal);
1370
1413
                                keyrep = false;
1371
1414
                                return;
1372
1415
                                break;
1373
 
                        case Key_Down:
 
1416
                        case Qt::Key_Down:
1374
1417
                                view->scrollBy(0, wheelVal);
1375
1418
                                keyrep = false;
1376
1419
                                return;
1377
1420
                                break;
1378
 
                        case Key_Tab:
 
1421
                        case Qt::Key_Tab:
1379
1422
                                keyrep = false;
1380
1423
                                windows = wsp->windowList();
1381
1424
                                if (windows.count() > 1)
1404
1447
                /** Now if we have an item selected
1405
1448
                 * - In normal mode we can:
1406
1449
                 * -- Use backspace or delete to delete the item
1407
 
                 * -- Use PageUp to raise an item
1408
 
                 * -- Use PageDown to lower an item
 
1450
                 * -- Use itemRaise action shortcut to raise an item (actionmanager.cpp connect, no code here)
 
1451
                 * -- Use itemLower action shortcut to lower an item (actionmanager.cpp connect, no code here)
1409
1452
                 * -- Use the arrow keys to move an item or group around for !inches:
1410
1453
                                With no meta, by 1.0 unit
1411
1454
                                Ctrl, by 10.0 units
1433
1476
                        double moveBy=1.0;
1434
1477
                        if (doc->unitIndex()!=SC_INCHES)
1435
1478
                        {
1436
 
                                if ((buttonState & ShiftButton) && !(buttonState & ControlButton) && !(buttonState & AltButton))
 
1479
                                if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1437
1480
                                        moveBy=0.1;
1438
 
                                else if (!(buttonState & ShiftButton) && (buttonState & ControlButton) && !(buttonState & AltButton))
 
1481
                                else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1439
1482
                                        moveBy=10.0;
1440
 
                                else if ((buttonState & ShiftButton) && (buttonState & ControlButton) && !(buttonState & AltButton))
 
1483
                                else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1441
1484
                                        moveBy=0.01;
1442
1485
 
1443
1486
                                moveBy/=doc->unitRatio();//Lets allow movement by the current doc ratio, not only points
1444
1487
                        }
1445
1488
                        else
1446
1489
                        {
1447
 
                                if ((buttonState & ShiftButton) && !(buttonState & ControlButton) && !(buttonState & AltButton))
 
1490
                                if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1448
1491
                                        moveBy=0.1/doc->unitRatio();
1449
 
                                else if (!(buttonState & ShiftButton) && (buttonState & ControlButton) && !(buttonState & AltButton))
 
1492
                                else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1450
1493
                                        moveBy=1.0/doc->unitRatio();
1451
 
                                else if ((buttonState & ShiftButton) && (buttonState & ControlButton) && !(buttonState & AltButton))
 
1494
                                else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
1452
1495
                                        moveBy=0.01/doc->unitRatio();
1453
1496
                        }
1454
 
                        bool resizing=((buttonState & AltButton) && !(buttonState & ControlButton));
1455
 
                        bool resizingsmaller=(resizing && (buttonState & ShiftButton));
 
1497
                        bool resizing=((buttonModifiers & Qt::AltModifier) && !(buttonModifiers & Qt::ControlModifier));
 
1498
                        bool resizingsmaller=(resizing && (buttonModifiers & Qt::ShiftModifier));
1456
1499
                        double resizeBy=1.0;
1457
1500
                        //CB with control locked out due to the requirement of moveby of 0.01, we cannot support
1458
1501
                        //resizeby 10 units unless we move to supporting modifier keys that most people dont have.
1459
 
                        //if (buttonState & ControlButton)
 
1502
                        //if (buttonModifiers & Qt::ControlModifier)
1460
1503
                        //      resizeBy*=10.0;
1461
1504
                        resizeBy/=doc->unitRatio();
1462
1505
                        if (resizingsmaller)
1467
1510
                        switch (doc->appMode)
1468
1511
                        {
1469
1512
                        case modeNormal:
 
1513
                        case modeEditClip:
1470
1514
                                switch (kk)
1471
1515
                                {
1472
 
                                case Key_Backspace:
1473
 
                                case Key_Delete:
 
1516
                                case Qt::Key_Backspace:
 
1517
                                case Qt::Key_Delete:
1474
1518
                                        doc->itemSelection_DeleteItem();
1475
1519
                                        break;
1476
 
                                case Key_Prior:
 
1520
                                        /* CB: Stop using inflexible hardcoded keys here, actions for lower/raise work without this
 
1521
                                                per note above with shortcuts.
 
1522
                                case Qt::Key_PageUp:
1477
1523
                                        if (!currItem->locked())
1478
1524
                                        {
1479
1525
                                                view->RaiseItem();
1480
1526
                                        }
1481
1527
                                        break;
1482
 
                                case Key_Next:
 
1528
                                case Qt::Key_PageDown:
1483
1529
                                        if (!currItem->locked())
1484
1530
                                        {
1485
1531
                                                view->LowerItem();
1486
1532
                                        }
1487
1533
                                        break;
1488
 
                                case Key_Left:
 
1534
                                        */
 
1535
                                case Qt::Key_Left:
1489
1536
                                        if (!currItem->locked())
1490
1537
                                        {
1491
1538
                                                if (!resizing)
1492
1539
                                                {
1493
 
                                                        if ((doc->EditClip) && (view->ClRe != -1))
 
1540
                                                        if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
1494
1541
                                                        {
1495
 
                                                                FPoint np;
1496
 
                                                                if (view->EditContour)
1497
 
                                                                        np = currItem->ContourLine.point(view->ClRe);
1498
 
                                                                else
1499
 
                                                                        np = currItem->PoLine.point(view->ClRe);
1500
 
                                                                np = np - FPoint(moveBy, 0);
1501
 
                                                                view->MoveClipPoint(currItem, np);
 
1542
                                                                int storedClRe = doc->nodeEdit.ClRe;
 
1543
                                                                if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
 
1544
                                                                {
 
1545
                                                                        for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
 
1546
                                                                        {
 
1547
                                                                                FPoint np;
 
1548
                                                                                int clRe = doc->nodeEdit.SelNode.at(itm);
 
1549
                                                                                if (doc->nodeEdit.isContourLine)
 
1550
                                                                                        np = currItem->ContourLine.point(clRe);
 
1551
                                                                                else
 
1552
                                                                                        np = currItem->PoLine.point(clRe);
 
1553
                                                                                doc->nodeEdit.ClRe = clRe;
 
1554
                                                                                np = np - FPoint(moveBy, 0);
 
1555
                                                                                doc->nodeEdit.moveClipPoint(currItem, np);
 
1556
                                                                        }
 
1557
                                                                }
 
1558
                                                                doc->nodeEdit.ClRe = storedClRe;
1502
1559
                                                        }
1503
1560
                                                        else
1504
1561
                                                        {
1508
1565
                                                                bool sav2 = doc->useRaster;
1509
1566
                                                                doc->SnapGuides = false;
1510
1567
                                                                doc->useRaster = false;
1511
 
                                                                view->moveGroup(-moveBy, 0);
 
1568
                                                                if (doc->m_Selection->count() > 1)
 
1569
                                                                        view->startGroupTransaction(Um::Move, "", Um::IMove);
 
1570
                                                                doc->moveGroup(-moveBy, 0);
 
1571
                                                                if (doc->m_Selection->count() > 1)
 
1572
                                                                        view->endGroupTransaction();
1512
1573
                                                                doc->SnapGuides = sav1;
1513
1574
                                                                doc->useRaster = sav2;
1514
1575
                                                        }
1516
1577
                                                else
1517
1578
                                                {
1518
1579
                                                        //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
1519
 
                                                        if(view->EditContour)
 
1580
                                                        if(doc->nodeEdit.isContourLine)
1520
1581
                                                                view->TransformPoly(10, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
1521
1582
                                                        else
1522
1583
                                                        {
1534
1595
                                                                }
1535
1596
                                                        }
1536
1597
                                                }
1537
 
                                                view->updateContents();
 
1598
                                                currItem->update();
1538
1599
                                                slotDocCh();
1539
1600
                                        }
1540
1601
                                        break;
1541
 
                                case Key_Right:
 
1602
                                case Qt::Key_Right:
1542
1603
                                        if (!currItem->locked())
1543
1604
                                        {
1544
1605
                                                if (!resizing)
1545
1606
                                                {
1546
 
                                                        if ((doc->EditClip) && (view->ClRe != -1))
 
1607
                                                        if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
1547
1608
                                                        {
1548
 
                                                                FPoint np;
1549
 
                                                                if (view->EditContour)
1550
 
                                                                        np = currItem->ContourLine.point(view->ClRe);
1551
 
                                                                else
1552
 
                                                                        np = currItem->PoLine.point(view->ClRe);
1553
 
                                                                np = np + FPoint(moveBy, 0);
1554
 
                                                                view->MoveClipPoint(currItem, np);
 
1609
                                                                int storedClRe = doc->nodeEdit.ClRe;
 
1610
                                                                if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
 
1611
                                                                {
 
1612
                                                                        for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
 
1613
                                                                        {
 
1614
                                                                                FPoint np;
 
1615
                                                                                int clRe = doc->nodeEdit.SelNode.at(itm);
 
1616
                                                                                if (doc->nodeEdit.isContourLine)
 
1617
                                                                                        np = currItem->ContourLine.point(clRe);
 
1618
                                                                                else
 
1619
                                                                                        np = currItem->PoLine.point(clRe);
 
1620
                                                                                doc->nodeEdit.ClRe = clRe;
 
1621
                                                                                np = np + FPoint(moveBy, 0);
 
1622
                                                                                doc->nodeEdit.moveClipPoint(currItem, np);
 
1623
                                                                        }
 
1624
                                                                }
 
1625
                                                                doc->nodeEdit.ClRe = storedClRe;
1555
1626
                                                        }
1556
1627
                                                        else
1557
1628
                                                        {
1561
1632
                                                                bool sav2 = doc->useRaster;
1562
1633
                                                                doc->SnapGuides = false;
1563
1634
                                                                doc->useRaster = false;
1564
 
                                                                view->moveGroup(moveBy, 0);
 
1635
                                                                if (doc->m_Selection->count() > 1)
 
1636
                                                                        view->startGroupTransaction(Um::Move, "", Um::IMove);
 
1637
                                                                doc->moveGroup(moveBy, 0);
 
1638
                                                                if (doc->m_Selection->count() > 1)
 
1639
                                                                        view->endGroupTransaction();
1565
1640
                                                                doc->SnapGuides = sav1;
1566
1641
                                                                doc->useRaster = sav2;
1567
1642
                                                        }
1569
1644
                                                else
1570
1645
                                                {
1571
1646
                                                        //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
1572
 
                                                        if(view->EditContour)
 
1647
                                                        if(doc->nodeEdit.isContourLine)
1573
1648
                                                                view->TransformPoly(11, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
1574
1649
                                                        else
1575
1650
                                                        {
1587
1662
                                                                }
1588
1663
                                                        }
1589
1664
                                                }
1590
 
                                                view->updateContents();
 
1665
                                                currItem->update();
1591
1666
                                                slotDocCh();
1592
1667
                                        }
1593
1668
                                        break;
1594
 
                                case Key_Up:
 
1669
                                case Qt::Key_Up:
1595
1670
                                        if (!currItem->locked())
1596
1671
                                        {
1597
1672
                                                if (!resizing)
1598
1673
                                                {
1599
 
                                                        if ((doc->EditClip) && (view->ClRe != -1))
 
1674
                                                        if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
1600
1675
                                                        {
1601
 
                                                                FPoint np;
1602
 
                                                                if (view->EditContour)
1603
 
                                                                        np = currItem->ContourLine.point(view->ClRe);
1604
 
                                                                else
1605
 
                                                                        np = currItem->PoLine.point(view->ClRe);
1606
 
                                                                np = np - FPoint(0, moveBy);
1607
 
                                                                view->MoveClipPoint(currItem, np);
 
1676
                                                                int storedClRe = doc->nodeEdit.ClRe;
 
1677
                                                                if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
 
1678
                                                                {
 
1679
                                                                        for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
 
1680
                                                                        {
 
1681
                                                                                FPoint np;
 
1682
                                                                                int clRe = doc->nodeEdit.SelNode.at(itm);
 
1683
                                                                                if (doc->nodeEdit.isContourLine)
 
1684
                                                                                        np = currItem->ContourLine.point(clRe);
 
1685
                                                                                else
 
1686
                                                                                        np = currItem->PoLine.point(clRe);
 
1687
                                                                                doc->nodeEdit.ClRe = clRe;
 
1688
                                                                                np = np - FPoint(0, moveBy);
 
1689
                                                                                doc->nodeEdit.moveClipPoint(currItem, np);
 
1690
                                                                        }
 
1691
                                                                }
 
1692
                                                                doc->nodeEdit.ClRe = storedClRe;
1608
1693
                                                        }
1609
1694
                                                        else
1610
1695
                                                        {
1614
1699
                                                                bool sav2 = doc->useRaster;
1615
1700
                                                                doc->SnapGuides = false;
1616
1701
                                                                doc->useRaster = false;
1617
 
                                                                view->moveGroup(0, -moveBy);
 
1702
                                                                if (doc->m_Selection->count() > 1)
 
1703
                                                                        view->startGroupTransaction(Um::Move, "", Um::IMove);
 
1704
                                                                doc->moveGroup(0, -moveBy);
 
1705
                                                                if (doc->m_Selection->count() > 1)
 
1706
                                                                        view->endGroupTransaction();
1618
1707
                                                                doc->SnapGuides = sav1;
1619
1708
                                                                doc->useRaster = sav2;
1620
1709
                                                        }
1622
1711
                                                else
1623
1712
                                                {
1624
1713
                                                        //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
1625
 
                                                        if(view->EditContour)
 
1714
                                                        if(doc->nodeEdit.isContourLine)
1626
1715
                                                                view->TransformPoly(12, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
1627
1716
                                                        else
1628
1717
                                                        {
1640
1729
                                                                }
1641
1730
                                                        }
1642
1731
                                                }
1643
 
                                                view->updateContents();
 
1732
                                                currItem->update();
1644
1733
                                                slotDocCh();
1645
1734
                                        }
1646
1735
                                        break;
1647
 
                                case Key_Down:
 
1736
                                case Qt::Key_Down:
1648
1737
                                        if (!currItem->locked())
1649
1738
                                        {
1650
1739
                                                if (!resizing)
1651
1740
                                                {
1652
 
                                                        if ((doc->EditClip) && (view->ClRe != -1))
 
1741
                                                        if ((doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
1653
1742
                                                        {
1654
 
                                                                FPoint np;
1655
 
                                                                if (view->EditContour)
1656
 
                                                                        np = currItem->ContourLine.point(view->ClRe);
1657
 
                                                                else
1658
 
                                                                        np = currItem->PoLine.point(view->ClRe);
1659
 
                                                                np = np + FPoint(0, moveBy);
1660
 
                                                                view->MoveClipPoint(currItem, np);
 
1743
                                                                int storedClRe = doc->nodeEdit.ClRe;
 
1744
                                                                if ((doc->nodeEdit.SelNode.count() != 0) && (doc->nodeEdit.EdPoints))
 
1745
                                                                {
 
1746
                                                                        for (int itm = 0; itm < doc->nodeEdit.SelNode.count(); ++itm)
 
1747
                                                                        {
 
1748
                                                                                FPoint np;
 
1749
                                                                                int clRe = doc->nodeEdit.SelNode.at(itm);
 
1750
                                                                                if (doc->nodeEdit.isContourLine)
 
1751
                                                                                        np = currItem->ContourLine.point(clRe);
 
1752
                                                                                else
 
1753
                                                                                        np = currItem->PoLine.point(clRe);
 
1754
                                                                                doc->nodeEdit.ClRe = clRe;
 
1755
                                                                                np = np - FPoint(0, -moveBy);
 
1756
                                                                                doc->nodeEdit.moveClipPoint(currItem, np);
 
1757
                                                                        }
 
1758
                                                                }
 
1759
                                                                doc->nodeEdit.ClRe = storedClRe;
1661
1760
                                                        }
1662
1761
                                                        else
1663
1762
                                                        {
1667
1766
                                                                bool sav2 = doc->useRaster;
1668
1767
                                                                doc->SnapGuides = false;
1669
1768
                                                                doc->useRaster = false;
1670
 
                                                                view->moveGroup(0, moveBy);
 
1769
                                                                if (doc->m_Selection->count() > 1)
 
1770
                                                                        view->startGroupTransaction(Um::Move, "", Um::IMove);
 
1771
                                                                doc->moveGroup(0, moveBy);
 
1772
                                                                if (doc->m_Selection->count() > 1)
 
1773
                                                                        view->endGroupTransaction();
1671
1774
                                                                doc->SnapGuides = sav1;
1672
1775
                                                                doc->useRaster = sav2;
1673
1776
                                                        }
1675
1778
                                                else
1676
1779
                                                {
1677
1780
                                                        //CB If in EditContour mode, allow contour line to be scaled with arrow keys too
1678
 
                                                        if(view->EditContour)
 
1781
                                                        if(doc->nodeEdit.isContourLine)
1679
1782
                                                                view->TransformPoly(13, 0, resizeBy/unitGetRatioFromIndex(doc->unitIndex()));
1680
1783
                                                        else
1681
1784
                                                        {
1693
1796
                                                                }
1694
1797
                                                        }
1695
1798
                                                }
1696
 
                                                view->updateContents();
 
1799
                                                currItem->update();
1697
1800
                                                slotDocCh();
1698
1801
                                        }
1699
1802
                                        break;
1709
1812
                                        double dX=0.0,dY=0.0;
1710
1813
                                        switch (kk)
1711
1814
                                        {
1712
 
                                                case Key_Left:
 
1815
                                                case Qt::Key_Left:
1713
1816
                                                        dX=-moveBy;
1714
1817
                                                        break;
1715
 
                                                case Key_Right:
 
1818
                                                case Qt::Key_Right:
1716
1819
                                                        dX=moveBy;
1717
1820
                                                        break;
1718
 
                                                case Key_Up:
 
1821
                                                case Qt::Key_Up:
1719
1822
                                                        dY=-moveBy;
1720
1823
                                                        break;
1721
 
                                                case Key_Down:
 
1824
                                                case Qt::Key_Down:
1722
1825
                                                        dY=moveBy;
1723
1826
                                                        break;
1724
1827
                                        }
1725
1828
                                        if (dX!=0.0 || dY!=0.0)
1726
1829
                                        {
1727
1830
                                                currItem->moveImageInFrame(dX, dY);
1728
 
                                                view->updateContents(currItem->getRedrawBounding(view->scale()));
 
1831
                                                currItem->update();
1729
1832
                                        }*/
1730
1833
                                }
1731
 
                                view->oldCp = currItem->CPos;
 
1834
//FIXME:av                              view->oldCp = currItem->CPos;
1732
1835
                                if (currItem->itemType() == PageItem::TextFrame)
1733
1836
                                {
1734
1837
                                        bool kr=keyrep;
1742
1845
        }
1743
1846
        switch(kk)
1744
1847
        {
1745
 
                case Key_Left:
1746
 
                case Key_Right:
1747
 
                case Key_Up:
1748
 
                case Key_Down:
 
1848
                case Qt::Key_Left:
 
1849
                case Qt::Key_Right:
 
1850
                case Qt::Key_Up:
 
1851
                case Qt::Key_Down:
1749
1852
                        _arrowKeyDown = true;
1750
1853
        }
1751
1854
        keyrep = false;
1753
1856
 
1754
1857
void ScribusMainWindow::keyReleaseEvent(QKeyEvent *k)
1755
1858
{
1756
 
        if (HaveDoc && (k->state() & ControlButton))
 
1859
        //Exit out of panning mode if Control is release while the right mouse button is pressed
 
1860
        if (HaveDoc)
1757
1861
        {
1758
 
                if ((doc->appMode == modePanning) && (k->state() & Qt::RightButton))
1759
 
                        setAppMode(modeNormal);
 
1862
                if ((doc->appMode == modePanning) && (k->key() == Qt::Key_Control) && (QApplication::mouseButtons() & Qt::RightButton))
 
1863
                        view->requestMode(modeNormal);
1760
1864
        }
1761
1865
        if (HaveDoc)
1762
1866
        {
1763
1867
                if (doc->appMode == modeMagnifier)
1764
 
                        qApp->setOverrideCursor(QCursor(loadIcon("LupeZ.xpm")), true);
 
1868
                        qApp->changeOverrideCursor(QCursor(loadIcon("LupeZ.xpm")));
1765
1869
        }
1766
1870
        if (k->isAutoRepeat() || !_arrowKeyDown)
1767
1871
                return;
1768
1872
        switch(k->key())
1769
1873
        {
1770
 
                case Key_Left:
1771
 
                case Key_Right:
1772
 
                case Key_Up:
1773
 
                case Key_Down:
 
1874
                case Qt::Key_Left:
 
1875
                case Qt::Key_Right:
 
1876
                case Qt::Key_Up:
 
1877
                case Qt::Key_Down:
1774
1878
                        _arrowKeyDown = false;
1775
1879
                        if ((HaveDoc) && (!view->zoomSpinBox->hasFocus()) && (!view->pageSelector->hasFocus()))
1776
1880
                        {
1777
 
                                uint docSelectionCount=doc->m_Selection->count();
1778
 
                                if ((docSelectionCount != 0) && (doc->appMode == modeNormal) && (doc->EditClip) && (view->ClRe != -1))
1779
 
                                        view->updateContents();
1780
 
                                for (uint i = 0; i < docSelectionCount; ++i)
 
1881
                                int docSelectionCount=doc->m_Selection->count();
 
1882
                                if ((docSelectionCount != 0) && (doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
 
1883
                                {
 
1884
                                        PageItem *currItem = doc->m_Selection->itemAt(0);
 
1885
                                        double xposOrig = currItem->xPos();
 
1886
                                        double yposOrig = currItem->yPos();
 
1887
                                        doc->AdjustItemSize(currItem);
 
1888
                                        if (!doc->nodeEdit.isContourLine)
 
1889
                                                currItem->ContourLine.translate(xposOrig - currItem->xPos(),yposOrig - currItem->yPos());
 
1890
                                        currItem->update();
 
1891
                                }
 
1892
                                for (int i = 0; i < docSelectionCount; ++i)
1781
1893
                                        doc->m_Selection->itemAt(i)->checkChanges(true);
1782
1894
                                if (docSelectionCount > 1 && view->groupTransactionStarted())
1783
 
                                        undoManager->commit();
 
1895
                                        view->endGroupTransaction();
1784
1896
                        }
1785
1897
                        break;
1786
1898
        }
1787
1899
}
1788
1900
 
 
1901
void ScribusMainWindow::changeEvent(QEvent *e)
 
1902
{
 
1903
        if (e->type() == QEvent::LanguageChange)
 
1904
        {
 
1905
                languageChange();
 
1906
        }
 
1907
        else
 
1908
                QWidget::changeEvent(e);
 
1909
}
 
1910
 
1789
1911
void ScribusMainWindow::closeEvent(QCloseEvent *ce)
1790
1912
{
1791
1913
        QWidgetList windows = wsp->windowList();
1814
1936
        bookmarkPalette->hide();
1815
1937
        layerPalette->hide();
1816
1938
        pagePalette->hide();
1817
 
        measurementPalette->hide();
 
1939
//      measurementPalette->hide();
1818
1940
        docCheckerPalette->hide();
1819
1941
        undoPalette->hide();
1820
1942
        alignDistributePalette->hide();
1830
1952
        if (!emergencyActivated)
1831
1953
                prefsManager->SavePrefs();
1832
1954
        UndoManager::deleteInstance();
1833
 
        qApp->setOverrideCursor(QCursor(ArrowCursor), true);
1834
 
        exit(0);
 
1955
        PrefsManager::deleteInstance();
 
1956
        FormatsManager::deleteInstance();
 
1957
        UrlLauncher::deleteInstance();
 
1958
        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 
1959
        qApp->exit(0);
1835
1960
}
1836
1961
 
1837
1962
/////////////////////////////////////////////////////////////////////
1854
1979
                if (dia->tabSelected == 0)
1855
1980
                {
1856
1981
                        int facingPages = dia->choosenLayout;
1857
 
                        int firstPage = dia->firstPage->currentItem();
 
1982
                        int firstPage = dia->firstPage->currentIndex();
1858
1983
                        docSet = dia->startDocSetup->isChecked();
1859
1984
                        double topMargin = dia->marginGroup->top();
1860
1985
                        double bottomMargin = dia->marginGroup->bottom();
1875
2000
                                PageSize ps2(dia->pageSizeComboBox->currentText());
1876
2001
                                pagesize = ps2.name();
1877
2002
                        }
1878
 
                        doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentItem(), firstPage, orientation, 1, pagesize, true, pageCount);
 
2003
                        doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset());
1879
2004
                        doc->pageSets[facingPages].FirstPage = firstPage;
1880
2005
                        doc->bleeds.Bottom = dia->bleedBottom;
1881
2006
                        doc->bleeds.Top = dia->bleedTop;
1882
2007
                        doc->bleeds.Left = dia->bleedLeft;
1883
2008
                        doc->bleeds.Right = dia->bleedRight;
1884
2009
                        HaveNewDoc();
 
2010
                        doc->reformPages(true);
 
2011
                        // Don's disturb user with "save?" dialog just after new doc
 
2012
                        // doc changing should be rewritten maybe... maybe later...
 
2013
                        doc->setModified(false);
 
2014
                        updateActiveWindowCaption(doc->DocName);
1885
2015
                }
1886
2016
                else
1887
2017
                {
1888
2018
                        if (dia->tabSelected == 1)
1889
2019
                        {
1890
 
                                QString fileName(dia->fileDialog->selectedFile());
 
2020
                                QString fileName(dia->selectedFile);
1891
2021
                                if (!fileName.isEmpty())
1892
2022
                                {
1893
 
                                        docContext->set("docsopen", fileName.left(fileName.findRev("/")));
 
2023
                                        docContext->set("docsopen", fileName.left(fileName.lastIndexOf("/")));
1894
2024
                                        loadDoc(fileName);
1895
2025
                                }
1896
2026
                        }
1897
2027
                        else
1898
2028
                        {
1899
 
                                QString fileName(dia->recentDocListBox->currentText());
1900
 
                                if (!fileName.isEmpty())
1901
 
                                        loadRecent(ScPaths::separatorsToSlashes(fileName));
 
2029
                                if (dia->recentDocListBox->currentItem() != NULL)
 
2030
                                {
 
2031
                                        QString fileName(dia->recentDocListBox->currentItem()->text());
 
2032
                                        if (!fileName.isEmpty())
 
2033
                                                loadRecent(QDir::fromNativeSeparators(fileName));
 
2034
                                }
1902
2035
                        }
1903
2036
                }
1904
2037
        }
1911
2044
 
1912
2045
bool ScribusMainWindow::slotFileNew()
1913
2046
{
1914
 
        if (HaveDoc && doc->EditClip)
1915
 
                ToggleFrameEdit();
 
2047
        if (HaveDoc && doc->appMode == modeEditClip)
 
2048
                view->requestMode(submodeEndNodeEdit);
1916
2049
        bool retVal = false;
1917
2050
        bool docSet = false;
1918
2051
        NewDoc* dia = new NewDoc(this, RecentDocs);
1919
2052
        if (dia->exec())
1920
2053
        {
1921
2054
                int facingPages = dia->choosenLayout;
1922
 
                int firstPage = dia->firstPage->currentItem();
 
2055
                int firstPage = dia->firstPage->currentIndex();
1923
2056
                docSet = dia->startDocSetup->isChecked();
1924
2057
                double topMargin = dia->marginGroup->top();
1925
2058
                double bottomMargin = dia->marginGroup->bottom();
1940
2073
                        PageSize ps2(dia->pageSizeComboBox->currentText());
1941
2074
                        pagesize = ps2.name();
1942
2075
                }
1943
 
                if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentItem(), firstPage, orientation, 1, pagesize, true, pageCount))
 
2076
                if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset()))
1944
2077
                {
1945
2078
                        doc->pageSets[facingPages].FirstPage = firstPage;
1946
2079
                        doc->bleeds.Bottom = dia->bleedBottom;
1949
2082
                        doc->bleeds.Right = dia->bleedRight;
1950
2083
                        mainWindowStatusLabel->setText( tr("Ready"));
1951
2084
                        HaveNewDoc();
 
2085
                        doc->reformPages(true);
1952
2086
                        retVal = true;
 
2087
                        // Don's disturb user with "save?" dialog just after new doc
 
2088
                        // doc changing should be rewritten maybe... maybe later...
 
2089
                        doc->setModified(false);
 
2090
                        updateActiveWindowCaption(doc->DocName);
1953
2091
                }
1954
2092
        }
1955
2093
        delete dia;
1959
2097
}
1960
2098
 
1961
2099
//TODO move to core, assign doc to doc list, optionally create gui for it
1962
 
ScribusDoc *ScribusMainWindow::newDoc(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount, bool showView)
 
2100
ScribusDoc *ScribusMainWindow::newDoc(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount, bool showView, int marginPreset)
1963
2101
{
1964
 
        return doFileNew(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, columnCount, autoTextFrames, pageArrangement, unitIndex, firstPageLocation, orientation, firstPageNumber, defaultPageSize, requiresGUI, pageCount, showView);
 
2102
        return doFileNew(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, columnCount, autoTextFrames, pageArrangement, unitIndex, firstPageLocation, orientation, firstPageNumber, defaultPageSize, requiresGUI, pageCount, showView, marginPreset);
1965
2103
        /* TODO CB finish later this week.
1966
2104
        if (HaveDoc)
1967
2105
                doc->OpenNodes = outlinePalette->buildReopenVals();
1979
2117
        doc->setPage(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, columnCount, autoTextFrames, pageArrangement);
1980
2118
        doc->setMasterPageMode(false);
1981
2119
        doc->addMasterPage(0, CommonStrings::masterPageNormal);
1982
 
        int createCount=QMAX(pageCount,1);
 
2120
        int createCount=qMax(pageCount,1);
1983
2121
        for (int i = 0; i < createCount; ++i)
1984
2122
                doc->addPage(i, CommonStrings::masterPageNormal, true);
1985
2123
        doc->addSection();
2040
2178
        */
2041
2179
}
2042
2180
 
2043
 
ScribusDoc *ScribusMainWindow::doFileNew(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount, bool showView)
 
2181
ScribusDoc *ScribusMainWindow::doFileNew(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount, bool showView, int marginPreset)
2044
2182
{
2045
2183
        if (HaveDoc)
2046
2184
                outlinePalette->buildReopenVals();
2064
2202
                recalcColors();
2065
2203
        //CB NOTE should be all done now
2066
2204
        tempDoc->setPage(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnCount, columnDistance, autoTextFrames, pageArrangement);
 
2205
        tempDoc->marginPreset = marginPreset;
2067
2206
        tempDoc->setMasterPageMode(false);
2068
2207
        tempDoc->createDefaultMasterPages();
2069
2208
        tempDoc->createNewDocPages(pageCount);
2085
2224
        if (requiresGUI && view!=NULL)
2086
2225
        {
2087
2226
                actionManager->disconnectNewViewActions();
2088
 
                disconnect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
 
2227
                disconnect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
2089
2228
        }
2090
2229
        ScribusView* tempView = new ScribusView(w, this, tempDoc);
2091
2230
        if (requiresGUI)
2092
2231
                view = tempView;
2093
2232
        tempDoc->setCurrentPage(tempDoc->Pages->at(0));
2094
2233
        tempDoc->setGUI(requiresGUI, this, tempView);
 
2234
        tempDoc->docHyphenator->ignoredWords = prefsManager->appPrefs.ignoredWords;
 
2235
        tempDoc->docHyphenator->specialWords = prefsManager->appPrefs.specialWords;
2095
2236
        tempDoc->setLoading(false);
2096
2237
        //run after setGUI to set up guidepalette ok
2097
2238
 
2105
2246
        w->setView(tempView);
2106
2247
        ActWin = w;
2107
2248
        tempDoc->WinHan = w;
2108
 
        w->setCentralWidget(tempView);
2109
2249
        if (requiresGUI)
2110
2250
                tempDoc->connectDocSignals(); //Must be before the first reformpages
2111
2251
        tempView->reformPages(true);
2112
2252
        //>>
2113
2253
        if (requiresGUI)
2114
2254
        {
 
2255
                wsp->addWindow(w);
2115
2256
                connect(undoManager, SIGNAL(undoRedoDone()), tempView, SLOT(DrawNew()));
2116
2257
                //connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
2117
 
                connect(tempView, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
 
2258
                connect(tempView, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
2118
2259
                //      connect(w, SIGNAL(SaveAndClose()), this, SLOT(DoSaveClose()));
2119
2260
        }
2120
2261
        //Independent finishing tasks after tempDoc setup
2131
2272
                connect(w, SIGNAL(AutoSaved()), this, SLOT(slotAutoSaved()));
2132
2273
                connect(ScCore->fileWatcher, SIGNAL(fileChanged(QString)), tempDoc, SLOT(updatePict(QString)));
2133
2274
                connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString)), tempDoc, SLOT(removePict(QString)));
 
2275
                connect(ScCore->fileWatcher, SIGNAL(dirChanged(QString )), tempDoc, SLOT(updatePictDir(QString )));
2134
2276
                //scrActions["fileSave"]->setEnabled(false);
2135
 
                tempView->cmsToolbarButton->setOn(tempDoc->HasCMS);
 
2277
                tempView->cmsToolbarButton->setChecked(tempDoc->HasCMS);
2136
2278
                undoManager->switchStack(tempDoc->DocName);
2137
2279
                styleManager->setDoc(tempDoc);
2138
2280
                tocGenerator->setDoc(tempDoc);
2157
2299
        //connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
2158
2300
}
2159
2301
 
2160
 
void ScribusMainWindow::fontMenuAboutToShow()
2161
 
{
2162
 
        QString df;
2163
 
        if (doc->m_Selection->count() != 0)
2164
 
        {
2165
 
                PageItem *currItem = doc->m_Selection->itemAt(0);
2166
 
                FontSub->RebuildList(doc, currItem->isAnnotation());
2167
 
        }
2168
 
        FontSub->setCurrentText(currentFontForFontMenu);
2169
 
        //propertiesPalette->Fonts->setCurrentFont(nf);
2170
 
        for (uint a = 2; a < FontMenu->count(); ++a)
2171
 
        {
2172
 
                df = FontID[FontMenu->idAt(a)];
2173
 
                FontMenu->setItemChecked(FontMenu->idAt(a), (df == currentFontForFontMenu));
2174
 
        }
2175
 
}
2176
 
 
2177
2302
void ScribusMainWindow::windowsMenuAboutToShow()
2178
2303
{
2179
 
        for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrWindowsActions.begin(); it!=scrWindowsActions.end(); ++it )
 
2304
        for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrWindowsActions.begin(); it!=scrWindowsActions.end(); ++it )
2180
2305
                scrMenuMgr->removeMenuItem((*it), "Windows");
2181
2306
        scrWindowsActions.clear();
2182
2307
        addDefaultWindowMenuItems();
2191
2316
                        scrMenuMgr->addMenuSeparator("Windows");
2192
2317
                for ( int i = 0; i < windowCount; ++i )
2193
2318
                {
2194
 
                        QString docInWindow=windows.at(i)->caption();
2195
 
                        scrWindowsActions.insert(docInWindow, new ScrAction( ScrAction::Window, noIcon, docInWindow, QKeySequence(), this, docInWindow, i));
 
2319
                        QString docInWindow(windows.at(i)->windowTitle());
 
2320
                        scrWindowsActions.insert(docInWindow, new ScrAction( ScrAction::Window, QPixmap(), QPixmap(), docInWindow, QKeySequence(), this, i));
2196
2321
                        scrWindowsActions[docInWindow]->setToggleAction(true);
2197
 
                        connect( scrWindowsActions[docInWindow], SIGNAL(activatedData(int)), this, SLOT(windowsMenuActivated(int)) );
 
2322
                        connect( scrWindowsActions[docInWindow], SIGNAL(triggeredData(int)), this, SLOT(windowsMenuActivated(int)) );
2198
2323
                        if (windowCount>1)
2199
2324
                                scrMenuMgr->addMenuItem(scrWindowsActions[docInWindow], "Windows");
2200
 
                        scrWindowsActions[docInWindow]->setOn(wsp->activeWindow() == windows.at(i));
2201
 
                }
2202
 
        }
 
2325
                        scrWindowsActions[docInWindow]->setChecked(wsp->activeWindow() == windows.at(i));
 
2326
                }
 
2327
        }
 
2328
}
 
2329
 
 
2330
void ScribusMainWindow::extrasMenuAboutToShow()
 
2331
{
 
2332
        // There is only Picture Manager handled now.
 
2333
        // As it can be opened all the time of the document life.
 
2334
        // This is only check for availability of any ImageFrame
 
2335
        // in the doc.
 
2336
        bool enablePicManager = false;
 
2337
        if (HaveDoc)
 
2338
        {
 
2339
                for (int i = 0; i < doc->Items->count(); ++i)
 
2340
                {
 
2341
                        if ((doc->Items->at(i)->itemType() == PageItem::ImageFrame) && (!doc->Items->at(i)->asLatexFrame()))
 
2342
                        {
 
2343
                                enablePicManager = true;
 
2344
                                break;
 
2345
                        }
 
2346
                }
 
2347
        }
 
2348
        scrActions["extrasManageImages"]->setEnabled(enablePicManager);
2203
2349
}
2204
2350
 
2205
2351
void ScribusMainWindow::newActWin(QWidget *w)
2209
2355
                ActWin = NULL;
2210
2356
                return;
2211
2357
        }
2212
 
        if (doc!=0 && doc->EditClip)
2213
 
                ToggleFrameEdit();
 
2358
        if (doc!=0 && doc->appMode == modeEditClip)
 
2359
                view->requestMode(submodeEndNodeEdit);
2214
2360
        ScribusWin* scw = (ScribusWin*)w;
2215
2361
        if (scw && scw->doc())
2216
2362
                if (!scw->doc()->hasGUI())
2232
2378
        if (view!=NULL)
2233
2379
        {
2234
2380
                actionManager->disconnectNewViewActions();
2235
 
                disconnect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
 
2381
                disconnect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
2236
2382
                if (ScCore->usingGUI())
2237
2383
                {
2238
2384
                        disconnect(doc->m_Selection, SIGNAL(selectionIsMultiple(bool)), 0, 0);
2244
2390
        actionManager->connectNewViewActions(view);
2245
2391
        actionManager->disconnectNewDocActions();
2246
2392
        actionManager->connectNewDocActions(doc);
2247
 
        connect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
 
2393
        connect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
2248
2394
        if (ScCore->usingGUI())
2249
2395
        {
2250
2396
                connect(doc->m_Selection, SIGNAL(selectionIsMultiple(bool)), propertiesPalette, SLOT( setMultipleSelection(bool)));
2271
2417
                }
2272
2418
                //if (doc->masterPageMode())
2273
2419
                //      ActWin->setMasterPagesPaletteShown(true);
2274
 
                setAppMode(doc->appMode);
 
2420
                view->requestMode(doc->appMode);
2275
2421
        }
2276
 
        w->setFocus();
 
2422
        view->setFocus();
2277
2423
        wsp->setScrollBarsEnabled(!(w->isMaximized()));
2278
 
        scrActions["viewShowMargins"]->setOn(doc->guidesSettings.marginsShown);
2279
 
        scrActions["viewShowBleeds"]->setOn(doc->guidesSettings.showBleed);
2280
 
        scrActions["viewShowFrames"]->setOn(doc->guidesSettings.framesShown);
2281
 
        scrActions["viewShowLayerMarkers"]->setOn(doc->guidesSettings.layerMarkersShown);
2282
 
        scrActions["viewShowGrid"]->setOn(doc->guidesSettings.gridShown);
2283
 
        scrActions["viewShowGuides"]->setOn(doc->guidesSettings.guidesShown);
2284
 
        scrActions["viewShowColumnBorders"]->setOn(doc->guidesSettings.colBordersShown);
2285
 
        scrActions["viewShowBaseline"]->setOn(doc->guidesSettings.baseShown);
2286
 
        scrActions["viewShowImages"]->setOn(doc->guidesSettings.showPic);
2287
 
        scrActions["viewShowTextChain"]->setOn(doc->guidesSettings.linkShown);
2288
 
        scrActions["viewShowTextControls"]->setOn(doc->guidesSettings.showControls);
2289
 
        scrActions["viewShowRulers"]->setOn(doc->guidesSettings.rulersShown);
2290
 
        scrActions["viewRulerMode"]->setOn(doc->guidesSettings.rulerMode);
 
2424
        scrActions["viewShowMargins"]->setChecked(doc->guidesSettings.marginsShown);
 
2425
        scrActions["viewShowBleeds"]->setChecked(doc->guidesSettings.showBleed);
 
2426
        scrActions["viewShowFrames"]->setChecked(doc->guidesSettings.framesShown);
 
2427
        scrActions["viewShowLayerMarkers"]->setChecked(doc->guidesSettings.layerMarkersShown);
 
2428
        scrActions["viewShowGrid"]->setChecked(doc->guidesSettings.gridShown);
 
2429
        scrActions["viewShowGuides"]->setChecked(doc->guidesSettings.guidesShown);
 
2430
        scrActions["viewShowColumnBorders"]->setChecked(doc->guidesSettings.colBordersShown);
 
2431
        scrActions["viewShowBaseline"]->setChecked(doc->guidesSettings.baseShown);
 
2432
        scrActions["viewShowImages"]->setChecked(doc->guidesSettings.showPic);
 
2433
        scrActions["viewShowTextChain"]->setChecked(doc->guidesSettings.linkShown);
 
2434
        scrActions["viewShowTextControls"]->setChecked(doc->guidesSettings.showControls);
 
2435
        scrActions["viewShowRulers"]->setChecked(doc->guidesSettings.rulersShown);
 
2436
        scrActions["viewRulerMode"]->setChecked(doc->guidesSettings.rulerMode);
2291
2437
        scrActions["extrasGenerateTableOfContents"]->setEnabled(doc->hasTOCSetup());
2292
2438
        if (!doc->masterPageMode())
2293
2439
                pagePalette->Rebuild();
2310
2456
        }
2311
2457
        tocGenerator->setDoc(doc);
2312
2458
        styleManager->setDoc(doc);
 
2459
        // Give plugins a chance to react on changing the current document
 
2460
        PluginManager& pluginManager(PluginManager::instance());
 
2461
        QStringList pluginNames(pluginManager.pluginNames(false));
 
2462
        ScPlugin* plugin;
 
2463
        QString pName;
 
2464
        for (int i = 0; i < pluginNames.count(); ++i)
 
2465
        {
 
2466
                pName = pluginNames.at(i);
 
2467
                plugin = pluginManager.getPlugin(pName, true);
 
2468
                Q_ASSERT(plugin); // all the returned names should represent loaded plugins
 
2469
                plugin->setDoc(doc);
 
2470
        }
2313
2471
}
2314
2472
 
2315
2473
void ScribusMainWindow::windowsMenuActivated( int id )
2326
2484
        dia->updateDocumentSettings();
2327
2485
        if (dia->imageResolutionChanged())
2328
2486
        {
2329
 
                setStatusBarInfoText( tr("Updating Pictures"));
 
2487
                setStatusBarInfoText( tr("Updating Images"));
2330
2488
                mainWindowProgressBar->reset();
2331
 
                qApp->setOverrideCursor(QCursor(waitCursor), true);
 
2489
                qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
2332
2490
                qApp->processEvents();
2333
2491
                doc->recalcPicturesRes(true);
2334
 
                qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
2492
                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
2335
2493
                setStatusBarInfoText("");
2336
2494
                mainWindowProgressBar->reset();
 
2495
                view->previewQualitySwitcher->blockSignals(true);
 
2496
                view->previewQualitySwitcher->setCurrentIndex(doc->toolSettings.lowResType);
 
2497
                view->previewQualitySwitcher->blockSignals(false);
2337
2498
        }
2338
 
        FontSub->RebuildList(doc);
2339
2499
        propertiesPalette->Fonts->RebuildList(doc);
2340
 
        scrActions["viewShowMargins"]->setOn(doc->guidesSettings.marginsShown);
2341
 
        scrActions["viewShowBleeds"]->setOn(doc->guidesSettings.showBleed);
2342
 
        scrActions["viewShowFrames"]->setOn(doc->guidesSettings.framesShown);
2343
 
        scrActions["viewShowLayerMarkers"]->setOn(doc->guidesSettings.layerMarkersShown);
2344
 
        scrActions["viewShowGrid"]->setOn(doc->guidesSettings.gridShown);
2345
 
        scrActions["viewShowGuides"]->setOn(doc->guidesSettings.guidesShown);
2346
 
        scrActions["viewShowColumnBorders"]->setOn(doc->guidesSettings.colBordersShown);
2347
 
        scrActions["viewShowBaseline"]->setOn(doc->guidesSettings.baseShown);
2348
 
        scrActions["viewShowImages"]->setOn(doc->guidesSettings.showPic);
2349
 
        scrActions["viewShowTextChain"]->setOn(doc->guidesSettings.linkShown);
2350
 
        scrActions["viewShowTextControls"]->setOn(doc->guidesSettings.showControls);
2351
 
        scrActions["viewShowRulers"]->setOn(doc->guidesSettings.rulersShown);
2352
 
        scrActions["viewRulerMode"]->setOn(doc->guidesSettings.rulerMode);
 
2500
        scrActions["viewShowMargins"]->setChecked(doc->guidesSettings.marginsShown);
 
2501
        scrActions["viewShowBleeds"]->setChecked(doc->guidesSettings.showBleed);
 
2502
        scrActions["viewShowFrames"]->setChecked(doc->guidesSettings.framesShown);
 
2503
        scrActions["viewShowLayerMarkers"]->setChecked(doc->guidesSettings.layerMarkersShown);
 
2504
        scrActions["viewShowGrid"]->setChecked(doc->guidesSettings.gridShown);
 
2505
        scrActions["viewShowGuides"]->setChecked(doc->guidesSettings.guidesShown);
 
2506
        scrActions["viewShowColumnBorders"]->setChecked(doc->guidesSettings.colBordersShown);
 
2507
        scrActions["viewShowBaseline"]->setChecked(doc->guidesSettings.baseShown);
 
2508
        scrActions["viewShowImages"]->setChecked(doc->guidesSettings.showPic);
 
2509
        scrActions["viewShowTextChain"]->setChecked(doc->guidesSettings.linkShown);
 
2510
        scrActions["viewShowTextControls"]->setChecked(doc->guidesSettings.showControls);
 
2511
        scrActions["viewShowRulers"]->setChecked(doc->guidesSettings.rulersShown);
 
2512
        scrActions["viewRulerMode"]->setChecked(doc->guidesSettings.rulerMode);
2353
2513
        scrActions["extrasGenerateTableOfContents"]->setEnabled(doc->hasTOCSetup());
2354
 
        view->cmsToolbarButton->setOn(doc->HasCMS);
 
2514
        view->cmsToolbarButton->setChecked(doc->HasCMS);
2355
2515
        //doc emits changed() via this
2356
2516
        doc->setMasterPageMode(true);
2357
2517
        view->reformPages();
2365
2525
        view->GotoPage(doc->currentPage()->pageNr());
2366
2526
        view->DrawNew();
2367
2527
        propertiesPalette->ShowCMS();
2368
 
        pagePalette->RebuildPage();
 
2528
        pagePalette->rebuildPages();
2369
2529
}
2370
2530
 
2371
2531
bool ScribusMainWindow::slotDocSetup()
2384
2544
 
2385
2545
void ScribusMainWindow::SwitchWin()
2386
2546
{
2387
 
        updateColorMenu();
2388
 
        buildFontMenu();
2389
2547
        propertiesPalette->Cpal->ChooseGrad(0);
2390
2548
        updateActiveWindowCaption(doc->DocName);
2391
 
        scrActions["shade100"]->setOn(true);
 
2549
//      scrActions["shade100"]->setChecked(true);
2392
2550
        propertiesPalette->setDoc(doc);
2393
2551
        pagePalette->setView(view);
2394
 
        FontSub->RebuildList(doc);
2395
2552
        propertiesPalette->Fonts->RebuildList(doc);
2396
2553
        layerPalette->setDoc(doc);
2397
2554
        guidePalette->setDoc(doc);
2404
2561
        //if we are switching windows #4357
2405
2562
        //nodePalette->setDoc(doc, view);
2406
2563
        slotChangeUnit(doc->unitIndex(), false);
2407
 
        if (doc->EditClip)
 
2564
/*      FIXME: check if this is really superflous now
 
2565
        if (doc->appMode == modeEditClip)
2408
2566
        {
2409
 
                doc->EditClip = !doc->EditClip;
2410
 
                ToggleFrameEdit();
2411
 
        }
 
2567
                doc->appMode = modeNormal;
 
2568
                view->requestMode(submodeEndNodeEdit);
 
2569
        } */
2412
2570
        scrActions["fileClose"]->setEnabled(true);
2413
2571
        if (doc->masterPageMode())
2414
2572
        {
2426
2584
                scrActions["fileRevert"]->setEnabled(false);
2427
2585
                scrMenuMgr->setMenuEnabled("FileOpenRecent", false);
2428
2586
                pagePalette->enablePalette(false);
 
2587
                scrActions["toolsPDFPushButton"]->setEnabled(false);
 
2588
                scrActions["toolsPDFTextField"]->setEnabled(false);
 
2589
                scrActions["toolsPDFCheckBox"]->setEnabled(false);
 
2590
                scrActions["toolsPDFComboBox"]->setEnabled(false);
 
2591
                scrActions["toolsPDFListBox"]->setEnabled(false);
 
2592
                scrActions["toolsPDFAnnotText"]->setEnabled(false);
2429
2593
        }
2430
2594
        else
2431
2595
        {
2435
2599
                scrActions["fileOpen"]->setEnabled(true);
2436
2600
                scrActions["fileClose"]->setEnabled(true);
2437
2601
                scrActions["fileSave"]->setEnabled(true);
2438
 
                //CB TODO  Huh? Why different to the above?, fileMenu->setItemEnabled(M_FileSave, ActWin->MenuStat[2]);
2439
 
                scrActions["fileSaveAs"]->setEnabled(ActWin->menuStatus(3));
2440
 
                scrActions["fileCollect"]->setEnabled(ActWin->menuStatus(3));
2441
2602
                scrActions["fileRevert"]->setEnabled(false);
2442
2603
                scrMenuMgr->setMenuEnabled("FileOpenRecent", true);
2443
2604
 
2451
2612
                }
2452
2613
                scrActions["fileSaveAs"]->setEnabled(true);
2453
2614
                scrActions["fileCollect"]->setEnabled(true);
 
2615
                scrActions["toolsPDFPushButton"]->setEnabled(true);
 
2616
                scrActions["toolsPDFTextField"]->setEnabled(true);
 
2617
                scrActions["toolsPDFCheckBox"]->setEnabled(true);
 
2618
                scrActions["toolsPDFComboBox"]->setEnabled(true);
 
2619
                scrActions["toolsPDFListBox"]->setEnabled(true);
 
2620
                scrActions["toolsPDFAnnotText"]->setEnabled(true);
2454
2621
                pagePalette->enablePalette(true);
2455
2622
        }
 
2623
        scrMenuMgr->setMenuEnabled("ItemLayer", doc->layerCount() > 1);
2456
2624
}
2457
2625
 
2458
2626
void ScribusMainWindow::HaveNewDoc()
2471
2639
        scrActions["pageImport"]->setEnabled(true);
2472
2640
        //scrActions["toolsPreflightVerifier"]->setEnabled(true);
2473
2641
 
2474
 
        if ( ScCore->haveGS()==0 || ScCore->isWinGUI() )
 
2642
        if ( ScCore->haveGS() || ScCore->isWinGUI() )
2475
2643
                scrActions["PrintPreview"]->setEnabled(true);
2476
2644
 
2477
2645
        if (scrActions["SaveAsDocumentTemplate"])
2479
2647
 
2480
2648
        scrActions["editCut"]->setEnabled(false);
2481
2649
        scrActions["editCopy"]->setEnabled(false);
2482
 
        scrActions["editPaste"]->setEnabled((!Buffer2.isEmpty()) || (scrapbookPalette->tempBView->objectMap.count() > 0));
 
2650
        scrActions["editPaste"]->setEnabled((ScMimeData::clipboardHasScribusData()) || (scrapbookPalette->tempBView->objectMap.count() > 0));
2483
2651
        scrMenuMgr->setMenuEnabled("EditPasteRecent", scrapbookPalette->tempBView->objectMap.count() > 0);
2484
2652
        scrMenuMgr->setMenuEnabled("EditContents", false);
2485
2653
        scrActions["editCopyContents"]->setEnabled(false);
2486
2654
        scrActions["editPasteContents"]->setEnabled(false);
2487
2655
        scrActions["editPasteContentsAbs"]->setEnabled(false);
2488
2656
        scrActions["editSelectAll"]->setEnabled(true);
 
2657
        scrActions["editSelectAllOnLayer"]->setEnabled(true);
2489
2658
        scrActions["editDeselectAll"]->setEnabled(false);
 
2659
        scrActions["editReplaceColors"]->setEnabled(true);
2490
2660
        scrActions["editPatterns"]->setEnabled(true);
2491
2661
        scrActions["editStyles"]->setEnabled(true);
2492
2662
        scrActions["editMasterPages"]->setEnabled(true);
2493
2663
        scrActions["editJavascripts"]->setEnabled(true);
2494
2664
 
2495
2665
        scrMenuMgr->setMenuEnabled("View", true);
2496
 
        scrActions["viewSnapToGrid"]->setOn(doc->useRaster);
2497
 
        scrActions["viewSnapToGuides"]->setOn(doc->SnapGuides);
 
2666
        scrActions["viewSnapToGrid"]->setChecked(doc->useRaster);
 
2667
        scrActions["viewSnapToGuides"]->setChecked(doc->SnapGuides);
2498
2668
        scrActions["viewShowRulers"]->setEnabled(true);
2499
2669
 
2500
2670
        scrMenuMgr->setMenuEnabled("Insert", true);
2513
2683
        scrActions["toolsInsertBezier"]->setEnabled(true);
2514
2684
        scrActions["toolsInsertFreehandLine"]->setEnabled(true);
2515
2685
        scrActions["toolsInsertPolygon"]->setEnabled(true);
2516
 
        scrActions["toolsMeasurements"]->setEnabled(true);
 
2686
        scrActions["toolsInsertRenderFrame"]->setEnabled(true);
 
2687
        scrActions["toolsMeasurements"]->setEnabled(true);
2517
2688
        scrActions["toolsEyeDropper"]->setEnabled(true);
2518
2689
        scrActions["toolsPDFPushButton"]->setEnabled(true);
2519
2690
        scrActions["toolsPDFTextField"]->setEnabled(true);
2526
2697
        bool setter = doc->Pages->count() > 1 ? true : false;
2527
2698
        scrActions["pageDelete"]->setEnabled(setter);
2528
2699
        scrActions["pageMove"]->setEnabled(setter);
 
2700
        scrMenuMgr->setMenuEnabled("ItemLayer", doc->layerCount() > 1);
2529
2701
 
2530
 
        updateColorMenu();
2531
2702
        //Update palettes
2532
2703
        updateActiveWindowCaption(doc->DocName);
2533
 
        scrActions["shade100"]->setOn(true);
 
2704
//      scrActions["shade100"]->setChecked(true);
2534
2705
        propertiesPalette->setDoc(doc);
2535
2706
        propertiesPalette->Cpal->ChooseGrad(0);
2536
2707
//      propertiesPalette->updateColorList();
2545
2716
        view->updateLayerMenu();
2546
2717
        view->setLayerMenuText(doc->activeLayerName());
2547
2718
        slotChangeUnit(doc->unitIndex());
2548
 
        buildFontMenu();
2549
2719
        windowsMenuAboutToShow();
2550
2720
        connect(view, SIGNAL(changeUN(int)), this, SLOT(slotChangeUnit(int)));
2551
2721
        connect(view, SIGNAL(changeLA(int)), layerPalette, SLOT(markActiveLayer(int)));
2559
2729
        connect(view, SIGNAL(ChBMText(PageItem *)), this, SLOT(BookMarkTxT(PageItem *)));
2560
2730
        connect(view, SIGNAL(HaveSel(int)), this, SLOT(HaveNewSel(int)));
2561
2731
        connect(view, SIGNAL(SetAngle(double)), propertiesPalette, SLOT(setR(double)));
2562
 
        connect(view, SIGNAL(SetSizeValue(double)), propertiesPalette, SLOT(setSvalue(double)));
2563
 
        connect(view, SIGNAL(SetLocalValues(double, double, double, double)), propertiesPalette, SLOT(setLvalue(double, double, double, double)));
 
2732
        connect(view, SIGNAL(SetSizeValue(double)), propertiesPalette, SLOT(setLineWidth(double)));
 
2733
        connect(view, SIGNAL(SetLocalValues(double, double, double, double)), propertiesPalette, SLOT(setScaleAndOffset(double, double, double, double)));
2564
2734
        connect(view, SIGNAL(SetLineArt(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)), propertiesPalette, SLOT( setLIvalue(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)));
2565
2735
//      connect(view, SIGNAL(ItemFarben(QString, QString, int, int)), this, SLOT(setCSMenu(QString, QString, int, int)));
2566
2736
//      connect(view, SIGNAL(ItemFarben(QString, QString, int, int)), propertiesPalette->Cpal, SLOT(setActFarben(QString, QString, int, int)));
2568
2738
//      connect(view, SIGNAL(ItemTrans(double, double)), propertiesPalette->Cpal, SLOT(setActTrans(double, double)));
2569
2739
//      connect(view, SIGNAL(ItemBlend(int, int)), propertiesPalette->Cpal, SLOT(setActBlend(int, int)));
2570
2740
        connect(view, SIGNAL(ItemTextAttr(double)), propertiesPalette, SLOT(setLsp(double)));
2571
 
        connect(view, SIGNAL(ItemTextUSval(int)), propertiesPalette, SLOT(setExtra(int)));
 
2741
        connect(view, SIGNAL(ItemTextUSval(double)), propertiesPalette, SLOT(setExtra(double)));
2572
2742
//      connect(view, SIGNAL(ItemTextCols(int, double)), propertiesPalette, SLOT(setCols(int, double)));
2573
 
        connect(view, SIGNAL(SetDistValues(double, double, double, double)), propertiesPalette, SLOT(setDvals(double, double, double, double)));
 
2743
        connect(view, SIGNAL(SetDistValues(double, double, double, double)), propertiesPalette, SLOT(setTextToFrameDistances(double, double, double, double)));
2574
2744
        connect(view, SIGNAL(ItemTextAbs(int)), propertiesPalette, SLOT(setAli(int)));
2575
 
        connect(view, SIGNAL(ItemTextFont(const QString&)), this, SLOT(AdjustFontMenu(const QString&)));
2576
2745
        connect(view, SIGNAL(ItemTextFont(const QString&)), propertiesPalette, SLOT(setFontFace(const QString&)));
2577
 
        connect(view, SIGNAL(ItemTextSize(int)), propertiesPalette, SLOT(setSize(int)));
 
2746
        connect(view, SIGNAL(ItemTextSize(double)), propertiesPalette, SLOT(setSize(double)));
2578
2747
        //connect(view, SIGNAL(ItemRadius(double)), propertiesPalette, SLOT(setRR(double)));
2579
 
        connect(view, SIGNAL(Amode(int)), this, SLOT(setAppMode(int)));
 
2748
//      connect(view, SIGNAL(Amode(int)), this, SLOT(setAppMode(int)));
2580
2749
        connect(view, SIGNAL(PaintingDone()), this, SLOT(slotSelect()));
2581
2750
        connect(view, SIGNAL(DocChanged()), this, SLOT(slotDocCh()));
2582
2751
        //connect(view, SIGNAL(HavePoint(bool, bool)), nodePalette, SLOT(HaveNode(bool, bool)));
2583
2752
        connect(view, SIGNAL(MousePos(double, double)), this, SLOT(setStatusBarMousePosition(double, double)));
2584
2753
        //connect(view, SIGNAL(ItemRadius(double)), propertiesPalette, SLOT(setRR(double)));
2585
2754
        connect(view, SIGNAL(ItemTextStil(int)), propertiesPalette, SLOT(setStil(int)));
2586
 
        connect(view, SIGNAL(ItemTextSca(int)), propertiesPalette, SLOT(setTScale(int)));
2587
 
        connect(view, SIGNAL(ItemTextScaV(int)), propertiesPalette, SLOT(setTScaleV(int)));
2588
 
        connect(view, SIGNAL(ItemTextBase(int)), propertiesPalette, SLOT(setTBase(int)));
2589
 
        connect(view, SIGNAL(ItemTextShadow(int, int )), propertiesPalette, SLOT(setShadowOffs(int, int )));
2590
 
        connect(view, SIGNAL(ItemTextUnderline(int, int)), propertiesPalette, SLOT(setUnderline(int, int)));
2591
 
        connect(view, SIGNAL(ItemTextStrike(int, int)), propertiesPalette, SLOT(setStrike(int, int)));
2592
 
        connect(view, SIGNAL(ItemTextOutline(int)), propertiesPalette, SLOT(setOutlineW(int)));
2593
 
        connect(view, SIGNAL(ItemTextSize(int)), this, SLOT(setFSizeMenu(int)));
 
2755
        connect(view, SIGNAL(ItemTextSca(double)), propertiesPalette, SLOT(setTScale(double)));
 
2756
        connect(view, SIGNAL(ItemTextScaV(double)), propertiesPalette, SLOT(setTScaleV(double)));
 
2757
        connect(view, SIGNAL(ItemTextBase(double)), propertiesPalette, SLOT(setTBase(double)));
 
2758
        connect(view, SIGNAL(ItemTextShadow(double, double )), propertiesPalette, SLOT(setShadowOffs(double, double )));
 
2759
        connect(view, SIGNAL(ItemTextUnderline(double, double)), propertiesPalette, SLOT(setUnderline(double, double)));
 
2760
        connect(view, SIGNAL(ItemTextStrike(double, double)), propertiesPalette, SLOT(setStrike(double, double)));
 
2761
        connect(view, SIGNAL(ItemTextOutline(double)), propertiesPalette, SLOT(setOutlineW(double)));
2594
2762
        connect(view, SIGNAL(ItemTextStil(int)), this, SLOT(setStilvalue(int)));
2595
2763
        connect(view, SIGNAL(ItemTextAbs(int)), this, SLOT(setAbsValue(int)));
2596
 
        connect(view, SIGNAL(ItemTextFarben(QString, QString, int, int)), propertiesPalette, SLOT(setActFarben(QString, QString, int, int)));
 
2764
        connect(view, SIGNAL(ItemTextFarben(QString, QString, double, double)), propertiesPalette, SLOT(setActFarben(QString, QString, double, double)));
2597
2765
        connect(view, SIGNAL(HasTextSel()), this, SLOT(EnableTxEdit()));
2598
2766
        connect(view, SIGNAL(HasNoTextSel()), this, SLOT(DisableTxEdit()));
2599
2767
        connect(view, SIGNAL(CopyItem()), this, SLOT(slotEditCopy()));
2600
2768
        connect(view, SIGNAL(CutItem()), this, SLOT(slotEditCut()));
2601
2769
        connect(view, SIGNAL(LoadPic()), this, SLOT(slotGetContent()));
 
2770
        connect(view, SIGNAL(StatusPic()), this, SLOT(StatusPic()));
2602
2771
        connect(view, SIGNAL(AppendText()), this, SLOT(slotFileAppend()));
2603
2772
        connect(view, SIGNAL(AnnotProps()), this, SLOT(ModifyAnnot()));
2604
2773
        //connect(view, SIGNAL(EditGuides()), this, SLOT(ManageGuides()));
2605
2774
        connect(view, SIGNAL(LoadElem(QString, double ,double, bool, bool, ScribusDoc *, ScribusView*)), this, SLOT(slotElemRead(QString, double, double, bool, bool, ScribusDoc *, ScribusView*)));
2606
2775
        connect(view, SIGNAL(AddBM(PageItem *)), this, SLOT(AddBookMark(PageItem *)));
2607
2776
        connect(view, SIGNAL(DelBM(PageItem *)), this, SLOT(DelBookMark(PageItem *)));
2608
 
        connect(view, SIGNAL(RasterPic(bool)), this, SLOT(HaveRaster(bool)));
2609
2777
        connect(view, SIGNAL(DoGroup()), this, SLOT(GroupObj()));
2610
 
        connect(view, SIGNAL(EndNodeEdit()), this, SLOT(ToggleFrameEdit()));
 
2778
//      connect(view, SIGNAL(EndNodeEdit()), this, SLOT(ToggleFrameEdit()));
2611
2779
        connect(view, SIGNAL(LevelChanged(uint )), propertiesPalette, SLOT(setLevel(uint)));
2612
2780
        connect(view, SIGNAL(callGimp()), this, SLOT(callImageEditor()));
2613
2781
}
2614
2782
 
2615
 
void ScribusMainWindow::HaveNewSel(int Nr)
 
2783
void ScribusMainWindow::HaveNewSel(int SelectedType)
2616
2784
{
 
2785
        bool isRaster = false;
2617
2786
        PageItem *currItem = NULL;
2618
 
        if (Nr != -1)
 
2787
        const uint docSelectionCount=doc->m_Selection->count();
 
2788
        if (SelectedType != -1)
2619
2789
        {
2620
 
                if (doc->m_Selection->count() != 0)
 
2790
                if (docSelectionCount != 0)
2621
2791
                {
2622
 
                        uint lowestItem = 999999;
2623
 
                        for (uint a=0; a<doc->m_Selection->count(); ++a)
 
2792
                        PageItem *lowestItem = doc->m_Selection->itemAt(0);
 
2793
                        for (uint a=0; a < docSelectionCount; ++a)
2624
2794
                        {
2625
2795
                                currItem = doc->m_Selection->itemAt(a);
2626
 
                                lowestItem = QMIN(lowestItem, currItem->ItemNr);
 
2796
                                if (currItem->ItemNr < lowestItem->ItemNr)
 
2797
                                        lowestItem = currItem;
2627
2798
                        }
2628
 
                        currItem = doc->Items->at(lowestItem);
 
2799
                        currItem = lowestItem;
 
2800
                        if ((docSelectionCount == 1) && currItem && currItem->asImageFrame())
 
2801
                                isRaster = currItem->isRaster;
2629
2802
//                      doc->m_Selection->removeItem(currItem);
2630
2803
//                      doc->m_Selection->prependItem(currItem);
2631
2804
//                      currItem = doc->m_Selection->itemAt(0);
2632
 
                        if (!currItem)
2633
 
                                Nr=-1;
 
2805
                        assert(currItem);
 
2806
//                      if (!currItem)
 
2807
//                              SelectedType=-1;
2634
2808
                }
2635
2809
                else
2636
 
                        Nr = -1;
2637
 
        }
 
2810
                        SelectedType = -1;
 
2811
        }
 
2812
        else if (docSelectionCount > 0)
 
2813
        {
 
2814
                currItem = doc->m_Selection->itemAt(0);
 
2815
        }
 
2816
        assert (docSelectionCount == 0 || currItem != NULL); // help coverity analysis
 
2817
 
2638
2818
        actionManager->disconnectNewSelectionActions();
2639
 
        scrActions["editDeselectAll"]->setEnabled(Nr!=-1);
 
2819
        scrActions["editSelectAllOnLayer"]->setEnabled(true);
 
2820
        scrActions["editDeselectAll"]->setEnabled(SelectedType != -1);
2640
2821
        scrActions["itemDetachTextFromPath"]->setEnabled(false);
2641
2822
        charPalette->setEnabled(false, 0);
2642
 
        scrActions["itemUpdateImage"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail);
2643
 
        scrActions["itemAdjustFrameToImage"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail && !currItem->isTableItem);
2644
 
        scrActions["itemExtendedImageProperties"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail && currItem->pixm.imgInfo.valid);
2645
 
        scrMenuMgr->setMenuEnabled("ItemPreviewSettings", Nr==PageItem::ImageFrame);
2646
 
        scrActions["itemImageIsVisible"]->setEnabled(Nr==PageItem::ImageFrame);
2647
 
        scrActions["itemPreviewLow"]->setEnabled(Nr==PageItem::ImageFrame);
2648
 
        scrActions["itemPreviewNormal"]->setEnabled(Nr==PageItem::ImageFrame);
2649
 
        scrActions["itemPreviewFull"]->setEnabled(Nr==PageItem::ImageFrame);
2650
 
        scrActions["styleImageEffects"]->setEnabled(Nr==PageItem::ImageFrame);
2651
 
        scrActions["editCopyContents"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail);
2652
 
        scrActions["editPasteContents"]->setEnabled(Nr==PageItem::ImageFrame);
2653
 
        scrActions["editPasteContentsAbs"]->setEnabled(Nr==PageItem::ImageFrame);
2654
 
        scrActions["editEditWithImageEditor"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail && currItem->isRaster);
2655
 
        if (Nr!=PageItem::ImageFrame)
 
2823
        scrActions["itemUpdateImage"]->setEnabled(SelectedType==PageItem::ImageFrame && (currItem->PictureIsAvailable || currItem->asLatexFrame()));
 
2824
        scrActions["itemAdjustFrameToImage"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && !currItem->isTableItem);
 
2825
        scrActions["itemAdjustImageToFrame"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
 
2826
        scrActions["itemExtendedImageProperties"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && currItem->pixm.imgInfo.valid);
 
2827
        scrMenuMgr->setMenuEnabled("ItemPreviewSettings", SelectedType==PageItem::ImageFrame);
 
2828
        scrActions["itemImageIsVisible"]->setEnabled(SelectedType==PageItem::ImageFrame);
 
2829
        scrActions["itemPreviewLow"]->setEnabled(SelectedType==PageItem::ImageFrame);
 
2830
        scrActions["itemPreviewNormal"]->setEnabled(SelectedType==PageItem::ImageFrame);
 
2831
        scrActions["itemPreviewFull"]->setEnabled(SelectedType==PageItem::ImageFrame);
 
2832
        scrActions["styleImageEffects"]->setEnabled(SelectedType==PageItem::ImageFrame && isRaster);
 
2833
        scrActions["editCopyContents"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
 
2834
        scrActions["editPasteContents"]->setEnabled(SelectedType==PageItem::ImageFrame);
 
2835
        scrActions["editPasteContentsAbs"]->setEnabled(SelectedType==PageItem::ImageFrame);
 
2836
        scrActions["editEditWithImageEditor"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && currItem->isRaster);
 
2837
        scrActions["editEditRenderSource"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem && currItem->asLatexFrame());
 
2838
        if (SelectedType!=PageItem::ImageFrame)
2656
2839
        {
2657
 
                scrActions["itemImageIsVisible"]->setOn(false);
2658
 
                scrActions["itemPreviewLow"]->setOn(false);
2659
 
                scrActions["itemPreviewNormal"]->setOn(false);
2660
 
                scrActions["itemPreviewFull"]->setOn(false);
 
2840
                scrActions["itemImageIsVisible"]->setChecked(false);
 
2841
                scrActions["itemPreviewLow"]->setChecked(false);
 
2842
                scrActions["itemPreviewNormal"]->setChecked(false);
 
2843
                scrActions["itemPreviewFull"]->setChecked(false);
2661
2844
        }
2662
 
        if ((Nr==-1) || (Nr!=-1 && !currItem->asTextFrame()))
 
2845
        if ((SelectedType==-1) || (SelectedType!=-1 && !currItem->asTextFrame()))
2663
2846
                enableTextActions(&scrActions, false);
2664
2847
        scrActions["insertSampleText"]->setEnabled(false);
2665
2848
 
2666
2849
        view->horizRuler->ItemPosValid = false;
2667
 
        view->horizRuler->repaint();
2668
 
        switch (Nr)
 
2850
        view->horizRuler->update();
 
2851
        switch (SelectedType)
2669
2852
        {
2670
2853
        case -1: // None
2671
2854
                scrActions["fileImportText"]->setEnabled(false);
2674
2857
                scrActions["fileImportAppendText"]->setEnabled(false);
2675
2858
                scrActions["fileExportText"]->setEnabled(false);
2676
2859
                scrMenuMgr->setMenuEnabled("Item", false);
2677
 
                scrMenuMgr->setMenuEnabled("ItemShapes", false);
 
2860
                //scrMenuMgr->setMenuEnabled("ItemShapes", false);
2678
2861
                scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
 
2862
                scrMenuMgr->setMenuEnabled("EditContents", false);
2679
2863
                scrActions["itemConvertToBezierCurve"]->setEnabled(false);
2680
2864
                scrActions["itemConvertToImageFrame"]->setEnabled(false);
2681
2865
                scrActions["itemConvertToOutlines"]->setEnabled(false);
2715
2899
                scrActions["extrasHyphenateText"]->setEnabled(false);
2716
2900
                scrActions["extrasDeHyphenateText"]->setEnabled(false);
2717
2901
                scrMenuMgr->setMenuEnabled("Item", true);
2718
 
                scrMenuMgr->setMenuEnabled("ItemShapes", !(currItem->isTableItem && currItem->isSingleSel));
 
2902
                //scrMenuMgr->setMenuEnabled("ItemShapes", !(currItem->isTableItem && currItem->isSingleSel));
2719
2903
                scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
2720
2904
                scrActions["itemConvertToBezierCurve"]->setEnabled(false);
2721
2905
                scrActions["itemConvertToImageFrame"]->setEnabled(false);
2728
2912
                scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
2729
2913
                scrActions["toolsRotate"]->setEnabled(true);
2730
2914
                scrActions["toolsCopyProperties"]->setEnabled(true);
2731
 
                scrActions["itemImageIsVisible"]->setOn(currItem->imageShown());
2732
 
                scrActions["itemPreviewLow"]->setOn(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewLow"]->actionInt());
2733
 
                scrActions["itemPreviewNormal"]->setOn(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewNormal"]->actionInt());
2734
 
                scrActions["itemPreviewFull"]->setOn(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewFull"]->actionInt());
 
2915
                scrActions["itemImageIsVisible"]->setChecked(currItem->imageShown());
 
2916
                scrActions["itemPreviewLow"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewLow"]->actionInt());
 
2917
                scrActions["itemPreviewNormal"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewNormal"]->actionInt());
 
2918
                scrActions["itemPreviewFull"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewFull"]->actionInt());
2735
2919
 
2736
2920
                break;
2737
2921
        case PageItem::TextFrame: //Text Frame
2738
 
                FontSub->RebuildList(doc, currItem->isAnnotation());
2739
2922
                propertiesPalette->Fonts->RebuildList(doc, currItem->isAnnotation());
2740
2923
                scrActions["fileImportText"]->setEnabled(true);
2741
2924
                scrActions["fileImportText2"]->setEnabled(true);
2750
2933
                scrActions["extrasHyphenateText"]->setEnabled(currItem->itemText.length() != 0);
2751
2934
                scrActions["extrasDeHyphenateText"]->setEnabled(currItem->itemText.length() != 0);
2752
2935
                scrMenuMgr->setMenuEnabled("Item", true);
2753
 
                scrMenuMgr->setMenuEnabled("ItemShapes", !(currItem->isTableItem && currItem->isSingleSel));
 
2936
                //scrMenuMgr->setMenuEnabled("ItemShapes", !(currItem->isTableItem && currItem->isSingleSel));
2754
2937
                scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
2755
2938
                scrActions["itemConvertToBezierCurve"]->setEnabled(false);
2756
2939
                scrActions["itemConvertToImageFrame"]->setEnabled(doc->appMode != modeEdit);
2789
2972
                {
2790
2973
                        setTBvals(currItem);
2791
2974
                        scrActions["editSelectAll"]->setEnabled(true);
 
2975
                        scrActions["editSelectAllOnLayer"]->setEnabled(false);
2792
2976
                        charPalette->setEnabled(true, currItem);
2793
2977
                        if (currItem->asTextFrame())
2794
2978
                                enableTextActions(&scrActions, true, currItem->currentStyle().charStyle().font().scName());
2813
2997
                                view->horizRuler->Revers = false;
2814
2998
                        view->horizRuler->ItemPosValid = true;
2815
2999
                        view->horizRuler->TabValues = currItem->currentStyle().tabValues();
2816
 
                        view->horizRuler->repaint();
 
3000
                        view->horizRuler->update();
2817
3001
                }
2818
3002
                else
2819
3003
                {
2838
3022
 
2839
3023
                break;
2840
3024
        case PageItem::PathText: //Path Text
2841
 
                FontSub->RebuildList(doc, currItem->isAnnotation());
2842
3025
                propertiesPalette->Fonts->RebuildList(doc, currItem->isAnnotation());
2843
3026
                scrActions["fileImportText"]->setEnabled(true);
2844
3027
                scrActions["fileImportText2"]->setEnabled(true);
2852
3035
                scrActions["extrasHyphenateText"]->setEnabled(false);
2853
3036
                scrActions["extrasDeHyphenateText"]->setEnabled(false);
2854
3037
                scrMenuMgr->setMenuEnabled("Item", true);
2855
 
                scrMenuMgr->setMenuEnabled("ItemShapes", false);
 
3038
                //scrMenuMgr->setMenuEnabled("ItemShapes", false);
2856
3039
                scrActions["itemDetachTextFromPath"]->setEnabled(true);
2857
3040
                scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
2858
3041
                scrActions["itemConvertToBezierCurve"]->setEnabled(false);
2901
3084
                scrActions["extrasHyphenateText"]->setEnabled(false);
2902
3085
                scrActions["extrasDeHyphenateText"]->setEnabled(false);
2903
3086
                scrMenuMgr->setMenuEnabled("Item", true);
2904
 
                if (Nr == 6) //Polygon
 
3087
                if (SelectedType == 6) //Polygon
2905
3088
                {
2906
 
                        scrMenuMgr->setMenuEnabled("ItemShapes", true);
2907
3089
                        scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
2908
3090
                        scrActions["itemConvertToBezierCurve"]->setEnabled(doc->appMode != modeEdit);
2909
3091
                        scrActions["itemConvertToImageFrame"]->setEnabled(doc->appMode != modeEdit);
2911
3093
                        scrActions["itemConvertToPolygon"]->setEnabled(false);
2912
3094
                        scrActions["itemConvertToTextFrame"]->setEnabled(doc->appMode != modeEdit);
2913
3095
                }
 
3096
                else if (SelectedType == 7) //Polyline
 
3097
                {
 
3098
                        scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
 
3099
                        scrActions["itemConvertToBezierCurve"]->setEnabled(false);
 
3100
                        scrActions["itemConvertToImageFrame"]->setEnabled(false);
 
3101
                        scrActions["itemConvertToOutlines"]->setEnabled(false);
 
3102
                        scrActions["itemConvertToPolygon"]->setEnabled(doc->appMode != modeEdit);
 
3103
                        scrActions["itemConvertToTextFrame"]->setEnabled(false);
 
3104
                }
 
3105
                else if (SelectedType == 5) // Line
 
3106
                {
 
3107
                        scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
 
3108
                        scrActions["itemConvertToBezierCurve"]->setEnabled(true);
 
3109
                        scrActions["itemConvertToImageFrame"]->setEnabled(false);
 
3110
                        scrActions["itemConvertToOutlines"]->setEnabled(false);
 
3111
                        scrActions["itemConvertToPolygon"]->setEnabled(false);
 
3112
                        scrActions["itemConvertToTextFrame"]->setEnabled(false);
 
3113
                }
2914
3114
                scrActions["toolsEditContents"]->setEnabled(false);
2915
3115
                scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
2916
3116
                scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
2917
3117
                scrActions["toolsLinkTextFrame"]->setEnabled(false);
2918
 
//              if (Nr != 5)
 
3118
//              if (SelectedType != 5)
2919
3119
                        scrActions["toolsRotate"]->setEnabled(true);
2920
3120
//              else
2921
3121
//                      scrActions["toolsRotate"]->setEnabled(false);
2922
3122
                scrActions["toolsCopyProperties"]->setEnabled(true);
2923
3123
                break;
2924
3124
        }
2925
 
        doc->CurrentSel = Nr;
2926
 
        rebuildStyleMenu(Nr);
2927
 
        propertiesPalette->RotationGroup->setButton(doc->RotMode);
2928
 
        uint docSelectionCount=doc->m_Selection->count();
 
3125
        doc->CurrentSel = SelectedType;
 
3126
        propertiesPalette->RotationGroup->setCheckedId(doc->RotMode);
2929
3127
        if (docSelectionCount > 1)
2930
3128
        {
2931
 
                scrActions["itemConvertToBezierCurve"]->setEnabled(false);
2932
 
                scrActions["itemConvertToImageFrame"]->setEnabled(false);
2933
 
                //scrActions["itemConvertToOutlines"]->setEnabled(false);
2934
 
                scrActions["itemConvertToPolygon"]->setEnabled(false);
2935
 
                scrActions["itemConvertToTextFrame"]->setEnabled(false);
 
3129
                if (!doc->m_Selection->itemsAreSameType())
 
3130
                {
 
3131
                        scrActions["itemConvertToBezierCurve"]->setEnabled(false);
 
3132
                        scrActions["itemConvertToImageFrame"]->setEnabled(false);
 
3133
                        //scrActions["itemConvertToOutlines"]->setEnabled(false);
 
3134
                        scrActions["itemConvertToPolygon"]->setEnabled(false);
 
3135
                        scrActions["itemConvertToTextFrame"]->setEnabled(false);
 
3136
                }
2936
3137
                scrActions["editSearchReplace"]->setEnabled(false);
2937
3138
 
2938
3139
                bool hPoly = false;
2940
3141
                int firstElem = -1;
2941
3142
                if (currItem->Groups.count() != 0)
2942
3143
                        firstElem = currItem->Groups.top();
2943
 
                for (uint bx=0; bx<docSelectionCount; ++bx)
 
3144
                for (uint bx=0; bx < docSelectionCount; ++bx)
2944
3145
                {
2945
3146
                        PageItem* bxi=doc->m_Selection->itemAt(bx);
2946
3147
                        if ((bxi->asPolygon()) || (bxi->asPolyLine()))
2957
3158
                scrActions["itemCombinePolygons"]->setEnabled(hPoly);
2958
3159
                if (docSelectionCount == 2)
2959
3160
                {
 
3161
                        //CB swap bx around if currItem is not at 0 index from the lastItem loop at start of havenewsel
2960
3162
                        PageItem* bx=doc->m_Selection->itemAt(1);
 
3163
                        if (currItem==bx)
 
3164
                                bx=doc->m_Selection->itemAt(0);
 
3165
 
2961
3166
                        if ((currItem->asTextFrame() && (bx->asPolygon() || bx->asPolyLine())) || (bx->asTextFrame() && (currItem->asPolygon() || currItem->asPolyLine())))
2962
3167
                        {
2963
3168
                                if ((currItem->nextInChain() == 0) && (currItem->prevInChain() == 0) && (bx->nextInChain() == 0) && (bx->prevInChain() == 0) && (currItem->Groups.count() == 0) && (bx->Groups.count() == 0))
2990
3195
                }
2991
3196
                if (currItem->locked())
2992
3197
                {
2993
 
                        scrMenuMgr->setMenuEnabled("ItemShapes", false);
 
3198
                        //scrMenuMgr->setMenuEnabled("ItemShapes", false);
2994
3199
                        scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
2995
3200
                        scrActions["itemConvertToBezierCurve"]->setEnabled(false);
2996
3201
                        scrActions["itemConvertToImageFrame"]->setEnabled(false);
3025
3230
                        scrActions["itemSendToScrapbook"]->setEnabled(setter);
3026
3231
                        scrActions["itemSendToPattern"]->setEnabled(setter);
3027
3232
                }
3028
 
                scrActions["itemLock"]->setOn(currItem->locked());
3029
 
                scrActions["itemLockSize"]->setOn(currItem->sizeLocked());
3030
 
                scrActions["itemPrintingEnabled"]->setOn(currItem->printEnabled());
 
3233
                scrActions["itemLock"]->setChecked(currItem->locked());
 
3234
                scrActions["itemLockSize"]->setChecked(currItem->sizeLocked());
 
3235
                scrActions["itemPrintingEnabled"]->setChecked(currItem->printEnabled());
3031
3236
        }
3032
3237
 
3033
 
        //propertiesPalette->NewSel(Nr);
3034
 
        if (Nr != -1)
 
3238
        //propertiesPalette->NewSel(SelectedType);
 
3239
        if (SelectedType != -1)
3035
3240
        {
3036
3241
                //propertiesPalette->SetCurItem(currItem);
3037
3242
                outlinePalette->slotShowSelect(currItem->OwnPage, currItem->ItemNr);
3038
 
                if (currItem->FrameType == 0)
3039
 
                        SCustom->setPixmap(SCustom->getIconPixmap(0));
3040
 
                if (currItem->FrameType == 1)
3041
 
                        SCustom->setPixmap(SCustom->getIconPixmap(1));
3042
 
                if (currItem->FrameType > 3)
3043
 
                        SCustom->setPixmap(SCustom->getIconPixmap(currItem->FrameType-2));
3044
3243
                actionManager->connectNewSelectionActions(view, doc);
3045
 
//              propertiesPalette->NewSel(Nr);
 
3244
//              propertiesPalette->NewSel(SelectedType);
3046
3245
        }
3047
3246
        else
3048
 
                propertiesPalette->NewSel(Nr);
3049
 
}
 
3247
                propertiesPalette->NewSel(SelectedType);
3050
3248
 
3051
 
void ScribusMainWindow::rebuildStyleMenu(int itemType)
3052
 
{
3053
 
        scrMenuMgr->clearMenu("Style");
3054
 
        int iT=itemType;
3055
 
        if (!HaveDoc)
3056
 
                iT=-1;
3057
 
        if (iT != -1)
 
3249
        PluginManager& pluginManager(PluginManager::instance());
 
3250
        QStringList pluginNames(pluginManager.pluginNames(false));
 
3251
        ScPlugin* plugin;
 
3252
        ScActionPlugin* ixplug;
 
3253
        ScrAction* pluginAction = 0;
 
3254
        QString pName;
 
3255
        for (int i = 0; i < pluginNames.count(); ++i)
3058
3256
        {
3059
 
                if (doc->m_Selection->count() == 0)
3060
 
                        iT = -1;
3061
 
                else
 
3257
                pName = pluginNames.at(i);
 
3258
                plugin = pluginManager.getPlugin(pName, true);
 
3259
                Q_ASSERT(plugin); // all the returned names should represent loaded plugins
 
3260
                if (plugin->inherits("ScActionPlugin"))
3062
3261
                {
3063
 
                        PageItem *currItem = doc->m_Selection->itemAt(0);
3064
 
                        if (!currItem)
3065
 
                                iT=-1;
 
3262
                        ixplug = dynamic_cast<ScActionPlugin*>(plugin);
 
3263
                        Q_ASSERT(ixplug);
 
3264
                        ScActionPlugin::ActionInfo ai(ixplug->actionInfo());
 
3265
                        pluginAction = ScCore->primaryMainWindow()->scrActions[ai.name];
 
3266
                        if (pluginAction != 0)
 
3267
                                pluginAction->setEnabled(ixplug->handleSelection(doc, SelectedType));
3066
3268
                }
3067
3269
        }
3068
 
        if (iT==PageItem::TextFrame || iT==PageItem::PathText)
3069
 
        {
3070
 
                scrMenuMgr->addMenuToMenu("Font","Style");
3071
 
                scrMenuMgr->addMenuToMenu("FontSize","Style");
3072
 
                scrMenuMgr->addMenuToMenu("TypeEffects","Style");
3073
 
                scrMenuMgr->addMenuToMenu("Alignment","Style");
3074
 
                scrMenuMgr->addMenuToMenu("Color","Style");
3075
 
                scrMenuMgr->addMenuToMenu("Shade","Style");
3076
 
                if (itemType==PageItem::TextFrame)
3077
 
                        scrMenuMgr->addMenuItem(scrActions["styleTabulators"], "Style");
3078
 
                scrMenuMgr->setMenuEnabled("Style", true);
3079
 
        }
3080
 
        else
3081
 
                scrMenuMgr->setMenuEnabled("Style", false);
3082
3270
}
3083
3271
 
3084
3272
void ScribusMainWindow::slotDocCh(bool /*reb*/)
3100
3288
                if (doc->hasName)
3101
3289
                        scrActions["fileRevert"]->setEnabled(true);
3102
3290
 
3103
 
                bool setter = doc->Pages->count() > 1 ? true : false;
3104
 
                scrActions["pageDelete"]->setEnabled(setter);
3105
 
                scrActions["pageMove"]->setEnabled(setter);
 
3291
                bool multiPages = doc->Pages->count() > 1;
 
3292
                scrActions["pageDelete"]->setEnabled(multiPages);
 
3293
                scrActions["pageMove"]->setEnabled(multiPages);
3106
3294
        }
3107
3295
 
3108
 
        ActWin->setMenuStatus(0, scrActions["fileSave"]->isEnabled());
3109
 
        ActWin->setMenuStatus(1, scrActions["fileClose"]->isEnabled());
3110
 
        ActWin->setMenuStatus(2, scrActions["fileSave"]->isEnabled());
3111
 
        ActWin->setMenuStatus(3, scrActions["fileSaveAs"]->isEnabled());
3112
3296
        if (outlinePalette->isVisible())
3113
3297
                outlinePalette->BuildTree();
 
3298
        // Give plugins a chance to react on changes in the current document
 
3299
        PluginManager& pluginManager(PluginManager::instance());
 
3300
        QStringList pluginNames(pluginManager.pluginNames(false));
 
3301
        ScPlugin* plugin;
 
3302
        QString pName;
 
3303
        for (int i = 0; i < pluginNames.count(); ++i)
 
3304
        {
 
3305
                pName = pluginNames.at(i);
 
3306
                plugin = pluginManager.getPlugin(pName, true);
 
3307
                Q_ASSERT(plugin); // all the returned names should represent loaded plugins
 
3308
                plugin->changedDoc(doc);
 
3309
        }
3114
3310
}
3115
3311
 
3116
3312
void ScribusMainWindow::updateRecent(QString fn)
3117
3313
{
3118
 
        if (RecentDocs.findIndex(fn) == -1)
 
3314
        if (RecentDocs.indexOf(fn) == -1)
3119
3315
        {
3120
3316
                RecentDocs.prepend(fn);
3121
3317
                ScCore->fileWatcher->addFile(fn);
3122
3318
        }
3123
3319
        else
3124
3320
        {
3125
 
                RecentDocs.remove(fn);
 
3321
                RecentDocs.removeAll(fn);
3126
3322
                RecentDocs.prepend(fn);
3127
3323
        }
3128
3324
        rebuildRecentFileMenu();
3130
3326
 
3131
3327
void ScribusMainWindow::removeRecent(QString fn)
3132
3328
{
3133
 
        if (RecentDocs.findIndex(fn) != -1)
 
3329
        if (RecentDocs.indexOf(fn) != -1)
3134
3330
        {
3135
 
                RecentDocs.remove(fn);
 
3331
                RecentDocs.removeAll(fn);
3136
3332
                ScCore->fileWatcher->removeFile(fn);
3137
3333
        }
3138
3334
        rebuildRecentFileMenu();
3151
3347
 
3152
3348
void ScribusMainWindow::rebuildRecentFileMenu()
3153
3349
{
3154
 
        for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrRecentFileActions.begin(); it!=scrRecentFileActions.end(); ++it )
 
3350
        for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrRecentFileActions.begin(); it!=scrRecentFileActions.end(); ++it )
3155
3351
                scrMenuMgr->removeMenuItem((*it), recentFileMenuName);
3156
3352
 
3157
3353
        scrRecentFileActions.clear();
3158
 
        uint max = QMIN(prefsManager->appPrefs.RecentDCount, RecentDocs.count());
 
3354
        uint max = qMin(prefsManager->appPrefs.RecentDCount, RecentDocs.count());
3159
3355
        QString strippedName, localName;
3160
3356
        for (uint m = 0; m < max; ++m)
3161
3357
        {
3162
3358
                strippedName=RecentDocs[m];
3163
3359
                strippedName.remove(QDir::separator());
3164
3360
                localName=QDir::convertSeparators(RecentDocs[m]);
3165
 
                scrRecentFileActions.insert(strippedName, new ScrAction(ScrAction::RecentFile, QIconSet(), QString("&%1 %2").arg(m+1).arg(localName), QKeySequence(), this, strippedName,0,0.0,RecentDocs[m]));
3166
 
                connect( scrRecentFileActions[strippedName], SIGNAL(activatedData(QString)), this, SLOT(loadRecent(QString)) );
 
3361
                scrRecentFileActions.insert(strippedName, new ScrAction(ScrAction::RecentFile, QPixmap(), QPixmap(), QString("&%1 %2").arg(m+1).arg(localName), QKeySequence(), this, 0,0.0,RecentDocs[m]));
 
3362
                connect( scrRecentFileActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(loadRecent(QString)) );
3167
3363
                scrMenuMgr->addMenuItem(scrRecentFileActions[strippedName], recentFileMenuName);
3168
3364
        }
3169
3365
}
3170
3366
 
3171
3367
void ScribusMainWindow::rebuildRecentPasteMenu()
3172
3368
{
3173
 
        for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrRecentPasteActions.begin(); it!=scrRecentPasteActions.end(); ++it )
 
3369
        for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrRecentPasteActions.begin(); it!=scrRecentPasteActions.end(); ++it )
3174
3370
                scrMenuMgr->removeMenuItem((*it), recentPasteMenuName);
3175
3371
 
3176
3372
        scrRecentPasteActions.clear();
3177
 
        uint max = QMIN(static_cast<uint>(prefsManager->appPrefs.numScrapbookCopies), scrapbookPalette->tempBView->objectMap.count());
 
3373
        int max = qMin(prefsManager->appPrefs.numScrapbookCopies, scrapbookPalette->tempBView->objectMap.count());
3178
3374
        if (max > 0)
3179
3375
        {
3180
3376
                QMap<QString,BibView::Elem>::Iterator it;
3181
3377
                it = scrapbookPalette->tempBView->objectMap.end();
3182
3378
                it--;
3183
3379
                QString strippedName;
3184
 
                for (uint m = 0; m < max; ++m)
 
3380
                for (int m = 0; m < max; ++m)
3185
3381
                {
3186
3382
                        strippedName = it.key();
3187
 
                        QPixmap pm = it.data().Preview;
3188
 
                        scrRecentPasteActions.insert(strippedName, new ScrAction(ScrAction::RecentPaste, QIconSet(pm), QString("&%1 %2").arg(m+1).arg(strippedName), QKeySequence(), this, strippedName,0,0.0,it.key()));
3189
 
                        connect( scrRecentPasteActions[strippedName], SIGNAL(activatedData(QString)), this, SLOT(pasteRecent(QString)) );
 
3383
                        QPixmap pm = it.value().Preview;
 
3384
                        scrRecentPasteActions.insert(strippedName, new ScrAction(ScrAction::RecentPaste, pm, QPixmap(), QString("&%1 %2").arg(m+1).arg(strippedName), QKeySequence(), this, 0,0.0,it.key()));
 
3385
                        connect( scrRecentPasteActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(pasteRecent(QString)) );
3190
3386
                        scrMenuMgr->addMenuItem(scrRecentPasteActions[strippedName], recentPasteMenuName);
3191
3387
                        it--;
3192
3388
                }
3193
3389
        }
3194
3390
}
3195
3391
 
 
3392
void ScribusMainWindow::pasteFromScrapbook(QString fn)
 
3393
{
 
3394
        doPasteRecent(scrapbookPalette->activeBView->objectMap[fn].Data);
 
3395
}
 
3396
 
3196
3397
void ScribusMainWindow::pasteRecent(QString fn)
3197
3398
{
3198
 
        QString data = scrapbookPalette->tempBView->objectMap[fn].Data;
3199
 
        QFileInfo fi(data);
3200
 
        if (fi.extension(true).lower() == "sml")
3201
 
        {
3202
 
                QString f = "";
3203
 
                loadText(data, &f);
3204
 
                StencilReader *pre = new StencilReader();
3205
 
                data = pre->createObjects(f);
3206
 
                delete pre;
3207
 
        }
3208
 
        else if (fi.extension(true).lower() == "shape")
3209
 
        {
3210
 
                QString f = "";
3211
 
                loadText(data, &f);
3212
 
                StencilReader *pre = new StencilReader();
3213
 
                data = pre->createShape(f);
3214
 
                delete pre;
3215
 
        }
3216
 
        else if (fi.extension(true).lower() == "sce")
3217
 
        {
3218
 
                QString f = "";
3219
 
                loadText(data, &f);
3220
 
                data = f;
3221
 
        }
3222
 
        view->Deselect(true);
3223
 
        uint ac = doc->Items->count();
3224
 
        bool savedAlignGrid = doc->useRaster;
3225
 
        bool savedAlignGuides = doc->SnapGuides;
3226
 
        doc->useRaster = false;
3227
 
        doc->SnapGuides = false;
3228
 
        slotElemRead(data, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
3229
 
        doc->useRaster = savedAlignGrid;
3230
 
        doc->SnapGuides = savedAlignGuides;
3231
 
        for (uint as = ac; as < doc->Items->count(); ++as)
3232
 
        {
3233
 
                PageItem* currItem = doc->Items->at(as);
3234
 
                if (currItem->isBookmark)
3235
 
                        AddBookMark(currItem);
3236
 
                view->SelectItemNr(as);
3237
 
        }
 
3399
        doPasteRecent(scrapbookPalette->tempBView->objectMap[fn].Data);
 
3400
}
 
3401
 
 
3402
void ScribusMainWindow::doPasteRecent(QString data)
 
3403
{
 
3404
        if (HaveDoc)
 
3405
        {
 
3406
                UndoTransaction pasteAction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
 
3407
                QFileInfo fi(data);
 
3408
                if (fi.suffix().toLower() == "sml")
 
3409
                {
 
3410
                        QString f = "";
 
3411
                        loadText(data, &f);
 
3412
                        StencilReader *pre = new StencilReader();
 
3413
                        data = pre->createObjects(f);
 
3414
                        delete pre;
 
3415
                }
 
3416
                else if (fi.suffix().toLower() == "shape")
 
3417
                {
 
3418
                        QString f = "";
 
3419
                        loadText(data, &f);
 
3420
                        StencilReader *pre = new StencilReader();
 
3421
                        data = pre->createShape(f);
 
3422
                        delete pre;
 
3423
                }
 
3424
                view->Deselect(true);
 
3425
                uint ac = doc->Items->count();
 
3426
                bool savedAlignGrid = doc->useRaster;
 
3427
                bool savedAlignGuides = doc->SnapGuides;
 
3428
                doc->useRaster = false;
 
3429
                doc->SnapGuides = false;
 
3430
                if (fi.suffix().toLower() == "sce")
 
3431
                        slotElemRead(data, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), true, true, doc, view);
 
3432
                else
 
3433
                        slotElemRead(data, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 
3434
                doc->useRaster = savedAlignGrid;
 
3435
                doc->SnapGuides = savedAlignGuides;
 
3436
                Selection tmpSelection(this, false);
 
3437
                tmpSelection.copy(*doc->m_Selection, true);
 
3438
                for (int as = ac; as < doc->Items->count(); ++as)
 
3439
                {
 
3440
                        PageItem* currItem = doc->Items->at(as);
 
3441
                        doc->setRedrawBounding(currItem);
 
3442
                        tmpSelection.addItem(currItem, true);
 
3443
                        if (currItem->isBookmark)
 
3444
                                AddBookMark(currItem);
 
3445
                }
 
3446
                doc->m_Selection->copy(tmpSelection, false);
 
3447
                pasteAction.commit();
3238
3448
                slotDocCh(false);
 
3449
                doc->regionsChanged()->update(QRectF());
 
3450
        }
 
3451
}
 
3452
 
 
3453
void ScribusMainWindow::importVectorFile()
 
3454
{
 
3455
        QString fileName = "";
 
3456
        QString formats = "";
 
3457
        QString allFormats = tr("All Supported Formats")+" (";
 
3458
        int fmtCode = FORMATID_ODGIMPORT;
 
3459
        const FileFormat *fmt = LoadSavePlugin::getFormatById(fmtCode);
 
3460
        while (fmt != 0)
 
3461
        {
 
3462
                if (fmt->load)
 
3463
                {
 
3464
                        formats += fmt->filter + ";;";
 
3465
                        int an = fmt->filter.indexOf("(");
 
3466
                        int en = fmt->filter.indexOf(")");
 
3467
                        while (an != -1)
 
3468
                        {
 
3469
                                allFormats += fmt->filter.mid(an+1, en-an-1)+" ";
 
3470
                                an = fmt->filter.indexOf("(", en);
 
3471
                                en = fmt->filter.indexOf(")", an);
 
3472
                        }
 
3473
                }
 
3474
                fmtCode++;
 
3475
                fmt = LoadSavePlugin::getFormatById(fmtCode);
 
3476
        }
 
3477
        allFormats += "*.sce *.SCE ";
 
3478
        allFormats += "*.shape *.SHAPE ";
 
3479
        allFormats += "*.sml *.SML);;";
 
3480
        formats += "Scribus Objects (*.sce *.SCE);;";
 
3481
        formats += "Dia Shapes (*.shape *.SHAPE);;";
 
3482
        formats += "Kivio Stencils (*.sml *.SML)";
 
3483
        allFormats += formats;
 
3484
        PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
 
3485
        QString wdir = dirs->get("pastefile", ".");
 
3486
        CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdHidePreviewCheckBox | fdExistingFiles);
 
3487
        if (dia.exec() == QDialog::Accepted)
 
3488
                fileName = dia.selectedFile();
 
3489
        else
 
3490
                return;
 
3491
        if (!fileName.isEmpty())
 
3492
        {
 
3493
                PrefsManager::instance()->prefsFile->getContext("dirs")->set("pastefile", fileName.left(fileName.lastIndexOf("/")));
 
3494
                QFileInfo fi(fileName);
 
3495
                QString suffix = fi.suffix().toLower();
 
3496
                if ((suffix == "sce") || (suffix == "sml") || (suffix == "shape"))
 
3497
                {
 
3498
                        QList<QUrl> urls;
 
3499
                        QMimeData* md = new QMimeData();
 
3500
                        urls.append( QUrl::fromLocalFile(fileName) );
 
3501
                        md->setUrls(urls);
 
3502
                        QDrag* dr = new QDrag(this);
 
3503
                        dr->setMimeData(md);
 
3504
                        const QPixmap& dragCursor = loadIcon("DragPix.xpm");
 
3505
                        dr->setDragCursor(dragCursor, Qt::CopyAction);
 
3506
                        dr->setDragCursor(dragCursor, Qt::MoveAction);
 
3507
                        dr->setDragCursor(dragCursor, Qt::LinkAction);
 
3508
                        dr->exec();
 
3509
                }
 
3510
                else
 
3511
                {
 
3512
                        FileLoader *fileLoader = new FileLoader(fileName);
 
3513
                        int testResult = fileLoader->TestFile();
 
3514
                        delete fileLoader;
 
3515
                        if ((testResult != -1) && (testResult >= FORMATID_ODGIMPORT))
 
3516
                        {
 
3517
                                const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
 
3518
                                if( fmt )
 
3519
                                        fmt->loadFile(fileName, LoadSavePlugin::lfUseCurrentPage|LoadSavePlugin::lfInteractive);
 
3520
                        }
 
3521
                }
 
3522
        }
3239
3523
}
3240
3524
 
3241
3525
void ScribusMainWindow::rebuildLayersList()
3242
3526
{
3243
3527
        if (HaveDoc)
3244
3528
        {
3245
 
                for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it0 = scrLayersActions.begin(); it0 != scrLayersActions.end(); ++it0 )
 
3529
                for( QMap<QString, QPointer<ScrAction> >::Iterator it0 = scrLayersActions.begin(); it0 != scrLayersActions.end(); ++it0 )
3246
3530
                        scrMenuMgr->removeMenuItem((*it0), layerMenuName);
3247
3531
                scrLayersActions.clear();
3248
 
                QValueList<Layer>::iterator it;
 
3532
                ScLayers::iterator it;
3249
3533
                if (doc->Layers.count()!= 0)
3250
3534
                {
3251
3535
                        for (it = doc->Layers.begin(); it != doc->Layers.end(); ++it)
3252
3536
                        {
3253
 
                                scrLayersActions.insert(QString("%1").arg((*it).LNr), new ScrAction( ScrAction::Layer, QIconSet(), (*it).Name, QKeySequence(), this, (*it).Name, (*it).LNr));
 
3537
                                scrLayersActions.insert(QString("%1").arg((*it).LNr), new ScrAction( ScrAction::Layer, QPixmap(), QPixmap(), (*it).Name, QKeySequence(), this, (*it).LNr));
3254
3538
                                scrLayersActions[QString("%1").arg((*it).LNr)]->setToggleAction(true);
 
3539
                                QPixmap pm(20,15);
 
3540
                                pm.fill((*it).markerColor);
 
3541
                                scrLayersActions[QString("%1").arg((*it).LNr)]->setIcon(pm);
3255
3542
                        }
3256
3543
                }
3257
3544
                int currActiveLayer=doc->activeLayer();
3265
3552
                        }
3266
3553
                }
3267
3554
                Q_ASSERT(found);
3268
 
                scrLayersActions[QString("%1").arg((*it).LNr)]->setOn(true);
 
3555
                scrLayersActions[QString("%1").arg((*it).LNr)]->setChecked(true);
3269
3556
 
3270
 
                for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=scrLayersActions.end(); ++it )
 
3557
                for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=scrLayersActions.end(); ++it )
3271
3558
                {
3272
3559
                        scrMenuMgr->addMenuItem((*it), layerMenuName);
3273
 
                        connect( (*it), SIGNAL(activatedData(int)), doc, SLOT(itemSelection_SendToLayer(int)) );
 
3560
                        connect( (*it), SIGNAL(triggeredData(int)), doc, SLOT(itemSelection_SendToLayer(int)) );
3274
3561
                }
3275
3562
        }
3276
3563
}
3279
3566
{
3280
3567
        if (HaveDoc)
3281
3568
        {
3282
 
                QMap<QString, QGuardedPtr<ScrAction> >::Iterator itend=scrLayersActions.end();
3283
 
                for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=itend; ++it )
 
3569
                QMap<QString, QPointer<ScrAction> >::Iterator itend=scrLayersActions.end();
 
3570
                for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=itend; ++it )
3284
3571
                {
3285
 
                        disconnect( (*it), SIGNAL(activatedData(int)), 0, 0 );
3286
 
                        (*it)->setOn(false);
 
3572
                        disconnect( (*it), SIGNAL(triggeredData(int)), 0, 0 );
 
3573
                        (*it)->setChecked(false);
3287
3574
                }
3288
3575
                if (doc->m_Selection->count()>0 && doc->m_Selection->itemAt(0))
3289
 
                        scrLayersActions[QString("%1").arg(doc->m_Selection->itemAt(0)->LayerNr)]->setOn(true);
3290
 
                for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=itend; ++it )
3291
 
                        connect( (*it), SIGNAL(activatedData(int)), doc, SLOT(itemSelection_SendToLayer(int)) );
 
3576
                        scrLayersActions[QString("%1").arg(doc->m_Selection->itemAt(0)->LayerNr)]->setChecked(true);
 
3577
                for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=itend; ++it )
 
3578
                        connect( (*it), SIGNAL(triggeredData(int)), doc, SLOT(itemSelection_SendToLayer(int)) );
3292
3579
        }
3293
3580
}
3294
3581
 
3307
3594
        if (fileName.isEmpty())
3308
3595
                // User cancelled
3309
3596
                return false;
3310
 
        docContext->set("docsopen", fileName.left(fileName.findRev("/")));
 
3597
        docContext->set("docsopen", fileName.left(fileName.lastIndexOf("/")));
3311
3598
        return loadDoc(fileName);
3312
3599
}
3313
3600
 
3319
3606
        if (dia->exec())
3320
3607
        {
3321
3608
                mainWindowStatusLabel->setText( tr("Importing Pages..."));
3322
 
                qApp->setOverrideCursor(QCursor(waitCursor), true);
 
3609
                qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
3323
3610
                std::vector<int> pageNs;
3324
3611
                parsePagesString(dia->getPageNumbers(), &pageNs, dia->getPageCounter());
3325
3612
                int startPage=0, nrToImport=pageNs.size();
3344
3631
                else
3345
3632
                {
3346
3633
                        startPage = doc->currentPage()->pageNr() + 1;
3347
 
                        if (static_cast<uint>(nrToImport) > (doc->DocPages.count() - doc->currentPage()->pageNr()))
 
3634
                        if (nrToImport > (doc->DocPages.count() - doc->currentPage()->pageNr()))
3348
3635
                        {
3349
 
                                qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
3636
                                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
3350
3637
                                int scmReturn=ScMessageBox::information(this, tr("Import Page(s)"), "<qt>" +
3351
3638
                                QObject::tr("<p>You are trying to import more pages than there are available in the current document counting from the active page.</p>Choose one of the following:<br>"
3352
3639
                                "<ul><li><b>Create</b> missing pages</li>"
3370
3657
                                                mainWindowStatusLabel->setText("");
3371
3658
                                                break;
3372
3659
                                }
3373
 
                                qApp->setOverrideCursor(QCursor(waitCursor), true);
 
3660
                                qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
3374
3661
                        }
3375
3662
                }
3376
3663
                if (doIt)
3378
3665
                        if (nrToImport > 0)
3379
3666
                        {
3380
3667
                                mainWindowProgressBar->reset();
3381
 
                                mainWindowProgressBar->setTotalSteps(nrToImport);
 
3668
                                mainWindowProgressBar->setMaximum(nrToImport);
3382
3669
                                int counter = startPage;
3383
3670
                                for (int i = 0; i < nrToImport; ++i)
3384
3671
                                {
3385
3672
                                        view->GotoPa(counter);
3386
3673
                                        loadPage(dia->getFromDoc(), pageNs[i] - 1, false);
3387
3674
                                        counter++;
3388
 
                                        mainWindowProgressBar->setProgress(i + 1);
 
3675
                                        mainWindowProgressBar->setValue(i + 1);
3389
3676
                                }
3390
3677
                                view->GotoPa(startPage);
3391
3678
                                mainWindowProgressBar->reset();
3397
3684
                                doIt = false;
3398
3685
                        }
3399
3686
                }
3400
 
                qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
3687
                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
3401
3688
                ret = doIt;
3402
3689
        }
3403
3690
        delete dia;
3435
3722
                        PageItem *ite = doc->Items->at(i);
3436
3723
//                      if ((docItemsCount - oldItemsCount) > 1)
3437
3724
//                              ite->Groups.push(doc->GroupCounter);
3438
 
                        if (ite->locked())
3439
 
                                ite->setLocked(false);
 
3725
//      #5386: allow locked imported items to remain locked
 
3726
//                      if (ite->locked())
 
3727
//                              ite->setLocked(false);
3440
3728
                        if ((ite->asTextFrame()) && (ite->isBookmark))
3441
 
                                bookmarkPalette->BView->AddPageItem(ite);
 
3729
                                AddBookMark(ite);
3442
3730
                }
3443
3731
//              if ((docItemsCount - oldItemsCount) > 1)
3444
3732
//                      doc->GroupCounter++;
3473
3761
        QFileInfo fi(fileName);
3474
3762
        if (!fi.exists())
3475
3763
                return false;
3476
 
        qApp->setOverrideCursor(QCursor(waitCursor), true);
 
3764
        qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
3477
3765
        if (HaveDoc)
3478
3766
                outlinePalette->buildReopenVals();
3479
3767
        bool ret = false;
3487
3775
        uint windowCount=windows.count();
3488
3776
        for ( uint i = 0; i < windowCount; ++i )
3489
3777
        {
3490
 
                if (windows.at(i)->caption() == platfName)
 
3778
                if (windows.at(i)->windowTitle() == platfName)
3491
3779
                {
3492
3780
                        found = true;
3493
3781
                        id = i;
3501
3789
        }
3502
3790
        if (!fileName.isEmpty())
3503
3791
        {
3504
 
                QString FName = fi.absFilePath();
3505
 
                QString DPath = fi.dirPath(true);
3506
 
                // Necessary on win32 platform for setCurrent() to succeed
3507
 
                // if document is located at drive root
3508
 
                if( !DPath.endsWith("/") )
3509
 
                        DPath += "/";
3510
 
                QDir::setCurrent(DPath);
 
3792
                QString FName = fi.absoluteFilePath();
3511
3793
                FileLoader *fileLoader = new FileLoader(FName);
3512
3794
                int testResult=fileLoader->TestFile();
3513
3795
                if (testResult == -1)
3514
3796
                {
3515
3797
                        delete fileLoader;
3516
 
                        qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
3798
                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
3517
3799
                        QMessageBox::critical(this, tr("Fatal Error"), "<qt>"+ tr("File %1 is not in an acceptable format").arg(FName)+"</qt>", CommonStrings::tr_OK);
3518
3800
                        return false;
3519
3801
                }
3520
3802
                bool is12doc=false;
3521
3803
                if (testResult == 0)
3522
3804
                {
3523
 
                        qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
3805
                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
3524
3806
                        //Scribus 1.3.x warning, remove at a later stage
3525
3807
                        is12doc=true;
3526
3808
                }
3527
3809
 
3528
 
                ScCore->getCMSProfilesDir(fi.dirPath(true)+"/", false, false);
3529
 
                prefsManager->appPrefs.AvailFonts.AddScalableFonts(fi.dirPath(true)+"/", FName);
 
3810
                ScCore->getCMSProfilesDir(fi.absolutePath()+"/", false, false);
 
3811
                prefsManager->appPrefs.AvailFonts.AddScalableFonts(fi.absolutePath()+"/", FName);
3530
3812
                prefsManager->appPrefs.AvailFonts.updateFontMap();
3531
3813
                doc=new ScribusDoc();
3532
3814
                doc->is12doc=is12doc;
3546
3828
                alignDistributePalette->setDoc(doc);
3547
3829
                ActWin = w;
3548
3830
                doc->WinHan = w;
3549
 
                w->setCentralWidget(view);
 
3831
                wsp->addWindow(w);
3550
3832
                w->setUpdatesEnabled(false);
3551
3833
                view->updatesOn(false);
3552
3834
                doc->SoftProofing = false;
3561
3843
                {
3562
3844
                        view->close();
3563
3845
                        delete fileLoader;
3564
 
                        delete view;
 
3846
//                      delete view;
3565
3847
                        delete doc;
3566
3848
                        delete w;
3567
3849
                        view=NULL;
3568
3850
                        doc=NULL;
3569
3851
                        ScriptRunning = false;
3570
 
                        qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
3852
                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
3571
3853
                        mainWindowStatusLabel->setText("");
3572
3854
                        mainWindowProgressBar->reset();
3573
3855
                        ActWin = NULL;
3578
3860
                }
3579
3861
                outlinePalette->setDoc(doc);
3580
3862
                fileLoader->informReplacementFonts();
3581
 
                view->unitSwitcher->setCurrentText(unitGetStrFromIndex(doc->unitIndex()));
 
3863
                setCurrentComboItem(view->unitSwitcher, unitGetStrFromIndex(doc->unitIndex()));
3582
3864
                view->unitChange();
3583
3865
                ScriptRunning = false;
3584
3866
                view->Deselect(true);
3588
3870
                if (doc->checkerProfiles.count() == 0)
3589
3871
                {
3590
3872
                        prefsManager->initDefaultCheckerPrefs(&doc->checkerProfiles);
3591
 
                        doc->curCheckProfile = tr("PostScript");
 
3873
                        doc->curCheckProfile = CommonStrings::PostScript;
3592
3874
                }
3593
3875
                if (doc->PDF_Options.LPISettings.count() == 0)
3594
3876
                {
3595
3877
                        struct LPIData lpo;
3596
 
                        lpo.Frequency = 75;
3597
 
                        lpo.SpotFunc = 2;
 
3878
                        lpo.Frequency = 133;
 
3879
                        lpo.SpotFunc = 3;
3598
3880
                        lpo.Angle = 105;
3599
3881
                        doc->PDF_Options.LPISettings.insert("Cyan", lpo);
3600
3882
                        lpo.Angle = 75;
3604
3886
                        lpo.Angle = 45;
3605
3887
                        doc->PDF_Options.LPISettings.insert("Black", lpo);
3606
3888
                }
 
3889
 
3607
3890
                //connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
3608
3891
                if (!doc->CMSSettings.CMSinUse)
3609
3892
                        doc->HasCMS = false;
3677
3960
                        }
3678
3961
                        if (cmsWarning)
3679
3962
                        {
3680
 
                                qApp->setOverrideCursor(QCursor(arrowCursor), true);
3681
 
                                QString mess = tr("Some ICC profiles used by this document are not installed:")+"\n\n";
3682
 
                                for (uint m = 0; m < missing.count(); ++m)
 
3963
                                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 
3964
                                QString mess = tr("Some color profiles used by this document are not installed:")+"\n\n";
 
3965
                                for (int m = 0; m < missing.count(); ++m)
3683
3966
                                {
3684
3967
                                        mess += missing[m] + tr(" was replaced by: ")+replacement[m]+"\n";
3685
3968
                                }
3686
3969
                                QMessageBox::warning(this, CommonStrings::trWarning, mess, 1, 0, 0);
3687
3970
                        }
3688
3971
                        doc->SoftProofing = doc->CMSSettings.SoftProofOn;
3689
 
                        doc->Gamut = doc->CMSSettings.GamutCheck;
 
3972
                        doc->Gamut        = doc->CMSSettings.GamutCheck;
3690
3973
                        doc->IntentColors = doc->CMSSettings.DefaultIntentColors;
3691
3974
                        doc->IntentImages = doc->CMSSettings.DefaultIntentImages;
3692
3975
                        if (doc->OpenCMSProfiles(ScCore->InputProfiles, ScCore->InputProfilesCMYK, ScCore->MonitorProfiles, ScCore->PrinterProfiles))
3694
3977
                                doc->HasCMS = true;
3695
3978
                                doc->PDF_Options.SComp = doc->CMSSettings.ComponentsInput2;
3696
3979
                        }
 
3980
                        else
 
3981
                        {
 
3982
                                doc->SetDefaultCMSParams();
 
3983
                                doc->HasCMS = false;
 
3984
                        }
3697
3985
                        if (doc->HasCMS)
3698
3986
                        {
3699
3987
                                recalcColors();
3732
4020
                doc->setMasterPageMode(true);
3733
4021
                doc->reformPages();
3734
4022
                doc->setLoading(false);
3735
 
                for (uint azz=0; azz<doc->MasterItems.count(); ++azz)
 
4023
                for (int azz=0; azz<doc->MasterItems.count(); ++azz)
3736
4024
                {
3737
4025
                        PageItem *ite = doc->MasterItems.at(azz);
3738
4026
                        // TODO fix that for Groups on Masterpages
3739
4027
//                      if (ite->Groups.count() != 0)
3740
4028
//                              view->GroupOnPage(ite);
3741
 
//                      qDebug(QString("load M: %1 %2 %3").arg(azz).arg((uint)ite).arg(ite->itemType()));
 
4029
//                      qDebug() << QString("load M: %1 %2 %3").arg(azz).arg((uint)ite).arg(ite->itemType());
3742
4030
                        ite->layout();
3743
4031
                }
3744
4032
//              RestoreBookMarks();
3745
4033
                doc->setMasterPageMode(false);
3746
 
                uint docItemsCount=doc->Items->count();
3747
 
                for (uint azz=0; azz<docItemsCount; ++azz)
 
4034
                int docItemsCount=doc->Items->count();
 
4035
                for (int azz=0; azz<docItemsCount; ++azz)
3748
4036
                {
3749
4037
                        PageItem *ite = doc->Items->at(azz);
3750
4038
                        //CB dont need this as we get it from the loading page in 1.2.x docs. 1.3.x items have this anyway.
3755
4043
                                ite->OwnPage = doc->OnPage(ite);
3756
4044
                        */
3757
4045
                        //view->setRedrawBounding(ite);
3758
 
//                      qDebug(QString("load D: %1 %2 %3").arg(azz).arg((uint)ite).arg(ite->itemType()));
 
4046
//                      qDebug() << QString("load D: %1 %2 %3").arg(azz).arg((uint)ite).arg(ite->itemType());
3759
4047
                        if(ite->nextInChain() == NULL)
3760
4048
                                ite->layout();
3761
4049
/*                      if (doc->OldBM)
3769
4057
                                        bookmarkPalette->BView->ChangeItem(ite->BMnr, ite->ItemNr);
3770
4058
                        } */
3771
4059
                }
3772
 
                for (uint azz=0; azz<doc->FrameItems.count(); ++azz)
 
4060
                for (int azz=0; azz<doc->FrameItems.count(); ++azz)
3773
4061
                {
3774
4062
                        PageItem *ite = doc->FrameItems.at(azz);
3775
 
//                      qDebug(QString("load F: %1 %2 %3").arg(azz).arg((uint)ite).arg(ite->itemType()));
 
4063
//                      qDebug() << QString("load F: %1 %2 %3").arg(azz).arg((uint)ite).arg(ite->itemType());
3776
4064
                        if(ite->nextInChain() == NULL)
3777
4065
                                ite->layout();
3778
4066
                }
3784
4072
                mainWindowStatusLabel->setText( tr("Ready"));
3785
4073
                ret = true;
3786
4074
                doc->setLoading(true);
3787
 
                for (uint p = 0; p < doc->DocPages.count(); ++p)
 
4075
                for (int p = 0; p < doc->DocPages.count(); ++p)
3788
4076
                {
3789
4077
                        Apply_MasterPage(doc->DocPages.at(p)->MPageNam, p, false);
3790
4078
                }
 
4079
                view->reformPages(false);
3791
4080
                doc->setLoading(false);
3792
4081
/*              if (fileLoader->FileType > FORMATID_NATIVEIMPORTEND)
3793
4082
                {
3805
4094
                view->show();
3806
4095
                newActWin(w);
3807
4096
                doc->setCurrentPage(doc->DocPages.at(0));
3808
 
                view->cmsToolbarButton->setOn(doc->HasCMS);
3809
 
                view->slotDoZoom();
 
4097
                view->cmsToolbarButton->setChecked(doc->HasCMS);
 
4098
                view->zoom();
3810
4099
                view->GotoPage(0);
3811
4100
                connect(wsp, SIGNAL(windowActivated(QWidget *)), this, SLOT(newActWin(QWidget *)));
3812
4101
                connect(w, SIGNAL(AutoSaved()), this, SLOT(slotAutoSaved()));
3813
4102
                connect(ScCore->fileWatcher, SIGNAL(fileChanged(QString )), doc, SLOT(updatePict(QString)));
3814
4103
                connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString )), doc, SLOT(removePict(QString)));
 
4104
                connect(ScCore->fileWatcher, SIGNAL(dirChanged(QString )), doc, SLOT(updatePictDir(QString )));
3815
4105
                connect(undoManager, SIGNAL(undoRedoDone()), view, SLOT(DrawNew()));
3816
4106
                doc->connectDocSignals();
3817
4107
                if (doc->AutoSave)
3827
4117
        }
3828
4118
        undoManager->switchStack(doc->DocName);
3829
4119
        pagePalette->Rebuild();
3830
 
        qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
4120
        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
3831
4121
        undoManager->setUndoEnabled(true);
3832
4122
        doc->setModified(false);
3833
4123
        return ret;
3850
4140
                PageItem *currItem = doc->m_Selection->itemAt(0);
3851
4141
                if (currItem->itemType() == PageItem::ImageFrame)
3852
4142
                {
3853
 
                        QString formatD(setupImageFormats());
 
4143
                        QString formatD(FormatsManager::instance()->fileDialogFormatList(FormatsManager::IMAGESIMGFRAME));
 
4144
 
3854
4145
                        QString docDir = ".";
3855
4146
                        QString prefsDocDir=prefsManager->documentDir();
3856
4147
                        if (!prefsDocDir.isEmpty())
3860
4151
                        QString fileName = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles);
3861
4152
                        if (!fileName.isEmpty())
3862
4153
                        {
3863
 
                                prefsManager->prefsFile->getContext("dirs")->set("images", fileName.left(fileName.findRev("/")));
 
4154
                                prefsManager->prefsFile->getContext("dirs")->set("images", fileName.left(fileName.lastIndexOf("/")));
3864
4155
                                currItem->EmProfile = "";
3865
4156
                                currItem->pixm.imgInfo.isRequest = false;
3866
4157
                                currItem->UseEmbedded = true;
3867
4158
                                currItem->IProfile = doc->CMSSettings.DefaultImageRGBProfile;
3868
4159
                                currItem->IRender = doc->CMSSettings.DefaultIntentImages;
3869
 
                                qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
3870
 
                                qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
 
4160
                                qApp->changeOverrideCursor( QCursor(Qt::WaitCursor) );
 
4161
                                qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
3871
4162
                                doc->LoadPict(fileName, currItem->ItemNr, false, true);
3872
4163
                                //view->AdjustPictScale(currItem, false);
3873
4164
                                //false was ignored anyway
3874
4165
                                currItem->AdjustPictScale();
3875
 
                                propertiesPalette->setLvalue(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset());
3876
 
                                qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
3877
 
                                qApp->restoreOverrideCursor();
 
4166
                                propertiesPalette->setScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset());
 
4167
                                qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
3878
4168
                                view->DrawNew();
3879
4169
                                propertiesPalette->updateColorList();
3880
4170
                                propertiesPalette->ShowCMS();
 
4171
                                currItem->emitAllToGUI();
3881
4172
                        }
3882
4173
                }
3883
4174
                if (currItem->asTextFrame())
3888
4179
                        {
3889
4180
                                if (currItem->itemText.length() != 0)
3890
4181
                                {
3891
 
                                        int t = ScMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"), QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
 
4182
                                        int t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to clear all your text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
3892
4183
                                        if (t == QMessageBox::No)
3893
4184
                                                return;
3894
4185
                                }
3897
4188
                        delete gt;
3898
4189
                        if (doc->docHyphenator->AutoCheck)
3899
4190
                                doc->docHyphenator->slotHyphenate(currItem);
3900
 
                        for (uint a = 0; a < doc->Items->count(); ++a)
 
4191
                        for (int a = 0; a < doc->Items->count(); ++a)
3901
4192
                        {
3902
4193
                                if (doc->Items->at(a)->isBookmark)
3903
4194
                                        bookmarkPalette->BView->ChangeText(doc->Items->at(a));
3904
4195
                        }
3905
4196
                        view->DrawNew();
3906
4197
                        slotDocCh();
 
4198
                        styleManager->setDoc(doc);
3907
4199
                }
3908
4200
        }
3909
4201
}
3921
4213
        ScGTPluginManager::instance()->run();
3922
4214
        if (doc->docHyphenator->AutoCheck)
3923
4215
                doc->docHyphenator->slotHyphenate(currItem);
3924
 
        for (uint a = 0; a < doc->Items->count(); ++a)
 
4216
        for (int a = 0; a < doc->Items->count(); ++a)
3925
4217
        {
3926
4218
                if (doc->Items->at(a)->isBookmark)
3927
4219
                        bookmarkPalette->BView->ChangeText(doc->Items->at(a));
3930
4222
        slotDocCh();
3931
4223
}
3932
4224
 
 
4225
void ScribusMainWindow::slotGetClipboardImage()
 
4226
{
 
4227
        if ((doc->m_Selection->count() != 0) && (QApplication::clipboard()->mimeData()->hasImage()))
 
4228
        {
 
4229
                PageItem *currItem = doc->m_Selection->itemAt(0);
 
4230
                if (currItem->itemType() == PageItem::ImageFrame)
 
4231
                {
 
4232
                        int t = QMessageBox::Yes;
 
4233
                        if (currItem->PictureIsAvailable)
 
4234
                                t = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to replace your existing image?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
 
4235
                        if (t == QMessageBox::Yes)
 
4236
                        {
 
4237
                                QImage img = QApplication::clipboard()->image();
 
4238
                                if (!img.isNull())
 
4239
                                {
 
4240
                                        currItem->EmProfile = "";
 
4241
                                        currItem->pixm.imgInfo.isRequest = false;
 
4242
                                        currItem->UseEmbedded = true;
 
4243
                                        currItem->IProfile = doc->CMSSettings.DefaultImageRGBProfile;
 
4244
                                        currItem->IRender = doc->CMSSettings.DefaultIntentImages;
 
4245
                                        qApp->changeOverrideCursor( QCursor(Qt::WaitCursor) );
 
4246
                                        qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
 
4247
                                        currItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX.png");
 
4248
                                        currItem->tempImageFile->open();
 
4249
                                        QString fileName = getLongPathName(currItem->tempImageFile->fileName());
 
4250
                                        currItem->tempImageFile->close();
 
4251
                                        currItem->isInlineImage = true;
 
4252
                                        currItem->Pfile = fileName;
 
4253
                                        img.save(fileName, "PNG");
 
4254
                                        doc->LoadPict(fileName, currItem->ItemNr, false, true);
 
4255
                                        currItem->AdjustPictScale();
 
4256
                                        propertiesPalette->setScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset());
 
4257
                                        qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
 
4258
                                        view->DrawNew();
 
4259
                                        propertiesPalette->updateColorList();
 
4260
                                        propertiesPalette->ShowCMS();
 
4261
                                        currItem->emitAllToGUI();
 
4262
                                }
 
4263
                        }
 
4264
                }
 
4265
        }
 
4266
}
 
4267
 
3933
4268
void ScribusMainWindow::slotFileAppend()
3934
4269
{
3935
4270
        if (doc->m_Selection->count() != 0)
3954
4289
{
3955
4290
        if ((doc->hasName) && (doc->isModified()) && (!doc->masterPageMode()))
3956
4291
        {
3957
 
                int t = ScMessageBox::warning(this, CommonStrings::trWarning, "<qt>" +
 
4292
                int t = QMessageBox::warning(this, CommonStrings::trWarning, "<qt>" +
3958
4293
                                                                 QObject::tr("The changes to your document have not been saved and you have requested to revert them. Do you wish to continue?") + "</qt>",
3959
 
                                                                 QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
 
4294
                                                                 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
3960
4295
                if (t == QMessageBox::No)
3961
4296
                        return;
3962
4297
 
3963
4298
                QString fn(doc->DocName);
3964
 
                QFileInfo fi(fn);
3965
 
                QDir::setCurrent(fi.dirPath(true));
3966
4299
                doc->setModified(false);
3967
4300
                if (doc==storyEditor->currentDocument())
3968
4301
                        storyEditor->close();
3987
4320
                if (doc->is12doc && !warningVersion(this))
3988
4321
                        return false;
3989
4322
 
3990
 
                QString fn(doc->DocName);
3991
 
                ret = DoFileSave(fn);
3992
 
                if (!ret)
3993
 
                        QMessageBox::warning(this, CommonStrings::trWarning, tr("Cannot write the file: \n%1").arg(fn), CommonStrings::tr_OK);
 
4323
                QString fn(doc->DocName), savedFileName;
 
4324
                ret = DoFileSave(fn, &savedFileName);
 
4325
                if (!ret && !savedFileName.isEmpty())
 
4326
                        QMessageBox::warning(this, CommonStrings::trWarning, tr("Your document was saved to a temporary file and could not be moved: \n%1").arg( QDir::toNativeSeparators(savedFileName) ), CommonStrings::tr_OK);
 
4327
                else if (!ret)
 
4328
                        QMessageBox::warning(this, CommonStrings::trWarning, tr("Cannot write the file: \n%1").arg( QDir::toNativeSeparators(fn) ), CommonStrings::tr_OK);
3994
4329
        }
3995
4330
        else
3996
4331
                ret = slotFileSaveAs();
4013
4348
        if (doc->hasName)
4014
4349
        {
4015
4350
                QFileInfo fi(doc->DocName);
4016
 
                wdir = fi.dirPath();
4017
 
                fna = fi.dirPath()+"/"+fi.baseName()+".sla";
 
4351
                wdir = QDir::fromNativeSeparators( fi.path() );
 
4352
                fna  = QDir::fromNativeSeparators( fi.path()+"/"+fi.baseName()+".sla" );
4018
4353
        }
4019
4354
        else
4020
4355
        {
4023
4358
                        wdir = docContext->get("save_as", prefsDocDir);
4024
4359
                else
4025
4360
                        wdir = docContext->get("save_as", ".");
 
4361
                wdir = QDir::fromNativeSeparators( wdir );
4026
4362
                if (wdir.right(1) != "/")
4027
4363
                        fna = wdir + "/";
4028
4364
                else
4031
4367
        }
4032
4368
        QString fileSpec=tr("Documents (*.sla *.sla.gz);;All Files (*)");
4033
4369
//      bool setter=true;
4034
 
        int optionFlags = fdCompressFile;
 
4370
        int optionFlags = fdCompressFile | fdHidePreviewCheckBox;
4035
4371
        QString fn = CFileDialog( wdir, tr("Save As"), fileSpec, fna, optionFlags);
4036
4372
        if (!fn.isEmpty())
4037
4373
        {
4038
 
                docContext->set("save_as", fn.left(fn.findRev("/")));
 
4374
                docContext->set("save_as", fn.left(fn.lastIndexOf("/")));
4039
4375
                if ((fn.endsWith(".sla")) || (fn.endsWith(".sla.gz")))
4040
4376
                        fna = fn;
4041
4377
                else
4042
4378
                        fna = fn+".sla";
4043
4379
                if (overwrite(this, fna))
4044
4380
                {
4045
 
                        ret = DoFileSave(fna);
4046
 
                        if (!ret)
4047
 
                                QMessageBox::warning(this, CommonStrings::trWarning, tr("Cannot write the file: \n%1").arg(fn), CommonStrings::tr_OK);
 
4381
                        QString savedFileName;
 
4382
                        ret = DoFileSave(fna, &savedFileName);
 
4383
                        if (!ret && !savedFileName.isEmpty())
 
4384
                                QMessageBox::warning(this, CommonStrings::trWarning, tr("Your document was saved to a temporary file and could not be moved: \n%1").arg( QDir::toNativeSeparators(savedFileName) ), CommonStrings::tr_OK);
 
4385
                        else if (!ret)
 
4386
                                QMessageBox::warning(this, CommonStrings::trWarning, tr("Cannot write the file: \n%1").arg( QDir::toNativeSeparators(fn) ), CommonStrings::tr_OK);
4048
4387
                        else
4049
 
                                doc->PDF_Options.Datei = ""; // #1482 reset the pdf file name
 
4388
                                doc->PDF_Options.fileName = ""; // #1482 reset the pdf file name
4050
4389
                }
4051
4390
        }
4052
4391
        mainWindowStatusLabel->setText( tr("Ready"));
4053
4392
        return ret;
4054
4393
}
4055
4394
 
4056
 
bool ScribusMainWindow::DoFileSave(QString fn)
 
4395
bool ScribusMainWindow::DoFileSave(const QString& fileName, QString* savedFileName)
4057
4396
{
4058
4397
        ScCore->fileWatcher->forceScan();
4059
4398
        ScCore->fileWatcher->stop();
4060
4399
        doc->reorganiseFonts();
4061
 
        buildFontMenu();
4062
4400
        mainWindowStatusLabel->setText( tr("Saving..."));
4063
4401
        mainWindowProgressBar->reset();
4064
 
        bool ret=doc->save(fn);
 
4402
        bool ret=doc->save(fileName, savedFileName);
4065
4403
        qApp->processEvents();
4066
4404
        if (ret)
4067
4405
        {
4068
 
                updateActiveWindowCaption(fn);
4069
 
                undoManager->renameStack(fn);
 
4406
                updateActiveWindowCaption(fileName);
 
4407
                undoManager->renameStack(fileName);
4070
4408
//              scrActions["fileSave"]->setEnabled(false);
4071
4409
                scrActions["fileRevert"]->setEnabled(false);
4072
 
                updateRecent(fn);
 
4410
                updateRecent(fileName);
4073
4411
        }
4074
4412
        mainWindowStatusLabel->setText("");
4075
4413
        mainWindowProgressBar->reset();
4095
4433
                storyEditor->close();
4096
4434
        actionManager->disconnectNewDocActions();
4097
4435
        actionManager->disconnectNewViewActions();
4098
 
        disconnect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
 
4436
        disconnect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
 
4437
        /*CB currently unused
4099
4438
        if (doc->viewCount > 1)
4100
4439
        {
4101
4440
                --doc->viewCount;
4102
4441
                closeActiveWindowMasterPageEditor();
4103
 
                setAppMode(modeNormal);
 
4442
                slotSelect();
4104
4443
                disconnect(ScCore->fileWatcher, SIGNAL(fileChanged(QString )), doc, SLOT(updatePict(QString)));
4105
4444
                disconnect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString )), doc, SLOT(removePict(QString)));
4106
4445
                view->close();
4109
4448
                doc = NULL;
4110
4449
                ActWin = NULL;
4111
4450
                return true;
4112
 
        }
 
4451
        }*/
4113
4452
        undoManager->removeStack(doc->DocName);
4114
4453
        closeActiveWindowMasterPageEditor();
4115
 
        setAppMode(modeNormal);
 
4454
        slotSelect();
4116
4455
        doc->autoSaveTimer->stop();
 
4456
        ScCore->fileWatcher->stop();
4117
4457
        disconnect(doc->autoSaveTimer, SIGNAL(timeout()), doc->WinHan, SLOT(slotAutoSave()));
4118
4458
        disconnect(doc->WinHan, SIGNAL(AutoSaved()), this, SLOT(slotAutoSaved()));
4119
4459
        disconnect(ScCore->fileWatcher, SIGNAL(fileChanged(QString )), doc, SLOT(updatePict(QString)));
4120
4460
        disconnect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString )), doc, SLOT(removePict(QString)));
4121
 
        for (uint a = 0; a < doc->DocItems.count(); ++a)
 
4461
        disconnect(ScCore->fileWatcher, SIGNAL(dirChanged(QString )), doc, SLOT(updatePictDir(QString )));
 
4462
        for (int a = 0; a < doc->DocItems.count(); ++a)
4122
4463
        {
4123
4464
                PageItem *currItem = doc->DocItems.at(a);
4124
 
                if (currItem->PicAvail)
 
4465
                if (currItem->PictureIsAvailable)
4125
4466
                        ScCore->fileWatcher->removeFile(currItem->Pfile);
 
4467
                if ((currItem->asImageFrame()) && (!currItem->Pfile.isEmpty()))
 
4468
                {
 
4469
                        QFileInfo fi(currItem->Pfile);
 
4470
                        ScCore->fileWatcher->removeDir(fi.absolutePath());
 
4471
                }
4126
4472
        }
4127
 
        for (uint a = 0; a < doc->MasterItems.count(); ++a)
 
4473
        for (int a = 0; a < doc->MasterItems.count(); ++a)
4128
4474
        {
4129
4475
                PageItem *currItem = doc->MasterItems.at(a);
4130
 
                if (currItem->PicAvail)
 
4476
                if (currItem->PictureIsAvailable)
4131
4477
                        ScCore->fileWatcher->removeFile(currItem->Pfile);
 
4478
                if ((currItem->asImageFrame()) && (!currItem->Pfile.isEmpty()))
 
4479
                {
 
4480
                        QFileInfo fi(currItem->Pfile);
 
4481
                        ScCore->fileWatcher->removeDir(fi.absolutePath());
 
4482
                }
4132
4483
        }
4133
 
        for (uint a = 0; a < doc->FrameItems.count(); ++a)
 
4484
        for (int a = 0; a < doc->FrameItems.count(); ++a)
4134
4485
        {
4135
4486
                PageItem *currItem = doc->FrameItems.at(a);
4136
 
                if (currItem->PicAvail)
 
4487
                if (currItem->PictureIsAvailable)
4137
4488
                        ScCore->fileWatcher->removeFile(currItem->Pfile);
 
4489
                if ((currItem->asImageFrame()) && (!currItem->Pfile.isEmpty()))
 
4490
                {
 
4491
                        QFileInfo fi(currItem->Pfile);
 
4492
                        ScCore->fileWatcher->removeDir(fi.absolutePath());
 
4493
                }
4138
4494
        }
4139
4495
        QStringList patterns = doc->docPatterns.keys();
4140
 
        for (uint c = 0; c < patterns.count(); ++c)
 
4496
        for (int c = 0; c < patterns.count(); ++c)
4141
4497
        {
4142
4498
                ScPattern pa = doc->docPatterns[patterns[c]];
4143
 
                for (uint o = 0; o < pa.items.count(); o++)
 
4499
                for (int o = 0; o < pa.items.count(); o++)
4144
4500
                {
4145
4501
                        PageItem *currItem = pa.items.at(o);
4146
 
                        if (currItem->PicAvail)
 
4502
                        if (currItem->PictureIsAvailable)
4147
4503
                                ScCore->fileWatcher->removeFile(currItem->Pfile);
 
4504
                        if ((currItem->asImageFrame()) && (!currItem->Pfile.isEmpty()))
 
4505
                        {
 
4506
                                QFileInfo fi(currItem->Pfile);
 
4507
                                ScCore->fileWatcher->removeDir(fi.absolutePath());
 
4508
                        }
4148
4509
                }
4149
4510
        }
4150
4511
        if (ScCore->haveCMS())
4154
4515
        propertiesPalette->unsetDoc();
4155
4516
        pagePalette->setView(0);
4156
4517
        pagePalette->Rebuild();
4157
 
        if (doc->EditClip)
4158
 
                NoFrameEdit();
 
4518
        if (doc->appMode == modeEditClip)
 
4519
                view->requestMode(submodeEndNodeEdit);
4159
4520
        bookmarkPalette->BView->clear();
4160
4521
        bookmarkPalette->BView->NrItems = 0;
4161
4522
        bookmarkPalette->BView->First = 1;
4165
4526
        //>>
4166
4527
        if ((wsp->windowList().isEmpty()) || (wsp->windowList().count() == 1))
4167
4528
        {
 
4529
                PluginManager& pluginManager(PluginManager::instance());
 
4530
                pluginManager.enableOnlyStartupPluginActions(this);
4168
4531
                scrActions["fileDocSetup"]->setEnabled(false);
4169
4532
                scrActions["filePrint"]->setEnabled(false);
4170
4533
                scrActions["fileSave"]->setEnabled(false);
4194
4557
                scrMenuMgr->setMenuEnabled("EditPasteRecent", false);
4195
4558
                scrActions["editClearContents"]->setEnabled(false);
4196
4559
                scrActions["editSelectAll"]->setEnabled(false);
 
4560
                scrActions["editSelectAllOnLayer"]->setEnabled(false);
4197
4561
                scrActions["editDeselectAll"]->setEnabled(false);
 
4562
                scrActions["editReplaceColors"]->setEnabled(false);
4198
4563
                scrActions["editPatterns"]->setEnabled(false);
4199
4564
                scrActions["editStyles"]->setEnabled(false);
4200
4565
                scrActions["editSearchReplace"]->setEnabled(false);
4207
4572
                scrActions["extrasDeHyphenateText"]->setEnabled(false);
4208
4573
                scrMenuMgr->setMenuEnabled("View", false);
4209
4574
                //scrMenuMgr->setMenuEnabled("Windows", false);
4210
 
                scrActions["viewSnapToGuides"]->setOn(false);
4211
 
                scrActions["viewSnapToGrid"]->setOn(false);
 
4575
                scrActions["viewSnapToGuides"]->setChecked(false);
 
4576
                scrActions["viewSnapToGrid"]->setChecked(false);
4212
4577
                scrActions["viewShowRulers"]->setEnabled(false);
4213
4578
 
4214
4579
                scrMenuMgr->setMenuEnabled("Insert", false);
4215
4580
                scrActions["insertFrame"]->setEnabled(false);
4216
4581
                scrMenuMgr->setMenuEnabled("Page", false);
4217
4582
                scrMenuMgr->setMenuEnabled("Extras", false);
4218
 
                scrMenuMgr->setMenuEnabled("Style", false);
4219
4583
                scrMenuMgr->setMenuEnabled("Item", false);
4220
4584
 
4221
4585
                scrActions["toolsSelect"]->setEnabled(false);
4231
4595
                scrActions["toolsInsertBezier"]->setEnabled(false);
4232
4596
                scrActions["toolsInsertFreehandLine"]->setEnabled(false);
4233
4597
                scrActions["toolsInsertPolygon"]->setEnabled(false);
 
4598
                scrActions["toolsInsertRenderFrame"]->setEnabled(false);
4234
4599
                scrActions["toolsLinkTextFrame"]->setEnabled(false);
4235
4600
                scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
4236
4601
                scrActions["toolsMeasurements"]->setEnabled(false);
4243
4608
                scrActions["toolsPDFListBox"]->setEnabled(false);
4244
4609
                scrActions["toolsPDFAnnotText"]->setEnabled(false);
4245
4610
                scrActions["toolsPDFAnnotLink"]->setEnabled(false);
4246
 
                ColorMenC->clear();
4247
4611
                //CB dont need this until we have a doc...
4248
4612
                //propertiesPalette->Cpal->SetColors(prefsManager->colorSet());
4249
4613
                propertiesPalette->Cpal->ChooseGrad(0);
4250
4614
                mainWindowStatusLabel->setText( tr("Ready"));
4251
4615
                PrinterUsed = false;
4252
4616
        }
 
4617
        // Give plugins a chance to react on closing the document
 
4618
        PluginManager& pluginManager(PluginManager::instance());
 
4619
        QStringList pluginNames(pluginManager.pluginNames(false));
 
4620
        ScPlugin* plugin;
 
4621
        QString pName;
 
4622
        for (int i = 0; i < pluginNames.count(); ++i)
 
4623
        {
 
4624
                pName = pluginNames.at(i);
 
4625
                plugin = pluginManager.getPlugin(pName, true);
 
4626
                Q_ASSERT(plugin); // all the returned names should represent loaded plugins
 
4627
                plugin->unsetDoc();
 
4628
        }
4253
4629
        QString fName(view->Doc->DocName);
4254
4630
        view->close();
4255
 
        delete view;
 
4631
//      delete view;
 
4632
        //CB Yes, we are setting it to NULL without deleting it. ActWin(ScribusWin) owns the view
 
4633
        //due to it being the central widget and will delete it at the correct moment from its own pointer.
 
4634
        view = NULL;
4256
4635
        doc->setLoading(true);
4257
4636
        guidePalette->setDoc(0);
4258
4637
        charPalette->setDoc(0);
 
4638
        tocGenerator->setDoc(0);
 
4639
        styleManager->setDoc(0);
4259
4640
        layerPalette->ClearInhalt();
4260
4641
        docCheckerPalette->buildErrorList(0);
4261
4642
        ScCore->fileWatcher->removeFile(fName);
4262
4643
        HaveDoc--;
4263
 
        view = NULL;
4264
4644
        delete doc;
4265
4645
        doc = NULL;
4266
4646
        ActWin = NULL;
4267
 
        tocGenerator->setDoc(doc);
4268
4647
        if ( HaveDoc == 0 )
4269
4648
        {
4270
4649
                QString prefsDocDir( PrefsManager::instance()->documentDir() );
4271
4650
                if ( QDir().exists(prefsDocDir) )
4272
4651
                        QDir::setCurrent( PrefsManager::instance()->documentDir() );
4273
4652
                else
4274
 
                        QDir::setCurrent( QDir::homeDirPath() );
 
4653
                        QDir::setCurrent( QDir::homePath() );
4275
4654
        }
4276
 
        styleManager->setDoc(0);
 
4655
        ScCore->fileWatcher->start();
4277
4656
        return true;
4278
4657
}
4279
4658
 
4285
4664
                {
4286
4665
                        if (doc->checkerProfiles[doc->curCheckProfile].ignoreErrors)
4287
4666
                        {
4288
 
                                int t = ScMessageBox::warning(this, CommonStrings::trWarning,
 
4667
                                int t = QMessageBox::warning(this, CommonStrings::trWarning,
4289
4668
                                                                                        "<qt>"+ tr("Scribus has detected some errors. Consider using the Preflight Verifier to correct them")+"</qt>",
4290
 
                                                                                        tr("&Ignore"), tr("&Abort"), 0, 0, 0);
4291
 
                                if (t == 1)
 
4669
                                                                                        QMessageBox::Abort | QMessageBox::Ignore);
 
4670
                                if (t == QMessageBox::Abort)
4292
4671
                                        return;
4293
4672
                        }
4294
4673
                        else
4298
4677
                                docCheckerPalette->checkMode = CheckDocument::checkPrint;
4299
4678
                                docCheckerPalette->buildErrorList(doc);
4300
4679
                                docCheckerPalette->show();
4301
 
                                scrActions["toolsPreflightVerifier"]->setOn(true);
 
4680
                                scrActions["toolsPreflightVerifier"]->setChecked(true);
4302
4681
                                return;
4303
4682
                        }
4304
4683
                }
4314
4693
                docCheckerPalette->setIgnoreEnabled(false);
4315
4694
                docCheckerPalette->hide();
4316
4695
                docCheckerPalette->checkMode = CheckDocument::checkNULL;
4317
 
                scrActions["toolsPreflightVerifier"]->setOn(false);
 
4696
                scrActions["toolsPreflightVerifier"]->setChecked(false);
4318
4697
                disconnect(docCheckerPalette, SIGNAL(ignoreAllErrors()), this, SLOT(slotReallyPrint()));
4319
4698
        }
 
4699
        QString printError;
4320
4700
        PrintOptions options;
4321
4701
        mainWindowStatusLabel->setText( tr("Printing..."));
4322
 
        if (PrinterUsed)
4323
 
        {
4324
 
                doc->Print_Options.printer = PDef.Pname;
4325
 
                doc->Print_Options.filename = PDef.Dname;
4326
 
        }
4327
 
        else
4328
 
        {
4329
 
                doc->Print_Options.printer = "";
 
4702
        if (doc->Print_Options.firstUse)
 
4703
        {
 
4704
                doc->Print_Options.printer = QString();
4330
4705
                if (!doc->DocName.startsWith( tr("Document")))
4331
4706
                {
4332
4707
                        QFileInfo fi(doc->DocName);
4333
 
                        doc->Print_Options.filename = fi.dirPath()+"/"+fi.baseName()+".ps";
 
4708
                        doc->Print_Options.filename = fi.path()+"/"+fi.baseName()+".ps";
4334
4709
                }
4335
4710
                else
4336
4711
                {
4337
4712
                        QDir di = QDir();
4338
 
                        doc->Print_Options.filename = di.currentDirPath()+"/"+doc->DocName+".ps";
 
4713
                        doc->Print_Options.filename = di.currentPath()+"/"+doc->DocName+".ps";
4339
4714
                }
4340
4715
        }
4341
4716
        doc->Print_Options.copies = 1;
4342
4717
        ColorList usedSpots;
4343
4718
        doc->getUsedColors(usedSpots, true);
4344
4719
        QStringList spots = usedSpots.keys();
4345
 
        qDebug(QString("scribus.cpp: before print dialog color=%1 copies = %2").arg(doc->Print_Options.useColor).arg(doc->Print_Options.copies));
4346
 
        Druck *printer = new Druck(this, doc, doc->Print_Options.filename, doc->Print_Options.printer, PDef.Command, PDef.DevMode, prefsManager->appPrefs.GCRMode, spots);
 
4720
        PrintDialog *printer = new PrintDialog(this, doc, doc->Print_Options.filename, doc->Print_Options.printer, PDef.Command, doc->Print_Options.devMode, prefsManager->appPrefs.GCRMode, spots);
4347
4721
        printer->setMinMax(1, doc->Pages->count(), doc->currentPage()->pageNr()+1);
4348
4722
        printDinUse = true;
4349
4723
        connect(printer, SIGNAL(doPreview()), this, SLOT(doPrintPreview()));
4350
4724
        if (printer->exec())
4351
4725
        {
4352
 
                qDebug(QString("scribus.cpp: before print dialog color=%1 copies = %2").arg(doc->Print_Options.useColor).arg(doc->Print_Options.copies));
4353
4726
                ReOrderText(doc, view);
4354
 
                qApp->setOverrideCursor(QCursor(waitCursor), true);
 
4727
                qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
4355
4728
                doc->Print_Options.pageNumbers.clear();
4356
 
                if (printer->CurrentPage->isChecked())
4357
 
                {
 
4729
                if (printer->doPrintCurrentPage())
4358
4730
                        doc->Print_Options.pageNumbers.push_back(doc->currentPage()->pageNr()+1);
4359
 
                }
4360
4731
                else
4361
4732
                {
4362
 
                        if (printer->RadioButton1->isChecked())
 
4733
                        if (printer->doPrintAll())
4363
4734
                                parsePagesString("*", &doc->Print_Options.pageNumbers, doc->DocPages.count());
4364
4735
                        else
4365
 
                                parsePagesString(printer->pageNr->text(), &doc->Print_Options.pageNumbers, doc->DocPages.count());
 
4736
                                parsePagesString(printer->getPageString(), &doc->Print_Options.pageNumbers, doc->DocPages.count());
4366
4737
                }
4367
4738
                PrinterUsed = true;
4368
 
#ifdef _WIN32
4369
 
                SHORT shiftState = GetKeyState( VK_SHIFT );
4370
 
                bool forceGDI = ( shiftState & 0x8000 ) ? true : false;
4371
 
                if (doc->Print_Options.toFile == false)
4372
 
                {
4373
 
                        ScWinPrint winPrint;
4374
 
                        done = winPrint.print( doc, doc->Print_Options, printer->DevMode, forceGDI );
4375
 
                }
4376
 
                else
4377
 
                        done = doPrint(doc->Print_Options);
4378
 
#else
4379
 
                done = doPrint(doc->Print_Options);
4380
 
#endif
 
4739
                done = doPrint(doc->Print_Options, printError);
4381
4740
                if (!done)
4382
4741
                {
4383
 
                        qApp->setOverrideCursor(QCursor(arrowCursor), true);
4384
 
                        QMessageBox::warning(this, CommonStrings::trWarning, tr("Printing failed!"), CommonStrings::tr_OK);
 
4742
                        QString message = tr("Printing failed!");
 
4743
                        if (!printError.isEmpty())
 
4744
                                message += QString("\n%1").arg(printError);
 
4745
                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 
4746
                        QMessageBox::warning(this, CommonStrings::trWarning, message, CommonStrings::tr_OK);
4385
4747
                }
4386
4748
                else
4387
4749
                        doc->Print_Options.firstUse = false;
4388
 
                qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
4750
                getDefaultPrinter(PDef.Pname, PDef.Pname, PDef.Command);
 
4751
                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
4389
4752
        }
4390
4753
        printDinUse = false;
4391
4754
        disconnect(printer, SIGNAL(doPreview()), this, SLOT(doPrintPreview()));
4393
4756
        mainWindowStatusLabel->setText( tr("Ready"));
4394
4757
}
4395
4758
 
4396
 
bool ScribusMainWindow::doPrint(PrintOptions &options)
 
4759
bool ScribusMainWindow::doPrint(PrintOptions &options, QString& error)
4397
4760
{
4398
 
        bool retw = false;
4399
 
        QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
 
4761
        bool printDone = false;
4400
4762
        QString filename(options.filename);
4401
 
        ReallyUsed.clear();
4402
 
        doc->getUsedFonts(ReallyUsed);
4403
 
        ColorList usedColors;
4404
 
        doc->getUsedColors(usedColors);
 
4763
        if (options.toFile)
 
4764
        {
 
4765
                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 
4766
                if (!overwrite(this, filename))
 
4767
                {
 
4768
                        return true;
 
4769
                }
 
4770
                qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
 
4771
        }
4405
4772
        ScCore->fileWatcher->forceScan();
4406
4773
        ScCore->fileWatcher->stop();
4407
 
        PSLib *dd = new PSLib(options, true, prefsManager->appPrefs.AvailFonts, ReallyUsed, usedColors, false, options.useSpotColors);
4408
 
        if (dd != NULL)
4409
 
        {
4410
 
                if (!options.toFile)
4411
 
                        filename = prefsManager->preferencesLocation()+"/tmp.ps";
4412
 
                else
4413
 
                {
4414
 
                        qApp->setOverrideCursor(QCursor(arrowCursor), true);
4415
 
                        if (!overwrite(this, filename))
4416
 
                        {
4417
 
                                delete dd;
4418
 
                                ScCore->fileWatcher->start();
4419
 
                                return true;
4420
 
                        }
4421
 
                        qApp->setOverrideCursor(QCursor(waitCursor), true);
4422
 
                }
4423
 
                bool PSfile = dd->PS_set_file(filename);
4424
 
                filename = QDir::convertSeparators(filename);
4425
 
                if (PSfile)
4426
 
                {
4427
 
                        // Write the PS to a file
4428
 
                        int psCreationRetVal=dd->CreatePS(doc, options);
4429
 
                        if (psCreationRetVal!=0)
4430
 
                        {
4431
 
                                unlink(filename);
4432
 
                                if (psCreationRetVal==2)
4433
 
                                        return true;
4434
 
                                else
4435
 
                                        return false;
4436
 
                        }
4437
 
                        if (options.PSLevel != 3)
4438
 
                        {
4439
 
                                // use gs to convert our PS to a lower version
4440
 
                                QString tmp;
4441
 
                                QStringList opts;
4442
 
                                opts.append( QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(doc->pageWidth)) );
4443
 
                                opts.append( QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(doc->pageHeight)) );
4444
 
                                convertPS2PS(filename, filename + ".tmp", opts, options.PSLevel);
4445
 
                                moveFile( filename + ".tmp", filename );
4446
 
                        }
4447
 
                        if (!options.toFile)
4448
 
                        {
4449
 
                                // print and delete the PS file
4450
 
                                QString cmd;
4451
 
                                if (options.useAltPrintCommand)
4452
 
                                {
4453
 
                                        cmd = options.printerCommand + " "+filename;
4454
 
                                        system(cmd);
4455
 
                                }
4456
 
                                else
4457
 
                                {
4458
 
                                        QString cc;
4459
 
                                        cmd = "lpr -P '" + options.printer + "'";
4460
 
                                        if (options.copies > 1)
4461
 
                                                cmd += " -#" + cc.setNum(options.copies);
4462
 
                                        cmd += options.printerOptions;
4463
 
                                        cmd += " "+filename;
4464
 
                                        system(cmd);
4465
 
                                }
4466
 
// Disabled that for now, as kprinter won't work otherwise
4467
 
// leaving that file around doesn't harm, as it will be overwritten the next time.
4468
 
//                              unlink(filename);
4469
 
                        }
4470
 
                        retw = true;
4471
 
                }
4472
 
                else
4473
 
                        retw = false;
4474
 
                delete dd;
4475
 
        }
 
4774
        ScPrintEngine* prnEngine = NULL;
 
4775
#if defined(_WIN32)
 
4776
        SHORT shiftState = GetKeyState( VK_SHIFT );
 
4777
        bool  forceGDI = ( shiftState & 0x8000 ) ? true : false;
 
4778
        if (doc->Print_Options.toFile)
 
4779
                prnEngine = dynamic_cast<ScPrintEngine*>(new ScPrintEngine_PS());
 
4780
        else
 
4781
        {
 
4782
                ScPrintEngine_GDI* gdiEngine = new ScPrintEngine_GDI();
 
4783
                gdiEngine->setForceGDI( forceGDI );
 
4784
                prnEngine = dynamic_cast<ScPrintEngine*>(gdiEngine);
 
4785
        }
 
4786
#else
 
4787
        prnEngine = dynamic_cast<ScPrintEngine*>(new ScPrintEngine_PS());
 
4788
#endif
 
4789
        if (prnEngine)
 
4790
        {
 
4791
                printDone = prnEngine->print(*doc, options);
 
4792
                if (!printDone)
 
4793
                        error = prnEngine->errorMessage();
 
4794
                delete prnEngine;
 
4795
        }
 
4796
        else
 
4797
                error = tr( "Print engine initialization failed");
4476
4798
        ScCore->fileWatcher->start();
4477
 
        return retw;
 
4799
        return printDone;
4478
4800
}
4479
4801
 
4480
4802
void ScribusMainWindow::slotFileQuit()
4484
4806
        close();
4485
4807
}
4486
4808
 
4487
 
 
 
4809
/*
4488
4810
static bool hasXMLRootElem(const QString& buffer, const QString& elemtag)
4489
4811
{
4490
 
        return buffer.findRev(elemtag, 50 + elemtag.length()) >= 0;
 
4812
        return buffer.lastIndexOf(elemtag, 50 + elemtag.length()) >= 0;
4491
4813
}
4492
 
 
 
4814
*/
4493
4815
 
4494
4816
void ScribusMainWindow::slotEditCut()
4495
4817
{
4496
4818
//      int a;
4497
 
        NoFrameEdit();
 
4819
        if (HaveDoc && doc->appMode == modeEditClip)
 
4820
                view->requestMode(submodeEndNodeEdit);
4498
4821
        QString BufferI = "";
4499
4822
        uint docSelectionCount=doc->m_Selection->count();
4500
4823
        if ((HaveDoc) && (docSelectionCount != 0))
4501
4824
        {
 
4825
                UndoTransaction* activeTransaction = NULL;
4502
4826
                PageItem *currItem;
4503
4827
                for (uint i = 0; i < docSelectionCount; ++i)
4504
4828
                {
4512
4836
                if (UndoManager::undoEnabled())
4513
4837
                {
4514
4838
                        if (docSelectionCount > 1)
4515
 
                                undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Cut,"",Um::ICut);
 
4839
                                activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Cut,"",Um::ICut));
4516
4840
                        else
4517
4841
                        {
4518
4842
                                PageItem* item=doc->m_Selection->itemAt(0);
4519
 
                                undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::Cut, "", Um::ICut);
 
4843
                                activeTransaction = new UndoTransaction(undoManager->beginTransaction(item->getUName(), item->getUPixmap(), Um::Cut, "", Um::ICut));
4520
4844
                        }
4521
4845
                }
4522
 
                Buffer2 = "<SCRIBUSTEXT>";
4523
4846
                currItem = doc->m_Selection->itemAt(0);
4524
4847
                if (doc->appMode == modeEdit)
4525
4848
                {
4528
4851
                        StoryText itemText(doc);
4529
4852
                        itemText.setDefaultStyle(currItem->itemText.defaultStyle());
4530
4853
                        itemText.insert(0, currItem->itemText, true);
4531
 
                        
4532
 
                        BufferI = itemText.text(0, itemText.length());
4533
 
                        
 
4854
 
4534
4855
                        std::ostringstream xmlString;
4535
4856
                        SaxXML xmlStream(xmlString);
4536
4857
                        xmlStream.beginDoc();
4537
4858
                        itemText.saxx(xmlStream, "SCRIBUSTEXT");
4538
4859
                        xmlStream.endDoc();
4539
4860
                        std::string xml(xmlString.str());
4540
 
                        Buffer2 = QString::fromUtf8(xml.c_str(), xml.length());
4541
 
                        
4542
 
                        /*                      PageItem *nextItem = currItem;
4543
 
                        while (nextItem != 0)
4544
 
                        {
4545
 
                                if (nextItem->prevInChain() != 0)
4546
 
                                        nextItem = nextItem->prevInChain();
4547
 
                                else
4548
 
                                        break;
4549
 
                        }
4550
 
                        if (nextItem != 0)
4551
 
                        {
4552
 
                                for (a = 0; a < nextItem->itemText.length(); ++a)
4553
 
                                {
4554
 
                                        if (nextItem->itemText.selected(a))
4555
 
                                        {
4556
 
                                                if (nextItem->itemText.text(a) == QChar(13))
4557
 
                                                {
4558
 
                                                        Buffer2 += QChar(5);
4559
 
                                                        BufferI += QChar(10);
4560
 
                                                }
4561
 
                                                else if (nextItem->itemText.text(a) == QChar(9))
4562
 
                                                {
4563
 
                                                        Buffer2 += QChar(4);
4564
 
                                                        BufferI += QChar(9);
4565
 
                                                }
4566
 
                                                else
4567
 
                                                {
4568
 
                                                        Buffer2 += nextItem->itemText.text(a);
4569
 
                                                        BufferI += nextItem->itemText.text(a);
4570
 
                                                }
4571
 
                                                Buffer2 += "\t";
4572
 
                                                Buffer2 += nextItem->itemText.charStyle(a).font().scName()+"\t";
4573
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).fontSize())+"\t";
4574
 
                                                Buffer2 += nextItem->itemText.charStyle(a).fillColor()+"\t";
4575
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).tracking())+"\t";
4576
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).fillShade())+'\t';
4577
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).effects())+'\t';
4578
 
                                                Buffer2 += QString::number(findParagraphStyle(doc, nextItem->itemText.paragraphStyle(a)))+'\t';
4579
 
                                                Buffer2 += nextItem->itemText.charStyle(a).strokeColor()+"\t";
4580
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).strokeShade())+'\t';
4581
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).scaleH())+"\t";
4582
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).scaleV())+'\t';
4583
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).baselineOffset())+'\t';
4584
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).shadowXOffset())+'\t';
4585
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).shadowYOffset())+'\t';
4586
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).outlineWidth())+'\t';
4587
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).underlineOffset())+'\t';
4588
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).underlineWidth())+'\t';
4589
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).strikethruOffset())+'\t';
4590
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).strikethruWidth())+'\n';
4591
 
                                        }
4592
 
                                }
4593
 
                                dynamic_cast<PageItem_TextFrame*>(nextItem)->deleteSelectedTextFromFrame();
4594
 
                                nextItem = nextItem->nextInChain();
4595
 
                        }
4596
 
                        */
 
4861
 
 
4862
                        ScTextMimeData* mimeData = new ScTextMimeData();
 
4863
                        mimeData->setScribusText (QByteArray(xml.c_str(), xml.length()));
 
4864
                        mimeData->setText( itemText.text(0, itemText.length()) ) ;
 
4865
                        QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
 
4866
 
4597
4867
                        dynamic_cast<PageItem_TextFrame*>(currItem)->deleteSelectedTextFromFrame();
4598
 
                        view->RefreshItem(currItem);
 
4868
                        currItem->update();
4599
4869
                }
4600
4870
                else
4601
4871
                {
4602
4872
                        if (((currItem->isSingleSel) && (currItem->isGroupControl)) || ((currItem->isSingleSel) && (currItem->isTableItem)))
4603
4873
                                return;
4604
 
                        
4605
 
                        // old version:
4606
 
                        ScriXmlDoc *ss = new ScriXmlDoc();
4607
 
                        Buffer2 = ss->WriteElem(doc, view, doc->m_Selection);
4608
 
                        
 
4874
 
4609
4875
                        // new version:
4610
4876
                        std::ostringstream xmlString;
4611
4877
                        SaxXML xmlStream(xmlString);
4612
 
//                      qDebug(QString("call serializer: %1").arg((ulong) & (doc->m_Selection)));
 
4878
//                      qDebug() << QString("call serializer: %1").arg((ulong) & (doc->m_Selection));
4613
4879
                        Serializer::serializeObjects(*doc->m_Selection, xmlStream);
4614
4880
                        std::string xml(xmlString.str());
4615
4881
                        BufferI = QString::fromUtf8(xml.c_str(), xml.length());
4616
 
                        
 
4882
 
4617
4883
                        if (prefsManager->appPrefs.doCopyToScrapbook)
4618
4884
                        {
4619
 
                                scrapbookPalette->ObjFromCopyAction(Buffer2);
 
4885
                                ScriXmlDoc ss;
 
4886
                                QString buffer = ss.WriteElem(doc, view, doc->m_Selection);
 
4887
                                scrapbookPalette->ObjFromCopyAction(buffer, currItem->itemName());
4620
4888
                                rebuildRecentPasteMenu();
4621
4889
                        }
4622
 
                        Buffer2 = BufferI;
4623
 
                        for (uint i=0; i < doc->m_Selection->count(); ++i)
 
4890
 
 
4891
                        ScFragmentMimeData* mimeData = new ScFragmentMimeData();
 
4892
                        mimeData->setScribusFragment ( QByteArray(xml.c_str(), xml.length()) );
 
4893
                        mimeData->setText( QString::fromUtf8(xml.c_str(), xml.length()) );
 
4894
                        QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
 
4895
 
 
4896
                        for (int i=0; i < doc->m_Selection->count(); ++i)
4624
4897
                        {
4625
4898
                                PageItem* frame = doc->m_Selection->itemAt(i);
4626
4899
                                if (frame->asTextFrame() && frame->prevInChain() == NULL)
4627
4900
                                        frame->clearContents();
4628
4901
                        }
4629
4902
                        doc->itemSelection_DeleteItem();
4630
 
                        delete ss;
4631
4903
                }
4632
4904
                slotDocCh();
4633
 
                BuFromApp = true;
4634
 
                ClipB->setText(BufferI);
4635
4905
                scrActions["editPaste"]->setEnabled(true);
4636
4906
                scrMenuMgr->setMenuEnabled("EditPasteRecent", scrapbookPalette->tempBView->objectMap.count() != 0);
4637
 
                if (UndoManager::undoEnabled())
4638
 
                        undoManager->commit();
 
4907
                if (activeTransaction)
 
4908
                {
 
4909
                        activeTransaction->commit();
 
4910
                        delete activeTransaction;
 
4911
                        activeTransaction = NULL;
 
4912
                }
4639
4913
        }
4640
4914
}
4641
4915
 
4642
4916
void ScribusMainWindow::slotEditCopy()
4643
4917
{
4644
4918
//      int a;
4645
 
        NoFrameEdit();
 
4919
        if (HaveDoc && doc->appMode == modeEditClip)
 
4920
                view->requestMode(submodeEndNodeEdit);
4646
4921
        QString BufferI = "";
4647
4922
        if ((HaveDoc) && (doc->m_Selection->count() != 0))
4648
4923
        {
4649
 
                Buffer2 = "<SCRIBUSTEXT/>";
4650
4924
                PageItem *currItem = doc->m_Selection->itemAt(0);
4651
4925
                if ((doc->appMode == modeEdit) && (currItem->HasSel))
4652
4926
                {
4653
4927
                        StoryText itemText(doc);
4654
4928
                        itemText.setDefaultStyle(currItem->itemText.defaultStyle());
4655
4929
                        itemText.insert(0, currItem->itemText, true);
4656
 
                        
 
4930
 
4657
4931
                        BufferI = itemText.text(0, itemText.length());
4658
 
                        
 
4932
 
4659
4933
                        std::ostringstream xmlString;
4660
4934
                        SaxXML xmlStream(xmlString);
4661
4935
                        xmlStream.beginDoc();
4662
4936
                        itemText.saxx(xmlStream, "SCRIBUSTEXT");
4663
4937
                        xmlStream.endDoc();
4664
4938
                        std::string xml(xmlString.str());
4665
 
                        Buffer2 = QString::fromUtf8(xml.c_str(), xml.length());
4666
 
//                      qDebug(Buffer2);
4667
 
                        
4668
 
/*                      PageItem *nextItem = currItem;
4669
 
                        while (nextItem != 0)
4670
 
                        {
4671
 
                                if (nextItem->prevInChain() != 0)
4672
 
                                        nextItem = nextItem->prevInChain();
4673
 
                                else
4674
 
                                        break;
4675
 
                        }
4676
 
                        if (nextItem != 0)
4677
 
                        {
4678
 
                                for (a = 0; a < nextItem->itemText.length(); ++a)
4679
 
                                {
4680
 
                                        if (nextItem->itemText.selected(a))
4681
 
                                        {
4682
 
                                                if (nextItem->itemText.text(a) == SpecialChars::PARSEP)
4683
 
                                                {
4684
 
                                                        Buffer2 += QChar(5);
4685
 
                                                        BufferI += QChar(10);
4686
 
                                                }
4687
 
                                                else if (nextItem->itemText.text(a) == SpecialChars::TAB)
4688
 
                                                {
4689
 
                                                        Buffer2 += QChar(4);
4690
 
                                                        BufferI += QChar(9);
4691
 
                                                }
4692
 
                                                else
4693
 
                                                {
4694
 
                                                        Buffer2 += nextItem->itemText.text(a);
4695
 
                                                        BufferI += nextItem->itemText.text(a);
4696
 
                                                }
4697
 
                                                Buffer2 += "\t";
4698
 
                                                Buffer2 += nextItem->itemText.charStyle(a).font().scName()+"\t";
4699
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).fontSize())+"\t";
4700
 
                                                Buffer2 += nextItem->itemText.charStyle(a).fillColor()+"\t";
4701
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).tracking())+"\t";
4702
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).fillShade())+"\t";
4703
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).effects())+"\t";
4704
 
                                                Buffer2 += QString::number(findParagraphStyle(doc, nextItem->itemText.paragraphStyle(a)))+"\t";
4705
 
                                                Buffer2 += nextItem->itemText.charStyle(a).strokeColor()+"\t";
4706
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).strokeShade())+"\t";
4707
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).scaleH())+"\t";
4708
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).scaleV())+'\t';
4709
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).baselineOffset())+'\t';
4710
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).shadowXOffset())+'\t';
4711
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).shadowYOffset())+'\t';
4712
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).outlineWidth())+'\t';
4713
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).underlineOffset())+'\t';
4714
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).underlineWidth())+'\t';
4715
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).strikethruOffset())+'\t';
4716
 
                                                Buffer2 += QString::number(nextItem->itemText.charStyle(a).strikethruWidth())+'\n';
4717
 
                                        }
4718
 
                                }
4719
 
                                nextItem = nextItem->nextInChain();
4720
 
                        }
4721
 
                        */
 
4939
 
 
4940
                        ScTextMimeData* mimeData = new ScTextMimeData();
 
4941
                        mimeData->setScribusText( QByteArray(xml.c_str(), xml.length()) );
 
4942
                        mimeData->setText( itemText.text(0, itemText.length()) );
 
4943
                        QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
4722
4944
                }
4723
4945
                else
4724
4946
                {
4725
4947
                        if (((currItem->isSingleSel) && (currItem->isGroupControl)) || ((currItem->isSingleSel) && (currItem->isTableItem)))
4726
4948
                                return;
4727
 
                        
4728
 
                        // old version:
4729
 
                        ScriXmlDoc *ss = new ScriXmlDoc();
4730
 
                        Buffer2 = ss->WriteElem(doc, view, doc->m_Selection);
4731
 
                        
 
4949
 
4732
4950
                        // new version:
4733
4951
                        std::ostringstream xmlString;
4734
4952
                        SaxXML xmlStream(xmlString);
4735
4953
                        Serializer::serializeObjects(*doc->m_Selection, xmlStream);
4736
4954
                        std::string xml(xmlString.str());
4737
 
                        BufferI = QString::fromUtf8(xml.c_str(), xml.length());
4738
 
                        
 
4955
 
4739
4956
#ifdef DESAXE_DEBUG
4740
4957
                        // debug:
4741
4958
                        SaxXML tmpfile1("tmp-scribus1.xml", true);
4747
4964
                        Serializer::serializeObjects(objects, tmpfile2);
4748
4965
                        doc->itemSelection_DeleteItem(&objects);
4749
4966
#endif
4750
 
                        
4751
 
                        if (prefsManager->appPrefs.doCopyToScrapbook)
 
4967
 
 
4968
                        if ((prefsManager->appPrefs.doCopyToScrapbook) && (!internalCopy))
4752
4969
                        {
4753
 
                                scrapbookPalette->ObjFromCopyAction(Buffer2);
 
4970
                                ScriXmlDoc ss;
 
4971
                                QString buffer = ss.WriteElem(doc, view, doc->m_Selection);
 
4972
                                scrapbookPalette->ObjFromCopyAction(buffer, currItem->itemName());
4754
4973
                                rebuildRecentPasteMenu();
4755
4974
                        }
4756
 
                        Buffer2 = BufferI;
4757
 
                        delete ss;
 
4975
 
 
4976
                        ScFragmentMimeData* mimeData = new ScFragmentMimeData();
 
4977
                        mimeData->setScribusFragment( QByteArray(xml.c_str(), xml.length()) );
 
4978
                        mimeData->setText( QString::fromUtf8(xml.c_str(), xml.length()) );
 
4979
                        QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
4758
4980
                }
4759
 
                BuFromApp = true;
4760
 
                ClipB->setText(BufferI);
4761
4981
                scrActions["editPaste"]->setEnabled(true);
4762
4982
                scrMenuMgr->setMenuEnabled("EditPasteRecent", scrapbookPalette->tempBView->objectMap.count() != 0);
4763
4983
        }
4765
4985
 
4766
4986
void ScribusMainWindow::slotEditPaste()
4767
4987
{
4768
 
        NoFrameEdit();
 
4988
        if (HaveDoc && doc->appMode == modeEditClip)
 
4989
                view->requestMode(submodeEndNodeEdit);
4769
4990
        if (HaveDoc)
4770
4991
        {
4771
 
                if (Buffer2.isNull())
 
4992
                UndoTransaction* activeTransaction = NULL;
 
4993
                if (!ScMimeData::clipboardHasScribusData())
4772
4994
                        return;
4773
4995
                if (UndoManager::undoEnabled())
4774
 
                        undoManager->beginTransaction(doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste);
4775
 
                if (doc->appMode == modeEdit)
 
4996
                        activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->currentPage()->getUName(), 0, Um::Paste, "", Um::IPaste));
 
4997
                if (doc->appMode == modeEdit && doc->m_Selection->itemAt(0))
4776
4998
                {
4777
4999
                        PageItem_TextFrame *currItem = dynamic_cast<PageItem_TextFrame*>(doc->m_Selection->itemAt(0));
 
5000
                        assert(currItem != NULL);
4778
5001
                        if (currItem->HasSel)
4779
5002
                                currItem->deleteSelectedTextFromFrame();
4780
5003
 
4782
5005
                                currItem->CPos = 0;
4783
5006
                        if (currItem->CPos > currItem->itemText.length())
4784
5007
                                currItem->CPos = currItem->itemText.length();
4785
 
                        
4786
 
                        if (hasXMLRootElem(Buffer2, "<SCRIBUSTEXT"))
 
5008
 
 
5009
                        if (ScMimeData::clipboardHasScribusText())
4787
5010
                        {
4788
5011
                                Serializer dig(*doc);
4789
5012
                                dig.store<ScribusDoc>("<scribusdoc>", doc);
4790
5013
                                StoryText::desaxeRules("/", dig, "SCRIBUSTEXT");
4791
5014
                                dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>());
4792
5015
 
4793
 
                                QCString xml( Buffer2.utf8() );
 
5016
                                QByteArray xml = ScMimeData::clipboardScribusText();
4794
5017
                                dig.parseMemory(xml, xml.length());
4795
 
                                
 
5018
 
4796
5019
                                StoryText* story = dig.result<StoryText>();
4797
 
                                
 
5020
 
4798
5021
                                currItem->itemText.insert(currItem->CPos, *story);
4799
5022
                                currItem->CPos += story->length();
4800
 
                                
 
5023
 
4801
5024
                                delete story;
4802
 
                                
4803
 
/*                              QString Buf = Buffer2.mid(13);
4804
 
                                QTextStream t(&Buf, IO_ReadOnly);
4805
 
                                QString cc;
4806
 
                                while (!t.atEnd())
4807
 
                                {
4808
 
                                        cc = t.readLine();
4809
 
                                        QStringList wt;
4810
 
                                        QStringList::Iterator it;
4811
 
                                        wt = QStringList::split("\t", cc);
4812
 
                                        it = wt.begin();
4813
 
                                        CharStyle nstyle;
4814
 
                                        QString ch = (*it);
4815
 
                                        if (ch == QChar(5))
4816
 
                                                ch = SpecialChars::PARSEP;
4817
 
                                        if (ch == QChar(4))
4818
 
                                                ch = SpecialChars::TAB;
4819
 
                                                Don't copy inline frames for now, as this is a very complicated thing.
4820
 
                                                We need to figure out a good way to copy inline frames, this must
4821
 
                                                be able to preserve them across documents. No idea how to solve
4822
 
                                                that yet. *--/
4823
 
                                        if (ch == SpecialChars::OBJECT)
4824
 
                                                ch = QChar(32);
4825
 
                                        it++;
4826
 
                                        nstyle.setFont((*doc->AllFonts)[*it]);
4827
 
                                        it++;
4828
 
                                        nstyle.setFontSize((*it).toInt());
4829
 
                                        it++;
4830
 
                                        nstyle.setFillColor(*it);
4831
 
                                        it++;
4832
 
                                        nstyle.setTracking((*it).toInt());
4833
 
                                        it++;
4834
 
                                        nstyle.setFillShade((*it).toInt());
4835
 
                                        it++;
4836
 
                                        nstyle.setFeatures(static_cast<StyleFlag>((*it).toInt()).featureList());
4837
 
                                        it++;
4838
 
                                        int cab = (*it).toInt();
4839
 
                                        it++;
4840
 
                                        if (it == NULL)
4841
 
                                                nstyle.setStrokeColor(CommonStrings::None);
4842
 
                                        else
4843
 
                                                nstyle.setStrokeColor(*it);
4844
 
                                        it++;
4845
 
                                        if (it == NULL)
4846
 
                                                nstyle.setStrokeShade(100);
4847
 
                                        else
4848
 
                                                nstyle.setStrokeShade((*it).toInt());
4849
 
                                        it++;
4850
 
                                        if (it == NULL)
4851
 
                                                nstyle.setScaleH(1000);
4852
 
                                        else
4853
 
                                                nstyle.setScaleH((*it).toInt());
4854
 
                                        it++;
4855
 
                                        if (it == NULL)
4856
 
                                                nstyle.setScaleV(1000);
4857
 
                                        else
4858
 
                                                nstyle.setScaleV(QMIN(QMAX((*it).toInt(), 100), 4000));
4859
 
                                        it++;
4860
 
                                        nstyle.setBaselineOffset(it == NULL ? 0 : (*it).toInt());
4861
 
                                        it++;
4862
 
                                        nstyle.setShadowXOffset(it == NULL ? 50 : (*it).toInt());
4863
 
                                        it++;
4864
 
                                        nstyle.setShadowYOffset(it == NULL ? -50 : (*it).toInt());
4865
 
                                        it++;
4866
 
                                        nstyle.setOutlineWidth(it == NULL ? 10 : (*it).toInt());
4867
 
                                        it++;
4868
 
                                        nstyle.setUnderlineOffset(it == NULL ? -1 : (*it).toInt());
4869
 
                                        it++;
4870
 
                                        nstyle.setUnderlineWidth(it == NULL ? -1 : (*it).toInt());
4871
 
                                        it++;
4872
 
                                        nstyle.setStrikethruOffset(it == NULL ? -1 : (*it).toInt());
4873
 
                                        it++;
4874
 
                                        nstyle.setStrikethruWidth(it == NULL ? -1 : (*it).toInt());
4875
 
                                        currItem->itemText.insertChars(currItem->CPos, ch);
4876
 
                                        if (ch == SpecialChars::PARSEP) {
4877
 
                                                currItem->itemText.applyStyle(currItem->CPos, doc->paragraphStyles()[cab]);
4878
 
                                        }
4879
 
                                        else {
4880
 
                                                currItem->itemText.applyCharStyle(currItem->CPos, 1, nstyle);
4881
 
                                        }
4882
 
                                        currItem->CPos += 1;
4883
 
                                }
4884
 
*/
4885
5025
                        }
4886
 
                        else if (hasXMLRootElem(Buffer2, "<SCRIBUSELEM") || hasXMLRootElem(Buffer2, "<SCRIBUSFRAGMENT"))
 
5026
                        else if (ScMimeData::clipboardHasScribusElem() || ScMimeData::clipboardHasScribusFragment())
4887
5027
                        {
4888
5028
                                bool savedAlignGrid = doc->useRaster;
4889
5029
                                bool savedAlignGuides = doc->SnapGuides;
4890
 
                                uint ac = doc->Items->count();
 
5030
                                int ac = doc->Items->count();
4891
5031
                                bool isGroup = false;
4892
5032
                                double gx, gy, gh, gw;
4893
5033
                                FPoint minSize = doc->minCanvasCoordinate;
4894
5034
                                FPoint maxSize = doc->maxCanvasCoordinate;
4895
5035
                                doc->useRaster = false;
4896
5036
                                doc->SnapGuides = false;
4897
 
                                if (hasXMLRootElem(Buffer2, "<SCRIBUSELEM"))
4898
 
                                        slotElemRead(Buffer2, 0, 0, false, true, doc, view);
4899
 
                                else 
4900
 
                                        Serializer(*doc).deserializeObjects(Buffer2.utf8());
 
5037
                                // HACK #6541 : undo does not handle text modification => do not record embedded item creation
 
5038
                                // if embedded item is deleted, undo system will not be aware of its deletion => crash - JG
 
5039
                                undoManager->setUndoEnabled(false);
 
5040
 
 
5041
                                if (ScMimeData::clipboardHasScribusElem())
 
5042
                                {
 
5043
                                        QString buffer  = ScMimeData::clipboardScribusElem();
 
5044
                                        slotElemRead(buffer, 0, 0, false, true, doc, view);
 
5045
                                }
 
5046
                                else
 
5047
                                {
 
5048
                                        QByteArray fragment = ScMimeData::clipboardScribusFragment();
 
5049
                                        Serializer(*doc).deserializeObjects(fragment);
 
5050
                                }
4901
5051
 
4902
5052
                                // update style lists:
4903
5053
                                styleManager->setDoc(doc);
4904
5054
                                propertiesPalette->unsetDoc();
4905
5055
                                propertiesPalette->setDoc(doc);
4906
 
                                
 
5056
 
4907
5057
                                doc->useRaster = savedAlignGrid;
4908
5058
                                doc->SnapGuides = savedAlignGuides;
4909
5059
                                //int tempList=doc->m_Selection->backupToTempList(0);
4911
5061
                                doc->m_Selection->clear();
4912
5062
                                if (doc->Items->count() - ac > 1)
4913
5063
                                        isGroup = true;
4914
 
                                for (uint as = ac; as < doc->Items->count(); ++as)
 
5064
                                doc->m_Selection->delaySignalsOn();
 
5065
                                for (int as = ac; as < doc->Items->count(); ++as)
4915
5066
                                {
4916
5067
                                        doc->m_Selection->addItem(doc->Items->at(as));
4917
5068
                                        if (isGroup)
4918
5069
                                                doc->Items->at(as)->Groups.push(doc->GroupCounter);
4919
5070
                                }
 
5071
                                doc->m_Selection->delaySignalsOff();
4920
5072
                                if (isGroup)
4921
5073
                                        doc->GroupCounter++;
4922
5074
                                doc->m_Selection->setGroupRect();
4923
5075
                                doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
4924
5076
                                PageItem* currItem3 = doc->Items->at(ac);
4925
 
                                for (uint as = ac; as < doc->Items->count(); ++as)
 
5077
                                for (int as = ac; as < doc->Items->count(); ++as)
4926
5078
                                {
4927
5079
                                        PageItem* currItem2 = doc->Items->at(as);
4928
5080
                                        currItem2->isEmbedded = true;
4935
5087
                                        currItem2->ItemNr = doc->FrameItems.count();
4936
5088
                                        doc->FrameItems.append(currItem2);
4937
5089
                                }
4938
 
                                uint acc = doc->Items->count();
4939
 
                                for (uint as = ac; as < acc; ++as)
 
5090
                                int acc = doc->Items->count();
 
5091
                                for (int as = ac; as < acc; ++as)
4940
5092
                                {
4941
 
                                        doc->Items->take(ac);
 
5093
                                        doc->Items->takeAt(ac);
4942
5094
                                }
4943
5095
                                doc->m_Selection->clear();
4944
5096
                                //doc->m_Selection->restoreFromTempList(0, tempList);
4945
5097
                                *doc->m_Selection=tempSelection;
4946
 
                                view->resizeContents(qRound((maxSize.x() - minSize.x()) * view->scale()), qRound((maxSize.y() - minSize.y()) * view->scale()));
4947
 
                                view->scrollBy(qRound((doc->minCanvasCoordinate.x() - minSize.x()) * view->scale()), qRound((doc->minCanvasCoordinate.y() - minSize.y()) * view->scale()));
 
5098
//                              view->resizeContents(qRound((maxSize.x() - minSize.x()) * view->scale()), qRound((maxSize.y() - minSize.y()) * view->scale()));
 
5099
//                              view->scrollBy(qRound((doc->minCanvasCoordinate.x() - minSize.x()) * view->scale()), qRound((doc->minCanvasCoordinate.y() - minSize.y()) * view->scale()));
4948
5100
                                doc->minCanvasCoordinate = minSize;
4949
5101
                                doc->maxCanvasCoordinate = maxSize;
4950
5102
                                if (outlinePalette->isVisible())
4951
5103
                                        outlinePalette->BuildTree();
4952
5104
                                currItem->itemText.insertObject(currItem->CPos, currItem3);
4953
5105
                                currItem->CPos += 1;
 
5106
                                undoManager->setUndoEnabled(true);
4954
5107
                        }
4955
5108
                        else
4956
5109
                        {
4957
5110
                                // K.I.S.S.:
4958
 
                                currItem->itemText.insertChars(currItem->CPos, Buffer2, true);
 
5111
                                QString text = QApplication::clipboard()->text(QClipboard::Clipboard);
 
5112
                                text = text.replace("\r\n", SpecialChars::PARSEP);
 
5113
                                text = text.replace('\n', SpecialChars::PARSEP);
 
5114
                                currItem->itemText.insertChars(currItem->CPos, text, true);
4959
5115
                        }
4960
 
                        view->RefreshItem(currItem);
 
5116
                        currItem->update();
4961
5117
                }
4962
5118
                else
4963
5119
                {
4964
 
                        if (hasXMLRootElem(Buffer2, "<SCRIBUSELEM") || hasXMLRootElem(Buffer2, "<SCRIBUSFRAGMENT"))
 
5120
                        if (ScMimeData::clipboardHasScribusElem() || ScMimeData::clipboardHasScribusFragment())
4965
5121
                        {
4966
5122
                                view->Deselect(true);
4967
5123
                                uint ac = doc->Items->count();
4969
5125
                                bool savedAlignGuides = doc->SnapGuides;
4970
5126
                                doc->useRaster = false;
4971
5127
                                doc->SnapGuides = false;
4972
 
//                              qDebug(Buffer2);
4973
 
                                if (hasXMLRootElem(Buffer2, "<SCRIBUSELEM"))
4974
 
                                        slotElemRead(Buffer2, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
4975
 
                                else 
4976
 
                                {
4977
 
                                        Selection pastedObjects = Serializer(*doc).deserializeObjects(Buffer2.utf8());
4978
 
                                        for (uint i=0; i < pastedObjects.count(); ++i)
 
5128
                                if (ScMimeData::clipboardHasScribusElem())
 
5129
                                {
 
5130
                                        QString buffer  = ScMimeData::clipboardScribusElem();
 
5131
                                        slotElemRead(buffer, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 
5132
                                }
 
5133
                                else
 
5134
                                {
 
5135
                                        QByteArray fragment = ScMimeData::clipboardScribusFragment();
 
5136
                                        Selection pastedObjects = Serializer(*doc).deserializeObjects(fragment);
 
5137
                                        for (int i=0; i < pastedObjects.count(); ++i)
4979
5138
                                                pastedObjects.itemAt(i)->LayerNr = doc->activeLayer();
4980
 
                                        
 
5139
 
4981
5140
                                        /*double x = doc->currentPage()->xOffset();
4982
5141
                                        double y = doc->currentPage()->yOffset();
4983
5142
                                        for (uint i=0; i < pastedObjects.count(); ++i)
4984
 
                                                if (! pastedObjects.itemAt(i)->isEmbedded) 
 
5143
                                                if (! pastedObjects.itemAt(i)->isEmbedded)
4985
5144
                                                {
4986
5145
                                                //      const Page* pg = doc->Pages->at(doc->OnPage(pastedObjects.itemAt(i)));
4987
5146
                                                //      if (!pg)
4988
5147
                                                //              pg = doc->Pages->at(doc->Pages->count() - 1);
4989
5148
                                                //      if (pg)
4990
5149
                                                //              pastedObjects.itemAt(i)->moveBy(x - pg->xOffset(), y - pg->yOffset(), true);
4991
 
                                                        qDebug(QString("move pasted: %1 %2,%3 + %4,%5").arg((ulong)pastedObjects.itemAt(i)).arg(x).arg(y).arg(pastedObjects.itemAt(i)->xPos()).arg(pastedObjects.itemAt(i)->yPos()));
 
5150
                                                        qDebug() << QString("move pasted: %1 %2,%3 + %4,%5").arg((ulong)pastedObjects.itemAt(i)).arg(x).arg(y).arg(pastedObjects.itemAt(i)->xPos()).arg(pastedObjects.itemAt(i)->yPos());
4992
5151
                                                        pastedObjects.itemAt(i)->moveBy(x, y, true);
4993
5152
                                                }
4994
5153
                                        */
4998
5157
                                styleManager->setDoc(doc);
4999
5158
                                propertiesPalette->unsetDoc();
5000
5159
                                propertiesPalette->setDoc(doc);
5001
 
                                                                
 
5160
 
5002
5161
                                doc->useRaster = savedAlignGrid;
5003
5162
                                doc->SnapGuides = savedAlignGuides;
5004
 
                                for (uint as = ac; as < doc->Items->count(); ++as)
 
5163
                                doc->m_Selection->delaySignalsOn();
 
5164
                                for (int as = ac; as < doc->Items->count(); ++as)
5005
5165
                                {
5006
5166
                                        PageItem* currItem = doc->Items->at(as);
5007
5167
                                        if (currItem->isBookmark)
5008
5168
                                                AddBookMark(currItem);
5009
5169
                                        doc->m_Selection->addItem(currItem);
5010
5170
                                }
 
5171
                                doc->m_Selection->delaySignalsOff();
5011
5172
                                int docSelectionCount=doc->m_Selection->count();
5012
5173
                                if (docSelectionCount > 1)
5013
5174
                                {
5014
5175
                                        doc->m_Selection->setGroupRect();
5015
 
                                        view->paintGroupRect();
 
5176
//                                      view->paintGroupRect();
5016
5177
                                        double x, y, w, h;
5017
5178
                                        doc->m_Selection->getGroupRect(&x, &y, &w, &h);
5018
5179
                                        propertiesPalette->setXY(x, y);
5023
5184
                        }
5024
5185
                        view->DrawNew();
5025
5186
                }
5026
 
                if (UndoManager::undoEnabled())
5027
 
                        undoManager->commit();
 
5187
                if (activeTransaction)
 
5188
                {
 
5189
                        activeTransaction->commit();
 
5190
                        delete activeTransaction;
 
5191
                        activeTransaction = NULL;
 
5192
                }
5028
5193
                slotDocCh(false);
5029
5194
        }
5030
5195
}
5031
5196
 
5032
5197
//CB-->Doc ?????
5033
 
void ScribusMainWindow::SelectAll()
 
5198
void ScribusMainWindow::SelectAllOnLayer()
 
5199
{
 
5200
        ColorList UsedC;
 
5201
        doc->getUsedColors(UsedC);
 
5202
        selectDialog *dia = new selectDialog(this, UsedC, doc->unitIndex());
 
5203
        if (dia->exec())
 
5204
        {
 
5205
                PageItem *currItem;
 
5206
                view->Deselect();
 
5207
                uint docItemsCount = doc->Items->count();
 
5208
                int docCurrentPage = doc->currentPageNumber();
 
5209
                doc->m_Selection->delaySignalsOn();
 
5210
                int range = dia->getSelectionRange();
 
5211
                for (uint a = 0; a < docItemsCount; ++a)
 
5212
                {
 
5213
                        currItem = doc->Items->at(a);
 
5214
                        if ((currItem->LayerNr == doc->activeLayer()) && (!doc->layerLocked(currItem->LayerNr)))
 
5215
                        {
 
5216
                                if ((range == 0) && (currItem->OwnPage != docCurrentPage))
 
5217
                                        continue;
 
5218
                                if ((range == 2) && (currItem->OwnPage != -1))
 
5219
                                        continue;
 
5220
                                if (dia->useAttributes())
 
5221
                                {
 
5222
                                        bool useType = false;
 
5223
                                        bool useFill = false;
 
5224
                                        bool useLine = false;
 
5225
                                        bool useLWidth = false;
 
5226
                                        bool usePrint = false;
 
5227
                                        bool useLocked = false;
 
5228
                                        bool useResize = false;
 
5229
                                        dia->getUsedAttributes(useType, useFill, useLine, useLWidth, usePrint, useLocked, useResize);
 
5230
                                        int Type = 0;
 
5231
                                        QString Fill = "";
 
5232
                                        QString Line = "";
 
5233
                                        double LWidth = 0.0;
 
5234
                                        bool Print = false;
 
5235
                                        bool Locked = false;
 
5236
                                        bool Resize = false;
 
5237
                                        dia->getUsedAttributesValues(Type, Fill, Line, LWidth, Print, Locked, Resize);
 
5238
                                        LWidth = LWidth / doc->unitRatio();
 
5239
                                        if ((useType) && (Type != currItem->realItemType()))
 
5240
                                                continue;
 
5241
                                        if ((useFill) && ((Fill != currItem->fillColor()) || (currItem->GrType != 0)))
 
5242
                                                continue;
 
5243
                                        if ((useLine) && (Line != currItem->lineColor()))
 
5244
                                                continue;
 
5245
                                        if ((useLWidth) && ((LWidth != currItem->lineWidth()) || (currItem->lineColor() == CommonStrings::None)))
 
5246
                                                continue;
 
5247
                                        if ((usePrint) && (Print != currItem->printEnabled()))
 
5248
                                                continue;
 
5249
                                        if ((useLocked) && (Locked != currItem->locked()))
 
5250
                                                continue;
 
5251
                                        if ((useResize) && (Resize != currItem->sizeLocked()))
 
5252
                                                continue;
 
5253
                                        doc->m_Selection->addItem(currItem);
 
5254
                                }
 
5255
                                else
 
5256
                                        doc->m_Selection->addItem(currItem);
 
5257
                        }
 
5258
                }
 
5259
                doc->m_Selection->delaySignalsOff();
 
5260
                int docSelectionCount = doc->m_Selection->count();
 
5261
                if (docSelectionCount > 1)
 
5262
                {
 
5263
                        double x, y, w, h;
 
5264
                        doc->m_Selection->setGroupRect();
 
5265
                        doc->m_Selection->getGroupRect(&x, &y, &w, &h);
 
5266
                        propertiesPalette->setXY(x, y);
 
5267
                        propertiesPalette->setBH(w, h);
 
5268
                }
 
5269
                if (docSelectionCount > 0)
 
5270
                {
 
5271
                        currItem = doc->m_Selection->itemAt(0);
 
5272
                        HaveNewSel(currItem->itemType());
 
5273
                }
 
5274
                view->DrawNew();
 
5275
        }
 
5276
        delete dia;
 
5277
}
 
5278
 
 
5279
void ScribusMainWindow::SelectAll(bool docWideSelect)
5034
5280
{
5035
5281
        if (doc->appMode == modeEdit)
5036
5282
        {
5037
5283
                PageItem *currItem = doc->m_Selection->itemAt(0);
5038
5284
                PageItem *nextItem = currItem;
 
5285
                nextItem->itemText.selectAll();
5039
5286
                while (nextItem != 0)
5040
5287
                {
5041
5288
                        if (nextItem->prevInChain() != 0)
5045
5292
                }
5046
5293
                while (nextItem != 0)
5047
5294
                {
5048
 
                        nextItem->itemText.selectAll();
5049
5295
                        nextItem->HasSel = true;
5050
5296
                        nextItem = nextItem->nextInChain();
5051
5297
                }
5052
 
                view->DrawNew();
5053
5298
                EnableTxEdit();
5054
5299
        }
5055
5300
        else
5056
5301
        {
5057
5302
                PageItem *currItem;
5058
5303
                view->Deselect();
 
5304
                doc->m_Selection->delaySignalsOn();
5059
5305
                uint docItemsCount=doc->Items->count();
 
5306
                int docCurrentPage=doc->currentPageNumber();
5060
5307
                for (uint a = 0; a < docItemsCount; ++a)
5061
5308
                {
5062
5309
                        currItem = doc->Items->at(a);
5063
5310
                        if ((currItem->LayerNr == doc->activeLayer()) && (!doc->layerLocked(currItem->LayerNr)))
5064
5311
                        {
5065
 
                                if (!currItem->isSelected())
 
5312
                                if (docWideSelect)
 
5313
                                        doc->m_Selection->addItem(currItem);
 
5314
                                else
5066
5315
                                {
5067
 
                                        doc->m_Selection->addItem(currItem);
5068
 
                                        currItem->FrameOnly = true;
5069
 
                                        currItem->paintObj();
 
5316
                                        if (currItem->OwnPage==docCurrentPage)
 
5317
                                                doc->m_Selection->addItem(currItem);
5070
5318
                                }
5071
5319
                        }
5072
5320
                }
 
5321
                doc->m_Selection->delaySignalsOff();
5073
5322
                int docSelectionCount=doc->m_Selection->count();
5074
5323
                if (docSelectionCount > 1)
5075
5324
                {
 
5325
                        double x, y, w, h;
5076
5326
                        doc->m_Selection->setGroupRect();
5077
 
                        view->paintGroupRect();
5078
 
                        double x, y, w, h;
5079
5327
                        doc->m_Selection->getGroupRect(&x, &y, &w, &h);
5080
5328
                        propertiesPalette->setXY(x, y);
5081
5329
                        propertiesPalette->setBH(w, h);
5086
5334
                        HaveNewSel(currItem->itemType());
5087
5335
                }
5088
5336
        }
 
5337
        view->DrawNew();
5089
5338
}
5090
5339
 
5091
5340
void ScribusMainWindow::deselectAll()
5096
5345
 
5097
5346
void ScribusMainWindow::ClipChange()
5098
5347
{
5099
 
        QString cc;
5100
 
#if QT_VERSION  >= 0x030100
5101
 
//      cc = ClipB->text(QClipboard::Selection);
5102
 
//      if (cc.isNull())
5103
 
        cc = ClipB->text(QClipboard::Clipboard);
5104
 
#else
5105
 
        cc = ClipB->text();
5106
 
#endif
5107
 
 
5108
 
        if (!cc.isNull())
5109
 
        {
5110
 
                if (!BuFromApp)
5111
 
                        Buffer2 = cc;
5112
 
                BuFromApp = false;
5113
 
        }
5114
 
        scrActions["editPaste"]->setEnabled(HaveDoc && 
5115
 
                                                                                (hasXMLRootElem(Buffer2, "<SCRIBUSELEM") 
5116
 
                                                                                 || hasXMLRootElem(Buffer2, "<SCRIBUSFRAGMENT") 
5117
 
                                                                                 || doc->appMode == modeEdit));
 
5348
        bool hasScribusData = ScMimeData::clipboardHasScribusElem() || ScMimeData::clipboardHasScribusFragment(); 
 
5349
        scrActions["editPaste"]->setEnabled(HaveDoc && (hasScribusData || doc->appMode == modeEdit));
5118
5350
}
5119
5351
 
5120
5352
void ScribusMainWindow::EnableTxEdit()
5133
5365
 
5134
5366
void ScribusMainWindow::slotHelpAbout()
5135
5367
{
5136
 
        About* dia = new About(this);
5137
 
        dia->exec();
5138
 
        delete dia;
 
5368
        About dia(this);
 
5369
        dia.exec();
5139
5370
}
5140
5371
 
5141
5372
void ScribusMainWindow::slotHelpAboutPlugins()
5142
5373
{
5143
 
        AboutPlugins* dia = new AboutPlugins(this);
5144
 
        dia->exec();
5145
 
        delete dia;
 
5374
        AboutPlugins dia(this);
 
5375
        dia.exec();
5146
5376
}
5147
5377
 
5148
5378
void ScribusMainWindow::slotHelpAboutQt()
5150
5380
        QMessageBox::aboutQt(this, tr("About Qt"));
5151
5381
}
5152
5382
 
 
5383
void ScribusMainWindow::slotHelpCheckUpdates()
 
5384
{
 
5385
        About dia(this, About::CheckUpdates);
 
5386
        dia.exec();
 
5387
}
 
5388
 
5153
5389
void ScribusMainWindow::slotOnlineHelp()
5154
5390
{
5155
 
        HelpBrowser *dia = new HelpBrowser(0, tr("Scribus Manual"), ScCore->getGuiLanguage());
5156
 
        dia->show();
 
5391
        helpBrowser = new HelpBrowser(0, tr("Scribus Manual"), ScCore->getGuiLanguage());
 
5392
        connect(helpBrowser, SIGNAL(closed()), this, SLOT(slotOnlineHelpClosed()));
 
5393
        helpBrowser->show();
 
5394
}
 
5395
 
 
5396
void ScribusMainWindow::slotOnlineHelpClosed()
 
5397
{
 
5398
        if (helpBrowser)
 
5399
                helpBrowser->deleteLater();
5157
5400
}
5158
5401
 
5159
5402
void ScribusMainWindow::ToggleTips()
5160
5403
{
5161
 
        QToolTip::setGloballyEnabled(scrActions["helpTooltips"]->isOn());
5162
 
        prefsManager->appPrefs.showToolTips = scrActions["helpTooltips"]->isOn();
 
5404
        prefsManager->appPrefs.showToolTips = scrActions["helpTooltips"]->isChecked();
 
5405
}
 
5406
 
 
5407
void ScribusMainWindow::ToggleMouseTips()
 
5408
{
 
5409
        prefsManager->appPrefs.showMouseCoordinates = scrActions["showMouseCoordinates"]->isChecked();
5163
5410
}
5164
5411
 
5165
5412
void ScribusMainWindow::SaveText()
5171
5418
                wdir = prefsManager->prefsFile->getContext("dirs")->get("save_text", prefsDocDir);
5172
5419
        else
5173
5420
                wdir = prefsManager->prefsFile->getContext("dirs")->get("save_text", ".");
5174
 
        QString fn = CFileDialog( wdir, tr("Save as"), tr("Text Files (*.txt);;All Files(*)"), "", fdShowCodecs);
 
5421
        QString fn = CFileDialog( wdir, tr("Save As"), tr("Text Files (*.txt);;All Files(*)"), "", fdShowCodecs);
5175
5422
        if (!fn.isEmpty())
5176
5423
        {
5177
 
                prefsManager->prefsFile->getContext("dirs")->set("save_text", fn.left(fn.findRev("/")));
 
5424
                prefsManager->prefsFile->getContext("dirs")->set("save_text", fn.left(fn.lastIndexOf("/")));
5178
5425
                const StoryText& story (doc->m_Selection->itemAt(0)->itemText);
5179
 
                Serializer::writeWithEncoding(fn, LoadEnc, story.text(0, story.length()));              
 
5426
                Serializer::writeWithEncoding(fn, LoadEnc, story.text(0, story.length()));
5180
5427
        }
5181
5428
}
5182
5429
 
5190
5437
 
5191
5438
void ScribusMainWindow::slotNewPageP(int wo, QString templ)
5192
5439
{
5193
 
        NoFrameEdit();
 
5440
        if (HaveDoc && doc->appMode == modeEditClip)
 
5441
                view->requestMode(submodeEndNodeEdit);
5194
5442
        view->Deselect(true);
 
5443
        int where = 1;
 
5444
        if (wo == 0)
 
5445
                where = 0;
 
5446
        else if (wo == doc->Pages->count())
 
5447
                where = 2;
5195
5448
        slotNewPage(wo, templ); //master page is applied now
5196
5449
        //applyNewMaster(templ);
5197
 
        doc->addPageToSection(wo, 1, 1);
 
5450
        if (where == 2)
 
5451
                doc->addPageToSection(wo, where, 1);
 
5452
        else
 
5453
                doc->addPageToSection(wo+1, where, 1);
 
5454
        doc->changed();
5198
5455
        if (outlinePalette->isVisible())
5199
5456
                outlinePalette->BuildTree();
5200
 
        pagePalette->RebuildPage();
 
5457
        pagePalette->rebuildPages();
 
5458
        view->DrawNew();
5201
5459
}
5202
5460
 
5203
5461
/** Erzeugt eine neue Seite */
5204
5462
void ScribusMainWindow::slotNewPageM()
5205
5463
{
5206
 
        NoFrameEdit();
 
5464
        if (HaveDoc && doc->appMode == modeEditClip)
 
5465
                view->requestMode(submodeEndNodeEdit);
5207
5466
        view->Deselect(true);
5208
5467
        QStringList base;
5209
5468
        InsPage *dia = new InsPage(this, doc, doc->currentPage()->pageNr(), doc->Pages->count());
5213
5472
                addNewPages(dia->getWherePage(),
5214
5473
                            dia->getWhere(),
5215
5474
                            dia->getCount(),
5216
 
                                        dia->heightMSpinBox->value() / doc->unitRatio(),
5217
 
                                        dia->widthMSpinBox->value() / doc->unitRatio(),
5218
 
                                        dia->orientationQComboBox->currentItem(),
 
5475
                                        dia->heightSpinBox->value() / doc->unitRatio(),
 
5476
                                        dia->widthSpinBox->value() / doc->unitRatio(),
 
5477
                                        dia->orientationQComboBox->currentIndex(),
5219
5478
                                        dia->prefsPageSizeName,
5220
5479
                                        dia->moveObjects->isChecked(),
5221
5480
                            &base
5226
5485
 
5227
5486
void ScribusMainWindow::addNewPages(int wo, int where, int numPages, double height, double width, int orient, QString siz, bool mov, QStringList* basedOn)
5228
5487
{
 
5488
        UndoTransaction* activeTransaction = NULL;
5229
5489
        if (UndoManager::undoEnabled())
5230
5490
        {
5231
 
                undoManager->beginTransaction(doc->getUName(), Um::IDocument, (numPages == 1) ? Um::AddPage : Um::AddPages, "", Um::ICreate);
 
5491
                activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->getUName(), Um::IDocument, (numPages == 1) ? Um::AddPage : Um::AddPages, "", Um::ICreate));
5232
5492
                SimpleState *ss = new SimpleState(Um::AddPage, "", Um::ICreate);
5233
5493
                ss->set("ADD_PAGE", "add_page");
5234
5494
                ss->set("PAGE", wo);
5290
5550
                --wot;
5291
5551
        else if (where==2)
5292
5552
                wot=doc->Pages->count();
 
5553
        qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
 
5554
        view->updatesOn(false);
5293
5555
        for (cc = 0; cc < numPages; ++cc)
5294
5556
        {
5295
5557
                slotNewPage(wot, base[(wot+doc->pageSets[doc->currentPageLayout].FirstPage) % doc->pageSets[doc->currentPageLayout].Columns], mov); //Avoid the master page application with QString::null
5303
5565
//                                               doc->currentPage()->pageNr(), false); // this Apply_MasterPage avoids DreawNew and PagePalette->ReBuild, which is much faster for 100 pp :-)
5304
5566
                wot ++;
5305
5567
        }
 
5568
        view->updatesOn(true);
 
5569
        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
5306
5570
        //Use wo, the dialog currently returns a page Index +1 due to old numbering scheme, function now does the -1 as required
 
5571
        doc->changed();
5307
5572
        doc->addPageToSection(wo, where, numPages);
5308
 
        pagePalette->RebuildPage();
 
5573
        pagePalette->rebuildPages();
5309
5574
        view->reformPages(mov);
5310
5575
        view->DrawNew();
5311
5576
        if (outlinePalette->isVisible())
5313
5578
 
5314
5579
        undoManager->setUndoEnabled(true);
5315
5580
 
5316
 
        if (UndoManager::undoEnabled())
5317
 
                undoManager->commit();
 
5581
        if (activeTransaction)
 
5582
        {
 
5583
                activeTransaction->commit();
 
5584
                delete activeTransaction;
 
5585
                activeTransaction = NULL;
 
5586
        }
5318
5587
}
5319
5588
 
5320
5589
void ScribusMainWindow::slotNewMasterPage(int w, const QString& name)
5335
5604
 
5336
5605
void ScribusMainWindow::duplicateToMasterPage()
5337
5606
{
5338
 
        NewTm *dia = new NewTm(this, tr("Name:"), tr("Convert Page to Master Page"), doc, tr("New Master Page %1").arg(doc->MasterNames.count()));
 
5607
        if (!HaveDoc)
 
5608
                return;
5339
5609
        view->Deselect(true);
5340
 
        if (dia->exec())
 
5610
        int pageLocationIndex=-1;
 
5611
        int pageLocationCount=0;
 
5612
        if (doc->currentPageLayout != singlePage)
5341
5613
        {
5342
 
                int diaLinksCurrItem=0;
5343
 
                int diaLinksCount=0;
5344
 
                if (doc->currentPageLayout != singlePage)
 
5614
                QStringList locationEntries;
 
5615
                for(QStringList::Iterator pNames = doc->pageSets[doc->currentPageLayout].pageNames.begin(); pNames != doc->pageSets[doc->currentPageLayout].pageNames.end(); ++pNames )
5345
5616
                {
5346
 
                        diaLinksCurrItem=dia->Links->currentItem();
5347
 
                        diaLinksCount=static_cast<int>(dia->Links->count());
 
5617
                        locationEntries << CommonStrings::translatePageSetLocString(*pNames);
5348
5618
                }
5349
 
                QString masterPageName = dia->Answer->text();
 
5619
                pageLocationIndex=doc->columnOfPage(doc->currentPageNumber());
 
5620
                pageLocationCount=locationEntries.count();
 
5621
        }
 
5622
 
 
5623
        CopyPageToMasterPageDialog copyDialog(doc->MasterNames.count(), doc->pageSets[doc->currentPageLayout].pageNames, pageLocationIndex, this);
 
5624
        if (copyDialog.exec())
 
5625
        {
 
5626
                bool copyFromMaster=false;
 
5627
                QString masterPageName;
 
5628
                int pageLocation=0;
 
5629
                copyDialog.values(masterPageName, copyFromMaster, pageLocation);
5350
5630
                while (doc->MasterNames.contains(masterPageName) || (masterPageName == CommonStrings::masterPageNormal))
5351
5631
                {
5352
 
                        if (!dia->exec())
5353
 
                        {
5354
 
                                delete dia;
 
5632
                        if (!copyDialog.exec())
5355
5633
                                return;
5356
 
                        }
5357
 
                        masterPageName = dia->Answer->text();
 
5634
                        copyDialog.values(masterPageName, copyFromMaster, pageLocation);
5358
5635
                }
5359
5636
                int currentPageNumber=doc->currentPage()->pageNr();
5360
 
                bool ok=doc->copyPageToMasterPage(currentPageNumber, diaLinksCurrItem, diaLinksCount, masterPageName);
 
5637
                bool ok=doc->copyPageToMasterPage(currentPageNumber, pageLocation, pageLocationCount, masterPageName, copyFromMaster);
5361
5638
                Q_ASSERT(ok); //TODO get a return value in case the copy was not possible
5362
5639
                pagePalette->Rebuild();
5363
5640
        }
5364
 
        delete dia;
5365
5641
}
5366
5642
 
5367
5643
void ScribusMainWindow::slotZoom(double zoomFactor)
5385
5661
                finalZoomFactor = zoomFactor*prefsManager->displayScale()/100.0;
5386
5662
        if (finalZoomFactor == view->scale())
5387
5663
                return;
5388
 
        int x = qRound(QMAX(view->contentsX() / view->scale(), 0));
5389
 
        int y = qRound(QMAX(view->contentsY() / view->scale(), 0));
5390
 
        int w = qRound(QMIN(view->visibleWidth() / view->scale(), doc->currentPage()->width()));
5391
 
        int h = qRound(QMIN(view->visibleHeight() / view->scale(), doc->currentPage()->height()));
 
5664
        int x = qRound(qMax(view->contentsX() / view->scale(), 0.0));
 
5665
        int y = qRound(qMax(view->contentsY() / view->scale(), 0.0));
 
5666
        int w = qRound(qMin(view->visibleWidth() / view->scale(), doc->currentPage()->width()));
 
5667
        int h = qRound(qMin(view->visibleHeight() / view->scale(), doc->currentPage()->height()));
5392
5668
        if (zoomFactor==-200.0)
5393
5669
                view->rememberOldZoomLocation(qRound(doc->currentPage()->xOffset() + doc->currentPage()->width() / 2.0), qRound(doc->currentPage()->yOffset() + doc->currentPage()->height() / 2.0));
5394
5670
        else
5395
5671
                view->rememberOldZoomLocation(w / 2 + x,h / 2 + y);
5396
 
        view->setScale(finalZoomFactor);
5397
 
        view->slotDoZoom();
 
5672
        view->zoom(finalZoomFactor);
5398
5673
}
5399
5674
 
5400
5675
void ScribusMainWindow::ToggleStickyTools()
5401
5676
{
5402
5677
        prefsManager->appPrefs.stickyTools = !prefsManager->appPrefs.stickyTools;
5403
 
        scrActions["stickyTools"]->setOn(prefsManager->appPrefs.stickyTools);
 
5678
        scrActions["stickyTools"]->setChecked(prefsManager->appPrefs.stickyTools);
 
5679
        if (HaveDoc && doc->appMode!=modeNormal && !prefsManager->appPrefs.stickyTools)
 
5680
                view->requestMode(modeNormal);
5404
5681
}
5405
5682
 
5406
5683
void ScribusMainWindow::ToggleAllPalettes()
5420
5697
                        pagePalette->show();
5421
5698
                if (palettesStatus[6])
5422
5699
                        bookmarkPalette->show();
5423
 
                if (palettesStatus[7])
5424
 
                        measurementPalette->show();
 
5700
//              if (palettesStatus[7])
 
5701
//                      measurementPalette->show();
5425
5702
                if (palettesStatus[9])
5426
5703
                        docCheckerPalette->show();
5427
5704
                setPagePalette(palettesStatus[5]);
5435
5712
                palettesStatus[4] = layerPalette->isVisible();
5436
5713
                palettesStatus[5] = pagePalette->isVisible();
5437
5714
                palettesStatus[6] = bookmarkPalette->isVisible();
5438
 
                palettesStatus[7] = measurementPalette->isVisible();
 
5715
//              palettesStatus[7] = measurementPalette->isVisible();
5439
5716
                palettesStatus[8] = undoPalette->isVisible();
5440
5717
                palettesStatus[9] = docCheckerPalette->isVisible();
5441
5718
                propertiesPalette->hide();
5444
5721
                bookmarkPalette->hide();
5445
5722
                pagePalette->hide();
5446
5723
                layerPalette->hide();
5447
 
                measurementPalette->hide();
 
5724
//              measurementPalette->hide();
5448
5725
                docCheckerPalette->hide();
5449
5726
                setPagePalette(false);
5450
5727
                setUndoPalette(false);
5460
5737
void ScribusMainWindow::setUndoPalette(bool visible)
5461
5738
{
5462
5739
        undoPalette->setPaletteShown(visible);
5463
 
        scrActions["toolsActionHistory"]->setOn(visible);
 
5740
        scrActions["toolsActionHistory"]->setChecked(visible);
5464
5741
}
5465
5742
/*
5466
5743
void ScribusMainWindow::togglePropertiesPalette()
5512
5789
 
5513
5790
void ScribusMainWindow::TogglePics()
5514
5791
{
5515
 
        if(doc)
 
5792
        if (doc)
5516
5793
        {
5517
5794
                doc->guidesSettings.showPic = !doc->guidesSettings.showPic;
5518
 
                for (uint b=0; b<doc->Items->count(); ++b)
 
5795
                for (int b=0; b<doc->Items->count(); ++b)
5519
5796
                {
5520
5797
                        if (doc->Items->at(b)->asImageFrame())
5521
5798
                                doc->Items->at(b)->setImageShown(doc->guidesSettings.showPic);
5586
5863
                doc->guidesSettings.showBleed = false;
5587
5864
                view->setRulersShown(doc->guidesSettings.rulersShown);
5588
5865
        }
5589
 
        scrActions["viewShowMargins"]->setOn(doc->guidesSettings.marginsShown);
5590
 
        scrActions["viewShowBleeds"]->setOn(doc->guidesSettings.showBleed);
5591
 
        scrActions["viewShowFrames"]->setOn(doc->guidesSettings.framesShown);
5592
 
        scrActions["viewShowLayerMarkers"]->setOn(doc->guidesSettings.layerMarkersShown);
5593
 
        scrActions["viewShowGrid"]->setOn(doc->guidesSettings.gridShown);
5594
 
        scrActions["viewShowGuides"]->setOn(doc->guidesSettings.guidesShown);
5595
 
        scrActions["viewShowColumnBorders"]->setOn(doc->guidesSettings.colBordersShown);
5596
 
        scrActions["viewShowBaseline"]->setOn(doc->guidesSettings.baseShown);
5597
 
        scrActions["viewShowTextChain"]->setOn(doc->guidesSettings.linkShown);
5598
 
        scrActions["viewShowTextControls"]->setOn(doc->guidesSettings.showControls);
5599
 
        scrActions["viewShowRulers"]->setOn(doc->guidesSettings.rulersShown);
5600
 
        scrActions["viewRulerMode"]->setOn(doc->guidesSettings.rulerMode);
 
5866
        scrActions["viewShowMargins"]->setChecked(doc->guidesSettings.marginsShown);
 
5867
        scrActions["viewShowBleeds"]->setChecked(doc->guidesSettings.showBleed);
 
5868
        scrActions["viewShowFrames"]->setChecked(doc->guidesSettings.framesShown);
 
5869
        scrActions["viewShowLayerMarkers"]->setChecked(doc->guidesSettings.layerMarkersShown);
 
5870
        scrActions["viewShowGrid"]->setChecked(doc->guidesSettings.gridShown);
 
5871
        scrActions["viewShowGuides"]->setChecked(doc->guidesSettings.guidesShown);
 
5872
        scrActions["viewShowColumnBorders"]->setChecked(doc->guidesSettings.colBordersShown);
 
5873
        scrActions["viewShowBaseline"]->setChecked(doc->guidesSettings.baseShown);
 
5874
        scrActions["viewShowTextChain"]->setChecked(doc->guidesSettings.linkShown);
 
5875
        scrActions["viewShowTextControls"]->setChecked(doc->guidesSettings.showControls);
 
5876
        scrActions["viewShowRulers"]->setChecked(doc->guidesSettings.rulersShown);
 
5877
        scrActions["viewRulerMode"]->setChecked(doc->guidesSettings.rulerMode);
5601
5878
        view->DrawNew();
5602
5879
}
5603
5880
 
5756
6033
        }
5757
6034
}
5758
6035
 
 
6036
 
 
6037
void ScribusMainWindow::toggleNodeEdit()
 
6038
{
 
6039
        if (!doc)
 
6040
                return;
 
6041
 
 
6042
        if (doc->appMode == modeEditClip)
 
6043
        {
 
6044
                view->requestMode(submodeEndNodeEdit);
 
6045
        }
 
6046
        else
 
6047
        {
 
6048
                view->requestMode(modeEditClip);
 
6049
        }
 
6050
}
 
6051
 
5759
6052
void ScribusMainWindow::ToggleFrameEdit()
5760
6053
{
5761
6054
        if (!doc)
5762
6055
                return;
5763
 
        if (doc->EditClip)
5764
 
        {
 
6056
        if (doc->appMode == modeEditClip)
5765
6057
                NoFrameEdit();
5766
 
        }
5767
6058
        else
5768
6059
        {
5769
6060
                //CB Enable/Disable undo in frame edit mode
5770
6061
//              undoManager->setUndoEnabled(false);
5771
6062
                scrActions["editUndoAction"]->setEnabled(false);
5772
6063
                scrActions["editRedoAction"]->setEnabled(false);
5773
 
                slotSelect();
 
6064
//done elsewhere now            slotSelect();
5774
6065
                nodePalette->setDoc(doc, view);
5775
6066
                nodePalette->MoveN();
5776
6067
                nodePalette->HaveNode(false, false);
5777
 
                nodePalette->MoveNode->setOn(true);
 
6068
                nodePalette->MoveNode->setChecked(true);
5778
6069
                nodePalette->show();
 
6070
//              qDebug() << "nodepalette show:" << nodePalette->geometry();
5779
6071
                connect(view, SIGNAL(HavePoint(bool, bool)), nodePalette, SLOT(HaveNode(bool, bool)));
5780
 
                doc->EditClipMode = 0;
5781
 
                doc->EditClip = true;
 
6072
                doc->nodeEdit.reset();
 
6073
//done elsewhere now            doc->appMode = modeEditClip;
5782
6074
                scrActions["toolsSelect"]->setEnabled(false);
5783
6075
                scrActions["toolsRotate"]->setEnabled(false);
5784
6076
                scrActions["toolsEditContents"]->setEnabled(false);
5792
6084
                scrActions["toolsInsertBezier"]->setEnabled(false);
5793
6085
                scrActions["toolsInsertFreehandLine"]->setEnabled(false);
5794
6086
                scrActions["toolsInsertPolygon"]->setEnabled(false);
 
6087
                scrActions["toolsInsertRenderFrame"]->setEnabled(false);
5795
6088
                scrActions["toolsLinkTextFrame"]->setEnabled(false);
5796
6089
                scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
5797
6090
                scrActions["toolsMeasurements"]->setEnabled(false);
5819
6112
                if (doc->m_Selection->count() != 0)
5820
6113
                {
5821
6114
                        PageItem *currItem = doc->m_Selection->itemAt(0);
5822
 
                        view->MarkClip(currItem, currItem->PoLine, true);
 
6115
//                      view->MarkClip(currItem, currItem->PoLine, true);
5823
6116
                        nodePalette->EditCont->setEnabled(currItem->ContourLine.size() != 0);
5824
6117
                        nodePalette->ResetCont->setEnabled(false);
5825
6118
                        nodePalette->ResetContClip->setEnabled(false);
5826
6119
                        nodePalette->PolyStatus(currItem->itemType(), currItem->PoLine.size());
5827
6120
                        if ((currItem->asImageFrame()) && (currItem->imageClip.size() != 0))
 
6121
                        {
 
6122
                                nodePalette->ResetContClip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(3), static_cast<QSizePolicy::Policy>(3)));
5828
6123
                                nodePalette->ResetContClip->show();
 
6124
                                nodePalette->ResetShape2Clip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(3), static_cast<QSizePolicy::Policy>(3)));
 
6125
                                nodePalette->ResetShape2Clip->show();
 
6126
                                nodePalette->layout()->activate();
 
6127
                                nodePalette->resize(QSize(170, 380).expandedTo(nodePalette->minimumSizeHint()));
 
6128
                        }
5829
6129
                        else
 
6130
                        {
 
6131
                                nodePalette->ResetContClip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(6), static_cast<QSizePolicy::Policy>(6)));
 
6132
                                nodePalette->ResetShape2Clip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(6), static_cast<QSizePolicy::Policy>(6)));
 
6133
                                nodePalette->layout()->activate();
5830
6134
                                nodePalette->ResetContClip->hide();
 
6135
                                nodePalette->ResetShape2Clip->hide();
 
6136
                                nodePalette->layout()->activate();
 
6137
                                nodePalette->resize(QSize(170, 380).expandedTo(nodePalette->minimumSizeHint()));
 
6138
                        }
5831
6139
                }
5832
6140
        }
5833
 
        scrActions["itemShapeEdit"]->setOn(doc->EditClip);
 
6141
        scrActions["itemShapeEdit"]->setChecked(doc->appMode == modeEditClip);
5834
6142
}
5835
6143
 
5836
6144
void ScribusMainWindow::NoFrameEdit()
5839
6147
        actionManager->disconnectModeActions();
5840
6148
        nodePalette->setDoc(0,0);
5841
6149
        nodePalette->hide();
 
6150
//      qDebug() << "nodepalette hide";
5842
6151
        scrActions["toolsSelect"]->setEnabled(true);
5843
 
        scrActions["toolsSelect"]->setOn(true);
 
6152
        scrActions["toolsSelect"]->setChecked(true);
5844
6153
        scrActions["toolsRotate"]->setEnabled(true);
5845
6154
        scrActions["toolsZoom"]->setEnabled(true);
5846
6155
        scrActions["toolsInsertTextFrame"]->setEnabled(true);
5851
6160
        scrActions["toolsInsertBezier"]->setEnabled(true);
5852
6161
        scrActions["toolsInsertFreehandLine"]->setEnabled(true);
5853
6162
        scrActions["toolsInsertPolygon"]->setEnabled(true);
 
6163
        scrActions["toolsInsertRenderFrame"]->setEnabled(true);
5854
6164
        scrActions["toolsPDFPushButton"]->setEnabled(true);
5855
6165
        scrActions["toolsPDFTextField"]->setEnabled(true);
5856
6166
        scrActions["toolsPDFCheckBox"]->setEnabled(true);
5858
6168
        scrActions["toolsPDFListBox"]->setEnabled(true);
5859
6169
        scrActions["toolsPDFAnnotText"]->setEnabled(true);
5860
6170
        scrActions["toolsPDFAnnotLink"]->setEnabled(true);
5861
 
        scrActions["toolsEditContents"]->setOn(false);
5862
 
        scrActions["toolsEditWithStoryEditor"]->setOn(false);
 
6171
        scrActions["toolsEditContents"]->setChecked(false);
 
6172
        scrActions["toolsEditWithStoryEditor"]->setChecked(false);
5863
6173
        scrActions["toolsMeasurements"]->setEnabled(true);
5864
6174
        scrActions["toolsCopyProperties"]->setEnabled(true);
5865
6175
        scrActions["toolsEyeDropper"]->setEnabled(true);
5866
6176
        scrActions["toolsUnlinkTextFrame"]->setEnabled(true);
5867
6177
        scrActions["itemDelete"]->setEnabled(true);
5868
 
        scrActions["itemShapeEdit"]->setOn(false);
 
6178
        scrActions["itemShapeEdit"]->setChecked(false);
5869
6179
        layerPalette->setEnabled(true);
5870
6180
        outlinePalette->setEnabled(true);
5871
6181
        guidePalette->setEnabled(true);
5880
6190
//      bool tmpClip = doc->EditClip; // for enabling undo if exiting shape edit mode
5881
6191
        if (HaveDoc)
5882
6192
        {
5883
 
                doc->EditClip = false;
5884
 
                view->EditContour = false;
 
6193
// done elsewhere now:          doc->appMode = modeNormal;
 
6194
                doc->nodeEdit.reset();
5885
6195
                if (doc->m_Selection->count() != 0)
5886
6196
                {
5887
6197
                        HaveNewSel(doc->m_Selection->itemAt(0)->itemType());
 
6198
                        doc->m_Selection->itemAt(0)->emitAllToGUI();
5888
6199
                        view->DrawNew();
5889
6200
                }
5890
6201
                else
5895
6206
//              undoManager->setUndoEnabled(true);
5896
6207
}
5897
6208
 
 
6209
/** This is the safest method to return to modeNormal
 
6210
*/
5898
6211
void ScribusMainWindow::slotSelect()
5899
6212
{
5900
 
        setAppMode(modeNormal);
 
6213
        if (doc)
 
6214
                view->requestMode(modeNormal);
 
6215
        else
 
6216
                setAppMode(modeNormal);
5901
6217
}
5902
6218
 
5903
6219
void ScribusMainWindow::setAppModeByToggle(bool isOn, int newMode)
5904
6220
{
5905
6221
        keyrep=false;
5906
 
        if (isOn)
5907
 
                setAppMode(newMode);
 
6222
        if (doc && isOn)
 
6223
                view->requestMode(newMode);
5908
6224
        else
5909
 
                setAppMode(modeNormal);
 
6225
                slotSelect();
5910
6226
}
5911
6227
 
5912
6228
void ScribusMainWindow::setAppMode(int mode)
5913
6229
{
 
6230
        assert(mode < submodeFirstSubmode);
 
6231
 
5914
6232
        //disconnect the tools actions so we dont fire them off
5915
6233
        actionManager->disconnectModeActions();
5916
6234
        //set the actions state based on incoming mode
5917
 
        scrActions["toolsSelect"]->setOn(mode==modeNormal);
5918
 
        scrActions["toolsInsertTextFrame"]->setOn(mode==modeDrawText);
5919
 
        scrActions["toolsInsertImageFrame"]->setOn(mode==modeDrawPicture);
5920
 
        scrActions["toolsInsertTableFrame"]->setOn(mode==modeDrawTable);
5921
 
        scrActions["toolsInsertShape"]->setOn(mode==modeDrawShapes);
5922
 
        scrActions["toolsInsertPolygon"]->setOn(mode==modeDrawRegularPolygon);
5923
 
        scrActions["toolsInsertLine"]->setOn(mode==modeDrawLine);
5924
 
        scrActions["toolsInsertBezier"]->setOn(mode==modeDrawBezierLine);
5925
 
        scrActions["toolsInsertFreehandLine"]->setOn(mode==modeDrawFreehandLine);
5926
 
        scrActions["toolsRotate"]->setOn(mode==modeRotation);
5927
 
        scrActions["toolsZoom"]->setOn(mode==modeMagnifier);
5928
 
        scrActions["toolsEditContents"]->setOn(mode==modeEdit);
5929
 
        scrActions["toolsEditWithStoryEditor"]->setOn(mode==modeStoryEditor);
5930
 
        scrActions["toolsLinkTextFrame"]->setOn(mode==modeLinkFrames);
5931
 
        scrActions["toolsUnlinkTextFrame"]->setOn(mode==modeUnlinkFrames);
5932
 
        scrActions["toolsEyeDropper"]->setOn(mode==modeEyeDropper);
5933
 
        scrActions["toolsCopyProperties"]->setOn(mode==modeCopyProperties);
5934
 
        scrActions["toolsPDFPushButton"]->setOn(mode==modeInsertPDFButton);
5935
 
        scrActions["toolsPDFTextField"]->setOn(mode==modeInsertPDFTextfield);
5936
 
        scrActions["toolsPDFCheckBox"]->setOn(mode==modeInsertPDFCheckbox);
5937
 
        scrActions["toolsPDFComboBox"]->setOn(mode==modeInsertPDFCombobox);
5938
 
        scrActions["toolsPDFListBox"]->setOn(mode==modeInsertPDFListbox);
5939
 
        scrActions["toolsPDFAnnotText"]->setOn(mode==modeInsertPDFTextAnnotation);
5940
 
        scrActions["toolsPDFAnnotLink"]->setOn(mode==modeInsertPDFLinkAnnotation);
 
6235
        scrActions["toolsSelect"]->setChecked(mode==modeNormal);
 
6236
        scrActions["toolsInsertTextFrame"]->setChecked(mode==modeDrawText);
 
6237
        scrActions["toolsInsertImageFrame"]->setChecked(mode==modeDrawImage);
 
6238
        scrActions["toolsInsertTableFrame"]->setChecked(mode==modeDrawTable);
 
6239
        scrActions["toolsInsertShape"]->setChecked(mode==modeDrawShapes);
 
6240
        scrActions["toolsInsertPolygon"]->setChecked(mode==modeDrawRegularPolygon);
 
6241
        scrActions["toolsInsertLine"]->setChecked(mode==modeDrawLine);
 
6242
        scrActions["toolsInsertBezier"]->setChecked(mode==modeDrawBezierLine);
 
6243
        scrActions["toolsInsertFreehandLine"]->setChecked(mode==modeDrawFreehandLine);
 
6244
        scrActions["toolsInsertRenderFrame"]->setChecked(mode==modeDrawLatex);
 
6245
        scrActions["toolsRotate"]->setChecked(mode==modeRotation);
 
6246
        scrActions["toolsZoom"]->setChecked(mode==modeMagnifier);
 
6247
        scrActions["toolsEditContents"]->setChecked(mode==modeEdit);
 
6248
        scrActions["toolsEditWithStoryEditor"]->setChecked(mode==modeStoryEditor);
 
6249
        scrActions["toolsLinkTextFrame"]->setChecked(mode==modeLinkFrames);
 
6250
        scrActions["toolsUnlinkTextFrame"]->setChecked(mode==modeUnlinkFrames);
 
6251
        scrActions["toolsEyeDropper"]->setChecked(mode==modeEyeDropper);
 
6252
        scrActions["toolsMeasurements"]->setChecked(mode==modeMeasurementTool);
 
6253
        scrActions["toolsCopyProperties"]->setChecked(mode==modeCopyProperties);
 
6254
        scrActions["toolsPDFPushButton"]->setChecked(mode==modeInsertPDFButton);
 
6255
        scrActions["toolsPDFTextField"]->setChecked(mode==modeInsertPDFTextfield);
 
6256
        scrActions["toolsPDFCheckBox"]->setChecked(mode==modeInsertPDFCheckbox);
 
6257
        scrActions["toolsPDFComboBox"]->setChecked(mode==modeInsertPDFCombobox);
 
6258
        scrActions["toolsPDFListBox"]->setChecked(mode==modeInsertPDFListbox);
 
6259
        scrActions["toolsPDFAnnotText"]->setChecked(mode==modeInsertPDFTextAnnotation);
 
6260
        scrActions["toolsPDFAnnotLink"]->setChecked(mode==modeInsertPDFLinkAnnotation);
5941
6261
 
5942
6262
        if (HaveDoc)
5943
6263
        {
5945
6265
                if (doc->m_Selection->count() != 0)
5946
6266
                        currItem = doc->m_Selection->itemAt(0);
5947
6267
                int oldMode = doc->appMode;
 
6268
                if (oldMode == modeEditClip && mode != modeEditClip)
 
6269
                        NoFrameEdit();
 
6270
                else if (oldMode != modeEditClip && mode == modeEditClip)
 
6271
                        ToggleFrameEdit();
5948
6272
                doc->appMode = mode;
5949
 
                if (oldMode == modeMeasurementTool)
5950
 
                        disconnect(view, SIGNAL(MVals(double, double, double, double, double, double, int )), measurementPalette, SLOT(setValues(double, double, double, double, double, double, int )));
5951
 
                if (mode != modeEdit && doc->CurTimer!=NULL)
 
6273
//              if (oldMode == modeMeasurementTool)
 
6274
//                      disconnect(view, SIGNAL(MVals(double, double, double, double, double, double, int )), measurementPalette, SLOT(setValues(double, double, double, double, double, double, int )));
 
6275
/*              if (mode != modeEdit && doc->CurTimer!=NULL)
5952
6276
                {
5953
6277
                        disconnect(doc->CurTimer, SIGNAL(timeout()), view, SLOT(blinkCursor()));
5954
6278
                        doc->CurTimer->stop();
5955
6279
                        delete doc->CurTimer;
5956
6280
                        doc->CurTimer = NULL;
5957
 
                }
 
6281
                } */
5958
6282
                if (mode!=modeEdit && oldMode==modeEdit)
5959
6283
                        actionManager->restoreActionShortcutsPostEditMode();
5960
6284
                else
5962
6286
                        actionManager->saveActionShortcutsPreEditMode();
5963
6287
                if (oldMode == modeEdit)
5964
6288
                {
5965
 
                        view->zoomSpinBox->setFocusPolicy(QWidget::ClickFocus);
5966
 
                        view->pageSelector->focusPolicy(QWidget::ClickFocus);
 
6289
                        view->zoomSpinBox->setFocusPolicy(Qt::ClickFocus);
 
6290
                        view->pageSelector->setFocusPolicy(Qt::ClickFocus);
5967
6291
                        scrActions["editClearContents"]->setEnabled(false);
5968
6292
                        charPalette->setEnabled(false, 0);
5969
 
                        view->slotDoCurs(false);
 
6293
//                      view->slotDoCurs(false);
5970
6294
                        if (currItem != 0)
5971
6295
                        {
5972
 
                                view->RefreshItem(currItem);
5973
 
                                scrMenuMgr->setMenuEnabled("Style", true);
 
6296
                                currItem->update();
5974
6297
                                scrMenuMgr->setMenuEnabled("Item", true);
5975
6298
                        }
5976
6299
                        view->horizRuler->ItemPosValid = false;
5977
 
                        view->horizRuler->repaint();
 
6300
                        view->horizRuler->update();
5978
6301
                }
5979
6302
                if (mode == modeEdit)
5980
6303
                {
5981
6304
//                      view->zoomSpinBox->setFocusPolicy(QWidget::NoFocus);
5982
 
                        view->pageSelector->focusPolicy(QWidget::NoFocus);
 
6305
//                      view->pageSelector->setFocusPolicy(QWidget::NoFocus);
5983
6306
                        if (currItem != 0)
5984
6307
                        {
5985
 
                                if ((currItem->itemType() == PageItem::Polygon) || (currItem->itemType() == PageItem::PolyLine) || (currItem->itemType() == PageItem::PathText))
5986
 
                                {
5987
 
                                        doc->appMode = 1;
5988
 
                                        ToggleFrameEdit();
5989
 
                                        return;
5990
 
                                }
 
6308
//                              if ((currItem->itemType() == PageItem::Polygon) || (currItem->itemType() == PageItem::PolyLine) || (currItem->itemType() == PageItem::PathText))
 
6309
//                              {
 
6310
//                                      doc->appMode = modeNormal;
 
6311
//                                      view->requestMode(modeEditClip);
 
6312
//                                      return;
 
6313
//                              }
5991
6314
                                setTBvals(currItem);
5992
6315
                                currItem->CPos = 0;
5993
6316
                        }
5995
6318
                        charPalette->setEnabled(true, currItem);
5996
6319
                        if (currItem!=NULL && currItem->asTextFrame())
5997
6320
                                enableTextActions(&scrActions, true, currItem->currentCharStyle().font().scName());
5998
 
                        if (!Buffer2.isNull())
 
6321
                        if (ScMimeData::clipboardHasScribusData())
5999
6322
                        {
6000
6323
//                              if (!hasXMLRootElem(Buffer2, "<SCRIBUSELEM"))
6001
6324
//                              {
6002
 
                                        BuFromApp = false;
6003
6325
                                        scrActions["editPaste"]->setEnabled(true);
6004
6326
//                              }
6005
6327
                        }
6006
 
                        view->slotDoCurs(true);
 
6328
//                      view->slotDoCurs(true);
6007
6329
                        scrMenuMgr->setMenuEnabled("Item", false);
6008
 
                        scrMenuMgr->setMenuEnabled("Style", false);
6009
 
                        doc->CurTimer = new QTimer(view);
 
6330
/*                      doc->CurTimer = new QTimer(view);
6010
6331
                        if (doc->CurTimer!=NULL)
6011
6332
                        {
6012
6333
                                connect(doc->CurTimer, SIGNAL(timeout()), view, SLOT(blinkCursor()));
6013
6334
                                doc->CurTimer->start(500);
6014
 
                        }
 
6335
                        } */
6015
6336
                        if (currItem != 0)
6016
6337
                        {
6017
6338
                                scrActions["editCut"]->setEnabled(currItem->HasSel);
6019
6340
                                scrActions["editClearContents"]->setEnabled(currItem->HasSel);
6020
6341
                                scrActions["editSearchReplace"]->setEnabled(true);
6021
6342
 
6022
 
                                view->RefreshItem(currItem);
 
6343
                                // Why the hell do you want to update the item here? - pm
 
6344
//                              currItem->update();
6023
6345
                        }
6024
6346
                }
6025
6347
                int docSelectionCount=doc->m_Selection->count();
6026
6348
                if (mode == modeDrawBezierLine)
6027
6349
                {
6028
 
                        if (docSelectionCount != 0)
 
6350
                        if ((docSelectionCount != 0) && (!prefsManager->appPrefs.stickyTools))
6029
6351
                                view->Deselect(true);
6030
6352
                        view->FirstPoly = true;
6031
6353
                }
6032
6354
                if (mode == modeEditGradientVectors)
6033
6355
                        propertiesPalette->setGradientEditMode(true);
6034
 
                if (mode == modeMeasurementTool)
6035
 
                {
6036
 
                        measurementPalette->show();
6037
 
                        connect(view, SIGNAL(MVals(double, double, double, double, double, double, int)), measurementPalette, SLOT(setValues(double, double, double, double, double, double, int )));
6038
 
                }
 
6356
//              if (mode == modeMeasurementTool)
 
6357
//              {
 
6358
//                      measurementPalette->show();
 
6359
//                      connect(view, SIGNAL(MVals(double, double, double, double, double, double, int)), measurementPalette, SLOT(setValues(double, double, double, double, double, double, int )));
 
6360
//              }
6039
6361
                switch (mode)
6040
6362
                {
6041
6363
                        case modeDrawShapes:
6042
6364
                                if (docSelectionCount!=0)
6043
6365
                                        view->Deselect(true);
6044
 
                                qApp->setOverrideCursor(QCursor(loadIcon("DrawFrame.xpm")), true);
6045
 
                                break;
6046
 
                        case modeDrawPicture:
6047
 
                                if (docSelectionCount!=0)
6048
 
                                        view->Deselect(true);
6049
 
                                qApp->setOverrideCursor(QCursor(loadIcon("DrawImageFrame.xpm")), true);
 
6366
                                qApp->changeOverrideCursor(QCursor(loadIcon("DrawFrame.xpm")));
 
6367
                                break;
 
6368
                        case modeDrawImage:
 
6369
                                if (docSelectionCount!=0)
 
6370
                                        view->Deselect(true);
 
6371
                                qApp->changeOverrideCursor(QCursor(loadIcon("DrawImageFrame.xpm")));
 
6372
                                break;
 
6373
                        case modeDrawLatex:
 
6374
                                if (docSelectionCount!=0)
 
6375
                                        view->Deselect(true);
 
6376
                                qApp->changeOverrideCursor(QCursor(loadIcon("DrawLatexFrame.xpm")));
6050
6377
                                break;
6051
6378
                        case modeDrawText:
6052
6379
                                if (docSelectionCount!=0)
6053
6380
                                        view->Deselect(true);
6054
 
                                qApp->setOverrideCursor(QCursor(loadIcon("DrawTextFrame.xpm")), true);
 
6381
                                qApp->changeOverrideCursor(QCursor(loadIcon("DrawTextFrame.xpm")));
6055
6382
                                break;
6056
6383
                        case modeDrawTable:
6057
6384
                                if (docSelectionCount!=0)
6058
6385
                                        view->Deselect(true);
6059
 
                                qApp->setOverrideCursor(QCursor(loadIcon("DrawTable.xpm")), true);
 
6386
                                qApp->changeOverrideCursor(QCursor(loadIcon("DrawTable.xpm")));
6060
6387
                                break;
6061
6388
                        case modeDrawRegularPolygon:
6062
6389
                                if (docSelectionCount!=0)
6063
6390
                                        view->Deselect(true);
6064
 
                                qApp->setOverrideCursor(QCursor(loadIcon("DrawPolylineFrame.xpm")), true);
 
6391
                                qApp->changeOverrideCursor(QCursor(loadIcon("DrawPolylineFrame.xpm")));
6065
6392
                                break;
6066
6393
                        case modeMagnifier:
6067
6394
                                if (docSelectionCount!=0)
6068
6395
                                        view->Deselect(true);
6069
 
                                qApp->setOverrideCursor(QCursor(loadIcon("LupeZ.xpm")), true);
 
6396
                                view->Magnify = true;
 
6397
                                qApp->changeOverrideCursor(QCursor(loadIcon("LupeZ.xpm")));
6070
6398
                                break;
6071
6399
                        case modePanning:
6072
 
                                qApp->setOverrideCursor(QCursor(loadIcon("HandC.xpm")), true);
 
6400
                                qApp->changeOverrideCursor(QCursor(loadIcon("HandC.xpm")));
6073
6401
                                break;
6074
6402
                        case modeDrawLine:
6075
6403
                        case modeDrawBezierLine:
6076
 
                                qApp->setOverrideCursor(QCursor(crossCursor), true);
 
6404
                                qApp->changeOverrideCursor(QCursor(Qt::CrossCursor));
6077
6405
                                break;
6078
6406
                        case modeDrawFreehandLine:
6079
 
                                qApp->setOverrideCursor(QCursor(loadIcon("DrawFreeLine.png"), 0, 32), true);
 
6407
                                qApp->changeOverrideCursor(QCursor(loadIcon("DrawFreeLine.png"), 0, 32));
6080
6408
                                break;
6081
6409
                        case modeEyeDropper:
6082
 
                                qApp->setOverrideCursor(QCursor(loadIcon("colorpickercursor.png"), 0, 32), true);
 
6410
                                qApp->changeOverrideCursor(QCursor(loadIcon("colorpickercursor.png"), 0, 32));
6083
6411
                                break;
6084
6412
                        case modeInsertPDFButton:
6085
6413
                        case modeInsertPDFTextfield:
6090
6418
                        case modeInsertPDFLinkAnnotation:
6091
6419
                                if (docSelectionCount!=0)
6092
6420
                                        view->Deselect(true);
6093
 
                                qApp->setOverrideCursor(QCursor(CrossCursor), true);
 
6421
                                qApp->changeOverrideCursor(QCursor(Qt::CrossCursor));
6094
6422
                                break;
6095
6423
                        case modeMeasurementTool:
6096
6424
                        case modeEditGradientVectors:
6097
 
                                qApp->setOverrideCursor(QCursor(CrossCursor), true);
 
6425
                                qApp->changeOverrideCursor(QCursor(Qt::CrossCursor));
6098
6426
                                break;
6099
6427
                        default:
6100
 
                                qApp->setOverrideCursor(QCursor(ArrowCursor), true);
 
6428
                                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
6101
6429
                        break;
6102
6430
                }
6103
6431
                if (mode == modeDrawShapes)
6104
6432
                {
6105
 
                        doc->SubMode = mainToolBar->SubMode;
6106
 
                        doc->ShapeValues = mainToolBar->ShapeVals;
6107
 
                        doc->ValCount = mainToolBar->ValCount;
6108
 
                        propertiesPalette->SCustom->setPixmap(propertiesPalette->SCustom->getIconPixmap(doc->SubMode));
6109
 
                        SCustom->setPixmap(SCustom->getIconPixmap(doc->SubMode));
 
6433
                        doc->SubMode = modeToolBar->SubMode;
 
6434
                        doc->ShapeValues = modeToolBar->ShapeVals;
 
6435
                        doc->ValCount = modeToolBar->ValCount;
 
6436
                        propertiesPalette->SCustom->setIcon(propertiesPalette->SCustom->getIconPixmap(doc->SubMode));
6110
6437
                }
6111
6438
                else
6112
6439
                        doc->SubMode = -1;
6117
6444
                if (mode == modeLinkFrames)
6118
6445
                        doc->ElemToLink = doc->m_Selection->itemAt(0);
6119
6446
                if ((mode == modeLinkFrames) || (mode == modeUnlinkFrames) || (oldMode == modeLinkFrames) || (oldMode == modeUnlinkFrames))
6120
 
                        view->updateContents();
 
6447
                        doc->regionsChanged()->update(QRect());
 
6448
 
6121
6449
                if (mode == modeStoryEditor)
6122
6450
                {
6123
6451
                        slotStoryEditor();
6137
6465
                        }
6138
6466
                }
6139
6467
                if (mode != modeNormal && mode != modeStoryEditor)
6140
 
                        setActiveWindow();
 
6468
                        activateWindow();
 
6469
                PluginManager& pluginManager(PluginManager::instance());
 
6470
                pluginManager.enablePluginActionsForSelection(this);
 
6471
/*
 
6472
                QStringList pluginNames(pluginManager.pluginNames(false));
 
6473
                ScPlugin* plugin;
 
6474
                ScActionPlugin* ixplug;
 
6475
                ScrAction* pluginAction = 0;
 
6476
                QString pName;
 
6477
                for (int i = 0; i < pluginNames.count(); ++i)
 
6478
                {
 
6479
                        pName = pluginNames.at(i);
 
6480
                        plugin = pluginManager.getPlugin(pName, true);
 
6481
                        Q_ASSERT(plugin); // all the returned names should represent loaded plugins
 
6482
                        if (plugin->inherits("ScActionPlugin"))
 
6483
                        {
 
6484
                                ixplug = dynamic_cast<ScActionPlugin*>(plugin);
 
6485
                                Q_ASSERT(ixplug);
 
6486
                                ScActionPlugin::ActionInfo ai(ixplug->actionInfo());
 
6487
                                pluginAction = ScCore->primaryMainWindow()->scrActions[ai.name];
 
6488
                                if (pluginAction != 0)
 
6489
                                {
 
6490
                                        if (doc->m_Selection->count() != 0)
 
6491
                                                pluginAction->setEnabled(ixplug->handleSelection(doc, doc->m_Selection->itemAt(0)->itemType()));
 
6492
                                        else
 
6493
                                                pluginAction->setEnabled(ixplug->handleSelection(doc));
 
6494
                                }
 
6495
                        }
 
6496
                }
 
6497
*/
6141
6498
        }
6142
6499
        actionManager->connectModeActions();
6143
6500
}
6144
6501
 
6145
6502
void ScribusMainWindow::setMainWindowActive()
6146
6503
{
6147
 
        setActiveWindow();
6148
 
        raise();
 
6504
        activateWindow();
 
6505
        if (!ScriptRunning)
 
6506
                raise();
6149
6507
}
6150
6508
 
6151
6509
void ScribusMainWindow::setItemTypeStyle(int id)
6153
6511
        int b = 0;
6154
6512
        if (id == 0)
6155
6513
        {
6156
 
                scrActions["typeEffectNormal"]->setOn(true);
6157
 
                scrActions["typeEffectUnderline"]->setOn(false);
6158
 
                scrActions["typeEffectUnderlineWords"]->setOn(false);
6159
 
                scrActions["typeEffectStrikeThrough"]->setOn(false);
6160
 
                scrActions["typeEffectSmallCaps"]->setOn(false);
6161
 
                scrActions["typeEffectAllCaps"]->setOn(false);
6162
 
                scrActions["typeEffectSuperscript"]->setOn(false);
6163
 
                scrActions["typeEffectSubscript"]->setOn(false);
6164
 
                scrActions["typeEffectOutline"]->setOn(false);
6165
 
                scrActions["typeEffectShadow"]->setOn(false);
 
6514
                scrActions["typeEffectNormal"]->setChecked(true);
 
6515
                scrActions["typeEffectUnderline"]->setChecked(false);
 
6516
                scrActions["typeEffectUnderlineWords"]->setChecked(false);
 
6517
                scrActions["typeEffectStrikeThrough"]->setChecked(false);
 
6518
                scrActions["typeEffectSmallCaps"]->setChecked(false);
 
6519
                scrActions["typeEffectAllCaps"]->setChecked(false);
 
6520
                scrActions["typeEffectSuperscript"]->setChecked(false);
 
6521
                scrActions["typeEffectSubscript"]->setChecked(false);
 
6522
                scrActions["typeEffectOutline"]->setChecked(false);
 
6523
                scrActions["typeEffectShadow"]->setChecked(false);
6166
6524
        }
6167
6525
        else
6168
6526
        {
6169
 
                scrActions["typeEffectNormal"]->setOn(false);
 
6527
                scrActions["typeEffectNormal"]->setChecked(false);
6170
6528
                if (id == 4)
6171
 
                        scrActions["typeEffectSubscript"]->setOn(false);
 
6529
                        scrActions["typeEffectSubscript"]->setChecked(false);
6172
6530
                if (id == 5)
6173
 
                        scrActions["typeEffectSuperscript"]->setOn(false);
 
6531
                        scrActions["typeEffectSuperscript"]->setChecked(false);
6174
6532
                if (id == 3)
6175
 
                        scrActions["typeEffectAllCaps"]->setOn(false);
 
6533
                        scrActions["typeEffectAllCaps"]->setChecked(false);
6176
6534
                if (id == 7)
6177
 
                        scrActions["typeEffectSmallCaps"]->setOn(false);
 
6535
                        scrActions["typeEffectSmallCaps"]->setChecked(false);
6178
6536
                if (id == 8)
6179
 
                        scrActions["typeEffectUnderline"]->setOn(false);
 
6537
                        scrActions["typeEffectUnderline"]->setChecked(false);
6180
6538
                if (id == 1)
6181
 
                        scrActions["typeEffectUnderlineWords"]->setOn(false);
6182
 
                if (scrActions["typeEffectUnderline"]->isOn())
 
6539
                        scrActions["typeEffectUnderlineWords"]->setChecked(false);
 
6540
                if (scrActions["typeEffectUnderline"]->isChecked())
6183
6541
                        b |= 8;
6184
 
                if (scrActions["typeEffectUnderlineWords"]->isOn())
 
6542
                if (scrActions["typeEffectUnderlineWords"]->isChecked())
6185
6543
                        b |= 512;
6186
 
                if (scrActions["typeEffectShadow"]->isOn())
 
6544
                if (scrActions["typeEffectShadow"]->isChecked())
6187
6545
                        b |= 256;
6188
 
                if (scrActions["typeEffectStrikeThrough"]->isOn())
 
6546
                if (scrActions["typeEffectStrikeThrough"]->isChecked())
6189
6547
                        b |= 16;
6190
 
                if (scrActions["typeEffectAllCaps"]->isOn())
 
6548
                if (scrActions["typeEffectAllCaps"]->isChecked())
6191
6549
                        b |= 32;
6192
 
                if (scrActions["typeEffectSmallCaps"]->isOn())
 
6550
                if (scrActions["typeEffectSmallCaps"]->isChecked())
6193
6551
                        b |= 64;
6194
 
                if (scrActions["typeEffectSuperscript"]->isOn())
 
6552
                if (scrActions["typeEffectSuperscript"]->isChecked())
6195
6553
                        b |= 1;
6196
 
                if (scrActions["typeEffectSubscript"]->isOn())
 
6554
                if (scrActions["typeEffectSubscript"]->isChecked())
6197
6555
                        b |= 2;
6198
 
                if (scrActions["typeEffectOutline"]->isOn())
 
6556
                if (scrActions["typeEffectOutline"]->isChecked())
6199
6557
                        b |= 4;
6200
6558
        }
6201
6559
        setItemHoch(b);
6205
6563
{
6206
6564
        int c = s & 1919;
6207
6565
//      doc->currentStyle.charStyle().setFeatures(static_cast<StyleFlag>(c).featureList());
6208
 
        scrActions["typeEffectNormal"]->setOn(c==0);
6209
 
        scrActions["typeEffectSuperscript"]->setOn(c & 1);
6210
 
        scrActions["typeEffectSubscript"]->setOn(c & 2);
6211
 
        scrActions["typeEffectOutline"]->setOn(c & 4);
6212
 
        scrActions["typeEffectUnderline"]->setOn(c & 8);
6213
 
        scrActions["typeEffectStrikeThrough"]->setOn(c & 16);
6214
 
        scrActions["typeEffectAllCaps"]->setOn(c & 32);
6215
 
        scrActions["typeEffectSmallCaps"]->setOn(c & 64);
6216
 
        scrActions["typeEffectShadow"]->setOn(c & 256);
6217
 
        scrActions["typeEffectUnderlineWords"]->setOn(c & 512);
 
6566
        scrActions["typeEffectNormal"]->setChecked(c==0);
 
6567
        scrActions["typeEffectSuperscript"]->setChecked(c & 1);
 
6568
        scrActions["typeEffectSubscript"]->setChecked(c & 2);
 
6569
        scrActions["typeEffectOutline"]->setChecked(c & 4);
 
6570
        scrActions["typeEffectUnderline"]->setChecked(c & 8);
 
6571
        scrActions["typeEffectStrikeThrough"]->setChecked(c & 16);
 
6572
        scrActions["typeEffectAllCaps"]->setChecked(c & 32);
 
6573
        scrActions["typeEffectSmallCaps"]->setChecked(c & 64);
 
6574
        scrActions["typeEffectShadow"]->setChecked(c & 256);
 
6575
        scrActions["typeEffectUnderlineWords"]->setChecked(c & 512);
6218
6576
        emit TextStil(s);
6219
6577
}
6220
6578
 
6231
6589
//CB-->Doc partly
6232
6590
void ScribusMainWindow::DeletePage2(int pg)
6233
6591
{
6234
 
        PageItem* ite;
6235
 
        NoFrameEdit();
 
6592
        if (HaveDoc && doc->appMode == modeEditClip)
 
6593
                view->requestMode(submodeEndNodeEdit);
 
6594
        view->Deselect(true);
6236
6595
        if (doc->Pages->count() == 1)
6237
6596
                return;
6238
 
        uint oldPg = doc->currentPageNumber();
6239
 
        guidePalette->setDoc(NULL);
6240
 
        if (UndoManager::undoEnabled())
6241
 
                undoManager->beginTransaction(doc->DocName, Um::IDocument, Um::DeletePage, "", Um::IDelete);
6242
 
/*      if (!doc->masterPageMode)
6243
 
                disconnect(doc->currentPage, SIGNAL(DelObj(uint, uint)), outlinePalette, SLOT(slotRemoveElement(uint, uint))); */
6244
 
        doc->m_Selection->clear();
6245
 
        for (uint d = 0; d < doc->Items->count(); ++d)
6246
 
        {
6247
 
                ite = doc->Items->at(d);
6248
 
                if (ite->OwnPage == pg)
6249
 
                {
6250
 
                        ite->setLocked(false);
6251
 
                        ite->isSingleSel = false;
6252
 
                        if (ite->isBookmark)
6253
 
                                DelBookMark(ite);
6254
 
                        ite->isBookmark = false;
6255
 
                        doc->m_Selection->addItem(ite);
6256
 
                }
6257
 
        }
6258
 
        if (doc->m_Selection->count() != 0)
6259
 
                doc->itemSelection_DeleteItem();
6260
 
        Page *page = doc->Pages->at(pg); // need to remove guides too to get their undo/redo actions working
6261
 
        page->guides.clearHorizontals(GuideManagerCore::Standard);
6262
 
        page->guides.clearHorizontals(GuideManagerCore::Auto);
6263
 
        page->guides.clearVerticals(GuideManagerCore::Standard);
6264
 
        page->guides.clearVerticals(GuideManagerCore::Auto);
6265
 
        if (UndoManager::undoEnabled())
6266
 
        {
6267
 
                SimpleState *ss = new SimpleState(Um::DeletePage, "", Um::ICreate);
6268
 
                ss->set("DELETE_PAGE", "delete_page");
6269
 
                ss->set("PAGENR", pg + 1);
6270
 
                ss->set("MASTERPAGE", doc->Pages->at(pg)->MPageNam);
6271
 
                // replace the deleted page in the undostack by a dummy object that will
6272
 
                // replaced with the "undone" page if user choose to undo the action
6273
 
                DummyUndoObject *duo = new DummyUndoObject();
6274
 
                uint id = static_cast<uint>(duo->getUId());
6275
 
                undoManager->replaceObject(doc->Pages->at(pg)->getUId(), duo);
6276
 
                ss->set("DUMMY_ID", id);
6277
 
                undoManager->action(this, ss);
6278
 
        }
6279
 
        if (doc->masterPageMode())
6280
 
                doc->deleteMasterPage(pg);
6281
 
        else
6282
 
                doc->deletePage(pg);
6283
 
        disconnect(view->pageSelector, SIGNAL(GotoPage(int)), view, SLOT(GotoPa(int)));
6284
 
        view->pageSelector->setMaxValue(doc->Pages->count());
6285
 
        view->pageSelector->GotoPg(0);
6286
 
        connect(view->pageSelector, SIGNAL(GotoPage(int)), view, SLOT(GotoPa(int)));
6287
 
        undoManager->setUndoEnabled(false); // ugly hack to prevent object moving when undoing page deletion
6288
 
        view->reformPages();
6289
 
        undoManager->setUndoEnabled(true); // ugly hack continues
6290
 
        view->GotoPage(QMIN(doc->Pages->count()-1, oldPg));
6291
 
        view->DrawNew();
6292
 
        if (outlinePalette->isVisible())
6293
 
                outlinePalette->BuildTree();
6294
 
        //CB done by doc::reformpages
6295
 
        //slotDocCh();
6296
 
        pagePalette->RebuildPage();
6297
 
        if (UndoManager::undoEnabled())
6298
 
                undoManager->commit();
 
6597
        DeletePage(pg+1, pg+1);
6299
6598
}
6300
6599
 
6301
6600
void ScribusMainWindow::DeletePage()
6302
6601
{
6303
 
        NoFrameEdit();
 
6602
        if (HaveDoc && doc->appMode == modeEditClip)
 
6603
                view->requestMode(submodeEndNodeEdit);
6304
6604
        view->Deselect(true);
6305
6605
        DelPages *dia = new DelPages(this, doc->currentPage()->pageNr()+1, doc->Pages->count());
6306
6606
        if (dia->exec())
6310
6610
 
6311
6611
void ScribusMainWindow::DeletePage(int from, int to)
6312
6612
{
 
6613
        UndoTransaction* activeTransaction = NULL;
6313
6614
        assert( from > 0 );
6314
6615
        assert( from <= to );
6315
 
        assert( to <= signed(doc->Pages->count()) );
6316
 
        uint oldPg = doc->currentPageNumber();
 
6616
        assert( to <= static_cast<int>(doc->Pages->count()) );
 
6617
        int oldPg = doc->currentPageNumber();
6317
6618
        guidePalette->setDoc(NULL);
6318
6619
        if (UndoManager::undoEnabled())
6319
 
                undoManager->beginTransaction(doc->DocName, Um::IDocument,
6320
 
                                                                          (from - to == 0) ? Um::DeletePage : Um::DeletePages, "",
6321
 
                                                                          Um::IDelete);
 
6620
                activeTransaction = new UndoTransaction(undoManager->beginTransaction(doc->DocName, Um::IDocument,
 
6621
                                                                                                                                                          (from - to == 0) ? Um::DeletePage : Um::DeletePages, "",
 
6622
                                                                                                                                                          Um::IDelete));
6322
6623
        PageItem* ite;
6323
6624
        doc->m_Selection->clear();
 
6625
        Selection tmpSelection(this, false);
6324
6626
        for (int a = to - 1; a >= from - 1; a--)
6325
6627
        {
6326
 
                for (uint d = 0; d < doc->Items->count(); ++d)
 
6628
                for (int d = 0; d < doc->Items->count(); ++d)
6327
6629
                {
6328
6630
                        ite = doc->Items->at(d);
6329
6631
                        if (ite->OwnPage == a)
6333
6635
                                if (ite->isBookmark)
6334
6636
                                        DelBookMark(ite);
6335
6637
                                ite->isBookmark = false;
6336
 
                                doc->m_Selection->addItem(ite);
 
6638
                                tmpSelection.addItem(ite);
6337
6639
                        }
6338
6640
                }
6339
6641
                Page *page = doc->Pages->at(a); // need to remove guides too to get their undo/redo actions working
6342
6644
                page->guides.clearVerticals(GuideManagerCore::Standard);
6343
6645
                page->guides.clearVerticals(GuideManagerCore::Auto);
6344
6646
        }
6345
 
        if (doc->m_Selection->count() != 0)
6346
 
                doc->itemSelection_DeleteItem();
 
6647
        if (tmpSelection.count() != 0)
 
6648
                doc->itemSelection_DeleteItem(&tmpSelection);
6347
6649
        for (int a = to - 1; a >= from - 1; a--)
6348
6650
        {
6349
6651
                if (UndoManager::undoEnabled())
6351
6653
                        SimpleState *ss = new SimpleState(Um::DeletePage, "", Um::ICreate);
6352
6654
                        ss->set("DELETE_PAGE", "delete_page");
6353
6655
                        ss->set("PAGENR", a + 1);
 
6656
                        ss->set("PAGENAME",   doc->Pages->at(a)->pageName());
6354
6657
                        ss->set("MASTERPAGE", doc->Pages->at(a)->MPageNam);
6355
6658
                        // replace the deleted page in the undostack by a dummy object that will
6356
6659
                        // replaced with the "undone" page if user choose to undo the action
6360
6663
                        ss->set("DUMMY_ID", id);
6361
6664
                        undoManager->action(this, ss);
6362
6665
                }
 
6666
                bool isMasterPage = !(doc->Pages->at(a)->pageName().isEmpty());
6363
6667
                if (doc->masterPageMode())
6364
6668
                        doc->deleteMasterPage(a);
6365
6669
                else
6366
6670
                        doc->deletePage(a);
6367
6671
                disconnect(view->pageSelector, SIGNAL(GotoPage(int)), view, SLOT(GotoPa(int)));
6368
 
                view->pageSelector->setMaxValue(doc->Pages->count());
 
6672
                view->pageSelector->setMaximum(doc->Pages->count());
6369
6673
                view->pageSelector->GotoPg(0);
6370
6674
                connect(view->pageSelector, SIGNAL(GotoPage(int)), view, SLOT(GotoPa(int)));
6371
 
                doc->removePageFromSection(a);
 
6675
                if (!isMasterPage) // Master pages are not added to sections when created
 
6676
                        doc->removePageFromSection(a);
6372
6677
        }
6373
6678
        undoManager->setUndoEnabled(false); // ugly hack to disable object moving when undoing page deletion
6374
6679
        view->reformPages();
6375
6680
        undoManager->setUndoEnabled(true); // ugly hack continues
6376
 
        view->GotoPage(QMIN(doc->Pages->count()-1, oldPg));
 
6681
        view->GotoPage(qMin(doc->Pages->count()-1, oldPg));
6377
6682
        view->DrawNew();
6378
6683
        if (outlinePalette->isVisible())
6379
6684
                outlinePalette->BuildTree();
6380
 
        pagePalette->RebuildPage();
6381
 
        if (UndoManager::undoEnabled())
6382
 
                undoManager->commit();
 
6685
        doc->rebuildMasterNames();
 
6686
        pagePalette->rebuildPages();
 
6687
        pagePalette->rebuildMasters();
 
6688
        if (activeTransaction)
 
6689
        {
 
6690
                activeTransaction->commit();
 
6691
                delete activeTransaction;
 
6692
                activeTransaction = NULL;
 
6693
        }
6383
6694
}
6384
6695
 
6385
6696
void ScribusMainWindow::MovePage()
6386
6697
{
6387
 
        NoFrameEdit();
 
6698
        if (HaveDoc && doc->appMode == modeEditClip)
 
6699
                view->requestMode(submodeEndNodeEdit);
6388
6700
        MovePages *dia = new MovePages(this, doc->currentPage()->pageNr()+1, doc->Pages->count(), true);
6389
6701
        if (dia->exec())
6390
6702
        {
6397
6709
                        doc->movePage(from-1, to, wo-1, wie);
6398
6710
                        view->reformPages();
6399
6711
                        view->DrawNew();
6400
 
                        pagePalette->RebuildPage();
 
6712
                        pagePalette->rebuildPages();
6401
6713
                        if (outlinePalette->isVisible())
6402
6714
                                outlinePalette->BuildTree();
6403
6715
                }
6407
6719
 
6408
6720
void ScribusMainWindow::CopyPage()
6409
6721
{
6410
 
        NoFrameEdit();
 
6722
        if (HaveDoc && doc->appMode == modeEditClip)
 
6723
                view->requestMode(submodeEndNodeEdit);
6411
6724
        MovePages *dia = new MovePages(this, doc->currentPage()->pageNr()+1, doc->Pages->count(), false);
6412
6725
        if (dia->exec())
6413
6726
        {
6418
6731
                doc->copyPage(pageNumberToCopy, wo, whereToInsert, copyCount);
6419
6732
                view->Deselect(true);
6420
6733
                view->DrawNew();
6421
 
                pagePalette->RebuildPage();
 
6734
                pagePalette->rebuildPages();
6422
6735
                if (outlinePalette->isVisible())
6423
6736
                        outlinePalette->BuildTree();
6424
6737
        }
6427
6740
 
6428
6741
void ScribusMainWindow::changePageMargins()
6429
6742
{
6430
 
        NoFrameEdit();
 
6743
        if (HaveDoc && doc->appMode == modeEditClip)
 
6744
                view->requestMode(submodeEndNodeEdit);
6431
6745
        QString Nam = doc->currentPage()->MPageNam;
6432
6746
        MarginDialog *dia = new MarginDialog(this, doc);
6433
6747
        if (dia->exec())
6455
6769
                        if (dia->masterPage() != Nam)
6456
6770
                                Apply_MasterPage(dia->masterPage(), doc->currentPage()->pageNr());
6457
6771
                }
 
6772
                doc->currentPage()->marginPreset = dia->getMarginPreset();
6458
6773
                view->reformPages(dia->getMoveObjects());
6459
6774
                view->DrawNew();
6460
6775
        }
6461
6776
        delete dia;
6462
6777
}
6463
6778
 
6464
 
void ScribusMainWindow::setItemFont2(int id)
6465
 
{
6466
 
        disconnect(FontMenu, SIGNAL(activated(int)), this, SLOT(setItemFont(int)));
6467
 
        SetNewFont(FontSub->text(id));
6468
 
        FontMenu->activateItemAt(0);
6469
 
        connect(FontMenu, SIGNAL(activated(int)), this, SLOT(setItemFont(int)));
6470
 
}
6471
 
 
6472
 
void ScribusMainWindow::setItemFont(int id)
6473
 
{
6474
 
        QString nf;
6475
 
        int a = FontMenu->indexOf(id);
6476
 
        if (a == 1)
6477
 
                return;
6478
 
        disconnect(FontMenu, SIGNAL(activated(int)), this, SLOT(setItemFont(int)));
6479
 
        nf = FontID[id];
6480
 
        SetNewFont(nf);
6481
 
        connect(FontMenu, SIGNAL(activated(int)), this, SLOT(setItemFont(int)));
6482
 
}
6483
 
 
6484
6779
void ScribusMainWindow::SetNewFont(const QString& nf)
6485
6780
{
6486
6781
        setMainWindowActive();
6489
6784
        {
6490
6785
                if (doc->AddFont(nf)) //, prefsManager->appPrefs.AvailFonts[nf]->Font))
6491
6786
                {
6492
 
                        int a = FontMenu->insertItem(new FmItem(nf, prefsManager->appPrefs.AvailFonts[nf]));
6493
 
                        FontID.insert(a, prefsManager->appPrefs.AvailFonts[nf].scName());
6494
6787
                }
6495
6788
                else
6496
6789
                {//CB FIXME: to doc?
6499
6792
                                PageItem *currItem = doc->m_Selection->itemAt(0);
6500
6793
                                nf2 = currItem->currentCharStyle().font().scName();
6501
6794
                        }
6502
 
//                      propertiesPalette->Fonts->RebuildList(doc);
6503
 
                        buildFontMenu();
6504
6795
                }
6505
6796
        }
6506
 
        AdjustFontMenu(nf2);
6507
6797
        doc->itemSelection_SetFont(nf2);
6508
6798
//      doc->currentStyle.charStyle().setFont((*doc->AllFonts)[nf2]);
6509
6799
        view->DrawNew();
6510
 
        slotDocCh();
6511
 
}
6512
 
 
6513
 
void ScribusMainWindow::AdjustFontMenu(const QString& nf)
6514
 
{
6515
 
        currentFontForFontMenu=nf;
6516
 
/*
6517
 
        QString df;
6518
 
        if (doc->m_Selection->count() != 0)
6519
 
        {
6520
 
                PageItem *currItem = doc->m_Selection->itemAt(0);
6521
 
                FontSub->RebuildList(doc, currItem->isAnnotation());
6522
 
        }
6523
 
        FontSub->setCurrentText(nf);
6524
 
        //propertiesPalette->Fonts->setCurrentFont(nf);
6525
 
        for (uint a = 2; a < FontMenu->count(); ++a)
6526
 
        {
6527
 
                df = FontID[FontMenu->idAt(a)];
6528
 
                FontMenu->setItemChecked(FontMenu->idAt(a), (df == nf));
6529
 
        }
6530
 
*/
 
6800
//      slotDocCh();
6531
6801
}
6532
6802
 
6533
6803
void ScribusMainWindow::setItemFSize(int id)
6548
6818
                delete dia;
6549
6819
        }
6550
6820
        propertiesPalette->setSize(c*10);
6551
 
        slotDocCh();
6552
 
}
6553
 
 
6554
 
void ScribusMainWindow::setFSizeMenu(int size)
6555
 
{
6556
 
        if (scrActions[QString("fontSize%1").arg(size/10)])
6557
 
                scrActions[QString("fontSize%1").arg(size/10)]->setOn(true);
6558
 
}
6559
 
 
6560
 
//CB-->Doc
6561
 
void ScribusMainWindow::setItemFarbe(int id)
6562
 
{
6563
 
        if (doc->m_Selection->count() != 0)
6564
 
        {
6565
 
                PageItem *currItem = doc->m_Selection->itemAt(0);
6566
 
                if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
6567
 
                        doc->itemSelection_SetFillColor(ColorMenC->text(id));
6568
 
                else
6569
 
                        doc->ItemBrush(ColorMenC->text(id));
6570
 
        }
6571
 
        scrMenuMgr->getLocalPopupMenu("Color")->activateItemAt(0);
6572
 
        slotDocCh();
 
6821
//      slotDocCh();
6573
6822
}
6574
6823
 
6575
6824
//CB-->Doc partly
6585
6834
                        if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
6586
6835
                                doc->itemSelection_SetFillShade(c);
6587
6836
                        else
6588
 
                                doc->ItemBrushShade(c);
 
6837
                                doc->itemSelection_SetItemBrushShade(c);
6589
6838
                }
6590
6839
                else
6591
6840
                {
6598
6847
                                        if ((currItem->itemType() == PageItem::TextFrame) || (currItem->itemType() == PageItem::PathText))
6599
6848
                                                doc->itemSelection_SetFillShade(c);
6600
6849
                                        else
6601
 
                                                doc->ItemBrushShade(c);
 
6850
                                                doc->itemSelection_SetItemBrushShade(c);
6602
6851
                                }
6603
6852
                        }
6604
6853
                        delete dia;
6605
6854
                }
6606
6855
        }
6607
 
        slotDocCh();
 
6856
//      slotDocCh();
6608
6857
}
6609
6858
 
 
6859
/* CB: unused in 135 without the colours menu
6610
6860
void ScribusMainWindow::setCSMenu()
6611
6861
{
6612
6862
        QString la = CommonStrings::tr_NoneColor;
6619
6869
                {
6620
6870
                        if ((doc->appMode == modeEdit) && (currItem->itemText.length() != 0))
6621
6871
                        {
6622
 
                                la = currItem->itemText.charStyle(QMIN(currItem->CPos, static_cast<int>(currItem->itemText.length()-1))).fillColor();
6623
 
                                lb = currItem->itemText.charStyle(QMIN(currItem->CPos, static_cast<int>(currItem->itemText.length()-1))).fillShade();
 
6872
                                la = currItem->itemText.charStyle(qMin(currItem->CPos, static_cast<int>(currItem->itemText.length()-1))).fillColor();
 
6873
                                lb = qRound(currItem->itemText.charStyle(qMin(currItem->CPos, static_cast<int>(currItem->itemText.length()-1))).fillShade());
6624
6874
                        }
6625
6875
                        else
6626
6876
                        {
6627
6877
                                la = currItem->itemText.defaultStyle().charStyle().fillColor();
6628
 
                                lb = currItem->itemText.defaultStyle().charStyle().fillShade();
 
6878
                                lb = qRound(currItem->itemText.defaultStyle().charStyle().fillShade());
6629
6879
                        }
6630
6880
                }
6631
6881
                else
6632
6882
                {
6633
6883
                        la = currItem->fillColor();
6634
 
                        lb = currItem->fillShade();
 
6884
                        lb = qRound(currItem->fillShade());
6635
6885
                }
6636
6886
        }
6637
6887
        if (la == CommonStrings::None)
6638
6888
                la = CommonStrings::tr_NoneColor;
6639
 
        for (uint a = 0; a < static_cast<uint>(ColorMenC->count()); ++a)
6640
 
        {
6641
 
                if (ColorMenC->text(a) == la)
6642
 
                        ColorMenC->setCurrentItem(a);
6643
 
        }
6644
6889
        if (scrActions[QString("shade%1").arg(lb)])
6645
 
                scrActions[QString("shade%1").arg(lb)]->setOn(true);
 
6890
                scrActions[QString("shade%1").arg(lb)]->setChecked(true);
6646
6891
}
6647
 
 
6648
 
 
 
6892
*/
 
6893
 
 
6894
#if 0
6649
6895
//CB still called from SE
6650
6896
void ScribusMainWindow::saveStyles(StilFormate *dia)
6651
6897
{
6652
 
        QValueList<uint> ers;
 
6898
        QList<uint> ers;
6653
6899
        QString nn;
6654
6900
//      PageItem* ite = 0;
6655
6901
        bool ff;
6931
7177
                        {
6932
7178
                                if (doc->AddFont(nf)) //, prefsManager->appPrefs.AvailFonts[nf]->Font))
6933
7179
                                {
6934
 
                                        int ff = FontMenu->insertItem(new FmItem(nf, prefsManager->appPrefs.AvailFonts[nf]));
6935
 
                                        FontID.insert(ff, prefsManager->appPrefs.AvailFonts[nf].scName());
6936
7180
                                }
6937
7181
//                              else
6938
7182
//FIXME                                 doc->paragraphStyles()[a].charStyle().setFont((prefsManager->appPrefs.AvailFonts[doc->toolSettings.defFont]));
6943
7187
        propertiesPalette->paraStyleCombo->updateFormatList();
6944
7188
        propertiesPalette->charStyleCombo->updateFormatList();
6945
7189
        propertiesPalette->updateColorList();
6946
 
        disconnect(ColorMenC, SIGNAL(activated(int)), this, SLOT(setItemFarbe(int)));
6947
 
        ColorList::Iterator it;
6948
 
        updateColorMenu();
6949
7190
        view->DrawNew();
6950
7191
        slotDocCh();
6951
7192
}
6952
 
 
 
7193
#endif
6953
7194
//CB-->Doc
6954
7195
void ScribusMainWindow::setNewAlignment(int a)
6955
7196
{
6972
7213
                        doc->itemSelection_SetNamedParagraphStyle(name);
6973
7214
                        doc->itemSelection_EraseParagraphStyle();
6974
7215
                }
6975
 
                else */         
 
7216
                else */
6976
7217
                        doc->itemSelection_SetNamedParagraphStyle(name);
6977
7218
                PageItem *currItem = doc->m_Selection->itemAt(0);
6978
7219
                setTBvals(currItem);
6985
7226
        {
6986
7227
/*              if (name.isEmpty())
6987
7228
                {
6988
 
                        doc->itemSelection_SetNamedCharStyle(name);                     
 
7229
                        doc->itemSelection_SetNamedCharStyle(name);
6989
7230
                        doc->itemSelection_EraseCharStyle();
6990
7231
                }
6991
7232
                else */
7005
7246
        {
7006
7247
                QString actionName="align"+alignment[b];
7007
7248
                if (scrActions[actionName])
7008
 
                        scrActions[actionName]->setOn(a==b);
 
7249
                        scrActions[actionName]->setChecked(a==b);
 
7250
        }
 
7251
}
 
7252
 
 
7253
void ScribusMainWindow::slotReplaceColors()
 
7254
{
 
7255
        if (HaveDoc)
 
7256
        {
 
7257
                ColorList UsedC;
 
7258
                doc->getUsedColors(UsedC);
 
7259
                replaceColorsDialog *dia2 = new replaceColorsDialog(this, doc->PageColors, UsedC);
 
7260
                if (dia2->exec())
 
7261
                {
 
7262
                        ResourceCollection colorrsc;
 
7263
                        colorrsc.mapColors(dia2->replaceMap);
 
7264
                        PrefsManager::replaceToolColors(doc->toolSettings, colorrsc.colors());
 
7265
                        doc->replaceNamedResources(colorrsc);
 
7266
                        doc->replaceLineStyleColors(dia2->replaceMap);
 
7267
                        doc->recalculateColors();
 
7268
                        doc->recalcPicturesRes();
 
7269
                        propertiesPalette->updateColorList();
 
7270
                        propertiesPalette->SetLineFormats(doc);
 
7271
                        styleManager->updateColorList();
 
7272
                        if (doc->m_Selection->count() != 0)
 
7273
                                doc->m_Selection->itemAt(0)->emitAllToGUI();
 
7274
                        view->DrawNew();
 
7275
                }
 
7276
                delete dia2;
7009
7277
        }
7010
7278
}
7011
7279
 
7021
7289
        {
7022
7290
                if (HaveDoc)
7023
7291
                {
7024
 
//                      uint c;
7025
 
//                      int d;
7026
 
//                      PageItem *ite;
7027
7292
                        QColor tmpc;
7028
7293
                        slotDocCh();
7029
7294
                        doc->PageColors = dia->EditColors;
7043
7308
                                doc->replaceNamedResources(colorrsc);
7044
7309
                                // Temporary code until LineStyle is effectively used
7045
7310
                                doc->replaceLineStyleColors(dia->replaceMap);
7046
 
                                /*
7047
 
                                // ers == colorrsc.fonts()
7048
 
                                QMap<QString,QString>::Iterator it;
7049
 
                                for (it = ers.begin(); it != ers.end(); ++it)
7050
 
                                {
7051
 
                                        if (it.key() == doc->currentStyle.charStyle().fillColor())
7052
 
                                                doc->currentStyle.charStyle().setFillColor(it.data());
7053
 
                                        if (it.key() == doc->currentStyle.charStyle().strokeColor())
7054
 
                                                doc->currentStyle.charStyle().setStrokeColor(it.data());
7055
 
                                        for (c=0; c<doc->DocItems.count(); ++c)
7056
 
                                        {
7057
 
                                                ite = doc->DocItems.at(c);
7058
 
                                                if ((ite->asTextFrame()) || (ite->asPathText()))
7059
 
                                                {
7060
 
                                                        CharStyle lastStyle;
7061
 
                                                        int lastStyleStart = 0;
7062
 
                                                        for (d=0; d<ite->itemText.length(); ++d)
7063
 
                                                        {
7064
 
                                                                CharStyle newStyle;
7065
 
                                                                if (it.key() == ite->itemText.charStyle(d).fillColor())
7066
 
                                                                        newStyle.setFillColor(it.data());
7067
 
                                                                if (it.key() == ite->itemText.charStyle(d).strokeColor())
7068
 
                                                                        newStyle.setStrokeColor(it.data());
7069
 
                                                                if (newStyle != lastStyle) {
7070
 
                                                                        ite->itemText.applyCharStyle(lastStyleStart, d-lastStyleStart, lastStyle);
7071
 
                                                                        lastStyle = newStyle;
7072
 
                                                                        lastStyleStart = d;
7073
 
                                                                }
7074
 
                                                        }
7075
 
                                                        ite->itemText.applyCharStyle(lastStyleStart, ite->itemText.length()-lastStyleStart, lastStyle);
7076
 
                                                }
7077
 
                                                if (it.key() == ite->fillColor())
7078
 
                                                        ite->setFillColor(it.data());
7079
 
                                                if (it.key() == ite->lineColor())
7080
 
                                                        ite->setLineColor(it.data());
7081
 
                                                QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops();
7082
 
                                                for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
7083
 
                                                {
7084
 
                                                        if (it.key() == cstops.at(cst)->name)
7085
 
                                                                cstops.at(cst)->name = it.data();
7086
 
                                                }
7087
 
                                        }
7088
 
                                }
7089
 
                                for (it = ers.begin(); it != ers.end(); ++it)
7090
 
                                {
7091
 
                                        for (c=0; c<doc->FrameItems.count(); ++c)
7092
 
                                        {
7093
 
                                                ite = doc->FrameItems.at(c);
7094
 
                                                if ((ite->asTextFrame()) || (ite->asPathText()))
7095
 
                                                {
7096
 
                                                        CharStyle lastStyle;
7097
 
                                                        int lastStyleStart = 0;
7098
 
                                                        for (d=0; d<ite->itemText.length(); ++d)
7099
 
                                                        {
7100
 
                                                                CharStyle newStyle;
7101
 
                                                                if (it.key() == ite->itemText.charStyle(d).fillColor())
7102
 
                                                                        newStyle.setFillColor(it.data());
7103
 
                                                                if (it.key() == ite->itemText.charStyle(d).strokeColor())
7104
 
                                                                        newStyle.setStrokeColor(it.data());
7105
 
                                                                if (newStyle != lastStyle) {
7106
 
                                                                        ite->itemText.applyCharStyle(lastStyleStart, d-lastStyleStart, lastStyle);
7107
 
                                                                        lastStyle = newStyle;
7108
 
                                                                        lastStyleStart = d;
7109
 
                                                                }
7110
 
                                                                ite->itemText.applyCharStyle(lastStyleStart, ite->itemText.length()-lastStyleStart, lastStyle);
7111
 
                                                        }
7112
 
                                                }
7113
 
                                                if (it.key() == ite->fillColor())
7114
 
                                                        ite->setFillColor(it.data());
7115
 
                                                if (it.key() == ite->lineColor())
7116
 
                                                        ite->setLineColor(it.data());
7117
 
                                                QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops();
7118
 
                                                for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
7119
 
                                                {
7120
 
                                                        if (it.key() == cstops.at(cst)->name)
7121
 
                                                                cstops.at(cst)->name = it.data();
7122
 
                                                }
7123
 
                                        }
7124
 
                                }
7125
 
                                for (it = ers.begin(); it != ers.end(); ++it)
7126
 
                                {
7127
 
                                        for (c=0; c<doc->MasterItems.count(); ++c)
7128
 
                                        {
7129
 
                                                ite = doc->MasterItems.at(c);
7130
 
                                                if ((ite->itemType() == PageItem::TextFrame) || (ite->itemType() == PageItem::PathText))
7131
 
                                                {
7132
 
                                                        CharStyle lastStyle;
7133
 
                                                        int lastStyleStart = 0;
7134
 
                                                        for (d=0; d<ite->itemText.length(); ++d)
7135
 
                                                        {
7136
 
                                                                CharStyle newStyle;
7137
 
                                                                if (it.key() == ite->itemText.charStyle(d).fillColor())
7138
 
                                                                        newStyle.setFillColor(it.data());
7139
 
                                                                if (it.key() == ite->itemText.charStyle(d).strokeColor())
7140
 
                                                                        newStyle.setStrokeColor(it.data());
7141
 
                                                                if (newStyle != lastStyle) {
7142
 
                                                                        ite->itemText.applyCharStyle(lastStyleStart, d-lastStyleStart, lastStyle);
7143
 
                                                                        lastStyle = newStyle;
7144
 
                                                                        lastStyleStart = d;
7145
 
                                                                }
7146
 
                                                        }
7147
 
                                                        ite->itemText.applyCharStyle(lastStyleStart, ite->itemText.length()-lastStyleStart, lastStyle);
7148
 
                                                }
7149
 
                                                if (it.key() == ite->fillColor())
7150
 
                                                        ite->setFillColor(it.data());
7151
 
                                                if (it.key() == ite->lineColor())
7152
 
                                                        ite->setLineColor(it.data());
7153
 
                                                QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops();
7154
 
                                                for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
7155
 
                                                {
7156
 
                                                        if (it.key() == cstops.at(cst)->name)
7157
 
                                                                cstops.at(cst)->name = it.data();
7158
 
                                                }
7159
 
                                        }
7160
 
                                }
7161
 
                                for (it = ers.begin(); it != ers.end(); ++it)
7162
 
                                {
7163
 
                                        QStringList patterns = doc->docPatterns.keys();
7164
 
                                        for (uint c = 0; c < patterns.count(); ++c)
7165
 
                                        {
7166
 
                                                ScPattern pa = doc->docPatterns[patterns[c]];
7167
 
                                                for (uint o = 0; o < pa.items.count(); o++)
7168
 
                                                {
7169
 
                                                        PageItem *ite = pa.items.at(o);
7170
 
                                                        if ((ite->itemType() == PageItem::TextFrame) || (ite->itemType() == PageItem::PathText))
7171
 
                                                        {
7172
 
                                                                CharStyle lastStyle;
7173
 
                                                                int lastStyleStart = 0;
7174
 
                                                                for (d=0; d<ite->itemText.length(); ++d)
7175
 
                                                                {
7176
 
                                                                        CharStyle newStyle;
7177
 
                                                                        if (it.key() == ite->itemText.charStyle(d).fillColor())
7178
 
                                                                                newStyle.setFillColor(it.data());
7179
 
                                                                        if (it.key() == ite->itemText.charStyle(d).strokeColor())
7180
 
                                                                                newStyle.setStrokeColor(it.data());
7181
 
                                                                        if (newStyle != lastStyle) {
7182
 
                                                                                ite->itemText.applyCharStyle(lastStyleStart, d-lastStyleStart, lastStyle);
7183
 
                                                                                lastStyle = newStyle;
7184
 
                                                                                lastStyleStart = d;
7185
 
                                                                        }
7186
 
                                                                }
7187
 
                                                                ite->itemText.applyCharStyle(lastStyleStart, ite->itemText.length()-lastStyleStart, lastStyle);
7188
 
                                                        }
7189
 
                                                        if (it.key() == ite->fillColor())
7190
 
                                                                ite->setFillColor(it.data());
7191
 
                                                        if (it.key() == ite->lineColor())
7192
 
                                                                ite->setLineColor(it.data());
7193
 
                                                        QPtrVector<VColorStop> cstops = ite->fill_gradient.colorStops();
7194
 
                                                        for (uint cst = 0; cst < ite->fill_gradient.Stops(); ++cst)
7195
 
                                                        {
7196
 
                                                                if (it.key() == cstops.at(cst)->name)
7197
 
                                                                {
7198
 
                                                                        cstops.at(cst)->name = it.data();
7199
 
                                                                }
7200
 
                                                        }
7201
 
                                                }
7202
 
                                        }
7203
 
                                }
7204
 
                                 */
7205
7311
                        }
7206
7312
                        doc->recalculateColors();
7207
7313
                        doc->recalcPicturesRes();
7208
7314
                        propertiesPalette->updateColorList();
 
7315
                        //3102: update the line styles in PP too
 
7316
                        propertiesPalette->SetLineFormats(doc);
7209
7317
                        styleManager->updateColorList();
7210
 
                        updateColorMenu();
7211
7318
                        if (doc->m_Selection->count() != 0)
7212
7319
                                doc->m_Selection->itemAt(0)->emitAllToGUI();
7213
7320
                        view->DrawNew();
7226
7333
        delete dia;
7227
7334
}
7228
7335
 
7229
 
// void ScribusMainWindow::slotStyleManager()
7230
 
// {
7231
 
//      styleManager->setDoc(HaveDoc ? doc : 0);
7232
 
//      styleManager->setShown(!styleManager->isVisible());
7233
 
// }
7234
 
 
7235
7336
void ScribusMainWindow::updtGradFill()
7236
7337
{
7237
7338
        if (!HaveDoc)
7272
7373
                break;
7273
7374
        }
7274
7375
        //propertiesPalette->SetCurItem(currItem);
7275
 
        view->RefreshItem(currItem);
 
7376
        currItem->update();
7276
7377
        slotDocCh();
7277
7378
}
7278
7379
 
7279
 
void ScribusMainWindow::ObjektDup()
 
7380
void ScribusMainWindow::duplicateItem()
7280
7381
{
7281
7382
        slotSelect();
7282
7383
        bool savedAlignGrid = doc->useRaster;
7283
7384
        bool savedAlignGuides = doc->SnapGuides;
 
7385
        internalCopy = true;
7284
7386
        doc->useRaster = false;
7285
7387
        doc->SnapGuides = false;
7286
7388
        slotEditCopy();
7287
7389
        view->Deselect(true);
7288
7390
        slotEditPaste();
7289
 
        for (uint b=0; b<doc->m_Selection->count(); ++b)
 
7391
        for (int b=0; b<doc->m_Selection->count(); ++b)
7290
7392
        {
7291
7393
                doc->m_Selection->itemAt(b)->setLocked(false);
7292
7394
                doc->MoveItem(doc->toolSettings.dispX, doc->toolSettings.dispY, doc->m_Selection->itemAt(b));
7293
7395
        }
7294
7396
        doc->useRaster = savedAlignGrid;
7295
7397
        doc->SnapGuides = savedAlignGuides;
 
7398
        internalCopy = false;
 
7399
        view->DrawNew();
7296
7400
}
7297
7401
 
7298
 
void ScribusMainWindow::ObjektDupM()
 
7402
void ScribusMainWindow::duplicateItemMulti()
7299
7403
{
7300
7404
        if (!HaveDoc)
7301
7405
                return;
7302
7406
        slotSelect();
7303
 
        NoFrameEdit();
 
7407
        if (HaveDoc && doc->appMode == modeEditClip)
 
7408
                view->requestMode(submodeEndNodeEdit);
 
7409
        internalCopy = true;
7304
7410
        MultipleDuplicate *dia = new MultipleDuplicate(doc->unitIndex(), this);
7305
7411
        if (dia->exec())
7306
7412
        {
7308
7414
                dia->getMultiplyData(mdData);
7309
7415
                doc->itemSelection_MultipleDuplicate(mdData);
7310
7416
        }
 
7417
        internalCopy = false;
7311
7418
        delete dia;
7312
7419
}
7313
7420
 
7314
7421
void ScribusMainWindow::selectItemsFromOutlines(PageItem* ite)
7315
7422
{
7316
 
        int d = doc->Items->findRef(ite);
 
7423
        int d = doc->Items->indexOf(ite);
7317
7424
        selectItemsFromOutlines(ite->OwnPage, d, true);
7318
7425
}
7319
7426
 
7320
7427
void ScribusMainWindow::selectItemsFromOutlines(int Page, int Item, bool single)
7321
7428
{
7322
 
        NoFrameEdit();
7323
 
        setActiveWindow();
 
7429
        if (HaveDoc && doc->appMode == modeEditClip)
 
7430
                view->requestMode(submodeEndNodeEdit);
 
7431
        activateWindow();
7324
7432
        view->Deselect(true);
7325
7433
        if ((Page != -1) && (Page != static_cast<int>(doc->currentPage()->pageNr())))
7326
7434
                view->GotoPage(Page);
 
7435
        doc->m_Selection->delaySignalsOn();
7327
7436
        view->SelectItemNr(Item, true, single);
 
7437
        doc->m_Selection->delaySignalsOff();
 
7438
        doc->m_Selection->connectItemToGUI();
7328
7439
        if (doc->m_Selection->count() != 0)
7329
7440
        {
7330
7441
                PageItem *currItem = doc->m_Selection->itemAt(0);
7339
7450
                        double x2 = cos((rotation+90.0)*MPI180) * currItem->height();
7340
7451
                        double mx = currItem->xPos() + ((x1 + x2)/2.0);
7341
7452
                        double my = currItem->yPos() + ((y1 + y2)/2.0);
7342
 
                        double viewScale=view->scale();
7343
 
                        if ((qRound((currItem->xPos() + QMAX(x1, x2)) * viewScale) > view->contentsWidth()) ||
7344
 
                                (qRound((currItem->yPos() + QMAX(y1, y2)) * viewScale) > view->contentsHeight()))
7345
 
                                view->resizeContents(QMAX(qRound((currItem->xPos() + QMAX(x1, x2)) * viewScale),
7346
 
                                                                        view->contentsWidth()),
7347
 
                                                                        QMAX(qRound((currItem->yPos() + QMAX(y1, y2)) * viewScale), view->contentsHeight()));
 
7453
//                      double viewScale=view->scale();
 
7454
//                      if ((qRound((currItem->xPos() + qMax(x1, x2)) * viewScale) > view->contentsWidth()) ||
 
7455
//                              (qRound((currItem->yPos() + qMax(y1, y2)) * viewScale) > view->contentsHeight()))
 
7456
//                              view->resizeContents(qMax(qRound((currItem->xPos() + qMax(x1, x2)) * viewScale),
 
7457
//                                                                      view->contentsWidth()),
 
7458
//                                                                      qMax(qRound((currItem->yPos() + qMax(y1, y2)) * viewScale), view->contentsHeight()));
7348
7459
                        view->SetCCPo(mx, my);
7349
7460
                }
7350
7461
                else
7351
7462
                {
7352
 
                        double viewScale=view->scale();
7353
 
                        if ((qRound((currItem->xPos() + currItem->width()) * viewScale) > view->contentsWidth()) ||
7354
 
                                (qRound((currItem->yPos() + currItem->height()) * viewScale) > view->contentsHeight())
7355
 
                                )
7356
 
                                view->resizeContents(QMAX(qRound((currItem->xPos() + currItem->width()) * viewScale), view->contentsWidth()),
7357
 
                                                                         QMAX(qRound((currItem->yPos() + currItem->height()) * viewScale), view->contentsHeight()));
 
7463
//                      double viewScale=view->scale();
 
7464
//                      if ((qRound((currItem->xPos() + currItem->width()) * viewScale) > view->contentsWidth()) ||
 
7465
//                              (qRound((currItem->yPos() + currItem->height()) * viewScale) > view->contentsHeight())
 
7466
//                              )
 
7467
//                              view->resizeContents(qMax(qRound((currItem->xPos() + currItem->width()) * viewScale), view->contentsWidth()),
 
7468
//                                                                       qMax(qRound((currItem->yPos() + currItem->height()) * viewScale), view->contentsHeight()));
7358
7469
                        view->SetCCPo(currItem->xPos() + currItem->width() / 2.0, currItem->yPos() + currItem->height() / 2.0);
7359
7470
                }
7360
7471
        }
7362
7473
 
7363
7474
void ScribusMainWindow::selectPagesFromOutlines(int Page)
7364
7475
{
7365
 
        NoFrameEdit();
7366
 
        setActiveWindow();
 
7476
        if (HaveDoc && doc->appMode == modeEditClip)
 
7477
                view->requestMode(submodeEndNodeEdit);
 
7478
        activateWindow();
7367
7479
        view->Deselect(true);
7368
7480
        if (Page < 0)
7369
7481
                return;
7370
7482
        view->GotoPage(Page);
7371
7483
}
7372
7484
 
7373
 
void ScribusMainWindow::buildFontMenu()
7374
 
{
7375
 
        FontID.clear();
7376
 
        FontMenu->clear();
7377
 
        SCFontsIterator it(prefsManager->appPrefs.AvailFonts);
7378
 
        FontSub = new FontCombo(0);
7379
 
        FontMenu->insertItem(FontSub);
7380
 
        connect(FontSub, SIGNAL(activated(int)), this, SLOT(setItemFont2(int)));
7381
 
        FontMenu->insertSeparator();
7382
 
        int a=0;
7383
 
        if (!HaveDoc)
7384
 
        {
7385
 
                a = FontMenu->insertItem(new FmItem(it.currentKey(), it.current()));
7386
 
                FontMenu->setItemChecked(a, true);
7387
 
                FontID.insert(a, it.current().scName());
7388
 
        }
7389
 
        else
7390
 
        {
7391
 
                QMap<QString,int>::Iterator it3;
7392
 
                for (it3 = doc->UsedFonts.begin(); it3 != doc->UsedFonts.end(); ++it3)
7393
 
                {
7394
 
                        a = FontMenu->insertItem(new FmItem(it3.key(), prefsManager->appPrefs.AvailFonts[it3.key()]));
7395
 
                        if (it3.key() == doc->toolSettings.defFont)
7396
 
                                FontMenu->setItemChecked(a, true);
7397
 
                        FontID.insert(a, it3.key());
7398
 
                }
7399
 
        }
7400
 
        connect(FontMenu, SIGNAL(activated(int)), this, SLOT(setItemFont(int)));
7401
 
}
7402
 
 
7403
7485
void ScribusMainWindow::prefsOrg(Preferences *dia)
7404
7486
{
7405
7487
        //reset the appMode so we restore our tools shortcuts
7406
7488
        QString oldGUILanguage = prefsManager->guiLanguage();
7407
 
        QString oldGUIStyle = prefsManager->guiStyle();
7408
 
        int oldGUIFontSize = prefsManager->guiFontSize();
7409
 
        //double oldDisplayScale=prefsManager->displayScale();
 
7489
        QString oldGUIStyle    = prefsManager->guiStyle();
 
7490
        bool oldShowPageShadow = prefsManager->showPageShadow();
 
7491
        int oldGUIFontSize     = prefsManager->guiFontSize();
 
7492
        double oldDisplayScale = prefsManager->displayScale();
 
7493
        int oldImageQuality = prefsManager->applicationPrefs()->toolSettings.lowResType;
 
7494
 
7410
7495
        dia->updatePreferences();
7411
7496
        prefsManager->SavePrefs();
7412
7497
        DocDir = prefsManager->documentDir();
7417
7502
                ScQApp->changeGUILanguage(newGUILanguage);
7418
7503
        QString newGUIStyle = prefsManager->guiStyle();
7419
7504
        if (oldGUIStyle != newGUIStyle)
7420
 
                qApp->setStyle(QStyleFactory::create(newGUIStyle));
 
7505
        {
 
7506
                if (newGUIStyle.isEmpty())
 
7507
                        qApp->setStyle(prefsManager->guiSystemStyle());
 
7508
                else
 
7509
                        qApp->setStyle(QStyleFactory::create(newGUIStyle));
 
7510
                // Plain wrong, a style may set a palette different from the standard palette
 
7511
                // Eg : Windows XP and Windows Vista styles
 
7512
                // qApp->setPalette(qApp->style()->standardPalette());
 
7513
        }
7421
7514
        int newGUIFontSize = prefsManager->guiFontSize();
7422
7515
        if (oldGUIFontSize != newGUIFontSize)
7423
7516
        {
7424
7517
                QFont apf = qApp->font();
7425
7518
                apf.setPointSize(prefsManager->appPrefs.AppFontSize);
7426
 
                qApp->setFont(apf,true);
 
7519
                qApp->setFont(apf);
7427
7520
        }
7428
 
        FontSub->RebuildList(0);
7429
7521
        propertiesPalette->Fonts->RebuildList(0);
7430
7522
        ScCore->getCMSProfiles(false);
7431
7523
        ScCore->recheckGS();
7432
 
        SetShortCut();
 
7524
        prefsManager->applyLoadedShortCuts();
 
7525
 
 
7526
        int newImageQuality = prefsManager->appPrefs.toolSettings.lowResType;
 
7527
        if (oldImageQuality != newImageQuality)
 
7528
                view->previewQualitySwitcher->setCurrentIndex(newImageQuality);
 
7529
 
 
7530
        QWidgetList windows = wsp->windowList();
 
7531
        bool shadowChanged = oldShowPageShadow != prefsManager->showPageShadow();
 
7532
        if (!windows.isEmpty())
 
7533
        {
 
7534
                int windowCount=static_cast<int>(windows.count());
 
7535
                for ( int i = 0; i < windowCount; ++i )
 
7536
                {
 
7537
                        QWidget* w = windows.at(i);
 
7538
                        ScribusWin* scw = (ScribusWin*) w;
 
7539
                        scw->view()->zoom((scw->view()->scale() / oldDisplayScale) * prefsManager->displayScale());
 
7540
                        if (shadowChanged)
 
7541
                                scw->view()->DrawNew();
 
7542
                }
 
7543
        }
7433
7544
}
7434
7545
 
7435
7546
void ScribusMainWindow::slotPrefsOrg()
7436
7547
{
7437
 
        setAppMode(modeNormal);
 
7548
        slotSelect();
7438
7549
 
7439
7550
        Preferences *dia = new Preferences(this);
7440
7551
        if (dia->exec())
7447
7558
void ScribusMainWindow::ShowSubs()
7448
7559
{
7449
7560
        QString mess;
7450
 
        if (ScCore->haveGS() != 0)
 
7561
        if (!ScCore->haveGS())
7451
7562
        {
7452
7563
                mess = tr("The following programs are missing:")+"\n\n";
7453
7564
#ifndef _WIN32
7464
7575
        bookmarkPalette->startup();
7465
7576
        pagePalette->startup();
7466
7577
        layerPalette->startup();
7467
 
        measurementPalette->startup();
 
7578
//      measurementPalette->startup();
7468
7579
        docCheckerPalette->startup();
7469
7580
        alignDistributePalette->startup();
7470
7581
        undoPalette->startup();
7473
7584
        styleManager->startup();
7474
7585
 
7475
7586
        // init the toolbars
7476
 
        fileToolBar->initVisibility();
7477
 
        editToolBar->initVisibility();
7478
 
        mainToolBar->initVisibility();
7479
 
        pdfToolBar->initVisibility();
 
7587
//      fileToolBar->initVisibility();
 
7588
//      editToolBar->initVisibility();
 
7589
//      modeToolBar->initVisibility();
 
7590
//      pdfToolBar->initVisibility();
7480
7591
 
7481
 
        setActiveWindow();
7482
 
        raise();
 
7592
        activateWindow();
 
7593
        if (!ScriptRunning)
 
7594
                raise();
7483
7595
}
7484
7596
 
7485
7597
void ScribusMainWindow::doPrintPreview()
7489
7601
                docCheckerPalette->hide();
7490
7602
                docCheckerPalette->checkMode = CheckDocument::checkNULL;
7491
7603
                docCheckerPalette->setIgnoreEnabled(false);
7492
 
                scrActions["toolsPreflightVerifier"]->setOn(false);
 
7604
                scrActions["toolsPreflightVerifier"]->setChecked(false);
7493
7605
                disconnect(docCheckerPalette, SIGNAL(ignoreAllErrors()), this, SLOT(doPrintPreview()));
7494
7606
        }
7495
7607
        if (HaveDoc)
7496
7608
        {
7497
7609
                PrefsContext* prefs = PrefsManager::instance()->prefsFile->getContext("print_options");
7498
 
                QString currentPrinter = prefs->get("CurrentPrn");
7499
 
                if ( PPreview::usePostscriptPreview(currentPrinter) && ( ScCore->haveGS() != 0 ) )
 
7610
                QString currentPrinter    = prefs->get("CurrentPrn");
 
7611
                PrintEngine currentEngine = (PrintEngine) prefs->get("CurrentPrnEngine", "3").toInt();
 
7612
                if ( PPreview::usePostscriptPreview(currentPrinter, currentEngine) && ( !ScCore->haveGS() ) )
7500
7613
                {
7501
 
                        QString mess = tr("Ghostscript is missing : Postscript Print Preview is not available")+"\n\n";
 
7614
                        QString mess = tr("Ghostscript is missing : PostScript Print Preview is not available")+"\n\n";
7502
7615
                        QMessageBox::warning(this, CommonStrings::trWarning, mess, 1, 0, 0);
7503
7616
                        return;
7504
7617
                }
7505
 
                PPreview *dia = new PPreview(this, view, doc, ScCore->havePNGAlpha(), ScCore->haveTIFFSep(), currentPrinter);
 
7618
                PPreview *dia = new PPreview(this, view, doc, currentPrinter, currentEngine);
7506
7619
                previewDinUse = true;
7507
7620
                connect(dia, SIGNAL(doPrint()), this, SLOT(slotReallyPrint()));
7508
7621
                dia->exec();
7510
7623
                prefsManager->appPrefs.PrPr_Mode = dia->EnableCMYK->isChecked();
7511
7624
                prefsManager->appPrefs.PrPr_AntiAliasing = dia->AntiAlias->isChecked();
7512
7625
                prefsManager->appPrefs.PrPr_Transparency = dia->AliasTr->isChecked();
7513
 
                if ( ScCore->haveTIFFSep() != 0 || !dia->postscriptPreview )
 
7626
                if ( !ScCore->haveTIFFSep() || !dia->postscriptPreview )
7514
7627
                {
7515
7628
                        prefsManager->appPrefs.PrPr_C = dia->EnableCMYK_C->isChecked();
7516
7629
                        prefsManager->appPrefs.PrPr_M = dia->EnableCMYK_M->isChecked();
7523
7636
                        prefsManager->appPrefs.PrPr_M = dia->flagsVisible["Magenta"]->isChecked();
7524
7637
                        prefsManager->appPrefs.PrPr_Y = dia->flagsVisible["Yellow"]->isChecked();
7525
7638
                        prefsManager->appPrefs.PrPr_K = dia->flagsVisible["Black"]->isChecked();
 
7639
                        prefsManager->appPrefs.PrPr_InkCoverage = dia->EnableInkCover->isChecked();
 
7640
                        prefsManager->appPrefs.PrPr_InkThreshold = dia->CoverThresholdValue->value();
7526
7641
                }
7527
7642
//              prefsManager->appPrefs.Gcr_Mode = dia->EnableGCR->isChecked();
7528
 
//              prefsManager->appPrefs.doOverprint = dia->EnableOverprint->isChecked();
7529
7643
                disconnect(dia, SIGNAL(doPrint()), this, SLOT(slotReallyPrint()));
7530
7644
                previewDinUse = false;
7531
7645
                delete dia;
7550
7664
                {
7551
7665
                        if (doc->checkerProfiles[doc->curCheckProfile].ignoreErrors)
7552
7666
                        {
7553
 
                                int t = ScMessageBox::warning(this, CommonStrings::trWarning,
 
7667
                                int t = QMessageBox::warning(this, CommonStrings::trWarning,
7554
7668
                                                                                        "<qt>"+ tr("Scribus has detected some errors. Consider using the Preflight Verifier to correct them")+"</qt>",
7555
 
                                                                                        tr("&Ignore"), tr("&Abort"), 0, 0, 0);
7556
 
                                if (t == 1)
 
7669
                                                                                        QMessageBox::Abort | QMessageBox::Ignore);
 
7670
                                if (t == QMessageBox::Abort)
7557
7671
                                        return;
7558
7672
                        }
7559
7673
                        else
7563
7677
                                docCheckerPalette->checkMode = CheckDocument::checkPrintPreview;
7564
7678
                                docCheckerPalette->buildErrorList(doc);
7565
7679
                                docCheckerPalette->show();
7566
 
                                scrActions["toolsPreflightVerifier"]->setOn(true);
 
7680
                                scrActions["toolsPreflightVerifier"]->setChecked(true);
7567
7681
                                return;
7568
7682
                        }
7569
7683
                }
7571
7685
        doPrintPreview();
7572
7686
}
7573
7687
 
7574
 
bool ScribusMainWindow::DoSaveAsEps(QString fn)
 
7688
bool ScribusMainWindow::DoSaveAsEps(QString fn, QString& error)
7575
7689
{
7576
7690
        QStringList spots;
7577
7691
        bool return_value = true;
7578
7692
        ReOrderText(doc, view);
7579
 
        qApp->setOverrideCursor(QCursor(waitCursor), true);
 
7693
        qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
7580
7694
        QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
7581
7695
        ReallyUsed.clear();
7582
7696
        doc->getUsedFonts(ReallyUsed);
7596
7710
        options.doGCR = prefsManager->appPrefs.GCRMode;
7597
7711
        options.setDevParam = false;
7598
7712
        options.doClip = true;
7599
 
        options.doOverprint = false;
7600
7713
        options.cropMarks = false;
7601
7714
        options.bleedMarks = false;
7602
7715
        options.registrationMarks = false;
7611
7724
        {
7612
7725
                if (dd->PS_set_file(fn))
7613
7726
                {
7614
 
                        dd->CreatePS(doc, options);
 
7727
                        int psRet = dd->CreatePS(doc, options);
 
7728
                        if (psRet == 1)
 
7729
                        {
 
7730
                                error = dd->errorMessage();
 
7731
                                return_value = false;
 
7732
                        }
7615
7733
                }
7616
7734
                else
7617
7735
                        return_value = false;
7618
7736
                delete dd;
7619
 
                qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
7737
                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
7620
7738
        }
7621
7739
        ScCore->fileWatcher->start();
7622
7740
        return return_value;
7630
7748
                {
7631
7749
                        if (doc->checkerProfiles[doc->curCheckProfile].ignoreErrors)
7632
7750
                        {
7633
 
                                int t = ScMessageBox::warning(this, CommonStrings::trWarning,
 
7751
                                int t = QMessageBox::warning(this, CommonStrings::trWarning,
7634
7752
                                                                                        tr("Scribus detected some errors.\nConsider using the Preflight Verifier  to correct them."),
7635
 
                                                                                        tr("&Abort"), tr("&Ignore"), 0, 0, 0);
7636
 
                                if (t == 0)
 
7753
                                                                                        QMessageBox::Abort | QMessageBox::Ignore);
 
7754
                                if (t == QMessageBox::Abort)
7637
7755
                                        return;
7638
7756
                        }
7639
7757
                        else
7643
7761
                                docCheckerPalette->checkMode = CheckDocument::checkEPS;
7644
7762
                                docCheckerPalette->buildErrorList(doc);
7645
7763
                                docCheckerPalette->show();
7646
 
                                scrActions["toolsPreflightVerifier"]->setOn(true);
 
7764
                                scrActions["toolsPreflightVerifier"]->setChecked(true);
7647
7765
                                return;
7648
7766
                        }
7649
7767
                }
7659
7777
                docCheckerPalette->hide();
7660
7778
                docCheckerPalette->checkMode = CheckDocument::checkNULL;
7661
7779
                docCheckerPalette->setIgnoreEnabled(false);
7662
 
                scrActions["toolsPreflightVerifier"]->setOn(false);
 
7780
                scrActions["toolsPreflightVerifier"]->setChecked(false);
7663
7781
                disconnect(docCheckerPalette, SIGNAL(ignoreAllErrors()), this, SLOT(reallySaveAsEps()));
7664
7782
        }
7665
7783
        if (!doc->DocName.startsWith( tr("Document")))
7666
7784
        {
7667
7785
                QFileInfo fi(doc->DocName);
7668
7786
                if (doc->m_Selection->count() != 0)
7669
 
                        fna = fi.dirPath() + "/" + fi.baseName(true) + "_selection.eps";
 
7787
                        fna = fi.path() + "/" + fi.completeBaseName() + "_selection.eps";
7670
7788
                else
7671
 
                        fna = fi.dirPath() + "/" + getFileNameByPage(doc, doc->currentPage()->pageNr(), "eps");
 
7789
                        fna = fi.path() + "/" + getFileNameByPage(doc, doc->currentPage()->pageNr(), "eps");
7672
7790
        }
7673
7791
        else
7674
7792
        {
7675
7793
                QDir di = QDir();
7676
7794
                if (doc->m_Selection->count() != 0)
7677
 
                        fna = di.currentDirPath() + "/" + doc->DocName + "_selection.eps";
 
7795
                        fna = di.currentPath() + "/" + doc->DocName + "_selection.eps";
7678
7796
                else
7679
 
                        fna = di.currentDirPath() + "/" + getFileNameByPage(doc, doc->currentPage()->pageNr(), "eps");
 
7797
                        fna = di.currentPath() + "/" + getFileNameByPage(doc, doc->currentPage()->pageNr(), "eps");
7680
7798
        }
7681
7799
        fna = QDir::convertSeparators(fna);
7682
7800
        QString wdir = ".";
7685
7803
                wdir = prefsManager->prefsFile->getContext("dirs")->get("eps", prefsDocDir);
7686
7804
        else
7687
7805
                wdir = prefsManager->prefsFile->getContext("dirs")->get("eps", ".");
7688
 
        QString fn = CFileDialog( wdir, tr("Save as"), tr("EPS Files (*.eps);;All Files (*)"), fna, fdNone);
 
7806
        QString fn = CFileDialog( wdir, tr("Save As"), tr("%1;;All Files (*)").arg(formatsManager->extensionsForFormat(FormatsManager::EPS)), fna, fdHidePreviewCheckBox | fdNone);
7689
7807
        if (!fn.isEmpty())
7690
7808
        {
7691
 
                prefsManager->prefsFile->getContext("dirs")->set("eps", fn.left(fn.findRev("/")));
 
7809
                prefsManager->prefsFile->getContext("dirs")->set("eps", fn.left(fn.lastIndexOf("/")));
7692
7810
                if (overwrite(this, fn))
7693
7811
                {
7694
 
                        if (!DoSaveAsEps(fn))
7695
 
                                QMessageBox::warning(this, CommonStrings::trWarning, tr("Cannot write the file: \n%1").arg(fn), CommonStrings::tr_OK);
 
7812
                        QString epsError;
 
7813
                        if (!DoSaveAsEps(fn, epsError))
 
7814
                        {
 
7815
                                QString message = tr("Cannot write the file: \n%1").arg(fn);
 
7816
                                if (!epsError.isEmpty())
 
7817
                                        message += QString("\n%1").arg(epsError);
 
7818
                                QMessageBox::warning(this, CommonStrings::trWarning, message, CommonStrings::tr_OK);
 
7819
                        }
7696
7820
                }
7697
7821
        }
7698
7822
}
7699
7823
 
7700
7824
bool ScribusMainWindow::getPDFDriver(const QString & fn, const QString & nam, int Components,
7701
 
                                                                         const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs)
 
7825
                                                                         const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs,
 
7826
                                                                         QString& error, bool* cancelled)
7702
7827
{
7703
7828
        ScCore->fileWatcher->forceScan();
7704
7829
        ScCore->fileWatcher->stop();
7705
 
        bool ret = PDFlib(*doc).doExport(fn, nam, Components, pageNs, thumbs);
 
7830
        PDFlib pdflib(*doc);
 
7831
        bool ret = pdflib.doExport(fn, nam, Components, pageNs, thumbs);
 
7832
        if (!ret)
 
7833
                error = pdflib.errorMessage();
 
7834
        if (cancelled)
 
7835
                *cancelled = pdflib.exportAborted();
7706
7836
        ScCore->fileWatcher->start();
7707
7837
        return ret;
7708
7838
}
7717
7847
                        {
7718
7848
                                int t = QMessageBox::warning(this, CommonStrings::trWarning,
7719
7849
                                                                                        tr("Detected some errors.\nConsider using the Preflight Verifier to correct them"),
7720
 
                                                                                        tr("&Abort"), tr("&Ignore"), 0, 0, 0);
7721
 
                                if (t == 0)
 
7850
                                                                                        QMessageBox::Abort | QMessageBox::Ignore);
 
7851
                                if (t == QMessageBox::Abort)
7722
7852
                                        return;
7723
7853
                        }
7724
7854
                        else
7728
7858
                                docCheckerPalette->checkMode = CheckDocument::checkPDF;
7729
7859
                                docCheckerPalette->buildErrorList(doc);
7730
7860
                                docCheckerPalette->show();
7731
 
                                scrActions["toolsPreflightVerifier"]->setOn(true);
 
7861
                                scrActions["toolsPreflightVerifier"]->setChecked(true);
7732
7862
                                return;
7733
7863
                        }
7734
7864
                }
7743
7873
                docCheckerPalette->hide();
7744
7874
                docCheckerPalette->checkMode = CheckDocument::checkNULL;
7745
7875
                docCheckerPalette->setIgnoreEnabled(false);
7746
 
                scrActions["toolsPreflightVerifier"]->setOn(false);
 
7876
                scrActions["toolsPreflightVerifier"]->setChecked(false);
7747
7877
                disconnect(docCheckerPalette, SIGNAL(ignoreAllErrors()), this, SLOT(doSaveAsPDF()));
7748
7878
        }
7749
7879
/*      if (bookmarkPalette->BView->childCount() == 0)
7750
7880
                doc->PDF_Options.Bookmarks = false; */
7751
 
        QMap<QString, int> ReallyUsed = doc->UsedFonts;
 
7881
// reenabling the following line fixes Bug #7630, not sure why this line was commented out.
 
7882
//      doc->reorganiseFonts();
 
7883
        QMap<QString, int> ReallyUsed = doc->reorganiseFonts(); //doc->UsedFonts;
7752
7884
        if (doc->PDF_Options.EmbedList.count() != 0)
7753
7885
        {
7754
 
                QValueList<QString> tmpEm;
7755
 
                QValueList<QString>::Iterator itef;
 
7886
                QList<QString> tmpEm;
 
7887
                QList<QString>::Iterator itef;
7756
7888
                for (itef = doc->PDF_Options.EmbedList.begin(); itef != doc->PDF_Options.EmbedList.end(); ++itef)
7757
7889
                {
7758
7890
                        if (ReallyUsed.contains((*itef)))
7762
7894
        }
7763
7895
        if (doc->PDF_Options.SubsetList.count() != 0)
7764
7896
        {
7765
 
                QValueList<QString> tmpEm;
7766
 
                QValueList<QString>::Iterator itef;
 
7897
                QList<QString> tmpEm;
 
7898
                QList<QString>::Iterator itef;
7767
7899
                for (itef = doc->PDF_Options.SubsetList.begin(); itef != doc->PDF_Options.SubsetList.end(); ++itef)
7768
7900
                {
7769
7901
                        if (ReallyUsed.contains((*itef)))
7775
7907
        PDFExportDialog dia(this, doc->DocName, ReallyUsed, view, doc->PDF_Options, doc->PDF_Options.PresentVals, ScCore->PDFXProfiles, prefsManager->appPrefs.AvailFonts, doc->unitRatio(), ScCore->PrinterProfiles);
7776
7908
        if (dia.exec())
7777
7909
        {
7778
 
                qApp->setOverrideCursor(QCursor(waitCursor), true);
 
7910
                qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
7779
7911
                dia.updateDocOptions();
7780
7912
                doc->PDF_Options.firstUse = false;
7781
7913
                ReOrderText(doc, view);
7785
7917
                QMap<int,QPixmap> thumbs;
7786
7918
                int components=dia.colorSpaceComponents();
7787
7919
                QString nam(dia.cmsDescriptor());
7788
 
                QString fileName = doc->PDF_Options.Datei;
 
7920
                QString fileName = doc->PDF_Options.fileName;
 
7921
                QString errorMsg;
7789
7922
                parsePagesString(pageString, &pageNs, doc->DocPages.count());
7790
7923
                if (doc->PDF_Options.useDocBleeds)
7791
7924
                        doc->PDF_Options.bleeds = doc->bleeds;
7792
 
                
 
7925
 
7793
7926
                if (doc->PDF_Options.doMultiFile)
7794
7927
                {
 
7928
                        bool cancelled = false;
7795
7929
                        QFileInfo fi(fileName);
7796
 
                        QString ext = fi.extension( false );
7797
 
                        QString path = fi.dirPath( true );
7798
 
                        QString name = fi.baseName( true );
 
7930
                        QString ext = fi.suffix();
 
7931
                        QString path = fi.path();
 
7932
                        QString name = fi.completeBaseName();
7799
7933
                        uint aa = 0;
7800
 
                        while (aa < pageNs.size())
 
7934
                        while (aa < pageNs.size() && !cancelled)
7801
7935
                        {
7802
7936
                                thumbs.clear();
7803
7937
                                std::vector<int> pageNs2;
7806
7940
                                pageNumbersSize = pageNs2.size();
7807
7941
                                QPixmap pm(10,10);
7808
7942
                                if (doc->PDF_Options.Thumbnails)
7809
 
                                        pm.convertFromImage(view->PageToPixmap(pageNs[aa]-1, 100));
 
7943
                                        pm=QPixmap::fromImage(view->PageToPixmap(pageNs[aa]-1, 100));
7810
7944
                                thumbs.insert(1, pm);
7811
 
                                QString realName = QDir::convertSeparators(path+"/"+name+ tr("-Page%1").arg(pageNs[aa])+"."+ext);
7812
 
                                if (!getPDFDriver(realName, nam, components, pageNs2, thumbs))
 
7945
                                QString realName = QDir::convertSeparators(path+"/"+name+ tr("-Page%1").arg(pageNs[aa], 3, 10, QChar('0'))+"."+ext);
 
7946
                                if (!getPDFDriver(realName, nam, components, pageNs2, thumbs, errorMsg, &cancelled))
7813
7947
                                {
7814
 
                                        qApp->setOverrideCursor(QCursor(arrowCursor), true);
7815
 
                                        QMessageBox::warning(this, CommonStrings::trWarning, tr("Cannot write the file: \n%1").arg(doc->PDF_Options.Datei), CommonStrings::tr_OK);
 
7948
                                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 
7949
                                        QString message = tr("Cannot write the file: \n%1").arg(doc->PDF_Options.fileName);
 
7950
                                        if (!errorMsg.isEmpty())
 
7951
                                                message = QString("%1\n%2").arg(message).arg(errorMsg);
 
7952
                                        QMessageBox::warning(this, CommonStrings::trWarning, message, CommonStrings::tr_OK);
7816
7953
                                        return;
7817
7954
                                }
7818
7955
                                aa++;
7825
7962
                        {
7826
7963
                                QPixmap pm(10,10);
7827
7964
                                if (doc->PDF_Options.Thumbnails)
7828
 
                                        pm.convertFromImage(view->PageToPixmap(pageNs[ap]-1, 100));
 
7965
                                        pm=QPixmap::fromImage(view->PageToPixmap(pageNs[ap]-1, 100));
7829
7966
                                thumbs.insert(pageNs[ap], pm);
7830
7967
                        }
7831
 
                        if (!getPDFDriver(fileName, nam, components, pageNs, thumbs))
 
7968
                        if (!getPDFDriver(fileName, nam, components, pageNs, thumbs, errorMsg))
7832
7969
                        {
7833
 
                                qApp->setOverrideCursor(QCursor(arrowCursor), true);
7834
 
                                QMessageBox::warning(this, CommonStrings::trWarning, tr("Cannot write the file: \n%1").arg(doc->PDF_Options.Datei), CommonStrings::tr_OK);
 
7970
                                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
 
7971
                                QString message = tr("Cannot write the file: \n%1").arg(doc->PDF_Options.fileName);
 
7972
                                if (!errorMsg.isEmpty())
 
7973
                                        message = QString("%1\n%2").arg(message).arg(errorMsg);
 
7974
                                QMessageBox::warning(this, CommonStrings::trWarning, message, CommonStrings::tr_OK);
7835
7975
                        }
7836
7976
                }
7837
7977
                if (doc->PDF_Options.useDocBleeds)
7838
7978
                        doc->PDF_Options.bleeds = optBleeds;
7839
 
                qApp->setOverrideCursor(QCursor(arrowCursor), true);
 
7979
                qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
7840
7980
        }
7841
7981
}
7842
7982
 
7844
7984
void ScribusMainWindow::AddBookMark(PageItem *ite)
7845
7985
{
7846
7986
        bookmarkPalette->BView->AddPageItem(ite);
7847
 
        StoreBookmarks();
7848
7987
}
7849
7988
 
7850
7989
//CB-->Doc, stop _storing_ bookmarks in the palette
7851
7990
void ScribusMainWindow::DelBookMark(PageItem *ite)
7852
7991
{
7853
7992
        bookmarkPalette->BView->DeleteItem(ite);
7854
 
        StoreBookmarks();
7855
7993
}
7856
7994
 
7857
7995
//CB-->Doc, stop _storing_ bookmarks in the palette
7858
7996
void ScribusMainWindow::BookMarkTxT(PageItem *ite)
7859
7997
{
7860
7998
        bookmarkPalette->BView->ChangeText(ite);
7861
 
        StoreBookmarks();
7862
7999
}
7863
8000
 
7864
8001
//CB-->Doc, stop _storing_ bookmarks in the palette
7865
8002
void ScribusMainWindow::RestoreBookMarks()
7866
8003
{
7867
 
        QValueList<ScribusDoc::BookMa>::Iterator it2 = doc->BookMarks.begin();
 
8004
        QList<ScribusDoc::BookMa>::Iterator it2 = doc->BookMarks.begin();
7868
8005
        bookmarkPalette->BView->clear();
7869
8006
        bookmarkPalette->BView->NrItems = 0;
7870
8007
        bookmarkPalette->BView->First = 1;
7886
8023
                }
7887
8024
                else
7888
8025
                {
7889
 
                        QListViewItemIterator it3(bookmarkPalette->BView);
7890
 
                        for ( ; it3.current(); ++it3)
 
8026
                        QTreeWidgetItemIterator it3(bookmarkPalette->BView);
 
8027
                        while (*it3)
7891
8028
                        {
7892
 
                                ip = (BookMItem*)it3.current();
 
8029
                                ip = (BookMItem*)(*it3);
7893
8030
                                if ((*it2).Parent == ip->ItemNr)
7894
8031
                                {
7895
8032
                                        ip2 = ip;
7896
8033
                                        break;
7897
8034
                                }
 
8035
                                ++it3;
7898
8036
                        }
7899
8037
                        if ((*it2).Prev == 0)
7900
8038
                        {
7903
8041
                        }
7904
8042
                        else
7905
8043
                        {
7906
 
                                QListViewItemIterator it4(bookmarkPalette->BView);
7907
 
                                for ( ; it4.current(); ++it4)
 
8044
                                QTreeWidgetItemIterator it4(bookmarkPalette->BView);
 
8045
                                while (*it4)
7908
8046
                                {
7909
 
                                        ip = (BookMItem*)it4.current();
 
8047
                                        ip = (BookMItem*)(*it4);
7910
8048
                                        if ((*it2).Prev == ip->ItemNr)
7911
8049
                                        {
7912
8050
                                                ip3 = ip;
7913
8051
                                                break;
7914
8052
                                        }
 
8053
                                        ++it4;
7915
8054
                                }
7916
8055
                                (void) new BookMItem(ip2, ip3, &(*it2));
7917
8056
                                bookmarkPalette->BView->NrItems++;
7919
8058
                }
7920
8059
        }
7921
8060
        bookmarkPalette->BView->Last = bookmarkPalette->BView->NrItems;
 
8061
        bookmarkPalette->BView->rebuildTree();
7922
8062
}
7923
8063
 
7924
8064
//CB-->Doc, stop _storing_ bookmarks in the palette
7926
8066
{
7927
8067
        doc->BookMarks.clear();
7928
8068
        BookMItem* ip;
7929
 
        QListViewItemIterator it(bookmarkPalette->BView);
 
8069
        QTreeWidgetItemIterator it(bookmarkPalette->BView);
7930
8070
        struct ScribusDoc::BookMa Boma;
7931
 
        for ( ; it.current(); ++it)
 
8071
        while (*it)
7932
8072
        {
7933
 
                ip = (BookMItem*)it.current();
 
8073
                ip = (BookMItem*)(*it);
7934
8074
                Boma.Title = ip->Titel;
7935
8075
                Boma.Text = ip->text(0);
7936
8076
                Boma.Aktion = ip->Action;
7944
8084
                Boma.Next = ip->Next;
7945
8085
                Boma.Last = ip->Last;
7946
8086
                doc->BookMarks.append(Boma);
 
8087
                ++it;
7947
8088
        }
7948
8089
        doc->NrItems = bookmarkPalette->BView->NrItems;
7949
8090
        doc->First = bookmarkPalette->BView->First;
7952
8093
 
7953
8094
void ScribusMainWindow::slotElemRead(QString xml, double x, double y, bool art, bool loca, ScribusDoc* docc, ScribusView* vie)
7954
8095
{
7955
 
        if (doc == docc)
7956
 
                NoFrameEdit();
7957
 
        
7958
 
        ScriXmlDoc *ss = new ScriXmlDoc();
7959
 
        if(ss->ReadElem(xml, prefsManager->appPrefs.AvailFonts, docc, x, y, art, loca, prefsManager->appPrefs.GFontSub, vie))
 
8096
        if (doc == docc && docc->appMode == modeEditClip)
 
8097
                view->requestMode(submodeEndNodeEdit);
 
8098
 
 
8099
        ScriXmlDoc ss;
 
8100
        if(ss.ReadElem(xml, prefsManager->appPrefs.AvailFonts, docc, x, y, art, loca, prefsManager->appPrefs.GFontSub, vie))
7960
8101
        {
7961
8102
                vie->DrawNew();
7962
8103
                if (doc == docc)
7963
8104
                {
7964
 
                        buildFontMenu();
7965
8105
                        propertiesPalette->updateColorList();
7966
8106
                        propertiesPalette->paraStyleCombo->updateFormatList();
7967
8107
                        propertiesPalette->charStyleCombo->updateFormatList();
7969
8109
                        slotDocCh();
7970
8110
                }
7971
8111
        }
7972
 
        delete ss;
7973
8112
}
7974
8113
 
7975
8114
void ScribusMainWindow::slotChangeUnit(int unitIndex, bool draw)
7976
8115
{
 
8116
        // Hack
 
8117
        QByteArray stylesheet;
 
8118
        if (loadRawText(ScPaths::getApplicationDataDir() + "/stylesheet.css", stylesheet))
 
8119
        {
 
8120
                qApp->setStyleSheet(QString(stylesheet));
 
8121
        }
 
8122
 
7977
8123
        doc->setUnitIndex(unitIndex);
7978
 
        view->unitSwitcher->setCurrentText(unitGetStrFromIndex(doc->unitIndex()));
 
8124
        setCurrentComboItem(view->unitSwitcher, unitGetStrFromIndex(doc->unitIndex()));
7979
8125
        propertiesPalette->unitChange();
7980
8126
        nodePalette->unitChange();
7981
8127
        alignDistributePalette->unitChange();
8023
8169
                        scrActions["pageApplyMasterPage"]->setEnabled(false);
8024
8170
                        scrActions["pageCopyToMasterPage"]->setEnabled(false);
8025
8171
                        scrActions["editMasterPages"]->setEnabled(false);
8026
 
                        ActWin->setMenuStatus(0, scrActions["fileSave"]->isEnabled());
8027
 
                        ActWin->setMenuStatus(1, scrActions["fileRevert"]->isEnabled());
8028
 
                        ActWin->setMenuStatus(2, scrActions["fileSave"]->isEnabled());
8029
 
                        ActWin->setMenuStatus(3, scrActions["fileSaveAs"]->isEnabled());
8030
8172
                        scrActions["fileNew"]->setEnabled(false);
8031
8173
                        scrActions["fileOpen"]->setEnabled(false);
8032
8174
                        scrActions["fileClose"]->setEnabled(false);
8035
8177
                        scrActions["fileDocSetup"]->setEnabled(false);
8036
8178
                        scrActions["filePrint"]->setEnabled(false);
8037
8179
                        scrActions["PrintPreview"]->setEnabled(false);
 
8180
                        scrActions["toolsPDFPushButton"]->setEnabled(false);
 
8181
                        scrActions["toolsPDFTextField"]->setEnabled(false);
 
8182
                        scrActions["toolsPDFCheckBox"]->setEnabled(false);
 
8183
                        scrActions["toolsPDFComboBox"]->setEnabled(false);
 
8184
                        scrActions["toolsPDFListBox"]->setEnabled(false);
 
8185
                        scrActions["toolsPDFAnnotText"]->setEnabled(false);
8038
8186
                        pagePalette->enablePalette(false);
8039
8187
                        dia->show();
8040
8188
                        ActWin->setMasterPagesPalette(dia);
8046
8194
{
8047
8195
        view->setScale(storedViewScale);
8048
8196
        view->hideMasterPage();
8049
 
        setAppMode(modeNormal);
 
8197
        slotSelect();
8050
8198
        scrActions["editMasterPages"]->setEnabled(true);
8051
8199
        scrActions["fileNew"]->setEnabled(true);
8052
8200
        scrActions["fileOpen"]->setEnabled(true);
8056
8204
        scrActions["fileRevert"]->setEnabled(true);
8057
8205
        scrActions["fileDocSetup"]->setEnabled(true);
8058
8206
        scrActions["filePrint"]->setEnabled(true);
8059
 
        if ( ScCore->haveGS()==0 || ScCore->isWinGUI() )
 
8207
        if ( ScCore->haveGS() || ScCore->isWinGUI() )
8060
8208
                scrActions["PrintPreview"]->setEnabled(true);
8061
8209
        scrActions["pageInsert"]->setEnabled(true);
8062
8210
        scrActions["pageCopy"]->setEnabled(true);
8066
8214
        bool setter = doc->Pages->count() > 1 ? true : false;
8067
8215
        scrActions["pageDelete"]->setEnabled(setter);
8068
8216
        scrActions["pageMove"]->setEnabled(setter);
 
8217
        scrActions["toolsPDFPushButton"]->setEnabled(true);
 
8218
        scrActions["toolsPDFTextField"]->setEnabled(true);
 
8219
        scrActions["toolsPDFCheckBox"]->setEnabled(true);
 
8220
        scrActions["toolsPDFComboBox"]->setEnabled(true);
 
8221
        scrActions["toolsPDFListBox"]->setEnabled(true);
 
8222
        scrActions["toolsPDFAnnotText"]->setEnabled(true);
8069
8223
        uint pageCount=doc->DocPages.count();
8070
8224
        for (uint c=0; c<pageCount; ++c)
8071
8225
                Apply_MasterPage(doc->DocPages.at(c)->MPageNam, c, false);
8072
8226
//      doc->setMasterPageMode(false);
8073
8227
        pagePalette->enablePalette(true);
8074
 
        pagePalette->RebuildTemp();
 
8228
        pagePalette->rebuildMasters();
8075
8229
        ActWin->setMasterPagesPalette(NULL);
8076
8230
        doc->setCurrentPage(doc->DocPages.at(storedPageNum));
8077
8231
        view->reformPages(false);
8148
8302
{
8149
8303
        if (HaveDoc)
8150
8304
        {
8151
 
                if (doc->m_Selection->count() < 2)
 
8305
                Selection* itemSelection = doc->m_Selection;
 
8306
                if (itemSelection->count() < 2)
8152
8307
                        return;
8153
 
                PageItem *currItem;
8154
 
                PageItem* bb;
8155
 
                double x, y, w, h;
8156
 
                QString tooltip = Um::ItemsInvolved + "\n";
8157
 
                uint selectedItemCount=doc->m_Selection->count();
 
8308
                bool lockObject = false;
 
8309
                bool modifyLock = false;
 
8310
                uint selectedItemCount=itemSelection->count();
8158
8311
                if (showLockDia)
8159
8312
                {
8160
8313
                        uint lockedCount=0;
8161
8314
                        for (uint a=0; a<selectedItemCount; ++a)
8162
8315
                        {
8163
 
                                if (doc->m_Selection->itemAt(a)->locked())
 
8316
                                if (itemSelection->itemAt(a)->locked())
8164
8317
                                        ++lockedCount;
8165
8318
                        }
8166
 
                        int t=-1;
8167
8319
                        if (lockedCount!=0 && lockedCount!=selectedItemCount)
8168
8320
                        {
8169
 
                                t = QMessageBox::warning(this, CommonStrings::trWarning,
8170
 
                                                                                        tr("Some objects are locked."),
8171
 
                                                                                        CommonStrings::tr_Cancel,
8172
 
                                                                                        tr("&Lock All"),
8173
 
                                                                                        tr("&Unlock All"), 0, 0);
8174
 
                                if (t == 0)
8175
 
                                        return; // user chose cancel -> do not group but return
8176
 
                                for (uint a=0; a<selectedItemCount; ++a)
8177
 
                                {
8178
 
                                        currItem = doc->m_Selection->itemAt(a);
8179
 
                                        if (currItem->locked())
8180
 
                                        {
8181
 
                                                for (uint c=0; c<selectedItemCount; ++c)
8182
 
                                                {
8183
 
                                                        bb = doc->m_Selection->itemAt(c);
8184
 
                                                        bool t1=(t==1);
8185
 
                                                        bb->setLocked(t1);
8186
 
                                                        scrActions["itemLock"]->setOn(t1);
8187
 
                                                        tooltip += "\t" + currItem->getUName() + "\n";
8188
 
                                                }
8189
 
                                        }
8190
 
                                }
8191
 
                        }
8192
 
                }
8193
 
                doc->m_Selection->getGroupRect(&x, &y, &w, &h);
8194
 
                uint lowestItem = 999999;
8195
 
                uint highestItem = 0;
8196
 
                for (uint a=0; a<selectedItemCount; ++a)
8197
 
                {
8198
 
                        currItem = doc->m_Selection->itemAt(a);
8199
 
                        currItem->gXpos = currItem->xPos() - x;
8200
 
                        currItem->gYpos = currItem->yPos() - y;
8201
 
                        currItem->gWidth = w;
8202
 
                        currItem->gHeight = h;
8203
 
                        lowestItem = QMIN(lowestItem, currItem->ItemNr);
8204
 
                        highestItem = QMAX(highestItem, currItem->ItemNr);
8205
 
                }
8206
 
                double minx = 99999.9;
8207
 
                double miny = 99999.9;
8208
 
                double maxx = -99999.9;
8209
 
                double maxy = -99999.9;
8210
 
                for (uint ep = 0; ep < selectedItemCount; ++ep)
8211
 
                {
8212
 
                        PageItem* currItem = doc->m_Selection->itemAt(ep);
8213
 
                        double lw = currItem->lineWidth() / 2.0;
8214
 
                        if (currItem->rotation() != 0)
8215
 
                        {
8216
 
                                FPointArray pb;
8217
 
                                pb.resize(0);
8218
 
                                pb.addPoint(FPoint(currItem->xPos()-lw, currItem->yPos()-lw));
8219
 
                                pb.addPoint(FPoint(currItem->width()+lw*2.0, -lw, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
8220
 
                                pb.addPoint(FPoint(currItem->width()+lw*2.0, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
8221
 
                                pb.addPoint(FPoint(-lw, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
8222
 
                                for (uint pc = 0; pc < 4; ++pc)
8223
 
                                {
8224
 
                                        minx = QMIN(minx, pb.point(pc).x());
8225
 
                                        miny = QMIN(miny, pb.point(pc).y());
8226
 
                                        maxx = QMAX(maxx, pb.point(pc).x());
8227
 
                                        maxy = QMAX(maxy, pb.point(pc).y());
8228
 
                                }
8229
 
                        }
8230
 
                        else
8231
 
                        {
8232
 
                                minx = QMIN(minx, currItem->xPos()-lw);
8233
 
                                miny = QMIN(miny, currItem->yPos()-lw);
8234
 
                                maxx = QMAX(maxx, currItem->xPos()-lw + currItem->width()+lw*2.0);
8235
 
                                maxy = QMAX(maxy, currItem->yPos()-lw + currItem->height()+lw*2.0);
8236
 
                        }
8237
 
                }
8238
 
                double gx = minx;
8239
 
                double gy = miny;
8240
 
                double gw = maxx - minx;
8241
 
                double gh = maxy - miny;
8242
 
                PageItem *high = doc->Items->at(highestItem);
8243
 
                undoManager->setUndoEnabled(false);
8244
 
                int z = doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, gx, gy, gw, gh, 0, doc->toolSettings.dBrush, doc->toolSettings.dPen, true);
8245
 
                PageItem *neu = doc->Items->take(z);
8246
 
                doc->Items->insert(lowestItem, neu);
8247
 
                neu->setItemName( tr("Group%1").arg(doc->GroupCounter));
8248
 
                neu->AutoName = false;
8249
 
                neu->isGroupControl = true;
8250
 
                neu->groupsLastItem = high;
8251
 
                undoManager->setUndoEnabled(true);
8252
 
 
8253
 
                QMap<int, uint> ObjOrder;
8254
 
                for (uint c = 0; c < selectedItemCount; ++c)
8255
 
                {
8256
 
                        currItem = doc->m_Selection->itemAt(c);
8257
 
                        ObjOrder.insert(currItem->ItemNr, c);
8258
 
                        int d = doc->Items->findRef(currItem);
8259
 
                        doc->Items->take(d);
8260
 
                }
8261
 
                QValueList<uint> Oindex = ObjOrder.values();
8262
 
                for (int c = static_cast<int>(Oindex.count()-1); c > -1; c--)
8263
 
                {
8264
 
                        doc->Items->insert(lowestItem+1, doc->m_Selection->itemAt(Oindex[c]));
8265
 
                }
8266
 
 
8267
 
                doc->renumberItemsInListOrder();
8268
 
                doc->m_Selection->prependItem(neu);
8269
 
                selectedItemCount=doc->m_Selection->count();
8270
 
                SimpleState *ss = new SimpleState(Um::Group, tooltip);
8271
 
                ss->set("GROUP", "group");
8272
 
                ss->set("itemcount", selectedItemCount);
8273
 
 
8274
 
                for (uint a=0; a<selectedItemCount; ++a)
8275
 
                {
8276
 
                        currItem = doc->m_Selection->itemAt(a);
8277
 
                        currItem->Groups.push(doc->GroupCounter);
8278
 
                        ss->set(QString("item%1").arg(a), currItem->uniqueNr);
8279
 
                }
8280
 
                doc->GroupCounter++;
8281
 
                view->updateContents(QRect(static_cast<int>(x-5), static_cast<int>(y-5), static_cast<int>(w+10), static_cast<int>(h+10)));
8282
 
                slotDocCh();
8283
 
                scrActions["itemAttachTextToPath"]->setEnabled(false);
8284
 
                scrActions["itemGroup"]->setEnabled(false);
8285
 
                scrActions["itemUngroup"]->setEnabled(true);
8286
 
                undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup);
 
8321
                                QMessageBox msgBox;
 
8322
                                QPushButton *abortButton = msgBox.addButton(QMessageBox::Cancel);
 
8323
                                QPushButton *lockButton = msgBox.addButton(tr("&Lock All"), QMessageBox::AcceptRole);
 
8324
                                QPushButton *unlockButton = msgBox.addButton(tr("&Unlock All"), QMessageBox::AcceptRole);
 
8325
                                msgBox.setIcon(QMessageBox::Warning);
 
8326
                                msgBox.setWindowTitle(CommonStrings::trWarning);
 
8327
                                msgBox.setText( tr("Some objects are locked."));
 
8328
                                msgBox.exec();
 
8329
                                if (msgBox.clickedButton() == abortButton)
 
8330
                                        return;
 
8331
                                else if (msgBox.clickedButton() == lockButton)
 
8332
                                        lockObject = true;
 
8333
                                modifyLock = true;
 
8334
                                unlockButton = NULL;    // just to silence the compiler
 
8335
                        }
 
8336
                }
 
8337
                doc->itemSelection_GroupObjects(modifyLock, lockObject);
8287
8338
        }
8288
8339
}
8289
8340
 
8291
8342
void ScribusMainWindow::UnGroupObj()
8292
8343
{
8293
8344
        if (HaveDoc)
8294
 
        {
8295
 
                if (doc->m_Selection->count() != 0)
8296
 
                {
8297
 
                        uint docSelectionCount=doc->m_Selection->count();
8298
 
                        PageItem *currItem;
8299
 
                        uint lowestItem = 999999;
8300
 
                        for (uint a=0; a<docSelectionCount; ++a)
8301
 
                        {
8302
 
                                currItem = doc->m_Selection->itemAt(a);
8303
 
                                if (currItem->Groups.count() != 0)
8304
 
                                        currItem->Groups.pop();
8305
 
                                lowestItem = QMIN(lowestItem, currItem->ItemNr);
8306
 
                        }
8307
 
                        if (doc->Items->at(lowestItem)->isGroupControl)
8308
 
                        {
8309
 
                                doc->m_Selection->removeItem(doc->Items->at(lowestItem));
8310
 
                                doc->Items->remove(lowestItem);
8311
 
                                doc->renumberItemsInListOrder();
8312
 
                        }
8313
 
                        docSelectionCount = doc->m_Selection->count();
8314
 
                        SimpleState *ss = new SimpleState(Um::Ungroup);
8315
 
                        ss->set("UNGROUP", "ungroup");
8316
 
                        ss->set("itemcount", docSelectionCount);
8317
 
                        QString tooltip = Um::ItemsInvolved + "\n";
8318
 
                        slotDocCh();
8319
 
                        HaveNewSel(doc->m_Selection->itemAt(0)->itemType());
8320
 
                        doc->m_Selection->itemAt(0)->emitAllToGUI();
8321
 
                        for (uint a=0; a<docSelectionCount; ++a)
8322
 
                        {
8323
 
                                currItem = doc->m_Selection->itemAt(a);
8324
 
                                ss->set(QString("item%1").arg(a), currItem->uniqueNr);
8325
 
                                ss->set(QString("tableitem%1").arg(a), currItem->isTableItem);
8326
 
                                tooltip += "\t" + currItem->getUName() + "\n";
8327
 
                                currItem->isTableItem = false;
8328
 
                                currItem->setSelected(true);
8329
 
                                currItem->paintObj();
8330
 
                        }
8331
 
                        undoManager->action(this, ss, Um::SelectionGroup, Um::IGroup);
8332
 
                }
8333
 
        }
 
8345
                doc->itemSelection_UnGroupObjects();
8334
8346
}
8335
8347
 
8336
8348
void ScribusMainWindow::restore(UndoState* state, bool isUndo)
8351
8363
 
8352
8364
void ScribusMainWindow::restoreDeletePage(SimpleState *state, bool isUndo)
8353
8365
{
8354
 
        uint pagenr   = state->getUInt("PAGENR");
8355
 
        QStringList tmpl = state->get("MASTERPAGE");
8356
8366
        int where, wo;
 
8367
        int pagenr = state->getUInt("PAGENR");
 
8368
        QStringList tmpl;
 
8369
        tmpl << state->get("MASTERPAGE");
 
8370
        QString pageName = state->get("PAGENAME");
 
8371
        bool oldPageMode = doc->masterPageMode();
 
8372
        if (!pageName.isEmpty() && !oldPageMode) // We try do undo a master page deletion in standard mode
 
8373
                doc->setMasterPageMode(true);
8357
8374
        if (pagenr == 1)
8358
8375
        {
8359
8376
                where = 0;
8373
8390
        {
8374
8391
                if (doc->masterPageMode())
8375
8392
                {
8376
 
                        slotNewMasterPage(wo, tmpl[0]);
 
8393
                        slotNewMasterPage(wo, pageName);
8377
8394
                }
8378
8395
                else
8379
8396
                {
8391
8408
                state->set("DUMMY_ID", id);
8392
8409
                DeletePage(pagenr, pagenr);
8393
8410
        }
 
8411
        if (!pageName.isEmpty() && !oldPageMode)
 
8412
        {
 
8413
                doc->setMasterPageMode(oldPageMode);
 
8414
                doc->rebuildMasterNames();
 
8415
                pagePalette->rebuildMasters();
 
8416
        }
 
8417
        if (doc->masterPageMode() && !pageName.isEmpty())
 
8418
                ActWin->masterPagesPalette()->updateMasterPageList();
 
8419
        pagePalette->rebuildPages();
8394
8420
}
8395
8421
 
8396
8422
void ScribusMainWindow::restoreAddPage(SimpleState *state, bool isUndo)
8398
8424
        int wo    = state->getInt("PAGE");
8399
8425
        int where = state->getInt("WHERE");
8400
8426
        int count = state->getInt("COUNT");
8401
 
        QStringList based = QStringList::split("|", state->get("BASED"));
 
8427
        QStringList based = state->get("BASED").split("|", QString::SkipEmptyParts);
8402
8428
        double height = state->getDouble("HEIGHT");
8403
8429
        double width = state->getDouble("WIDTH");
8404
8430
        int orient = state->getInt("ORIENT");
8436
8462
                        undoManager->replaceObject(doc->Pages->at(i)->getUId(), duo);
8437
8463
                        state->set(QString("Page%1").arg(i), static_cast<uint>(did));
8438
8464
                }
8439
 
                NoFrameEdit();
 
8465
                if (HaveDoc && doc->appMode == modeEditClip)
 
8466
                        view->requestMode(submodeEndNodeEdit);
8440
8467
                view->Deselect(true);
8441
8468
                DeletePage(delFrom, delTo);
8442
8469
        }
8478
8505
                for (uint a=0; a<docSelectionCount; ++a)
8479
8506
                {
8480
8507
                        currItem = doc->m_Selection->itemAt(a);
8481
 
                        lowestItem = QMIN(lowestItem, currItem->ItemNr);
 
8508
                        lowestItem = qMin(lowestItem, currItem->ItemNr);
8482
8509
                }
8483
8510
                if ((lowestItem > 0) && (doc->Items->at(lowestItem-1)->Groups.count() != 0))
8484
8511
                {
8517
8544
                for (uint a=0; a<docSelectionCount; ++a)
8518
8545
                {
8519
8546
                        currItem = doc->m_Selection->itemAt(a);
8520
 
                        lowestItem = QMIN(lowestItem, currItem->ItemNr);
 
8547
                        lowestItem = qMin(lowestItem, currItem->ItemNr);
8521
8548
                }
8522
8549
                if ((lowestItem > 0) && (doc->Items->at(lowestItem-1)->Groups.count() != 0))
8523
8550
                {
8538
8565
                connect(dia, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
8539
8566
                connect(dia, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
8540
8567
                connect(dia, SIGNAL(selectElement(int, int, bool)), this, SLOT(selectItemsFromOutlines(int, int, bool)));
8541
 
                connect(dia, SIGNAL(refreshItem(PageItem*)), view, SLOT(RefreshItem(PageItem*)));
 
8568
//              connect(dia, SIGNAL(refreshItem(PageItem*)), view, SLOT(RefreshItem(PageItem*)));
8542
8569
                dia->exec();
8543
8570
                delete dia;
8544
8571
        }
8554
8581
        if (!defNa.isEmpty())
8555
8582
        {
8556
8583
                QFileInfo f(defNa);
8557
 
                dia->setExtension(f.extension(true));
8558
 
                dia->setZipExtension(f.extension(true) + ".gz");
 
8584
                dia->setExtension(f.completeSuffix());
 
8585
                dia->setZipExtension(f.completeSuffix() + ".gz");
8559
8586
                dia->setSelection(defNa);
8560
8587
        }
8561
8588
        if (optionFlags & fdDirectoriesOnly)
8584
8611
                }
8585
8612
                this->repaint();
8586
8613
                retval = dia->selectedFile();
8587
 
                qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
 
8614
                qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
8588
8615
        }
8589
8616
        delete dia;
8590
8617
        return retval;
8597
8624
        if (HaveDoc)
8598
8625
        {
8599
8626
                doc->recalculateColors();
8600
 
                updateColorMenu(dia);
8601
8627
                propertiesPalette->updateColorList();
8602
8628
        }
8603
8629
}
8604
8630
 
8605
8631
void ScribusMainWindow::ModifyAnnot()
8606
8632
{
8607
 
        Q_ASSERT(!doc->masterPageMode());
 
8633
//      Q_ASSERT(!doc->masterPageMode());
8608
8634
        if (doc->m_Selection->count() != 0)
8609
8635
        {
8610
8636
                PageItem *currItem = doc->m_Selection->itemAt(0);
8633
8659
                                slotDocCh();
8634
8660
                        delete dia;
8635
8661
                }
 
8662
                currItem->update();
8636
8663
        }
8637
8664
}
8638
8665
 
8640
8667
{
8641
8668
        for (QMap<QString,Keys>::Iterator it = prefsManager->appPrefs.KeyActions.begin(); it != prefsManager->appPrefs.KeyActions.end(); ++it )
8642
8669
        {
8643
 
                if (!it.data().actionName.isEmpty())
8644
 
                        if (scrActions[it.data().actionName])
8645
 
                                scrActions[it.data().actionName]->setAccel(it.data().keySequence);
 
8670
                if (!it.value().actionName.isEmpty())
 
8671
                        if (scrActions[it.value().actionName])
 
8672
                                scrActions[it.value().actionName]->setShortcut(it.value().keySequence);
8646
8673
        }
8647
8674
}
8648
8675
 
8649
8676
void ScribusMainWindow::PutScrap()
8650
8677
{
8651
 
        ScriXmlDoc *ss = new ScriXmlDoc();
8652
 
        QString objectString = ss->WriteElem(doc, view, doc->m_Selection);
 
8678
        ScriXmlDoc ss;
 
8679
        QString objectString = ss.WriteElem(doc, view, doc->m_Selection);
 
8680
        QDomDocument docu("scridoc");
 
8681
        docu.setContent(objectString);
 
8682
        QDomElement elem = docu.documentElement();
 
8683
        QDomNode DOC = elem.firstChild();
 
8684
        bool first = true;
 
8685
        DOC = elem.firstChild();
 
8686
        while(!DOC.isNull())
 
8687
        {
 
8688
                QDomElement pg = DOC.toElement();
 
8689
                if(pg.tagName() == "ITEM")
 
8690
                {
 
8691
                        if (first)
 
8692
                                pg.setAttribute("ANNAME", doc->m_Selection->itemAt(0)->itemName());
 
8693
                        first = false;
 
8694
                }
 
8695
                DOC = DOC.nextSibling();
 
8696
        }
 
8697
        objectString = docu.toString();
8653
8698
        scrapbookPalette->ObjFromMenu(objectString);
8654
 
        delete ss;
8655
8699
}
8656
8700
 
8657
8701
void ScribusMainWindow::changeLayer(int )
8658
8702
{
 
8703
        if (doc->appMode == modeEdit)
 
8704
                slotSelect();
 
8705
        else if (doc->appMode == modeEditClip)
 
8706
                NoFrameEdit();
8659
8707
        view->Deselect(true);
8660
8708
        rebuildLayersList();
8661
8709
        view->updateLayerMenu();
8662
8710
        view->setLayerMenuText(doc->activeLayerName());
8663
8711
        view->DrawNew();
8664
8712
        bool setter = !doc->layerLocked( doc->activeLayer() );
8665
 
        scrActions["editPaste"]->setEnabled(((!Buffer2.isEmpty()) || (scrapbookPalette->tempBView->objectMap.count() > 0)) && (setter));
 
8713
        scrActions["editPaste"]->setEnabled((ScMimeData::clipboardHasScribusData() || (scrapbookPalette->tempBView->objectMap.count() > 0)) && (setter));
8666
8714
        scrMenuMgr->setMenuEnabled("EditPasteRecent", ((scrapbookPalette->tempBView->objectMap.count() > 0) && (setter)));
8667
8715
        scrActions["editSelectAll"]->setEnabled(setter);
 
8716
        scrActions["editSelectAllOnLayer"]->setEnabled(setter);
8668
8717
        scrActions["editDeselectAll"]->setEnabled(false);
8669
8718
        scrMenuMgr->setMenuEnabled("Insert", setter);
8670
8719
        scrActions["insertFrame"]->setEnabled(setter);
8677
8726
        scrActions["toolsInsertBezier"]->setEnabled(setter);
8678
8727
        scrActions["toolsInsertFreehandLine"]->setEnabled(setter);
8679
8728
        scrActions["toolsInsertPolygon"]->setEnabled(setter);
8680
 
        scrActions["toolsPDFPushButton"]->setEnabled(setter);
8681
 
        scrActions["toolsPDFTextField"]->setEnabled(setter);
8682
 
        scrActions["toolsPDFCheckBox"]->setEnabled(setter);
8683
 
        scrActions["toolsPDFComboBox"]->setEnabled(setter);
8684
 
        scrActions["toolsPDFListBox"]->setEnabled(setter);
8685
 
        scrActions["toolsPDFAnnotText"]->setEnabled(setter);
 
8729
        scrActions["toolsInsertRenderFrame"]->setEnabled(setter);
 
8730
        if (doc->masterPageMode())
 
8731
        {
 
8732
                scrActions["toolsPDFPushButton"]->setEnabled(false);
 
8733
                scrActions["toolsPDFTextField"]->setEnabled(false);
 
8734
                scrActions["toolsPDFCheckBox"]->setEnabled(false);
 
8735
                scrActions["toolsPDFComboBox"]->setEnabled(false);
 
8736
                scrActions["toolsPDFListBox"]->setEnabled(false);
 
8737
                scrActions["toolsPDFAnnotText"]->setEnabled(false);
 
8738
        }
 
8739
        else
 
8740
        {
 
8741
                scrActions["toolsPDFPushButton"]->setEnabled(setter);
 
8742
                scrActions["toolsPDFTextField"]->setEnabled(setter);
 
8743
                scrActions["toolsPDFCheckBox"]->setEnabled(setter);
 
8744
                scrActions["toolsPDFComboBox"]->setEnabled(setter);
 
8745
                scrActions["toolsPDFListBox"]->setEnabled(setter);
 
8746
                scrActions["toolsPDFAnnotText"]->setEnabled(setter);
 
8747
        }
8686
8748
        scrActions["toolsPDFAnnotLink"]->setEnabled(setter);
 
8749
        scrMenuMgr->setMenuEnabled("ItemLayer", doc->layerCount() > 1);
8687
8750
}
8688
8751
 
8689
8752
void ScribusMainWindow::showLayer()
8707
8770
        //Build our list of hyphenation dictionaries we have in the install dir
8708
8771
        //Grab the language abbreviation from it, get the full language text
8709
8772
        //Insert the name as key and a new string list into the map
8710
 
        QString hyphDirName = QDir::convertSeparators(ScPaths::instance().libDir() + "dicts/");
 
8773
        QString hyphDirName = QDir::convertSeparators(ScPaths::instance().dictDir());
8711
8774
        QDir hyphDir(hyphDirName, "*.dic", QDir::Name, QDir::Files | QDir::NoSymLinks);
8712
8775
        if ((hyphDir.exists()) && (hyphDir.count() != 0))
8713
8776
        {
8714
 
                LanguageManager langmgr;
8715
 
                langmgr.init(false);
 
8777
//              LanguageManager langmgr;
 
8778
//              langmgr.init(false);
8716
8779
                QString languageOfHyphFile;
8717
8780
                for (uint dc = 0; dc < hyphDir.count(); ++dc)
8718
8781
                {
8719
8782
                        QFileInfo fi(hyphDir[dc]);
8720
8783
                        QString fileLangAbbrev=fi.baseName().section('_', 1);
8721
 
                        languageOfHyphFile = langmgr.getLangFromAbbrev(fileLangAbbrev, false);
 
8784
                        languageOfHyphFile = LanguageManager::instance()->getLangFromAbbrev(fileLangAbbrev, false);
8722
8785
                        InstLang.insert(languageOfHyphFile, QStringList());
8723
8786
                }
8724
8787
        }
8725
8788
 
8726
8789
        //For each qm file existing, load the file and find the translations of the names
8727
 
        QString pfad = ScPaths::instance().libDir();
 
8790
        QString pfad = ScPaths::instance().translationDir();
8728
8791
        QDir d2(pfad, "*.*", QDir::Name, QDir::Files | QDir::NoSymLinks);
8729
8792
        if ((d2.exists()) && (d2.count() != 0))
8730
8793
        {
8731
8794
                for (uint dc = 0; dc < d2.count(); dc++)
8732
8795
                {
8733
8796
                        QFileInfo fi(pfad + d2[dc]);
8734
 
                        QString ext = fi.extension(false).lower();
 
8797
                        QString ext = fi.suffix().toLower();
8735
8798
                        if (ext == "qm")
8736
8799
                        {
8737
8800
                        QTranslator *trans = new QTranslator(0);
8741
8804
                                for (QMap<QString, QStringList>::Iterator it=InstLang.begin(); it!=InstLang.end(); ++it)
8742
8805
                                {
8743
8806
                                        translatedLang="";
8744
 
                                        translatedLang = trans->findMessage("ScribusMainWindow", it.key(), "").translation();
 
8807
                                        translatedLang = trans->translate("QObject", it.key().toLocal8Bit().data(), "");
8745
8808
                                        if (!translatedLang.isEmpty())
8746
 
                                                it.data().append(translatedLang);
 
8809
                                                it.value().append(translatedLang);
8747
8810
                                }
8748
8811
                                delete trans;
8749
8812
                        }
8750
8813
                }
8751
8814
        }
8752
8815
        //For each hyphenation file, grab the strings and the hyphenation data.
8753
 
        QString lang = QString(QTextCodec::locale()).left(2);
 
8816
        QString lang = QString(QLocale::system().name()).left(2);
8754
8817
        LangTransl.clear();
8755
8818
        prefsManager->appPrefs.Language = "English";
8756
8819
        if ((hyphDir.exists()) && (hyphDir.count() != 0))
8757
8820
        {
8758
 
                LanguageManager langmgr;
8759
 
                langmgr.init(false);
 
8821
                LanguageManager *langmgr(LanguageManager::instance());
 
8822
//              langmgr.init(false);
8760
8823
                QString datein = "";
8761
8824
                for (uint dc = 0; dc < hyphDir.count(); ++dc)
8762
8825
                {
8763
8826
                        QFileInfo fi(hyphDir[dc]);
8764
8827
                        QString fileLangAbbrev=fi.baseName().section('_', 1);
8765
 
                        datein = langmgr.getLangFromAbbrev(fileLangAbbrev);
 
8828
                        datein = langmgr->getLangFromAbbrev(fileLangAbbrev);
8766
8829
                        QString tDatein = datein;
8767
8830
                        datein = GetLang(datein);
8768
8831
                        LangTransl.insert(datein, tDatein);
8769
 
                        Sprachen.insert(datein, hyphDir[dc]);
 
8832
                        langmgr->addHyphLang(fileLangAbbrev, hyphDir[dc]);
 
8833
//                      Sprachen.insert(datein, hyphDir[dc]);
8770
8834
                        if (fileLangAbbrev == lang)
8771
8835
                                prefsManager->appPrefs.Language = datein;
8772
8836
                }
8781
8845
        QMap<QString, QStringList>::Iterator itlend=InstLang.end();
8782
8846
        for (QMap<QString, QStringList>::Iterator itl = InstLang.begin(); itl != itlend; ++itl)
8783
8847
        {
8784
 
                QStringList::Iterator itlrend=itl.data().end();
8785
 
                for (QStringList::Iterator itlr = itl.data().begin(); itlr != itlrend; ++itlr)
8786
 
                {
8787
 
                        if ((*itlr) == inLang)
8788
 
                                return itl.key();
8789
 
                }
 
8848
                if (itl.value().contains(inLang))
 
8849
                        return itl.key();
8790
8850
        }
8791
8851
        return inLang;
8792
8852
}
8811
8871
        CollectForOutput c(doc, withFonts, withProfiles, compress);
8812
8872
        return c.collect();
8813
8873
}
8814
 
/*
8815
 
void ScribusMainWindow::ReorgFonts()
8816
 
{
8817
 
        doc->reorganiseFonts();
8818
 
        buildFontMenu();
8819
 
}
8820
 
*/
 
8874
 
8821
8875
void ScribusMainWindow::docCheckToggle(bool visible)
8822
8876
{
8823
8877
        if (!visible)
8845
8899
 
8846
8900
bool ScribusMainWindow::scanDocument()
8847
8901
{
8848
 
        DocumentChecker docChecker;
8849
 
        return docChecker.checkDocument(doc);
8850
 
}
8851
 
 
8852
 
void ScribusMainWindow::HaveRaster(bool art)
8853
 
{
8854
 
        if (art && doc->m_Selection->count() != 0)
8855
 
        {
8856
 
                PageItem *currItem = doc->m_Selection->itemAt(0);
8857
 
                if (currItem->asImageFrame())
8858
 
                {
8859
 
                        scrMenuMgr->clearMenu("Style");
8860
 
                        scrMenuMgr->addMenuToMenu("Color","Style");
8861
 
                        scrMenuMgr->addMenuItem(scrActions["styleImageEffects"], "Style");
8862
 
                }
8863
 
        }
 
8902
        return DocumentChecker().checkDocument(doc);
8864
8903
}
8865
8904
 
8866
8905
void ScribusMainWindow::slotStoryEditor()
8904
8943
                        doc->setModified(false);
8905
8944
                        if (doc->hasName)
8906
8945
                        {
8907
 
                                std::cout << "Saving: " << doc->DocName+".emergency" << std::endl;
 
8946
                                std::cout << "Saving: " << doc->DocName.toStdString() << ".emergency" << std::endl;
8908
8947
                                doc->autoSaveTimer->stop();
8909
8948
                                //disconnect(ActWin, SIGNAL(Schliessen()), ScMW, SLOT(DoFileClose()));
8910
8949
                                FileLoader fl(doc->DocName+".emergency");
8933
8972
                                ParagraphStyle newTabs(currItem->itemText.defaultStyle());
8934
8973
                                newTabs.setTabValues(dia->tmpTab);
8935
8974
                                currItem->itemText.setDefaultStyle(newTabs);
8936
 
                                view->RefreshItem(currItem);
 
8975
                                currItem->update();
8937
8976
                                slotDocCh();
8938
8977
                        }
8939
8978
                        delete dia;
8944
8983
void ScribusMainWindow::SearchText()
8945
8984
{
8946
8985
        PageItem *currItem = doc->m_Selection->itemAt(0);
8947
 
        setAppMode(modeEdit);
 
8986
        view->requestMode(modeEdit);
8948
8987
        currItem->CPos = 0;
8949
8988
        SearchReplace* dia = new SearchReplace(this, doc, currItem);
8950
8989
        connect(dia, SIGNAL(NewFont(const QString&)), this, SLOT(SetNewFont(const QString&)));
8956
8995
        slotSelect();
8957
8996
}
8958
8997
 
8959
 
void ScribusMainWindow::imageEditorExited()
 
8998
void ScribusMainWindow::imageEditorExited(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/)
8960
8999
{
8961
 
        int ex = 0;
8962
9000
        if ( ExternalApp != 0 )
8963
9001
        {
8964
 
                ex = ExternalApp->exitStatus();
8965
9002
                delete ExternalApp;
8966
9003
                ExternalApp = 0;
8967
9004
        }
8972
9009
{
8973
9010
        if (doc->m_Selection->count() != 0)
8974
9011
        {
 
9012
                //NOTE to reviewers: I added my code to this function,
 
9013
                // - as it performs a similar function,
 
9014
                // - when the frame is a latex frame it makes only sense
 
9015
                //   to run a latex editor
 
9016
                // - IMHO ScribusMainWindow has way to many slots already
 
9017
                // - my code here is short and without sideeffects
 
9018
                PageItem *currItem = doc->m_Selection->itemAt(0);
 
9019
                if (currItem->asLatexFrame()) {
 
9020
                        currItem->asLatexFrame()->runEditor();
 
9021
                        return; //Don't process the functions for imageframes!
 
9022
                }
 
9023
 
8975
9024
                QString imageEditorExecutable=prefsManager->imageEditorExecutable();
8976
9025
                if (ExternalApp != 0)
8977
9026
                {
8979
9028
                        QMessageBox::information(this, tr("Information"), "<qt>" + tr("The program %1 is already running!").arg(ieExe) + "</qt>", 1, 0, 0);
8980
9029
                        return;
8981
9030
                }
8982
 
                PageItem *currItem = doc->m_Selection->itemAt(0);
8983
 
                if (currItem->PicAvail)
 
9031
                if (currItem->PictureIsAvailable)
8984
9032
                {
8985
9033
                        int index;
8986
9034
                        QString imEditor;
8987
9035
                        ExternalApp = new QProcess(NULL);
8988
9036
                        QStringList cmd;
8989
9037
                #if defined(_WIN32)
8990
 
                        index = imageEditorExecutable.find( ".exe" );
 
9038
                        index = imageEditorExecutable.indexOf( ".exe" );
8991
9039
                        if ( index >= 0 )
8992
9040
                                imEditor = imageEditorExecutable.left( index + 4 );
8993
9041
                        imEditor.replace( "\\", "/" );
8994
 
                        cmd.append(imEditor);
8995
9042
                        if ( imEditor.length() < imageEditorExecutable.length() )
8996
9043
                        {
8997
9044
                                int diffLength = imageEditorExecutable.length() - imEditor.length();
8998
9045
                                QString cmdStr = imageEditorExecutable.right( diffLength );
8999
 
                                QStringList cmd1 = QStringList::split( " ", cmdStr);
 
9046
                                QStringList cmd1 = cmdStr.split( " ", QString::SkipEmptyParts);
9000
9047
                                cmd += cmd1;
9001
9048
                        }
9002
9049
                #else
9003
 
                        cmd = QStringList::split(" ", imageEditorExecutable);
 
9050
                        cmd = imageEditorExecutable.split(" ", QString::SkipEmptyParts);
9004
9051
                        if ( cmd.count() > 0 )
9005
9052
                                imEditor = cmd[0];
 
9053
                        cmd.clear();
9006
9054
                #endif
9007
 
                        index = imEditor.findRev( "/" );
 
9055
                        index = imEditor.lastIndexOf( "/" );
9008
9056
                        if (index > -1 )
9009
9057
                        {
9010
9058
                                QString imEditorDir = imEditor.left( index + 1 );
9011
9059
                                ExternalApp->setWorkingDirectory( imEditorDir );
9012
9060
                        }
9013
9061
                        cmd.append(QDir::convertSeparators(currItem->Pfile));
9014
 
                        ExternalApp->setArguments(cmd);
9015
 
                        if ( !ExternalApp->start() )
 
9062
                        ExternalApp->start(imEditor, cmd);
 
9063
                        if (!ExternalApp->waitForStarted())
9016
9064
                        {
9017
9065
                                delete ExternalApp;
9018
9066
                                ExternalApp = 0;
9019
9067
                                QMessageBox::critical(this, CommonStrings::trWarning, "<qt>" + tr("The program %1 is missing!").arg(imageEditorExecutable) + "</qt>", 1, 0, 0);
9020
9068
                                return;
9021
9069
                        }
9022
 
                        connect(ExternalApp, SIGNAL(processExited()), this, SLOT(imageEditorExited()));
 
9070
                        connect(ExternalApp, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(imageEditorExited(int, QProcess::ExitStatus)));
9023
9071
                }
9024
9072
        }
9025
9073
}
9107
9155
        {
9108
9156
                if (doc->appMode == modeEyeDropper)
9109
9157
                {
9110
 
                        qApp->setOverrideCursor(QCursor(ArrowCursor), true);
 
9158
                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
9111
9159
                        releaseMouse();
9112
9160
                        sendToSuper=false;
9113
9161
                        QPixmap pm = QPixmap::grabWindow( QApplication::desktop()->winId(), m->globalPos().x(), m->globalPos().y(), 1, 1);
9114
 
                        QImage i = pm.convertToImage();
 
9162
                        QImage i = pm.toImage();
9115
9163
                        QColor selectedColor=i.pixel(0, 0);
9116
9164
                        bool found=false;
9117
9165
                        ColorList::Iterator it;
9118
9166
                        for (it = doc->PageColors.begin(); it != doc->PageColors.end(); ++it)
9119
9167
                        {
9120
 
                                if (selectedColor== ScColorEngine::getRGBColor(it.data(), doc))
 
9168
                                if (selectedColor== ScColorEngine::getRGBColor(it.value(), doc))
9121
9169
                                {
9122
9170
                                        found=true;
9123
9171
                                        break;
9133
9181
                                QString questionString="<qt>"+ tr("The selected color does not exist in the document's color set. Please enter a name for this new color.")+"</qt>";
9134
9182
                                do
9135
9183
                                {
9136
 
                                        colorName = QInputDialog::getText( tr("Color Not Found"), questionString, QLineEdit::Normal, QString::null, &ok, this);
 
9184
                                        colorName = QInputDialog::getText(this, tr("Color Not Found"), questionString, QLineEdit::Normal, QString::null, &ok);
9137
9185
                                        if (ok)
9138
9186
                                        {
9139
9187
                                                if (doc->PageColors.contains(colorName))
9159
9207
                                        PageItem *currItem=doc->m_Selection->itemAt(i);
9160
9208
                                        if (currItem!=NULL)
9161
9209
                                        {
9162
 
                                                if ((m->stateAfter() & Qt::ControlButton) && (currItem->asTextFrame() || currItem->asPathText()))
 
9210
                                                if ((m->modifiers() & Qt::ControlModifier) && (currItem->asTextFrame() || currItem->asPathText()))
9163
9211
                                                        doc->itemSelection_SetFillColor(colorName); //Text colour
9164
9212
                                                else
9165
 
                                                if (m->stateAfter() & Qt::AltButton) //Line colour
9166
 
                                                        doc->ItemPen(colorName);
 
9213
                                                if (m->modifiers() & Qt::AltModifier) //Line colour
 
9214
                                                        doc->itemSelection_SetItemPen(colorName);
9167
9215
                                                else
9168
 
                                                        doc->ItemBrush(colorName); //Fill colour
 
9216
                                                        doc->itemSelection_SetItemBrush(colorName); //Fill colour
9169
9217
                                        }
9170
9218
                                }
9171
9219
                        }
9172
9220
                        //propertiesPalette->Cpal->SetColors(ScMW->doc->PageColors);
9173
9221
                        //propertiesPalette->updateCList();
9174
 
                        setAppMode(modeNormal);
 
9222
                        slotSelect();
9175
9223
                }
9176
9224
        }
9177
9225
        if (sendToSuper)
9181
9229
 
9182
9230
void ScribusMainWindow::insertSampleText()
9183
9231
{
9184
 
        LoremManager *m = new LoremManager(doc, this, "m", true, 0);
 
9232
        LoremManager *m = new LoremManager(doc, this);
9185
9233
        if (prefsManager->appPrefs.useStandardLI)
9186
9234
                m->insertLoremIpsum("la.xml", prefsManager->appPrefs.paragraphsLI);
9187
9235
        else
9192
9240
 
9193
9241
void ScribusMainWindow::languageChange()
9194
9242
{
 
9243
//      qDebug() << "void ScribusMainWindow::languageChange()";
9195
9244
        if (ScCore->initialized())
9196
9245
        {
9197
9246
                CommonStrings::languageChange();
9205
9254
                //Update menu texts
9206
9255
                if (scrMenuMgr!=NULL && !scrMenuMgr->empty())
9207
9256
                {
9208
 
                        scrMenuMgr->setMenuText("File", tr("&File"));
9209
 
                        scrMenuMgr->setMenuText(recentFileMenuName, tr("Open &Recent"));
9210
 
                        scrMenuMgr->setMenuText(recentPasteMenuName, tr("Paste Recent"));
9211
 
                        scrMenuMgr->setMenuText("FileImport", tr("&Import"));
9212
 
                        scrMenuMgr->setMenuText("FileExport", tr("&Export"));
9213
 
                        scrMenuMgr->setMenuText("Edit", tr("&Edit"));
9214
 
                        scrMenuMgr->setMenuText("EditContents", tr("Contents"));
9215
 
                        scrMenuMgr->setMenuText("Style", tr("St&yle"));
9216
 
                        scrMenuMgr->setMenuText("Color", tr("&Color"));
9217
 
                        scrMenuMgr->setMenuText("FontSize", tr("&Size"));
9218
 
                        scrMenuMgr->setMenuText("Shade", tr("&Shade"));
9219
 
                        scrMenuMgr->setMenuText("Font", tr("&Font"));
9220
 
                        scrMenuMgr->setMenuText("TypeEffects", tr("&Effects"));
9221
 
                        scrMenuMgr->setMenuText("Item", tr("&Item"));
9222
 
                        scrMenuMgr->setMenuText("ItemLevel", tr("&Level"));
9223
 
                        scrMenuMgr->setMenuText("ItemLayer", tr("Send to Layer"));
9224
 
                        scrMenuMgr->setMenuText("ItemPreviewSettings", tr("Previe&w Settings"));
9225
 
                        scrMenuMgr->setMenuText("ItemPDFOptions", tr("&PDF Options"));
9226
 
                        scrMenuMgr->setMenuText("ItemShapes", tr("&Shape"));
9227
 
                        scrMenuMgr->setMenuText("ItemConvertTo", tr("C&onvert To"));
9228
 
                        scrMenuMgr->setMenuText("Insert", tr("I&nsert"));
9229
 
                        scrMenuMgr->setMenuText("InsertChar", tr("Character"));
9230
 
                        scrMenuMgr->setMenuText("InsertQuote", tr("Quote"));
9231
 
                        scrMenuMgr->setMenuText("InsertSpace", tr("Space"));
9232
 
                        scrMenuMgr->setMenuText("InsertLigature", tr("Liga&ture"));
9233
 
                        scrMenuMgr->setMenuText("Page", tr("&Page"));
9234
 
                        scrMenuMgr->setMenuText("View", tr("&View"));
9235
 
                        scrMenuMgr->setMenuText("Tools", tr("&Tools"));
9236
 
                        scrMenuMgr->setMenuText("Extras", tr("E&xtras"));
9237
 
                        scrMenuMgr->setMenuText("Windows", tr("&Windows"));
9238
 
                        scrMenuMgr->setMenuText("Help", tr("&Help"));
9239
 
                        scrMenuMgr->setMenuText("Alignment", tr("&Alignment"));
9240
 
 
9241
 
                        rebuildStyleMenu(HaveDoc ? doc->CurrentSel : -1);
 
9257
                        scrMenuMgr->setText("File", ActionManager::defaultMenuNameEntryTranslated("File"));
 
9258
                        scrMenuMgr->setText(recentFileMenuName, tr("Open &Recent"));
 
9259
                        scrMenuMgr->setText(recentPasteMenuName, tr("Paste Recent"));
 
9260
                        scrMenuMgr->setText("FileImport", tr("&Import"));
 
9261
                        scrMenuMgr->setText("FileExport", tr("&Export"));
 
9262
                        scrMenuMgr->setText("Edit", ActionManager::defaultMenuNameEntryTranslated("Edit"));
 
9263
                        scrMenuMgr->setText("EditContents", tr("Contents"));
 
9264
                        scrMenuMgr->setText("Item", ActionManager::defaultMenuNameEntryTranslated("Item"));
 
9265
                        scrMenuMgr->setText("ItemLevel", tr("&Level"));
 
9266
                        scrMenuMgr->setText("ItemLayer", tr("Send to Layer"));
 
9267
                        scrMenuMgr->setText("ItemPreviewSettings", tr("Previe&w Settings"));
 
9268
                        scrMenuMgr->setText("ItemPDFOptions", tr("&PDF Options"));
 
9269
                        //scrMenuMgr->setText("ItemShapes", tr("&Shape"));
 
9270
                        scrMenuMgr->setText("ItemConvertTo", tr("C&onvert To"));
 
9271
//                      scrMenuMgr->setText("ItemPathOps", tr("Path Tools"));
 
9272
                        scrMenuMgr->setText("Insert", ActionManager::defaultMenuNameEntryTranslated("Insert"));
 
9273
                        scrMenuMgr->setText("InsertChar", tr("Character"));
 
9274
                        scrMenuMgr->setText("InsertQuote", tr("Quote"));
 
9275
                        scrMenuMgr->setText("InsertSpace", tr("Space"));
 
9276
                        scrMenuMgr->setText("InsertLigature", tr("Liga&ture"));
 
9277
                        scrMenuMgr->setText("Page", ActionManager::defaultMenuNameEntryTranslated("Page"));
 
9278
                        scrMenuMgr->setText("View", ActionManager::defaultMenuNameEntryTranslated("View"));
 
9279
//                      scrMenuMgr->setText("Tools", tr("&Tools"));
 
9280
                        scrMenuMgr->setText("Extras", ActionManager::defaultMenuNameEntryTranslated("Extras"));
 
9281
                        scrMenuMgr->setText("Windows", ActionManager::defaultMenuNameEntryTranslated("Windows"));
 
9282
                        scrMenuMgr->setText("Help", ActionManager::defaultMenuNameEntryTranslated("Help"));
 
9283
                        scrMenuMgr->setText("Alignment", tr("&Alignment"));
 
9284
                        scrMenuMgr->setText("HelpOnlineTutorials", tr("Online &Tutorials"));
9242
9285
                }
9243
9286
                if (undoManager!=NULL)
9244
9287
                        undoManager->languageChange();
9258
9301
        PDef.Command = command;
9259
9302
}
9260
9303
 
9261
 
void ScribusMainWindow::getDefaultPrinter(QString *name, QString *file, QString *command)
9262
 
{
9263
 
        *name=PDef.Pname;
9264
 
        *file=PDef.Dname;
9265
 
        *command=PDef.Command;
9266
 
}
9267
 
 
9268
 
void ScribusMainWindow::updateColorMenu(QProgressBar* progressBar)
9269
 
{
9270
 
        disconnect(ColorMenC, SIGNAL(activated(int)), this, SLOT(setItemFarbe(int)));
9271
 
        ColorMenC->clear();
9272
 
        ColorMenC->insertItem(CommonStrings::tr_NoneColor);
9273
 
        if (HaveDoc)
9274
 
        {
9275
 
                if (doc->toolSettings.dBrush == CommonStrings::tr_NoneColor)
9276
 
                        ColorMenC->setCurrentItem(0);
9277
 
                int a = 1;
9278
 
                ColorList::Iterator itend=doc->PageColors.end();
9279
 
                for (ColorList::Iterator it = doc->PageColors.begin(); it != itend; ++it)
9280
 
                {
9281
 
                        ColorMenC->insertSmallItem( it.data(), doc, it.key() );
9282
 
                        if (it.key() == doc->toolSettings.dBrush)
9283
 
                                ColorMenC->setCurrentItem(a);
9284
 
                        ++a;
9285
 
                        if (progressBar != NULL)
9286
 
                                progressBar->setProgress(a);
9287
 
                }
9288
 
        }
9289
 
        connect(ColorMenC, SIGNAL(activated(int)), this, SLOT(setItemFarbe(int)));
 
9304
void ScribusMainWindow::getDefaultPrinter(QString& name, QString& file, QString& command)
 
9305
{
 
9306
        name=PDef.Pname;
 
9307
        file=PDef.Dname;
 
9308
        command=PDef.Command;
9290
9309
}
9291
9310
 
9292
9311
void ScribusMainWindow::closeActiveWindowMasterPageEditor()
9304
9323
{
9305
9324
        if (!HaveDoc)
9306
9325
                return;
9307
 
        ActWin->setCaption(QDir::convertSeparators(newCaption));
 
9326
        ActWin->setWindowTitle(QDir::convertSeparators(newCaption));
9308
9327
}
9309
9328
 
9310
9329
void ScribusMainWindow::dragEnterEvent ( QDragEnterEvent* e)
9311
9330
{
9312
9331
        bool accepted = false;
9313
 
        if ( e->provides("text/uri-list") && QUriDrag::canDecode(e) )
 
9332
        if ( e->mimeData()->hasFormat("text/uri-list"))
9314
9333
        {
9315
9334
                QString fileUrl;
9316
 
                QStringList fileUrls;
9317
 
                QUriDrag::decodeLocalFiles(e, fileUrls);
9318
 
                for( uint i = 0; i < fileUrls.count(); ++i )
 
9335
                QList<QUrl> fileUrls = e->mimeData()->urls();
 
9336
                for( int i = 0; i < fileUrls.count(); ++i )
9319
9337
                {
9320
 
                        fileUrl = fileUrls[i].lower();
 
9338
                        fileUrl = fileUrls[i].toLocalFile().toLower();
9321
9339
                        if ( fileUrl.endsWith(".sla") || fileUrl.endsWith(".sla.gz") )
9322
9340
                        {
9323
 
                                accepted = true;;
 
9341
                                accepted = true;
9324
9342
                                break;
9325
9343
                        }
 
9344
                        else
 
9345
                        {
 
9346
                                QUrl url( fileUrls[i] );
 
9347
                                FileLoader *fileLoader = new FileLoader(url.path());
 
9348
                                int testResult = fileLoader->TestFile();
 
9349
                                delete fileLoader;
 
9350
                                if ((testResult != -1) && (testResult >= FORMATID_ODGIMPORT))
 
9351
                                {
 
9352
                                        accepted = true;
 
9353
                                        break;
 
9354
                                }
 
9355
                        }
9326
9356
                }
9327
9357
        }
9328
 
        e->accept(accepted);
 
9358
        if (accepted)
 
9359
                e->accept();
9329
9360
}
9330
9361
 
9331
9362
void ScribusMainWindow::dropEvent ( QDropEvent * e)
9332
9363
{
9333
9364
        bool accepted = false;
9334
 
        if ( e->provides("text/uri-list") && QUriDrag::canDecode(e) )
 
9365
        if ( e->mimeData()->hasFormat("text/uri-list"))
9335
9366
        {
9336
9367
                QString fileUrl;
9337
 
                QStringList fileUrls;
9338
 
                QUriDrag::decodeLocalFiles(e, fileUrls);
9339
 
                for( uint i = 0; i < fileUrls.count(); ++i )
 
9368
                QList<QUrl> fileUrls = e->mimeData()->urls();
 
9369
                for( int i = 0; i < fileUrls.count(); ++i )
9340
9370
                {
9341
 
                        fileUrl = fileUrls[i].lower();
 
9371
                        fileUrl = fileUrls[i].toLocalFile().toLower();
9342
9372
                        if ( fileUrl.endsWith(".sla") || fileUrl.endsWith(".sla.gz") )
9343
9373
                        {
9344
9374
                                QUrl url( fileUrls[i] );
9346
9376
                                if ( fi.exists() )
9347
9377
                                {
9348
9378
                                        accepted = true;
9349
 
                                        loadDoc( fi.absFilePath() );
 
9379
                                        loadDoc( fi.absoluteFilePath() );
 
9380
                                }
 
9381
                        }
 
9382
                        else
 
9383
                        {
 
9384
                                QUrl url( fileUrls[i] );
 
9385
                                FileLoader *fileLoader = new FileLoader(url.path());
 
9386
                                int testResult = fileLoader->TestFile();
 
9387
                                delete fileLoader;
 
9388
                                if ((testResult != -1) && (testResult >= FORMATID_ODGIMPORT))
 
9389
                                {
 
9390
                                        QFileInfo fi(url.path());
 
9391
                                        if ( fi.exists() )
 
9392
                                        {
 
9393
                                                accepted = true;
 
9394
                                                loadDoc( fi.absoluteFilePath() );
 
9395
                                        }
9350
9396
                                }
9351
9397
                        }
9352
9398
                }
9353
9399
        }
9354
 
        e->accept( accepted );
 
9400
        if (accepted)
 
9401
                e->accept();
9355
9402
}
9356
9403
 
9357
9404
void ScribusMainWindow::slotEditCopyContents()
9363
9410
                if (currItem->itemType()==PageItem::ImageFrame)
9364
9411
                {
9365
9412
                        PageItem_ImageFrame* imageItem=currItem->asImageFrame();
9366
 
                        if (imageItem->PicAvail)
 
9413
                        if (imageItem->PictureIsAvailable)
9367
9414
                        {
9368
 
                                contentsBuffer.sourceType=PageItem::ImageFrame;
9369
 
                                contentsBuffer.contentsFileName=imageItem->Pfile;
9370
 
                                contentsBuffer.LocalScX=imageItem->imageXScale();
9371
 
                                contentsBuffer.LocalScY=imageItem->imageYScale();
9372
 
                                contentsBuffer.LocalX=imageItem->imageXOffset();
9373
 
                                contentsBuffer.LocalY=imageItem->imageYOffset();
9374
 
                                contentsBuffer.ItemX=imageItem->xPos();
9375
 
                                contentsBuffer.ItemY=imageItem->yPos();
9376
 
                                contentsBuffer.inputProfile=imageItem->IProfile;
9377
 
                                contentsBuffer.useEmbedded=imageItem->UseEmbedded;
9378
 
                                contentsBuffer.renderingIntent=imageItem->IRender;
 
9415
                                contentsBuffer.sourceType = PageItem::ImageFrame;
 
9416
                                contentsBuffer.contentsFileName = imageItem->Pfile;
 
9417
                                contentsBuffer.LocalScX = imageItem->imageXScale();
 
9418
                                contentsBuffer.LocalScY = imageItem->imageYScale();
 
9419
                                contentsBuffer.LocalX   = imageItem->imageXOffset();
 
9420
                                contentsBuffer.LocalY   = imageItem->imageYOffset();
 
9421
                                contentsBuffer.ItemX   = imageItem->xPos();
 
9422
                                contentsBuffer.ItemY   = imageItem->yPos();
 
9423
                                contentsBuffer.effects = imageItem->effectsInUse;
 
9424
                                contentsBuffer.inputProfile = imageItem->IProfile;
 
9425
                                contentsBuffer.useEmbedded  = imageItem->UseEmbedded;
 
9426
                                contentsBuffer.renderingIntent = imageItem->IRender;
9379
9427
                        }
9380
9428
                }
9381
9429
        }
9390
9438
                {
9391
9439
                        PageItem_ImageFrame* imageItem=currItem->asImageFrame();
9392
9440
                        int t=QMessageBox::Yes;
9393
 
                        if (imageItem->PicAvail)
9394
 
                                t = ScMessageBox::warning(this, CommonStrings::trWarning,
 
9441
                        if (imageItem->PictureIsAvailable)
 
9442
                                t = QMessageBox::warning(this, CommonStrings::trWarning,
9395
9443
                                                                                tr("Do you really want to replace your existing image?"),
9396
 
                                                                                QMessageBox::Yes, QMessageBox::No | QMessageBox::Default);
 
9444
                                                                                QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
9397
9445
                        if (t == QMessageBox::Yes)
9398
9446
                        {
9399
9447
                                imageItem->EmProfile = "";
9400
9448
                                imageItem->pixm.imgInfo.isRequest = false;
9401
9449
                                imageItem->IProfile = doc->CMSSettings.DefaultImageRGBProfile;
9402
 
                                imageItem->IRender = doc->CMSSettings.DefaultIntentImages;
9403
 
                                qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
9404
 
                                qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
 
9450
                                imageItem->IRender  = doc->CMSSettings.DefaultIntentImages;
 
9451
                                imageItem->effectsInUse = contentsBuffer.effects;
 
9452
                                qApp->changeOverrideCursor( QCursor(Qt::WaitCursor) );
 
9453
                                qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
9405
9454
                                doc->loadPict(contentsBuffer.contentsFileName, imageItem);
9406
9455
                                imageItem->AdjustPictScale();
9407
9456
                                imageItem->setImageXYScale(contentsBuffer.LocalScX, contentsBuffer.LocalScY);
9414
9463
                                imageItem->IProfile=contentsBuffer.inputProfile;
9415
9464
                                imageItem->UseEmbedded=contentsBuffer.useEmbedded;
9416
9465
                                imageItem->IRender=contentsBuffer.renderingIntent;
9417
 
                                qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
9418
 
                                qApp->restoreOverrideCursor();
 
9466
                                qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
9419
9467
                                view->DrawNew();
9420
9468
                                propertiesPalette->updateColorList();
9421
9469
                                propertiesPalette->ShowCMS();
 
9470
                                currItem->emitAllToGUI();
9422
9471
                        }
9423
9472
                }
9424
9473
        }
9443
9492
 
9444
9493
void ScribusMainWindow::PutToPatterns()
9445
9494
{
9446
 
        undoManager->setUndoEnabled(false);
9447
9495
        QString patternName = "Pattern_"+doc->m_Selection->itemAt(0)->itemName();
9448
 
        patternName = patternName.stripWhiteSpace().simplifyWhiteSpace().replace(" ", "_");
9449
 
        ScriXmlDoc *ss = new ScriXmlDoc();
9450
 
        QString objectString = ss->WriteElem(doc, view, doc->m_Selection);
9451
 
        uint ac = doc->Items->count();
 
9496
        patternName = patternName.trimmed().simplified().replace(" ", "_");
 
9497
        Query dia(this, "tt", 1, 0, tr("&Name:"), tr("New Entry"));
 
9498
        dia.setEditText(patternName, true);
 
9499
        if (dia.exec())
 
9500
        {
 
9501
                patternName = dia.getEditText();
 
9502
                while (doc->docPatterns.contains(patternName))
 
9503
                {
 
9504
                        if (!dia.exec())
 
9505
                                return;
 
9506
                        patternName = dia.getEditText();
 
9507
                }
 
9508
        }
 
9509
        else
 
9510
                return;
 
9511
        undoManager->setUndoEnabled(false);
 
9512
        int ac = doc->Items->count();
 
9513
        uint oldNum = doc->TotalItems;
9452
9514
        bool savedAlignGrid = doc->useRaster;
9453
9515
        bool savedAlignGuides = doc->SnapGuides;
 
9516
        internalCopy = true;
9454
9517
        doc->useRaster = false;
9455
9518
        doc->SnapGuides = false;
9456
 
        slotElemRead(objectString, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 
9519
        Selection itemSelection(this, false);
 
9520
        itemSelection.copy(*doc->m_Selection, false);
 
9521
        slotEditCopy();
 
9522
        doc->m_Selection->delaySignalsOn();
 
9523
        view->Deselect(true);
 
9524
        slotEditPaste();
9457
9525
        doc->useRaster = savedAlignGrid;
9458
9526
        doc->SnapGuides = savedAlignGuides;
9459
 
        uint ae = doc->Items->count();
 
9527
        internalCopy = false;
 
9528
        int ae = doc->Items->count();
9460
9529
        ScPattern pat = ScPattern();
9461
9530
        pat.setDoc(doc);
9462
9531
        PageItem* currItem = doc->Items->at(ac);
9463
9532
        pat.pattern = currItem->DrawObj_toImage();
9464
9533
        pat.width = currItem->gWidth;
9465
9534
        pat.height = currItem->gHeight;
9466
 
        for (uint as = ac; as < ae; ++as)
 
9535
        for (int as = ac; as < ae; ++as)
9467
9536
        {
9468
 
                pat.items.append(doc->Items->take(ac));
 
9537
                pat.items.append(doc->Items->takeAt(ac));
9469
9538
        }
9470
9539
        doc->addPattern(patternName, pat);
9471
9540
        propertiesPalette->updateColorList();
9472
 
        delete ss;
 
9541
        if (outlinePalette->isVisible())
 
9542
                outlinePalette->BuildTree();
 
9543
        doc->TotalItems = oldNum;
 
9544
        view->Deselect(true);
 
9545
//      doc->m_Selection->delaySignalsOn();
 
9546
        doc->m_Selection->copy(itemSelection, false);
 
9547
        doc->m_Selection->delaySignalsOff();
 
9548
        view->DrawNew();
9473
9549
        undoManager->setUndoEnabled(true);
9474
9550
}
9475
9551
 
9483
9559
                if (dia->exec())
9484
9560
                {
9485
9561
                        doc->setPatterns(dia->dialogPatterns);
 
9562
                        if (!dia->replaceMap.isEmpty())
 
9563
                        {
 
9564
                                ResourceCollection colorrsc;
 
9565
                                colorrsc.mapPatterns(dia->replaceMap);
 
9566
                                doc->replaceNamedResources(colorrsc);
 
9567
                        }
9486
9568
                        propertiesPalette->updateColorList();
9487
9569
                        view->DrawNew();
9488
 
                        undoManager->setUndoEnabled(true);
9489
9570
                }
9490
9571
                delete dia;
9491
9572
                undoManager->setUndoEnabled(true);
9492
9573
        }
9493
9574
}
9494
9575
 
9495
 
void ScribusMainWindow::enableTextActions(QMap<QString, QGuardedPtr<ScrAction> > *actionMap, bool enabled, const QString& fontName)
 
9576
void ScribusMainWindow::enableTextActions(QMap<QString, QPointer<ScrAction> > *actionMap, bool enabled, const QString& fontName)
9496
9577
{
9497
9578
        actionManager->enableUnicodeActions(actionMap, enabled, fontName);
9498
9579
        scrMenuMgr->setMenuEnabled("InsertChar", enabled);