Import: Move options handling to ImportGui.importOptions

Currently a modal dialog is used directly in ImportGui.open()/ImportGui.insert() that makes it impossible to use the functions in a
script because they will be blocked
This commit is contained in:
wmayer
2024-06-18 13:50:05 +02:00
committed by Chris Hennes
parent c1e125194a
commit d49303a5dc
9 changed files with 215 additions and 49 deletions

View File

@@ -127,18 +127,6 @@ std::list<ImportExportSettings::CodePage> ImportExportSettings::getCodePageList(
return codePageList;
}
void ImportExportSettings::setReadShowDialogImport(bool on)
{
auto grp = pGroup->GetGroup("hSTEP");
grp->SetBool("ReadShowDialogImport", on);
}
bool ImportExportSettings::getReadShowDialogImport() const
{
auto grp = pGroup->GetGroup("hSTEP");
return grp->GetBool("ReadShowDialogImport", false);
}
#endif
void ImportExportSettings::initSTEP(Base::Reference<ParameterGrp> hGrp)

View File

@@ -103,9 +103,6 @@ public:
ImportMode getImportMode() const;
#if OCC_VERSION_HEX >= 0x070800
void setReadShowDialogImport(bool);
bool getReadShowDialogImport() const;
void setImportCodePage(int);
Resource_FormatType getImportCodePage() const;
std::list<ImportExportSettings::CodePage> getCodePageList() const;

View File

@@ -47,6 +47,15 @@ bool ImportExportSettings::isVisibleExportDialog() const
return pGroup->GetBool("VisibleExportDialog", true);
}
void ImportExportSettings::setVisibleImportDialog(bool on)
{
pGroup->SetBool("VisibleImportDialog", on);
}
bool ImportExportSettings::isVisibleImportDialog() const
{
return pGroup->GetBool("VisibleImportDialog", true);
}
void ImportExportSettings::setWriteSurfaceCurveMode(bool on)
{

View File

@@ -40,6 +40,9 @@ public:
void setVisibleExportDialog(bool);
bool isVisibleExportDialog() const;
void setVisibleImportDialog(bool);
bool isVisibleImportDialog() const;
void setWriteSurfaceCurveMode(bool);
bool getWriteSurfaceCurveMode() const;

View File

@@ -22,6 +22,10 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QDialogButtonBox>
#endif
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
#include <Mod/Part/App/STEP/ImportExportSettings.h>
@@ -45,7 +49,6 @@ DlgImportStep::DlgImportStep(QWidget* parent)
ui->checkBoxExpandCompound->setChecked(settings.getExpandCompound());
ui->checkBoxShowProgress->setChecked(settings.getShowProgress());
#if OCC_VERSION_HEX >= 0x070800
ui->checkBoxShowOnImport->setChecked(settings.getReadShowDialogImport());
std::list<Part::OCAF::ImportExportSettings::CodePage> codepagelist;
codepagelist = settings.getCodePageList();
for (const auto& codePage : codepagelist) {
@@ -54,10 +57,8 @@ DlgImportStep::DlgImportStep(QWidget* parent)
#else
// hide options that not supported in this OCCT version (7.8.0)
ui->label_6->hide();
ui->checkBoxShowOnImport->hide();
ui->comboBoxImportCodePage->hide();
#endif
}
/**
@@ -69,7 +70,6 @@ void DlgImportStep::saveSettings()
{
// (h)STEP of Import module
#if OCC_VERSION_HEX >= 0x070800
ui->checkBoxShowOnImport->onSave();
ui->comboBoxImportCodePage->onSave();
#endif
ui->checkBoxMergeCompound->onSave();
@@ -86,7 +86,6 @@ void DlgImportStep::loadSettings()
{
// (h)STEP of Import module
#if OCC_VERSION_HEX >= 0x070800
ui->checkBoxShowOnImport->onRestore();
ui->comboBoxImportCodePage->onRestore();
#endif
ui->checkBoxMergeCompound->onRestore();
@@ -99,6 +98,25 @@ void DlgImportStep::loadSettings()
ui->comboBoxImportMode->onRestore();
}
StepImportSettings DlgImportStep::getSettings() const
{
StepImportSettings set;
Part::OCAF::ImportExportSettings settings;
set.merge = settings.getReadShapeCompoundMode();
set.useLinkGroup = settings.getUseLinkGroup();
set.useBaseName = settings.getUseBaseName();
set.importHidden = settings.getImportHiddenObject();
set.reduceObjects = settings.getReduceObjects();
set.showProgress = settings.getShowProgress();
set.expandCompound = settings.getExpandCompound();
set.mode = static_cast<int>(settings.getImportMode());
#if OCC_VERSION_HEX >= 0x070800
Resource_FormatType cp = settings.getImportCodePage();
set.codePage = static_cast<int>(cp);
#endif
return set;
}
/**
* Sets the strings of the subwidgets using the current language.
*/
@@ -112,5 +130,57 @@ void DlgImportStep::changeEvent(QEvent *e)
}
}
// ----------------------------------------------------------------------------
TaskImportStep::TaskImportStep(QWidget* parent)
: QDialog(parent)
, ui(new DlgImportStep(this))
{
QApplication::setOverrideCursor(Qt::ArrowCursor);
ui->loadSettings();
setWindowTitle(ui->windowTitle());
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(ui.get());
setLayout(layout);
showThis = new QCheckBox(this);
showThis->setText(tr("Don't show this dialog again"));
layout->addWidget(showThis);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
layout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, this, &TaskImportStep::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &TaskImportStep::reject);
}
TaskImportStep::~TaskImportStep()
{
QApplication::restoreOverrideCursor();
}
void TaskImportStep::accept()
{
QDialog::accept();
ui->saveSettings();
Part::STEP::ImportExportSettings settings;
settings.setVisibleImportDialog(!showThis->isChecked());
}
bool TaskImportStep::showDialog() const
{
Part::STEP::ImportExportSettings settings;
return settings.isVisibleImportDialog();
}
StepImportSettings TaskImportStep::getSettings() const
{
return ui->getSettings();
}
#include "moc_DlgImportStep.cpp"

View File

@@ -24,13 +24,28 @@
#ifndef PARTGUI_DLGIMPORTSTEP_H
#define PARTGUI_DLGIMPORTSTEP_H
#include <Mod/Part/PartGlobal.h>
#include <Gui/PropertyPage.h>
#include <QDialog>
class QButtonGroup;
class QCheckBox;
namespace PartGui {
struct StepImportSettings
{
bool merge = false;
bool useLinkGroup = false;
bool useBaseName = true;
bool importHidden = true;
bool reduceObjects = false;
bool showProgress = false;
bool expandCompound = false;
int mode = 0;
int codePage = -1;
};
class Ui_DlgImportStep;
class DlgImportStep : public Gui::Dialog::PreferencePage
{
@@ -43,6 +58,8 @@ public:
void saveSettings() override;
void loadSettings() override;
StepImportSettings getSettings() const;
protected:
void changeEvent(QEvent *e) override;
@@ -50,6 +67,25 @@ private:
std::unique_ptr<Ui_DlgImportStep> ui;
};
// ----------------------------------------------------------------------------
class PartGuiExport TaskImportStep : public QDialog
{
Q_OBJECT
public:
explicit TaskImportStep(QWidget* parent = nullptr);
~TaskImportStep() override;
bool showDialog() const;
void accept() override;
StepImportSettings getSettings() const;
private:
QCheckBox* showThis;
std::unique_ptr<DlgImportStep> ui;
};
} // namespace PartGui
#endif // PARTGUI_DLGIMPORTSTEP_H

View File

@@ -20,22 +20,6 @@
<string>Import</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxShowOnImport">
<property name="toolTip">
<string>If checked, this Dialog will be shown during Import</string>
</property>
<property name="text">
<string>Show this Dialog when importing</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>ReadShowDialogImport</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Import/hSTEP</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxMergeCompound">
<property name="toolTip">