19#include "mainwindow2.h"
20#include "ui_mainwindow2.h"
23#include <QActionGroup>
29#include <QProgressDialog>
30#include <QTabletEvent>
31#include <QStandardPaths>
40#include "pencilsettings.h"
44#include "filemanager.h"
45#include "colormanager.h"
46#include "layermanager.h"
47#include "toolmanager.h"
48#include "playbackmanager.h"
49#include "selectionmanager.h"
50#include "soundmanager.h"
51#include "viewmanager.h"
52#include "selectionmanager.h"
53#include "undoredomanager.h"
55#include "actioncommands.h"
56#include "fileformat.h"
58#include "undoredocommand.h"
62#include "colorinspector.h"
63#include "colorpalettewidget.h"
64#include "tooloptionwidget.h"
65#include "preferencesdialog.h"
68#include "onionskinwidget.h"
69#include "pegbaralignmentdialog.h"
70#include "repositionframesdialog.h"
72#include "errordialog.h"
73#include "filedialog.h"
74#include "importimageseqdialog.h"
75#include "importlayersdialog.h"
76#include "importpositiondialog.h"
77#include "layeropacitydialog.h"
78#include "recentfilemenu.h"
79#include "shortcutfilter.h"
81#include "presetdialog.h"
82#include "pegbaralignmentdialog.h"
86#define BUILD_DATE S__GIT_TIMESTAMP
88#define BUILD_DATE __DATE__
91#if defined(PENCIL2D_RELEASE_BUILD)
92#define PENCIL_WINDOW_TITLE QString("[*]Pencil2D v%1").arg(APP_VERSION)
93#elif defined(PENCIL2D_NIGHTLY_BUILD)
94#define PENCIL_WINDOW_TITLE QString("[*]Pencil2D Nightly Build %1").arg(BUILD_DATE)
96#define PENCIL_WINDOW_TITLE QString("[*]Pencil2D Development Build %1").arg(BUILD_DATE)
101MainWindow2::MainWindow2(
QWidget* parent) :
109 mEditor =
new Editor(
this);
110 mEditor->setScribbleArea(ui->scribbleArea);
115 ui->scribbleArea->setEditor(mEditor);
116 ui->scribbleArea->init();
118 ui->statusBar->setEditor(mEditor);
119 ui->statusBar->updateZoomStatus();
120 ui->statusBar->setVisible(mEditor->preference()->isOn(SETTING::SHOW_STATUS_BAR));
123 mCommands->setCore(mEditor);
128 setupKeyboardShortcuts();
133 currentLayerChanged();
135 connect(mEditor, &Editor::needSave,
this, &MainWindow2::autoSave);
137 mEditor->tools()->setDefaultTool();
138 ui->background->init(mEditor->preference());
140 setWindowTitle(PENCIL_WINDOW_TITLE);
143MainWindow2::~MainWindow2()
148void MainWindow2::createDockWidgets()
154 mColorBox->
setToolTip(
tr(
"color palette:<br>use <b>(C)</b><br>toggle at cursor"));
162 mColorPalette->setCore(mEditor);
183 mStartIcon =
QIcon(
":icons/controls/play.png");
184 mStopIcon =
QIcon(
":icons/controls/stop.png");
189 pWidget->setFeatures(QDockWidget::DockWidgetFeature::DockWidgetClosable |
190 QDockWidget::DockWidgetFeature::DockWidgetMovable |
191 QDockWidget::DockWidgetFeature::DockWidgetFloatable);
194 pWidget->setEditor(mEditor);
196 qDebug() <<
"Init Dock widget: " << pWidget->objectName();
216 makeConnections(mEditor, ui->scribbleArea);
217 makeConnections(mEditor);
218 makeConnections(mEditor, mTimeLine);
219 makeConnections(mEditor, mColorBox);
220 makeConnections(mEditor, mColorInspector);
221 makeConnections(mEditor, mColorPalette);
222 makeConnections(mEditor, mToolOptions);
223 makeConnections(mEditor, ui->statusBar);
227 w->setFloating(
false);
233void MainWindow2::createMenus()
266 replaceUndoRedoActions();
272 connect(mEditor->select(), &SelectionManager::selectionChanged,
this, &MainWindow2::selectionChanged);
287 connect(ui->actionChangeLineColorCurrent_keyframe, &
QAction::triggered, mCommands, &ActionCommands::changeKeyframeLineColor);
288 connect(ui->actionChangeLineColorAll_keyframes_on_layer, &
QAction::triggered, mCommands, &ActionCommands::changeallKeyframeLineColor);
291 QList<QAction*> visibilityActions = ui->menuLayer_Visibility->actions();
293 visibilityGroup->setExclusive(
true);
294 for (
int i = 0; i < visibilityActions.
size(); i++) {
295 QAction* action = visibilityActions[i];
296 visibilityGroup->addAction(action);
299 visibilityActions[mEditor->preference()->getInt(SETTING::LAYER_VISIBILITY)]->setChecked(
true);
300 connect(mEditor->preference(), &PreferenceManager::optionChanged, [=](SETTING e) {
301 if (e == SETTING::LAYER_VISIBILITY) {
302 visibilityActions[mEditor->preference()->getInt(SETTING::LAYER_VISIBILITY)]->setChecked(true);
308 connect(ui->actionZoom_Out, &
QAction::triggered, mCommands, &ActionCommands::ZoomOut);
309 connect(ui->actionRotate_Clockwise, &
QAction::triggered, mCommands, &ActionCommands::rotateClockwise);
310 connect(ui->actionRotate_Anticlockwise, &
QAction::triggered, mCommands, &ActionCommands::rotateCounterClockwise);
311 connect(ui->actionReset_Rotation, &
QAction::triggered, mEditor->view(), &ViewManager::resetRotation);
312 connect(ui->actionReset_View, &
QAction::triggered, mEditor->view(), &ViewManager::resetView);
313 connect(ui->actionCenter_View, &
QAction::triggered, mEditor->view(), &ViewManager::centerView);
314 connect(ui->actionZoom400, &
QAction::triggered, mEditor->view(), &ViewManager::scale400);
315 connect(ui->actionZoom300, &
QAction::triggered, mEditor->view(), &ViewManager::scale300);
316 connect(ui->actionZoom200, &
QAction::triggered, mEditor->view(), &ViewManager::scale200);
317 connect(ui->actionZoom100, &
QAction::triggered, mEditor->view(), &ViewManager::scale100);
318 connect(ui->actionZoom50, &
QAction::triggered, mEditor->view(), &ViewManager::scale50);
319 connect(ui->actionZoom33, &
QAction::triggered, mEditor->view(), &ViewManager::scale33);
320 connect(ui->actionZoom25, &
QAction::triggered, mEditor->view(), &ViewManager::scale25);
321 connect(ui->actionHorizontal_Flip, &
QAction::triggered, mEditor->view(), &ViewManager::flipHorizontal);
322 connect(ui->actionVertical_Flip, &
QAction::triggered, mEditor->view(), &ViewManager::flipVertical);
323 connect(mEditor->view(), &ViewManager::viewFlipped,
this, &MainWindow2::viewFlipped);
327 bindPreferenceSetting(ui->actionStatusBar, prefs, SETTING::SHOW_STATUS_BAR);
328 bindPreferenceSetting(ui->actionThreePointPerspective, prefs, SETTING::OVERLAY_PERSPECTIVE3);
329 bindPreferenceSetting(ui->actionTwoPointPerspective, prefs, SETTING::OVERLAY_PERSPECTIVE2);
330 bindPreferenceSetting(ui->actionOnePointPerspective, prefs, SETTING::OVERLAY_PERSPECTIVE1);
331 bindPreferenceSetting(ui->actionSafeAreas, prefs, SETTING::OVERLAY_SAFE);
332 bindPreferenceSetting(ui->actionGoldenRatio, prefs, SETTING::OVERLAY_GOLDEN);
333 bindPreferenceSetting(ui->actionThirds, prefs, SETTING::OVERLAY_THIRDS);
334 bindPreferenceSetting(ui->actionCenter, prefs, SETTING::OVERLAY_CENTER);
335 bindPreferenceSetting(ui->actionGrid, prefs, SETTING::GRID);
336 bindPreferenceSetting(ui->actionShowOutlinesOnly, prefs, SETTING::OUTLINES);
337 bindPreferenceSetting(ui->actionShowInvisibleLines, prefs, SETTING::INVISIBLE_LINES);
338 bindPreferenceSetting(ui->actionOnionPrev, prefs, SETTING::PREV_ONION);
339 bindPreferenceSetting(ui->actionOnionNext, prefs, SETTING::NEXT_ONION);
341 bool enableSafeArea = (prefs->isOn(SETTING::ACTION_SAFE_ON) || prefs->isOn(SETTING::TITLE_SAFE_ON));
342 ui->actionSafeAreas->setEnabled(enableSafeArea);
344 auto perspectiveLinesAngleGroup =
new QActionGroup(
this);
345 perspectiveLinesAngleGroup->setExclusive(
true);
346 perspectiveLinesAngleGroup->addAction(ui->action2Degrees);
347 perspectiveLinesAngleGroup->addAction(ui->action3Degrees);
348 perspectiveLinesAngleGroup->addAction(ui->action5Degrees);
349 perspectiveLinesAngleGroup->addAction(ui->action7_5Degrees);
350 perspectiveLinesAngleGroup->addAction(ui->action10Degrees);
351 perspectiveLinesAngleGroup->addAction(ui->action15Degrees);
352 perspectiveLinesAngleGroup->addAction(ui->action20Degrees);
353 perspectiveLinesAngleGroup->addAction(ui->action30Degrees);
355 if (action == ui->action2Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 2);
356 else if (action == ui->action3Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 3);
357 else if (action == ui->action5Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 5);
358 else if (action == ui->action7_5Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 7);
359 else if (action == ui->action10Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 10);
360 else if (action == ui->action15Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 15);
361 else if (action == ui->action20Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 20);
362 else if (action == ui->action30Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 30);
363 else Q_UNREACHABLE();
364 emit mEditor->view()->viewChanged();
367 switch (prefs->getInt(SETTING::OVERLAY_ANGLE)) {
368 case 2: ui->action2Degrees->setChecked(
true);
break;
369 case 3: ui->action3Degrees->setChecked(
true);
break;
370 case 5: ui->action5Degrees->setChecked(
true);
break;
371 case 7: ui->action7_5Degrees->setChecked(
true);
break;
372 case 10: ui->action10Degrees->setChecked(
true);
break;
373 case 15: ui->action15Degrees->setChecked(
true);
break;
374 case 20: ui->action20Degrees->setChecked(
true);
break;
375 case 30: ui->action30Degrees->setChecked(
true);
break;
382 connect(ui->actionLoop, &
QAction::triggered, pPlaybackManager, &PlaybackManager::setLooping);
383 connect(ui->actionLoopControl, &
QAction::triggered, pPlaybackManager, &PlaybackManager::enableRangedPlayback);
384 connect(pPlaybackManager, &PlaybackManager::loopStateChanged, ui->actionLoop, &
QAction::setChecked);
385 connect(pPlaybackManager, &PlaybackManager::loopStateChanged, mTimeLine, &TimeLine::setLoop);
386 connect(pPlaybackManager, &PlaybackManager::rangedPlaybackStateChanged, ui->actionLoopControl, &
QAction::setChecked);
387 connect(pPlaybackManager, &PlaybackManager::rangedPlaybackStateChanged, mTimeLine, &TimeLine::setRangeState);
388 connect(pPlaybackManager, &PlaybackManager::playStateChanged, mTimeLine, &TimeLine::setPlaying);
389 connect(pPlaybackManager, &PlaybackManager::playStateChanged,
this, &MainWindow2::changePlayState);
391 connect(ui->actionFlip_inbetween, &
QAction::triggered, pPlaybackManager, &PlaybackManager::playFlipInBetween);
392 connect(ui->actionFlip_rolling, &
QAction::triggered, pPlaybackManager, &PlaybackManager::playFlipRoll);
395 connect(ui->actionRemove_Frame, &
QAction::triggered, mCommands, &ActionCommands::removeKey);
396 connect(ui->actionAdd_Frame_Exposure, &
QAction::triggered, mCommands, &ActionCommands::addExposureToSelectedFrames);
397 connect(ui->actionSubtract_Frame_Exposure, &
QAction::triggered, mCommands, &ActionCommands::subtractExposureFromSelectedFrames);
398 connect(ui->actionNext_Frame, &
QAction::triggered, mCommands, &ActionCommands::GotoNextFrame);
399 connect(ui->actionPrevious_Frame, &
QAction::triggered, mCommands, &ActionCommands::GotoPrevFrame);
400 connect(ui->actionNext_KeyFrame, &
QAction::triggered, mCommands, &ActionCommands::GotoNextKeyFrame);
401 connect(ui->actionPrev_KeyFrame, &
QAction::triggered, mCommands, &ActionCommands::GotoPrevKeyFrame);
402 connect(ui->actionDuplicate_Frame, &
QAction::triggered, mCommands, &ActionCommands::duplicateKey);
403 connect(ui->actionMove_Frame_Forward, &
QAction::triggered, mCommands, &ActionCommands::moveFrameForward);
404 connect(ui->actionMove_Frame_Backward, &
QAction::triggered, mCommands, &ActionCommands::moveFrameBackward);
406 connect(ui->actionReverse_Frames_Order, &
QAction::triggered, mCommands, &ActionCommands::reverseSelectedFrames);
407 connect(ui->actionRemove_Frames, &
QAction::triggered, mCommands, &ActionCommands::removeSelectedFrames);
413 connect(ui->actionPolyline, &
QAction::triggered, mToolBox, &ToolBoxWidget::polylineOn);
419 connect(ui->actionEyedropper, &
QAction::triggered, mToolBox, &ToolBoxWidget::eyedropperOn);
421 connect(ui->actionResetToolsDefault, &
QAction::triggered, mEditor->tools(), &ToolManager::resetAllTools);
424 QMenu* winMenu = ui->menuWindows;
425 const std::vector<QAction*> actions
427 mToolBox->toggleViewAction(),
428 mToolOptions->toggleViewAction(),
429 mColorBox->toggleViewAction(),
430 mColorPalette->toggleViewAction(),
431 mTimeLine->toggleViewAction(),
432 mColorInspector->toggleViewAction(),
433 mOnionSkinWidget->toggleViewAction()
436 for (
QAction* action : actions)
439 winMenu->
insertAction(ui->menuToolbars->menuAction(), action);
442 connect(ui->actionResetWindows, &
QAction::triggered,
this, &MainWindow2::resetAndDockAllSubWidgets);
443 connect(ui->actionLockWindows, &
QAction::toggled,
this, &MainWindow2::lockWidgets);
444 bindPreferenceSetting(ui->actionLockWindows, prefs, SETTING::LAYOUT_LOCK);
448 connect(ui->actionQuick_Guide, &
QAction::triggered, mCommands, &ActionCommands::quickGuide);
452 connect(ui->actionCheck_for_Updates, &
QAction::triggered, mCommands, &ActionCommands::checkForUpdates);
453 connect(ui->actionReport_Bug, &
QAction::triggered, mCommands, &ActionCommands::reportbug);
454 connect(ui->actionOpen_Temporary_Directory, &
QAction::triggered, mCommands, &ActionCommands::openTemporaryDirectory);
459 mRecentFileMenu->loadFromDisk();
460 ui->menuFile->insertMenu(ui->actionSave, mRecentFileMenu);
462 connect(mRecentFileMenu, &RecentFileMenu::loadRecentFile,
this, &MainWindow2::openFile);
465void MainWindow2::replaceUndoRedoActions()
467 ui->menuEdit->removeAction(ui->actionUndo);
468 ui->menuEdit->removeAction(ui->actionRedo);
469 ui->actionUndo = mEditor->undoRedo()->createUndoAction(
this, ui->actionUndo->icon());
470 ui->actionRedo = mEditor->undoRedo()->createRedoAction(
this, ui->actionRedo->icon());
471 ui->menuEdit->insertAction(ui->actionCut, ui->actionUndo);
472 ui->menuEdit->insertAction(ui->actionCut, ui->actionRedo);
475void MainWindow2::setOpacity(
int opacity)
477 mEditor->preference()->set(SETTING::WINDOW_OPACITY, 100 - opacity);
481void MainWindow2::updateSaveState()
485 ui->statusBar->updateModifiedStatus(hasUnsavedChanges);
488void MainWindow2::updateBackupActionState()
490 mEditor->undoRedo()->updateUndoAction(ui->actionUndo);
491 mEditor->undoRedo()->updateRedoAction(ui->actionRedo);
494void MainWindow2::openPegAlignDialog()
496 if (mPegAlign !=
nullptr)
499 tr(
"Dialog is already open!"),
509 flags &= (
~Qt::WindowContextHelpButtonHint);
518void MainWindow2::openLayerOpacityDialog()
520 if (mLayerOpacityDialog !=
nullptr)
523 tr(
"Dialog is already open!"),
529 mLayerOpacityDialog->setCore(mEditor);
530 mLayerOpacityDialog->initUI();
532 mLayerOpacityDialog->
show();
536 mLayerOpacityDialog =
nullptr;
540void MainWindow2::openRepositionDialog()
542 if (mEditor->layers()->currentLayer()->getSelectedFramesByPos().
count() < 2)
545 tr(
"Please select at least 2 frames!"),
549 if (mReposDialog !=
nullptr)
557 hideQuestionMark(*mReposDialog);
558 mReposDialog->setCore(mEditor);
559 mReposDialog->initUI();
560 mEditor->tools()->setCurrentTool(ToolType::MOVE);
562 mReposDialog->
show();
565void MainWindow2::closeRepositionDialog()
568 mReposDialog =
nullptr;
571void MainWindow2::currentLayerChanged()
573 bool isBitmap = (mEditor->layers()->currentLayer()->type() == Layer::BITMAP);
574 ui->menuChange_line_color->setEnabled(isBitmap);
576 bool isVector = (mEditor->layers()->currentLayer()->type() == Layer::VECTOR);
577 ui->actionShowInvisibleLines->setEnabled(isVector);
578 ui->actionShowOutlinesOnly->setEnabled(isVector);
581void MainWindow2::selectionChanged()
583 bool somethingSelected = mEditor->select()->somethingSelected();
584 ui->menuSelection->setEnabled(somethingSelected);
587void MainWindow2::viewFlipped()
589 ui->actionHorizontal_Flip->setChecked(mEditor->view()->isFlipHorizontal());
590 ui->actionVertical_Flip->setChecked(mEditor->view()->isFlipVertical());
609 m2ndCloseEvent =
true;
617void MainWindow2::newDocument()
619 if (maybeSave() && !tryLoadPreset())
625void MainWindow2::openDocument()
634 openObject(fileName);
638bool MainWindow2::saveAsNewDocument()
645 return saveObject(fileName);
648void MainWindow2::openStartupFile(
const QString& filename)
650 if (tryRecoverUnsavedProject())
655 if (!filename.
isEmpty() && openObject(filename))
660 loadMostRecent() || tryLoadPreset();
663void MainWindow2::openFile(
const QString& filename)
667 openObject(filename);
671bool MainWindow2::openObject(
const QString& strFilePath)
674 hideQuestionMark(progress);
678 Status s = mEditor->openObject(strFilePath, [&progress](
int p)
680 progress.setValue(p);
682 }, [&progress](
int max)
684 progress.setRange(0, max);
689 ErrorDialog errorDialog(s.title(), s.description(), s.details().str());
691 emptyDocumentWhenErrorOccurred();
696 settings.setValue(LAST_PCLX_PATH, mEditor->object()->filePath());
699 if (!mEditor->object()->filePath().
isEmpty())
701 mRecentFileMenu->addRecentFile(mEditor->object()->filePath());
702 mRecentFileMenu->saveToDisk();
709 ui->statusBar->updateModifiedStatus(
false);
711 progress.setValue(progress.maximum());
714 updateBackupActionState();
716 if (!
QFileInfo(strFilePath).isWritable())
719 tr(
"This program does not currently have permission to write to the file you have selected. "
720 "Please make sure you have write permission for this file before attempting to save it. "
721 "Alternatively, you can use the Save As... menu option to save to a writable location."),
728bool MainWindow2::saveObject(
QString strSavedFileName)
731 hideQuestionMark(progress);
735 mEditor->prepareSave();
739 connect(&fm, &FileManager::progressChanged, [&progress](
int p)
741 progress.setValue(p);
744 connect(&fm, &FileManager::progressRangeChanged, [&progress](
int max)
746 progress.setRange(0, max + 3);
749 Status st = fm.save(mEditor->object(), strSavedFileName);
754#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
759 errorLogFolder.mkpath(
"./logs");
760 errorLogFolder.cd(
"logs");
768 out << st.details().str();
773 st.description().append(
tr(
"<br><br>An error has occurred and your file may not have saved successfully."
774 "\nIf you believe that this error is an issue with Pencil2D, please create a new issue at:"
775 "<br><a href='https://github.com/pencil2d/pencil/issues'>https://github.com/pencil2d/pencil/issues</a><br>"
776 "Please be sure to include the following details in your issue:")), st.details().html());
781 mEditor->object()->setFilePath(strSavedFileName);
782 mEditor->object()->setModified(
false);
784 mEditor->clearTemporary();
787 settings.setValue(LAST_PCLX_PATH, strSavedFileName);
789 mRecentFileMenu->addRecentFile(strSavedFileName);
790 mRecentFileMenu->saveToDisk();
792 mTimeLine->updateContent();
797 progress.setValue(progress.maximum());
799 mEditor->resetAutoSaveCounter();
804bool MainWindow2::saveDocument()
806 if (!mEditor->object()->filePath().
isEmpty())
807 return saveObject(mEditor->object()->filePath());
809 return saveAsNewDocument();
812bool MainWindow2::maybeSave()
820 tr(
"This animation has been modified.\n Do you want to save your changes?"),
823 return saveDocument();
828bool MainWindow2::autoSave()
830 if (!mEditor->object()->filePath().
isEmpty())
832 return saveDocument();
835 if (mEditor->autoSaveNeverAskAgain())
838 if(mSuppressAutoSaveDialog)
843 msgBox.setWindowTitle(
tr(
"AutoSave Reminder"));
844 msgBox.setText(
tr(
"The animation is not saved yet.\n Do you want to save now?"));
849 int ret = msgBox.exec();
852 return saveDocument();
856 mEditor->dontAskAutoSave(
true);
862void MainWindow2::emptyDocumentWhenErrorOccurred()
870void MainWindow2::importImage()
874 if (strFilePath.
isEmpty()) {
return; }
878 OnScopeExit(
delete positionDialog)
880 positionDialog->
exec();
887 Status st = mEditor->importImage(strFilePath);
890 ErrorDialog errorDialog(st.title(), st.description(), st.details().html());
895 ui->scribbleArea->updateFrame();
896 mTimeLine->updateContent();
899void MainWindow2::importImageSequence()
901 mSuppressAutoSaveDialog =
true;
904 OnScopeExit(
delete imageSeqDialog)
905 imageSeqDialog->setCore(mEditor);
909 imageSeqDialog->
exec();
916 OnScopeExit(
delete positionDialog)
918 positionDialog->
exec();
924 imageSeqDialog->importArbitrarySequence();
926 mSuppressAutoSaveDialog =
false;
929void MainWindow2::importPredefinedImageSet()
932 OnScopeExit(
delete imageSeqDialog)
933 imageSeqDialog->setCore(mEditor);
937 mSuppressAutoSaveDialog =
true;
938 imageSeqDialog->
exec();
945 OnScopeExit(
delete positionDialog)
947 positionDialog->
exec();
953 imageSeqDialog->importPredefinedSet();
954 mSuppressAutoSaveDialog =
false;
957void MainWindow2::importLayers()
960 importLayers->setCore(mEditor);
962 importLayers->
open();
965void MainWindow2::importAnimatedImage()
968 mSuppressAutoSaveDialog =
true;
970 mCommands->importAnimatedImage();
972 mSuppressAutoSaveDialog =
false;
975void MainWindow2::lockWidgets(
bool shouldLock)
979 : (QDockWidget::DockWidgetFeature::DockWidgetClosable |
980 QDockWidget::DockWidgetFeature::DockWidgetMovable |
981 QDockWidget::DockWidgetFeature::DockWidgetFloatable);
985 d->setFeatures(feat);
990 QWidget* customTitleBarWidget = shouldLock ? (
new QWidget) :
nullptr;
991 d->setTitleBarWidget(customTitleBarWidget);
995void MainWindow2::preferences()
1000 mPrefDialog->
raise();
1006 mPrefDialog->init(mEditor->preference());
1008 connect(mPrefDialog, &PreferencesDialog::windowOpacityChange,
this, &MainWindow2::setOpacity);
1009 connect(mPrefDialog, &PreferencesDialog::soundScrubChanged, mEditor->playback(), &PlaybackManager::setSoundScrubActive);
1010 connect(mPrefDialog, &PreferencesDialog::soundScrubMsecChanged, mEditor->playback(), &PlaybackManager::setSoundScrubMsec);
1013 clearKeyboardShortcuts();
1014 setupKeyboardShortcuts();
1015 mPrefDialog =
nullptr;
1018 mPrefDialog->
show();
1021void MainWindow2::resetAndDockAllSubWidgets()
1024 settings.remove(SETTING_WINDOW_GEOMETRY);
1025 settings.remove(SETTING_WINDOW_STATE);
1029 dock->setFloating(
false);
1043void MainWindow2::newObject()
1045 auto object =
new Object();
1049 object->addNewCameraLayer();
1050 object->addNewBitmapLayer();
1054 object->data()->setCurrentLayer(1);
1056 mEditor->setObject(
object);
1062 updateBackupActionState();
1065bool MainWindow2::newObjectFromPresets(
int presetIndex)
1067 QString presetFilePath = PresetDialog::getPresetPath(presetIndex);
1075 Object*
object = fm.load(presetFilePath);
1077 if (!fm.error().ok() ||
object ==
nullptr)
1082 mEditor->setObject(
object);
1083 object->setFilePath(
QString());
1087 updateBackupActionState();
1092bool MainWindow2::loadMostRecent()
1094 if(!mEditor->preference()->isOn(SETTING::LOAD_MOST_RECENT))
1100 QString myPath = settings.value(LAST_PCLX_PATH,
QVariant(
"")).toString();
1105 return openObject(myPath);
1108bool MainWindow2::tryLoadPreset()
1110 if (!mEditor->preference()->isOn(SETTING::ASK_FOR_PRESET))
1112 int defaultPreset = mEditor->preference()->getInt(SETTING::DEFAULT_PRESET);
1113 return newObjectFromPresets(defaultPreset);
1125 int presetIndex = presetDialog->getPresetIndex();
1126 if (presetDialog->shouldAlwaysUse())
1128 mEditor->preference()->set(SETTING::ASK_FOR_PRESET, false);
1129 mEditor->preference()->set(SETTING::DEFAULT_PRESET, presetIndex);
1131 if (!newObjectFromPresets(presetIndex))
1136 presetDialog->
open();
1140void MainWindow2::closeDialogs()
1147void MainWindow2::readSettings()
1151 QVariant winGeometry = settings.
value(SETTING_WINDOW_GEOMETRY);
1157 int opacity = mEditor->preference()->getInt(SETTING::WINDOW_OPACITY);
1158 setOpacity(100 - opacity);
1160 bool isWindowsLocked = mEditor->preference()->isOn(SETTING::LAYOUT_LOCK);
1161 lockWidgets(isWindowsLocked);
1164void MainWindow2::writeSettings()
1167 settings.setValue(SETTING_WINDOW_GEOMETRY,
saveGeometry());
1168 settings.setValue(SETTING_WINDOW_STATE,
saveState());
1171void MainWindow2::setupKeyboardShortcuts()
1173 checkExistingShortcuts();
1177 strCommandName =
QString(
"shortcuts/") + strCommandName;
1183 ui->actionNew->setShortcut(cmdKeySeq(CMD_NEW_FILE));
1184 ui->actionOpen->setShortcut(cmdKeySeq(CMD_OPEN_FILE));
1185 ui->actionSave->setShortcut(cmdKeySeq(CMD_SAVE_FILE));
1186 ui->actionSave_as->setShortcut(cmdKeySeq(CMD_SAVE_AS));
1188 ui->actionImport_Image->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE));
1189 ui->actionImport_ImageSeq->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE_SEQ));
1190 ui->actionImport_ImageSeqNum->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE_PREDEFINED_SET));
1191 ui->actionImport_MovieVideo->setShortcut(cmdKeySeq(CMD_IMPORT_MOVIE_VIDEO));
1192 ui->actionImport_AnimatedImage->setShortcut(cmdKeySeq(CMD_IMPORT_ANIMATED_IMAGE));
1193 ui->actionImportLayers_from_pclx->setShortcut(cmdKeySeq(CMD_IMPORT_LAYERS));
1194 ui->actionImport_Sound->setShortcut(cmdKeySeq(CMD_IMPORT_SOUND));
1195 ui->actionImport_MovieAudio->setShortcut(cmdKeySeq(CMD_IMPORT_MOVIE_AUDIO));
1196 ui->actionImport_Append_Palette->setShortcut(cmdKeySeq(CMD_IMPORT_PALETTE));
1197 ui->actionImport_Replace_Palette->setShortcut(cmdKeySeq(CMD_IMPORT_PALETTE_REPLACE));
1199 ui->actionExport_Image->setShortcut(cmdKeySeq(CMD_EXPORT_IMAGE));
1200 ui->actionExport_ImageSeq->setShortcut(cmdKeySeq(CMD_EXPORT_IMAGE_SEQ));
1201 ui->actionExport_Movie->setShortcut(cmdKeySeq(CMD_EXPORT_MOVIE));
1202 ui->actionExport_Animated_GIF->setShortcut(cmdKeySeq(CMD_EXPORT_GIF));
1203 ui->actionExport_Palette->setShortcut(cmdKeySeq(CMD_EXPORT_PALETTE));
1206 ui->actionUndo->setShortcut(cmdKeySeq(CMD_UNDO));
1207 ui->actionRedo->setShortcut(cmdKeySeq(CMD_REDO));
1208 ui->actionCut->setShortcut(cmdKeySeq(CMD_CUT));
1209 ui->actionCopy->setShortcut(cmdKeySeq(CMD_COPY));
1210 ui->actionPaste_Previous->setShortcut(cmdKeySeq(CMD_PASTE_FROM_PREVIOUS));
1211 ui->actionPaste->setShortcut(cmdKeySeq(CMD_PASTE));
1212 ui->actionClearFrame->setShortcut(cmdKeySeq(CMD_CLEAR_FRAME));
1213 ui->actionFlip_X->setShortcut(cmdKeySeq(CMD_SELECTION_FLIP_HORIZONTAL));
1214 ui->actionFlip_Y->setShortcut(cmdKeySeq(CMD_SELECTION_FLIP_VERTICAL));
1215 ui->actionSelect_All->setShortcut(cmdKeySeq(CMD_SELECT_ALL));
1216 ui->actionDeselect_All->setShortcut(cmdKeySeq(CMD_DESELECT_ALL));
1217 ui->actionPegbarAlignment->setShortcut(cmdKeySeq(CMD_PEGBAR_ALIGNMENT));
1218 ui->actionPreference->setShortcut(cmdKeySeq(CMD_PREFERENCE));
1221 ui->actionResetWindows->setShortcut(cmdKeySeq(CMD_RESET_WINDOWS));
1222 ui->actionLockWindows->setShortcut(cmdKeySeq(CMD_LOCK_WINDOWS));
1223 ui->actionReset_View->setShortcut(cmdKeySeq(CMD_RESET_ZOOM_ROTATE));
1224 ui->actionCenter_View->setShortcut(cmdKeySeq(CMD_CENTER_VIEW));
1225 ui->actionZoom_In->setShortcut(cmdKeySeq(CMD_ZOOM_IN));
1226 ui->actionZoom_Out->setShortcut(cmdKeySeq(CMD_ZOOM_OUT));
1227 ui->actionZoom400->setShortcut(cmdKeySeq(CMD_ZOOM_400));
1228 ui->actionZoom300->setShortcut(cmdKeySeq(CMD_ZOOM_300));
1229 ui->actionZoom200->setShortcut(cmdKeySeq(CMD_ZOOM_200));
1230 ui->actionZoom100->setShortcut(cmdKeySeq(CMD_ZOOM_100));
1231 ui->actionZoom50->setShortcut(cmdKeySeq(CMD_ZOOM_50));
1232 ui->actionZoom33->setShortcut(cmdKeySeq(CMD_ZOOM_33));
1233 ui->actionZoom25->setShortcut(cmdKeySeq(CMD_ZOOM_25));
1234 ui->actionRotate_Clockwise->setShortcut(cmdKeySeq(CMD_ROTATE_CLOCK));
1235 ui->actionRotate_Anticlockwise->setShortcut(cmdKeySeq(CMD_ROTATE_ANTI_CLOCK));
1236 ui->actionReset_Rotation->setShortcut(cmdKeySeq(CMD_RESET_ROTATION));
1237 ui->actionHorizontal_Flip->setShortcut(cmdKeySeq(CMD_FLIP_HORIZONTAL));
1238 ui->actionVertical_Flip->setShortcut(cmdKeySeq(CMD_FLIP_VERTICAL));
1239 ui->actionGrid->setShortcut(cmdKeySeq(CMD_GRID));
1240 ui->actionCenter->setShortcut(cmdKeySeq(CMD_OVERLAY_CENTER));
1241 ui->actionThirds->setShortcut(cmdKeySeq(CMD_OVERLAY_THIRDS));
1242 ui->actionGoldenRatio->setShortcut(cmdKeySeq(CMD_OVERLAY_GOLDEN_RATIO));
1243 ui->actionSafeAreas->setShortcut(cmdKeySeq(CMD_OVERLAY_SAFE_AREAS));
1244 ui->actionOnePointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_ONE_POINT_PERSPECTIVE));
1245 ui->actionTwoPointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_TWO_POINT_PERSPECTIVE));
1246 ui->actionThreePointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_THREE_POINT_PERSPECTIVE));
1247 ui->actionOnionPrev->setShortcut(cmdKeySeq(CMD_ONIONSKIN_PREV));
1248 ui->actionOnionNext->setShortcut(cmdKeySeq(CMD_ONIONSKIN_NEXT));
1249 ui->actionStatusBar->setShortcut(cmdKeySeq(CMD_TOGGLE_STATUS_BAR));
1252 ui->actionPlay->setShortcut(cmdKeySeq(CMD_PLAY));
1253 ui->actionLoop->setShortcut(cmdKeySeq(CMD_LOOP));
1254 ui->actionLoopControl->setShortcut(cmdKeySeq(CMD_LOOP_CONTROL));
1255 ui->actionPrevious_Frame->setShortcut(cmdKeySeq(CMD_GOTO_PREV_FRAME));
1256 ui->actionNext_Frame->setShortcut(cmdKeySeq(CMD_GOTO_NEXT_FRAME));
1257 ui->actionPrev_KeyFrame->setShortcut(cmdKeySeq(CMD_GOTO_PREV_KEY_FRAME));
1258 ui->actionNext_KeyFrame->setShortcut(cmdKeySeq(CMD_GOTO_NEXT_KEY_FRAME));
1259 ui->actionAdd_Frame->setShortcut(cmdKeySeq(CMD_ADD_FRAME));
1260 ui->actionDuplicate_Frame->setShortcut(cmdKeySeq(CMD_DUPLICATE_FRAME));
1261 ui->actionRemove_Frame->setShortcut(cmdKeySeq(CMD_REMOVE_FRAME));
1262 ui->actionAdd_Frame_Exposure->setShortcut(cmdKeySeq(CMD_SELECTION_ADD_FRAME_EXPOSURE));
1263 ui->actionSubtract_Frame_Exposure->setShortcut(cmdKeySeq(CMD_SELECTION_SUBTRACT_FRAME_EXPOSURE));
1264 ui->actionReverse_Frames_Order->setShortcut(cmdKeySeq(CMD_REVERSE_SELECTED_FRAMES));
1265 ui->actionRemove_Frames->setShortcut(cmdKeySeq(CMD_REMOVE_SELECTED_FRAMES));
1266 ui->actionMove_Frame_Backward->setShortcut(cmdKeySeq(CMD_MOVE_FRAME_BACKWARD));
1267 ui->actionMove_Frame_Forward->setShortcut(cmdKeySeq(CMD_MOVE_FRAME_FORWARD));
1268 ui->actionFlip_inbetween->setShortcut(cmdKeySeq(CMD_FLIP_INBETWEEN));
1269 ui->actionFlip_rolling->setShortcut(cmdKeySeq(CMD_FLIP_ROLLING));
1270 ui->actionReposition_Selected_Frames->setShortcut(cmdKeySeq(CMD_SELECTION_REPOSITION_FRAMES));
1273 ui->actionMove->setShortcut(cmdKeySeq(CMD_TOOL_MOVE));
1274 ui->actionSelect->setShortcut(cmdKeySeq(CMD_TOOL_SELECT));
1275 ui->actionBrush->setShortcut(cmdKeySeq(CMD_TOOL_BRUSH));
1276 ui->actionPolyline->setShortcut(cmdKeySeq(CMD_TOOL_POLYLINE));
1277 ui->actionSmudge->setShortcut(cmdKeySeq(CMD_TOOL_SMUDGE));
1278 ui->actionPen->setShortcut(cmdKeySeq(CMD_TOOL_PEN));
1279 ui->actionHand->setShortcut(cmdKeySeq(CMD_TOOL_HAND));
1280 ui->actionPencil->setShortcut(cmdKeySeq(CMD_TOOL_PENCIL));
1281 ui->actionBucket->setShortcut(cmdKeySeq(CMD_TOOL_BUCKET));
1282 ui->actionEyedropper->setShortcut(cmdKeySeq(CMD_TOOL_EYEDROPPER));
1283 ui->actionEraser->setShortcut(cmdKeySeq(CMD_TOOL_ERASER));
1284 ui->actionResetToolsDefault->setShortcut(cmdKeySeq(CMD_RESET_ALL_TOOLS));
1286 ui->actionMove->installEventFilter(shortcutFilter);
1287 ui->actionMove->installEventFilter(shortcutFilter);
1288 ui->actionSelect->installEventFilter(shortcutFilter);
1289 ui->actionBrush->installEventFilter(shortcutFilter);
1290 ui->actionPolyline->installEventFilter(shortcutFilter);
1291 ui->actionSmudge->installEventFilter(shortcutFilter);
1292 ui->actionPen->installEventFilter(shortcutFilter);
1293 ui->actionHand->installEventFilter(shortcutFilter);
1294 ui->actionPencil->installEventFilter(shortcutFilter);
1295 ui->actionBucket->installEventFilter(shortcutFilter);
1296 ui->actionEyedropper->installEventFilter(shortcutFilter);
1297 ui->actionEraser->installEventFilter(shortcutFilter);
1300 ui->actionNew_Bitmap_Layer->setShortcut(cmdKeySeq(CMD_NEW_BITMAP_LAYER));
1301 ui->actionNew_Vector_Layer->setShortcut(cmdKeySeq(CMD_NEW_VECTOR_LAYER));
1302 ui->actionNew_Camera_Layer->setShortcut(cmdKeySeq(CMD_NEW_CAMERA_LAYER));
1303 ui->actionNew_Sound_Layer->setShortcut(cmdKeySeq(CMD_NEW_SOUND_LAYER));
1304 ui->actionDelete_Current_Layer->setShortcut(cmdKeySeq(CMD_DELETE_CUR_LAYER));
1305 ui->actionChangeLineColorCurrent_keyframe->setShortcut(cmdKeySeq(CMD_CHANGE_LINE_COLOR_KEYFRAME));
1306 ui->actionChangeLineColorAll_keyframes_on_layer->setShortcut(cmdKeySeq(CMD_CHANGE_LINE_COLOR_LAYER));
1307 ui->actionChangeLayerOpacity->setShortcut(cmdKeySeq(CMD_CHANGE_LAYER_OPACITY));
1309 ui->actionVisibilityCurrentLayerOnly->setShortcut(cmdKeySeq(CMD_CURRENT_LAYER_VISIBILITY));
1310 ui->actionVisibilityRelative->setShortcut(cmdKeySeq(CMD_RELATIVE_LAYER_VISIBILITY));
1311 ui->actionVisibilityAll->setShortcut(cmdKeySeq(CMD_ALL_LAYER_VISIBILITY));
1313 mToolBox->toggleViewAction()->setShortcut(cmdKeySeq(CMD_TOGGLE_TOOLBOX));
1321 ui->actionHelp->setShortcut(cmdKeySeq(CMD_HELP));
1322 ui->actionExit->setShortcut(cmdKeySeq(CMD_EXIT));
1325void MainWindow2::clearKeyboardShortcuts()
1328 for (
QAction* action : actionList)
1334void MainWindow2::exportPalette()
1339 mEditor->object()->exportPalette(filePath);
1343void MainWindow2::importPalette()
1348 mEditor->object()->importPalette(filePath);
1349 mColorPalette->refreshColorList();
1350 mColorPalette->adjustSwatches();
1351 mEditor->color()->setColorNumber(0);
1355void MainWindow2::openPalette()
1357 for (
int i = 0; i < mEditor->object()->getColorCount(); i++)
1359 if (!mEditor->object()->isColorInUse(i))
1365 msgBox.
setText(
tr(
"Opening a palette will replace the old palette.\n"
1366 "Color(s) in strokes will be altered by this action!"));
1382 mEditor->object()->openPalette(filePath);
1383 mColorPalette->refreshColorList();
1384 mEditor->color()->setColorNumber(0);
1387void MainWindow2::makeConnections(
Editor* editor)
1389 connect(editor->undoRedo(), &UndoRedoManager::didUpdateUndoStack,
this, &MainWindow2::updateSaveState);
1390 connect(editor->undoRedo(), &UndoRedoManager::didUpdateUndoStack,
this, &MainWindow2::updateBackupActionState);
1391 connect(editor, &Editor::needDisplayInfo,
this, &MainWindow2::displayMessageBox);
1392 connect(editor, &Editor::needDisplayInfoNoTitle,
this, &MainWindow2::displayMessageBoxNoTitle);
1393 connect(editor->layers(), &LayerManager::currentLayerChanged,
this, &MainWindow2::currentLayerChanged);
1394 connect(editor->select(), &SelectionManager::selectionChanged,
this, &MainWindow2::selectionChanged);
1395 connect(editor, &Editor::canCopyChanged,
this, [=](
bool canCopy) {
1396 ui->actionCopy->setEnabled(canCopy);
1397 ui->actionCut->setEnabled(canCopy);
1402void MainWindow2::makeConnections(
Editor* editor,
ColorBox* colorBox)
1404 connect(colorBox, &ColorBox::colorChanged, editor->color(), &ColorManager::setFrontColor);
1405 connect(editor->color(), &ColorManager::colorChanged, colorBox, &ColorBox::setColor);
1410 connect(colorInspector, &ColorInspector::colorChanged, editor->color(), &ColorManager::setFrontColor);
1411 connect(editor->color(), &ColorManager::colorChanged, colorInspector, &ColorInspector::setColor);
1416 connect(editor->tools(), &ToolManager::toolChanged, scribbleArea, &ScribbleArea::updateToolCursor);
1417 connect(editor->tools(), &ToolManager::toolChanged, mToolBox, &ToolBoxWidget::onToolSetActive);
1418 connect(editor->tools(), &ToolManager::toolPropertyChanged, scribbleArea, &ScribbleArea::updateToolCursor);
1430void MainWindow2::makeConnections(
Editor* pEditor,
TimeLine* pTimeline)
1433 connect(pTimeline, &TimeLine::duplicateLayerClick, mCommands, &ActionCommands::duplicateLayer);
1434 connect(pTimeline, &TimeLine::duplicateKeyClick, mCommands, &ActionCommands::duplicateKey);
1436 connect(pTimeline, &TimeLine::soundClick, pPlaybackManager, &PlaybackManager::enableSound);
1437 connect(pTimeline, &TimeLine::fpsChanged, pPlaybackManager, &PlaybackManager::setFps);
1438 connect(pTimeline, &TimeLine::fpsChanged, pEditor, &Editor::setFps);
1441 connect(pTimeline, &TimeLine::removeKeyClick, mCommands, &ActionCommands::removeKey);
1443 connect(pTimeline, &TimeLine::newBitmapLayer, mCommands, &ActionCommands::addNewBitmapLayer);
1444 connect(pTimeline, &TimeLine::newVectorLayer, mCommands, &ActionCommands::addNewVectorLayer);
1445 connect(pTimeline, &TimeLine::newSoundLayer, mCommands, &ActionCommands::addNewSoundLayer);
1446 connect(pTimeline, &TimeLine::newCameraLayer, mCommands, &ActionCommands::addNewCameraLayer);
1447 connect(mTimeLine, &TimeLine::playButtonTriggered, mCommands, &ActionCommands::PlayStop);
1448 connect(pTimeline, &TimeLine::deleteCurrentLayerClick, mCommands, &ActionCommands::deleteCurrentLayer);
1452 connect(pTimeline, &TimeLine::selectionChanged,
this, &MainWindow2::updateCopyCutPasteEnabled);
1454 connect(mEditor->select(), &SelectionManager::selectionChanged,
this, &MainWindow2::updateCopyCutPasteEnabled);
1456 connect(pEditor->layers(), &LayerManager::currentLayerChanged, pTimeline, &TimeLine::updateUI);
1458 connect(pEditor->sound(), &SoundManager::soundClipDurationChanged, pTimeline, &TimeLine::updateUI);
1463 connect(pEditor, &Editor::objectLoaded, pTimeline, &TimeLine::onObjectLoaded);
1464 connect(pEditor, &Editor::updateTimeLine, pTimeline, &TimeLine::updateUI);
1465 connect(pEditor, &Editor::updateTimeLineCached, pTimeline, &TimeLine::updateUICached);
1467 connect(pEditor->layers(), &LayerManager::currentLayerChanged,
this, &MainWindow2::updateLayerMenu);
1468 connect(pEditor->layers(), &LayerManager::currentLayerChanged, mToolOptions, &ToolOptionWidget::updateUI);
1477 toolOptions->makeConnectionToEditor(editor);
1482 connect(pEditor, &Editor::objectLoaded, pColorPalette, &ColorPaletteWidget::updateUI);
1485 ScribbleArea* pScribbleArea = pEditor->getScribbleArea();
1487 connect(pColorPalette, &ColorPaletteWidget::colorNumberChanged, pColorManager, &ColorManager::setColorNumber);
1488 connect(pColorManager, &ColorManager::colorNumberChanged, pScribbleArea, &ScribbleArea::paletteColorChanged);
1489 connect(pColorManager, &ColorManager::colorNumberChanged, pColorPalette, &ColorPaletteWidget::selectColorNumber);
1492void MainWindow2::makeConnections(
Editor* editor,
StatusBar *statusBar)
1501void MainWindow2::updateCopyCutPasteEnabled()
1503 bool canCopy = mEditor->canCopy();
1504 bool canPaste = mEditor->canPaste();
1506 ui->actionCopy->setEnabled(canCopy);
1507 ui->actionCut->setEnabled(canCopy);
1508 ui->actionPaste->setEnabled(canPaste);
1511void MainWindow2::updateLayerMenu()
1513 ui->actionDelete_Current_Layer->setEnabled(mEditor->layers()->canDeleteLayer(mEditor->currentLayerIndex()));
1516void MainWindow2::changePlayState(
bool isPlaying)
1520 ui->actionPlay->setText(
tr(
"Stop"));
1521 ui->actionPlay->setIcon(mStopIcon);
1525 ui->actionPlay->setText(
tr(
"Play"));
1526 ui->actionPlay->setIcon(mStartIcon);
1531void MainWindow2::importMovieVideo()
1534 mSuppressAutoSaveDialog =
true;
1536 mCommands->importMovieVideo();
1538 mSuppressAutoSaveDialog =
false;
1541bool MainWindow2::event(
QEvent* event)
1549void MainWindow2::displayMessageBox(
const QString& title,
const QString& body)
1554void MainWindow2::displayMessageBoxNoTitle(
const QString& body)
1559bool MainWindow2::tryRecoverUnsavedProject()
1562 QStringList recoverables = fm.searchForUnsavedProjects();
1564 if (recoverables.
empty())
1569 QString caption =
tr(
"Restore Project?");
1570 QString text =
tr(
"Pencil2D didn't close correctly. Would you like to restore the project?");
1572 QString recoverPath = recoverables[0];
1583 hideQuestionMark(*msgBox);
1590void MainWindow2::startProjectRecovery(
int result)
1605 Object* o = fm.recoverUnsavedProject(recoverPath);
1606 if (!fm.error().ok())
1608 Q_ASSERT(o ==
nullptr);
1609 const QString title =
tr(
"Recovery Failed.");
1610 const QString text =
tr(
"Sorry! Pencil2D is unable to restore your project");
1616 mEditor->setObject(o);
1618 updateBackupActionState();
1620 const QString title =
tr(
"Recovery Succeeded!");
1621 const QString text =
tr(
"Please save your work immediately to prevent loss of data");
1625void MainWindow2::createToolbars()
1630 mMainToolbar->
addAction(ui->actionOpen);
1631 mMainToolbar->
addAction(ui->actionSave);
1633 mMainToolbar->
addAction(ui->actionUndo);
1634 mMainToolbar->
addAction(ui->actionRedo);
1637 mMainToolbar->
addAction(ui->actionCopy);
1638 mMainToolbar->
addAction(ui->actionPaste);
1639 mMainToolbar->
addAction(ui->actionClearFrame);
1643 mViewToolbar->
addAction(ui->actionZoom_In);
1644 mViewToolbar->
addAction(ui->actionZoom_Out);
1645 mViewToolbar->
addAction(ui->actionReset_View);
1647 mViewToolbar->
addAction(ui->actionHorizontal_Flip);
1648 mViewToolbar->
addAction(ui->actionVertical_Flip);
1650 mViewToolbar->
addAction(ui->actionShowInvisibleLines);
1651 mViewToolbar->
addAction(ui->actionShowOutlinesOnly);
1655 mOverlayToolbar->
addAction(ui->actionGrid);
1656 mOverlayToolbar->
addAction(ui->actionCenter);
1657 mOverlayToolbar->
addAction(ui->actionThirds);
1658 mOverlayToolbar->
addAction(ui->actionGoldenRatio);
1659 mOverlayToolbar->
addAction(ui->actionSafeAreas);
1660 mOverlayToolbar->
addAction(ui->actionOnePointPerspective);
1661 mOverlayToolbar->
addAction(ui->actionTwoPointPerspective);
1662 mOverlayToolbar->
addAction(ui->actionThreePointPerspective);
1668 perspectiveLinesAngleButton->
setDefaultAction(ui->menuPerspectiveLinesAngle->menuAction());
1670 mOverlayToolbar->
addWidget(perspectiveLinesAngleButton);
1672 mToolbars = { mMainToolbar, mViewToolbar, mOverlayToolbar };
1676 ui->menuToolbars->addAction(tb->toggleViewAction());
Status insertKeyFrameAtCurrentPosition()
Will insert a keyframe at the current position and push connected frames to the right.
void framesModified()
This should be emitted after modifying multiple frames.
void frameModified(int frameNumber)
This should be emitted after modifying the frame content.
void scrubbed(int frameNumber)
This should be emitted after scrubbing.
static QString getSaveFileName(QWidget *parent, FileType fileType, const QString &caption=QString())
Shows a file dialog which allows the user to select a file save path.
static QString getOpenFileName(QWidget *parent, FileType fileType, const QString &caption=QString())
Shows a file dialog which allows the user to select a file to open.
void notifyAnimationLengthChanged()
This should be emitted whenever the animation length frames, eg.
void windowActivated()
Emitted when window regains focus.
void onScrubbed(int frameNumber)
Frame scrubbed, invalidate relevant cache.
void onViewChanged()
View updated, invalidate relevant cache.
void onObjectLoaded()
Object updated, invalidate all cache.
void onFramesModified()
Multiple frames modified, invalidate cache for affected frames.
void onPlayStateChanged()
Playstate changed, invalidate relevant cache.
void onLayerChanged()
Layer changed, invalidate relevant cache.
void onFrameModified(int frameNumber)
Frame modified, invalidate cache for frame if any.
The status bar of Pencil2D's main window.
void updateToolStatus(ToolType tool)
Updates the status bar with information about the current tool.
void zoomChanged(double scale)
This signal is sent when the user chooses a new zoom level through the status bar.
void updateZoomStatus()
Updates the zoom level displayed in the status bar.
void extendLength(int frame)
Extends the timeline frame length if necessary.
bool hasUnsavedChanges() const
Checks whether there are unsaved changes.
void setShortcut(const QKeySequence &shortcut)
void toggled(bool checked)
void triggered(bool checked)
void triggered(QAction *action)
void processEvents(QEventLoop::ProcessEventsFlags flags)
QDateTime currentDateTime()
void setTimeSpec(Qt::TimeSpec spec)
QString toString(Qt::DateFormat format) const const
void finished(int result)
QEvent::Type type() const const
bool exists() const const
int count(const T &value) const const
void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget)
void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
void setDockNestingEnabled(bool enabled)
virtual bool event(QEvent *event) override
bool restoreState(const QByteArray &state, int version)
QByteArray saveState(int version) const const
QStatusBar * statusBar() const const
virtual int exec() override
void setIconPixmap(const QPixmap &pixmap)
void setInformativeText(const QString &text)
void open(QObject *receiver, const char *member)
void setWindowModality(Qt::WindowModality windowModality)
void setWindowTitle(const QString &title)
void setText(const QString &text)
QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setObjectName(const QString &name)
QVariant property(const char *name) const const
QObject * sender() const const
bool setProperty(const char *name, const QVariant &value)
QString tr(const char *sourceText, const char *disambiguation, int n)
QString writableLocation(QStandardPaths::StandardLocation type)
bool isEmpty() const const
QString & prepend(QChar ch)
void keySequence(QWindow *window, const QKeySequence &keySequence)
char * toString(const T &value)
QByteArray toByteArray() const const
QString toString() const const