Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to cancel "Insert SMILES" #1969

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions avogadro/qtplugins/lineformatinput/lineformatinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ using Avogadro::QtGui::FileFormatDialog;
namespace Avogadro::QtPlugins {

LineFormatInput::LineFormatInput(QObject* parent_)
: Avogadro::QtGui::ExtensionPlugin(parent_),
m_molecule(nullptr), m_reader(nullptr)
: Avogadro::QtGui::ExtensionPlugin(parent_), m_molecule(nullptr),
m_reader(nullptr)
{
auto* action = new QAction(tr("SMILES…"), this);
action->setProperty("menu priority", 800);
Expand Down Expand Up @@ -98,7 +98,8 @@ void LineFormatInput::showDialog()
dlg.exec();

// check if the reply is empty
if (dlg.descriptor().isEmpty())
if (dlg.result() != LineFormatInputDialog::Accepted ||
dlg.descriptor().isEmpty())
return; // nothing to do

// Resolve any format conflicts:
Expand Down Expand Up @@ -137,4 +138,4 @@ void LineFormatInput::showDialog()
m_reader = nullptr;
}

} // namespace Avogadro
} // namespace Avogadro::QtPlugins
14 changes: 13 additions & 1 deletion avogadro/qtplugins/lineformatinput/lineformatinputdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ LineFormatInputDialog::LineFormatInputDialog(QWidget* aParent)
: QDialog(aParent), m_ui(new Ui::LineFormatInputDialog)
{
m_ui->setupUi(this);

QSettings settings;
// set the last used descriptor
QString lastDescriptor =
settings.value("lineformatinput/lastDescriptor").toString();
setDescriptor(lastDescriptor);
}

LineFormatInputDialog::~LineFormatInputDialog()
Expand Down Expand Up @@ -45,6 +51,11 @@ void LineFormatInputDialog::setCurrentFormat(const QString& format)
m_ui->formats->setCurrentIndex(index);
}

void LineFormatInputDialog::setDescriptor(const QString& descriptor)
{
m_ui->descriptor->setText(descriptor);
}

QString LineFormatInputDialog::descriptor() const
{
return m_ui->descriptor->text();
Expand All @@ -54,7 +65,8 @@ void LineFormatInputDialog::accept()
{
QSettings settings;
settings.setValue("lineformatinput/lastUsed", format());
settings.setValue("lineformatinput/lastDescriptor", descriptor());
QDialog::accept();
}

} // namespace Avogadro
} // namespace Avogadro::QtPlugins
2 changes: 2 additions & 0 deletions avogadro/qtplugins/lineformatinput/lineformatinputdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class LineFormatInputDialog : public QDialog

void setCurrentFormat(const QString& format);

void setDescriptor(const QString& descriptor);

QString descriptor() const;

protected slots:
Expand Down
Loading