Rev 1957 |
Rev 1973 |
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 "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"
//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;
PrefsFile* prefsFile;
ScribusApp::ScribusApp()
{} // 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;
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();
initFileMenuActions();
initEditMenuActions();
initStyleMenuActions();
initItemMenuActions();
initInsertMenuActions();
initPageMenuActions();
initViewMenuActions();
initToolsMenuActions();
initExtrasMenuActions();
initWindowsMenuActions();
initScriptMenuActions();
initHelpMenuActions();
initSpecialActions();
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("Getting ICC Profiles"));
CMSavail = false;
GetCMSProfiles();
initCMS();
if (splashScreen != NULL)
splashScreen->setStatus( tr("Init 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.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 = 9;
Prefs.RandUnten = 40;
Prefs.RandLinks = 9;
Prefs.RandRechts = 9;
Prefs.FacingPages = false;
Prefs.LeftPageFirst = false;
Prefs.toolSettings.scaleType = true;
Prefs.toolSettings.aspectRatio = true;
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.TemplateDir = "";
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.gimp_exe = "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 = 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 )
{
SetKeyEntry(it.key(), it.data()->cleanMenuText(), QString(it.data()->accel()),0);
//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);
scrapbookPalette->BibWin->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(SetTranspar(double)));
connect(propertiesPalette->Cpal, SIGNAL(NewTransS(double)), this, SLOT(SetTransparS(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(rescan()), this, SLOT(slotCheckDoc()));
connect(docCheckerPalette, SIGNAL(selectElement(int, int)), this, SLOT(SelectFromOutl(int, int)));
connect(docCheckerPalette, SIGNAL(selectPage(int)), this, SLOT(SelectFromOutlS(int)));
connect(docCheckerPalette, SIGNAL(selectTemplatePage(QString)), this, SLOT(ManageTemp(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(selectTemplatePage(QString)), this, SLOT(ManageTemp(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(ManageTemp(QString)));
connect(pagePalette->PageView, SIGNAL(UseTemp(QString, int)), this, SLOT(Apply_Temp(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->BibWin->ReadContents(scrapbookFile);
scrapbookPalette->ScFilename = 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"),
QObject::tr("You are running a development version of Scribus 1.3.x.\nThe process of saving will make files originating from versions of\nScribus of 1.2.x or lower unusable again in those versions.\nAre you sure you wish to proceed with this operation?"),
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::initFileMenuActions()
{
//File Menu
scrActions.insert("fileNew", new ScrAction(QIconSet(loadIcon("DateiNeu16.png"), loadIcon("DateiNeu.xpm")), tr("&New"), CTRL+Key_N, this, "fileNew"));
scrActions.insert("fileOpen", new ScrAction(QIconSet(loadIcon("DateiOpen16.png"), loadIcon("DateiOpen.xpm")), tr("&Open..."), CTRL+Key_O, this, "fileOpen"));
scrActions.insert("fileClose", new ScrAction(QIconSet(loadIcon("DateiClos16.png"), loadIcon("DateiClose.png")), tr("&Close"), CTRL+Key_W, this, "fileClose"));
scrActions.insert("fileSave", new ScrAction(QIconSet(loadIcon("DateiSave16.png"), loadIcon("DateiSave2.png")), tr("&Save"), CTRL+Key_S, this, "fileSave"));
scrActions.insert("fileSaveAs", new ScrAction(QPixmap(loadIcon("filesaveas.png")), tr("Save &As..."), CTRL+SHIFT+Key_S, this, "fileSaveAs"));
scrActions.insert("fileRevert", new ScrAction(QPixmap(loadIcon("revert.png")), tr("Re&vert to Saved"), QKeySequence(), this, "fileRevert"));
scrActions.insert("fileCollect", new ScrAction(tr("Collect for O&utput..."), QKeySequence(), this, "fileCollect"));
//File Import Menu
scrActions.insert("fileImportText", new ScrAction(tr("Get Text..."), QKeySequence(), this, "fileImportText"));
scrActions.insert("fileImportAppendText", new ScrAction(tr("Append &Text..."), QKeySequence(), this, "fileImportAppendText"));
scrActions.insert("fileImportImage", new ScrAction(tr("Get Image..."), QKeySequence(), this, "fileImportImage"));
scrActions.insert("fileImportPage", new ScrAction(tr("Import Page(s)..."), QKeySequence(), this, "fileImportPage"));
//File Export Menu
scrActions.insert("fileExportText", new ScrAction(tr("Save &Text..."), QKeySequence(), this, "fileExportText"));
scrActions.insert("fileExportAsEPS", new ScrAction(tr("Save Page as &EPS..."), QKeySequence(), this, "fileExportAsEPS"));
scrActions.insert("fileExportAsPDF", new ScrAction(loadIcon("acrobat.png"), tr("Save as P&DF..."), QKeySequence(), this, "fileExportAsPDF"));
//Rest of File Menu
scrActions.insert("fileDocInfo", new ScrAction(loadIcon("documentinfo.png"), tr("Document &Information..."), CTRL+Key_I, this, "fileDocInfo"));
scrActions.insert("fileDocSetup", new ScrAction(tr("Document &Setup..."), QKeySequence(), this, "fileDocSetup"));
scrActions.insert("filePrint", new ScrAction(QIconSet(loadIcon("DateiPrint16.png"), loadIcon("DateiPrint.xpm")), tr("&Print..."), CTRL+Key_P, this, "filePrint"));
scrActions.insert("fileQuit", new ScrAction(QPixmap(loadIcon("exit.png")), tr("&Quit"), CTRL+Key_Q, this, "fileQuit"));
//Connect our signals and slots
//File Menu
connect( scrActions["fileNew"], SIGNAL(activated()) , this, SLOT(slotFileNew()) );
connect( scrActions["fileOpen"], SIGNAL(activated()) , this, SLOT(slotDocOpen()) );
connect( scrActions["fileClose"], SIGNAL(activated()) , this, SLOT(slotFileClose()) );
connect( scrActions["filePrint"], SIGNAL(activated()) , this, SLOT(slotFilePrint()) );
connect( scrActions["fileSave"], SIGNAL(activated()) , this, SLOT(slotFileSave()) );
connect( scrActions["fileSaveAs"], SIGNAL(activated()) , this, SLOT(slotFileSaveAs()) );
connect( scrActions["fileDocInfo"], SIGNAL(activated()) , this, SLOT(InfoDoc()) );
connect( scrActions["fileDocSetup"], SIGNAL(activated()) , this, SLOT(SetupDoc()) );
connect( scrActions["fileRevert"], SIGNAL(activated()) , this, SLOT(slotFileRevert()) );
connect( scrActions["fileCollect"], SIGNAL(activated()) , this, SLOT(Collect()) );
connect( scrActions["fileQuit"], SIGNAL(activated()) , this, SLOT(slotFileQuit()) );
//File Import Menu
connect( scrActions["fileImportText"], SIGNAL(activated()) , this, SLOT(slotFileOpen()) );
connect( scrActions["fileImportAppendText"], SIGNAL(activated()) , this, SLOT(slotFileAppend()) );
connect( scrActions["fileImportImage"], SIGNAL(activated()) , this, SLOT(slotFileOpen()) );
connect( scrActions["fileImportPage"], SIGNAL(activated()) , this, SLOT(slotDocMerge()) );
//File Export Menu
connect( scrActions["fileExportText"], SIGNAL(activated()) , this, SLOT(SaveText()) );
connect( scrActions["fileExportAsEPS"], SIGNAL(activated()) , this, SLOT(SaveAsEps()) );
connect( scrActions["fileExportAsPDF"], SIGNAL(activated()) , this, SLOT(SaveAsPDF()) );
//The rest are plugins
}
void ScribusApp::initEditMenuActions()
{
//Edit Menu
scrActions.insert("editUndoAction", new ScrAction(ScrAction::DataInt, QIconSet(loadIcon("u_undo16.png"), loadIcon("u_undo.png")), tr("&Undo"), CTRL+Key_Z, this, "editUndoAction",1));
scrActions.insert("editRedoAction", new ScrAction(ScrAction::DataInt, QIconSet(loadIcon("u_redo16.png"), loadIcon("u_redo.png")), tr("&Redo"), CTRL+SHIFT+Key_Z, this, "editRedoAction", 1));
scrActions.insert("editActionMode", new ScrAction(tr("&Item Action Mode"), QKeySequence(), this, "editActionMode"));
scrActions["editActionMode"]->setToggleAction(true);
scrActions.insert("editCut", new ScrAction(QIconSet(loadIcon("editcut.png"), loadIcon("editcut.png")), tr("Cu&t"), CTRL+Key_X, this, "editCut"));
scrActions.insert("editCopy", new ScrAction(QIconSet(loadIcon("editcopy.png"), loadIcon("editcopy.png")), tr("&Copy"), CTRL+Key_C, this, "editCopy"));
scrActions.insert("editPaste", new ScrAction(QIconSet(loadIcon("editpaste.png"), loadIcon("editpaste.png")), tr("&Paste"), CTRL+Key_V, this, "editPaste"));
scrActions.insert("editClearContents", new ScrAction(QIconSet(loadIcon("editdelete.png"), loadIcon("editdelete.png")), tr("C&lear Contents"), QKeySequence(), this, "editClearContents"));
scrActions.insert("editSelectAll", new ScrAction(tr("Select &All"), CTRL+Key_A, this, "editSelectAll"));
scrActions.insert("editDeselectAll", new ScrAction(tr("&Deselect All"), CTRL+SHIFT+Key_A, this, "editDeselectAll"));
scrActions.insert("editSearchReplace", new ScrAction(QIconSet(loadIcon("find16.png"), loadIcon("find16.png")), tr("&Search/Replace..."), QKeySequence(CTRL+Key_F), this, "editSearchReplace"));
scrActions.insert("editColors", new ScrAction(tr("C&olors..."), QKeySequence(), this, "editColors"));
scrActions.insert("editParaStyles", new ScrAction(tr("&Paragraph Styles..."), QKeySequence(), this, "editParaStyles"));
scrActions.insert("editLineStyles", new ScrAction(tr("&Line Styles..."), QKeySequence(), this, "editLineStyles"));
scrActions.insert("editTemplates", new ScrAction(tr("&Templates..."), QKeySequence(), this, "editTemplates"));
scrActions.insert("editJavascripts", new ScrAction(tr("&Javascripts..."), QKeySequence(), this, "editJavascripts"));
scrActions.insert("editPreferences", new ScrAction(tr("P&references..."), QKeySequence(), this, "editPreferences"));
connect( scrActions["editUndoAction"], SIGNAL(activatedData(int)) , undoManager, SLOT(undo(int)) );
connect( scrActions["editRedoAction"], SIGNAL(activatedData(int)) , undoManager, SLOT(redo(int)) );
connect( scrActions["editActionMode"], SIGNAL(toggled(bool)) , this, SLOT(setUndoMode(bool)) );
connect( scrActions["editCut"], SIGNAL(activated()) , this, SLOT(slotEditCut()) );
connect( scrActions["editCopy"], SIGNAL(activated()) , this, SLOT(slotEditCopy()) );
connect( scrActions["editPaste"], SIGNAL(activated()) , this, SLOT(slotEditPaste()) );
connect( scrActions["editClearContents"], SIGNAL(activated()) , this, SLOT(clearContents()) );
connect( scrActions["editSelectAll"], SIGNAL(activated()) , this, SLOT(SelectAll()) );
connect( scrActions["editDeselectAll"], SIGNAL(activated()) , this, SLOT(deselectAll()) );
connect( scrActions["editSearchReplace"], SIGNAL(activated()), this, SLOT(SearchText()) );
connect( scrActions["editColors"], SIGNAL(activated()) , this, SLOT(slotEditColors()) );
connect( scrActions["editParaStyles"], SIGNAL(activated()) , this, SLOT(slotEditStyles()) );
connect( scrActions["editLineStyles"], SIGNAL(activated()) , this, SLOT(slotEditLineStyles()) );
connect( scrActions["editTemplates"], SIGNAL(activated()) , this, SLOT(ManageTemp()) );
connect( scrActions["editJavascripts"], SIGNAL(activated()) , this, SLOT(ManageJava()) );
connect( scrActions["editPreferences"], SIGNAL(activated()) , this, SLOT(slotPrefsOrg()) );
}
void ScribusApp::initStyleMenuActions()
{
//Text Size actions
scrActionGroups.insert("fontSize", new QActionGroup(this, "fontSize", true));
scrActions.insert("fontSizeOther", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Other..."), QKeySequence(), scrActionGroups["fontSize"], "fontSizeOther", -1));
connect(scrActions["fontSizeOther"], SIGNAL(activatedData(int)), this, SLOT(setItemFSize(int)));
int font_sizes[] = {7, 9, 10, 11, 12, 14, 18, 24, 36, 48, 60, 72};
size_t f_size = sizeof(font_sizes) / sizeof(*font_sizes);
for (uint s = 0; s < f_size; ++s)
{
QString fontSizeName=QString("fontSize%1").arg(font_sizes[s]);
scrActions.insert(fontSizeName, new ScrAction(ScrAction::DataInt, QIconSet(), tr("%1 pt").arg(font_sizes[s]), QKeySequence(), scrActionGroups["fontSize"], fontSizeName, font_sizes[s]));
scrActions[fontSizeName]->setToggleAction(true);
connect(scrActions[fontSizeName], SIGNAL(activatedData(int)), this, SLOT(setItemFSize(int)));
}
//Alignment actions
scrActions.insert("alignLeft", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Left"), QKeySequence(), this, "alignLeft", 0));
scrActions.insert("alignCenter", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Center"), QKeySequence(), this, "alignCenter", 1));
scrActions.insert("alignRight", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Right"), QKeySequence(), this, "alignRight", 2));
scrActions.insert("alignBlock", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Block"), QKeySequence(), this, "alignBlock", 3));
scrActions.insert("alignForced", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Forced"), QKeySequence(), this, "alignForced", 4));
scrActions["alignLeft"]->setToggleAction(true);
scrActions["alignCenter"]->setToggleAction(true);
scrActions["alignRight"]->setToggleAction(true);
scrActions["alignBlock"]->setToggleAction(true);
scrActions["alignForced"]->setToggleAction(true);
connect(scrActions["alignLeft"], SIGNAL(activatedData(int)), this, SLOT(setNewAbStyle(int)));
connect(scrActions["alignCenter"], SIGNAL(activatedData(int)), this, SLOT(setNewAbStyle(int)));
connect(scrActions["alignRight"], SIGNAL(activatedData(int)), this, SLOT(setNewAbStyle(int)));
connect(scrActions["alignBlock"], SIGNAL(activatedData(int)), this, SLOT(setNewAbStyle(int)));
connect(scrActions["alignForced"], SIGNAL(activatedData(int)), this, SLOT(setNewAbStyle(int)));
//Shade actions
scrActionGroups.insert("shade", new QActionGroup(this, "shade", true));
scrActions.insert("shadeOther", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Other..."), QKeySequence(), scrActionGroups["shade"], "shadeOther", -1));
connect(scrActions["shadeOther"], SIGNAL(activatedData(int)), this, SLOT(setItemShade(int)));
for (uint i=0; i<=100 ; i+=10)
{
QString shadeName=QString("shade%1").arg(i);
scrActions.insert(shadeName, new ScrAction(ScrAction::DataInt, QIconSet(), tr("&%1 %").arg(i), QKeySequence(), scrActionGroups["shade"], shadeName, i));
scrActions[shadeName]->setToggleAction(true);
connect(scrActions[shadeName], SIGNAL(activatedData(int)), this, SLOT(setItemShade(int)));
}
//Type Effects actions
scrActionGroups.insert("typeEffects", new QActionGroup(this, "typeEffects", false));
scrActions.insert("typeEffectNormal", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Normal"), QKeySequence(), scrActionGroups["typeEffects"], "typeEffectNormal", 0));
scrActions.insert("typeEffectUnderline", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Underline"), QKeySequence(), scrActionGroups["typeEffects"], "typeEffectUnderline", 1));
scrActions.insert("typeEffectStrikeThrough", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Strike Through"), QKeySequence(), scrActionGroups["typeEffects"], "typeEffectStrikeThrough", 2));
scrActions.insert("typeEffectSmallCaps", new ScrAction(ScrAction::DataInt, QIconSet(), tr("Small &Caps"), QKeySequence(), scrActionGroups["typeEffects"], "typeEffectSmallCaps", 3));
scrActions.insert("typeEffectSuperscript", new ScrAction(ScrAction::DataInt, QIconSet(), tr("Su&perscript"), QKeySequence(), scrActionGroups["typeEffects"], "typeEffectSuperscript", 4));
scrActions.insert("typeEffectSubscript", new ScrAction(ScrAction::DataInt, QIconSet(), tr("Su&bscript"), QKeySequence(), scrActionGroups["typeEffects"], "typeEffectSubscript", 5));
scrActions.insert("typeEffectOutline", new ScrAction(ScrAction::DataInt, QIconSet(), tr("&Outline"), QKeySequence(), scrActionGroups["typeEffects"], "typeEffectOutline", 6));
scrActions["typeEffectNormal"]->setToggleAction(true);
scrActions["typeEffectUnderline"]->setToggleAction(true);
scrActions["typeEffectStrikeThrough"]->setToggleAction(true);
scrActions["typeEffectSmallCaps"]->setToggleAction(true);
scrActions["typeEffectSuperscript"]->setToggleAction(true);
scrActions["typeEffectSubscript"]->setToggleAction(true);
scrActions["typeEffectOutline"]->setToggleAction(true);
connect(scrActions["typeEffectNormal"], SIGNAL(activatedData(int)), this, SLOT(setItemTypeStyle(int)));
connect(scrActions["typeEffectUnderline"], SIGNAL(activatedData(int)), this, SLOT(setItemTypeStyle(int)));
connect(scrActions["typeEffectStrikeThrough"], SIGNAL(activatedData(int)), this, SLOT(setItemTypeStyle(int)));
connect(scrActions["typeEffectSmallCaps"], SIGNAL(activatedData(int)), this, SLOT(setItemTypeStyle(int)));
connect(scrActions["typeEffectSuperscript"], SIGNAL(activatedData(int)), this, SLOT(setItemTypeStyle(int)));
connect(scrActions["typeEffectSubscript"], SIGNAL(activatedData(int)), this, SLOT(setItemTypeStyle(int)));
connect(scrActions["typeEffectOutline"], SIGNAL(activatedData(int)), this, SLOT(setItemTypeStyle(int)));
//Other Style menu items that get added in various places
scrActions.insert("styleInvertPict", new ScrAction(tr("&Invert"), QKeySequence(), this, "styleInvertPict"));
scrActions.insert("styleTabulators", new ScrAction(tr("&Tabulators..."), QKeySequence(), this, "styleTabulators"));
connect(scrActions["styleInvertPict"], SIGNAL(activated()), this, SLOT(InvertPict()));
connect(scrActions["styleTabulators"], SIGNAL(activated()), this, SLOT(EditTabs()));
}
void ScribusApp::initItemMenuActions()
{
//Item Menu
scrActions.insert("itemDuplicate", new ScrAction(tr("D&uplicate"), CTRL+Key_D, this, "itemDuplicate"));
scrActions.insert("itemMulDuplicate", new ScrAction(tr("&Multiple Duplicate"), QKeySequence(), this, "itemMulDuplicate"));
scrActions.insert("itemDelete", new ScrAction(tr("&Delete"), CTRL+Key_K, this, "itemDelete"));
scrActions.insert("itemGroup", new ScrAction(tr("&Group"), CTRL+Key_G, this, "itemGroup"));
scrActions.insert("itemUngroup", new ScrAction(tr("&Ungroup"), CTRL+Key_U, this, "itemUngroup"));
scrActions.insert("itemLock", new ScrAction(tr("Is &Locked"), CTRL+Key_L, this, "itemLock"));
scrActions.insert("itemLockSize", new ScrAction(tr("Si&ze is Locked"), CTRL+SHIFT+Key_L, this, "itemLockSize"));
scrActions["itemLock"]->setToggleAction(true);
scrActions["itemLockSize"]->setToggleAction(true);
scrActions.insert("itemSendToBack", new ScrAction(tr("Send to &Back"), QKeySequence(Key_End), this, "itemSendToBack"));
scrActions.insert("itemBringToFront", new ScrAction(tr("Bring to &Front"), QKeySequence(Key_Home), this, "itemBringToFront"));
scrActions.insert("itemLower", new ScrAction(tr("&Lower"), QKeySequence(Key_PageDown), this, "itemLower"));
scrActions.insert("itemRaise", new ScrAction(tr("&Raise"), QKeySequence(Key_PageUp), this, "itemRaise"));
scrActions.insert("itemAlignDist", new ScrAction(tr("Distribute/&Align..."), QKeySequence(), this, "itemAlignDist"));
scrActions.insert("itemAttributes", new ScrAction(tr("&Attributes..."), QKeySequence(), this, "itemAttributes"));
scrActions.insert("itemShapeEdit", new ScrAction(tr("&Edit Shape..."), QKeySequence(), this, "itemShapeEdit"));
scrActions["itemShapeEdit"]->setToggleAction(true);
scrActions.insert("itemAttachTextToPath", new ScrAction(tr("&Attach Text to Path"), QKeySequence(), this, "itemAttachTextToPath"));
scrActions.insert("itemDetachTextFromPath", new ScrAction(tr("&Detach Text from Path"), QKeySequence(), this, "itemDetachTextFromPath"));
scrActions.insert("itemCombinePolygons", new ScrAction(tr("&Combine Polygons"), QKeySequence(), this, "itemCombinePolygons"));
scrActions.insert("itemSplitPolygons", new ScrAction(tr("Split &Polygons"), QKeySequence(), this, "itemSplitPolygons"));
scrActions.insert("itemConvertToBezierCurve", new ScrAction(tr("&Bezier Curve"), QKeySequence(), this, "itemConvertToBezierCurve"));
scrActions.insert("itemConvertToImageFrame", new ScrAction(tr("&Image Frame"), QKeySequence(), this, "itemConvertToImageFrame"));
scrActions.insert("itemConvertToOutlines", new ScrAction(tr("&Outlines"), QKeySequence(), this, "itemConvertToOutlines"));
scrActions.insert("itemConvertToPolygon", new ScrAction(tr("&Polygon"), QKeySequence(), this, "itemConvertToPolygon"));
scrActions.insert("itemConvertToTextFrame", new ScrAction(tr("&Text Frame"), QKeySequence(), this, "itemConvertToTextFrame"));
connect( scrActions["itemDuplicate"], SIGNAL(activated()) , this, SLOT(ObjektDup()) );
connect( scrActions["itemMulDuplicate"], SIGNAL(activated()) , this, SLOT(ObjektDupM()) );
connect( scrActions["itemDelete"], SIGNAL(activated()) , this, SLOT(DeleteObjekt()) );
connect( scrActions["itemGroup"], SIGNAL(activated()) , this, SLOT(GroupObj()) );
connect( scrActions["itemUngroup"], SIGNAL(activated()) , this, SLOT(UnGroupObj()) );
connect( scrActions["itemLock"], SIGNAL(activated()) , this, SLOT(ToggleObjLock()) );
connect( scrActions["itemLockSize"], SIGNAL(activated()) , this, SLOT(ToggleObjSizeLock()) );
connect( scrActions["itemSendToBack"], SIGNAL(activated()) , this, SLOT(Objekt2Back()) );
connect( scrActions["itemBringToFront"], SIGNAL(activated()) , this, SLOT(Objekt2Front()) );
connect( scrActions["itemLower"], SIGNAL(activated()) , this, SLOT(ObjektLower()) );
connect( scrActions["itemRaise"], SIGNAL(activated()) , this, SLOT(ObjektRaise()) );
connect( scrActions["itemAlignDist"], SIGNAL(activated()) , this, SLOT(ObjektAlign()) );
connect( scrActions["itemAttributes"], SIGNAL(activated()) , this, SLOT(objectAttributes()) );
connect( scrActions["itemShapeEdit"], SIGNAL(activated()) , this, SLOT(ToggleFrameEdit()) );
connect( scrActions["itemAttachTextToPath"], SIGNAL(activated()) , this, SLOT(Pfadtext()) );
connect( scrActions["itemDetachTextFromPath"], SIGNAL(activated()) , this, SLOT(noPfadtext()) );
connect( scrActions["itemCombinePolygons"], SIGNAL(activated()) , this, SLOT(UniteOb()) );
connect( scrActions["itemSplitPolygons"], SIGNAL(activated()) , this, SLOT(SplitUniteOb()) );
connect( scrActions["itemConvertToBezierCurve"], SIGNAL(activated()) , this, SLOT(convertToBezierCurve()) );
connect( scrActions["itemConvertToImageFrame"], SIGNAL(activated()) , this, SLOT(convertToImageFrame()) );
connect( scrActions["itemConvertToOutlines"], SIGNAL(activated()) , this, SLOT(convertToOutlines()) );
connect( scrActions["itemConvertToPolygon"], SIGNAL(activated()) , this, SLOT(convertToPolygon()) );
connect( scrActions["itemConvertToTextFrame"], SIGNAL(activated()) , this, SLOT(convertToTextFrame()) );
}
void ScribusApp::initInsertMenuActions()
{
//Insert Menu
scrActions.insert("insertGlyph", new ScrAction(tr("&Glyph..."), QKeySequence(), this, "insertGlyph"));
//scrActions["insertGlyph"]->setText(tr("Insert Special Character"));
scrActions.insert("insertSampleText", new ScrAction(tr("Sample Text"), QKeySequence(), this, "insertSampleText"));
connect( scrActions["insertGlyph"], SIGNAL(activated()) , this, SLOT(slotCharSelect()) );
connect( scrActions["insertSampleText"], SIGNAL(activated()) , this, SLOT(insertSampleText()) );
}
void ScribusApp::initPageMenuActions()
{
//Page menu
scrActions.insert("pageInsert", new ScrAction(tr("&Insert..."), QKeySequence(), this, "pageInsert"));
scrActions.insert("pageDelete", new ScrAction(tr("&Delete..."), QKeySequence(), this, "pageDelete"));
scrActions.insert("pageCopy", new ScrAction(tr("&Copy..."), QKeySequence(), this, "pageCopy"));
scrActions.insert("pageMove", new ScrAction(tr("&Move..."), QKeySequence(), this, "pageMove"));
scrActions.insert("pageApplyTemplate", new ScrAction(tr("&Apply Template..."), QKeySequence(), this, "pageApplyTemplate"));
scrActions.insert("pageManageGuides", new ScrAction(tr("Manage &Guides..."), QKeySequence(), this, "pageManageGuides"));
connect( scrActions["pageInsert"], SIGNAL(activated()) , this, SLOT(slotNewPageM()) );
connect( scrActions["pageDelete"], SIGNAL(activated()) , this, SLOT(DeletePage()) );
connect( scrActions["pageCopy"], SIGNAL(activated()) , this, SLOT(CopyPage()) );
connect( scrActions["pageMove"], SIGNAL(activated()) , this, SLOT(MovePage()) );
connect( scrActions["pageApplyTemplate"], SIGNAL(activated()) , this, SLOT(ApplyTemp()) );
connect( scrActions["pageManageGuides"], SIGNAL(activated()) , this, SLOT(ManageGuides()) );
}
void ScribusApp::initViewMenuActions()
{
scrActions.insert("viewFitInWindow", new ScrAction(ScrAction::DataDouble, QIconSet(), tr("&Fit in window"), CTRL+Key_0, this, "viewFitInWindow", 0, -100.0));
scrActions.insert("viewFit50", new ScrAction(ScrAction::DataDouble, QIconSet(), tr("&50%"), QKeySequence(), this, "viewFit50", 0, 50.0));
scrActions.insert("viewFit75", new ScrAction(ScrAction::DataDouble, QIconSet(), tr("&75%"), QKeySequence(), this, "viewFit75", 0, 75.0));
scrActions.insert("viewFit100", new ScrAction(ScrAction::DataDouble, QIconSet(), tr("&100%"), CTRL+Key_1, this, "viewFit100", 0, 100.0));
scrActions.insert("viewFit200", new ScrAction(ScrAction::DataDouble, QIconSet(), tr("&200%"), QKeySequence(), this, "viewFit200", 0, 200.0));
scrActions.insert("viewFit20", new ScrAction(ScrAction::DataDouble, QIconSet(), tr("&Thumbnails"), QKeySequence(), this, "viewFit20", 0, 20.0));
scrActions.insert("viewShowMargins", new ScrAction(tr("Show &Margins"), QKeySequence(), this, "viewShowMargins"));
scrActions.insert("viewShowFrames", new ScrAction(tr("Show &Frames"), QKeySequence(), this, "viewShowFrames"));
scrActions.insert("viewShowImages", new ScrAction(tr("Show &Images"), QKeySequence(), this, "viewShowImages"));
scrActions.insert("viewShowGrid", new ScrAction(tr("Show &Grid"), QKeySequence(), this, "viewShowGrid"));
scrActions.insert("viewShowGuides", new ScrAction(tr("Show G&uides"), QKeySequence(), this, "viewShowGuides"));
scrActions.insert("viewShowBaseline", new ScrAction(tr("Show &Baseline Grid"), QKeySequence(), this, "viewShowBaseline"));
scrActions.insert("viewShowTextChain", new ScrAction(tr("Show &Text Chain"), QKeySequence(), this, "viewShowTextChain"));
scrActions.insert("viewSnapToGrid", new ScrAction(tr("Sn&ap to Grid"), QKeySequence(), this, "viewSnapToGrid"));
scrActions.insert("viewSnapToGuides", new ScrAction(tr("Sna&p to Guides"), QKeySequence(), this, "viewSnapToGuides"));
// scrActions.insert("viewNewView", new ScrAction(tr("New View"), QKeySequence(), this, "viewNewView"));
scrActions["viewShowMargins"]->setToggleAction(true);
scrActions["viewShowFrames"]->setToggleAction(true);
scrActions["viewShowImages"]->setToggleAction(true);
scrActions["viewShowGrid"]->setToggleAction(true);
scrActions["viewShowGuides"]->setToggleAction(true);
scrActions["viewShowBaseline"]->setToggleAction(true);
scrActions["viewShowTextChain"]->setToggleAction(true);
scrActions["viewSnapToGrid"]->setToggleAction(true);
scrActions["viewSnapToGuides"]->setToggleAction(true);
scrActions["viewShowMargins"]->setOn(true);
scrActions["viewShowFrames"]->setOn(true);
scrActions["viewShowImages"]->setOn(true);
scrActions["viewShowGuides"]->setOn(true);
connect( scrActions["viewFitInWindow"], SIGNAL(activatedData(double)) , this, SLOT(slotZoom(double)) );
connect( scrActions["viewFit50"], SIGNAL(activatedData(double)) , this, SLOT(slotZoom(double)) );
connect( scrActions["viewFit75"], SIGNAL(activatedData(double)) , this, SLOT(slotZoom(double)) );
connect( scrActions["viewFit100"], SIGNAL(activatedData(double)) , this, SLOT(slotZoom(double)) );
connect( scrActions["viewFit200"], SIGNAL(activatedData(double)) , this, SLOT(slotZoom(double)) );
connect( scrActions["viewFit20"], SIGNAL(activatedData(double)) , this, SLOT(slotZoom(double)) );
connect( scrActions["viewShowMargins"], SIGNAL(activated()) , this, SLOT(ToggleMarks()) );
connect( scrActions["viewShowFrames"], SIGNAL(activated()) , this, SLOT(ToggleFrames()) );
connect( scrActions["viewShowImages"], SIGNAL(activated()) , this, SLOT(TogglePics()) );
connect( scrActions["viewShowGrid"], SIGNAL(activated()) , this, SLOT(ToggleRaster()) );
connect( scrActions["viewShowGuides"], SIGNAL(activated()) , this, SLOT(ToggleGuides()) );
connect( scrActions["viewShowBaseline"], SIGNAL(activated()) , this, SLOT(ToggleBase()) );
connect( scrActions["viewShowTextChain"], SIGNAL(activated()) , this, SLOT(ToggleTextLinks()) );
connect( scrActions["viewSnapToGrid"], SIGNAL(activated()) , this, SLOT(ToggleURaster()) );
connect( scrActions["viewSnapToGuides"], SIGNAL(activated()) , this, SLOT(ToggleUGuides()) );
// connect( scrActions["viewNewView"], SIGNAL(activated()) , this, SLOT(newView()) );
}
void ScribusApp::initToolsMenuActions()
{
//Tool menu
scrActions.insert("toolsProperties", new ScrAction(tr("&Properties"), QKeySequence(), this, "toolsProperties"));
scrActions.insert("toolsOutline", new ScrAction(tr("&Outline"), QKeySequence(), this, "toolsOutline"));
scrActions.insert("toolsScrapbook", new ScrAction(tr("&Scrapbook"), QKeySequence(), this, "toolsScrapbook"));
scrActions.insert("toolsLayers", new ScrAction(tr("&Layers"), QKeySequence(Key_F6), this, "toolsLayers"));
scrActions.insert("toolsPages", new ScrAction(tr("P&age Palette"), QKeySequence(), this, "toolsPages"));
scrActions.insert("toolsBookmarks", new ScrAction(tr("&Bookmarks"), QKeySequence(), this, "toolsBookmarks"));
scrActions.insert("toolsMeasurements", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("dist.png"), loadIcon("dist.png")), tr("&Measurements"), QKeySequence(), this, "toolsMeasurements", MeasurementTool));
scrActions.insert("toolsActionHistory", new ScrAction(tr("Action &History"), QKeySequence(), this, "toolsActionHistory"));
scrActions.insert("toolsPreflightVerifier", new ScrAction(QIconSet(loadIcon("launch16.png"), loadIcon("launch.png")),tr("Preflight &Verifier"), QKeySequence(), this, "toolsPreflightVerifier"));
scrActions.insert("toolsToolbarTools", new ScrAction(tr("&Tools"), QKeySequence(), this, "toolsToolbarTools"));
scrActions.insert("toolsToolbarPDF", new ScrAction(tr("P&DF Tools"), QKeySequence(), this, "toolsToolbarPDF"));
//toolbar only items
scrActions.insert("toolsSelect", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Kreuz.xpm"), loadIcon("Kreuz.xpm")), tr("Select Item"), QKeySequence(Key_C), this, "toolsSelect", NormalMode));
scrActions.insert("toolsInsertTextFrame", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Text16.xpm"), loadIcon("Text.xpm")), tr("&Text Frame"), QKeySequence(Key_T), this, "toolsInsertTextFrame", DrawText));
scrActions.insert("toolsInsertImageFrame", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Bild16.xpm"), loadIcon("Bild.xpm")), tr("&Image Frame"), QKeySequence(Key_I), this, "toolsInsertImageFrame", DrawPicture));
scrActions.insert("toolsInsertTableFrame", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("frame_table16.png"), loadIcon("frame_table.png")), tr("T&able"), QKeySequence(Key_A), this, "toolsInsertTableFrame", DrawTable));
scrActions.insert("toolsInsertShape", new ScrAction(ScrAction::DataInt,QIconSet(), tr("&Shape"), QKeySequence(Key_S), this, "toolsInsertShape", DrawShapes));
scrActions.insert("toolsInsertPolygon", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("spline16.png"), loadIcon("spline.png")), tr("&Polygon"), QKeySequence(Key_P), this, "toolsInsertPolygon", DrawRegularPolygon));
scrActions.insert("toolsInsertLine", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Stift16.xpm"), loadIcon("Stift.xpm")), tr("&Line"), QKeySequence(Key_L), this, "toolsInsertLine", DrawLine));
scrActions.insert("toolsInsertBezier", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("beziertool16.png"), loadIcon("beziertool.png")), tr("&Bezier Curve"), QKeySequence(Key_B), this, "toolsInsertBezier", DrawBezierLine));
scrActions.insert("toolsInsertFreehandLine", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Stiftalt16.xpm"), loadIcon("Stiftalt.xpm")), tr("&Freehand Line"), QKeySequence(Key_F), this, "toolsInsertFreehandLine", DrawFreehandLine));
scrActions["toolsInsertTextFrame"]->setText(tr("Insert Text Frame"));
scrActions["toolsInsertImageFrame"]->setText(tr("Insert Image Frame"));
scrActions["toolsInsertTableFrame"]->setText(tr("Insert Table"));
scrActions["toolsInsertShape"]->setText(tr("Insert Shape"));
scrActions["toolsInsertPolygon"]->setText(tr("Insert Polygon"));
scrActions["toolsInsertLine"]->setText(tr("Insert Line"));
scrActions["toolsInsertBezier"]->setText(tr("Insert Bezier Curve"));
scrActions["toolsInsertFreehandLine"]->setText(tr("Insert Freehand Line"));
scrActions.insert("toolsRotate", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Rotieren.xpm"), loadIcon("Rotieren.xpm")), tr("Rotate Item"), QKeySequence(Key_R), this, "toolsRotate", Rotation));
scrActions.insert("toolsZoom", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Lupe.xpm"), loadIcon("Lupe.xpm")), tr("Zoom in or out"), QKeySequence(Key_Z), this, "toolsZoom", Magnifier));
scrActions.insert("toolsZoomIn", new ScrAction(QIconSet(loadIcon("Gross.xpm"), loadIcon("Gross.xpm")), tr("Zoom in"), QKeySequence(CTRL+Key_Plus), this, "toolsZoomIn"));
scrActions.insert("toolsZoomOut", new ScrAction(QIconSet(loadIcon("Klein.xpm"), loadIcon("Klein.xpm")), tr("Zoom out"), QKeySequence(CTRL+Key_Minus), this, "toolsZoomOut"));
scrActions.insert("toolsEditContents", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Editm.xpm"), loadIcon("Editm.xpm")), tr("Edit Contents of Frame"), QKeySequence(Key_E), this, "toolsEditContents", EditMode));
scrActions.insert("toolsEditWithStoryEditor", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("signature.png"), loadIcon("signature.png")), tr("Edit the text with the Story Editor"), QKeySequence(CTRL+Key_Y), this, "toolsEditWithStoryEditor", StartStoryEditor));
scrActions.insert("toolsLinkTextFrame", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Lock.xpm"), loadIcon("Lock.xpm")), tr("Link Text Frames"), QKeySequence(Key_N), this, "toolsLinkTextFrame", LinkFrames));
scrActions.insert("toolsUnlinkTextFrame", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("Unlock.xpm"), loadIcon("Unlock.xpm")), tr("Unlink Text Frames"), QKeySequence(Key_U), this, "toolsUnlinkTextFrame", UnlinkFrames));
scrActions.insert("toolsEyeDropper", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("colorpicker.png"), loadIcon("colorpicker.png")), tr("&Eye Dropper"), QKeySequence(Key_Y), this, "toolsEyeDropper", EyeDropper));
scrActions.insert("toolsCopyProperties", new ScrAction(ScrAction::DataInt,QIconSet(loadIcon("wizard.png"), loadIcon("wizard.png")), tr("Copy Item Properties"), QKeySequence(), this, "toolsCopyProperties", CopyProperties));
scrActions["toolsProperties"]->setToggleAction(true);
scrActions["toolsOutline"]->setToggleAction(true);
scrActions["toolsScrapbook"]->setToggleAction(true);
scrActions["toolsLayers"]->setToggleAction(true);
scrActions["toolsPages"]->setToggleAction(true);
scrActions["toolsBookmarks"]->setToggleAction(true);
scrActions["toolsMeasurements"]->setToggleAction(true);
scrActions["toolsActionHistory"]->setToggleAction(true);
scrActions["toolsPreflightVerifier"]->setToggleAction(true);
scrActions["toolsToolbarTools"]->setToggleAction(true);
scrActions["toolsToolbarPDF"]->setToggleAction(true);
scrActions["toolsSelect"]->setToggleAction(true);
scrActions["toolsInsertTextFrame"]->setToggleAction(true);
scrActions["toolsInsertImageFrame"]->setToggleAction(true);
scrActions["toolsInsertTableFrame"]->setToggleAction(true);
scrActions["toolsInsertShape"]->setToggleAction(true);
scrActions["toolsInsertPolygon"]->setToggleAction(true);
scrActions["toolsInsertLine"]->setToggleAction(true);
scrActions["toolsInsertBezier"]->setToggleAction(true);
scrActions["toolsInsertFreehandLine"]->setToggleAction(true);
scrActions["toolsRotate"]->setToggleAction(true);
scrActions["toolsZoom"]->setToggleAction(true);
scrActions["toolsEditContents"]->setToggleAction(true);
scrActions["toolsEditWithStoryEditor"]->setToggleAction(true);
scrActions["toolsLinkTextFrame"]->setToggleAction(true);
scrActions["toolsUnlinkTextFrame"]->setToggleAction(true);
scrActions["toolsEyeDropper"]->setToggleAction(true);
scrActions["toolsCopyProperties"]->setToggleAction(true);
modeActionNames=new QStringList();
*modeActionNames << "toolsSelect" << "toolsInsertTextFrame" << "toolsInsertImageFrame" << "toolsInsertTableFrame";
*modeActionNames << "toolsInsertShape" << "toolsInsertPolygon" << "toolsInsertLine" << "toolsInsertBezier";
*modeActionNames << "toolsInsertFreehandLine" << "toolsRotate" << "toolsZoom" << "toolsEditContents";
*modeActionNames << "toolsEditWithStoryEditor" << "toolsLinkTextFrame" << "toolsUnlinkTextFrame";
*modeActionNames << "toolsEyeDropper" << "toolsCopyProperties";
nonEditActionNames=new QStringList();
*modeActionNames << "itemSendToBack" << "itemBringToFront" << "itemRaise" << "itemLower";
connect( scrActions["toolsActionHistory"], SIGNAL(toggled(bool)) , this, SLOT(setUndoPalette(bool)) );
connect( scrActions["toolsToolbarTools"], SIGNAL(toggled(bool)) , this, SLOT(setTools(bool)) );
connect( scrActions["toolsToolbarPDF"], SIGNAL(toggled(bool)) , this, SLOT(setPDFTools(bool)) );
connectModeActions();
}
void ScribusApp::initExtrasMenuActions()
{
scrActions.insert("extrasManagePictures", new ScrAction(tr("&Manage Pictures"), QKeySequence(), this, "extrasManagePictures"));
scrActions.insert("extrasHyphenateText", new ScrAction(tr("&Hyphenate Text"), QKeySequence(), this, "extrasHyphenateText"));
scrActions.insert("extrasGenerateTableOfContents", new ScrAction(tr("&Generate Table Of Contents"), QKeySequence(), this, "extrasGenerateTableOfContents"));
connect( scrActions["extrasManagePictures"], SIGNAL(activated()) , this, SLOT(StatusPic()) );
connect( scrActions["extrasHyphenateText"], SIGNAL(activated()) , this, SLOT(doHyphenate()) );
connect( scrActions["extrasGenerateTableOfContents"], SIGNAL(activated()) , this, SLOT(generateTableOfContents()) );
}
void ScribusApp::initWindowsMenuActions()
{
}
void ScribusApp::initScriptMenuActions()
{
}
void ScribusApp::initHelpMenuActions()
{
scrActions.insert("helpAboutScribus", new ScrAction(tr("&About Scribus"), QKeySequence(), this, "helpAboutScribus"));
scrActions.insert("helpAboutQt", new ScrAction(tr("About &Qt"), QKeySequence(), this, "helpAboutQt"));
scrActions.insert("helpTooltips", new ScrAction(tr("Toolti&ps"), QKeySequence(), this, "helpTooltips"));
scrActions.insert("helpManual", new ScrAction(tr("Scribus &Manual..."), Key_F1, this, "helpManual"));
scrActions["helpTooltips"]->setToggleAction(true);
scrActions["helpTooltips"]->setOn(true);
connect( scrActions["helpAboutScribus"], SIGNAL(activated()) , this, SLOT(slotHelpAbout()) );
connect( scrActions["helpAboutQt"], SIGNAL(activated()) , this, SLOT(slotHelpAboutQt()) );
connect( scrActions["helpTooltips"], SIGNAL(activated()) , this, SLOT(ToggleTips()) );
connect( scrActions["helpManual"], SIGNAL(activated()) , this, SLOT(slotOnlineHelp()) );
}
void ScribusApp::initSpecialActions()
{
//typography
scrActions.insert("specialSmartHyphen", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Smart &Hyphen"), CTRL+SHIFT+Key_Minus, this, "specialSmartHyphen",-1));
scrActions.insert("specialNonBreakingSpace", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Non Breaking &Space"), CTRL+Key_Space, this, "specialNonBreakingSpace",29));
scrActions.insert("specialPageNumber", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Page &Number"), CTRL+SHIFT+ALT+Key_P, this, "specialPageNumber",30));
scrActions.insert("specialCopyRight", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Copyright"), QKeySequence(), this, "specialCopyRight",0x0A9));
scrActions.insert("specialRegdTM", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Registered Trademark"), QKeySequence(), this, "specialRegdTM",0x00AE));
scrActions.insert("specialTM", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Trademark"), QKeySequence(), this, "specialTM",0x2122));
scrActions.insert("specialBullet", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Bullet"), QKeySequence(), this, "specialBullet",0x2022));
scrActions.insert("specialDashEm", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Em Dash"), QKeySequence(), this, "specialDashEm",0x2014));
scrActions.insert("specialDashEn", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("En Dash"), QKeySequence(), this, "specialDashEn",0x2013));
scrActions.insert("specialDashFigure", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Figure Dash"), QKeySequence(), this, "specialDashFigure",0x2012));
scrActions.insert("specialDashQuotation", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Quotation Dash"), QKeySequence(), this, "specialDashQuotation",0x2015));
scrActions.insert("specialQuoteDoubleLeft", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Double Left Quote"), QKeySequence(), this, "specialQuoteDoubleLeft",0x201C));
scrActions.insert("specialQuoteDoubleRight", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Double Right Quote"), QKeySequence(), this, "specialQuoteDoubleRight",0x201D));
scrActions.insert("specialQuoteSingleLeft", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Single Left Quote"), QKeySequence(), this, "specialQuoteSingleLeft",0x2018));
scrActions.insert("specialQuoteSingleRight", new ScrAction(ScrAction::UnicodeChar, QIconSet(), tr("Single Right Quote"), QKeySequence(), this, "specialQuoteSingleRight",0x2019));
scrActions["specialSmartHyphen"]->setText("Insert Smart Hyphen");
scrActions["specialNonBreakingSpace"]->setText("Insert Non Breaking Space");
scrActions["specialPageNumber"]->setText("Insert Page Number");
unicodeCharActionNames=new QStringList();
*unicodeCharActionNames << "specialSmartHyphen" << "specialNonBreakingSpace" << "specialPageNumber";
*unicodeCharActionNames << "specialCopyRight" << "specialRegdTM" << "specialTM";
*unicodeCharActionNames << "specialBullet";
*unicodeCharActionNames << "specialDashEm" << "specialDashEn" << "specialDashFigure" << "specialDashQuotation";
*unicodeCharActionNames << "specialQuoteDoubleLeft" << "specialQuoteDoubleRight" << "specialQuoteSingleLeft" << "specialQuoteSingleRight";
for ( QStringList::Iterator it = unicodeCharActionNames->begin(); it != unicodeCharActionNames->end(); ++it )
connect( scrActions[*it], SIGNAL(activatedUnicodeShortcut(QString, int)), this, SLOT(specialActionKeyEvent(QString, int)) );
//GUI
scrActions.insert("specialToggleAllPalettes", new ScrAction(ScrAction::DataQString, QIconSet(), tr("Toggle Palettes"), Key_F10, this, "specialToggleAllPalettes",0,0.0,"specialToggleAllPalettes"));
scrActions.insert("specialToggleAllGuides", new ScrAction(ScrAction::DataQString, QIconSet(), tr("Toggle Guides"), Key_F11, this, "specialToggleAllGuides",0,0.0,"specialToggleAllGuides"));
connect( scrActions["specialToggleAllPalettes"], SIGNAL(activated()) , this, SLOT(ToggleAllPalettes()) );
connect( scrActions["specialToggleAllGuides"], SIGNAL(activated()) , this, SLOT(ToggleAllGuides()) );
}
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->addMenuItem(scrActions["fileImportPage"], "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["fileImportPage"]->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->addMenuSeparator("Edit");
scrMenuMgr->addMenuItem(scrActions["editColors"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editParaStyles"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editLineStyles"], "Edit");
scrMenuMgr->addMenuItem(scrActions["editTemplates"], "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["editTemplates"]->setEnabled(false);
scrActions["editJavascripts"]->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->addMenuSeparator("Item");
scrMenuMgr->createMenu("ItemLevel", tr("&Level"));
scrMenuMgr->addMenuToMenu("ItemLevel", "Item");
scrMenuMgr->addMenuItem(scrActions["itemSendToBack"], "ItemLevel");
scrMenuMgr->addMenuItem(scrActions["itemBringToFront"], "ItemLevel");
scrMenuMgr->addMenuItem(scrActions["itemLower"], "ItemLevel");
scrMenuMgr->addMenuItem(scrActions["itemRaise"], "ItemLevel");
scrMenuMgr->addMenuItem(scrActions["itemAlignDist"], "Item");
scrMenuMgr->addMenuSeparator("Item");
scrMenuMgr->addMenuItem(scrActions["itemAttributes"], "Item");
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);
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->addMenuSeparator("Insert");
scrMenuMgr->addMenuItem(scrActions["specialSmartHyphen"], "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->addMenuSeparator("InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleLeft"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialQuoteDoubleRight"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialQuoteSingleLeft"], "InsertChar");
scrMenuMgr->addMenuItem(scrActions["specialQuoteSingleRight"], "InsertChar");
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["pageDelete"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageCopy"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageMove"], "Page");
scrMenuMgr->addMenuItem(scrActions["pageApplyTemplate"], "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::ReportMP(double xp, double yp)
{
QString suffix=unitGetSuffixFromIndex(doc->docUnitIndex);
int multiplier=unitGetDecimalsFromIndex(doc->docUnitIndex);
double divisor = static_cast<double>(multiplier);
int precision=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::DeleteSel(PageItem *currItem)
{
int FirstSel = 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)
FirstSel++;
}
if (currItem->itemText.count() != 0)
{
if (currItem->itemText.first()->cselect)
{
currItem->itemText.remove();
currItem->CPos = 0;
}
else
currItem->CPos = FirstSel;
}
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 & 127;
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();
break;
case Key_Prior:
if (!currItem->locked())
view->RaiseItem();
break;
case Key_Next:
if (!currItem->locked())
view->LowerItem();
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);
}
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);
}
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);
}
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);
}
break;
default:
break;
}
slotDocCh();
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)
DeleteSel(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 & 256)
{
currItem->CPos -= 1;
while ((currItem->CPos > 0) && (currItem->itemText.at(currItem->CPos)->cstyle & 256))
{
currItem->CPos--;
if (currItem->CPos == 0)
break;
}
}
}
else
{
while ((currItem->CPos > 0) && (currItem->itemText.at(currItem->CPos)->cstyle & 256))
{
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)
{
DeleteSel(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)
DeleteSel(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)
{
DeleteSel(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)
DeleteSel(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))
DeleteSel(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)