diff --git a/mainApp/commonmenus.cpp b/mainApp/commonmenus.cpp index d87f99f1f..b00257aa6 100644 --- a/mainApp/commonmenus.cpp +++ b/mainApp/commonmenus.cpp @@ -3857,9 +3857,16 @@ void CommonMenus::setWhatsThis() " Cycle each page when navigating forward by more than
" " one page.

" " Select Yes to perform the cycle behaviour across the
" - " specified pages
Select No to perform a direct jump
" - " to the the specified page. Select Cancel to abort the
" - " navigation action altogether.%1
") + " specified pages
" + " Select No to perform a direct jump to the the specified page.
" + " Select Cancel to abort the navigation action altogether.

" + " If you do not wan to display this dialog at each Update,
" + " you may elect to not show this dialog. When the cycle
" + " each page dialog is presented upon clicking Update,
" + " The additional dialog to Remember your choice and do
" + " not show this message again is presented.%1

" + " You may reset the dialog display from the Command Editor
" + " dialog.%1
") .arg( #ifdef QT_DEBUG_MODE QLatin1String("

WT_DIALOG_CYCLE") diff --git a/mainApp/docs/README.txt b/mainApp/docs/README.txt index 19c124f9e..e3ccd4d0a 100644 --- a/mainApp/docs/README.txt +++ b/mainApp/docs/README.txt @@ -21,6 +21,7 @@ Revisions: - Enhancement - Expanded part filter options #786 - Enhancement - Improve integration of BuildMods with fade steps and highlight step #776 - Enhancement - Option to load last opened page on load last opened file #795 +- Enhancement - Option to show or hide the cycle each page on Update dialog #798 - Change - AbEnd on insert a page pointer at the top of a STEP #789 - Change - Add minizip unzOpen to quazip to avoid violating ODR #787 - Change - AppImage build Qt Network SSL limitation #784 diff --git a/mainApp/docs/RELEASE_NOTES.html b/mainApp/docs/RELEASE_NOTES.html index aa2fdff42..c6231b46c 100644 --- a/mainApp/docs/RELEASE_NOTES.html +++ b/mainApp/docs/RELEASE_NOTES.html @@ -89,6 +89,7 @@

LPub3D Official release.

  • 2.4.8.217 Enhancement - Expanded part filter options #786
  • 2.4.8.217 Enhancement - Improve integration of BuildMods with fade steps and highlight step #776
  • 2.4.8.217 Enhancement - Option to load last opened page on load last opened file #795
  • +
  • 2.4.8.217 Enhancement - Option to show or hide the cycle each page on Update dialog #798
  • 2.4.8.217 Change - AbEnd on insert a page pointer at the top of a STEP #789
  • 2.4.8.217 Change - Add minizip unzOpen to quazip to avoid violating ODR #787
  • 2.4.8.217 Change - AppImage build Qt Network SSL limitation #784
  • diff --git a/mainApp/editwindow.cpp b/mainApp/editwindow.cpp index b8c8b003b..0ef104611 100644 --- a/mainApp/editwindow.cpp +++ b/mainApp/editwindow.cpp @@ -561,7 +561,7 @@ void EditWindow::createActions() redrawAct = new QAction(QIcon(":/resources/redraw.png"), tr("&Redraw"), this); redrawAct->setObjectName("redrawAct.2"); redrawAct->setShortcut(QStringLiteral("Ctrl+R")); - redrawAct->setStatusTip(tr("Redraw page, reset model caches")); + redrawAct->setStatusTip(tr("Redraw page and reset model caches")); lpub->actions.insert(redrawAct->objectName(), Action(QStringLiteral("Edit.Redraw"), redrawAct)); connect(redrawAct, SIGNAL(triggered()), this, SLOT(redraw())); @@ -2272,11 +2272,6 @@ void EditWindow::showLine(int lineNumber, int lineType) pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); } -bool EditWindow::updateEnabled() -{ - return updateAct->isEnabled(); -} - void EditWindow::updateDisabled(bool state) { if (sender() == saveAct) { @@ -2666,11 +2661,14 @@ void EditWindow::preferences() bool editorBufferedPaging = Preferences::editorBufferedPaging; bool editorHighlightLines = Preferences::editorHighlightLines; bool editorLoadSelectionStep = Preferences::editorLoadSelectionStep; + QString editorFont = Preferences::editorFont; QString change; // modelFileEdit() only bool editorPreviewOnDoubleClick = Preferences::editorPreviewOnDoubleClick; + bool editorCyclePagesOnUpdateDialog = Preferences::editorCyclePagesOnUpdateDialog; + auto showMessage = [&windowTitle] (const QString change) { QMessageBoxResizable box; box.setWindowIcon(QIcon()); @@ -2738,6 +2736,17 @@ void EditWindow::preferences() editorLinesPerPageSpin->setToolTip(tr("Set lines per page between %1 and %2 to optimize scrolling.").arg(EDITOR_MIN_LINES_DEFAULT).arg(EDITOR_MAX_LINES_DEFAULT)); editorBufferedPagingSubform->addRow(editorLinesPerPageLabel, editorLinesPerPageSpin); + // options - cycle pages on update dialog + QGroupBox *editorCyclePagesOnUpdateDialogGrpBox = new QGroupBox(tr("Cycle Pages Dialog")); + form->addWidget(editorCyclePagesOnUpdateDialogGrpBox); + QFormLayout *editorCyclePagesOnUpdateDialogSubform = new QFormLayout(editorCyclePagesOnUpdateDialogGrpBox); + + QCheckBox *editorCyclePagesOnUpdateDialogChkBox = nullptr; + editorCyclePagesOnUpdateDialogChkBox = new QCheckBox(tr("Show Cycle Pages On Update Dialog"), dialog); + editorCyclePagesOnUpdateDialogChkBox->setToolTip(tr("Check to display the dialog on page update.")); + editorCyclePagesOnUpdateDialogChkBox->setChecked(editorCyclePagesOnUpdateDialog); + editorCyclePagesOnUpdateDialogSubform->addRow(editorCyclePagesOnUpdateDialogChkBox); + // options - selected lines QCheckBox *editorHighlightLinesBox = nullptr; QCheckBox *editorLoadSelectionStepBox = nullptr; @@ -2764,7 +2773,6 @@ void EditWindow::preferences() editorSelectedItemsSubform->addRow(editorPreviewOnDoubleClickBox); } // ! modelFileEdit() - // options - button box QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, dialog); @@ -2815,6 +2823,12 @@ void EditWindow::preferences() emit lpub->messageSig(LOG_INFO,tr("Buffered lines par page changed from %1 to %2").arg(editorLinesPerPage).arg(Preferences::editorLinesPerPage)); } + if (editorCyclePagesOnUpdateDialog != editorCyclePagesOnUpdateDialogChkBox->isChecked()) { + editorCyclePagesOnUpdateDialog = editorCyclePagesOnUpdateDialogChkBox->isChecked(); + Preferences::setEditorCyclePagesOnUpdateDialog(editorCyclePagesOnUpdateDialog); + emit lpub->messageSig(LOG_INFO,tr("Show Cycle Pages On Update dialog changed is %1").arg(editorCyclePagesOnUpdateDialog ? "On" : "Off")); + } + if (! modelFileEdit()) { Preferences::editorHighlightLines = editorHighlightLinesBox->isChecked(); if (editorHighlightLines != Preferences::editorHighlightLines) { diff --git a/mainApp/editwindow.h b/mainApp/editwindow.h index 57098f4d4..7c9f465cd 100644 --- a/mainApp/editwindow.h +++ b/mainApp/editwindow.h @@ -39,6 +39,7 @@ #include #include "declarations.h" +#include "qaction.h" class QAbstractItemModel; class QCompleter; @@ -88,7 +89,16 @@ class EditWindow : public QMainWindow { return stepLines.bottom; } - bool updateEnabled(); + + bool updateEnabled() + { + return updateAct->isEnabled(); + } + + void setUpdateEnabled(bool b) + { + updateAct->setEnabled(b); + } QToolBar *editToolBar; QToolBar *toolsToolBar; diff --git a/mainApp/lpub.cpp b/mainApp/lpub.cpp index f634e2173..7b2951a12 100644 --- a/mainApp/lpub.cpp +++ b/mainApp/lpub.cpp @@ -421,7 +421,7 @@ void Gui::displayPage() } } -void Gui::cyclePageDisplay(const int inputPageNum, bool silent/*true*/, bool fileReload/*false*/) +void Gui::cyclePageDisplay(const int inputPageNum, bool silent/*true*/, bool fileReload/*false*/, bool isEditor) { int goToPageNum = inputPageNum; @@ -476,7 +476,13 @@ void Gui::cyclePageDisplay(const int inputPageNum, bool silent/*true*/, bool fil if (!silent || fileReload) { // if dialog or fileReload is true, cycleEachPage = FILE_RELOAD (1), else cycleEachPage = FILE_DEFAULT(0) do not cycle PageDirection cycleEachPage = DIRECTION_NOT_SET; - if (notAtStartOfPages && !(Preferences::cycleEachPage || fileReload)) { + bool showCycleDialog = true; + if (isEditor) { + showCycleDialog = Preferences::editorCyclePagesOnUpdateDialog; + if (!showCycleDialog) + cycleEachPage = Preferences::editorCyclePagesOnUpdate ? FILE_RELOAD : FILE_DEFAULT; + } + if (notAtStartOfPages && !(Preferences::cycleEachPage || fileReload) && showCycleDialog) { const QString directionName[] = { tr("Next"), tr("Jump Forward"), @@ -487,23 +493,30 @@ void Gui::cyclePageDisplay(const int inputPageNum, bool silent/*true*/, bool fil // On page update, (move = 0), subtract first page from displayPageNum. int movement = setDirection(move); int pages = movement ? qAbs(movement) : Gui::displayPageNum - (1 + Gui::pa); - int pageDir = Gui::pageDirection; - const QString message = tr("Cycle each of the %1 pages for the model file %2 %3 ?") - .arg(pages) - .arg(directionName[pageDir].toLower()) - .arg(fileReload ? tr("reload") : tr("load")); - int result = CycleDialog::getCycle(tr("%1 Page %2") - .arg(VER_PRODUCTNAME_STR) - .arg(directionName[pageDir]), message, nullptr); - if (result == CycleYes) - cycleEachPage = FILE_RELOAD; - else if (result == CycleNo) - cycleEachPage = FILE_DEFAULT; - else if (result == CycleCancel) - return; - } + if (pages > 1) { + int pageDir = Gui::pageDirection; + const QString message = tr("Cycle each of the %1 pages for the model file %2 %3 ?") + .arg(pages) + .arg(directionName[pageDir].toLower()) + .arg(fileReload ? tr("reload") : tr("load")); + + CyclePageDlgType result = CycleDialog::getCycle(tr("%1 Page %2") + .arg(VER_PRODUCTNAME_STR) + .arg(directionName[pageDir]), message, isEditor, nullptr); + if (result == CycleYes) + cycleEachPage = FILE_RELOAD; + else if (result == CycleNo) + cycleEachPage = FILE_DEFAULT; + else if (result == CycleCancel) { + editWindow->setUpdateEnabled(true); + return; + } + } else { + cycleEachPage = FILE_DEFAULT; + } + } // show dialog - if (cycleEachPage > DIRECTION_NOT_SET) { + if (cycleEachPage > FILE_DEFAULT) { if (Preferences::buildModEnabled) cycleEachPage = move; Preferences::setCyclePageDisplay(cycleEachPage); @@ -520,6 +533,7 @@ void Gui::cyclePageDisplay(const int inputPageNum, bool silent/*true*/, bool fil if (!Gui::m_lastDisplayedPage) goToPageNum = Gui::pa ? savePage + Gui::pa : savePage; Gui::displayPageNum = 1 + Gui::pa; + gui->setPageLineEdit->setText(QString("%1 of %2").arg(goToPageNum).arg(Gui::maxPages)); if (move == DIRECTION_NOT_SET) setDirection(move); if (move > PAGE_NEXT) { @@ -1812,7 +1826,8 @@ void Gui::reloadCurrentPage(bool prompt) { return; } - if (sender() == gui->editWindow || prompt) { + bool isEditor = sender() == gui->editWindow; + if (isEditor || prompt) { bool _continue; if (Preferences::saveOnUpdate) { _continue = gui->maybeSave(false); // No prompt @@ -1827,7 +1842,7 @@ void Gui::reloadCurrentPage(bool prompt) { timer.start(); // Gui::displayPage(); - gui->cyclePageDisplay(Gui::displayPageNum, false/*silent*/); + gui->cyclePageDisplay(Gui::displayPageNum, false/*silent*/, false/*fileReload*/,isEditor); emit gui->messageSig(LOG_STATUS, tr("Page %1 reloaded. %2").arg(Gui::displayPageNum).arg(Gui::elapsedTime(timer.elapsed()))); diff --git a/mainApp/lpub.h b/mainApp/lpub.h index 72d29df90..729afc31e 100644 --- a/mainApp/lpub.h +++ b/mainApp/lpub.h @@ -1565,7 +1565,7 @@ public slots: void reloadCurrentModelFile(); void reloadModelFileAfterColorFileGen(); void reloadCurrentPage(bool prompt = false); - void cyclePageDisplay(const int inputPageNum, bool silent = true, bool global = false); + void cyclePageDisplay(const int inputPageNum, bool silent = true, bool global = false, bool isEditor = false); void resetModelCache(QString file = QString(), bool commandLine = false); bool removeDir(int &count,const QString &dirName); diff --git a/mainApp/lpub3d.appdata.xml b/mainApp/lpub3d.appdata.xml index 087a015a4..dcf4c3819 100644 --- a/mainApp/lpub3d.appdata.xml +++ b/mainApp/lpub3d.appdata.xml @@ -89,6 +89,7 @@ Enhancement - Expanded part filter options #786 Enhancement - Improve integration of BuildMods with fade steps and highlight step #776 Enhancement - Option to load last opened page on load last opened file #795 + Enhancement - Option to show or hide the cycle each page on Update dialog #798 Change - AbEnd on insert a page pointer at the top of a STEP #789 Change - Add minizip unzOpen to quazip to avoid violating ODR #787 Change - AppImage build Qt Network SSL limitation #784 diff --git a/mainApp/lpub_preferences.cpp b/mainApp/lpub_preferences.cpp index 90a40de8b..bf78aa0a5 100644 --- a/mainApp/lpub_preferences.cpp +++ b/mainApp/lpub_preferences.cpp @@ -448,6 +448,8 @@ bool Preferences::finalModelEnabled = true; bool Preferences::editorHighlightLines = false; bool Preferences::editorLoadSelectionStep = true; bool Preferences::editorPreviewOnDoubleClick = true; +bool Preferences::editorCyclePagesOnUpdate = true; +bool Preferences::editorCyclePagesOnUpdateDialog = true; bool Preferences::editorTabLock = false; bool Preferences::inlineNativeContent = true; bool Preferences::useSystemTheme = true; @@ -3705,6 +3707,22 @@ void Preferences::editorPreferences() editorHighlightLines = Settings.value(QString("%1/%2").arg(SETTINGS,"EditorHighlightLines")).toBool(); } + // Remember cycle pages on update dialog choice - Yes=true, No=false + if ( ! Settings.contains(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdate"))) { + QVariant uValue(editorCyclePagesOnUpdate); + Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdate"),uValue); + } else { + editorCyclePagesOnUpdate = Settings.value(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdate")).toBool(); + } + + // Show cycle pages on Update dialog - Show=true. Hide=false + if ( ! Settings.contains(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdateDialog"))) { + QVariant uValue(editorCyclePagesOnUpdateDialog); + Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdateDialog"),uValue); + } else { + editorCyclePagesOnUpdateDialog = Settings.value(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdateDialog")).toBool(); + } + // Load the first step (on multi-line select) of selected lines in the Visual Editor if ( ! Settings.contains(QString("%1/%2").arg(SETTINGS,"EditorLoadSelectionStep"))) { QVariant uValue(editorLoadSelectionStep); @@ -4532,6 +4550,20 @@ int Preferences::showMessage( return box.exec(); } +void Preferences::setEditorCyclePagesOnUpdate(bool b) +{ + QSettings Settings; + editorCyclePagesOnUpdate = b; + Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdate"),QVariant(b)); +} + +void Preferences::setEditorCyclePagesOnUpdateDialog(bool b) +{ + QSettings Settings; + editorCyclePagesOnUpdateDialog = b; + Settings.setValue(QString("%1/%2").arg(SETTINGS,"EditorCyclePagesOnUpdateDialog"),QVariant(b)); +} + void Preferences::setShowSaveOnRedrawPreference(bool b) { QSettings Settings; diff --git a/mainApp/lpub_preferences.h b/mainApp/lpub_preferences.h index adb7265b1..076849695 100644 --- a/mainApp/lpub_preferences.h +++ b/mainApp/lpub_preferences.h @@ -144,7 +144,10 @@ class Preferences static void setBlenderVersionPreference(QString); static void setBlenderLDrawConfigPreference(QString); static void setBlenderImportModule(QString); - static void setBlenderAddonVersionCheck(bool = true); + static void setBlenderAddonVersionCheck(bool = true); + + static void setEditorCyclePagesOnUpdate(bool); + static void setEditorCyclePagesOnUpdateDialog(bool); static void setInitFadeSteps(); static void setInitHighlightStep(); @@ -423,6 +426,8 @@ class Preferences static bool editorHighlightLines; static bool editorLoadSelectionStep; static bool editorPreviewOnDoubleClick; + static bool editorCyclePagesOnUpdate; + static bool editorCyclePagesOnUpdateDialog; static bool editorTabLock; #ifdef Q_OS_MAC diff --git a/mainApp/pairdialog.cpp b/mainApp/pairdialog.cpp index 993c11472..7025c3890 100644 --- a/mainApp/pairdialog.cpp +++ b/mainApp/pairdialog.cpp @@ -459,12 +459,12 @@ bool LocalDialog::getLocal( } } -int CycleDialog::cycleResult = CycleNone; - CycleDialog::CycleDialog( - QString title, - QString question, - QWidget *parent) + QString title, + QString question, + bool isEditor, + QWidget *parent) : + rememberEditorCycleChoice(false) { QLabel *label = new QLabel(question,parent); @@ -476,15 +476,23 @@ CycleDialog::CycleDialog( grid->addWidget(label); - QDialogButtonBox *buttonBox; + if (isEditor) { + QCheckBox *cb = new QCheckBox(tr("Remember Choice and do not show this again.")); + grid->addWidget(cb); + QObject::connect(cb, &QCheckBox::stateChanged, [&](int state) { + if (static_cast(state) == Qt::CheckState::Checked) { + Preferences::setEditorCyclePagesOnUpdateDialog(false); + rememberEditorCycleChoice = true; + } + }); + } buttonBox = new QDialogButtonBox(parent); buttonBox->addButton(QDialogButtonBox::Yes); - connect(buttonBox,SIGNAL(accepted()),SLOT(accept())); buttonBox->addButton(QDialogButtonBox::No); - connect(buttonBox,SIGNAL(rejected()), this, SLOT(reject())); buttonBox->addButton(QDialogButtonBox::Cancel); - connect(buttonBox,SIGNAL(rejected()), this, SLOT(cancel())); + connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), + this, SLOT(buttonClicked(QAbstractButton*))); grid->addWidget(buttonBox); @@ -498,32 +506,41 @@ CycleDialog::~CycleDialog() { } -int CycleDialog::getCycle( - QString title, - QString question, - QWidget *parent) -{ - CycleDialog *dialog = new CycleDialog(title,question,parent); - if (dialog->exec() == QDialog::Accepted) { - cycleResult = CycleYes; +CyclePageDlgType CycleDialog::getCycle( + QString title, + QString question, + bool isEditor, + QWidget *parent) +{ + CycleDialog *dialog = new CycleDialog(title,question,isEditor,parent); + dialog->exec(); + return dialog->cycleResult; +} + +void CycleDialog::buttonClicked( QAbstractButton *button ) +{ + switch (buttonBox->standardButton(button)) + { + case QDialogButtonBox::Yes: + cycleResult = CycleYes; + if (rememberEditorCycleChoice) + Preferences::setEditorCyclePagesOnUpdate(true); + return QDialog::accept(); + case QDialogButtonBox::No: + cycleResult = CycleNo; + if (rememberEditorCycleChoice) + Preferences::setEditorCyclePagesOnUpdate(false); + break; + case QDialogButtonBox::Cancel: + cycleResult = CycleCancel; + break; + default: + qDebug() << Q_FUNC_INFO << qPrintable("Cycle pages button not handled"); + break; } - qDebug() << "DEBUG: Cycle Resule" << (cycleResult == CycleYes ? "Yes" : cycleResult == CycleNo ? "No" : "Cancel"); - return cycleResult; -} - -void CycleDialog::cancel() -{ - cycleResult = CycleCancel; QDialog::reject(); } -void CycleDialog::reject() -{ - cycleResult = CycleNo; - QDialog::reject(); -} - - OptionDialog::OptionDialog( QString titles, QString options, diff --git a/mainApp/pairdialog.h b/mainApp/pairdialog.h index cb2f827fd..616b71339 100644 --- a/mainApp/pairdialog.h +++ b/mainApp/pairdialog.h @@ -234,18 +234,21 @@ class CycleDialog : public QDialog CycleDialog( QString title, QString question, + bool isEditor, QWidget *parent); ~CycleDialog(); - static int getCycle( + static CyclePageDlgType getCycle( QString title, QString question, + bool isEditor, QWidget *parent); private slots: - virtual void cancel(); - virtual void reject(); + void buttonClicked(QAbstractButton *button); private: - static int cycleResult; + QDialogButtonBox *buttonBox; + CyclePageDlgType cycleResult; + bool rememberEditorCycleChoice; }; class OptionDialog : public QDialog