Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
mainwindow2.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2008-2009 Mj Mendoza IV
6Copyright (C) 2012-2020 Matthew Chiawen Chang
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17*/
18#ifndef MAINWINDOW2_H
19#define MAINWINDOW2_H
20
21#include <QMainWindow>
22
23template<typename T> class QList;
24class QActionGroup;
25class QToolBar;
26class Object;
27class Editor;
28class ScribbleArea;
29class BaseDockWidget;
30class ColorPaletteWidget;
31class OnionSkinWidget;
32class ToolOptionWidget;
33class TimeLine;
34class ToolBoxDockWidget;
35class PreferencesDialog;
36class PreviewWidget;
37class ColorBox;
38class ColorInspector;
39class RecentFileMenu;
40class ActionCommands;
41class ImportImageSeqDialog;
42class UndoRedoCommand;
43class LayerOpacityDialog;
44class PegBarAlignmentDialog;
45class AddTransparencyToPaperDialog;
46class RepositionFramesDialog;
47class StatusBar;
48class AutosaverByTime;
49enum class SETTING;
50
51
52namespace Ui
53{
54 class MainWindow2;
55}
56
57class MainWindow2 : public QMainWindow
58{
59 Q_OBJECT
60
61public:
62 explicit MainWindow2(QWidget* parent = nullptr);
63 ~MainWindow2() override;
64
65 Editor* mEditor = nullptr;
66
67public slots:
68 void updateBackupActionState();
69 void updateSaveState();
70 void openPegAlignDialog();
71 void openRepositionDialog();
72 void closeRepositionDialog();
73 void openLayerOpacityDialog();
74 void openAddTranspToPaperDialog();
75 void currentLayerChanged();
76 void selectionChanged();
77 void viewFlipped();
78
79public:
80 void newDocument();
81 void openDocument();
82 bool saveDocument();
83 bool saveAsNewDocument();
84 bool maybeSave();
85 bool autoSave();
86 void emptyDocumentWhenErrorOccurred();
87
88 // import
89 void importImage();
90 void importImageSequence();
91 void importPredefinedImageSet();
92 void importLayers();
93 void importMovieVideo();
94 void importAnimatedImage();
95
96 void lockWidgets(bool shouldLock);
97
98 void setOpacity(int opacity);
99 void preferences();
100
101 void openStartupFile(const QString& filename);
102 void openFile(const QString& filename);
103
104 void displayMessageBox(const QString& title, const QString& body);
105 void displayMessageBoxNoTitle(const QString& body);
106
107signals:
109 void windowActivated();
110
111protected:
112 void tabletEvent(QTabletEvent*) override;
113 void closeEvent(QCloseEvent*) override;
114 bool event(QEvent*) override;
115
116private slots:
117 void updateCopyCutPasteEnabled();
118 void updateLayerMenu();
119 void autoSaveTimeout();
120private:
121 void newObject();
122 bool newObjectFromPresets(int presetIndex);
123 bool openObject(const QString& strFilename);
124 bool saveObject(QString strFileName);
125 void closeDialogs();
126
127 void createDockWidgets();
128 void createMenus();
129 void replaceUndoRedoActions();
130 void setupKeyboardShortcuts();
131 void clearKeyboardShortcuts();
132 bool loadMostRecent();
133 bool tryLoadPreset();
134
135 void openPalette();
136 void importPalette();
137 void exportPalette();
138
139 void readSettings();
140 void writeSettings();
141 void resetAndDockAllSubWidgets();
142
143 void changePlayState(bool isPlaying);
144
145 void makeConnections(Editor*);
146 void makeConnections(Editor*, ColorBox* colorBox);
147 void makeConnections(Editor*, ColorInspector*);
148 void makeConnections(Editor*, ScribbleArea*);
149 void makeConnections(Editor*, ColorPaletteWidget*);
150 void makeConnections(Editor*, TimeLine*);
151 void makeConnections(Editor*, ToolOptionWidget*);
152 void makeConnections(Editor*, OnionSkinWidget*);
153 void makeConnections(Editor*, StatusBar*);
154
155 bool checkForRecoverableProjects();
156 bool tryRecoverProject(const QString recoverPath);
157 bool startProjectRecovery(const QString recoverPath);
158
159 // UI: Dock widgets
160 ColorBox* mColorBox = nullptr;
161 ColorPaletteWidget* mColorPalette = nullptr;
162 ToolOptionWidget* mToolOptions = nullptr;
163 ToolBoxDockWidget* mToolBox = nullptr;
164 RecentFileMenu* mRecentFileMenu = nullptr;
165 PreferencesDialog* mPrefDialog = nullptr;
166 //PreviewWidget* mPreview = nullptr;
167 TimeLine* mTimeLine = nullptr;
168 ColorInspector* mColorInspector = nullptr;
169 OnionSkinWidget* mOnionSkinWidget = nullptr;
170 QToolBar* mMainToolbar = nullptr;
171 QToolBar* mViewToolbar = nullptr;
172 QToolBar* mOverlayToolbar = nullptr;
173
174 PegBarAlignmentDialog* mPegAlign = nullptr;
175 RepositionFramesDialog* mReposDialog = nullptr;
176 LayerOpacityDialog* mLayerOpacityDialog = nullptr;
177 AddTransparencyToPaperDialog* mAddTranspToPaper = nullptr;
178
179 // Autosave handler
180 AutosaverByTime* mAutoSaver = nullptr;
181
182 void createToolbars();
183private:
184 ActionCommands* mCommands = nullptr;
185 QList<BaseDockWidget*> mDockWidgets;
186 QList<QToolBar*> mToolbars;
187
188 QIcon mStartIcon;
189 QIcon mStopIcon;
190
191 // a hack for MacOS because closeEvent fires twice
192 bool m2ndCloseEvent = false;
193
194 // Whether to suppress the auto save dialog due to internal work
195 bool mSuppressAutoSaveDialog = false;
196
197 Ui::MainWindow2* ui = nullptr;
198};
199
200#endif // MAINWINDOW2_H
ActionCommands
Definition: actioncommands.h:30
AddTransparencyToPaperDialog
Definition: addtransparencytopaperdialog.h:34
AutosaverByTime
Definition: autosaverbytime.h:11
BaseDockWidget
Definition: basedockwidget.h:27
ColorBox
Definition: colorbox.h:24
ColorInspector
Definition: colorinspector.h:27
ColorPaletteWidget
Definition: colorpalettewidget.h:39
Editor
Definition: editor.h:71
ImportImageSeqDialog
Definition: importimageseqdialog.h:46
LayerOpacityDialog
Definition: layeropacitydialog.h:22
MainWindow2
Definition: mainwindow2.h:58
MainWindow2::windowActivated
void windowActivated()
Emitted when window regains focus.
Object
Definition: object.h:42
OnionSkinWidget
Definition: onionskinwidget.h:32
PegBarAlignmentDialog
Definition: pegbaralignmentdialog.h:29
PreferencesDialog
Definition: preferencesdialog.h:30
RecentFileMenu
Definition: recentfilemenu.h:30
RepositionFramesDialog
Definition: repositionframesdialog.h:16
ScribbleArea
Definition: scribblearea.h:51
StatusBar
The status bar of Pencil2D's main window.
Definition: statusbar.h:34
TimeLine
Definition: timeline.h:32
ToolBoxDockWidget
Definition: toolbox.h:35
ToolOptionWidget
Definition: tooloptionwidget.h:37
UndoRedoCommand
Definition: undoredocommand.h:40
QActionGroup
QCloseEvent
QEvent
QIcon
QList
QMainWindow
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::parent
QObject * parent() const const
QString
QTabletEvent
QToolBar
QWidget
Generated on Wed Apr 29 2026 06:05:08 for Pencil2D by doxygen 1.9.6 based on revision 5841f625b8680b86111af64be6a1235440cd8ff2