Rev 14759 |
Rev 14765 |
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 <QApplication>
#include <QByteArray>
#include <QCloseEvent>
#include <QColor>
#include <QColorDialog>
#include <QCursor>
#include <QDesktopWidget>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QEvent>
#include <QEventLoop>
#include <QFrame>
#include <QIcon>
#include <QInputDialog>
#include <QKeyEvent>
#include <QKeySequence>
#include <QLabel>
#include <QList>
#include <QLocale>
#include <QMouseEvent>
#include <QPixmap>
#include <QRegExp>
#include <QStyleFactory>
#include <QTableWidget>
#include <QTextCodec>
#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 "ui/about.h"
#include "ui/aboutplugins.h"
#include "actionmanager.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 "canvasmode.h"
#include "ui/charselect.h"
#include "ui/checkDocument.h"
#include "ui/cmsprefs.h"
#include "collect4output.h"
#include "ui/colorcombo.h"
#include "ui/colorm.h"
#include "commonstrings.h"
#include "ui/contextmenu.h"
#include "ui/cpalette.h"
#include "ui/customfdialog.h"
#include "ui/delpages.h"
#include "desaxe/digester.h"
#include "desaxe/saxXML.h"
#include "desaxe/simple_actions.h"
#include "docinfo.h"
#include "ui/docitemattrprefs.h"
#include "documentchecker.h"
#include "documentinformation.h"
#include "ui/effectsdialog.h"
#include "fileloader.h"
#include "filewatcher.h"
#include "ui/fontcombo.h"
#include "ui/fontprefs.h"
#include "fpoint.h"
#include "fpointarray.h"
#include "gtgettext.h"
#include "ui/gradientmanager.h"
#include "ui/guidemanager.h"
#include "ui/helpbrowser.h"
#include "ui/hruler.h"
#include "hyphenator.h"
#include "ui/hysettings.h"
#include "ui/imageinfodialog.h"
#include "ui/insertaframe.h"
#include "ui/inspage.h"
#include "ui/javadocs.h"
#include "langmgr.h"
#include "ui/layers.h"
#include "ui/loremipsum.h"
#include "ui/marginwidget.h"
#include "ui/margindialog.h"
#include "ui/masterpagepalette.h"
#include "ui/mergedoc.h"
#include "ui/movepage.h"
#include "ui/multipleduplicate.h"
#include "ui/newfile.h"
#include "ui/newtemp.h"
#include "nfttemplate.h"
#include "ui/nftdialog.h"
#include "ui_nftdialog.h"
#include "ui/nftwidget.h"
#include "ui/nodeeditpalette.h"
#ifdef HAVE_OSG
#include "ui/osgeditor.h"
#endif
#include "ui/outlinepalette.h"
#include "page.h"
#include "pageitem_imageframe.h"
#include "pageitem_latexframe.h"
#include "pageitem_textframe.h"
#include "ui/pageitemattributes.h"
#include "ui/pagelayout.h"
#include "ui/pagepalette.h"
#include "ui/pageselector.h"
#include "pagesize.h"
#include "ui/patterndialog.h"
#include "pdflib.h"
#include "pdfoptions.h"
#include "ui/pdfopts.h"
#include "ui/picstatus.h"
#include "pluginmanager.h"
#include "plugins/formatidlist.h"
#include "ui/polygonwidget.h"
#include "ui/preferencesdialog.h"
#include "ui/prefs.h"
#include "prefscontext.h"
#include "prefsfile.h"
#include "prefsmanager.h"
#include "prefstable.h"
#include "ui/preview.h"
#include "ui/printdialog.h"
#include "ui/propertiespalette.h"
#include "pslib.h"
#include "ui/query.h"
#include "ui/reformdoc.h"
#include "ui/replacecolors.h"
#include "resourcecollection.h"
#include "sccolorengine.h"
#include "ui/sccombobox.h"
#include "scgtplugin.h"
#include "ui/scmessagebox.h"
#include "scmimedata.h"
#include "scpaths.h"
#include "scprintengine_ps.h"
#include "scraction.h"
#include "ui/scrapbookpalette.h"
#include "scribus.h"
#include "scribusdoc.h"
#include "scribusXml.h"
#include "scribusapp.h"
#include "scribuscore.h"
#include "scribusview.h"
#include "scribuswin.h"
#include "ui/scmwmenumanager.h"
#include "ui/search.h"
#include "selection.h"
#include "ui/selectobjects.h"
#include "serializer.h"
#include "ui/smlinestyle.h"
#include "ui/smtextstyles.h"
#include "ui/splash.h"
#include "stencilreader.h"
#include "ui/storyeditor.h"
#include "ui/stylemanager.h"
#include "ui/tabcheckdoc.h"
#include "ui/tabguides.h"
#include "ui/tabmanager.h"
#include "ui/tabpdfoptions.h"
#include "ui/tabtools.h"
#include "ui/tabtypography.h"
#include "text/nlsconfig.h"
#include "tocgenerator.h"
#include "ui/tocindexprefs.h"
#include "ui/copypagetomasterpagedialog.h"
#include "ui/edittoolbar.h"
#include "ui/filetoolbar.h"
#include "ui/modetoolbar.h"
#include "ui/pdftoolbar.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"
#include "ui/vruler.h"
#include "loadsaveplugin.h"
#include "plugins/formatidlist.h"
#include "scimagecachemanager.h"
#if defined(_WIN32)
#include "scdocoutput_ps2.h"
#include "scprintengine_gdi.h"
#endif
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_WS_MAC
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;
QByteArray stylesheet;
if (loadRawText(ScPaths::getApplicationDataDir() + "/stylesheet.css", stylesheet))
{
qApp->setStyleSheet(QString(stylesheet));
}
// origEventFilter = qApp->setEventFilter(reportFocusChanges);
previewDinUse = false;
printDinUse = false;
internalCopy = false;
CurrStED = NULL;
setWindowTitle( tr("Scribus " VERSION));
setAttribute(Qt::WA_KeyCompression, false);
setWindowIcon(loadIcon("AppIcon.png"));
scrActionGroups.clear();
scrActions.clear();
scrRecentFileActions.clear();
scrRecentPasteActions.clear();
scrWindowsActions.clear();
scrLayersActions.clear();
scrMenuMgr = new ScMWMenuManager(menuBar());
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();
initDefaultValues();
initStatusBar();
qApp->processEvents();
actionManager = new ActionManager(this);
actionManager->init(this);
// if (primaryMainWindow)
// ScCore->setSplashStatus( tr("Applying User Shortcuts") );
// prefsManager->applyLoadedShortCuts();
// initKeyboardShortcuts();
initMenuBar();
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);
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);
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Initializing Story Editor") );
storyEditor = new StoryEditor(this);
DocDir = prefsManager->documentDir();
if (primaryMainWindow)
ScCore->setSplashStatus( tr("Initializing Hyphenator") );
QString preLang(prefsManager->appPrefs.hyphPrefs.Language);
initHyphenator();
if (!LanguageManager::instance()->getHyphFilename( preLang, false ).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(removeRecent(QString)));
connect(this, SIGNAL(TextStyle(const ParagraphStyle&)), propertiesPalette, SLOT(updateStyle(const ParagraphStyle&)));
connect(this, SIGNAL(TextIFont(QString)), propertiesPalette, SLOT(setFontFace(QString)));
connect(this, SIGNAL(TextISize(double)), propertiesPalette, SLOT(setSize(double)));
connect(this, SIGNAL(TextUSval(double)), propertiesPalette, SLOT(setExtra(double)));
connect(this, SIGNAL(TextStil(int)), propertiesPalette, SLOT(setStil(int)));
connect(this, SIGNAL(TextScale(double)), propertiesPalette, SLOT(setTScale(double)));
connect(this, SIGNAL(TextScaleV(double)), propertiesPalette, SLOT(setTScaleV(double)));
connect(this, SIGNAL(TextBase(double)), propertiesPalette, SLOT(setTBase(double)));
connect(this, SIGNAL(TextShadow(double, double )), propertiesPalette, SLOT(setShadowOffs(double, double )));
connect(this, SIGNAL(TextOutline(double)), propertiesPalette, SLOT(setOutlineW(double)));
connect(this, SIGNAL(TextUnderline(double, double)), propertiesPalette, SLOT(setUnderline(double, double)));
connect(this, SIGNAL(TextStrike(double, double)), propertiesPalette, SLOT(setStrike(double, double)));
connect(this, SIGNAL(TextFarben(QString, QString, double, double)), propertiesPalette, SLOT(setActFarben(QString, QString, double, double)));
connect(ClipB, SIGNAL(dataChanged()), this, SLOT(ClipChange()));
// connect(ClipB, SIGNAL(selectionChanged()), this, SLOT(ClipChange()));
setAcceptDrops(true);
QCoreApplication::instance()->installEventFilter(this);
scrActions["toolsSelect"]->setChecked(true);
return retVal;
}
ScribusMainWindow::~ScribusMainWindow()
{
}
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);
addScToolBar(fileToolBar, "ToolBar-File");
addScToolBar(editToolBar, "ToolBar-Edit");
addScToolBar(modeToolBar, "ToolBar-Tools");
addScToolBar(pdfToolBar, "ToolBar-PDF_Tools");
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)) );
}
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;
}
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();
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)));
//CB dont need this until we have a doc...
//propertiesPalette->Cpal->SetColors(prefsManager->colorSet());
propertiesPalette->Fonts->RebuildList(0);
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)));
scrapbookPalette->installEventFilter(this);
pagePalette = new PagePalette(this);
connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , pagePalette, SLOT(setPaletteShown(bool)) );
connect( scrActions["toolsPages"], SIGNAL(toggled(bool)) , this, SLOT(setPagePalette(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);
// measurementPalette = new Measurements(this);
// connect( scrActions["toolsMeasurements"], SIGNAL(toggled(bool)) , measurementPalette, SLOT(setPaletteShown(bool)) );
connect( scrActions["toolsMeasurements"], SIGNAL(toggledData(bool, int)) , this, SLOT(setAppModeByToggle(bool, int)) );
// connect( measurementPalette, SIGNAL(paletteShown(bool)), scrActions["toolsMeasurements"], SLOT(setChecked(bool)));
// measurementPalette->installEventFilter(this);
// measurementPalette->hide();
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", false);
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);
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");
styleManager->addStyle(new SMLineStyle());
SMCharacterStyle *tmpCS = new SMCharacterStyle();
styleManager->addStyle(new SMParagraphStyle(tmpCS->tmpStyles()));
styleManager->addStyle(tmpCS);
connect( scrActions["editStyles"], SIGNAL(toggled(bool)), styleManager, SLOT(setPaletteShown(bool)) );
connect( styleManager, SIGNAL(paletteShown(bool)), scrActions["editStyles"], SLOT(setChecked(bool)));
styleManager->installEventFilter(this);
connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(selectItemsFromOutlines(int, int)));
connect(docCheckerPalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
connect(docCheckerPalette, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
connect(outlinePalette, SIGNAL(selectElement(int, int, bool)), this, SLOT(selectItemsFromOutlines(int, int, bool)));
connect(outlinePalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
connect(outlinePalette, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
connect(propertiesPalette->paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewParStyle(const QString&)));
connect(propertiesPalette->charStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewCharStyle(const QString&)));
// connect(propertiesPalette, SIGNAL(EditLSt()), this, SLOT(slotEditLineStyles()));
connect(nodePalette, SIGNAL(Schliessen()), propertiesPalette, SLOT(endEdit2()));
connect(nodePalette, SIGNAL(Schliessen()), 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 *)), this, SLOT(selectItemsFromOutlines(PageItem *)));
// 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::convertSeparators(prefsManager->preferencesLocation()+"/scrap13.scs");
QFileInfo scrapbookFileInfoO = QFileInfo(scrapbookFileO);
if (scrapbookFileInfoO.exists())
{
scrapbookPalette->readOldContents(scrapbookFileO, QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrapbook/main"));
QDir d = QDir();
d.rename(scrapbookFileO, QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrap13.backup"));
}
QString scrapbookTemp = QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrapbook/tmp");
QFileInfo scrapbookTempInfo = QFileInfo(scrapbookTemp);
if (scrapbookTempInfo.exists())
scrapbookPalette->readTempContents(scrapbookTemp);
QString scrapbookFile = QDir::convertSeparators(prefsManager->preferencesLocation()+"/scrapbook/main");
QFileInfo scrapbookFileInfo = QFileInfo(scrapbookFile);
if (scrapbookFileInfo.exists())
scrapbookPalette->readContents(scrapbookFile);
scrapbookPalette->setScrapbookFileName(scrapbookFile);
scrapbookPalette->setOpenScrapbooks(prefsManager->appPrefs.scrapbookPrefs.RecentScrapbooks);
rebuildRecentPasteMenu();
connect(scrapbookPalette, SIGNAL(updateRecentMenue()), this, SLOT(rebuildRecentPasteMenu()));
}
bool ScribusMainWindow::warningVersion(QWidget *parent)
{
bool retval = false;
int t = ScMessageBox::warning(parent, QObject::tr("Scribus Development Version"), "<qt>" +
QObject::tr("You are running a development version of Scribus 1.3.x. The document you are working with was created in Scribus 1.2.x. Saving the current file under 1.3.x renders it unable to be edited in Scribus 1.2.x versions. To preserve the ability to edit in 1.2.x, save this file under a different name and further edit the newly named file and the original will be untouched. Are you sure you wish to proceed with this operation?") + "</qt>",
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->addMenuItem(scrActions["fileNew"], "File", true);
scrMenuMgr->addMenuItem(scrActions["fileNewFromTemplate"], "File", true);
scrMenuMgr->addMenuItem(scrActions["fileOpen"], "File", true);
scrMenuMgr->createMenu("FileOpenRecent", tr("Open &Recent"), "File");
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["fileClose"], "File", false);
scrMenuMgr->addMenuItem(scrActions["fileSave"], "File", false);
scrMenuMgr->addMenuItem(scrActions["fileSaveAs"], "File", false);
scrMenuMgr->addMenuItem(scrActions["fileRevert"], "File", false);
scrMenuMgr->addMenuItem(scrActions["fileCollect"], "File", false);
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->createMenu("FileImport", tr("&Import"), "File");
scrMenuMgr->addMenuItem(scrActions["fileImportText"], "FileImport", false);
// scrMenuMgr->addMenuItem(scrActions["fileImportText2"], "FileImport", false);
scrMenuMgr->addMenuItem(scrActions["fileImportAppendText"], "FileImport", false);
scrMenuMgr->addMenuItem(scrActions["fileImportImage"], "FileImport", false);
scrMenuMgr->addMenuItem(scrActions["fileImportVector"], "FileImport", true);
scrMenuMgr->createMenu("FileExport", tr("&Export"), "File");
scrMenuMgr->addMenuItem(scrActions["fileExportText"], "FileExport", false);
scrMenuMgr->addMenuItem(scrActions["fileExportAsEPS"], "FileExport", false);
scrMenuMgr->addMenuItem(scrActions["fileExportAsPDF"], "FileExport", false);
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["fileDocSetup"], "File", false);
scrMenuMgr->addMenuItem(scrActions["filePreferences"], "File", true);
scrMenuMgr->addMenuItem(scrActions["filePreferences150"], "File", true);
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["filePrint"], "File", false);
scrMenuMgr->addMenuItem(scrActions["PrintPreview"], "File", false);
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["fileQuit"], "File", true);
// scrActions["fileClose"]->setEnabled(false);
// scrActions["fileSave"]->setEnabled(false);
// scrActions["fileSaveAs"]->setEnabled(false);
// scrActions["fileRevert"]->setEnabled(false);
// scrActions["fileCollect"]->setEnabled(false);
// scrActions["fileImportText"]->setEnabled(false);
// scrActions["fileImportText2"]->setEnabled(false);
// scrActions["fileImportImage"]->setEnabled(false);
// scrActions["fileImportAppendText"]->setEnabled(false);
// scrActions["pageImport"]->setEnabled(false);
// scrActions["fileExportText"]->setEnabled(false);
// scrActions["fileExportAsEPS"]->setEnabled(false);
// scrActions["fileExportAsPDF"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("FileImport", false);
scrMenuMgr->setMenuEnabled("FileExport", false);
// scrActions["fileDocSetup"]->setEnabled(false);
// scrActions["filePrint"]->setEnabled(false);
// scrActions["PrintPreview"]->setEnabled(false);
scrMenuMgr->createMenu("Edit", ActionManager::defaultMenuNameEntryTranslated("Edit"));
scrMenuMgr->addMenuItem(scrActions["editUndoAction"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editRedoAction"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editActionMode"], "Edit", true);
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editCut"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editCopy"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editPaste"], "Edit", false);
scrMenuMgr->createMenu("EditPasteRecent", tr("Paste Recent"), "Edit");
scrMenuMgr->createMenu("EditContents", tr("Contents"), "Edit");
scrMenuMgr->addMenuItem(scrActions["editCopyContents"], "EditContents", false);
scrMenuMgr->addMenuItem(scrActions["editPasteContents"], "EditContents", false);
scrMenuMgr->addMenuItem(scrActions["editPasteContentsAbs"], "EditContents", false);
scrMenuMgr->addMenuItem(scrActions["editClearContents"], "EditContents", false);
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editSelectAll"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editSelectAllOnLayer"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editDeselectAll"], "Edit", false);
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editSearchReplace"], "Edit" , false);
scrMenuMgr->addMenuItem(scrActions["toolsEditWithStoryEditor"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editEditWithImageEditor"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editEditRenderSource"], "Edit", false);
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editColors"], "Edit", true);
scrMenuMgr->addMenuItem(scrActions["editReplaceColors"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editGradients"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editPatterns"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editStyles"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editMasterPages"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editJavascripts"], "Edit", false);
// scrActions["editUndoAction"]->setEnabled(false);
// scrActions["editRedoAction"]->setEnabled(false);
// scrActions["editActionMode"]->setEnabled(true);
// scrActions["editCut"]->setEnabled(false);
// scrActions["editCopy"]->setEnabled(false);
// scrActions["editPaste"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("EditPasteRecent", false);
scrMenuMgr->setMenuEnabled("EditContents", false);
// scrActions["editCopyContents"]->setEnabled(false);
// scrActions["editPasteContents"]->setEnabled(false);
// scrActions["editPasteContentsAbs"]->setEnabled(false);
// scrActions["editClearContents"]->setEnabled(false);
// scrActions["editSelectAll"]->setEnabled(false);
// scrActions["editSelectAllOnLayer"]->setEnabled(false);
// scrActions["editDeselectAll"]->setEnabled(false);
// scrActions["editSearchReplace"]->setEnabled(false);
// scrActions["editReplaceColors"]->setEnabled(false);
// scrActions["editPatterns"]->setEnabled(false);
// scrActions["editGradients"]->setEnabled(false);
// scrActions["editStyles"]->setEnabled(false);
// scrActions["editMasterPages"]->setEnabled(false);
// scrActions["editJavascripts"]->setEnabled(false);
// scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
// scrActions["editEditWithImageEditor"]->setEnabled(false);
// scrActions["editEditRenderSource"]->setEnabled(false);
scrActions["itemDuplicate"]->setEnabled(false);
scrActions["itemMulDuplicate"]->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);
scrActions["itemSendToPattern"]->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);
//Item Menu
scrMenuMgr->createMenu("Item", ActionManager::defaultMenuNameEntryTranslated("Item"));
scrMenuMgr->addMenuItem(scrActions["itemDuplicate"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemMulDuplicate"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemDelete"], "Item", false);
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemGroup"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemUngroup"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemLock"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemLockSize"], "Item", false);
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->createMenu("ItemLevel", tr("Level"));
scrMenuMgr->addMenuToMenu("ItemLevel", "Item");
scrMenuMgr->addMenuItem(scrActions["itemRaise"], "ItemLevel", false);
scrMenuMgr->addMenuItem(scrActions["itemLower"], "ItemLevel", false);
scrMenuMgr->addMenuItem(scrActions["itemRaiseToTop"], "ItemLevel", false);
scrMenuMgr->addMenuItem(scrActions["itemLowerToBottom"], "ItemLevel", false);
scrMenuMgr->createMenu("ItemLayer", tr("Send to La&yer"));
scrMenuMgr->addMenuToMenu("ItemLayer", "Item");
scrMenuMgr->addMenuItem(scrActions["itemSendToScrapbook"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemSendToPattern"], "Item", false);
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemAdjustFrameToImage"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemAdjustImageToFrame"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemExtendedImageProperties"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemUpdateImage"], "Item", false);
scrMenuMgr->createMenu("ItemPreviewSettings", tr("Preview Settings"), "Item");
scrMenuMgr->addMenuItem(scrActions["itemImageIsVisible"], "ItemPreviewSettings", false);
scrMenuMgr->addMenuSeparator("ItemPreviewSettings");
scrMenuMgr->addMenuItem(scrActions["itemPreviewLow"], "ItemPreviewSettings", false);
scrMenuMgr->addMenuItem(scrActions["itemPreviewNormal"], "ItemPreviewSettings", false);
scrMenuMgr->addMenuItem(scrActions["itemPreviewFull"], "ItemPreviewSettings", false);
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemAttributes"], "Item", false);
scrMenuMgr->createMenu("ItemPDFOptions", tr("&PDF Options"));
scrMenuMgr->addMenuToMenu("ItemPDFOptions", "Item");
scrMenuMgr->addMenuItem(scrActions["itemPDFIsAnnotation"], "ItemPDFOptions", false);
scrMenuMgr->addMenuItem(scrActions["itemPDFIsBookmark"], "ItemPDFOptions", false);
scrMenuMgr->addMenuItem(scrActions["itemPDFAnnotationProps"], "ItemPDFOptions", false);
scrMenuMgr->addMenuItem(scrActions["itemPDFFieldProps"], "ItemPDFOptions", false);
//scrMenuMgr->createMenu("ItemShapes", tr("&Shape"), "Item");
scrMenuMgr->createMenu("ItemConvertTo", tr("C&onvert To"), "Item");
scrMenuMgr->addMenuItem(scrActions["itemConvertToBezierCurve"], "ItemConvertTo", false);
scrMenuMgr->addMenuItem(scrActions["itemConvertToImageFrame"], "ItemConvertTo", false);
scrMenuMgr->addMenuItem(scrActions["itemConvertToOutlines"], "ItemConvertTo", false);
scrMenuMgr->addMenuItem(scrActions["itemConvertToPolygon"], "ItemConvertTo", false);
scrMenuMgr->addMenuItem(scrActions["itemConvertToTextFrame"], "ItemConvertTo", false);
scrMenuMgr->addMenuItem(scrActions["itemAttachTextToPath"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemDetachTextFromPath"], "Item", false);
// scrMenuMgr->createMenu("ItemPathOps", tr("Path Tools"), "Item");
scrMenuMgr->addMenuItem(scrActions["itemCombinePolygons"], "Item", false);
scrMenuMgr->addMenuItem(scrActions["itemSplitPolygons"], "Item", false);
//scrMenuMgr->setMenuEnabled("ItemShapes", false);
// scrActions["itemGroup"]->setEnabled(false);
// scrActions["itemUngroup"]->setEnabled(false);
// scrActions["itemAttachTextToPath"]->setEnabled(false);
// scrActions["itemDetachTextFromPath"]->setEnabled(false);
// scrActions["itemCombinePolygons"]->setEnabled(false);
// scrActions["itemSplitPolygons"]->setEnabled(false);
// scrActions["itemLock"]->setEnabled(false);
// scrActions["itemLockSize"]->setEnabled(false);
scrActions["itemPrintingEnabled"]->setEnabled(false);
// scrActions["itemImageIsVisible"]->setEnabled(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);
//Insert menu
scrMenuMgr->createMenu("Insert", ActionManager::defaultMenuNameEntryTranslated("Insert"));
scrMenuMgr->addMenuItem(scrActions["insertFrame"], "Insert", false);
scrMenuMgr->addMenuSeparator("Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertTextFrame"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertImageFrame"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertRenderFrame"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertTableFrame"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertShape"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertPolygon"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertLine"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertBezier"], "Insert", false);
scrMenuMgr->addMenuItem(scrActions["toolsInsertFreehandLine"], "Insert", false);
scrMenuMgr->addMenuSeparator("Insert");
scrMenuMgr->addMenuItem(scrActions["stickyTools"], "Insert", true);
scrMenuMgr->addMenuSeparator("Insert");
scrMenuMgr->addMenuItem(scrActions["insertGlyph"], "Insert", false);
scrMenuMgr->createMenu("InsertChar", tr("&Character"), "Insert");
scrMenuMgr->addMenuItem(scrActions["unicodePageNumber"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodePageCount"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSmartHyphen"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeNonBreakingHyphen"], "InsertChar", false);
scrMenuMgr->addMenuSeparator("InsertChar");
scrMenuMgr->addMenuItem(scrActions["unicodeCopyRight"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeRegdTM"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeTM"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSolidus"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeBullet"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeMidpoint"], "InsertChar", false);
scrMenuMgr->addMenuSeparator("InsertChar");
scrMenuMgr->addMenuItem(scrActions["unicodeDashEm"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeDashEn"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeDashFigure"], "InsertChar", false);
scrMenuMgr->addMenuItem(scrActions["unicodeDashQuotation"], "InsertChar", false);
scrMenuMgr->createMenu("InsertQuote", tr("&Quote"), "Insert");
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteApostrophe"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteStraight"], "InsertQuote", false);
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleLeft"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleRight"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleLeft"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleRight"], "InsertQuote", false);
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleReversed"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleReversed"], "InsertQuote", false);
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteLowSingleComma"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteLowDoubleComma"], "InsertQuote", false);
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleLeftGuillemet"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteSingleRightGuillemet"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleLeftGuillemet"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteDoubleRightGuillemet"], "InsertQuote", false);
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKSingleLeft"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKSingleRight"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKDoubleLeft"], "InsertQuote", false);
scrMenuMgr->addMenuItem(scrActions["unicodeQuoteCJKDoubleRight"], "InsertQuote", false);
scrMenuMgr->createMenu("InsertSpace", tr("S&paces && Breaks"), "Insert");
scrMenuMgr->addMenuItem(scrActions["unicodeNonBreakingSpace"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSpaceEN"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSpaceEM"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSpaceThin"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSpaceThick"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSpaceMid"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeSpaceHair"], "InsertSpace", false);
scrMenuMgr->addMenuSeparator("InsertSpace");
scrMenuMgr->addMenuItem(scrActions["unicodeNewLine"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeFrameBreak"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeColumnBreak"], "InsertSpace", false);
scrMenuMgr->addMenuItem(scrActions["unicodeZerowidthSpace"], "InsertSpace", false);
scrMenuMgr->createMenu("InsertLigature", tr("Liga&ture"), "Insert");
scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ff"], "InsertLigature", false);
scrMenuMgr->addMenuItem(scrActions["unicodeLigature_fi"], "InsertLigature", false);
scrMenuMgr->addMenuItem(scrActions["unicodeLigature_fl"], "InsertLigature", false);
scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ffi"], "InsertLigature", false);
scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ffl"], "InsertLigature", false);
scrMenuMgr->addMenuItem(scrActions["unicodeLigature_ft"], "InsertLigature", false);
scrMenuMgr->addMenuItem(scrActions["unicodeLigature_st"], "InsertLigature", false);
scrMenuMgr->addMenuSeparator("Insert");
scrMenuMgr->addMenuItem(scrActions["insertSampleText"], "Insert", false);
// scrActions["insertFrame"]->setEnabled(false);
//Page menu
scrMenuMgr->createMenu("Page", ActionManager::defaultMenuNameEntryTranslated("Page"));
scrMenuMgr->addMenuItem(scrActions["pageInsert"], "Page", false);
scrMenuMgr->addMenuItem(scrActions["pageImport"], "Page", false);
scrMenuMgr->addMenuItem(scrActions["pageDelete"], "Page", false);
scrMenuMgr->addMenuItem(scrActions["pageCopy"], "Page", false);
scrMenuMgr->addMenuItem(scrActions["pageMove"], "Page", false);
scrMenuMgr->addMenuSeparator("Page");
scrMenuMgr->addMenuItem(scrActions["pageApplyMasterPage"], "Page", false);
scrMenuMgr->addMenuItem(scrActions["pageCopyToMasterPage"], "Page", false);
scrMenuMgr->addMenuItem(scrActions["pageManageGuides"], "Page", false);
scrMenuMgr->addMenuItem(scrActions["pageManageMargins"], "Page", false);
scrMenuMgr->addMenuSeparator("Page");
scrMenuMgr->addMenuItem(scrActions["viewSnapToGrid"], "Page", true);
scrMenuMgr->addMenuItem(scrActions["viewSnapToGuides"], "Page", true);
// scrActions["pageDelete"]->setEnabled(false);
// scrActions["pageMove"]->setEnabled(false);
//View menu
scrMenuMgr->createMenu("View", ActionManager::defaultMenuNameEntryTranslated("View"));
scrMenuMgr->addMenuItem(scrActions["viewFitInWindow"], "View", false);
scrMenuMgr->addMenuItem(scrActions["viewFitWidth"], "View", false);
scrMenuMgr->addMenuItem(scrActions["viewFit50"], "View", false);
scrMenuMgr->addMenuItem(scrActions["viewFit75"], "View", false);
scrMenuMgr->addMenuItem(scrActions["viewFit100"], "View", false);
scrMenuMgr->addMenuItem(scrActions["viewFit200"], "View", false);
scrMenuMgr->addMenuItem(scrActions["viewFit400"], "View", false);
scrMenuMgr->addMenuSeparator("View");
scrMenuMgr->addMenuItem(scrActions["viewFitPreview"], "View", true);
scrMenuMgr->addMenuSeparator("View");
scrMenuMgr->addMenuItem(scrActions["viewShowMargins"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowBleeds"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowFrames"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowLayerMarkers"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowImages"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowGrid"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowGuides"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowColumnBorders"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowBaseline"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowTextChain"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowTextControls"], "View", true);
scrMenuMgr->addMenuItem(scrActions["viewShowRulers"], "View", false);
scrMenuMgr->addMenuItem(scrActions["viewRulerMode"], "View", true);
scrMenuMgr->addMenuItem(scrActions["showMouseCoordinates"], "View", true);
// scrActions["viewShowRulers"]->setEnabled(false);
//CB If this is viewNewView imeplemented, it should be on the windows menu
// scrMenuMgr->addMenuItem(scrActions["viewNewView"], "View");
//Tool menu
/*
scrMenuMgr->createMenu("Tools", tr("&Tools"));
scrMenuMgr->addMenuItem(scrActions["toolsProperties"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsOutline"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsScrapbook"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsLayers"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsPages"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsBookmarks"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsMeasurements"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsActionHistory"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsPreflightVerifier"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsAlignDistribute"], "Tools");
scrMenuMgr->addMenuSeparator("Tools");
scrMenuMgr->addMenuItem(scrActions["toolsToolbarTools"], "Tools");
scrMenuMgr->addMenuItem(scrActions["toolsToolbarPDF"], "Tools");
//scrActions["toolsPreflightVerifier"]->setEnabled(false);*/
//Extra menu
scrMenuMgr->createMenu("Extras", ActionManager::defaultMenuNameEntryTranslated("Extras"));
scrMenuMgr->addMenuItem(scrActions["extrasManageImages"], "Extras", false);
scrMenuMgr->addMenuItem(scrActions["extrasHyphenateText"], "Extras", false);
scrMenuMgr->addMenuItem(scrActions["extrasDeHyphenateText"], "Extras", false);
scrMenuMgr->addMenuItem(scrActions["extrasGenerateTableOfContents"], "Extras", false);
scrMenuMgr->setMenuEnabled("Extras", false);
// scrActions["extrasHyphenateText"]->setEnabled(false);
// scrActions["extrasDeHyphenateText"]->setEnabled(false);
connect(scrMenuMgr->getLocalPopupMenu("Extras"), SIGNAL(aboutToShow()), this, SLOT(extrasMenuAboutToShow()));
//Window menu
scrMenuMgr->createMenu("Windows", ActionManager::defaultMenuNameEntryTranslated("Windows"), QString::null, true);
connect(scrMenuMgr->getLocalPopupMenu("Windows"), SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
addDefaultWindowMenuItems();
//Help menu
scrMenuMgr->createMenu("Help", ActionManager::defaultMenuNameEntryTranslated("Help"));
scrMenuMgr->addMenuItem(scrActions["helpManual"], "Help", true);
scrMenuMgr->addMenuItem(scrActions["helpManual2"], "Help", true);
scrMenuMgr->addMenuSeparator("Help");
scrMenuMgr->addMenuItem(scrActions["helpTooltips"], "Help", true);
scrMenuMgr->addMenuSeparator("Help");
scrMenuMgr->addMenuItem(scrActions["helpOnlineWWW"], "Help", true);
scrMenuMgr->addMenuItem(scrActions["helpOnlineDocs"], "Help", true);
scrMenuMgr->addMenuItem(scrActions["helpOnlineWiki"], "Help", true);
scrMenuMgr->createMenu("HelpOnlineTutorials", tr("Online &Tutorials"), "Help");
scrMenuMgr->addMenuItem(scrActions["helpOnlineTutorial1"], "HelpOnlineTutorials", true);
scrMenuMgr->addMenuSeparator("Help");
scrMenuMgr->addMenuItem(scrActions["helpCheckUpdates"], "Help", true);
scrMenuMgr->addMenuSeparator("Help");
scrMenuMgr->addMenuItem(scrActions["helpAboutScribus"], "Help", true);
scrMenuMgr->addMenuItem(scrActions["helpAboutPlugins"], "Help", true);
scrMenuMgr->addMenuItem(scrActions["helpAboutQt"], "Help", true);
scrMenuMgr->addMenuToMenuBar("File");
scrMenuMgr->addMenuToMenuBar("Edit");
scrMenuMgr->addMenuToMenuBar("Item");
// scrMenuMgr->setMenuEnabled("Item", false);
scrMenuMgr->addMenuToMenuBar("Insert");
scrMenuMgr->setMenuEnabled("Insert", false);
scrMenuMgr->addMenuToMenuBar("Page");
// scrMenuMgr->setMenuEnabled("Page", false);
scrMenuMgr->addMenuToMenuBar("View");
// scrMenuMgr->setMenuEnabled("View", false);
//scrMenuMgr->addMenuToMenuBar("Tools");
scrMenuMgr->addMenuToMenuBar("Extras");
scrMenuMgr->setMenuEnabled("Extras", false);
scrMenuMgr->addMenuToMenuBar("Windows");
//scrMenuMgr->setMenuEnabled("Windows", false);
menuBar()->addSeparator();
scrMenuMgr->addMenuToMenuBar("Help");
}
void ScribusMainWindow::addDefaultWindowMenuItems()
{
scrMenuMgr->clearMenu("Windows");
scrMenuMgr->addMenuItem(scrActions["windowsCascade"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["windowsTile"], "Windows", true);
scrMenuMgr->addMenuSeparator("Windows");
scrMenuMgr->addMenuItem(scrActions["toolsProperties"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsOutline"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsScrapbook"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsLayers"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsPages"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsBookmarks"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsMeasurements"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsActionHistory"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsPreflightVerifier"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsAlignDistribute"], "Windows", true);
scrMenuMgr->addMenuSeparator("Windows");
scrMenuMgr->addMenuItem(scrActions["toolsToolbarTools"], "Windows", true);
scrMenuMgr->addMenuItem(scrActions["toolsToolbarPDF"], "Windows", true);
}
void ScribusMainWindow::initStatusBar()
{
mainWindowStatusLabel = new QLabel( " ", statusBar());
mainWindowProgressBar = new QProgressBar(statusBar());
mainWindowProgressBar->setAlignment(Qt::AlignHCenter);
mainWindowProgressBar->setFixedWidth( 100 );
mainWindowProgressBar->reset();
mainWindowXPosLabel = new QLabel( tr("X-Pos:"), statusBar());
mainWindowYPosLabel = new QLabel( tr("Y-Pos:"), statusBar());
mainWindowXPosDataLabel = new QLabel( " ", statusBar());
mainWindowYPosDataLabel = new QLabel( " ", statusBar());
statusBar()->addPermanentWidget(mainWindowStatusLabel, 6);
statusBar()->addPermanentWidget(mainWindowProgressBar, 0);
statusBar()->addPermanentWidget(mainWindowXPosLabel, 0);
statusBar()->addPermanentWidget(mainWindowXPosDataLabel, 1);
statusBar()->addPermanentWidget(mainWindowYPosLabel, 0);
statusBar()->addPermanentWidget(mainWindowYPosDataLabel, 1);
}
void ScribusMainWindow::setStatusBarMousePosition(double xp, double yp)
{
double xn = xp;
double yn = yp;
if (doc->guidesSettings.rulerMode)
{
xn -= doc->currentPage()->xOffset();
yn -= doc->currentPage()->yOffset();
}
xn -= doc->rulerXoffset;
yn -= doc->rulerYoffset;
mainWindowXPosDataLabel->setText(value2String(xn, doc->unitIndex(), true, true));
mainWindowYPosDataLabel->setText(value2String(yn, doc->unitIndex(), true, true));
}
void ScribusMainWindow::setStatusBarInfoText(QString newText)
{
if (mainWindowStatusLabel)
mainWindowStatusLabel->setText(newText);
}
//AV to be replaced with Selection::update and listener in PropertiesPalette
void ScribusMainWindow::setTBvals(PageItem *currItem)
{
if (currItem->itemText.length() != 0)
{
// int ChPos = qMin(currItem->CPos, static_cast<int>(currItem->itemText.length()-1));
const ParagraphStyle& currPStyle( (doc->appMode == modeEdit) ? currItem->currentStyle() : currItem->itemText.defaultStyle());
setAbsValue(currPStyle.alignment());
propertiesPalette->setParStyle(currPStyle.parent());
propertiesPalette->setCharStyle(currItem->currentCharStyle().parent());
doc->currentStyle = currItem->currentStyle();
// #8112 : do not use operator= here as it does not update style features
doc->currentStyle.charStyle().setStyle( currItem->currentCharStyle() );
emit TextStyle(doc->currentStyle);
// to go: (av)
emit TextUnderline(doc->currentStyle.charStyle().underlineOffset(), doc->currentStyle.charStyle().underlineWidth());
emit TextStrike(doc->currentStyle.charStyle().strikethruOffset(), doc->currentStyle.charStyle().strikethruWidth());
emit TextShadow(doc->currentStyle.charStyle().shadowXOffset(), doc->currentStyle.charStyle().shadowYOffset());
emit TextFarben(doc->currentStyle.charStyle().strokeColor(),
doc->currentStyle.charStyle().fillColor(),
doc->currentStyle.charStyle().strokeShade(),
doc->currentStyle.charStyle().fillShade());
emit TextIFont(doc->currentStyle.charStyle().font().scName());
emit TextISize(doc->currentStyle.charStyle().fontSize());
emit TextUSval(doc->currentStyle.charStyle().tracking());
emit TextStil(doc->currentStyle.charStyle().effects());
emit TextScale(doc->currentStyle.charStyle().scaleH());
emit TextScaleV(doc->currentStyle.charStyle().scaleV());
emit TextBase(doc->currentStyle.charStyle().baselineOffset());
emit TextOutline(doc->currentStyle.charStyle().outlineWidth());
}
}
//Special keys assigned to actions are stolen by the action and not passed to
//keyPressEvent so process them here.
void ScribusMainWindow::specialActionKeyEvent(const QString& actionName, int unicodevalue)
{
if (HaveDoc)
{
if (doc->appMode==modeEdit)
{
if (doc->m_Selection->count() == 1)
{
PageItem *currItem = doc->m_Selection->itemAt(0);
if (currItem!=NULL)
{
if (unicodevalue!=-1)
{
if (currItem->HasSel && currItem->itemType()==PageItem::TextFrame)
currItem->asTextFrame()->deleteSelectedTextFromFrame();
currItem->itemText.insertChars(currItem->CPos, QString(QChar(unicodevalue)), true);
currItem->CPos += 1;
// currItem->Tinput = true;
currItem->update();
}
else if (actionName=="unicodeSmartHyphen") //ignore the char as we use an attribute if the text item, for now.
{
// this code is currently dead since unicodeSmartHyphen
// doesnt have unicodevalue == -1 any more
if (currItem->CPos-1>0)
{
#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
currItem->itemText.insertChars(currItem->CPos, QString(SpecialChars::SHYPHEN), true);
currItem->CPos += 1;
#endif
// currItem->Tinput = true;
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).isNull())
return false;
retVal=true;
//Palette actions
if (currKeySeq == scrActions["specialToggleAllPalettes"]->shortcut())
scrActions["specialToggleAllPalettes"]->activate(QAction::Trigger);
else
// CB These were moved to ActionManager via the setShortcutContext(Qt::ApplicationShortcut) calls, leaving for notes for now
// if (currKeySeq == scrActions["toolsProperties"]->accel())
// scrActions["toolsProperties"]->toggle();
// else
// if (currKeySeq == scrActions["toolsOutline"]->accel())
// scrActions["toolsOutline"]->toggle();
// else
// if (currKeySeq == scrActions["toolsScrapbook"]->accel())
// scrActions["toolsScrapbook"]->toggle();
// else
// if (currKeySeq == scrActions["toolsLayers"]->accel())
// scrActions["toolsLayers"]->toggle();
// else
// if (currKeySeq == scrActions["toolsPages"]->accel())
// scrActions["toolsPages"]->toggle();
// else
// if (currKeySeq == scrActions["toolsBookmarks"]->accel())
// scrActions["toolsBookmarks"]->toggle();
// else
// if (currKeySeq == scrActions["toolsActionHistory"]->accel())
// scrActions["toolsActionHistory"]->toggle();
// else
// if (currKeySeq == scrActions["toolsPreflightVerifier"]->accel())
// scrActions["toolsPreflightVerifier"]->toggle();
// else
// if (currKeySeq == scrActions["toolsAlignDistribute"]->accel())
// scrActions["toolsAlignDistribute"]->toggle();
// else
//Edit actions
if (currKeySeq == scrActions["editStyles"]->shortcut())
scrActions["editStyles"]->toggle();
else
if (currKeySeq == scrActions["editUndoAction"]->shortcut() && scrActions["editUndoAction"]->isEnabled())
scrActions["editUndoAction"]->activate(QAction::Trigger);
else
if (currKeySeq == scrActions["editRedoAction"]->shortcut() && scrActions["editRedoAction"]->isEnabled())
scrActions["editRedoAction"]->activate(QAction::Trigger);
else
//Other actions
if (currKeySeq == scrActions["fileQuit"]->shortcut())
scrActions["fileQuit"]->activate(QAction::Trigger);
else
//Zoom actions
if (currKeySeq == scrActions["toolsZoomIn"]->shortcut())
scrActions["toolsZoomIn"]->activate(QAction::Trigger);
else
if (currKeySeq == scrActions["toolsZoomOut"]->shortcut())
scrActions["toolsZoomOut"]->activate(QAction::Trigger);
else
retVal=false;
}
else
retVal=false;
//Return false to pass event to object
return retVal;
}
//AV -> CanvasMode
void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
{
QList<QMdiSubWindow *> windows;
QMdiSubWindow* w = NULL;
int kk = k->key();
QString uc = k->text();
// QString cr, Tcha, Twort;
if (HaveDoc)
{
if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift))
{
qApp->changeOverrideCursor(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->count() != 0)
{
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->removeAt(currItem->ItemNr);
}
else
view->Deselect(false);
view->cancelGroupTransaction();
break;
case modeEdit:
view->cancelGroupTransaction();
break;
case modeLinkFrames:
case modeUnlinkFrames:
case modeRotation:
case modeEditGradientVectors:
case modeCopyProperties:
view->Deselect(false);
case modeEyeDropper:
case modeImportObject:
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->removeAt(currItem->ItemNr);
}
else
{
doc->SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem->ItemNr, 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->removeAt(currItem->ItemNr);
}
break;
}
}
doc->DragP = false;
doc->leaveDrag = false;
view->stopAllDrags();
doc->SubMode = -1;
doc->ElemToLink = NULL;
slotSelect();
if (doc->m_Selection->count() == 0)
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) && (!view->zoomSpinBox->hasFocus()) && (!view->pageSelector->hasFocus()))
{
//Show our context menu
QKeySequence currKeySeq = QKeySequence(kk | keyMod);
if (currKeySeq.matches(scrActions["viewShowContextMenu"]->shortcut()) == QKeySequence::ExactMatch)
{
ContextMenu* cmen=NULL;
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
if (doc->m_Selection->count() == 0)
{
//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->count() == 0))
{
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())
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->currentPageLayout].Columns;
if (pg > -1)
view->GotoPage(pg);
}
keyrep = false;
return;
break;
case Qt::Key_PageDown:
if (doc->masterPageMode())
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->currentPageLayout].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;
}
}
/** Now if we have an item selected
* - In normal mode we can:
* -- Use backspace or delete to delete the item
* -- In edit mode of an image frame, use the arrow keys to resize the image:
(flows to pageitem_imageframe for control)
Alt right arrow, move right side of image outwards (expand)
Alt left arrow, move right side inwards (shrink)
Alt down arrow, move bottom side downwards (expand)
Alt up arrow, move top side inwards (shrink)
*/
if (doc->m_Selection->count() != 0)
{
PageItem *currItem = doc->m_Selection->itemAt(0);
if (doc->appMode == modeEdit)
{
if (currItem->asImageFrame() && !currItem->locked())
{
currItem->handleModeEditKey(k, keyrep);
}
//FIXME:av view->oldCp = currItem->CPos;
if (currItem->itemType() == PageItem::TextFrame)
{
bool kr=keyrep;
currItem->handleModeEditKey(k, keyrep);
keyrep=kr;
}
slotDocCh(false);
}
}
}
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)
qApp->changeOverrideCursor(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) && (!view->zoomSpinBox->hasFocus()) && (!view->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
Preferences *prefsWin = findChild<Preferences *>(QString::fromLocal8Bit("PreferencesWindow"));
PreferencesDialog *prefsDialog = findChild<PreferencesDialog *>(QString::fromLocal8Bit("PreferencesDialog"));
NewDoc *newDocWin = findChild<NewDoc *>(QString::fromLocal8Bit("NewDocumentWindow"));
if (prefsWin!=NULL || 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();
ActWin->close();
if (tw == ActWin)
{
ce->ignore();
connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(newActWin(QMdiSubWindow *)));
return;
}
}
}
}
propertiesPalette->hide();
outlinePalette->hide();
scrapbookPalette->hide();
bookmarkPalette->hide();
layerPalette->hide();
pagePalette->hide();
// measurementPalette->hide();
docCheckerPalette->hide();
undoPalette->hide();
alignDistributePalette->hide();
guidePalette->hide();
charPalette->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();
PrefsManager::deleteInstance();
FormatsManager::deleteInstance();
UrlLauncher::deleteInstance();
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
qApp->exit(0);
}
/////////////////////////////////////////////////////////////////////
// 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(), PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
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->pageSets[facingPages].FirstPage = firstPage;
doc->bleeds.Bottom = dia->bleedBottom();
doc->bleeds.Top = dia->bleedTop();
doc->bleeds.Left = dia->bleedLeft();
doc->bleeds.Right = 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);
}
}
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->pageSets[facingPages].FirstPage = firstPage;
doc->bleeds.Bottom = dia->bleedBottom();
doc->bleeds.Top = dia->bleedTop();
doc->bleeds.Left = dia->bleedLeft();
doc->bleeds.Right = 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);
/* TODO CB finish later this week.
if (HaveDoc)
doc->OpenNodes = outlinePalette->buildReopenVals();
MarginStruct margins(topMargin, leftMargin, bottomMargin, rightMargin);
DocPagesSetup pagesSetup(pageArrangement, firstPageLocation, firstPageNumber, orientation, autoTextFrames, columnDistance, columnCount);
QString newDocName(tr("Document")+"-"+QString::number(DocNr));
doc = new ScribusDoc(newDocName, unitindex, pagesize, margins, pagesSetup);
doc->setLoading(true);
doc->setup(unitIndex, pageArrangement, firstPageLocation, orientation, firstPageNumber, defaultPageSize, newDocName);
HaveDoc++;
DocNr++;
if (ScCore->haveCMS() && doc->CMSSettings.CMSinUse)
recalcColors();
//CB NOTE should be all done now
doc->setPage(width, height, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, columnCount, autoTextFrames, pageArrangement);
doc->setMasterPageMode(false);
doc->addMasterPage(0, CommonStrings::masterPageNormal);
int createCount=qMax(pageCount,1);
for (int i = 0; i < createCount; ++i)
doc->addPage(i, CommonStrings::masterPageNormal, true);
doc->addSection();
doc->setFirstSectionFromFirstPageNumber();
doc->setModified(false);
doc->OpenNodes.clear();
actionManager->disconnectNewDocActions();
actionManager->connectNewDocActions(doc);
//<<View and window code
ScribusWin* w = new ScribusWin(mdiArea, doc);
w->setMainWindow(this);
if (view!=NULL)
{
actionManager->disconnectNewViewActions();
disconnect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
}
view = new ScribusView(w, this, doc);
doc->setCurrentPage(doc->Pages->at(0));
doc->setGUI(this, view);
doc->setLoading(false);
//run after setGUI to set up guidepalette ok
view->setScale(prefsManager->displayScale());
actionManager->connectNewViewActions(view);
alignDistributePalette->setDoc(doc);
docCheckerPalette->clearErrorList();
w->setView(view);
ActWin = w;
doc->WinHan = w;
w->setCentralWidget(view);
doc->connectDocSignals(); //Must be before the first reformpages
view->reformPages(true);
//>>
connect(undoManager, SIGNAL(undoRedoDone()), view, SLOT(DrawNew()));
//connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
connect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
// connect(w, SIGNAL(SaveAndClose()), this, SLOT(DoSaveClose()));
//Independent finishing tasks after doc setup
if (showView)
{
if ( mdiArea->windowList().isEmpty() )
w->showMaximized();
else
w->show();
view->show();
}
connect(w, SIGNAL(AutoSaved()), this, SLOT(slotAutoSaved()));
connect(ScCore->fileWatcher, SIGNAL(fileChanged(QString)), doc, SLOT(updatePict(QString)));
connect(ScCore->fileWatcher, SIGNAL(fileDeleted(QString)), doc, SLOT(removePict(QString)));
scrActions["fileSave"]->setEnabled(false);
undoManager->switchStack(doc->DocName);
styleManager->currentDoc(doc);
tocGenerator->setDoc(doc);
return doc;
*/
}
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 = new ScribusDoc(newDocName, unitindex, pagesize, margins, pagesSetup);
tempDoc->setLoading(true);
outlinePalette->setDoc(tempDoc);
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->marginPreset = 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)
{
actionManager->connectNewViewActions(tempView);
alignDistributePalette->setDoc(tempDoc);
docCheckerPalette->clearErrorList();
}
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));
connect(undoManager, SIGNAL(undoRedoBegin()), tempDoc, SLOT(undoRedoBegin()));
connect(undoManager, SIGNAL(undoRedoDone()), tempDoc, SLOT(undoRedoDone()));
connect(undoManager, SIGNAL(undoRedoDone()), tempView, SLOT(DrawNew()));
//connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
connect(tempView, SIGNAL(signalGuideInformation(int, qreal)), alignDistributePalette, SLOT(setGuide(int, qreal)));
// connect(w, SIGNAL(SaveAndClose()), this, SLOT(DoSaveClose()));
}
//Independent finishing tasks after tempDoc setup
if (showView)
{
if ( mdiArea->subWindowList().count() == 1)
w->showMaximized();
else
w->show();
tempView->show();
}
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 )));
//scrActions["fileSave"]->setEnabled(false);
tempView->cmsToolbarButton->setChecked(tempDoc->HasCMS);
undoManager->switchStack(tempDoc->DocName);
styleManager->setDoc(tempDoc);
tocGenerator->setDoc(tempDoc);
}
undoManager->setUndoEnabled(true);
return tempDoc;
}
void ScribusMainWindow::newFileFromTemplate()
{
nftdialog* nftdia = new nftdialog(this, ScCore->getGuiLanguage(), PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
if (nftdia->exec())
{
if (nftdia->nftGui->currentDocumentTemplate)
{
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
if (loadDoc(QDir::cleanPath(nftdia->nftGui->currentDocumentTemplate->file)))
{
doc->hasName = false;
UndoManager::instance()->renameStack(nftdia->nftGui->currentDocumentTemplate->name);
doc->DocName = nftdia->nftGui->currentDocumentTemplate->name;
updateActiveWindowCaption(QObject::tr("Document Template: ") + nftdia->nftGui->currentDocumentTemplate->name);
QDir::setCurrent(PrefsManager::instance()->documentDir());
removeRecent(QDir::cleanPath(nftdia->nftGui->currentDocumentTemplate->file));
}
qApp->changeOverrideCursor(Qt::ArrowCursor);
}
}
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();
//connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
}
void ScribusMainWindow::windowsMenuAboutToShow()
{
for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrWindowsActions.begin(); it!=scrWindowsActions.end(); ++it )
scrMenuMgr->removeMenuItem((*it), "Windows");
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->addMenuSeparator("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)) );
if (windowCount>1)
scrMenuMgr->addMenuItem(scrWindowsActions[docInWindow], "Windows", true);
scrWindowsActions[docInWindow]->setChecked(mdiArea->activeSubWindow() == windows.at(i));
}
}
}
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)
{
for (int i = 0; i < doc->Items->count(); ++i)
{
#ifdef HAVE_OSG
if ((doc->Items->at(i)->itemType() == PageItem::ImageFrame) && (!((doc->Items->at(i)->asLatexFrame()) || (doc->Items->at(i)->asOSGFrame()))))
#else
if ((doc->Items->at(i)->itemType() == PageItem::ImageFrame) && (!(doc->Items->at(i)->asLatexFrame())))
#endif
{
enablePicManager = true;
break;
}
}
}
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;
if (doc!=0 && doc->appMode == modeEditClip)
view->requestMode(submodeEndNodeEdit);
ScribusWin* scw = dynamic_cast<ScribusWin *>(w->widget());
if (!scw)
return;
if (scw && scw->doc())
{
if (!scw->doc()->hasGUI())
return;
}
ActWin = scw;
if (ActWin->doc()==NULL)
return;
if (doc != NULL)
{
if ((HaveDoc) && (doc != ActWin->doc()))
outlinePalette->buildReopenVals();
}
docCheckerPalette->clearErrorList();
doc = ActWin->doc();
undoManager->switchStack(doc->DocName);
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);
//disconnect(doc->m_Selection, SIGNAL(empty()), 0, 0);
}
}
view = ActWin->view();
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())
{
scanDocument();
docCheckerPalette->buildErrorList(doc);
SwitchWin();
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
ScribusWin* swin;
for ( int i = 0; i < static_cast<int>(windows.count()); ++i )
{
swin = dynamic_cast<ScribusWin *>(windows.at(i)->widget());
if (swin)
{
if (swin==ActWin && doc->masterPageMode())
swin->setMasterPagesPaletteShown(true);
else
swin->setMasterPagesPaletteShown(false);
}
}
//if (doc->masterPageMode())
// ActWin->setMasterPagesPaletteShown(true);
view->requestMode(doc->appMode);
}
view->setFocus();
// mdiArea->setScrollBarsEnabled(!(w->isMaximized()));
scrActions["viewShowMargins"]->setChecked(doc->guidesSettings.marginsShown);
scrActions["viewShowBleeds"]->setChecked(doc->guidesSettings.showBleed);
scrActions["viewShowFrames"]->setChecked(doc->guidesSettings.framesShown);
scrActions["viewShowLayerMarkers"]->setChecked(doc->guidesSettings.layerMarkersShown);
scrActions["viewShowGrid"]->setChecked(doc->guidesSettings.gridShown);
scrActions["viewShowGuides"]->setChecked(doc->guidesSettings.guidesShown);
scrActions["viewShowColumnBorders"]->setChecked(doc->guidesSettings.colBordersShown);
scrActions["viewShowBaseline"]->setChecked(doc->guidesSettings.baselineGridShown);
scrActions["viewShowImages"]->setChecked(doc->guidesSettings.showPic);
scrActions["viewShowTextChain"]->setChecked(doc->guidesSettings.linkShown);
scrActions["viewShowTextControls"]->setChecked(doc->guidesSettings.showControls);
scrActions["viewShowRulers"]->setChecked(doc->guidesSettings.rulersShown);
scrActions["viewRulerMode"]->setChecked(doc->guidesSettings.rulerMode);
scrActions["extrasGenerateTableOfContents"]->setEnabled(doc->hasTOCSetup());
if (!doc->masterPageMode())
pagePalette->Rebuild();
outlinePalette->setDoc(doc);
if (outlinePalette->isVisible())
{
outlinePalette->BuildTree(false);
outlinePalette->reopenTree();
}
RestoreBookMarks();
if (!doc->isLoading())
{
if (doc->m_Selection->count() != 0)
{
HaveNewSel(doc->m_Selection->itemAt(0)->itemType());
doc->m_Selection->itemAt(0)->emitAllToGUI();
}
else
HaveNewSel(-1);
}
tocGenerator->setDoc(doc);
styleManager->setDoc(doc);
// 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 )
windowWidget->showNormal();
newActWin(windowWidget);
}
void ScribusMainWindow::docSetup(ReformDoc* dia)
{
slotChangeUnit(dia->getSelectedUnit(), false);
dia->updateDocumentSettings();
if (dia->imageResolutionChanged())
{
setStatusBarInfoText( tr("Updating Images"));
mainWindowProgressBar->reset();
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
qApp->processEvents();
doc->recalcPicturesRes(true);
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
setStatusBarInfoText("");
mainWindowProgressBar->reset();
view->previewQualitySwitcher->blockSignals(true);
view->previewQualitySwitcher->setCurrentIndex(doc->itemToolPrefs.imageLowResType);
view->previewQualitySwitcher->blockSignals(false);
}
propertiesPalette->Fonts->RebuildList(doc);
scrActions["viewShowMargins"]->setChecked(doc->guidesSettings.marginsShown);
scrActions["viewShowBleeds"]->setChecked(doc->guidesSettings.showBleed);
scrActions["viewShowFrames"]->setChecked(doc->guidesSettings.framesShown);
scrActions["viewShowLayerMarkers"]->setChecked(doc->guidesSettings.layerMarkersShown);
scrActions["viewShowGrid"]->setChecked(doc->guidesSettings.gridShown);
scrActions["viewShowGuides"]->setChecked(doc->guidesSettings.guidesShown);
scrActions["viewShowColumnBorders"]->setChecked(doc->guidesSettings.colBordersShown);
scrActions["viewShowBaseline"]->setChecked(doc->guidesSettings.baselineGridShown);
scrActions["viewShowImages"]->setChecked(doc->guidesSettings.showPic);
scrActions["viewShowTextChain"]->setChecked(doc->guidesSettings.linkShown);
scrActions["viewShowTextControls"]->setChecked(doc->guidesSettings.showControls);
scrActions["viewShowRulers"]->setChecked(doc->guidesSettings.rulersShown);
scrActions["viewRulerMode"]->setChecked(doc->guidesSettings.rulerMode);
scrActions["extrasGenerateTableOfContents"]->setEnabled(doc->hasTOCSetup());
view->cmsToolbarButton->setChecked(doc->HasCMS);
//doc emits changed() via this
doc->setMasterPageMode(true);
view->reformPages();
doc->setMasterPageMode(false);
/* doc->setLoading(true);
uint pageCount=doc->DocPages.count();
for (uint c=0; c<pageCount; ++c)
Apply_MasterPage(doc->DocPages.at(c)->MPageNam, c, false);
doc->setLoading(false); */
view->reformPages();
view->GotoPage(doc->currentPage()->pageNr());
view->DrawNew();
propertiesPalette->ShowCMS();
pagePalette->rebuildPages();
}
bool ScribusMainWindow::slotDocSetup()
{
bool ret = false;
ReformDoc* dia = new ReformDoc(this, doc);
Q_CHECK_PTR(dia);
if (dia->exec())
{
docSetup(dia);
ret = true;
}
delete dia;
return ret;
}
void ScribusMainWindow::SwitchWin()
{
updateActiveWindowCaption(doc->DocName);
// scrActions["shade100"]->setChecked(true);
propertiesPalette->setDoc(doc);
propertiesPalette->Cpal->ChooseGrad(0);
pagePalette->setView(view);
propertiesPalette->Fonts->RebuildList(doc);
layerPalette->setDoc(doc);
guidePalette->setDoc(doc);
charPalette->setDoc(doc);
outlinePalette->setDoc(doc);
rebuildLayersList();
view->updateLayerMenu();
view->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);
} */
scrActions["fileClose"]->setEnabled(true);
if (doc->masterPageMode())
{
scrActions["pageInsert"]->setEnabled(false);
scrActions["pageDelete"]->setEnabled(false);
scrActions["pageCopy"]->setEnabled(false);
scrActions["pageMove"]->setEnabled(false);
scrActions["pageApplyMasterPage"]->setEnabled(false);
scrActions["pageCopyToMasterPage"]->setEnabled(false);
scrActions["editMasterPages"]->setEnabled(false);
scrActions["fileNew"]->setEnabled(false);
scrActions["fileNewFromTemplate"]->setEnabled(false);
scrActions["fileSave"]->setEnabled(true);
scrActions["fileOpen"]->setEnabled(false);
scrActions["fileClose"]->setEnabled(false);
scrActions["fileRevert"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("FileOpenRecent", false);
pagePalette->enablePalette(false);
scrActions["toolsPDFPushButton"]->setEnabled(false);
scrActions["toolsPDFTextField"]->setEnabled(false);
scrActions["toolsPDFCheckBox"]->setEnabled(false);
scrActions["toolsPDFComboBox"]->setEnabled(false);
scrActions["toolsPDFListBox"]->setEnabled(false);
scrActions["toolsPDFAnnotText"]->setEnabled(false);
#ifdef HAVE_OSG
scrActions["toolsPDFAnnot3D"]->setEnabled(false);
#endif
}
else
{
scrActions["editMasterPages"]->setEnabled(true);
scrActions["fileNew"]->setEnabled(true);
scrActions["fileNewFromTemplate"]->setEnabled(true);
scrActions["fileOpen"]->setEnabled(true);
scrActions["fileClose"]->setEnabled(true);
scrActions["fileSave"]->setEnabled(true);
scrActions["fileRevert"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("FileOpenRecent", true);
if (doc->isModified())
slotDocCh(false);
else
{
bool setter = doc->Pages->count() > 1 ? true : false;
scrActions["pageDelete"]->setEnabled(setter);
scrActions["pageMove"]->setEnabled(setter);
}
// scrMenuMgr->setMenuEnabled("Page", true);
scrActions["pageInsert"]->setEnabled(true);
scrActions["pageImport"]->setEnabled(true);
scrActions["pageCopy"]->setEnabled(true);
scrActions["pageApplyMasterPage"]->setEnabled(true);
scrActions["pageCopyToMasterPage"]->setEnabled(true);
scrActions["pageManageGuides"]->setEnabled(true);
scrActions["pageManageMargins"]->setEnabled(true);
scrActions["fileSaveAs"]->setEnabled(true);
scrActions["fileCollect"]->setEnabled(true);
scrActions["toolsPDFPushButton"]->setEnabled(true);
scrActions["toolsPDFTextField"]->setEnabled(true);
scrActions["toolsPDFCheckBox"]->setEnabled(true);
scrActions["toolsPDFComboBox"]->setEnabled(true);
scrActions["toolsPDFListBox"]->setEnabled(true);
scrActions["toolsPDFAnnotText"]->setEnabled(true);
#ifdef HAVE_OSG
scrActions["toolsPDFAnnot3D"]->setEnabled(true);
#endif
pagePalette->enablePalette(true);
}
scrMenuMgr->setMenuEnabled("ItemLayer", doc->layerCount() > 1);
}
void ScribusMainWindow::HaveNewDoc()
{
scrActions["filePrint"]->setEnabled(true);
scrActions["fileSave"]->setEnabled(true);
scrActions["fileClose"]->setEnabled(true);
scrActions["fileDocSetup"]->setEnabled(true);
scrActions["fileRevert"]->setEnabled(false);
scrActions["fileCollect"]->setEnabled(true);
scrActions["fileSaveAs"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("FileImport", true);
scrMenuMgr->setMenuEnabled("FileExport", true);
scrActions["fileExportAsEPS"]->setEnabled(true);
scrActions["fileExportAsPDF"]->setEnabled(true);
scrActions["pageImport"]->setEnabled(true);
//scrActions["toolsPreflightVerifier"]->setEnabled(true);
if ( ScCore->haveGS() || ScCore->isWinGUI() )
scrActions["PrintPreview"]->setEnabled(true);
if (scrActions["SaveAsDocumentTemplate"])
scrActions["SaveAsDocumentTemplate"]->setEnabled(true);
scrActions["editCut"]->setEnabled(false);
scrActions["editCopy"]->setEnabled(false);
scrActions["editPaste"]->setEnabled((ScMimeData::clipboardHasScribusData()) || (scrapbookPalette->tempBView->objectMap.count() > 0));
scrMenuMgr->setMenuEnabled("EditPasteRecent", scrapbookPalette->tempBView->objectMap.count() > 0);
scrMenuMgr->setMenuEnabled("EditContents", false);
scrActions["editCopyContents"]->setEnabled(false);
scrActions["editPasteContents"]->setEnabled(false);
scrActions["editPasteContentsAbs"]->setEnabled(false);
scrActions["editSelectAll"]->setEnabled(true);
scrActions["editSelectAllOnLayer"]->setEnabled(true);
scrActions["editDeselectAll"]->setEnabled(false);
scrActions["editReplaceColors"]->setEnabled(true);
scrActions["editPatterns"]->setEnabled(true);
// scrActions["editGradients"]->setEnabled(true);
scrActions["editStyles"]->setEnabled(true);
scrActions["editMasterPages"]->setEnabled(true);
scrActions["editJavascripts"]->setEnabled(true);
// scrMenuMgr->setMenuEnabled("View", true);
scrActions["viewFitInWindow"]->setEnabled(true);
scrActions["viewFitWidth"]->setEnabled(true);
scrActions["viewFit50"]->setEnabled(true);
scrActions["viewFit75"]->setEnabled(true);
scrActions["viewFit100"]->setEnabled(true);
scrActions["viewFit200"]->setEnabled(true);
scrActions["viewFit400"]->setEnabled(true);
scrActions["viewSnapToGrid"]->setChecked(doc->useRaster);
scrActions["viewSnapToGuides"]->setChecked(doc->SnapGuides);
scrActions["viewShowRulers"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("Insert", true);
scrActions["insertFrame"]->setEnabled(true);
//scrMenuMgr->setMenuEnabled("Windows", true);
// scrMenuMgr->setMenuEnabled("Page", true);
scrMenuMgr->setMenuEnabled("Extras", true);
scrActions["toolsSelect"]->setEnabled(true);
scrActions["toolsZoom"]->setEnabled(true);
scrActions["toolsInsertTextFrame"]->setEnabled(true);
scrActions["toolsInsertImageFrame"]->setEnabled(true);
scrActions["toolsInsertTableFrame"]->setEnabled(true);
scrActions["toolsInsertShape"]->setEnabled(true);
scrActions["toolsInsertLine"]->setEnabled(true);
scrActions["toolsInsertBezier"]->setEnabled(true);
scrActions["toolsInsertFreehandLine"]->setEnabled(true);
scrActions["toolsInsertPolygon"]->setEnabled(true);
scrActions["toolsInsertRenderFrame"]->setEnabled(true);
scrActions["toolsMeasurements"]->setEnabled(true);
scrActions["toolsEyeDropper"]->setEnabled(true);
scrActions["toolsPDFPushButton"]->setEnabled(true);
scrActions["toolsPDFTextField"]->setEnabled(true);
scrActions["toolsPDFCheckBox"]->setEnabled(true);
scrActions["toolsPDFComboBox"]->setEnabled(true);
scrActions["toolsPDFListBox"]->setEnabled(true);
scrActions["toolsPDFAnnotText"]->setEnabled(true);
scrActions["toolsPDFAnnotLink"]->setEnabled(true);
#ifdef HAVE_OSG
scrActions["toolsPDFAnnot3D"]->setEnabled(true);
#endif
bool setter = doc->Pages->count() > 1 ? true : false;
scrActions["pageDelete"]->setEnabled(setter);
scrActions["pageMove"]->setEnabled(setter);
scrActions["pageInsert"]->setEnabled(true);
scrActions["pageImport"]->setEnabled(true);
scrActions["pageCopy"]->setEnabled(true);
scrActions["pageApplyMasterPage"]->setEnabled(true);
scrActions["pageCopyToMasterPage"]->setEnabled(true);
scrActions["pageManageGuides"]->setEnabled(true);
scrActions["pageManageMargins"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("ItemLayer", doc->layerCount() > 1);
//Update palettes
updateActiveWindowCaption(doc->DocName);
// scrActions["shade100"]->setChecked(true);
propertiesPalette->setDoc(doc);
propertiesPalette->Cpal->ChooseGrad(0);
// propertiesPalette->updateColorList();
pagePalette->setView(view);
layerPalette->setDoc(doc);
guidePalette->setDoc(doc);
charPalette->setDoc(doc);
outlinePalette->setDoc(doc);
if (outlinePalette->isVisible())
outlinePalette->BuildTree();
rebuildLayersList();
view->updateLayerMenu();
view->setLayerMenuText(doc->activeLayerName());
slotChangeUnit(doc->unitIndex());
windowsMenuAboutToShow();
connect(view, SIGNAL(changeUN(int)), this, SLOT(slotChangeUnit(int)));
connect(view, SIGNAL(changeLA(int)), layerPalette, SLOT(markActiveLayer(int)));
connect(view->horizRuler, SIGNAL(MarkerMoved(double, double)), this, SLOT(setStatusBarMousePosition(double, double)));
connect(view->horizRuler, SIGNAL(DocChanged(bool)), this, SLOT(slotDocCh(bool)));
connect(view, SIGNAL(ClipPo(double, double)), nodePalette, SLOT(SetXY(double, double)));
connect(view, SIGNAL(PolyOpen()), nodePalette, SLOT(IsOpen()));
connect(view, SIGNAL(PStatus(int, uint)), nodePalette, SLOT(PolyStatus(int, uint)));
connect(view, SIGNAL(ItemPos(double, double)), propertiesPalette, SLOT(setXY(double, double)));
connect(view, SIGNAL(ItemGeom(double, double)), propertiesPalette, SLOT(setBH(double, double)));
connect(view, SIGNAL(ChBMText(PageItem *)), this, SLOT(BookMarkTxT(PageItem *)));
connect(view, SIGNAL(HaveSel(int)), this, SLOT(HaveNewSel(int)));
connect(view, SIGNAL(SetAngle(double)), propertiesPalette, SLOT(setR(double)));
connect(view, SIGNAL(SetSizeValue(double)), propertiesPalette, SLOT(setLineWidth(double)));
connect(view, SIGNAL(SetLocalValues(double, double, double, double)), propertiesPalette, SLOT(setScaleAndOffset(double, double, double, double)));
connect(view, SIGNAL(SetLineArt(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)), propertiesPalette, SLOT( setLIvalue(Qt::PenStyle, Qt::PenCapStyle, Qt::PenJoinStyle)));
// connect(view, SIGNAL(ItemFarben(QString, QString, int, int)), this, SLOT(setCSMenu(QString, QString, int, int)));
// connect(view, SIGNAL(ItemFarben(QString, QString, int, int)), propertiesPalette->Cpal, SLOT(setActFarben(QString, QString, int, int)));
// connect(view, SIGNAL(ItemGradient(int)), propertiesPalette->Cpal, SLOT(setActGradient(int)));
// connect(view, SIGNAL(ItemTrans(double, double)), propertiesPalette->Cpal, SLOT(setActTrans(double, double)));
// connect(view, SIGNAL(ItemBlend(int, int)), propertiesPalette->Cpal, SLOT(setActBlend(int, int)));
connect(view, SIGNAL(ItemTextAttr(double)), propertiesPalette, SLOT(setLsp(double)));
connect(view, SIGNAL(ItemTextUSval(double)), propertiesPalette, SLOT(setExtra(double)));
// connect(view, SIGNAL(ItemTextCols(int, double)), propertiesPalette, SLOT(setCols(int, double)));
connect(view, SIGNAL(SetDistValues(double, double, double, double)), propertiesPalette, SLOT(setTextToFrameDistances(double, double, double, double)));
connect(view, SIGNAL(ItemTextAbs(int)), propertiesPalette, SLOT(setAli(int)));
connect(view, SIGNAL(ItemTextFont(const QString&)), propertiesPalette, SLOT(setFontFace(const QString&)));
connect(view, SIGNAL(ItemTextSize(double)), propertiesPalette, SLOT(setSize(double)));
//connect(view, SIGNAL(ItemRadius(double)), propertiesPalette, SLOT(setRR(double)));
// connect(view, SIGNAL(Amode(int)), this, SLOT(setAppMode(int)));
connect(view, SIGNAL(PaintingDone()), this, SLOT(slotSelect()));
connect(view, SIGNAL(DocChanged()), this, SLOT(slotDocCh()));
//connect(view, SIGNAL(HavePoint(bool, bool)), nodePalette, SLOT(HaveNode(bool, bool)));
connect(view, SIGNAL(MousePos(double, double)), this, SLOT(setStatusBarMousePosition(double, double)));
//connect(view, SIGNAL(ItemRadius(double)), propertiesPalette, SLOT(setRR(double)));
connect(view, SIGNAL(ItemTextStil(int)), propertiesPalette, SLOT(setStil(int)));
connect(view, SIGNAL(ItemTextSca(double)), propertiesPalette, SLOT(setTScale(double)));
connect(view, SIGNAL(ItemTextScaV(double)), propertiesPalette, SLOT(setTScaleV(double)));
connect(view, SIGNAL(ItemTextBase(double)), propertiesPalette, SLOT(setTBase(double)));
connect(view, SIGNAL(ItemTextShadow(double, double )), propertiesPalette, SLOT(setShadowOffs(double, double )));
connect(view, SIGNAL(ItemTextUnderline(double, double)), propertiesPalette, SLOT(setUnderline(double, double)));
connect(view, SIGNAL(ItemTextStrike(double, double)), propertiesPalette, SLOT(setStrike(double, double)));
connect(view, SIGNAL(ItemTextOutline(double)), propertiesPalette, SLOT(setOutlineW(double)));
connect(view, SIGNAL(ItemTextStil(int)), this, SLOT(setStilvalue(int)));
connect(view, SIGNAL(ItemTextAbs(int)), this, SLOT(setAbsValue(int)));
connect(view, SIGNAL(ItemTextFarben(QString, QString, double, double)), propertiesPalette, SLOT(setActFarben(QString, QString, double, double)));
connect(view, SIGNAL(HasTextSel()), this, SLOT(EnableTxEdit()));
connect(view, SIGNAL(HasNoTextSel()), this, SLOT(DisableTxEdit()));
connect(view, SIGNAL(CopyItem()), this, SLOT(slotEditCopy()));
connect(view, SIGNAL(CutItem()), this, SLOT(slotEditCut()));
connect(view, SIGNAL(LoadPic()), this, SLOT(slotGetContent()));
connect(view, SIGNAL(StatusPic()), this, SLOT(StatusPic()));
connect(view, SIGNAL(AppendText()), this, SLOT(slotFileAppend()));
connect(view, SIGNAL(AnnotProps()), this, SLOT(ModifyAnnot()));
//connect(view, SIGNAL(EditGuides()), this, SLOT(ManageGuides()));
connect(view, SIGNAL(LoadElem(QString, double ,double, bool, bool, ScribusDoc *, ScribusView*)), this, SLOT(slotElemRead(QString, double, double, bool, bool, ScribusDoc *, ScribusView*)));
connect(view, SIGNAL(AddBM(PageItem *)), this, SLOT(AddBookMark(PageItem *)));
connect(view, SIGNAL(DelBM(PageItem *)), this, SLOT(DelBookMark(PageItem *)));
connect(view, SIGNAL(DoGroup()), this, SLOT(GroupObj()));
// connect(view, SIGNAL(EndNodeEdit()), this, SLOT(ToggleFrameEdit()));
connect(view, SIGNAL(LevelChanged(uint )), propertiesPalette, SLOT(setLevel(uint)));
connect(view, SIGNAL(callGimp()), this, SLOT(callImageEditor()));
}
void ScribusMainWindow::HaveNewSel(int SelectedType)
{
bool isRaster = false;
PageItem *currItem = NULL;
const uint docSelectionCount=doc->m_Selection->count();
if (SelectedType != -1)
{
if (docSelectionCount != 0)
{
PageItem *lowestItem = doc->m_Selection->itemAt(0);
for (uint a=0; a < docSelectionCount; ++a)
{
currItem = doc->m_Selection->itemAt(a);
if (currItem->ItemNr < lowestItem->ItemNr)
lowestItem = currItem;
}
currItem = lowestItem;
if ((docSelectionCount == 1) && currItem && currItem->asImageFrame())
isRaster = currItem->isRaster;
// doc->m_Selection->removeItem(currItem);
// doc->m_Selection->prependItem(currItem);
// currItem = doc->m_Selection->itemAt(0);
assert(currItem);
// if (!currItem)
// SelectedType=-1;
}
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)
setStatusBarInfoText( tr("1 Object selected"));
else
setStatusBarInfoText( tr("%1 Objects selected").arg(docSelectionCount));
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 && !currItem->isTableItem);
scrActions["itemAdjustImageToFrame"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable);
scrActions["itemExtendedImageProperties"]->setEnabled(SelectedType==PageItem::ImageFrame && currItem->PictureIsAvailable && currItem->pixm.imgInfo.valid);
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 && 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
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()))
enableTextActions(&scrActions, false);
scrActions["insertSampleText"]->setEnabled(false);
view->horizRuler->ItemPosValid = 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["itemDelete"]->setEnabled(false);
scrActions["itemRaise"]->setEnabled(false);
scrActions["itemLower"]->setEnabled(false);
scrActions["itemRaiseToTop"]->setEnabled(false);
scrActions["itemLowerToBottom"]->setEnabled(false);
scrActions["itemSendToScrapbook"]->setEnabled(false);
scrActions["itemSendToPattern"]->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["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["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(), -1);
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);
// scrMenuMgr->setMenuEnabled("Item", true);
scrActions["itemDuplicate"]->setEnabled(true);
scrActions["itemMulDuplicate"]->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);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(true);
scrActions["itemAdjustImageToFrame"]->setEnabled(true);
scrActions["itemExtendedImageProperties"]->setEnabled(true);
scrActions["itemUpdateImage"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
scrActions["itemPreviewNormal"]->setEnabled(true);
scrActions["itemPreviewFull"]->setEnabled(true);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
//scrMenuMgr->setMenuEnabled("ItemShapes", !(currItem->isTableItem && currItem->isSingleSel));
// scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(!currItem->isTableItem && doc->appMode != modeEdit);
scrActions["itemConvertToTextFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["toolsUnlinkTextFrame"]->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["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
propertiesPalette->Fonts->RebuildList(doc, currItem->isAnnotation());
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["itemDelete"]->setEnabled(true);
scrActions["itemRaise"]->setEnabled(true);
scrActions["itemLower"]->setEnabled(true);
scrActions["itemRaiseToTop"]->setEnabled(true);
scrActions["itemLowerToBottom"]->setEnabled(true);
scrActions["itemSendToScrapbook"]->setEnabled(true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(true);
scrActions["itemAdjustImageToFrame"]->setEnabled(true);
scrActions["itemExtendedImageProperties"]->setEnabled(true);
scrActions["itemUpdateImage"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
scrActions["itemPreviewNormal"]->setEnabled(true);
scrActions["itemPreviewFull"]->setEnabled(true);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
//scrMenuMgr->setMenuEnabled("ItemShapes", !(currItem->isTableItem && currItem->isSingleSel));
// scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToOutlines"]->setEnabled(!currItem->isTableItem && doc->appMode != modeEdit);
scrActions["itemConvertToPolygon"]->setEnabled(!currItem->isTableItem && doc->appMode != modeEdit);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["toolsRotate"]->setEnabled(true);
scrActions["toolsCopyProperties"]->setEnabled(true);
scrActions["toolsEditWithStoryEditor"]->setEnabled(true);
scrActions["insertSampleText"]->setEnabled(true);
if ((currItem->nextInChain() != 0) || (currItem->prevInChain() != 0))
{
scrActions["itemConvertToBezierCurve"]->setEnabled(false);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
// scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->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);
}
if (currItem->nextInChain() == 0)
scrActions["toolsLinkTextFrame"]->setEnabled(true);
// if (doc->masterPageMode())
// scrActions["toolsLinkTextFrame"]->setEnabled(false);
if (doc->appMode == modeEdit)
{
setTBvals(currItem);
scrActions["editSelectAll"]->setEnabled(true);
scrActions["editSelectAllOnLayer"]->setEnabled(false);
charPalette->setEnabled(true, currItem);
if (currItem->asTextFrame())
enableTextActions(&scrActions, true, currItem->currentStyle().charStyle().font().scName());
view->horizRuler->setItem(currItem);
if ((currItem->lineColor() != CommonStrings::None) || (!currItem->strokePattern().isEmpty()))
view->horizRuler->lineCorr = currItem->lineWidth() / 2.0;
else
view->horizRuler->lineCorr = 0;
view->horizRuler->ColGap = currItem->ColGap;
view->horizRuler->Cols = currItem->Cols;
view->horizRuler->Extra = currItem->textToFrameDistLeft();
view->horizRuler->RExtra = currItem->textToFrameDistRight();
view->horizRuler->First = currItem->currentStyle().firstIndent();
view->horizRuler->Indent = currItem->currentStyle().leftMargin();
double columnWidth = (currItem->width() - (currItem->columnGap() * (currItem->columns() - 1))
- currItem->textToFrameDistLeft() - currItem->textToFrameDistLeft()
- 2*view->horizRuler->lineCorr) / currItem->columns();
view->horizRuler->RMargin = columnWidth - currItem->currentStyle().rightMargin();
if (currItem->imageFlippedH() || (currItem->reversed()))
view->horizRuler->Revers = true;
else
view->horizRuler->Revers = false;
view->horizRuler->ItemPosValid = true;
view->horizRuler->TabValues = currItem->currentStyle().tabValues();
view->horizRuler->update();
}
else
{
doc->currentStyle = currItem->itemText.defaultStyle();
emit TextStyle(doc->currentStyle);
// to go: (av)
emit TextStrike(doc->currentStyle.charStyle().strikethruOffset(), doc->currentStyle.charStyle().strikethruWidth());
emit TextUnderline(doc->currentStyle.charStyle().underlineOffset(), doc->currentStyle.charStyle().underlineWidth());
emit TextShadow(doc->currentStyle.charStyle().shadowXOffset(), doc->currentStyle.charStyle().shadowYOffset());
emit TextFarben(doc->currentStyle.charStyle().strokeColor(), doc->currentStyle.charStyle().fillColor(), doc->currentStyle.charStyle().strokeShade(), doc->currentStyle.charStyle().fillShade());
emit TextScale(doc->currentStyle.charStyle().scaleH());
emit TextScaleV(doc->currentStyle.charStyle().scaleV());
emit TextBase(doc->currentStyle.charStyle().baselineOffset());
emit TextOutline(doc->currentStyle.charStyle().outlineWidth());
// emit TextStil(doc->currentStyle.charStyle().effects());
setStilvalue(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::PathText: //Path Text
propertiesPalette->Fonts->RebuildList(doc, currItem->isAnnotation());
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["itemDelete"]->setEnabled(true);
scrActions["itemRaise"]->setEnabled(true);
scrActions["itemLower"]->setEnabled(true);
scrActions["itemRaiseToTop"]->setEnabled(true);
scrActions["itemLowerToBottom"]->setEnabled(true);
scrActions["itemSendToScrapbook"]->setEnabled(true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(true);
scrActions["itemAdjustImageToFrame"]->setEnabled(true);
scrActions["itemExtendedImageProperties"]->setEnabled(true);
scrActions["itemUpdateImage"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
scrActions["itemPreviewNormal"]->setEnabled(true);
scrActions["itemPreviewFull"]->setEnabled(true);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
//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["toolsRotate"]->setEnabled(true);
scrActions["toolsCopyProperties"]->setEnabled(true);
scrActions["toolsEditContents"]->setEnabled(false);
scrActions["toolsEditWithStoryEditor"]->setEnabled(true);
scrActions["toolsLinkTextFrame"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
if (doc->appMode == modeEdit)
setTBvals(currItem);
else
{
doc->currentStyle = currItem->itemText.defaultStyle();
emit TextStyle(doc->currentStyle);
// to go: (av)
emit TextStrike(doc->currentStyle.charStyle().strikethruOffset(), doc->currentStyle.charStyle().strikethruWidth());
emit TextUnderline(doc->currentStyle.charStyle().underlineOffset(), doc->currentStyle.charStyle().underlineWidth());
emit TextShadow(doc->currentStyle.charStyle().shadowXOffset(), doc->currentStyle.charStyle().shadowYOffset());
emit TextFarben(doc->currentStyle.charStyle().strokeColor(), doc->currentStyle.charStyle().fillColor(), doc->currentStyle.charStyle().strokeShade(), doc->currentStyle.charStyle().fillShade());
emit TextScale(doc->currentStyle.charStyle().scaleH());
emit TextScaleV(doc->currentStyle.charStyle().scaleV());
emit TextBase(doc->currentStyle.charStyle().baselineOffset());
emit TextOutline(doc->currentStyle.charStyle().outlineWidth());
// emit TextStil(doc->currentStyle.charStyle().effects());
setStilvalue(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["itemDelete"]->setEnabled(true);
scrActions["itemRaise"]->setEnabled(true);
scrActions["itemLower"]->setEnabled(true);
scrActions["itemRaiseToTop"]->setEnabled(true);
scrActions["itemLowerToBottom"]->setEnabled(true);
scrActions["itemSendToScrapbook"]->setEnabled(true);
scrActions["itemSendToPattern"]->setEnabled(true);
scrActions["itemAdjustFrameToImage"]->setEnabled(true);
scrActions["itemAdjustImageToFrame"]->setEnabled(true);
scrActions["itemExtendedImageProperties"]->setEnabled(true);
scrActions["itemUpdateImage"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
scrActions["itemPreviewNormal"]->setEnabled(true);
scrActions["itemPreviewFull"]->setEnabled(true);
scrActions["itemAttributes"]->setEnabled(true);
scrActions["itemPreviewLow"]->setEnabled(true);
if (SelectedType == 6) //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);
}
else if (SelectedType == 7) //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);
}
else if (SelectedType == 5) // Line
{
scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(true);
scrActions["itemConvertToImageFrame"]->setEnabled(false);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(false);
}
scrActions["toolsEditContents"]->setEnabled(false);
scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->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->RotationGroup->setCheckedId(doc->RotMode());
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["editSearchReplace"]->setEnabled(false);
bool hPoly = false;
bool isGroup = true;
int firstElem = -1;
if (currItem->Groups.count() != 0)
firstElem = currItem->Groups.top();
for (uint bx=0; bx < docSelectionCount; ++bx)
{
PageItem* bxi=doc->m_Selection->itemAt(bx);
if ((bxi->asPolygon()) || (bxi->asPolyLine()))
hPoly = true;
if (bxi->Groups.count() != 0)
{
if (bxi->Groups.top() != firstElem)
isGroup = false;
}
else
isGroup = false;
}
// 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(!isGroup && objectsOnSameLayer);
scrActions["itemCombinePolygons"]->setEnabled(hPoly);
if (docSelectionCount == 2)
{
//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->Groups.count() == 0) && (bx->Groups.count() == 0))
scrActions["itemAttachTextToPath"]->setEnabled(true);
}
}
}
else
{
scrActions["itemGroup"]->setEnabled(false);
scrActions["itemAttachTextToPath"]->setEnabled(false);
scrActions["itemCombinePolygons"]->setEnabled(false);
}
if (docSelectionCount != 0)
{
actionManager->setPDFActions(view);
updateItemLayerList();
//propertiesPalette->textFlowsAroundFrame->setChecked(currItem->textFlowsAroundFrame());
propertiesPalette->setTextFlowMode(currItem->textFlowMode());
scrActions["itemLock"]->setEnabled(true);
scrActions["itemLockSize"]->setEnabled(true);
scrActions["itemPrintingEnabled"]->setEnabled(true);
if (currItem->Groups.count() != 0)
scrActions["itemUngroup"]->setEnabled(true);
else
{
scrActions["itemUngroup"]->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["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));
scrActions["itemSendToPattern"]->setEnabled(!(currItem->isTableItem && currItem->isSingleSel));
scrActions["editCut"]->setEnabled(false);
scrActions["editClearContents"]->setEnabled(false);
scrActions["toolsRotate"]->setEnabled(false);
}
else
{
bool setter=!(currItem->isSingleSel && (currItem->isTableItem || currItem->isGroupControl));
scrMenuMgr->setMenuEnabled("ItemLevel", setter);
scrActions["itemDuplicate"]->setEnabled(setter);
scrActions["itemMulDuplicate"]->setEnabled(setter);
scrActions["itemDelete"]->setEnabled(!currItem->isSingleSel);
scrActions["itemLowerToBottom"]->setEnabled(setter);
scrActions["itemRaiseToTop"]->setEnabled(setter);
scrActions["itemRaise"]->setEnabled(setter);
scrActions["itemLower"]->setEnabled(setter);
scrActions["itemSendToScrapbook"]->setEnabled(setter);
scrActions["itemSendToPattern"]->setEnabled(setter);
}
scrActions["itemLock"]->setChecked(currItem->locked());
scrActions["itemLockSize"]->setChecked(currItem->sizeLocked());
scrActions["itemPrintingEnabled"]->setChecked(currItem->printEnabled());
}
//propertiesPalette->NewSel(SelectedType);
if (SelectedType != -1)
{
//propertiesPalette->SetCurItem(currItem);
outlinePalette->slotShowSelect(currItem->OwnPage, currItem->ItemNr);
actionManager->connectNewSelectionActions(view, doc);
// propertiesPalette->NewSel(SelectedType);
}
else
propertiesPalette->NewSel(SelectedType);
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);
plugin = pluginManager.getPlugin(pName, true);
Q_ASSERT(plugin); // all the returned names should represent loaded plugins
if (plugin->inherits("ScActionPlugin"))
{
ixplug = dynamic_cast<ScActionPlugin*>(plugin);
Q_ASSERT(ixplug);
ScActionPlugin::ActionInfo ai(ixplug->actionInfo());
pluginAction = ScCore->primaryMainWindow()->scrActions[ai.name];
if (pluginAction != 0)
pluginAction->setEnabled(ixplug->handleSelection(doc, SelectedType));
}
}
}
void ScribusMainWindow::slotDocCh(bool /*reb*/)
{
if (!doc->isLoading() && docCheckerPalette->isVisible())
{
scanDocument();
docCheckerPalette->buildErrorList(doc);
}
if (!doc->isModified())
doc->setModified(true);
updateActiveWindowCaption(doc->DocName + "*");
// scrActions["fileSave"]->setEnabled(true);
// scrActions["fileSaveAs"]->setEnabled(true);
scrActions["fileCollect"]->setEnabled(true);
if (!doc->masterPageMode())
{
scrActions["fileClose"]->setEnabled(true);
if (doc->hasName)
scrActions["fileRevert"]->setEnabled(true);
bool multiPages = doc->Pages->count() > 1;
scrActions["pageDelete"]->setEnabled(multiPages);
scrActions["pageMove"]->setEnabled(multiPages);
}
if (outlinePalette->isVisible())
outlinePalette->BuildTree();
// Give plugins a chance to react on changes in 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->changedDoc(doc);
}
}
void ScribusMainWindow::updateRecent(QString fn)
{
if (RecentDocs.indexOf(fn) == -1)
{
RecentDocs.prepend(fn);
ScCore->fileWatcher->addFile(fn);
}
else
{
RecentDocs.removeAll(fn);
RecentDocs.prepend(fn);
}
rebuildRecentFileMenu();
}
void ScribusMainWindow::removeRecent(QString fn)
{
if (RecentDocs.indexOf(fn) != -1)
{
RecentDocs.removeAll(fn);
ScCore->fileWatcher->removeFile(fn);
}
rebuildRecentFileMenu();
}
void ScribusMainWindow::loadRecent(QString fn)
{
QFileInfo fd(fn);
if (!fd.exists())
{
removeRecent(fn);
return;
}
loadDoc(fn);
}
void ScribusMainWindow::rebuildRecentFileMenu()
{
for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrRecentFileActions.begin(); it!=scrRecentFileActions.end(); ++it )
scrMenuMgr->removeMenuItem((*it), "FileOpenRecent");
scrRecentFileActions.clear();
uint max = qMin(prefsManager->appPrefs.uiPrefs.recentDocCount, RecentDocs.count());
QString strippedName, localName;
for (uint m = 0; m < max; ++m)
{
strippedName = localName = QDir::toNativeSeparators(RecentDocs[m]);
strippedName.remove(QDir::separator());
scrRecentFileActions.insert(strippedName, new ScrAction(ScrAction::RecentFile, QPixmap(), QPixmap(), QString("&%1 %2").arg(m+1).arg(localName), QKeySequence(), this, 0,0.0,RecentDocs[m]));
connect( scrRecentFileActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(loadRecent(QString)) );
scrMenuMgr->addMenuItem(scrRecentFileActions[strippedName], "FileOpenRecent", true);
}
}
void ScribusMainWindow::rebuildRecentPasteMenu()
{
for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrRecentPasteActions.begin(); it!=scrRecentPasteActions.end(); ++it )
scrMenuMgr->removeMenuItem((*it), "EditPasteRecent");
scrRecentPasteActions.clear();
int max = qMin(prefsManager->appPrefs.scrapbookPrefs.numScrapbookCopies, scrapbookPalette->tempBView->objectMap.count());
if (max > 0)
{
QMap<QString,BibView::Elem>::Iterator it;
it = scrapbookPalette->tempBView->objectMap.end();
it--;
QString strippedName;
for (int m = 0; m < max; ++m)
{
strippedName = it.key();
QPixmap pm = it.value().Preview;
scrRecentPasteActions.insert(strippedName, new ScrAction(ScrAction::RecentPaste, pm, QPixmap(), QString("&%1 %2").arg(m+1).arg(strippedName), QKeySequence(), this, 0,0.0,it.key()));
connect( scrRecentPasteActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(pasteRecent(QString)) );
scrMenuMgr->addMenuItem(scrRecentPasteActions[strippedName], "EditPasteRecent", true);
it--;
}
}
}
void ScribusMainWindow::pasteFromScrapbook(QString fn)
{
doPasteRecent(scrapbookPalette->activeBView->objectMap[fn].Data);
}
void ScribusMainWindow::pasteRecent(QString fn)
{
doPasteRecent(scrapbookPalette->tempBView->objectMap[fn].Data);
}
void ScribusMainWindow::doPasteRecent(QString data)
{
if (HaveDoc)
{
UndoTransaction pasteAction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
QFileInfo fi(data);
if (fi.suffix().toLower() == "sml")
{
QString f = "";
loadText(data, &f);
StencilReader *pre = new StencilReader();
data = pre->createObjects(f);
delete pre;
}
else if (fi.suffix().toLower() == "shape")
{
QString f = "";
loadText(data, &f);
StencilReader *pre = new StencilReader();
data = pre->createShape(f);
delete pre;
}
view->Deselect(true);
uint ac = doc->Items->count();
bool