Subversion Repositories Scribus

Rev

Rev 25070 | Rev 25154 | 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>
24844 jghali 31
#include <QDomDocument>
18198 fschmid 32
#include <QDrag>
10862 cbradney 33
#include <QDragEnterEvent>
8501 cbradney 34
#include <QDropEvent>
35
#include <QEvent>
10862 cbradney 36
#include <QEventLoop>
15130 cbradney 37
#include <QFileDialog>
10862 cbradney 38
#include <QFrame>
16546 jghali 39
#include <QFont>
21752 jghali 40
#include <QHBoxLayout>
10862 cbradney 41
#include <QIcon>
42
#include <QInputDialog>
8501 cbradney 43
#include <QKeyEvent>
10862 cbradney 44
#include <QKeySequence>
45
#include <QLabel>
46
#include <QList>
47
#include <QLocale>
16546 jghali 48
#include <QMdiArea>
49
#include <QMdiSubWindow>
50
#include <QMessageBox>
10862 cbradney 51
#include <QMouseEvent>
22201 jghali 52
#include <QMultiMap>
10862 cbradney 53
#include <QPixmap>
16546 jghali 54
#include <QProgressBar>
19093 craig 55
#include <QPushButton>
18803 jghali 56
#include <QScopedPointer>
23568 craig 57
#include <QScreen>
10862 cbradney 58
#include <QStyleFactory>
9853 fschmid 59
#include <QTableWidget>
10862 cbradney 60
#include <QTextCodec>
61
#include <QTranslator>
23568 craig 62
#include <QWindow>
10862 cbradney 63
#include <QWheelEvent>
1208 cbradney 64
 
14539 jghali 65
#ifdef DEBUG_LOAD_TIMES
66
#include <QDebug>
67
#include <QTime>
68
#include <sys/times.h>
69
#endif
70
 
3 paul 71
#include <cstdio>
72
#include <cstdlib>
9082 avox 73
#include <cassert>
2629 craig 74
 
2688 craig 75
#include "scconfig.h"
2629 craig 76
 
77
#ifdef HAVE_DLFCN_H
3 paul 78
#include <dlfcn.h>
2629 craig 79
#endif
80
 
81
#ifdef HAVE_UNISTD_H
135 Franz 82
#include <unistd.h>
2629 craig 83
#endif
84
 
25058 jghali 85
#include <array>
3 paul 86
#include <iostream>
8289 avox 87
#include <sstream>
22652 craig 88
#include <csignal>
80 Franz 89
#include <string>
1208 cbradney 90
 
16546 jghali 91
#include "actionmanager.h"
23088 jghali 92
#include "actionsearch.h"
24486 craig 93
#include "api/api_application.h"
19499 craig 94
#include "appmodehelper.h"
19067 craig 95
#include "appmodes.h"
16546 jghali 96
#include "canvasmode.h"
17735 craig 97
#include "canvasmode_imageimport.h"
16546 jghali 98
#include "commonstrings.h"
99
#include "desaxe/digester.h"
100
#include "desaxe/saxXML.h"
101
#include "desaxe/simple_actions.h"
102
#include "documentchecker.h"
103
#include "documentinformation.h"
104
#include "fileloader.h"
105
#include "filewatcher.h"
106
#include "fpoint.h"
107
#include "fpointarray.h"
108
#include "gtgettext.h"
109
#include "hyphenator.h"
20185 craig 110
#include "iconmanager.h"
16546 jghali 111
#include "langmgr.h"
23607 craig 112
#include "localemgr.h"
19093 craig 113
#include "loadsaveplugin.h"
17826 craig 114
#include "marks.h"
19093 craig 115
#include "nfttemplate.h"
17826 craig 116
#include "notesstyles.h"
16916 fschmid 117
#include "pageitem_group.h"
16546 jghali 118
#include "pageitem_imageframe.h"
119
#include "pageitem_latexframe.h"
19093 craig 120
#include "pageitem_noteframe.h"
16856 craig 121
#include "pageitem_table.h"
16546 jghali 122
#include "pageitem_textframe.h"
123
#include "pagesize.h"
124
#include "pdflib.h"
125
#include "pdfoptions.h"
126
#include "pluginmanager.h"
127
#include "plugins/formatidlist.h"
19093 craig 128
#include "plugins/formatidlist.h"
16546 jghali 129
#include "prefscontext.h"
130
#include "prefsfile.h"
131
#include "prefsmanager.h"
132
#include "prefstable.h"
133
#include "pslib.h"
134
#include "resourcecollection.h"
135
#include "sccolorengine.h"
136
#include "scgtplugin.h"
19093 craig 137
#include "scimagecachemanager.h"
16546 jghali 138
#include "scmimedata.h"
16736 jghali 139
#include "scpage.h"
16546 jghali 140
#include "scpaths.h"
24049 jghali 141
#include "scprintengine_pdf.h"
16546 jghali 142
#include "scprintengine_ps.h"
143
#include "scraction.h"
144
#include "scribusXml.h"
145
#include "scribusapp.h"
146
#include "scribuscore.h"
19093 craig 147
#include "scribusdoc.h"
16546 jghali 148
#include "scribusview.h"
149
#include "scribuswin.h"
150
#include "selection.h"
151
#include "serializer.h"
24265 jghali 152
#include "storyloader.h"
19093 craig 153
#include "styleoptions.h"
24684 jghali 154
#include "textnote.h"
19093 craig 155
#include "tocgenerator.h"
13552 cbradney 156
#include "ui/about.h"
13544 cbradney 157
#include "ui/aboutplugins.h"
23088 jghali 158
#include "ui/actionsearchdialog.h"
13544 cbradney 159
#include "ui/aligndistribute.h"
13650 cbradney 160
#include "ui/annot.h"
161
#include "ui/annota.h"
13552 cbradney 162
#include "ui/applytemplatedialog.h"
13576 cbradney 163
#include "ui/arrowchooser.h"
13650 cbradney 164
#include "ui/autoform.h"
13576 cbradney 165
#include "ui/basepointwidget.h"
13551 cbradney 166
#include "ui/bookmarkpalette.h"
13544 cbradney 167
#include "ui/charselect.h"
13650 cbradney 168
#include "ui/checkDocument.h"
14798 cbradney 169
#include "ui/collectforoutput_ui.h"
13650 cbradney 170
#include "ui/colorcombo.h"
23284 jghali 171
#include "ui/contentpalette.h"
13576 cbradney 172
#include "ui/contextmenu.h"
19093 craig 173
#include "ui/copypagetomasterpagedialog.h"
13551 cbradney 174
#include "ui/cpalette.h"
13552 cbradney 175
#include "ui/customfdialog.h"
13650 cbradney 176
#include "ui/delpages.h"
19783 craig 177
#include "ui/downloadspalette.h"
19093 craig 178
#include "ui/edittoolbar.h"
13552 cbradney 179
#include "ui/effectsdialog.h"
19093 craig 180
#include "ui/filetoolbar.h"
13650 cbradney 181
#include "ui/fontcombo.h"
13544 cbradney 182
#include "ui/guidemanager.h"
13576 cbradney 183
#include "ui/helpbrowser.h"
184
#include "ui/hruler.h"
13552 cbradney 185
#include "ui/imageinfodialog.h"
17405 fschmid 186
#include "ui/inlinepalette.h"
13544 cbradney 187
#include "ui/insertaframe.h"
13650 cbradney 188
#include "ui/inspage.h"
189
#include "ui/javadocs.h"
13576 cbradney 190
#include "ui/layers.h"
13650 cbradney 191
#include "ui/loremipsum.h"
192
#include "ui/marginwidget.h"
17826 craig 193
#include "ui/mark2item.h"
194
#include "ui/mark2mark.h"
195
#include "ui/markanchor.h"
19093 craig 196
#include "ui/markinsert.h"
17826 craig 197
#include "ui/marknote.h"
19093 craig 198
#include "ui/marksmanager.h"
17826 craig 199
#include "ui/markvariabletext.h"
13650 cbradney 200
#include "ui/mergedoc.h"
19093 craig 201
#include "ui/modetoolbar.h"
13650 cbradney 202
#include "ui/movepage.h"
13544 cbradney 203
#include "ui/multipleduplicate.h"
23361 jghali 204
#include "ui/newdocdialog.h"
13650 cbradney 205
#include "ui/newtemp.h"
13544 cbradney 206
#include "ui/nftdialog.h"
207
#include "ui/nftwidget.h"
13551 cbradney 208
#include "ui/nodeeditpalette.h"
17826 craig 209
#include "ui/notesstyleseditor.h"
13551 cbradney 210
#include "ui/outlinepalette.h"
23829 jghali 211
#include "ui/outputpreview_pdf.h"
23845 jghali 212
#include "ui/outputpreview_ps.h"
13544 cbradney 213
#include "ui/pageitemattributes.h"
13650 cbradney 214
#include "ui/pagelayout.h"
13551 cbradney 215
#include "ui/pagepalette.h"
21903 jghali 216
#include "ui/pagepropertiesdialog.h"
13576 cbradney 217
#include "ui/pageselector.h"
21926 craig 218
#include "ui/colorsandfills.h"
19966 craig 219
#include "ui/pdfexportdialog.h"
19093 craig 220
#include "ui/pdftoolbar.h"
13544 cbradney 221
#include "ui/picstatus.h"
222
#include "ui/polygonwidget.h"
13761 cbradney 223
#include "ui/preferencesdialog.h"
13544 cbradney 224
#include "ui/printdialog.h"
23791 jghali 225
#include "ui/printpreview.h"
13551 cbradney 226
#include "ui/propertiespalette.h"
16546 jghali 227
#include "ui/propertiespalette_line.h"
228
#include "ui/propertiespalette_shape.h"
229
#include "ui/propertiespalette_xyz.h"
13650 cbradney 230
#include "ui/query.h"
21098 fschmid 231
#include "ui/recoverdialog.h"
13544 cbradney 232
#include "ui/replacecolors.h"
19821 craig 233
#include "ui/resourcemanager.h"
17735 craig 234
#include "ui/scfilewidget.h"
13576 cbradney 235
#include "ui/scmessagebox.h"
19093 craig 236
#include "ui/scmwmenumanager.h"
13551 cbradney 237
#include "ui/scrapbookpalette.h"
19093 craig 238
#include "ui/scrspinbox.h"
239
#include "ui/search.h"
16546 jghali 240
#include "ui/selectobjects.h"
16856 craig 241
#include "ui/smcellstyle.h"
13544 cbradney 242
#include "ui/smlinestyle.h"
16856 craig 243
#include "ui/smtablestyle.h"
13544 cbradney 244
#include "ui/smtextstyles.h"
13551 cbradney 245
#include "ui/splash.h"
13576 cbradney 246
#include "ui/storyeditor.h"
13544 cbradney 247
#include "ui/stylemanager.h"
15060 fschmid 248
#include "ui/symbolpalette.h"
13544 cbradney 249
#include "ui/tabmanager.h"
15309 cbradney 250
#include "ui/transformdialog.h"
16034 fschmid 251
#include "ui/transparencypalette.h"
19009 craig 252
#include "ui/viewtoolbar.h"
19093 craig 253
#include "ui/vruler.h"
254
#include "ui_nftdialog.h"
10212 cbradney 255
#include "undogui.h"
256
#include "undomanager.h"
257
#include "undostate.h"
258
#include "units.h"
10311 cbradney 259
#include "urllauncher.h"
23169 jghali 260
#include "usertaskstructs.h"
5184 avox 261
#include "util.h"
19917 fschmid 262
#include "util_file.h"
10212 cbradney 263
#include "util_formats.h"
264
#include "util_ghostscript.h"
14170 jghali 265
#include "util_math.h"
134 Franz 266
 
21553 craig 267
#ifdef HAVE_SVNVERSION
268
        #include "svnversion.h"
269
#endif
19093 craig 270
 
271
#ifdef HAVE_OSG
272
        #include "ui/osgeditor.h"
273
        #include <osgDB/ReaderWriter>
274
        #include <osgDB/PluginQuery>
275
#endif
276
 
4361 cbradney 277
#if defined(_WIN32)
5178 mrdocs 278
#include "scdocoutput_ps2.h"
10967 jghali 279
#include "scprintengine_gdi.h"
4361 cbradney 280
#endif
281
 
15023 jghali 282
#include "sclimits.h"
283
 
3 paul 284
using namespace std;
285
 
3234 fschmid 286
bool previewDinUse;
287
bool printDinUse;
2891 cbradney 288
 
3 paul 289
QString DocDir;
3205 craig 290
 
10532 avox 291
 
22639 craig 292
//extern ScribusQApp* ScQApp;
2634 cbradney 293
extern bool emergencyActivated;
3 paul 294
 
10532 avox 295
 
23060 craig 296
ScribusMainWindow::ScribusMainWindow() :
297
        m_prefsManager(PrefsManager::instance())
2161 cbradney 298
{
18204 fschmid 299
#ifdef Q_OS_MAC
19839 craig 300
        //commenting this out until this is resolved :https://bugreports.qt.io/browse/QTBUG-44565
301
        //ScQApp->setAttribute(Qt::AA_DontShowIconsInMenus);
23054 craig 302
        //noIcon = IconManager::instance().loadPixmap("noicon.png");
3580 avox 303
#endif
10625 cbradney 304
}
188 Franz 305
 
11158 avox 306
/*
767 cbradney 307
 * retval 0 - ok, 1 - no fonts, ...
308
 */
5243 cbradney 309
int ScribusMainWindow::initScMW(bool primaryMainWindow)
188 Franz 310
{
767 cbradney 311
        int retVal=0;
24857 jghali 312
        //qsrand(1234);
9909 avox 313
        QByteArray stylesheet;
21526 craig 314
        if (loadRawText(ScPaths::preferencesDir() + "/stylesheet.css", stylesheet))
9909 avox 315
        {
316
                qApp->setStyleSheet(QString(stylesheet));
317
        }
10953 subik 318
 
25058 jghali 319
        QApplication::setLayoutDirection(QLocale(ScCore->getGuiLanguage()).textDirection());
3234 fschmid 320
        previewDinUse = false;
321
        printDinUse = false;
9721 fschmid 322
        internalCopy = false;
23943 jghali 323
        internalCopyBuffer.clear();
16016 fschmid 324
        m_doc = new ScribusDoc();
325
        m_doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
326
        m_doc->setPage(100, 100, 0, 0, 0, 0, 0, 0, false, false);
327
        m_doc->addPage(0);
22561 craig 328
        m_doc->setGUI(false, this, nullptr);
22516 craig 329
        CurrStED = nullptr;
24486 craig 330
        QString scribusTitle(ScribusAPI::getVersionScribusTranslated());
24490 jghali 331
        if (ScribusAPI::isSVN() && ScribusAPI::haveSVNRevision())
24486 craig 332
                scribusTitle.append(QString(" (r%1)").arg(ScribusAPI::getSVNRevision()));
21553 craig 333
        setWindowTitle(scribusTitle);
10564 fschmid 334
        setAttribute(Qt::WA_KeyCompression, false);
16546 jghali 335
        setAttribute(Qt::WA_InputMethodEnabled, true);
23054 craig 336
        setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
16612 fschmid 337
        setObjectName("MainWindow");
1325 cbradney 338
        scrActionGroups.clear();
1208 cbradney 339
        scrActions.clear();
340
        scrRecentFileActions.clear();
5800 fschmid 341
        scrRecentPasteActions.clear();
1260 cbradney 342
        scrWindowsActions.clear();
2408 cbradney 343
        scrLayersActions.clear();
15516 fschmid 344
        scrScrapActions.clear();
18533 craig 345
        actionManager = new ActionManager(this);
19495 craig 346
        appModeHelper = new AppModeHelper();
19509 craig 347
        appModeHelper->setup(actionManager, &scrActions, &scrRecentFileActions, &scrWindowsActions, &scrScrapActions, &scrLayersActions, &scrRecentPasteActions);
18533 craig 348
        scrMenuMgr = new ScMWMenuManager(menuBar(), actionManager);
20691 craig 349
        m_formatsManager = FormatsManager::instance();
350
        m_objectSpecificUndo = false;
7087 subik 351
 
20691 craig 352
        m_undoManager = UndoManager::instance();
23060 craig 353
        PrefsContext *undoPrefs = m_prefsManager.prefsFile->getContext("undo");
20691 craig 354
        m_undoManager->setUndoEnabled(undoPrefs->getBool("enabled", true));
355
        m_tocGenerator = new TOCGenerator();
17826 craig 356
        m_marksCount = 0;
4510 subik 357
 
1780 cbradney 358
        initDefaultValues();
272 Franz 359
        initStatusBar();
7087 subik 360
 
25058 jghali 361
        QApplication::processEvents();
675 cbradney 362
 
22076 jghali 363
        actionManager->init(this);
18533 craig 364
 
22076 jghali 365
        initMdiArea();
11174 fschmid 366
        initMenuBar();
18548 craig 367
        createMenuBar();
11174 fschmid 368
        initToolBars();
18438 craig 369
        ScCore->pluginManager->setupPluginActions(this);
14509 cbradney 370
        ScCore->pluginManager->enableOnlyStartupPluginActions(this);
18438 craig 371
        ScCore->pluginManager->languageChange();
18548 craig 372
 
10977 cbradney 373
        if (primaryMainWindow)
374
                ScCore->setSplashStatus( tr("Applying User Shortcuts") );
23060 craig 375
        m_prefsManager.applyLoadedShortCuts();
10977 cbradney 376
        initKeyboardShortcuts();
11960 subik 377
 
5243 cbradney 378
        resize(610, 600);
22607 craig 379
        connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(newActWin(QMdiSubWindow*)));
13959 jghali 380
        //Connect windows cascade and tile actions to the workspace after its created. Only depends on mdiArea created.
381
        connect( scrActions["windowsCascade"], SIGNAL(triggered()) , mdiArea, SLOT(cascadeSubWindows()) );
382
        connect( scrActions["windowsTile"], SIGNAL(triggered()) , mdiArea, SLOT(tileSubWindows()) );
5243 cbradney 383
        initPalettes();
7087 subik 384
 
770 cbradney 385
 
23060 craig 386
        viewToolBar->previewQualitySwitcher->setCurrentIndex(m_prefsManager.appPrefs.itemToolPrefs.imageLowResType);
5243 cbradney 387
        if (primaryMainWindow)
388
                ScCore->setSplashStatus( tr("Initializing Story Editor") );
389
        storyEditor = new StoryEditor(this);
770 cbradney 390
 
23060 craig 391
        DocDir = m_prefsManager.documentDir();
1485 tsoots 392
 
5243 cbradney 393
        if (primaryMainWindow)
17798 craig 394
                ScCore->setSplashStatus( tr("Initializing Languages") );
395
        LanguageManager::instance();
396
 
5800 fschmid 397
        initHyphenator();
23060 craig 398
//      QString preLang(m_prefsManager.appPrefs.hyphPrefs.Language);
21563 jghali 399
//      if (!LanguageManager::instance()->getHyphFilename( preLang ).isEmpty() )
23060 craig 400
//              m_prefsManager.appPrefs.hyphPrefs.Language = preLang;
5800 fschmid 401
        if (primaryMainWindow)
402
                ScCore->setSplashStatus( tr("Reading Scrapbook") );
403
        initScrapbook();
404
 
23060 craig 405
        scrActions["helpTooltips"]->setChecked(m_prefsManager.appPrefs.displayPrefs.showToolTips);
406
        scrActions["showMouseCoordinates"]->setChecked(m_prefsManager.appPrefs.displayPrefs.showMouseCoordinates);
407
        scrActions["stickyTools"]->setChecked(m_prefsManager.appPrefs.uiPrefs.stickyTools);
5800 fschmid 408
        ToggleTips();
12754 fschmid 409
        ToggleMouseTips();
5800 fschmid 410
        propertiesPalette->setFontSize();
23282 craig 411
        contentPalette->setFontSize();
6451 fschmid 412
        if (scrActions["SaveAsDocumentTemplate"])
413
                scrActions["SaveAsDocumentTemplate"]->setEnabled(false);
7087 subik 414
 
23474 jghali 415
        connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()));
23607 craig 416
        connect(ScQApp, SIGNAL(localeChanged()), this, SLOT(localeChange()));
22561 craig 417
        connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString)), this, SLOT(removeRecentFromWatcher(QString)));
5800 fschmid 418
        connect(ClipB, SIGNAL(dataChanged()), this, SLOT(ClipChange()));
419
        setAcceptDrops(true);
9562 fschmid 420
        QCoreApplication::instance()->installEventFilter(this);
12846 fschmid 421
        scrActions["toolsSelect"]->setChecked(true);
23474 jghali 422
 
16016 fschmid 423
        ColorSetManager csm;
424
        csm.findPaletteLocations();
425
        csm.findPalettes();
426
        csm.findUserPalettes();
21526 craig 427
        QString Cpfad = QDir::toNativeSeparators(ScPaths::applicationDataDir())+"DefaultColors.xml";
16016 fschmid 428
        QFile fc(Cpfad);
429
        if (fc.exists())
23060 craig 430
                csm.loadPalette(Cpfad, m_doc, m_prefsManager.appPrefs.colorPrefs.DColors, m_prefsManager.appPrefs.defaultGradients, m_prefsManager.appPrefs.defaultPatterns, false);
16016 fschmid 431
        else
432
        {
23060 craig 433
                if (m_prefsManager.appPrefs.colorPrefs.DColorSet != "Scribus Small")
16016 fschmid 434
                {
435
                        QStringList CustomColorSets = csm.userPaletteNames();
23060 craig 436
                        if (CustomColorSets.contains(m_prefsManager.appPrefs.colorPrefs.DColorSet))
437
                                Cpfad = csm.userPaletteFileFromName(m_prefsManager.appPrefs.colorPrefs.DColorSet);
16016 fschmid 438
                        else
23060 craig 439
                                Cpfad = csm.paletteFileFromName(m_prefsManager.appPrefs.colorPrefs.DColorSet);
18562 jghali 440
                        if (!Cpfad.isEmpty())
23060 craig 441
                                csm.loadPalette(Cpfad, m_doc, m_prefsManager.appPrefs.colorPrefs.DColors, m_prefsManager.appPrefs.defaultGradients, m_prefsManager.appPrefs.defaultPatterns, false);
16016 fschmid 442
                }
443
        }
19509 craig 444
        appModeHelper->setStartupActionsEnabled(false);
18556 craig 445
 
20196 craig 446
        setStyleSheet();
447
 
5800 fschmid 448
        return retVal;
449
}
450
 
23568 craig 451
void ScribusMainWindow::setupMainWindow()
452
{
453
        setDefaultPrinter(m_prefsManager.appPrefs.printerPrefs.PrinterName, m_prefsManager.appPrefs.printerPrefs.PrinterFile, m_prefsManager.appPrefs.printerPrefs.PrinterCommand);
10532 avox 454
 
23568 craig 455
        uint max = qMin(m_prefsManager.appPrefs.uiPrefs.recentDocCount, m_prefsManager.appPrefs.uiPrefs.RecentDocs.count());
456
        for (uint m = 0; m < max; ++m)
457
        {
458
                QFileInfo fd(m_prefsManager.appPrefs.uiPrefs.RecentDocs[m]);
459
                if (fd.exists())
460
                {
461
                        m_recentDocsList.append(m_prefsManager.appPrefs.uiPrefs.RecentDocs[m]);
462
                        //#9845: ScCore->fileWatcher->addFile(appPrefs.uiPrefs.RecentDocs[m]);
463
                }
464
        }
465
        rebuildRecentFileMenu();
466
        //For 1.3.5, we dump prefs first time around.
467
        if (!m_prefsManager.firstTimeIgnoreOldPrefs())
24226 jghali 468
                m_prefsManager.readPrefsXML();
23568 craig 469
        if (m_prefsManager.appPrefs.verifierPrefs.checkerPrefsList.count() == 0)
470
        {
471
                m_prefsManager.initDefaultCheckerPrefs(m_prefsManager.appPrefs.verifierPrefs.checkerPrefsList);
472
                m_prefsManager.appPrefs.verifierPrefs.curCheckProfile = CommonStrings::PDF_1_4;
473
        }
474
 
23574 jghali 475
        const WindowPrefs& mainWinSettings = m_prefsManager.appPrefs.uiPrefs.mainWinSettings;
23590 jghali 476
        QWindow* w = windowHandle();
23568 craig 477
        QList<QScreen*> screens = QGuiApplication::screens();
23574 jghali 478
        QScreen* s = nullptr;
23568 craig 479
        if (w != nullptr)
480
        {
23574 jghali 481
                s = screens.at(qMin(mainWinSettings.screenNumber, QGuiApplication::screens().count() - 1));
23568 craig 482
                windowHandle()->setScreen(s);
483
        }
484
        else
23574 jghali 485
                s = QGuiApplication::primaryScreen();
486
        QRect r(0, 0, 0, 0);
487
        if (s != nullptr)
488
                r = s->geometry();
489
        move(r.left() + abs(mainWinSettings.xPosition), r.top() + abs(mainWinSettings.yPosition));
490
        resize(mainWinSettings.width, mainWinSettings.height);
23569 craig 491
 
23590 jghali 492
        if (mainWinSettings.maximized)
24155 jghali 493
                this->setWindowState((this->windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) | Qt::WindowMaximized);
23590 jghali 494
 
23569 craig 495
        if (!m_prefsManager.appPrefs.uiPrefs.mainWinState.isEmpty())
496
                restoreState(m_prefsManager.appPrefs.uiPrefs.mainWinState);
23568 craig 497
}
498
 
23577 craig 499
int ScribusMainWindow::getScreenNumber() const
23568 craig 500
{
501
        QList<QScreen*> screens = QGuiApplication::screens();
23577 craig 502
        int screenNumber = -1;
23568 craig 503
        QScreen* s = ScCore->primaryMainWindow()->screen();
504
        screenNumber = screens.indexOf(s);
23575 jghali 505
        if (screenNumber < 0)
506
                screenNumber = screens.indexOf(QGuiApplication::primaryScreen());
507
        if (screenNumber < 0)
508
                screenNumber = 0;
23577 craig 509
        return screenNumber;
510
}
511
 
512
QScreen* ScribusMainWindow::getScreen() const
513
{
514
        QList<QScreen*> screens = QGuiApplication::screens();
515
        return screens.at(getScreenNumber());
516
}
517
 
518
void ScribusMainWindow::getScreenPosition(int& xPos, int& yPos) const
519
{
520
        QScreen* screen(getScreen());
521
        QRect screenGeom = screen->geometry();
23574 jghali 522
        xPos = screenGeom.left();
523
        yPos = screenGeom.top();
23568 craig 524
}
525
 
23577 craig 526
void ScribusMainWindow::getScreenDPI(int& dpiX, int& dpiY) const
527
{
528
        QScreen* screen(getScreen());
529
        dpiX = screen->physicalDotsPerInchX();
530
        dpiY = screen->physicalDotsPerInchY();
531
}
23568 craig 532
 
5800 fschmid 533
ScribusMainWindow::~ScribusMainWindow()
534
{
22607 craig 535
        delete actionManager;
536
        delete appModeHelper;
537
        delete m_doc;
538
        delete m_tocGenerator;
5800 fschmid 539
}
540
 
22635 craig 541
void ScribusMainWindow::addScToolBar(ScToolBar *tb, const QString & name)
11040 fschmid 542
{
543
        if (!scrToolBars.contains(name))
544
                scrToolBars.insert(name, tb);
545
        addToolBar(tb);
546
}
5800 fschmid 547
 
548
void ScribusMainWindow::initToolBars()
549
{
10976 cbradney 550
        fileToolBar = new FileToolBar(this);
551
        editToolBar = new EditToolBar(this);
5800 fschmid 552
        UndoWidget* uWidget = new UndoWidget(editToolBar, "uWidget");
20691 craig 553
        m_undoManager->registerGui(uWidget);
10976 cbradney 554
        modeToolBar = new ModeToolBar(this);
5800 fschmid 555
        pdfToolBar = new PDFToolBar(this);
19009 craig 556
        viewToolBar = new ViewToolBar(this);
10953 subik 557
 
15260 cbradney 558
        addScToolBar(fileToolBar, fileToolBar->objectName());
559
        addScToolBar(editToolBar, editToolBar->objectName());
560
        addScToolBar(modeToolBar, modeToolBar->objectName());
561
        addScToolBar(pdfToolBar, pdfToolBar->objectName());
19009 craig 562
        addScToolBar(viewToolBar, viewToolBar->objectName());
10976 cbradney 563
        connect(modeToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarTools"], SLOT(setChecked(bool)));
10734 jghali 564
        connect(scrActions["toolsToolbarPDF"], SIGNAL(toggled(bool)), pdfToolBar, SLOT(setVisible(bool)));
10969 subik 565
        connect(pdfToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarPDF"], SLOT(setChecked(bool)));
10976 cbradney 566
        connect(scrActions["toolsToolbarTools"], SIGNAL(toggled(bool)), modeToolBar, SLOT(setVisible(bool)) );
19009 craig 567
        connect(viewToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarView"], SLOT(setChecked(bool)));
568
        connect(scrActions["toolsToolbarView"], SIGNAL(toggled(bool)), viewToolBar, SLOT(setVisible(bool)) );
5800 fschmid 569
}
570
 
20196 craig 571
void ScribusMainWindow::setStyleSheet()
572
{
573
        QByteArray stylesheet;
574
        if (loadRawText(ScPaths::instance().libDir() + "scribus.css", stylesheet))
575
        {
23054 craig 576
                QString downArrow(IconManager::instance().pathForIcon("16/go-down.png"));
20196 craig 577
                QByteArray da;
24148 craig 578
                da.append(downArrow.toUtf8());
20196 craig 579
                stylesheet.replace("___downArrow___", da);
23054 craig 580
                QString toolbararrow(IconManager::instance().pathForIcon("stylesheet/down_arrow.png"));
20196 craig 581
                QByteArray tba;
24148 craig 582
                tba.append(toolbararrow.toUtf8());
20196 craig 583
                stylesheet.replace("___tb_menu_arrow___", tba);
584
        }
10532 avox 585
 
20196 craig 586
        layerMenu->setStyleSheet(stylesheet);
587
        unitSwitcher->setStyleSheet(stylesheet);
588
        zoomDefaultToolbarButton->setStyleSheet(stylesheet);
589
        zoomInToolbarButton->setStyleSheet(stylesheet);
590
        zoomOutToolbarButton->setStyleSheet(stylesheet);
591
        zoomSpinBox->setStyleSheet(stylesheet);
592
 
593
        fileToolBar->setStyleSheet(stylesheet);
594
        editToolBar->setStyleSheet(stylesheet);
595
        modeToolBar->setStyleSheet(stylesheet);
596
        pdfToolBar->setStyleSheet(stylesheet);
597
        viewToolBar->setStyleSheet(stylesheet);
598
}
599
 
600
 
5800 fschmid 601
void ScribusMainWindow::initDefaultValues()
602
{
603
        HaveDoc = false;
22516 craig 604
        view = nullptr;
605
        doc = nullptr;
20691 craig 606
        m_DocNr = 1;
607
        m_PrinterUsed = false;
23943 jghali 608
        PDef.Pname.clear();
609
        PDef.Dname.clear();
610
        PDef.Command.clear();
24003 jghali 611
        //m_keyrep = false;
612
        //m_arrowKeyDown = false;
5800 fschmid 613
        ClipB = QApplication::clipboard();
24715 jghali 614
        for (int i = 0; i < PAL_MAX ; ++i)
20691 craig 615
                m_palettesStatus[i] = false;
24715 jghali 616
        for (int i = 0; i < GS_MAX ; ++i)
20691 craig 617
                m_guidesStatus[i] = false;
17781 fschmid 618
#ifdef HAVE_OSG
18207 fschmid 619
        QStringList supportedExts;
620
        supportedExts << "osg" << "dxf" << "flt" << "ive" << "geo" << "sta" << "stl" << "logo" << "3ds" << "ac" << "obj";
621
        QStringList realSupportedExts;
622
        QMap<QString, QString> formats;
623
        osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
22723 jghali 624
        for (osgDB::FileNameList::iterator itr = plugins.begin(); itr != plugins.end(); ++itr)
18207 fschmid 625
        {
626
                osgDB::ReaderWriterInfoList infoList;
627
                if (QString::fromStdString(*itr).contains("qfont"))
628
                        continue;
629
                if (osgDB::queryPlugin(*itr, infoList))
17781 fschmid 630
                {
22509 jghali 631
                        for (auto rwi_itr = infoList.begin(); rwi_itr != infoList.end(); ++rwi_itr)
17781 fschmid 632
                        {
18207 fschmid 633
                                osgDB::ReaderWriterInfo& info = *(*rwi_itr);
634
                                osgDB::ReaderWriter::FormatDescriptionMap::iterator fdm_itr;
22723 jghali 635
                                for (fdm_itr = info.extensions.begin(); fdm_itr != info.extensions.end(); ++fdm_itr)
17781 fschmid 636
                                {
18207 fschmid 637
                                        if (supportedExts.contains(QString::fromStdString(fdm_itr->first)))
638
                                                formats.insert("*." + QString::fromStdString(fdm_itr->first) + " *." + QString::fromStdString(fdm_itr->first).toUpper(), QString::fromStdString(fdm_itr->second) + " (*." + QString::fromStdString(fdm_itr->first) + " *." + QString::fromStdString(fdm_itr->first).toUpper() + ")");
17781 fschmid 639
                                }
640
                        }
641
                }
18207 fschmid 642
        }
643
        realSupportedExts = formats.keys();
644
        QString docexts = realSupportedExts.join(" ");
645
        QStringList longList = formats.values();
646
        QString longDesc = longList.join(";;") + ";;";
20695 craig 647
        m_osgFilterString = tr("All Supported Formats (%1);;%2All Files (*)").arg(docexts).arg(longDesc);
17781 fschmid 648
#endif
5800 fschmid 649
}
650
 
10532 avox 651
 
5800 fschmid 652
void ScribusMainWindow::initKeyboardShortcuts()
653
{
22723 jghali 654
        for (auto it = scrActions.begin(); it!=scrActions.end(); ++it )
5800 fschmid 655
        {
22723 jghali 656
                if ((ScrAction*)(it.value()) != nullptr)
5800 fschmid 657
                {
18194 fschmid 658
                        QString accelerator = it.value()->shortcut().toString();
23060 craig 659
                        m_prefsManager.setKeyEntry(it.key(), it.value()->cleanMenuText(), accelerator,0);
5800 fschmid 660
                }
661
                //else
13085 jghali 662
                //      qDebug() << it.key();
663
                //qDebug() << QString("|-\n|%1||%2||%3").arg(it.key()).arg(it.value()->cleanMenuText()).arg(QString(it.data()->accel()));
5800 fschmid 664
        }
665
}
666
 
10532 avox 667
 
5800 fschmid 668
void ScribusMainWindow::initPalettes()
669
{
670
        //CB TODO hide the publicly available members of some palettes
671
        // these must be filtered too as they take control of the palettes events
10862 cbradney 672
        outlinePalette = new OutlinePalette(this);
5800 fschmid 673
        outlinePalette->setMainWindow(this);
22607 craig 674
        connect( scrActions["toolsOutline"], SIGNAL(toggled(bool)) , outlinePalette, SLOT(setPaletteShown(bool)));
10581 cbradney 675
        connect( outlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsOutline"], SLOT(setChecked(bool)));
16546 jghali 676
 
10862 cbradney 677
        propertiesPalette = new PropertiesPalette(this);
5800 fschmid 678
        propertiesPalette->setMainWindow(this);
22607 craig 679
        connect( scrActions["toolsProperties"], SIGNAL(toggled(bool)) , propertiesPalette, SLOT(setPaletteShown(bool)));
10581 cbradney 680
        connect( propertiesPalette, SIGNAL(paletteShown(bool)), scrActions["toolsProperties"], SLOT(setChecked(bool)));
16546 jghali 681
        emit UpdateRequest(reqDefFontListUpdate);
5800 fschmid 682
        propertiesPalette->installEventFilter(this);
21575 craig 683
 
23282 craig 684
        contentPalette = new ContentPalette(this);
685
        contentPalette->setMainWindow(this);
686
        connect( scrActions["toolsContent"], &QAction::toggled, contentPalette, &ContentPalette::setPaletteShown);
687
        connect( contentPalette, &ContentPalette::paletteShown, scrActions["toolsContent"], &QAction::setChecked);
688
        contentPalette->installEventFilter(this);
689
 
5800 fschmid 690
        nodePalette = new NodePalette(this);
691
        nodePalette->installEventFilter(this);
692
        layerPalette = new LayerPalette(this);
693
        guidePalette = new GuideManager(this);
7087 subik 694
        charPalette = new CharSelect(this);
22607 craig 695
        connect( scrActions["toolsLayers"], SIGNAL(toggled(bool)) , layerPalette, SLOT(setPaletteShown(bool)));
10581 cbradney 696
        connect( layerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsLayers"], SLOT(setChecked(bool)));
5800 fschmid 697
        layerPalette->installEventFilter(this);
698
        scrapbookPalette = new Biblio(this);
22607 craig 699
        connect( scrActions["toolsScrapbook"], SIGNAL(toggled(bool)) , scrapbookPalette, SLOT(setPaletteShown(bool)));
10581 cbradney 700
        connect( scrapbookPalette, SIGNAL(paletteShown(bool)), scrActions["toolsScrapbook"], SLOT(setChecked(bool)));
11554 fschmid 701
        connect( scrapbookPalette, SIGNAL(pasteToActualPage(QString)), this, SLOT(pasteFromScrapbook(QString)));
18924 craig 702
        connect( scrapbookPalette, SIGNAL(scrapbookListChanged()), this, SLOT(rebuildScrapbookMenu()));
5800 fschmid 703
        scrapbookPalette->installEventFilter(this);
704
        pagePalette = new PagePalette(this);
705
        connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , pagePalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 706
        connect( pagePalette, SIGNAL(paletteShown(bool)), scrActions["toolsPages"], SLOT(setChecked(bool)));
5800 fschmid 707
        pagePalette->installEventFilter(this);
708
        bookmarkPalette = new BookPalette(this);
709
        connect( scrActions["toolsBookmarks"], SIGNAL(toggled(bool)) , bookmarkPalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 710
        connect( bookmarkPalette, SIGNAL(paletteShown(bool)), scrActions["toolsBookmarks"], SLOT(setChecked(bool)));
5800 fschmid 711
        bookmarkPalette->installEventFilter(this);
19783 craig 712
        downloadsPalette = new DownloadsPalette(this);
713
        connect( scrActions["toolsDownloads"], SIGNAL(toggled(bool)) , downloadsPalette, SLOT(setPaletteShown(bool)) );
714
        connect( downloadsPalette, SIGNAL(paletteShown(bool)), scrActions["toolsDownloads"], SLOT(setChecked(bool)));
715
        downloadsPalette->installEventFilter(this);
22607 craig 716
        connect( scrActions["toolsMeasurements"], SIGNAL(toggledData(bool,int)) , this, SLOT(setAppModeByToggle(bool,int)) );
5800 fschmid 717
        docCheckerPalette = new CheckDocument(this, false);
718
        connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , docCheckerPalette, SLOT(setPaletteShown(bool)) );
719
        connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , this, SLOT(docCheckToggle(bool)) );
10581 cbradney 720
        connect( docCheckerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsPreflightVerifier"], SLOT(setChecked(bool)));
5800 fschmid 721
        connect( docCheckerPalette, SIGNAL(paletteShown(bool)), this, SLOT(docCheckToggle(bool)));
722
        docCheckerPalette->installEventFilter(this);
723
        docCheckerPalette->hide();
724
 
18194 fschmid 725
        alignDistributePalette = new AlignDistributePalette(this, "AlignDistributePalette");
5800 fschmid 726
        connect( scrActions["toolsAlignDistribute"], SIGNAL(toggled(bool)) , alignDistributePalette, SLOT(setPaletteShown(bool)) );
10581 cbradney 727
        connect( alignDistributePalette, SIGNAL(paletteShown(bool)), scrActions["toolsAlignDistribute"], SLOT(setChecked(bool)));
5800 fschmid 728
        connect( alignDistributePalette, SIGNAL(documentChanged()), this, SLOT(slotDocCh()));
729
        alignDistributePalette->installEventFilter(this);
7087 subik 730
 
15060 fschmid 731
        symbolPalette = new SymbolPalette(this);
732
        symbolPalette->setMainWindow(this);
16029 fschmid 733
        connect(scrActions["toolsSymbols"], SIGNAL(toggled(bool)), symbolPalette, SLOT(setPaletteShown(bool)));
734
        connect(symbolPalette, SIGNAL(paletteShown(bool)), scrActions["toolsSymbols"], SLOT(setChecked(bool)));
735
        connect(symbolPalette, SIGNAL(startEdit(QString)), this, SLOT(editSymbolStart(QString)));
736
        connect(symbolPalette, SIGNAL(endEdit()), this, SLOT(editSymbolEnd()));
17793 fschmid 737
        connect(symbolPalette, SIGNAL(objectDropped()), this, SLOT(PutToPatterns()));
15060 fschmid 738
        symbolPalette->installEventFilter(this);
739
        symbolPalette->hide();
17405 fschmid 740
 
741
        inlinePalette = new InlinePalette(this);
742
        inlinePalette->setMainWindow(this);
743
        connect(scrActions["toolsInline"], SIGNAL(toggled(bool)), inlinePalette, SLOT(setPaletteShown(bool)));
744
        connect(inlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsInline"], SLOT(setChecked(bool)));
17410 fschmid 745
        connect(inlinePalette, SIGNAL(startEdit(int)), this, SLOT(editInlineStart(int)));
746
        connect(inlinePalette, SIGNAL(endEdit()), this, SLOT(editInlineEnd()));
17804 fschmid 747
        connect(inlinePalette, SIGNAL(objectDropped(QString)), this, SLOT(PutToInline(QString)));
17405 fschmid 748
        inlinePalette->installEventFilter(this);
749
        inlinePalette->hide();
15060 fschmid 750
 
5800 fschmid 751
        undoPalette = new UndoPalette(this, "undoPalette");
752
        undoPalette->installEventFilter(this);
20691 craig 753
        m_undoManager->registerGui(undoPalette);
5800 fschmid 754
        connect(undoPalette, SIGNAL(paletteShown(bool)), this, SLOT(setUndoPalette(bool)));
755
        connect(undoPalette, SIGNAL(objectMode(bool)), this, SLOT(setUndoMode(bool)));
756
 
757
        // initializing style manager here too even it's not strictly a palette
20691 craig 758
        m_styleManager = new StyleManager(this, "styleManager");
7063 tsoots 759
        SMCharacterStyle *tmpCS = new SMCharacterStyle();
21374 jghali 760
        m_styleManager->addStyle(new SMParagraphStyle(tmpCS));
20691 craig 761
        m_styleManager->addStyle(tmpCS);
762
        m_styleManager->addStyle(new SMTableStyle());
763
        m_styleManager->addStyle(new SMCellStyle());
764
        m_styleManager->addStyle(new SMLineStyle());
765
        connect( scrActions["editStyles"], SIGNAL(toggled(bool)), m_styleManager, SLOT(setPaletteShown(bool)) );
766
        connect( m_styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setChecked(bool)));
767
        m_styleManager->installEventFilter(this);
5800 fschmid 768
 
17826 craig 769
        // initializing mark`s manager
770
        marksManager = new MarksManager(this, "marksManager");
771
        connect( scrActions["editMarks"], SIGNAL(toggled(bool)), marksManager, SLOT(setPaletteShown(bool)) );
772
        connect( marksManager, SIGNAL(paletteShown(bool)), scrActions["editMarks"], SLOT(setChecked(bool)));
773
        marksManager->installEventFilter(this);
774
        // initializing notes styles manager
775
        nsEditor = new NotesStylesEditor(this, "notesStylesEditor");
776
        connect( scrActions["editNotesStyles"], SIGNAL(toggled(bool)), nsEditor, SLOT(setPaletteShown(bool)) );
777
        connect( nsEditor, SIGNAL(paletteShown(bool)), scrActions["editNotesStyles"], SLOT(setChecked(bool)));
778
        nsEditor->installEventFilter(this);
779
 
22607 craig 780
        connect(docCheckerPalette, SIGNAL(selectElementByItem(PageItem*,bool)), this, SLOT(selectItemsFromOutlines(PageItem*,bool)));
781
        connect(docCheckerPalette, SIGNAL(selectElement(PageItem*,bool,int)), this, SLOT(selectItemFromOutlines(PageItem*,bool,int)));
5800 fschmid 782
        connect(docCheckerPalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
18888 craig 783
        connect(docCheckerPalette, SIGNAL(selectMasterPage(QString)), this, SLOT(editMasterPagesStart(QString)));
24887 craig 784
        connect(outlinePalette, SIGNAL(selectElementByItem(PageItem*,bool)), this, SLOT(selectItemsFromOutlines(PageItem*,bool)));
785
        connect(outlinePalette, SIGNAL(editElementByItem(PageItem*)), this, SLOT(editItemsFromOutlines(PageItem*)));
5800 fschmid 786
        connect(outlinePalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
18888 craig 787
        connect(outlinePalette, SIGNAL(selectMasterPage(QString)), this, SLOT(editMasterPagesStart(QString)));
16546 jghali 788
        connect(nodePalette, SIGNAL(paletteClosed()), this, SLOT(slotSelect()));
5800 fschmid 789
        connect(nodePalette, SIGNAL(DocChanged()), this, SLOT(slotDocCh()));
790
        connect(layerPalette, SIGNAL(LayerChanged()), this, SLOT(showLayer()));
791
 
22396 jghali 792
        connect(bookmarkPalette->BView, SIGNAL(markMoved()), this, SLOT(StoreBookmarks()));
5800 fschmid 793
        connect(bookmarkPalette->BView, SIGNAL(changed()), this, SLOT(slotDocCh()));
24887 craig 794
        connect(bookmarkPalette->BView, SIGNAL(selectElement(PageItem*,bool)), this, SLOT(selectItemsFromOutlines(PageItem*,bool)));
5800 fschmid 795
        // guides
796
        connect(scrActions["pageManageGuides"], SIGNAL(toggled(bool)), guidePalette, SLOT(setPaletteShown(bool)));
10581 cbradney 797
        connect(guidePalette, SIGNAL(paletteShown(bool)), scrActions["pageManageGuides"], SLOT(setChecked(bool)));
7087 subik 798
        // char palette
799
        connect(scrActions["insertGlyph"], SIGNAL(toggled(bool)), charPalette, SLOT(setPaletteShown(bool)));
10581 cbradney 800
        connect(charPalette, SIGNAL(paletteShown(bool)), scrActions["insertGlyph"], SLOT(setChecked(bool)));
5800 fschmid 801
}
802
 
10532 avox 803
 
5800 fschmid 804
void ScribusMainWindow::initScrapbook()
805
{
23060 craig 806
        QString scrapbookFileO = QDir::toNativeSeparators(m_prefsManager.preferencesLocation()+"/scrap13.scs");
24715 jghali 807
        QFileInfo scrapbookFileInfoO(scrapbookFileO);
5800 fschmid 808
        if (scrapbookFileInfoO.exists())
809
        {
21591 jghali 810
                scrapbookPalette->readOldContents(scrapbookFileO, ScPaths::scrapbookDir(true) + "main");
24715 jghali 811
                QDir d;
23060 craig 812
                d.rename(scrapbookFileO, QDir::toNativeSeparators(m_prefsManager.preferencesLocation()+"/scrap13.backup"));
5800 fschmid 813
        }
21591 jghali 814
        QString scrapbookTemp = QDir::toNativeSeparators(ScPaths::scrapbookDir(true) + "tmp");
24715 jghali 815
        QFileInfo scrapbookTempInfo(scrapbookTemp);
5800 fschmid 816
        if (scrapbookTempInfo.exists())
817
                scrapbookPalette->readTempContents(scrapbookTemp);
21591 jghali 818
        QString scrapbookFile = QDir::toNativeSeparators(ScPaths::scrapbookDir(true) + "main");
24715 jghali 819
        QFileInfo scrapbookFileInfo(scrapbookFile);
5800 fschmid 820
        if (scrapbookFileInfo.exists())
821
                scrapbookPalette->readContents(scrapbookFile);
822
        scrapbookPalette->setScrapbookFileName(scrapbookFile);
15527 fschmid 823
        ScCore->fileWatcher->addDir(scrapbookFile, true);
23060 craig 824
        scrapbookPalette->setOpenScrapbooks(m_prefsManager.appPrefs.scrapbookPrefs.RecentScrapbooks);
5800 fschmid 825
        rebuildRecentPasteMenu();
5806 fschmid 826
        connect(scrapbookPalette, SIGNAL(updateRecentMenue()), this, SLOT(rebuildRecentPasteMenu()));
24887 craig 827
        connect(ScCore->fileWatcher, SIGNAL(dirChanged(QString)), scrapbookPalette, SLOT(reloadLib(QString)));
828
        connect(ScCore->fileWatcher, SIGNAL(dirDeleted(QString)), scrapbookPalette, SLOT(closeOnDel(QString)));
5800 fschmid 829
}
830
 
831
bool ScribusMainWindow::warningVersion(QWidget *parent)
832
{
833
        bool retval = false;
19605 jghali 834
        int t = ScMessageBox::warning(parent, QObject::tr("Scribus Development Version"), "<qt>" +
17948 jghali 835
                                                                 QObject::tr("You are running a development version of Scribus 1.5.x. The document you are working with was created in Scribus 1.2.x.  Saving the current file under 1.5.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>",
19605 jghali 836
                                                                 QMessageBox::Ok | QMessageBox::Cancel,
837
                                                                 QMessageBox::Cancel,   // GUI default
838
                                                                 QMessageBox::Ok);      // batch default
9422 fschmid 839
        if (t == QMessageBox::Ok)
5800 fschmid 840
                retval = true;
841
        return retval;
842
}
843
 
22076 jghali 844
void ScribusMainWindow::initMdiArea()
845
{
846
        mdiArea = new QMdiArea(this);
847
        mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
848
        mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
23060 craig 849
        if (m_prefsManager.appPrefs.uiPrefs.useTabs)
22076 jghali 850
        {
851
                mdiArea->setViewMode(QMdiArea::TabbedView);
852
                mdiArea->setTabsClosable(true);
853
                mdiArea->setDocumentMode(true);
854
        }
855
        else
856
                mdiArea->setViewMode(QMdiArea::SubWindowView);
857
        setCentralWidget(mdiArea);
858
}
10532 avox 859
 
5800 fschmid 860
void ScribusMainWindow::initMenuBar()
861
{
22700 craig 862
        m_recentDocsList.clear();
12940 cbradney 863
        scrMenuMgr->createMenu("File", ActionManager::defaultMenuNameEntryTranslated("File"));
18533 craig 864
        scrMenuMgr->addMenuItemString("fileNew", "File");
865
        scrMenuMgr->addMenuItemString("fileNewFromTemplate", "File");
866
        scrMenuMgr->addMenuItemString("fileOpen", "File");
867
        scrMenuMgr->addMenuItemString("FileOpenRecent", "File");
18583 craig 868
        scrMenuMgr->createMenu("FileOpenRecent", tr("Open &Recent"), "File", false, true);
18533 craig 869
        scrMenuMgr->addMenuItemString("SEPARATOR", "File");
870
        scrMenuMgr->addMenuItemString("fileClose", "File");
871
        scrMenuMgr->addMenuItemString("fileSave", "File");
872
        scrMenuMgr->addMenuItemString("fileSaveAs", "File");
873
        scrMenuMgr->addMenuItemString("fileRevert", "File");
874
        scrMenuMgr->addMenuItemString("fileCollect", "File");
875
        scrMenuMgr->addMenuItemString("SEPARATOR", "File");
10558 cbradney 876
        scrMenuMgr->createMenu("FileImport", tr("&Import"), "File");
18533 craig 877
        scrMenuMgr->addMenuItemString("FileImport", "File");
878
        scrMenuMgr->addMenuItemString("fileImportText", "FileImport");
879
        scrMenuMgr->addMenuItemString("fileImportAppendText", "FileImport");
880
        scrMenuMgr->addMenuItemString("fileImportImage", "FileImport");
881
        scrMenuMgr->addMenuItemString("fileImportVector", "FileImport");
882
        scrMenuMgr->addMenuItemString("FileExport", "File");
10558 cbradney 883
        scrMenuMgr->createMenu("FileExport", tr("&Export"), "File");
18533 craig 884
        scrMenuMgr->addMenuItemString("fileExportText", "FileExport");
885
        scrMenuMgr->addMenuItemString("fileExportAsEPS", "FileExport");
886
        scrMenuMgr->addMenuItemString("fileExportAsPDF", "FileExport");
887
        scrMenuMgr->addMenuItemString("SEPARATOR", "File");
888
        scrMenuMgr->addMenuItemString("fileDocSetup150", "File");
889
        scrMenuMgr->addMenuItemString("filePreferences150", "File");
890
        scrMenuMgr->addMenuItemString("SEPARATOR", "File");
891
        scrMenuMgr->addMenuItemString("filePrint", "File");
23829 jghali 892
        if (ScCore->haveGS() || ScCore->isWinGUI())
19179 craig 893
                scrMenuMgr->addMenuItemString("PrintPreview", "File");
18533 craig 894
        scrMenuMgr->addMenuItemString("SEPARATOR", "File");
23829 jghali 895
        if (ScCore->haveGS())
896
        {
897
                scrMenuMgr->addMenuItemString("FileOutputPreview", "File");
898
                scrMenuMgr->createMenu("FileOutputPreview", tr("&Output Preview"), "File");
899
                scrMenuMgr->addMenuItemString("OutputPreviewPDF", "FileOutputPreview");
23845 jghali 900
                scrMenuMgr->addMenuItemString("OutputPreviewPS", "FileOutputPreview");
23829 jghali 901
                scrMenuMgr->addMenuItemString("SEPARATOR", "File");
902
        }
18533 craig 903
        scrMenuMgr->addMenuItemString("fileQuit", "File");
5800 fschmid 904
 
6451 fschmid 905
        scrMenuMgr->setMenuEnabled("FileImport", false);
5800 fschmid 906
        scrMenuMgr->setMenuEnabled("FileExport", false);
23829 jghali 907
        scrMenuMgr->setMenuEnabled("FileOutputPreview", false);
5800 fschmid 908
 
12940 cbradney 909
        scrMenuMgr->createMenu("Edit", ActionManager::defaultMenuNameEntryTranslated("Edit"));
18533 craig 910
        scrMenuMgr->addMenuItemString("editUndoAction", "Edit");
911
        scrMenuMgr->addMenuItemString("editRedoAction", "Edit");
912
        scrMenuMgr->addMenuItemString("editActionMode", "Edit");
913
        scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
914
        scrMenuMgr->addMenuItemString("editCut", "Edit");
915
        scrMenuMgr->addMenuItemString("editCopy", "Edit");
916
        scrMenuMgr->addMenuItemString("editPaste", "Edit");
23032 jghali 917
        scrMenuMgr->createMenu("EditPasteRecent", tr("Paste Recent"), "Edit", false, true);
918
        scrMenuMgr->addMenuItemString("itemDelete", "Edit");
919
        scrMenuMgr->createMenu("EditContents", tr("Contents"), "Edit", false, true);
920
        scrMenuMgr->addMenuItemString("EditContents", "Edit");
18533 craig 921
        scrMenuMgr->addMenuItemString("editCopyContents", "EditContents");
922
        scrMenuMgr->addMenuItemString("editPasteContents", "EditContents");
923
        scrMenuMgr->addMenuItemString("editPasteContentsAbs", "EditContents");
924
        scrMenuMgr->addMenuItemString("editClearContents", "EditContents");
23032 jghali 925
        scrMenuMgr->addMenuItemString("editTruncateContents", "EditContents");
18533 craig 926
        scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
927
        scrMenuMgr->addMenuItemString("editSelectAll", "Edit");
928
        scrMenuMgr->addMenuItemString("editSelectAllOnLayer", "Edit");
929
        scrMenuMgr->addMenuItemString("editDeselectAll", "Edit");
930
        scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
931
        scrMenuMgr->addMenuItemString("editSearchReplace", "Edit");
932
        scrMenuMgr->addMenuItemString("toolsEditWithStoryEditor", "Edit");
933
        scrMenuMgr->addMenuItemString("editEditWithImageEditor", "Edit");
934
        scrMenuMgr->addMenuItemString("editEditRenderSource", "Edit");
935
        scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
21928 craig 936
        scrMenuMgr->addMenuItemString("editColorsAndFills", "Edit");
18533 craig 937
        scrMenuMgr->addMenuItemString("editReplaceColors", "Edit");
938
        scrMenuMgr->addMenuItemString("editStyles", "Edit");
939
        scrMenuMgr->addMenuItemString("editMarks", "Edit");
940
        scrMenuMgr->addMenuItemString("editNotesStyles", "Edit");
941
        scrMenuMgr->addMenuItemString("editMasterPages", "Edit");
942
        scrMenuMgr->addMenuItemString("editJavascripts", "Edit");
5827 fschmid 943
        scrMenuMgr->setMenuEnabled("EditPasteRecent", false);
7565 cbradney 944
        scrMenuMgr->setMenuEnabled("EditContents", false);
5800 fschmid 945
 
18756 craig 946
 
5800 fschmid 947
        //Item Menu
12940 cbradney 948
        scrMenuMgr->createMenu("Item", ActionManager::defaultMenuNameEntryTranslated("Item"));
18070 fschmid 949
        scrMenuMgr->createMenu("DuplicateTransform", tr("Duplicate/Transform"), "Item");
18533 craig 950
        scrMenuMgr->addMenuItemString("DuplicateTransform", "Item");
951
        scrMenuMgr->addMenuItemString("itemDuplicate", "DuplicateTransform");
952
        scrMenuMgr->addMenuItemString("itemMulDuplicate", "DuplicateTransform");
953
        scrMenuMgr->addMenuItemString("itemTransform", "DuplicateTransform");
18070 fschmid 954
        scrMenuMgr->createMenu("Grouping", tr("Grouping"), "Item");
18533 craig 955
        scrMenuMgr->addMenuItemString("Grouping", "Item");
956
        scrMenuMgr->addMenuItemString("itemGroup", "Grouping");
957
        scrMenuMgr->addMenuItemString("itemUngroup", "Grouping");
958
        scrMenuMgr->addMenuItemString("itemGroupAdjust", "Grouping");
18070 fschmid 959
        scrMenuMgr->createMenu("Locking", tr("Locking"), "Item");
18533 craig 960
        scrMenuMgr->addMenuItemString("Locking", "Item");
961
        scrMenuMgr->addMenuItemString("itemLock", "Locking");
962
        scrMenuMgr->addMenuItemString("itemLockSize", "Locking");
18070 fschmid 963
        scrMenuMgr->createMenu("ItemLevel", tr("Level"), "Item");
18533 craig 964
        scrMenuMgr->addMenuItemString("ItemLevel", "Item");
18547 craig 965
        scrMenuMgr->addMenuItemString("itemRaise", "ItemLevel");
966
        scrMenuMgr->addMenuItemString("itemLower", "ItemLevel");
967
        scrMenuMgr->addMenuItemString("itemRaiseToTop", "ItemLevel");
968
        scrMenuMgr->addMenuItemString("itemLowerToBottom", "ItemLevel");
23943 jghali 969
        scrMenuMgr->createMenu("ItemLayer", tr("Send to La&yer"), QString(), false, true);
18533 craig 970
        scrMenuMgr->addMenuItemString("ItemLayer", "Item");
18070 fschmid 971
        scrMenuMgr->createMenu("SendTo", tr("Send to"), "Item");
18533 craig 972
        scrMenuMgr->addMenuItemString("SendTo", "Item");
23943 jghali 973
        scrMenuMgr->createMenu("ItemSendToScrapbook", tr("Scrapbook"), QString(), false, true);
18539 craig 974
        scrMenuMgr->addMenuItemString("ItemSendToScrapbook", "SendTo");
18533 craig 975
        scrMenuMgr->addMenuItemString("itemSendToPattern", "SendTo");
976
        scrMenuMgr->addMenuItemString("itemSendToInline", "SendTo");
18070 fschmid 977
        scrMenuMgr->createMenu("Adjust", tr("Adjust"), "Item");
18533 craig 978
        scrMenuMgr->addMenuItemString("Adjust", "Item");
979
        scrMenuMgr->addMenuItemString("itemAdjustFrameHeightToText", "Adjust");
980
        scrMenuMgr->addMenuItemString("itemAdjustFrameToImage", "Adjust");
981
        scrMenuMgr->addMenuItemString("itemAdjustImageToFrame", "Adjust");
18070 fschmid 982
        scrMenuMgr->createMenu("Image", tr("Image"), "Item");
18533 craig 983
        scrMenuMgr->addMenuItemString("Image", "Item");
984
        scrMenuMgr->addMenuItemString("itemUpdateImage", "Image");
985
        scrMenuMgr->addMenuItemString("styleImageEffects", "Image");
986
        scrMenuMgr->addMenuItemString("itemExtendedImageProperties", "Image");
987
        scrMenuMgr->addMenuItemString("itemToggleInlineImage", "Image");
19253 craig 988
        scrMenuMgr->createMenu("ItemPreviewSettings", tr("Preview Settings"));
18533 craig 989
        scrMenuMgr->addMenuItemString("ItemPreviewSettings", "Image");
990
        scrMenuMgr->addMenuItemString("itemImageIsVisible", "ItemPreviewSettings");
991
        scrMenuMgr->addMenuItemString("SEPARATOR", "ItemPreviewSettings");
19465 jghali 992
        scrMenuMgr->addMenuItemString("itemPreviewFull", "ItemPreviewSettings");
993
        scrMenuMgr->addMenuItemString("itemPreviewNormal", "ItemPreviewSettings");
18533 craig 994
        scrMenuMgr->addMenuItemString("itemPreviewLow", "ItemPreviewSettings");
23507 craig 995
        scrMenuMgr->createMenu("ItemPDFOptions", tr("P&DF Options"));
18533 craig 996
        scrMenuMgr->addMenuItemString("ItemPDFOptions", "Item");
997
        scrMenuMgr->addMenuItemString("itemPDFIsAnnotation", "ItemPDFOptions");
998
        scrMenuMgr->addMenuItemString("itemPDFIsBookmark", "ItemPDFOptions");
999
        scrMenuMgr->addMenuItemString("itemPDFAnnotationProps", "ItemPDFOptions");
1000
        scrMenuMgr->addMenuItemString("itemPDFFieldProps", "ItemPDFOptions");
19436 jghali 1001
        scrMenuMgr->createMenu("ItemConvertTo", tr("C&onvert to"), "Item");
18533 craig 1002
        scrMenuMgr->addMenuItemString("ItemConvertTo", "Item");
18629 craig 1003
        scrMenuMgr->addMenuItemString("itemConvertToTextFrame", "ItemConvertTo");
1004
        scrMenuMgr->addMenuItemString("itemConvertToImageFrame", "ItemConvertTo");
1005
        scrMenuMgr->addMenuItemString("itemConvertToPolygon", "ItemConvertTo");
18533 craig 1006
        scrMenuMgr->addMenuItemString("itemConvertToBezierCurve", "ItemConvertTo");
1007
        scrMenuMgr->addMenuItemString("itemConvertToOutlines", "ItemConvertTo");
1008
        scrMenuMgr->addMenuItemString("itemConvertToSymbolFrame", "ItemConvertTo");
18070 fschmid 1009
        scrMenuMgr->createMenu("TextLinking", tr("Text Frame Links"), "Item");
18533 craig 1010
        scrMenuMgr->addMenuItemString("TextLinking", "Item");
1011
        scrMenuMgr->addMenuItemString("toolsLinkTextFrame", "TextLinking");
1012
        scrMenuMgr->addMenuItemString("toolsUnlinkTextFrame", "TextLinking");
21468 jghali 1013
        scrMenuMgr->addMenuItemString("toolsUnlinkTextFrameAndCutText", "TextLinking");
18070 fschmid 1014
        scrMenuMgr->createMenu("ItemPathOps", tr("Path Tools"), "Item");
18533 craig 1015
        scrMenuMgr->addMenuItemString("ItemPathOps", "Item");
1016
        scrMenuMgr->addMenuItemString("itemCombinePolygons", "ItemPathOps");
1017
        scrMenuMgr->addMenuItemString("itemSplitPolygons", "ItemPathOps");
1018
        scrMenuMgr->addMenuItemString("itemAttachTextToPath", "ItemPathOps");
1019
        scrMenuMgr->addMenuItemString("itemDetachTextFromPath", "ItemPathOps");
15108 cbradney 1020
 
5800 fschmid 1021
        scrActions["itemPrintingEnabled"]->setEnabled(false);
1022
        scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
1023
 
18070 fschmid 1024
        scrMenuMgr->createMenu("Weld", tr("Welding"), "Item");
18533 craig 1025
        scrMenuMgr->addMenuItemString("Weld", "Item");
18629 craig 1026
        scrMenuMgr->addMenuItemString("itemWeld", "Weld");
18533 craig 1027
        scrMenuMgr->addMenuItemString("itemsUnWeld", "Weld");
1028
        scrMenuMgr->addMenuItemString("itemEditWeld", "Weld");
17826 craig 1029
 
24728 craig 1030
        scrMenuMgr->createMenu("Marks", tr("Marks"), "Item");
1031
        scrMenuMgr->addMenuItemString("Marks", "Item");
1032
        scrMenuMgr->addMenuItemString("editMark", "Marks");
1033
 
1034
        scrMenuMgr->createMenu("TextFeatures", tr("Text Features", "Item"));
1035
        scrMenuMgr->addMenuItemString("TextFeatures", "Item");
1036
        scrMenuMgr->addMenuItemString("alignLeft", "TextFeatures");
1037
        scrMenuMgr->addMenuItemString("alignCenter", "TextFeatures");
1038
        scrMenuMgr->addMenuItemString("alignRight", "TextFeatures");
1039
        scrMenuMgr->addMenuItemString("alignBlock", "TextFeatures");
1040
        scrMenuMgr->addMenuItemString("alignForced", "TextFeatures");
1041
        scrMenuMgr->addMenuItemString("SEPARATOR", "TextFeatures");
1042
        scrMenuMgr->addMenuItemString("typeEffectNormal", "TextFeatures");
1043
        scrMenuMgr->addMenuItemString("typeEffectUnderline", "TextFeatures");
1044
        scrMenuMgr->addMenuItemString("typeEffectUnderlineWords", "TextFeatures");
1045
        scrMenuMgr->addMenuItemString("typeEffectStrikeThrough", "TextFeatures");
1046
        scrMenuMgr->addMenuItemString("typeEffectAllCaps", "TextFeatures");
1047
        scrMenuMgr->addMenuItemString("typeEffectSmallCaps", "TextFeatures");
1048
        scrMenuMgr->addMenuItemString("typeEffectSuperscript", "TextFeatures");
1049
        scrMenuMgr->addMenuItemString("typeEffectSubscript", "TextFeatures");
1050
        scrMenuMgr->addMenuItemString("typeEffectOutline", "TextFeatures");
1051
        scrMenuMgr->addMenuItemString("typeEffectShadow", "TextFeatures");
1052
 
5800 fschmid 1053
        //Insert menu
12940 cbradney 1054
        scrMenuMgr->createMenu("Insert", ActionManager::defaultMenuNameEntryTranslated("Insert"));
18533 craig 1055
        scrMenuMgr->addMenuItemString("insertFrame", "Insert");
1056
        scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
1057
        scrMenuMgr->addMenuItemString("toolsInsertTextFrame", "Insert");
1058
        scrMenuMgr->addMenuItemString("toolsInsertImageFrame", "Insert");
1059
        scrMenuMgr->addMenuItemString("toolsInsertRenderFrame", "Insert");
1060
        scrMenuMgr->addMenuItemString("toolsInsertTable", "Insert");
1061
        scrMenuMgr->addMenuItemString("toolsInsertShape", "Insert");
1062
        scrMenuMgr->addMenuItemString("toolsInsertPolygon", "Insert");
1063
        scrMenuMgr->addMenuItemString("toolsInsertArc", "Insert");
1064
        scrMenuMgr->addMenuItemString("toolsInsertSpiral", "Insert");
1065
        scrMenuMgr->addMenuItemString("toolsInsertLine", "Insert");
1066
        scrMenuMgr->addMenuItemString("toolsInsertBezier", "Insert");
1067
        scrMenuMgr->addMenuItemString("toolsInsertFreehandLine", "Insert");
1068
        scrMenuMgr->addMenuItemString("toolsInsertCalligraphicLine", "Insert");
1069
        scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
1070
        scrMenuMgr->addMenuItemString("stickyTools", "Insert");
1071
        scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
1072
        scrMenuMgr->addMenuItemString("insertGlyph", "Insert");
5800 fschmid 1073
 
10558 cbradney 1074
        scrMenuMgr->createMenu("InsertChar", tr("&Character"), "Insert");
18533 craig 1075
        scrMenuMgr->addMenuItemString("InsertChar", "Insert");
1076
        scrMenuMgr->addMenuItemString("unicodePageNumber", "InsertChar");
1077
        scrMenuMgr->addMenuItemString("unicodePageCount", "InsertChar");
1078
        scrMenuMgr->addMenuItemString("unicodeSoftHyphen", "InsertChar");
1079
        scrMenuMgr->addMenuItemString("unicodeNonBreakingHyphen", "InsertChar");
21563 jghali 1080
        scrMenuMgr->addMenuItemString("unicodeZWJ", "InsertChar");
1081
        scrMenuMgr->addMenuItemString("unicodeZWNJ", "InsertChar");
18533 craig 1082
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertChar");
1083
        scrMenuMgr->addMenuItemString("unicodeCopyRight", "InsertChar");
1084
        scrMenuMgr->addMenuItemString("unicodeRegdTM", "InsertChar");
1085
        scrMenuMgr->addMenuItemString("unicodeTM", "InsertChar");
1086
        scrMenuMgr->addMenuItemString("unicodeSolidus", "InsertChar");
1087
        scrMenuMgr->addMenuItemString("unicodeBullet", "InsertChar");
1088
        scrMenuMgr->addMenuItemString("unicodeMidpoint", "InsertChar");
1089
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertChar");
1090
        scrMenuMgr->addMenuItemString("unicodeDashEm", "InsertChar");
1091
        scrMenuMgr->addMenuItemString("unicodeDashEn", "InsertChar");
1092
        scrMenuMgr->addMenuItemString("unicodeDashFigure", "InsertChar");
1093
        scrMenuMgr->addMenuItemString("unicodeDashQuotation", "InsertChar");
5800 fschmid 1094
 
10558 cbradney 1095
        scrMenuMgr->createMenu("InsertQuote", tr("&Quote"), "Insert");
18533 craig 1096
        scrMenuMgr->addMenuItemString("InsertQuote", "Insert");
1097
        scrMenuMgr->addMenuItemString("unicodeQuoteApostrophe", "InsertQuote");
1098
        scrMenuMgr->addMenuItemString("unicodeQuoteStraight", "InsertQuote");
1099
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
1100
        scrMenuMgr->addMenuItemString("unicodeQuoteSingleLeft", "InsertQuote");
1101
        scrMenuMgr->addMenuItemString("unicodeQuoteSingleRight", "InsertQuote");
1102
        scrMenuMgr->addMenuItemString("unicodeQuoteDoubleLeft", "InsertQuote");
1103
        scrMenuMgr->addMenuItemString("unicodeQuoteDoubleRight", "InsertQuote");
1104
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
1105
        scrMenuMgr->addMenuItemString("unicodeQuoteSingleReversed", "InsertQuote");
1106
        scrMenuMgr->addMenuItemString("unicodeQuoteDoubleReversed", "InsertQuote");
1107
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
1108
        scrMenuMgr->addMenuItemString("unicodeQuoteLowSingleComma", "InsertQuote");
1109
        scrMenuMgr->addMenuItemString("unicodeQuoteLowDoubleComma", "InsertQuote");
1110
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
1111
        scrMenuMgr->addMenuItemString("unicodeQuoteSingleLeftGuillemet", "InsertQuote");
1112
        scrMenuMgr->addMenuItemString("unicodeQuoteSingleRightGuillemet", "InsertQuote");
1113
        scrMenuMgr->addMenuItemString("unicodeQuoteDoubleLeftGuillemet", "InsertQuote");
1114
        scrMenuMgr->addMenuItemString("unicodeQuoteDoubleRightGuillemet", "InsertQuote");
1115
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
1116
        scrMenuMgr->addMenuItemString("unicodeQuoteCJKSingleLeft", "InsertQuote");
1117
        scrMenuMgr->addMenuItemString("unicodeQuoteCJKSingleRight", "InsertQuote");
1118
        scrMenuMgr->addMenuItemString("unicodeQuoteCJKDoubleLeft", "InsertQuote");
1119
        scrMenuMgr->addMenuItemString("unicodeQuoteCJKDoubleRight", "InsertQuote");
5800 fschmid 1120
 
21058 craig 1121
        scrMenuMgr->createMenu("InsertSpace", tr("S&paces && Breaks"), "Insert");
18533 craig 1122
        scrMenuMgr->addMenuItemString("InsertSpace", "Insert");
1123
        scrMenuMgr->addMenuItemString("unicodeNonBreakingSpace", "InsertSpace");
23871 jghali 1124
        scrMenuMgr->addMenuItemString("unicodeNarrowNoBreakSpace", "InsertSpace");
18533 craig 1125
        scrMenuMgr->addMenuItemString("unicodeSpaceEN", "InsertSpace");
1126
        scrMenuMgr->addMenuItemString("unicodeSpaceEM", "InsertSpace");
1127
        scrMenuMgr->addMenuItemString("unicodeSpaceThin", "InsertSpace");
1128
        scrMenuMgr->addMenuItemString("unicodeSpaceThick", "InsertSpace");
1129
        scrMenuMgr->addMenuItemString("unicodeSpaceMid", "InsertSpace");
1130
        scrMenuMgr->addMenuItemString("unicodeSpaceHair", "InsertSpace");
1131
        scrMenuMgr->addMenuItemString("SEPARATOR", "InsertSpace");
22995 craig 1132
        scrMenuMgr->addMenuItemString("unicodeZerowidthSpace", "InsertSpace");
18533 craig 1133
        scrMenuMgr->addMenuItemString("unicodeNewLine", "InsertSpace");
22995 craig 1134
        scrMenuMgr->addMenuItemString("unicodeColumnBreak", "InsertSpace");
18533 craig 1135
        scrMenuMgr->addMenuItemString("unicodeFrameBreak", "InsertSpace");
5800 fschmid 1136
 
10558 cbradney 1137
        scrMenuMgr->createMenu("InsertLigature", tr("Liga&ture"), "Insert");
18533 craig 1138
        scrMenuMgr->addMenuItemString("InsertLigature", "Insert");
1139
        scrMenuMgr->addMenuItemString("unicodeLigature_ff", "InsertLigature");
1140
        scrMenuMgr->addMenuItemString("unicodeLigature_fi", "InsertLigature");
1141
        scrMenuMgr->addMenuItemString("unicodeLigature_fl", "InsertLigature");
1142
        scrMenuMgr->addMenuItemString("unicodeLigature_ffi", "InsertLigature");
1143
        scrMenuMgr->addMenuItemString("unicodeLigature_ffl", "InsertLigature");
1144
        scrMenuMgr->addMenuItemString("unicodeLigature_ft", "InsertLigature");
1145
        scrMenuMgr->addMenuItemString("unicodeLigature_st", "InsertLigature");
5800 fschmid 1146
 
18533 craig 1147
        scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
1148
        scrMenuMgr->addMenuItemString("insertSampleText", "Insert");
1149
        scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
17826 craig 1150
        scrMenuMgr->createMenu("InsertMark", tr("Marks"), "Insert");
18533 craig 1151
        scrMenuMgr->addMenuItemString("InsertMark", "Insert");
1152
        scrMenuMgr->addMenuItemString("insertMarkAnchor", "InsertMark");
21460 jghali 1153
        scrMenuMgr->addMenuItemString("insertMarkNote", "InsertMark");
1154
        scrMenuMgr->addMenuItemString("insertMarkItem", "InsertMark");
18914 craig 1155
        scrMenuMgr->addMenuItemString("insertMark2Mark", "InsertMark");
18533 craig 1156
        scrMenuMgr->addMenuItemString("insertMarkVariableText", "InsertMark");
5800 fschmid 1157
 
1158
        //Page menu
12940 cbradney 1159
        scrMenuMgr->createMenu("Page", ActionManager::defaultMenuNameEntryTranslated("Page"));
18533 craig 1160
        scrMenuMgr->addMenuItemString("pageInsert", "Page");
1161
        scrMenuMgr->addMenuItemString("pageImport", "Page");
1162
        scrMenuMgr->addMenuItemString("pageDelete", "Page");
1163
        scrMenuMgr->addMenuItemString("pageCopy", "Page");
1164
        scrMenuMgr->addMenuItemString("pageMove", "Page");
1165
        scrMenuMgr->addMenuItemString("SEPARATOR", "Page");
1166
        scrMenuMgr->addMenuItemString("pageApplyMasterPage", "Page");
1167
        scrMenuMgr->addMenuItemString("pageCopyToMasterPage", "Page");
1168
        scrMenuMgr->addMenuItemString("pageManageGuides", "Page");
19907 craig 1169
        scrMenuMgr->addMenuItemString("pageManageProperties", "Page");
18533 craig 1170
        scrMenuMgr->addMenuItemString("SEPARATOR", "Page");
1171
        scrMenuMgr->addMenuItemString("viewSnapToGrid", "Page");
1172
        scrMenuMgr->addMenuItemString("viewSnapToGuides", "Page");
1173
        scrMenuMgr->addMenuItemString("viewSnapToElements", "Page");
5800 fschmid 1174
 
1175
        //View menu
12940 cbradney 1176
        scrMenuMgr->createMenu("View", ActionManager::defaultMenuNameEntryTranslated("View"));
18249 craig 1177
        scrMenuMgr->createMenu("ViewZoom", tr("Zoom"), "View");
18533 craig 1178
        scrMenuMgr->addMenuItemString("ViewZoom", "View");
1179
        scrMenuMgr->addMenuItemString("viewFitInWindow", "ViewZoom");
1180
        scrMenuMgr->addMenuItemString("viewFitWidth", "ViewZoom");
1181
        scrMenuMgr->addMenuItemString("viewFit50", "ViewZoom");
1182
        scrMenuMgr->addMenuItemString("viewFit75", "ViewZoom");
1183
        scrMenuMgr->addMenuItemString("viewFit100", "ViewZoom");
1184
        scrMenuMgr->addMenuItemString("viewFit200", "ViewZoom");
1185
        scrMenuMgr->addMenuItemString("viewFit400", "ViewZoom");
18249 craig 1186
        scrMenuMgr->createMenu("ViewPreview", tr("Preview"), "View");
18533 craig 1187
        scrMenuMgr->addMenuItemString("ViewPreview", "View");
1188
        scrMenuMgr->addMenuItemString("viewPreviewMode", "ViewPreview");
20252 craig 1189
        scrMenuMgr->createMenu("ViewMeasuring", tr("Measurement"), "View");
18533 craig 1190
        scrMenuMgr->addMenuItemString("ViewMeasuring", "View");
1191
        scrMenuMgr->addMenuItemString("viewShowRulers", "ViewMeasuring");
1192
        scrMenuMgr->addMenuItemString("viewRulerMode", "ViewMeasuring");
1193
        scrMenuMgr->addMenuItemString("showMouseCoordinates", "ViewMeasuring");
18249 craig 1194
        scrMenuMgr->createMenu("ViewTextFrames", tr("Text Frames"), "View");
18533 craig 1195
        scrMenuMgr->addMenuItemString("ViewTextFrames", "View");
1196
        scrMenuMgr->addMenuItemString("viewShowBaseline", "ViewTextFrames");
1197
        scrMenuMgr->addMenuItemString("viewShowColumnBorders", "ViewTextFrames");
1198
        scrMenuMgr->addMenuItemString("viewShowTextChain", "ViewTextFrames");
1199
        scrMenuMgr->addMenuItemString("viewShowTextControls", "ViewTextFrames");
18249 craig 1200
        scrMenuMgr->createMenu("ViewImageFrames", tr("Image Frames"), "View");
18533 craig 1201
        scrMenuMgr->addMenuItemString("ViewImageFrames", "View");
1202
        scrMenuMgr->addMenuItemString("viewShowImages", "ViewImageFrames");
18249 craig 1203
        scrMenuMgr->createMenu("ViewDocument", tr("Document"), "View");
18533 craig 1204
        scrMenuMgr->addMenuItemString("ViewDocument", "View");
1205
        scrMenuMgr->addMenuItemString("viewShowMargins", "ViewDocument");
1206
        scrMenuMgr->addMenuItemString("viewShowBleeds", "ViewDocument");
1207
        scrMenuMgr->addMenuItemString("viewShowFrames", "ViewDocument");
1208
        scrMenuMgr->addMenuItemString("viewShowLayerMarkers", "ViewDocument");
18249 craig 1209
        scrMenuMgr->createMenu("ViewGrids", tr("Grids and Guides"), "View");
18533 craig 1210
        scrMenuMgr->addMenuItemString("ViewGrids", "View");
18545 craig 1211
        scrMenuMgr->addMenuItemString("viewShowGrid", "ViewGrids");
1212
        scrMenuMgr->addMenuItemString("viewShowGuides", "ViewGrids");
5800 fschmid 1213
 
1214
        //CB If this is viewNewView imeplemented, it should be on the windows menu
1215
//      scrMenuMgr->addMenuItem(scrActions["viewNewView"], "View");
1216
 
18070 fschmid 1217
        // Table menu.
1218
        scrMenuMgr->createMenu("ItemTable", ActionManager::defaultMenuNameEntryTranslated("Table"));
18533 craig 1219
        scrMenuMgr->addMenuItemString("tableInsertRows", "ItemTable");
1220
        scrMenuMgr->addMenuItemString("tableInsertColumns", "ItemTable");
1221
        scrMenuMgr->addMenuItemString("tableDeleteRows", "ItemTable");
1222
        scrMenuMgr->addMenuItemString("tableDeleteColumns", "ItemTable");
1223
        scrMenuMgr->addMenuItemString("SEPARATOR", "ItemTable");
1224
        scrMenuMgr->addMenuItemString("tableMergeCells", "ItemTable");
1225
        scrMenuMgr->addMenuItemString("tableSplitCells", "ItemTable");
1226
        scrMenuMgr->addMenuItemString("SEPARATOR", "ItemTable");
1227
        scrMenuMgr->addMenuItemString("tableSetRowHeights", "ItemTable");
1228
        scrMenuMgr->addMenuItemString("tableSetColumnWidths", "ItemTable");
1229
        scrMenuMgr->addMenuItemString("tableDistributeRowsEvenly", "ItemTable");
1230
        scrMenuMgr->addMenuItemString("tableDistributeColumnsEvenly", "ItemTable");
1231
        scrMenuMgr->addMenuItemString("SEPARATOR", "ItemTable");
1232
        scrMenuMgr->addMenuItemString("tableAdjustFrameToTable", "ItemTable");
1233
        scrMenuMgr->addMenuItemString("tableAdjustTableToFrame", "ItemTable");
5800 fschmid 1234
 
1235
        //Extra menu
12940 cbradney 1236
        scrMenuMgr->createMenu("Extras", ActionManager::defaultMenuNameEntryTranslated("Extras"));
18533 craig 1237
        scrMenuMgr->addMenuItemString("extrasHyphenateText", "Extras");
1238
        scrMenuMgr->addMenuItemString("extrasDeHyphenateText", "Extras");
1239
        scrMenuMgr->addMenuItemString("extrasGenerateTableOfContents", "Extras");
18586 craig 1240
        scrMenuMgr->addMenuItemString("itemUpdateMarks", "Extras");
1241
        scrMenuMgr->addMenuItemString("SEPARATOR", "Extras");
1242
        scrMenuMgr->addMenuItemString("extrasManageImages", "Extras");
1243
        scrMenuMgr->addMenuItemString("SEPARATOR", "Extras");
18533 craig 1244
        scrMenuMgr->addMenuItemString("extrasUpdateDocument", "Extras");
20998 fschmid 1245
//      Disabled for release as it does nothing useful
1246
//      scrMenuMgr->addMenuItemString("extrasTestQTQuick2_1", "Extras");
5800 fschmid 1247
 
1248
        //Window menu
23041 craig 1249
        scrMenuMgr->createMenu("Windows", ActionManager::defaultMenuNameEntryTranslated("Windows"), QString(), true);
5800 fschmid 1250
 
1251
        //Help menu
12940 cbradney 1252
        scrMenuMgr->createMenu("Help", ActionManager::defaultMenuNameEntryTranslated("Help"));
18533 craig 1253
        scrMenuMgr->addMenuItemString("helpManual", "Help");
20510 craig 1254
        scrMenuMgr->addMenuItemString("helpChat", "Help");
18533 craig 1255
        scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
23088 jghali 1256
        scrMenuMgr->addMenuItemString("helpActionSearch", "Help");
18533 craig 1257
        scrMenuMgr->addMenuItemString("helpTooltips", "Help");
1258
        scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
1259
        scrMenuMgr->addMenuItemString("helpOnlineWWW", "Help");
1260
        scrMenuMgr->addMenuItemString("helpOnlineDocs", "Help");
1261
        scrMenuMgr->addMenuItemString("helpOnlineWiki", "Help");
1262
        scrMenuMgr->addMenuItemString("HelpOnlineTutorials", "Help");
1263
        scrMenuMgr->addMenuItemString("helpOnlineTutorial1", "Help");
1264
        scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
1265
        scrMenuMgr->addMenuItemString("helpCheckUpdates", "Help");
1266
        scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
1267
        scrMenuMgr->addMenuItemString("helpAboutScribus", "Help");
1268
        scrMenuMgr->addMenuItemString("helpAboutPlugins", "Help");
1269
        scrMenuMgr->addMenuItemString("helpAboutQt", "Help");
18548 craig 1270
}
10953 subik 1271
 
18548 craig 1272
void ScribusMainWindow::createMenuBar()
1273
{
18533 craig 1274
        scrMenuMgr->addMenuStringToMenuBar("File");
22900 jghali 1275
        scrMenuMgr->addMenuItemStringsToMenuBar("File", scrActions);
18533 craig 1276
        scrMenuMgr->addMenuStringToMenuBar("Edit");
22900 jghali 1277
        scrMenuMgr->addMenuItemStringsToMenuBar("Edit", scrActions);
18533 craig 1278
        scrMenuMgr->addMenuStringToMenuBar("Item");
22900 jghali 1279
        scrMenuMgr->addMenuItemStringsToMenuBar("Item", scrActions);
18533 craig 1280
        scrMenuMgr->addMenuStringToMenuBar("Insert");
22900 jghali 1281
        scrMenuMgr->addMenuItemStringsToMenuBar("Insert", scrActions);
18533 craig 1282
        scrMenuMgr->addMenuStringToMenuBar("Page");
22900 jghali 1283
        scrMenuMgr->addMenuItemStringsToMenuBar("Page", scrActions);
18533 craig 1284
        scrMenuMgr->addMenuStringToMenuBar("ItemTable");
22900 jghali 1285
        scrMenuMgr->addMenuItemStringsToMenuBar("ItemTable", scrActions);
18533 craig 1286
        scrMenuMgr->addMenuStringToMenuBar("Extras");
22900 jghali 1287
        scrMenuMgr->addMenuItemStringsToMenuBar("Extras", scrActions);
18533 craig 1288
        scrMenuMgr->addMenuStringToMenuBar("View");
22900 jghali 1289
        scrMenuMgr->addMenuItemStringsToMenuBar("View", scrActions);
18583 craig 1290
        scrMenuMgr->addMenuStringToMenuBar("Windows", true);
18533 craig 1291
        addDefaultWindowMenuItems();
10564 fschmid 1292
        menuBar()->addSeparator();
18533 craig 1293
        scrMenuMgr->addMenuStringToMenuBar("Help");
22900 jghali 1294
        scrMenuMgr->addMenuItemStringsToMenuBar("Help", scrActions);
18557 craig 1295
        connect(scrMenuMgr->getLocalPopupMenu("Extras"), SIGNAL(aboutToShow()), this, SLOT(extrasMenuAboutToShow()));
1296
        connect(scrMenuMgr->getLocalPopupMenu("Windows"), SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
1297
 
5800 fschmid 1298
}
1299
 
10532 avox 1300
 
5800 fschmid 1301
void ScribusMainWindow::addDefaultWindowMenuItems()
1302
{
1303
        scrMenuMgr->clearMenu("Windows");
18533 craig 1304
        scrMenuMgr->addMenuItemString("windowsCascade", "Windows");
1305
        scrMenuMgr->addMenuItemString("windowsTile", "Windows");
1306
        scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
23347 jghali 1307
        scrMenuMgr->addMenuItemString("toolsProperties", "Windows");
23282 craig 1308
        scrMenuMgr->addMenuItemString("toolsContent", "Windows");
18533 craig 1309
        scrMenuMgr->addMenuItemString("toolsActionHistory", "Windows");
1310
        scrMenuMgr->addMenuItemString("toolsAlignDistribute", "Windows");
1311
        scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
1312
        scrMenuMgr->addMenuItemString("toolsOutline", "Windows");
1313
        scrMenuMgr->addMenuItemString("toolsPages", "Windows");
1314
        scrMenuMgr->addMenuItemString("toolsLayers", "Windows");
1315
        scrMenuMgr->addMenuItemString("toolsBookmarks", "Windows");
20039 craig 1316
//      scrMenuMgr->addMenuItemString("toolsDownloads", "Windows");
19821 craig 1317
        scrMenuMgr->addMenuItemString("toolsResources", "Windows");
18533 craig 1318
        scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
1319
        scrMenuMgr->addMenuItemString("toolsScrapbook", "Windows");
1320
        scrMenuMgr->addMenuItemString("toolsSymbols", "Windows");
1321
        scrMenuMgr->addMenuItemString("toolsInline", "Windows");
1322
        scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
1323
        scrMenuMgr->addMenuItemString("toolsMeasurements", "Windows");
1324
        scrMenuMgr->addMenuItemString("toolsPreflightVerifier", "Windows");
1325
        scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
1326
        scrMenuMgr->addMenuItemString("toolsToolbarTools", "Windows");
1327
        scrMenuMgr->addMenuItemString("toolsToolbarPDF", "Windows");
19009 craig 1328
        scrMenuMgr->addMenuItemString("toolsToolbarView", "Windows");
19962 fschmid 1329
        scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
22900 jghali 1330
        scrMenuMgr->addMenuItemStringsToMenuBar("Windows", scrActions);
5800 fschmid 1331
}
1332
 
1333
 
1334
void ScribusMainWindow::initStatusBar()
1335
{
18972 craig 1336
        QFont fo = QFont(font());
1337
        int posi = fo.pointSize() - (ScCore->isWinGUI() ? 1 : 2);
1338
        fo.setPointSize(posi);
1339
        unitSwitcher = new QComboBox( this );
19954 craig 1340
        unitSwitcher->setObjectName("unitSwitcher");
18972 craig 1341
        unitSwitcher->setFocusPolicy(Qt::NoFocus);
1342
        unitSwitcher->setFont(fo);
1343
        int maxUindex = unitGetMaxIndex() - 2;
1344
        for (int i = 0; i <= maxUindex; ++i)
1345
                unitSwitcher->addItem(unitGetStrFromIndex(i));
19954 craig 1346
 
1347
 
1348
        QWidget* zoomWidget = new QWidget( statusBar() );
1349
        QHBoxLayout* zoomLayout = new QHBoxLayout( zoomWidget );
24545 craig 1350
        zoomLayout->setContentsMargins(0, 0, 0, 0);
24561 craig 1351
        zoomLayout->setSpacing(3);
19954 craig 1352
 
1353
        zoomSpinBox = new ScrSpinBox( 1, 32000, zoomWidget, 6 );
18972 craig 1354
        zoomSpinBox->setFont(fo);
1355
        zoomSpinBox->setValue( 100 );
1356
        zoomSpinBox->setSingleStep(10);
1357
        zoomSpinBox->setFocusPolicy(Qt::ClickFocus);
1358
        zoomSpinBox->setSuffix( tr( " %" ) );
1359
        layerMenu = new QComboBox( this );
19954 craig 1360
        layerMenu->setObjectName("layerMenu");
18972 craig 1361
        layerMenu->setEditable(false);
1362
        layerMenu->setFont(fo);
1363
        layerMenu->setFocusPolicy(Qt::NoFocus);
1364
        layerMenu->setSizeAdjustPolicy(QComboBox::AdjustToContents);
1365
 
1366
        pageSelector = new PageSelector(this, 1);
19954 craig 1367
        pageSelector->setObjectName("pageSelector");
18972 craig 1368
        pageSelector->setFont(fo);
1369
        pageSelector->setFocusPolicy(Qt::ClickFocus);
1370
 
19954 craig 1371
        zoomDefaultToolbarButton = new QPushButton(zoomWidget);
18972 craig 1372
        zoomDefaultToolbarButton->setFocusPolicy(Qt::NoFocus);
1373
        zoomDefaultToolbarButton->setDefault( false );
1374
        zoomDefaultToolbarButton->setAutoDefault( false );
19954 craig 1375
        zoomOutToolbarButton = new QPushButton(zoomWidget);
18972 craig 1376
        zoomOutToolbarButton->setFocusPolicy(Qt::NoFocus);
1377
        zoomOutToolbarButton->setDefault( false );
1378
        zoomOutToolbarButton->setAutoDefault( false );
19954 craig 1379
        zoomInToolbarButton = new QPushButton(zoomWidget);
18972 craig 1380
        zoomInToolbarButton->setFocusPolicy(Qt::NoFocus);
1381
        zoomInToolbarButton->setDefault( false );
1382
        zoomInToolbarButton->setAutoDefault( false );
19954 craig 1383
 
23054 craig 1384
        zoomDefaultToolbarButton->setIcon(IconManager::instance().loadIcon("16/zoom-original.png"));
1385
        zoomOutToolbarButton->setIcon(IconManager::instance().loadIcon("16/zoom-out.png"));
1386
        zoomInToolbarButton->setIcon(IconManager::instance().loadIcon("16/zoom-in.png"));
18972 craig 1387
 
19954 craig 1388
        zoomLayout->addWidget( zoomSpinBox );
1389
        zoomLayout->addWidget( zoomOutToolbarButton );
1390
        zoomLayout->addWidget( zoomDefaultToolbarButton );
1391
        zoomLayout->addWidget( zoomInToolbarButton );
1392
 
20691 craig 1393
        m_mainWindowStatusLabel = new QLabel( "           ", statusBar());
1394
        m_mainWindowStatusLabel->setFont(fo);
9953 cbradney 1395
        mainWindowProgressBar = new QProgressBar(statusBar());
1396
        mainWindowProgressBar->setAlignment(Qt::AlignHCenter);
5800 fschmid 1397
        mainWindowProgressBar->setFixedWidth( 100 );
1398
        mainWindowProgressBar->reset();
18972 craig 1399
        mainWindowXPosLabel = new QLabel( tr("X:"), statusBar());
18978 craig 1400
        mainWindowXPosLabel->setFont(fo);
18972 craig 1401
        mainWindowYPosLabel = new QLabel( tr("Y:"), statusBar());
18978 craig 1402
        mainWindowYPosLabel->setFont(fo);
23943 jghali 1403
        mainWindowXPosDataLabel = new QLabel(QString(), statusBar());
18978 craig 1404
        mainWindowXPosDataLabel->setFont(fo);
23943 jghali 1405
        mainWindowYPosDataLabel = new QLabel(QString(), statusBar());
18978 craig 1406
        mainWindowYPosDataLabel->setFont(fo);
23596 craig 1407
        mainWindowXPosDataLabel->setMinimumWidth(mainWindowXPosDataLabel->fontMetrics().horizontalAdvance("99999.999"));
1408
        mainWindowYPosDataLabel->setMinimumWidth(mainWindowYPosDataLabel->fontMetrics().horizontalAdvance("99999.999"));
18972 craig 1409
        statusBarLanguageChange();
1410
 
19956 craig 1411
        layerMenu->setObjectName("layerMenu");
1412
        unitSwitcher->setObjectName("unitSwitcher");
1413
        zoomDefaultToolbarButton->setObjectName("zoomDefaultToolbarButton");
1414
        zoomInToolbarButton->setObjectName("zoomInToolbarButton");
1415
        zoomOutToolbarButton->setObjectName("zoomOutToolbarButton");
1416
        zoomSpinBox->setObjectName("zoomSpinBox");
1417
 
19009 craig 1418
        statusBar()->setFont(fo);
20691 craig 1419
        statusBar()->addPermanentWidget(m_mainWindowStatusLabel, 5);
23943 jghali 1420
        QLabel *s = new QLabel(QString());
1421
        QLabel *s2 = new QLabel(QString());
1422
        QLabel *s3 = new QLabel(QString());
19009 craig 1423
        statusBar()->addPermanentWidget(s,1);
19954 craig 1424
        statusBar()->addPermanentWidget(s2,1);
1425
        statusBar()->addPermanentWidget(zoomWidget,0);
1426
        statusBar()->addPermanentWidget(pageSelector,0);
19009 craig 1427
        statusBar()->addPermanentWidget(layerMenu,1);
19954 craig 1428
        statusBar()->addPermanentWidget(s3,3);
10564 fschmid 1429
        statusBar()->addPermanentWidget(mainWindowXPosLabel, 0);
19954 craig 1430
        statusBar()->addPermanentWidget(mainWindowXPosDataLabel, 0);
10564 fschmid 1431
        statusBar()->addPermanentWidget(mainWindowYPosLabel, 0);
19954 craig 1432
        statusBar()->addPermanentWidget(mainWindowYPosDataLabel, 0);
1433
 
19009 craig 1434
        statusBar()->addPermanentWidget(unitSwitcher,0);
1435
        statusBar()->addPermanentWidget(mainWindowProgressBar, 0);
24887 craig 1436
        connect(statusBar(), SIGNAL(messageChanged(QString)), this, SLOT(setTempStatusBarText(QString)));
18972 craig 1437
 
5800 fschmid 1438
}
1439
 
10532 avox 1440
 
5800 fschmid 1441
void ScribusMainWindow::setStatusBarMousePosition(double xp, double yp)
1442
{
21373 craig 1443
        if (!HaveDoc)
1444
        {
1445
                mainWindowXPosDataLabel->clear();
1446
                mainWindowYPosDataLabel->clear();
1447
                return;
1448
        }
18065 fschmid 1449
        if (doc->Pages->count() == 0)
1450
                return;
5800 fschmid 1451
        double xn = xp;
1452
        double yn = yp;
14932 cbradney 1453
        if (doc->guidesPrefs().rulerMode)
5800 fschmid 1454
        {
1455
                xn -= doc->currentPage()->xOffset();
1456
                yn -= doc->currentPage()->yOffset();
1457
        }
1458
        xn -= doc->rulerXoffset;
1459
        yn -= doc->rulerYoffset;
19009 craig 1460
        mainWindowXPosDataLabel->setText(value2String(xn, doc->unitIndex(), true, false));
1461
        mainWindowYPosDataLabel->setText(value2String(yn, doc->unitIndex(), true, false));
5800 fschmid 1462
}
1463
 
15465 avox 1464
void ScribusMainWindow::setStatusBarTextPosition(double base, double xp)
1465
{
18065 fschmid 1466
        if (doc->Pages->count() == 0)
1467
                return;
15465 avox 1468
        mainWindowXPosDataLabel->setText(base + xp >= 0? value2String(xp, doc->unitIndex(), true, true): QString("-"));
1469
        mainWindowYPosDataLabel->setText("-");
1470
}
10532 avox 1471
 
19386 craig 1472
void ScribusMainWindow::setStatusBarTextSelectedItemInfo()
1473
{
22268 craig 1474
        const int docSelectionCount = doc->m_Selection->count();
19386 craig 1475
        if (docSelectionCount == 0)
19581 craig 1476
        {
19386 craig 1477
                setStatusBarInfoText("");
19581 craig 1478
                return;
1479
        }
1480
        QString widthTxt = value2String(doc->m_Selection->width(), doc->unitIndex(), true, true);
1481
        QString heightTxt = value2String(doc->m_Selection->height(), doc->unitIndex(), true, true);
1482
        if (docSelectionCount == 1)
19386 craig 1483
        {
1484
                QString whatSel = tr("Unknown");
1485
                switch (doc->m_Selection->itemAt(0)->itemType())
1486
                {
1487
                        case 2:
1488
                                whatSel = CommonStrings::itemType_ImageFrame;
1489
                                break;
1490
                        case 4:
1491
                                whatSel = CommonStrings::itemType_TextFrame;
1492
                                break;
1493
                        case 5:
1494
                                whatSel = CommonStrings::itemType_Line;
1495
                                break;
1496
                        case 6:
1497
                                whatSel = CommonStrings::itemType_Polygon;
1498
                                break;
1499
                        case 7:
1500
                                whatSel = CommonStrings::itemType_Polyline;
1501
                                break;
1502
                        case 8:
1503
                                whatSel = CommonStrings::itemType_PathText;
1504
                                break;
1505
                        case 9:
1506
                                whatSel = CommonStrings::itemType_LatexFrame;
1507
                                break;
1508
                        case 11:
1509
                                whatSel = CommonStrings::itemType_Symbol;
1510
                                break;
1511
                        case 12:
1512
                                whatSel = CommonStrings::itemType_Group;
1513
                                break;
1514
                        case 13:
1515
                                whatSel = CommonStrings::itemType_RegularPolygon;
1516
                                break;
1517
                        case 14:
1518
                                whatSel = CommonStrings::itemType_Arc;
1519
                                break;
1520
                        case 15:
1521
                                whatSel = CommonStrings::itemType_Spiral;
1522
                                break;
1523
                        case 16:
1524
                                whatSel = CommonStrings::itemType_Table;
1525
                                break;
1526
                        default:
1527
                                whatSel = "Unknown";
1528
                                break;
1529
                }
1530
                QString txtBody = tr("%1 selected").arg(whatSel) + " : " + tr("Size");
21934 craig 1531
                setStatusBarInfoText( QString("%1 = %3 x %4").arg(txtBody, widthTxt, heightTxt));
19386 craig 1532
        }
1533
        else
1534
        {
23210 craig 1535
                setStatusBarInfoText( tr("%1 Objects selected, Selection Size = %2 x %3").arg(docSelectionCount).arg(widthTxt, heightTxt));
19386 craig 1536
        }
1537
}
1538
 
15675 fschmid 1539
void ScribusMainWindow::setTempStatusBarText(const QString &text)
1540
{
20691 craig 1541
        if (m_mainWindowStatusLabel)
15675 fschmid 1542
        {
1543
                if (text.isEmpty())
20691 craig 1544
                        m_mainWindowStatusLabel->setText(m_statusLabelText);
15675 fschmid 1545
                else
20691 craig 1546
                        m_mainWindowStatusLabel->setText(text);
15675 fschmid 1547
        }
1548
}
15465 avox 1549
 
22635 craig 1550
void ScribusMainWindow::setStatusBarInfoText(const QString & newText)
5800 fschmid 1551
{
20691 craig 1552
        if (m_mainWindowStatusLabel)
1553
                m_mainWindowStatusLabel->setText(newText);
1554
        m_statusLabelText = newText;
5800 fschmid 1555
}
1556
 
10532 avox 1557
 
23282 craig 1558
//AV to be replaced with Selection::update and listener in contentPalette
5800 fschmid 1559
void ScribusMainWindow::setTBvals(PageItem *currItem)
1560
{
17826 craig 1561
        scrActions["editMark"]->setEnabled(false);
18794 jghali 1562
 
1563
        PageItem* item  = currItem;
1564
        bool inEditMode = (doc->appMode == modeEdit);
1565
        if (doc->appMode == modeEditTable)
5800 fschmid 1566
        {
18794 jghali 1567
                if (currItem->isTable())
1568
                        item = currItem->asTable()->activeCell().textFrame();
1569
                inEditMode = item->isTextFrame();
1570
        }
1571
        if (!item || item->itemText.length() <= 0)
1572
                return;
1573
 
22004 jghali 1574
        const ParagraphStyle& currPStyle(inEditMode ? item->currentStyle() : item->itemText.defaultStyle());
18794 jghali 1575
        setAlignmentValue(currPStyle.alignment());
22228 jghali 1576
 
1577
        // Assignment operator does not perform style context assignment
1578
        // Do it in this case, otherwise we might get some crashes if previous
1579
        // text object was deleted or things like that
1580
        const ParagraphStyle& curStyle = item->currentStyle();
1581
        doc->currentStyle.setContext(curStyle.context());
1582
        doc->currentStyle = curStyle;
21132 jghali 1583
        if (doc->appMode == modeEdit || doc->appMode == modeEditTable)
1584
                item->currentTextProps(doc->currentStyle);
1585
        else
1586
                doc->currentStyle.charStyle().setStyle(item->currentCharStyle());
18794 jghali 1587
        emit TextStyle(doc->currentStyle);
1588
        // to go: (av)
23282 craig 1589
        contentPalette->update(doc->currentStyle);
18794 jghali 1590
        //check if mark in cursor place and enable editMark action
1591
        if (doc->appMode == modeEdit && item->itemText.cursorPosition() < item->itemText.length())
1592
        {
18920 craig 1593
                if (item->itemText.hasMark(item->itemText.cursorPosition()))
17826 craig 1594
                {
18920 craig 1595
                        Mark* mark = item->itemText.mark(item->itemText.cursorPosition());
18794 jghali 1596
                        scrActions["editMark"]->setEnabled(true);
22516 craig 1597
                        if ((mark->isType(MARKNoteMasterType) || mark->isType(MARKNoteFrameType)) && (mark->getNotePtr() != nullptr))
18920 craig 1598
                                nsEditor->setNotesStyle(mark->getNotePtr()->notesStyle());
17826 craig 1599
                }
18794 jghali 1600
                else
1601
                        scrActions["editMark"]->setEnabled(false);
5800 fschmid 1602
        }
1603
}
1604
 
1605
//Special keys assigned to actions are stolen by the action and not passed to
1606
//keyPressEvent so process them here.
19100 craig 1607
void ScribusMainWindow::specialActionKeyEvent(int unicodevalue)
5800 fschmid 1608
{
19581 craig 1609
        if (!HaveDoc)
1610
                return;
22268 craig 1611
        if (doc->m_Selection->count() != 1)
1612
                return;
22893 jghali 1613
        if ((doc->appMode != modeEdit) && (doc->appMode != modeEditTable))
1614
                return;
1615
 
22268 craig 1616
        PageItem* selItem = doc->m_Selection->itemAt(0);
22893 jghali 1617
        if (!selItem->isTextFrame() && !selItem->isTable())
1618
                return;
1619
 
1620
        PageItem_TextFrame *currItem;
1621
        if (doc->appMode == modeEditTable)
1622
                currItem = selItem->asTable()->activeCell().textFrame();
1623
        else
1624
                currItem = selItem->asTextFrame();
1625
        if (currItem == nullptr)
1626
                return;
1627
 
1628
        if (unicodevalue!=-1)
5800 fschmid 1629
        {
22893 jghali 1630
                UndoTransaction activeTransaction;
1631
                if (currItem->HasSel)
5800 fschmid 1632
                {
22893 jghali 1633
                        if (UndoManager::undoEnabled())
23943 jghali 1634
                                activeTransaction = m_undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ReplaceText, QString(), Um::IDelete);
22893 jghali 1635
                        currItem->deleteSelectedTextFromFrame();
1636
                }
1637
                if (UndoManager::undoEnabled())
1638
                {
1639
                        SimpleState *ss = dynamic_cast<SimpleState*>(m_undoManager->getLastUndo());
23553 jghali 1640
                        UndoObject *undoTarget = currItem;
1641
                        if (ss && (ss->get("ETEA") == "insert_frametext") && (ss->undoObject() == undoTarget))
1642
                                ss->set("TEXT_STR", ss->get("TEXT_STR") + QString(QChar(unicodevalue)));
22894 jghali 1643
                        else
1644
                        {
23943 jghali 1645
                                ss = new SimpleState(Um::InsertText, QString(), Um::ICreate);
22893 jghali 1646
                                ss->set("INSERT_FRAMETEXT");
1647
                                ss->set("ETEA", QString("insert_frametext"));
1648
                                ss->set("TEXT_STR", QString(QChar(unicodevalue)));
1649
                                ss->set("START", currItem->itemText.cursorPosition());
1650
                                if (currItem->isNoteFrame())
5800 fschmid 1651
                                {
22893 jghali 1652
                                        undoTarget = doc;
1653
                                        ss->set("noteframeName", currItem->getUName());
22268 craig 1654
                                }
22893 jghali 1655
                                m_undoManager->action(undoTarget, ss);
22268 craig 1656
                        }
22893 jghali 1657
                }
1658
                currItem->itemText.insertChars(QString(QChar(unicodevalue)), true);
1659
                if (activeTransaction)
1660
                        activeTransaction.commit();
1661
        }
22894 jghali 1662
        else if (unicodevalue == SpecialChars::SHYPHEN.unicode()) //ignore the char as we use an attribute if the text item, for now.
22893 jghali 1663
        {
1664
                // this code is currently dead since unicodeSoftHyphen
1665
                // doesn't have unicodevalue == -1 any more
1666
                if (currItem->itemText.cursorPosition() <= 1)
1667
                        return;
1668
#if 0
1669
                StyleFlag fl = currItem->itemText.item(qMax(currItem->CPos-1,0))->effects();
1670
                fl |= ScStyle_HyphenationPossible;
1671
                currItem->itemText.item(qMax(currItem->CPos-1,0))->setEffects(fl);
1672
#else
1673
                if (UndoManager::undoEnabled())
1674
                {
1675
                        SimpleState *ss = dynamic_cast<SimpleState*>(m_undoManager->getLastUndo());
23553 jghali 1676
                        UndoObject *undoTarget = currItem;
1677
                        if (ss && (ss->get("ETEA") == "insert_frametext") && (ss->undoObject() == undoTarget))
1678
                                ss->set("TEXT_STR", ss->get("TEXT_STR") + QString(SpecialChars::SHYPHEN));
22893 jghali 1679
                        else
22268 craig 1680
                        {
23943 jghali 1681
                                ss = new SimpleState(Um::InsertText, QString(), Um::ICreate);
22893 jghali 1682
                                ss->set("INSERT_FRAMETEXT");
1683
                                ss->set("ETEA", QString("insert_frametext"));
1684
                                ss->set("TEXT_STR", QString(SpecialChars::SHYPHEN));
1685
                                ss->set("START", currItem->itemText.cursorPosition());
1686
                                if (currItem->isNoteFrame())
22268 craig 1687
                                {
22893 jghali 1688
                                        undoTarget = doc;
1689
                                        ss->set("noteframeName", currItem->getUName());
5800 fschmid 1690
                                }
22893 jghali 1691
                                m_undoManager->action(undoTarget, ss);
5800 fschmid 1692
                        }
1693
                }
22893 jghali 1694
                currItem->itemText.insertChars(QString(SpecialChars::SHYPHEN), true);
1695
#endif
5800 fschmid 1696
        }
22893 jghali 1697
        if (doc->appMode == modeEditTable)
1698
                selItem->asTable()->update();
1699
        else
1700
                currItem->update();
5800 fschmid 1701
}
1702
 
1703
bool ScribusMainWindow::eventFilter( QObject* /*o*/, QEvent *e )
1704
{
9562 fschmid 1705
        if (e->type() == QEvent::ToolTip)
23060 craig 1706
                return (!m_prefsManager.appPrefs.displayPrefs.showToolTips);
23963 jghali 1707
 
23960 craig 1708
        bool retVal = false;
23963 jghali 1709
        if (e->type() == QEvent::KeyPress)
11893 cbradney 1710
        {
22289 craig 1711
                QKeyEvent *k = dynamic_cast<QKeyEvent *>(e);
22313 craig 1712
                if (!k)
1713
                        return false;
5800 fschmid 1714
                int keyMod=0;
10390 cbradney 1715
                if (k->modifiers() & Qt::ShiftModifier)
8523 cbradney 1716
                        keyMod |= Qt::SHIFT;
10390 cbradney 1717
                if (k->modifiers() & Qt::ControlModifier)
8523 cbradney 1718
                        keyMod |= Qt::CTRL;
10390 cbradney 1719
                if (k->modifiers() & Qt::AltModifier)
8523 cbradney 1720
                        keyMod |= Qt::ALT;
5800 fschmid 1721
 
24715 jghali 1722
                QKeySequence currKeySeq(k->key() | keyMod);
18194 fschmid 1723
                if (QString(currKeySeq.toString()).isNull())
1724
                        return false;
23963 jghali 1725
                retVal = true;
5800 fschmid 1726
                //Palette actions
19304 craig 1727
                if (actionManager->compareKeySeqToShortcut(currKeySeq, "specialToggleAllPalettes"))
8613 cbradney 1728
                        scrActions["specialToggleAllPalettes"]->activate(QAction::Trigger);
23963 jghali 1729
                else if (actionManager->compareKeySeqToShortcut(currKeySeq, "specialToggleAllGuides"))
15302 cbradney 1730
                        scrActions["specialToggleAllGuides"]->activate(QAction::Trigger);
1731
                else
23963 jghali 1732
                        retVal = false;
5800 fschmid 1733
        }
23963 jghali 1734
        else if (e->type() == QEvent::KeyRelease)
23960 craig 1735
        {
1736
                QKeyEvent *k = dynamic_cast<QKeyEvent *>(e);
1737
                if (!k)
1738
                        return false;
1739
#if defined(Q_OS_MAC)
23963 jghali 1740
                if ((k->key() == Qt::Key_QuoteLeft) && (k->modifiers() & Qt::ControlModifier))
23960 craig 1741
                {
1742
                        if (k->modifiers() & Qt::ShiftModifier)
1743
                                mdiArea->activatePreviousSubWindow();
1744
                        else
1745
                                mdiArea->activateNextSubWindow();
23963 jghali 1746
                        retVal = true;
23960 craig 1747
                }
1748
#endif
1749
        }
5800 fschmid 1750
        //Return false to pass event to object
1751
        return retVal;
1752
}
1753
 
10532 avox 1754
 
16546 jghali 1755
void ScribusMainWindow::inputMethodEvent ( QInputMethodEvent * event )
1756
{
17761 jghali 1757
        //qDebug() << "IMEmw" << event->commitString() << event->preeditString() << "attributes:" << event->attributes().count();
16546 jghali 1758
}
1759
 
1760
QVariant ScribusMainWindow::inputMethodQuery ( Qt::InputMethodQuery query ) const
1761
{
17761 jghali 1762
        //qDebug() << "IMQmw" << query;
16546 jghali 1763
        return QVariant();
1764
}
1765
 
10532 avox 1766
//AV -> CanvasMode
5800 fschmid 1767
void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
1768
{
24441 jghali 1769
        if (HaveDoc && view && (view->hasFocus() || view->widget()->hasFocus()))
7435 fschmid 1770
        {
24003 jghali 1771
                view->canvasMode()->keyPressEvent(k);
5800 fschmid 1772
                return;
1773
        }
11960 subik 1774
 
24003 jghali 1775
        QMainWindow::keyPressEvent(k);
1776
}
11960 subik 1777
 
5800 fschmid 1778
void ScribusMainWindow::keyReleaseEvent(QKeyEvent *k)
1779
{
24441 jghali 1780
        if (HaveDoc && view && (view->hasFocus() || view->widget()->hasFocus()))
5800 fschmid 1781
        {
24003 jghali 1782
                view->canvasMode()->keyReleaseEvent(k);
5800 fschmid 1783
                return;
1784
        }
24003 jghali 1785
 
1786
        QMainWindow::keyReleaseEvent(k);
5800 fschmid 1787
}
24003 jghali 1788
 
10859 cbradney 1789
void ScribusMainWindow::changeEvent(QEvent *e)
1790
{
1791
        if (e->type() == QEvent::LanguageChange)
1792
                languageChange();
10903 cbradney 1793
        else
24003 jghali 1794
                QMainWindow::changeEvent(e);
10859 cbradney 1795
}
1796
 
5800 fschmid 1797
void ScribusMainWindow::closeEvent(QCloseEvent *ce)
1798
{
13487 cbradney 1799
        //Do not quit if Preferences or new doc window is open
14658 cbradney 1800
        PreferencesDialog *prefsDialog = findChild<PreferencesDialog *>(QString::fromLocal8Bit("PreferencesDialog"));
23361 jghali 1801
        NewDocDialog *newDocWin = findChild<NewDocDialog *>(QString::fromLocal8Bit("NewDocumentWindow"));
23648 jghali 1802
        if (prefsDialog != nullptr || newDocWin != nullptr)
13478 cbradney 1803
        {
1804
                ce->ignore();
1805
                return;
1806
        }
25058 jghali 1807
 
1808
        disconnect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(newActWin(QMdiSubWindow*)));
1809
 
13959 jghali 1810
        QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
5800 fschmid 1811
        if (!windows.isEmpty())
1812
        {
25058 jghali 1813
                ScribusWin* tw { nullptr };
24003 jghali 1814
                int windowCount = windows.count();
22268 craig 1815
                for ( int i = 0; i < windowCount; ++i )
5800 fschmid 1816
                {
14010 fschmid 1817
                        QMdiSubWindow *tws = windows.at(i);
1818
                        ScribusWin* scw = dynamic_cast<ScribusWin *>(tws->widget());
25058 jghali 1819
                        if (!scw)
1820
                                continue;
1821
 
1822
                        newActWin(windows.at(i));
1823
                        tw = ActWin;
1824
                        slotSelect();
1825
                        tws->close();
1826
                        if (tw == ActWin)
5800 fschmid 1827
                        {
25058 jghali 1828
                                ce->ignore();
1829
                                connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(newActWin(QMdiSubWindow*)));
1830
                                return;
5800 fschmid 1831
                        }
1832
                }
1833
        }
15260 cbradney 1834
        fileToolBar->connectPrefsSlot(false);
1835
        editToolBar->connectPrefsSlot(false);
1836
        modeToolBar->connectPrefsSlot(false);
1837
        pdfToolBar->connectPrefsSlot(false);
21040 fschmid 1838
 
23060 craig 1839
        m_prefsManager.appPrefs.uiPrefs.tabbedPalettes.clear();
21040 fschmid 1840
        QList<QTabBar *> bars = findChildren<QTabBar *>(QString());
1841
        for (int i = 0; i < bars.count(); ++i)
1842
        {
1843
                QTabBar *bar = bars[i];
21043 fschmid 1844
                tabPrefs currentTab;
21040 fschmid 1845
                for (int ii = 0; ii < bar->count(); ii++)
1846
                {
21043 fschmid 1847
                        currentTab.activeTab = bar->currentIndex();
21040 fschmid 1848
                        QObject *obj = (QObject*)bar->tabData(ii).toULongLong();
22516 craig 1849
                        if (obj != nullptr)
21043 fschmid 1850
                                currentTab.palettes.append(obj->objectName());
21040 fschmid 1851
                }
21043 fschmid 1852
                if (!currentTab.palettes.isEmpty())
23060 craig 1853
                        m_prefsManager.appPrefs.uiPrefs.tabbedPalettes.append(currentTab);
21040 fschmid 1854
        }
1855
 
5800 fschmid 1856
        propertiesPalette->hide();
23282 craig 1857
        contentPalette->hide();
5800 fschmid 1858
        outlinePalette->hide();
1859
        scrapbookPalette->hide();
1860
        bookmarkPalette->hide();
19783 craig 1861
        downloadsPalette->hide();
5800 fschmid 1862
        layerPalette->hide();
1863
        pagePalette->hide();
1864
        docCheckerPalette->hide();
1865
        undoPalette->hide();
1866
        alignDistributePalette->hide();
1867
        guidePalette->hide();
7087 subik 1868
        charPalette->hide();
15060 fschmid 1869
        symbolPalette->hide();
17405 fschmid 1870
        inlinePalette->hide();
5800 fschmid 1871
 
1872
        // Clean up plugins, THEN save prefs to disk
1873
        ScCore->pluginManager->cleanupPlugins();
23060 craig 1874
        if (!m_prefsManager.appPrefs.scrapbookPrefs.persistentScrapbook)
23035 jghali 1875
                scrapbookPalette->cleanUpTemp();
23060 craig 1876
        m_prefsManager.appPrefs.scrapbookPrefs.RecentScrapbooks.clear();
1877
        m_prefsManager.appPrefs.scrapbookPrefs.RecentScrapbooks = scrapbookPalette->getOpenScrapbooks();
5800 fschmid 1878
        if (!emergencyActivated)
24226 jghali 1879
                m_prefsManager.savePrefs();
5800 fschmid 1880
        UndoManager::deleteInstance();
10181 cbradney 1881
        FormatsManager::deleteInstance();
18181 fschmid 1882
//      qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
18646 jghali 1883
        ce->accept();
5800 fschmid 1884
}
1885
 
16546 jghali 1886
void ScribusMainWindow::requestUpdate(int val)
1887
{
1888
        emit UpdateRequest(val);
1889
}
1890
 
5800 fschmid 1891
/////////////////////////////////////////////////////////////////////
1892
// SLOT IMPLEMENTATION
1893
/////////////////////////////////////////////////////////////////////
1894
 
24003 jghali 1895
/*
5800 fschmid 1896
bool ScribusMainWindow::arrowKeyDown()
1897
{
23954 jghali 1898
        return m_arrowKeyDown;
5800 fschmid 1899
}
24003 jghali 1900
*/
5800 fschmid 1901
 
21098 fschmid 1902
QStringList ScribusMainWindow::findRecoverableFile()
1903
{
1904
        QSet<QString> foundFiles;
22268 craig 1905
        QDir::SortFlags sortflags = QDir::Name | QDir::Time;
1906
        QDir::Filters filterflags = QDir::Files | QDir::NoSymLinks | QDir::NoDot | QDir::NoDotDot;
23060 craig 1907
        if (!m_prefsManager.appPrefs.docSetupPrefs.AutoSaveDir.isEmpty())
21098 fschmid 1908
        {
23060 craig 1909
                QDir dirAuto(m_prefsManager.appPrefs.docSetupPrefs.AutoSaveDir, "*_emergency_*.sla", sortflags, filterflags);
21098 fschmid 1910
                QFileInfoList aList = dirAuto.entryInfoList();
1911
                if (aList.count() > 0)
1912
                {
22268 craig 1913
                        for (int i = 0; i < aList.count(); i++)
1914
                                foundFiles.insert(aList[i].absoluteFilePath());
21098 fschmid 1915
                }
23060 craig 1916
                QDir dirAuto2(m_prefsManager.appPrefs.docSetupPrefs.AutoSaveDir, "*_autosave_*.sla", sortflags, filterflags);
21098 fschmid 1917
                QFileInfoList aList2 = dirAuto2.entryInfoList();
1918
                if (aList2.count() > 0)
1919
                {
22268 craig 1920
                        for (int i = 0; i < aList2.count(); i++)
1921
                                foundFiles.insert(aList2[i].absoluteFilePath());
21098 fschmid 1922
                }
1923
        }
23060 craig 1924
        QDir dirDoc(m_prefsManager.documentDir(), "*_emergency_*.sla", sortflags, filterflags);
21098 fschmid 1925
        QFileInfoList dList = dirDoc.entryInfoList();
22268 craig 1926
        for (int i = 0; i < dList.count(); i++)
1927
                foundFiles.insert(dList[i].absoluteFilePath());
1928
 
23060 craig 1929
        QDir dirDoc2(m_prefsManager.documentDir(), "*_autosave_*.sla", sortflags, filterflags);
21098 fschmid 1930
        QFileInfoList dList2 = dirDoc2.entryInfoList();
22268 craig 1931
        for (int i = 0; i < dList2.count(); i++)
1932
                foundFiles.insert(dList2[i].absoluteFilePath());
1933
 
1934
        QDir dirHome(QDir::toNativeSeparators(QDir::homePath()), "*_emergency_*.sla", sortflags, filterflags);
21098 fschmid 1935
        QFileInfoList hList = dirHome.entryInfoList();
22268 craig 1936
        for (int i = 0; i < hList.count(); i++)
1937
                foundFiles.insert(hList[i].absoluteFilePath());
1938
 
1939
        QDir dirHome2(QDir::toNativeSeparators(QDir::homePath()), "*_autosave_*.sla", sortflags, filterflags);
21098 fschmid 1940
        QFileInfoList hList2 = dirHome2.entryInfoList();
22268 craig 1941
        for (int i = 0; i < hList2.count(); i++)
1942
                foundFiles.insert(hList2[i].absoluteFilePath());
1943
 
23861 jghali 1944
        return foundFiles.values();
21098 fschmid 1945
}
1946
 
22635 craig 1947
bool ScribusMainWindow::recoverFile(const QStringList& foundFiles)
21098 fschmid 1948
{
1949
        appModeHelper->setStartupActionsEnabled(false);
21120 fschmid 1950
        bool ret = false;
21098 fschmid 1951
        RecoverDialog* dia = new RecoverDialog(this, foundFiles);
1952
        if (dia->exec())
1953
        {