diff --git a/qt/settings_dialog.ui b/qt/settings_dialog.ui index 9112e022..3f756946 100644 --- a/qt/settings_dialog.ui +++ b/qt/settings_dialog.ui @@ -302,6 +302,103 @@ + + + + + 50 + false + + + + Dialogs + + + + 4 + + + 4 + + + 4 + + + 4 + + + 4 + + + + + Skip new project dialog (use defaults) + + + + + + + + + + 50 + false + true + + + + Default Tool Table + + + + + + + false + + + + Default + + + + + Current + + + + + Empty + + + + + + + + Qt::Horizontal + + + + 13 + 17 + + + + + + + + + + Skip save confirmation on close + + + + + + diff --git a/src/camotics/qt/FileTabManager.cpp b/src/camotics/qt/FileTabManager.cpp index 8db967e9..07a784c2 100644 --- a/src/camotics/qt/FileTabManager.cpp +++ b/src/camotics/qt/FileTabManager.cpp @@ -33,6 +33,7 @@ #include #include #include +#include using namespace CAMotics; using namespace cb; @@ -126,6 +127,9 @@ const SmartPointer &FileTabManager::getFile(unsigned tab) const { bool FileTabManager::checkSave(unsigned tab) { + if (QSettings().value("Settings/SkipSaveConfirmation", false).toBool()) + return true; + if (!isModified(tab)) return true; // Select tab @@ -144,6 +148,9 @@ bool FileTabManager::checkSave(unsigned tab) { bool FileTabManager::checkSaveAll() { + if (QSettings().value("Settings/SkipSaveConfirmation", false).toBool()) + return true; + bool all = false; try { diff --git a/src/camotics/qt/QtWin.cpp b/src/camotics/qt/QtWin.cpp index 3085c4c7..cc0430c7 100644 --- a/src/camotics/qt/QtWin.cpp +++ b/src/camotics/qt/QtWin.cpp @@ -1006,12 +1006,25 @@ bool QtWin::runNewProjectDialog() { // Initialize dialog newProjectDialog.setUnits(getDefaultUnits()); + // Skip dialog if configured + if (QSettings().value("Settings/SkipNewProjectDialog", false).toBool()) + return true; + // Run dialog return newProjectDialog.exec() == QDialog::Accepted; } GCode::ToolTable QtWin::getNewToolTable() { + // When dialog was skipped, use the configured default tool table + if (QSettings().value("Settings/SkipNewProjectDialog", false).toBool()) { + int toolTable = QSettings().value("Settings/DefaultToolTable", 0).toInt(); + if (toolTable == 0) return loadDefaultToolTable(); + if (toolTable == 1) + return project.isNull() ? GCode::ToolTable() : project->getTools(); + return GCode::ToolTable(); + } + if (newProjectDialog.defaultToolTableSelected()) return loadDefaultToolTable(); @@ -1333,6 +1346,9 @@ void QtWin::removeFile(unsigned index) { bool QtWin::checkSave(bool canCancel) { + if (QSettings().value("Settings/SkipSaveConfirmation", false).toBool()) + return true; + if (!ui->fileTabManager->checkSaveAll()) return false; if (project.isNull() || !project->isDirty()) return true; diff --git a/src/camotics/qt/SettingsDialog.cpp b/src/camotics/qt/SettingsDialog.cpp index a1a2be39..3d317d3b 100644 --- a/src/camotics/qt/SettingsDialog.cpp +++ b/src/camotics/qt/SettingsDialog.cpp @@ -138,6 +138,16 @@ void SettingsDialog::load(Project::Project &project, View &view) { ui.renderModeComboBox-> setCurrentIndex(settings.get("Settings/RenderMode", 0).toInt()); + // Dialog settings + bool skipNewProject = + settings.get("Settings/SkipNewProjectDialog", false).toBool(); + ui.skipNewProjectCheckBox->setChecked(skipNewProject); + ui.defaultToolTableComboBox->setEnabled(skipNewProject); + ui.defaultToolTableComboBox-> + setCurrentIndex(settings.get("Settings/DefaultToolTable", 0).toInt()); + ui.skipSaveConfirmCheckBox-> + setChecked(settings.get("Settings/SkipSaveConfirmation", false).toBool()); + ui.aabbCheckBox->setChecked(view.isFlagSet(View::SHOW_BBTREE_FLAG)); ui.aabbLeavesCheckBox->setChecked(view.isFlagSet(View::BBTREE_LEAVES_FLAG)); @@ -162,6 +172,14 @@ void SettingsDialog::save(Project::Project &project, View &view) { settings.set("Settings/RenderMode", ui.renderModeComboBox->currentIndex()); + // Dialog settings + settings.set("Settings/SkipNewProjectDialog", + ui.skipNewProjectCheckBox->isChecked()); + settings.set("Settings/DefaultToolTable", + ui.defaultToolTableComboBox->currentIndex()); + settings.set("Settings/SkipSaveConfirmation", + ui.skipSaveConfirmCheckBox->isChecked()); + view.setFlag(View::SHOW_BBTREE_FLAG, ui.aabbCheckBox->isChecked()); view.setFlag(View::BBTREE_LEAVES_FLAG, ui.aabbLeavesCheckBox->isChecked()); @@ -214,3 +232,8 @@ void SettingsDialog::on_resolutionDoubleSpinBox_valueChanged(double value) { void SettingsDialog::on_plannerEnableCheckBox_stateChanged(int checked) { ui.plannerGroupBox->setEnabled(checked); } + + +void SettingsDialog::on_skipNewProjectCheckBox_stateChanged(int checked) { + ui.defaultToolTableComboBox->setEnabled(checked); +} diff --git a/src/camotics/qt/SettingsDialog.h b/src/camotics/qt/SettingsDialog.h index 2747866f..dfd36ef0 100644 --- a/src/camotics/qt/SettingsDialog.h +++ b/src/camotics/qt/SettingsDialog.h @@ -80,5 +80,6 @@ namespace CAMotics { void on_resolutionComboBox_currentIndexChanged(int index); void on_resolutionDoubleSpinBox_valueChanged(double value); void on_plannerEnableCheckBox_stateChanged(int checked); + void on_skipNewProjectCheckBox_stateChanged(int checked); }; }