]> git.sven.stormbind.net Git - sven/vym.git/blob - src/mainwindow.h
New upstream version 2.9.22
[sven/vym.git] / src / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include <QMainWindow>
5 #include <QPrinter>
6 #include <QProgressDialog>
7 #include <QScriptContext>
8 #include <QScriptEngine>
9 #include <QScriptValue>
10 #include <QTextStream>
11
12 #include "branchpropeditor.h"
13 #include "extrainfodialog.h"
14 #include "file.h"
15 #include "flag.h"
16 #include "historywindow.h"
17 #include "mapeditor.h"
18 #include "scripting.h"
19 #include "texteditor.h"
20 #include "vymview.h"
21
22 class Main : public QMainWindow {
23     Q_OBJECT
24
25   public:
26     /*! Modifier modes are used when SHIFT together with a mouse button is
27      * pressed */
28     enum ModMode {
29         ModModeUndefined,  //!< Unused
30         ModModePoint,      //!< Regular mode: Point and relink items
31         ModModeColor,      //!< Pick color from object
32         ModModeXLink,      //!< Create a XLink (XLinkObj) from selected object
33         ModModeMoveObject, //!< Move object without linking
34         ModModeMoveView    //!< Move view without changing
35     };
36
37     Main(QWidget *parent = 0);
38     ~Main();
39     void loadCmdLine();
40
41   private:
42     QProgressDialog progressDialog;
43     int progressMax;
44     int progressCounter;
45     int progressCounterTotal;
46
47   public:
48     void statusMessage(const QString &);
49     void setProgressMaximum(int max);
50     void addProgressValue(float v);
51     void initProgressCounter(uint n = 1);
52     void removeProgressCounter();
53
54   public slots:
55     void fileNew();
56     void fileNewCopy();
57
58   protected:
59     void closeEvent(QCloseEvent *);
60
61   public:
62     QPrinter *setupPrinter();
63
64   private:
65     void setupAPI();
66
67     /*! Helper method to clone actions later in MapEditor */
68     void cloneActionMapEditor(QAction *a, QKeySequence ks);
69
70     void setupFileActions();
71     void setupEditActions();
72     void setupSelectActions();
73     void setupFormatActions();
74     void setupViewActions();
75     void setupConnectActions();
76     void setupModeActions();
77     void setupWindowActions();
78     void setupFlagActions();
79
80   public slots:
81     void addUserFlag();
82
83   public:
84     Flag *setupFlag(const QString &path, Flag::FlagType type,
85                     const QString &name, const QString &tooltip,
86                     const QUuid &uid = QUuid(), const QKeySequence &ks = 0);
87
88   private:
89     void setupNetworkActions();
90     void setupSettingsActions();
91     void setupTestActions();
92     void setupHelpActions();
93     void setupContextMenus();
94     void setupRecentMapsMenu();
95     void setupMacros();
96     void setupToolbars();
97     VymView *currentView() const;
98     VymView *view(const int i);
99
100   public:
101     MapEditor *currentMapEditor() const;
102     VymModel *currentModel() const;
103     uint currentMapID() const;
104     int currentMapIndex() const;
105     VymModel *getModel(uint);
106     void gotoModel(VymModel *m);
107     void gotoModelWithID(uint id);
108     bool closeModelWithID(uint id);
109     int modelCount();
110     void updateTabName(VymModel *vm);
111
112   private slots:
113     void editorChanged();
114
115   public slots:
116     File::ErrorCode fileLoad(QString, const LoadMode &, const FileType &ftype);
117     void fileLoad(const LoadMode &);
118   private slots:
119     void fileLoad();
120     void fileSaveSession();
121   public slots:
122     void fileRestoreSession();
123   private slots:
124     void fileLoadRecent();
125     void addRecentMap(const QString &);
126     void fileSave(VymModel *, const SaveMode &);
127     void fileSave();
128   public slots:
129     void fileSave(VymModel *); // autosave from MapEditor
130   private slots:
131     void fileSaveAs();
132     void fileSaveAs(const SaveMode &);
133     void fileSaveAsDefault();
134     void fileImportFirefoxBookmarks();
135     void fileImportFreemind();
136     void fileImportMM();
137     void fileImportDir();
138     void fileExportAO();
139     void fileExportASCII();
140     void fileExportASCIITasks();
141     void fileExportCSV();
142     void fileExportConfluence();
143     void fileExportFirefoxBookmarks();
144     void fileExportHTML();
145     void fileExportImage();
146     void fileExportImpress();
147     void fileExportLaTeX();
148     void fileExportMarkdown();
149     void fileExportOrgMode();
150     void fileExportPDF();
151     void fileExportSVG();
152     void fileExportTaskjuggler();
153     void fileExportXML();
154     void fileExportLast();
155     bool fileCloseMap(int i = -1); // Optionally pass number of tab
156     void filePrint();
157     bool fileExitVYM();
158
159   public slots:
160     void editUndo();
161     void editRedo();
162     void gotoHistoryStep(int);
163   private slots:
164     void editCopy();
165     void editPaste();
166     void editCut();
167
168   public slots:
169     void updateQueries(VymModel *);
170     bool openURL(const QString &url);
171     void openTabs(QStringList);
172     void editOpenURL();
173     void editOpenURLTab();
174
175   private slots:
176     void editOpenMultipleVisURLTabs(bool ignoreScrolled = true);
177     void editOpenMultipleURLTabs();
178     void editNote2URLs();
179     void editURL();
180     void editLocalURL();
181     void editHeading2URL();
182     void getJiraDataSubtree();
183     void setHeadingConfluencePageName();
184     void getConfluenceUser();
185     void openVymLinks(const QStringList &, bool background = false);
186     void editVymLink();
187     void editOpenMultipleVymLinks();
188   public slots:
189     void editHeading();
190     void editHeadingFinished(VymModel *m);
191     void editOpenVymLink(bool background = false);
192     void editOpenVymLinkBackground();
193   private slots:
194     void editDeleteVymLink();
195     void editToggleHideExport();
196     void editToggleTask();
197     void editCycleTaskStatus();
198     void editTaskResetDeltaPrio();
199     void editTaskSleepN();
200     void editAddTimestamp();
201     void editMapProperties();
202     void editMoveUp();
203     void editMoveDown();
204     void editMoveUpDiagonally();
205     void editMoveDownDiagonally();
206     void editDetach();
207     void editSortChildren();
208     void editSortBackChildren();
209     void editToggleScroll();
210     void editExpandAll();
211     void editExpandOneLevel();
212     void editCollapseOneLevel();
213     void editCollapseUnselected();
214     void editUnscrollChildren();
215     void editGrowSelectionSize();
216     void editShrinkSelectionSize();
217     void editResetSelectionSize();
218     void editAddAttribute();
219     void editAddMapCenter();
220     void editNewBranch();
221     void editNewBranchBefore();
222     void editNewBranchAbove();
223     void editNewBranchBelow();
224     void editImportAdd();
225     void editImportReplace();
226     void editSaveBranch();
227     void editDeleteKeepChildren();
228     void editDeleteChildren();
229     void editDeleteSelection();
230     void editLoadImage();
231     void editSaveImage();
232     void popupFollowXLink();
233     void editFollowXLink(QAction *);
234     void editEditXLink(QAction *);
235
236   private slots:
237     bool initLinkedMapsMenu(VymModel *model, QMenu *menu);
238
239   public slots:
240     void editGoToLinkedMap();
241
242   private slots:
243     void editToggleTarget();
244     bool initTargetsMenu(VymModel *model, QMenu *menu);
245     void editGoToTarget();
246     void editMoveToTarget();
247     void editSelectPrevious();
248     void editSelectNext();
249     void editSelectNothing();
250     void editOpenFindResultWidget();
251     void editFindNext(QString s, bool searchNotesFlag);
252     void editFindDuplicateURLs();
253
254   public slots:
255     void selectQuickColor(int n);
256     void setQuickColor(QColor col);
257     void quickColorPressed();
258     void formatPickColor();
259     QColor getCurrentColor();
260     int getCurrentColorIndex();
261     void setCurrentColor(QColor);
262
263   private slots:
264     void formatColorBranch();
265     void formatColorSubtree();
266     void formatLinkStyleLine();
267     void formatLinkStyleParabel();
268     void formatLinkStylePolyLine();
269     void formatLinkStylePolyParabel();
270     void formatSelectBackColor();
271     void formatSelectBackImage();
272     void formatSelectLinkColor();
273     void formatSelectSelectionColor();
274     void formatSelectFont();
275     void formatToggleLinkColorHint();
276     void formatHideLinkUnselected();
277
278   public slots:
279     void viewZoomReset();
280     void viewZoomIn();
281     void viewZoomOut();
282     void viewRotateCounterClockwise();
283     void viewRotateClockwise();
284     void viewCenter();
285     void viewCenterScaled();
286
287   public slots:
288     void networkStartServer();
289     void networkConnect();
290     void downloadFinished();
291     bool settingsPDF();
292     bool settingsURL();
293     void settingsZipTool();
294     void settingsMacroPath();
295     void settingsUndoLevels();
296     void settingsDefaultMapPath();
297
298   public:
299     QString defaultMapPath();   // Default path, used with "auto" to define newMapPath
300     QString newMapPath();       // Depends on settings and dark theme
301     bool useAutosave();
302     void setAutosave(bool b);
303
304   public slots:
305     void settingsAutosaveTime();
306     void settingsDefaultMapAuthor();
307     void settingsDarkTheme();
308     void settingsShowParentsLevelTasks();
309     void settingsShowParentsLevelFindResults();
310     void settingsToggleAutoLayout();
311     void settingsToggleWriteBackupFile();
312     void settingsToggleAnimation();
313     void settingsToggleDownloads();
314     bool settingsConfluence();
315     bool settingsJIRA();
316
317     void windowToggleNoteEditor();
318     void windowToggleTreeEditor();
319     void windowToggleTaskEditor();
320     void windowToggleSlideEditor();
321     void windowToggleScriptEditor();
322     void windowToggleScriptOutput();
323     void windowToggleHistory();
324     void windowToggleProperty();
325     void windowShowHeadingEditor();
326     void windowToggleHeadingEditor();
327     void updateHistory(SimpleSettings &);
328     void windowToggleAntiAlias();
329     bool isAliased();
330     bool hasSmoothPixmapTransform();
331     void windowToggleSmoothPixmap();
332     void clearScriptOutput();
333     void updateHeading(const VymText &vt);
334     void updateNoteText(const VymText &vt);
335     void updateNoteEditor(TreeItem *ti);
336     void updateHeadingEditor(BranchItem *bi = nullptr);
337     void selectInNoteEditor(QString s, int i);
338     void setFocusMapEditor();
339     void changeSelection(VymModel *model, const QItemSelection &newSel,
340                          const QItemSelection &delSel);
341     void updateDockWidgetTitles(VymModel *model);
342
343     void updateActions();
344     ModMode getModMode();
345     bool autoSelectNewBranch();
346     QVariant runScript(const QString &);
347     QObject *getCurrentModelWrapper();
348     bool gotoWindow(const int &n);
349
350   private slots:
351     void windowNextEditor();
352     void windowPreviousEditor();
353     void nextSlide();
354     void previousSlide();
355
356     void flagChanged();
357
358     void testFunction1();
359     void testFunction2();
360     void toggleWinter();
361     void toggleHideExport();
362     void testCommand();
363
364     void helpDoc();
365     void helpDemo();
366     void helpShortcuts();
367     void helpMacros();
368     void helpScriptingCommands();
369     void helpDebugInfo();
370     void helpAbout();
371     void helpAboutQT();
372
373     void callMacro();
374     void downloadReleaseNotesFinished();
375
376   private:
377     QUrl serverUrl(const QString &scriptName);
378     bool checkUpdatesAfterReleaseNotes;
379
380   public:
381     void checkReleaseNotesAndUpdates();
382
383   public slots:
384     void checkReleaseNotes();
385     bool downloadsEnabled(bool userTriggered = false);
386     void downloadUpdatesFinished(bool userTriggered = false);
387     void downloadUpdatesFinishedInt();
388     void downloadUpdates(bool userTriggered);
389     void checkUpdates();
390     void escapePressed();
391     void togglePresentationMode();
392
393   private:
394     QString shortcutScope; //! For listing shortcuts
395     QTabWidget *tabWidget;
396     qint64 *browserPID;
397
398     QStringList imageTypes;
399
400     QScriptEngine scriptEngine;
401
402     QString prevSelection;
403
404     HistoryWindow *historyWindow;
405
406     QDockWidget *headingEditorDW;
407     QDockWidget *noteEditorDW;
408     QDockWidget *scriptEditorDW;
409     QDockWidget *branchPropertyEditorDW;
410
411   public:
412     QList<QAction *>
413         mapEditorActions; //! allows mapEditor to clone actions and shortcuts
414     QList<QAction *>
415         taskEditorActions; //! allows taskEditor to clone actions and shortcuts
416   private:
417     QList<QAction *>
418         restrictedMapActions; //! Actions reqire map and write access
419     QList<QAction *>
420         unrestrictedMapActions;       //! Actions require map, but work also in
421                                       //! readonly, e.g. print, copy
422     QList<QAction *> actionListFiles; //! File related actions, e.g. load, save,
423                                       //! restore session
424     QList<QAction *> actionListBranches;
425     QList<QAction *> actionListItems;
426
427     int xLinkMenuWidth;
428
429     QMenu *recentFilesMenu;
430     enum { MaxRecentFiles = 20 };
431     QAction *recentFileActions[MaxRecentFiles];
432
433     QAction *macroActions[24];
434     QStringList macro;
435
436     QList <QColor> quickColors;
437
438     QMenu *toolbarsMenu;
439     QToolBar *fileToolbar;
440     QToolBar *clipboardToolbar;
441     QToolBar *editActionsToolbar;
442     QToolBar *selectionToolbar;
443     QToolBar *editorsToolbar;
444     QToolBar *colorsToolbar;
445     QToolBar *zoomToolbar;
446     QToolBar *modModesToolbar;
447     QToolBar *referencesToolbar;
448     QToolBar *standardFlagsToolbar;
449     QToolBar *userFlagsToolbar;
450
451     bool presentationMode;
452     QMap<QToolBar *, bool>
453         toolbarStates; // Save visibilty of toolbars during presentation mode
454
455     QAction *actionFileNew;
456     QAction *actionFileNewCopy;
457     QAction *actionFileOpen;
458     QAction *actionFileRestoreSession;
459     QAction *actionFileSave;
460     QAction *actionFilePrint;
461     QAction *actionMapProperties;
462     QAction *actionFileExportLast;
463     QAction *actionFileExportConfluence;
464     QAction *actionUndo;
465     QAction *actionRedo;
466     QAction *actionCopy;
467     QAction *actionCut;
468     QAction *actionPaste;
469     QAction *actionMoveUp;
470     QAction *actionMoveDown;
471     QAction *actionMoveDownDiagonally;
472     QAction *actionMoveUpDiagonally;
473     QAction *actionDetach;
474     QAction *actionSortChildren;
475     QAction *actionSortBackChildren;
476     QAction *actionToggleScroll;
477     QAction *actionExpandAll;
478     QAction *actionExpandOneLevel;
479     QAction *actionCollapseOneLevel;
480     QAction *actionCollapseUnselected;
481     QAction *actionOpenURL;
482     QAction *actionOpenURLTab;
483     QAction *actionOpenMultipleVisURLTabs;
484     QAction *actionOpenMultipleURLTabs;
485     QAction *actionGetURLsFromNote;
486     QAction *actionURLNew;
487     QAction *actionLocalURL;
488     QAction *actionHeading2URL;
489     QAction *actionGetJiraDataSubtree;
490     QAction *actionGetConfluencePageName;
491     QAction *actionOpenVymLink;
492     QAction *actionOpenVymLinkBackground;
493     QAction *actionOpenMultipleVymLinks;
494     QAction *actionEditVymLink;
495     QAction *actionDeleteVymLink;
496     QAction *actionAddTimestamp;
497     QAction *actionToggleTask;
498     QAction *actionTogglePresentationMode;
499     QAction *actionCycleTaskStatus;
500     QAction *actionTaskResetDeltaPrio;
501     QAction *actionTaskSleep0;
502     QAction *actionTaskSleepN;
503     QAction *actionTaskSleep1;
504     QAction *actionTaskSleep2;
505     QAction *actionTaskSleep3;
506     QAction *actionTaskSleep4;
507     QAction *actionTaskSleep5;
508     QAction *actionTaskSleep7;
509     QAction *actionTaskSleep14;
510     QAction *actionTaskSleep28;
511     QAction *actionToggleHideExport;
512     QAction *actionMapInfo;
513     QAction *actionHeading;
514     QAction *actionDelete;
515     QAction *actionDeleteAlt;
516     QAction *actionAddAttribute;
517
518   public:
519     QAction *actionAddMapCenter;
520
521   private:
522     QAction *actionAddBranch;
523     QAction *actionAddBranchBefore;
524     QAction *actionAddBranchAbove;
525     QAction *actionAddBranchBelow;
526     QAction *actionDeleteKeepChildren;
527     QAction *actionDeleteChildren;
528     QAction *actionImportAdd;
529     QAction *actionImportReplace;
530     QAction *actionSaveBranch;
531     QAction *actionLoadImage;
532
533     QAction *actionGrowSelectionSize;
534     QAction *actionShrinkSelectionSize;
535     QAction *actionResetSelectionSize;
536
537     QAction *actionToggleTarget;
538     QAction *actionGoToTargetLinkedMap;
539     QAction *actionGoToTarget;
540     QAction *actionMoveToTarget;
541     QAction *actionSelectPrevious;
542     QAction *actionSelectNext;
543     QAction *actionSelectNothing;
544     QAction *actionFind;
545
546     QActionGroup *actionGroupQuickColors;
547     QAction *actionFormatQuickColor;
548     QAction *actionFormatPickColor;
549     QAction *actionFormatColorBranch;
550     QAction *actionFormatColorSubtree;
551     QAction *actionFormatLinkColorHint;
552     QAction *actionFormatBackColor;
553     QAction *actionFormatBackImage;
554     QAction *actionFormatLinkColor;
555     QAction *actionFormatSelectionColor;
556     QAction *actionFormatFont;
557
558     QAction *actionZoomIn;
559     QAction *actionZoomOut;
560     QAction *actionZoomReset;
561     QAction *actionRotateCounterClockwise;
562     QAction *actionRotateClockwise;
563     QAction *actionCenterOn;
564     QAction *actionFitToSelection;
565
566     QActionGroup *actionGroupModModes;
567     QAction *actionModModePoint;
568     QAction *actionModModeColor;
569     QAction *actionModModeCopy;
570     QAction *actionModModeXLink;
571     QAction *actionModModeMoveObject;
572     QAction *actionModModeMoveView;
573
574     QAction *actionToggleHideMode;
575
576     QAction *actionToggleWinter;
577
578     QActionGroup *actionGroupFormatFrameTypes;
579
580     QActionGroup *actionGroupFormatLinkStyles;
581     QAction *actionFormatLinkStyleLine;
582     QAction *actionFormatLinkStyleParabel;
583     QAction *actionFormatLinkStylePolyLine;
584     QAction *actionFormatLinkStylePolyParabel;
585     QAction *actionFormatHideLinkUnselected;
586
587     QAction *actionViewToggleNoteEditor;
588     QAction *actionViewToggleHeadingEditor;
589     QAction *actionViewToggleTreeEditor;
590     QAction *actionViewToggleTaskEditor;
591     QAction *actionViewToggleSlideEditor;
592     QAction *actionViewToggleScriptEditor;
593     QAction *actionViewToggleScriptOutput;
594     QAction *actionViewToggleHistoryWindow;
595     QAction *actionViewTogglePropertyEditor;
596     QAction *actionViewToggleAntiAlias;
597     QAction *actionViewToggleSmoothPixmapTransform;
598     QAction *actionViewCenter;
599
600     QAction *actionConnectGetConfluenceUser;
601     QAction *actionSettingsAutoSelectNewBranch;
602     QAction *actionSettingsAutoSelectText;
603     QAction *actionSettingsUseFlagGroups;
604     QAction *actionSettingsUseHideExport;
605     QAction *actionSettingsToggleAutosave;
606     QAction *actionSettingsAutosaveTime;
607     QAction *actionSettingsDarkTheme;
608     QAction *actionSettingsShowParentsLevelTasks;
609     QAction *actionSettingsShowParentsLevelFindResults;
610     QAction *actionSettingsToggleAutoLayout;
611     QAction *actionSettingsWriteBackupFile;
612     QAction *actionSettingsToggleDownloads;
613     QAction *actionSettingsUseAnimation;
614     QAction *actionSettingsJIRA;
615     QAction *actionSettingsConfluence;
616 };
617
618 #endif