summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-04-15 09:19:56 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-04-15 09:19:56 (GMT)
commit21099dac569348a15df2d6a5a61015b5afa17097 (patch)
treeb4ae338f206666b7f07e1f78278ad6d38609880b /tools/designer/src/lib
parentf169ca1020886707b04101300e365d79f38a6332 (diff)
parent4e78de5a4281bd1c27a984b13887975798573aae (diff)
downloadQt-21099dac569348a15df2d6a5a61015b5afa17097.zip
Qt-21099dac569348a15df2d6a5a61015b5afa17097.tar.gz
Qt-21099dac569348a15df2d6a5a61015b5afa17097.tar.bz2
Merge commit 'origin/4.5'
Conflicts: src/gui/graphicsview/qgraphicsitem.cpp
Diffstat (limited to 'tools/designer/src/lib')
-rw-r--r--tools/designer/src/lib/shared/actioneditor.cpp8
-rw-r--r--tools/designer/src/lib/shared/actionrepository.cpp17
-rw-r--r--tools/designer/src/lib/shared/actionrepository_p.h7
-rw-r--r--tools/designer/src/lib/shared/newactiondialog.cpp4
-rw-r--r--tools/designer/src/lib/shared/newactiondialog_p.h2
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 d29643d..e60b212 100644
--- a/tools/designer/src/lib/shared/actioneditor.cpp
+++ b/tools/designer/src/lib/shared/actioneditor.cpp
@@ -452,7 +452,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));
@@ -487,10 +487,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;
@@ -540,7 +540,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; }