Skip to content

Commit

Permalink
Option to show or hide the cycle each page on Update dialog #798
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Dec 2, 2024
1 parent f2f5953 commit eb2f619
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 68 deletions.
13 changes: 10 additions & 3 deletions mainApp/commonmenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3857,9 +3857,16 @@ void CommonMenus::setWhatsThis()
" Cycle each page when navigating forward by more than <br>"
" one page.<br><br>"
" Select Yes to perform the cycle behaviour across the<br>"
" specified pages<br>Select No to perform a direct jump<br>"
" to the the specified page. Select Cancel to abort the<br>"
" navigation action altogether.%1<br>")
" specified pages<br>"
" Select No to perform a direct jump to the the specified page.<br>"
" Select Cancel to abort the navigation action altogether.<br><br>"
" If you do not wan to display this dialog at each Update,<br>"
" you may elect to not show this dialog. When the cycle<br>"
" each page dialog is presented upon clicking Update,<br>"
" The additional dialog to Remember your choice and do<br>"
" not show this message again is presented.%1<br><br>"
" You may reset the dialog display from the Command Editor<br>"
" dialog.%1<br>")
.arg(
#ifdef QT_DEBUG_MODE
QLatin1String("<br><br> WT_DIALOG_CYCLE")
Expand Down
1 change: 1 addition & 0 deletions mainApp/docs/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions mainApp/docs/RELEASE_NOTES.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h2>LPub3D Official release.</h2>
<li><code><a href="https://github.com/trevorsandy/lpub3d/issues/786">2.4.8.217 Enhancement - Expanded part filter options #786</a></code></li>
<li><code><a href="https://github.com/trevorsandy/lpub3d/issues/776">2.4.8.217 Enhancement - Improve integration of BuildMods with fade steps and highlight step #776</a></code></li>
<li><code><a href="https://github.com/trevorsandy/lpub3d/issues/795">2.4.8.217 Enhancement - Option to load last opened page on load last opened file #795</a></code></li>
<li><code><a href="https://github.com/trevorsandy/lpub3d/issues/798">2.4.8.217 Enhancement - Option to show or hide the cycle each page on Update dialog #798</a></code></li>
<li><code><a href="https://github.com/trevorsandy/lpub3d/issues/789">2.4.8.217 Change - AbEnd on insert a page pointer at the top of a STEP #789</a></code></li>
<li><code><a href="https://github.com/trevorsandy/lpub3d/issues/787">2.4.8.217 Change - Add minizip unzOpen to quazip to avoid violating ODR #787</a></code></li>
<li><code><a href="https://github.com/trevorsandy/lpub3d/issues/784">2.4.8.217 Change - AppImage build Qt Network SSL limitation #784</a></code></li>
Expand Down
28 changes: 21 additions & 7 deletions mainApp/editwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand All @@ -2764,7 +2773,6 @@ void EditWindow::preferences()
editorSelectedItemsSubform->addRow(editorPreviewOnDoubleClickBox);
} // ! modelFileEdit()


// options - button box
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, dialog);
Expand Down Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion mainApp/editwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <atomic>

#include "declarations.h"
#include "qaction.h"

class QAbstractItemModel;
class QCompleter;
Expand Down Expand Up @@ -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;
Expand Down
55 changes: 35 additions & 20 deletions mainApp/lpub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"),
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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())));

Expand Down
2 changes: 1 addition & 1 deletion mainApp/lpub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions mainApp/lpub3d.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions mainApp/lpub_preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion mainApp/lpub_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit eb2f619

Please sign in to comment.