Rev 4214 |
Rev 4260 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/***************************************************************************
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 <qaccel.h>
#include <qapplication.h>
#include <qeventloop.h>
#include <qcolordialog.h>
#include <qcolor.h>
#include <qiconset.h>
#include <qtextstream.h>
#include <qstylefactory.h>
#include <qregexp.h>
#include <qtextcodec.h>
#include <qcursor.h>
#include <qvbox.h>
#include <qpixmap.h>
#include <qkeysequence.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include "scconfig.h"
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <iostream>
#include <signal.h>
#include <string>
#include "sccombobox.h"
#include "scribusapp.h"
#include "scribus.h"
#include "scribus.moc"
#include "newfile.h"
#include "page.h"
#include "query.h"
#include "mdup.h"
#include "docinfo.h"
#include "reformdoc.h"
#include "serializer.h"
#include "aligndistribute.h"
#include "fmitem.h"
#include "fontprefs.h"
#include "prefs.h"
#include "prefscontext.h"
#include "prefstable.h"
#include "pdfopts.h"
#include "pdflib.h"
#include "inspage.h"
#include "delpages.h"
#include "movepage.h"
#include "helpbrowser.h"
#include "scribusXml.h"
#include "about.h"
#include "aboutplugins.h"
#include "pslib.h"
#include "druck.h"
#include "editformats.h"
#include "muster.h"
#include "newtemp.h"
#include "applytemplatedialog.h"
#include "picstatus.h"
#include "customfdialog.h"
#include "cmsprefs.h"
#include "annot.h"
#include "annota.h"
#include "javadocs.h"
#include "colorm.h"
#include "mpalette.h"
#include "cpalette.h"
#include "bookpalette.h"
#include "seiten.h"
#include "layers.h"
#include "frameedit.h"
#include "splash.h"
#include "measurements.h"
#include "gtgettext.h"
#include "fileloader.h"
#include "arrowchooser.h"
#include "tabtypography.h"
#include "tabguides.h"
#include "tabtools.h"
#include "undogui.h"
#include "filewatcher.h"
#include "charselect.h"
#include "checkDocument.h"
#include "tabcheckdoc.h"
#include "tabpdfoptions.h"
#include "docitemattrprefs.h"
#include "pageitemattributes.h"
#include "pageitem_textframe.h"
#include "tocindexprefs.h"
#include "tocgenerator.h"
#include "collect4output.h"
#include "fpoint.h"
#include "fpointarray.h"
#include "hysettings.h"
#include "guidemanager.h"
#include "keymanager.h"
#include "mergedoc.h"
#include "lineformats.h"
#include "story.h"
#include "autoform.h"
#include "tabmanager.h"
#include "search.h"
#include "fontcombo.h"
#include "prefsfile.h"
#include "undomanager.h"
#include "polygonwidget.h"
#include "werktoolb.h"
#include "units.h"
#include "hruler.h"
#include "vruler.h"
#include "pageselector.h"
#include "scraction.h"
#include "menumanager.h"
#include "undostate.h"
#include "tree.h"
#include "scrap.h"
#include "pluginmanager.h"
#include "scpaths.h"
#include "pdfoptions.h"
#include "actionmanager.h"
#include "documentinformation.h"
#include "effectsdialog.h"
#include "documentchecker.h"
#include "util.h"
#include "pagesize.h"
#include "loremipsum.h"
#include "marginWidget.h"
#include "margindialog.h"
#include "prefsmanager.h"
#include "pagelayout.h"
#include "commonstrings.h"
#include "preview.h"
#include "scribuswin.h"
#include "hyphenator.h"
#include "scmessagebox.h"
#include "imageinfodialog.h"
#include "selection.h"
using namespace std;
#ifdef HAVE_CMS
cmsHPROFILE CMSoutputProf;
cmsHPROFILE CMSprinterProf;
cmsHTRANSFORM stdTransG;
cmsHTRANSFORM stdProofG;
cmsHTRANSFORM stdTransImgG;
cmsHTRANSFORM stdProofImgG;
cmsHTRANSFORM stdTransCMYKG;
cmsHTRANSFORM stdProofCMYKG;
cmsHTRANSFORM stdTransRGBG;
cmsHTRANSFORM stdProofGCG;
cmsHTRANSFORM stdProofCMYKGCG;
bool BlackPoint;
bool SoftProofing;
bool Gamut;
bool SCRIBUS_API CMSuse;
int IntentMonitor;
int IntentPrinter;
#endif
bool CMSavail;
bool previewDinUse;
bool printDinUse;
QString DocDir;
extern ScribusQApp* ScQApp;
extern bool emergencyActivated;
ScribusMainWindow::ScribusMainWindow()
{
scribusInitialized=false;
actionManager=NULL;
scrMenuMgr=NULL;
undoManager=NULL;
prefsManager=NULL;
#ifdef Q_WS_MAC
noIcon = loadIcon("noicon.xpm");
#endif
} // ScribusMainWindow::ScribusMainWindow()
/*
* retval 0 - ok, 1 - no fonts, ...
*/
int ScribusMainWindow::initScribus(bool showSplash, bool showFontInfo, const QString newGuiLanguage, const QString prefsUserFile)
{
CommonStrings::languageChange();
noneString = tr("None");
int retVal=0;
ExternalApp = 0;
previewDinUse = false;
printDinUse = false;
guiLanguage = newGuiLanguage;
initSplash(showSplash);
setUsesBigPixmaps(true);
CurrStED = NULL;
setCaption( tr("Scribus " VERSION));
setKeyCompression(false);
setIcon(loadIcon("AppIcon.png"));
scrActionGroups.clear();
scrActionGroups.setAutoDelete(true);
scrActions.clear();
scrRecentFileActions.clear();
scrWindowsActions.clear();
scrLayersActions.clear();
scrMenuMgr = new MenuManager(this->menuBar());
prefsManager = PrefsManager::instance();
prefsManager->setup();
PrefsPfad = prefsManager->preferencesLocation();
undoManager = UndoManager::instance();
objectSpecificUndo = false;
pluginManager = new PluginManager();
tocGenerator = new TOCGenerator();
actionManager = new ActionManager(this, "actionManager");
initDefaultValues();
initMenuBar();
initStatusBar();
initToolBars();
qApp->processEvents();
BuFromApp = false;
#ifdef QT_MAC
bool haveFonts=initFonts(true);
#else
bool haveFonts=initFonts(showFontInfo);
#endif
if (!haveFonts)
retVal=1;
else
{
buildFontMenu();
prefsManager->initDefaults();
prefsManager->initDefaultGUIFont(qApp->font());
prefsManager->initArrowStyles();
resize(610, 600);
QVBox* vb = new QVBox( this );
vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
wsp = new QWorkspace( vb );
setCentralWidget( vb );
connect(wsp, SIGNAL(windowActivated(QWidget *)), this, SLOT(newActWin(QWidget *)));
//Connect windows cascade and tile actions to the workspace after its created. Only depends on wsp created.
connect( scrActions["windowsCascade"], SIGNAL(activated()) , wsp, SLOT(cascade()) );
connect( scrActions["windowsTile"], SIGNAL(activated()) , wsp, SLOT(tile()) );
initPalettes();
fileWatcher = new FileWatcher(this);
setSplashStatus( tr("Initializing Plugins") );
pluginManager->initPlugs();
setSplashStatus( tr("Initializing Keyboard Shortcuts") );
initKeyboardShortcuts();
setSplashStatus( tr("Reading Preferences") );
if (prefsUserFile.isNull())
prefsManager->ReadPrefs();
else
prefsManager->ReadPrefs(prefsUserFile);
setSplashStatus( tr("Initializing Story Editor") );
storyEditor = new StoryEditor(this);
HaveGS = testGSAvailability();
HavePngAlpha = testGSDeviceAvailability("pngalpha");
HaveTiffSep = testGSDeviceAvailability("tiffsep");
DocDir = prefsManager->documentDir();
setSplashStatus( tr("Reading ICC Profiles") );
CMSavail = false;
GetCMSProfiles();
initCMS();
setSplashStatus( tr("Initializing Hyphenator") );
QString preLang = prefsManager->appPrefs.Language;
initHyphenator();
if (Sprachen.contains(preLang))
prefsManager->appPrefs.Language = preLang;
setSplashStatus( tr("Reading Scrapbook") );
initScrapbook();
setSplashStatus( tr("Setting up Shortcuts") );
SetShortCut();
scrActions["helpTooltips"]->setOn(prefsManager->appPrefs.showToolTips);
ToggleTips();
emit prefsChanged();
connect(fileWatcher, SIGNAL(fileDeleted(QString )), this, SLOT(removeRecent(QString)));
connect(this, SIGNAL(TextIFont(QString)), this, SLOT(AdjustFontMenu(QString)));
connect(this, SIGNAL(TextIFont(QString)), propertiesPalette, SLOT(setFontFace(QString)));
connect(this, SIGNAL(TextISize(int)), this, SLOT(setFSizeMenu(int)));
connect(this, SIGNAL(TextISize(int)), propertiesPalette, SLOT(setSize(int)));
connect(this, SIGNAL(TextUSval(int)), propertiesPalette, SLOT(setExtra(int)));
connect(this, SIGNAL(TextStil(int)), propertiesPalette, SLOT(setStil(int)));
connect(this, SIGNAL(TextScale(int)), propertiesPalette, SLOT(setTScale(int)));
connect(this, SIGNAL(TextScaleV(int)), propertiesPalette, SLOT(setTScaleV(int)));
connect(this, SIGNAL(TextBase(int)), propertiesPalette, SLOT(setTBase(int)));
connect(this, SIGNAL(TextShadow(int, int )), propertiesPalette, SLOT(setShadowOffs(int, int )));
connect(this, SIGNAL(TextOutline(int)), propertiesPalette, SLOT(setOutlineW(int)));
connect(this, SIGNAL(TextUnderline(int, int)), propertiesPalette, SLOT(setUnderline(int, int)));
connect(this, SIGNAL(TextStrike(int, int)), propertiesPalette, SLOT(setStrike(int, int)));
connect(this, SIGNAL(TextFarben(QString, QString, int, int)), propertiesPalette, SLOT(setActFarben(QString, QString, int, int)));
}
closeSplash();
scribusInitialized=true;
//pluginManager->languageChange();
return retVal;
}
ScribusMainWindow::~ScribusMainWindow()
{
}
void ScribusMainWindow::initSplash(bool showSplash)
{
if (showSplash)
{
splashScreen = new SplashScreen();
if (splashScreen != NULL && splashScreen->isShown())
setSplashStatus(QObject::tr("Initializing..."));
}
else
splashScreen = NULL;
}
void ScribusMainWindow::setSplashStatus(const QString& newText)
{
if (splashScreen != NULL)
splashScreen->setStatus( newText );
qApp->processEvents();
}
void ScribusMainWindow::showSplash(bool shown)
{
if (splashScreen!=NULL && shown!=splashScreen->isShown())
splashScreen->setShown(shown);
}
bool ScribusMainWindow::splashShowing() const
{
if (splashScreen != NULL)
return splashScreen->isShown();
return false;
}
void ScribusMainWindow::closeSplash()
{
if (splashScreen!=NULL)
{
splashScreen->close();
delete splashScreen;
splashScreen = NULL;
}
}
void ScribusMainWindow::initToolBars()
{
fileToolBar = new QToolBar( tr("File"), this);
scrActions["fileNew"]->addTo(fileToolBar);
scrActions["fileOpen"]->addTo(fileToolBar);
scrMenuMgr->addMenuToWidgetOfAction("FileOpenRecent", scrActions["fileOpen"]);
scrActions["fileSave"]->addTo(fileToolBar);
scrActions["fileClose"]->addTo(fileToolBar);
scrActions["filePrint"]->addTo(fileToolBar);
scrActions["toolsPreflightVerifier"]->addTo(fileToolBar);
scrActions["fileExportAsPDF"]->addTo(fileToolBar);
editToolBar = new QToolBar( tr("Edit"), this);
UndoWidget* uWidget = new UndoWidget(editToolBar, "uWidget");
undoManager->registerGui(uWidget);
mainToolBar = new WerkToolB(this);
setDockEnabled(mainToolBar, DockLeft, false);
setDockEnabled(mainToolBar, DockRight, false);
mainToolBar->Sichtbar = true;
mainToolBar->setEnabled(false);
pdfToolBar = new WerkToolBP(this);
setDockEnabled(pdfToolBar, DockLeft, false);
setDockEnabled(pdfToolBar, DockRight, false);
pdfToolBar->setEnabled(false);
pdfToolBar->Sichtbar = true;
connect(mainToolBar, SIGNAL(Schliessen()), this, SLOT(ToggleTools()));
connect(pdfToolBar, SIGNAL(NewMode(int)), this, SLOT(setAppMode(int)));
connect(pdfToolBar, SIGNAL(Schliessen()), this, SLOT(TogglePDFTools()));
}
//Returns false when there are no fonts
const bool ScribusMainWindow::initFonts(bool showFontInfo)
{
setSplashStatus( tr("Searching for Fonts") );
bool haveFonts=prefsManager->GetAllFonts(showFontInfo);
if (!haveFonts)
{
if (splashScreen!=NULL)
splashScreen->close(); // 10/10/2004 pv fix #1200
QString mess = tr("There are no fonts found on your system.");
mess += "\n" + tr("Exiting now.");
QMessageBox::critical(this, tr("Fatal Error"), mess, 1, 0, 0);
}
else
setSplashStatus( tr("Font System Initialized") );
return haveFonts;
}
void ScribusMainWindow::initDefaultValues()
{
dirs = prefsManager->prefsFile->getContext("dirs");
HaveDoc = false;
singleClose = false;
ScriptRunning = false;
view = NULL;
doc = NULL;
Buffer2 = "";
DispX = 10;
DispY = 10;
DocNr = 1;
PrinterUsed = false;
PDef.Pname = "";
PDef.Dname = "";
PDef.Command = "";
keyrep = false;
_arrowKeyDown = false;
ClipB = QApplication::clipboard();
PalettesStat[0] = false;
GuidesStat[0] = false;
connect(ClipB, SIGNAL(dataChanged()), this, SLOT(ClipChange()));
connect(ClipB, SIGNAL(selectionChanged()), this, SLOT(ClipChange()));
}
void ScribusMainWindow::initKeyboardShortcuts()
{
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrActions.begin(); it!=scrActions.end(); ++it )
{
if ((ScrAction*)(it.data())!=NULL)
{
QString accelerator=it.data()->accel();
prefsManager->setKeyEntry(it.key(), it.data()->cleanMenuText(), accelerator,0);
}
//else
// qDebug(it.key());
//qDebug(QString("|-\n|%1||%2||%3").arg(it.key()).arg(it.data()->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 Tree(this, this);
connect( scrActions["toolsOutline"], SIGNAL(toggled(bool)) , outlinePalette, SLOT(setPaletteShown(bool)) );
connect( outlinePalette, SIGNAL(paletteShown(bool)), scrActions["toolsOutline"], SLOT(setOn(bool)));
propertiesPalette = new Mpalette(this);
connect( scrActions["toolsProperties"], SIGNAL(toggled(bool)) , propertiesPalette, SLOT(setPaletteShown(bool)) );
connect( propertiesPalette, SIGNAL(paletteShown(bool)), scrActions["toolsProperties"], SLOT(setOn(bool)));
//CB dont need this until we have a doc...
//propertiesPalette->Cpal->SetColors(prefsManager->colorSet());
propertiesPalette->Cpal->UseTrans(true);
propertiesPalette->Fonts->RebuildList(0);
propertiesPalette->installEventFilter(this);
nodePalette = new NodePalette(this);
nodePalette->installEventFilter(this);
layerPalette = new LayerPalette(this);
connect( scrActions["toolsLayers"], SIGNAL(toggled(bool)) , layerPalette, SLOT(setPaletteShown(bool)) );
connect( layerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsLayers"], SLOT(setOn(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(setOn(bool)));
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(setOn(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(setOn(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(setOn(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(setOn(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(setOn(bool)));
connect( alignDistributePalette, SIGNAL(documentChanged()), this, SLOT(slotDocCh()));
alignDistributePalette->installEventFilter(this);
//alignDistributePalette->hide();
undoPalette = new UndoPalette(this, "undoPalette");
undoPalette->installEventFilter(this);
undoManager->registerGui(undoPalette);
connect(undoPalette, SIGNAL(paletteShown(bool)), this, SLOT(setUndoPalette(bool)));
connect(undoPalette, SIGNAL(objectMode(bool)), this, SLOT(setUndoMode(bool)));
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->Spal, SIGNAL(newStyle(int)), this, SLOT(setNewAbStyle(int)));
connect(propertiesPalette, SIGNAL(EditLSt()), this, SLOT(slotEditLineStyles()));
connect(nodePalette, SIGNAL(Schliessen()), this, SLOT(NoFrameEdit()));
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(ChangeBMNr(int, int, int)), this, SLOT(ChBookmarks(int, int, int)));
connect(bookmarkPalette->BView, SIGNAL(SelectElement(int, int)), this, SLOT(selectItemsFromOutlines(int, int)));
}
void ScribusMainWindow::initScrapbook()
{
QString scrapbookFile = QDir::convertSeparators(PrefsPfad+"/scrap13.scs");
QFileInfo scrapbookFileInfo = QFileInfo(scrapbookFile);
if (scrapbookFileInfo.exists())
scrapbookPalette->readContents(scrapbookFile);
scrapbookPalette->setScrapbookFileName(scrapbookFile);
scrapbookPalette->AdjustMenu();
}
const QString ScribusMainWindow::getGuiLanguage()
{
return guiLanguage;
}
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.3 or lower. The process of saving will make this file unusable again in Scribus 1.2.3 unless you use File->Save As. Are you sure you wish to proceed with this operation?") + "</qt>",
CommonStrings::tr_OK, CommonStrings::tr_Cancel, "", 1, 0);
if (t == 0)
retval = true;
return retval;
}
void ScribusMainWindow::initMenuBar()
{
RecentDocs.clear();
scrMenuMgr->createMenu("File", tr("&File"));
scrMenuMgr->addMenuItem(scrActions["fileNew"], "File");
scrMenuMgr->addMenuItem(scrActions["fileOpen"], "File");
recentFileMenuName="FileOpenRecent";
scrMenuMgr->createMenu(recentFileMenuName, QIconSet(noIcon), tr("Open &Recent"), "File");
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["fileClose"], "File");
scrMenuMgr->addMenuItem(scrActions["fileSave"], "File");
scrMenuMgr->addMenuItem(scrActions["fileSaveAs"], "File");
scrMenuMgr->addMenuItem(scrActions["fileRevert"], "File");
scrMenuMgr->addMenuItem(scrActions["fileCollect"], "File");
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->createMenu("FileImport", QIconSet(noIcon), tr("&Import"), "File");
scrMenuMgr->addMenuItem(scrActions["fileImportText"], "FileImport");
scrMenuMgr->addMenuItem(scrActions["fileImportAppendText"], "FileImport");
scrMenuMgr->addMenuItem(scrActions["fileImportImage"], "FileImport");
scrMenuMgr->createMenu("FileExport", QIconSet(noIcon), tr("&Export"), "File");
scrMenuMgr->addMenuItem(scrActions["fileExportText"], "FileExport");
scrMenuMgr->addMenuItem(scrActions["fileExportAsEPS"], "FileExport");
scrMenuMgr->addMenuItem(scrActions["fileExportAsPDF"], "FileExport");
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["fileDocSetup"], "File");
scrMenuMgr->addMenuItem(scrActions["filePrint"], "File");
scrMenuMgr->addMenuItem(scrActions["PrintPreview"], "File");
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["fileQuit"], "File");
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["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("FileExport", false);
scrActions["fileDocSetup"]->setEnabled(false);
scrActions["filePrint"]->setEnabled(false);
scrActions["PrintPreview"]->setEnabled(false);
scrMenuMgr->createMenu("Edit", tr("&Edit"));
scrMenuMgr->addMenuItem(scrActions["editUndoAction"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editRedoAction"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editActionMode"], "Edit");
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editCut"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editCopy"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editPaste"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editClearContents"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editSelectAll"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editDeselectAll"], "Edit");
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editSearchReplace"], "Edit");
scrMenuMgr->addMenuItem(scrActions["toolsEditWithStoryEditor"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editEditWithImageEditor"], "Edit");
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editColors"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editParaStyles"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editLineStyles"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editMasterPages"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editJavascripts"], "Edit");
scrMenuMgr->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editPreferences"], "Edit");
scrActions["editUndoAction"]->setEnabled(false);
scrActions["editRedoAction"]->setEnabled(false);
scrActions["editActionMode"]->setEnabled(true);
scrActions["editCut"]->setEnabled(false);
scrActions["editCopy"]->setEnabled(false);
scrActions["editPaste"]->setEnabled(false);
scrActions["editClearContents"]->setEnabled(false);
scrActions["editSelectAll"]->setEnabled(false);
scrActions["editDeselectAll"]->setEnabled(false);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["editParaStyles"]->setEnabled(false);
scrActions["editLineStyles"]->setEnabled(false);
scrActions["editMasterPages"]->setEnabled(false);
scrActions["editJavascripts"]->setEnabled(false);
scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
scrActions["editEditWithImageEditor"]->setEnabled(false);
//Style Menu
scrMenuMgr->createMenu("Style", tr("St&yle"));
//Color menu
// CB TODO
scrMenuMgr->createMenu("Color", tr("&Color"));
ColorMenC = new ScComboBox(false);
ColorMenC->setEditable(false);
scrMenuMgr->addMenuItem(ColorMenC, "Color");
//Text size menu
scrMenuMgr->createMenu("FontSize", tr("&Size"));
scrActionGroups["fontSize"]->addTo(scrMenuMgr->getLocalPopupMenu("FontSize"));
//Shade menu
scrMenuMgr->createMenu("Shade", tr("&Shade"));
scrActionGroups["shade"]->addTo(scrMenuMgr->getLocalPopupMenu("Shade"));
//Font menu
scrMenuMgr->createMenu("Font", tr("&Font"));
FontMenu = scrMenuMgr->getLocalPopupMenu("Font");
//Type style menu
scrMenuMgr->createMenu("TypeEffects", tr("&Effects"));
scrActionGroups["typeEffects"]->addTo(scrMenuMgr->getLocalPopupMenu("TypeEffects"));
//Item Menu
scrMenuMgr->createMenu("Item", tr("&Item"));
scrMenuMgr->addMenuItem(scrActions["itemDuplicate"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemMulDuplicate"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemDelete"], "Item");
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemGroup"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemUngroup"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemLock"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemLockSize"], "Item");
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemImageIsVisible"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemUpdateImage"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemAdjustFrameToImage"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemExtendedImageProperties"], "Item");
scrMenuMgr->createMenu("ItemPreviewSettings", tr("Preview Settings"), "Item");
scrMenuMgr->addMenuItem(scrActions["itemPreviewLow"], "ItemPreviewSettings");
scrMenuMgr->addMenuItem(scrActions["itemPreviewNormal"], "ItemPreviewSettings");
scrMenuMgr->addMenuItem(scrActions["itemPreviewFull"], "ItemPreviewSettings");
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->createMenu("ItemLevel", tr("Level"));
scrMenuMgr->addMenuToMenu("ItemLevel", "Item");
scrMenuMgr->addMenuItem(scrActions["itemRaise"], "ItemLevel");
scrMenuMgr->addMenuItem(scrActions["itemLower"], "ItemLevel");
scrMenuMgr->addMenuItem(scrActions["itemRaiseToTop"], "ItemLevel");
scrMenuMgr->addMenuItem(scrActions["itemLowerToBottom"], "ItemLevel");
scrMenuMgr->createMenu("ItemLayer", tr("Send to La&yer"));
scrMenuMgr->addMenuToMenu("ItemLayer", "Item");
layerMenuName="ItemLayer";
scrMenuMgr->addMenuItem(scrActions["itemSendToScrapbook"], "Item");
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemAttributes"], "Item");
scrMenuMgr->createMenu("ItemPDFOptions", tr("&PDF Options"));
scrMenuMgr->addMenuToMenu("ItemPDFOptions", "Item");
scrMenuMgr->addMenuItem(scrActions["itemPDFIsAnnotation"], "ItemPDFOptions");
scrMenuMgr->addMenuItem(scrActions["itemPDFIsBookmark"], "ItemPDFOptions");
scrMenuMgr->addMenuItem(scrActions["itemPDFAnnotationProps"], "ItemPDFOptions");
scrMenuMgr->addMenuItem(scrActions["itemPDFFieldProps"], "ItemPDFOptions");
scrMenuMgr->createMenu("ItemShapes", tr("&Shape"), "Item");
// CB TODO
//Shape menu
SCustom = new Autoforms(0);
scrMenuMgr->addMenuItem(SCustom, "ItemShapes");
connect(SCustom, SIGNAL(FormSel(int, int, double *)), this, SLOT(MakeFrame(int, int, double *)));
scrMenuMgr->addMenuItem(scrActions["itemShapeEdit"], "ItemShapes");
scrMenuMgr->createMenu("ItemConvertTo", tr("C&onvert To"));
scrMenuMgr->addMenuToMenu("ItemConvertTo", "Item");
scrMenuMgr->addMenuItem(scrActions["itemConvertToBezierCurve"], "ItemConvertTo");
scrMenuMgr->addMenuItem(scrActions["itemConvertToImageFrame"], "ItemConvertTo");
scrMenuMgr->addMenuItem(scrActions["itemConvertToOutlines"], "ItemConvertTo");
scrMenuMgr->addMenuItem(scrActions["itemConvertToPolygon"], "ItemConvertTo");
scrMenuMgr->addMenuItem(scrActions["itemConvertToTextFrame"], "ItemConvertTo");
scrMenuMgr->addMenuItem(scrActions["itemAttachTextToPath"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemDetachTextFromPath"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemCombinePolygons"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemSplitPolygons"], "Item");
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["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", tr("I&nsert"));
scrMenuMgr->addMenuItem(scrActions["toolsInsertTextFrame"], "Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertImageFrame"], "Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertTableFrame"], "Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertShape"], "Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertPolygon"], "Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertLine"], "Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertBezier"], "Insert");
scrMenuMgr->addMenuItem(scrActions["toolsInsertFreehandLine"], "Insert");
scrMenuMgr->addMenuSeparator("Insert");
scrMenuMgr->addMenuItem(scrActions["insertGlyph"], "Insert");
scrMenuMgr->createMenu("InsertChar", QPixmap(noIcon), tr("Character"), "Insert");
//scrMenuMgr->addMenuToMenu("InsertChar", "Insert");
scrMenuMgr->addMenuItem(scrActions["specialPageNumber"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialSmartHyphen"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialNonBreakingHyphen"], "InsertChar");
scrMenuMgr->addMenuSeparator("InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialCopyRight"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialRegdTM"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialTM"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialBullet"], "InsertChar");
scrMenuMgr->addMenuSeparator("InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialDashEm"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialDashEn"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialDashFigure"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialDashQuotation"], "InsertChar");
scrMenuMgr->createMenu("InsertQuote", QPixmap(noIcon), tr("Quote"), "Insert");
//scrMenuMgr->addMenuToMenu("InsertQuote", "Insert");
scrMenuMgr->addMenuItem(scrActions["specialQuoteApostrophe"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteStraight"], "InsertQuote");
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteSingleLeft"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteSingleRight"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleLeft"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleRight"], "InsertQuote");
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteLowSingleComma"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteLowDoubleComma"], "InsertQuote");
//scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleTurnedComma"], "InsertQuote");
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteSingleReversed"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleReversed"], "InsertQuote");
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteSingleLeftGuillemet"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteSingleRightGuillemet"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleLeftGuillemet"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleRightGuillemet"], "InsertQuote");
scrMenuMgr->addMenuSeparator("InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteCJKSingleLeft"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteCJKSingleRight"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteCJKDoubleLeft"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteCJKDoubleRight"], "InsertQuote");
scrMenuMgr->createMenu("InsertSpace", QPixmap(noIcon), tr("Space"), "Insert");
//scrMenuMgr->addMenuToMenu("InsertSpace", "Insert");
scrMenuMgr->addMenuItem(scrActions["specialNonBreakingSpace"], "InsertSpace");
scrMenuMgr->addMenuItem(scrActions["specialNewLine"], "InsertSpace");
scrMenuMgr->addMenuItem(scrActions["specialFrameBreak"], "InsertSpace");
scrMenuMgr->addMenuItem(scrActions["specialColumnBreak"], "InsertSpace");
scrMenuMgr->addMenuSeparator("Insert");
scrMenuMgr->addMenuItem(scrActions["insertSampleText"], "Insert");
scrActions["insertGlyph"]->setEnabled(false);
//Page menu
scrMenuMgr->createMenu("Page", tr("&Page"));
scrMenuMgr->addMenuItem(scrActions["pageInsert"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageImport"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageDelete"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageCopy"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageMove"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageApplyMasterPage"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageCopyToMasterPage"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageManageGuides"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageManageMargins"], "Page");
scrMenuMgr->addMenuSeparator("Page");
scrMenuMgr->addMenuItem(scrActions["viewSnapToGrid"], "Page");
scrMenuMgr->addMenuItem(scrActions["viewSnapToGuides"], "Page");
scrActions["pageDelete"]->setEnabled(false);
scrActions["pageMove"]->setEnabled(false);
//View menu
scrMenuMgr->createMenu("View", tr("&View"));
scrMenuMgr->addMenuItem(scrActions["viewFitInWindow"], "View");
scrMenuMgr->addMenuItem(scrActions["viewFit50"], "View");
scrMenuMgr->addMenuItem(scrActions["viewFit75"], "View");
scrMenuMgr->addMenuItem(scrActions["viewFit100"], "View");
scrMenuMgr->addMenuItem(scrActions["viewFit200"], "View");
scrMenuMgr->addMenuItem(scrActions["viewFit20"], "View");
scrMenuMgr->addMenuSeparator("View");
scrMenuMgr->addMenuItem(scrActions["viewShowMargins"], "View");
scrMenuMgr->addMenuItem(scrActions["viewShowFrames"], "View");
scrMenuMgr->addMenuItem(scrActions["viewShowImages"], "View");
scrMenuMgr->addMenuItem(scrActions["viewShowGrid"], "View");
scrMenuMgr->addMenuItem(scrActions["viewShowGuides"], "View");
scrMenuMgr->addMenuItem(scrActions["viewShowBaseline"], "View");
scrMenuMgr->addMenuItem(scrActions["viewShowTextChain"], "View");
scrMenuMgr->addMenuItem(scrActions["viewShowTextControls"], "View");
scrMenuMgr->addMenuItem(scrActions["viewRulerMode"], "View");
//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", tr("E&xtras"));
scrMenuMgr->addMenuItem(scrActions["extrasManagePictures"], "Extras");
scrMenuMgr->addMenuItem(scrActions["extrasHyphenateText"], "Extras");
scrMenuMgr->addMenuItem(scrActions["extrasDeHyphenateText"], "Extras");
scrMenuMgr->addMenuItem(scrActions["extrasGenerateTableOfContents"], "Extras");
scrMenuMgr->setMenuEnabled("Extras", false);
scrActions["extrasHyphenateText"]->setEnabled(false);
scrActions["extrasDeHyphenateText"]->setEnabled(false);
//Window menu
scrMenuMgr->createMenu("Windows", tr("&Windows"), QString::null, true);
connect(scrMenuMgr->getLocalPopupMenu("Windows"), SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
addDefaultWindowMenuItems();
//Help menu
scrMenuMgr->createMenu("Help", tr("&Help"));
scrMenuMgr->addMenuItem(scrActions["helpAboutScribus"], "Help");
scrMenuMgr->addMenuItem(scrActions["helpAboutPlugins"], "Help");
scrMenuMgr->addMenuItem(scrActions["helpAboutQt"], "Help");
scrMenuMgr->addMenuSeparator("Help");
scrMenuMgr->addMenuItem(scrActions["helpTooltips"], "Help");
scrMenuMgr->addMenuItem(scrActions["helpManual"], "Help");
scrMenuMgr->addMenuToMenuBar("File");
scrMenuMgr->addMenuToMenuBar("Edit");
scrMenuMgr->addMenuToMenuBar("Style");
scrMenuMgr->setMenuEnabled("Style", false);
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()->insertSeparator();
scrMenuMgr->addMenuToMenuBar("Help");
//Alignment menu
scrMenuMgr->createMenu("Alignment", tr("&Alignment"));
scrMenuMgr->addMenuItem(scrActions["alignLeft"], "Alignment");
scrMenuMgr->addMenuItem(scrActions["alignCenter"], "Alignment");
scrMenuMgr->addMenuItem(scrActions["alignRight"], "Alignment");
scrMenuMgr->addMenuItem(scrActions["alignBlock"], "Alignment");
scrMenuMgr->addMenuItem(scrActions["alignForced"], "Alignment");
connect(ColorMenC, SIGNAL(activated(int)), this, SLOT(setItemFarbe(int)));
connect(FontMenu, SIGNAL(activated(int)), this, SLOT(setItemFont(int)));
}
void ScribusMainWindow::addDefaultWindowMenuItems()
{
scrMenuMgr->clearMenu("Windows");
scrMenuMgr->addMenuItem(scrActions["windowsCascade"], "Windows");
scrMenuMgr->addMenuItem(scrActions["windowsTile"], "Windows");
scrMenuMgr->addMenuSeparator("Windows");
scrMenuMgr->addMenuItem(scrActions["toolsProperties"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsOutline"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsScrapbook"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsLayers"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsPages"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsBookmarks"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsMeasurements"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsActionHistory"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsPreflightVerifier"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsAlignDistribute"], "Windows");
scrMenuMgr->addMenuSeparator("Windows");
scrMenuMgr->addMenuItem(scrActions["toolsToolbarTools"], "Windows");
scrMenuMgr->addMenuItem(scrActions["toolsToolbarPDF"], "Windows");
}
void ScribusMainWindow::initStatusBar()
{
mainWindowStatusLabel = new QLabel( " ", statusBar(), "ft");
mainWindowProgressBar = new QProgressBar(statusBar(), "p");
mainWindowProgressBar->setCenterIndicator(true);
mainWindowProgressBar->setFixedWidth( 100 );
mainWindowProgressBar->reset();
mainWindowXPosLabel = new QLabel( "X-Pos:", statusBar(), "xt");
mainWindowYPosLabel = new QLabel( "Y-Pos:", statusBar(), "yt");
mainWindowXPosDataLabel = new QLabel( " ", statusBar(), "dt");
mainWindowYPosDataLabel = new QLabel( " ", statusBar(), "ydt");
statusBar()->addWidget(mainWindowStatusLabel, 3, true);
statusBar()->addWidget(mainWindowProgressBar, 0, true);
statusBar()->addWidget(mainWindowXPosLabel, 0, true);
statusBar()->addWidget(mainWindowXPosDataLabel, 1, true);
statusBar()->addWidget(mainWindowYPosLabel, 0, true);
statusBar()->addWidget(mainWindowYPosDataLabel, 1, true);
}
void ScribusMainWindow::setMousePositionOnStatusBar(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;
QString suffix=unitGetSuffixFromIndex(doc->unitIndex());
int multiplier=unitGetDecimalsFromIndex(doc->unitIndex());
double divisor=static_cast<double>(multiplier);
int precision=unitGetPrecisionFromIndex(doc->unitIndex());
QString tmp;
mainWindowXPosDataLabel->setText(tmp.setNum(qRound(xn*doc->unitRatio() * multiplier) / divisor, 'f', precision) + suffix);
mainWindowYPosDataLabel->setText(tmp.setNum(qRound(yn*doc->unitRatio() * multiplier) / divisor, 'f', precision) + suffix);
}
void ScribusMainWindow::setTBvals(PageItem *currItem)
{
if (currItem->itemText.count() != 0)
{
int ChPos = QMIN(currItem->CPos, static_cast<int>(currItem->itemText.count()-1));
doc->CurrentStyle = currItem->itemText.at(ChPos)->cstyle & 1919;
doc->currentParaStyle = currItem->itemText.at(ChPos)->cab;
setAbsValue(doc->currentParaStyle);
propertiesPalette->setAli(doc->currentParaStyle);
doc->CurrFont = currItem->itemText.at(ChPos)->cfont->scName();
doc->CurrFontSize = currItem->itemText.at(ChPos)->csize;
doc->CurrTextFill = currItem->itemText.at(ChPos)->ccolor;
doc->CurrTextFillSh = currItem->itemText.at(ChPos)->cshade;
doc->CurrTextStroke = currItem->itemText.at(ChPos)->cstroke;
doc->CurrTextStrokeSh = currItem->itemText.at(ChPos)->cshade2;
doc->CurrTextScale = currItem->itemText.at(ChPos)->cscale;
doc->CurrTextScaleV = currItem->itemText.at(ChPos)->cscalev;
doc->CurrTextBase = currItem->itemText.at(ChPos)->cbase;
doc->CurrTextShadowX = currItem->itemText.at(ChPos)->cshadowx;
doc->CurrTextShadowY = currItem->itemText.at(ChPos)->cshadowy;
doc->CurrTextOutline = currItem->itemText.at(ChPos)->coutline;
doc->CurrTextUnderPos = currItem->itemText.at(ChPos)->cunderpos;
doc->CurrTextUnderWidth = currItem->itemText.at(ChPos)->cunderwidth;
doc->CurrTextStrikePos = currItem->itemText.at(ChPos)->cstrikepos;
doc->CurrTextStrikeWidth = currItem->itemText.at(ChPos)->cstrikewidth;
emit TextUnderline(doc->CurrTextUnderPos, doc->CurrTextUnderWidth);
emit TextStrike(doc->CurrTextStrikePos, doc->CurrTextStrikeWidth);
emit TextShadow(doc->CurrTextShadowX, doc->CurrTextShadowY);
emit TextFarben(doc->CurrTextStroke, doc->CurrTextFill, doc->CurrTextStrokeSh, doc->CurrTextFillSh);
emit TextIFont(doc->CurrFont);
emit TextISize(doc->CurrFontSize);
emit TextUSval(currItem->itemText.at(ChPos)->cextra);
emit TextStil(doc->CurrentStyle);
emit TextScale(doc->CurrTextScale);
emit TextScaleV(doc->CurrTextScaleV);
emit TextBase(doc->CurrTextBase);
emit TextOutline(doc->CurrTextOutline);
}
}
void ScribusMainWindow::wheelEvent(QWheelEvent *w)
{
if (HaveDoc)
{
int wheelVal=prefsManager->mouseWheelValue();
if ((w->orientation() != Qt::Vertical) || ( w->state() & ShiftButton ))
{
if (w->delta() < 0)
view->scrollBy(wheelVal, 0);
else
view->scrollBy(-wheelVal, 0);
}
else
{
if (w->delta() < 0)
view->scrollBy(0, wheelVal);
else
view->scrollBy(0, -wheelVal);
}
w->accept();
}
}
//Special keys assigned to actions are stolen by the action and not passed to
//keyPressEvent so process them here.
void ScribusMainWindow::specialActionKeyEvent(QString actionName, int unicodevalue)
{
if (HaveDoc)
{
if (doc->appMode==modeEdit)
{
if (doc->selection->count() == 1)
{
struct ScText *hg = new ScText;
PageItem *currItem = doc->selection->itemAt(0);
if (unicodevalue!=-1)
{
hg->ch = QString(QChar(unicodevalue));
doc->setScTextDefaultsFromDoc(hg);
hg->cselect = false;
hg->cextra = 0;
hg->xp = 0;
hg->yp = 0;
hg->PRot = 0;
hg->PtransX = 0;
hg->PtransY = 0;
hg->cembedded = 0;
currItem->itemText.insert(currItem->CPos, hg);
currItem->CPos += 1;
currItem->Tinput = true;
view->RefreshItem(currItem);
}
else if (actionName=="specialSmartHyphen") //ignore the char as we use an attribute if the text item, for now.
{
currItem->itemText.at(QMAX(currItem->CPos-1,0))->cstyle ^= 128;
currItem->Tinput = true;
view->RefreshItem(currItem);
}
}
}
}
}
/*!
\brief Receive key events from palettes such as palette hiding events. Possibly easier way but this is cleaner than before. No need to modify all those palettes and each new one in future.
*/
bool ScribusMainWindow::eventFilter( QObject */*o*/, QEvent *e )
{
bool retVal;
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent *k = (QKeyEvent *)e;
int keyMod=0;
if (k->state() & ShiftButton)
keyMod |= SHIFT;
if (k->state() & ControlButton)
keyMod |= CTRL;
if (k->state() & AltButton)
keyMod |= ALT;
QKeySequence currKeySeq = QKeySequence(k->key() | keyMod);
if (QString(currKeySeq).isNull())
return false;
retVal=true;
//Palette actions
if (currKeySeq == scrActions["specialToggleAllPalettes"]->accel())
scrActions["specialToggleAllPalettes"]->activate();
else
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
//Undo actions
if (currKeySeq == scrActions["editUndoAction"]->accel() && scrActions["editUndoAction"]->isEnabled())
scrActions["editUndoAction"]->activate();
else
if (currKeySeq == scrActions["editRedoAction"]->accel() && scrActions["editRedoAction"]->isEnabled())
scrActions["editRedoAction"]->activate();
else
//Other actions
if (currKeySeq == scrActions["fileQuit"]->accel())
scrActions["fileQuit"]->activate();
else
//Zoom actions
if (currKeySeq == scrActions["toolsZoomIn"]->accel())
scrActions["toolsZoomIn"]->activate();
else
if (currKeySeq == scrActions["toolsZoomOut"]->accel())
scrActions["toolsZoomOut"]->activate();
else
retVal=false;
}
else
retVal=false;
//Return false to pass event to object
return retVal;
}
void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
{
QWidgetList windows;
QWidget* w = NULL;
//struct ScText *hg;
int kk = k->key();
//int as = k->ascii();
//double altx, alty;
QString uc = k->text();
QString cr, Tcha, Twort;
//uint Tcoun;
//int len, pos, c;
if (keyrep)
return;
keyrep = true;
int KeyMod;
switch (k->state())
{
case ShiftButton:
KeyMod = SHIFT;
break;
case AltButton:
KeyMod = ALT;
break;
case ControlButton:
KeyMod = CTRL;
break;
default:
KeyMod = 0;
break;
}
//User presses escape and we have a doc open, and we have an item selected
if ((kk == Key_Escape) && (HaveDoc))
{
keyrep = false;
PageItem *currItem;
if (doc->selection->count() != 0)
{
currItem = doc->selection->itemAt(0);
switch (doc->appMode)
{
case modeNormal:
currItem->Sizing = false;
if (doc->SubMode != -1)
{
view->Deselect(false);
doc->Items->remove(currItem->ItemNr);
}
break;
case modeLinkFrames:
case modeUnlinkFrames:
case modeEdit:
case modeRotation:
view->Deselect(false);
case modePanning:
break;
case modeDrawBezierLine:
currItem->PoLine.resize(currItem->PoLine.size()-2);
if (currItem->PoLine.size() < 4)
{
view->Deselect(false);
doc->Items->remove(currItem->ItemNr);
}
else
{
view->SizeItem(currItem->PoLine.WidthHeight().x(), currItem->PoLine.WidthHeight().y(), currItem->ItemNr, false, false);
currItem->SetPolyClip(qRound(QMAX(currItem->Pwidth / 2, 1)));
view->AdjustItemSize(currItem);
currItem->ContourLine = currItem->PoLine.copy();
currItem->ClipEdited = true;
currItem->FrameType = 3;
slotDocCh();
}
view->FirstPoly = true;
break;
default:
view->Deselect(false);
doc->Items->remove(currItem->ItemNr);
break;
}
}
view->Mpressed = false;
doc->DragP = false;
doc->leaveDrag = false;
view->Imoved = false;
view->mCG = false;
view->MidButt = false;
doc->SubMode = -1;
doc->ElemToLink = NULL;
NoFrameEdit();
slotSelect();
return;
}
ButtonState buttonState = k->state();
/**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()))
{
/**
* 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->selection->count() == 0))
{
switch (kk)
{
case Key_Space:
keyrep = false;
if (doc->appMode == modePanning)
setAppMode(modeNormal);
else
setAppMode(modePanning);
return;
break;
case Key_Prior:
view->scrollBy(0, -prefsManager->mouseWheelValue());
keyrep = false;
return;
break;
case Key_Next:
view->scrollBy(0, prefsManager->mouseWheelValue());
keyrep = false;
return;
break;
case Key_Tab:
keyrep = false;
windows = wsp->windowList();
if (windows.count() > 1)
{
for (int i = 0; i < static_cast<int>(windows.count()); ++i)
{
if (wsp->activeWindow() == windows.at(i))
{
if (i == static_cast<int>(windows.count()-1))
w = windows.at(0);
else
w = windows.at(i+1);
break;
}
}
doc->OpenNodes = 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
* -- Use PageUp to raise an item
* -- Use PageDown to lower an item
* -- Use the arrow keys to move an item or group around, with no meta, by 1.0, Ctrl by 0.1, Shift by 10.0.
*/
if (doc->selection->count() != 0)
{
double moveBy=1.0;
if (buttonState & ShiftButton)
moveBy=10.0;
else if (buttonState & ControlButton)
moveBy=0.1;
PageItem *currItem = doc->selection->itemAt(0);
switch (doc->appMode)
{
case modeNormal:
switch (kk)
{
case Key_Backspace:
case Key_Delete:
if (!doc->EditClip)
{
view->DeleteItem();
slotDocCh();
}
break;
case Key_Prior:
if (!currItem->locked())
{
view->RaiseItem();
slotDocCh();
}
break;
case Key_Next:
if (!currItem->locked())
{
view->LowerItem();
slotDocCh();
}
break;
case Key_Left:
if (!currItem->locked())
{
if ((doc->EditClip) && (view->ClRe != -1))
{
FPoint np;
if (view->EditContour)
np = currItem->ContourLine.point(view->ClRe);
else
np = currItem->PoLine.point(view->ClRe);
np = np - FPoint(moveBy, 0);
view->MoveClipPoint(currItem, np);
}
else
{
view->moveGroup(-moveBy, 0);
}
slotDocCh();
}
break;
case Key_Right:
if (!currItem->locked())
{
if ((doc->EditClip) && (view->ClRe != -1))
{
FPoint np;
if (view->EditContour)
np = currItem->ContourLine.point(view->ClRe);
else
np = currItem->PoLine.point(view->ClRe);
np = np + FPoint(moveBy, 0);
view->MoveClipPoint(currItem, np);
}
else
{
view->moveGroup(moveBy, 0);
}
slotDocCh();
}
break;
case Key_Up:
if (!currItem->locked())
{
if ((doc->EditClip) && (view->ClRe != -1))
{
FPoint np;
if (view->EditContour)
np = currItem->ContourLine.point(view->ClRe);
else
np = currItem->PoLine.point(view->ClRe);
np = np - FPoint(0, moveBy);
view->MoveClipPoint(currItem, np);
}
else
{
view->moveGroup(0, -moveBy);
}
slotDocCh();
}
break;
case Key_Down:
if (!currItem->locked())
{
if ((doc->EditClip) && (view->ClRe != -1))
{
FPoint np;
if (view->EditContour)
np = currItem->ContourLine.point(view->ClRe);
else
np = currItem->PoLine.point(view->ClRe);
np = np + FPoint(0, moveBy);
view->MoveClipPoint(currItem, np);
}
else
{
view->moveGroup(0, moveBy);
}
slotDocCh();
}
break;
default:
break;
}
break;
case modeEdit:
if (currItem->asImageFrame() && !currItem->locked())
{
switch (kk)
{
case Key_Left:
view->MoveItemI(currItem, -moveBy, 0, true);
break;
case Key_Right:
view->MoveItemI(currItem, moveBy, 0, true);
break;
case Key_Up:
view->MoveItemI(currItem, 0, -moveBy, true);
break;
case Key_Down:
view->MoveItemI(currItem, 0, moveBy, true);
break;
}
}
view->oldCp = currItem->CPos;
if (currItem->itemType() == PageItem::TextFrame)
{
bool kr=keyrep;
currItem->handleModeEditKey(k, keyrep);
keyrep=kr;
}
slotDocCh(false);
break;
}
}
}
switch(kk)
{
case Key_Left:
case Key_Right:
case Key_Up:
case Key_Down:
_arrowKeyDown = true;
}
keyrep = false;
}
void ScribusMainWindow::keyReleaseEvent(QKeyEvent *k)
{
if (k->state() & ControlButton)
{
if (HaveDoc)
{
if ((doc->appMode == modePanning) && (k->state() & Qt::RightButton))
setAppMode(modeNormal);
}
}
if (k->isAutoRepeat() || !_arrowKeyDown)
return;
switch(k->key())
{
case Key_Left:
case Key_Right:
case Key_Up:
case Key_Down:
_arrowKeyDown = false;
if ((HaveDoc) && (!view->zoomSpinBox->hasFocus()) && (!view->pageSelector->hasFocus()))
{
uint docSelectionCount=doc->selection->count();
if ((docSelectionCount != 0) && (doc->appMode == modeNormal) && (doc->EditClip) && (view->ClRe != -1))
view->updateContents();
for (uint i = 0; i < docSelectionCount; ++i)
doc->selection->itemAt(i)->checkChanges(true);
if (docSelectionCount > 1 && view->groupTransactionStarted())
undoManager->commit();
}
break;
}
}
void ScribusMainWindow::closeEvent(QCloseEvent *ce)
{
QWidgetList windows = wsp->windowList();
ScribusWin* tw;
disconnect(wsp, SIGNAL(windowActivated(QWidget *)), this, SLOT(newActWin(QWidget *)));
if (!windows.isEmpty())
{
singleClose = true;
uint windowCount=windows.count();
for ( uint i = 0; i < windowCount; ++i )
{
newActWin(windows.at(i));
tw = ActWin;
ActWin->close();
if (tw == ActWin)
{
ce->ignore();
singleClose = false;
connect(wsp, SIGNAL(windowActivated(QWidget *)), this, SLOT(newActWin(QWidget *)));
return;
}
}
}
propertiesPalette->hide();
outlinePalette->hide();
scrapbookPalette->hide();
bookmarkPalette->hide();
layerPalette->hide();
pagePalette->hide();
measurementPalette->hide();
docCheckerPalette->hide();
undoPalette->hide();
alignDistributePalette->hide();
// Clean up plugins, THEN save prefs to disk
pluginManager->cleanupPlugins();
if (!emergencyActivated)
prefsManager->SavePrefs();
UndoManager::deleteInstance();
if ((prefsManager->appPrefs.SaveAtQ) && (scrapbookPalette->changed()))
{
if (scrapbookPalette->getScrapbookFileName().isEmpty())
scrapbookPalette->setScrapbookFileName(PrefsPfad+"/scrap13.scs");
scrapbookPalette->Save();
}
if (scrapbookPalette->objectCount() == 0)
unlink(PrefsPfad+"/scrap13.scs");
qApp->setOverrideCursor(QCursor(ArrowCursor), true);
exit(0);
}
/////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATION
/////////////////////////////////////////////////////////////////////
bool ScribusMainWindow::arrowKeyDown()
{
return _arrowKeyDown;
}
void ScribusMainWindow::startUpDialog()
{
PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false);
NewDoc* dia = new NewDoc(this, true);
if (dia->exec())
{
if (dia->tabSelected == 0)
{
int facingPages = dia->choosenLayout;
int firstPage = dia->docLayout->firstPage->currentItem();
double topMargin = dia->GroupRand->RandT;
double bottomMargin = dia->GroupRand->RandB;
double leftMargin = dia->GroupRand->RandL;
double rightMargin = dia->GroupRand->RandR;
double columnDistance = dia->Dist;
double pageWidth = dia->Pagebr;
double pageHeight = dia->Pageho;
double numberCols = dia->SpinBox10->value();
bool autoframes = dia->AutoFrame->isChecked();
int orientation = dia->Orient;
int pageCount=dia->PgNum->value();
PageSize *ps2 = new PageSize(dia->ComboBox1->currentText());
QString pagesize = ps2->getPageName();
doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->ComboBox3->currentItem(), firstPage, orientation, dia->PgNr->value(), pagesize, pageCount);
doc->pageSets[facingPages].FirstPage = firstPage;
delete ps2;
HaveNewDoc();
}
else
{
if (dia->tabSelected == 1)
{
QString fileName(dia->fileDialog->selectedFile());
if (!fileName.isEmpty())
{
docContext->set("docsopen", fileName.left(fileName.findRev("/")));
loadDoc(fileName);
}
}
else
{
QString fileName(dia->recentDocList->currentText());
if (!fileName.isEmpty())
loadRecent(fileName);
}
}
}
prefsManager->setShowStartupDialog(!dia->startUpDialog->isChecked());
delete dia;
mainWindowStatusLabel->setText( tr("Ready"));
}
bool ScribusMainWindow::slotFileNew()
{
bool retVal;
NewDoc* dia = new NewDoc(this);
if (dia->exec())
{
int facingPages = dia->choosenLayout;
int firstPage = dia->docLayout->firstPage->currentItem();
double topMargin = dia->GroupRand->RandT;
double bottomMargin = dia->GroupRand->RandB;
double leftMargin = dia->GroupRand->RandL;
double rightMargin = dia->GroupRand->RandR;
double columnDistance = dia->Dist;
double pageWidth = dia->Pagebr;
double pageHeight = dia->Pageho;
double numberCols = dia->SpinBox10->value();
bool autoframes = dia->AutoFrame->isChecked();
int orientation = dia->Orient;
int pageCount=dia->PgNum->value();
PageSize *ps2 = new PageSize(dia->ComboBox1->currentText());
QString pagesize = ps2->getPageName();
retVal = doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->ComboBox3->currentItem(), firstPage, orientation, dia->PgNr->value(), pagesize, pageCount);
doc->pageSets[facingPages].FirstPage = firstPage;
mainWindowStatusLabel->setText( tr("Ready"));
delete ps2;
HaveNewDoc();
}
else
retVal = false;
delete dia;
return retVal;
}
bool ScribusMainWindow::doFileNew(double width, double h, double tpr, double lr, double rr, double br, double ab, double sp,
bool atf, int fp, int einh, int firstleft, int Ori, int SNr, const QString& defaultPageSize, int pageCount)
{
QString cc;
if (HaveDoc)
{
doc->OpenNodes = outlinePalette->buildReopenVals();
}
doc = new ScribusDoc();
doc->setLoading(true);
doc->setup(einh, fp, firstleft, Ori, SNr, defaultPageSize, doc->DocName+cc.setNum(DocNr));
HaveDoc++;
DocNr++;
if (CMSavail && doc->CMSSettings.CMSinUse)
recalcColors();
doc->setPage(width, h, tpr, lr, rr, br, sp, ab, atf, fp);
doc->setMasterPageMode(false);
doc->addMasterPage(0, "Normal");
int createCount=pageCount;
if (createCount<=0)
createCount=1;
for (int i = 0; i < createCount; ++i)
doc->addPage(i, "Normal", true);
doc->addSection();
doc->setFirstSectionFromFirstPageNumber();
doc->setModified(false);
doc->setLoading(false);
doc->currentPage = doc->Pages->at(0);
doc->OpenNodes.clear();
//<<View and window code
ScribusWin* w = new ScribusWin(wsp, doc);
if (view!=NULL)
{
actionManager->disconnectNewViewActions();
disconnect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
}
view = new ScribusView(w, doc);
view->setScale(prefsManager->displayScale());
actionManager->connectNewViewActions(view);
alignDistributePalette->setView(view);
docCheckerPalette->clearErrorList();
w->setView(view);
ActWin = w;
doc->WinHan = w;
w->setCentralWidget(view);
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 ( wsp->windowList().isEmpty() )
w->showMaximized();
else
w->show();
view->show();
connect(doc->autoSaveTimer, SIGNAL(timeout()), w, SLOT(slotAutoSave()));
connect(w, SIGNAL(AutoSaved()), this, SLOT(slotAutoSaved()));
connect(fileWatcher, SIGNAL(fileChanged(QString)), view, SLOT(updatePict(QString)));
connect(fileWatcher, SIGNAL(fileDeleted(QString)), view, SLOT(removePict(QString)));
scrActions["fileSave"]->setEnabled(false);
undoManager->switchStack(doc->DocName);
tocGenerator->setDoc(doc);
return true;
}
void ScribusMainWindow::newView()
{
ScribusWin* w = new ScribusWin(wsp, doc);
view = new ScribusView(w, doc);
view->setScale(prefsManager->displayScale());
w->setView(view);
ActWin = w;
w->setCentralWidget(view);
alignDistributePalette->setView(view);
connect(undoManager, SIGNAL(undoRedoDone()), view, SLOT(DrawNew()));
//connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
}
/*CB Unnecessary code, used once, lets use the slot directly
bool ScribusMainWindow::DoSaveClose()
{
return slotFileSave();
}
*/
void ScribusMainWindow::windowsMenuAboutToShow()
{
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrWindowsActions.begin(); it!=scrWindowsActions.end(); ++it )
scrMenuMgr->removeMenuItem((*it), "Windows");
scrWindowsActions.clear();
addDefaultWindowMenuItems();
QWidgetList windows = wsp->windowList();
bool windowsListNotEmpty=!windows.isEmpty();
scrActions["windowsCascade"]->setEnabled(windowsListNotEmpty);
scrActions["windowsTile"]->setEnabled(windowsListNotEmpty);
if (windowsListNotEmpty)
{
scrMenuMgr->addMenuSeparator("Windows");
int windowCount=static_cast<int>(windows.count());
for ( int i = 0; i < windowCount; ++i )
{
QString docInWindow=windows.at(i)->caption();
scrWindowsActions.insert(docInWindow, new ScrAction( ScrAction::Window, noIcon, docInWindow, QKeySequence(), this, docInWindow, i));
scrWindowsActions[docInWindow]->setToggleAction(true);
connect( scrWindowsActions[docInWindow], SIGNAL(activatedData(int)), this, SLOT(windowsMenuActivated(int)) );
scrMenuMgr->addMenuItem(scrWindowsActions[docInWindow], "Windows");
scrWindowsActions[docInWindow]->setOn(wsp->activeWindow() == windows.at(i));
}
}
}
void ScribusMainWindow::newActWin(QWidget *w)
{
if (w == NULL)
{
ActWin = NULL;
return;
}
ActWin = (ScribusWin*)w;
if (ActWin->document()==NULL)
return;
QString oldDocName = "";
if (ActWin && ActWin->document())
oldDocName = ActWin->document()->DocName;
/* if (doc != NULL)
{
if ((HaveDoc) && (doc != ActWin->doc))
doc->OpenNodes = outlinePalette->buildReopenVals();
} */
docCheckerPalette->clearErrorList();
QString newDocName = "";
if (ActWin && ActWin->document())
newDocName = ActWin->document()->DocName;
if (oldDocName != newDocName)
undoManager->switchStack(newDocName);
if (view!=NULL)
{
actionManager->disconnectNewViewActions();
disconnect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
if (ScQApp->usingGUI())
disconnect(doc->selection, SIGNAL(selectionIsMultiple(bool)), 0, 0);
}
doc = ActWin->document();
view = ActWin->view();
actionManager->connectNewViewActions(view);
connect(view, SIGNAL(signalGuideInformation(int, double)), alignDistributePalette, SLOT(setGuide(int, double)));
if (ScQApp->usingGUI())
connect(doc->selection, SIGNAL(selectionIsMultiple(bool)), propertiesPalette, SLOT( setMultipleSelection(bool)));
pagePalette->setView(view);
alignDistributePalette->setView(view);
if (!doc->isLoading())
{
scanDocument();
docCheckerPalette->buildErrorList(doc);
SwitchWin();
QWidgetList windows = wsp->windowList();
ScribusWin* swin;
for ( int i = 0; i < static_cast<int>(windows.count()); ++i )
{
swin = (ScribusWin*)windows.at(i);
if (swin==ActWin && doc->masterPageMode())
swin->setMasterPagesPaletteShown(true);
else
swin->setMasterPagesPaletteShown(false);
}
//if (doc->masterPageMode())
// ActWin->setMasterPagesPaletteShown(true);
setAppMode(doc->appMode);
}
w->setFocus();
wsp->setScrollBarsEnabled(!(w->isMaximized()));
scrActions["viewShowMargins"]->setOn(doc->guidesSettings.marginsShown);
scrActions["viewShowFrames"]->setOn(doc->guidesSettings.framesShown);
scrActions["viewShowGrid"]->setOn(doc->guidesSettings.gridShown);
scrActions["viewShowGuides"]->setOn(doc->guidesSettings.guidesShown);
scrActions["viewShowBaseline"]->setOn(doc->guidesSettings.baseShown);
scrActions["viewShowImages"]->setOn(doc->guidesSettings.showPic);
scrActions["viewShowTextChain"]->setOn(doc->guidesSettings.linkShown);
scrActions["viewShowTextControls"]->setOn(doc->guidesSettings.showControls);
scrActions["viewRulerMode"]->setOn(doc->guidesSettings.rulerMode);
if (!doc->masterPageMode())
pagePalette->Rebuild();
outlinePalette->setDoc(doc);
outlinePalette->BuildTree();
// outlinePalette->reopenTree(doc->OpenNodes);
/* bookmarkPalette->BView->NrItems = doc->NrItems;
bookmarkPalette->BView->First = doc->First;
bookmarkPalette->BView->Last = doc->Last; */
RestoreBookMarks();
if (!doc->isLoading())
{
if (doc->selection->count() != 0)
{
HaveNewSel(doc->selection->itemAt(0)->itemType());
doc->selection->itemAt(0)->emitAllToGUI();
}
else
HaveNewSel(-1);
}
tocGenerator->setDoc(doc);
}
void ScribusMainWindow::windowsMenuActivated( int id )
{
if (HaveDoc)
doc->OpenNodes = outlinePalette->buildReopenVals();
QWidget* windowWidget = wsp->windowList().at( id );
if ( windowWidget )
windowWidget->showNormal();
newActWin(windowWidget);
}
bool ScribusMainWindow::slotDocSetup()
{
bool ret = false;
ReformDoc* dia = new ReformDoc(this, doc);
Q_CHECK_PTR(dia);
if (dia->exec())
{
slotChangeUnit(dia->getSelectedUnit(), false);
dia->updateDocumentSettings();
if (dia->imageResolutionChanged())
view->RecalcPicturesRes();
FontSub->RebuildList(doc);
propertiesPalette->Fonts->RebuildList(doc);
scrActions["viewShowMargins"]->setOn(doc->guidesSettings.marginsShown);
scrActions["viewShowFrames"]->setOn(doc->guidesSettings.framesShown);
scrActions["viewShowGrid"]->setOn(doc->guidesSettings.gridShown);
scrActions["viewShowGuides"]->setOn(doc->guidesSettings.guidesShown);
scrActions["viewShowBaseline"]->setOn(doc->guidesSettings.baseShown);
scrActions["viewShowImages"]->setOn(doc->guidesSettings.showPic);
scrActions["viewShowTextChain"]->setOn(doc->guidesSettings.linkShown);
scrActions["viewShowTextControls"]->setOn(doc->guidesSettings.showControls);
scrActions["viewRulerMode"]->setOn(doc->guidesSettings.rulerMode);
view->reformPages();
view->GotoPage(doc->currentPage->pageNr());
view->DrawNew();
propertiesPalette->ShowCMS();
pagePalette->RebuildPage();
slotDocCh();
ret = true;
}
delete dia;
return ret;
}
void ScribusMainWindow::SwitchWin()
{
updateColorMenu();
buildFontMenu();
#ifdef HAVE_CMS
SoftProofing = doc->SoftProofing;
Gamut = doc->Gamut;
IntentPrinter = doc->IntentPrinter;
IntentMonitor = doc->IntentMonitor;
stdProofG = doc->stdProof;
stdTransG = doc->stdTrans;
stdProofImgG = doc->stdProofImg;
stdTransImgG = doc->stdTransImg;
stdProofCMYKG = doc->stdProofCMYK;
stdTransCMYKG = doc->stdTransCMYK;
stdTransRGBG = doc->stdTransRGB;
stdProofGCG = doc->stdProofGC;
stdProofCMYKGCG = doc->stdProofCMYKGC;
CMSoutputProf = doc->DocOutputProf;
CMSprinterProf = doc->DocPrinterProf;
CMSuse = doc->CMSSettings.CMSinUse;
#endif
propertiesPalette->updateColorList();
propertiesPalette->Cpal->ChooseGrad(0);
ActWin->setCaption(doc->DocName);
scrActions["shade100"]->setOn(true);
//ShadeMenu->setItemChecked(ShadeMenu->idAt(11), true);
propertiesPalette->setDoc(doc);
propertiesPalette->updateCList();
pagePalette->setView(view);
propertiesPalette->Spal->setFormats(doc);
propertiesPalette->SetLineFormats(doc);
propertiesPalette->startArrow->rebuildList(&doc->arrowStyles);
propertiesPalette->endArrow->rebuildList(&doc->arrowStyles);
FontSub->RebuildList(doc);
propertiesPalette->Fonts->RebuildList(doc);
layerPalette->setLayers(&doc->Layers, doc->activeLayer());
rebuildLayersList();
view->updateLayerMenu();
view->setLayerMenuText(doc->activeLayerName());
doc->currentParaStyle = 0;
slotChangeUnit(doc->unitIndex(), false);
if (doc->EditClip)
{
doc->EditClip = !doc->EditClip;
ToggleFrameEdit();
}
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["fileSave"]->setEnabled(doc->isModified());
scrActions["fileOpen"]->setEnabled(false);
scrActions["fileClose"]->setEnabled(false);
scrActions["fileRevert"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("FileOpenRecent", false);
pagePalette->enablePalette(false);
}
else
{
scrMenuMgr->setMenuEnabled("Page", true);
scrActions["editMasterPages"]->setEnabled(true);
scrActions["fileNew"]->setEnabled(true);
scrActions["fileOpen"]->setEnabled(true);
scrActions["fileClose"]->setEnabled(true);
scrActions["fileSave"]->setEnabled(doc->isModified());
//CB TODO Huh? Why different to the above?, fileMenu->setItemEnabled(M_FileSave, ActWin->MenuStat[2]);
scrActions["fileSaveAs"]->setEnabled(ActWin->menuStatus(3));
scrActions["fileCollect"]->setEnabled(ActWin->menuStatus(3));
scrActions["fileRevert"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("FileOpenRecent", true);
bool setter = doc->Pages->count() > 1 ? true : false;
scrActions["pageDelete"]->setEnabled(setter);
scrActions["pageMove"]->setEnabled(setter);
if (doc->isModified())
slotDocCh(false);
scrActions["fileSaveAs"]->setEnabled(true);
scrActions["fileCollect"]->setEnabled(true);
pagePalette->enablePalette(true);
}
}
void ScribusMainWindow::HaveNewDoc()
{
scrActions["filePrint"]->setEnabled(true);
scrActions["fileSave"]->setEnabled(false);
scrActions["fileClose"]->setEnabled(true);
scrActions["fileDocSetup"]->setEnabled(true);
scrActions["fileRevert"]->setEnabled(false);
scrActions["fileCollect"]->setEnabled(true);
scrActions["fileSaveAs"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("FileExport", true);
scrActions["fileExportAsEPS"]->setEnabled(true);
scrActions["fileExportAsPDF"]->setEnabled(true);
scrActions["pageImport"]->setEnabled(true);
//scrActions["toolsPreflightVerifier"]->setEnabled(true);
if (HaveGS==0)
scrActions["PrintPreview"]->setEnabled(true);
if (scrActions["SaveAsDocumentTemplate"])
scrActions["SaveAsDocumentTemplate"]->setEnabled(true);
scrActions["editCut"]->setEnabled(false);
scrActions["editCopy"]->setEnabled(false);
scrActions["editPaste"]->setEnabled(!Buffer2.isEmpty());
scrActions["editSelectAll"]->setEnabled(true);
scrActions["editDeselectAll"]->setEnabled(false);
scrActions["editParaStyles"]->setEnabled(true);
scrActions["editLineStyles"]->setEnabled(true);
scrActions["editMasterPages"]->setEnabled(true);
scrActions["editJavascripts"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("View", true);
scrActions["viewSnapToGrid"]->setOn(doc->useRaster);
scrActions["viewSnapToGuides"]->setOn(doc->SnapGuides);
scrMenuMgr->setMenuEnabled("Insert", true);
//scrMenuMgr->setMenuEnabled("Windows", true);
scrMenuMgr->setMenuEnabled("Page", true);
scrMenuMgr->setMenuEnabled("Extras", true);
mainToolBar->setEnabled(true);
pdfToolBar->setEnabled(true);
bool setter = doc->Pages->count() > 1 ? true : false;
scrActions["pageDelete"]->setEnabled(setter);
scrActions["pageMove"]->setEnabled(setter);
updateColorMenu();
//Update palettes
propertiesPalette->updateColorList();
propertiesPalette->Cpal->ChooseGrad(0);
ActWin->setCaption(doc->DocName);
scrActions["shade100"]->setOn(true);
propertiesPalette->setDoc(doc);
propertiesPalette->updateCList();
pagePalette->setView(view);
propertiesPalette->Spal->setFormats(doc);
propertiesPalette->SetLineFormats(doc);
propertiesPalette->startArrow->rebuildList(&doc->arrowStyles);
propertiesPalette->endArrow->rebuildList(&doc->arrowStyles);
layerPalette->setLayers(&doc->Layers, doc->activeLayer());
outlinePalette->setDoc(doc);
outlinePalette->BuildTree();
rebuildLayersList();
view->updateLayerMenu();
view->setLayerMenuText(doc->activeLayerName());
doc->currentParaStyle = 0;
slotChangeUnit(doc->unitIndex());
buildFontMenu();
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(setMousePositionOnStatusBar(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(NewBMNr(int, int)), bookmarkPalette->BView, SLOT(ChangeItem(int, int)));
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(setSvalue(double)));
connect(view, SIGNAL(SetLocalValues(double, double, double, double)), propertiesPalette, SLOT(setLvalue(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(ItemTextAttr(double)), propertiesPalette, SLOT(setLsp(double)));
connect(view, SIGNAL(ItemTextUSval(int)), propertiesPalette, SLOT(setExtra(int)));
// connect(view, SIGNAL(ItemTextCols(int, double)), propertiesPalette, SLOT(setCols(int, double)));
connect(view, SIGNAL(SetDistValues(double, double, double, double)), propertiesPalette, SLOT(setDvals(double, double, double, double)));
connect(view, SIGNAL(ItemTextAbs(int)), propertiesPalette, SLOT(setAli(int)));
connect(view, SIGNAL(ItemTextFont(QString)), this, SLOT(AdjustFontMenu(QString)));
connect(view, SIGNAL(ItemTextFont(QString)), propertiesPalette, SLOT(setFontFace(QString)));
connect(view, SIGNAL(ItemTextSize(int)), propertiesPalette, SLOT(setSize(int)));
//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(setMousePositionOnStatusBar(double, double)));
//connect(view, SIGNAL(ItemRadius(double)), propertiesPalette, SLOT(setRR(double)));
connect(view, SIGNAL(ItemTextStil(int)), propertiesPalette, SLOT(setStil(int)));
connect(view, SIGNAL(ItemTextSca(int)), propertiesPalette, SLOT(setTScale(int)));
connect(view, SIGNAL(ItemTextScaV(int)), propertiesPalette, SLOT(setTScaleV(int)));
connect(view, SIGNAL(ItemTextBase(int)), propertiesPalette, SLOT(setTBase(int)));
connect(view, SIGNAL(ItemTextShadow(int, int )), propertiesPalette, SLOT(setShadowOffs(int, int )));
connect(view, SIGNAL(ItemTextUnderline(int, int)), propertiesPalette, SLOT(setUnderline(int, int)));
connect(view, SIGNAL(ItemTextStrike(int, int)), propertiesPalette, SLOT(setStrike(int, int)));
connect(view, SIGNAL(ItemTextOutline(int)), propertiesPalette, SLOT(setOutlineW(int)));
connect(view, SIGNAL(ItemTextSize(int)), this, SLOT(setFSizeMenu(int)));
connect(view, SIGNAL(ItemTextStil(int)), this, SLOT(setStilvalue(int)));
connect(view, SIGNAL(ItemTextAbs(int)), this, SLOT(setAbsValue(int)));
connect(view, SIGNAL(ItemTextFarben(QString, QString, int, int)), propertiesPalette, SLOT(setActFarben(QString, QString, int, int)));
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(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(RasterPic(bool)), this, SLOT(HaveRaster(bool)));
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()));
connect(view, SIGNAL(UpdtObj(uint, uint)), outlinePalette, SLOT(slotUpdateElement(uint, uint)));
connect(view, SIGNAL(AddObj(PageItem *)), outlinePalette, SLOT(slotAddElement(PageItem *)));
/* if (!doc->masterPageMode)
{
connect(doc->currentPage, SIGNAL(DelObj(uint, uint)), outlinePalette, SLOT(slotRemoveElement(uint, uint)));
connect(doc->currentPage, SIGNAL(AddObj(uint, uint)), outlinePalette, SLOT(slotAddElement(uint, uint)));
connect(doc->currentPage, SIGNAL(UpdtObj(uint, uint)), outlinePalette, SLOT(slotUpdateElement(uint, uint)));
connect(doc->currentPage, SIGNAL(MoveObj(uint, uint, uint)), outlinePalette, SLOT(slotMoveElement(uint, uint, uint)));
} */
}
void ScribusMainWindow::HaveNewSel(int Nr)
{
PageItem *currItem = NULL;
if (Nr != -1)
{
if (doc->selection->count() != 0)
{
currItem = doc->selection->itemAt(0);
if (!currItem)
Nr=-1;
}
else
Nr = -1;
}
actionManager->disconnectNewSelectionActions();
scrActions["editDeselectAll"]->setEnabled(Nr!=-1);
scrActions["itemDetachTextFromPath"]->setEnabled(false);
scrActions["insertGlyph"]->setEnabled(false);
scrActions["itemImageIsVisible"]->setEnabled(Nr==PageItem::ImageFrame);
scrActions["itemUpdateImage"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail);
scrActions["itemAdjustFrameToImage"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail && !currItem->isTableItem);
scrActions["itemExtendedImageProperties"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail && currItem->pixm.imgInfo.valid);
scrActions["itemPreviewLow"]->setEnabled(Nr==PageItem::ImageFrame);
scrActions["itemPreviewNormal"]->setEnabled(Nr==PageItem::ImageFrame);
scrActions["itemPreviewFull"]->setEnabled(Nr==PageItem::ImageFrame);
scrActions["editEditWithImageEditor"]->setEnabled(Nr==PageItem::ImageFrame && currItem->PicAvail && currItem->isRaster);
if (Nr!=PageItem::ImageFrame)
{
scrActions["itemImageIsVisible"]->setOn(false);
scrActions["itemPreviewLow"]->setOn(false);
scrActions["itemPreviewNormal"]->setOn(false);
scrActions["itemPreviewFull"]->setOn(false);
}
if ((Nr==-1) || (Nr!=-1 && !currItem->asTextFrame()))
actionManager->enableUnicodeActions(false);
scrActions["insertSampleText"]->setEnabled(false);
view->horizRuler->ItemPosValid = false;
view->horizRuler->repaint();
switch (Nr)
{
case -1: // None
scrActions["fileImportText"]->setEnabled(false);
scrActions["fileImportImage"]->setEnabled(false);
scrActions["fileImportAppendText"]->setEnabled(false);
scrActions["fileExportText"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("Style", false);
scrMenuMgr->setMenuEnabled("Item", false);
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["itemLock"]->setEnabled(false);
scrActions["itemLockSize"]->setEnabled(false);
scrActions["editCut"]->setEnabled(false);
scrActions["editCopy"]->setEnabled(false);
scrActions["editClearContents"]->setEnabled(false);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["extrasHyphenateText"]->setEnabled(false);
scrActions["extrasDeHyphenateText"]->setEnabled(false);
scrMenuMgr->clearMenu("Style");
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);
break;
case PageItem::ImageFrame: //Image Frame
scrActions["fileImportAppendText"]->setEnabled(false);
scrActions["fileImportText"]->setEnabled(false);
scrActions["fileImportImage"]->setEnabled(true);
scrActions["editCut"]->setEnabled(true);
scrActions["editCopy"]->setEnabled(true);
scrActions["editClearContents"]->setEnabled(true);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["extrasHyphenateText"]->setEnabled(false);
scrActions["extrasDeHyphenateText"]->setEnabled(false);
scrMenuMgr->setMenuEnabled("Style", false);
scrMenuMgr->setMenuEnabled("Item", 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);
scrMenuMgr->clearMenu("Style");
// scrMenuMgr->addMenuToMenu("Color","Style");
// if (currItem->isRaster)
// scrMenuMgr->addMenuItem(scrActions["styleInvertPict"], "Style");
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"]->setOn(currItem->PicArt);
scrActions["itemPreviewLow"]->setOn(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewLow"]->actionInt());
scrActions["itemPreviewNormal"]->setOn(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewNormal"]->actionInt());
scrActions["itemPreviewFull"]->setOn(currItem->pixm.imgInfo.lowResType==scrActions["itemPreviewFull"]->actionInt());
break;
case PageItem::TextFrame: //Text Frame
scrActions["fileImportText"]->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(true);
scrActions["editSearchReplace"]->setEnabled(currItem->itemText.count() != 0);
scrActions["extrasHyphenateText"]->setEnabled(true);
scrActions["extrasDeHyphenateText"]->setEnabled(true);
scrMenuMgr->setMenuEnabled("Style", true);
scrMenuMgr->setMenuEnabled("Item", 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);
scrMenuMgr->clearMenu("Style");
scrMenuMgr->addMenuToMenu("Font","Style");
scrMenuMgr->addMenuToMenu("FontSize","Style");
scrMenuMgr->addMenuToMenu("TypeEffects","Style");
scrMenuMgr->addMenuToMenu("Alignment","Style");
scrMenuMgr->addMenuToMenu("Color","Style");
scrMenuMgr->addMenuToMenu("Shade","Style");
scrMenuMgr->addMenuItem(scrActions["styleTabulators"], "Style");
scrActions["toolsRotate"]->setEnabled(true);
scrActions["toolsCopyProperties"]->setEnabled(true);
scrActions["toolsEditWithStoryEditor"]->setEnabled(true);
scrActions["insertSampleText"]->setEnabled(true);
if ((currItem->NextBox != 0) || (currItem->BackBox != 0))
{
scrActions["toolsUnlinkTextFrame"]->setEnabled(true);
if ((currItem->BackBox != 0) && (currItem->itemText.count() == 0))
scrActions["toolsEditContents"]->setEnabled(false);
else
scrActions["toolsEditContents"]->setEnabled(true);
}
else
scrActions["toolsEditContents"]->setEnabled(true);
if (currItem->NextBox == 0)
scrActions["toolsLinkTextFrame"]->setEnabled(true);
if (doc->masterPageMode())
scrActions["toolsLinkTextFrame"]->setEnabled(false);
if (doc->appMode == modeEdit)
{
setTBvals(currItem);
scrActions["editSelectAll"]->setEnabled(true);
scrActions["insertGlyph"]->setEnabled(true);
if (currItem->asTextFrame())
actionManager->enableUnicodeActions(true);
view->horizRuler->setItemPosition(currItem->xPos(), currItem->width());
if (currItem->lineColor() != "None")
view->horizRuler->lineCorr = currItem->Pwidth / 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 = doc->docParagraphStyles[doc->currentParaStyle].First;
view->horizRuler->Indent = doc->docParagraphStyles[doc->currentParaStyle].Indent;
if (currItem->imageFlippedH() || (currItem->reversed()))
view->horizRuler->Revers = true;
else
view->horizRuler->Revers = false;
view->horizRuler->ItemPosValid = true;
if (doc->currentParaStyle < 5)
view->horizRuler->TabValues = currItem->TabValues;
else
view->horizRuler->TabValues = doc->docParagraphStyles[doc->currentParaStyle].TabValues;
view->horizRuler->repaint();
}
else
{
doc->CurrFont = currItem->font();
doc->CurrFontSize = currItem->fontSize();
doc->CurrTextFill = currItem->TxtFill;
doc->CurrTextStroke = currItem->TxtStroke;
doc->CurrTextStrokeSh = currItem->ShTxtStroke;
doc->CurrTextFillSh = currItem->ShTxtFill;
doc->CurrTextScale = currItem->TxtScale;
doc->CurrTextScaleV = currItem->TxtScaleV;
doc->CurrTextBase = currItem->TxtBase;
doc->CurrTextShadowX = currItem->TxtShadowX;
doc->CurrTextShadowY = currItem->TxtShadowY;
doc->CurrTextOutline = currItem->TxtOutline;
doc->CurrTextUnderPos = currItem->TxtUnderPos;
doc->CurrTextUnderWidth = currItem->TxtUnderWidth;
doc->CurrTextStrikePos = currItem->TxtStrikePos;
doc->CurrTextStrikeWidth = currItem->TxtStrikeWidth;
emit TextStrike(doc->CurrTextStrikePos, doc->CurrTextStrikeWidth);
emit TextUnderline(doc->CurrTextUnderPos, doc->CurrTextUnderWidth);
emit TextShadow(doc->CurrTextShadowX, doc->CurrTextShadowY);
emit TextFarben(doc->CurrTextStroke, doc->CurrTextFill, doc->CurrTextStrokeSh, doc->CurrTextFillSh);
doc->CurrentStyle = currItem->TxTStyle;
emit TextStil(doc->CurrentStyle);
emit TextScale(doc->CurrTextScale);
emit TextScaleV(doc->CurrTextScaleV);
emit TextBase(doc->CurrTextBase);
emit TextOutline(doc->CurrTextOutline);
setStilvalue(doc->CurrentStyle);
}
doc->docParagraphStyles[0].LineSpaMode = currItem->LineSpMode;
doc->docParagraphStyles[0].LineSpa = currItem->LineSp;
doc->docParagraphStyles[0].textAlignment = currItem->textAlignment;
break;
case PageItem::PathText: //Path Text
scrActions["fileImportText"]->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);
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);
scrMenuMgr->clearMenu("Style");
scrMenuMgr->setMenuEnabled("Style", true);
scrMenuMgr->addMenuToMenu("Font","Style");
scrMenuMgr->addMenuToMenu("FontSize","Style");
scrMenuMgr->addMenuToMenu("TypeEffects","Style");
scrMenuMgr->addMenuToMenu("Color","Style");
scrMenuMgr->addMenuToMenu("Shade","Style");
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->CurrFont = currItem->font();
doc->CurrFontSize = currItem->fontSize();
doc->CurrTextFill = currItem->TxtFill;
doc->CurrTextStroke = currItem->TxtStroke;
doc->CurrTextStrokeSh = currItem->ShTxtStroke;
doc->CurrTextFillSh = currItem->ShTxtFill;
doc->CurrTextScale = currItem->TxtScale;
doc->CurrTextScaleV = currItem->TxtScaleV;
doc->CurrTextBase = currItem->TxtBase;
doc->CurrTextShadowX = currItem->TxtShadowX;
doc->CurrTextShadowY = currItem->TxtShadowY;
doc->CurrTextOutline = currItem->TxtOutline;
doc->CurrTextUnderPos = currItem->TxtUnderPos;
doc->CurrTextUnderWidth = currItem->TxtUnderWidth;
doc->CurrTextStrikePos = currItem->TxtStrikePos;
doc->CurrTextStrikeWidth = currItem->TxtStrikeWidth;
emit TextStrike(doc->CurrTextStrikePos, doc->CurrTextStrikeWidth);
emit TextUnderline(doc->CurrTextUnderPos, doc->CurrTextUnderWidth);
emit TextShadow(doc->CurrTextShadowX, doc->CurrTextShadowY);
emit TextFarben(doc->CurrTextStroke, doc->CurrTextFill, doc->CurrTextStrokeSh, doc->CurrTextFillSh);
doc->CurrentStyle = currItem->TxTStyle;
emit TextStil(doc->CurrentStyle);
emit TextScale(doc->CurrTextScale);
emit TextScaleV(doc->CurrTextScaleV);
emit TextBase(doc->CurrTextBase);
emit TextOutline(doc->CurrTextOutline);
setStilvalue(doc->CurrentStyle);
}
break;
default:
scrActions["fileImportText"]->setEnabled(false);
scrActions["fileImportImage"]->setEnabled(false);
scrActions["fileImportAppendText"]->setEnabled(false);
scrActions["fileExportText"]->setEnabled(false);
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("Style", false);
scrMenuMgr->setMenuEnabled("Item", true);
scrMenuMgr->clearMenu("Style");
// scrMenuMgr->addMenuToMenu("Color","Style");
// scrMenuMgr->addMenuToMenu("Shade","Style");
if (Nr == 6) //Polygon
{
scrMenuMgr->setMenuEnabled("ItemShapes", true);
scrMenuMgr->setMenuEnabled("ItemConvertTo", true);
scrActions["itemConvertToBezierCurve"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToImageFrame"]->setEnabled(doc->appMode != modeEdit);
scrActions["itemConvertToOutlines"]->setEnabled(false);
scrActions["itemConvertToPolygon"]->setEnabled(false);
scrActions["itemConvertToTextFrame"]->setEnabled(doc->appMode != modeEdit);
}
scrActions["toolsEditContents"]->setEnabled(false);
scrActions["toolsEditWithStoryEditor"]->setEnabled(false);
scrActions["toolsUnlinkTextFrame"]->setEnabled(false);
scrActions["toolsLinkTextFrame"]->setEnabled(false);
if (Nr != 5)
scrActions["toolsRotate"]->setEnabled(true);
else
scrActions["toolsRotate"]->setEnabled(false);
scrActions["toolsCopyProperties"]->setEnabled(true);
break;
}
doc->CurrentSel = Nr;
propertiesPalette->RotationGroup->setButton(doc->RotMode);
uint docSelectionCount=doc->selection->count();
if (docSelectionCount > 1)
{
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 = true;
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->selection->itemAt(bx);
if (!bxi->asPolygon())
hPoly = false;
if (bxi->Groups.count() != 0)
{
if (bxi->Groups.top() != firstElem)
isGroup = false;
}
else
isGroup = false;
}
scrActions["itemGroup"]->setEnabled(!isGroup);
scrActions["itemCombinePolygons"]->setEnabled(hPoly);
if (docSelectionCount == 2)
{
PageItem* bx=doc->selection->itemAt(1);
if (((currItem->itemType() == PageItem::TextFrame) || (bx->itemType() == PageItem::TextFrame)) && ((currItem->itemType() == PageItem::PolyLine) || (bx->itemType() == PageItem::PolyLine)))
{
if ((currItem->NextBox == 0) && (currItem->BackBox == 0) && (bx->NextBox == 0) && (bx->BackBox == 0) && (currItem->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());
scrActions["itemLock"]->setEnabled(true);
scrActions["itemLockSize"]->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);
scrActions["itemLowerToBottom"]->setEnabled(false);
scrActions["itemRaiseToTop"]->setEnabled(false);
scrActions["itemRaise"]->setEnabled(false);
scrActions["itemLower"]->setEnabled(false);
scrActions["itemSendToScrapbook"]->setEnabled(false);
scrActions["editCut"]->setEnabled(false);
scrActions["editClearContents"]->setEnabled(false);
scrActions["toolsRotate"]->setEnabled(false);
}
else
{
bool setter=!(currItem->isTableItem && currItem->isSingleSel);
scrActions["itemDuplicate"]->setEnabled(setter);
scrActions["itemMulDuplicate"]->setEnabled(setter);
scrActions["itemDelete"]->setEnabled(setter);
scrActions["itemLowerToBottom"]->setEnabled(setter);
scrActions["itemRaiseToTop"]->setEnabled(setter);
scrActions["itemRaise"]->setEnabled(setter);
scrActions["itemLower"]->setEnabled(setter);
scrActions["itemSendToScrapbook"]->setEnabled(setter);
}
scrActions["itemLock"]->setOn(currItem->locked());
scrActions["itemLockSize"]->setOn(currItem->sizeLocked());
}
//propertiesPalette->NewSel(Nr);
if (Nr != -1)
{
//propertiesPalette->SetCurItem(currItem);
outlinePalette->slotShowSelect(currItem->OwnPage, currItem->ItemNr);
if (currItem->FrameType == 0)
SCustom->setPixmap(SCustom->getIconPixmap(0));
if (currItem->FrameType == 1)
SCustom->setPixmap(SCustom->getIconPixmap(1));
if (currItem->FrameType > 3)
SCustom->setPixmap(SCustom->getIconPixmap(currItem->FrameType-2));
actionManager->connectNewSelectionActions(view);
}
else
propertiesPalette->NewSel(Nr);
}
void ScribusMainWindow::slotDocCh(bool /*reb*/)
{
/* if ((reb) && (!doc->masterPageMode) && (view->SelItem.count() != 0))
{
for (uint upd = 0; upd < view->SelItem.count(); ++upd)
outlinePalette->slotUpdateElement(doc->currentPage->PageNr, view->SelItem.at(upd)->ItemNr);
} */
if (!doc->isLoading() && docCheckerPalette->isVisible())
{
scanDocument();
docCheckerPalette->buildErrorList(doc);
}
if (!doc->isModified())
doc->setModified(true);
ActWin->setCaption( 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);
}
ActWin->setMenuStatus(0, scrActions["fileSave"]->isEnabled());
ActWin->setMenuStatus(1, scrActions["fileClose"]->isEnabled());
ActWin->setMenuStatus(2, scrActions["fileSave"]->isEnabled());
ActWin->setMenuStatus(3, scrActions["fileSaveAs"]->isEnabled());
}
void ScribusMainWindow::updateRecent(QString fn)
{
if (RecentDocs.findIndex(fn) == -1)
{
RecentDocs.prepend(fn);
fileWatcher->addFile(fn);
}
else
{
RecentDocs.remove(fn);
RecentDocs.prepend(fn);
}
rebuildRecentFileMenu();
}
void ScribusMainWindow::removeRecent(QString fn)
{
if (RecentDocs.findIndex(fn) != -1)
{
RecentDocs.remove(fn);
if (!fileWatcher->isActive())
fileWatcher->removeFile(fn);
}
rebuildRecentFileMenu();
}
void ScribusMainWindow::loadRecent(QString fn)
{
QFileInfo fd(fn);
if (!fd.exists())
{
RecentDocs.remove(fn);
fileWatcher->removeFile(fn);
rebuildRecentFileMenu();
return;
}
loadDoc(fn);
}
void ScribusMainWindow::rebuildRecentFileMenu()
{
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrRecentFileActions.begin(); it!=scrRecentFileActions.end(); ++it )
scrMenuMgr->removeMenuItem((*it), recentFileMenuName);
scrRecentFileActions.clear();
uint max = QMIN(prefsManager->appPrefs.RecentDCount, RecentDocs.count());
for (uint m = 0; m < max; ++m)
{
QString strippedName=RecentDocs[m];
strippedName.remove(QDir::separator());
scrRecentFileActions.insert(strippedName, new ScrAction( ScrAction::RecentFile, QIconSet(), RecentDocs[m], QKeySequence(), this, strippedName));
connect( scrRecentFileActions[strippedName], SIGNAL(activatedData(QString)), this, SLOT(loadRecent(QString)) );
scrMenuMgr->addMenuItem(scrRecentFileActions[strippedName], recentFileMenuName);
}
}
void ScribusMainWindow::rebuildLayersList()
{
if (HaveDoc)
{
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it0 = scrLayersActions.begin(); it0 != scrLayersActions.end(); ++it0 )
scrMenuMgr->removeMenuItem((*it0), layerMenuName);
scrLayersActions.clear();
QValueList<Layer>::iterator it;
if (doc->Layers.count()!= 0)
{
for (it = doc->Layers.begin(); it != doc->Layers.end(); ++it)
{
scrLayersActions.insert(QString("%1").arg((*it).LNr), new ScrAction( ScrAction::Layer, QIconSet(), (*it).Name, QKeySequence(), this, (*it).Name, (*it).LNr));
scrLayersActions[QString("%1").arg((*it).LNr)]->setToggleAction(true);
}
}
int currActiveLayer=doc->activeLayer();
bool found=false;
for (it = doc->Layers.begin(); it != doc->Layers.end(); ++it)
{
if ((*it).LNr == currActiveLayer)
{
found=true;
break;
}
}
Q_ASSERT(found);
scrLayersActions[QString("%1").arg((*it).LNr)]->setOn(true);
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=scrLayersActions.end(); ++it )
{
scrMenuMgr->addMenuItem((*it), layerMenuName);
connect( (*it), SIGNAL(activatedData(int)), this, SLOT(sendToLayer(int)) );
}
}
}
void ScribusMainWindow::updateItemLayerList()
{
if (HaveDoc)
{
QMap<QString, QGuardedPtr<ScrAction> >::Iterator itend=scrLayersActions.end();
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=itend; ++it )
{
disconnect( (*it), SIGNAL(activatedData(int)), 0, 0 );
(*it)->setOn(false);
}
if (doc->selection->count()>0 && doc->selection->itemAt(0))
scrLayersActions[QString("%1").arg(doc->selection->itemAt(0)->LayerNr)]->setOn(true);
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=itend; ++it )
connect( (*it), SIGNAL(activatedData(int)), this, SLOT(sendToLayer(int)) );
}
}
void ScribusMainWindow::sendToLayer(int layerNumber)
{
if (HaveDoc)
{
uint docSelectionCount=doc->selection->count();
if (docSelectionCount != 0)
{
if (UndoManager::undoEnabled() && docSelectionCount > 1)
undoManager->beginTransaction();
QString tooltip = Um::ItemsInvolved + "\n";
for (uint a = 0; a < docSelectionCount; ++a)
{
PageItem *currItem = doc->selection->itemAt(a);
currItem->setLayer(layerNumber);
tooltip += "\t" + currItem->getUName() + "\n";
}
if (UndoManager::undoEnabled() && docSelectionCount > 1)
undoManager->commit(Um::Selection,
Um::IGroup,
Um::SendToLayer,
tooltip,
Um::ILayerAction);
}
view->Deselect(true);
view->updateContents();
slotDocCh();
}
}
bool ScribusMainWindow::slotDocOpen()
{
PrefsContext* docContext = prefsManager->prefsFile->getContext("docdirs", false);
QString docDir = ".";
QString prefsDocDir=prefsManager->documentDir();
if (!prefsDocDir.isEmpty())
docDir = docContext->get("docsopen", prefsDocDir);
else
docDir = docContext->get("docsopen", ".");
QString formats(FileLoader::getLoadFilterString());
QString fileName = CFileDialog( docDir, tr("Open"), formats);
if (fileName.isEmpty())
// User cancelled
return false;
docContext->set("docsopen", fileName.left(fileName.findRev("/")));
bool ret = loadDoc(fileName);
return ret;
}
bool ScribusMainWindow::slotPageImport()
{
Q_ASSERT(!doc->masterPageMode());
bool ret = false;
MergeDoc *dia = new MergeDoc(this, false, doc->DocPages.count(), doc->currentPage->pageNr() + 1);
if (dia->exec())
{
mainWindowStatusLabel->setText( tr("Importing Pages..."));
qApp->setOverrideCursor(QCursor(waitCursor), true);
std::vector<int> pageNs;
parsePagesString(dia->getPageNumbers(), &pageNs, dia->getPageCounter());
int startPage, nrToImport;
bool doIt = true;
if (doc->masterPageMode())
{
if (pageNs.size() > 1)
loadPage(dia->getFromDoc(), pageNs[0] - 1, false);
doIt = false;
}
else if (dia->getCreatePageChecked())
{
int importWhere=dia->getImportWhere();
if (importWhere == 0)
startPage = dia->getImportWherePage();
else if (importWhere == 1)
startPage = dia->getImportWherePage() + 1;
else
startPage = doc->DocPages.count() + 1;
addNewPages(dia->getImportWherePage(), importWhere, pageNs.size(), doc->pageHeight, doc->pageWidth, doc->PageOri, doc->PageSize, true);
nrToImport = pageNs.size();
}
else
{
startPage = doc->currentPage->pageNr() + 1;
nrToImport = pageNs.size();
if (pageNs.size() > (doc->DocPages.count() - doc->currentPage->pageNr()))
{
qApp->setOverrideCursor(QCursor(arrowCursor), true);
int scmReturn=ScMessageBox::information(this, tr("Import Page(s)"), "<qt>" +
QObject::tr("<p>You are trying to import more pages than there are available in the current document counting from the active page.</p>Choose one of the following:<br>"
"<ul><li><b>Create</b> missing pages</li>"
"<li><b>Import</b> pages until the last page</li>"
"<li><b>Cancel</b></li></ul>") + "</qt>",
QObject::tr("C&reate"),
QObject::tr("&Import"),
CommonStrings::tr_Cancel, 2, 2);
switch( scmReturn )
{
case 0:
nrToImport = pageNs.size();
addNewPages(doc->DocPages.count(), 2, pageNs.size() - (doc->DocPages.count() - doc->currentPage->pageNr()), doc->pageHeight, doc->pageWidth, doc->PageOri, doc->PageSize, true);
break;
case 1:
nrToImport = doc->DocPages.count() - doc->currentPage->pageNr();
break;
case 2:
doIt = false;
mainWindowStatusLabel->setText("");
break;
}
qApp->setOverrideCursor(QCursor(waitCursor), true);
}
}
if (doIt)
{
if (nrToImport > 0)
{
mainWindowProgressBar->reset();
mainWindowProgressBar->setTotalSteps(nrToImport);
int counter = startPage;
for (int i = 0; i < nrToImport; ++i)
{
view->GotoPa(counter);
loadPage(dia->getFromDoc(), pageNs[i] - 1, false);
counter++;
mainWindowProgressBar->setProgress(i + 1);
}
view->GotoPa(startPage);
mainWindowProgressBar->reset();
mainWindowStatusLabel->setText( tr("Import done"));
}
else
{
mainWindowStatusLabel->setText( tr("Found nothing to import"));
doIt = false;
}
}
qApp->setOverrideCursor(QCursor(arrowCursor), true);
ret = doIt;
}
delete dia;
return ret;
}
bool ScribusMainWindow::loadPage(QString fileName, int Nr, bool Mpa)
{
bool ret = false;
if (!fileName.isEmpty())
{
if (!Mpa)
doc->OpenNodes = outlinePalette->buildReopenVals();
FileLoader *fl = new FileLoader(fileName);
if (fl->TestFile() == -1)
{
delete fl;
return false;
}
doc->setLoading(true);
uint oldItemsCount = doc->Items->count();
if(!fl->LoadPage(Nr, Mpa))
{
delete fl;
doc->setLoading(false);
return false;
}
delete fl;
if (CMSavail && doc->CMSSettings.CMSinUse)
{
recalcColors();
doc->RecalcPictures(&InputProfiles, &InputProfilesCMYK);
}
uint docItemsCount=doc->Items->count();
for (uint i = oldItemsCount; i < docItemsCount; ++i)
{
PageItem *ite = doc->Items->at(i);
if ((ite->asTextFrame()) && (ite->isBookmark))
bookmarkPalette->BView->AddPageItem(ite);
}
propertiesPalette->updateColorList();
propertiesPalette->updateCList();
propertiesPalette->Spal->setFormats(doc);
propertiesPalette->SetLineFormats(doc);
propertiesPalette->startArrow->rebuildList(&doc->arrowStyles);
propertiesPalette->endArrow->rebuildList(&doc->arrowStyles);
if (!Mpa)
{
outlinePalette->BuildTree();
outlinePalette->reopenTree(doc->OpenNodes);
scanDocument();
docCheckerPalette->buildErrorList(doc);
}
slotDocCh();
rebuildLayersList();
view->updateLayerMenu();
layerPalette->rebuildList();
doc->setLoading(false);
ret = true;
}
if (!Mpa)
pagePalette->Rebuild();
view->reformPages();
view->DrawNew();
return ret;
}
bool ScribusMainWindow::loadDoc(QString fileName)
{
undoManager->setUndoEnabled(false);
QFileInfo fi(fileName);
if (!fi.exists())
return false;
qApp->setOverrideCursor(QCursor(waitCursor), true);
/* if (HaveDoc)
doc->OpenNodes = outlinePalette->buildReopenVals(); */
bool ret = false;
QWidgetList windows = wsp->windowList();
ScribusWin* ActWinOld = NULL;
if (windows.count() != 0)
ActWinOld = ActWin;
bool found = false;
uint id = 0;
uint windowCount=windows.count();
for ( uint i = 0; i < windowCount; ++i )
{
if (windows.at(i)->caption() == fileName)
{
found = true;
id = i;
break;
}
}
if (found)
{
windowsMenuActivated(id);
return true;
}
if (!fileName.isEmpty())
{
QString FName = fi.absFilePath();
QString DPath = fi.dirPath(true);
// Necessary on win32 platform for setCurrent() to succeed
// if document is located at drive root
if( !DPath.endsWith("/") )
DPath += "/";
QDir::setCurrent(DPath);
FileLoader *fileLoader = new FileLoader(FName);
if (fileLoader->TestFile() == -1)
{
delete fileLoader;
qApp->setOverrideCursor(QCursor(arrowCursor), true);
QMessageBox::critical(this, tr("Fatal Error"), "<qt>"+tr("File %1 is not in an acceptable format").arg(FName)+"</qt>", CommonStrings::tr_OK);
return false;
}
bool is12doc=false;
if (fileLoader->TestFile() == 0)
{
qApp->setOverrideCursor(QCursor(arrowCursor), true);
//Scribus 1.3.x warning, remove at a later stage
is12doc=true;
}
prefsManager->appPrefs.AvailFonts.AddScalableFonts(fi.dirPath(true)+"/", FName);
prefsManager->appPrefs.AvailFonts.updateFontMap();
doc=new ScribusDoc();
doc->is12doc=is12doc;
doc->appMode = modeNormal;
doc->HasCMS = false;
//doc->setActiveLayer(0); //CB should not need this, the file load process sets it to ALAYER from the doc
doc->OpenNodes.clear();
doc->setLoading(true);
mainWindowStatusLabel->setText( tr("Loading..."));
mainWindowProgressBar->reset();
ScribusWin* w = new ScribusWin(wsp, doc);
view = new ScribusView(w, doc);
view->setScale(prefsManager->displayScale());
w->setView(view);
alignDistributePalette->setView(view);
ActWin = w;
doc->WinHan = w;
w->setCentralWidget(view);
w->setUpdatesEnabled(false);
view->setUpdatesEnabled(false);
#ifdef HAVE_CMS
doc->SoftProofing = false;
doc->Gamut = false;
bool cmsu = CMSuse;
CMSuse = false;
#endif
ScMW->ScriptRunning = true;
bool loadSuccess=fileLoader->LoadFile();
//Do the font replacement check from here, when we have a GUI. TODO do this also somehow without the GUI
//This also gives the user the opportunity to cancel the load when finding theres a replacement required.
if (loadSuccess && ScQApp->usingGUI())
loadSuccess=fileLoader->postLoad(is12doc);
if(!loadSuccess)
{
view->close();
delete fileLoader;
delete view;
delete doc;
delete w;
ScMW->ScriptRunning = false;
mainWindowStatusLabel->setText("");
mainWindowProgressBar->reset();
ActWin = NULL;
if (windows.count() != 0)
newActWin(ActWinOld);
return false;
}
fileLoader->informReplacementFonts();
view->unitSwitcher->setCurrentText(unitGetStrFromIndex(doc->unitIndex()));
view->unitChange();
ScMW->ScriptRunning = false;
view->Deselect(true);
mainWindowStatusLabel->setText("");
mainWindowProgressBar->reset();
#ifdef HAVE_CMS
CMSuse = cmsu;
#endif
HaveDoc++;
if (doc->checkerProfiles.count() == 0)
{
prefsManager->initDefaultCheckerPrefs(&doc->checkerProfiles);
doc->curCheckProfile = tr("PostScript");
}
if (doc->PDF_Options.LPISettings.count() == 0)
{
struct LPIData lpo;
lpo.Frequency = 75;
lpo.SpotFunc = 2;
lpo.Angle = 105;
doc->PDF_Options.LPISettings.insert("Cyan", lpo);
lpo.Angle = 75;
doc->PDF_Options.LPISettings.insert("Magenta", lpo);
lpo.Angle = 90;
doc->PDF_Options.LPISettings.insert("Yellow", lpo);
lpo.Angle = 45;
doc->PDF_Options.LPISettings.insert("Black", lpo);
}
//connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
if (!doc->HasCMS)
{
doc->CMSSettings.DefaultImageRGBProfile = prefsManager->appPrefs.DCMSset.DefaultImageRGBProfile;
doc->CMSSettings.DefaultImageCMYKProfile = prefsManager->appPrefs.DCMSset.DefaultImageCMYKProfile;
doc->CMSSettings.DefaultSolidColorProfile = prefsManager->appPrefs.DCMSset.DefaultSolidColorProfile;
doc->CMSSettings.DefaultMonitorProfile = prefsManager->appPrefs.DCMSset.DefaultMonitorProfile;
doc->CMSSettings.DefaultPrinterProfile = prefsManager->appPrefs.DCMSset.DefaultPrinterProfile;
doc->CMSSettings.DefaultIntentPrinter = prefsManager->appPrefs.DCMSset.DefaultIntentPrinter;
doc->CMSSettings.DefaultIntentMonitor = prefsManager->appPrefs.DCMSset.DefaultIntentMonitor;
doc->CMSSettings.DefaultIntentImages = prefsManager->appPrefs.DCMSset.DefaultIntentImages;
doc->CMSSettings.SoftProofOn = prefsManager->appPrefs.DCMSset.SoftProofOn;
doc->CMSSettings.GamutCheck = prefsManager->appPrefs.DCMSset.GamutCheck;
doc->CMSSettings.BlackPoint = prefsManager->appPrefs.DCMSset.BlackPoint;
doc->CMSSettings.CMSinUse = false;
}
if ((CMSavail) && (doc->CMSSettings.CMSinUse))
{
bool cmsWarning = false;
QStringList missing;
QStringList replacement;
if (!InputProfiles.contains(doc->CMSSettings.DefaultImageRGBProfile))
{
cmsWarning = true;
missing.append(doc->CMSSettings.DefaultImageRGBProfile);
replacement.append(prefsManager->appPrefs.DCMSset.DefaultImageRGBProfile);
doc->CMSSettings.DefaultImageRGBProfile = prefsManager->appPrefs.DCMSset.DefaultImageRGBProfile;
}
if (!InputProfiles.contains(doc->CMSSettings.DefaultSolidColorProfile))
{
cmsWarning = true;
missing.append(doc->CMSSettings.DefaultSolidColorProfile);
replacement.append(prefsManager->appPrefs.DCMSset.DefaultSolidColorProfile);
doc->CMSSettings.DefaultSolidColorProfile = prefsManager->appPrefs.DCMSset.DefaultSolidColorProfile;
}
if (!MonitorProfiles.contains(doc->CMSSettings.DefaultMonitorProfile))
{
cmsWarning = true;
missing.append(doc->CMSSettings.DefaultMonitorProfile);
replacement.append(prefsManager->appPrefs.DCMSset.DefaultMonitorProfile);
doc->CMSSettings.DefaultMonitorProfile = prefsManager->appPrefs.DCMSset.DefaultMonitorProfile;
}
if (!PrinterProfiles.contains(doc->CMSSettings.DefaultPrinterProfile))
{
cmsWarning = true;
missing.append(doc->CMSSettings.DefaultPrinterProfile);
replacement.append(prefsManager->appPrefs.DCMSset.DefaultPrinterProfile);
doc->CMSSettings.DefaultPrinterProfile = prefsManager->appPrefs.DCMSset.DefaultPrinterProfile;
}
if (!PrinterProfiles.contains(doc->PDF_Options.PrintProf))
{
cmsWarning = true;
missing.append(doc->PDF_Options.PrintProf);
replacement.append(prefsManager->appPrefs.DCMSset.DefaultPrinterProfile);
doc->PDF_Options.PrintProf = doc->CMSSettings.DefaultPrinterProfile;
}
if (!InputProfiles.contains(doc->PDF_Options.ImageProf))
{
cmsWarning = true;
missing.append(doc->PDF_Options.ImageProf);
replacement.append(prefsManager->appPrefs.DCMSset.DefaultImageRGBProfile);
doc->PDF_Options.ImageProf = doc->CMSSettings.DefaultImageRGBProfile;
}
if (!InputProfiles.contains(doc->PDF_Options.SolidProf))
{
cmsWarning = true;
missing.append(doc->PDF_Options.SolidProf);
replacement.append(prefsManager->appPrefs.DCMSset.DefaultSolidColorProfile);
doc->PDF_Options.SolidProf = doc->CMSSettings.DefaultSolidColorProfile;
}
if ((cmsWarning) && (doc->HasCMS))
{
qApp->setOverrideCursor(QCursor(arrowCursor), true);
QString mess = tr("Some ICC profiles used by this document are not installed:")+"\n\n";
for (uint m = 0; m < missing.count(); ++m)
{
mess += missing[m] + tr(" was replaced by: ")+replacement[m]+"\n";
}
QMessageBox::warning(this, CommonStrings::trWarning, mess, 1, 0, 0);
}
#ifdef HAVE_CMS
doc->SoftProofing = doc->CMSSettings.SoftProofOn;
doc->Gamut = doc->CMSSettings.GamutCheck;
CMSuse = doc->CMSSettings.CMSinUse;
doc->IntentPrinter = doc->CMSSettings.DefaultIntentPrinter;
doc->IntentMonitor = doc->CMSSettings.DefaultIntentMonitor;
SoftProofing = doc->CMSSettings.SoftProofOn;
Gamut = doc->CMSSettings.GamutCheck;
IntentPrinter = doc->CMSSettings.DefaultIntentPrinter;
IntentMonitor = doc->CMSSettings.DefaultIntentMonitor;
doc->OpenCMSProfiles(InputProfiles, MonitorProfiles, PrinterProfiles);
CMSuse = doc->CMSSettings.CMSinUse;
stdProofG = doc->stdProof;
stdTransG = doc->stdTrans;
stdProofImgG = doc->stdProofImg;
stdTransImgG = doc->stdTransImg;
stdProofCMYKG = doc->stdProofCMYK;
stdTransCMYKG = doc->stdTransCMYK;
stdTransRGBG = doc->stdTransRGB;
stdProofGCG = doc->stdProofGC;
stdProofCMYKGCG = doc->stdProofCMYKGC;
CMSoutputProf = doc->DocOutputProf;
CMSprinterProf = doc->DocPrinterProf;
if (static_cast<int>(cmsGetColorSpace(doc->DocInputProf)) == icSigRgbData)
doc->CMSSettings.ComponentsInput2 = 3;
if (static_cast<int>(cmsGetColorSpace(doc->DocInputProf)) == icSigCmykData)
doc->CMSSettings.ComponentsInput2 = 4;
if (static_cast<int>(cmsGetColorSpace(doc->DocInputProf)) == icSigCmyData)
doc->CMSSettings.ComponentsInput2 = 3;
if (static_cast<int>(cmsGetColorSpace(doc->DocPrinterProf)) == icSigRgbData)
doc->CMSSettings.ComponentsPrinter = 3;
if (static_cast<int>(cmsGetColorSpace(doc->DocPrinterProf)) == icSigCmykData)
doc->CMSSettings.ComponentsPrinter = 4;
if (static_cast<int>(cmsGetColorSpace(doc->DocPrinterProf)) == icSigCmyData)
doc->CMSSettings.ComponentsPrinter = 3;
doc->PDF_Options.SComp = doc->CMSSettings.ComponentsInput2;
#endif
if (doc->CMSSettings.CMSinUse)
{
recalcColors();
doc->RecalcPictures(&InputProfiles, &InputProfilesCMYK);
}
}
else
{
doc->CMSSettings.CMSinUse = false;
#ifdef HAVE_CMS
CMSuse = doc->CMSSettings.CMSinUse;
#endif
}
propertiesPalette->updateColorList();
propertiesPalette->Cpal->ChooseGrad(0);
if (fileLoader->FileType > 1)
{
doc->setName(FName+tr("(converted)"));
QFileInfo fi(doc->DocName);
doc->setName(fi.fileName());
}
else
doc->setName(FName);
doc->setMasterPageMode(false);
doc->Language = GetLang(doc->Language);
HaveNewDoc();
propertiesPalette->updateCList();
doc->hasName = true;
if (doc->MasterPages.count() == 0)
doc->addMasterPage(0, "Normal");
//Add doc sections if we have none
if (doc->sections.count()==0)
{
doc->addSection(-1);
doc->setFirstSectionFromFirstPageNumber();
}
doc->setLoading(false);
doc->RePos = true;
QPixmap pgPix(10, 10);
QRect rd = QRect(0,0,9,9);
ScPainter *painter = new ScPainter(&pgPix, pgPix.width(), pgPix.height());
doc->setMasterPageMode(true);
for (uint azz=0; azz<doc->MasterItems.count(); ++azz)
{
PageItem *ite = doc->MasterItems.at(azz);
// TODO fix that for Groups on Masterpages
// if (ite->Groups.count() != 0)
// view->GroupOnPage(ite);
if ((ite->asTextFrame()) || (ite->asPathText()))
{
if (ite->asPathText())
{
ite->Frame = true;
ite->UpdatePolyClip();
}
else
{
if ((ite->BackBox != 0) || (ite->NextBox != 0))
{
PageItem *nextItem = ite;
while (nextItem != 0)
{
if (nextItem->BackBox != 0)
nextItem = nextItem->BackBox;
else
break;
}
ite = nextItem;
}
}
ite->DrawObj(painter, rd);
}
}
// RestoreBookMarks();
doc->setMasterPageMode(false);
uint docItemsCount=doc->Items->count();
for (uint azz=0; azz<docItemsCount; ++azz)
{
PageItem *ite = doc->Items->at(azz);
//CB dont need this as we get it from the loading page in 1.2.x docs. 1.3.x items have this anyway.
/*
if (ite->Groups.count() != 0)
doc->GroupOnPage(ite);
else
ite->OwnPage = doc->OnPage(ite);
*/
//view->setRedrawBounding(ite);
if ((ite->itemType() == PageItem::TextFrame) || (ite->itemType() == PageItem::PathText) && (!ite->Redrawn))
{
if (ite->itemType() == PageItem::PathText)
{
ite->Frame = true;
ite->UpdatePolyClip();
ite->DrawObj(painter, rd);
}
else
{
if ((ite->BackBox != 0) || (ite->NextBox != 0))
{
PageItem *nextItem = ite;
while (nextItem != 0)
{
if (nextItem->BackBox != 0)
nextItem = nextItem->BackBox;