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
107 void onFocusRequested(QWidget* widget);
108
109signals:
111 void windowActivated();
112
113protected:
114 void tabletEvent(QTabletEvent*) override;
115 void closeEvent(QCloseEvent*) override;
116 bool event(QEvent*) override;
117
118private slots:
119 void updateCopyCutPasteEnabled();
120 void updateLayerMenu();
121 void autoSaveTimeout();
122private:
123 void newObject();
124 bool newObjectFromPresets(int presetIndex);
125 bool openObject(const QString& strFilename);
126 bool saveObject(QString strFileName);
127 void closeDialogs();
128
129 void createDockWidgets();
130 void createMenus();
131 void replaceUndoRedoActions();
132 void setupKeyboardShortcuts();
133 void clearKeyboardShortcuts();
134 bool loadMostRecent();
135 bool tryLoadPreset();
136
137 void openPalette();
138 void importPalette();
139 void exportPalette();
140
141 void readSettings();
142 void writeSettings();
143 void resetAndDockAllSubWidgets();
144
145 void changePlayState(bool isPlaying);
146
147 void makeConnections(Editor*);
148 void makeConnections(Editor*, ColorBox* colorBox);
149 void makeConnections(Editor*, ColorInspector*);
150 void makeConnections(Editor*, ScribbleArea*);
151 void makeConnections(Editor*, ColorPaletteWidget*);
152 void makeConnections(Editor*, TimeLine*);
153 void makeConnections(Editor*, ToolOptionWidget*);
154 void makeConnections(Editor*, OnionSkinWidget*);
155 void makeConnections(Editor*, StatusBar*);
156
157 bool checkForRecoverableProjects();
158 bool tryRecoverProject(const QString recoverPath);
159 bool startProjectRecovery(const QString recoverPath);
160
161 // UI: Dock widgets
162 ColorBox* mColorBox = nullptr;
163 ColorPaletteWidget* mColorPalette = nullptr;
164 ToolOptionWidget* mToolOptions = nullptr;
165 ToolBoxDockWidget* mToolBox = nullptr;
166 RecentFileMenu* mRecentFileMenu = nullptr;
167 PreferencesDialog* mPrefDialog = nullptr;
168 //PreviewWidget* mPreview = nullptr;
169 TimeLine* mTimeLine = nullptr;
170 ColorInspector* mColorInspector = nullptr;
171 OnionSkinWidget* mOnionSkinWidget = nullptr;
172 QToolBar* mMainToolbar = nullptr;
173 QToolBar* mViewToolbar = nullptr;
174 QToolBar* mOverlayToolbar = nullptr;
175
176 PegBarAlignmentDialog* mPegAlign = nullptr;
177 RepositionFramesDialog* mReposDialog = nullptr;
178 LayerOpacityDialog* mLayerOpacityDialog = nullptr;
179 AddTransparencyToPaperDialog* mAddTranspToPaper = nullptr;
180
181 // Autosave handler
182 AutosaverByTime* mAutoSaver = nullptr;
183
184 void createToolbars();
185private:
186 ActionCommands* mCommands = nullptr;
187 QList<BaseDockWidget*> mDockWidgets;
188 QList<QToolBar*> mToolbars;
189
190 QIcon mStartIcon;
191 QIcon mStopIcon;
192
193 // a hack for MacOS because closeEvent fires twice
194 bool m2ndCloseEvent = false;
195
196 // Whether to suppress the auto save dialog due to internal work
197 bool mSuppressAutoSaveDialog = false;
198
199 Ui::MainWindow2* ui = nullptr;
200};
201
202#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 Mon May 4 2026 07:50:47 for Pencil2D by doxygen 1.9.6 based on revision 3ed50cdd696e72315cedf30508d3572536c3876e