Subversion Repositories Scribus

Rev

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

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