Scribus
Open source desktop publishing at your fingertips
scribus.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 /***************************************************************************
8  scribus.h - description
9  -------------------
10  begin : Fre Apr 6 21:09:31 CEST 2001
11  copyright : (C) 2001 by Franz Schmid
12  email : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 
15 /***************************************************************************
16  * *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or *
20  * (at your option) any later version. *
21  * *
22  ***************************************************************************/
23 
24 #ifndef SCRIBUS_H
25 #define SCRIBUS_H
26 
27 #define VERS13x
28 
29 // include from stl
30 #include <vector>
31 
32 // include files for QT
33 
34 #include <QActionGroup>
35 #include <QClipboard>
36 #include <QKeyEvent>
37 #include <QMainWindow>
38 #include <QMap>
39 #include <QMultiHash>
40 #include <QPixmap>
41 #include <QPointer>
42 #include <QPushButton>
43 #include <QProcess>
44 #include <QString>
45 
46 class QCloseEvent;
47 class QDragEnterEvent;
48 class QDropEvent;
49 class QEvent;
50 class QKeyEvent;
51 class QLabel;
52 class QMdiArea;
53 class QMdiSubWindow;
54 class QQuickView;
55 
56 // application specific includes
57 #include "scribusapi.h"
58 #include "scribusdoc.h"
59 #include "styleoptions.h"
60 #include "ui/customfdialog.h"
61 #include "ui/scmessagebox.h"
62 
63 class ActionManager;
65 class AppModeHelper;
66 class Autoforms;
67 class Biblio;
68 class BookPalette;
69 class CharSelect;
70 class CheckDocument;
71 class ColorCombo;
72 class DownloadsPalette;
73 class EditToolBar;
74 class FileToolBar;
75 class FontCombo;
76 class FormatsManager;
77 class GuideManager;
78 class HelpBrowser;
79 class InlinePalette;
80 class LayerPalette;
81 class MarksManager;
82 class Measurements;
83 class ModeToolBar;
84 class NodePalette;
85 class NotesStylesEditor;
86 class OutlinePalette;
87 class PDFToolBar;
88 class PSLib;
89 class PageItem;
90 class PagePalette;
91 class PageSelector;
92 class PrefsContext;
93 class PrefsManager;
94 class PropertiesPalette;
95 class ResourceManager;
96 class ScMWMenuManager;
97 class ScToolBar;
98 class ScrAction;
99 class ScrSpinBox;
100 class ScribusCore;
101 class ScribusDoc;
102 class ScribusMainWindow;
103 class ScribusQApp;
104 class ScribusWin;
105 class SimpleState;
106 class StoryEditor;
107 class StyleManager;
108 class SymbolPalette;
109 class TOCGenerator;
110 class UndoManager;
111 class UndoPalette;
112 class UndoState;
113 class ViewToolBar;
114 
115 extern SCRIBUS_API ScribusQApp* ScQApp;
116 
123 class SCRIBUS_API ScribusMainWindow : public QMainWindow, public UndoObject
124 {
125  Q_OBJECT
126 
127 public:
135  int initScMW(bool primaryMainwWindow);
136  void addScToolBar(ScToolBar *tb, QString name);
137  bool warningVersion(QWidget *parent);
138  void SetShortCut();
139  void startUpDialog();
140  void setDefaultPrinter(const QString&, const QString&, const QString&);
141  void getDefaultPrinter(QString& name, QString& file, QString& command);
142 
143  inline bool scriptIsRunning(void) const { return (ScriptRunning > 0); }
144  inline void setScriptRunning(bool value) { ScriptRunning += (value ? 1 : -1); }
145 
146  ScribusDoc *doFileNew(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount=1, bool showView=true, int marginPreset=0);
147  ScribusDoc *newDoc(double width, double height, double topMargin, double leftMargin, double rightMargin, double bottomMargin, double columnDistance, double columnCount, bool autoTextFrames, int pageArrangement, int unitIndex, int firstPageLocation, int orientation, int firstPageNumber, const QString& defaultPageSize, bool requiresGUI, int pageCount=1, bool showView=true, int marginPreset=0);
148  bool DoFileSave(const QString& fileName, QString* savedFileName = NULL);
149  void changeEvent(QEvent *e);
150  void closeEvent(QCloseEvent *ce);
151  void keyPressEvent(QKeyEvent *k);
152  void keyReleaseEvent(QKeyEvent *k);
153  void inputMethodEvent ( QInputMethodEvent * event );
154  QVariant inputMethodQuery ( Qt::InputMethodQuery query ) const ;
155  void requestUpdate(int);
156  void setTBvals(PageItem *currItem);
157  int ShowSubs();
158  void applyNewMaster(QString name);
159  void updateRecent(QString fn);
160  void doPasteRecent(QString data);
161  bool getPDFDriver(const QString & filename, const QString & name, int components, const std::vector<int> & pageNumbers, const QMap<int,QPixmap> & thumbs, QString& error, bool* cancelled = NULL);
162  bool DoSaveAsEps(QString fn, QString& error);
163  QString CFileDialog(QString workingDirectory = ".", QString dialogCaption = "", QString fileFilter = "", QString defNa = "",
164  int optionFlags = fdExistingFiles, bool *useCompression = 0, bool *useFonts = 0, bool *useProfiles = 0);
168  void recalcColors(QProgressBar *dia = 0);
169  void SwitchWin();
170  void RestoreBookMarks();
171  QStringList scrapbookNames();
172  void updateLayerMenu();
173  void emergencySave();
174 
179  bool arrowKeyDown();
184  bool isObjectSpecificUndo();
185  void restore(UndoState* state, bool isUndo);
186  void restoreGrouping(SimpleState *state, bool isUndo);
187  void restoreUngrouping(SimpleState *state, bool isUndo);
188  void restoreAddPage(SimpleState *state, bool isUndo);
189  void restoreDeletePage(SimpleState *state, bool isUndo);
190  void setPreviewToolbar();
191  struct CopyContentsBuffer contentsBuffer;
192  bool internalCopy;
193  QString internalCopyBuffer;
194  int HaveDoc;
195  PrefsContext* dirs;
208 
209 
210  QProgressBar* mainWindowProgressBar;
211  ScrSpinBox* zoomSpinBox; //zoom spinbox at bottom of view
212  PageSelector* pageSelector; //Page selector at bottom of view
213  QPushButton *zoomDefaultToolbarButton;
214  QPushButton *zoomOutToolbarButton;
215  QPushButton *zoomInToolbarButton;
216  QComboBox *layerMenu; //Menu for layers at bottom of view
217  QComboBox *unitSwitcher; //Menu for units at bottom of view
218  EditToolBar *editToolBar;
219  FileToolBar *fileToolBar;
220  ModeToolBar* modeToolBar;
221  PDFToolBar* pdfToolBar;
222  ViewToolBar* viewToolBar;
223  QLabel* mainWindowXPosLabel;
224  QLabel* mainWindowXPosDataLabel;
225  QLabel* mainWindowYPosLabel;
226  QLabel* mainWindowYPosDataLabel;
227  GuideManager *guidePalette;
228  CharSelect *charPalette;
229  PropertiesPalette *propertiesPalette;
230  MarksManager *marksManager;
231  NotesStylesEditor *nsEditor;
232  NodePalette *nodePalette;
233  OutlinePalette *outlinePalette;
234  Biblio *scrapbookPalette;
235  LayerPalette* layerPalette;
236  PagePalette *pagePalette;
237  BookPalette *bookmarkPalette;
238  DownloadsPalette *downloadsPalette;
239  SymbolPalette *symbolPalette;
240  InlinePalette *inlinePalette;
241  Measurements* measurementPalette;
242  CheckDocument * docCheckerPalette;
243  UndoPalette* undoPalette;
244  AlignDistributePalette *alignDistributePalette;
245  ResourceManager *resourceManager;
246  StoryEditor* storyEditor;
247  StoryEditor* CurrStED;
248  QMdiArea *mdiArea;
249  ScribusWin* ActWin;
250  QClipboard *ClipB;
251  QString LoadEnc;
252  AppModeHelper *appModeHelper;
253 
254  QProcess *ExternalApp;
255 
256  QMap<QString, QPointer<ScrAction> > scrActions;
257  QMap<QString, QPointer<ScrAction> > scrRecentFileActions;
258  QMap<QString, QPointer<ScrAction> > scrWindowsActions;
259  QMap<QString, QPointer<ScrAction> > scrScrapActions;
260  QMap<QString, QPointer<ScrAction> > scrLayersActions;
261  QMap<QString, QPointer<ScrAction> > scrRecentPasteActions;
262  QMap<QString, QPointer<ScToolBar> > scrToolBars;
263  QMultiHash<QString, QActionGroup*> scrActionGroups;
264  ScMWMenuManager* scrMenuMgr;
265  ActionManager* actionManager;
266  QStringList RecentDocs;
267  QStringList patternsDependingOnThis;
268 
269 public slots:
270  void languageChange();
271  void statusBarLanguageChange();
272  void specialActionKeyEvent(int unicodevalue);
273  void newView();
274  void ToggleStickyTools();
275  void ToggleAllGuides();
276  void ToggleAllPalettes();
277  void slotStoryEditor(bool fromTable);
278  void slotCharSelect();
279  void ImageEffects();
280  QString fileCollect(const bool compress = false, const bool withFonts = false, const bool withProfiles = false, const QString& newDirectory=QString::null);
281  void AddBookMark(PageItem *ite);
282  void DelBookMark(PageItem *ite);
283  void BookMarkTxT(PageItem *ite);
284  void StoreBookmarks();
285  void setStatusBarMousePosition(double xp, double yp);
286  void setStatusBarTextPosition(double base, double xp);
287  void setStatusBarTextSelectedItemInfo();
288  void setTempStatusBarText(const QString &text);
289  void setStatusBarInfoText(QString newText);
290  bool DoFileClose();
291  void windowsMenuAboutToShow();
293  void extrasMenuAboutToShow();
294  void newActWin(QMdiSubWindow *w);
295  void closeActiveWindowMasterPageEditor();
296  void updateActiveWindowCaption(const QString &newCaption);
297  void windowsMenuActivated(int id);
298  void PutScrap(int scID);
299  void PutToInline(QString buffer);
300  void PutToInline();
301  void PutToPatterns();
302  void ConvertToSymbol();
303  void changeLayer(int);
304  void setLayerMenuText(const QString &);
305  void showLayer();
306  void slotSetCurrentPage(int Seite);
307  void setCurrentPage(int p);
308  void ManageJava();
309  void editSelectedSymbolStart();
310  void editSymbolStart(QString temp);
311  void editSymbolEnd();
312  void editInlineStart(int id);
313  void editInlineEnd();
314  void editMasterPagesStart(QString temp = "");
315  void editMasterPagesEnd();
317  bool slotFileNew();
318  void newFileFromTemplate();
319  bool slotPageImport();
320  bool loadPage(QString fileName, int Nr, bool Mpa, const QString& renamedPageName=QString::null);
321  void GotoLa(int l);
322  void slotGetContent();
323  void slotGetContent2(); // kk2006
324  void slotGetClipboardImage();
325  void toogleInlineState();
330  void slotFileAppend();
331 
332  void removeRecent(QString fn, bool fromFileWatcher = false);
333  void removeRecentFromWatcher(QString filename);
334  void loadRecent(QString filename);
335  void rebuildRecentFileMenu();
336  void rebuildRecentPasteMenu();
337  void rebuildScrapbookMenu();
338  void pasteRecent(QString fn);
339  void pasteFromScrapbook(QString fn);
340  void importVectorFile();
341  void rebuildLayersList();
342  bool slotFileOpen();
343  bool loadDoc(QString);
347  bool postLoadDoc();
348  void slotAutoSaved();
350  bool slotFileSave();
352  bool slotFileSaveAs();
353  void slotFileRevert();
355  void SaveText();
357  bool slotFileClose();
359  void slotFilePrint();
360  void slotReallyPrint();
361  void slotEndSpecialEdit();
369  bool doPrint(PrintOptions &options, QString& error);
371  void slotFileQuit();
374  void slotEditCut();
376  void slotEditCopy();
378  void slotEditPaste();
379  void slotEditCopyContents();
380  void slotEditPasteContents(int absolute=0);
381  void EnableTxEdit();
382  void DisableTxEdit();
383  void SelectAll(bool docWideSelect=false);
384  void SelectAllOnLayer();
385  void deselectAll();
386  void ClipChange();
388  void slotHelpAbout();
389  void slotHelpAboutPlugins();
390  void slotHelpAboutQt();
391  void slotHelpCheckUpdates();
392  void slotRaiseOnlineHelp();
393  void slotOnlineHelp(const QString & jumpToSection=QString::null, const QString & jumpToFile=QString::null);
394  void slotOnlineHelpClosed();
395  void slotResourceManager();
396  void ToggleTips();
397  void ToggleMouseTips();
399  void slotNewPageP(int wo, QString templ);
400  void slotNewPageM();
401  void slotNewMasterPage(int w, const QString &);
402  void slotNewPage(int w, const QString& masterPageName=QString::null, bool mov = true);
403  void duplicateToMasterPage();
405  void deletePage();
411  void deletePage(int from, int to);
412  void deletePage2(int pg);
414  void movePage();
415  void copyPage();
416  void changePageProperties();
424  void slotZoom(double zoomFactor); // 20, 50, 100, or -100 for Fit
426  void toggleMarks();
427  void toggleBleeds();
428  void toggleFrames();
429  void toggleLayerMarkers();
430  void toggleTextLinks();
431  void toggleTextControls();
432  void toggleColumnBorders();
433  void toggleRulers();
434  void toggleRulerMode();
435  void togglePagePalette();
436  void toggleUndoPalette();
437  void setUndoPalette(bool visible);
438  void toggleCheckPal();
440  void toggleImageVisibility();
442  void toggleGrid();
444  void toggleSnapGrid();
446  void toggleNodeEdit();
447  void slotSelect();
450  //void setAppMode(int mode);
451  void setAppModeByToggle(bool isOn, int newMode);
453  void HaveNewDoc();
454  void HaveNewSel();
456  void slotDocCh(bool reb = true);
458  //void setItemShade(int id);
461  void SetNewFont(const QString& nf);
463  void setItemFontSize(int fontSize);
465  void slotReplaceColors();
469  void MakeFrame(int f, int c, double *vals);
471  void duplicateItem();
473  void duplicateItemMulti();
474 
475  void objectAttributes();
476  void getImageInfo();
477  void generateTableOfContents();
478  void updateDocument();
479 
480 // void saveStyles(StilFormate *dia); //still required for style save from SE
481  void setNewAlignment(int a);
482  void setNewParStyle(const QString& name);
483  void setNewCharStyle(const QString& name);
484  void setAlignmentValue(int a);
485  void editItemsFromOutlines(PageItem *ite);
486  //0= center, 1 = top left.
487  void selectItemsFromOutlines(PageItem *ite, bool single = false, int position = 0);
488  void selectItemFromOutlines(PageItem *ite, bool single, int cPos);
489  void selectPagesFromOutlines(int ScPage);
490  void doPrintPreview();
491  void printPreview();
492  void SaveAsEps();
493  void reallySaveAsEps();
494  void SaveAsPDF();
495  void doSaveAsPDF();
496  void setMainWindowActive();
497  void setItemEffects(int h);
498  void setStyleEffects(int s);
499  void setItemTypeStyle(int id);
500  void slotElemRead(QString Name, double x, double y, bool art, bool loca, ScribusDoc* docc, ScribusView* vie);
501  void slotChangeUnit(int art, bool draw = true);
506  void ApplyMasterPage();
507  void Apply_MasterPage(QString pageName, int pageNumber, bool reb = true);
508  void GroupObj(bool showLockDia = true);
509  void UnGroupObj();
510  void AdjustGroupObj();
511  void StatusPic();
512  void ModifyAnnot();
513  void toggleGuides();
514  void toggleBase();
515  void toggleSnapGuides();
516  void toggleSnapElements();
517  void SetSnapElements(bool b);
518  void EditTabs();
519  void SearchText();
520  void imageEditorExited(int, QProcess::ExitStatus);
522  void callImageEditor();
523  void docCheckToggle(bool visible);
525  bool scanDocument();
526  void setUndoMode(bool isObjectSpecific);
528  void insertSampleText();
529  void updateItemLayerList();
530  void updateColorLists();
533  void slotPrefsOrg();
536  void slotDocSetup();
538  void slotInsertFrame();
540  void slotItemTransform();
542  void managePaints();
544  StyleManager *styleMgr() const {return styleManager;};
546  void updateGUIAfterPagesChanged();
553  void updateTableMenuActions();
554  void emitUpdateRequest(int updateFlags) { emit UpdateRequest(updateFlags); }
555 
556  //inserting marks
557  void slotInsertMark2Mark() { insertMark(MARK2MarkType); }
558  void slotInsertMarkAnchor() { insertMark(MARKAnchorType); }
559  void slotInsertMarkVariableText() { insertMark(MARKVariableTextType); }
560  void slotInsertMarkItem() { insertMark(MARK2ItemType); }
561  void slotInsertMarkNote();
562  void slotInsertMarkIndex() { insertMark(MARKIndexType); }
563  void slotEditMark();
564  //connected to signal emited by actions when "Update Marks" menu item is triggered
565  void slotUpdateMarks();
566  bool editMarkDlg(Mark *mrk, PageItem_TextFrame* currItem = NULL);
567  void testQTQuick2_1();
568  void testQT_slot1(QString);
569  void testQT_slot2(double);
570  void testQT_slot3(int);
571  void testQT_slot4();
572  //void adjustCMS();
573  void changePreviewQuality(int index);
574  void enablePalettes(bool b);
575  void ToggleFrameEdit();
576  void NoFrameEdit();
577 
578 signals:
579  //void AppModeChanged(int oldMode, int newMode);
580  void TextStyle(const ParagraphStyle&);
581 //deprecated: (av)
582  void TextEffects(int);
583  void UpdateRequest(int updateFlags);
584  void changeLayers(int);
585 
586 protected:
590  bool eventFilter( QObject *o, QEvent *e );
591  virtual void dragEnterEvent( QDragEnterEvent* e);
592  virtual void dropEvent( QDropEvent* e);
593 
594 private:
596  void initSplash(bool showSplash);
597  void initMenuBar(); // initMenuBar creates the menu_bar and inserts the menuitems
598  void createMenuBar();
599  void addDefaultWindowMenuItems(); // addDefaultWindowMenuItems adds the basic Windows menu items, excluding the actual list of windows
600  void initStatusBar(); // setup the statusbar
601  void initToolBars(); // setup the toolbars
602  void setStyleSheet(); //set stylesheet for app
603  //Returns false when there are no fonts
604  void initHyphenator();
605  void initDefaultValues();
606  void initKeyboardShortcuts();
607  void initPalettes();
608  void initScrapbook();
609 
610  void updateColorMenu(QProgressBar* progressBar=NULL);
611 
612  int ScriptRunning;
613 
614  QLabel* mainWindowStatusLabel;
615  QString statusLabelText;
616  //QPixmap noIcon;
617 
618  int toolbarMenuTools;
619  int toolbarMenuPDFTools;
620  int viewToolbars;
621  int viewPropertiesPalette;
622  int viewOutlinePalette;
623  int viewNodePalette;
624  int viewBpal;
625  int viewLayerPalette;
626  int viewPagePalette;
627  int viewBopal;
628  int viewUndoPalette;
629 
630  bool palettesStatus[11];
631  bool guidesStatus[13];
632 
633  bool keyrep;
635  bool _arrowKeyDown;
637  bool objectSpecificUndo;
638 
639  //CB: #8212: add overrideMasterPageSizing, however default to true for compatibility with other calls.. for now
640  void addNewPages(int wo, int where, int numPages, double height, double width, int orient, QString siz, bool mov, QStringList* basedOn = 0, bool overrideMasterPageSizing=true);
641 
642  int DocNr;
643  bool PrinterUsed;
644  struct PDe {
645  QString Pname;
646  QString Dname;
647  QString Command;
648  } PDef ;
649  TOCGenerator *tocGenerator;
650  int storedPageNum;
651  int storedViewXCoor;
652  int storedViewYCoor;
653  double storedViewScale;
654  StyleManager *styleManager;
655  UndoManager *undoManager;
656  PrefsManager *prefsManager;
657  FormatsManager *formatsManager;
658 
659  QPointer<HelpBrowser> helpBrowser;
660  QString osgFilterString;
661 
662  void insertMark(MarkType);
663  bool insertMarkDialog(PageItem_TextFrame* item, MarkType mT, ScItemsState* &is);
664  int m_marksCount; //remember marks count from last call
665  bool m_WasAutoSave;
666  bool m_pagePalVisible;
667 
668  QQuickView *qqview;
669 };
670 
671 #endif
StyleManager * styleMgr() const
allow SE to get the SM for edit stlyes
Definition: scribus.h:544
Definition: downloadspalette.h:34
Definition: pdftoolbar.h:32
Definition: scrapbookpalette.h:69
Definition: pslib.h:54
Definition: util_formats.h:34
Definition: measurements.h:14
Definition: pageitem_textframe.h:45
Definition: edittoolbar.h:32
Definition: scmwmenumanager.h:31
UndoGui subclass which creates an undo history window.
Definition: undogui.h:259
Definition: sctoolbar.h:43
Definition: scpage.h:46
Definition: pagepalette.h:33
UndoState describes an undoable state (action).
Definition: undostate.h:59
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
Definition: undostate.h:305
Definition: viewtoolbar.h:29
Align/Distribute palette.
Definition: aligndistribute.h:54
Definition: outlinepalette.h:56
The ColorCombo widget is a combo box for displaying list of colors.
Definition: colorcombo.h:33
Definition: storyeditor.h:377
Definition: symbolpalette.h:73
Definition: paragraphstyle.h:27
Definition: marks.h:40
Definition: tocgenerator.h:34
Definition: notesstyleseditor.h:11
ScribusDoc * doc
doc represents your actual document and is created only once. It keeps information such as filename a...
Definition: scribus.h:205
the Document Class
Definition: scribusdoc.h:90
Definition: layers.h:31
Definition: scribusapp.h:34
Definition: scribuswin.h:40
Definition: autoform.h:18
Preflight Verifier GUI (P.V.) A tool to check document for errors (in P.V. profiles) which can be set...
Definition: checkDocument.h:37
Definition: scribusstructs.h:213
Definition: pageselector.h:24
A Bookmark Palette.
Definition: bookmarkpalette.h:39
GuideManager is the dialog for guides managing ;). It's scribus non-modal palette now...
Definition: guidemanager.h:32
ScrSpinBox is a Qt4 replacement for our old ScrSpinBox using Qt3.
Definition: scrspinbox.h:21
Definition: nodeeditpalette.h:33
Superclass for all objects that are wanted to have undoable actions.
Definition: undoobject.h:59
The core functions moved from the old ScribusMainWindow class NO WINDOWS NO VIEWS NO DOCS NO PAGEITEM...
Definition: scribuscore.h:52
Definition: propertiespalette.h:51
Definition: scraction.h:33
Definition: prefscontext.h:40
Definition: inlinepalette.h:70
Definition: appmodehelper.h:30
Binary buffer.
Definition: pdbim.h:93
Definition: filetoolbar.h:35
Definition: pageitem.h:92
UndoManager handles the undo stack.
Definition: undomanager.h:81
Definition: modetoolbar.h:50
ScribusDoc * m_doc
private doc for managing default patterns.
Definition: scribus.h:207
Definition: scribusstructs.h:58
Definition: scribusview.h:87
Definition: fontcombo.h:43
ScribusView * view
view is the main widget which represents your working area. The View class should handle all events o...
Definition: scribus.h:201
Manage Scribus preferences here, and here alone Start to move the preferences out of scribus...
Definition: prefsmanager.h:43
Definition: actionmanager.h:50
SimpleState provides a simple implementation of the UndoState.
Definition: undostate.h:145
Definition: resourcemanager.h:38
virtual void restore(UndoState *state, bool isUndo)=0
Method used when an undo/redo is requested.