Rev 2187 |
Rev 2193 |
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 <dlfcn.h>
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include <string>
#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 "align.h"
#include "fmitem.h"
#include "fontprefs.h"
#include "prefs.h"
#include "prefstable.h"
#include "pdfopts.h"
#include "inspage.h"
#include "delpages.h"
#include "movepage.h"
#include "helpbrowser.h"
#include "scribusXml.h"
#include "about.h"
#include "libpostscript/pslib.h"
#include "druck.h"
#include "editformats.h"
#include "muster.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 "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 "tocindexprefs.h"
#ifdef _MSC_VER
#if (_MSC_VER >= 1200)
#include "win-config.h"
#endif
#else
#include "config.h"
#endif
#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 "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"
//CB TODO include for toc testing for now
#include "gtwriter.h"
//CB
extern QPixmap loadIcon(QString nam);
extern bool overwrite(QWidget *parent, QString filename);
extern void CopyPageItem(struct CopyPasteBuffer *Buffer, PageItem *currItem);
extern void ReOrderText(ScribusDoc *doc, ScribusView *view);
extern int copyFile(QString source, QString target);
extern int moveFile(QString source, QString target);
using namespace std;
#ifdef HAVE_CMS
cmsHPROFILE CMSoutputProf;
cmsHPROFILE CMSprinterProf;
cmsHTRANSFORM stdTransG;
cmsHTRANSFORM stdProofG;
cmsHTRANSFORM stdTransImgG;
cmsHTRANSFORM stdProofImgG;
cmsHTRANSFORM stdTransCMYKG;
cmsHTRANSFORM stdProofCMYKG;
cmsHTRANSFORM stdTransRGBG;
bool BlackPoint;
bool SoftProofing;
bool Gamut;
bool CMSuse;
int IntentMonitor;
int IntentPrinter;
#endif
bool CMSavail;
ProfilesL InputProfiles;
QString DocDir;
ScribusApp* ScApp;
ScribusQApp* ScQApp;
PrefsFile* prefsFile;
ScribusApp::ScribusApp()
{
actionManager=NULL;
scrMenuMgr=NULL;
} // ScribusApp::ScribusApp()
/*
* retval 0 - ok, 1 - no fonts, ...
*/
int ScribusApp::initScribus(bool showSplash, const QString newGuiLanguage)
{
int retVal=0;
ExternalApp = 0;
guiLanguage = newGuiLanguage;
initSplash(showSplash);
setUsesBigPixmaps(true);
ScApp = this;
ScQApp = (ScribusQApp*)qApp;
CurrStED = NULL;
setCaption( tr("Scribus " VERSION));
setKeyCompression(false);
setIcon(loadIcon("AppIcon.png"));
scrActionGroups.clear();
scrActionGroups.setAutoDelete(true);
scrActions.clear();
scrRecentFileActions.clear();
scrWindowsActions.clear();
scrMenuMgr = new MenuManager(this->menuBar());
PrefsPfad = getPreferencesLocation();
bool importingFrom12=convert12Preferences(PrefsPfad);
prefsFile = new PrefsFile(QDir::convertSeparators(PrefsPfad + "/prefs13.xml"));
undoManager = UndoManager::instance();
objectSpecificUndo = false;
pluginManager = new PluginManager();
initDefaultValues();
actionManager = new ActionManager(this, "actionManager");
initMenuBar();
initStatusBar();
initToolBars();
qApp->processEvents();
BuFromApp = false;
initFonts();
if (NoFonts)
retVal=1;
else
{
buildFontMenu();
initDefaultPrefs();
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 *)));
initPalettes();
fileWatcher = new FileWatcher(this);
if (splashScreen != NULL)
splashScreen->setStatus( tr("Initializing Plugins"));
qApp->processEvents();
pluginManager->initPlugs();
initKeyboardShortcuts();
if (splashScreen != NULL)
splashScreen->setStatus( tr("Reading Preferences"));
qApp->processEvents();
//<<CB TODO Reset keyboard shortcuts of all 1.3 users as too many
// have conflicts if they dont nuke their settings. muhahahhaha
importingFrom12=true;
//>>CB
ReadPrefs(importingFrom12);
HaveGS = system(Prefs.gs_exe+" -h > /dev/null 2>&1");
HavePngAlpha = system(Prefs.gs_exe+" -sDEVICE=pngalpha -c quit > /dev/null 2>&1");
DocDir = Prefs.DocDir;
if (splashScreen != NULL)
splashScreen->setStatus( tr("Reading ICC Profiles"));
CMSavail = false;
GetCMSProfiles();
initCMS();
if (splashScreen != NULL)
splashScreen->setStatus( tr("Initializing Hyphenator"));
qApp->processEvents();
initHyphenator();
if (splashScreen != NULL)
splashScreen->setStatus( tr("Reading Scrapbook"));
initScrapbook();
if (splashScreen != NULL)
splashScreen->setStatus( tr("Setting up Shortcuts"));
qApp->processEvents();
SetShortCut();
emit prefsChanged();
connect(fileWatcher, SIGNAL(fileDeleted(QString )), this, SLOT(removeRecent(QString)));
connect(this, SIGNAL(TextIFont(QString)), this, SLOT(AdjustFontMenu(QString)));
connect(this, SIGNAL(TextISize(int)), this, SLOT(setFSizeMenu(int)));
connect(this, SIGNAL(TextISize(int)), propertiesPalette, SLOT(setSize(int)));
connect(this, SIGNAL(TextUSval(double)), propertiesPalette, SLOT(setExtra(double)));
connect(this, SIGNAL(TextStil(int)), propertiesPalette, SLOT(setStil(int)));
connect(this, SIGNAL(TextScale(int)), propertiesPalette, SLOT(setTScale(int)));
connect(this, SIGNAL(TextFarben(QString, QString, int, int)), propertiesPalette, SLOT(setActFarben(QString, QString, int, int)));
initCrashHandler();
}
closeSplash();
return retVal;
}
void ScribusApp::initSplash(bool showSplash)
{
if (showSplash)
{
splashScreen = new SplashScreen();
splashScreen->setStatus(QObject::tr("Initializing..."));
}
else
splashScreen = NULL;
}
void ScribusApp::closeSplash()
{
if (splashScreen!=NULL)
{
splashScreen->close();
delete splashScreen;
splashScreen = NULL;
}
}
void ScribusApp::initToolBars()
{
WerkTools2 = new QToolBar( tr("File"), this);
scrActions["fileNew"]->addTo(WerkTools2);
scrActions["fileOpen"]->addTo(WerkTools2);
scrMenuMgr->addMenuToWidgetOfAction("FileOpenRecent", scrActions["fileOpen"]);
scrActions["fileSave"]->addTo(WerkTools2);
scrActions["fileClose"]->addTo(WerkTools2);
scrActions["filePrint"]->addTo(WerkTools2);
scrActions["toolsPreflightVerifier"]->addTo(WerkTools2);
scrActions["fileExportAsPDF"]->addTo(WerkTools2);
editToolBar = new QToolBar(tr("Edit"), this);
UndoWidget* uWidget = new UndoWidget(editToolBar, "uWidget");
undoManager->registerGui(uWidget);
WerkTools = new WerkToolB(this);
setDockEnabled(WerkTools, DockLeft, false);
setDockEnabled(WerkTools, DockRight, false);
WerkTools->Sichtbar = true;
WerkTools->setEnabled(false);
WerkToolsP = new WerkToolBP(this);
setDockEnabled(WerkToolsP, DockLeft, false);
setDockEnabled(WerkToolsP, DockRight, false);
WerkToolsP->setEnabled(false);
WerkToolsP->Sichtbar = true;
connect(WerkTools, SIGNAL(Schliessen()), this, SLOT(ToggleTools()));
connect(WerkToolsP, SIGNAL(NewMode(int)), this, SLOT(setAppMode(int)));
connect(WerkToolsP, SIGNAL(Schliessen()), this, SLOT(TogglePDFTools()));
}
void ScribusApp::initFonts()
{
if (splashScreen!=NULL) {
splashScreen->setStatus( tr("Searching for Fonts"));
qApp->processEvents();
}
NoFonts=GetAllFonts();
if (NoFonts)
{
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
if (splashScreen!=NULL)
{
splashScreen->setStatus( tr("Font System Initialized"));
qApp->processEvents();
}
}
void ScribusApp::initDefaultPrefs()
{
/** Default font and size **/
SCFontsIterator it(Prefs.AvailFonts);
Prefs.toolSettings.defFont = it.currentKey();
Prefs.toolSettings.defSize = 120;
Prefs.AppFontSize = qApp->font().pointSize();
/** Default colours **/
Prefs.DColors.clear();
QString pfadC = ScPaths::instance().libDir();
QString pfadC2 = pfadC + "rgbscribus.txt";
QFile fiC(pfadC2);
if (!fiC.exists())
{
Prefs.DColors.insert("White", CMYKColor(0, 0, 0, 0));
Prefs.DColors.insert("Black", CMYKColor(0, 0, 0, 255));
Prefs.DColors.insert("Blue", CMYKColor(255, 255, 0, 0));
Prefs.DColors.insert("Cyan", CMYKColor(255, 0, 0, 0));
Prefs.DColors.insert("Green", CMYKColor(255, 0, 255, 0));
Prefs.DColors.insert("Red", CMYKColor(0, 255, 255, 0));
Prefs.DColors.insert("Yellow", CMYKColor(0, 0, 255, 0));
Prefs.DColors.insert("Magenta", CMYKColor(0, 255, 0, 0));
Prefs.DColorSet = "Scribus-Small";
}
else
{
if (fiC.open(IO_ReadOnly))
{
QString ColorEn, Cname;
int Rval, Gval, Bval;
QTextStream tsC(&fiC);
ColorEn = tsC.readLine();
while (!tsC.atEnd())
{
ColorEn = tsC.readLine();
QTextStream CoE(&ColorEn, IO_ReadOnly);
CoE >> Rval;
CoE >> Gval;
CoE >> Bval;
CoE >> Cname;
CMYKColor tmp;
tmp.setColorRGB(Rval, Gval, Bval);
Prefs.DColors.insert(Cname, tmp);
}
fiC.close();
}
Prefs.DColorSet = "X11 RGB-Set";
}
Prefs.Wheelval = 40;
Prefs.guidesSettings.marginsShown = true;
Prefs.guidesSettings.framesShown = true;
Prefs.guidesSettings.gridShown = false;
Prefs.guidesSettings.guidesShown = false;
Prefs.guidesSettings.baseShown = false;
Prefs.guidesSettings.showPic = true;
Prefs.guidesSettings.linkShown = false;
Prefs.guidesSettings.grabRad = 4;
Prefs.guidesSettings.guideRad = 10;
Prefs.guidesSettings.minorGrid = 20;
Prefs.guidesSettings.majorGrid = 100;
Prefs.guidesSettings.minorColor = QColor(green);
Prefs.guidesSettings.majorColor = QColor(green);
Prefs.guidesSettings.margColor = QColor(blue);
Prefs.guidesSettings.guideColor = QColor(darkBlue);
Prefs.guidesSettings.baseColor = QColor(lightGray);
Prefs.typographicSetttings.valueSuperScript = 33;
Prefs.typographicSetttings.scalingSuperScript = 100;
Prefs.typographicSetttings.valueSubScript = 33;
Prefs.typographicSetttings.scalingSubScript = 100;
Prefs.typographicSetttings.valueSmallCaps = 75;
Prefs.typographicSetttings.autoLineSpacing = 20;
Prefs.typographicSetttings.valueUnderlinePos = -1;
Prefs.typographicSetttings.valueUnderlineWidth = -1;
Prefs.typographicSetttings.valueStrikeThruPos = -1;
Prefs.typographicSetttings.valueStrikeThruWidth = -1;
Prefs.typographicSetttings.valueBaseGrid = 14.4;
Prefs.typographicSetttings.offsetBaseGrid = 0.0;
Prefs.GUI = "Default";
Prefs.toolSettings.dPen = "Black";
Prefs.toolSettings.dBrush = "Black";
Prefs.toolSettings.dShade = 100;
Prefs.toolSettings.dShade2 = 100;
Prefs.toolSettings.dLineArt = SolidLine;
Prefs.toolSettings.dWidth = 1;
Prefs.toolSettings.dPenLine = "Black";
Prefs.toolSettings.dPenText = "Black";
Prefs.toolSettings.dStrokeText = "Black";
Prefs.DpapColor = QColor(white);
Prefs.toolSettings.dCols = 1;
Prefs.toolSettings.dGap = 0.0;
Prefs.toolSettings.dShadeLine = 100;
Prefs.toolSettings.dLstyleLine = SolidLine;
Prefs.toolSettings.dWidthLine = 1;
Prefs.toolSettings.dStartArrow = 0;
Prefs.toolSettings.dEndArrow = 0;
Prefs.toolSettings.magMin = 10;
Prefs.toolSettings.magMax = 3200;
Prefs.toolSettings.magStep = 25;
Prefs.toolSettings.dBrushPict = "White";
Prefs.toolSettings.shadePict = 100;
Prefs.toolSettings.scaleX = 1;
Prefs.toolSettings.scaleY = 1;
Prefs.guidesSettings.before = true;
Prefs.docUnitIndex = 0;
Prefs.toolSettings.polyC = 4;
Prefs.toolSettings.polyF = 0.5;
Prefs.toolSettings.polyS = false;
Prefs.toolSettings.polyFd = 0;
Prefs.toolSettings.polyR = 0;
Prefs.mainToolBarSettings.visible = true;
Prefs.pdfToolBarSettings.visible = true;
Prefs.PSize = 40;
Prefs.SaveAtQ = true;
Prefs.ClipMargin = true;
Prefs.GCRMode = true;
Prefs.RecentDocs.clear();
Prefs.RecentDCount = 5;
Prefs.marginColored = false;
Prefs.pageSize = "A4";
Prefs.pageOrientation = 0;
Prefs.PageWidth = 595;
Prefs.PageHeight = 842;
Prefs.RandOben = 40;
Prefs.RandUnten = 40;
Prefs.RandLinks = 40;
Prefs.RandRechts = 40;
Prefs.FacingPages = false;
Prefs.LeftPageFirst = false;
Prefs.toolSettings.scaleType = true;
Prefs.toolSettings.aspectRatio = true;
Prefs.toolSettings.lowResType = 1;
Prefs.toolSettings.useEmbeddedPath = false;
Prefs.MinWordLen = 3;
Prefs.HyCount = 2;
Prefs.Language = "";
Prefs.Automatic = true;
Prefs.AutoCheck = false;
Prefs.AutoSave = false;
Prefs.AutoSaveTime = 600000;
Prefs.DisScale = 1.0;
Prefs.DocDir = QDir::homeDirPath();
Prefs.ProfileDir = "";
Prefs.ScriptDir = "";
Prefs.documentTemplatesDir = "";
Prefs.CustomColorSets.clear();
Prefs.PrPr_Mode = false;
Prefs.Gcr_Mode = true;
Prefs.PrPr_AlphaText = false;
Prefs.PrPr_AlphaGraphics = false;
Prefs.PrPr_Transparency = false;
Prefs.PrPr_C = true;
Prefs.PrPr_M = true;
Prefs.PrPr_Y = true;
Prefs.PrPr_K = true;
Prefs.imageEditorExecutable = "gimp";
Prefs.gs_AntiAliasGraphics = true;
Prefs.gs_AntiAliasText = true;
Prefs.gs_exe = "gs";
Prefs.STEcolor = QColor(white);
Prefs.STEfont = font().toString();
Prefs.DCMSset.DefaultMonitorProfile = "";
Prefs.DCMSset.DefaultPrinterProfile = "";
Prefs.DCMSset.DefaultInputProfile = "";
Prefs.DCMSset.DefaultInputProfile2 = "";
Prefs.DCMSset.CMSinUse = false;
Prefs.DCMSset.SoftProofOn = false;
Prefs.DCMSset.GamutCheck = false;
Prefs.DCMSset.BlackPoint = true;
Prefs.DCMSset.DefaultIntentMonitor = 1;
Prefs.DCMSset.DefaultIntentMonitor2 = 1;
Prefs.DCMSset.DefaultIntentPrinter = 0;
Prefs.GFontSub.clear();
Prefs.ScratchLeft = 100;
Prefs.ScratchRight = 100;
Prefs.ScratchTop = 20;
Prefs.ScratchBottom = 20;
Prefs.askBeforeSubstituite = true;
struct checkerPrefs checkerSettings;
checkerSettings.ignoreErrors = false;
checkerSettings.autoCheck = true;
checkerSettings.checkGlyphs = true;
checkerSettings.checkOrphans = true;
checkerSettings.checkOverflow = true;
checkerSettings.checkPictures = true;
checkerSettings.checkResolution = true;
checkerSettings.checkTransparency = true;
checkerSettings.checkAnnotations = false;
checkerSettings.checkRasterPDF = true;
checkerSettings.minResolution = 72.0;
Prefs.checkerProfiles.insert( tr("Postscript"), checkerSettings);
Prefs.checkerProfiles.insert( tr("PDF 1.3"), checkerSettings);
checkerSettings.checkTransparency = false;
Prefs.checkerProfiles.insert( tr("PDF 1.4"), checkerSettings);
checkerSettings.checkTransparency = true;
checkerSettings.checkAnnotations = true;
checkerSettings.minResolution = 144.0;
Prefs.checkerProfiles.insert( tr("PDF/X-3"), checkerSettings);
Prefs.curCheckProfile = tr("Postscript");
Prefs.PDF_Options.Thumbnails = false;
Prefs.PDF_Options.Articles = false;
Prefs.PDF_Options.Compress = true;
Prefs.PDF_Options.CompressMethod = 0;
Prefs.PDF_Options.Quality = 0;
Prefs.PDF_Options.RecalcPic = false;
Prefs.PDF_Options.Bookmarks = false;
Prefs.PDF_Options.PicRes = 300;
Prefs.PDF_Options.Version = PDFOptions::PDFVersion_14;
Prefs.PDF_Options.Resolution = 300;
Prefs.PDF_Options.Binding = 0;
Prefs.PDF_Options.EmbedList.clear();
Prefs.PDF_Options.SubsetList.clear();
Prefs.PDF_Options.MirrorH = false;
Prefs.PDF_Options.MirrorV = false;
Prefs.PDF_Options.RotateDeg = 0;
Prefs.PDF_Options.PresentMode = false;
Prefs.PDF_Options.Datei = "";
Prefs.PDF_Options.PresentVals.clear();
Prefs.PDF_Options.isGrayscale = false;
Prefs.PDF_Options.UseRGB = true;
Prefs.PDF_Options.UseProfiles = false;
Prefs.PDF_Options.UseProfiles2 = false;
Prefs.PDF_Options.SolidProf = "";
Prefs.PDF_Options.SComp = 3;
Prefs.PDF_Options.ImageProf = "";
Prefs.PDF_Options.PrintProf = "";
Prefs.PDF_Options.Info = "";
Prefs.PDF_Options.Intent = 0;
Prefs.PDF_Options.Intent2 = 0;
Prefs.PDF_Options.BleedTop = 0;
Prefs.PDF_Options.BleedLeft = 0;
Prefs.PDF_Options.BleedRight = 0;
Prefs.PDF_Options.BleedBottom = 0;
Prefs.PDF_Options.EmbeddedI = false;
Prefs.PDF_Options.Encrypt = false;
Prefs.PDF_Options.PassOwner = "";
Prefs.PDF_Options.PassUser = "";
Prefs.PDF_Options.Permissions = -4;
Prefs.PDF_Options.UseLPI = false;
Prefs.PDF_Options.LPISettings.clear();
//Attribute setup
Prefs.defaultItemAttributes.clear();
Prefs.defaultToCSetups.clear();
}
void ScribusApp::initDefaultValues()
{
dirs = prefsFile->getContext("dirs");
HaveDoc = false;
singleClose = false;
ScriptRunning = false;
view = NULL;
doc = NULL;
Buffer2 = "";
UniCinp = false;
UniCinC = 0;
UniCinS = "";
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()));
}
void ScribusApp::initKeyboardShortcuts()
{
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrActions.begin(); it!=scrActions.end(); ++it )
{
if ((ScrAction*)(it.data())!=NULL)
SetKeyEntry(it.key(), it.data()->cleanMenuText(), QString(it.data()->accel()),0);
//else
// qDebug(it.key());
//qDebug(QString("|-\n|%1||%2||%3").arg(it.key()).arg(it.data()->cleanMenuText()).arg(QString(it.data()->accel())));
}
}
void ScribusApp::initArrowStyles()
{
struct ArrowDesc arrow;
FPointArray points;
QWMatrix arrowScaling;
arrowScaling.scale(0.5, 0.5);
arrow.name = "Arrow1L";
arrow.userArrow = false;
points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
points.addQuadPoint(12, 0, 12, 0, 12, 0, 12, 0);
points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
points.addQuadPoint(0, 0, 0, 0, 0, 0, 0, 0);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "Arrow1M";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "Arrow1S";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "SquareL";
points.resize(0);
points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
points.addQuadPoint(5, -5, 5, -5, 5, -5, 5, -5);
points.addQuadPoint(5, 5, 5, 5, 5, 5, 5, 5);
points.addQuadPoint(-5, 5, -5, 5, -5, 5, -5, 5);
points.addQuadPoint(-5, -5, -5, -5, -5, -5, -5, -5);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "SquareM";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "SquareS";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "TriangleInL";
points.resize(0);
points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
points.addQuadPoint(-2.88, 5, -2.88, 5, -2.88, 5, -2.88, 5);
points.addQuadPoint(-2.88, -5, -2.88, -5, -2.88, -5, -2.88, -5);
points.addQuadPoint(5.77, 0, 5.77, 0, 5.77, 0, 5.77, 0);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "TriangleInM";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "TriangleInS";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "TriangleOutL";
points.resize(0);
points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
points.addQuadPoint(2.88, 5, 2.88, 5, 2.88, 5, 2.88, 5);
points.addQuadPoint(2.88, -5, 2.88, -5, 2.88, -5, 2.88, -5);
points.addQuadPoint(-5.77, 0, -5.77, 0, -5.77, 0, -5.77, 0);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "TriangleOutM";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
arrow.name = "TriangleOutS";
points.map(arrowScaling);
arrow.points = points.copy();
Prefs.arrowStyles.append(arrow);
}
void ScribusApp::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)));
outlinePalette->setPrefsContext("OutlinePalette");
outlinePalette->reportDisplay->installEventFilter(this);
propertiesPalette = new Mpalette(this, &Prefs);
connect( scrActions["toolsProperties"], SIGNAL(toggled(bool)) , propertiesPalette, SLOT(setPaletteShown(bool)) );
connect( propertiesPalette, SIGNAL(paletteShown(bool)), scrActions["toolsProperties"], SLOT(setOn(bool)));
propertiesPalette->setPrefsContext("PropertiesPalette");
propertiesPalette->Cpal->SetColors(Prefs.DColors);
propertiesPalette->Cpal->UseTrans(true);
propertiesPalette->Fonts->RebuildList(&Prefs, 0);
propertiesPalette->installEventFilter(this);
nodePalette = new NodePalette(this);
nodePalette->setPrefsContext("NodePalette");
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->setPrefsContext("LayerPalette");
layerPalette->installEventFilter(this);
layerPalette->Table->installEventFilter(this);
scrapbookPalette = new Biblio(this, &Prefs);
connect( scrActions["toolsScrapbook"], SIGNAL(toggled(bool)) , scrapbookPalette, SLOT(setPaletteShown(bool)) );
connect( scrapbookPalette, SIGNAL(paletteShown(bool)), scrActions["toolsScrapbook"], SLOT(setOn(bool)));
scrapbookPalette->setPrefsContext("ScrapbookPalette");
scrapbookPalette->installEventFilter(this);
pagePalette = new SeitenPal(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->setPrefsContext("PagePalette");
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->setPrefsContext("BookmarkPalette");
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->setPrefsContext("MeasurementPalette");
measurementPalette->installEventFilter(this);
measurementPalette->hide();
docCheckerPalette = new CheckDocument(this, false);
connect( scrActions["toolsPreflightVerifier"], SIGNAL(toggled(bool)) , docCheckerPalette, SLOT(setPaletteShown(bool)) );
connect( docCheckerPalette, SIGNAL(paletteShown(bool)), scrActions["toolsPreflightVerifier"], SLOT(setOn(bool)));
connect( docCheckerPalette, SIGNAL(paletteShown(bool)), this, SLOT(docCheckToggle(bool)));
docCheckerPalette->setPrefsContext("DocCheckerPalette");
docCheckerPalette->installEventFilter(this);
docCheckerPalette->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(propertiesPalette, SIGNAL(DocChanged()), this, SLOT(slotDocCh()));
connect(propertiesPalette, SIGNAL(NewAbStyle(int)), this, SLOT(setNewAbStyle(int)));
connect(propertiesPalette, SIGNAL(BackHome()), this, SLOT(Aktiv()));
connect(propertiesPalette, SIGNAL(Stellung(int)), this, SLOT(setItemHoch(int)));
connect(propertiesPalette, SIGNAL(EditCL()), this, SLOT(ToggleFrameEdit()));
connect(propertiesPalette, SIGNAL(NewTF(QString)), this, SLOT(SetNewFont(QString)));
connect(propertiesPalette, SIGNAL(UpdtGui(int)), this, SLOT(HaveNewSel(int)));
connect(propertiesPalette->Cpal, SIGNAL(NewPen(QString)), this, SLOT(setPenFarbe(QString)));
connect(propertiesPalette->Cpal, SIGNAL(NewBrush(QString)), this, SLOT(setBrushFarbe(QString)));
connect(propertiesPalette->Cpal, SIGNAL(NewPenShade(int)), this, SLOT(setPenShade(int)));
connect(propertiesPalette->Cpal, SIGNAL(NewBrushShade(int)), this, SLOT(setBrushShade(int)));
connect(propertiesPalette->Cpal, SIGNAL(NewTrans(double)), this, SLOT(setItemFillTransparency(double)));
connect(propertiesPalette->Cpal, SIGNAL(NewTransS(double)), this, SLOT(setItemLineTransparency(double)));
connect(propertiesPalette->Cpal, SIGNAL(NewGradient(int)), this, SLOT(setGradFill(int)));
connect(propertiesPalette->Cpal->gradEdit->Preview, SIGNAL(gradientChanged()), this, SLOT(updtGradFill()));
connect(propertiesPalette->Cpal, SIGNAL(gradientChanged()), this, SLOT(updtGradFill()));
connect(propertiesPalette->Cpal, SIGNAL(QueryItem()), this, SLOT(GetBrushPen()));
connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(SelectFromOutl(int, int)));
connect(docCheckerPalette, SIGNAL(selectPage(int)), this, SLOT(SelectFromOutlS(int)));
connect(docCheckerPalette, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
connect(outlinePalette, SIGNAL(selectElement(int, int, bool)), this, SLOT(SelectFromOutl(int, int, bool)));
connect(outlinePalette, SIGNAL(selectPage(int)), this, SLOT(SelectFromOutlS(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(layerPalette, SIGNAL(LayerActivated(int)), this, SLOT(changeLayer(int)));
connect(layerPalette, SIGNAL(LayerRemoved(int, bool)), this, SLOT(LayerRemove(int, bool)));
connect(layerPalette, SIGNAL(LayerChanged()), this, SLOT(showLayer()));
connect(pagePalette, SIGNAL(EditTemp(QString)), this, SLOT(manageMasterPages(QString)));
connect(pagePalette->PageView, SIGNAL(UseTemp(QString, int)), this, SLOT(Apply_MasterPage(QString, int)));
connect(pagePalette->PageView, SIGNAL(NewPage(int, QString)), this, SLOT(slotNewPageP(int, QString)));
connect(pagePalette->Trash, SIGNAL(DelPage(int)), this, SLOT(DeletePage2(int)));
connect(pagePalette, SIGNAL(GotoSeite(int)), this, SLOT(SelectFromOutlS(int)));
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(SelectFromOutl(int, int)));
}
void ScribusApp::initScrapbook()
{
QString scrapbookFile = QDir::convertSeparators(PrefsPfad+"/scrap13.scs");
QFileInfo scrapbookFileInfo = QFileInfo(scrapbookFile);
if (scrapbookFileInfo.exists())
scrapbookPalette->readContents(scrapbookFile);
scrapbookPalette->setScrapbookFileName(scrapbookFile);
scrapbookPalette->AdjustMenu();
}
void ScribusApp::initCrashHandler()
{
typedef void (*HandlerType)(int);
HandlerType handler = 0;
handler = ScribusApp::defaultCrashHandler;
if (!handler)
handler = SIG_DFL;
sigset_t mask;
sigemptyset(&mask);
#ifdef SIGSEGV
signal (SIGSEGV, handler);
sigaddset(&mask, SIGSEGV);
#endif
#ifdef SIGFPE
signal (SIGFPE, handler);
sigaddset(&mask, SIGFPE);
#endif
#ifdef SIGILL
signal (SIGILL, handler);
sigaddset(&mask, SIGILL);
#endif
#ifdef SIGABRT
signal (SIGABRT, handler);
sigaddset(&mask, SIGABRT);
#endif
sigprocmask(SIG_UNBLOCK, &mask, 0);
}
const QString ScribusApp::getGuiLanguage()
{
return guiLanguage;
}
bool ScribusApp::warningVersion(QWidget *parent)
{
bool retval = false;
int t = QMessageBox::warning(parent, QObject::tr("Scribus Development Version"), "<qt>" +
QObject::tr("You are running a development version of Scribus 1.3.x. The current document you are working with was originally created in Scribus 1.2.2 or lower. The process of saving will make this file unusable again in Scribus 1.2.2 unless you use File->Save As. Are you sure you wish to proceed with this operation?") + "</qt>",
QObject::tr("&Cancel"), QObject::tr("&Proceed"), "", 1, 0);
if (t == 1)
retval = true;
return retval;
}
/*!
\fn QString ScribusApp::getPreferencesLocation()
\author Craig Bradney
\date Thu 18 Nov 2004
\brief Get the user's preference file location. Rename any existing old preferences files
\param None
\retval QString Location of the user's preferences
*/
QString ScribusApp::getPreferencesLocation()
{
QString Pff = QDir::convertSeparators(QDir::homeDirPath()+"/.scribus");
QFileInfo Pffi = QFileInfo(Pff);
QString PrefsPfad;
//If we are using ~/.scribus
if (Pffi.exists())
{
if (Pffi.isDir())
PrefsPfad = Pff;
else
PrefsPfad = QDir::homeDirPath();
}
else // Move to using ~/.scribus/scribus.* from ~/.scribus.*
{
QDir prefsDirectory = QDir();
prefsDirectory.mkdir(Pff);
PrefsPfad = Pff;
QString oldPR = QDir::convertSeparators(QDir::homeDirPath()+"/.scribus.rc");
QFileInfo oldPi = QFileInfo(oldPR);
if (oldPi.exists())
moveFile(oldPR, Pff+"/scribus.rc");
QString oldPR2 = QDir::convertSeparators(QDir::homeDirPath()+"/.scribusfont.rc");
QFileInfo oldPi2 = QFileInfo(oldPR2);
if (oldPi2.exists())
moveFile(oldPR2, Pff+"/scribusfont.rc");
QString oldPR3 = QDir::convertSeparators(QDir::homeDirPath()+"/.scribusscrap.scs");
QFileInfo oldPi3 = QFileInfo(oldPR3);
if (oldPi3.exists())
moveFile(oldPR3, Pff+"/scrap.scs");
}
return PrefsPfad;
}
/*!
\fn QString ScribusApp::convertToXMLPreferences(QString prefsLocation)
\author Craig Bradney
\date Sun 09 Jan 2005
\brief Convert 1.2 prefs to 1.3 prefs
\param prefsLocation Location of user preferences
\retval None
*/
bool ScribusApp::convert12Preferences(const QString prefsLocation)
{
//Now make copies for 1.3 use and leave the old ones alone for <1.3.0 usage
QString oldPR[5], newPR[5];
oldPR[0]=QDir::convertSeparators(prefsLocation+"/scribus.rc");
oldPR[1]=QDir::convertSeparators(prefsLocation+"/scribusfont.rc");
oldPR[2]=QDir::convertSeparators(prefsLocation+"/scrap.scs");
oldPR[3]=QDir::convertSeparators(prefsLocation+"/prefs.xml");
oldPR[4]=QDir::convertSeparators(prefsLocation+"/scripter.rc");
newPR[0]=QDir::convertSeparators(prefsLocation+"/scribus13.rc");
newPR[1]=QDir::convertSeparators(prefsLocation+"/scribusfont13.rc");
newPR[2]=QDir::convertSeparators(prefsLocation+"/scrap13.scs");
newPR[3]=QDir::convertSeparators(prefsLocation+"/prefs13.xml");
newPR[4]=QDir::convertSeparators(prefsLocation+"/scripter13.rc");
bool existsOldPR[5], existsNewPR[5];
for (uint i=0;i<5;++i)
{
existsOldPR[i] =QFile::exists(oldPR[i]);
existsNewPR[i] =QFile::exists(newPR[i]);
}
bool retVal=false;
//Only check for these two as they will be autocreated if they dont exist.
if( (existsOldPR[0] && !existsNewPR[0]) || (existsOldPR[3] && !existsNewPR[3]) )
{
retVal=true; // converting from 1.2 prefs
if (splashScreen)
splashScreen->hide();
if ( (QMessageBox::question( this, tr("Migrate Old Scribus Settings?"),
tr("Scribus has detected existing Scribus 1.2 preferences files.\n"
"Do you want to migrate them to the new Scribus version?"),
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::NoButton))==QMessageBox::Yes )
{
for (uint i=0;i<5;++i)
{
if (existsOldPR[i] && !existsNewPR[i])
copyFile(oldPR[i], newPR[i]);
}
}
if (splashScreen)
splashScreen->show();
}
return retVal;
}
void ScribusApp::initMenuBar()
{
QFont tmp;
RecentDocs.clear();
scrMenuMgr->createMenu("File", tr("&File"));
scrMenuMgr->addMenuItem(scrActions["fileNew"], "File");
scrMenuMgr->addMenuItem(scrActions["fileOpen"], "File");
recentFileMenuName="FileOpenRecent";
scrMenuMgr->createMenu(recentFileMenuName, 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", tr("&Import"), "File");
scrMenuMgr->addMenuItem(scrActions["fileImportText"], "FileImport");
scrMenuMgr->addMenuItem(scrActions["fileImportAppendText"], "FileImport");
scrMenuMgr->addMenuItem(scrActions["fileImportImage"], "FileImport");
scrMenuMgr->createMenu("FileExport", tr("&Export"), "File");
scrMenuMgr->addMenuItem(scrActions["fileExportText"], "FileExport");
scrMenuMgr->addMenuItem(scrActions["fileExportAsEPS"], "FileExport");
scrMenuMgr->addMenuItem(scrActions["fileExportAsPDF"], "FileExport");
scrMenuMgr->addMenuSeparator("File");
scrMenuMgr->addMenuItem(scrActions["fileDocInfo"], "File");
scrMenuMgr->addMenuItem(scrActions["fileDocSetup"], "File");
scrMenuMgr->addMenuItem(scrActions["filePrint"], "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["fileDocInfo"]->setEnabled(false);
scrActions["fileDocSetup"]->setEnabled(false);
scrActions["filePrint"]->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->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);
//Style Menu
scrMenuMgr->createMenu("Style", tr("St&yle"));
//Color menu
// CB TODO
scrMenuMgr->createMenu("Color", tr("&Color"));
ColorMenC = new QComboBox(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->addMenuItem(scrActions["itemImageIsVisible"], "Item");
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->addMenuItem(scrActions["itemAlignDist"], "Item");
scrMenuMgr->addMenuItem(scrActions["itemSendToScrapbook"], "Item");
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemAttributes"], "ItemPDFOptions");
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["itemAlignDist"]->setEnabled(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", tr("Character"));
scrMenuMgr->addMenuToMenu("InsertChar", "Insert");
scrMenuMgr->addMenuItem(scrActions["specialPageNumber"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialSmartHyphen"], "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", tr("Quote"));
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["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["specialQuoteLowSingleComma"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteLowDoubleComma"], "InsertQuote");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleTurnedComma"], "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", tr("Space"));
scrMenuMgr->addMenuToMenu("InsertSpace", "Insert");
scrMenuMgr->addMenuItem(scrActions["specialNonBreakingSpace"], "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["pageManageGuides"], "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->addMenuSeparator("View");
scrMenuMgr->addMenuItem(scrActions["viewSnapToGrid"], "View");
scrMenuMgr->addMenuItem(scrActions["viewSnapToGuides"], "View");
// 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->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["extrasGenerateTableOfContents"], "Extras");
scrMenuMgr->setMenuEnabled("Extras", false);
scrActions["extrasHyphenateText"]->setEnabled(false);
//Window menu
scrMenuMgr->createMenu("Windows", tr("&Windows"));
connect(scrMenuMgr->getLocalPopupMenu("Windows"), SIGNAL(aboutToShow()), this, SLOT(windowsMenuAboutToShow()));
//Help menu
scrMenuMgr->createMenu("Help", tr("&Help"));
scrMenuMgr->addMenuItem(scrActions["helpAboutScribus"], "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 ScribusApp::initStatusBar()
{
FMess = new QLabel( " ", statusBar(), "ft");
FProg = new QProgressBar(statusBar(), "p");
FProg->setCenterIndicator(true);
FProg->setFixedWidth( 100 );
FProg->reset();
XMess = new QLabel( tr("X-Pos:"), statusBar(), "xt");
YMess = new QLabel( tr("Y-Pos:"), statusBar(), "yt");
XDat = new QLabel( " ", statusBar(), "dt");
YDat = new QLabel( " ", statusBar(), "ydt");
statusBar()->addWidget(FMess, 3, true);
statusBar()->addWidget(FProg, 0, true);
statusBar()->addWidget(XMess, 0, true);
statusBar()->addWidget(XDat, 1, true);
statusBar()->addWidget(YMess, 0, true);
statusBar()->addWidget(YDat, 1, true);
}
void ScribusApp::setMousePositionOnStatusBar(double xp, double yp)
{
QString suffix=unitGetSuffixFromIndex(doc->docUnitIndex);
int multiplier=unitGetDecimalsFromIndex(doc->docUnitIndex);
double divisor=static_cast<double>(multiplier);
int precision=unitGetPrecisionFromIndex(doc->docUnitIndex);
QString tmp;
XDat->setText(tmp.setNum(qRound(xp*doc->unitRatio * multiplier) / divisor, 'f', precision) + suffix);
YDat->setText(tmp.setNum(qRound(yp*doc->unitRatio * multiplier) / divisor, 'f', precision) + suffix);
}
void ScribusApp::SetKeyEntry(QString actName, QString cleanMenuText, QString keyseq, int rowNumber)
{
Keys ke;
if (actName!="")
{
if (scrActions[actName])
{
ke.actionName=actName;
ke.keySequence = keyseq;
ke.cleanMenuText=cleanMenuText;
ke.tableRow=rowNumber;
Prefs.KeyActions.insert(actName, ke);
}
else
qDebug("%s", QString("Action Name: %1 does not exist").arg(actName).ascii());
}
}
void ScribusApp::deleteSelectedTextFromFrame(PageItem *currItem)
{
int firstSelection = 0;
bool first = false;
for (ScText *it = currItem->itemText.first(); it != 0; it = currItem->itemText.next())
{
if (it->cselect)
{
first = true;
currItem->itemText.remove();
it = currItem->itemText.prev();
if (it == 0)
it = currItem->itemText.first();
}
if (!first)
firstSelection++;
}
if (currItem->itemText.count() != 0)
{
if (currItem->itemText.first()->cselect)
{
currItem->itemText.remove();
currItem->CPos = 0;
}
else
currItem->CPos = firstSelection;
}
else
currItem->CPos = 0;
currItem->HasSel = false;
DisableTxEdit();
}
void ScribusApp::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;
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);
}
}
void ScribusApp::wheelEvent(QWheelEvent *w)
{
if (HaveDoc)
{
if ((w->orientation() != Qt::Vertical) || ( w->state() & ShiftButton ))
{
if (w->delta() < 0)
view->scrollBy(Prefs.Wheelval, 0);
else
view->scrollBy(-Prefs.Wheelval, 0);
}
else
{
if (w->delta() < 0)
view->scrollBy(0, Prefs.Wheelval);
else
view->scrollBy(0, -Prefs.Wheelval);
}
w->accept();
}
}
//Special keys assigned to actions are stolen by the action and not passed to
//keyPressEvent so process them here.
void ScribusApp::specialActionKeyEvent(QString actionName, int unicodevalue)
{
if (HaveDoc)
{
if (doc->appMode==EditMode)
{
if (view->SelItem.count() == 1)
{
struct ScText *hg = new ScText;
PageItem *currItem = view->SelItem.at(0);
if (unicodevalue!=-1)
{
hg->ch = QString(QChar(unicodevalue));
hg->cfont = (*doc->AllFonts)[doc->CurrFont];
hg->csize = doc->CurrFontSize;
hg->ccolor = doc->CurrTextFill;
hg->cshade = doc->CurrTextFillSh;
hg->cstroke = doc->CurrTextStroke;
hg->cshade2 = doc->CurrTextStrokeSh;
hg->cscale = doc->CurrTextScale;
hg->cselect = false;
hg->cstyle = doc->CurrentStyle;
hg->cab = doc->currentParaStyle;
if (doc->docParagraphStyles[doc->currentParaStyle].Font != "")
{
hg->cfont = (*doc->AllFonts)[doc->docParagraphStyles[doc->currentParaStyle].Font];
hg->csize = doc->docParagraphStyles[doc->currentParaStyle].FontSize;
}
hg->cextra = 0;
hg->xp = 0;
hg->yp = 0;
hg->PRot = 0;
hg->PtransX = 0;
hg->PtransY = 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 eaier way but this is cleaner than before. No need to modify all those palettes and each new one in future.
*/
bool ScribusApp::eventFilter( QObject */*o*/, QEvent *e )
{
bool retVal;
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent *k = (QKeyEvent *)e;
int keyMod;
switch (k->state())
{
case ShiftButton:
keyMod = SHIFT;
break;
case AltButton:
keyMod = ALT;
break;
case ControlButton:
keyMod = CTRL;
break;
default:
keyMod = 0;
break;
}
QKeySequence currKeySeq = QKeySequence(k->key() | keyMod);
retVal=true;
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["fileQuit"]->accel())
scrActions["fileQuit"]->activate();
else
retVal=false;
}
else
retVal=false;
//Return false to pass event to object
return retVal;
}
void ScribusApp::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;
switch (k->state())
{
case ShiftButton:
KeyMod = SHIFT;
break;
case AltButton:
KeyMod = ALT;
break;
case ControlButton:
KeyMod = CTRL;
break;
default:
KeyMod = 0;
break;
}
if ((kk == Key_Escape) && (HaveDoc))
{
keyrep = false;
PageItem *currItem;
if ((view->SelItem.count() != 0))
{
currItem = view->SelItem.at(0);
switch (doc->appMode)
{
case NormalMode:
currItem->Sizing = false;
if (doc->SubMode != -1)
{
view->Deselect(false);
doc->Items.remove(currItem->ItemNr);
}
break;
case LinkFrames:
case UnlinkFrames:
case EditMode:
case Rotation:
view->Deselect(false);
case PanningMode:
break;
case DrawBezierLine:
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);
view->SetPolyClip(currItem, 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 ((HaveDoc) && (!view->LE->hasFocus()) && (!view->PGS->PageCombo->hasFocus()))
{
if ((doc->appMode != EditMode) && (view->SelItem.count() == 0))
{
switch (kk)
{
case Key_Space:
keyrep = false;
if (doc->appMode == PanningMode)
setAppMode(NormalMode);
else
{
setAppMode(PanningMode);
qApp->setOverrideCursor(QCursor(loadIcon("HandC.xpm")), true);
}
return;
break;
case Key_Prior:
view->scrollBy(0, -Prefs.Wheelval);
keyrep = false;
return;
break;
case Key_Next:
view->scrollBy(0, Prefs.Wheelval);
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;
}
}
if (view->SelItem.count() != 0)
{
PageItem *currItem = view->SelItem.at(0);
switch (doc->appMode)
{
case NormalMode:
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 ( buttonState & ShiftButton )
view->moveGroup(-10, 0);
else if ( buttonState & ControlButton )
view->moveGroup(-0.1, 0);
else
view->moveGroup(-1, 0);
slotDocCh();
}
break;
case Key_Right:
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->moveGroup(10, 0);
else if ( buttonState & ControlButton )
view->moveGroup(0.1, 0);
else
view->moveGroup(1, 0);
slotDocCh();
}
break;
case Key_Up:
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->moveGroup(0, -10);
else if ( buttonState & ControlButton )
view->moveGroup(0, -0.1);
else
view->moveGroup(0, -1);
slotDocCh();
}
break;
case Key_Down:
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->moveGroup(0, 10);
else if ( buttonState & ControlButton )
view->moveGroup(0, 0.1);
else
view->moveGroup(0, 1);
slotDocCh();
}
break;
default:
break;
}
break;
case EditMode:
int oldPos = currItem->CPos; // 15-mar-2004 jjsa for cursor movement with Shift + Arrow key
view->oldCp = currItem->CPos;
if (currItem->itemType() == PageItem::ImageFrame)
{
switch (kk)
{
case Key_Left:
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->MoveItemI(-10, 0, currItem->ItemNr, true);
else if ( buttonState & ControlButton )
view->MoveItemI(-0.1, 0, currItem->ItemNr, true);
else
view->MoveItemI(-1, 0, currItem->ItemNr, true);
}
break;
case Key_Right:
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->MoveItemI(10, 0, currItem->ItemNr, true);
else if ( buttonState & ControlButton )
view->MoveItemI(0.1, 0, currItem->ItemNr, true);
else
view->MoveItemI(1, 0, currItem->ItemNr, true);
}
break;
case Key_Up:
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->MoveItemI(0, -10, currItem->ItemNr, true);
else if ( buttonState & ControlButton )
view->MoveItemI(0, -0.1, currItem->ItemNr, true);
else
view->MoveItemI(0, -1, currItem->ItemNr, true);
}
break;
case Key_Down:
if (!currItem->locked())
{
if ( buttonState & ShiftButton )
view->MoveItemI(0, 10, currItem->ItemNr, true);
else if ( buttonState & ControlButton )
view->MoveItemI(0, 0.1, currItem->ItemNr, true);
else
view->MoveItemI(0, 1, currItem->ItemNr, true);
}
break;
}
}
if (currItem->itemType() == PageItem::TextFrame)
{
view->slotDoCurs(false);
switch (kk)
{
case Key_Prior:
case Key_Next:
case Key_End:
case Key_Home:
case Key_Right:
case Key_Left:
case Key_Up:
case Key_Down:
if ( (buttonState & ShiftButton) == 0 )
view->deselectAll(currItem);
}
/* ISO 14755
if ((buttonState & ControlButton) && (buttonState & ShiftButton))
{
if (!UniCinp)
{
UniCinp=true;
UniCinC = 0;
UniCinS = "";
keyrep = false;
}
qDebug(QString("%1 %2 %3 %4 %5").arg("uni").arg("c+s").arg(uc).arg(kk).arg(as));
}
*/
if (UniCinp)
{
int conv = 0;
bool ok = false;
UniCinS += uc;
conv = UniCinS.toInt(&ok, 16);
if (!ok)
{
UniCinp = false;
UniCinC = 0;
UniCinS = "";
keyrep = false;
return;
}
UniCinC++;
if (UniCinC == 4)
{
UniCinp = false;
UniCinC = 0;
UniCinS = "";
if (ok)
{
if (currItem->HasSel)
deleteSelectedTextFromFrame(currItem);
if (conv < 31)
conv = 32;
hg = new ScText;
hg->ch = QString(QChar(conv));
hg->cfont = (*doc->AllFonts)[doc->CurrFont];
hg->csize = doc->CurrFontSize;
hg->ccolor = doc->CurrTextFill;
hg->cshade = doc->CurrTextFillSh;
hg->cstroke = doc->CurrTextStroke;
hg->cshade2 = doc->CurrTextStrokeSh;
hg->cscale = doc->CurrTextScale;
hg->cselect = false;
hg->cstyle = doc->CurrentStyle;
hg->cab = doc->currentParaStyle;
if (doc->docParagraphStyles[doc->currentParaStyle].Font != "")
{
hg->cfont = (*doc->AllFonts)[doc->docParagraphStyles[doc->currentParaStyle].Font];
hg->csize = doc->docParagraphStyles[doc->currentParaStyle].FontSize;
}
hg->cextra = 0;
hg->xp = 0;
hg->yp = 0;
hg->PRot = 0;
hg->PtransX = 0;
hg->PtransY = 0;
currItem->itemText.insert(currItem->CPos, hg);
currItem->CPos += 1;
currItem->Tinput = true;
setTBvals(currItem);
view->RefreshItem(currItem);
keyrep = false;
return;
}
}
else
{
keyrep = false;
return;
}
}
switch (kk)
{
case Key_F12:
UniCinp = true;
UniCinC = 0;
UniCinS = "";
keyrep = false;
return;
break;
case Key_Home:
// go to begin of line
if ( (pos = currItem->CPos) == 0 )
break; // at begin of frame
len = static_cast<int>(currItem->itemText.count());
if ( pos == len )
pos--;
if ( (buttonState & ControlButton) == 0 )
{
alty = currItem->itemText.at(pos)->yp;
c = currItem->itemText.at(pos)->ch.at(0).latin1();
if ( c == 13 ) // new line, position is wrong
if ( --pos > 0 )
alty = currItem->itemText.at(pos)->yp;
// check for yp at actual position
if ( pos < len )
{
altx = currItem->itemText.at(pos)->yp;
if ( altx > alty )
{
// we was at begin of line
break;
}
}
while ( pos > 0 && currItem->itemText.at(pos-1)->yp == alty )
pos--;
if ( currItem->itemText.at(pos)->ch.at(0).latin1() == 13 )
pos++;
}
else
{
// paragraph begin
if ( pos < len &&
currItem->itemText.at(pos)->ch.at(0).latin1() == 13 )
pos--;
while(pos > 0 )
if ( currItem->itemText.at(pos)->ch.at(0).latin1() == 13 )
{
pos++;
break;
}
else
pos--;
}
currItem->CPos = pos;
if ( buttonState & ShiftButton )
view->ExpandSel(currItem, -1, oldPos);
break;
case Key_End:
// go to end of line
len = static_cast<int>(currItem->itemText.count());
if ( currItem->CPos >= len )
break; // at end of frame
if ( (buttonState & ControlButton) == 0 )
{
if ((currItem->CPos < len) && ((currItem->itemText.at(currItem->CPos)->ch.at(0).latin1() == 13) || (currItem->itemText.at(currItem->CPos)->ch.at(0).latin1() == 28)))
{
// at end of paragraph and therefore line
break;
}
QString nextCh = currItem->itemText.at(currItem->CPos)->ch;
int nextChs = currItem->itemText.at(currItem->CPos)->csize;
alty = currItem->itemText.at(currItem->CPos)->yp - currItem->SetZeichAttr(currItem->itemText.at(currItem->CPos), &nextChs, &nextCh);
double nextY;
while (currItem->CPos < len-1)
{
nextCh = currItem->itemText.at(currItem->CPos+1)->ch;
nextChs = currItem->itemText.at(currItem->CPos+1)->csize;
nextY = currItem->itemText.at(currItem->CPos+1)->yp - currItem->SetZeichAttr(currItem->itemText.at(currItem->CPos+1), &nextChs, &nextCh);
if (fabs(nextY - alty) > 1.0)
break;
currItem->CPos++;
if ( currItem->CPos == len-1)
break;
}
if ( currItem->CPos < len -1 )
c = currItem->itemText.at(currItem->CPos+1)->ch.at(0).latin1();
else if ( currItem->CPos == len - 1 )
c = 13;
else
c = 0;
if (( c == 13 ) || (c = 28))
currItem->CPos++;
}
else
{
// go to end of paragraph
if ( currItem->itemText.at(currItem->CPos)->ch.at(0).latin1() == 13 )
{
break;
}
pos = currItem->CPos;
while ( pos < len )
{
if ( currItem->itemText.at(pos)->ch.at(0).latin1() == 13 )
break;
else
pos++;
}
currItem->CPos = pos;
}
if ( buttonState & ShiftButton )
view->ExpandSel(currItem, 1, oldPos);
break;
case Key_Down:
if (currItem->CPos != static_cast<int>(currItem->itemText.count()))
{
alty = currItem->itemText.at(currItem->CPos)->yp;
altx = currItem->itemText.at(currItem->CPos)->xp;
do
{
currItem->CPos += 1;
if (currItem->CPos == static_cast<int>(currItem->itemText.count()))
break;
if (currItem->itemText.at(currItem->CPos)->yp > alty)
{
if (currItem->itemText.at(currItem->CPos)->xp >= altx)
break;
}
}
while (currItem->CPos < static_cast<int>(currItem->itemText.count()));
if ( buttonState & ShiftButton )
{
if ( buttonState & AltButton )
currItem->CPos = currItem->itemText.count();
view->ExpandSel(currItem, 1, oldPos);
}
else
if (currItem->CPos == static_cast<int>(currItem->itemText.count()))
if (currItem->NextBox != 0)
{
if (currItem->NextBox->itemText.count() != 0)
{
view->Deselect(true);
currItem->NextBox->CPos = 0;
view->SelectItemNr(currItem->NextBox->ItemNr);
currItem = currItem->NextBox;
}
}
}
else
{
if (currItem->NextBox != 0)
{
if (currItem->NextBox->itemText.count() != 0)
{
view->Deselect(true);
currItem->NextBox->CPos = 0;
view->SelectItemNr(currItem->NextBox->ItemNr);
currItem = currItem->NextBox;
}
}
}
if ( currItem->HasSel )
view->RefreshItem(currItem);
setTBvals(currItem);
break;
case Key_Up:
if (currItem->CPos > 0)
{
if (currItem->CPos == static_cast<int>(currItem->itemText.count()))
currItem->CPos -= 1;
alty = currItem->itemText.at(currItem->CPos)->yp;
altx = currItem->itemText.at(currItem->CPos)->xp;
if (currItem->CPos > 0)
{
do
{
currItem->CPos -= 1;
if (currItem->CPos == 0)
break;
if ( currItem->itemText.at(currItem->CPos)->ch.at(0).latin1() == 13 )
break;
if (currItem->itemText.at(currItem->CPos)->yp < alty)
{
if (currItem->itemText.at(currItem->CPos)->xp <= altx)
break;
}
}
while (currItem->CPos > 0);
}
if ( buttonState & ShiftButton )
{
if ( buttonState & AltButton )
currItem->CPos = 0;
view->ExpandSel(currItem, -1, oldPos);
}
else
if (currItem->CPos == 0)
{
if (currItem->BackBox != 0)
{
view->Deselect(true);
currItem->BackBox->CPos = currItem->BackBox->itemText.count();
view->SelectItemNr(currItem->BackBox->ItemNr);
currItem = currItem->BackBox;
}
}
}
else
{
currItem->CPos = 0;
if (currItem->BackBox != 0)
{
view->Deselect(true);
currItem->BackBox->CPos = currItem->BackBox->itemText.count();
view->SelectItemNr(currItem->BackBox->ItemNr);
currItem = currItem->BackBox;
}
}
if ( currItem->HasSel )
view->RefreshItem(currItem);
setTBvals(currItem);
break;
case Key_Prior:
currItem->CPos = 0;
if ( buttonState & ShiftButton )
view->ExpandSel(currItem, -1, oldPos);
setTBvals(currItem);
break;
case Key_Next:
currItem->CPos = static_cast<int>(currItem->itemText.count());
if ( buttonState & ShiftButton )
view->ExpandSel(currItem, 1, oldPos);
setTBvals(currItem);
break;
case Key_Left:
if ( buttonState & ControlButton )
{
view->setNewPos(currItem, oldPos, currItem->itemText.count(),-1);
if ( buttonState & ShiftButton )
view->ExpandSel(currItem, -1, oldPos);
}
else if ( buttonState & ShiftButton )
{
currItem->CPos--;
if ( currItem->CPos < 0 )
currItem->CPos = 0;
else
view->ExpandSel(currItem, -1, oldPos);
}
else
{
currItem->CPos -= 1;
if (currItem->CPos < 0)
{
currItem->CPos = 0;
if (currItem->BackBox != 0)
{
view->Deselect(true);
currItem->BackBox->CPos = currItem->BackBox->itemText.count();
view->SelectItemNr(currItem->BackBox->ItemNr);
currItem = currItem->BackBox;
}
}
}
if ((currItem->CPos > 0) && (currItem->CPos == static_cast<int>(currItem->itemText.count())))
{
if (currItem->itemText.at(currItem->CPos-1)->cstyle & 4096)
{
currItem->CPos -= 1;
while ((currItem->CPos > 0) && (currItem->itemText.at(currItem->CPos)->cstyle & 4096))
{
currItem->CPos--;
if (currItem->CPos == 0)
break;
}
}
}
else
{
while ((currItem->CPos > 0) && (currItem->itemText.at(currItem->CPos)->cstyle & 4096))
{
currItem->CPos--;
if (currItem->CPos == 0)
break;
}
}
if ( currItem->HasSel )
view->RefreshItem(currItem);
setTBvals(currItem);
break;
case Key_Right:
if ( buttonState & ControlButton )
{
view->setNewPos(currItem, oldPos, currItem->itemText.count(),1);
if ( buttonState & ShiftButton )
view->ExpandSel(currItem, 1, oldPos);
}
else if ( buttonState & ShiftButton )
{
currItem->CPos++;
if ( currItem->CPos > static_cast<int>(currItem->itemText.count()) )
currItem->CPos--;
else
view->ExpandSel(currItem, 1, oldPos);
}
else
{
currItem->CPos += 1; // new position within text ?
if (currItem->CPos > static_cast<int>(currItem->itemText.count()))
{
currItem->CPos -= 1;
if (currItem->NextBox != 0)
{
if (currItem->NextBox->itemText.count() != 0)
{
view->Deselect(true);
currItem->NextBox->CPos = 0;
view->SelectItemNr(currItem->NextBox->ItemNr);
currItem = currItem->NextBox;
}
}
}
}
if ( currItem->HasSel )
view->RefreshItem(currItem);
setTBvals(currItem);
break;
case Key_Delete:
if (currItem->CPos == static_cast<int>(currItem->itemText.count()))
{
if (currItem->HasSel)
{
deleteSelectedTextFromFrame(currItem);
setTBvals(currItem);
view->RefreshItem(currItem);
}
keyrep = false;
return;
}
if (currItem->itemText.count() == 0)
{
keyrep = false;
return;
}
cr = currItem->itemText.at(currItem->CPos)->ch;
if (currItem->HasSel)
deleteSelectedTextFromFrame(currItem);
else
currItem->itemText.remove(currItem->CPos);
currItem->Tinput = false;
if ((cr == QChar(13)) && (currItem->itemText.count() != 0))
{
view->chAbStyle(currItem, currItem->itemText.at(QMAX(currItem->CPos-1,0))->cab);
currItem->Tinput = false;
}
setTBvals(currItem);
view->RefreshItem(currItem);
break;
case Key_Backspace:
if (currItem->CPos == 0)
{
if (currItem->HasSel)
{
deleteSelectedTextFromFrame(currItem);
setTBvals(currItem);
view->RefreshItem(currItem);
}
break;
}
if (currItem->itemText.count() == 0)
break;
cr = currItem->itemText.at(QMAX(currItem->CPos-1,0))->ch;
if (currItem->HasSel)
deleteSelectedTextFromFrame(currItem);
else
{
currItem->CPos -= 1;
currItem->itemText.remove(currItem->CPos);
}
currItem->Tinput = false;
if ((cr == QChar(13)) && (currItem->itemText.count() != 0))
{
view->chAbStyle(currItem, currItem->itemText.at(QMAX(currItem->CPos-1,0))->cab);
currItem->Tinput = false;
}
setTBvals(currItem);
view->RefreshItem(currItem);
break;
default:
if ((currItem->HasSel) && (kk < 0x1000))
deleteSelectedTextFromFrame(currItem);
if ((kk == Key_Tab) || ((kk == Key_Return) && (buttonState & ShiftButton)))
{
hg = new ScText;
if (kk == Key_Return)
hg->ch = QString(QChar(28));
else if (kk == Key_Tab)
hg->ch = QString(QChar(9));
hg->cfont = (*doc->AllFonts)[doc->CurrFont];
hg->csize = doc->CurrFontSize;
hg->ccolor = doc->CurrTextFill;
hg->cshade = doc->CurrTextFillSh;
hg->cstroke = doc->CurrTextStroke;
hg->cshade2 = doc->CurrTextStrokeSh;
hg->cscale = doc->CurrTextScale;
hg->cselect = false;
hg->cstyle = doc->CurrentStyle;
hg->cab = doc->currentParaStyle;
if (doc->docParagraphStyles[doc->currentParaStyle].Font != "")
{
hg->cfont = (*doc->AllFonts)[doc->docParagraphStyles[doc->currentParaStyle].Font];
hg->csize = doc->docParagraphStyles[doc->currentParaStyle].FontSize;
}
hg->cextra = 0;
hg->xp = 0;
hg->yp = 0;
hg->PRot = 0;
hg->PtransX = 0;
hg->PtransY = 0;
currItem->itemText.insert(currItem->CPos, hg);
currItem->CPos += 1;
currItem->Tinput = true;
view->RefreshItem(currItem);
break;
}
if (((uc[0] > QChar(31)) || (as == 13) || (as == 30)) && ((*doc->AllFonts)[doc->CurrFont]->CharWidth.contains(uc[0].unicode())))
{
hg = new ScText;
hg->ch = uc;
hg->cfont = (*doc->AllFonts)[doc->CurrFont];
hg->ccolor = doc->CurrTextFill;
hg->cshade = doc->CurrTextFillSh;
hg->cstroke = doc->CurrTextStroke;
hg->cshade2 = doc->CurrTextStrokeSh;
hg->cscale = doc->CurrTextScale;
hg->csize = doc->CurrFontSize;
hg->cextra = 0;
hg->cselect = false;
hg->cstyle = doc->CurrentStyle;
hg->cab = doc->currentParaStyle;
if (doc->docParagraphStyles[doc->currentParaStyle].Font != "")
{
hg->cfont = (*doc->AllFonts)[doc->docParagraphStyles[doc->currentParaStyle].Font];
hg->csize = doc->docParagraphStyles[doc->currentParaStyle].FontSize;
}
hg->xp = 0;
hg->yp = 0;
hg->PRot = 0;
hg->PtransX = 0;
hg->PtransY = 0;
currItem->itemText.insert(currItem->CPos, hg);
currItem->CPos += 1;
if ((doc->docHyphenator->AutoCheck) && (currItem->CPos > 1))
{
Twort = "";
Tcoun = 0;
for (int hych = currItem->CPos-1; hych > -1; hych--)
{
Tcha = currItem->itemText.at(hych)->ch;
if (Tcha == " ")
{
Tcoun = hych+1;
break;
}
Twort.prepend(Tcha);
}
if (Twort != "")
{
if (doc->docHyphenator->Language != currItem->Language)
doc->docHyphenator->slotNewDict(currItem->Language);
doc->docHyphenator->slotHyphenateWord(currItem, Twort, Tcoun);
}
}
currItem->Tinput = true;
view->RefreshItem(currItem);
}
break;
}
view->slotDoCurs(true);
if ((kk == Key_Left) || (kk == Key_Right) || (kk == Key_Up) || (kk == Key_Down))
{
keyrep = false;
return;
}
}
slotDocCh(false);
break;
}
}
}
switch(kk)
{
case Key_Left:
case Key_Right:
case Key_Up:
case Key_Down:
_arrowKeyDown = true;
}
keyrep = false;
}
void ScribusApp::keyReleaseEvent(QKeyEvent *k)
{
if (k->isAutoRepeat() || !_arrowKeyDown)
return;
switch(k->key())
{
case Key_Left:
case Key_Right:
case Key_Up:
case Key_Down:
_arrowKeyDown = false;
for (uint i = 0; i < view->SelItem.count(); ++i)
view->SelItem.at(i)->checkChanges(true);
if (view->SelItem.count() > 1 && view->groupTransactionStarted())
undoManager->commit();
}
}
void ScribusApp::closeEvent(QCloseEvent *ce)
{
QWidgetList windows = wsp->windowList();
ScribusWin* tw;
if (!windows.isEmpty())
{
singleClose = true;
for ( int i = 0; i < static_cast<int>(windows.count()); ++i )
{
newActWin(windows.at(i));
tw = ActWin;
ActWin->close();
if (tw == ActWin)
{
ce->ignore();
singleClose = false;
return;
}
}
propertiesPalette->hide();
outlinePalette->hide();
scrapbookPalette->hide();
bookmarkPalette->hide();
layerPalette->hide();
pagePalette->hide();
measurementPalette->hide();
docCheckerPalette->hide();
// Shut down plugins before saving prefs to ensure
// plugins can use prefs mgr from their cleanup routines.
pluginManager->finalizePlugs();
SavePrefs();
delete prefsFile;
UndoManager::deleteInstance();
if ((Prefs.SaveAtQ) && (scrapbookPalette->changed()))
{
if (scrapbookPalette->getScrapbookFileName().isEmpty())
scrapbookPalette->setScrapbookFileName(PrefsPfad+"/scrap13.scs");
scrapbookPalette->Save();
}
if (scrapbookPalette->objectCount() == 0)
unlink(PrefsPfad+"/scrap13.scs");
Prefs.AvailFonts.~SCFonts();
exit(0);
}
else
{
propertiesPalette->hide();
outlinePalette->hide();
scrapbookPalette->hide();
bookmarkPalette->hide();
layerPalette->hide();
pagePalette->hide();
measurementPalette->hide();
docCheckerPalette->hide();
SavePrefs();
UndoManager::deleteInstance();
if ((Prefs.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);
Prefs.AvailFonts.~SCFonts();
pluginManager->finalizePlugs();
delete prefsFile;
exit(0);
}
}
/////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATION
/////////////////////////////////////////////////////////////////////
void ScribusApp::parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount)
{
QString tmp = pages;
QString token;
int from, to, pageNr;
do
{
if (tmp.find(",") == -1)
{
token = tmp;
tmp = "";
}
else
{
token = tmp.left(tmp.find(","));
tmp = tmp.right(tmp.length() - tmp.find(",") - 1);
}
token = token.stripWhiteSpace();
if (token == "*") // Import all source doc pages
{
for (int i = 1; i <= sourcePageCount; ++i)
pageNs->push_back(i);
}
else if (token.find("-") != -1) // import a range of source doc pages
{
from = QString(token.left(token.find("-"))).toInt();
to = QString(token.right(token.length() - token.find("-") - 1)).toInt();
if ((from != 0) && (to != 0))
{
if (from > sourcePageCount)
from = sourcePageCount;
if (to > sourcePageCount)
to = sourcePageCount;
if (from == to)
pageNs->push_back(to);
else if (from < to)
{
for (int i = from; i <= to; ++i)
pageNs->push_back(i);
}
else
{
for (int i = from; i >= to; --i)
pageNs->push_back(i);
}
}
}
else // import single source doc page
{
pageNr = token.toInt();
if ((pageNr > 0) && (pageNr <= sourcePageCount))
pageNs->push_back(pageNr);
}
} while (tmp != "");
}
bool ScribusApp::arrowKeyDown()
{
return _arrowKeyDown;
}
bool ScribusApp::slotFileNew()
{
bool retVal;
NewDoc* dia = new NewDoc(this, &Prefs);
if (dia->exec())
{
bool facingPages, autoframes;
double pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, numberCols, columnDistance;
topMargin = dia->Top;
leftMargin = dia->Left;
rightMargin = dia->Right;
bottomMargin = dia->Bottom;
columnDistance = dia->Dist;
pageWidth = dia->Pagebr;
pageHeight = dia->Pageho;
numberCols = dia->SpinBox10->value();
autoframes = dia->AutoFrame->isChecked();
facingPages = dia->Doppelseiten->isChecked();
int orientation = dia->Orient;
QString pagesize = dia->ComboBox1->currentText();
retVal = doFileNew(pageWidth, pageHeight, topMargin, leftMargin, rightMargin, bottomMargin, columnDistance, numberCols, autoframes, facingPages, dia->ComboBox3->currentItem(),
dia->ErsteSeite->isChecked(), orientation, dia->PgNr->value(), pagesize);
FMess->setText( tr("Ready"));
}
else
retVal = false;
delete dia;
windowsMenuAboutToShow();
return retVal;
}
bool ScribusApp::doFileNew(double width, double h, double tpr, double lr, double rr, double br, double ab, double sp,
bool atf, bool fp, int einh, bool firstleft, int Ori, int SNr, QString PageSize)
{
QString cc;
if (HaveDoc)
doc->OpenNodes = outlinePalette->buildReopenVals();
doc = new ScribusDoc(&Prefs);
doc->is12doc=false;
docCheckerPalette->clearErrorList();
doc->docUnitIndex = einh;
if (fp)
doc->FirstPageLeft = firstleft;
doc->PageOri = Ori;
doc->PageSize = PageSize;
doc->FirstPnum = SNr;
doc->setName(doc->DocName+cc.setNum(DocNr));
doc->HasCMS = true;
doc->CMSSettings.DefaultInputProfile = Prefs.DCMSset.DefaultInputProfile;
doc->CMSSettings.DefaultInputProfile2 = Prefs.DCMSset.DefaultInputProfile2;
doc->CMSSettings.DefaultMonitorProfile = Prefs.DCMSset.DefaultMonitorProfile;
doc->CMSSettings.DefaultPrinterProfile = Prefs.DCMSset.DefaultPrinterProfile;
doc->CMSSettings.DefaultIntentPrinter = Prefs.DCMSset.DefaultIntentPrinter;
doc->CMSSettings.DefaultIntentMonitor = Prefs.DCMSset.DefaultIntentMonitor;
doc->CMSSettings.DefaultIntentMonitor2 = Prefs.DCMSset.DefaultIntentMonitor2;
doc->CMSSettings.SoftProofOn = Prefs.DCMSset.SoftProofOn;
doc->CMSSettings.GamutCheck = Prefs.DCMSset.GamutCheck;
doc->CMSSettings.BlackPoint = Prefs.DCMSset.BlackPoint;
doc->CMSSettings.CMSinUse = Prefs.DCMSset.CMSinUse;
doc->PDF_Options.SolidProf = doc->CMSSettings.DefaultInputProfile2;
doc->PDF_Options.ImageProf = doc->CMSSettings.DefaultInputProfile;
doc->PDF_Options.PrintProf = doc->CMSSettings.DefaultPrinterProfile;
doc->PDF_Options.Intent = doc->CMSSettings.DefaultIntentMonitor;
doc->PDF_Options.Intent2 = doc->CMSSettings.DefaultIntentMonitor2;
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);
doc->ActiveLayer = 0;
HaveDoc++;
DocNr++;
doc->appMode = NormalMode;
doc->PageColors = Prefs.DColors;
doc->loading = true;
ScribusWin* w = new ScribusWin(wsp, doc);
if (view!=NULL)
actionManager->disconnectNewViewActions();
view = new ScribusView(w, doc, &Prefs);
view->Scale = 1.0*Prefs.DisScale;
actionManager->connectNewViewActions(view);
w->setView(view);
ActWin = w;
doc->WinHan = w;
w->setCentralWidget(view);
connect(undoManager, SIGNAL(undoRedoDone()), view, SLOT(DrawNew()));
connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
// connect(w, SIGNAL(SaveAndClose()), this, SLOT(DoSaveClose()));
if (CMSavail)
{
#ifdef HAVE_CMS
doc->SoftProofing = Prefs.DCMSset.SoftProofOn;
doc->Gamut = Prefs.DCMSset.GamutCheck;
CMSuse = Prefs.DCMSset.CMSinUse;
doc->IntentPrinter = Prefs.DCMSset.DefaultIntentPrinter;
doc->IntentMonitor = Prefs.DCMSset.DefaultIntentMonitor;
SoftProofing = Prefs.DCMSset.SoftProofOn;
Gamut = Prefs.DCMSset.GamutCheck;
BlackPoint = Prefs.DCMSset.BlackPoint;
IntentPrinter = Prefs.DCMSset.DefaultIntentPrinter;
IntentMonitor = Prefs.DCMSset.DefaultIntentMonitor;
doc->OpenCMSProfiles(InputProfiles, MonitorProfiles, PrinterProfiles);
stdProofG = doc->stdProof;
stdTransG = doc->stdTrans;
stdProofImgG = doc->stdProofImg;
stdTransImgG = doc->stdTransImg;
stdProofCMYKG = doc->stdProofCMYK;
stdTransCMYKG = doc->stdTransCMYK;
stdTransRGBG = doc->stdTransRGB;
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 (Prefs.DCMSset.CMSinUse)
RecalcColors();
}
doc->setPage(width, h, tpr, lr, rr, br, sp, ab, atf, fp);
doc->loading = false;
slotNewPage(0);
doc->loading = true;
HaveNewDoc();
doc->DocPages = doc->Pages;
doc->Pages = doc->MasterPages;
doc->pageCount = doc->MasterPages.count();
bool atfb = doc->PageAT;
doc->PageAT = false;
doc->MasterP = true;
slotNewPage(0);
doc->PageAT = atfb;
doc->MasterNames["Normal"] = 0;
doc->Pages.at(0)->setPageName("Normal");
doc->MasterPages = doc->Pages;
doc->pageCount = doc->DocPages.count();
doc->Pages = doc->DocPages;
doc->MasterP = false;
doc->Pages.at(0)->MPageNam = "Normal";
doc->setUnModified();
doc->loading = false;
doc->DocItems = doc->Items;
doc->currentPage = doc->Pages.at(0);
doc->OpenNodes.clear();
outlinePalette->BuildTree(doc);
pagePalette->Rebuild();
bookmarkPalette->BView->clear();
if ( wsp->windowList().isEmpty() )
w->showMaximized();
else
w->show();
view->show();
connect(doc->ASaveTimer, 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)));
doc->AutoSave = Prefs.AutoSave;
doc->AutoSaveTime = Prefs.AutoSaveTime;
if (doc->AutoSave)
doc->ASaveTimer->start(Prefs.AutoSaveTime);
scrActions["fileSave"]->setEnabled(false);
undoManager->switchStack(doc->DocName);
return true;
}
void ScribusApp::newView()
{
ScribusWin* w = new ScribusWin(wsp, doc);
view = new ScribusView(w, doc, &Prefs);
view->Scale = 1.0*Prefs.DisScale;
w->setView(view);
ActWin = w;
w->setCentralWidget(view);
connect(undoManager, SIGNAL(undoRedoDone()), view, SLOT(DrawNew()));
connect(w, SIGNAL(Schliessen()), this, SLOT(DoFileClose()));
}
bool ScribusApp::DoSaveClose()
{
return slotFileSave();
}
void ScribusApp::windowsMenuAboutToShow()
{
for( QMap<QString, QGuardedPtr<ScrAction> >::Iterator it = scrWindowsActions.begin(); it!=scrWindowsActions.end(); ++it )
scrMenuMgr->removeMenuItem((*it), "Windows");
scrWindowsActions.clear();
scrMenuMgr->clearMenu("Windows");
scrWindowsActions.insert("windowsCascade", new ScrAction(tr("&Cascade"), QKeySequence(), this, "windowsCascade"));
scrWindowsActions.insert("windowsTile", new ScrAction(tr("&Tile"), QKeySequence(), this, "windowstile"));
connect( scrWindowsActions["windowsCascade"], SIGNAL(activated()) , wsp, SLOT(cascade()) );
connect( scrWindowsActions["windowsTile"], SIGNAL(activated()) , wsp, SLOT(tile()) );
scrMenuMgr->addMenuItem(scrWindowsActions["windowsCascade"], "Windows");
scrMenuMgr->addMenuItem(scrWindowsActions["windowsTile"], "Windows");
scrMenuMgr->addMenuSeparator("Windows");
if ( wsp->windowList().isEmpty() )
{
scrWindowsActions["windowsCascade"]->setEnabled(false);
scrWindowsActions["windowsTile"]->setEnabled(false);
}
QWidgetList windows = wsp->windowList();
for ( int i = 0; i < static_cast<int>(windows.count()); ++i )
{
QString docInWindow=windows.at(i)->caption();
scrWindowsActions.insert(docInWindow, new ScrAction( ScrAction::Window, QIconSet(), 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 ScribusApp::newActWin(QWidget *w)
{
if (w == NULL)
{
ActWin = NULL;
return;
}
QString oldDocName = "";
if (ActWin && ActWin->doc)
oldDocName = ActWin->doc->DocName;
ActWin = (ScribusWin*)w;
/* if (doc != NULL)
{
if ((HaveDoc) && (doc != ActWin->doc))
doc->OpenNodes = outlinePalette->buildReopenVals();
} */
docCheckerPalette->clearErrorList();
QString newDocName = "";
if (ActWin && ActWin->doc)
newDocName = ActWin->doc->DocName;
if (oldDocName != newDocName)
undoManager->switchStack(newDocName);
if (view!=NULL)
actionManager->disconnectNewViewActions();
doc = ActWin->doc;
view = ActWin->view;
actionManager->connectNewViewActions(view);
pagePalette->SetView(view);
ScribusWin* swin;
if (!doc->loading)
{
scanDocument();
docCheckerPalette->buildErrorList(doc);
SwitchWin();
QWidgetList windows = wsp->windowList();
for ( int i = 0; i < static_cast<int>(windows.count()); ++i )
{
swin = (ScribusWin*)windows.at(i);
if (swin->muster != NULL)
swin->muster->hide();
}
if (doc->masterPageMode)
ActWin->muster->show();
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);
if (!doc->masterPageMode)
pagePalette->Rebuild();
outlinePalette->BuildTree(doc);
// outlinePalette->reopenTree(doc->OpenNodes);
bookmarkPalette->BView->NrItems = doc->NrItems;
bookmarkPalette->BView->First = doc->First;
bookmarkPalette->BView->Last = doc->Last;
RestoreBookMarks();
if (!doc->loading)
{
if (view->SelItem.count() != 0)
{
HaveNewSel(view->SelItem.at(0)->itemType());
view->EmitValues(view->SelItem.at(0));
}
else
HaveNewSel(-1);
}
}
void ScribusApp::windowsMenuActivated( int id )
{
if (HaveDoc)
doc->OpenNodes = outlinePalette->buildReopenVals();
QWidget* windowWidget = wsp->windowList().at( id );
if ( windowWidget )
windowWidget->showNormal();
newActWin(windowWidget);
}
bool ScribusApp::SetupDoc()
{
bool fp = doc->PageFP;
double tpr2, lr2, rr2, br2;
bool ret = false;
ReformDoc* dia = new ReformDoc(this, doc);
if (dia->exec())
{
slotChangeUnit(dia->unitCombo->currentItem(), false);
tpr2 = dia->topR->value() / doc->unitRatio;
lr2 = dia->leftR->value() / doc->unitRatio;
rr2 = dia->rightR->value() / doc->unitRatio;
br2 = dia->bottomR->value() / doc->unitRatio;
fp = dia->facingPages->isChecked();
if (fp)
doc->FirstPageLeft = dia->firstPage->isChecked();
doc->FirstPnum = dia->pageNumber->value();
doc->resetPage(tpr2, lr2, rr2, br2, fp);
doc->guidesSettings.before = dia->tabGuides->inBackground->isChecked();
doc->marginColored = dia->checkUnprintable->isChecked();
doc->papColor = dia->colorPaper;
doc->guidesSettings.marginsShown = dia->tabGuides->marginBox->isChecked();
doc->guidesSettings.framesShown = dia->checkFrame->isChecked();
doc->guidesSettings.gridShown = dia->tabGuides->checkGrid->isChecked();
doc->guidesSettings.guidesShown = dia->tabGuides->guideBox->isChecked();
doc->guidesSettings.baseShown = dia->tabGuides->baselineBox->isChecked();
doc->guidesSettings.showPic = dia->checkPictures->isChecked();
doc->guidesSettings.linkShown = dia->checkLink->isChecked();
doc->guidesSettings.grabRad = dia->tabGuides->grabDistance->value();
doc->guidesSettings.guideRad = dia->tabGuides->snapDistance->value() / doc->unitRatio;
doc->guidesSettings.minorGrid = dia->tabGuides->minorSpace->value() / doc->unitRatio;
doc->guidesSettings.majorGrid = dia->tabGuides->majorSpace->value() / doc->unitRatio;
doc->guidesSettings.minorColor = dia->tabGuides->colorMinorGrid;
doc->guidesSettings.majorColor = dia->tabGuides->colorMajorGrid;
doc->guidesSettings.margColor = dia->tabGuides->colorMargin;
doc->guidesSettings.guideColor = dia->tabGuides->colorGuides;
doc->guidesSettings.baseColor = dia->tabGuides->colorBaselineGrid;
doc->checkerProfiles = dia->tabDocChecker->checkerProfile;
doc->curCheckProfile = dia->tabDocChecker->curCheckProfile->currentText();
doc->typographicSetttings.valueSuperScript = dia->tabTypo->superDisplacement->value();
doc->typographicSetttings.scalingSuperScript = dia->tabTypo->superScaling->value();
doc->typographicSetttings.valueSubScript = dia->tabTypo->subDisplacement->value();
doc->typographicSetttings.scalingSubScript = dia->tabTypo->subScaling->value();
doc->typographicSetttings.valueSmallCaps = dia->tabTypo->capsScaling->value();
doc->typographicSetttings.autoLineSpacing = dia->tabTypo->autoLine->value();
doc->typographicSetttings.valueBaseGrid = dia->tabGuides->baseGrid->value() / doc->unitRatio;
doc->typographicSetttings.offsetBaseGrid = dia->tabGuides->baseOffset->value() / doc->unitRatio;
doc->typographicSetttings.valueUnderlinePos = dia->tabTypo->underlinePos->value();
doc->typographicSetttings.valueUnderlineWidth = dia->tabTypo->underlineWidth->value();
doc->typographicSetttings.valueStrikeThruPos = dia->tabTypo->strikethruPos->value();
doc->typographicSetttings.valueStrikeThruWidth = dia->tabTypo->strikethruWidth->value();
doc->toolSettings.defFont = dia->tabTools->fontComboText->currentText();
doc->toolSettings.defSize = dia->tabTools->sizeComboText->currentText().left(2).toInt() * 10;
doc->toolSettings.dStrokeText = dia->tabTools->colorComboStrokeText->currentText();
if (doc->toolSettings.dStrokeText == tr("None"))
doc->toolSettings.dStrokeText = "None";
doc->toolSettings.dPenText = dia->tabTools->colorComboText->currentText();
if (doc->toolSettings.dPenText == tr("None"))
doc->toolSettings.dPenText = "None";
doc->toolSettings.dCols = dia->tabTools->columnsText->value();
doc->toolSettings.dGap = dia->tabTools->gapText->value() / doc->unitRatio;
doc->toolSettings.dPen = dia->tabTools->colorComboLineShape->currentText();
if (doc->toolSettings.dPen == tr("None"))
doc->toolSettings.dPen = "None";
doc->toolSettings.dBrush = dia->tabTools->comboFillShape->currentText();
if (doc->toolSettings.dBrush == tr("None"))
doc->toolSettings.dBrush = "None";
doc->toolSettings.dShade = dia->tabTools->shadingFillShape->value();
doc->toolSettings.dShade2 = dia->tabTools->shadingLineShape->value();
switch (dia->tabTools->comboStyleShape->currentItem())
{
case 0:
doc->toolSettings.dLineArt = SolidLine;
break;
case 1:
doc->toolSettings.dLineArt = DashLine;
break;
case 2:
doc->toolSettings.dLineArt = DotLine;
break;
case 3:
doc->toolSettings.dLineArt = DashDotLine;
break;
case 4:
doc->toolSettings.dLineArt = DashDotDotLine;
break;
}
doc->toolSettings.dWidth = dia->tabTools->lineWidthShape->value();
doc->toolSettings.dStartArrow = dia->tabTools->startArrow->currentItem();
doc->toolSettings.dEndArrow = dia->tabTools->endArrow->currentItem();
doc->toolSettings.magMin = dia->tabTools->minimumZoom->value();
doc->toolSettings.magMax = dia->tabTools->maximumZoom->value();
doc->toolSettings.magStep = dia->tabTools->zoomStep->value();
doc->toolSettings.dPenLine = dia->tabTools->colorComboLine->currentText();
if (doc->toolSettings.dPenLine == tr("None"))
doc->toolSettings.dPenLine = "None";
doc->toolSettings.dShadeLine = dia->tabTools->shadingLine->value();
switch (dia->tabTools->comboStyleLine->currentItem())
{
case 0:
doc->toolSettings.dLstyleLine = SolidLine;
break;
case 1:
doc->toolSettings.dLstyleLine = DashLine;
break;
case 2:
doc->toolSettings.dLstyleLine = DotLine;
break;
case 3:
doc->toolSettings.dLstyleLine = DashDotLine;
break;
case 4:
doc->toolSettings.dLstyleLine = DashDotDotLine;
break;
}
doc->toolSettings.dWidthLine = dia->tabTools->lineWidthLine->value();
doc->toolSettings.dBrushPict = dia->tabTools->comboFillImage->currentText();
if (doc->toolSettings.dBrushPict == tr("None"))
doc->toolSettings.dBrushPict = "None";
doc->toolSettings.shadePict = dia->tabTools->shadingFillImage->value();
doc->toolSettings.scaleX = static_cast<double>(dia->tabTools->scalingHorizontal->value()) / 100.0;
doc->toolSettings.scaleY = static_cast<double>(dia->tabTools->scalingVertical->value()) / 100.0;
doc->toolSettings.scaleType = dia->tabTools->buttonGroup3->isChecked();
doc->toolSettings.aspectRatio = dia->tabTools->checkRatioImage->isChecked();
doc->toolSettings.useEmbeddedPath = dia->tabTools->embeddedPath->isChecked();
int haRes = 0;
if (dia->tabTools->checkFullRes->isChecked())
haRes = 0;
if (dia->tabTools->checkNormalRes->isChecked())
haRes = 1;
if (dia->tabTools->checkHalfRes->isChecked())
haRes = 2;
if (doc->toolSettings.lowResType != haRes)
{
doc->toolSettings.lowResType = haRes;
view->RecalcPicturesRes();
}
dia->tabTools->polyWidget->getValues(&doc->toolSettings.polyC, &doc->toolSettings.polyFd, &doc->toolSettings.polyF, &doc->toolSettings.polyS, &doc->toolSettings.polyR);
doc->ScratchBottom = dia->bottomScratch->value() / doc->unitRatio;
doc->ScratchLeft = dia->leftScratch->value() / doc->unitRatio;
doc->ScratchRight = dia->rightScratch->value() / doc->unitRatio;
doc->ScratchTop = dia->topScratch->value() / doc->unitRatio;
doc->AutoSave = dia->groupAutoSave->isChecked();
doc->AutoSaveTime = dia->autoSaveTime->value() * 60 * 1000;
if (doc->AutoSave)
{
doc->ASaveTimer->stop();
doc->ASaveTimer->start(doc->AutoSaveTime);
}
doc->docHyphenator->slotNewDict(dia->tabHyphenator->language->currentText());
doc->docHyphenator->slotNewSettings(dia->tabHyphenator->wordLen->value(),
!dia->tabHyphenator->verbose->isChecked(),
dia->tabHyphenator->input->isChecked(),
dia->tabHyphenator->maxCount->value());
if (CMSavail)
{
dia->tabColorManagement->setValues();
if (dia->tabColorManagement->changed)
{
FMess->setText( tr("Adjusting Colors"));
FProg->reset();
int cc = doc->PageColors.count() + view->CountElements();
FProg->setTotalSteps(cc);
#ifdef HAVE_CMS
doc->HasCMS = doc->CMSSettings.CMSinUse;
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;
BlackPoint = doc->CMSSettings.BlackPoint;
IntentPrinter = doc->CMSSettings.DefaultIntentPrinter;
IntentMonitor = doc->CMSSettings.DefaultIntentMonitor;
qApp->setOverrideCursor(QCursor(waitCursor), true);
doc->CloseCMSProfiles();
doc->OpenCMSProfiles(InputProfiles, MonitorProfiles, PrinterProfiles);
stdProofG = doc->stdProof;
stdTransG = doc->stdTrans;
stdProofImgG = doc->stdProofImg;
stdTransImgG = doc->stdTransImg;
stdProofCMYKG = doc->stdProofCMYK;
stdTransCMYKG = doc->stdTransCMYK;
stdTransRGBG = doc->stdTransRGB;
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;
doc->PDF_Options.SolidProf = doc->CMSSettings.DefaultInputProfile2;
doc->PDF_Options.ImageProf = doc->CMSSettings.DefaultInputProfile;
doc->PDF_Options.PrintProf = doc->CMSSettings.DefaultPrinterProfile;
doc->PDF_Options.Intent = doc->CMSSettings.DefaultIntentMonitor;
RecalcColors(FProg);
view->RecalcPictures(&InputProfiles, FProg);
#endif
FProg->setProgress(cc);
qApp->setOverrideCursor(QCursor(arrowCursor), true);
FMess->setText("");
FProg->reset();
}
}
uint a = 0;
SCFontsIterator it(Prefs.AvailFonts);
for ( ; it.current() ; ++it)
{
it.current()->EmbedPS = dia->tabFonts->fontFlags[it.currentKey()].FlagPS;
it.current()->UseFont = dia->tabFonts->fontFlags[it.currentKey()].FlagUse;
it.current()->Subset = dia->tabFonts->fontFlags[it.currentKey()].FlagSub;
}
a = 0;
QMap<QString,QString>::Iterator itfsu;
Prefs.GFontSub.clear();
for (itfsu = dia->tabFonts->RList.begin(); itfsu != dia->tabFonts->RList.end(); ++itfsu)
{
Prefs.GFontSub[itfsu.key()] = dia->tabFonts->FlagsRepl.at(a)->currentText();
a++;
}
QStringList uf = doc->UsedFonts.keys();
QMap<QString,QFont>::Iterator it3;
for (it3 = doc->UsedFonts.begin(); it3 != doc->UsedFonts.end(); ++it3)
{
FT_Done_Face(doc->FFonts[it3.key()]);
}
doc->UsedFonts.clear();
QStringList::Iterator it3a;
for (it3a = uf.begin(); it3a != uf.end(); ++it3a)
{
doc->AddFont((*it3a), Prefs.AvailFonts[(*it3a)]->Font);
}
FontSub->RebuildList(&Prefs, doc);
propertiesPalette->Fonts->RebuildList(&Prefs, doc);
doc->PDF_Options.Thumbnails = dia->tabPDF->CheckBox1->isChecked();
doc->PDF_Options.Compress = dia->tabPDF->Compression->isChecked();
doc->PDF_Options.CompressMethod = dia->tabPDF->CMethod->currentItem();
doc->PDF_Options.Quality = dia->tabPDF->CQuality->currentItem();
doc->PDF_Options.Resolution = dia->tabPDF->Resolution->value();
doc->PDF_Options.RecalcPic = dia->tabPDF->DSColor->isChecked();
doc->PDF_Options.PicRes = dia->tabPDF->ValC->value();
doc->PDF_Options.Bookmarks = dia->tabPDF->CheckBM->isChecked();
doc->PDF_Options.Binding = dia->tabPDF->ComboBind->currentItem();
doc->PDF_Options.MirrorH = dia->tabPDF->MirrorH->isOn();
doc->PDF_Options.MirrorV = dia->tabPDF->MirrorV->isOn();
doc->PDF_Options.RotateDeg = dia->tabPDF->RotateDeg->currentItem() * 90;
doc->PDF_Options.Articles = dia->tabPDF->Article->isChecked();
doc->PDF_Options.Encrypt = dia->tabPDF->Encry->isChecked();
doc->PDF_Options.UseLPI = dia->tabPDF->UseLPI->isChecked();
doc->PDF_Options.useLayers = dia->tabPDF->useLayers->isChecked();
doc->PDF_Options.BleedBottom = dia->tabPDF->BleedBottom->value() / doc->unitRatio;
doc->PDF_Options.BleedTop = dia->tabPDF->BleedTop->value() / doc->unitRatio;
doc->PDF_Options.BleedLeft = dia->tabPDF->BleedLeft->value() / doc->unitRatio;
doc->PDF_Options.BleedRight = dia->tabPDF->BleedRight->value() / doc->unitRatio;
if (dia->tabPDF->Encry->isChecked())
{
int Perm = -64;
if (dia->tabPDF->PDFVersionCombo->currentItem() == 1)
Perm &= ~0x00240000;
if (dia->tabPDF->PrintSec->isChecked())
Perm +=