diff --git a/avogadro/io/cjsonformat.cpp b/avogadro/io/cjsonformat.cpp index 52bcf06354..3c32446f44 100644 --- a/avogadro/io/cjsonformat.cpp +++ b/avogadro/io/cjsonformat.cpp @@ -667,11 +667,18 @@ bool CjsonFormat::deserialize(std::istream& file, Molecule& molecule, // std::cout << " property: " << element.key() << " = " << matrix // << " size " << matrix.rows() << 'x' << matrix.cols() // << std::endl; + } else if (element.value().type() == json::value_t::number_float) { + molecule.setData(element.key(), element.value().get()); + } else if (element.value().type() == json::value_t::number_integer) { + molecule.setData(element.key(), element.value().get()); + } else if (element.value().type() == json::value_t::boolean) { + molecule.setData(element.key(), element.value().get()); + } else if (element.value().type() == json::value_t::string) { + molecule.setData(element.key(), element.value().get()); } else { - molecule.setData(element.key(), element.value()); - // std::cout << " property: " << element.key() << " = " - // << element.value() << " type " - // << element.value().type_name() << std::endl; + std::cout << " cannot store property: " << element.key() << " = " + << element.value() << " type " + << element.value().type_name() << std::endl; } } } diff --git a/avogadro/qtplugins/label/labeleditor.cpp b/avogadro/qtplugins/label/labeleditor.cpp index b26107eb24..4a0fdeecd8 100644 --- a/avogadro/qtplugins/label/labeleditor.cpp +++ b/avogadro/qtplugins/label/labeleditor.cpp @@ -32,7 +32,8 @@ LabelEditor::LabelEditor(QObject* parent_) m_activateAction->setText(tr("Edit Labels")); m_activateAction->setToolTip( tr("Atom Label Tool \t(%1)\n\n" - "Left Mouse: \tClick on Atoms to add Custom Labels").arg(shortcut)); + "Left Mouse: \tClick on Atoms to add Custom Labels") + .arg(shortcut)); setIcon(); } @@ -46,13 +47,15 @@ void LabelEditor::setIcon(bool darkTheme) m_activateAction->setIcon(QIcon(":/icons/label_light.svg")); } -QUndoCommand* LabelEditor::mouseReleaseEvent(QMouseEvent*) +QUndoCommand* LabelEditor::mouseReleaseEvent(QMouseEvent* e) { + e->ignore(); return nullptr; } -QUndoCommand* LabelEditor::mouseMoveEvent(QMouseEvent*) +QUndoCommand* LabelEditor::mouseMoveEvent(QMouseEvent* e) { + e->ignore(); return nullptr; } @@ -82,7 +85,6 @@ void LabelEditor::save() m_selectedAtom = RWAtom(); // make sure the label display is made active - qDebug() << "Requesting active display types"; emit requestActiveDisplayTypes(QStringList() << "Labels"); } @@ -92,18 +94,25 @@ QUndoCommand* LabelEditor::mousePressEvent(QMouseEvent* e) return nullptr; if (e->buttons() & Qt::LeftButton) { - e->accept(); if (m_selectedAtom.isValid()) { + e->accept(); save(); + emit drawablesChanged(); } Identifier clickedObject = m_renderer->hit(e->pos().x(), e->pos().y()); m_selected = (clickedObject.type == Rendering::AtomType); if (m_selected) { + e->accept(); m_selectedAtom = m_molecule->atom(clickedObject.index); m_text = QString::fromStdString(m_selectedAtom.label()); + emit drawablesChanged(); + } else { + // clicked on empty space + e->ignore(); } - emit drawablesChanged(); + } else { + e->ignore(); } return nullptr; diff --git a/avogadro/qtplugins/manipulator/manipulator.cpp b/avogadro/qtplugins/manipulator/manipulator.cpp index 07eb04e84a..5eeeb9b761 100644 --- a/avogadro/qtplugins/manipulator/manipulator.cpp +++ b/avogadro/qtplugins/manipulator/manipulator.cpp @@ -51,7 +51,8 @@ Manipulator::Manipulator(QObject* parent_) m_activateAction->setToolTip( tr("Manipulation Tool \t(%1)\n\n" "Left Mouse: \tClick and drag to move atoms\n" - "Right Mouse: \tClick and drag to rotate atoms.\n").arg(shortcut)); + "Right Mouse: \tClick and drag to rotate atoms.\n") + .arg(shortcut)); setIcon(); connect(m_toolWidget->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); @@ -235,10 +236,17 @@ QUndoCommand* Manipulator::mouseReleaseEvent(QMouseEvent* e) QUndoCommand* Manipulator::mouseMoveEvent(QMouseEvent* e) { + // if we're dragging through empty space, just return and ignore + // (e.g., fall back to the navigate tool) + const Core::Molecule* mol = &m_molecule->molecule(); + if (mol->isSelectionEmpty() && m_object.type == Rendering::InvalidType) { + e->ignore(); + return nullptr; + } + updatePressedButtons(e, false); e->ignore(); - const Core::Molecule* mol = &m_molecule->molecule(); Vector2f windowPos(e->localPos().x(), e->localPos().y()); if (mol->isSelectionEmpty() && m_object.type == Rendering::AtomType &&