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

Fix bug with incorrect Unicode characters added to labels #1588

Merged
merged 1 commit into from Feb 1, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions avogadro/qtgui/extensionplugin.h
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
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
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