Rev 19157 |
Rev 19188 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
scribus.cpp - description
-------------------
begin : Fre Apr 6 21:09:31 CEST 2001
copyright : (C) 2001 by Franz Schmid
email : Franz.Schmid@altmuehlnet.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QAction>
#include <QApplication>
#include <QByteArray>
#include <QCloseEvent>
#include <QColor>
#include <QColorDialog>
#include <QCursor>
#include <QDesktopWidget>
#include <QDrag>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QEvent>
#include <QEventLoop>
#include <QFileDialog>
#include <QFrame>
#include <QFont>
#include <QIcon>
#include <QInputDialog>
#include <QKeyEvent>
#include <QKeySequence>
#include <QLabel>
#include <QList>
#include <QLocale>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QMessageBox>
#include <QMouseEvent>
#include <QPixmap>
#include <QProgressBar>
#include <QPushButton>
//<<QML testing
#include <QHBoxLayout>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlComponent>
#include <QQuickItem>
#include <QQmlProperty>
//>>
#include <QRegExp>
#include <QScopedPointer>
#include <QStyleFactory>
#include <QTableWidget>
#include <QTextCodec>
#include <QToolButton>
#include <QTranslator>
#include <QWheelEvent>
#ifdef DEBUG_LOAD_TIMES
#include <QDebug>
#include <QTime>
#include <sys/times.h>
#endif
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include "scconfig.h"
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <iostream>
#include <sstream>
#include <signal.h>
#include <string>
#include "actionmanager.h"
#include "appmodes.h"
#include "canvasmode.h"
#include "canvasmode_imageimport.h"
#include "commonstrings.h"
#include "desaxe/digester.h"
#include "desaxe/saxXML.h"
#include "desaxe/simple_actions.h"
#include "docinfo.h"
#include "documentchecker.h"
#include "documentinformation.h"
#include "fileloader.h"
#include "filewatcher.h"
#include "fpoint.h"
#include "fpointarray.h"
#include "gtgettext.h"
#include "hyphenator.h"
#include "langmgr.h"
#include "loadsaveplugin.h"
#include "marks.h"
#include "nfttemplate.h"
#include "notesstyles.h"
#include "pageitem_group.h"
#include "pageitem_imageframe.h"
#include "pageitem_latexframe.h"
#include "pageitem_noteframe.h"
#include "pageitem_table.h"
#include "pageitem_textframe.h"
#include "pagesize.h"
#include "pdflib.h"
#include "pdfoptions.h"
#include "pluginmanager.h"
#include "plugins/formatidlist.h"
#include "plugins/formatidlist.h"
#include "prefscontext.h"
#include "prefsfile.h"
#include "prefsmanager.h"
#include "prefstable.h"
#include "pslib.h"
#include "resourcecollection.h"
#include "sccolorengine.h"
#include "scgtplugin.h"
#include "scimagecachemanager.h"
#include "scmimedata.h"
#include "scpage.h"
#include "scpaths.h"
#include "scprintengine_ps.h"
#include "scraction.h"
#include "scribusXml.h"
#include "scribusapp.h"
#include "scribuscore.h"
#include "scribusdoc.h"
#include "scribusview.h"
#include "scribuswin.h"
#include "selection.h"
#include "serializer.h"
#include "styleoptions.h"
#include "tocgenerator.h"
#include "ui/about.h"
#include "ui/aboutplugins.h"
#include "ui/adjustcmsdialog.h"
#include "ui/aligndistribute.h"
#include "ui/annot.h"
#include "ui/annota.h"
#include "ui/applytemplatedialog.h"
#include "ui/arrowchooser.h"
#include "ui/autoform.h"
#include "ui/basepointwidget.h"
#include "ui/bookmarkpalette.h"
#include "ui/charselect.h"
#include "ui/checkDocument.h"
#include "ui/collectforoutput_ui.h"
#include "ui/colorcombo.h"
#include "ui/contextmenu.h"
#include "ui/copypagetomasterpagedialog.h"
#include "ui/cpalette.h"
#include "ui/customfdialog.h"
#include "ui/delpages.h"
#include "ui/edittoolbar.h"
#include "ui/effectsdialog.h"
#include "ui/filetoolbar.h"
#include "ui/fontcombo.h"
#include "ui/guidemanager.h"
#include "ui/helpbrowser.h"
#include "ui/hruler.h"
#include "ui/imageinfodialog.h"
#include "ui/inlinepalette.h"
#include "ui/insertaframe.h"
#include "ui/inspage.h"
#include "ui/javadocs.h"
#include "ui/layers.h"
#include "ui/loremipsum.h"
#include "ui/margindialog.h"
#include "ui/marginwidget.h"
#include "ui/mark2item.h"
#include "ui/mark2mark.h"
#include "ui/markanchor.h"
#include "ui/markinsert.h"
#include "ui/marknote.h"
#include "ui/marksmanager.h"
#include "ui/markvariabletext.h"
#include "ui/masterpagepalette.h"
#include "ui/mergedoc.h"
#include "ui/modetoolbar.h"
#include "ui/movepage.h"
#include "ui/multipleduplicate.h"
#include "ui/newfile.h"
#include "ui/newtemp.h"
#include "ui/nftdialog.h"
#include "ui/nftwidget.h"
#include "ui/nodeeditpalette.h"
#include "ui/notesstyleseditor.h"
#include "ui/outlinepalette.h"
#include "ui/pageitemattributes.h"
#include "ui/pagelayout.h"
#include "ui/pagepalette.h"
#include "ui/pageselector.h"
#include "ui/paintmanager.h"
#include "ui/pdfopts.h"
#include "ui/pdftoolbar.h"
#include "ui/picstatus.h"
#include "ui/polygonwidget.h"
#include "ui/preferencesdialog.h"
#include "ui/preview.h"
#include "ui/printdialog.h"
#include "ui/propertiespalette.h"
#include "ui/propertiespalette_image.h"
#include "ui/propertiespalette_line.h"
#include "ui/propertiespalette_shape.h"
#include "ui/propertiespalette_text.h"
#include "ui/propertiespalette_xyz.h"
#include "ui/query.h"
#include "ui/replacecolors.h"
#include "ui/sccombobox.h"
#include "ui/scfilewidget.h"
#include "ui/scmessagebox.h"
#include "ui/scmwmenumanager.h"
#include "ui/scrapbookpalette.h"
#include "ui/scrspinbox.h"
#include "ui/search.h"
#include "ui/selectobjects.h"
#include "ui/smcellstyle.h"
#include "ui/smlinestyle.h"
#include "ui/smtablestyle.h"
#include "ui/smtextstyles.h"
#include "ui/splash.h"
#include "ui/storyeditor.h"
#include "ui/stylemanager.h"
#include "ui/symbolpalette.h"
#include "ui/tabmanager.h"
#include "ui/transformdialog.h"
#include "ui/transparencypalette.h"
#include "ui/viewtoolbar.h"
#include "ui/vruler.h"
#include "ui_nftdialog.h"
#include "undogui.h"
#include "undomanager.h"
#include "undostate.h"
#include "units.h"
#include "urllauncher.h"
#include "util.h"
#include "util_formats.h"
#include "util_ghostscript.h"
#include "util_icon.h"
#include "util_math.h"
#ifdef HAVE_OSG
#include "ui/osgeditor.h"
#include <osgDB/ReaderWriter>
#include <osgDB/PluginQuery>
#endif
#if defined(_WIN32)
#include "scdocoutput_ps2.h"
#include "scprintengine_gdi.h"
#endif
#include "sclimits.h"
using namespace std;
bool previewDinUse;
bool printDinUse;
QString DocDir;
extern ScribusQApp* ScQApp;
extern bool emergencyActivated;
ScribusMainWindow::ScribusMainWindow()
{
actionManager=0;
scrMenuMgr=0;
prefsManager=0;
formatsManager=0;
UrlLauncher::instance();
mainWindowStatusLabel=0;
ExternalApp=0;
#ifdef Q_OS_MAC
ScQApp->setAttribute(Qt::AA_DontShowIconsInMenus);
noIcon = loadIcon("noicon.xpm");
#endif
}
/*
static QCoreApplication::EventFilter origEventFilter = 0;
bool reportFocusChanges(void *message, long *result)
{
unsigned* data = static_cast<unsigned*>(message);
if (QApplication::focusWidget())
qDebug() << QApplication::applicationFilePath() << reinterpret_cast<void*>(QApplication::focusWidget()) << typeid(*QApplication::focusWidget()).name() << QApplication::focusWidget()->objectName() << message << data[0] << data[1] << data[2] << data[3] << data[4] << data[5] << data[6] << data[7];
else
qDebug() << QApplication::applicationFilePath() << "no focus" << message << data[0] << data[1] << data[2] << data[3] << data[4] << data[5] << data[6] << data[7];
return origEventFilter && origEventFilter(message, result);
}
*/
/*
* retval 0 - ok, 1 - no fonts, ...
*/
int ScribusMainWindow::initScMW(bool primaryMainWindow)
{
int retVal=0;
qsrand(1234);
QByteArray stylesheet;
if (loadRawText(ScPaths::getApplicationDataDir() + "/stylesheet.css", stylesheet))
{
qApp->setStyleSheet(QString(stylesheet));
}
// origEventFilter = qApp->setEventFilter(reportFocusChanges);
previewDinUse = false;
printDinUse = false;
internalCopy = false;
internalCopyBuffer = "";
m_doc = new ScribusDoc();
m_doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
m_doc->setPage(100, 100, 0, 0, 0, 0, 0, 0, false, false);
m_doc->addPage(0);
m_doc->setGUI(false, this, 0);
CurrStED = NULL;
setWindowTitle( tr("Scribus " VERSION));
setAttribute(Qt::WA_KeyCompression, false);
setAttribute(Qt::WA_InputMethodEnabled, true);
setWindowIcon(loadIcon("AppIcon.png"));
setObjectName("MainWindow");
scrActionGroups.clear();
scrActions.clear();
scrRecentFileActions.clear();
scrRecentPasteActions.clear();
scrWindowsActions.clear();
scrLayersActions.clear();
scrScrapActions.clear();
actionManager = new ActionManager(this);
appModeHelper.setup(actionManager, &scrActions);
scrMenuMgr = new ScMWMenuManager(menuBar(), actionManager);
prefsManager = PrefsManager::instance();
formatsManager = FormatsManager::instance();
objectSpecificUndo = false;
undoManager = UndoManager::instance();
PrefsContext *undoPrefs = prefsManager->prefsFile->getContext("undo");
undoManager->setUndoEnabled(undoPrefs->getBool("enabled", true));
tocGenerator = new TOCGenerator();
m_marksCount = 0;
initDefaultValues();
initStatusBar();
qApp->processEvents();
actionManager->init(this);
// if (primaryMainWindow)
// ScCore->setSplashStatus( tr("Applying User Shortcuts") );
// prefsManager->applyLoadedShortCuts();
// initKeyboardShortcuts();
initMenuBar();
createMenuBar();
initToolBars();
ScCore->pluginManager->setupPluginActions(this);
ScCore->pluginManager->enableOnlyStartupPluginActions(this);
ScCore->pluginManager->languageChange();
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Applying User Shortcuts") );
prefsManager->applyLoadedShortCuts();
initKeyboardShortcuts();
resize(610, 600);
mdiArea = new QMdiArea(this);
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
if (prefsManager->appPrefs.uiPrefs.useTabs)
{
mdiArea->setViewMode(QMdiArea::TabbedView);
mdiArea->setTabsClosable(true);
mdiArea->setDocumentMode(true);
}
else
mdiArea->setViewMode(QMdiArea::SubWindowView);
setCentralWidget( mdiArea );
connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
//Connect windows cascade and tile actions to the workspace after its created. Only depends on mdiArea created.
connect( scrActions["windowsCascade"], SIGNAL(triggered()) , mdiArea, SLOT(cascadeSubWindows()) );
connect( scrActions["windowsTile"], SIGNAL(triggered()) , mdiArea, SLOT(tileSubWindows()) );
initPalettes();
prefsManager->setupMainWindow(this);
viewToolBar->previewQualitySwitcher->setCurrentIndex(prefsManager->appPrefs.itemToolPrefs.imageLowResType);
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Initializing Story Editor") );
storyEditor = new StoryEditor(this);
DocDir = prefsManager->documentDir();
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Initializing Languages") );
LanguageManager::instance();
QString preLang(prefsManager->appPrefs.hyphPrefs.Language);
initHyphenator();
if (!LanguageManager::instance()->getHyphFilename( preLang ).isEmpty() )
prefsManager->appPrefs.hyphPrefs.Language = preLang;
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Reading Scrapbook") );
initScrapbook();
scrActions["helpTooltips"]->setChecked(prefsManager->appPrefs.displayPrefs.showToolTips);
scrActions["showMouseCoordinates"]->setChecked(prefsManager->appPrefs.displayPrefs.showMouseCoordinates);
scrActions["stickyTools"]->setChecked(prefsManager->appPrefs.uiPrefs.stickyTools);
ToggleTips();
ToggleMouseTips();
propertiesPalette->setFontSize();
if (scrActions["SaveAsDocumentTemplate"])
scrActions["SaveAsDocumentTemplate"]->setEnabled(false);
connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString )), this, SLOT(removeRecentFromWatcher(QString)));
connect(ClipB, SIGNAL(dataChanged()), this, SLOT(ClipChange()));
setAcceptDrops(true);
QCoreApplication::instance()->installEventFilter(this);
scrActions["toolsSelect"]->setChecked(true);
ColorSetManager csm;
csm.findPaletteLocations();
csm.findPalettes();
csm.findUserPalettes();
QString Cpfad = QDir::toNativeSeparators(ScPaths::getApplicationDataDir())+"DefaultColors.xml";
QFile fc(Cpfad);
if (fc.exists())
csm.loadPalette(Cpfad, m_doc, prefsManager->appPrefs.colorPrefs.DColors, prefsManager->appPrefs.defaultGradients, prefsManager->appPrefs.defaultPatterns, false);
else
{
if (prefsManager->appPrefs.colorPrefs.DColorSet != "Scribus Small")
{
QStringList CustomColorSets = csm.userPaletteNames();
if (CustomColorSets.contains(prefsManager->appPrefs.colorPrefs.DColorSet))
Cpfad = csm.userPaletteFileFromName(prefsManager->appPrefs.colorPrefs.DColorSet);
else
Cpfad = csm.paletteFileFromName(prefsManager->appPrefs.colorPrefs.DColorSet);
if (!Cpfad.isEmpty())
csm.loadPalette(Cpfad, m_doc, prefsManager->appPrefs.colorPrefs.DColors, prefsManager->appPrefs.defaultGradients, prefsManager->appPrefs.defaultPatterns, false);
}
}
actionManager->setStartupActionsEnabled(false);
return retVal;
}
ScribusMainWindow::~ScribusMainWindow()
{
if (actionManager)
delete actionManager;
delete m_doc;
}
void ScribusMainWindow::addScToolBar(ScToolBar *tb, QString name)
{
if (!scrToolBars.contains(name))
scrToolBars.insert(name, tb);
addToolBar(tb);
}
void ScribusMainWindow::initToolBars()
{
fileToolBar = new FileToolBar(this);
editToolBar = new EditToolBar(this);
UndoWidget* uWidget = new UndoWidget(editToolBar, "uWidget");
undoManager->registerGui(uWidget);
modeToolBar = new ModeToolBar(this);
pdfToolBar = new PDFToolBar(this);
viewToolBar = new ViewToolBar(this);
addScToolBar(fileToolBar, fileToolBar->objectName());
addScToolBar(editToolBar, editToolBar->objectName());
addScToolBar(modeToolBar, modeToolBar->objectName());
addScToolBar(pdfToolBar, pdfToolBar->objectName());
addScToolBar(viewToolBar, viewToolBar->objectName());
connect(modeToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarTools"], SLOT(setChecked(bool)));
connect(scrActions["toolsToolbarPDF"], SIGNAL(toggled(bool)), pdfToolBar, SLOT(setVisible(bool)));
connect(pdfToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarPDF"], SLOT(setChecked(bool)));
connect(scrActions["toolsToolbarTools"], SIGNAL(toggled(bool)), modeToolBar, SLOT(setVisible(bool)) );
connect(viewToolBar, SIGNAL(visibilityChanged(bool)), scrActions["toolsToolbarView"], SLOT(setChecked(bool)));
connect(scrActions["toolsToolbarView"], SIGNAL(toggled(bool)), viewToolBar, SLOT(setVisible(bool)) );
}
void ScribusMainWindow::initDefaultValues()
{
HaveDoc = false;
ScriptRunning = 0;
view = NULL;
doc = NULL;
DocNr = 1;
PrinterUsed = false;
PDef.Pname = "";
PDef.Dname = "";
PDef.Command = "";
keyrep = false;
_arrowKeyDown = false;
ClipB = QApplication::clipboard();
palettesStatus[0] = false;
guidesStatus[0] = false;
#ifdef HAVE_OSG
QStringList supportedExts;
supportedExts << "osg" << "dxf" << "flt" << "ive" << "geo" << "sta" << "stl" << "logo" << "3ds" << "ac" << "obj";
QStringList realSupportedExts;
QMap<QString, QString> formats;
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
for(osgDB::FileNameList::iterator itr = plugins.begin(); itr != plugins.end(); ++itr)
{
osgDB::ReaderWriterInfoList infoList;
if (QString::fromStdString(*itr).contains("qfont"))
continue;
if (osgDB::queryPlugin(*itr, infoList))
{
for(osgDB::ReaderWriterInfoList::iterator rwi_itr = infoList.begin(); rwi_itr != infoList.end(); ++rwi_itr)
{
osgDB::ReaderWriterInfo& info = *(*rwi_itr);
osgDB::ReaderWriter::FormatDescriptionMap::iterator fdm_itr;
for(fdm_itr = info.extensions.begin(); fdm_itr != info.extensions.end(); ++fdm_itr)
{
if (supportedExts.contains(QString::fromStdString(fdm_itr->first)))
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() + ")");
}
}
}
}
realSupportedExts = formats.keys();
QString docexts = realSupportedExts.join(" ");
QStringList longList = formats.values();
QString longDesc = longList.join(";;") + ";;";
osgFilterString = tr("All Supported Formats (%1);;%2All Files (*)").arg(docexts).arg(longDesc);
#endif
}
void ScribusMainWindow::initKeyboardShortcuts()
{
for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrActions.begin(); it!=scrActions.end(); ++it )
{
if ((ScrAction*)(it.value())!=NULL)
{
QString accelerator = it.value()->shortcut().toString();
prefsManager->setKeyEntry(it.key(), it.value()->cleanMenuText(), accelerator,0);
}
//else
// qDebug() << it.key();
//qDebug() << QString("|-\n|%1||%2||%3").arg(it.key()).arg(it.value()->cleanMenuText()).arg(QString(it.data()->accel()));
}
}
void ScribusMainWindow::initPalettes()
{
//CB TODO hide the publicly available members of some palettes
// these must be filtered too as they take control of the palettes events
outlinePalette = new OutlinePalette(this);
outlinePalette->setMainWindow(this);
connect( scrActions["toolsOutline"], SIGNAL(toggled(bool)) , outlinePalette, SLOT(setPaletteShown(bool)) );
connect( outlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsOutline"], SLOT(setChecked(bool)));
propertiesPalette = new PropertiesPalette(this);
propertiesPalette->setMainWindow(this);
connect( scrActions["toolsProperties"], SIGNAL(toggled(bool)) , propertiesPalette, SLOT(setPaletteShown(bool)) );
connect( propertiesPalette, SIGNAL(paletteShown(bool)), scrActions["toolsProperties"], SLOT(setChecked(bool)));
emit UpdateRequest(reqDefFontListUpdate);
propertiesPalette->installEventFilter(this);
nodePalette = new NodePalette(this);
nodePalette->installEventFilter(this);
layerPalette = new LayerPalette(this);
guidePalette = new GuideManager(this);
charPalette = new CharSelect(this);
connect( scrActions["toolsLayers"], SIGNAL(toggled(bool)) , layerPalette, SLOT(setPaletteShown(bool)) );
connect( layerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsLayers"], SLOT(setChecked(bool)));
layerPalette->installEventFilter(this);
layerPalette->Table->installEventFilter(this);
scrapbookPalette = new Biblio(this);
connect( scrActions["toolsScrapbook"], SIGNAL(toggled(bool)) , scrapbookPalette, SLOT(setPaletteShown(bool)) );
connect( scrapbookPalette, SIGNAL(paletteShown(bool)), scrActions["toolsScrapbook"], SLOT(setChecked(bool)));
connect( scrapbookPalette, SIGNAL(pasteToActualPage(QString)), this, SLOT(pasteFromScrapbook(QString)));
connect( scrapbookPalette, SIGNAL(scrapbookListChanged()), this, SLOT(rebuildScrapbookMenu()));
scrapbookPalette->installEventFilter(this);
pagePalette = new PagePalette(this);
connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , pagePalette, SLOT(setPaletteShown(bool)) );
connect( pagePalette, SIGNAL(paletteShown(bool)), scrActions["toolsPages"], SLOT(setChecked(bool)));
pagePalette->installEventFilter(this);
bookmarkPalette = new BookPalette(this);
connect( scrActions["toolsBookmarks"], SIGNAL(toggled(bool)) , bookmarkPalette, SLOT(setPaletteShown(bool)) );
connect( bookmarkPalette, SIGNAL(paletteShown(bool)), scrActions["toolsBookmarks"], SLOT(setChecked(bool)));
bookmarkPalette->installEventFilter(this);
connect( scrActions["toolsMeasurements"], SIGNAL(toggledData(bool, int)) , this, SLOT(setAppModeByToggle(bool, int)) );
docCheckerPalette = new CheckDocument(this, false);
connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , docCheckerPalette, SLOT(setPaletteShown(bool)) );
connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , this, SLOT(docCheckToggle(bool)) );
connect( docCheckerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsPreflightVerifier"], SLOT(setChecked(bool)));
connect( docCheckerPalette, SIGNAL(paletteShown(bool)), this, SLOT(docCheckToggle(bool)));
docCheckerPalette->installEventFilter(this);
docCheckerPalette->hide();
alignDistributePalette = new AlignDistributePalette(this, "AlignDistributePalette");
connect( scrActions["toolsAlignDistribute"], SIGNAL(toggled(bool)) , alignDistributePalette, SLOT(setPaletteShown(bool)) );
connect( alignDistributePalette, SIGNAL(paletteShown(bool)), scrActions["toolsAlignDistribute"], SLOT(setChecked(bool)));
connect( alignDistributePalette, SIGNAL(documentChanged()), this, SLOT(slotDocCh()));
alignDistributePalette->installEventFilter(this);
symbolPalette = new SymbolPalette(this);
symbolPalette->setMainWindow(this);
connect(scrActions["toolsSymbols"], SIGNAL(toggled(bool)), symbolPalette, SLOT(setPaletteShown(bool)));
connect(symbolPalette, SIGNAL(paletteShown(bool)), scrActions["toolsSymbols"], SLOT(setChecked(bool)));
connect(symbolPalette, SIGNAL(startEdit(QString)), this, SLOT(editSymbolStart(QString)));
connect(symbolPalette, SIGNAL(endEdit()), this, SLOT(editSymbolEnd()));
connect(symbolPalette, SIGNAL(objectDropped()), this, SLOT(PutToPatterns()));
symbolPalette->installEventFilter(this);
symbolPalette->hide();
inlinePalette = new InlinePalette(this);
inlinePalette->setMainWindow(this);
connect(scrActions["toolsInline"], SIGNAL(toggled(bool)), inlinePalette, SLOT(setPaletteShown(bool)));
connect(inlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsInline"], SLOT(setChecked(bool)));
connect(inlinePalette, SIGNAL(startEdit(int)), this, SLOT(editInlineStart(int)));
connect(inlinePalette, SIGNAL(endEdit()), this, SLOT(editInlineEnd()));
connect(inlinePalette, SIGNAL(objectDropped(QString)), this, SLOT(PutToInline(QString)));
inlinePalette->installEventFilter(this);
inlinePalette->hide();
undoPalette = new UndoPalette(this, "undoPalette");
undoPalette->installEventFilter(this);
undoManager->registerGui(undoPalette);
connect(undoPalette, SIGNAL(paletteShown(bool)), this, SLOT(setUndoPalette(bool)));
connect(undoPalette, SIGNAL(objectMode(bool)), this, SLOT(setUndoMode(bool)));
// initializing style manager here too even it's not strictly a palette
styleManager = new StyleManager(this, "styleManager");
SMCharacterStyle *tmpCS = new SMCharacterStyle();
styleManager->addStyle(new SMParagraphStyle(tmpCS->tmpStyles()));
styleManager->addStyle(tmpCS);
styleManager->addStyle(new SMTableStyle());
styleManager->addStyle(new SMCellStyle());
styleManager->addStyle(new SMLineStyle());
connect( scrActions["editStyles"], SIGNAL(toggled(bool)), styleManager, SLOT(setPaletteShown(bool)) );
connect( styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setChecked(bool)));
styleManager->installEventFilter(this);
// initializing mark`s manager
marksManager = new MarksManager(this, "marksManager");
connect( scrActions["editMarks"], SIGNAL(toggled(bool)), marksManager, SLOT(setPaletteShown(bool)) );
connect( marksManager, SIGNAL(paletteShown(bool)), scrActions["editMarks"], SLOT(setChecked(bool)));
marksManager->installEventFilter(this);
// initializing notes styles manager
nsEditor = new NotesStylesEditor(this, "notesStylesEditor");
connect( scrActions["editNotesStyles"], SIGNAL(toggled(bool)), nsEditor, SLOT(setPaletteShown(bool)) );
connect( nsEditor, SIGNAL(paletteShown(bool)), scrActions["editNotesStyles"], SLOT(setChecked(bool)));
nsEditor->installEventFilter(this);
// connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(selectItemsFromOutlines(int, int)));
connect(docCheckerPalette, SIGNAL(selectElementByItem(PageItem *, bool)), this, SLOT(selectItemsFromOutlines(PageItem *, bool)));
connect(docCheckerPalette, SIGNAL(selectElement(PageItem *, bool, int)), this, SLOT(selectItemFromOutlines(PageItem *, bool, int)));
connect(docCheckerPalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
connect(docCheckerPalette, SIGNAL(selectMasterPage(QString)), this, SLOT(editMasterPagesStart(QString)));
// connect(outlinePalette, SIGNAL(selectElement(int, int, bool)), this, SLOT(selectItemsFromOutlines(int, int, bool)));
connect(outlinePalette, SIGNAL(selectElementByItem(PageItem *, bool)), this, SLOT(selectItemsFromOutlines(PageItem *, bool)));
connect(outlinePalette, SIGNAL(editElementByItem(PageItem *)), this, SLOT(editItemsFromOutlines(PageItem *)));
connect(outlinePalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
connect(outlinePalette, SIGNAL(selectMasterPage(QString)), this, SLOT(editMasterPagesStart(QString)));
// connect(propertiesPalette, SIGNAL(EditLSt()), this, SLOT(slotEditLineStyles()));
// connect(nodePalette, SIGNAL(paletteClosed()), propertiesPalette, SLOT(endEdit2()));
connect(nodePalette, SIGNAL(paletteClosed()), this, SLOT(slotSelect()));
connect(nodePalette, SIGNAL(DocChanged()), this, SLOT(slotDocCh()));
connect(layerPalette, SIGNAL(LayerChanged()), this, SLOT(showLayer()));
connect(bookmarkPalette->BView, SIGNAL(MarkMoved()), this, SLOT(StoreBookmarks()));
connect(bookmarkPalette->BView, SIGNAL(changed()), this, SLOT(slotDocCh()));
connect(bookmarkPalette->BView, SIGNAL(SelectElement(PageItem *, bool)), this, SLOT(selectItemsFromOutlines(PageItem *, bool)));
// guides
connect(scrActions["pageManageGuides"], SIGNAL(toggled(bool)), guidePalette, SLOT(setPaletteShown(bool)));
connect(guidePalette, SIGNAL(paletteShown(bool)), scrActions["pageManageGuides"], SLOT(setChecked(bool)));
// char palette
connect(scrActions["insertGlyph"], SIGNAL(toggled(bool)), charPalette, SLOT(setPaletteShown(bool)));
connect(charPalette, SIGNAL(paletteShown(bool)), scrActions["insertGlyph"], SLOT(setChecked(bool)));
}
void ScribusMainWindow::initScrapbook()
{
QString scrapbookFileO = QDir::toNativeSeparators(prefsManager->preferencesLocation()+"/scrap13.scs");
QFileInfo scrapbookFileInfoO = QFileInfo(scrapbookFileO);
if (scrapbookFileInfoO.exists())
{
scrapbookPalette->readOldContents(scrapbookFileO, QDir::toNativeSeparators(prefsManager->preferencesLocation()+"/scrapbook/main"));
QDir d = QDir();
d.rename(scrapbookFileO, QDir::toNativeSeparators(prefsManager->preferencesLocation()+"/scrap13.backup"));
}
QString scrapbookTemp = QDir::toNativeSeparators(prefsManager->preferencesLocation()+"/scrapbook/tmp");
QFileInfo scrapbookTempInfo = QFileInfo(scrapbookTemp);
if (scrapbookTempInfo.exists())
scrapbookPalette->readTempContents(scrapbookTemp);
QString scrapbookFile = QDir::toNativeSeparators(prefsManager->preferencesLocation()+"/scrapbook/main");
QFileInfo scrapbookFileInfo = QFileInfo(scrapbookFile);
if (scrapbookFileInfo.exists())
scrapbookPalette->readContents(scrapbookFile);
scrapbookPalette->setScrapbookFileName(scrapbookFile);
ScCore->fileWatcher->addDir(scrapbookFile, true);
scrapbookPalette->setOpenScrapbooks(prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks);
rebuildRecentPasteMenu();
connect(scrapbookPalette, SIGNAL(updateRecentMenue()), this, SLOT(rebuildRecentPasteMenu()));
connect(ScCore->fileWatcher, SIGNAL(dirChanged(QString )), scrapbookPalette, SLOT(reloadLib(QString )));
connect(ScCore->fileWatcher, SIGNAL(dirDeleted(QString )), scrapbookPalette, SLOT(closeOnDel(QString )));
}
bool ScribusMainWindow::warningVersion(QWidget *parent)
{
bool retval = false;
int t = QMessageBox::warning(parent, QObject::tr("Scribus Development Version"), "<qt>" +
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>",
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel);
if (t == QMessageBox::Ok)
retval = true;
return retval;
}
void ScribusMainWindow::initMenuBar()
{
RecentDocs.clear();
scrMenuMgr->createMenu("File", ActionManager::defaultMenuNameEntryTranslated("File"));
scrMenuMgr->addMenuItemString("fileNew", "File");
scrMenuMgr->addMenuItemString("fileNewFromTemplate", "File");
scrMenuMgr->addMenuItemString("fileOpen", "File");
scrMenuMgr->addMenuItemString("FileOpenRecent", "File");
scrMenuMgr->createMenu("FileOpenRecent", tr("Open &Recent"), "File", false, true);
scrMenuMgr->addMenuItemString("SEPARATOR", "File");
scrMenuMgr->addMenuItemString("fileClose", "File");
scrMenuMgr->addMenuItemString("fileSave", "File");
scrMenuMgr->addMenuItemString("fileSaveAs", "File");
scrMenuMgr->addMenuItemString("fileRevert", "File");
scrMenuMgr->addMenuItemString("fileCollect", "File");
scrMenuMgr->addMenuItemString("SEPARATOR", "File");
scrMenuMgr->createMenu("FileImport", tr("&Import"), "File");
scrMenuMgr->addMenuItemString("FileImport", "File");
scrMenuMgr->addMenuItemString("fileImportText", "FileImport");
scrMenuMgr->addMenuItemString("fileImportAppendText", "FileImport");
scrMenuMgr->addMenuItemString("fileImportImage", "FileImport");
scrMenuMgr->addMenuItemString("fileImportVector", "FileImport");
scrMenuMgr->addMenuItemString("FileExport", "File");
scrMenuMgr->createMenu("FileExport", tr("&Export"), "File");
scrMenuMgr->addMenuItemString("fileExportText", "FileExport");
scrMenuMgr->addMenuItemString("fileExportAsEPS", "FileExport");
scrMenuMgr->addMenuItemString("fileExportAsPDF", "FileExport");
scrMenuMgr->addMenuItemString("SEPARATOR", "File");
scrMenuMgr->addMenuItemString("fileDocSetup150", "File");
scrMenuMgr->addMenuItemString("filePreferences150", "File");
scrMenuMgr->addMenuItemString("SEPARATOR", "File");
scrMenuMgr->addMenuItemString("filePrint", "File");
if ( ScCore->haveGS() || ScCore->isWinGUI() )
scrMenuMgr->addMenuItemString("PrintPreview", "File");
scrMenuMgr->addMenuItemString("SEPARATOR", "File");
scrMenuMgr->addMenuItemString("fileQuit", "File");
scrMenuMgr->setMenuEnabled("FileImport", false);
scrMenuMgr->setMenuEnabled("FileExport", false);
scrMenuMgr->createMenu("Edit", ActionManager::defaultMenuNameEntryTranslated("Edit"));
scrMenuMgr->addMenuItemString("editUndoAction", "Edit");
scrMenuMgr->addMenuItemString("editRedoAction", "Edit");
scrMenuMgr->addMenuItemString("editActionMode", "Edit");
scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
scrMenuMgr->addMenuItemString("editCut", "Edit");
scrMenuMgr->addMenuItemString("editCopy", "Edit");
scrMenuMgr->addMenuItemString("editPaste", "Edit");
scrMenuMgr->createMenu("EditPasteRecent", tr("Paste Recent"), "Edit",false,true);
scrMenuMgr->createMenu("EditContents", tr("Contents"), "Edit");
scrMenuMgr->addMenuItemString("editCopyContents", "EditContents");
scrMenuMgr->addMenuItemString("editPasteContents", "EditContents");
scrMenuMgr->addMenuItemString("editPasteContentsAbs", "EditContents");
scrMenuMgr->addMenuItemString("editClearContents", "EditContents");
scrMenuMgr->addMenuItemString("itemDelete", "Edit");
scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
scrMenuMgr->addMenuItemString("editSelectAll", "Edit");
scrMenuMgr->addMenuItemString("editSelectAllOnLayer", "Edit");
scrMenuMgr->addMenuItemString("editDeselectAll", "Edit");
scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
scrMenuMgr->addMenuItemString("editSearchReplace", "Edit");
scrMenuMgr->addMenuItemString("toolsEditWithStoryEditor", "Edit");
scrMenuMgr->addMenuItemString("editEditWithImageEditor", "Edit");
scrMenuMgr->addMenuItemString("editEditRenderSource", "Edit");
scrMenuMgr->addMenuItemString("SEPARATOR", "Edit");
scrMenuMgr->addMenuItemString("editColors", "Edit");
scrMenuMgr->addMenuItemString("editReplaceColors", "Edit");
scrMenuMgr->addMenuItemString("editStyles", "Edit");
scrMenuMgr->addMenuItemString("editMarks", "Edit");
scrMenuMgr->addMenuItemString("editNotesStyles", "Edit");
scrMenuMgr->addMenuItemString("editMasterPages", "Edit");
scrMenuMgr->addMenuItemString("editJavascripts", "Edit");
scrMenuMgr->setMenuEnabled("EditPasteRecent", false);
scrMenuMgr->setMenuEnabled("EditContents", false);
//Item Menu
scrMenuMgr->createMenu("Item", ActionManager::defaultMenuNameEntryTranslated("Item"));
scrMenuMgr->createMenu("DuplicateTransform", tr("Duplicate/Transform"), "Item");
scrMenuMgr->addMenuItemString("DuplicateTransform", "Item");
scrMenuMgr->addMenuItemString("itemDuplicate", "DuplicateTransform");
scrMenuMgr->addMenuItemString("itemMulDuplicate", "DuplicateTransform");
scrMenuMgr->addMenuItemString("itemTransform", "DuplicateTransform");
scrMenuMgr->createMenu("Grouping", tr("Grouping"), "Item");
scrMenuMgr->addMenuItemString("Grouping", "Item");
scrMenuMgr->addMenuItemString("itemGroup", "Grouping");
scrMenuMgr->addMenuItemString("itemUngroup", "Grouping");
scrMenuMgr->addMenuItemString("itemGroupAdjust", "Grouping");
scrMenuMgr->createMenu("Locking", tr("Locking"), "Item");
scrMenuMgr->addMenuItemString("Locking", "Item");
scrMenuMgr->addMenuItemString("itemLock", "Locking");
scrMenuMgr->addMenuItemString("itemLockSize", "Locking");
scrMenuMgr->createMenu("ItemLevel", tr("Level"), "Item");
scrMenuMgr->addMenuItemString("ItemLevel", "Item");
scrMenuMgr->addMenuItemString("itemRaise", "ItemLevel");
scrMenuMgr->addMenuItemString("itemLower", "ItemLevel");
scrMenuMgr->addMenuItemString("itemRaiseToTop", "ItemLevel");
scrMenuMgr->addMenuItemString("itemLowerToBottom", "ItemLevel");
scrMenuMgr->createMenu("ItemLayer", tr("Send to La&yer"), "",false, true);
scrMenuMgr->addMenuItemString("ItemLayer", "Item");
scrMenuMgr->createMenu("SendTo", tr("Send to"), "Item");
scrMenuMgr->addMenuItemString("SendTo", "Item");
scrMenuMgr->createMenu("ItemSendToScrapbook", tr("Scrapbook"),"",false,true);
scrMenuMgr->addMenuItemString("ItemSendToScrapbook", "SendTo");
scrMenuMgr->addMenuItemString("itemSendToPattern", "SendTo");
scrMenuMgr->addMenuItemString("itemSendToInline", "SendTo");
scrMenuMgr->createMenu("Adjust", tr("Adjust"), "Item");
scrMenuMgr->addMenuItemString("Adjust", "Item");
scrMenuMgr->addMenuItemString("itemAdjustFrameHeightToText", "Adjust");
scrMenuMgr->addMenuItemString("itemAdjustFrameToImage", "Adjust");
scrMenuMgr->addMenuItemString("itemAdjustImageToFrame", "Adjust");
scrMenuMgr->createMenu("Image", tr("Image"), "Item");
scrMenuMgr->addMenuItemString("Image", "Item");
scrMenuMgr->addMenuItemString("itemUpdateImage", "Image");
scrMenuMgr->addMenuItemString("styleImageEffects", "Image");
scrMenuMgr->addMenuItemString("itemExtendedImageProperties", "Image");
scrMenuMgr->addMenuItemString("itemToggleInlineImage", "Image");
scrMenuMgr->createMenu("ItemPreviewSettings", tr("Preview Settings"), "Image");
scrMenuMgr->addMenuItemString("ItemPreviewSettings", "Image");
scrMenuMgr->addMenuItemString("itemImageIsVisible", "ItemPreviewSettings");
scrMenuMgr->addMenuItemString("SEPARATOR", "ItemPreviewSettings");
scrMenuMgr->addMenuItemString("itemPreviewLow", "ItemPreviewSettings");
scrMenuMgr->addMenuItemString("itemPreviewNormal", "ItemPreviewSettings");
scrMenuMgr->addMenuItemString("itemPreviewFull", "ItemPreviewSettings");
scrMenuMgr->createMenu("ItemPDFOptions", tr("&PDF Options"));
scrMenuMgr->addMenuItemString("ItemPDFOptions", "Item");
scrMenuMgr->addMenuItemString("itemPDFIsAnnotation", "ItemPDFOptions");
scrMenuMgr->addMenuItemString("itemPDFIsBookmark", "ItemPDFOptions");
scrMenuMgr->addMenuItemString("itemPDFAnnotationProps", "ItemPDFOptions");
scrMenuMgr->addMenuItemString("itemPDFFieldProps", "ItemPDFOptions");
scrMenuMgr->createMenu("ItemConvertTo", tr("C&onvert To"), "Item");
scrMenuMgr->addMenuItemString("ItemConvertTo", "Item");
scrMenuMgr->addMenuItemString("itemConvertToTextFrame", "ItemConvertTo");
scrMenuMgr->addMenuItemString("itemConvertToImageFrame", "ItemConvertTo");
scrMenuMgr->addMenuItemString("itemConvertToPolygon", "ItemConvertTo");
scrMenuMgr->addMenuItemString("itemConvertToBezierCurve", "ItemConvertTo");
scrMenuMgr->addMenuItemString("itemConvertToOutlines", "ItemConvertTo");
scrMenuMgr->addMenuItemString("itemConvertToSymbolFrame", "ItemConvertTo");
scrMenuMgr->createMenu("TextLinking", tr("Text Frame Links"), "Item");
scrMenuMgr->addMenuItemString("TextLinking", "Item");
scrMenuMgr->addMenuItemString("toolsLinkTextFrame", "TextLinking");
scrMenuMgr->addMenuItemString("toolsUnlinkTextFrame", "TextLinking");
scrMenuMgr->addMenuItemString("toolsUnlinkTextFrameWithTextCopy", "TextLinking");
scrMenuMgr->addMenuItemString("toolsUnlinkTextFrameWithTextCut", "TextLinking");
scrMenuMgr->createMenu("ItemPathOps", tr("Path Tools"), "Item");
scrMenuMgr->addMenuItemString("ItemPathOps", "Item");
scrMenuMgr->addMenuItemString("itemCombinePolygons", "ItemPathOps");
scrMenuMgr->addMenuItemString("itemSplitPolygons", "ItemPathOps");
scrMenuMgr->addMenuItemString("itemAttachTextToPath", "ItemPathOps");
scrMenuMgr->addMenuItemString("itemDetachTextFromPath", "ItemPathOps");
scrActions["itemPrintingEnabled"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
scrMenuMgr->createMenu("Weld", tr("Welding"), "Item");
scrMenuMgr->addMenuItemString("Weld", "Item");
scrMenuMgr->addMenuItemString("itemWeld", "Weld");
scrMenuMgr->addMenuItemString("itemsUnWeld", "Weld");
scrMenuMgr->addMenuItemString("itemEditWeld", "Weld");
scrMenuMgr->addMenuItemString("editMark", "Item");
//Insert menu
scrMenuMgr->createMenu("Insert", ActionManager::defaultMenuNameEntryTranslated("Insert"));
scrMenuMgr->addMenuItemString("insertFrame", "Insert");
scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertTextFrame", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertImageFrame", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertRenderFrame", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertTable", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertShape", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertPolygon", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertArc", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertSpiral", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertLine", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertBezier", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertFreehandLine", "Insert");
scrMenuMgr->addMenuItemString("toolsInsertCalligraphicLine", "Insert");
scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
scrMenuMgr->addMenuItemString("stickyTools", "Insert");
scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
scrMenuMgr->addMenuItemString("insertGlyph", "Insert");
scrMenuMgr->createMenu("InsertChar", tr("&Character"), "Insert");
scrMenuMgr->addMenuItemString("InsertChar", "Insert");
scrMenuMgr->addMenuItemString("unicodePageNumber", "InsertChar");
scrMenuMgr->addMenuItemString("unicodePageCount", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeSoftHyphen", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeNonBreakingHyphen", "InsertChar");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeCopyRight", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeRegdTM", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeTM", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeSolidus", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeBullet", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeMidpoint", "InsertChar");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeDashEm", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeDashEn", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeDashFigure", "InsertChar");
scrMenuMgr->addMenuItemString("unicodeDashQuotation", "InsertChar");
scrMenuMgr->createMenu("InsertQuote", tr("&Quote"), "Insert");
scrMenuMgr->addMenuItemString("InsertQuote", "Insert");
scrMenuMgr->addMenuItemString("unicodeQuoteApostrophe", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteStraight", "InsertQuote");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteSingleLeft", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteSingleRight", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteDoubleLeft", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteDoubleRight", "InsertQuote");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteSingleReversed", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteDoubleReversed", "InsertQuote");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteLowSingleComma", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteLowDoubleComma", "InsertQuote");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteSingleLeftGuillemet", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteSingleRightGuillemet", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteDoubleLeftGuillemet", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteDoubleRightGuillemet", "InsertQuote");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteCJKSingleLeft", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteCJKSingleRight", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteCJKDoubleLeft", "InsertQuote");
scrMenuMgr->addMenuItemString("unicodeQuoteCJKDoubleRight", "InsertQuote");
scrMenuMgr->createMenu("InsertSpace", tr("S&paces / Breaks"), "Insert");
scrMenuMgr->addMenuItemString("InsertSpace", "Insert");
scrMenuMgr->addMenuItemString("unicodeNonBreakingSpace", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeSpaceEN", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeSpaceEM", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeSpaceThin", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeSpaceThick", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeSpaceMid", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeSpaceHair", "InsertSpace");
scrMenuMgr->addMenuItemString("SEPARATOR", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeNewLine", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeFrameBreak", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeColumnBreak", "InsertSpace");
scrMenuMgr->addMenuItemString("unicodeZerowidthSpace", "InsertSpace");
scrMenuMgr->createMenu("InsertLigature", tr("Liga&ture"), "Insert");
scrMenuMgr->addMenuItemString("InsertLigature", "Insert");
scrMenuMgr->addMenuItemString("unicodeLigature_ff", "InsertLigature");
scrMenuMgr->addMenuItemString("unicodeLigature_fi", "InsertLigature");
scrMenuMgr->addMenuItemString("unicodeLigature_fl", "InsertLigature");
scrMenuMgr->addMenuItemString("unicodeLigature_ffi", "InsertLigature");
scrMenuMgr->addMenuItemString("unicodeLigature_ffl", "InsertLigature");
scrMenuMgr->addMenuItemString("unicodeLigature_ft", "InsertLigature");
scrMenuMgr->addMenuItemString("unicodeLigature_st", "InsertLigature");
scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
scrMenuMgr->addMenuItemString("insertSampleText", "Insert");
scrMenuMgr->addMenuItemString("SEPARATOR", "Insert");
scrMenuMgr->createMenu("InsertMark", tr("Marks"), "Insert");
scrMenuMgr->addMenuItemString("InsertMark", "Insert");
scrMenuMgr->addMenuItemString("insertMarkAnchor", "InsertMark");
scrMenuMgr->addMenuItemString("insertMark2Mark", "InsertMark");
scrMenuMgr->addMenuItemString("insertMarkItem", "InsertMark");
scrMenuMgr->addMenuItemString("insertMarkVariableText", "InsertMark");
scrMenuMgr->addMenuItemString("insertMarkNote", "InsertMark");
//Page menu
scrMenuMgr->createMenu("Page", ActionManager::defaultMenuNameEntryTranslated("Page"));
scrMenuMgr->addMenuItemString("pageInsert", "Page");
scrMenuMgr->addMenuItemString("pageImport", "Page");
scrMenuMgr->addMenuItemString("pageDelete", "Page");
scrMenuMgr->addMenuItemString("pageCopy", "Page");
scrMenuMgr->addMenuItemString("pageMove", "Page");
scrMenuMgr->addMenuItemString("SEPARATOR", "Page");
scrMenuMgr->addMenuItemString("pageApplyMasterPage", "Page");
scrMenuMgr->addMenuItemString("pageCopyToMasterPage", "Page");
scrMenuMgr->addMenuItemString("pageManageGuides", "Page");
scrMenuMgr->addMenuItemString("pageManageMargins", "Page");
scrMenuMgr->addMenuItemString("SEPARATOR", "Page");
scrMenuMgr->addMenuItemString("viewSnapToGrid", "Page");
scrMenuMgr->addMenuItemString("viewSnapToGuides", "Page");
scrMenuMgr->addMenuItemString("viewSnapToElements", "Page");
//View menu
scrMenuMgr->createMenu("View", ActionManager::defaultMenuNameEntryTranslated("View"));
scrMenuMgr->createMenu("ViewZoom", tr("Zoom"), "View");
scrMenuMgr->addMenuItemString("ViewZoom", "View");
scrMenuMgr->addMenuItemString("viewFitInWindow", "ViewZoom");
scrMenuMgr->addMenuItemString("viewFitWidth", "ViewZoom");
scrMenuMgr->addMenuItemString("viewFit50", "ViewZoom");
scrMenuMgr->addMenuItemString("viewFit75", "ViewZoom");
scrMenuMgr->addMenuItemString("viewFit100", "ViewZoom");
scrMenuMgr->addMenuItemString("viewFit200", "ViewZoom");
scrMenuMgr->addMenuItemString("viewFit400", "ViewZoom");
scrMenuMgr->createMenu("ViewPreview", tr("Preview"), "View");
scrMenuMgr->addMenuItemString("ViewPreview", "View");
scrMenuMgr->addMenuItemString("viewPreviewMode", "ViewPreview");
scrMenuMgr->createMenu("ViewMeasuring", tr("Measures"), "View");
scrMenuMgr->addMenuItemString("ViewMeasuring", "View");
scrMenuMgr->addMenuItemString("viewShowRulers", "ViewMeasuring");
scrMenuMgr->addMenuItemString("viewRulerMode", "ViewMeasuring");
scrMenuMgr->addMenuItemString("showMouseCoordinates", "ViewMeasuring");
scrMenuMgr->createMenu("ViewTextFrames", tr("Text Frames"), "View");
scrMenuMgr->addMenuItemString("ViewTextFrames", "View");
scrMenuMgr->addMenuItemString("viewShowBaseline", "ViewTextFrames");
scrMenuMgr->addMenuItemString("viewShowColumnBorders", "ViewTextFrames");
scrMenuMgr->addMenuItemString("viewShowTextChain", "ViewTextFrames");
scrMenuMgr->addMenuItemString("viewShowTextControls", "ViewTextFrames");
scrMenuMgr->createMenu("ViewImageFrames", tr("Image Frames"), "View");
scrMenuMgr->addMenuItemString("ViewImageFrames", "View");
scrMenuMgr->addMenuItemString("viewShowImages", "ViewImageFrames");
scrMenuMgr->createMenu("ViewDocument", tr("Document"), "View");
scrMenuMgr->addMenuItemString("ViewDocument", "View");
scrMenuMgr->addMenuItemString("viewShowMargins", "ViewDocument");
scrMenuMgr->addMenuItemString("viewShowBleeds", "ViewDocument");
scrMenuMgr->addMenuItemString("viewShowFrames", "ViewDocument");
scrMenuMgr->addMenuItemString("viewShowLayerMarkers", "ViewDocument");
scrMenuMgr->createMenu("ViewGrids", tr("Grids and Guides"), "View");
scrMenuMgr->addMenuItemString("ViewGrids", "View");
scrMenuMgr->addMenuItemString("viewShowGrid", "ViewGrids");
scrMenuMgr->addMenuItemString("viewShowGuides", "ViewGrids");
//CB If this is viewNewView imeplemented, it should be on the windows menu
// scrMenuMgr->addMenuItem(scrActions["viewNewView"], "View");
// Table menu.
scrMenuMgr->createMenu("ItemTable", ActionManager::defaultMenuNameEntryTranslated("Table"));
scrMenuMgr->addMenuItemString("tableInsertRows", "ItemTable");
scrMenuMgr->addMenuItemString("tableInsertColumns", "ItemTable");
scrMenuMgr->addMenuItemString("tableDeleteRows", "ItemTable");
scrMenuMgr->addMenuItemString("tableDeleteColumns", "ItemTable");
scrMenuMgr->addMenuItemString("SEPARATOR", "ItemTable");
scrMenuMgr->addMenuItemString("tableMergeCells", "ItemTable");
scrMenuMgr->addMenuItemString("tableSplitCells", "ItemTable");
scrMenuMgr->addMenuItemString("SEPARATOR", "ItemTable");
scrMenuMgr->addMenuItemString("tableSetRowHeights", "ItemTable");
scrMenuMgr->addMenuItemString("tableSetColumnWidths", "ItemTable");
scrMenuMgr->addMenuItemString("tableDistributeRowsEvenly", "ItemTable");
scrMenuMgr->addMenuItemString("tableDistributeColumnsEvenly", "ItemTable");
scrMenuMgr->addMenuItemString("SEPARATOR", "ItemTable");
scrMenuMgr->addMenuItemString("tableAdjustFrameToTable", "ItemTable");
scrMenuMgr->addMenuItemString("tableAdjustTableToFrame", "ItemTable");
//Extra menu
scrMenuMgr->createMenu("Extras", ActionManager::defaultMenuNameEntryTranslated("Extras"));
scrMenuMgr->addMenuItemString("extrasHyphenateText", "Extras");
scrMenuMgr->addMenuItemString("extrasDeHyphenateText", "Extras");
scrMenuMgr->addMenuItemString("extrasGenerateTableOfContents", "Extras");
scrMenuMgr->addMenuItemString("itemUpdateMarks", "Extras");
scrMenuMgr->addMenuItemString("SEPARATOR", "Extras");
scrMenuMgr->addMenuItemString("extrasManageImages", "Extras");
scrMenuMgr->addMenuItemString("SEPARATOR", "Extras");
scrMenuMgr->addMenuItemString("extrasUpdateDocument", "Extras");
scrMenuMgr->addMenuItemString("extrasTestQTQuick2_1", "Extras");
//Window menu
scrMenuMgr->createMenu("Windows", ActionManager::defaultMenuNameEntryTranslated("Windows"), QString::null, true);
//Help menu
scrMenuMgr->createMenu("Help", ActionManager::defaultMenuNameEntryTranslated("Help"));
scrMenuMgr->addMenuItemString("helpManual", "Help");
scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
scrMenuMgr->addMenuItemString("helpTooltips", "Help");
scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
scrMenuMgr->addMenuItemString("helpOnlineWWW", "Help");
scrMenuMgr->addMenuItemString("helpOnlineDocs", "Help");
scrMenuMgr->addMenuItemString("helpOnlineWiki", "Help");
scrMenuMgr->addMenuItemString("HelpOnlineTutorials", "Help");
scrMenuMgr->addMenuItemString("helpOnlineTutorial1", "Help");
scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
scrMenuMgr->addMenuItemString("helpCheckUpdates", "Help");
scrMenuMgr->addMenuItemString("SEPARATOR", "Help");
scrMenuMgr->addMenuItemString("helpAboutScribus", "Help");
scrMenuMgr->addMenuItemString("helpAboutPlugins", "Help");
scrMenuMgr->addMenuItemString("helpAboutQt", "Help");
}
void ScribusMainWindow::createMenuBar()
{
scrMenuMgr->addMenuStringToMenuBar("File");
scrMenuMgr->addMenuItemStringstoMenuBar("File", scrActions);
scrMenuMgr->addMenuStringToMenuBar("Edit");
scrMenuMgr->addMenuItemStringstoMenuBar("Edit", scrActions);
scrMenuMgr->addMenuStringToMenuBar("Item");
scrMenuMgr->addMenuItemStringstoMenuBar("Item", scrActions);
scrMenuMgr->addMenuStringToMenuBar("Insert");
scrMenuMgr->addMenuItemStringstoMenuBar("Insert", scrActions);
scrMenuMgr->addMenuStringToMenuBar("Page");
scrMenuMgr->addMenuItemStringstoMenuBar("Page", scrActions);
scrMenuMgr->addMenuStringToMenuBar("ItemTable");
scrMenuMgr->addMenuItemStringstoMenuBar("ItemTable", scrActions);
scrMenuMgr->addMenuStringToMenuBar("Extras");
scrMenuMgr->addMenuItemStringstoMenuBar("Extras", scrActions);
scrMenuMgr->addMenuStringToMenuBar("View");
scrMenuMgr->addMenuItemStringstoMenuBar("View", scrActions);
scrMenuMgr->addMenuStringToMenuBar("Windows", true);
addDefaultWindowMenuItems();
menuBar()->addSeparator();
scrMenuMgr->addMenuStringToMenuBar("Help");
scrMenuMgr->addMenuItemStringstoMenuBar("Help", scrActions);
connect(scrMenuMgr->getLocalPopupMenu("Extras"), SIGNAL(aboutToShow()), this, SLOT(extrasMenuAboutToShow()));
connect(scrMenuMgr->getLocalPopupMenu("Windows"), SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
}
void ScribusMainWindow::addDefaultWindowMenuItems()
{
scrMenuMgr->clearMenu("Windows");
scrMenuMgr->addMenuItemString("windowsCascade", "Windows");
scrMenuMgr->addMenuItemString("windowsTile", "Windows");
scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
scrMenuMgr->addMenuItemString("toolsProperties", "Windows");
scrMenuMgr->addMenuItemString("toolsActionHistory", "Windows");
scrMenuMgr->addMenuItemString("toolsAlignDistribute", "Windows");
scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
scrMenuMgr->addMenuItemString("toolsOutline", "Windows");
scrMenuMgr->addMenuItemString("toolsPages", "Windows");
scrMenuMgr->addMenuItemString("toolsLayers", "Windows");
scrMenuMgr->addMenuItemString("toolsBookmarks", "Windows");
scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
scrMenuMgr->addMenuItemString("toolsScrapbook", "Windows");
scrMenuMgr->addMenuItemString("toolsSymbols", "Windows");
scrMenuMgr->addMenuItemString("toolsInline", "Windows");
scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
scrMenuMgr->addMenuItemString("toolsMeasurements", "Windows");
scrMenuMgr->addMenuItemString("toolsPreflightVerifier", "Windows");
scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
scrMenuMgr->addMenuItemString("toolsToolbarTools", "Windows");
scrMenuMgr->addMenuItemString("toolsToolbarPDF", "Windows");
scrMenuMgr->addMenuItemString("toolsToolbarView", "Windows");
scrMenuMgr->addMenuItemStringstoMenuBar("Windows", scrActions);
}
void ScribusMainWindow::initStatusBar()
{
QFont fo = QFont(font());
int posi = fo.pointSize() - (ScCore->isWinGUI() ? 1 : 2);
fo.setPointSize(posi);
unitSwitcher = new QComboBox( this );
unitSwitcher->setFocusPolicy(Qt::NoFocus);
unitSwitcher->setFont(fo);
int maxUindex = unitGetMaxIndex() - 2;
for (int i = 0; i <= maxUindex; ++i)
unitSwitcher->addItem(unitGetStrFromIndex(i));
zoomSpinBox = new ScrSpinBox( 1, 32000, this, 6 );
zoomSpinBox->setTabAdvance(false);
zoomSpinBox->setFont(fo);
zoomSpinBox->setValue( 100 );
zoomSpinBox->setSingleStep(10);
zoomSpinBox->setFocusPolicy(Qt::ClickFocus);
zoomSpinBox->setSuffix( tr( " %" ) );
layerMenu = new QComboBox( this );
layerMenu->setEditable(false);
layerMenu->setFont(fo);
layerMenu->setFocusPolicy(Qt::NoFocus);
layerMenu->setSizeAdjustPolicy(QComboBox::AdjustToContents);
pageSelector = new PageSelector(this, 1);
pageSelector->setFont(fo);
pageSelector->setFocusPolicy(Qt::ClickFocus);
#if OPTION_USE_QTOOLBUTTON
zoomDefaultToolbarButton = new QToolButton(this);
zoomInToolbarButton = new QToolButton(this);
zoomOutToolbarButton = new QToolButton(this);
zoomDefaultToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON);
zoomOutToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON);
zoomInToolbarButton->setAutoRaise(OPTION_FLAT_BUTTON);
zoomInToolbarButton->setDefaultAction(scrActions["toolsZoomIn"]);
zoomOutToolbarButton->setDefaultAction(scrActions["toolsZoomOut"]);
#else
zoomDefaultToolbarButton = new QPushButton(this);
zoomDefaultToolbarButton->setFocusPolicy(Qt::NoFocus);
zoomDefaultToolbarButton->setDefault( false );
zoomDefaultToolbarButton->setAutoDefault( false );
zoomDefaultToolbarButton->setFlat(OPTION_FLAT_BUTTON);
zoomOutToolbarButton = new QPushButton(this);
zoomOutToolbarButton->setFocusPolicy(Qt::NoFocus);
zoomOutToolbarButton->setDefault( false );
zoomOutToolbarButton->setAutoDefault( false );
zoomOutToolbarButton->setFlat(OPTION_FLAT_BUTTON);
zoomInToolbarButton = new QPushButton(this);
zoomInToolbarButton->setFocusPolicy(Qt::NoFocus);
zoomInToolbarButton->setDefault( false );
zoomInToolbarButton->setAutoDefault( false );
zoomInToolbarButton->setFlat(OPTION_FLAT_BUTTON);
zoomInToolbarButton->addAction(scrActions["toolsZoomIn"]);
zoomOutToolbarButton->addAction(scrActions["toolsZoomOut"]);
#endif
zoomDefaultToolbarButton->setIcon(QIcon(loadIcon("16/zoom-original.png")));
zoomOutToolbarButton->setIcon(QIcon(loadIcon("16/zoom-out.png")));
zoomInToolbarButton->setIcon(QIcon(loadIcon("16/zoom-in.png")));
zoomOutToolbarButton->resize(10,10);
// cmsAdjustMenu = new QMenu();
// idCmsAdjustMenu = cmsAdjustMenu->addAction( "Configure CMS...", this, SLOT(adjustCMS()));
// cmsToolbarButton->setMenu(cmsAdjustMenu);
mainWindowStatusLabel = new QLabel( " ", statusBar());
mainWindowStatusLabel->setFont(fo);
mainWindowProgressBar = new QProgressBar(statusBar());
mainWindowProgressBar->setAlignment(Qt::AlignHCenter);
mainWindowProgressBar->setFixedWidth( 100 );
mainWindowProgressBar->reset();
mainWindowXPosLabel = new QLabel( tr("X:"), statusBar());
mainWindowXPosLabel->setFont(fo);
mainWindowYPosLabel = new QLabel( tr("Y:"), statusBar());
mainWindowYPosLabel->setFont(fo);
mainWindowXPosDataLabel = new QLabel( " ", statusBar());
mainWindowXPosDataLabel->setFont(fo);
mainWindowYPosDataLabel = new QLabel( " ", statusBar());
mainWindowYPosDataLabel->setFont(fo);
statusBarLanguageChange();
statusBar()->setFont(fo);
statusBar()->addPermanentWidget(mainWindowStatusLabel, 5);
QLabel *s=new QLabel("");
QLabel *s2=new QLabel("");
statusBar()->addPermanentWidget(s,1);
statusBar()->addPermanentWidget(zoomSpinBox,1);
statusBar()->addPermanentWidget(zoomOutToolbarButton,1);
statusBar()->addPermanentWidget(zoomDefaultToolbarButton,1);
statusBar()->addPermanentWidget(zoomInToolbarButton,1);
statusBar()->addPermanentWidget(pageSelector,1);
statusBar()->addPermanentWidget(layerMenu,1);
statusBar()->addPermanentWidget(s2,2);
statusBar()->addPermanentWidget(mainWindowXPosLabel, 0);
statusBar()->addPermanentWidget(mainWindowXPosDataLabel, 1);
statusBar()->addPermanentWidget(mainWindowYPosLabel, 0);
statusBar()->addPermanentWidget(mainWindowYPosDataLabel, 1);
statusBar()->addPermanentWidget(unitSwitcher,0);
statusBar()->addPermanentWidget(mainWindowProgressBar, 0);
connect(statusBar(), SIGNAL(messageChanged(const QString &)), this, SLOT(setTempStatusBarText(const QString &)));
}
void ScribusMainWindow::setStatusBarMousePosition(double xp, double yp)
{
if (doc->Pages->count() == 0)
return;
double xn = xp;
double yn = yp;
if (doc->guidesPrefs().rulerMode)
{
xn -= doc->currentPage()->xOffset();
yn -= doc->currentPage()->yOffset();
}
xn -= doc->rulerXoffset;
yn -= doc->rulerYoffset;
mainWindowXPosDataLabel->setText(value2String(xn, doc->unitIndex(), true, false));
mainWindowYPosDataLabel->setText(value2String(yn, doc->unitIndex(), true, false));
}
void ScribusMainWindow::setStatusBarTextPosition(double base, double xp)
{
if (doc->Pages->count() == 0)
return;
mainWindowXPosDataLabel->setText(base + xp >= 0? value2String(xp, doc->unitIndex(), true, true): QString("-"));
mainWindowYPosDataLabel->setText("-");
}
void ScribusMainWindow::setTempStatusBarText(const QString &text)
{
if (mainWindowStatusLabel)
{
if (text.isEmpty())
mainWindowStatusLabel->setText(statusLabelText);
else
mainWindowStatusLabel->setText(text);
}
}
void ScribusMainWindow::setStatusBarInfoText(QString newText)
{
if (mainWindowStatusLabel)
mainWindowStatusLabel->setText(newText);
statusLabelText = newText;
}
//AV to be replaced with Selection::update and listener in PropertiesPalette
void ScribusMainWindow::setTBvals(PageItem *currItem)
{
scrActions["editMark"]->setEnabled(false);
PageItem* item = currItem;
bool inEditMode = (doc->appMode == modeEdit);
if (doc->appMode == modeEditTable)
{
if (currItem->isTable())
item = currItem->asTable()->activeCell().textFrame();
inEditMode = item->isTextFrame();
}
if (!item || item->itemText.length() <= 0)
return;
const ParagraphStyle& currPStyle( inEditMode ? item->currentStyle() : item->itemText.defaultStyle());
setAlignmentValue(currPStyle.alignment());
propertiesPalette->textPal->showParStyle(currPStyle.parent());
propertiesPalette->textPal->showCharStyle(item->currentCharStyle().parent());
doc->currentStyle = item->currentStyle();
// #8112 : do not use operator= here as it does not update style features
doc->currentStyle.charStyle().setStyle(item->currentCharStyle());
emit TextStyle(doc->currentStyle);
// to go: (av)
propertiesPalette->textPal->updateStyle(doc->currentStyle);
//check if mark in cursor place and enable editMark action
if (doc->appMode == modeEdit && item->itemText.cursorPosition() < item->itemText.length())
{
if (item->itemText.hasMark(item->itemText.cursorPosition()))
{
Mark* mark = item->itemText.mark(item->itemText.cursorPosition());
scrActions["editMark"]->setEnabled(true);
if ((mark->isType(MARKNoteMasterType) || mark->isType(MARKNoteFrameType)) && (mark->getNotePtr() != NULL))
nsEditor->setNotesStyle(mark->getNotePtr()->notesStyle());
}
else
scrActions["editMark"]->setEnabled(false);
}
}
//Special keys assigned to actions are stolen by the action and not passed to
//keyPressEvent so process them here.
void ScribusMainWindow::specialActionKeyEvent(int unicodevalue)
{
const QString& actionName="";
if (HaveDoc)
{
if (doc->m_Selection->count() == 1)
{
PageItem* selItem = doc->m_Selection->itemAt(0);
if (((doc->appMode == modeEdit) || (doc->appMode == modeEditTable)) && (selItem->isTextFrame() || selItem->isTable()))
{
PageItem_TextFrame *currItem;
if (doc->appMode == modeEditTable)
currItem = selItem->asTable()->activeCell().textFrame();
else
currItem = selItem->asTextFrame();
if (currItem!=NULL)
{
if (unicodevalue!=-1)
{
UndoTransaction* activeTransaction = NULL;
if (currItem->HasSel){
if (UndoManager::undoEnabled())
activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection, Um::IGroup, Um::ReplaceText, "", Um::IDelete));
currItem->deleteSelectedTextFromFrame();
}
if (UndoManager::undoEnabled())
{
SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
if(ss && ss->get("ETEA") == "insert_frametext")
ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(QChar(unicodevalue)));
else {
ss = new SimpleState(Um::InsertText,"",Um::ICreate);
ss->set("INSERT_FRAMETEXT", "insert_frametext");
ss->set("ETEA", QString("insert_frametext"));
ss->set("TEXT_STR", QString(QChar(unicodevalue)));
ss->set("START", currItem->itemText.cursorPosition());
UndoObject * undoTarget = currItem;
if (currItem->isNoteFrame())
{
undoTarget = doc;
ss->set("noteframeName", currItem->getUName());
}
undoManager->action(undoTarget, ss);
}
}
currItem->itemText.insertChars(QString(QChar(unicodevalue)), true);
if (activeTransaction)
{
activeTransaction->commit();
delete activeTransaction;
activeTransaction = NULL;
}
}
else if (unicodevalue==SpecialChars::SHYPHEN.unicode()) //ignore the char as we use an attribute if the text item, for now.
{
// this code is currently dead since unicodeSoftHyphen
// doesnt have unicodevalue == -1 any more
if (currItem->itemText.cursorPosition() > 1)
{
#if 0
StyleFlag fl = currItem->itemText.item(qMax(currItem->CPos-1,0))->effects();
fl |= ScStyle_HyphenationPossible;
currItem->itemText.item(qMax(currItem->CPos-1,0))->setEffects(fl);
#else
if (UndoManager::undoEnabled())
{
SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
if(ss && ss->get("ETEA") == "insert_frametext")
ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(SpecialChars::SHYPHEN));
else {
ss = new SimpleState(Um::InsertText,"",Um::ICreate);
ss->set("INSERT_FRAMETEXT", "insert_frametext");
ss->set("ETEA", QString("insert_frametext"));
ss->set("TEXT_STR", QString(SpecialChars::SHYPHEN));
ss->set("START", currItem->itemText.cursorPosition());
UndoObject * undoTarget = currItem;
if (currItem->isNoteFrame())
{
undoTarget = doc;
ss->set("noteframeName", currItem->getUName());
}
undoManager->action(undoTarget, ss);
}
}
currItem->itemText.insertChars(QString(SpecialChars::SHYPHEN), true);
#endif
}
}
if (doc->appMode == modeEditTable)
selItem->asTable()->update();
else
currItem->update();
}
}
}
}
}
bool ScribusMainWindow::eventFilter( QObject* /*o*/, QEvent *e )
{
bool retVal;
if (e->type() == QEvent::ToolTip)
{
return (!prefsManager->appPrefs.displayPrefs.showToolTips);
}
if ( e->type() == QEvent::KeyPress )
{
QKeyEvent *k = (QKeyEvent *)e;
int keyMod=0;
if (k->modifiers() & Qt::ShiftModifier)
keyMod |= Qt::SHIFT;
if (k->modifiers() & Qt::ControlModifier)
keyMod |= Qt::CTRL;
if (k->modifiers() & Qt::AltModifier)
keyMod |= Qt::ALT;
QKeySequence currKeySeq = QKeySequence(k->key() | keyMod);
if (QString(currKeySeq.toString()).isNull())
return false;
retVal=true;
//Palette actions
if (currKeySeq == scrActions["specialToggleAllPalettes"]->shortcut())
scrActions["specialToggleAllPalettes"]->activate(QAction::Trigger);
else
if (currKeySeq == scrActions["specialToggleAllGuides"]->shortcut())
scrActions["specialToggleAllGuides"]->activate(QAction::Trigger);
else
retVal=false;
}
else
retVal=false;
//Return false to pass event to object
return retVal;
}
void ScribusMainWindow::inputMethodEvent ( QInputMethodEvent * event )
{
//qDebug() << "IMEmw" << event->commitString() << event->preeditString() << "attributes:" << event->attributes().count();
}
QVariant ScribusMainWindow::inputMethodQuery ( Qt::InputMethodQuery query ) const
{
//qDebug() << "IMQmw" << query;
return QVariant();
}
//AV -> CanvasMode
void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
{
QList<QMdiSubWindow *> windows;
QMdiSubWindow* w = NULL;
int kk = k->key();
if (HaveDoc)
{
if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift))
{
view->setCursor(QCursor(loadIcon("LupeZm.xpm")));
return;
}
}
if (keyrep)
return;
keyrep = true;
int keyMod=0;
if (k->modifiers() & Qt::ShiftModifier)
keyMod |= Qt::SHIFT;
if (k->modifiers() & Qt::ControlModifier)
keyMod |= Qt::CTRL;
if (k->modifiers() & Qt::AltModifier)
keyMod |= Qt::ALT;
//User presses escape and we have a doc open, and we have an item selected
if ((kk == Qt::Key_Escape) && (HaveDoc))
{
keyrep = false;
PageItem *currItem;
if (!doc->m_Selection->isEmpty())
{
currItem = doc->m_Selection->itemAt(0);
switch (doc->appMode)
{
case modeNormal:
case modeEditClip:
currItem->Sizing = false;
if (doc->SubMode != -1)
{
view->Deselect(false);
doc->Items->removeOne(currItem);
}
else
view->Deselect(false);
view->cancelGroupTransaction();
break;
case modeEdit:
view->cancelGroupTransaction();
break;
case modeCopyProperties:
case modeEditGradientVectors:
case modeEditMeshGradient:
case modeLinkFrames:
case modeUnlinkFrames:
case modeRotation:
view->Deselect(false);
case modeEditWeldPoint:
case modeEyeDropper:
case modeImportObject:
case modeImportImage:
case modePanning:
view->requestMode(modeNormal);
break;
case modeDrawBezierLine:
currItem->PoLine.resize(qMax(0, static_cast<int>(currItem->PoLine.size())-2));
if (currItem->PoLine.size() < 4)
{
view->Deselect(false);
doc->Items->removeOne(currItem);
}
else
{
doc->SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem, false, false);
currItem->setPolyClip(qRound(qMax(currItem->lineWidth() / 2.0, 1.0)));
doc->AdjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
currItem->ClipEdited = true;
currItem->FrameType = 3;
slotDocCh();
}
view->FirstPoly = true;
break;
default:
if (currItem->Sizing)
{
view->Deselect(false);
doc->Items->removeOne(currItem);
}
break;
}
}
doc->DragP = false;
doc->leaveDrag = false;
view->stopAllDrags();
doc->SubMode = -1;
doc->ElemToLink = NULL;
slotSelect();
if (doc->m_Selection->isEmpty())
HaveNewSel(-1);
prefsManager->appPrefs.uiPrefs.stickyTools = false;
scrActions["stickyTools"]->setChecked(false);
return;
}
Qt::KeyboardModifiers buttonModifiers = k->modifiers();
/**If we have a doc and we are not changing the page or zoom level in the status bar */
if ((HaveDoc) && (!zoomSpinBox->hasFocus()) && (!pageSelector->hasFocus()))
{
//Show our context menu
QKeySequence currKeySeq = QKeySequence(kk | keyMod);
if (currKeySeq.matches(scrActions["viewShowContextMenu"]->shortcut()) == QKeySequence::ExactMatch)
{
ContextMenu* cmen=NULL;
if (doc->m_Selection->isEmpty())
{
//CB We should be able to get this calculated by the canvas.... it is already in m_canvas->globalToCanvas(m->globalPos());
QPoint p(QCursor::pos() - mapToGlobal(QPoint(0,0)));
FPoint fp(p.x() / view->scale() + doc->minCanvasCoordinate.x(),
p.y() / view->scale() + doc->minCanvasCoordinate.y());
cmen = new ContextMenu(this, doc, fp.x(), fp.y());
}
else
cmen = new ContextMenu(*(doc->m_Selection), this, doc);
if (cmen)
{
setUndoMode(true);
cmen->exec(QCursor::pos());
setUndoMode(false);
}
delete cmen;
}
/**
* With no item selected we can:
* - With space, get into panning mode (modePanning)
* - With PageUp, scroll up
* - With PageDown, scroll down
* - With Tab, change active document windowActivated
*/
if ((doc->appMode != modeEdit) && (doc->m_Selection->isEmpty()))
{
int pg;
int wheelVal = prefsManager->mouseWheelJump();
if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
wheelVal = qMax(qRound(wheelVal / 10.0), 1);
switch (kk)
{
case Qt::Key_Space:
keyrep = false;
if (doc->appMode == modePanning)
view->requestMode(modeNormal);
else
view->requestMode(modePanning);
return;
break;
case Qt::Key_PageUp:
if (doc->masterPageMode() || doc->symbolEditMode() || doc->inlineEditMode())
view->scrollBy(0, -prefsManager->mouseWheelJump());
else
{
pg = doc->currentPageNumber();
if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
pg--;
else
pg -= doc->pageSets()[doc->pagePositioning()].Columns;
if (pg > -1)
view->GotoPage(pg);
}
keyrep = false;
return;
break;
case Qt::Key_PageDown:
if (doc->masterPageMode() || doc->symbolEditMode() || doc->inlineEditMode())
view->scrollBy(0, prefsManager->mouseWheelJump());
else
{
pg = doc->currentPageNumber();
if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
pg++;
else
pg += doc->pageSets()[doc->pagePositioning()].Columns;
if (pg < static_cast<int>(doc->Pages->count()))
view->GotoPage(pg);
}
keyrep = false;
return;
break;
case Qt::Key_Left:
view->scrollBy(-wheelVal, 0);
keyrep = false;
return;
break;
case Qt::Key_Right:
view->scrollBy(wheelVal, 0);
keyrep = false;
return;
break;
case Qt::Key_Up:
view->scrollBy(0, -wheelVal);
keyrep = false;
return;
break;
case Qt::Key_Down:
view->scrollBy(0, wheelVal);
keyrep = false;
return;
break;
case Qt::Key_Tab:
if (buttonModifiers == Qt::ControlModifier)
{
keyrep = false;
windows = mdiArea->subWindowList();
if (windows.count() > 1)
{
for (int i = 0; i < static_cast<int>(windows.count()); ++i)
{
if (mdiArea->activeSubWindow() == windows.at(i))
{
if (i == static_cast<int>(windows.count()-1))
w = windows.at(0);
else
w = windows.at(i+1);
break;
}
}
outlinePalette->buildReopenVals();
docCheckerPalette->clearErrorList();
if ( w )
w->showNormal();
newActWin(w);
}
return;
}
break;
}
}
}
switch(kk)
{
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
case Qt::Key_Down:
_arrowKeyDown = true;
}
keyrep = false;
}
void ScribusMainWindow::keyReleaseEvent(QKeyEvent *k)
{
//Exit out of panning mode if Control is release while the right mouse button is pressed
if (HaveDoc)
{
if ((doc->appMode == modePanning) && (k->key() == Qt::Key_Control) && (QApplication::mouseButtons() & Qt::RightButton))
view->requestMode(modeNormal);
}
if (HaveDoc)
{
if (doc->appMode == modeMagnifier)
view->setCursor(QCursor(loadIcon("LupeZ.xpm")));
}
if (k->isAutoRepeat() || !_arrowKeyDown)
return;
switch(k->key())
{
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
case Qt::Key_Down:
_arrowKeyDown = false;
if ((HaveDoc) && (!zoomSpinBox->hasFocus()) && (!pageSelector->hasFocus()))
{
int docSelectionCount=doc->m_Selection->count();
if ((docSelectionCount != 0) && (doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
{
PageItem *currItem = doc->m_Selection->itemAt(0);
double xposOrig = currItem->xPos();
double yposOrig = currItem->yPos();
doc->AdjustItemSize(currItem);
if (!doc->nodeEdit.isContourLine)
currItem->ContourLine.translate(xposOrig - currItem->xPos(),yposOrig - currItem->yPos());
currItem->update();
}
for (int i = 0; i < docSelectionCount; ++i)
doc->m_Selection->itemAt(i)->checkChanges(true);
if (docSelectionCount > 1 && view->groupTransactionStarted())
view->endGroupTransaction();
}
break;
}
}
void ScribusMainWindow::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
{
languageChange();
}
else
QWidget::changeEvent(e);
}
void ScribusMainWindow::closeEvent(QCloseEvent *ce)
{
//Do not quit if Preferences or new doc window is open
PreferencesDialog *prefsDialog = findChild<PreferencesDialog *>(QString::fromLocal8Bit("PreferencesDialog"));
NewDoc *newDocWin = findChild<NewDoc *>(QString::fromLocal8Bit("NewDocumentWindow"));
if (prefsDialog!=NULL || newDocWin!=NULL)
{
ce->ignore();
return;
}
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
ScribusWin* tw;
disconnect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
if (!windows.isEmpty())
{
uint windowCount=windows.count();
for ( uint i = 0; i < windowCount; ++i )
{
tw = (ScribusWin *)(windows.at(i));
QMdiSubWindow *tws = windows.at(i);
ScribusWin* scw = dynamic_cast<ScribusWin *>(tws->widget());
if (scw)
{
newActWin(windows.at(i));
tw = ActWin;
slotSelect();
tws->close();
if (tw == ActWin)
{
ce->ignore();
connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
return;
}
}
}
}
fileToolBar->connectPrefsSlot(false);
editToolBar->connectPrefsSlot(false);
modeToolBar->connectPrefsSlot(false);
pdfToolBar->connectPrefsSlot(false);
propertiesPalette->hide();
outlinePalette->hide();
scrapbookPalette->hide();
bookmarkPalette->hide();
layerPalette->hide();
pagePalette->hide();
docCheckerPalette->hide();
undoPalette->hide();
alignDistributePalette->hide();
guidePalette->hide();
charPalette->hide();
symbolPalette->hide();
inlinePalette->hide();
// Clean up plugins, THEN save prefs to disk
ScCore->pluginManager->cleanupPlugins();
if (!prefsManager->appPrefs.scrapbookPrefs.persistentScrapbook)
scrapbookPalette->CleanUpTemp();
prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks.clear();
prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks = scrapbookPalette->getOpenScrapbooks();
if (!emergencyActivated)
prefsManager->SavePrefs();
UndoManager::deleteInstance();
FormatsManager::deleteInstance();
UrlLauncher::deleteInstance();
// qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
ce->accept();
}
void ScribusMainWindow::requestUpdate(int val)
{
emit UpdateRequest(val);
}
/////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATION
/////////////////////////////////////////////////////////////////////
bool ScribusMainWindow::arrowKeyDown()
{
return _arrowKeyDown;
}
void ScribusMainWindow::startUpDialog()
{
bool docSet = false;
PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false);
NewDoc* dia = new NewDoc(this, RecentDocs, true, ScCore->getGuiLanguage());
if (dia->exec())
{
if (dia->tabSelected() == NewDoc::NewDocumentTab)
{
int facingPages = dia->choosenLayout();
int firstPage = dia->firstPage->currentIndex();
docSet = dia->startDocSetup->isChecked();
double topMargin = dia->marginGroup->top();
double bottomMargin = dia->marginGroup->bottom();
double leftMargin = dia->marginGroup->left();
double rightMargin = dia->marginGroup->right();
double columnDistance = dia->distance();
double pageWidth = dia->pageWidth();
double pageHeight = dia->pageHeight();
double numberCols = dia->numberOfCols->value();
bool autoframes = dia->autoTextFrame->isChecked();
int orientation = dia->orientation();
int pageCount=dia->pageCountSpinBox->value();
QString pagesize;
if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize)
pagesize = CommonStrings::customPageSize;
else
{
PageSize ps2(dia->pageSizeComboBox->currentText());
pagesize = ps2.name();
}
doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset());
doc->setPageSetFirstPage(facingPages, firstPage);
doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight());
HaveNewDoc();
doc->reformPages(true);
// Don's disturb user with "save?" dialog just after new doc
// doc changing should be rewritten maybe... maybe later...
doc->setModified(false);
updateActiveWindowCaption(doc->DocName);
}
else if (dia->tabSelected() == NewDoc::NewFromTemplateTab)
{
QString fileName = QDir::cleanPath(dia->selectedFile());
if (!fileName.isEmpty() && loadDoc(fileName))
{
doc->hasName = false;
UndoManager::instance()->renameStack(dia->nftGui->currentDocumentTemplate->name);
doc->DocName = dia->nftGui->currentDocumentTemplate->name;
updateActiveWindowCaption(QObject::tr("Document Template: ") + dia->nftGui->currentDocumentTemplate->name);
QDir::setCurrent(PrefsManager::instance()->documentDir());
removeRecent(fileName);
}
}
else if (dia->tabSelected() == NewDoc::OpenExistingTab)
{
QString fileName = dia->selectedFile();
if (!fileName.isEmpty())
{
QFileInfo fi(fileName);
docContext->set("docsopen", fi.absolutePath());
loadDoc(fileName);
}
}
else // NewDoc::OpenRecentTab
{
QString fileName = dia->selectedFile();
if (!fileName.isEmpty())
loadRecent(fileName);
}
}
else
{
actionManager->setStartupActionsEnabled(false);
}
prefsManager->setShowStartupDialog(!dia->startUpDialog->isChecked());
delete dia;
mainWindowStatusLabel->setText( tr("Ready"));
if (docSet)
slotDocSetup();
}
bool ScribusMainWindow::slotFileNew()
{
if (HaveDoc && doc->appMode == modeEditClip)
view->requestMode(submodeEndNodeEdit);
bool retVal = false;
bool docSet = false;
NewDoc* dia = new NewDoc(this, RecentDocs);
if (dia->exec())
{
int facingPages = dia->choosenLayout();
int firstPage = dia->firstPage->currentIndex();
docSet = dia->startDocSetup->isChecked();
double topMargin = dia->marginGroup->top();
double bottomMargin = dia->marginGroup->bottom();
double leftMargin = dia->marginGroup->left();
double rightMargin = dia->marginGroup->right();
double columnDistance = dia->distance();
double pageWidth = dia->pageWidth();
double pageHeight = dia->pageHeight();
double numberCols = dia->numberOfCols->value();
bool autoframes = dia->autoTextFrame->isChecked();
int orientation = dia->orientation();
int pageCount=dia->pageCountSpinBox->value();
QString pagesize;
if (dia->pageSizeComboBox->currentText() == CommonStrings::trCustomPageSize)
pagesize = CommonStrings::customPageSize;
else
{
PageSize ps2(dia->pageSizeComboBox->currentText());
pagesize = ps2.name();
}
if (doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->unitOfMeasureComboBox->currentIndex(), firstPage, orientation, 1, pagesize, true, pageCount, true, dia->marginGroup->getMarginPreset()))
{
doc->setPageSetFirstPage(facingPages, firstPage);
doc->bleeds()->set(dia->bleedTop(), dia->bleedLeft(), dia->bleedBottom(), dia->bleedRight());
mainWindowStatusLabel->setText( tr("Ready"));
HaveNewDoc();
doc->reformPages(true);
retVal = true;
// Don's disturb user with "save?" dialog just after new doc
// doc changing should be rewritten maybe... maybe later...
doc->setModified(false);
updateActiveWindowCaption(doc->DocName);
}
}
delete dia;
if (docSet)
slotDocSetup();
return retVal;
}
//TODO move to core, assign doc to doc list, optionally create gui for it
ScribusDoc *ScribusMainWindow::newDoc(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount, bool showView, int marginPreset)
{
return doFileNew(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, columnCount, autoTextFrames, pageArrangement, unitIndex, firstPageLocation, orientation, firstPageNumber, defaultPageSize, requiresGUI, pageCount, showView, marginPreset);
}
ScribusDoc *ScribusMainWindow::doFileNew(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount, bool showView, int marginPreset)
{
if (HaveDoc)
outlinePalette->buildReopenVals();
undoManager->setUndoEnabled(false);
MarginStruct margins(topMargin, leftMargin, bottomMargin, rightMargin);
DocPagesSetup pagesSetup(pageArrangement, firstPageLocation, firstPageNumber, orientation, autoTextFrames, columnDistance, columnCount);
QString newDocName( tr("Document")+"-"+QString::number(DocNr));
ScribusDoc *tempDoc = new ScribusDoc();
if (requiresGUI)
doc=tempDoc;
tempDoc->setLoading(true);
outlinePalette->setDoc(tempDoc);
ColorSetManager csm;
csm.findPaletteLocations();
csm.findPalettes();
csm.findUserPalettes();
ColorList colorList;
QHash<QString, VGradient> gradientsList;
QHash<QString, ScPattern> patternsList;
QString Cpfad = QDir::toNativeSeparators(ScPaths::getApplicationDataDir())+"DefaultColors.xml";
QFile fc(Cpfad);
if (fc.exists())
{
csm.loadPalette(Cpfad, doc, colorList, gradientsList, patternsList, false);
doc->PageColors = colorList;
doc->docGradients = gradientsList;
doc->docPatterns = patternsList;
}
else
{
if (prefsManager->appPrefs.colorPrefs.DColorSet != "Scribus Small")
{
QStringList CustomColorSets = csm.userPaletteNames();
if (CustomColorSets.contains(prefsManager->appPrefs.colorPrefs.DColorSet))
Cpfad = csm.userPaletteFileFromName(prefsManager->appPrefs.colorPrefs.DColorSet);
else
Cpfad = csm.paletteFileFromName(prefsManager->appPrefs.colorPrefs.DColorSet);
if (!Cpfad.isEmpty())
csm.loadPalette(Cpfad, doc, colorList, gradientsList, patternsList, false);
doc->PageColors = colorList;
doc->docGradients = gradientsList;
doc->docPatterns = patternsList;
}
else
doc->PageColors = prefsManager->appPrefs.colorPrefs.DColors;
}
tempDoc->PageColors.ensureDefaultColors();
tempDoc->setup(unitIndex, pageArrangement, firstPageLocation, orientation, firstPageNumber, defaultPageSize, newDocName);
if (requiresGUI)
{
HaveDoc++;
DocNr++;
}
if (ScCore->haveCMS() && tempDoc->cmsSettings().CMSinUse)
recalcColors();
//CB NOTE should be all done now
tempDoc->setPage(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnCount, columnDistance, autoTextFrames, pageArrangement);
tempDoc->setMarginPreset(marginPreset);
tempDoc->setMasterPageMode(false);
tempDoc->createDefaultMasterPages();
tempDoc->createNewDocPages(pageCount);
tempDoc->addSection();
tempDoc->setFirstSectionFromFirstPageNumber();
tempDoc->setModified(false);
tempDoc->OpenNodes.clear();
if (requiresGUI)
{
actionManager->disconnectNewDocActions();
actionManager->connectNewDocActions(tempDoc);
}
//<<View and window code
QMdiArea* qwsp = 0;
if (requiresGUI)
qwsp = mdiArea;
ScribusWin* w = new ScribusWin(qwsp, tempDoc);
w->setMainWindow(this);
if (requiresGUI && view!=NULL)
{
actionManager->disconnectNewViewActions();
disconnect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
}
ScribusView* tempView = new ScribusView(w, this, tempDoc);
if (requiresGUI)
view = tempView;
tempDoc->setCurrentPage(tempDoc->Pages->at(0));
tempDoc->setGUI(requiresGUI, this, tempView);
if (requiresGUI)
{
tempDoc->docHyphenator->ignoredWords = prefsManager->appPrefs.hyphPrefs.ignoredWords;
tempDoc->docHyphenator->specialWords = prefsManager->appPrefs.hyphPrefs.specialWords;
}
tempDoc->setLoading(false);
//run after setGUI to set up guidepalette ok
tempView->setScale(prefsManager->displayScale());
if (requiresGUI)
{
//done in newactinw actionManager->connectNewViewActions(tempView);
alignDistributePalette->setDoc(tempDoc);
docCheckerPalette->clearErrorList();
symbolPalette->setDoc(tempDoc);
inlinePalette->setDoc(tempDoc);
}
w->setView(tempView);
ActWin = w;
tempDoc->WinHan = w;
if (requiresGUI)
tempDoc->connectDocSignals(); //Must be before the first reformpages
tempView->reformPages(true);
//>>
if (requiresGUI)
{
w->setSubWin(mdiArea->addSubWindow(w));
//#9250 : transfered to newActWin()
//connect(undoManager, SIGNAL(undoRedoBegin()), tempDoc, SLOT(undoRedoBegin()));
//connect(undoManager, SIGNAL(undoRedoDone()), tempDoc, SLOT(undoRedoDone()));
//connect(undoManager, SIGNAL(undoRedoDone()), tempView, SLOT(DrawNew()));
connect(tempView, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
}
//Independent finishing tasks after tempDoc setup
if (showView)
{
if ( mdiArea->subWindowList().count() == 1)
w->showMaximized();
else
w->show();
tempView->show();
// Seems to fix crash on loading
ActWin = NULL;
newActWin(w->getSubWin());
}
if (requiresGUI)
{
connect(w, SIGNAL(autoSaved()), this, SLOT(slotAutoSaved()));
connect(ScCore->fileWatcher, SIGNAL(fileChanged(QString)), tempDoc, SLOT(updatePict(QString)));
connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString)), tempDoc, SLOT(removePict(QString)));
connect(ScCore->fileWatcher, SIGNAL(dirChanged(QString )), tempDoc, SLOT(updatePictDir(QString )));
connect(doc, SIGNAL(updateAutoSaveClock()), view->clockLabel, SLOT(resetTime()));
view->clockLabel->resetTime();
scrActions["viewToggleCMS"]->setChecked(tempDoc->HasCMS);
undoManager->switchStack(tempDoc->DocName);
styleManager->setDoc(tempDoc);
marksManager->setDoc(tempDoc);
nsEditor->setDoc(tempDoc);
tocGenerator->setDoc(tempDoc);
}
undoManager->setUndoEnabled(true);
return tempDoc;
}
void ScribusMainWindow::newFileFromTemplate()
{
nftdialog* nftdia = new nftdialog(this, ScCore->getGuiLanguage());
if (nftdia->exec() && nftdia->isTemplateSelected())
{
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
nfttemplate* currentTemplate = nftdia->currentTemplate();
if (loadDoc(QDir::cleanPath(currentTemplate->file)))
{
doc->hasName = false;
UndoManager::instance()->renameStack(currentTemplate->name);
doc->DocName = currentTemplate->name;
updateActiveWindowCaption(QObject::tr("Document Template: ") + currentTemplate->name);
QDir::setCurrent(PrefsManager::instance()->documentDir());
removeRecent(QDir::cleanPath(currentTemplate->file));
}
qApp->restoreOverrideCursor();
}
delete nftdia;
}
void ScribusMainWindow::newView()
{
ScribusWin* w = new ScribusWin(mdiArea, doc);
w->setMainWindow(this);
view = new ScribusView(w, this, doc);
view->setScale(prefsManager->displayScale());
w->setView(view);
ActWin = w;
w->setCentralWidget(view);
actionManager->connectNewViewActions(view);
alignDistributePalette->setDoc(doc);
connect(undoManager, SIGNAL(undoRedoDone()), view, SLOT(DrawNew()));
view->show();
}
void ScribusMainWindow::windowsMenuAboutToShow()
{
scrWindowsActions.clear();
addDefaultWindowMenuItems();
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
bool windowsListNotEmpty=!windows.isEmpty();
scrActions["windowsCascade"]->setEnabled(windowsListNotEmpty);
scrActions["windowsTile"]->setEnabled(windowsListNotEmpty);
if (windowsListNotEmpty)
{
int windowCount=static_cast<int>(windows.count());
if (windowCount>1)
scrMenuMgr->addMenuItemString("SEPARATOR", "Windows");
for ( int i = 0; i < windowCount; ++i )
{
QString docInWindow(windows.at(i)->windowTitle());
scrWindowsActions.insert(docInWindow, new ScrAction( ScrAction::Window, QPixmap(), QPixmap(), docInWindow, QKeySequence(), this, i));
scrWindowsActions[docInWindow]->setToggleAction(true);
connect( scrWindowsActions[docInWindow], SIGNAL(triggeredData(int)), this, SLOT(windowsMenuActivated(int)) );
scrWindowsActions[docInWindow]->setChecked(mdiArea->activeSubWindow() == windows.at(i));
scrMenuMgr->addMenuItemString(docInWindow, "Windows");
}
if (windowCount>1)
scrMenuMgr->addMenuItemStringstoRememberedMenu("Windows", scrWindowsActions);
}
}
void ScribusMainWindow::extrasMenuAboutToShow()
{
// There is only Picture Manager handled now.
// As it can be opened all the time of the document life.
// This is only check for availability of any ImageFrame
// in the doc.
bool enablePicManager = false;
if (HaveDoc)
{
QList<PageItem*> allItems;
for (int i = 0; i < doc->Items->count(); ++i)
{
PageItem *currItem = doc->Items->at(i);
if (currItem->isGroup())
allItems = currItem->asGroupFrame()->getItemList();
else
allItems.append(currItem);
for (int ii = 0; ii < allItems.count(); ii++)
{
PageItem* item = allItems.at(ii);
#ifdef HAVE_OSG
if ((item->itemType() == PageItem::ImageFrame) && (!((item->asLatexFrame()) || (item->asOSGFrame()))))
#else
if ((item->itemType() == PageItem::ImageFrame) && (!(item->asLatexFrame())))
#endif
{
enablePicManager = true;
break;
}
}
allItems.clear();
}
}
scrActions["extrasManageImages"]->setEnabled(enablePicManager);
}
void ScribusMainWindow::newActWin(QMdiSubWindow *w)
{
if (w == NULL)
{
if (mdiArea->subWindowList().count() == 0)
ActWin = NULL;
return;
}
if (w->widget() == NULL)
return;
ScribusWin* scw = dynamic_cast<ScribusWin *>(w->widget());
if (!scw)
return;
if (scw && scw->doc())
{
if (!scw->doc()->hasGUI())
return;
}
if (scw == ActWin)
return;
ActWin = scw;
if (ActWin->doc() == NULL)
return;
if (doc != NULL)
{
if (doc->appMode == modeEditClip)
view->requestMode(submodeEndNodeEdit);
if ((HaveDoc) && (doc != ActWin->doc()))
outlinePalette->buildReopenVals();
}
docCheckerPalette->clearErrorList();
if (HaveDoc && (doc != NULL) && doc->hasGUI())
{
disconnect(undoManager, SIGNAL(undoRedoBegin()), doc, SLOT(undoRedoBegin()));
disconnect(undoManager, SIGNAL(undoRedoDone()) , doc, SLOT(undoRedoDone()));
disconnect(undoManager, SIGNAL(undoRedoDone()) , doc->view(), SLOT(DrawNew()));
disconnect(doc, SIGNAL(addBookmark(PageItem *)), this, SLOT(AddBookMark(PageItem *)));
disconnect(doc, SIGNAL(deleteBookmark(PageItem *)), this, SLOT(DelBookMark(PageItem *)));
disconnect(unitSwitcher, SIGNAL(activated(int)), doc->view(), SLOT(ChgUnit(int)));
disconnect(zoomSpinBox, SIGNAL(valueChanged(double)), doc->view(), SLOT(setZoom()));
disconnect(zoomDefaultToolbarButton, SIGNAL(clicked()), doc->view(), SLOT(slotZoom100()));
disconnect(zoomOutToolbarButton, SIGNAL(clicked()), doc->view(), SLOT(slotZoomOut()));
disconnect(zoomInToolbarButton, SIGNAL(clicked()), doc->view(), SLOT(slotZoomIn()));
disconnect(layerMenu, SIGNAL(activated(int)), doc->view(), SLOT(GotoLa(int)));
disconnect(viewToolBar->previewQualitySwitcher, SIGNAL(activated(int)), this, SLOT(changePreviewQuality(int)));
disconnect(viewToolBar->visualMenu, SIGNAL(activated(int)), doc->view(), SLOT(switchPreviewVisual(int)));
disconnect(pageSelector, 0, 0, 0);
pageSelector->setEnabled(false);
}
doc = ActWin->doc();
undoManager->switchStack(doc->DocName);
if ((doc != NULL) && doc->hasGUI())
{
connect(undoManager, SIGNAL(undoRedoBegin()), doc, SLOT(undoRedoBegin()));
connect(undoManager, SIGNAL(undoRedoDone()) , doc, SLOT(undoRedoDone()));
connect(undoManager, SIGNAL(undoRedoDone()) , doc->view(), SLOT(DrawNew()));
connect(doc, SIGNAL(addBookmark(PageItem *)), this, SLOT(AddBookMark(PageItem *)));
connect(doc, SIGNAL(deleteBookmark(PageItem *)), this, SLOT(DelBookMark(PageItem *)));
connect(unitSwitcher, SIGNAL(activated(int)), doc->view(), SLOT(ChgUnit(int)));
connect(zoomSpinBox, SIGNAL(valueChanged(double)), doc->view(), SLOT(setZoom()));
connect(zoomDefaultToolbarButton, SIGNAL(clicked()), doc->view(), SLOT(slotZoom100()));
connect(zoomOutToolbarButton, SIGNAL(clicked()), doc->view(), SLOT(slotZoomOut()));
connect(zoomInToolbarButton, SIGNAL(clicked()), doc->view(), SLOT(slotZoomIn()));
connect(layerMenu, SIGNAL(activated(int)), doc->view(), SLOT(GotoLa(int)));
scrActions["viewPreviewMode"]->blockSignals(true);
scrActions["viewPreviewMode"]->setChecked(doc->drawAsPreview);
scrActions["viewPreviewMode"]->blockSignals(false);
scrActions["viewEditInPreview"]->setEnabled(doc->drawAsPreview);
scrActions["viewToggleCMS"]->blockSignals(true);
scrActions["viewToggleCMS"]->setChecked(doc->HasCMS);
scrActions["viewToggleCMS"]->blockSignals(false);
viewToolBar->previewQualitySwitcher->setCurrentIndex(doc->previewQuality());
connect(viewToolBar->previewQualitySwitcher, SIGNAL(activated(int)), this, SLOT(changePreviewQuality(int)));
viewToolBar->visualMenu->setCurrentIndex(doc->previewVisual);
connect(viewToolBar->visualMenu, SIGNAL(activated(int)), doc->view(), SLOT(switchPreviewVisual(int)));
viewToolBar->setDoc(doc);
pageSelector->setMaximum(doc->masterPageMode() ? 1 : doc->Pages->count());
slotSetCurrentPage(doc->currentPageNumber());
connect(pageSelector, SIGNAL(GotoPage(int)), this, SLOT(setCurrentPage(int)));
pageSelector->setEnabled(true);
}
if (view!=NULL)
{
actionManager->disconnectNewViewActions();
disconnect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
if (ScCore->usingGUI())
disconnect(doc->m_Selection, SIGNAL(selectionIsMultiple(bool)), 0, 0);
}
view = ActWin->view();
zoomSpinBox->setValue(view->scale() * 100.0 / PrefsManager::instance()->appPrefs.displayPrefs.displayScale);
connect(zoomSpinBox, SIGNAL(valueChanged(double)), doc->view(), SLOT(setZoom()));
actionManager->connectNewViewActions(view);
actionManager->disconnectNewDocActions();
actionManager->connectNewDocActions(doc);
connect(view, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
if (ScCore->usingGUI())
{
//connect(doc->m_Selection, SIGNAL(selectionIsMultiple(bool)), propertiesPalette, SLOT( setMultipleSelection(bool)));
connect(doc->m_Selection, SIGNAL(selectionIsMultiple(bool)), actionManager, SLOT( handleMultipleSelections(bool)));
//connect(doc->m_Selection, SIGNAL(empty()), propertiesPalette, SLOT( unsetItem()));
}
pagePalette->setView(view);
alignDistributePalette->setDoc(doc);
if (!doc->isLoading())
{
SwitchWin();
view->requestMode(doc->appMode);
}
view->setFocus();
scrActions["viewShowMargins"]->setChecked(doc->guidesPrefs().marginsShown);
scrActions["viewShowBleeds"]->setChecked(doc->guidesPrefs().showBleed);
scrActions["viewShowFrames"]->setChecked(doc->guidesPrefs().framesShown);
scrActions["viewShowLayerMarkers"]->setChecked(doc->guidesPrefs().layerMarkersShown);
scrActions["viewShowGrid"]->setChecked(doc->guidesPrefs().gridShown);
scrActions["viewShowGuides"]->setChecked(doc->guidesPrefs().guidesShown);
scrActions["viewShowColumnBorders"]->setChecked(doc->guidesPrefs().colBordersShown);
scrActions["viewShowBaseline"]->setChecked(doc->guidesPrefs().baselineGridShown);
scrActions["viewShowImages"]->setChecked(doc->guidesPrefs().showPic);
scrActions["viewShowTextChain"]->setChecked(doc->guidesPrefs().linkShown);
scrActions["viewShowTextControls"]->setChecked(doc->guidesPrefs().showControls);
scrActions["viewShowRulers"]->setChecked(doc->guidesPrefs().rulersShown);
scrActions["viewRulerMode"]->setChecked(doc->guidesPrefs().rulerMode);
scrActions["extrasGenerateTableOfContents"]->setEnabled(doc->hasTOCSetup());
scrActions["extrasUpdateDocument"]->setEnabled(true);
if (!doc->masterPageMode())
pagePalette->Rebuild();
outlinePalette->setDoc(doc);
if (outlinePalette->isVisible())
{
outlinePalette->BuildTree(false);
outlinePalette->reopenTree();
}
RestoreBookMarks();
if (!doc->isLoading())
{
if (!doc->m_Selection->isEmpty())
{
HaveNewSel(doc->m_Selection->itemAt(0)->itemType());
doc->m_Selection->itemAt(0)->emitAllToGUI();
}
else
HaveNewSel(-1);
}
docCheckerPalette->setDoc(doc);
tocGenerator->setDoc(doc);
styleManager->setDoc(doc);
marksManager->setDoc(doc);
nsEditor->setDoc(doc);
symbolPalette->setDoc(doc);
inlinePalette->setDoc(doc);
modeToolBar->Angle->setValue(doc->itemToolPrefs().calligrapicPenAngle);
modeToolBar->PWidth->setValue(doc->itemToolPrefs().calligrapicPenWidth);
// Give plugins a chance to react on changing the current document
PluginManager& pluginManager(PluginManager::instance());
QStringList pluginNames(pluginManager.pluginNames(false));
ScPlugin* plugin;
QString pName;
for (int i = 0; i < pluginNames.count(); ++i)
{
pName = pluginNames.at(i);
plugin = pluginManager.getPlugin(pName, true);
Q_ASSERT(plugin); // all the returned names should represent loaded plugins
plugin->setDoc(doc);
}
}
void ScribusMainWindow::windowsMenuActivated(int id)
{
QMdiSubWindow* windowWidget = mdiArea->subWindowList().at( id );
if (windowWidget)
{
if (windowWidget->isShaded() || windowWidget->isMinimized())
windowWidget->showNormal();
windowWidget->raise();
}
newActWin(windowWidget);
}
void ScribusMainWindow::SwitchWin()
{
updateActiveWindowCaption(doc->DocName);
propertiesPalette->setDoc(doc);
marksManager->setDoc(doc);
nsEditor->setDoc(doc);
pagePalette->setView(view);
layerPalette->setDoc(doc);
guidePalette->setDoc(doc);
charPalette->setDoc(doc);
outlinePalette->setDoc(doc);
symbolPalette->setDoc(doc);
inlinePalette->setDoc(doc);
rebuildLayersList();
updateLayerMenu();
setLayerMenuText(doc->activeLayerName());
//Do not set this!, it doesnt get valid pointers unless its in EditClip mode and its not
//if we are switching windows #4357
//nodePalette->setDoc(doc, view);
slotChangeUnit(doc->unitIndex(), false);
/* FIXME: check if this is really superflous now
if (doc->appMode == modeEditClip)
{
doc->appMode = modeNormal;
view->requestMode(submodeEndNodeEdit);
} */
appModeHelper.mainWindowSwitchWin(doc);
if (doc->masterPageMode() || doc->symbolEditMode() || doc->inlineEditMode())
pagePalette->enablePalette(false);
else
{
if (doc->isModified())
slotDocCh(false);
pagePalette->enablePalette(true);
setPreviewToolbar();
}
}
void ScribusMainWindow::HaveNewDoc()
{
appModeHelper.mainWindowHasNewDoc(doc, (ScMimeData::clipboardHasScribusData()) || (scrapbookPalette->tempHasContents()));
//Update palettes
updateActiveWindowCaption(doc->DocName);
propertiesPalette->setDoc(doc);
nsEditor->setDoc(doc);
marksManager->setDoc(doc);
symbolPalette->setDoc(doc);
inlinePalette->setDoc(doc);
pagePalette->setView(view);
layerPalette->setDoc(doc);
guidePalette->setDoc(doc);
charPalette->setDoc(doc);
outlinePalette->setDoc(doc);
if (outlinePalette->isVisible())
outlinePalette->BuildTree();
rebuildLayersList();
updateLayerMenu();
setLayerMenuText(doc->activeLayerName());
slotChangeUnit(doc->unitIndex());
windowsMenuAboutToShow();
// #9275 : scripter must call HaveNewDoc() in case new doc has been created in a script
// We may consequently have to call HaveNewDoc several times for the same doc.
// Use Qt::UniqueConnection here to avoid multiple identical signal connections
connect(view, SIGNAL(changeUN(int)), this, SLOT(slotChangeUnit(int)), Qt::UniqueConnection);
connect(view, SIGNAL(changeLA(int)), layerPalette, SLOT(markActiveLayer(int)), Qt::UniqueConnection);
connect(this, SIGNAL(changeLayers(int)), layerPalette, SLOT(markActiveLayer(int)), Qt::UniqueConnection);
connect(view->horizRuler, SIGNAL(MarkerMoved(double, double)), this, SLOT(setStatusBarTextPosition(double, double)), Qt::UniqueConnection);
connect(view->horizRuler, SIGNAL(DocChanged(bool)), this, SLOT(slotDocCh(bool)), Qt::UniqueConnection);
connect(view, SIGNAL(ClipPo(double, double)), nodePalette, SLOT(SetXY(double, double)), Qt::UniqueConnection);
connect(view, SIGNAL(PolyOpen()), nodePalette, SLOT(IsOpen()), Qt::UniqueConnection);
connect(view, SIGNAL(PStatus(int, uint)), nodePalette, SLOT(PolyStatus(int, uint)), Qt::UniqueConnection);
connect(view, SIGNAL(ItemGeom()), propertiesPalette->xyzPal, SLOT(handleSelectionChanged()), Qt::UniqueConnection);
connect(view, SIGNAL(ChBMText(PageItem *)), this, SLOT(BookMarkTxT(PageItem *)), Qt::UniqueConnection);
connect(view, SIGNAL(HaveSel(int)), this, SLOT(HaveNewSel(int)), Qt::UniqueConnection);
connect(view, SIGNAL(PaintingDone()), this, SLOT(slotSelect()), Qt::UniqueConnection);
connect(view, SIGNAL(DocChanged()), this, SLOT(slotDocCh()), Qt::UniqueConnection);
connect(view, SIGNAL(MousePos(double, double)), this, SLOT(setStatusBarMousePosition(double, double)), Qt::UniqueConnection);
connect(view, SIGNAL(ItemCharStyle(const CharStyle&)), propertiesPalette->textPal, SLOT(updateCharStyle(const CharStyle&)), Qt::UniqueConnection);
connect(view, SIGNAL(ItemTextEffects(int)), this, SLOT(setStyleEffects(int)), Qt::UniqueConnection);
connect(view, SIGNAL(ItemTextAlign(int)) , this, SLOT(setAlignmentValue(int)), Qt::UniqueConnection);
connect(view, SIGNAL(HasTextSel()), this, SLOT(EnableTxEdit()), Qt::UniqueConnection);
connect(view, SIGNAL(HasNoTextSel()), this, SLOT(DisableTxEdit()), Qt::UniqueConnection);
connect(view, SIGNAL(CopyItem()), this, SLOT(slotEditCopy()), Qt::UniqueConnection);
connect(view, SIGNAL(CutItem()), this, SLOT(slotEditCut()), Qt::UniqueConnection);
connect(view, SIGNAL(LoadPic()), this, SLOT(slotGetContent()), Qt::UniqueConnection);
connect(view, SIGNAL(StatusPic()), this, SLOT(StatusPic()), Qt::UniqueConnection);
connect(view, SIGNAL(AppendText()), this, SLOT(slotFileAppend()), Qt::UniqueConnection);
connect(view, SIGNAL(AnnotProps()), this, SLOT(ModifyAnnot()), Qt::UniqueConnection);
connect(view, SIGNAL(LoadElem(QString, double ,double, bool, bool, ScribusDoc *, ScribusView*)), this, SLOT(slotElemRead(QString, double, double, bool, bool, ScribusDoc *, ScribusView*)), Qt::UniqueConnection);
connect(view, SIGNAL(AddBM(PageItem *)), this, SLOT(AddBookMark(PageItem *)), Qt::UniqueConnection);
connect(view, SIGNAL(DelBM(PageItem *)), this, SLOT(DelBookMark(PageItem *)), Qt::UniqueConnection);
connect(view, SIGNAL(DoGroup()), this, SLOT(GroupObj()), Qt::UniqueConnection);
connect(view, SIGNAL(callGimp()), this, SLOT(callImageEditor()), Qt::UniqueConnection);
}
void ScribusMainWindow::HaveNewSel(int SelectedType)
{
PageItem *currItem = NULL;
if (doc == NULL)
return;
const uint docSelectionCount=doc->m_Selection->count();
if (SelectedType != -1)
{
if (docSelectionCount != 0)
currItem = doc->m_Selection->itemAt(0);
else
SelectedType = -1;
}
else if (docSelectionCount > 0)
{
currItem = doc->m_Selection->itemAt(0);
}
assert (docSelectionCount == 0 || currItem != NULL); // help coverity analysis
if (docSelectionCount == 0)
setStatusBarInfoText("");
else if (docSelectionCount == 1)
{
QString whatSel = tr("Unknown");
switch (currItem->itemType())
{
case 2:
whatSel = CommonStrings::itemType_ImageFrame;
break;
case 4:
whatSel = CommonStrings::itemType_TextFrame;
break;
case 5:
whatSel = CommonStrings::itemType_Line;
break;
case 6:
whatSel = CommonStrings::itemType_Polygon;
break;
case 7:
whatSel = CommonStrings::itemType_Polyline;
break;
case 8:
whatSel = CommonStrings::itemType_PathText;
break;
case 9:
whatSel = CommonStrings::itemType_LatexFrame;
break;
case 11:
whatSel = CommonStrings::itemType_Symbol;
break;
case 12:
whatSel = CommonStrings::itemType_Group;
break;
case 13:
whatSel = CommonStrings::itemType_RegularPolygon;
break;
case 14:
whatSel = CommonStrings::itemType_Arc;
break;
case 15:
whatSel = CommonStrings::itemType_Spiral;
break;
case 16:
whatSel = CommonStrings::itemType_Table;
break;
default:
whatSel = "Unknown";
break;
}
QString widthTxt = value2String(doc->m_Selection->width(), doc->unitIndex(), true, true);
QString heightTxt = value2String(doc->m_Selection->height(), doc->unitIndex(), true, true);
QString txtBody = tr("selected, Size");
setStatusBarInfoText( QString("%1 %2 = %3 x %4").arg(whatSel).arg(txtBody).arg(widthTxt).arg(heightTxt));
}
else
{
QString widthTxt = value2String(doc->m_Selection->width(), doc->unitIndex(), true, true);
QString heightTxt = value2String(doc->m_Selection->height(), doc->unitIndex(), true, true);
setStatusBarInfoText( tr("%1 Objects selected, Selection Size = %2 x %3").arg(docSelectionCount).arg(widthTxt).arg(heightTxt));
}
actionManager->disconnectNewSelectionActions();
scrActions["editSelectAllOnLayer"]->setEnabled(true);
scrActions["editDeselectAll"]->setEnabled(SelectedType != -1);
scrActions["itemDetachTextFromPath"]->setEnabled(false);
charPalette->setEnabled(false, 0);
scrActions["itemUpdateImage"]->setEnabled(SelectedType==PageItem::ImageFrame && (currItem->PictureIsAvailable || currItem->asLatexFrame()));
scrActions["itemAdjustFrameToImage"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
scrActions["itemAdjustImageToFrame"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
scrActions["itemExtendedImageProperties"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && currItem->pixm.imgInfo.valid);
scrActions["itemToggleInlineImage"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
scrMenuMgr->setMenuEnabled("ItemPreviewSettings", SelectedType==PageItem::ImageFrame);
scrActions["itemImageIsVisible"]->setEnabled(SelectedType==PageItem::ImageFrame);
scrActions["itemPreviewLow"]->setEnabled(SelectedType==PageItem::ImageFrame);
scrActions["itemPreviewNormal"]->setEnabled(SelectedType==PageItem::ImageFrame);
scrActions["itemPreviewFull"]->setEnabled(SelectedType==PageItem::ImageFrame);
scrActions["styleImageEffects"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->isRaster);
scrActions["editCopyContents"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
scrActions["editPasteContents"]->setEnabled(SelectedType==PageItem::ImageFrame);
scrActions["editPasteContentsAbs"]->setEnabled(SelectedType==PageItem::ImageFrame);
scrActions["editEditWithImageEditor"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && currItem->isRaster);
#ifdef HAVE_OSG
scrActions["editEditRenderSource"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem && (currItem->asLatexFrame() || currItem->asOSGFrame()));
#else
scrActions["editEditRenderSource"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem && (currItem->asLatexFrame()));
#endif
scrActions["itemAdjustFrameHeightToText"]->setEnabled(SelectedType==PageItem::TextFrame && currItem->itemText.length() >0);
if (SelectedType!=PageItem::ImageFrame)
{
scrActions["itemImageIsVisible"]->setChecked(false);
scrActions["itemPreviewLow"]->setChecked(false);
scrActions["itemPreviewNormal"]->setChecked(false);
scrActions["itemPreviewFull"]->setChecked(false);
}
if ((SelectedType==-1) || (SelectedType!=-1 && !currItem->asTextFrame()))
appModeHelper.enableTextActions(false);
scrActions["insertSampleText"]->setEnabled(false);
view->horizRuler->textMode(false);
view->horizRuler->update();
switch (SelectedType)
{
case -1: // None
scrActions["fileImportText"]->setEnabled(false);
scrActions["fileImportText2"]->setEnabled(false);
scrActions["fileImportImage"]->setEnabled(false);
scrActions["fileImportAppendText"]->setEnabled(false);
scrActions["fileExportText"]->setEnabled(false);
scrActions["itemDuplicate"]->setEnabled(false);
scrActions["itemMulDuplicate"]->setEnabled(false);
scrActions["itemTransform"]->setEnabled(false);
scrActions["itemDelete"]->setEnabled(false);
scrActions["itemRaise"]->setEnabled(false);
scrActions["itemLower"]->setEnabled(false);
scrActions["itemRaiseToTop"]->setEnabled(false);
scrActions["itemLowerToBottom"]->setEnabled(false);
// scrActions["itemSendToScrapbook"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("itemSendToScrapbook", false);
scrActions["itemSendToPattern"]->setEnabled(false);
scrActions["itemSendToInline"]->setEnabled(false);
scrActions["itemAdjustFrameToImage"]->setEnabled(false);
scrActions["itemAdjustImageToFrame"]->setEnabled(false);
scrActions["itemExtendedImageProperties"]->setEnabled(false);
scrActions["itemUpdateImage"]->setEnabled(false);
scrActions["itemPreviewLow"]->setEnabled(false);
scrActions["itemPreviewNormal"]->setEnabled(false);
scrActions["itemPreviewFull"]->setEnabled(false);
scrActions["itemAttributes"]->setEnabled(false);
scrActions["itemPreviewLow"]->setEnabled(false);
// scrMenuMgr->setMenuEnabled("Item", false);
//scrMenuMgr->setMenuEnabled("ItemShapes", false);
// scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
scrMenuMgr->setMenuEnabled("EditContents", false);
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(false);
scrActions["itemLock"]->setEnabled(false);
scrActions["itemLockSize"]->setEnabled(false);
scrActions["itemPrintingEnabled"]->setEnabled(false);
scrActions["editCut"]->setEnabled(false);
scrActions["editCopy"]->setEnabled(false);
scrActions["editCopyContents"]->setEnabled(false);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["extrasHyphenateText"]->setEnabled(false);
scrActions["extrasDeHyphenateText"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCopy"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCut"]->setEnabled(false);
scrActions["toolsLinkTextFrame"]->setEnabled(false);
scrActions["toolsEditContents"]->setEnabled(false);
scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
scrActions["toolsRotate"]->setEnabled(false);
scrActions["toolsCopyProperties"]->setEnabled(false);
//CB 061005 moved to cpalette choosegrad
//propertiesPalette->Cpal->gradientQCombo->setCurrentItem(0);
outlinePalette->slotShowSelect(doc->currentPageNumber(), NULL);
propertiesPalette->setGradientEditMode(false);
break;
case PageItem::ImageFrame: //Image Frame
scrActions["fileImportAppendText"]->setEnabled(false);
scrActions["fileImportText"]->setEnabled(false);
scrActions["fileImportText2"]->setEnabled(false);
scrActions["fileImportImage"]->setEnabled(true);
scrActions["editCut"]->setEnabled(true);
scrActions["editCopy"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("EditContents", true);
scrActions["editClearContents"]->setEnabled(true);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["extrasHyphenateText"]->setEnabled(false);
scrActions["extrasDeHyphenateText"]->setEnabled(false);
scrActions["itemDuplicate"]->setEnabled(true);
scrActions["itemMulDuplicate"]->setEnabled(true);
scrActions["itemTransform"]->setEnabled(true);
scrActions["itemDelete"]->setEnabled(true);
scrActions["itemRaise"]->setEnabled(true);
scrActions["itemLower"]->setEnabled(true);
scrActions["itemRaiseToTop"]->setEnabled(true);
scrActions["itemLowerToBottom"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("itemSendToScrapbook", true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemSendToInline"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(true);
scrActions["itemAdjustImageToFrame"]->setEnabled(true);
scrActions["itemExtendedImageProperties"]->setEnabled(currItem->pixm.imgInfo.valid);
scrActions["itemUpdateImage"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
scrActions["itemPreviewNormal"]->setEnabled(true);
scrActions["itemPreviewFull"]->setEnabled(true);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToTextFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToSymbolFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCopy"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCut"]->setEnabled(false);
scrActions["toolsLinkTextFrame"]->setEnabled(false);
scrActions["toolsEditContents"]->setEnabled(currItem->ScaleType);
scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
scrActions["toolsRotate"]->setEnabled(true);
scrActions["toolsCopyProperties"]->setEnabled(true);
scrActions["itemImageIsVisible"]->setChecked(currItem->imageShown());
scrActions["itemToggleInlineImage"]->setChecked(currItem->isImageInline());
scrActions["itemPreviewLow"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewLow"]->actionInt());
scrActions["itemPreviewNormal"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewNormal"]->actionInt());
scrActions["itemPreviewFull"]->setChecked(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewFull"]->actionInt());
break;
case PageItem::TextFrame: //Text Frame
scrActions["fileImportText"]->setEnabled(true);
scrActions["fileImportText2"]->setEnabled(true);
scrActions["fileImportImage"]->setEnabled(false);
scrActions["fileImportAppendText"]->setEnabled(true);
scrActions["fileExportText"]->setEnabled(true);
scrActions["editCut"]->setEnabled(true);
scrActions["editCopy"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("EditContents", true);
scrActions["editClearContents"]->setEnabled(true);
scrActions["editSearchReplace"]->setEnabled(currItem->itemText.length() != 0);
scrActions["extrasHyphenateText"]->setEnabled(true);
scrActions["extrasDeHyphenateText"]->setEnabled(true);
// scrMenuMgr->setMenuEnabled("Item", true);
scrActions["itemDuplicate"]->setEnabled(true);
scrActions["itemMulDuplicate"]->setEnabled(true);
scrActions["itemTransform"]->setEnabled(true);
scrActions["itemDelete"]->setEnabled(true);
scrActions["itemRaise"]->setEnabled(true);
scrActions["itemLower"]->setEnabled(true);
scrActions["itemRaiseToTop"]->setEnabled(true);
scrActions["itemLowerToBottom"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("itemSendToScrapbook", true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemSendToInline"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(false);
scrActions["itemAdjustImageToFrame"]->setEnabled(false);
scrActions["itemExtendedImageProperties"]->setEnabled(false);
scrActions["itemUpdateImage"]->setEnabled(false);
scrActions["itemPreviewLow"]->setEnabled(false);
scrActions["itemPreviewNormal"]->setEnabled(false);
scrActions["itemPreviewFull"]->setEnabled(false);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("ItemConvertTo", !((doc->appMode == modeEdit) || (currItem->isAnnotation())));
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToOutlines"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToPolygon"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["toolsRotate"]->setEnabled(true);
scrActions["toolsCopyProperties"]->setEnabled(true);
scrActions["toolsEditWithStoryEditor"]->setEnabled(true);
scrActions["insertSampleText"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("InsertMark",true);
if ((currItem->nextInChain() != 0) || (currItem->prevInChain() != 0))
{
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->setEnabled(true);
scrActions["toolsUnlinkTextFrameWithTextCopy"]->setEnabled(true);
scrActions["toolsUnlinkTextFrameWithTextCut"]->setEnabled(true);
// FIXME: once there's one itemtext per story, always enable editcontents
if ((currItem->prevInChain() != 0) && (currItem->itemText.length() == 0))
scrActions["toolsEditContents"]->setEnabled(false);
else
scrActions["toolsEditContents"]->setEnabled(true);
}
else
{
scrActions["toolsEditContents"]->setEnabled(true);
scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCopy"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCut"]->setEnabled(false);
}
scrActions["toolsLinkTextFrame"]->setEnabled(!currItem->nextInChain());
// if (doc->masterPageMode())
// scrActions["toolsLinkTextFrame"]->setEnabled(false);
if (doc->appMode == modeEdit)
{
setTBvals(currItem);
scrActions["editSelectAll"]->setEnabled(true);
scrActions["editSelectAllOnLayer"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("InsertMark",true);
charPalette->setEnabled(true, currItem);
if (currItem->asTextFrame())
{
appModeHelper.enableTextActions(true, currItem->currentStyle().charStyle().font().scName());
currItem->asTextFrame()->togleEditModeActions();
}
view->horizRuler->setItem(currItem);
view->horizRuler->update();
}
else
{
scrMenuMgr->setMenuEnabled("InsertMark",false);
doc->currentStyle = currItem->itemText.defaultStyle();
propertiesPalette->textPal->showParStyle(doc->currentStyle.parent());
propertiesPalette->textPal->showCharStyle(doc->currentStyle.charStyle().parent());
emit TextStyle(doc->currentStyle);
// to go: (av)
propertiesPalette->textPal->updateStyle(doc->currentStyle);
setStyleEffects(doc->currentStyle.charStyle().effects());
}
// doc->docParagraphStyles[0].setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(currItem->lineSpacingMode()));
// doc->docParagraphStyles[0].setLineSpacing(currItem->lineSpacing());
// doc->docParagraphStyles[0].setAlignment(currItem->textAlignment);
break;
case PageItem::Table:
scrActions["editCut"]->setEnabled(true);
scrActions["editCopy"]->setEnabled(true);
scrActions["toolsRotate"]->setEnabled(true);
if (doc->appMode == modeEditTable)
{
charPalette->setEnabled(true, currItem);
PageItem *i2 = currItem->asTable()->activeCell().textFrame();
appModeHelper.enableTextActions(true, i2->currentCharStyle().font().scName());
scrActions["insertSampleText"]->setEnabled(true);
scrActions["toolsEditWithStoryEditor"]->setEnabled(true);
}
break;
case PageItem::PathText: //Path Text
scrActions["fileImportText"]->setEnabled(true);
scrActions["fileImportText2"]->setEnabled(true);
scrActions["fileImportImage"]->setEnabled(false);
scrActions["fileImportAppendText"]->setEnabled(true);
scrActions["fileExportText"]->setEnabled(true);
scrActions["editCut"]->setEnabled(true);
scrActions["editCopy"]->setEnabled(true);
scrActions["editClearContents"]->setEnabled(false);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["extrasHyphenateText"]->setEnabled(false);
scrActions["extrasDeHyphenateText"]->setEnabled(false);
// scrMenuMgr->setMenuEnabled("Item", true);
scrActions["itemDuplicate"]->setEnabled(true);
scrActions["itemMulDuplicate"]->setEnabled(true);
scrActions["itemTransform"]->setEnabled(true);
scrActions["itemDelete"]->setEnabled(true);
scrActions["itemRaise"]->setEnabled(true);
scrActions["itemLower"]->setEnabled(true);
scrActions["itemRaiseToTop"]->setEnabled(true);
scrActions["itemLowerToBottom"]->setEnabled(true);
// scrActions["itemSendToScrapbook"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("itemSendToScrapbook", true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemSendToInline"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(false);
scrActions["itemAdjustImageToFrame"]->setEnabled(false);
scrActions["itemExtendedImageProperties"]->setEnabled(false);
scrActions["itemUpdateImage"]->setEnabled(false);
scrActions["itemPreviewLow"]->setEnabled(false);
scrActions["itemPreviewNormal"]->setEnabled(false);
scrActions["itemPreviewFull"]->setEnabled(false);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(false);
//scrMenuMgr->setMenuEnabled("ItemShapes", false);
scrActions["itemDetachTextFromPath"]->setEnabled(true);
// scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(true);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(true);
scrActions["toolsRotate"]->setEnabled(true);
scrActions["toolsCopyProperties"]->setEnabled(true);
scrActions["toolsEditContents"]->setEnabled(false);
scrActions["toolsEditWithStoryEditor"]->setEnabled(true);
scrActions["toolsLinkTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCopy"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCut"]->setEnabled(false);
if (doc->appMode == modeEdit)
setTBvals(currItem);
else
{
doc->currentStyle = currItem->itemText.defaultStyle();
propertiesPalette->textPal->showParStyle(doc->currentStyle.parent());
propertiesPalette->textPal->showCharStyle(doc->currentStyle.charStyle().parent());
emit TextStyle(doc->currentStyle);
// to go: (av)
propertiesPalette->textPal->updateStyle(doc->currentStyle);
setStyleEffects(doc->currentStyle.charStyle().effects());
}
break;
default:
scrActions["fileImportText"]->setEnabled(false);
scrActions["fileImportText2"]->setEnabled(false);
scrActions["fileImportImage"]->setEnabled(false);
scrActions["fileImportAppendText"]->setEnabled(false);
scrActions["fileExportText"]->setEnabled(false);
scrActions["editCut"]->setEnabled(true);
scrActions["editCopy"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("EditContents", false);
scrActions["editClearContents"]->setEnabled(false);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["extrasHyphenateText"]->setEnabled(false);
scrActions["extrasDeHyphenateText"]->setEnabled(false);
// scrMenuMgr->setMenuEnabled("Item", true);
scrActions["itemDuplicate"]->setEnabled(true);
scrActions["itemMulDuplicate"]->setEnabled(true);
scrActions["itemTransform"]->setEnabled(true);
scrActions["itemDelete"]->setEnabled(true);
scrActions["itemRaise"]->setEnabled(true);
scrActions["itemLower"]->setEnabled(true);
scrActions["itemRaiseToTop"]->setEnabled(true);
scrActions["itemLowerToBottom"]->setEnabled(true);
// scrActions["itemSendToScrapbook"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("itemSendToScrapbook", true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemSendToInline"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(false);
scrActions["itemAdjustImageToFrame"]->setEnabled(false);
scrActions["itemExtendedImageProperties"]->setEnabled(false);
scrActions["itemUpdateImage"]->setEnabled(false);
scrActions["itemPreviewLow"]->setEnabled(false);
scrActions["itemPreviewNormal"]->setEnabled(false);
scrActions["itemPreviewFull"]->setEnabled(true);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
if (SelectedType == PageItem::Polygon) //Polygon
{
scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToImageFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToSymbolFrame"]->setEnabled(doc->appMode != modeEdit);
}
else if ((SelectedType == PageItem::RegularPolygon) || (SelectedType == PageItem::Arc)) // Regular Polygon + Arc
{
scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToImageFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToTextFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToSymbolFrame"]->setEnabled(doc->appMode != modeEdit);
}
else if (SelectedType == PageItem::PolyLine) //Polyline
{
scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(doc->appMode != modeEdit);
}
else if ((SelectedType == PageItem::Line) || (SelectedType == PageItem::Spiral)) // Line
{
scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(true);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(false);
if (SelectedType == PageItem::Spiral)
scrActions["itemConvertToPolygon"]->setEnabled(doc->appMode != modeEdit);
else
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(doc->appMode != modeEdit);
}
else if (SelectedType == PageItem::Symbol)
scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
scrActions["toolsEditContents"]->setEnabled(false);
scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCopy"]->setEnabled(false);
scrActions["toolsUnlinkTextFrameWithTextCut"]->setEnabled(false);
scrActions["toolsLinkTextFrame"]->setEnabled(false);
// if (SelectedType != 5)
scrActions["toolsRotate"]->setEnabled(true);
// else
// scrActions["toolsRotate"]->setEnabled(false);
scrActions["toolsCopyProperties"]->setEnabled(true);
break;
}
doc->CurrentSel = SelectedType;
propertiesPalette->xyzPal->basePointWidget->setCheckedId(doc->RotMode());
if (docSelectionCount == 1)
{
PageItem* bx = doc->m_Selection->itemAt(0);
scrActions["itemsUnWeld"]->setEnabled(bx->isWelded());
scrActions["itemEditWeld"]->setEnabled(bx->isWelded());
}
if (docSelectionCount > 1)
{
if (!doc->m_Selection->itemsAreSameType())
{
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
//scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(false);
}
scrActions["editSearchReplace"]->setEnabled(false);
bool hPoly = false;
for (uint bx=0; bx < docSelectionCount; ++bx)
{
PageItem* bxi=doc->m_Selection->itemAt(bx);
if ((bxi->asPolygon()) || (bxi->asPolyLine()))
hPoly = true;
}
// It is possible to select objects on different layer using
// document outline palette. We need to check selected objects
// are on a common layer before allowing user to group them
bool objectsOnSameLayer = (doc->m_Selection->objectsLayer() != -1);
scrActions["itemGroup"]->setEnabled(objectsOnSameLayer);
scrActions["itemCombinePolygons"]->setEnabled(hPoly);
if (docSelectionCount == 2)
{
scrActions["itemWeld"]->setEnabled(true);
//CB swap bx around if currItem is not at 0 index from the lastItem loop at start of havenewsel
PageItem* bx=doc->m_Selection->itemAt(1);
if (currItem==bx)
bx=doc->m_Selection->itemAt(0);
if ((currItem->asTextFrame() && (bx->asPolygon() || bx->asPolyLine())) || (bx->asTextFrame() && (currItem->asPolygon() || currItem->asPolyLine())))
{
if ((currItem->nextInChain() == 0) && (currItem->prevInChain() == 0) && (bx->nextInChain() == 0) && (bx->prevInChain() == 0) && (!currItem->isGroup()) && (!bx->isGroup()))
scrActions["itemAttachTextToPath"]->setEnabled(true);
}
}
else
scrActions["itemWeld"]->setEnabled(false);
}
else
{
scrActions["itemWeld"]->setEnabled(false);
scrActions["itemGroup"]->setEnabled(false);
scrActions["itemAttachTextToPath"]->setEnabled(false);
scrActions["itemCombinePolygons"]->setEnabled(false);
}
if (docSelectionCount != 0)
{
actionManager->setPDFActions(view);
updateItemLayerList();
rebuildScrapbookMenu();
//propertiesPalette->textFlowsAroundFrame->setChecked(currItem->textFlowsAroundFrame());
propertiesPalette->setTextFlowMode(currItem->textFlowMode());
scrActions["itemLock"]->setEnabled(true);
scrActions["itemLockSize"]->setEnabled(true);
scrActions["itemPrintingEnabled"]->setEnabled(true);
if (currItem->isGroup())
{
scrActions["itemUngroup"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemGroupAdjust"]->setEnabled(doc->appMode != modeEdit);
}
else
{
scrActions["itemUngroup"]->setEnabled(false);
scrActions["itemGroupAdjust"]->setEnabled(false);
scrActions["itemSplitPolygons"]->setEnabled( (currItem->asPolygon()) && (currItem->Segments.count() != 0) );
}
if (currItem->locked())
{
//scrMenuMgr->setMenuEnabled("ItemShapes", false);
scrMenuMgr->setMenuEnabled("ItemConvertTo", false);
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["itemConvertToSymbolFrame"]->setEnabled(false);
scrActions["itemSplitPolygons"]->setEnabled(false);
scrActions["itemAttachTextToPath"]->setEnabled(false);
scrActions["itemDetachTextFromPath"]->setEnabled(false);
scrActions["itemCombinePolygons"]->setEnabled(false);
scrActions["itemDelete"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("ItemLevel", false);
scrActions["itemLowerToBottom"]->setEnabled(false);
scrActions["itemRaiseToTop"]->setEnabled(false);
scrActions["itemRaise"]->setEnabled(false);
scrActions["itemLower"]->setEnabled(false);
// scrActions["itemSendToScrapbook"]->setEnabled(!(currItem->isTableItem && currItem->isSingleSel));
scrMenuMgr->setMenuEnabled("itemSendToScrapbook", true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemSendToInline"]->setEnabled(true);
scrActions["editCut"]->setEnabled(false);
scrActions["editClearContents"]->setEnabled(false);
scrActions["toolsRotate"]->setEnabled(false);
}
else
{
bool setter = !currItem->isGroup();
scrMenuMgr->setMenuEnabled("ItemLevel", setter);
scrActions["itemDuplicate"]->setEnabled(true);
scrActions["itemMulDuplicate"]->setEnabled(true);
scrActions["itemTransform"]->setEnabled(true);
scrActions["itemDelete"]->setEnabled(true);
// scrActions["itemSendToScrapbook"]->setEnabled(setter);
scrMenuMgr->setMenuEnabled("itemSendToScrapbook", true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemSendToInline"]->setEnabled(true);
if (docSelectionCount > 1)
{
bool haveSameParent = true;
PageItem *firstItem = doc->m_Selection->itemAt(0);
for (uint a = 1; a < docSelectionCount; ++a)
{
if (doc->m_Selection->itemAt(a)->Parent != firstItem->Parent)
{
haveSameParent = false;
break;
}
}
scrActions["itemRaise"]->setEnabled(haveSameParent);
scrActions["itemLower"]->setEnabled(haveSameParent);
scrActions["itemRaiseToTop"]->setEnabled(haveSameParent);
scrActions["itemLowerToBottom"]->setEnabled(haveSameParent);
}
}
scrActions["itemLock"]->setChecked(currItem->locked());
scrActions["itemLockSize"]->setChecked(currItem->sizeLocked());
scrActions["itemPrintingEnabled"]->setChecked(currItem->printEnabled());
}
if (SelectedType != -1)
{
//propertiesPalette->setCurrentItem(currItem);
outlinePalette->slotShowSelect(currItem->OwnPage, currItem);
actionManager->connectNewSelectionActions(view, doc);
// propertiesPalette->handleSelectionChanged();
}
// else
// propertiesPalette->handleSelectionChanged();
PluginManager& pluginManager(PluginManager::instance());
QStringList pluginNames(pluginManager.pluginNames(false));
ScPlugin* plugin;
ScActionPlugin* ixplug;
ScrAction* pluginAction = 0;
QString pName;
for (int i = 0; i < pluginNames.count(); ++i)
{
pName = pluginNames.at(i)