Merge pull request #594 from manongjohn/breakout_autocreation_options

Breakout frame creation options from Autocreate preference
This commit is contained in:
manongjohn 2021-02-24 14:27:52 -05:00 committed by GitHub
commit 2c668c85ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 6 deletions

View file

@ -301,7 +301,8 @@ TImage *TTool::touchImage() {
bool animationSheetEnabled = pref->isAnimationSheetEnabled();
bool isAutoStretchEnabled = pref->isAutoStretchEnabled();
bool isAutoRenumberEnabled = pref->isAutorenumberEnabled();
bool isCreateInHoldCellsEnabled = pref->isCreationInHoldCellsEnabled();
bool isCreateInHoldCellsEnabled =
isAutoCreateEnabled && pref->isCreationInHoldCellsEnabled();
TFrameHandle *currentFrame = m_application->getCurrentFrame();
TXshLevelHandle *currentLevel = m_application->getCurrentLevel();

View file

@ -2710,6 +2710,8 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
//----- Going to cheat a little. Use autocreate rules to help create what we
// need
// If autocreate disabled, let's turn it on temporarily
bool isAutoCreateEnabled = Preferences::instance()->isAutoCreateEnabled();
if (!isAutoCreateEnabled)
@ -2719,6 +2721,7 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
Preferences::instance()->isCreationInHoldCellsEnabled();
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, true, false);
//------------------
TImage *img = toolHandle->getTool()->touchImage();
@ -2726,11 +2729,13 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
TXshSimpleLevel *sl = cell.getSimpleLevel();
if (!img || !sl) {
//----- Restore previous states of autocreation
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, false,
false);
//------------------
if (!multiple)
DVGui::warning(QObject::tr(
"Unable to create a blank drawing on the current column"));
@ -2738,11 +2743,13 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
}
if (!toolHandle->getTool()->m_isFrameCreated) {
//----- Restore previous states of autocreation
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, false,
false);
//------------------
if (!multiple)
DVGui::warning(QObject::tr(
"Unable to replace the current drawing with a blank drawing"));
@ -2760,11 +2767,12 @@ void TCellSelection::createBlankDrawing(int row, int col, bool multiple) {
IconGenerator::instance()->invalidate(sl, frame);
// Reset back to what these were
//----- Restore previous states of autocreation
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, false, false);
//------------------
}
//-----------------------------------------------------------------------------
@ -2861,6 +2869,8 @@ void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
ToolHandle *toolHandle = TApp::instance()->getCurrentTool();
//----- Going to cheat a little. Use autocreate rules to help create what we
// need
// If autocreate disabled, let's turn it on temporarily
bool isAutoCreateEnabled = Preferences::instance()->isAutoCreateEnabled();
if (!isAutoCreateEnabled)
@ -2870,14 +2880,17 @@ void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
Preferences::instance()->isCreationInHoldCellsEnabled();
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, true, false);
//------------------
TImage *img = toolHandle->getTool()->touchImage();
if (!img) {
//----- Restore previous states of autocreation
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, false,
false);
//------------------
if (!multiple)
DVGui::warning(
QObject::tr("Unable to duplicate a drawing on the current column"));
@ -2886,11 +2899,13 @@ void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
bool frameCreated = toolHandle->getTool()->m_isFrameCreated;
if (!frameCreated) {
//----- Restore previous states of autocreation
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, false,
false);
//------------------
if (!multiple)
DVGui::warning(
QObject::tr("Unable to replace the current or next drawing with a "
@ -2912,10 +2927,12 @@ void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
new DuplicateDrawingUndo(sl, srcFrame, targetFrame);
TUndoManager::manager()->add(undo);
//----- Restore previous states of autocreation
if (!isAutoCreateEnabled)
Preferences::instance()->setValue(EnableAutocreation, false, false);
if (!isCreationInHoldCellsEnabled)
Preferences::instance()->setValue(EnableCreationInHoldCells, false, false);
//------------------
}
//-----------------------------------------------------------------------------

View file

@ -1658,13 +1658,16 @@ QWidget* PreferencesPopup::createDrawingPage() {
insertUI(newLevelSizeToCameraSizeEnabled, lay);
insertDualUIs(DefLevelWidth, DefLevelHeight, lay);
// insertUI(DefLevelDpi, lay);
QGridLayout* creationLay = insertGroupBox(
tr("Frame Creation Options"), lay);
{
insertUI(NumberingSystem, creationLay, getComboItemList(NumberingSystem));
insertUI(EnableAutoStretch, creationLay);
insertUI(EnableAutoRenumber, creationLay);
}
QGridLayout* autoCreationLay = insertGroupBoxUI(EnableAutocreation, lay);
{
insertUI(NumberingSystem, autoCreationLay,
getComboItemList(NumberingSystem));
insertUI(EnableAutoStretch, autoCreationLay);
insertUI(EnableCreationInHoldCells, autoCreationLay);
insertUI(EnableAutoRenumber, autoCreationLay);
}
insertUI(vectorSnappingTarget, lay, getComboItemList(vectorSnappingTarget));
insertUI(saveUnpaintedInCleanup, lay);