Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
3 paul 7
/***************************************************************************
8
                          scribus.cpp  -  description
9
                             -------------------
10
    begin                : Fre Apr  6 21:09:31 CEST 2001
11
    copyright            : (C) 2001 by Franz Schmid
12
    email                : Franz.Schmid@altmuehlnet.de
13
 ***************************************************************************/
14
 
15
/***************************************************************************
16
 *                                                                         *
17
 *   This program is free software; you can redistribute it and/or modify  *
18
 *   it under the terms of the GNU General Public License as published by  *
19
 *   the Free Software Foundation; either version 2 of the License, or     *
20
 *   (at your option) any later version.                                   *
21
 *                                                                         *
22
 ***************************************************************************/
23
 
8591 cbradney 24
#include <QApplication>
10862 cbradney 25
#include <QByteArray>
26
#include <QCloseEvent>
27
#include <QColor>
10223 cbradney 28
#include <QColorDialog>
29
#include <QCursor>
8635 cbradney 30
#include <QDesktopWidget>
10862 cbradney 31
#include <QDragEnterEvent>
8501 cbradney 32
#include <QDropEvent>
33
#include <QEvent>
10862 cbradney 34
#include <QEventLoop>
35
#include <QFrame>
36
#include <QIcon>
37
#include <QInputDialog>
8501 cbradney 38
#include <QKeyEvent>
10862 cbradney 39
#include <QKeySequence>
40
#include <QLabel>
41
#include <QList>
42
#include <QLocale>
43
#include <QMouseEvent>
44
#include <QPixmap>
45
#include <QRegExp>
46
#include <QStyleFactory>
9853 fschmid 47
#include <QTableWidget>
10862 cbradney 48
#include <QTextCodec>
49
#include <QTranslator>
50
#include <QWheelEvent>
1208 cbradney 51
 
14539 jghali 52
#ifdef DEBUG_LOAD_TIMES
53
#include <QDebug>
54
#include <QTime>
55
#include <sys/times.h>
56
#endif
57
 
3 paul 58
#include <cstdio>
59
#include <cstdlib>
9082 avox 60
#include <cassert>
2629 craig 61
 
2688 craig 62
#include "scconfig.h"
2629 craig 63
 
64
#ifdef HAVE_DLFCN_H
3 paul 65
#include <dlfcn.h>
2629 craig 66
#endif
67
 
68
#ifdef HAVE_UNISTD_H
135 Franz 69
#include <unistd.h>
2629 craig 70
#endif
71
 
3 paul 72
#include <iostream>
8289 avox 73
#include <sstream>
119 Franz 74
#include <signal.h>
80 Franz 75
#include <string>
1208 cbradney 76
 
13552 cbradney 77
#include "ui/about.h"
13544 cbradney 78
#include "ui/aboutplugins.h"
10212 cbradney 79
#include "actionmanager.h"
13544 cbradney 80
#include "ui/aligndistribute.h"
13650 cbradney 81
#include "ui/annot.h"
82
#include "ui/annota.h"
13552 cbradney 83
#include "ui/applytemplatedialog.h"
13576 cbradney 84
#include "ui/arrowchooser.h"
13650 cbradney 85
#include "ui/autoform.h"
13576 cbradney 86
#include "ui/basepointwidget.h"
13551 cbradney 87
#include "ui/bookmarkpalette.h"
10532 avox 88
#include "canvasmode.h"
13544 cbradney 89
#include "ui/charselect.h"
13650 cbradney 90
#include "ui/checkDocument.h"
13544 cbradney 91
#include "ui/cmsprefs.h"
10212 cbradney 92
#include "collect4output.h"
13650 cbradney 93
#include "ui/colorcombo.h"
94
#include "ui/colorm.h"
10212 cbradney 95
#include "commonstrings.h"
13576 cbradney 96
#include "ui/contextmenu.h"
13551 cbradney 97
#include "ui/cpalette.h"
13552 cbradney 98
#include "ui/customfdialog.h"
13650 cbradney 99
#include "ui/delpages.h"
10862 cbradney 100
#include "desaxe/digester.h"
101
#include "desaxe/saxXML.h"
102
#include "desaxe/simple_actions.h"
10212 cbradney 103
#include "docinfo.h"
13544 cbradney 104
#include "ui/docitemattrprefs.h"
10212 cbradney 105
#include "documentchecker.h"
106
#include "documentinformation.h"
13552 cbradney 107
#include "ui/effectsdialog.h"
506 fschmid 108
#include "fileloader.h"
1151 fschmid 109
#include "filewatcher.h"
13650 cbradney 110
#include "ui/fontcombo.h"
111
#include "ui/fontprefs.h"
6397 cbradney 112
#include "fpoint.h"
3 paul 113
#include "fpointarray.h"
10212 cbradney 114
#include "gtgettext.h"
14150 fschmid 115
#include "ui/gradientmanager.h"
13544 cbradney 116
#include "ui/guidemanager.h"
13576 cbradney 117
#include "ui/helpbrowser.h"
118
#include "ui/hruler.h"
10212 cbradney 119
#include "hyphenator.h"
13544 cbradney 120
#include "ui/hysettings.h"
13552 cbradney 121
#include "ui/imageinfodialog.h"
13544 cbradney 122
#include "ui/insertaframe.h"
13650 cbradney 123
#include "ui/inspage.h"
124
#include "ui/javadocs.h"
10212 cbradney 125
#include "langmgr.h"
13576 cbradney 126
#include "ui/layers.h"
13650 cbradney 127
#include "ui/loremipsum.h"
128
#include "ui/marginwidget.h"
13552 cbradney 129
#include "ui/margindialog.h"
13551 cbradney 130
#include "ui/masterpagepalette.h"
13650 cbradney 131
#include "ui/mergedoc.h"
132
#include "ui/movepage.h"
13544 cbradney 133
#include "ui/multipleduplicate.h"
13650 cbradney 134
#include "ui/newfile.h"
135
#include "ui/newtemp.h"
13188 fschmid 136
#include "nfttemplate.h"
13544 cbradney 137
#include "ui/nftdialog.h"
13188 fschmid 138
#include "ui_nftdialog.h"
13544 cbradney 139
#include "ui/nftwidget.h"
13551 cbradney 140
#include "ui/nodeeditpalette.h"
13839 fschmid 141
#ifdef HAVE_OSG
142
        #include "ui/osgeditor.h"
143
#endif
13551 cbradney 144
#include "ui/outlinepalette.h"
10212 cbradney 145
#include "page.h"
146
#include "pageitem_imageframe.h"
10532 avox 147
#include "pageitem_latexframe.h"
10212 cbradney 148
#include "pageitem_textframe.h"
13544 cbradney 149
#include "ui/pageitemattributes.h"
13650 cbradney 150
#include "ui/pagelayout.h"
13551 cbradney 151
#include "ui/pagepalette.h"
13576 cbradney 152
#include "ui/pageselector.h"
10212 cbradney 153
#include "pagesize.h"
13544 cbradney 154
#include "ui/patterndialog.h"
10862 cbradney 155
#include "pdflib.h"
10212 cbradney 156
#include "pdfoptions.h"
13650 cbradney 157
#include "ui/pdfopts.h"
13544 cbradney 158
#include "ui/picstatus.h"
10212 cbradney 159
#include "pluginmanager.h"
10862 cbradney 160
#include "plugins/formatidlist.h"
13544 cbradney 161
#include "ui/polygonwidget.h"
13761 cbradney 162
#include "ui/preferencesdialog.h"
13576 cbradney 163
#include "ui/prefs.h"
10212 cbradney 164
#include "prefscontext.h"
165
#include "prefsfile.h"
2834 cbradney 166
#include "prefsmanager.h"
10212 cbradney 167
#include "prefstable.h"
13650 cbradney 168
#include "ui/preview.h"
13544 cbradney 169
#include "ui/printdialog.h"
13551 cbradney 170
#include "ui/propertiespalette.h"
10212 cbradney 171
#include "pslib.h"
13650 cbradney 172
#include "ui/query.h"
13576 cbradney 173
#include "ui/reformdoc.h"
13544 cbradney 174
#include "ui/replacecolors.h"
10212 cbradney 175
#include "resourcecollection.h"
176
#include "sccolorengine.h"
13650 cbradney 177
#include "ui/sccombobox.h"
10532 avox 178
#include "scgtplugin.h"
13576 cbradney 179
#include "ui/scmessagebox.h"
12841 jghali 180
#include "scmimedata.h"
10532 avox 181
#include "scpaths.h"
10967 jghali 182
#include "scprintengine_ps.h"
10212 cbradney 183
#include "scraction.h"
13551 cbradney 184
#include "ui/scrapbookpalette.h"
10212 cbradney 185
#include "scribus.h"
13805 jghali 186
#include "scribusdoc.h"
10212 cbradney 187
#include "scribusXml.h"
188
#include "scribusapp.h"
189
#include "scribuscore.h"
13805 jghali 190
#include "scribusview.h"
3252 craig 191
#include "scribuswin.h"
14509 cbradney 192
#include "ui/scmwmenumanager.h"
13650 cbradney 193
#include "ui/search.h"
3934 cbradney 194
#include "selection.h"
13544 cbradney 195
#include "ui/selectobjects.h"
10212 cbradney 196
#include "serializer.h"
13544 cbradney 197
#include "ui/smlinestyle.h"
198
#include "ui/smtextstyles.h"
13551 cbradney 199
#include "ui/splash.h"
10212 cbradney 200
#include "stencilreader.h"
13576 cbradney 201
#include "ui/storyeditor.h"
13544 cbradney 202
#include "ui/stylemanager.h"
203
#include "ui/tabcheckdoc.h"
204
#include "ui/tabguides.h"
205
#include "ui/tabmanager.h"
206
#include "ui/tabpdfoptions.h"
207
#include "ui/tabtools.h"
208
#include "ui/tabtypography.h"
10862 cbradney 209
#include "text/nlsconfig.h"
10212 cbradney 210
#include "tocgenerator.h"
13544 cbradney 211
#include "ui/tocindexprefs.h"
10862 cbradney 212
#include "ui/copypagetomasterpagedialog.h"
10976 cbradney 213
#include "ui/edittoolbar.h"
214
#include "ui/filetoolbar.h"
215
#include "ui/modetoolbar.h"
216
#include "ui/pdftoolbar.h"
10212 cbradney 217
#include "undogui.h"
218
#include "undomanager.h"
219
#include "undostate.h"
220
#include "units.h"
10311 cbradney 221
#include "urllauncher.h"
5184 avox 222
#include "util.h"
10212 cbradney 223
#include "util_formats.h"
224
#include "util_ghostscript.h"
10200 cbradney 225
#include "util_icon.h"
14170 jghali 226
#include "util_math.h"
13576 cbradney 227
#include "ui/vruler.h"
12110 fschmid 228
#include "loadsaveplugin.h"
229
#include "plugins/formatidlist.h"
14539 jghali 230
#include "scimagecachemanager.h"
134 Franz 231
 
10212 cbradney 232
 
4361 cbradney 233
#if defined(_WIN32)
5178 mrdocs 234
#include "scdocoutput_ps2.h"
10967 jghali 235
#include "scprintengine_gdi.h"
4361 cbradney 236
#endif
237
 
3 paul 238
using namespace std;
239
 
3234 fschmid 240
bool previewDinUse;
241
bool printDinUse;
2891 cbradney 242
 
3 paul 243
QString DocDir;
3205 craig 244
 
10532 avox 245
 
2536 cbradney 246
extern ScribusQApp* ScQApp;
2634 cbradney 247
extern bool emergencyActivated;
3 paul 248
 
10532 avox 249
 
4026 craig 250
ScribusMainWindow::ScribusMainWindow()
2161 cbradney 251
{
5781 cbradney 252
        actionManager=0;
253
        scrMenuMgr=0;
254
        prefsManager=0;
10181 cbradney 255
        formatsManager=0;
10311 cbradney 256
        UrlLauncher::instance();
5781 cbradney 257
        mainWindowStatusLabel=0;
7354 cbradney 258
        ExternalApp=0;
3580 avox 259
#ifdef Q_WS_MAC
260
        noIcon = loadIcon("noicon.xpm");
261
#endif
10625 cbradney 262
}
188 Franz 263
 
11158 avox 264
/*
265
static QCoreApplication::EventFilter origEventFilter = 0;
10532 avox 266
 
11158 avox 267
bool reportFocusChanges(void *message, long *result)
268
{
269
        unsigned* data = static_cast<unsigned*>(message);
270
        if (QApplication::focusWidget())
271
                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];
272
        else
273
                qDebug() << QApplication::applicationFilePath() << "no focus" << message << data[0] << data[1] << data[2] << data[3] << data[4] << data[5] << data[6] << data[7];
274
        return origEventFilter && origEventFilter(message, result);
275
}
276
*/
277
 
767 cbradney 278
/*
279
 * retval 0 - ok, 1 - no fonts, ...
280
 */
5243 cbradney 281
int ScribusMainWindow::initScMW(bool primaryMainWindow)
188 Franz 282
{
767 cbradney 283
        int retVal=0;
5243 cbradney 284
 
9909 avox 285
        QByteArray stylesheet;
9910 jghali 286
        if (loadRawText(ScPaths::getApplicationDataDir() + "/stylesheet.css", stylesheet))
9909 avox 287
        {
288
                qApp->setStyleSheet(QString(stylesheet));
289
        }
10953 subik 290
 
11158 avox 291
//      origEventFilter = qApp->setEventFilter(reportFocusChanges);
11960 subik 292
 
3234 fschmid 293
        previewDinUse = false;
294
        printDinUse = false;
9721 fschmid 295
        internalCopy = false;
355 Franz 296
        CurrStED = NULL;
10495 cbradney 297
        setWindowTitle( tr("Scribus " VERSION));
10564 fschmid 298
        setAttribute(Qt::WA_KeyCompression, false);
299
        setWindowIcon(loadIcon("AppIcon.png"));
1325 cbradney 300
        scrActionGroups.clear();
1208 cbradney 301
        scrActions.clear();
302
        scrRecentFileActions.clear();
5800 fschmid 303
        scrRecentPasteActions.clear();
1260 cbradney 304
        scrWindowsActions.clear();
2408 cbradney 305
        scrLayersActions.clear();
14509 cbradney 306
        scrMenuMgr = new ScMWMenuManager(menuBar());
2835 cbradney 307
        prefsManager = PrefsManager::instance();
10181 cbradney 308
        formatsManager = FormatsManager::instance();
5243 cbradney 309
        objectSpecificUndo = false;
7087 subik 310
 
1247 tsoots 311
        undoManager = UndoManager::instance();
7880 fschmid 312
        PrefsContext *undoPrefs = prefsManager->prefsFile->getContext("undo");
313
        undoManager->setUndoEnabled(undoPrefs->getBool("enabled", true));
2441 cbradney 314
        tocGenerator = new TOCGenerator();
4510 subik 315
 
7087 subik 316
 
1780 cbradney 317
        initDefaultValues();
7087 subik 318
 
272 Franz 319
        initStatusBar();
7087 subik 320
 
490 cbradney 321
        qApp->processEvents();
675 cbradney 322
 
10427 cbradney 323
        actionManager = new ActionManager(this);
5257 cbradney 324
        actionManager->init(this);
11174 fschmid 325
//      if (primaryMainWindow)
326
//              ScCore->setSplashStatus( tr("Applying User Shortcuts") );
327
//      prefsManager->applyLoadedShortCuts();
328
//      initKeyboardShortcuts();
329
        initMenuBar();
330
        initToolBars();
331
        ScCore->pluginManager->setupPluginActions(this);
14509 cbradney 332
        ScCore->pluginManager->enableOnlyStartupPluginActions(this);
11174 fschmid 333
        ScCore->pluginManager->languageChange();
10977 cbradney 334
        if (primaryMainWindow)
335
                ScCore->setSplashStatus( tr("Applying User Shortcuts") );
336
        prefsManager->applyLoadedShortCuts();
337
        initKeyboardShortcuts();
11960 subik 338
 
5243 cbradney 339
        resize(610, 600);
13959 jghali 340
        mdiArea = new QMdiArea(this);
341
        mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
342
        mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
14224 fschmid 343
        if (prefsManager->appPrefs.uiPrefs.useTabs)
344
                mdiArea->setViewMode(QMdiArea::TabbedView);
345
        else
346
                mdiArea->setViewMode(QMdiArea::SubWindowView);
13959 jghali 347
        setCentralWidget( mdiArea );
348
        connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
349
        //Connect windows cascade and tile actions to the workspace after its created. Only depends on mdiArea created.
350
        connect( scrActions["windowsCascade"], SIGNAL(triggered()) , mdiArea, SLOT(cascadeSubWindows()) );
351
        connect( scrActions["windowsTile"], SIGNAL(triggered()) , mdiArea, SLOT(tileSubWindows()) );
5243 cbradney 352
        initPalettes();
7087 subik 353
 
5243 cbradney 354
        prefsManager->setupMainWindow(this);
770 cbradney 355
 
5243 cbradney 356
        if (primaryMainWindow)
357
                ScCore->setSplashStatus( tr("Initializing Story Editor") );
358
        storyEditor = new StoryEditor(this);
770 cbradney 359
 
5243 cbradney 360
        DocDir = prefsManager->documentDir();
1485 tsoots 361
 
5243 cbradney 362
        if (primaryMainWindow)
5800 fschmid 363
                ScCore->setSplashStatus( tr("Initializing Hyphenator") );
13955 cbradney 364
        QString preLang(prefsManager->appPrefs.hyphPrefs.Language);
5800 fschmid 365
        initHyphenator();
12787 pierre 366
        if (!LanguageManager::instance()->getHyphFilename( preLang, false ).isEmpty() )
13955 cbradney 367
                prefsManager->appPrefs.hyphPrefs.Language = preLang;
5800 fschmid 368
        if (primaryMainWindow)
369
                ScCore->setSplashStatus( tr("Reading Scrapbook") );
370
        initScrapbook();
371
 
13955 cbradney 372
        scrActions["helpTooltips"]->setChecked(prefsManager->appPrefs.displayPrefs.showToolTips);
373
        scrActions["showMouseCoordinates"]->setChecked(prefsManager->appPrefs.displayPrefs.showMouseCoordinates);
374
        scrActions["stickyTools"]->setChecked(prefsManager->appPrefs.uiPrefs.stickyTools);
5800 fschmid 375
        ToggleTips();
12754 fschmid 376
        ToggleMouseTips();
5800 fschmid 377
        propertiesPalette->setFontSize();
6451 fschmid 378
        if (scrActions["SaveAsDocumentTemplate"])
379
                scrActions["SaveAsDocumentTemplate"]->setEnabled(false);
7087 subik 380
 
5800 fschmid 381
        connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString )), this, SLOT(removeRecent(QString)));
9067 avox 382
        connect(this, SIGNAL(TextStyle(const ParagraphStyle&)), propertiesPalette, SLOT(updateStyle(const ParagraphStyle&)));
5800 fschmid 383
        connect(this, SIGNAL(TextIFont(QString)), propertiesPalette, SLOT(setFontFace(QString)));
9920 fschmid 384
        connect(this, SIGNAL(TextISize(double)), propertiesPalette, SLOT(setSize(double)));
385
        connect(this, SIGNAL(TextUSval(double)), propertiesPalette, SLOT(setExtra(double)));
5800 fschmid 386
        connect(this, SIGNAL(TextStil(int)), propertiesPalette, SLOT(setStil(int)));
9920 fschmid 387
        connect(this, SIGNAL(TextScale(double)), propertiesPalette, SLOT(setTScale(double)));
388
        connect(this, SIGNAL(TextScaleV(double)), propertiesPalette, SLOT(setTScaleV(double)));
389
        connect(this, SIGNAL(TextBase(double)), propertiesPalette, SLOT(setTBase(double)));
390
        connect(this, SIGNAL(TextShadow(double, double )), propertiesPalette, SLOT(setShadowOffs(double, double )));
391
        connect(this, SIGNAL(TextOutline(double)), propertiesPalette, SLOT(setOutlineW(double)));
392
        connect(this, SIGNAL(TextUnderline(double, double)), propertiesPalette, SLOT(setUnderline(double, double)));
393
        connect(this, SIGNAL(TextStrike(double, double)), propertiesPalette, SLOT(setStrike(double, double)));
394
        connect(this, SIGNAL(TextFarben(QString, QString, double, double)), propertiesPalette, SLOT(setActFarben(QString, QString, double, double)));
5800 fschmid 395
        connect(ClipB, SIGNAL(dataChanged()), this, SLOT(ClipChange()));
7337 fschmid 396
//      connect(ClipB, SIGNAL(selectionChanged()), this, SLOT(ClipChange()));
5800 fschmid 397
        setAcceptDrops(true);
9562 fschmid 398
        QCoreApplication::instance()->installEventFilter(this);
12846 fschmid 399
        scrActions["toolsSelect"]->setChecked(true);
11960 subik 400
 
5800 fschmid 401
        return retVal;
402
}
403
 
10532 avox 404
 
5800 fschmid 405
ScribusMainWindow::~ScribusMainWindow()
406
{
407
}
408
 
11040 fschmid 409
void ScribusMainWindow::addScToolBar(ScToolBar *tb, QString name)
410
{
411
        if (!scrToolBars.contains(name))
412
                scrToolBars.insert(name, tb);
413
        addToolBar(tb);
414
}
5800 fschmid 415
 
416
void ScribusMainWindow::initToolBars()
417
{
10976 cbradney 418
        fileToolBar = new FileToolBar(this);
419
        editToolBar = new EditToolBar(this);
5800 fschmid 420
        UndoWidget* uWidget = new UndoWidget(editToolBar, "uWidget");
421
        undoManager->registerGui(uWidget);
10976 cbradney 422
        modeToolBar = new ModeToolBar(this);
5800 fschmid 423
        pdfToolBar = new PDFToolBar(this);
10953 subik 424
 
11040 fschmid 425
        addScToolBar(fileToolBar, "ToolBar-File");
426
        addScToolBar(editToolBar, "ToolBar-Edit");
427
        addScToolBar(modeToolBar, "ToolBar-Tools");
428
        addScToolBar(pdfToolBar, "ToolBar-PDF_Tools");
7087 subik 429
 
10976 cbradney 430
        connect(modeToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarTools"], SLOT(setChecked(bool)));
10734 jghali 431
        connect(scrActions["toolsToolbarPDF"], SIGNAL(toggled(bool)), pdfToolBar, SLOT(setVisible(bool)));
10969 subik 432
        connect(pdfToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarPDF"], SLOT(setChecked(bool)));
10976 cbradney 433
        connect(scrActions["toolsToolbarTools"], SIGNAL(toggled(bool)), modeToolBar, SLOT(setVisible(bool)) );
5800 fschmid 434
}
435
 
10532 avox 436
 
5800 fschmid 437
void ScribusMainWindow::initDefaultValues()
438
{
439
        HaveDoc = false;
14754 jghali 440
        ScriptRunning = 0;
5800 fschmid 441
        view = NULL;
442
        doc = NULL;
443
        DocNr = 1;
444
        PrinterUsed = false;
445
        PDef.Pname = "";
446
        PDef.Dname = "";
447
        PDef.Command = "";
448
        keyrep = false;
449
        _arrowKeyDown = false;
450
        ClipB = QApplication::clipboard();
451
        palettesStatus[0] = false;
452
        guidesStatus[0] = false;
453
}
454
 
10532 avox 455
 
5800 fschmid 456
void ScribusMainWindow::initKeyboardShortcuts()
457
{
8501 cbradney 458
        for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrActions.begin(); it!=scrActions.end(); ++it )
5800 fschmid 459
        {
10516 cbradney 460
                if ((ScrAction*)(it.value())!=NULL)
5800 fschmid 461
                {
10564 fschmid 462
                        QString accelerator=it.value()->shortcut();
10516 cbradney 463
                        prefsManager->setKeyEntry(it.key(), it.value()->cleanMenuText(), accelerator,0);
5800 fschmid 464
                }
465
                //else
13085 jghali 466
                //      qDebug() << it.key();
467
                //qDebug() << QString("|-\n|%1||%2||%3").arg(it.key()).arg(it.value()->cleanMenuText()).arg(QString(it.data()->accel()));
5800 fschmid 468
        }
469
}
470
 
10532 avox 471
 
5800 fschmid 472
void ScribusMainWindow::initPalettes()
473
{
474
        //CB TODO hide the publicly available members of some palettes
475
        // these must be filtered too as they take control of the palettes events
10862 cbradney 476
        outlinePalette = new OutlinePalette(this);
5800 fschmid 477
        outlinePalette->setMainWindow(this);
478
        connect( scrActions["toolsOutline"], SIGNAL(toggled(bool)) , outlinePalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 479
        connect( outlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsOutline"], SLOT(setChecked(bool)));
10862 cbradney 480
        propertiesPalette = new PropertiesPalette(this);
5800 fschmid 481
        propertiesPalette->setMainWindow(this);
482
        connect( scrActions["toolsProperties"], SIGNAL(toggled(bool)) , propertiesPalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 483
        connect( propertiesPalette, SIGNAL(paletteShown(bool)), scrActions["toolsProperties"], SLOT(setChecked(bool)));
5800 fschmid 484
 
485
        //CB dont need this until we have a doc...
486
        //propertiesPalette->Cpal->SetColors(prefsManager->colorSet());
487
        propertiesPalette->Fonts->RebuildList(0);
488
        propertiesPalette->installEventFilter(this);
489
        nodePalette = new NodePalette(this);
490
        nodePalette->installEventFilter(this);
491
        layerPalette = new LayerPalette(this);
492
        guidePalette = new GuideManager(this);
7087 subik 493
        charPalette = new CharSelect(this);
5800 fschmid 494
        connect( scrActions["toolsLayers"], SIGNAL(toggled(bool)) , layerPalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 495
        connect( layerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsLayers"], SLOT(setChecked(bool)));
5800 fschmid 496
        layerPalette->installEventFilter(this);
497
        layerPalette->Table->installEventFilter(this);
498
        scrapbookPalette = new Biblio(this);
499
        connect( scrActions["toolsScrapbook"], SIGNAL(toggled(bool)) , scrapbookPalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 500
        connect( scrapbookPalette, SIGNAL(paletteShown(bool)), scrActions["toolsScrapbook"], SLOT(setChecked(bool)));
11554 fschmid 501
        connect( scrapbookPalette, SIGNAL(pasteToActualPage(QString)), this, SLOT(pasteFromScrapbook(QString)));
5800 fschmid 502
        scrapbookPalette->installEventFilter(this);
503
        pagePalette = new PagePalette(this);
504
        connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , pagePalette, SLOT(setPaletteShown(bool)) );
505
        connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , this, SLOT(setPagePalette(bool)) );
10581 cbradney 506
        connect( pagePalette, SIGNAL(paletteShown(bool)), scrActions["toolsPages"], SLOT(setChecked(bool)));
5800 fschmid 507
        pagePalette->installEventFilter(this);
508
        bookmarkPalette = new BookPalette(this);
509
        connect( scrActions["toolsBookmarks"], SIGNAL(toggled(bool)) , bookmarkPalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 510
        connect( bookmarkPalette, SIGNAL(paletteShown(bool)), scrActions["toolsBookmarks"], SLOT(setChecked(bool)));
5800 fschmid 511
        bookmarkPalette->installEventFilter(this);
11190 avox 512
//      measurementPalette = new Measurements(this);
513
//      connect( scrActions["toolsMeasurements"], SIGNAL(toggled(bool)) , measurementPalette, SLOT(setPaletteShown(bool)) );
5800 fschmid 514
        connect( scrActions["toolsMeasurements"], SIGNAL(toggledData(bool, int)) , this, SLOT(setAppModeByToggle(bool, int)) );
11190 avox 515
//      connect( measurementPalette, SIGNAL(paletteShown(bool)), scrActions["toolsMeasurements"], SLOT(setChecked(bool)));
516
//      measurementPalette->installEventFilter(this);
517
//      measurementPalette->hide();
5800 fschmid 518
        docCheckerPalette = new CheckDocument(this, false);
519
        connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , docCheckerPalette, SLOT(setPaletteShown(bool)) );
520
        connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , this, SLOT(docCheckToggle(bool)) );
10581 cbradney 521
        connect( docCheckerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsPreflightVerifier"], SLOT(setChecked(bool)));
5800 fschmid 522
        connect( docCheckerPalette, SIGNAL(paletteShown(bool)), this, SLOT(docCheckToggle(bool)));
523
        docCheckerPalette->installEventFilter(this);
524
        docCheckerPalette->hide();
525
 
526
        alignDistributePalette = new AlignDistributePalette(this, "AlignDistributePalette", false);
527
        connect( scrActions["toolsAlignDistribute"], SIGNAL(toggled(bool)) , alignDistributePalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 528
        connect( alignDistributePalette, SIGNAL(paletteShown(bool)), scrActions["toolsAlignDistribute"], SLOT(setChecked(bool)));
5800 fschmid 529
        connect( alignDistributePalette, SIGNAL(documentChanged()), this, SLOT(slotDocCh()));
530
        alignDistributePalette->installEventFilter(this);
7087 subik 531
 
5800 fschmid 532
        undoPalette = new UndoPalette(this, "undoPalette");
533
        undoPalette->installEventFilter(this);
534
        undoManager->registerGui(undoPalette);
535
        connect(undoPalette, SIGNAL(paletteShown(bool)), this, SLOT(setUndoPalette(bool)));
536
        connect(undoPalette, SIGNAL(objectMode(bool)), this, SLOT(setUndoMode(bool)));
537
 
538
        // initializing style manager here too even it's not strictly a palette
539
        styleManager = new StyleManager(this, "styleManager");
540
        styleManager->addStyle(new SMLineStyle());
7063 tsoots 541
        SMCharacterStyle *tmpCS = new SMCharacterStyle();
542
        styleManager->addStyle(new SMParagraphStyle(tmpCS->tmpStyles()));
543
        styleManager->addStyle(tmpCS);
10627 cbradney 544
        connect( scrActions["editStyles"], SIGNAL(toggled(bool)), styleManager, SLOT(setPaletteShown(bool)) );
10581 cbradney 545
        connect( styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setChecked(bool)));
8005 cbradney 546
        styleManager->installEventFilter(this);
5800 fschmid 547
 
548
        connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(selectItemsFromOutlines(int, int)));
549
        connect(docCheckerPalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
550
        connect(docCheckerPalette, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
551
        connect(outlinePalette, SIGNAL(selectElement(int, int, bool)), this, SLOT(selectItemsFromOutlines(int, int, bool)));
552
        connect(outlinePalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
553
        connect(outlinePalette, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
9067 avox 554
        connect(propertiesPalette->paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewParStyle(const QString&)));
555
        connect(propertiesPalette->charStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewCharStyle(const QString&)));
5800 fschmid 556
//      connect(propertiesPalette, SIGNAL(EditLSt()), this, SLOT(slotEditLineStyles()));
11852 fschmid 557
        connect(nodePalette, SIGNAL(Schliessen()), propertiesPalette, SLOT(endEdit2()));
10532 avox 558
        connect(nodePalette, SIGNAL(Schliessen()), this, SLOT(slotSelect()));
5800 fschmid 559
        connect(nodePalette, SIGNAL(DocChanged()), this, SLOT(slotDocCh()));
560
        connect(layerPalette, SIGNAL(LayerChanged()), this, SLOT(showLayer()));
561
 
562
        connect(bookmarkPalette->BView, SIGNAL(MarkMoved()), this, SLOT(StoreBookmarks()));
563
        connect(bookmarkPalette->BView, SIGNAL(changed()), this, SLOT(slotDocCh()));
564
        connect(bookmarkPalette->BView, SIGNAL(SelectElement(PageItem *)), this, SLOT(selectItemsFromOutlines(PageItem *)));
565
        // guides
566
        connect(scrActions["pageManageGuides"], SIGNAL(toggled(bool)), guidePalette, SLOT(setPaletteShown(bool)));
10581 cbradney 567
        connect(guidePalette, SIGNAL(paletteShown(bool)), scrActions["pageManageGuides"], SLOT(setChecked(bool)));
7087 subik 568
        // char palette
569
        connect(scrActions["insertGlyph"], SIGNAL(toggled(bool)), charPalette, SLOT(setPaletteShown(bool)));
10581 cbradney 570
        connect(charPalette, SIGNAL(paletteShown(bool)), scrActions["insertGlyph"], SLOT(setChecked(bool)));
5800 fschmid 571
}
572
 
10532 avox 573
 
5800 fschmid 574
void ScribusMainWindow::initScrapbook()
575
{
576
        QString scrapbookFileO = QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrap13.scs");
577
        QFileInfo scrapbookFileInfoO = QFileInfo(scrapbookFileO);
578
        if (scrapbookFileInfoO.exists())
579
        {
580
                scrapbookPalette->readOldContents(scrapbookFileO, QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrapbook/main"));
581
                QDir d = QDir();
582
                d.rename(scrapbookFileO, QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrap13.backup"));
583
        }
584
        QString scrapbookTemp = QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrapbook/tmp");
585
        QFileInfo scrapbookTempInfo = QFileInfo(scrapbookTemp);
586
        if (scrapbookTempInfo.exists())
587
                scrapbookPalette->readTempContents(scrapbookTemp);
588
        QString scrapbookFile = QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrapbook/main");
589
        QFileInfo scrapbookFileInfo = QFileInfo(scrapbookFile);
590
        if (scrapbookFileInfo.exists())
591
                scrapbookPalette->readContents(scrapbookFile);
592
        scrapbookPalette->setScrapbookFileName(scrapbookFile);
13955 cbradney 593
        scrapbookPalette->setOpenScrapbooks(prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks);
5800 fschmid 594
        rebuildRecentPasteMenu();
5806 fschmid 595
        connect(scrapbookPalette, SIGNAL(updateRecentMenue()), this, SLOT(rebuildRecentPasteMenu()));
5800 fschmid 596
}
597
 
10532 avox 598
 
5800 fschmid 599
bool ScribusMainWindow::warningVersion(QWidget *parent)
600
{
601
        bool retval = false;
602
        int t = ScMessageBox::warning(parent, QObject::tr("Scribus Development Version"), "<qt>" +
6442 cbradney 603
                                                                 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>",
9422 fschmid 604
                                                                 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
605
        if (t == QMessageBox::Ok)
5800 fschmid 606
                retval = true;
607
        return retval;
608
}
609
 
10532 avox 610
 
5800 fschmid 611
void ScribusMainWindow::initMenuBar()
612
{
613
        RecentDocs.clear();
12940 cbradney 614
        scrMenuMgr->createMenu("File", ActionManager::defaultMenuNameEntryTranslated("File"));
14509 cbradney 615
        scrMenuMgr->addMenuItem(scrActions["fileNew"], "File", true);
616
        scrMenuMgr->addMenuItem(scrActions["fileNewFromTemplate"], "File", true);
617
        scrMenuMgr->addMenuItem(scrActions["fileOpen"], "File", true);
618
        scrMenuMgr->createMenu("FileOpenRecent", tr("Open &Recent"), "File");
5800 fschmid 619
        scrMenuMgr->addMenuSeparator("File");
14509 cbradney 620
        scrMenuMgr->addMenuItem(scrActions["fileClose"], "File", false);
621
        scrMenuMgr->addMenuItem(scrActions["fileSave"], "File", false);
622
        scrMenuMgr->addMenuItem(scrActions["fileSaveAs"], "File", false);
623
        scrMenuMgr->addMenuItem(scrActions["fileRevert"], "File", false);
624
        scrMenuMgr->addMenuItem(scrActions["fileCollect"], "File", false);
5800 fschmid 625
        scrMenuMgr->addMenuSeparator("File");
10558 cbradney 626
        scrMenuMgr->createMenu("FileImport", tr("&Import"), "File");
14509 cbradney 627
        scrMenuMgr->addMenuItem(scrActions["fileImportText"], "FileImport", false);
628
//      scrMenuMgr->addMenuItem(scrActions["fileImportText2"], "FileImport", false);
629
        scrMenuMgr->addMenuItem(scrActions["fileImportAppendText"], "FileImport", false);
630
        scrMenuMgr->addMenuItem(scrActions["fileImportImage"], "FileImport", false);
631
        scrMenuMgr->addMenuItem(scrActions["fileImportVector"], "FileImport", true);
12110 fschmid 632
 
10558 cbradney 633
        scrMenuMgr->createMenu("FileExport", tr("&Export"), "File");
14509 cbradney 634
        scrMenuMgr->addMenuItem(scrActions["fileExportText"], "FileExport", false);
635
        scrMenuMgr->addMenuItem(scrActions["fileExportAsEPS"], "FileExport", false);
636
        scrMenuMgr->addMenuItem(scrActions["fileExportAsPDF"], "FileExport", false);
5800 fschmid 637
        scrMenuMgr->addMenuSeparator("File");
14509 cbradney 638
        scrMenuMgr->addMenuItem(scrActions["fileDocSetup"], "File", false);
639
        scrMenuMgr->addMenuItem(scrActions["filePreferences"], "File", true);
640
        scrMenuMgr->addMenuItem(scrActions["filePreferences150"], "File", true);
5800 fschmid 641
        scrMenuMgr->addMenuSeparator("File");
14509 cbradney 642
        scrMenuMgr->addMenuItem(scrActions["filePrint"], "File", false);
643
        scrMenuMgr->addMenuItem(scrActions["PrintPreview"], "File", false);
5800 fschmid 644
        scrMenuMgr->addMenuSeparator("File");
14509 cbradney 645
        scrMenuMgr->addMenuItem(scrActions["fileQuit"], "File", true);
5800 fschmid 646
 
14509 cbradney 647
//      scrActions["fileClose"]->setEnabled(false);
648
//      scrActions["fileSave"]->setEnabled(false);
649
//      scrActions["fileSaveAs"]->setEnabled(false);
650
//      scrActions["fileRevert"]->setEnabled(false);
651
//      scrActions["fileCollect"]->setEnabled(false);
652
//      scrActions["fileImportText"]->setEnabled(false);
653
//      scrActions["fileImportText2"]->setEnabled(false);
654
//      scrActions["fileImportImage"]->setEnabled(false);
655
//      scrActions["fileImportAppendText"]->setEnabled(false);
656
//      scrActions["pageImport"]->setEnabled(false);
657
//      scrActions["fileExportText"]->setEnabled(false);
658
//      scrActions["fileExportAsEPS"]->setEnabled(false);
659
//      scrActions["fileExportAsPDF"]->setEnabled(false);
6451 fschmid 660
        scrMenuMgr->setMenuEnabled("FileImport", false);
5800 fschmid 661
        scrMenuMgr->setMenuEnabled("FileExport", false);
14509 cbradney 662
//      scrActions["fileDocSetup"]->setEnabled(false);
663
//      scrActions["filePrint"]->setEnabled(false);
664
//      scrActions["PrintPreview"]->setEnabled(false);
5800 fschmid 665
 
12940 cbradney 666
        scrMenuMgr->createMenu("Edit", ActionManager::defaultMenuNameEntryTranslated("Edit"));
14509 cbradney 667
        scrMenuMgr->addMenuItem(scrActions["editUndoAction"], "Edit", false);
668
        scrMenuMgr->addMenuItem(scrActions["editRedoAction"], "Edit", false);
669
        scrMenuMgr->addMenuItem(scrActions["editActionMode"], "Edit", true);
5800 fschmid 670
        scrMenuMgr->addMenuSeparator("Edit");
14509 cbradney 671
        scrMenuMgr->addMenuItem(scrActions["editCut"], "Edit", false);
672
        scrMenuMgr->addMenuItem(scrActions["editCopy"], "Edit", false);
673
        scrMenuMgr->addMenuItem(scrActions["editPaste"], "Edit", false);
674
        scrMenuMgr->createMenu("EditPasteRecent", tr("Paste Recent"), "Edit");
10558 cbradney 675
        scrMenuMgr->createMenu("EditContents", tr("Contents"), "Edit");
14509 cbradney 676
        scrMenuMgr->addMenuItem(scrActions["editCopyContents"], "EditContents", false);
677
        scrMenuMgr->addMenuItem(scrActions["editPasteContents"], "EditContents", false);
678
        scrMenuMgr->addMenuItem(scrActions["editPasteContentsAbs"], "EditContents", false);
679
        scrMenuMgr->addMenuItem(scrActions["editClearContents"], "EditContents", false);
5800 fschmid 680
        scrMenuMgr->addMenuSeparator("Edit");
14509 cbradney 681
        scrMenuMgr->addMenuItem(scrActions["editSelectAll"], "Edit", false);
682
        scrMenuMgr->addMenuItem(scrActions["editSelectAllOnLayer"], "Edit", false);
683
        scrMenuMgr->addMenuItem(scrActions["editDeselectAll"], "Edit", false);
5800 fschmid 684
        scrMenuMgr->addMenuSeparator("Edit");
14509 cbradney 685
        scrMenuMgr->addMenuItem(scrActions["editSearchReplace"], "Edit" , false);
686
        scrMenuMgr->addMenuItem(scrActions["toolsEditWithStoryEditor"], "Edit", false);
687
        scrMenuMgr->addMenuItem(scrActions["editEditWithImageEditor"], "Edit", false);
688
        scrMenuMgr->addMenuItem(scrActions["editEditRenderSource"], "Edit", false);
5800 fschmid 689
        scrMenuMgr->addMenuSeparator("Edit");
14509 cbradney 690
        scrMenuMgr->addMenuItem(scrActions["editColors"], "Edit", true);
691
        scrMenuMgr->addMenuItem(scrActions["editReplaceColors"], "Edit", false);
692
        scrMenuMgr->addMenuItem(scrActions["editGradients"], "Edit", false);
693
        scrMenuMgr->addMenuItem(scrActions["editPatterns"], "Edit", false);
694
        scrMenuMgr->addMenuItem(scrActions["editStyles"], "Edit", false);
695
        scrMenuMgr->addMenuItem(scrActions["editMasterPages"], "Edit", false);
696
        scrMenuMgr->addMenuItem(scrActions["editJavascripts"], "Edit", false);
697
//      scrActions["editUndoAction"]->setEnabled(false);
698
//      scrActions["editRedoAction"]->setEnabled(false);
699
//      scrActions["editActionMode"]->setEnabled(true);
700
//      scrActions["editCut"]->setEnabled(false);
701
//      scrActions["editCopy"]->setEnabled(false);
702
//      scrActions["editPaste"]->setEnabled(false);
5827 fschmid 703
        scrMenuMgr->setMenuEnabled("EditPasteRecent", false);
7565 cbradney 704
        scrMenuMgr->setMenuEnabled("EditContents", false);
14509 cbradney 705
//      scrActions["editCopyContents"]->setEnabled(false);
706
//      scrActions["editPasteContents"]->setEnabled(false);
707
//      scrActions["editPasteContentsAbs"]->setEnabled(false);
708
//      scrActions["editClearContents"]->setEnabled(false);
709
//      scrActions["editSelectAll"]->setEnabled(false);
710
//      scrActions["editSelectAllOnLayer"]->setEnabled(false);
711
//      scrActions["editDeselectAll"]->setEnabled(false);
712
//      scrActions["editSearchReplace"]->setEnabled(false);
713
//      scrActions["editReplaceColors"]->setEnabled(false);
714
//      scrActions["editPatterns"]->setEnabled(false);
14150 fschmid 715
//      scrActions["editGradients"]->setEnabled(false);
14509 cbradney 716
//      scrActions["editStyles"]->setEnabled(false);
717
//      scrActions["editMasterPages"]->setEnabled(false);
718
//      scrActions["editJavascripts"]->setEnabled(false);
719
//      scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
720
//      scrActions["editEditWithImageEditor"]->setEnabled(false);
721
//      scrActions["editEditRenderSource"]->setEnabled(false);
5800 fschmid 722
 
14509 cbradney 723
 
724
        scrActions["itemDuplicate"]->setEnabled(false);
725
        scrActions["itemMulDuplicate"]->setEnabled(false);
726
        scrActions["itemDelete"]->setEnabled(false);
727
        scrActions["itemRaise"]->setEnabled(false);
728
        scrActions["itemLower"]->setEnabled(false);
729
        scrActions["itemRaiseToTop"]->setEnabled(false);
730
        scrActions["itemLowerToBottom"]->setEnabled(false);
731
        scrActions["itemSendToScrapbook"]->setEnabled(false);
732
        scrActions["itemSendToPattern"]->setEnabled(false);
733
        scrActions["itemAdjustFrameToImage"]->setEnabled(false);
734
        scrActions["itemAdjustImageToFrame"]->setEnabled(false);
735
        scrActions["itemExtendedImageProperties"]->setEnabled(false);
736
        scrActions["itemUpdateImage"]->setEnabled(false);
737
        scrActions["itemPreviewLow"]->setEnabled(false);
738
        scrActions["itemPreviewNormal"]->setEnabled(false);
739
        scrActions["itemPreviewFull"]->setEnabled(false);
740
        scrActions["itemAttributes"]->setEnabled(false);
741
        scrActions["itemPreviewLow"]->setEnabled(false);
742
 
743
 
5800 fschmid 744
        //Item Menu
12940 cbradney 745
        scrMenuMgr->createMenu("Item", ActionManager::defaultMenuNameEntryTranslated("Item"));
14509 cbradney 746
        scrMenuMgr->addMenuItem(scrActions["itemDuplicate"], "Item", false);
747
        scrMenuMgr->addMenuItem(scrActions["itemMulDuplicate"], "Item", false);
748
        scrMenuMgr->addMenuItem(scrActions["itemDelete"], "Item", false);
5800 fschmid 749
        scrMenuMgr->addMenuSeparator("Item");
14509 cbradney 750
        scrMenuMgr->addMenuItem(scrActions["itemGroup"], "Item", false);
751
        scrMenuMgr->addMenuItem(scrActions["itemUngroup"], "Item", false);
752
        scrMenuMgr->addMenuItem(scrActions["itemLock"], "Item", false);
753
        scrMenuMgr->addMenuItem(scrActions["itemLockSize"], "Item", false);
5800 fschmid 754
        scrMenuMgr->addMenuSeparator("Item");
755
        scrMenuMgr->createMenu("ItemLevel", tr("Level"));
756
        scrMenuMgr->addMenuToMenu("ItemLevel", "Item");
14509 cbradney 757
        scrMenuMgr->addMenuItem(scrActions["itemRaise"], "ItemLevel", false);
758
        scrMenuMgr->addMenuItem(scrActions["itemLower"], "ItemLevel", false);
759
        scrMenuMgr->addMenuItem(scrActions["itemRaiseToTop"], "ItemLevel", false);
760
        scrMenuMgr->addMenuItem(scrActions["itemLowerToBottom"], "ItemLevel", false);
5800 fschmid 761
        scrMenuMgr->createMenu("ItemLayer", tr("Send to La&yer"));
762
        scrMenuMgr->addMenuToMenu("ItemLayer", "Item");
14509 cbradney 763
        scrMenuMgr->addMenuItem(scrActions["itemSendToScrapbook"], "Item", false);
764
        scrMenuMgr->addMenuItem(scrActions["itemSendToPattern"], "Item", false);
5800 fschmid 765
        scrMenuMgr->addMenuSeparator("Item");
14509 cbradney 766
        scrMenuMgr->addMenuItem(scrActions["itemAdjustFrameToImage"], "Item", false);
767
        scrMenuMgr->addMenuItem(scrActions["itemAdjustImageToFrame"], "Item", false);
768
        scrMenuMgr->addMenuItem(scrActions["itemExtendedImageProperties"], "Item", false);
769
        scrMenuMgr->addMenuItem(scrActions["itemUpdateImage"], "Item", false);
8020 cbradney 770
        scrMenuMgr->createMenu("ItemPreviewSettings", tr("Preview Settings"), "Item");
14509 cbradney 771
        scrMenuMgr->addMenuItem(scrActions["itemImageIsVisible"], "ItemPreviewSettings", false);
8020 cbradney 772
        scrMenuMgr->addMenuSeparator("ItemPreviewSettings");
14509 cbradney 773
        scrMenuMgr->addMenuItem(scrActions["itemPreviewLow"], "ItemPreviewSettings", false);
774
        scrMenuMgr->addMenuItem(scrActions["itemPreviewNormal"], "ItemPreviewSettings", false);
775
        scrMenuMgr->addMenuItem(scrActions["itemPreviewFull"], "ItemPreviewSettings", false);
8020 cbradney 776
        scrMenuMgr->addMenuSeparator("Item");
14509 cbradney 777
        scrMenuMgr->addMenuItem(scrActions["itemAttributes"], "Item", false);
5800 fschmid 778
        scrMenuMgr->createMenu("ItemPDFOptions", tr("&PDF Options"));
779
        scrMenuMgr->addMenuToMenu("ItemPDFOptions", "Item");
14509 cbradney 780
        scrMenuMgr->addMenuItem(scrActions["itemPDFIsAnnotation"], "ItemPDFOptions", false);
781
        scrMenuMgr->addMenuItem(scrActions["itemPDFIsBookmark"], "ItemPDFOptions", false);
782
        scrMenuMgr->addMenuItem(scrActions["itemPDFAnnotationProps"], "ItemPDFOptions", false);
783
        scrMenuMgr->addMenuItem(scrActions["itemPDFFieldProps"], "ItemPDFOptions", false);
11067 cbradney 784
        //scrMenuMgr->createMenu("ItemShapes", tr("&Shape"), "Item");
10558 cbradney 785
        scrMenuMgr->createMenu("ItemConvertTo", tr("C&onvert To"), "Item");
14509 cbradney 786
        scrMenuMgr->addMenuItem(scrActions["itemConvertToBezierCurve"], "ItemConvertTo", false);
787
        scrMenuMgr->addMenuItem(scrActions["itemConvertToImageFrame"], "ItemConvertTo", false);
788
        scrMenuMgr->addMenuItem(scrActions["itemConvertToOutlines"], "ItemConvertTo", false);
789
        scrMenuMgr->addMenuItem(scrActions["itemConvertToPolygon"], "ItemConvertTo", false);
790
        scrMenuMgr->addMenuItem(scrActions["itemConvertToTextFrame"], "ItemConvertTo", false);
5800 fschmid 791
 
14509 cbradney 792
        scrMenuMgr->addMenuItem(scrActions["itemAttachTextToPath"], "Item", false);
793
        scrMenuMgr->addMenuItem(scrActions["itemDetachTextFromPath"], "Item", false);
11050 fschmid 794
//      scrMenuMgr->createMenu("ItemPathOps", tr("Path Tools"), "Item");
14509 cbradney 795
        scrMenuMgr->addMenuItem(scrActions["itemCombinePolygons"], "Item", false);
796
        scrMenuMgr->addMenuItem(scrActions["itemSplitPolygons"], "Item", false);
11067 cbradney 797
        //scrMenuMgr->setMenuEnabled("ItemShapes", false);
14509 cbradney 798
//      scrActions["itemGroup"]->setEnabled(false);
799
//      scrActions["itemUngroup"]->setEnabled(false);
800
//      scrActions["itemAttachTextToPath"]->setEnabled(false);
801
//      scrActions["itemDetachTextFromPath"]->setEnabled(false);
802
//      scrActions["itemCombinePolygons"]->setEnabled(false);
803
//      scrActions["itemSplitPolygons"]->setEnabled(false);
804
//      scrActions["itemLock"]->setEnabled(false);
805
//      scrActions["itemLockSize"]->setEnabled(false);
5800 fschmid 806
        scrActions["itemPrintingEnabled"]->setEnabled(false);
14509 cbradney 807
//      scrActions["itemImageIsVisible"]->setEnabled(false);
5800 fschmid 808
        scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
14509 cbradney 809
//      scrActions["itemConvertToBezierCurve"]->setEnabled(false);
810
//      scrActions["itemConvertToImageFrame"]->setEnabled(false);
811
//      scrActions["itemConvertToOutlines"]->setEnabled(false);
812
//      scrActions["itemConvertToPolygon"]->setEnabled(false);
813
//      scrActions["itemConvertToTextFrame"]->setEnabled(false);
5800 fschmid 814
 
815
        //Insert menu
12940 cbradney 816
        scrMenuMgr->createMenu("Insert", ActionManager::defaultMenuNameEntryTranslated("Insert"));
14509 cbradney 817
        scrMenuMgr->addMenuItem(scrActions["insertFrame"], "Insert", false);
6090 cbradney 818
        scrMenuMgr->addMenuSeparator("Insert");
14509 cbradney 819
        scrMenuMgr->addMenuItem(scrActions["toolsInsertTextFrame"], "Insert", false);
820
        scrMenuMgr->addMenuItem(scrActions["toolsInsertImageFrame"], "Insert", false);
821
        scrMenuMgr->addMenuItem(scrActions["toolsInsertRenderFrame"], "Insert", false);
822
        scrMenuMgr->addMenuItem(scrActions["toolsInsertTableFrame"], "Insert", false);
823
        scrMenuMgr->addMenuItem(scrActions["toolsInsertShape"], "Insert", false);
824
        scrMenuMgr->addMenuItem(scrActions["toolsInsertPolygon"], "Insert", false);
825
        scrMenuMgr->addMenuItem(scrActions["toolsInsertLine"], "Insert", false);
826
        scrMenuMgr->addMenuItem(scrActions["toolsInsertBezier"], "Insert", false);
827
        scrMenuMgr->addMenuItem(scrActions["toolsInsertFreehandLine"], "Insert", false);
7400 cbradney 828
        scrMenuMgr->addMenuSeparator("Insert");
14509 cbradney 829
        scrMenuMgr->addMenuItem(scrActions["stickyTools"], "Insert", true);
5800 fschmid 830
        scrMenuMgr->addMenuSeparator("Insert");
14509 cbradney 831
        scrMenuMgr->addMenuItem(scrActions["insertGlyph"], "Insert", false);
5800 fschmid 832
 
10558 cbradney 833
        scrMenuMgr->createMenu("InsertChar", tr("&Character"), "Insert");
14509 cbradney 834
        scrMenuMgr->addMenuItem(scrActions["unicodePageNumber"], "InsertChar", false);
835
        scrMenuMgr->addMenuItem(scrActions["unicodePageCount"], "InsertChar", false);
836
        scrMenuMgr->addMenuItem(scrActions["unicodeSmartHyphen"], "InsertChar", false);
837
        scrMenuMgr->addMenuItem(scrActions["unicodeNonBreakingHyphen"], "InsertChar", false);
5800 fschmid 838
        scrMenuMgr->addMenuSeparator("InsertChar");
14509 cbradney 839
        scrMenuMgr->addMenuItem(scrActions["unicodeCopyRight"], "InsertChar", false);
840
        scrMenuMgr->addMenuItem(scrActions["unicodeRegdTM"], "InsertChar", false);
841
        scrMenuMgr->addMenuItem(scrActions["unicodeTM"], "InsertChar", false);
842
        scrMenuMgr->addMenuItem(scrActions["unicodeSolidus"], "InsertChar", false);
843
        scrMenuMgr->addMenuItem(scrActions["unicodeBullet"], "InsertChar", false);
844
        scrMenuMgr->addMenuItem(scrActions["unicodeMidpoint"], "InsertChar", false);
5800 fschmid 845
        scrMenuMgr->addMenuSeparator("InsertChar");
14509 cbradney 846
        scrMenuMgr->addMenuItem(scrActions["unicodeDashEm"], "InsertChar", false);
847
        scrMenuMgr->addMenuItem(scrActions["unicodeDashEn"], "InsertChar", false);
848
        scrMenuMgr->addMenuItem(scrActions["unicodeDashFigure"], "InsertChar", false);
849
        scrMenuMgr->addMenuItem(scrActions["unicodeDashQuotation"], "InsertChar", false);
5800 fschmid 850
 
10558 cbradney 851
        scrMenuMgr->createMenu("InsertQuote", tr("&Quote"), "Insert");
14509 cbradney 852
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteApostrophe"], "InsertQuote", false);
853
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteStraight"], "InsertQuote", false);
5800 fschmid 854
        scrMenuMgr->addMenuSeparator("InsertQuote");
14509 cbradney 855
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleLeft"], "InsertQuote", false);
856
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleRight"], "InsertQuote", false);
857
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleLeft"], "InsertQuote", false);
858
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleRight"], "InsertQuote", false);
5800 fschmid 859
        scrMenuMgr->addMenuSeparator("InsertQuote");
14509 cbradney 860
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleReversed"], "InsertQuote", false);
861
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleReversed"], "InsertQuote", false);
8755 cbradney 862
        scrMenuMgr->addMenuSeparator("InsertQuote");
14509 cbradney 863
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteLowSingleComma"], "InsertQuote", false);
864
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteLowDoubleComma"], "InsertQuote", false);
5800 fschmid 865
        scrMenuMgr->addMenuSeparator("InsertQuote");
14509 cbradney 866
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleLeftGuillemet"], "InsertQuote", false);
867
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleRightGuillemet"], "InsertQuote", false);
868
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleLeftGuillemet"], "InsertQuote", false);
869
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleRightGuillemet"], "InsertQuote", false);
5800 fschmid 870
        scrMenuMgr->addMenuSeparator("InsertQuote");
14509 cbradney 871
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKSingleLeft"], "InsertQuote", false);
872
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKSingleRight"], "InsertQuote", false);
873
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKDoubleLeft"], "InsertQuote", false);
874
        scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKDoubleRight"], "InsertQuote", false);
5800 fschmid 875
 
10558 cbradney 876
        scrMenuMgr->createMenu("InsertSpace", tr("S&paces && Breaks"), "Insert");
14509 cbradney 877
        scrMenuMgr->addMenuItem(scrActions["unicodeNonBreakingSpace"], "InsertSpace", false);
878
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceEN"], "InsertSpace", false);
879
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceEM"], "InsertSpace", false);
880
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceThin"], "InsertSpace", false);
881
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceThick"], "InsertSpace", false);
882
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceMid"], "InsertSpace", false);
883
        scrMenuMgr->addMenuItem(scrActions["unicodeSpaceHair"], "InsertSpace", false);
5800 fschmid 884
        scrMenuMgr->addMenuSeparator("InsertSpace");
14509 cbradney 885
        scrMenuMgr->addMenuItem(scrActions["unicodeNewLine"], "InsertSpace", false);
886
        scrMenuMgr->addMenuItem(scrActions["unicodeFrameBreak"], "InsertSpace", false);
887
        scrMenuMgr->addMenuItem(scrActions["unicodeColumnBreak"], "InsertSpace", false);
888
        scrMenuMgr->addMenuItem(scrActions["unicodeZerowidthSpace"], "InsertSpace", false);
5800 fschmid 889
 
10558 cbradney 890
        scrMenuMgr->createMenu("InsertLigature", tr("Liga&ture"), "Insert");
14509 cbradney 891
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ff"], "InsertLigature", false);
892
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_fi"], "InsertLigature", false);
893
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_fl"], "InsertLigature", false);
894
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ffi"], "InsertLigature", false);
895
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ffl"], "InsertLigature", false);
896
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ft"], "InsertLigature", false);
897
        scrMenuMgr->addMenuItem(scrActions["unicodeLigature_st"], "InsertLigature", false);
5800 fschmid 898
 
899
        scrMenuMgr->addMenuSeparator("Insert");
14509 cbradney 900
        scrMenuMgr->addMenuItem(scrActions["insertSampleText"], "Insert", false);
901
//      scrActions["insertFrame"]->setEnabled(false);
5800 fschmid 902
 
903
        //Page menu
12940 cbradney 904
        scrMenuMgr->createMenu("Page", ActionManager::defaultMenuNameEntryTranslated("Page"));
14509 cbradney 905
        scrMenuMgr->addMenuItem(scrActions["pageInsert"], "Page", false);
906
        scrMenuMgr->addMenuItem(scrActions["pageImport"], "Page", false);
907
        scrMenuMgr->addMenuItem(scrActions["pageDelete"], "Page", false);
908
        scrMenuMgr->addMenuItem(scrActions["pageCopy"], "Page", false);
909
        scrMenuMgr->addMenuItem(scrActions["pageMove"], "Page", false);
5800 fschmid 910
        scrMenuMgr->addMenuSeparator("Page");
14509 cbradney 911
        scrMenuMgr->addMenuItem(scrActions["pageApplyMasterPage"], "Page", false);
912
        scrMenuMgr->addMenuItem(scrActions["pageCopyToMasterPage"], "Page", false);
913
        scrMenuMgr->addMenuItem(scrActions["pageManageGuides"], "Page", false);
914
        scrMenuMgr->addMenuItem(scrActions["pageManageMargins"], "Page", false);
915
        scrMenuMgr->addMenuSeparator("Page");
916
        scrMenuMgr->addMenuItem(scrActions["viewSnapToGrid"], "Page", true);
917
        scrMenuMgr->addMenuItem(scrActions["viewSnapToGuides"], "Page", true);
918
//      scrActions["pageDelete"]->setEnabled(false);
919
//      scrActions["pageMove"]->setEnabled(false);
5800 fschmid 920
 
921
        //View menu
12940 cbradney 922
        scrMenuMgr->createMenu("View", ActionManager::defaultMenuNameEntryTranslated("View"));
14509 cbradney 923
        scrMenuMgr->addMenuItem(scrActions["viewFitInWindow"], "View", false);
924
        scrMenuMgr->addMenuItem(scrActions["viewFitWidth"], "View", false);
925
        scrMenuMgr->addMenuItem(scrActions["viewFit50"], "View", false);
926
        scrMenuMgr->addMenuItem(scrActions["viewFit75"], "View", false);
927
        scrMenuMgr->addMenuItem(scrActions["viewFit100"], "View", false);
928
        scrMenuMgr->addMenuItem(scrActions["viewFit200"], "View", false);
929
        scrMenuMgr->addMenuItem(scrActions["viewFit400"], "View", false);
5800 fschmid 930
        scrMenuMgr->addMenuSeparator("View");
14509 cbradney 931
        scrMenuMgr->addMenuItem(scrActions["viewFitPreview"], "View", true);
7587 cbradney 932
        scrMenuMgr->addMenuSeparator("View");
14509 cbradney 933
        scrMenuMgr->addMenuItem(scrActions["viewShowMargins"], "View", true);
934
        scrMenuMgr->addMenuItem(scrActions["viewShowBleeds"], "View", true);
935
        scrMenuMgr->addMenuItem(scrActions["viewShowFrames"], "View", true);
936
        scrMenuMgr->addMenuItem(scrActions["viewShowLayerMarkers"], "View", true);
937
        scrMenuMgr->addMenuItem(scrActions["viewShowImages"], "View", true);
938
        scrMenuMgr->addMenuItem(scrActions["viewShowGrid"], "View", true);
939
        scrMenuMgr->addMenuItem(scrActions["viewShowGuides"], "View", true);
940
        scrMenuMgr->addMenuItem(scrActions["viewShowColumnBorders"], "View", true);
941
        scrMenuMgr->addMenuItem(scrActions["viewShowBaseline"], "View", true);
942
        scrMenuMgr->addMenuItem(scrActions["viewShowTextChain"], "View", true);
943
        scrMenuMgr->addMenuItem(scrActions["viewShowTextControls"], "View", true);
944
        scrMenuMgr->addMenuItem(scrActions["viewShowRulers"], "View", false);
945
        scrMenuMgr->addMenuItem(scrActions["viewRulerMode"], "View", true);
946
        scrMenuMgr->addMenuItem(scrActions["showMouseCoordinates"], "View", true);
5800 fschmid 947
 
14509 cbradney 948
//      scrActions["viewShowRulers"]->setEnabled(false);
5800 fschmid 949
 
950
        //CB If this is viewNewView imeplemented, it should be on the windows menu
951
//      scrMenuMgr->addMenuItem(scrActions["viewNewView"], "View");
952
 
953
        //Tool menu
954
        /*
955
        scrMenuMgr->createMenu("Tools", tr("&Tools"));
956
        scrMenuMgr->addMenuItem(scrActions["toolsProperties"], "Tools");
957
        scrMenuMgr->addMenuItem(scrActions["toolsOutline"], "Tools");
958
        scrMenuMgr->addMenuItem(scrActions["toolsScrapbook"], "Tools");
959
        scrMenuMgr->addMenuItem(scrActions["toolsLayers"], "Tools");
960
        scrMenuMgr->addMenuItem(scrActions["toolsPages"], "Tools");
961
        scrMenuMgr->addMenuItem(scrActions["toolsBookmarks"], "Tools");
962
        scrMenuMgr->addMenuItem(scrActions["toolsMeasurements"], "Tools");
963
        scrMenuMgr->addMenuItem(scrActions["toolsActionHistory"], "Tools");
964
        scrMenuMgr->addMenuItem(scrActions["toolsPreflightVerifier"], "Tools");
965
        scrMenuMgr->addMenuItem(scrActions["toolsAlignDistribute"], "Tools");
966
        scrMenuMgr->addMenuSeparator("Tools");
967
        scrMenuMgr->addMenuItem(scrActions["toolsToolbarTools"], "Tools");
968
        scrMenuMgr->addMenuItem(scrActions["toolsToolbarPDF"], "Tools");
969
        //scrActions["toolsPreflightVerifier"]->setEnabled(false);*/
970
 
971
        //Extra menu
12940 cbradney 972
        scrMenuMgr->createMenu("Extras", ActionManager::defaultMenuNameEntryTranslated("Extras"));
14509 cbradney 973
        scrMenuMgr->addMenuItem(scrActions["extrasManageImages"], "Extras", false);
974
        scrMenuMgr->addMenuItem(scrActions["extrasHyphenateText"], "Extras", false);
975
        scrMenuMgr->addMenuItem(scrActions["extrasDeHyphenateText"], "Extras", false);
976
        scrMenuMgr->addMenuItem(scrActions["extrasGenerateTableOfContents"], "Extras", false);
5800 fschmid 977
 
978
        scrMenuMgr->setMenuEnabled("Extras", false);
14509 cbradney 979
//      scrActions["extrasHyphenateText"]->setEnabled(false);
980
//      scrActions["extrasDeHyphenateText"]->setEnabled(false);
11129 subik 981
        connect(scrMenuMgr->getLocalPopupMenu("Extras"), SIGNAL(aboutToShow()), this, SLOT(extrasMenuAboutToShow()));
5800 fschmid 982
 
983
        //Window menu
12940 cbradney 984
         scrMenuMgr->createMenu("Windows", ActionManager::defaultMenuNameEntryTranslated("Windows"), QString::null, true);
5800 fschmid 985
        connect(scrMenuMgr->getLocalPopupMenu("Windows"), SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
986
        addDefaultWindowMenuItems();
987
 
988
        //Help menu
12940 cbradney 989
        scrMenuMgr->createMenu("Help", ActionManager::defaultMenuNameEntryTranslated("Help"));
14509 cbradney 990
        scrMenuMgr->addMenuItem(scrActions["helpManual"], "Help", true);
991
        scrMenuMgr->addMenuItem(scrActions["helpManual2"], "Help", true);
7425 cbradney 992
        scrMenuMgr->addMenuSeparator("Help");
14509 cbradney 993
        scrMenuMgr->addMenuItem(scrActions["helpTooltips"], "Help", true);
7425 cbradney 994
        scrMenuMgr->addMenuSeparator("Help");
14509 cbradney 995
        scrMenuMgr->addMenuItem(scrActions["helpOnlineWWW"], "Help", true);
996
        scrMenuMgr->addMenuItem(scrActions["helpOnlineDocs"], "Help", true);
997
        scrMenuMgr->addMenuItem(scrActions["helpOnlineWiki"], "Help", true);
10558 cbradney 998
        scrMenuMgr->createMenu("HelpOnlineTutorials", tr("Online &Tutorials"), "Help");
14509 cbradney 999
        scrMenuMgr->addMenuItem(scrActions["helpOnlineTutorial1"], "HelpOnlineTutorials", true);
10311 cbradney 1000
        scrMenuMgr->addMenuSeparator("Help");
14509 cbradney 1001
        scrMenuMgr->addMenuItem(scrActions["helpCheckUpdates"], "Help", true);
10913 jghali 1002
        scrMenuMgr->addMenuSeparator("Help");
14509 cbradney 1003
        scrMenuMgr->addMenuItem(scrActions["helpAboutScribus"], "Help", true);
1004
        scrMenuMgr->addMenuItem(scrActions["helpAboutPlugins"], "Help", true);
1005
        scrMenuMgr->addMenuItem(scrActions["helpAboutQt"], "Help", true);
10953 subik 1006
 
5800 fschmid 1007
        scrMenuMgr->addMenuToMenuBar("File");
1008
        scrMenuMgr->addMenuToMenuBar("Edit");
1009
        scrMenuMgr->addMenuToMenuBar("Item");
14509 cbradney 1010
//      scrMenuMgr->setMenuEnabled("Item", false);
5800 fschmid 1011
        scrMenuMgr->addMenuToMenuBar("Insert");
1012
        scrMenuMgr->setMenuEnabled("Insert", false);
1013
        scrMenuMgr->addMenuToMenuBar("Page");
14509 cbradney 1014
//      scrMenuMgr->setMenuEnabled("Page", false);
5800 fschmid 1015
        scrMenuMgr->addMenuToMenuBar("View");
14509 cbradney 1016
//      scrMenuMgr->setMenuEnabled("View", false);
5800 fschmid 1017
        //scrMenuMgr->addMenuToMenuBar("Tools");
1018
        scrMenuMgr->addMenuToMenuBar("Extras");
1019
        scrMenuMgr->setMenuEnabled("Extras", false);
1020
        scrMenuMgr->addMenuToMenuBar("Windows");
1021
        //scrMenuMgr->setMenuEnabled("Windows", false);
10564 fschmid 1022
        menuBar()->addSeparator();
5800 fschmid 1023
        scrMenuMgr->addMenuToMenuBar("Help");
1024
}
1025
 
10532 avox 1026
 
5800 fschmid 1027
void ScribusMainWindow::addDefaultWindowMenuItems()
1028
{
1029
        scrMenuMgr->clearMenu("Windows");
14509 cbradney 1030
        scrMenuMgr->addMenuItem(scrActions["windowsCascade"], "Windows", true);
1031
        scrMenuMgr->addMenuItem(scrActions["windowsTile"], "Windows", true);
5800 fschmid 1032
        scrMenuMgr->addMenuSeparator("Windows");
1033
 
14509 cbradney 1034
        scrMenuMgr->addMenuItem(scrActions["toolsProperties"], "Windows", true);
1035
        scrMenuMgr->addMenuItem(scrActions["toolsOutline"], "Windows", true);
1036
        scrMenuMgr->addMenuItem(scrActions["toolsScrapbook"], "Windows", true);
1037
        scrMenuMgr->addMenuItem(scrActions["toolsLayers"], "Windows", true);
1038
        scrMenuMgr->addMenuItem(scrActions["toolsPages"], "Windows", true);
1039
        scrMenuMgr->addMenuItem(scrActions["toolsBookmarks"], "Windows", true);
1040
        scrMenuMgr->addMenuItem(scrActions["toolsMeasurements"], "Windows", true);
1041
        scrMenuMgr->addMenuItem(scrActions["toolsActionHistory"], "Windows", true);
1042
        scrMenuMgr->addMenuItem(scrActions["toolsPreflightVerifier"], "Windows", true);
1043
        scrMenuMgr->addMenuItem(scrActions["toolsAlignDistribute"], "Windows", true);
5800 fschmid 1044
        scrMenuMgr->addMenuSeparator("Windows");
14509 cbradney 1045
        scrMenuMgr->addMenuItem(scrActions["toolsToolbarTools"], "Windows", true);
1046
        scrMenuMgr->addMenuItem(scrActions["toolsToolbarPDF"], "Windows", true);
5800 fschmid 1047
}
1048
 
1049
 
1050
void ScribusMainWindow::initStatusBar()
1051
{
10564 fschmid 1052
        mainWindowStatusLabel = new QLabel( "           ", statusBar());
9953 cbradney 1053
        mainWindowProgressBar = new QProgressBar(statusBar());
1054
        mainWindowProgressBar->setAlignment(Qt::AlignHCenter);
5800 fschmid 1055
        mainWindowProgressBar->setFixedWidth( 100 );
1056
        mainWindowProgressBar->reset();
12904 jghali 1057
        mainWindowXPosLabel = new QLabel( tr("X-Pos:"), statusBar());
1058
        mainWindowYPosLabel = new QLabel( tr("Y-Pos:"), statusBar());
10564 fschmid 1059
        mainWindowXPosDataLabel = new QLabel( "        ", statusBar());
1060
        mainWindowYPosDataLabel = new QLabel( "        ", statusBar());
5800 fschmid 1061
 
10564 fschmid 1062
        statusBar()->addPermanentWidget(mainWindowStatusLabel, 6);
1063
        statusBar()->addPermanentWidget(mainWindowProgressBar, 0);
1064
        statusBar()->addPermanentWidget(mainWindowXPosLabel, 0);
1065
        statusBar()->addPermanentWidget(mainWindowXPosDataLabel, 1);
1066
        statusBar()->addPermanentWidget(mainWindowYPosLabel, 0);
1067
        statusBar()->addPermanentWidget(mainWindowYPosDataLabel, 1);
5800 fschmid 1068
}
1069
 
10532 avox 1070
 
5800 fschmid 1071
void ScribusMainWindow::setStatusBarMousePosition(double xp, double yp)
1072
{
1073
        double xn = xp;
1074
        double yn = yp;
1075
        if (doc->guidesSettings.rulerMode)
1076
        {
1077
                xn -= doc->currentPage()->xOffset();
1078
                yn -= doc->currentPage()->yOffset();
1079
        }
1080
        xn -= doc->rulerXoffset;
1081
        yn -= doc->rulerYoffset;
12652 cbradney 1082
        mainWindowXPosDataLabel->setText(value2String(xn, doc->unitIndex(), true, true));
1083
        mainWindowYPosDataLabel->setText(value2String(yn, doc->unitIndex(), true, true));
5800 fschmid 1084
}
1085
 
10532 avox 1086
 
5800 fschmid 1087
void ScribusMainWindow::setStatusBarInfoText(QString newText)
1088
{
1089
        if (mainWindowStatusLabel)
1090
                mainWindowStatusLabel->setText(newText);
1091
}
1092
 
10532 avox 1093
 
1094
//AV to be replaced with Selection::update and listener in PropertiesPalette
5800 fschmid 1095
void ScribusMainWindow::setTBvals(PageItem *currItem)
1096
{
1097
        if (currItem->itemText.length() != 0)
1098
        {
8562 jghali 1099
//              int ChPos = qMin(currItem->CPos, static_cast<int>(currItem->itemText.length()-1));
12715 pierre 1100
                const ParagraphStyle& currPStyle( (doc->appMode == modeEdit) ? currItem->currentStyle() : currItem->itemText.defaultStyle());
5800 fschmid 1101
                setAbsValue(currPStyle.alignment());
6866 avox 1102
                propertiesPalette->setParStyle(currPStyle.parent());
9607 avox 1103
                propertiesPalette->setCharStyle(currItem->currentCharStyle().parent());
9067 avox 1104
                doc->currentStyle = currItem->currentStyle();
13616 jghali 1105
                // #8112 : do not use operator= here as it does not update style features
1106
                doc->currentStyle.charStyle().setStyle( currItem->currentCharStyle() );
9067 avox 1107
                emit TextStyle(doc->currentStyle);
1108
                // to go: (av)
5800 fschmid 1109
                emit TextUnderline(doc->currentStyle.charStyle().underlineOffset(), doc->currentStyle.charStyle().underlineWidth());
1110
                emit TextStrike(doc->currentStyle.charStyle().strikethruOffset(), doc->currentStyle.charStyle().strikethruWidth());
1111
                emit TextShadow(doc->currentStyle.charStyle().shadowXOffset(), doc->currentStyle.charStyle().shadowYOffset());
7087 subik 1112
                emit TextFarben(doc->currentStyle.charStyle().strokeColor(),
1113
                                                doc->currentStyle.charStyle().fillColor(),
1114
                                                doc->currentStyle.charStyle().strokeShade(),
5800 fschmid 1115
                                                doc->currentStyle.charStyle().fillShade());
5980 avox 1116
                emit TextIFont(doc->currentStyle.charStyle().font().scName());
5800 fschmid 1117
                emit TextISize(doc->currentStyle.charStyle().fontSize());
1118
                emit TextUSval(doc->currentStyle.charStyle().tracking());
1119
                emit TextStil(doc->currentStyle.charStyle().effects());
1120
                emit TextScale(doc->currentStyle.charStyle().scaleH());
1121
                emit TextScaleV(doc->currentStyle.charStyle().scaleV());
1122
                emit TextBase(doc->currentStyle.charStyle().baselineOffset());
1123
                emit TextOutline(doc->currentStyle.charStyle().outlineWidth());
1124
        }
1125
}
1126
 
1127
//Special keys assigned to actions are stolen by the action and not passed to
1128
//keyPressEvent so process them here.
8080 cbradney 1129
void ScribusMainWindow::specialActionKeyEvent(const QString& actionName, int unicodevalue)
5800 fschmid 1130
{
1131
        if (HaveDoc)
1132
        {
1133
                if (doc->appMode==modeEdit)
1134
                {
1135
                        if (doc->m_Selection->count() == 1)
1136
                        {
1137
                                PageItem *currItem = doc->m_Selection->itemAt(0);
1138
                                if (currItem!=NULL)
1139
                                {
1140
                                        if (unicodevalue!=-1)
1141
                                        {
1142
                                                if (currItem->HasSel && currItem->itemType()==PageItem::TextFrame)
1143
                                                        currItem->asTextFrame()->deleteSelectedTextFromFrame();
1144
 
9646 avox 1145
                                                currItem->itemText.insertChars(currItem->CPos, QString(QChar(unicodevalue)), true);
5800 fschmid 1146
                                                currItem->CPos += 1;
8177 avox 1147
//                                              currItem->Tinput = true;
10532 avox 1148
                                                currItem->update();
5800 fschmid 1149
                                        }
1150
                                        else if (actionName=="unicodeSmartHyphen") //ignore the char as we use an attribute if the text item, for now.
1151
                                        {
7087 subik 1152
                                                // this code is currently dead since unicodeSmartHyphen
6999 avox 1153
                                                // doesnt have unicodevalue == -1 any more
5800 fschmid 1154
                                                if (currItem->CPos-1>0)
1155
                                                {
7442 avox 1156
#if 0
8562 jghali 1157
                                                        StyleFlag fl = currItem->itemText.item(qMax(currItem->CPos-1,0))->effects();
5800 fschmid 1158
                                                        fl |= ScStyle_HyphenationPossible;
8562 jghali 1159
                                                        currItem->itemText.item(qMax(currItem->CPos-1,0))->setEffects(fl);
5800 fschmid 1160
#else
9646 avox 1161
                                                        currItem->itemText.insertChars(currItem->CPos, QString(SpecialChars::SHYPHEN), true);
5800 fschmid 1162
                                                        currItem->CPos += 1;
1163
#endif
8177 avox 1164
//                                                      currItem->Tinput = true;
10532 avox 1165
                                                        currItem->update();
5800 fschmid 1166
                                                }
1167
                                        }
1168
                                }
1169
                        }
1170
                }
1171
        }
1172
}
1173
 
1174
bool ScribusMainWindow::eventFilter( QObject* /*o*/, QEvent *e )
1175
{
1176
        bool retVal;
9562 fschmid 1177
        if (e->type() == QEvent::ToolTip)
1178
        {
13955 cbradney 1179
                return (!prefsManager->appPrefs.displayPrefs.showToolTips);
9562 fschmid 1180
        }
11960 subik 1181
        if ( e->type() == QEvent::KeyPress )
11893 cbradney 1182
        {
5800 fschmid 1183
                QKeyEvent *k = (QKeyEvent *)e;
1184
                int keyMod=0;
10390 cbradney 1185
                if (k->modifiers() & Qt::ShiftModifier)
8523 cbradney 1186
                        keyMod |= Qt::SHIFT;
10390 cbradney 1187
                if (k->modifiers() & Qt::ControlModifier)
8523 cbradney 1188
                        keyMod |= Qt::CTRL;
10390 cbradney 1189
                if (k->modifiers() & Qt::AltModifier)
8523 cbradney 1190
                        keyMod |= Qt::ALT;
5800 fschmid 1191
 
1192
                QKeySequence currKeySeq = QKeySequence(k->key() | keyMod);
1193
                if (QString(currKeySeq).isNull())
1194
                        return false;
1195
                retVal=true;
1196
                //Palette actions
10564 fschmid 1197
                if (currKeySeq == scrActions["specialToggleAllPalettes"]->shortcut())
8613 cbradney 1198
                        scrActions["specialToggleAllPalettes"]->activate(QAction::Trigger);
5800 fschmid 1199
                else
10390 cbradney 1200
// CB These were moved to ActionManager via the setShortcutContext(Qt::ApplicationShortcut) calls, leaving for notes for now
10181 cbradney 1201
//              if (currKeySeq == scrActions["toolsProperties"]->accel())
1202
//                      scrActions["toolsProperties"]->toggle();
1203
//              else
1204
//              if (currKeySeq == scrActions["toolsOutline"]->accel())
1205
//                      scrActions["toolsOutline"]->toggle();
1206
//              else
1207
//              if (currKeySeq == scrActions["toolsScrapbook"]->accel())
1208
//                      scrActions["toolsScrapbook"]->toggle();
1209
//              else
1210
//              if (currKeySeq == scrActions["toolsLayers"]->accel())
1211
//                      scrActions["toolsLayers"]->toggle();
1212
//              else
1213
//              if (currKeySeq == scrActions["toolsPages"]->accel())
1214
//                      scrActions["toolsPages"]->toggle();
1215
//              else
1216
//              if (currKeySeq == scrActions["toolsBookmarks"]->accel())
1217
//                      scrActions["toolsBookmarks"]->toggle();
1218
//              else
1219
//              if (currKeySeq == scrActions["toolsActionHistory"]->accel())
1220
//                      scrActions["toolsActionHistory"]->toggle();
1221
//              else
1222
//              if (currKeySeq == scrActions["toolsPreflightVerifier"]->accel())
1223
//                      scrActions["toolsPreflightVerifier"]->toggle();
1224
//              else
1225
//              if (currKeySeq == scrActions["toolsAlignDistribute"]->accel())
1226
//                      scrActions["toolsAlignDistribute"]->toggle();
1227
//              else
8005 cbradney 1228
                //Edit actions
10564 fschmid 1229
                if (currKeySeq == scrActions["editStyles"]->shortcut())
8005 cbradney 1230
                        scrActions["editStyles"]->toggle();
1231
                else
10564 fschmid 1232
                if (currKeySeq == scrActions["editUndoAction"]->shortcut() && scrActions["editUndoAction"]->isEnabled())
8613 cbradney 1233
                        scrActions["editUndoAction"]->activate(QAction::Trigger);
5800 fschmid 1234
                else
10564 fschmid 1235
                if (currKeySeq == scrActions["editRedoAction"]->shortcut() && scrActions["editRedoAction"]->isEnabled())
8613 cbradney 1236
                        scrActions["editRedoAction"]->activate(QAction::Trigger);
5800 fschmid 1237
                else
1238
                //Other actions
10564 fschmid 1239
                if (currKeySeq == scrActions["fileQuit"]->shortcut())
8613 cbradney 1240
                        scrActions["fileQuit"]->activate(QAction::Trigger);
5800 fschmid 1241
                else
1242
                //Zoom actions
10564 fschmid 1243
                if (currKeySeq == scrActions["toolsZoomIn"]->shortcut())
8613 cbradney 1244
                        scrActions["toolsZoomIn"]->activate(QAction::Trigger);
5800 fschmid 1245
                else
10564 fschmid 1246
                if (currKeySeq == scrActions["toolsZoomOut"]->shortcut())
8613 cbradney 1247
                        scrActions["toolsZoomOut"]->activate(QAction::Trigger);
5800 fschmid 1248
                else
1249
                        retVal=false;
1250
        }
1251
        else
1252
                retVal=false;
1253
        //Return false to pass event to object
1254
        return retVal;
1255
}
1256
 
10532 avox 1257
 
1258
//AV -> CanvasMode
5800 fschmid 1259
void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
1260
{
13950 fschmid 1261
        QList<QMdiSubWindow *> windows;
1262
        QMdiSubWindow* w = NULL;
5800 fschmid 1263
        int kk = k->key();
1264
        QString uc = k->text();
11146 cbradney 1265
//      QString cr, Tcha, Twort;
7435 fschmid 1266
        if (HaveDoc)
1267
        {
8523 cbradney 1268
                if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift))
7435 fschmid 1269
                {
9380 fschmid 1270
                        qApp->changeOverrideCursor(QCursor(loadIcon("LupeZm.xpm")));
7435 fschmid 1271
                        return;
1272
                }
1273
        }
5800 fschmid 1274
        if (keyrep)
1275
                return;
1276
        keyrep = true;
10390 cbradney 1277
        int keyMod=0;
1278
        if (k->modifiers() & Qt::ShiftModifier)
1279
                keyMod |= Qt::SHIFT;
1280
        if (k->modifiers() & Qt::ControlModifier)
1281
                keyMod |= Qt::CTRL;
1282
        if (k->modifiers() & Qt::AltModifier)
1283
                keyMod |= Qt::ALT;
5800 fschmid 1284
        //User presses escape and we have a doc open, and we have an item selected
8523 cbradney 1285
        if ((kk == Qt::Key_Escape) && (HaveDoc))
5800 fschmid 1286
        {
1287
                keyrep = false;
1288
                PageItem *currItem;
1289
                if (doc->m_Selection->count() != 0)
1290
                {
1291
                        currItem = doc->m_Selection->itemAt(0);
1292
                        switch (doc->appMode)
1293
                        {
1294
                                case modeNormal:
10532 avox 1295
                                case modeEditClip:
5800 fschmid 1296
                                        currItem->Sizing = false;
1297
                                        if (doc->SubMode != -1)
1298
                                        {
1299
                                                view->Deselect(false);
9856 fschmid 1300
                                                doc->Items->removeAt(currItem->ItemNr);
5800 fschmid 1301
                                        }
5967 fschmid 1302
                                        else
1303
                                                view->Deselect(false);
11576 avox 1304
                                        view->cancelGroupTransaction();
5800 fschmid 1305
                                        break;
7436 fschmid 1306
                                case modeEdit:
11576 avox 1307
                                        view->cancelGroupTransaction();
7436 fschmid 1308
                                        break;
5800 fschmid 1309
                                case modeLinkFrames:
1310
                                case modeUnlinkFrames:
1311
                                case modeRotation:
1312
                                case modeEditGradientVectors:
8942 cbradney 1313
                                case modeCopyProperties:
5800 fschmid 1314
                                        view->Deselect(false);
12022 cbradney 1315
                                case modeEyeDropper:
12971 jghali 1316
                                case modeImportObject:
5800 fschmid 1317
                                case modePanning:
11490 avox 1318
                                        view->requestMode(modeNormal);
5800 fschmid 1319
                                        break;
1320
                                case modeDrawBezierLine:
11672 cbradney 1321
                                        currItem->PoLine.resize(qMax(0, static_cast<int>(currItem->PoLine.size())-2));
5800 fschmid 1322
                                        if (currItem->PoLine.size() < 4)
1323
                                        {
1324
                                                view->Deselect(false);
9856 fschmid 1325
                                                doc->Items->removeAt(currItem->ItemNr);
5800 fschmid 1326
                                        }
1327
                                        else
1328
                                        {
7736 cbradney 1329
                                                doc->SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem->ItemNr, false, false);
8591 cbradney 1330
                                                currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1.0)));
7736 cbradney 1331
                                                doc->AdjustItemSize(currItem);
5800 fschmid 1332
                                                currItem->ContourLine = currItem->PoLine.copy();
1333
                                                currItem->ClipEdited = true;
1334
                                                currItem->FrameType = 3;
1335
                                                slotDocCh();
1336
                                        }
1337
                                        view->FirstPoly = true;
1338
                                        break;
1339
                                default:
11704 fschmid 1340
                                        if (currItem->Sizing)
1341
                                        {
1342
                                                view->Deselect(false);
1343
                                                doc->Items->removeAt(currItem->ItemNr);
1344
                                        }
5800 fschmid 1345
                                        break;
1346
                        }
1347
                }
1348
                doc->DragP = false;
1349
                doc->leaveDrag = false;
10532 avox 1350
                view->stopAllDrags();
5800 fschmid 1351
                doc->SubMode = -1;
1352
                doc->ElemToLink = NULL;
1353
                slotSelect();
11704 fschmid 1354
                if (doc->m_Selection->count() == 0)
1355
                        HaveNewSel(-1);
13955 cbradney 1356
                prefsManager->appPrefs.uiPrefs.stickyTools = false;
1357
                scrActions["stickyTools"]->setChecked(false);
5800 fschmid 1358
                return;
1359
        }
10390 cbradney 1360
        Qt::KeyboardModifiers buttonModifiers = k->modifiers();
5800 fschmid 1361
        /**If we have a doc and we are not changing the page or zoom level in the status bar */
1362
        if ((HaveDoc) && (!view->zoomSpinBox->hasFocus()) && (!view->pageSelector->hasFocus()))
1363
        {
11146 cbradney 1364
                //Show our context menu
1365
                QKeySequence currKeySeq = QKeySequence(kk | keyMod);
11149 cbradney 1366
                if (currKeySeq.matches(scrActions["viewShowContextMenu"]->shortcut()) == QKeySequence::ExactMatch)
11146 cbradney 1367
                {
1368
                        ContextMenu* cmen=NULL;
1369
                        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
1370
                        if (doc->m_Selection->count() == 0)
1371
                        {
1372
                                //CB We should be able to get this calculated by the canvas.... it is already in m_canvas->globalToCanvas(m->globalPos());
1373
                                QPoint p(QCursor::pos() - mapToGlobal(QPoint(0,0)));
1374
                                FPoint fp(p.x() / view->scale() + doc->minCanvasCoordinate.x(),
11960 subik 1375
                                p.y() / view->scale() + doc->minCanvasCoordinate.y());
11146 cbradney 1376
                                cmen = new ContextMenu(this, doc, fp.x(), fp.y());
1377
                        }
1378
                        else
1379
                                cmen = new ContextMenu(*(doc->m_Selection), this, doc);
1380
                        if (cmen)
1381
                        {
1382
                                setUndoMode(true);
1383
                                cmen->exec(QCursor::pos());
1384
                                setUndoMode(false);
1385
                        }
1386
                        delete cmen;
1387
                }
11960 subik 1388
 
1389
 
5800 fschmid 1390
                /**
1391
                 * With no item selected we can:
1392
                 * - With space, get into panning mode (modePanning)
1393
                 * - With PageUp, scroll up
1394
                 * - With PageDown, scroll down
1395
                 * - With Tab, change active document windowActivated
1396
                 */
1397
 
1398
                if ((doc->appMode != modeEdit) && (doc->m_Selection->count() == 0))
1399
                {
6284 fschmid 1400
                        int pg;
13870 cbradney 1401
                        int wheelVal = prefsManager->mouseWheelJump();
10390 cbradney 1402
                        if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
8970 fschmid 1403
                                wheelVal = qMax(qRound(wheelVal / 10.0), 1);
5800 fschmid 1404
                        switch (kk)
1405
                        {
8523 cbradney 1406
                        case Qt::Key_Space:
5800 fschmid 1407
                                keyrep = false;
1408
                                if (doc->appMode == modePanning)
10532 avox 1409
                                        view->requestMode(modeNormal);
5800 fschmid 1410
                                else
10532 avox 1411
                                        view->requestMode(modePanning);
5800 fschmid 1412
                                return;
1413
                                break;
10564 fschmid 1414
                        case Qt::Key_PageUp:
6284 fschmid 1415
                                if (doc->masterPageMode())
13870 cbradney 1416
                                        view->scrollBy(0, -prefsManager->mouseWheelJump());
6284 fschmid 1417
                                else
1418
                                {
1419
                                        pg = doc->currentPageNumber();
10390 cbradney 1420
                                        if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
6284 fschmid 1421
                                                pg--;
1422
                                        else
1423
                                                pg -= doc->pageSets[doc->currentPageLayout].Columns;
1424
                                        if (pg > -1)
1425
                                                view->GotoPage(pg);
1426
                                }
5800 fschmid 1427
                                keyrep = false;
1428
                                return;
1429
                                break;
10564 fschmid 1430
                        case Qt::Key_PageDown:
6284 fschmid 1431
                                if (doc->masterPageMode())
13870 cbradney 1432
                                        view->scrollBy(0, prefsManager->mouseWheelJump());
6284 fschmid 1433
                                else
1434
                                {
1435
                                        pg = doc->currentPageNumber();
10390 cbradney 1436
                                        if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
6284 fschmid 1437
                                                pg++;
1438
                                        else
1439
                                                pg += doc->pageSets[doc->currentPageLayout].Columns;
7328 fschmid 1440
                                        if (pg < static_cast<int>(doc->Pages->count()))
6284 fschmid 1441
                                                view->GotoPage(pg);
1442
                                }
5800 fschmid 1443
                                keyrep = false;
1444
                                return;
1445
                                break;
8970 fschmid 1446
                        case Qt::Key_Left:
1447
                                view->scrollBy(-wheelVal, 0);
1448
                                keyrep = false;
1449
                                return;
1450
                                break;
1451
                        case Qt::Key_Right:
1452
                                view->scrollBy(wheelVal, 0);
1453
                                keyrep = false;
1454
                                return;
1455
                                break;
1456
                        case Qt::Key_Up:
1457
                                view->scrollBy(0, -wheelVal);
1458
                                keyrep = false;
1459
                                return;
1460
                                break;
1461
                        case Qt::Key_Down:
1462
                                view->scrollBy(0, wheelVal);
1463
                                keyrep = false;
1464
                                return;
1465
                                break;
8523 cbradney 1466
                        case Qt::Key_Tab:
14034 jghali 1467
                                if (buttonModifiers == Qt::ControlModifier)
5800 fschmid 1468
                                {
14034 jghali 1469
                                        keyrep = false;
1470
                                        windows = mdiArea->subWindowList();
1471
                                        if (windows.count() > 1)
5800 fschmid 1472
                                        {
14034 jghali 1473
                                                for (int i = 0; i < static_cast<int>(windows.count()); ++i)
5800 fschmid 1474
                                                {
14034 jghali 1475
                                                        if (mdiArea->activeSubWindow() == windows.at(i))
1476
                                                        {
1477
                                                                if (i == static_cast<int>(windows.count()-1))
1478
                                                                        w = windows.at(0);
1479
                                                                else
1480
                                                                        w = windows.at(i+1);
1481
                                                                break;
1482
                                                        }
5800 fschmid 1483
                                                }
14034 jghali 1484
                                                outlinePalette->buildReopenVals();
1485
                                                docCheckerPalette->clearErrorList();
1486
                                                if ( w )
1487
                                                        w->showNormal();
1488
                                                newActWin(w);
5800 fschmid 1489
                                        }
14034 jghali 1490
                                        return;
5800 fschmid 1491
                                }
1492
                                break;
1493
                        }
1494
                }
1495
                /** Now if we have an item selected
1496
                 * - In normal mode we can:
1497
                 * -- Use backspace or delete to delete the item
1498
                 * -- In edit mode of an image frame, use the arrow keys to resize the image:
1499
                                (flows to pageitem_imageframe for control)
1500
                                Alt right arrow, move right side of image outwards (expand)
1501
                                Alt left arrow, move right side inwards (shrink)
1502
                                Alt down arrow, move bottom side downwards (expand)
1503
                                Alt up arrow, move top side inwards (shrink)
1504
                 */
1505
                if (doc->m_Selection->count() != 0)
1506
                {
1507
                        PageItem *currItem = doc->m_Selection->itemAt(0);
14340 jghali 1508
                        if (doc->appMode == modeEdit)
5800 fschmid 1509
                        {
1510
                                if (currItem->asImageFrame() && !currItem->locked())
1511
                                {
1512
                                        currItem->handleModeEditKey(k, keyrep);
1513
                                }
14340 jghali 1514
//FIXME:av              view->oldCp = currItem->CPos;
5800 fschmid 1515
                                if (currItem->itemType() == PageItem::TextFrame)
1516
                                {
1517
                                        bool kr=keyrep;
1518
                                        currItem->handleModeEditKey(k, keyrep);
1519
                                        keyrep=kr;
1520
                                }
1521
                                slotDocCh(false);
1522
                        }
1523
                }
1524
        }
1525
        switch(kk)
1526
        {
8523 cbradney 1527
                case Qt::Key_Left:
1528
                case Qt::Key_Right:
1529
                case Qt::Key_Up:
1530
                case Qt::Key_Down:
5800 fschmid 1531
                        _arrowKeyDown = true;
1532
        }
1533
        keyrep = false;
1534
}
1535
 
1536
void ScribusMainWindow::keyReleaseEvent(QKeyEvent *k)
1537
{
10390 cbradney 1538
        //Exit out of panning mode if Control is release while the right mouse button is pressed
1539
        if (HaveDoc)
5800 fschmid 1540
        {
10390 cbradney 1541
                if ((doc->appMode == modePanning) && (k->key() == Qt::Key_Control) && (QApplication::mouseButtons() & Qt::RightButton))
10532 avox 1542
                        view->requestMode(modeNormal);
5800 fschmid 1543
        }
7435 fschmid 1544
        if (HaveDoc)
1545
        {
1546
                if (doc->appMode == modeMagnifier)
9380 fschmid 1547
                        qApp->changeOverrideCursor(QCursor(loadIcon("LupeZ.xpm")));
7435 fschmid 1548
        }
5800 fschmid 1549
        if (k->isAutoRepeat() || !_arrowKeyDown)
1550
                return;
1551
        switch(k->key())
1552
        {
8523 cbradney 1553
                case Qt::Key_Left:
1554
                case Qt::Key_Right:
1555
                case Qt::Key_Up:
1556
                case Qt::Key_Down:
5800 fschmid 1557
                        _arrowKeyDown = false;
1558
                        if ((HaveDoc) && (!view->zoomSpinBox->hasFocus()) && (!view->pageSelector->hasFocus()))
1559
                        {
10390 cbradney 1560
                                int docSelectionCount=doc->m_Selection->count();
10532 avox 1561
                                if ((docSelectionCount != 0) && (doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
9735 fschmid 1562
                                {
1563
                                        PageItem *currItem = doc->m_Selection->itemAt(0);
1564
                                        double xposOrig = currItem->xPos();
1565
                                        double yposOrig = currItem->yPos();
1566
                                        doc->AdjustItemSize(currItem);
10532 avox 1567
                                        if (!doc->nodeEdit.isContourLine)
9735 fschmid 1568
                                                currItem->ContourLine.translate(xposOrig - currItem->xPos(),yposOrig - currItem->yPos());
10532 avox 1569
                                        currItem->update();
9735 fschmid 1570
                                }
10390 cbradney 1571
                                for (int i = 0; i < docSelectionCount; ++i)
5800 fschmid 1572
                                        doc->m_Selection->itemAt(i)->checkChanges(true);
1573
                                if (docSelectionCount > 1 && view->groupTransactionStarted())
11576 avox 1574
                                        view->endGroupTransaction();
5800 fschmid 1575
                        }
1576
                        break;
1577
        }
1578
}
1579
 
10859 cbradney 1580
void ScribusMainWindow::changeEvent(QEvent *e)
1581
{
1582
        if (e->type() == QEvent::LanguageChange)
1583
        {
1584
                languageChange();
1585
        }
10903 cbradney 1586
        else
1587
                QWidget::changeEvent(e);
10859 cbradney 1588
}
1589
 
5800 fschmid 1590
void ScribusMainWindow::closeEvent(QCloseEvent *ce)
1591
{
13487 cbradney 1592
        //Do not quit if Preferences or new doc window is open
13478 cbradney 1593
        Preferences *prefsWin = findChild<Preferences *>(QString::fromLocal8Bit("PreferencesWindow"));
14658 cbradney 1594
        PreferencesDialog *prefsDialog = findChild<PreferencesDialog *>(QString::fromLocal8Bit("PreferencesDialog"));
13487 cbradney 1595
        NewDoc *newDocWin = findChild<NewDoc *>(QString::fromLocal8Bit("NewDocumentWindow"));
14658 cbradney 1596
        if (prefsWin!=NULL || prefsDialog!=NULL || newDocWin!=NULL)
13478 cbradney 1597
        {
1598
                ce->ignore();
1599
                return;
1600
        }
13959 jghali 1601
        QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
5800 fschmid 1602
        ScribusWin* tw;
13959 jghali 1603
        disconnect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
5800 fschmid 1604
        if (!windows.isEmpty())
1605
        {
1606
                uint windowCount=windows.count();
1607
                for ( uint i = 0; i < windowCount; ++i )
1608
                {
14010 fschmid 1609
                        tw = (ScribusWin *)(windows.at(i));
1610
                        QMdiSubWindow *tws = windows.at(i);
1611
                        ScribusWin* scw = dynamic_cast<ScribusWin *>(tws->widget());
1612
                        if (scw)
5800 fschmid 1613
                        {
14001 fschmid 1614
                                newActWin(windows.at(i));
1615
                                tw = ActWin;
1616
                                slotSelect();
1617
                                ActWin->close();
1618
                                if (tw == ActWin)
1619
                                {
1620
                                        ce->ignore();
1621
                                        connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
1622
                                        return;
1623
                                }
5800 fschmid 1624
                        }
1625
                }
1626
        }
1627
        propertiesPalette->hide();
1628
        outlinePalette->hide();
1629
        scrapbookPalette->hide();
1630
        bookmarkPalette->hide();
1631
        layerPalette->hide();
1632
        pagePalette->hide();
11190 avox 1633
//      measurementPalette->hide();
5800 fschmid 1634
        docCheckerPalette->hide();
1635
        undoPalette->hide();
1636
        alignDistributePalette->hide();
1637
        guidePalette->hide();
7087 subik 1638
        charPalette->hide();
5800 fschmid 1639
 
1640
        // Clean up plugins, THEN save prefs to disk
1641
        ScCore->pluginManager->cleanupPlugins();
13955 cbradney 1642
        if (!prefsManager->appPrefs.scrapbookPrefs.persistentScrapbook)
5800 fschmid 1643
                scrapbookPalette->CleanUpTemp();
13955 cbradney 1644
        prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks.clear();
1645
        prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks = scrapbookPalette->getOpenScrapbooks();
5800 fschmid 1646
        if (!emergencyActivated)
1647
                prefsManager->SavePrefs();
1648
        UndoManager::deleteInstance();
10181 cbradney 1649
        PrefsManager::deleteInstance();
1650
        FormatsManager::deleteInstance();
10311 cbradney 1651
        UrlLauncher::deleteInstance();
9380 fschmid 1652
        qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
10259 jghali 1653
        qApp->exit(0);
5800 fschmid 1654
}
1655
 
1656
/////////////////////////////////////////////////////////////////////
1657
// SLOT IMPLEMENTATION
1658
/////////////////////////////////////////////////////////////////////
1659
 
1660
 
1661
bool ScribusMainWindow::arrowKeyDown()
1662
{
1663
        return _arrowKeyDown;
1664
}
1665
 
1666
void ScribusMainWindow::startUpDialog()
1667
{
7025 fschmid 1668
        bool docSet = false;
5800 fschmid 1669
        PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false);
13876 cbradney 1670
        NewDoc* dia = new NewDoc(this, RecentDocs, true, ScCore->getGuiLanguage(), PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
5800 fschmid 1671
        if (dia->exec())
1672
        {
13380 subik 1673
                if (dia->tabSelected() == NewDoc::NewDocumentTab)
5800 fschmid 1674
                {
13236 jghali 1675
                        int facingPages = dia->choosenLayout();
10564 fschmid 1676
                        int firstPage = dia->firstPage->currentIndex();
7025 fschmid 1677
                        docSet = dia->startDocSetup->isChecked();
5800 fschmid 1678
                        double topMargin = dia->marginGroup->top();
1679
                        double bottomMargin = dia->marginGroup->bottom();
1680
                        double leftMargin = dia->marginGroup->left();
1681
                        double rightMargin = dia->marginGroup->right();
13236 jghali 1682
                        double columnDistance = dia->distance();
1683
                        double pageWidth = dia->pageWidth();
1684
                        double pageHeight = dia->pageHeight();
5800 fschmid 1685
                        double numberCols = dia->numberOfCols->value();
7023 fschmid 1686
                        bool autoframes = dia->autoTextFrame->isChecked();
13236 jghali 1687
                        int orientation = dia->orientation();
5918 cbradney 1688
                        int pageCount=dia->pageCountSpinBox->value();
7518 fschmid 1689
                        QString pagesize;
1690
                        if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize)
1691
                                pagesize = CommonStrings::customPageSize;
1692
                        else
1693
                        {
1694
                                PageSize ps2(dia->pageSizeComboBox->currentText());
1695
                                pagesize = ps2.name();
1696
                        }
12334 fschmid 1697
                        doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset());
5800 fschmid 1698
                        doc->pageSets[facingPages].FirstPage = firstPage;
13236 jghali 1699
                        doc->bleeds.Bottom = dia->bleedBottom();
1700
                        doc->bleeds.Top = dia->bleedTop();
1701
                        doc->bleeds.Left = dia->bleedLeft();
1702
                        doc->bleeds.Right = dia->bleedRight();
5800 fschmid 1703
                        HaveNewDoc();
10038 fschmid 1704
                        doc->reformPages(true);
11284 subik 1705
                        // Don's disturb user with "save?" dialog just after new doc
1706
                        // doc changing should be rewritten maybe... maybe later...
1707
                        doc->setModified(false);
1708
                        updateActiveWindowCaption(doc->DocName);
5800 fschmid 1709
                }
13380 subik 1710
                else if (dia->tabSelected() == NewDoc::NewFromTemplateTab)
5800 fschmid 1711
                {
13236 jghali 1712
                        QString fileName = QDir::cleanPath(dia->selectedFile());
1713
                        if (!fileName.isEmpty() && loadDoc(fileName))
5800 fschmid 1714
                        {
13188 fschmid 1715
                                doc->hasName = false;
1716
                                UndoManager::instance()->renameStack(dia->nftGui->currentDocumentTemplate->name);
1717
                                doc->DocName = dia->nftGui->currentDocumentTemplate->name;
1718
                                updateActiveWindowCaption(QObject::tr("Document Template: ") + dia->nftGui->currentDocumentTemplate->name);
1719
                                QDir::setCurrent(PrefsManager::instance()->documentDir());
13236 jghali 1720
                                removeRecent(fileName);
5800 fschmid 1721
                        }
13188 fschmid 1722
                }
13380 subik 1723
                else if (dia->tabSelected() == NewDoc::OpenExistingTab)
13188 fschmid 1724
                {
13236 jghali 1725
                        QString fileName = dia->selectedFile();
13188 fschmid 1726
                        if (!fileName.isEmpty())
5800 fschmid 1727
                        {
13235 jghali 1728
                                QFileInfo fi(fileName);
1729
                                docContext->set("docsopen", fi.absolutePath());
13188 fschmid 1730
                                loadDoc(fileName);
5800 fschmid 1731
                        }
1732
                }
13380 subik 1733
                else // NewDoc::OpenRecentTab
13188 fschmid 1734
                {
13236 jghali 1735
                        QString fileName = dia->selectedFile();
1736
                        if (!fileName.isEmpty())
1737
                                loadRecent(fileName);
13188 fschmid 1738
                }
5800 fschmid 1739
        }
1740
        prefsManager->setShowStartupDialog(!dia->startUpDialog->isChecked());
1741
        delete dia;
1742
        mainWindowStatusLabel->setText( tr("Ready"));
7025 fschmid 1743
        if (docSet)
1744
                slotDocSetup();
5800 fschmid 1745
}
1746
 
1747
bool ScribusMainWindow::slotFileNew()
1748
{
10532 avox 1749
        if (HaveDoc && doc->appMode == modeEditClip)
1750
                view->requestMode(submodeEndNodeEdit);
6189 jghali 1751
        bool retVal = false;
7025 fschmid 1752
        bool docSet = false;
5800 fschmid 1753
        NewDoc* dia = new NewDoc(this, RecentDocs);
1754
        if (dia->exec())
1755
        {
13236 jghali 1756
                int facingPages = dia->choosenLayout();
10564 fschmid 1757
                int firstPage = dia->firstPage->currentIndex();
7025 fschmid 1758
                docSet = dia->startDocSetup->isChecked();
5800 fschmid 1759
                double topMargin = dia->marginGroup->top();
1760
                double bottomMargin = dia->marginGroup->bottom();
1761
                double leftMargin = dia->marginGroup->left();
1762
                double rightMargin = dia->marginGroup->right();
13236 jghali 1763
                double columnDistance = dia->distance();
1764
                double pageWidth = dia->pageWidth();
1765
                double pageHeight = dia->pageHeight();
5800 fschmid 1766
                double numberCols = dia->numberOfCols->value();
7023 fschmid 1767
                bool autoframes = dia->autoTextFrame->isChecked();
13236 jghali 1768
                int orientation = dia->orientation();
5918 cbradney 1769
                int pageCount=dia->pageCountSpinBox->value();
7518 fschmid 1770
                QString pagesize;
1771
                if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize)
1772
                        pagesize = CommonStrings::customPageSize;
1773
                else
6189 jghali 1774
                {
7518 fschmid 1775
                        PageSize ps2(dia->pageSizeComboBox->currentText());
1776
                        pagesize = ps2.name();
1777
                }
12334 fschmid 1778
                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()))
7518 fschmid 1779
                {
6189 jghali 1780
                        doc->pageSets[facingPages].FirstPage = firstPage;
13236 jghali 1781
                        doc->bleeds.Bottom = dia->bleedBottom();
1782
                        doc->bleeds.Top = dia->bleedTop();
1783
                        doc->bleeds.Left = dia->bleedLeft();
1784
                        doc->bleeds.Right = dia->bleedRight();
6189 jghali 1785
                        mainWindowStatusLabel->setText( tr("Ready"));
1786
                        HaveNewDoc();
10038 fschmid 1787
                        doc->reformPages(true);
6189 jghali 1788
                        retVal = true;
11284 subik 1789
                        // Don's disturb user with "save?" dialog just after new doc
1790
                        // doc changing should be rewritten maybe... maybe later...
1791
                        doc->setModified(false);
1792
                        updateActiveWindowCaption(doc->DocName);
6189 jghali 1793
                }
5800 fschmid 1794
        }
1795
        delete dia;
7025 fschmid 1796
        if (docSet)
1797
                slotDocSetup();
6189 jghali 1798
        return retVal;
5800 fschmid 1799
}
1800
 
1801
//TODO move to core, assign doc to doc list, optionally create gui for it
12334 fschmid 1802
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)
5800 fschmid 1803
{
12334 fschmid 1804
        return doFileNew(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, columnCount, autoTextFrames, pageArrangement, unitIndex, firstPageLocation, orientation, firstPageNumber, defaultPageSize, requiresGUI, pageCount, showView, marginPreset);
5800 fschmid 1805
        /* TODO CB finish later this week.
1806
        if (HaveDoc)
1807
                doc->OpenNodes = outlinePalette->buildReopenVals();
1808
        MarginStruct margins(topMargin, leftMargin, bottomMargin, rightMargin);
1809
        DocPagesSetup pagesSetup(pageArrangement, firstPageLocation, firstPageNumber, orientation, autoTextFrames, columnDistance, columnCount);
1810
        QString newDocName(tr("Document")+"-"+QString::number(DocNr));
1811
        doc = new ScribusDoc(newDocName, unitindex, pagesize, margins, pagesSetup);
1812
                doc->setLoading(true);
1813
        doc->setup(unitIndex, pageArrangement, firstPageLocation, orientation, firstPageNumber, defaultPageSize, newDocName);
1814
        HaveDoc++;
1815
        DocNr++;
5880 jghali 1816
        if (ScCore->haveCMS() && doc->CMSSettings.CMSinUse)
5800 fschmid 1817
                recalcColors();
1818
        //CB NOTE should be all done now
1819
        doc->setPage(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, columnCount, autoTextFrames, pageArrangement);
1820
        doc->setMasterPageMode(false);
6715 cbradney 1821
        doc->addMasterPage(0, CommonStrings::masterPageNormal);
8562 jghali 1822
        int createCount=qMax(pageCount,1);
5800 fschmid 1823
        for (int i = 0; i < createCount; ++i)
6715 cbradney 1824
                doc->addPage(i, CommonStrings::masterPageNormal, true);
5800 fschmid 1825
        doc->addSection();
1826
        doc->setFirstSectionFromFirstPageNumber();
1827
        doc->setModified(false);
1828
        doc->OpenNodes.clear();
1829
        actionManager->disconnectNewDocActions();
1830
        actionManager->connectNewDocActions(doc);
1831
        //<<View and window code
13959 jghali 1832
        ScribusWin* w = new ScribusWin(mdiArea, doc);
5800 fschmid 1833
        w->setMainWindow(this);
1834
        if (view!=NULL)
1835
        {
1836
                actionManager->disconnectNewViewActions();
1837
                disconnect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
1838
        }
1839
        view = new ScribusView(w, this, doc);
1840
        doc->setCurrentPage(doc->Pages->at(0));
1841
        doc->setGUI(this, view);
1842
        doc->setLoading(false);
1843
        //run after setGUI to set up guidepalette ok
7087 subik 1844
 
5800 fschmid 1845
        view->setScale(prefsManager->displayScale());
1846
        actionManager->connectNewViewActions(view);
1847
        alignDistributePalette->setDoc(doc);
1848
        docCheckerPalette->clearErrorList();
1849
        w->setView(view);
1850
        ActWin = w;
1851
        doc->WinHan = w;
1852
        w->setCentralWidget(view);
1853
        doc->connectDocSignals(); //Must be before the first reformpages
1854
        view->reformPages(true);
1855
        //>>
1856
 
1857
        connect(undoManager, SIGNAL(undoRedoDone()), view, SLOT(DrawNew()));
1858
        //connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
1859
        connect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
1860
        //      connect(w, SIGNAL(SaveAndClose()), this, SLOT(DoSaveClose()));
1861
 
1862
        //Independent finishing tasks after doc setup
1863
        if (showView)
1864
        {
13959 jghali 1865
                if ( mdiArea->windowList().isEmpty() )
5800 fschmid 1866
                        w->showMaximized();
1867
                else
1868
                        w->show();
1869
                view->show();
1870
        }
1871
        connect(w, SIGNAL(AutoSaved()), this, SLOT(slotAutoSaved()));
1872
        connect(ScCore->fileWatcher, SIGNAL(fileChanged(QString)), doc, SLOT(updatePict(QString)));
1873
        connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString)), doc, SLOT(removePict(QString)));
1874
        scrActions["fileSave"]->setEnabled(false);
1875
        undoManager->switchStack(doc->DocName);
1876
        styleManager->currentDoc(doc);
1877
        tocGenerator->setDoc(doc);
1878
 
1879
        return doc;
1880
        */
1881
}
1882
 
12334 fschmid 1883
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)
5800 fschmid 1884
{
8220 fschmid 1885
        if (HaveDoc)
1886
                outlinePalette->buildReopenVals();
6725 tsoots 1887
        undoManager->setUndoEnabled(false);
5800 fschmid 1888
        MarginStruct margins(topMargin, leftMargin, bottomMargin, rightMargin);
1889
        DocPagesSetup pagesSetup(pageArrangement, firstPageLocation, firstPageNumber, orientation, autoTextFrames, columnDistance, columnCount);
6259 fschmid 1890
        QString newDocName( tr("Document")+"-"+QString::number(DocNr));
5808 cbradney 1891
        ScribusDoc *tempDoc = new ScribusDoc();
1892
        if (requiresGUI)
1893
                doc=tempDoc;
1894
        //tempDoc = new ScribusDoc(newDocName, unitindex, pagesize, margins, pagesSetup);
1895
        tempDoc->setLoading(true);
7099 fschmid 1896
        outlinePalette->setDoc(tempDoc);
5808 cbradney 1897
        tempDoc->setup(unitIndex, pageArrangement, firstPageLocation, orientation, firstPageNumber, defaultPageSize, newDocName);
1898
        if (requiresGUI)
1899
        {
1900
                HaveDoc++;
1901
                DocNr++;
1902
        }
5880 jghali 1903
        if (ScCore->haveCMS() && tempDoc->CMSSettings.CMSinUse)
5800 fschmid 1904
                recalcColors();
1905
        //CB NOTE should be all done now
5914 fschmid 1906
        tempDoc->setPage(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnCount, columnDistance, autoTextFrames, pageArrangement);
12334 fschmid 1907
        tempDoc->marginPreset = marginPreset;
5808 cbradney 1908
        tempDoc->setMasterPageMode(false);
6715 cbradney 1909
        tempDoc->createDefaultMasterPages();
1910
        tempDoc->createNewDocPages(pageCount);
5808 cbradney 1911
        tempDoc->addSection();
1912
        tempDoc->setFirstSectionFromFirstPageNumber();
1913
        tempDoc->setModified(false);
1914
        tempDoc->OpenNodes.clear();
1915
        if (requiresGUI)
1916
        {
1917
                actionManager->disconnectNewDocActions();
1918
                actionManager->connectNewDocActions(tempDoc);
1919
        }
5800 fschmid 1920
        //<<View and window code
13950 fschmid 1921
        QMdiArea* qwsp = 0;
5808 cbradney 1922
        if (requiresGUI)
13959 jghali 1923
                qwsp = mdiArea;
5808 cbradney 1924
        ScribusWin* w = new ScribusWin(qwsp, tempDoc);
5800 fschmid 1925
        w->setMainWindow(this);
5808 cbradney 1926
        if (requiresGUI && view!=NULL)
5800 fschmid 1927
        {
1928
                actionManager->disconnectNewViewActions();
13165 fschmid 1929
                disconnect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
5800 fschmid 1930
        }
5808 cbradney 1931
        ScribusView* tempView = new ScribusView(w, this, tempDoc);
1932
        if (requiresGUI)
1933
                view = tempView;
1934
        tempDoc->setCurrentPage(tempDoc->Pages->at(0));
5824 cbradney 1935
        tempDoc->setGUI(requiresGUI, this, tempView);
14717 cbradney 1936
        if (requiresGUI)
1937
        {
1938
                tempDoc->docHyphenator->ignoredWords = prefsManager->appPrefs.hyphPrefs.ignoredWords;
1939
                tempDoc->docHyphenator->specialWords = prefsManager->appPrefs.hyphPrefs.specialWords;
1940
        }
5808 cbradney 1941
        tempDoc->setLoading(false);
5800 fschmid 1942
        //run after setGUI to set up guidepalette ok
7087 subik 1943
 
5808 cbradney 1944
        tempView->setScale(prefsManager->displayScale());
1945
        if (requiresGUI)
1946
        {
1947
                actionManager->connectNewViewActions(tempView);
1948
                alignDistributePalette->setDoc(tempDoc);
1949
                docCheckerPalette->clearErrorList();
1950
        }
1951
        w->setView(tempView);
5800 fschmid 1952
        ActWin = w;
5808 cbradney 1953
        tempDoc->WinHan = w;
1954
        if (requiresGUI)
1955
                tempDoc->connectDocSignals(); //Must be before the first reformpages
1956
        tempView->reformPages(true);
5800 fschmid 1957
        //>>
5808 cbradney 1958
        if (requiresGUI)
1959
        {
13959 jghali 1960
                w->setSubWin(mdiArea->addSubWindow(w));
13349 jghali 1961
                connect(undoManager, SIGNAL(undoRedoBegin()), tempDoc, SLOT(undoRedoBegin()));
1962
                connect(undoManager, SIGNAL(undoRedoDone()), tempDoc, SLOT(undoRedoDone()));
5808 cbradney 1963
                connect(undoManager, SIGNAL(undoRedoDone()), tempView, SLOT(DrawNew()));
1964
                //connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
13165 fschmid 1965
                connect(tempView, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
5808 cbradney 1966
                //      connect(w, SIGNAL(SaveAndClose()), this, SLOT(DoSaveClose()));
1967
        }
1968
        //Independent finishing tasks after tempDoc setup
5800 fschmid 1969
        if (showView)
1970
        {
13959 jghali 1971
                if ( mdiArea->subWindowList().count() == 1)
5800 fschmid 1972
                        w->showMaximized();
1973
                else
1974
                        w