Qt Designer: Suppress updating of QAction's object name when editing existing actions.
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Tue, 3 Mar 2015 12:29:10 +0000 (13:29 +0100)
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Thu, 9 Apr 2015 07:47:06 +0000 (07:47 +0000)
Suppress the updating on clearing the text for existing actions
that have non-empty names initially.

Task-number: QTBUG-44778
Change-Id: Iedf59d5c8ac2ca356ed86774de677c6faf08afc7
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
src/designer/src/lib/shared/newactiondialog.cpp
src/designer/src/lib/shared/newactiondialog_p.h

index 9d418df..bc90b67 100644 (file)
@@ -78,7 +78,8 @@ unsigned ActionData::compare(const ActionData &rhs) const
 NewActionDialog::NewActionDialog(ActionEditor *parent) :
     QDialog(parent, Qt::Sheet),
     m_ui(new Ui::NewActionDialog),
-    m_actionEditor(parent)
+    m_actionEditor(parent),
+    m_autoUpdateObjectName(true)
 {
     m_ui->setupUi(this);
 
@@ -90,7 +91,6 @@ NewActionDialog::NewActionDialog(ActionEditor *parent) :
 
     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
     m_ui->editActionText->setFocus();
-    m_auto_update_object_name = true;
     updateButtons();
 
     QDesignerFormWindowInterface *form = parent->formWindow();
@@ -141,16 +141,14 @@ void NewActionDialog::setActionData(const ActionData &d)
     m_ui->keySequenceEdit->setKeySequence(d.keysequence.value());
     m_ui->checkableCheckBox->setCheckState(d.checkable ? Qt::Checked : Qt::Unchecked);
 
-    m_auto_update_object_name = false;
+    // Suppress updating of the object name from the text for existing actions.
+    m_autoUpdateObjectName = d.name.isEmpty();
     updateButtons();
 }
 
 void NewActionDialog::on_editActionText_textEdited(const QString &text)
 {
-    if (text.isEmpty())
-        m_auto_update_object_name = true;
-
-    if (m_auto_update_object_name)
+    if (m_autoUpdateObjectName)
         m_ui->editObjectName->setText(ActionEditor::actionTextToName(text));
 
     updateButtons();
@@ -159,7 +157,7 @@ void NewActionDialog::on_editActionText_textEdited(const QString &text)
 void NewActionDialog::on_editObjectName_textEdited(const QString&)
 {
     updateButtons();
-    m_auto_update_object_name = false;
+    m_autoUpdateObjectName = false;
 }
 
 void NewActionDialog::slotEditToolTip()
index 79c10e9..5281795 100644 (file)
@@ -104,7 +104,7 @@ private slots:
 private:
     Ui::NewActionDialog *m_ui;
     ActionEditor *m_actionEditor;
-    bool m_auto_update_object_name;
+    bool m_autoUpdateObjectName;
 
     void updateButtons();
 };