diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-04-15 06:18:30 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-04-15 06:18:30 (GMT) |
commit | 6c4b9cb575292f5f81afc772d993c1a53eb96ea5 (patch) | |
tree | f06be19545a6e7521707060c4d56eaeb2ba2c16e /tools/designer/src | |
parent | 3eb4aacf07c77876c6ce68e9746906424934433b (diff) | |
download | Qt-6c4b9cb575292f5f81afc772d993c1a53eb96ea5.zip Qt-6c4b9cb575292f5f81afc772d993c1a53eb96ea5.tar.gz Qt-6c4b9cb575292f5f81afc772d993c1a53eb96ea5.tar.bz2 |
Display QAction keyboard shortcuts in action editor correctly.
Use PropertySheetKeySequenceValue instead of plain strings.
Diffstat (limited to 'tools/designer/src')
5 files changed, 25 insertions, 13 deletions
diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp index 6a66442..7f96a15 100644 --- a/tools/designer/src/lib/shared/actioneditor.cpp +++ b/tools/designer/src/lib/shared/actioneditor.cpp @@ -456,7 +456,7 @@ void ActionEditor::slotNewAction() if (actionData.checkable) setInitialProperty(sheet, QLatin1String(checkablePropertyC), QVariant(true)); - if (!actionData.keysequence.isEmpty()) + if (!actionData.keysequence.value().isEmpty()) setInitialProperty(sheet, QLatin1String(shortcutPropertyC), qVariantFromValue(actionData.keysequence)); sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), qVariantFromValue(actionData.icon)); @@ -491,10 +491,10 @@ static QDesignerFormWindowCommand *setIconPropertyCommand(const PropertySheetIco // return a FormWindow command to apply a QKeySequence or a reset command // in case it is empty. -static QDesignerFormWindowCommand *setKeySequencePropertyCommand(const QKeySequence &ks, QAction *action, QDesignerFormWindowInterface *fw) +static QDesignerFormWindowCommand *setKeySequencePropertyCommand(const PropertySheetKeySequenceValue &ks, QAction *action, QDesignerFormWindowInterface *fw) { const QString shortcutProperty = QLatin1String(shortcutPropertyC); - if (ks.isEmpty()) { + if (ks.value().isEmpty()) { ResetPropertyCommand *cmd = new ResetPropertyCommand(fw); cmd->init(action, shortcutProperty); return cmd; @@ -544,7 +544,7 @@ void ActionEditor::editAction(QAction *action) oldActionData.text = action->text(); oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC)); oldActionData.icon = qVariantValue<PropertySheetIconValue>(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); - oldActionData.keysequence = qVariantValue<QKeySequence>(sheet->property(sheet->indexOf(QLatin1String(shortcutPropertyC)))); + oldActionData.keysequence = ActionModel::actionShortCut(sheet); oldActionData.checkable = action->isCheckable(); dlg.setActionData(oldActionData); diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp index 941a9ba..1b638c3 100644 --- a/tools/designer/src/lib/shared/actionrepository.cpp +++ b/tools/designer/src/lib/shared/actionrepository.cpp @@ -42,6 +42,7 @@ #include "actionrepository_p.h" #include "qtresourceview_p.h" #include "iconloader_p.h" +#include "qdesigner_utils_p.h" #include <QtDesigner/QDesignerFormEditorInterface> #include <QtDesigner/QDesignerPropertySheetExtension> @@ -168,16 +169,20 @@ QWidgetList ActionModel::associatedWidgets(const QAction *action) } // shortcut is a fake property, need to retrieve it via property sheet. -static QString actionShortCut(QDesignerFormEditorInterface *core, QAction *action) +PropertySheetKeySequenceValue ActionModel::actionShortCut(QDesignerFormEditorInterface *core, QAction *action) { QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), action); if (!sheet) - return QString(); + return PropertySheetKeySequenceValue(); + return actionShortCut(sheet); +} + +PropertySheetKeySequenceValue ActionModel::actionShortCut(const QDesignerPropertySheetExtension *sheet) +{ const int index = sheet->indexOf(QLatin1String("shortcut")); if (index == -1) - return QString(); - const QKeySequence keysequence = qvariant_cast<QKeySequence>(sheet->property(index)); - return keysequence.toString(); + return PropertySheetKeySequenceValue(); + return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index)); } void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QStandardItemList &sl) @@ -221,7 +226,7 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, item->setText(action->text()); item->setToolTip(action->text()); // shortcut - const QString shortcut = actionShortCut(core, action); + const QString shortcut = actionShortCut(core, action).value().toString(); item = sl[ShortCutColumn]; item->setText(shortcut); item->setToolTip(shortcut); diff --git a/tools/designer/src/lib/shared/actionrepository_p.h b/tools/designer/src/lib/shared/actionrepository_p.h index 9d1af5a..66d77ce 100644 --- a/tools/designer/src/lib/shared/actionrepository_p.h +++ b/tools/designer/src/lib/shared/actionrepository_p.h @@ -65,9 +65,12 @@ QT_BEGIN_NAMESPACE class QPixmap; class QDesignerFormEditorInterface; +class QDesignerPropertySheetExtension; namespace qdesigner_internal { +class PropertySheetKeySequenceValue; + // Shared model of actions, to be used for several views (detailed/icon view). class QDESIGNER_SHARED_EXPORT ActionModel: public QStandardItemModel { @@ -99,6 +102,10 @@ public: // Find the associated menus and toolbars, ignore toolbuttons static QWidgetList associatedWidgets(const QAction *action); + // Retrieve shortcut via property sheet as it is a fake property + static PropertySheetKeySequenceValue actionShortCut(QDesignerFormEditorInterface *core, QAction *action); + static PropertySheetKeySequenceValue actionShortCut(const QDesignerPropertySheetExtension *ps); + signals: void resourceImageDropped(const QString &path, QAction *action); diff --git a/tools/designer/src/lib/shared/newactiondialog.cpp b/tools/designer/src/lib/shared/newactiondialog.cpp index 53aec4b..bb163d6 100644 --- a/tools/designer/src/lib/shared/newactiondialog.cpp +++ b/tools/designer/src/lib/shared/newactiondialog.cpp @@ -134,7 +134,7 @@ ActionData NewActionDialog::actionData() const rc.toolTip = m_ui->tooltipEditor->text(); rc.icon = m_ui->iconSelector->icon(); rc.checkable = m_ui->checkableCheckBox->checkState() == Qt::Checked; - rc.keysequence = m_ui->keySequenceEdit->keySequence(); + rc.keysequence = PropertySheetKeySequenceValue(m_ui->keySequenceEdit->keySequence()); return rc; } @@ -144,7 +144,7 @@ void NewActionDialog::setActionData(const ActionData &d) m_ui->editObjectName->setText(d.name); m_ui->iconSelector->setIcon(d.icon); m_ui->tooltipEditor->setText(d.toolTip); - m_ui->keySequenceEdit->setKeySequence(d.keysequence); + m_ui->keySequenceEdit->setKeySequence(d.keysequence.value()); m_ui->checkableCheckBox->setCheckState(d.checkable ? Qt::Checked : Qt::Unchecked); m_auto_update_object_name = false; diff --git a/tools/designer/src/lib/shared/newactiondialog_p.h b/tools/designer/src/lib/shared/newactiondialog_p.h index c8bd34c..d4e9b5b 100644 --- a/tools/designer/src/lib/shared/newactiondialog_p.h +++ b/tools/designer/src/lib/shared/newactiondialog_p.h @@ -84,7 +84,7 @@ struct ActionData { QString toolTip; PropertySheetIconValue icon; bool checkable; - QKeySequence keysequence; + PropertySheetKeySequenceValue keysequence; }; inline bool operator==(const ActionData &a1, const ActionData &a2) { return a1.compare(a2) == 0u; } |