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 "addtransparencytopaperdialog.h"
71#include "repositionframesdialog.h"
73#include "errordialog.h"
74#include "filedialog.h"
75#include "importimageseqdialog.h"
76#include "importlayersdialog.h"
77#include "importpositiondialog.h"
78#include "layeropacitydialog.h"
79#include "recentfilemenu.h"
80#include "shortcutfilter.h"
82#include "presetdialog.h"
83#include "pegbaralignmentdialog.h"
87#define BUILD_DATE S__GIT_TIMESTAMP
89#define BUILD_DATE __DATE__
92#if defined(PENCIL2D_RELEASE_BUILD)
93#define PENCIL_WINDOW_TITLE QString("[*]Pencil2D v%1").arg(APP_VERSION)
94#elif defined(PENCIL2D_NIGHTLY_BUILD)
95#define PENCIL_WINDOW_TITLE QString("[*]Pencil2D Nightly Build %1").arg(BUILD_DATE)
97#define PENCIL_WINDOW_TITLE QString("[*]Pencil2D Development Build %1").arg(BUILD_DATE)
102MainWindow2::MainWindow2(
QWidget* parent) :
110 mEditor =
new Editor(
this);
111 mEditor->setScribbleArea(ui->scribbleArea);
116 ui->scribbleArea->setEditor(mEditor);
117 ui->scribbleArea->init();
119 ui->statusBar->setEditor(mEditor);
120 ui->statusBar->updateZoomStatus();
121 ui->statusBar->setVisible(mEditor->preference()->isOn(SETTING::SHOW_STATUS_BAR));
124 mCommands->setCore(mEditor);
129 setupKeyboardShortcuts();
134 currentLayerChanged();
136 connect(mEditor, &Editor::needSave,
this, &MainWindow2::autoSave);
138 mEditor->tools()->setDefaultTool();
139 ui->background->init(mEditor->preference());
141 setWindowTitle(PENCIL_WINDOW_TITLE);
144MainWindow2::~MainWindow2()
149void MainWindow2::createDockWidgets()
155 mColorBox->
setToolTip(
tr(
"color palette:<br>use <b>(C)</b><br>toggle at cursor"));
163 mColorPalette->setCore(mEditor);
184 mStartIcon =
QIcon(
":icons/controls/play.png");
185 mStopIcon =
QIcon(
":icons/controls/stop.png");
190 pWidget->setFeatures(QDockWidget::DockWidgetFeature::DockWidgetClosable |
191 QDockWidget::DockWidgetFeature::DockWidgetMovable |
192 QDockWidget::DockWidgetFeature::DockWidgetFloatable);
195 pWidget->setEditor(mEditor);
197 qDebug() <<
"Init Dock widget: " << pWidget->objectName();
217 makeConnections(mEditor, ui->scribbleArea);
218 makeConnections(mEditor);
219 makeConnections(mEditor, mTimeLine);
220 makeConnections(mEditor, mColorBox);
221 makeConnections(mEditor, mColorInspector);
222 makeConnections(mEditor, mColorPalette);
223 makeConnections(mEditor, mToolOptions);
224 makeConnections(mEditor, ui->statusBar);
228 w->setFloating(
false);
234void MainWindow2::createMenus()
267 replaceUndoRedoActions();
273 connect(mEditor->select(), &SelectionManager::selectionChanged,
this, &MainWindow2::selectionChanged);
289 connect(ui->actionChangeLineColorCurrent_keyframe, &
QAction::triggered, mCommands, &ActionCommands::changeKeyframeLineColor);
290 connect(ui->actionChangeLineColorAll_keyframes_on_layer, &
QAction::triggered, mCommands, &ActionCommands::changeallKeyframeLineColor);
293 QList<QAction*> visibilityActions = ui->menuLayer_Visibility->actions();
295 visibilityGroup->setExclusive(
true);
296 for (
int i = 0; i < visibilityActions.
size(); i++) {
297 QAction* action = visibilityActions[i];
298 visibilityGroup->addAction(action);
301 visibilityActions[mEditor->preference()->getInt(SETTING::LAYER_VISIBILITY)]->setChecked(
true);
302 connect(mEditor->preference(), &PreferenceManager::optionChanged, [=](SETTING e) {
303 if (e == SETTING::LAYER_VISIBILITY) {
304 visibilityActions[mEditor->preference()->getInt(SETTING::LAYER_VISIBILITY)]->setChecked(true);
310 connect(ui->actionZoom_Out, &
QAction::triggered, mCommands, &ActionCommands::ZoomOut);
311 connect(ui->actionRotate_Clockwise, &
QAction::triggered, mCommands, &ActionCommands::rotateClockwise);
312 connect(ui->actionRotate_Anticlockwise, &
QAction::triggered, mCommands, &ActionCommands::rotateCounterClockwise);
313 connect(ui->actionReset_Rotation, &
QAction::triggered, mEditor->view(), &ViewManager::resetRotation);
314 connect(ui->actionReset_View, &
QAction::triggered, mEditor->view(), &ViewManager::resetView);
315 connect(ui->actionCenter_View, &
QAction::triggered, mEditor->view(), &ViewManager::centerView);
316 connect(ui->actionZoom400, &
QAction::triggered, mEditor->view(), &ViewManager::scale400);
317 connect(ui->actionZoom300, &
QAction::triggered, mEditor->view(), &ViewManager::scale300);
318 connect(ui->actionZoom200, &
QAction::triggered, mEditor->view(), &ViewManager::scale200);
319 connect(ui->actionZoom100, &
QAction::triggered, mEditor->view(), &ViewManager::scale100);
320 connect(ui->actionZoom50, &
QAction::triggered, mEditor->view(), &ViewManager::scale50);
321 connect(ui->actionZoom33, &
QAction::triggered, mEditor->view(), &ViewManager::scale33);
322 connect(ui->actionZoom25, &
QAction::triggered, mEditor->view(), &ViewManager::scale25);
323 connect(ui->actionHorizontal_Flip, &
QAction::triggered, mEditor->view(), &ViewManager::flipHorizontal);
324 connect(ui->actionVertical_Flip, &
QAction::triggered, mEditor->view(), &ViewManager::flipVertical);
325 connect(mEditor->view(), &ViewManager::viewFlipped,
this, &MainWindow2::viewFlipped);
329 bindPreferenceSetting(ui->actionStatusBar, prefs, SETTING::SHOW_STATUS_BAR);
330 bindPreferenceSetting(ui->actionThreePointPerspective, prefs, SETTING::OVERLAY_PERSPECTIVE3);
331 bindPreferenceSetting(ui->actionTwoPointPerspective, prefs, SETTING::OVERLAY_PERSPECTIVE2);
332 bindPreferenceSetting(ui->actionOnePointPerspective, prefs, SETTING::OVERLAY_PERSPECTIVE1);
333 bindPreferenceSetting(ui->actionSafeAreas, prefs, SETTING::OVERLAY_SAFE);
334 bindPreferenceSetting(ui->actionGoldenRatio, prefs, SETTING::OVERLAY_GOLDEN);
335 bindPreferenceSetting(ui->actionThirds, prefs, SETTING::OVERLAY_THIRDS);
336 bindPreferenceSetting(ui->actionCenter, prefs, SETTING::OVERLAY_CENTER);
337 bindPreferenceSetting(ui->actionGrid, prefs, SETTING::GRID);
338 bindPreferenceSetting(ui->actionShowOutlinesOnly, prefs, SETTING::OUTLINES);
339 bindPreferenceSetting(ui->actionShowInvisibleLines, prefs, SETTING::INVISIBLE_LINES);
340 bindPreferenceSetting(ui->actionOnionPrev, prefs, SETTING::PREV_ONION);
341 bindPreferenceSetting(ui->actionOnionNext, prefs, SETTING::NEXT_ONION);
343 bool enableSafeArea = (prefs->isOn(SETTING::ACTION_SAFE_ON) || prefs->isOn(SETTING::TITLE_SAFE_ON));
344 ui->actionSafeAreas->setEnabled(enableSafeArea);
346 auto perspectiveLinesAngleGroup =
new QActionGroup(
this);
347 perspectiveLinesAngleGroup->setExclusive(
true);
348 perspectiveLinesAngleGroup->addAction(ui->action2Degrees);
349 perspectiveLinesAngleGroup->addAction(ui->action3Degrees);
350 perspectiveLinesAngleGroup->addAction(ui->action5Degrees);
351 perspectiveLinesAngleGroup->addAction(ui->action7_5Degrees);
352 perspectiveLinesAngleGroup->addAction(ui->action10Degrees);
353 perspectiveLinesAngleGroup->addAction(ui->action15Degrees);
354 perspectiveLinesAngleGroup->addAction(ui->action20Degrees);
355 perspectiveLinesAngleGroup->addAction(ui->action30Degrees);
357 if (action == ui->action2Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 2);
358 else if (action == ui->action3Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 3);
359 else if (action == ui->action5Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 5);
360 else if (action == ui->action7_5Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 7);
361 else if (action == ui->action10Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 10);
362 else if (action == ui->action15Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 15);
363 else if (action == ui->action20Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 20);
364 else if (action == ui->action30Degrees) mEditor->preference()->set(SETTING::OVERLAY_ANGLE, 30);
365 else Q_UNREACHABLE();
366 emit mEditor->view()->viewChanged();
369 switch (prefs->getInt(SETTING::OVERLAY_ANGLE)) {
370 case 2: ui->action2Degrees->setChecked(
true);
break;
371 case 3: ui->action3Degrees->setChecked(
true);
break;
372 case 5: ui->action5Degrees->setChecked(
true);
break;
373 case 7: ui->action7_5Degrees->setChecked(
true);
break;
374 case 10: ui->action10Degrees->setChecked(
true);
break;
375 case 15: ui->action15Degrees->setChecked(
true);
break;
376 case 20: ui->action20Degrees->setChecked(
true);
break;
377 case 30: ui->action30Degrees->setChecked(
true);
break;
384 connect(ui->actionLoop, &
QAction::triggered, pPlaybackManager, &PlaybackManager::setLooping);
385 connect(ui->actionLoopControl, &
QAction::triggered, pPlaybackManager, &PlaybackManager::enableRangedPlayback);
386 connect(pPlaybackManager, &PlaybackManager::loopStateChanged, ui->actionLoop, &
QAction::setChecked);
387 connect(pPlaybackManager, &PlaybackManager::loopStateChanged, mTimeLine, &TimeLine::setLoop);
388 connect(pPlaybackManager, &PlaybackManager::rangedPlaybackStateChanged, ui->actionLoopControl, &
QAction::setChecked);
389 connect(pPlaybackManager, &PlaybackManager::rangedPlaybackStateChanged, mTimeLine, &TimeLine::setRangeState);
390 connect(pPlaybackManager, &PlaybackManager::playStateChanged, mTimeLine, &TimeLine::setPlaying);
391 connect(pPlaybackManager, &PlaybackManager::playStateChanged,
this, &MainWindow2::changePlayState);
393 connect(ui->actionFlip_inbetween, &
QAction::triggered, pPlaybackManager, &PlaybackManager::playFlipInBetween);
394 connect(ui->actionFlip_rolling, &
QAction::triggered, pPlaybackManager, &PlaybackManager::playFlipRoll);
397 connect(ui->actionRemove_Frame, &
QAction::triggered, mCommands, &ActionCommands::removeKey);
398 connect(ui->actionAdd_Frame_Exposure, &
QAction::triggered, mCommands, &ActionCommands::addExposureToSelectedFrames);
399 connect(ui->actionSubtract_Frame_Exposure, &
QAction::triggered, mCommands, &ActionCommands::subtractExposureFromSelectedFrames);
400 connect(ui->actionNext_Frame, &
QAction::triggered, mCommands, &ActionCommands::GotoNextFrame);
401 connect(ui->actionPrevious_Frame, &
QAction::triggered, mCommands, &ActionCommands::GotoPrevFrame);
402 connect(ui->actionNext_KeyFrame, &
QAction::triggered, mCommands, &ActionCommands::GotoNextKeyFrame);
403 connect(ui->actionPrev_KeyFrame, &
QAction::triggered, mCommands, &ActionCommands::GotoPrevKeyFrame);
404 connect(ui->actionDuplicate_Frame, &
QAction::triggered, mCommands, &ActionCommands::duplicateKey);
405 connect(ui->actionMove_Frame_Forward, &
QAction::triggered, mCommands, &ActionCommands::moveFrameForward);
406 connect(ui->actionMove_Frame_Backward, &
QAction::triggered, mCommands, &ActionCommands::moveFrameBackward);
408 connect(ui->actionReverse_Frames_Order, &
QAction::triggered, mCommands, &ActionCommands::reverseSelectedFrames);
409 connect(ui->actionRemove_Frames, &
QAction::triggered, mCommands, &ActionCommands::removeSelectedFrames);
415 connect(ui->actionPolyline, &
QAction::triggered, mToolBox, &ToolBoxWidget::polylineOn);
421 connect(ui->actionEyedropper, &
QAction::triggered, mToolBox, &ToolBoxWidget::eyedropperOn);
423 connect(ui->actionResetToolsDefault, &
QAction::triggered, mEditor->tools(), &ToolManager::resetAllTools);
426 QMenu* winMenu = ui->menuWindows;
427 const std::vector<QAction*> actions
429 mToolBox->toggleViewAction(),
430 mToolOptions->toggleViewAction(),
431 mColorBox->toggleViewAction(),
432 mColorPalette->toggleViewAction(),
433 mTimeLine->toggleViewAction(),
434 mColorInspector->toggleViewAction(),
435 mOnionSkinWidget->toggleViewAction()
438 for (
QAction* action : actions)
441 winMenu->
insertAction(ui->menuToolbars->menuAction(), action);
444 connect(ui->actionResetWindows, &
QAction::triggered,
this, &MainWindow2::resetAndDockAllSubWidgets);
445 connect(ui->actionLockWindows, &
QAction::toggled,
this, &MainWindow2::lockWidgets);
446 bindPreferenceSetting(ui->actionLockWindows, prefs, SETTING::LAYOUT_LOCK);
450 connect(ui->actionQuick_Guide, &
QAction::triggered, mCommands, &ActionCommands::quickGuide);
454 connect(ui->actionCheck_for_Updates, &
QAction::triggered, mCommands, &ActionCommands::checkForUpdates);
455 connect(ui->actionReport_Bug, &
QAction::triggered, mCommands, &ActionCommands::reportbug);
456 connect(ui->actionOpen_Temporary_Directory, &
QAction::triggered, mCommands, &ActionCommands::openTemporaryDirectory);
461 mRecentFileMenu->loadFromDisk();
462 ui->menuFile->insertMenu(ui->actionSave, mRecentFileMenu);
464 connect(mRecentFileMenu, &RecentFileMenu::loadRecentFile,
this, &MainWindow2::openFile);
467void MainWindow2::replaceUndoRedoActions()
469 ui->menuEdit->removeAction(ui->actionUndo);
470 ui->menuEdit->removeAction(ui->actionRedo);
471 ui->actionUndo = mEditor->undoRedo()->createUndoAction(
this, ui->actionUndo->icon());
472 ui->actionRedo = mEditor->undoRedo()->createRedoAction(
this, ui->actionRedo->icon());
473 ui->menuEdit->insertAction(ui->actionCut, ui->actionUndo);
474 ui->menuEdit->insertAction(ui->actionCut, ui->actionRedo);
477void MainWindow2::setOpacity(
int opacity)
479 mEditor->preference()->set(SETTING::WINDOW_OPACITY, 100 - opacity);
483void MainWindow2::updateSaveState()
487 ui->statusBar->updateModifiedStatus(hasUnsavedChanges);
490void MainWindow2::updateBackupActionState()
492 mEditor->undoRedo()->updateUndoAction(ui->actionUndo);
493 mEditor->undoRedo()->updateRedoAction(ui->actionRedo);
496void MainWindow2::openPegAlignDialog()
498 if (mPegAlign !=
nullptr)
501 tr(
"Dialog is already open!"),
511 flags &= (
~Qt::WindowContextHelpButtonHint);
520void MainWindow2::openLayerOpacityDialog()
522 if (mLayerOpacityDialog !=
nullptr)
525 tr(
"Dialog is already open!"),
531 mLayerOpacityDialog->setCore(mEditor);
532 mLayerOpacityDialog->initUI();
534 mLayerOpacityDialog->
show();
538 mLayerOpacityDialog =
nullptr;
542void MainWindow2::openAddTranspToPaperDialog()
544 if (mAddTranspToPaper)
547 mAddTranspToPaper->
raise();
552 mAddTranspToPaper->setCore(mEditor);
553 mAddTranspToPaper->initUI();
555 mAddTranspToPaper->
show();
561 mSuppressAutoSaveDialog =
true;
562 mAddTranspToPaper->traceScannedDrawings();
563 mSuppressAutoSaveDialog =
false;
566 mAddTranspToPaper =
nullptr;
570void MainWindow2::openRepositionDialog()
572 if (mEditor->layers()->currentLayer()->getSelectedFramesByPos().
count() < 2)
575 tr(
"Please select at least 2 frames!"),
579 if (mReposDialog !=
nullptr)
587 hideQuestionMark(*mReposDialog);
588 mReposDialog->setCore(mEditor);
589 mReposDialog->initUI();
590 mEditor->tools()->setCurrentTool(ToolType::MOVE);
592 mReposDialog->
show();
595void MainWindow2::closeRepositionDialog()
598 mReposDialog =
nullptr;
601void MainWindow2::currentLayerChanged()
603 bool isBitmap = (mEditor->layers()->currentLayer()->type() == Layer::BITMAP);
604 ui->menuChange_line_color->setEnabled(isBitmap);
606 bool isVector = (mEditor->layers()->currentLayer()->type() == Layer::VECTOR);
607 ui->actionShowInvisibleLines->setEnabled(isVector);
608 ui->actionShowOutlinesOnly->setEnabled(isVector);
611void MainWindow2::selectionChanged()
613 bool somethingSelected = mEditor->select()->somethingSelected();
614 ui->menuSelection->setEnabled(somethingSelected);
617void MainWindow2::viewFlipped()
619 ui->actionHorizontal_Flip->setChecked(mEditor->view()->isFlipHorizontal());
620 ui->actionVertical_Flip->setChecked(mEditor->view()->isFlipVertical());
639 m2ndCloseEvent =
true;
647void MainWindow2::newDocument()
649 if (maybeSave() && !tryLoadPreset())
655void MainWindow2::openDocument()
664 openObject(fileName);
668bool MainWindow2::saveAsNewDocument()
675 return saveObject(fileName);
678void MainWindow2::openStartupFile(
const QString& filename)
680 if (tryRecoverUnsavedProject())
685 if (!filename.
isEmpty() && openObject(filename))
690 loadMostRecent() || tryLoadPreset();
693void MainWindow2::openFile(
const QString& filename)
697 openObject(filename);
701bool MainWindow2::openObject(
const QString& strFilePath)
704 hideQuestionMark(progress);
708 Status s = mEditor->openObject(strFilePath, [&progress](
int p)
710 progress.setValue(p);
712 }, [&progress](
int max)
714 progress.setRange(0, max);
719 ErrorDialog errorDialog(s.title(), s.description(), s.details().str());
721 emptyDocumentWhenErrorOccurred();
726 settings.setValue(LAST_PCLX_PATH, mEditor->object()->filePath());
729 if (!mEditor->object()->filePath().
isEmpty())
731 mRecentFileMenu->addRecentFile(mEditor->object()->filePath());
732 mRecentFileMenu->saveToDisk();
739 ui->statusBar->updateModifiedStatus(
false);
741 progress.setValue(progress.maximum());
744 updateBackupActionState();
746 if (!
QFileInfo(strFilePath).isWritable())
749 tr(
"This program does not currently have permission to write to the file you have selected. "
750 "Please make sure you have write permission for this file before attempting to save it. "
751 "Alternatively, you can use the Save As... menu option to save to a writable location."),
758bool MainWindow2::saveObject(
QString strSavedFileName)
761 hideQuestionMark(progress);
765 mEditor->prepareSave();
769 connect(&fm, &FileManager::progressChanged, [&progress](
int p)
771 progress.setValue(p);
774 connect(&fm, &FileManager::progressRangeChanged, [&progress](
int max)
776 progress.setRange(0, max + 3);
779 Status st = fm.save(mEditor->object(), strSavedFileName);
784#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
789 errorLogFolder.mkpath(
"./logs");
790 errorLogFolder.cd(
"logs");
798 out << st.details().str();
803 st.description().append(
tr(
"<br><br>An error has occurred and your file may not have saved successfully."
804 "\nIf you believe that this error is an issue with Pencil2D, please create a new issue at:"
805 "<br><a href='https://github.com/pencil2d/pencil/issues'>https://github.com/pencil2d/pencil/issues</a><br>"
806 "Please be sure to include the following details in your issue:")), st.details().html());
811 mEditor->object()->setFilePath(strSavedFileName);
812 mEditor->object()->setModified(
false);
814 mEditor->clearTemporary();
817 settings.setValue(LAST_PCLX_PATH, strSavedFileName);
819 mRecentFileMenu->addRecentFile(strSavedFileName);
820 mRecentFileMenu->saveToDisk();
822 mTimeLine->updateContent();
827 progress.setValue(progress.maximum());
829 mEditor->resetAutoSaveCounter();
834bool MainWindow2::saveDocument()
836 if (!mEditor->object()->filePath().
isEmpty())
837 return saveObject(mEditor->object()->filePath());
839 return saveAsNewDocument();
842bool MainWindow2::maybeSave()
850 tr(
"This animation has been modified.\n Do you want to save your changes?"),
853 return saveDocument();
858bool MainWindow2::autoSave()
860 if (!mEditor->object()->filePath().
isEmpty())
862 return saveDocument();
865 if (mEditor->autoSaveNeverAskAgain())
868 if(mSuppressAutoSaveDialog)
873 msgBox.setWindowTitle(
tr(
"AutoSave Reminder"));
874 msgBox.setText(
tr(
"The animation is not saved yet.\n Do you want to save now?"));
879 int ret = msgBox.exec();
882 return saveDocument();
886 mEditor->dontAskAutoSave(
true);
892void MainWindow2::emptyDocumentWhenErrorOccurred()
900void MainWindow2::importImage()
904 if (strFilePath.
isEmpty()) {
return; }
908 OnScopeExit(
delete positionDialog)
910 positionDialog->
exec();
917 Status st = mEditor->importImage(strFilePath);
920 ErrorDialog errorDialog(st.title(), st.description(), st.details().html());
925 ui->scribbleArea->updateFrame();
926 mTimeLine->updateContent();
929void MainWindow2::importImageSequence()
931 mSuppressAutoSaveDialog =
true;
934 OnScopeExit(
delete imageSeqDialog)
935 imageSeqDialog->setCore(mEditor);
939 imageSeqDialog->
exec();
946 OnScopeExit(
delete positionDialog)
948 positionDialog->
exec();
954 imageSeqDialog->importArbitrarySequence();
956 mSuppressAutoSaveDialog =
false;
959void MainWindow2::importPredefinedImageSet()
962 OnScopeExit(
delete imageSeqDialog)
963 imageSeqDialog->setCore(mEditor);
967 mSuppressAutoSaveDialog =
true;
968 imageSeqDialog->
exec();
975 OnScopeExit(
delete positionDialog)
977 positionDialog->
exec();
983 imageSeqDialog->importPredefinedSet();
984 mSuppressAutoSaveDialog =
false;
987void MainWindow2::importLayers()
990 importLayers->setCore(mEditor);
992 importLayers->
open();
995void MainWindow2::importAnimatedImage()
998 mSuppressAutoSaveDialog =
true;
1000 mCommands->importAnimatedImage();
1002 mSuppressAutoSaveDialog =
false;
1005void MainWindow2::lockWidgets(
bool shouldLock)
1009 : (QDockWidget::DockWidgetFeature::DockWidgetClosable |
1010 QDockWidget::DockWidgetFeature::DockWidgetMovable |
1011 QDockWidget::DockWidgetFeature::DockWidgetFloatable);
1015 d->setFeatures(feat);
1020 QWidget* customTitleBarWidget = shouldLock ? (
new QWidget) :
nullptr;
1021 d->setTitleBarWidget(customTitleBarWidget);
1025void MainWindow2::preferences()
1030 mPrefDialog->
raise();
1036 mPrefDialog->init(mEditor->preference());
1038 connect(mPrefDialog, &PreferencesDialog::windowOpacityChange,
this, &MainWindow2::setOpacity);
1039 connect(mPrefDialog, &PreferencesDialog::soundScrubChanged, mEditor->playback(), &PlaybackManager::setSoundScrubActive);
1040 connect(mPrefDialog, &PreferencesDialog::soundScrubMsecChanged, mEditor->playback(), &PlaybackManager::setSoundScrubMsec);
1043 clearKeyboardShortcuts();
1044 setupKeyboardShortcuts();
1045 mPrefDialog =
nullptr;
1048 mPrefDialog->
show();
1051void MainWindow2::resetAndDockAllSubWidgets()
1054 settings.remove(SETTING_WINDOW_GEOMETRY);
1055 settings.remove(SETTING_WINDOW_STATE);
1059 dock->setFloating(
false);
1073void MainWindow2::newObject()
1075 auto object =
new Object();
1079 object->addNewCameraLayer();
1080 object->addNewBitmapLayer();
1084 object->data()->setCurrentLayer(1);
1086 mEditor->setObject(
object);
1092 updateBackupActionState();
1095bool MainWindow2::newObjectFromPresets(
int presetIndex)
1097 QString presetFilePath = PresetDialog::getPresetPath(presetIndex);
1105 Object*
object = fm.load(presetFilePath);
1107 if (!fm.error().ok() ||
object ==
nullptr)
1112 mEditor->setObject(
object);
1113 object->setFilePath(
QString());
1117 updateBackupActionState();
1122bool MainWindow2::loadMostRecent()
1124 if(!mEditor->preference()->isOn(SETTING::LOAD_MOST_RECENT))
1130 QString myPath = settings.value(LAST_PCLX_PATH,
QVariant(
"")).toString();
1135 return openObject(myPath);
1138bool MainWindow2::tryLoadPreset()
1140 if (!mEditor->preference()->isOn(SETTING::ASK_FOR_PRESET))
1142 int defaultPreset = mEditor->preference()->getInt(SETTING::DEFAULT_PRESET);
1143 return newObjectFromPresets(defaultPreset);
1155 int presetIndex = presetDialog->getPresetIndex();
1156 if (presetDialog->shouldAlwaysUse())
1158 mEditor->preference()->set(SETTING::ASK_FOR_PRESET, false);
1159 mEditor->preference()->set(SETTING::DEFAULT_PRESET, presetIndex);
1161 if (!newObjectFromPresets(presetIndex))
1166 presetDialog->
open();
1170void MainWindow2::closeDialogs()
1177void MainWindow2::readSettings()
1181 QVariant winGeometry = settings.
value(SETTING_WINDOW_GEOMETRY);
1187 int opacity = mEditor->preference()->getInt(SETTING::WINDOW_OPACITY);
1188 setOpacity(100 - opacity);
1190 bool isWindowsLocked = mEditor->preference()->isOn(SETTING::LAYOUT_LOCK);
1191 lockWidgets(isWindowsLocked);
1194void MainWindow2::writeSettings()
1197 settings.setValue(SETTING_WINDOW_GEOMETRY,
saveGeometry());
1198 settings.setValue(SETTING_WINDOW_STATE,
saveState());
1201void MainWindow2::setupKeyboardShortcuts()
1203 checkExistingShortcuts();
1207 strCommandName =
QString(
"shortcuts/") + strCommandName;
1213 ui->actionNew->setShortcut(cmdKeySeq(CMD_NEW_FILE));
1214 ui->actionOpen->setShortcut(cmdKeySeq(CMD_OPEN_FILE));
1215 ui->actionSave->setShortcut(cmdKeySeq(CMD_SAVE_FILE));
1216 ui->actionSave_as->setShortcut(cmdKeySeq(CMD_SAVE_AS));
1218 ui->actionImport_Image->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE));
1219 ui->actionImport_ImageSeq->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE_SEQ));
1220 ui->actionImport_ImageSeqNum->setShortcut(cmdKeySeq(CMD_IMPORT_IMAGE_PREDEFINED_SET));
1221 ui->actionImport_MovieVideo->setShortcut(cmdKeySeq(CMD_IMPORT_MOVIE_VIDEO));
1222 ui->actionImport_AnimatedImage->setShortcut(cmdKeySeq(CMD_IMPORT_ANIMATED_IMAGE));
1223 ui->actionImportLayers_from_pclx->setShortcut(cmdKeySeq(CMD_IMPORT_LAYERS));
1224 ui->actionImport_Sound->setShortcut(cmdKeySeq(CMD_IMPORT_SOUND));
1225 ui->actionImport_MovieAudio->setShortcut(cmdKeySeq(CMD_IMPORT_MOVIE_AUDIO));
1226 ui->actionImport_Append_Palette->setShortcut(cmdKeySeq(CMD_IMPORT_PALETTE));
1227 ui->actionImport_Replace_Palette->setShortcut(cmdKeySeq(CMD_IMPORT_PALETTE_REPLACE));
1229 ui->actionExport_Image->setShortcut(cmdKeySeq(CMD_EXPORT_IMAGE));
1230 ui->actionExport_ImageSeq->setShortcut(cmdKeySeq(CMD_EXPORT_IMAGE_SEQ));
1231 ui->actionExport_Movie->setShortcut(cmdKeySeq(CMD_EXPORT_MOVIE));
1232 ui->actionExport_Animated_GIF->setShortcut(cmdKeySeq(CMD_EXPORT_GIF));
1233 ui->actionExport_Palette->setShortcut(cmdKeySeq(CMD_EXPORT_PALETTE));
1236 ui->actionUndo->setShortcut(cmdKeySeq(CMD_UNDO));
1237 ui->actionRedo->setShortcut(cmdKeySeq(CMD_REDO));
1238 ui->actionCut->setShortcut(cmdKeySeq(CMD_CUT));
1239 ui->actionCopy->setShortcut(cmdKeySeq(CMD_COPY));
1240 ui->actionPaste_Previous->setShortcut(cmdKeySeq(CMD_PASTE_FROM_PREVIOUS));
1241 ui->actionPaste->setShortcut(cmdKeySeq(CMD_PASTE));
1242 ui->actionClearFrame->setShortcut(cmdKeySeq(CMD_CLEAR_FRAME));
1243 ui->actionFlip_X->setShortcut(cmdKeySeq(CMD_SELECTION_FLIP_HORIZONTAL));
1244 ui->actionFlip_Y->setShortcut(cmdKeySeq(CMD_SELECTION_FLIP_VERTICAL));
1245 ui->actionSelect_All->setShortcut(cmdKeySeq(CMD_SELECT_ALL));
1246 ui->actionDeselect_All->setShortcut(cmdKeySeq(CMD_DESELECT_ALL));
1247 ui->actionPegbarAlignment->setShortcut(cmdKeySeq(CMD_PEGBAR_ALIGNMENT));
1248 ui->actionPreference->setShortcut(cmdKeySeq(CMD_PREFERENCE));
1251 ui->actionResetWindows->setShortcut(cmdKeySeq(CMD_RESET_WINDOWS));
1252 ui->actionLockWindows->setShortcut(cmdKeySeq(CMD_LOCK_WINDOWS));
1253 ui->actionReset_View->setShortcut(cmdKeySeq(CMD_RESET_ZOOM_ROTATE));
1254 ui->actionCenter_View->setShortcut(cmdKeySeq(CMD_CENTER_VIEW));
1255 ui->actionZoom_In->setShortcut(cmdKeySeq(CMD_ZOOM_IN));
1256 ui->actionZoom_Out->setShortcut(cmdKeySeq(CMD_ZOOM_OUT));
1257 ui->actionZoom400->setShortcut(cmdKeySeq(CMD_ZOOM_400));
1258 ui->actionZoom300->setShortcut(cmdKeySeq(CMD_ZOOM_300));
1259 ui->actionZoom200->setShortcut(cmdKeySeq(CMD_ZOOM_200));
1260 ui->actionZoom100->setShortcut(cmdKeySeq(CMD_ZOOM_100));
1261 ui->actionZoom50->setShortcut(cmdKeySeq(CMD_ZOOM_50));
1262 ui->actionZoom33->setShortcut(cmdKeySeq(CMD_ZOOM_33));
1263 ui->actionZoom25->setShortcut(cmdKeySeq(CMD_ZOOM_25));
1264 ui->actionRotate_Clockwise->setShortcut(cmdKeySeq(CMD_ROTATE_CLOCK));
1265 ui->actionRotate_Anticlockwise->setShortcut(cmdKeySeq(CMD_ROTATE_ANTI_CLOCK));
1266 ui->actionReset_Rotation->setShortcut(cmdKeySeq(CMD_RESET_ROTATION));
1267 ui->actionHorizontal_Flip->setShortcut(cmdKeySeq(CMD_FLIP_HORIZONTAL));
1268 ui->actionVertical_Flip->setShortcut(cmdKeySeq(CMD_FLIP_VERTICAL));
1269 ui->actionGrid->setShortcut(cmdKeySeq(CMD_GRID));
1270 ui->actionCenter->setShortcut(cmdKeySeq(CMD_OVERLAY_CENTER));
1271 ui->actionThirds->setShortcut(cmdKeySeq(CMD_OVERLAY_THIRDS));
1272 ui->actionGoldenRatio->setShortcut(cmdKeySeq(CMD_OVERLAY_GOLDEN_RATIO));
1273 ui->actionSafeAreas->setShortcut(cmdKeySeq(CMD_OVERLAY_SAFE_AREAS));
1274 ui->actionOnePointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_ONE_POINT_PERSPECTIVE));
1275 ui->actionTwoPointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_TWO_POINT_PERSPECTIVE));
1276 ui->actionThreePointPerspective->setShortcut(cmdKeySeq(CMD_OVERLAY_THREE_POINT_PERSPECTIVE));
1277 ui->actionOnionPrev->setShortcut(cmdKeySeq(CMD_ONIONSKIN_PREV));
1278 ui->actionOnionNext->setShortcut(cmdKeySeq(CMD_ONIONSKIN_NEXT));
1279 ui->actionStatusBar->setShortcut(cmdKeySeq(CMD_TOGGLE_STATUS_BAR));
1282 ui->actionPlay->setShortcut(cmdKeySeq(CMD_PLAY));
1283 ui->actionLoop->setShortcut(cmdKeySeq(CMD_LOOP));
1284 ui->actionLoopControl->setShortcut(cmdKeySeq(CMD_LOOP_CONTROL));
1285 ui->actionPrevious_Frame->setShortcut(cmdKeySeq(CMD_GOTO_PREV_FRAME));
1286 ui->actionNext_Frame->setShortcut(cmdKeySeq(CMD_GOTO_NEXT_FRAME));
1287 ui->actionPrev_KeyFrame->setShortcut(cmdKeySeq(CMD_GOTO_PREV_KEY_FRAME));
1288 ui->actionNext_KeyFrame->setShortcut(cmdKeySeq(CMD_GOTO_NEXT_KEY_FRAME));
1289 ui->actionAdd_Frame->setShortcut(cmdKeySeq(CMD_ADD_FRAME));
1290 ui->actionDuplicate_Frame->setShortcut(cmdKeySeq(CMD_DUPLICATE_FRAME));
1291 ui->actionRemove_Frame->setShortcut(cmdKeySeq(CMD_REMOVE_FRAME));
1292 ui->actionAdd_Frame_Exposure->setShortcut(cmdKeySeq(CMD_SELECTION_ADD_FRAME_EXPOSURE));
1293 ui->actionSubtract_Frame_Exposure->setShortcut(cmdKeySeq(CMD_SELECTION_SUBTRACT_FRAME_EXPOSURE));
1294 ui->actionReverse_Frames_Order->setShortcut(cmdKeySeq(CMD_REVERSE_SELECTED_FRAMES));
1295 ui->actionRemove_Frames->setShortcut(cmdKeySeq(CMD_REMOVE_SELECTED_FRAMES));
1296 ui->actionMove_Frame_Backward->setShortcut(cmdKeySeq(CMD_MOVE_FRAME_BACKWARD));
1297 ui->actionMove_Frame_Forward->setShortcut(cmdKeySeq(CMD_MOVE_FRAME_FORWARD));
1298 ui->actionFlip_inbetween->setShortcut(cmdKeySeq(CMD_FLIP_INBETWEEN));
1299 ui->actionFlip_rolling->setShortcut(cmdKeySeq(CMD_FLIP_ROLLING));
1300 ui->actionReposition_Selected_Frames->setShortcut(cmdKeySeq(CMD_SELECTION_REPOSITION_FRAMES));
1303 ui->actionMove->setShortcut(cmdKeySeq(CMD_TOOL_MOVE));
1304 ui->actionSelect->setShortcut(cmdKeySeq(CMD_TOOL_SELECT));
1305 ui->actionBrush->setShortcut(cmdKeySeq(CMD_TOOL_BRUSH));
1306 ui->actionPolyline->setShortcut(cmdKeySeq(CMD_TOOL_POLYLINE));
1307 ui->actionSmudge->setShortcut(cmdKeySeq(CMD_TOOL_SMUDGE));
1308 ui->actionPen->setShortcut(cmdKeySeq(CMD_TOOL_PEN));
1309 ui->actionHand->setShortcut(cmdKeySeq(CMD_TOOL_HAND));
1310 ui->actionPencil->setShortcut(cmdKeySeq(CMD_TOOL_PENCIL));
1311 ui->actionBucket->setShortcut(cmdKeySeq(CMD_TOOL_BUCKET));
1312 ui->actionEyedropper->setShortcut(cmdKeySeq(CMD_TOOL_EYEDROPPER));
1313 ui->actionEraser->setShortcut(cmdKeySeq(CMD_TOOL_ERASER));
1314 ui->actionResetToolsDefault->setShortcut(cmdKeySeq(CMD_RESET_ALL_TOOLS));
1316 ui->actionMove->installEventFilter(shortcutFilter);
1317 ui->actionMove->installEventFilter(shortcutFilter);
1318 ui->actionSelect->installEventFilter(shortcutFilter);
1319 ui->actionBrush->installEventFilter(shortcutFilter);
1320 ui->actionPolyline->installEventFilter(shortcutFilter);
1321 ui->actionSmudge->installEventFilter(shortcutFilter);
1322 ui->actionPen->installEventFilter(shortcutFilter);
1323 ui->actionHand->installEventFilter(shortcutFilter);
1324 ui->actionPencil->installEventFilter(shortcutFilter);
1325 ui->actionBucket->installEventFilter(shortcutFilter);
1326 ui->actionEyedropper->installEventFilter(shortcutFilter);
1327 ui->actionEraser->installEventFilter(shortcutFilter);
1330 ui->actionNew_Bitmap_Layer->setShortcut(cmdKeySeq(CMD_NEW_BITMAP_LAYER));
1331 ui->actionNew_Vector_Layer->setShortcut(cmdKeySeq(CMD_NEW_VECTOR_LAYER));
1332 ui->actionNew_Camera_Layer->setShortcut(cmdKeySeq(CMD_NEW_CAMERA_LAYER));
1333 ui->actionNew_Sound_Layer->setShortcut(cmdKeySeq(CMD_NEW_SOUND_LAYER));
1334 ui->actionDelete_Current_Layer->setShortcut(cmdKeySeq(CMD_DELETE_CUR_LAYER));
1335 ui->actionChangeLineColorCurrent_keyframe->setShortcut(cmdKeySeq(CMD_CHANGE_LINE_COLOR_KEYFRAME));
1336 ui->actionChangeLineColorAll_keyframes_on_layer->setShortcut(cmdKeySeq(CMD_CHANGE_LINE_COLOR_LAYER));
1337 ui->actionChangeLayerOpacity->setShortcut(cmdKeySeq(CMD_CHANGE_LAYER_OPACITY));
1339 ui->actionVisibilityCurrentLayerOnly->setShortcut(cmdKeySeq(CMD_CURRENT_LAYER_VISIBILITY));
1340 ui->actionVisibilityRelative->setShortcut(cmdKeySeq(CMD_RELATIVE_LAYER_VISIBILITY));
1341 ui->actionVisibilityAll->setShortcut(cmdKeySeq(CMD_ALL_LAYER_VISIBILITY));
1343 mToolBox->toggleViewAction()->setShortcut(cmdKeySeq(CMD_TOGGLE_TOOLBOX));
1351 ui->actionHelp->setShortcut(cmdKeySeq(CMD_HELP));
1352 ui->actionExit->setShortcut(cmdKeySeq(CMD_EXIT));
1355void MainWindow2::clearKeyboardShortcuts()
1358 for (
QAction* action : actionList)
1364void MainWindow2::exportPalette()
1369 mEditor->object()->exportPalette(filePath);
1373void MainWindow2::importPalette()
1378 mEditor->object()->importPalette(filePath);
1379 mColorPalette->refreshColorList();
1380 mColorPalette->adjustSwatches();
1381 mEditor->color()->setColorNumber(0);
1385void MainWindow2::openPalette()
1387 for (
int i = 0; i < mEditor->object()->getColorCount(); i++)
1389 if (!mEditor->object()->isColorInUse(i))
1395 msgBox.
setText(
tr(
"Opening a palette will replace the old palette.\n"
1396 "Color(s) in strokes will be altered by this action!"));
1412 mEditor->object()->openPalette(filePath);
1413 mColorPalette->refreshColorList();
1414 mEditor->color()->setColorNumber(0);
1417void MainWindow2::makeConnections(
Editor* editor)
1419 connect(editor->undoRedo(), &UndoRedoManager::didUpdateUndoStack,
this, &MainWindow2::updateSaveState);
1420 connect(editor->undoRedo(), &UndoRedoManager::didUpdateUndoStack,
this, &MainWindow2::updateBackupActionState);
1421 connect(editor, &Editor::needDisplayInfo,
this, &MainWindow2::displayMessageBox);
1422 connect(editor, &Editor::needDisplayInfoNoTitle,
this, &MainWindow2::displayMessageBoxNoTitle);
1423 connect(editor->layers(), &LayerManager::currentLayerChanged,
this, &MainWindow2::currentLayerChanged);
1424 connect(editor->select(), &SelectionManager::selectionChanged,
this, &MainWindow2::selectionChanged);
1425 connect(editor, &Editor::canCopyChanged,
this, [=](
bool canCopy) {
1426 ui->actionCopy->setEnabled(canCopy);
1427 ui->actionCut->setEnabled(canCopy);
1432void MainWindow2::makeConnections(
Editor* editor,
ColorBox* colorBox)
1434 connect(colorBox, &ColorBox::colorChanged, editor->color(), &ColorManager::setFrontColor);
1435 connect(editor->color(), &ColorManager::colorChanged, colorBox, &ColorBox::setColor);
1440 connect(colorInspector, &ColorInspector::colorChanged, editor->color(), &ColorManager::setFrontColor);
1441 connect(editor->color(), &ColorManager::colorChanged, colorInspector, &ColorInspector::setColor);
1446 connect(editor->tools(), &ToolManager::toolChanged, scribbleArea, &ScribbleArea::updateToolCursor);
1447 connect(editor->tools(), &ToolManager::toolChanged, mToolBox, &ToolBoxWidget::onToolSetActive);
1448 connect(editor->tools(), &ToolManager::toolPropertyChanged, scribbleArea, &ScribbleArea::updateToolCursor);
1460void MainWindow2::makeConnections(
Editor* pEditor,
TimeLine* pTimeline)
1463 connect(pTimeline, &TimeLine::duplicateLayerClick, mCommands, &ActionCommands::duplicateLayer);
1464 connect(pTimeline, &TimeLine::duplicateKeyClick, mCommands, &ActionCommands::duplicateKey);
1466 connect(pTimeline, &TimeLine::soundClick, pPlaybackManager, &PlaybackManager::enableSound);
1467 connect(pTimeline, &TimeLine::fpsChanged, pPlaybackManager, &PlaybackManager::setFps);
1468 connect(pTimeline, &TimeLine::fpsChanged, pEditor, &Editor::setFps);
1471 connect(pTimeline, &TimeLine::removeKeyClick, mCommands, &ActionCommands::removeKey);
1473 connect(pTimeline, &TimeLine::newBitmapLayer, mCommands, &ActionCommands::addNewBitmapLayer);
1474 connect(pTimeline, &TimeLine::newVectorLayer, mCommands, &ActionCommands::addNewVectorLayer);
1475 connect(pTimeline, &TimeLine::newSoundLayer, mCommands, &ActionCommands::addNewSoundLayer);
1476 connect(pTimeline, &TimeLine::newCameraLayer, mCommands, &ActionCommands::addNewCameraLayer);
1477 connect(mTimeLine, &TimeLine::playButtonTriggered, mCommands, &ActionCommands::PlayStop);
1478 connect(pTimeline, &TimeLine::deleteCurrentLayerClick, mCommands, &ActionCommands::deleteCurrentLayer);
1482 connect(pTimeline, &TimeLine::selectionChanged,
this, &MainWindow2::updateCopyCutPasteEnabled);
1484 connect(mEditor->select(), &SelectionManager::selectionChanged,
this, &MainWindow2::updateCopyCutPasteEnabled);
1486 connect(pEditor->layers(), &LayerManager::currentLayerChanged, pTimeline, &TimeLine::updateUI);
1488 connect(pEditor->sound(), &SoundManager::soundClipDurationChanged, pTimeline, &TimeLine::updateUI);
1493 connect(pEditor, &Editor::objectLoaded, pTimeline, &TimeLine::onObjectLoaded);
1494 connect(pEditor, &Editor::updateTimeLine, pTimeline, &TimeLine::updateUI);
1495 connect(pEditor, &Editor::updateTimeLineCached, pTimeline, &TimeLine::updateUICached);
1497 connect(pEditor->layers(), &LayerManager::currentLayerChanged,
this, &MainWindow2::updateLayerMenu);
1498 connect(pEditor->layers(), &LayerManager::currentLayerChanged, mToolOptions, &ToolOptionWidget::updateUI);
1507 toolOptions->makeConnectionToEditor(editor);
1512 connect(pEditor, &Editor::objectLoaded, pColorPalette, &ColorPaletteWidget::updateUI);
1515 ScribbleArea* pScribbleArea = pEditor->getScribbleArea();
1517 connect(pColorPalette, &ColorPaletteWidget::colorNumberChanged, pColorManager, &ColorManager::setColorNumber);
1518 connect(pColorManager, &ColorManager::colorNumberChanged, pScribbleArea, &ScribbleArea::paletteColorChanged);
1519 connect(pColorManager, &ColorManager::colorNumberChanged, pColorPalette, &ColorPaletteWidget::selectColorNumber);
1522void MainWindow2::makeConnections(
Editor* editor,
StatusBar *statusBar)
1531void MainWindow2::updateCopyCutPasteEnabled()
1533 bool canCopy = mEditor->canCopy();
1534 bool canPaste = mEditor->canPaste();
1536 ui->actionCopy->setEnabled(canCopy);
1537 ui->actionCut->setEnabled(canCopy);
1538 ui->actionPaste->setEnabled(canPaste);
1541void MainWindow2::updateLayerMenu()
1543 ui->actionDelete_Current_Layer->setEnabled(mEditor->layers()->canDeleteLayer(mEditor->currentLayerIndex()));
1546void MainWindow2::changePlayState(
bool isPlaying)
1550 ui->actionPlay->setText(
tr(
"Stop"));
1551 ui->actionPlay->setIcon(mStopIcon);
1555 ui->actionPlay->setText(
tr(
"Play"));
1556 ui->actionPlay->setIcon(mStartIcon);
1561void MainWindow2::importMovieVideo()
1564 mSuppressAutoSaveDialog =
true;
1566 mCommands->importMovieVideo();
1568 mSuppressAutoSaveDialog =
false;
1571bool MainWindow2::event(
QEvent* event)
1579void MainWindow2::displayMessageBox(
const QString& title,
const QString& body)
1584void MainWindow2::displayMessageBoxNoTitle(
const QString& body)
1589bool MainWindow2::tryRecoverUnsavedProject()
1592 QStringList recoverables = fm.searchForUnsavedProjects();
1594 if (recoverables.
empty())
1599 QString caption =
tr(
"Restore Project?");
1600 QString text =
tr(
"Pencil2D didn't close correctly. Would you like to restore the project?");
1602 QString recoverPath = recoverables[0];
1613 hideQuestionMark(*msgBox);
1620void MainWindow2::startProjectRecovery(
int result)
1635 Object* o = fm.recoverUnsavedProject(recoverPath);
1636 if (!fm.error().ok())
1638 Q_ASSERT(o ==
nullptr);
1639 const QString title =
tr(
"Recovery Failed.");
1640 const QString text =
tr(
"Sorry! Pencil2D is unable to restore your project");
1646 mEditor->setObject(o);
1648 updateBackupActionState();
1650 const QString title =
tr(
"Recovery Succeeded!");
1651 const QString text =
tr(
"Please save your work immediately to prevent loss of data");
1655void MainWindow2::createToolbars()
1660 mMainToolbar->
addAction(ui->actionOpen);
1661 mMainToolbar->
addAction(ui->actionSave);
1663 mMainToolbar->
addAction(ui->actionUndo);
1664 mMainToolbar->
addAction(ui->actionRedo);
1667 mMainToolbar->
addAction(ui->actionCopy);
1668 mMainToolbar->
addAction(ui->actionPaste);
1669 mMainToolbar->
addAction(ui->actionClearFrame);
1673 mViewToolbar->
addAction(ui->actionZoom_In);
1674 mViewToolbar->
addAction(ui->actionZoom_Out);
1675 mViewToolbar->
addAction(ui->actionReset_View);
1677 mViewToolbar->
addAction(ui->actionHorizontal_Flip);
1678 mViewToolbar->
addAction(ui->actionVertical_Flip);
1680 mViewToolbar->
addAction(ui->actionShowInvisibleLines);
1681 mViewToolbar->
addAction(ui->actionShowOutlinesOnly);
1685 mOverlayToolbar->
addAction(ui->actionGrid);
1686 mOverlayToolbar->
addAction(ui->actionCenter);
1687 mOverlayToolbar->
addAction(ui->actionThirds);
1688 mOverlayToolbar->
addAction(ui->actionGoldenRatio);
1689 mOverlayToolbar->
addAction(ui->actionSafeAreas);
1690 mOverlayToolbar->
addAction(ui->actionOnePointPerspective);
1691 mOverlayToolbar->
addAction(ui->actionTwoPointPerspective);
1692 mOverlayToolbar->
addAction(ui->actionThreePointPerspective);
1698 perspectiveLinesAngleButton->
setDefaultAction(ui->menuPerspectiveLinesAngle->menuAction());
1700 mOverlayToolbar->
addWidget(perspectiveLinesAngleButton);
1702 mToolbars = { mMainToolbar, mViewToolbar, mOverlayToolbar };
1706 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