Skip to content

Commit

Permalink
Merge pull request #1588 from ghutchis/label-bug
Browse files Browse the repository at this point in the history
Fix bug with incorrect Unicode characters added to labels
  • Loading branch information
ghutchis authored Feb 1, 2024
2 parents 71be4ad + debb817 commit 424f2d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions avogadro/qtgui/extensionplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ public slots:
void requestActiveTool(QString toolName);

/**
* Request a specific display type (or types) are active, and all others are
* disabled. This can be useful when loading a specific type of data that
* Request a specific display type (or types) are made active.
* This can be useful when loading a specific type of data that
* would be most readily viewed with a specialized view.
*/
void requestActiveDisplayTypes(QStringList displayTypes);
Expand Down
7 changes: 7 additions & 0 deletions avogadro/qtgui/toolplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ class AVOGADROQTGUI_EXPORT ToolPlugin : public QObject
*/
void registerCommand(QString command, QString description);

/**
* Request a specific display type (or types) are made active.
* This can be useful when loading a specific type of data that
* would be most readily viewed with a specialized view.
*/
void requestActiveDisplayTypes(QStringList displayTypes);

public slots:
/**
* Called when the current molecule changes.
Expand Down
8 changes: 7 additions & 1 deletion avogadro/qtplugins/label/labeleditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <QAction>
#include <QKeyEvent>

#include <QDebug>

namespace Avogadro::QtPlugins {

using Core::Elements;
Expand Down Expand Up @@ -57,7 +59,7 @@ QUndoCommand* LabelEditor::keyPressEvent(QKeyEvent* e)
{
if (m_selected && !e->text().isEmpty()) {
e->accept();
auto text = e->text()[0];
const QChar text = e->text()[0];
if (text.isPrint()) {
m_text.append(text);
} else if (e->key() == Qt::Key_Backspace) {
Expand All @@ -77,6 +79,10 @@ void LabelEditor::save()
m_molecule->endMergeMode();
m_text.clear();
m_selectedAtom = RWAtom();

// make sure the label display is made active
qDebug() << "Requesting active display types";
emit requestActiveDisplayTypes(QStringList() << "Labels");
}

QUndoCommand* LabelEditor::mousePressEvent(QMouseEvent* e)
Expand Down

0 comments on commit 424f2d2

Please sign in to comment.