1 /*******************************************************************
2 
3 Part of the Fritzing project - http://fritzing.org
4 Copyright (c) 2007-2015 Fachhochschule Potsdam - http://fh-potsdam.de
5 
6 Fritzing is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 Fritzing is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with Fritzing.  If not, see <http://www.gnu.org/licenses/>.
18 
19 ********************************************************************
20 
21 $Revision: 6999 $:
22 $Author: irascibl@gmail.com $:
23 $Date: 2013-04-28 14:14:07 +0200 (So, 28. Apr 2013) $
24 
25 ********************************************************************/
26 
27 #ifndef MAINWINDOW_H
28 #define MAINWINDOW_H
29 
30 #include <QUndoView>
31 #include <QUndoGroup>
32 #include <QRadioButton>
33 #include <QLineEdit>
34 #include <QToolButton>
35 #include <QPushButton>
36 #include <QStackedWidget>
37 #include <QSizeGrip>
38 #include <QPointer>
39 #include <QProcess>
40 #include <QDockWidget>
41 #include <QXmlStreamWriter>
42 #include <QRegExp>
43 #include <QProxyStyle>
44 #include <QStyle>
45 #include <QStylePainter>
46 #include <QPrinter>
47 
48 #include "fritzingwindow.h"
49 #include "sketchareawidget.h"
50 #include "../viewlayer.h"
51 #include "../program/programwindow.h"
52 #include "../svg/svg2gerber.h"
53 #include "../routingstatus.h"
54 
55 QT_BEGIN_NAMESPACE
56 class QAction;
57 class QListWidget;
58 class QMenu;
59 QT_END_NAMESPACE
60 
61 class FSizeGrip;
62 
63 typedef class FDockWidget * (*DockFactory)(const QString & title, QWidget * parent);
64 
65 bool sortPartList(class ItemBase * b1, class ItemBase * b2);
66 
67 static const QString ORDERFABENABLED = "OrderFabEnabled";
68 
69 class FTabWidget : public QTabWidget {
70     Q_OBJECT
71 public:
72     FTabWidget(QWidget * parent = NULL);
73 
74     //int addTab(QWidget * page, const QIcon & icon, const QIcon & hoverIcon, const QIcon & inactiveIcon, const QString & label);
75 
76 protected slots:
77     //void tabIndexChanged(int index);
78 
79 protected:
80     //QList<QIcon> m_inactiveIcons;
81     //QList<QIcon> m_hoverIcons;
82     //QList<QIcon> m_icons;
83 };
84 
85 class FTabBar : public QTabBar {
86     Q_OBJECT
87 public:
88     FTabBar();
89 
90     void paintEvent(QPaintEvent *);
91 
92 protected:
93     bool m_firstTime;
94 };
95 
96 class SwapTimer : public QTimer
97 {
98 Q_OBJECT
99 
100 public:
101 	SwapTimer();
102 
103 	void setAll(const QString & family, const QString & prop, QMap<QString, QString> &  propsMap, ItemBase *);
104 	const QString & family();
105 	const QString & prop();
106 	QMap<QString, QString> propsMap();
107 	ItemBase * itemBase();
108 
109 protected:
110 	QString m_family;
111 	QString m_prop;
112 	QMap<QString, QString> m_propsMap;
113 	QPointer <ItemBase> m_itemBase;
114 };
115 
116 struct GridSizeThing
117 {
118 	QLineEdit * lineEdit;
119 	QDoubleValidator * validator;
120 	QRadioButton * mmButton;
121 	QRadioButton * inButton;
122 	double defaultGridSize;
123     QString gridSizeText;
124 	QString viewName;
125 	QString shortName;
126 
127     GridSizeThing(const QString & viewName, const QString & shortName, double defaultSize, const QString & gridSizeText);
128 };
129 
130 class GridSizeDialog : public QDialog {
131     Q_OBJECT
132 
133 public:
134     GridSizeDialog(GridSizeThing *);
135     GridSizeThing * gridSizeThing();
136 
137 protected:
138     GridSizeThing * m_gridSizeThing;
139 };
140 
141 
142 struct TraceMenuThing {
143     int boardCount;
144     int boardSelectedCount;
145 	bool jiEnabled;
146 	bool exEnabled;
147 	bool viaEnabled;
148 	bool exChecked;
149 	bool gfrEnabled;
150     bool gfsEnabled;
151 
TraceMenuThingTraceMenuThing152     TraceMenuThing() {
153         boardCount = 0;
154         boardSelectedCount = 0;
155         gfsEnabled = false;
156         jiEnabled = false;
157 	    exEnabled = false;
158 	    exChecked = true;
159 	    viaEnabled = false;
160 	    gfrEnabled = false;
161     }
162 };
163 
164 class MainWindow : public FritzingWindow
165 {
166     Q_OBJECT
167     Q_PROPERTY(int fireQuoteDelay READ fireQuoteDelay WRITE setFireQuoteDelay DESIGNABLE true)
168 
169 public:
170     MainWindow(class ReferenceModel *referenceModel, QWidget * parent);
171     MainWindow(QFile & fileToLoad);
172 	~MainWindow();
173 
174     void mainLoad(const QString & fileName, const QString & displayName, bool checkObsolete);
175 	bool loadWhich(const QString & fileName, bool setAsLastOpened, bool addToRecent, bool checkObsolete, const QString & displayName);
176 	void notClosableForAWhile();
177 	QAction *raiseWindowAction();
178 	QSizeGrip *sizeGrip();
179 	QStatusBar *realStatusBar();
180 	void enableCheckUpdates(bool enabled);
181 
182 	void getPartsEditorNewAnd(ItemBase * fromItem);
183 	void addDefaultParts();
184     void init(ReferenceModel *referenceModel, bool lockFiles);
185 	void showFileProgressDialog(const QString & path);
186 	void setFileProgressPath(const QString & path);
187 	void clearFileProgressDialog();
188 	class FileProgressDialog * fileProgressDialog();
189 
190 	const QString &selectedModuleID();
191 
192 	void saveDocks();
193 	void restoreDocks();
194 
195 	void redrawSketch();
196 
197 	// if we consider a part as the smallest ("atomic") entity inside
198 	// fritzing, then this functions may help with the bundle tasks
199 	// on the complex entities: sketches, bins, modules (?)
200 	void saveBundledNonAtomicEntity(QString &filename, const QString &extension, Bundler *bundler, const QList<ModelPart*> &partsToSave, bool askForFilename, const QString & destFolderPath, bool saveModel, bool deleteLeftovers);
201 	bool loadBundledNonAtomicEntity(const QString &filename, Bundler *bundler, bool addToBin, bool dontAsk);
202 	void saveAsShareable(const QString & path, bool saveModel);
203 
204 
205 	void setCurrentFile(const QString &fileName, bool addToRecent, bool setAsLastOpened);
206 	void setReportMissingModules(bool);
207 	QList<class SketchWidget *> sketchWidgets();
208     ProgramWindow * programmingWidget();
209 	void setCloseSilently(bool);
210 	class PCBSketchWidget * pcbView();
211 	void noBackup();
212 	void swapSelectedAux(ItemBase * itemBase, const QString & moduleID, bool useViewLayerPlacement, ViewLayer::ViewLayerPlacement, QMap<QString, QString> & propsMap);
213     void swapLayers(ItemBase * itemBase, int layers, const QString & msg, int delay);
214 	bool saveAsAux(const QString & fileName);
215 	void swapObsolete(bool displayFeedback, QList<ItemBase *> &);
216 	QList<ItemBase *> selectAllObsolete(bool displayFeedback);
217 	void hideTempPartsBin();
218 	const QString & fritzingVersion();
219 	void removeGroundFill(ViewLayer::ViewLayerID, QUndoCommand * parentCommand);
220 	void groundFill(ViewLayer::ViewLayerID);
221 	void copperFill(ViewLayer::ViewLayerID);
222     bool hasAnyAlien();
223     void exportSvg(double res, bool selectedItems, bool flatten, const QString & filename);
224     void setCurrentView(ViewLayer::ViewID);
225     bool usesPart(const QString & moduleID);
226     bool anyUsePart(const QString & moduleID);
227     bool updateParts(const QString & moduleID, QUndoCommand * parentCommand);
228 	void updatePartsBin(const QString & moduleID);
229 	bool hasCustomBoardShape();
230     void selectPartsWithModuleID(ModelPart *);
231     void addToSketch(QList<ModelPart *> &);
232 	QStringList newDesignRulesCheck(bool showOkMessage);
233     int fireQuoteDelay();
234     void setFireQuoteDelay(int);
235     void setInitialTab(int);
236     void noSchematicConversion();
237 
238 public:
239 	static void initNames();
240 	static MainWindow * newMainWindow(ReferenceModel *referenceModel, const QString & displayPath, bool showProgress, bool lockFiles, int initialTab);
241 	static void setAutosavePeriod(int);
242 	static void setAutosaveEnabled(bool);
243 
244 signals:
245 	void alienPartsDismissed();
246 	void mainWindowMoved(QWidget *);
247 	void changeActivationSignal(bool activate, QWidget * originator);
248 	void externalProcessSignal(QString & name, QString & path, QStringList & args);
249 
250 public slots:
251 	void ensureClosable();
252 	ModelPart* loadBundledPart(const QString &fileName, bool addToBin);
253 	void importFilesFromPrevInstall();
254 	void acceptAlienFiles();
255 	void statusMessage(QString message, int timeout);
256     void showPCBView();
257 	void groundFill();
258 	void removeGroundFill();
259 	void copperFill();
260 	void setOneGroundFillSeed();
261 	void setGroundFillSeeds();
262 	void clearGroundFillSeeds();
263 	void changeBoardLayers(int layers, bool doEmit);
264 	void selectAllObsolete();
265 	void swapObsolete();
266     void swapBoardImageSlot(SketchWidget * sketchWidget, ItemBase * itemBase, const QString & filename, const QString & moduleID, bool addName);
267 	void updateTraceMenu();
268     virtual void updateExportMenu();
269 	virtual void updateFileMenu();
270     void showStatusMessage(const QString &);
271     void orderFabHoverEnter();
272     void orderFabHoverLeave();
273     void setGroundFillKeepout();
274     void oldSchematicsSlot(const QString & filename, bool & useOldSchematics);
275     void showWelcomeView();
276 
277 protected slots:
278 	void mainLoad();
279 	void revert();
280 	void openRecentOrExampleFile();
281 	void openRecentOrExampleFile(const QString & filename, const QString & actionText);
282     void print();
283     void doExport();
284 	void exportEtchable();
285     void about();
286 	void tipsAndTricks();
287 	void firstTimeHelp();
288     void copy();
289     void cut();
290     void paste();
291 	void pasteInPlace();
292     void duplicate();
293     void doDelete();
294     void doDeleteMinus();
295     void selectAll();
296     void deselect();
297     void zoomIn();
298     void zoomOut();
299     void fitInWindow();
300     void actualSize();
301 	void hundredPercentSize();
302     void alignToGrid();
303     void showGrid();
304     void setGridSize();
305     void setBackgroundColor();
306     void showBreadboardView();
307     void showSchematicView();
308     void showProgramView();
309 	void showPartsBinIconView();
310 	void showPartsBinListView();
311     virtual void updateEditMenu();
312     virtual void updateLayerMenu(bool resetLayout = false);
313     void updatePartMenu();
314     virtual void updateWireMenu();
315     void updateTransformationActions();
316 	void updateRecentFileActions();
317     virtual void tabWidget_currentChanged(int index);
318     void createNewSketch();
319     void minimize();
320     void toggleToolbar(bool toggle);
321     void togglePartLibrary(bool toggle);
322     void toggleInfo(bool toggle);
323     void toggleUndoHistory(bool toggle);
324 	void toggleDebuggerOutput(bool toggle);
325 	void openHelp();
326 	void openDonate();
327 	void openExamples();
328 	void openPartsReference();
329 	void visitFritzingDotOrg();
330 	void partsEditorHelp();
331 	virtual void updateWindowMenu();
332 	void pageSetup();
333 	void sendToBack();
334 	void sendBackward();
335 	void bringForward();
336 	void bringToFront();
337     void alignLeft();
338     void alignRight();
339     void alignVerticalCenter();
340     void alignTop();
341     void alignHorizontalCenter();
342     void alignBottom();
343 	void rotate90cw();
344 	void rotate90ccw();
345 	void rotate180();
346 	void rotate45ccw();
347 	void rotate45cw();
348 	void rotateIncCCW();
349 	void rotateIncCW();
350 	void rotateIncCCWRubberBand();
351 	void rotateIncCWRubberBand();
352 	void flipHorizontal();
353 	void flipVertical();
354 	void showAllLayers();
355 	void hideAllLayers();
356 	void addBendpoint();
357 	void convertToVia();
358 	void convertToBendpoint();
359 	void flattenCurve();
360 	void disconnectAll();
361 
362 	void openInPartsEditorNew();
363 	void openNewPartsEditor(class PaletteItem *);
364 
365 	void updateZoomSlider(double zoom);
366 	void updateZoomOptionsNoMatterWhat(double zoom);
367 	void updateViewZoom(double newZoom);
368 
369 	void setInfoViewOnHover(bool infoViewOnHover);
370 	void updateItemMenu();
371 
372 	void newAutoroute();
373 	void orderFab();
374 	void activeLayerTop();
375 	void activeLayerBottom();
376 	void activeLayerBoth();
377 	void toggleActiveLayer();
378 	void createTrace();
379 	void excludeFromAutoroute();
380 	void selectAllTraces();
381 	void showUnrouted();
382     void selectAllCopperFill();
383 	void updateRoutingStatus();
384 	void selectAllExcludedTraces();
385 	void selectAllIncludedTraces();
386 	void selectAllJumperItems();
387 	void selectAllVias();
388 
389 	void shareOnline();
390 	void saveBundledPart(const QString &moduleId=___emptyString___);
391 	QStringList saveBundledAux(ModelPart *mp, const QDir &destFolder);
392 
393 	void binSaved(bool hasAlienParts);
394 	void routingStatusSlot(class SketchWidget *, const RoutingStatus &);
395 
396 	void applyReadOnlyChange(bool isReadOnly);
397 
398 	void raiseAndActivate();
399 	void activateWindowAux();
400 	void showPartLabels();
401 	void addNote();
402 	void reportBug();
403 	void enableDebug();
404 	void tidyWires();
405 	void changeWireColor(bool checked);
406 
407 	void startSaveInstancesSlot(const QString & fileName, ModelPart *, QXmlStreamWriter &);
408 	void loadedViewsSlot(class ModelBase *, QDomElement & views);
409 	void loadedRootSlot(const QString & filename, ModelBase *, QDomElement & views);
410     void obsoleteSMDOrientationSlot();
411 	void exportNormalizedSVG();
412 	void exportNormalizedFlattenedSVG();
413     void dumpAllParts();
414     void testConnectors();
415 
416 	void launchExternalProcess();
417 	bool externalProcess(QString & name, QString & path, QStringList & args);
418 	void processError(QProcess::ProcessError processError);
419 	void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
420 	void processReadyRead();
421 	void processStateChanged(QProcess::ProcessState newState);
422     void throwFakeException();
423 
424 	void dropPaste(SketchWidget *);
425 
426 	void openProgramWindow();
427     void linkToProgramFile(const QString & filename, Platform * platform, bool addLink, bool strong);
428 	QStringList newDesignRulesCheck();
429 	void subSwapSlot(SketchWidget *, ItemBase *, const QString & newModuleID, ViewLayer::ViewLayerPlacement, long & newID, QUndoCommand * parentCommand);
430 	void updateLayerMenuSlot();
431 	bool save();
432 	bool saveAs();
433 	virtual void backupSketch();
434 	void undoStackCleanChanged(bool isClean);
435 	void autosaveNeeded(int index = 0);
436 	void changeTraceLayer();
437 	void routingStatusLabelMousePress(QMouseEvent*);
438 	void routingStatusLabelMouseRelease(QMouseEvent*);
439 	void selectMoveLock();
440 	void moveLock();
441 	void setSticky();
442 	void autorouterSettings();
443 	void boardDeletedSlot();
444 	void cursorLocationSlot(double, double, double=0.0, double=0.0);
445 	void locationLabelClicked();
446 	void swapSelectedMap(const QString & family, const QString & prop, QMap<QString, QString> & currPropsMap, ItemBase *);
447 	void swapSelectedDelay(const QString & family, const QString & prop, QMap<QString, QString> & currPropsMap, ItemBase *);
448 	void swapSelectedTimeout();
449 	void filenameIfSlot(QString & filename);
450 	void openURL();
451 	void setActiveWire(class Wire *);
452 	void setActiveConnectorItem(class ConnectorItem *);
453 	void gridUnits(bool);
454 	void restoreDefaultGrid();
455     void checkLoadedTraces();
456 
457     void keepMargins();
458 	void dockChangeActivation(bool activate, QWidget * originator);
459     void addToMyParts(ModelPart *);
460     void hidePartSilkscreen();
461     void fabQuote();
462     void findPartInSketch();
463     void fireQuote();
464     void setViewFromBelowToggle();
465     void setViewFromBelow();
466     void setViewFromAbove();
467     void updateWelcomeViewRecentList(bool doEmit = true);
468     virtual void initZoom();
469 
470 protected:
471 	void initSketchWidget(SketchWidget *);
472     virtual void initProgrammingWidget();
473 
474     virtual void createActions();
475     virtual void createFileMenuActions();
476     void createExportActions();
477     void createRaiseWindowActions();
478     void createOrderFabAct();
479     void createOpenExampleMenu();
480 	void createActiveLayerActions();
481     void populateMenuFromXMLFile(QMenu *parentMenu, QStringList &actionsTracker, const QString &folderPath, const QString &indexFileName);
482     QHash<QString, struct SketchDescriptor *> indexAvailableElements(QDomElement &domElem, const QString &srcPrefix, QStringList & actionsTracker, const QString & localeName);
483     void populateMenuWithIndex(const QHash<QString, struct SketchDescriptor *> &, QMenu * parentMenu, QDomElement &domElem, const QString & localeName);
484     void populateMenuFromFolderContent(QMenu *parentMenu, const QString &path);
485     void createOpenRecentMenu();
486     void createEditMenuActions();
487     void createPartMenuActions();
488     virtual void createViewMenuActions(bool showWelcome);
489     void createWindowMenuActions();
490     void createHelpMenuActions();
491     virtual void createMenus();
492     void createStatusBar();
493 	virtual void connectPairs();
494 	void connectPair(SketchWidget * signaller, SketchWidget * slotter);
495 	void closeEvent(QCloseEvent * event);
496 	void saveAsAuxAux(const QString & fileName);
497 	void printAux(QPrinter &printer, bool removeBackground, bool paginate);
498 	void exportAux(QString fileName, QImage::Format format, int quality, bool removeBackground);
499 	void notYetImplemented(QString action);
500 	bool eventFilter(QObject *obj, QEvent *event);
501 	void setActionsIcons(int index, QList<QAction *> &);
502 	void exportToEagle();
503 	void exportToGerber();
504     void exportBOM();
505     void exportNetlist();
506     void exportSpiceNetlist();
507     void exportSvg(double res, bool selectedItems, bool flatten);
508 	void exportSvgWatermark(QString & svg, double res);
509 	void exportEtchable(bool wantPDF, bool wantSVG);
510 
511 	virtual QList<QWidget*> getButtonsForView(ViewLayer::ViewID viewId);
512 	const QString untitledFileName();
513 	int &untitledFileCount();
514 	const QString fileExtension();
515 	QString getExtensionString();
516 	QStringList getExtensions();
517 	const QString defaultSaveFolder();
518 	bool undoStackIsEmpty();
519 
520 	void createTraceMenuActions();
521 	void hideShowTraceMenu();
522     void hideShowProgramMenu();
523     void updatePCBTraceMenu(QGraphicsItem *, TraceMenuThing &);
524 
525 	QList<ModelPart*> moveToPartsFolder(QDir &unzipDir, MainWindow* mw, bool addToBin, bool addToAlien, const QString & prefixFolder, const QString &destFolder, bool importingSinglePart);
526 	QString copyToSvgFolder(const QFileInfo& file, bool addToAlien, const QString & prefixFolder, const QString &destFolder);
527 	ModelPart* copyToPartsFolder(const QFileInfo& file, bool addToAlien, const QString & prefixFolder, const QString &destFolder);
528 
529 	void closeIfEmptySketch(MainWindow* mw);
530 	bool whatToDoWithAlienFiles();
531 	void backupExistingFileIfExists(const QString &destFilePath);
532 	void recoverBackupedFiles();
533 	void resetTempFolder();
534     void saveLastTabList();
535 
536 	virtual QMenu *breadboardItemMenu();
537 	virtual QMenu *schematicItemMenu();
538 	virtual QMenu *pcbItemMenu();
539 	virtual QMenu *pcbWireMenu();
540 	virtual QMenu *schematicWireMenu();
541 	virtual QMenu *breadboardWireMenu();
542 
543 	QMenu *viewItemMenuAux(QMenu* menu);
544 
545 	void createZoomOptions(SketchAreaWidget* parent);
546 	class SketchToolButton *createRotateButton(SketchAreaWidget *parent);
547 	SketchToolButton *createShareButton(SketchAreaWidget *parent);
548 	SketchToolButton *createFlipButton(SketchAreaWidget *parent);
549 	SketchToolButton *createAutorouteButton(SketchAreaWidget *parent);
550     SketchToolButton *createOrderFabButton(SketchAreaWidget *parent);
551 	QWidget *createActiveLayerButton(SketchAreaWidget *parent);
552 	QWidget *createViewFromButton(SketchAreaWidget *parent);
553 	class ExpandingLabel * createRoutingStatusLabel(SketchAreaWidget *);
554 	SketchToolButton *createExportEtchableButton(SketchAreaWidget *parent);
555 	SketchToolButton *createNoteButton(SketchAreaWidget *parent);
556 	QWidget *createToolbarSpacer(SketchAreaWidget *parent);
557 	SketchAreaWidget *currentSketchArea();
558 	const QString fritzingTitle();
559 
560 	virtual void updateRaiseWindowAction();
561 
562 	void moveEvent(QMoveEvent * event);
563 	bool event(QEvent *);
564 	void resizeEvent(QResizeEvent * event);
565 	QString genIcon(SketchWidget *, LayerList &  partViewLayerIDs, LayerList & wireViewLayerIDs);
566 
567 	bool alreadyOpen(const QString & fileName);
568 	void svgMissingLayer(const QString & layername, const QString & path);
569 	long swapSelectedAuxAux(ItemBase * itemBase, const QString & moduleID, ViewLayer::ViewLayerPlacement viewLayerPlacement, QMap<QString, QString> & propsMap, QUndoCommand * parentCommand);
570 	bool swapSpecial(const QString & prop, QMap<QString, QString> & currPropsMap);
571 
572 	void enableAddBendpointAct(QGraphicsItem *);
573 	class FileProgressDialog * exportProgress();
574 	QString constructFileName(const QString & differentiator, const QString & extension);
575 	bool isGroundFill(ItemBase * itemBase);
576 
577 	QString getBoardSvg(ItemBase * board, int res, LayerList &);
578 	QString mergeBoardSvg(QString & svg, ItemBase * board, int res, bool flip, LayerList &);
579 
580 	void updateActiveLayerButtons();
581 	int activeLayerIndex();
582 	bool hasLinkedProgramFiles(const QString & filename, QStringList & linkedProgramFiles);
583 	void pasteAux(bool pasteInPlace);
584 
585 	void routingStatusLabelMouse(QMouseEvent*, bool show);
586 	class Wire * retrieveWire();
587 	class ConnectorItem * retrieveConnectorItem();
588 	QString getBomProps(ItemBase *);
589 	ModelPart * findReplacedby(ModelPart * originalModelPart);
590 	void groundFillAux(bool fillGroundTraces, ViewLayer::ViewLayerID viewLayerID);
591     void groundFillAux2(bool fillGroundTraces);
592 	void connectStartSave(bool connect);
593 	void loadBundledSketch(const QString &fileName, bool addToRecent, bool setAsLastOpened, bool checkObsolete);
594     void dropEvent(QDropEvent *event);
595     void dragEnterEvent(QDragEnterEvent *event);
596     void mainLoadAux(const QString & fileName);
597 	QWidget * createGridSizeForm(GridSizeThing *);
598     void massageOutput(QString & svg, bool doMask, bool doSilk, bool doPaste, QString & maskTop, QString & maskBottom, const QString & fileName, ItemBase * board, int dpi, const LayerList &);
599     virtual void initLockedFiles(bool lockFiles);
600     virtual void initSketchWidgets(bool withIcons);
601 	virtual void initWelcomeView();
602     virtual void initDock();
603     virtual void initMenus();
604     virtual void moreInitDock();
605     virtual void setInitialView();
606     virtual void createFileMenu();
607     virtual void createEditMenu();
608     virtual void createPartMenu();
609     virtual void createViewMenu();
610     virtual void createWindowMenu();
611     virtual void createTraceMenus();
612     virtual void createHelpMenu();
613     virtual void createRotateSubmenu(QMenu * parentMenu);
614     virtual void createZOrderSubmenu(QMenu * parentMenu);
615     virtual void createZOrderWireSubmenu(QMenu * parentMenu);
616     virtual void createAlignSubmenu(QMenu * parentMenu);
617     virtual void createAddToBinSubmenu(QMenu * parentMenu);
618 	virtual void populateExportMenu();
619 
620     // dock management
621 	void createDockWindows();
622 	void dontKeepMargins();
623 	class FDockWidget * makeDock(const QString & title, QWidget * widget, int dockMinHeight, int dockDefaultHeight, Qt::DockWidgetArea area = Qt::RightDockWidgetArea, DockFactory dockFactory = NULL);
624 	class FDockWidget * dockIt(FDockWidget* dock, int dockMinHeight, int dockDefaultHeight, Qt::DockWidgetArea area = Qt::RightDockWidgetArea);
625 	FDockWidget *newTopWidget();
626 	FDockWidget *newBottomWidget();
627 	void removeMargin(FDockWidget* dock);
628 	void addTopMargin(FDockWidget* dock);
629 	void addBottomMargin(FDockWidget* dock);
630 	void dockMarginAux(FDockWidget* dock, const QString &name, const QString &style);
631     void initStyleSheet();
632     virtual QString getStyleSheetSuffix();
633 	virtual QWidget * createTabWidget();
634 	virtual void addTab(QWidget * widget, const QString & label);
635 	virtual void addTab(QWidget * widget, const QString & iconPath, const QString & label, bool withIcon);
636 	virtual int currentTabIndex();
637 	virtual void setCurrentTabIndex(int);
638 	virtual QWidget * currentTabWidget();
639 	virtual bool activeLayerWidgetAlwaysOn();
640     bool copySvg(const QString & path, QFileInfoList & svgEntryInfoList);
641     void checkSwapObsolete(QList<ItemBase *> &, bool includeUpdateLaterMessage);
642     QMessageBox::StandardButton oldSchematicMessage(const QString & filename);
643     MainWindow * revertAux();
644 
645 protected:
646 	static void removeActionsStartingAt(QMenu *menu, int start=0);
647 	static void setAutosave(int, bool);
648 
649 protected:
650 
651 	QUndoGroup *m_undoGroup;
652 	QUndoView *m_undoView;
653 
654 	QPointer<SketchAreaWidget> m_breadboardWidget;
655 	QPointer<class BreadboardSketchWidget> m_breadboardGraphicsView;
656 
657 	QPointer<SketchAreaWidget> m_schematicWidget;
658 	QPointer<class SchematicSketchWidget> m_schematicGraphicsView;
659 
660 	QPointer<SketchAreaWidget> m_pcbWidget;
661 	QPointer<class PCBSketchWidget> m_pcbGraphicsView;
662 
663 	QPointer<SketchAreaWidget> m_welcomeWidget;
664 	class WelcomeView * m_welcomeView;
665 
666     QPointer<class BinManager> m_binManager;
667 	QPointer<QWidget> m_tabWidget;
668     QPointer<ReferenceModel> m_referenceModel;
669     QPointer<class SketchModel> m_sketchModel;
670     QPointer<class HtmlInfoView> m_infoView;
671     QPointer<QToolBar> m_toolbar;
672 
673     bool m_closing;
674 	bool m_dontClose;
675     bool m_firstOpen;
676 
677     QPointer<SketchAreaWidget> m_currentWidget;
678     QPointer<SketchWidget> m_currentGraphicsView;
679 
680     //QToolBar *m_fileToolBar;
681     //QToolBar *m_editToolBar;
682 
683     QAction *m_raiseWindowAct;
684 
685     // Fritzing Menu
686     QMenu *m_fritzingMenu;
687     QAction *m_aboutAct;
688     QAction *m_preferencesAct;
689     QAction *m_quitAct;
690     QAction *m_exceptionAct;
691 
692     // File Menu
693     enum { MaxRecentFiles = 10 };
694 
695 	QMenu *m_fileMenu;
696 	QAction *m_newAct;
697 	QAction *m_openAct;
698 	QAction *m_revertAct;
699 	QMenu *m_openRecentFileMenu;
700     QAction *m_openRecentFileActs[MaxRecentFiles];
701 	QMenu *m_openExampleMenu;
702 	QAction *m_saveAct;
703 	QAction *m_saveAsAct;
704 	QAction *m_pageSetupAct;
705 	QAction *m_printAct;
706 	QAction *m_shareOnlineAct;
707 
708 	QAction * m_launchExternalProcessAct;
709 
710 	QMenu *m_zOrderMenu;
711 	QMenu *m_zOrderWireMenu;
712 	QAction *m_bringToFrontAct;
713 	QAction *m_bringForwardAct;
714 	QAction *m_sendBackwardAct;
715 	QAction *m_sendToBackAct;
716 	class WireAction *m_bringToFrontWireAct;
717 	class WireAction *m_bringForwardWireAct;
718 	class WireAction *m_sendBackwardWireAct;
719 	class WireAction *m_sendToBackWireAct;
720 
721     QMenu *m_alignMenu;
722     QAction * m_alignVerticalCenterAct;
723     QAction * m_alignHorizontalCenterAct;
724     QAction * m_alignTopAct;
725     QAction * m_alignLeftAct;
726     QAction * m_alignBottomAct;
727     QAction * m_alignRightAct;
728 
729 	// Export Menu
730 	QMenu *m_exportMenu;
731 	QAction *m_exportJpgAct;
732 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
733 	QAction *m_exportPsAct;
734 #endif
735 	QAction *m_exportPngAct;
736 	QAction *m_exportPdfAct;
737 	QAction *m_exportEagleAct;
738 	QAction *m_exportGerberAct;
739 	QAction *m_exportEtchablePdfAct;
740 	QAction *m_exportEtchableSvgAct;
741 	QAction *m_exportBomAct;
742 	QAction *m_exportNetlistAct;
743 	QAction *m_exportSpiceNetlistAct;
744 	QAction *m_exportSvgAct;
745 
746     // Edit Menu
747     QMenu *m_editMenu;
748     QAction *m_undoAct;
749     QAction *m_redoAct;
750     QAction *m_cutAct;
751     QAction *m_copyAct;
752     QAction *m_pasteAct;
753     QAction *m_pasteInPlaceAct;
754     QAction *m_duplicateAct;
755     QAction *m_deleteAct;
756     QAction *m_deleteMinusAct;
757     class WireAction *m_deleteWireAct;
758     class WireAction *m_deleteWireMinusAct;
759     QAction *m_selectAllAct;
760     QAction *m_deselectAct;
761 	QAction *m_addNoteAct;
762 
763     // Part Menu
764     QMenu *m_partMenu;
765 	QAction *m_infoViewOnHoverAction;
766 	QAction *m_exportNormalizedSvgAction;
767 	QAction *m_exportNormalizedFlattenedSvgAction;
768 	QAction *m_dumpAllPartsAction;
769 	QAction *m_testConnectorsAction;
770     QAction *m_openInPartsEditorNewAct;
771     QMenu *m_addToBinMenu;
772 
773 
774 	QMenu *m_rotateMenu;
775 	QAction *m_rotate90cwAct;
776 	QAction *m_rotate180Act;
777 	QAction *m_rotate90ccwAct;
778 	QAction *m_rotate45ccwAct;
779 	QAction *m_rotate45cwAct;
780 
781 	QAction *m_moveLockAct;
782 	QAction *m_stickyAct;
783 	QAction *m_selectMoveLockAct;
784 	QAction *m_flipHorizontalAct;
785 	QAction *m_flipVerticalAct;
786 	QAction *m_showPartLabelAct;
787 	QAction *m_saveBundledPart;
788 	QAction *m_disconnectAllAct;
789 	QAction *m_selectAllObsoleteAct;
790 	QAction *m_swapObsoleteAct;
791     QAction *m_findPartInSketchAct;
792 	QAction * m_openProgramWindowAct;
793 
794 	QAction *m_addBendpointAct;
795 	QAction *m_convertToViaAct;
796 	QAction *m_convertToBendpointAct;
797     QAction * m_convertToBendpointSeparator;
798 	QAction *m_flattenCurveAct;
799     QAction *m_showAllLayersAct;
800 	QAction *m_hideAllLayersAct;
801 
802     QAction *m_hidePartSilkscreenAct;
803 
804     // View Menu
805     QMenu *m_viewMenu;
806     QAction *m_zoomInAct;
807     QAction *m_zoomInShortcut;
808     QAction *m_zoomOutAct;
809     QAction *m_fitInWindowAct;
810     QAction *m_actualSizeAct;
811     QAction *m_100PercentSizeAct;
812     QAction *m_alignToGridAct;
813     QAction *m_showGridAct;
814     QAction *m_setGridSizeAct;
815     QAction *m_setBackgroundColorAct;
816     QAction *m_showWelcomeAct;
817     QAction *m_showBreadboardAct;
818     QAction *m_showSchematicAct;
819     QAction *m_showProgramAct;
820     QAction *m_showPCBAct;
821 	QAction *m_showPartsBinIconViewAct;
822 	QAction *m_showPartsBinListViewAct;
823     //QAction *m_toggleToolbarAct;
824     int m_numFixedActionsInViewMenu;
825 
826     // Window Menu
827 	QMenu *m_windowMenu;
828 	QAction *m_minimizeAct;
829 	QAction *m_togglePartLibraryAct;
830 	QAction *m_toggleInfoAct;
831 	QAction *m_toggleUndoHistoryAct;
832 	QAction *m_toggleDebuggerOutputAct;
833 	QAction *m_windowMenuSeparator;
834 
835 	// Trace Menu
836 	QMenu *m_pcbTraceMenu;
837 	QMenu *m_schematicTraceMenu;
838 	QMenu *m_breadboardTraceMenu;
839 	QAction *m_newAutorouteAct;
840 	QAction *m_orderFabAct;
841 	QAction *m_activeLayerTopAct;
842 	QAction *m_activeLayerBottomAct;
843 	QAction *m_activeLayerBothAct;
844 	QAction *m_viewFromBelowToggleAct;
845 	QAction *m_viewFromBelowAct;
846 	QAction *m_viewFromAboveAct;
847 	class WireAction *m_createTraceWireAct;
848 	class WireAction *m_createWireWireAct;
849 	QAction *m_createJumperAct;
850 	QAction *m_changeTraceLayerAct;
851 	class WireAction *m_changeTraceLayerWireAct;
852 	QAction *m_excludeFromAutorouteAct;
853 	class WireAction *m_excludeFromAutorouteWireAct;
854     QAction * m_showUnroutedAct;
855 	QAction *m_selectAllTracesAct;
856 	QAction *m_selectAllWiresAct;
857 	QAction *m_selectAllCopperFillAct;
858 	QAction *m_updateRoutingStatusAct;
859 	QAction *m_selectAllExcludedTracesAct;
860 	QAction *m_selectAllIncludedTracesAct;
861 	QAction *m_selectAllJumperItemsAct;
862 	QAction *m_selectAllViasAct;
863 	QAction *m_groundFillAct;
864 	QAction *m_removeGroundFillAct;
865 	QAction *m_copperFillAct;
866 	class ConnectorItemAction *m_setOneGroundFillSeedAct;
867 	QAction *m_setGroundFillSeedsAct;
868 	QAction *m_clearGroundFillSeedsAct;
869     QAction *m_setGroundFillKeepoutAct;
870 	QAction *m_newDesignRulesCheckAct;
871 	QAction *m_autorouterSettingsAct;
872 	QAction *m_fabQuoteAct;
873 	QAction *m_tidyWiresAct;
874 	QAction *m_checkLoadedTracesAct;
875 
876 	// Help Menu
877     QMenu *m_helpMenu;
878     QAction *m_openHelpAct;
879     QAction *m_openDonateAct;
880     QAction *m_examplesAct;
881     QAction *m_partsRefAct;
882     QAction *m_visitFritzingDotOrgAct;
883     QAction *m_checkForUpdatesAct;
884     QAction *m_aboutQtAct;
885     QAction *m_reportBugAct;
886 	QAction *m_enableDebugAct;
887     QAction *m_importFilesFromPrevInstallAct;
888 	QAction *m_partsEditorHelpAct;
889     QAction *m_tipsAndTricksAct;
890     QAction *m_firstTimeHelpAct;
891 
892 	// Wire Color Menu
893 	QMenu * m_breadboardWireColorMenu;
894 	QMenu * m_schematicWireColorMenu;
895 
896     // Dot icons
897     QIcon m_dotIcon;
898     QIcon m_emptyIcon;
899 
900 	QList<SketchToolButton*> m_rotateButtons;
901 	QList<SketchToolButton*> m_flipButtons;
902 	QStackedWidget * m_activeLayerButtonWidget;
903 	QStackedWidget * m_viewFromButtonWidget;
904 
905     bool m_comboboxChanged;
906     bool m_restarting;
907 
908     QStringList m_alienFiles;
909     QString m_alienPartsMsg;
910     QStringList m_filesReplacedByAlienOnes;
911 
912     QStringList m_openExampleActions;
913 
914 	QPointer<class FSizeGrip> m_sizeGrip;
915 
916 	QTimer m_setUpDockManagerTimer;
917 	QPointer<class FileProgressDialog> m_fileProgressDialog;
918 	QPointer<class ZoomSlider> m_zoomSlider;
919 	QPointer<QLabel> m_locationLabel;
920 	QString m_locationLabelUnits;
921 
922 	QByteArray m_externalProcessOutput;
923 
924 	QPointer<class LayerPalette> m_layerPalette;
925 	QPointer<class ProgramWindow> m_programWindow;
926 	QPointer<class ProgramWindow> m_programView;
927 	QList<LinkedFile *>  m_linkedProgramFiles;
928 	QString m_backupFileNameAndPath;
929 	QTimer m_autosaveTimer;
930     QTimer m_fireQuoteTimer;
931 	bool m_autosaveNeeded;
932 	bool m_backingUp;
933 	QString m_bundledSketchName;
934 	RoutingStatus m_routingStatus;
935 	bool m_orderFabEnabled;
936 	bool m_closeSilently;
937 	QString m_fzzFolder;
938 	QHash<QString, struct LockedFile *> m_fzzFiles;
939 	SwapTimer m_swapTimer;
940 	QPointer<Wire> m_activeWire;
941 	QPointer<ConnectorItem> m_activeConnectorItem;
942     bool m_addedToTemp;
943     QString m_settingsPrefix;
944     bool m_convertedSchematic;
945     bool m_useOldSchematic;
946     bool m_noSchematicConversion;
947     int m_initialTab;
948 
949     // dock management
950 	QList<FDockWidget*> m_docks;
951 	FDockWidget* m_topDock;
952 	FDockWidget* m_bottomDock;
953 	QString m_oldTopDockStyle;
954 	QString m_oldBottomDockStyle;
955 	bool m_dontKeepMargins;
956     QPointer<QDialog> m_rolloverQuoteDialog;
957     bool m_obsoleteSMDOrientation;
958     QWidget * m_orderFabButton;
959     int m_fireQuoteDelay;
960 
961 public:
962 	static int AutosaveTimeoutMinutes;
963 	static bool AutosaveEnabled;
964 	static QString BackupFolder;
965     static const int DockMinWidth;
966     static const int DockMinHeight;
967 
968 protected:
969 	static const QString UntitledSketchName;
970 	static int UntitledSketchIndex;
971 	static int CascadeFactorX;
972 	static int CascadeFactorY;
973     static QRegExp GuidMatcher;
974 };
975 
976 #endif
977